(function (_, kotlin_kotlin, kotlin_io_github_aakira_napier, kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core, kotlin_org_jetbrains_kotlinx_atomicfu, kotlin_org_jetbrains_kotlinx_kotlinx_serialization_core, kotlin_io_ktor_ktor_http, kotlin_io_ktor_ktor_utils, kotlin_io_ktor_ktor_client_core, kotlin_org_jetbrains_kotlinx_kotlinx_serialization_json, kotlin_app_cash_paging_paging_common, kotlin_io_ktor_ktor_io) {
  'use strict';
  //region block: imports
  var imul = Math.imul;
  var protoOf = kotlin_kotlin.$_$.vf;
  var interfaceMeta = kotlin_kotlin.$_$.we;
  var setMetadataFor = kotlin_kotlin.$_$.wf;
  var Exception = kotlin_kotlin.$_$.ul;
  var Unit_getInstance = kotlin_kotlin.$_$.g6;
  var classMeta = kotlin_kotlin.$_$.ge;
  var VOID = kotlin_kotlin.$_$.g;
  var indexOf = kotlin_kotlin.$_$.si;
  var StringBuilder_init_$Create$ = kotlin_kotlin.$_$.m1;
  var _Char___init__impl__6a9atx = kotlin_kotlin.$_$.m3;
  var objectMeta = kotlin_kotlin.$_$.uf;
  var LinkedHashMap_init_$Create$ = kotlin_kotlin.$_$.a1;
  var THROW_CCE = kotlin_kotlin.$_$.fm;
  var IllegalStateException_init_$Create$ = kotlin_kotlin.$_$.l2;
  var isInterface = kotlin_kotlin.$_$.ff;
  var Long = kotlin_kotlin.$_$.yl;
  var getKClassFromExpression = kotlin_kotlin.$_$.d;
  var CoroutineImpl = kotlin_kotlin.$_$.nd;
  var get_COROUTINE_SUSPENDED = kotlin_kotlin.$_$.yc;
  var CancellationException = kotlin_kotlin.$_$.xc;
  var SuspendFunction1 = kotlin_kotlin.$_$.pd;
  var Napier_getInstance = kotlin_io_github_aakira_napier.$_$.g;
  var ArrayList_init_$Create$ = kotlin_kotlin.$_$.q;
  var removeAll = kotlin_kotlin.$_$.kb;
  var listOf = kotlin_kotlin.$_$.qa;
  var collectionSizeOrDefault = kotlin_kotlin.$_$.z7;
  var ArrayList_init_$Create$_0 = kotlin_kotlin.$_$.p;
  var checkIndexOverflow = kotlin_kotlin.$_$.x7;
  var listOf_0 = kotlin_kotlin.$_$.ra;
  var plus = kotlin_kotlin.$_$.gb;
  var flatten = kotlin_kotlin.$_$.s9;
  var joinToString = kotlin_kotlin.$_$.ca;
  var toList = kotlin_kotlin.$_$.kc;
  var CoroutineScope = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.h2;
  var get = kotlin_kotlin.$_$.id;
  var fold = kotlin_kotlin.$_$.hd;
  var minusKey = kotlin_kotlin.$_$.jd;
  var plus_0 = kotlin_kotlin.$_$.md;
  var Element = kotlin_kotlin.$_$.kd;
  var Key = kotlin_kotlin.$_$.ld;
  var toSet = kotlin_kotlin.$_$.qc;
  var toLong = kotlin_kotlin.$_$.yf;
  var withTimeout = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.r;
  var withContext = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.p;
  var launch = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.z2;
  var NonCancellable_getInstance = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.f1;
  var Dispatchers_getInstance = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.c1;
  var atomic$int$1 = kotlin_org_jetbrains_kotlinx_atomicfu.$_$.f;
  var Mutex = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.z1;
  var atomic$boolean$1 = kotlin_org_jetbrains_kotlinx_atomicfu.$_$.c;
  var Job = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.l2;
  var CoroutineScope_0 = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.g2;
  var cancel = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.u2;
  var to = kotlin_kotlin.$_$.xn;
  var mapOf = kotlin_kotlin.$_$.ua;
  var toMap = kotlin_kotlin.$_$.mc;
  var IntCompanionObject_getInstance = kotlin_kotlin.$_$.r5;
  var numberToLong = kotlin_kotlin.$_$.sf;
  var delay = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.n;
  var atomic$long$1 = kotlin_org_jetbrains_kotlinx_atomicfu.$_$.d;
  var numberToInt = kotlin_kotlin.$_$.rf;
  var LazyThreadSafetyMode_NONE_getInstance = kotlin_kotlin.$_$.l;
  var lazy = kotlin_kotlin.$_$.hn;
  var ensureNotNull = kotlin_kotlin.$_$.an;
  var KProperty1 = kotlin_kotlin.$_$.fh;
  var getPropertyCallableRef = kotlin_kotlin.$_$.se;
  var RuntimeException = kotlin_kotlin.$_$.em;
  var RuntimeException_init_$Init$ = kotlin_kotlin.$_$.z2;
  var captureStack = kotlin_kotlin.$_$.ae;
  var getStringHashCode = kotlin_kotlin.$_$.te;
  var getBooleanHashCode = kotlin_kotlin.$_$.oe;
  var PluginGeneratedSerialDescriptor = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_core.$_$.x2;
  var LongSerializer_getInstance = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_core.$_$.w;
  var UnknownFieldException_init_$Create$ = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_core.$_$.g;
  var typeParametersSerializers = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_core.$_$.r2;
  var GeneratedSerializer = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_core.$_$.s2;
  var throwMissingFieldException = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_core.$_$.c3;
  var objectCreate = kotlin_kotlin.$_$.tf;
  var Annotation = kotlin_kotlin.$_$.il;
  var THROW_IAE = kotlin_kotlin.$_$.gm;
  var enumEntries = kotlin_kotlin.$_$.td;
  var Enum = kotlin_kotlin.$_$.sl;
  var contentEquals = kotlin_kotlin.$_$.f8;
  var hashCode = kotlin_kotlin.$_$.ue;
  var toString = kotlin_kotlin.$_$.ag;
  var IllegalArgumentException_init_$Create$ = kotlin_kotlin.$_$.f2;
  var NoSuchElementException_init_$Create$ = kotlin_kotlin.$_$.s2;
  var Application_getInstance = kotlin_io_ktor_ktor_http.$_$.c;
  var TextContent = kotlin_io_ktor_ktor_http.$_$.r;
  var JsType_getInstance = kotlin_io_ktor_ktor_utils.$_$.b;
  var getKClass = kotlin_kotlin.$_$.e;
  var arrayOf = kotlin_kotlin.$_$.um;
  var createKType = kotlin_kotlin.$_$.b;
  var typeInfoImpl = kotlin_io_ktor_ktor_utils.$_$.k;
  var OutgoingContent = kotlin_io_ktor_ktor_http.$_$.q;
  var NullBody_getInstance = kotlin_io_ktor_ktor_http.$_$.b;
  var header = kotlin_io_ktor_ktor_client_core.$_$.e;
  var takeFrom = kotlin_io_ktor_ktor_http.$_$.l1;
  var get_encodedPath = kotlin_io_ktor_ktor_http.$_$.g1;
  var set_encodedPath = kotlin_io_ktor_ktor_http.$_$.h1;
  var equals = kotlin_kotlin.$_$.ke;
  var toList_0 = kotlin_kotlin.$_$.jc;
  var get_jsonPrimitive = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_json.$_$.x;
  var JsonNull = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_json.$_$.k;
  var get_boolean = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_json.$_$.r;
  var get_double = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_json.$_$.s;
  var get_float = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_json.$_$.t;
  var get_long = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_json.$_$.y;
  var get_int = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_json.$_$.u;
  var toShort = kotlin_kotlin.$_$.zf;
  var JsonPrimitive = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_json.$_$.n;
  var JsonPrimitive_0 = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_json.$_$.o;
  var JsonNull_getInstance = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_json.$_$.d;
  var mapCapacity = kotlin_kotlin.$_$.sa;
  var coerceAtLeast = kotlin_kotlin.$_$.ng;
  var LinkedHashMap_init_$Create$_0 = kotlin_kotlin.$_$.z;
  var JsonObject = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_json.$_$.l;
  var JsonPrimitive_1 = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_json.$_$.m;
  var Regex_init_$Create$ = kotlin_kotlin.$_$.k1;
  var KProperty0 = kotlin_kotlin.$_$.eh;
  var RegexOption_IGNORE_CASE_getInstance = kotlin_kotlin.$_$.h;
  var Regex_init_$Create$_0 = kotlin_kotlin.$_$.l1;
  var LogLevel_VERBOSE_getInstance = kotlin_io_github_aakira_napier.$_$.e;
  var LogLevel_DEBUG_getInstance = kotlin_io_github_aakira_napier.$_$.b;
  var LogLevel_INFO_getInstance = kotlin_io_github_aakira_napier.$_$.d;
  var LogLevel_WARNING_getInstance = kotlin_io_github_aakira_napier.$_$.f;
  var LogLevel_ERROR_getInstance = kotlin_io_github_aakira_napier.$_$.c;
  var LogLevel_ASSERT_getInstance = kotlin_io_github_aakira_napier.$_$.a;
  var noWhenBranchMatchedException = kotlin_kotlin.$_$.jn;
  var ArrayListSerializer = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_core.$_$.p2;
  var IntSerializer_getInstance = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_core.$_$.v;
  var MutableSharedFlow = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.l1;
  var asSharedFlow = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.n1;
  var PagingSource = kotlin_app_cash_paging_paging_common.$_$.e;
  var Invalid = kotlin_app_cash_paging_paging_common.$_$.b;
  var firstOrNull = kotlin_kotlin.$_$.l9;
  var emptyList = kotlin_kotlin.$_$.d9;
  var first = kotlin_kotlin.$_$.p9;
  var JsonObjectSerializer_getInstance = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_json.$_$.f;
  var toString_0 = kotlin_kotlin.$_$.wn;
  var List = kotlin_kotlin.$_$.z6;
  var Collection = kotlin_kotlin.$_$.p6;
  var FlowCollector = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.j1;
  var get_isActive = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.x2;
  var HttpRequestBuilder = kotlin_io_ktor_ktor_client_core.$_$.d;
  var Companion_getInstance = kotlin_io_ktor_ktor_http.$_$.j;
  var HttpStatement = kotlin_io_ktor_ktor_client_core.$_$.i;
  var toLong_0 = kotlin_kotlin.$_$.qk;
  var contentType = kotlin_io_ktor_ktor_http.$_$.f1;
  var bodyAsText = kotlin_io_ktor_ktor_client_core.$_$.a;
  var Companion_getInstance_0 = kotlin_io_ktor_ktor_http.$_$.k;
  var MutableStateFlow = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.m1;
  var asStateFlow = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.o1;
  var Default_getInstance = kotlin_kotlin.$_$.u5;
  var Channel = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.g1;
  var CompletableDeferred = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.b2;
  var numberRangeToNumber = kotlin_kotlin.$_$.nf;
  var trimIndent = kotlin_kotlin.$_$.zk;
  var joinToString_0 = kotlin_kotlin.$_$.da;
  var ChannelResult__getOrThrow_impl_od1axs = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.w;
  var _ChannelResult___get_isSuccess__impl__odq1z9 = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.x;
  var atomic$ref$1 = kotlin_org_jetbrains_kotlinx_atomicfu.$_$.e;
  var Factory_getInstance = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.y;
  var GlobalScope_getInstance = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.d1;
  var startsWith = kotlin_kotlin.$_$.rj;
  var substringAfter = kotlin_kotlin.$_$.wj;
  var get_js = kotlin_kotlin.$_$.jf;
  var copyToArray = kotlin_kotlin.$_$.z8;
  var compareTo = kotlin_kotlin.$_$.he;
  var addAll = kotlin_kotlin.$_$.l7;
  var substringAfterLast = kotlin_kotlin.$_$.uj;
  var Json = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_json.$_$.p;
  var plus_1 = kotlin_kotlin.$_$.bb;
  var putAll = kotlin_kotlin.$_$.ib;
  var Exception_init_$Init$ = kotlin_kotlin.$_$.z1;
  var NotImplementedError = kotlin_kotlin.$_$.am;
  var newThrowable = kotlin_kotlin.$_$.mf;
  var Exception_init_$Create$ = kotlin_kotlin.$_$.y1;
  var Companion_getInstance_1 = kotlin_kotlin.$_$.x5;
  var json = kotlin_kotlin.$_$.kf;
  var toInt = kotlin_kotlin.$_$.nk;
  var cancel_0 = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.s2;
  var SuspendFunction0 = kotlin_kotlin.$_$.od;
  var isByteArray = kotlin_kotlin.$_$.ze;
  var ClosedRange = kotlin_kotlin.$_$.kg;
  var contains = kotlin_kotlin.$_$.vg;
  var indexOf_0 = kotlin_kotlin.$_$.w9;
  var first_0 = kotlin_kotlin.$_$.r9;
  var toByte = kotlin_kotlin.$_$.hk;
  var toShort_0 = kotlin_kotlin.$_$.rk;
  var toDouble = kotlin_kotlin.$_$.kk;
  var Charsets_getInstance = kotlin_io_ktor_ktor_io.$_$.f;
  var encodeToByteArray = kotlin_kotlin.$_$.ki;
  var encodeToByteArray_0 = kotlin_io_ktor_ktor_io.$_$.j;
  //endregion
  //region block: pre-declaration
  setMetadataFor(DoorQuery, 'DoorQuery', interfaceMeta);
  setMetadataFor(DoorSqlDatabase, 'DoorSqlDatabase', interfaceMeta);
  setMetadataFor(DoorSqlDatabaseConnectionImpl, 'DoorSqlDatabaseConnectionImpl', classMeta, VOID, [DoorSqlDatabase]);
  setMetadataFor(Companion, 'Companion', objectMeta);
  setMetadataFor(Statement, 'Statement', interfaceMeta, VOID, VOID, VOID, VOID, VOID, [1]);
  setMetadataFor(PreparedStatement, 'PreparedStatement', interfaceMeta, VOID, [Statement], VOID, VOID, VOID, [0, 1]);
  setMetadataFor(PreparedStatementArrayProxyCommon, 'PreparedStatementArrayProxyCommon', classMeta, VOID, [PreparedStatement], VOID, VOID, VOID, [0, 1]);
  setMetadataFor(ResultSet, 'ResultSet', interfaceMeta);
  setMetadataFor(PreparedStatementResultSetWrapper, 'PreparedStatementResultSetWrapper', classMeta, VOID, [ResultSet]);
  setMetadataFor(prepareAndUseStatementAsync$slambda, 'prepareAndUseStatementAsync$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor($prepareAndUseStatementAsyncCOROUTINE$0, '$prepareAndUseStatementAsyncCOROUTINE$0', classMeta, CoroutineImpl);
  setMetadataFor(Companion_0, 'Companion', objectMeta);
  setMetadataFor($setupSqliteTriggersAsyncCOROUTINE$1, '$setupSqliteTriggersAsyncCOROUTINE$1', classMeta, CoroutineImpl);
  setMetadataFor($findChangedTablesOnConnectionAsyncCOROUTINE$2, '$findChangedTablesOnConnectionAsyncCOROUTINE$2', classMeta, CoroutineImpl);
  setMetadataFor(InvalidationTracker, 'InvalidationTracker', classMeta, VOID, VOID, VOID, VOID, VOID, [1]);
  setMetadataFor(InvalidationTrackerObserver, 'InvalidationTrackerObserver', classMeta);
  setMetadataFor(RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda, 'RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor(RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda_1, 'RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor(RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda_3, 'RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor(Listener, 'Listener', interfaceMeta, VOID, VOID, VOID, VOID, VOID, [3]);
  setMetadataFor(TransactionElement, 'TransactionElement', classMeta, VOID, [Element]);
  setMetadataFor(Key_0, 'Key', objectMeta, VOID, [Key]);
  setMetadataFor(RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda, 'RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor(RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda_1, 'RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor(RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda_3, 'RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor(RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda, 'RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor($useNewConnectionAsyncInternalCOROUTINE$3, '$useNewConnectionAsyncInternalCOROUTINE$3', classMeta, CoroutineImpl);
  setMetadataFor(RoomDatabaseJdbcImplHelperCommon, 'RoomDatabaseJdbcImplHelperCommon', classMeta, VOID, VOID, VOID, VOID, VOID, [0, 2, 1]);
  setMetadataFor(RoomJdbcImpl, 'RoomJdbcImpl', interfaceMeta);
  setMetadataFor($dropDoorTriggersAndReceiveViewsSqliteCOROUTINE$4, '$dropDoorTriggersAndReceiveViewsSqliteCOROUTINE$4', classMeta, CoroutineImpl);
  setMetadataFor($getSqliteDoorTriggerNamesCOROUTINE$5, '$getSqliteDoorTriggerNamesCOROUTINE$5', classMeta, CoroutineImpl);
  setMetadataFor($getSqliteDoorReceiveViewNamesCOROUTINE$6, '$getSqliteDoorReceiveViewNamesCOROUTINE$6', classMeta, CoroutineImpl);
  setMetadataFor(DoorConstants, 'DoorConstants', objectMeta);
  setMetadataFor(DoorDatabaseCallback, 'DoorDatabaseCallback', interfaceMeta);
  setMetadataFor(DoorDatabaseCallbackStatementList, 'DoorDatabaseCallbackStatementList', interfaceMeta, VOID, [DoorDatabaseCallback]);
  setMetadataFor(DoorDatabaseCallbackSync, 'DoorDatabaseCallbackSync', interfaceMeta, VOID, [DoorDatabaseCallback]);
  setMetadataFor(DoorDatabaseJdbc, 'DoorDatabaseJdbc', interfaceMeta);
  setMetadataFor(DoorDatabaseRepository, 'DoorDatabaseRepository', interfaceMeta);
  setMetadataFor(Companion_1, 'Companion', objectMeta);
  setMetadataFor(DoorDatabaseWrapper, 'DoorDatabaseWrapper', interfaceMeta);
  setMetadataFor(Companion_2, 'Companion', objectMeta);
  setMetadataFor(DoorDbType, 'DoorDbType', classMeta, VOID, VOID, DoorDbType);
  setMetadataFor($nextIdAsyncCOROUTINE$7, '$nextIdAsyncCOROUTINE$7', classMeta, CoroutineImpl);
  setMetadataFor(TablePrimaryKeyManager, 'TablePrimaryKeyManager', classMeta, VOID, VOID, VOID, VOID, VOID, [0]);
  setMetadataFor(Companion_3, 'Companion', objectMeta);
  setMetadataFor(DoorPrimaryKeyManager, 'DoorPrimaryKeyManager', classMeta, VOID, VOID, VOID, VOID, VOID, [1]);
  setMetadataFor(Array_0, 'Array', interfaceMeta);
  setMetadataFor(JdbcArrayProxyCommon, 'JdbcArrayProxyCommon', classMeta, VOID, [Array_0]);
  setMetadataFor(NotSupportedException, 'NotSupportedException', classMeta, RuntimeException, VOID, NotSupportedException);
  setMetadataFor(Companion_4, 'Companion', objectMeta);
  setMetadataFor(PreparedStatementConfig, 'PreparedStatementConfig', classMeta);
  setMetadataFor(Companion_5, 'Companion', objectMeta);
  setMetadataFor($serializer, '$serializer', objectMeta, VOID, [GeneratedSerializer]);
  setMetadataFor(SyncNode, 'SyncNode', classMeta, VOID, VOID, SyncNode, VOID, {0: $serializer_getInstance});
  setMetadataFor(AttachmentMd5, 'AttachmentMd5', classMeta, VOID, [Annotation]);
  setMetadataFor(AttachmentSize, 'AttachmentSize', classMeta, VOID, [Annotation]);
  setMetadataFor(AttachmentUri, 'AttachmentUri', classMeta, VOID, [Annotation]);
  setMetadataFor(EntityWithAttachment, 'EntityWithAttachment', classMeta, VOID, [Annotation]);
  setMetadataFor(LastChangedBy, 'LastChangedBy', classMeta, VOID, [Annotation]);
  setMetadataFor(LocalChangeSeqNum, 'LocalChangeSeqNum', classMeta, VOID, [Annotation]);
  setMetadataFor(MasterChangeSeqNum, 'MasterChangeSeqNum', classMeta, VOID, [Annotation]);
  setMetadataFor(RemoteInsertStrategy, 'RemoteInsertStrategy', classMeta, Enum);
  setMetadataFor(ReplicateEntity, 'ReplicateEntity', classMeta, VOID, [Annotation]);
  setMetadataFor(ReplicateEtag, 'ReplicateEtag', classMeta, VOID, [Annotation]);
  setMetadataFor(ReplicateLastModified, 'ReplicateLastModified', classMeta, VOID, [Annotation]);
  setMetadataFor(Event, 'Event', classMeta, Enum);
  setMetadataFor(Order, 'Order', classMeta, Enum);
  setMetadataFor(On, 'On', classMeta, Enum);
  setMetadataFor(Companion_6, 'Companion', objectMeta);
  setMetadataFor(Trigger, 'Trigger', classMeta, VOID, [Annotation]);
  setMetadataFor(Triggers, 'Triggers', classMeta, VOID, [Annotation]);
  setMetadataFor(Companion_7, 'Companion', objectMeta);
  setMetadataFor(DoorNode, 'DoorNode', classMeta, VOID, VOID, DoorNode);
  setMetadataFor(NodeIdAndAuth, 'NodeIdAndAuth', classMeta);
  setMetadataFor(OutgoingReplication, 'OutgoingReplication', classMeta, VOID, VOID, OutgoingReplication);
  setMetadataFor(Companion_8, 'Companion', objectMeta);
  setMetadataFor(DoorDatabaseMetadata, 'DoorDatabaseMetadata', classMeta);
  setMetadataFor(Companion_9, 'Companion', objectMeta);
  setMetadataFor(DoorTag, 'DoorTag', classMeta, VOID, VOID, DoorTag);
  setMetadataFor(ConnectionAsync, 'ConnectionAsync', interfaceMeta, VOID, VOID, VOID, VOID, VOID, [1, 0]);
  setMetadataFor(StatementConstantsKmp, 'StatementConstantsKmp', objectMeta);
  setMetadataFor(TypesKmp, 'TypesKmp', objectMeta);
  setMetadataFor($useStatementAsyncCOROUTINE$8, '$useStatementAsyncCOROUTINE$8', classMeta, CoroutineImpl);
  setMetadataFor(DoorLogLevel, 'DoorLogLevel', classMeta, Enum);
  function log$default(level, message, throwable, $super) {
    throwable = throwable === VOID ? null : throwable;
    var tmp;
    if ($super === VOID) {
      this.log_kks8iu_k$(level, message, throwable);
      tmp = Unit_getInstance();
    } else {
      tmp = $super.log_kks8iu_k$.call(this, level, message, throwable);
    }
    return tmp;
  }
  function log$default_0(level, throwable, message, $super) {
    throwable = throwable === VOID ? null : throwable;
    var tmp;
    if ($super === VOID) {
      this.log_vpti5k_k$(level, throwable, message);
      tmp = Unit_getInstance();
    } else {
      tmp = $super.log_vpti5k_k$.call(this, level, throwable, message);
    }
    return tmp;
  }
  setMetadataFor(DoorLogger, 'DoorLogger', interfaceMeta);
  setMetadataFor(NapierDoorLogger, 'NapierDoorLogger', classMeta, VOID, [DoorLogger], NapierDoorLogger);
  setMetadataFor(DoorMessageCallback, 'DoorMessageCallback', interfaceMeta, VOID, VOID, VOID, VOID, VOID, [2]);
  setMetadataFor(DefaultDoorMessageCallback, 'DefaultDoorMessageCallback', classMeta, VOID, [DoorMessageCallback], DefaultDoorMessageCallback, VOID, VOID, [2]);
  setMetadataFor(Companion_10, 'Companion', objectMeta);
  setMetadataFor($serializer_0, '$serializer', objectMeta, VOID, [GeneratedSerializer]);
  setMetadataFor(DoorMessage, 'DoorMessage', classMeta, VOID, VOID, VOID, VOID, {0: $serializer_getInstance_0});
  setMetadataFor(DoorMigration, 'DoorMigration', classMeta);
  setMetadataFor(DoorMigrationAsync, 'DoorMigrationAsync', classMeta, DoorMigration);
  setMetadataFor(DoorMigrationStatementList, 'DoorMigrationStatementList', classMeta, DoorMigration);
  setMetadataFor(DoorMigrationSync, 'DoorMigrationSync', classMeta, DoorMigration);
  setMetadataFor(NodeEvent, 'NodeEvent', classMeta);
  setMetadataFor($createNodeEventTableAndTriggerCOROUTINE$9, '$createNodeEventTableAndTriggerCOROUTINE$9', classMeta, CoroutineImpl);
  setMetadataFor(NodeEventConstants, 'NodeEventConstants', objectMeta);
  setMetadataFor(NodeEventManager, 'NodeEventManager', interfaceMeta, VOID, VOID, VOID, VOID, VOID, [1]);
  setMetadataFor(NodeEventManagerCommon$onIncomingMessageReceived$slambda, 'NodeEventManagerCommon$onIncomingMessageReceived$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor($onIncomingMessageReceivedCOROUTINE$10, '$onIncomingMessageReceivedCOROUTINE$10', classMeta, CoroutineImpl);
  setMetadataFor(NodeEventManagerCommon, 'NodeEventManagerCommon', classMeta, VOID, [NodeEventManager], VOID, VOID, VOID, [1]);
  setMetadataFor(DelegatedInvalidationPagingSource, 'DelegatedInvalidationPagingSource', classMeta, PagingSource, VOID, VOID, VOID, VOID, [1]);
  setMetadataFor(PagingSourceWithHttpLoader, 'PagingSourceWithHttpLoader', interfaceMeta, VOID, VOID, VOID, VOID, VOID, [1]);
  setMetadataFor(ReplicateEntityPrimaryKeys, 'ReplicateEntityPrimaryKeys', classMeta);
  setMetadataFor(acknowledgeReceivedReplications$slambda, 'acknowledgeReceivedReplications$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor(selectPendingOutgoingReplicationsByDestNodeId$slambda, 'selectPendingOutgoingReplicationsByDestNodeId$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor(getDoorNodeAuth$slambda, 'getDoorNodeAuth$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor(insertNewDoorNode$slambda, 'insertNewDoorNode$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor(insertEntitiesFromMessage$slambda, 'insertEntitiesFromMessage$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor(insertEntitiesFromMessage$slambda_1, 'insertEntitiesFromMessage$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor(insertEntitiesFromMessage$slambda_3, 'insertEntitiesFromMessage$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor(selectDoorReplicateEntitiesByTableIdAndPrimaryKeys$slambda, 'selectDoorReplicateEntitiesByTableIdAndPrimaryKeys$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor($selectPendingOutgoingReplicationsByDestNodeIdCOROUTINE$11, '$selectPendingOutgoingReplicationsByDestNodeIdCOROUTINE$11', classMeta, CoroutineImpl);
  setMetadataFor($insertNewDoorNodeCOROUTINE$12, '$insertNewDoorNodeCOROUTINE$12', classMeta, CoroutineImpl);
  setMetadataFor($insertEntitiesFromMessageCOROUTINE$13, '$insertEntitiesFromMessageCOROUTINE$13', classMeta, CoroutineImpl);
  setMetadataFor(Companion_11, 'Companion', objectMeta);
  setMetadataFor($serializer_1, '$serializer', objectMeta, VOID, [GeneratedSerializer]);
  setMetadataFor(DoorReplicationEntity, 'DoorReplicationEntity', classMeta, VOID, VOID, VOID, VOID, {0: $serializer_getInstance_1});
  setMetadataFor(DoorRepositoryReplicationClient$DefaultOnMarkAcknowledgedAndGetNextOutgoingReplications$invoke$slambda, 'DoorRepositoryReplicationClient$DefaultOnMarkAcknowledgedAndGetNextOutgoingReplications$invoke$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor(DoorRepositoryReplicationClient$DefaultOnStartPendingSession$invoke$slambda, 'DoorRepositoryReplicationClient$DefaultOnStartPendingSession$invoke$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor($invokeCOROUTINE$14, '$invokeCOROUTINE$14', classMeta, CoroutineImpl);
  setMetadataFor(DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda$slambda, 'DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor(DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda$slambda_1, 'DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor(DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda, 'DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor($invokeCOROUTINE$15, '$invokeCOROUTINE$15', classMeta, CoroutineImpl);
  setMetadataFor(DoorRepositoryReplicationClient$slambda$slambda$slambda, 'DoorRepositoryReplicationClient$slambda$slambda$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor(DoorRepositoryReplicationClient$slambda$slambda$slambda_1, 'DoorRepositoryReplicationClient$slambda$slambda$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor(DoorRepositoryReplicationClient$slambda$slambda, 'DoorRepositoryReplicationClient$slambda$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor(DoorRepositoryReplicationClient$slambda$slambda_1, 'DoorRepositoryReplicationClient$slambda$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor(ClientState, 'ClientState', classMeta, VOID, VOID, ClientState);
  setMetadataFor(OnMarkAcknowledgedAndGetNextOutgoingReplications, 'OnMarkAcknowledgedAndGetNextOutgoingReplications', interfaceMeta, VOID, VOID, VOID, VOID, VOID, [3]);
  setMetadataFor(DefaultOnMarkAcknowledgedAndGetNextOutgoingReplications, 'DefaultOnMarkAcknowledgedAndGetNextOutgoingReplications', classMeta, VOID, [OnMarkAcknowledgedAndGetNextOutgoingReplications], VOID, VOID, VOID, [3]);
  setMetadataFor(OnStartPendingSession, 'OnStartPendingSession', interfaceMeta, VOID, VOID, VOID, VOID, VOID, [2]);
  setMetadataFor(DefaultOnStartPendingSession, 'DefaultOnStartPendingSession', classMeta, VOID, [OnStartPendingSession], VOID, VOID, VOID, [2]);
  setMetadataFor(OnPendingSessionResolved, 'OnPendingSessionResolved', interfaceMeta, VOID, VOID, VOID, VOID, VOID, [2]);
  setMetadataFor(DefaultOnPendingSessionResolved, 'DefaultOnPendingSessionResolved', classMeta, VOID, [OnPendingSessionResolved], VOID, VOID, VOID, [2]);
  setMetadataFor(Companion_12, 'Companion', objectMeta);
  setMetadataFor(sam$kotlinx_coroutines_flow_FlowCollector$0, 'sam$kotlinx_coroutines_flow_FlowCollector$0', classMeta, VOID, [FlowCollector], VOID, VOID, VOID, [1]);
  setMetadataFor(DoorRepositoryReplicationClient$slambda, 'DoorRepositoryReplicationClient$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor(DoorRepositoryReplicationClient$slambda_1, 'DoorRepositoryReplicationClient$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor(DoorRepositoryReplicationClient$slambda_3, 'DoorRepositoryReplicationClient$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor(DoorRepositoryReplicationClient$slambda_5, 'DoorRepositoryReplicationClient$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor($runSendLoopCOROUTINE$16, '$runSendLoopCOROUTINE$16', classMeta, CoroutineImpl);
  setMetadataFor($runFetchLoopCOROUTINE$17, '$runFetchLoopCOROUTINE$17', classMeta, CoroutineImpl);
  setMetadataFor(DoorRepositoryReplicationClient, 'DoorRepositoryReplicationClient', classMeta, VOID, VOID, VOID, VOID, VOID, [0]);
  setMetadataFor(JsonDbFieldInfo, 'JsonDbFieldInfo', interfaceMeta);
  setMetadataFor(ReplicationConstants, 'ReplicationConstants', objectMeta);
  setMetadataFor(ReplicationEntityMetaData, 'ReplicationEntityMetaData', classMeta);
  setMetadataFor(ReplicationFieldMetaData, 'ReplicationFieldMetaData', classMeta, VOID, [JsonDbFieldInfo]);
  setMetadataFor(Companion_13, 'Companion', objectMeta);
  setMetadataFor($serializer_2, '$serializer', objectMeta, VOID, [GeneratedSerializer]);
  setMetadataFor(ReplicationReceivedAck, 'ReplicationReceivedAck', classMeta, VOID, VOID, VOID, VOID, {0: $serializer_getInstance_2});
  setMetadataFor(TriggerConstants, 'TriggerConstants', objectMeta);
  setMetadataFor(DoorEventCollator$receiveEvent$slambda$slambda, 'DoorEventCollator$receiveEvent$slambda$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor(DoorEventCollator$receiveEvent$slambda, 'DoorEventCollator$receiveEvent$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor(DoorEventCollator, 'DoorEventCollator', classMeta);
  setMetadataFor(IWeakRef, 'IWeakRef', interfaceMeta);
  setMetadataFor(OnNewDoorNode, 'OnNewDoorNode', interfaceMeta);
  setMetadataFor($verifyCOROUTINE$18, '$verifyCOROUTINE$18', classMeta, CoroutineImpl);
  setMetadataFor(NodeIdAuthCache, 'NodeIdAuthCache', classMeta, VOID, VOID, VOID, VOID, VOID, [2]);
  setMetadataFor(TransactionMode, 'TransactionMode', classMeta, Enum);
  setMetadataFor(Companion_14, 'Companion', objectMeta);
  setMetadataFor($buildCOROUTINE$19, '$buildCOROUTINE$19', classMeta, CoroutineImpl);
  setMetadataFor($build$execSqlAsyncCOROUTINE$20, '$build$execSqlAsyncCOROUTINE$20', classMeta, CoroutineImpl);
  setMetadataFor(DatabaseBuilder, 'DatabaseBuilder', classMeta, VOID, VOID, VOID, VOID, VOID, [0, 1]);
  setMetadataFor(DatabaseBuilderOptions, 'DatabaseBuilderOptions', classMeta);
  setMetadataFor(DoorUriProps, 'DoorUriProps', classMeta);
  setMetadataFor(Companion_15, 'Companion', objectMeta);
  setMetadataFor(DoorUri, 'DoorUri', classMeta, VOID, VOID, VOID, VOID, VOID, [1]);
  setMetadataFor(JdbcArrayProxy, 'JdbcArrayProxy', classMeta, JdbcArrayProxyCommon);
  setMetadataFor(PreparedStatementArrayProxy, 'PreparedStatementArrayProxy', classMeta, PreparedStatementArrayProxyCommon, VOID, VOID, VOID, VOID, [0, 1]);
  setMetadataFor(Builder, 'Builder', classMeta);
  setMetadataFor(Companion_16, 'Companion', objectMeta);
  setMetadataFor(RepositoryConfig, 'RepositoryConfig', classMeta);
  setMetadataFor(SaveToIndexedDbChangeListener$eventCollator$slambda, 'SaveToIndexedDbChangeListener$eventCollator$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor(SaveToIndexedDbChangeListener$1, VOID, classMeta, InvalidationTrackerObserver);
  setMetadataFor(SaveToIndexedDbChangeListener, 'SaveToIndexedDbChangeListener', classMeta);
  setMetadataFor(withDoorTransactionAsync$slambda, 'withDoorTransactionAsync$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor(Connection, 'Connection', interfaceMeta);
  setMetadataFor(DataSource, 'DataSource', interfaceMeta);
  setMetadataFor(DatabaseMetadata, 'DatabaseMetadata', interfaceMeta, VOID, VOID, VOID, VOID, VOID, [4]);
  setMetadataFor(ResultSetMetaData, 'ResultSetMetaData', interfaceMeta);
  setMetadataFor(SQLException, 'SQLException', classMeta, Exception);
  setMetadataFor(RoomDatabase$execSQLBatchAsyncJs$slambda, 'RoomDatabase$execSQLBatchAsyncJs$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor($execSQLBatchAsyncJsCOROUTINE$21, '$execSQLBatchAsyncJsCOROUTINE$21', classMeta, CoroutineImpl);
  setMetadataFor(RoomDatabase, 'RoomDatabase', classMeta, VOID, VOID, VOID, VOID, VOID, [0, 1]);
  setMetadataFor(RoomDatabaseJdbcImplHelper, 'RoomDatabaseJdbcImplHelper', classMeta, RoomDatabaseJdbcImplHelperCommon, VOID, VOID, VOID, VOID, [0, 2, 1]);
  setMetadataFor($storeBlobCOROUTINE$22, '$storeBlobCOROUTINE$22', classMeta, CoroutineImpl);
  setMetadataFor(IndexedDb, 'IndexedDb', objectMeta, VOID, VOID, VOID, VOID, VOID, [1, 4, 3]);
  setMetadataFor(Companion_17, 'Companion', objectMeta);
  setMetadataFor($setAutoCommitAsyncCOROUTINE$23, '$setAutoCommitAsyncCOROUTINE$23', classMeta, CoroutineImpl);
  setMetadataFor($commitAsyncCOROUTINE$24, '$commitAsyncCOROUTINE$24', classMeta, CoroutineImpl);
  setMetadataFor($rollbackAsyncCOROUTINE$25, '$rollbackAsyncCOROUTINE$25', classMeta, CoroutineImpl);
  setMetadataFor(SQLiteConnectionJs, 'SQLiteConnectionJs', classMeta, VOID, [Connection, ConnectionAsync], VOID, VOID, VOID, [1, 0]);
  setMetadataFor($getTablesAsyncCOROUTINE$26, '$getTablesAsyncCOROUTINE$26', classMeta, CoroutineImpl);
  setMetadataFor(SQLiteDatabaseMetadataJs, 'SQLiteDatabaseMetadataJs', classMeta, VOID, [DatabaseMetadata], VOID, VOID, VOID, [4]);
  setMetadataFor(Companion_18, 'Companion', objectMeta);
  setMetadataFor(SQLiteDatasourceJs$sendQuery$slambda, 'SQLiteDatasourceJs$sendQuery$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [0]);
  setMetadataFor(SQLiteDatasourceJs$sendUpdate$slambda, 'SQLiteDatasourceJs$sendUpdate$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [0]);
  setMetadataFor(SQLiteDatasourceJs$loadDbFromIndexedDb$lambda$lambda$slambda, 'SQLiteDatasourceJs$loadDbFromIndexedDb$lambda$lambda$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor($sendMessageCOROUTINE$27, '$sendMessageCOROUTINE$27', classMeta, CoroutineImpl);
  setMetadataFor($withTransactionLockCOROUTINE$28, '$withTransactionLockCOROUTINE$28', classMeta, CoroutineImpl);
  setMetadataFor($exportDatabaseToFileCOROUTINE$29, '$exportDatabaseToFileCOROUTINE$29', classMeta, CoroutineImpl);
  setMetadataFor($saveDatabaseToIndexedDbCOROUTINE$30, '$saveDatabaseToIndexedDbCOROUTINE$30', classMeta, CoroutineImpl);
  setMetadataFor(SQLiteDatasourceJs, 'SQLiteDatasourceJs', classMeta, VOID, [DataSource], VOID, VOID, VOID, [1, 2, 3, 4, 0]);
  setMetadataFor($executeUpdateAsyncCOROUTINE$31, '$executeUpdateAsyncCOROUTINE$31', classMeta, CoroutineImpl);
  setMetadataFor(SQLiteStatementJs, 'SQLiteStatementJs', classMeta, VOID, [Statement], VOID, VOID, VOID, [1]);
  setMetadataFor(SQLitePreparedStatementJs, 'SQLitePreparedStatementJs', classMeta, SQLiteStatementJs, [SQLiteStatementJs, PreparedStatement], VOID, VOID, VOID, [0, 1]);
  setMetadataFor(MetaData, 'MetaData', classMeta, VOID, [ResultSetMetaData]);
  setMetadataFor(SQLiteResultSet, 'SQLiteResultSet', classMeta, VOID, [ResultSet]);
  setMetadataFor($executeUpdateAsyncJsCOROUTINE$32, '$executeUpdateAsyncJsCOROUTINE$32', classMeta, CoroutineImpl);
  setMetadataFor(UpdateResult, 'UpdateResult', classMeta);
  setMetadataFor(WorkerResult, 'WorkerResult', classMeta);
  setMetadataFor(DoorJsImplClasses, 'DoorJsImplClasses', classMeta);
  setMetadataFor(WeakRefJs, 'WeakRefJs', classMeta, VOID, [IWeakRef]);
  //endregion
  function DoorQuery() {
  }
  function DoorSqlDatabase() {
  }
  function DoorSqlDatabaseConnectionImpl(connection, dbTypeInt) {
    this.connection_1 = connection;
    this.dbTypeInt_1 = dbTypeInt;
  }
  protoOf(DoorSqlDatabaseConnectionImpl).get_connection_x01z89_k$ = function () {
    return this.connection_1;
  };
  protoOf(DoorSqlDatabaseConnectionImpl).get_dbTypeInt_k2nxu_k$ = function () {
    return this.dbTypeInt_1;
  };
  protoOf(DoorSqlDatabaseConnectionImpl).execSQL_4zzrpp_k$ = function (sql) {
    $l$block: {
      // Inline function 'com.ustadmobile.door.jdbc.ext.useStatement' call
      var this_0 = this.connection_1.createStatement_cbd7tf_k$();
      try {
        // Inline function 'com.ustadmobile.door.DoorSqlDatabaseConnectionImpl.execSQL.<anonymous>' call
        this_0.executeUpdate_k6x04k_k$(sql);
        break $l$block;
      } catch ($p) {
        if ($p instanceof Exception) {
          var e = $p;
          throw e;
        } else {
          throw $p;
        }
      }
      finally {
        this_0.close_yn9xrc_k$();
      }
    }
  };
  protoOf(DoorSqlDatabaseConnectionImpl).execSQLBatch_23yw79_k$ = function (statements) {
    $l$block: {
      // Inline function 'com.ustadmobile.door.jdbc.ext.useStatement' call
      var this_0 = this.connection_1.createStatement_cbd7tf_k$();
      try {
        this.connection_1.setAutoCommit_yh8u8d_k$(false);
        // Inline function 'kotlin.collections.forEach' call
        var inductionVariable = 0;
        var last = statements.length;
        while (inductionVariable < last) {
          var element = statements[inductionVariable];
          inductionVariable = inductionVariable + 1 | 0;
          // Inline function 'com.ustadmobile.door.DoorSqlDatabaseConnectionImpl.execSQLBatch.<anonymous>.<anonymous>' call
          this_0.executeUpdate_k6x04k_k$(element);
        }
        this.connection_1.commit_vpt10n_k$();
        break $l$block;
      } catch ($p) {
        if ($p instanceof Exception) {
          var e = $p;
          throw e;
        } else {
          throw $p;
        }
      }
      finally {
        this_0.close_yn9xrc_k$();
      }
    }
  };
  function _get_queryParams__wxa6n1($this) {
    return $this.queryParams_1;
  }
  function _get_queryTypes__jj0avu($this) {
    return $this.queryTypes_1;
  }
  function _get_nullSqlTypes__pfbh47($this) {
    return $this.nullSqlTypes_1;
  }
  function getNthIndexOf(_this__u8e3s4, $this, char, n) {
    var foundCount = 0;
    var pos = 0;
    $l$loop: while (true) {
      var tmp;
      var tmp0 = foundCount;
      foundCount = tmp0 + 1 | 0;
      if (tmp0 < n) {
        tmp = !(pos === -1);
      } else {
        tmp = false;
      }
      if (!tmp) {
        break $l$loop;
      }
      pos = indexOf(_this__u8e3s4, char, pos + 1 | 0);
    }
    return pos;
  }
  function makeArrayPlaceholders($this, numPlaceholders) {
    // Inline function 'kotlin.math.max' call
    var b = imul(2, numPlaceholders) - 1 | 0;
    var tmp$ret$0 = Math.max(0, b);
    var sb = StringBuilder_init_$Create$(tmp$ret$0);
    var inductionVariable = 0;
    if (inductionVariable < numPlaceholders)
      do {
        var i = inductionVariable;
        inductionVariable = inductionVariable + 1 | 0;
        if (!(i === 0)) {
          sb.append_am5a4z_k$(_Char___init__impl__6a9atx(44));
        }
        sb.append_am5a4z_k$(_Char___init__impl__6a9atx(63));
      }
       while (inductionVariable < numPlaceholders);
    return sb.toString();
  }
  function Companion() {
    Companion_instance = this;
    this.ARR_PROXY_SET_OBJECT_1 = -5000;
    this.PROXY_SET_NULL_1 = -5001;
  }
  protoOf(Companion).get_ARR_PROXY_SET_OBJECT_dwlfxw_k$ = function () {
    return this.ARR_PROXY_SET_OBJECT_1;
  };
  protoOf(Companion).get_PROXY_SET_NULL_xr3lfi_k$ = function () {
    return this.PROXY_SET_NULL_1;
  };
  var Companion_instance;
  function Companion_getInstance_2() {
    if (Companion_instance == null)
      new Companion();
    return Companion_instance;
  }
  function PreparedStatementArrayProxyCommon(query, connectionInternal) {
    Companion_getInstance_2();
    this.query_1 = query;
    this.connectionInternal_1 = connectionInternal;
    var tmp = this;
    // Inline function 'kotlin.collections.mutableMapOf' call
    tmp.queryParams_1 = LinkedHashMap_init_$Create$();
    var tmp_0 = this;
    // Inline function 'kotlin.collections.mutableMapOf' call
    tmp_0.queryTypes_1 = LinkedHashMap_init_$Create$();
    var tmp_1 = this;
    // Inline function 'kotlin.collections.mutableMapOf' call
    tmp_1.nullSqlTypes_1 = LinkedHashMap_init_$Create$();
    this.stmtQueryTimeout_1 = -1;
  }
  protoOf(PreparedStatementArrayProxyCommon).get_query_ixn1y7_k$ = function () {
    return this.query_1;
  };
  protoOf(PreparedStatementArrayProxyCommon).get_connectionInternal_tlp70c_k$ = function () {
    return this.connectionInternal_1;
  };
  protoOf(PreparedStatementArrayProxyCommon).set_stmtQueryTimeout_y4bkfe_k$ = function (_set____db54di) {
    this.stmtQueryTimeout_1 = _set____db54di;
  };
  protoOf(PreparedStatementArrayProxyCommon).get_stmtQueryTimeout_l5p7fa_k$ = function () {
    return this.stmtQueryTimeout_1;
  };
  protoOf(PreparedStatementArrayProxyCommon).setBoolean_pzdm1v_k$ = function (index, value) {
    // Inline function 'kotlin.collections.set' call
    this.queryParams_1.put_4fpzoq_k$(index, value);
    // Inline function 'kotlin.collections.set' call
    var this_0 = this.queryTypes_1;
    var value_0 = TypesKmp_getInstance().get_BOOLEAN_e7jswv_k$();
    this_0.put_4fpzoq_k$(index, value_0);
  };
  protoOf(PreparedStatementArrayProxyCommon).setByte_o65f22_k$ = function (index, value) {
    // Inline function 'kotlin.collections.set' call
    this.queryParams_1.put_4fpzoq_k$(index, value);
    // Inline function 'kotlin.collections.set' call
    var this_0 = this.queryTypes_1;
    var value_0 = TypesKmp_getInstance().get_SMALLINT_sw3een_k$();
    this_0.put_4fpzoq_k$(index, value_0);
  };
  protoOf(PreparedStatementArrayProxyCommon).setShort_mhpatm_k$ = function (index, value) {
    // Inline function 'kotlin.collections.set' call
    this.queryParams_1.put_4fpzoq_k$(index, value);
    // Inline function 'kotlin.collections.set' call
    var this_0 = this.queryTypes_1;
    var value_0 = TypesKmp_getInstance().get_SMALLINT_sw3een_k$();
    this_0.put_4fpzoq_k$(index, value_0);
  };
  protoOf(PreparedStatementArrayProxyCommon).setInt_c72a8z_k$ = function (index, value) {
    // Inline function 'kotlin.collections.set' call
    this.queryParams_1.put_4fpzoq_k$(index, value);
    // Inline function 'kotlin.collections.set' call
    var this_0 = this.queryTypes_1;
    var value_0 = TypesKmp_getInstance().get_INTEGER_pibe8b_k$();
    this_0.put_4fpzoq_k$(index, value_0);
  };
  protoOf(PreparedStatementArrayProxyCommon).setLong_j1sybo_k$ = function (index, value) {
    // Inline function 'kotlin.collections.set' call
    this.queryParams_1.put_4fpzoq_k$(index, value);
    // Inline function 'kotlin.collections.set' call
    var this_0 = this.queryTypes_1;
    var value_0 = TypesKmp_getInstance().get_BIGINT_47wyyw_k$();
    this_0.put_4fpzoq_k$(index, value_0);
  };
  protoOf(PreparedStatementArrayProxyCommon).setFloat_dia6lm_k$ = function (index, value) {
    // Inline function 'kotlin.collections.set' call
    this.queryParams_1.put_4fpzoq_k$(index, value);
    // Inline function 'kotlin.collections.set' call
    var this_0 = this.queryTypes_1;
    var value_0 = TypesKmp_getInstance().get_FLOAT_i998gj_k$();
    this_0.put_4fpzoq_k$(index, value_0);
  };
  protoOf(PreparedStatementArrayProxyCommon).setDouble_gsfx69_k$ = function (index, value) {
    // Inline function 'kotlin.collections.set' call
    this.queryParams_1.put_4fpzoq_k$(index, value);
    // Inline function 'kotlin.collections.set' call
    var this_0 = this.queryTypes_1;
    var value_0 = TypesKmp_getInstance().get_DOUBLE_36a61y_k$();
    this_0.put_4fpzoq_k$(index, value_0);
  };
  protoOf(PreparedStatementArrayProxyCommon).setString_2gt7ua_k$ = function (index, value) {
    // Inline function 'kotlin.collections.set' call
    this.queryParams_1.put_4fpzoq_k$(index, value);
    // Inline function 'kotlin.collections.set' call
    var this_0 = this.queryTypes_1;
    var value_0 = TypesKmp_getInstance().get_VARCHAR_h1w92s_k$();
    this_0.put_4fpzoq_k$(index, value_0);
  };
  protoOf(PreparedStatementArrayProxyCommon).setArray_61y2p9_k$ = function (index, array) {
    // Inline function 'kotlin.collections.set' call
    this.queryParams_1.put_4fpzoq_k$(index, array);
    // Inline function 'kotlin.collections.set' call
    var this_0 = this.queryTypes_1;
    var value = TypesKmp_getInstance().get_ARRAY_i6m5n4_k$();
    this_0.put_4fpzoq_k$(index, value);
  };
  protoOf(PreparedStatementArrayProxyCommon).setBigDecimal_lq0top_k$ = function (index, value) {
    throw new SQLException('PreparedStatementArrayProxy unsupported type: BigDecimal', (null == null ? true : null instanceof Error) ? null : THROW_CCE());
  };
  protoOf(PreparedStatementArrayProxyCommon).setBytes_hpy65b_k$ = function (index, value) {
    throw new SQLException('PreparedStatementArrayProxy unsupported type: Bytes', (null == null ? true : null instanceof Error) ? null : THROW_CCE());
  };
  protoOf(PreparedStatementArrayProxyCommon).setDate_ytyjt6_k$ = function (index, value) {
    throw new SQLException('PreparedStatementArrayProxy unsupported type: Date', (null == null ? true : null instanceof Error) ? null : THROW_CCE());
  };
  protoOf(PreparedStatementArrayProxyCommon).setTime_3vnst7_k$ = function (index, value) {
  };
  protoOf(PreparedStatementArrayProxyCommon).setObject_9i2mag_k$ = function (index, value) {
    // Inline function 'kotlin.collections.set' call
    this.queryParams_1.put_4fpzoq_k$(index, value);
    // Inline function 'kotlin.collections.set' call
    this.queryTypes_1.put_4fpzoq_k$(index, -5000);
  };
  protoOf(PreparedStatementArrayProxyCommon).setNull_24rkav_k$ = function (parameterIndex, sqlType) {
    // Inline function 'kotlin.collections.set' call
    this.queryParams_1.put_4fpzoq_k$(parameterIndex, null);
    // Inline function 'kotlin.collections.set' call
    this.queryTypes_1.put_4fpzoq_k$(parameterIndex, -5001);
    // Inline function 'kotlin.collections.set' call
    this.nullSqlTypes_1.put_4fpzoq_k$(parameterIndex, sqlType);
  };
  protoOf(PreparedStatementArrayProxyCommon).setQueryTimeout_qepe4z_k$ = function (seconds) {
    this.stmtQueryTimeout_1 = seconds;
  };
  protoOf(PreparedStatementArrayProxyCommon).prepareStatement_ieuhug_k$ = function () {
    var arrayOffset = 0;
    // Inline function 'kotlin.collections.mutableMapOf' call
    var paramValues = LinkedHashMap_init_$Create$();
    // Inline function 'kotlin.collections.mutableMapOf' call
    var paramTypes = LinkedHashMap_init_$Create$();
    var adjustedQuery = this.query_1;
    var tmp0_iterator = this.queryParams_1.get_keys_wop4xp_k$().iterator_jk1svi_k$();
    while (tmp0_iterator.hasNext_bitz1p_k$()) {
      var paramIndex = tmp0_iterator.next_20eer_k$();
      var value = this.queryParams_1.get_wei43m_k$(paramIndex);
      if (!(value == null) ? isInterface(value, Array_0) : false) {
        var arrayProxy = value instanceof JdbcArrayProxy ? value : THROW_CCE();
        var objects = arrayProxy.get_objects_q6k34l_k$();
        var arrayParamPos = getNthIndexOf(adjustedQuery, this, _Char___init__impl__6a9atx(63), paramIndex + arrayOffset | 0);
        // Inline function 'kotlin.text.substring' call
        // Inline function 'kotlin.js.asDynamic' call
        var tmp = adjustedQuery.substring(0, arrayParamPos) + makeArrayPlaceholders(this, objects.length);
        // Inline function 'kotlin.text.substring' call
        var this_0 = adjustedQuery;
        var startIndex = arrayParamPos + 1 | 0;
        // Inline function 'kotlin.js.asDynamic' call
        adjustedQuery = tmp + this_0.substring(startIndex);
        var inductionVariable = 0;
        var last = objects.length - 1 | 0;
        if (inductionVariable <= last)
          do {
            var i = inductionVariable;
            inductionVariable = inductionVariable + 1 | 0;
            var paramPos = (paramIndex + arrayOffset | 0) + i | 0;
            // Inline function 'kotlin.collections.set' call
            var value_0 = objects[i];
            paramValues.put_4fpzoq_k$(paramPos, value_0);
            // Inline function 'kotlin.collections.set' call
            var value_1 = arrayProxy.getBaseType_5w77s1_k$();
            paramTypes.put_4fpzoq_k$(paramPos, value_1);
          }
           while (inductionVariable <= last);
        arrayOffset = arrayOffset + (objects.length - 1 | 0) | 0;
      } else {
        // Inline function 'kotlin.collections.set' call
        var key = paramIndex + arrayOffset | 0;
        paramValues.put_4fpzoq_k$(key, value);
        // Inline function 'kotlin.collections.set' call
        var key_0 = paramIndex + arrayOffset | 0;
        var tmp2_elvis_lhs = this.queryTypes_1.get_wei43m_k$(paramIndex);
        var tmp_0;
        if (tmp2_elvis_lhs == null) {
          throw IllegalStateException_init_$Create$('PreparedStatementArrayProxy: Cannot find query param type at index ' + paramIndex);
        } else {
          tmp_0 = tmp2_elvis_lhs;
        }
        var value_2 = tmp_0;
        paramTypes.put_4fpzoq_k$(key_0, value_2);
      }
    }
    var stmt = null;
    try {
      stmt = this.connectionInternal_1.prepareStatement_f6j8eq_k$(adjustedQuery);
      // Inline function 'kotlin.takeIf' call
      var this_1 = stmt;
      // Inline function 'kotlin.contracts.contract' call
      var tmp_1;
      // Inline function 'com.ustadmobile.door.PreparedStatementArrayProxyCommon.prepareStatement.<anonymous>' call
      if (this.stmtQueryTimeout_1 > 0) {
        tmp_1 = this_1;
      } else {
        tmp_1 = null;
      }
      var tmp3_safe_receiver = tmp_1;
      if (tmp3_safe_receiver == null)
        null;
      else {
        tmp3_safe_receiver.setQueryTimeout_qepe4z_k$(this.stmtQueryTimeout_1);
      }
      var tmp4_iterator = paramValues.get_keys_wop4xp_k$().iterator_jk1svi_k$();
      while (tmp4_iterator.hasNext_bitz1p_k$()) {
        var paramIndex_0 = tmp4_iterator.next_20eer_k$();
        var value_3 = paramValues.get_wei43m_k$(paramIndex_0);
        var tmp5_elvis_lhs = paramTypes.get_wei43m_k$(paramIndex_0);
        var paramType = tmp5_elvis_lhs == null ? 0 : tmp5_elvis_lhs;
        if (paramType === -5001) {
          var tmp_2 = stmt;
          var tmp7_elvis_lhs = this.nullSqlTypes_1.get_wei43m_k$(paramIndex_0);
          tmp_2.setNull_24rkav_k$(paramIndex_0, tmp7_elvis_lhs == null ? 0 : tmp7_elvis_lhs);
        } else if (paramType === TypesKmp_getInstance().get_INTEGER_pibe8b_k$()) {
          var tmp_3 = stmt;
          tmp_3.setInt_c72a8z_k$(paramIndex_0, (!(value_3 == null) ? typeof value_3 === 'number' : false) ? value_3 : THROW_CCE());
        } else if (paramType === TypesKmp_getInstance().get_BOOLEAN_e7jswv_k$()) {
          var tmp_4 = stmt;
          tmp_4.setBoolean_pzdm1v_k$(paramIndex_0, (!(value_3 == null) ? typeof value_3 === 'boolean' : false) ? value_3 : THROW_CCE());
        } else if (paramType === TypesKmp_getInstance().get_VARCHAR_h1w92s_k$() ? true : paramType === TypesKmp_getInstance().get_LONGVARCHAR_lmf0o_k$()) {
          var tmp_5 = stmt;
          tmp_5.setString_2gt7ua_k$(paramIndex_0, (value_3 == null ? true : typeof value_3 === 'string') ? value_3 : THROW_CCE());
        } else if (paramType === TypesKmp_getInstance().get_BIGINT_47wyyw_k$()) {
          var tmp_6 = stmt;
          tmp_6.setLong_j1sybo_k$(paramIndex_0, value_3 instanceof Long ? value_3 : THROW_CCE());
        } else if (paramType === TypesKmp_getInstance().get_FLOAT_i998gj_k$()) {
          var tmp_7 = stmt;
          tmp_7.setFloat_dia6lm_k$(paramIndex_0, (!(value_3 == null) ? typeof value_3 === 'number' : false) ? value_3 : THROW_CCE());
        } else if (paramType === -5000) {
          stmt.setObject_9i2mag_k$(paramIndex_0, value_3);
        }
      }
    } catch ($p) {
      if ($p instanceof SQLException) {
        var e = $p;
        var tmp8_safe_receiver = stmt;
        if (tmp8_safe_receiver == null)
          null;
        else {
          tmp8_safe_receiver.close_yn9xrc_k$();
        }
        throw e;
      } else {
        throw $p;
      }
    }
    return stmt;
  };
  protoOf(PreparedStatementArrayProxyCommon).executeQuery_mh7xd9_k$ = function () {
    var stmt = this.prepareStatement_ieuhug_k$();
    var resultSet = stmt.executeQuery_mh7xd9_k$();
    return new PreparedStatementResultSetWrapper(resultSet, stmt);
  };
  protoOf(PreparedStatementArrayProxyCommon).executeUpdate_fapcbi_k$ = function () {
    var tmp$ret$1;
    $l$block: {
      // Inline function 'com.ustadmobile.door.jdbc.ext.useStatement' call
      var this_0 = this.prepareStatement_ieuhug_k$();
      try {
        // Inline function 'com.ustadmobile.door.PreparedStatementArrayProxyCommon.executeUpdate.<anonymous>' call
        tmp$ret$1 = this_0.executeUpdate_fapcbi_k$();
        break $l$block;
      } catch ($p) {
        if ($p instanceof Exception) {
          var e = $p;
          throw e;
        } else {
          throw $p;
        }
      }
      finally {
        this_0.close_yn9xrc_k$();
      }
    }
    return tmp$ret$1;
  };
  function _get_resultSet__v33ndg($this) {
    return $this.resultSet_1;
  }
  function _get_stmt__ddv8ub($this) {
    return $this.stmt_1;
  }
  function PreparedStatementResultSetWrapper(resultSet, stmt) {
    this.resultSet_1 = resultSet;
    this.stmt_1 = stmt;
  }
  protoOf(PreparedStatementResultSetWrapper).getBigDecimal_vg28s3_k$ = function (columnName) {
    return this.resultSet_1.getBigDecimal_vg28s3_k$(columnName);
  };
  protoOf(PreparedStatementResultSetWrapper).getBoolean_oe92jq_k$ = function (columnIndex) {
    return this.resultSet_1.getBoolean_oe92jq_k$(columnIndex);
  };
  protoOf(PreparedStatementResultSetWrapper).getBoolean_xz3hoo_k$ = function (columnName) {
    return this.resultSet_1.getBoolean_xz3hoo_k$(columnName);
  };
  protoOf(PreparedStatementResultSetWrapper).getByte_8098nu_k$ = function (columnIndex) {
    return this.resultSet_1.getByte_8098nu_k$(columnIndex);
  };
  protoOf(PreparedStatementResultSetWrapper).getByte_blta6c_k$ = function (columnName) {
    return this.resultSet_1.getByte_blta6c_k$(columnName);
  };
  protoOf(PreparedStatementResultSetWrapper).getBytes_hu5f8b_k$ = function (columnName) {
    return this.resultSet_1.getBytes_hu5f8b_k$(columnName);
  };
  protoOf(PreparedStatementResultSetWrapper).getDate_jtyvo6_k$ = function (columnName) {
    return this.resultSet_1.getDate_jtyvo6_k$(columnName);
  };
  protoOf(PreparedStatementResultSetWrapper).getDouble_5me5vz_k$ = function (columnIndex) {
    return this.resultSet_1.getDouble_5me5vz_k$(columnIndex);
  };
  protoOf(PreparedStatementResultSetWrapper).getDouble_v37ict_k$ = function (columnName) {
    return this.resultSet_1.getDouble_v37ict_k$(columnName);
  };
  protoOf(PreparedStatementResultSetWrapper).getFloat_m7y41e_k$ = function (columnIndex) {
    return this.resultSet_1.getFloat_m7y41e_k$(columnIndex);
  };
  protoOf(PreparedStatementResultSetWrapper).getFloat_1jlp7w_k$ = function (columnName) {
    return this.resultSet_1.getFloat_1jlp7w_k$(columnName);
  };
  protoOf(PreparedStatementResultSetWrapper).getInt_s8uc8x_k$ = function (columnIndex) {
    return this.resultSet_1.getInt_s8uc8x_k$(columnIndex);
  };
  protoOf(PreparedStatementResultSetWrapper).getInt_npc9pd_k$ = function (columnName) {
    return this.resultSet_1.getInt_npc9pd_k$(columnName);
  };
  protoOf(PreparedStatementResultSetWrapper).getLong_rneply_k$ = function (columnIndex) {
    return this.resultSet_1.getLong_rneply_k$(columnIndex);
  };
  protoOf(PreparedStatementResultSetWrapper).getLong_3wgf2g_k$ = function (columnName) {
    return this.resultSet_1.getLong_3wgf2g_k$(columnName);
  };
  protoOf(PreparedStatementResultSetWrapper).getMetaData_qwn0zp_k$ = function () {
    return this.resultSet_1.getMetaData_qwn0zp_k$();
  };
  protoOf(PreparedStatementResultSetWrapper).getObject_m2jtdv_k$ = function (columnIndex) {
    return this.resultSet_1.getObject_m2jtdv_k$(columnIndex);
  };
  protoOf(PreparedStatementResultSetWrapper).getObject_63qtd1_k$ = function (columnName) {
    return this.resultSet_1.getObject_63qtd1_k$(columnName);
  };
  protoOf(PreparedStatementResultSetWrapper).getShort_agwca6_k$ = function (columnIndex) {
    return this.resultSet_1.getShort_agwca6_k$(columnIndex);
  };
  protoOf(PreparedStatementResultSetWrapper).getShort_4zegvo_k$ = function (columnName) {
    return this.resultSet_1.getShort_4zegvo_k$(columnName);
  };
  protoOf(PreparedStatementResultSetWrapper).getString_5demq7_k$ = function (columnIndex) {
    return this.resultSet_1.getString_5demq7_k$(columnIndex);
  };
  protoOf(PreparedStatementResultSetWrapper).getString_gb1pt9_k$ = function (columnName) {
    return this.resultSet_1.getString_gb1pt9_k$(columnName);
  };
  protoOf(PreparedStatementResultSetWrapper).getTime_of3q21_k$ = function (columnName) {
    return this.resultSet_1.getTime_of3q21_k$(columnName);
  };
  protoOf(PreparedStatementResultSetWrapper).getTimestamp_78pst6_k$ = function (columnName) {
    return this.resultSet_1.getTimestamp_78pst6_k$(columnName);
  };
  protoOf(PreparedStatementResultSetWrapper).isClosed_baxhhm_k$ = function () {
    return this.resultSet_1.isClosed_baxhhm_k$();
  };
  protoOf(PreparedStatementResultSetWrapper).next_20eer_k$ = function () {
    return this.resultSet_1.next_20eer_k$();
  };
  protoOf(PreparedStatementResultSetWrapper).wasNull_ilge1c_k$ = function () {
    return this.resultSet_1.wasNull_ilge1c_k$();
  };
  protoOf(PreparedStatementResultSetWrapper).close_yn9xrc_k$ = function () {
    try {
      if (!this.resultSet_1.isClosed_baxhhm_k$()) {
        this.resultSet_1.close_yn9xrc_k$();
      }
    } catch ($p) {
      if ($p instanceof SQLException) {
        var e = $p;
        throw e;
      } else {
        throw $p;
      }
    }
    finally {
      if (!this.stmt_1.getConnection_hr2oto_k$().isClosed_baxhhm_k$() ? !this.stmt_1.isClosed_baxhhm_k$() : false) {
        this.stmt_1.close_yn9xrc_k$();
      }
    }
  };
  function get_doorPrimaryKeyManager(_this__u8e3s4) {
    var tmp = get_rootDatabase(_this__u8e3s4);
    return (isInterface(tmp, DoorDatabaseJdbc) ? tmp : THROW_CCE()).get_realPrimaryKeyManager_s5zvav_k$();
  }
  function get_sourceDatabase(_this__u8e3s4) {
    var tmp;
    if (isInterface(_this__u8e3s4, DoorDatabaseJdbc)) {
      tmp = null;
    } else {
      if (isInterface(_this__u8e3s4, DoorDatabaseRepository)) {
        tmp = _this__u8e3s4.get_db_knto1l_k$();
      } else {
        if (isInterface(_this__u8e3s4, DoorDatabaseWrapper)) {
          tmp = _this__u8e3s4.get_realDatabase_fu4k1q_k$();
        } else {
          throw IllegalStateException_init_$Create$('SourceDatabase : Not a recognized implementation: ' + getKClassFromExpression(_this__u8e3s4));
        }
      }
    }
    return tmp;
  }
  function prepareAndUseStatementAsync(_this__u8e3s4, stmtConfig, block, $completion) {
    var tmp = new $prepareAndUseStatementAsyncCOROUTINE$0(_this__u8e3s4, stmtConfig, block, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  }
  function prepareAndUseStatementAsync$slambda$lambda($jdbcImpl, $stmtConfig) {
    return function () {
      return '[prepareAndUseStatementAsync - ' + $jdbcImpl.get_jdbcImplHelper_iauze6_k$().get_dbName_c9i0qa_k$() + '] - prepare "' + $stmtConfig.get_sql_18iw0r_k$() + '"';
    };
  }
  function prepareAndUseStatementAsync$slambda($logger, $this_prepareAndUseStatementAsync, $stmtConfig, $block, $jdbcImpl, resultContinuation) {
    this.$logger_1 = $logger;
    this.$this_prepareAndUseStatementAsync_1 = $this_prepareAndUseStatementAsync;
    this.$stmtConfig_1 = $stmtConfig;
    this.$block_1 = $block;
    this.$jdbcImpl_1 = $jdbcImpl;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(prepareAndUseStatementAsync$slambda).invoke_8ggh1u_k$ = function (connection, $completion) {
    var tmp = this.create_1rn91a_k$(connection, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(prepareAndUseStatementAsync$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_8ggh1u_k$((!(p1 == null) ? isInterface(p1, Connection) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(prepareAndUseStatementAsync$slambda).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(12);
            v(this.$logger_1, VOID, prepareAndUseStatementAsync$slambda$lambda(this.$jdbcImpl_1, this.$stmtConfig_1));
            this.set_state_rjd8d0_k$(1);
            continue $sm;
          case 1:
            var tmp_0 = this;
            tmp_0.this1__1 = prepareStatement(this.connection_1, this.$this_prepareAndUseStatementAsync_1, this.$stmtConfig_1);
            this.set_state_rjd8d0_k$(2);
            continue $sm;
          case 2:
            this.set_state_rjd8d0_k$(3);
            continue $sm;
          case 3:
            this.set_state_rjd8d0_k$(4);
            continue $sm;
          case 4:
            this.set_exceptionState_fex74n_k$(9);
            this.set_exceptionState_fex74n_k$(8);
            var tmp_1 = this;
            tmp_1.stmt5__1 = this.this1__1;
            var tmp_2 = get_rootDatabase(this.$this_prepareAndUseStatementAsync_1);
            this.stmt5__1.setQueryTimeout_qepe4z_k$((isInterface(tmp_2, DoorDatabaseJdbc) ? tmp_2 : THROW_CCE()).get_jdbcQueryTimeout_rk5wkj_k$());
            this.blockStartTime6__1 = systemTimeInMillis();
            this.set_state_rjd8d0_k$(5);
            suspendResult = this.$block_1(this.stmt5__1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 5:
            var this_0 = suspendResult;
            var blockTime = systemTimeInMillis().minus_mfbszm_k$(this.blockStartTime6__1);
            if (blockTime.compareTo_9jj042_k$(new Long(1000, 0)) > 0) {
              w_0(this.$logger_1, '[prepareAndUseStatementAsync - ' + this.$jdbcImpl_1.get_jdbcImplHelper_iauze6_k$().get_dbName_c9i0qa_k$() + '] query ' + this.$stmtConfig_1.get_sql_18iw0r_k$() + ' took ' + blockTime.toString() + 'ms');
            }

            this.tmp$ret$04__1 = this_0;
            this.set_exceptionState_fex74n_k$(12);
            this.set_state_rjd8d0_k$(6);
            var tmp_3 = this;
            continue $sm;
          case 6:
            var tmp_4 = this.tmp$ret$04__1;
            this.set_exceptionState_fex74n_k$(12);
            this.this1__1.close_yn9xrc_k$();
            return tmp_4;
          case 7:
            this.set_exceptionState_fex74n_k$(12);
            var tmp_5 = this;
            this.this1__1.close_yn9xrc_k$();
            tmp_5.tmp$ret$60__1 = Unit_getInstance();
            this.set_state_rjd8d0_k$(11);
            continue $sm;
          case 8:
            this.set_exceptionState_fex74n_k$(9);
            var tmp_6 = this.get_exception_x0n6w6_k$();
            if (tmp_6 instanceof Exception) {
              var e = this.get_exception_x0n6w6_k$();
              var tmp_7 = this;
              throw e;
            } else {
              throw this.get_exception_x0n6w6_k$();
            }

          case 9:
            this.set_exceptionState_fex74n_k$(12);
            var t = this.get_exception_x0n6w6_k$();
            this.this1__1.close_yn9xrc_k$();
            throw t;
          case 10:
            this.set_exceptionState_fex74n_k$(12);
            this.this1__1.close_yn9xrc_k$();
            if (false) {
              this.set_state_rjd8d0_k$(1);
              continue $sm;
            }

            this.set_state_rjd8d0_k$(11);
            continue $sm;
          case 11:
            return this.tmp$ret$60__1;
          case 12:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e_0 = $p;
        if (this.get_exceptionState_wflpxn_k$() === 12) {
          throw e_0;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e_0);
        }
      }
     while (true);
  };
  protoOf(prepareAndUseStatementAsync$slambda).create_1rn91a_k$ = function (connection, completion) {
    var i = new prepareAndUseStatementAsync$slambda(this.$logger_1, this.$this_prepareAndUseStatementAsync_1, this.$stmtConfig_1, this.$block_1, this.$jdbcImpl_1, completion);
    i.connection_1 = connection;
    return i;
  };
  protoOf(prepareAndUseStatementAsync$slambda).create_wyq9v6_k$ = function (value, completion) {
    return this.create_1rn91a_k$((!(value == null) ? isInterface(value, Connection) : false) ? value : THROW_CCE(), completion);
  };
  function prepareAndUseStatementAsync$slambda_0($logger, $this_prepareAndUseStatementAsync, $stmtConfig, $block, $jdbcImpl, resultContinuation) {
    var i = new prepareAndUseStatementAsync$slambda($logger, $this_prepareAndUseStatementAsync, $stmtConfig, $block, $jdbcImpl, resultContinuation);
    var l = function (connection, $completion) {
      return i.invoke_8ggh1u_k$(connection, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function $prepareAndUseStatementAsyncCOROUTINE$0(_this__u8e3s4, stmtConfig, block, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
    this.stmtConfig_1 = stmtConfig;
    this.block_1 = block;
  }
  protoOf($prepareAndUseStatementAsyncCOROUTINE$0).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(3);
            var tmp_0 = this;
            var tmp_1 = get_rootDatabase(this._this__u8e3s4__1);
            tmp_0.jdbcImpl0__1 = isInterface(tmp_1, RoomJdbcImpl) ? tmp_1 : THROW_CCE();
            this.logger1__1 = this.jdbcImpl0__1.get_jdbcImplHelper_iauze6_k$().get_logger_g9gejd_k$();
            this.set_exceptionState_fex74n_k$(2);
            this.set_state_rjd8d0_k$(1);
            var tmp_2 = this.jdbcImpl0__1.get_jdbcImplHelper_iauze6_k$();
            var tmp_3 = this.stmtConfig_1.get_readOnly_ovku97_k$();
            suspendResult = tmp_2.useConnectionAsync_98htgj_k$(tmp_3, prepareAndUseStatementAsync$slambda_0(this.logger1__1, this._this__u8e3s4__1, this.stmtConfig_1, this.block_1, this.jdbcImpl0__1, null), this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            return suspendResult;
          case 2:
            this.set_exceptionState_fex74n_k$(3);
            var tmp_4 = this.get_exception_x0n6w6_k$();
            if (tmp_4 instanceof Exception) {
              var e_0 = this.get_exception_x0n6w6_k$();
              if (!(e_0 instanceof CancellationException)) {
                e(this.logger1__1, '[prepareAndUseStatementAsync - ' + this.jdbcImpl0__1.get_jdbcImplHelper_iauze6_k$().get_dbName_c9i0qa_k$() + '] - Exception running ' + this.stmtConfig_1.get_sql_18iw0r_k$(), e_0);
              }
              throw e_0;
            } else {
              throw this.get_exception_x0n6w6_k$();
            }

          case 3:
            throw this.get_exception_x0n6w6_k$();
          case 4:
            this.set_exceptionState_fex74n_k$(3);
            return Unit_getInstance();
        }
      } catch ($p) {
        var e_1 = $p;
        if (this.get_exceptionState_wflpxn_k$() === 3) {
          throw e_1;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e_1);
        }
      }
     while (true);
  };
  function _get_tableNames__thvz2n($this) {
    return $this.tableNames_1;
  }
  function _get_observers__lk71bg($this) {
    return $this.observers_1;
  }
  function _get_weakObservers__c6vcd0($this) {
    return $this.weakObservers_1;
  }
  function fireChanges($this, listToFire) {
    var tmp = Napier_getInstance();
    var tmp_0 = Companion_getInstance_12().get_LOG_TAG_it8mba_k$();
    tmp.v$default_i2q2w7_k$(VOID, tmp_0, InvalidationTracker$fireChanges$lambda(listToFire));
    // Inline function 'kotlin.collections.filter' call
    // Inline function 'kotlin.collections.filterTo' call
    var this_0 = $this.observers_1;
    var destination = ArrayList_init_$Create$();
    var tmp0_iterator = this_0.iterator_jk1svi_k$();
    while (tmp0_iterator.hasNext_bitz1p_k$()) {
      var element = tmp0_iterator.next_20eer_k$();
      // Inline function 'com.ustadmobile.door.room.InvalidationTracker.fireChanges.<anonymous>' call
      var tmp$ret$1;
      $l$block: {
        // Inline function 'kotlin.collections.any' call
        var indexedObject = element.get_tables_ju165q_k$();
        var inductionVariable = 0;
        var last = indexedObject.length;
        while (inductionVariable < last) {
          var element_0 = indexedObject[inductionVariable];
          inductionVariable = inductionVariable + 1 | 0;
          // Inline function 'com.ustadmobile.door.room.InvalidationTracker.fireChanges.<anonymous>.<anonymous>' call
          if (listToFire.contains_aljjnj_k$(element_0)) {
            tmp$ret$1 = true;
            break $l$block;
          }
        }
        tmp$ret$1 = false;
      }
      if (tmp$ret$1) {
        destination.add_utx5q5_k$(element);
      }
    }
    var affectedObservers = destination;
    // Inline function 'kotlin.collections.forEach' call
    var tmp0_iterator_0 = affectedObservers.iterator_jk1svi_k$();
    while (tmp0_iterator_0.hasNext_bitz1p_k$()) {
      var element_1 = tmp0_iterator_0.next_20eer_k$();
      // Inline function 'com.ustadmobile.door.room.InvalidationTracker.fireChanges.<anonymous>' call
      element_1.onInvalidated_v59v8q_k$(listToFire);
    }
    // Inline function 'kotlin.collections.mapNotNull' call
    // Inline function 'kotlin.collections.mapNotNullTo' call
    var this_1 = $this.weakObservers_1;
    var destination_0 = ArrayList_init_$Create$();
    // Inline function 'kotlin.collections.forEach' call
    var tmp0_iterator_1 = this_1.iterator_jk1svi_k$();
    while (tmp0_iterator_1.hasNext_bitz1p_k$()) {
      var element_2 = tmp0_iterator_1.next_20eer_k$();
      // Inline function 'kotlin.collections.mapNotNullTo.<anonymous>' call
      // Inline function 'com.ustadmobile.door.room.InvalidationTracker.fireChanges.<anonymous>' call
      var observer = element_2.get_26vq_k$();
      var tmp_1;
      var tmp_2;
      if (!(observer == null)) {
        var tmp$ret$6;
        $l$block_0: {
          // Inline function 'kotlin.collections.any' call
          var indexedObject_0 = observer.get_tables_ju165q_k$();
          var inductionVariable_0 = 0;
          var last_0 = indexedObject_0.length;
          while (inductionVariable_0 < last_0) {
            var element_3 = indexedObject_0[inductionVariable_0];
            inductionVariable_0 = inductionVariable_0 + 1 | 0;
            // Inline function 'com.ustadmobile.door.room.InvalidationTracker.fireChanges.<anonymous>.<anonymous>' call
            if (listToFire.contains_aljjnj_k$(element_3)) {
              tmp$ret$6 = true;
              break $l$block_0;
            }
          }
          tmp$ret$6 = false;
        }
        tmp_2 = tmp$ret$6;
      } else {
        tmp_2 = false;
      }
      if (tmp_2) {
        tmp_1 = observer;
      } else {
        tmp_1 = null;
      }
      var tmp0_safe_receiver = tmp_1;
      if (tmp0_safe_receiver == null)
        null;
      else {
        // Inline function 'kotlin.let' call
        // Inline function 'kotlin.contracts.contract' call
        destination_0.add_utx5q5_k$(tmp0_safe_receiver);
      }
    }
    var affectedWeakObservers = destination_0;
    // Inline function 'kotlin.collections.forEach' call
    var tmp0_iterator_2 = affectedWeakObservers.iterator_jk1svi_k$();
    while (tmp0_iterator_2.hasNext_bitz1p_k$()) {
      var element_4 = tmp0_iterator_2.next_20eer_k$();
      // Inline function 'com.ustadmobile.door.room.InvalidationTracker.fireChanges.<anonymous>' call
      element_4.onInvalidated_v59v8q_k$(listToFire);
    }
    removeAll($this.weakObservers_1, InvalidationTracker$fireChanges$lambda_0);
  }
  function Companion_0() {
    Companion_instance_0 = this;
    this.UPDATE_TABLE_NAME_1 = 'door_update_mods';
    this.TABLE_ID_COLNAME_1 = 'tableId';
    this.TABLE_INVALIDATED_COLNAME_1 = 'invalidated';
    this.CREATE_TEMP_TABLE_SQL_1 = 'CREATE TEMP TABLE IF NOT EXISTS door_update_mods (tableId INTEGER PRIMARY KEY, invalidated INTEGER NOT NULL DEFAULT 0)';
    this.CREATE_TABLE_SQL_1 = 'CREATE TABLE IF NOT EXISTS door_update_mods (tableId INTEGER PRIMARY KEY, invalidated INTEGER NOT NULL DEFAULT 0)';
    this.FIND_CHANGED_TABLES_SQL_1 = 'SELECT tableId FROM door_update_mods WHERE invalidated = 1';
    this.RESET_CHANGED_TABLES_SQL_1 = '\n            UPDATE door_update_mods \n               SET invalidated = 0 \n             WHERE invalidated = 1\n        ';
  }
  protoOf(Companion_0).generateCreateTriggersSql_julqud_k$ = function (tableNames, temporary) {
    var tempStr = temporary ? 'TEMP' : '';
    var createTableSql = temporary ? 'CREATE TEMP TABLE IF NOT EXISTS door_update_mods (tableId INTEGER PRIMARY KEY, invalidated INTEGER NOT NULL DEFAULT 0)' : 'CREATE TABLE IF NOT EXISTS door_update_mods (tableId INTEGER PRIMARY KEY, invalidated INTEGER NOT NULL DEFAULT 0)';
    var tmp = listOf(createTableSql);
    // Inline function 'kotlin.collections.mapIndexed' call
    // Inline function 'kotlin.collections.mapIndexedTo' call
    var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(tableNames, 10));
    var index = 0;
    var tmp0_iterator = tableNames.iterator_jk1svi_k$();
    while (tmp0_iterator.hasNext_bitz1p_k$()) {
      var item = tmp0_iterator.next_20eer_k$();
      // Inline function 'com.ustadmobile.door.room.Companion.generateCreateTriggersSql.<anonymous>' call
      var tmp1 = index;
      index = tmp1 + 1 | 0;
      var tableId = checkIndexOverflow(tmp1);
      var tmp_0 = listOf('INSERT OR IGNORE INTO door_update_mods (tableId, invalidated) ' + ('VALUES (' + tableId + ', 0)'));
      // Inline function 'kotlin.collections.map' call
      var this_0 = listOf_0(['UPDATE', 'INSERT', 'DELETE']);
      // Inline function 'kotlin.collections.mapTo' call
      var destination_0 = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10));
      var tmp0_iterator_0 = this_0.iterator_jk1svi_k$();
      while (tmp0_iterator_0.hasNext_bitz1p_k$()) {
        var item_0 = tmp0_iterator_0.next_20eer_k$();
        // Inline function 'com.ustadmobile.door.room.Companion.generateCreateTriggersSql.<anonymous>.<anonymous>' call
        var tmp$ret$0 = 'CREATE ' + tempStr + ' TRIGGER IF NOT EXISTS door_mod_trigger_' + item + '_' + item_0 + ' \n                   AFTER ' + item_0 + '\n                   ON ' + item + ' \n                   BEGIN \n                   UPDATE door_update_mods\n                      SET invalidated = 1 \n                    WHERE tableId = ' + tableId + '\n                      AND invalidated = 0;\n                    END \n                    ';
        destination_0.add_utx5q5_k$(tmp$ret$0);
      }
      var tmp$ret$3 = plus(tmp_0, destination_0);
      destination.add_utx5q5_k$(tmp$ret$3);
    }
    return plus(tmp, flatten(destination));
  };
  protoOf(Companion_0).generateCreateTriggersSql$default_bxjzhb_k$ = function (tableNames, temporary, $super) {
    temporary = temporary === VOID ? true : temporary;
    return $super === VOID ? this.generateCreateTriggersSql_julqud_k$(tableNames, temporary) : $super.generateCreateTriggersSql_julqud_k$.call(this, tableNames, temporary);
  };
  protoOf(Companion_0).get_UPDATE_TABLE_NAME_vd737t_k$ = function () {
    return this.UPDATE_TABLE_NAME_1;
  };
  protoOf(Companion_0).get_TABLE_ID_COLNAME_y553y7_k$ = function () {
    return this.TABLE_ID_COLNAME_1;
  };
  protoOf(Companion_0).get_TABLE_INVALIDATED_COLNAME_rkwfh7_k$ = function () {
    return this.TABLE_INVALIDATED_COLNAME_1;
  };
  protoOf(Companion_0).get_CREATE_TEMP_TABLE_SQL_mxkmfo_k$ = function () {
    return this.CREATE_TEMP_TABLE_SQL_1;
  };
  protoOf(Companion_0).get_CREATE_TABLE_SQL_6ltxib_k$ = function () {
    return this.CREATE_TABLE_SQL_1;
  };
  protoOf(Companion_0).get_FIND_CHANGED_TABLES_SQL_mlda64_k$ = function () {
    return this.FIND_CHANGED_TABLES_SQL_1;
  };
  protoOf(Companion_0).get_RESET_CHANGED_TABLES_SQL_g6wri0_k$ = function () {
    return this.RESET_CHANGED_TABLES_SQL_1;
  };
  var Companion_instance_0;
  function Companion_getInstance_3() {
    if (Companion_instance_0 == null)
      new Companion_0();
    return Companion_instance_0;
  }
  function InvalidationTracker$fireChanges$lambda($listToFire) {
    return function () {
      return '' + ('InvalidationTracker: tables invalidated: ' + joinToString($listToFire));
    };
  }
  function InvalidationTracker$fireChanges$lambda_0(it) {
    return it.get_26vq_k$() == null;
  }
  function InvalidationTracker$findChangedTablesOnConnection$lambda$lambda(this$0) {
    return function (it) {
      return this$0.tableNames_1.get_c1px32_k$(it.getInt_s8uc8x_k$(1));
    };
  }
  function InvalidationTracker$findChangedTablesOnConnection$lambda(this$0) {
    return function (results) {
      return mapRows(results, InvalidationTracker$findChangedTablesOnConnection$lambda$lambda(this$0));
    };
  }
  function InvalidationTracker$findChangedTablesOnConnectionAsync$lambda$lambda(this$0) {
    return function (it) {
      return this$0.tableNames_1.get_c1px32_k$(it.getInt_s8uc8x_k$(1));
    };
  }
  function InvalidationTracker$findChangedTablesOnConnectionAsync$lambda(this$0) {
    return function (results) {
      return mapRows(results, InvalidationTracker$findChangedTablesOnConnectionAsync$lambda$lambda(this$0));
    };
  }
  function $setupSqliteTriggersAsyncCOROUTINE$1(_this__u8e3s4, connection, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
    this.connection_1 = connection;
  }
  protoOf($setupSqliteTriggersAsyncCOROUTINE$1).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(10);
            this.set_state_rjd8d0_k$(1);
            continue $sm;
          case 1:
            var tmp_0 = this;
            tmp_0.this1__1 = this.connection_1.createStatement_cbd7tf_k$();
            this.set_state_rjd8d0_k$(2);
            continue $sm;
          case 2:
            this.set_state_rjd8d0_k$(3);
            continue $sm;
          case 3:
            this.set_exceptionState_fex74n_k$(9);
            this.set_exceptionState_fex74n_k$(8);
            var tmp_1 = this;
            tmp_1.stmt4__1 = this.this1__1;
            var tmp_2 = this;
            tmp_2.this5__1 = Companion_getInstance_3().generateCreateTriggersSql$default_bxjzhb_k$(this._this__u8e3s4__1.tableNames_1);
            this.tmp0_iterator6__1 = this.this5__1.iterator_jk1svi_k$();
            this.set_state_rjd8d0_k$(4);
            continue $sm;
          case 4:
            if (!this.tmp0_iterator6__1.hasNext_bitz1p_k$()) {
              this.set_state_rjd8d0_k$(6);
              continue $sm;
            }

            this.element7__1 = this.tmp0_iterator6__1.next_20eer_k$();
            var tmp_3 = this;
            tmp_3.sql8__1 = this.element7__1;
            this.set_state_rjd8d0_k$(5);
            suspendResult = executeUpdateAsync(this.stmt4__1, this.sql8__1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 5:
            this.set_state_rjd8d0_k$(4);
            continue $sm;
          case 6:
            this.tmp$ret$03__1 = Unit_getInstance();
            this.set_exceptionState_fex74n_k$(10);
            this.set_state_rjd8d0_k$(7);
            var tmp_4 = this;
            continue $sm;
          case 7:
            this.set_exceptionState_fex74n_k$(10);
            var tmp_5 = this;
            this.this1__1.close_yn9xrc_k$();
            tmp_5.tmp$ret$40__1 = Unit_getInstance();
            this.set_state_rjd8d0_k$(12);
            continue $sm;
          case 8:
            this.set_exceptionState_fex74n_k$(9);
            var tmp_6 = this.get_exception_x0n6w6_k$();
            if (tmp_6 instanceof Exception) {
              var e = this.get_exception_x0n6w6_k$();
              var tmp_7 = this;
              throw e;
            } else {
              throw this.get_exception_x0n6w6_k$();
            }

          case 9:
            this.set_exceptionState_fex74n_k$(10);
            var t = this.get_exception_x0n6w6_k$();
            this.this1__1.close_yn9xrc_k$();
            throw t;
          case 10:
            throw this.get_exception_x0n6w6_k$();
          case 11:
            this.set_exceptionState_fex74n_k$(10);
            this.this1__1.close_yn9xrc_k$();
            if (false) {
              this.set_state_rjd8d0_k$(1);
              continue $sm;
            }

            this.set_state_rjd8d0_k$(12);
            continue $sm;
          case 12:
            return Unit_getInstance();
        }
      } catch ($p) {
        var e_0 = $p;
        if (this.get_exceptionState_wflpxn_k$() === 10) {
          throw e_0;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e_0);
        }
      }
     while (true);
  };
  function $findChangedTablesOnConnectionAsyncCOROUTINE$2(_this__u8e3s4, connection, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
    this.connection_1 = connection;
  }
  protoOf($findChangedTablesOnConnectionAsyncCOROUTINE$2).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(17);
            this.set_state_rjd8d0_k$(1);
            continue $sm;
          case 1:
            var tmp_0 = this;
            tmp_0.this1__1 = this.connection_1.prepareStatement_f6j8eq_k$('SELECT tableId FROM door_update_mods WHERE invalidated = 1');
            this.set_state_rjd8d0_k$(2);
            continue $sm;
          case 2:
            this.set_state_rjd8d0_k$(3);
            continue $sm;
          case 3:
            this.set_exceptionState_fex74n_k$(7);
            this.set_exceptionState_fex74n_k$(6);
            var tmp_1 = this;
            tmp_1.stmt4__1 = this.this1__1;
            this.set_state_rjd8d0_k$(4);
            suspendResult = executeQueryAsyncKmp(this.stmt4__1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 4:
            this.ARGUMENT5__1 = suspendResult;
            var tmp_2 = this;
            tmp_2.tmp$ret$03__1 = useResults(this.ARGUMENT5__1, InvalidationTracker$findChangedTablesOnConnectionAsync$lambda(this._this__u8e3s4__1));
            this.set_exceptionState_fex74n_k$(17);
            this.set_state_rjd8d0_k$(5);
            var tmp_3 = this;
            continue $sm;
          case 5:
            this.tmp6__1 = this.tmp$ret$03__1;
            this.set_exceptionState_fex74n_k$(17);
            this.this1__1.close_yn9xrc_k$();
            this.tmp$ret$40__1 = this.tmp6__1;
            this.set_state_rjd8d0_k$(9);
            continue $sm;
          case 6:
            this.set_exceptionState_fex74n_k$(7);
            var tmp_4 = this.get_exception_x0n6w6_k$();
            if (tmp_4 instanceof Exception) {
              this.e7__1 = this.get_exception_x0n6w6_k$();
              var tmp_5 = this;
              throw this.e7__1;
            } else {
              throw this.get_exception_x0n6w6_k$();
            }

          case 7:
            this.set_exceptionState_fex74n_k$(17);
            this.t8__1 = this.get_exception_x0n6w6_k$();
            this.this1__1.close_yn9xrc_k$();
            throw this.t8__1;
          case 8:
            this.set_exceptionState_fex74n_k$(17);
            this.this1__1.close_yn9xrc_k$();
            if (false) {
              this.set_state_rjd8d0_k$(1);
              continue $sm;
            }

            this.set_state_rjd8d0_k$(9);
            continue $sm;
          case 9:
            this.changedTables9__1 = this.tmp$ret$40__1;
            this.set_state_rjd8d0_k$(10);
            continue $sm;
          case 10:
            var tmp_6 = this;
            tmp_6.this11__1 = this.connection_1.prepareStatement_f6j8eq_k$('\n            UPDATE door_update_mods \n               SET invalidated = 0 \n             WHERE invalidated = 1\n        ');
            this.set_state_rjd8d0_k$(11);
            continue $sm;
          case 11:
            this.set_state_rjd8d0_k$(12);
            continue $sm;
          case 12:
            this.set_exceptionState_fex74n_k$(16);
            this.set_exceptionState_fex74n_k$(15);
            var tmp_7 = this;
            tmp_7.stmt14__1 = this.this11__1;
            this.set_state_rjd8d0_k$(13);
            suspendResult = executeUpdateAsyncKmp(this.stmt14__1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 13:
            this.tmp$ret$613__1 = suspendResult;
            this.set_exceptionState_fex74n_k$(17);
            this.set_state_rjd8d0_k$(14);
            var tmp_8 = this;
            continue $sm;
          case 14:
            var tmp_9 = this.tmp$ret$613__1;
            this.set_exceptionState_fex74n_k$(17);
            this.this11__1.close_yn9xrc_k$();
            this.tmp$ret$1010__1 = tmp_9;
            this.set_state_rjd8d0_k$(19);
            continue $sm;
          case 15:
            this.set_exceptionState_fex74n_k$(16);
            var tmp_10 = this.get_exception_x0n6w6_k$();
            if (tmp_10 instanceof Exception) {
              var e = this.get_exception_x0n6w6_k$();
              var tmp_11 = this;
              throw e;
            } else {
              throw this.get_exception_x0n6w6_k$();
            }

          case 16:
            this.set_exceptionState_fex74n_k$(17);
            var t = this.get_exception_x0n6w6_k$();
            this.this11__1.close_yn9xrc_k$();
            throw t;
          case 17:
            throw this.get_exception_x0n6w6_k$();
          case 18:
            this.set_exceptionState_fex74n_k$(17);
            this.this11__1.close_yn9xrc_k$();
            if (false) {
              this.set_state_rjd8d0_k$(10);
              continue $sm;
            }

            this.set_state_rjd8d0_k$(19);
            continue $sm;
          case 19:
            return this.changedTables9__1;
        }
      } catch ($p) {
        var e_0 = $p;
        if (this.get_exceptionState_wflpxn_k$() === 17) {
          throw e_0;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e_0);
        }
      }
     while (true);
  };
  function InvalidationTracker(tables) {
    Companion_getInstance_3();
    this.tableNames_1 = toList(tables);
    this.observers_1 = concurrentSafeListOf([]);
    this.weakObservers_1 = concurrentSafeListOf([]);
  }
  protoOf(InvalidationTracker).addObserver_wpl76o_k$ = function (observer) {
    // Inline function 'kotlin.collections.plusAssign' call
    this.observers_1.add_utx5q5_k$(observer);
  };
  protoOf(InvalidationTracker).removeObserver_i1cen1_k$ = function (observer) {
    // Inline function 'kotlin.collections.minusAssign' call
    this.observers_1.remove_cedx0m_k$(observer);
  };
  protoOf(InvalidationTracker).addWeakObserver_o9vq7s_k$ = function (observer) {
    // Inline function 'kotlin.collections.plusAssign' call
    var this_0 = this.weakObservers_1;
    var element = weakRefOf(observer);
    this_0.add_utx5q5_k$(element);
  };
  protoOf(InvalidationTracker).onTablesInvalidated_lvy657_k$ = function (tableNames) {
    fireChanges(this, tableNames);
  };
  protoOf(InvalidationTracker).setupSqliteTriggers_z7aq6z_k$ = function (connection) {
    $l$block: {
      // Inline function 'com.ustadmobile.door.jdbc.ext.useStatement' call
      var this_0 = connection.createStatement_cbd7tf_k$();
      try {
        var tmp0_iterator = Companion_getInstance_3().generateCreateTriggersSql$default_bxjzhb_k$(this.tableNames_1).iterator_jk1svi_k$();
        while (tmp0_iterator.hasNext_bitz1p_k$()) {
          var element = tmp0_iterator.next_20eer_k$();
          // Inline function 'com.ustadmobile.door.room.InvalidationTracker.setupSqliteTriggers.<anonymous>.<anonymous>' call
          this_0.executeUpdate_k6x04k_k$(element);
        }
        break $l$block;
      } catch ($p) {
        if ($p instanceof Exception) {
          var e = $p;
          throw e;
        } else {
          throw $p;
        }
      }
      finally {
        this_0.close_yn9xrc_k$();
      }
    }
  };
  protoOf(InvalidationTracker).setupSqliteTriggersAsync_6tji8i_k$ = function (connection, $completion) {
    var tmp = new $setupSqliteTriggersAsyncCOROUTINE$1(this, connection, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(InvalidationTracker).findChangedTablesOnConnection_e292jy_k$ = function (connection) {
    var tmp$ret$1;
    $l$block: {
      // Inline function 'com.ustadmobile.door.jdbc.ext.useStatement' call
      var this_0 = connection.prepareStatement_f6j8eq_k$('SELECT tableId FROM door_update_mods WHERE invalidated = 1');
      try {
        // Inline function 'com.ustadmobile.door.room.InvalidationTracker.findChangedTablesOnConnection.<anonymous>' call
        var tmp = this_0.executeQuery_mh7xd9_k$();
        tmp$ret$1 = useResults(tmp, InvalidationTracker$findChangedTablesOnConnection$lambda(this));
        break $l$block;
      } catch ($p) {
        if ($p instanceof Exception) {
          var e = $p;
          throw e;
        } else {
          throw $p;
        }
      }
      finally {
        this_0.close_yn9xrc_k$();
      }
    }
    var changedTables = tmp$ret$1;
    $l$block_0: {
      // Inline function 'com.ustadmobile.door.jdbc.ext.useStatement' call
      var this_1 = connection.prepareStatement_f6j8eq_k$('\n            UPDATE door_update_mods \n               SET invalidated = 0 \n             WHERE invalidated = 1\n        ');
      try {
        // Inline function 'com.ustadmobile.door.room.InvalidationTracker.findChangedTablesOnConnection.<anonymous>' call
        this_1.executeUpdate_fapcbi_k$();
        break $l$block_0;
      } catch ($p) {
        if ($p instanceof Exception) {
          var e_0 = $p;
          throw e_0;
        } else {
          throw $p;
        }
      }
      finally {
        this_1.close_yn9xrc_k$();
      }
    }
    return changedTables;
  };
  protoOf(InvalidationTracker).findChangedTablesOnConnectionAsync_sc896d_k$ = function (connection, $completion) {
    var tmp = new $findChangedTablesOnConnectionAsyncCOROUTINE$2(this, connection, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  function InvalidationTrackerObserver(tables) {
    this.tables_1 = tables;
  }
  protoOf(InvalidationTrackerObserver).get_tables_ju165q_k$ = function () {
    return this.tables_1;
  };
  function RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda$lambda($connectionLogPrefix, $t, $transactionStartTime) {
    return function () {
      return $connectionLogPrefix + ' : cancelled ' + $t.message + ' after ' + systemTimeInMillis().minus_mfbszm_k$($transactionStartTime).toString() + 'ms';
    };
  }
  function RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda($block, $transactionContext, resultContinuation) {
    this.$block_1 = $block;
    this.$transactionContext_1 = $transactionContext;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda).invoke_nd4u9n_k$ = function ($this$withContext, $completion) {
    var tmp = this.create_rcuf4x_k$($this$withContext, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_nd4u9n_k$((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            this.set_state_rjd8d0_k$(1);
            suspendResult = this.$block_1(this.$transactionContext_1.connection_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            return suspendResult;
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda).create_rcuf4x_k$ = function ($this$withContext, completion) {
    var i = new RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda(this.$block_1, this.$transactionContext_1, completion);
    i.$this$withContext_1 = $this$withContext;
    return i;
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda).create_wyq9v6_k$ = function (value, completion) {
    return this.create_rcuf4x_k$((!(value == null) ? isInterface(value, CoroutineScope) : false) ? value : THROW_CCE(), completion);
  };
  function RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda_0($block, $transactionContext, resultContinuation) {
    var i = new RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda($block, $transactionContext, resultContinuation);
    var l = function ($this$withContext, $completion) {
      return i.invoke_nd4u9n_k$($this$withContext, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda_1(this$0, $readOnly, $block, resultContinuation) {
    this.this$0__1 = this$0;
    this.$readOnly_1 = $readOnly;
    this.$block_1 = $block;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda_1).invoke_nd4u9n_k$ = function ($this$withTimeout, $completion) {
    var tmp = this.create_rcuf4x_k$($this$withTimeout, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda_1).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_nd4u9n_k$((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda_1).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(6);
            var tmp_0 = this;
            tmp_0.this0__1 = this.this$0__1.sqliteMutex_1;
            var tmp_1 = this;
            tmp_1.owner1__1 = null;
            this.set_state_rjd8d0_k$(1);
            suspendResult = this.this0__1.lock_ugrcvf_k$(this.owner1__1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            this.set_state_rjd8d0_k$(2);
            continue $sm;
          case 2:
            this.set_exceptionState_fex74n_k$(5);
            this.set_state_rjd8d0_k$(3);
            suspendResult = useNewConnectionAsyncInternal(this.this$0__1, this.$readOnly_1, this.$block_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 3:
            this.tmp$ret$02__1 = suspendResult;
            this.set_exceptionState_fex74n_k$(6);
            this.set_state_rjd8d0_k$(4);
            continue $sm;
          case 4:
            var tmp_2 = this.tmp$ret$02__1;
            this.set_exceptionState_fex74n_k$(6);
            this.this0__1.unlock_ulcrcl_k$(this.owner1__1);
            return tmp_2;
          case 5:
            this.set_exceptionState_fex74n_k$(6);
            var t = this.get_exception_x0n6w6_k$();
            this.this0__1.unlock_ulcrcl_k$(this.owner1__1);
            throw t;
          case 6:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 6) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda_1).create_rcuf4x_k$ = function ($this$withTimeout, completion) {
    var i = new RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda_1(this.this$0__1, this.$readOnly_1, this.$block_1, completion);
    i.$this$withTimeout_1 = $this$withTimeout;
    return i;
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda_1).create_wyq9v6_k$ = function (value, completion) {
    return this.create_rcuf4x_k$((!(value == null) ? isInterface(value, CoroutineScope) : false) ? value : THROW_CCE(), completion);
  };
  function RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda_2(this$0, $readOnly, $block, resultContinuation) {
    var i = new RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda_1(this$0, $readOnly, $block, resultContinuation);
    var l = function ($this$withTimeout, $completion) {
      return i.invoke_nd4u9n_k$($this$withTimeout, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda_3(this$0, $readOnly, $block, resultContinuation) {
    this.this$0__1 = this$0;
    this.$readOnly_1 = $readOnly;
    this.$block_1 = $block;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda_3).invoke_nd4u9n_k$ = function ($this$withTimeout, $completion) {
    var tmp = this.create_rcuf4x_k$($this$withTimeout, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda_3).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_nd4u9n_k$((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda_3).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            this.set_state_rjd8d0_k$(1);
            suspendResult = useNewConnectionAsyncInternal(this.this$0__1, this.$readOnly_1, this.$block_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            return suspendResult;
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda_3).create_rcuf4x_k$ = function ($this$withTimeout, completion) {
    var i = new RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda_3(this.this$0__1, this.$readOnly_1, this.$block_1, completion);
    i.$this$withTimeout_1 = $this$withTimeout;
    return i;
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda_3).create_wyq9v6_k$ = function (value, completion) {
    return this.create_rcuf4x_k$((!(value == null) ? isInterface(value, CoroutineScope) : false) ? value : THROW_CCE(), completion);
  };
  function RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda_4(this$0, $readOnly, $block, resultContinuation) {
    var i = new RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda_3(this$0, $readOnly, $block, resultContinuation);
    var l = function ($this$withTimeout, $completion) {
      return i.invoke_nd4u9n_k$($this$withTimeout, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function _get_tableNames__thvz2n_0($this) {
    return $this.tableNames_1;
  }
  function _get_transactionIdAtomic__5082jx($this) {
    return $this.transactionIdAtomic_1;
  }
  function _get_openTransactions__d41e5o($this) {
    return $this.openTransactions_1;
  }
  function _get_listeners__760gzy($this) {
    return $this.listeners_1;
  }
  function _set_closed__kdb0et($this, _set____db54di) {
    $this.closed_1 = _set____db54di;
  }
  function _get_closed__iwkfs1($this) {
    return $this.closed_1;
  }
  function Listener() {
  }
  function TransactionElement(key, connection, transactionId, readOnly) {
    transactionId = transactionId === VOID ? 0 : transactionId;
    this.key_1 = key;
    this.connection_1 = connection;
    this.transactionId_1 = transactionId;
    this.readOnly_1 = readOnly;
  }
  protoOf(TransactionElement).get_key_18j28a_k$ = function () {
    return this.key_1;
  };
  protoOf(TransactionElement).get_connection_x01z89_k$ = function () {
    return this.connection_1;
  };
  protoOf(TransactionElement).get_transactionId_674h9s_k$ = function () {
    return this.transactionId_1;
  };
  protoOf(TransactionElement).get_readOnly_ovku97_k$ = function () {
    return this.readOnly_1;
  };
  function useNewConnectionAsyncInternal($this, readOnly, block, $completion) {
    var tmp = new $useNewConnectionAsyncInternalCOROUTINE$3($this, readOnly, block, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  }
  function Key_0() {
    Key_instance = this;
  }
  var Key_instance;
  function Key_getInstance() {
    if (Key_instance == null)
      new Key_0();
    return Key_instance;
  }
  function RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$lambda($connectionLogPrefix, $readOnly) {
    return function () {
      return $connectionLogPrefix + ' - start readOnly=' + $readOnly;
    };
  }
  function RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$lambda_0($connectionLogPrefix) {
    return function () {
      return $connectionLogPrefix + ': creating SQLite change triggers ';
    };
  }
  function RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda($block, $transactionElement, resultContinuation) {
    this.$block_1 = $block;
    this.$transactionElement_1 = $transactionElement;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda).invoke_nd4u9n_k$ = function ($this$withContext, $completion) {
    var tmp = this.create_rcuf4x_k$($this$withContext, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_nd4u9n_k$((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            this.set_state_rjd8d0_k$(1);
            suspendResult = this.$block_1(this.$transactionElement_1.connection_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            return suspendResult;
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda).create_rcuf4x_k$ = function ($this$withContext, completion) {
    var i = new RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda(this.$block_1, this.$transactionElement_1, completion);
    i.$this$withContext_1 = $this$withContext;
    return i;
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda).create_wyq9v6_k$ = function (value, completion) {
    return this.create_rcuf4x_k$((!(value == null) ? isInterface(value, CoroutineScope) : false) ? value : THROW_CCE(), completion);
  };
  function RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda_0($block, $transactionElement, resultContinuation) {
    var i = new RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda($block, $transactionElement, resultContinuation);
    var l = function ($this$withContext, $completion) {
      return i.invoke_nd4u9n_k$($this$withContext, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$lambda_1($connectionLogPrefix, $changes) {
    return function () {
      return $connectionLogPrefix + ': SQLite Change Tracker: Changed tables=[' + joinToString($changes) + ']';
    };
  }
  function RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$lambda_2($connectionLogPrefix) {
    return function () {
      return $connectionLogPrefix + ' committed changes';
    };
  }
  function RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda_1(this$0, $changedTables, resultContinuation) {
    this.this$0__1 = this$0;
    this.$changedTables_1 = $changedTables;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda_1).invoke_d9fzmj_k$ = function ($this$launch, $completion) {
    var tmp = this.create_rcuf4x_k$($this$launch, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda_1).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_d9fzmj_k$((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda_1).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        if (tmp === 0) {
          this.set_exceptionState_fex74n_k$(1);
          this.this$0__1.invalidationTracker_1.onTablesInvalidated_lvy657_k$(toSet(this.$changedTables_1));
          return Unit_getInstance();
        } else if (tmp === 1) {
          throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        throw e;
      }
     while (true);
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda_1).create_rcuf4x_k$ = function ($this$launch, completion) {
    var i = new RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda_1(this.this$0__1, this.$changedTables_1, completion);
    i.$this$launch_1 = $this$launch;
    return i;
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda_1).create_wyq9v6_k$ = function (value, completion) {
    return this.create_rcuf4x_k$((!(value == null) ? isInterface(value, CoroutineScope) : false) ? value : THROW_CCE(), completion);
  };
  function RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda_2(this$0, $changedTables, resultContinuation) {
    var i = new RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda_1(this$0, $changedTables, resultContinuation);
    var l = function ($this$launch, $completion) {
      return i.invoke_d9fzmj_k$($this$launch, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda_3($t, this$0, $connectionLogPrefix, $connection, $readOnly, $connectionId, $transactionStartTime, resultContinuation) {
    this.$t_1 = $t;
    this.this$0__1 = this$0;
    this.$connectionLogPrefix_1 = $connectionLogPrefix;
    this.$connection_1 = $connection;
    this.$readOnly_1 = $readOnly;
    this.$connectionId_1 = $connectionId;
    this.$transactionStartTime_1 = $transactionStartTime;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda_3).invoke_d9fzmj_k$ = function ($this$withContext, $completion) {
    var tmp = this.create_rcuf4x_k$($this$withContext, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda_3).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_d9fzmj_k$((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda_3).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(4);
            var tmp_0 = this.$t_1;
            if (tmp_0 instanceof CancellationException) {
              v(this.this$0__1.logger_1, VOID, RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda$lambda(this.$connectionLogPrefix_1, this.$t_1, this.$transactionStartTime_1));
            } else {
              e(this.this$0__1.logger_1, this.$connectionLogPrefix_1 + ' exception ', this.$t_1);
            }

            if (!this.$connection_1.isClosed_baxhhm_k$() ? !this.$readOnly_1 : false) {
              i(this.this$0__1.logger_1, this.$connectionLogPrefix_1 + ' Attempting to rollback transaction #' + this.$connectionId_1);
              var tmp_1 = this.$connection_1;
              if (isInterface(tmp_1, ConnectionAsync)) {
                this.set_state_rjd8d0_k$(1);
                suspendResult = this.$connection_1.rollbackAsync_usrhnj_k$(this);
                if (suspendResult === get_COROUTINE_SUSPENDED()) {
                  return suspendResult;
                }
                continue $sm;
              } else {
                this.$connection_1.rollback_r7r9ck_k$();
                this.set_state_rjd8d0_k$(2);
                continue $sm;
              }
            } else {
              this.set_state_rjd8d0_k$(3);
              continue $sm;
            }

          case 1:
            this.set_state_rjd8d0_k$(2);
            continue $sm;
          case 2:
            i(this.this$0__1.logger_1, this.$connectionLogPrefix_1 + ' Rolled back changes');
            this.set_state_rjd8d0_k$(3);
            continue $sm;
          case 3:
            return Unit_getInstance();
          case 4:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e_0 = $p;
        if (this.get_exceptionState_wflpxn_k$() === 4) {
          throw e_0;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e_0);
        }
      }
     while (true);
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda_3).create_rcuf4x_k$ = function ($this$withContext, completion) {
    var i = new RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda_3(this.$t_1, this.this$0__1, this.$connectionLogPrefix_1, this.$connection_1, this.$readOnly_1, this.$connectionId_1, this.$transactionStartTime_1, completion);
    i.$this$withContext_1 = $this$withContext;
    return i;
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda_3).create_wyq9v6_k$ = function (value, completion) {
    return this.create_rcuf4x_k$((!(value == null) ? isInterface(value, CoroutineScope) : false) ? value : THROW_CCE(), completion);
  };
  function RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda_4($t, this$0, $connectionLogPrefix, $connection, $readOnly, $connectionId, $transactionStartTime, resultContinuation) {
    var i = new RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda_3($t, this$0, $connectionLogPrefix, $connection, $readOnly, $connectionId, $transactionStartTime, resultContinuation);
    var l = function ($this$withContext, $completion) {
      return i.invoke_d9fzmj_k$($this$withContext, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$lambda_3($connectionLogPrefix, $connectionId) {
    return function () {
      return $connectionLogPrefix + ': end transaction #' + $connectionId;
    };
  }
  function RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda(this$0, $readOnly, $block, resultContinuation) {
    this.this$0__1 = this$0;
    this.$readOnly_1 = $readOnly;
    this.$block_1 = $block;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda).invoke_nd4u9n_k$ = function ($this$withContext, $completion) {
    var tmp = this.create_rcuf4x_k$($this$withContext, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_nd4u9n_k$((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(5);
            this.transactionContext0__1 = this.$this$withContext_1.get_coroutineContext_115oqo_k$().get_y2st91_k$(Key_getInstance());
            var tmp_0 = this;
            var tmp_1 = get_rootDatabase(this.this$0__1.db_1);
            tmp_0.dbQueryTimeoutMs1__1 = toLong(imul((isInterface(tmp_1, DoorDatabaseJdbc) ? tmp_1 : THROW_CCE()).get_jdbcQueryTimeout_rk5wkj_k$(), 1000));
            if (!(this.transactionContext0__1 == null)) {
              if (this.transactionContext0__1.readOnly_1 ? !this.$readOnly_1 : false) {
                throw IllegalStateException_init_$Create$('Current transaction context is read-only');
              }
              this.set_state_rjd8d0_k$(3);
              suspendResult = withContext(this.transactionContext0__1, RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda_0(this.$block_1, this.transactionContext0__1, null), this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            } else {
              if (this.this$0__1.dbType_1 === Companion_getInstance_5().get_SQLITE_3yc5jp_k$()) {
                this.set_state_rjd8d0_k$(2);
                suspendResult = withTimeout(this.dbQueryTimeoutMs1__1, RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda_2(this.this$0__1, this.$readOnly_1, this.$block_1, null), this);
                if (suspendResult === get_COROUTINE_SUSPENDED()) {
                  return suspendResult;
                }
                continue $sm;
              } else {
                this.set_state_rjd8d0_k$(1);
                suspendResult = withTimeout(this.dbQueryTimeoutMs1__1, RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda$slambda_4(this.this$0__1, this.$readOnly_1, this.$block_1, null), this);
                if (suspendResult === get_COROUTINE_SUSPENDED()) {
                  return suspendResult;
                }
                continue $sm;
              }
            }

          case 1:
            this.WHEN_RESULT2__1 = suspendResult;
            this.set_state_rjd8d0_k$(4);
            continue $sm;
          case 2:
            this.WHEN_RESULT2__1 = suspendResult;
            this.set_state_rjd8d0_k$(4);
            continue $sm;
          case 3:
            this.WHEN_RESULT2__1 = suspendResult;
            this.set_state_rjd8d0_k$(4);
            continue $sm;
          case 4:
            return this.WHEN_RESULT2__1;
          case 5:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 5) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda).create_rcuf4x_k$ = function ($this$withContext, completion) {
    var i = new RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda(this.this$0__1, this.$readOnly_1, this.$block_1, completion);
    i.$this$withContext_1 = $this$withContext;
    return i;
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda).create_wyq9v6_k$ = function (value, completion) {
    return this.create_rcuf4x_k$((!(value == null) ? isInterface(value, CoroutineScope) : false) ? value : THROW_CCE(), completion);
  };
  function RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda_0(this$0, $readOnly, $block, resultContinuation) {
    var i = new RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda(this$0, $readOnly, $block, resultContinuation);
    var l = function ($this$withContext, $completion) {
      return i.invoke_nd4u9n_k$($this$withContext, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function $useNewConnectionAsyncInternalCOROUTINE$3(_this__u8e3s4, readOnly, block, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
    this.readOnly_1 = readOnly;
    this.block_1 = block;
  }
  protoOf($useNewConnectionAsyncInternalCOROUTINE$3).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(28);
            this._this__u8e3s4__1.assertNotClosed_modxnt_k$();
            this.connection0__1 = this._this__u8e3s4__1.dataSource_1.getConnection_hr2oto_k$();
            this.connectionId1__1 = this._this__u8e3s4__1.transactionIdAtomic_1.atomicfu$incrementAndGet();
            this.connectionLogPrefix2__1 = this._this__u8e3s4__1.logPrefix_1 + ' - useNewConnectionAsyncInternal connection #' + this.connectionId1__1 + ' ';
            v(this._this__u8e3s4__1.logger_1, VOID, RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$lambda(this.connectionLogPrefix2__1, this.readOnly_1));
            if (!this.readOnly_1) {
              var tmp_0 = this.connection0__1;
              if (isInterface(tmp_0, ConnectionAsync)) {
                this.set_state_rjd8d0_k$(1);
                suspendResult = this.connection0__1.setAutoCommitAsync_dpyye2_k$(false, this);
                if (suspendResult === get_COROUTINE_SUSPENDED()) {
                  return suspendResult;
                }
                continue $sm;
              } else {
                this.connection0__1.setAutoCommit_yh8u8d_k$(false);
                this.set_state_rjd8d0_k$(2);
                continue $sm;
              }
            } else {
              this.set_state_rjd8d0_k$(3);
              continue $sm;
            }

          case 1:
            this.set_state_rjd8d0_k$(2);
            continue $sm;
          case 2:
            this.set_state_rjd8d0_k$(3);
            continue $sm;
          case 3:
            this.transactionStartTime3__1 = systemTimeInMillis();
            this.changedTables4__1 = mutableLinkedListOf_0([]);
            this.set_state_rjd8d0_k$(4);
            continue $sm;
          case 4:
            this.set_state_rjd8d0_k$(5);
            continue $sm;
          case 5:
            this.set_exceptionState_fex74n_k$(27);
            this.set_exceptionState_fex74n_k$(24);
            if (!this.readOnly_1 ? this._this__u8e3s4__1.dbType_1 === Companion_getInstance_5().get_SQLITE_3yc5jp_k$() : false) {
              v(this._this__u8e3s4__1.logger_1, VOID, RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$lambda_0(this.connectionLogPrefix2__1));
              this.set_state_rjd8d0_k$(6);
              suspendResult = this._this__u8e3s4__1.setupSqliteTriggersAsync_ncp3ds_k$(this.connection0__1, this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            } else {
              this.set_state_rjd8d0_k$(7);
              continue $sm;
            }

          case 6:
            this.set_state_rjd8d0_k$(7);
            continue $sm;
          case 7:
            this.transactionElement7__1 = new TransactionElement(Key_getInstance(), this.connection0__1, this.connectionId1__1, this.readOnly_1);
            var this_0 = this._this__u8e3s4__1.openTransactions_1;
            var key = this.connectionId1__1;
            var value = this.transactionElement7__1;
            this_0.put_4fpzoq_k$(key, value);
            var tmp_1 = this;
            tmp_1.this8__1 = this._this__u8e3s4__1.listeners_1;
            this.tmp0_iterator9__1 = this.this8__1.iterator_jk1svi_k$();
            this.set_state_rjd8d0_k$(8);
            continue $sm;
          case 8:
            if (!this.tmp0_iterator9__1.hasNext_bitz1p_k$()) {
              this.set_state_rjd8d0_k$(10);
              continue $sm;
            }

            this.element10__1 = this.tmp0_iterator9__1.next_20eer_k$();
            var tmp_2 = this;
            tmp_2.it11__1 = this.element10__1;
            this.set_state_rjd8d0_k$(9);
            suspendResult = this.it11__1.onBeforeTransactionAsync_mscshz_k$(this.readOnly_1, this.connection0__1, this.connectionId1__1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 9:
            this.set_state_rjd8d0_k$(8);
            continue $sm;
          case 10:
            this.set_state_rjd8d0_k$(11);
            suspendResult = withContext(this.transactionElement7__1, RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda_0(this.block_1, this.transactionElement7__1, null), this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 11:
            this.result12__1 = suspendResult;
            if (!this.readOnly_1 ? this._this__u8e3s4__1.dbType_1 === Companion_getInstance_5().get_SQLITE_3yc5jp_k$() : false) {
              this.set_state_rjd8d0_k$(12);
              suspendResult = this._this__u8e3s4__1.invalidationTracker_1.findChangedTablesOnConnectionAsync_sc896d_k$(this.connection0__1, this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            } else {
              this.set_state_rjd8d0_k$(13);
              continue $sm;
            }

          case 12:
            this.changes13__1 = suspendResult;
            d_0(this._this__u8e3s4__1.logger_1, VOID, RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$lambda_1(this.connectionLogPrefix2__1, this.changes13__1));
            this.changedTables4__1.addAll_4lagoh_k$(this.changes13__1);
            this.set_state_rjd8d0_k$(13);
            continue $sm;
          case 13:
            var tmp_3 = this;
            tmp_3.this14__1 = this._this__u8e3s4__1.listeners_1;
            this.tmp0_iterator15__1 = this.this14__1.iterator_jk1svi_k$();
            this.set_state_rjd8d0_k$(14);
            continue $sm;
          case 14:
            if (!this.tmp0_iterator15__1.hasNext_bitz1p_k$()) {
              this.set_state_rjd8d0_k$(16);
              continue $sm;
            }

            this.element16__1 = this.tmp0_iterator15__1.next_20eer_k$();
            var tmp_4 = this;
            tmp_4.it17__1 = this.element16__1;
            this.set_state_rjd8d0_k$(15);
            suspendResult = this.it17__1.onAfterTransactionAsync_hxd2oq_k$(this.readOnly_1, this.connection0__1, this.connectionId1__1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 15:
            this.set_state_rjd8d0_k$(14);
            continue $sm;
          case 16:
            if (!this.readOnly_1) {
              var tmp_5 = this.connection0__1;
              if (isInterface(tmp_5, ConnectionAsync)) {
                this.set_state_rjd8d0_k$(17);
                suspendResult = this.connection0__1.commitAsync_wepez2_k$(this);
                if (suspendResult === get_COROUTINE_SUSPENDED()) {
                  return suspendResult;
                }
                continue $sm;
              } else {
                this.connection0__1.commit_vpt10n_k$();
                this.set_state_rjd8d0_k$(18);
                continue $sm;
              }
            } else {
              this.set_state_rjd8d0_k$(19);
              continue $sm;
            }

          case 17:
            this.set_state_rjd8d0_k$(18);
            continue $sm;
          case 18:
            v(this._this__u8e3s4__1.logger_1, VOID, RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$lambda_2(this.connectionLogPrefix2__1));
            this.set_state_rjd8d0_k$(19);
            continue $sm;
          case 19:
            var tmp_6 = this;
            tmp_6.this18__1 = this._this__u8e3s4__1.listeners_1;
            this.tmp0_iterator19__1 = this.this18__1.iterator_jk1svi_k$();
            this.set_state_rjd8d0_k$(20);
            continue $sm;
          case 20:
            if (!this.tmp0_iterator19__1.hasNext_bitz1p_k$()) {
              this.set_state_rjd8d0_k$(22);
              continue $sm;
            }

            this.element20__1 = this.tmp0_iterator19__1.next_20eer_k$();
            var tmp_7 = this;
            tmp_7.it21__1 = this.element20__1;
            this.set_state_rjd8d0_k$(21);
            suspendResult = this.it21__1.onTransactionCommittedAsync_g9ntmy_k$(this.readOnly_1, this.connection0__1, this.connectionId1__1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 21:
            this.set_state_rjd8d0_k$(20);
            continue $sm;
          case 22:
            var this_1 = this._this__u8e3s4__1.scope_1;
            var tmp_8;
            if (!this.changedTables4__1.isEmpty_y1axqb_k$()) {
              tmp_8 = this_1;
            } else {
              tmp_8 = null;
            }

            var tmp0_safe_receiver = tmp_8;
            if (tmp0_safe_receiver == null)
              null;
            else {
              launch(tmp0_safe_receiver, VOID, VOID, RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda_2(this._this__u8e3s4__1, this.changedTables4__1, null));
            }

            this.tmp$ret$06__1 = this.result12__1;
            this.set_exceptionState_fex74n_k$(28);
            this.set_state_rjd8d0_k$(23);
            var tmp_9 = this;
            continue $sm;
          case 23:
            this.tmp22__1 = this.tmp$ret$06__1;
            this.set_exceptionState_fex74n_k$(28);
            this.connection0__1.close_yn9xrc_k$();
            this._this__u8e3s4__1.openTransactions_1.remove_gppy8k_k$(this.connectionId1__1);
            v(this._this__u8e3s4__1.logger_1, VOID, RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$lambda_3(this.connectionLogPrefix2__1, this.connectionId1__1));
            if (!this._this__u8e3s4__1.openTransactions_1.isEmpty_y1axqb_k$()) {
              w_0(this._this__u8e3s4__1.logger_1, 'useConnectionAsync: close transaction ' + this.connectionId1__1 + ' (took ' + systemTimeInMillis().minus_mfbszm_k$(this.transactionStartTime3__1).toString() + 'ms).' + ('There are Transactions [' + joinToString(this._this__u8e3s4__1.openTransactions_1.get_keys_wop4xp_k$()) + '] pending async transactions still open.'));
            }

            return this.tmp22__1;
          case 24:
            this.set_exceptionState_fex74n_k$(27);
            var tmp_10 = this.get_exception_x0n6w6_k$();
            if (tmp_10 instanceof Error) {
              this.t23__1 = this.get_exception_x0n6w6_k$();
              this.set_state_rjd8d0_k$(25);
              var tmp_11 = NonCancellable_getInstance();
              suspendResult = withContext(tmp_11, RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$slambda_4(this.t23__1, this._this__u8e3s4__1, this.connectionLogPrefix2__1, this.connection0__1, this.readOnly_1, this.connectionId1__1, this.transactionStartTime3__1, null), this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            } else {
              throw this.get_exception_x0n6w6_k$();
            }

          case 25:
            var tmp_12 = this;
            throw this.t23__1;
          case 26:
            this.set_exceptionState_fex74n_k$(28);
            this.connection0__1.close_yn9xrc_k$();
            this._this__u8e3s4__1.openTransactions_1.remove_gppy8k_k$(this.connectionId1__1);
            v(this._this__u8e3s4__1.logger_1, VOID, RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$lambda_3(this.connectionLogPrefix2__1, this.connectionId1__1));
            if (!this._this__u8e3s4__1.openTransactions_1.isEmpty_y1axqb_k$()) {
              w_0(this._this__u8e3s4__1.logger_1, 'useConnectionAsync: close transaction ' + this.connectionId1__1 + ' (took ' + systemTimeInMillis().minus_mfbszm_k$(this.transactionStartTime3__1).toString() + 'ms).' + ('There are Transactions [' + joinToString(this._this__u8e3s4__1.openTransactions_1.get_keys_wop4xp_k$()) + '] pending async transactions still open.'));
            }

            return Unit_getInstance();
          case 27:
            this.set_exceptionState_fex74n_k$(28);
            var t = this.get_exception_x0n6w6_k$();
            this.connection0__1.close_yn9xrc_k$();
            this._this__u8e3s4__1.openTransactions_1.remove_gppy8k_k$(this.connectionId1__1);
            v(this._this__u8e3s4__1.logger_1, VOID, RoomDatabaseJdbcImplHelperCommon$useNewConnectionAsyncInternal$lambda_3(this.connectionLogPrefix2__1, this.connectionId1__1));
            if (!this._this__u8e3s4__1.openTransactions_1.isEmpty_y1axqb_k$()) {
              w_0(this._this__u8e3s4__1.logger_1, 'useConnectionAsync: close transaction ' + this.connectionId1__1 + ' (took ' + systemTimeInMillis().minus_mfbszm_k$(this.transactionStartTime3__1).toString() + 'ms).' + ('There are Transactions [' + joinToString(this._this__u8e3s4__1.openTransactions_1.get_keys_wop4xp_k$()) + '] pending async transactions still open.'));
            }

            throw t;
          case 28:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 28) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  function RoomDatabaseJdbcImplHelperCommon(dataSource, db, dbName, logger, tableNames, invalidationTracker, dbType, dispatcher) {
    Key_getInstance();
    dbType = dbType === VOID ? Companion_getInstance_5().get_SQLITE_3yc5jp_k$() : dbType;
    dispatcher = dispatcher === VOID ? Dispatchers_getInstance().get_Default_goqax4_k$() : dispatcher;
    this.dataSource_1 = dataSource;
    this.db_1 = db;
    this.dbName_1 = dbName;
    this.logger_1 = logger;
    this.tableNames_1 = tableNames;
    this.invalidationTracker_1 = invalidationTracker;
    this.dbType_1 = dbType;
    this.transactionIdAtomic_1 = atomic$int$1(0);
    this.openTransactions_1 = concurrentSafeMapOf([]);
    this.sqliteMutex_1 = Mutex();
    this.listeners_1 = concurrentSafeListOf([]);
    this.closed_1 = atomic$boolean$1(false);
    this.logPrefix_1 = '[RoomJdbcImplHelper - ' + this.dbName_1 + ']';
    this.scope_1 = CoroutineScope_0(dispatcher.plus_s13ygv_k$(Job()));
  }
  protoOf(RoomDatabaseJdbcImplHelperCommon).get_dataSource_vce0e_k$ = function () {
    return this.dataSource_1;
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon).get_db_knto1l_k$ = function () {
    return this.db_1;
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon).get_dbName_c9i0qa_k$ = function () {
    return this.dbName_1;
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon).get_logger_g9gejd_k$ = function () {
    return this.logger_1;
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon).get_invalidationTracker_tp0k9d_k$ = function () {
    return this.invalidationTracker_1;
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon).get_dbType_c9mcip_k$ = function () {
    return this.dbType_1;
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon).get_sqliteMutex_j9dq52_k$ = function () {
    return this.sqliteMutex_1;
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon).get_logPrefix_vopxo3_k$ = function () {
    return this.logPrefix_1;
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon).get_scope_iyfcq3_k$ = function () {
    return this.scope_1;
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon).assertNotClosed_modxnt_k$ = function () {
    if (this.closed_1.get_kotlinx$atomicfu$value_vi2am5_k$())
      throw IllegalStateException_init_$Create$('' + this + ' is closed!');
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon).useConnectionAsync_98htgj_k$ = function (readOnly, block, $completion) {
    var tmp = this.scope_1.get_coroutineContext_115oqo_k$();
    return withContext(tmp, RoomDatabaseJdbcImplHelperCommon$useConnectionAsync$slambda_0(this, readOnly, block, null), $completion);
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon).useConnectionAsync_y1du5w_k$ = function (block, $completion) {
    return this.useConnectionAsync_98htgj_k$(false, block, $completion);
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon).addListener_xad3hi_k$ = function (listener) {
    // Inline function 'kotlin.collections.plusAssign' call
    this.listeners_1.add_utx5q5_k$(listener);
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon).removeListener_iok9nb_k$ = function (listener) {
    // Inline function 'kotlin.collections.minusAssign' call
    this.listeners_1.remove_cedx0m_k$(listener);
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon).onStartChangeTracking_lhwimy_k$ = function () {
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon).close_yn9xrc_k$ = function () {
    if (!this.closed_1.atomicfu$getAndSet(true)) {
      // Inline function 'kotlin.collections.forEach' call
      // Inline function 'kotlin.collections.iterator' call
      var tmp0_iterator = this.openTransactions_1.get_entries_p20ztl_k$().iterator_jk1svi_k$();
      while (tmp0_iterator.hasNext_bitz1p_k$()) {
        var element = tmp0_iterator.next_20eer_k$();
        // Inline function 'com.ustadmobile.door.room.RoomDatabaseJdbcImplHelperCommon.close.<anonymous>' call
        try {
          element.get_value_j01efc_k$().connection_1.close_yn9xrc_k$();
        } catch ($p) {
          if ($p instanceof Exception) {
            var e = $p;
            w_0(this.logger_1, this.logPrefix_1 + ' : exception closing connection for transaction #' + element.get_key_18j28a_k$());
          } else {
            throw $p;
          }
        }
      }
      this.openTransactions_1.clear_j9egeb_k$();
      this.onClose_84idtj_k$();
      cancel(this.scope_1, 'Database closed');
    }
  };
  protoOf(RoomDatabaseJdbcImplHelperCommon).onClose_84idtj_k$ = function () {
  };
  function RoomJdbcImpl() {
  }
  function dropDoorTriggersAndReceiveViewsSqlite(_this__u8e3s4, $completion) {
    var tmp = new $dropDoorTriggersAndReceiveViewsSqliteCOROUTINE$4(_this__u8e3s4, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  }
  function getSqliteDoorTriggerNames(_this__u8e3s4, $completion) {
    var tmp = new $getSqliteDoorTriggerNamesCOROUTINE$5(_this__u8e3s4, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  }
  function getSqliteDoorReceiveViewNames(_this__u8e3s4, $completion) {
    var tmp = new $getSqliteDoorReceiveViewNamesCOROUTINE$6(_this__u8e3s4, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  }
  function getSqliteDoorTriggerNames$lambda(results) {
    return mapRows(results, getSqliteDoorTriggerNames$lambda$lambda);
  }
  function getSqliteDoorTriggerNames$lambda$lambda(resultSet) {
    return resultSet.getString_5demq7_k$(1);
  }
  function getSqliteDoorReceiveViewNames$lambda(results) {
    return mapRows(results, getSqliteDoorReceiveViewNames$lambda$lambda);
  }
  function getSqliteDoorReceiveViewNames$lambda$lambda(resultSet) {
    return resultSet.getString_5demq7_k$(1);
  }
  function $dropDoorTriggersAndReceiveViewsSqliteCOROUTINE$4(_this__u8e3s4, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
  }
  protoOf($dropDoorTriggersAndReceiveViewsSqliteCOROUTINE$4).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(25);
            this.set_state_rjd8d0_k$(1);
            suspendResult = getSqliteDoorTriggerNames(this._this__u8e3s4__1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            this.triggerNames0__1 = suspendResult;
            this.set_state_rjd8d0_k$(2);
            continue $sm;
          case 2:
            var tmp_0 = this;
            tmp_0.this2__1 = this._this__u8e3s4__1.createStatement_cbd7tf_k$();
            this.set_state_rjd8d0_k$(3);
            continue $sm;
          case 3:
            this.set_state_rjd8d0_k$(4);
            continue $sm;
          case 4:
            this.set_exceptionState_fex74n_k$(10);
            this.set_exceptionState_fex74n_k$(9);
            var tmp_1 = this;
            tmp_1.stmt5__1 = this.this2__1;
            var tmp_2 = this;
            tmp_2.this6__1 = this.triggerNames0__1;
            this.tmp0_iterator7__1 = this.this6__1.iterator_jk1svi_k$();
            this.set_state_rjd8d0_k$(5);
            continue $sm;
          case 5:
            if (!this.tmp0_iterator7__1.hasNext_bitz1p_k$()) {
              this.set_state_rjd8d0_k$(7);
              continue $sm;
            }

            this.element8__1 = this.tmp0_iterator7__1.next_20eer_k$();
            var tmp_3 = this;
            tmp_3.triggerName9__1 = this.element8__1;
            this.set_state_rjd8d0_k$(6);
            suspendResult = executeUpdateAsync(this.stmt5__1, 'DROP TRIGGER ' + this.triggerName9__1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 6:
            this.set_state_rjd8d0_k$(5);
            continue $sm;
          case 7:
            this.tmp$ret$04__1 = Unit_getInstance();
            this.set_exceptionState_fex74n_k$(25);
            this.set_state_rjd8d0_k$(8);
            var tmp_4 = this;
            continue $sm;
          case 8:
            this.set_exceptionState_fex74n_k$(25);
            var tmp_5 = this;
            this.this2__1.close_yn9xrc_k$();
            tmp_5.tmp$ret$41__1 = Unit_getInstance();
            this.set_state_rjd8d0_k$(12);
            continue $sm;
          case 9:
            this.set_exceptionState_fex74n_k$(10);
            var tmp_6 = this.get_exception_x0n6w6_k$();
            if (tmp_6 instanceof Exception) {
              this.e10__1 = this.get_exception_x0n6w6_k$();
              var tmp_7 = this;
              throw this.e10__1;
            } else {
              throw this.get_exception_x0n6w6_k$();
            }

          case 10:
            this.set_exceptionState_fex74n_k$(25);
            this.t11__1 = this.get_exception_x0n6w6_k$();
            this.this2__1.close_yn9xrc_k$();
            throw this.t11__1;
          case 11:
            this.set_exceptionState_fex74n_k$(25);
            this.this2__1.close_yn9xrc_k$();
            if (false) {
              this.set_state_rjd8d0_k$(2);
              continue $sm;
            }

            this.set_state_rjd8d0_k$(12);
            continue $sm;
          case 12:
            this.set_state_rjd8d0_k$(13);
            suspendResult = getSqliteDoorReceiveViewNames(this._this__u8e3s4__1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 13:
            this.receiveViewNames12__1 = suspendResult;
            this.set_state_rjd8d0_k$(14);
            continue $sm;
          case 14:
            var tmp_8 = this;
            tmp_8.this14__1 = this._this__u8e3s4__1.createStatement_cbd7tf_k$();
            this.set_state_rjd8d0_k$(15);
            continue $sm;
          case 15:
            this.set_state_rjd8d0_k$(16);
            continue $sm;
          case 16:
            this.set_exceptionState_fex74n_k$(22);
            this.set_exceptionState_fex74n_k$(21);
            var tmp_9 = this;
            tmp_9.it17__1 = this.this14__1;
            var tmp_10 = this;
            tmp_10.this18__1 = this.receiveViewNames12__1;
            this.tmp0_iterator19__1 = this.this18__1.iterator_jk1svi_k$();
            this.set_state_rjd8d0_k$(17);
            continue $sm;
          case 17:
            if (!this.tmp0_iterator19__1.hasNext_bitz1p_k$()) {
              this.set_state_rjd8d0_k$(19);
              continue $sm;
            }

            this.element20__1 = this.tmp0_iterator19__1.next_20eer_k$();
            var tmp_11 = this;
            tmp_11.receiveViewName21__1 = this.element20__1;
            this.set_state_rjd8d0_k$(18);
            suspendResult = executeUpdateAsync(this.it17__1, 'DROP VIEW ' + this.receiveViewName21__1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 18:
            this.set_state_rjd8d0_k$(17);
            continue $sm;
          case 19:
            this.tmp$ret$616__1 = Unit_getInstance();
            this.set_exceptionState_fex74n_k$(25);
            this.set_state_rjd8d0_k$(20);
            var tmp_12 = this;
            continue $sm;
          case 20:
            this.set_exceptionState_fex74n_k$(25);
            var tmp_13 = this;
            this.this14__1.close_yn9xrc_k$();
            tmp_13.tmp$ret$1013__1 = Unit_getInstance();
            this.set_state_rjd8d0_k$(24);
            continue $sm;
          case 21:
            this.set_exceptionState_fex74n_k$(22);
            var tmp_14 = this.get_exception_x0n6w6_k$();
            if (tmp_14 instanceof Exception) {
              var e = this.get_exception_x0n6w6_k$();
              var tmp_15 = this;
              throw e;
            } else {
              throw this.get_exception_x0n6w6_k$();
            }

          case 22:
            this.set_exceptionState_fex74n_k$(25);
            var t = this.get_exception_x0n6w6_k$();
            this.this14__1.close_yn9xrc_k$();
            throw t;
          case 23:
            this.set_exceptionState_fex74n_k$(25);
            this.this14__1.close_yn9xrc_k$();
            if (false) {
              this.set_state_rjd8d0_k$(14);
              continue $sm;
            }

            this.set_state_rjd8d0_k$(24);
            continue $sm;
          case 24:
            return Unit_getInstance();
          case 25:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e_0 = $p;
        if (this.get_exceptionState_wflpxn_k$() === 25) {
          throw e_0;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e_0);
        }
      }
     while (true);
  };
  function $getSqliteDoorTriggerNamesCOROUTINE$5(_this__u8e3s4, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
  }
  protoOf($getSqliteDoorTriggerNamesCOROUTINE$5).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(8);
            this.set_state_rjd8d0_k$(1);
            continue $sm;
          case 1:
            var tmp_0 = this;
            tmp_0.this1__1 = this._this__u8e3s4__1.prepareStatement_f6j8eq_k$(TriggerConstants_getInstance().get_SQLITE_SELECT_TRIGGER_NAMES_4rc9qw_k$());
            this.set_state_rjd8d0_k$(2);
            continue $sm;
          case 2:
            this.set_state_rjd8d0_k$(3);
            continue $sm;
          case 3:
            this.set_exceptionState_fex74n_k$(7);
            this.set_exceptionState_fex74n_k$(6);
            var tmp_1 = this;
            tmp_1.preparedStmt4__1 = this.this1__1;
            this.preparedStmt4__1.setString_2gt7ua_k$(1, Companion_getInstance_9().get_NAME_PREFIX_pvog9p_k$() + '%');
            this.set_state_rjd8d0_k$(4);
            suspendResult = executeQueryAsyncKmp(this.preparedStmt4__1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 4:
            var ARGUMENT = suspendResult;
            var tmp_2 = this;
            tmp_2.tmp$ret$03__1 = useResults(ARGUMENT, getSqliteDoorTriggerNames$lambda);
            this.set_exceptionState_fex74n_k$(8);
            this.set_state_rjd8d0_k$(5);
            var tmp_3 = this;
            continue $sm;
          case 5:
            var tmp_4 = this.tmp$ret$03__1;
            this.set_exceptionState_fex74n_k$(8);
            this.this1__1.close_yn9xrc_k$();
            this.tmp$ret$40__1 = tmp_4;
            this.set_state_rjd8d0_k$(10);
            continue $sm;
          case 6:
            this.set_exceptionState_fex74n_k$(7);
            var tmp_5 = this.get_exception_x0n6w6_k$();
            if (tmp_5 instanceof Exception) {
              var e = this.get_exception_x0n6w6_k$();
              var tmp_6 = this;
              throw e;
            } else {
              throw this.get_exception_x0n6w6_k$();
            }

          case 7:
            this.set_exceptionState_fex74n_k$(8);
            var t = this.get_exception_x0n6w6_k$();
            this.this1__1.close_yn9xrc_k$();
            throw t;
          case 8:
            throw this.get_exception_x0n6w6_k$();
          case 9:
            this.set_exceptionState_fex74n_k$(8);
            this.this1__1.close_yn9xrc_k$();
            if (false) {
              this.set_state_rjd8d0_k$(1);
              continue $sm;
            }

            this.set_state_rjd8d0_k$(10);
            continue $sm;
          case 10:
            var this_0 = this.tmp$ret$40__1;
            var destination = ArrayList_init_$Create$();
            var tmp0_iterator = this_0.iterator_jk1svi_k$();
            while (tmp0_iterator.hasNext_bitz1p_k$()) {
              var element = tmp0_iterator.next_20eer_k$();
              if (element == null)
                null;
              else {
                destination.add_utx5q5_k$(element);
              }
            }

            return destination;
        }
      } catch ($p) {
        var e_0 = $p;
        if (this.get_exceptionState_wflpxn_k$() === 8) {
          throw e_0;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e_0);
        }
      }
     while (true);
  };
  function $getSqliteDoorReceiveViewNamesCOROUTINE$6(_this__u8e3s4, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
  }
  protoOf($getSqliteDoorReceiveViewNamesCOROUTINE$6).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(8);
            this.set_state_rjd8d0_k$(1);
            continue $sm;
          case 1:
            var tmp_0 = this;
            tmp_0.this1__1 = this._this__u8e3s4__1.prepareStatement_f6j8eq_k$(TriggerConstants_getInstance().get_SQLITE_SELECT_VIEW_NAMES_bt69on_k$());
            this.set_state_rjd8d0_k$(2);
            continue $sm;
          case 2:
            this.set_state_rjd8d0_k$(3);
            continue $sm;
          case 3:
            this.set_exceptionState_fex74n_k$(7);
            this.set_exceptionState_fex74n_k$(6);
            var tmp_1 = this;
            tmp_1.preparedStatement4__1 = this.this1__1;
            this.preparedStatement4__1.setString_2gt7ua_k$(1, '%' + DoorConstants_getInstance().get_RECEIVE_VIEW_SUFFIX_agehja_k$());
            this.set_state_rjd8d0_k$(4);
            suspendResult = executeQueryAsyncKmp(this.preparedStatement4__1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 4:
            var ARGUMENT = suspendResult;
            var tmp_2 = this;
            tmp_2.tmp$ret$03__1 = useResults(ARGUMENT, getSqliteDoorReceiveViewNames$lambda);
            this.set_exceptionState_fex74n_k$(8);
            this.set_state_rjd8d0_k$(5);
            var tmp_3 = this;
            continue $sm;
          case 5:
            var tmp_4 = this.tmp$ret$03__1;
            this.set_exceptionState_fex74n_k$(8);
            this.this1__1.close_yn9xrc_k$();
            this.tmp$ret$40__1 = tmp_4;
            this.set_state_rjd8d0_k$(10);
            continue $sm;
          case 6:
            this.set_exceptionState_fex74n_k$(7);
            var tmp_5 = this.get_exception_x0n6w6_k$();
            if (tmp_5 instanceof Exception) {
              var e = this.get_exception_x0n6w6_k$();
              var tmp_6 = this;
              throw e;
            } else {
              throw this.get_exception_x0n6w6_k$();
            }

          case 7:
            this.set_exceptionState_fex74n_k$(8);
            var t = this.get_exception_x0n6w6_k$();
            this.this1__1.close_yn9xrc_k$();
            throw t;
          case 8:
            throw this.get_exception_x0n6w6_k$();
          case 9:
            this.set_exceptionState_fex74n_k$(8);
            this.this1__1.close_yn9xrc_k$();
            if (false) {
              this.set_state_rjd8d0_k$(1);
              continue $sm;
            }

            this.set_state_rjd8d0_k$(10);
            continue $sm;
          case 10:
            var this_0 = this.tmp$ret$40__1;
            var destination = ArrayList_init_$Create$();
            var tmp0_iterator = this_0.iterator_jk1svi_k$();
            while (tmp0_iterator.hasNext_bitz1p_k$()) {
              var element = tmp0_iterator.next_20eer_k$();
              if (element == null)
                null;
              else {
                destination.add_utx5q5_k$(element);
              }
            }

            return destination;
        }
      } catch ($p) {
        var e_0 = $p;
        if (this.get_exceptionState_wflpxn_k$() === 8) {
          throw e_0;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e_0);
        }
      }
     while (true);
  };
  function DoorConstants() {
    DoorConstants_instance = this;
    this.MIME_TYPE_PLAIN_1 = 'text/plain';
    this.MIME_TYPE_JSON_1 = 'application/json';
    this.HEADER_DBVERSION_1 = 'door-dbversion';
    this.HEADER_NODE_AND_AUTH_1 = 'door-node';
    this.HEADER_NODE_ID_1 = 'door-node-id';
    this.DBINFO_TABLENAME_1 = '_doorwayinfo';
    this.PGSECTION_COMMENT_PREFIX_1 = '/*psql';
    this.NOTPGSECTION_COMMENT_PREFIX_1 = '--notpsql';
    this.NOTPGSECTION_END_COMMENT_PREFIX_1 = '--endnotpsql';
    this.RECEIVE_VIEW_SUFFIX_1 = '_ReceiveView';
    this.HEADER_PAGING_END_REACHED_1 = 'door-paging-end-reached';
  }
  protoOf(DoorConstants).get_MIME_TYPE_PLAIN_9lccbr_k$ = function () {
    return this.MIME_TYPE_PLAIN_1;
  };
  protoOf(DoorConstants).get_MIME_TYPE_JSON_kxfbez_k$ = function () {
    return this.MIME_TYPE_JSON_1;
  };
  protoOf(DoorConstants).get_HEADER_DBVERSION_wpdj3j_k$ = function () {
    return this.HEADER_DBVERSION_1;
  };
  protoOf(DoorConstants).get_HEADER_NODE_AND_AUTH_2mchyc_k$ = function () {
    return this.HEADER_NODE_AND_AUTH_1;
  };
  protoOf(DoorConstants).get_HEADER_NODE_ID_n9vw0f_k$ = function () {
    return this.HEADER_NODE_ID_1;
  };
  protoOf(DoorConstants).get_DBINFO_TABLENAME_s0l67j_k$ = function () {
    return this.DBINFO_TABLENAME_1;
  };
  protoOf(DoorConstants).get_PGSECTION_COMMENT_PREFIX_2p1ohg_k$ = function () {
    return this.PGSECTION_COMMENT_PREFIX_1;
  };
  protoOf(DoorConstants).get_NOTPGSECTION_COMMENT_PREFIX_ilkn8z_k$ = function () {
    return this.NOTPGSECTION_COMMENT_PREFIX_1;
  };
  protoOf(DoorConstants).get_NOTPGSECTION_END_COMMENT_PREFIX_4igrhr_k$ = function () {
    return this.NOTPGSECTION_END_COMMENT_PREFIX_1;
  };
  protoOf(DoorConstants).get_RECEIVE_VIEW_SUFFIX_agehja_k$ = function () {
    return this.RECEIVE_VIEW_SUFFIX_1;
  };
  protoOf(DoorConstants).get_HEADER_PAGING_END_REACHED_l3srwc_k$ = function () {
    return this.HEADER_PAGING_END_REACHED_1;
  };
  var DoorConstants_instance;
  function DoorConstants_getInstance() {
    if (DoorConstants_instance == null)
      new DoorConstants();
    return DoorConstants_instance;
  }
  function DoorDatabaseCallback() {
  }
  function DoorDatabaseCallbackStatementList() {
  }
  function DoorDatabaseCallbackSync() {
  }
  function DoorDatabaseJdbc() {
  }
  function DoorDatabaseRepository() {
  }
  function Companion_1() {
    Companion_instance_1 = this;
    this.SUFFIX_1 = '_DoorWrapper';
  }
  protoOf(Companion_1).get_SUFFIX_40ffiy_k$ = function () {
    return this.SUFFIX_1;
  };
  var Companion_instance_1;
  function Companion_getInstance_4() {
    if (Companion_instance_1 == null)
      new Companion_1();
    return Companion_instance_1;
  }
  function DoorDatabaseWrapper() {
  }
  function Companion_2() {
    Companion_instance_2 = this;
    this.SQLITE_1 = 1;
    this.POSTGRES_1 = 2;
    this.SUPPORTED_TYPES_1 = listOf_0([1, 2]);
    this.PRODUCT_NAME_MAP_1 = mapOf([to('PostgreSQL', 2), to('SQLite', 1)]);
    var tmp = this;
    // Inline function 'kotlin.collections.map' call
    var this_0 = this.PRODUCT_NAME_MAP_1.get_keys_wop4xp_k$();
    // Inline function 'kotlin.collections.mapTo' call
    var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10));
    var tmp0_iterator = this_0.iterator_jk1svi_k$();
    while (tmp0_iterator.hasNext_bitz1p_k$()) {
      var item = tmp0_iterator.next_20eer_k$();
      // Inline function 'com.ustadmobile.door.Companion.PRODUCT_INT_TO_NAME_MAP.<anonymous>' call
      var tmp$ret$0 = to(Companion_getInstance_5().PRODUCT_NAME_MAP_1.get_wei43m_k$(item), item);
      destination.add_utx5q5_k$(tmp$ret$0);
    }
    tmp.PRODUCT_INT_TO_NAME_MAP_1 = toMap(destination);
  }
  protoOf(Companion_2).get_SQLITE_3yc5jp_k$ = function () {
    return this.SQLITE_1;
  };
  protoOf(Companion_2).get_POSTGRES_6bxnsu_k$ = function () {
    return this.POSTGRES_1;
  };
  protoOf(Companion_2).get_SUPPORTED_TYPES_ceyf0f_k$ = function () {
    return this.SUPPORTED_TYPES_1;
  };
  protoOf(Companion_2).get_PRODUCT_NAME_MAP_1ag7cv_k$ = function () {
    return this.PRODUCT_NAME_MAP_1;
  };
  protoOf(Companion_2).get_PRODUCT_INT_TO_NAME_MAP_gswr2b_k$ = function () {
    return this.PRODUCT_INT_TO_NAME_MAP_1;
  };
  protoOf(Companion_2).typeIntFromProductName_o9ohnl_k$ = function (productName) {
    var tmp0_elvis_lhs = this.PRODUCT_NAME_MAP_1.get_wei43m_k$(productName);
    return tmp0_elvis_lhs == null ? -1 : tmp0_elvis_lhs;
  };
  protoOf(Companion_2).productNameForDbType_o9war5_k$ = function (dbProductType) {
    switch (dbProductType) {
      case 1:
        return 'SQLite';
      case 2:
        return 'Postgres';
      default:
        return 'UNKNOWN';
    }
  };
  var Companion_instance_2;
  function Companion_getInstance_5() {
    if (Companion_instance_2 == null)
      new Companion_2();
    return Companion_instance_2;
  }
  function DoorDbType() {
    Companion_getInstance_5();
  }
  function _get_atomicWrapper__u29p93($this) {
    return $this.atomicWrapper_1;
  }
  function nextWrappedTimeAndSeqNum(_this__u8e3s4, $this) {
    var tmp$ret$5;
    $l$block: {
      // Inline function 'kotlinx.atomicfu.updateAndGet' call
      while (true) {
        var cur = _this__u8e3s4.get_kotlinx$atomicfu$value_vi2am5_k$();
        // Inline function 'com.ustadmobile.door.TablePrimaryKeyManager.nextWrappedTimeAndSeqNum.<anonymous>' call
        var lastTimestamp = cur.shr_9fl3wl_k$(32);
        var lastSeq = cur.and_4spn93_k$(toLong(IntCompanionObject_getInstance().get_MAX_VALUE_54a9lf_k$()));
        // Inline function 'com.ustadmobile.door.DoorPrimaryKeyManager.timestamp' call
        $this.$this_1;
        // Inline function 'kotlin.Long.minus' call
        // Inline function 'kotlin.Long.div' call
        var this_0 = systemTimeInMillis().div_jun7gj_k$(toLong(1000));
        var other = 1577836800;
        var newTimestamp = this_0.minus_mfbszm_k$(toLong(other));
        var tmp;
        if (newTimestamp.compareTo_9jj042_k$(lastTimestamp) > 0) {
          tmp = new Long(0, 0);
        } else {
          // Inline function 'kotlin.Long.plus' call
          tmp = lastSeq.plus_r93sks_k$(toLong(1));
        }
        var newSeq = tmp;
        var upd = newTimestamp.shl_bg8if3_k$(32).or_v7fvkl_k$(newSeq);
        if (_this__u8e3s4.atomicfu$compareAndSet(cur, upd)) {
          tmp$ret$5 = upd;
          break $l$block;
        }
      }
    }
    return tmp$ret$5;
  }
  function unwrapTime(_this__u8e3s4, $this) {
    return _this__u8e3s4.shr_9fl3wl_k$(32);
  }
  function unwrapSeqNum(_this__u8e3s4, $this) {
    return _this__u8e3s4.and_4spn93_k$(toLong(IntCompanionObject_getInstance().get_MAX_VALUE_54a9lf_k$()));
  }
  function generateId($this, currentTimestamp, nodeId, seqNum) {
    return currentTimestamp.shl_bg8if3_k$(32).or_v7fvkl_k$(nodeId.shl_bg8if3_k$(12)).or_v7fvkl_k$(seqNum);
  }
  function $nextIdAsyncCOROUTINE$7(_this__u8e3s4, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
  }
  protoOf($nextIdAsyncCOROUTINE$7).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(3);
            var tmp_0 = this;
            this._this__u8e3s4__1.$this_1;
            var this_0 = this._this__u8e3s4__1.atomicWrapper_1;
            var tmp$ret$0;
            l$ret$1: do {
              while (true) {
                var cur = this_0.get_kotlinx$atomicfu$value_vi2am5_k$();
                var lastTimestamp = cur.shr_9fl3wl_k$(32);
                var lastSeq = cur.and_4spn93_k$(toLong(IntCompanionObject_getInstance().get_MAX_VALUE_54a9lf_k$()));
                var this_1 = systemTimeInMillis().div_jun7gj_k$(toLong(1000));
                var other = 1577836800;
                var newTimestamp = this_1.minus_mfbszm_k$(toLong(other));
                var tmp_1;
                if (newTimestamp.compareTo_9jj042_k$(lastTimestamp) > 0) {
                  tmp_1 = new Long(0, 0);
                } else {
                  tmp_1 = lastSeq.plus_r93sks_k$(toLong(1));
                }
                var newSeq = tmp_1;
                var upd = newTimestamp.shl_bg8if3_k$(32).or_v7fvkl_k$(newSeq);
                if (this_0.atomicfu$compareAndSet(cur, upd)) {
                  tmp$ret$0 = upd;
                  break l$ret$1;
                }
              }
            }
             while (false);
            tmp_0.nextWrappedId0__1 = tmp$ret$0;
            this.seqNum1__1 = unwrapSeqNum(this.nextWrappedId0__1, this._this__u8e3s4__1);
            if (this.seqNum1__1.compareTo_9jj042_k$(toLong(Companion_getInstance_6().MAX_SEQUENCE_1)) < 0) {
              return generateId(this._this__u8e3s4__1, unwrapTime(this.nextWrappedId0__1, this._this__u8e3s4__1), toLong(this._this__u8e3s4__1.$this_1.get_nodeId_h7ho7a_k$()), this.seqNum1__1);
            } else {
              this.set_state_rjd8d0_k$(1);
              var this_2 = systemTimeInMillis();
              suspendResult = delay(numberToLong(1001).minus_mfbszm_k$(this_2.rem_bsnl9o_k$(toLong(1000))), this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            }

          case 1:
            return this._this__u8e3s4__1.nextId_hcfceq_k$();
          case 2:
            return Unit_getInstance();
          case 3:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 3) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  function _get_tableKeyManagers__p1qkqc($this) {
    return $this.tableKeyManagers_1;
  }
  function _get_timestamp__6mtu63($this) {
    // Inline function 'kotlin.Long.minus' call
    // Inline function 'kotlin.Long.div' call
    var this_0 = systemTimeInMillis().div_jun7gj_k$(toLong(1000));
    var other = 1577836800;
    return this_0.minus_mfbszm_k$(toLong(other));
  }
  function TablePrimaryKeyManager($outer) {
    this.$this_1 = $outer;
    this.atomicWrapper_1 = atomic$long$1(new Long(0, 0));
  }
  protoOf(TablePrimaryKeyManager).nextId_hcfceq_k$ = function () {
    // Inline function 'com.ustadmobile.door.TablePrimaryKeyManager.nextWrappedTimeAndSeqNum' call
    this.$this_1;
    var this_0 = this.atomicWrapper_1;
    var tmp$ret$5;
    $l$block: {
      // Inline function 'kotlinx.atomicfu.updateAndGet' call
      while (true) {
        var cur = this_0.get_kotlinx$atomicfu$value_vi2am5_k$();
        // Inline function 'com.ustadmobile.door.TablePrimaryKeyManager.nextWrappedTimeAndSeqNum.<anonymous>' call
        var lastTimestamp = cur.shr_9fl3wl_k$(32);
        var lastSeq = cur.and_4spn93_k$(toLong(IntCompanionObject_getInstance().get_MAX_VALUE_54a9lf_k$()));
        // Inline function 'com.ustadmobile.door.DoorPrimaryKeyManager.timestamp' call
        // Inline function 'kotlin.Long.minus' call
        // Inline function 'kotlin.Long.div' call
        var this_1 = systemTimeInMillis().div_jun7gj_k$(toLong(1000));
        var other = 1577836800;
        var newTimestamp = this_1.minus_mfbszm_k$(toLong(other));
        var tmp;
        if (newTimestamp.compareTo_9jj042_k$(lastTimestamp) > 0) {
          tmp = new Long(0, 0);
        } else {
          // Inline function 'kotlin.Long.plus' call
          tmp = lastSeq.plus_r93sks_k$(toLong(1));
        }
        var newSeq = tmp;
        var upd = newTimestamp.shl_bg8if3_k$(32).or_v7fvkl_k$(newSeq);
        if (this_0.atomicfu$compareAndSet(cur, upd)) {
          tmp$ret$5 = upd;
          break $l$block;
        }
      }
    }
    var nextWrappedId = tmp$ret$5;
    var seqNum = unwrapSeqNum(nextWrappedId, this);
    if (seqNum.compareTo_9jj042_k$(toLong(Companion_getInstance_6().MAX_SEQUENCE_1)) < 0) {
      return generateId(this, unwrapTime(nextWrappedId, this), toLong(this.$this_1.get_nodeId_h7ho7a_k$()), seqNum);
    } else {
      // Inline function 'kotlin.Long.rem' call
      var tmp$ret$7 = systemTimeInMillis().rem_bsnl9o_k$(toLong(1000));
      waitBlocking(numberToLong(1001).minus_mfbszm_k$(tmp$ret$7));
      return this.nextId_hcfceq_k$();
    }
  };
  protoOf(TablePrimaryKeyManager).nextIdAsync_lm2pgf_k$ = function ($completion) {
    var tmp = new $nextIdAsyncCOROUTINE$7(this, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  function Companion_3() {
    Companion_instance_3 = this;
    this.UNUSED_BITS_1 = 1;
    this.EPOCH_BITS_1 = 31;
    this.NODE_ID_BITS_1 = 20;
    this.SEQUENCE_BITS_1 = 12;
    var tmp = this;
    // Inline function 'kotlin.math.pow' call
    var tmp$ret$0 = Math.pow(2.0, 20);
    tmp.MAX_NODE_ID_1 = numberToInt(tmp$ret$0);
    var tmp_0 = this;
    // Inline function 'kotlin.math.pow' call
    var tmp$ret$1 = Math.pow(2.0, 12);
    tmp_0.MAX_SEQUENCE_1 = numberToInt(tmp$ret$1);
    this.CUSTOM_EPOCH_1 = 1577836800;
  }
  protoOf(Companion_3).get_UNUSED_BITS_kxk0pm_k$ = function () {
    return this.UNUSED_BITS_1;
  };
  protoOf(Companion_3).get_EPOCH_BITS_kxgeqt_k$ = function () {
    return this.EPOCH_BITS_1;
  };
  protoOf(Companion_3).get_NODE_ID_BITS_mde8c6_k$ = function () {
    return this.NODE_ID_BITS_1;
  };
  protoOf(Companion_3).get_SEQUENCE_BITS_w5d7xh_k$ = function () {
    return this.SEQUENCE_BITS_1;
  };
  protoOf(Companion_3).get_MAX_NODE_ID_cvq7tg_k$ = function () {
    return this.MAX_NODE_ID_1;
  };
  protoOf(Companion_3).get_MAX_SEQUENCE_n50rq3_k$ = function () {
    return this.MAX_SEQUENCE_1;
  };
  protoOf(Companion_3).get_CUSTOM_EPOCH_15c1i4_k$ = function () {
    return this.CUSTOM_EPOCH_1;
  };
  var Companion_instance_3;
  function Companion_getInstance_6() {
    if (Companion_instance_3 == null)
      new Companion_3();
    return Companion_instance_3;
  }
  function DoorPrimaryKeyManager$nodeId$delegate$lambda() {
    return generateDoorNodeId(Companion_getInstance_6().MAX_NODE_ID_1);
  }
  function DoorPrimaryKeyManager(tableIdList) {
    Companion_getInstance_6();
    this.tableKeyManagers_1 = threadSafeMapOf([]);
    var tmp = this;
    var tmp_0 = LazyThreadSafetyMode_NONE_getInstance();
    tmp.nodeId$delegate_1 = lazy(tmp_0, DoorPrimaryKeyManager$nodeId$delegate$lambda);
    // Inline function 'kotlin.collections.forEach' call
    var tmp0_iterator = tableIdList.iterator_jk1svi_k$();
    while (tmp0_iterator.hasNext_bitz1p_k$()) {
      var element = tmp0_iterator.next_20eer_k$();
      // Inline function 'com.ustadmobile.door.DoorPrimaryKeyManager.<anonymous>' call
      // Inline function 'kotlin.collections.set' call
      var this_0 = this.tableKeyManagers_1;
      var value = new TablePrimaryKeyManager(this);
      this_0.put_4fpzoq_k$(element, value);
    }
  }
  protoOf(DoorPrimaryKeyManager).get_nodeId_h7ho7a_k$ = function () {
    // Inline function 'kotlin.getValue' call
    var this_0 = this.nodeId$delegate_1;
    nodeId$factory();
    return this_0.get_value_j01efc_k$();
  };
  protoOf(DoorPrimaryKeyManager).nextId_8yjjmy_k$ = function (tableId) {
    return ensureNotNull(this.tableKeyManagers_1.get_wei43m_k$(tableId)).nextId_hcfceq_k$();
  };
  protoOf(DoorPrimaryKeyManager).nextIdAsync_kh60wr_k$ = function (tableId, $completion) {
    return ensureNotNull(this.tableKeyManagers_1.get_wei43m_k$(tableId)).nextIdAsync_lm2pgf_k$($completion);
  };
  function nodeId$factory() {
    return getPropertyCallableRef('nodeId', 1, KProperty1, function (receiver) {
      return receiver.get_nodeId_h7ho7a_k$();
    }, null);
  }
  function _get__baseType__5fda49($this) {
    return $this._baseType_1;
  }
  function JdbcArrayProxyCommon(typeName, objects) {
    this.typeName_1 = typeName;
    this.objects_1 = objects;
    switch (this.typeName_1) {
      case 'INTEGER':
        this._baseType_1 = TypesKmp_getInstance().get_INTEGER_pibe8b_k$();
        break;
      case 'VARCHAR':
        this._baseType_1 = TypesKmp_getInstance().get_VARCHAR_h1w92s_k$();
        break;
      case 'BIGINT':
        this._baseType_1 = TypesKmp_getInstance().get_BIGINT_47wyyw_k$();
        break;
      case 'SHORT':
        this._baseType_1 = TypesKmp_getInstance().get_SMALLINT_sw3een_k$();
        break;
      case 'BOOLEAN':
        this._baseType_1 = TypesKmp_getInstance().get_BOOLEAN_e7jswv_k$();
        break;
      case 'TEXT':
        this._baseType_1 = TypesKmp_getInstance().get_LONGVARCHAR_lmf0o_k$();
        break;
      default:
        throw IllegalStateException_init_$Create$('JdbcArrayProxyCommon: Unsupported type: ' + this.typeName_1);
    }
  }
  protoOf(JdbcArrayProxyCommon).get_typeName_s1eeum_k$ = function () {
    return this.typeName_1;
  };
  protoOf(JdbcArrayProxyCommon).get_objects_q6k34l_k$ = function () {
    return this.objects_1;
  };
  protoOf(JdbcArrayProxyCommon).getBaseTypeName_bw8aes_k$ = function () {
    return this.typeName_1;
  };
  protoOf(JdbcArrayProxyCommon).getBaseType_5w77s1_k$ = function () {
    return this._baseType_1;
  };
  protoOf(JdbcArrayProxyCommon).getArray_w8c143_k$ = function () {
    return this;
  };
  function NotSupportedException(message, cause) {
    message = message === VOID ? null : message;
    cause = cause === VOID ? null : cause;
    RuntimeException_init_$Init$(message, cause, this);
    captureStack(this, NotSupportedException);
  }
  function Companion_4() {
    Companion_instance_4 = this;
    this.STATEMENT_DEFAULT_TIMEOUT_SECS_1 = 10;
  }
  protoOf(Companion_4).get_STATEMENT_DEFAULT_TIMEOUT_SECS_3kojx3_k$ = function () {
    return this.STATEMENT_DEFAULT_TIMEOUT_SECS_1;
  };
  var Companion_instance_4;
  function Companion_getInstance_7() {
    if (Companion_instance_4 == null)
      new Companion_4();
    return Companion_instance_4;
  }
  function PreparedStatementConfig(sql, hasListParams, generatedKeys, timeoutSeconds, postgreSql, readOnly) {
    Companion_getInstance_7();
    hasListParams = hasListParams === VOID ? false : hasListParams;
    generatedKeys = generatedKeys === VOID ? StatementConstantsKmp_getInstance().get_NO_GENERATED_KEYS_h4ycm1_k$() : generatedKeys;
    timeoutSeconds = timeoutSeconds === VOID ? 10 : timeoutSeconds;
    postgreSql = postgreSql === VOID ? null : postgreSql;
    readOnly = readOnly === VOID ? false : readOnly;
    this.sql_1 = sql;
    this.hasListParams_1 = hasListParams;
    this.generatedKeys_1 = generatedKeys;
    this.timeoutSeconds_1 = timeoutSeconds;
    this.postgreSql_1 = postgreSql;
    this.readOnly_1 = readOnly;
  }
  protoOf(PreparedStatementConfig).get_sql_18iw0r_k$ = function () {
    return this.sql_1;
  };
  protoOf(PreparedStatementConfig).get_hasListParams_eih2hh_k$ = function () {
    return this.hasListParams_1;
  };
  protoOf(PreparedStatementConfig).get_generatedKeys_rooagq_k$ = function () {
    return this.generatedKeys_1;
  };
  protoOf(PreparedStatementConfig).get_timeoutSeconds_immndz_k$ = function () {
    return this.timeoutSeconds_1;
  };
  protoOf(PreparedStatementConfig).get_postgreSql_g1ajst_k$ = function () {
    return this.postgreSql_1;
  };
  protoOf(PreparedStatementConfig).get_readOnly_ovku97_k$ = function () {
    return this.readOnly_1;
  };
  protoOf(PreparedStatementConfig).sqlToUse_pxgz0m_k$ = function (dbType) {
    var tmp;
    if (dbType === Companion_getInstance_5().get_SQLITE_3yc5jp_k$()) {
      tmp = this.sql_1;
    } else {
      var tmp0_elvis_lhs = this.postgreSql_1;
      tmp = tmp0_elvis_lhs == null ? this.sql_1 : tmp0_elvis_lhs;
    }
    return tmp;
  };
  protoOf(PreparedStatementConfig).component1_7eebsc_k$ = function () {
    return this.sql_1;
  };
  protoOf(PreparedStatementConfig).component2_7eebsb_k$ = function () {
    return this.hasListParams_1;
  };
  protoOf(PreparedStatementConfig).component3_7eebsa_k$ = function () {
    return this.generatedKeys_1;
  };
  protoOf(PreparedStatementConfig).component4_7eebs9_k$ = function () {
    return this.timeoutSeconds_1;
  };
  protoOf(PreparedStatementConfig).component5_7eebs8_k$ = function () {
    return this.postgreSql_1;
  };
  protoOf(PreparedStatementConfig).component6_7eebs7_k$ = function () {
    return this.readOnly_1;
  };
  protoOf(PreparedStatementConfig).copy_15qzo4_k$ = function (sql, hasListParams, generatedKeys, timeoutSeconds, postgreSql, readOnly) {
    return new PreparedStatementConfig(sql, hasListParams, generatedKeys, timeoutSeconds, postgreSql, readOnly);
  };
  protoOf(PreparedStatementConfig).copy$default_wakw15_k$ = function (sql, hasListParams, generatedKeys, timeoutSeconds, postgreSql, readOnly, $super) {
    sql = sql === VOID ? this.sql_1 : sql;
    hasListParams = hasListParams === VOID ? this.hasListParams_1 : hasListParams;
    generatedKeys = generatedKeys === VOID ? this.generatedKeys_1 : generatedKeys;
    timeoutSeconds = timeoutSeconds === VOID ? this.timeoutSeconds_1 : timeoutSeconds;
    postgreSql = postgreSql === VOID ? this.postgreSql_1 : postgreSql;
    readOnly = readOnly === VOID ? this.readOnly_1 : readOnly;
    return $super === VOID ? this.copy_15qzo4_k$(sql, hasListParams, generatedKeys, timeoutSeconds, postgreSql, readOnly) : $super.copy_15qzo4_k$.call(this, sql, hasListParams, generatedKeys, timeoutSeconds, postgreSql, readOnly);
  };
  protoOf(PreparedStatementConfig).toString = function () {
    return 'PreparedStatementConfig(sql=' + this.sql_1 + ', hasListParams=' + this.hasListParams_1 + ', generatedKeys=' + this.generatedKeys_1 + ', timeoutSeconds=' + this.timeoutSeconds_1 + ', postgreSql=' + this.postgreSql_1 + ', readOnly=' + this.readOnly_1 + ')';
  };
  protoOf(PreparedStatementConfig).hashCode = function () {
    var result = getStringHashCode(this.sql_1);
    result = imul(result, 31) + getBooleanHashCode(this.hasListParams_1) | 0;
    result = imul(result, 31) + this.generatedKeys_1 | 0;
    result = imul(result, 31) + this.timeoutSeconds_1 | 0;
    result = imul(result, 31) + (this.postgreSql_1 == null ? 0 : getStringHashCode(this.postgreSql_1)) | 0;
    result = imul(result, 31) + getBooleanHashCode(this.readOnly_1) | 0;
    return result;
  };
  protoOf(PreparedStatementConfig).equals = function (other) {
    if (this === other)
      return true;
    if (!(other instanceof PreparedStatementConfig))
      return false;
    var tmp0_other_with_cast = other instanceof PreparedStatementConfig ? other : THROW_CCE();
    if (!(this.sql_1 === tmp0_other_with_cast.sql_1))
      return false;
    if (!(this.hasListParams_1 === tmp0_other_with_cast.hasListParams_1))
      return false;
    if (!(this.generatedKeys_1 === tmp0_other_with_cast.generatedKeys_1))
      return false;
    if (!(this.timeoutSeconds_1 === tmp0_other_with_cast.timeoutSeconds_1))
      return false;
    if (!(this.postgreSql_1 == tmp0_other_with_cast.postgreSql_1))
      return false;
    if (!(this.readOnly_1 === tmp0_other_with_cast.readOnly_1))
      return false;
    return true;
  };
  function Companion_5() {
    Companion_instance_5 = this;
    this.SELECT_LOCAL_NODE_ID_SQL_1 = '\n            (SELECT COALESCE(\n                    (SELECT nodeClientId \n                       FROM SyncNode \n                      LIMIT 1), 0))\n        ';
  }
  protoOf(Companion_5).get_SELECT_LOCAL_NODE_ID_SQL_bp9wef_k$ = function () {
    return this.SELECT_LOCAL_NODE_ID_SQL_1;
  };
  protoOf(Companion_5).serializer_9w0wvi_k$ = function () {
    return $serializer_getInstance();
  };
  var Companion_instance_5;
  function Companion_getInstance_8() {
    if (Companion_instance_5 == null)
      new Companion_5();
    return Companion_instance_5;
  }
  function $serializer() {
    $serializer_instance = this;
    var tmp0_serialDesc = new PluginGeneratedSerialDescriptor('com.ustadmobile.door.SyncNode', this, 1);
    tmp0_serialDesc.addElement_5pzumi_k$('nodeClientId', true);
    this.descriptor_1 = tmp0_serialDesc;
  }
  protoOf($serializer).get_descriptor_wjt6a0_k$ = function () {
    return this.descriptor_1;
  };
  protoOf($serializer).childSerializers_5ghqw5_k$ = function () {
    // Inline function 'kotlin.arrayOf' call
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    return [LongSerializer_getInstance()];
  };
  protoOf($serializer).deserialize_sy6x50_k$ = function (decoder) {
    var tmp0_desc = this.descriptor_1;
    var tmp1_flag = true;
    var tmp2_index = 0;
    var tmp3_bitMask0 = 0;
    var tmp4_local0 = new Long(0, 0);
    var tmp5_input = decoder.beginStructure_yljocp_k$(tmp0_desc);
    if (tmp5_input.decodeSequentially_xlblqy_k$()) {
      tmp4_local0 = tmp5_input.decodeLongElement_994anb_k$(tmp0_desc, 0);
      tmp3_bitMask0 = tmp3_bitMask0 | 1;
    } else
      while (tmp1_flag) {
        tmp2_index = tmp5_input.decodeElementIndex_bstkhp_k$(tmp0_desc);
        switch (tmp2_index) {
          case -1:
            tmp1_flag = false;
            break;
          case 0:
            tmp4_local0 = tmp5_input.decodeLongElement_994anb_k$(tmp0_desc, 0);
            tmp3_bitMask0 = tmp3_bitMask0 | 1;
            break;
          default:
            throw UnknownFieldException_init_$Create$(tmp2_index);
        }
      }
    tmp5_input.endStructure_1xqz0n_k$(tmp0_desc);
    return SyncNode_init_$Create$(tmp3_bitMask0, tmp4_local0, null);
  };
  protoOf($serializer).serialize_su696f_k$ = function (encoder, value) {
    var tmp0_desc = this.descriptor_1;
    var tmp1_output = encoder.beginStructure_yljocp_k$(tmp0_desc);
    if (tmp1_output.shouldEncodeElementDefault_x8eyid_k$(tmp0_desc, 0) ? true : !value.nodeClientId_1.equals(new Long(0, 0))) {
      tmp1_output.encodeLongElement_cega27_k$(tmp0_desc, 0, value.nodeClientId_1);
    }
    tmp1_output.endStructure_1xqz0n_k$(tmp0_desc);
  };
  protoOf($serializer).serialize_5ase3y_k$ = function (encoder, value) {
    return this.serialize_su696f_k$(encoder, value instanceof SyncNode ? value : THROW_CCE());
  };
  var $serializer_instance;
  function $serializer_getInstance() {
    if ($serializer_instance == null)
      new $serializer();
    return $serializer_instance;
  }
  function SyncNode_init_$Init$(seen1, nodeClientId, serializationConstructorMarker, $this) {
    if (!(0 === (0 & seen1))) {
      throwMissingFieldException(seen1, 0, $serializer_getInstance().descriptor_1);
    }
    if (0 === (seen1 & 1))
      $this.nodeClientId_1 = new Long(0, 0);
    else
      $this.nodeClientId_1 = nodeClientId;
    return $this;
  }
  function SyncNode_init_$Create$(seen1, nodeClientId, serializationConstructorMarker) {
    return SyncNode_init_$Init$(seen1, nodeClientId, serializationConstructorMarker, objectCreate(protoOf(SyncNode)));
  }
  function SyncNode(nodeClientId) {
    Companion_getInstance_8();
    nodeClientId = nodeClientId === VOID ? new Long(0, 0) : nodeClientId;
    this.nodeClientId_1 = nodeClientId;
  }
  protoOf(SyncNode).set_nodeClientId_wfl6e1_k$ = function (_set____db54di) {
    this.nodeClientId_1 = _set____db54di;
  };
  protoOf(SyncNode).get_nodeClientId_5fbwkx_k$ = function () {
    return this.nodeClientId_1;
  };
  protoOf(SyncNode).component1_7eebsc_k$ = function () {
    return this.nodeClientId_1;
  };
  protoOf(SyncNode).copy_dtzw2h_k$ = function (nodeClientId) {
    return new SyncNode(nodeClientId);
  };
  protoOf(SyncNode).copy$default_9zrndo_k$ = function (nodeClientId, $super) {
    nodeClientId = nodeClientId === VOID ? this.nodeClientId_1 : nodeClientId;
    return $super === VOID ? this.copy_dtzw2h_k$(nodeClientId) : $super.copy_dtzw2h_k$.call(this, nodeClientId);
  };
  protoOf(SyncNode).toString = function () {
    return 'SyncNode(nodeClientId=' + this.nodeClientId_1.toString() + ')';
  };
  protoOf(SyncNode).hashCode = function () {
    return this.nodeClientId_1.hashCode();
  };
  protoOf(SyncNode).equals = function (other) {
    if (this === other)
      return true;
    if (!(other instanceof SyncNode))
      return false;
    var tmp0_other_with_cast = other instanceof SyncNode ? other : THROW_CCE();
    if (!this.nodeClientId_1.equals(tmp0_other_with_cast.nodeClientId_1))
      return false;
    return true;
  };
  function AttachmentMd5() {
  }
  protoOf(AttachmentMd5).equals = function (other) {
    if (!(other instanceof AttachmentMd5))
      return false;
    other instanceof AttachmentMd5 || THROW_CCE();
    return true;
  };
  protoOf(AttachmentMd5).hashCode = function () {
    return 0;
  };
  protoOf(AttachmentMd5).toString = function () {
    return '@com.ustadmobile.door.annotation.AttachmentMd5()';
  };
  function AttachmentSize() {
  }
  protoOf(AttachmentSize).equals = function (other) {
    if (!(other instanceof AttachmentSize))
      return false;
    other instanceof AttachmentSize || THROW_CCE();
    return true;
  };
  protoOf(AttachmentSize).hashCode = function () {
    return 0;
  };
  protoOf(AttachmentSize).toString = function () {
    return '@com.ustadmobile.door.annotation.AttachmentSize()';
  };
  function AttachmentUri() {
  }
  protoOf(AttachmentUri).equals = function (other) {
    if (!(other instanceof AttachmentUri))
      return false;
    other instanceof AttachmentUri || THROW_CCE();
    return true;
  };
  protoOf(AttachmentUri).hashCode = function () {
    return 0;
  };
  protoOf(AttachmentUri).toString = function () {
    return '@com.ustadmobile.door.annotation.AttachmentUri()';
  };
  function EntityWithAttachment() {
  }
  protoOf(EntityWithAttachment).equals = function (other) {
    if (!(other instanceof EntityWithAttachment))
      return false;
    other instanceof EntityWithAttachment || THROW_CCE();
    return true;
  };
  protoOf(EntityWithAttachment).hashCode = function () {
    return 0;
  };
  protoOf(EntityWithAttachment).toString = function () {
    return '@com.ustadmobile.door.annotation.EntityWithAttachment()';
  };
  function LastChangedBy() {
  }
  protoOf(LastChangedBy).equals = function (other) {
    if (!(other instanceof LastChangedBy))
      return false;
    other instanceof LastChangedBy || THROW_CCE();
    return true;
  };
  protoOf(LastChangedBy).hashCode = function () {
    return 0;
  };
  protoOf(LastChangedBy).toString = function () {
    return '@com.ustadmobile.door.annotation.LastChangedBy()';
  };
  function LocalChangeSeqNum() {
  }
  protoOf(LocalChangeSeqNum).equals = function (other) {
    if (!(other instanceof LocalChangeSeqNum))
      return false;
    other instanceof LocalChangeSeqNum || THROW_CCE();
    return true;
  };
  protoOf(LocalChangeSeqNum).hashCode = function () {
    return 0;
  };
  protoOf(LocalChangeSeqNum).toString = function () {
    return '@com.ustadmobile.door.annotation.LocalChangeSeqNum()';
  };
  function MasterChangeSeqNum() {
  }
  protoOf(MasterChangeSeqNum).equals = function (other) {
    if (!(other instanceof MasterChangeSeqNum))
      return false;
    other instanceof MasterChangeSeqNum || THROW_CCE();
    return true;
  };
  protoOf(MasterChangeSeqNum).hashCode = function () {
    return 0;
  };
  protoOf(MasterChangeSeqNum).toString = function () {
    return '@com.ustadmobile.door.annotation.MasterChangeSeqNum()';
  };
  var RemoteInsertStrategy_CALLBACK_instance;
  var RemoteInsertStrategy_INSERT_instance;
  var RemoteInsertStrategy_INSERT_INTO_RECEIVE_VIEW_instance;
  function values() {
    return [RemoteInsertStrategy_CALLBACK_getInstance(), RemoteInsertStrategy_INSERT_getInstance(), RemoteInsertStrategy_INSERT_INTO_RECEIVE_VIEW_getInstance()];
  }
  function valueOf(value) {
    switch (value) {
      case 'CALLBACK':
        return RemoteInsertStrategy_CALLBACK_getInstance();
      case 'INSERT':
        return RemoteInsertStrategy_INSERT_getInstance();
      case 'INSERT_INTO_RECEIVE_VIEW':
        return RemoteInsertStrategy_INSERT_INTO_RECEIVE_VIEW_getInstance();
      default:
        RemoteInsertStrategy_initEntries();
        THROW_IAE('No enum constant value.');
        break;
    }
  }
  function get_entries() {
    if ($ENTRIES == null)
      $ENTRIES = enumEntries(values());
    return $ENTRIES;
  }
  var RemoteInsertStrategy_entriesInitialized;
  function RemoteInsertStrategy_initEntries() {
    if (RemoteInsertStrategy_entriesInitialized)
      return Unit_getInstance();
    RemoteInsertStrategy_entriesInitialized = true;
    RemoteInsertStrategy_CALLBACK_instance = new RemoteInsertStrategy('CALLBACK', 0);
    RemoteInsertStrategy_INSERT_instance = new RemoteInsertStrategy('INSERT', 1);
    RemoteInsertStrategy_INSERT_INTO_RECEIVE_VIEW_instance = new RemoteInsertStrategy('INSERT_INTO_RECEIVE_VIEW', 2);
  }
  var $ENTRIES;
  function RemoteInsertStrategy(name, ordinal) {
    Enum.call(this, name, ordinal);
  }
  function RemoteInsertStrategy_CALLBACK_getInstance() {
    RemoteInsertStrategy_initEntries();
    return RemoteInsertStrategy_CALLBACK_instance;
  }
  function RemoteInsertStrategy_INSERT_getInstance() {
    RemoteInsertStrategy_initEntries();
    return RemoteInsertStrategy_INSERT_instance;
  }
  function RemoteInsertStrategy_INSERT_INTO_RECEIVE_VIEW_getInstance() {
    RemoteInsertStrategy_initEntries();
    return RemoteInsertStrategy_INSERT_INTO_RECEIVE_VIEW_instance;
  }
  function ReplicateEntity(tableId, batchSize, remoteInsertStrategy) {
    batchSize = batchSize === VOID ? 1000 : batchSize;
    remoteInsertStrategy = remoteInsertStrategy === VOID ? RemoteInsertStrategy_CALLBACK_getInstance() : remoteInsertStrategy;
    this.tableId_1 = tableId;
    this.batchSize_1 = batchSize;
    this.remoteInsertStrategy_1 = remoteInsertStrategy;
  }
  protoOf(ReplicateEntity).get_tableId_of07s0_k$ = function () {
    return this.tableId_1;
  };
  protoOf(ReplicateEntity).get_batchSize_7o99am_k$ = function () {
    return this.batchSize_1;
  };
  protoOf(ReplicateEntity).get_remoteInsertStrategy_t4k5ff_k$ = function () {
    return this.remoteInsertStrategy_1;
  };
  protoOf(ReplicateEntity).equals = function (other) {
    if (!(other instanceof ReplicateEntity))
      return false;
    var tmp0_other_with_cast = other instanceof ReplicateEntity ? other : THROW_CCE();
    if (!(this.tableId_1 === tmp0_other_with_cast.tableId_1))
      return false;
    if (!(this.batchSize_1 === tmp0_other_with_cast.batchSize_1))
      return false;
    if (!this.remoteInsertStrategy_1.equals(tmp0_other_with_cast.remoteInsertStrategy_1))
      return false;
    return true;
  };
  protoOf(ReplicateEntity).hashCode = function () {
    var result = imul(getStringHashCode('tableId'), 127) ^ this.tableId_1;
    result = result + (imul(getStringHashCode('batchSize'), 127) ^ this.batchSize_1) | 0;
    result = result + (imul(getStringHashCode('remoteInsertStrategy'), 127) ^ this.remoteInsertStrategy_1.hashCode()) | 0;
    return result;
  };
  protoOf(ReplicateEntity).toString = function () {
    return '@com.ustadmobile.door.annotation.ReplicateEntity(tableId=' + this.tableId_1 + ', batchSize=' + this.batchSize_1 + ', remoteInsertStrategy=' + this.remoteInsertStrategy_1 + ')';
  };
  function ReplicateEtag() {
  }
  protoOf(ReplicateEtag).equals = function (other) {
    if (!(other instanceof ReplicateEtag))
      return false;
    other instanceof ReplicateEtag || THROW_CCE();
    return true;
  };
  protoOf(ReplicateEtag).hashCode = function () {
    return 0;
  };
  protoOf(ReplicateEtag).toString = function () {
    return '@com.ustadmobile.door.annotation.ReplicateEtag()';
  };
  function ReplicateLastModified(autoSet) {
    autoSet = autoSet === VOID ? true : autoSet;
    this.autoSet_1 = autoSet;
  }
  protoOf(ReplicateLastModified).get_autoSet_9f9392_k$ = function () {
    return this.autoSet_1;
  };
  protoOf(ReplicateLastModified).equals = function (other) {
    if (!(other instanceof ReplicateLastModified))
      return false;
    var tmp0_other_with_cast = other instanceof ReplicateLastModified ? other : THROW_CCE();
    if (!(this.autoSet_1 === tmp0_other_with_cast.autoSet_1))
      return false;
    return true;
  };
  protoOf(ReplicateLastModified).hashCode = function () {
    return imul(getStringHashCode('autoSet'), 127) ^ getBooleanHashCode(this.autoSet_1);
  };
  protoOf(ReplicateLastModified).toString = function () {
    return '@com.ustadmobile.door.annotation.ReplicateLastModified(autoSet=' + this.autoSet_1 + ')';
  };
  var Event_INSERT_instance;
  var Event_UPDATE_instance;
  var Event_DELETE_instance;
  function values_0() {
    return [Event_INSERT_getInstance(), Event_UPDATE_getInstance(), Event_DELETE_getInstance()];
  }
  function valueOf_0(value) {
    switch (value) {
      case 'INSERT':
        return Event_INSERT_getInstance();
      case 'UPDATE':
        return Event_UPDATE_getInstance();
      case 'DELETE':
        return Event_DELETE_getInstance();
      default:
        Event_initEntries();
        THROW_IAE('No enum constant value.');
        break;
    }
  }
  function get_entries_0() {
    if ($ENTRIES_0 == null)
      $ENTRIES_0 = enumEntries(values_0());
    return $ENTRIES_0;
  }
  var Event_entriesInitialized;
  function Event_initEntries() {
    if (Event_entriesInitialized)
      return Unit_getInstance();
    Event_entriesInitialized = true;
    Event_INSERT_instance = new Event('INSERT', 0, 'INSERT');
    Event_UPDATE_instance = new Event('UPDATE', 1, 'UPDATE');
    Event_DELETE_instance = new Event('DELETE', 2, 'DELETE');
  }
  var $ENTRIES_0;
  var Order_AFTER_instance;
  var Order_BEFORE_instance;
  var Order_INSTEAD_OF_instance;
  function values_1() {
    return [Order_AFTER_getInstance(), Order_BEFORE_getInstance(), Order_INSTEAD_OF_getInstance()];
  }
  function valueOf_1(value) {
    switch (value) {
      case 'AFTER':
        return Order_AFTER_getInstance();
      case 'BEFORE':
        return Order_BEFORE_getInstance();
      case 'INSTEAD_OF':
        return Order_INSTEAD_OF_getInstance();
      default:
        Order_initEntries();
        THROW_IAE('No enum constant value.');
        break;
    }
  }
  function get_entries_1() {
    if ($ENTRIES_1 == null)
      $ENTRIES_1 = enumEntries(values_1());
    return $ENTRIES_1;
  }
  var Order_entriesInitialized;
  function Order_initEntries() {
    if (Order_entriesInitialized)
      return Unit_getInstance();
    Order_entriesInitialized = true;
    Order_AFTER_instance = new Order('AFTER', 0, 'AFTER');
    Order_BEFORE_instance = new Order('BEFORE', 1, 'BEFORE');
    Order_INSTEAD_OF_instance = new Order('INSTEAD_OF', 2, 'INSTEAD OF');
  }
  var $ENTRIES_1;
  var On_ENTITY_instance;
  var On_RECEIVEVIEW_instance;
  function values_2() {
    return [On_ENTITY_getInstance(), On_RECEIVEVIEW_getInstance()];
  }
  function valueOf_2(value) {
    switch (value) {
      case 'ENTITY':
        return On_ENTITY_getInstance();
      case 'RECEIVEVIEW':
        return On_RECEIVEVIEW_getInstance();
      default:
        On_initEntries();
        THROW_IAE('No enum constant value.');
        break;
    }
  }
  function get_entries_2() {
    if ($ENTRIES_2 == null)
      $ENTRIES_2 = enumEntries(values_2());
    return $ENTRIES_2;
  }
  var On_entriesInitialized;
  function On_initEntries() {
    if (On_entriesInitialized)
      return Unit_getInstance();
    On_entriesInitialized = true;
    On_ENTITY_instance = new On('ENTITY', 0);
    On_RECEIVEVIEW_instance = new On('RECEIVEVIEW', 1);
  }
  var $ENTRIES_2;
  function Event(name, ordinal, sqlKeyWord) {
    Enum.call(this, name, ordinal);
    this.sqlKeyWord_1 = sqlKeyWord;
  }
  protoOf(Event).get_sqlKeyWord_5ioqos_k$ = function () {
    return this.sqlKeyWord_1;
  };
  function Order(name, ordinal, sqlStr) {
    Enum.call(this, name, ordinal);
    this.sqlStr_1 = sqlStr;
  }
  protoOf(Order).get_sqlStr_jly4y4_k$ = function () {
    return this.sqlStr_1;
  };
  function On(name, ordinal) {
    Enum.call(this, name, ordinal);
  }
  function Companion_6() {
    Companion_instance_6 = this;
    this.NAME_PREFIX_1 = '_d';
  }
  protoOf(Companion_6).get_NAME_PREFIX_pvog9p_k$ = function () {
    return this.NAME_PREFIX_1;
  };
  var Companion_instance_6;
  function Companion_getInstance_9() {
    if (Companion_instance_6 == null)
      new Companion_6();
    return Companion_instance_6;
  }
  function Event_INSERT_getInstance() {
    Event_initEntries();
    return Event_INSERT_instance;
  }
  function Event_UPDATE_getInstance() {
    Event_initEntries();
    return Event_UPDATE_instance;
  }
  function Event_DELETE_getInstance() {
    Event_initEntries();
    return Event_DELETE_instance;
  }
  function Order_AFTER_getInstance() {
    Order_initEntries();
    return Order_AFTER_instance;
  }
  function Order_BEFORE_getInstance() {
    Order_initEntries();
    return Order_BEFORE_instance;
  }
  function Order_INSTEAD_OF_getInstance() {
    Order_initEntries();
    return Order_INSTEAD_OF_instance;
  }
  function On_ENTITY_getInstance() {
    On_initEntries();
    return On_ENTITY_instance;
  }
  function On_RECEIVEVIEW_getInstance() {
    On_initEntries();
    return On_RECEIVEVIEW_instance;
  }
  function Trigger(name, order, events, on, sqlStatements, postgreSqlStatements, conditionSql, conditionSqlPostgres) {
    Companion_getInstance_9();
    on = on === VOID ? On_ENTITY_getInstance() : on;
    postgreSqlStatements = postgreSqlStatements === VOID ? [] : postgreSqlStatements;
    conditionSql = conditionSql === VOID ? '' : conditionSql;
    conditionSqlPostgres = conditionSqlPostgres === VOID ? '' : conditionSqlPostgres;
    this.name_1 = name;
    this.order_1 = order;
    this.events_1 = events;
    this.on_1 = on;
    this.sqlStatements_1 = sqlStatements;
    this.postgreSqlStatements_1 = postgreSqlStatements;
    this.conditionSql_1 = conditionSql;
    this.conditionSqlPostgres_1 = conditionSqlPostgres;
  }
  protoOf(Trigger).get_name_woqyms_k$ = function () {
    return this.name_1;
  };
  protoOf(Trigger).get_order_iwhiqt_k$ = function () {
    return this.order_1;
  };
  protoOf(Trigger).get_events_d1yhia_k$ = function () {
    return this.events_1;
  };
  protoOf(Trigger).get_on_kntnrs_k$ = function () {
    return this.on_1;
  };
  protoOf(Trigger).get_sqlStatements_hnj4d3_k$ = function () {
    return this.sqlStatements_1;
  };
  protoOf(Trigger).get_postgreSqlStatements_zif4ov_k$ = function () {
    return this.postgreSqlStatements_1;
  };
  protoOf(Trigger).get_conditionSql_fcgp38_k$ = function () {
    return this.conditionSql_1;
  };
  protoOf(Trigger).get_conditionSqlPostgres_wz9qc5_k$ = function () {
    return this.conditionSqlPostgres_1;
  };
  protoOf(Trigger).equals = function (other) {
    if (!(other instanceof Trigger))
      return false;
    var tmp0_other_with_cast = other instanceof Trigger ? other : THROW_CCE();
    if (!(this.name_1 === tmp0_other_with_cast.name_1))
      return false;
    if (!this.order_1.equals(tmp0_other_with_cast.order_1))
      return false;
    if (!contentEquals(this.events_1, tmp0_other_with_cast.events_1))
      return false;
    if (!this.on_1.equals(tmp0_other_with_cast.on_1))
      return false;
    if (!contentEquals(this.sqlStatements_1, tmp0_other_with_cast.sqlStatements_1))
      return false;
    if (!contentEquals(this.postgreSqlStatements_1, tmp0_other_with_cast.postgreSqlStatements_1))
      return false;
    if (!(this.conditionSql_1 === tmp0_other_with_cast.conditionSql_1))
      return false;
    if (!(this.conditionSqlPostgres_1 === tmp0_other_with_cast.conditionSqlPostgres_1))
      return false;
    return true;
  };
  protoOf(Trigger).hashCode = function () {
    var result = imul(getStringHashCode('name'), 127) ^ getStringHashCode(this.name_1);
    result = result + (imul(getStringHashCode('order'), 127) ^ this.order_1.hashCode()) | 0;
    result = result + (imul(getStringHashCode('events'), 127) ^ hashCode(this.events_1)) | 0;
    result = result + (imul(getStringHashCode('on'), 127) ^ this.on_1.hashCode()) | 0;
    result = result + (imul(getStringHashCode('sqlStatements'), 127) ^ hashCode(this.sqlStatements_1)) | 0;
    result = result + (imul(getStringHashCode('postgreSqlStatements'), 127) ^ hashCode(this.postgreSqlStatements_1)) | 0;
    result = result + (imul(getStringHashCode('conditionSql'), 127) ^ getStringHashCode(this.conditionSql_1)) | 0;
    result = result + (imul(getStringHashCode('conditionSqlPostgres'), 127) ^ getStringHashCode(this.conditionSqlPostgres_1)) | 0;
    return result;
  };
  protoOf(Trigger).toString = function () {
    return '@com.ustadmobile.door.annotation.Trigger(name=' + this.name_1 + ', order=' + this.order_1 + ', events=' + toString(this.events_1) + ', on=' + this.on_1 + ', sqlStatements=' + toString(this.sqlStatements_1) + ', postgreSqlStatements=' + toString(this.postgreSqlStatements_1) + ', conditionSql=' + this.conditionSql_1 + ', conditionSqlPostgres=' + this.conditionSqlPostgres_1 + ')';
  };
  function Triggers(value) {
    value = value === VOID ? [] : value;
    this.value_1 = value;
  }
  protoOf(Triggers).get_value_j01efc_k$ = function () {
    return this.value_1;
  };
  protoOf(Triggers).equals = function (other) {
    if (!(other instanceof Triggers))
      return false;
    var tmp0_other_with_cast = other instanceof Triggers ? other : THROW_CCE();
    if (!contentEquals(this.value_1, tmp0_other_with_cast.value_1))
      return false;
    return true;
  };
  protoOf(Triggers).hashCode = function () {
    return imul(getStringHashCode('value'), 127) ^ hashCode(this.value_1);
  };
  protoOf(Triggers).toString = function () {
    return '@com.ustadmobile.door.annotation.Triggers(value=' + toString(this.value_1) + ')';
  };
  function Companion_7() {
    Companion_instance_7 = this;
    this.SUBSCRIBED_TO_1 = 1;
    this.SERVER_FOR_1 = 2;
  }
  protoOf(Companion_7).get_SUBSCRIBED_TO_5aqmon_k$ = function () {
    return this.SUBSCRIBED_TO_1;
  };
  protoOf(Companion_7).get_SERVER_FOR_spbpdi_k$ = function () {
    return this.SERVER_FOR_1;
  };
  var Companion_instance_7;
  function Companion_getInstance_10() {
    if (Companion_instance_7 == null)
      new Companion_7();
    return Companion_instance_7;
  }
  function DoorNode() {
    Companion_getInstance_10();
    this.nodeId_1 = new Long(0, 0);
    this.auth_1 = null;
    this.rel_1 = 1;
  }
  protoOf(DoorNode).set_nodeId_xy4u70_k$ = function (_set____db54di) {
    this.nodeId_1 = _set____db54di;
  };
  protoOf(DoorNode).get_nodeId_h7ho7a_k$ = function () {
    return this.nodeId_1;
  };
  protoOf(DoorNode).set_auth_b8k972_k$ = function (_set____db54di) {
    this.auth_1 = _set____db54di;
  };
  protoOf(DoorNode).get_auth_woj2sx_k$ = function () {
    return this.auth_1;
  };
  protoOf(DoorNode).set_rel_w9cafg_k$ = function (_set____db54di) {
    this.rel_1 = _set____db54di;
  };
  protoOf(DoorNode).get_rel_18ix1s_k$ = function () {
    return this.rel_1;
  };
  function NodeIdAndAuth(nodeId, auth) {
    this.nodeId_1 = nodeId;
    this.auth_1 = auth;
  }
  protoOf(NodeIdAndAuth).get_nodeId_h7ho7a_k$ = function () {
    return this.nodeId_1;
  };
  protoOf(NodeIdAndAuth).get_auth_woj2sx_k$ = function () {
    return this.auth_1;
  };
  protoOf(NodeIdAndAuth).component1_7eebsc_k$ = function () {
    return this.nodeId_1;
  };
  protoOf(NodeIdAndAuth).component2_7eebsb_k$ = function () {
    return this.auth_1;
  };
  protoOf(NodeIdAndAuth).copy_pjtdc1_k$ = function (nodeId, auth) {
    return new NodeIdAndAuth(nodeId, auth);
  };
  protoOf(NodeIdAndAuth).copy$default_8t40sg_k$ = function (nodeId, auth, $super) {
    nodeId = nodeId === VOID ? this.nodeId_1 : nodeId;
    auth = auth === VOID ? this.auth_1 : auth;
    return $super === VOID ? this.copy_pjtdc1_k$(nodeId, auth) : $super.copy_pjtdc1_k$.call(this, nodeId, auth);
  };
  protoOf(NodeIdAndAuth).toString = function () {
    return 'NodeIdAndAuth(nodeId=' + this.nodeId_1.toString() + ', auth=' + this.auth_1 + ')';
  };
  protoOf(NodeIdAndAuth).hashCode = function () {
    var result = this.nodeId_1.hashCode();
    result = imul(result, 31) + getStringHashCode(this.auth_1) | 0;
    return result;
  };
  protoOf(NodeIdAndAuth).equals = function (other) {
    if (this === other)
      return true;
    if (!(other instanceof NodeIdAndAuth))
      return false;
    var tmp0_other_with_cast = other instanceof NodeIdAndAuth ? other : THROW_CCE();
    if (!this.nodeId_1.equals(tmp0_other_with_cast.nodeId_1))
      return false;
    if (!(this.auth_1 === tmp0_other_with_cast.auth_1))
      return false;
    return true;
  };
  function OutgoingReplication(orUid, destNodeId, orTableId, orPk1, orPk2, orPk3, orPk4) {
    orUid = orUid === VOID ? new Long(0, 0) : orUid;
    destNodeId = destNodeId === VOID ? new Long(0, 0) : destNodeId;
    orTableId = orTableId === VOID ? 0 : orTableId;
    orPk1 = orPk1 === VOID ? new Long(0, 0) : orPk1;
    orPk2 = orPk2 === VOID ? new Long(0, 0) : orPk2;
    orPk3 = orPk3 === VOID ? new Long(0, 0) : orPk3;
    orPk4 = orPk4 === VOID ? new Long(0, 0) : orPk4;
    this.orUid_1 = orUid;
    this.destNodeId_1 = destNodeId;
    this.orTableId_1 = orTableId;
    this.orPk1__1 = orPk1;
    this.orPk2__1 = orPk2;
    this.orPk3__1 = orPk3;
    this.orPk4__1 = orPk4;
  }
  protoOf(OutgoingReplication).set_orUid_avnb5e_k$ = function (_set____db54di) {
    this.orUid_1 = _set____db54di;
  };
  protoOf(OutgoingReplication).get_orUid_iwh7pg_k$ = function () {
    return this.orUid_1;
  };
  protoOf(OutgoingReplication).set_destNodeId_n0qmci_k$ = function (_set____db54di) {
    this.destNodeId_1 = _set____db54di;
  };
  protoOf(OutgoingReplication).get_destNodeId_d2y4xk_k$ = function () {
    return this.destNodeId_1;
  };
  protoOf(OutgoingReplication).set_orTableId_ytziu9_k$ = function (_set____db54di) {
    this.orTableId_1 = _set____db54di;
  };
  protoOf(OutgoingReplication).get_orTableId_lu6glf_k$ = function () {
    return this.orTableId_1;
  };
  protoOf(OutgoingReplication).set_orPk1_lv6n5k_k$ = function (_set____db54di) {
    this.orPk1__1 = _set____db54di;
  };
  protoOf(OutgoingReplication).get_orPk1_iwh40a_k$ = function () {
    return this.orPk1__1;
  };
  protoOf(OutgoingReplication).set_orPk2_ej2ie1_k$ = function (_set____db54di) {
    this.orPk2__1 = _set____db54di;
  };
  protoOf(OutgoingReplication).get_orPk2_iwh40b_k$ = function () {
    return this.orPk2__1;
  };
  protoOf(OutgoingReplication).set_orPk3_76ydmi_k$ = function (_set____db54di) {
    this.orPk3__1 = _set____db54di;
  };
  protoOf(OutgoingReplication).get_orPk3_iwh40c_k$ = function () {
    return this.orPk3__1;
  };
  protoOf(OutgoingReplication).set_orPk4_55r51_k$ = function (_set____db54di) {
    this.orPk4__1 = _set____db54di;
  };
  protoOf(OutgoingReplication).get_orPk4_iwh40d_k$ = function () {
    return this.orPk4__1;
  };
  function get_rootDatabase(_this__u8e3s4) {
    var db = _this__u8e3s4;
    $l$loop: while (true) {
      var tmp0_elvis_lhs = get_sourceDatabase(db);
      var tmp;
      if (tmp0_elvis_lhs == null) {
        break $l$loop;
      } else {
        tmp = tmp0_elvis_lhs;
      }
      db = tmp;
    }
    return db;
  }
  function prepareAndUseStatementAsync_0(_this__u8e3s4, sql, readOnly, block, $completion) {
    readOnly = readOnly === VOID ? false : readOnly;
    return prepareAndUseStatementAsync(_this__u8e3s4, new PreparedStatementConfig(sql, VOID, VOID, VOID, VOID, readOnly), block, $completion);
  }
  function Companion_8() {
    Companion_instance_8 = this;
    this.SUFFIX_DOOR_METADATA_1 = '_DoorMetadata';
  }
  protoOf(Companion_8).get_SUFFIX_DOOR_METADATA_wonret_k$ = function () {
    return this.SUFFIX_DOOR_METADATA_1;
  };
  var Companion_instance_8;
  function Companion_getInstance_11() {
    if (Companion_instance_8 == null)
      new Companion_8();
    return Companion_instance_8;
  }
  function DoorDatabaseMetadata() {
    Companion_getInstance_11();
  }
  protoOf(DoorDatabaseMetadata).get_replicateTableNames_6uibay_k$ = function () {
    // Inline function 'kotlin.collections.map' call
    var this_0 = this.get_replicateEntities_2w1n4x_k$().get_values_ksazhn_k$();
    // Inline function 'kotlin.collections.mapTo' call
    var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10));
    var tmp0_iterator = this_0.iterator_jk1svi_k$();
    while (tmp0_iterator.hasNext_bitz1p_k$()) {
      var item = tmp0_iterator.next_20eer_k$();
      // Inline function 'com.ustadmobile.door.ext.DoorDatabaseMetadata.<get-replicateTableNames>.<anonymous>' call
      var tmp$ret$0 = item.get_entityTableName_g8x9t9_k$();
      destination.add_utx5q5_k$(tmp$ret$0);
    }
    return destination;
  };
  protoOf(DoorDatabaseMetadata).requireReplicateEntityMetaData_9swzku_k$ = function (tableId) {
    var tmp0_elvis_lhs = this.get_replicateEntities_2w1n4x_k$().get_wei43m_k$(tableId);
    var tmp;
    if (tmp0_elvis_lhs == null) {
      throw IllegalArgumentException_init_$Create$('No metadata for table id ' + tableId);
    } else {
      tmp = tmp0_elvis_lhs;
    }
    return tmp;
  };
  protoOf(DoorDatabaseMetadata).getTableId_77qvrb_k$ = function (tableName) {
    var tmp$ret$1;
    $l$block: {
      // Inline function 'kotlin.collections.first' call
      var tmp0_iterator = this.get_replicateEntities_2w1n4x_k$().get_values_ksazhn_k$().iterator_jk1svi_k$();
      while (tmp0_iterator.hasNext_bitz1p_k$()) {
        var element = tmp0_iterator.next_20eer_k$();
        // Inline function 'com.ustadmobile.door.ext.DoorDatabaseMetadata.getTableId.<anonymous>' call
        if (element.get_entityTableName_g8x9t9_k$() === tableName) {
          tmp$ret$1 = element;
          break $l$block;
        }
      }
      throw NoSuchElementException_init_$Create$('Collection contains no element matching the predicate.');
    }
    return tmp$ret$1.get_tableId_of07s0_k$();
  };
  function Companion_9() {
    Companion_instance_9 = this;
    this.TAG_DB_1 = 1;
    this.TAG_REPO_1 = 2;
    this.TAG_ATTACHMENT_DIR_1 = 4;
    this.LOG_TAG_1 = 'DoorLog';
  }
  protoOf(Companion_9).get_TAG_DB_46ibfw_k$ = function () {
    return this.TAG_DB_1;
  };
  protoOf(Companion_9).get_TAG_REPO_v06nfk_k$ = function () {
    return this.TAG_REPO_1;
  };
  protoOf(Companion_9).get_TAG_ATTACHMENT_DIR_8rm7cx_k$ = function () {
    return this.TAG_ATTACHMENT_DIR_1;
  };
  protoOf(Companion_9).get_LOG_TAG_it8mba_k$ = function () {
    return this.LOG_TAG_1;
  };
  var Companion_instance_9;
  function Companion_getInstance_12() {
    if (Companion_instance_9 == null)
      new Companion_9();
    return Companion_instance_9;
  }
  function DoorTag() {
    Companion_getInstance_12();
  }
  function setBodyJson(_this__u8e3s4, json, serializer, value, contentType) {
    contentType = contentType === VOID ? Application_getInstance().get_Json_wo4ci9_k$() : contentType;
    // Inline function 'io.ktor.client.request.setBody' call
    var body = new TextContent(json.encodeToString_k0apqx_k$(serializer, value), contentType);
    if (body == null) {
      _this__u8e3s4.set_body_slfhxt_k$(NullBody_getInstance());
      // Inline function 'io.ktor.util.reflect.typeInfo' call
      var tmp = JsType_getInstance();
      var tmp_0 = getKClass(TextContent);
      // Inline function 'io.ktor.util.reflect.tryGetType' call
      var tmp_1;
      try {
        tmp_1 = createKType(getKClass(TextContent), arrayOf([]), false);
      } catch ($p) {
        var tmp_2;
        if ($p instanceof Error) {
          var cause = $p;
          tmp_2 = null;
        } else {
          throw $p;
        }
        tmp_1 = tmp_2;
      }
      var tmp$ret$0 = tmp_1;
      var tmp$ret$1 = typeInfoImpl(tmp, tmp_0, tmp$ret$0);
      _this__u8e3s4.set_bodyType_8pgqkl_k$(tmp$ret$1);
    } else {
      if (body instanceof OutgoingContent) {
        _this__u8e3s4.set_body_slfhxt_k$(body);
        _this__u8e3s4.set_bodyType_8pgqkl_k$(null);
      } else {
        _this__u8e3s4.set_body_slfhxt_k$(body);
        // Inline function 'io.ktor.util.reflect.typeInfo' call
        var tmp_3 = JsType_getInstance();
        var tmp_4 = getKClass(TextContent);
        // Inline function 'io.ktor.util.reflect.tryGetType' call
        var tmp_5;
        try {
          tmp_5 = createKType(getKClass(TextContent), arrayOf([]), false);
        } catch ($p) {
          var tmp_6;
          if ($p instanceof Error) {
            var cause_0 = $p;
            tmp_6 = null;
          } else {
            throw $p;
          }
          tmp_5 = tmp_6;
        }
        var tmp$ret$2 = tmp_5;
        var tmp$ret$3 = typeInfoImpl(tmp_3, tmp_4, tmp$ret$2);
        _this__u8e3s4.set_bodyType_8pgqkl_k$(tmp$ret$3);
      }
    }
  }
  function doorNodeIdHeader(_this__u8e3s4, repo) {
    header(_this__u8e3s4, DoorConstants_getInstance().get_HEADER_NODE_AND_AUTH_2mchyc_k$(), repo.get_config_c0698r_k$().get_nodeId_h7ho7a_k$().toString() + '/' + repo.get_config_c0698r_k$().get_auth_woj2sx_k$());
  }
  function doorNodeIdHeader_0(_this__u8e3s4, nodeId, auth) {
    header(_this__u8e3s4, DoorConstants_getInstance().get_HEADER_NODE_AND_AUTH_2mchyc_k$(), nodeId.toString() + '/' + auth);
  }
  function setRepoUrl(_this__u8e3s4, repoEndpoint, repoPath) {
    _this__u8e3s4.url_gkqa8r_k$(setRepoUrl$lambda(repoEndpoint, repoPath));
  }
  function setRepoUrl$lambda($repoEndpoint, $repoPath) {
    return function ($this$url, it) {
      takeFrom($this$url, $repoEndpoint);
      set_encodedPath($this$url, get_encodedPath($this$url) + $repoPath);
      return Unit_getInstance();
    };
  }
  function runningSplitBy(_this__u8e3s4, key) {
    var result = mutableLinkedListOf([]);
    var lastItemKey = null;
    var lastList = null;
    var tmp0_iterator = _this__u8e3s4.iterator_jk1svi_k$();
    while (tmp0_iterator.hasNext_bitz1p_k$()) {
      var item = tmp0_iterator.next_20eer_k$();
      var itemKey = key(item);
      if ((!(lastItemKey == null) ? !(lastList == null) : false) ? equals(itemKey, lastItemKey) : false) {
        lastList.add_utx5q5_k$(item);
      } else {
        var newList = mutableLinkedListOf([item]);
        result.add_utx5q5_k$(newList);
        lastList = newList;
      }
      lastItemKey = itemKey;
    }
    return toList_0(result);
  }
  function toUrlQueryString(_this__u8e3s4) {
    // Inline function 'kotlin.collections.map' call
    var this_0 = _this__u8e3s4.get_entries_p20ztl_k$();
    // Inline function 'kotlin.collections.mapTo' call
    var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10));
    var tmp0_iterator = this_0.iterator_jk1svi_k$();
    while (tmp0_iterator.hasNext_bitz1p_k$()) {
      var item = tmp0_iterator.next_20eer_k$();
      // Inline function 'com.ustadmobile.door.ext.toUrlQueryString.<anonymous>' call
      var tmp$ret$0 = urlEncode(item.get_key_18j28a_k$()) + '=' + urlEncode(item.get_value_j01efc_k$());
      destination.add_utx5q5_k$(tmp$ret$0);
    }
    return joinToString(destination, '&');
  }
  function setAllFromJsonObject(_this__u8e3s4, jsonObject, entityFieldsMetaData, startIndex) {
    startIndex = startIndex === VOID ? 1 : startIndex;
    // Inline function 'kotlin.collections.forEachIndexed' call
    var index = 0;
    var tmp0_iterator = entityFieldsMetaData.iterator_jk1svi_k$();
    while (tmp0_iterator.hasNext_bitz1p_k$()) {
      var item = tmp0_iterator.next_20eer_k$();
      // Inline function 'com.ustadmobile.door.ext.setAllFromJsonObject.<anonymous>' call
      var tmp1 = index;
      index = tmp1 + 1 | 0;
      var index_0 = checkIndexOverflow(tmp1);
      var fieldType = item.get_dbFieldType_pz3j77_k$();
      var tmp = index_0 + startIndex | 0;
      var tmp_0 = item.get_dbFieldType_pz3j77_k$();
      // Inline function 'kotlin.collections.getOrElse' call
      var key = item.get_fieldName_tfocn0_k$();
      var tmp0_elvis_lhs = jsonObject.get_wei43m_k$(key);
      var tmp_1;
      if (tmp0_elvis_lhs == null) {
        // Inline function 'com.ustadmobile.door.ext.setAllFromJsonObject.<anonymous>.<anonymous>' call
        tmp_1 = defaultJsonPrimitive(fieldType, item.get_nullable_7petka_k$());
      } else {
        tmp_1 = tmp0_elvis_lhs;
      }
      var tmp$ret$1 = tmp_1;
      setJsonPrimitive(_this__u8e3s4, tmp, tmp_0, get_jsonPrimitive(tmp$ret$1));
    }
  }
  function setJsonPrimitive(_this__u8e3s4, index, type, jsonPrimitive) {
    if (jsonPrimitive instanceof JsonNull) {
      _this__u8e3s4.setObject_9i2mag_k$(index, null);
      return Unit_getInstance();
    }
    if (type === TypesKmp_getInstance().get_INTEGER_pibe8b_k$()) {
      _this__u8e3s4.setInt_c72a8z_k$(index, get_int(jsonPrimitive));
    } else if (type === TypesKmp_getInstance().get_SMALLINT_sw3een_k$()) {
      _this__u8e3s4.setShort_mhpatm_k$(index, toShort(get_int(jsonPrimitive)));
    } else if (type === TypesKmp_getInstance().get_BIGINT_47wyyw_k$()) {
      _this__u8e3s4.setLong_j1sybo_k$(index, get_long(jsonPrimitive));
    } else if (type === TypesKmp_getInstance().get_FLOAT_i998gj_k$()) {
      _this__u8e3s4.setFloat_dia6lm_k$(index, get_float(jsonPrimitive));
    } else if (type === TypesKmp_getInstance().get_REAL_wo8h5z_k$()) {
      _this__u8e3s4.setFloat_dia6lm_k$(index, get_float(jsonPrimitive));
    } else if (type === TypesKmp_getInstance().get_DOUBLE_36a61y_k$()) {
      _this__u8e3s4.setDouble_gsfx69_k$(index, get_double(jsonPrimitive));
    } else if (type === TypesKmp_getInstance().get_BOOLEAN_e7jswv_k$()) {
      _this__u8e3s4.setBoolean_pzdm1v_k$(index, get_boolean(jsonPrimitive));
    } else if (type === TypesKmp_getInstance().get_VARCHAR_h1w92s_k$()) {
      _this__u8e3s4.setString_2gt7ua_k$(index, jsonPrimitive.get_content_h02jrk_k$());
    } else if (type === TypesKmp_getInstance().get_LONGVARCHAR_lmf0o_k$()) {
      _this__u8e3s4.setString_2gt7ua_k$(index, jsonPrimitive.get_content_h02jrk_k$());
    }
  }
  function defaultJsonPrimitive(type, nullable) {
    return nullable ? JsonNull_getInstance() : (type === TypesKmp_getInstance().get_VARCHAR_h1w92s_k$() ? true : type === TypesKmp_getInstance().get_LONGVARCHAR_lmf0o_k$()) ? JsonNull_getInstance() : type === TypesKmp_getInstance().get_BOOLEAN_e7jswv_k$() ? JsonPrimitive_0(false) : JsonPrimitive(0);
  }
  function rowToJsonObject(_this__u8e3s4, columns) {
    // Inline function 'kotlin.collections.associate' call
    var capacity = coerceAtLeast(mapCapacity(collectionSizeOrDefault(columns, 10)), 16);
    // Inline function 'kotlin.collections.associateTo' call
    var destination = LinkedHashMap_init_$Create$_0(capacity);
    var tmp0_iterator = columns.iterator_jk1svi_k$();
    while (tmp0_iterator.hasNext_bitz1p_k$()) {
      var element = tmp0_iterator.next_20eer_k$();
      // Inline function 'kotlin.collections.plusAssign' call
      // Inline function 'com.ustadmobile.door.ext.rowToJsonObject.<anonymous>' call
      var pair = to(element.get_fieldName_tfocn0_k$(), getJsonPrimitive(_this__u8e3s4, element));
      destination.put_4fpzoq_k$(pair.get_first_irdx8n_k$(), pair.get_second_jf7fjx_k$());
    }
    return new JsonObject(destination);
  }
  function getJsonPrimitive(_this__u8e3s4, fieldInfo) {
    var colName = fieldInfo.get_fieldName_tfocn0_k$();
    var tmp;
    if (fieldInfo.get_nullable_7petka_k$()) {
      var tmp0_subject = fieldInfo.get_dbFieldType_pz3j77_k$();
      var tmp_0;
      if (tmp0_subject === TypesKmp_getInstance().get_SMALLINT_sw3een_k$()) {
        tmp_0 = JsonPrimitive(getShortNullable(_this__u8e3s4, colName));
      } else if (tmp0_subject === TypesKmp_getInstance().get_INTEGER_pibe8b_k$()) {
        tmp_0 = JsonPrimitive(getIntNullable(_this__u8e3s4, colName));
      } else if (tmp0_subject === TypesKmp_getInstance().get_BIGINT_47wyyw_k$()) {
        tmp_0 = JsonPrimitive(getLongNullable(_this__u8e3s4, colName));
      } else if (tmp0_subject === TypesKmp_getInstance().get_REAL_wo8h5z_k$()) {
        tmp_0 = JsonPrimitive(getFloatNullable(_this__u8e3s4, colName));
      } else if (tmp0_subject === TypesKmp_getInstance().get_FLOAT_i998gj_k$()) {
        tmp_0 = JsonPrimitive(getFloatNullable(_this__u8e3s4, colName));
      } else if (tmp0_subject === TypesKmp_getInstance().get_DOUBLE_36a61y_k$()) {
        tmp_0 = JsonPrimitive(getDoubleNullable(_this__u8e3s4, colName));
      } else if (tmp0_subject === TypesKmp_getInstance().get_VARCHAR_h1w92s_k$()) {
        tmp_0 = JsonPrimitive_1(_this__u8e3s4.getString_gb1pt9_k$(colName));
      } else if (tmp0_subject === TypesKmp_getInstance().get_LONGVARCHAR_lmf0o_k$()) {
        tmp_0 = JsonPrimitive_1(_this__u8e3s4.getString_gb1pt9_k$(colName));
      } else if (tmp0_subject === TypesKmp_getInstance().get_BOOLEAN_e7jswv_k$()) {
        tmp_0 = JsonPrimitive_0(getBooleanNullable(_this__u8e3s4, colName));
      } else {
        throw IllegalArgumentException_init_$Create$('Unsupported type: ' + fieldInfo.get_dbFieldType_pz3j77_k$());
      }
      tmp = tmp_0;
    } else {
      var tmp1_subject = fieldInfo.get_dbFieldType_pz3j77_k$();
      var tmp_1;
      if (tmp1_subject === TypesKmp_getInstance().get_SMALLINT_sw3een_k$()) {
        tmp_1 = JsonPrimitive(_this__u8e3s4.getShort_4zegvo_k$(colName));
      } else if (tmp1_subject === TypesKmp_getInstance().get_INTEGER_pibe8b_k$()) {
        tmp_1 = JsonPrimitive(_this__u8e3s4.getInt_npc9pd_k$(colName));
      } else if (tmp1_subject === TypesKmp_getInstance().get_BIGINT_47wyyw_k$()) {
        tmp_1 = JsonPrimitive(_this__u8e3s4.getLong_3wgf2g_k$(colName));
      } else if (tmp1_subject === TypesKmp_getInstance().get_REAL_wo8h5z_k$()) {
        tmp_1 = JsonPrimitive(_this__u8e3s4.getFloat_1jlp7w_k$(colName));
      } else if (tmp1_subject === TypesKmp_getInstance().get_FLOAT_i998gj_k$()) {
        tmp_1 = JsonPrimitive(_this__u8e3s4.getFloat_1jlp7w_k$(colName));
      } else if (tmp1_subject === TypesKmp_getInstance().get_DOUBLE_36a61y_k$()) {
        tmp_1 = JsonPrimitive(_this__u8e3s4.getDouble_v37ict_k$(colName));
      } else if (tmp1_subject === TypesKmp_getInstance().get_VARCHAR_h1w92s_k$()) {
        tmp_1 = JsonPrimitive_1(_this__u8e3s4.getString_gb1pt9_k$(colName));
      } else if (tmp1_subject === TypesKmp_getInstance().get_LONGVARCHAR_lmf0o_k$()) {
        tmp_1 = JsonPrimitive_1(_this__u8e3s4.getString_gb1pt9_k$(colName));
      } else if (tmp1_subject === TypesKmp_getInstance().get_BOOLEAN_e7jswv_k$()) {
        tmp_1 = JsonPrimitive_0(_this__u8e3s4.getBoolean_xz3hoo_k$(colName));
      } else {
        throw IllegalArgumentException_init_$Create$('Unsupported type: ' + fieldInfo.get_dbFieldType_pz3j77_k$());
      }
      tmp = tmp_1;
    }
    return tmp;
  }
  function get_doorWrapperNodeId(_this__u8e3s4) {
    return get_doorWrapper(_this__u8e3s4).get_nodeId_h7ho7a_k$();
  }
  function get_doorWrapper(_this__u8e3s4) {
    var tmp;
    if (isInterface(_this__u8e3s4, DoorDatabaseWrapper)) {
      tmp = isInterface(_this__u8e3s4, DoorDatabaseWrapper) ? _this__u8e3s4 : THROW_CCE();
    } else {
      if (isInterface(_this__u8e3s4, DoorDatabaseRepository)) {
        var tmp_0 = _this__u8e3s4.get_db_knto1l_k$();
        tmp = isInterface(tmp_0, DoorDatabaseWrapper) ? tmp_0 : THROW_CCE();
      } else {
        throw IllegalArgumentException_init_$Create$('Cannot get doorWrapper for ' + _this__u8e3s4 + ' : it is not a wrapper or repository');
      }
    }
    return tmp;
  }
  function get_STR_REGEX() {
    _init_properties_StringExt_kt__eg42u6();
    // Inline function 'kotlin.getValue' call
    var this_0 = STR_REGEX$delegate;
    STR_REGEX$factory();
    return this_0.get_value_j01efc_k$();
  }
  var STR_REGEX$delegate;
  function get_sanitizeRegex() {
    _init_properties_StringExt_kt__eg42u6();
    // Inline function 'kotlin.getValue' call
    var this_0 = sanitizeRegex$delegate;
    sanitizeRegex$factory();
    return this_0.get_value_j01efc_k$();
  }
  var sanitizeRegex$delegate;
  function get_POSTGRES_SELECT_IN_PATTERN() {
    _init_properties_StringExt_kt__eg42u6();
    return POSTGRES_SELECT_IN_PATTERN;
  }
  var POSTGRES_SELECT_IN_PATTERN;
  function STR_REGEX$delegate$lambda() {
    _init_properties_StringExt_kt__eg42u6();
    return Regex_init_$Create$('\\s\\s+');
  }
  function sanitizeRegex$delegate$lambda() {
    _init_properties_StringExt_kt__eg42u6();
    return Regex_init_$Create$('\\W');
  }
  function STR_REGEX$factory() {
    return getPropertyCallableRef('STR_REGEX', 0, KProperty0, function () {
      return get_STR_REGEX();
    }, null);
  }
  function sanitizeRegex$factory() {
    return getPropertyCallableRef('sanitizeRegex', 0, KProperty0, function () {
      return get_sanitizeRegex();
    }, null);
  }
  var properties_initialized_StringExt_kt_sd962o;
  function _init_properties_StringExt_kt__eg42u6() {
    if (!properties_initialized_StringExt_kt_sd962o) {
      properties_initialized_StringExt_kt_sd962o = true;
      var tmp = LazyThreadSafetyMode_NONE_getInstance();
      STR_REGEX$delegate = lazy(tmp, STR_REGEX$delegate$lambda);
      var tmp_0 = LazyThreadSafetyMode_NONE_getInstance();
      sanitizeRegex$delegate = lazy(tmp_0, sanitizeRegex$delegate$lambda);
      POSTGRES_SELECT_IN_PATTERN = Regex_init_$Create$_0('IN(\\s*)\\((\\s*)\\?(\\s*)\\)', RegexOption_IGNORE_CASE_getInstance());
    }
  }
  function ConnectionAsync() {
  }
  function StatementConstantsKmp() {
    StatementConstantsKmp_instance = this;
    this.RETURN_GENERATED_KEYS_1 = 1;
    this.NO_GENERATED_KEYS_1 = 2;
  }
  protoOf(StatementConstantsKmp).get_RETURN_GENERATED_KEYS_s33sei_k$ = function () {
    return this.RETURN_GENERATED_KEYS_1;
  };
  protoOf(StatementConstantsKmp).set_NO_GENERATED_KEYS_8zcrr1_k$ = function (_set____db54di) {
    this.NO_GENERATED_KEYS_1 = _set____db54di;
  };
  protoOf(StatementConstantsKmp).get_NO_GENERATED_KEYS_h4ycm1_k$ = function () {
    return this.NO_GENERATED_KEYS_1;
  };
  var StatementConstantsKmp_instance;
  function StatementConstantsKmp_getInstance() {
    if (StatementConstantsKmp_instance == null)
      new StatementConstantsKmp();
    return StatementConstantsKmp_instance;
  }
  function TypesKmp() {
    TypesKmp_instance = this;
    this.INTEGER_1 = 4;
    this.BOOLEAN_1 = 16;
    this.VARCHAR_1 = 12;
    this.BIGINT_1 = -5;
    this.FLOAT_1 = 6;
    this.REAL_1 = 7;
    this.DOUBLE_1 = 8;
    this.SMALLINT_1 = 5;
    this.LONGVARCHAR_1 = -1;
    this.ARRAY_1 = 2003;
  }
  protoOf(TypesKmp).get_INTEGER_pibe8b_k$ = function () {
    return this.INTEGER_1;
  };
  protoOf(TypesKmp).get_BOOLEAN_e7jswv_k$ = function () {
    return this.BOOLEAN_1;
  };
  protoOf(TypesKmp).get_VARCHAR_h1w92s_k$ = function () {
    return this.VARCHAR_1;
  };
  protoOf(TypesKmp).get_BIGINT_47wyyw_k$ = function () {
    return this.BIGINT_1;
  };
  protoOf(TypesKmp).get_FLOAT_i998gj_k$ = function () {
    return this.FLOAT_1;
  };
  protoOf(TypesKmp).get_REAL_wo8h5z_k$ = function () {
    return this.REAL_1;
  };
  protoOf(TypesKmp).get_DOUBLE_36a61y_k$ = function () {
    return this.DOUBLE_1;
  };
  protoOf(TypesKmp).get_SMALLINT_sw3een_k$ = function () {
    return this.SMALLINT_1;
  };
  protoOf(TypesKmp).get_LONGVARCHAR_lmf0o_k$ = function () {
    return this.LONGVARCHAR_1;
  };
  protoOf(TypesKmp).get_ARRAY_i6m5n4_k$ = function () {
    return this.ARRAY_1;
  };
  var TypesKmp_instance;
  function TypesKmp_getInstance() {
    if (TypesKmp_instance == null)
      new TypesKmp();
    return TypesKmp_instance;
  }
  function useConnection(_this__u8e3s4, block) {
    try {
      return block(_this__u8e3s4);
    }finally {
      _this__u8e3s4.close_yn9xrc_k$();
    }
  }
  function useResults(_this__u8e3s4, block) {
    try {
      return block(_this__u8e3s4);
    }finally {
      _this__u8e3s4.close_yn9xrc_k$();
    }
  }
  function mapRows(_this__u8e3s4, block) {
    var mappedResults = mutableLinkedListOf_0([]);
    while (_this__u8e3s4.next_20eer_k$()) {
      // Inline function 'kotlin.collections.plusAssign' call
      var element = block(_this__u8e3s4);
      mappedResults.add_utx5q5_k$(element);
    }
    return mappedResults;
  }
  function mapNextRow(_this__u8e3s4, defaultVal, block) {
    return _this__u8e3s4.next_20eer_k$() ? block(_this__u8e3s4) : defaultVal;
  }
  function getShortNullable(_this__u8e3s4, columnName) {
    // Inline function 'com.ustadmobile.door.jdbc.ext.getOrNull' call
    // Inline function 'kotlin.let' call
    // Inline function 'com.ustadmobile.door.jdbc.ext.getShortNullable.<anonymous>' call
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'com.ustadmobile.door.jdbc.ext.getOrNull.<anonymous>' call
    var it = _this__u8e3s4.getShort_4zegvo_k$(columnName);
    return _this__u8e3s4.wasNull_ilge1c_k$() ? null : it;
  }
  function getIntNullable(_this__u8e3s4, columnName) {
    // Inline function 'com.ustadmobile.door.jdbc.ext.getOrNull' call
    // Inline function 'kotlin.let' call
    // Inline function 'com.ustadmobile.door.jdbc.ext.getIntNullable.<anonymous>' call
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'com.ustadmobile.door.jdbc.ext.getOrNull.<anonymous>' call
    var it = _this__u8e3s4.getInt_npc9pd_k$(columnName);
    return _this__u8e3s4.wasNull_ilge1c_k$() ? null : it;
  }
  function getLongNullable(_this__u8e3s4, columnName) {
    // Inline function 'com.ustadmobile.door.jdbc.ext.getOrNull' call
    // Inline function 'kotlin.let' call
    // Inline function 'com.ustadmobile.door.jdbc.ext.getLongNullable.<anonymous>' call
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'com.ustadmobile.door.jdbc.ext.getOrNull.<anonymous>' call
    var it = _this__u8e3s4.getLong_3wgf2g_k$(columnName);
    return _this__u8e3s4.wasNull_ilge1c_k$() ? null : it;
  }
  function getFloatNullable(_this__u8e3s4, columnName) {
    // Inline function 'com.ustadmobile.door.jdbc.ext.getOrNull' call
    // Inline function 'kotlin.let' call
    // Inline function 'com.ustadmobile.door.jdbc.ext.getFloatNullable.<anonymous>' call
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'com.ustadmobile.door.jdbc.ext.getOrNull.<anonymous>' call
    var it = _this__u8e3s4.getFloat_1jlp7w_k$(columnName);
    return _this__u8e3s4.wasNull_ilge1c_k$() ? null : it;
  }
  function getDoubleNullable(_this__u8e3s4, columnName) {
    // Inline function 'com.ustadmobile.door.jdbc.ext.getOrNull' call
    // Inline function 'kotlin.let' call
    // Inline function 'com.ustadmobile.door.jdbc.ext.getDoubleNullable.<anonymous>' call
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'com.ustadmobile.door.jdbc.ext.getOrNull.<anonymous>' call
    var it = _this__u8e3s4.getDouble_v37ict_k$(columnName);
    return _this__u8e3s4.wasNull_ilge1c_k$() ? null : it;
  }
  function getBooleanNullable(_this__u8e3s4, columnName) {
    // Inline function 'com.ustadmobile.door.jdbc.ext.getOrNull' call
    // Inline function 'kotlin.let' call
    // Inline function 'com.ustadmobile.door.jdbc.ext.getBooleanNullable.<anonymous>' call
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'com.ustadmobile.door.jdbc.ext.getOrNull.<anonymous>' call
    var it = _this__u8e3s4.getBoolean_xz3hoo_k$(columnName);
    return _this__u8e3s4.wasNull_ilge1c_k$() ? null : it;
  }
  function getOrNull(_this__u8e3s4, block) {
    // Inline function 'kotlin.let' call
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'com.ustadmobile.door.jdbc.ext.getOrNull.<anonymous>' call
    var it = block(_this__u8e3s4);
    return _this__u8e3s4.wasNull_ilge1c_k$() ? null : it;
  }
  function useStatementAsync(_this__u8e3s4, block, $completion) {
    var tmp = new $useStatementAsyncCOROUTINE$8(_this__u8e3s4, block, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  }
  function useStatement(_this__u8e3s4, block) {
    try {
      return block(_this__u8e3s4);
    } catch ($p) {
      if ($p instanceof Exception) {
        var e = $p;
        throw e;
      } else {
        throw $p;
      }
    }
    finally {
      _this__u8e3s4.close_yn9xrc_k$();
    }
  }
  function $useStatementAsyncCOROUTINE$8(_this__u8e3s4, block, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
    this.block_1 = block;
  }
  protoOf($useStatementAsyncCOROUTINE$8).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(7);
            this.set_state_rjd8d0_k$(1);
            continue $sm;
          case 1:
            this.set_state_rjd8d0_k$(2);
            continue $sm;
          case 2:
            this.set_exceptionState_fex74n_k$(6);
            this.set_exceptionState_fex74n_k$(5);
            this.set_state_rjd8d0_k$(3);
            suspendResult = this.block_1(this._this__u8e3s4__1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 3:
            this.tmp$ret$01__1 = suspendResult;
            this.set_exceptionState_fex74n_k$(7);
            this.set_state_rjd8d0_k$(4);
            var tmp_0 = this;
            continue $sm;
          case 4:
            var tmp_1 = this.tmp$ret$01__1;
            this.set_exceptionState_fex74n_k$(7);
            this._this__u8e3s4__1.close_yn9xrc_k$();
            return tmp_1;
          case 5:
            this.set_exceptionState_fex74n_k$(6);
            var tmp_2 = this.get_exception_x0n6w6_k$();
            if (tmp_2 instanceof Exception) {
              var e = this.get_exception_x0n6w6_k$();
              var tmp_3 = this;
              throw e;
            } else {
              throw this.get_exception_x0n6w6_k$();
            }

          case 6:
            this.set_exceptionState_fex74n_k$(7);
            var t = this.get_exception_x0n6w6_k$();
            this._this__u8e3s4__1.close_yn9xrc_k$();
            throw t;
          case 7:
            throw this.get_exception_x0n6w6_k$();
          case 8:
            this.set_exceptionState_fex74n_k$(7);
            this._this__u8e3s4__1.close_yn9xrc_k$();
            return Unit_getInstance();
        }
      } catch ($p) {
        var e_0 = $p;
        if (this.get_exceptionState_wflpxn_k$() === 7) {
          throw e_0;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e_0);
        }
      }
     while (true);
  };
  var DoorLogLevel_VERBOSE_instance;
  var DoorLogLevel_DEBUG_instance;
  var DoorLogLevel_INFO_instance;
  var DoorLogLevel_WARNING_instance;
  var DoorLogLevel_ERROR_instance;
  var DoorLogLevel_ASSERT_instance;
  function values_3() {
    return [DoorLogLevel_VERBOSE_getInstance(), DoorLogLevel_DEBUG_getInstance(), DoorLogLevel_INFO_getInstance(), DoorLogLevel_WARNING_getInstance(), DoorLogLevel_ERROR_getInstance(), DoorLogLevel_ASSERT_getInstance()];
  }
  function valueOf_3(value) {
    switch (value) {
      case 'VERBOSE':
        return DoorLogLevel_VERBOSE_getInstance();
      case 'DEBUG':
        return DoorLogLevel_DEBUG_getInstance();
      case 'INFO':
        return DoorLogLevel_INFO_getInstance();
      case 'WARNING':
        return DoorLogLevel_WARNING_getInstance();
      case 'ERROR':
        return DoorLogLevel_ERROR_getInstance();
      case 'ASSERT':
        return DoorLogLevel_ASSERT_getInstance();
      default:
        DoorLogLevel_initEntries();
        THROW_IAE('No enum constant value.');
        break;
    }
  }
  function get_entries_3() {
    if ($ENTRIES_3 == null)
      $ENTRIES_3 = enumEntries(values_3());
    return $ENTRIES_3;
  }
  var DoorLogLevel_entriesInitialized;
  function DoorLogLevel_initEntries() {
    if (DoorLogLevel_entriesInitialized)
      return Unit_getInstance();
    DoorLogLevel_entriesInitialized = true;
    DoorLogLevel_VERBOSE_instance = new DoorLogLevel('VERBOSE', 0);
    DoorLogLevel_DEBUG_instance = new DoorLogLevel('DEBUG', 1);
    DoorLogLevel_INFO_instance = new DoorLogLevel('INFO', 2);
    DoorLogLevel_WARNING_instance = new DoorLogLevel('WARNING', 3);
    DoorLogLevel_ERROR_instance = new DoorLogLevel('ERROR', 4);
    DoorLogLevel_ASSERT_instance = new DoorLogLevel('ASSERT', 5);
  }
  var $ENTRIES_3;
  function DoorLogLevel(name, ordinal) {
    Enum.call(this, name, ordinal);
  }
  function DoorLogLevel_VERBOSE_getInstance() {
    DoorLogLevel_initEntries();
    return DoorLogLevel_VERBOSE_instance;
  }
  function DoorLogLevel_DEBUG_getInstance() {
    DoorLogLevel_initEntries();
    return DoorLogLevel_DEBUG_instance;
  }
  function DoorLogLevel_INFO_getInstance() {
    DoorLogLevel_initEntries();
    return DoorLogLevel_INFO_instance;
  }
  function DoorLogLevel_WARNING_getInstance() {
    DoorLogLevel_initEntries();
    return DoorLogLevel_WARNING_instance;
  }
  function DoorLogLevel_ERROR_getInstance() {
    DoorLogLevel_initEntries();
    return DoorLogLevel_ERROR_instance;
  }
  function DoorLogLevel_ASSERT_getInstance() {
    DoorLogLevel_initEntries();
    return DoorLogLevel_ASSERT_instance;
  }
  function DoorLogger() {
  }
  function d(_this__u8e3s4, message, throwable) {
    throwable = throwable === VOID ? null : throwable;
    _this__u8e3s4.log_kks8iu_k$(DoorLogLevel_DEBUG_getInstance(), message, throwable);
  }
  function v(_this__u8e3s4, throwable, message) {
    throwable = throwable === VOID ? null : throwable;
    _this__u8e3s4.log_vpti5k_k$(DoorLogLevel_VERBOSE_getInstance(), throwable, message);
  }
  function w(_this__u8e3s4, throwable, message) {
    throwable = throwable === VOID ? null : throwable;
    _this__u8e3s4.log_vpti5k_k$(DoorLogLevel_WARNING_getInstance(), throwable, message);
  }
  function d_0(_this__u8e3s4, throwable, message) {
    throwable = throwable === VOID ? null : throwable;
    _this__u8e3s4.log_vpti5k_k$(DoorLogLevel_DEBUG_getInstance(), throwable, message);
  }
  function e(_this__u8e3s4, message, throwable) {
    throwable = throwable === VOID ? null : throwable;
    _this__u8e3s4.log_kks8iu_k$(DoorLogLevel_ERROR_getInstance(), message, throwable);
  }
  function i(_this__u8e3s4, message, throwable) {
    throwable = throwable === VOID ? null : throwable;
    _this__u8e3s4.log_kks8iu_k$(DoorLogLevel_INFO_getInstance(), message, throwable);
  }
  function w_0(_this__u8e3s4, message, throwable) {
    throwable = throwable === VOID ? null : throwable;
    _this__u8e3s4.log_kks8iu_k$(DoorLogLevel_WARNING_getInstance(), message, throwable);
  }
  function _get_tag__e6h4qf($this) {
    return $this.tag_1;
  }
  function toNapierLogLevel(_this__u8e3s4, $this) {
    var tmp;
    switch (_this__u8e3s4.get_ordinal_ip24qg_k$()) {
      case 0:
        tmp = LogLevel_VERBOSE_getInstance();
        break;
      case 1:
        tmp = LogLevel_DEBUG_getInstance();
        break;
      case 2:
        tmp = LogLevel_INFO_getInstance();
        break;
      case 3:
        tmp = LogLevel_WARNING_getInstance();
        break;
      case 4:
        tmp = LogLevel_ERROR_getInstance();
        break;
      case 5:
        tmp = LogLevel_ASSERT_getInstance();
        break;
      default:
        noWhenBranchMatchedException();
        break;
    }
    return tmp;
  }
  function NapierDoorLogger(tag) {
    tag = tag === VOID ? Companion_getInstance_12().get_LOG_TAG_it8mba_k$() : tag;
    this.tag_1 = tag;
  }
  protoOf(NapierDoorLogger).log_kks8iu_k$ = function (level, message, throwable) {
    Napier_getInstance().log_lmdivf_k$(toNapierLogLevel(level, this), this.tag_1, throwable, message);
  };
  protoOf(NapierDoorLogger).log_vpti5k_k$ = function (level, throwable, message) {
    var logLevel = toNapierLogLevel(level, this);
    if (Napier_getInstance().isEnable_3u442w_k$(logLevel, this.tag_1)) {
      Napier_getInstance().log_lmdivf_k$(logLevel, this.tag_1, throwable, message());
    }
  };
  function DefaultDoorMessageCallback() {
  }
  protoOf(DefaultDoorMessageCallback).onIncomingMessageReceived_pehqv4_k$ = function (db, eventMessage, $completion) {
    return eventMessage;
  };
  protoOf(DefaultDoorMessageCallback).onIncomingMessageProcessed_12bofr_k$ = function (db, eventMessage, $completion) {
    return Unit_getInstance();
  };
  protoOf(DefaultDoorMessageCallback).onBeforeOutgoingMessageSend_yxed9a_k$ = function (db, eventMessage, $completion) {
    return eventMessage;
  };
  protoOf(DefaultDoorMessageCallback).onOutgoingMessageSent_6kws8v_k$ = function (db, eventMessage, $completion) {
    return Unit_getInstance();
  };
  function _get_$childSerializers__r2zwns($this) {
    return $this.$childSerializers_1;
  }
  function Companion_10() {
    Companion_instance_10 = this;
    var tmp = this;
    // Inline function 'kotlin.arrayOf' call
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    tmp.$childSerializers_1 = [null, null, null, new ArrayListSerializer($serializer_getInstance_1())];
    this.WHAT_REPLICATION_PUSH_1 = 1;
    this.WHAT_REPLICATION_PULL_1 = 2;
  }
  protoOf(Companion_10).get_WHAT_REPLICATION_PUSH_tr3xkv_k$ = function () {
    return this.WHAT_REPLICATION_PUSH_1;
  };
  protoOf(Companion_10).get_WHAT_REPLICATION_PULL_tr3xey_k$ = function () {
    return this.WHAT_REPLICATION_PULL_1;
  };
  protoOf(Companion_10).serializer_9w0wvi_k$ = function () {
    return $serializer_getInstance_0();
  };
  var Companion_instance_10;
  function Companion_getInstance_13() {
    if (Companion_instance_10 == null)
      new Companion_10();
    return Companion_instance_10;
  }
  function $serializer_0() {
    $serializer_instance_0 = this;
    var tmp0_serialDesc = new PluginGeneratedSerialDescriptor('com.ustadmobile.door.message.DoorMessage', this, 4);
    tmp0_serialDesc.addElement_5pzumi_k$('what', false);
    tmp0_serialDesc.addElement_5pzumi_k$('fromNode', false);
    tmp0_serialDesc.addElement_5pzumi_k$('toNode', false);
    tmp0_serialDesc.addElement_5pzumi_k$('replications', false);
    this.descriptor_1 = tmp0_serialDesc;
  }
  protoOf($serializer_0).get_descriptor_wjt6a0_k$ = function () {
    return this.descriptor_1;
  };
  protoOf($serializer_0).childSerializers_5ghqw5_k$ = function () {
    var tmp0_cached = Companion_getInstance_13().$childSerializers_1;
    // Inline function 'kotlin.arrayOf' call
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    return [IntSerializer_getInstance(), LongSerializer_getInstance(), LongSerializer_getInstance(), tmp0_cached[3]];
  };
  protoOf($serializer_0).deserialize_sy6x50_k$ = function (decoder) {
    var tmp0_desc = this.descriptor_1;
    var tmp1_flag = true;
    var tmp2_index = 0;
    var tmp3_bitMask0 = 0;
    var tmp4_local0 = 0;
    var tmp5_local1 = new Long(0, 0);
    var tmp6_local2 = new Long(0, 0);
    var tmp7_local3 = null;
    var tmp8_input = decoder.beginStructure_yljocp_k$(tmp0_desc);
    var tmp9_cached = Companion_getInstance_13().$childSerializers_1;
    if (tmp8_input.decodeSequentially_xlblqy_k$()) {
      tmp4_local0 = tmp8_input.decodeIntElement_941u6a_k$(tmp0_desc, 0);
      tmp3_bitMask0 = tmp3_bitMask0 | 1;
      tmp5_local1 = tmp8_input.decodeLongElement_994anb_k$(tmp0_desc, 1);
      tmp3_bitMask0 = tmp3_bitMask0 | 2;
      tmp6_local2 = tmp8_input.decodeLongElement_994anb_k$(tmp0_desc, 2);
      tmp3_bitMask0 = tmp3_bitMask0 | 4;
      tmp7_local3 = tmp8_input.decodeSerializableElement_uahnnv_k$(tmp0_desc, 3, tmp9_cached[3], tmp7_local3);
      tmp3_bitMask0 = tmp3_bitMask0 | 8;
    } else
      while (tmp1_flag) {
        tmp2_index = tmp8_input.decodeElementIndex_bstkhp_k$(tmp0_desc);
        switch (tmp2_index) {
          case -1:
            tmp1_flag = false;
            break;
          case 0:
            tmp4_local0 = tmp8_input.decodeIntElement_941u6a_k$(tmp0_desc, 0);
            tmp3_bitMask0 = tmp3_bitMask0 | 1;
            break;
          case 1:
            tmp5_local1 = tmp8_input.decodeLongElement_994anb_k$(tmp0_desc, 1);
            tmp3_bitMask0 = tmp3_bitMask0 | 2;
            break;
          case 2:
            tmp6_local2 = tmp8_input.decodeLongElement_994anb_k$(tmp0_desc, 2);
            tmp3_bitMask0 = tmp3_bitMask0 | 4;
            break;
          case 3:
            tmp7_local3 = tmp8_input.decodeSerializableElement_uahnnv_k$(tmp0_desc, 3, tmp9_cached[3], tmp7_local3);
            tmp3_bitMask0 = tmp3_bitMask0 | 8;
            break;
          default:
            throw UnknownFieldException_init_$Create$(tmp2_index);
        }
      }
    tmp8_input.endStructure_1xqz0n_k$(tmp0_desc);
    return DoorMessage_init_$Create$(tmp3_bitMask0, tmp4_local0, tmp5_local1, tmp6_local2, tmp7_local3, null);
  };
  protoOf($serializer_0).serialize_odwvld_k$ = function (encoder, value) {
    var tmp0_desc = this.descriptor_1;
    var tmp1_output = encoder.beginStructure_yljocp_k$(tmp0_desc);
    var tmp2_cached = Companion_getInstance_13().$childSerializers_1;
    tmp1_output.encodeIntElement_krhhce_k$(tmp0_desc, 0, value.what_1);
    tmp1_output.encodeLongElement_cega27_k$(tmp0_desc, 1, value.fromNode_1);
    tmp1_output.encodeLongElement_cega27_k$(tmp0_desc, 2, value.toNode_1);
    tmp1_output.encodeSerializableElement_isqxcl_k$(tmp0_desc, 3, tmp2_cached[3], value.replications_1);
    tmp1_output.endStructure_1xqz0n_k$(tmp0_desc);
  };
  protoOf($serializer_0).serialize_5ase3y_k$ = function (encoder, value) {
    return this.serialize_odwvld_k$(encoder, value instanceof DoorMessage ? value : THROW_CCE());
  };
  var $serializer_instance_0;
  function $serializer_getInstance_0() {
    if ($serializer_instance_0 == null)
      new $serializer_0();
    return $serializer_instance_0;
  }
  function DoorMessage_init_$Init$(seen1, what, fromNode, toNode, replications, serializationConstructorMarker, $this) {
    if (!(15 === (15 & seen1))) {
      throwMissingFieldException(seen1, 15, $serializer_getInstance_0().descriptor_1);
    }
    $this.what_1 = what;
    $this.fromNode_1 = fromNode;
    $this.toNode_1 = toNode;
    $this.replications_1 = replications;
    return $this;
  }
  function DoorMessage_init_$Create$(seen1, what, fromNode, toNode, replications, serializationConstructorMarker) {
    return DoorMessage_init_$Init$(seen1, what, fromNode, toNode, replications, serializationConstructorMarker, objectCreate(protoOf(DoorMessage)));
  }
  function DoorMessage(what, fromNode, toNode, replications) {
    Companion_getInstance_13();
    this.what_1 = what;
    this.fromNode_1 = fromNode;
    this.toNode_1 = toNode;
    this.replications_1 = replications;
  }
  protoOf(DoorMessage).get_what_wowufh_k$ = function () {
    return this.what_1;
  };
  protoOf(DoorMessage).get_fromNode_in16s5_k$ = function () {
    return this.fromNode_1;
  };
  protoOf(DoorMessage).get_toNode_k1dkx2_k$ = function () {
    return this.toNode_1;
  };
  protoOf(DoorMessage).get_replications_s2xb3k_k$ = function () {
    return this.replications_1;
  };
  protoOf(DoorMessage).component1_7eebsc_k$ = function () {
    return this.what_1;
  };
  protoOf(DoorMessage).component2_7eebsb_k$ = function () {
    return this.fromNode_1;
  };
  protoOf(DoorMessage).component3_7eebsa_k$ = function () {
    return this.toNode_1;
  };
  protoOf(DoorMessage).component4_7eebs9_k$ = function () {
    return this.replications_1;
  };
  protoOf(DoorMessage).copy_o3k2ca_k$ = function (what, fromNode, toNode, replications) {
    return new DoorMessage(what, fromNode, toNode, replications);
  };
  protoOf(DoorMessage).copy$default_j96d3w_k$ = function (what, fromNode, toNode, replications, $super) {
    what = what === VOID ? this.what_1 : what;
    fromNode = fromNode === VOID ? this.fromNode_1 : fromNode;
    toNode = toNode === VOID ? this.toNode_1 : toNode;
    replications = replications === VOID ? this.replications_1 : replications;
    return $super === VOID ? this.copy_o3k2ca_k$(what, fromNode, toNode, replications) : $super.copy_o3k2ca_k$.call(this, what, fromNode, toNode, replications);
  };
  protoOf(DoorMessage).toString = function () {
    return 'DoorMessage(what=' + this.what_1 + ', fromNode=' + this.fromNode_1.toString() + ', toNode=' + this.toNode_1.toString() + ', replications=' + this.replications_1 + ')';
  };
  protoOf(DoorMessage).hashCode = function () {
    var result = this.what_1;
    result = imul(result, 31) + this.fromNode_1.hashCode() | 0;
    result = imul(result, 31) + this.toNode_1.hashCode() | 0;
    result = imul(result, 31) + hashCode(this.replications_1) | 0;
    return result;
  };
  protoOf(DoorMessage).equals = function (other) {
    if (this === other)
      return true;
    if (!(other instanceof DoorMessage))
      return false;
    var tmp0_other_with_cast = other instanceof DoorMessage ? other : THROW_CCE();
    if (!(this.what_1 === tmp0_other_with_cast.what_1))
      return false;
    if (!this.fromNode_1.equals(tmp0_other_with_cast.fromNode_1))
      return false;
    if (!this.toNode_1.equals(tmp0_other_with_cast.toNode_1))
      return false;
    if (!equals(this.replications_1, tmp0_other_with_cast.replications_1))
      return false;
    return true;
  };
  function DoorMessageCallback() {
  }
  function DoorMigration() {
  }
  function DoorMigrationAsync(startVersion, endVersion, migrateFn) {
    DoorMigration.call(this);
    this.startVersion_1 = startVersion;
    this.endVersion_1 = endVersion;
    this.migrateFn_1 = migrateFn;
  }
  protoOf(DoorMigrationAsync).get_startVersion_84uten_k$ = function () {
    return this.startVersion_1;
  };
  protoOf(DoorMigrationAsync).get_endVersion_algoai_k$ = function () {
    return this.endVersion_1;
  };
  protoOf(DoorMigrationAsync).get_migrateFn_5ksgd2_k$ = function () {
    return this.migrateFn_1;
  };
  function DoorMigrationStatementList(startVersion, endVersion, migrateStmts) {
    DoorMigration.call(this);
    this.startVersion_1 = startVersion;
    this.endVersion_1 = endVersion;
    this.migrateStmts_1 = migrateStmts;
  }
  protoOf(DoorMigrationStatementList).get_startVersion_84uten_k$ = function () {
    return this.startVersion_1;
  };
  protoOf(DoorMigrationStatementList).get_endVersion_algoai_k$ = function () {
    return this.endVersion_1;
  };
  protoOf(DoorMigrationStatementList).get_migrateStmts_i54q9j_k$ = function () {
    return this.migrateStmts_1;
  };
  function DoorMigrationSync(startVersion, endVersion, migrateFn) {
    DoorMigration.call(this);
    this.startVersion_1 = startVersion;
    this.endVersion_1 = endVersion;
    this.migrateFn_1 = migrateFn;
  }
  protoOf(DoorMigrationSync).get_startVersion_84uten_k$ = function () {
    return this.startVersion_1;
  };
  protoOf(DoorMigrationSync).get_endVersion_algoai_k$ = function () {
    return this.endVersion_1;
  };
  protoOf(DoorMigrationSync).get_migrateFn_5ksgd2_k$ = function () {
    return this.migrateFn_1;
  };
  function NodeEvent(what, toNode, tableId, key1, key2, key3, key4) {
    this.what_1 = what;
    this.toNode_1 = toNode;
    this.tableId_1 = tableId;
    this.key1__1 = key1;
    this.key2__1 = key2;
    this.key3__1 = key3;
    this.key4__1 = key4;
  }
  protoOf(NodeEvent).get_what_wowufh_k$ = function () {
    return this.what_1;
  };
  protoOf(NodeEvent).get_toNode_k1dkx2_k$ = function () {
    return this.toNode_1;
  };
  protoOf(NodeEvent).get_tableId_of07s0_k$ = function () {
    return this.tableId_1;
  };
  protoOf(NodeEvent).get_key1_wop4vv_k$ = function () {
    return this.key1__1;
  };
  protoOf(NodeEvent).get_key2_wop4vw_k$ = function () {
    return this.key2__1;
  };
  protoOf(NodeEvent).get_key3_wop4vx_k$ = function () {
    return this.key3__1;
  };
  protoOf(NodeEvent).get_key4_wop4vy_k$ = function () {
    return this.key4__1;
  };
  function createNodeEventTableAndTrigger(_this__u8e3s4, hasOutgoingReplicationTable, temporary, $completion) {
    temporary = temporary === VOID ? true : temporary;
    var tmp = new $createNodeEventTableAndTriggerCOROUTINE$9(_this__u8e3s4, hasOutgoingReplicationTable, temporary, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  }
  function $createNodeEventTableAndTriggerCOROUTINE$9(_this__u8e3s4, hasOutgoingReplicationTable, temporary, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
    this.hasOutgoingReplicationTable_1 = hasOutgoingReplicationTable;
    this.temporary_1 = temporary;
  }
  protoOf($createNodeEventTableAndTriggerCOROUTINE$9).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(10);
            this.set_state_rjd8d0_k$(1);
            continue $sm;
          case 1:
            var tmp_0 = this;
            tmp_0.this1__1 = this._this__u8e3s4__1.createStatement_cbd7tf_k$();
            this.set_state_rjd8d0_k$(2);
            continue $sm;
          case 2:
            this.set_state_rjd8d0_k$(3);
            continue $sm;
          case 3:
            this.set_exceptionState_fex74n_k$(9);
            this.set_exceptionState_fex74n_k$(8);
            var tmp_1 = this;
            tmp_1.stmt4__1 = this.this1__1;
            this.set_state_rjd8d0_k$(4);
            var tmp_2;
            if (this.temporary_1) {
              tmp_2 = NodeEventConstants_getInstance().get_CREATE_NODE_EVENT_TMP_TABLE_SQL_nmsya5_k$();
            } else {
              tmp_2 = NodeEventConstants_getInstance().get_CREATE_NODE_EVENT_TABLE_SQL_qrhtqt_k$();
            }

            suspendResult = executeUpdateAsync(this.stmt4__1, tmp_2, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 4:
            var tmp_3 = this;
            var this_0 = this.stmt4__1;
            var tmp_4;
            if (this.hasOutgoingReplicationTable_1) {
              tmp_4 = this_0;
            } else {
              tmp_4 = null;
            }

            tmp_3.tmp0_safe_receiver5__1 = tmp_4;
            if (this.tmp0_safe_receiver5__1 == null) {
              this.WHEN_RESULT6__1 = null;
              this.set_state_rjd8d0_k$(6);
              continue $sm;
            } else {
              this.set_state_rjd8d0_k$(5);
              var tmp_5;
              if (this.temporary_1) {
                tmp_5 = NodeEventConstants_getInstance().get_CREATE_OUTGOING_REPLICATION_NODE_EVENT_TRIGGER_TMP_ga6zuu_k$();
              } else {
                tmp_5 = NodeEventConstants_getInstance().get_CREATE_OUTGOING_REPLICATION_NODE_EVENT_TRIGGER_7q214u_k$();
              }
              suspendResult = executeUpdateAsync(this.tmp0_safe_receiver5__1, tmp_5, this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            }

          case 5:
            this.WHEN_RESULT6__1 = suspendResult;
            this.set_state_rjd8d0_k$(6);
            continue $sm;
          case 6:
            this.tmp$ret$03__1 = this.WHEN_RESULT6__1;
            this.set_exceptionState_fex74n_k$(10);
            this.set_state_rjd8d0_k$(7);
            var tmp_6 = this;
            continue $sm;
          case 7:
            var tmp_7 = this.tmp$ret$03__1;
            this.set_exceptionState_fex74n_k$(10);
            this.this1__1.close_yn9xrc_k$();
            this.tmp$ret$40__1 = tmp_7;
            this.set_state_rjd8d0_k$(12);
            continue $sm;
          case 8:
            this.set_exceptionState_fex74n_k$(9);
            var tmp_8 = this.get_exception_x0n6w6_k$();
            if (tmp_8 instanceof Exception) {
              var e = this.get_exception_x0n6w6_k$();
              var tmp_9 = this;
              throw e;
            } else {
              throw this.get_exception_x0n6w6_k$();
            }

          case 9:
            this.set_exceptionState_fex74n_k$(10);
            var t = this.get_exception_x0n6w6_k$();
            this.this1__1.close_yn9xrc_k$();
            throw t;
          case 10:
            throw this.get_exception_x0n6w6_k$();
          case 11:
            this.set_exceptionState_fex74n_k$(10);
            this.this1__1.close_yn9xrc_k$();
            if (false) {
              this.set_state_rjd8d0_k$(1);
              continue $sm;
            }

            this.set_state_rjd8d0_k$(12);
            continue $sm;
          case 12:
            return Unit_getInstance();
        }
      } catch ($p) {
        var e_0 = $p;
        if (this.get_exceptionState_wflpxn_k$() === 10) {
          throw e_0;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e_0);
        }
      }
     while (true);
  };
  function _get_NODE_EVENT_TABLE_SQL__i1e7dc($this) {
    return $this.NODE_EVENT_TABLE_SQL_1;
  }
  function _get_OUTGOING_REPLICATION_NODE_EVENT_TRIGGER__np985x($this) {
    return $this.OUTGOING_REPLICATION_NODE_EVENT_TRIGGER_1;
  }
  function NodeEventConstants() {
    NodeEventConstants_instance = this;
    this.OUTGOING_REPLICATION_TABLE_NAME_1 = 'OutgoingReplication';
    this.NODE_EVENT_TABLE_SQL_1 = '\n        TABLE IF NOT EXISTS NodeEvent (\n                   eventId INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,\n                   what INTEGER NOT NULL, \n                   toNode BIGINT NOT NULL,\n                   tableId INTEGER NOT NULL,\n                   key1 BIGINT NOT NULL,\n                   key2 BIGINT NOT NULL,\n                   key3 BIGINT NOT NULL,\n                   key4 BIGINT NOT NULL\n            )\n    ';
    this.CREATE_NODE_EVENT_TMP_TABLE_SQL_1 = '\n            CREATE TEMP \n        TABLE IF NOT EXISTS NodeEvent (\n                   eventId INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,\n                   what INTEGER NOT NULL, \n                   toNode BIGINT NOT NULL,\n                   tableId INTEGER NOT NULL,\n                   key1 BIGINT NOT NULL,\n                   key2 BIGINT NOT NULL,\n                   key3 BIGINT NOT NULL,\n                   key4 BIGINT NOT NULL\n            )\n    \n        ';
    this.CREATE_NODE_EVENT_TABLE_SQL_1 = '\n        CREATE \n        TABLE IF NOT EXISTS NodeEvent (\n                   eventId INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,\n                   what INTEGER NOT NULL, \n                   toNode BIGINT NOT NULL,\n                   tableId INTEGER NOT NULL,\n                   key1 BIGINT NOT NULL,\n                   key2 BIGINT NOT NULL,\n                   key3 BIGINT NOT NULL,\n                   key4 BIGINT NOT NULL\n            )\n    \n    ';
    this.OUTGOING_REPLICATION_NODE_EVENT_TRIGGER_1 = '\n        TRIGGER IF NOT EXISTS _door_event_trig\n             AFTER INSERT\n                ON OutgoingReplication\n             BEGIN INSERT INTO NodeEvent(what, toNode, tableId, key1, key2, key3, key4)\n                   VALUES (1, \n                           NEW.destNodeId, \n                           NEW.orTableId,\n                           NEW.orPk1,\n                           NEW.orPk2,\n                           NEW.orPK3,\n                           NEW.orPk4\n                          );\n                   END      \n    ';
    this.CREATE_OUTGOING_REPLICATION_NODE_EVENT_TRIGGER_TMP_1 = '\n            CREATE TEMP \n        TRIGGER IF NOT EXISTS _door_event_trig\n             AFTER INSERT\n                ON OutgoingReplication\n             BEGIN INSERT INTO NodeEvent(what, toNode, tableId, key1, key2, key3, key4)\n                   VALUES (1, \n                           NEW.destNodeId, \n                           NEW.orTableId,\n                           NEW.orPk1,\n                           NEW.orPk2,\n                           NEW.orPK3,\n                           NEW.orPk4\n                          );\n                   END      \n    \n        ';
    this.CREATE_OUTGOING_REPLICATION_NODE_EVENT_TRIGGER_1 = '\n        CREATE \n        TRIGGER IF NOT EXISTS _door_event_trig\n             AFTER INSERT\n                ON OutgoingReplication\n             BEGIN INSERT INTO NodeEvent(what, toNode, tableId, key1, key2, key3, key4)\n                   VALUES (1, \n                           NEW.destNodeId, \n                           NEW.orTableId,\n                           NEW.orPk1,\n                           NEW.orPk2,\n                           NEW.orPK3,\n                           NEW.orPk4\n                          );\n                   END      \n    \n    ';
    this.SELECT_EVENT_FROM_TMP_TABLE_1 = '\n        SELECT NodeEvent.what AS what,\n               NodeEvent.toNode AS toNode,\n               NodeEvent.tableId AS tableId,\n               NodeEvent.key1 AS key1,\n               NodeEvent.key2 AS key2,\n               NodeEvent.key3 AS key3,\n               NodeEvent.key4 AS key4\n          FROM NodeEvent\n    ';
    this.CLEAR_EVENTS_TMP_TABLE_1 = '\n        DELETE FROM NodeEvent\n    ';
  }
  protoOf(NodeEventConstants).get_OUTGOING_REPLICATION_TABLE_NAME_fm288p_k$ = function () {
    return this.OUTGOING_REPLICATION_TABLE_NAME_1;
  };
  protoOf(NodeEventConstants).get_CREATE_NODE_EVENT_TMP_TABLE_SQL_nmsya5_k$ = function () {
    return this.CREATE_NODE_EVENT_TMP_TABLE_SQL_1;
  };
  protoOf(NodeEventConstants).get_CREATE_NODE_EVENT_TABLE_SQL_qrhtqt_k$ = function () {
    return this.CREATE_NODE_EVENT_TABLE_SQL_1;
  };
  protoOf(NodeEventConstants).get_CREATE_OUTGOING_REPLICATION_NODE_EVENT_TRIGGER_TMP_ga6zuu_k$ = function () {
    return this.CREATE_OUTGOING_REPLICATION_NODE_EVENT_TRIGGER_TMP_1;
  };
  protoOf(NodeEventConstants).get_CREATE_OUTGOING_REPLICATION_NODE_EVENT_TRIGGER_7q214u_k$ = function () {
    return this.CREATE_OUTGOING_REPLICATION_NODE_EVENT_TRIGGER_1;
  };
  protoOf(NodeEventConstants).get_SELECT_EVENT_FROM_TMP_TABLE_iqhehc_k$ = function () {
    return this.SELECT_EVENT_FROM_TMP_TABLE_1;
  };
  protoOf(NodeEventConstants).get_CLEAR_EVENTS_TMP_TABLE_cs4qzf_k$ = function () {
    return this.CLEAR_EVENTS_TMP_TABLE_1;
  };
  var NodeEventConstants_instance;
  function NodeEventConstants_getInstance() {
    if (NodeEventConstants_instance == null)
      new NodeEventConstants();
    return NodeEventConstants_instance;
  }
  function NodeEventManager() {
  }
  function _get__incomingMessages__o1h4sg($this) {
    return $this._incomingMessages_1;
  }
  function NodeEventManagerCommon$onIncomingMessageReceived$lambda(this$0, $message) {
    return function () {
      return this$0.logPrefix_1 + ' receiveMessage with ' + $message.get_replications_s2xb3k_k$().get_size_woubt6_k$() + ' replications: run inserts';
    };
  }
  function NodeEventManagerCommon$onIncomingMessageReceived$slambda(this$0, $message, resultContinuation) {
    this.this$0__1 = this$0;
    this.$message_1 = $message;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(NodeEventManagerCommon$onIncomingMessageReceived$slambda).invoke_dkhsnf_k$ = function (it, $completion) {
    var tmp = this.create_vzhb75_k$(it, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(NodeEventManagerCommon$onIncomingMessageReceived$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_dkhsnf_k$(p1 instanceof RoomDatabase ? p1 : THROW_CCE(), $completion);
  };
  protoOf(NodeEventManagerCommon$onIncomingMessageReceived$slambda).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(4);
            this.set_state_rjd8d0_k$(1);
            suspendResult = this.this$0__1.messageCallback_1.onIncomingMessageReceived_pehqv4_k$(this.this$0__1.db_1, this.$message_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            this.messageToProcess0__1 = suspendResult;
            this.set_state_rjd8d0_k$(2);
            suspendResult = insertEntitiesFromMessage(this.this$0__1.db_1, this.messageToProcess0__1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 2:
            this.set_state_rjd8d0_k$(3);
            suspendResult = this.this$0__1.messageCallback_1.onIncomingMessageProcessed_12bofr_k$(this.this$0__1.db_1, this.messageToProcess0__1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 3:
            return Unit_getInstance();
          case 4:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 4) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(NodeEventManagerCommon$onIncomingMessageReceived$slambda).create_vzhb75_k$ = function (it, completion) {
    var i = new NodeEventManagerCommon$onIncomingMessageReceived$slambda(this.this$0__1, this.$message_1, completion);
    i.it_1 = it;
    return i;
  };
  protoOf(NodeEventManagerCommon$onIncomingMessageReceived$slambda).create_wyq9v6_k$ = function (value, completion) {
    return this.create_vzhb75_k$(value instanceof RoomDatabase ? value : THROW_CCE(), completion);
  };
  function NodeEventManagerCommon$onIncomingMessageReceived$slambda_0(this$0, $message, resultContinuation) {
    var i = new NodeEventManagerCommon$onIncomingMessageReceived$slambda(this$0, $message, resultContinuation);
    var l = function (it, $completion) {
      return i.invoke_dkhsnf_k$(it, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function NodeEventManagerCommon$onIncomingMessageReceived$lambda_0(this$0, $message) {
    return function () {
      return this$0.logPrefix_1 + ' receiveMessage with ' + $message.get_replications_s2xb3k_k$().get_size_woubt6_k$() + ' replications: inserts done/transaction finished';
    };
  }
  function $onIncomingMessageReceivedCOROUTINE$10(_this__u8e3s4, message, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
    this.message_1 = message;
  }
  protoOf($onIncomingMessageReceivedCOROUTINE$10).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(5);
            this._this__u8e3s4__1.assertNotClosed_modxnt_k$();
            this.set_exceptionState_fex74n_k$(3);
            var tmp_0 = this._this__u8e3s4__1.get_logger_g9gejd_k$();
            v(tmp_0, VOID, NodeEventManagerCommon$onIncomingMessageReceived$lambda(this._this__u8e3s4__1, this.message_1));
            this.set_state_rjd8d0_k$(1);
            suspendResult = withDoorTransactionAsync(this._this__u8e3s4__1.db_1, VOID, NodeEventManagerCommon$onIncomingMessageReceived$slambda_0(this._this__u8e3s4__1, this.message_1, null), this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            var tmp_1 = this._this__u8e3s4__1.get_logger_g9gejd_k$();
            d_0(tmp_1, VOID, NodeEventManagerCommon$onIncomingMessageReceived$lambda_0(this._this__u8e3s4__1, this.message_1));
            this.set_state_rjd8d0_k$(2);
            suspendResult = this._this__u8e3s4__1._incomingMessages_1.emit_t92u1f_k$(this.message_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 2:
            this.set_exceptionState_fex74n_k$(5);
            this.set_state_rjd8d0_k$(4);
            continue $sm;
          case 3:
            this.set_exceptionState_fex74n_k$(5);
            var tmp_2 = this.get_exception_x0n6w6_k$();
            if (tmp_2 instanceof Exception) {
              var e = this.get_exception_x0n6w6_k$();
              throw e;
            } else {
              throw this.get_exception_x0n6w6_k$();
            }

          case 4:
            this.set_exceptionState_fex74n_k$(5);
            return Unit_getInstance();
          case 5:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e_0 = $p;
        if (this.get_exceptionState_wflpxn_k$() === 5) {
          throw e_0;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e_0);
        }
      }
     while (true);
  };
  function NodeEventManagerCommon(db, messageCallback, logger, dbName, dispatcher) {
    dispatcher = dispatcher === VOID ? Dispatchers_getInstance().get_Default_goqax4_k$() : dispatcher;
    this.db_1 = db;
    this.messageCallback_1 = messageCallback;
    this.logger_1 = logger;
    this.dbName_1 = dbName;
    this.dispatcher_1 = dispatcher;
    this.logPrefix_1 = '[NodeEventManager - ' + this.dbName_1 + ']';
    this.hasOutgoingReplicationTable_1 = doorDatabaseMetadata(getKClassFromExpression(this.db_1)).get_allTables_1jy9x9_k$().contains_aljjnj_k$('OutgoingReplication');
    this._outgoingEvents_1 = MutableSharedFlow();
    this.outgoingEvents_1 = asSharedFlow(this._outgoingEvents_1);
    this._incomingMessages_1 = MutableSharedFlow();
    this.incomingMessages_1 = asSharedFlow(this._incomingMessages_1);
    this.closed_1 = atomic$boolean$1(false);
  }
  protoOf(NodeEventManagerCommon).get_db_knto1l_k$ = function () {
    return this.db_1;
  };
  protoOf(NodeEventManagerCommon).get_messageCallback_kxaem5_k$ = function () {
    return this.messageCallback_1;
  };
  protoOf(NodeEventManagerCommon).get_logger_g9gejd_k$ = function () {
    return this.logger_1;
  };
  protoOf(NodeEventManagerCommon).get_dbName_c9i0qa_k$ = function () {
    return this.dbName_1;
  };
  protoOf(NodeEventManagerCommon).get_dispatcher_usy1bk_k$ = function () {
    return this.dispatcher_1;
  };
  protoOf(NodeEventManagerCommon).get_logPrefix_vopxo3_k$ = function () {
    return this.logPrefix_1;
  };
  protoOf(NodeEventManagerCommon).get_hasOutgoingReplicationTable_wjzuwv_k$ = function () {
    return this.hasOutgoingReplicationTable_1;
  };
  protoOf(NodeEventManagerCommon).get__outgoingEvents_qw2ml7_k$ = function () {
    return this._outgoingEvents_1;
  };
  protoOf(NodeEventManagerCommon).get_outgoingEvents_40o3ma_k$ = function () {
    return this.outgoingEvents_1;
  };
  protoOf(NodeEventManagerCommon).get_incomingMessages_7rqqu3_k$ = function () {
    return this.incomingMessages_1;
  };
  protoOf(NodeEventManagerCommon).get_closed_byjrzp_k$ = function () {
    return this.closed_1;
  };
  protoOf(NodeEventManagerCommon).assertNotClosed_modxnt_k$ = function () {
    if (this.closed_1.get_kotlinx$atomicfu$value_vi2am5_k$())
      throw IllegalStateException_init_$Create$('NodeEventManager is closed!');
  };
  protoOf(NodeEventManagerCommon).onIncomingMessageReceived_3v60w2_k$ = function (message, $completion) {
    var tmp = new $onIncomingMessageReceivedCOROUTINE$10(this, message, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(NodeEventManagerCommon).close_yn9xrc_k$ = function () {
    this.closed_1.set_kotlinx$atomicfu$value_tm3k58_k$(true);
  };
  function _get_invalidationDelegate__oj54rc($this) {
    return $this.invalidationDelegate_1;
  }
  function _get_srcInvalidateCallbackRegistered__72hoxh($this) {
    return $this.srcInvalidateCallbackRegistered_1;
  }
  function _get_invalidated__yx9o7s($this) {
    return $this.invalidated_1;
  }
  function _get_srcInvalidatedCallback__qnsba7($this) {
    return $this.srcInvalidatedCallback_1;
  }
  function onSrcInvalidated($this) {
    $this.invalidationDelegate_1.unregisterInvalidatedCallback_3xxsu2_k$($this.srcInvalidatedCallback_1);
    if (!$this.invalidated_1.atomicfu$getAndSet(true)) {
      $this.invalidate_p4aufp_k$();
    }
  }
  function DelegatedInvalidationPagingSource$srcInvalidatedCallback$lambda(this$0) {
    return function () {
      onSrcInvalidated(this$0);
      return Unit_getInstance();
    };
  }
  function DelegatedInvalidationPagingSource(invalidationDelegate) {
    PagingSource.call(this);
    this.invalidationDelegate_1 = invalidationDelegate;
    this.srcInvalidateCallbackRegistered_1 = atomic$boolean$1(false);
    this.invalidated_1 = atomic$boolean$1(false);
    var tmp = this;
    tmp.srcInvalidatedCallback_1 = DelegatedInvalidationPagingSource$srcInvalidatedCallback$lambda(this);
  }
  protoOf(DelegatedInvalidationPagingSource).registerInvalidationCallbackIfNeeded_8aur2g_k$ = function () {
    if (!this.srcInvalidateCallbackRegistered_1.atomicfu$getAndSet(true)) {
      this.invalidationDelegate_1.registerInvalidatedCallback_m09l7x_k$(this.srcInvalidatedCallback_1);
    }
  };
  function get_INVALID() {
    _init_properties_DoorPagingUtil_kt__xv2bfg();
    return INVALID;
  }
  var INVALID;
  var properties_initialized_DoorPagingUtil_kt_2vglj6;
  function _init_properties_DoorPagingUtil_kt__xv2bfg() {
    if (!properties_initialized_DoorPagingUtil_kt_2vglj6) {
      properties_initialized_DoorPagingUtil_kt_2vglj6 = true;
      INVALID = new Invalid();
    }
  }
  function PagingSourceWithHttpLoader() {
  }
  function acknowledgeReceivedReplications(_this__u8e3s4, nodeId, receivedUids, $completion) {
    return prepareAndUseStatementAsync_0(_this__u8e3s4, '\n        DELETE FROM OutgoingReplication\n              WHERE orUid = ?\n                AND destNodeId = ?\n        ', false, acknowledgeReceivedReplications$slambda_0(receivedUids, nodeId, null), $completion);
  }
  function selectPendingOutgoingReplicationsByDestNodeId(_this__u8e3s4, nodeId, limit, $completion) {
    limit = limit === VOID ? 1000 : limit;
    var tmp = new $selectPendingOutgoingReplicationsByDestNodeIdCOROUTINE$11(_this__u8e3s4, nodeId, limit, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  }
  function getDoorNodeAuth(_this__u8e3s4, nodeId, $completion) {
    return prepareAndUseStatementAsync_0(_this__u8e3s4, 'SELECT auth\n            FROM DoorNode\n            WHERE nodeId = ?\n            ', true, getDoorNodeAuth$slambda_0(nodeId, null), $completion);
  }
  function insertNewDoorNode(_this__u8e3s4, node, $completion) {
    var tmp = new $insertNewDoorNodeCOROUTINE$12(_this__u8e3s4, node, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  }
  function insertEntitiesFromMessage(_this__u8e3s4, message, $completion) {
    var tmp = new $insertEntitiesFromMessageCOROUTINE$13(_this__u8e3s4, message, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  }
  function selectDoorReplicateEntitiesByTableIdAndPrimaryKeys(_this__u8e3s4, tableId, primaryKeysList, $completion) {
    var entityMetaData = doorDatabaseMetadata(getKClassFromExpression(_this__u8e3s4)).requireReplicateEntityMetaData_9swzku_k$(tableId);
    var tmp = entityMetaData.get_selectEntityByPrimaryKeysSql_y6bvk9_k$();
    return prepareAndUseStatementAsync_0(_this__u8e3s4, tmp, true, selectDoorReplicateEntitiesByTableIdAndPrimaryKeys$slambda_0(primaryKeysList, entityMetaData, tableId, null), $completion);
  }
  function ReplicateEntityPrimaryKeys(pk1, pk2, pk3, pk4, orUid) {
    this.pk1__1 = pk1;
    this.pk2__1 = pk2;
    this.pk3__1 = pk3;
    this.pk4__1 = pk4;
    this.orUid_1 = orUid;
  }
  protoOf(ReplicateEntityPrimaryKeys).get_pk1_18iyfn_k$ = function () {
    return this.pk1__1;
  };
  protoOf(ReplicateEntityPrimaryKeys).get_pk2_18iyfm_k$ = function () {
    return this.pk2__1;
  };
  protoOf(ReplicateEntityPrimaryKeys).set_pk3_p03ewz_k$ = function (_set____db54di) {
    this.pk3__1 = _set____db54di;
  };
  protoOf(ReplicateEntityPrimaryKeys).get_pk3_18iyfl_k$ = function () {
    return this.pk3__1;
  };
  protoOf(ReplicateEntityPrimaryKeys).set_pk4_wc7joi_k$ = function (_set____db54di) {
    this.pk4__1 = _set____db54di;
  };
  protoOf(ReplicateEntityPrimaryKeys).get_pk4_18iyfk_k$ = function () {
    return this.pk4__1;
  };
  protoOf(ReplicateEntityPrimaryKeys).get_orUid_iwh7pg_k$ = function () {
    return this.orUid_1;
  };
  protoOf(ReplicateEntityPrimaryKeys).component1_7eebsc_k$ = function () {
    return this.pk1__1;
  };
  protoOf(ReplicateEntityPrimaryKeys).component2_7eebsb_k$ = function () {
    return this.pk2__1;
  };
  protoOf(ReplicateEntityPrimaryKeys).component3_7eebsa_k$ = function () {
    return this.pk3__1;
  };
  protoOf(ReplicateEntityPrimaryKeys).component4_7eebs9_k$ = function () {
    return this.pk4__1;
  };
  protoOf(ReplicateEntityPrimaryKeys).component5_7eebs8_k$ = function () {
    return this.orUid_1;
  };
  protoOf(ReplicateEntityPrimaryKeys).copy_167ief_k$ = function (pk1, pk2, pk3, pk4, orUid) {
    return new ReplicateEntityPrimaryKeys(pk1, pk2, pk3, pk4, orUid);
  };
  protoOf(ReplicateEntityPrimaryKeys).copy$default_3r9jfs_k$ = function (pk1, pk2, pk3, pk4, orUid, $super) {
    pk1 = pk1 === VOID ? this.pk1__1 : pk1;
    pk2 = pk2 === VOID ? this.pk2__1 : pk2;
    pk3 = pk3 === VOID ? this.pk3__1 : pk3;
    pk4 = pk4 === VOID ? this.pk4__1 : pk4;
    orUid = orUid === VOID ? this.orUid_1 : orUid;
    return $super === VOID ? this.copy_167ief_k$(pk1, pk2, pk3, pk4, orUid) : $super.copy_167ief_k$.call(this, pk1, pk2, pk3, pk4, orUid);
  };
  protoOf(ReplicateEntityPrimaryKeys).toString = function () {
    return 'ReplicateEntityPrimaryKeys(pk1=' + this.pk1__1.toString() + ', pk2=' + this.pk2__1.toString() + ', pk3=' + this.pk3__1.toString() + ', pk4=' + this.pk4__1.toString() + ', orUid=' + this.orUid_1.toString() + ')';
  };
  protoOf(ReplicateEntityPrimaryKeys).hashCode = function () {
    var result = this.pk1__1.hashCode();
    result = imul(result, 31) + this.pk2__1.hashCode() | 0;
    result = imul(result, 31) + this.pk3__1.hashCode() | 0;
    result = imul(result, 31) + this.pk4__1.hashCode() | 0;
    result = imul(result, 31) + this.orUid_1.hashCode() | 0;
    return result;
  };
  protoOf(ReplicateEntityPrimaryKeys).equals = function (other) {
    if (this === other)
      return true;
    if (!(other instanceof ReplicateEntityPrimaryKeys))
      return false;
    var tmp0_other_with_cast = other instanceof ReplicateEntityPrimaryKeys ? other : THROW_CCE();
    if (!this.pk1__1.equals(tmp0_other_with_cast.pk1__1))
      return false;
    if (!this.pk2__1.equals(tmp0_other_with_cast.pk2__1))
      return false;
    if (!this.pk3__1.equals(tmp0_other_with_cast.pk3__1))
      return false;
    if (!this.pk4__1.equals(tmp0_other_with_cast.pk4__1))
      return false;
    if (!this.orUid_1.equals(tmp0_other_with_cast.orUid_1))
      return false;
    return true;
  };
  function acknowledgeReceivedReplications$slambda($receivedUids, $nodeId, resultContinuation) {
    this.$receivedUids_1 = $receivedUids;
    this.$nodeId_1 = $nodeId;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(acknowledgeReceivedReplications$slambda).invoke_e5ovyj_k$ = function (stmt, $completion) {
    var tmp = this.create_hxh3pd_k$(stmt, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(acknowledgeReceivedReplications$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_e5ovyj_k$((!(p1 == null) ? isInterface(p1, PreparedStatement) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(acknowledgeReceivedReplications$slambda).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(4);
            var tmp_0 = this;
            tmp_0.this0__1 = this.$receivedUids_1;
            this.tmp0_iterator1__1 = this.this0__1.iterator_jk1svi_k$();
            this.set_state_rjd8d0_k$(1);
            continue $sm;
          case 1:
            if (!this.tmp0_iterator1__1.hasNext_bitz1p_k$()) {
              this.set_state_rjd8d0_k$(3);
              continue $sm;
            }

            this.element2__1 = this.tmp0_iterator1__1.next_20eer_k$();
            var tmp_1 = this;
            tmp_1.uid3__1 = this.element2__1;
            this.stmt_1.setLong_j1sybo_k$(1, this.uid3__1);
            this.stmt_1.setLong_j1sybo_k$(2, this.$nodeId_1);
            this.set_state_rjd8d0_k$(2);
            suspendResult = executeUpdateAsyncKmp(this.stmt_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 2:
            this.set_state_rjd8d0_k$(1);
            continue $sm;
          case 3:
            return Unit_getInstance();
          case 4:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 4) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(acknowledgeReceivedReplications$slambda).create_hxh3pd_k$ = function (stmt, completion) {
    var i = new acknowledgeReceivedReplications$slambda(this.$receivedUids_1, this.$nodeId_1, completion);
    i.stmt_1 = stmt;
    return i;
  };
  protoOf(acknowledgeReceivedReplications$slambda).create_wyq9v6_k$ = function (value, completion) {
    return this.create_hxh3pd_k$((!(value == null) ? isInterface(value, PreparedStatement) : false) ? value : THROW_CCE(), completion);
  };
  function acknowledgeReceivedReplications$slambda_0($receivedUids, $nodeId, resultContinuation) {
    var i = new acknowledgeReceivedReplications$slambda($receivedUids, $nodeId, resultContinuation);
    var l = function (stmt, $completion) {
      return i.invoke_e5ovyj_k$(stmt, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function selectPendingOutgoingReplicationsByDestNodeId$slambda$lambda(results) {
    return mapRows(results, selectPendingOutgoingReplicationsByDestNodeId$slambda$lambda$lambda);
  }
  function selectPendingOutgoingReplicationsByDestNodeId$slambda$lambda$lambda(result) {
    return new OutgoingReplication(result.getLong_3wgf2g_k$('orUid'), result.getLong_3wgf2g_k$('destNodeId'), result.getInt_npc9pd_k$('orTableId'), result.getLong_3wgf2g_k$('orPk1'), result.getLong_3wgf2g_k$('orPk2'));
  }
  function selectPendingOutgoingReplicationsByDestNodeId$slambda($nodeId, $limit, resultContinuation) {
    this.$nodeId_1 = $nodeId;
    this.$limit_1 = $limit;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(selectPendingOutgoingReplicationsByDestNodeId$slambda).invoke_hjnl1o_k$ = function (stmt, $completion) {
    var tmp = this.create_hxh3pd_k$(stmt, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(selectPendingOutgoingReplicationsByDestNodeId$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_hjnl1o_k$((!(p1 == null) ? isInterface(p1, PreparedStatement) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(selectPendingOutgoingReplicationsByDestNodeId$slambda).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            this.stmt_1.setLong_j1sybo_k$(1, this.$nodeId_1);
            this.stmt_1.setInt_c72a8z_k$(2, this.$limit_1);
            this.set_state_rjd8d0_k$(1);
            suspendResult = executeQueryAsyncKmp(this.stmt_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            var ARGUMENT = suspendResult;
            return useResults(ARGUMENT, selectPendingOutgoingReplicationsByDestNodeId$slambda$lambda);
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(selectPendingOutgoingReplicationsByDestNodeId$slambda).create_hxh3pd_k$ = function (stmt, completion) {
    var i = new selectPendingOutgoingReplicationsByDestNodeId$slambda(this.$nodeId_1, this.$limit_1, completion);
    i.stmt_1 = stmt;
    return i;
  };
  protoOf(selectPendingOutgoingReplicationsByDestNodeId$slambda).create_wyq9v6_k$ = function (value, completion) {
    return this.create_hxh3pd_k$((!(value == null) ? isInterface(value, PreparedStatement) : false) ? value : THROW_CCE(), completion);
  };
  function selectPendingOutgoingReplicationsByDestNodeId$slambda_0($nodeId, $limit, resultContinuation) {
    var i = new selectPendingOutgoingReplicationsByDestNodeId$slambda($nodeId, $limit, resultContinuation);
    var l = function (stmt, $completion) {
      return i.invoke_hjnl1o_k$(stmt, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function getDoorNodeAuth$slambda$lambda(results) {
    return firstOrNull(mapRows(results, getDoorNodeAuth$slambda$lambda$lambda));
  }
  function getDoorNodeAuth$slambda$lambda$lambda(it) {
    return it.getString_5demq7_k$(1);
  }
  function getDoorNodeAuth$slambda($nodeId, resultContinuation) {
    this.$nodeId_1 = $nodeId;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(getDoorNodeAuth$slambda).invoke_j35ylu_k$ = function (stmt, $completion) {
    var tmp = this.create_hxh3pd_k$(stmt, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(getDoorNodeAuth$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_j35ylu_k$((!(p1 == null) ? isInterface(p1, PreparedStatement) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(getDoorNodeAuth$slambda).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            this.stmt_1.setLong_j1sybo_k$(1, this.$nodeId_1);
            this.set_state_rjd8d0_k$(1);
            suspendResult = executeQueryAsyncKmp(this.stmt_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            var ARGUMENT = suspendResult;
            return useResults(ARGUMENT, getDoorNodeAuth$slambda$lambda);
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(getDoorNodeAuth$slambda).create_hxh3pd_k$ = function (stmt, completion) {
    var i = new getDoorNodeAuth$slambda(this.$nodeId_1, completion);
    i.stmt_1 = stmt;
    return i;
  };
  protoOf(getDoorNodeAuth$slambda).create_wyq9v6_k$ = function (value, completion) {
    return this.create_hxh3pd_k$((!(value == null) ? isInterface(value, PreparedStatement) : false) ? value : THROW_CCE(), completion);
  };
  function getDoorNodeAuth$slambda_0($nodeId, resultContinuation) {
    var i = new getDoorNodeAuth$slambda($nodeId, resultContinuation);
    var l = function (stmt, $completion) {
      return i.invoke_j35ylu_k$(stmt, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function insertNewDoorNode$slambda($node, resultContinuation) {
    this.$node_1 = $node;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(insertNewDoorNode$slambda).invoke_n3u1ar_k$ = function (stmt, $completion) {
    var tmp = this.create_hxh3pd_k$(stmt, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(insertNewDoorNode$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_n3u1ar_k$((!(p1 == null) ? isInterface(p1, PreparedStatement) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(insertNewDoorNode$slambda).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            this.stmt_1.setLong_j1sybo_k$(1, this.$node_1.get_nodeId_h7ho7a_k$());
            this.stmt_1.setString_2gt7ua_k$(2, this.$node_1.get_auth_woj2sx_k$());
            this.stmt_1.setInt_c72a8z_k$(3, this.$node_1.get_rel_18ix1s_k$());
            this.set_state_rjd8d0_k$(1);
            suspendResult = executeUpdateAsyncKmp(this.stmt_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            return suspendResult;
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(insertNewDoorNode$slambda).create_hxh3pd_k$ = function (stmt, completion) {
    var i = new insertNewDoorNode$slambda(this.$node_1, completion);
    i.stmt_1 = stmt;
    return i;
  };
  protoOf(insertNewDoorNode$slambda).create_wyq9v6_k$ = function (value, completion) {
    return this.create_hxh3pd_k$((!(value == null) ? isInterface(value, PreparedStatement) : false) ? value : THROW_CCE(), completion);
  };
  function insertNewDoorNode$slambda_0($node, resultContinuation) {
    var i = new insertNewDoorNode$slambda($node, resultContinuation);
    var l = function (stmt, $completion) {
      return i.invoke_n3u1ar_k$(stmt, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function insertEntitiesFromMessage$slambda($message, $tableId, resultContinuation) {
    this.$message_1 = $message;
    this.$tableId_1 = $tableId;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(insertEntitiesFromMessage$slambda).invoke_n3u1ar_k$ = function (stmt, $completion) {
    var tmp = this.create_hxh3pd_k$(stmt, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(insertEntitiesFromMessage$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_n3u1ar_k$((!(p1 == null) ? isInterface(p1, PreparedStatement) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(insertEntitiesFromMessage$slambda).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            this.stmt_1.setLong_j1sybo_k$(1, this.$message_1.get_fromNode_in16s5_k$());
            this.stmt_1.setInt_c72a8z_k$(2, this.$tableId_1);
            this.stmt_1.setInt_c72a8z_k$(3, 0);
            this.set_state_rjd8d0_k$(1);
            suspendResult = executeUpdateAsyncKmp(this.stmt_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            return suspendResult;
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(insertEntitiesFromMessage$slambda).create_hxh3pd_k$ = function (stmt, completion) {
    var i = new insertEntitiesFromMessage$slambda(this.$message_1, this.$tableId_1, completion);
    i.stmt_1 = stmt;
    return i;
  };
  protoOf(insertEntitiesFromMessage$slambda).create_wyq9v6_k$ = function (value, completion) {
    return this.create_hxh3pd_k$((!(value == null) ? isInterface(value, PreparedStatement) : false) ? value : THROW_CCE(), completion);
  };
  function insertEntitiesFromMessage$slambda_0($message, $tableId, resultContinuation) {
    var i = new insertEntitiesFromMessage$slambda($message, $tableId, resultContinuation);
    var l = function (stmt, $completion) {
      return i.invoke_n3u1ar_k$(stmt, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function insertEntitiesFromMessage$slambda_1($tableEntities, $entityMetaData, $message, resultContinuation) {
    this.$tableEntities_1 = $tableEntities;
    this.$entityMetaData_1 = $entityMetaData;
    this.$message_1 = $message;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(insertEntitiesFromMessage$slambda_1).invoke_e5ovyj_k$ = function (stmt, $completion) {
    var tmp = this.create_hxh3pd_k$(stmt, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(insertEntitiesFromMessage$slambda_1).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_e5ovyj_k$((!(p1 == null) ? isInterface(p1, PreparedStatement) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(insertEntitiesFromMessage$slambda_1).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(4);
            var tmp_0 = this;
            tmp_0.this0__1 = this.$tableEntities_1;
            this.tmp0_iterator1__1 = this.this0__1.iterator_jk1svi_k$();
            this.set_state_rjd8d0_k$(1);
            continue $sm;
          case 1:
            if (!this.tmp0_iterator1__1.hasNext_bitz1p_k$()) {
              this.set_state_rjd8d0_k$(3);
              continue $sm;
            }

            this.element2__1 = this.tmp0_iterator1__1.next_20eer_k$();
            var tmp_1 = this;
            tmp_1.entity3__1 = this.element2__1;
            setAllFromJsonObject(this.stmt_1, this.entity3__1.get_entity_cxtlv0_k$(), this.$entityMetaData_1.get_entityFields_ad1dc5_k$());
            this.stmt_1.setLong_j1sybo_k$(this.$entityMetaData_1.get_entityFields_ad1dc5_k$().get_size_woubt6_k$() + 1 | 0, this.$message_1.get_fromNode_in16s5_k$());
            this.set_state_rjd8d0_k$(2);
            suspendResult = executeUpdateAsyncKmp(this.stmt_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 2:
            this.set_state_rjd8d0_k$(1);
            continue $sm;
          case 3:
            return Unit_getInstance();
          case 4:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 4) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(insertEntitiesFromMessage$slambda_1).create_hxh3pd_k$ = function (stmt, completion) {
    var i = new insertEntitiesFromMessage$slambda_1(this.$tableEntities_1, this.$entityMetaData_1, this.$message_1, completion);
    i.stmt_1 = stmt;
    return i;
  };
  protoOf(insertEntitiesFromMessage$slambda_1).create_wyq9v6_k$ = function (value, completion) {
    return this.create_hxh3pd_k$((!(value == null) ? isInterface(value, PreparedStatement) : false) ? value : THROW_CCE(), completion);
  };
  function insertEntitiesFromMessage$slambda_2($tableEntities, $entityMetaData, $message, resultContinuation) {
    var i = new insertEntitiesFromMessage$slambda_1($tableEntities, $entityMetaData, $message, resultContinuation);
    var l = function (stmt, $completion) {
      return i.invoke_e5ovyj_k$(stmt, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function insertEntitiesFromMessage$slambda_3($message, $tableId, resultContinuation) {
    this.$message_1 = $message;
    this.$tableId_1 = $tableId;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(insertEntitiesFromMessage$slambda_3).invoke_n3u1ar_k$ = function (stmt, $completion) {
    var tmp = this.create_hxh3pd_k$(stmt, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(insertEntitiesFromMessage$slambda_3).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_n3u1ar_k$((!(p1 == null) ? isInterface(p1, PreparedStatement) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(insertEntitiesFromMessage$slambda_3).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            this.stmt_1.setLong_j1sybo_k$(1, this.$message_1.get_fromNode_in16s5_k$());
            this.stmt_1.setInt_c72a8z_k$(2, this.$tableId_1);
            this.set_state_rjd8d0_k$(1);
            suspendResult = executeUpdateAsyncKmp(this.stmt_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            return suspendResult;
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(insertEntitiesFromMessage$slambda_3).create_hxh3pd_k$ = function (stmt, completion) {
    var i = new insertEntitiesFromMessage$slambda_3(this.$message_1, this.$tableId_1, completion);
    i.stmt_1 = stmt;
    return i;
  };
  protoOf(insertEntitiesFromMessage$slambda_3).create_wyq9v6_k$ = function (value, completion) {
    return this.create_hxh3pd_k$((!(value == null) ? isInterface(value, PreparedStatement) : false) ? value : THROW_CCE(), completion);
  };
  function insertEntitiesFromMessage$slambda_4($message, $tableId, resultContinuation) {
    var i = new insertEntitiesFromMessage$slambda_3($message, $tableId, resultContinuation);
    var l = function (stmt, $completion) {
      return i.invoke_n3u1ar_k$(stmt, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function selectDoorReplicateEntitiesByTableIdAndPrimaryKeys$slambda$lambda$lambda($tableId, $primaryKeys, $entityMetaData) {
    return function (mapResult) {
      return new DoorReplicationEntity($tableId, $primaryKeys.orUid_1, rowToJsonObject(mapResult, $entityMetaData.get_entityFields_ad1dc5_k$()));
    };
  }
  function selectDoorReplicateEntitiesByTableIdAndPrimaryKeys$slambda$lambda($tableId, $primaryKeys, $entityMetaData) {
    return function (result) {
      return mapNextRow(result, null, selectDoorReplicateEntitiesByTableIdAndPrimaryKeys$slambda$lambda$lambda($tableId, $primaryKeys, $entityMetaData));
    };
  }
  function selectDoorReplicateEntitiesByTableIdAndPrimaryKeys$slambda($primaryKeysList, $entityMetaData, $tableId, resultContinuation) {
    this.$primaryKeysList_1 = $primaryKeysList;
    this.$entityMetaData_1 = $entityMetaData;
    this.$tableId_1 = $tableId;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(selectDoorReplicateEntitiesByTableIdAndPrimaryKeys$slambda).invoke_u0nirm_k$ = function (stmt, $completion) {
    var tmp = this.create_hxh3pd_k$(stmt, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(selectDoorReplicateEntitiesByTableIdAndPrimaryKeys$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_u0nirm_k$((!(p1 == null) ? isInterface(p1, PreparedStatement) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(selectDoorReplicateEntitiesByTableIdAndPrimaryKeys$slambda).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(4);
            var tmp_0 = this;
            tmp_0.this0__1 = this.$primaryKeysList_1;
            var tmp_1 = this;
            tmp_1.this1__1 = this.this0__1;
            var tmp_2 = this;
            tmp_2.destination2__1 = ArrayList_init_$Create$();
            var tmp_3 = this;
            tmp_3.this3__1 = this.this1__1;
            this.tmp0_iterator4__1 = this.this3__1.iterator_jk1svi_k$();
            this.set_state_rjd8d0_k$(1);
            continue $sm;
          case 1:
            if (!this.tmp0_iterator4__1.hasNext_bitz1p_k$()) {
              this.set_state_rjd8d0_k$(3);
              continue $sm;
            }

            this.element5__1 = this.tmp0_iterator4__1.next_20eer_k$();
            var tmp_4 = this;
            tmp_4.element6__1 = this.element5__1;
            var tmp_5 = this;
            tmp_5.primaryKeys7__1 = this.element6__1;
            this.stmt_1.setLong_j1sybo_k$(1, this.primaryKeys7__1.pk1__1);
            if (this.$entityMetaData_1.get_entityPrimaryKeyFieldNames_5y8huf_k$().get_size_woubt6_k$() >= 2) {
              this.stmt_1.setLong_j1sybo_k$(2, this.primaryKeys7__1.pk2__1);
            }

            if (this.$entityMetaData_1.get_entityPrimaryKeyFieldNames_5y8huf_k$().get_size_woubt6_k$() >= 3) {
              this.stmt_1.setLong_j1sybo_k$(3, this.primaryKeys7__1.pk3__1);
            }

            if (this.$entityMetaData_1.get_entityPrimaryKeyFieldNames_5y8huf_k$().get_size_woubt6_k$() >= 4) {
              this.stmt_1.setLong_j1sybo_k$(3, this.primaryKeys7__1.pk4__1);
            }

            this.set_state_rjd8d0_k$(2);
            suspendResult = executeQueryAsyncKmp(this.stmt_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 2:
            var ARGUMENT = suspendResult;
            var tmp0_safe_receiver = useResults(ARGUMENT, selectDoorReplicateEntitiesByTableIdAndPrimaryKeys$slambda$lambda(this.$tableId_1, this.primaryKeys7__1, this.$entityMetaData_1));
            if (tmp0_safe_receiver == null)
              null;
            else {
              this.destination2__1.add_utx5q5_k$(tmp0_safe_receiver);
            }

            this.set_state_rjd8d0_k$(1);
            continue $sm;
          case 3:
            return this.destination2__1;
          case 4:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 4) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(selectDoorReplicateEntitiesByTableIdAndPrimaryKeys$slambda).create_hxh3pd_k$ = function (stmt, completion) {
    var i = new selectDoorReplicateEntitiesByTableIdAndPrimaryKeys$slambda(this.$primaryKeysList_1, this.$entityMetaData_1, this.$tableId_1, completion);
    i.stmt_1 = stmt;
    return i;
  };
  protoOf(selectDoorReplicateEntitiesByTableIdAndPrimaryKeys$slambda).create_wyq9v6_k$ = function (value, completion) {
    return this.create_hxh3pd_k$((!(value == null) ? isInterface(value, PreparedStatement) : false) ? value : THROW_CCE(), completion);
  };
  function selectDoorReplicateEntitiesByTableIdAndPrimaryKeys$slambda_0($primaryKeysList, $entityMetaData, $tableId, resultContinuation) {
    var i = new selectDoorReplicateEntitiesByTableIdAndPrimaryKeys$slambda($primaryKeysList, $entityMetaData, $tableId, resultContinuation);
    var l = function (stmt, $completion) {
      return i.invoke_u0nirm_k$(stmt, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function $selectPendingOutgoingReplicationsByDestNodeIdCOROUTINE$11(_this__u8e3s4, nodeId, limit, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
    this.nodeId_1 = nodeId;
    this.limit_1 = limit;
  }
  protoOf($selectPendingOutgoingReplicationsByDestNodeIdCOROUTINE$11).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(5);
            this.set_state_rjd8d0_k$(1);
            suspendResult = prepareAndUseStatementAsync_0(this._this__u8e3s4__1, '\n            SELECT OutgoingReplication.*\n              FROM OutgoingReplication\n             WHERE OutgoingReplication.destNodeId = ?\n          ORDER BY OutgoingReplication.orUid ASC\n             LIMIT ?\n        ', true, selectPendingOutgoingReplicationsByDestNodeId$slambda_0(this.nodeId_1, this.limit_1, null), this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            this.pendingReplications0__1 = suspendResult;
            if (this.pendingReplications0__1.isEmpty_y1axqb_k$())
              return emptyList();
            var tmp_0 = this;
            var this_0 = this.pendingReplications0__1;
            var result = mutableLinkedListOf([]);
            var lastItemKey = null;
            var lastList = null;
            var tmp0_iterator = this_0.iterator_jk1svi_k$();
            while (tmp0_iterator.hasNext_bitz1p_k$()) {
              var item = tmp0_iterator.next_20eer_k$();
              var itemKey = item.get_orTableId_lu6glf_k$();
              if ((!(lastItemKey == null) ? !(lastList == null) : false) ? itemKey === lastItemKey : false) {
                lastList.add_utx5q5_k$(item);
              } else {
                var newList = mutableLinkedListOf([item]);
                result.add_utx5q5_k$(newList);
                lastList = newList;
              }
              lastItemKey = itemKey;
            }

            tmp_0.this1__1 = toList_0(result);
            var tmp_1 = this;
            tmp_1.this2__1 = this.this1__1;
            var tmp_2 = this;
            tmp_2.destination3__1 = ArrayList_init_$Create$_0(collectionSizeOrDefault(this.this1__1, 10));
            this.tmp0_iterator4__1 = this.this2__1.iterator_jk1svi_k$();
            this.set_state_rjd8d0_k$(2);
            continue $sm;
          case 2:
            if (!this.tmp0_iterator4__1.hasNext_bitz1p_k$()) {
              this.set_state_rjd8d0_k$(4);
              continue $sm;
            }

            this.item5__1 = this.tmp0_iterator4__1.next_20eer_k$();
            var tmp_3 = this;
            tmp_3.tableIdPendingList6__1 = this.item5__1;
            this.tableId7__1 = first(this.tableIdPendingList6__1).get_orTableId_lu6glf_k$();
            this.set_state_rjd8d0_k$(3);
            var this_1 = this.pendingReplications0__1;
            var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_1, 10));
            var tmp0_iterator_0 = this_1.iterator_jk1svi_k$();
            while (tmp0_iterator_0.hasNext_bitz1p_k$()) {
              var item_0 = tmp0_iterator_0.next_20eer_k$();
              destination.add_utx5q5_k$(new ReplicateEntityPrimaryKeys(item_0.get_orPk1_iwh40a_k$(), item_0.get_orPk2_iwh40b_k$(), item_0.get_orPk3_iwh40c_k$(), item_0.get_orPk4_iwh40d_k$(), item_0.get_orUid_iwh7pg_k$()));
            }

            suspendResult = selectDoorReplicateEntitiesByTableIdAndPrimaryKeys(this._this__u8e3s4__1, this.tableId7__1, destination, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 3:
            var ARGUMENT = suspendResult;
            this.destination3__1.add_utx5q5_k$(ARGUMENT);
            this.set_state_rjd8d0_k$(2);
            continue $sm;
          case 4:
            var ARGUMENT_0 = this.destination3__1;
            return flatten(ARGUMENT_0);
          case 5:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 5) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  function $insertNewDoorNodeCOROUTINE$12(_this__u8e3s4, node, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
    this.node_1 = node;
  }
  protoOf($insertNewDoorNodeCOROUTINE$12).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            this.set_state_rjd8d0_k$(1);
            suspendResult = prepareAndUseStatementAsync_0(this._this__u8e3s4__1, 'INSERT INTO DoorNode(nodeId, auth, rel) VALUES(?, ?, ?)', VOID, insertNewDoorNode$slambda_0(this.node_1, null), this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            return Unit_getInstance();
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  function $insertEntitiesFromMessageCOROUTINE$13(_this__u8e3s4, message, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
    this.message_1 = message;
  }
  protoOf($insertEntitiesFromMessageCOROUTINE$13).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(9);
            this.dbMetadata0__1 = doorDatabaseMetadata(getKClassFromExpression(this._this__u8e3s4__1));
            this.hasReplicationOpTable1__1 = this.dbMetadata0__1.get_allTables_1jy9x9_k$().contains_aljjnj_k$('ReplicationOperation');
            var tmp_0 = this;
            var this_0 = this.message_1.get_replications_s2xb3k_k$();
            var result = mutableLinkedListOf([]);
            var lastItemKey = null;
            var lastList = null;
            var tmp0_iterator = this_0.iterator_jk1svi_k$();
            while (tmp0_iterator.hasNext_bitz1p_k$()) {
              var item = tmp0_iterator.next_20eer_k$();
              var itemKey = item.get_tableId_of07s0_k$();
              if ((!(lastItemKey == null) ? !(lastList == null) : false) ? itemKey === lastItemKey : false) {
                lastList.add_utx5q5_k$(item);
              } else {
                var newList = mutableLinkedListOf([item]);
                result.add_utx5q5_k$(newList);
                lastList = newList;
              }
              lastItemKey = itemKey;
            }

            tmp_0.this2__1 = toList_0(result);
            this.tmp0_iterator3__1 = this.this2__1.iterator_jk1svi_k$();
            this.set_state_rjd8d0_k$(1);
            continue $sm;
          case 1:
            if (!this.tmp0_iterator3__1.hasNext_bitz1p_k$()) {
              this.set_state_rjd8d0_k$(8);
              continue $sm;
            }

            this.element4__1 = this.tmp0_iterator3__1.next_20eer_k$();
            var tmp_1 = this;
            tmp_1.tableEntities5__1 = this.element4__1;
            this.tableId6__1 = first(this.tableEntities5__1).get_tableId_of07s0_k$();
            this.entityMetaData7__1 = this.dbMetadata0__1.requireReplicateEntityMetaData_9swzku_k$(this.tableId6__1);
            if (this.hasReplicationOpTable1__1) {
              this.set_state_rjd8d0_k$(2);
              suspendResult = prepareAndUseStatementAsync_0(this._this__u8e3s4__1, '\n                    INSERT INTO ReplicationOperation(repOpRemoteNodeId, repOpTableId, repOpStatus)\n                           VALUES(?, ?, ?)\n                    ', false, insertEntitiesFromMessage$slambda_0(this.message_1, this.tableId6__1, null), this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            } else {
              this.set_state_rjd8d0_k$(3);
              continue $sm;
            }

          case 2:
            this.set_state_rjd8d0_k$(3);
            continue $sm;
          case 3:
            if (this.entityMetaData7__1.get_remoteInsertStrategy_t4k5ff_k$().equals(RemoteInsertStrategy_INSERT_INTO_RECEIVE_VIEW_getInstance())) {
              this.set_state_rjd8d0_k$(4);
              var tmp_2 = this.entityMetaData7__1.get_insertIntoReceiveViewSql_vqtvfs_k$();
              suspendResult = prepareAndUseStatementAsync_0(this._this__u8e3s4__1, tmp_2, false, insertEntitiesFromMessage$slambda_2(this.tableEntities5__1, this.entityMetaData7__1, this.message_1, null), this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            } else {
              this.set_state_rjd8d0_k$(5);
              continue $sm;
            }

          case 4:
            this.set_state_rjd8d0_k$(5);
            continue $sm;
          case 5:
            if (this.hasReplicationOpTable1__1) {
              this.set_state_rjd8d0_k$(6);
              suspendResult = prepareAndUseStatementAsync_0(this._this__u8e3s4__1, '\n                    DELETE FROM ReplicationOperation\n                          WHERE repOpRemoteNodeId = ?\n                            AND repOpTableId = ?\n                    ', false, insertEntitiesFromMessage$slambda_4(this.message_1, this.tableId6__1, null), this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            } else {
              this.set_state_rjd8d0_k$(7);
              continue $sm;
            }

          case 6:
            this.set_state_rjd8d0_k$(7);
            continue $sm;
          case 7:
            this.set_state_rjd8d0_k$(1);
            continue $sm;
          case 8:
            return Unit_getInstance();
          case 9:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 9) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  function Companion_11() {
    Companion_instance_11 = this;
  }
  protoOf(Companion_11).serializer_9w0wvi_k$ = function () {
    return $serializer_getInstance_1();
  };
  var Companion_instance_11;
  function Companion_getInstance_14() {
    if (Companion_instance_11 == null)
      new Companion_11();
    return Companion_instance_11;
  }
  function $serializer_1() {
    $serializer_instance_1 = this;
    var tmp0_serialDesc = new PluginGeneratedSerialDescriptor('com.ustadmobile.door.replication.DoorReplicationEntity', this, 3);
    tmp0_serialDesc.addElement_5pzumi_k$('tableId', false);
    tmp0_serialDesc.addElement_5pzumi_k$('orUid', false);
    tmp0_serialDesc.addElement_5pzumi_k$('entity', false);
    this.descriptor_1 = tmp0_serialDesc;
  }
  protoOf($serializer_1).get_descriptor_wjt6a0_k$ = function () {
    return this.descriptor_1;
  };
  protoOf($serializer_1).childSerializers_5ghqw5_k$ = function () {
    // Inline function 'kotlin.arrayOf' call
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    return [IntSerializer_getInstance(), LongSerializer_getInstance(), JsonObjectSerializer_getInstance()];
  };
  protoOf($serializer_1).deserialize_sy6x50_k$ = function (decoder) {
    var tmp0_desc = this.descriptor_1;
    var tmp1_flag = true;
    var tmp2_index = 0;
    var tmp3_bitMask0 = 0;
    var tmp4_local0 = 0;
    var tmp5_local1 = new Long(0, 0);
    var tmp6_local2 = null;
    var tmp7_input = decoder.beginStructure_yljocp_k$(tmp0_desc);
    if (tmp7_input.decodeSequentially_xlblqy_k$()) {
      tmp4_local0 = tmp7_input.decodeIntElement_941u6a_k$(tmp0_desc, 0);
      tmp3_bitMask0 = tmp3_bitMask0 | 1;
      tmp5_local1 = tmp7_input.decodeLongElement_994anb_k$(tmp0_desc, 1);
      tmp3_bitMask0 = tmp3_bitMask0 | 2;
      tmp6_local2 = tmp7_input.decodeSerializableElement_uahnnv_k$(tmp0_desc, 2, JsonObjectSerializer_getInstance(), tmp6_local2);
      tmp3_bitMask0 = tmp3_bitMask0 | 4;
    } else
      while (tmp1_flag) {
        tmp2_index = tmp7_input.decodeElementIndex_bstkhp_k$(tmp0_desc);
        switch (tmp2_index) {
          case -1:
            tmp1_flag = false;
            break;
          case 0:
            tmp4_local0 = tmp7_input.decodeIntElement_941u6a_k$(tmp0_desc, 0);
            tmp3_bitMask0 = tmp3_bitMask0 | 1;
            break;
          case 1:
            tmp5_local1 = tmp7_input.decodeLongElement_994anb_k$(tmp0_desc, 1);
            tmp3_bitMask0 = tmp3_bitMask0 | 2;
            break;
          case 2:
            tmp6_local2 = tmp7_input.decodeSerializableElement_uahnnv_k$(tmp0_desc, 2, JsonObjectSerializer_getInstance(), tmp6_local2);
            tmp3_bitMask0 = tmp3_bitMask0 | 4;
            break;
          default:
            throw UnknownFieldException_init_$Create$(tmp2_index);
        }
      }
    tmp7_input.endStructure_1xqz0n_k$(tmp0_desc);
    return DoorReplicationEntity_init_$Create$(tmp3_bitMask0, tmp4_local0, tmp5_local1, tmp6_local2, null);
  };
  protoOf($serializer_1).serialize_cqtu5e_k$ = function (encoder, value) {
    var tmp0_desc = this.descriptor_1;
    var tmp1_output = encoder.beginStructure_yljocp_k$(tmp0_desc);
    tmp1_output.encodeIntElement_krhhce_k$(tmp0_desc, 0, value.tableId_1);
    tmp1_output.encodeLongElement_cega27_k$(tmp0_desc, 1, value.orUid_1);
    tmp1_output.encodeSerializableElement_isqxcl_k$(tmp0_desc, 2, JsonObjectSerializer_getInstance(), value.entity_1);
    tmp1_output.endStructure_1xqz0n_k$(tmp0_desc);
  };
  protoOf($serializer_1).serialize_5ase3y_k$ = function (encoder, value) {
    return this.serialize_cqtu5e_k$(encoder, value instanceof DoorReplicationEntity ? value : THROW_CCE());
  };
  var $serializer_instance_1;
  function $serializer_getInstance_1() {
    if ($serializer_instance_1 == null)
      new $serializer_1();
    return $serializer_instance_1;
  }
  function DoorReplicationEntity_init_$Init$(seen1, tableId, orUid, entity, serializationConstructorMarker, $this) {
    if (!(7 === (7 & seen1))) {
      throwMissingFieldException(seen1, 7, $serializer_getInstance_1().descriptor_1);
    }
    $this.tableId_1 = tableId;
    $this.orUid_1 = orUid;
    $this.entity_1 = entity;
    return $this;
  }
  function DoorReplicationEntity_init_$Create$(seen1, tableId, orUid, entity, serializationConstructorMarker) {
    return DoorReplicationEntity_init_$Init$(seen1, tableId, orUid, entity, serializationConstructorMarker, objectCreate(protoOf(DoorReplicationEntity)));
  }
  function DoorReplicationEntity(tableId, orUid, entity) {
    Companion_getInstance_14();
    this.tableId_1 = tableId;
    this.orUid_1 = orUid;
    this.entity_1 = entity;
  }
  protoOf(DoorReplicationEntity).get_tableId_of07s0_k$ = function () {
    return this.tableId_1;
  };
  protoOf(DoorReplicationEntity).get_orUid_iwh7pg_k$ = function () {
    return this.orUid_1;
  };
  protoOf(DoorReplicationEntity).get_entity_cxtlv0_k$ = function () {
    return this.entity_1;
  };
  protoOf(DoorReplicationEntity).component1_7eebsc_k$ = function () {
    return this.tableId_1;
  };
  protoOf(DoorReplicationEntity).component2_7eebsb_k$ = function () {
    return this.orUid_1;
  };
  protoOf(DoorReplicationEntity).component3_7eebsa_k$ = function () {
    return this.entity_1;
  };
  protoOf(DoorReplicationEntity).copy_c4k5st_k$ = function (tableId, orUid, entity) {
    return new DoorReplicationEntity(tableId, orUid, entity);
  };
  protoOf(DoorReplicationEntity).copy$default_3geszp_k$ = function (tableId, orUid, entity, $super) {
    tableId = tableId === VOID ? this.tableId_1 : tableId;
    orUid = orUid === VOID ? this.orUid_1 : orUid;
    entity = entity === VOID ? this.entity_1 : entity;
    return $super === VOID ? this.copy_c4k5st_k$(tableId, orUid, entity) : $super.copy_c4k5st_k$.call(this, tableId, orUid, entity);
  };
  protoOf(DoorReplicationEntity).toString = function () {
    return 'DoorReplicationEntity(tableId=' + this.tableId_1 + ', orUid=' + this.orUid_1.toString() + ', entity=' + this.entity_1 + ')';
  };
  protoOf(DoorReplicationEntity).hashCode = function () {
    var result = this.tableId_1;
    result = imul(result, 31) + this.orUid_1.hashCode() | 0;
    result = imul(result, 31) + this.entity_1.hashCode() | 0;
    return result;
  };
  protoOf(DoorReplicationEntity).equals = function (other) {
    if (this === other)
      return true;
    if (!(other instanceof DoorReplicationEntity))
      return false;
    var tmp0_other_with_cast = other instanceof DoorReplicationEntity ? other : THROW_CCE();
    if (!(this.tableId_1 === tmp0_other_with_cast.tableId_1))
      return false;
    if (!this.orUid_1.equals(tmp0_other_with_cast.orUid_1))
      return false;
    if (!this.entity_1.equals(tmp0_other_with_cast.entity_1))
      return false;
    return true;
  };
  function _get_db__ndbzd9($this) {
    return $this.db_1;
  }
  function DoorRepositoryReplicationClient$DefaultOnMarkAcknowledgedAndGetNextOutgoingReplications$invoke$slambda($receivedAck, this$0, $nodeId, $batchSize, resultContinuation) {
    this.$receivedAck_1 = $receivedAck;
    this.this$0__1 = this$0;
    this.$nodeId_1 = $nodeId;
    this.$batchSize_1 = $batchSize;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(DoorRepositoryReplicationClient$DefaultOnMarkAcknowledgedAndGetNextOutgoingReplications$invoke$slambda).invoke_yaliv1_k$ = function (it, $completion) {
    var tmp = this.create_3kxuey_k$(it, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(DoorRepositoryReplicationClient$DefaultOnMarkAcknowledgedAndGetNextOutgoingReplications$invoke$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_yaliv1_k$(p1 instanceof RoomDatabase ? p1 : THROW_CCE(), $completion);
  };
  protoOf(DoorRepositoryReplicationClient$DefaultOnMarkAcknowledgedAndGetNextOutgoingReplications$invoke$slambda).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(4);
            if (!this.$receivedAck_1.get_replicationUids_xbjn4q_k$().isEmpty_y1axqb_k$()) {
              this.set_state_rjd8d0_k$(1);
              suspendResult = acknowledgeReceivedReplications(this.this$0__1.db_1, this.$nodeId_1, this.$receivedAck_1.get_replicationUids_xbjn4q_k$(), this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            } else {
              this.set_state_rjd8d0_k$(2);
              continue $sm;
            }

          case 1:
            this.set_state_rjd8d0_k$(2);
            continue $sm;
          case 2:
            this.set_state_rjd8d0_k$(3);
            suspendResult = selectPendingOutgoingReplicationsByDestNodeId(this.this$0__1.db_1, this.$nodeId_1, this.$batchSize_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 3:
            return suspendResult;
          case 4:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 4) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(DoorRepositoryReplicationClient$DefaultOnMarkAcknowledgedAndGetNextOutgoingReplications$invoke$slambda).create_3kxuey_k$ = function (it, completion) {
    var i = new DoorRepositoryReplicationClient$DefaultOnMarkAcknowledgedAndGetNextOutgoingReplications$invoke$slambda(this.$receivedAck_1, this.this$0__1, this.$nodeId_1, this.$batchSize_1, completion);
    i.it_1 = it;
    return i;
  };
  protoOf(DoorRepositoryReplicationClient$DefaultOnMarkAcknowledgedAndGetNextOutgoingReplications$invoke$slambda).create_wyq9v6_k$ = function (value, completion) {
    return this.create_3kxuey_k$(value instanceof RoomDatabase ? value : THROW_CCE(), completion);
  };
  function DoorRepositoryReplicationClient$DefaultOnMarkAcknowledgedAndGetNextOutgoingReplications$invoke$slambda_0($receivedAck, this$0, $nodeId, $batchSize, resultContinuation) {
    var i = new DoorRepositoryReplicationClient$DefaultOnMarkAcknowledgedAndGetNextOutgoingReplications$invoke$slambda($receivedAck, this$0, $nodeId, $batchSize, resultContinuation);
    var l = function (it, $completion) {
      return i.invoke_yaliv1_k$(it, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function _get_db__ndbzd9_0($this) {
    return $this.db_1;
  }
  function DoorRepositoryReplicationClient$DefaultOnStartPendingSession$invoke$slambda($fakeRemoteNodeId, $endpointUrl, resultContinuation) {
    this.$fakeRemoteNodeId_1 = $fakeRemoteNodeId;
    this.$endpointUrl_1 = $endpointUrl;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(DoorRepositoryReplicationClient$DefaultOnStartPendingSession$invoke$slambda).invoke_n3u1ar_k$ = function (it, $completion) {
    var tmp = this.create_hxh3pd_k$(it, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(DoorRepositoryReplicationClient$DefaultOnStartPendingSession$invoke$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_n3u1ar_k$((!(p1 == null) ? isInterface(p1, PreparedStatement) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(DoorRepositoryReplicationClient$DefaultOnStartPendingSession$invoke$slambda).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            this.it_1.setLong_j1sybo_k$(1, this.$fakeRemoteNodeId_1);
            this.it_1.setString_2gt7ua_k$(2, this.$endpointUrl_1);
            this.set_state_rjd8d0_k$(1);
            suspendResult = executeUpdateAsyncKmp(this.it_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            return suspendResult;
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(DoorRepositoryReplicationClient$DefaultOnStartPendingSession$invoke$slambda).create_hxh3pd_k$ = function (it, completion) {
    var i = new DoorRepositoryReplicationClient$DefaultOnStartPendingSession$invoke$slambda(this.$fakeRemoteNodeId_1, this.$endpointUrl_1, completion);
    i.it_1 = it;
    return i;
  };
  protoOf(DoorRepositoryReplicationClient$DefaultOnStartPendingSession$invoke$slambda).create_wyq9v6_k$ = function (value, completion) {
    return this.create_hxh3pd_k$((!(value == null) ? isInterface(value, PreparedStatement) : false) ? value : THROW_CCE(), completion);
  };
  function DoorRepositoryReplicationClient$DefaultOnStartPendingSession$invoke$slambda_0($fakeRemoteNodeId, $endpointUrl, resultContinuation) {
    var i = new DoorRepositoryReplicationClient$DefaultOnStartPendingSession$invoke$slambda($fakeRemoteNodeId, $endpointUrl, resultContinuation);
    var l = function (it, $completion) {
      return i.invoke_n3u1ar_k$(it, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function $invokeCOROUTINE$14(_this__u8e3s4, fakeRemoteNodeId, endpointUrl, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
    this.fakeRemoteNodeId_1 = fakeRemoteNodeId;
    this.endpointUrl_1 = endpointUrl;
  }
  protoOf($invokeCOROUTINE$14).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            this.set_state_rjd8d0_k$(1);
            suspendResult = prepareAndUseStatementAsync_0(this._this__u8e3s4__1.db_1, '\n                INSERT INTO PendingRepositorySession(remoteNodeId, endpointUrl)\n                            VALUES(?, ?)\n                ', VOID, DoorRepositoryReplicationClient$DefaultOnStartPendingSession$invoke$slambda_0(this.fakeRemoteNodeId_1, this.endpointUrl_1, null), this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            return Unit_getInstance();
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  function DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda$slambda($remoteNodeId, $endpointUrl, resultContinuation) {
    this.$remoteNodeId_1 = $remoteNodeId;
    this.$endpointUrl_1 = $endpointUrl;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda$slambda).invoke_n3u1ar_k$ = function (it, $completion) {
    var tmp = this.create_hxh3pd_k$(it, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_n3u1ar_k$((!(p1 == null) ? isInterface(p1, PreparedStatement) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda$slambda).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            this.it_1.setLong_j1sybo_k$(1, this.$remoteNodeId_1);
            this.it_1.setString_2gt7ua_k$(2, this.$endpointUrl_1);
            this.set_state_rjd8d0_k$(1);
            suspendResult = executeUpdateAsyncKmp(this.it_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            return suspendResult;
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda$slambda).create_hxh3pd_k$ = function (it, completion) {
    var i = new DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda$slambda(this.$remoteNodeId_1, this.$endpointUrl_1, completion);
    i.it_1 = it;
    return i;
  };
  protoOf(DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda$slambda).create_wyq9v6_k$ = function (value, completion) {
    return this.create_hxh3pd_k$((!(value == null) ? isInterface(value, PreparedStatement) : false) ? value : THROW_CCE(), completion);
  };
  function DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda$slambda_0($remoteNodeId, $endpointUrl, resultContinuation) {
    var i = new DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda$slambda($remoteNodeId, $endpointUrl, resultContinuation);
    var l = function (it, $completion) {
      return i.invoke_n3u1ar_k$(it, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda$slambda_1($endpointUrl, resultContinuation) {
    this.$endpointUrl_1 = $endpointUrl;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda$slambda_1).invoke_n3u1ar_k$ = function (it, $completion) {
    var tmp = this.create_hxh3pd_k$(it, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda$slambda_1).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_n3u1ar_k$((!(p1 == null) ? isInterface(p1, PreparedStatement) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda$slambda_1).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            this.it_1.setString_2gt7ua_k$(1, this.$endpointUrl_1);
            this.set_state_rjd8d0_k$(1);
            suspendResult = executeUpdateAsyncKmp(this.it_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            return suspendResult;
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda$slambda_1).create_hxh3pd_k$ = function (it, completion) {
    var i = new DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda$slambda_1(this.$endpointUrl_1, completion);
    i.it_1 = it;
    return i;
  };
  protoOf(DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda$slambda_1).create_wyq9v6_k$ = function (value, completion) {
    return this.create_hxh3pd_k$((!(value == null) ? isInterface(value, PreparedStatement) : false) ? value : THROW_CCE(), completion);
  };
  function DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda$slambda_2($endpointUrl, resultContinuation) {
    var i = new DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda$slambda_1($endpointUrl, resultContinuation);
    var l = function (it, $completion) {
      return i.invoke_n3u1ar_k$(it, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function _get_db__ndbzd9_1($this) {
    return $this.db_1;
  }
  function DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda(this$0, $remoteNodeId, $endpointUrl, resultContinuation) {
    this.this$0__1 = this$0;
    this.$remoteNodeId_1 = $remoteNodeId;
    this.$endpointUrl_1 = $endpointUrl;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda).invoke_e0mr08_k$ = function (it, $completion) {
    var tmp = this.create_3kxuey_k$(it, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_e0mr08_k$(p1 instanceof RoomDatabase ? p1 : THROW_CCE(), $completion);
  };
  protoOf(DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(3);
            this.set_state_rjd8d0_k$(1);
            suspendResult = prepareAndUseStatementAsync_0(this.this$0__1.db_1, '\n                        UPDATE OutgoingReplication\n                           SET destNodeId = ?\n                         WHERE destNodeId IN\n                               (SELECT PendingRepositorySession.remoteNodeId\n                                  FROM PendingRepositorySession\n                                 WHERE endpointUrl = ?)  \n                        ', false, DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda$slambda_0(this.$remoteNodeId_1, this.$endpointUrl_1, null), this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            this.set_state_rjd8d0_k$(2);
            suspendResult = prepareAndUseStatementAsync_0(this.this$0__1.db_1, '\n                        DELETE \n                          FROM PendingRepositorySession\n                         WHERE PendingRepositorySession.endpointUrl = ?\n                        ', false, DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda$slambda_2(this.$endpointUrl_1, null), this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 2:
            return suspendResult;
          case 3:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 3) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda).create_3kxuey_k$ = function (it, completion) {
    var i = new DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda(this.this$0__1, this.$remoteNodeId_1, this.$endpointUrl_1, completion);
    i.it_1 = it;
    return i;
  };
  protoOf(DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda).create_wyq9v6_k$ = function (value, completion) {
    return this.create_3kxuey_k$(value instanceof RoomDatabase ? value : THROW_CCE(), completion);
  };
  function DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda_0(this$0, $remoteNodeId, $endpointUrl, resultContinuation) {
    var i = new DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda(this$0, $remoteNodeId, $endpointUrl, resultContinuation);
    var l = function (it, $completion) {
      return i.invoke_e0mr08_k$(it, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function $invokeCOROUTINE$15(_this__u8e3s4, remoteNodeId, endpointUrl, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
    this.remoteNodeId_1 = remoteNodeId;
    this.endpointUrl_1 = endpointUrl;
  }
  protoOf($invokeCOROUTINE$15).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            this.set_state_rjd8d0_k$(1);
            suspendResult = withDoorTransactionAsync(this._this__u8e3s4__1.db_1, VOID, DoorRepositoryReplicationClient$DefaultOnPendingSessionResolved$invoke$slambda_0(this._this__u8e3s4__1, this.remoteNodeId_1, this.endpointUrl_1, null), this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            return Unit_getInstance();
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  function DoorRepositoryReplicationClient$slambda$lambda(this$0) {
    return function () {
      return this$0.logPrefix_1 + ' getRemoteNodeId : requesting node id of server';
    };
  }
  function DoorRepositoryReplicationClient$slambda$lambda_0(this$0, $remoteNodeIdResponse, $nodeIdHeaderVal) {
    return function () {
      return this$0.logPrefix_1 + ' getRemoteNodeId : got server node id: status=' + $remoteNodeIdResponse.get_status_jnf6d7_k$() + ' ' + toString_0($nodeIdHeaderVal);
    };
  }
  function DoorRepositoryReplicationClient$slambda$lambda_1(this$0) {
    return function () {
      return this$0.logPrefix_1 + ' getRemoteNodeId : exception getting remote node id';
    };
  }
  function DoorRepositoryReplicationClient$slambda$slambda$slambda($remoteNodeIdVal, this$0, resultContinuation) {
    this.$remoteNodeIdVal_1 = $remoteNodeIdVal;
    this.this$0__1 = this$0;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(DoorRepositoryReplicationClient$slambda$slambda$slambda).invoke_l1b4fx_k$ = function (events, $completion) {
    var tmp = this.create_2c4j9d_k$(events, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(DoorRepositoryReplicationClient$slambda$slambda$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_l1b4fx_k$((!(p1 == null) ? isInterface(p1, List) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(DoorRepositoryReplicationClient$slambda$slambda$slambda).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        if (tmp === 0) {
          this.set_exceptionState_fex74n_k$(1);
          var tmp$ret$0;
          l$ret$1: do {
            var this_0 = this.events_1;
            var tmp_0;
            if (isInterface(this_0, Collection)) {
              tmp_0 = this_0.isEmpty_y1axqb_k$();
            } else {
              tmp_0 = false;
            }
            if (tmp_0) {
              tmp$ret$0 = false;
              break l$ret$1;
            }
            var tmp0_iterator = this_0.iterator_jk1svi_k$();
            while (tmp0_iterator.hasNext_bitz1p_k$()) {
              var element = tmp0_iterator.next_20eer_k$();
              if (element.get_toNode_k1dkx2_k$().equals(this.$remoteNodeIdVal_1) ? element.get_what_wowufh_k$() === Companion_getInstance_13().get_WHAT_REPLICATION_PUSH_tr3xkv_k$() : false) {
                tmp$ret$0 = true;
                break l$ret$1;
              }
            }
            tmp$ret$0 = false;
          }
           while (false);
          if (tmp$ret$0) {
            this.this$0__1.sendNotifyChannel_1.trySend_62dpg8_k$(Unit_getInstance());
          }
          return Unit_getInstance();
        } else if (tmp === 1) {
          throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        throw e;
      }
     while (true);
  };
  protoOf(DoorRepositoryReplicationClient$slambda$slambda$slambda).create_2c4j9d_k$ = function (events, completion) {
    var i = new DoorRepositoryReplicationClient$slambda$slambda$slambda(this.$remoteNodeIdVal_1, this.this$0__1, completion);
    i.events_1 = events;
    return i;
  };
  protoOf(DoorRepositoryReplicationClient$slambda$slambda$slambda).create_wyq9v6_k$ = function (value, completion) {
    return this.create_2c4j9d_k$((!(value == null) ? isInterface(value, List) : false) ? value : THROW_CCE(), completion);
  };
  function DoorRepositoryReplicationClient$slambda$slambda$slambda_0($remoteNodeIdVal, this$0, resultContinuation) {
    var i = new DoorRepositoryReplicationClient$slambda$slambda$slambda($remoteNodeIdVal, this$0, resultContinuation);
    var l = function (events, $completion) {
      return i.invoke_l1b4fx_k$(events, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function DoorRepositoryReplicationClient$slambda$slambda$slambda_1($remoteNodeIdVal, this$0, resultContinuation) {
    this.$remoteNodeIdVal_1 = $remoteNodeIdVal;
    this.this$0__1 = this$0;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(DoorRepositoryReplicationClient$slambda$slambda$slambda_1).invoke_1inq8d_k$ = function (message, $completion) {
    var tmp = this.create_g8ln41_k$(message, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(DoorRepositoryReplicationClient$slambda$slambda$slambda_1).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_1inq8d_k$(p1 instanceof DoorMessage ? p1 : THROW_CCE(), $completion);
  };
  protoOf(DoorRepositoryReplicationClient$slambda$slambda$slambda_1).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        if (tmp === 0) {
          this.set_exceptionState_fex74n_k$(1);
          if (this.message_1.get_fromNode_in16s5_k$().equals(this.$remoteNodeIdVal_1) ? this.message_1.get_what_wowufh_k$() === Companion_getInstance_13().get_WHAT_REPLICATION_PUSH_tr3xkv_k$() : false) {
            this.this$0__1.fetchNotifyChannel_1.trySend_62dpg8_k$(Unit_getInstance());
          }
          return Unit_getInstance();
        } else if (tmp === 1) {
          throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        throw e;
      }
     while (true);
  };
  protoOf(DoorRepositoryReplicationClient$slambda$slambda$slambda_1).create_g8ln41_k$ = function (message, completion) {
    var i = new DoorRepositoryReplicationClient$slambda$slambda$slambda_1(this.$remoteNodeIdVal_1, this.this$0__1, completion);
    i.message_1 = message;
    return i;
  };
  protoOf(DoorRepositoryReplicationClient$slambda$slambda$slambda_1).create_wyq9v6_k$ = function (value, completion) {
    return this.create_g8ln41_k$(value instanceof DoorMessage ? value : THROW_CCE(), completion);
  };
  function DoorRepositoryReplicationClient$slambda$slambda$slambda_2($remoteNodeIdVal, this$0, resultContinuation) {
    var i = new DoorRepositoryReplicationClient$slambda$slambda$slambda_1($remoteNodeIdVal, this$0, resultContinuation);
    var l = function (message, $completion) {
      return i.invoke_1inq8d_k$(message, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function DoorRepositoryReplicationClient$slambda$slambda(this$0, $remoteNodeIdVal, resultContinuation) {
    this.this$0__1 = this$0;
    this.$remoteNodeIdVal_1 = $remoteNodeIdVal;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(DoorRepositoryReplicationClient$slambda$slambda).invoke_d9fzmj_k$ = function ($this$launch, $completion) {
    var tmp = this.create_rcuf4x_k$($this$launch, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(DoorRepositoryReplicationClient$slambda$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_d9fzmj_k$((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(DoorRepositoryReplicationClient$slambda$slambda).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            this.set_state_rjd8d0_k$(1);
            var tmp_0 = this.this$0__1.nodeEventManager_1.get_outgoingEvents_40o3ma_k$();
            var tmp_1 = DoorRepositoryReplicationClient$slambda$slambda$slambda_0(this.$remoteNodeIdVal_1, this.this$0__1, null);
            suspendResult = tmp_0.collect_aksokr_k$(new sam$kotlinx_coroutines_flow_FlowCollector$0(tmp_1), this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            return Unit_getInstance();
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(DoorRepositoryReplicationClient$slambda$slambda).create_rcuf4x_k$ = function ($this$launch, completion) {
    var i = new DoorRepositoryReplicationClient$slambda$slambda(this.this$0__1, this.$remoteNodeIdVal_1, completion);
    i.$this$launch_1 = $this$launch;
    return i;
  };
  protoOf(DoorRepositoryReplicationClient$slambda$slambda).create_wyq9v6_k$ = function (value, completion) {
    return this.create_rcuf4x_k$((!(value == null) ? isInterface(value, CoroutineScope) : false) ? value : THROW_CCE(), completion);
  };
  function DoorRepositoryReplicationClient$slambda$slambda_0(this$0, $remoteNodeIdVal, resultContinuation) {
    var i = new DoorRepositoryReplicationClient$slambda$slambda(this$0, $remoteNodeIdVal, resultContinuation);
    var l = function ($this$launch, $completion) {
      return i.invoke_d9fzmj_k$($this$launch, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function DoorRepositoryReplicationClient$slambda$slambda_1(this$0, $remoteNodeIdVal, resultContinuation) {
    this.this$0__1 = this$0;
    this.$remoteNodeIdVal_1 = $remoteNodeIdVal;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(DoorRepositoryReplicationClient$slambda$slambda_1).invoke_d9fzmj_k$ = function ($this$launch, $completion) {
    var tmp = this.create_rcuf4x_k$($this$launch, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(DoorRepositoryReplicationClient$slambda$slambda_1).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_d9fzmj_k$((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(DoorRepositoryReplicationClient$slambda$slambda_1).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            this.set_state_rjd8d0_k$(1);
            var tmp_0 = this.this$0__1.nodeEventManager_1.get_incomingMessages_7rqqu3_k$();
            var tmp_1 = DoorRepositoryReplicationClient$slambda$slambda$slambda_2(this.$remoteNodeIdVal_1, this.this$0__1, null);
            suspendResult = tmp_0.collect_aksokr_k$(new sam$kotlinx_coroutines_flow_FlowCollector$0(tmp_1), this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            return Unit_getInstance();
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(DoorRepositoryReplicationClient$slambda$slambda_1).create_rcuf4x_k$ = function ($this$launch, completion) {
    var i = new DoorRepositoryReplicationClient$slambda$slambda_1(this.this$0__1, this.$remoteNodeIdVal_1, completion);
    i.$this$launch_1 = $this$launch;
    return i;
  };
  protoOf(DoorRepositoryReplicationClient$slambda$slambda_1).create_wyq9v6_k$ = function (value, completion) {
    return this.create_rcuf4x_k$((!(value == null) ? isInterface(value, CoroutineScope) : false) ? value : THROW_CCE(), completion);
  };
  function DoorRepositoryReplicationClient$slambda$slambda_2(this$0, $remoteNodeIdVal, resultContinuation) {
    var i = new DoorRepositoryReplicationClient$slambda$slambda_1(this$0, $remoteNodeIdVal, resultContinuation);
    var l = function ($this$launch, $completion) {
      return i.invoke_d9fzmj_k$($this$launch, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function _get_localNodeId__wdvgqf($this) {
    return $this.localNodeId_1;
  }
  function _get_localNodeAuth__axnzdw($this) {
    return $this.localNodeAuth_1;
  }
  function _get_httpClient__2ty1zc($this) {
    return $this.httpClient_1;
  }
  function _get_json__d8whur($this) {
    return $this.json_1;
  }
  function _get_repoEndpointUrl__yiipiv($this) {
    return $this.repoEndpointUrl_1;
  }
  function _get_nodeEventManager__cjqgt2($this) {
    return $this.nodeEventManager_1;
  }
  function _get_onMarkAcknowledgedAndGetNextOutgoingReplications__qnv76($this) {
    return $this.onMarkAcknowledgedAndGetNextOutgoingReplications_1;
  }
  function _get_onStartPendingSession__5e0hox($this) {
    return $this.onStartPendingSession_1;
  }
  function _get_onPendingSessionResolved__pnhor($this) {
    return $this.onPendingSessionResolved_1;
  }
  function _get_logger__rkp4sl($this) {
    return $this.logger_1;
  }
  function _get_dbName__9h2wvy($this) {
    return $this.dbName_1;
  }
  function _get_retryInterval__pgfiu4($this) {
    return $this.retryInterval_1;
  }
  function ClientState(initialized) {
    initialized = initialized === VOID ? false : initialized;
    this.initialized_1 = initialized;
  }
  protoOf(ClientState).get_initialized_yawktn_k$ = function () {
    return this.initialized_1;
  };
  protoOf(ClientState).component1_7eebsc_k$ = function () {
    return this.initialized_1;
  };
  protoOf(ClientState).copy_o18wmo_k$ = function (initialized) {
    return new ClientState(initialized);
  };
  protoOf(ClientState).copy$default_inuduc_k$ = function (initialized, $super) {
    initialized = initialized === VOID ? this.initialized_1 : initialized;
    return $super === VOID ? this.copy_o18wmo_k$(initialized) : $super.copy_o18wmo_k$.call(this, initialized);
  };
  protoOf(ClientState).toString = function () {
    return 'ClientState(initialized=' + this.initialized_1 + ')';
  };
  protoOf(ClientState).hashCode = function () {
    return getBooleanHashCode(this.initialized_1);
  };
  protoOf(ClientState).equals = function (other) {
    if (this === other)
      return true;
    if (!(other instanceof ClientState))
      return false;
    var tmp0_other_with_cast = other instanceof ClientState ? other : THROW_CCE();
    if (!(this.initialized_1 === tmp0_other_with_cast.initialized_1))
      return false;
    return true;
  };
  function DoorRepositoryReplicationClient_init_$Init$(db, repositoryConfig, scope, nodeEventManager, retryInterval, $this) {
    DoorRepositoryReplicationClient.call($this, get_doorWrapperNodeId(db), repositoryConfig.get_auth_woj2sx_k$(), repositoryConfig.get_httpClient_cdum84_k$(), repositoryConfig.get_json_woos35_k$(), repositoryConfig.get_endpoint_30bvdu_k$(), scope, nodeEventManager, new DefaultOnMarkAcknowledgedAndGetNextOutgoingReplications(db), new DefaultOnStartPendingSession(db), new DefaultOnPendingSessionResolved(db), repositoryConfig.get_logger_g9gejd_k$(), repositoryConfig.get_dbName_c9i0qa_k$(), retryInterval);
    return $this;
  }
  function DoorRepositoryReplicationClient_init_$Create$(db, repositoryConfig, scope, nodeEventManager, retryInterval) {
    return DoorRepositoryReplicationClient_init_$Init$(db, repositoryConfig, scope, nodeEventManager, retryInterval, objectCreate(protoOf(DoorRepositoryReplicationClient)));
  }
  function _get_logPrefix__aovpcr($this) {
    return $this.logPrefix_1;
  }
  function _get__state__37adl3($this) {
    return $this._state_1;
  }
  function _get_fakeRemoteNodeId__du958t($this) {
    return $this.fakeRemoteNodeId_1;
  }
  function OnMarkAcknowledgedAndGetNextOutgoingReplications() {
  }
  function DefaultOnMarkAcknowledgedAndGetNextOutgoingReplications(db) {
    this.db_1 = db;
  }
  protoOf(DefaultOnMarkAcknowledgedAndGetNextOutgoingReplications).invoke_1uc1uk_k$ = function (nodeId, receivedAck, batchSize, $completion) {
    return withDoorTransactionAsync(this.db_1, VOID, DoorRepositoryReplicationClient$DefaultOnMarkAcknowledgedAndGetNextOutgoingReplications$invoke$slambda_0(receivedAck, this, nodeId, batchSize, null), $completion);
  };
  function OnStartPendingSession() {
  }
  function DefaultOnStartPendingSession(db) {
    this.db_1 = db;
  }
  protoOf(DefaultOnStartPendingSession).invoke_j6nxkd_k$ = function (fakeRemoteNodeId, endpointUrl, $completion) {
    var tmp = new $invokeCOROUTINE$14(this, fakeRemoteNodeId, endpointUrl, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  function OnPendingSessionResolved() {
  }
  function DefaultOnPendingSessionResolved(db) {
    this.db_1 = db;
  }
  protoOf(DefaultOnPendingSessionResolved).invoke_j6nxkd_k$ = function (remoteNodeId, endpointUrl, $completion) {
    var tmp = new $invokeCOROUTINE$15(this, remoteNodeId, endpointUrl, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  function _get_fetchPendingReplicationsJob__pcnbh4($this) {
    return $this.fetchPendingReplicationsJob_1;
  }
  function _get_sendPendingReplicationsJob__k1i0fw($this) {
    return $this.sendPendingReplicationsJob_1;
  }
  function _get_collectEventsJob__bpge29($this) {
    return $this.collectEventsJob_1;
  }
  function _get_fetchNotifyChannel__hnx7x1($this) {
    return $this.fetchNotifyChannel_1;
  }
  function _get_sendNotifyChannel__l8h8sf($this) {
    return $this.sendNotifyChannel_1;
  }
  function _get_batchSize__q8zwru($this) {
    return $this.batchSize_1;
  }
  function _get_remoteNodeId__vu8wl4($this) {
    return $this.remoteNodeId_1;
  }
  function runSendLoop(_this__u8e3s4, $this, $completion) {
    var tmp = new $runSendLoopCOROUTINE$16($this, _this__u8e3s4, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  }
  function runFetchLoop(_this__u8e3s4, $this, $completion) {
    var tmp = new $runFetchLoopCOROUTINE$17($this, _this__u8e3s4, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  }
  function Companion_12() {
    Companion_instance_12 = this;
    this.REPLICATION_PATH_1 = 'replication';
  }
  protoOf(Companion_12).get_REPLICATION_PATH_xbptnj_k$ = function () {
    return this.REPLICATION_PATH_1;
  };
  var Companion_instance_12;
  function Companion_getInstance_15() {
    if (Companion_instance_12 == null)
      new Companion_12();
    return Companion_instance_12;
  }
  function sam$kotlinx_coroutines_flow_FlowCollector$0(function_0) {
    this.function_1 = function_0;
  }
  protoOf(sam$kotlinx_coroutines_flow_FlowCollector$0).emit_t92u1f_k$ = function (value, $completion) {
    return this.function_1(value, $completion);
  };
  function DoorRepositoryReplicationClient$slambda(this$0, resultContinuation) {
    this.this$0__1 = this$0;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(DoorRepositoryReplicationClient$slambda).invoke_d9fzmj_k$ = function ($this$launch, $completion) {
    var tmp = this.create_rcuf4x_k$($this$launch, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(DoorRepositoryReplicationClient$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_d9fzmj_k$((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(DoorRepositoryReplicationClient$slambda).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(10);
            this.set_state_rjd8d0_k$(1);
            continue $sm;
          case 1:
            if (!(get_isActive(this.$this$launch_1) ? !this.this$0__1.remoteNodeId_1.get_isCompleted_a6j6c8_k$() : false)) {
              this.set_state_rjd8d0_k$(11);
              continue $sm;
            }

            this.set_exceptionState_fex74n_k$(6);
            this.set_state_rjd8d0_k$(2);
            suspendResult = this.this$0__1.onStartPendingSession_1.invoke_j6nxkd_k$(this.this$0__1.fakeRemoteNodeId_1, this.this$0__1.repoEndpointUrl_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 2:
            v(this.this$0__1.logger_1, VOID, DoorRepositoryReplicationClient$slambda$lambda(this.this$0__1));
            var tmp_0 = this;
            tmp_0.this0__1 = this.this$0__1.httpClient_1;
            var tmp_1 = this;
            tmp_1.this1__1 = this.this0__1;
            var tmp_2 = this;
            var this_0 = new HttpRequestBuilder();
            doorNodeIdHeader_0(this_0, this.this$0__1.localNodeId_1, this.this$0__1.localNodeAuth_1);
            setRepoUrl(this_0, this.this$0__1.repoEndpointUrl_1, 'replication/nodeId');
            tmp_2.builder2__1 = this_0;
            this.builder2__1.set_method_hoo95u_k$(Companion_getInstance().get_Get_18jsxf_k$());
            var tmp_3 = this;
            tmp_3.this3__1 = this.this1__1;
            var tmp_4 = this;
            tmp_4.builder4__1 = this.builder2__1;
            this.set_state_rjd8d0_k$(3);
            suspendResult = (new HttpStatement(this.builder4__1, this.this3__1)).execute_rsj18j_k$(this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 3:
            this.remoteNodeIdResponse5__1 = suspendResult;
            var tmp_5 = this;
            var tmp0_safe_receiver = this.remoteNodeIdResponse5__1.get_headers_ef25jx_k$().get_6bo4tg_k$(DoorConstants_getInstance().get_HEADER_NODE_ID_n9vw0f_k$());
            tmp_5.nodeIdHeaderVal6__1 = tmp0_safe_receiver == null ? null : toLong_0(tmp0_safe_receiver);
            v(this.this$0__1.logger_1, VOID, DoorRepositoryReplicationClient$slambda$lambda_0(this.this$0__1, this.remoteNodeIdResponse5__1, this.nodeIdHeaderVal6__1));
            if (!(this.nodeIdHeaderVal6__1 == null)) {
              this.this$0__1.remoteNodeId_1.complete_ixf84q_k$(this.nodeIdHeaderVal6__1);
              this.set_state_rjd8d0_k$(4);
              suspendResult = this.this$0__1.onPendingSessionResolved_1.invoke_j6nxkd_k$(this.nodeIdHeaderVal6__1, this.this$0__1.repoEndpointUrl_1, this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            } else {
              throw IllegalStateException_init_$Create$(this.this$0__1.logPrefix_1 + ' getRemoteNodeId : server did not provide node id');
            }

          case 4:
            l$ret$1: do {
              var this_1 = this.this$0__1._state_1;
              while (true) {
                var prevValue = this_1.get_value_j01efc_k$();
                var nextValue = prevValue.copy_o18wmo_k$(true);
                if (this_1.compareAndSet_l3595a_k$(prevValue, nextValue)) {
                  break l$ret$1;
                }
              }
            }
             while (false);
            this.set_state_rjd8d0_k$(5);
            continue $sm;
          case 5:
            this.set_exceptionState_fex74n_k$(10);
            this.set_state_rjd8d0_k$(9);
            continue $sm;
          case 6:
            this.set_exceptionState_fex74n_k$(10);
            var tmp_6 = this.get_exception_x0n6w6_k$();
            if (tmp_6 instanceof Exception) {
              this.e7__1 = this.get_exception_x0n6w6_k$();
              var tmp_7 = this.e7__1;
              if (!(tmp_7 instanceof CancellationException)) {
                w(this.this$0__1.logger_1, this.e7__1, DoorRepositoryReplicationClient$slambda$lambda_1(this.this$0__1));
                this.set_state_rjd8d0_k$(7);
                suspendResult = delay(toLong(this.this$0__1.retryInterval_1), this);
                if (suspendResult === get_COROUTINE_SUSPENDED()) {
                  return suspendResult;
                }
                continue $sm;
              } else {
                this.set_state_rjd8d0_k$(8);
                continue $sm;
              }
            } else {
              throw this.get_exception_x0n6w6_k$();
            }

          case 7:
            this.set_state_rjd8d0_k$(8);
            continue $sm;
          case 8:
            this.set_state_rjd8d0_k$(9);
            continue $sm;
          case 9:
            this.set_exceptionState_fex74n_k$(10);
            this.set_state_rjd8d0_k$(1);
            continue $sm;
          case 10:
            throw this.get_exception_x0n6w6_k$();
          case 11:
            return Unit_getInstance();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 10) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(DoorRepositoryReplicationClient$slambda).create_rcuf4x_k$ = function ($this$launch, completion) {
    var i = new DoorRepositoryReplicationClient$slambda(this.this$0__1, completion);
    i.$this$launch_1 = $this$launch;
    return i;
  };
  protoOf(DoorRepositoryReplicationClient$slambda).create_wyq9v6_k$ = function (value, completion) {
    return this.create_rcuf4x_k$((!(value == null) ? isInterface(value, CoroutineScope) : false) ? value : THROW_CCE(), completion);
  };
  function DoorRepositoryReplicationClient$slambda_0(this$0, resultContinuation) {
    var i = new DoorRepositoryReplicationClient$slambda(this$0, resultContinuation);
    var l = function ($this$launch, $completion) {
      return i.invoke_d9fzmj_k$($this$launch, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function DoorRepositoryReplicationClient$slambda_1(this$0, resultContinuation) {
    this.this$0__1 = this$0;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(DoorRepositoryReplicationClient$slambda_1).invoke_d9fzmj_k$ = function ($this$launch, $completion) {
    var tmp = this.create_rcuf4x_k$($this$launch, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(DoorRepositoryReplicationClient$slambda_1).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_d9fzmj_k$((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(DoorRepositoryReplicationClient$slambda_1).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            this.set_state_rjd8d0_k$(1);
            suspendResult = runFetchLoop(this.$this$launch_1, this.this$0__1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            return Unit_getInstance();
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(DoorRepositoryReplicationClient$slambda_1).create_rcuf4x_k$ = function ($this$launch, completion) {
    var i = new DoorRepositoryReplicationClient$slambda_1(this.this$0__1, completion);
    i.$this$launch_1 = $this$launch;
    return i;
  };
  protoOf(DoorRepositoryReplicationClient$slambda_1).create_wyq9v6_k$ = function (value, completion) {
    return this.create_rcuf4x_k$((!(value == null) ? isInterface(value, CoroutineScope) : false) ? value : THROW_CCE(), completion);
  };
  function DoorRepositoryReplicationClient$slambda_2(this$0, resultContinuation) {
    var i = new DoorRepositoryReplicationClient$slambda_1(this$0, resultContinuation);
    var l = function ($this$launch, $completion) {
      return i.invoke_d9fzmj_k$($this$launch, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function DoorRepositoryReplicationClient$slambda_3(this$0, resultContinuation) {
    this.this$0__1 = this$0;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(DoorRepositoryReplicationClient$slambda_3).invoke_d9fzmj_k$ = function ($this$launch, $completion) {
    var tmp = this.create_rcuf4x_k$($this$launch, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(DoorRepositoryReplicationClient$slambda_3).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_d9fzmj_k$((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(DoorRepositoryReplicationClient$slambda_3).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            this.set_state_rjd8d0_k$(1);
            suspendResult = runSendLoop(this.$this$launch_1, this.this$0__1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            return Unit_getInstance();
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(DoorRepositoryReplicationClient$slambda_3).create_rcuf4x_k$ = function ($this$launch, completion) {
    var i = new DoorRepositoryReplicationClient$slambda_3(this.this$0__1, completion);
    i.$this$launch_1 = $this$launch;
    return i;
  };
  protoOf(DoorRepositoryReplicationClient$slambda_3).create_wyq9v6_k$ = function (value, completion) {
    return this.create_rcuf4x_k$((!(value == null) ? isInterface(value, CoroutineScope) : false) ? value : THROW_CCE(), completion);
  };
  function DoorRepositoryReplicationClient$slambda_4(this$0, resultContinuation) {
    var i = new DoorRepositoryReplicationClient$slambda_3(this$0, resultContinuation);
    var l = function ($this$launch, $completion) {
      return i.invoke_d9fzmj_k$($this$launch, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function DoorRepositoryReplicationClient$slambda_5(this$0, resultContinuation) {
    this.this$0__1 = this$0;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(DoorRepositoryReplicationClient$slambda_5).invoke_d9fzmj_k$ = function ($this$launch, $completion) {
    var tmp = this.create_rcuf4x_k$($this$launch, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(DoorRepositoryReplicationClient$slambda_5).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_d9fzmj_k$((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(DoorRepositoryReplicationClient$slambda_5).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            this.set_state_rjd8d0_k$(1);
            suspendResult = this.this$0__1.remoteNodeId_1.await_4rdzbx_k$(this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            var remoteNodeIdVal = suspendResult;
            launch(this.$this$launch_1, VOID, VOID, DoorRepositoryReplicationClient$slambda$slambda_0(this.this$0__1, remoteNodeIdVal, null));
            launch(this.$this$launch_1, VOID, VOID, DoorRepositoryReplicationClient$slambda$slambda_2(this.this$0__1, remoteNodeIdVal, null));
            return Unit_getInstance();
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(DoorRepositoryReplicationClient$slambda_5).create_rcuf4x_k$ = function ($this$launch, completion) {
    var i = new DoorRepositoryReplicationClient$slambda_5(this.this$0__1, completion);
    i.$this$launch_1 = $this$launch;
    return i;
  };
  protoOf(DoorRepositoryReplicationClient$slambda_5).create_wyq9v6_k$ = function (value, completion) {
    return this.create_rcuf4x_k$((!(value == null) ? isInterface(value, CoroutineScope) : false) ? value : THROW_CCE(), completion);
  };
  function DoorRepositoryReplicationClient$slambda_6(this$0, resultContinuation) {
    var i = new DoorRepositoryReplicationClient$slambda_5(this$0, resultContinuation);
    var l = function ($this$launch, $completion) {
      return i.invoke_d9fzmj_k$($this$launch, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function DoorRepositoryReplicationClient$runSendLoop$lambda(this$0, $outgoingReplicationsToAck) {
    return function () {
      return this$0.logPrefix_1 + ' : runSendLoop : querying db to mark ' + $outgoingReplicationsToAck.get_size_woubt6_k$() + ' entities as ' + 'acknowledged by server and get next batch of replications to send';
    };
  }
  function DoorRepositoryReplicationClient$runSendLoop$lambda_0(this$0, $outgoingReplications) {
    return function () {
      return this$0.logPrefix_1 + ' : runSendLoop : found ' + $outgoingReplications.get_size_woubt6_k$() + ' pending outgoing replications ' + 'to send';
    };
  }
  function DoorRepositoryReplicationClient$runSendLoop$lambda_1(this$0, $outgoingReplications) {
    return function () {
      return this$0.logPrefix_1 + ' : runSendLoop : sending ' + $outgoingReplications.get_size_woubt6_k$() + ' to server ';
    };
  }
  function DoorRepositoryReplicationClient$runSendLoop$lambda_2(this$0, $replicationResponse, $replicationReceivedAck) {
    return function () {
      return this$0.logPrefix_1 + ' : runSendLoop : received reply from server status= ' + $replicationResponse.get_status_jnf6d7_k$() + ' ' + (' acknowledges ' + $replicationReceivedAck.get_replicationUids_xbjn4q_k$().get_size_woubt6_k$() + ' entities');
    };
  }
  function DoorRepositoryReplicationClient$runSendLoop$lambda_3(this$0) {
    return function () {
      return this$0.logPrefix_1 + ' exception sending outgoing replications';
    };
  }
  function DoorRepositoryReplicationClient$runFetchLoop$lambda(this$0, $acknowledgementsToSend) {
    return function () {
      return this$0.logPrefix_1 + ' : runFetchLoop: acknowledging ' + $acknowledgementsToSend.get_size_woubt6_k$() + ' entities received and ' + 'request next batch of pending replications';
    };
  }
  function DoorRepositoryReplicationClient$runFetchLoop$lambda_0(this$0, $entitiesReceivedResponse) {
    return function () {
      return this$0.logPrefix_1 + ' : runFetchLoop: received response status = ' + $entitiesReceivedResponse.get_status_jnf6d7_k$();
    };
  }
  function DoorRepositoryReplicationClient$runFetchLoop$lambda_1(this$0, $entitiesReceivedMessage) {
    return function () {
      return this$0.logPrefix_1 + ' : runFetchLoop: received ' + $entitiesReceivedMessage.get_replications_s2xb3k_k$().get_size_woubt6_k$() + ' replications incoming';
    };
  }
  function DoorRepositoryReplicationClient$runFetchLoop$lambda_2(this$0, $entitiesReceivedMessage) {
    return function () {
      return this$0.logPrefix_1 + ' : runFetchLoop: delivered ' + $entitiesReceivedMessage.get_replications_s2xb3k_k$().get_size_woubt6_k$() + ' replications to node event manager';
    };
  }
  function DoorRepositoryReplicationClient$runFetchLoop$lambda_3($e) {
    return function () {
      return 'DoorRepositoryReplicationClient: : runFetchLoop: exception (probably offline): ' + $e;
    };
  }
  function $runSendLoopCOROUTINE$16(_this__u8e3s4, _this__u8e3s4_0, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
    this._this__u8e3s4__2 = _this__u8e3s4_0;
  }
  protoOf($runSendLoopCOROUTINE$16).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(14);
            this.set_state_rjd8d0_k$(1);
            suspendResult = this._this__u8e3s4__1.remoteNodeId_1.await_4rdzbx_k$(this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            this.remoteNodeIdVal0__1 = suspendResult;
            var tmp_0 = this;
            tmp_0.outgoingReplicationsToAck1__1 = ArrayList_init_$Create$();
            this.set_state_rjd8d0_k$(2);
            continue $sm;
          case 2:
            if (!get_isActive(this._this__u8e3s4__2)) {
              this.set_state_rjd8d0_k$(13);
              continue $sm;
            }

            this.set_exceptionState_fex74n_k$(9);
            if (this.outgoingReplicationsToAck1__1.isEmpty_y1axqb_k$()) {
              this.set_state_rjd8d0_k$(3);
              suspendResult = this._this__u8e3s4__1.sendNotifyChannel_1.receive_awoumx_k$(this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            } else {
              this.set_state_rjd8d0_k$(4);
              continue $sm;
            }

          case 3:
            this.set_state_rjd8d0_k$(4);
            continue $sm;
          case 4:
            v(this._this__u8e3s4__1.logger_1, VOID, DoorRepositoryReplicationClient$runSendLoop$lambda(this._this__u8e3s4__1, this.outgoingReplicationsToAck1__1));
            this.set_state_rjd8d0_k$(5);
            suspendResult = this._this__u8e3s4__1.onMarkAcknowledgedAndGetNextOutgoingReplications_1.invoke_1uc1uk_k$(this.remoteNodeIdVal0__1, new ReplicationReceivedAck(this.outgoingReplicationsToAck1__1), this._this__u8e3s4__1.batchSize_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 5:
            this.outgoingReplications2__1 = suspendResult;
            v(this._this__u8e3s4__1.logger_1, VOID, DoorRepositoryReplicationClient$runSendLoop$lambda_0(this._this__u8e3s4__1, this.outgoingReplications2__1));
            this.outgoingReplicationsToAck1__1.clear_j9egeb_k$();
            if (!this.outgoingReplications2__1.isEmpty_y1axqb_k$()) {
              v(this._this__u8e3s4__1.logger_1, VOID, DoorRepositoryReplicationClient$runSendLoop$lambda_1(this._this__u8e3s4__1, this.outgoingReplications2__1));
              var tmp_1 = this;
              tmp_1.this3__1 = this._this__u8e3s4__1.httpClient_1;
              var tmp_2 = this;
              tmp_2.this4__1 = this.this3__1;
              var tmp_3 = this;
              var this_0 = new HttpRequestBuilder();
              setRepoUrl(this_0, this._this__u8e3s4__1.repoEndpointUrl_1, 'replication/message');
              doorNodeIdHeader_0(this_0, this._this__u8e3s4__1.localNodeId_1, this._this__u8e3s4__1.localNodeAuth_1);
              contentType(this_0, Application_getInstance().get_Json_wo4ci9_k$());
              setBodyJson(this_0, this._this__u8e3s4__1.json_1, Companion_getInstance_13().serializer_9w0wvi_k$(), new DoorMessage(Companion_getInstance_13().get_WHAT_REPLICATION_PUSH_tr3xkv_k$(), this._this__u8e3s4__1.localNodeId_1, this.remoteNodeIdVal0__1, this.outgoingReplications2__1));
              tmp_3.builder5__1 = this_0;
              this.builder5__1.set_method_hoo95u_k$(Companion_getInstance().get_Post_wo83k9_k$());
              var tmp_4 = this;
              tmp_4.this6__1 = this.this4__1;
              var tmp_5 = this;
              tmp_5.builder7__1 = this.builder5__1;
              this.set_state_rjd8d0_k$(6);
              suspendResult = (new HttpStatement(this.builder7__1, this.this6__1)).execute_rsj18j_k$(this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            } else {
              this.set_state_rjd8d0_k$(8);
              continue $sm;
            }

          case 6:
            this.replicationResponse8__1 = suspendResult;
            this.ARGUMENT9__1 = this._this__u8e3s4__1.json_1;
            this.ARGUMENT10__1 = Companion_getInstance_16().serializer_9w0wvi_k$();
            this.set_state_rjd8d0_k$(7);
            suspendResult = bodyAsText(this.replicationResponse8__1, VOID, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 7:
            this.ARGUMENT11__1 = suspendResult;
            this.replicationReceivedAck12__1 = this.ARGUMENT9__1.decodeFromString_jwu9sq_k$(this.ARGUMENT10__1, this.ARGUMENT11__1);
            v(this._this__u8e3s4__1.logger_1, VOID, DoorRepositoryReplicationClient$runSendLoop$lambda_2(this._this__u8e3s4__1, this.replicationResponse8__1, this.replicationReceivedAck12__1));
            this.outgoingReplicationsToAck1__1.addAll_4lagoh_k$(this.replicationReceivedAck12__1.get_replicationUids_xbjn4q_k$());
            this.set_state_rjd8d0_k$(8);
            continue $sm;
          case 8:
            this.set_exceptionState_fex74n_k$(14);
            this.set_state_rjd8d0_k$(12);
            continue $sm;
          case 9:
            this.set_exceptionState_fex74n_k$(14);
            var tmp_6 = this.get_exception_x0n6w6_k$();
            if (tmp_6 instanceof Exception) {
              this.e13__1 = this.get_exception_x0n6w6_k$();
              var tmp_7 = this.e13__1;
              if (!(tmp_7 instanceof CancellationException)) {
                d_0(this._this__u8e3s4__1.logger_1, this.e13__1, DoorRepositoryReplicationClient$runSendLoop$lambda_3(this._this__u8e3s4__1));
                this.set_state_rjd8d0_k$(10);
                suspendResult = delay(toLong(this._this__u8e3s4__1.retryInterval_1), this);
                if (suspendResult === get_COROUTINE_SUSPENDED()) {
                  return suspendResult;
                }
                continue $sm;
              } else {
                this.set_state_rjd8d0_k$(11);
                continue $sm;
              }
            } else {
              throw this.get_exception_x0n6w6_k$();
            }

          case 10:
            this.set_state_rjd8d0_k$(11);
            continue $sm;
          case 11:
            this.set_state_rjd8d0_k$(12);
            continue $sm;
          case 12:
            this.set_exceptionState_fex74n_k$(14);
            this.set_state_rjd8d0_k$(2);
            continue $sm;
          case 13:
            return Unit_getInstance();
          case 14:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 14) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  function $runFetchLoopCOROUTINE$17(_this__u8e3s4, _this__u8e3s4_0, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
    this._this__u8e3s4__2 = _this__u8e3s4_0;
  }
  protoOf($runFetchLoopCOROUTINE$17).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(13);
            var tmp_0 = this;
            tmp_0.acknowledgementsToSend0__1 = ArrayList_init_$Create$();
            this.set_state_rjd8d0_k$(1);
            continue $sm;
          case 1:
            if (!get_isActive(this._this__u8e3s4__2)) {
              this.set_state_rjd8d0_k$(12);
              continue $sm;
            }

            this.set_exceptionState_fex74n_k$(8);
            if (this.acknowledgementsToSend0__1.isEmpty_y1axqb_k$()) {
              this.set_state_rjd8d0_k$(2);
              suspendResult = this._this__u8e3s4__1.fetchNotifyChannel_1.receive_awoumx_k$(this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            } else {
              this.set_state_rjd8d0_k$(3);
              continue $sm;
            }

          case 2:
            this.set_state_rjd8d0_k$(3);
            continue $sm;
          case 3:
            v(this._this__u8e3s4__1.logger_1, VOID, DoorRepositoryReplicationClient$runFetchLoop$lambda(this._this__u8e3s4__1, this.acknowledgementsToSend0__1));
            var tmp_1 = this;
            tmp_1.this1__1 = this._this__u8e3s4__1.httpClient_1;
            var tmp_2 = this;
            tmp_2.this2__1 = this.this1__1;
            var tmp_3 = this;
            var this_0 = new HttpRequestBuilder();
            doorNodeIdHeader_0(this_0, this._this__u8e3s4__1.localNodeId_1, this._this__u8e3s4__1.localNodeAuth_1);
            setRepoUrl(this_0, this._this__u8e3s4__1.repoEndpointUrl_1, 'replication/ackAndGetPendingReplications');
            contentType(this_0, Application_getInstance().get_Json_wo4ci9_k$());
            setBodyJson(this_0, this._this__u8e3s4__1.json_1, Companion_getInstance_16().serializer_9w0wvi_k$(), new ReplicationReceivedAck(this.acknowledgementsToSend0__1));
            tmp_3.builder3__1 = this_0;
            this.builder3__1.set_method_hoo95u_k$(Companion_getInstance().get_Post_wo83k9_k$());
            var tmp_4 = this;
            tmp_4.this4__1 = this.this2__1;
            var tmp_5 = this;
            tmp_5.builder5__1 = this.builder3__1;
            this.set_state_rjd8d0_k$(4);
            suspendResult = (new HttpStatement(this.builder5__1, this.this4__1)).execute_rsj18j_k$(this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 4:
            this.entitiesReceivedResponse6__1 = suspendResult;
            v(this._this__u8e3s4__1.logger_1, VOID, DoorRepositoryReplicationClient$runFetchLoop$lambda_0(this._this__u8e3s4__1, this.entitiesReceivedResponse6__1));
            this.acknowledgementsToSend0__1.clear_j9egeb_k$();
            if (this.entitiesReceivedResponse6__1.get_status_jnf6d7_k$().equals(Companion_getInstance_0().get_OK_kntokb_k$())) {
              this.ARGUMENT7__1 = this._this__u8e3s4__1.json_1;
              this.ARGUMENT8__1 = Companion_getInstance_13().serializer_9w0wvi_k$();
              this.set_state_rjd8d0_k$(5);
              suspendResult = bodyAsText(this.entitiesReceivedResponse6__1, VOID, this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            } else {
              this.set_state_rjd8d0_k$(7);
              continue $sm;
            }

          case 5:
            this.ARGUMENT9__1 = suspendResult;
            this.entitiesReceivedMessage10__1 = this.ARGUMENT7__1.decodeFromString_jwu9sq_k$(this.ARGUMENT8__1, this.ARGUMENT9__1);
            v(this._this__u8e3s4__1.logger_1, VOID, DoorRepositoryReplicationClient$runFetchLoop$lambda_1(this._this__u8e3s4__1, this.entitiesReceivedMessage10__1));
            this.set_state_rjd8d0_k$(6);
            suspendResult = this._this__u8e3s4__1.nodeEventManager_1.onIncomingMessageReceived_3v60w2_k$(this.entitiesReceivedMessage10__1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 6:
            var this_1 = this.entitiesReceivedMessage10__1.get_replications_s2xb3k_k$();
            var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_1, 10));
            var tmp0_iterator = this_1.iterator_jk1svi_k$();
            while (tmp0_iterator.hasNext_bitz1p_k$()) {
              var item = tmp0_iterator.next_20eer_k$();
              destination.add_utx5q5_k$(item.get_orUid_iwh7pg_k$());
            }

            this.acknowledgementsToSend0__1.addAll_4lagoh_k$(destination);
            v(this._this__u8e3s4__1.logger_1, VOID, DoorRepositoryReplicationClient$runFetchLoop$lambda_2(this._this__u8e3s4__1, this.entitiesReceivedMessage10__1));
            this.set_state_rjd8d0_k$(7);
            continue $sm;
          case 7:
            if (this.entitiesReceivedResponse6__1.get_status_jnf6d7_k$().equals(Companion_getInstance_0().get_NoContent_3ur3v5_k$())) {
              this._this__u8e3s4__1.lastReceiveCompleteTime_1 = this.entitiesReceivedResponse6__1.get_responseTime_scfvg7_k$().get_timestamp_9fccx9_k$();
            }

            this.set_exceptionState_fex74n_k$(13);
            this.set_state_rjd8d0_k$(11);
            continue $sm;
          case 8:
            this.set_exceptionState_fex74n_k$(13);
            var tmp_6 = this.get_exception_x0n6w6_k$();
            if (tmp_6 instanceof Exception) {
              this.e11__1 = this.get_exception_x0n6w6_k$();
              var tmp_7 = this.e11__1;
              if (!(tmp_7 instanceof CancellationException)) {
                v(this._this__u8e3s4__1.logger_1, this.e11__1, DoorRepositoryReplicationClient$runFetchLoop$lambda_3(this.e11__1));
                this.set_state_rjd8d0_k$(9);
                suspendResult = delay(toLong(this._this__u8e3s4__1.retryInterval_1), this);
                if (suspendResult === get_COROUTINE_SUSPENDED()) {
                  return suspendResult;
                }
                continue $sm;
              } else {
                this.set_state_rjd8d0_k$(10);
                continue $sm;
              }
            } else {
              throw this.get_exception_x0n6w6_k$();
            }

          case 9:
            this.set_state_rjd8d0_k$(10);
            continue $sm;
          case 10:
            this.set_state_rjd8d0_k$(11);
            continue $sm;
          case 11:
            this.set_exceptionState_fex74n_k$(13);
            this.set_state_rjd8d0_k$(1);
            continue $sm;
          case 12:
            return Unit_getInstance();
          case 13:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 13) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  function DoorRepositoryReplicationClient(localNodeId, localNodeAuth, httpClient, json, repoEndpointUrl, scope, nodeEventManager, onMarkAcknowledgedAndGetNextOutgoingReplications, onStartPendingSession, onPendingSessionResolved, logger, dbName, retryInterval) {
    Companion_getInstance_15();
    retryInterval = retryInterval === VOID ? 10000 : retryInterval;
    this.localNodeId_1 = localNodeId;
    this.localNodeAuth_1 = localNodeAuth;
    this.httpClient_1 = httpClient;
    this.json_1 = json;
    this.repoEndpointUrl_1 = repoEndpointUrl;
    this.nodeEventManager_1 = nodeEventManager;
    this.onMarkAcknowledgedAndGetNextOutgoingReplications_1 = onMarkAcknowledgedAndGetNextOutgoingReplications;
    this.onStartPendingSession_1 = onStartPendingSession;
    this.onPendingSessionResolved_1 = onPendingSessionResolved;
    this.logger_1 = logger;
    this.dbName_1 = dbName;
    this.retryInterval_1 = retryInterval;
    this.logPrefix_1 = '[DoorRepositoryReplicationClient - ' + this.dbName_1 + ' - endpoint=' + this.repoEndpointUrl_1 + ']';
    this._state_1 = MutableStateFlow(new ClientState());
    this.state_1 = asStateFlow(this._state_1);
    this.fakeRemoteNodeId_1 = Default_getInstance().nextLong_m0lbld_k$(new Long(-10000, -1), new Long(-1, -1));
    d(this.logger_1, this.logPrefix_1 + ' init');
    this.lastReceiveCompleteTime_1 = new Long(0, 0);
    this.fetchNotifyChannel_1 = Channel(1);
    this.sendNotifyChannel_1 = Channel(1);
    this.batchSize_1 = 1000;
    this.remoteNodeId_1 = CompletableDeferred();
    launch(scope, VOID, VOID, DoorRepositoryReplicationClient$slambda_0(this, null));
    var tmp = this;
    tmp.fetchPendingReplicationsJob_1 = launch(scope, VOID, VOID, DoorRepositoryReplicationClient$slambda_2(this, null));
    var tmp_0 = this;
    tmp_0.sendPendingReplicationsJob_1 = launch(scope, VOID, VOID, DoorRepositoryReplicationClient$slambda_4(this, null));
    var tmp_1 = this;
    tmp_1.collectEventsJob_1 = launch(scope, VOID, VOID, DoorRepositoryReplicationClient$slambda_6(this, null));
    this.fetchNotifyChannel_1.trySend_62dpg8_k$(Unit_getInstance());
    this.sendNotifyChannel_1.trySend_62dpg8_k$(Unit_getInstance());
  }
  protoOf(DoorRepositoryReplicationClient).get_state_iypx7s_k$ = function () {
    return this.state_1;
  };
  protoOf(DoorRepositoryReplicationClient).set_lastReceiveCompleteTime_kbjhfs_k$ = function (_set____db54di) {
    this.lastReceiveCompleteTime_1 = _set____db54di;
  };
  protoOf(DoorRepositoryReplicationClient).get_lastReceiveCompleteTime_jo4vue_k$ = function () {
    return this.lastReceiveCompleteTime_1;
  };
  protoOf(DoorRepositoryReplicationClient).remoteNodeIdOrNull_xiaqh9_k$ = function () {
    return this.remoteNodeId_1.get_isCompleted_a6j6c8_k$() ? this.remoteNodeId_1.getCompleted_nczk2z_k$() : null;
  };
  protoOf(DoorRepositoryReplicationClient).remoteNodeIdOrFake_xi57q3_k$ = function () {
    var tmp;
    if (this.remoteNodeId_1.get_isCompleted_a6j6c8_k$()) {
      tmp = this.remoteNodeId_1.getCompleted_nczk2z_k$();
    } else {
      tmp = this.fakeRemoteNodeId_1;
    }
    return tmp;
  };
  protoOf(DoorRepositoryReplicationClient).close_yn9xrc_k$ = function () {
    this.sendNotifyChannel_1.cancel$default_880p35_k$();
    this.fetchPendingReplicationsJob_1.cancel$default_8haxne_k$();
    this.collectEventsJob_1.cancel$default_8haxne_k$();
    this.fetchNotifyChannel_1.close$default_kcbl7u_k$();
    this.sendNotifyChannel_1.close$default_kcbl7u_k$();
    this.remoteNodeId_1.cancel$default_8haxne_k$();
  };
  function JsonDbFieldInfo() {
  }
  function ReplicationConstants() {
    ReplicationConstants_instance = this;
    this.RECEIVE_VIEW_FROM_NODE_ID_FIELDNAME_1 = 'fromNodeId';
  }
  protoOf(ReplicationConstants).get_RECEIVE_VIEW_FROM_NODE_ID_FIELDNAME_wp94aq_k$ = function () {
    return this.RECEIVE_VIEW_FROM_NODE_ID_FIELDNAME_1;
  };
  var ReplicationConstants_instance;
  function ReplicationConstants_getInstance() {
    if (ReplicationConstants_instance == null)
      new ReplicationConstants();
    return ReplicationConstants_instance;
  }
  function ReplicationEntityMetaData$_get_selectEntityByPrimaryKeysSql_$lambda_c8e82w(it) {
    return it + ' = ?';
  }
  function ReplicationEntityMetaData$insertIntoReceiveViewSql$delegate$lambda$lambda(it) {
    return it.get_fieldName_tfocn0_k$();
  }
  function ReplicationEntityMetaData$insertIntoReceiveViewSql$delegate$lambda(this$0) {
    return function () {
      var tmp = joinToString(this$0.entityFields_1, VOID, VOID, VOID, VOID, VOID, ReplicationEntityMetaData$insertIntoReceiveViewSql$delegate$lambda$lambda);
      var tmp_0 = ReplicationConstants_getInstance().get_RECEIVE_VIEW_FROM_NODE_ID_FIELDNAME_wp94aq_k$();
      // Inline function 'kotlin.collections.map' call
      var this_0 = numberRangeToNumber(0, this$0.entityFields_1.get_size_woubt6_k$());
      // Inline function 'kotlin.collections.mapTo' call
      var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10));
      var tmp0_iterator = this_0.iterator_jk1svi_k$();
      while (tmp0_iterator.hasNext_bitz1p_k$()) {
        var item = tmp0_iterator.next_20eer_k$();
        // Inline function 'com.ustadmobile.door.replication.ReplicationEntityMetaData.insertIntoReceiveViewSql$delegate.<anonymous>.<anonymous>' call
        destination.add_utx5q5_k$('?');
      }
      return '\n        INSERT INTO ' + this$0.receiveViewName_1 + ' (' + tmp + ', ' + tmp_0 + ')\n               VALUES (' + joinToString(destination) + ')\n        ';
    };
  }
  function ReplicationEntityMetaData(tableId, entityTableName, receiveViewName, entityPrimaryKeyFieldNames, entityVersionIdFieldName, entityFields, batchSize, remoteInsertStrategy, triggers) {
    batchSize = batchSize === VOID ? 1000 : batchSize;
    this.tableId_1 = tableId;
    this.entityTableName_1 = entityTableName;
    this.receiveViewName_1 = receiveViewName;
    this.entityPrimaryKeyFieldNames_1 = entityPrimaryKeyFieldNames;
    this.entityVersionIdFieldName_1 = entityVersionIdFieldName;
    this.entityFields_1 = entityFields;
    this.batchSize_1 = batchSize;
    this.remoteInsertStrategy_1 = remoteInsertStrategy;
    this.triggers_1 = triggers;
    var tmp = this;
    var tmp_0 = LazyThreadSafetyMode_NONE_getInstance();
    tmp.insertIntoReceiveViewSql$delegate_1 = lazy(tmp_0, ReplicationEntityMetaData$insertIntoReceiveViewSql$delegate$lambda(this));
  }
  protoOf(ReplicationEntityMetaData).get_tableId_of07s0_k$ = function () {
    return this.tableId_1;
  };
  protoOf(ReplicationEntityMetaData).get_entityTableName_g8x9t9_k$ = function () {
    return this.entityTableName_1;
  };
  protoOf(ReplicationEntityMetaData).get_receiveViewName_toacx6_k$ = function () {
    return this.receiveViewName_1;
  };
  protoOf(ReplicationEntityMetaData).get_entityPrimaryKeyFieldNames_5y8huf_k$ = function () {
    return this.entityPrimaryKeyFieldNames_1;
  };
  protoOf(ReplicationEntityMetaData).get_entityVersionIdFieldName_naw5k2_k$ = function () {
    return this.entityVersionIdFieldName_1;
  };
  protoOf(ReplicationEntityMetaData).get_entityFields_ad1dc5_k$ = function () {
    return this.entityFields_1;
  };
  protoOf(ReplicationEntityMetaData).get_batchSize_7o99am_k$ = function () {
    return this.batchSize_1;
  };
  protoOf(ReplicationEntityMetaData).get_remoteInsertStrategy_t4k5ff_k$ = function () {
    return this.remoteInsertStrategy_1;
  };
  protoOf(ReplicationEntityMetaData).get_triggers_6y18jg_k$ = function () {
    return this.triggers_1;
  };
  protoOf(ReplicationEntityMetaData).get_selectEntityByPrimaryKeysSql_y6bvk9_k$ = function () {
    return trimIndent('\n            SELECT ' + this.entityTableName_1 + '.* \n              FROM ' + this.entityTableName_1 + '\n             WHERE ' + joinToString(this.entityPrimaryKeyFieldNames_1, ' AND ', VOID, VOID, VOID, VOID, ReplicationEntityMetaData$_get_selectEntityByPrimaryKeysSql_$lambda_c8e82w) + '\n        ');
  };
  protoOf(ReplicationEntityMetaData).get_insertIntoReceiveViewSql_vqtvfs_k$ = function () {
    // Inline function 'kotlin.getValue' call
    var this_0 = this.insertIntoReceiveViewSql$delegate_1;
    insertIntoReceiveViewSql$factory();
    return this_0.get_value_j01efc_k$();
  };
  protoOf(ReplicationEntityMetaData).get_createReceiveViewSql_tpcdt7_k$ = function () {
    return '\n                CREATE VIEW ' + this.receiveViewName_1 + ' AS \n                       SELECT ' + this.entityTableName_1 + '.*, \n                              CAST(0 AS BIGINT) AS fromNodeId\n                         FROM ' + this.entityTableName_1 + '\n            ';
  };
  function insertIntoReceiveViewSql$factory() {
    return getPropertyCallableRef('insertIntoReceiveViewSql', 1, KProperty1, function (receiver) {
      return receiver.get_insertIntoReceiveViewSql_vqtvfs_k$();
    }, null);
  }
  function ReplicationFieldMetaData(fieldName, dbFieldType, nullable) {
    this.fieldName_1 = fieldName;
    this.dbFieldType_1 = dbFieldType;
    this.nullable_1 = nullable;
  }
  protoOf(ReplicationFieldMetaData).get_fieldName_tfocn0_k$ = function () {
    return this.fieldName_1;
  };
  protoOf(ReplicationFieldMetaData).get_dbFieldType_pz3j77_k$ = function () {
    return this.dbFieldType_1;
  };
  protoOf(ReplicationFieldMetaData).get_nullable_7petka_k$ = function () {
    return this.nullable_1;
  };
  protoOf(ReplicationFieldMetaData).component1_7eebsc_k$ = function () {
    return this.fieldName_1;
  };
  protoOf(ReplicationFieldMetaData).component2_7eebsb_k$ = function () {
    return this.dbFieldType_1;
  };
  protoOf(ReplicationFieldMetaData).component3_7eebsa_k$ = function () {
    return this.nullable_1;
  };
  protoOf(ReplicationFieldMetaData).copy_1mfbjm_k$ = function (fieldName, dbFieldType, nullable) {
    return new ReplicationFieldMetaData(fieldName, dbFieldType, nullable);
  };
  protoOf(ReplicationFieldMetaData).copy$default_jkd5r7_k$ = function (fieldName, dbFieldType, nullable, $super) {
    fieldName = fieldName === VOID ? this.fieldName_1 : fieldName;
    dbFieldType = dbFieldType === VOID ? this.dbFieldType_1 : dbFieldType;
    nullable = nullable === VOID ? this.nullable_1 : nullable;
    return $super === VOID ? this.copy_1mfbjm_k$(fieldName, dbFieldType, nullable) : $super.copy_1mfbjm_k$.call(this, fieldName, dbFieldType, nullable);
  };
  protoOf(ReplicationFieldMetaData).toString = function () {
    return 'ReplicationFieldMetaData(fieldName=' + this.fieldName_1 + ', dbFieldType=' + this.dbFieldType_1 + ', nullable=' + this.nullable_1 + ')';
  };
  protoOf(ReplicationFieldMetaData).hashCode = function () {
    var result = getStringHashCode(this.fieldName_1);
    result = imul(result, 31) + this.dbFieldType_1 | 0;
    result = imul(result, 31) + getBooleanHashCode(this.nullable_1) | 0;
    return result;
  };
  protoOf(ReplicationFieldMetaData).equals = function (other) {
    if (this === other)
      return true;
    if (!(other instanceof ReplicationFieldMetaData))
      return false;
    var tmp0_other_with_cast = other instanceof ReplicationFieldMetaData ? other : THROW_CCE();
    if (!(this.fieldName_1 === tmp0_other_with_cast.fieldName_1))
      return false;
    if (!(this.dbFieldType_1 === tmp0_other_with_cast.dbFieldType_1))
      return false;
    if (!(this.nullable_1 === tmp0_other_with_cast.nullable_1))
      return false;
    return true;
  };
  function _get_$childSerializers__r2zwns_0($this) {
    return $this.$childSerializers_1;
  }
  function Companion_13() {
    Companion_instance_13 = this;
    var tmp = this;
    // Inline function 'kotlin.arrayOf' call
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    tmp.$childSerializers_1 = [new ArrayListSerializer(LongSerializer_getInstance())];
  }
  protoOf(Companion_13).serializer_9w0wvi_k$ = function () {
    return $serializer_getInstance_2();
  };
  var Companion_instance_13;
  function Companion_getInstance_16() {
    if (Companion_instance_13 == null)
      new Companion_13();
    return Companion_instance_13;
  }
  function $serializer_2() {
    $serializer_instance_2 = this;
    var tmp0_serialDesc = new PluginGeneratedSerialDescriptor('com.ustadmobile.door.replication.ReplicationReceivedAck', this, 1);
    tmp0_serialDesc.addElement_5pzumi_k$('replicationUids', false);
    this.descriptor_1 = tmp0_serialDesc;
  }
  protoOf($serializer_2).get_descriptor_wjt6a0_k$ = function () {
    return this.descriptor_1;
  };
  protoOf($serializer_2).childSerializers_5ghqw5_k$ = function () {
    // Inline function 'kotlin.arrayOf' call
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    return [Companion_getInstance_16().$childSerializers_1[0]];
  };
  protoOf($serializer_2).deserialize_sy6x50_k$ = function (decoder) {
    var tmp0_desc = this.descriptor_1;
    var tmp1_flag = true;
    var tmp2_index = 0;
    var tmp3_bitMask0 = 0;
    var tmp4_local0 = null;
    var tmp5_input = decoder.beginStructure_yljocp_k$(tmp0_desc);
    var tmp6_cached = Companion_getInstance_16().$childSerializers_1;
    if (tmp5_input.decodeSequentially_xlblqy_k$()) {
      tmp4_local0 = tmp5_input.decodeSerializableElement_uahnnv_k$(tmp0_desc, 0, tmp6_cached[0], tmp4_local0);
      tmp3_bitMask0 = tmp3_bitMask0 | 1;
    } else
      while (tmp1_flag) {
        tmp2_index = tmp5_input.decodeElementIndex_bstkhp_k$(tmp0_desc);
        switch (tmp2_index) {
          case -1:
            tmp1_flag = false;
            break;
          case 0:
            tmp4_local0 = tmp5_input.decodeSerializableElement_uahnnv_k$(tmp0_desc, 0, tmp6_cached[0], tmp4_local0);
            tmp3_bitMask0 = tmp3_bitMask0 | 1;
            break;
          default:
            throw UnknownFieldException_init_$Create$(tmp2_index);
        }
      }
    tmp5_input.endStructure_1xqz0n_k$(tmp0_desc);
    return ReplicationReceivedAck_init_$Create$(tmp3_bitMask0, tmp4_local0, null);
  };
  protoOf($serializer_2).serialize_5ks207_k$ = function (encoder, value) {
    var tmp0_desc = this.descriptor_1;
    var tmp1_output = encoder.beginStructure_yljocp_k$(tmp0_desc);
    var tmp2_cached = Companion_getInstance_16().$childSerializers_1;
    tmp1_output.encodeSerializableElement_isqxcl_k$(tmp0_desc, 0, tmp2_cached[0], value.replicationUids_1);
    tmp1_output.endStructure_1xqz0n_k$(tmp0_desc);
  };
  protoOf($serializer_2).serialize_5ase3y_k$ = function (encoder, value) {
    return this.serialize_5ks207_k$(encoder, value instanceof ReplicationReceivedAck ? value : THROW_CCE());
  };
  var $serializer_instance_2;
  function $serializer_getInstance_2() {
    if ($serializer_instance_2 == null)
      new $serializer_2();
    return $serializer_instance_2;
  }
  function ReplicationReceivedAck_init_$Init$(seen1, replicationUids, serializationConstructorMarker, $this) {
    if (!(1 === (1 & seen1))) {
      throwMissingFieldException(seen1, 1, $serializer_getInstance_2().descriptor_1);
    }
    $this.replicationUids_1 = replicationUids;
    return $this;
  }
  function ReplicationReceivedAck_init_$Create$(seen1, replicationUids, serializationConstructorMarker) {
    return ReplicationReceivedAck_init_$Init$(seen1, replicationUids, serializationConstructorMarker, objectCreate(protoOf(ReplicationReceivedAck)));
  }
  function ReplicationReceivedAck(replicationUids) {
    Companion_getInstance_16();
    this.replicationUids_1 = replicationUids;
  }
  protoOf(ReplicationReceivedAck).get_replicationUids_xbjn4q_k$ = function () {
    return this.replicationUids_1;
  };
  protoOf(ReplicationReceivedAck).component1_7eebsc_k$ = function () {
    return this.replicationUids_1;
  };
  protoOf(ReplicationReceivedAck).copy_vqu7_k$ = function (replicationUids) {
    return new ReplicationReceivedAck(replicationUids);
  };
  protoOf(ReplicationReceivedAck).copy$default_io3oh2_k$ = function (replicationUids, $super) {
    replicationUids = replicationUids === VOID ? this.replicationUids_1 : replicationUids;
    return $super === VOID ? this.copy_vqu7_k$(replicationUids) : $super.copy_vqu7_k$.call(this, replicationUids);
  };
  protoOf(ReplicationReceivedAck).toString = function () {
    return 'ReplicationReceivedAck(replicationUids=' + this.replicationUids_1 + ')';
  };
  protoOf(ReplicationReceivedAck).hashCode = function () {
    return hashCode(this.replicationUids_1);
  };
  protoOf(ReplicationReceivedAck).equals = function (other) {
    if (this === other)
      return true;
    if (!(other instanceof ReplicationReceivedAck))
      return false;
    var tmp0_other_with_cast = other instanceof ReplicationReceivedAck ? other : THROW_CCE();
    if (!equals(this.replicationUids_1, tmp0_other_with_cast.replicationUids_1))
      return false;
    return true;
  };
  function TriggerConstants() {
    TriggerConstants_instance = this;
    this.SQLITE_SELECT_TRIGGER_NAMES_1 = "\n        SELECT name\n                  FROM sqlite_master\n                 WHERE type = 'trigger'\n                   AND name LIKE ?\n    ";
    this.SQLITE_SELECT_VIEW_NAMES_1 = "\n        SELECT name\n          FROM sqlite_master\n         WHERE type = 'view'\n           AND name LIKE ?\n    ";
  }
  protoOf(TriggerConstants).get_SQLITE_SELECT_TRIGGER_NAMES_4rc9qw_k$ = function () {
    return this.SQLITE_SELECT_TRIGGER_NAMES_1;
  };
  protoOf(TriggerConstants).get_SQLITE_SELECT_VIEW_NAMES_bt69on_k$ = function () {
    return this.SQLITE_SELECT_VIEW_NAMES_1;
  };
  var TriggerConstants_instance;
  function TriggerConstants_getInstance() {
    if (TriggerConstants_instance == null)
      new TriggerConstants();
    return TriggerConstants_instance;
  }
  function createSqliteTriggerAndReceiveViewSetupStatementList(_this__u8e3s4) {
    // Inline function 'kotlin.collections.buildList' call
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'kotlin.collections.buildListInternal' call
    // Inline function 'kotlin.apply' call
    var this_0 = ArrayList_init_$Create$();
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'com.ustadmobile.door.triggers.createSqliteTriggerAndReceiveViewSetupStatementList.<anonymous>' call
    // Inline function 'kotlin.collections.forEach' call
    var tmp0_iterator = _this__u8e3s4.get_replicateEntities_2w1n4x_k$().get_values_ksazhn_k$().iterator_jk1svi_k$();
    while (tmp0_iterator.hasNext_bitz1p_k$()) {
      var element = tmp0_iterator.next_20eer_k$();
      // Inline function 'com.ustadmobile.door.triggers.createSqliteTriggerAndReceiveViewSetupStatementList.<anonymous>.<anonymous>' call
      if (element.get_remoteInsertStrategy_t4k5ff_k$().equals(RemoteInsertStrategy_INSERT_INTO_RECEIVE_VIEW_getInstance())) {
        this_0.add_utx5q5_k$(element.get_createReceiveViewSql_tpcdt7_k$());
      }
      // Inline function 'kotlin.collections.forEach' call
      var tmp0_iterator_0 = element.get_triggers_6y18jg_k$().iterator_jk1svi_k$();
      while (tmp0_iterator_0.hasNext_bitz1p_k$()) {
        var element_0 = tmp0_iterator_0.next_20eer_k$();
        // Inline function 'com.ustadmobile.door.triggers.createSqliteTriggerAndReceiveViewSetupStatementList.<anonymous>.<anonymous>.<anonymous>' call
        var tmp;
        if (element_0.get_on_kntnrs_k$().equals(On_ENTITY_getInstance())) {
          tmp = element.get_entityTableName_g8x9t9_k$();
        } else {
          tmp = element.get_receiveViewName_toacx6_k$();
        }
        var tableOrViewName = tmp;
        // Inline function 'kotlin.collections.forEach' call
        var indexedObject = element_0.get_events_d1yhia_k$();
        var inductionVariable = 0;
        var last = indexedObject.length;
        while (inductionVariable < last) {
          var element_1 = indexedObject[inductionVariable];
          inductionVariable = inductionVariable + 1 | 0;
          // Inline function 'com.ustadmobile.door.triggers.createSqliteTriggerAndReceiveViewSetupStatementList.<anonymous>.<anonymous>.<anonymous>.<anonymous>' call
          // Inline function 'kotlin.text.substring' call
          // Inline function 'kotlin.text.lowercase' call
          // Inline function 'kotlin.js.asDynamic' call
          // Inline function 'kotlin.js.asDynamic' call
          var postfix = element_1.get_sqlKeyWord_5ioqos_k$().toLowerCase().substring(0, 3);
          this_0.add_utx5q5_k$(trimIndent('\n                CREATE TRIGGER ' + Companion_getInstance_9().get_NAME_PREFIX_pvog9p_k$() + element_0.get_name_woqyms_k$() + '_' + postfix + ' \n                ' + element_0.get_order_iwhiqt_k$().get_sqlStr_jly4y4_k$() + ' ' + element_1 + ' ON ' + tableOrViewName + '\n                FOR EACH ROW ' + (!(element_0.get_conditionSql_fcgp38_k$() === '') ? ' WHEN (' + element_0.get_conditionSql_fcgp38_k$() + ') ' : '') + '\n                BEGIN\n                    ' + joinToString_0(element_0.get_sqlStatements_hnj4d3_k$(), ';') + ';\n                END\n            '));
        }
      }
    }
    return this_0.build_1k0s4u_k$();
  }
  function DoorEventCollator$receiveEvent$slambda$slambda(this$0, resultContinuation) {
    this.this$0__1 = this$0;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(DoorEventCollator$receiveEvent$slambda$slambda).invoke_d9fzmj_k$ = function ($this$launch, $completion) {
    var tmp = this.create_rcuf4x_k$($this$launch, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(DoorEventCollator$receiveEvent$slambda$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_d9fzmj_k$((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(DoorEventCollator$receiveEvent$slambda$slambda).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(3);
            this.set_state_rjd8d0_k$(1);
            suspendResult = delay(this.this$0__1.maxWaitTime_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            this.this$0__1.dispatchJob_1.set_kotlinx$atomicfu$value_508e3y_k$(null);
            this.set_state_rjd8d0_k$(2);
            suspendResult = this.this$0__1.onCollate_1(tryReceiveAll(this.this$0__1.channel_1, this.this$0__1), this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 2:
            return Unit_getInstance();
          case 3:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 3) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(DoorEventCollator$receiveEvent$slambda$slambda).create_rcuf4x_k$ = function ($this$launch, completion) {
    var i = new DoorEventCollator$receiveEvent$slambda$slambda(this.this$0__1, completion);
    i.$this$launch_1 = $this$launch;
    return i;
  };
  protoOf(DoorEventCollator$receiveEvent$slambda$slambda).create_wyq9v6_k$ = function (value, completion) {
    return this.create_rcuf4x_k$((!(value == null) ? isInterface(value, CoroutineScope) : false) ? value : THROW_CCE(), completion);
  };
  function DoorEventCollator$receiveEvent$slambda$slambda_0(this$0, resultContinuation) {
    var i = new DoorEventCollator$receiveEvent$slambda$slambda(this$0, resultContinuation);
    var l = function ($this$launch, $completion) {
      return i.invoke_d9fzmj_k$($this$launch, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function _get_maxWaitTime__cgml91($this) {
    return $this.maxWaitTime_1;
  }
  function _get_coroutineScope__o75s5t($this) {
    return $this.coroutineScope_1;
  }
  function _get_dispatchJob__5lfkzy($this) {
    return $this.dispatchJob_1;
  }
  function _get_channel__c6e3yq($this) {
    return $this.channel_1;
  }
  function tryReceiveAll(_this__u8e3s4, $this) {
    var resultList = mutableLinkedListOf([]);
    while (true) {
      var result = _this__u8e3s4.tryReceive_y3ovg2_k$();
      if (_ChannelResult___get_isSuccess__impl__odq1z9(result)) {
        // Inline function 'kotlin.collections.plusAssign' call
        var element = ChannelResult__getOrThrow_impl_od1axs(result);
        resultList.add_utx5q5_k$(element);
      } else
        return resultList;
    }
  }
  function DoorEventCollator$receiveEvent$slambda(this$0, resultContinuation) {
    this.this$0__1 = this$0;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(DoorEventCollator$receiveEvent$slambda).invoke_d9fzmj_k$ = function ($this$launch, $completion) {
    var tmp = this.create_rcuf4x_k$($this$launch, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(DoorEventCollator$receiveEvent$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_d9fzmj_k$((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(DoorEventCollator$receiveEvent$slambda).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        if (tmp === 0) {
          this.set_exceptionState_fex74n_k$(1);
          this.this$0__1.dispatchJob_1.set_kotlinx$atomicfu$value_508e3y_k$(launch(this.this$0__1.coroutineScope_1, VOID, VOID, DoorEventCollator$receiveEvent$slambda$slambda_0(this.this$0__1, null)));
          return Unit_getInstance();
        } else if (tmp === 1) {
          throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        throw e;
      }
     while (true);
  };
  protoOf(DoorEventCollator$receiveEvent$slambda).create_rcuf4x_k$ = function ($this$launch, completion) {
    var i = new DoorEventCollator$receiveEvent$slambda(this.this$0__1, completion);
    i.$this$launch_1 = $this$launch;
    return i;
  };
  protoOf(DoorEventCollator$receiveEvent$slambda).create_wyq9v6_k$ = function (value, completion) {
    return this.create_rcuf4x_k$((!(value == null) ? isInterface(value, CoroutineScope) : false) ? value : THROW_CCE(), completion);
  };
  function DoorEventCollator$receiveEvent$slambda_0(this$0, resultContinuation) {
    var i = new DoorEventCollator$receiveEvent$slambda(this$0, resultContinuation);
    var l = function ($this$launch, $completion) {
      return i.invoke_d9fzmj_k$($this$launch, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function DoorEventCollator(maxWaitTime, coroutineScope, onCollate) {
    this.maxWaitTime_1 = maxWaitTime;
    this.coroutineScope_1 = coroutineScope;
    this.onCollate_1 = onCollate;
    this.dispatchJob_1 = atomic$ref$1(null);
    this.channel_1 = Channel(Factory_getInstance().get_UNLIMITED_eshsm0_k$());
  }
  protoOf(DoorEventCollator).get_onCollate_opqb8i_k$ = function () {
    return this.onCollate_1;
  };
  protoOf(DoorEventCollator).receiveEvent_cmiqeg_k$ = function (event) {
    this.channel_1.trySend_62dpg8_k$(event);
    if (this.dispatchJob_1.get_kotlinx$atomicfu$value_vi2am5_k$() == null) {
      var tmp = GlobalScope_getInstance();
      launch(tmp, VOID, VOID, DoorEventCollator$receiveEvent$slambda_0(this, null));
    }
  };
  function IWeakRef() {
  }
  function _get_db__ndbzd9_2($this) {
    return $this.db_1;
  }
  function OnNewDoorNode() {
  }
  function _get_newNodeListeners__dut0ky($this) {
    return $this.newNodeListeners_1;
  }
  function _get_cachedAuth__eox4bj($this) {
    return $this.cachedAuth_1;
  }
  function _get_mutex__e2dgb2($this) {
    return $this.mutex_1;
  }
  function $verifyCOROUTINE$18(_this__u8e3s4, nodeId, auth, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
    this.nodeId_1 = nodeId;
    this.auth_1 = auth;
  }
  protoOf($verifyCOROUTINE$18).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(8);
            this.cachedAuthResult0__1 = this._this__u8e3s4__1.cachedAuth_1.get_wei43m_k$(this.nodeId_1);
            if (!(this.cachedAuthResult0__1 == null))
              return this.cachedAuthResult0__1 === this.auth_1;
            var tmp_0 = this;
            tmp_0.this1__1 = this._this__u8e3s4__1.mutex_1;
            var tmp_1 = this;
            tmp_1.owner2__1 = null;
            this.set_state_rjd8d0_k$(1);
            suspendResult = this.this1__1.lock_ugrcvf_k$(this.owner2__1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            this.set_state_rjd8d0_k$(2);
            continue $sm;
          case 2:
            this.set_exceptionState_fex74n_k$(7);
            this.set_state_rjd8d0_k$(3);
            suspendResult = getDoorNodeAuth(this._this__u8e3s4__1.db_1, this.nodeId_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 3:
            this.dbAuthResult4__1 = suspendResult;
            if (!(this.dbAuthResult4__1 == null)) {
              var tmp_2 = this;
              var this_0 = this._this__u8e3s4__1.cachedAuth_1;
              var key = this.nodeId_1;
              var value = this.dbAuthResult4__1;
              this_0.put_4fpzoq_k$(key, value);
              tmp_2.WHEN_RESULT5__1 = this.dbAuthResult4__1 === this.auth_1;
              this.set_state_rjd8d0_k$(5);
              continue $sm;
            } else {
              Napier_getInstance().d$default_a5agxr_k$('NodeIdAndAuthCache: New Node connected: ' + this.nodeId_1.toString() + ' ', VOID, Companion_getInstance_12().get_LOG_TAG_it8mba_k$());
              this.set_state_rjd8d0_k$(4);
              var this_1 = new DoorNode();
              this_1.set_auth_b8k972_k$(this.auth_1);
              this_1.set_nodeId_xy4u70_k$(this.nodeId_1);
              this_1.set_rel_w9cafg_k$(Companion_getInstance_10().get_SERVER_FOR_spbpdi_k$());
              suspendResult = insertNewDoorNode(this._this__u8e3s4__1.db_1, this_1, this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            }

          case 4:
            var this_2 = this._this__u8e3s4__1.cachedAuth_1;
            var key_0 = this.nodeId_1;
            var value_0 = this.auth_1;
            this_2.put_4fpzoq_k$(key_0, value_0);
            Napier_getInstance().d$default_a5agxr_k$('NodeIdAndAuthCache: Fire new node event to ' + this._this__u8e3s4__1.newNodeListeners_1.get_size_woubt6_k$() + ' listeners');
            var tmp0_iterator = this._this__u8e3s4__1.newNodeListeners_1.iterator_jk1svi_k$();
            while (tmp0_iterator.hasNext_bitz1p_k$()) {
              var element = tmp0_iterator.next_20eer_k$();
              element.onNewDoorNode_sj4mgd_k$(this.nodeId_1, this.auth_1);
            }

            this.WHEN_RESULT5__1 = true;
            this.set_state_rjd8d0_k$(5);
            continue $sm;
          case 5:
            this.tmp$ret$03__1 = this.WHEN_RESULT5__1;
            this.set_exceptionState_fex74n_k$(8);
            this.set_state_rjd8d0_k$(6);
            continue $sm;
          case 6:
            var tmp_3 = this.tmp$ret$03__1;
            this.set_exceptionState_fex74n_k$(8);
            this.this1__1.unlock_ulcrcl_k$(this.owner2__1);
            return tmp_3;
          case 7:
            this.set_exceptionState_fex74n_k$(8);
            var t = this.get_exception_x0n6w6_k$();
            this.this1__1.unlock_ulcrcl_k$(this.owner2__1);
            throw t;
          case 8:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 8) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  function NodeIdAuthCache(db) {
    this.db_1 = db;
    this.newNodeListeners_1 = concurrentSafeListOf([]);
    this.cachedAuth_1 = concurrentSafeMapOf([]);
    this.mutex_1 = Mutex();
  }
  protoOf(NodeIdAuthCache).verify_l4pfjv_k$ = function (nodeId, auth, $completion) {
    var tmp = new $verifyCOROUTINE$18(this, nodeId, auth, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(NodeIdAuthCache).addNewNodeListener_d3nzd7_k$ = function (newNodeListener) {
    // Inline function 'kotlin.collections.plusAssign' call
    this.newNodeListeners_1.add_utx5q5_k$(newNodeListener);
  };
  protoOf(NodeIdAuthCache).removeNewNodeListener_yyy57y_k$ = function (newNodeListener) {
    // Inline function 'kotlin.collections.minusAssign' call
    this.newNodeListeners_1.remove_cedx0m_k$(newNodeListener);
  };
  var TransactionMode_READ_WRITE_instance;
  var TransactionMode_READ_ONLY_instance;
  function values_4() {
    return [TransactionMode_READ_WRITE_getInstance(), TransactionMode_READ_ONLY_getInstance()];
  }
  function valueOf_4(value) {
    switch (value) {
      case 'READ_WRITE':
        return TransactionMode_READ_WRITE_getInstance();
      case 'READ_ONLY':
        return TransactionMode_READ_ONLY_getInstance();
      default:
        TransactionMode_initEntries();
        THROW_IAE('No enum constant value.');
        break;
    }
  }
  function get_entries_4() {
    if ($ENTRIES_4 == null)
      $ENTRIES_4 = enumEntries(values_4());
    return $ENTRIES_4;
  }
  var TransactionMode_entriesInitialized;
  function TransactionMode_initEntries() {
    if (TransactionMode_entriesInitialized)
      return Unit_getInstance();
    TransactionMode_entriesInitialized = true;
    TransactionMode_READ_WRITE_instance = new TransactionMode('READ_WRITE', 0);
    TransactionMode_READ_ONLY_instance = new TransactionMode('READ_ONLY', 1);
  }
  var $ENTRIES_4;
  function TransactionMode(name, ordinal) {
    Enum.call(this, name, ordinal);
  }
  function TransactionMode_READ_WRITE_getInstance() {
    TransactionMode_initEntries();
    return TransactionMode_READ_WRITE_instance;
  }
  function TransactionMode_READ_ONLY_getInstance() {
    TransactionMode_initEntries();
    return TransactionMode_READ_ONLY_instance;
  }
  function _get_implementationMap__h2mibr($this) {
    return $this.implementationMap_1;
  }
  function _get_builderOptions__3s2dbc($this) {
    return $this.builderOptions_1;
  }
  function _get_callbacks__bg494z($this) {
    return $this.callbacks_1;
  }
  function _get_migrationList__vdnnej($this) {
    return $this.migrationList_1;
  }
  function Companion_14() {
    Companion_instance_14 = this;
    var tmp = this;
    // Inline function 'kotlin.collections.mutableMapOf' call
    tmp.implementationMap_1 = LinkedHashMap_init_$Create$();
  }
  protoOf(Companion_14).databaseBuilder_hr8t2y_k$ = function (builderOptions) {
    return new DatabaseBuilder(builderOptions);
  };
  protoOf(Companion_14).lookupImplementations_qvwvxm_k$ = function (dbKClass) {
    var tmp = this.implementationMap_1.get_wei43m_k$(dbKClass);
    var tmp0_elvis_lhs = tmp instanceof DoorJsImplClasses ? tmp : null;
    var tmp_0;
    if (tmp0_elvis_lhs == null) {
      throw IllegalArgumentException_init_$Create$('' + dbKClass.get_simpleName_r6f8py_k$() + ' is not registered through DatabaseBuilder.register');
    } else {
      tmp_0 = tmp0_elvis_lhs;
    }
    return tmp_0;
  };
  protoOf(Companion_14).register_5pbmmw_k$ = function (implClasses) {
    // Inline function 'kotlin.collections.set' call
    var this_0 = this.implementationMap_1;
    var key = implClasses.get_dbKClass_7eayj0_k$();
    this_0.put_4fpzoq_k$(key, implClasses);
    // Inline function 'kotlin.collections.set' call
    var this_1 = this.implementationMap_1;
    var key_0 = implClasses.get_dbImplKClass_9ooj90_k$();
    this_1.put_4fpzoq_k$(key_0, implClasses);
    var tmp0_safe_receiver = implClasses.get_repositoryImplClass_s9eqw5_k$();
    if (tmp0_safe_receiver == null)
      null;
    else {
      // Inline function 'kotlin.also' call
      // Inline function 'kotlin.contracts.contract' call
      // Inline function 'com.ustadmobile.door.Companion.register.<anonymous>' call
      // Inline function 'kotlin.collections.set' call
      Companion_getInstance_17().implementationMap_1.put_4fpzoq_k$(tmp0_safe_receiver, implClasses);
    }
    var tmp1_safe_receiver = implClasses.get_replicateWrapperImplClass_h5k6md_k$();
    if (tmp1_safe_receiver == null)
      null;
    else {
      // Inline function 'kotlin.also' call
      // Inline function 'kotlin.contracts.contract' call
      // Inline function 'com.ustadmobile.door.Companion.register.<anonymous>' call
      // Inline function 'kotlin.collections.set' call
      Companion_getInstance_17().implementationMap_1.put_4fpzoq_k$(tmp1_safe_receiver, implClasses);
    }
  };
  var Companion_instance_14;
  function Companion_getInstance_17() {
    if (Companion_instance_14 == null)
      new Companion_14();
    return Companion_instance_14;
  }
  function build$execSqlAsync(_this__u8e3s4, sqlStmts, $completion) {
    var tmp = new $build$execSqlAsyncCOROUTINE$20(_this__u8e3s4, sqlStmts, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  }
  function $buildCOROUTINE$19(_this__u8e3s4, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
  }
  protoOf($buildCOROUTINE$19).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(33);
            if (!startsWith(this._this__u8e3s4__1.builderOptions_1.get_dbUrl_iq59m0_k$(), Companion_getInstance_21().get_PROTOCOL_SQLITE_PREFIX_pl3y1_k$()))
              throw IllegalArgumentException_init_$Create$('Door/JS: Only SQLite is supported on JS! dbUrl must be in the form of sqlite::memory: OR sqlite:indexeddb_name');
            Companion_getInstance_17().register_5pbmmw_k$(this._this__u8e3s4__1.builderOptions_1.get_dbImplClasses_b09lsx_k$());
            this.storageLocation0__1 = substringAfter(this._this__u8e3s4__1.builderOptions_1.get_dbUrl_iq59m0_k$(), Companion_getInstance_21().get_PROTOCOL_SQLITE_PREFIX_pl3y1_k$());
            this.dbMetaData1__1 = Companion_getInstance_17().lookupImplementations_qvwvxm_k$(this._this__u8e3s4__1.builderOptions_1.get_dbClass_ov3elt_k$()).get_metadata_vs95vc_k$();
            this.dataSource2__1 = new SQLiteDatasourceJs(this.storageLocation0__1, new Worker(this._this__u8e3s4__1.builderOptions_1.get_webWorkerPath_ilxjim_k$()), this._this__u8e3s4__1.builderOptions_1.get_logger_g9gejd_k$(), this._this__u8e3s4__1.builderOptions_1.get_logWorkerMessages_j9kuor_k$());
            Companion_getInstance_17().register_5pbmmw_k$(this._this__u8e3s4__1.builderOptions_1.get_dbImplClasses_b09lsx_k$());
            var tmp_0 = this;
            var tmp_1 = createInstance(get_js(this._this__u8e3s4__1.builderOptions_1.get_dbImplClasses_b09lsx_k$().get_dbImplKClass_9ooj90_k$()), [null, this.dataSource2__1, this._this__u8e3s4__1.builderOptions_1.get_dbUrl_iq59m0_k$(), this._this__u8e3s4__1.builderOptions_1.get_dbName_c9i0qa_k$(), this._this__u8e3s4__1.builderOptions_1.get_jdbcQueryTimeout_rk5wkj_k$(), Companion_getInstance_5().get_SQLITE_3yc5jp_k$(), this._this__u8e3s4__1.builderOptions_1.get_logger_g9gejd_k$()]);
            tmp_0.dbImpl3__1 = tmp_1 instanceof RoomDatabase ? tmp_1 : THROW_CCE();
            if (!(this.storageLocation0__1 === Companion_getInstance_21().get_LOCATION_MEMORY_rxk7vm_k$())) {
              this.set_state_rjd8d0_k$(1);
              suspendResult = IndexedDb_getInstance().checkIfExists_v2er53_k$(this.storageLocation0__1, this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            } else {
              this.WHEN_RESULT4__1 = false;
              this.set_state_rjd8d0_k$(2);
              continue $sm;
            }

          case 1:
            this.WHEN_RESULT4__1 = suspendResult;
            this.set_state_rjd8d0_k$(2);
            continue $sm;
          case 2:
            this.loadFromIndexedDb5__1 = this.WHEN_RESULT4__1;
            this.connection6__1 = this.dataSource2__1.getConnection_hr2oto_k$();
            this.sqlDatabase7__1 = new DoorSqlDatabaseConnectionImpl(this.connection6__1, Companion_getInstance_5().get_SQLITE_3yc5jp_k$());
            if (this.loadFromIndexedDb5__1) {
              Napier_getInstance().i$default_htnpp6_k$('DatabaseBuilderJs: database ' + this._this__u8e3s4__1.builderOptions_1.get_dbUrl_iq59m0_k$() + ' exists... loading\n', VOID, Companion_getInstance_12().get_LOG_TAG_it8mba_k$());
              this.set_state_rjd8d0_k$(9);
              suspendResult = this.dataSource2__1.loadDbFromIndexedDb_tcxnl_k$(this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            } else {
              Napier_getInstance().i$default_htnpp6_k$('DatabaseBuilderJs: Creating database ' + this._this__u8e3s4__1.builderOptions_1.get_dbUrl_iq59m0_k$() + '\n', VOID, Companion_getInstance_12().get_LOG_TAG_it8mba_k$());
              this.set_state_rjd8d0_k$(3);
              var this_0 = this.dbImpl3__1.createAllTables_v6vepi_k$();
              suspendResult = build$execSqlAsync(this.connection6__1, copyToArray(this_0).slice(), this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            }

          case 3:
            Napier_getInstance().i$default_htnpp6_k$('DatabaseBuilderJs: creating door triggers and receive views ' + this._this__u8e3s4__1.builderOptions_1.get_dbUrl_iq59m0_k$() + '\n', VOID, Companion_getInstance_12().get_LOG_TAG_it8mba_k$());
            this.set_state_rjd8d0_k$(4);
            var this_1 = createSqliteTriggerAndReceiveViewSetupStatementList(this.dbMetaData1__1);
            suspendResult = build$execSqlAsync(this.connection6__1, copyToArray(this_1).slice(), this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 4:
            Napier_getInstance().d$default_a5agxr_k$('DatabaseBuilderJs: Running onCreate callbacks...\n', VOID, Companion_getInstance_12().get_LOG_TAG_it8mba_k$());
            var tmp_2 = this;
            tmp_2.this8__1 = this._this__u8e3s4__1.callbacks_1;
            this.tmp0_iterator9__1 = this.this8__1.iterator_jk1svi_k$();
            this.set_state_rjd8d0_k$(5);
            continue $sm;
          case 5:
            if (!this.tmp0_iterator9__1.hasNext_bitz1p_k$()) {
              this.set_state_rjd8d0_k$(8);
              continue $sm;
            }

            this.element10__1 = this.tmp0_iterator9__1.next_20eer_k$();
            var tmp_3 = this;
            tmp_3.it11__1 = this.element10__1;
            this.tmp0_subject12__1 = this.it11__1;
            var tmp_4 = this.tmp0_subject12__1;
            if (isInterface(tmp_4, DoorDatabaseCallbackSync)) {
              throw new NotSupportedException('Cannot use sync callback on JS');
            } else {
              var tmp_5 = this.tmp0_subject12__1;
              if (isInterface(tmp_5, DoorDatabaseCallbackStatementList)) {
                Napier_getInstance().d$default_a5agxr_k$('DatabaseBuilderJs: Running onCreate callback: ' + getKClassFromExpression(this.it11__1).get_simpleName_r6f8py_k$(), VOID, Companion_getInstance_12().get_LOG_TAG_it8mba_k$());
                this.set_state_rjd8d0_k$(6);
                var this_2 = this.it11__1.onCreate_greuoz_k$(this.sqlDatabase7__1);
                suspendResult = build$execSqlAsync(this.connection6__1, copyToArray(this_2).slice(), this);
                if (suspendResult === get_COROUTINE_SUSPENDED()) {
                  return suspendResult;
                }
                continue $sm;
              } else {
                this.set_state_rjd8d0_k$(7);
                continue $sm;
              }
            }

          case 6:
            this.set_state_rjd8d0_k$(7);
            continue $sm;
          case 7:
            this.set_state_rjd8d0_k$(5);
            continue $sm;
          case 8:
            Napier_getInstance().d$default_a5agxr_k$('DatabaseBuilderJs: table creation finished\n', VOID, Companion_getInstance_12().get_LOG_TAG_it8mba_k$());
            this.set_state_rjd8d0_k$(26);
            continue $sm;
          case 9:
            var tmp_6 = this;
            tmp_6.sqlCon13__1 = (null == null ? true : null instanceof SQLiteConnectionJs) ? null : THROW_CCE();
            var tmp_7 = this;
            tmp_7.stmt14__1 = (null == null ? true : null instanceof SQLitePreparedStatementJs) ? null : THROW_CCE();
            var tmp_8 = this;
            tmp_8.resultSet15__1 = (null == null ? true : null instanceof SQLiteResultSet) ? null : THROW_CCE();
            this.currentDbVersion16__1 = -1;
            this.set_state_rjd8d0_k$(10);
            continue $sm;
          case 10:
            this.set_exceptionState_fex74n_k$(13);
            this.set_exceptionState_fex74n_k$(12);
            var tmp_9 = this;
            var tmp_10 = this.dataSource2__1.getConnection_hr2oto_k$();
            tmp_9.sqlCon13__1 = tmp_10 instanceof SQLiteConnectionJs ? tmp_10 : THROW_CCE();
            this.stmt14__1 = new SQLitePreparedStatementJs(this.sqlCon13__1, 'SELECT dbVersion FROM _doorwayinfo');
            this.set_state_rjd8d0_k$(11);
            suspendResult = this.stmt14__1.executeQueryAsyncInt_j35d75_k$(this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 11:
            var tmp_11 = this;
            tmp_11.resultSet15__1 = suspendResult instanceof SQLiteResultSet ? suspendResult : THROW_CCE();
            var tmp_12 = this;
            var tmp_13;
            if (this.resultSet15__1.next_20eer_k$()) {
              this.currentDbVersion16__1 = this.resultSet15__1.getInt_s8uc8x_k$(1);
              tmp_13 = Unit_getInstance();
            }

            tmp_12.tmp$ret$017__1 = tmp_13;
            this.set_exceptionState_fex74n_k$(33);
            this.set_state_rjd8d0_k$(14);
            continue $sm;
          case 12:
            this.set_exceptionState_fex74n_k$(13);
            var tmp_14 = this.get_exception_x0n6w6_k$();
            if (tmp_14 instanceof SQLException) {
              this.exception18__1 = this.get_exception_x0n6w6_k$();
              var tmp_15 = this;
              throw this.exception18__1;
            } else {
              throw this.get_exception_x0n6w6_k$();
            }

          case 13:
            this.set_exceptionState_fex74n_k$(33);
            this.t19__1 = this.get_exception_x0n6w6_k$();
            var tmp0_safe_receiver = this.resultSet15__1;
            if (tmp0_safe_receiver == null)
              null;
            else {
              tmp0_safe_receiver.close_yn9xrc_k$();
            }

            var tmp1_safe_receiver = this.stmt14__1;
            if (tmp1_safe_receiver == null)
              null;
            else {
              tmp1_safe_receiver.close_yn9xrc_k$();
            }

            var tmp2_safe_receiver = this.sqlCon13__1;
            if (tmp2_safe_receiver == null)
              null;
            else {
              tmp2_safe_receiver.close_yn9xrc_k$();
            }

            throw this.t19__1;
          case 14:
            this.set_exceptionState_fex74n_k$(33);
            var tmp0_safe_receiver_0 = this.resultSet15__1;
            if (tmp0_safe_receiver_0 == null)
              null;
            else {
              tmp0_safe_receiver_0.close_yn9xrc_k$();
            }

            var tmp1_safe_receiver_0 = this.stmt14__1;
            if (tmp1_safe_receiver_0 == null)
              null;
            else {
              tmp1_safe_receiver_0.close_yn9xrc_k$();
            }

            var tmp2_safe_receiver_0 = this.sqlCon13__1;
            if (tmp2_safe_receiver_0 == null)
              null;
            else {
              tmp2_safe_receiver_0.close_yn9xrc_k$();
            }

            Napier_getInstance().d$default_a5agxr_k$('DatabaseBuilderJs: Found current db version = ' + this.currentDbVersion16__1 + '\n', VOID, Companion_getInstance_12().get_LOG_TAG_it8mba_k$());
            this.dbWillBeMigrated20__1 = this.currentDbVersion16__1 < this.dbImpl3__1.get_dbVersion_jd6ndd_k$();
            var tmp_16 = this;
            var tmp3_safe_receiver = this.sqlCon13__1;
            var tmp_17;
            if (tmp3_safe_receiver == null) {
              tmp_17 = null;
            } else {
              var tmp_18;
              if (this.dbWillBeMigrated20__1) {
                tmp_18 = tmp3_safe_receiver;
              } else {
                tmp_18 = null;
              }
              tmp_17 = tmp_18;
            }

            tmp_16.tmp4_safe_receiver21__1 = tmp_17;
            if (this.tmp4_safe_receiver21__1 == null) {
              this.WHEN_RESULT22__1 = null;
              this.set_state_rjd8d0_k$(16);
              continue $sm;
            } else {
              this.set_state_rjd8d0_k$(15);
              suspendResult = dropDoorTriggersAndReceiveViewsSqlite(this.tmp4_safe_receiver21__1, this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            }

          case 15:
            var tmp_19 = this;
            tmp_19.WHEN_RESULT22__1 = Unit_getInstance();
            this.set_state_rjd8d0_k$(16);
            continue $sm;
          case 16:
            this.set_state_rjd8d0_k$(17);
            continue $sm;
          case 17:
            if (!(this.currentDbVersion16__1 < this.dbImpl3__1.get_dbVersion_jd6ndd_k$())) {
              this.set_state_rjd8d0_k$(23);
              continue $sm;
            }

            var tmp_20 = this;
            var tmp$ret$2;
            l$ret$3: do {
              var this_3 = this._this__u8e3s4__1.migrationList_1;
              var destination = ArrayList_init_$Create$();
              var tmp0_iterator = this_3.iterator_jk1svi_k$();
              while (tmp0_iterator.hasNext_bitz1p_k$()) {
                var element = tmp0_iterator.next_20eer_k$();
                var tmp_21;
                if (element.get_startVersion_84uten_k$() === this.currentDbVersion16__1) {
                  tmp_21 = !(element instanceof DoorMigrationSync);
                } else {
                  tmp_21 = false;
                }
                if (tmp_21) {
                  destination.add_utx5q5_k$(element);
                }
              }
              var iterator = destination.iterator_jk1svi_k$();
              if (!iterator.hasNext_bitz1p_k$()) {
                tmp$ret$2 = null;
                break l$ret$3;
              }
              var maxElem = iterator.next_20eer_k$();
              if (!iterator.hasNext_bitz1p_k$()) {
                tmp$ret$2 = maxElem;
                break l$ret$3;
              }
              var maxValue = maxElem.get_endVersion_algoai_k$();
              do {
                var e = iterator.next_20eer_k$();
                var v = e.get_endVersion_algoai_k$();
                if (compareTo(maxValue, v) < 0) {
                  maxElem = e;
                  maxValue = v;
                }
              }
               while (iterator.hasNext_bitz1p_k$());
              tmp$ret$2 = maxElem;
            }
             while (false);
            tmp_20.nextMigration23__1 = tmp$ret$2;
            if (!(this.nextMigration23__1 == null)) {
              Napier_getInstance().d$default_a5agxr_k$('DatabaseBuilderJs: Attempting to upgrade from ' + this.nextMigration23__1.get_startVersion_84uten_k$() + ' to ' + ('' + this.nextMigration23__1.get_endVersion_algoai_k$() + '\n'), VOID, Companion_getInstance_12().get_LOG_TAG_it8mba_k$());
              this.tmp5_subject24__1 = this.nextMigration23__1;
              var tmp_22 = this.tmp5_subject24__1;
              if (tmp_22 instanceof DoorMigrationAsync) {
                this.set_state_rjd8d0_k$(19);
                suspendResult = this.nextMigration23__1.get_migrateFn_5ksgd2_k$()(this.sqlDatabase7__1, this);
                if (suspendResult === get_COROUTINE_SUSPENDED()) {
                  return suspendResult;
                }
                continue $sm;
              } else {
                var tmp_23 = this.tmp5_subject24__1;
                if (tmp_23 instanceof DoorMigrationStatementList) {
                  this.set_state_rjd8d0_k$(18);
                  var this_4 = this.nextMigration23__1.get_migrateStmts_i54q9j_k$()(this.sqlDatabase7__1);
                  suspendResult = build$execSqlAsync(this.connection6__1, copyToArray(this_4).slice(), this);
                  if (suspendResult === get_COROUTINE_SUSPENDED()) {
                    return suspendResult;
                  }
                  continue $sm;
                } else {
                  throw IllegalArgumentException_init_$Create$('Cannot use DataMigrationSync on JS');
                }
              }
            } else {
              throw IllegalStateException_init_$Create$('Need to migrate to version ' + ('' + this.dbImpl3__1.get_dbVersion_jd6ndd_k$() + ' from ' + this.currentDbVersion16__1 + ' - could not find next migration'));
            }

          case 18:
            this.set_state_rjd8d0_k$(20);
            continue $sm;
          case 19:
            this.set_state_rjd8d0_k$(20);
            continue $sm;
          case 20:
            this.currentDbVersion16__1 = this.nextMigration23__1.get_endVersion_algoai_k$();
            this.set_state_rjd8d0_k$(21);
            suspendResult = build$execSqlAsync(this.connection6__1, ['UPDATE _doorwayinfo SET dbVersion = ' + this.currentDbVersion16__1], this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 21:
            Napier_getInstance().d$default_a5agxr_k$('DatabaseBuilderJs: migrated up to ' + this.currentDbVersion16__1, VOID, Companion_getInstance_12().get_LOG_TAG_it8mba_k$());
            this.set_state_rjd8d0_k$(22);
            continue $sm;
          case 22:
            this.set_state_rjd8d0_k$(17);
            continue $sm;
          case 23:
            var tmp_24 = this;
            var this_5 = this.connection6__1;
            var tmp_25;
            if (this.dbWillBeMigrated20__1) {
              tmp_25 = this_5;
            } else {
              tmp_25 = null;
            }

            tmp_24.tmp6_safe_receiver25__1 = tmp_25;
            if (this.tmp6_safe_receiver25__1 == null) {
              this.WHEN_RESULT26__1 = null;
              this.set_state_rjd8d0_k$(25);
              continue $sm;
            } else {
              this.set_state_rjd8d0_k$(24);
              var this_6 = createSqliteTriggerAndReceiveViewSetupStatementList(this.dbMetaData1__1);
              suspendResult = build$execSqlAsync(this.tmp6_safe_receiver25__1, copyToArray(this_6).slice(), this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            }

          case 24:
            var tmp_26 = this;
            tmp_26.WHEN_RESULT26__1 = Unit_getInstance();
            this.set_state_rjd8d0_k$(25);
            continue $sm;
          case 25:
            this.set_state_rjd8d0_k$(26);
            continue $sm;
          case 26:
            Napier_getInstance().d$default_a5agxr_k$('DatabaseBuilderJs: Running onOpen callbacks...\n', VOID, Companion_getInstance_12().get_LOG_TAG_it8mba_k$());
            var tmp_27 = this;
            tmp_27.this27__1 = this._this__u8e3s4__1.callbacks_1;
            this.tmp0_iterator28__1 = this.this27__1.iterator_jk1svi_k$();
            this.set_state_rjd8d0_k$(27);
            continue $sm;
          case 27:
            if (!this.tmp0_iterator28__1.hasNext_bitz1p_k$()) {
              this.set_state_rjd8d0_k$(30);
              continue $sm;
            }

            this.element29__1 = this.tmp0_iterator28__1.next_20eer_k$();
            var tmp_28 = this;
            tmp_28.it30__1 = this.element29__1;
            this.tmp0_subject31__1 = this.it30__1;
            var tmp_29 = this.tmp0_subject31__1;
            if (isInterface(tmp_29, DoorDatabaseCallbackStatementList)) {
              this.set_state_rjd8d0_k$(28);
              var this_7 = this.it30__1.onOpen_58e9dd_k$(this.sqlDatabase7__1);
              suspendResult = build$execSqlAsync(this.connection6__1, copyToArray(this_7).slice(), this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            } else {
              throw IllegalArgumentException_init_$Create$('Cannot use sync callback on JS');
            }

          case 28:
            this.set_state_rjd8d0_k$(29);
            continue $sm;
          case 29:
            this.set_state_rjd8d0_k$(27);
            continue $sm;
          case 30:
            Napier_getInstance().d$default_a5agxr_k$('DatabaseBuilderJs: Setting up InvalidationTracker trigger SQL\n', VOID, Companion_getInstance_12().get_LOG_TAG_it8mba_k$());
            this.set_state_rjd8d0_k$(31);
            var this_8 = Companion_getInstance_3().generateCreateTriggersSql_julqud_k$(this.dbMetaData1__1.get_allTables_1jy9x9_k$(), false);
            suspendResult = build$execSqlAsync(this.connection6__1, copyToArray(this_8).slice(), this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 31:
            Napier_getInstance().d$default_a5agxr_k$('DatabaseBuilderJs: Setting up NodeEvent table and trigger SQL\n', VOID, Companion_getInstance_12().get_LOG_TAG_it8mba_k$());
            this.set_state_rjd8d0_k$(32);
            suspendResult = createNodeEventTableAndTrigger(this.connection6__1, this.dbMetaData1__1.get_allTables_1jy9x9_k$().contains_aljjnj_k$(NodeEventConstants_getInstance().get_OUTGOING_REPLICATION_TABLE_NAME_fm288p_k$()), false, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 32:
            Napier_getInstance().d$default_a5agxr_k$('DatabaseBuilderJs: Setting up change listener\n', VOID, Companion_getInstance_12().get_LOG_TAG_it8mba_k$());
            if (!(this.storageLocation0__1 === Companion_getInstance_21().get_LOCATION_MEMORY_rxk7vm_k$())) {
              new SaveToIndexedDbChangeListener(this.dbImpl3__1, this.dataSource2__1, this.dbMetaData1__1.get_replicateTableNames_6uibay_k$(), this._this__u8e3s4__1.builderOptions_1.get_saveToIndexedDbDelayTime_vryaqm_k$());
            }

            this.connection6__1.close_yn9xrc_k$();
            var tmp7_safe_receiver = this._this__u8e3s4__1.builderOptions_1.get_dbImplClasses_b09lsx_k$().get_replicateWrapperImplClass_h5k6md_k$();
            var tmp8_safe_receiver = tmp7_safe_receiver == null ? null : get_js(tmp7_safe_receiver);
            var tmp_30 = tmp8_safe_receiver == null ? null : createInstance(tmp8_safe_receiver, [this.dbImpl3__1, this._this__u8e3s4__1.builderOptions_1.get_nodeId_h7ho7a_k$(), this._this__u8e3s4__1.builderOptions_1.get_messageCallback_kxaem5_k$(), this._this__u8e3s4__1.builderOptions_1.get_logger_g9gejd_k$(), this._this__u8e3s4__1.builderOptions_1.get_dbName_c9i0qa_k$()]);
            var wrapperClass = (tmp_30 == null ? true : tmp_30 instanceof RoomDatabase) ? tmp_30 : THROW_CCE();
            Napier_getInstance().i$default_htnpp6_k$('Built database for: ' + this._this__u8e3s4__1.builderOptions_1.get_dbUrl_iq59m0_k$() + '\n', VOID, Companion_getInstance_12().get_LOG_TAG_it8mba_k$());
            return wrapperClass == null ? this.dbImpl3__1 : wrapperClass;
          case 33:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e_0 = $p;
        if (this.get_exceptionState_wflpxn_k$() === 33) {
          throw e_0;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e_0);
        }
      }
     while (true);
  };
  function $build$execSqlAsyncCOROUTINE$20(_this__u8e3s4, sqlStmts, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
    this.sqlStmts_1 = sqlStmts;
  }
  protoOf($build$execSqlAsyncCOROUTINE$20).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(8);
            this.set_state_rjd8d0_k$(1);
            continue $sm;
          case 1:
            var tmp_0 = this;
            tmp_0.this1__1 = this._this__u8e3s4__1.createStatement_cbd7tf_k$();
            this.set_state_rjd8d0_k$(2);
            continue $sm;
          case 2:
            this.set_state_rjd8d0_k$(3);
            continue $sm;
          case 3:
            this.set_exceptionState_fex74n_k$(7);
            this.set_exceptionState_fex74n_k$(6);
            var tmp_1 = this;
            tmp_1.stmt4__1 = this.this1__1;
            this.set_state_rjd8d0_k$(4);
            suspendResult = this.stmt4__1.executeUpdateAsyncJs_btupiy_k$(joinToString_0(this.sqlStmts_1, ';'), this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 4:
            this.tmp$ret$03__1 = suspendResult;
            this.set_exceptionState_fex74n_k$(8);
            this.set_state_rjd8d0_k$(5);
            var tmp_2 = this;
            continue $sm;
          case 5:
            var tmp_3 = this.tmp$ret$03__1;
            this.set_exceptionState_fex74n_k$(8);
            this.this1__1.close_yn9xrc_k$();
            this.tmp$ret$40__1 = tmp_3;
            this.set_state_rjd8d0_k$(10);
            continue $sm;
          case 6:
            this.set_exceptionState_fex74n_k$(7);
            var tmp_4 = this.get_exception_x0n6w6_k$();
            if (tmp_4 instanceof Exception) {
              var e = this.get_exception_x0n6w6_k$();
              var tmp_5 = this;
              throw e;
            } else {
              throw this.get_exception_x0n6w6_k$();
            }

          case 7:
            this.set_exceptionState_fex74n_k$(8);
            var t = this.get_exception_x0n6w6_k$();
            this.this1__1.close_yn9xrc_k$();
            throw t;
          case 8:
            throw this.get_exception_x0n6w6_k$();
          case 9:
            this.set_exceptionState_fex74n_k$(8);
            this.this1__1.close_yn9xrc_k$();
            if (false) {
              this.set_state_rjd8d0_k$(1);
              continue $sm;
            }

            this.set_state_rjd8d0_k$(10);
            continue $sm;
          case 10:
            return Unit_getInstance();
        }
      } catch ($p) {
        var e_0 = $p;
        if (this.get_exceptionState_wflpxn_k$() === 8) {
          throw e_0;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e_0);
        }
      }
     while (true);
  };
  function DatabaseBuilder(builderOptions) {
    Companion_getInstance_17();
    this.builderOptions_1 = builderOptions;
    var tmp = this;
    // Inline function 'kotlin.collections.mutableListOf' call
    tmp.callbacks_1 = ArrayList_init_$Create$();
    var tmp_0 = this;
    // Inline function 'kotlin.collections.mutableListOf' call
    tmp_0.migrationList_1 = ArrayList_init_$Create$();
  }
  protoOf(DatabaseBuilder).build_xhukzv_k$ = function ($completion) {
    var tmp = new $buildCOROUTINE$19(this, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(DatabaseBuilder).addMigrations_a2y08e_k$ = function (migrations) {
    addAll(this.migrationList_1, migrations);
    return this;
  };
  protoOf(DatabaseBuilder).addCallback_kclapb_k$ = function (callback) {
    Napier_getInstance().d$default_a5agxr_k$('DatabaseBuilderJs: Add Callback: ' + getKClassFromExpression(callback).get_simpleName_r6f8py_k$(), VOID, Companion_getInstance_12().get_LOG_TAG_it8mba_k$());
    this.callbacks_1.add_utx5q5_k$(callback);
    return this;
  };
  protoOf(DatabaseBuilder).queryTimeout_6wf75b_k$ = function (seconds) {
    this.builderOptions_1.set_jdbcQueryTimeout_vcgkx5_k$(seconds);
  };
  function DatabaseBuilderOptions(dbClass, dbImplClasses, nodeId, dbUrl, webWorkerPath, saveToIndexedDbDelayTime, messageCallback, jdbcQueryTimeout, dbName, logger, logWorkerMessages) {
    dbUrl = dbUrl === VOID ? 'indexeddb:' + ensureNotNull(dbClass.get_simpleName_r6f8py_k$()) : dbUrl;
    saveToIndexedDbDelayTime = saveToIndexedDbDelayTime === VOID ? new Long(200, 0) : saveToIndexedDbDelayTime;
    messageCallback = messageCallback === VOID ? new DefaultDoorMessageCallback() : messageCallback;
    jdbcQueryTimeout = jdbcQueryTimeout === VOID ? 10 : jdbcQueryTimeout;
    dbName = dbName === VOID ? dbUrl : dbName;
    logger = logger === VOID ? new NapierDoorLogger() : logger;
    logWorkerMessages = logWorkerMessages === VOID ? false : logWorkerMessages;
    this.dbClass_1 = dbClass;
    this.dbImplClasses_1 = dbImplClasses;
    this.nodeId_1 = nodeId;
    this.dbUrl_1 = dbUrl;
    this.webWorkerPath_1 = webWorkerPath;
    this.saveToIndexedDbDelayTime_1 = saveToIndexedDbDelayTime;
    this.messageCallback_1 = messageCallback;
    this.jdbcQueryTimeout_1 = jdbcQueryTimeout;
    this.dbName_1 = dbName;
    this.logger_1 = logger;
    this.logWorkerMessages_1 = logWorkerMessages;
  }
  protoOf(DatabaseBuilderOptions).set_dbClass_qpzdln_k$ = function (_set____db54di) {
    this.dbClass_1 = _set____db54di;
  };
  protoOf(DatabaseBuilderOptions).get_dbClass_ov3elt_k$ = function () {
    return this.dbClass_1;
  };
  protoOf(DatabaseBuilderOptions).set_dbImplClasses_ynpo62_k$ = function (_set____db54di) {
    this.dbImplClasses_1 = _set____db54di;
  };
  protoOf(DatabaseBuilderOptions).get_dbImplClasses_b09lsx_k$ = function () {
    return this.dbImplClasses_1;
  };
  protoOf(DatabaseBuilderOptions).get_nodeId_h7ho7a_k$ = function () {
    return this.nodeId_1;
  };
  protoOf(DatabaseBuilderOptions).set_dbUrl_c4zumi_k$ = function (_set____db54di) {
    this.dbUrl_1 = _set____db54di;
  };
  protoOf(DatabaseBuilderOptions).get_dbUrl_iq59m0_k$ = function () {
    return this.dbUrl_1;
  };
  protoOf(DatabaseBuilderOptions).set_webWorkerPath_sos6kw_k$ = function (_set____db54di) {
    this.webWorkerPath_1 = _set____db54di;
  };
  protoOf(DatabaseBuilderOptions).get_webWorkerPath_ilxjim_k$ = function () {
    return this.webWorkerPath_1;
  };
  protoOf(DatabaseBuilderOptions).get_saveToIndexedDbDelayTime_vryaqm_k$ = function () {
    return this.saveToIndexedDbDelayTime_1;
  };
  protoOf(DatabaseBuilderOptions).get_messageCallback_kxaem5_k$ = function () {
    return this.messageCallback_1;
  };
  protoOf(DatabaseBuilderOptions).set_jdbcQueryTimeout_vcgkx5_k$ = function (_set____db54di) {
    this.jdbcQueryTimeout_1 = _set____db54di;
  };
  protoOf(DatabaseBuilderOptions).get_jdbcQueryTimeout_rk5wkj_k$ = function () {
    return this.jdbcQueryTimeout_1;
  };
  protoOf(DatabaseBuilderOptions).set_dbName_5mqzek_k$ = function (_set____db54di) {
    this.dbName_1 = _set____db54di;
  };
  protoOf(DatabaseBuilderOptions).get_dbName_c9i0qa_k$ = function () {
    return this.dbName_1;
  };
  protoOf(DatabaseBuilderOptions).set_logger_i89g1p_k$ = function (_set____db54di) {
    this.logger_1 = _set____db54di;
  };
  protoOf(DatabaseBuilderOptions).get_logger_g9gejd_k$ = function () {
    return this.logger_1;
  };
  protoOf(DatabaseBuilderOptions).set_logWorkerMessages_s20uv8_k$ = function (_set____db54di) {
    this.logWorkerMessages_1 = _set____db54di;
  };
  protoOf(DatabaseBuilderOptions).get_logWorkerMessages_j9kuor_k$ = function () {
    return this.logWorkerMessages_1;
  };
  protoOf(DatabaseBuilderOptions).component1_7eebsc_k$ = function () {
    return this.dbClass_1;
  };
  protoOf(DatabaseBuilderOptions).component2_7eebsb_k$ = function () {
    return this.dbImplClasses_1;
  };
  protoOf(DatabaseBuilderOptions).component3_7eebsa_k$ = function () {
    return this.nodeId_1;
  };
  protoOf(DatabaseBuilderOptions).component4_7eebs9_k$ = function () {
    return this.dbUrl_1;
  };
  protoOf(DatabaseBuilderOptions).component5_7eebs8_k$ = function () {
    return this.webWorkerPath_1;
  };
  protoOf(DatabaseBuilderOptions).component6_7eebs7_k$ = function () {
    return this.saveToIndexedDbDelayTime_1;
  };
  protoOf(DatabaseBuilderOptions).component7_7eebs6_k$ = function () {
    return this.messageCallback_1;
  };
  protoOf(DatabaseBuilderOptions).component8_7eebs5_k$ = function () {
    return this.jdbcQueryTimeout_1;
  };
  protoOf(DatabaseBuilderOptions).component9_7eebs4_k$ = function () {
    return this.dbName_1;
  };
  protoOf(DatabaseBuilderOptions).component10_gazzfo_k$ = function () {
    return this.logger_1;
  };
  protoOf(DatabaseBuilderOptions).component11_gazzfn_k$ = function () {
    return this.logWorkerMessages_1;
  };
  protoOf(DatabaseBuilderOptions).copy_goicjw_k$ = function (dbClass, dbImplClasses, nodeId, dbUrl, webWorkerPath, saveToIndexedDbDelayTime, messageCallback, jdbcQueryTimeout, dbName, logger, logWorkerMessages) {
    return new DatabaseBuilderOptions(dbClass, dbImplClasses, nodeId, dbUrl, webWorkerPath, saveToIndexedDbDelayTime, messageCallback, jdbcQueryTimeout, dbName, logger, logWorkerMessages);
  };
  protoOf(DatabaseBuilderOptions).copy$default_t51wy8_k$ = function (dbClass, dbImplClasses, nodeId, dbUrl, webWorkerPath, saveToIndexedDbDelayTime, messageCallback, jdbcQueryTimeout, dbName, logger, logWorkerMessages, $super) {
    dbClass = dbClass === VOID ? this.dbClass_1 : dbClass;
    dbImplClasses = dbImplClasses === VOID ? this.dbImplClasses_1 : dbImplClasses;
    nodeId = nodeId === VOID ? this.nodeId_1 : nodeId;
    dbUrl = dbUrl === VOID ? this.dbUrl_1 : dbUrl;
    webWorkerPath = webWorkerPath === VOID ? this.webWorkerPath_1 : webWorkerPath;
    saveToIndexedDbDelayTime = saveToIndexedDbDelayTime === VOID ? this.saveToIndexedDbDelayTime_1 : saveToIndexedDbDelayTime;
    messageCallback = messageCallback === VOID ? this.messageCallback_1 : messageCallback;
    jdbcQueryTimeout = jdbcQueryTimeout === VOID ? this.jdbcQueryTimeout_1 : jdbcQueryTimeout;
    dbName = dbName === VOID ? this.dbName_1 : dbName;
    logger = logger === VOID ? this.logger_1 : logger;
    logWorkerMessages = logWorkerMessages === VOID ? this.logWorkerMessages_1 : logWorkerMessages;
    return $super === VOID ? this.copy_goicjw_k$(dbClass, dbImplClasses, nodeId, dbUrl, webWorkerPath, saveToIndexedDbDelayTime, messageCallback, jdbcQueryTimeout, dbName, logger, logWorkerMessages) : $super.copy_goicjw_k$.call(this, dbClass, dbImplClasses, nodeId, dbUrl, webWorkerPath, saveToIndexedDbDelayTime, messageCallback, jdbcQueryTimeout, dbName, logger, logWorkerMessages);
  };
  protoOf(DatabaseBuilderOptions).toString = function () {
    return 'DatabaseBuilderOptions(dbClass=' + this.dbClass_1 + ', dbImplClasses=' + this.dbImplClasses_1 + ', nodeId=' + this.nodeId_1.toString() + ', dbUrl=' + this.dbUrl_1 + ', webWorkerPath=' + this.webWorkerPath_1 + ', saveToIndexedDbDelayTime=' + this.saveToIndexedDbDelayTime_1.toString() + ', messageCallback=' + this.messageCallback_1 + ', jdbcQueryTimeout=' + this.jdbcQueryTimeout_1 + ', dbName=' + this.dbName_1 + ', logger=' + this.logger_1 + ', logWorkerMessages=' + this.logWorkerMessages_1 + ')';
  };
  protoOf(DatabaseBuilderOptions).hashCode = function () {
    var result = this.dbClass_1.hashCode();
    result = imul(result, 31) + hashCode(this.dbImplClasses_1) | 0;
    result = imul(result, 31) + this.nodeId_1.hashCode() | 0;
    result = imul(result, 31) + getStringHashCode(this.dbUrl_1) | 0;
    result = imul(result, 31) + getStringHashCode(this.webWorkerPath_1) | 0;
    result = imul(result, 31) + this.saveToIndexedDbDelayTime_1.hashCode() | 0;
    result = imul(result, 31) + hashCode(this.messageCallback_1) | 0;
    result = imul(result, 31) + this.jdbcQueryTimeout_1 | 0;
    result = imul(result, 31) + getStringHashCode(this.dbName_1) | 0;
    result = imul(result, 31) + hashCode(this.logger_1) | 0;
    result = imul(result, 31) + getBooleanHashCode(this.logWorkerMessages_1) | 0;
    return result;
  };
  protoOf(DatabaseBuilderOptions).equals = function (other) {
    if (this === other)
      return true;
    if (!(other instanceof DatabaseBuilderOptions))
      return false;
    var tmp0_other_with_cast = other instanceof DatabaseBuilderOptions ? other : THROW_CCE();
    if (!this.dbClass_1.equals(tmp0_other_with_cast.dbClass_1))
      return false;
    if (!equals(this.dbImplClasses_1, tmp0_other_with_cast.dbImplClasses_1))
      return false;
    if (!this.nodeId_1.equals(tmp0_other_with_cast.nodeId_1))
      return false;
    if (!(this.dbUrl_1 === tmp0_other_with_cast.dbUrl_1))
      return false;
    if (!(this.webWorkerPath_1 === tmp0_other_with_cast.webWorkerPath_1))
      return false;
    if (!this.saveToIndexedDbDelayTime_1.equals(tmp0_other_with_cast.saveToIndexedDbDelayTime_1))
      return false;
    if (!equals(this.messageCallback_1, tmp0_other_with_cast.messageCallback_1))
      return false;
    if (!(this.jdbcQueryTimeout_1 === tmp0_other_with_cast.jdbcQueryTimeout_1))
      return false;
    if (!(this.dbName_1 === tmp0_other_with_cast.dbName_1))
      return false;
    if (!equals(this.logger_1, tmp0_other_with_cast.logger_1))
      return false;
    if (!(this.logWorkerMessages_1 === tmp0_other_with_cast.logWorkerMessages_1))
      return false;
    return true;
  };
  function _get_doorUriInfo__o3gwwr($this) {
    return $this.doorUriInfo_1;
  }
  function DoorUriProps(uri, fileName, mimeType) {
    this.uri_1 = uri;
    this.fileName_1 = fileName;
    this.mimeType_1 = mimeType;
  }
  protoOf(DoorUriProps).get_uri_18iuil_k$ = function () {
    return this.uri_1;
  };
  protoOf(DoorUriProps).get_fileName_r258mo_k$ = function () {
    return this.fileName_1;
  };
  protoOf(DoorUriProps).get_mimeType_g7ccbb_k$ = function () {
    return this.mimeType_1;
  };
  protoOf(DoorUriProps).component1_7eebsc_k$ = function () {
    return this.uri_1;
  };
  protoOf(DoorUriProps).component2_7eebsb_k$ = function () {
    return this.fileName_1;
  };
  protoOf(DoorUriProps).component3_7eebsa_k$ = function () {
    return this.mimeType_1;
  };
  protoOf(DoorUriProps).copy_37sg9j_k$ = function (uri, fileName, mimeType) {
    return new DoorUriProps(uri, fileName, mimeType);
  };
  protoOf(DoorUriProps).copy$default_pis2v1_k$ = function (uri, fileName, mimeType, $super) {
    uri = uri === VOID ? this.uri_1 : uri;
    fileName = fileName === VOID ? this.fileName_1 : fileName;
    mimeType = mimeType === VOID ? this.mimeType_1 : mimeType;
    return $super === VOID ? this.copy_37sg9j_k$(uri, fileName, mimeType) : $super.copy_37sg9j_k$.call(this, uri, fileName, mimeType);
  };
  protoOf(DoorUriProps).toString = function () {
    return 'DoorUriProps(uri=' + this.uri_1 + ', fileName=' + this.fileName_1 + ', mimeType=' + this.mimeType_1 + ')';
  };
  protoOf(DoorUriProps).hashCode = function () {
    var result = getStringHashCode(this.uri_1);
    result = imul(result, 31) + (this.fileName_1 == null ? 0 : getStringHashCode(this.fileName_1)) | 0;
    result = imul(result, 31) + (this.mimeType_1 == null ? 0 : getStringHashCode(this.mimeType_1)) | 0;
    return result;
  };
  protoOf(DoorUriProps).equals = function (other) {
    if (this === other)
      return true;
    if (!(other instanceof DoorUriProps))
      return false;
    var tmp0_other_with_cast = other instanceof DoorUriProps ? other : THROW_CCE();
    if (!(this.uri_1 === tmp0_other_with_cast.uri_1))
      return false;
    if (!(this.fileName_1 == tmp0_other_with_cast.fileName_1))
      return false;
    if (!(this.mimeType_1 == tmp0_other_with_cast.mimeType_1))
      return false;
    return true;
  };
  function Companion_15() {
    Companion_instance_15 = this;
    var tmp = this;
    // Inline function 'kotlin.collections.mutableMapOf' call
    tmp.doorUriInfo_1 = LinkedHashMap_init_$Create$();
  }
  protoOf(Companion_15).parse_pc1q8p_k$ = function (uriString) {
    return new DoorUri(new URL(uriString));
  };
  protoOf(Companion_15).createLocalUri_7qzolo_k$ = function (blob, filename, mimeType) {
    var localUrl = URL.createObjectURL(blob);
    // Inline function 'kotlin.collections.set' call
    var this_0 = this.doorUriInfo_1;
    var value = new DoorUriProps(localUrl, filename, mimeType);
    this_0.put_4fpzoq_k$(localUrl, value);
    return new DoorUri(new URL(localUrl));
  };
  protoOf(Companion_15).createLocalUri$default_zarwb6_k$ = function (blob, filename, mimeType, $super) {
    mimeType = mimeType === VOID ? null : mimeType;
    return $super === VOID ? this.createLocalUri_7qzolo_k$(blob, filename, mimeType) : $super.createLocalUri_7qzolo_k$.call(this, blob, filename, mimeType);
  };
  protoOf(Companion_15).getDoorUriProps_xza1bi_k$ = function (uri) {
    return this.doorUriInfo_1.get_wei43m_k$(uri);
  };
  protoOf(Companion_15).revokeLocalUri_s7frvo_k$ = function (localUri) {
    URL.revokeObjectURL(localUri.toString());
    this.doorUriInfo_1.remove_gppy8k_k$(localUri.toString());
  };
  var Companion_instance_15;
  function Companion_getInstance_18() {
    if (Companion_instance_15 == null)
      new Companion_15();
    return Companion_instance_15;
  }
  function DoorUri(uri) {
    Companion_getInstance_18();
    this.uri_1 = uri;
  }
  protoOf(DoorUri).get_uri_18iuil_k$ = function () {
    return this.uri_1;
  };
  protoOf(DoorUri).getFileName_yox9a6_k$ = function (context, $completion) {
    var tmp0_safe_receiver = Companion_getInstance_18().doorUriInfo_1.get_wei43m_k$(toString(this.uri_1));
    var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.fileName_1;
    return tmp1_elvis_lhs == null ? substringAfterLast(this.uri_1.pathname, '/') : tmp1_elvis_lhs;
  };
  protoOf(DoorUri).toString = function () {
    return toString(this.uri_1);
  };
  protoOf(DoorUri).equals = function (other) {
    var tmp0_safe_receiver = other instanceof DoorUri ? other : null;
    return equals(tmp0_safe_receiver == null ? null : tmp0_safe_receiver.uri_1, this.uri_1);
  };
  protoOf(DoorUri).hashCode = function () {
    return getStringHashCode(toString(this.uri_1));
  };
  function JdbcArrayProxy(typeName, objects) {
    JdbcArrayProxyCommon.call(this, typeName, objects);
  }
  protoOf(JdbcArrayProxy).free_au51lw_k$ = function () {
  };
  function _set_closed__kdb0et_0($this, _set____db54di) {
    $this.closed_1 = _set____db54di;
  }
  function _get_closed__iwkfs1_0($this) {
    return $this.closed_1;
  }
  function PreparedStatementArrayProxy(query, connection) {
    PreparedStatementArrayProxyCommon.call(this, query, connection);
    this.closed_1 = false;
  }
  protoOf(PreparedStatementArrayProxy).executeUpdate_k6x04k_k$ = function (sql) {
    return this.prepareStatement_ieuhug_k$().executeUpdate_fapcbi_k$();
  };
  protoOf(PreparedStatementArrayProxy).executeUpdateAsync_1e6m2t_k$ = function ($completion) {
    return this.prepareStatement_ieuhug_k$().executeUpdateAsync_1e6m2t_k$($completion);
  };
  protoOf(PreparedStatementArrayProxy).executeUpdateAsyncJs_btupiy_k$ = function (sql, $completion) {
    return this.prepareStatement_ieuhug_k$().executeUpdateAsyncJs_btupiy_k$(sql, $completion);
  };
  protoOf(PreparedStatementArrayProxy).executeQueryAsyncInt_j35d75_k$ = function ($completion) {
    return this.prepareStatement_ieuhug_k$().executeQueryAsyncInt_j35d75_k$($completion);
  };
  protoOf(PreparedStatementArrayProxy).getGeneratedKeys_aewui5_k$ = function () {
    throw new SQLException('PreparedStatementArrayProxy does not support getting generated keys', null);
  };
  protoOf(PreparedStatementArrayProxy).close_yn9xrc_k$ = function () {
    this.closed_1 = true;
  };
  protoOf(PreparedStatementArrayProxy).isClosed_baxhhm_k$ = function () {
    return this.closed_1;
  };
  protoOf(PreparedStatementArrayProxy).getConnection_hr2oto_k$ = function () {
    return this.get_connectionInternal_tlp70c_k$();
  };
  function Builder(context, endpoint, auth, nodeId, httpClient, json, logger, dbName) {
    this.context_1 = context;
    this.endpoint_1 = endpoint;
    this.auth_1 = auth;
    this.nodeId_1 = nodeId;
    this.httpClient_1 = httpClient;
    this.json_1 = json;
    this.logger_1 = logger;
    this.dbName_1 = dbName;
  }
  protoOf(Builder).get_context_h02k06_k$ = function () {
    return this.context_1;
  };
  protoOf(Builder).get_endpoint_30bvdu_k$ = function () {
    return this.endpoint_1;
  };
  protoOf(Builder).get_auth_woj2sx_k$ = function () {
    return this.auth_1;
  };
  protoOf(Builder).get_nodeId_h7ho7a_k$ = function () {
    return this.nodeId_1;
  };
  protoOf(Builder).get_httpClient_cdum84_k$ = function () {
    return this.httpClient_1;
  };
  protoOf(Builder).get_json_woos35_k$ = function () {
    return this.json_1;
  };
  protoOf(Builder).get_logger_g9gejd_k$ = function () {
    return this.logger_1;
  };
  protoOf(Builder).get_dbName_c9i0qa_k$ = function () {
    return this.dbName_1;
  };
  protoOf(Builder).build_1k0s4u_k$ = function () {
    return new RepositoryConfig(this.context_1, this.endpoint_1, this.auth_1, this.nodeId_1, this.httpClient_1, this.json_1, this.logger_1, this.dbName_1);
  };
  function RepositoryConfig$Companion$repositoryConfig$lambda($this$Json) {
    $this$Json.set_encodeDefaults_c5evsg_k$(true);
    return Unit_getInstance();
  }
  function RepositoryConfig$Companion$repositoryConfig$lambda_0($this$null) {
    return Unit_getInstance();
  }
  function Companion_16() {
    Companion_instance_16 = this;
  }
  protoOf(Companion_16).repositoryConfig_yi0yu_k$ = function (context, endpoint, auth, nodeId, httpClient, logger, dbName, json, block) {
    var builder = new Builder(context, endpoint, auth, nodeId, httpClient, json, logger, dbName);
    block(builder);
    return builder.build_1k0s4u_k$();
  };
  protoOf(Companion_16).repositoryConfig$default_5l7wp9_k$ = function (context, endpoint, auth, nodeId, httpClient, logger, dbName, json, block, $super) {
    logger = logger === VOID ? new NapierDoorLogger() : logger;
    dbName = dbName === VOID ? endpoint : dbName;
    var tmp;
    if (json === VOID) {
      tmp = Json(VOID, RepositoryConfig$Companion$repositoryConfig$lambda);
    } else {
      tmp = json;
    }
    json = tmp;
    var tmp_0;
    if (block === VOID) {
      tmp_0 = RepositoryConfig$Companion$repositoryConfig$lambda_0;
    } else {
      tmp_0 = block;
    }
    block = tmp_0;
    return $super === VOID ? this.repositoryConfig_yi0yu_k$(context, endpoint, auth, nodeId, httpClient, logger, dbName, json, block) : $super.repositoryConfig_yi0yu_k$.call(this, context, endpoint, auth, nodeId, httpClient, logger, dbName, json, block);
  };
  var Companion_instance_16;
  function Companion_getInstance_19() {
    if (Companion_instance_16 == null)
      new Companion_16();
    return Companion_instance_16;
  }
  function RepositoryConfig(context, endpoint, auth, nodeId, httpClient, json, logger, dbName) {
    Companion_getInstance_19();
    this.context_1 = context;
    this.endpoint_1 = endpoint;
    this.auth_1 = auth;
    this.nodeId_1 = nodeId;
    this.httpClient_1 = httpClient;
    this.json_1 = json;
    this.logger_1 = logger;
    this.dbName_1 = dbName;
  }
  protoOf(RepositoryConfig).get_context_h02k06_k$ = function () {
    return this.context_1;
  };
  protoOf(RepositoryConfig).get_endpoint_30bvdu_k$ = function () {
    return this.endpoint_1;
  };
  protoOf(RepositoryConfig).get_auth_woj2sx_k$ = function () {
    return this.auth_1;
  };
  protoOf(RepositoryConfig).get_nodeId_h7ho7a_k$ = function () {
    return this.nodeId_1;
  };
  protoOf(RepositoryConfig).get_httpClient_cdum84_k$ = function () {
    return this.httpClient_1;
  };
  protoOf(RepositoryConfig).get_json_woos35_k$ = function () {
    return this.json_1;
  };
  protoOf(RepositoryConfig).get_logger_g9gejd_k$ = function () {
    return this.logger_1;
  };
  protoOf(RepositoryConfig).get_dbName_c9i0qa_k$ = function () {
    return this.dbName_1;
  };
  function _get_datasource__pefkrq($this) {
    return $this.datasource_1;
  }
  function _get_changeListenerRequest__wc2pja($this) {
    return $this.changeListenerRequest_1;
  }
  function _get_eventCollator__ffqyzv($this) {
    return $this.eventCollator_1;
  }
  function SaveToIndexedDbChangeListener$eventCollator$slambda($database, this$0, resultContinuation) {
    this.$database_1 = $database;
    this.this$0__1 = this$0;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(SaveToIndexedDbChangeListener$eventCollator$slambda).invoke_zhr0un_k$ = function (it, $completion) {
    var tmp = this.create_5ir2kr_k$(it, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(SaveToIndexedDbChangeListener$eventCollator$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_zhr0un_k$((!(p1 == null) ? isInterface(p1, List) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(SaveToIndexedDbChangeListener$eventCollator$slambda).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            Napier_getInstance().d$default_a5agxr_k$('Save database ' + this.$database_1 + ' to indexedDb', VOID, Companion_getInstance_12().get_LOG_TAG_it8mba_k$());
            this.set_state_rjd8d0_k$(1);
            suspendResult = this.this$0__1.datasource_1.saveDatabaseToIndexedDb_xd3smc_k$(this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            return Unit_getInstance();
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(SaveToIndexedDbChangeListener$eventCollator$slambda).create_5ir2kr_k$ = function (it, completion) {
    var i = new SaveToIndexedDbChangeListener$eventCollator$slambda(this.$database_1, this.this$0__1, completion);
    i.it_1 = it;
    return i;
  };
  protoOf(SaveToIndexedDbChangeListener$eventCollator$slambda).create_wyq9v6_k$ = function (value, completion) {
    return this.create_5ir2kr_k$((!(value == null) ? isInterface(value, List) : false) ? value : THROW_CCE(), completion);
  };
  function SaveToIndexedDbChangeListener$eventCollator$slambda_0($database, this$0, resultContinuation) {
    var i = new SaveToIndexedDbChangeListener$eventCollator$slambda($database, this$0, resultContinuation);
    var l = function (it, $completion) {
      return i.invoke_zhr0un_k$(it, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function SaveToIndexedDbChangeListener$1($tablesToListen, this$0) {
    this.this$0__1 = this$0;
    // Inline function 'kotlin.collections.toTypedArray' call
    var tmp$ret$0 = copyToArray($tablesToListen);
    InvalidationTrackerObserver.call(this, tmp$ret$0);
  }
  protoOf(SaveToIndexedDbChangeListener$1).onInvalidated_v59v8q_k$ = function (tables) {
    this.this$0__1.eventCollator_1.receiveEvent_cmiqeg_k$(toList_0(tables));
  };
  function SaveToIndexedDbChangeListener(database, datasource, tablesToListen, maxWaitTime) {
    this.datasource_1 = datasource;
    var tmp = this;
    var tmp_0 = GlobalScope_getInstance();
    tmp.eventCollator_1 = new DoorEventCollator(maxWaitTime, tmp_0, SaveToIndexedDbChangeListener$eventCollator$slambda_0(database, this, null));
    var tmp_1 = this;
    tmp_1.changeListenerRequest_1 = new SaveToIndexedDbChangeListener$1(tablesToListen, this);
    database.get_invalidationTracker_tp0k9d_k$().addObserver_wpl76o_k$(this.changeListenerRequest_1);
  }
  function prepareStatement(_this__u8e3s4, db, stmtConfig) {
    var tmp;
    if (stmtConfig.get_hasListParams_eih2hh_k$()) {
      tmp = new PreparedStatementArrayProxy(stmtConfig.get_sql_18iw0r_k$(), _this__u8e3s4);
    } else {
      tmp = _this__u8e3s4.prepareStatement_w7z552_k$(stmtConfig.get_sql_18iw0r_k$(), stmtConfig.get_generatedKeys_rooagq_k$());
    }
    return tmp;
  }
  function dbType(_this__u8e3s4) {
    return Companion_getInstance_5().get_SQLITE_3yc5jp_k$();
  }
  function withDoorTransactionAsync(_this__u8e3s4, transactionMode, block, $completion) {
    transactionMode = transactionMode === VOID ? TransactionMode_READ_WRITE_getInstance() : transactionMode;
    var tmp = get_rootDatabase(_this__u8e3s4);
    var tmp_0 = (isInterface(tmp, RoomJdbcImpl) ? tmp : THROW_CCE()).get_jdbcImplHelper_iauze6_k$();
    var tmp_1 = transactionMode.equals(TransactionMode_READ_ONLY_getInstance());
    return tmp_0.useConnectionAsync_98htgj_k$(tmp_1, withDoorTransactionAsync$slambda_0(block, _this__u8e3s4, null), $completion);
  }
  function doorDatabaseMetadata(_this__u8e3s4) {
    return Companion_getInstance_17().lookupImplementations_qvwvxm_k$(_this__u8e3s4).get_metadata_vs95vc_k$();
  }
  function withDoorTransactionAsync$slambda($block, $this_withDoorTransactionAsync, resultContinuation) {
    this.$block_1 = $block;
    this.$this_withDoorTransactionAsync_1 = $this_withDoorTransactionAsync;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(withDoorTransactionAsync$slambda).invoke_8ggh1u_k$ = function (it, $completion) {
    var tmp = this.create_1rn91a_k$(it, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(withDoorTransactionAsync$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_8ggh1u_k$((!(p1 == null) ? isInterface(p1, Connection) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(withDoorTransactionAsync$slambda).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            this.set_state_rjd8d0_k$(1);
            suspendResult = this.$block_1(this.$this_withDoorTransactionAsync_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            return suspendResult;
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(withDoorTransactionAsync$slambda).create_1rn91a_k$ = function (it, completion) {
    var i = new withDoorTransactionAsync$slambda(this.$block_1, this.$this_withDoorTransactionAsync_1, completion);
    i.it_1 = it;
    return i;
  };
  protoOf(withDoorTransactionAsync$slambda).create_wyq9v6_k$ = function (value, completion) {
    return this.create_1rn91a_k$((!(value == null) ? isInterface(value, Connection) : false) ? value : THROW_CCE(), completion);
  };
  function withDoorTransactionAsync$slambda_0($block, $this_withDoorTransactionAsync, resultContinuation) {
    var i = new withDoorTransactionAsync$slambda($block, $this_withDoorTransactionAsync, resultContinuation);
    var l = function (it, $completion) {
      return i.invoke_8ggh1u_k$(it, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function createInstance(_this__u8e3s4, args) {
    var ctor = _this__u8e3s4;
    // Inline function 'kotlin.collections.toTypedArray' call
    var this_0 = plus_1(listOf(null), args);
    var argsArray = copyToArray(this_0);
    return new (Function.prototype.bind.apply(ctor, argsArray))();
  }
  function mutableLinkedListOf(items) {
    // Inline function 'kotlin.also' call
    // Inline function 'kotlin.collections.mutableListOf' call
    var this_0 = ArrayList_init_$Create$();
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'com.ustadmobile.door.ext.mutableLinkedListOf.<anonymous>' call
    addAll(this_0, items);
    return this_0;
  }
  function concurrentSafeListOf(items) {
    // Inline function 'kotlin.also' call
    // Inline function 'kotlin.collections.mutableListOf' call
    var this_0 = ArrayList_init_$Create$();
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'com.ustadmobile.door.ext.concurrentSafeListOf.<anonymous>' call
    addAll(this_0, items);
    return this_0;
  }
  function concurrentSafeMapOf(items) {
    // Inline function 'kotlin.also' call
    // Inline function 'kotlin.collections.mutableMapOf' call
    var this_0 = LinkedHashMap_init_$Create$();
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'com.ustadmobile.door.ext.concurrentSafeMapOf.<anonymous>' call
    putAll(this_0, items);
    return this_0;
  }
  function urlEncode(_this__u8e3s4) {
    return encodeURIComponent(_this__u8e3s4);
  }
  function Array_0() {
  }
  function Connection() {
  }
  function DataSource() {
  }
  function DatabaseMetadata() {
  }
  function PreparedStatement() {
  }
  function ResultSet() {
  }
  function ResultSetMetaData() {
  }
  function SQLException(message, cause) {
    Exception_init_$Init$(message, cause, this);
    captureStack(this, SQLException);
  }
  function Statement() {
  }
  function mutableLinkedListOf_0(items) {
    // Inline function 'kotlin.collections.mutableListOf' call
    return ArrayList_init_$Create$();
  }
  function executeUpdateAsyncKmp(_this__u8e3s4, $completion) {
    return _this__u8e3s4.executeUpdateAsync_1e6m2t_k$($completion);
  }
  function executeUpdateAsync(_this__u8e3s4, sql, $completion) {
    return _this__u8e3s4.executeUpdateAsyncJs_btupiy_k$(sql, $completion);
  }
  function executeQueryAsyncKmp(_this__u8e3s4, $completion) {
    return _this__u8e3s4.executeQueryAsyncInt_j35d75_k$($completion);
  }
  function RoomDatabase$execSQLBatchAsyncJs$slambda($sqlStatements, resultContinuation) {
    this.$sqlStatements_1 = $sqlStatements;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(RoomDatabase$execSQLBatchAsyncJs$slambda).invoke_tjufio_k$ = function (connection, $completion) {
    var tmp = this.create_1rn91a_k$(connection, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(RoomDatabase$execSQLBatchAsyncJs$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_tjufio_k$((!(p1 == null) ? isInterface(p1, Connection) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(RoomDatabase$execSQLBatchAsyncJs$slambda).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(8);
            this.set_state_rjd8d0_k$(1);
            continue $sm;
          case 1:
            var tmp_0 = this;
            tmp_0.this1__1 = this.connection_1.createStatement_cbd7tf_k$();
            this.set_state_rjd8d0_k$(2);
            continue $sm;
          case 2:
            this.set_state_rjd8d0_k$(3);
            continue $sm;
          case 3:
            this.set_exceptionState_fex74n_k$(7);
            this.set_exceptionState_fex74n_k$(6);
            var tmp_1 = this;
            tmp_1.statement4__1 = this.this1__1;
            this.set_state_rjd8d0_k$(4);
            suspendResult = this.statement4__1.executeUpdateAsyncJs_btupiy_k$(joinToString_0(this.$sqlStatements_1, ';'), this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 4:
            this.tmp$ret$03__1 = suspendResult;
            this.set_exceptionState_fex74n_k$(8);
            this.set_state_rjd8d0_k$(5);
            var tmp_2 = this;
            continue $sm;
          case 5:
            var tmp_3 = this.tmp$ret$03__1;
            this.set_exceptionState_fex74n_k$(8);
            this.this1__1.close_yn9xrc_k$();
            this.tmp$ret$40__1 = tmp_3;
            this.set_state_rjd8d0_k$(10);
            continue $sm;
          case 6:
            this.set_exceptionState_fex74n_k$(7);
            var tmp_4 = this.get_exception_x0n6w6_k$();
            if (tmp_4 instanceof Exception) {
              var e = this.get_exception_x0n6w6_k$();
              var tmp_5 = this;
              throw e;
            } else {
              throw this.get_exception_x0n6w6_k$();
            }

          case 7:
            this.set_exceptionState_fex74n_k$(8);
            var t = this.get_exception_x0n6w6_k$();
            this.this1__1.close_yn9xrc_k$();
            throw t;
          case 8:
            throw this.get_exception_x0n6w6_k$();
          case 9:
            this.set_exceptionState_fex74n_k$(8);
            this.this1__1.close_yn9xrc_k$();
            if (false) {
              this.set_state_rjd8d0_k$(1);
              continue $sm;
            }

            this.set_state_rjd8d0_k$(10);
            continue $sm;
          case 10:
            return this.tmp$ret$40__1;
        }
      } catch ($p) {
        var e_0 = $p;
        if (this.get_exceptionState_wflpxn_k$() === 8) {
          throw e_0;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e_0);
        }
      }
     while (true);
  };
  protoOf(RoomDatabase$execSQLBatchAsyncJs$slambda).create_1rn91a_k$ = function (connection, completion) {
    var i = new RoomDatabase$execSQLBatchAsyncJs$slambda(this.$sqlStatements_1, completion);
    i.connection_1 = connection;
    return i;
  };
  protoOf(RoomDatabase$execSQLBatchAsyncJs$slambda).create_wyq9v6_k$ = function (value, completion) {
    return this.create_1rn91a_k$((!(value == null) ? isInterface(value, Connection) : false) ? value : THROW_CCE(), completion);
  };
  function RoomDatabase$execSQLBatchAsyncJs$slambda_0($sqlStatements, resultContinuation) {
    var i = new RoomDatabase$execSQLBatchAsyncJs$slambda($sqlStatements, resultContinuation);
    var l = function (connection, $completion) {
      return i.invoke_tjufio_k$(connection, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function $execSQLBatchAsyncJsCOROUTINE$21(_this__u8e3s4, sqlStatements, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
    this.sqlStatements_1 = sqlStatements;
  }
  protoOf($execSQLBatchAsyncJsCOROUTINE$21).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            this.set_state_rjd8d0_k$(1);
            var tmp_0 = this._this__u8e3s4__1;
            var tmp_1 = (isInterface(tmp_0, RoomJdbcImpl) ? tmp_0 : THROW_CCE()).get_jdbcImplHelper_iauze6_k$();
            suspendResult = tmp_1.useConnectionAsync_y1du5w_k$(RoomDatabase$execSQLBatchAsyncJs$slambda_0(this.sqlStatements_1, null), this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            return Unit_getInstance();
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  function RoomDatabase() {
  }
  protoOf(RoomDatabase).get_invalidationTracker_tp0k9d_k$ = function () {
    var reason = 'getInvalidationTracker: maybe override this in the generated version';
    throw new NotImplementedError('An operation is not implemented: ' + reason);
  };
  protoOf(RoomDatabase).runInTransaction_4l5j4b_k$ = function (runnable) {
    runnable.run_mvkpxh_k$();
  };
  protoOf(RoomDatabase).execSQLBatchAsyncJs_63mnbz_k$ = function (sqlStatements, $completion) {
    var tmp = new $execSQLBatchAsyncJsCOROUTINE$21(this, sqlStatements, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(RoomDatabase).close_yn9xrc_k$ = function () {
  };
  function RoomDatabaseJdbcImplHelper$onClose$lambda() {
    return 'SQLite/JS Datasource: closing\n';
  }
  function RoomDatabaseJdbcImplHelper$onClose$lambda_0() {
    return 'SQLite/JS Datasource: closed\n';
  }
  function RoomDatabaseJdbcImplHelper(dataSource, db, dbUrl, dbName, logger, tableNames, invalidationTracker, dbType) {
    RoomDatabaseJdbcImplHelperCommon.call(this, dataSource, db, dbName, logger, tableNames, invalidationTracker, dbType);
  }
  protoOf(RoomDatabaseJdbcImplHelper).setupSqliteTriggersAsync_ncp3ds_k$ = function (_this__u8e3s4, $completion) {
    return Unit_getInstance();
  };
  protoOf(RoomDatabaseJdbcImplHelper).useConnection_u6tku8_k$ = function (readOnly, block) {
    throw IllegalStateException_init_$Create$('useConnection synchronous not supported on JS');
  };
  protoOf(RoomDatabaseJdbcImplHelper).useConnection_u29dkd_k$ = function (block) {
    throw IllegalStateException_init_$Create$('useConnection synchronous not supported on JS');
  };
  protoOf(RoomDatabaseJdbcImplHelper).exportToFile_8am0r0_k$ = function ($completion) {
    var tmp = this.get_dataSource_vce0e_k$();
    return (tmp instanceof SQLiteDatasourceJs ? tmp : THROW_CCE()).exportDatabaseToFile_frmrgx_k$($completion);
  };
  protoOf(RoomDatabaseJdbcImplHelper).onClose_84idtj_k$ = function () {
    protoOf(RoomDatabaseJdbcImplHelperCommon).onClose_84idtj_k$.call(this);
    var tmp = this.get_dataSource_vce0e_k$();
    if (tmp instanceof SQLiteDatasourceJs) {
      var tmp_0 = Napier_getInstance();
      var tmp_1 = Companion_getInstance_12().get_LOG_TAG_it8mba_k$();
      tmp_0.i$default_3m0r7e_k$(VOID, tmp_1, RoomDatabaseJdbcImplHelper$onClose$lambda);
      this.get_dataSource_vce0e_k$().close_yn9xrc_k$();
      var tmp_2 = Napier_getInstance();
      var tmp_3 = Companion_getInstance_12().get_LOG_TAG_it8mba_k$();
      tmp_2.i$default_3m0r7e_k$(VOID, tmp_3, RoomDatabaseJdbcImplHelper$onClose$lambda_0);
    }
  };
  function onUpgradeNeededThenCreateStores($this, request) {
    request.onupgradeneeded = IndexedDb$onUpgradeNeededThenCreateStores$lambda;
  }
  function IndexedDb$onUpgradeNeededThenCreateStores$lambda(event) {
    var db = event.target.result;
    if (!db.objectStoreNames.contains('um_db_store')) {
      db.createObjectStore('um_db_store');
    }
    if (!db.objectStoreNames.contains('door_attachments')) {
      db.createObjectStore('door_attachments');
    }
    return Unit_getInstance();
  }
  function IndexedDb$checkIfExists$lambda($checkCompletable) {
    return function () {
      return $checkCompletable.completeExceptionally_xyzekf_k$(newThrowable('Error when opening database'));
    };
  }
  function IndexedDb$checkIfExists$lambda$lambda($checkCompletable) {
    return function (data) {
      return $checkCompletable.complete_ixf84q_k$(data.target.result != null);
    };
  }
  function IndexedDb$checkIfExists$lambda$lambda_0($checkCompletable) {
    return function () {
      return $checkCompletable.completeExceptionally_xyzekf_k$(newThrowable('Error when querying for database from um_db_store'));
    };
  }
  function IndexedDb$checkIfExists$lambda_0($checkCompletable) {
    return function (event) {
      var db = event.target.result;
      var store = db.transaction('um_db_store', 'readwrite').objectStore('um_db_store').get('um_db_key');
      store.onsuccess = IndexedDb$checkIfExists$lambda$lambda($checkCompletable);
      store.onerror = IndexedDb$checkIfExists$lambda$lambda_0($checkCompletable);
      return Unit_getInstance();
    };
  }
  function IndexedDb$storeBlob$lambda$lambda$lambda() {
    return 'Saved blob to db';
  }
  function IndexedDb$storeBlob$lambda$lambda($completeable) {
    return function () {
      var tmp = Napier_getInstance();
      var tmp_0 = Companion_getInstance_12().get_LOG_TAG_it8mba_k$();
      tmp.d$default_iccotn_k$(VOID, tmp_0, IndexedDb$storeBlob$lambda$lambda$lambda);
      return $completeable.complete_ixf84q_k$(true);
    };
  }
  function IndexedDb$storeBlob$lambda$lambda$lambda_0() {
    return 'Failed to save blob';
  }
  function IndexedDb$storeBlob$lambda$lambda_0($completeable) {
    return function () {
      var tmp = Napier_getInstance();
      var tmp_0 = Companion_getInstance_12().get_LOG_TAG_it8mba_k$();
      tmp.e$default_s5p7m2_k$(VOID, tmp_0, IndexedDb$storeBlob$lambda$lambda$lambda_0);
      return $completeable.completeExceptionally_xyzekf_k$(Exception_init_$Create$('storeAttachment exception'));
    };
  }
  function IndexedDb$storeBlob$lambda($storeName, $blob, $key, $completeable) {
    return function (event) {
      var db = event.target.result;
      var transaction = db.transaction($storeName, 'readwrite');
      transaction.oncomplete = IndexedDb$storeBlob$lambda$lambda($completeable);
      transaction.onerror = IndexedDb$storeBlob$lambda$lambda_0($completeable);
      var store = transaction.objectStore($storeName);
      return store.put($blob, $key);
    };
  }
  function IndexedDb$retrieveBlob$lambda$lambda($completableDeferred) {
    return function (data) {
      // Inline function 'kotlin.js.unsafeCast' call
      var tmp$ret$0 = data.target.result;
      return $completableDeferred.complete_ixf84q_k$(tmp$ret$0);
    };
  }
  function IndexedDb$retrieveBlob$lambda$lambda_0($dbName, $storeName, $key, $completableDeferred) {
    return function () {
      var errMsg = 'Exception attempting to retrieve blob: db=' + $dbName + '/store=' + $storeName + '/key=' + $key;
      Napier_getInstance().e$default_pvzj32_k$(errMsg, VOID, Companion_getInstance_12().get_LOG_TAG_it8mba_k$());
      return $completableDeferred.completeExceptionally_xyzekf_k$(Exception_init_$Create$(errMsg));
    };
  }
  function IndexedDb$retrieveBlob$lambda($storeName, $key, $completableDeferred, $dbName) {
    return function (event) {
      var db = event.target.result;
      var store = db.transaction($storeName, 'readwrite').objectStore($storeName).get($key);
      store.onsuccess = IndexedDb$retrieveBlob$lambda$lambda($completableDeferred);
      store.onerror = IndexedDb$retrieveBlob$lambda$lambda_0($dbName, $storeName, $key, $completableDeferred);
      return Unit_getInstance();
    };
  }
  function $storeBlobCOROUTINE$22(_this__u8e3s4, dbName, storeName, key, blob, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
    this.dbName_1 = dbName;
    this.storeName_1 = storeName;
    this.key_1 = key;
    this.blob_1 = blob;
  }
  protoOf($storeBlobCOROUTINE$22).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            this.request0__1 = this._this__u8e3s4__1.indexedDb_1.open(this.dbName_1, 2);
            this.completeable1__1 = CompletableDeferred();
            onUpgradeNeededThenCreateStores(this._this__u8e3s4__1, this.request0__1);
            this.request0__1.onsuccess = IndexedDb$storeBlob$lambda(this.storeName_1, this.blob_1, this.key_1, this.completeable1__1);
            this.set_state_rjd8d0_k$(1);
            suspendResult = this.completeable1__1.await_4rdzbx_k$(this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            return Unit_getInstance();
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  function IndexedDb() {
    IndexedDb_instance = this;
    this.indexedDb_1 = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
    this.DB_STORE_NAME_1 = 'um_db_store';
    this.ATTACHMENT_STORE_NAME_1 = 'door_attachments';
    this.DB_STORE_KEY_1 = 'um_db_key';
    this.DATABASE_VERSION_1 = 2;
  }
  protoOf(IndexedDb).checkIfExists_v2er53_k$ = function (dbName, $completion) {
    var checkCompletable = CompletableDeferred();
    var request = this.indexedDb_1.open(dbName, 2);
    onUpgradeNeededThenCreateStores(this, request);
    request.onerror = IndexedDb$checkIfExists$lambda(checkCompletable);
    request.onsuccess = IndexedDb$checkIfExists$lambda_0(checkCompletable);
    return checkCompletable.await_4rdzbx_k$($completion);
  };
  protoOf(IndexedDb).storeBlob_mz5v13_k$ = function (dbName, storeName, key, blob, $completion) {
    var tmp = new $storeBlobCOROUTINE$22(this, dbName, storeName, key, blob, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(IndexedDb).retrieveBlob_gcy6ua_k$ = function (dbName, storeName, key, $completion) {
    var completableDeferred = CompletableDeferred();
    var request = this.indexedDb_1.open(dbName, 2);
    onUpgradeNeededThenCreateStores(this, request);
    request.onsuccess = IndexedDb$retrieveBlob$lambda(storeName, key, completableDeferred, dbName);
    return completableDeferred.await_4rdzbx_k$($completion);
  };
  protoOf(IndexedDb).get_indexedDb_4tyfkq_k$ = function () {
    return this.indexedDb_1;
  };
  protoOf(IndexedDb).get_DB_STORE_NAME_6go0an_k$ = function () {
    return this.DB_STORE_NAME_1;
  };
  protoOf(IndexedDb).get_ATTACHMENT_STORE_NAME_u2vyc_k$ = function () {
    return this.ATTACHMENT_STORE_NAME_1;
  };
  protoOf(IndexedDb).get_DB_STORE_KEY_djf1qh_k$ = function () {
    return this.DB_STORE_KEY_1;
  };
  protoOf(IndexedDb).get_DATABASE_VERSION_zcoczh_k$ = function () {
    return this.DATABASE_VERSION_1;
  };
  var IndexedDb_instance;
  function IndexedDb_getInstance() {
    if (IndexedDb_instance == null)
      new IndexedDb();
    return IndexedDb_instance;
  }
  function _set_connectionIdCounter__h29e82($this, _set____db54di) {
    $this.connectionIdCounter_1 = _set____db54di;
  }
  function _get_connectionIdCounter__uczn4e($this) {
    return $this.connectionIdCounter_1;
  }
  function _set_closed__kdb0et_1($this, _set____db54di) {
    $this.closed_1 = _set____db54di;
  }
  function _get_closed__iwkfs1_1($this) {
    return $this.closed_1;
  }
  function _set_mAutoCommit__y2fg6m($this, _set____db54di) {
    $this.mAutoCommit_1 = _set____db54di;
  }
  function _get_mAutoCommit__3s19uq($this) {
    return $this.mAutoCommit_1;
  }
  function _get_logPrefix__aovpcr_0($this) {
    return $this.logPrefix_1;
  }
  function Companion_17() {
    Companion_instance_17 = this;
    this.connectionIdCounter_1 = 1;
  }
  var Companion_instance_17;
  function Companion_getInstance_20() {
    if (Companion_instance_17 == null)
      new Companion_17();
    return Companion_instance_17;
  }
  function SQLiteConnectionJs$lambda(this$0) {
    return function () {
      return this$0.logPrefix_1 + ' : open';
    };
  }
  function SQLiteConnectionJs$close$lambda(this$0) {
    return function () {
      return this$0.logPrefix_1 + ' : close';
    };
  }
  function $setAutoCommitAsyncCOROUTINE$23(_this__u8e3s4, autoCommit, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
    this.autoCommit_1 = autoCommit;
  }
  protoOf($setAutoCommitAsyncCOROUTINE$23).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(4);
            if (!this.autoCommit_1 ? this._this__u8e3s4__1.mAutoCommit_1 : false) {
              this.set_state_rjd8d0_k$(1);
              suspendResult = this._this__u8e3s4__1.datasource_1.acquireTransactionLock_ufxryl_k$(this._this__u8e3s4__1, this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            } else {
              if (this.autoCommit_1 ? !this.autoCommit_1 : false) {
                this._this__u8e3s4__1.datasource_1.releaseTransactionLock_m282pp_k$(this._this__u8e3s4__1);
                this._this__u8e3s4__1.mAutoCommit_1 = false;
                this.set_state_rjd8d0_k$(3);
                continue $sm;
              } else {
                this.set_state_rjd8d0_k$(3);
                continue $sm;
              }
            }

          case 1:
            this._this__u8e3s4__1.mAutoCommit_1 = false;
            this.set_state_rjd8d0_k$(2);
            suspendResult = this._this__u8e3s4__1.datasource_1.sendUpdate$default_3nckq3_k$(this._this__u8e3s4__1, 'BEGIN TRANSACTION', [], VOID, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 2:
            this.set_state_rjd8d0_k$(3);
            continue $sm;
          case 3:
            return Unit_getInstance();
          case 4:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 4) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  function $commitAsyncCOROUTINE$24(_this__u8e3s4, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
  }
  protoOf($commitAsyncCOROUTINE$24).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            if (this._this__u8e3s4__1.mAutoCommit_1)
              throw IllegalStateException_init_$Create$('commitAsync: not in transaction (autoCommit=true) - cannot commit');
            this.set_state_rjd8d0_k$(1);
            suspendResult = this._this__u8e3s4__1.datasource_1.sendUpdate$default_3nckq3_k$(this._this__u8e3s4__1, 'COMMIT', [], VOID, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            return Unit_getInstance();
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  function $rollbackAsyncCOROUTINE$25(_this__u8e3s4, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
  }
  protoOf($rollbackAsyncCOROUTINE$25).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            this.set_state_rjd8d0_k$(1);
            suspendResult = this._this__u8e3s4__1.datasource_1.sendUpdate$default_3nckq3_k$(this._this__u8e3s4__1, 'ROLLBACK', [], VOID, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            return Unit_getInstance();
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  function SQLiteConnectionJs(datasource) {
    Companion_getInstance_20();
    this.datasource_1 = datasource;
    this.closed_1 = false;
    this.mAutoCommit_1 = true;
    var tmp = this;
    var tmp0_this = Companion_getInstance_20();
    var tmp1 = tmp0_this.connectionIdCounter_1;
    tmp0_this.connectionIdCounter_1 = tmp1 + 1 | 0;
    tmp.connectionId_1 = tmp1;
    this.logPrefix_1 = '[SQLiteConnectionJS #' + this.connectionId_1 + ']';
    var tmp_0 = Napier_getInstance();
    var tmp_1 = Companion_getInstance_12().get_LOG_TAG_it8mba_k$();
    tmp_0.v$default_i2q2w7_k$(VOID, tmp_1, SQLiteConnectionJs$lambda(this));
  }
  protoOf(SQLiteConnectionJs).get_datasource_g0samm_k$ = function () {
    return this.datasource_1;
  };
  protoOf(SQLiteConnectionJs).get_connectionId_yokwf2_k$ = function () {
    return this.connectionId_1;
  };
  protoOf(SQLiteConnectionJs).setAutoCommit_yh8u8d_k$ = function (commit) {
  };
  protoOf(SQLiteConnectionJs).getAutoCommit_iwnrr8_k$ = function () {
    return this.mAutoCommit_1;
  };
  protoOf(SQLiteConnectionJs).setAutoCommitAsync_dpyye2_k$ = function (autoCommit, $completion) {
    var tmp = new $setAutoCommitAsyncCOROUTINE$23(this, autoCommit, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(SQLiteConnectionJs).commitAsync_wepez2_k$ = function ($completion) {
    var tmp = new $commitAsyncCOROUTINE$24(this, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(SQLiteConnectionJs).rollbackAsync_usrhnj_k$ = function ($completion) {
    var tmp = new $rollbackAsyncCOROUTINE$25(this, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(SQLiteConnectionJs).prepareStatement_f6j8eq_k$ = function (sql) {
    return new SQLitePreparedStatementJs(this, sql);
  };
  protoOf(SQLiteConnectionJs).prepareStatement_w7z552_k$ = function (sql, autoGeneratedKeys) {
    return new SQLitePreparedStatementJs(this, sql, autoGeneratedKeys);
  };
  protoOf(SQLiteConnectionJs).createStatement_cbd7tf_k$ = function () {
    return new SQLiteStatementJs(this);
  };
  protoOf(SQLiteConnectionJs).commit_vpt10n_k$ = function () {
  };
  protoOf(SQLiteConnectionJs).rollback_r7r9ck_k$ = function () {
  };
  protoOf(SQLiteConnectionJs).close_yn9xrc_k$ = function () {
    var tmp = Napier_getInstance();
    var tmp_0 = Companion_getInstance_12().get_LOG_TAG_it8mba_k$();
    tmp.v$default_i2q2w7_k$(VOID, tmp_0, SQLiteConnectionJs$close$lambda(this));
    if (!this.mAutoCommit_1) {
      this.datasource_1.releaseTransactionLock_m282pp_k$(this);
    }
    this.closed_1 = true;
  };
  protoOf(SQLiteConnectionJs).isClosed_baxhhm_k$ = function () {
    return this.closed_1;
  };
  protoOf(SQLiteConnectionJs).createArrayOf_8kbkpw_k$ = function (arrayType, objects) {
    throw new SQLException('Array not supported on SQLite', null);
  };
  protoOf(SQLiteConnectionJs).getMetaData_qwn0zp_k$ = function () {
    return new SQLiteDatabaseMetadataJs(this.datasource_1);
  };
  function $getTablesAsyncCOROUTINE$26(_this__u8e3s4, catalog, schemaPattern, tableNamePattern, types, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
    this.catalog_1 = catalog;
    this.schemaPattern_1 = schemaPattern;
    this.tableNamePattern_1 = tableNamePattern;
    this.types_1 = types;
  }
  protoOf($getTablesAsyncCOROUTINE$26).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(9);
            this.tblNamePattern0__1 = (this.tableNamePattern_1 == null ? true : '' === this.tableNamePattern_1) ? '%' : Companion_getInstance_1().escape_984trb_k$(this.tableNamePattern_1);
            this.sql1__1 = trimIndent("\n            SELECT NULL AS TABLE_CAT,\n                   NULL AS TABLE_SCHEM,\n                   NAME AS TABLE_NAME,\n                   TYPE AS TABLE_TYPE,\n                   NULL AS REMARKS,\n                   NULL AS TYPE_CAT,\n                   NULL AS TYPE_SCHEM,\n                   NULL AS TYPE_NAME,\n                   NULL AS SELF_REFERENCING_COL_NAME,\n                   NULL AS REF_GENERATION \n            FROM \n                   (SELECT NAME,\n                        UPPER(TYPE) AS TYPE \n                    FROM sqlite_master\n                    WHERE NAME NOT LIKE 'sqlite\\_%' ESCAPE '\\'\n                        AND UPPER(TYPE) IN ('TABLE', 'VIEW') \n                    UNION ALL\n                        SELECT NAME, 'GLOBAL TEMPORARY' AS TYPE\n                        FROM sqlite_temp_master\n                        UNION ALL \n                            SELECT NAME,'SYSTEM TABLE' AS TYPE\n                            FROM sqlite_master\n                            WHERE NAME LIKE 'sqlite\\_%' ESCAPE '\\') \n            WHERE TABLE_NAME LIKE '" + this.tblNamePattern0__1 + "' AND TABLE_TYPE IN (\n        ");
            if (this.types_1.length === 0) {
              this.sql1__1 = this.sql1__1 + "'TABLE','VIEW'";
            } else {
              var tmp_0 = this;
              var tmp_1 = this.sql1__1;
              tmp_0.sql1__1 = tmp_1 + ("'" + this.types_1[0].toUpperCase() + "'");
              var inductionVariable = 1;
              var last = this.types_1.length;
              if (inductionVariable < last)
                do {
                  var i = inductionVariable;
                  inductionVariable = inductionVariable + 1 | 0;
                  var tmp_2 = this;
                  var tmp_3 = this.sql1__1;
                  tmp_2.sql1__1 = tmp_3 + (",'" + this.types_1[i].toUpperCase() + "'");
                }
                 while (inductionVariable < last);
            }

            this.sql1__1 = this.sql1__1 + ') ORDER BY TABLE_TYPE, TABLE_NAME';
            this.set_state_rjd8d0_k$(1);
            continue $sm;
          case 1:
            var tmp_4 = this;
            tmp_4.this3__1 = this._this__u8e3s4__1.datasource_1.getConnection_hr2oto_k$();
            this.set_state_rjd8d0_k$(2);
            continue $sm;
          case 2:
            this.set_state_rjd8d0_k$(3);
            continue $sm;
          case 3:
            this.set_exceptionState_fex74n_k$(8);
            var tmp_5 = this;
            tmp_5.it6__1 = this.this3__1;
            this.set_state_rjd8d0_k$(4);
            suspendResult = this._this__u8e3s4__1.datasource_1.sendQuery$default_czcv91_k$(this.it6__1, this.sql1__1, VOID, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 4:
            this.tmp$ret$05__1 = suspendResult;
            this.set_exceptionState_fex74n_k$(9);
            this.set_state_rjd8d0_k$(5);
            var tmp_6 = this;
            continue $sm;
          case 5:
            var tmp_7 = this.tmp$ret$05__1;
            this.set_exceptionState_fex74n_k$(9);
            this.this3__1.close_yn9xrc_k$();
            this.tmp$ret$42__1 = tmp_7;
            this.set_state_rjd8d0_k$(7);
            continue $sm;
          case 6:
            this.set_exceptionState_fex74n_k$(9);
            this.this3__1.close_yn9xrc_k$();
            if (false) {
              this.set_state_rjd8d0_k$(1);
              continue $sm;
            }

            this.set_state_rjd8d0_k$(7);
            continue $sm;
          case 7:
            return this.tmp$ret$42__1;
          case 8:
            this.set_exceptionState_fex74n_k$(9);
            var t = this.get_exception_x0n6w6_k$();
            this.this3__1.close_yn9xrc_k$();
            throw t;
          case 9:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 9) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  function SQLiteDatabaseMetadataJs(datasource) {
    this.datasource_1 = datasource;
  }
  protoOf(SQLiteDatabaseMetadataJs).get_datasource_g0samm_k$ = function () {
    return this.datasource_1;
  };
  protoOf(SQLiteDatabaseMetadataJs).getTables_eub13u_k$ = function (catalog, schemaPattern, tableNamePattern, types) {
    throw Exception_init_$Create$('getTables: This can not be used on JS, only for JVM. Call getTablesAsync instead');
  };
  protoOf(SQLiteDatabaseMetadataJs).getDatabaseProductName_re6tex_k$ = function () {
    return 'SQLite';
  };
  protoOf(SQLiteDatabaseMetadataJs).getTablesAsync_5l8i8x_k$ = function (catalog, schemaPattern, tableNamePattern, types, $completion) {
    var tmp = new $getTablesAsyncCOROUTINE$26(this, catalog, schemaPattern, tableNamePattern, types, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  function SQLiteDatasourceJs$sendQuery$slambda$lambda(this$0, $sql, $params) {
    return function () {
      var tmp0_safe_receiver = $params;
      return this$0.logPrefix_1 + ' sending query: ' + $sql + ' params=' + (tmp0_safe_receiver == null ? null : joinToString_0(tmp0_safe_receiver));
    };
  }
  function SQLiteDatasourceJs$sendQuery$slambda$lambda_0(this$0, $sql, $params, $sqliteResultSet) {
    return function () {
      var tmp0_safe_receiver = $params;
      return this$0.logPrefix_1 + " Got result: Ran: '" + $sql + "' params=" + (tmp0_safe_receiver == null ? null : joinToString_0(tmp0_safe_receiver)) + ' result = ' + $sqliteResultSet + '\n';
    };
  }
  function SQLiteDatasourceJs$sendUpdate$slambda$lambda(this$0, $sql, $params) {
    return function () {
      var tmp0_safe_receiver = $params;
      return this$0.logPrefix_1 + " sending update: '" + $sql + "', params=" + (tmp0_safe_receiver == null ? null : joinToString_0(tmp0_safe_receiver)) + '\n';
    };
  }
  function SQLiteDatasourceJs$sendUpdate$slambda$lambda_0(this$0, $sql) {
    return function () {
      return this$0.logPrefix_1 + " update done: '" + $sql + "'";
    };
  }
  function _get_dbName__9h2wvy_0($this) {
    return $this.dbName_1;
  }
  function _get_worker__80fttf($this) {
    return $this.worker_1;
  }
  function _get_logger__rkp4sl_0($this) {
    return $this.logger_1;
  }
  function _get_logWorkerMessages__dd7y9p($this) {
    return $this.logWorkerMessages_1;
  }
  function _get_pendingMessages__vzrhim($this) {
    return $this.pendingMessages_1;
  }
  function _get_executedSqlQueries__ngh8os($this) {
    return $this.executedSqlQueries_1;
  }
  function _get_transactionMutex__k4c6ui($this) {
    return $this.transactionMutex_1;
  }
  function _get_logPrefix__aovpcr_1($this) {
    return $this.logPrefix_1;
  }
  function _set_closed__kdb0et_2($this, _set____db54di) {
    $this.closed_1 = _set____db54di;
  }
  function _get_closed__iwkfs1_2($this) {
    return $this.closed_1;
  }
  function _get_scope__bi2zur($this) {
    return $this.scope_1;
  }
  function assertNotClosed($this) {
    if ($this.closed_1)
      throw IllegalStateException_init_$Create$('SQLiteDataSourceJs is closed!');
  }
  function sendMessage($this, message, $completion) {
    var tmp = new $sendMessageCOROUTINE$27($this, message, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  }
  function makeMessage($this, sql, params) {
    return json([to('action', 'exec'), to('sql', sql), to('params', params), to('config', json([to('useBigInt', true)]))]);
  }
  function makeMessage$default($this, sql, params, $super) {
    var tmp;
    if (params === VOID) {
      // Inline function 'kotlin.arrayOf' call
      // Inline function 'kotlin.js.unsafeCast' call
      // Inline function 'kotlin.js.asDynamic' call
      tmp = [];
    } else {
      tmp = params;
    }
    params = tmp;
    return makeMessage($this, sql, params);
  }
  function withTransactionLock($this, connection, block, $completion) {
    var tmp = new $withTransactionLockCOROUTINE$28($this, connection, block, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  }
  function Companion_18() {
    Companion_instance_18 = this;
    this.idCounter_1 = 0;
    this.PROTOCOL_SQLITE_PREFIX_1 = 'sqlite:';
    this.LOCATION_MEMORY_1 = ':memory:';
  }
  protoOf(Companion_18).set_idCounter_3tyq84_k$ = function (_set____db54di) {
    this.idCounter_1 = _set____db54di;
  };
  protoOf(Companion_18).get_idCounter_8lwzw8_k$ = function () {
    return this.idCounter_1;
  };
  protoOf(Companion_18).get_PROTOCOL_SQLITE_PREFIX_pl3y1_k$ = function () {
    return this.PROTOCOL_SQLITE_PREFIX_1;
  };
  protoOf(Companion_18).get_LOCATION_MEMORY_rxk7vm_k$ = function () {
    return this.LOCATION_MEMORY_1;
  };
  var Companion_instance_18;
  function Companion_getInstance_21() {
    if (Companion_instance_18 == null)
      new Companion_18();
    return Companion_instance_18;
  }
  function SQLiteDatasourceJs$lambda(this$0) {
    return function (dbEvent) {
      var actionId = toInt(toString(dbEvent.data['id']));
      var executedQuery = this$0.executedSqlQueries_1.remove_gppy8k_k$(actionId);
      var pendingCompletable = this$0.pendingMessages_1.remove_gppy8k_k$(actionId);
      var tmp;
      if (!(pendingCompletable == null)) {
        if (dbEvent.data['error'] != undefined) {
          var exception = new SQLException(toString(dbEvent.data['error']), Exception_init_$Create$('Error occurred when executing ' + executedQuery));
          pendingCompletable.completeExceptionally_xyzekf_k$(exception);
        }
        var executedSuccessfully = dbEvent.data['ready'] == (undefined && dbEvent.data['results'] != undefined) ? true : dbEvent.data['ready'];
        var tmp_0;
        if (dbEvent.data['results'] != undefined) {
          tmp_0 = dbEvent.data['results'];
        } else {
          // Inline function 'kotlin.arrayOf' call
          // Inline function 'kotlin.js.unsafeCast' call
          // Inline function 'kotlin.js.asDynamic' call
          tmp_0 = [];
        }
        var results = tmp_0;
        var buffer = dbEvent.data['buffer'] != undefined ? dbEvent.data['buffer'] : null;
        pendingCompletable.complete_ixf84q_k$(new WorkerResult(dbEvent.data['id'], results, executedSuccessfully, buffer));
        tmp = Unit_getInstance();
      }
      return Unit_getInstance();
    };
  }
  function SQLiteDatasourceJs$sendMessage$lambda(this$0, $actionId, $message) {
    return function () {
      return this$0.logPrefix_1 + ' sendMessage #' + $actionId + ' - sending action=' + toString_0($message['action']) + ' \n';
    };
  }
  function SQLiteDatasourceJs$sendMessage$lambda_0(this$0, $actionId) {
    return function () {
      return this$0.logPrefix_1 + ' sendMessage #' + $actionId + ' - got result \n';
    };
  }
  function SQLiteDatasourceJs$sendQuery$slambda(this$0, $sql, $params, resultContinuation) {
    this.this$0__1 = this$0;
    this.$sql_1 = $sql;
    this.$params_1 = $params;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(SQLiteDatasourceJs$sendQuery$slambda).invoke_56nrne_k$ = function ($completion) {
    var tmp = this.create_d196fn_k$($completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(SQLiteDatasourceJs$sendQuery$slambda).invoke_ib42db_k$ = function ($completion) {
    return this.invoke_56nrne_k$($completion);
  };
  protoOf(SQLiteDatasourceJs$sendQuery$slambda).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            var this_0 = this.this$0__1.logger_1;
            var tmp_0;
            if (this.this$0__1.logWorkerMessages_1) {
              tmp_0 = this_0;
            } else {
              tmp_0 = null;
            }

            var tmp0_safe_receiver = tmp_0;
            if (tmp0_safe_receiver == null)
              null;
            else {
              v(tmp0_safe_receiver, VOID, SQLiteDatasourceJs$sendQuery$slambda$lambda(this.this$0__1, this.$sql_1, this.$params_1));
            }

            this.set_state_rjd8d0_k$(1);
            suspendResult = sendMessage(this.this$0__1, makeMessage(this.this$0__1, this.$sql_1, this.$params_1), this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            var ARGUMENT = suspendResult;
            var results = ARGUMENT.get_results_jf06j1_k$();
            var tmp_1;
            if (results == null) {
              tmp_1 = null;
            } else {
              tmp_1 = new SQLiteResultSet(results);
            }

            var tmp2_elvis_lhs = tmp_1;
            var tmp_2;
            if (tmp2_elvis_lhs == null) {
              var this_1 = [];
              tmp_2 = new SQLiteResultSet(this_1);
            } else {
              tmp_2 = tmp2_elvis_lhs;
            }

            var sqliteResultSet = tmp_2;
            var this_2 = this.this$0__1.logger_1;
            var tmp_3;
            if (this.this$0__1.logWorkerMessages_1) {
              tmp_3 = this_2;
            } else {
              tmp_3 = null;
            }

            var tmp3_safe_receiver = tmp_3;
            if (tmp3_safe_receiver == null)
              null;
            else {
              v(tmp3_safe_receiver, VOID, SQLiteDatasourceJs$sendQuery$slambda$lambda_0(this.this$0__1, this.$sql_1, this.$params_1, sqliteResultSet));
            }

            return sqliteResultSet;
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(SQLiteDatasourceJs$sendQuery$slambda).create_d196fn_k$ = function (completion) {
    return new SQLiteDatasourceJs$sendQuery$slambda(this.this$0__1, this.$sql_1, this.$params_1, completion);
  };
  function SQLiteDatasourceJs$sendQuery$slambda_0(this$0, $sql, $params, resultContinuation) {
    var i = new SQLiteDatasourceJs$sendQuery$slambda(this$0, $sql, $params, resultContinuation);
    var l = function ($completion) {
      return i.invoke_56nrne_k$($completion);
    };
    l.$arity = 0;
    return l;
  }
  function SQLiteDatasourceJs$sendUpdate$slambda(this$0, $sql, $params, $returnGeneratedKey, resultContinuation) {
    this.this$0__1 = this$0;
    this.$sql_1 = $sql;
    this.$params_1 = $params;
    this.$returnGeneratedKey_1 = $returnGeneratedKey;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(SQLiteDatasourceJs$sendUpdate$slambda).invoke_z6umen_k$ = function ($completion) {
    var tmp = this.create_d196fn_k$($completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(SQLiteDatasourceJs$sendUpdate$slambda).invoke_ib42db_k$ = function ($completion) {
    return this.invoke_z6umen_k$($completion);
  };
  protoOf(SQLiteDatasourceJs$sendUpdate$slambda).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(4);
            var this_0 = this.this$0__1.logger_1;
            var tmp_0;
            if (this.this$0__1.logWorkerMessages_1) {
              tmp_0 = this_0;
            } else {
              tmp_0 = null;
            }

            var tmp0_safe_receiver = tmp_0;
            if (tmp0_safe_receiver == null)
              null;
            else {
              v(tmp0_safe_receiver, VOID, SQLiteDatasourceJs$sendUpdate$slambda$lambda(this.this$0__1, this.$sql_1, this.$params_1));
            }

            this.set_state_rjd8d0_k$(1);
            suspendResult = sendMessage(this.this$0__1, makeMessage(this.this$0__1, this.$sql_1, this.$params_1), this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            if (this.$returnGeneratedKey_1) {
              this.set_state_rjd8d0_k$(2);
              suspendResult = sendMessage(this.this$0__1, makeMessage$default(this.this$0__1, 'SELECT last_insert_rowid()'), this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            } else {
              var tmp_1 = this;
              tmp_1.WHEN_RESULT0__1 = null;
              this.set_state_rjd8d0_k$(3);
              continue $sm;
            }

          case 2:
            var ARGUMENT = suspendResult;
            var tmp1_safe_receiver = ARGUMENT.get_results_jf06j1_k$();
            var tmp_2 = this;
            var tmp_3;
            if (tmp1_safe_receiver == null) {
              tmp_3 = null;
            } else {
              tmp_3 = new SQLiteResultSet(tmp1_safe_receiver);
            }

            tmp_2.WHEN_RESULT0__1 = tmp_3;
            this.set_state_rjd8d0_k$(3);
            continue $sm;
          case 3:
            var generatedKey = this.WHEN_RESULT0__1;
            var this_1 = this.this$0__1.logger_1;
            var tmp_4;
            if (this.this$0__1.logWorkerMessages_1) {
              tmp_4 = this_1;
            } else {
              tmp_4 = null;
            }

            var tmp2_safe_receiver = tmp_4;
            if (tmp2_safe_receiver == null)
              null;
            else {
              v(tmp2_safe_receiver, VOID, SQLiteDatasourceJs$sendUpdate$slambda$lambda_0(this.this$0__1, this.$sql_1));
            }

            return new UpdateResult(1, generatedKey);
          case 4:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 4) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(SQLiteDatasourceJs$sendUpdate$slambda).create_d196fn_k$ = function (completion) {
    return new SQLiteDatasourceJs$sendUpdate$slambda(this.this$0__1, this.$sql_1, this.$params_1, this.$returnGeneratedKey_1, completion);
  };
  function SQLiteDatasourceJs$sendUpdate$slambda_0(this$0, $sql, $params, $returnGeneratedKey, resultContinuation) {
    var i = new SQLiteDatasourceJs$sendUpdate$slambda(this$0, $sql, $params, $returnGeneratedKey, resultContinuation);
    var l = function ($completion) {
      return i.invoke_z6umen_k$($completion);
    };
    l.$arity = 0;
    return l;
  }
  function SQLiteDatasourceJs$loadDbFromIndexedDb$lambda$lambda$slambda(this$0, $data, $exportCompletable, resultContinuation) {
    this.this$0__1 = this$0;
    this.$data_1 = $data;
    this.$exportCompletable_1 = $exportCompletable;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(SQLiteDatasourceJs$loadDbFromIndexedDb$lambda$lambda$slambda).invoke_d9fzmj_k$ = function ($this$launch, $completion) {
    var tmp = this.create_rcuf4x_k$($this$launch, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(SQLiteDatasourceJs$loadDbFromIndexedDb$lambda$lambda$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_d9fzmj_k$((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(SQLiteDatasourceJs$loadDbFromIndexedDb$lambda$lambda$slambda).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            this.set_state_rjd8d0_k$(1);
            suspendResult = sendMessage(this.this$0__1, json([to('action', 'open'), to('buffer', this.$data_1.target.result)]), this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            var result = suspendResult;
            this.$exportCompletable_1.complete_ixf84q_k$(result.get_ready_ixwjga_k$());
            return Unit_getInstance();
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(SQLiteDatasourceJs$loadDbFromIndexedDb$lambda$lambda$slambda).create_rcuf4x_k$ = function ($this$launch, completion) {
    var i = new SQLiteDatasourceJs$loadDbFromIndexedDb$lambda$lambda$slambda(this.this$0__1, this.$data_1, this.$exportCompletable_1, completion);
    i.$this$launch_1 = $this$launch;
    return i;
  };
  protoOf(SQLiteDatasourceJs$loadDbFromIndexedDb$lambda$lambda$slambda).create_wyq9v6_k$ = function (value, completion) {
    return this.create_rcuf4x_k$((!(value == null) ? isInterface(value, CoroutineScope) : false) ? value : THROW_CCE(), completion);
  };
  function SQLiteDatasourceJs$loadDbFromIndexedDb$lambda$lambda$slambda_0(this$0, $data, $exportCompletable, resultContinuation) {
    var i = new SQLiteDatasourceJs$loadDbFromIndexedDb$lambda$lambda$slambda(this$0, $data, $exportCompletable, resultContinuation);
    var l = function ($this$launch, $completion) {
      return i.invoke_d9fzmj_k$($this$launch, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function SQLiteDatasourceJs$loadDbFromIndexedDb$lambda$lambda(this$0, $exportCompletable) {
    return function (data) {
      var tmp = GlobalScope_getInstance();
      return launch(tmp, VOID, VOID, SQLiteDatasourceJs$loadDbFromIndexedDb$lambda$lambda$slambda_0(this$0, data, $exportCompletable, null));
    };
  }
  function SQLiteDatasourceJs$loadDbFromIndexedDb$lambda$lambda_0($exportCompletable) {
    return function () {
      return $exportCompletable.completeExceptionally_xyzekf_k$(newThrowable('Error when executing store data fetch'));
    };
  }
  function SQLiteDatasourceJs$loadDbFromIndexedDb$lambda(this$0, $exportCompletable) {
    return function (event) {
      var db = event.target.result;
      var store = db.transaction(IndexedDb_getInstance().get_DB_STORE_NAME_6go0an_k$(), 'readwrite').objectStore(IndexedDb_getInstance().get_DB_STORE_NAME_6go0an_k$()).get(IndexedDb_getInstance().get_DB_STORE_KEY_djf1qh_k$());
      store.onsuccess = SQLiteDatasourceJs$loadDbFromIndexedDb$lambda$lambda(this$0, $exportCompletable);
      store.onerror = SQLiteDatasourceJs$loadDbFromIndexedDb$lambda$lambda_0($exportCompletable);
      return Unit_getInstance();
    };
  }
  function SQLiteDatasourceJs$loadDbFromIndexedDb$lambda_0($exportCompletable) {
    return function () {
      return $exportCompletable.completeExceptionally_xyzekf_k$(newThrowable('Error when importing database from IndexedDb to SQLite DB'));
    };
  }
  function SQLiteDatasourceJs$saveDatabaseToIndexedDb$lambda(this$0) {
    return function () {
      return this$0.logPrefix_1 + ' SQLiteDataSource/JS: saving to indexed db';
    };
  }
  function SQLiteDatasourceJs$saveDatabaseToIndexedDb$lambda$lambda(this$0, $exportCompletable) {
    return function () {
      i(this$0.logger_1, this$0.logPrefix_1 + ' Saved to IndexedDb: ' + this$0.dbName_1);
      return $exportCompletable.complete_ixf84q_k$(true);
    };
  }
  function SQLiteDatasourceJs$saveDatabaseToIndexedDb$lambda$lambda_0($exportCompletable) {
    return function () {
      return $exportCompletable.completeExceptionally_xyzekf_k$(newThrowable('Error when importing SQLJs database to IndexedDb'));
    };
  }
  function SQLiteDatasourceJs$saveDatabaseToIndexedDb$lambda_0($result, this$0, $exportCompletable) {
    return function (event) {
      var db = event.target.result;
      var transaction = db.transaction(IndexedDb_getInstance().get_DB_STORE_NAME_6go0an_k$(), 'readwrite');
      transaction.oncomplete = SQLiteDatasourceJs$saveDatabaseToIndexedDb$lambda$lambda(this$0, $exportCompletable);
      transaction.onerror = SQLiteDatasourceJs$saveDatabaseToIndexedDb$lambda$lambda_0($exportCompletable);
      var store = transaction.objectStore(IndexedDb_getInstance().get_DB_STORE_NAME_6go0an_k$());
      return store.put($result.get_buffer_bmaafd_k$(), IndexedDb_getInstance().get_DB_STORE_KEY_djf1qh_k$());
    };
  }
  function $sendMessageCOROUTINE$27(_this__u8e3s4, message, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
    this.message_1 = message;
  }
  protoOf($sendMessageCOROUTINE$27).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            assertNotClosed(this._this__u8e3s4__1);
            this.completable0__1 = CompletableDeferred();
            var tmp_0 = this;
            var tmp0_this = Companion_getInstance_21();
            tmp0_this.idCounter_1 = tmp0_this.idCounter_1 + 1 | 0;
            tmp_0.actionId1__1 = tmp0_this.idCounter_1;
            var this_0 = this._this__u8e3s4__1.logger_1;
            var tmp_1;
            if (this._this__u8e3s4__1.logWorkerMessages_1) {
              tmp_1 = this_0;
            } else {
              tmp_1 = null;
            }

            var tmp1_safe_receiver = tmp_1;
            if (tmp1_safe_receiver == null)
              null;
            else {
              v(tmp1_safe_receiver, VOID, SQLiteDatasourceJs$sendMessage$lambda(this._this__u8e3s4__1, this.actionId1__1, this.message_1));
            }

            var this_1 = this._this__u8e3s4__1.pendingMessages_1;
            var key = this.actionId1__1;
            var value = this.completable0__1;
            this_1.put_4fpzoq_k$(key, value);
            var this_2 = this._this__u8e3s4__1.executedSqlQueries_1;
            var key_0 = this.actionId1__1;
            var value_0 = toString_0(this.message_1['sql']);
            this_2.put_4fpzoq_k$(key_0, value_0);
            this.message_1['id'] = this.actionId1__1;
            this._this__u8e3s4__1.worker_1.postMessage(this.message_1);
            this.set_state_rjd8d0_k$(1);
            suspendResult = this.completable0__1.await_4rdzbx_k$(this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            var result = suspendResult;
            var this_3 = this._this__u8e3s4__1.logger_1;
            var tmp_2;
            if (this._this__u8e3s4__1.logWorkerMessages_1) {
              tmp_2 = this_3;
            } else {
              tmp_2 = null;
            }

            var tmp2_safe_receiver = tmp_2;
            if (tmp2_safe_receiver == null)
              null;
            else {
              v(tmp2_safe_receiver, VOID, SQLiteDatasourceJs$sendMessage$lambda_0(this._this__u8e3s4__1, this.actionId1__1));
            }

            return result;
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  function $withTransactionLockCOROUTINE$28(_this__u8e3s4, connection, block, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
    this.connection_1 = connection;
    this.block_1 = block;
  }
  protoOf($withTransactionLockCOROUTINE$28).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(8);
            if (this._this__u8e3s4__1.transactionMutex_1.holdsLock_9pqa81_k$(this.connection_1)) {
              this.set_state_rjd8d0_k$(6);
              suspendResult = this.block_1(this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            } else {
              var tmp_0 = this;
              tmp_0.this1__1 = this._this__u8e3s4__1.transactionMutex_1;
              var tmp_1 = this;
              tmp_1.owner2__1 = this.connection_1;
              this.set_state_rjd8d0_k$(1);
              suspendResult = this.this1__1.lock_ugrcvf_k$(this.owner2__1, this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            }

          case 1:
            this.set_state_rjd8d0_k$(2);
            continue $sm;
          case 2:
            this.set_exceptionState_fex74n_k$(5);
            this.set_state_rjd8d0_k$(3);
            suspendResult = this.block_1(this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 3:
            this.tmp$ret$03__1 = suspendResult;
            this.set_exceptionState_fex74n_k$(8);
            this.set_state_rjd8d0_k$(4);
            continue $sm;
          case 4:
            var tmp_2 = this.tmp$ret$03__1;
            this.set_exceptionState_fex74n_k$(8);
            this.this1__1.unlock_ulcrcl_k$(this.owner2__1);
            this.WHEN_RESULT0__1 = tmp_2;
            this.set_state_rjd8d0_k$(7);
            continue $sm;
          case 5:
            this.set_exceptionState_fex74n_k$(8);
            var t = this.get_exception_x0n6w6_k$();
            this.this1__1.unlock_ulcrcl_k$(this.owner2__1);
            throw t;
          case 6:
            this.WHEN_RESULT0__1 = suspendResult;
            this.set_state_rjd8d0_k$(7);
            continue $sm;
          case 7:
            return this.WHEN_RESULT0__1;
          case 8:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 8) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  function $exportDatabaseToFileCOROUTINE$29(_this__u8e3s4, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
  }
  protoOf($exportDatabaseToFileCOROUTINE$29).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(6);
            var tmp_0 = this;
            tmp_0.this0__1 = this._this__u8e3s4__1.transactionMutex_1;
            var tmp_1 = this;
            tmp_1.owner1__1 = null;
            this.set_state_rjd8d0_k$(1);
            suspendResult = this.this0__1.lock_ugrcvf_k$(this.owner1__1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            this.set_state_rjd8d0_k$(2);
            continue $sm;
          case 2:
            this.set_exceptionState_fex74n_k$(5);
            this.set_state_rjd8d0_k$(3);
            suspendResult = sendMessage(this._this__u8e3s4__1, json([to('action', 'export')]), this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 3:
            var result = suspendResult;
            var tmp0_elvis_lhs = result.get_buffer_bmaafd_k$();
            var tmp_2;
            if (tmp0_elvis_lhs == null) {
              throw IllegalStateException_init_$Create$('no result buffer');
            } else {
              tmp_2 = tmp0_elvis_lhs;
            }

            var typedArray = tmp_2;
            var this_0 = [typedArray.buffer];
            var blob = new Blob(this_0);
            var tmp_3 = document.createElement('a');
            var link = tmp_3 instanceof HTMLAnchorElement ? tmp_3 : THROW_CCE();
            var tmp1_safe_receiver = document.body;
            if (tmp1_safe_receiver == null)
              null;
            else
              tmp1_safe_receiver.appendChild(link);
            link.href = URL.createObjectURL(blob);
            link.download = this._this__u8e3s4__1.dbName_1 + '.db';
            var tmp_4 = this;
            link.click();
            tmp_4.tmp$ret$02__1 = Unit_getInstance();
            this.set_exceptionState_fex74n_k$(6);
            this.set_state_rjd8d0_k$(4);
            continue $sm;
          case 4:
            this.set_exceptionState_fex74n_k$(6);
            this.this0__1.unlock_ulcrcl_k$(this.owner1__1);
            return Unit_getInstance();
          case 5:
            this.set_exceptionState_fex74n_k$(6);
            var t = this.get_exception_x0n6w6_k$();
            this.this0__1.unlock_ulcrcl_k$(this.owner1__1);
            throw t;
          case 6:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 6) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  function $saveDatabaseToIndexedDbCOROUTINE$30(_this__u8e3s4, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
  }
  protoOf($saveDatabaseToIndexedDbCOROUTINE$30).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(7);
            this.exportCompletable0__1 = CompletableDeferred();
            var tmp_0 = this;
            tmp_0.this1__1 = this._this__u8e3s4__1.transactionMutex_1;
            var tmp_1 = this;
            tmp_1.owner2__1 = this._this__u8e3s4__1;
            this.set_state_rjd8d0_k$(1);
            suspendResult = this.this1__1.lock_ugrcvf_k$(this.owner2__1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            this.set_state_rjd8d0_k$(2);
            continue $sm;
          case 2:
            this.set_exceptionState_fex74n_k$(6);
            d_0(this._this__u8e3s4__1.logger_1, VOID, SQLiteDatasourceJs$saveDatabaseToIndexedDb$lambda(this._this__u8e3s4__1));
            this.set_state_rjd8d0_k$(3);
            suspendResult = sendMessage(this._this__u8e3s4__1, json([to('action', 'export')]), this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 3:
            this.result4__1 = suspendResult;
            this.request5__1 = IndexedDb_getInstance().get_indexedDb_4tyfkq_k$().open(this._this__u8e3s4__1.dbName_1, IndexedDb_getInstance().get_DATABASE_VERSION_zcoczh_k$());
            this.request5__1.onsuccess = SQLiteDatasourceJs$saveDatabaseToIndexedDb$lambda_0(this.result4__1, this._this__u8e3s4__1, this.exportCompletable0__1);
            this.set_state_rjd8d0_k$(4);
            suspendResult = this.exportCompletable0__1.await_4rdzbx_k$(this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 4:
            var this_0 = suspendResult;
            d(this._this__u8e3s4__1.logger_1, this._this__u8e3s4__1.logPrefix_1 + ' SQLiteDataSource/JS: saving to indexed db complete');
            this.tmp$ret$03__1 = this_0;
            this.set_exceptionState_fex74n_k$(7);
            this.set_state_rjd8d0_k$(5);
            continue $sm;
          case 5:
            var tmp_2 = this.tmp$ret$03__1;
            this.set_exceptionState_fex74n_k$(7);
            this.this1__1.unlock_ulcrcl_k$(this.owner2__1);
            return tmp_2;
          case 6:
            this.set_exceptionState_fex74n_k$(7);
            var t = this.get_exception_x0n6w6_k$();
            this.this1__1.unlock_ulcrcl_k$(this.owner2__1);
            throw t;
          case 7:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 7) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  function SQLiteDatasourceJs(dbName, worker, logger, logWorkerMessages) {
    Companion_getInstance_21();
    logWorkerMessages = logWorkerMessages === VOID ? false : logWorkerMessages;
    this.dbName_1 = dbName;
    this.worker_1 = worker;
    this.logger_1 = logger;
    this.logWorkerMessages_1 = logWorkerMessages;
    var tmp = this;
    // Inline function 'kotlin.collections.mutableMapOf' call
    tmp.pendingMessages_1 = LinkedHashMap_init_$Create$();
    var tmp_0 = this;
    // Inline function 'kotlin.collections.mutableMapOf' call
    tmp_0.executedSqlQueries_1 = LinkedHashMap_init_$Create$();
    this.transactionMutex_1 = Mutex();
    this.logPrefix_1 = '[SQLiteDataSourceJs - ' + this.dbName_1 + ']';
    this.closed_1 = false;
    this.scope_1 = CoroutineScope_0(Dispatchers_getInstance().get_Default_goqax4_k$().plus_s13ygv_k$(Job()));
    this.worker_1.onmessage = SQLiteDatasourceJs$lambda(this);
  }
  protoOf(SQLiteDatasourceJs).acquireTransactionLock_ufxryl_k$ = function (connection, $completion) {
    return this.transactionMutex_1.lock_ugrcvf_k$(connection, $completion);
  };
  protoOf(SQLiteDatasourceJs).releaseTransactionLock_m282pp_k$ = function (connection) {
    this.transactionMutex_1.unlock_ulcrcl_k$(connection);
  };
  protoOf(SQLiteDatasourceJs).sendQuery_yu5wbz_k$ = function (connection, sql, params, $completion) {
    return withTransactionLock(this, connection, SQLiteDatasourceJs$sendQuery$slambda_0(this, sql, params, null), $completion);
  };
  protoOf(SQLiteDatasourceJs).sendQuery$default_czcv91_k$ = function (connection, sql, params, $completion, $super) {
    params = params === VOID ? null : params;
    return $super === VOID ? this.sendQuery_yu5wbz_k$(connection, sql, params, $completion) : $super.sendQuery_yu5wbz_k$.call(this, connection, sql, params, $completion);
  };
  protoOf(SQLiteDatasourceJs).sendUpdate_kjt5mx_k$ = function (connection, sql, params, returnGeneratedKey, $completion) {
    return withTransactionLock(this, connection, SQLiteDatasourceJs$sendUpdate$slambda_0(this, sql, params, returnGeneratedKey, null), $completion);
  };
  protoOf(SQLiteDatasourceJs).sendUpdate$default_3nckq3_k$ = function (connection, sql, params, returnGeneratedKey, $completion, $super) {
    returnGeneratedKey = returnGeneratedKey === VOID ? false : returnGeneratedKey;
    return $super === VOID ? this.sendUpdate_kjt5mx_k$(connection, sql, params, returnGeneratedKey, $completion) : $super.sendUpdate_kjt5mx_k$.call(this, connection, sql, params, returnGeneratedKey, $completion);
  };
  protoOf(SQLiteDatasourceJs).loadDbFromIndexedDb_tcxnl_k$ = function ($completion) {
    var exportCompletable = CompletableDeferred();
    var request = IndexedDb_getInstance().get_indexedDb_4tyfkq_k$().open(this.dbName_1, IndexedDb_getInstance().get_DATABASE_VERSION_zcoczh_k$());
    request.onsuccess = SQLiteDatasourceJs$loadDbFromIndexedDb$lambda(this, exportCompletable);
    request.onerror = SQLiteDatasourceJs$loadDbFromIndexedDb$lambda_0(exportCompletable);
    return exportCompletable.await_4rdzbx_k$($completion);
  };
  protoOf(SQLiteDatasourceJs).exportDatabaseToFile_frmrgx_k$ = function ($completion) {
    var tmp = new $exportDatabaseToFileCOROUTINE$29(this, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(SQLiteDatasourceJs).saveDatabaseToIndexedDb_xd3smc_k$ = function ($completion) {
    var tmp = new $saveDatabaseToIndexedDbCOROUTINE$30(this, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(SQLiteDatasourceJs).getConnection_hr2oto_k$ = function () {
    assertNotClosed(this);
    return new SQLiteConnectionJs(this);
  };
  protoOf(SQLiteDatasourceJs).close_yn9xrc_k$ = function () {
    d(this.logger_1, this.logPrefix_1 + ' close - terminating worker\n');
    this.worker_1.terminate();
    cancel_0(this.scope_1);
    this.closed_1 = true;
    i(this.logger_1, this.logPrefix_1 + ' close - worker terminated, closed\n');
  };
  function _get_sql__e6gtqb($this) {
    return $this.sql_1;
  }
  function _get_params__oo7d51($this) {
    return $this.params_1;
  }
  function $executeUpdateAsyncCOROUTINE$31(_this__u8e3s4, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
  }
  protoOf($executeUpdateAsyncCOROUTINE$31).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            this.generateKeys0__1 = this._this__u8e3s4__1.get_autoGeneratedKeys_yzw64r_k$() === StatementConstantsKmp_getInstance().get_RETURN_GENERATED_KEYS_s33sei_k$();
            this.set_state_rjd8d0_k$(1);
            suspendResult = this._this__u8e3s4__1.get_connection_x01z89_k$().get_datasource_g0samm_k$().sendUpdate_kjt5mx_k$(this._this__u8e3s4__1.get_connection_x01z89_k$(), this._this__u8e3s4__1.sql_1, this._this__u8e3s4__1.params_1, this.generateKeys0__1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            var result = suspendResult;
            this._this__u8e3s4__1.set_lastGeneratedKey_qi9x5k_k$(result.get_autoGeneratedKey_5pm7ag_k$());
            return 1;
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  function SQLitePreparedStatementJs(connection, sql, autoGeneratedKeys) {
    autoGeneratedKeys = autoGeneratedKeys === VOID ? StatementConstantsKmp_getInstance().get_NO_GENERATED_KEYS_h4ycm1_k$() : autoGeneratedKeys;
    SQLiteStatementJs.call(this, connection, autoGeneratedKeys);
    this.sql_1 = sql;
    var tmp = this;
    // Inline function 'kotlin.arrayOf' call
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    tmp.params_1 = [];
  }
  protoOf(SQLitePreparedStatementJs).executeQueryAsyncInt_j35d75_k$ = function ($completion) {
    return this.get_connection_x01z89_k$().get_datasource_g0samm_k$().sendQuery_yu5wbz_k$(this.get_connection_x01z89_k$(), this.sql_1, this.params_1, $completion);
  };
  protoOf(SQLitePreparedStatementJs).setBoolean_pzdm1v_k$ = function (index, value) {
    this.params_1[index - 1 | 0] = value ? 1 : 0;
  };
  protoOf(SQLitePreparedStatementJs).setByte_o65f22_k$ = function (index, value) {
    this.params_1[index - 1 | 0] = value;
  };
  protoOf(SQLitePreparedStatementJs).setShort_mhpatm_k$ = function (index, value) {
    this.params_1[index - 1 | 0] = value;
  };
  protoOf(SQLitePreparedStatementJs).setString_2gt7ua_k$ = function (index, value) {
    this.params_1[index - 1 | 0] = value;
  };
  protoOf(SQLitePreparedStatementJs).setBytes_hpy65b_k$ = function (index, value) {
    this.params_1[index - 1 | 0] = value;
  };
  protoOf(SQLitePreparedStatementJs).setDate_ytyjt6_k$ = function (index, value) {
    throw new SQLException('This is currently not supported', null);
  };
  protoOf(SQLitePreparedStatementJs).setTime_3vnst7_k$ = function (index, value) {
    throw new SQLException('This is currently not supported', null);
  };
  protoOf(SQLitePreparedStatementJs).setObject_9i2mag_k$ = function (index, value) {
    if (value == null) {
      this.params_1[index - 1 | 0] = null;
    } else {
      if (!(value == null) ? typeof value === 'boolean' : false) {
        this.setBoolean_pzdm1v_k$(index, value);
      } else {
        if (!(value == null) ? typeof value === 'number' : false) {
          this.setByte_o65f22_k$(index, value);
        } else {
          if (!(value == null) ? typeof value === 'number' : false) {
            this.setShort_mhpatm_k$(index, value);
          } else {
            if (!(value == null) ? typeof value === 'string' : false) {
              this.setString_2gt7ua_k$(index, value);
            } else {
              if (!(value == null) ? isByteArray(value) : false) {
                this.setBytes_hpy65b_k$(index, value);
              } else {
                if (value instanceof Long) {
                  this.setLong_j1sybo_k$(index, value);
                } else {
                  if (!(value == null) ? typeof value === 'number' : false) {
                    this.setInt_c72a8z_k$(index, value);
                  }
                }
              }
            }
          }
        }
      }
    }
  };
  protoOf(SQLitePreparedStatementJs).setNull_24rkav_k$ = function (parameterIndex, sqlType) {
    this.params_1[parameterIndex - 1 | 0] = null;
  };
  protoOf(SQLitePreparedStatementJs).setArray_61y2p9_k$ = function (index, array) {
    throw new SQLException('SQLite does not support arrays', null);
  };
  protoOf(SQLitePreparedStatementJs).setInt_c72a8z_k$ = function (index, value) {
    this.params_1[index - 1 | 0] = value;
  };
  protoOf(SQLitePreparedStatementJs).setLong_j1sybo_k$ = function (index, value) {
    var tmp = index - 1 | 0;
    var tmp_0;
    // Inline function 'kotlin.ranges.contains' call
    var this_0 = numberRangeToNumber(0, 1);
    if (contains(isInterface(this_0, ClosedRange) ? this_0 : THROW_CCE(), value)) {
      tmp_0 = eval('Number(' + value.toString() + ')');
    } else {
      tmp_0 = eval(value.toString() + 'n');
    }
    this.params_1[tmp] = tmp_0;
  };
  protoOf(SQLitePreparedStatementJs).setFloat_dia6lm_k$ = function (index, value) {
    this.params_1[index - 1 | 0] = value;
  };
  protoOf(SQLitePreparedStatementJs).setDouble_gsfx69_k$ = function (index, value) {
    this.params_1[index - 1 | 0] = value;
  };
  protoOf(SQLitePreparedStatementJs).setBigDecimal_lq0top_k$ = function (index, value) {
    throw new SQLException('This is currently not supported', null);
  };
  protoOf(SQLitePreparedStatementJs).executeUpdate_fapcbi_k$ = function () {
    throw Exception_init_$Create$('executeUpdate: (not-async) This can not be used on JS, only for JVM');
  };
  protoOf(SQLitePreparedStatementJs).executeUpdateAsync_1e6m2t_k$ = function ($completion) {
    var tmp = new $executeUpdateAsyncCOROUTINE$31(this, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(SQLitePreparedStatementJs).executeQuery_mh7xd9_k$ = function () {
    throw Exception_init_$Create$('executeQuery (non-async): This can not be used on JS, only for JVM');
  };
  protoOf(SQLitePreparedStatementJs).close_yn9xrc_k$ = function () {
  };
  function _get_results__tlunyz($this) {
    return $this.results_1;
  }
  function MetaData($outer) {
    this.$this_1 = $outer;
  }
  protoOf(MetaData).getColumnCount_otnr31_k$ = function () {
    var tmp0_safe_receiver = this.$this_1.columns_1;
    var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.length;
    return tmp1_elvis_lhs == null ? 0 : tmp1_elvis_lhs;
  };
  protoOf(MetaData).getColumnLabel_619i9c_k$ = function (column) {
    var index = column - 1 | 0;
    var tmp0_safe_receiver = this.$this_1.columns_1;
    var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : tmp0_safe_receiver[index];
    var tmp;
    if (tmp1_elvis_lhs == null) {
      throw IllegalStateException_init_$Create$('Could not get column index: ' + index);
    } else {
      tmp = tmp1_elvis_lhs;
    }
    return tmp;
  };
  function _set_closed__kdb0et_3($this, _set____db54di) {
    $this.closed_1 = _set____db54di;
  }
  function _get_closed__iwkfs1_3($this) {
    return $this.closed_1;
  }
  function _set_lastWasNull__n5n0wl($this, _set____db54di) {
    $this.lastWasNull_1 = _set____db54di;
  }
  function _get_lastWasNull__74r5fb($this) {
    return $this.lastWasNull_1;
  }
  function getValue($this, columnName) {
    // Inline function 'kotlin.also' call
    var tmp0_safe_receiver = $this.columns_1;
    var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : indexOf_0(tmp0_safe_receiver, columnName);
    var tmp;
    if (tmp1_safe_receiver == null) {
      tmp = null;
    } else {
      // Inline function 'kotlin.let' call
      // Inline function 'kotlin.contracts.contract' call
      // Inline function 'com.ustadmobile.door.sqljsjdbc.SQLiteResultSet.getValue.<anonymous>' call
      var tmp0_safe_receiver_0 = $this.currentRow_1;
      tmp = tmp0_safe_receiver_0 == null ? null : tmp0_safe_receiver_0[tmp1_safe_receiver];
    }
    var this_0 = tmp;
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'com.ustadmobile.door.sqljsjdbc.SQLiteResultSet.getValue.<anonymous>' call
    $this.lastWasNull_1 = this_0 == null;
    return this_0;
  }
  function getValue_0($this, columnIndex) {
    // Inline function 'kotlin.also' call
    var tmp0_safe_receiver = $this.currentRow_1;
    var this_0 = tmp0_safe_receiver == null ? null : tmp0_safe_receiver[columnIndex - 1 | 0];
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'com.ustadmobile.door.sqljsjdbc.SQLiteResultSet.getValue.<anonymous>' call
    $this.lastWasNull_1 = this_0 == null;
    return this_0;
  }
  function SQLiteResultSet(results) {
    this.results_1 = results;
    this.currentIndex_1 = -1;
    this.currentRow_1 = null;
    this.columns_1 = null;
    this.closed_1 = false;
    this.lastWasNull_1 = true;
    var tmp = this;
    var tmp_0;
    // Inline function 'kotlin.collections.isNotEmpty' call
    // Inline function 'kotlin.collections.isEmpty' call
    if (!(this.results_1.length === 0)) {
      // Inline function 'kotlin.js.asDynamic' call
      tmp_0 = first_0(this.results_1).columns;
    } else {
      tmp_0 = null;
    }
    tmp.columns_1 = tmp_0;
  }
  protoOf(SQLiteResultSet).set_currentIndex_yhm4em_k$ = function (_set____db54di) {
    this.currentIndex_1 = _set____db54di;
  };
  protoOf(SQLiteResultSet).get_currentIndex_shwroi_k$ = function () {
    return this.currentIndex_1;
  };
  protoOf(SQLiteResultSet).set_currentRow_gtvni6_k$ = function (_set____db54di) {
    this.currentRow_1 = _set____db54di;
  };
  protoOf(SQLiteResultSet).get_currentRow_wui8mi_k$ = function () {
    return this.currentRow_1;
  };
  protoOf(SQLiteResultSet).set_columns_dgv1pn_k$ = function (_set____db54di) {
    this.columns_1 = _set____db54di;
  };
  protoOf(SQLiteResultSet).get_columns_gyzrhw_k$ = function () {
    return this.columns_1;
  };
  protoOf(SQLiteResultSet).next_20eer_k$ = function () {
    var tmp;
    // Inline function 'kotlin.collections.isNotEmpty' call
    // Inline function 'kotlin.collections.isEmpty' call
    if (!(this.results_1.length === 0)) {
      this.currentIndex_1 = this.currentIndex_1 + 1 | 0;
      // Inline function 'kotlin.js.asDynamic' call
      var data = first_0(this.results_1).values;
      var tmp_0 = this.currentIndex_1;
      var tmp_1 = data.length;
      var hasNext = tmp_0 < ((!(tmp_1 == null) ? typeof tmp_1 === 'number' : false) ? tmp_1 : THROW_CCE());
      this.currentRow_1 = hasNext ? data[this.currentIndex_1] : null;
      if (this.currentRow_1 == null) {
        this.currentIndex_1 = this.currentIndex_1 - 1 | 0;
      }
      return !(this.currentRow_1 == null);
    } else {
      tmp = false;
    }
    return tmp;
  };
  protoOf(SQLiteResultSet).getString_gb1pt9_k$ = function (columnName) {
    var tmp0_safe_receiver = getValue(this, columnName);
    return tmp0_safe_receiver == null ? null : toString(tmp0_safe_receiver);
  };
  protoOf(SQLiteResultSet).getString_5demq7_k$ = function (columnIndex) {
    var tmp0_safe_receiver = getValue_0(this, columnIndex);
    return tmp0_safe_receiver == null ? null : toString(tmp0_safe_receiver);
  };
  protoOf(SQLiteResultSet).getBoolean_xz3hoo_k$ = function (columnName) {
    var value = getValue(this, columnName);
    return Boolean(value);
  };
  protoOf(SQLiteResultSet).getBoolean_oe92jq_k$ = function (columnIndex) {
    var value = getValue_0(this, columnIndex);
    return Boolean(value);
  };
  protoOf(SQLiteResultSet).getByte_blta6c_k$ = function (columnName) {
    var tmp0_safe_receiver = getValue(this, columnName);
    var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : toString(tmp0_safe_receiver);
    var tmp2_elvis_lhs = tmp1_safe_receiver == null ? null : toByte(tmp1_safe_receiver);
    return tmp2_elvis_lhs == null ? 0 : tmp2_elvis_lhs;
  };
  protoOf(SQLiteResultSet).getByte_8098nu_k$ = function (columnIndex) {
    var tmp0_safe_receiver = getValue_0(this, columnIndex);
    var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : toString(tmp0_safe_receiver);
    var tmp2_elvis_lhs = tmp1_safe_receiver == null ? null : toByte(tmp1_safe_receiver);
    return tmp2_elvis_lhs == null ? 0 : tmp2_elvis_lhs;
  };
  protoOf(SQLiteResultSet).getShort_4zegvo_k$ = function (columnName) {
    var tmp0_safe_receiver = getValue(this, columnName);
    var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : toString(tmp0_safe_receiver);
    var tmp2_elvis_lhs = tmp1_safe_receiver == null ? null : toShort_0(tmp1_safe_receiver);
    return tmp2_elvis_lhs == null ? 0 : tmp2_elvis_lhs;
  };
  protoOf(SQLiteResultSet).getShort_agwca6_k$ = function (columnIndex) {
    var tmp0_safe_receiver = getValue_0(this, columnIndex);
    var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : toString(tmp0_safe_receiver);
    var tmp2_elvis_lhs = tmp1_safe_receiver == null ? null : toShort_0(tmp1_safe_receiver);
    return tmp2_elvis_lhs == null ? 0 : tmp2_elvis_lhs;
  };
  protoOf(SQLiteResultSet).getInt_npc9pd_k$ = function (columnName) {
    var tmp0_safe_receiver = getValue(this, columnName);
    var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : toString(tmp0_safe_receiver);
    var tmp2_elvis_lhs = tmp1_safe_receiver == null ? null : toInt(tmp1_safe_receiver);
    return tmp2_elvis_lhs == null ? 0 : tmp2_elvis_lhs;
  };
  protoOf(SQLiteResultSet).getInt_s8uc8x_k$ = function (columnIndex) {
    var tmp0_safe_receiver = getValue_0(this, columnIndex);
    var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : toString(tmp0_safe_receiver);
    var tmp2_elvis_lhs = tmp1_safe_receiver == null ? null : toInt(tmp1_safe_receiver);
    return tmp2_elvis_lhs == null ? 0 : tmp2_elvis_lhs;
  };
  protoOf(SQLiteResultSet).getFloat_1jlp7w_k$ = function (columnName) {
    var tmp0_safe_receiver = getValue(this, columnName);
    var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : toString(tmp0_safe_receiver);
    var tmp;
    if (tmp1_safe_receiver == null) {
      tmp = null;
    } else {
      // Inline function 'kotlin.text.toFloat' call
      // Inline function 'kotlin.js.unsafeCast' call
      // Inline function 'kotlin.js.asDynamic' call
      tmp = toDouble(tmp1_safe_receiver);
    }
    var tmp2_elvis_lhs = tmp;
    return tmp2_elvis_lhs == null ? 0.0 : tmp2_elvis_lhs;
  };
  protoOf(SQLiteResultSet).getFloat_m7y41e_k$ = function (columnIndex) {
    var tmp0_safe_receiver = getValue_0(this, columnIndex);
    var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : toString(tmp0_safe_receiver);
    var tmp;
    if (tmp1_safe_receiver == null) {
      tmp = null;
    } else {
      // Inline function 'kotlin.text.toFloat' call
      // Inline function 'kotlin.js.unsafeCast' call
      // Inline function 'kotlin.js.asDynamic' call
      tmp = toDouble(tmp1_safe_receiver);
    }
    var tmp2_elvis_lhs = tmp;
    return tmp2_elvis_lhs == null ? 0.0 : tmp2_elvis_lhs;
  };
  protoOf(SQLiteResultSet).getLong_3wgf2g_k$ = function (columnName) {
    var tmp0_safe_receiver = getValue(this, columnName);
    var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : toString(tmp0_safe_receiver);
    var tmp2_elvis_lhs = tmp1_safe_receiver == null ? null : toLong_0(tmp1_safe_receiver);
    return tmp2_elvis_lhs == null ? new Long(0, 0) : tmp2_elvis_lhs;
  };
  protoOf(SQLiteResultSet).getLong_rneply_k$ = function (columnIndex) {
    var tmp0_safe_receiver = getValue_0(this, columnIndex);
    var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : toString(tmp0_safe_receiver);
    var tmp2_elvis_lhs = tmp1_safe_receiver == null ? null : toLong_0(tmp1_safe_receiver);
    return tmp2_elvis_lhs == null ? new Long(0, 0) : tmp2_elvis_lhs;
  };
  protoOf(SQLiteResultSet).getDouble_v37ict_k$ = function (columnName) {
    var tmp0_safe_receiver = getValue(this, columnName);
    var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : toString(tmp0_safe_receiver);
    var tmp2_elvis_lhs = tmp1_safe_receiver == null ? null : toDouble(tmp1_safe_receiver);
    return tmp2_elvis_lhs == null ? 0.0 : tmp2_elvis_lhs;
  };
  protoOf(SQLiteResultSet).getDouble_5me5vz_k$ = function (columnIndex) {
    var tmp0_safe_receiver = getValue_0(this, columnIndex);
    var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : toString(tmp0_safe_receiver);
    var tmp2_elvis_lhs = tmp1_safe_receiver == null ? null : toDouble(tmp1_safe_receiver);
    return tmp2_elvis_lhs == null ? 0.0 : tmp2_elvis_lhs;
  };
  protoOf(SQLiteResultSet).getBigDecimal_vg28s3_k$ = function (columnName) {
    return getValue(this, columnName);
  };
  protoOf(SQLiteResultSet).getBytes_hu5f8b_k$ = function (columnName) {
    var value = getValue(this, columnName);
    if (!(value == null)) {
      var tmp$ret$0;
      $l$block: {
        // Inline function 'io.ktor.utils.io.core.toByteArray' call
        var this_0 = toString(value);
        var charset = Charsets_getInstance().get_UTF_8_ihn39z_k$();
        if (charset.equals(Charsets_getInstance().get_UTF_8_ihn39z_k$())) {
          tmp$ret$0 = encodeToByteArray(this_0);
          break $l$block;
        }
        tmp$ret$0 = encodeToByteArray_0(charset.newEncoder_gqwcdg_k$(), this_0, 0, this_0.length);
      }
      return tmp$ret$0;
    }
    return null;
  };
  protoOf(SQLiteResultSet).getDate_jtyvo6_k$ = function (columnName) {
    var value = getValue(this, columnName);
    if (!(value == null)) {
      return new Date(toString(value));
    }
    return null;
  };
  protoOf(SQLiteResultSet).getTime_of3q21_k$ = function (columnName) {
    return getValue(this, columnName);
  };
  protoOf(SQLiteResultSet).getTimestamp_78pst6_k$ = function (columnName) {
    return getValue(this, columnName);
  };
  protoOf(SQLiteResultSet).getObject_63qtd1_k$ = function (columnName) {
    return getValue(this, columnName);
  };
  protoOf(SQLiteResultSet).getObject_m2jtdv_k$ = function (columnIndex) {
    return getValue_0(this, columnIndex);
  };
  protoOf(SQLiteResultSet).wasNull_ilge1c_k$ = function () {
    return this.lastWasNull_1;
  };
  protoOf(SQLiteResultSet).getMetaData_qwn0zp_k$ = function () {
    return new MetaData(this);
  };
  protoOf(SQLiteResultSet).close_yn9xrc_k$ = function () {
    this.currentRow_1 = null;
    this.columns_1 = null;
    this.currentIndex_1 = -1;
    this.closed_1 = true;
  };
  protoOf(SQLiteResultSet).isClosed_baxhhm_k$ = function () {
    return this.closed_1;
  };
  protoOf(SQLiteResultSet).toString = function () {
    var str = '[SQLiteResultSet] Columns=' + this.columns_1;
    // Inline function 'kotlin.collections.isEmpty' call
    if (this.results_1.length === 0) {
      str = str + ' - no rows';
      return str;
    }
    return str;
  };
  function _set_closed__kdb0et_4($this, _set____db54di) {
    $this.closed_1 = _set____db54di;
  }
  function _get_closed__iwkfs1_4($this) {
    return $this.closed_1;
  }
  function $executeUpdateAsyncJsCOROUTINE$32(_this__u8e3s4, sql, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
    this.sql_1 = sql;
  }
  protoOf($executeUpdateAsyncJsCOROUTINE$32).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(2);
            Napier_getInstance().v$default_9ddbot_k$('SqliteJs: updateAsyncJs: ' + this.sql_1 + '\n', VOID, Companion_getInstance_12().get_LOG_TAG_it8mba_k$());
            this.set_state_rjd8d0_k$(1);
            var tmp_0 = this._this__u8e3s4__1.connection_1.get_datasource_g0samm_k$();
            suspendResult = tmp_0.sendUpdate$default_3nckq3_k$(this._this__u8e3s4__1.connection_1, this.sql_1, [], VOID, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            var ARGUMENT = suspendResult;
            return ARGUMENT.get_numRowsChanged_uyxfwi_k$();
          case 2:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 2) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  function SQLiteStatementJs(connection, autoGeneratedKeys) {
    autoGeneratedKeys = autoGeneratedKeys === VOID ? StatementConstantsKmp_getInstance().get_NO_GENERATED_KEYS_h4ycm1_k$() : autoGeneratedKeys;
    this.connection_1 = connection;
    this.autoGeneratedKeys_1 = autoGeneratedKeys;
    this.closed_1 = false;
    this.lastGeneratedKey_1 = null;
    this.queryTimeoutSecs_1 = 0;
  }
  protoOf(SQLiteStatementJs).get_connection_x01z89_k$ = function () {
    return this.connection_1;
  };
  protoOf(SQLiteStatementJs).get_autoGeneratedKeys_yzw64r_k$ = function () {
    return this.autoGeneratedKeys_1;
  };
  protoOf(SQLiteStatementJs).set_lastGeneratedKey_qi9x5k_k$ = function (_set____db54di) {
    this.lastGeneratedKey_1 = _set____db54di;
  };
  protoOf(SQLiteStatementJs).get_lastGeneratedKey_xglrg1_k$ = function () {
    return this.lastGeneratedKey_1;
  };
  protoOf(SQLiteStatementJs).set_queryTimeoutSecs_omfp5c_k$ = function (_set____db54di) {
    this.queryTimeoutSecs_1 = _set____db54di;
  };
  protoOf(SQLiteStatementJs).get_queryTimeoutSecs_b2eh98_k$ = function () {
    return this.queryTimeoutSecs_1;
  };
  protoOf(SQLiteStatementJs).executeUpdate_k6x04k_k$ = function (sql) {
    throw new SQLException('Synchronous SQL not supported!', null);
  };
  protoOf(SQLiteStatementJs).executeUpdateAsyncJs_btupiy_k$ = function (sql, $completion) {
    var tmp = new $executeUpdateAsyncJsCOROUTINE$32(this, sql, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(SQLiteStatementJs).close_yn9xrc_k$ = function () {
    this.closed_1 = true;
  };
  protoOf(SQLiteStatementJs).isClosed_baxhhm_k$ = function () {
    return this.closed_1;
  };
  protoOf(SQLiteStatementJs).getConnection_hr2oto_k$ = function () {
    return this.connection_1;
  };
  protoOf(SQLiteStatementJs).getGeneratedKeys_aewui5_k$ = function () {
    var tmp0_elvis_lhs = this.lastGeneratedKey_1;
    var tmp;
    if (tmp0_elvis_lhs == null) {
      // Inline function 'kotlin.arrayOf' call
      // Inline function 'kotlin.js.unsafeCast' call
      // Inline function 'kotlin.js.asDynamic' call
      var tmp$ret$2 = [];
      tmp = new SQLiteResultSet(tmp$ret$2);
    } else {
      tmp = tmp0_elvis_lhs;
    }
    return tmp;
  };
  protoOf(SQLiteStatementJs).setQueryTimeout_qepe4z_k$ = function (seconds) {
    this.queryTimeoutSecs_1 = seconds;
  };
  function UpdateResult(numRowsChanged, autoGeneratedKey) {
    this.numRowsChanged_1 = numRowsChanged;
    this.autoGeneratedKey_1 = autoGeneratedKey;
  }
  protoOf(UpdateResult).get_numRowsChanged_uyxfwi_k$ = function () {
    return this.numRowsChanged_1;
  };
  protoOf(UpdateResult).get_autoGeneratedKey_5pm7ag_k$ = function () {
    return this.autoGeneratedKey_1;
  };
  protoOf(UpdateResult).component1_7eebsc_k$ = function () {
    return this.numRowsChanged_1;
  };
  protoOf(UpdateResult).component2_7eebsb_k$ = function () {
    return this.autoGeneratedKey_1;
  };
  protoOf(UpdateResult).copy_48hpoo_k$ = function (numRowsChanged, autoGeneratedKey) {
    return new UpdateResult(numRowsChanged, autoGeneratedKey);
  };
  protoOf(UpdateResult).copy$default_y0rb7c_k$ = function (numRowsChanged, autoGeneratedKey, $super) {
    numRowsChanged = numRowsChanged === VOID ? this.numRowsChanged_1 : numRowsChanged;
    autoGeneratedKey = autoGeneratedKey === VOID ? this.autoGeneratedKey_1 : autoGeneratedKey;
    return $super === VOID ? this.copy_48hpoo_k$(numRowsChanged, autoGeneratedKey) : $super.copy_48hpoo_k$.call(this, numRowsChanged, autoGeneratedKey);
  };
  protoOf(UpdateResult).toString = function () {
    return 'UpdateResult(numRowsChanged=' + this.numRowsChanged_1 + ', autoGeneratedKey=' + this.autoGeneratedKey_1 + ')';
  };
  protoOf(UpdateResult).hashCode = function () {
    var result = this.numRowsChanged_1;
    result = imul(result, 31) + (this.autoGeneratedKey_1 == null ? 0 : hashCode(this.autoGeneratedKey_1)) | 0;
    return result;
  };
  protoOf(UpdateResult).equals = function (other) {
    if (this === other)
      return true;
    if (!(other instanceof UpdateResult))
      return false;
    var tmp0_other_with_cast = other instanceof UpdateResult ? other : THROW_CCE();
    if (!(this.numRowsChanged_1 === tmp0_other_with_cast.numRowsChanged_1))
      return false;
    if (!equals(this.autoGeneratedKey_1, tmp0_other_with_cast.autoGeneratedKey_1))
      return false;
    return true;
  };
  function WorkerResult(id, results, ready, buffer) {
    this.id_1 = id;
    this.results_1 = results;
    this.ready_1 = ready;
    this.buffer_1 = buffer;
  }
  protoOf(WorkerResult).set_id_kpjn9s_k$ = function (_set____db54di) {
    this.id_1 = _set____db54di;
  };
  protoOf(WorkerResult).get_id_kntnx8_k$ = function () {
    return this.id_1;
  };
  protoOf(WorkerResult).set_results_cgh3qb_k$ = function (_set____db54di) {
    this.results_1 = _set____db54di;
  };
  protoOf(WorkerResult).get_results_jf06j1_k$ = function () {
    return this.results_1;
  };
  protoOf(WorkerResult).set_ready_2pre9d_k$ = function (_set____db54di) {
    this.ready_1 = _set____db54di;
  };
  protoOf(WorkerResult).get_ready_ixwjga_k$ = function () {
    return this.ready_1;
  };
  protoOf(WorkerResult).set_buffer_dp5jk6_k$ = function (_set____db54di) {
    this.buffer_1 = _set____db54di;
  };
  protoOf(WorkerResult).get_buffer_bmaafd_k$ = function () {
    return this.buffer_1;
  };
  protoOf(WorkerResult).component1_7eebsc_k$ = function () {
    return this.id_1;
  };
  protoOf(WorkerResult).component2_7eebsb_k$ = function () {
    return this.results_1;
  };
  protoOf(WorkerResult).component3_7eebsa_k$ = function () {
    return this.ready_1;
  };
  protoOf(WorkerResult).component4_7eebs9_k$ = function () {
    return this.buffer_1;
  };
  protoOf(WorkerResult).copy_esdbor_k$ = function (id, results, ready, buffer) {
    return new WorkerResult(id, results, ready, buffer);
  };
  protoOf(WorkerResult).copy$default_ip702s_k$ = function (id, results, ready, buffer, $super) {
    id = id === VOID ? this.id_1 : id;
    results = results === VOID ? this.results_1 : results;
    ready = ready === VOID ? this.ready_1 : ready;
    buffer = buffer === VOID ? this.buffer_1 : buffer;
    return $super === VOID ? this.copy_esdbor_k$(id, results, ready, buffer) : $super.copy_esdbor_k$.call(this, id, results, ready, buffer);
  };
  protoOf(WorkerResult).toString = function () {
    return 'WorkerResult(id=' + this.id_1 + ', results=' + toString(this.results_1) + ', ready=' + this.ready_1 + ', buffer=' + this.buffer_1 + ')';
  };
  protoOf(WorkerResult).hashCode = function () {
    var result = this.id_1;
    result = imul(result, 31) + (this.results_1 == null ? 0 : hashCode(this.results_1)) | 0;
    result = imul(result, 31) + getBooleanHashCode(this.ready_1) | 0;
    result = imul(result, 31) + (this.buffer_1 == null ? 0 : hashCode(this.buffer_1)) | 0;
    return result;
  };
  protoOf(WorkerResult).equals = function (other) {
    if (this === other)
      return true;
    if (!(other instanceof WorkerResult))
      return false;
    var tmp0_other_with_cast = other instanceof WorkerResult ? other : THROW_CCE();
    if (!(this.id_1 === tmp0_other_with_cast.id_1))
      return false;
    if (!equals(this.results_1, tmp0_other_with_cast.results_1))
      return false;
    if (!(this.ready_1 === tmp0_other_with_cast.ready_1))
      return false;
    if (!equals(this.buffer_1, tmp0_other_with_cast.buffer_1))
      return false;
    return true;
  };
  function DoorJsImplClasses() {
  }
  function generateDoorNodeId(maxNodeId) {
    var nodeIdRef = 'nodeId_ref';
    // Inline function 'org.w3c.dom.get' call
    // Inline function 'kotlin.js.asDynamic' call
    var tmp0_safe_receiver = localStorage[nodeIdRef];
    var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : toInt(tmp0_safe_receiver);
    var foundNodeId = tmp1_elvis_lhs == null ? 0 : tmp1_elvis_lhs;
    if (foundNodeId === 0) {
      // Inline function 'kotlin.math.floor' call
      var x = Default_getInstance().nextDouble_s2xvfg_k$() * maxNodeId;
      var tmp$ret$2 = Math.floor(x);
      foundNodeId = numberToInt(tmp$ret$2);
      localStorage.setItem(nodeIdRef, foundNodeId.toString());
    }
    return foundNodeId;
  }
  function systemTimeInMillis() {
    return numberToLong((new Date()).getTime());
  }
  function threadSafeMapOf(items) {
    // Inline function 'kotlin.also' call
    // Inline function 'kotlin.collections.mutableMapOf' call
    var this_0 = LinkedHashMap_init_$Create$();
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'com.ustadmobile.door.util.threadSafeMapOf.<anonymous>' call
    putAll(this_0, items);
    return this_0;
  }
  function waitBlocking(delayInMs) {
    var delayFor = numberToLong((new Date()).getTime()).plus_r93sks_k$(delayInMs);
    while ((new Date()).getTime() <= delayFor.toDouble_ygsx0s_k$()) {
    }
  }
  function _get_weakRef__myyv7a($this) {
    return $this.weakRef_1;
  }
  function WeakRefJs(target) {
    this.weakRef_1 = new WeakRef(target);
  }
  protoOf(WeakRefJs).get_26vq_k$ = function () {
    return this.weakRef_1.deref();
  };
  function weakRefOf(target) {
    return new WeakRefJs(target);
  }
  //region block: post-declaration
  protoOf(TransactionElement).get_y2st91_k$ = get;
  protoOf(TransactionElement).fold_j2vaxd_k$ = fold;
  protoOf(TransactionElement).minusKey_9i5ggf_k$ = minusKey;
  protoOf(TransactionElement).plus_s13ygv_k$ = plus_0;
  protoOf($serializer).typeParametersSerializers_fr94fx_k$ = typeParametersSerializers;
  protoOf(NapierDoorLogger).log$default_fb1f4z_k$ = log$default;
  protoOf(NapierDoorLogger).log$default_6v36wb_k$ = log$default_0;
  protoOf($serializer_0).typeParametersSerializers_fr94fx_k$ = typeParametersSerializers;
  protoOf($serializer_1).typeParametersSerializers_fr94fx_k$ = typeParametersSerializers;
  protoOf($serializer_2).typeParametersSerializers_fr94fx_k$ = typeParametersSerializers;
  //endregion
  //region block: exports
  _.$_$ = _.$_$ || {};
  _.$_$.a = NodeIdAndAuth;
  _.$_$.b = dbType;
  _.$_$.c = doorNodeIdHeader;
  _.$_$.d = get_doorPrimaryKeyManager;
  _.$_$.e = get_doorWrapperNodeId;
  _.$_$.f = mutableLinkedListOf;
  _.$_$.g = setBodyJson;
  _.$_$.h = toUrlQueryString;
  _.$_$.i = DoorMigrationStatementList;
  _.$_$.j = DelegatedInvalidationPagingSource;
  _.$_$.k = PagingSourceWithHttpLoader;
  _.$_$.l = RoomDatabase;
  _.$_$.m = systemTimeInMillis;
  _.$_$.n = DoorDatabaseRepository;
  _.$_$.o = withDoorTransactionAsync;
  _.$_$.p = Companion_getInstance_12;
  _.$_$.q = Companion_getInstance_5;
  _.$_$.r = Companion_getInstance_18;
  //endregion
  return _;
}(module.exports, require('./kotlin-kotlin-stdlib.js'), require('./Napier-napier-js-ir.js'), require('./kotlinx-coroutines-core.js'), require('./kotlinx-atomicfu.js'), require('./kotlinx-serialization-kotlinx-serialization-core.js'), require('./ktor-ktor-http.js'), require('./ktor-ktor-utils.js'), require('./ktor-ktor-client-core.js'), require('./kotlinx-serialization-kotlinx-serialization-json.js'), require('./multiplatform-paging-root-paging-common.js'), require('./ktor-ktor-io.js')));

//# sourceMappingURL=door-door-runtime.js.map
