// @ts-nocheck function _M0DTPB4Json4Null() {} _M0DTPB4Json4Null.prototype.$tag = 0; const _M0DTPB4Json4Null__ = new _M0DTPB4Json4Null(); function _M0DTPB4Json4True() {} _M0DTPB4Json4True.prototype.$tag = 1; const _M0DTPB4Json4True__ = new _M0DTPB4Json4True(); function _M0DTPB4Json5False() {} _M0DTPB4Json5False.prototype.$tag = 2; const _M0DTPB4Json5False__ = new _M0DTPB4Json5False(); function _M0DTPB4Json6Number(param0, param1) { this._0 = param0; this._1 = param1; } _M0DTPB4Json6Number.prototype.$tag = 3; function _M0DTPB4Json6String(param0) { this._0 = param0; } _M0DTPB4Json6String.prototype.$tag = 4; function _M0DTPB4Json5Array(param0) { this._0 = param0; } _M0DTPB4Json5Array.prototype.$tag = 5; function _M0DTPB4Json6Object(param0) { this._0 = param0; } _M0DTPB4Json6Object.prototype.$tag = 6; const $reinterpret_view = new DataView(new ArrayBuffer(8)); function $i64_reinterpret_f64(a) { $reinterpret_view.setBigUint64(0, BigInt.asUintN(64, a), false); return $reinterpret_view.getFloat64(0, false); } function _M0TPC28internal7strconv9FloatInfo(param0, param1, param2) { this.mantissa_bits = param0; this.exponent_bits = param1; this.bias = param2; } function _M0TP36zxch3n5flock5flock3Hlc(param0, param1) { this.physical_time = param0; this.logical_counter = param1; } function _M0DTP36zxch3n5flock5flock6Source5Local() {} _M0DTP36zxch3n5flock5flock6Source5Local.prototype.$tag = 0; const _M0DTP36zxch3n5flock5flock6Source5Local__ = new _M0DTP36zxch3n5flock5flock6Source5Local(); function _M0DTP36zxch3n5flock5flock6Source6Import(param0) { this._0 = param0; } _M0DTP36zxch3n5flock5flock6Source6Import.prototype.$tag = 1; class $PanicError extends Error {} function $panic() { throw new $PanicError(); } function $bound_check(arr, index) { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); } function _M0TPB13StringBuilder(param0) { this.val = param0; } function _M0TPC16string10StringView(param0, param1, param2) { this.str = param0; this.start = param1; this.end = param2; } function $compare_int(a, b) { return (a >= b) - (a <= b); } const _M0FPB12random__seed = () => { if (globalThis.crypto?.getRandomValues) { const array = new Uint32Array(1); globalThis.crypto.getRandomValues(array); return array[0] | 0; // Convert to signed 32 } else { return Math.floor(Math.random() * 0x100000000) | 0; // Fallback to Math.random } }; const _M0FPB19int__to__string__js = (x, radix) => { return x.toString(radix); }; function _M0TPB4IterGUsRPB4JsonEE(param0, param1) { this.f = param0; this.size_hint = param1; } function _M0TPB4IterGyE(param0, param1) { this.f = param0; this.size_hint = param1; } function _M0TPB4IterGcE(param0, param1) { this.f = param0; this.size_hint = param1; } function _M0TPB4IterGRP26zxch3n6expect6FormatE(param0, param1) { this.f = param0; this.size_hint = param1; } function _M0TPB9ArrayViewGkE(param0, param1, param2) { this.buf = param0; this.start = param1; this.end = param2; } function $unsafe_bytes_sub_string(bytes, byte_offset, byte_length) { const end_offset = byte_offset + byte_length; let buf = ''; while (byte_offset < end_offset) { buf += String.fromCharCode(bytes[byte_offset] | (bytes[byte_offset + 1] << 8)); byte_offset += 2; } return buf; } function $makebytes(a, b) { const arr = new Uint8Array(a); if (b !== 0) { arr.fill(b); } return arr; } function _M0TPB8MutLocalGiE(param0) { this.val = param0; } function _M0TPB4IterGURP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEEE(param0, param1) { this.f = param0; this.size_hint = param1; } function _M0TPB4IterGURPB5ArrayGRPB4JsonERP36zxch3n5flock5flock5EntryEE(param0, param1) { this.f = param0; this.size_hint = param1; } function _M0TPB4IterGURP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryEE(param0, param1) { this.f = param0; this.size_hint = param1; } function $make_array_len_and_init(a, b) { const arr = new Array(a); arr.fill(b); return arr; } const _M0MPB7JSArray4push = (arr, val) => { arr.push(val); }; function _M0TPB4IterGRPC16string10StringViewE(param0, param1) { this.f = param0; this.size_hint = param1; } function _M0TPB8MutLocalGORPC16string10StringViewE(param0) { this.val = param0; } function _M0TPB9ArrayViewGyE(param0, param1, param2) { this.buf = param0; this.start = param1; this.end = param2; } function _M0TPB9ArrayViewGRPB4JsonE(param0, param1, param2) { this.buf = param0; this.start = param1; this.end = param2; } function _M0TPB9ArrayViewGRP26zxch3n6expect6FormatE(param0, param1, param2) { this.buf = param0; this.start = param1; this.end = param2; } function _M0TPB3MapGsRP36zxch3n5flock5flock3HlcE(param0, param1, param2, param3, param4, param5, param6) { this.entries = param0; this.size = param1; this.capacity = param2; this.capacity_mask = param3; this.grow_at = param4; this.head = param5; this.tail = param6; } function _M0TPB3MapGiWRP36zxch3n5flock5flock10EventBatchEuE(param0, param1, param2, param3, param4, param5, param6) { this.entries = param0; this.size = param1; this.capacity = param2; this.capacity_mask = param3; this.grow_at = param4; this.head = param5; this.tail = param6; } function _M0TPB5EntryGsRP36zxch3n5flock5flock3HlcE(param0, param1, param2, param3, param4, param5) { this.prev = param0; this.next = param1; this.psl = param2; this.hash = param3; this.key = param4; this.value = param5; } function _M0TPB5EntryGsRPB4JsonE(param0, param1, param2, param3, param4, param5) { this.prev = param0; this.next = param1; this.psl = param2; this.hash = param3; this.key = param4; this.value = param5; } function _M0TPB5EntryGiWRP36zxch3n5flock5flock10EventBatchEuE(param0, param1, param2, param3, param4, param5) { this.prev = param0; this.next = param1; this.psl = param2; this.hash = param3; this.key = param4; this.value = param5; } function _M0TPB8MutLocalGORPB5EntryGsRPB4JsonEE(param0) { this.val = param0; } function _M0TPB9ArrayViewGUsRPB4JsonEE(param0, param1, param2) { this.buf = param0; this.start = param1; this.end = param2; } const _M0MPB7JSArray4copy = (arr) => arr.slice(0); const $bytes_literal$0 = new Uint8Array(); function _M0TPC15bytes9BytesView(param0, param1, param2) { this.bytes = param0; this.start = param1; this.end = param2; } const _M0MPB7JSArray3pop = (arr) => arr.pop(); const _M0MPB7JSArray7splice1 = (arr, idx, cnt, val) => arr.splice(idx, cnt, val); function _M0TPB9ArrayViewGRP36zxch3n5flock5flock5EntryE(param0, param1, param2) { this.buf = param0; this.start = param1; this.end = param2; } function _M0DTPC16result6ResultGiiE3Err(param0) { this._0 = param0; } _M0DTPC16result6ResultGiiE3Err.prototype.$tag = 0; function _M0DTPC16result6ResultGiiE2Ok(param0) { this._0 = param0; } _M0DTPC16result6ResultGiiE2Ok.prototype.$tag = 1; function _M0TPB9ArrayViewGsE(param0, param1, param2) { this.buf = param0; this.start = param1; this.end = param2; } const _M0FPC13env13now__internal = function() { const nowMs = Date.now(); return BigInt.asUintN(64, BigInt(nowMs)); }; function _M0DTPC16result6ResultGuRPB7FailureE3Err(param0) { this._0 = param0; } _M0DTPC16result6ResultGuRPB7FailureE3Err.prototype.$tag = 0; function _M0DTPC16result6ResultGuRPB7FailureE2Ok(param0) { this._0 = param0; } _M0DTPC16result6ResultGuRPB7FailureE2Ok.prototype.$tag = 1; function _M0DTPC15error5Error50zxch3n_2fflock_2fflock_2eImportError_2eInvalidJson(param0, param1) { this._0 = param0; this._1 = param1; } _M0DTPC15error5Error50zxch3n_2fflock_2fflock_2eImportError_2eInvalidJson.prototype.$tag = 17; function _M0DTPC15error5Error46zxch3n_2fflock_2fflock_2ePutError_2eInvalidKey(param0) { this._0 = param0; } _M0DTPC15error5Error46zxch3n_2fflock_2fflock_2ePutError_2eInvalidKey.prototype.$tag = 16; function _M0DTPC15error5Error54zxch3n_2fflock_2fflock_2ePutError_2eInvalidValueForMvr(param0) { this._0 = param0; } _M0DTPC15error5Error54zxch3n_2fflock_2fflock_2ePutError_2eInvalidValueForMvr.prototype.$tag = 15; function _M0DTPC15error5Error54zxch3n_2fflock_2fmemcomparable_2eKeyError_2eInvalidTag(param0) { this._0 = param0; } _M0DTPC15error5Error54zxch3n_2fflock_2fmemcomparable_2eKeyError_2eInvalidTag.prototype.$tag = 14; function _M0DTPC15error5Error57zxch3n_2fflock_2fmemcomparable_2eKeyError_2eUnexpectedEOF() {} _M0DTPC15error5Error57zxch3n_2fflock_2fmemcomparable_2eKeyError_2eUnexpectedEOF.prototype.$tag = 13; const _M0DTPC15error5Error57zxch3n_2fflock_2fmemcomparable_2eKeyError_2eUnexpectedEOF__ = new _M0DTPC15error5Error57zxch3n_2fflock_2fmemcomparable_2eKeyError_2eUnexpectedEOF(); function _M0DTPC15error5Error55zxch3n_2fflock_2fmemcomparable_2eKeyError_2eInvalidUTF8() {} _M0DTPC15error5Error55zxch3n_2fflock_2fmemcomparable_2eKeyError_2eInvalidUTF8.prototype.$tag = 12; const _M0DTPC15error5Error55zxch3n_2fflock_2fmemcomparable_2eKeyError_2eInvalidUTF8__ = new _M0DTPC15error5Error55zxch3n_2fflock_2fmemcomparable_2eKeyError_2eInvalidUTF8(); function _M0DTPC15error5Error55zxch3n_2fflock_2fmemcomparable_2eKeyError_2eNaNFloatKey() {} _M0DTPC15error5Error55zxch3n_2fflock_2fmemcomparable_2eKeyError_2eNaNFloatKey.prototype.$tag = 11; const _M0DTPC15error5Error55zxch3n_2fflock_2fmemcomparable_2eKeyError_2eNaNFloatKey__ = new _M0DTPC15error5Error55zxch3n_2fflock_2fmemcomparable_2eKeyError_2eNaNFloatKey(); function _M0DTPC15error5Error44Yoorkin_2fjmop_2eRuntimeError_2eRuntimeError(param0) { this._0 = param0; } _M0DTPC15error5Error44Yoorkin_2fjmop_2eRuntimeError_2eRuntimeError.prototype.$tag = 10; function _M0DTPC15error5Error60Yoorkin_2fjmop_2eInvalidNestedPromise_2eInvalidNestedPromise(param0) { this._0 = param0; } _M0DTPC15error5Error60Yoorkin_2fjmop_2eInvalidNestedPromise_2eInvalidNestedPromise.prototype.$tag = 9; function _M0DTPC15error5Error40Yoorkin_2fjmop_2eUnwrapNull_2eUnwrapNull(param0) { this._0 = param0; } _M0DTPC15error5Error40Yoorkin_2fjmop_2eUnwrapNull_2eUnwrapNull.prototype.$tag = 8; function _M0DTPC15error5Error50Yoorkin_2fjmop_2eUnwrapUndefined_2eUnwrapUndefined(param0) { this._0 = param0; } _M0DTPC15error5Error50Yoorkin_2fjmop_2eUnwrapUndefined_2eUnwrapUndefined.prototype.$tag = 7; function _M0DTPC15error5Error52moonbitlang_2fcore_2fjson_2eParseError_2eInvalidChar(param0, param1) { this._0 = param0; this._1 = param1; } _M0DTPC15error5Error52moonbitlang_2fcore_2fjson_2eParseError_2eInvalidChar.prototype.$tag = 6; function _M0DTPC15error5Error51moonbitlang_2fcore_2fjson_2eParseError_2eInvalidEof() {} _M0DTPC15error5Error51moonbitlang_2fcore_2fjson_2eParseError_2eInvalidEof.prototype.$tag = 5; const _M0DTPC15error5Error51moonbitlang_2fcore_2fjson_2eParseError_2eInvalidEof__ = new _M0DTPC15error5Error51moonbitlang_2fcore_2fjson_2eParseError_2eInvalidEof(); function _M0DTPC15error5Error54moonbitlang_2fcore_2fjson_2eParseError_2eInvalidNumber(param0, param1) { this._0 = param0; this._1 = param1; } _M0DTPC15error5Error54moonbitlang_2fcore_2fjson_2eParseError_2eInvalidNumber.prototype.$tag = 4; function _M0DTPC15error5Error59moonbitlang_2fcore_2fjson_2eParseError_2eInvalidIdentEscape(param0) { this._0 = param0; } _M0DTPC15error5Error59moonbitlang_2fcore_2fjson_2eParseError_2eInvalidIdentEscape.prototype.$tag = 3; function _M0DTPC15error5Error59moonbitlang_2fcore_2fjson_2eParseError_2eDepthLimitExceeded() {} _M0DTPC15error5Error59moonbitlang_2fcore_2fjson_2eParseError_2eDepthLimitExceeded.prototype.$tag = 2; const _M0DTPC15error5Error59moonbitlang_2fcore_2fjson_2eParseError_2eDepthLimitExceeded__ = new _M0DTPC15error5Error59moonbitlang_2fcore_2fjson_2eParseError_2eDepthLimitExceeded(); function _M0DTPC15error5Error48moonbitlang_2fcore_2fbuiltin_2eFailure_2eFailure(param0) { this._0 = param0; } _M0DTPC15error5Error48moonbitlang_2fcore_2fbuiltin_2eFailure_2eFailure.prototype.$tag = 1; function _M0DTPC15error5Error42Yoorkin_2fjmop_2eInvalidCast_2eInvalidCast(param0) { this._0 = param0; } _M0DTPC15error5Error42Yoorkin_2fjmop_2eInvalidCast_2eInvalidCast.prototype.$tag = 0; function _M0DTPC16result6ResultGdRPB7FailureE3Err(param0) { this._0 = param0; } _M0DTPC16result6ResultGdRPB7FailureE3Err.prototype.$tag = 0; function _M0DTPC16result6ResultGdRPB7FailureE2Ok(param0) { this._0 = param0; } _M0DTPC16result6ResultGdRPB7FailureE2Ok.prototype.$tag = 1; function _M0DTPC16result6ResultGORPC28internal7strconv6NumberRPB7FailureE3Err(param0) { this._0 = param0; } _M0DTPC16result6ResultGORPC28internal7strconv6NumberRPB7FailureE3Err.prototype.$tag = 0; function _M0DTPC16result6ResultGORPC28internal7strconv6NumberRPB7FailureE2Ok(param0) { this._0 = param0; } _M0DTPC16result6ResultGORPC28internal7strconv6NumberRPB7FailureE2Ok.prototype.$tag = 1; function _M0DTPC16result6ResultGRPC16string10StringViewRPB7FailureE3Err(param0) { this._0 = param0; } _M0DTPC16result6ResultGRPC16string10StringViewRPB7FailureE3Err.prototype.$tag = 0; function _M0DTPC16result6ResultGRPC16string10StringViewRPB7FailureE2Ok(param0) { this._0 = param0; } _M0DTPC16result6ResultGRPC16string10StringViewRPB7FailureE2Ok.prototype.$tag = 1; function _M0DTPC16result6ResultGORPC28internal7strconv6NumberRPC15error5ErrorE3Err(param0) { this._0 = param0; } _M0DTPC16result6ResultGORPC28internal7strconv6NumberRPC15error5ErrorE3Err.prototype.$tag = 0; function _M0DTPC16result6ResultGORPC28internal7strconv6NumberRPC15error5ErrorE2Ok(param0) { this._0 = param0; } _M0DTPC16result6ResultGORPC28internal7strconv6NumberRPC15error5ErrorE2Ok.prototype.$tag = 1; function _M0TPC28internal7strconv6Number(param0, param1, param2, param3) { this.exponent = param0; this.mantissa = param1; this.negative = param2; this.many_digits = param3; } function _M0DTPC16result6ResultGdRPC15error5ErrorE3Err(param0) { this._0 = param0; } _M0DTPC16result6ResultGdRPC15error5ErrorE3Err.prototype.$tag = 0; function _M0DTPC16result6ResultGdRPC15error5ErrorE2Ok(param0) { this._0 = param0; } _M0DTPC16result6ResultGdRPC15error5ErrorE2Ok.prototype.$tag = 1; function $i64_clz(a) { a = BigInt.asUintN(64, a); if (a === 0n) return 64; const hi = Number(a >> 32n); if (hi !== 0) { return Math.clz32(hi); } return 32 + Math.clz32(Number(a & 0xffffffffn)); } function _M0TPC28internal7strconv7Decimal(param0, param1, param2, param3, param4) { this.digits = param0; this.digits_num = param1; this.decimal_point = param2; this.negative = param3; this.truncated = param4; } function _M0DTPC16result6ResultGRPC28internal7strconv7DecimalRPC15error5ErrorE3Err(param0) { this._0 = param0; } _M0DTPC16result6ResultGRPC28internal7strconv7DecimalRPC15error5ErrorE3Err.prototype.$tag = 0; function _M0DTPC16result6ResultGRPC28internal7strconv7DecimalRPC15error5ErrorE2Ok(param0) { this._0 = param0; } _M0DTPC16result6ResultGRPC28internal7strconv7DecimalRPC15error5ErrorE2Ok.prototype.$tag = 1; function $f64_convert_i64_u(a) { return Number(a); } function _M0DTPC16option6OptionGdE4None() {} _M0DTPC16option6OptionGdE4None.prototype.$tag = 0; const _M0DTPC16option6OptionGdE4None__ = new _M0DTPC16option6OptionGdE4None(); function _M0DTPC16option6OptionGdE4Some(param0) { this._0 = param0; } _M0DTPC16option6OptionGdE4Some.prototype.$tag = 1; function _M0TPC16buffer6Buffer(param0, param1) { this.data = param0; this.len = param1; } function _M0TPC14json8Position(param0, param1) { this.line = param0; this.column = param1; } function _M0DTPC16result6ResultGRPB4JsonRPC14json10ParseErrorE3Err(param0) { this._0 = param0; } _M0DTPC16result6ResultGRPB4JsonRPC14json10ParseErrorE3Err.prototype.$tag = 0; function _M0DTPC16result6ResultGRPB4JsonRPC14json10ParseErrorE2Ok(param0) { this._0 = param0; } _M0DTPC16result6ResultGRPB4JsonRPC14json10ParseErrorE2Ok.prototype.$tag = 1; function _M0DTPC16result6ResultGuRPC14json10ParseErrorE3Err(param0) { this._0 = param0; } _M0DTPC16result6ResultGuRPC14json10ParseErrorE3Err.prototype.$tag = 0; function _M0DTPC16result6ResultGuRPC14json10ParseErrorE2Ok(param0) { this._0 = param0; } _M0DTPC16result6ResultGuRPC14json10ParseErrorE2Ok.prototype.$tag = 1; function _M0TPC14json12ParseContext(param0, param1, param2, param3) { this.offset = param0; this.input = param1; this.end_offset = param2; this.remaining_available_depth = param3; } function $f64_convert_i64(a) { return Number(BigInt.asIntN(64, a)); } function _M0TPC14json14JsonNumberScan(param0, param1, param2, param3, param4) { this.negative = param0; this.is_integer = param1; this.mantissa = param2; this.exponent = param3; this.many_digits = param4; } function _M0DTPC16result6ResultGUdORPC16string10StringViewERPC14json10ParseErrorE3Err(param0) { this._0 = param0; } _M0DTPC16result6ResultGUdORPC16string10StringViewERPC14json10ParseErrorE3Err.prototype.$tag = 0; function _M0DTPC16result6ResultGUdORPC16string10StringViewERPC14json10ParseErrorE2Ok(param0) { this._0 = param0; } _M0DTPC16result6ResultGUdORPC16string10StringViewERPC14json10ParseErrorE2Ok.prototype.$tag = 1; function _M0DTPC16result6ResultGiRPC14json10ParseErrorE3Err(param0) { this._0 = param0; } _M0DTPC16result6ResultGiRPC14json10ParseErrorE3Err.prototype.$tag = 0; function _M0DTPC16result6ResultGiRPC14json10ParseErrorE2Ok(param0) { this._0 = param0; } _M0DTPC16result6ResultGiRPC14json10ParseErrorE2Ok.prototype.$tag = 1; function _M0DTPC16result6ResultGsRPC14json10ParseErrorE3Err(param0) { this._0 = param0; } _M0DTPC16result6ResultGsRPC14json10ParseErrorE3Err.prototype.$tag = 0; function _M0DTPC16result6ResultGsRPC14json10ParseErrorE2Ok(param0) { this._0 = param0; } _M0DTPC16result6ResultGsRPC14json10ParseErrorE2Ok.prototype.$tag = 1; function _M0DTPC16result6ResultGRPC14json5TokenRPC14json10ParseErrorE3Err(param0) { this._0 = param0; } _M0DTPC16result6ResultGRPC14json5TokenRPC14json10ParseErrorE3Err.prototype.$tag = 0; function _M0DTPC16result6ResultGRPC14json5TokenRPC14json10ParseErrorE2Ok(param0) { this._0 = param0; } _M0DTPC16result6ResultGRPC14json5TokenRPC14json10ParseErrorE2Ok.prototype.$tag = 1; function _M0DTPC14json5Token4Null() {} _M0DTPC14json5Token4Null.prototype.$tag = 0; const _M0DTPC14json5Token4Null__ = new _M0DTPC14json5Token4Null(); function _M0DTPC14json5Token4True() {} _M0DTPC14json5Token4True.prototype.$tag = 1; const _M0DTPC14json5Token4True__ = new _M0DTPC14json5Token4True(); function _M0DTPC14json5Token5False() {} _M0DTPC14json5Token5False.prototype.$tag = 2; const _M0DTPC14json5Token5False__ = new _M0DTPC14json5Token5False(); function _M0DTPC14json5Token6Number(param0, param1) { this._0 = param0; this._1 = param1; } _M0DTPC14json5Token6Number.prototype.$tag = 3; function _M0DTPC14json5Token6String(param0) { this._0 = param0; } _M0DTPC14json5Token6String.prototype.$tag = 4; function _M0DTPC14json5Token6LBrace() {} _M0DTPC14json5Token6LBrace.prototype.$tag = 5; const _M0DTPC14json5Token6LBrace__ = new _M0DTPC14json5Token6LBrace(); function _M0DTPC14json5Token6RBrace() {} _M0DTPC14json5Token6RBrace.prototype.$tag = 6; const _M0DTPC14json5Token6RBrace__ = new _M0DTPC14json5Token6RBrace(); function _M0DTPC14json5Token8LBracket() {} _M0DTPC14json5Token8LBracket.prototype.$tag = 7; const _M0DTPC14json5Token8LBracket__ = new _M0DTPC14json5Token8LBracket(); function _M0DTPC14json5Token8RBracket() {} _M0DTPC14json5Token8RBracket.prototype.$tag = 8; const _M0DTPC14json5Token8RBracket__ = new _M0DTPC14json5Token8RBracket(); function _M0DTPC14json5Token5Comma() {} _M0DTPC14json5Token5Comma.prototype.$tag = 9; const _M0DTPC14json5Token5Comma__ = new _M0DTPC14json5Token5Comma(); function _M0DTPC14json10WriteFrame5Array(param0, param1) { this._0 = param0; this._1 = param1; } _M0DTPC14json10WriteFrame5Array.prototype.$tag = 0; function _M0DTPC14json10WriteFrame6Object(param0, param1) { this._0 = param0; this._1 = param1; } _M0DTPC14json10WriteFrame6Object.prototype.$tag = 1; const _M0MPC16bigint6BigInt9from__int = (x) => BigInt(x); const _M0MPC16bigint6BigInt7compare = (x, y) => x < y ? -1 : x > y ? 1 : 0; const _M0MPC16bigint6BigInt5equal = (x, y) => x === y; const _M0MPC16bigint6BigInt11from__int64 = (x) => BigInt.asIntN(64, x); const _M0MPC16bigint6BigInt12op__neg__ffi = (x) => -x; const _M0MPC16bigint6BigInt12op__add__ffi = (x, y) => x + y; const _M0MPC16bigint6BigInt12op__mul__ffi = (x, y) => x * y; const _M0MPC16bigint6BigInt12op__div__ffi = (x, y) => x / y; const _M0MPC16bigint6BigInt12op__mod__ffi = (x, y) => x % y; const _M0MPC16bigint6BigInt7js__shr = (x, y) => x >> BigInt(y); const _M0MPC16bigint6BigInt8to__uint = (x) => Number(BigInt.asUintN(32, x)) | 0; const _M0MPC16bigint6BigInt7to__int = (x) => Number(BigInt.asIntN(32, x)); const _M0FP27Yoorkin4jmop11ffi__typeof = (x) => typeof x; function _M0DTPC16result6ResultGdRP27Yoorkin4jmop11InvalidCastE3Err(param0) { this._0 = param0; } _M0DTPC16result6ResultGdRP27Yoorkin4jmop11InvalidCastE3Err.prototype.$tag = 0; function _M0DTPC16result6ResultGdRP27Yoorkin4jmop11InvalidCastE2Ok(param0) { this._0 = param0; } _M0DTPC16result6ResultGdRP27Yoorkin4jmop11InvalidCastE2Ok.prototype.$tag = 1; function _M0DTPC16result6ResultGsRP27Yoorkin4jmop11InvalidCastE3Err(param0) { this._0 = param0; } _M0DTPC16result6ResultGsRP27Yoorkin4jmop11InvalidCastE3Err.prototype.$tag = 0; function _M0DTPC16result6ResultGsRP27Yoorkin4jmop11InvalidCastE2Ok(param0) { this._0 = param0; } _M0DTPC16result6ResultGsRP27Yoorkin4jmop11InvalidCastE2Ok.prototype.$tag = 1; const _M0FP27Yoorkin4jmop21ffi__object__is__null = (x) => x === null; const _M0FP27Yoorkin4jmop14ffi__is__array = (x) => Array.isArray(x); function _M0DTPC16result6ResultGRP27Yoorkin4jmop5ValueRP27Yoorkin4jmop11InvalidCastE3Err(param0) { this._0 = param0; } _M0DTPC16result6ResultGRP27Yoorkin4jmop5ValueRP27Yoorkin4jmop11InvalidCastE3Err.prototype.$tag = 0; function _M0DTPC16result6ResultGRP27Yoorkin4jmop5ValueRP27Yoorkin4jmop11InvalidCastE2Ok(param0) { this._0 = param0; } _M0DTPC16result6ResultGRP27Yoorkin4jmop5ValueRP27Yoorkin4jmop11InvalidCastE2Ok.prototype.$tag = 1; function _M0DTPC16result6ResultGRPB5ArrayGRP27Yoorkin4jmop5ValueERP27Yoorkin4jmop11InvalidCastE3Err(param0) { this._0 = param0; } _M0DTPC16result6ResultGRPB5ArrayGRP27Yoorkin4jmop5ValueERP27Yoorkin4jmop11InvalidCastE3Err.prototype.$tag = 0; function _M0DTPC16result6ResultGRPB5ArrayGRP27Yoorkin4jmop5ValueERP27Yoorkin4jmop11InvalidCastE2Ok(param0) { this._0 = param0; } _M0DTPC16result6ResultGRPB5ArrayGRP27Yoorkin4jmop5ValueERP27Yoorkin4jmop11InvalidCastE2Ok.prototype.$tag = 1; const _M0FP27Yoorkin4jmop14ffi__undefined = () => undefined; const _M0FP27Yoorkin4jmop18ffi__is__undefined = (x) => x === undefined; function _M0DTPC16result6ResultGRP27Yoorkin4jmop8NullableGRP27Yoorkin4jmop5ValueERP27Yoorkin4jmop15UnwrapUndefinedE3Err(param0) { this._0 = param0; } _M0DTPC16result6ResultGRP27Yoorkin4jmop8NullableGRP27Yoorkin4jmop5ValueERP27Yoorkin4jmop15UnwrapUndefinedE3Err.prototype.$tag = 0; function _M0DTPC16result6ResultGRP27Yoorkin4jmop8NullableGRP27Yoorkin4jmop5ValueERP27Yoorkin4jmop15UnwrapUndefinedE2Ok(param0) { this._0 = param0; } _M0DTPC16result6ResultGRP27Yoorkin4jmop8NullableGRP27Yoorkin4jmop5ValueERP27Yoorkin4jmop15UnwrapUndefinedE2Ok.prototype.$tag = 1; function _M0DTPC16result6ResultGRP27Yoorkin4jmop5ValueRP27Yoorkin4jmop10UnwrapNullE3Err(param0) { this._0 = param0; } _M0DTPC16result6ResultGRP27Yoorkin4jmop5ValueRP27Yoorkin4jmop10UnwrapNullE3Err.prototype.$tag = 0; function _M0DTPC16result6ResultGRP27Yoorkin4jmop5ValueRP27Yoorkin4jmop10UnwrapNullE2Ok(param0) { this._0 = param0; } _M0DTPC16result6ResultGRP27Yoorkin4jmop5ValueRP27Yoorkin4jmop10UnwrapNullE2Ok.prototype.$tag = 1; const _M0FP27Yoorkin4jmop9ffi__init = (convert_thrown_error, ) => { globalThis["MoonBit"] = { Result: { Ok: (x) => ({ $tag: 1, _0: x}), Err: (x) => ({ $tag: 1, _0: x}) }, Error: { // raise a special js error raise: function(tag, payload0, payload1){ throw { jmop_error_tag: tag, _0: payload0, _1: payload1 } }, // is special error is_error: function(x) { !!x && typeof x.jmop_error_tag === 'string' }, // convert the special js error to moonbit error convert: function(e) { return this.is_error(e) ? convert_thrown_error(e.jmop_error_tag, e['_0'], e['_1']) : convert_thrown_error("unknown", e, undefined) }, // get special error tag or payloads tag: function(x) { x.jmop_error_tag }, payload0: function(x) { x['_0'] }, payload0: function(x) { x['_1'] }, // tags InvalidNestedPromise: "InvalidNestedPromise", }, Promise: { is_promise: (p) => !!p && typeof p.then === 'function', not_promise_or_throw: function(x, loc) { if(MoonBit.Promise.is_promise(x)){ MoonBit.Error.raise(MoonBit.Error.InvalidNestedPromise, loc) } else { return x } }, handle_thrown: function(p) { p.catch(e => MoonBit.Error.convert(e)) } } } }; function _M0DTPC16result6ResultGuRP27Yoorkin4jmop20InvalidNestedPromiseE3Err(param0) { this._0 = param0; } _M0DTPC16result6ResultGuRP27Yoorkin4jmop20InvalidNestedPromiseE3Err.prototype.$tag = 0; function _M0DTPC16result6ResultGuRP27Yoorkin4jmop20InvalidNestedPromiseE2Ok(param0) { this._0 = param0; } _M0DTPC16result6ResultGuRP27Yoorkin4jmop20InvalidNestedPromiseE2Ok.prototype.$tag = 1; function _M0DTPC16result6ResultGuRP27Yoorkin4jmop12RuntimeErrorE3Err(param0) { this._0 = param0; } _M0DTPC16result6ResultGuRP27Yoorkin4jmop12RuntimeErrorE3Err.prototype.$tag = 0; function _M0DTPC16result6ResultGuRP27Yoorkin4jmop12RuntimeErrorE2Ok(param0) { this._0 = param0; } _M0DTPC16result6ResultGuRP27Yoorkin4jmop12RuntimeErrorE2Ok.prototype.$tag = 1; function _M0TP27gmlewis6sha2566Digest(param0, param1, param2, param3, param4) { this.h = param0; this.x = param1; this.nx = param2; this.len = param3; this.name = param4; } function _M0TPB9ArrayViewGjE(param0, param1, param2) { this.buf = param0; this.start = param1; this.end = param2; } function _M0TP26zxch3n6expect8Formated(param0, param1, param2, param3) { this.str = param0; this.bg_color = param1; this.color = param2; this.formats = param3; } function _M0TP36zxch3n5flock5types7Utf8Str(param0) { this.bytes = param0; } function _M0TP36zxch3n5flock13memcomparable3Key(param0) { this.parts = param0; } function $f64_reinterpret_i64(a) { $reinterpret_view.setFloat64(0, a, false); return BigInt.asUintN(64, $reinterpret_view.getBigUint64(0, false)); } function _M0DTPC16result6ResultGURPC15bytes9BytesViewiERP36zxch3n5flock13memcomparable8KeyErrorE3Err(param0) { this._0 = param0; } _M0DTPC16result6ResultGURPC15bytes9BytesViewiERP36zxch3n5flock13memcomparable8KeyErrorE3Err.prototype.$tag = 0; function _M0DTPC16result6ResultGURPC15bytes9BytesViewiERP36zxch3n5flock13memcomparable8KeyErrorE2Ok(param0) { this._0 = param0; } _M0DTPC16result6ResultGURPC15bytes9BytesViewiERP36zxch3n5flock13memcomparable8KeyErrorE2Ok.prototype.$tag = 1; function _M0DTPC16result6ResultGURPC15bytes9BytesViewRPC16bigint6BigIntERP36zxch3n5flock13memcomparable8KeyErrorE3Err(param0) { this._0 = param0; } _M0DTPC16result6ResultGURPC15bytes9BytesViewRPC16bigint6BigIntERP36zxch3n5flock13memcomparable8KeyErrorE3Err.prototype.$tag = 0; function _M0DTPC16result6ResultGURPC15bytes9BytesViewRPC16bigint6BigIntERP36zxch3n5flock13memcomparable8KeyErrorE2Ok(param0) { this._0 = param0; } _M0DTPC16result6ResultGURPC15bytes9BytesViewRPC16bigint6BigIntERP36zxch3n5flock13memcomparable8KeyErrorE2Ok.prototype.$tag = 1; function _M0DTPC16result6ResultGUdiERP36zxch3n5flock13memcomparable8KeyErrorE3Err(param0) { this._0 = param0; } _M0DTPC16result6ResultGUdiERP36zxch3n5flock13memcomparable8KeyErrorE3Err.prototype.$tag = 0; function _M0DTPC16result6ResultGUdiERP36zxch3n5flock13memcomparable8KeyErrorE2Ok(param0) { this._0 = param0; } _M0DTPC16result6ResultGUdiERP36zxch3n5flock13memcomparable8KeyErrorE2Ok.prototype.$tag = 1; function _M0DTPC16result6ResultGRP36zxch3n5flock13memcomparable3KeyRP36zxch3n5flock13memcomparable8KeyErrorE3Err(param0) { this._0 = param0; } _M0DTPC16result6ResultGRP36zxch3n5flock13memcomparable3KeyRP36zxch3n5flock13memcomparable8KeyErrorE3Err.prototype.$tag = 0; function _M0DTPC16result6ResultGRP36zxch3n5flock13memcomparable3KeyRP36zxch3n5flock13memcomparable8KeyErrorE2Ok(param0) { this._0 = param0; } _M0DTPC16result6ResultGRP36zxch3n5flock13memcomparable3KeyRP36zxch3n5flock13memcomparable8KeyErrorE2Ok.prototype.$tag = 1; function _M0DTP36zxch3n5flock13memcomparable7KeyPart5Bytes(param0) { this._0 = param0; } _M0DTP36zxch3n5flock13memcomparable7KeyPart5Bytes.prototype.$tag = 0; function _M0DTP36zxch3n5flock13memcomparable7KeyPart6String(param0) { this._0 = param0; } _M0DTP36zxch3n5flock13memcomparable7KeyPart6String.prototype.$tag = 1; function _M0DTP36zxch3n5flock13memcomparable7KeyPart3Int(param0) { this._0 = param0; } _M0DTP36zxch3n5flock13memcomparable7KeyPart3Int.prototype.$tag = 2; function _M0DTP36zxch3n5flock13memcomparable7KeyPart5Float(param0) { this._0 = param0; } _M0DTP36zxch3n5flock13memcomparable7KeyPart5Float.prototype.$tag = 3; function _M0DTP36zxch3n5flock13memcomparable7KeyPart5False() {} _M0DTP36zxch3n5flock13memcomparable7KeyPart5False.prototype.$tag = 4; const _M0DTP36zxch3n5flock13memcomparable7KeyPart5False__ = new _M0DTP36zxch3n5flock13memcomparable7KeyPart5False(); function _M0DTP36zxch3n5flock13memcomparable7KeyPart4True() {} _M0DTP36zxch3n5flock13memcomparable7KeyPart4True.prototype.$tag = 5; const _M0DTP36zxch3n5flock13memcomparable7KeyPart4True__ = new _M0DTP36zxch3n5flock13memcomparable7KeyPart4True(); function _M0TP36zxch3n5flock11sorted__map9SortedMapGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(param0, param1) { this.root = param0; this.size = param1; } function _M0TP36zxch3n5flock11sorted__map9SortedMapGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(param0, param1) { this.root = param0; this.size = param1; } function _M0TP36zxch3n5flock11sorted__map4NodeGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(param0, param1, param2, param3, param4) { this.key = param0; this.value = param1; this.left = param2; this.right = param3; this.height = param4; } function _M0TP36zxch3n5flock11sorted__map4NodeGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(param0, param1, param2, param3, param4) { this.key = param0; this.value = param1; this.left = param2; this.right = param3; this.height = param4; } function _M0DTPC16option6OptionGRPB5ArrayGRP36zxch3n5flock5flock5EntryEE4None() {} _M0DTPC16option6OptionGRPB5ArrayGRP36zxch3n5flock5flock5EntryEE4None.prototype.$tag = 0; const _M0DTPC16option6OptionGRPB5ArrayGRP36zxch3n5flock5flock5EntryEE4None__ = new _M0DTPC16option6OptionGRPB5ArrayGRP36zxch3n5flock5flock5EntryEE4None(); function _M0DTPC16option6OptionGRPB5ArrayGRP36zxch3n5flock5flock5EntryEE4Some(param0) { this._0 = param0; } _M0DTPC16option6OptionGRPB5ArrayGRP36zxch3n5flock5flock5EntryEE4Some.prototype.$tag = 1; function _M0TPB8MutLocalGbE(param0) { this.val = param0; } function _M0TP36zxch3n5flock5flock13SubscriberSetGRP36zxch3n5flock5flock10EventBatchE(param0, param1) { this.seq = param0; this.subscribers = param1; } function _M0TP36zxch3n5flock5flock11HlcWithPeer(param0, param1) { this.hlc = param0; this.peer = param1; } function _M0TP36zxch3n5flock5flock11FlockDigest(param0) { this.bytes = param0; } function _M0TP36zxch3n5flock5flock12DigestWriter(param0) { this.digest = param0; } function _M0TP36zxch3n5flock5flock5Entry(param0, param1, param2) { this.key = param0; this.value = param1; this.overridden = param2; } function _M0TP36zxch3n5flock5flock8RawValue(param0, param1, param2) { this.data = param0; this.metadata = param1; this.clock = param2; } function _M0TP36zxch3n5flock5flock9EntryInfo(param0, param1, param2) { this.data = param0; this.metadata = param1; this.clock = param2; } function _M0DTPC16option6OptionGRPB5ArrayGURPB5ArrayGRPB4JsonERP36zxch3n5flock5flock8RawValueEEE4None() {} _M0DTPC16option6OptionGRPB5ArrayGURPB5ArrayGRPB4JsonERP36zxch3n5flock5flock8RawValueEEE4None.prototype.$tag = 0; const _M0DTPC16option6OptionGRPB5ArrayGURPB5ArrayGRPB4JsonERP36zxch3n5flock5flock8RawValueEEE4None__ = new _M0DTPC16option6OptionGRPB5ArrayGURPB5ArrayGRPB4JsonERP36zxch3n5flock5flock8RawValueEEE4None(); function _M0DTPC16option6OptionGRPB5ArrayGURPB5ArrayGRPB4JsonERP36zxch3n5flock5flock8RawValueEEE4Some(param0) { this._0 = param0; } _M0DTPC16option6OptionGRPB5ArrayGURPB5ArrayGRPB4JsonERP36zxch3n5flock5flock8RawValueEEE4Some.prototype.$tag = 1; function _M0TP36zxch3n5flock5flock5Flock(param0, param1, param2, param3, param4, param5, param6, param7) { this.peer_id = param0; this.max_hlc = param1; this.vv = param2; this.kv = param3; this.updates = param4; this.subscribers = param5; this.digest = param6; this.txn_events = param7; } function _M0DTPC16result6ResultGuRP36zxch3n5flock5flock8PutErrorE3Err(param0) { this._0 = param0; } _M0DTPC16result6ResultGuRP36zxch3n5flock5flock8PutErrorE3Err.prototype.$tag = 0; function _M0DTPC16result6ResultGuRP36zxch3n5flock5flock8PutErrorE2Ok(param0) { this._0 = param0; } _M0DTPC16result6ResultGuRP36zxch3n5flock5flock8PutErrorE2Ok.prototype.$tag = 1; function _M0TP36zxch3n5flock5flock10EventBatch(param0, param1) { this.by = param0; this.events = param1; } function _M0DTPC16option6OptionGORPB3MapGsRPB4JsonEE4None() {} _M0DTPC16option6OptionGORPB3MapGsRPB4JsonEE4None.prototype.$tag = 0; const _M0DTPC16option6OptionGORPB3MapGsRPB4JsonEE4None__ = new _M0DTPC16option6OptionGORPB3MapGsRPB4JsonEE4None(); function _M0DTPC16option6OptionGORPB3MapGsRPB4JsonEE4Some(param0) { this._0 = param0; } _M0DTPC16option6OptionGORPB3MapGsRPB4JsonEE4Some.prototype.$tag = 1; function _M0DTPC16option6OptionGOWRP36zxch3n5flock5flock5EntryEORP36zxch3n5flock5flock5EntryE4None() {} _M0DTPC16option6OptionGOWRP36zxch3n5flock5flock5EntryEORP36zxch3n5flock5flock5EntryE4None.prototype.$tag = 0; const _M0DTPC16option6OptionGOWRP36zxch3n5flock5flock5EntryEORP36zxch3n5flock5flock5EntryE4None__ = new _M0DTPC16option6OptionGOWRP36zxch3n5flock5flock5EntryEORP36zxch3n5flock5flock5EntryE4None(); function _M0DTPC16option6OptionGOWRP36zxch3n5flock5flock5EntryEORP36zxch3n5flock5flock5EntryE4Some(param0) { this._0 = param0; } _M0DTPC16option6OptionGOWRP36zxch3n5flock5flock5EntryEORP36zxch3n5flock5flock5EntryE4Some.prototype.$tag = 1; function _M0TPB8MutLocalGRPB5ArrayGRPB4JsonEE(param0) { this.val = param0; } function _M0DTP36zxch3n5flock11sorted__map5BoundGzE9Inclusive(param0) { this._0 = param0; } _M0DTP36zxch3n5flock11sorted__map5BoundGzE9Inclusive.prototype.$tag = 0; function _M0DTP36zxch3n5flock11sorted__map5BoundGzE9Exclusive(param0) { this._0 = param0; } _M0DTP36zxch3n5flock11sorted__map5BoundGzE9Exclusive.prototype.$tag = 1; function _M0DTP36zxch3n5flock11sorted__map5BoundGzE9Unbounded() {} _M0DTP36zxch3n5flock11sorted__map5BoundGzE9Unbounded.prototype.$tag = 2; const _M0DTP36zxch3n5flock11sorted__map5BoundGzE9Unbounded__ = new _M0DTP36zxch3n5flock11sorted__map5BoundGzE9Unbounded(); function _M0TPB8MutLocalGOzE(param0) { this.val = param0; } function _M0DTP36zxch3n5flock11sorted__map5BoundGRP36zxch3n5flock5types6NBytesE9Inclusive(param0) { this._0 = param0; } _M0DTP36zxch3n5flock11sorted__map5BoundGRP36zxch3n5flock5types6NBytesE9Inclusive.prototype.$tag = 0; function _M0DTP36zxch3n5flock11sorted__map5BoundGRP36zxch3n5flock5types6NBytesE9Exclusive(param0) { this._0 = param0; } _M0DTP36zxch3n5flock11sorted__map5BoundGRP36zxch3n5flock5types6NBytesE9Exclusive.prototype.$tag = 1; function _M0DTP36zxch3n5flock11sorted__map5BoundGRP36zxch3n5flock5types6NBytesE9Unbounded() {} _M0DTP36zxch3n5flock11sorted__map5BoundGRP36zxch3n5flock5types6NBytesE9Unbounded.prototype.$tag = 2; const _M0DTP36zxch3n5flock11sorted__map5BoundGRP36zxch3n5flock5types6NBytesE9Unbounded__ = new _M0DTP36zxch3n5flock11sorted__map5BoundGRP36zxch3n5flock5types6NBytesE9Unbounded(); function _M0DTP36zxch3n5flock11sorted__map5BoundGRPB5ArrayGRPB4JsonEE9Inclusive(param0) { this._0 = param0; } _M0DTP36zxch3n5flock11sorted__map5BoundGRPB5ArrayGRPB4JsonEE9Inclusive.prototype.$tag = 0; function _M0DTP36zxch3n5flock11sorted__map5BoundGRPB5ArrayGRPB4JsonEE9Exclusive(param0) { this._0 = param0; } _M0DTP36zxch3n5flock11sorted__map5BoundGRPB5ArrayGRPB4JsonEE9Exclusive.prototype.$tag = 1; function _M0DTP36zxch3n5flock11sorted__map5BoundGRPB5ArrayGRPB4JsonEE9Unbounded() {} _M0DTP36zxch3n5flock11sorted__map5BoundGRPB5ArrayGRPB4JsonEE9Unbounded.prototype.$tag = 2; const _M0DTP36zxch3n5flock11sorted__map5BoundGRPB5ArrayGRPB4JsonEE9Unbounded__ = new _M0DTP36zxch3n5flock11sorted__map5BoundGRPB5ArrayGRPB4JsonEE9Unbounded(); function _M0DTPC16result6ResultGRP36zxch3n5flock5flock12ImportReportRP36zxch3n5flock5flock11ImportErrorE3Err(param0) { this._0 = param0; } _M0DTPC16result6ResultGRP36zxch3n5flock5flock12ImportReportRP36zxch3n5flock5flock11ImportErrorE3Err.prototype.$tag = 0; function _M0DTPC16result6ResultGRP36zxch3n5flock5flock12ImportReportRP36zxch3n5flock5flock11ImportErrorE2Ok(param0) { this._0 = param0; } _M0DTPC16result6ResultGRP36zxch3n5flock5flock12ImportReportRP36zxch3n5flock5flock11ImportErrorE2Ok.prototype.$tag = 1; function _M0TP36zxch3n5flock5flock12SkippedEntry(param0, param1) { this.key = param0; this.reason = param1; } function _M0TP36zxch3n5flock5flock12ImportReport(param0, param1) { this.accepted = param0; this.skipped = param1; } function _M0DTPC16option6OptionGOsE4None() {} _M0DTPC16option6OptionGOsE4None.prototype.$tag = 0; const _M0DTPC16option6OptionGOsE4None__ = new _M0DTPC16option6OptionGOsE4None(); function _M0DTPC16option6OptionGOsE4Some(param0) { this._0 = param0; } _M0DTPC16option6OptionGOsE4Some.prototype.$tag = 1; function _M0DTPC16option6OptionGOWRP36zxch3n5flock5flock5EntryERP36zxch3n5flock5flock16PreprocessResultE4None() {} _M0DTPC16option6OptionGOWRP36zxch3n5flock5flock5EntryERP36zxch3n5flock5flock16PreprocessResultE4None.prototype.$tag = 0; const _M0DTPC16option6OptionGOWRP36zxch3n5flock5flock5EntryERP36zxch3n5flock5flock16PreprocessResultE4None__ = new _M0DTPC16option6OptionGOWRP36zxch3n5flock5flock5EntryERP36zxch3n5flock5flock16PreprocessResultE4None(); function _M0DTPC16option6OptionGOWRP36zxch3n5flock5flock5EntryERP36zxch3n5flock5flock16PreprocessResultE4Some(param0) { this._0 = param0; } _M0DTPC16option6OptionGOWRP36zxch3n5flock5flock5EntryERP36zxch3n5flock5flock16PreprocessResultE4Some.prototype.$tag = 1; function _M0DTPC16result6ResultGRP36zxch3n5flock5flock5FlockRP36zxch3n5flock5flock11ImportErrorE3Err(param0) { this._0 = param0; } _M0DTPC16result6ResultGRP36zxch3n5flock5flock5FlockRP36zxch3n5flock5flock11ImportErrorE3Err.prototype.$tag = 0; function _M0DTPC16result6ResultGRP36zxch3n5flock5flock5FlockRP36zxch3n5flock5flock11ImportErrorE2Ok(param0) { this._0 = param0; } _M0DTPC16result6ResultGRP36zxch3n5flock5flock5FlockRP36zxch3n5flock5flock11ImportErrorE2Ok.prototype.$tag = 1; function _M0DTPC16option6OptionGRPB5ArrayGRPB4JsonEE4None() {} _M0DTPC16option6OptionGRPB5ArrayGRPB4JsonEE4None.prototype.$tag = 0; const _M0DTPC16option6OptionGRPB5ArrayGRPB4JsonEE4None__ = new _M0DTPC16option6OptionGRPB5ArrayGRPB4JsonEE4None(); function _M0DTPC16option6OptionGRPB5ArrayGRPB4JsonEE4Some(param0) { this._0 = param0; } _M0DTPC16option6OptionGRPB5ArrayGRPB4JsonEE4Some.prototype.$tag = 1; const _M0FP36zxch3n5flock5flock27ffi__json__stringify__value = (value) => { const result = JSON.stringify(value); if (result === undefined) { throw new TypeError("Value is not JSON serializable"); } return result; }; const _M0FP36zxch3n5flock5flock30ffi__json__parse__to__nullable = (json) => JSON.parse(json); const _M0FP36zxch3n5flock5flock18ffi__any__is__null = (value) => value === null; const _M0FP36zxch3n5flock5flock23ffi__any__is__undefined = (value) => value === undefined; function _M0TP36zxch3n5flock5flock11DigestCache(param0, param1) { this.sum = param0; this.pending = param1; } const _M0FP36zxch3n5flock5flock21ffi__invoke__listener = (listener, event) => listener(event); const _M0FP36zxch3n5flock5flock22ffi__make__unsubscribe = (callback) => () => callback(); const _M0FP092moonbitlang_2fcore_2fbuiltin_2fStringBuilder_24as_24_40moonbitlang_2fcore_2fbuiltin_2eLogger = { method_0: _M0IPB13StringBuilderPB6Logger13write__string, method_1: _M0IP016_24default__implPB6Logger16write__substringGRPB13StringBuilderE, method_2: _M0IPB13StringBuilderPB6Logger11write__view, method_3: _M0IPB13StringBuilderPB6Logger11write__char, method_4: _M0IP016_24default__implPB6Logger28write__string__interpolationGRPB13StringBuilderE, method_5: _M0IP016_24default__implPB6Logger5writeGRPB13StringBuilderE }; const _M0FPB4null = _M0DTPB4Json4Null__; const _M0MPB4Iter4nextN6constrS8926GURP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEEE = 0; const _M0MPB4Iter4nextN6constrS8927GURP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEEE = 0; const _M0MPB4Iter4nextN6constrS8926GyE = 0; const _M0MPB4Iter4nextN6constrS8927GyE = 0; const _M0MPB4Iter4nextN6constrS8926GcE = 0; const _M0MPB4Iter4nextN6constrS8927GcE = 0; const _M0MPB4Iter4nextN6constrS8926GRP26zxch3n6expect6FormatE = 0; const _M0MPB4Iter4nextN6constrS8927GRP26zxch3n6expect6FormatE = 0; const _M0MPB4Iter3newN6constrS8934GUsRPB4JsonEE = 0; const _M0MPB4Iter3newN6constrS8934GyE = 0; const _M0MPB4Iter3newN6constrS8934GcE = 0; const _M0MPB4Iter3newN6constrS8934GRP26zxch3n6expect6FormatE = 0; const _M0MPB5Iter23newN6constrS8935GRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE = 0; const _M0MPB5Iter23newN6constrS8935GRPB5ArrayGRPB4JsonERP36zxch3n5flock5flock5EntryE = 0; const _M0MPB5Iter23newN6constrS8935GRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE = 0; const _M0FPC16double14not__a__number = $i64_reinterpret_f64(9221120237041090561n); const _M0FPC16double8infinity = $i64_reinterpret_f64(9218868437227405312n); const _M0FPC16double13neg__infinity = $i64_reinterpret_f64(18442240474082181120n); const _M0FPC28internal7strconv15range__err__str = "value out of range"; const _M0FPC28internal7strconv16syntax__err__str = "invalid syntax"; const _M0FPC28internal7strconv17min__19digit__int = 1000000000000000000n; const _M0FPC28internal7strconv17parse__scientificN8exp__numS241 = 0n; const _M0FPC28internal7strconv13parse__numberN11exp__numberS222 = 0n; const _M0FPC28internal7strconv12double__info = new _M0TPC28internal7strconv9FloatInfo(52, 11, -1023); const _M0FPC28internal7strconv25min__exponent__fast__path = 18446744073709551594n; const _M0FPC28internal7strconv25max__exponent__fast__path = 22n; const _M0FPC28internal7strconv36max__exponent__disguised__fast__path = 37n; const _M0FPC28internal7strconv25max__mantissa__fast__path = 9007199254740992n; const _M0FPC28internal7strconv6powtab = [1, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59]; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS967 = { _0: 0, _1: "" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS968 = { _0: 1, _1: "5" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS969 = { _0: 1, _1: "25" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS970 = { _0: 1, _1: "125" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS971 = { _0: 2, _1: "625" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS972 = { _0: 2, _1: "3125" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS973 = { _0: 2, _1: "15625" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS974 = { _0: 3, _1: "78125" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS975 = { _0: 3, _1: "390625" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS976 = { _0: 3, _1: "1953125" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS977 = { _0: 4, _1: "9765625" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS978 = { _0: 4, _1: "48828125" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS979 = { _0: 4, _1: "244140625" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS980 = { _0: 4, _1: "1220703125" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS981 = { _0: 5, _1: "6103515625" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS982 = { _0: 5, _1: "30517578125" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS983 = { _0: 5, _1: "152587890625" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS984 = { _0: 6, _1: "762939453125" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS985 = { _0: 6, _1: "3814697265625" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS986 = { _0: 6, _1: "19073486328125" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS987 = { _0: 7, _1: "95367431640625" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS988 = { _0: 7, _1: "476837158203125" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS989 = { _0: 7, _1: "2384185791015625" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS990 = { _0: 7, _1: "11920928955078125" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS991 = { _0: 8, _1: "59604644775390625" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS992 = { _0: 8, _1: "298023223876953125" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS993 = { _0: 8, _1: "1490116119384765625" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS994 = { _0: 9, _1: "7450580596923828125" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS995 = { _0: 9, _1: "37252902984619140625" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS996 = { _0: 9, _1: "186264514923095703125" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS997 = { _0: 10, _1: "931322574615478515625" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS998 = { _0: 10, _1: "4656612873077392578125" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS999 = { _0: 10, _1: "23283064365386962890625" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1000 = { _0: 10, _1: "116415321826934814453125" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1001 = { _0: 11, _1: "582076609134674072265625" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1002 = { _0: 11, _1: "2910383045673370361328125" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1003 = { _0: 11, _1: "14551915228366851806640625" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1004 = { _0: 12, _1: "72759576141834259033203125" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1005 = { _0: 12, _1: "363797880709171295166015625" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1006 = { _0: 12, _1: "1818989403545856475830078125" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1007 = { _0: 13, _1: "9094947017729282379150390625" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1008 = { _0: 13, _1: "45474735088646411895751953125" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1009 = { _0: 13, _1: "227373675443232059478759765625" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1010 = { _0: 13, _1: "1136868377216160297393798828125" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1011 = { _0: 14, _1: "5684341886080801486968994140625" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1012 = { _0: 14, _1: "28421709430404007434844970703125" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1013 = { _0: 14, _1: "142108547152020037174224853515625" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1014 = { _0: 15, _1: "710542735760100185871124267578125" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1015 = { _0: 15, _1: "3552713678800500929355621337890625" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1016 = { _0: 15, _1: "17763568394002504646778106689453125" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1017 = { _0: 16, _1: "88817841970012523233890533447265625" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1018 = { _0: 16, _1: "444089209850062616169452667236328125" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1019 = { _0: 16, _1: "2220446049250313080847263336181640625" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1020 = { _0: 16, _1: "11102230246251565404236316680908203125" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1021 = { _0: 17, _1: "55511151231257827021181583404541015625" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1022 = { _0: 17, _1: "277555756156289135105907917022705078125" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1023 = { _0: 17, _1: "1387778780781445675529539585113525390625" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1024 = { _0: 18, _1: "6938893903907228377647697925567626953125" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1025 = { _0: 18, _1: "34694469519536141888238489627838134765625" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1026 = { _0: 18, _1: "173472347597680709441192448139190673828125" }; const _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1027 = { _0: 19, _1: "867361737988403547205962240695953369140625" }; const _M0FPC28internal7strconv19left__shift__cheats = [_M0FPC28internal7strconv19left__shift__cheatsN5tupleS967, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS968, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS969, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS970, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS971, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS972, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS973, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS974, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS975, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS976, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS977, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS978, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS979, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS980, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS981, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS982, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS983, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS984, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS985, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS986, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS987, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS988, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS989, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS990, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS991, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS992, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS993, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS994, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS995, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS996, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS997, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS998, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS999, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1000, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1001, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1002, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1003, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1004, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1005, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1006, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1007, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1008, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1009, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1010, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1011, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1012, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1013, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1014, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1015, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1016, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1017, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1018, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1019, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1020, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1021, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1022, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1023, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1024, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1025, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1026, _M0FPC28internal7strconv19left__shift__cheatsN5tupleS1027]; const _M0FPC28internal7strconv10int__pow10 = [1n, 10n, 100n, 1000n, 10000n, 100000n, 1000000n, 10000000n, 100000000n, 1000000000n, 10000000000n, 100000000000n, 1000000000000n, 10000000000000n, 100000000000000n, 1000000000000000n]; const _M0FPC28internal7strconv5table = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000, 100000000000, 1e+12, 1e+13, 1e+14, 1e+15, 1e+16, 1e+17, 1e+18, 1e+19, 1e+20, 1e+21, 1e+22, 0, 0, 0, 0, 0, 0, 0, 0, 0]; const _M0FPC28internal7strconv12checked__mulN6constrS1108 = 0n; const _M0FPC14json17int__pow10__table = [1n, 10n, 100n, 1000n, 10000n, 100000n, 1000000n, 10000000n, 100000000n, 1000000000n, 10000000000n, 100000000000n, 1000000000000n, 10000000000000n, 100000000000000n, 1000000000000000n]; const _M0FPC14json12pow10__table = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000, 100000000000, 1e+12, 1e+13, 1e+14, 1e+15, 1e+16, 1e+17, 1e+18, 1e+19, 1e+20, 1e+21, 1e+22, 0, 0, 0, 0, 0, 0, 0, 0, 0]; const _M0FPC14json12checked__mulN6constrS1761 = 0n; const _M0FP27gmlewis6sha2563__K = [1116352408, 1899447441, -1245643825, -373957723, 961987163, 1508970993, -1841331548, -1424204075, -670586216, 310598401, 607225278, 1426881987, 1925078388, -2132889090, -1680079193, -1046744716, -459576895, -272742522, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, -1740746414, -1473132947, -1341970488, -1084653625, -958395405, -710438585, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, -2117940946, -1838011259, -1564481375, -1474664885, -1035236496, -949202525, -778901479, -694614492, -200395387, 275423344, 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, -2067236844, -1933114872, -1866530822, -1538233109, -1090935817, -965641998]; const _M0MP26zxch3n6expect8Formated10to__stringN7_2abindS179 = ";"; const _M0MP26zxch3n6expect8Formated3redN6constrS279 = 1; const _M0MP26zxch3n6expect8Formated6yellowN6constrS281 = 3; const _M0MP26zxch3n6expect8Formated4blueN6constrS285 = 4; const _M0MP36zxch3n5flock5flock11HlcWithPeer12from__stringN7_2abindS904 = ","; const _M0MP36zxch3n5flock5flock3Hlc4zeroN6recordS1853 = new _M0TP36zxch3n5flock5flock3Hlc(0, 0); (() => { _M0FP27Yoorkin4jmop9ffi__init(_M0FP27Yoorkin4jmop22convert__thrown__error); })(); const _M0FPB4seed = 42; const _M0FPB18brute__force__findN6constrS8937 = 0; const _M0FPB28boyer__moore__horspool__findN6constrS8936 = 0; const _M0MP27gmlewis6sha2566Digest3newN7_2abindS100 = [1779033703, -1150833019, 1013904242, -1521486534, 1359893119, -1694144372, 528734635, 1541459225]; const _M0MP36zxch3n5flock5flock5Flock20import__json_2einnerN6constrS1856 = new _M0DTP36zxch3n5flock5flock6Source6Import("import_json"); const _M0MP36zxch3n5flock5flock5Flock3newN7_2abindS1071 = new _M0TP36zxch3n5flock5flock3Hlc(0, 0); const _M0MP36zxch3n5flock5flock5Flock14delete_2einnerN6constrS1854 = true; function _M0FPC15abort5abortGRP36zxch3n5flock5types7Utf8StrE(msg) { return $panic(); } function _M0FPC15abort5abortGRP27Yoorkin4jmop3AnyE(msg) { return $panic(); } function _M0FPC15abort5abortGuE(msg) { $panic(); } function _M0FPC15abort5abortGyE(msg) { return $panic(); } function _M0FPC15abort5abortGkE(msg) { return $panic(); } function _M0FPC15abort5abortGiE(msg) { return $panic(); } function _M0FPC15abort5abortGOiE(msg) { return $panic(); } function _M0MPB6Logger13write__objectGsE(self, obj) { _M0IP016_24default__implPB4Show6outputGsE(obj, self); } function _M0MPB6Logger13write__objectGRPB4JsonE(self, obj) { _M0IPC14json4JsonPB4Show6output(obj, self); } function _M0FPB13consume4__acc(acc, input) { const _p = (acc >>> 0) + ((Math.imul(input, -1028477379) | 0) >>> 0) | 0; const _p$2 = 17; return Math.imul(_p << _p$2 | (_p >>> (32 - _p$2 | 0) | 0), 668265263) | 0; } function _M0MPC15array10FixedArray12unsafe__blitGyE(dst, dst_offset, src, src_offset, len) { if (dst === src && dst_offset < src_offset) { let _tmp = 0; while (true) { const i = _tmp; if (i < len) { const _tmp$2 = dst_offset + i | 0; const _tmp$3 = src_offset + i | 0; $bound_check(src, _tmp$3); $bound_check(dst, _tmp$2); dst[_tmp$2] = src[_tmp$3]; _tmp = i + 1 | 0; continue; } else { return; } } } else { let _tmp = len - 1 | 0; while (true) { const i = _tmp; if (i >= 0) { const _tmp$2 = dst_offset + i | 0; const _tmp$3 = src_offset + i | 0; $bound_check(src, _tmp$3); $bound_check(dst, _tmp$2); dst[_tmp$2] = src[_tmp$3]; _tmp = i - 1 | 0; continue; } else { return; } } } } function _M0MPB13StringBuilder13write__objectGRPB4JsonE(self, obj) { _M0IPC14json4JsonPB4Show6output(obj, { self: self, method_table: _M0FP092moonbitlang_2fcore_2fbuiltin_2fStringBuilder_24as_24_40moonbitlang_2fcore_2fbuiltin_2eLogger }); } function _M0MPB13StringBuilder13write__objectGdE(self, obj) { _M0IP016_24default__implPB4Show6outputGdE(obj, { self: self, method_table: _M0FP092moonbitlang_2fcore_2fbuiltin_2fStringBuilder_24as_24_40moonbitlang_2fcore_2fbuiltin_2eLogger }); } function _M0MPB13StringBuilder13write__objectGsE(self, obj) { _M0IP016_24default__implPB4Show6outputGsE(obj, { self: self, method_table: _M0FP092moonbitlang_2fcore_2fbuiltin_2fStringBuilder_24as_24_40moonbitlang_2fcore_2fbuiltin_2eLogger }); } function _M0MPB13StringBuilder13write__objectGRPC16string10StringViewE(self, obj) { const _p = { self: self, method_table: _M0FP092moonbitlang_2fcore_2fbuiltin_2fStringBuilder_24as_24_40moonbitlang_2fcore_2fbuiltin_2eLogger }; _p.method_table.method_2(_p.self, obj); } function _M0MPB13StringBuilder13write__objectGiE(self, obj) { _M0IP016_24default__implPB4Show6outputGiE(obj, { self: self, method_table: _M0FP092moonbitlang_2fcore_2fbuiltin_2fStringBuilder_24as_24_40moonbitlang_2fcore_2fbuiltin_2eLogger }); } function _M0MPB13StringBuilder21StringBuilder_2einner(size_hint) { return new _M0TPB13StringBuilder(""); } function _M0IPB13StringBuilderPB6Logger11write__char(self, ch) { self.val = `${self.val}${String.fromCodePoint(ch)}`; } function _M0MPC16uint166UInt1622is__leading__surrogate(self) { return _M0IP016_24default__implPB7Compare6op__geGkE(self, 55296) && _M0IP016_24default__implPB7Compare6op__leGkE(self, 56319); } function _M0MPC16uint166UInt1623is__trailing__surrogate(self) { return _M0IP016_24default__implPB7Compare6op__geGkE(self, 56320) && _M0IP016_24default__implPB7Compare6op__leGkE(self, 57343); } function _M0FPB32code__point__of__surrogate__pair(leading, trailing) { return (((Math.imul(leading - 55296 | 0, 1024) | 0) + trailing | 0) - 56320 | 0) + 65536 | 0; } function _M0MPC14byte4Byte7to__hexN14to__hex__digitS3588(i) { if (i < 10) { const _p = 48; const _p$2 = (i + _p | 0) & 255; return _p$2; } else { const _p = 97; const _p$2 = (i + _p | 0) & 255; const _p$3 = 10; const _p$4 = (_p$2 - _p$3 | 0) & 255; return _p$4; } } function _M0MPC14byte4Byte7to__hex(b) { const _self = _M0MPB13StringBuilder21StringBuilder_2einner(0); const _p = 16; _M0IPB13StringBuilderPB6Logger11write__char(_self, _M0MPC14byte4Byte7to__hexN14to__hex__digitS3588((b / _p | 0) & 255)); const _p$2 = 16; _M0IPB13StringBuilderPB6Logger11write__char(_self, _M0MPC14byte4Byte7to__hexN14to__hex__digitS3588((b % _p$2 | 0) & 255)); const _p$3 = _self; return _p$3.val; } function _M0MPC16string10StringView11sub_2einner(self, start, end) { const str_len = self.str.length; let abs_end; if (end === undefined) { abs_end = self.end; } else { const _Some = end; const _end = _Some; abs_end = _end < 0 ? self.end + _end | 0 : self.start + _end | 0; } const abs_start = start < 0 ? self.end + start | 0 : self.start + start | 0; if (abs_start >= self.start && (abs_start <= abs_end && abs_end <= self.end)) { if (abs_start < str_len) { if (!_M0MPC16uint166UInt1623is__trailing__surrogate(self.str.charCodeAt(abs_start))) { } else { $panic(); } } if (abs_end < str_len) { if (!_M0MPC16uint166UInt1623is__trailing__surrogate(self.str.charCodeAt(abs_end))) { } else { $panic(); } } return new _M0TPC16string10StringView(self.str, abs_start, abs_end); } else { return $panic(); } } function _M0IPB13StringBuilderPB6Logger13write__string(self, str) { self.val = `${self.val}${str}`; } function _M0IP016_24default__implPB2Eq10not__equalGRP36zxch3n5flock5types6NBytesE(x, y) { return !_M0IP36zxch3n5flock5types6NBytesPB2Eq5equal(x, y); } function _M0IP016_24default__implPB2Eq10not__equalGORPB4JsonE(x, y) { return !_M0IPC16option6OptionPB2Eq5equalGRPB4JsonE(x, y); } function _M0IP016_24default__implPB2Eq10not__equalGRPB4JsonE(x, y) { return !_M0IPC14json4JsonPB2Eq5equal(x, y); } function _M0IP016_24default__implPB2Eq10not__equalGORP36zxch3n5flock11sorted__map4NodeGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEEE(x, y) { return !_M0IPC16option6OptionPB2Eq5equalGRP36zxch3n5flock11sorted__map4NodeGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEEE(x, y); } function _M0IP016_24default__implPB2Eq10not__equalGORP36zxch3n5flock11sorted__map4NodeGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryEE(x, y) { return !_M0IPC16option6OptionPB2Eq5equalGRP36zxch3n5flock11sorted__map4NodeGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryEE(x, y); } function _M0IP016_24default__implPB7Compare6op__ltGRP36zxch3n5flock5flock3HlcE(x, y) { return (x.physical_time < y.physical_time ? -1 : x.physical_time > y.physical_time ? 1 : $compare_int(x.logical_counter, y.logical_counter)) < 0; } function _M0IP016_24default__implPB7Compare6op__ltGRP36zxch3n5flock5flock11HlcWithPeerE(x, y) { return _M0IP36zxch3n5flock5flock11HlcWithPeerPB7Compare7compare(x, y) < 0; } function _M0IP016_24default__implPB7Compare6op__ltGRP36zxch3n5flock5types7Utf8StrE(x, y) { return _M0IP36zxch3n5flock5types7Utf8StrPB7Compare7compare(x, y) < 0; } function _M0IP016_24default__implPB7Compare6op__ltGkE(x, y) { return $compare_int(x, y) < 0; } function _M0IP016_24default__implPB7Compare6op__ltGRP36zxch3n5flock5types6NBytesE(x, y) { return _M0IP36zxch3n5flock5types6NBytesPB7Compare7compare(x, y) < 0; } function _M0IP016_24default__implPB7Compare6op__gtGRP36zxch3n5flock5flock11HlcWithPeerE(x, y) { return _M0IP36zxch3n5flock5flock11HlcWithPeerPB7Compare7compare(x, y) > 0; } function _M0IP016_24default__implPB7Compare6op__gtGRPC16bigint6BigIntE(x, y) { return _M0IPC16bigint6BigIntPB7Compare7compare(x, y) > 0; } function _M0IP016_24default__implPB7Compare6op__gtGkE(x, y) { return $compare_int(x, y) > 0; } function _M0IP016_24default__implPB7Compare6op__leGkE(x, y) { return $compare_int(x, y) <= 0; } function _M0IP016_24default__implPB7Compare6op__geGRP36zxch3n5flock5flock3HlcE(x, y) { return (x.physical_time < y.physical_time ? -1 : x.physical_time > y.physical_time ? 1 : $compare_int(x.logical_counter, y.logical_counter)) >= 0; } function _M0IP016_24default__implPB7Compare6op__geGkE(x, y) { return $compare_int(x, y) >= 0; } function _M0FPB14avalanche__acc(acc) { let acc$2 = acc; acc$2 = acc$2 ^ (acc$2 >>> 15 | 0); acc$2 = Math.imul(acc$2, -2048144777) | 0; acc$2 = acc$2 ^ (acc$2 >>> 13 | 0); acc$2 = Math.imul(acc$2, -1028477379) | 0; acc$2 = acc$2 ^ (acc$2 >>> 16 | 0); return acc$2; } function _M0FPB13finalize__acc(acc) { return _M0FPB14avalanche__acc(acc); } function _M0IP016_24default__implPB6Logger28write__string__interpolationGRPB13StringBuilderE(self, show) { show.method_table.method_0(show.self, { self: self, method_table: _M0FP092moonbitlang_2fcore_2fbuiltin_2fStringBuilder_24as_24_40moonbitlang_2fcore_2fbuiltin_2eLogger }); } function _M0IP016_24default__implPB6Logger5writeGRPB13StringBuilderE(self, show) { show.method_table.method_0(show.self, { self: self, method_table: _M0FP092moonbitlang_2fcore_2fbuiltin_2fStringBuilder_24as_24_40moonbitlang_2fcore_2fbuiltin_2eLogger }); } function _M0MPC16string6String11sub_2einner(self, start, end) { const len = self.length; let end$2; if (end === undefined) { end$2 = len; } else { const _Some = end; const _end = _Some; end$2 = _end < 0 ? len + _end | 0 : _end; } const start$2 = start < 0 ? len + start | 0 : start; if (start$2 >= 0 && (start$2 <= end$2 && end$2 <= len)) { if (start$2 < len) { if (!_M0MPC16uint166UInt1623is__trailing__surrogate(self.charCodeAt(start$2))) { } else { $panic(); } } if (end$2 < len) { if (!_M0MPC16uint166UInt1623is__trailing__surrogate(self.charCodeAt(end$2))) { } else { $panic(); } } return new _M0TPC16string10StringView(self, start$2, end$2); } else { return $panic(); } } function _M0IP016_24default__implPB6Logger16write__substringGRPB13StringBuilderE(self, value, start, len) { _M0IPB13StringBuilderPB6Logger11write__view(self, _M0MPC16string6String11sub_2einner(value, start, start + len | 0)); } function _M0IP016_24default__implPB4Show6outputGdE(self, logger) { logger.method_table.method_0(logger.self, _M0IPC16double6DoublePB4Show10to__string(self)); } function _M0IP016_24default__implPB4Show6outputGsE(self, logger) { logger.method_table.method_0(logger.self, self); } function _M0IP016_24default__implPB4Show6outputGiE(self, logger) { logger.method_table.method_0(logger.self, _M0IPC13int3IntPB4Show10to__string(self)); } function _M0MPB4Iter4nextGURP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEEE(self) { const _func = self.f; const result = _func(); const _bind = self.size_hint; if (result === undefined) { self.size_hint = _M0MPB4Iter4nextN6constrS8927GURP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEEE; } else { if (_bind === undefined) { } else { const _Some = _bind; const _n = _Some; self.size_hint = _n > 0 ? _n - 1 | 0 : _M0MPB4Iter4nextN6constrS8926GURP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEEE; } } return result; } function _M0MPB4Iter4nextGyE(self) { const _func = self.f; const result = _func(); const _bind = self.size_hint; if (result === -1) { self.size_hint = _M0MPB4Iter4nextN6constrS8927GyE; } else { if (_bind === undefined) { } else { const _Some = _bind; const _n = _Some; self.size_hint = _n > 0 ? _n - 1 | 0 : _M0MPB4Iter4nextN6constrS8926GyE; } } return result; } function _M0MPB4Iter4nextGcE(self) { const _func = self.f; const result = _func(); const _bind = self.size_hint; if (result === -1) { self.size_hint = _M0MPB4Iter4nextN6constrS8927GcE; } else { if (_bind === undefined) { } else { const _Some = _bind; const _n = _Some; self.size_hint = _n > 0 ? _n - 1 | 0 : _M0MPB4Iter4nextN6constrS8926GcE; } } return result; } function _M0MPB4Iter4nextGRP26zxch3n6expect6FormatE(self) { const _func = self.f; const result = _func(); const _bind = self.size_hint; if (result === undefined) { self.size_hint = _M0MPB4Iter4nextN6constrS8927GRP26zxch3n6expect6FormatE; } else { if (_bind === undefined) { } else { const _Some = _bind; const _n = _Some; self.size_hint = _n > 0 ? _n - 1 | 0 : _M0MPB4Iter4nextN6constrS8926GRP26zxch3n6expect6FormatE; } } return result; } function _M0MPB6Logger19write__iter_2einnerGRPB4JsonE(self, iter, prefix, suffix, sep, trailing) { self.method_table.method_0(self.self, prefix); if (trailing) { while (true) { const _bind = _M0MPB4Iter4nextGURP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEEE(iter); if (_bind === undefined) { break; } else { const _Some = _bind; const _x = _Some; _M0MPB6Logger13write__objectGRPB4JsonE(self, _x); self.method_table.method_0(self.self, sep); continue; } } } else { const _bind = _M0MPB4Iter4nextGURP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEEE(iter); if (_bind === undefined) { } else { const _Some = _bind; const _x = _Some; _M0MPB6Logger13write__objectGRPB4JsonE(self, _x); while (true) { const _bind$2 = _M0MPB4Iter4nextGURP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEEE(iter); if (_bind$2 === undefined) { break; } else { const _Some$2 = _bind$2; const _x$2 = _Some$2; self.method_table.method_0(self.self, sep); _M0MPB6Logger13write__objectGRPB4JsonE(self, _x$2); continue; } } } } self.method_table.method_0(self.self, suffix); } function _M0MPC13int3Int18to__string_2einner(self, radix) { return _M0FPB19int__to__string__js(self, radix); } function _M0MPC16string10StringView2at(self, index) { return index >= 0 && index < (self.end - self.start | 0) ? self.str.charCodeAt(self.start + index | 0) : _M0FPC15abort5abortGkE("Index out of bounds"); } function _M0MPB4Iter3newGUsRPB4JsonEE(f, size_hint) { let size_hint$2; if (size_hint === undefined) { size_hint$2 = undefined; } else { const _Some = size_hint; const _n = _Some; size_hint$2 = _n > 0 ? _n : _M0MPB4Iter3newN6constrS8934GUsRPB4JsonEE; } return new _M0TPB4IterGUsRPB4JsonEE(f, size_hint$2); } function _M0MPB4Iter3newGyE(f, size_hint) { let size_hint$2; if (size_hint === undefined) { size_hint$2 = undefined; } else { const _Some = size_hint; const _n = _Some; size_hint$2 = _n > 0 ? _n : _M0MPB4Iter3newN6constrS8934GyE; } return new _M0TPB4IterGyE(f, size_hint$2); } function _M0MPB4Iter3newGcE(f, size_hint) { let size_hint$2; if (size_hint === undefined) { size_hint$2 = undefined; } else { const _Some = size_hint; const _n = _Some; size_hint$2 = _n > 0 ? _n : _M0MPB4Iter3newN6constrS8934GcE; } return new _M0TPB4IterGcE(f, size_hint$2); } function _M0MPB4Iter3newGRP26zxch3n6expect6FormatE(f, size_hint) { let size_hint$2; if (size_hint === undefined) { size_hint$2 = undefined; } else { const _Some = size_hint; const _n = _Some; size_hint$2 = _n > 0 ? _n : _M0MPB4Iter3newN6constrS8934GRP26zxch3n6expect6FormatE; } return new _M0TPB4IterGRP26zxch3n6expect6FormatE(f, size_hint$2); } function _M0MPC16string10StringView12view_2einner(self, start_offset, end_offset) { let end_offset$2; if (end_offset === undefined) { end_offset$2 = self.end - self.start | 0; } else { const _Some = end_offset; end_offset$2 = _Some; } return start_offset >= 0 && (start_offset <= end_offset$2 && end_offset$2 <= (self.end - self.start | 0)) ? new _M0TPC16string10StringView(self.str, self.start + start_offset | 0, self.start + end_offset$2 | 0) : _M0FPC15abort5abortGRP36zxch3n5flock5types7Utf8StrE("Invalid index for View"); } function _M0MPC16string10StringView11code__units(self) { const _p = self.end - self.start | 0; let _bind; if (_p <= 0) { _bind = []; } else { const _p$2 = new Array(_p); let _tmp = 0; while (true) { const _p$3 = _tmp; if (_p$3 < _p) { _p$2[_p$3] = self.str.charCodeAt(self.start + _p$3 | 0); _tmp = _p$3 + 1 | 0; continue; } else { break; } } _bind = _p$2; } return new _M0TPB9ArrayViewGkE(_bind, 0, _bind.length); } function _M0FPB19unsafe__sub__string(_tmp, _tmp$2, _tmp$3) { return $unsafe_bytes_sub_string(_tmp, _tmp$2, _tmp$3); } function _M0MPC15bytes5Bytes29to__unchecked__string_2einner(self, offset, length) { const len = self.length; let length$2; if (length === undefined) { length$2 = len - offset | 0; } else { const _Some = length; length$2 = _Some; } return offset >= 0 && (length$2 >= 0 && (offset + length$2 | 0) <= len) ? _M0FPB19unsafe__sub__string(self, offset, length$2) : $panic(); } function _M0MPC16string10StringView9to__owned(self) { return self.str.substring(self.start, self.end); } function _M0MPC16string10StringView4iter(self) { const start = self.start; const end = self.end; const index = new _M0TPB8MutLocalGiE(start); return _M0MPB4Iter3newGcE(() => { if (index.val < end) { const c1 = self.str.charCodeAt(index.val); if (_M0MPC16uint166UInt1622is__leading__surrogate(c1) && (index.val + 1 | 0) < self.end) { const c2 = self.str.charCodeAt(index.val + 1 | 0); if (_M0MPC16uint166UInt1623is__trailing__surrogate(c2)) { index.val = index.val + 2 | 0; return _M0FPB32code__point__of__surrogate__pair(c1, c2); } } index.val = index.val + 1 | 0; return c1; } else { return -1; } }, undefined); } function _M0MPB5Iter23newGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(f, size_hint) { let size_hint$2; if (size_hint === undefined) { size_hint$2 = undefined; } else { const _Some = size_hint; const _n = _Some; size_hint$2 = _n > 0 ? _n : _M0MPB5Iter23newN6constrS8935GRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE; } return new _M0TPB4IterGURP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEEE(f, size_hint$2); } function _M0MPB5Iter23newGRPB5ArrayGRPB4JsonERP36zxch3n5flock5flock5EntryE(f, size_hint) { let size_hint$2; if (size_hint === undefined) { size_hint$2 = undefined; } else { const _Some = size_hint; const _n = _Some; size_hint$2 = _n > 0 ? _n : _M0MPB5Iter23newN6constrS8935GRPB5ArrayGRPB4JsonERP36zxch3n5flock5flock5EntryE; } return new _M0TPB4IterGURPB5ArrayGRPB4JsonERP36zxch3n5flock5flock5EntryEE(f, size_hint$2); } function _M0MPB5Iter23newGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(f, size_hint) { let size_hint$2; if (size_hint === undefined) { size_hint$2 = undefined; } else { const _Some = size_hint; const _n = _Some; size_hint$2 = _n > 0 ? _n : _M0MPB5Iter23newN6constrS8935GRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE; } return new _M0TPB4IterGURP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryEE(f, size_hint$2); } function _M0MPC16string6String12view_2einner(self, start_offset, end_offset) { let end_offset$2; if (end_offset === undefined) { end_offset$2 = self.length; } else { const _Some = end_offset; end_offset$2 = _Some; } return start_offset >= 0 && (start_offset <= end_offset$2 && end_offset$2 <= self.length) ? new _M0TPC16string10StringView(self, start_offset, end_offset$2) : _M0FPC15abort5abortGRP36zxch3n5flock5types7Utf8StrE("Invalid index for View"); } function _M0MPC16string6String4view(self, start_offset$46$opt, end_offset) { let start_offset; if (start_offset$46$opt === undefined) { start_offset = 0; } else { const _Some = start_offset$46$opt; start_offset = _Some; } return _M0MPC16string6String12view_2einner(self, start_offset, end_offset); } function _M0MPC16string6String24char__length__ge_2einner(self, len, start_offset, end_offset) { let end_offset$2; if (end_offset === undefined) { end_offset$2 = self.length; } else { const _Some = end_offset; end_offset$2 = _Some; } let _tmp = start_offset; let _tmp$2 = 0; while (true) { const index = _tmp; const count = _tmp$2; if (index < end_offset$2 && count < len) { const c1 = self.charCodeAt(index); if (_M0MPC16uint166UInt1622is__leading__surrogate(c1) && (index + 1 | 0) < end_offset$2) { const c2 = self.charCodeAt(index + 1 | 0); if (_M0MPC16uint166UInt1623is__trailing__surrogate(c2)) { _tmp = index + 2 | 0; _tmp$2 = count + 1 | 0; continue; } else { _M0FPC15abort5abortGuE("invalid surrogate pair"); } } _tmp = index + 1 | 0; _tmp$2 = count + 1 | 0; continue; } else { return count >= len; } } } function _M0MPC16string6String31offset__of__nth__char__backward(self, n, start_offset, end_offset) { let _tmp = end_offset; let _tmp$2 = 0; while (true) { const utf16_offset = _tmp; const char_count = _tmp$2; if ((utf16_offset - 1 | 0) >= start_offset && char_count < n) { const c = self.charCodeAt(utf16_offset - 1 | 0); if (_M0MPC16uint166UInt1623is__trailing__surrogate(c)) { _tmp = utf16_offset - 2 | 0; _tmp$2 = char_count + 1 | 0; continue; } else { _tmp = utf16_offset - 1 | 0; _tmp$2 = char_count + 1 | 0; continue; } } else { return char_count < n || utf16_offset < start_offset ? undefined : utf16_offset; } } } function _M0MPC16string6String30offset__of__nth__char__forward(self, n, start_offset, end_offset) { if (start_offset >= 0 && start_offset <= end_offset) { let _tmp = start_offset; let _tmp$2 = 0; while (true) { const utf16_offset = _tmp; const char_count = _tmp$2; if (utf16_offset < end_offset && char_count < n) { const c = self.charCodeAt(utf16_offset); if (_M0MPC16uint166UInt1622is__leading__surrogate(c)) { _tmp = utf16_offset + 2 | 0; _tmp$2 = char_count + 1 | 0; continue; } else { _tmp = utf16_offset + 1 | 0; _tmp$2 = char_count + 1 | 0; continue; } } else { return char_count < n || utf16_offset >= end_offset ? undefined : utf16_offset; } } } else { return _M0FPC15abort5abortGOiE("Invalid start index"); } } function _M0MPC16string6String29offset__of__nth__char_2einner(self, i, start_offset, end_offset) { let end_offset$2; if (end_offset === undefined) { end_offset$2 = self.length; } else { const _Some = end_offset; end_offset$2 = _Some; } return i >= 0 ? _M0MPC16string6String30offset__of__nth__char__forward(self, i, start_offset, end_offset$2) : _M0MPC16string6String31offset__of__nth__char__backward(self, -i | 0, start_offset, end_offset$2); } function _M0IPB13StringBuilderPB6Logger11write__view(self, str) { self.val = `${self.val}${_M0MPC16string10StringView9to__owned(str)}`; } function _M0FPB28boyer__moore__horspool__find(haystack, needle) { const haystack_len = haystack.end - haystack.start | 0; const needle_len = needle.end - needle.start | 0; if (needle_len > 0) { if (haystack_len >= needle_len) { const skip_table = $make_array_len_and_init(256, needle_len); const _bind = needle_len - 1 | 0; let _tmp = 0; while (true) { const i = _tmp; if (i < _bind) { const _tmp$2 = needle.str.charCodeAt(needle.start + i | 0) & 255; $bound_check(skip_table, _tmp$2); skip_table[_tmp$2] = (needle_len - 1 | 0) - i | 0; _tmp = i + 1 | 0; continue; } else { break; } } let _tmp$2 = 0; while (true) { const i = _tmp$2; if (i <= (haystack_len - needle_len | 0)) { const _bind$2 = needle_len - 1 | 0; let _tmp$3 = 0; while (true) { const j = _tmp$3; if (j <= _bind$2) { const _p = i + j | 0; const _p$2 = haystack.str.charCodeAt(haystack.start + _p | 0); const _p$3 = needle.str.charCodeAt(needle.start + j | 0); if (_p$2 !== _p$3) { break; } _tmp$3 = j + 1 | 0; continue; } else { return i; } } const _p = (i + needle_len | 0) - 1 | 0; const _tmp$4 = haystack.str.charCodeAt(haystack.start + _p | 0) & 255; $bound_check(skip_table, _tmp$4); _tmp$2 = i + skip_table[_tmp$4] | 0; continue; } else { break; } } return undefined; } else { return undefined; } } else { return _M0FPB28boyer__moore__horspool__findN6constrS8936; } } function _M0FPB18brute__force__find(haystack, needle) { const haystack_len = haystack.end - haystack.start | 0; const needle_len = needle.end - needle.start | 0; if (needle_len > 0) { if (haystack_len >= needle_len) { const _p = 0; const needle_first = needle.str.charCodeAt(needle.start + _p | 0); const forward_len = haystack_len - needle_len | 0; let _tmp = 0; while (true) { const i = _tmp; if (i <= forward_len) { const _p$2 = haystack.str.charCodeAt(haystack.start + i | 0); if (_p$2 !== needle_first) { _tmp = i + 1 | 0; continue; } let _tmp$2 = 1; while (true) { const j = _tmp$2; if (j < needle_len) { const _p$3 = i + j | 0; const _p$4 = haystack.str.charCodeAt(haystack.start + _p$3 | 0); const _p$5 = needle.str.charCodeAt(needle.start + j | 0); if (_p$4 !== _p$5) { break; } _tmp$2 = j + 1 | 0; continue; } else { return i; } } _tmp = i + 1 | 0; continue; } else { break; } } return undefined; } else { return undefined; } } else { return _M0FPB18brute__force__findN6constrS8937; } } function _M0MPC16string10StringView4find(self, str) { return (str.end - str.start | 0) <= 4 ? _M0FPB18brute__force__find(self, str) : _M0FPB28boyer__moore__horspool__find(self, str); } function _M0MPC16string6String6repeat(self, n) { if (n < 0) { return _M0FPC15abort5abortGRP36zxch3n5flock5types7Utf8StrE("negative repeat count"); } else { if (n === 0) { return ""; } else { if (n === 1) { return self; } else { const len = self.length; const total = Math.imul(len, n) | 0; if (len === 0 || (total / n | 0) === len) { const buf = _M0MPB13StringBuilder21StringBuilder_2einner(total); const str = self; let _tmp = 0; while (true) { const _ = _tmp; if (_ < n) { _M0IPB13StringBuilderPB6Logger13write__string(buf, str); _tmp = _ + 1 | 0; continue; } else { break; } } return buf.val; } else { return _M0FPC15abort5abortGRP36zxch3n5flock5types7Utf8StrE("repeat result too large"); } } } } } function _M0MPC15array5Array11new_2einnerGRPB4JsonE(capacity) { return []; } function _M0MPC15array5Array11new_2einnerGyE(capacity) { return []; } function _M0MPC15array5Array4pushGRPB4JsonE(self, value) { _M0MPB7JSArray4push(self, value); } function _M0MPC15array5Array4pushGyE(self, value) { _M0MPB7JSArray4push(self, value); } function _M0MPC15array5Array4pushGRP26zxch3n6expect6FormatE(self, value) { _M0MPB7JSArray4push(self, value); } function _M0MPC16string10StringView9is__empty(self) { return (self.end - self.start | 0) === 0; } function _M0MPB4Iter3mapGcRPC16string10StringViewE(self, f) { return new _M0TPB4IterGRPC16string10StringViewE(() => { const _bind = _M0MPB4Iter4nextGcE(self); if (_bind === -1) { return undefined; } else { const _Some = _bind; const _x = _Some; return f(_x); } }, self.size_hint); } function _M0IPC14char4CharPB4Show10to__string(self) { return String.fromCodePoint(self); } function _M0MPC16string10StringView5split(self, sep) { const sep_len = sep.end - sep.start | 0; if (sep_len === 0) { return _M0MPB4Iter3mapGcRPC16string10StringViewE(_M0MPC16string10StringView4iter(self), (c) => _M0MPC16string6String12view_2einner(_M0IPC14char4CharPB4Show10to__string(c), 0, undefined)); } const remaining = new _M0TPB8MutLocalGORPC16string10StringViewE(self); return _M0MPB4Iter3newGUsRPB4JsonEE(() => { const _bind = remaining.val; if (_bind === undefined) { return undefined; } else { const _Some = _bind; const _view = _Some; const _bind$2 = _M0MPC16string10StringView4find(_view, sep); if (_bind$2 === undefined) { remaining.val = undefined; return _view; } else { const _Some$2 = _bind$2; const _end = _Some$2; remaining.val = _M0MPC16string10StringView12view_2einner(_view, _end + sep_len | 0, undefined); return _M0MPC16string10StringView12view_2einner(_view, 0, _end); } } }, undefined); } function _M0MPB4Iter9to__arrayGRPC16string10StringViewE(self) { const _bind = self.size_hint; let result; if (_bind === undefined) { result = []; } else { const _Some = _bind; const _n = _Some; result = _M0MPC15array5Array11new_2einnerGRPB4JsonE(_n); } while (true) { const _bind$2 = _M0MPB4Iter4nextGURP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEEE(self); if (_bind$2 === undefined) { break; } else { const _Some = _bind$2; const _x = _Some; _M0MPC15array5Array4pushGRPB4JsonE(result, _x); continue; } } return result; } function _M0MPB4Iter9to__arrayGyE(self) { const _bind = self.size_hint; let result; if (_bind === undefined) { result = []; } else { const _Some = _bind; const _n = _Some; result = _M0MPC15array5Array11new_2einnerGyE(_n); } while (true) { const _bind$2 = _M0MPB4Iter4nextGyE(self); if (_bind$2 === -1) { break; } else { const _Some = _bind$2; const _x = _Some; _M0MPC15array5Array4pushGyE(result, _x); continue; } } return result; } function _M0MPC16string10StringView9get__char(self, idx) { if (idx >= 0 && idx < (self.end - self.start | 0)) { const c = self.str.charCodeAt(self.start + idx | 0); if (_M0MPC16uint166UInt1622is__leading__surrogate(c)) { if ((idx + 1 | 0) < (self.end - self.start | 0)) { const _p = idx + 1 | 0; const next = self.str.charCodeAt(self.start + _p | 0); return _M0MPC16uint166UInt1623is__trailing__surrogate(next) ? _M0FPB32code__point__of__surrogate__pair(c, next) : -1; } else { return -1; } } else { return _M0MPC16uint166UInt1623is__trailing__surrogate(c) ? -1 : c; } } else { return -1; } } function _M0IPC16string6StringPB12ToStringView16to__string__view(self) { return new _M0TPC16string10StringView(self, 0, self.length); } function _M0MPC16string6String11code__units(self) { const _p = self.length; let _bind; if (_p <= 0) { _bind = []; } else { const _p$2 = new Array(_p); let _tmp = 0; while (true) { const _p$3 = _tmp; if (_p$3 < _p) { _p$2[_p$3] = self.charCodeAt(_p$3); _tmp = _p$3 + 1 | 0; continue; } else { break; } } _bind = _p$2; } return new _M0TPB9ArrayViewGkE(_bind, 0, _bind.length); } function _M0IPC13int3IntPB4Show10to__string(self) { return _M0MPC13int3Int18to__string_2einner(self, 10); } function _M0MPC15array9ArrayView4iterGyE(self) { const i = new _M0TPB8MutLocalGiE(0); const len = self.end - self.start | 0; return _M0MPB4Iter3newGyE(() => { if (i.val < len) { const elem = self.buf[self.start + i.val | 0]; i.val = i.val + 1 | 0; return elem; } else { return -1; } }, len); } function _M0MPC15array9ArrayView4iterGRPB4JsonE(self) { const i = new _M0TPB8MutLocalGiE(0); const len = self.end - self.start | 0; return _M0MPB4Iter3newGUsRPB4JsonEE(() => { if (i.val < len) { const elem = self.buf[self.start + i.val | 0]; i.val = i.val + 1 | 0; return elem; } else { return undefined; } }, len); } function _M0MPC15array9ArrayView4iterGRP26zxch3n6expect6FormatE(self) { const i = new _M0TPB8MutLocalGiE(0); const len = self.end - self.start | 0; return _M0MPB4Iter3newGRP26zxch3n6expect6FormatE(() => { if (i.val < len) { const elem = self.buf[self.start + i.val | 0]; i.val = i.val + 1 | 0; return elem; } else { return undefined; } }, len); } function _M0MPC15array10FixedArray4iterGyE(self) { return _M0MPC15array9ArrayView4iterGyE(new _M0TPB9ArrayViewGyE(self, 0, self.length)); } function _M0MPC15array5Array4iterGRPB4JsonE(self) { return _M0MPC15array9ArrayView4iterGRPB4JsonE(new _M0TPB9ArrayViewGRPB4JsonE(self, 0, self.length)); } function _M0MPC15array5Array4iterGRP26zxch3n6expect6FormatE(self) { return _M0MPC15array9ArrayView4iterGRP26zxch3n6expect6FormatE(new _M0TPB9ArrayViewGRP26zxch3n6expect6FormatE(self, 0, self.length)); } function _M0IPC15array5ArrayPB4Show6outputGRPB4JsonE(self, logger) { _M0MPB6Logger19write__iter_2einnerGRPB4JsonE(logger, _M0MPC15array5Array4iterGRPB4JsonE(self), "[", "]", ", ", false); } function _M0MPC15array10FixedArray11from__arrayGjE(array) { const _p = array.end - array.start | 0; if (_p <= 0) { return []; } else { const _p$2 = 0; const _p$3 = $make_array_len_and_init(_p, array.buf[array.start + _p$2 | 0]); let _tmp = 1; while (true) { const _p$4 = _tmp; if (_p$4 < _p) { $bound_check(_p$3, _p$4); _p$3[_p$4] = array.buf[array.start + _p$4 | 0]; _tmp = _p$4 + 1 | 0; continue; } else { break; } } return _p$3; } } function _M0MPC15array9ArrayView2atGyE(self, index) { if (index >= 0 && index < (self.end - self.start | 0)) { const _tmp = self.buf; const _tmp$2 = self.start + index | 0; $bound_check(_tmp, _tmp$2); return _tmp[_tmp$2]; } else { const _string_builder = _M0MPB13StringBuilder21StringBuilder_2einner(60); _M0IPB13StringBuilderPB6Logger13write__string(_string_builder, "index out of bounds: the len is from 0 to "); _M0MPB13StringBuilder13write__objectGiE(_string_builder, self.end - self.start | 0); _M0IPB13StringBuilderPB6Logger13write__string(_string_builder, " but the index is "); _M0MPB13StringBuilder13write__objectGiE(_string_builder, index); return _M0FPC15abort5abortGyE(_string_builder.val); } } function _M0MPC15array9ArrayView12view_2einnerGkE(self, start, end) { const len = self.end - self.start | 0; let end$2; if (end === undefined) { end$2 = len; } else { const _Some = end; const _end = _Some; end$2 = _end < 0 ? len + _end | 0 : _end; } const start$2 = start < 0 ? len + start | 0 : start; if (start$2 >= 0 && (start$2 <= end$2 && end$2 <= len)) { const _bind = self.buf; const _bind$2 = self.start + start$2 | 0; const _bind$3 = end$2 - start$2 | 0; return new _M0TPB9ArrayViewGkE(_bind, _bind$2, _bind$2 + _bind$3 | 0); } else { return _M0FPC15abort5abortGRP36zxch3n5flock5types7Utf8StrE("View index out of bounds"); } } function _M0MPC15array10FixedArray12view_2einnerGyE(self, start, end) { const len = self.length; let end$2; if (end === undefined) { end$2 = len; } else { const _Some = end; const _end = _Some; end$2 = _end < 0 ? len + _end | 0 : _end; } const start$2 = start < 0 ? len + start | 0 : start; if (start$2 >= 0 && (start$2 <= end$2 && end$2 <= len)) { const _bind = self; const _bind$2 = end$2 - start$2 | 0; return new _M0TPB9ArrayViewGyE(_bind, start$2, start$2 + _bind$2 | 0); } else { return _M0FPC15abort5abortGRP36zxch3n5flock5types7Utf8StrE("View index out of bounds"); } } function _M0MPC15array9ArrayView4joinGsE(self, separator) { if ((self.end - self.start | 0) === 0) { return ""; } else { const _hd = self.buf[self.start]; const _x_buf = self.buf; const _x_start = 1 + self.start | 0; const _x_end = self.end; const hd = _M0IPC16string6StringPB12ToStringView16to__string__view(_hd); const _bind = _x_end - _x_start | 0; let size_hint; let _tmp = 0; let _tmp$2 = hd.end - hd.start | 0; while (true) { const _ = _tmp; const size_hint$2 = _tmp$2; if (_ < _bind) { const s = _x_buf[_x_start + _ | 0]; _tmp = _ + 1 | 0; const _p = _M0IPC16string6StringPB12ToStringView16to__string__view(s); _tmp$2 = (size_hint$2 + (_p.end - _p.start | 0) | 0) + (separator.end - separator.start | 0) | 0; continue; } else { size_hint = size_hint$2; break; } } const size_hint$2 = size_hint << 1; const buf = _M0MPB13StringBuilder21StringBuilder_2einner(size_hint$2); _M0IPB13StringBuilderPB6Logger11write__view(buf, hd); if ((separator.end - separator.start | 0) === 0) { const _bind$2 = _x_end - _x_start | 0; let _tmp$3 = 0; while (true) { const _ = _tmp$3; if (_ < _bind$2) { const s = _x_buf[_x_start + _ | 0]; const s$2 = _M0IPC16string6StringPB12ToStringView16to__string__view(s); _M0IPB13StringBuilderPB6Logger11write__view(buf, s$2); _tmp$3 = _ + 1 | 0; continue; } else { break; } } } else { const _bind$2 = _x_end - _x_start | 0; let _tmp$3 = 0; while (true) { const _ = _tmp$3; if (_ < _bind$2) { const s = _x_buf[_x_start + _ | 0]; const s$2 = _M0IPC16string6StringPB12ToStringView16to__string__view(s); _M0IPB13StringBuilderPB6Logger11write__view(buf, separator); _M0IPB13StringBuilderPB6Logger11write__view(buf, s$2); _tmp$3 = _ + 1 | 0; continue; } else { break; } } } return buf.val; } } function _M0IPC16option6OptionPB2Eq5equalGRPB4JsonE(self, other) { if (self === undefined) { return other === undefined; } else { const _Some = self; const _x = _Some; if (other === undefined) { return false; } else { const _Some$2 = other; const _y = _Some$2; return _M0IPC14json4JsonPB2Eq5equal(_x, _y); } } } function _M0IPC16option6OptionPB2Eq5equalGRPB3MapGsRPB4JsonEE(self, other) { if (self === undefined) { return other === undefined; } else { const _Some = self; const _x = _Some; if (other === undefined) { return false; } else { const _Some$2 = other; const _y = _Some$2; return _M0IPB3MapPB2Eq5equalGsRPB4JsonE(_x, _y); } } } function _M0IPC16option6OptionPB2Eq5equalGRP36zxch3n5flock11sorted__map4NodeGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEEE(self, other) { if (self === undefined) { return other === undefined; } else { const _Some = self; const _x = _Some; if (other === undefined) { return false; } else { const _Some$2 = other; const _y = _Some$2; return _M0IP36zxch3n5flock11sorted__map4NodePB2Eq5equalGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(_x, _y); } } } function _M0IPC16option6OptionPB2Eq5equalGRP36zxch3n5flock11sorted__map4NodeGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryEE(self, other) { if (self === undefined) { return other === undefined; } else { const _Some = self; const _x = _Some; if (other === undefined) { return false; } else { const _Some$2 = other; const _y = _Some$2; return _M0IP36zxch3n5flock11sorted__map4NodePB2Eq5equalGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(_x, _y); } } } function _M0MPC16option6Option6unwrapGdE(self) { if (self.$tag === 0) { return $panic(); } else { const _Some = self; return _Some._0; } } function _M0MPC16option6Option16unwrap__or__elseGdE(self, default_) { if (self.$tag === 0) { return default_(); } else { const _Some = self; const _t = _Some._0; return _t; } } function _M0MPC16option6Option3mapGRP36zxch3n5flock5flock5EntryRP36zxch3n5flock5flock9EntryInfoE(self, f) { if (self === undefined) { return undefined; } else { const _Some = self; const _t = _Some; return f(_t); } } function _M0MPC16option6Option3mapGRPB4JsonRP36zxch3n5flock5flock11FlockDigestE(self, f) { if (self === undefined) { return undefined; } else { const _Some = self; const _t = _Some; return f(_t); } } function _M0MPC16option6Option3mapGRPC16string10StringViewsE(self, f) { if (self === undefined) { return undefined; } else { const _Some = self; const _t = _Some; return f(_t); } } function _M0MPC16option6Option4bindGRP36zxch3n5flock5flock5EntryRPB4JsonE(self, f) { if (self === undefined) { return undefined; } else { const _Some = self; const _t = _Some; return f(_t); } } function _M0MPC13int3Int20next__power__of__two(self) { if (self >= 0) { if (self <= 1) { return 1; } if (self > 1073741824) { return 1073741824; } return (2147483647 >> (Math.clz32(self - 1 | 0) - 1 | 0)) + 1 | 0; } else { return $panic(); } } function _M0FPB8new__mapGsRP36zxch3n5flock5flock3HlcE(capacity) { const capacity$2 = _M0MPC13int3Int20next__power__of__two(capacity); const _bind = capacity$2 - 1 | 0; const _bind$2 = (Math.imul(capacity$2, 13) | 0) / 16 | 0; const _bind$3 = $make_array_len_and_init(capacity$2, undefined); const _bind$4 = undefined; return new _M0TPB3MapGsRP36zxch3n5flock5flock3HlcE(_bind$3, 0, capacity$2, _bind, _bind$2, _bind$4, -1); } function _M0FPB8new__mapGiWRP36zxch3n5flock5flock10EventBatchEuE(capacity) { const capacity$2 = _M0MPC13int3Int20next__power__of__two(capacity); const _bind = capacity$2 - 1 | 0; const _bind$2 = (Math.imul(capacity$2, 13) | 0) / 16 | 0; const _bind$3 = $make_array_len_and_init(capacity$2, undefined); const _bind$4 = undefined; return new _M0TPB3MapGiWRP36zxch3n5flock5flock10EventBatchEuE(_bind$3, 0, capacity$2, _bind, _bind$2, _bind$4, -1); } function _M0FPB21capacity__for__length(length) { let capacity = _M0MPC13int3Int20next__power__of__two(length); const _p = capacity; if (length > ((Math.imul(_p, 13) | 0) / 16 | 0)) { capacity = Math.imul(capacity, 2) | 0; } return capacity; } function _M0MPB3Map20add__entry__to__tailGsRP36zxch3n5flock5flock3HlcE(self, idx, entry) { const _bind = self.tail; if (_bind === -1) { self.head = entry; } else { const _tmp = self.entries; $bound_check(_tmp, _bind); const _p = _tmp[_bind]; let _tmp$2; if (_p === undefined) { _tmp$2 = $panic(); } else { const _p$2 = _p; _tmp$2 = _p$2; } _tmp$2.next = entry; } self.tail = idx; const _tmp = self.entries; $bound_check(_tmp, idx); _tmp[idx] = entry; self.size = self.size + 1 | 0; } function _M0MPB3Map20add__entry__to__tailGiWRP36zxch3n5flock5flock10EventBatchEuE(self, idx, entry) { const _bind = self.tail; if (_bind === -1) { self.head = entry; } else { const _tmp = self.entries; $bound_check(_tmp, _bind); const _p = _tmp[_bind]; let _tmp$2; if (_p === undefined) { _tmp$2 = $panic(); } else { const _p$2 = _p; _tmp$2 = _p$2; } _tmp$2.next = entry; } self.tail = idx; const _tmp = self.entries; $bound_check(_tmp, idx); _tmp[idx] = entry; self.size = self.size + 1 | 0; } function _M0MPB3Map10set__entryGsRP36zxch3n5flock5flock3HlcE(self, entry, new_idx) { const _tmp = self.entries; $bound_check(_tmp, new_idx); _tmp[new_idx] = entry; const _bind = entry.next; if (_bind === undefined) { self.tail = new_idx; return; } else { const _Some = _bind; const _next = _Some; _next.prev = new_idx; return; } } function _M0MPB3Map10set__entryGiWRP36zxch3n5flock5flock10EventBatchEuE(self, entry, new_idx) { const _tmp = self.entries; $bound_check(_tmp, new_idx); _tmp[new_idx] = entry; const _bind = entry.next; if (_bind === undefined) { self.tail = new_idx; return; } else { const _Some = _bind; const _next = _Some; _next.prev = new_idx; return; } } function _M0MPB3Map10push__awayGsRP36zxch3n5flock5flock3HlcE(self, idx, entry) { let _tmp = entry.psl + 1 | 0; let _tmp$2 = idx + 1 & self.capacity_mask; let _tmp$3 = entry; while (true) { const psl = _tmp; const idx$2 = _tmp$2; const entry$2 = _tmp$3; const _tmp$4 = self.entries; $bound_check(_tmp$4, idx$2); const _bind = _tmp$4[idx$2]; if (_bind === undefined) { entry$2.psl = psl; _M0MPB3Map10set__entryGsRP36zxch3n5flock5flock3HlcE(self, entry$2, idx$2); return; } else { const _Some = _bind; const _curr_entry = _Some; if (psl > _curr_entry.psl) { entry$2.psl = psl; _M0MPB3Map10set__entryGsRP36zxch3n5flock5flock3HlcE(self, entry$2, idx$2); _tmp = _curr_entry.psl + 1 | 0; _tmp$2 = idx$2 + 1 & self.capacity_mask; _tmp$3 = _curr_entry; continue; } else { _tmp = psl + 1 | 0; _tmp$2 = idx$2 + 1 & self.capacity_mask; continue; } } } } function _M0MPB3Map10push__awayGiWRP36zxch3n5flock5flock10EventBatchEuE(self, idx, entry) { let _tmp = entry.psl + 1 | 0; let _tmp$2 = idx + 1 & self.capacity_mask; let _tmp$3 = entry; while (true) { const psl = _tmp; const idx$2 = _tmp$2; const entry$2 = _tmp$3; const _tmp$4 = self.entries; $bound_check(_tmp$4, idx$2); const _bind = _tmp$4[idx$2]; if (_bind === undefined) { entry$2.psl = psl; _M0MPB3Map10set__entryGiWRP36zxch3n5flock5flock10EventBatchEuE(self, entry$2, idx$2); return; } else { const _Some = _bind; const _curr_entry = _Some; if (psl > _curr_entry.psl) { entry$2.psl = psl; _M0MPB3Map10set__entryGiWRP36zxch3n5flock5flock10EventBatchEuE(self, entry$2, idx$2); _tmp = _curr_entry.psl + 1 | 0; _tmp$2 = idx$2 + 1 & self.capacity_mask; _tmp$3 = _curr_entry; continue; } else { _tmp = psl + 1 | 0; _tmp$2 = idx$2 + 1 & self.capacity_mask; continue; } } } } function _M0MPB3Map20rehash__place__entryGsRP36zxch3n5flock5flock3HlcE(self, outer) { const hash = outer.hash; let _tmp = 0; let _tmp$2 = hash & self.capacity_mask; while (true) { const psl = _tmp; const idx = _tmp$2; const _tmp$3 = self.entries; $bound_check(_tmp$3, idx); const _bind = _tmp$3[idx]; if (_bind === undefined) { outer.psl = psl; outer.prev = self.tail; _M0MPB3Map20add__entry__to__tailGsRP36zxch3n5flock5flock3HlcE(self, idx, outer); return undefined; } else { const _Some = _bind; const _curr = _Some; if (psl > _curr.psl) { _M0MPB3Map10push__awayGsRP36zxch3n5flock5flock3HlcE(self, idx, _curr); outer.psl = psl; outer.prev = self.tail; _M0MPB3Map20add__entry__to__tailGsRP36zxch3n5flock5flock3HlcE(self, idx, outer); return undefined; } else { _tmp = psl + 1 | 0; _tmp$2 = idx + 1 & self.capacity_mask; continue; } } } } function _M0MPB3Map20rehash__place__entryGiWRP36zxch3n5flock5flock10EventBatchEuE(self, outer) { const hash = outer.hash; let _tmp = 0; let _tmp$2 = hash & self.capacity_mask; while (true) { const psl = _tmp; const idx = _tmp$2; const _tmp$3 = self.entries; $bound_check(_tmp$3, idx); const _bind = _tmp$3[idx]; if (_bind === undefined) { outer.psl = psl; outer.prev = self.tail; _M0MPB3Map20add__entry__to__tailGiWRP36zxch3n5flock5flock10EventBatchEuE(self, idx, outer); return undefined; } else { const _Some = _bind; const _curr = _Some; if (psl > _curr.psl) { _M0MPB3Map10push__awayGiWRP36zxch3n5flock5flock10EventBatchEuE(self, idx, _curr); outer.psl = psl; outer.prev = self.tail; _M0MPB3Map20add__entry__to__tailGiWRP36zxch3n5flock5flock10EventBatchEuE(self, idx, outer); return undefined; } else { _tmp = psl + 1 | 0; _tmp$2 = idx + 1 & self.capacity_mask; continue; } } } } function _M0MPB3Map4growGsRP36zxch3n5flock5flock3HlcE(self) { const old_head = self.head; const new_capacity = self.capacity << 1; self.entries = $make_array_len_and_init(new_capacity, undefined); self.capacity = new_capacity; self.capacity_mask = new_capacity - 1 | 0; const _p = self.capacity; self.grow_at = (Math.imul(_p, 13) | 0) / 16 | 0; self.size = 0; self.head = undefined; self.tail = -1; let _tmp = old_head; while (true) { const x = _tmp; if (x === undefined) { return; } else { const _Some = x; const _e = _Some; const next_in_chain = _e.next; _e.next = undefined; _M0MPB3Map20rehash__place__entryGsRP36zxch3n5flock5flock3HlcE(self, _e); _tmp = next_in_chain; continue; } } } function _M0MPB3Map4growGiWRP36zxch3n5flock5flock10EventBatchEuE(self) { const old_head = self.head; const new_capacity = self.capacity << 1; self.entries = $make_array_len_and_init(new_capacity, undefined); self.capacity = new_capacity; self.capacity_mask = new_capacity - 1 | 0; const _p = self.capacity; self.grow_at = (Math.imul(_p, 13) | 0) / 16 | 0; self.size = 0; self.head = undefined; self.tail = -1; let _tmp = old_head; while (true) { const x = _tmp; if (x === undefined) { return; } else { const _Some = x; const _e = _Some; const next_in_chain = _e.next; _e.next = undefined; _M0MPB3Map20rehash__place__entryGiWRP36zxch3n5flock5flock10EventBatchEuE(self, _e); _tmp = next_in_chain; continue; } } } function _M0MPB3Map15set__with__hashGsRP36zxch3n5flock5flock3HlcE(self, key, value, hash) { let _tmp = 0; let _tmp$2 = hash & self.capacity_mask; while (true) { const psl = _tmp; const idx = _tmp$2; const _tmp$3 = self.entries; $bound_check(_tmp$3, idx); const _bind = _tmp$3[idx]; if (_bind === undefined) { if (self.size >= self.grow_at) { _M0MPB3Map4growGsRP36zxch3n5flock5flock3HlcE(self); _tmp = 0; _tmp$2 = hash & self.capacity_mask; continue; } const _bind$2 = self.tail; const _bind$3 = undefined; const entry = new _M0TPB5EntryGsRP36zxch3n5flock5flock3HlcE(_bind$2, _bind$3, psl, hash, key, value); _M0MPB3Map20add__entry__to__tailGsRP36zxch3n5flock5flock3HlcE(self, idx, entry); return undefined; } else { const _Some = _bind; const _curr_entry = _Some; if (_curr_entry.hash === hash && _curr_entry.key === key) { _curr_entry.value = value; return undefined; } if (psl > _curr_entry.psl) { if (self.size >= self.grow_at) { _M0MPB3Map4growGsRP36zxch3n5flock5flock3HlcE(self); _tmp = 0; _tmp$2 = hash & self.capacity_mask; continue; } _M0MPB3Map10push__awayGsRP36zxch3n5flock5flock3HlcE(self, idx, _curr_entry); const _bind$2 = self.tail; const _bind$3 = undefined; const entry = new _M0TPB5EntryGsRP36zxch3n5flock5flock3HlcE(_bind$2, _bind$3, psl, hash, key, value); _M0MPB3Map20add__entry__to__tailGsRP36zxch3n5flock5flock3HlcE(self, idx, entry); return undefined; } _tmp = psl + 1 | 0; _tmp$2 = idx + 1 & self.capacity_mask; continue; } } } function _M0MPB3Map15set__with__hashGsRPB4JsonE(self, key, value, hash) { let _tmp = 0; let _tmp$2 = hash & self.capacity_mask; while (true) { const psl = _tmp; const idx = _tmp$2; const _tmp$3 = self.entries; $bound_check(_tmp$3, idx); const _bind = _tmp$3[idx]; if (_bind === undefined) { if (self.size >= self.grow_at) { _M0MPB3Map4growGsRP36zxch3n5flock5flock3HlcE(self); _tmp = 0; _tmp$2 = hash & self.capacity_mask; continue; } const _bind$2 = self.tail; const _bind$3 = undefined; const entry = new _M0TPB5EntryGsRPB4JsonE(_bind$2, _bind$3, psl, hash, key, value); _M0MPB3Map20add__entry__to__tailGsRP36zxch3n5flock5flock3HlcE(self, idx, entry); return undefined; } else { const _Some = _bind; const _curr_entry = _Some; if (_curr_entry.hash === hash && _curr_entry.key === key) { _curr_entry.value = value; return undefined; } if (psl > _curr_entry.psl) { if (self.size >= self.grow_at) { _M0MPB3Map4growGsRP36zxch3n5flock5flock3HlcE(self); _tmp = 0; _tmp$2 = hash & self.capacity_mask; continue; } _M0MPB3Map10push__awayGsRP36zxch3n5flock5flock3HlcE(self, idx, _curr_entry); const _bind$2 = self.tail; const _bind$3 = undefined; const entry = new _M0TPB5EntryGsRPB4JsonE(_bind$2, _bind$3, psl, hash, key, value); _M0MPB3Map20add__entry__to__tailGsRP36zxch3n5flock5flock3HlcE(self, idx, entry); return undefined; } _tmp = psl + 1 | 0; _tmp$2 = idx + 1 & self.capacity_mask; continue; } } } function _M0MPB3Map15set__with__hashGiWRP36zxch3n5flock5flock10EventBatchEuE(self, key, value, hash) { let _tmp = 0; let _tmp$2 = hash & self.capacity_mask; while (true) { const psl = _tmp; const idx = _tmp$2; const _tmp$3 = self.entries; $bound_check(_tmp$3, idx); const _bind = _tmp$3[idx]; if (_bind === undefined) { if (self.size >= self.grow_at) { _M0MPB3Map4growGiWRP36zxch3n5flock5flock10EventBatchEuE(self); _tmp = 0; _tmp$2 = hash & self.capacity_mask; continue; } const _bind$2 = self.tail; const _bind$3 = undefined; const entry = new _M0TPB5EntryGiWRP36zxch3n5flock5flock10EventBatchEuE(_bind$2, _bind$3, psl, hash, key, value); _M0MPB3Map20add__entry__to__tailGiWRP36zxch3n5flock5flock10EventBatchEuE(self, idx, entry); return undefined; } else { const _Some = _bind; const _curr_entry = _Some; if (_curr_entry.hash === hash && _curr_entry.key === key) { _curr_entry.value = value; return undefined; } if (psl > _curr_entry.psl) { if (self.size >= self.grow_at) { _M0MPB3Map4growGiWRP36zxch3n5flock5flock10EventBatchEuE(self); _tmp = 0; _tmp$2 = hash & self.capacity_mask; continue; } _M0MPB3Map10push__awayGiWRP36zxch3n5flock5flock10EventBatchEuE(self, idx, _curr_entry); const _bind$2 = self.tail; const _bind$3 = undefined; const entry = new _M0TPB5EntryGiWRP36zxch3n5flock5flock10EventBatchEuE(_bind$2, _bind$3, psl, hash, key, value); _M0MPB3Map20add__entry__to__tailGiWRP36zxch3n5flock5flock10EventBatchEuE(self, idx, entry); return undefined; } _tmp = psl + 1 | 0; _tmp$2 = idx + 1 & self.capacity_mask; continue; } } } function _M0MPB3Map3setGsRP36zxch3n5flock5flock3HlcE(self, key, value) { _M0MPB3Map15set__with__hashGsRP36zxch3n5flock5flock3HlcE(self, key, value, _M0IPC16string6StringPB4Hash4hash(key)); } function _M0MPB3Map3setGsRPB4JsonE(self, key, value) { _M0MPB3Map15set__with__hashGsRPB4JsonE(self, key, value, _M0IPC16string6StringPB4Hash4hash(key)); } function _M0MPB3Map3setGiWRP36zxch3n5flock5flock10EventBatchEuE(self, key, value) { _M0MPB3Map15set__with__hashGiWRP36zxch3n5flock5flock10EventBatchEuE(self, key, value, _M0IPC13int3IntPB4Hash4hash(key)); } function _M0MPB3Map3MapGsRPB4JsonE(arr, capacity) { const length = arr.end - arr.start | 0; let capacity$2; if (capacity === undefined) { capacity$2 = length === 0 ? 8 : _M0FPB21capacity__for__length(length); } else { const _Some = capacity; const _capacity = _Some; const _p = _M0FPB21capacity__for__length(length); capacity$2 = _capacity > _p ? _capacity : _p; } const m = _M0FPB8new__mapGsRP36zxch3n5flock5flock3HlcE(capacity$2); const _bind = arr.end - arr.start | 0; let _tmp = 0; while (true) { const _ = _tmp; if (_ < _bind) { const e = arr.buf[arr.start + _ | 0]; _M0MPB3Map3setGsRPB4JsonE(m, e._0, e._1); _tmp = _ + 1 | 0; continue; } else { break; } } return m; } function _M0MPB3Map3getGsRP36zxch3n5flock5flock3HlcE(self, key) { const hash = _M0IPC16string6StringPB4Hash4hash(key); let _tmp = 0; let _tmp$2 = hash & self.capacity_mask; while (true) { const i = _tmp; const idx = _tmp$2; const _tmp$3 = self.entries; $bound_check(_tmp$3, idx); const _bind = _tmp$3[idx]; if (_bind === undefined) { return undefined; } else { const _Some = _bind; const _entry = _Some; if (_entry.hash === hash && _entry.key === key) { return _entry.value; } if (i > _entry.psl) { return undefined; } _tmp = i + 1 | 0; _tmp$2 = idx + 1 & self.capacity_mask; continue; } } } function _M0MPB3Map3getGsRPB4JsonE(self, key) { const hash = _M0IPC16string6StringPB4Hash4hash(key); let _tmp = 0; let _tmp$2 = hash & self.capacity_mask; while (true) { const i = _tmp; const idx = _tmp$2; const _tmp$3 = self.entries; $bound_check(_tmp$3, idx); const _bind = _tmp$3[idx]; if (_bind === undefined) { return undefined; } else { const _Some = _bind; const _entry = _Some; if (_entry.hash === hash && _entry.key === key) { return _entry.value; } if (i > _entry.psl) { return undefined; } _tmp = i + 1 | 0; _tmp$2 = idx + 1 & self.capacity_mask; continue; } } } function _M0MPB3Map12contains__kvGsRPB4JsonE(self, key, value) { const hash = _M0IPC16string6StringPB4Hash4hash(key); let _tmp = 0; let _tmp$2 = hash & self.capacity_mask; while (true) { const i = _tmp; const idx = _tmp$2; const _tmp$3 = self.entries; $bound_check(_tmp$3, idx); const _bind = _tmp$3[idx]; if (_bind === undefined) { return false; } else { const _Some = _bind; const _entry = _Some; if (_entry.hash === hash && (_entry.key === key && _M0IPC14json4JsonPB2Eq5equal(_entry.value, value))) { return true; } if (i > _entry.psl) { return false; } _tmp = i + 1 | 0; _tmp$2 = idx + 1 & self.capacity_mask; continue; } } } function _M0MPB3Map13remove__entryGiWRP36zxch3n5flock5flock10EventBatchEuE(self, entry) { const _bind = entry.prev; if (_bind === -1) { self.head = entry.next; } else { const _tmp = self.entries; $bound_check(_tmp, _bind); const _p = _tmp[_bind]; let _tmp$2; if (_p === undefined) { _tmp$2 = $panic(); } else { const _p$2 = _p; _tmp$2 = _p$2; } _tmp$2.next = entry.next; } const _bind$2 = entry.next; if (_bind$2 === undefined) { self.tail = entry.prev; return; } else { const _Some = _bind$2; const _next = _Some; _next.prev = entry.prev; return; } } function _M0MPB3Map11shift__backGiWRP36zxch3n5flock5flock10EventBatchEuE(self, idx) { let _tmp = idx; while (true) { const cur = _tmp; const next = cur + 1 & self.capacity_mask; _L: { const _tmp$2 = self.entries; $bound_check(_tmp$2, next); const _bind = _tmp$2[next]; if (_bind === undefined) { break _L; } else { const _Some = _bind; const _x = _Some; const _x$2 = _x.psl; if (_x$2 === 0) { break _L; } else { _x.psl = _x.psl - 1 | 0; _M0MPB3Map10set__entryGiWRP36zxch3n5flock5flock10EventBatchEuE(self, _x, cur); _tmp = next; continue; } } } const _tmp$2 = self.entries; $bound_check(_tmp$2, cur); _tmp$2[cur] = undefined; return; } } function _M0MPB3Map18remove__with__hashGiWRP36zxch3n5flock5flock10EventBatchEuE(self, key, hash) { let _tmp = 0; let _tmp$2 = hash & self.capacity_mask; while (true) { const i = _tmp; const idx = _tmp$2; const _tmp$3 = self.entries; $bound_check(_tmp$3, idx); const _bind = _tmp$3[idx]; if (_bind === undefined) { return; } else { const _Some = _bind; const _entry = _Some; if (_entry.hash === hash && _entry.key === key) { _M0MPB3Map13remove__entryGiWRP36zxch3n5flock5flock10EventBatchEuE(self, _entry); _M0MPB3Map11shift__backGiWRP36zxch3n5flock5flock10EventBatchEuE(self, idx); self.size = self.size - 1 | 0; return; } if (i > _entry.psl) { return; } _tmp = i + 1 | 0; _tmp$2 = idx + 1 & self.capacity_mask; continue; } } } function _M0MPB3Map6removeGiWRP36zxch3n5flock5flock10EventBatchEuE(self, key) { _M0MPB3Map18remove__with__hashGiWRP36zxch3n5flock5flock10EventBatchEuE(self, key, _M0IPC13int3IntPB4Hash4hash(key)); } function _M0IPB3MapPB4Show6outputGsRPB4JsonE(self, logger) { logger.method_table.method_0(logger.self, "{"); let _tmp = 0; let _tmp$2 = self.head; while (true) { const x = _tmp; const y = _tmp$2; if (y === undefined) { logger.method_table.method_0(logger.self, "}"); return; } else { const _Some = y; const _x = _Some; const _key = _x.key; const _value = _x.value; const _next = _x.next; if (x > 0) { logger.method_table.method_0(logger.self, ", "); } _M0MPB6Logger13write__objectGsE(logger, _key); logger.method_table.method_0(logger.self, ": "); _M0MPB6Logger13write__objectGRPB4JsonE(logger, _value); _tmp = x + 1 | 0; _tmp$2 = _next; continue; } } } function _M0MPB3Map4iterGsRPB4JsonE(self) { const curr_entry = new _M0TPB8MutLocalGORPB5EntryGsRPB4JsonEE(self.head); const len = self.size; const remaining = new _M0TPB8MutLocalGiE(len); return _M0MPB4Iter3newGUsRPB4JsonEE(() => { _L: { if (remaining.val > 0) { const _bind = curr_entry.val; if (_bind === undefined) { break _L; } else { const _Some = _bind; const _x = _Some; const _key = _x.key; const _value = _x.value; const _next = _x.next; curr_entry.val = _next; remaining.val = remaining.val - 1 | 0; return { _0: _key, _1: _value }; } } else { break _L; } } return undefined; }, len); } function _M0MPB3Map5iter2GsRP36zxch3n5flock5flock3HlcE(self) { return _M0MPB3Map4iterGsRPB4JsonE(self); } function _M0IPB3MapPB2Eq5equalGsRPB4JsonE(self, that) { if (self.size === that.size) { const _it = _M0MPB3Map5iter2GsRP36zxch3n5flock5flock3HlcE(self); while (true) { const _bind = _M0MPB5Iter24nextGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(_it); if (_bind === undefined) { return true; } else { const _Some = _bind; const _x = _Some; const _k = _x._0; const _v = _x._1; if (_M0MPB3Map12contains__kvGsRPB4JsonE(that, _k, _v)) { } else { return false; } continue; } } } else { return false; } } function _M0MPB3Map4copyGsRP36zxch3n5flock5flock3HlcE(self) { const _bind = self.capacity; const _bind$2 = $make_array_len_and_init(self.capacity, undefined); const _bind$3 = self.size; const _bind$4 = self.capacity_mask; const _bind$5 = self.grow_at; const _bind$6 = undefined; const _bind$7 = self.tail; const other = new _M0TPB3MapGsRP36zxch3n5flock5flock3HlcE(_bind$2, _bind$3, _bind, _bind$4, _bind$5, _bind$6, _bind$7); if (self.size === 0) { return other; } const _tmp = self.entries; const _tmp$2 = self.tail; $bound_check(_tmp, _tmp$2); const _bind$8 = _tmp[_tmp$2]; if (_bind$8 === undefined) { return $panic(); } else { const _Some = _bind$8; const _last = _Some; let _tmp$3 = _last; let _tmp$4 = self.tail; let _tmp$5 = undefined; while (true) { const entry = _tmp$3; const idx = _tmp$4; const next = _tmp$5; const _prev = entry.prev; const _psl = entry.psl; const _hash = entry.hash; const _key = entry.key; const _value = entry.value; const new_entry = new _M0TPB5EntryGsRP36zxch3n5flock5flock3HlcE(_prev, next, _psl, _hash, _key, _value); const _tmp$6 = other.entries; $bound_check(_tmp$6, idx); _tmp$6[idx] = new_entry; if (_prev !== -1) { const _tmp$7 = self.entries; $bound_check(_tmp$7, _prev); const _p = _tmp$7[_prev]; if (_p === undefined) { _tmp$3 = $panic(); } else { const _p$2 = _p; _tmp$3 = _p$2; } _tmp$4 = _prev; _tmp$5 = new_entry; continue; } else { other.head = new_entry; break; } } return other; } } function _M0IPC14json4JsonPB2Eq5equal(a, b) { switch (a.$tag) { case 0: { if (b.$tag === 0) { return true; } else { return false; } } case 1: { if (b.$tag === 1) { return true; } else { return false; } } case 2: { if (b.$tag === 2) { return true; } else { return false; } } case 3: { const _Number = a; const _a_num = _Number._0; if (b.$tag === 3) { const _Number$2 = b; const _b_num = _Number$2._0; return _a_num === _b_num; } else { return false; } } case 4: { const _String = a; const _a_str = _String._0; if (b.$tag === 4) { const _String$2 = b; const _b_str = _String$2._0; return _a_str === _b_str; } else { return false; } } case 5: { const _Array = a; const _a_arr = _Array._0; if (b.$tag === 5) { const _Array$2 = b; const _b_arr = _Array$2._0; return _M0IPC15array5ArrayPB2Eq5equalGRPB4JsonE(_a_arr, _b_arr); } else { return false; } } default: { const _Object = a; const _a_obj = _Object._0; if (b.$tag === 6) { const _Object$2 = b; const _b_obj = _Object$2._0; return _M0IPB3MapPB2Eq5equalGsRPB4JsonE(_a_obj, _b_obj); } else { return false; } } } } function _M0IPC13int3IntPB6ToJson8to__json(self) { const _p = self + 0; const _p$2 = undefined; return new _M0DTPB4Json6Number(_p, _p$2); } function _M0IPC16double6DoublePB6ToJson8to__json(self) { if (self !== self) { const _p = "NaN"; return new _M0DTPB4Json6String(_p); } else { if (self > $i64_reinterpret_f64(9218868437227405311n)) { const _p = "Infinity"; return new _M0DTPB4Json6String(_p); } else { if (self < $i64_reinterpret_f64(18442240474082181119n)) { const _p = "-Infinity"; return new _M0DTPB4Json6String(_p); } else { const _p = undefined; return new _M0DTPB4Json6Number(self, _p); } } } } function _M0IPC15array5ArrayPB6ToJson8to__jsonGRPB4JsonE(self) { const _p = new Array(self.length); const _p$2 = self.length; let _tmp = 0; while (true) { const _p$3 = _tmp; if (_p$3 < _p$2) { const _p$4 = self[_p$3]; _p[_p$3] = _p$4; _tmp = _p$3 + 1 | 0; continue; } else { break; } } return new _M0DTPB4Json5Array(_p); } function _M0IPB3MapPB6ToJson8to__jsonGsRPB4JsonE(self) { const _bind = []; const object = _M0MPB3Map3MapGsRPB4JsonE(new _M0TPB9ArrayViewGUsRPB4JsonEE(_bind, 0, 0), self.capacity); const _it = _M0MPB3Map5iter2GsRP36zxch3n5flock5flock3HlcE(self); while (true) { const _bind$2 = _M0MPB5Iter24nextGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(_it); if (_bind$2 === undefined) { break; } else { const _Some = _bind$2; const _x = _Some; const _k = _x._0; const _v = _x._1; _M0MPB3Map3setGsRPB4JsonE(object, _k, _v); continue; } } return new _M0DTPB4Json6Object(object); } function _M0MPB5Iter24nextGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(self) { return _M0MPB4Iter4nextGURP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEEE(self); } function _M0MPB5Iter24nextGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(self) { return _M0MPB4Iter4nextGURP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEEE(self); } function _M0MPB5Iter24nextGRPB5ArrayGRPB4JsonERP36zxch3n5flock5flock5EntryE(self) { return _M0MPB4Iter4nextGURP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEEE(self); } function _M0MPB5Iter23runGRPB5ArrayGRPB4JsonERP36zxch3n5flock5flock5EntryE(self, f) { while (true) { const _bind = _M0MPB4Iter4nextGURP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEEE(self); if (_bind === undefined) { return 1; } else { const _Some = _bind; const _x = _Some; const _x$2 = _x._0; const _y = _x._1; const _bind$2 = f(_x$2, _y); if (_bind$2 === 1) { } else { return 0; } continue; } } } function _M0IPC16string6StringPB4Hash4hash(self) { let acc = (_M0FPB4seed >>> 0) + (374761393 >>> 0) | 0; const _bind = self.length; let _tmp = 0; while (true) { const i = _tmp; if (i < _bind) { acc = (acc >>> 0) + (4 >>> 0) | 0; const v = self.charCodeAt(i); acc = _M0FPB13consume4__acc(acc, v); _tmp = i + 1 | 0; continue; } else { break; } } return _M0FPB13finalize__acc(acc); } function _M0IPC13int3IntPB4Hash4hash(self) { const acc = (((_M0FPB4seed >>> 0) + (374761393 >>> 0) | 0) >>> 0) + (4 >>> 0) | 0; return _M0FPB13finalize__acc(_M0FPB13consume4__acc(acc, self)); } function _M0MPC15array10FixedArray23unsafe__make__and__blitGyE(src, allocate_len, init, src_offset, dst_offset, blit_len) { const dst = $makebytes(allocate_len, init); _M0MPC15array10FixedArray12unsafe__blitGyE(dst, dst_offset, src, src_offset, blit_len); return dst; } function _M0MPC15array10FixedArray23make__and__blit_2einnerGyE(src, allocate_len, init, len, src_offset, dst_offset) { if (allocate_len >= 0 && (len >= 0 && (src_offset >= 0 && (dst_offset >= 0 && ((src_offset + len | 0) <= src.length && (dst_offset + len | 0) <= allocate_len))))) { return _M0MPC15array10FixedArray23unsafe__make__and__blitGyE(src, allocate_len, init, src_offset, dst_offset, len); } else { const _string_builder = _M0MPB13StringBuilder21StringBuilder_2einner(89); _M0IPB13StringBuilderPB6Logger13write__string(_string_builder, "bounds check failed: allocate_len = "); _M0MPB13StringBuilder13write__objectGiE(_string_builder, allocate_len); _M0IPB13StringBuilderPB6Logger13write__string(_string_builder, ", src_offset = "); _M0MPB13StringBuilder13write__objectGiE(_string_builder, src_offset); _M0IPB13StringBuilderPB6Logger13write__string(_string_builder, ", dst_offset = "); _M0MPB13StringBuilder13write__objectGiE(_string_builder, dst_offset); _M0IPB13StringBuilderPB6Logger13write__string(_string_builder, ", len = "); _M0MPB13StringBuilder13write__objectGiE(_string_builder, len); _M0IPB13StringBuilderPB6Logger13write__string(_string_builder, ", src.length = "); _M0MPB13StringBuilder13write__objectGiE(_string_builder, src.length); return _M0FPC15abort5abortGRP36zxch3n5flock5types7Utf8StrE(_string_builder.val); } } function _M0MPC15array10FixedArray4copyGyE(self) { return _M0MPB7JSArray4copy(self); } function _M0MPC16double6Double7to__int(self) { return self !== self ? 0 : self >= 2147483647 ? 2147483647 : self <= -2147483648 ? -2147483648 : self | 0; } function _M0IPC16double6DoublePB4Show10to__string(self) { return String(self); } function _M0MPC15bytes5Bytes5makei(length, value) { if (length <= 0) { return $bytes_literal$0; } const arr = $makebytes(length, value(0)); let _tmp = 1; while (true) { const i = _tmp; if (i < length) { $bound_check(arr, i); arr[i] = value(i); _tmp = i + 1 | 0; continue; } else { break; } } return arr; } function _M0MPB3Map11new_2einnerGsRP36zxch3n5flock5flock3HlcE(capacity) { return _M0FPB8new__mapGsRP36zxch3n5flock5flock3HlcE(capacity); } function _M0MPB3Map11new_2einnerGiWRP36zxch3n5flock5flock10EventBatchEuE(capacity) { return _M0FPB8new__mapGiWRP36zxch3n5flock5flock10EventBatchEuE(capacity); } function _M0MPB3Map3newGsRP36zxch3n5flock5flock3HlcE(capacity$46$opt) { let capacity; if (capacity$46$opt === undefined) { capacity = 8; } else { const _Some = capacity$46$opt; capacity = _Some; } return _M0MPB3Map11new_2einnerGsRP36zxch3n5flock5flock3HlcE(capacity); } function _M0MPB3Map3newGiWRP36zxch3n5flock5flock10EventBatchEuE(capacity$46$opt) { let capacity; if (capacity$46$opt === undefined) { capacity = 8; } else { const _Some = capacity$46$opt; capacity = _Some; } return _M0MPB3Map11new_2einnerGiWRP36zxch3n5flock5flock10EventBatchEuE(capacity); } function _M0FPB7printlnGsE(input) { console.log(input); } function _M0MPC15bytes9BytesView2at(self, index) { if (index >= 0 && index < (self.end - self.start | 0)) { const _tmp = self.bytes; const _tmp$2 = self.start + index | 0; $bound_check(_tmp, _tmp$2); return _tmp[_tmp$2]; } else { const _string_builder = _M0MPB13StringBuilder21StringBuilder_2einner(60); _M0IPB13StringBuilderPB6Logger13write__string(_string_builder, "index out of bounds: the len is from 0 to "); _M0MPB13StringBuilder13write__objectGiE(_string_builder, self.end - self.start | 0); _M0IPB13StringBuilderPB6Logger13write__string(_string_builder, " but the index is "); _M0MPB13StringBuilder13write__objectGiE(_string_builder, index); return _M0FPC15abort5abortGyE(_string_builder.val); } } function _M0MPC15bytes9BytesView12view_2einner(self, start, end) { const len = self.end - self.start | 0; let end$2; if (end === undefined) { end$2 = len; } else { const _Some = end; const _end = _Some; end$2 = _end < 0 ? len + _end | 0 : _end; } const start$2 = start < 0 ? len + start | 0 : start; if (start$2 >= 0 && (start$2 <= end$2 && end$2 <= len)) { const _bind = self.bytes; const _bind$2 = self.start + start$2 | 0; const _bind$3 = end$2 - start$2 | 0; return new _M0TPC15bytes9BytesView(_bind, _bind$2, _bind$2 + _bind$3 | 0); } else { return _M0FPC15abort5abortGRP36zxch3n5flock5types7Utf8StrE("Invalid index for View"); } } function _M0MPC15bytes9BytesView4iter(self) { const i = new _M0TPB8MutLocalGiE(0); const len = self.end - self.start | 0; return _M0MPB4Iter3newGyE(() => { if (i.val < len) { const _p = i.val; const result = self.bytes[self.start + _p | 0]; i.val = i.val + 1 | 0; return result; } else { return -1; } }, len); } function _M0MPC15array10FixedArray17blit__from__bytes(self, bytes_offset, src, src_offset, length) { const e1 = (bytes_offset + length | 0) - 1 | 0; const e2 = (src_offset + length | 0) - 1 | 0; const len1 = self.length; const len2 = src.length; if (length >= 0 && (bytes_offset >= 0 && (e1 < len1 && (src_offset >= 0 && e2 < len2)))) { _M0MPC15array10FixedArray12unsafe__blitGyE(self, bytes_offset, src, src_offset, length); return; } else { $panic(); return; } } function _M0MPC14byte4Byte10to__uint64(self) { const _p = self; return BigInt.asUintN(64, BigInt(_p >>> 0)); } function _M0MPC15array10FixedArray18set__utf16le__char(self, offset, value) { const code = value; if (code >>> 0 < 65536 >>> 0) { const _p = code & 255; $bound_check(self, offset); self[offset] = _p & 255; const _tmp = offset + 1 | 0; const _p$2 = code >>> 8 | 0; $bound_check(self, _tmp); self[_tmp] = _p$2 & 255; return 2; } else { if (code >>> 0 < 1114112 >>> 0) { const hi = (code >>> 0) - (65536 >>> 0) | 0; const lo = hi >>> 10 | 55296; const hi$2 = hi & 1023 | 56320; const _p = lo & 255; $bound_check(self, offset); self[offset] = _p & 255; const _tmp = offset + 1 | 0; const _p$2 = lo >>> 8 | 0; $bound_check(self, _tmp); self[_tmp] = _p$2 & 255; const _tmp$2 = offset + 2 | 0; const _p$3 = hi$2 & 255; $bound_check(self, _tmp$2); self[_tmp$2] = _p$3 & 255; const _tmp$3 = offset + 3 | 0; const _p$4 = hi$2 >>> 8 | 0; $bound_check(self, _tmp$3); self[_tmp$3] = _p$4 & 255; return 4; } else { return _M0FPC15abort5abortGiE("Char out of range"); } } } function _M0IPC15bytes5BytesPB2Eq5equal(self, other) { if (self.length !== other.length) { return false; } else { const len = self.length; let _tmp = 0; while (true) { const i = _tmp; if (i < len) { $bound_check(self, i); const _tmp$2 = self[i]; $bound_check(other, i); if (_tmp$2 !== other[i]) { return false; } _tmp = i + 1 | 0; continue; } else { return true; } } } } function _M0MPC15bytes5Bytes11from__array(arr) { return _M0MPC15bytes5Bytes5makei(arr.end - arr.start | 0, (i) => _M0MPC15array9ArrayView2atGyE(arr, i)); } function _M0MPC15bytes5Bytes10from__iter(iter) { const _bind = _M0MPB4Iter9to__arrayGyE(iter); return _M0MPC15bytes5Bytes11from__array(new _M0TPB9ArrayViewGyE(_bind, 0, _bind.length)); } function _M0IPC14byte4BytePB3Shr3shr(self, count) { return (self >>> count | 0) & 255; } function _M0MPC15array5Array17reserve__capacityGRP26zxch3n6expect6FormatE(self, capacity) {} function _M0MPC15array5Array11unsafe__popGRP36zxch3n5flock11sorted__map4NodeGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEEE(self) { return _M0MPB7JSArray3pop(self); } function _M0MPC15array5Array3popGRP36zxch3n5flock11sorted__map4NodeGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEEE(self) { if (self.length === 0) { return undefined; } else { const v = _M0MPC15array5Array11unsafe__popGRP36zxch3n5flock11sorted__map4NodeGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEEE(self); return v; } } function _M0MPC15array5Array6insertGRP36zxch3n5flock5flock5EntryE(self, index, value) { if (index >= 0 && index <= self.length) { _M0MPB7JSArray7splice1(self, index, 0, value); return; } else { const _string_builder = _M0MPB13StringBuilder21StringBuilder_2einner(60); _M0IPB13StringBuilderPB6Logger13write__string(_string_builder, "index out of bounds: the len is from 0 to "); _M0MPB13StringBuilder13write__objectGiE(_string_builder, self.length); _M0IPB13StringBuilderPB6Logger13write__string(_string_builder, " but the index is "); _M0MPB13StringBuilder13write__objectGiE(_string_builder, index); _M0FPC15abort5abortGuE(_string_builder.val); return; } } function _M0MPC15array5Array4copyGRPB4JsonE(self) { return _M0MPB7JSArray4copy(self); } function _M0MPC15array5Array2atGRP36zxch3n5flock5flock5EntryE(self, index) { const len = self.length; if (index >= 0 && index < len) { $bound_check(self, index); return self[index]; } else { return $panic(); } } function _M0MPC15array5Array2atGyE(self, index) { const len = self.length; if (index >= 0 && index < len) { $bound_check(self, index); return self[index]; } else { return $panic(); } } function _M0MPC15array5Array2atGjE(self, index) { const len = self.length; if (index >= 0 && index < len) { $bound_check(self, index); return self[index]; } else { return $panic(); } } function _M0MPC15array5Array3setGyE(self, index, value) { const len = self.length; if (index >= 0 && index < len) { $bound_check(self, index); self[index] = value; return; } else { $panic(); return; } } function _M0MPC15array5Array3setGUsRPB4JsonEE(self, index, value) { const len = self.length; if (index >= 0 && index < len) { $bound_check(self, index); self[index] = value; return; } else { $panic(); return; } } function _M0IPC15array5ArrayPB2Eq5equalGRPB4JsonE(self, other) { const self_len = self.length; const other_len = other.length; if (self_len === other_len) { let _tmp = 0; while (true) { const i = _tmp; if (i < self_len) { if (_M0IPC14json4JsonPB2Eq5equal(self[i], other[i])) { } else { return false; } _tmp = i + 1 | 0; continue; } else { return true; } } } else { return false; } } function _M0MPC15array5Array3revGyE(self) { const len = self.length; const arr = new Array(len); let _tmp = 0; while (true) { const i = _tmp; if (i < len) { arr[i] = self[(len - i | 0) - 1 | 0]; _tmp = i + 1 | 0; continue; } else { break; } } return arr; } function _M0MPC15array5Array18binary__search__byGRP36zxch3n5flock5flock5EntryE(self, cmp) { const _p = new _M0TPB9ArrayViewGRP36zxch3n5flock5flock5EntryE(self, 0, self.length); const _p$2 = _p.end - _p.start | 0; let _tmp = 0; let _tmp$2 = _p$2; while (true) { const _p$3 = _tmp; const _p$4 = _tmp$2; if (_p$3 < _p$4) { const _p$5 = _p$3 + ((_p$4 - _p$3 | 0) / 2 | 0) | 0; if (cmp(_p.buf[_p.start + _p$5 | 0]) < 0) { _tmp = _p$5 + 1 | 0; continue; } else { _tmp$2 = _p$5; continue; } } else { return _p$3 < _p$2 && cmp(_p.buf[_p.start + _p$3 | 0]) === 0 ? new _M0DTPC16result6ResultGiiE2Ok(_p$3) : new _M0DTPC16result6ResultGiiE3Err(_p$3); } } } function _M0MPC15array5Array10push__iterGRP26zxch3n6expect6FormatE(self, iter) { const _bind = iter.size_hint; if (_bind === undefined) { } else { const _Some = _bind; const _n = _Some; _M0MPC15array5Array17reserve__capacityGRP26zxch3n6expect6FormatE(self, self.length + _n | 0); } while (true) { const _bind$2 = _M0MPB4Iter4nextGRP26zxch3n6expect6FormatE(iter); if (_bind$2 === undefined) { return; } else { const _Some = _bind$2; const _x = _Some; _M0MPC15array5Array4pushGRP26zxch3n6expect6FormatE(self, _x); continue; } } } function _M0MPC15array5Array4lastGRP36zxch3n5flock5flock5EntryE(self) { if (self.length === 0) { return undefined; } else { const _last = self[self.length - 1 | 0]; return _last; } } function _M0MPC15array5Array4joinGsE(self, separator) { return _M0MPC15array9ArrayView4joinGsE(new _M0TPB9ArrayViewGsE(self, 0, self.length), separator); } function _M0MPC14uint4UInt9to__int64(self) { return BigInt.asUintN(64, BigInt(self >>> 0)); } function _M0FPC13env3now() { return _M0FPC13env13now__internal(); } function _M0FPC28internal7strconv10range__errGuE() { return new _M0DTPC16result6ResultGuRPB7FailureE3Err(new _M0DTPC15error5Error48moonbitlang_2fcore_2fbuiltin_2eFailure_2eFailure(_M0FPC28internal7strconv15range__err__str)); } function _M0FPC28internal7strconv11syntax__errGdE() { return new _M0DTPC16result6ResultGdRPB7FailureE3Err(new _M0DTPC15error5Error48moonbitlang_2fcore_2fbuiltin_2eFailure_2eFailure(_M0FPC28internal7strconv16syntax__err__str)); } function _M0FPC28internal7strconv11syntax__errGORPC28internal7strconv6NumberE() { return new _M0DTPC16result6ResultGORPC28internal7strconv6NumberRPB7FailureE3Err(new _M0DTPC15error5Error48moonbitlang_2fcore_2fbuiltin_2eFailure_2eFailure(_M0FPC28internal7strconv16syntax__err__str)); } function _M0FPC28internal7strconv11syntax__errGuE() { return new _M0DTPC16result6ResultGuRPB7FailureE3Err(new _M0DTPC15error5Error48moonbitlang_2fcore_2fbuiltin_2eFailure_2eFailure(_M0FPC28internal7strconv16syntax__err__str)); } function _M0FPC28internal7strconv11syntax__errGRPC16string10StringViewE() { return new _M0DTPC16result6ResultGRPC16string10StringViewRPB7FailureE3Err(new _M0DTPC15error5Error48moonbitlang_2fcore_2fbuiltin_2eFailure_2eFailure(_M0FPC28internal7strconv16syntax__err__str)); } function _M0EPC16string10StringViewPC28internal7strconv12fold__digitsGmE(self, init, f) { let _tmp = self; let _tmp$2 = init; let _tmp$3 = 0; while (true) { const str = _tmp; const ret = _tmp$2; const len = _tmp$3; _L: { if ((str.end - str.start | 0) >= 1) { const _x = str.str.charCodeAt(str.start); if (_x >= 48 && _x <= 57) { const _x$2 = new _M0TPC16string10StringView(str.str, str.start + 1 | 0, str.end); _tmp = _x$2; _tmp$2 = f(_x - 48 | 0, ret); _tmp$3 = len + 1 | 0; continue; } else { if (_x === 95) { const _x$2 = new _M0TPC16string10StringView(str.str, str.start + 1 | 0, str.end); _tmp = _x$2; continue; } else { break _L; } } } else { break _L; } } return { _0: str, _1: ret, _2: len }; } } function _M0FPC28internal7strconv13parse__digits(s, x) { return _M0EPC16string10StringViewPC28internal7strconv12fold__digitsGmE(s, x, (digit, acc) => BigInt.asUintN(64, BigInt.asUintN(64, acc * 10n) + BigInt.asUintN(64, BigInt(digit >>> 0)))); } function _M0FPC28internal7strconv20try__parse__19digits(s, x) { let x$2 = x; let len = 0; let _tmp = s; while (true) { const s$2 = _tmp; let s$3; _L: { if ((s$2.end - s$2.start | 0) >= 1) { const _x = s$2.str.charCodeAt(s$2.start); if (_x >= 48 && _x <= 57) { const _x$2 = new _M0TPC16string10StringView(s$2.str, s$2.start + 1 | 0, s$2.end); if (BigInt.asUintN(64, x$2) < BigInt.asUintN(64, _M0FPC28internal7strconv17min__19digit__int)) { len = len + 1 | 0; x$2 = BigInt.asUintN(64, BigInt.asUintN(64, x$2 * 10n) + BigInt.asUintN(64, BigInt((_x - 48 | 0) >>> 0))); _tmp = _x$2; continue; } else { s$3 = s$2; break _L; } } else { if (_x === 95) { const _x$2 = new _M0TPC16string10StringView(s$2.str, s$2.start + 1 | 0, s$2.end); _tmp = _x$2; continue; } else { s$3 = s$2; break _L; } } } else { s$3 = s$2; break _L; } } return { _0: s$3, _1: x$2, _2: len }; } } function _M0FPC28internal7strconv17parse__scientific(s) { let s$2 = s; let neg_exp = false; let rest; let ch; _L: { _L$2: { const _bind = s$2; if ((_bind.end - _bind.start | 0) >= 1) { const _x = _bind.str.charCodeAt(_bind.start); switch (_x) { case 43: { const _x$2 = new _M0TPC16string10StringView(_bind.str, _bind.start + 1 | 0, _bind.end); rest = _x$2; ch = _x; break _L$2; } case 45: { const _x$3 = new _M0TPC16string10StringView(_bind.str, _bind.start + 1 | 0, _bind.end); rest = _x$3; ch = _x; break _L$2; } } } break _L; } neg_exp = ch === 45; s$2 = rest; } _L$2: { const _bind = s$2; if ((_bind.end - _bind.start | 0) >= 1) { const _x = _bind.str.charCodeAt(_bind.start); if (_x >= 48 && _x <= 57) { const _bind$2 = _M0EPC16string10StringViewPC28internal7strconv12fold__digitsGmE(s$2, _M0FPC28internal7strconv17parse__scientificN8exp__numS241, (digit, exp_num) => BigInt.asIntN(64, exp_num) < BigInt.asIntN(64, 65536n) ? BigInt.asUintN(64, BigInt.asUintN(64, 10n * exp_num) + BigInt.asUintN(64, BigInt(digit))) : exp_num); const _s = _bind$2._0; const _exp_num = _bind$2._1; return neg_exp ? { _0: _s, _1: BigInt.asUintN(64, -_exp_num) } : { _0: _s, _1: _exp_num }; } else { break _L$2; } } else { break _L$2; } } return undefined; } function _M0FPC28internal7strconv13parse__number(s) { let s$2; let negative; _L: { let rest; _L$2: { if ((s.end - s.start | 0) >= 1) { const _x = s.str.charCodeAt(s.start); switch (_x) { case 45: { const _x$2 = new _M0TPC16string10StringView(s.str, s.start + 1 | 0, s.end); s$2 = _x$2; negative = true; break _L; } case 43: { const _x$3 = new _M0TPC16string10StringView(s.str, s.start + 1 | 0, s.end); rest = _x$3; break _L$2; } default: { rest = s; break _L$2; } } } else { rest = s; break _L$2; } } s$2 = rest; negative = false; break _L; } if (_M0MPC16string10StringView9is__empty(s$2)) { return new _M0DTPC16result6ResultGORPC28internal7strconv6NumberRPC15error5ErrorE2Ok(undefined); } const _bind = _M0FPC28internal7strconv13parse__digits(s$2, 0n); const _s = _bind._0; const _mantissa = _bind._1; const _consumed = _bind._2; let mantissa = _mantissa; let s$3 = _s; let n_digits = _consumed; let n_after_dot = 0; let exponent = 0n; const _bind$2 = s$3; if ((_bind$2.end - _bind$2.start | 0) >= 1) { const _x = _bind$2.str.charCodeAt(_bind$2.start); if (_x === 46) { const _x$2 = new _M0TPC16string10StringView(_bind$2.str, _bind$2.start + 1 | 0, _bind$2.end); s$3 = _x$2; const _bind$3 = _M0FPC28internal7strconv13parse__digits(s$3, mantissa); const _new_s = _bind$3._0; const _new_mantissa = _bind$3._1; const _consumed_digit = _bind$3._2; s$3 = _new_s; mantissa = _new_mantissa; n_after_dot = _consumed_digit; exponent = BigInt.asUintN(64, -BigInt.asUintN(64, BigInt(n_after_dot))); } } n_digits = n_digits + n_after_dot | 0; if (n_digits === 0) { return new _M0DTPC16result6ResultGORPC28internal7strconv6NumberRPC15error5ErrorE2Ok(undefined); } let rest; _L$2: { _L$3: { const _bind$3 = s$3; if ((_bind$3.end - _bind$3.start | 0) >= 1) { const _x = _bind$3.str.charCodeAt(_bind$3.start); switch (_x) { case 101: { const _x$2 = new _M0TPC16string10StringView(_bind$3.str, _bind$3.start + 1 | 0, _bind$3.end); rest = _x$2; break _L$3; } case 69: { const _x$3 = new _M0TPC16string10StringView(_bind$3.str, _bind$3.start + 1 | 0, _bind$3.end); rest = _x$3; break _L$3; } } } break _L$2; } const _bind$3 = _M0FPC28internal7strconv17parse__scientific(rest); let _bind$4; if (_bind$3 === undefined) { return new _M0DTPC16result6ResultGORPC28internal7strconv6NumberRPC15error5ErrorE2Ok(undefined); } else { const _Some = _bind$3; _bind$4 = _Some; } const _new_s = _bind$4._0; const _exp_number = _bind$4._1; s$3 = _new_s; exponent = BigInt.asUintN(64, exponent + _exp_number); } const _bind$3 = s$3; if ((_bind$3.end - _bind$3.start | 0) === 0) { if (n_digits <= 19) { return new _M0DTPC16result6ResultGORPC28internal7strconv6NumberRPC15error5ErrorE2Ok(new _M0TPC28internal7strconv6Number(exponent, mantissa, negative, false)); } n_digits = n_digits - 19 | 0; let many_digits = false; let _tmp = s; while (true) { const s$4 = _tmp; _L$3: { let rest$2; let ch; _L$4: { if ((s$4.end - s$4.start | 0) >= 1) { const _x = s$4.str.charCodeAt(s$4.start); switch (_x) { case 48: { const _x$2 = new _M0TPC16string10StringView(s$4.str, s$4.start + 1 | 0, s$4.end); rest$2 = _x$2; ch = _x; break _L$4; } case 46: { const _x$3 = new _M0TPC16string10StringView(s$4.str, s$4.start + 1 | 0, s$4.end); rest$2 = _x$3; ch = _x; break _L$4; } default: { break _L$3; } } } else { break _L$3; } } n_digits = n_digits - ((ch - 46 | 0) / 2 | 0) | 0; _tmp = rest$2; continue; } break; } let mantissa$2 = mantissa; if (n_digits > 0) { many_digits = true; mantissa$2 = 0n; const _bind$4 = _M0FPC28internal7strconv20try__parse__19digits(s, mantissa$2); const _s$2 = _bind$4._0; const _new_mantissa = _bind$4._1; const _consumed_digit = _bind$4._2; mantissa$2 = _new_mantissa; let _tmp$2; if (BigInt.asUintN(64, mantissa$2) >= BigInt.asUintN(64, _M0FPC28internal7strconv17min__19digit__int)) { _tmp$2 = _consumed_digit; } else { if (_M0MPC16string6String24char__length__ge_2einner(_s$2.str, 1, _s$2.start, _s$2.end)) { const _tmp$3 = _s$2.str; const _bind$5 = _M0MPC16string6String29offset__of__nth__char_2einner(_s$2.str, 1, _s$2.start, _s$2.end); let _tmp$4; if (_bind$5 === undefined) { _tmp$4 = _s$2.end; } else { const _Some = _bind$5; _tmp$4 = _Some; } const _x = new _M0TPC16string10StringView(_tmp$3, _tmp$4, _s$2.end); const _bind$6 = _M0FPC28internal7strconv20try__parse__19digits(_x, mantissa$2); const _new_mantissa$2 = _bind$6._1; const _consumed_digit$2 = _bind$6._2; mantissa$2 = _new_mantissa$2; _tmp$2 = _consumed_digit$2; } else { return new _M0DTPC16result6ResultGORPC28internal7strconv6NumberRPC15error5ErrorE2Ok(undefined); } } exponent = BigInt.asUintN(64, BigInt(_tmp$2)); exponent = BigInt.asUintN(64, exponent + _M0FPC28internal7strconv13parse__numberN11exp__numberS222); } return new _M0DTPC16result6ResultGORPC28internal7strconv6NumberRPC15error5ErrorE2Ok(new _M0TPC28internal7strconv6Number(exponent, mantissa$2, negative, many_digits)); } else { return _M0FPC28internal7strconv11syntax__errGORPC28internal7strconv6NumberE(); } } function _M0FPC28internal7strconv15parse__inf__nan(rest) { let pos; let rest$2; _L: { let rest$3; _L$2: { if ((rest.end - rest.start | 0) >= 1) { const _x = rest.str.charCodeAt(rest.start); switch (_x) { case 45: { const _x$2 = new _M0TPC16string10StringView(rest.str, rest.start + 1 | 0, rest.end); pos = false; rest$2 = _x$2; break _L; } case 43: { const _x$3 = new _M0TPC16string10StringView(rest.str, rest.start + 1 | 0, rest.end); rest$3 = _x$3; break _L$2; } default: { rest$3 = rest; break _L$2; } } } else { rest$3 = rest; break _L$2; } } pos = true; rest$2 = rest$3; break _L; } const _data = rest$2.str; const _start = rest$2.start; const _end = _start + (rest$2.end - rest$2.start | 0) | 0; let _cursor = _start; let accept_state = -1; let match_end = -1; _L$2: { _L$3: { if ((_cursor + 2 | 0) < _end) { _L$4: { _L$5: { const _p = _cursor; const next_char = _data.charCodeAt(_p); _cursor = _cursor + 1 | 0; if (next_char < 79) { if (next_char < 74) { if (next_char < 73) { break _L$2; } else { break _L$4; } } else { if (next_char > 77) { break _L$5; } else { break _L$2; } } } else { if (next_char > 104) { if (next_char < 110) { if (next_char < 106) { break _L$4; } else { break _L$2; } } else { if (next_char > 110) { break _L$2; } else { break _L$5; } } } else { break _L$2; } } } _L$6: { const _p = _cursor; const next_char = _data.charCodeAt(_p); _cursor = _cursor + 1 | 0; if (next_char < 66) { if (next_char < 65) { break _L$2; } else { break _L$6; } } else { if (next_char > 96) { if (next_char < 98) { break _L$6; } else { break _L$2; } } else { break _L$2; } } } _L$7: { const _p = _cursor; const next_char = _data.charCodeAt(_p); _cursor = _cursor + 1 | 0; if (next_char < 79) { if (next_char < 78) { break _L$2; } else { break _L$7; } } else { if (next_char > 109) { if (next_char < 111) { break _L$7; } else { break _L$2; } } else { break _L$2; } } } if (_cursor < _end) { break _L$2; } else { accept_state = 0; match_end = _cursor; break _L$2; } } _L$5: { const _p = _cursor; const next_char = _data.charCodeAt(_p); _cursor = _cursor + 1 | 0; if (next_char < 79) { if (next_char < 78) { break _L$2; } else { break _L$5; } } else { if (next_char > 109) { if (next_char < 111) { break _L$5; } else { break _L$2; } } else { break _L$2; } } } _L$6: { const _p = _cursor; const next_char = _data.charCodeAt(_p); _cursor = _cursor + 1 | 0; if (next_char < 71) { if (next_char < 70) { break _L$2; } else { break _L$6; } } else { if (next_char > 101) { if (next_char < 103) { break _L$6; } else { break _L$2; } } else { break _L$2; } } } if (_cursor < _end) { _L$7: { const _p = _cursor; const next_char = _data.charCodeAt(_p); _cursor = _cursor + 1 | 0; if (next_char < 74) { if (next_char < 73) { break _L$2; } else { break _L$7; } } else { if (next_char > 104) { if (next_char < 106) { break _L$7; } else { break _L$2; } } else { break _L$2; } } } if ((_cursor + 3 | 0) < _end) { _L$8: { const _p = _cursor; const next_char = _data.charCodeAt(_p); _cursor = _cursor + 1 | 0; if (next_char < 79) { if (next_char < 78) { break _L$2; } else { break _L$8; } } else { if (next_char > 109) { if (next_char < 111) { break _L$8; } else { break _L$2; } } else { break _L$2; } } } _L$9: { const _p = _cursor; const next_char = _data.charCodeAt(_p); _cursor = _cursor + 1 | 0; if (next_char < 74) { if (next_char < 73) { break _L$2; } else { break _L$9; } } else { if (next_char > 104) { if (next_char < 106) { break _L$9; } else { break _L$2; } } else { break _L$2; } } } _L$10: { const _p = _cursor; const next_char = _data.charCodeAt(_p); _cursor = _cursor + 1 | 0; if (next_char < 85) { if (next_char < 84) { break _L$2; } else { break _L$10; } } else { if (next_char > 115) { if (next_char < 117) { break _L$10; } else { break _L$2; } } else { break _L$2; } } } _L$11: { const _p = _cursor; const next_char = _data.charCodeAt(_p); _cursor = _cursor + 1 | 0; if (next_char < 90) { if (next_char < 89) { break _L$2; } else { break _L$11; } } else { if (next_char > 120) { if (next_char < 122) { break _L$11; } else { break _L$2; } } else { break _L$2; } } } if (_cursor < _end) { break _L$2; } else { break _L$3; } } else { break _L$2; } } else { break _L$3; } } else { break _L$2; } } accept_state = 1; match_end = _cursor; break _L$2; } switch (accept_state) { case 0: { return new _M0DTPC16result6ResultGdRPC15error5ErrorE2Ok(_M0FPC16double14not__a__number); } case 1: { return pos ? new _M0DTPC16result6ResultGdRPC15error5ErrorE2Ok(_M0FPC16double8infinity) : new _M0DTPC16result6ResultGdRPC15error5ErrorE2Ok(_M0FPC16double13neg__infinity); } default: { return _M0FPC28internal7strconv11syntax__errGdE(); } } } function _M0FPC28internal7strconv12checked__mul(a, b) { if (BigInt.asUintN(64, a) === BigInt.asUintN(64, 0n) || BigInt.asUintN(64, b) === BigInt.asUintN(64, 0n)) { return _M0FPC28internal7strconv12checked__mulN6constrS1108; } if (BigInt.asUintN(64, a) === BigInt.asUintN(64, 1n)) { return b; } if (BigInt.asUintN(64, b) === BigInt.asUintN(64, 1n)) { return a; } if ($i64_clz(b) === 0 || $i64_clz(a) === 0) { return undefined; } if (b === 0n) { $panic(); } const quotient = BigInt.asUintN(64, BigInt.asUintN(64, 18446744073709551615n) / BigInt.asUintN(64, b)); if (BigInt.asUintN(64, a) > BigInt.asUintN(64, quotient)) { return undefined; } return BigInt.asUintN(64, a * b); } function _M0FPC28internal7strconv17check__underscore(str) { let rest; if ((str.end - str.start | 0) >= 1) { const _x = str.str.charCodeAt(str.start); switch (_x) { case 43: { const _x$2 = new _M0TPC16string10StringView(str.str, str.start + 1 | 0, str.end); rest = _x$2; break; } case 45: { const _x$3 = new _M0TPC16string10StringView(str.str, str.start + 1 | 0, str.end); rest = _x$3; break; } default: { rest = str; } } } else { rest = str; } let rest$2; let allow_underscore; let hex; _L: { const _data = rest.str; const _start = rest.start; const _end = _start + (rest.end - rest.start | 0) | 0; let _cursor = _start; let accept_state = -1; let match_end = -1; _L$2: { if ((_cursor + 1 | 0) < _end) { const _p = _cursor; if (_data.charCodeAt(_p) === 48) { _cursor = _cursor + 1 | 0; _L$3: { _L$4: { _L$5: { const _p$2 = _cursor; const next_char = _data.charCodeAt(_p$2); _cursor = _cursor + 1 | 0; if (next_char < 89) { if (next_char < 79) { if (next_char === 66) { break _L$3; } else { break _L$2; } } else { if (next_char > 79) { if (next_char < 88) { break _L$2; } else { break _L$5; } } else { break _L$4; } } } else { if (next_char > 97) { if (next_char < 112) { if (next_char < 99) { break _L$3; } else { if (next_char > 110) { break _L$4; } else { break _L$2; } } } else { if (next_char > 119) { if (next_char < 121) { break _L$5; } else { break _L$2; } } else { break _L$2; } } } else { break _L$2; } } } accept_state = 2; match_end = _cursor; break _L$2; } accept_state = 1; match_end = _cursor; break _L$2; } accept_state = 0; match_end = _cursor; break _L$2; } else { break _L$2; } } else { break _L$2; } } switch (accept_state) { case 2: { const rest$3 = _M0MPC16string6String4view(_data, match_end, _end); rest$2 = rest$3; allow_underscore = true; hex = true; break _L; } case 1: { const rest$4 = _M0MPC16string6String4view(_data, match_end, _end); rest$2 = rest$4; allow_underscore = true; hex = false; break _L; } case 0: { const rest$5 = _M0MPC16string6String4view(_data, match_end, _end); rest$2 = rest$5; allow_underscore = true; hex = false; break _L; } default: { rest$2 = rest; allow_underscore = false; hex = false; break _L; } } } let _tmp = rest$2; let _tmp$2 = allow_underscore; let _tmp$3 = false; while (true) { const rest$3 = _tmp; const allow_underscore$2 = _tmp$2; const follow_underscore = _tmp$3; let rest$4; _L$2: { _L$3: { let rest$5; _L$4: { _L$5: { let rest$6; _L$6: { let rest$7; _L$7: { if ((rest$3.end - rest$3.start | 0) === 0) { return true; } else { if ((rest$3.end - rest$3.start | 0) === 1) { const _x = rest$3.str.charCodeAt(rest$3.start); if (_x === 95) { return false; } else { if (_x >= 48 && _x <= 57) { const _x$2 = new _M0TPC16string10StringView(rest$3.str, rest$3.start + 1 | 0, rest$3.end); rest$7 = _x$2; break _L$7; } else { if (_x >= 97 && _x <= 102) { const _x$2 = new _M0TPC16string10StringView(rest$3.str, rest$3.start + 1 | 0, rest$3.end); if (hex) { rest$6 = _x$2; break _L$6; } else { if (_x === 101) { if (follow_underscore === true) { break _L$5; } else { rest$5 = _x$2; break _L$4; } } else { if (follow_underscore === true) { break _L$3; } else { rest$4 = _x$2; break _L$2; } } } } else { if (_x >= 65 && _x <= 70) { const _x$2 = new _M0TPC16string10StringView(rest$3.str, rest$3.start + 1 | 0, rest$3.end); if (hex) { rest$6 = _x$2; break _L$6; } else { if (_x === 69) { if (follow_underscore === true) { break _L$5; } else { rest$5 = _x$2; break _L$4; } } else { if (follow_underscore === true) { break _L$3; } else { rest$4 = _x$2; break _L$2; } } } } else { if (_x === 46) { if (follow_underscore === true) { break _L$5; } else { const _x$2 = new _M0TPC16string10StringView(rest$3.str, rest$3.start + 1 | 0, rest$3.end); rest$5 = _x$2; break _L$4; } } else { if (_x === 43) { if (follow_underscore === true) { break _L$5; } else { const _x$2 = new _M0TPC16string10StringView(rest$3.str, rest$3.start + 1 | 0, rest$3.end); rest$5 = _x$2; break _L$4; } } else { if (_x === 45) { if (follow_underscore === true) { break _L$5; } else { const _x$2 = new _M0TPC16string10StringView(rest$3.str, rest$3.start + 1 | 0, rest$3.end); rest$5 = _x$2; break _L$4; } } else { if (follow_underscore === true) { break _L$3; } else { const _tmp$4 = rest$3.str; const _bind = _M0MPC16string6String29offset__of__nth__char_2einner(rest$3.str, 1, rest$3.start, rest$3.end); let _tmp$5; if (_bind === undefined) { _tmp$5 = rest$3.end; } else { const _Some = _bind; _tmp$5 = _Some; } const _x$2 = new _M0TPC16string10StringView(_tmp$4, _tmp$5, rest$3.end); rest$4 = _x$2; break _L$2; } } } } } } } } } else { const _x = rest$3.str.charCodeAt(rest$3.start); if (_x === 95) { if (allow_underscore$2 === false) { return false; } else { const _x$2 = new _M0TPC16string10StringView(rest$3.str, rest$3.start + 1 | 0, rest$3.end); _tmp = _x$2; _tmp$2 = false; _tmp$3 = true; continue; } } else { if (_x >= 48 && _x <= 57) { const _x$2 = new _M0TPC16string10StringView(rest$3.str, rest$3.start + 1 | 0, rest$3.end); rest$7 = _x$2; break _L$7; } else { if (_x >= 97 && _x <= 102) { const _x$2 = new _M0TPC16string10StringView(rest$3.str, rest$3.start + 1 | 0, rest$3.end); if (hex) { rest$6 = _x$2; break _L$6; } else { if (_x === 101) { if (follow_underscore === true) { break _L$5; } else { rest$5 = _x$2; break _L$4; } } else { if (follow_underscore === true) { break _L$3; } else { rest$4 = _x$2; break _L$2; } } } } else { if (_x >= 65 && _x <= 70) { const _x$2 = new _M0TPC16string10StringView(rest$3.str, rest$3.start + 1 | 0, rest$3.end); if (hex) { rest$6 = _x$2; break _L$6; } else { if (_x === 69) { if (follow_underscore === true) { break _L$5; } else { rest$5 = _x$2; break _L$4; } } else { if (follow_underscore === true) { break _L$3; } else { rest$4 = _x$2; break _L$2; } } } } else { if (_x === 46) { if (follow_underscore === true) { break _L$5; } else { const _x$2 = new _M0TPC16string10StringView(rest$3.str, rest$3.start + 1 | 0, rest$3.end); rest$5 = _x$2; break _L$4; } } else { if (_x === 43) { if (follow_underscore === true) { break _L$5; } else { const _x$2 = new _M0TPC16string10StringView(rest$3.str, rest$3.start + 1 | 0, rest$3.end); rest$5 = _x$2; break _L$4; } } else { if (_x === 45) { if (follow_underscore === true) { break _L$5; } else { const _x$2 = new _M0TPC16string10StringView(rest$3.str, rest$3.start + 1 | 0, rest$3.end); rest$5 = _x$2; break _L$4; } } else { if (follow_underscore === true) { break _L$3; } else { const _tmp$4 = rest$3.str; const _bind = _M0MPC16string6String29offset__of__nth__char_2einner(rest$3.str, 1, rest$3.start, rest$3.end); let _tmp$5; if (_bind === undefined) { _tmp$5 = rest$3.end; } else { const _Some = _bind; _tmp$5 = _Some; } const _x$2 = new _M0TPC16string10StringView(_tmp$4, _tmp$5, rest$3.end); rest$4 = _x$2; break _L$2; } } } } } } } } } } } _tmp = rest$7; _tmp$2 = true; _tmp$3 = false; continue; } _tmp = rest$6; _tmp$2 = true; _tmp$3 = false; continue; } return false; } _tmp = rest$5; _tmp$2 = false; _tmp$3 = false; continue; } return false; } _tmp = rest$4; _tmp$2 = false; _tmp$3 = false; continue; } } function _M0MPC28internal7strconv7Decimal9new__priv() { return new _M0TPC28internal7strconv7Decimal($makebytes(800, 0), 0, 0, false, false); } function _M0MPC28internal7strconv7Decimal4trim(self) { while (true) { let _tmp; if (self.digits_num > 0) { const _tmp$2 = self.digits; const _tmp$3 = self.digits_num - 1 | 0; $bound_check(_tmp$2, _tmp$3); const _p = _tmp$2[_tmp$3]; const _p$2 = 0; _tmp = _p === _p$2; } else { _tmp = false; } if (_tmp) { self.digits_num = self.digits_num - 1 | 0; continue; } else { break; } } if (self.digits_num === 0) { self.decimal_point = 0; return; } else { return; } } function _M0FPC28internal7strconv26parse__decimal__from__view(str) { const d = _M0MPC28internal7strconv7Decimal9new__priv(); let has_dp = false; let has_digits = false; let rest; _L: { _L$2: { if ((str.end - str.start | 0) >= 1) { const _x = str.str.charCodeAt(str.start); switch (_x) { case 45: { const _x$2 = new _M0TPC16string10StringView(str.str, str.start + 1 | 0, str.end); d.negative = true; rest = _x$2; break; } case 43: { rest = new _M0TPC16string10StringView(str.str, str.start + 1 | 0, str.end); break; } default: { break _L$2; } } } else { break _L$2; } break _L; } rest = str; } let rest$2; let _tmp = rest; while (true) { const rest$3 = _tmp; let rest$4; _L$2: { _L$3: { if ((rest$3.end - rest$3.start | 0) >= 1) { const _x = rest$3.str.charCodeAt(rest$3.start); if (_x === 95) { const _x$2 = new _M0TPC16string10StringView(rest$3.str, rest$3.start + 1 | 0, rest$3.end); _tmp = _x$2; continue; } else { if (_x === 46) { const _x$2 = new _M0TPC16string10StringView(rest$3.str, rest$3.start + 1 | 0, rest$3.end); if (!has_dp) { has_dp = true; d.decimal_point = d.digits_num; _tmp = _x$2; continue; } else { const _bind = _M0FPC28internal7strconv11syntax__errGuE(); if (_bind.$tag === 1) { const _ok = _bind; _ok._0; } else { return _bind; } } } else { if (_x >= 48 && _x <= 57) { const _x$2 = new _M0TPC16string10StringView(rest$3.str, rest$3.start + 1 | 0, rest$3.end); has_digits = true; if (_x === 48 && d.digits_num === 0) { d.decimal_point = d.decimal_point - 1 | 0; _tmp = _x$2; continue; } if (d.digits_num < d.digits.length) { const _tmp$2 = d.digits; const _tmp$3 = d.digits_num; $bound_check(_tmp$2, _tmp$3); _tmp$2[_tmp$3] = (_x - 48 | 0) & 255; d.digits_num = d.digits_num + 1 | 0; } else { if (_x !== 48) { d.truncated = true; } } _tmp = _x$2; continue; } else { rest$4 = rest$3; break _L$3; } } } } else { rest$4 = rest$3; break _L$3; } break _L$2; } rest$2 = rest$4; break; } continue; } if (has_digits) { if (!has_dp) { d.decimal_point = d.digits_num; } let rest$3; let rest$4; _L$2: { _L$3: { if ((rest$2.end - rest$2.start | 0) >= 1) { const _x = rest$2.str.charCodeAt(rest$2.start); switch (_x) { case 101: { const _x$2 = new _M0TPC16string10StringView(rest$2.str, rest$2.start + 1 | 0, rest$2.end); rest$4 = _x$2; break _L$3; } case 69: { const _x$3 = new _M0TPC16string10StringView(rest$2.str, rest$2.start + 1 | 0, rest$2.end); rest$4 = _x$3; break _L$3; } default: { rest$3 = rest$2; } } } else { rest$3 = rest$2; } break _L$2; } let exp_sign = 1; let rest$5; if ((rest$4.end - rest$4.start | 0) >= 1) { const _x = rest$4.str.charCodeAt(rest$4.start); switch (_x) { case 43: { rest$5 = new _M0TPC16string10StringView(rest$4.str, rest$4.start + 1 | 0, rest$4.end); break; } case 45: { const _x$2 = new _M0TPC16string10StringView(rest$4.str, rest$4.start + 1 | 0, rest$4.end); exp_sign = -1; rest$5 = _x$2; break; } default: { rest$5 = rest$4; } } } else { rest$5 = rest$4; } _L$4: { _L$5: { if ((rest$5.end - rest$5.start | 0) >= 1) { const _x = rest$5.str.charCodeAt(rest$5.start); if (_x >= 48 && _x <= 57) { const exp_limit = exp_sign > 0 ? (d.decimal_point < 311 ? 311 - d.decimal_point | 0 : 0) : d.decimal_point > -331 ? d.decimal_point + 331 | 0 : 0; let exp = 0; let rest$6; let _tmp$2 = rest$5; while (true) { const rest$7 = _tmp$2; let rest$8; _L$6: { if ((rest$7.end - rest$7.start | 0) >= 1) { const _x$2 = rest$7.str.charCodeAt(rest$7.start); if (_x$2 === 95) { const _x$3 = new _M0TPC16string10StringView(rest$7.str, rest$7.start + 1 | 0, rest$7.end); _tmp$2 = _x$3; continue; } else { if (_x$2 >= 48 && _x$2 <= 57) { const _x$3 = new _M0TPC16string10StringView(rest$7.str, rest$7.start + 1 | 0, rest$7.end); if (exp < exp_limit) { exp = (Math.imul(exp, 10) | 0) + (_x$2 - 48 | 0) | 0; if (exp > exp_limit) { exp = exp_limit; } } _tmp$2 = _x$3; continue; } else { rest$8 = rest$7; break _L$6; } } } else { rest$8 = rest$7; break _L$6; } } rest$6 = rest$8; break; } d.decimal_point = d.decimal_point + (Math.imul(exp_sign, exp) | 0) | 0; rest$3 = rest$6; } else { break _L$5; } } else { break _L$5; } break _L$4; } const _bind = _M0FPC28internal7strconv11syntax__errGRPC16string10StringViewE(); if (_bind.$tag === 1) { const _ok = _bind; rest$3 = _ok._0; } else { return _bind; } } } if ((rest$3.end - rest$3.start | 0) === 0) { _M0MPC28internal7strconv7Decimal4trim(d); return new _M0DTPC16result6ResultGRPC28internal7strconv7DecimalRPC15error5ErrorE2Ok(d); } else { return _M0FPC28internal7strconv11syntax__errGRPC16string10StringViewE(); } } else { return _M0FPC28internal7strconv11syntax__errGRPC16string10StringViewE(); } } function _M0FPC28internal7strconv20parse__decimal__priv(str) { return _M0FPC28internal7strconv26parse__decimal__from__view(str); } function _M0FPC28internal7strconv14assemble__bits(mantissa, exponent, negative) { const biased_exp = exponent - _M0FPC28internal7strconv12double__info.bias | 0; let bits = BigInt.asUintN(64, mantissa & BigInt.asUintN(64, BigInt.asUintN(64, 1n << BigInt(_M0FPC28internal7strconv12double__info.mantissa_bits & 63)) - 1n)); const exp_bits = BigInt.asUintN(64, BigInt(biased_exp & ((1 << _M0FPC28internal7strconv12double__info.exponent_bits) - 1 | 0))); bits = BigInt.asUintN(64, bits | BigInt.asUintN(64, exp_bits << BigInt(_M0FPC28internal7strconv12double__info.mantissa_bits & 63))); if (negative) { bits = BigInt.asUintN(64, bits | BigInt.asUintN(64, BigInt.asUintN(64, 1n << BigInt(_M0FPC28internal7strconv12double__info.mantissa_bits & 63)) << BigInt(_M0FPC28internal7strconv12double__info.exponent_bits & 63))); } return bits; } function _M0MPC28internal7strconv7Decimal17should__round__up(self, d) { if (d < 0 || d >= self.digits_num) { return false; } let _tmp; const _tmp$2 = self.digits; $bound_check(_tmp$2, d); if (_tmp$2[d] === 5) { _tmp = (d + 1 | 0) === self.digits_num; } else { _tmp = false; } if (_tmp) { if (self.truncated) { return true; } let _tmp$3; if (d > 0) { const _tmp$4 = self.digits; const _tmp$5 = d - 1 | 0; $bound_check(_tmp$4, _tmp$5); _tmp$3 = (_tmp$4[_tmp$5] % 2 | 0) !== 0; } else { _tmp$3 = false; } return _tmp$3; } const _tmp$3 = self.digits; $bound_check(_tmp$3, d); return _tmp$3[d] >= 5; } function _M0MPC28internal7strconv7Decimal16rounded__integer(self) { if (self.decimal_point > 20) { return 18446744073709551615n; } let _tmp = 0n; let _tmp$2 = 0; while (true) { const n = _tmp; const i = _tmp$2; if (i < self.decimal_point && i < self.digits_num) { const _tmp$3 = BigInt.asUintN(64, n * 10n); const _tmp$4 = self.digits; $bound_check(_tmp$4, i); const _p = _tmp$4[i]; _tmp = BigInt.asUintN(64, _tmp$3 + BigInt.asUintN(64, BigInt(_p))); _tmp$2 = i + 1 | 0; continue; } else { let n$2; let _tmp$3 = n; let _tmp$4 = i; while (true) { const n$3 = _tmp$3; const i$2 = _tmp$4; if (i$2 < self.decimal_point) { _tmp$3 = BigInt.asUintN(64, n$3 * 10n); _tmp$4 = i$2 + 1 | 0; continue; } else { n$2 = n$3; break; } } return _M0MPC28internal7strconv7Decimal17should__round__up(self, self.decimal_point) ? BigInt.asUintN(64, n$2 + 1n) : n$2; } } } function _M0MPC28internal7strconv7Decimal11new__digits(self, s) { $bound_check(_M0FPC28internal7strconv19left__shift__cheats, s); const new_digits = _M0FPC28internal7strconv19left__shift__cheats[s]._0; $bound_check(_M0FPC28internal7strconv19left__shift__cheats, s); const cheat_num = _M0FPC28internal7strconv19left__shift__cheats[s]._1; const _bind = _M0MPC16string6String11code__units(cheat_num); const _bind$2 = _bind.end - _bind.start | 0; let less; let _tmp = 0; while (true) { const i = _tmp; if (i < _bind$2) { const code_unit = _bind.buf[_bind.start + i | 0]; if (i >= self.digits_num) { less = true; break; } const d = code_unit - 48 | 0; const _tmp$2 = self.digits; $bound_check(_tmp$2, i); if (_tmp$2[i] !== d) { const _tmp$3 = self.digits; $bound_check(_tmp$3, i); less = _tmp$3[i] < d; break; } _tmp = i + 1 | 0; continue; } else { less = false; break; } } return less ? new_digits - 1 | 0 : new_digits; } function _M0MPC28internal7strconv7Decimal11left__shift(self, s) { const new_digits = _M0MPC28internal7strconv7Decimal11new__digits(self, s); let read_index = self.digits_num; let write_index = self.digits_num + new_digits | 0; let acc = 0n; read_index = read_index - 1 | 0; while (true) { if (read_index >= 0) { const _tmp = self.digits; const _tmp$2 = read_index; $bound_check(_tmp, _tmp$2); const _p = _tmp[_tmp$2]; const d = BigInt.asUintN(64, BigInt(_p)); acc = BigInt.asUintN(64, acc + BigInt.asUintN(64, d << BigInt(s & 63))); if (10n === 0n) { $panic(); } const quo = BigInt.asUintN(64, BigInt.asIntN(64, acc) / BigInt.asIntN(64, 10n)); const rem = Number(BigInt.asIntN(32, BigInt.asUintN(64, acc - BigInt.asUintN(64, quo * 10n)))) | 0; write_index = write_index - 1 | 0; if (write_index < self.digits.length) { const _tmp$3 = self.digits; const _tmp$4 = write_index; $bound_check(_tmp$3, _tmp$4); _tmp$3[_tmp$4] = rem & 255; } else { if (rem !== 0) { self.truncated = true; } } acc = quo; read_index = read_index - 1 | 0; continue; } else { break; } } while (true) { if (BigInt.asIntN(64, acc) > BigInt.asIntN(64, 0n)) { if (10n === 0n) { $panic(); } const quo = BigInt.asUintN(64, BigInt.asIntN(64, acc) / BigInt.asIntN(64, 10n)); const rem = Number(BigInt.asIntN(32, BigInt.asUintN(64, acc - BigInt.asUintN(64, 10n * quo)))) | 0; write_index = write_index - 1 | 0; if (write_index < self.digits.length) { const _tmp = self.digits; const _tmp$2 = write_index; $bound_check(_tmp, _tmp$2); _tmp[_tmp$2] = rem & 255; } else { if (rem !== 0) { self.truncated = true; } } acc = quo; continue; } else { break; } } self.digits_num = self.digits_num + new_digits | 0; if (self.digits_num > self.digits.length) { self.digits_num = self.digits.length; } self.decimal_point = self.decimal_point + new_digits | 0; _M0MPC28internal7strconv7Decimal4trim(self); } function _M0MPC28internal7strconv7Decimal12right__shift(self, s) { let read_index = 0; let write_index = 0; let acc = 0n; while (true) { if (BigInt.asUintN(64, BigInt.asUintN(64, BigInt.asUintN(64, acc) >> BigInt(s & 63))) === BigInt.asUintN(64, 0n)) { if (read_index >= self.digits_num) { while (true) { if (BigInt.asUintN(64, BigInt.asUintN(64, BigInt.asUintN(64, acc) >> BigInt(s & 63))) === BigInt.asUintN(64, 0n)) { acc = BigInt.asUintN(64, acc * 10n); read_index = read_index + 1 | 0; continue; } else { break; } } break; } const _tmp = self.digits; const _tmp$2 = read_index; $bound_check(_tmp, _tmp$2); const d = _tmp[_tmp$2]; acc = BigInt.asUintN(64, BigInt.asUintN(64, acc * 10n) + BigInt.asUintN(64, BigInt(d))); read_index = read_index + 1 | 0; continue; } else { break; } } self.decimal_point = self.decimal_point - (read_index - 1 | 0) | 0; const mask = BigInt.asUintN(64, BigInt.asUintN(64, 1n << BigInt(s & 63)) - 1n); while (true) { if (read_index < self.digits_num) { const out = BigInt.asUintN(64, BigInt.asUintN(64, acc) >> BigInt(s & 63)); const _tmp = self.digits; const _tmp$2 = write_index; $bound_check(_tmp, _tmp$2); _tmp[_tmp$2] = (Number(BigInt.asIntN(32, out)) | 0) & 255; write_index = write_index + 1 | 0; acc = BigInt.asUintN(64, acc & mask); const _tmp$3 = self.digits; const _tmp$4 = read_index; $bound_check(_tmp$3, _tmp$4); const d = _tmp$3[_tmp$4]; acc = BigInt.asUintN(64, BigInt.asUintN(64, acc * 10n) + BigInt.asUintN(64, BigInt(d))); read_index = read_index + 1 | 0; continue; } else { break; } } while (true) { if (BigInt.asUintN(64, acc) > BigInt.asUintN(64, 0n)) { const out = BigInt.asUintN(64, BigInt.asUintN(64, acc) >> BigInt(s & 63)); if (write_index < self.digits.length) { const _tmp = self.digits; const _tmp$2 = write_index; $bound_check(_tmp, _tmp$2); _tmp[_tmp$2] = (Number(BigInt.asIntN(32, out)) | 0) & 255; write_index = write_index + 1 | 0; } else { if (BigInt.asUintN(64, out) > BigInt.asUintN(64, 0n)) { self.truncated = true; } } acc = BigInt.asUintN(64, acc & mask); acc = BigInt.asUintN(64, acc * 10n); continue; } else { break; } } self.digits_num = write_index; _M0MPC28internal7strconv7Decimal4trim(self); } function _M0MPC28internal7strconv7Decimal11shift__priv(self, s) { if (self.digits_num === 0) { return undefined; } let s$2 = s; if (s$2 > 0) { while (true) { if (s$2 > 59) { _M0MPC28internal7strconv7Decimal11left__shift(self, 59); s$2 = s$2 - 59 | 0; continue; } else { break; } } _M0MPC28internal7strconv7Decimal11left__shift(self, s$2); } if (s$2 < 0) { while (true) { if (s$2 < -59) { _M0MPC28internal7strconv7Decimal12right__shift(self, 59); s$2 = s$2 + 59 | 0; continue; } else { break; } } _M0MPC28internal7strconv7Decimal12right__shift(self, -s$2 | 0); return; } else { return; } } function _M0MPC28internal7strconv7Decimal16to__double__priv(self) { let exponent = 0; let mantissa = 0n; if (self.digits_num === 0 || self.decimal_point < -330) { mantissa = 0n; exponent = _M0FPC28internal7strconv12double__info.bias; const bits = _M0FPC28internal7strconv14assemble__bits(mantissa, exponent, self.negative); return new _M0DTPC16result6ResultGdRPC15error5ErrorE2Ok($i64_reinterpret_f64(bits)); } if (self.decimal_point > 310) { const _bind = _M0FPC28internal7strconv10range__errGuE(); if (_bind.$tag === 1) { const _ok = _bind; _ok._0; } else { return _bind; } } while (true) { if (self.decimal_point > 0) { let n = 0; if (self.decimal_point >= _M0FPC28internal7strconv6powtab.length) { n = 60; } else { const _p = self.decimal_point; $bound_check(_M0FPC28internal7strconv6powtab, _p); n = _M0FPC28internal7strconv6powtab[_p]; } _M0MPC28internal7strconv7Decimal11shift__priv(self, -n | 0); exponent = exponent + n | 0; continue; } else { break; } } while (true) { let _tmp; if (self.decimal_point < 0) { _tmp = true; } else { let _tmp$2; if (self.decimal_point === 0) { const _tmp$3 = self.digits; $bound_check(_tmp$3, 0); _tmp$2 = _tmp$3[0] < 5; } else { _tmp$2 = false; } _tmp = _tmp$2; } if (_tmp) { let n = 0; if ((-self.decimal_point | 0) >= _M0FPC28internal7strconv6powtab.length) { n = 60; } else { const _p = -self.decimal_point | 0; $bound_check(_M0FPC28internal7strconv6powtab, _p); n = _M0FPC28internal7strconv6powtab[_p]; } _M0MPC28internal7strconv7Decimal11shift__priv(self, n); exponent = exponent - n | 0; continue; } else { break; } } exponent = exponent - 1 | 0; if (exponent < (_M0FPC28internal7strconv12double__info.bias + 1 | 0)) { const n = (_M0FPC28internal7strconv12double__info.bias + 1 | 0) - exponent | 0; _M0MPC28internal7strconv7Decimal11shift__priv(self, -n | 0); exponent = exponent + n | 0; } if ((exponent - _M0FPC28internal7strconv12double__info.bias | 0) >= ((1 << _M0FPC28internal7strconv12double__info.exponent_bits) - 1 | 0)) { const _bind = _M0FPC28internal7strconv10range__errGuE(); if (_bind.$tag === 1) { const _ok = _bind; _ok._0; } else { return _bind; } } _M0MPC28internal7strconv7Decimal11shift__priv(self, _M0FPC28internal7strconv12double__info.mantissa_bits + 1 | 0); mantissa = _M0MPC28internal7strconv7Decimal16rounded__integer(self); if (BigInt.asUintN(64, mantissa) === BigInt.asUintN(64, BigInt.asUintN(64, 2n << BigInt(_M0FPC28internal7strconv12double__info.mantissa_bits & 63)))) { mantissa = BigInt.asUintN(64, BigInt.asIntN(64, mantissa) >> BigInt(1 & 63)); exponent = exponent + 1 | 0; if ((exponent - _M0FPC28internal7strconv12double__info.bias | 0) >= ((1 << _M0FPC28internal7strconv12double__info.exponent_bits) - 1 | 0)) { const _bind = _M0FPC28internal7strconv10range__errGuE(); if (_bind.$tag === 1) { const _ok = _bind; _ok._0; } else { return _bind; } } } if (BigInt.asUintN(64, BigInt.asUintN(64, mantissa & BigInt.asUintN(64, 1n << BigInt(_M0FPC28internal7strconv12double__info.mantissa_bits & 63)))) === BigInt.asUintN(64, 0n)) { exponent = _M0FPC28internal7strconv12double__info.bias; } const bits = _M0FPC28internal7strconv14assemble__bits(mantissa, exponent, self.negative); return new _M0DTPC16result6ResultGdRPC15error5ErrorE2Ok($i64_reinterpret_f64(bits)); } function _M0FPC28internal7strconv17pow10__fast__path(exponent) { const _p = exponent & 31; $bound_check(_M0FPC28internal7strconv5table, _p); return _M0FPC28internal7strconv5table[_p]; } function _M0MPC28internal7strconv6Number14is__fast__path(self) { return BigInt.asIntN(64, _M0FPC28internal7strconv25min__exponent__fast__path) <= BigInt.asIntN(64, self.exponent) && (BigInt.asIntN(64, self.exponent) <= BigInt.asIntN(64, _M0FPC28internal7strconv36max__exponent__disguised__fast__path) && (BigInt.asUintN(64, self.mantissa) <= BigInt.asUintN(64, _M0FPC28internal7strconv25max__mantissa__fast__path) && !self.many_digits)); } function _M0MPC28internal7strconv6Number15try__fast__path(self) { if (_M0MPC28internal7strconv6Number14is__fast__path(self)) { let value; if (BigInt.asIntN(64, self.exponent) <= BigInt.asIntN(64, _M0FPC28internal7strconv25max__exponent__fast__path)) { const value$2 = $f64_convert_i64_u(BigInt.asUintN(64, self.mantissa)); value = BigInt.asIntN(64, self.exponent) < BigInt.asIntN(64, 0n) ? value$2 / _M0FPC28internal7strconv17pow10__fast__path(-(Number(BigInt.asIntN(32, self.exponent)) | 0) | 0) : value$2 * _M0FPC28internal7strconv17pow10__fast__path(Number(BigInt.asIntN(32, self.exponent)) | 0); } else { const shift = BigInt.asUintN(64, self.exponent - _M0FPC28internal7strconv25max__exponent__fast__path); const _tmp = self.mantissa; const _p = Number(BigInt.asIntN(32, shift)) | 0; $bound_check(_M0FPC28internal7strconv10int__pow10, _p); const _bind = _M0FPC28internal7strconv12checked__mul(_tmp, _M0FPC28internal7strconv10int__pow10[_p]); let mantissa; if (_bind === undefined) { return _M0DTPC16option6OptionGdE4None__; } else { const _Some = _bind; mantissa = _Some; } if (BigInt.asUintN(64, mantissa) > BigInt.asUintN(64, _M0FPC28internal7strconv25max__mantissa__fast__path)) { return _M0DTPC16option6OptionGdE4None__; } value = $f64_convert_i64_u(BigInt.asUintN(64, mantissa)) * _M0FPC28internal7strconv17pow10__fast__path(Number(BigInt.asIntN(32, _M0FPC28internal7strconv25max__exponent__fast__path)) | 0); } if (self.negative) { value = -value; } return new _M0DTPC16option6OptionGdE4Some(value); } else { return _M0DTPC16option6OptionGdE4None__; } } function _M0FPC28internal7strconv13parse__double(str) { if ((str.end - str.start | 0) > 0) { if (_M0FPC28internal7strconv17check__underscore(str)) { const _bind = _M0FPC28internal7strconv13parse__number(str); let _bind$2; if (_bind.$tag === 1) { const _ok = _bind; _bind$2 = _ok._0; } else { return _bind; } if (_bind$2 === undefined) { return _M0FPC28internal7strconv15parse__inf__nan(str); } else { const _Some = _bind$2; const _num = _Some; const _bind$3 = _M0MPC28internal7strconv6Number15try__fast__path(_num); if (_bind$3.$tag === 1) { const _Some$2 = _bind$3; const _value = _Some$2._0; return new _M0DTPC16result6ResultGdRPC15error5ErrorE2Ok(_value); } else { const _bind$4 = _M0FPC28internal7strconv20parse__decimal__priv(str); let _tmp; if (_bind$4.$tag === 1) { const _ok = _bind$4; _tmp = _ok._0; } else { return _bind$4; } return _M0MPC28internal7strconv7Decimal16to__double__priv(_tmp); } } } else { return _M0FPC28internal7strconv11syntax__errGdE(); } } else { return _M0FPC28internal7strconv11syntax__errGdE(); } } function _M0MPC16buffer6Buffer19grow__if__necessary(self, required) { const start = self.data.length <= 0 ? 1 : self.data.length; let enough_space; let _tmp = start; while (true) { const space = _tmp; if (space >= required) { enough_space = space; break; } _tmp = Math.imul(space, 2) | 0; continue; } if (enough_space !== self.data.length) { const new_data = _M0MPC15array10FixedArray23make__and__blit_2einnerGyE(self.data, enough_space, 0, self.len, 0, 0); self.data = new_data; return; } else { return; } } function _M0MPC16buffer6Buffer11write__byte(self, value) { _M0MPC16buffer6Buffer19grow__if__necessary(self, self.len + 1 | 0); const _tmp = self.data; const _tmp$2 = self.len; $bound_check(_tmp, _tmp$2); _tmp[_tmp$2] = value; self.len = self.len + 1 | 0; } function _M0MPC16buffer6Buffer9to__bytes(self) { return _M0MPC15bytes5Bytes11from__array(_M0MPC15array10FixedArray12view_2einnerGyE(self.data, 0, self.len)); } function _M0MPC16buffer6Buffer14Buffer_2einner(size_hint) { const initial = size_hint < 1 ? 1 : size_hint; const data = $makebytes(initial, 0); return new _M0TPC16buffer6Buffer(data, 0); } function _M0MPC16buffer6Buffer16write__bytesview(self, value) { const val_len = value.end - value.start | 0; _M0MPC16buffer6Buffer19grow__if__necessary(self, self.len + val_len | 0); _M0MPC15array10FixedArray17blit__from__bytes(self.data, self.len, value.bytes, value.start, value.end - value.start | 0); self.len = self.len + val_len | 0; } function _M0MPC16buffer6Buffer12write__bytes(self, value) { _M0MPC16buffer6Buffer16write__bytesview(self, value); } function _M0FPC16buffer11new_2einner(size_hint) { return _M0MPC16buffer6Buffer14Buffer_2einner(size_hint); } function _M0IPC16buffer6BufferPB6Logger11write__char(self, value) { _M0MPC16buffer6Buffer19grow__if__necessary(self, self.len + 4 | 0); const inc = _M0MPC15array10FixedArray18set__utf16le__char(self.data, self.len, value); self.len = self.len + inc | 0; } function _M0FPC14json20offset__to__position(input, offset) { const _bind = _M0MPC15array9ArrayView12view_2einnerGkE(_M0MPC16string10StringView11code__units(input), 0, offset); const _bind$2 = _bind.end - _bind.start | 0; let _tmp = 0; let _tmp$2 = 1; let _tmp$3 = 0; while (true) { const _ = _tmp; const line = _tmp$2; const column = _tmp$3; if (_ < _bind$2) { const code_unit = _bind.buf[_bind.start + _ | 0]; const _p = 10; if (code_unit === _p) { _tmp = _ + 1 | 0; _tmp$2 = line + 1 | 0; _tmp$3 = 0; continue; } else { _tmp = _ + 1 | 0; _tmp$3 = column + 1 | 0; continue; } } else { return new _M0TPC14json8Position(line, column); } } } function _M0MPC14json12ParseContext21invalid__char_2einnerGRPB4JsonE(ctx, shift) { const offset = ctx.offset + shift | 0; const _p = _M0MPC16string10StringView9get__char(ctx.input, offset); const _p$2 = 65533; return new _M0DTPC16result6ResultGRPB4JsonRPC14json10ParseErrorE3Err(new _M0DTPC15error5Error52moonbitlang_2fcore_2fjson_2eParseError_2eInvalidChar(_M0FPC14json20offset__to__position(ctx.input, offset), _p === -1 ? _p$2 : _p)); } function _M0MPC14json12ParseContext21invalid__char_2einnerGuE(ctx, shift) { const offset = ctx.offset + shift | 0; const _p = _M0MPC16string10StringView9get__char(ctx.input, offset); const _p$2 = 65533; return new _M0DTPC16result6ResultGuRPC14json10ParseErrorE3Err(new _M0DTPC15error5Error52moonbitlang_2fcore_2fjson_2eParseError_2eInvalidChar(_M0FPC14json20offset__to__position(ctx.input, offset), _p === -1 ? _p$2 : _p)); } function _M0IPC14json4JsonPB4Show6output(self, logger) { switch (self.$tag) { case 0: { logger.method_table.method_0(logger.self, "Null"); return; } case 1: { logger.method_table.method_0(logger.self, "True"); return; } case 2: { logger.method_table.method_0(logger.self, "False"); return; } case 3: { const _Number = self; const _n = _Number._0; const _repr = _Number._1; logger.method_table.method_0(logger.self, "Number("); _M0IP016_24default__implPB4Show6outputGdE(_n, logger); if (_repr === undefined) { } else { const _Some = _repr; const _repr$2 = _Some; logger.method_table.method_0(logger.self, ", repr="); logger.method_table.method_0(logger.self, "Some("); _M0IP016_24default__implPB4Show6outputGsE(_repr$2, logger); logger.method_table.method_0(logger.self, ")"); } logger.method_table.method_0(logger.self, ")"); return; } case 4: { const _String = self; const _s = _String._0; logger.method_table.method_0(logger.self, "String("); _M0IP016_24default__implPB4Show6outputGsE(_s, logger); logger.method_table.method_0(logger.self, ")"); return; } case 5: { const _Array = self; const _a = _Array._0; logger.method_table.method_0(logger.self, "Array("); _M0IPC15array5ArrayPB4Show6outputGRPB4JsonE(_a, logger); logger.method_table.method_0(logger.self, ")"); return; } default: { const _Object = self; const _o = _Object._0; logger.method_table.method_0(logger.self, "Object("); _M0IPB3MapPB4Show6outputGsRPB4JsonE(_o, logger); logger.method_table.method_0(logger.self, ")"); return; } } } function _M0MPC14json12ParseContext21lex__skip__whitespace(ctx) { const end = ctx.end_offset; let _tmp; let _tmp$2 = ctx.offset; while (true) { const offset = _tmp$2; if (offset >= end) { _tmp = offset; break; } const _p = ctx.input; const c = _p.str.charCodeAt(_p.start + offset | 0); let _tmp$3; const _p$2 = 32; if (c === _p$2) { _tmp$3 = true; } else { let _tmp$4; const _p$3 = 9; if (c === _p$3) { _tmp$4 = true; } else { let _tmp$5; const _p$4 = 13; if (c === _p$4) { _tmp$5 = true; } else { const _p$5 = 10; _tmp$5 = c === _p$5; } _tmp$4 = _tmp$5; } _tmp$3 = _tmp$4; } if (_tmp$3) { _tmp$2 = offset + 1 | 0; continue; } else { _tmp = offset; break; } } ctx.offset = _tmp; } function _M0MPC14json12ParseContext4make(input, max_nesting_depth) { return new _M0TPC14json12ParseContext(0, input, input.end - input.start | 0, max_nesting_depth); } function _M0MPC14json12ParseContext19expect__ascii__char(ctx, c) { if (ctx.offset < ctx.end_offset) { const _p = ctx.input; const _p$2 = ctx.offset; const c1 = _p.str.charCodeAt(_p.start + _p$2 | 0); ctx.offset = ctx.offset + 1 | 0; return c !== c1 ? _M0MPC14json12ParseContext21invalid__char_2einnerGuE(ctx, -1) : new _M0DTPC16result6ResultGuRPC14json10ParseErrorE2Ok(undefined); } else { return new _M0DTPC16result6ResultGuRPC14json10ParseErrorE3Err(_M0DTPC15error5Error51moonbitlang_2fcore_2fjson_2eParseError_2eInvalidEof__); } } function _M0FPC14json12checked__mul(a, b) { if (BigInt.asUintN(64, a) === BigInt.asUintN(64, 0n) || BigInt.asUintN(64, b) === BigInt.asUintN(64, 0n)) { return _M0FPC14json12checked__mulN6constrS1761; } if (BigInt.asUintN(64, a) === BigInt.asUintN(64, 1n)) { return b; } if (BigInt.asUintN(64, b) === BigInt.asUintN(64, 1n)) { return a; } if ($i64_clz(b) === 0 || $i64_clz(a) === 0) { return undefined; } if (b === 0n) { $panic(); } const quotient = BigInt.asUintN(64, BigInt.asUintN(64, 18446744073709551615n) / BigInt.asUintN(64, b)); return BigInt.asUintN(64, a) > BigInt.asUintN(64, quotient) ? undefined : BigInt.asUintN(64, a * b); } function _M0FPC14json23json__pow10__fast__path(exponent) { const _p = exponent & 31; $bound_check(_M0FPC14json12pow10__table, _p); return _M0FPC14json12pow10__table[_p]; } function _M0MPC14json14JsonNumberScan17try__fast__double(self) { if (BigInt.asUintN(64, self.mantissa) === BigInt.asUintN(64, 0n)) { return self.negative ? -0 : 0; } if (self.many_digits || (BigInt.asIntN(64, self.exponent) < BigInt.asIntN(64, 18446744073709551594n) || (BigInt.asIntN(64, self.exponent) > BigInt.asIntN(64, 37n) || BigInt.asUintN(64, self.mantissa) > BigInt.asUintN(64, 9007199254740992n)))) { return _M0FPC16double14not__a__number; } let value; if (BigInt.asIntN(64, self.exponent) <= BigInt.asIntN(64, 22n)) { const value$2 = $f64_convert_i64_u(BigInt.asUintN(64, self.mantissa)); value = BigInt.asIntN(64, self.exponent) < BigInt.asIntN(64, 0n) ? value$2 / _M0FPC14json23json__pow10__fast__path(-(Number(BigInt.asIntN(32, self.exponent)) | 0) | 0) : value$2 * _M0FPC14json23json__pow10__fast__path(Number(BigInt.asIntN(32, self.exponent)) | 0); } else { const shift = BigInt.asUintN(64, self.exponent - 22n); const _tmp = self.mantissa; const _p = Number(BigInt.asIntN(32, shift)) | 0; $bound_check(_M0FPC14json17int__pow10__table, _p); const _bind = _M0FPC14json12checked__mul(_tmp, _M0FPC14json17int__pow10__table[_p]); let mantissa; if (_bind === undefined) { return _M0FPC16double14not__a__number; } else { const _Some = _bind; mantissa = _Some; } if (BigInt.asUintN(64, mantissa) > BigInt.asUintN(64, 9007199254740992n)) { return _M0FPC16double14not__a__number; } value = $f64_convert_i64_u(BigInt.asUintN(64, mantissa)) * _M0FPC14json23json__pow10__fast__path(22); } return self.negative ? -value : value; } function _M0MPC14json12ParseContext17lex__integer__end(ctx, start, end) { const _p = ctx.input; const _p$2 = _p.str.charCodeAt(_p.start + start | 0); const _p$3 = 45; const negative = _p$2 === _p$3; const number_start = negative ? start + 1 | 0 : start; let _tmp = number_start; let _tmp$2 = 0n; while (true) { const i = _tmp; const acc = _tmp$2; if (i >= end) { const value = negative ? BigInt.asUintN(64, -acc) : acc; return { _0: $f64_convert_i64(BigInt.asIntN(64, value)), _1: undefined }; } const _p$4 = ctx.input; const digit = BigInt.asUintN(64, BigInt(_p$4.str.charCodeAt(_p$4.start + i | 0) - 48 | 0)); if (10n === 0n) { $panic(); } if (BigInt.asIntN(64, acc) > BigInt.asIntN(64, BigInt.asUintN(64, BigInt.asIntN(64, BigInt.asUintN(64, 9007199254740991n - digit)) / BigInt.asIntN(64, 10n)))) { const s = _M0MPC16string10StringView12view_2einner(ctx.input, start, end); return negative ? { _0: _M0FPC16double13neg__infinity, _1: s } : { _0: _M0FPC16double8infinity, _1: s }; } _tmp = i + 1 | 0; _tmp$2 = BigInt.asUintN(64, BigInt.asUintN(64, acc * 10n) + digit); continue; } } function _M0MPC14json12ParseContext18scan__json__number(ctx, start, end) { const _p = ctx.input; const _p$2 = _p.str.charCodeAt(_p.start + start | 0); const _p$3 = 45; const negative = _p$2 === _p$3; let has_decimal = false; let has_exponent = false; let exponent_negative = false; let exponent_part = 0n; let fractional_digits = 0; let mantissa = 0n; let significant_digits = 0; let seen_nonzero = false; let _tmp = negative ? start + 1 | 0 : start; while (true) { const i = _tmp; if (i < end) { const _p$4 = ctx.input; const c = _p$4.str.charCodeAt(_p$4.start + i | 0); if (c >= 48 && c <= 57) { const digit = c - 48 | 0; if (has_exponent) { if (BigInt.asIntN(64, exponent_part) < BigInt.asIntN(64, 100000n)) { const next_exponent = BigInt.asUintN(64, BigInt.asUintN(64, exponent_part * 10n) + BigInt.asUintN(64, BigInt(digit))); exponent_part = BigInt.asIntN(64, next_exponent) > BigInt.asIntN(64, 100000n) ? 100000n : next_exponent; } } else { if (has_decimal) { fractional_digits = fractional_digits + 1 | 0; } if (digit !== 0 || seen_nonzero) { seen_nonzero = true; significant_digits = significant_digits + 1 | 0; if (significant_digits <= 19) { mantissa = BigInt.asUintN(64, BigInt.asUintN(64, mantissa * 10n) + BigInt.asUintN(64, BigInt(digit >>> 0))); } } } } else { const _p$5 = 46; if (c === _p$5) { has_decimal = true; } else { let _tmp$2; const _p$6 = 101; if (c === _p$6) { _tmp$2 = true; } else { const _p$7 = 69; _tmp$2 = c === _p$7; } if (_tmp$2) { has_exponent = true; if ((i + 1 | 0) < end) { const _p$7 = ctx.input; const _p$8 = i + 1 | 0; const next = _p$7.str.charCodeAt(_p$7.start + _p$8 | 0); const _p$9 = 45; if (next === _p$9) { exponent_negative = true; } } } } } _tmp = i + 1 | 0; continue; } else { break; } } const exponent_part$2 = exponent_negative ? BigInt.asUintN(64, -exponent_part) : exponent_part; return new _M0TPC14json14JsonNumberScan(negative, !has_decimal && !has_exponent, mantissa, BigInt.asUintN(64, exponent_part$2 - BigInt.asUintN(64, BigInt(fractional_digits))), significant_digits > 19); } function _M0MPC14json12ParseContext16lex__number__end(ctx, start, end) { const scan = _M0MPC14json12ParseContext18scan__json__number(ctx, start, end); if (scan.is_integer) { if (!scan.many_digits && (BigInt.asUintN(64, scan.exponent) === BigInt.asUintN(64, 0n) && BigInt.asUintN(64, scan.mantissa) <= BigInt.asUintN(64, 9007199254740991n))) { const v = scan.mantissa; const signed = scan.negative ? BigInt.asUintN(64, -v) : v; return { _0: $f64_convert_i64(BigInt.asIntN(64, signed)), _1: undefined }; } return _M0MPC14json12ParseContext17lex__integer__end(ctx, start, end); } const fast = _M0MPC14json14JsonNumberScan17try__fast__double(scan); if (!(fast !== fast)) { return { _0: fast, _1: undefined }; } const s = _M0MPC16string10StringView12view_2einner(ctx.input, start, end); let _try_err; _L: { const _bind = _M0FPC28internal7strconv13parse__double(s); let d; if (_bind.$tag === 1) { const _ok = _bind; d = _ok._0; } else { const _err = _bind; _try_err = _err._0; break _L; } return { _0: d, _1: undefined }; } return scan.negative ? { _0: _M0FPC16double13neg__infinity, _1: s } : { _0: _M0FPC16double8infinity, _1: s }; } function _M0MPC14json12ParseContext10read__char(ctx) { if (ctx.offset < ctx.end_offset) { const _p = ctx.input; const _p$2 = ctx.offset; const c1 = _p.str.charCodeAt(_p.start + _p$2 | 0); ctx.offset = ctx.offset + 1 | 0; if (c1 >= 55296 && c1 <= 56319) { if (ctx.offset < ctx.end_offset) { const _p$3 = ctx.input; const _p$4 = ctx.offset; const c2 = _p$3.str.charCodeAt(_p$3.start + _p$4 | 0); if (c2 >= 56320 && c2 <= 57343) { ctx.offset = ctx.offset + 1 | 0; const c3 = ((c1 << 10) + c2 | 0) - 56613888 | 0; return c3; } } } return c1; } else { return -1; } } function _M0MPC14json12ParseContext31lex__decimal__exponent__integer(ctx, start) { while (true) { const _bind = _M0MPC14json12ParseContext10read__char(ctx); if (_bind === -1) { return _M0MPC14json12ParseContext16lex__number__end(ctx, start, ctx.offset); } else { const _Some = _bind; const _c = _Some; if (_c >= 48 && _c <= 57) { continue; } ctx.offset = ctx.offset - 1 | 0; return _M0MPC14json12ParseContext16lex__number__end(ctx, start, ctx.offset); } } } function _M0MPC14json12ParseContext28lex__decimal__exponent__sign(ctx, start) { const _bind = _M0MPC14json12ParseContext10read__char(ctx); if (_bind === -1) { return new _M0DTPC16result6ResultGUdORPC16string10StringViewERPC14json10ParseErrorE3Err(_M0DTPC15error5Error51moonbitlang_2fcore_2fjson_2eParseError_2eInvalidEof__); } else { const _Some = _bind; const _c = _Some; if (_c >= 48 && _c <= 57) { return new _M0DTPC16result6ResultGUdORPC16string10StringViewERPC14json10ParseErrorE2Ok(_M0MPC14json12ParseContext31lex__decimal__exponent__integer(ctx, start)); } ctx.offset = ctx.offset - 1 | 0; return _M0MPC14json12ParseContext21invalid__char_2einnerGRPB4JsonE(ctx, 0); } } function _M0MPC14json12ParseContext22lex__decimal__exponent(ctx, start) { _L: { const _bind = _M0MPC14json12ParseContext10read__char(ctx); if (_bind === -1) { return new _M0DTPC16result6ResultGUdORPC16string10StringViewERPC14json10ParseErrorE3Err(_M0DTPC15error5Error51moonbitlang_2fcore_2fjson_2eParseError_2eInvalidEof__); } else { const _Some = _bind; const _x = _Some; switch (_x) { case 43: { break _L; } case 45: { break _L; } default: { if (_x >= 48 && _x <= 57) { return new _M0DTPC16result6ResultGUdORPC16string10StringViewERPC14json10ParseErrorE2Ok(_M0MPC14json12ParseContext31lex__decimal__exponent__integer(ctx, start)); } ctx.offset = ctx.offset - 1 | 0; return _M0MPC14json12ParseContext21invalid__char_2einnerGRPB4JsonE(ctx, 0); } } } } const _bind = _M0MPC14json12ParseContext28lex__decimal__exponent__sign(ctx, start); let _tmp; if (_bind.$tag === 1) { const _ok = _bind; _tmp = _ok._0; } else { return _bind; } return new _M0DTPC16result6ResultGUdORPC16string10StringViewERPC14json10ParseErrorE2Ok(_tmp); } function _M0MPC14json12ParseContext22lex__decimal__fraction(ctx, start) { let _tmp; _L: while (true) { _L$2: { const _bind = _M0MPC14json12ParseContext10read__char(ctx); if (_bind === -1) { return new _M0DTPC16result6ResultGUdORPC16string10StringViewERPC14json10ParseErrorE2Ok(_M0MPC14json12ParseContext16lex__number__end(ctx, start, ctx.offset)); } else { const _Some = _bind; const _x = _Some; switch (_x) { case 101: { break _L$2; } case 69: { break _L$2; } default: { if (_x >= 48 && _x <= 57) { continue _L; } ctx.offset = ctx.offset - 1 | 0; return new _M0DTPC16result6ResultGUdORPC16string10StringViewERPC14json10ParseErrorE2Ok(_M0MPC14json12ParseContext16lex__number__end(ctx, start, ctx.offset)); } } } } const _bind = _M0MPC14json12ParseContext22lex__decimal__exponent(ctx, start); let _tmp$2; if (_bind.$tag === 1) { const _ok = _bind; _tmp$2 = _ok._0; } else { return _bind; } return new _M0DTPC16result6ResultGUdORPC16string10StringViewERPC14json10ParseErrorE2Ok(_tmp$2); } return new _M0DTPC16result6ResultGUdORPC16string10StringViewERPC14json10ParseErrorE2Ok(_tmp); } function _M0MPC14json12ParseContext19lex__decimal__point(ctx, start) { const _bind = _M0MPC14json12ParseContext10read__char(ctx); if (_bind === -1) { return new _M0DTPC16result6ResultGUdORPC16string10StringViewERPC14json10ParseErrorE3Err(_M0DTPC15error5Error51moonbitlang_2fcore_2fjson_2eParseError_2eInvalidEof__); } else { const _Some = _bind; const _c = _Some; return _c >= 48 && _c <= 57 ? _M0MPC14json12ParseContext22lex__decimal__fraction(ctx, start) : _M0MPC14json12ParseContext21invalid__char_2einnerGRPB4JsonE(ctx, -1); } } function _M0MPC14json12ParseContext21lex__decimal__integer(ctx, start) { let _tmp; _L: while (true) { _L$2: { const _bind = _M0MPC14json12ParseContext10read__char(ctx); if (_bind === -1) { return new _M0DTPC16result6ResultGUdORPC16string10StringViewERPC14json10ParseErrorE2Ok(_M0MPC14json12ParseContext16lex__number__end(ctx, start, ctx.offset)); } else { const _Some = _bind; const _x = _Some; switch (_x) { case 46: { const _bind$2 = _M0MPC14json12ParseContext19lex__decimal__point(ctx, start); let _tmp$2; if (_bind$2.$tag === 1) { const _ok = _bind$2; _tmp$2 = _ok._0; } else { return _bind$2; } return new _M0DTPC16result6ResultGUdORPC16string10StringViewERPC14json10ParseErrorE2Ok(_tmp$2); } case 101: { break _L$2; } case 69: { break _L$2; } default: { if (_x >= 48 && _x <= 57) { continue _L; } ctx.offset = ctx.offset - 1 | 0; return new _M0DTPC16result6ResultGUdORPC16string10StringViewERPC14json10ParseErrorE2Ok(_M0MPC14json12ParseContext16lex__number__end(ctx, start, ctx.offset)); } } } } const _bind = _M0MPC14json12ParseContext22lex__decimal__exponent(ctx, start); let _tmp$2; if (_bind.$tag === 1) { const _ok = _bind; _tmp$2 = _ok._0; } else { return _bind; } return new _M0DTPC16result6ResultGUdORPC16string10StringViewERPC14json10ParseErrorE2Ok(_tmp$2); } return new _M0DTPC16result6ResultGUdORPC16string10StringViewERPC14json10ParseErrorE2Ok(_tmp); } function _M0MPC14json12ParseContext16lex__hex__digits(ctx, n) { let _tmp; let _tmp$2 = 0; let _tmp$3 = 0; while (true) { const _ = _tmp$2; const r = _tmp$3; if (_ < n) { const _bind = _M0MPC14json12ParseContext10read__char(ctx); if (_bind === -1) { return new _M0DTPC16result6ResultGiRPC14json10ParseErrorE3Err(_M0DTPC15error5Error51moonbitlang_2fcore_2fjson_2eParseError_2eInvalidEof__); } else { const _Some = _bind; const _c = _Some; if (_c >= 65) { const d = ((_c & ~32) - 65 | 0) + 10 | 0; if (d > 15) { const _bind$2 = _M0MPC14json12ParseContext21invalid__char_2einnerGuE(ctx, -1); if (_bind$2.$tag === 1) { const _ok = _bind$2; _ok._0; } else { return _bind$2; } } _tmp$2 = _ + 1 | 0; _tmp$3 = r << 4 | d; continue; } else { if (_c >= 48) { const d = _c - 48 | 0; if (d > 9) { const _bind$2 = _M0MPC14json12ParseContext21invalid__char_2einnerGuE(ctx, -1); if (_bind$2.$tag === 1) { const _ok = _bind$2; _ok._0; } else { return _bind$2; } } _tmp$2 = _ + 1 | 0; _tmp$3 = r << 4 | d; continue; } else { const _bind$2 = _M0MPC14json12ParseContext21invalid__char_2einnerGuE(ctx, -1); if (_bind$2.$tag === 1) { const _ok = _bind$2; _ok._0; } else { return _bind$2; } } } } _tmp$2 = _ + 1 | 0; continue; } else { _tmp = r; break; } } return new _M0DTPC16result6ResultGiRPC14json10ParseErrorE2Ok(_tmp); } function _M0MPC14json12ParseContext17lex__string__slowN5flushS326(_env, end) { const ctx = _env._2; const start = _env._1; const buf = _env._0; if (start.val > 0 && end > start.val) { _M0IPB13StringBuilderPB6Logger11write__view(buf, _M0MPC16string10StringView11sub_2einner(ctx.input, start.val, end)); return; } else { return; } } function _M0MPC14json12ParseContext17lex__string__slow(ctx) { const buf = _M0MPB13StringBuilder21StringBuilder_2einner(0); const start = new _M0TPB8MutLocalGiE(ctx.offset); const _env = { _0: buf, _1: start, _2: ctx }; _L: while (true) { _L$2: { _L$3: { const _bind = _M0MPC14json12ParseContext10read__char(ctx); if (_bind === -1) { return new _M0DTPC16result6ResultGsRPC14json10ParseErrorE3Err(_M0DTPC15error5Error51moonbitlang_2fcore_2fjson_2eParseError_2eInvalidEof__); } else { const _Some = _bind; const _x = _Some; switch (_x) { case 34: { _M0MPC14json12ParseContext17lex__string__slowN5flushS326(_env, ctx.offset - 1 | 0); break _L; } case 10: { break _L$3; } case 13: { break _L$3; } case 92: { _M0MPC14json12ParseContext17lex__string__slowN5flushS326(_env, ctx.offset - 1 | 0); const _bind$2 = _M0MPC14json12ParseContext10read__char(ctx); if (_bind$2 === -1) { return new _M0DTPC16result6ResultGsRPC14json10ParseErrorE3Err(_M0DTPC15error5Error51moonbitlang_2fcore_2fjson_2eParseError_2eInvalidEof__); } else { const _Some$2 = _bind$2; const _x$2 = _Some$2; switch (_x$2) { case 98: { _M0IPB13StringBuilderPB6Logger11write__char(buf, 8); break; } case 102: { _M0IPB13StringBuilderPB6Logger11write__char(buf, 12); break; } case 110: { _M0IPB13StringBuilderPB6Logger11write__char(buf, 10); break; } case 114: { _M0IPB13StringBuilderPB6Logger11write__char(buf, 13); break; } case 116: { _M0IPB13StringBuilderPB6Logger11write__char(buf, 9); break; } case 34: { _M0IPB13StringBuilderPB6Logger11write__char(buf, 34); break; } case 92: { _M0IPB13StringBuilderPB6Logger11write__char(buf, 92); break; } case 47: { _M0IPB13StringBuilderPB6Logger11write__char(buf, 47); break; } case 117: { const _bind$3 = _M0MPC14json12ParseContext16lex__hex__digits(ctx, 4); let c; if (_bind$3.$tag === 1) { const _ok = _bind$3; c = _ok._0; } else { return _bind$3; } _M0IPB13StringBuilderPB6Logger11write__char(buf, c); break; } default: { const _bind$4 = _M0MPC14json12ParseContext21invalid__char_2einnerGuE(ctx, -1); if (_bind$4.$tag === 1) { const _ok = _bind$4; _ok._0; } else { return _bind$4; } } } } start.val = ctx.offset; break; } default: { if (_x < 32) { const _bind$3 = _M0MPC14json12ParseContext21invalid__char_2einnerGuE(ctx, -1); if (_bind$3.$tag === 1) { const _ok = _bind$3; _ok._0; } else { return _bind$3; } } else { continue _L; } } } } break _L$2; } const _bind = _M0MPC14json12ParseContext21invalid__char_2einnerGuE(ctx, -1); if (_bind.$tag === 1) { const _ok = _bind; _ok._0; } else { return _bind; } } continue; } return new _M0DTPC16result6ResultGsRPC14json10ParseErrorE2Ok(buf.val); } function _M0MPC14json12ParseContext11lex__string(ctx) { const string_start = ctx.offset; let _tmp = string_start; while (true) { const i = _tmp; if (i < ctx.end_offset) { const _p = ctx.input; const c = _p.str.charCodeAt(_p.start + i | 0); const _p$2 = 34; if (c === _p$2) { ctx.offset = i + 1 | 0; return new _M0DTPC16result6ResultGsRPC14json10ParseErrorE2Ok(_M0MPC16string10StringView9to__owned(_M0MPC16string10StringView12view_2einner(ctx.input, string_start, i))); } else { const _p$3 = 92; if (c === _p$3) { const _bind = _M0MPC14json12ParseContext17lex__string__slow(ctx); let _tmp$2; if (_bind.$tag === 1) { const _ok = _bind; _tmp$2 = _ok._0; } else { return _bind; } return new _M0DTPC16result6ResultGsRPC14json10ParseErrorE2Ok(_tmp$2); } else { let _tmp$2; const _p$4 = 10; if (c === _p$4) { _tmp$2 = true; } else { let _tmp$3; const _p$5 = 13; if (c === _p$5) { _tmp$3 = true; } else { _tmp$3 = _M0IP016_24default__implPB7Compare6op__ltGkE(c, 32); } _tmp$2 = _tmp$3; } if (_tmp$2) { ctx.offset = i + 1 | 0; const _bind = _M0MPC14json12ParseContext21invalid__char_2einnerGuE(ctx, -1); if (_bind.$tag === 1) { const _ok = _bind; _ok._0; } else { return _bind; } } } } _tmp = i + 1 | 0; continue; } else { break; } } return new _M0DTPC16result6ResultGsRPC14json10ParseErrorE3Err(_M0DTPC15error5Error51moonbitlang_2fcore_2fjson_2eParseError_2eInvalidEof__); } function _M0MPC14json12ParseContext9lex__zero(ctx, start) { _L: { const _bind = _M0MPC14json12ParseContext10read__char(ctx); if (_bind === -1) { return new _M0DTPC16result6ResultGUdORPC16string10StringViewERPC14json10ParseErrorE2Ok(_M0MPC14json12ParseContext16lex__number__end(ctx, start, ctx.offset)); } else { const _Some = _bind; const _x = _Some; switch (_x) { case 46: { return _M0MPC14json12ParseContext19lex__decimal__point(ctx, start); } case 101: { break _L; } case 69: { break _L; } default: { if (_x >= 48 && _x <= 57) { ctx.offset = ctx.offset - 1 | 0; const _bind$2 = _M0MPC14json12ParseContext21invalid__char_2einnerGuE(ctx, 0); if (_bind$2.$tag === 1) { const _ok = _bind$2; _ok._0; } else { return _bind$2; } } ctx.offset = ctx.offset - 1 | 0; return new _M0DTPC16result6ResultGUdORPC16string10StringViewERPC14json10ParseErrorE2Ok(_M0MPC14json12ParseContext16lex__number__end(ctx, start, ctx.offset)); } } } } return _M0MPC14json12ParseContext22lex__decimal__exponent(ctx, start); } function _M0MPC14json12ParseContext10lex__value(ctx, allow_rbracket) { _M0MPC14json12ParseContext21lex__skip__whitespace(ctx); const _bind = _M0MPC14json12ParseContext10read__char(ctx); if (_bind === -1) { return new _M0DTPC16result6ResultGRPC14json5TokenRPC14json10ParseErrorE3Err(_M0DTPC15error5Error51moonbitlang_2fcore_2fjson_2eParseError_2eInvalidEof__); } else { const _Some = _bind; const _x = _Some; if (_x === 123) { return new _M0DTPC16result6ResultGRPC14json5TokenRPC14json10ParseErrorE2Ok(_M0DTPC14json5Token6LBrace__); } else { if (_x === 91) { return new _M0DTPC16result6ResultGRPC14json5TokenRPC14json10ParseErrorE2Ok(_M0DTPC14json5Token8LBracket__); } else { if (_x === 93) { if (allow_rbracket) { return new _M0DTPC16result6ResultGRPC14json5TokenRPC14json10ParseErrorE2Ok(_M0DTPC14json5Token8RBracket__); } else { return _M0MPC14json12ParseContext21invalid__char_2einnerGRPB4JsonE(ctx, -1); } } else { if (_x === 110) { const _bind$2 = _M0MPC14json12ParseContext19expect__ascii__char(ctx, 117); if (_bind$2.$tag === 1) { const _ok = _bind$2; _ok._0; } else { return _bind$2; } const _bind$3 = _M0MPC14json12ParseContext19expect__ascii__char(ctx, 108); if (_bind$3.$tag === 1) { const _ok = _bind$3; _ok._0; } else { return _bind$3; } const _bind$4 = _M0MPC14json12ParseContext19expect__ascii__char(ctx, 108); if (_bind$4.$tag === 1) { const _ok = _bind$4; _ok._0; } else { return _bind$4; } return new _M0DTPC16result6ResultGRPC14json5TokenRPC14json10ParseErrorE2Ok(_M0DTPC14json5Token4Null__); } else { if (_x === 116) { const _bind$2 = _M0MPC14json12ParseContext19expect__ascii__char(ctx, 114); if (_bind$2.$tag === 1) { const _ok = _bind$2; _ok._0; } else { return _bind$2; } const _bind$3 = _M0MPC14json12ParseContext19expect__ascii__char(ctx, 117); if (_bind$3.$tag === 1) { const _ok = _bind$3; _ok._0; } else { return _bind$3; } const _bind$4 = _M0MPC14json12ParseContext19expect__ascii__char(ctx, 101); if (_bind$4.$tag === 1) { const _ok = _bind$4; _ok._0; } else { return _bind$4; } return new _M0DTPC16result6ResultGRPC14json5TokenRPC14json10ParseErrorE2Ok(_M0DTPC14json5Token4True__); } else { if (_x === 102) { const _bind$2 = _M0MPC14json12ParseContext19expect__ascii__char(ctx, 97); if (_bind$2.$tag === 1) { const _ok = _bind$2; _ok._0; } else { return _bind$2; } const _bind$3 = _M0MPC14json12ParseContext19expect__ascii__char(ctx, 108); if (_bind$3.$tag === 1) { const _ok = _bind$3; _ok._0; } else { return _bind$3; } const _bind$4 = _M0MPC14json12ParseContext19expect__ascii__char(ctx, 115); if (_bind$4.$tag === 1) { const _ok = _bind$4; _ok._0; } else { return _bind$4; } const _bind$5 = _M0MPC14json12ParseContext19expect__ascii__char(ctx, 101); if (_bind$5.$tag === 1) { const _ok = _bind$5; _ok._0; } else { return _bind$5; } return new _M0DTPC16result6ResultGRPC14json5TokenRPC14json10ParseErrorE2Ok(_M0DTPC14json5Token5False__); } else { if (_x === 45) { const _bind$2 = _M0MPC14json12ParseContext10read__char(ctx); if (_bind$2 === -1) { return new _M0DTPC16result6ResultGRPC14json5TokenRPC14json10ParseErrorE3Err(_M0DTPC15error5Error51moonbitlang_2fcore_2fjson_2eParseError_2eInvalidEof__); } else { const _Some$2 = _bind$2; const _x$2 = _Some$2; if (_x$2 === 48) { const _bind$3 = _M0MPC14json12ParseContext9lex__zero(ctx, ctx.offset - 2 | 0); let _bind$4; if (_bind$3.$tag === 1) { const _ok = _bind$3; _bind$4 = _ok._0; } else { return _bind$3; } const _n = _bind$4._0; const _repr = _bind$4._1; return new _M0DTPC16result6ResultGRPC14json5TokenRPC14json10ParseErrorE2Ok(new _M0DTPC14json5Token6Number(_n, _M0MPC16option6Option3mapGRPC16string10StringViewsE(_repr, (repr) => _M0MPC16string10StringView9to__owned(repr)))); } else { if (_x$2 >= 49 && _x$2 <= 57) { const _bind$3 = _M0MPC14json12ParseContext21lex__decimal__integer(ctx, ctx.offset - 2 | 0); let _bind$4; if (_bind$3.$tag === 1) { const _ok = _bind$3; _bind$4 = _ok._0; } else { return _bind$3; } const _n = _bind$4._0; const _repr = _bind$4._1; return new _M0DTPC16result6ResultGRPC14json5TokenRPC14json10ParseErrorE2Ok(new _M0DTPC14json5Token6Number(_n, _M0MPC16option6Option3mapGRPC16string10StringViewsE(_repr, (repr) => _M0MPC16string10StringView9to__owned(repr)))); } return _M0MPC14json12ParseContext21invalid__char_2einnerGRPB4JsonE(ctx, -1); } } } else { if (_x === 48) { const _bind$2 = _M0MPC14json12ParseContext9lex__zero(ctx, ctx.offset - 1 | 0); let _bind$3; if (_bind$2.$tag === 1) { const _ok = _bind$2; _bind$3 = _ok._0; } else { return _bind$2; } const _n = _bind$3._0; const _repr = _bind$3._1; return new _M0DTPC16result6ResultGRPC14json5TokenRPC14json10ParseErrorE2Ok(new _M0DTPC14json5Token6Number(_n, _M0MPC16option6Option3mapGRPC16string10StringViewsE(_repr, (repr) => _M0MPC16string10StringView9to__owned(repr)))); } else { if (_x >= 49 && _x <= 57) { const _bind$2 = _M0MPC14json12ParseContext21lex__decimal__integer(ctx, ctx.offset - 1 | 0); let _bind$3; if (_bind$2.$tag === 1) { const _ok = _bind$2; _bind$3 = _ok._0; } else { return _bind$2; } const _n = _bind$3._0; const _repr = _bind$3._1; return new _M0DTPC16result6ResultGRPC14json5TokenRPC14json10ParseErrorE2Ok(new _M0DTPC14json5Token6Number(_n, _M0MPC16option6Option3mapGRPC16string10StringViewsE(_repr, (repr) => _M0MPC16string10StringView9to__owned(repr)))); } else { if (_x === 34) { const _bind$2 = _M0MPC14json12ParseContext11lex__string(ctx); let s; if (_bind$2.$tag === 1) { const _ok = _bind$2; s = _ok._0; } else { return _bind$2; } return new _M0DTPC16result6ResultGRPC14json5TokenRPC14json10ParseErrorE2Ok(new _M0DTPC14json5Token6String(s)); } else { const _p = _x; const shift = -(_p <= 65535 ? 1 : 2) | 0; return _M0MPC14json12ParseContext21invalid__char_2einnerGRPB4JsonE(ctx, shift); } } } } } } } } } } } } function _M0MPC14json12ParseContext24lex__after__array__value(ctx) { _M0MPC14json12ParseContext21lex__skip__whitespace(ctx); const _bind = _M0MPC14json12ParseContext10read__char(ctx); if (_bind === -1) { return new _M0DTPC16result6ResultGRPC14json5TokenRPC14json10ParseErrorE3Err(_M0DTPC15error5Error51moonbitlang_2fcore_2fjson_2eParseError_2eInvalidEof__); } else { const _Some = _bind; const _x = _Some; switch (_x) { case 93: { return new _M0DTPC16result6ResultGRPC14json5TokenRPC14json10ParseErrorE2Ok(_M0DTPC14json5Token8RBracket__); } case 44: { return new _M0DTPC16result6ResultGRPC14json5TokenRPC14json10ParseErrorE2Ok(_M0DTPC14json5Token5Comma__); } default: { return _M0MPC14json12ParseContext21invalid__char_2einnerGRPB4JsonE(ctx, -1); } } } } function _M0MPC14json12ParseContext25lex__after__object__value(ctx) { _M0MPC14json12ParseContext21lex__skip__whitespace(ctx); const _bind = _M0MPC14json12ParseContext10read__char(ctx); if (_bind === -1) { return new _M0DTPC16result6ResultGRPC14json5TokenRPC14json10ParseErrorE3Err(_M0DTPC15error5Error51moonbitlang_2fcore_2fjson_2eParseError_2eInvalidEof__); } else { const _Some = _bind; const _x = _Some; switch (_x) { case 125: { return new _M0DTPC16result6ResultGRPC14json5TokenRPC14json10ParseErrorE2Ok(_M0DTPC14json5Token6RBrace__); } case 44: { return new _M0DTPC16result6ResultGRPC14json5TokenRPC14json10ParseErrorE2Ok(_M0DTPC14json5Token5Comma__); } default: { return _M0MPC14json12ParseContext21invalid__char_2einnerGRPB4JsonE(ctx, -1); } } } } function _M0MPC14json12ParseContext26lex__after__property__name(ctx) { _M0MPC14json12ParseContext21lex__skip__whitespace(ctx); const _bind = _M0MPC14json12ParseContext10read__char(ctx); if (_bind === -1) { return new _M0DTPC16result6ResultGuRPC14json10ParseErrorE3Err(_M0DTPC15error5Error51moonbitlang_2fcore_2fjson_2eParseError_2eInvalidEof__); } else { const _Some = _bind; const _x = _Some; if (_x === 58) { return new _M0DTPC16result6ResultGuRPC14json10ParseErrorE2Ok(undefined); } else { return _M0MPC14json12ParseContext21invalid__char_2einnerGuE(ctx, -1); } } } function _M0MPC14json12ParseContext19lex__property__name(ctx) { _M0MPC14json12ParseContext21lex__skip__whitespace(ctx); const _bind = _M0MPC14json12ParseContext10read__char(ctx); if (_bind === -1) { return new _M0DTPC16result6ResultGRPC14json5TokenRPC14json10ParseErrorE3Err(_M0DTPC15error5Error51moonbitlang_2fcore_2fjson_2eParseError_2eInvalidEof__); } else { const _Some = _bind; const _x = _Some; switch (_x) { case 125: { return new _M0DTPC16result6ResultGRPC14json5TokenRPC14json10ParseErrorE2Ok(_M0DTPC14json5Token6RBrace__); } case 34: { const _bind$2 = _M0MPC14json12ParseContext11lex__string(ctx); let s; if (_bind$2.$tag === 1) { const _ok = _bind$2; s = _ok._0; } else { return _bind$2; } return new _M0DTPC16result6ResultGRPC14json5TokenRPC14json10ParseErrorE2Ok(new _M0DTPC14json5Token6String(s)); } default: { return _M0MPC14json12ParseContext21invalid__char_2einnerGRPB4JsonE(ctx, -1); } } } } function _M0MPC14json12ParseContext20lex__property__name2(ctx) { _M0MPC14json12ParseContext21lex__skip__whitespace(ctx); const _bind = _M0MPC14json12ParseContext10read__char(ctx); if (_bind === -1) { return new _M0DTPC16result6ResultGRPC14json5TokenRPC14json10ParseErrorE3Err(_M0DTPC15error5Error51moonbitlang_2fcore_2fjson_2eParseError_2eInvalidEof__); } else { const _Some = _bind; const _x = _Some; if (_x === 34) { const _bind$2 = _M0MPC14json12ParseContext11lex__string(ctx); let s; if (_bind$2.$tag === 1) { const _ok = _bind$2; s = _ok._0; } else { return _bind$2; } return new _M0DTPC16result6ResultGRPC14json5TokenRPC14json10ParseErrorE2Ok(new _M0DTPC14json5Token6String(s)); } else { return _M0MPC14json12ParseContext21invalid__char_2einnerGRPB4JsonE(ctx, -1); } } } function _M0MPC14json12ParseContext12parse__value(ctx) { const _bind = _M0MPC14json12ParseContext10lex__value(ctx, false); let tok; if (_bind.$tag === 1) { const _ok = _bind; tok = _ok._0; } else { return _bind; } return _M0MPC14json12ParseContext13parse__value2(ctx, tok); } function _M0MPC14json12ParseContext13parse__value2(ctx, tok) { _L: { switch (tok.$tag) { case 0: { return new _M0DTPC16result6ResultGRPB4JsonRPC14json10ParseErrorE2Ok(_M0FPB4null); } case 1: { const _p = true; return new _M0DTPC16result6ResultGRPB4JsonRPC14json10ParseErrorE2Ok(_p ? _M0DTPB4Json4True__ : _M0DTPB4Json5False__); } case 2: { const _p$2 = false; return new _M0DTPC16result6ResultGRPB4JsonRPC14json10ParseErrorE2Ok(_p$2 ? _M0DTPB4Json4True__ : _M0DTPB4Json5False__); } case 3: { const _Number = tok; const _n = _Number._0; const _repr = _Number._1; return new _M0DTPC16result6ResultGRPB4JsonRPC14json10ParseErrorE2Ok(new _M0DTPB4Json6Number(_n, _repr)); } case 4: { const _String = tok; const _s = _String._0; return new _M0DTPC16result6ResultGRPB4JsonRPC14json10ParseErrorE2Ok(new _M0DTPB4Json6String(_s)); } case 5: { return _M0MPC14json12ParseContext13parse__object(ctx); } case 7: { return _M0MPC14json12ParseContext12parse__array(ctx); } case 8: { break _L; } case 6: { break _L; } default: { break _L; } } } return new _M0DTPC16result6ResultGRPB4JsonRPC14json10ParseErrorE2Ok(_M0FPC15abort5abortGRP36zxch3n5flock5types7Utf8StrE("unreachable")); } function _M0MPC14json12ParseContext12parse__array(ctx) { if (ctx.remaining_available_depth <= 0) { return new _M0DTPC16result6ResultGRPB4JsonRPC14json10ParseErrorE3Err(_M0DTPC15error5Error59moonbitlang_2fcore_2fjson_2eParseError_2eDepthLimitExceeded__); } ctx.remaining_available_depth = ctx.remaining_available_depth - 1 | 0; const vec = []; let _tmp; const _bind = _M0MPC14json12ParseContext10lex__value(ctx, true); let _tmp$2; if (_bind.$tag === 1) { const _ok = _bind; _tmp$2 = _ok._0; } else { return _bind; } let _tmp$3 = _tmp$2; _L: while (true) { const x = _tmp$3; if (x.$tag === 8) { ctx.remaining_available_depth = ctx.remaining_available_depth + 1 | 0; _tmp = new _M0DTPB4Json5Array(vec); break; } else { const _bind$2 = _M0MPC14json12ParseContext13parse__value2(ctx, x); let _tmp$4; if (_bind$2.$tag === 1) { const _ok = _bind$2; _tmp$4 = _ok._0; } else { return _bind$2; } _M0MPC15array5Array4pushGRPB4JsonE(vec, _tmp$4); const _bind$3 = _M0MPC14json12ParseContext24lex__after__array__value(ctx); let tok2; if (_bind$3.$tag === 1) { const _ok = _bind$3; tok2 = _ok._0; } else { return _bind$3; } switch (tok2.$tag) { case 9: { const _bind$4 = _M0MPC14json12ParseContext10lex__value(ctx, false); if (_bind$4.$tag === 1) { const _ok = _bind$4; _tmp$3 = _ok._0; } else { return _bind$4; } continue _L; } case 8: { ctx.remaining_available_depth = ctx.remaining_available_depth + 1 | 0; _tmp = new _M0DTPB4Json5Array(vec); break _L; } default: { _M0FPC15abort5abortGuE("unreachable"); } } } continue; } return new _M0DTPC16result6ResultGRPB4JsonRPC14json10ParseErrorE2Ok(_tmp); } function _M0MPC14json12ParseContext13parse__object(ctx) { if (ctx.remaining_available_depth <= 0) { return new _M0DTPC16result6ResultGRPB4JsonRPC14json10ParseErrorE3Err(_M0DTPC15error5Error59moonbitlang_2fcore_2fjson_2eParseError_2eDepthLimitExceeded__); } ctx.remaining_available_depth = ctx.remaining_available_depth - 1 | 0; const _bind = []; const map = _M0MPB3Map3MapGsRPB4JsonE(new _M0TPB9ArrayViewGUsRPB4JsonEE(_bind, 0, 0), undefined); let _tmp; const _bind$2 = _M0MPC14json12ParseContext19lex__property__name(ctx); let _tmp$2; if (_bind$2.$tag === 1) { const _ok = _bind$2; _tmp$2 = _ok._0; } else { return _bind$2; } let _tmp$3 = _tmp$2; _L: while (true) { const x = _tmp$3; switch (x.$tag) { case 6: { ctx.remaining_available_depth = ctx.remaining_available_depth + 1 | 0; _tmp = new _M0DTPB4Json6Object(map); break _L; } case 4: { const _String = x; const _name = _String._0; const _bind$3 = _M0MPC14json12ParseContext26lex__after__property__name(ctx); if (_bind$3.$tag === 1) { const _ok = _bind$3; _ok._0; } else { return _bind$3; } const _bind$4 = _M0MPC14json12ParseContext12parse__value(ctx); let _tmp$4; if (_bind$4.$tag === 1) { const _ok = _bind$4; _tmp$4 = _ok._0; } else { return _bind$4; } _M0MPB3Map3setGsRPB4JsonE(map, _name, _tmp$4); const _bind$5 = _M0MPC14json12ParseContext25lex__after__object__value(ctx); let _bind$6; if (_bind$5.$tag === 1) { const _ok = _bind$5; _bind$6 = _ok._0; } else { return _bind$5; } switch (_bind$6.$tag) { case 9: { const _bind$7 = _M0MPC14json12ParseContext20lex__property__name2(ctx); if (_bind$7.$tag === 1) { const _ok = _bind$7; _tmp$3 = _ok._0; } else { return _bind$7; } continue _L; } case 6: { ctx.remaining_available_depth = ctx.remaining_available_depth + 1 | 0; _tmp = new _M0DTPB4Json6Object(map); break _L; } default: { _M0FPC15abort5abortGuE("unreachable"); } } break; } default: { _M0FPC15abort5abortGuE("unreachable"); } } continue; } return new _M0DTPC16result6ResultGRPB4JsonRPC14json10ParseErrorE2Ok(_tmp); } function _M0FPC14json13parse_2einner(input, max_nesting_depth) { const ctx = _M0MPC14json12ParseContext4make(input, max_nesting_depth); const _bind = _M0MPC14json12ParseContext12parse__value(ctx); let val; if (_bind.$tag === 1) { const _ok = _bind; val = _ok._0; } else { return _bind; } _M0MPC14json12ParseContext21lex__skip__whitespace(ctx); return ctx.offset >= ctx.end_offset ? new _M0DTPC16result6ResultGRPB4JsonRPC14json10ParseErrorE2Ok(val) : _M0MPC14json12ParseContext21invalid__char_2einnerGRPB4JsonE(ctx, 0); } function _M0FPC14json6escape(str, escape_slash) { const buf = _M0MPB13StringBuilder21StringBuilder_2einner(str.length); const _bind = str.length; let _tmp = 0; while (true) { const _string_index = _tmp; if (_string_index < _bind) { let _decoded_next_string_index; let _decoded_char; _L: { const _bind$2 = str.charCodeAt(_string_index); if (_bind$2 >= 55296 && _bind$2 <= 56319 && (_string_index + 1 | 0) < _bind) { const _bind$3 = str.charCodeAt(_string_index + 1 | 0); if (_bind$3 >= 56320 && _bind$3 <= 57343) { const _tmp$2 = _string_index + 2 | 0; const _p = (((Math.imul(_bind$2 - 55296 | 0, 1024) | 0) + _bind$3 | 0) - 56320 | 0) + 65536 | 0; _decoded_next_string_index = _tmp$2; _decoded_char = _p; break _L; } else { const _tmp$2 = _string_index + 1 | 0; const _p = _bind$2; _decoded_next_string_index = _tmp$2; _decoded_char = _p; break _L; } } else { const _tmp$2 = _string_index + 1 | 0; const _p = _bind$2; _decoded_next_string_index = _tmp$2; _decoded_char = _p; break _L; } } switch (_decoded_char) { case 34: { _M0IPB13StringBuilderPB6Logger13write__string(buf, "\\\""); break; } case 92: { _M0IPB13StringBuilderPB6Logger13write__string(buf, "\\\\"); break; } case 47: { if (escape_slash) { _M0IPB13StringBuilderPB6Logger13write__string(buf, "\\/"); } else { _M0IPB13StringBuilderPB6Logger11write__char(buf, _decoded_char); } break; } case 10: { _M0IPB13StringBuilderPB6Logger13write__string(buf, "\\n"); break; } case 13: { _M0IPB13StringBuilderPB6Logger13write__string(buf, "\\r"); break; } case 8: { _M0IPB13StringBuilderPB6Logger13write__string(buf, "\\b"); break; } case 9: { _M0IPB13StringBuilderPB6Logger13write__string(buf, "\\t"); break; } default: { const code = _decoded_char; if (code === 12) { _M0IPB13StringBuilderPB6Logger13write__string(buf, "\\f"); } else { if (code < 32) { _M0IPB13StringBuilderPB6Logger13write__string(buf, "\\u00"); _M0IPB13StringBuilderPB6Logger13write__string(buf, _M0MPC14byte4Byte7to__hex(code & 255)); } else { _M0IPB13StringBuilderPB6Logger11write__char(buf, _decoded_char); } } } } _tmp = _decoded_next_string_index; continue; } else { break; } } return buf.val; } function _M0FPC14json11indent__str(level, indent) { if (indent === 0) { return ""; } else { const spaces = Math.imul(indent, level) | 0; switch (spaces) { case 0: { return "\n"; } case 1: { return "\n "; } case 2: { return "\n "; } case 3: { return "\n "; } case 4: { return "\n "; } case 5: { return "\n "; } case 6: { return "\n "; } case 7: { return "\n "; } case 8: { return "\n "; } default: { return `\n${_M0MPC16string6String6repeat(" ", spaces)}`; } } } } function _M0MPC14json4Json17stringify_2einner(self, escape_slash, indent, replacer) { const buf = _M0MPB13StringBuilder21StringBuilder_2einner(0); const stack = []; let depth = 0; let _tmp = self; while (true) { const x = _tmp; if (x === undefined) { if (stack.length === 0) { break; } else { const _x = stack[stack.length - 1 | 0]; if (_x.$tag === 0) { const _Array = _x; const _arr = _Array._0; const _i = _Array._1; if (_i < _arr.length) { const element = _M0MPC15array5Array2atGRP36zxch3n5flock5flock5EntryE(_arr, _i); _Array._1 = _i + 1 | 0; if (_i > 0) { _M0IPB13StringBuilderPB6Logger11write__char(buf, 44); _M0IPB13StringBuilderPB6Logger13write__string(buf, _M0FPC14json11indent__str(depth, indent)); } _tmp = element; continue; } else { depth = depth - 1 | 0; _M0MPC15array5Array3popGRP36zxch3n5flock11sorted__map4NodeGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEEE(stack); _M0IPB13StringBuilderPB6Logger13write__string(buf, _M0FPC14json11indent__str(depth, indent)); _M0IPB13StringBuilderPB6Logger11write__char(buf, 93); _tmp = undefined; continue; } } else { const _Object = _x; const _iterator = _Object._0; const _first = _Object._1; const _bind = _M0MPB4Iter4nextGURP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEEE(_iterator); if (_bind === undefined) { depth = depth - 1 | 0; _M0MPC15array5Array3popGRP36zxch3n5flock11sorted__map4NodeGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEEE(stack); _M0IPB13StringBuilderPB6Logger13write__string(buf, _M0FPC14json11indent__str(depth, indent)); _M0IPB13StringBuilderPB6Logger11write__char(buf, 125); _tmp = undefined; continue; } else { const _Some = _bind; const _x$2 = _Some; const _k = _x$2._0; const _v = _x$2._1; let v2 = _v; if (replacer === undefined) { } else { const _Some$2 = replacer; const _replacer = _Some$2; const _func = _replacer.f; const _bind$2 = _func(_k, _v); if (_bind$2 === undefined) { _tmp = undefined; continue; } else { const _Some$3 = _bind$2; const _v$2 = _Some$3; v2 = _v$2; } } if (!_first) { _M0IPB13StringBuilderPB6Logger11write__char(buf, 44); _M0IPB13StringBuilderPB6Logger13write__string(buf, _M0FPC14json11indent__str(depth, indent)); } _M0IPB13StringBuilderPB6Logger11write__char(buf, 34); _M0IPB13StringBuilderPB6Logger13write__string(buf, _M0FPC14json6escape(_k, escape_slash)); _M0IPB13StringBuilderPB6Logger11write__char(buf, 34); _M0IPB13StringBuilderPB6Logger11write__char(buf, 58); if (indent > 0) { _M0IPB13StringBuilderPB6Logger11write__char(buf, 32); } _Object._1 = false; _tmp = v2; continue; } } } } else { const _Some = x; const _value = _Some; switch (_value.$tag) { case 6: { const _Object = _value; const _members = _Object._0; if (_members.size === 0) { _M0IPB13StringBuilderPB6Logger13write__string(buf, "{}"); } else { depth = depth + 1 | 0; _M0IPB13StringBuilderPB6Logger11write__char(buf, 123); _M0IPB13StringBuilderPB6Logger13write__string(buf, _M0FPC14json11indent__str(depth, indent)); _M0MPC15array5Array4pushGRPB4JsonE(stack, new _M0DTPC14json10WriteFrame6Object(_M0MPB3Map4iterGsRPB4JsonE(_members), true)); } break; } case 5: { const _Array = _value; const _arr = _Array._0; if (_arr.length === 0) { _M0IPB13StringBuilderPB6Logger13write__string(buf, "[]"); } else { depth = depth + 1 | 0; _M0IPB13StringBuilderPB6Logger11write__char(buf, 91); _M0IPB13StringBuilderPB6Logger13write__string(buf, _M0FPC14json11indent__str(depth, indent)); _M0MPC15array5Array4pushGRPB4JsonE(stack, new _M0DTPC14json10WriteFrame5Array(_arr, 0)); } break; } case 4: { const _String = _value; const _s = _String._0; _M0IPB13StringBuilderPB6Logger11write__char(buf, 34); _M0IPB13StringBuilderPB6Logger13write__string(buf, _M0FPC14json6escape(_s, escape_slash)); _M0IPB13StringBuilderPB6Logger11write__char(buf, 34); break; } case 3: { const _Number = _value; const _n = _Number._0; const _repr = _Number._1; if (_repr === undefined) { _M0MPB13StringBuilder13write__objectGdE(buf, _n); } else { const _Some$2 = _repr; const _r = _Some$2; _M0IPB13StringBuilderPB6Logger13write__string(buf, _r); } break; } case 1: { _M0IPB13StringBuilderPB6Logger13write__string(buf, "true"); break; } case 2: { _M0IPB13StringBuilderPB6Logger13write__string(buf, "false"); break; } default: { _M0IPB13StringBuilderPB6Logger13write__string(buf, "null"); } } _tmp = undefined; continue; } } return buf.val; } function _M0MPC14json4Json10as__number(self) { if (self.$tag === 3) { const _Number = self; const _n = _Number._0; return new _M0DTPC16option6OptionGdE4Some(_n); } else { return _M0DTPC16option6OptionGdE4None__; } } function _M0IPC16bigint6BigIntPB7Compare7compare(self, other) { return _M0MPC16bigint6BigInt7compare(self, other); } function _M0IPC16bigint6BigIntPB2Eq5equal(self, other) { return _M0MPC16bigint6BigInt5equal(self, other); } function _M0IPC16bigint6BigIntPB3Neg3neg(self) { return _M0MPC16bigint6BigInt12op__neg__ffi(self); } function _M0IPC16bigint6BigIntPB3Add3add(self, other) { return _M0MPC16bigint6BigInt12op__add__ffi(self, other); } function _M0IPC16bigint6BigIntPB3Mul3mul(self, other) { return _M0MPC16bigint6BigInt12op__mul__ffi(self, other); } function _M0IPC16bigint6BigIntPB3Div3div(self, other) { return _M0MPC16bigint6BigInt12op__div__ffi(self, other); } function _M0IPC16bigint6BigIntPB3Mod3mod(self, other) { return _M0MPC16bigint6BigInt12op__mod__ffi(self, other); } function _M0IPC16bigint6BigIntPB3Shr3shr(self, n) { if (n < 0) { _M0FPC15abort5abortGuE("negative shift count"); } return _M0MPC16bigint6BigInt7js__shr(self, n); } function _M0MPC16bigint6BigInt9to__int64(self) { const hi = _M0MPC16bigint6BigInt8to__uint(_M0IPC16bigint6BigIntPB3Shr3shr(self, 32)); const lo = _M0MPC16bigint6BigInt8to__uint(self); return BigInt.asUintN(64, BigInt.asUintN(64, _M0MPC14uint4UInt9to__int64(hi) << BigInt(32 & 63)) | _M0MPC14uint4UInt9to__int64(lo)); } function _M0MP27Yoorkin4jmop5Value9get__type(self) { return _M0FP27Yoorkin4jmop11ffi__typeof(self); } function _M0MP27Yoorkin4jmop5Value10to__number(self, loc) { if (_M0MP27Yoorkin4jmop5Value9get__type(self) === "number") { return new _M0DTPC16result6ResultGdRP27Yoorkin4jmop11InvalidCastE2Ok(self); } else { return new _M0DTPC16result6ResultGdRP27Yoorkin4jmop11InvalidCastE3Err(new _M0DTPC15error5Error42Yoorkin_2fjmop_2eInvalidCast_2eInvalidCast({ _0: loc, _1: self, _2: "Double" })); } } function _M0MP27Yoorkin4jmop5Value10to__string(self, loc) { const _bind = _M0MP27Yoorkin4jmop5Value9get__type(self); if (_bind === "string") { return new _M0DTPC16result6ResultGsRP27Yoorkin4jmop11InvalidCastE2Ok(self); } else { return new _M0DTPC16result6ResultGsRP27Yoorkin4jmop11InvalidCastE3Err(new _M0DTPC15error5Error42Yoorkin_2fjmop_2eInvalidCast_2eInvalidCast({ _0: loc, _1: self, _2: "String" })); } } function _M0MP27Yoorkin4jmop13DynCastResult7rethrowGRP27Yoorkin4jmop5ValueE(self, loc) { const _inner = self; if (_inner.$tag === 0) { const _Err = _inner; const _x = _Err._0; const _InvalidCast = _x; const _x$2 = _InvalidCast._0; const _value = _x$2._1; const _target = _x$2._2; return new _M0DTPC16result6ResultGRP27Yoorkin4jmop5ValueRP27Yoorkin4jmop11InvalidCastE3Err(new _M0DTPC15error5Error42Yoorkin_2fjmop_2eInvalidCast_2eInvalidCast({ _0: loc, _1: _value, _2: _target })); } else { const _Ok = _inner; const _x = _Ok._0; return new _M0DTPC16result6ResultGRP27Yoorkin4jmop5ValueRP27Yoorkin4jmop11InvalidCastE2Ok(_x); } } function _M0MP27Yoorkin4jmop5Value9to__arrayGRP27Yoorkin4jmop5ValueE(self, loc) { if (_M0FP27Yoorkin4jmop14ffi__is__array(self)) { const arr = self; let _p; _L: { const _p$2 = new Array(arr.length); const _p$3 = arr.length; let _tmp = 0; while (true) { const _p$4 = _tmp; if (_p$4 < _p$3) { const _p$5 = arr[_p$4]; const _bind = _M0MP27Yoorkin4jmop13DynCastResult7rethrowGRP27Yoorkin4jmop5ValueE(new _M0DTPC16result6ResultGRP27Yoorkin4jmop5ValueRP27Yoorkin4jmop11InvalidCastE2Ok(_p$5), "value.mbt:156:18-156:50@Yoorkin/jmop"); let _tmp$2; if (_bind.$tag === 1) { const _ok = _bind; _tmp$2 = _ok._0; } else { const _err = _bind; _p = _err._0; break _L; } _p$2[_p$4] = _tmp$2; _tmp = _p$4 + 1 | 0; continue; } else { break; } } return new _M0DTPC16result6ResultGRPB5ArrayGRP27Yoorkin4jmop5ValueERP27Yoorkin4jmop11InvalidCastE2Ok(_p$2); } return new _M0DTPC16result6ResultGRPB5ArrayGRP27Yoorkin4jmop5ValueERP27Yoorkin4jmop11InvalidCastE3Err(_p); } else { return new _M0DTPC16result6ResultGRPB5ArrayGRP27Yoorkin4jmop5ValueERP27Yoorkin4jmop11InvalidCastE3Err(new _M0DTPC15error5Error42Yoorkin_2fjmop_2eInvalidCast_2eInvalidCast({ _0: loc, _1: self, _2: "Array" })); } } function _M0MP27Yoorkin4jmop8Optional9undefinedGRP27Yoorkin4jmop5ValueE() { return _M0FP27Yoorkin4jmop14ffi__undefined(); } function _M0MP27Yoorkin4jmop8Optional6unwrapGRP27Yoorkin4jmop8NullableGRP27Yoorkin4jmop5ValueEE(self, loc) { if (_M0FP27Yoorkin4jmop18ffi__is__undefined(self)) { return new _M0DTPC16result6ResultGRP27Yoorkin4jmop8NullableGRP27Yoorkin4jmop5ValueERP27Yoorkin4jmop15UnwrapUndefinedE3Err(new _M0DTPC15error5Error50Yoorkin_2fjmop_2eUnwrapUndefined_2eUnwrapUndefined(loc)); } else { return new _M0DTPC16result6ResultGRP27Yoorkin4jmop8NullableGRP27Yoorkin4jmop5ValueERP27Yoorkin4jmop15UnwrapUndefinedE2Ok(self); } } function _M0MP27Yoorkin4jmop8Nullable6unwrapGRP27Yoorkin4jmop5ValueE(self, loc) { if (_M0FP27Yoorkin4jmop21ffi__object__is__null(self)) { return new _M0DTPC16result6ResultGRP27Yoorkin4jmop5ValueRP27Yoorkin4jmop10UnwrapNullE3Err(new _M0DTPC15error5Error40Yoorkin_2fjmop_2eUnwrapNull_2eUnwrapNull(loc)); } else { return new _M0DTPC16result6ResultGRP27Yoorkin4jmop5ValueRP27Yoorkin4jmop10UnwrapNullE2Ok(self); } } function _M0MP27Yoorkin4jmop8Optional13unwrap__value(self, loc) { const _bind = _M0MP27Yoorkin4jmop8Optional6unwrapGRP27Yoorkin4jmop8NullableGRP27Yoorkin4jmop5ValueEE(self, loc); let _tmp; if (_bind.$tag === 1) { const _ok = _bind; _tmp = _ok._0; } else { return _bind; } return _M0MP27Yoorkin4jmop8Nullable6unwrapGRP27Yoorkin4jmop5ValueE(_tmp, loc); } function _M0MP27Yoorkin4jmop3Any13unwrap__value(x, loc) { const _inner = x; return _M0MP27Yoorkin4jmop8Optional13unwrap__value(_inner, loc); } function _M0FP27Yoorkin4jmop22convert__thrown__error(x, payload0, payload1) { if (x === "InvalidNestedPromise") { const _bind = _M0MP27Yoorkin4jmop3Any13unwrap__value(payload0, "init.mbt:63:43-63:66@Yoorkin/jmop"); let _tmp; if (_bind.$tag === 1) { const _ok = _bind; _tmp = _ok._0; } else { return _bind; } return new _M0DTPC16result6ResultGuRP27Yoorkin4jmop20InvalidNestedPromiseE3Err(new _M0DTPC15error5Error60Yoorkin_2fjmop_2eInvalidNestedPromise_2eInvalidNestedPromise(_tmp)); } else { return new _M0DTPC16result6ResultGuRP27Yoorkin4jmop12RuntimeErrorE3Err(new _M0DTPC15error5Error44Yoorkin_2fjmop_2eRuntimeError_2eRuntimeError(payload0)); } } function _M0MP27gmlewis6sha2566Digest3new() { return new _M0TP27gmlewis6sha2566Digest(_M0MPC15array10FixedArray11from__arrayGjE(new _M0TPB9ArrayViewGjE(_M0MP27gmlewis6sha2566Digest3newN7_2abindS100, 0, 8)), $makebytes(64, 0), 0, 0n, "sha256"); } function _M0FP27gmlewis6sha2567to__hex(v) { return v < 10 ? v + 48 | 0 : (v - 10 | 0) + 97 | 0; } function _M0FP27gmlewis6sha25615be__put__uint32(b, offset, value) { const _tmp = offset + 3 | 0; const _p = value & 255; $bound_check(b, _tmp); b[_tmp] = _p & 255; const _tmp$2 = offset + 2 | 0; const _p$2 = value >>> 8 & 255; $bound_check(b, _tmp$2); b[_tmp$2] = _p$2 & 255; const _tmp$3 = offset + 1 | 0; const _p$3 = value >>> 16 & 255; $bound_check(b, _tmp$3); b[_tmp$3] = _p$3 & 255; const _p$4 = value >>> 24 & 255; $bound_check(b, offset); b[offset] = _p$4 & 255; } function _M0FP27gmlewis6sha25615be__put__uint64(b, offset, value) { _M0FP27gmlewis6sha25615be__put__uint32(b, offset + 4 | 0, Number(BigInt.asUintN(32, BigInt.asUintN(64, value & 4294967295n))) | 0); _M0FP27gmlewis6sha25615be__put__uint32(b, offset, Number(BigInt.asUintN(32, BigInt.asUintN(64, BigInt.asUintN(64, BigInt.asUintN(64, value) >> BigInt(32 & 63)) & 4294967295n))) | 0); } function _M0MP27gmlewis6sha2566Digest14block__generic(self) { const w = $make_array_len_and_init(64, 0); const p = self.x; let _tmp = 0; while (true) { const i = _tmp; if (i < 16) { const j = Math.imul(i, 4) | 0; $bound_check(p, j); const _p = p[j]; const _tmp$2 = _p << 24; const _tmp$3 = j + 1 | 0; $bound_check(p, _tmp$3); const _p$2 = p[_tmp$3]; const _tmp$4 = _tmp$2 | _p$2 << 16; const _tmp$5 = j + 2 | 0; $bound_check(p, _tmp$5); const _p$3 = p[_tmp$5]; const _tmp$6 = _tmp$4 | _p$3 << 8; const _tmp$7 = j + 3 | 0; $bound_check(p, _tmp$7); const _p$4 = p[_tmp$7]; $bound_check(w, i); w[i] = _tmp$6 | _p$4; _tmp = i + 1 | 0; continue; } else { break; } } let _tmp$2 = 16; while (true) { const i = _tmp$2; if (i < 64) { const _tmp$3 = i - 2 | 0; $bound_check(w, _tmp$3); const v1 = w[_tmp$3]; const _p = -17; const _tmp$4 = v1 << _p | (v1 >>> (32 - _p | 0) | 0); const _p$2 = -19; const t1 = _tmp$4 ^ (v1 << _p$2 | (v1 >>> (32 - _p$2 | 0) | 0)) ^ (v1 >>> 10 | 0); const _tmp$5 = i - 15 | 0; $bound_check(w, _tmp$5); const v2 = w[_tmp$5]; const _p$3 = -7; const _tmp$6 = v2 << _p$3 | (v2 >>> (32 - _p$3 | 0) | 0); const _p$4 = -18; const t2 = _tmp$6 ^ (v2 << _p$4 | (v2 >>> (32 - _p$4 | 0) | 0)) ^ (v2 >>> 3 | 0); const _tmp$7 = i - 7 | 0; $bound_check(w, _tmp$7); const _tmp$8 = (((t1 >>> 0) + (w[_tmp$7] >>> 0) | 0) >>> 0) + (t2 >>> 0) | 0; const _tmp$9 = i - 16 | 0; $bound_check(w, _tmp$9); $bound_check(w, i); w[i] = (_tmp$8 >>> 0) + (w[_tmp$9] >>> 0) | 0; _tmp$2 = i + 1 | 0; continue; } else { break; } } const _tmp$3 = self.h; $bound_check(_tmp$3, 0); let a = _tmp$3[0]; const _tmp$4 = self.h; $bound_check(_tmp$4, 1); let b = _tmp$4[1]; const _tmp$5 = self.h; $bound_check(_tmp$5, 2); let c = _tmp$5[2]; const _tmp$6 = self.h; $bound_check(_tmp$6, 3); let d = _tmp$6[3]; const _tmp$7 = self.h; $bound_check(_tmp$7, 4); let e = _tmp$7[4]; const _tmp$8 = self.h; $bound_check(_tmp$8, 5); let f = _tmp$8[5]; const _tmp$9 = self.h; $bound_check(_tmp$9, 6); let g = _tmp$9[6]; const _tmp$10 = self.h; $bound_check(_tmp$10, 7); let h = _tmp$10[7]; let _tmp$11 = 0; while (true) { const i = _tmp$11; if (i < 64) { const _tmp$12 = h; const _p = e; const _p$2 = -6; const _tmp$13 = _p << _p$2 | (_p >>> (32 - _p$2 | 0) | 0); const _p$3 = e; const _p$4 = -11; const _tmp$14 = _tmp$13 ^ (_p$3 << _p$4 | (_p$3 >>> (32 - _p$4 | 0) | 0)); const _p$5 = e; const _p$6 = -25; const _tmp$15 = (((((_tmp$12 >>> 0) + ((_tmp$14 ^ (_p$5 << _p$6 | (_p$5 >>> (32 - _p$6 | 0) | 0))) >>> 0) | 0) >>> 0) + ((e & f ^ ~e & g) >>> 0) | 0) >>> 0) + (_M0MPC15array5Array2atGjE(_M0FP27gmlewis6sha2563__K, i) >>> 0) | 0; $bound_check(w, i); const t1 = (_tmp$15 >>> 0) + (w[i] >>> 0) | 0; const _p$7 = a; const _p$8 = -2; const _tmp$16 = _p$7 << _p$8 | (_p$7 >>> (32 - _p$8 | 0) | 0); const _p$9 = a; const _p$10 = -13; const _tmp$17 = _tmp$16 ^ (_p$9 << _p$10 | (_p$9 >>> (32 - _p$10 | 0) | 0)); const _p$11 = a; const _p$12 = -22; const t2 = ((_tmp$17 ^ (_p$11 << _p$12 | (_p$11 >>> (32 - _p$12 | 0) | 0))) >>> 0) + ((a & b ^ a & c ^ b & c) >>> 0) | 0; h = g; g = f; f = e; e = (d >>> 0) + (t1 >>> 0) | 0; d = c; c = b; b = a; a = (t1 >>> 0) + (t2 >>> 0) | 0; _tmp$11 = i + 1 | 0; continue; } else { break; } } const _array_1 = self.h; $bound_check(_array_1, 0); $bound_check(_array_1, 0); _array_1[0] = (_array_1[0] >>> 0) + (a >>> 0) | 0; const _array_3 = self.h; $bound_check(_array_3, 1); $bound_check(_array_3, 1); _array_3[1] = (_array_3[1] >>> 0) + (b >>> 0) | 0; const _array_5 = self.h; $bound_check(_array_5, 2); $bound_check(_array_5, 2); _array_5[2] = (_array_5[2] >>> 0) + (c >>> 0) | 0; const _array_7 = self.h; $bound_check(_array_7, 3); $bound_check(_array_7, 3); _array_7[3] = (_array_7[3] >>> 0) + (d >>> 0) | 0; const _array_9 = self.h; $bound_check(_array_9, 4); $bound_check(_array_9, 4); _array_9[4] = (_array_9[4] >>> 0) + (e >>> 0) | 0; const _array_11 = self.h; $bound_check(_array_11, 5); $bound_check(_array_11, 5); _array_11[5] = (_array_11[5] >>> 0) + (f >>> 0) | 0; const _array_13 = self.h; $bound_check(_array_13, 6); $bound_check(_array_13, 6); _array_13[6] = (_array_13[6] >>> 0) + (g >>> 0) | 0; const _array_15 = self.h; $bound_check(_array_15, 7); $bound_check(_array_15, 7); _array_15[7] = (_array_15[7] >>> 0) + (h >>> 0) | 0; } function _M0IP27gmlewis6sha2566DigestP27gmlewis6sha2568HashFunc5write(self, b) { self.len = BigInt.asUintN(64, self.len + 1n); const _tmp = self.x; const _tmp$2 = self.nx; $bound_check(_tmp, _tmp$2); _tmp[_tmp$2] = b; self.nx = self.nx + 1 | 0; if (self.nx === 64) { _M0MP27gmlewis6sha2566Digest14block__generic(self); self.nx = 0; return; } else { return; } } function _M0MP27gmlewis6sha2566Digest3sum(self) { const tmp = $makebytes(72, 0); $bound_check(tmp, 0); tmp[0] = 128; let t; if (64n === 0n) { $panic(); } if (BigInt.asUintN(64, BigInt.asUintN(64, BigInt.asUintN(64, self.len) % BigInt.asUintN(64, 64n))) < BigInt.asUintN(64, 56n)) { if (64n === 0n) { $panic(); } t = Number(BigInt.asIntN(32, BigInt.asUintN(64, 56n - BigInt.asUintN(64, BigInt.asUintN(64, self.len) % BigInt.asUintN(64, 64n))))) | 0; } else { if (64n === 0n) { $panic(); } t = Number(BigInt.asIntN(32, BigInt.asUintN(64, 120n - BigInt.asUintN(64, BigInt.asUintN(64, self.len) % BigInt.asUintN(64, 64n))))) | 0; } const len = BigInt.asUintN(64, self.len << BigInt(3 & 63)); _M0FP27gmlewis6sha25615be__put__uint64(tmp, t, len); let _tmp = 0; while (true) { const i = _tmp; if (i < (t + 8 | 0)) { $bound_check(tmp, i); _M0IP27gmlewis6sha2566DigestP27gmlewis6sha2568HashFunc5write(self, tmp[i]); _tmp = i + 1 | 0; continue; } else { break; } } if (self.nx !== 0) { $panic(); } const digest = $makebytes(32, 0); const _tmp$2 = self.h; $bound_check(_tmp$2, 0); _M0FP27gmlewis6sha25615be__put__uint32(digest, 0, _tmp$2[0]); const _tmp$3 = self.h; $bound_check(_tmp$3, 1); _M0FP27gmlewis6sha25615be__put__uint32(digest, 4, _tmp$3[1]); const _tmp$4 = self.h; $bound_check(_tmp$4, 2); _M0FP27gmlewis6sha25615be__put__uint32(digest, 8, _tmp$4[2]); const _tmp$5 = self.h; $bound_check(_tmp$5, 3); _M0FP27gmlewis6sha25615be__put__uint32(digest, 12, _tmp$5[3]); const _tmp$6 = self.h; $bound_check(_tmp$6, 4); _M0FP27gmlewis6sha25615be__put__uint32(digest, 16, _tmp$6[4]); const _tmp$7 = self.h; $bound_check(_tmp$7, 5); _M0FP27gmlewis6sha25615be__put__uint32(digest, 20, _tmp$7[5]); const _tmp$8 = self.h; $bound_check(_tmp$8, 6); _M0FP27gmlewis6sha25615be__put__uint32(digest, 24, _tmp$8[6]); const _tmp$9 = self.h; $bound_check(_tmp$9, 7); _M0FP27gmlewis6sha25615be__put__uint32(digest, 28, _tmp$9[7]); return digest; } function _M0IP27gmlewis6sha2566DigestP27gmlewis6sha2568HashFunc10check__sum(self) { const digest = _M0MP27gmlewis6sha2566Digest3sum(self); const result = _M0FPC16buffer11new_2einner(64); const _bind = digest.length; let _tmp = 0; while (true) { const _ = _tmp; if (_ < _bind) { const b = digest[_]; _M0IPC16buffer6BufferPB6Logger11write__char(result, _M0FP27gmlewis6sha2567to__hex(b >> 4 & 15)); _M0IPC16buffer6BufferPB6Logger11write__char(result, _M0FP27gmlewis6sha2567to__hex(b & 15)); _tmp = _ + 1 | 0; continue; } else { break; } } return _M0MPC15bytes5Bytes29to__unchecked__string_2einner(_M0MPC16buffer6Buffer9to__bytes(result), 0, undefined); } function _M0FP36zxch3n5flock6leb12814encode__uint64(value) { const result = []; let val = value; while (true) { const _p = BigInt.asUintN(64, val & 127n); let byte = (Number(BigInt.asIntN(32, _p)) | 0) & 255; val = BigInt.asUintN(64, BigInt.asUintN(64, val) >> BigInt(7 & 63)); if (BigInt.asUintN(64, val) !== BigInt.asUintN(64, 0n)) { const _p$2 = byte; const _p$3 = 128; byte = (_p$2 | _p$3) & 255; } _M0MPC15array5Array4pushGyE(result, byte); if (BigInt.asUintN(64, val) === BigInt.asUintN(64, 0n)) { break; } continue; } return _M0MPC15bytes5Bytes11from__array(new _M0TPB9ArrayViewGyE(result, 0, result.length)); } function _M0FP36zxch3n5flock6leb12813encode__int64(value) { const result = []; let val = value; let more = true; while (true) { if (more) { let byte = Number(BigInt.asUintN(8, BigInt.asUintN(64, val & 127n))); val = BigInt.asUintN(64, BigInt.asIntN(64, val) >> BigInt(7 & 63)); let _tmp; if (BigInt.asUintN(64, val) === BigInt.asUintN(64, 0n)) { const _p = byte; const _p$2 = 64; const _p$3 = _p & _p$2 & 255; const _p$4 = 0; _tmp = _p$3 === _p$4; } else { _tmp = false; } if (_tmp) { more = false; } else { let _tmp$2; if (BigInt.asUintN(64, val) === BigInt.asUintN(64, 18446744073709551615n)) { const _p = byte; const _p$2 = 64; _tmp$2 = (_p & _p$2 & 255) !== 0; } else { _tmp$2 = false; } if (_tmp$2) { more = false; } else { const _p = byte; const _p$2 = 128; byte = (_p | _p$2) & 255; } } _M0MPC15array5Array4pushGyE(result, byte); continue; } else { break; } } return _M0MPC15bytes5Bytes11from__array(new _M0TPB9ArrayViewGyE(result, 0, result.length)); } function _M0MP26zxch3n6expect5Color19to__bg__color__code(self) { switch (self) { case 0: { return "40"; } case 1: { return "41"; } case 2: { return "42"; } case 3: { return "43"; } case 4: { return "44"; } case 5: { return "45"; } case 6: { return "46"; } case 7: { return "47"; } default: { return "49"; } } } function _M0MP26zxch3n6expect5Color15to__color__code(self) { switch (self) { case 0: { return "30"; } case 1: { return "31"; } case 2: { return "32"; } case 3: { return "33"; } case 4: { return "34"; } case 5: { return "35"; } case 6: { return "36"; } case 7: { return "37"; } default: { return "39"; } } } function _M0MP26zxch3n6expect8Formated10to__string(self) { const styles = []; const _bind = self.color; if (_bind === undefined) { } else { const _Some = _bind; const _color = _Some; _M0MPC15array5Array4pushGRPB4JsonE(styles, _M0MP26zxch3n6expect5Color15to__color__code(_color)); } const _bind$2 = self.bg_color; if (_bind$2 === undefined) { } else { const _Some = _bind$2; const _bg_color = _Some; _M0MPC15array5Array4pushGRPB4JsonE(styles, _M0MP26zxch3n6expect5Color19to__bg__color__code(_bg_color)); } const _bind$3 = self.formats; const _bind$4 = _bind$3.length; let _tmp = 0; while (true) { const _ = _tmp; if (_ < _bind$4) { const format = _bind$3[_]; switch (format) { case 0: { _M0MPC15array5Array4pushGRPB4JsonE(styles, "1"); break; } case 1: { _M0MPC15array5Array4pushGRPB4JsonE(styles, "4"); break; } case 2: { _M0MPC15array5Array4pushGRPB4JsonE(styles, "5"); break; } case 3: { _M0MPC15array5Array4pushGRPB4JsonE(styles, "7"); break; } case 4: { _M0MPC15array5Array4pushGRPB4JsonE(styles, "8"); break; } case 5: { _M0MPC15array5Array4pushGRPB4JsonE(styles, "9"); break; } default: { _M0MPC15array5Array4pushGRPB4JsonE(styles, "3"); } } _tmp = _ + 1 | 0; continue; } else { break; } } if (styles.length > 0) { const style_string = _M0MPC15array5Array4joinGsE(styles, new _M0TPC16string10StringView(_M0MP26zxch3n6expect8Formated10to__stringN7_2abindS179, 0, _M0MP26zxch3n6expect8Formated10to__stringN7_2abindS179.length)); const _string_builder = _M0MPB13StringBuilder21StringBuilder_2einner(5); _M0IPB13StringBuilderPB6Logger13write__string(_string_builder, "["); _M0MPB13StringBuilder13write__objectGsE(_string_builder, style_string); _M0IPB13StringBuilderPB6Logger13write__string(_string_builder, "m"); _M0MPB13StringBuilder13write__objectGsE(_string_builder, self.str); _M0IPB13StringBuilderPB6Logger13write__string(_string_builder, "[0m"); return _string_builder.val; } else { return self.str; } } function _M0MP26zxch3n6expect8Formated6format(str) { return new _M0TP26zxch3n6expect8Formated(str, undefined, undefined, []); } function _M0MP26zxch3n6expect8Formated3red(self) { return new _M0TP26zxch3n6expect8Formated(self.str, self.bg_color, _M0MP26zxch3n6expect8Formated3redN6constrS279, self.formats); } function _M0MP26zxch3n6expect8Formated6yellow(self) { return new _M0TP26zxch3n6expect8Formated(self.str, self.bg_color, _M0MP26zxch3n6expect8Formated6yellowN6constrS281, self.formats); } function _M0MP26zxch3n6expect8Formated4blue(self) { return new _M0TP26zxch3n6expect8Formated(self.str, self.bg_color, _M0MP26zxch3n6expect8Formated4blueN6constrS285, self.formats); } function _M0MP26zxch3n6expect8Formated4bold(self) { const _tmp = self.str; const _tmp$2 = self.bg_color; const _tmp$3 = self.color; const _self = []; _M0MPC15array5Array4pushGRP26zxch3n6expect6FormatE(_self, 0); _M0MPC15array5Array10push__iterGRP26zxch3n6expect6FormatE(_self, _M0MPC15array5Array4iterGRP26zxch3n6expect6FormatE(self.formats)); return new _M0TP26zxch3n6expect8Formated(_tmp, _tmp$2, _tmp$3, _self); } function _M0FP26zxch3n6expect13panic_2einnerGuE(reason, loc) { const msg = `${_M0MP26zxch3n6expect8Formated10to__string(_M0MP26zxch3n6expect8Formated3red(_M0MP26zxch3n6expect8Formated4bold(_M0MP26zxch3n6expect8Formated6format("Panic: "))))}${_M0MP26zxch3n6expect8Formated10to__string(_M0MP26zxch3n6expect8Formated6yellow(_M0MP26zxch3n6expect8Formated6format(reason)))} at ${_M0MP26zxch3n6expect8Formated10to__string(_M0MP26zxch3n6expect8Formated4blue(_M0MP26zxch3n6expect8Formated6format(loc)))}`; _M0FPB7printlnGsE(msg); _M0FPC15abort5abortGuE(msg); } function _M0IP36zxch3n5flock5types6NBytesPB2Eq5equal(_x_164, _x_165) { return _M0IPC15bytes5BytesPB2Eq5equal(_x_164, _x_165); } function _M0IP36zxch3n5flock5types7Utf8StrPB2Eq5equal(self, other) { if (self.bytes.length !== other.bytes.length) { return false; } let _tmp = 0; while (true) { const i = _tmp; if (i < self.bytes.length) { const _tmp$2 = self.bytes; $bound_check(_tmp$2, i); const _tmp$3 = _tmp$2[i]; const _tmp$4 = other.bytes; $bound_check(_tmp$4, i); if (_tmp$3 !== _tmp$4[i]) { return false; } _tmp = i + 1 | 0; continue; } else { break; } } return true; } function _M0FP36zxch3n5flock5types16string__to__utf8(str) { const bytes = _M0MPC15array5Array11new_2einnerGyE(0); let i = 0; while (true) { if (i < str.length) { const _tmp = i; $bound_check(str, _tmp); const code = str.charCodeAt(_tmp); if (code >= 55296 && (code <= 56319 && (i + 1 | 0) < str.length)) { const _tmp$2 = i + 1 | 0; $bound_check(str, _tmp$2); const low = str.charCodeAt(_tmp$2); if (low >= 56320 && low <= 57343) { const code_point = (65536 + (code - 55296 << 10) | 0) + (low - 56320 | 0) | 0; _M0MPC15array5Array4pushGyE(bytes, (240 | code_point >> 18) & 255); _M0MPC15array5Array4pushGyE(bytes, (128 | code_point >> 12 & 63) & 255); _M0MPC15array5Array4pushGyE(bytes, (128 | code_point >> 6 & 63) & 255); _M0MPC15array5Array4pushGyE(bytes, (128 | code_point & 63) & 255); i = i + 1 | 0; } else { _M0MPC15array5Array4pushGyE(bytes, (224 | code >> 12) & 255); _M0MPC15array5Array4pushGyE(bytes, (128 | code >> 6 & 63) & 255); _M0MPC15array5Array4pushGyE(bytes, (128 | code & 63) & 255); } } else { if (code < 128) { _M0MPC15array5Array4pushGyE(bytes, code & 255); } else { if (code < 2048) { _M0MPC15array5Array4pushGyE(bytes, (192 | code >> 6) & 255); _M0MPC15array5Array4pushGyE(bytes, (128 | code & 63) & 255); } else { _M0MPC15array5Array4pushGyE(bytes, (224 | code >> 12) & 255); _M0MPC15array5Array4pushGyE(bytes, (128 | code >> 6 & 63) & 255); _M0MPC15array5Array4pushGyE(bytes, (128 | code & 63) & 255); } } } i = i + 1 | 0; continue; } else { break; } } return _M0MPC15bytes5Bytes11from__array(new _M0TPB9ArrayViewGyE(bytes, 0, bytes.length)); } function _M0MP36zxch3n5flock5types7Utf8Str12from__string(str) { return new _M0TP36zxch3n5flock5types7Utf8Str(_M0FP36zxch3n5flock5types16string__to__utf8(str)); } function _M0FP36zxch3n5flock5types15is__valid__utf8(utf8Arr) { let i = 0; while (true) { if (i < (utf8Arr.end - utf8Arr.start | 0)) { const byte = _M0MPC15bytes9BytesView2at(utf8Arr, i); const _p = 128; const _p$2 = byte & _p & 255; const _p$3 = 0; if (_p$2 === _p$3) { i = i + 1 | 0; } else { const _p$4 = 224; const _p$5 = byte & _p$4 & 255; const _p$6 = 192; if (_p$5 === _p$6) { if ((i + 1 | 0) >= (utf8Arr.end - utf8Arr.start | 0)) { return false; } const byte2 = _M0MPC15bytes9BytesView2at(utf8Arr, i + 1 | 0); const _p$7 = 192; if ((byte2 & _p$7 & 255) !== 128) { return false; } i = i + 2 | 0; } else { const _p$7 = 240; const _p$8 = byte & _p$7 & 255; const _p$9 = 224; if (_p$8 === _p$9) { if ((i + 2 | 0) >= (utf8Arr.end - utf8Arr.start | 0)) { return false; } const byte2 = _M0MPC15bytes9BytesView2at(utf8Arr, i + 1 | 0); const byte3 = _M0MPC15bytes9BytesView2at(utf8Arr, i + 2 | 0); let _tmp; const _p$10 = 192; if ((byte2 & _p$10 & 255) !== 128) { _tmp = true; } else { const _p$11 = 192; _tmp = (byte3 & _p$11 & 255) !== 128; } if (_tmp) { return false; } i = i + 3 | 0; } else { const _p$10 = 248; const _p$11 = byte & _p$10 & 255; const _p$12 = 240; if (_p$11 === _p$12) { if ((i + 3 | 0) >= (utf8Arr.end - utf8Arr.start | 0)) { return false; } const byte2 = _M0MPC15bytes9BytesView2at(utf8Arr, i + 1 | 0); const byte3 = _M0MPC15bytes9BytesView2at(utf8Arr, i + 2 | 0); const byte4 = _M0MPC15bytes9BytesView2at(utf8Arr, i + 3 | 0); let _tmp; const _p$13 = 192; if ((byte2 & _p$13 & 255) !== 128) { _tmp = true; } else { let _tmp$2; const _p$14 = 192; if ((byte3 & _p$14 & 255) !== 128) { _tmp$2 = true; } else { const _p$15 = 192; _tmp$2 = (byte4 & _p$15 & 255) !== 128; } _tmp = _tmp$2; } if (_tmp) { return false; } i = i + 4 | 0; } else { return false; } } } } continue; } else { break; } } return true; } function _M0MP36zxch3n5flock5types7Utf8Str17from__bytes__view(bytes) { if (!_M0FP36zxch3n5flock5types15is__valid__utf8(_M0MPC15bytes9BytesView12view_2einner(bytes, 0, undefined))) { return undefined; } return new _M0TP36zxch3n5flock5types7Utf8Str(_M0MPC15bytes5Bytes10from__iter(_M0MPC15bytes9BytesView4iter(bytes))); } function _M0FP36zxch3n5flock5types23new__string__from__utf8(utf8Arr) { let i = 0; let result = ""; while (true) { if (i < utf8Arr.length) { const _tmp = i; $bound_check(utf8Arr, _tmp); const byte = utf8Arr[_tmp]; let code_point; const _p = 128; const _p$2 = byte & _p & 255; const _p$3 = 0; if (_p$2 === _p$3) { code_point = byte; } else { const _p$4 = 224; const _p$5 = byte & _p$4 & 255; const _p$6 = 192; if (_p$5 === _p$6) { if ((i + 1 | 0) >= utf8Arr.length) { return undefined; } const _tmp$2 = i + 1 | 0; $bound_check(utf8Arr, _tmp$2); const byte2 = utf8Arr[_tmp$2]; const _p$7 = 192; if ((byte2 & _p$7 & 255) !== 128) { return undefined; } i = i + 1 | 0; const _p$8 = 31; const _tmp$3 = (byte & _p$8 & 255) << 6; const _p$9 = 63; code_point = _tmp$3 | byte2 & _p$9 & 255; } else { const _p$7 = 240; const _p$8 = byte & _p$7 & 255; const _p$9 = 224; if (_p$8 === _p$9) { if ((i + 2 | 0) >= utf8Arr.length) { return undefined; } const _tmp$2 = i + 1 | 0; $bound_check(utf8Arr, _tmp$2); const byte2 = utf8Arr[_tmp$2]; const _tmp$3 = i + 2 | 0; $bound_check(utf8Arr, _tmp$3); const byte3 = utf8Arr[_tmp$3]; let _tmp$4; const _p$10 = 192; if ((byte2 & _p$10 & 255) !== 128) { _tmp$4 = true; } else { const _p$11 = 192; _tmp$4 = (byte3 & _p$11 & 255) !== 128; } if (_tmp$4) { return undefined; } i = i + 2 | 0; const _p$11 = 15; const _tmp$5 = (byte & _p$11 & 255) << 12; const _p$12 = 63; const _tmp$6 = _tmp$5 | (byte2 & _p$12 & 255) << 6; const _p$13 = 63; code_point = _tmp$6 | byte3 & _p$13 & 255; } else { const _p$10 = 248; const _p$11 = byte & _p$10 & 255; const _p$12 = 240; if (_p$11 === _p$12) { if ((i + 3 | 0) >= utf8Arr.length) { return undefined; } const _tmp$2 = i + 1 | 0; $bound_check(utf8Arr, _tmp$2); const byte2 = utf8Arr[_tmp$2]; const _tmp$3 = i + 2 | 0; $bound_check(utf8Arr, _tmp$3); const byte3 = utf8Arr[_tmp$3]; const _tmp$4 = i + 3 | 0; $bound_check(utf8Arr, _tmp$4); const byte4 = utf8Arr[_tmp$4]; let _tmp$5; const _p$13 = 192; if ((byte2 & _p$13 & 255) !== 128) { _tmp$5 = true; } else { let _tmp$6; const _p$14 = 192; if ((byte3 & _p$14 & 255) !== 128) { _tmp$6 = true; } else { const _p$15 = 192; _tmp$6 = (byte4 & _p$15 & 255) !== 128; } _tmp$5 = _tmp$6; } if (_tmp$5) { return undefined; } i = i + 3 | 0; const _p$14 = 7; const _tmp$6 = (byte & _p$14 & 255) << 18; const _p$15 = 63; const _tmp$7 = _tmp$6 | (byte2 & _p$15 & 255) << 12; const _p$16 = 63; const _tmp$8 = _tmp$7 | (byte3 & _p$16 & 255) << 6; const _p$17 = 63; code_point = _tmp$8 | byte4 & _p$17 & 255; } else { return undefined; } } } } result = `${result}${_M0IPC14char4CharPB4Show10to__string(code_point)}`; i = i + 1 | 0; continue; } else { break; } } return result; } function _M0MP36zxch3n5flock5types7Utf8Str10to__string(self) { const _p = _M0FP36zxch3n5flock5types23new__string__from__utf8(self.bytes); if (_p === undefined) { return $panic(); } else { const _p$2 = _p; return _p$2; } } function _M0FP36zxch3n5flock5types14compare__bytes(b1, b2) { const n1 = b1.end - b1.start | 0; const n2 = b2.end - b2.start | 0; const n = n1 < n2 ? n1 : n2; let _tmp = 0; while (true) { const i = _tmp; if (i < n) { const _p = _M0MPC15bytes9BytesView2at(b1, i); const _p$2 = _M0MPC15bytes9BytesView2at(b2, i); const cmp = $compare_int(_p, _p$2); if (cmp !== 0) { return cmp; } _tmp = i + 1 | 0; continue; } else { break; } } return $compare_int(n1, n2); } function _M0IP36zxch3n5flock5types7Utf8StrPB7Compare7compare(self, other) { const _bind = self.bytes; const _tmp = new _M0TPC15bytes9BytesView(_bind, 0, _bind.length); const _bind$2 = other.bytes; return _M0FP36zxch3n5flock5types14compare__bytes(_tmp, new _M0TPC15bytes9BytesView(_bind$2, 0, _bind$2.length)); } function _M0IP36zxch3n5flock5types6NBytesPB7Compare7compare(self, other) { const _bind = self; const _tmp = new _M0TPC15bytes9BytesView(_bind, 0, _bind.length); const _bind$2 = other; return _M0FP36zxch3n5flock5types14compare__bytes(_tmp, new _M0TPC15bytes9BytesView(_bind$2, 0, _bind$2.length)); } function _M0FP36zxch3n5flock13memcomparable21uint64__to__be__bytes(n) { const bytes = _M0MPC15array5Array11new_2einnerGyE(0); const _p = BigInt.asUintN(64, BigInt.asUintN(64, BigInt.asUintN(64, n) >> BigInt(56 & 63)) & 255n); _M0MPC15array5Array4pushGyE(bytes, (Number(BigInt.asIntN(32, _p)) | 0) & 255); const _p$2 = BigInt.asUintN(64, BigInt.asUintN(64, BigInt.asUintN(64, n) >> BigInt(48 & 63)) & 255n); _M0MPC15array5Array4pushGyE(bytes, (Number(BigInt.asIntN(32, _p$2)) | 0) & 255); const _p$3 = BigInt.asUintN(64, BigInt.asUintN(64, BigInt.asUintN(64, n) >> BigInt(40 & 63)) & 255n); _M0MPC15array5Array4pushGyE(bytes, (Number(BigInt.asIntN(32, _p$3)) | 0) & 255); const _p$4 = BigInt.asUintN(64, BigInt.asUintN(64, BigInt.asUintN(64, n) >> BigInt(32 & 63)) & 255n); _M0MPC15array5Array4pushGyE(bytes, (Number(BigInt.asIntN(32, _p$4)) | 0) & 255); const _p$5 = BigInt.asUintN(64, BigInt.asUintN(64, BigInt.asUintN(64, n) >> BigInt(24 & 63)) & 255n); _M0MPC15array5Array4pushGyE(bytes, (Number(BigInt.asIntN(32, _p$5)) | 0) & 255); const _p$6 = BigInt.asUintN(64, BigInt.asUintN(64, BigInt.asUintN(64, n) >> BigInt(16 & 63)) & 255n); _M0MPC15array5Array4pushGyE(bytes, (Number(BigInt.asIntN(32, _p$6)) | 0) & 255); const _p$7 = BigInt.asUintN(64, BigInt.asUintN(64, BigInt.asUintN(64, n) >> BigInt(8 & 63)) & 255n); _M0MPC15array5Array4pushGyE(bytes, (Number(BigInt.asIntN(32, _p$7)) | 0) & 255); const _p$8 = BigInt.asUintN(64, n & 255n); _M0MPC15array5Array4pushGyE(bytes, (Number(BigInt.asIntN(32, _p$8)) | 0) & 255); return _M0MPC15bytes5Bytes11from__array(new _M0TPB9ArrayViewGyE(bytes, 0, bytes.length)); } function _M0FP36zxch3n5flock13memcomparable23uint64__from__be__bytes(bytes) { if (bytes.length !== 8) { _M0FP26zxch3n6expect13panic_2einnerGuE("Invalid byte array length", "moon/memcomparable/utils.mbt:28:5-28:54@zxch3n/flock"); } let result = 0n; const _tmp = result; $bound_check(bytes, 0); result = BigInt.asUintN(64, _tmp | BigInt.asUintN(64, _M0MPC14byte4Byte10to__uint64(bytes[0]) << BigInt(56 & 63))); const _tmp$2 = result; $bound_check(bytes, 1); result = BigInt.asUintN(64, _tmp$2 | BigInt.asUintN(64, _M0MPC14byte4Byte10to__uint64(bytes[1]) << BigInt(48 & 63))); const _tmp$3 = result; $bound_check(bytes, 2); result = BigInt.asUintN(64, _tmp$3 | BigInt.asUintN(64, _M0MPC14byte4Byte10to__uint64(bytes[2]) << BigInt(40 & 63))); const _tmp$4 = result; $bound_check(bytes, 3); result = BigInt.asUintN(64, _tmp$4 | BigInt.asUintN(64, _M0MPC14byte4Byte10to__uint64(bytes[3]) << BigInt(32 & 63))); const _tmp$5 = result; $bound_check(bytes, 4); result = BigInt.asUintN(64, _tmp$5 | BigInt.asUintN(64, _M0MPC14byte4Byte10to__uint64(bytes[4]) << BigInt(24 & 63))); const _tmp$6 = result; $bound_check(bytes, 5); result = BigInt.asUintN(64, _tmp$6 | BigInt.asUintN(64, _M0MPC14byte4Byte10to__uint64(bytes[5]) << BigInt(16 & 63))); const _tmp$7 = result; $bound_check(bytes, 6); result = BigInt.asUintN(64, _tmp$7 | BigInt.asUintN(64, _M0MPC14byte4Byte10to__uint64(bytes[6]) << BigInt(8 & 63))); const _tmp$8 = result; $bound_check(bytes, 7); result = BigInt.asUintN(64, _tmp$8 | _M0MPC14byte4Byte10to__uint64(bytes[7])); return result; } function _M0MP36zxch3n5flock13memcomparable3Key3new() { return new _M0TP36zxch3n5flock13memcomparable3Key(_M0MPC15array5Array11new_2einnerGRPB4JsonE(0)); } function _M0MP36zxch3n5flock13memcomparable3Key4push(self, part) { _M0MPC15array5Array4pushGRPB4JsonE(self.parts, part); } function _M0FP36zxch3n5flock13memcomparable14compare__bytes(b1, b2) { const n1 = b1.end - b1.start | 0; const n2 = b2.end - b2.start | 0; const n = n1 < n2 ? n1 : n2; let _tmp = 0; while (true) { const i = _tmp; if (i < n) { const _p = _M0MPC15bytes9BytesView2at(b1, i); const _p$2 = _M0MPC15bytes9BytesView2at(b2, i); const cmp = $compare_int(_p, _p$2); if (cmp !== 0) { return cmp; } _tmp = i + 1 | 0; continue; } else { break; } } return $compare_int(n1, n2); } function _M0FP36zxch3n5flock13memcomparable17canonicalize__f64(n) { return n !== n ? (n < 0 ? -_M0FPC16double14not__a__number : _M0FPC16double14not__a__number) : n; } function _M0FP36zxch3n5flock13memcomparable13encode__bytes(bytes, output) { _M0MPC16buffer6Buffer11write__byte(output, 1); const _bind = bytes.end - bytes.start | 0; let _tmp = 0; while (true) { const _ = _tmp; if (_ < _bind) { const b = bytes.bytes[bytes.start + _ | 0]; _M0MPC16buffer6Buffer11write__byte(output, b); const _p = 0; if (b === _p) { _M0MPC16buffer6Buffer11write__byte(output, 255); } _tmp = _ + 1 | 0; continue; } else { break; } } _M0MPC16buffer6Buffer11write__byte(output, 0); } function _M0FP36zxch3n5flock13memcomparable14encode__string(s, output) { _M0MPC16buffer6Buffer11write__byte(output, 2); const bytes = s.bytes; const _bind = bytes.length; let _tmp = 0; while (true) { const _ = _tmp; if (_ < _bind) { const b = bytes[_]; _M0MPC16buffer6Buffer11write__byte(output, b); const _p = 0; if (b === _p) { _M0MPC16buffer6Buffer11write__byte(output, 255); } _tmp = _ + 1 | 0; continue; } else { break; } } _M0MPC16buffer6Buffer11write__byte(output, 0); } function _M0FP36zxch3n5flock13memcomparable13encode__float(f, output) { _M0MPC16buffer6Buffer11write__byte(output, 33); const f$2 = _M0FP36zxch3n5flock13memcomparable17canonicalize__f64(f); const raw = $f64_reinterpret_i64(f$2); const bits = BigInt.asUintN(64, BigInt.asUintN(64, raw & 9223372036854775808n)) !== BigInt.asUintN(64, 0n) ? BigInt.asUintN(64, raw ^ 18446744073709551615n) : BigInt.asUintN(64, raw ^ 9223372036854775808n); const bytes = _M0FP36zxch3n5flock13memcomparable21uint64__to__be__bytes(bits); const _bind = bytes.length; let _tmp = 0; while (true) { const _ = _tmp; if (_ < _bind) { const b = bytes[_]; _M0MPC16buffer6Buffer11write__byte(output, b); _tmp = _ + 1 | 0; continue; } else { return; } } } function _M0FP36zxch3n5flock13memcomparable22biguint__to__be__bytes(n) { const bytes = []; let x = n; while (true) { if (_M0IP016_24default__implPB7Compare6op__gtGRPC16bigint6BigIntE(x, 0n)) { const byte = _M0MPC16bigint6BigInt7to__int(_M0IPC16bigint6BigIntPB3Mod3mod(x, 256n)); _M0MPC15array5Array4pushGyE(bytes, byte & 255); x = _M0IPC16bigint6BigIntPB3Div3div(x, 256n); continue; } else { break; } } const _bind = _M0MPC15array5Array3revGyE(bytes); return _M0MPC15bytes5Bytes11from__array(new _M0TPB9ArrayViewGyE(_bind, 0, _bind.length)); } function _M0FP36zxch3n5flock13memcomparable21bigint__to__be__bytes(n, output) { if (_M0IPC16bigint6BigIntPB2Eq5equal(n, 0n)) { _M0MPC16buffer6Buffer11write__byte(output, 20); return undefined; } const sign = _M0IP016_24default__implPB7Compare6op__gtGRPC16bigint6BigIntE(n, 0n); const bytes = sign ? _M0FP36zxch3n5flock13memcomparable22biguint__to__be__bytes(n) : _M0FP36zxch3n5flock13memcomparable22biguint__to__be__bytes(_M0IPC16bigint6BigIntPB3Neg3neg(n)); const n$2 = bytes.length; if (sign === false) { if (n$2 <= 8) { const _p = 20; const _p$2 = n$2 & 255; _M0MPC16buffer6Buffer11write__byte(output, (_p - _p$2 | 0) & 255); } else { _M0MPC16buffer6Buffer11write__byte(output, 11); if (n$2 > 255) { _M0FPC15abort5abortGuE("n is too large"); } const _p = n$2 & 255; const _p$2 = 255; _M0MPC16buffer6Buffer11write__byte(output, (_p ^ _p$2) & 255); } const inverted = _M0FPC16buffer11new_2einner(0); let _tmp = 0; while (true) { const i = _tmp; if (i < bytes.length) { $bound_check(bytes, i); const _p = bytes[i]; const _p$2 = 255; _M0MPC16buffer6Buffer11write__byte(inverted, (_p ^ _p$2) & 255); _tmp = i + 1 | 0; continue; } else { break; } } const _bind = _M0MPC16buffer6Buffer9to__bytes(inverted); _M0MPC16buffer6Buffer12write__bytes(output, new _M0TPC15bytes9BytesView(_bind, 0, _bind.length)); return; } else { if (n$2 <= 8) { const _p = 20; const _p$2 = n$2 & 255; _M0MPC16buffer6Buffer11write__byte(output, (_p + _p$2 | 0) & 255); } else { _M0MPC16buffer6Buffer11write__byte(output, 29); if (n$2 > 255) { _M0FPC15abort5abortGuE("n is too large"); } _M0MPC16buffer6Buffer11write__byte(output, n$2 & 255); } _M0MPC16buffer6Buffer12write__bytes(output, new _M0TPC15bytes9BytesView(bytes, 0, bytes.length)); return; } } function _M0MP36zxch3n5flock13memcomparable7KeyPart20encode__with__output(self, output) { switch (self.$tag) { case 0: { const _Bytes = self; const _bytes = _Bytes._0; const _bind = _bytes; _M0FP36zxch3n5flock13memcomparable13encode__bytes(new _M0TPC15bytes9BytesView(_bind, 0, _bind.length), output); return; } case 1: { const _String = self; const _s = _String._0; _M0FP36zxch3n5flock13memcomparable14encode__string(_s, output); return; } case 2: { const _Int = self; const _n = _Int._0; _M0FP36zxch3n5flock13memcomparable21bigint__to__be__bytes(_n, output); return; } case 3: { const _Float = self; const _f = _Float._0; _M0FP36zxch3n5flock13memcomparable13encode__float(_f, output); return; } case 4: { _M0MPC16buffer6Buffer11write__byte(output, 38); return; } default: { _M0MPC16buffer6Buffer11write__byte(output, 39); return; } } } function _M0MP36zxch3n5flock13memcomparable3Key6encode(self) { const output = _M0FPC16buffer11new_2einner(0); const _bind = self.parts; const _bind$2 = _bind.length; let _tmp = 0; while (true) { const _ = _tmp; if (_ < _bind$2) { const part = _bind[_]; _M0MP36zxch3n5flock13memcomparable7KeyPart20encode__with__output(part, output); _tmp = _ + 1 | 0; continue; } else { break; } } return _M0MPC16buffer6Buffer9to__bytes(output); } function _M0FP36zxch3n5flock13memcomparable12parse__slice(bytes, start) { const output = _M0FPC16buffer11new_2einner(0); let i = start; while (true) { if (i < (bytes.end - bytes.start | 0)) { const b = _M0MPC15bytes9BytesView2at(bytes, i); i = i + 1 | 0; const _p = 0; if (b === _p) { let _tmp; if (i < (bytes.end - bytes.start | 0)) { const _p$2 = _M0MPC15bytes9BytesView2at(bytes, i); const _p$3 = 255; _tmp = _p$2 === _p$3; } else { _tmp = false; } if (_tmp) { _M0MPC16buffer6Buffer11write__byte(output, 0); i = i + 1 | 0; continue; } else { const _bind = _M0MPC16buffer6Buffer9to__bytes(output); return new _M0DTPC16result6ResultGURPC15bytes9BytesViewiERP36zxch3n5flock13memcomparable8KeyErrorE2Ok({ _0: new _M0TPC15bytes9BytesView(_bind, 0, _bind.length), _1: i }); } } _M0MPC16buffer6Buffer11write__byte(output, b); continue; } else { break; } } return new _M0DTPC16result6ResultGURPC15bytes9BytesViewiERP36zxch3n5flock13memcomparable8KeyErrorE3Err(_M0DTPC15error5Error57zxch3n_2fflock_2fmemcomparable_2eKeyError_2eUnexpectedEOF__); } function _M0FP36zxch3n5flock13memcomparable17bytes__to__bigint(bytes) { let n = _M0MPC16bigint6BigInt11from__int64(0n); let base = _M0MPC16bigint6BigInt11from__int64(1n); let _tmp = (bytes.end - bytes.start | 0) - 1 | 0; while (true) { const i = _tmp; if (i >= 0) { const byte_val = _M0MPC16bigint6BigInt11from__int64(BigInt.asUintN(64, BigInt(_M0MPC15bytes9BytesView2at(bytes, i)))); n = _M0IPC16bigint6BigIntPB3Add3add(n, _M0IPC16bigint6BigIntPB3Mul3mul(base, byte_val)); base = _M0IPC16bigint6BigIntPB3Mul3mul(base, _M0MPC16bigint6BigInt11from__int64(256n)); _tmp = i - 1 | 0; continue; } else { break; } } return n; } function _M0FP36zxch3n5flock13memcomparable34bigint__from__be__bytes__with__tag(bytes, tag) { let _tmp; if (20 <= tag) { const _p = 20; const _p$2 = 8 & 255; _tmp = tag <= ((_p + _p$2 | 0) & 255); } else { _tmp = false; } if (_tmp) { const _p = 20; const n = (tag - _p | 0) & 255; if ((bytes.end - bytes.start | 0) < n) { return new _M0DTPC16result6ResultGURPC15bytes9BytesViewRPC16bigint6BigIntERP36zxch3n5flock13memcomparable8KeyErrorE3Err(_M0DTPC15error5Error57zxch3n_2fflock_2fmemcomparable_2eKeyError_2eUnexpectedEOF__); } const num_bytes = _M0MPC15bytes9BytesView12view_2einner(bytes, 0, n); const rest = _M0MPC15bytes9BytesView12view_2einner(bytes, n, undefined); return new _M0DTPC16result6ResultGURPC15bytes9BytesViewRPC16bigint6BigIntERP36zxch3n5flock13memcomparable8KeyErrorE2Ok({ _0: rest, _1: _M0FP36zxch3n5flock13memcomparable17bytes__to__bigint(num_bytes) }); } else { let _tmp$2; const _p = 20; const _p$2 = 8 & 255; if (((_p - _p$2 | 0) & 255) <= tag) { _tmp$2 = tag < 20; } else { _tmp$2 = false; } if (_tmp$2) { const _p$3 = 20; const n = (_p$3 - tag | 0) & 255; if ((bytes.end - bytes.start | 0) < n) { return new _M0DTPC16result6ResultGURPC15bytes9BytesViewRPC16bigint6BigIntERP36zxch3n5flock13memcomparable8KeyErrorE3Err(_M0DTPC15error5Error57zxch3n_2fflock_2fmemcomparable_2eKeyError_2eUnexpectedEOF__); } const num_bytes = _M0MPC15bytes9BytesView12view_2einner(bytes, 0, n); const rest = _M0MPC15bytes9BytesView12view_2einner(bytes, n, undefined); const inverted = _M0FPC16buffer11new_2einner(0); let _tmp$3 = 0; while (true) { const i = _tmp$3; if (i < (num_bytes.end - num_bytes.start | 0)) { const _p$4 = _M0MPC15bytes9BytesView2at(num_bytes, i); const _p$5 = 255; _M0MPC16buffer6Buffer11write__byte(inverted, (_p$4 ^ _p$5) & 255); _tmp$3 = i + 1 | 0; continue; } else { break; } } const _bind = _M0MPC16buffer6Buffer9to__bytes(inverted); return new _M0DTPC16result6ResultGURPC15bytes9BytesViewRPC16bigint6BigIntERP36zxch3n5flock13memcomparable8KeyErrorE2Ok({ _0: rest, _1: _M0IPC16bigint6BigIntPB3Neg3neg(_M0FP36zxch3n5flock13memcomparable17bytes__to__bigint(new _M0TPC15bytes9BytesView(_bind, 0, _bind.length))) }); } else { const _p$3 = 11; if (tag === _p$3) { if ((bytes.end - bytes.start | 0) < 1) { return new _M0DTPC16result6ResultGURPC15bytes9BytesViewRPC16bigint6BigIntERP36zxch3n5flock13memcomparable8KeyErrorE3Err(_M0DTPC15error5Error57zxch3n_2fflock_2fmemcomparable_2eKeyError_2eUnexpectedEOF__); } const raw_length = _M0MPC15bytes9BytesView2at(bytes, 0); const _p$4 = 255; const n = (raw_length ^ _p$4) & 255; if ((bytes.end - bytes.start | 0) < (n + 1 | 0)) { return new _M0DTPC16result6ResultGURPC15bytes9BytesViewRPC16bigint6BigIntERP36zxch3n5flock13memcomparable8KeyErrorE3Err(_M0DTPC15error5Error57zxch3n_2fflock_2fmemcomparable_2eKeyError_2eUnexpectedEOF__); } const num_bytes = _M0MPC15bytes9BytesView12view_2einner(bytes, 1, n + 1 | 0); const rest = _M0MPC15bytes9BytesView12view_2einner(bytes, n + 1 | 0, undefined); const inverted = _M0FPC16buffer11new_2einner(0); let _tmp$3 = 0; while (true) { const i = _tmp$3; if (i < (num_bytes.end - num_bytes.start | 0)) { const _p$5 = _M0MPC15bytes9BytesView2at(num_bytes, i); const _p$6 = 255; _M0MPC16buffer6Buffer11write__byte(inverted, (_p$5 ^ _p$6) & 255); _tmp$3 = i + 1 | 0; continue; } else { break; } } const _bind = _M0MPC16buffer6Buffer9to__bytes(inverted); return new _M0DTPC16result6ResultGURPC15bytes9BytesViewRPC16bigint6BigIntERP36zxch3n5flock13memcomparable8KeyErrorE2Ok({ _0: rest, _1: _M0IPC16bigint6BigIntPB3Neg3neg(_M0FP36zxch3n5flock13memcomparable17bytes__to__bigint(new _M0TPC15bytes9BytesView(_bind, 0, _bind.length))) }); } else { const _p$4 = 29; if (tag === _p$4) { if ((bytes.end - bytes.start | 0) < 1) { return new _M0DTPC16result6ResultGURPC15bytes9BytesViewRPC16bigint6BigIntERP36zxch3n5flock13memcomparable8KeyErrorE3Err(_M0DTPC15error5Error57zxch3n_2fflock_2fmemcomparable_2eKeyError_2eUnexpectedEOF__); } const raw_length = _M0MPC15bytes9BytesView2at(bytes, 0); const n = raw_length; if ((bytes.end - bytes.start | 0) < (n + 1 | 0)) { return new _M0DTPC16result6ResultGURPC15bytes9BytesViewRPC16bigint6BigIntERP36zxch3n5flock13memcomparable8KeyErrorE3Err(_M0DTPC15error5Error57zxch3n_2fflock_2fmemcomparable_2eKeyError_2eUnexpectedEOF__); } const num_bytes = _M0MPC15bytes9BytesView12view_2einner(bytes, 1, n + 1 | 0); const rest = _M0MPC15bytes9BytesView12view_2einner(bytes, n + 1 | 0, undefined); return new _M0DTPC16result6ResultGURPC15bytes9BytesViewRPC16bigint6BigIntERP36zxch3n5flock13memcomparable8KeyErrorE2Ok({ _0: rest, _1: _M0FP36zxch3n5flock13memcomparable17bytes__to__bigint(num_bytes) }); } else { return new _M0DTPC16result6ResultGURPC15bytes9BytesViewRPC16bigint6BigIntERP36zxch3n5flock13memcomparable8KeyErrorE3Err(new _M0DTPC15error5Error54zxch3n_2fflock_2fmemcomparable_2eKeyError_2eInvalidTag(tag)); } } } } } function _M0FP36zxch3n5flock13memcomparable13decode__float(bytes, start) { if ((start + 8 | 0) > (bytes.end - bytes.start | 0)) { return new _M0DTPC16result6ResultGUdiERP36zxch3n5flock13memcomparable8KeyErrorE3Err(_M0DTPC15error5Error57zxch3n_2fflock_2fmemcomparable_2eKeyError_2eUnexpectedEOF__); } const data = _M0MPC15array5Array11new_2einnerGyE(0); let _tmp = 0; while (true) { const i = _tmp; if (i < 8) { _M0MPC15array5Array4pushGyE(data, _M0MPC15bytes9BytesView2at(bytes, start + i | 0)); _tmp = i + 1 | 0; continue; } else { break; } } const bits = _M0FP36zxch3n5flock13memcomparable23uint64__from__be__bytes(_M0MPC15bytes5Bytes11from__array(new _M0TPB9ArrayViewGyE(data, 0, data.length))); let f; if (BigInt.asUintN(64, BigInt.asUintN(64, bits & 9223372036854775808n)) === BigInt.asUintN(64, 0n)) { const _p = BigInt.asUintN(64, bits ^ 18446744073709551615n); f = $i64_reinterpret_f64(_p); } else { const _p = BigInt.asUintN(64, bits ^ 9223372036854775808n); f = $i64_reinterpret_f64(_p); } if (f !== f) { return new _M0DTPC16result6ResultGUdiERP36zxch3n5flock13memcomparable8KeyErrorE3Err(_M0DTPC15error5Error55zxch3n_2fflock_2fmemcomparable_2eKeyError_2eNaNFloatKey__); } return new _M0DTPC16result6ResultGUdiERP36zxch3n5flock13memcomparable8KeyErrorE2Ok({ _0: f, _1: start + 8 | 0 }); } function _M0MP36zxch3n5flock13memcomparable3Key6decode(bytes) { const key = _M0MP36zxch3n5flock13memcomparable3Key3new(); let i = 0; while (true) { if (i < (bytes.end - bytes.start | 0)) { const tag = _M0MPC15bytes9BytesView2at(bytes, i); i = i + 1 | 0; if (tag === 2) { const _bind = _M0FP36zxch3n5flock13memcomparable12parse__slice(bytes, i); let _bind$2; if (_bind.$tag === 1) { const _ok = _bind; _bind$2 = _ok._0; } else { return _bind; } const _data = _bind$2._0; const _next_i = _bind$2._1; const _bind$3 = _M0MP36zxch3n5flock5types7Utf8Str17from__bytes__view(_data); if (_bind$3 === undefined) { return new _M0DTPC16result6ResultGRP36zxch3n5flock13memcomparable3KeyRP36zxch3n5flock13memcomparable8KeyErrorE3Err(_M0DTPC15error5Error55zxch3n_2fflock_2fmemcomparable_2eKeyError_2eInvalidUTF8__); } else { const _Some = _bind$3; const _s = _Some; _M0MP36zxch3n5flock13memcomparable3Key4push(key, new _M0DTP36zxch3n5flock13memcomparable7KeyPart6String(_s)); } i = _next_i; } else { if (tag === 1) { const _bind = _M0FP36zxch3n5flock13memcomparable12parse__slice(bytes, i); let _bind$2; if (_bind.$tag === 1) { const _ok = _bind; _bind$2 = _ok._0; } else { return _bind; } const _data = _bind$2._0; const _next_i = _bind$2._1; _M0MP36zxch3n5flock13memcomparable3Key4push(key, new _M0DTP36zxch3n5flock13memcomparable7KeyPart5Bytes(_M0MPC15bytes5Bytes10from__iter(_M0MPC15bytes9BytesView4iter(_data)))); i = _next_i; } else { if (tag >= 11 && tag <= 29) { const _bind = _M0FP36zxch3n5flock13memcomparable34bigint__from__be__bytes__with__tag(_M0MPC15bytes9BytesView12view_2einner(bytes, i, undefined), tag); let _bind$2; if (_bind.$tag === 1) { const _ok = _bind; _bind$2 = _ok._0; } else { return _bind; } const _view = _bind$2._0; const _data = _bind$2._1; _M0MP36zxch3n5flock13memcomparable3Key4push(key, new _M0DTP36zxch3n5flock13memcomparable7KeyPart3Int(_data)); i = (bytes.end - bytes.start | 0) - (_view.end - _view.start | 0) | 0; } else { if (tag === 33) { const _bind = _M0FP36zxch3n5flock13memcomparable13decode__float(bytes, i); let _bind$2; if (_bind.$tag === 1) { const _ok = _bind; _bind$2 = _ok._0; } else { return _bind; } const _data = _bind$2._0; const _next_i = _bind$2._1; _M0MP36zxch3n5flock13memcomparable3Key4push(key, new _M0DTP36zxch3n5flock13memcomparable7KeyPart5Float(_data)); i = _next_i; } else { if (tag === 38) { _M0MP36zxch3n5flock13memcomparable3Key4push(key, _M0DTP36zxch3n5flock13memcomparable7KeyPart5False__); } else { if (tag === 39) { _M0MP36zxch3n5flock13memcomparable3Key4push(key, _M0DTP36zxch3n5flock13memcomparable7KeyPart4True__); } else { return new _M0DTPC16result6ResultGRP36zxch3n5flock13memcomparable3KeyRP36zxch3n5flock13memcomparable8KeyErrorE3Err(new _M0DTPC15error5Error54zxch3n_2fflock_2fmemcomparable_2eKeyError_2eInvalidTag(tag)); } } } } } } continue; } else { break; } } return new _M0DTPC16result6ResultGRP36zxch3n5flock13memcomparable3KeyRP36zxch3n5flock13memcomparable8KeyErrorE2Ok(key); } function _M0FP36zxch3n5flock13memcomparable19json__to__key__part(part) { switch (part.$tag) { case 3: { const _Number = part; const _n = _Number._0; return _M0MPC16double6Double7to__int(_n) + 0 === _n ? new _M0DTP36zxch3n5flock13memcomparable7KeyPart3Int(_M0MPC16bigint6BigInt9from__int(_M0MPC16double6Double7to__int(_n))) : new _M0DTP36zxch3n5flock13memcomparable7KeyPart5Float(_n); } case 4: { const _String = part; const _s = _String._0; return new _M0DTP36zxch3n5flock13memcomparable7KeyPart6String(_M0MP36zxch3n5flock5types7Utf8Str12from__string(_s)); } case 1: { return _M0DTP36zxch3n5flock13memcomparable7KeyPart4True__; } case 2: { return _M0DTP36zxch3n5flock13memcomparable7KeyPart5False__; } default: { return undefined; } } } function _M0FP36zxch3n5flock13memcomparable19key__part__to__json(part) { switch (part.$tag) { case 3: { const _Float = part; const _f = _Float._0; const _p = undefined; return new _M0DTPB4Json6Number(_f, _p); } case 2: { const _Int = part; const _n = _Int._0; const _p$2 = $f64_convert_i64(BigInt.asIntN(64, _M0MPC16bigint6BigInt9to__int64(_n))); const _p$3 = undefined; return new _M0DTPB4Json6Number(_p$2, _p$3); } case 1: { const _String = part; const _s = _String._0; const _p$4 = _M0MP36zxch3n5flock5types7Utf8Str10to__string(_s); return new _M0DTPB4Json6String(_p$4); } case 5: { const _p$5 = true; return _p$5 ? _M0DTPB4Json4True__ : _M0DTPB4Json5False__; } case 4: { const _p$6 = false; return _p$6 ? _M0DTPB4Json4True__ : _M0DTPB4Json5False__; } default: { return undefined; } } } function _M0FP36zxch3n5flock13memcomparable17encode__json__key(parts) { const key = _M0MP36zxch3n5flock13memcomparable3Key3new(); const _bind = parts.length; let _tmp = 0; while (true) { const _ = _tmp; if (_ < _bind) { const part = parts[_]; const part$2 = _M0FP36zxch3n5flock13memcomparable19json__to__key__part(part); if (part$2 === undefined) { return undefined; } const _tmp$2 = key.parts; let _tmp$3; if (part$2 === undefined) { _tmp$3 = $panic(); } else { const _p = part$2; _tmp$3 = _p; } _M0MPC15array5Array4pushGRPB4JsonE(_tmp$2, _tmp$3); _tmp = _ + 1 | 0; continue; } else { break; } } return _M0MP36zxch3n5flock13memcomparable3Key6encode(key); } function _M0FP36zxch3n5flock13memcomparable21decode__key__to__json(bytes) { let key; let _try_err; _L: { _L$2: { const _bind = _M0MP36zxch3n5flock13memcomparable3Key6decode(new _M0TPC15bytes9BytesView(bytes, 0, bytes.length)); if (_bind.$tag === 1) { const _ok = _bind; key = _ok._0; } else { const _err = _bind; _try_err = _err._0; break _L$2; } break _L; } key = _M0FPC15abort5abortGRP36zxch3n5flock5types7Utf8StrE("Failed to decode key"); } const parts = _M0MPC15array5Array11new_2einnerGRPB4JsonE(0); const _bind = key.parts; const _bind$2 = _bind.length; let _tmp = 0; while (true) { const _ = _tmp; if (_ < _bind$2) { const part = _bind[_]; const _p = _M0FP36zxch3n5flock13memcomparable19key__part__to__json(part); let _tmp$2; if (_p === undefined) { _tmp$2 = $panic(); } else { const _p$2 = _p; _tmp$2 = _p$2; } _M0MPC15array5Array4pushGRPB4JsonE(parts, _tmp$2); _tmp = _ + 1 | 0; continue; } else { break; } } return parts; } function _M0MP36zxch3n5flock11sorted__map9SortedMap4eachN3dfsS148GRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(f, root) { let _tmp = root; while (true) { const root$2 = _tmp; if (root$2 === undefined) { return; } else { const _Some = root$2; const _root = _Some; _M0MP36zxch3n5flock11sorted__map9SortedMap4eachN3dfsS148GRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(f, _root.left); f(_root.key, _root.value); _tmp = _root.right; continue; } } } function _M0MP36zxch3n5flock11sorted__map9SortedMap4eachGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(self, f) { _M0MP36zxch3n5flock11sorted__map9SortedMap4eachN3dfsS148GRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(f, self.root); } function _M0MP36zxch3n5flock11sorted__map9SortedMap9to__arrayGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(self) { const arr = _M0MPC15array5Array11new_2einnerGRPB4JsonE(self.size); _M0MP36zxch3n5flock11sorted__map9SortedMap4eachGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(self, (k, v) => { _M0MPC15array5Array4pushGRPB4JsonE(arr, { _0: k, _1: v }); }); return arr; } function _M0MP36zxch3n5flock11sorted__map9SortedMap3newGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE() { return new _M0TP36zxch3n5flock11sorted__map9SortedMapGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(undefined, 0); } function _M0MP36zxch3n5flock11sorted__map9SortedMap3newGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE() { return new _M0TP36zxch3n5flock11sorted__map9SortedMapGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(undefined, 0); } function _M0FP36zxch3n5flock11sorted__map10height__geGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(x1, x2) { if (x2 === undefined) { return true; } else { const _Some = x2; const _n2 = _Some; if (x1 === undefined) { return false; } else { const _Some$2 = x1; const _n1 = _Some$2; return _n1.height >= _n2.height; } } } function _M0FP36zxch3n5flock11sorted__map10height__geGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(x1, x2) { if (x2 === undefined) { return true; } else { const _Some = x2; const _n2 = _Some; if (x1 === undefined) { return false; } else { const _Some$2 = x1; const _n1 = _Some$2; return _n1.height >= _n2.height; } } } function _M0MP36zxch3n5flock11sorted__map4Node14update__heightGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(self) { const _p = self.left; let _p$2; if (_p === undefined) { _p$2 = 0; } else { const _p$3 = _p; const _p$4 = _p$3; _p$2 = _p$4.height; } const _p$3 = self.right; let _p$4; if (_p$3 === undefined) { _p$4 = 0; } else { const _p$5 = _p$3; const _p$6 = _p$5; _p$4 = _p$6.height; } self.height = 1 + (_p$2 > _p$4 ? _p$2 : _p$4) | 0; } function _M0MP36zxch3n5flock11sorted__map4Node14update__heightGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(self) { const _p = self.left; let _p$2; if (_p === undefined) { _p$2 = 0; } else { const _p$3 = _p; const _p$4 = _p$3; _p$2 = _p$4.height; } const _p$3 = self.right; let _p$4; if (_p$3 === undefined) { _p$4 = 0; } else { const _p$5 = _p$3; const _p$6 = _p$5; _p$4 = _p$6.height; } self.height = 1 + (_p$2 > _p$4 ? _p$2 : _p$4) | 0; } function _M0FP36zxch3n5flock11sorted__map9rotate__lGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(n) { const _p = n.right; let r; if (_p === undefined) { r = $panic(); } else { const _p$2 = _p; r = _p$2; } n.right = r.left; r.left = n; _M0MP36zxch3n5flock11sorted__map4Node14update__heightGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(n); _M0MP36zxch3n5flock11sorted__map4Node14update__heightGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(r); return r; } function _M0FP36zxch3n5flock11sorted__map9rotate__lGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(n) { const _p = n.right; let r; if (_p === undefined) { r = $panic(); } else { const _p$2 = _p; r = _p$2; } n.right = r.left; r.left = n; _M0MP36zxch3n5flock11sorted__map4Node14update__heightGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(n); _M0MP36zxch3n5flock11sorted__map4Node14update__heightGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(r); return r; } function _M0FP36zxch3n5flock11sorted__map9rotate__rGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(n) { const _p = n.left; let l; if (_p === undefined) { l = $panic(); } else { const _p$2 = _p; l = _p$2; } n.left = l.right; l.right = n; _M0MP36zxch3n5flock11sorted__map4Node14update__heightGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(n); _M0MP36zxch3n5flock11sorted__map4Node14update__heightGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(l); return l; } function _M0FP36zxch3n5flock11sorted__map9rotate__rGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(n) { const _p = n.left; let l; if (_p === undefined) { l = $panic(); } else { const _p$2 = _p; l = _p$2; } n.left = l.right; l.right = n; _M0MP36zxch3n5flock11sorted__map4Node14update__heightGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(n); _M0MP36zxch3n5flock11sorted__map4Node14update__heightGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(l); return l; } function _M0FP36zxch3n5flock11sorted__map10rotate__lrGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(n) { const _p = n.left; let l; if (_p === undefined) { l = $panic(); } else { const _p$2 = _p; l = _p$2; } const v = _M0FP36zxch3n5flock11sorted__map9rotate__lGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(l); n.left = v; return _M0FP36zxch3n5flock11sorted__map9rotate__rGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(n); } function _M0FP36zxch3n5flock11sorted__map10rotate__lrGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(n) { const _p = n.left; let l; if (_p === undefined) { l = $panic(); } else { const _p$2 = _p; l = _p$2; } const v = _M0FP36zxch3n5flock11sorted__map9rotate__lGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(l); n.left = v; return _M0FP36zxch3n5flock11sorted__map9rotate__rGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(n); } function _M0FP36zxch3n5flock11sorted__map10rotate__rlGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(n) { const _p = n.right; let r; if (_p === undefined) { r = $panic(); } else { const _p$2 = _p; r = _p$2; } const v = _M0FP36zxch3n5flock11sorted__map9rotate__rGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(r); n.right = v; return _M0FP36zxch3n5flock11sorted__map9rotate__lGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(n); } function _M0FP36zxch3n5flock11sorted__map10rotate__rlGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(n) { const _p = n.right; let r; if (_p === undefined) { r = $panic(); } else { const _p$2 = _p; r = _p$2; } const v = _M0FP36zxch3n5flock11sorted__map9rotate__rGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(r); n.right = v; return _M0FP36zxch3n5flock11sorted__map9rotate__lGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(n); } function _M0FP36zxch3n5flock11sorted__map7balanceGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(root) { const l = root.left; const r = root.right; let hl; if (l === undefined) { hl = 0; } else { const _p = l; const _p$2 = _p; hl = _p$2.height; } let hr; if (r === undefined) { hr = 0; } else { const _p = r; const _p$2 = _p; hr = _p$2.height; } let new_root; if (hl > (hr + 1 | 0)) { let _bind; if (l === undefined) { _bind = $panic(); } else { const _p = l; _bind = _p; } const _ll = _bind.left; const _lr = _bind.right; new_root = _M0FP36zxch3n5flock11sorted__map10height__geGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(_ll, _lr) ? _M0FP36zxch3n5flock11sorted__map9rotate__rGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(root) : _M0FP36zxch3n5flock11sorted__map10rotate__lrGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(root); } else { if (hr > (hl + 1 | 0)) { let _bind; if (r === undefined) { _bind = $panic(); } else { const _p = r; _bind = _p; } const _rl = _bind.left; const _rr = _bind.right; new_root = _M0FP36zxch3n5flock11sorted__map10height__geGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(_rr, _rl) ? _M0FP36zxch3n5flock11sorted__map9rotate__lGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(root) : _M0FP36zxch3n5flock11sorted__map10rotate__rlGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(root); } else { new_root = root; } } _M0MP36zxch3n5flock11sorted__map4Node14update__heightGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(new_root); return new_root; } function _M0FP36zxch3n5flock11sorted__map7balanceGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(root) { const l = root.left; const r = root.right; let hl; if (l === undefined) { hl = 0; } else { const _p = l; const _p$2 = _p; hl = _p$2.height; } let hr; if (r === undefined) { hr = 0; } else { const _p = r; const _p$2 = _p; hr = _p$2.height; } let new_root; if (hl > (hr + 1 | 0)) { let _bind; if (l === undefined) { _bind = $panic(); } else { const _p = l; _bind = _p; } const _ll = _bind.left; const _lr = _bind.right; new_root = _M0FP36zxch3n5flock11sorted__map10height__geGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(_ll, _lr) ? _M0FP36zxch3n5flock11sorted__map9rotate__rGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(root) : _M0FP36zxch3n5flock11sorted__map10rotate__lrGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(root); } else { if (hr > (hl + 1 | 0)) { let _bind; if (r === undefined) { _bind = $panic(); } else { const _p = r; _bind = _p; } const _rl = _bind.left; const _rr = _bind.right; new_root = _M0FP36zxch3n5flock11sorted__map10height__geGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(_rr, _rl) ? _M0FP36zxch3n5flock11sorted__map9rotate__lGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(root) : _M0FP36zxch3n5flock11sorted__map10rotate__rlGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(root); } else { new_root = root; } } _M0MP36zxch3n5flock11sorted__map4Node14update__heightGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(new_root); return new_root; } function _M0FP36zxch3n5flock11sorted__map9new__nodeGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(key, value) { return new _M0TP36zxch3n5flock11sorted__map4NodeGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(key, value, undefined, undefined, 1); } function _M0FP36zxch3n5flock11sorted__map9new__nodeGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(key, value) { return new _M0TP36zxch3n5flock11sorted__map4NodeGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(key, value, undefined, undefined, 1); } function _M0FP36zxch3n5flock11sorted__map9add__nodeGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(root, key, value) { if (root === undefined) { return { _0: _M0FP36zxch3n5flock11sorted__map9new__nodeGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(key, value), _1: true }; } else { const _Some = root; const _n = _Some; if (_M0IP36zxch3n5flock5types7Utf8StrPB2Eq5equal(key, _n.key)) { _n.value = value; return { _0: _n, _1: false }; } else { const l = _n.left; const r = _n.right; if (_M0IP016_24default__implPB7Compare6op__ltGRP36zxch3n5flock5types7Utf8StrE(key, _n.key)) { const _bind = _M0FP36zxch3n5flock11sorted__map9add__nodeGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(l, key, value); const _nl = _bind._0; const _inserted = _bind._1; _n.left = _nl; return { _0: _M0FP36zxch3n5flock11sorted__map7balanceGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(_n), _1: _inserted }; } else { const _bind = _M0FP36zxch3n5flock11sorted__map9add__nodeGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(r, key, value); const _nr = _bind._0; const _inserted = _bind._1; _n.right = _nr; return { _0: _M0FP36zxch3n5flock11sorted__map7balanceGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(_n), _1: _inserted }; } } } } function _M0FP36zxch3n5flock11sorted__map9add__nodeGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(root, key, value) { if (root === undefined) { return { _0: _M0FP36zxch3n5flock11sorted__map9new__nodeGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(key, value), _1: true }; } else { const _Some = root; const _n = _Some; if (_M0IP36zxch3n5flock5types6NBytesPB2Eq5equal(key, _n.key)) { _n.value = value; return { _0: _n, _1: false }; } else { const l = _n.left; const r = _n.right; if (_M0IP016_24default__implPB7Compare6op__ltGRP36zxch3n5flock5types6NBytesE(key, _n.key)) { const _bind = _M0FP36zxch3n5flock11sorted__map9add__nodeGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(l, key, value); const _nl = _bind._0; const _inserted = _bind._1; _n.left = _nl; return { _0: _M0FP36zxch3n5flock11sorted__map7balanceGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(_n), _1: _inserted }; } else { const _bind = _M0FP36zxch3n5flock11sorted__map9add__nodeGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(r, key, value); const _nr = _bind._0; const _inserted = _bind._1; _n.right = _nr; return { _0: _M0FP36zxch3n5flock11sorted__map7balanceGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(_n), _1: _inserted }; } } } } function _M0MP36zxch3n5flock11sorted__map9SortedMap3setGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(self, key, value) { const _bind = _M0FP36zxch3n5flock11sorted__map9add__nodeGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(self.root, key, value); const _new_root = _bind._0; const _inserted = _bind._1; if (_M0IP016_24default__implPB2Eq10not__equalGORP36zxch3n5flock11sorted__map4NodeGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEEE(self.root, _new_root)) { self.root = _new_root; } if (_inserted) { self.size = self.size + 1 | 0; return; } else { return; } } function _M0MP36zxch3n5flock11sorted__map9SortedMap3setGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(self, key, value) { const _bind = _M0FP36zxch3n5flock11sorted__map9add__nodeGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(self.root, key, value); const _new_root = _bind._0; const _inserted = _bind._1; if (_M0IP016_24default__implPB2Eq10not__equalGORP36zxch3n5flock11sorted__map4NodeGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryEE(self.root, _new_root)) { self.root = _new_root; } if (_inserted) { self.size = self.size + 1 | 0; return; } else { return; } } function _M0MP36zxch3n5flock11sorted__map9SortedMap3getGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(self, key) { let _tmp = self.root; while (true) { const _param = _tmp; if (_param === undefined) { return undefined; } else { const _Some = _param; const _node = _Some; const cmp = _M0IP36zxch3n5flock5types6NBytesPB7Compare7compare(key, _node.key); if (cmp === 0) { return _node.value; } else { if (cmp > 0) { _tmp = _node.right; continue; } else { _tmp = _node.left; continue; } } } } } function _M0MP36zxch3n5flock11sorted__map9SortedMap3getGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(self, key) { let _tmp = self.root; while (true) { const _param = _tmp; if (_param === undefined) { return _M0DTPC16option6OptionGRPB5ArrayGRP36zxch3n5flock5flock5EntryEE4None__; } else { const _Some = _param; const _node = _Some; const cmp = _M0IP36zxch3n5flock5types7Utf8StrPB7Compare7compare(key, _node.key); if (cmp === 0) { return new _M0DTPC16option6OptionGRPB5ArrayGRP36zxch3n5flock5flock5EntryEE4Some(_node.value); } else { if (cmp > 0) { _tmp = _node.right; continue; } else { _tmp = _node.left; continue; } } } } } function _M0MP36zxch3n5flock11sorted__map9SortedMap5entryGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(self, key) { let _tmp = self.root; while (true) { const _param = _tmp; if (_param === undefined) { return { _0: undefined, _1: (v) => { _M0MP36zxch3n5flock11sorted__map9SortedMap3setGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(self, key, v); } }; } else { const _Some = _param; const _node = _Some; const cmp = _M0IP36zxch3n5flock5types6NBytesPB7Compare7compare(key, _node.key); if (cmp === 0) { return { _0: _node.value, _1: (v) => { _node.value = v; } }; } else { if (cmp > 0) { _tmp = _node.right; continue; } else { _tmp = _node.left; continue; } } } } } function _M0MP36zxch3n5flock11sorted__map9SortedMap2atGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(self, key) { let _tmp = self.root; while (true) { const _param = _tmp; if (_param === undefined) { return $panic(); } else { const _Some = _param; const _node = _Some; const cmp = _M0IP36zxch3n5flock5types7Utf8StrPB7Compare7compare(key, _node.key); if (cmp === 0) { return _node.value; } else { if (cmp > 0) { _tmp = _node.right; continue; } else { _tmp = _node.left; continue; } } } } } function _M0MP36zxch3n5flock11sorted__map9SortedMap8containsGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(self, key) { const _bind = _M0MP36zxch3n5flock11sorted__map9SortedMap3getGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(self, key); if (_bind.$tag === 1) { return true; } else { return false; } } function _M0MP36zxch3n5flock11sorted__map9SortedMap5iter2N10push__leftS115GRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(stack, node) { let _tmp = node; while (true) { const node$2 = _tmp; if (node$2 === undefined) { return; } else { const _Some = node$2; const _node = _Some; _M0MPC15array5Array4pushGRPB4JsonE(stack, _node); _tmp = _node.left; continue; } } } function _M0MP36zxch3n5flock11sorted__map9SortedMap5iter2N10push__leftS115GRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(stack, node) { let _tmp = node; while (true) { const node$2 = _tmp; if (node$2 === undefined) { return; } else { const _Some = node$2; const _node = _Some; _M0MPC15array5Array4pushGRPB4JsonE(stack, _node); _tmp = _node.left; continue; } } } function _M0MP36zxch3n5flock11sorted__map9SortedMap5iter2GRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(self) { const stack = _M0MPC15array5Array11new_2einnerGRPB4JsonE(0); _M0MP36zxch3n5flock11sorted__map9SortedMap5iter2N10push__leftS115GRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(stack, self.root); return _M0MPB5Iter23newGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(() => { const _bind = _M0MPC15array5Array3popGRP36zxch3n5flock11sorted__map4NodeGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEEE(stack); if (_bind === undefined) { return undefined; } else { const _Some = _bind; const _node = _Some; _M0MP36zxch3n5flock11sorted__map9SortedMap5iter2N10push__leftS115GRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(stack, _node.right); return { _0: _node.key, _1: _node.value }; } }, undefined); } function _M0MP36zxch3n5flock11sorted__map9SortedMap5iter2GRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(self) { const stack = _M0MPC15array5Array11new_2einnerGRPB4JsonE(0); _M0MP36zxch3n5flock11sorted__map9SortedMap5iter2N10push__leftS115GRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(stack, self.root); return _M0MPB5Iter23newGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(() => { const _bind = _M0MPC15array5Array3popGRP36zxch3n5flock11sorted__map4NodeGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEEE(stack); if (_bind === undefined) { return undefined; } else { const _Some = _bind; const _node = _Some; _M0MP36zxch3n5flock11sorted__map9SortedMap5iter2N10push__leftS115GRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(stack, _node.right); return { _0: _node.key, _1: _node.value }; } }, undefined); } function _M0MP36zxch3n5flock11sorted__map9SortedMap5rangeN10push__leftS92GRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(stack, node) { let _tmp = node; while (true) { const node$2 = _tmp; if (node$2 === undefined) { return; } else { const _Some = node$2; const _node = _Some; _M0MPC15array5Array4pushGRPB4JsonE(stack, _node); _tmp = _node.left; continue; } } } function _M0MP36zxch3n5flock11sorted__map9SortedMap5rangeN8push__geS95GRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(stack, node, lo, inclusive) { let _tmp = node; while (true) { const node$2 = _tmp; if (node$2 === undefined) { return; } else { const _Some = node$2; const _node = _Some; const cmp = _M0IP36zxch3n5flock5types6NBytesPB7Compare7compare(_node.key, lo); const ok = inclusive ? cmp >= 0 : cmp > 0; if (ok) { _M0MPC15array5Array4pushGRPB4JsonE(stack, _node); _tmp = _node.left; continue; } else { _tmp = _node.right; continue; } } } } function _M0MP36zxch3n5flock11sorted__map9SortedMap5rangeGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(self, low, high) { const stack = _M0MPC15array5Array11new_2einnerGRPB4JsonE(0); const ended = new _M0TPB8MutLocalGbE(false); switch (low.$tag) { case 2: { _M0MP36zxch3n5flock11sorted__map9SortedMap5rangeN10push__leftS92GRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(stack, self.root); break; } case 0: { const _Inclusive = low; const _lo = _Inclusive._0; _M0MP36zxch3n5flock11sorted__map9SortedMap5rangeN8push__geS95GRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(stack, self.root, _lo, true); break; } default: { const _Exclusive = low; const _lo$2 = _Exclusive._0; _M0MP36zxch3n5flock11sorted__map9SortedMap5rangeN8push__geS95GRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(stack, self.root, _lo$2, false); } } return _M0MPB5Iter23newGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(() => { if (ended.val) { return undefined; } const _bind = _M0MPC15array5Array3popGRP36zxch3n5flock11sorted__map4NodeGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEEE(stack); if (_bind === undefined) { return undefined; } else { const _Some = _bind; const _node = _Some; _M0MP36zxch3n5flock11sorted__map9SortedMap5rangeN10push__leftS92GRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(stack, _node.right); let within_high; switch (high.$tag) { case 2: { within_high = true; break; } case 0: { const _Inclusive$2 = high; const _hi = _Inclusive$2._0; within_high = _M0IP36zxch3n5flock5types6NBytesPB7Compare7compare(_node.key, _hi) <= 0; break; } default: { const _Exclusive$2 = high; const _hi$2 = _Exclusive$2._0; within_high = _M0IP36zxch3n5flock5types6NBytesPB7Compare7compare(_node.key, _hi$2) < 0; } } if (!within_high) { ended.val = true; return undefined; } return { _0: _node.key, _1: _node.value }; } }, undefined); } function _M0IP36zxch3n5flock11sorted__map4NodePB2Eq5equalGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(self, other) { return _M0IP36zxch3n5flock5types7Utf8StrPB2Eq5equal(self.key, other.key); } function _M0IP36zxch3n5flock11sorted__map4NodePB2Eq5equalGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(self, other) { return _M0IP36zxch3n5flock5types6NBytesPB2Eq5equal(self.key, other.key); } function _M0FP36zxch3n5flock5flock22peer__id__from__string(peer_id) { const utf8 = _M0MP36zxch3n5flock5types7Utf8Str12from__string(peer_id); if (utf8.bytes.length >= 128) { return undefined; } return utf8; } function _M0MP36zxch3n5flock5flock3Hlc11from__parts(physical_time, logical_counter) { return new _M0TP36zxch3n5flock5flock3Hlc(physical_time, logical_counter); } function _M0MP36zxch3n5flock5flock13SubscriberSet3newGRP36zxch3n5flock5flock10EventBatchE() { return new _M0TP36zxch3n5flock5flock13SubscriberSetGRP36zxch3n5flock5flock10EventBatchE(0, _M0MPB3Map3newGiWRP36zxch3n5flock5flock10EventBatchEuE(undefined)); } function _M0MP36zxch3n5flock5flock13SubscriberSet3addGRP36zxch3n5flock5flock10EventBatchE(self, subscriber) { const seq = self.seq; _M0MPB3Map3setGiWRP36zxch3n5flock5flock10EventBatchEuE(self.subscribers, self.seq, subscriber); self.seq = self.seq + 1 | 0; return () => { _M0MPB3Map6removeGiWRP36zxch3n5flock5flock10EventBatchEuE(self.subscribers, seq); }; } function _M0MP36zxch3n5flock5flock13SubscriberSet6notifyGRP36zxch3n5flock5flock10EventBatchE(self, event) { const _p = self.subscribers; let _tmp = _p.head; while (true) { const _p$2 = _tmp; if (_p$2 === undefined) { return; } else { const _p$3 = _p$2; const _p$4 = _p$3; const _p$5 = _p$4.value; const _p$6 = _p$4.next; _p$5(event); _tmp = _p$6; continue; } } } function _M0MP36zxch3n5flock5flock13SubscriberSet9is__emptyGRP36zxch3n5flock5flock10EventBatchE(self) { const _p = self.subscribers; return _p.size === 0; } function _M0FP36zxch3n5flock5flock14bytes__to__hex(bytes) { let ans = ""; let _tmp = 0; while (true) { const i = _tmp; if (i < bytes.length) { $bound_check(bytes, i); const byte = bytes[i]; const _p = _M0IPC14byte4BytePB3Shr3shr(byte, 4); const _p$2 = 15; const hi = _p & _p$2 & 255; const _p$3 = 15; const lo = byte & _p$3 & 255; const h = hi < 10 ? _M0IPC14char4CharPB4Show10to__string(hi + 48 | 0) : _M0IPC14char4CharPB4Show10to__string((hi - 10 | 0) + 97 | 0); const l = lo < 10 ? _M0IPC14char4CharPB4Show10to__string(lo + 48 | 0) : _M0IPC14char4CharPB4Show10to__string((lo - 10 | 0) + 97 | 0); ans = `${ans}${h}`; ans = `${ans}${l}`; _tmp = i + 1 | 0; continue; } else { break; } } return ans; } function _M0FP36zxch3n5flock5flock16bytes__from__hex(hex) { if (((hex.end - hex.start | 0) % 2 | 0) !== 0) { const _string_builder = _M0MPB13StringBuilder21StringBuilder_2einner(20); _M0IPB13StringBuilderPB6Logger13write__string(_string_builder, "Invalid hex length: "); _M0MPB13StringBuilder13write__objectGiE(_string_builder, hex.end - hex.start | 0); _M0FPB7printlnGsE(_string_builder.val); return undefined; } const bytes = []; let _tmp = 0; while (true) { const i = _tmp; if (i < (hex.end - hex.start | 0)) { const first = _M0MPC16string10StringView2at(hex, i); const second = _M0MPC16string10StringView2at(hex, i + 1 | 0); let value = 0; if (first >= 48 && first <= 57) { value = value + (Math.imul(first - 48 | 0, 16) | 0) | 0; } else { if (first >= 97 && first <= 102) { value = value + (Math.imul((first - 97 | 0) + 10 | 0, 16) | 0) | 0; } else { if (first >= 65 && first <= 70) { value = value + (Math.imul((first - 65 | 0) + 10 | 0, 16) | 0) | 0; } else { const _string_builder = _M0MPB13StringBuilder21StringBuilder_2einner(23); _M0IPB13StringBuilderPB6Logger13write__string(_string_builder, "Invalid hex character: "); _M0MPB13StringBuilder13write__objectGiE(_string_builder, first); _M0FPB7printlnGsE(_string_builder.val); return undefined; } } } if (second >= 48 && second <= 57) { value = value + (second - 48 | 0) | 0; } else { if (second >= 97 && second <= 102) { value = value + ((second - 97 | 0) + 10 | 0) | 0; } else { if (second >= 65 && second <= 70) { value = value + ((second - 65 | 0) + 10 | 0) | 0; } else { const _string_builder = _M0MPB13StringBuilder21StringBuilder_2einner(23); _M0IPB13StringBuilderPB6Logger13write__string(_string_builder, "Invalid hex character: "); _M0MPB13StringBuilder13write__objectGiE(_string_builder, second); _M0FPB7printlnGsE(_string_builder.val); return undefined; } } } _M0MPC15array5Array4pushGyE(bytes, value & 255); _tmp = i + 2 | 0; continue; } else { break; } } return _M0MPC15bytes5Bytes11from__array(new _M0TPB9ArrayViewGyE(bytes, 0, bytes.length)); } function _M0FP36zxch3n5flock5flock19validate__peer__key(peer_id) { if (peer_id.bytes.length >= 128) { _M0FPC15abort5abortGuE("peer id must be less than 128 bytes"); return; } else { return; } } function _M0FP36zxch3n5flock5flock21peer__key__to__string(peer) { return _M0MP36zxch3n5flock5types7Utf8Str10to__string(peer); } function _M0IP36zxch3n5flock5flock11HlcWithPeerPB2Eq5equal(a, b) { const _p = a.hlc; const _p$2 = b.hlc; if (_p.physical_time === _p$2.physical_time && _p.logical_counter === _p$2.logical_counter) { return _M0IP36zxch3n5flock5types7Utf8StrPB2Eq5equal(a.peer, b.peer); } else { return false; } } function _M0IP36zxch3n5flock5flock11HlcWithPeerPB7Compare7compare(a, b) { const _p = a.hlc; const _p$2 = b.hlc; const ans = _p.physical_time < _p$2.physical_time ? -1 : _p.physical_time > _p$2.physical_time ? 1 : $compare_int(_p.logical_counter, _p$2.logical_counter); if (ans !== 0) { return ans; } return _M0IP36zxch3n5flock5types7Utf8StrPB7Compare7compare(a.peer, b.peer); } function _M0MP36zxch3n5flock5flock3Hlc10to__string(self) { const _string_builder = _M0MPB13StringBuilder21StringBuilder_2einner(1); _M0MPB13StringBuilder13write__objectGdE(_string_builder, self.physical_time); _M0IPB13StringBuilderPB6Logger13write__string(_string_builder, ","); _M0MPB13StringBuilder13write__objectGiE(_string_builder, self.logical_counter); return _string_builder.val; } function _M0MP36zxch3n5flock5flock11HlcWithPeer10to__string(self) { const _string_builder = _M0MPB13StringBuilder21StringBuilder_2einner(1); _M0MPB13StringBuilder13write__objectGsE(_string_builder, _M0MP36zxch3n5flock5flock3Hlc10to__string(self.hlc)); _M0IPB13StringBuilderPB6Logger13write__string(_string_builder, ","); _M0MPB13StringBuilder13write__objectGsE(_string_builder, _M0FP36zxch3n5flock5flock21peer__key__to__string(self.peer)); return _string_builder.val; } function _M0MP36zxch3n5flock5flock11HlcWithPeer12from__string(s) { const parts = _M0MPB4Iter9to__arrayGRPC16string10StringViewE(_M0MPC16string10StringView5split(s, new _M0TPC16string10StringView(_M0MP36zxch3n5flock5flock11HlcWithPeer12from__stringN7_2abindS904, 0, _M0MP36zxch3n5flock5flock11HlcWithPeer12from__stringN7_2abindS904.length))); if (parts.length < 3) { return undefined; } let peer = _M0MPC16string10StringView9to__owned(_M0MPC15array5Array2atGRP36zxch3n5flock5flock5EntryE(parts, 2)); let _tmp = 3; while (true) { const i = _tmp; if (i < parts.length) { const _string_builder = _M0MPB13StringBuilder21StringBuilder_2einner(1); _M0MPB13StringBuilder13write__objectGsE(_string_builder, peer); _M0IPB13StringBuilderPB6Logger13write__string(_string_builder, ","); _M0MPB13StringBuilder13write__objectGRPC16string10StringViewE(_string_builder, _M0MPC15array5Array2atGRP36zxch3n5flock5flock5EntryE(parts, i)); peer = _string_builder.val; _tmp = i + 1 | 0; continue; } else { break; } } const _bind = _M0FP36zxch3n5flock5flock22peer__id__from__string(peer); let peer_id; if (_bind === undefined) { return undefined; } else { const _Some = _bind; peer_id = _Some; } const a = _M0MPC15array5Array2atGRP36zxch3n5flock5flock5EntryE(parts, 0); const b = _M0MPC15array5Array2atGRP36zxch3n5flock5flock5EntryE(parts, 1); let _tmp$2; let _try_err; _L: { _L$2: { const _bind$2 = _M0MPC16string10StringView9to__owned(a); const _bind$3 = _M0FPC14json13parse_2einner(new _M0TPC16string10StringView(_bind$2, 0, _bind$2.length), 1024); let _tmp$3; if (_bind$3.$tag === 1) { const _ok = _bind$3; _tmp$3 = _ok._0; } else { const _err = _bind$3; _try_err = _err._0; break _L$2; } _tmp$2 = _M0MPC16option6Option6unwrapGdE(_M0MPC14json4Json10as__number(_tmp$3)); break _L; } _tmp$2 = $panic(); } const _tmp$3 = _tmp$2; let _tmp$4; let _try_err$2; _L$2: { _L$3: { const _bind$2 = _M0MPC16string10StringView9to__owned(b); const _bind$3 = _M0FPC14json13parse_2einner(new _M0TPC16string10StringView(_bind$2, 0, _bind$2.length), 1024); let _tmp$5; if (_bind$3.$tag === 1) { const _ok = _bind$3; _tmp$5 = _ok._0; } else { const _err = _bind$3; _try_err$2 = _err._0; break _L$3; } _tmp$4 = _M0MPC16double6Double7to__int(_M0MPC16option6Option6unwrapGdE(_M0MPC14json4Json10as__number(_tmp$5))); break _L$2; } _tmp$4 = $panic(); } return new _M0TP36zxch3n5flock5flock11HlcWithPeer(new _M0TP36zxch3n5flock5flock3Hlc(_tmp$3, _tmp$4), peer_id); } function _M0MP36zxch3n5flock5flock11FlockDigest3new(bytes) { return new _M0TP36zxch3n5flock5flock11FlockDigest(bytes); } function _M0MP36zxch3n5flock5flock12DigestWriter6finish(self) { const hex = _M0IP27gmlewis6sha2566DigestP27gmlewis6sha2568HashFunc10check__sum(self.digest); const _bind = _M0FP36zxch3n5flock5flock16bytes__from__hex(new _M0TPC16string10StringView(hex, 0, hex.length)); if (_bind === undefined) { return _M0FPC15abort5abortGRP36zxch3n5flock5types7Utf8StrE("unexpected digest hex parse failure"); } else { const _Some = _bind; const _bytes = _Some; const data = $makebytes(32, 0); let _tmp = 0; while (true) { const i = _tmp; if (i < 32) { $bound_check(_bytes, i); $bound_check(data, i); data[i] = _bytes[i]; _tmp = i + 1 | 0; continue; } else { break; } } return _M0MP36zxch3n5flock5flock11FlockDigest3new(data); } } function _M0MP36zxch3n5flock5flock12DigestWriter3new() { return new _M0TP36zxch3n5flock5flock12DigestWriter(_M0MP27gmlewis6sha2566Digest3new()); } function _M0MP36zxch3n5flock5flock12DigestWriter17write__raw__bytes(self, bytes) { let _tmp = 0; while (true) { const i = _tmp; if (i < (bytes.end - bytes.start | 0)) { _M0IP27gmlewis6sha2566DigestP27gmlewis6sha2568HashFunc5write(self.digest, _M0MPC15bytes9BytesView2at(bytes, i)); _tmp = i + 1 | 0; continue; } else { return; } } } function _M0MP36zxch3n5flock5flock12DigestWriter10write__len(self, len) { const encoded = _M0FP36zxch3n5flock6leb12814encode__uint64(len); _M0MP36zxch3n5flock5flock12DigestWriter17write__raw__bytes(self, new _M0TPC15bytes9BytesView(encoded, 0, encoded.length)); } function _M0MP36zxch3n5flock5flock12DigestWriter12write__bytes(self, bytes) { const _p = bytes.end - bytes.start | 0; _M0MP36zxch3n5flock5flock12DigestWriter10write__len(self, BigInt.asUintN(64, BigInt(_p))); _M0MP36zxch3n5flock5flock12DigestWriter17write__raw__bytes(self, bytes); } function _M0FP36zxch3n5flock5flock14compare__ascii(lhs, rhs) { const len_lhs = lhs.length; const len_rhs = rhs.length; const limit = len_lhs < len_rhs ? len_lhs : len_rhs; let _tmp = 0; while (true) { const i = _tmp; if (i < limit) { $bound_check(lhs, i); const a = lhs.charCodeAt(i); $bound_check(rhs, i); const b = rhs.charCodeAt(i); if (_M0IP016_24default__implPB7Compare6op__ltGkE(a, b)) { return -1; } else { if (_M0IP016_24default__implPB7Compare6op__gtGkE(a, b)) { return 1; } } _tmp = i + 1 | 0; continue; } else { break; } } return len_lhs < len_rhs ? -1 : len_lhs > len_rhs ? 1 : 0; } function _M0FP36zxch3n5flock5flock21sort__object__entries(entries) { let _tmp = 0; while (true) { const i = _tmp; if (i < entries.length) { let min_index = i; let _tmp$2 = i + 1 | 0; while (true) { const j = _tmp$2; if (j < entries.length) { if (_M0FP36zxch3n5flock5flock14compare__ascii(_M0MPC15array5Array2atGRP36zxch3n5flock5flock5EntryE(entries, j)._0, _M0MPC15array5Array2atGRP36zxch3n5flock5flock5EntryE(entries, min_index)._0) < 0) { min_index = j; } _tmp$2 = j + 1 | 0; continue; } else { break; } } if (min_index !== i) { const tmp = _M0MPC15array5Array2atGRP36zxch3n5flock5flock5EntryE(entries, i); _M0MPC15array5Array3setGUsRPB4JsonEE(entries, i, _M0MPC15array5Array2atGRP36zxch3n5flock5flock5EntryE(entries, min_index)); _M0MPC15array5Array3setGUsRPB4JsonEE(entries, min_index, tmp); } _tmp = i + 1 | 0; continue; } else { return; } } } function _M0MP36zxch3n5flock5flock12DigestWriter11write__bool(self, value) { const byte = value ? 1 : 0; _M0IP27gmlewis6sha2566DigestP27gmlewis6sha2568HashFunc5write(self.digest, byte & 255); } function _M0MP36zxch3n5flock5flock12DigestWriter10write__u64(self, value) { const encoded = _M0FP36zxch3n5flock6leb12814encode__uint64(value); _M0MP36zxch3n5flock5flock12DigestWriter17write__raw__bytes(self, new _M0TPC15bytes9BytesView(encoded, 0, encoded.length)); } function _M0MP36zxch3n5flock5flock12DigestWriter10write__f64(self, value) { _M0MP36zxch3n5flock5flock12DigestWriter10write__u64(self, $f64_reinterpret_i64(value)); } function _M0MP36zxch3n5flock5flock12DigestWriter10write__i64(self, value) { const encoded = _M0FP36zxch3n5flock6leb12813encode__int64(value); _M0MP36zxch3n5flock5flock12DigestWriter17write__raw__bytes(self, new _M0TPC15bytes9BytesView(encoded, 0, encoded.length)); } function _M0MP36zxch3n5flock5flock12DigestWriter13write__string(self, value) { const utf8 = _M0MP36zxch3n5flock5types7Utf8Str12from__string(value); const bytes = utf8.bytes; _M0MP36zxch3n5flock5flock12DigestWriter12write__bytes(self, new _M0TPC15bytes9BytesView(bytes, 0, bytes.length)); } function _M0MP36zxch3n5flock5flock12DigestWriter10write__tag(self, tag) { _M0IP27gmlewis6sha2566DigestP27gmlewis6sha2568HashFunc5write(self.digest, tag); } function _M0MP36zxch3n5flock5flock12DigestWriter11write__json(self, value) { switch (value.$tag) { case 0: { _M0MP36zxch3n5flock5flock12DigestWriter10write__tag(self, 32); return; } case 1: { _M0MP36zxch3n5flock5flock12DigestWriter10write__tag(self, 33); _M0MP36zxch3n5flock5flock12DigestWriter11write__bool(self, true); return; } case 2: { _M0MP36zxch3n5flock5flock12DigestWriter10write__tag(self, 33); _M0MP36zxch3n5flock5flock12DigestWriter11write__bool(self, false); return; } case 3: { const _Number = value; const _number = _Number._0; _M0MP36zxch3n5flock5flock12DigestWriter10write__tag(self, 34); _M0MP36zxch3n5flock5flock12DigestWriter10write__f64(self, _number); return; } case 4: { const _String = value; const _s = _String._0; _M0MP36zxch3n5flock5flock12DigestWriter10write__tag(self, 35); _M0MP36zxch3n5flock5flock12DigestWriter13write__string(self, _s); return; } case 5: { const _Array = value; const _arr = _Array._0; _M0MP36zxch3n5flock5flock12DigestWriter10write__tag(self, 36); const _p = _arr.length; _M0MP36zxch3n5flock5flock12DigestWriter10write__len(self, BigInt.asUintN(64, BigInt(_p))); let _tmp = 0; while (true) { const i = _tmp; if (i < _arr.length) { _M0MP36zxch3n5flock5flock12DigestWriter11write__json(self, _M0MPC15array5Array2atGRP36zxch3n5flock5flock5EntryE(_arr, i)); _tmp = i + 1 | 0; continue; } else { return; } } } default: { const _Object = value; const _obj = _Object._0; _M0MP36zxch3n5flock5flock12DigestWriter10write__tag(self, 37); const entries = _M0MPC15array5Array11new_2einnerGRPB4JsonE(0); let _tmp$2 = _obj.head; while (true) { const _p$2 = _tmp$2; if (_p$2 === undefined) { break; } else { const _p$3 = _p$2; const _p$4 = _p$3; const _p$5 = _p$4.key; const _p$6 = _p$4.value; const _p$7 = _p$4.next; _M0MPC15array5Array4pushGRPB4JsonE(entries, { _0: _p$5, _1: _p$6 }); _tmp$2 = _p$7; continue; } } _M0FP36zxch3n5flock5flock21sort__object__entries(entries); const _p$2 = entries.length; _M0MP36zxch3n5flock5flock12DigestWriter10write__len(self, BigInt.asUintN(64, BigInt(_p$2))); let _tmp$3 = 0; while (true) { const i = _tmp$3; if (i < entries.length) { const _bind = _M0MPC15array5Array2atGRP36zxch3n5flock5flock5EntryE(entries, i); const _name = _bind._0; const _entry = _bind._1; _M0MP36zxch3n5flock5flock12DigestWriter13write__string(self, _name); _M0MP36zxch3n5flock5flock12DigestWriter11write__json(self, _entry); _tmp$3 = i + 1 | 0; continue; } else { return; } } } } } function _M0MP36zxch3n5flock5flock12DigestWriter17write__raw__value(self, value) { _M0MP36zxch3n5flock5flock12DigestWriter10write__tag(self, 16); const _bind = value.data; if (_bind === undefined) { _M0MP36zxch3n5flock5flock12DigestWriter11write__bool(self, false); } else { const _Some = _bind; const _data = _Some; _M0MP36zxch3n5flock5flock12DigestWriter11write__bool(self, true); _M0MP36zxch3n5flock5flock12DigestWriter11write__json(self, _data); } _M0MP36zxch3n5flock5flock12DigestWriter10write__tag(self, 18); const _bind$2 = value.metadata; if (_bind$2 === undefined) { _M0MP36zxch3n5flock5flock12DigestWriter11write__bool(self, false); } else { const _Some = _bind$2; const _metadata = _Some; _M0MP36zxch3n5flock5flock12DigestWriter11write__bool(self, true); const entries = _M0MPC15array5Array11new_2einnerGRPB4JsonE(0); let _tmp = _metadata.head; while (true) { const _p = _tmp; if (_p === undefined) { break; } else { const _p$2 = _p; const _p$3 = _p$2; const _p$4 = _p$3.key; const _p$5 = _p$3.value; const _p$6 = _p$3.next; _M0MPC15array5Array4pushGRPB4JsonE(entries, { _0: _p$4, _1: _p$5 }); _tmp = _p$6; continue; } } _M0FP36zxch3n5flock5flock21sort__object__entries(entries); const _p = entries.length; _M0MP36zxch3n5flock5flock12DigestWriter10write__len(self, BigInt.asUintN(64, BigInt(_p))); let _tmp$2 = 0; while (true) { const i = _tmp$2; if (i < entries.length) { const _bind$3 = _M0MPC15array5Array2atGRP36zxch3n5flock5flock5EntryE(entries, i); const _name = _bind$3._0; const _entry = _bind$3._1; _M0MP36zxch3n5flock5flock12DigestWriter13write__string(self, _name); _M0MP36zxch3n5flock5flock12DigestWriter11write__json(self, _entry); _tmp$2 = i + 1 | 0; continue; } else { break; } } } _M0MP36zxch3n5flock5flock12DigestWriter10write__tag(self, 17); _M0MP36zxch3n5flock5flock12DigestWriter10write__f64(self, value.clock.hlc.physical_time); _M0MP36zxch3n5flock5flock12DigestWriter10write__i64(self, BigInt.asUintN(64, BigInt(value.clock.hlc.logical_counter))); const _p = value.clock.peer; const _bind$3 = _p.bytes; _M0MP36zxch3n5flock5flock12DigestWriter12write__bytes(self, new _M0TPC15bytes9BytesView(_bind$3, 0, _bind$3.length)); } function _M0MP36zxch3n5flock5flock11FlockDigest4zero() { const bytes = $makebytes(32, 0); return new _M0TP36zxch3n5flock5flock11FlockDigest(bytes); } function _M0FP36zxch3n5flock5flock22compute__entry__digest(key, value) { const _bind = value.data; if (_bind === undefined) { return _M0MP36zxch3n5flock5flock11FlockDigest4zero(); } const writer = _M0MP36zxch3n5flock5flock12DigestWriter3new(); const _bind$2 = key; _M0MP36zxch3n5flock5flock12DigestWriter12write__bytes(writer, new _M0TPC15bytes9BytesView(_bind$2, 0, _bind$2.length)); _M0MP36zxch3n5flock5flock12DigestWriter17write__raw__value(writer, value); return _M0MP36zxch3n5flock5flock12DigestWriter6finish(writer); } function _M0MP36zxch3n5flock5flock5Entry6digest(self) { return _M0FP36zxch3n5flock5flock22compute__entry__digest(self.key, self.value); } function _M0FP36zxch3n5flock5flock11make__entry(key, value) { return new _M0TP36zxch3n5flock5flock5Entry(key, value, false); } function _M0FP36zxch3n5flock5flock14entries__equal(a, b) { if (_M0IP36zxch3n5flock5types6NBytesPB2Eq5equal(a.key, b.key)) { let _tmp; if (_M0IPC16option6OptionPB2Eq5equalGRPB4JsonE(a.value.data, b.value.data)) { let _tmp$2; if (_M0IPC16option6OptionPB2Eq5equalGRPB3MapGsRPB4JsonEE(a.value.metadata, b.value.metadata)) { let _tmp$3; if (_M0IP36zxch3n5flock5types7Utf8StrPB2Eq5equal(a.value.clock.peer, b.value.clock.peer)) { const _p = a.value.clock.hlc; const _p$2 = b.value.clock.hlc; _tmp$3 = _p.physical_time === _p$2.physical_time && _p.logical_counter === _p$2.logical_counter; } else { _tmp$3 = false; } _tmp$2 = _tmp$3; } else { _tmp$2 = false; } _tmp = _tmp$2; } else { _tmp = false; } return _tmp; } else { return false; } } function _M0MP36zxch3n5flock5flock5Flock31record__pending__change_2einner(self, remove_digest, add_digest) { const _bind = self.digest; if (_bind === undefined) { return; } else { const _Some = _bind; const _cache = _Some; const _pending0 = _cache.pending; if (remove_digest === undefined) { } else { const _Some$2 = remove_digest; const _d = _Some$2; _M0MPC15array5Array4pushGRPB4JsonE(_pending0, _d); } if (add_digest === undefined) { return; } else { const _Some$2 = add_digest; const _d = _Some$2; _M0MPC15array5Array4pushGRPB4JsonE(_pending0, _d); return; } } } function _M0MP36zxch3n5flock5flock5Flock12apply__entry(self, entry, skip_same_value) { const entry_key = entry.key; const peer = entry.value.clock.peer; const _bind = _M0MP36zxch3n5flock11sorted__map9SortedMap5entryGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(self.kv, entry_key); const _maybe_existing = _bind._0; const _setter = _bind._1; let should_apply; if (_maybe_existing === undefined) { should_apply = true; } else { const _Some = _maybe_existing; const _existing = _Some; should_apply = _M0IP016_24default__implPB7Compare6op__gtGRP36zxch3n5flock5flock11HlcWithPeerE(entry.value.clock, _existing.value.clock) || skip_same_value && _M0IPC16option6OptionPB2Eq5equalGRPB4JsonE(entry.value.data, _existing.value.data); } if (!should_apply) { return false; } let removed_digest = undefined; if (_maybe_existing === undefined) { } else { const _Some = _maybe_existing; const _existing = _Some; removed_digest = _M0MP36zxch3n5flock5flock5Entry6digest(_existing); _existing.overridden = true; } const added_digest = _M0MPC16option6Option3mapGRPB4JsonRP36zxch3n5flock5flock11FlockDigestE(entry.value.data, (_discard_) => _M0MP36zxch3n5flock5flock5Entry6digest(entry)); _setter(entry); if (!_M0MP36zxch3n5flock11sorted__map9SortedMap8containsGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(self.updates, peer)) { _M0MP36zxch3n5flock11sorted__map9SortedMap3setGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(self.updates, peer, []); } const updates = _M0MP36zxch3n5flock11sorted__map9SortedMap2atGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(self.updates, peer); let meet_rare_case = false; const _bind$2 = _M0MPC15array5Array4lastGRP36zxch3n5flock5flock5EntryE(updates); if (_bind$2 === undefined) { } else { const _Some = _bind$2; const _last = _Some; if (_M0IP016_24default__implPB7Compare6op__gtGRP36zxch3n5flock5flock11HlcWithPeerE(_last.value.clock, entry.value.clock)) { meet_rare_case = true; let _tmp = updates.length - 2 | 0; while (true) { const i = _tmp; if (i >= 0) { if (_M0IP016_24default__implPB7Compare6op__ltGRP36zxch3n5flock5flock11HlcWithPeerE(_M0MPC15array5Array2atGRP36zxch3n5flock5flock5EntryE(updates, i).value.clock, entry.value.clock)) { _M0MPC15array5Array6insertGRP36zxch3n5flock5flock5EntryE(updates, i + 1 | 0, entry); break; } _tmp = i - 1 | 0; continue; } else { _M0MPC15array5Array6insertGRP36zxch3n5flock5flock5EntryE(updates, 0, entry); break; } } } } if (!meet_rare_case) { _M0MPC15array5Array4pushGRPB4JsonE(updates, entry); } _M0MP36zxch3n5flock5flock5Flock31record__pending__change_2einner(self, removed_digest, added_digest); return true; } function _M0FP36zxch3n5flock5flock15clone__metadata(metadata) { const copy = _M0MPB3Map3newGsRP36zxch3n5flock5flock3HlcE(undefined); let _tmp = metadata.head; while (true) { const _p = _tmp; if (_p === undefined) { break; } else { const _p$2 = _p; const _p$3 = _p$2; const _p$4 = _p$3.key; const _p$5 = _p$3.value; const _p$6 = _p$3.next; _M0MPB3Map3setGsRPB4JsonE(copy, _p$4, _p$5); _tmp = _p$6; continue; } } return copy; } function _M0FP36zxch3n5flock5flock17clone__raw__value(value) { const _bind = value.metadata; let metadata; if (_bind === undefined) { metadata = undefined; } else { const _Some = _bind; const _metadata = _Some; metadata = _M0FP36zxch3n5flock5flock15clone__metadata(_metadata); } return new _M0TP36zxch3n5flock5flock8RawValue(value.data, metadata, value.clock); } function _M0MP36zxch3n5flock5flock8RawValue8to__json(self) { const obj = _M0MPB3Map3newGsRP36zxch3n5flock5flock3HlcE(undefined); const _bind = self.data; if (_bind === undefined) { } else { const _Some = _bind; const _data = _Some; _M0MPB3Map3setGsRPB4JsonE(obj, "d", _data); } const _p = _M0MP36zxch3n5flock5flock11HlcWithPeer10to__string(self.clock); _M0MPB3Map3setGsRPB4JsonE(obj, "c", new _M0DTPB4Json6String(_p)); const _bind$2 = self.metadata; if (_bind$2 === undefined) { } else { const _Some = _bind$2; const _metadata = _Some; _M0MPB3Map3setGsRPB4JsonE(obj, "m", _M0IPB3MapPB6ToJson8to__jsonGsRPB4JsonE(_M0FP36zxch3n5flock5flock15clone__metadata(_metadata))); } return _M0IPB3MapPB6ToJson8to__jsonGsRPB4JsonE(obj); } function _M0MP36zxch3n5flock5flock8RawValue10from__json(json) { if (json.$tag === 6) { const _Object = json; const _obj = _Object._0; let clock; _L: { _L$2: { const _bind = _M0MPB3Map3getGsRPB4JsonE(_obj, "c"); if (_bind === undefined) { break _L$2; } else { const _Some = _bind; const _x = _Some; if (_x.$tag === 4) { const _String = _x; const _clock = _String._0; const _bind$2 = _M0MP36zxch3n5flock5flock11HlcWithPeer12from__string(new _M0TPC16string10StringView(_clock, 0, _clock.length)); if (_bind$2 === undefined) { return undefined; } else { const _Some$2 = _bind$2; clock = _Some$2; } } else { break _L$2; } } break _L; } return undefined; } const data = _M0MPB3Map3getGsRPB4JsonE(_obj, "d"); const _bind = _M0MPB3Map3getGsRPB4JsonE(_obj, "m"); let metadata; if (_bind === undefined) { metadata = undefined; } else { const _Some = _bind; const _x = _Some; switch (_x.$tag) { case 6: { const _Object$2 = _x; const _meta = _Object$2._0; metadata = _M0FP36zxch3n5flock5flock15clone__metadata(_meta); break; } case 0: { metadata = undefined; break; } default: { return undefined; } } } return new _M0TP36zxch3n5flock5flock8RawValue(data, metadata, clock); } else { return undefined; } } function _M0FP36zxch3n5flock5flock20raw__value__to__info(value) { const _bind = value.metadata; let metadata; if (_bind === undefined) { metadata = _M0MPB3Map3newGsRP36zxch3n5flock5flock3HlcE(undefined); } else { const _Some = _bind; const _meta = _Some; metadata = _M0FP36zxch3n5flock5flock15clone__metadata(_meta); } return new _M0TP36zxch3n5flock5flock9EntryInfo(value.data, metadata, value.clock); } function _M0MP36zxch3n5flock5flock5Flock3new(peer_id) { const _bind = _M0FP36zxch3n5flock5flock22peer__id__from__string(peer_id); let peer_key; if (_bind === undefined) { peer_key = _M0FPC15abort5abortGRP36zxch3n5flock5types7Utf8StrE("peer id must be less than 128 bytes"); } else { const _Some = _bind; peer_key = _Some; } _M0FP36zxch3n5flock5flock19validate__peer__key(peer_key); const _bind$2 = _M0MPB3Map3newGsRP36zxch3n5flock5flock3HlcE(undefined); const _bind$3 = _M0MP36zxch3n5flock11sorted__map9SortedMap3newGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(); const _bind$4 = _M0MP36zxch3n5flock11sorted__map9SortedMap3newGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(); const _bind$5 = _M0MP36zxch3n5flock5flock13SubscriberSet3newGRP36zxch3n5flock5flock10EventBatchE(); const _bind$6 = undefined; const _bind$7 = _M0DTPC16option6OptionGRPB5ArrayGURPB5ArrayGRPB4JsonERP36zxch3n5flock5flock8RawValueEEE4None__; return new _M0TP36zxch3n5flock5flock5Flock(peer_key, _M0MP36zxch3n5flock5flock5Flock3newN7_2abindS1071, _bind$2, _bind$3, _bind$4, _bind$5, _bind$6, _bind$7); } function _M0MP36zxch3n5flock5flock5Flock13set__peer__id(self, peer_id) { const _bind = _M0FP36zxch3n5flock5flock22peer__id__from__string(peer_id); let peer_key; if (_bind === undefined) { peer_key = _M0FPC15abort5abortGRP36zxch3n5flock5types7Utf8StrE("peer id must be less than 128 bytes"); } else { const _Some = _bind; peer_key = _Some; } _M0FP36zxch3n5flock5flock19validate__peer__key(peer_key); self.peer_id = peer_key; } function _M0MP36zxch3n5flock5flock5Flock18check__consistency(a, b) { const entries_a = _M0MP36zxch3n5flock11sorted__map9SortedMap9to__arrayGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(a.kv); const entries_b = _M0MP36zxch3n5flock11sorted__map9SortedMap9to__arrayGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(b.kv); if (entries_a.length !== entries_b.length) { return false; } let _tmp = 0; while (true) { const i = _tmp; if (i < entries_a.length) { const _bind = _M0MPC15array5Array2atGRP36zxch3n5flock5flock5EntryE(entries_a, i); const _key_a = _bind._0; const _entry_a = _bind._1; const _bind$2 = _M0MPC15array5Array2atGRP36zxch3n5flock5flock5EntryE(entries_b, i); const _key_b = _bind$2._0; const _entry_b = _bind$2._1; if (_M0IP016_24default__implPB2Eq10not__equalGRP36zxch3n5flock5types6NBytesE(_key_a, _key_b)) { return false; } if (!_M0FP36zxch3n5flock5flock14entries__equal(_entry_a, _entry_b)) { return false; } _tmp = i + 1 | 0; continue; } else { break; } } return true; } function _M0MP36zxch3n5flock5flock5Flock17check__invariants(_self) {} function _M0MP36zxch3n5flock5flock5Flock18put__inner_2einner(self, key, data, metadata, now, hooks, skip_same_value) { const _bind = _M0FP36zxch3n5flock13memcomparable17encode__json__key(key); if (_bind === undefined) { return new _M0DTPC16result6ResultGuRP36zxch3n5flock5flock8PutErrorE3Err(new _M0DTPC15error5Error46zxch3n_2fflock_2fflock_2ePutError_2eInvalidKey(_M0IPC15array5ArrayPB6ToJson8to__jsonGRPB4JsonE(key))); } else { const _Some = _bind; const _encoded_key = _Some; if (skip_same_value) { const _bind$2 = _M0MP36zxch3n5flock11sorted__map9SortedMap3getGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(self.kv, _encoded_key); if (_bind$2 === undefined) { if (data === undefined) { if (metadata === undefined) { return new _M0DTPC16result6ResultGuRP36zxch3n5flock5flock8PutErrorE2Ok(undefined); } } } else { const _Some$2 = _bind$2; const _existing = _Some$2; if (_M0IPC16option6OptionPB2Eq5equalGRPB4JsonE(_existing.value.data, data) && _M0IPC16option6OptionPB2Eq5equalGRPB3MapGsRPB4JsonEE(_existing.value.metadata, metadata)) { return new _M0DTPC16result6ResultGuRP36zxch3n5flock5flock8PutErrorE2Ok(undefined); } } } const now$2 = _M0MPC16option6Option16unwrap__or__elseGdE(now, () => $f64_convert_i64_u(BigInt.asUintN(64, _M0FPC13env3now()))); if (now$2 > self.max_hlc.physical_time) { self.max_hlc = new _M0TP36zxch3n5flock5flock3Hlc(now$2, 0); } else { self.max_hlc = new _M0TP36zxch3n5flock5flock3Hlc(self.max_hlc.physical_time, self.max_hlc.logical_counter + 1 | 0); } const clock = new _M0TP36zxch3n5flock5flock11HlcWithPeer(self.max_hlc, self.peer_id); let metadata_copy; if (metadata === undefined) { metadata_copy = undefined; } else { const _Some$2 = metadata; const _meta = _Some$2; metadata_copy = _M0FP36zxch3n5flock5flock15clone__metadata(_meta); } const base_value = new _M0TP36zxch3n5flock5flock8RawValue(data, metadata_copy, clock); const base_entry = _M0FP36zxch3n5flock5flock11make__entry(_encoded_key, base_value); let transformed_value; if (hooks === undefined) { transformed_value = _M0FP36zxch3n5flock5flock17clone__raw__value(base_entry.value); } else { const _Some$2 = hooks; const _transform_fn = _Some$2; const _bind$2 = _transform_fn(base_entry); if (_bind$2 === undefined) { transformed_value = _M0FP36zxch3n5flock5flock17clone__raw__value(base_entry.value); } else { const _Some$3 = _bind$2; const _updated_entry = _Some$3; transformed_value = _M0FP36zxch3n5flock5flock17clone__raw__value(_updated_entry.value); } } const final_value = new _M0TP36zxch3n5flock5flock8RawValue(transformed_value.data, transformed_value.metadata, clock); const final_entry = _M0FP36zxch3n5flock5flock11make__entry(_encoded_key, final_value); const applied = _M0MP36zxch3n5flock5flock5Flock12apply__entry(self, final_entry, true); if (!applied) { return new _M0DTPC16result6ResultGuRP36zxch3n5flock5flock8PutErrorE2Ok(undefined); } const final_clock = final_entry.value.clock.hlc; self.max_hlc = final_clock; _M0MPB3Map3setGsRP36zxch3n5flock5flock3HlcE(self.vv, _M0FP36zxch3n5flock5flock21peer__key__to__string(self.peer_id), final_clock); const _bind$2 = self.txn_events; if (_bind$2.$tag === 1) { const _Some$2 = _bind$2; const _events = _Some$2._0; const event_key = _M0FP36zxch3n5flock13memcomparable21decode__key__to__json(final_entry.key); const event_payload = _M0FP36zxch3n5flock5flock17clone__raw__value(final_entry.value); return new _M0DTPC16result6ResultGuRP36zxch3n5flock5flock8PutErrorE2Ok(_M0MPC15array5Array4pushGRPB4JsonE(_events, { _0: event_key, _1: event_payload })); } else { if (!_M0MP36zxch3n5flock5flock13SubscriberSet9is__emptyGRP36zxch3n5flock5flock10EventBatchE(self.subscribers)) { const event_key = _M0FP36zxch3n5flock13memcomparable21decode__key__to__json(final_entry.key); const event_payload = _M0FP36zxch3n5flock5flock17clone__raw__value(final_entry.value); return new _M0DTPC16result6ResultGuRP36zxch3n5flock5flock8PutErrorE2Ok(_M0MP36zxch3n5flock5flock13SubscriberSet6notifyGRP36zxch3n5flock5flock10EventBatchE(self.subscribers, new _M0TP36zxch3n5flock5flock10EventBatch(_M0DTP36zxch3n5flock5flock6Source5Local__, [{ _0: event_key, _1: event_payload }]))); } else { return new _M0DTPC16result6ResultGuRP36zxch3n5flock5flock8PutErrorE2Ok(undefined); } } } } function _M0MP36zxch3n5flock5flock5Flock10put__inner(self, key, data, metadata$46$opt, now$46$opt, hooks$46$opt, skip_same_value$46$opt) { let metadata; if (metadata$46$opt.$tag === 1) { const _Some = metadata$46$opt; metadata = _Some._0; } else { metadata = undefined; } let now; if (now$46$opt === undefined) { now = _M0DTPC16option6OptionGdE4None__; } else { const _Some = now$46$opt; now = _Some; } let hooks; if (hooks$46$opt.$tag === 1) { const _Some = hooks$46$opt; hooks = _Some._0; } else { hooks = undefined; } const skip_same_value = skip_same_value$46$opt === -1 ? true : skip_same_value$46$opt; return _M0MP36zxch3n5flock5flock5Flock18put__inner_2einner(self, key, data, metadata, now, hooks, skip_same_value); } function _M0MP36zxch3n5flock5flock5Flock23put__with__meta_2einner(self, key, value, metadata, now, hooks) { return _M0MP36zxch3n5flock5flock5Flock18put__inner_2einner(self, key, value, metadata, now, hooks, true); } function _M0MP36zxch3n5flock5flock5Flock15put__with__meta(self, key, value, metadata$46$opt, now$46$opt, hooks$46$opt) { let metadata; if (metadata$46$opt.$tag === 1) { const _Some = metadata$46$opt; metadata = _Some._0; } else { metadata = undefined; } let now; if (now$46$opt === undefined) { now = _M0DTPC16option6OptionGdE4None__; } else { const _Some = now$46$opt; now = _Some; } let hooks; if (hooks$46$opt.$tag === 1) { const _Some = hooks$46$opt; hooks = _Some._0; } else { hooks = undefined; } return _M0MP36zxch3n5flock5flock5Flock23put__with__meta_2einner(self, key, value, metadata, now, hooks); } function _M0MP36zxch3n5flock5flock5Flock11put_2einner(self, key, value, now) { return _M0MP36zxch3n5flock5flock5Flock15put__with__meta(self, key, value, _M0DTPC16option6OptionGORPB3MapGsRPB4JsonEE4None__, now, _M0DTPC16option6OptionGOWRP36zxch3n5flock5flock5EntryEORP36zxch3n5flock5flock5EntryE4None__); } function _M0MP36zxch3n5flock5flock5Flock14delete_2einner(self, key, now) { return _M0MP36zxch3n5flock5flock5Flock10put__inner(self, key, undefined, _M0DTPC16option6OptionGORPB3MapGsRPB4JsonEE4None__, now, _M0DTPC16option6OptionGOWRP36zxch3n5flock5flock5EntryEORP36zxch3n5flock5flock5EntryE4None__, _M0MP36zxch3n5flock5flock5Flock14delete_2einnerN6constrS1854); } function _M0MP36zxch3n5flock5flock5Flock10txn__begin(self) { const _bind = self.txn_events; if (_bind.$tag === 0) { self.txn_events = new _M0DTPC16option6OptionGRPB5ArrayGURPB5ArrayGRPB4JsonERP36zxch3n5flock5flock8RawValueEEE4Some([]); return; } else { _M0FPC15abort5abortGuE("Nested transactions are not supported"); return; } } function _M0MP36zxch3n5flock5flock5Flock11txn__commit(self) { const _bind = self.txn_events; if (_bind.$tag === 1) { const _Some = _bind; const _events = _Some._0; self.txn_events = _M0DTPC16option6OptionGRPB5ArrayGURPB5ArrayGRPB4JsonERP36zxch3n5flock5flock8RawValueEEE4None__; if (_events.length > 0 && !_M0MP36zxch3n5flock5flock13SubscriberSet9is__emptyGRP36zxch3n5flock5flock10EventBatchE(self.subscribers)) { _M0MP36zxch3n5flock5flock13SubscriberSet6notifyGRP36zxch3n5flock5flock10EventBatchE(self.subscribers, new _M0TP36zxch3n5flock5flock10EventBatch(_M0DTP36zxch3n5flock5flock6Source5Local__, _events)); return; } else { return; } } else { _M0FPC15abort5abortGuE("No active transaction to commit"); return; } } function _M0MP36zxch3n5flock5flock5Flock13txn__rollback(self) { const _bind = self.txn_events; if (_bind.$tag === 1) { self.txn_events = _M0DTPC16option6OptionGRPB5ArrayGURPB5ArrayGRPB4JsonERP36zxch3n5flock5flock8RawValueEEE4None__; return; } else { _M0FPC15abort5abortGuE("No active transaction to rollback"); return; } } function _M0MP36zxch3n5flock5flock5Flock11is__in__txn(self) { const _bind = self.txn_events; if (_bind.$tag === 1) { return true; } else { return false; } } function _M0MP36zxch3n5flock5flock5Flock3get(self, key) { const _bind = _M0FP36zxch3n5flock13memcomparable17encode__json__key(key); if (_bind === undefined) { return undefined; } else { const _Some = _bind; const _encoded_key = _Some; return _M0MPC16option6Option4bindGRP36zxch3n5flock5flock5EntryRPB4JsonE(_M0MP36zxch3n5flock11sorted__map9SortedMap3getGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(self.kv, _encoded_key), (entry) => entry.value.data); } } function _M0MP36zxch3n5flock5flock5Flock10get__entry(self, key) { const _bind = _M0FP36zxch3n5flock13memcomparable17encode__json__key(key); if (_bind === undefined) { return undefined; } else { const _Some = _bind; const _encoded_key = _Some; return _M0MPC16option6Option3mapGRP36zxch3n5flock5flock5EntryRP36zxch3n5flock5flock9EntryInfoE(_M0MP36zxch3n5flock11sorted__map9SortedMap3getGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(self.kv, _encoded_key), (entry) => _M0FP36zxch3n5flock5flock20raw__value__to__info(entry.value)); } } function _M0FP36zxch3n5flock5flock17empty__scan__iter() { return _M0MPB5Iter23newGRPB5ArrayGRPB4JsonERP36zxch3n5flock5flock5EntryE(() => undefined, undefined); } function _M0FP36zxch3n5flock5flock27prefix__upper__bound__bytes(bytes) { if ((bytes.end - bytes.start | 0) === 0) { return undefined; } const data = _M0MPC15array5Array11new_2einnerGyE(bytes.end - bytes.start | 0); let _tmp = 0; while (true) { const i = _tmp; if (i < (bytes.end - bytes.start | 0)) { _M0MPC15array5Array4pushGyE(data, _M0MPC15bytes9BytesView2at(bytes, i)); _tmp = i + 1 | 0; continue; } else { break; } } let _tmp$2 = data.length - 1 | 0; while (true) { const i = _tmp$2; if (i >= 0) { const current = _M0MPC15array5Array2atGyE(data, i); if (current < 255) { _M0MPC15array5Array3setGyE(data, i, (current + 1 | 0) & 255); const truncated = _M0MPC15array5Array11new_2einnerGyE(i + 1 | 0); let _tmp$3 = 0; while (true) { const j = _tmp$3; if (j <= i) { _M0MPC15array5Array4pushGyE(truncated, _M0MPC15array5Array2atGyE(data, j)); _tmp$3 = j + 1 | 0; continue; } else { break; } } return _M0MPC15bytes5Bytes11from__array(new _M0TPB9ArrayViewGyE(truncated, 0, truncated.length)); } _tmp$2 = i - 1 | 0; continue; } else { break; } } return undefined; } function _M0MP36zxch3n5flock5flock5Flock12scan_2einnerN12apply__lowerS440(_env, bytes, inclusive) { const lower_inclusive = _env._1; const lower_bytes = _env._0; const _bind = lower_bytes.val; if (_bind === undefined) { lower_bytes.val = bytes; lower_inclusive.val = inclusive; return; } else { const _Some = _bind; const _current = _Some; const cmp = _M0FP36zxch3n5flock13memcomparable14compare__bytes(new _M0TPC15bytes9BytesView(bytes, 0, bytes.length), new _M0TPC15bytes9BytesView(_current, 0, _current.length)); if (cmp > 0) { lower_bytes.val = bytes; lower_inclusive.val = inclusive; return; } else { if (cmp === 0) { lower_inclusive.val = lower_inclusive.val && inclusive; return; } else { return; } } } } function _M0MP36zxch3n5flock5flock5Flock12scan_2einnerN12apply__upperS452(_env, bytes, inclusive) { const upper_bytes = _env._1; const upper_inclusive = _env._0; const _bind = upper_bytes.val; if (_bind === undefined) { upper_bytes.val = bytes; upper_inclusive.val = inclusive; return; } else { const _Some = _bind; const _current = _Some; const cmp = _M0FP36zxch3n5flock13memcomparable14compare__bytes(new _M0TPC15bytes9BytesView(bytes, 0, bytes.length), new _M0TPC15bytes9BytesView(_current, 0, _current.length)); if (cmp < 0) { upper_bytes.val = bytes; upper_inclusive.val = inclusive; return; } else { if (cmp === 0) { upper_inclusive.val = upper_inclusive.val && inclusive; return; } else { return; } } } } function _M0MP36zxch3n5flock5flock5Flock12scan_2einner(self, start, end, prefix) { const prefix_filter = new _M0TPB8MutLocalGRPB5ArrayGRPB4JsonEE(_M0MPC15array5Array11new_2einnerGRPB4JsonE(0)); const has_prefix_filter = new _M0TPB8MutLocalGbE(false); let prefix_bytes = undefined; let prefix_upper_bytes = undefined; if (prefix.$tag === 1) { const _Some = prefix; const _p = _Some._0; prefix_filter.val = _M0MPC15array5Array4copyGRPB4JsonE(_p); has_prefix_filter.val = true; const _bind = _M0FP36zxch3n5flock13memcomparable17encode__json__key(_p); if (_bind === undefined) { return _M0FP36zxch3n5flock5flock17empty__scan__iter(); } else { const _Some$2 = _bind; const _encoded_prefix = _Some$2; prefix_upper_bytes = _M0FP36zxch3n5flock5flock27prefix__upper__bound__bytes(new _M0TPC15bytes9BytesView(_encoded_prefix, 0, _encoded_prefix.length)); prefix_bytes = _encoded_prefix; } } let start_bound_bytes; switch (start.$tag) { case 0: { const _Inclusive = start; const _s = _Inclusive._0; const _bind = _M0FP36zxch3n5flock13memcomparable17encode__json__key(_s); if (_bind === undefined) { return _M0FP36zxch3n5flock5flock17empty__scan__iter(); } else { const _Some = _bind; const _encoded_start = _Some; start_bound_bytes = new _M0DTP36zxch3n5flock11sorted__map5BoundGzE9Inclusive(_encoded_start); } break; } case 1: { const _Exclusive = start; const _s$2 = _Exclusive._0; const _bind$2 = _M0FP36zxch3n5flock13memcomparable17encode__json__key(_s$2); if (_bind$2 === undefined) { return _M0FP36zxch3n5flock5flock17empty__scan__iter(); } else { const _Some = _bind$2; const _encoded_start = _Some; start_bound_bytes = new _M0DTP36zxch3n5flock11sorted__map5BoundGzE9Exclusive(_encoded_start); } break; } default: { start_bound_bytes = _M0DTP36zxch3n5flock11sorted__map5BoundGzE9Unbounded__; } } let end_bound_bytes; switch (end.$tag) { case 0: { const _Inclusive$2 = end; const _e = _Inclusive$2._0; const _bind$3 = _M0FP36zxch3n5flock13memcomparable17encode__json__key(_e); if (_bind$3 === undefined) { return _M0FP36zxch3n5flock5flock17empty__scan__iter(); } else { const _Some = _bind$3; const _encoded_end = _Some; end_bound_bytes = new _M0DTP36zxch3n5flock11sorted__map5BoundGzE9Inclusive(_encoded_end); } break; } case 1: { const _Exclusive$2 = end; const _e$2 = _Exclusive$2._0; const _bind$4 = _M0FP36zxch3n5flock13memcomparable17encode__json__key(_e$2); if (_bind$4 === undefined) { return _M0FP36zxch3n5flock5flock17empty__scan__iter(); } else { const _Some = _bind$4; const _encoded_end = _Some; end_bound_bytes = new _M0DTP36zxch3n5flock11sorted__map5BoundGzE9Exclusive(_encoded_end); } break; } default: { end_bound_bytes = _M0DTP36zxch3n5flock11sorted__map5BoundGzE9Unbounded__; } } const lower_bytes = new _M0TPB8MutLocalGOzE(undefined); const lower_inclusive = new _M0TPB8MutLocalGbE(true); const _env = { _0: lower_bytes, _1: lower_inclusive }; const _bind$5 = prefix_bytes; if (_bind$5 === undefined) { } else { const _Some = _bind$5; const _prefix_key = _Some; _M0MP36zxch3n5flock5flock5Flock12scan_2einnerN12apply__lowerS440(_env, _prefix_key, true); } switch (start_bound_bytes.$tag) { case 0: { const _Inclusive$3 = start_bound_bytes; const _start_key = _Inclusive$3._0; _M0MP36zxch3n5flock5flock5Flock12scan_2einnerN12apply__lowerS440(_env, _start_key, true); break; } case 1: { const _Exclusive$3 = start_bound_bytes; const _start_key$2 = _Exclusive$3._0; _M0MP36zxch3n5flock5flock5Flock12scan_2einnerN12apply__lowerS440(_env, _start_key$2, false); break; } } const _bind$6 = lower_bytes.val; let low_bound; if (_bind$6 === undefined) { low_bound = _M0DTP36zxch3n5flock11sorted__map5BoundGRP36zxch3n5flock5types6NBytesE9Unbounded__; } else { const _Some = _bind$6; const _bytes = _Some; low_bound = lower_inclusive.val ? new _M0DTP36zxch3n5flock11sorted__map5BoundGRP36zxch3n5flock5types6NBytesE9Inclusive(_bytes) : new _M0DTP36zxch3n5flock11sorted__map5BoundGRP36zxch3n5flock5types6NBytesE9Exclusive(_bytes); } const upper_bytes = new _M0TPB8MutLocalGOzE(undefined); const upper_inclusive = new _M0TPB8MutLocalGbE(true); const _env$2 = { _0: upper_inclusive, _1: upper_bytes }; const _bind$7 = prefix_upper_bytes; if (_bind$7 === undefined) { } else { const _Some = _bind$7; const _prefix_upper = _Some; _M0MP36zxch3n5flock5flock5Flock12scan_2einnerN12apply__upperS452(_env$2, _prefix_upper, false); } switch (end_bound_bytes.$tag) { case 0: { const _Inclusive$4 = end_bound_bytes; const _end_key = _Inclusive$4._0; _M0MP36zxch3n5flock5flock5Flock12scan_2einnerN12apply__upperS452(_env$2, _end_key, true); break; } case 1: { const _Exclusive$4 = end_bound_bytes; const _end_key$2 = _Exclusive$4._0; _M0MP36zxch3n5flock5flock5Flock12scan_2einnerN12apply__upperS452(_env$2, _end_key$2, false); break; } } const _bind$8 = upper_bytes.val; let high_bound; if (_bind$8 === undefined) { high_bound = _M0DTP36zxch3n5flock11sorted__map5BoundGRP36zxch3n5flock5types6NBytesE9Unbounded__; } else { const _Some = _bind$8; const _bytes = _Some; high_bound = upper_inclusive.val ? new _M0DTP36zxch3n5flock11sorted__map5BoundGRP36zxch3n5flock5types6NBytesE9Inclusive(_bytes) : new _M0DTP36zxch3n5flock11sorted__map5BoundGRP36zxch3n5flock5types6NBytesE9Exclusive(_bytes); } const range_iter = _M0MP36zxch3n5flock11sorted__map9SortedMap5rangeGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(self.kv, low_bound, high_bound); const next_entry = () => { while (true) { const _bind$9 = _M0MPB5Iter24nextGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(range_iter); if (_bind$9 === undefined) { return undefined; } else { const _Some = _bind$9; const _x = _Some; const _encoded_key = _x._0; const _entry = _x._1; const key_json = _M0FP36zxch3n5flock13memcomparable21decode__key__to__json(_encoded_key); if (has_prefix_filter.val) { if (prefix_filter.val.length > key_json.length) { continue; } let matches = true; let _tmp = 0; while (true) { const i = _tmp; if (i < prefix_filter.val.length) { if (_M0IP016_24default__implPB2Eq10not__equalGRPB4JsonE(_M0MPC15array5Array2atGRP36zxch3n5flock5flock5EntryE(prefix_filter.val, i), _M0MPC15array5Array2atGRP36zxch3n5flock5flock5EntryE(key_json, i))) { matches = false; break; } _tmp = i + 1 | 0; continue; } else { break; } } if (!matches) { continue; } } return { _0: key_json, _1: _entry }; } } }; return _M0MPB5Iter23newGRPB5ArrayGRPB4JsonERP36zxch3n5flock5flock5EntryE(next_entry, undefined); } function _M0MP36zxch3n5flock5flock5Flock4scan(self, start$46$opt, end$46$opt, prefix) { let start; if (start$46$opt === undefined) { start = _M0DTP36zxch3n5flock11sorted__map5BoundGRPB5ArrayGRPB4JsonEE9Unbounded__; } else { const _Some = start$46$opt; start = _Some; } let end; if (end$46$opt === undefined) { end = _M0DTP36zxch3n5flock11sorted__map5BoundGRPB5ArrayGRPB4JsonEE9Unbounded__; } else { const _Some = end$46$opt; end = _Some; } return _M0MP36zxch3n5flock5flock5Flock12scan_2einner(self, start, end, prefix); } function _M0MP36zxch3n5flock5flock5Flock9subscribe(self, listener) { return _M0MP36zxch3n5flock5flock13SubscriberSet3addGRP36zxch3n5flock5flock10EventBatchE(self.subscribers, listener); } function _M0MP36zxch3n5flock5flock5Flock8peer__id(self) { return _M0FP36zxch3n5flock5flock21peer__key__to__string(self.peer_id); } function _M0MP36zxch3n5flock5flock5Flock7version(self) { const result = _M0MPB3Map3newGsRP36zxch3n5flock5flock3HlcE(undefined); const _it = _M0MP36zxch3n5flock11sorted__map9SortedMap5iter2GRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(self.updates); while (true) { const _bind = _M0MPB5Iter24nextGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(_it); if (_bind === undefined) { break; } else { const _Some = _bind; const _x = _Some; const _peer_key = _x._0; const _entries = _x._1; let _tmp = _entries.length - 1 | 0; while (true) { const i = _tmp; if (i >= 0) { const entry = _M0MPC15array5Array2atGRP36zxch3n5flock5flock5EntryE(_entries, i); if (!entry.overridden) { _M0MPB3Map3setGsRP36zxch3n5flock5flock3HlcE(result, _M0FP36zxch3n5flock5flock21peer__key__to__string(_peer_key), entry.value.clock.hlc); break; } _tmp = i - 1 | 0; continue; } else { break; } } continue; } } return result; } function _M0MP36zxch3n5flock5flock5Flock16inclusiveVersion(self) { return _M0MPB3Map4copyGsRP36zxch3n5flock5flock3HlcE(self.vv); } function _M0FP36zxch3n5flock5flock22export__current__state(entries, peer_key, prune_before, flock) { const _bind = _M0MP36zxch3n5flock11sorted__map9SortedMap3getGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(flock.updates, peer_key); if (_bind.$tag === 1) { const _Some = _bind; const _peer_updates = _Some._0; let _tmp = 0; while (true) { const i = _tmp; if (i < _peer_updates.length) { _L: { const update = _M0MPC15array5Array2atGRP36zxch3n5flock5flock5EntryE(_peer_updates, i); if (update.overridden) { break _L; } _L$2: { _L$3: { const _bind$2 = _M0MP36zxch3n5flock11sorted__map9SortedMap3getGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(flock.kv, update.key); if (_bind$2 === undefined) { break _L$3; } else { const _Some$2 = _bind$2; const _current_entry = _Some$2; if (_M0IP36zxch3n5flock5flock11HlcWithPeerPB2Eq5equal(_current_entry.value.clock, update.value.clock)) { if (prune_before.$tag === 1) { const _Some$3 = prune_before; const _before = _Some$3._0; const _bind$3 = update.value.data; if (_bind$3 === undefined) { if (update.value.clock.hlc.physical_time < _before) { break _L; } } } const key = _M0FP36zxch3n5flock13memcomparable21decode__key__to__json(update.key); const exported_value = update.value; _M0MPB3Map3setGsRPB4JsonE(entries, _M0MPC14json4Json17stringify_2einner(_M0IPC15array5ArrayPB6ToJson8to__jsonGRPB4JsonE(key), false, 0, undefined), _M0MP36zxch3n5flock5flock8RawValue8to__json(exported_value)); } else { break _L$3; } } break _L$2; } break _L; } break _L; } _tmp = i + 1 | 0; continue; } else { return; } } } else { return; } } function _M0FP36zxch3n5flock5flock22export__updates__since(entries, peer_key, since, prune_before, flock) { const _bind = _M0MP36zxch3n5flock11sorted__map9SortedMap3getGRP36zxch3n5flock5types7Utf8StrRPB5ArrayGRP36zxch3n5flock5flock5EntryEE(flock.updates, peer_key); if (_bind.$tag === 1) { const _Some = _bind; const _peer_updates = _Some._0; const _bind$2 = _M0MPC15array5Array18binary__search__byGRP36zxch3n5flock5flock5EntryE(_peer_updates, (e) => { const _p = e.value.clock.hlc; return _p.physical_time < since.physical_time ? -1 : _p.physical_time > since.physical_time ? 1 : $compare_int(_p.logical_counter, since.logical_counter); }); let index; if (_bind$2.$tag === 1) { const _Ok = _bind$2; const _index = _Ok._0; index = _index + 1 | 0; } else { const _Err = _bind$2; index = _Err._0; } let _tmp = index; while (true) { const i = _tmp; if (i < _peer_updates.length) { _L: { const update = _M0MPC15array5Array2atGRP36zxch3n5flock5flock5EntryE(_peer_updates, i); if (update.overridden) { break _L; } if (prune_before.$tag === 1) { const _Some$2 = prune_before; const _before = _Some$2._0; const _bind$3 = update.value.data; if (_bind$3 === undefined) { if (update.value.clock.hlc.physical_time < _before) { break _L; } } } const key = _M0FP36zxch3n5flock13memcomparable21decode__key__to__json(update.key); const exported_value = update.value; _M0MPB3Map3setGsRPB4JsonE(entries, _M0MPC14json4Json17stringify_2einner(_M0IPC15array5ArrayPB6ToJson8to__jsonGRPB4JsonE(key), false, 0, undefined), _M0MP36zxch3n5flock5flock8RawValue8to__json(exported_value)); break _L; } _tmp = i + 1 | 0; continue; } else { return; } } } else { return; } } function _M0MP36zxch3n5flock5flock5Flock20export__json_2einner(self, from, prune_tombstones_before, peer_id) { const ans = _M0MPB3Map3newGsRP36zxch3n5flock5flock3HlcE(undefined); let target_peer_key; if (peer_id === undefined) { target_peer_key = undefined; } else { const _Some = peer_id; const _pid = _Some; const _bind = _M0FP36zxch3n5flock5flock22peer__id__from__string(_pid); if (_bind === undefined) { target_peer_key = undefined; } else { const _Some$2 = _bind; const _pk = _Some$2; target_peer_key = _pk; } } const _p = 0; const _p$2 = undefined; _M0MPB3Map3setGsRPB4JsonE(ans, "version", new _M0DTPB4Json6Number(_p, _p$2)); const entries = _M0MPB3Map3newGsRP36zxch3n5flock5flock3HlcE(undefined); if (target_peer_key === undefined) { _L: { _L$2: { if (from === undefined) { break _L$2; } else { const _Some = from; const _f = _Some; if (!(_f.size === 0)) { const _it = _M0MPB3Map5iter2GsRP36zxch3n5flock5flock3HlcE(self.vv); while (true) { const _bind = _M0MPB5Iter24nextGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(_it); if (_bind === undefined) { break; } else { const _Some$2 = _bind; const _x = _Some$2; const _peer = _x._0; const _clock = _x._1; const _p$3 = _M0MPB3Map3getGsRP36zxch3n5flock5flock3HlcE(_f, _peer); let v; if (_p$3 === undefined) { v = _M0MP36zxch3n5flock5flock3Hlc4zeroN6recordS1853; } else { const _p$4 = _p$3; v = _p$4; } if (_M0IP016_24default__implPB7Compare6op__geGRP36zxch3n5flock5flock3HlcE(v, _clock)) { continue; } const _bind$2 = _M0FP36zxch3n5flock5flock22peer__id__from__string(_peer); let peer_key; if (_bind$2 === undefined) { continue; } else { const _Some$3 = _bind$2; peer_key = _Some$3; } _M0FP36zxch3n5flock5flock22export__updates__since(entries, peer_key, v, prune_tombstones_before, self); continue; } } } else { break _L$2; } } break _L; } const _it = _M0MP36zxch3n5flock11sorted__map9SortedMap5iter2GRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(self.kv); while (true) { const _bind = _M0MPB5Iter24nextGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(_it); if (_bind === undefined) { break; } else { const _Some = _bind; const _x = _Some; const _k = _x._0; const _v = _x._1; const key = _M0FP36zxch3n5flock13memcomparable21decode__key__to__json(_k); const exported_value = _v.value; _M0MPB3Map3setGsRPB4JsonE(entries, _M0MPC14json4Json17stringify_2einner(_M0IPC15array5ArrayPB6ToJson8to__jsonGRPB4JsonE(key), false, 0, undefined), _M0MP36zxch3n5flock5flock8RawValue8to__json(exported_value)); continue; } } } } else { const _Some = target_peer_key; const _target = _Some; _L: { _L$2: { if (from === undefined) { break _L$2; } else { const _Some$2 = from; const _f = _Some$2; if (!(_f.size === 0)) { const peer_string = _M0FP36zxch3n5flock5flock21peer__key__to__string(_target); const _p$3 = _M0MPB3Map3getGsRP36zxch3n5flock5flock3HlcE(_f, peer_string); let v; if (_p$3 === undefined) { v = _M0MP36zxch3n5flock5flock3Hlc4zeroN6recordS1853; } else { const _p$4 = _p$3; v = _p$4; } _L$3: { _L$4: { const _bind = _M0MPB3Map3getGsRP36zxch3n5flock5flock3HlcE(self.vv, peer_string); if (_bind === undefined) { break _L$4; } else { const _Some$3 = _bind; const _clock = _Some$3; if (_M0IP016_24default__implPB7Compare6op__ltGRP36zxch3n5flock5flock3HlcE(v, _clock)) { _M0FP36zxch3n5flock5flock22export__updates__since(entries, _target, v, prune_tombstones_before, self); } else { break _L$4; } } break _L$3; } } } else { break _L$2; } } break _L; } _M0FP36zxch3n5flock5flock22export__current__state(entries, _target, prune_tombstones_before, self); } } _M0MPB3Map3setGsRPB4JsonE(ans, "entries", new _M0DTPB4Json6Object(entries)); return new _M0DTPB4Json6Object(ans); } function _M0MP36zxch3n5flock5flock5Flock12export__json(self, from, prune_tombstones_before$46$opt, peer_id$46$opt) { let prune_tombstones_before; if (prune_tombstones_before$46$opt === undefined) { prune_tombstones_before = _M0DTPC16option6OptionGdE4None__; } else { const _Some = prune_tombstones_before$46$opt; prune_tombstones_before = _Some; } let peer_id; if (peer_id$46$opt.$tag === 1) { const _Some = peer_id$46$opt; peer_id = _Some._0; } else { peer_id = undefined; } return _M0MP36zxch3n5flock5flock5Flock20export__json_2einner(self, from, prune_tombstones_before, peer_id); } function _M0MP36zxch3n5flock5flock5Flock20import__json_2einner(self, json, hooks) { const _bind = self.txn_events; if (_bind.$tag === 1) { const _Some = _bind; const _pending_events = _Some._0; self.txn_events = _M0DTPC16option6OptionGRPB5ArrayGURPB5ArrayGRPB4JsonERP36zxch3n5flock5flock8RawValueEEE4None__; if (_pending_events.length > 0 && !_M0MP36zxch3n5flock5flock13SubscriberSet9is__emptyGRP36zxch3n5flock5flock10EventBatchE(self.subscribers)) { _M0MP36zxch3n5flock5flock13SubscriberSet6notifyGRP36zxch3n5flock5flock10EventBatchE(self.subscribers, new _M0TP36zxch3n5flock5flock10EventBatch(_M0DTP36zxch3n5flock5flock6Source5Local__, _pending_events)); } return new _M0DTPC16result6ResultGRP36zxch3n5flock5flock12ImportReportRP36zxch3n5flock5flock11ImportErrorE3Err(new _M0DTPC15error5Error50zxch3n_2fflock_2fflock_2eImportError_2eInvalidJson(json, "import called during transaction - transaction was auto-committed")); } if (json.$tag === 6) { const _Object = json; const _map = _Object._0; let version; _L: { _L$2: { const _bind$2 = _M0MPB3Map3getGsRPB4JsonE(_map, "version"); if (_bind$2 === undefined) { return new _M0DTPC16result6ResultGRP36zxch3n5flock5flock12ImportReportRP36zxch3n5flock5flock11ImportErrorE3Err(new _M0DTPC15error5Error50zxch3n_2fflock_2fflock_2eImportError_2eInvalidJson(json, "The imported json does not contain a version field")); } else { const _Some = _bind$2; const _x = _Some; if (_x.$tag === 3) { const _Number = _x; const _version = _Number._0; if (_version === 0) { } else { version = _x; break _L$2; } } else { version = _x; break _L$2; } } break _L; } const _string_builder = _M0MPB13StringBuilder21StringBuilder_2einner(46); _M0IPB13StringBuilderPB6Logger13write__string(_string_builder, "The imported json uses an unsupported version "); _M0MPB13StringBuilder13write__objectGRPB4JsonE(_string_builder, version); return new _M0DTPC16result6ResultGRP36zxch3n5flock5flock12ImportReportRP36zxch3n5flock5flock11ImportErrorE3Err(new _M0DTPC15error5Error50zxch3n_2fflock_2fflock_2eImportError_2eInvalidJson(json, _string_builder.val)); } let events = _M0DTPC16option6OptionGRPB5ArrayGURPB5ArrayGRPB4JsonERP36zxch3n5flock5flock8RawValueEEE4None__; if (!_M0MP36zxch3n5flock5flock13SubscriberSet9is__emptyGRP36zxch3n5flock5flock10EventBatchE(self.subscribers)) { events = new _M0DTPC16option6OptionGRPB5ArrayGURPB5ArrayGRPB4JsonERP36zxch3n5flock5flock8RawValueEEE4Some(_M0MPC15array5Array11new_2einnerGRPB4JsonE(0)); } const skipped_entries = _M0MPC15array5Array11new_2einnerGRPB4JsonE(0); let accepted = 0; let entries; _L$2: { _L$3: { const _bind$2 = _M0MPB3Map3getGsRPB4JsonE(_map, "entries"); if (_bind$2 === undefined) { break _L$3; } else { const _Some = _bind$2; const _x = _Some; if (_x.$tag === 6) { const _Object$2 = _x; entries = _Object$2._0; } else { break _L$3; } } break _L$2; } return new _M0DTPC16result6ResultGRP36zxch3n5flock5flock12ImportReportRP36zxch3n5flock5flock11ImportErrorE3Err(new _M0DTPC15error5Error50zxch3n_2fflock_2fflock_2eImportError_2eInvalidJson(json, "entries is not an object")); } const _it = _M0MPB3Map5iter2GsRP36zxch3n5flock5flock3HlcE(entries); while (true) { const _bind$2 = _M0MPB5Iter24nextGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(_it); if (_bind$2 === undefined) { break; } else { const _Some = _bind$2; const _x = _Some; const _raw_key = _x._0; const _raw_value_json = _x._1; const _bind$3 = _M0MP36zxch3n5flock5flock8RawValue10from__json(_raw_value_json); let raw_value; if (_bind$3 === undefined) { return new _M0DTPC16result6ResultGRP36zxch3n5flock5flock12ImportReportRP36zxch3n5flock5flock11ImportErrorE3Err(new _M0DTPC15error5Error50zxch3n_2fflock_2fflock_2eImportError_2eInvalidJson(json, "value is not a raw value")); } else { const _Some$2 = _bind$3; raw_value = _Some$2; } let key_json; let _try_err; _L$3: { _L$4: { const _bind$4 = _M0FPC14json13parse_2einner(new _M0TPC16string10StringView(_raw_key, 0, _raw_key.length), 1024); if (_bind$4.$tag === 1) { const _ok = _bind$4; key_json = _ok._0; } else { const _err = _bind$4; _try_err = _err._0; break _L$4; } break _L$3; } key_json = $panic(); } if (key_json.$tag === 5) { const _Array = key_json; const _parts = _Array._0; const key_parts = _M0MPC15array5Array11new_2einnerGRPB4JsonE(0); let _tmp = 0; while (true) { const i = _tmp; if (i < _parts.length) { _M0MPC15array5Array4pushGRPB4JsonE(key_parts, _M0MPC15array5Array2atGRP36zxch3n5flock5flock5EntryE(_parts, i)); _tmp = i + 1 | 0; continue; } else { break; } } const _bind$4 = _M0FP36zxch3n5flock13memcomparable17encode__json__key(key_parts); if (_bind$4 === undefined) { return new _M0DTPC16result6ResultGRP36zxch3n5flock5flock12ImportReportRP36zxch3n5flock5flock11ImportErrorE3Err(new _M0DTPC15error5Error50zxch3n_2fflock_2fflock_2eImportError_2eInvalidJson(json, "key is not a valid key")); } else { const _Some$2 = _bind$4; const _encoded_bytes = _Some$2; const encoded_key = _encoded_bytes; const entry = _M0FP36zxch3n5flock5flock11make__entry(encoded_key, raw_value); let final_entry; if (hooks === undefined) { final_entry = entry; } else { const _Some$3 = hooks; const _preprocess_fn = _Some$3; const _bind$5 = _preprocess_fn(entry); if (_bind$5.$tag === 0) { final_entry = entry; } else { const _Skip = _bind$5; const _reason = _Skip._0; _M0MPC15array5Array4pushGRPB4JsonE(skipped_entries, new _M0TP36zxch3n5flock5flock12SkippedEntry(_M0MPC15array5Array4copyGRPB4JsonE(key_parts), _reason)); continue; } } accepted = accepted + 1 | 0; const peer = final_entry.value.clock.peer; const clock = final_entry.value.clock.hlc; const applied = _M0MP36zxch3n5flock5flock5Flock12apply__entry(self, final_entry, false); if (_M0IP016_24default__implPB7Compare6op__ltGRP36zxch3n5flock5flock3HlcE(self.max_hlc, clock)) { self.max_hlc = clock; } const peer_id_str = _M0FP36zxch3n5flock5flock21peer__key__to__string(peer); const _bind$5 = _M0MPB3Map3getGsRP36zxch3n5flock5flock3HlcE(self.vv, peer_id_str); if (_bind$5 === undefined) { _M0MPB3Map3setGsRP36zxch3n5flock5flock3HlcE(self.vv, peer_id_str, clock); } else { const _Some$3 = _bind$5; const _prev_clock = _Some$3; if ((_prev_clock.physical_time < clock.physical_time ? -1 : _prev_clock.physical_time > clock.physical_time ? 1 : $compare_int(_prev_clock.logical_counter, clock.logical_counter)) < 0) { _M0MPB3Map3setGsRP36zxch3n5flock5flock3HlcE(self.vv, peer_id_str, clock); } } if (applied) { const _bind$6 = events; if (_bind$6.$tag === 1) { const _Some$3 = _bind$6; const _events_ = _Some$3._0; const event_key = _M0FP36zxch3n5flock13memcomparable21decode__key__to__json(final_entry.key); _M0MPC15array5Array4pushGRPB4JsonE(_events_, { _0: event_key, _1: _M0FP36zxch3n5flock5flock17clone__raw__value(final_entry.value) }); } } } } else { return new _M0DTPC16result6ResultGRP36zxch3n5flock5flock12ImportReportRP36zxch3n5flock5flock11ImportErrorE3Err(new _M0DTPC15error5Error50zxch3n_2fflock_2fflock_2eImportError_2eInvalidJson(json, "key is not an array json")); } continue; } } const _bind$2 = events; if (_bind$2.$tag === 1) { const _Some = _bind$2; const _events = _Some._0; if (_events.length > 0) { _M0MP36zxch3n5flock5flock13SubscriberSet6notifyGRP36zxch3n5flock5flock10EventBatchE(self.subscribers, new _M0TP36zxch3n5flock5flock10EventBatch(_M0MP36zxch3n5flock5flock5Flock20import__json_2einnerN6constrS1856, _events)); } } return new _M0DTPC16result6ResultGRP36zxch3n5flock5flock12ImportReportRP36zxch3n5flock5flock11ImportErrorE2Ok(new _M0TP36zxch3n5flock5flock12ImportReport(accepted, skipped_entries)); } else { return new _M0DTPC16result6ResultGRP36zxch3n5flock5flock12ImportReportRP36zxch3n5flock5flock11ImportErrorE3Err(new _M0DTPC15error5Error50zxch3n_2fflock_2fflock_2eImportError_2eInvalidJson(json, "not an object")); } } function _M0MP36zxch3n5flock5flock5Flock12import__json(self, json, hooks$46$opt) { let hooks; if (hooks$46$opt.$tag === 1) { const _Some = hooks$46$opt; hooks = _Some._0; } else { hooks = undefined; } return _M0MP36zxch3n5flock5flock5Flock20import__json_2einner(self, json, hooks); } function _M0MP36zxch3n5flock5flock5Flock5merge(self, other) { let _try_err; _L: { _L$2: { const _bind = _M0MP36zxch3n5flock5flock5Flock12import__json(self, _M0MP36zxch3n5flock5flock5Flock12export__json(other, _M0MP36zxch3n5flock5flock5Flock7version(self), undefined, _M0DTPC16option6OptionGOsE4None__), _M0DTPC16option6OptionGOWRP36zxch3n5flock5flock5EntryERP36zxch3n5flock5flock16PreprocessResultE4None__); if (_bind.$tag === 1) { const _ok = _bind; _ok._0; } else { const _err = _bind; _try_err = _err._0; break _L$2; } break _L; } $panic(); } } function _M0MP36zxch3n5flock5flock5Flock10from__json(json, peer_id) { const flock = _M0MP36zxch3n5flock5flock5Flock3new(peer_id); const _bind = _M0MP36zxch3n5flock5flock5Flock12import__json(flock, json, _M0DTPC16option6OptionGOWRP36zxch3n5flock5flock5EntryERP36zxch3n5flock5flock16PreprocessResultE4None__); let report; if (_bind.$tag === 1) { const _ok = _bind; report = _ok._0; } else { return _bind; } return new _M0DTPC16result6ResultGRP36zxch3n5flock5flock5FlockRP36zxch3n5flock5flock11ImportErrorE2Ok(flock); } function _M0MP36zxch3n5flock5flock5Flock12kv__to__json(self) { return _M0MP36zxch3n5flock5flock5Flock12export__json(self, undefined, undefined, _M0DTPC16option6OptionGOsE4None__); } function _M0MP36zxch3n5flock5flock5Flock16put__mvr_2einner(self, key, value, now) { const _it = _M0MP36zxch3n5flock5flock5Flock4scan(self, undefined, undefined, new _M0DTPC16option6OptionGRPB5ArrayGRPB4JsonEE4Some(key)); while (true) { const _bind = _M0MPB5Iter24nextGRPB5ArrayGRPB4JsonERP36zxch3n5flock5flock5EntryE(_it); if (_bind === undefined) { break; } else { const _Some = _bind; const _x = _Some; const _k = _x._0; const _v = _x._1; let _tmp; if (_k.length === (key.length + 1 | 0)) { const _tmp$2 = _v.value.data; const _p = true; _tmp = _M0IPC16option6OptionPB2Eq5equalGRPB4JsonE(_tmp$2, _p ? _M0DTPB4Json4True__ : _M0DTPB4Json5False__); } else { _tmp = false; } if (_tmp) { const _bind$2 = _M0MP36zxch3n5flock5flock5Flock14delete_2einner(self, _k, now); if (_bind$2.$tag === 1) { const _ok = _bind$2; _ok._0; } else { return _bind$2; } } continue; } } const key$2 = _M0MPC15array5Array4copyGRPB4JsonE(key); _L: { _L$2: { switch (value.$tag) { case 5: { break _L$2; } case 0: { break _L$2; } case 6: { break _L$2; } } break _L; } return new _M0DTPC16result6ResultGuRP36zxch3n5flock5flock8PutErrorE3Err(new _M0DTPC15error5Error54zxch3n_2fflock_2fflock_2ePutError_2eInvalidValueForMvr(value)); } _M0MPC15array5Array4pushGRPB4JsonE(key$2, value); const _p = true; return _M0MP36zxch3n5flock5flock5Flock10put__inner(self, key$2, _p ? _M0DTPB4Json4True__ : _M0DTPB4Json5False__, _M0DTPC16option6OptionGORPB3MapGsRPB4JsonEE4None__, now, _M0DTPC16option6OptionGOWRP36zxch3n5flock5flock5EntryEORP36zxch3n5flock5flock5EntryE4None__, -1); } function _M0MP36zxch3n5flock5flock5Flock8get__mvr(self, key) { const ans = []; const _it = _M0MP36zxch3n5flock5flock5Flock4scan(self, undefined, undefined, new _M0DTPC16option6OptionGRPB5ArrayGRPB4JsonEE4Some(key)); while (true) { const _bind = _M0MPB5Iter24nextGRPB5ArrayGRPB4JsonERP36zxch3n5flock5flock5EntryE(_it); if (_bind === undefined) { break; } else { const _Some = _bind; const _x = _Some; const _k = _x._0; const _v = _x._1; let _tmp; if (_k.length !== (key.length + 1 | 0)) { _tmp = true; } else { const _tmp$2 = _v.value.data; const _p = true; _tmp = _M0IP016_24default__implPB2Eq10not__equalGORPB4JsonE(_tmp$2, _p ? _M0DTPB4Json4True__ : _M0DTPB4Json5False__); } if (_tmp) { continue; } const value = _M0MPC15array5Array2atGRP36zxch3n5flock5flock5EntryE(_k, key.length); _M0MPC15array5Array4pushGRPB4JsonE(ans, value); continue; } } return ans; } function _M0MP36zxch3n5flock5flock5Flock8newFlock(peer_id) { return _M0MP36zxch3n5flock5flock5Flock3new(peer_id); } function _M0FP36zxch3n5flock5flock22json__stringify__value(value) { return _M0FP36zxch3n5flock5flock27ffi__json__stringify__value(value); } function _M0FP36zxch3n5flock5flock15value__to__json(value) { const json_string = _M0FP36zxch3n5flock5flock22json__stringify__value(value); let _try_err; _L: { const _bind = _M0FPC14json13parse_2einner(new _M0TPC16string10StringView(json_string, 0, json_string.length), 1024); if (_bind.$tag === 1) { const _ok = _bind; return _ok._0; } else { const _err = _bind; _try_err = _err._0; break _L; } } return $panic(); } function _M0MP36zxch3n5flock5flock5Flock8put__ffi(self, key, value, now) { let _try_err; _L: { const _bind = _M0MP27Yoorkin4jmop3Any13unwrap__value(key, "moon/flock/ffi-js.mbt:14:15-14:33@zxch3n/flock"); let key$2; if (_bind.$tag === 1) { const _ok = _bind; key$2 = _ok._0; } else { const _err = _bind; _try_err = _err._0; break _L; } let value$2; let _try_err$2; _L$2: { _L$3: { const _bind$2 = _M0FPC14json13parse_2einner(new _M0TPC16string10StringView(value, 0, value.length), 1024); if (_bind$2.$tag === 1) { const _ok = _bind$2; value$2 = _ok._0; } else { const _err = _bind$2; _try_err$2 = _err._0; break _L$3; } break _L$2; } value$2 = $panic(); } const _bind$2 = _M0MP27Yoorkin4jmop5Value9to__arrayGRP27Yoorkin4jmop5ValueE(key$2, "moon/flock/ffi-js.mbt:16:40-16:54@zxch3n/flock"); let key_arr; if (_bind$2.$tag === 1) { const _ok = _bind$2; key_arr = _ok._0; } else { const _err = _bind$2; _try_err = _err._0; break _L; } const _p = new Array(key_arr.length); const _p$2 = key_arr.length; let _tmp = 0; while (true) { const _p$3 = _tmp; if (_p$3 < _p$2) { const _p$4 = key_arr[_p$3]; _p[_p$3] = _M0FP36zxch3n5flock5flock15value__to__json(_p$4); _tmp = _p$3 + 1 | 0; continue; } else { break; } } const key_arr$2 = _p; const _bind$3 = _M0MP36zxch3n5flock5flock5Flock10put__inner(self, key_arr$2, value$2, _M0DTPC16option6OptionGORPB3MapGsRPB4JsonEE4None__, new _M0DTPC16option6OptionGdE4Some(now), _M0DTPC16option6OptionGOWRP36zxch3n5flock5flock5EntryEORP36zxch3n5flock5flock5EntryE4None__, -1); if (_bind$3.$tag === 1) { const _ok = _bind$3; _ok._0; return; } else { const _err = _bind$3; _try_err = _err._0; break _L; } } $panic(); } function _M0FP36zxch3n5flock5flock22json__parse__to__value(json) { return _M0FP36zxch3n5flock5flock30ffi__json__parse__to__nullable(json); } function _M0FP36zxch3n5flock5flock15json__to__value(json) { const json_string = _M0MPC14json4Json17stringify_2einner(json, false, 0, undefined); return _M0FP36zxch3n5flock5flock22json__parse__to__value(json_string); } function _M0FP36zxch3n5flock5flock18json__to__metadata(json) { switch (json.$tag) { case 6: { const _Object = json; const _obj = _Object._0; const metadata = _M0MPB3Map3newGsRP36zxch3n5flock5flock3HlcE(undefined); let _tmp = _obj.head; while (true) { const _p = _tmp; if (_p === undefined) { break; } else { const _p$2 = _p; const _p$3 = _p$2; const _p$4 = _p$3.key; const _p$5 = _p$3.value; const _p$6 = _p$3.next; _M0MPB3Map3setGsRPB4JsonE(metadata, _p$4, _p$5); _tmp = _p$6; continue; } } return metadata; } case 0: { return undefined; } default: { return _M0FPC15abort5abortGRP27Yoorkin4jmop3AnyE("metadata must be an object or null"); } } } function _M0MP36zxch3n5flock5flock5Flock8get__ffi(self, key) { let _try_err; _L: { const _bind = _M0MP27Yoorkin4jmop3Any13unwrap__value(key, "moon/flock/ffi-js.mbt:50:15-50:33@zxch3n/flock"); let key$2; if (_bind.$tag === 1) { const _ok = _bind; key$2 = _ok._0; } else { const _err = _bind; _try_err = _err._0; break _L; } const _bind$2 = _M0MP27Yoorkin4jmop5Value9to__arrayGRP27Yoorkin4jmop5ValueE(key$2, "moon/flock/ffi-js.mbt:51:40-51:54@zxch3n/flock"); let key_arr; if (_bind$2.$tag === 1) { const _ok = _bind$2; key_arr = _ok._0; } else { const _err = _bind$2; _try_err = _err._0; break _L; } const _p = new Array(key_arr.length); const _p$2 = key_arr.length; let _tmp = 0; while (true) { const _p$3 = _tmp; if (_p$3 < _p$2) { const _p$4 = key_arr[_p$3]; _p[_p$3] = _M0FP36zxch3n5flock5flock15value__to__json(_p$4); _tmp = _p$3 + 1 | 0; continue; } else { break; } } const key_arr$2 = _p; const ans = _M0MP36zxch3n5flock5flock5Flock3get(self, key_arr$2); if (ans === undefined) { const a = _M0MP27Yoorkin4jmop8Optional9undefinedGRP27Yoorkin4jmop5ValueE(); return a; } else { const _Some = ans; const _value = _Some; const _p$3 = _M0FP36zxch3n5flock5flock15json__to__value(_value); return _p$3; } } return $panic(); } function _M0FP36zxch3n5flock5flock15clock__to__json(clock) { const obj = _M0MPB3Map3newGsRP36zxch3n5flock5flock3HlcE(undefined); _M0MPB3Map3setGsRPB4JsonE(obj, "physicalTime", _M0IPC16double6DoublePB6ToJson8to__json(clock.hlc.physical_time)); _M0MPB3Map3setGsRPB4JsonE(obj, "logicalCounter", _M0IPC13int3IntPB6ToJson8to__json(clock.hlc.logical_counter)); const _p = _M0FP36zxch3n5flock5flock21peer__key__to__string(clock.peer); _M0MPB3Map3setGsRPB4JsonE(obj, "peerId", new _M0DTPB4Json6String(_p)); return _M0IPB3MapPB6ToJson8to__jsonGsRPB4JsonE(obj); } function _M0FP36zxch3n5flock5flock23metadata__map__to__json(metadata) { const obj = _M0MPB3Map3newGsRP36zxch3n5flock5flock3HlcE(undefined); let _tmp = metadata.head; while (true) { const _p = _tmp; if (_p === undefined) { break; } else { const _p$2 = _p; const _p$3 = _p$2; const _p$4 = _p$3.key; const _p$5 = _p$3.value; const _p$6 = _p$3.next; _M0MPB3Map3setGsRPB4JsonE(obj, _p$4, _p$5); _tmp = _p$6; continue; } } return _M0IPB3MapPB6ToJson8to__jsonGsRPB4JsonE(obj); } function _M0MP36zxch3n5flock5flock5Flock15get__entry__ffi(self, key) { let _try_err; _L: { const _bind = _M0MP27Yoorkin4jmop3Any13unwrap__value(key, "moon/flock/ffi-js.mbt:67:15-67:33@zxch3n/flock"); let key$2; if (_bind.$tag === 1) { const _ok = _bind; key$2 = _ok._0; } else { const _err = _bind; _try_err = _err._0; break _L; } const _bind$2 = _M0MP27Yoorkin4jmop5Value9to__arrayGRP27Yoorkin4jmop5ValueE(key$2, "moon/flock/ffi-js.mbt:68:40-68:54@zxch3n/flock"); let key_arr; if (_bind$2.$tag === 1) { const _ok = _bind$2; key_arr = _ok._0; } else { const _err = _bind$2; _try_err = _err._0; break _L; } const _p = new Array(key_arr.length); const _p$2 = key_arr.length; let _tmp = 0; while (true) { const _p$3 = _tmp; if (_p$3 < _p$2) { const _p$4 = key_arr[_p$3]; _p[_p$3] = _M0FP36zxch3n5flock5flock15value__to__json(_p$4); _tmp = _p$3 + 1 | 0; continue; } else { break; } } const key_arr$2 = _p; const _bind$3 = _M0MP36zxch3n5flock5flock5Flock10get__entry(self, key_arr$2); if (_bind$3 === undefined) { const a = _M0MP27Yoorkin4jmop8Optional9undefinedGRP27Yoorkin4jmop5ValueE(); return a; } else { const _Some = _bind$3; const _info = _Some; const obj = _M0MPB3Map3newGsRP36zxch3n5flock5flock3HlcE(undefined); const _bind$4 = _info.data; if (_bind$4 === undefined) { } else { const _Some$2 = _bind$4; const _data = _Some$2; _M0MPB3Map3setGsRPB4JsonE(obj, "data", _data); } _M0MPB3Map3setGsRPB4JsonE(obj, "metadata", _M0FP36zxch3n5flock5flock23metadata__map__to__json(_info.metadata)); _M0MPB3Map3setGsRPB4JsonE(obj, "clock", _M0FP36zxch3n5flock5flock15clock__to__json(_info.clock)); const _p$3 = _M0FP36zxch3n5flock5flock15json__to__value(_M0IPB3MapPB6ToJson8to__jsonGsRPB4JsonE(obj)); return _p$3; } } return $panic(); } function _M0FP36zxch3n5flock5flock13any__is__null(value) { return _M0FP36zxch3n5flock5flock18ffi__any__is__null(value); } function _M0FP36zxch3n5flock5flock18any__is__undefined(value) { return _M0FP36zxch3n5flock5flock23ffi__any__is__undefined(value); } function _M0FP36zxch3n5flock5flock25json__to__version__vector(json) { if (json.$tag === 6) { const _Object = json; const _map = _Object._0; const vv = _M0MPB3Map3newGsRP36zxch3n5flock5flock3HlcE(undefined); const _it = _M0MPB3Map5iter2GsRP36zxch3n5flock5flock3HlcE(_map); while (true) { const _bind = _M0MPB5Iter24nextGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(_it); if (_bind === undefined) { break; } else { const _Some = _bind; const _x = _Some; const _peer = _x._0; const _raw_clock = _x._1; const _bind$2 = _M0FP36zxch3n5flock5flock22peer__id__from__string(_peer); if (_bind$2 === undefined) { _M0FPC15abort5abortGuE("invalid peer id in version vector"); } _L: { _L$2: { if (_raw_clock.$tag === 5) { const _Array = _raw_clock; const _parts = _Array._0; if (_parts.length >= 2) { const physical_time = _M0MPC16option6Option6unwrapGdE(_M0MPC14json4Json10as__number(_M0MPC15array5Array2atGRP36zxch3n5flock5flock5EntryE(_parts, 0))); const logical_counter = _M0MPC16double6Double7to__int(_M0MPC16option6Option6unwrapGdE(_M0MPC14json4Json10as__number(_M0MPC15array5Array2atGRP36zxch3n5flock5flock5EntryE(_parts, 1)))); _M0MPB3Map3setGsRP36zxch3n5flock5flock3HlcE(vv, _peer, _M0MP36zxch3n5flock5flock3Hlc11from__parts(physical_time, logical_counter)); } else { break _L$2; } } else { break _L$2; } break _L; } _M0FPC15abort5abortGuE("version vector entry must be [physical_time, logical_counter]"); } continue; } } return vv; } else { return _M0FPC15abort5abortGRP36zxch3n5flock5types7Utf8StrE("version vector must be an object"); } } function _M0MP36zxch3n5flock5flock5Flock17export__json__ffi(self, from, prune_tombstones_before, peer_id) { let _try_err; _L: { let export_from; if (_M0FP36zxch3n5flock5flock18any__is__undefined(from) || _M0FP36zxch3n5flock5flock13any__is__null(from)) { export_from = undefined; } else { const _bind = _M0MP27Yoorkin4jmop3Any13unwrap__value(from, "moon/flock/ffi-js.mbt:100:32-100:51@zxch3n/flock"); let _tmp; if (_bind.$tag === 1) { const _ok = _bind; _tmp = _ok._0; } else { const _err = _bind; _try_err = _err._0; break _L; } const json = _M0FP36zxch3n5flock5flock15value__to__json(_tmp); export_from = _M0FP36zxch3n5flock5flock25json__to__version__vector(json); } let prune_before; if (_M0FP36zxch3n5flock5flock18any__is__undefined(prune_tombstones_before) || _M0FP36zxch3n5flock5flock13any__is__null(prune_tombstones_before)) { prune_before = _M0DTPC16option6OptionGdE4None__; } else { const _bind = _M0MP27Yoorkin4jmop3Any13unwrap__value(prune_tombstones_before, "moon/flock/ffi-js.mbt:107:12-107:50@zxch3n/flock"); let _tmp; if (_bind.$tag === 1) { const _ok = _bind; _tmp = _ok._0; } else { const _err = _bind; _try_err = _err._0; break _L; } const _bind$2 = _M0MP27Yoorkin4jmop5Value10to__number(_tmp, "moon/flock/ffi-js.mbt:107:12-107:62@zxch3n/flock"); let _tmp$2; if (_bind$2.$tag === 1) { const _ok = _bind$2; _tmp$2 = _ok._0; } else { const _err = _bind$2; _try_err = _err._0; break _L; } prune_before = new _M0DTPC16option6OptionGdE4Some(_tmp$2); } let target_peer_id; if (_M0FP36zxch3n5flock5flock18any__is__undefined(peer_id) || _M0FP36zxch3n5flock5flock13any__is__null(peer_id)) { target_peer_id = undefined; } else { const _bind = _M0MP27Yoorkin4jmop3Any13unwrap__value(peer_id, "moon/flock/ffi-js.mbt:112:12-112:34@zxch3n/flock"); let _tmp; if (_bind.$tag === 1) { const _ok = _bind; _tmp = _ok._0; } else { const _err = _bind; _try_err = _err._0; break _L; } const _bind$2 = _M0MP27Yoorkin4jmop5Value10to__string(_tmp, "moon/flock/ffi-js.mbt:112:12-112:46@zxch3n/flock"); if (_bind$2.$tag === 1) { const _ok = _bind$2; target_peer_id = _ok._0; } else { const _err = _bind$2; _try_err = _err._0; break _L; } } let exported; if (export_from === undefined) { exported = _M0MP36zxch3n5flock5flock5Flock20export__json_2einner(self, undefined, prune_before, target_peer_id); } else { const _Some = export_from; const _vv = _Some; exported = _M0MP36zxch3n5flock5flock5Flock20export__json_2einner(self, _vv, prune_before, target_peer_id); } const _p = _M0FP36zxch3n5flock5flock15json__to__value(exported); return _p; } return $panic(); } function _M0MP36zxch3n5flock5flock5Flock17import__json__ffi(self, json) { let _try_err; _L: { if (!(_M0FP36zxch3n5flock5flock18any__is__undefined(json) || _M0FP36zxch3n5flock5flock13any__is__null(json))) { const _bind = _M0MP27Yoorkin4jmop3Any13unwrap__value(json, "moon/flock/ffi-js.mbt:137:32-137:51@zxch3n/flock"); let _tmp; if (_bind.$tag === 1) { const _ok = _bind; _tmp = _ok._0; } else { const _err = _bind; _try_err = _err._0; break _L; } const parsed = _M0FP36zxch3n5flock5flock15value__to__json(_tmp); let report; let _try_err$2; _L$2: { _L$3: { const _bind$2 = _M0MP36zxch3n5flock5flock5Flock12import__json(self, parsed, _M0DTPC16option6OptionGOWRP36zxch3n5flock5flock5EntryERP36zxch3n5flock5flock16PreprocessResultE4None__); if (_bind$2.$tag === 1) { const _ok = _bind$2; report = _ok._0; } else { const _err = _bind$2; _try_err$2 = _err._0; break _L$3; } break _L$2; } report = $panic(); } const skipped_rows = _M0MPC15array5Array11new_2einnerGRPB4JsonE(0); let _tmp$2 = 0; while (true) { const i = _tmp$2; if (i < report.skipped.length) { const skipped = _M0MPC15array5Array2atGRP36zxch3n5flock5flock5EntryE(report.skipped, i); const obj = _M0MPB3Map3newGsRP36zxch3n5flock5flock3HlcE(undefined); _M0MPB3Map3setGsRPB4JsonE(obj, "key", _M0IPC15array5ArrayPB6ToJson8to__jsonGRPB4JsonE(skipped.key)); const _p = skipped.reason; _M0MPB3Map3setGsRPB4JsonE(obj, "reason", new _M0DTPB4Json6String(_p)); _M0MPC15array5Array4pushGRPB4JsonE(skipped_rows, _M0IPB3MapPB6ToJson8to__jsonGsRPB4JsonE(obj)); _tmp$2 = i + 1 | 0; continue; } else { break; } } const report_obj = _M0MPB3Map3newGsRP36zxch3n5flock5flock3HlcE(undefined); _M0MPB3Map3setGsRPB4JsonE(report_obj, "accepted", _M0IPC13int3IntPB6ToJson8to__json(report.accepted)); _M0MPB3Map3setGsRPB4JsonE(report_obj, "skipped", _M0IPC15array5ArrayPB6ToJson8to__jsonGRPB4JsonE(skipped_rows)); const _p = _M0FP36zxch3n5flock5flock15json__to__value(_M0IPB3MapPB6ToJson8to__jsonGsRPB4JsonE(report_obj)); return _p; } else { return _M0FPC15abort5abortGRP27Yoorkin4jmop3AnyE("json is null or undefined"); } } return $panic(); } function _M0MP36zxch3n5flock5flock5Flock22import__json__str__ffi(self, json_str) { let _try_err; _L: { if (!(_M0FP36zxch3n5flock5flock18any__is__undefined(json_str) || _M0FP36zxch3n5flock5flock13any__is__null(json_str))) { const _bind = _M0MP27Yoorkin4jmop3Any13unwrap__value(json_str, "moon/flock/ffi-js.mbt:163:13-163:36@zxch3n/flock"); let _tmp; if (_bind.$tag === 1) { const _ok = _bind; _tmp = _ok._0; } else { const _err = _bind; _try_err = _err._0; break _L; } const _bind$2 = _M0MP27Yoorkin4jmop5Value10to__string(_tmp, "moon/flock/ffi-js.mbt:163:13-163:48@zxch3n/flock"); let s; if (_bind$2.$tag === 1) { const _ok = _bind$2; s = _ok._0; } else { const _err = _bind$2; _try_err = _err._0; break _L; } let parsed; let _try_err$2; _L$2: { _L$3: { const _bind$3 = _M0FPC14json13parse_2einner(new _M0TPC16string10StringView(s, 0, s.length), 1024); if (_bind$3.$tag === 1) { const _ok = _bind$3; parsed = _ok._0; } else { const _err = _bind$3; _try_err$2 = _err._0; break _L$3; } break _L$2; } parsed = $panic(); } let report; let _try_err$3; _L$3: { _L$4: { const _bind$3 = _M0MP36zxch3n5flock5flock5Flock12import__json(self, parsed, _M0DTPC16option6OptionGOWRP36zxch3n5flock5flock5EntryERP36zxch3n5flock5flock16PreprocessResultE4None__); if (_bind$3.$tag === 1) { const _ok = _bind$3; report = _ok._0; } else { const _err = _bind$3; _try_err$3 = _err._0; break _L$4; } break _L$3; } report = $panic(); } const skipped_rows = _M0MPC15array5Array11new_2einnerGRPB4JsonE(0); let _tmp$2 = 0; while (true) { const i = _tmp$2; if (i < report.skipped.length) { const skipped = _M0MPC15array5Array2atGRP36zxch3n5flock5flock5EntryE(report.skipped, i); const obj = _M0MPB3Map3newGsRP36zxch3n5flock5flock3HlcE(undefined); _M0MPB3Map3setGsRPB4JsonE(obj, "key", _M0IPC15array5ArrayPB6ToJson8to__jsonGRPB4JsonE(skipped.key)); const _p = skipped.reason; _M0MPB3Map3setGsRPB4JsonE(obj, "reason", new _M0DTPB4Json6String(_p)); _M0MPC15array5Array4pushGRPB4JsonE(skipped_rows, _M0IPB3MapPB6ToJson8to__jsonGsRPB4JsonE(obj)); _tmp$2 = i + 1 | 0; continue; } else { break; } } const report_obj = _M0MPB3Map3newGsRP36zxch3n5flock5flock3HlcE(undefined); _M0MPB3Map3setGsRPB4JsonE(report_obj, "accepted", _M0IPC13int3IntPB6ToJson8to__json(report.accepted)); _M0MPB3Map3setGsRPB4JsonE(report_obj, "skipped", _M0IPC15array5ArrayPB6ToJson8to__jsonGRPB4JsonE(skipped_rows)); const _p = _M0FP36zxch3n5flock5flock15json__to__value(_M0IPB3MapPB6ToJson8to__jsonGsRPB4JsonE(report_obj)); return _p; } else { return _M0FPC15abort5abortGRP27Yoorkin4jmop3AnyE("json is null or undefined"); } } return $panic(); } function _M0FP36zxch3n5flock5flock25version__vector__to__json(vv) { const result = _M0MPB3Map3newGsRP36zxch3n5flock5flock3HlcE(undefined); const _it = _M0MPB3Map5iter2GsRP36zxch3n5flock5flock3HlcE(vv); while (true) { const _bind = _M0MPB5Iter24nextGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(_it); if (_bind === undefined) { break; } else { const _Some = _bind; const _x = _Some; const _peer = _x._0; const _clock = _x._1; const entry = [_M0IPC16double6DoublePB6ToJson8to__json(_clock.physical_time), _M0IPC13int3IntPB6ToJson8to__json(_clock.logical_counter)]; _M0MPB3Map3setGsRPB4JsonE(result, _peer, _M0IPC15array5ArrayPB6ToJson8to__jsonGRPB4JsonE(entry)); continue; } } return _M0IPB3MapPB6ToJson8to__jsonGsRPB4JsonE(result); } function _M0MP36zxch3n5flock5flock5Flock12version__ffi(self) { const json = _M0FP36zxch3n5flock5flock25version__vector__to__json(_M0MP36zxch3n5flock5flock5Flock7version(self)); const _p = _M0FP36zxch3n5flock5flock15json__to__value(json); return _p; } function _M0MP36zxch3n5flock5flock5Flock21inclusiveVersion__ffi(self) { const json = _M0FP36zxch3n5flock5flock25version__vector__to__json(_M0MP36zxch3n5flock5flock5Flock16inclusiveVersion(self)); const _p = _M0FP36zxch3n5flock5flock15json__to__value(json); return _p; } function _M0FP36zxch3n5flock5flock20string__to__peer__id(peer_id) { const _bind = _M0FP36zxch3n5flock5flock22peer__id__from__string(peer_id); return _bind === undefined ? _M0FPC15abort5abortGRP36zxch3n5flock5types7Utf8StrE("invalid peer id") : peer_id; } function _M0FP36zxch3n5flock5flock17bound__from__json(json) { if (json.$tag === 6) { const _Object = json; const _obj = _Object._0; let kind; _L: { _L$2: { const _bind = _M0MPB3Map3getGsRPB4JsonE(_obj, "kind"); if (_bind === undefined) { break _L$2; } else { const _Some = _bind; const _x = _Some; if (_x.$tag === 4) { const _String = _x; kind = _String._0; } else { break _L$2; } } break _L; } kind = _M0FPC15abort5abortGRP36zxch3n5flock5types7Utf8StrE("bound.kind must be a string"); } let key; _L$2: { _L$3: { const _bind = _M0MPB3Map3getGsRPB4JsonE(_obj, "key"); if (_bind === undefined) { break _L$3; } else { const _Some = _bind; const _x = _Some; if (_x.$tag === 5) { const _Array = _x; const _arr = _Array._0; key = _M0MPC15array5Array4copyGRPB4JsonE(_arr); } else { break _L$3; } } break _L$2; } key = _M0FPC15abort5abortGRP27Yoorkin4jmop3AnyE("bound.key must be an array"); } return kind === "inclusive" ? new _M0DTP36zxch3n5flock11sorted__map5BoundGRPB5ArrayGRPB4JsonEE9Inclusive(key) : kind === "exclusive" ? new _M0DTP36zxch3n5flock11sorted__map5BoundGRPB5ArrayGRPB4JsonEE9Exclusive(key) : kind === "unbounded" ? _M0DTP36zxch3n5flock11sorted__map5BoundGRPB5ArrayGRPB4JsonEE9Unbounded__ : _M0FPC15abort5abortGRP36zxch3n5flock5types7Utf8StrE("unexpected bound.kind"); } else { return _M0FPC15abort5abortGRP36zxch3n5flock5types7Utf8StrE("bound must be an object"); } } function _M0FP36zxch3n5flock5flock23check__consistency__ffi(a, b) { return _M0MP36zxch3n5flock5flock5Flock18check__consistency(a, b); } function _M0MP36zxch3n5flock5flock5Flock22check__invariants__ffi(self) { _M0MP36zxch3n5flock5flock5Flock17check__invariants(self); } function _M0MP36zxch3n5flock5flock5Flock14put__json__ffi(self, key, value, now) { let _try_err; _L: { const _bind = _M0MP27Yoorkin4jmop3Any13unwrap__value(key, "moon/flock/ffi-js.mbt:284:21-284:39@zxch3n/flock"); let key_value; if (_bind.$tag === 1) { const _ok = _bind; key_value = _ok._0; } else { const _err = _bind; _try_err = _err._0; break _L; } const _bind$2 = _M0MP27Yoorkin4jmop5Value9to__arrayGRP27Yoorkin4jmop5ValueE(key_value, "moon/flock/ffi-js.mbt:285:40-285:60@zxch3n/flock"); let key_arr; if (_bind$2.$tag === 1) { const _ok = _bind$2; key_arr = _ok._0; } else { const _err = _bind$2; _try_err = _err._0; break _L; } const _p = new Array(key_arr.length); const _p$2 = key_arr.length; let _tmp = 0; while (true) { const _p$3 = _tmp; if (_p$3 < _p$2) { const _p$4 = key_arr[_p$3]; _p[_p$3] = _M0FP36zxch3n5flock5flock15value__to__json(_p$4); _tmp = _p$3 + 1 | 0; continue; } else { break; } } const key_json = _p; let value_json; let _try_err$2; _L$2: { _L$3: { const _bind$3 = _M0FPC14json13parse_2einner(new _M0TPC16string10StringView(value, 0, value.length), 1024); if (_bind$3.$tag === 1) { const _ok = _bind$3; value_json = _ok._0; } else { const _err = _bind$3; _try_err$2 = _err._0; break _L$3; } break _L$2; } value_json = $panic(); } let now_value; if (_M0FP36zxch3n5flock5flock18any__is__undefined(now) || _M0FP36zxch3n5flock5flock13any__is__null(now)) { now_value = _M0DTPC16option6OptionGdE4None__; } else { const _bind$3 = _M0MP27Yoorkin4jmop3Any13unwrap__value(now, "moon/flock/ffi-js.mbt:291:12-291:30@zxch3n/flock"); let _tmp$2; if (_bind$3.$tag === 1) { const _ok = _bind$3; _tmp$2 = _ok._0; } else { const _err = _bind$3; _try_err = _err._0; break _L; } const _bind$4 = _M0MP27Yoorkin4jmop5Value10to__number(_tmp$2, "moon/flock/ffi-js.mbt:291:12-291:42@zxch3n/flock"); let _tmp$3; if (_bind$4.$tag === 1) { const _ok = _bind$4; _tmp$3 = _ok._0; } else { const _err = _bind$4; _try_err = _err._0; break _L; } now_value = new _M0DTPC16option6OptionGdE4Some(_tmp$3); } const _bind$3 = _M0MP36zxch3n5flock5flock5Flock11put_2einner(self, key_json, value_json, now_value); if (_bind$3.$tag === 1) { const _ok = _bind$3; _ok._0; return; } else { const _err = _bind$3; _try_err = _err._0; break _L; } } $panic(); } function _M0MP36zxch3n5flock5flock5Flock20put__with__meta__ffi(self, key, value, metadata, now) { let _try_err; _L: { const _bind = _M0MP27Yoorkin4jmop3Any13unwrap__value(key, "moon/flock/ffi-js.mbt:306:21-306:39@zxch3n/flock"); let key_value; if (_bind.$tag === 1) { const _ok = _bind; key_value = _ok._0; } else { const _err = _bind; _try_err = _err._0; break _L; } const _bind$2 = _M0MP27Yoorkin4jmop5Value9to__arrayGRP27Yoorkin4jmop5ValueE(key_value, "moon/flock/ffi-js.mbt:307:40-307:60@zxch3n/flock"); let key_arr; if (_bind$2.$tag === 1) { const _ok = _bind$2; key_arr = _ok._0; } else { const _err = _bind$2; _try_err = _err._0; break _L; } const _p = new Array(key_arr.length); const _p$2 = key_arr.length; let _tmp = 0; while (true) { const _p$3 = _tmp; if (_p$3 < _p$2) { const _p$4 = key_arr[_p$3]; _p[_p$3] = _M0FP36zxch3n5flock5flock15value__to__json(_p$4); _tmp = _p$3 + 1 | 0; continue; } else { break; } } const key_json = _p; let value_json; let _try_err$2; _L$2: { _L$3: { const _bind$3 = _M0FPC14json13parse_2einner(new _M0TPC16string10StringView(value, 0, value.length), 1024); if (_bind$3.$tag === 1) { const _ok = _bind$3; value_json = _ok._0; } else { const _err = _bind$3; _try_err$2 = _err._0; break _L$3; } break _L$2; } value_json = $panic(); } let metadata_value; if (_M0FP36zxch3n5flock5flock18any__is__undefined(metadata) || _M0FP36zxch3n5flock5flock13any__is__null(metadata)) { metadata_value = undefined; } else { const _bind$3 = _M0MP27Yoorkin4jmop3Any13unwrap__value(metadata, "moon/flock/ffi-js.mbt:313:41-313:64@zxch3n/flock"); let _tmp$2; if (_bind$3.$tag === 1) { const _ok = _bind$3; _tmp$2 = _ok._0; } else { const _err = _bind$3; _try_err = _err._0; break _L; } const metadata_json = _M0FP36zxch3n5flock5flock15value__to__json(_tmp$2); metadata_value = _M0FP36zxch3n5flock5flock18json__to__metadata(metadata_json); } let now_value; if (_M0FP36zxch3n5flock5flock18any__is__undefined(now) || _M0FP36zxch3n5flock5flock13any__is__null(now)) { now_value = _M0DTPC16option6OptionGdE4None__; } else { const _bind$3 = _M0MP27Yoorkin4jmop3Any13unwrap__value(now, "moon/flock/ffi-js.mbt:319:12-319:30@zxch3n/flock"); let _tmp$2; if (_bind$3.$tag === 1) { const _ok = _bind$3; _tmp$2 = _ok._0; } else { const _err = _bind$3; _try_err = _err._0; break _L; } const _bind$4 = _M0MP27Yoorkin4jmop5Value10to__number(_tmp$2, "moon/flock/ffi-js.mbt:319:12-319:42@zxch3n/flock"); let _tmp$3; if (_bind$4.$tag === 1) { const _ok = _bind$4; _tmp$3 = _ok._0; } else { const _err = _bind$4; _try_err = _err._0; break _L; } now_value = new _M0DTPC16option6OptionGdE4Some(_tmp$3); } if (metadata_value === undefined) { const _bind$3 = _M0MP36zxch3n5flock5flock5Flock15put__with__meta(self, key_json, value_json, _M0DTPC16option6OptionGORPB3MapGsRPB4JsonEE4None__, now_value, _M0DTPC16option6OptionGOWRP36zxch3n5flock5flock5EntryEORP36zxch3n5flock5flock5EntryE4None__); if (_bind$3.$tag === 1) { const _ok = _bind$3; _ok._0; return; } else { const _err = _bind$3; _try_err = _err._0; break _L; } } else { const _Some = metadata_value; const _meta = _Some; const _bind$3 = _M0MP36zxch3n5flock5flock5Flock15put__with__meta(self, key_json, value_json, new _M0DTPC16option6OptionGORPB3MapGsRPB4JsonEE4Some(_meta), now_value, _M0DTPC16option6OptionGOWRP36zxch3n5flock5flock5EntryEORP36zxch3n5flock5flock5EntryE4None__); if (_bind$3.$tag === 1) { const _ok = _bind$3; _ok._0; return; } else { const _err = _bind$3; _try_err = _err._0; break _L; } } } $panic(); } function _M0MP36zxch3n5flock5flock5Flock11delete__ffi(self, key, now) { let _try_err; _L: { const _bind = _M0MP27Yoorkin4jmop3Any13unwrap__value(key, "moon/flock/ffi-js.mbt:341:21-341:39@zxch3n/flock"); let key_value; if (_bind.$tag === 1) { const _ok = _bind; key_value = _ok._0; } else { const _err = _bind; _try_err = _err._0; break _L; } const _bind$2 = _M0MP27Yoorkin4jmop5Value9to__arrayGRP27Yoorkin4jmop5ValueE(key_value, "moon/flock/ffi-js.mbt:342:40-342:60@zxch3n/flock"); let key_arr; if (_bind$2.$tag === 1) { const _ok = _bind$2; key_arr = _ok._0; } else { const _err = _bind$2; _try_err = _err._0; break _L; } const _p = new Array(key_arr.length); const _p$2 = key_arr.length; let _tmp = 0; while (true) { const _p$3 = _tmp; if (_p$3 < _p$2) { const _p$4 = key_arr[_p$3]; _p[_p$3] = _M0FP36zxch3n5flock5flock15value__to__json(_p$4); _tmp = _p$3 + 1 | 0; continue; } else { break; } } const key_json = _p; let now_value; if (_M0FP36zxch3n5flock5flock18any__is__undefined(now) || _M0FP36zxch3n5flock5flock13any__is__null(now)) { now_value = _M0DTPC16option6OptionGdE4None__; } else { const _bind$3 = _M0MP27Yoorkin4jmop3Any13unwrap__value(now, "moon/flock/ffi-js.mbt:347:12-347:30@zxch3n/flock"); let _tmp$2; if (_bind$3.$tag === 1) { const _ok = _bind$3; _tmp$2 = _ok._0; } else { const _err = _bind$3; _try_err = _err._0; break _L; } const _bind$4 = _M0MP27Yoorkin4jmop5Value10to__number(_tmp$2, "moon/flock/ffi-js.mbt:347:12-347:42@zxch3n/flock"); let _tmp$3; if (_bind$4.$tag === 1) { const _ok = _bind$4; _tmp$3 = _ok._0; } else { const _err = _bind$4; _try_err = _err._0; break _L; } now_value = new _M0DTPC16option6OptionGdE4Some(_tmp$3); } const _bind$3 = _M0MP36zxch3n5flock5flock5Flock14delete_2einner(self, key_json, now_value); if (_bind$3.$tag === 1) { const _ok = _bind$3; _ok._0; return; } else { const _err = _bind$3; _try_err = _err._0; break _L; } } $panic(); } function _M0MP36zxch3n5flock5flock5Flock29get__max__physical__time__ffi(self) { const _p = self.max_hlc.physical_time; return _p; } function _M0MP36zxch3n5flock5flock5Flock13peer__id__ffi(self) { const _p = _M0MP36zxch3n5flock5flock5Flock8peer__id(self); return _p; } function _M0MP36zxch3n5flock5flock5Flock17kv__to__json__ffi(self) { const _p = _M0FP36zxch3n5flock5flock15json__to__value(_M0MP36zxch3n5flock5flock5Flock12kv__to__json(self)); return _p; } function _M0MP36zxch3n5flock5flock11FlockDigest4copy(self) { return new _M0TP36zxch3n5flock5flock11FlockDigest(_M0MPC15array10FixedArray4copyGyE(self.bytes)); } function _M0MP36zxch3n5flock5flock11FlockDigest3xor(self, digest) { const bytes = _M0MPC15array10FixedArray4copyGyE(self.bytes); const digest_bytes = digest.bytes; let _tmp = 0; while (true) { const i = _tmp; if (i < 32) { $bound_check(bytes, i); const _p = bytes[i]; $bound_check(digest_bytes, i); const _p$2 = digest_bytes[i]; $bound_check(bytes, i); bytes[i] = (_p ^ _p$2) & 255; _tmp = i + 1 | 0; continue; } else { break; } } return new _M0TP36zxch3n5flock5flock11FlockDigest(bytes); } function _M0MP36zxch3n5flock5flock5Flock23recompute__full__digest(self) { let sum = _M0MP36zxch3n5flock5flock11FlockDigest4zero(); const _it = _M0MP36zxch3n5flock11sorted__map9SortedMap5iter2GRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(self.kv); while (true) { const _bind = _M0MPB5Iter24nextGRP36zxch3n5flock5types6NBytesRP36zxch3n5flock5flock5EntryE(_it); if (_bind === undefined) { break; } else { const _Some = _bind; const _x = _Some; const _entry = _x._1; const _bind$2 = _entry.value.data; if (_bind$2 === undefined) { continue; } sum = _M0MP36zxch3n5flock5flock11FlockDigest3xor(sum, _M0MP36zxch3n5flock5flock5Entry6digest(_entry)); continue; } } const digest = _M0MP36zxch3n5flock5flock11FlockDigest4copy(sum); self.digest = new _M0TP36zxch3n5flock5flock11DigestCache(sum, []); return digest; } function _M0MP36zxch3n5flock5flock5Flock6digest(self) { const _bind = self.digest; if (_bind === undefined) { } else { const _Some = _bind; const _cache = _Some; const _sum0 = _cache.sum; const _pending = _cache.pending; if (_pending.length === 0) { return _M0MP36zxch3n5flock5flock11FlockDigest4copy(_sum0); } const pending_len = _pending.length; const _p = self.kv; const kv_size = _p.size; if (pending_len >= kv_size) { return _M0MP36zxch3n5flock5flock5Flock23recompute__full__digest(self); } let sum_acc = _M0MP36zxch3n5flock5flock11FlockDigest4copy(_sum0); let _tmp = 0; while (true) { const i = _tmp; if (i < _pending.length) { sum_acc = _M0MP36zxch3n5flock5flock11FlockDigest3xor(sum_acc, _M0MPC15array5Array2atGRP36zxch3n5flock5flock5EntryE(_pending, i)); _tmp = i + 1 | 0; continue; } else { break; } } self.digest = new _M0TP36zxch3n5flock5flock11DigestCache(sum_acc, []); return _M0MP36zxch3n5flock5flock11FlockDigest4copy(sum_acc); } return _M0MP36zxch3n5flock5flock5Flock23recompute__full__digest(self); } function _M0MP36zxch3n5flock5flock11FlockDigest7to__hex(self) { const bytes = _M0MPC15bytes5Bytes10from__iter(_M0MPC15array10FixedArray4iterGyE(self.bytes)); return _M0FP36zxch3n5flock5flock14bytes__to__hex(bytes); } function _M0MP36zxch3n5flock5flock5Flock11digest__hex(self) { return _M0MP36zxch3n5flock5flock11FlockDigest7to__hex(_M0MP36zxch3n5flock5flock5Flock6digest(self)); } function _M0MP36zxch3n5flock5flock5Flock16digest__hex__ffi(self) { const _p = _M0MP36zxch3n5flock5flock5Flock11digest__hex(self); return _p; } function _M0MP36zxch3n5flock5flock5Flock13put__mvr__ffi(self, key, value, now) { let _try_err; _L: { const _bind = _M0MP27Yoorkin4jmop3Any13unwrap__value(key, "moon/flock/ffi-js.mbt:381:21-381:39@zxch3n/flock"); let key_value; if (_bind.$tag === 1) { const _ok = _bind; key_value = _ok._0; } else { const _err = _bind; _try_err = _err._0; break _L; } const _bind$2 = _M0MP27Yoorkin4jmop5Value9to__arrayGRP27Yoorkin4jmop5ValueE(key_value, "moon/flock/ffi-js.mbt:382:40-382:60@zxch3n/flock"); let key_arr; if (_bind$2.$tag === 1) { const _ok = _bind$2; key_arr = _ok._0; } else { const _err = _bind$2; _try_err = _err._0; break _L; } const _p = new Array(key_arr.length); const _p$2 = key_arr.length; let _tmp = 0; while (true) { const _p$3 = _tmp; if (_p$3 < _p$2) { const _p$4 = key_arr[_p$3]; _p[_p$3] = _M0FP36zxch3n5flock5flock15value__to__json(_p$4); _tmp = _p$3 + 1 | 0; continue; } else { break; } } const key_json = _p; let value_json; let _try_err$2; _L$2: { _L$3: { const _bind$3 = _M0FPC14json13parse_2einner(new _M0TPC16string10StringView(value, 0, value.length), 1024); if (_bind$3.$tag === 1) { const _ok = _bind$3; value_json = _ok._0; } else { const _err = _bind$3; _try_err$2 = _err._0; break _L$3; } break _L$2; } value_json = $panic(); } let now_value; if (_M0FP36zxch3n5flock5flock18any__is__undefined(now) || _M0FP36zxch3n5flock5flock13any__is__null(now)) { now_value = _M0DTPC16option6OptionGdE4None__; } else { const _bind$3 = _M0MP27Yoorkin4jmop3Any13unwrap__value(now, "moon/flock/ffi-js.mbt:388:12-388:30@zxch3n/flock"); let _tmp$2; if (_bind$3.$tag === 1) { const _ok = _bind$3; _tmp$2 = _ok._0; } else { const _err = _bind$3; _try_err = _err._0; break _L; } const _bind$4 = _M0MP27Yoorkin4jmop5Value10to__number(_tmp$2, "moon/flock/ffi-js.mbt:388:12-388:42@zxch3n/flock"); let _tmp$3; if (_bind$4.$tag === 1) { const _ok = _bind$4; _tmp$3 = _ok._0; } else { const _err = _bind$4; _try_err = _err._0; break _L; } now_value = new _M0DTPC16option6OptionGdE4Some(_tmp$3); } const _bind$3 = _M0MP36zxch3n5flock5flock5Flock16put__mvr_2einner(self, key_json, value_json, now_value); if (_bind$3.$tag === 1) { const _ok = _bind$3; _ok._0; return; } else { const _err = _bind$3; _try_err = _err._0; break _L; } } $panic(); } function _M0MP36zxch3n5flock5flock5Flock13get__mvr__ffi(self, key) { let _try_err; _L: { const _bind = _M0MP27Yoorkin4jmop3Any13unwrap__value(key, "moon/flock/ffi-js.mbt:397:21-397:39@zxch3n/flock"); let key_value; if (_bind.$tag === 1) { const _ok = _bind; key_value = _ok._0; } else { const _err = _bind; _try_err = _err._0; break _L; } const _bind$2 = _M0MP27Yoorkin4jmop5Value9to__arrayGRP27Yoorkin4jmop5ValueE(key_value, "moon/flock/ffi-js.mbt:398:40-398:60@zxch3n/flock"); let key_arr; if (_bind$2.$tag === 1) { const _ok = _bind$2; key_arr = _ok._0; } else { const _err = _bind$2; _try_err = _err._0; break _L; } const _p = new Array(key_arr.length); const _p$2 = key_arr.length; let _tmp = 0; while (true) { const _p$3 = _tmp; if (_p$3 < _p$2) { const _p$4 = key_arr[_p$3]; _p[_p$3] = _M0FP36zxch3n5flock5flock15value__to__json(_p$4); _tmp = _p$3 + 1 | 0; continue; } else { break; } } const key_json = _p; const ans = _M0MP36zxch3n5flock5flock5Flock8get__mvr(self, key_json); const _p$3 = _M0FP36zxch3n5flock5flock15json__to__value(_M0IPC15array5ArrayPB6ToJson8to__jsonGRPB4JsonE(ans)); return _p$3; } return $panic(); } function _M0FP36zxch3n5flock5flock15from__json__ffi(json, peer_id) { let _try_err; _L: { const _bind = _M0MP27Yoorkin4jmop3Any13unwrap__value(json, "moon/flock/ffi-js.mbt:408:22-408:41@zxch3n/flock"); let json_value; if (_bind.$tag === 1) { const _ok = _bind; json_value = _ok._0; } else { const _err = _bind; _try_err = _err._0; break _L; } const parsed = _M0FP36zxch3n5flock5flock15value__to__json(json_value); const _bind$2 = _M0MP27Yoorkin4jmop3Any13unwrap__value(peer_id, "moon/flock/ffi-js.mbt:410:22-410:44@zxch3n/flock"); let peer_value; if (_bind$2.$tag === 1) { const _ok = _bind$2; peer_value = _ok._0; } else { const _err = _bind$2; _try_err = _err._0; break _L; } const _bind$3 = _M0MP27Yoorkin4jmop5Value10to__string(peer_value, "moon/flock/ffi-js.mbt:411:16-411:38@zxch3n/flock"); let peer; if (_bind$3.$tag === 1) { const _ok = _bind$3; peer = _ok._0; } else { const _err = _bind$3; _try_err = _err._0; break _L; } const _bind$4 = _M0MP36zxch3n5flock5flock5Flock10from__json(parsed, _M0FP36zxch3n5flock5flock20string__to__peer__id(peer)); if (_bind$4.$tag === 1) { const _ok = _bind$4; return _ok._0; } else { const _err = _bind$4; _try_err = _err._0; break _L; } } return $panic(); } function _M0MP36zxch3n5flock5flock5Flock9scan__ffi(self, start, end, prefix) { let _try_err; _L: { let start_bound; if (_M0FP36zxch3n5flock5flock18any__is__undefined(start) || _M0FP36zxch3n5flock5flock13any__is__null(start)) { start_bound = _M0DTP36zxch3n5flock11sorted__map5BoundGRPB5ArrayGRPB4JsonEE9Unbounded__; } else { const _bind = _M0MP27Yoorkin4jmop3Any13unwrap__value(start, "moon/flock/ffi-js.mbt:427:25-427:45@zxch3n/flock"); let start_value; if (_bind.$tag === 1) { const _ok = _bind; start_value = _ok._0; } else { const _err = _bind; _try_err = _err._0; break _L; } start_bound = _M0FP36zxch3n5flock5flock17bound__from__json(_M0FP36zxch3n5flock5flock15value__to__json(start_value)); } let end_bound; if (_M0FP36zxch3n5flock5flock18any__is__undefined(end) || _M0FP36zxch3n5flock5flock13any__is__null(end)) { end_bound = _M0DTP36zxch3n5flock11sorted__map5BoundGRPB5ArrayGRPB4JsonEE9Unbounded__; } else { const _bind = _M0MP27Yoorkin4jmop3Any13unwrap__value(end, "moon/flock/ffi-js.mbt:433:23-433:41@zxch3n/flock"); let end_value; if (_bind.$tag === 1) { const _ok = _bind; end_value = _ok._0; } else { const _err = _bind; _try_err = _err._0; break _L; } end_bound = _M0FP36zxch3n5flock5flock17bound__from__json(_M0FP36zxch3n5flock5flock15value__to__json(end_value)); } let prefix_filter; if (_M0FP36zxch3n5flock5flock18any__is__undefined(prefix) || _M0FP36zxch3n5flock5flock13any__is__null(prefix)) { prefix_filter = _M0DTPC16option6OptionGRPB5ArrayGRPB4JsonEE4None__; } else { const _bind = _M0MP27Yoorkin4jmop3Any13unwrap__value(prefix, "moon/flock/ffi-js.mbt:439:26-439:47@zxch3n/flock"); let prefix_value; if (_bind.$tag === 1) { const _ok = _bind; prefix_value = _ok._0; } else { const _err = _bind; _try_err = _err._0; break _L; } const _bind$2 = _M0MP27Yoorkin4jmop5Value9to__arrayGRP27Yoorkin4jmop5ValueE(prefix_value, "moon/flock/ffi-js.mbt:440:45-440:68@zxch3n/flock"); let prefix_arr; if (_bind$2.$tag === 1) { const _ok = _bind$2; prefix_arr = _ok._0; } else { const _err = _bind$2; _try_err = _err._0; break _L; } const _p = new Array(prefix_arr.length); const _p$2 = prefix_arr.length; let _tmp = 0; while (true) { const _p$3 = _tmp; if (_p$3 < _p$2) { const _p$4 = prefix_arr[_p$3]; _p[_p$3] = _M0FP36zxch3n5flock5flock15value__to__json(_p$4); _tmp = _p$3 + 1 | 0; continue; } else { break; } } prefix_filter = new _M0DTPC16option6OptionGRPB5ArrayGRPB4JsonEE4Some(_p); } const rows = _M0MPC15array5Array11new_2einnerGRPB4JsonE(0); let scan_iter; if (prefix_filter.$tag === 1) { const _Some = prefix_filter; const _prefix_value = _Some._0; scan_iter = _M0MP36zxch3n5flock5flock5Flock12scan_2einner(self, start_bound, end_bound, new _M0DTPC16option6OptionGRPB5ArrayGRPB4JsonEE4Some(_prefix_value)); } else { scan_iter = _M0MP36zxch3n5flock5flock5Flock12scan_2einner(self, start_bound, end_bound, _M0DTPC16option6OptionGRPB5ArrayGRPB4JsonEE4None__); } _M0MPB5Iter23runGRPB5ArrayGRPB4JsonERP36zxch3n5flock5flock5EntryE(scan_iter, (key, entry) => { const obj = _M0MPB3Map3newGsRP36zxch3n5flock5flock3HlcE(undefined); _M0MPB3Map3setGsRPB4JsonE(obj, "key", _M0IPC15array5ArrayPB6ToJson8to__jsonGRPB4JsonE(key)); _M0MPB3Map3setGsRPB4JsonE(obj, "raw", _M0MP36zxch3n5flock5flock8RawValue8to__json(entry.value)); const _bind = entry.value.data; if (_bind === undefined) { } else { const _Some = _bind; const _data = _Some; _M0MPB3Map3setGsRPB4JsonE(obj, "value", _data); } _M0MPC15array5Array4pushGRPB4JsonE(rows, _M0IPB3MapPB6ToJson8to__jsonGsRPB4JsonE(obj)); return 1; }); const _p = _M0FP36zxch3n5flock5flock15json__to__value(_M0IPC15array5ArrayPB6ToJson8to__jsonGRPB4JsonE(rows)); return _p; } return $panic(); } function _M0FP36zxch3n5flock5flock29raw__value__payload__to__json(value) { const obj = _M0MPB3Map3newGsRP36zxch3n5flock5flock3HlcE(undefined); const _bind = value.data; if (_bind === undefined) { } else { const _Some = _bind; const _data = _Some; _M0MPB3Map3setGsRPB4JsonE(obj, "data", _data); } const _bind$2 = value.metadata; if (_bind$2 === undefined) { } else { const _Some = _bind$2; const _meta = _Some; _M0MPB3Map3setGsRPB4JsonE(obj, "metadata", _M0FP36zxch3n5flock5flock23metadata__map__to__json(_meta)); } return _M0IPB3MapPB6ToJson8to__jsonGsRPB4JsonE(obj); } function _M0MP36zxch3n5flock5flock5Flock14subscribe__ffi(self, listener) { let _try_err; _L: { const _bind = _M0MP27Yoorkin4jmop3Any13unwrap__value(listener, "moon/flock/ffi-js.mbt:498:26-498:49@zxch3n/flock"); let listener_value; if (_bind.$tag === 1) { const _ok = _bind; listener_value = _ok._0; } else { const _err = _bind; _try_err = _err._0; break _L; } const unsubscribe = _M0MP36zxch3n5flock5flock5Flock9subscribe(self, (batch) => { const events = _M0MPC15array5Array11new_2einnerGRPB4JsonE(0); let _tmp = 0; while (true) { const i = _tmp; if (i < batch.events.length) { const _bind$2 = _M0MPC15array5Array2atGRP36zxch3n5flock5flock5EntryE(batch.events, i); const _key = _bind$2._0; const _value = _bind$2._1; const obj = _M0MPB3Map3newGsRP36zxch3n5flock5flock3HlcE(undefined); _M0MPB3Map3setGsRPB4JsonE(obj, "key", _M0IPC15array5ArrayPB6ToJson8to__jsonGRPB4JsonE(_key)); const _bind$3 = _value.data; if (_bind$3 === undefined) { } else { const _Some = _bind$3; const _data = _Some; _M0MPB3Map3setGsRPB4JsonE(obj, "value", _data); } const _bind$4 = _value.metadata; if (_bind$4 === undefined) { } else { const _Some = _bind$4; const _meta = _Some; _M0MPB3Map3setGsRPB4JsonE(obj, "metadata", _M0FP36zxch3n5flock5flock23metadata__map__to__json(_meta)); } _M0MPB3Map3setGsRPB4JsonE(obj, "payload", _M0FP36zxch3n5flock5flock29raw__value__payload__to__json(_value)); _M0MPC15array5Array4pushGRPB4JsonE(events, _M0IPB3MapPB6ToJson8to__jsonGsRPB4JsonE(obj)); _tmp = i + 1 | 0; continue; } else { break; } } const event_obj = _M0MPB3Map3newGsRP36zxch3n5flock5flock3HlcE(undefined); _M0MPB3Map3setGsRPB4JsonE(event_obj, "events", _M0IPC15array5ArrayPB6ToJson8to__jsonGRPB4JsonE(events)); const _bind$2 = batch.by; let _tmp$2; if (_bind$2.$tag === 0) { const _p = "local"; _tmp$2 = new _M0DTPB4Json6String(_p); } else { const _Import = _bind$2; const _name = _Import._0; _tmp$2 = new _M0DTPB4Json6String(_name); } _M0MPB3Map3setGsRPB4JsonE(event_obj, "source", _tmp$2); _M0FP36zxch3n5flock5flock21ffi__invoke__listener(listener_value, _M0FP36zxch3n5flock5flock15json__to__value(_M0IPB3MapPB6ToJson8to__jsonGsRPB4JsonE(event_obj))); }); const _p = _M0FP36zxch3n5flock5flock22ffi__make__unsubscribe(unsubscribe); return _p; } return $panic(); } function _M0MP36zxch3n5flock5flock5Flock15txn__begin__ffi(self) { _M0MP36zxch3n5flock5flock5Flock10txn__begin(self); } function _M0MP36zxch3n5flock5flock5Flock16txn__commit__ffi(self) { _M0MP36zxch3n5flock5flock5Flock11txn__commit(self); } function _M0MP36zxch3n5flock5flock5Flock18txn__rollback__ffi(self) { _M0MP36zxch3n5flock5flock5Flock13txn__rollback(self); } function _M0MP36zxch3n5flock5flock5Flock16is__in__txn__ffi(self) { return _M0MP36zxch3n5flock5flock5Flock11is__in__txn(self); } export { _M0MP36zxch3n5flock5flock5Flock13set__peer__id as set_peer_id, _M0MP36zxch3n5flock5flock5Flock7version as version, _M0MP36zxch3n5flock5flock5Flock16inclusiveVersion as inclusiveVersion, _M0MP36zxch3n5flock5flock5Flock12export__json as export_json, _M0MP36zxch3n5flock5flock5Flock12import__json as import_json, _M0MP36zxch3n5flock5flock5Flock5merge as merge, _M0MP36zxch3n5flock5flock5Flock10from__json as from_json, _M0MP36zxch3n5flock5flock5Flock8newFlock as newFlock, _M0MP36zxch3n5flock5flock5Flock8put__ffi as put_ffi, _M0MP36zxch3n5flock5flock5Flock8get__ffi as get_ffi, _M0MP36zxch3n5flock5flock5Flock15get__entry__ffi as get_entry_ffi, _M0MP36zxch3n5flock5flock5Flock17export__json__ffi as export_json_ffi, _M0MP36zxch3n5flock5flock5Flock17import__json__ffi as import_json_ffi, _M0MP36zxch3n5flock5flock5Flock22import__json__str__ffi as import_json_str_ffi, _M0MP36zxch3n5flock5flock5Flock12version__ffi as version_ffi, _M0MP36zxch3n5flock5flock5Flock21inclusiveVersion__ffi as inclusiveVersion_ffi, _M0FP36zxch3n5flock5flock23check__consistency__ffi as check_consistency_ffi, _M0MP36zxch3n5flock5flock5Flock22check__invariants__ffi as check_invariants_ffi, _M0MP36zxch3n5flock5flock5Flock14put__json__ffi as put_json_ffi, _M0MP36zxch3n5flock5flock5Flock20put__with__meta__ffi as put_with_meta_ffi, _M0MP36zxch3n5flock5flock5Flock11delete__ffi as delete_ffi, _M0MP36zxch3n5flock5flock5Flock29get__max__physical__time__ffi as get_max_physical_time_ffi, _M0MP36zxch3n5flock5flock5Flock13peer__id__ffi as peer_id_ffi, _M0MP36zxch3n5flock5flock5Flock17kv__to__json__ffi as kv_to_json_ffi, _M0MP36zxch3n5flock5flock5Flock16digest__hex__ffi as digest_hex_ffi, _M0MP36zxch3n5flock5flock5Flock13put__mvr__ffi as put_mvr_ffi, _M0MP36zxch3n5flock5flock5Flock13get__mvr__ffi as get_mvr_ffi, _M0FP36zxch3n5flock5flock15from__json__ffi as from_json_ffi, _M0MP36zxch3n5flock5flock5Flock9scan__ffi as scan_ffi, _M0MP36zxch3n5flock5flock5Flock14subscribe__ffi as subscribe_ffi, _M0MP36zxch3n5flock5flock5Flock15txn__begin__ffi as txn_begin_ffi, _M0MP36zxch3n5flock5flock5Flock16txn__commit__ffi as txn_commit_ffi, _M0MP36zxch3n5flock5flock5Flock18txn__rollback__ffi as txn_rollback_ffi, _M0MP36zxch3n5flock5flock5Flock16is__in__txn__ffi as is_in_txn_ffi }