UNPKG

@tonk/keepsync

Version:

A reactive sync engine framework for use with Tonk apps

1,798 lines 3.66 MB
var __defProp = Object.defineProperty; var __typeError = (msg) => { throw TypeError(msg); }; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg); var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)); var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value); var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value); var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method); var __privateWrapper = (obj, member, setter, getter) => ({ set _(value) { __privateSet(obj, member, value, setter); }, get _() { return __privateGet(obj, member, getter); } }); var _I2, _A2, _Q2, _g2, _C2, _E2, _i2, _jg_instances, D_get, B_get, G_fn, w_fn, o_fn, _I3, _A3, _Q3, _g3, _C3, _E3, _rG_instances, i_fn, D_fn, _I4, _A4, _Q4, _g4, _C4, _I5, _A5, _Q5, _g5, _C5, _Qw_instances, E_fn, i_fn2, D_fn2, B_fn, _I6, _A6, _Q6, _g6, _C6, _E4, _i3, _D2, _B2, _G2, _Cw_instances, w_fn2, o_fn2, h_fn, k_fn, J_fn, c_fn, F_fn, a_fn, Y_fn, N_fn, M_fn, _I7, _A7, _Q7, _Bw_instances, g_fn, C_fn, E_fn2, _I8, _A8, _Q8, _g7, _C7, _E5, _i4, _Dw_instances, D_fn3, B_fn2, _G3, w_fn3, o_fn3, h_fn2, k_fn2, _I9, _A9, _Q9, _g8, _C8; import lI from "chalk"; const Vg = Symbol.for("_am_meta"), TI = Symbol.for("_am_trace"), rI = Symbol.for("_am_objectId"), PQ = Symbol.for("_am_isProxy"), cB = Symbol.for("_am_clearCache"), mD = Symbol.for("_am_uint"), nD = Symbol.for("_am_int"), WD = Symbol.for("_am_f64"), RB = Symbol.for("_am_counter"), sB = Symbol.for("_am_immutableString"); class cQ { constructor(A) { this.value = A || 0, Reflect.defineProperty(this, RB, { value: true }); } /** * A peculiar JavaScript language feature from its early days: if the object * `x` has a `valueOf()` method that returns a number, you can use numerical * operators on the object `x` directly, such as `x + 1` or `x < 4`. * This method is also called when coercing a value to a string by * concatenating it with another string, as in `x + ''`. * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf */ valueOf() { return this.value; } /** * Returns the counter value as a decimal string. If `x` is a counter object, * this method is called e.g. when you do `['value: ', x].join('')` or when * you use string interpolation: `value: ${x}`. */ toString() { return this.valueOf().toString(); } /** * Returns the counter value, so that a JSON serialization of an Automerge * document represents the counter simply as an integer. */ toJSON() { return this.value; } /** * Increases the value of the counter by `delta`. If `delta` is not given, * increases the value of the counter by 1. * * Will throw an error if used outside of a change callback. */ increment(A) { throw new Error("Counters should not be incremented outside of a change callback"); } /** * Decreases the value of the counter by `delta`. If `delta` is not given, * decreases the value of the counter by 1. * * Will throw an error if used outside of a change callback. */ decrement(A) { throw new Error("Counters should not be decremented outside of a change callback"); } } class bD extends cQ { constructor(A, g, Q, C, B) { super(A), this.context = g, this.path = Q, this.objectId = C, this.key = B; } /** * Increases the value of the counter by `delta`. If `delta` is not given, * increases the value of the counter by 1. */ increment(A) { return A = typeof A == "number" ? A : 1, this.context.increment(this.objectId, this.key, A), this.value += A, this.value; } /** * Decreases the value of the counter by `delta`. If `delta` is not given, * decreases the value of the counter by 1. */ decrement(A) { return this.increment(typeof A == "number" ? -A : -1); } } function VD(I, A, g, Q, C) { return new bD(I, A, g, Q, C); } var yB; class UB { constructor(A) { this[yB] = true, this.val = A; } /** * Returns the content of the ImmutableString object as a simple string */ toString() { return this.val; } toJSON() { return this.val; } } yB = sB; function uA(I) { if (typeof I == "string" && /^[0-9]+$/.test(I) && (I = parseInt(I, 10)), typeof I != "number") return I; if (I < 0 || isNaN(I) || I === 1 / 0 || I === -1 / 0) throw new RangeError("A list index must be positive, but you passed " + I); return I; } function SA(I, A) { const { context: g, objectId: Q, path: C } = I, B = g.getWithType(Q, A); if (B === null) return; const E = B[0], D = B[1]; switch (E) { case void 0: return; case "map": return Qg(g, D, [...C, A]); case "list": return xg(g, D, [...C, A]); case "text": return g.text(D); case "str": return new UB(D); case "uint": return D; case "int": return D; case "f64": return D; case "boolean": return D; case "null": return null; case "bytes": return D; case "timestamp": return D; case "counter": return VD(D, g, C, Q, A); default: throw RangeError(`datatype ${E} unimplemented`); } } function Lg(I, A, g) { const Q = typeof I; switch (Q) { case "object": if (I == null) return [null, "null"]; if (I[mD]) return [I.value, "uint"]; if (I[nD]) return [I.value, "int"]; if (I[WD]) return [I.value, "f64"]; if (I[RB]) return [I.value, "counter"]; if (I instanceof Date) return [I.getTime(), "timestamp"]; if (KB(I)) return [I.toString(), "str"]; if (I instanceof Uint8Array) return [I, "bytes"]; if (I instanceof Array) return [I, "list"]; if (Object.prototype.toString.call(I) === "[object Object]") return [I, "map"]; throw Xg(I, g) ? new RangeError("Cannot create a reference to an existing document object") : new RangeError(`Cannot assign unknown object: ${I}`); case "boolean": return [I, "boolean"]; case "number": return Number.isInteger(I) ? [I, "int"] : [I, "f64"]; case "string": return [I, "text"]; case "undefined": throw new RangeError([ `Cannot assign undefined value at ${KC(A)}, `, "because `undefined` is not a valid JSON data type. ", "You might consider setting the property's value to `null`, ", "or using `delete` to remove it altogether." ].join("")); default: throw new RangeError([ `Cannot assign ${Q} value at ${KC(A)}. `, "All JSON primitive datatypes (object, array, string, number, boolean, null) ", `are supported in an Automerge document; ${Q} values are not. ` ].join("")); } } function Xg(I, A) { var g, Q; return I instanceof Date ? false : !!(I && ((Q = (g = I[Vg]) === null || g === void 0 ? void 0 : g.handle) === null || Q === void 0 ? void 0 : Q.__wbg_ptr) === A.__wbg_ptr); } const XD = { get(I, A) { const { context: g, objectId: Q, cache: C } = I; return A === Symbol.toStringTag ? I[Symbol.toStringTag] : A === rI ? Q : A === PQ ? true : A === TI ? I.trace : A === Vg ? { handle: g } : (C[A] || (C[A] = SA(I, A)), C[A]); }, set(I, A, g) { const { context: Q, objectId: C, path: B } = I; if (I.cache = {}, Xg(g, Q)) throw new RangeError("Cannot create a reference to an existing document object"); if (A === TI) return I.trace = g, true; if (A === cB) return true; const [E, D] = Lg(g, [...B, A], Q); switch (D) { case "list": { const i = Q.putObject(C, A, []), G = xg(Q, i, [...B, A]); for (let w = 0; w < E.length; w++) G[w] = E[w]; break; } case "text": { Q.putObject(C, A, E); break; } case "map": { const i = Q.putObject(C, A, {}), G = Qg(Q, i, [...B, A]); for (const w in E) G[w] = E[w]; break; } default: Q.put(C, A, E, D); } return true; }, deleteProperty(I, A) { const { context: g, objectId: Q } = I; return I.cache = {}, g.delete(Q, A), true; }, has(I, A) { return this.get(I, A) !== void 0; }, getOwnPropertyDescriptor(I, A) { const g = this.get(I, A); if (typeof g < "u") return { configurable: true, enumerable: true, value: g }; }, ownKeys(I) { const { context: A, objectId: g } = I, Q = A.keys(g); return [...new Set(Q)]; } }, xD = { get(I, A) { const { context: g, objectId: Q } = I; return A = uA(A), A === Symbol.hasInstance ? (C) => Array.isArray(C) : A === Symbol.toStringTag ? I[Symbol.toStringTag] : A === rI ? Q : A === PQ ? true : A === TI ? I.trace : A === Vg ? { handle: g } : A === "length" ? g.length(Q) : typeof A == "number" ? SA(I, A) : rD(I)[A]; }, set(I, A, g) { const { context: Q, objectId: C, path: B } = I; if (A = uA(A), Xg(g, Q)) throw new RangeError("Cannot create a reference to an existing document object"); if (A === cB) return true; if (A === TI) return I.trace = g, true; if (typeof A == "string") throw new RangeError("list index must be a number"); const [E, D] = Lg(g, [...B, A], Q); switch (D) { case "list": { let i; A >= Q.length(C) ? i = Q.insertObject(C, A, []) : i = Q.putObject(C, A, []), xg(Q, i, [...B, A]).splice(0, 0, ...E); break; } case "text": { A >= Q.length(C) ? Q.insertObject(C, A, E) : Q.putObject(C, A, E); break; } case "map": { let i; A >= Q.length(C) ? i = Q.insertObject(C, A, {}) : i = Q.putObject(C, A, {}); const G = Qg(Q, i, [...B, A]); for (const w in E) G[w] = E[w]; break; } default: A >= Q.length(C) ? Q.insert(C, A, E, D) : Q.put(C, A, E, D); } return true; }, deleteProperty(I, A) { const { context: g, objectId: Q } = I; A = uA(A); const C = g.get(Q, A); if (C != null && C[0] == "counter") throw new TypeError("Unsupported operation: deleting a counter from a list"); return g.delete(Q, A), true; }, has(I, A) { const { context: g, objectId: Q } = I; return A = uA(A), typeof A == "number" ? A < g.length(Q) : A === "length"; }, getOwnPropertyDescriptor(I, A) { const { context: g, objectId: Q } = I; return A === "length" ? { writable: true, value: g.length(Q) } : A === rI ? { configurable: false, enumerable: false, value: Q } : (A = uA(A), { configurable: true, enumerable: true, value: SA(I, A) }); }, getPrototypeOf(I) { return Object.getPrototypeOf(I); }, ownKeys() { const I = []; return I.push("length"), I; } }; function Qg(I, A, g) { const Q = { context: I, objectId: A, path: g || [], cache: {} }, C = {}; return Object.assign(C, Q), new Proxy(C, XD); } function xg(I, A, g) { const Q = { context: I, objectId: A, path: g || [], cache: {} }, C = []; return Object.assign(C, Q), new Proxy(C, xD); } function TD(I) { return Qg(I, "_root", []); } function rD(I) { const { context: A, objectId: g, path: Q } = I; return { at(B) { return SA(I, B); }, deleteAt(B, E) { return typeof E == "number" ? A.splice(g, B, E) : A.delete(g, B), this; }, fill(B, E, D) { const [i, G] = Lg(B, [...Q, E], A), w = A.length(g); E = uA(E || 0), D = uA(D || w); for (let o = E; o < Math.min(D, w); o++) G === "list" || G === "map" || G === "text" ? A.putObject(g, o, i) : A.put(g, o, i, G); return this; }, indexOf(B, E = 0) { const D = A.length(g); for (let i = E; i < D; i++) { const G = A.getWithType(g, i); if (!G) continue; const [w, o] = G; if (!["map", "list", "text"].includes(w)) { if (o === B) return i; continue; } if (w === "text" && typeof B == "string" && B === SA(I, i) || B[rI] === o) return i; } return -1; }, insertAt(B, ...E) { return this.splice(B, 0, ...E), this; }, pop() { const B = A.length(g); if (B == 0) return; const E = SA(I, B - 1); return A.delete(g, B - 1), E; }, push(...B) { const E = A.length(g); return this.splice(E, 0, ...B), A.length(g); }, shift() { if (A.length(g) == 0) return; const B = SA(I, 0); return A.delete(g, 0), B; }, splice(B, E, ...D) { B = uA(B), typeof E != "number" && (E = A.length(g) - B), E = uA(E); for (const w of D) if (Xg(w, A)) throw new RangeError("Cannot create a reference to an existing document object"); const i = []; for (let w = 0; w < E; w++) { const o = SA(I, B); o !== void 0 && i.push(o), A.delete(g, B); } const G = D.map((w, o) => { try { return Lg(w, [...Q], A); } catch (N) { throw N instanceof RangeError ? new RangeError(`${N.message} (at index ${o} in the input)`) : N; } }); for (const [w, o] of G) { switch (o) { case "list": { const N = A.insertObject(g, B, []); xg(A, N, [...Q, B]).splice(0, 0, ...w); break; } case "text": { A.insertObject(g, B, w); break; } case "map": { const N = A.insertObject(g, B, {}), k = Qg(A, N, [...Q, B]); for (const h in w) k[h] = w[h]; break; } default: A.insert(g, B, w, o); } B += 1; } return i; }, unshift(...B) { return this.splice(0, 0, ...B), A.length(g); }, entries() { let B = 0; return { next: () => { const D = SA(I, B); return D === void 0 ? { value: void 0, done: true } : { value: [B++, D], done: false }; }, [Symbol.iterator]() { return this; } }; }, keys() { let B = 0; const E = A.length(g); return { next: () => B < E ? { value: B++, done: false } : { value: void 0, done: true }, [Symbol.iterator]() { return this; } }; }, values() { let B = 0; return { next: () => { const D = SA(I, B++); return D === void 0 ? { value: void 0, done: true } : { value: D, done: false }; }, [Symbol.iterator]() { return this; } }; }, toArray() { const B = []; let E; do E = SA(I, B.length), E !== void 0 && B.push(E); while (E !== void 0); return B; }, map(B) { return this.toArray().map(B); }, toString() { return this.toArray().toString(); }, toLocaleString() { return this.toArray().toLocaleString(); }, forEach(B) { return this.toArray().forEach(B); }, // todo: real concat function is different concat(B) { return this.toArray().concat(B); }, every(B) { return this.toArray().every(B); }, filter(B) { return this.toArray().filter(B); }, find(B) { let E = 0; for (const D of this) { if (B(D, E)) return D; E += 1; } }, findIndex(B) { let E = 0; for (const D of this) { if (B(D, E)) return E; E += 1; } return -1; }, includes(B) { return this.find((E) => E === B) !== void 0; }, join(B) { return this.toArray().join(B); }, reduce(B, E) { return this.toArray().reduce(B, E); }, reduceRight(B, E) { return this.toArray().reduceRight(B, E); }, lastIndexOf(B, E = 1 / 0) { return this.toArray().lastIndexOf(B, E); }, slice(B, E) { return this.toArray().slice(B, E); }, some(B) { let E = 0; for (const D of this) { if (B(D, E)) return true; E += 1; } return false; }, [Symbol.iterator]: function* () { let B = 0, E = SA(I, B); for (; E !== void 0; ) yield E, B += 1, E = SA(I, B); } }; } function KC(I) { const A = I.map((g) => { if (typeof g == "number") return g.toString(); if (typeof g == "string") return g.replace(/~/g, "~0").replace(/\//g, "~1"); }); return I.length === 0 ? "" : "/" + A.join("/"); } function KB(I) { return typeof I == "object" && I !== null && Object.prototype.hasOwnProperty.call(I, sB); } let y, ZA = 0, WI = null; function XI() { return (WI === null || WI.byteLength === 0) && (WI = new Uint8Array(y.memory.buffer)), WI; } const cg = typeof TextEncoder < "u" ? new TextEncoder("utf-8") : { encode: () => { throw Error("TextEncoder not available"); } }, fD = typeof cg.encodeInto == "function" ? function(I, A) { return cg.encodeInto(I, A); } : function(I, A) { const g = cg.encode(I); return A.set(g), { read: I.length, written: g.length }; }; function XA(I, A, g) { if (g === void 0) { const D = cg.encode(I), i = A(D.length, 1) >>> 0; return XI().subarray(i, i + D.length).set(D), ZA = D.length, i; } let Q = I.length, C = A(Q, 1) >>> 0; const B = XI(); let E = 0; for (; E < Q; E++) { const D = I.charCodeAt(E); if (D > 127) break; B[C + E] = D; } if (E !== Q) { E !== 0 && (I = I.slice(E)), C = g(C, Q, Q = E + I.length * 3, 1) >>> 0; const D = XI().subarray(C + E, C + Q), i = fD(I, D); E += i.written, C = g(C, Q, E, 1) >>> 0; } return ZA = E, C; } let BI = null; function LA() { return (BI === null || BI.buffer.detached === true || BI.buffer.detached === void 0 && BI.buffer !== y.memory.buffer) && (BI = new DataView(y.memory.buffer)), BI; } function kA(I) { const A = y.__externref_table_alloc(); return y.__wbindgen_export_4.set(A, I), A; } function rA(I, A) { try { return I.apply(this, A); } catch (g) { const Q = kA(g); y.__wbindgen_exn_store(Q); } } const SB = typeof TextDecoder < "u" ? new TextDecoder("utf-8", { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error("TextDecoder not available"); } }; typeof TextDecoder < "u" && SB.decode(); function HA(I, A) { return I = I >>> 0, SB.decode(XI().subarray(I, I + A)); } function zD(I, A) { return I = I >>> 0, XI().subarray(I / 1, I / 1 + A); } function RQ(I) { const A = typeof I; if (A == "number" || A == "boolean" || I == null) return `${I}`; if (A == "string") return `"${I}"`; if (A == "symbol") { const C = I.description; return C == null ? "Symbol" : `Symbol(${C})`; } if (A == "function") { const C = I.name; return typeof C == "string" && C.length > 0 ? `Function(${C})` : "Function"; } if (Array.isArray(I)) { const C = I.length; let B = "["; C > 0 && (B += RQ(I[0])); for (let E = 1; E < C; E++) B += ", " + RQ(I[E]); return B += "]", B; } const g = /\[object ([^\]]+)\]/.exec(toString.call(I)); let Q; if (g && g.length > 1) Q = g[1]; else return toString.call(I); if (Q == "Object") try { return "Object(" + JSON.stringify(I) + ")"; } catch { return "Object"; } return I instanceof Error ? `${I.name}: ${I.message} ${I.stack}` : Q; } function v(I) { return I == null; } function p(I) { const A = y.__wbindgen_export_4.get(I); return y.__externref_table_dealloc(I), A; } function DI(I, A) { if (!(I instanceof A)) throw new Error(`expected instance of ${A.name}`); } function uD(I) { const A = y.create(I); if (A[2]) throw p(A[1]); return VA.__wrap(A[0]); } function PD(I, A) { const g = y.load(I, A); if (g[2]) throw p(g[1]); return VA.__wrap(g[0]); } function vD(I) { const A = y.encodeChange(I); if (A[2]) throw p(A[1]); return p(A[0]); } function _D(I) { const A = y.decodeChange(I); if (A[2]) throw p(A[1]); return p(A[0]); } function $D() { const I = y.initSyncState(); return OA.__wrap(I); } function Ai(I) { const A = y.importSyncState(I); if (A[2]) throw p(A[1]); return OA.__wrap(A[0]); } function Ii(I) { return DI(I, OA), y.exportSyncState(I.__wbg_ptr); } function gi(I) { const A = y.encodeSyncMessage(I); if (A[2]) throw p(A[1]); return p(A[0]); } function Qi(I) { const A = y.decodeSyncMessage(I); if (A[2]) throw p(A[1]); return p(A[0]); } function Ci(I) { return DI(I, OA), y.encodeSyncState(I.__wbg_ptr); } function Bi(I) { const A = y.decodeSyncState(I); if (A[2]) throw p(A[1]); return OA.__wrap(A[0]); } const SC = typeof FinalizationRegistry > "u" ? { register: () => { }, unregister: () => { } } : new FinalizationRegistry((I) => y.__wbg_automerge_free(I >>> 0, 1)); class VA { static __wrap(A) { A = A >>> 0; const g = Object.create(VA.prototype); return g.__wbg_ptr = A, SC.register(g, g.__wbg_ptr, g), g; } __destroy_into_raw() { const A = this.__wbg_ptr; return this.__wbg_ptr = 0, SC.unregister(this), A; } free() { const A = this.__destroy_into_raw(); y.__wbg_automerge_free(A, 0); } /** * @param {string | null} [actor] * @returns {Automerge} */ static new(A) { var g = v(A) ? 0 : XA(A, y.__wbindgen_malloc, y.__wbindgen_realloc), Q = ZA; const C = y.automerge_new(g, Q); if (C[2]) throw p(C[1]); return VA.__wrap(C[0]); } /** * @param {string | null} [actor] * @returns {Automerge} */ clone(A) { var g = v(A) ? 0 : XA(A, y.__wbindgen_malloc, y.__wbindgen_realloc), Q = ZA; const C = y.automerge_clone(this.__wbg_ptr, g, Q); if (C[2]) throw p(C[1]); return VA.__wrap(C[0]); } /** * @param {string | null | undefined} actor * @param {any} heads * @returns {Automerge} */ fork(A, g) { var Q = v(A) ? 0 : XA(A, y.__wbindgen_malloc, y.__wbindgen_realloc), C = ZA; const B = y.automerge_fork(this.__wbg_ptr, Q, C, g); if (B[2]) throw p(B[1]); return VA.__wrap(B[0]); } /** * @returns {number} */ pendingOps() { return y.automerge_pendingOps(this.__wbg_ptr); } /** * @param {string | null} [message] * @param {number | null} [time] * @returns {Hash | null} */ commit(A, g) { var Q = v(A) ? 0 : XA(A, y.__wbindgen_malloc, y.__wbindgen_realloc), C = ZA; return y.automerge_commit(this.__wbg_ptr, Q, C, !v(g), v(g) ? 0 : g); } /** * @param {Automerge} other * @returns {Heads} */ merge(A) { DI(A, VA); const g = y.automerge_merge(this.__wbg_ptr, A.__wbg_ptr); if (g[2]) throw p(g[1]); return p(g[0]); } /** * @returns {number} */ rollback() { return y.automerge_rollback(this.__wbg_ptr); } /** * @param {any} obj * @param {Array<any> | null} [heads] * @returns {Array<any>} */ keys(A, g) { const Q = y.automerge_keys(this.__wbg_ptr, A, v(g) ? 0 : kA(g)); if (Q[2]) throw p(Q[1]); return p(Q[0]); } /** * @param {any} obj * @param {Array<any> | null} [heads] * @returns {string} */ text(A, g) { let Q, C; try { const D = y.automerge_text(this.__wbg_ptr, A, v(g) ? 0 : kA(g)); var B = D[0], E = D[1]; if (D[3]) throw B = 0, E = 0, p(D[2]); return Q = B, C = E, HA(B, E); } finally { y.__wbindgen_free(Q, C, 1); } } /** * @param {any} obj * @param {Array<any> | null} [heads] * @returns {Array<any>} */ spans(A, g) { const Q = y.automerge_spans(this.__wbg_ptr, A, v(g) ? 0 : kA(g)); if (Q[2]) throw p(Q[1]); return p(Q[0]); } /** * @param {any} obj * @param {number} start * @param {number} delete_count * @param {any} text */ splice(A, g, Q, C) { const B = y.automerge_splice(this.__wbg_ptr, A, g, Q, C); if (B[1]) throw p(B[0]); } /** * @param {ObjID} obj * @param {string} new_text */ updateText(A, g) { const Q = y.automerge_updateText(this.__wbg_ptr, A, g); if (Q[1]) throw p(Q[0]); } /** * @param {ObjID} obj * @param {Span[]} args * @param {UpdateSpansConfig | undefined | null} config */ updateSpans(A, g, Q) { const C = y.automerge_updateSpans(this.__wbg_ptr, A, g, Q); if (C[1]) throw p(C[0]); } /** * @param {any} obj * @param {any} value * @param {any} datatype */ push(A, g, Q) { const C = y.automerge_push(this.__wbg_ptr, A, g, Q); if (C[1]) throw p(C[0]); } /** * @param {ObjID} obj * @param {ObjType} value * @returns {ObjID} */ pushObject(A, g) { let Q, C; try { const D = y.automerge_pushObject(this.__wbg_ptr, A, g); var B = D[0], E = D[1]; if (D[3]) throw B = 0, E = 0, p(D[2]); return Q = B, C = E, HA(B, E); } finally { y.__wbindgen_free(Q, C, 1); } } /** * @param {any} obj * @param {number} index * @param {any} value * @param {any} datatype */ insert(A, g, Q, C) { const B = y.automerge_insert(this.__wbg_ptr, A, g, Q, C); if (B[1]) throw p(B[0]); } /** * @param {ObjID} obj * @param {number} index * @param {{[key: string]: MaterializeValue}} block */ splitBlock(A, g, Q) { const C = y.automerge_splitBlock(this.__wbg_ptr, A, g, Q); if (C[1]) throw p(C[0]); } /** * @param {ObjID} obj * @param {number} index */ joinBlock(A, g) { const Q = y.automerge_joinBlock(this.__wbg_ptr, A, g); if (Q[1]) throw p(Q[0]); } /** * @param {ObjID} obj * @param {number} index * @param {{[key: string]: MaterializeValue}} block */ updateBlock(A, g, Q) { const C = y.automerge_updateBlock(this.__wbg_ptr, A, g, Q); if (C[1]) throw p(C[0]); } /** * @param {any} text * @param {number} index * @param {Array<any> | null} [heads] * @returns {any} */ getBlock(A, g, Q) { const C = y.automerge_getBlock(this.__wbg_ptr, A, g, v(Q) ? 0 : kA(Q)); if (C[2]) throw p(C[1]); return p(C[0]); } /** * @param {ObjID} obj * @param {number} index * @param {ObjType} value * @returns {ObjID} */ insertObject(A, g, Q) { let C, B; try { const i = y.automerge_insertObject(this.__wbg_ptr, A, g, Q); var E = i[0], D = i[1]; if (i[3]) throw E = 0, D = 0, p(i[2]); return C = E, B = D, HA(E, D); } finally { y.__wbindgen_free(C, B, 1); } } /** * @param {any} obj * @param {any} prop * @param {any} value * @param {any} datatype */ put(A, g, Q, C) { const B = y.automerge_put(this.__wbg_ptr, A, g, Q, C); if (B[1]) throw p(B[0]); } /** * @param {ObjID} obj * @param {Prop} prop * @param {ObjType} value * @returns {ObjID} */ putObject(A, g, Q) { const C = y.automerge_putObject(this.__wbg_ptr, A, g, Q); if (C[2]) throw p(C[1]); return p(C[0]); } /** * @param {ObjID} obj * @param {Prop} prop * @param {number} value */ increment(A, g, Q) { const C = y.automerge_increment(this.__wbg_ptr, A, g, Q); if (C[1]) throw p(C[0]); } /** * @param {any} obj * @param {any} prop * @param {Array<any> | null} [heads] * @returns {any} */ get(A, g, Q) { const C = y.automerge_get(this.__wbg_ptr, A, g, v(Q) ? 0 : kA(Q)); if (C[2]) throw p(C[1]); return p(C[0]); } /** * @param {any} obj * @param {any} prop * @param {Array<any> | null} [heads] * @returns {any} */ getWithType(A, g, Q) { const C = y.automerge_getWithType(this.__wbg_ptr, A, g, v(Q) ? 0 : kA(Q)); if (C[2]) throw p(C[1]); return p(C[0]); } /** * @param {any} obj * @param {Array<any> | null} [heads] * @returns {object} */ objInfo(A, g) { const Q = y.automerge_objInfo(this.__wbg_ptr, A, v(g) ? 0 : kA(g)); if (Q[2]) throw p(Q[1]); return p(Q[0]); } /** * @param {any} obj * @param {any} arg * @param {Array<any> | null} [heads] * @returns {Array<any>} */ getAll(A, g, Q) { const C = y.automerge_getAll(this.__wbg_ptr, A, g, v(Q) ? 0 : kA(Q)); if (C[2]) throw p(C[1]); return p(C[0]); } /** * @param {boolean} enable * @returns {boolean} */ enableFreeze(A) { const g = y.automerge_enableFreeze(this.__wbg_ptr, A); if (g[2]) throw p(g[1]); return g[0] !== 0; } /** * @param {string} datatype * @param {Function} construct * @param {(arg: any) => any | undefined} deconstruct */ registerDatatype(A, g, Q) { const C = y.automerge_registerDatatype(this.__wbg_ptr, A, g, Q); if (C[1]) throw p(C[0]); } /** * @param {any} object * @param {any} meta * @returns {any} */ applyPatches(A, g) { const Q = y.automerge_applyPatches(this.__wbg_ptr, A, g); if (Q[2]) throw p(Q[1]); return p(Q[0]); } /** * @param {any} object * @param {any} meta * @returns {any} */ applyAndReturnPatches(A, g) { const Q = y.automerge_applyAndReturnPatches(this.__wbg_ptr, A, g); if (Q[2]) throw p(Q[1]); return p(Q[0]); } /** * @returns {Patch[]} */ diffIncremental() { const A = y.automerge_diffIncremental(this.__wbg_ptr); if (A[2]) throw p(A[1]); return p(A[0]); } updateDiffCursor() { y.automerge_updateDiffCursor(this.__wbg_ptr); } resetDiffCursor() { y.automerge_resetDiffCursor(this.__wbg_ptr); } /** * @param {Heads} before * @param {Heads} after * @returns {Patch[]} */ diff(A, g) { const Q = y.automerge_diff(this.__wbg_ptr, A, g); if (Q[2]) throw p(Q[1]); return p(Q[0]); } /** * @param {Heads} heads */ isolate(A) { const g = y.automerge_isolate(this.__wbg_ptr, A); if (g[1]) throw p(g[0]); } integrate() { y.automerge_integrate(this.__wbg_ptr); } /** * @param {any} obj * @param {Array<any> | null} [heads] * @returns {number} */ length(A, g) { const Q = y.automerge_length(this.__wbg_ptr, A, v(g) ? 0 : kA(g)); if (Q[2]) throw p(Q[1]); return Q[0]; } /** * @param {ObjID} obj * @param {Prop} prop */ delete(A, g) { const Q = y.automerge_delete(this.__wbg_ptr, A, g); if (Q[1]) throw p(Q[0]); } /** * @returns {Uint8Array} */ save() { return y.automerge_save(this.__wbg_ptr); } /** * @returns {Uint8Array} */ saveIncremental() { return y.automerge_saveIncremental(this.__wbg_ptr); } /** * @param {Heads} heads * @returns {Uint8Array} */ saveSince(A) { const g = y.automerge_saveSince(this.__wbg_ptr, A); if (g[2]) throw p(g[1]); return p(g[0]); } /** * @returns {Uint8Array} */ saveNoCompress() { return y.automerge_saveNoCompress(this.__wbg_ptr); } /** * @returns {Uint8Array} */ saveAndVerify() { const A = y.automerge_saveAndVerify(this.__wbg_ptr); if (A[2]) throw p(A[1]); return p(A[0]); } /** * @param {Uint8Array} data * @returns {number} */ loadIncremental(A) { const g = y.automerge_loadIncremental(this.__wbg_ptr, A); if (g[2]) throw p(g[1]); return g[0]; } /** * @param {Change[]} changes */ applyChanges(A) { const g = y.automerge_applyChanges(this.__wbg_ptr, A); if (g[1]) throw p(g[0]); } /** * @param {Heads} have_deps * @returns {Change[]} */ getChanges(A) { const g = y.automerge_getChanges(this.__wbg_ptr, A); if (g[2]) throw p(g[1]); return p(g[0]); } /** * @param {Heads} have_deps * @returns {ChangeMetadata[]} */ getChangesMeta(A) { const g = y.automerge_getChangesMeta(this.__wbg_ptr, A); if (g[2]) throw p(g[1]); return p(g[0]); } /** * @param {Hash} hash * @returns {Change | null} */ getChangeByHash(A) { const g = y.automerge_getChangeByHash(this.__wbg_ptr, A); if (g[2]) throw p(g[1]); return p(g[0]); } /** * @param {Hash} hash * @returns {ChangeMetadata | null} */ getChangeMetaByHash(A) { const g = y.automerge_getChangeMetaByHash(this.__wbg_ptr, A); if (g[2]) throw p(g[1]); return p(g[0]); } /** * @param {Hash} hash * @returns {DecodedChange | null} */ getDecodedChangeByHash(A) { const g = y.automerge_getDecodedChangeByHash(this.__wbg_ptr, A); if (g[2]) throw p(g[1]); return p(g[0]); } /** * @param {Automerge} other * @returns {Change[]} */ getChangesAdded(A) { return DI(A, VA), y.automerge_getChangesAdded(this.__wbg_ptr, A.__wbg_ptr); } /** * @returns {Heads} */ getHeads() { return y.automerge_getHeads(this.__wbg_ptr); } /** * @returns {Actor} */ getActorId() { let A, g; try { const Q = y.automerge_getActorId(this.__wbg_ptr); return A = Q[0], g = Q[1], HA(Q[0], Q[1]); } finally { y.__wbindgen_free(A, g, 1); } } /** * @returns {Change | null} */ getLastLocalChange() { return y.automerge_getLastLocalChange(this.__wbg_ptr); } dump() { y.automerge_dump(this.__wbg_ptr); } /** * @param {Array<any> | null} [heads] * @returns {Array<any>} */ getMissingDeps(A) { const g = y.automerge_getMissingDeps(this.__wbg_ptr, v(A) ? 0 : kA(A)); if (g[2]) throw p(g[1]); return p(g[0]); } /** * @param {SyncState} state * @param {SyncMessage} message */ receiveSyncMessage(A, g) { DI(A, OA); const Q = y.automerge_receiveSyncMessage(this.__wbg_ptr, A.__wbg_ptr, g); if (Q[1]) throw p(Q[0]); } /** * @param {SyncState} state * @returns {SyncMessage | null} */ generateSyncMessage(A) { return DI(A, OA), y.automerge_generateSyncMessage(this.__wbg_ptr, A.__wbg_ptr); } /** * @param {any} meta * @returns {MaterializeValue} */ toJS(A) { const g = y.automerge_toJS(this.__wbg_ptr, A); if (g[2]) throw p(g[1]); return p(g[0]); } /** * @param {any} obj * @param {Array<any> | null | undefined} heads * @param {any} meta * @returns {any} */ materialize(A, g, Q) { const C = y.automerge_materialize(this.__wbg_ptr, A, v(g) ? 0 : kA(g), Q); if (C[2]) throw p(C[1]); return p(C[0]); } /** * @param {any} obj * @param {any} position * @param {Array<any> | null | undefined} heads * @param {any} move_cursor * @returns {string} */ getCursor(A, g, Q, C) { let B, E; try { const G = y.automerge_getCursor(this.__wbg_ptr, A, g, v(Q) ? 0 : kA(Q), C); var D = G[0], i = G[1]; if (G[3]) throw D = 0, i = 0, p(G[2]); return B = D, E = i, HA(D, i); } finally { y.__wbindgen_free(B, E, 1); } } /** * @param {any} obj * @param {any} cursor * @param {Array<any> | null} [heads] * @returns {number} */ getCursorPosition(A, g, Q) { const C = y.automerge_getCursorPosition(this.__wbg_ptr, A, g, v(Q) ? 0 : kA(Q)); if (C[2]) throw p(C[1]); return C[0]; } /** * @param {string | null} [message] * @param {number | null} [time] * @returns {Hash} */ emptyChange(A, g) { var Q = v(A) ? 0 : XA(A, y.__wbindgen_malloc, y.__wbindgen_realloc), C = ZA; return y.automerge_emptyChange(this.__wbg_ptr, Q, C, !v(g), v(g) ? 0 : g); } /** * @param {any} obj * @param {any} range * @param {any} name * @param {any} value * @param {any} datatype */ mark(A, g, Q, C, B) { const E = y.automerge_mark(this.__wbg_ptr, A, g, Q, C, B); if (E[1]) throw p(E[0]); } /** * @param {ObjID} obj * @param {MarkRange} range * @param {string} name */ unmark(A, g, Q) { const C = y.automerge_unmark(this.__wbg_ptr, A, g, Q); if (C[1]) throw p(C[0]); } /** * @param {any} obj * @param {Array<any> | null} [heads] * @returns {any} */ marks(A, g) { const Q = y.automerge_marks(this.__wbg_ptr, A, v(g) ? 0 : kA(g)); if (Q[2]) throw p(Q[1]); return p(Q[0]); } /** * @param {any} obj * @param {number} index * @param {Array<any> | null} [heads] * @returns {object} */ marksAt(A, g, Q) { const C = y.automerge_marksAt(this.__wbg_ptr, A, g, v(Q) ? 0 : kA(Q)); if (C[2]) throw p(C[1]); return p(C[0]); } /** * @param {SyncState} state * @returns {boolean} */ hasOurChanges(A) { return DI(A, OA), y.automerge_hasOurChanges(this.__wbg_ptr, A.__wbg_ptr) !== 0; } /** * @returns {Hash[]} */ topoHistoryTraversal() { return y.automerge_topoHistoryTraversal(this.__wbg_ptr); } /** * @returns {Stats} */ stats() { return y.automerge_stats(this.__wbg_ptr); } } const qC = typeof FinalizationRegistry > "u" ? { register: () => { }, unregister: () => { } } : new FinalizationRegistry((I) => y.__wbg_syncstate_free(I >>> 0, 1)); class OA { static __wrap(A) { A = A >>> 0; const g = Object.create(OA.prototype); return g.__wbg_ptr = A, qC.register(g, g.__wbg_ptr, g), g; } __destroy_into_raw() { const A = this.__wbg_ptr; return this.__wbg_ptr = 0, qC.unregister(this), A; } free() { const A = this.__destroy_into_raw(); y.__wbg_syncstate_free(A, 0); } /** * @returns {Heads} */ get sharedHeads() { return y.syncstate_sharedHeads(this.__wbg_ptr); } /** * @returns {Heads} */ get lastSentHeads() { return y.syncstate_lastSentHeads(this.__wbg_ptr); } /** * @param {Heads} heads */ set lastSentHeads(A) { const g = y.syncstate_set_lastSentHeads(this.__wbg_ptr, A); if (g[1]) throw p(g[0]); } /** * @param {Heads} hashes */ set sentHashes(A) { const g = y.syncstate_set_sentHashes(this.__wbg_ptr, A); if (g[1]) throw p(g[0]); } /** * @returns {SyncState} */ clone() { const A = y.syncstate_clone(this.__wbg_ptr); return OA.__wrap(A); } } async function Ei(I, A) { if (typeof Response == "function" && I instanceof Response) { if (typeof WebAssembly.instantiateStreaming == "function") try { return await WebAssembly.instantiateStreaming(I, A); } catch (Q) { if (I.headers.get("Content-Type") != "application/wasm") console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", Q); else throw Q; } const g = await I.arrayBuffer(); return await WebAssembly.instantiate(g, A); } else { const g = await WebAssembly.instantiate(I, A); return g instanceof WebAssembly.Instance ? { instance: g, module: I } : g; } } function qB() { const I = {}; return I.wbg = {}, I.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(A, g) { const Q = String(g), C = XA(Q, y.__wbindgen_malloc, y.__wbindgen_realloc), B = ZA; LA().setInt32(A + 4 * 1, B, true), LA().setInt32(A + 4 * 0, C, true); }, I.wbg.__wbg_apply_eb9e9b97497f91e4 = function() { return rA(function(A, g, Q) { return Reflect.apply(A, g, Q); }, arguments); }, I.wbg.__wbg_assign_3627b8559449930a = function(A, g) { return Object.assign(A, g); }, I.wbg.__wbg_buffer_609cc3eee51ed158 = function(A) { return A.buffer; }, I.wbg.__wbg_call_672a4d21634d4a24 = function() { return rA(function(A, g) { return A.call(g); }, arguments); }, I.wbg.__wbg_call_7cccdd69e0791ae2 = function() { return rA(function(A, g, Q) { return A.call(g, Q); }, arguments); }, I.wbg.__wbg_concat_9de968491c4340cf = function(A, g) { return A.concat(g); }, I.wbg.__wbg_defineProperty_a3ddad9901e2d29e = function(A, g, Q) { return Object.defineProperty(A, g, Q); }, I.wbg.__wbg_deleteProperty_96363d4a1d977c97 = function() { return rA(function(A, g) { return Reflect.deleteProperty(A, g); }, arguments); }, I.wbg.__wbg_done_769e5ede4b31c67b = function(A) { return A.done; }, I.wbg.__wbg_entries_3265d4158b33e5dc = function(A) { return Object.entries(A); }, I.wbg.__wbg_error_7534b8e9a36f1ab4 = function(A, g) { let Q, C; try { Q = A, C = g, console.error(HA(A, g)); } finally { y.__wbindgen_free(Q, C, 1); } }, I.wbg.__wbg_for_4ff07bddd743c5e7 = function(A, g) { return Symbol.for(HA(A, g)); }, I.wbg.__wbg_freeze_ef6d70cf38e8d948 = function(A) { return Object.freeze(A); }, I.wbg.__wbg_from_2a5d3e218e67aa85 = function(A) { return Array.from(A); }, I.wbg.__wbg_getRandomValues_3c9c0d586e575a16 = function() { return rA(function(A, g) { globalThis.crypto.getRandomValues(zD(A, g)); }, arguments); }, I.wbg.__wbg_getTime_46267b1c24877e30 = function(A) { return A.getTime(); }, I.wbg.__wbg_get_67b2ba62fc30de12 = function() { return rA(function(A, g) { return Reflect.get(A, g); }, arguments); }, I.wbg.__wbg_get_b9b93047fe3cf45b = function(A, g) { return A[g >>> 0]; }, I.wbg.__wbg_instanceof_ArrayBuffer_e14585432e3737fc = function(A) { let g; try { g = A instanceof ArrayBuffer; } catch { g = false; } return g; }, I.wbg.__wbg_instanceof_Date_e9a9be8b9cea7890 = function(A) { let g; try { g = A instanceof Date; } catch { g = false; } return g; }, I.wbg.__wbg_instanceof_Object_7f2dcef8f78644a4 = function(A) { let g; try { g = A instanceof Object; } catch { g = false; } return g; }, I.wbg.__wbg_instanceof_Uint8Array_17156bcf118086a9 = function(A) { let g; try { g = A instanceof Uint8Array; } catch { g = false; } return g; }, I.wbg.__wbg_isArray_a1eab7e0d067391b = function(A) { return Array.isArray(A); }, I.wbg.__wbg_iterator_9a24c88df860dc65 = function() { return Symbol.iterator; }, I.wbg.__wbg_keys_5c77a08ddc2fb8a6 = function(A) { return Object.keys(A); }, I.wbg.__wbg_length_a446193dc22c12f8 = function(A) { return A.length; }, I.wbg.__wbg_length_d56737991078581b = function(A) { return A.length; }, I.wbg.__wbg_length_e2d2a49132c1b256 = function(A) { return A.length; }, I.wbg.__wbg_log_1ae1e9f741096e91 = function(A, g) { console.log(A, g); }, I.wbg.__wbg_log_c222819a41e063d3 = function(A) { console.log(A); }, I.wbg.__wbg_new_1ab78df5e132f715 = function(A, g) { return new RangeError(HA(A, g)); }, I.wbg.__wbg_new_31a97dac4f10fab7 = function(A) { return new Date(A); }, I.wbg.__wbg_new_405e22f390576ce2 = function() { return new Object(); }, I.wbg.__wbg_new_78feb108b6472713 = function() { return new Array(); }, I.wbg.__wbg_new_8a6f238a6ece86ea = function() { return new Error(); }, I.wbg.__wbg_new_a12002a7f91c75be = function(A) { return new Uint8Array(A); }, I.wbg.__wbg_new_c68d7209be747379 = function(A, g) { return new Error(HA(A, g)); }, I.wbg.__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a = function(A, g, Q) { return new Uint8Array(A, g >>> 0, Q >>> 0); }, I.wbg.__wbg_next_25feadfc0913fea9 = function(A) { return A.next; }, I.wbg.__wbg_next_6574e1a8a62d1055 = function() { return rA(function(A) { return A.next(); }, arguments); }, I.wbg.__wbg_ownKeys_3930041068756f1f = function() { return rA(function(A) { return Reflect.ownKeys(A); }, arguments); }, I.wbg.__wbg_push_737cfc8c1432c2c6 = function(A, g) { return A.push(g); }, I.wbg.__wbg_set_37837023f3d740e8 = function(A, g, Q) { A[g >>> 0] = Q; }, I.wbg.__wbg_set_3f1d0b984ed272ed = function(A, g, Q) { A[g] = Q; }, I.wbg.__wbg_set_65595bdd868b3009 = function(A, g, Q) { A.set(g, Q >>> 0); }, I.wbg.__wbg_set_bb8cecf6a62b9f46 = function() { return rA(function(A, g, Q) { return Reflect.set(A, g, Q); }, arguments); }, I.wbg.__wbg_slice_972c243648c9fd2e = function(A, g, Q) { return A.slice(g >>> 0, Q >>> 0); }, I.wbg.__wbg_stack_0ed75d68575b0f3c = function(A, g) { const Q = g.stack, C = XA(Q, y.__wbindgen_malloc, y.__wbindgen_realloc), B = ZA; LA().setInt32(A + 4 * 1, B, true), LA().setInt32(A + 4 * 0, C, true); }, I.wbg.__wbg_toString_66ab719c2a98bdf1 = function(A) { return A.toString(); }, I.wbg.__wbg_unshift_c290010f73f04fb1 = function(A, g) { return A.unshift(g); }, I.wbg.__wbg_value_cd1ffa7b1ab794f1 = function(A) { return A.value; }, I.wbg.__wbg_values_fcb8ba8c0aad8b58 = function(A) { return Object.values(A); }, I.wbg.__wbindgen_bigint_from_i64 = function(A) { return A; }, I.wbg.__wbindgen_bigint_from_u64 = function(A) { return BigInt.asUintN(64, A); }, I.wbg.__wbindgen_boolean_get = function(A) { const g = A; return typeof g == "boolean" ? g ? 1 : 0 : 2; }, I.wbg.__wbindgen_debug_string = function(A, g) { const Q = RQ(g), C = XA(Q, y.__wbindgen_malloc, y.__wbindgen_realloc), B = ZA; LA().setInt32(A + 4 * 1, B, true), LA().setInt32(A + 4 * 0, C, true); }, I.wbg.__wbindgen_error_new = function(A, g) { return new Error(HA(A, g)); }, I.wbg.__wbindgen_init_externref_table = function() { const A = y.__wbindgen_export_4, g = A.grow(4); A.set(0, void 0), A.set(g + 0, void 0), A.set(g + 1, null), A.set(g + 2, true), A.set(g + 3, false); }, I.wbg.__wbindgen_is_array = function(A) { return Array.isArray(A); }, I.wbg.__wbindgen_is_function = function(A) { return typeof A == "function"; }, I.wbg.__wbindgen_is_null = function(A) { return A === null; }, I.wbg.__wbindgen_is_object = function(A) { const g = A; return typeof g == "object" && g !== null; }, I.wbg.__wbindgen_is_string = function(A) { return typeof A == "string"; }, I.wbg.__wbindgen_is_undefined = function(A) { return A === void 0; }, I.wbg.__wbindgen_json_serialize = function(A, g) { const Q = g, C = JSON.stringify(Q === void 0 ? null : Q), B = XA(C, y.__wbindgen_malloc, y.__wbindgen_realloc), E = ZA; LA().setInt32(A + 4 * 1, E, true), LA().setInt32(A + 4 * 0, B, true); }, I.wbg.__wbindgen_jsval_loose_eq = function(A, g) { return A == g; }, I.wbg.__wbindgen_memory = function() { return y.memory; }, I.wbg.__wbindgen_number_get = function(A, g) { const Q = g, C = typeof Q == "number" ? Q : void 0; LA().setFloat64(A + 8 * 1, v(C) ? 0 : C, true), LA().setInt32(A + 4 * 0, !v(C), true); }, I.wbg.__wbindgen_number_new = function(A) { return A; }, I.wbg.__wbindgen_string_get = function(A, g) { const Q = g, C = typeof Q == "string" ? Q : void 0; var B = v(C) ? 0 : XA(C, y.__wbindgen_malloc, y.__wbindgen_realloc), E = ZA; LA().setInt32(A + 4 * 1, E, true), LA().setInt32(A + 4 * 0, B, true); }, I.wbg.__wbindgen_string_new = function(A, g) { return HA(A, g); }, I.wbg.__wbindgen_throw = function(A, g) { throw new Error(HA(A, g)); }, I; } function LB(I, A) { return y = I.exports, vQ.__wbindgen_wasm_module = A, BI = null, WI = null, y.__wbindgen_start(), y; } function Di(I) { if (y !== void 0) return y; typeof I < "u" && (Object.getPrototypeOf(I) === Object.prototype ? { module: I } = I : console.warn("using deprecated parameters for `initSync()`; pass a single object instead")); const A = qB(); I instanceof WebAssembly.Module || (I = new WebAssembly.Module(I)); const g = new WebAssembly.Instance(I, A); return LB(g, I); } async function vQ(I) { if (y !== void 0) return y; typeof I < "u" && (Object.getPrototypeOf(I) === Object.prototype ? { module_or_path: I } = I : console.warn("using deprecated parameters for the initialization function; pass a single object instead")), typeof I > "u" && (I = new /* @vite-ignore */ URL("automerge_wasm_bg.wasm", import.meta.url)); const A = qB(); (typeof I == "string" || typeof Request == "function" && I instanceof Request || typeof URL == "function" && I instanceof URL) && (I = fetch(I)); const { instance: g, module: Q } = await Ei(await I, A); return LB(g, Q); } const ii = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, Automerge: VA, SyncState: OA, create: uD, decodeChange: _D, decodeSyncMessage: Qi, decodeSyncState: Bi, default: vQ, encodeChange: vD, encodeSyncMessage: gi, encodeSyncState: Ci, exportSyncState: Ii, importSyncState: Ai, initSync: Di, initSyncState: $D, load: PD }, Symbol.toStringTag, { value: "Module" })); let oi = []; function Gi(I) { for (const A in I) yA[A] = I[A]; for (const A of oi) A(); } const yA = { create(I) { throw new RangeError("Automerge.use() not called"); }, load(I, A) { throw new RangeError("Automerge.use() not called (load)"); }, encodeChange(I) { throw new RangeError("Automerge.use() not called (encodeChange)"); }, decodeChange(I) { throw new RangeError("Automerge.use() not called (decodeChange)"); }, initSyncState() { throw new RangeError("Automerge.use() not called (initSyncState)"); }, encodeSyncMessage(I) { throw new RangeError("Automerge.use() not called (encodeSyncMessage)"); }, decodeSyncMessage(I) { throw