action_merge 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.md +157 -0
  3. data/README.md +49 -0
  4. data/Rakefile +8 -0
  5. data/app/assets/builds/action_merge/application.d.ts +1 -0
  6. data/app/assets/builds/action_merge/application.d.ts.map +1 -0
  7. data/app/assets/builds/action_merge/application.js +6 -0
  8. data/app/assets/builds/action_merge/application.js.map +1 -0
  9. data/app/assets/builds/action_merge/automerge.wasm +0 -0
  10. data/app/assets/builds/action_merge/network-adapter.d.ts +18 -0
  11. data/app/assets/builds/action_merge/network-adapter.d.ts.map +1 -0
  12. data/app/assets/builds/action_merge/syncable.d.ts +7 -0
  13. data/app/assets/builds/action_merge/syncable.d.ts.map +1 -0
  14. data/app/assets/config/action_merge_manifest.js +1 -0
  15. data/app/assets/stylesheets/action_merge/application.css +15 -0
  16. data/app/channels/action_merge/sync_channel.rb +36 -0
  17. data/app/channels/application_cable/channel.rb +4 -0
  18. data/app/channels/application_cable/connection.rb +4 -0
  19. data/app/controllers/action_merge/application_controller.rb +4 -0
  20. data/app/helpers/action_merge/application_helper.rb +4 -0
  21. data/app/javascript/action_merge/application.ts +5 -0
  22. data/app/javascript/action_merge/network-adapter.ts +144 -0
  23. data/app/javascript/action_merge/syncable.ts +24 -0
  24. data/app/jobs/action_merge/application_job.rb +4 -0
  25. data/app/mailers/action_merge/application_mailer.rb +6 -0
  26. data/app/models/action_merge/application_record.rb +5 -0
  27. data/app/models/action_merge/document/chunk.rb +11 -0
  28. data/app/models/action_merge/document.rb +6 -0
  29. data/app/models/action_merge/peer.rb +23 -0
  30. data/app/models/action_merge/storage_adapter.rb +32 -0
  31. data/app/views/layouts/action_merge/application.html.erb +14 -0
  32. data/config/routes.rb +2 -0
  33. data/db/migrate/20240910160133_create_action_merge_documents.rb +19 -0
  34. data/lib/action_merge/assets.rb +19 -0
  35. data/lib/action_merge/engine.rb +16 -0
  36. data/lib/action_merge/helpers.rb +7 -0
  37. data/lib/action_merge/syncable.rb +19 -0
  38. data/lib/action_merge.rb +12 -0
  39. data/lib/tasks/action_merge_tasks.rake +4 -0
  40. metadata +104 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"application.js","sources":["../../../../node_modules/@automerge/automerge/dist/mjs/constants.js","../../../../node_modules/@automerge/automerge/dist/mjs/text.js","../../../../node_modules/@automerge/automerge/dist/mjs/counter.js","../../../../node_modules/@automerge/automerge/dist/mjs/numbers.js","../../../../node_modules/@automerge/automerge/dist/mjs/raw_string.js","../../../../node_modules/@automerge/automerge/dist/mjs/proxies.js","../../../../node_modules/@automerge/automerge/dist/mjs/conflicts.js","../../../../node_modules/uuid/dist/esm-browser/rng.js","../../../../node_modules/uuid/dist/esm-browser/regex.js","../../../../node_modules/uuid/dist/esm-browser/validate.js","../../../../node_modules/uuid/dist/esm-browser/stringify.js","../../../../node_modules/uuid/dist/esm-browser/parse.js","../../../../node_modules/uuid/dist/esm-browser/native.js","../../../../node_modules/uuid/dist/esm-browser/v4.js","../../../../node_modules/@automerge/automerge/dist/mjs/wasm_bindgen_output/web/automerge_wasm.js","../../../../node_modules/@automerge/automerge/dist/mjs/low_level.js","../../../../node_modules/@automerge/automerge/dist/mjs/internal_state.js","../../../../node_modules/@automerge/automerge/dist/mjs/stable.js","../../../../node_modules/@automerge/automerge/dist/mjs/next_slim.js","../../../../node_modules/ms/index.js","../../../../node_modules/debug/src/common.js","../../../../node_modules/debug/src/browser.js","../../../../node_modules/eventemitter3/index.js","../../../../node_modules/xstate/dev/dist/xstate-dev.esm.js","../../../../node_modules/xstate/dist/raise-c0e3c984.esm.js","../../../../node_modules/xstate/dist/log-a2c94240.esm.js","../../../../node_modules/xstate/dist/xstate.esm.js","../../../../node_modules/@noble/hashes/_assert.js","../../../../node_modules/@noble/hashes/crypto.js","../../../../node_modules/@noble/hashes/utils.js","../../../../node_modules/@noble/hashes/_md.js","../../../../node_modules/@noble/hashes/sha256.js","../../../../node_modules/base-x/src/index.js","../../../../node_modules/bs58/index.js","../../../../node_modules/bs58check/base.js","../../../../node_modules/bs58check/index.js","../../../../node_modules/@automerge/automerge-repo/dist/AutomergeUrl.js","../../../../node_modules/cbor-x/decode.js","../../../../node_modules/cbor-x/encode.js","../../../../node_modules/@automerge/automerge-repo/dist/helpers/cbor.js","../../../../node_modules/@automerge/automerge-repo/dist/helpers/arraysAreEqual.js","../../../../node_modules/@automerge/automerge-repo/dist/helpers/headsAreSame.js","../../../../node_modules/@automerge/automerge-repo/dist/helpers/withTimeout.js","../../../../node_modules/@automerge/automerge-repo/dist/DocHandle.js","../../../../node_modules/@automerge/automerge-repo/dist/RemoteHeadsSubscriptions.js","../../../../node_modules/@automerge/automerge-repo/dist/helpers/throttle.js","../../../../node_modules/@automerge/automerge-repo/dist/network/messages.js","../../../../node_modules/@automerge/automerge-repo/dist/network/NetworkSubsystem.js","../../../../node_modules/@automerge/automerge-repo/dist/helpers/mergeArrays.js","../../../../node_modules/fast-sha256/sha256.js","../../../../node_modules/@automerge/automerge-repo/dist/storage/keyHash.js","../../../../node_modules/@automerge/automerge-repo/dist/storage/chunkTypeFromKey.js","../../../../node_modules/@automerge/automerge-repo/dist/storage/StorageSubsystem.js","../../../../node_modules/@automerge/automerge-repo/dist/synchronizer/Synchronizer.js","../../../../node_modules/@automerge/automerge-repo/dist/synchronizer/DocSynchronizer.js","../../../../node_modules/@automerge/automerge-repo/dist/synchronizer/CollectionSynchronizer.js","../../../../node_modules/@automerge/automerge-repo/dist/Repo.js","../../../../node_modules/@automerge/automerge-repo/dist/network/NetworkAdapter.js","../../../../node_modules/@automerge/automerge/dist/mjs/wasm_bindgen_output/bundler/automerge_wasm_bg.wasm?url","../../../../../../../../__vite-plugin-wasm-helper","../../../../node_modules/@automerge/automerge/dist/mjs/wasm_bindgen_output/bundler/automerge_wasm_bg.js","../../../../node_modules/@automerge/automerge/dist/mjs/wasm_bindgen_output/bundler/automerge_wasm_bg.wasm","../../../../node_modules/@automerge/automerge/dist/mjs/wasm_bindgen_output/bundler/automerge_wasm.js","../../../../node_modules/@automerge/automerge/dist/mjs/entrypoints/fullfat_bundler.js","../../../../node_modules/@rails/actioncable/app/assets/javascripts/actioncable.esm.js","../../../../node_modules/lodash.omit/index.js","../../../javascript/action_merge/network-adapter.ts","../../../../node_modules/@automerge/automerge-repo-storage-indexeddb/dist/index.js","../../../javascript/action_merge/syncable.ts","../../../javascript/action_merge/application.ts"],"sourcesContent":["// Properties of the document root object\nexport const STATE = Symbol.for(\"_am_meta\"); // symbol used to hide application metadata on automerge objects\nexport const TRACE = Symbol.for(\"_am_trace\"); // used for debugging\nexport const OBJECT_ID = Symbol.for(\"_am_objectId\"); // symbol used to hide the object id on automerge objects\nexport const IS_PROXY = Symbol.for(\"_am_isProxy\"); // symbol used to test if the document is a proxy object\nexport const CLEAR_CACHE = Symbol.for(\"_am_clearCache\"); // symbol used to tell a proxy object to clear its cache\nexport const UINT = Symbol.for(\"_am_uint\");\nexport const INT = Symbol.for(\"_am_int\");\nexport const F64 = Symbol.for(\"_am_f64\");\nexport const COUNTER = Symbol.for(\"_am_counter\");\nexport const TEXT = Symbol.for(\"_am_text\");\n","import { TEXT, STATE } from \"./constants.js\";\nexport class Text {\n constructor(text) {\n if (typeof text === \"string\") {\n this.elems = [...text];\n }\n else if (Array.isArray(text)) {\n this.elems = text;\n }\n else if (text === undefined) {\n this.elems = [];\n }\n else {\n throw new TypeError(`Unsupported initial value for Text: ${text}`);\n }\n Reflect.defineProperty(this, TEXT, { value: true });\n }\n get length() {\n return this.elems.length;\n }\n //eslint-disable-next-line @typescript-eslint/no-explicit-any\n get(index) {\n return this.elems[index];\n }\n /**\n * Iterates over the text elements character by character, including any\n * inline objects.\n */\n [Symbol.iterator]() {\n const elems = this.elems;\n let index = -1;\n return {\n next() {\n index += 1;\n if (index < elems.length) {\n return { done: false, value: elems[index] };\n }\n else {\n return { done: true };\n }\n },\n };\n }\n /**\n * Returns the content of the Text object as a simple string, ignoring any\n * non-character elements.\n */\n toString() {\n if (!this.str) {\n // Concatting to a string is faster than creating an array and then\n // .join()ing for small (<100KB) arrays.\n // https://jsperf.com/join-vs-loop-w-type-test\n this.str = \"\";\n for (const elem of this.elems) {\n if (typeof elem === \"string\")\n this.str += elem;\n else\n this.str += \"\\uFFFC\";\n }\n }\n return this.str;\n }\n /**\n * Returns the content of the Text object as a sequence of strings,\n * interleaved with non-character elements.\n *\n * For example, the value `['a', 'b', {x: 3}, 'c', 'd']` has spans:\n * `=> ['ab', {x: 3}, 'cd']`\n */\n toSpans() {\n if (!this.spans) {\n this.spans = [];\n let chars = \"\";\n for (const elem of this.elems) {\n if (typeof elem === \"string\") {\n chars += elem;\n }\n else {\n if (chars.length > 0) {\n this.spans.push(chars);\n chars = \"\";\n }\n this.spans.push(elem);\n }\n }\n if (chars.length > 0) {\n this.spans.push(chars);\n }\n }\n return this.spans;\n }\n /**\n * Returns the content of the Text object as a simple string, so that the\n * JSON serialization of an Automerge document represents text nicely.\n */\n toJSON() {\n return this.toString();\n }\n /**\n * Updates the list item at position `index` to a new value `value`.\n */\n set(index, value) {\n if (this[STATE]) {\n throw new RangeError(\"object cannot be modified outside of a change block\");\n }\n this.elems[index] = value;\n }\n /**\n * Inserts new list items `values` starting at position `index`.\n */\n insertAt(index, ...values) {\n if (this[STATE]) {\n throw new RangeError(\"object cannot be modified outside of a change block\");\n }\n if (values.every(v => typeof v === \"string\")) {\n this.elems.splice(index, 0, ...values.join(\"\"));\n }\n else {\n this.elems.splice(index, 0, ...values);\n }\n }\n /**\n * Deletes `numDelete` list items starting at position `index`.\n * if `numDelete` is not given, one item is deleted.\n */\n deleteAt(index, numDelete = 1) {\n if (this[STATE]) {\n throw new RangeError(\"object cannot be modified outside of a change block\");\n }\n this.elems.splice(index, numDelete);\n }\n map(callback) {\n this.elems.map(callback);\n }\n lastIndexOf(searchElement, fromIndex) {\n this.elems.lastIndexOf(searchElement, fromIndex);\n }\n concat(other) {\n return new Text(this.elems.concat(other.elems));\n }\n every(test) {\n return this.elems.every(test);\n }\n filter(test) {\n return new Text(this.elems.filter(test));\n }\n find(test) {\n return this.elems.find(test);\n }\n findIndex(test) {\n return this.elems.findIndex(test);\n }\n forEach(f) {\n this.elems.forEach(f);\n }\n includes(elem) {\n return this.elems.includes(elem);\n }\n indexOf(elem) {\n return this.elems.indexOf(elem);\n }\n join(sep) {\n return this.elems.join(sep);\n }\n reduce(f) {\n this.elems.reduce(f);\n }\n reduceRight(f) {\n this.elems.reduceRight(f);\n }\n slice(start, end) {\n return new Text(this.elems.slice(start, end));\n }\n some(test) {\n return this.elems.some(test);\n }\n toLocaleString() {\n this.toString();\n }\n}\n","import { COUNTER } from \"./constants.js\";\n/**\n * The most basic CRDT: an integer value that can be changed only by\n * incrementing and decrementing. Since addition of integers is commutative,\n * the value trivially converges.\n */\nexport class Counter {\n constructor(value) {\n this.value = value || 0;\n Reflect.defineProperty(this, COUNTER, { value: true });\n }\n /**\n * A peculiar JavaScript language feature from its early days: if the object\n * `x` has a `valueOf()` method that returns a number, you can use numerical\n * operators on the object `x` directly, such as `x + 1` or `x < 4`.\n * This method is also called when coercing a value to a string by\n * concatenating it with another string, as in `x + ''`.\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf\n */\n valueOf() {\n return this.value;\n }\n /**\n * Returns the counter value as a decimal string. If `x` is a counter object,\n * this method is called e.g. when you do `['value: ', x].join('')` or when\n * you use string interpolation: `value: ${x}`.\n */\n toString() {\n return this.valueOf().toString();\n }\n /**\n * Returns the counter value, so that a JSON serialization of an Automerge\n * document represents the counter simply as an integer.\n */\n toJSON() {\n return this.value;\n }\n /**\n * Increases the value of the counter by `delta`. If `delta` is not given,\n * increases the value of the counter by 1.\n *\n * Will throw an error if used outside of a change callback.\n */\n increment(_delta) {\n throw new Error(\"Counters should not be incremented outside of a change callback\");\n }\n /**\n * Decreases the value of the counter by `delta`. If `delta` is not given,\n * decreases the value of the counter by 1.\n *\n * Will throw an error if used outside of a change callback.\n */\n decrement(_delta) {\n throw new Error(\"Counters should not be decremented outside of a change callback\");\n }\n}\n/**\n * An instance of this class is used when a counter is accessed within a change\n * callback.\n */\nclass WriteableCounter extends Counter {\n constructor(value, context, path, objectId, key) {\n super(value);\n this.context = context;\n this.path = path;\n this.objectId = objectId;\n this.key = key;\n }\n /**\n * Increases the value of the counter by `delta`. If `delta` is not given,\n * increases the value of the counter by 1.\n */\n increment(delta) {\n delta = typeof delta === \"number\" ? delta : 1;\n this.context.increment(this.objectId, this.key, delta);\n this.value += delta;\n return this.value;\n }\n /**\n * Decreases the value of the counter by `delta`. If `delta` is not given,\n * decreases the value of the counter by 1.\n */\n decrement(delta) {\n return this.increment(typeof delta === \"number\" ? -delta : -1);\n }\n}\n/**\n * Returns an instance of `WriteableCounter` for use in a change callback.\n * `context` is the proxy context that keeps track of the mutations.\n * `objectId` is the ID of the object containing the counter, and `key` is\n * the property name (key in map, or index in list) where the counter is\n * located.\n */\nexport function getWriteableCounter(value, context, path, objectId, key) {\n return new WriteableCounter(value, context, path, objectId, key);\n}\n//module.exports = { Counter, getWriteableCounter }\n","// Convenience classes to allow users to strictly specify the number type they want\nimport { INT, UINT, F64 } from \"./constants.js\";\nexport class Int {\n constructor(value) {\n if (!(Number.isInteger(value) &&\n value <= Number.MAX_SAFE_INTEGER &&\n value >= Number.MIN_SAFE_INTEGER)) {\n throw new RangeError(`Value ${value} cannot be a uint`);\n }\n this.value = value;\n Reflect.defineProperty(this, INT, { value: true });\n Object.freeze(this);\n }\n}\nexport class Uint {\n constructor(value) {\n if (!(Number.isInteger(value) &&\n value <= Number.MAX_SAFE_INTEGER &&\n value >= 0)) {\n throw new RangeError(`Value ${value} cannot be a uint`);\n }\n this.value = value;\n Reflect.defineProperty(this, UINT, { value: true });\n Object.freeze(this);\n }\n}\nexport class Float64 {\n constructor(value) {\n if (typeof value !== \"number\") {\n throw new RangeError(`Value ${value} cannot be a float64`);\n }\n this.value = value || 0.0;\n Reflect.defineProperty(this, F64, { value: true });\n Object.freeze(this);\n }\n}\n","export class RawString {\n constructor(val) {\n this.val = val;\n }\n /**\n * Returns the content of the RawString object as a simple string\n */\n toString() {\n return this.val;\n }\n toJSON() {\n return this.val;\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { Text } from \"./text.js\";\nimport { getWriteableCounter } from \"./counter.js\";\nimport { STATE, TRACE, IS_PROXY, OBJECT_ID, CLEAR_CACHE, COUNTER, INT, UINT, F64, } from \"./constants.js\";\nimport { RawString } from \"./raw_string.js\";\nfunction parseListIndex(key) {\n if (typeof key === \"string\" && /^[0-9]+$/.test(key))\n key = parseInt(key, 10);\n if (typeof key !== \"number\") {\n return key;\n }\n if (key < 0 || isNaN(key) || key === Infinity || key === -Infinity) {\n throw new RangeError(\"A list index must be positive, but you passed \" + key);\n }\n return key;\n}\nfunction valueAt(target, prop) {\n const { context, objectId, path, textV2 } = target;\n const value = context.getWithType(objectId, prop);\n if (value === null) {\n return;\n }\n const datatype = value[0];\n const val = value[1];\n switch (datatype) {\n case undefined:\n return;\n case \"map\":\n return mapProxy(context, val, textV2, [...path, prop]);\n case \"list\":\n return listProxy(context, val, textV2, [...path, prop]);\n case \"text\":\n if (textV2) {\n return context.text(val);\n }\n else {\n return textProxy(context, val, [\n ...path,\n prop,\n ]);\n }\n case \"str\":\n return val;\n case \"uint\":\n return val;\n case \"int\":\n return val;\n case \"f64\":\n return val;\n case \"boolean\":\n return val;\n case \"null\":\n return null;\n case \"bytes\":\n return val;\n case \"timestamp\":\n return val;\n case \"counter\": {\n const counter = getWriteableCounter(val, context, path, objectId, prop);\n return counter;\n }\n default:\n throw RangeError(`datatype ${datatype} unimplemented`);\n }\n}\nfunction import_value(value, textV2, path, context) {\n const type = typeof value;\n switch (type) {\n case \"object\":\n if (value == null) {\n return [null, \"null\"];\n }\n else if (value[UINT]) {\n return [value.value, \"uint\"];\n }\n else if (value[INT]) {\n return [value.value, \"int\"];\n }\n else if (value[F64]) {\n return [value.value, \"f64\"];\n }\n else if (value[COUNTER]) {\n return [value.value, \"counter\"];\n }\n else if (value instanceof Date) {\n return [value.getTime(), \"timestamp\"];\n }\n else if (value instanceof RawString) {\n return [value.toString(), \"str\"];\n }\n else if (value instanceof Text) {\n return [value, \"text\"];\n }\n else if (value instanceof Uint8Array) {\n return [value, \"bytes\"];\n }\n else if (value instanceof Array) {\n return [value, \"list\"];\n }\n else if (Object.prototype.toString.call(value) === \"[object Object]\") {\n return [value, \"map\"];\n }\n else if (isSameDocument(value, context)) {\n throw new RangeError(\"Cannot create a reference to an existing document object\");\n }\n else {\n throw new RangeError(`Cannot assign unknown object: ${value}`);\n }\n case \"boolean\":\n return [value, \"boolean\"];\n case \"number\":\n if (Number.isInteger(value)) {\n return [value, \"int\"];\n }\n else {\n return [value, \"f64\"];\n }\n case \"string\":\n if (textV2) {\n return [value, \"text\"];\n }\n else {\n return [value, \"str\"];\n }\n case \"undefined\":\n throw new RangeError([\n `Cannot assign undefined value at ${printPath(path)}, `,\n \"because `undefined` is not a valid JSON data type. \",\n \"You might consider setting the property's value to `null`, \",\n \"or using `delete` to remove it altogether.\",\n ].join(\"\"));\n default:\n throw new RangeError([\n `Cannot assign ${type} value at ${printPath(path)}. `,\n `All JSON primitive datatypes (object, array, string, number, boolean, null) `,\n `are supported in an Automerge document; ${type} values are not. `,\n ].join(\"\"));\n }\n}\n// When we assign a value to a property in a proxy we recursively walk through\n// the value we are assigning and copy it into the document. This is generally\n// desirable behaviour. However, a very common bug is to accidentally assign a\n// value which is already in the document to another key within the same\n// document, this often leads to surprising behaviour where users expected to\n// _move_ the object, but it is instead copied. To avoid this we check if the\n// value is from the same document and if it is we throw an error, this means\n// we require an explicit Object.assign call to copy the object, thus avoiding\n// the footgun\nfunction isSameDocument(val, context) {\n var _b, _c;\n // Date is technically an object, but immutable, so allowing people to assign\n // a date from one place in the document to another place in the document is\n // not likely to be a bug\n if (val instanceof Date) {\n return false;\n }\n // this depends on __wbg_ptr being the wasm pointer\n // a new version of wasm-bindgen will break this\n // but the tests should expose the break\n if (val && ((_c = (_b = val[STATE]) === null || _b === void 0 ? void 0 : _b.handle) === null || _c === void 0 ? void 0 : _c.__wbg_ptr) === context.__wbg_ptr) {\n return true;\n }\n return false;\n}\nconst MapHandler = {\n get(target, key) {\n const { context, objectId, cache } = target;\n if (key === Symbol.toStringTag) {\n return target[Symbol.toStringTag];\n }\n if (key === OBJECT_ID)\n return objectId;\n if (key === IS_PROXY)\n return true;\n if (key === TRACE)\n return target.trace;\n if (key === STATE)\n return { handle: context, textV2: target.textV2 };\n if (!cache[key]) {\n cache[key] = valueAt(target, key);\n }\n return cache[key];\n },\n set(target, key, val) {\n const { context, objectId, path, textV2 } = target;\n target.cache = {}; // reset cache on set\n if (isSameDocument(val, context)) {\n throw new RangeError(\"Cannot create a reference to an existing document object\");\n }\n if (key === TRACE) {\n target.trace = val;\n return true;\n }\n if (key === CLEAR_CACHE) {\n return true;\n }\n const [value, datatype] = import_value(val, textV2, [...path, key], context);\n switch (datatype) {\n case \"list\": {\n const list = context.putObject(objectId, key, []);\n const proxyList = listProxy(context, list, textV2, [...path, key]);\n for (let i = 0; i < value.length; i++) {\n proxyList[i] = value[i];\n }\n break;\n }\n case \"text\": {\n if (textV2) {\n assertString(value);\n context.putObject(objectId, key, value);\n }\n else {\n assertText(value);\n const text = context.putObject(objectId, key, \"\");\n const proxyText = textProxy(context, text, [...path, key]);\n proxyText.splice(0, 0, ...value);\n }\n break;\n }\n case \"map\": {\n const map = context.putObject(objectId, key, {});\n const proxyMap = mapProxy(context, map, textV2, [...path, key]);\n for (const key in value) {\n proxyMap[key] = value[key];\n }\n break;\n }\n default:\n context.put(objectId, key, value, datatype);\n }\n return true;\n },\n deleteProperty(target, key) {\n const { context, objectId } = target;\n target.cache = {}; // reset cache on delete\n context.delete(objectId, key);\n return true;\n },\n has(target, key) {\n const value = this.get(target, key);\n return value !== undefined;\n },\n getOwnPropertyDescriptor(target, key) {\n // const { context, objectId } = target\n const value = this.get(target, key);\n if (typeof value !== \"undefined\") {\n return {\n configurable: true,\n enumerable: true,\n value,\n };\n }\n },\n ownKeys(target) {\n const { context, objectId } = target;\n // FIXME - this is a tmp workaround until fix the dupe key bug in keys()\n const keys = context.keys(objectId);\n return [...new Set(keys)];\n },\n};\nconst ListHandler = {\n get(target, index) {\n const { context, objectId } = target;\n index = parseListIndex(index);\n if (index === Symbol.hasInstance) {\n return (instance) => {\n return Array.isArray(instance);\n };\n }\n if (index === Symbol.toStringTag) {\n return target[Symbol.toStringTag];\n }\n if (index === OBJECT_ID)\n return objectId;\n if (index === IS_PROXY)\n return true;\n if (index === TRACE)\n return target.trace;\n if (index === STATE)\n return { handle: context };\n if (index === \"length\")\n return context.length(objectId);\n if (typeof index === \"number\") {\n return valueAt(target, index);\n }\n else {\n return listMethods(target)[index];\n }\n },\n set(target, index, val) {\n const { context, objectId, path, textV2 } = target;\n index = parseListIndex(index);\n if (isSameDocument(val, context)) {\n throw new RangeError(\"Cannot create a reference to an existing document object\");\n }\n if (index === CLEAR_CACHE) {\n return true;\n }\n if (index === TRACE) {\n target.trace = val;\n return true;\n }\n if (typeof index == \"string\") {\n throw new RangeError(\"list index must be a number\");\n }\n const [value, datatype] = import_value(val, textV2, [...path, index], context);\n switch (datatype) {\n case \"list\": {\n let list;\n if (index >= context.length(objectId)) {\n list = context.insertObject(objectId, index, []);\n }\n else {\n list = context.putObject(objectId, index, []);\n }\n const proxyList = listProxy(context, list, textV2, [...path, index]);\n proxyList.splice(0, 0, ...value);\n break;\n }\n case \"text\": {\n if (textV2) {\n assertString(value);\n if (index >= context.length(objectId)) {\n context.insertObject(objectId, index, value);\n }\n else {\n context.putObject(objectId, index, value);\n }\n }\n else {\n let text;\n assertText(value);\n if (index >= context.length(objectId)) {\n text = context.insertObject(objectId, index, \"\");\n }\n else {\n text = context.putObject(objectId, index, \"\");\n }\n const proxyText = textProxy(context, text, [...path, index]);\n proxyText.splice(0, 0, ...value);\n }\n break;\n }\n case \"map\": {\n let map;\n if (index >= context.length(objectId)) {\n map = context.insertObject(objectId, index, {});\n }\n else {\n map = context.putObject(objectId, index, {});\n }\n const proxyMap = mapProxy(context, map, textV2, [...path, index]);\n for (const key in value) {\n proxyMap[key] = value[key];\n }\n break;\n }\n default:\n if (index >= context.length(objectId)) {\n context.insert(objectId, index, value, datatype);\n }\n else {\n context.put(objectId, index, value, datatype);\n }\n }\n return true;\n },\n deleteProperty(target, index) {\n const { context, objectId } = target;\n index = parseListIndex(index);\n const elem = context.get(objectId, index);\n if (elem != null && elem[0] == \"counter\") {\n throw new TypeError(\"Unsupported operation: deleting a counter from a list\");\n }\n context.delete(objectId, index);\n return true;\n },\n has(target, index) {\n const { context, objectId } = target;\n index = parseListIndex(index);\n if (typeof index === \"number\") {\n return index < context.length(objectId);\n }\n return index === \"length\";\n },\n getOwnPropertyDescriptor(target, index) {\n const { context, objectId } = target;\n if (index === \"length\")\n return { writable: true, value: context.length(objectId) };\n if (index === OBJECT_ID)\n return { configurable: false, enumerable: false, value: objectId };\n index = parseListIndex(index);\n const value = valueAt(target, index);\n return { configurable: true, enumerable: true, value };\n },\n getPrototypeOf(target) {\n return Object.getPrototypeOf(target);\n },\n ownKeys( /*target*/) {\n const keys = [];\n // uncommenting this causes assert.deepEqual() to fail when comparing to a pojo array\n // but not uncommenting it causes for (i in list) {} to not enumerate values properly\n //const {context, objectId } = target\n //for (let i = 0; i < target.context.length(objectId); i++) { keys.push(i.toString()) }\n keys.push(\"length\");\n return keys;\n },\n};\nconst TextHandler = Object.assign({}, ListHandler, {\n get(target, index) {\n const { context, objectId } = target;\n index = parseListIndex(index);\n if (index === Symbol.hasInstance) {\n return (instance) => {\n return Array.isArray(instance);\n };\n }\n if (index === Symbol.toStringTag) {\n return target[Symbol.toStringTag];\n }\n if (index === OBJECT_ID)\n return objectId;\n if (index === IS_PROXY)\n return true;\n if (index === TRACE)\n return target.trace;\n if (index === STATE)\n return { handle: context };\n if (index === \"length\")\n return context.length(objectId);\n if (typeof index === \"number\") {\n return valueAt(target, index);\n }\n else {\n return textMethods(target)[index] || listMethods(target)[index];\n }\n },\n getPrototypeOf( /*target*/) {\n return Object.getPrototypeOf(new Text());\n },\n});\nexport function mapProxy(context, objectId, textV2, path) {\n const target = {\n context,\n objectId,\n path: path || [],\n cache: {},\n textV2,\n };\n const proxied = {};\n Object.assign(proxied, target);\n const result = new Proxy(proxied, MapHandler);\n // conversion through unknown is necessary because the types are so different\n return result;\n}\nexport function listProxy(context, objectId, textV2, path) {\n const target = {\n context,\n objectId,\n path: path || [],\n cache: {},\n textV2,\n };\n const proxied = [];\n Object.assign(proxied, target);\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return new Proxy(proxied, ListHandler);\n}\nexport function textProxy(context, objectId, path) {\n const target = {\n context,\n objectId,\n path: path || [],\n cache: {},\n textV2: false,\n };\n const proxied = {};\n Object.assign(proxied, target);\n return new Proxy(proxied, TextHandler);\n}\nexport function rootProxy(context, textV2) {\n /* eslint-disable-next-line */\n return mapProxy(context, \"_root\", textV2, []);\n}\nfunction listMethods(target) {\n const { context, objectId, path, textV2 } = target;\n const methods = {\n deleteAt(index, numDelete) {\n if (typeof numDelete === \"number\") {\n context.splice(objectId, index, numDelete);\n }\n else {\n context.delete(objectId, index);\n }\n return this;\n },\n fill(val, start, end) {\n const [value, datatype] = import_value(val, textV2, [...path, start], context);\n const length = context.length(objectId);\n start = parseListIndex(start || 0);\n end = parseListIndex(end || length);\n for (let i = start; i < Math.min(end, length); i++) {\n if (datatype === \"list\" || datatype === \"map\") {\n context.putObject(objectId, i, value);\n }\n else if (datatype === \"text\") {\n if (textV2) {\n assertString(value);\n context.putObject(objectId, i, value);\n }\n else {\n assertText(value);\n const text = context.putObject(objectId, i, \"\");\n const proxyText = textProxy(context, text, [...path, i]);\n for (let i = 0; i < value.length; i++) {\n proxyText[i] = value.get(i);\n }\n }\n }\n else {\n context.put(objectId, i, value, datatype);\n }\n }\n return this;\n },\n indexOf(o, start = 0) {\n const length = context.length(objectId);\n for (let i = start; i < length; i++) {\n const value = context.getWithType(objectId, i);\n if (value && (value[1] === o[OBJECT_ID] || value[1] === o)) {\n return i;\n }\n }\n return -1;\n },\n insertAt(index, ...values) {\n this.splice(index, 0, ...values);\n return this;\n },\n pop() {\n const length = context.length(objectId);\n if (length == 0) {\n return undefined;\n }\n const last = valueAt(target, length - 1);\n context.delete(objectId, length - 1);\n return last;\n },\n push(...values) {\n const len = context.length(objectId);\n this.splice(len, 0, ...values);\n return context.length(objectId);\n },\n shift() {\n if (context.length(objectId) == 0)\n return;\n const first = valueAt(target, 0);\n context.delete(objectId, 0);\n return first;\n },\n splice(index, del, ...vals) {\n index = parseListIndex(index);\n // if del is undefined, delete until the end of the list\n if (typeof del !== \"number\") {\n del = context.length(objectId) - index;\n }\n del = parseListIndex(del);\n for (const val of vals) {\n if (isSameDocument(val, context)) {\n throw new RangeError(\"Cannot create a reference to an existing document object\");\n }\n }\n const result = [];\n for (let i = 0; i < del; i++) {\n const value = valueAt(target, index);\n if (value !== undefined) {\n result.push(value);\n }\n context.delete(objectId, index);\n }\n const values = vals.map((val, index) => {\n try {\n return import_value(val, textV2, [...path], context);\n }\n catch (e) {\n if (e instanceof RangeError) {\n throw new RangeError(`${e.message} (at index ${index} in the input)`);\n }\n else {\n throw e;\n }\n }\n });\n for (const [value, datatype] of values) {\n switch (datatype) {\n case \"list\": {\n const list = context.insertObject(objectId, index, []);\n const proxyList = listProxy(context, list, textV2, [...path, index]);\n proxyList.splice(0, 0, ...value);\n break;\n }\n case \"text\": {\n if (textV2) {\n assertString(value);\n context.insertObject(objectId, index, value);\n }\n else {\n const text = context.insertObject(objectId, index, \"\");\n const proxyText = textProxy(context, text, [...path, index]);\n proxyText.splice(0, 0, ...value);\n }\n break;\n }\n case \"map\": {\n const map = context.insertObject(objectId, index, {});\n const proxyMap = mapProxy(context, map, textV2, [...path, index]);\n for (const key in value) {\n proxyMap[key] = value[key];\n }\n break;\n }\n default:\n context.insert(objectId, index, value, datatype);\n }\n index += 1;\n }\n return result;\n },\n unshift(...values) {\n this.splice(0, 0, ...values);\n return context.length(objectId);\n },\n entries() {\n let i = 0;\n const iterator = {\n next: () => {\n const value = valueAt(target, i);\n if (value === undefined) {\n return { value: undefined, done: true };\n }\n else {\n return { value: [i++, value], done: false };\n }\n },\n [Symbol.iterator]() {\n return this;\n },\n };\n return iterator;\n },\n keys() {\n let i = 0;\n const len = context.length(objectId);\n const iterator = {\n next: () => {\n if (i < len) {\n return { value: i++, done: false };\n }\n return { value: undefined, done: true };\n },\n [Symbol.iterator]() {\n return this;\n },\n };\n return iterator;\n },\n values() {\n let i = 0;\n const iterator = {\n next: () => {\n const value = valueAt(target, i++);\n if (value === undefined) {\n return { value: undefined, done: true };\n }\n else {\n return { value, done: false };\n }\n },\n [Symbol.iterator]() {\n return this;\n },\n };\n return iterator;\n },\n toArray() {\n const list = [];\n let value;\n do {\n value = valueAt(target, list.length);\n if (value !== undefined) {\n list.push(value);\n }\n } while (value !== undefined);\n return list;\n },\n map(f) {\n return this.toArray().map(f);\n },\n toString() {\n return this.toArray().toString();\n },\n toLocaleString() {\n return this.toArray().toLocaleString();\n },\n forEach(f) {\n return this.toArray().forEach(f);\n },\n // todo: real concat function is different\n concat(other) {\n return this.toArray().concat(other);\n },\n every(f) {\n return this.toArray().every(f);\n },\n filter(f) {\n return this.toArray().filter(f);\n },\n find(f) {\n let index = 0;\n for (const v of this) {\n if (f(v, index)) {\n return v;\n }\n index += 1;\n }\n },\n findIndex(f) {\n let index = 0;\n for (const v of this) {\n if (f(v, index)) {\n return index;\n }\n index += 1;\n }\n return -1;\n },\n includes(elem) {\n return this.find(e => e === elem) !== undefined;\n },\n join(sep) {\n return this.toArray().join(sep);\n },\n reduce(f, initialValue) {\n return this.toArray().reduce(f, initialValue);\n },\n reduceRight(f, initialValue) {\n return this.toArray().reduceRight(f, initialValue);\n },\n lastIndexOf(search, fromIndex = +Infinity) {\n // this can be faster\n return this.toArray().lastIndexOf(search, fromIndex);\n },\n slice(index, num) {\n return this.toArray().slice(index, num);\n },\n some(f) {\n let index = 0;\n for (const v of this) {\n if (f(v, index)) {\n return true;\n }\n index += 1;\n }\n return false;\n },\n [Symbol.iterator]: function* () {\n let i = 0;\n let value = valueAt(target, i);\n while (value !== undefined) {\n yield value;\n i += 1;\n value = valueAt(target, i);\n }\n },\n };\n return methods;\n}\nfunction textMethods(target) {\n const { context, objectId } = target;\n const methods = {\n set(index, value) {\n return (this[index] = value);\n },\n get(index) {\n return this[index];\n },\n toString() {\n return context.text(objectId).replace(//g, \"\");\n },\n toSpans() {\n const spans = [];\n let chars = \"\";\n const length = context.length(objectId);\n for (let i = 0; i < length; i++) {\n const value = this[i];\n if (typeof value === \"string\") {\n chars += value;\n }\n else {\n if (chars.length > 0) {\n spans.push(chars);\n chars = \"\";\n }\n spans.push(value);\n }\n }\n if (chars.length > 0) {\n spans.push(chars);\n }\n return spans;\n },\n toJSON() {\n return this.toString();\n },\n indexOf(o, start = 0) {\n const text = context.text(objectId);\n return text.indexOf(o, start);\n },\n insertAt(index, ...values) {\n if (values.every(v => typeof v === \"string\")) {\n context.splice(objectId, index, 0, values.join(\"\"));\n }\n else {\n listMethods(target).insertAt(index, ...values);\n }\n },\n };\n return methods;\n}\nfunction assertText(value) {\n if (!(value instanceof Text)) {\n throw new Error(\"value was not a Text instance\");\n }\n}\nfunction assertString(value) {\n if (typeof value !== \"string\") {\n throw new Error(\"value was not a string\");\n }\n}\nfunction printPath(path) {\n // print the path as a json pointer\n const jsonPointerComponents = path.map(component => {\n // if its a number just turn it into a string\n if (typeof component === \"number\") {\n return component.toString();\n }\n else if (typeof component === \"string\") {\n // otherwise we have to escape `/` and `~` characters\n return component.replace(/~/g, \"~0\").replace(/\\//g, \"~1\");\n }\n });\n if (path.length === 0) {\n return \"\";\n }\n else {\n return \"/\" + jsonPointerComponents.join(\"/\");\n }\n}\n","import { Counter } from \"./types.js\";\nimport { Text } from \"./text.js\";\nimport { mapProxy, listProxy } from \"./proxies.js\";\nexport function stableConflictAt(context, objectId, prop) {\n return conflictAt(context, objectId, prop, true, (context, conflictId) => {\n return new Text(context.text(conflictId));\n });\n}\nexport function unstableConflictAt(context, objectId, prop) {\n return conflictAt(context, objectId, prop, true, (context, conflictId) => {\n return context.text(conflictId);\n });\n}\nfunction conflictAt(context, objectId, prop, textV2, handleText) {\n const values = context.getAll(objectId, prop);\n if (values.length <= 1) {\n return;\n }\n const result = {};\n for (const fullVal of values) {\n switch (fullVal[0]) {\n case \"map\":\n result[fullVal[1]] = mapProxy(context, fullVal[1], textV2, [prop]);\n break;\n case \"list\":\n result[fullVal[1]] = listProxy(context, fullVal[1], textV2, [prop]);\n break;\n case \"text\":\n result[fullVal[1]] = handleText(context, fullVal[1]);\n break;\n case \"str\":\n case \"uint\":\n case \"int\":\n case \"f64\":\n case \"boolean\":\n case \"bytes\":\n case \"null\":\n result[fullVal[2]] = fullVal[1];\n break;\n case \"counter\":\n result[fullVal[2]] = new Counter(fullVal[1]);\n break;\n case \"timestamp\":\n result[fullVal[2]] = new Date(fullVal[1]);\n break;\n default:\n throw RangeError(`datatype ${fullVal[0]} unimplemented`);\n }\n }\n return result;\n}\n","// Unique ID creation requires a high quality random # generator. In the browser we therefore\n// require the crypto API and do not support built-in fallback to lower quality random number\n// generators (like Math.random()).\nlet getRandomValues;\nconst rnds8 = new Uint8Array(16);\nexport default function rng() {\n // lazy load so that environments that need to polyfill have a chance to do so\n if (!getRandomValues) {\n // getRandomValues needs to be invoked in a context where \"this\" is a Crypto implementation.\n getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);\n\n if (!getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n }\n\n return getRandomValues(rnds8);\n}","export default /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;","import REGEX from './regex.js';\n\nfunction validate(uuid) {\n return typeof uuid === 'string' && REGEX.test(uuid);\n}\n\nexport default validate;","import validate from './validate.js';\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nconst byteToHex = [];\n\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\n\nexport function unsafeStringify(arr, offset = 0) {\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];\n}\n\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\nexport default stringify;","import validate from './validate.js';\n\nfunction parse(uuid) {\n if (!validate(uuid)) {\n throw TypeError('Invalid UUID');\n }\n\n let v;\n const arr = new Uint8Array(16); // Parse ########-....-....-....-............\n\n arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;\n arr[1] = v >>> 16 & 0xff;\n arr[2] = v >>> 8 & 0xff;\n arr[3] = v & 0xff; // Parse ........-####-....-....-............\n\n arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;\n arr[5] = v & 0xff; // Parse ........-....-####-....-............\n\n arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;\n arr[7] = v & 0xff; // Parse ........-....-....-####-............\n\n arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;\n arr[9] = v & 0xff; // Parse ........-....-....-....-############\n // (Use \"/\" to avoid 32-bit truncation when bit-shifting high-order bytes)\n\n arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;\n arr[11] = v / 0x100000000 & 0xff;\n arr[12] = v >>> 24 & 0xff;\n arr[13] = v >>> 16 & 0xff;\n arr[14] = v >>> 8 & 0xff;\n arr[15] = v & 0xff;\n return arr;\n}\n\nexport default parse;","const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nexport default {\n randomUUID\n};","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\n\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n\n options = options || {};\n const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n\n return buf;\n }\n\n return unsafeStringify(rnds);\n}\n\nexport default v4;","let wasm;\n\nconst heap = new Array(128).fill(undefined);\n\nheap.push(undefined, null, true, false);\n\nfunction getObject(idx) { return heap[idx]; }\n\nlet heap_next = heap.length;\n\nfunction dropObject(idx) {\n if (idx < 132) return;\n heap[idx] = heap_next;\n heap_next = idx;\n}\n\nfunction takeObject(idx) {\n const ret = getObject(idx);\n dropObject(idx);\n return ret;\n}\n\nlet WASM_VECTOR_LEN = 0;\n\nlet cachedUint8Memory0 = null;\n\nfunction getUint8Memory0() {\n if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {\n cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);\n }\n return cachedUint8Memory0;\n}\n\nconst cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );\n\nconst encodeString = (typeof cachedTextEncoder.encodeInto === 'function'\n ? function (arg, view) {\n return cachedTextEncoder.encodeInto(arg, view);\n}\n : function (arg, view) {\n const buf = cachedTextEncoder.encode(arg);\n view.set(buf);\n return {\n read: arg.length,\n written: buf.length\n };\n});\n\nfunction passStringToWasm0(arg, malloc, realloc) {\n\n if (realloc === undefined) {\n const buf = cachedTextEncoder.encode(arg);\n const ptr = malloc(buf.length, 1) >>> 0;\n getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);\n WASM_VECTOR_LEN = buf.length;\n return ptr;\n }\n\n let len = arg.length;\n let ptr = malloc(len, 1) >>> 0;\n\n const mem = getUint8Memory0();\n\n let offset = 0;\n\n for (; offset < len; offset++) {\n const code = arg.charCodeAt(offset);\n if (code > 0x7F) break;\n mem[ptr + offset] = code;\n }\n\n if (offset !== len) {\n if (offset !== 0) {\n arg = arg.slice(offset);\n }\n ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;\n const view = getUint8Memory0().subarray(ptr + offset, ptr + len);\n const ret = encodeString(arg, view);\n\n offset += ret.written;\n ptr = realloc(ptr, len, offset, 1) >>> 0;\n }\n\n WASM_VECTOR_LEN = offset;\n return ptr;\n}\n\nfunction isLikeNone(x) {\n return x === undefined || x === null;\n}\n\nlet cachedInt32Memory0 = null;\n\nfunction getInt32Memory0() {\n if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {\n cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);\n }\n return cachedInt32Memory0;\n}\n\nconst cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );\n\nif (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };\n\nfunction getStringFromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));\n}\n\nfunction addHeapObject(obj) {\n if (heap_next === heap.length) heap.push(heap.length + 1);\n const idx = heap_next;\n heap_next = heap[idx];\n\n heap[idx] = obj;\n return idx;\n}\n\nlet cachedFloat64Memory0 = null;\n\nfunction getFloat64Memory0() {\n if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {\n cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);\n }\n return cachedFloat64Memory0;\n}\n\nfunction debugString(val) {\n // primitive types\n const type = typeof val;\n if (type == 'number' || type == 'boolean' || val == null) {\n return `${val}`;\n }\n if (type == 'string') {\n return `\"${val}\"`;\n }\n if (type == 'symbol') {\n const description = val.description;\n if (description == null) {\n return 'Symbol';\n } else {\n return `Symbol(${description})`;\n }\n }\n if (type == 'function') {\n const name = val.name;\n if (typeof name == 'string' && name.length > 0) {\n return `Function(${name})`;\n } else {\n return 'Function';\n }\n }\n // objects\n if (Array.isArray(val)) {\n const length = val.length;\n let debug = '[';\n if (length > 0) {\n debug += debugString(val[0]);\n }\n for(let i = 1; i < length; i++) {\n debug += ', ' + debugString(val[i]);\n }\n debug += ']';\n return debug;\n }\n // Test for built-in\n const builtInMatches = /\\[object ([^\\]]+)\\]/.exec(toString.call(val));\n let className;\n if (builtInMatches.length > 1) {\n className = builtInMatches[1];\n } else {\n // Failed to match the standard '[object ClassName]'\n return toString.call(val);\n }\n if (className == 'Object') {\n // we're a user defined class or Object\n // JSON.stringify avoids problems with cycles, and is generally much\n // easier than looping through ownProperties of `val`.\n try {\n return 'Object(' + JSON.stringify(val) + ')';\n } catch (_) {\n return 'Object';\n }\n }\n // errors\n if (val instanceof Error) {\n return `${val.name}: ${val.message}\\n${val.stack}`;\n }\n // TODO we could test for more things here, like `Set`s and `Map`s.\n return className;\n}\n\nfunction _assertClass(instance, klass) {\n if (!(instance instanceof klass)) {\n throw new Error(`expected instance of ${klass.name}`);\n }\n return instance.ptr;\n}\n/**\n* @param {any} options\n* @returns {Automerge}\n*/\nexport function create(options) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.create(retptr, addHeapObject(options));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return Automerge.__wrap(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n}\n\n/**\n* @param {Uint8Array} data\n* @param {any} options\n* @returns {Automerge}\n*/\nexport function load(data, options) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.load(retptr, addHeapObject(data), addHeapObject(options));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return Automerge.__wrap(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n}\n\n/**\n* @param {any} change\n* @returns {Uint8Array}\n*/\nexport function encodeChange(change) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.encodeChange(retptr, addHeapObject(change));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n}\n\n/**\n* @param {Uint8Array} change\n* @returns {any}\n*/\nexport function decodeChange(change) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.decodeChange(retptr, addHeapObject(change));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n}\n\n/**\n* @returns {SyncState}\n*/\nexport function initSyncState() {\n const ret = wasm.initSyncState();\n return SyncState.__wrap(ret);\n}\n\n/**\n* @param {any} state\n* @returns {SyncState}\n*/\nexport function importSyncState(state) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.importSyncState(retptr, addHeapObject(state));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return SyncState.__wrap(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n}\n\n/**\n* @param {SyncState} state\n* @returns {any}\n*/\nexport function exportSyncState(state) {\n _assertClass(state, SyncState);\n const ret = wasm.exportSyncState(state.__wbg_ptr);\n return takeObject(ret);\n}\n\n/**\n* @param {any} message\n* @returns {Uint8Array}\n*/\nexport function encodeSyncMessage(message) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.encodeSyncMessage(retptr, addHeapObject(message));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n}\n\n/**\n* @param {Uint8Array} msg\n* @returns {any}\n*/\nexport function decodeSyncMessage(msg) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.decodeSyncMessage(retptr, addHeapObject(msg));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n}\n\n/**\n* @param {SyncState} state\n* @returns {Uint8Array}\n*/\nexport function encodeSyncState(state) {\n _assertClass(state, SyncState);\n const ret = wasm.encodeSyncState(state.__wbg_ptr);\n return takeObject(ret);\n}\n\n/**\n* @param {Uint8Array} data\n* @returns {SyncState}\n*/\nexport function decodeSyncState(data) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.decodeSyncState(retptr, addHeapObject(data));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return SyncState.__wrap(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n}\n\nfunction handleError(f, args) {\n try {\n return f.apply(this, args);\n } catch (e) {\n wasm.__wbindgen_exn_store(addHeapObject(e));\n }\n}\n/**\n* How text is represented in materialized objects on the JS side\n*/\nexport const TextRepresentation = Object.freeze({\n/**\n* As an array of characters and objects\n*/\nArray:0,\"0\":\"Array\",\n/**\n* As a single JS string\n*/\nString:1,\"1\":\"String\", });\n\nconst AutomergeFinalization = (typeof FinalizationRegistry === 'undefined')\n ? { register: () => {}, unregister: () => {} }\n : new FinalizationRegistry(ptr => wasm.__wbg_automerge_free(ptr >>> 0));\n/**\n*/\nexport class Automerge {\n\n static __wrap(ptr) {\n ptr = ptr >>> 0;\n const obj = Object.create(Automerge.prototype);\n obj.__wbg_ptr = ptr;\n AutomergeFinalization.register(obj, obj.__wbg_ptr, obj);\n return obj;\n }\n\n __destroy_into_raw() {\n const ptr = this.__wbg_ptr;\n this.__wbg_ptr = 0;\n AutomergeFinalization.unregister(this);\n return ptr;\n }\n\n free() {\n const ptr = this.__destroy_into_raw();\n wasm.__wbg_automerge_free(ptr);\n }\n /**\n * @param {string | undefined} actor\n * @param {TextRepresentation} text_rep\n * @returns {Automerge}\n */\n static new(actor, text_rep) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n var ptr0 = isLikeNone(actor) ? 0 : passStringToWasm0(actor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len0 = WASM_VECTOR_LEN;\n wasm.automerge_new(retptr, ptr0, len0, text_rep);\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return Automerge.__wrap(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {string | undefined} [actor]\n * @returns {Automerge}\n */\n clone(actor) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n var ptr0 = isLikeNone(actor) ? 0 : passStringToWasm0(actor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len0 = WASM_VECTOR_LEN;\n wasm.automerge_clone(retptr, this.__wbg_ptr, ptr0, len0);\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return Automerge.__wrap(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {string | undefined} actor\n * @param {any} heads\n * @returns {Automerge}\n */\n fork(actor, heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n var ptr0 = isLikeNone(actor) ? 0 : passStringToWasm0(actor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len0 = WASM_VECTOR_LEN;\n wasm.automerge_fork(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return Automerge.__wrap(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @returns {any}\n */\n pendingOps() {\n const ret = wasm.automerge_pendingOps(this.__wbg_ptr);\n return takeObject(ret);\n }\n /**\n * @param {string | undefined} [message]\n * @param {number | undefined} [time]\n * @returns {any}\n */\n commit(message, time) {\n var ptr0 = isLikeNone(message) ? 0 : passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len0 = WASM_VECTOR_LEN;\n const ret = wasm.automerge_commit(this.__wbg_ptr, ptr0, len0, !isLikeNone(time), isLikeNone(time) ? 0 : time);\n return takeObject(ret);\n }\n /**\n * @param {Automerge} other\n * @returns {Array<any>}\n */\n merge(other) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n _assertClass(other, Automerge);\n wasm.automerge_merge(retptr, this.__wbg_ptr, other.__wbg_ptr);\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @returns {number}\n */\n rollback() {\n const ret = wasm.automerge_rollback(this.__wbg_ptr);\n return ret;\n }\n /**\n * @param {any} obj\n * @param {Array<any> | undefined} [heads]\n * @returns {Array<any>}\n */\n keys(obj, heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_keys(retptr, this.__wbg_ptr, addHeapObject(obj), isLikeNone(heads) ? 0 : addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {Array<any> | undefined} [heads]\n * @returns {string}\n */\n text(obj, heads) {\n let deferred2_0;\n let deferred2_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_text(retptr, this.__wbg_ptr, addHeapObject(obj), isLikeNone(heads) ? 0 : addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n var r3 = getInt32Memory0()[retptr / 4 + 3];\n var ptr1 = r0;\n var len1 = r1;\n if (r3) {\n ptr1 = 0; len1 = 0;\n throw takeObject(r2);\n }\n deferred2_0 = ptr1;\n deferred2_1 = len1;\n return getStringFromWasm0(ptr1, len1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);\n }\n }\n /**\n * @param {any} obj\n * @param {Array<any> | undefined} [heads]\n * @returns {Array<any>}\n */\n spans(obj, heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_spans(retptr, this.__wbg_ptr, addHeapObject(obj), isLikeNone(heads) ? 0 : addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {number} start\n * @param {number} delete_count\n * @param {any} text\n */\n splice(obj, start, delete_count, text) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_splice(retptr, this.__wbg_ptr, addHeapObject(obj), start, delete_count, addHeapObject(text));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {any} new_text\n */\n updateText(obj, new_text) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_updateText(retptr, this.__wbg_ptr, addHeapObject(obj), addHeapObject(new_text));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {any} args\n */\n updateSpans(obj, args) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_updateSpans(retptr, this.__wbg_ptr, addHeapObject(obj), addHeapObject(args));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {any} value\n * @param {any} datatype\n */\n push(obj, value, datatype) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_push(retptr, this.__wbg_ptr, addHeapObject(obj), addHeapObject(value), addHeapObject(datatype));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {any} value\n * @returns {string | undefined}\n */\n pushObject(obj, value) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_pushObject(retptr, this.__wbg_ptr, addHeapObject(obj), addHeapObject(value));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n var r3 = getInt32Memory0()[retptr / 4 + 3];\n if (r3) {\n throw takeObject(r2);\n }\n let v1;\n if (r0 !== 0) {\n v1 = getStringFromWasm0(r0, r1).slice();\n wasm.__wbindgen_free(r0, r1 * 1, 1);\n }\n return v1;\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {number} index\n * @param {any} value\n * @param {any} datatype\n */\n insert(obj, index, value, datatype) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_insert(retptr, this.__wbg_ptr, addHeapObject(obj), index, addHeapObject(value), addHeapObject(datatype));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {number} index\n * @param {any} args\n */\n splitBlock(obj, index, args) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_splitBlock(retptr, this.__wbg_ptr, addHeapObject(obj), index, addHeapObject(args));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} text\n * @param {number} index\n */\n joinBlock(text, index) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_joinBlock(retptr, this.__wbg_ptr, addHeapObject(text), index);\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} text\n * @param {number} index\n * @param {any} args\n */\n updateBlock(text, index, args) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_updateBlock(retptr, this.__wbg_ptr, addHeapObject(text), index, addHeapObject(args));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} text\n * @param {number} index\n * @param {Array<any> | undefined} [heads]\n * @returns {any}\n */\n getBlock(text, index, heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_getBlock(retptr, this.__wbg_ptr, addHeapObject(text), index, isLikeNone(heads) ? 0 : addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {number} index\n * @param {any} value\n * @returns {string | undefined}\n */\n insertObject(obj, index, value) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_insertObject(retptr, this.__wbg_ptr, addHeapObject(obj), index, addHeapObject(value));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n var r3 = getInt32Memory0()[retptr / 4 + 3];\n if (r3) {\n throw takeObject(r2);\n }\n let v1;\n if (r0 !== 0) {\n v1 = getStringFromWasm0(r0, r1).slice();\n wasm.__wbindgen_free(r0, r1 * 1, 1);\n }\n return v1;\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {any} prop\n * @param {any} value\n * @param {any} datatype\n */\n put(obj, prop, value, datatype) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_put(retptr, this.__wbg_ptr, addHeapObject(obj), addHeapObject(prop), addHeapObject(value), addHeapObject(datatype));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {any} prop\n * @param {any} value\n * @returns {any}\n */\n putObject(obj, prop, value) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_putObject(retptr, this.__wbg_ptr, addHeapObject(obj), addHeapObject(prop), addHeapObject(value));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {any} prop\n * @param {any} value\n */\n increment(obj, prop, value) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_increment(retptr, this.__wbg_ptr, addHeapObject(obj), addHeapObject(prop), addHeapObject(value));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {any} prop\n * @param {Array<any> | undefined} [heads]\n * @returns {any}\n */\n get(obj, prop, heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_get(retptr, this.__wbg_ptr, addHeapObject(obj), addHeapObject(prop), isLikeNone(heads) ? 0 : addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {any} prop\n * @param {Array<any> | undefined} [heads]\n * @returns {any}\n */\n getWithType(obj, prop, heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_getWithType(retptr, this.__wbg_ptr, addHeapObject(obj), addHeapObject(prop), isLikeNone(heads) ? 0 : addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {Array<any> | undefined} [heads]\n * @returns {object}\n */\n objInfo(obj, heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_objInfo(retptr, this.__wbg_ptr, addHeapObject(obj), isLikeNone(heads) ? 0 : addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {any} arg\n * @param {Array<any> | undefined} [heads]\n * @returns {Array<any>}\n */\n getAll(obj, arg, heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_getAll(retptr, this.__wbg_ptr, addHeapObject(obj), addHeapObject(arg), isLikeNone(heads) ? 0 : addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} enable\n * @returns {any}\n */\n enableFreeze(enable) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_enableFreeze(retptr, this.__wbg_ptr, addHeapObject(enable));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} datatype\n * @param {any} export_function\n * @param {any} import_function\n */\n registerDatatype(datatype, export_function, import_function) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_registerDatatype(retptr, this.__wbg_ptr, addHeapObject(datatype), addHeapObject(export_function), addHeapObject(import_function));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} object\n * @param {any} meta\n * @returns {any}\n */\n applyPatches(object, meta) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_applyPatches(retptr, this.__wbg_ptr, addHeapObject(object), addHeapObject(meta));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} object\n * @param {any} meta\n * @returns {any}\n */\n applyAndReturnPatches(object, meta) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_applyAndReturnPatches(retptr, this.__wbg_ptr, addHeapObject(object), addHeapObject(meta));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @returns {Array<any>}\n */\n diffIncremental() {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_diffIncremental(retptr, this.__wbg_ptr);\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n */\n updateDiffCursor() {\n wasm.automerge_updateDiffCursor(this.__wbg_ptr);\n }\n /**\n */\n resetDiffCursor() {\n wasm.automerge_resetDiffCursor(this.__wbg_ptr);\n }\n /**\n * @param {Array<any>} before\n * @param {Array<any>} after\n * @returns {Array<any>}\n */\n diff(before, after) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_diff(retptr, this.__wbg_ptr, addHeapObject(before), addHeapObject(after));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {Array<any>} heads\n */\n isolate(heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_isolate(retptr, this.__wbg_ptr, addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n */\n integrate() {\n wasm.automerge_integrate(this.__wbg_ptr);\n }\n /**\n * @param {any} obj\n * @param {Array<any> | undefined} [heads]\n * @returns {number}\n */\n length(obj, heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_length(retptr, this.__wbg_ptr, addHeapObject(obj), isLikeNone(heads) ? 0 : addHeapObject(heads));\n var r0 = getFloat64Memory0()[retptr / 8 + 0];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n var r3 = getInt32Memory0()[retptr / 4 + 3];\n if (r3) {\n throw takeObject(r2);\n }\n return r0;\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {any} prop\n */\n delete(obj, prop) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_delete(retptr, this.__wbg_ptr, addHeapObject(obj), addHeapObject(prop));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @returns {Uint8Array}\n */\n save() {\n const ret = wasm.automerge_save(this.__wbg_ptr);\n return takeObject(ret);\n }\n /**\n * @returns {Uint8Array}\n */\n saveIncremental() {\n const ret = wasm.automerge_saveIncremental(this.__wbg_ptr);\n return takeObject(ret);\n }\n /**\n * @param {Array<any>} heads\n * @returns {Uint8Array}\n */\n saveSince(heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_saveSince(retptr, this.__wbg_ptr, addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @returns {Uint8Array}\n */\n saveNoCompress() {\n const ret = wasm.automerge_saveNoCompress(this.__wbg_ptr);\n return takeObject(ret);\n }\n /**\n * @returns {Uint8Array}\n */\n saveAndVerify() {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_saveAndVerify(retptr, this.__wbg_ptr);\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {Uint8Array} data\n * @returns {number}\n */\n loadIncremental(data) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_loadIncremental(retptr, this.__wbg_ptr, addHeapObject(data));\n var r0 = getFloat64Memory0()[retptr / 8 + 0];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n var r3 = getInt32Memory0()[retptr / 4 + 3];\n if (r3) {\n throw takeObject(r2);\n }\n return r0;\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} changes\n */\n applyChanges(changes) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_applyChanges(retptr, this.__wbg_ptr, addHeapObject(changes));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} have_deps\n * @returns {Array<any>}\n */\n getChanges(have_deps) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_getChanges(retptr, this.__wbg_ptr, addHeapObject(have_deps));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} hash\n * @returns {any}\n */\n getChangeByHash(hash) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_getChangeByHash(retptr, this.__wbg_ptr, addHeapObject(hash));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} hash\n * @returns {any}\n */\n getDecodedChangeByHash(hash) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_getDecodedChangeByHash(retptr, this.__wbg_ptr, addHeapObject(hash));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {Automerge} other\n * @returns {Array<any>}\n */\n getChangesAdded(other) {\n _assertClass(other, Automerge);\n const ret = wasm.automerge_getChangesAdded(this.__wbg_ptr, other.__wbg_ptr);\n return takeObject(ret);\n }\n /**\n * @returns {Array<any>}\n */\n getHeads() {\n const ret = wasm.automerge_getHeads(this.__wbg_ptr);\n return takeObject(ret);\n }\n /**\n * @returns {string}\n */\n getActorId() {\n let deferred1_0;\n let deferred1_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_getActorId(retptr, this.__wbg_ptr);\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n deferred1_0 = r0;\n deferred1_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);\n }\n }\n /**\n * @returns {any}\n */\n getLastLocalChange() {\n const ret = wasm.automerge_getLastLocalChange(this.__wbg_ptr);\n return takeObject(ret);\n }\n /**\n */\n dump() {\n wasm.automerge_dump(this.__wbg_ptr);\n }\n /**\n * @param {Array<any> | undefined} [heads]\n * @returns {Array<any>}\n */\n getMissingDeps(heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_getMissingDeps(retptr, this.__wbg_ptr, isLikeNone(heads) ? 0 : addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {SyncState} state\n * @param {Uint8Array} message\n */\n receiveSyncMessage(state, message) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n _assertClass(state, SyncState);\n wasm.automerge_receiveSyncMessage(retptr, this.__wbg_ptr, state.__wbg_ptr, addHeapObject(message));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {SyncState} state\n * @returns {any}\n */\n generateSyncMessage(state) {\n _assertClass(state, SyncState);\n const ret = wasm.automerge_generateSyncMessage(this.__wbg_ptr, state.__wbg_ptr);\n return takeObject(ret);\n }\n /**\n * @param {any} meta\n * @returns {any}\n */\n toJS(meta) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_toJS(retptr, this.__wbg_ptr, addHeapObject(meta));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {Array<any> | undefined} heads\n * @param {any} meta\n * @returns {any}\n */\n materialize(obj, heads, meta) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_materialize(retptr, this.__wbg_ptr, addHeapObject(obj), isLikeNone(heads) ? 0 : addHeapObject(heads), addHeapObject(meta));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {number} index\n * @param {Array<any> | undefined} [heads]\n * @returns {string}\n */\n getCursor(obj, index, heads) {\n let deferred2_0;\n let deferred2_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_getCursor(retptr, this.__wbg_ptr, addHeapObject(obj), index, isLikeNone(heads) ? 0 : addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n var r3 = getInt32Memory0()[retptr / 4 + 3];\n var ptr1 = r0;\n var len1 = r1;\n if (r3) {\n ptr1 = 0; len1 = 0;\n throw takeObject(r2);\n }\n deferred2_0 = ptr1;\n deferred2_1 = len1;\n return getStringFromWasm0(ptr1, len1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);\n }\n }\n /**\n * @param {any} obj\n * @param {any} cursor\n * @param {Array<any> | undefined} [heads]\n * @returns {number}\n */\n getCursorPosition(obj, cursor, heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_getCursorPosition(retptr, this.__wbg_ptr, addHeapObject(obj), addHeapObject(cursor), isLikeNone(heads) ? 0 : addHeapObject(heads));\n var r0 = getFloat64Memory0()[retptr / 8 + 0];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n var r3 = getInt32Memory0()[retptr / 4 + 3];\n if (r3) {\n throw takeObject(r2);\n }\n return r0;\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {string | undefined} [message]\n * @param {number | undefined} [time]\n * @returns {any}\n */\n emptyChange(message, time) {\n var ptr0 = isLikeNone(message) ? 0 : passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len0 = WASM_VECTOR_LEN;\n const ret = wasm.automerge_emptyChange(this.__wbg_ptr, ptr0, len0, !isLikeNone(time), isLikeNone(time) ? 0 : time);\n return takeObject(ret);\n }\n /**\n * @param {any} obj\n * @param {any} range\n * @param {any} name\n * @param {any} value\n * @param {any} datatype\n */\n mark(obj, range, name, value, datatype) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_mark(retptr, this.__wbg_ptr, addHeapObject(obj), addHeapObject(range), addHeapObject(name), addHeapObject(value), addHeapObject(datatype));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {any} range\n * @param {any} name\n */\n unmark(obj, range, name) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_unmark(retptr, this.__wbg_ptr, addHeapObject(obj), addHeapObject(range), addHeapObject(name));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {Array<any> | undefined} [heads]\n * @returns {any}\n */\n marks(obj, heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_marks(retptr, this.__wbg_ptr, addHeapObject(obj), isLikeNone(heads) ? 0 : addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {number} index\n * @param {Array<any> | undefined} [heads]\n * @returns {object}\n */\n marksAt(obj, index, heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_marksAt(retptr, this.__wbg_ptr, addHeapObject(obj), index, isLikeNone(heads) ? 0 : addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {SyncState} state\n * @returns {any}\n */\n hasOurChanges(state) {\n _assertClass(state, SyncState);\n const ret = wasm.automerge_hasOurChanges(this.__wbg_ptr, state.__wbg_ptr);\n return takeObject(ret);\n }\n /**\n * @returns {any}\n */\n topoHistoryTraversal() {\n const ret = wasm.automerge_topoHistoryTraversal(this.__wbg_ptr);\n return takeObject(ret);\n }\n /**\n * @returns {any}\n */\n stats() {\n const ret = wasm.automerge_stats(this.__wbg_ptr);\n return takeObject(ret);\n }\n}\n\nconst SyncStateFinalization = (typeof FinalizationRegistry === 'undefined')\n ? { register: () => {}, unregister: () => {} }\n : new FinalizationRegistry(ptr => wasm.__wbg_syncstate_free(ptr >>> 0));\n/**\n*/\nexport class SyncState {\n\n static __wrap(ptr) {\n ptr = ptr >>> 0;\n const obj = Object.create(SyncState.prototype);\n obj.__wbg_ptr = ptr;\n SyncStateFinalization.register(obj, obj.__wbg_ptr, obj);\n return obj;\n }\n\n __destroy_into_raw() {\n const ptr = this.__wbg_ptr;\n this.__wbg_ptr = 0;\n SyncStateFinalization.unregister(this);\n return ptr;\n }\n\n free() {\n const ptr = this.__destroy_into_raw();\n wasm.__wbg_syncstate_free(ptr);\n }\n /**\n * @returns {any}\n */\n get sharedHeads() {\n const ret = wasm.syncstate_sharedHeads(this.__wbg_ptr);\n return takeObject(ret);\n }\n /**\n * @returns {any}\n */\n get lastSentHeads() {\n const ret = wasm.syncstate_lastSentHeads(this.__wbg_ptr);\n return takeObject(ret);\n }\n /**\n * @param {any} heads\n */\n set lastSentHeads(heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.syncstate_set_lastSentHeads(retptr, this.__wbg_ptr, addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} hashes\n */\n set sentHashes(hashes) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.syncstate_set_sentHashes(retptr, this.__wbg_ptr, addHeapObject(hashes));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @returns {SyncState}\n */\n clone() {\n const ret = wasm.syncstate_clone(this.__wbg_ptr);\n return SyncState.__wrap(ret);\n }\n}\n\nasync function __wbg_load(module, imports) {\n if (typeof Response === 'function' && module instanceof Response) {\n if (typeof WebAssembly.instantiateStreaming === 'function') {\n try {\n return await WebAssembly.instantiateStreaming(module, imports);\n\n } catch (e) {\n if (module.headers.get('Content-Type') != 'application/wasm') {\n 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\", e);\n\n } else {\n throw e;\n }\n }\n }\n\n const bytes = await module.arrayBuffer();\n return await WebAssembly.instantiate(bytes, imports);\n\n } else {\n const instance = await WebAssembly.instantiate(module, imports);\n\n if (instance instanceof WebAssembly.Instance) {\n return { instance, module };\n\n } else {\n return instance;\n }\n }\n}\n\nfunction __wbg_get_imports() {\n const imports = {};\n imports.wbg = {};\n imports.wbg.__wbindgen_object_drop_ref = function(arg0) {\n takeObject(arg0);\n };\n imports.wbg.__wbindgen_string_get = function(arg0, arg1) {\n const obj = getObject(arg1);\n const ret = typeof(obj) === 'string' ? obj : undefined;\n var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len1 = WASM_VECTOR_LEN;\n getInt32Memory0()[arg0 / 4 + 1] = len1;\n getInt32Memory0()[arg0 / 4 + 0] = ptr1;\n };\n imports.wbg.__wbindgen_error_new = function(arg0, arg1) {\n const ret = new Error(getStringFromWasm0(arg0, arg1));\n return addHeapObject(ret);\n };\n imports.wbg.__wbindgen_string_new = function(arg0, arg1) {\n const ret = getStringFromWasm0(arg0, arg1);\n return addHeapObject(ret);\n };\n imports.wbg.__wbindgen_number_new = function(arg0) {\n const ret = arg0;\n return addHeapObject(ret);\n };\n imports.wbg.__wbindgen_object_clone_ref = function(arg0) {\n const ret = getObject(arg0);\n return addHeapObject(ret);\n };\n imports.wbg.__wbindgen_number_get = function(arg0, arg1) {\n const obj = getObject(arg1);\n const ret = typeof(obj) === 'number' ? obj : undefined;\n getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;\n getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);\n };\n imports.wbg.__wbindgen_is_undefined = function(arg0) {\n const ret = getObject(arg0) === undefined;\n return ret;\n };\n imports.wbg.__wbindgen_boolean_get = function(arg0) {\n const v = getObject(arg0);\n const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;\n return ret;\n };\n imports.wbg.__wbindgen_is_null = function(arg0) {\n const ret = getObject(arg0) === null;\n return ret;\n };\n imports.wbg.__wbindgen_is_string = function(arg0) {\n const ret = typeof(getObject(arg0)) === 'string';\n return ret;\n };\n imports.wbg.__wbindgen_is_function = function(arg0) {\n const ret = typeof(getObject(arg0)) === 'function';\n return ret;\n };\n imports.wbg.__wbindgen_is_object = function(arg0) {\n const val = getObject(arg0);\n const ret = typeof(val) === 'object' && val !== null;\n return ret;\n };\n imports.wbg.__wbindgen_is_array = function(arg0) {\n const ret = Array.isArray(getObject(arg0));\n return ret;\n };\n imports.wbg.__wbindgen_json_serialize = function(arg0, arg1) {\n const obj = getObject(arg1);\n const ret = JSON.stringify(obj === undefined ? null : obj);\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n getInt32Memory0()[arg0 / 4 + 1] = len1;\n getInt32Memory0()[arg0 / 4 + 0] = ptr1;\n };\n imports.wbg.__wbg_new_abda76e883ba8a5f = function() {\n const ret = new Error();\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {\n const ret = getObject(arg1).stack;\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n getInt32Memory0()[arg0 / 4 + 1] = len1;\n getInt32Memory0()[arg0 / 4 + 0] = ptr1;\n };\n imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {\n let deferred0_0;\n let deferred0_1;\n try {\n deferred0_0 = arg0;\n deferred0_1 = arg1;\n console.error(getStringFromWasm0(arg0, arg1));\n } finally {\n wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);\n }\n };\n imports.wbg.__wbindgen_jsval_loose_eq = function(arg0, arg1) {\n const ret = getObject(arg0) == getObject(arg1);\n return ret;\n };\n imports.wbg.__wbg_String_91fba7ded13ba54c = function(arg0, arg1) {\n const ret = String(getObject(arg1));\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n getInt32Memory0()[arg0 / 4 + 1] = len1;\n getInt32Memory0()[arg0 / 4 + 0] = ptr1;\n };\n imports.wbg.__wbindgen_bigint_from_i64 = function(arg0) {\n const ret = arg0;\n return addHeapObject(ret);\n };\n imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {\n const ret = BigInt.asUintN(64, arg0);\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_set_20cbc34131e76824 = function(arg0, arg1, arg2) {\n getObject(arg0)[takeObject(arg1)] = takeObject(arg2);\n };\n imports.wbg.__wbg_getRandomValues_3aa56aa6edec874c = function() { return handleError(function (arg0, arg1) {\n getObject(arg0).getRandomValues(getObject(arg1));\n }, arguments) };\n imports.wbg.__wbg_randomFillSync_5c9c955aa56b6049 = function() { return handleError(function (arg0, arg1) {\n getObject(arg0).randomFillSync(takeObject(arg1));\n }, arguments) };\n imports.wbg.__wbg_crypto_1d1f22824a6a080c = function(arg0) {\n const ret = getObject(arg0).crypto;\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_process_4a72847cc503995b = function(arg0) {\n const ret = getObject(arg0).process;\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_versions_f686565e586dd935 = function(arg0) {\n const ret = getObject(arg0).versions;\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_node_104a2ff8d6ea03a2 = function(arg0) {\n const ret = getObject(arg0).node;\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_require_cca90b1a94a0255b = function() { return handleError(function () {\n const ret = module.require;\n return addHeapObject(ret);\n }, arguments) };\n imports.wbg.__wbg_msCrypto_eb05e62b530a1508 = function(arg0) {\n const ret = getObject(arg0).msCrypto;\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_log_5bb5f88f245d7762 = function(arg0) {\n console.log(getObject(arg0));\n };\n imports.wbg.__wbg_log_1746d5c75ec89963 = function(arg0, arg1) {\n console.log(getObject(arg0), getObject(arg1));\n };\n imports.wbg.__wbg_get_bd8e338fbd5f5cc8 = function(arg0, arg1) {\n const ret = getObject(arg0)[arg1 >>> 0];\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_length_cd7af8117672b8b8 = function(arg0) {\n const ret = getObject(arg0).length;\n return ret;\n };\n imports.wbg.__wbg_new_16b304a2cfa7ff4a = function() {\n const ret = new Array();\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_newnoargs_e258087cd0daa0ea = function(arg0, arg1) {\n const ret = new Function(getStringFromWasm0(arg0, arg1));\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_next_40fc327bfc8770e6 = function(arg0) {\n const ret = getObject(arg0).next;\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_next_196c84450b364254 = function() { return handleError(function (arg0) {\n const ret = getObject(arg0).next();\n return addHeapObject(ret);\n }, arguments) };\n imports.wbg.__wbg_done_298b57d23c0fc80c = function(arg0) {\n const ret = getObject(arg0).done;\n return ret;\n };\n imports.wbg.__wbg_value_d93c65011f51a456 = function(arg0) {\n const ret = getObject(arg0).value;\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_iterator_2cee6dadfd956dfa = function() {\n const ret = Symbol.iterator;\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_get_e3c254076557e348 = function() { return handleError(function (arg0, arg1) {\n const ret = Reflect.get(getObject(arg0), getObject(arg1));\n return addHeapObject(ret);\n }, arguments) };\n imports.wbg.__wbg_call_27c0f87801dedf93 = function() { return handleError(function (arg0, arg1) {\n const ret = getObject(arg0).call(getObject(arg1));\n return addHeapObject(ret);\n }, arguments) };\n imports.wbg.__wbg_new_72fb9a18b5ae2624 = function() {\n const ret = new Object();\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_length_dee433d4c85c9387 = function(arg0) {\n const ret = getObject(arg0).length;\n return ret;\n };\n imports.wbg.__wbg_set_d4638f722068f043 = function(arg0, arg1, arg2) {\n getObject(arg0)[arg1 >>> 0] = takeObject(arg2);\n };\n imports.wbg.__wbg_from_89e3fc3ba5e6fb48 = function(arg0) {\n const ret = Array.from(getObject(arg0));\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_isArray_2ab64d95e09ea0ae = function(arg0) {\n const ret = Array.isArray(getObject(arg0));\n return ret;\n };\n imports.wbg.__wbg_push_a5b05aedc7234f9f = function(arg0, arg1) {\n const ret = getObject(arg0).push(getObject(arg1));\n return ret;\n };\n imports.wbg.__wbg_unshift_e22df4b34bcf5070 = function(arg0, arg1) {\n const ret = getObject(arg0).unshift(getObject(arg1));\n return ret;\n };\n imports.wbg.__wbg_instanceof_ArrayBuffer_836825be07d4c9d2 = function(arg0) {\n let result;\n try {\n result = getObject(arg0) instanceof ArrayBuffer;\n } catch (_) {\n result = false;\n }\n const ret = result;\n return ret;\n };\n imports.wbg.__wbg_new_28c511d9baebfa89 = function(arg0, arg1) {\n const ret = new Error(getStringFromWasm0(arg0, arg1));\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_call_b3ca7c6051f9bec1 = function() { return handleError(function (arg0, arg1, arg2) {\n const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));\n return addHeapObject(ret);\n }, arguments) };\n imports.wbg.__wbg_instanceof_Date_f65cf97fb83fc369 = function(arg0) {\n let result;\n try {\n result = getObject(arg0) instanceof Date;\n } catch (_) {\n result = false;\n }\n const ret = result;\n return ret;\n };\n imports.wbg.__wbg_getTime_2bc4375165f02d15 = function(arg0) {\n const ret = getObject(arg0).getTime();\n return ret;\n };\n imports.wbg.__wbg_new_cf3ec55744a78578 = function(arg0) {\n const ret = new Date(getObject(arg0));\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_instanceof_Object_71ca3c0a59266746 = function(arg0) {\n let result;\n try {\n result = getObject(arg0) instanceof Object;\n } catch (_) {\n result = false;\n }\n const ret = result;\n return ret;\n };\n imports.wbg.__wbg_assign_496d2d14fecafbcf = function(arg0, arg1) {\n const ret = Object.assign(getObject(arg0), getObject(arg1));\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_defineProperty_cc00e2de8a0f5141 = function(arg0, arg1, arg2) {\n const ret = Object.defineProperty(getObject(arg0), getObject(arg1), getObject(arg2));\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_entries_95cc2c823b285a09 = function(arg0) {\n const ret = Object.entries(getObject(arg0));\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_freeze_cc6bc19f75299986 = function(arg0) {\n const ret = Object.freeze(getObject(arg0));\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_keys_91e412b4b222659f = function(arg0) {\n const ret = Object.keys(getObject(arg0));\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_values_9c75e6e2bfbdb70d = function(arg0) {\n const ret = Object.values(getObject(arg0));\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_new_dd6a5dd7b538af21 = function(arg0, arg1) {\n const ret = new RangeError(getStringFromWasm0(arg0, arg1));\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_apply_0a5aa603881e6d79 = function() { return handleError(function (arg0, arg1, arg2) {\n const ret = Reflect.apply(getObject(arg0), getObject(arg1), getObject(arg2));\n return addHeapObject(ret);\n }, arguments) };\n imports.wbg.__wbg_deleteProperty_13e721a56f19e842 = function() { return handleError(function (arg0, arg1) {\n const ret = Reflect.deleteProperty(getObject(arg0), getObject(arg1));\n return ret;\n }, arguments) };\n imports.wbg.__wbg_ownKeys_658942b7f28d1fe9 = function() { return handleError(function (arg0) {\n const ret = Reflect.ownKeys(getObject(arg0));\n return addHeapObject(ret);\n }, arguments) };\n imports.wbg.__wbg_set_1f9b04f170055d33 = function() { return handleError(function (arg0, arg1, arg2) {\n const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));\n return ret;\n }, arguments) };\n imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) {\n const ret = getObject(arg0).buffer;\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_concat_3de229fe4fe90fea = function(arg0, arg1) {\n const ret = getObject(arg0).concat(getObject(arg1));\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_slice_52fb626ffdc8da8f = function(arg0, arg1, arg2) {\n const ret = getObject(arg0).slice(arg1 >>> 0, arg2 >>> 0);\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_for_27c67e2dbdce22f6 = function(arg0, arg1) {\n const ret = Symbol.for(getStringFromWasm0(arg0, arg1));\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_toString_7df3c77999517c20 = function(arg0) {\n const ret = getObject(arg0).toString();\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_self_ce0dbfc45cf2f5be = function() { return handleError(function () {\n const ret = self.self;\n return addHeapObject(ret);\n }, arguments) };\n imports.wbg.__wbg_window_c6fb939a7f436783 = function() { return handleError(function () {\n const ret = window.window;\n return addHeapObject(ret);\n }, arguments) };\n imports.wbg.__wbg_globalThis_d1e6af4856ba331b = function() { return handleError(function () {\n const ret = globalThis.globalThis;\n return addHeapObject(ret);\n }, arguments) };\n imports.wbg.__wbg_global_207b558942527489 = function() { return handleError(function () {\n const ret = global.global;\n return addHeapObject(ret);\n }, arguments) };\n imports.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function(arg0, arg1, arg2) {\n const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_new_63b92bc8671ed464 = function(arg0) {\n const ret = new Uint8Array(getObject(arg0));\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) {\n getObject(arg0).set(getObject(arg1), arg2 >>> 0);\n };\n imports.wbg.__wbg_length_c20a40f15020d68a = function(arg0) {\n const ret = getObject(arg0).length;\n return ret;\n };\n imports.wbg.__wbg_instanceof_Uint8Array_2b3bbecd033d19f6 = function(arg0) {\n let result;\n try {\n result = getObject(arg0) instanceof Uint8Array;\n } catch (_) {\n result = false;\n }\n const ret = result;\n return ret;\n };\n imports.wbg.__wbg_newwithlength_e9b4878cebadb3d3 = function(arg0) {\n const ret = new Uint8Array(arg0 >>> 0);\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_subarray_a1f73cd4b5b42fe1 = function(arg0, arg1, arg2) {\n const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);\n return addHeapObject(ret);\n };\n imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {\n const ret = debugString(getObject(arg1));\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n getInt32Memory0()[arg0 / 4 + 1] = len1;\n getInt32Memory0()[arg0 / 4 + 0] = ptr1;\n };\n imports.wbg.__wbindgen_throw = function(arg0, arg1) {\n throw new Error(getStringFromWasm0(arg0, arg1));\n };\n imports.wbg.__wbindgen_memory = function() {\n const ret = wasm.memory;\n return addHeapObject(ret);\n };\n\n return imports;\n}\n\nfunction __wbg_init_memory(imports, maybe_memory) {\n\n}\n\nfunction __wbg_finalize_init(instance, module) {\n wasm = instance.exports;\n __wbg_init.__wbindgen_wasm_module = module;\n cachedFloat64Memory0 = null;\n cachedInt32Memory0 = null;\n cachedUint8Memory0 = null;\n\n\n return wasm;\n}\n\nfunction initSync(module) {\n if (wasm !== undefined) return wasm;\n\n const imports = __wbg_get_imports();\n\n __wbg_init_memory(imports);\n\n if (!(module instanceof WebAssembly.Module)) {\n module = new WebAssembly.Module(module);\n }\n\n const instance = new WebAssembly.Instance(module, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nasync function __wbg_init(input) {\n if (wasm !== undefined) return wasm;\n\n if (typeof input === 'undefined') {\n input = new URL('automerge_wasm_bg.wasm', import.meta.url);\n }\n const imports = __wbg_get_imports();\n\n if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {\n input = fetch(input);\n }\n\n __wbg_init_memory(imports);\n\n const { instance, module } = await __wbg_load(await input, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nexport { initSync }\nexport default __wbg_init;\n","import { default as initWasm } from \"./wasm_bindgen_output/web/automerge_wasm.js\";\nimport * as WasmApi from \"./wasm_bindgen_output/web/automerge_wasm.js\";\nlet _initialized = false;\nlet _initializeListeners = [];\nexport function UseApi(api) {\n for (const k in api) {\n // eslint-disable-next-line @typescript-eslint/no-extra-semi,@typescript-eslint/no-explicit-any\n ;\n ApiHandler[k] = api[k];\n }\n _initialized = true;\n for (const listener of _initializeListeners) {\n listener();\n }\n}\n/* eslint-disable */\nexport const ApiHandler = {\n create(options) {\n throw new RangeError(\"Automerge.use() not called\");\n },\n load(data, options) {\n throw new RangeError(\"Automerge.use() not called (load)\");\n },\n encodeChange(change) {\n throw new RangeError(\"Automerge.use() not called (encodeChange)\");\n },\n decodeChange(change) {\n throw new RangeError(\"Automerge.use() not called (decodeChange)\");\n },\n initSyncState() {\n throw new RangeError(\"Automerge.use() not called (initSyncState)\");\n },\n encodeSyncMessage(message) {\n throw new RangeError(\"Automerge.use() not called (encodeSyncMessage)\");\n },\n decodeSyncMessage(msg) {\n throw new RangeError(\"Automerge.use() not called (decodeSyncMessage)\");\n },\n encodeSyncState(state) {\n throw new RangeError(\"Automerge.use() not called (encodeSyncState)\");\n },\n decodeSyncState(data) {\n throw new RangeError(\"Automerge.use() not called (decodeSyncState)\");\n },\n exportSyncState(state) {\n throw new RangeError(\"Automerge.use() not called (exportSyncState)\");\n },\n importSyncState(state) {\n throw new RangeError(\"Automerge.use() not called (importSyncState)\");\n },\n};\n/* eslint-enable */\n/**\n * Initialize the wasm module\n *\n * @param wasmBlob - The wasm module as a Uint8Array, Request, Promise<Uint8Array> or string. If this argument is a string then it is assumed to be a URL and the library will attempt to fetch the wasm module from that URL.\n *\n * @remarks\n * If you are using the `/slim` subpath export then this function must be\n * called before any other functions in the library. If you are using any of\n * the other subpath exports then it will have already been called for you.\n */\nexport function initializeWasm(wasmBlob) {\n return initWasm(wasmBlob).then(_ => {\n UseApi(WasmApi);\n });\n}\n/**\n * Initialize the wasm module from a base64 encoded string\n *\n * @param wasmBase64 - The bytes of the wasm file as a base64 encoded string\n */\nexport function initializeBase64Wasm(wasmBase64) {\n return initializeWasm(Uint8Array.from(atob(wasmBase64), c => c.charCodeAt(0)));\n}\n/**\n * A promise which resolves when the web assembly module has been initialized\n * (or immediately if it has already been initialized)\n */\nexport function wasmInitialized() {\n if (_initialized)\n return Promise.resolve();\n return new Promise(resolve => {\n _initializeListeners.push(resolve);\n });\n}\n/**\n * Check if the wasm module has been initialized\n *\n * @returns true if the wasm module has been initialized\n */\nexport function isWasmInitialized() {\n return _initialized;\n}\n","import { CLEAR_CACHE, IS_PROXY, OBJECT_ID, STATE, TRACE } from \"./constants.js\";\nexport function _state(doc, checkroot = true) {\n if (typeof doc !== \"object\") {\n throw new RangeError(\"must be the document root\");\n }\n const state = Reflect.get(doc, STATE);\n if (state === undefined ||\n state == null ||\n (checkroot && _obj(doc) !== \"_root\")) {\n throw new RangeError(\"must be the document root\");\n }\n return state;\n}\nexport function _clear_cache(doc) {\n Reflect.set(doc, CLEAR_CACHE, true);\n}\nexport function _trace(doc) {\n return Reflect.get(doc, TRACE);\n}\nexport function _obj(doc) {\n if (!(typeof doc === \"object\") || doc === null) {\n return null;\n }\n return Reflect.get(doc, OBJECT_ID);\n}\nexport function _is_proxy(doc) {\n return !!Reflect.get(doc, IS_PROXY);\n}\n","var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n};\n/** @hidden **/\nexport { /** @hidden */ uuid } from \"./uuid.js\";\nimport { rootProxy } from \"./proxies.js\";\nimport { STATE } from \"./constants.js\";\nimport { Counter, } from \"./types.js\";\nexport { Counter, Int, Uint, Float64, } from \"./types.js\";\nimport { Text } from \"./text.js\";\nexport { Text } from \"./text.js\";\nconst SyncStateSymbol = Symbol(\"_syncstate\");\nimport { ApiHandler, UseApi } from \"./low_level.js\";\nexport { initializeWasm, initializeBase64Wasm, wasmInitialized, isWasmInitialized, } from \"./low_level.js\";\nimport { RawString } from \"./raw_string.js\";\nimport { _state, _is_proxy, _trace, _obj } from \"./internal_state.js\";\nimport { stableConflictAt } from \"./conflicts.js\";\n/**\n * Function for use in {@link change} which inserts values into a list at a given index\n * @param list\n * @param index\n * @param values\n */\nexport function insertAt(list, index, ...values) {\n if (!_is_proxy(list)) {\n throw new RangeError(\"object cannot be modified outside of a change block\");\n }\n ;\n list.insertAt(index, ...values);\n}\n/**\n * Function for use in {@link change} which deletes values from a list at a given index\n * @param list\n * @param index\n * @param numDelete\n */\nexport function deleteAt(list, index, numDelete) {\n if (!_is_proxy(list)) {\n throw new RangeError(\"object cannot be modified outside of a change block\");\n }\n ;\n list.deleteAt(index, numDelete);\n}\n/** @hidden **/\nexport function use(api) {\n UseApi(api);\n}\n/** @hidden */\nexport function getBackend(doc) {\n return _state(doc).handle;\n}\nfunction importOpts(_actor) {\n if (typeof _actor === \"object\") {\n return _actor;\n }\n else {\n return { actor: _actor };\n }\n}\n/**\n * Create a new automerge document\n *\n * @typeParam T - The type of value contained in the document. This will be the\n * type that is passed to the change closure in {@link change}\n * @param _opts - Either an actorId or an {@link InitOptions} (which may\n * contain an actorId). If this is null the document will be initialised with a\n * random actor ID\n */\nexport function init(_opts) {\n const opts = importOpts(_opts);\n const freeze = !!opts.freeze;\n const patchCallback = opts.patchCallback;\n const text_v1 = !(opts.enableTextV2 || false);\n const actor = opts.actor;\n const handle = ApiHandler.create({ actor, text_v1 });\n handle.enableFreeze(!!opts.freeze);\n const textV2 = opts.enableTextV2 || false;\n registerDatatypes(handle, textV2);\n const doc = handle.materialize(\"/\", undefined, {\n handle,\n heads: undefined,\n freeze,\n patchCallback,\n textV2,\n });\n return doc;\n}\n/**\n * Make an immutable view of an automerge document as at `heads`\n *\n * @remarks\n * The document returned from this function cannot be passed to {@link change}.\n * This is because it shares the same underlying memory as `doc`, but it is\n * consequently a very cheap copy.\n *\n * Note that this function will throw an error if any of the hashes in `heads`\n * are not in the document.\n *\n * @typeParam T - The type of the value contained in the document\n * @param doc - The document to create a view of\n * @param heads - The hashes of the heads to create a view at\n */\nexport function view(doc, heads) {\n const state = _state(doc);\n const handle = state.handle;\n return state.handle.materialize(\"/\", heads, Object.assign(Object.assign({}, state), { handle,\n heads }));\n}\n/**\n * Make a full writable copy of an automerge document\n *\n * @remarks\n * Unlike {@link view} this function makes a full copy of the memory backing\n * the document and can thus be passed to {@link change}. It also generates a\n * new actor ID so that changes made in the new document do not create duplicate\n * sequence numbers with respect to the old document. If you need control over\n * the actor ID which is generated you can pass the actor ID as the second\n * argument\n *\n * @typeParam T - The type of the value contained in the document\n * @param doc - The document to clone\n * @param _opts - Either an actor ID to use for the new doc or an {@link InitOptions}\n */\nexport function clone(doc, _opts) {\n const state = _state(doc);\n const heads = state.heads;\n const opts = importOpts(_opts);\n const handle = state.handle.fork(opts.actor, heads);\n handle.updateDiffCursor();\n // `change` uses the presence of state.heads to determine if we are in a view\n // set it to undefined to indicate that this is a full fat document\n const { heads: _oldHeads } = state, stateSansHeads = __rest(state, [\"heads\"]);\n stateSansHeads.patchCallback = opts.patchCallback;\n return handle.applyPatches(doc, Object.assign(Object.assign({}, stateSansHeads), { handle }));\n}\n/** Explicity free the memory backing a document. Note that this is note\n * necessary in environments which support\n * [`FinalizationRegistry`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry)\n */\nexport function free(doc) {\n return _state(doc).handle.free();\n}\n/**\n * Create an automerge document from a POJO\n *\n * @param initialState - The initial state which will be copied into the document\n * @typeParam T - The type of the value passed to `from` _and_ the type the resulting document will contain\n * @typeParam actor - The actor ID of the resulting document, if this is null a random actor ID will be used\n *\n * @example\n * ```\n * const doc = automerge.from({\n * tasks: [\n * {description: \"feed dogs\", done: false}\n * ]\n * })\n * ```\n */\nexport function from(initialState, _opts) {\n return _change(init(_opts), \"from\", {}, d => Object.assign(d, initialState))\n .newDoc;\n}\n/**\n * Update the contents of an automerge document\n * @typeParam T - The type of the value contained in the document\n * @param doc - The document to update\n * @param options - Either a message, an {@link ChangeOptions}, or a {@link ChangeFn}\n * @param callback - A `ChangeFn` to be used if `options` was a `string`\n *\n * Note that if the second argument is a function it will be used as the `ChangeFn` regardless of what the third argument is.\n *\n * @example A simple change\n * ```\n * let doc1 = automerge.init()\n * doc1 = automerge.change(doc1, d => {\n * d.key = \"value\"\n * })\n * assert.equal(doc1.key, \"value\")\n * ```\n *\n * @example A change with a message\n *\n * ```\n * doc1 = automerge.change(doc1, \"add another value\", d => {\n * d.key2 = \"value2\"\n * })\n * ```\n *\n * @example A change with a message and a timestamp\n *\n * ```\n * doc1 = automerge.change(doc1, {message: \"add another value\", time: 1640995200}, d => {\n * d.key2 = \"value2\"\n * })\n * ```\n *\n * @example responding to a patch callback\n * ```\n * let patchedPath\n * let patchCallback = patch => {\n * patchedPath = patch.path\n * }\n * doc1 = automerge.change(doc1, {message: \"add another value\", time: 1640995200, patchCallback}, d => {\n * d.key2 = \"value2\"\n * })\n * assert.equal(patchedPath, [\"key2\"])\n * ```\n */\nexport function change(doc, options, callback) {\n if (typeof options === \"function\") {\n return _change(doc, \"change\", {}, options).newDoc;\n }\n else if (typeof callback === \"function\") {\n if (typeof options === \"string\") {\n options = { message: options };\n }\n return _change(doc, \"change\", options, callback).newDoc;\n }\n else {\n throw RangeError(\"Invalid args for change\");\n }\n}\n/**\n * Make a change to the document as it was at a particular point in history\n * @typeParam T - The type of the value contained in the document\n * @param doc - The document to update\n * @param scope - The heads representing the point in history to make the change\n * @param options - Either a message or a {@link ChangeOptions} for the new change\n * @param callback - A `ChangeFn` to be used if `options` was a `string`\n *\n * @remarks\n * This function is similar to {@link change} but allows you to make changes to\n * the document as if it were at a particular point in time. To understand this\n * imagine a document created with the following history:\n *\n * ```ts\n * let doc = automerge.from({..})\n * doc = automerge.change(doc, () => {...})\n *\n * const heads = automerge.getHeads(doc)\n *\n * // fork the document make a change\n * let fork = automerge.fork(doc)\n * fork = automerge.change(fork, () => {...})\n * const headsOnFork = automerge.getHeads(fork)\n *\n * // make a change on the original doc\n * doc = automerge.change(doc, () => {...})\n * const headsOnOriginal = automerge.getHeads(doc)\n *\n * // now merge the changes back to the original document\n * doc = automerge.merge(doc, fork)\n *\n * // The heads of the document will now be (headsOnFork, headsOnOriginal)\n * ```\n *\n * {@link ChangeAt} produces an equivalent history, but without having to\n * create a fork of the document. In particular the `newHeads` field of the\n * returned {@link ChangeAtResult} will be the same as `headsOnFork`.\n *\n * Why would you want this? It's typically used in conjunction with {@link diff}\n * to reconcile state which is managed concurrently with the document. For\n * example, if you have a text editor component which the user is modifying\n * and you can't send the changes to the document synchronously you might follow\n * a workflow like this:\n *\n * * On initialization save the current heads of the document in the text editor state\n * * Every time the user makes a change record the change in the text editor state\n *\n * Now from time to time reconcile the editor state and the document\n * * Load the last saved heads from the text editor state, call them `oldHeads`\n * * Apply all the unreconciled changes to the document using `changeAt(doc, oldHeads, ...)`\n * * Get the diff from the resulting document to the current document using {@link diff}\n * passing the {@link ChangeAtResult.newHeads} as the `before` argument and the\n * heads of the entire document as the `after` argument.\n * * Apply the diff to the text editor state\n * * Save the current heads of the document in the text editor state\n */\nexport function changeAt(doc, scope, options, callback) {\n if (typeof options === \"function\") {\n return _change(doc, \"changeAt\", {}, options, scope);\n }\n else if (typeof callback === \"function\") {\n if (typeof options === \"string\") {\n options = { message: options };\n }\n return _change(doc, \"changeAt\", options, callback, scope);\n }\n else {\n throw RangeError(\"Invalid args for changeAt\");\n }\n}\nfunction progressDocument(doc, source, heads, callback) {\n if (heads == null) {\n return doc;\n }\n const state = _state(doc);\n const nextState = Object.assign(Object.assign({}, state), { heads: undefined });\n const { value: nextDoc, patches } = state.handle.applyAndReturnPatches(doc, nextState);\n if (patches.length > 0) {\n if (callback != null) {\n callback(patches, { before: doc, after: nextDoc, source });\n }\n const newState = _state(nextDoc);\n newState.mostRecentPatch = {\n before: _state(doc).heads,\n after: newState.handle.getHeads(),\n patches,\n };\n }\n state.heads = heads;\n return nextDoc;\n}\nfunction _change(doc, source, options, callback, scope) {\n if (typeof callback !== \"function\") {\n throw new RangeError(\"invalid change function\");\n }\n const state = _state(doc);\n if (doc === undefined || state === undefined) {\n throw new RangeError(\"must be the document root\");\n }\n if (state.heads) {\n throw new RangeError(\"Attempting to change an outdated document. Use Automerge.clone() if you wish to make a writable copy.\");\n }\n if (_is_proxy(doc)) {\n throw new RangeError(\"Calls to Automerge.change cannot be nested\");\n }\n let heads = state.handle.getHeads();\n if (scope && headsEqual(scope, heads)) {\n scope = undefined;\n }\n if (scope) {\n state.handle.isolate(scope);\n heads = scope;\n }\n if (!(\"time\" in options)) {\n options.time = Math.floor(Date.now() / 1000);\n }\n try {\n state.heads = heads;\n const root = rootProxy(state.handle, state.textV2);\n callback(root);\n if (state.handle.pendingOps() === 0) {\n state.heads = undefined;\n if (scope) {\n state.handle.integrate();\n }\n return {\n newDoc: doc,\n newHeads: null,\n };\n }\n else {\n const newHead = state.handle.commit(options.message, options.time);\n state.handle.integrate();\n return {\n newDoc: progressDocument(doc, source, heads, options.patchCallback || state.patchCallback),\n newHeads: newHead != null ? [newHead] : null,\n };\n }\n }\n catch (e) {\n state.heads = undefined;\n state.handle.rollback();\n throw e;\n }\n}\n/**\n * Make a change to a document which does not modify the document\n *\n * @param doc - The doc to add the empty change to\n * @param options - Either a message or a {@link ChangeOptions} for the new change\n *\n * Why would you want to do this? One reason might be that you have merged\n * changes from some other peers and you want to generate a change which\n * depends on those merged changes so that you can sign the new change with all\n * of the merged changes as part of the new change.\n */\nexport function emptyChange(doc, options) {\n if (options === undefined) {\n options = {};\n }\n if (typeof options === \"string\") {\n options = { message: options };\n }\n if (!(\"time\" in options)) {\n options.time = Math.floor(Date.now() / 1000);\n }\n const state = _state(doc);\n if (state.heads) {\n throw new RangeError(\"Attempting to change an outdated document. Use Automerge.clone() if you wish to make a writable copy.\");\n }\n if (_is_proxy(doc)) {\n throw new RangeError(\"Calls to Automerge.change cannot be nested\");\n }\n const heads = state.handle.getHeads();\n state.handle.emptyChange(options.message, options.time);\n return progressDocument(doc, \"emptyChange\", heads);\n}\n/**\n * Load an automerge document from a compressed document produce by {@link save}\n *\n * @typeParam T - The type of the value which is contained in the document.\n * Note that no validation is done to make sure this type is in\n * fact the type of the contained value so be a bit careful\n * @param data - The compressed document\n * @param _opts - Either an actor ID or some {@link InitOptions}, if the actor\n * ID is null a random actor ID will be created\n *\n * Note that `load` will throw an error if passed incomplete content (for\n * example if you are receiving content over the network and don't know if you\n * have the complete document yet). If you need to handle incomplete content use\n * {@link init} followed by {@link loadIncremental}.\n */\nexport function load(data, _opts) {\n const opts = importOpts(_opts);\n const actor = opts.actor;\n const patchCallback = opts.patchCallback;\n const text_v1 = !(opts.enableTextV2 || false);\n const unchecked = opts.unchecked || false;\n const allowMissingDeps = opts.allowMissingChanges || false;\n const convertRawStringsToText = opts.convertRawStringsToText || false;\n const handle = ApiHandler.load(data, {\n text_v1,\n actor,\n unchecked,\n allowMissingDeps,\n convertRawStringsToText,\n });\n handle.enableFreeze(!!opts.freeze);\n const textV2 = opts.enableTextV2 || false;\n registerDatatypes(handle, textV2);\n const doc = handle.materialize(\"/\", undefined, {\n handle,\n heads: undefined,\n patchCallback,\n textV2,\n });\n return doc;\n}\n/**\n * Load changes produced by {@link saveIncremental}, or partial changes\n *\n * @typeParam T - The type of the value which is contained in the document.\n * Note that no validation is done to make sure this type is in\n * fact the type of the contained value so be a bit careful\n * @param data - The compressedchanges\n * @param opts - an {@link ApplyOptions}\n *\n * This function is useful when staying up to date with a connected peer.\n * Perhaps the other end sent you a full compresed document which you loaded\n * with {@link load} and they're sending you the result of\n * {@link getLastLocalChange} every time they make a change.\n *\n * Note that this function will succesfully load the results of {@link save} as\n * well as {@link getLastLocalChange} or any other incremental change.\n */\nexport function loadIncremental(doc, data, opts) {\n if (!opts) {\n opts = {};\n }\n const state = _state(doc);\n if (state.heads) {\n throw new RangeError(\"Attempting to change an out of date document - set at: \" + _trace(doc));\n }\n if (_is_proxy(doc)) {\n throw new RangeError(\"Calls to Automerge.change cannot be nested\");\n }\n const heads = state.handle.getHeads();\n state.handle.loadIncremental(data);\n return progressDocument(doc, \"loadIncremental\", heads, opts.patchCallback || state.patchCallback);\n}\n/**\n * Create binary save data to be appended to a save file or fed into {@link loadIncremental}\n *\n * @typeParam T - The type of the value which is contained in the document.\n * Note that no validation is done to make sure this type is in\n * fact the type of the contained value so be a bit careful\n *\n * This function is useful for incrementally saving state. The data can be appended to a\n * automerge save file, or passed to a document replicating its state.\n *\n */\nexport function saveIncremental(doc) {\n const state = _state(doc);\n if (state.heads) {\n throw new RangeError(\"Attempting to change an out of date document - set at: \" + _trace(doc));\n }\n if (_is_proxy(doc)) {\n throw new RangeError(\"Calls to Automerge.change cannot be nested\");\n }\n return state.handle.saveIncremental();\n}\n/**\n * Export the contents of a document to a compressed format\n *\n * @param doc - The doc to save\n *\n * The returned bytes can be passed to {@link load} or {@link loadIncremental}\n */\nexport function save(doc) {\n return _state(doc).handle.save();\n}\n/**\n * Merge `remote` into `local`\n * @typeParam T - The type of values contained in each document\n * @param local - The document to merge changes into\n * @param remote - The document to merge changes from\n *\n * @returns - The merged document\n *\n * Often when you are merging documents you will also need to clone them. Both\n * arguments to `merge` are frozen after the call so you can no longer call\n * mutating methods (such as {@link change}) on them. The symtom of this will be\n * an error which says \"Attempting to change an out of date document\". To\n * overcome this call {@link clone} on the argument before passing it to {@link\n * merge}.\n */\nexport function merge(local, remote) {\n const localState = _state(local);\n if (localState.heads) {\n throw new RangeError(\"Attempting to change an out of date document - set at: \" + _trace(local));\n }\n const heads = localState.handle.getHeads();\n const remoteState = _state(remote);\n const changes = localState.handle.getChangesAdded(remoteState.handle);\n localState.handle.applyChanges(changes);\n return progressDocument(local, \"merge\", heads, localState.patchCallback);\n}\n/**\n * Get the actor ID associated with the document\n */\nexport function getActorId(doc) {\n const state = _state(doc);\n return state.handle.getActorId();\n}\n/**\n * Get the conflicts associated with a property\n *\n * The values of properties in a map in automerge can be conflicted if there\n * are concurrent \"put\" operations to the same key. Automerge chooses one value\n * arbitrarily (but deterministically, any two nodes who have the same set of\n * changes will choose the same value) from the set of conflicting values to\n * present as the value of the key.\n *\n * Sometimes you may want to examine these conflicts, in this case you can use\n * {@link getConflicts} to get the conflicts for the key.\n *\n * @example\n * ```\n * import * as automerge from \"@automerge/automerge\"\n *\n * type Profile = {\n * pets: Array<{name: string, type: string}>\n * }\n *\n * let doc1 = automerge.init<Profile>(\"aaaa\")\n * doc1 = automerge.change(doc1, d => {\n * d.pets = [{name: \"Lassie\", type: \"dog\"}]\n * })\n * let doc2 = automerge.init<Profile>(\"bbbb\")\n * doc2 = automerge.merge(doc2, automerge.clone(doc1))\n *\n * doc2 = automerge.change(doc2, d => {\n * d.pets[0].name = \"Beethoven\"\n * })\n *\n * doc1 = automerge.change(doc1, d => {\n * d.pets[0].name = \"Babe\"\n * })\n *\n * const doc3 = automerge.merge(doc1, doc2)\n *\n * // Note that here we pass `doc3.pets`, not `doc3`\n * let conflicts = automerge.getConflicts(doc3.pets[0], \"name\")\n *\n * // The two conflicting values are the keys of the conflicts object\n * assert.deepEqual(Object.values(conflicts), [\"Babe\", Beethoven\"])\n * ```\n */\nexport function getConflicts(doc, prop) {\n const state = _state(doc, false);\n if (state.textV2) {\n throw new Error(\"use unstable.getConflicts for an unstable document\");\n }\n const objectId = _obj(doc);\n if (objectId != null) {\n return stableConflictAt(state.handle, objectId, prop);\n }\n else {\n return undefined;\n }\n}\n/**\n * Get the binary representation of the last change which was made to this doc\n *\n * This is most useful when staying in sync with other peers, every time you\n * make a change locally via {@link change} you immediately call {@link\n * getLastLocalChange} and send the result over the network to other peers.\n */\nexport function getLastLocalChange(doc) {\n const state = _state(doc);\n return state.handle.getLastLocalChange() || undefined;\n}\n/**\n * Return the object ID of an arbitrary javascript value\n *\n * This is useful to determine if something is actually an automerge document,\n * if `doc` is not an automerge document this will return null.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getObjectId(doc, prop) {\n if (prop) {\n const state = _state(doc, false);\n const objectId = _obj(doc);\n if (!state || !objectId) {\n return null;\n }\n return state.handle.get(objectId, prop);\n }\n else {\n return _obj(doc);\n }\n}\n/**\n * Get the changes which are in `newState` but not in `oldState`. The returned\n * changes can be loaded in `oldState` via {@link applyChanges}.\n *\n * Note that this will crash if there are changes in `oldState` which are not in `newState`.\n */\nexport function getChanges(oldState, newState) {\n const n = _state(newState);\n return n.handle.getChanges(getHeads(oldState));\n}\n/**\n * Get all the changes in a document\n *\n * This is different to {@link save} because the output is an array of changes\n * which can be individually applied via {@link applyChanges}`\n *\n */\nexport function getAllChanges(doc) {\n const state = _state(doc);\n return state.handle.getChanges([]);\n}\n/**\n * Apply changes received from another document\n *\n * `doc` will be updated to reflect the `changes`. If there are changes which\n * we do not have dependencies for yet those will be stored in the document and\n * applied when the depended on changes arrive.\n *\n * You can use the {@link ApplyOptions} to pass a patchcallback which will be\n * informed of any changes which occur as a result of applying the changes\n *\n */\nexport function applyChanges(doc, changes, opts) {\n const state = _state(doc);\n if (!opts) {\n opts = {};\n }\n if (state.heads) {\n throw new RangeError(\"Attempting to change an outdated document. Use Automerge.clone() if you wish to make a writable copy.\");\n }\n if (_is_proxy(doc)) {\n throw new RangeError(\"Calls to Automerge.change cannot be nested\");\n }\n const heads = state.handle.getHeads();\n state.handle.applyChanges(changes);\n state.heads = heads;\n return [\n progressDocument(doc, \"applyChanges\", heads, opts.patchCallback || state.patchCallback),\n ];\n}\n/** @hidden */\nexport function getHistory(doc) {\n const textV2 = _state(doc).textV2;\n const history = getAllChanges(doc);\n return history.map((change, index) => ({\n get change() {\n return decodeChange(change);\n },\n get snapshot() {\n const [state] = applyChanges(init({ enableTextV2: textV2 }), history.slice(0, index + 1));\n return state;\n },\n }));\n}\n/**\n * Create a set of patches representing the change from one set of heads to another\n *\n * If either of the heads are missing from the document the returned set of patches will be empty\n */\nexport function diff(doc, before, after) {\n checkHeads(before, \"before\");\n checkHeads(after, \"after\");\n const state = _state(doc);\n if (state.mostRecentPatch &&\n equals(state.mostRecentPatch.before, before) &&\n equals(state.mostRecentPatch.after, after)) {\n return state.mostRecentPatch.patches;\n }\n return state.handle.diff(before, after);\n}\nfunction headsEqual(heads1, heads2) {\n if (heads1.length !== heads2.length) {\n return false;\n }\n for (let i = 0; i < heads1.length; i++) {\n if (heads1[i] !== heads2[i]) {\n return false;\n }\n }\n return true;\n}\nfunction checkHeads(heads, fieldname) {\n if (!Array.isArray(heads)) {\n throw new Error(`${fieldname} must be an array`);\n }\n}\n/** @hidden */\n// FIXME : no tests\n// FIXME can we just use deep equals now?\nexport function equals(val1, val2) {\n if (!isObject(val1) || !isObject(val2))\n return val1 === val2;\n const keys1 = Object.keys(val1).sort(), keys2 = Object.keys(val2).sort();\n if (keys1.length !== keys2.length)\n return false;\n for (let i = 0; i < keys1.length; i++) {\n if (keys1[i] !== keys2[i])\n return false;\n if (!equals(val1[keys1[i]], val2[keys2[i]]))\n return false;\n }\n return true;\n}\n/**\n * encode a {@link SyncState} into binary to send over the network\n *\n * @group sync\n * */\nexport function encodeSyncState(state) {\n const sync = ApiHandler.importSyncState(state);\n const result = ApiHandler.encodeSyncState(sync);\n sync.free();\n return result;\n}\n/**\n * Decode some binary data into a {@link SyncState}\n *\n * @group sync\n */\nexport function decodeSyncState(state) {\n const sync = ApiHandler.decodeSyncState(state);\n const result = ApiHandler.exportSyncState(sync);\n sync.free();\n return result;\n}\n/**\n * Generate a sync message to send to the peer represented by `inState`\n * @param doc - The doc to generate messages about\n * @param inState - The {@link SyncState} representing the peer we are talking to\n *\n * @group sync\n *\n * @returns An array of `[newSyncState, syncMessage | null]` where\n * `newSyncState` should replace `inState` and `syncMessage` should be sent to\n * the peer if it is not null. If `syncMessage` is null then we are up to date.\n */\nexport function generateSyncMessage(doc, inState) {\n const state = _state(doc);\n const syncState = ApiHandler.importSyncState(inState);\n const message = state.handle.generateSyncMessage(syncState);\n const outState = ApiHandler.exportSyncState(syncState);\n return [outState, message];\n}\n/**\n * Update a document and our sync state on receiving a sync message\n *\n * @group sync\n *\n * @param doc - The doc the sync message is about\n * @param inState - The {@link SyncState} for the peer we are communicating with\n * @param message - The message which was received\n * @param opts - Any {@link ApplyOption}s, used for passing a\n * {@link PatchCallback} which will be informed of any changes\n * in `doc` which occur because of the received sync message.\n *\n * @returns An array of `[newDoc, newSyncState, syncMessage | null]` where\n * `newDoc` is the updated state of `doc`, `newSyncState` should replace\n * `inState` and `syncMessage` should be sent to the peer if it is not null. If\n * `syncMessage` is null then we are up to date.\n */\nexport function receiveSyncMessage(doc, inState, message, opts) {\n const syncState = ApiHandler.importSyncState(inState);\n if (!opts) {\n opts = {};\n }\n const state = _state(doc);\n if (state.heads) {\n throw new RangeError(\"Attempting to change an outdated document. Use Automerge.clone() if you wish to make a writable copy.\");\n }\n if (_is_proxy(doc)) {\n throw new RangeError(\"Calls to Automerge.change cannot be nested\");\n }\n const heads = state.handle.getHeads();\n state.handle.receiveSyncMessage(syncState, message);\n const outSyncState = ApiHandler.exportSyncState(syncState);\n return [\n progressDocument(doc, \"receiveSyncMessage\", heads, opts.patchCallback || state.patchCallback),\n outSyncState,\n null,\n ];\n}\n/**\n * Check whether the replica represented by `remoteState` has all our changes\n *\n * @param doc - The doc to check whether the remote has changes for\n * @param remoteState - The {@link SyncState} representing the peer we are talking to\n *\n * @group sync\n *\n * @returns true if the remote has all of our changes\n */\nexport function hasOurChanges(doc, remoteState) {\n const state = _state(doc);\n const syncState = ApiHandler.importSyncState(remoteState);\n return state.handle.hasOurChanges(syncState);\n}\n/**\n * Create a new, blank {@link SyncState}\n *\n * When communicating with a peer for the first time use this to generate a new\n * {@link SyncState} for them\n *\n * @group sync\n */\nexport function initSyncState() {\n return ApiHandler.exportSyncState(ApiHandler.initSyncState());\n}\n/** @hidden */\nexport function encodeChange(change) {\n return ApiHandler.encodeChange(change);\n}\n/** @hidden */\nexport function decodeChange(data) {\n return ApiHandler.decodeChange(data);\n}\n/** @hidden */\nexport function encodeSyncMessage(message) {\n return ApiHandler.encodeSyncMessage(message);\n}\n/** @hidden */\nexport function decodeSyncMessage(message) {\n return ApiHandler.decodeSyncMessage(message);\n}\n/**\n * Get any changes in `doc` which are not dependencies of `heads`\n */\nexport function getMissingDeps(doc, heads) {\n const state = _state(doc);\n return state.handle.getMissingDeps(heads);\n}\n/**\n * Get the hashes of the heads of this document\n */\nexport function getHeads(doc) {\n const state = _state(doc);\n return state.heads || state.handle.getHeads();\n}\n/** @hidden */\nexport function dump(doc) {\n const state = _state(doc);\n state.handle.dump();\n}\n/** @hidden */\nexport function toJS(doc) {\n const state = _state(doc);\n const enabled = state.handle.enableFreeze(false);\n const result = state.handle.materialize();\n state.handle.enableFreeze(enabled);\n return result;\n}\nexport function isAutomerge(doc) {\n if (typeof doc == \"object\" && doc !== null) {\n return getObjectId(doc) === \"_root\" && !!Reflect.get(doc, STATE);\n }\n else {\n return false;\n }\n}\nfunction isObject(obj) {\n return typeof obj === \"object\" && obj !== null;\n}\nexport function saveSince(doc, heads) {\n const state = _state(doc);\n const result = state.handle.saveSince(heads);\n return result;\n}\n/**\n * Returns true if the document has all of the given heads somewhere in its history\n */\nexport function hasHeads(doc, heads) {\n const state = _state(doc);\n for (const hash of heads) {\n if (!state.handle.getChangeByHash(hash)) {\n return false;\n }\n }\n return true;\n}\nfunction registerDatatypes(handle, textV2) {\n handle.registerDatatype(\"counter\", (n) => new Counter(n), n => {\n if (n instanceof Counter) {\n return n.value;\n }\n });\n if (textV2) {\n handle.registerDatatype(\"str\", (n) => {\n return new RawString(n);\n }, s => {\n if (s instanceof RawString) {\n return s.val;\n }\n });\n }\n else {\n handle.registerDatatype(\"text\", (n) => new Text(n), t => {\n if (t instanceof Text) {\n return t.join(\"\");\n }\n });\n }\n}\n/**\n * @hidden\n */\nexport function topoHistoryTraversal(doc) {\n const state = _state(doc);\n return state.handle.topoHistoryTraversal();\n}\n/**\n * Decode a change hash into the details of this change\n *\n * This should be considered a semi-stable API. We try not to change the\n * encoding in backwards incompatible ways but we won't bump a major version if\n * we do have to change it\n */\nexport function inspectChange(doc, changeHash) {\n const state = _state(doc);\n return state.handle.getDecodedChangeByHash(changeHash);\n}\n/**\n * Return some internal statistics about the document\n */\nexport function stats(doc) {\n const state = _state(doc);\n return state.handle.stats();\n}\n","/**\n * # The next API\n *\n * This module contains new features we are working on which are backwards\n * incompatible with the current API of Automerge. This module will become the\n * API of the next major version of Automerge\n *\n * ## Differences from stable\n *\n * In the stable API text objects are represented using the {@link Text} class.\n * This means you must decide up front whether your string data might need\n * concurrent merges in the future and if you change your mind you have to\n * figure out how to migrate your data. In the unstable API the `Text` class is\n * gone and all `string`s are represented using the text CRDT, allowing for\n * concurrent changes. Modifying a string is done using the {@link splice}\n * function. You can still access the old behaviour of strings which do not\n * support merging behaviour via the {@link RawString} class.\n *\n * This leads to the following differences from `stable`:\n *\n * * There is no `unstable.Text` class, all strings are text objects\n * * Reading strings in an `unstable` document is the same as reading any other\n * javascript string\n * * To modify strings in an `unstable` document use {@link splice}\n * * The {@link AutomergeValue} type does not include the {@link Text}\n * class but the {@link RawString} class is included in the {@link ScalarValue}\n * type\n *\n * ## CHANGELOG\n * * Rename this module to `next` to reflect our increased confidence in it\n * and stability commitment to it\n * * Introduce this module to expose the new API which has no `Text` class\n *\n *\n * @module\n */\nexport { Counter, Int, Uint, Float64, } from \"./next_types.js\";\nimport { unstableConflictAt } from \"./conflicts.js\";\nexport { view, free, getHeads, change, changeAt, emptyChange, loadIncremental, saveIncremental, save, merge, getActorId, getLastLocalChange, getChanges, getAllChanges, applyChanges, getHistory, equals, encodeSyncState, decodeSyncState, generateSyncMessage, receiveSyncMessage, hasOurChanges, initSyncState, encodeChange, decodeChange, encodeSyncMessage, decodeSyncMessage, getMissingDeps, dump, toJS, isAutomerge, getObjectId, diff, insertAt, deleteAt, saveSince, initializeWasm, initializeBase64Wasm, wasmInitialized, isWasmInitialized, hasHeads, topoHistoryTraversal, inspectChange, stats, } from \"./stable.js\";\nimport * as stable from \"./stable.js\";\nexport { RawString } from \"./raw_string.js\";\n/** @hidden */\nexport const getBackend = stable.getBackend;\nimport { _is_proxy, _state, _obj, _clear_cache } from \"./internal_state.js\";\n/**\n * Create a new automerge document\n *\n * @typeParam T - The type of value contained in the document. This will be the\n * type that is passed to the change closure in {@link change}\n * @param _opts - Either an actorId or an {@link InitOptions} (which may\n * contain an actorId). If this is null the document will be initialised with a\n * random actor ID\n */\nexport function init(_opts) {\n const opts = importOpts(_opts);\n opts.enableTextV2 = true;\n return stable.init(opts);\n}\n/**\n * Make a full writable copy of an automerge document\n *\n * @remarks\n * Unlike {@link view} this function makes a full copy of the memory backing\n * the document and can thus be passed to {@link change}. It also generates a\n * new actor ID so that changes made in the new document do not create duplicate\n * sequence numbers with respect to the old document. If you need control over\n * the actor ID which is generated you can pass the actor ID as the second\n * argument\n *\n * @typeParam T - The type of the value contained in the document\n * @param doc - The document to clone\n * @param _opts - Either an actor ID to use for the new doc or an {@link InitOptions}\n */\nexport function clone(doc, _opts) {\n const opts = importOpts(_opts);\n opts.enableTextV2 = true;\n return stable.clone(doc, opts);\n}\n/**\n * Create an automerge document from a POJO\n *\n * @param initialState - The initial state which will be copied into the document\n * @typeParam T - The type of the value passed to `from` _and_ the type the resulting document will contain\n * @typeParam actor - The actor ID of the resulting document, if this is null a random actor ID will be used\n *\n * @example\n * ```\n * const doc = automerge.from({\n * tasks: [\n * {description: \"feed dogs\", done: false}\n * ]\n * })\n * ```\n */\nexport function from(initialState, _opts) {\n const opts = importOpts(_opts);\n opts.enableTextV2 = true;\n return stable.from(initialState, opts);\n}\n/**\n * Load an automerge document from a compressed document produce by {@link save}\n *\n * @typeParam T - The type of the value which is contained in the document.\n * Note that no validation is done to make sure this type is in\n * fact the type of the contained value so be a bit careful\n * @param data - The compressed document\n * @param _opts - Either an actor ID or some {@link InitOptions}, if the actor\n * ID is null a random actor ID will be created\n *\n * Note that `load` will throw an error if passed incomplete content (for\n * example if you are receiving content over the network and don't know if you\n * have the complete document yet). If you need to handle incomplete content use\n * {@link init} followed by {@link loadIncremental}.\n */\nexport function load(data, _opts) {\n const opts = importOpts(_opts);\n opts.enableTextV2 = true;\n if (opts.patchCallback) {\n return stable.loadIncremental(stable.init(opts), data);\n }\n else {\n return stable.load(data, opts);\n }\n}\nfunction importOpts(_actor) {\n if (typeof _actor === \"object\") {\n return _actor;\n }\n else {\n return { actor: _actor };\n }\n}\nfunction cursorToIndex(state, value, index) {\n if (typeof index == \"string\") {\n if (/^[0-9]+@[0-9a-zA-z]+$/.test(index)) {\n return state.handle.getCursorPosition(value, index);\n }\n else {\n throw new RangeError(\"index must be a number or cursor\");\n }\n }\n else {\n return index;\n }\n}\n/**\n * Modify a string\n *\n * @typeParam T - The type of the value contained in the document\n * @param doc - The document to modify\n * @param path - The path to the string to modify\n * @param index - The position (as a {@link Cursor} or index) to edit.\n * If a cursor is used then the edit happens such that the cursor will\n * now point to the end of the newText, so you can continue to reuse\n * the same cursor for multiple calls to splice.\n * @param del - The number of code units to delete, a positive number\n * deletes N characters after the cursor, a negative number deletes\n * N characters before the cursor.\n * @param newText - The string to insert (if any).\n */\nexport function splice(doc, path, index, del, newText) {\n const objPath = absoluteObjPath(doc, path, \"splice\");\n if (!_is_proxy(doc)) {\n throw new RangeError(\"object cannot be modified outside of a change block\");\n }\n const state = _state(doc, false);\n _clear_cache(doc);\n index = cursorToIndex(state, objPath, index);\n try {\n return state.handle.splice(objPath, index, del, newText);\n }\n catch (e) {\n throw new RangeError(`Cannot splice: ${e}`);\n }\n}\n/**\n * Update the value of a string\n *\n * @typeParam T - The type of the value contained in the document\n * @param doc - The document to modify\n * @param path - The path to the string to modify\n * @param newText - The new text to update the value to\n *\n * @remarks\n * This will calculate a diff between the current value and the new value and\n * then convert that diff into calls to {@link splice}. This will produce results\n * which don't merge as well as directly capturing the user input actions, but\n * sometimes it's not possible to capture user input and this is the best you\n * can do.\n *\n * This is an experimental API and may change in the future.\n *\n * @beta\n */\nexport function updateText(doc, path, newText) {\n const objPath = absoluteObjPath(doc, path, \"updateText\");\n if (!_is_proxy(doc)) {\n throw new RangeError(\"object cannot be modified outside of a change block\");\n }\n const state = _state(doc, false);\n _clear_cache(doc);\n try {\n return state.handle.updateText(objPath, newText);\n }\n catch (e) {\n throw new RangeError(`Cannot updateText: ${e}`);\n }\n}\n/**\n * Return the text + block markers at a given path\n *\n * @remarks\n * Rich text in automerge is represented as a sequence of characters with block\n * markers appearing inline with the text, and inline formatting spans overlaid\n * on the whole sequence. Block markers are normal automerge maps, but they are\n * only visible via either the {@link block} function or the {@link spans}\n * function. This function returns the current state of the spans\n */\nexport function spans(doc, path) {\n const state = _state(doc, false);\n const objPath = absoluteObjPath(doc, path, \"spans\");\n try {\n return state.handle.spans(objPath, state.heads);\n }\n catch (e) {\n throw new RangeError(`Cannot splice: ${e}`);\n }\n}\n/**\n * Get the block marker at the given index\n */\nexport function block(doc, path, index) {\n const objPath = absoluteObjPath(doc, path, \"splitBlock\");\n const state = _state(doc, false);\n index = cursorToIndex(state, objPath, index);\n try {\n return state.handle.getBlock(objPath, index);\n }\n catch (e) {\n throw new RangeError(`Cannot get block: ${e}`);\n }\n}\n/**\n * Insert a new block marker at the given index\n */\nexport function splitBlock(doc, path, index, block) {\n if (!_is_proxy(doc)) {\n throw new RangeError(\"object cannot be modified outside of a change block\");\n }\n const objPath = absoluteObjPath(doc, path, \"splitBlock\");\n const state = _state(doc, false);\n _clear_cache(doc);\n index = cursorToIndex(state, objPath, index);\n try {\n state.handle.splitBlock(objPath, index, block);\n }\n catch (e) {\n throw new RangeError(`Cannot splice: ${e}`);\n }\n}\n/**\n * Delete the block marker at the given index\n */\nexport function joinBlock(doc, path, index) {\n if (!_is_proxy(doc)) {\n throw new RangeError(\"object cannot be modified outside of a change block\");\n }\n const objPath = absoluteObjPath(doc, path, \"joinBlock\");\n const state = _state(doc, false);\n _clear_cache(doc);\n index = cursorToIndex(state, objPath, index);\n try {\n state.handle.joinBlock(objPath, index);\n }\n catch (e) {\n throw new RangeError(`Cannot joinBlock: ${e}`);\n }\n}\n/**\n * Update the block marker at the given index\n */\nexport function updateBlock(doc, path, index, block) {\n if (!_is_proxy(doc)) {\n throw new RangeError(\"object cannot be modified outside of a change block\");\n }\n const objPath = absoluteObjPath(doc, path, \"updateBlock\");\n const state = _state(doc, false);\n _clear_cache(doc);\n index = cursorToIndex(state, objPath, index);\n try {\n state.handle.updateBlock(objPath, index, block);\n }\n catch (e) {\n throw new RangeError(`Cannot updateBlock: ${e}`);\n }\n}\n/**\n * Update the spans at the given path\n *\n * @remarks\n * Like {@link updateText} this will diff `newSpans` against the current state\n * of the text at `path` and perform a reasonably minimal number of operations\n * required to update the spans to the new state.\n */\nexport function updateSpans(doc, path, newSpans) {\n if (!_is_proxy(doc)) {\n throw new RangeError(\"object cannot be modified outside of a change block\");\n }\n const objPath = absoluteObjPath(doc, path, \"updateSpans\");\n const state = _state(doc, false);\n _clear_cache(doc);\n try {\n state.handle.updateSpans(objPath, newSpans);\n }\n catch (e) {\n throw new RangeError(`Cannot updateBlock: ${e}`);\n }\n}\n/**\n * Returns a cursor for the given position in a string.\n *\n * @remarks\n * A cursor represents a relative position, \"before character X\",\n * rather than an absolute position. As the document is edited, the\n * cursor remains stable relative to its context, just as you'd expect\n * from a cursor in a concurrent text editor.\n *\n * The string representation is shareable, and so you can use this both\n * to edit the document yourself (using {@link splice}) or to share multiple\n * collaborator's current cursor positions over the network.\n *\n * @typeParam T - The type of the value contained in the document\n * @param doc - The document\n * @param path - The path to the string\n * @param index - The current index of the position of the cursor\n */\nexport function getCursor(doc, path, index) {\n const objPath = absoluteObjPath(doc, path, \"getCursor\");\n const state = _state(doc, false);\n try {\n return state.handle.getCursor(objPath, index);\n }\n catch (e) {\n throw new RangeError(`Cannot getCursor: ${e}`);\n }\n}\n/**\n * Returns the current index of the cursor.\n *\n * @typeParam T - The type of the value contained in the document\n *\n * @param doc - The document\n * @param path - The path to the string\n * @param index - The cursor\n */\nexport function getCursorPosition(doc, path, cursor) {\n const objPath = absoluteObjPath(doc, path, \"getCursorPosition\");\n const state = _state(doc, false);\n try {\n return state.handle.getCursorPosition(objPath, cursor);\n }\n catch (e) {\n throw new RangeError(`Cannot getCursorPosition: ${e}`);\n }\n}\nexport function mark(doc, path, range, name, value) {\n const objPath = absoluteObjPath(doc, path, \"mark\");\n if (!_is_proxy(doc)) {\n throw new RangeError(\"object cannot be modified outside of a change block\");\n }\n const state = _state(doc, false);\n try {\n return state.handle.mark(objPath, range, name, value);\n }\n catch (e) {\n throw new RangeError(`Cannot mark: ${e}`);\n }\n}\nexport function unmark(doc, path, range, name) {\n const objPath = absoluteObjPath(doc, path, \"unmark\");\n if (!_is_proxy(doc)) {\n throw new RangeError(\"object cannot be modified outside of a change block\");\n }\n const state = _state(doc, false);\n try {\n return state.handle.unmark(objPath, range, name);\n }\n catch (e) {\n throw new RangeError(`Cannot unmark: ${e}`);\n }\n}\nexport function marks(doc, path) {\n const objPath = absoluteObjPath(doc, path, \"marks\");\n const state = _state(doc, false);\n try {\n return state.handle.marks(objPath);\n }\n catch (e) {\n throw new RangeError(`Cannot call marks(): ${e}`);\n }\n}\nexport function marksAt(doc, path, index) {\n const objPath = absoluteObjPath(doc, path, \"marksAt\");\n const state = _state(doc, false);\n try {\n return state.handle.marksAt(objPath, index);\n }\n catch (e) {\n throw new RangeError(`Cannot call marksAt(): ${e}`);\n }\n}\n/**\n * Get the conflicts associated with a property\n *\n * The values of properties in a map in automerge can be conflicted if there\n * are concurrent \"put\" operations to the same key. Automerge chooses one value\n * arbitrarily (but deterministically, any two nodes who have the same set of\n * changes will choose the same value) from the set of conflicting values to\n * present as the value of the key.\n *\n * Sometimes you may want to examine these conflicts, in this case you can use\n * {@link getConflicts} to get the conflicts for the key.\n *\n * @example\n * ```\n * import * as automerge from \"@automerge/automerge\"\n *\n * type Profile = {\n * pets: Array<{name: string, type: string}>\n * }\n *\n * let doc1 = automerge.init<Profile>(\"aaaa\")\n * doc1 = automerge.change(doc1, d => {\n * d.pets = [{name: \"Lassie\", type: \"dog\"}]\n * })\n * let doc2 = automerge.init<Profile>(\"bbbb\")\n * doc2 = automerge.merge(doc2, automerge.clone(doc1))\n *\n * doc2 = automerge.change(doc2, d => {\n * d.pets[0].name = \"Beethoven\"\n * })\n *\n * doc1 = automerge.change(doc1, d => {\n * d.pets[0].name = \"Babe\"\n * })\n *\n * const doc3 = automerge.merge(doc1, doc2)\n *\n * // Note that here we pass `doc3.pets`, not `doc3`\n * let conflicts = automerge.getConflicts(doc3.pets[0], \"name\")\n *\n * // The two conflicting values are the keys of the conflicts object\n * assert.deepEqual(Object.values(conflicts), [\"Babe\", \"Beethoven\"])\n * ```\n */\nexport function getConflicts(doc, prop) {\n const state = _state(doc, false);\n if (!state.textV2) {\n throw new Error(\"use getConflicts for a stable document\");\n }\n const objectId = _obj(doc);\n if (objectId != null) {\n return unstableConflictAt(state.handle, objectId, prop);\n }\n else {\n return undefined;\n }\n}\nfunction absoluteObjPath(doc, path, functionName) {\n path = path.slice();\n const objectId = _obj(doc);\n if (!objectId) {\n throw new RangeError(`invalid object for ${functionName}`);\n }\n path.unshift(objectId);\n return path.join(\"/\");\n}\n","/**\n * Helpers.\n */\n\nvar s = 1000;\nvar m = s * 60;\nvar h = m * 60;\nvar d = h * 24;\nvar w = d * 7;\nvar y = d * 365.25;\n\n/**\n * Parse or format the given `val`.\n *\n * Options:\n *\n * - `long` verbose formatting [false]\n *\n * @param {String|Number} val\n * @param {Object} [options]\n * @throws {Error} throw an error if val is not a non-empty string or a number\n * @return {String|Number}\n * @api public\n */\n\nmodule.exports = function (val, options) {\n options = options || {};\n var type = typeof val;\n if (type === 'string' && val.length > 0) {\n return parse(val);\n } else if (type === 'number' && isFinite(val)) {\n return options.long ? fmtLong(val) : fmtShort(val);\n }\n throw new Error(\n 'val is not a non-empty string or a valid number. val=' +\n JSON.stringify(val)\n );\n};\n\n/**\n * Parse the given `str` and return milliseconds.\n *\n * @param {String} str\n * @return {Number}\n * @api private\n */\n\nfunction parse(str) {\n str = String(str);\n if (str.length > 100) {\n return;\n }\n var match = /^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(\n str\n );\n if (!match) {\n return;\n }\n var n = parseFloat(match[1]);\n var type = (match[2] || 'ms').toLowerCase();\n switch (type) {\n case 'years':\n case 'year':\n case 'yrs':\n case 'yr':\n case 'y':\n return n * y;\n case 'weeks':\n case 'week':\n case 'w':\n return n * w;\n case 'days':\n case 'day':\n case 'd':\n return n * d;\n case 'hours':\n case 'hour':\n case 'hrs':\n case 'hr':\n case 'h':\n return n * h;\n case 'minutes':\n case 'minute':\n case 'mins':\n case 'min':\n case 'm':\n return n * m;\n case 'seconds':\n case 'second':\n case 'secs':\n case 'sec':\n case 's':\n return n * s;\n case 'milliseconds':\n case 'millisecond':\n case 'msecs':\n case 'msec':\n case 'ms':\n return n;\n default:\n return undefined;\n }\n}\n\n/**\n * Short format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtShort(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return Math.round(ms / d) + 'd';\n }\n if (msAbs >= h) {\n return Math.round(ms / h) + 'h';\n }\n if (msAbs >= m) {\n return Math.round(ms / m) + 'm';\n }\n if (msAbs >= s) {\n return Math.round(ms / s) + 's';\n }\n return ms + 'ms';\n}\n\n/**\n * Long format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtLong(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return plural(ms, msAbs, d, 'day');\n }\n if (msAbs >= h) {\n return plural(ms, msAbs, h, 'hour');\n }\n if (msAbs >= m) {\n return plural(ms, msAbs, m, 'minute');\n }\n if (msAbs >= s) {\n return plural(ms, msAbs, s, 'second');\n }\n return ms + ' ms';\n}\n\n/**\n * Pluralization helper.\n */\n\nfunction plural(ms, msAbs, n, name) {\n var isPlural = msAbs >= n * 1.5;\n return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');\n}\n","\n/**\n * This is the common logic for both the Node.js and web browser\n * implementations of `debug()`.\n */\n\nfunction setup(env) {\n\tcreateDebug.debug = createDebug;\n\tcreateDebug.default = createDebug;\n\tcreateDebug.coerce = coerce;\n\tcreateDebug.disable = disable;\n\tcreateDebug.enable = enable;\n\tcreateDebug.enabled = enabled;\n\tcreateDebug.humanize = require('ms');\n\tcreateDebug.destroy = destroy;\n\n\tObject.keys(env).forEach(key => {\n\t\tcreateDebug[key] = env[key];\n\t});\n\n\t/**\n\t* The currently active debug mode names, and names to skip.\n\t*/\n\n\tcreateDebug.names = [];\n\tcreateDebug.skips = [];\n\n\t/**\n\t* Map of special \"%n\" handling functions, for the debug \"format\" argument.\n\t*\n\t* Valid key names are a single, lower or upper-case letter, i.e. \"n\" and \"N\".\n\t*/\n\tcreateDebug.formatters = {};\n\n\t/**\n\t* Selects a color for a debug namespace\n\t* @param {String} namespace The namespace string for the debug instance to be colored\n\t* @return {Number|String} An ANSI color code for the given namespace\n\t* @api private\n\t*/\n\tfunction selectColor(namespace) {\n\t\tlet hash = 0;\n\n\t\tfor (let i = 0; i < namespace.length; i++) {\n\t\t\thash = ((hash << 5) - hash) + namespace.charCodeAt(i);\n\t\t\thash |= 0; // Convert to 32bit integer\n\t\t}\n\n\t\treturn createDebug.colors[Math.abs(hash) % createDebug.colors.length];\n\t}\n\tcreateDebug.selectColor = selectColor;\n\n\t/**\n\t* Create a debugger with the given `namespace`.\n\t*\n\t* @param {String} namespace\n\t* @return {Function}\n\t* @api public\n\t*/\n\tfunction createDebug(namespace) {\n\t\tlet prevTime;\n\t\tlet enableOverride = null;\n\t\tlet namespacesCache;\n\t\tlet enabledCache;\n\n\t\tfunction debug(...args) {\n\t\t\t// Disabled?\n\t\t\tif (!debug.enabled) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst self = debug;\n\n\t\t\t// Set `diff` timestamp\n\t\t\tconst curr = Number(new Date());\n\t\t\tconst ms = curr - (prevTime || curr);\n\t\t\tself.diff = ms;\n\t\t\tself.prev = prevTime;\n\t\t\tself.curr = curr;\n\t\t\tprevTime = curr;\n\n\t\t\targs[0] = createDebug.coerce(args[0]);\n\n\t\t\tif (typeof args[0] !== 'string') {\n\t\t\t\t// Anything else let's inspect with %O\n\t\t\t\targs.unshift('%O');\n\t\t\t}\n\n\t\t\t// Apply any `formatters` transformations\n\t\t\tlet index = 0;\n\t\t\targs[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {\n\t\t\t\t// If we encounter an escaped % then don't increase the array index\n\t\t\t\tif (match === '%%') {\n\t\t\t\t\treturn '%';\n\t\t\t\t}\n\t\t\t\tindex++;\n\t\t\t\tconst formatter = createDebug.formatters[format];\n\t\t\t\tif (typeof formatter === 'function') {\n\t\t\t\t\tconst val = args[index];\n\t\t\t\t\tmatch = formatter.call(self, val);\n\n\t\t\t\t\t// Now we need to remove `args[index]` since it's inlined in the `format`\n\t\t\t\t\targs.splice(index, 1);\n\t\t\t\t\tindex--;\n\t\t\t\t}\n\t\t\t\treturn match;\n\t\t\t});\n\n\t\t\t// Apply env-specific formatting (colors, etc.)\n\t\t\tcreateDebug.formatArgs.call(self, args);\n\n\t\t\tconst logFn = self.log || createDebug.log;\n\t\t\tlogFn.apply(self, args);\n\t\t}\n\n\t\tdebug.namespace = namespace;\n\t\tdebug.useColors = createDebug.useColors();\n\t\tdebug.color = createDebug.selectColor(namespace);\n\t\tdebug.extend = extend;\n\t\tdebug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.\n\n\t\tObject.defineProperty(debug, 'enabled', {\n\t\t\tenumerable: true,\n\t\t\tconfigurable: false,\n\t\t\tget: () => {\n\t\t\t\tif (enableOverride !== null) {\n\t\t\t\t\treturn enableOverride;\n\t\t\t\t}\n\t\t\t\tif (namespacesCache !== createDebug.namespaces) {\n\t\t\t\t\tnamespacesCache = createDebug.namespaces;\n\t\t\t\t\tenabledCache = createDebug.enabled(namespace);\n\t\t\t\t}\n\n\t\t\t\treturn enabledCache;\n\t\t\t},\n\t\t\tset: v => {\n\t\t\t\tenableOverride = v;\n\t\t\t}\n\t\t});\n\n\t\t// Env-specific initialization logic for debug instances\n\t\tif (typeof createDebug.init === 'function') {\n\t\t\tcreateDebug.init(debug);\n\t\t}\n\n\t\treturn debug;\n\t}\n\n\tfunction extend(namespace, delimiter) {\n\t\tconst newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);\n\t\tnewDebug.log = this.log;\n\t\treturn newDebug;\n\t}\n\n\t/**\n\t* Enables a debug mode by namespaces. This can include modes\n\t* separated by a colon and wildcards.\n\t*\n\t* @param {String} namespaces\n\t* @api public\n\t*/\n\tfunction enable(namespaces) {\n\t\tcreateDebug.save(namespaces);\n\t\tcreateDebug.namespaces = namespaces;\n\n\t\tcreateDebug.names = [];\n\t\tcreateDebug.skips = [];\n\n\t\tlet i;\n\t\tconst split = (typeof namespaces === 'string' ? namespaces : '').split(/[\\s,]+/);\n\t\tconst len = split.length;\n\n\t\tfor (i = 0; i < len; i++) {\n\t\t\tif (!split[i]) {\n\t\t\t\t// ignore empty strings\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tnamespaces = split[i].replace(/\\*/g, '.*?');\n\n\t\t\tif (namespaces[0] === '-') {\n\t\t\t\tcreateDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$'));\n\t\t\t} else {\n\t\t\t\tcreateDebug.names.push(new RegExp('^' + namespaces + '$'));\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t* Disable debug output.\n\t*\n\t* @return {String} namespaces\n\t* @api public\n\t*/\n\tfunction disable() {\n\t\tconst namespaces = [\n\t\t\t...createDebug.names.map(toNamespace),\n\t\t\t...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)\n\t\t].join(',');\n\t\tcreateDebug.enable('');\n\t\treturn namespaces;\n\t}\n\n\t/**\n\t* Returns true if the given mode name is enabled, false otherwise.\n\t*\n\t* @param {String} name\n\t* @return {Boolean}\n\t* @api public\n\t*/\n\tfunction enabled(name) {\n\t\tif (name[name.length - 1] === '*') {\n\t\t\treturn true;\n\t\t}\n\n\t\tlet i;\n\t\tlet len;\n\n\t\tfor (i = 0, len = createDebug.skips.length; i < len; i++) {\n\t\t\tif (createDebug.skips[i].test(name)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\tfor (i = 0, len = createDebug.names.length; i < len; i++) {\n\t\t\tif (createDebug.names[i].test(name)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t* Convert regexp to namespace\n\t*\n\t* @param {RegExp} regxep\n\t* @return {String} namespace\n\t* @api private\n\t*/\n\tfunction toNamespace(regexp) {\n\t\treturn regexp.toString()\n\t\t\t.substring(2, regexp.toString().length - 2)\n\t\t\t.replace(/\\.\\*\\?$/, '*');\n\t}\n\n\t/**\n\t* Coerce `val`.\n\t*\n\t* @param {Mixed} val\n\t* @return {Mixed}\n\t* @api private\n\t*/\n\tfunction coerce(val) {\n\t\tif (val instanceof Error) {\n\t\t\treturn val.stack || val.message;\n\t\t}\n\t\treturn val;\n\t}\n\n\t/**\n\t* XXX DO NOT USE. This is a temporary stub function.\n\t* XXX It WILL be removed in the next major release.\n\t*/\n\tfunction destroy() {\n\t\tconsole.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');\n\t}\n\n\tcreateDebug.enable(createDebug.load());\n\n\treturn createDebug;\n}\n\nmodule.exports = setup;\n","/* eslint-env browser */\n\n/**\n * This is the web browser implementation of `debug()`.\n */\n\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\nexports.storage = localstorage();\nexports.destroy = (() => {\n\tlet warned = false;\n\n\treturn () => {\n\t\tif (!warned) {\n\t\t\twarned = true;\n\t\t\tconsole.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');\n\t\t}\n\t};\n})();\n\n/**\n * Colors.\n */\n\nexports.colors = [\n\t'#0000CC',\n\t'#0000FF',\n\t'#0033CC',\n\t'#0033FF',\n\t'#0066CC',\n\t'#0066FF',\n\t'#0099CC',\n\t'#0099FF',\n\t'#00CC00',\n\t'#00CC33',\n\t'#00CC66',\n\t'#00CC99',\n\t'#00CCCC',\n\t'#00CCFF',\n\t'#3300CC',\n\t'#3300FF',\n\t'#3333CC',\n\t'#3333FF',\n\t'#3366CC',\n\t'#3366FF',\n\t'#3399CC',\n\t'#3399FF',\n\t'#33CC00',\n\t'#33CC33',\n\t'#33CC66',\n\t'#33CC99',\n\t'#33CCCC',\n\t'#33CCFF',\n\t'#6600CC',\n\t'#6600FF',\n\t'#6633CC',\n\t'#6633FF',\n\t'#66CC00',\n\t'#66CC33',\n\t'#9900CC',\n\t'#9900FF',\n\t'#9933CC',\n\t'#9933FF',\n\t'#99CC00',\n\t'#99CC33',\n\t'#CC0000',\n\t'#CC0033',\n\t'#CC0066',\n\t'#CC0099',\n\t'#CC00CC',\n\t'#CC00FF',\n\t'#CC3300',\n\t'#CC3333',\n\t'#CC3366',\n\t'#CC3399',\n\t'#CC33CC',\n\t'#CC33FF',\n\t'#CC6600',\n\t'#CC6633',\n\t'#CC9900',\n\t'#CC9933',\n\t'#CCCC00',\n\t'#CCCC33',\n\t'#FF0000',\n\t'#FF0033',\n\t'#FF0066',\n\t'#FF0099',\n\t'#FF00CC',\n\t'#FF00FF',\n\t'#FF3300',\n\t'#FF3333',\n\t'#FF3366',\n\t'#FF3399',\n\t'#FF33CC',\n\t'#FF33FF',\n\t'#FF6600',\n\t'#FF6633',\n\t'#FF9900',\n\t'#FF9933',\n\t'#FFCC00',\n\t'#FFCC33'\n];\n\n/**\n * Currently only WebKit-based Web Inspectors, Firefox >= v31,\n * and the Firebug extension (any Firefox version) are known\n * to support \"%c\" CSS customizations.\n *\n * TODO: add a `localStorage` variable to explicitly enable/disable colors\n */\n\n// eslint-disable-next-line complexity\nfunction useColors() {\n\t// NB: In an Electron preload script, document will be defined but not fully\n\t// initialized. Since we know we're in Chrome, we'll just detect this case\n\t// explicitly\n\tif (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {\n\t\treturn true;\n\t}\n\n\t// Internet Explorer and Edge do not support colors.\n\tif (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/)) {\n\t\treturn false;\n\t}\n\n\tlet m;\n\n\t// Is webkit? http://stackoverflow.com/a/16459606/376773\n\t// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632\n\treturn (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||\n\t\t// Is firebug? http://stackoverflow.com/a/398120/376773\n\t\t(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||\n\t\t// Is firefox >= v31?\n\t\t// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages\n\t\t(typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)) && parseInt(m[1], 10) >= 31) ||\n\t\t// Double check webkit in userAgent just in case we are in a worker\n\t\t(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/));\n}\n\n/**\n * Colorize log arguments if enabled.\n *\n * @api public\n */\n\nfunction formatArgs(args) {\n\targs[0] = (this.useColors ? '%c' : '') +\n\t\tthis.namespace +\n\t\t(this.useColors ? ' %c' : ' ') +\n\t\targs[0] +\n\t\t(this.useColors ? '%c ' : ' ') +\n\t\t'+' + module.exports.humanize(this.diff);\n\n\tif (!this.useColors) {\n\t\treturn;\n\t}\n\n\tconst c = 'color: ' + this.color;\n\targs.splice(1, 0, c, 'color: inherit');\n\n\t// The final \"%c\" is somewhat tricky, because there could be other\n\t// arguments passed either before or after the %c, so we need to\n\t// figure out the correct index to insert the CSS into\n\tlet index = 0;\n\tlet lastC = 0;\n\targs[0].replace(/%[a-zA-Z%]/g, match => {\n\t\tif (match === '%%') {\n\t\t\treturn;\n\t\t}\n\t\tindex++;\n\t\tif (match === '%c') {\n\t\t\t// We only are interested in the *last* %c\n\t\t\t// (the user may have provided their own)\n\t\t\tlastC = index;\n\t\t}\n\t});\n\n\targs.splice(lastC, 0, c);\n}\n\n/**\n * Invokes `console.debug()` when available.\n * No-op when `console.debug` is not a \"function\".\n * If `console.debug` is not available, falls back\n * to `console.log`.\n *\n * @api public\n */\nexports.log = console.debug || console.log || (() => {});\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\nfunction save(namespaces) {\n\ttry {\n\t\tif (namespaces) {\n\t\t\texports.storage.setItem('debug', namespaces);\n\t\t} else {\n\t\t\texports.storage.removeItem('debug');\n\t\t}\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\nfunction load() {\n\tlet r;\n\ttry {\n\t\tr = exports.storage.getItem('debug');\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n\n\t// If debug isn't set in LS, and we're in Electron, try to load $DEBUG\n\tif (!r && typeof process !== 'undefined' && 'env' in process) {\n\t\tr = process.env.DEBUG;\n\t}\n\n\treturn r;\n}\n\n/**\n * Localstorage attempts to return the localstorage.\n *\n * This is necessary because safari throws\n * when a user disables cookies/localstorage\n * and you attempt to access it.\n *\n * @return {LocalStorage}\n * @api private\n */\n\nfunction localstorage() {\n\ttry {\n\t\t// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context\n\t\t// The Browser also has localStorage in the global context.\n\t\treturn localStorage;\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n}\n\nmodule.exports = require('./common')(exports);\n\nconst {formatters} = module.exports;\n\n/**\n * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.\n */\n\nformatters.j = function (v) {\n\ttry {\n\t\treturn JSON.stringify(v);\n\t} catch (error) {\n\t\treturn '[UnexpectedJSONParseError]: ' + error.message;\n\t}\n};\n","'use strict';\n\nvar has = Object.prototype.hasOwnProperty\n , prefix = '~';\n\n/**\n * Constructor to create a storage for our `EE` objects.\n * An `Events` instance is a plain object whose properties are event names.\n *\n * @constructor\n * @private\n */\nfunction Events() {}\n\n//\n// We try to not inherit from `Object.prototype`. In some engines creating an\n// instance in this way is faster than calling `Object.create(null)` directly.\n// If `Object.create(null)` is not supported we prefix the event names with a\n// character to make sure that the built-in object properties are not\n// overridden or used as an attack vector.\n//\nif (Object.create) {\n Events.prototype = Object.create(null);\n\n //\n // This hack is needed because the `__proto__` property is still inherited in\n // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.\n //\n if (!new Events().__proto__) prefix = false;\n}\n\n/**\n * Representation of a single event listener.\n *\n * @param {Function} fn The listener function.\n * @param {*} context The context to invoke the listener with.\n * @param {Boolean} [once=false] Specify if the listener is a one-time listener.\n * @constructor\n * @private\n */\nfunction EE(fn, context, once) {\n this.fn = fn;\n this.context = context;\n this.once = once || false;\n}\n\n/**\n * Add a listener for a given event.\n *\n * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} context The context to invoke the listener with.\n * @param {Boolean} once Specify if the listener is a one-time listener.\n * @returns {EventEmitter}\n * @private\n */\nfunction addListener(emitter, event, fn, context, once) {\n if (typeof fn !== 'function') {\n throw new TypeError('The listener must be a function');\n }\n\n var listener = new EE(fn, context || emitter, once)\n , evt = prefix ? prefix + event : event;\n\n if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;\n else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);\n else emitter._events[evt] = [emitter._events[evt], listener];\n\n return emitter;\n}\n\n/**\n * Clear event by name.\n *\n * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.\n * @param {(String|Symbol)} evt The Event name.\n * @private\n */\nfunction clearEvent(emitter, evt) {\n if (--emitter._eventsCount === 0) emitter._events = new Events();\n else delete emitter._events[evt];\n}\n\n/**\n * Minimal `EventEmitter` interface that is molded against the Node.js\n * `EventEmitter` interface.\n *\n * @constructor\n * @public\n */\nfunction EventEmitter() {\n this._events = new Events();\n this._eventsCount = 0;\n}\n\n/**\n * Return an array listing the events for which the emitter has registered\n * listeners.\n *\n * @returns {Array}\n * @public\n */\nEventEmitter.prototype.eventNames = function eventNames() {\n var names = []\n , events\n , name;\n\n if (this._eventsCount === 0) return names;\n\n for (name in (events = this._events)) {\n if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);\n }\n\n if (Object.getOwnPropertySymbols) {\n return names.concat(Object.getOwnPropertySymbols(events));\n }\n\n return names;\n};\n\n/**\n * Return the listeners registered for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Array} The registered listeners.\n * @public\n */\nEventEmitter.prototype.listeners = function listeners(event) {\n var evt = prefix ? prefix + event : event\n , handlers = this._events[evt];\n\n if (!handlers) return [];\n if (handlers.fn) return [handlers.fn];\n\n for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {\n ee[i] = handlers[i].fn;\n }\n\n return ee;\n};\n\n/**\n * Return the number of listeners listening to a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Number} The number of listeners.\n * @public\n */\nEventEmitter.prototype.listenerCount = function listenerCount(event) {\n var evt = prefix ? prefix + event : event\n , listeners = this._events[evt];\n\n if (!listeners) return 0;\n if (listeners.fn) return 1;\n return listeners.length;\n};\n\n/**\n * Calls each of the listeners registered for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Boolean} `true` if the event had listeners, else `false`.\n * @public\n */\nEventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {\n var evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) return false;\n\n var listeners = this._events[evt]\n , len = arguments.length\n , args\n , i;\n\n if (listeners.fn) {\n if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);\n\n switch (len) {\n case 1: return listeners.fn.call(listeners.context), true;\n case 2: return listeners.fn.call(listeners.context, a1), true;\n case 3: return listeners.fn.call(listeners.context, a1, a2), true;\n case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;\n case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;\n case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;\n }\n\n for (i = 1, args = new Array(len -1); i < len; i++) {\n args[i - 1] = arguments[i];\n }\n\n listeners.fn.apply(listeners.context, args);\n } else {\n var length = listeners.length\n , j;\n\n for (i = 0; i < length; i++) {\n if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);\n\n switch (len) {\n case 1: listeners[i].fn.call(listeners[i].context); break;\n case 2: listeners[i].fn.call(listeners[i].context, a1); break;\n case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;\n case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;\n default:\n if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {\n args[j - 1] = arguments[j];\n }\n\n listeners[i].fn.apply(listeners[i].context, args);\n }\n }\n }\n\n return true;\n};\n\n/**\n * Add a listener for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.on = function on(event, fn, context) {\n return addListener(this, event, fn, context, false);\n};\n\n/**\n * Add a one-time listener for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.once = function once(event, fn, context) {\n return addListener(this, event, fn, context, true);\n};\n\n/**\n * Remove the listeners of a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn Only remove the listeners that match this function.\n * @param {*} context Only remove the listeners that have this context.\n * @param {Boolean} once Only remove one-time listeners.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {\n var evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) return this;\n if (!fn) {\n clearEvent(this, evt);\n return this;\n }\n\n var listeners = this._events[evt];\n\n if (listeners.fn) {\n if (\n listeners.fn === fn &&\n (!once || listeners.once) &&\n (!context || listeners.context === context)\n ) {\n clearEvent(this, evt);\n }\n } else {\n for (var i = 0, events = [], length = listeners.length; i < length; i++) {\n if (\n listeners[i].fn !== fn ||\n (once && !listeners[i].once) ||\n (context && listeners[i].context !== context)\n ) {\n events.push(listeners[i]);\n }\n }\n\n //\n // Reset the array, or remove it completely if we have no more listeners.\n //\n if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;\n else clearEvent(this, evt);\n }\n\n return this;\n};\n\n/**\n * Remove all listeners, or those of the specified event.\n *\n * @param {(String|Symbol)} [event] The event name.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {\n var evt;\n\n if (event) {\n evt = prefix ? prefix + event : event;\n if (this._events[evt]) clearEvent(this, evt);\n } else {\n this._events = new Events();\n this._eventsCount = 0;\n }\n\n return this;\n};\n\n//\n// Alias methods names because people roll like that.\n//\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\nEventEmitter.prototype.addListener = EventEmitter.prototype.on;\n\n//\n// Expose the prefix.\n//\nEventEmitter.prefixed = prefix;\n\n//\n// Allow `EventEmitter` to be imported as module namespace.\n//\nEventEmitter.EventEmitter = EventEmitter;\n\n//\n// Expose the module.\n//\nif ('undefined' !== typeof module) {\n module.exports = EventEmitter;\n}\n","// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis\nfunction getGlobal() {\n if (typeof globalThis !== 'undefined') {\n return globalThis;\n }\n if (typeof self !== 'undefined') {\n return self;\n }\n if (typeof window !== 'undefined') {\n return window;\n }\n if (typeof global !== 'undefined') {\n return global;\n }\n}\nfunction getDevTools() {\n const w = getGlobal();\n if (!!w.__xstate__) {\n return w.__xstate__;\n }\n return undefined;\n}\nfunction registerService(service) {\n if (typeof window === 'undefined') {\n return;\n }\n const devTools = getDevTools();\n if (devTools) {\n devTools.register(service);\n }\n}\nconst devToolsAdapter = service => {\n if (typeof window === 'undefined') {\n return;\n }\n const devTools = getDevTools();\n if (devTools) {\n devTools.register(service);\n }\n};\n\nexport { devToolsAdapter, getGlobal, registerService };\n","import { devToolsAdapter } from '../dev/dist/xstate-dev.esm.js';\n\nclass Mailbox {\n constructor(_process) {\n this._process = _process;\n this._active = false;\n this._current = null;\n this._last = null;\n }\n start() {\n this._active = true;\n this.flush();\n }\n clear() {\n // we can't set _current to null because we might be currently processing\n // and enqueue following clear shouldnt start processing the enqueued item immediately\n if (this._current) {\n this._current.next = null;\n this._last = this._current;\n }\n }\n enqueue(event) {\n const enqueued = {\n value: event,\n next: null\n };\n if (this._current) {\n this._last.next = enqueued;\n this._last = enqueued;\n return;\n }\n this._current = enqueued;\n this._last = enqueued;\n if (this._active) {\n this.flush();\n }\n }\n flush() {\n while (this._current) {\n // atm the given _process is responsible for implementing proper try/catch handling\n // we assume here that this won't throw in a way that can affect this mailbox\n const consumed = this._current;\n this._process(consumed.value);\n this._current = consumed.next;\n }\n this._last = null;\n }\n}\n\nconst STATE_DELIMITER = '.';\nconst TARGETLESS_KEY = '';\nconst NULL_EVENT = '';\nconst STATE_IDENTIFIER = '#';\nconst WILDCARD = '*';\nconst XSTATE_INIT = 'xstate.init';\nconst XSTATE_ERROR = 'xstate.error';\nconst XSTATE_STOP = 'xstate.stop';\n\n/**\n * Returns an event that represents an implicit event that is sent after the\n * specified `delay`.\n *\n * @param delayRef The delay in milliseconds\n * @param id The state node ID where this event is handled\n */\nfunction createAfterEvent(delayRef, id) {\n return {\n type: `xstate.after.${delayRef}.${id}`\n };\n}\n\n/**\n * Returns an event that represents that a final state node has been reached in\n * the parent state node.\n *\n * @param id The final state node's parent state node `id`\n * @param output The data to pass into the event\n */\nfunction createDoneStateEvent(id, output) {\n return {\n type: `xstate.done.state.${id}`,\n output\n };\n}\n\n/**\n * Returns an event that represents that an invoked service has terminated.\n *\n * An invoked service is terminated when it has reached a top-level final state\n * node, but not when it is canceled.\n *\n * @param invokeId The invoked service ID\n * @param output The data to pass into the event\n */\nfunction createDoneActorEvent(invokeId, output) {\n return {\n type: `xstate.done.actor.${invokeId}`,\n output,\n actorId: invokeId\n };\n}\nfunction createErrorActorEvent(id, error) {\n return {\n type: `xstate.error.actor.${id}`,\n error,\n actorId: id\n };\n}\nfunction createInitEvent(input) {\n return {\n type: XSTATE_INIT,\n input\n };\n}\n\n/**\n * This function makes sure that unhandled errors are thrown in a separate\n * macrotask. It allows those errors to be detected by global error handlers and\n * reported to bug tracking services without interrupting our own stack of\n * execution.\n *\n * @param err Error to be thrown\n */\nfunction reportUnhandledError(err) {\n setTimeout(() => {\n throw err;\n });\n}\n\nconst symbolObservable = (() => typeof Symbol === 'function' && Symbol.observable || '@@observable')();\n\nfunction matchesState(parentStateId, childStateId) {\n const parentStateValue = toStateValue(parentStateId);\n const childStateValue = toStateValue(childStateId);\n if (typeof childStateValue === 'string') {\n if (typeof parentStateValue === 'string') {\n return childStateValue === parentStateValue;\n }\n\n // Parent more specific than child\n return false;\n }\n if (typeof parentStateValue === 'string') {\n return parentStateValue in childStateValue;\n }\n return Object.keys(parentStateValue).every(key => {\n if (!(key in childStateValue)) {\n return false;\n }\n return matchesState(parentStateValue[key], childStateValue[key]);\n });\n}\nfunction toStatePath(stateId) {\n if (isArray(stateId)) {\n return stateId;\n }\n let result = [];\n let segment = '';\n for (let i = 0; i < stateId.length; i++) {\n const char = stateId.charCodeAt(i);\n switch (char) {\n // \\\n case 92:\n // consume the next character\n segment += stateId[i + 1];\n // and skip over it\n i++;\n continue;\n // .\n case 46:\n result.push(segment);\n segment = '';\n continue;\n }\n segment += stateId[i];\n }\n result.push(segment);\n return result;\n}\nfunction toStateValue(stateValue) {\n if (isMachineSnapshot(stateValue)) {\n return stateValue.value;\n }\n if (typeof stateValue !== 'string') {\n return stateValue;\n }\n const statePath = toStatePath(stateValue);\n return pathToStateValue(statePath);\n}\nfunction pathToStateValue(statePath) {\n if (statePath.length === 1) {\n return statePath[0];\n }\n const value = {};\n let marker = value;\n for (let i = 0; i < statePath.length - 1; i++) {\n if (i === statePath.length - 2) {\n marker[statePath[i]] = statePath[i + 1];\n } else {\n const previous = marker;\n marker = {};\n previous[statePath[i]] = marker;\n }\n }\n return value;\n}\nfunction mapValues(collection, iteratee) {\n const result = {};\n const collectionKeys = Object.keys(collection);\n for (let i = 0; i < collectionKeys.length; i++) {\n const key = collectionKeys[i];\n result[key] = iteratee(collection[key], key, collection, i);\n }\n return result;\n}\nfunction toArrayStrict(value) {\n if (isArray(value)) {\n return value;\n }\n return [value];\n}\nfunction toArray(value) {\n if (value === undefined) {\n return [];\n }\n return toArrayStrict(value);\n}\nfunction resolveOutput(mapper, context, event, self) {\n if (typeof mapper === 'function') {\n return mapper({\n context,\n event,\n self\n });\n }\n return mapper;\n}\nfunction isArray(value) {\n return Array.isArray(value);\n}\nfunction isErrorActorEvent(event) {\n return event.type.startsWith('xstate.error.actor');\n}\nfunction toTransitionConfigArray(configLike) {\n return toArrayStrict(configLike).map(transitionLike => {\n if (typeof transitionLike === 'undefined' || typeof transitionLike === 'string') {\n return {\n target: transitionLike\n };\n }\n return transitionLike;\n });\n}\nfunction normalizeTarget(target) {\n if (target === undefined || target === TARGETLESS_KEY) {\n return undefined;\n }\n return toArray(target);\n}\nfunction toObserver(nextHandler, errorHandler, completionHandler) {\n const isObserver = typeof nextHandler === 'object';\n const self = isObserver ? nextHandler : undefined;\n return {\n next: (isObserver ? nextHandler.next : nextHandler)?.bind(self),\n error: (isObserver ? nextHandler.error : errorHandler)?.bind(self),\n complete: (isObserver ? nextHandler.complete : completionHandler)?.bind(self)\n };\n}\nfunction createInvokeId(stateNodeId, index) {\n return `${index}.${stateNodeId}`;\n}\nfunction resolveReferencedActor(machine, src) {\n const match = src.match(/^xstate\\.invoke\\.(\\d+)\\.(.*)/);\n if (!match) {\n return machine.implementations.actors[src];\n }\n const [, indexStr, nodeId] = match;\n const node = machine.getStateNodeById(nodeId);\n const invokeConfig = node.config.invoke;\n return (Array.isArray(invokeConfig) ? invokeConfig[indexStr] : invokeConfig).src;\n}\nfunction getAllOwnEventDescriptors(snapshot) {\n return [...new Set([...snapshot._nodes.flatMap(sn => sn.ownEvents)])];\n}\n\nfunction createScheduledEventId(actorRef, id) {\n return `${actorRef.sessionId}.${id}`;\n}\nlet idCounter = 0;\nfunction createSystem(rootActor, options) {\n const children = new Map();\n const keyedActors = new Map();\n const reverseKeyedActors = new WeakMap();\n const inspectionObservers = new Set();\n const timerMap = {};\n const {\n clock,\n logger\n } = options;\n const scheduler = {\n schedule: (source, target, event, delay, id = Math.random().toString(36).slice(2)) => {\n const scheduledEvent = {\n source,\n target,\n event,\n delay,\n id,\n startedAt: Date.now()\n };\n const scheduledEventId = createScheduledEventId(source, id);\n system._snapshot._scheduledEvents[scheduledEventId] = scheduledEvent;\n const timeout = clock.setTimeout(() => {\n delete timerMap[scheduledEventId];\n delete system._snapshot._scheduledEvents[scheduledEventId];\n system._relay(source, target, event);\n }, delay);\n timerMap[scheduledEventId] = timeout;\n },\n cancel: (source, id) => {\n const scheduledEventId = createScheduledEventId(source, id);\n const timeout = timerMap[scheduledEventId];\n delete timerMap[scheduledEventId];\n delete system._snapshot._scheduledEvents[scheduledEventId];\n if (timeout !== undefined) {\n clock.clearTimeout(timeout);\n }\n },\n cancelAll: actorRef => {\n for (const scheduledEventId in system._snapshot._scheduledEvents) {\n const scheduledEvent = system._snapshot._scheduledEvents[scheduledEventId];\n if (scheduledEvent.source === actorRef) {\n scheduler.cancel(actorRef, scheduledEvent.id);\n }\n }\n }\n };\n const sendInspectionEvent = event => {\n if (!inspectionObservers.size) {\n return;\n }\n const resolvedInspectionEvent = {\n ...event,\n rootId: rootActor.sessionId\n };\n inspectionObservers.forEach(observer => observer.next?.(resolvedInspectionEvent));\n };\n const system = {\n _snapshot: {\n _scheduledEvents: (options?.snapshot && options.snapshot.scheduler) ?? {}\n },\n _bookId: () => `x:${idCounter++}`,\n _register: (sessionId, actorRef) => {\n children.set(sessionId, actorRef);\n return sessionId;\n },\n _unregister: actorRef => {\n children.delete(actorRef.sessionId);\n const systemId = reverseKeyedActors.get(actorRef);\n if (systemId !== undefined) {\n keyedActors.delete(systemId);\n reverseKeyedActors.delete(actorRef);\n }\n },\n get: systemId => {\n return keyedActors.get(systemId);\n },\n _set: (systemId, actorRef) => {\n const existing = keyedActors.get(systemId);\n if (existing && existing !== actorRef) {\n throw new Error(`Actor with system ID '${systemId}' already exists.`);\n }\n keyedActors.set(systemId, actorRef);\n reverseKeyedActors.set(actorRef, systemId);\n },\n inspect: observerOrFn => {\n const observer = toObserver(observerOrFn);\n inspectionObservers.add(observer);\n return {\n unsubscribe() {\n inspectionObservers.delete(observer);\n }\n };\n },\n _sendInspectionEvent: sendInspectionEvent,\n _relay: (source, target, event) => {\n system._sendInspectionEvent({\n type: '@xstate.event',\n sourceRef: source,\n actorRef: target,\n event\n });\n target._send(event);\n },\n scheduler,\n getSnapshot: () => {\n return {\n _scheduledEvents: {\n ...system._snapshot._scheduledEvents\n }\n };\n },\n start: () => {\n const scheduledEvents = system._snapshot._scheduledEvents;\n system._snapshot._scheduledEvents = {};\n for (const scheduledId in scheduledEvents) {\n const {\n source,\n target,\n event,\n delay,\n id\n } = scheduledEvents[scheduledId];\n scheduler.schedule(source, target, event, delay, id);\n }\n },\n _clock: clock,\n _logger: logger\n };\n return system;\n}\n\nconst $$ACTOR_TYPE = 1;\n\n// those values are currently used by @xstate/react directly so it's important to keep the assigned values in sync\nlet ProcessingStatus = /*#__PURE__*/function (ProcessingStatus) {\n ProcessingStatus[ProcessingStatus[\"NotStarted\"] = 0] = \"NotStarted\";\n ProcessingStatus[ProcessingStatus[\"Running\"] = 1] = \"Running\";\n ProcessingStatus[ProcessingStatus[\"Stopped\"] = 2] = \"Stopped\";\n return ProcessingStatus;\n}({});\nconst defaultOptions = {\n clock: {\n setTimeout: (fn, ms) => {\n return setTimeout(fn, ms);\n },\n clearTimeout: id => {\n return clearTimeout(id);\n }\n },\n logger: console.log.bind(console),\n devTools: false\n};\n\n/**\n * An Actor is a running process that can receive events, send events and change\n * its behavior based on the events it receives, which can cause effects outside\n * of the actor. When you run a state machine, it becomes an actor.\n */\nclass Actor {\n /**\n * Creates a new actor instance for the given logic with the provided options,\n * if any.\n *\n * @param logic The logic to create an actor from\n * @param options Actor options\n */\n constructor(logic, options) {\n this.logic = logic;\n /** The current internal state of the actor. */\n this._snapshot = void 0;\n /**\n * The clock that is responsible for setting and clearing timeouts, such as\n * delayed events and transitions.\n */\n this.clock = void 0;\n this.options = void 0;\n /** The unique identifier for this actor relative to its parent. */\n this.id = void 0;\n this.mailbox = new Mailbox(this._process.bind(this));\n this.observers = new Set();\n this.eventListeners = new Map();\n this.logger = void 0;\n /** @internal */\n this._processingStatus = ProcessingStatus.NotStarted;\n // Actor Ref\n this._parent = void 0;\n /** @internal */\n this._syncSnapshot = void 0;\n this.ref = void 0;\n // TODO: add typings for system\n this._actorScope = void 0;\n this._systemId = void 0;\n /** The globally unique process ID for this invocation. */\n this.sessionId = void 0;\n /** The system to which this actor belongs. */\n this.system = void 0;\n this._doneEvent = void 0;\n this.src = void 0;\n // array of functions to defer\n this._deferred = [];\n const resolvedOptions = {\n ...defaultOptions,\n ...options\n };\n const {\n clock,\n logger,\n parent,\n syncSnapshot,\n id,\n systemId,\n inspect\n } = resolvedOptions;\n this.system = parent ? parent.system : createSystem(this, {\n clock,\n logger\n });\n if (inspect && !parent) {\n // Always inspect at the system-level\n this.system.inspect(toObserver(inspect));\n }\n this.sessionId = this.system._bookId();\n this.id = id ?? this.sessionId;\n this.logger = options?.logger ?? this.system._logger;\n this.clock = options?.clock ?? this.system._clock;\n this._parent = parent;\n this._syncSnapshot = syncSnapshot;\n this.options = resolvedOptions;\n this.src = resolvedOptions.src ?? logic;\n this.ref = this;\n this._actorScope = {\n self: this,\n id: this.id,\n sessionId: this.sessionId,\n logger: this.logger,\n defer: fn => {\n this._deferred.push(fn);\n },\n system: this.system,\n stopChild: child => {\n if (child._parent !== this) {\n throw new Error(`Cannot stop child actor ${child.id} of ${this.id} because it is not a child`);\n }\n child._stop();\n },\n emit: emittedEvent => {\n const listeners = this.eventListeners.get(emittedEvent.type);\n const wildcardListener = this.eventListeners.get('*');\n if (!listeners && !wildcardListener) {\n return;\n }\n const allListeners = new Set([...(listeners ? listeners.values() : []), ...(wildcardListener ? wildcardListener.values() : [])]);\n for (const handler of Array.from(allListeners)) {\n handler(emittedEvent);\n }\n }\n };\n\n // Ensure that the send method is bound to this Actor instance\n // if destructured\n this.send = this.send.bind(this);\n this.system._sendInspectionEvent({\n type: '@xstate.actor',\n actorRef: this\n });\n if (systemId) {\n this._systemId = systemId;\n this.system._set(systemId, this);\n }\n this._initState(options?.snapshot ?? options?.state);\n if (systemId && this._snapshot.status !== 'active') {\n this.system._unregister(this);\n }\n }\n _initState(persistedState) {\n try {\n this._snapshot = persistedState ? this.logic.restoreSnapshot ? this.logic.restoreSnapshot(persistedState, this._actorScope) : persistedState : this.logic.getInitialSnapshot(this._actorScope, this.options?.input);\n } catch (err) {\n // if we get here then it means that we assign a value to this._snapshot that is not of the correct type\n // we can't get the true `TSnapshot & { status: 'error'; }`, it's impossible\n // so right now this is a lie of sorts\n this._snapshot = {\n status: 'error',\n output: undefined,\n error: err\n };\n }\n }\n update(snapshot, event) {\n // Update state\n this._snapshot = snapshot;\n\n // Execute deferred effects\n let deferredFn;\n while (deferredFn = this._deferred.shift()) {\n try {\n deferredFn();\n } catch (err) {\n // this error can only be caught when executing *initial* actions\n // it's the only time when we call actions provided by the user through those deferreds\n // when the actor is already running we always execute them synchronously while transitioning\n // no \"builtin deferred\" should actually throw an error since they are either safe\n // or the control flow is passed through the mailbox and errors should be caught by the `_process` used by the mailbox\n this._deferred.length = 0;\n this._snapshot = {\n ...snapshot,\n status: 'error',\n error: err\n };\n }\n }\n switch (this._snapshot.status) {\n case 'active':\n for (const observer of this.observers) {\n try {\n observer.next?.(snapshot);\n } catch (err) {\n reportUnhandledError(err);\n }\n }\n break;\n case 'done':\n // next observers are meant to be notified about done snapshots\n // this can be seen as something that is different from how observable work\n // but with observables `complete` callback is called without any arguments\n // it's more ergonomic for XState to treat a done snapshot as a \"next\" value\n // and the completion event as something that is separate,\n // something that merely follows emitting that done snapshot\n for (const observer of this.observers) {\n try {\n observer.next?.(snapshot);\n } catch (err) {\n reportUnhandledError(err);\n }\n }\n this._stopProcedure();\n this._complete();\n this._doneEvent = createDoneActorEvent(this.id, this._snapshot.output);\n if (this._parent) {\n this.system._relay(this, this._parent, this._doneEvent);\n }\n break;\n case 'error':\n this._error(this._snapshot.error);\n break;\n }\n this.system._sendInspectionEvent({\n type: '@xstate.snapshot',\n actorRef: this,\n event,\n snapshot\n });\n }\n\n /**\n * Subscribe an observer to an actor’s snapshot values.\n *\n * @remarks\n * The observer will receive the actor’s snapshot value when it is emitted.\n * The observer can be:\n *\n * - A plain function that receives the latest snapshot, or\n * - An observer object whose `.next(snapshot)` method receives the latest\n * snapshot\n *\n * @example\n *\n * ```ts\n * // Observer as a plain function\n * const subscription = actor.subscribe((snapshot) => {\n * console.log(snapshot);\n * });\n * ```\n *\n * @example\n *\n * ```ts\n * // Observer as an object\n * const subscription = actor.subscribe({\n * next(snapshot) {\n * console.log(snapshot);\n * },\n * error(err) {\n * // ...\n * },\n * complete() {\n * // ...\n * }\n * });\n * ```\n *\n * The return value of `actor.subscribe(observer)` is a subscription object\n * that has an `.unsubscribe()` method. You can call\n * `subscription.unsubscribe()` to unsubscribe the observer:\n *\n * @example\n *\n * ```ts\n * const subscription = actor.subscribe((snapshot) => {\n * // ...\n * });\n *\n * // Unsubscribe the observer\n * subscription.unsubscribe();\n * ```\n *\n * When the actor is stopped, all of its observers will automatically be\n * unsubscribed.\n *\n * @param observer - Either a plain function that receives the latest\n * snapshot, or an observer object whose `.next(snapshot)` method receives\n * the latest snapshot\n */\n\n subscribe(nextListenerOrObserver, errorListener, completeListener) {\n const observer = toObserver(nextListenerOrObserver, errorListener, completeListener);\n if (this._processingStatus !== ProcessingStatus.Stopped) {\n this.observers.add(observer);\n } else {\n switch (this._snapshot.status) {\n case 'done':\n try {\n observer.complete?.();\n } catch (err) {\n reportUnhandledError(err);\n }\n break;\n case 'error':\n {\n const err = this._snapshot.error;\n if (!observer.error) {\n reportUnhandledError(err);\n } else {\n try {\n observer.error(err);\n } catch (err) {\n reportUnhandledError(err);\n }\n }\n break;\n }\n }\n }\n return {\n unsubscribe: () => {\n this.observers.delete(observer);\n }\n };\n }\n on(type, handler) {\n let listeners = this.eventListeners.get(type);\n if (!listeners) {\n listeners = new Set();\n this.eventListeners.set(type, listeners);\n }\n const wrappedHandler = handler.bind(undefined);\n listeners.add(wrappedHandler);\n return {\n unsubscribe: () => {\n listeners.delete(wrappedHandler);\n }\n };\n }\n\n /** Starts the Actor from the initial state */\n start() {\n if (this._processingStatus === ProcessingStatus.Running) {\n // Do not restart the service if it is already started\n return this;\n }\n if (this._syncSnapshot) {\n this.subscribe({\n next: snapshot => {\n if (snapshot.status === 'active') {\n this.system._relay(this, this._parent, {\n type: `xstate.snapshot.${this.id}`,\n snapshot\n });\n }\n },\n error: () => {}\n });\n }\n this.system._register(this.sessionId, this);\n if (this._systemId) {\n this.system._set(this._systemId, this);\n }\n this._processingStatus = ProcessingStatus.Running;\n\n // TODO: this isn't correct when rehydrating\n const initEvent = createInitEvent(this.options.input);\n this.system._sendInspectionEvent({\n type: '@xstate.event',\n sourceRef: this._parent,\n actorRef: this,\n event: initEvent\n });\n const status = this._snapshot.status;\n switch (status) {\n case 'done':\n // a state machine can be \"done\" upon initialization (it could reach a final state using initial microsteps)\n // we still need to complete observers, flush deferreds etc\n this.update(this._snapshot, initEvent);\n // TODO: rethink cleanup of observers, mailbox, etc\n return this;\n case 'error':\n this._error(this._snapshot.error);\n return this;\n }\n if (!this._parent) {\n this.system.start();\n }\n if (this.logic.start) {\n try {\n this.logic.start(this._snapshot, this._actorScope);\n } catch (err) {\n this._snapshot = {\n ...this._snapshot,\n status: 'error',\n error: err\n };\n this._error(err);\n return this;\n }\n }\n\n // TODO: this notifies all subscribers but usually this is redundant\n // there is no real change happening here\n // we need to rethink if this needs to be refactored\n this.update(this._snapshot, initEvent);\n if (this.options.devTools) {\n this.attachDevTools();\n }\n this.mailbox.start();\n return this;\n }\n _process(event) {\n let nextState;\n let caughtError;\n try {\n nextState = this.logic.transition(this._snapshot, event, this._actorScope);\n } catch (err) {\n // we wrap it in a box so we can rethrow it later even if falsy value gets caught here\n caughtError = {\n err\n };\n }\n if (caughtError) {\n const {\n err\n } = caughtError;\n this._snapshot = {\n ...this._snapshot,\n status: 'error',\n error: err\n };\n this._error(err);\n return;\n }\n this.update(nextState, event);\n if (event.type === XSTATE_STOP) {\n this._stopProcedure();\n this._complete();\n }\n }\n _stop() {\n if (this._processingStatus === ProcessingStatus.Stopped) {\n return this;\n }\n this.mailbox.clear();\n if (this._processingStatus === ProcessingStatus.NotStarted) {\n this._processingStatus = ProcessingStatus.Stopped;\n return this;\n }\n this.mailbox.enqueue({\n type: XSTATE_STOP\n });\n return this;\n }\n\n /** Stops the Actor and unsubscribe all listeners. */\n stop() {\n if (this._parent) {\n throw new Error('A non-root actor cannot be stopped directly.');\n }\n return this._stop();\n }\n _complete() {\n for (const observer of this.observers) {\n try {\n observer.complete?.();\n } catch (err) {\n reportUnhandledError(err);\n }\n }\n this.observers.clear();\n }\n _reportError(err) {\n if (!this.observers.size) {\n if (!this._parent) {\n reportUnhandledError(err);\n }\n return;\n }\n let reportError = false;\n for (const observer of this.observers) {\n const errorListener = observer.error;\n reportError ||= !errorListener;\n try {\n errorListener?.(err);\n } catch (err2) {\n reportUnhandledError(err2);\n }\n }\n this.observers.clear();\n if (reportError) {\n reportUnhandledError(err);\n }\n }\n _error(err) {\n this._stopProcedure();\n this._reportError(err);\n if (this._parent) {\n this.system._relay(this, this._parent, createErrorActorEvent(this.id, err));\n }\n }\n // TODO: atm children don't belong entirely to the actor so\n // in a way - it's not even super aware of them\n // so we can't stop them from here but we really should!\n // right now, they are being stopped within the machine's transition\n // but that could throw and leave us with \"orphaned\" active actors\n _stopProcedure() {\n if (this._processingStatus !== ProcessingStatus.Running) {\n // Actor already stopped; do nothing\n return this;\n }\n\n // Cancel all delayed events\n this.system.scheduler.cancelAll(this);\n\n // TODO: mailbox.reset\n this.mailbox.clear();\n // TODO: after `stop` we must prepare ourselves for receiving events again\n // events sent *after* stop signal must be queued\n // it seems like this should be the common behavior for all of our consumers\n // so perhaps this should be unified somehow for all of them\n this.mailbox = new Mailbox(this._process.bind(this));\n this._processingStatus = ProcessingStatus.Stopped;\n this.system._unregister(this);\n return this;\n }\n\n /** @internal */\n _send(event) {\n if (this._processingStatus === ProcessingStatus.Stopped) {\n return;\n }\n this.mailbox.enqueue(event);\n }\n\n /**\n * Sends an event to the running Actor to trigger a transition.\n *\n * @param event The event to send\n */\n send(event) {\n this.system._relay(undefined, this, event);\n }\n attachDevTools() {\n const {\n devTools\n } = this.options;\n if (devTools) {\n const resolvedDevToolsAdapter = typeof devTools === 'function' ? devTools : devToolsAdapter;\n resolvedDevToolsAdapter(this);\n }\n }\n toJSON() {\n return {\n xstate$$type: $$ACTOR_TYPE,\n id: this.id\n };\n }\n\n /**\n * Obtain the internal state of the actor, which can be persisted.\n *\n * @remarks\n * The internal state can be persisted from any actor, not only machines.\n *\n * Note that the persisted state is not the same as the snapshot from\n * {@link Actor.getSnapshot}. Persisted state represents the internal state of\n * the actor, while snapshots represent the actor's last emitted value.\n *\n * Can be restored with {@link ActorOptions.state}\n * @see https://stately.ai/docs/persistence\n */\n\n getPersistedSnapshot(options) {\n return this.logic.getPersistedSnapshot(this._snapshot, options);\n }\n [symbolObservable]() {\n return this;\n }\n\n /**\n * Read an actor’s snapshot synchronously.\n *\n * @remarks\n * The snapshot represent an actor's last emitted value.\n *\n * When an actor receives an event, its internal state may change. An actor\n * may emit a snapshot when a state transition occurs.\n *\n * Note that some actors, such as callback actors generated with\n * `fromCallback`, will not emit snapshots.\n * @see {@link Actor.subscribe} to subscribe to an actor’s snapshot values.\n * @see {@link Actor.getPersistedSnapshot} to persist the internal state of an actor (which is more than just a snapshot).\n */\n getSnapshot() {\n return this._snapshot;\n }\n}\n/**\n * Creates a new actor instance for the given actor logic with the provided\n * options, if any.\n *\n * @remarks\n * When you create an actor from actor logic via `createActor(logic)`, you\n * implicitly create an actor system where the created actor is the root actor.\n * Any actors spawned from this root actor and its descendants are part of that\n * actor system.\n * @example\n *\n * ```ts\n * import { createActor } from 'xstate';\n * import { someActorLogic } from './someActorLogic.ts';\n *\n * // Creating the actor, which implicitly creates an actor system with itself as the root actor\n * const actor = createActor(someActorLogic);\n *\n * actor.subscribe((snapshot) => {\n * console.log(snapshot);\n * });\n *\n * // Actors must be started by calling `actor.start()`, which will also start the actor system.\n * actor.start();\n *\n * // Actors can receive events\n * actor.send({ type: 'someEvent' });\n *\n * // You can stop root actors by calling `actor.stop()`, which will also stop the actor system and all actors in that system.\n * actor.stop();\n * ```\n *\n * @param logic - The actor logic to create an actor from. For a state machine\n * actor logic creator, see {@link createMachine}. Other actor logic creators\n * include {@link fromCallback}, {@link fromEventObservable},\n * {@link fromObservable}, {@link fromPromise}, and {@link fromTransition}.\n * @param options - Actor options\n */\nfunction createActor(logic, ...[options]) {\n return new Actor(logic, options);\n}\n\n/**\n * Creates a new Interpreter instance for the given machine with the provided\n * options, if any.\n *\n * @deprecated Use `createActor` instead\n * @alias\n */\nconst interpret = createActor;\n\n/**\n * @deprecated Use `Actor` instead.\n * @alias\n */\n\nfunction resolveCancel(_, snapshot, actionArgs, actionParams, {\n sendId\n}) {\n const resolvedSendId = typeof sendId === 'function' ? sendId(actionArgs, actionParams) : sendId;\n return [snapshot, resolvedSendId];\n}\nfunction executeCancel(actorScope, resolvedSendId) {\n actorScope.defer(() => {\n actorScope.system.scheduler.cancel(actorScope.self, resolvedSendId);\n });\n}\n/**\n * Cancels a delayed `sendTo(...)` action that is waiting to be executed. The\n * canceled `sendTo(...)` action will not send its event or execute, unless the\n * `delay` has already elapsed before `cancel(...)` is called.\n *\n * @example\n *\n * ```ts\n * import { createMachine, sendTo, cancel } from 'xstate';\n *\n * const machine = createMachine({\n * // ...\n * on: {\n * sendEvent: {\n * actions: sendTo(\n * 'some-actor',\n * { type: 'someEvent' },\n * {\n * id: 'some-id',\n * delay: 1000\n * }\n * )\n * },\n * cancelEvent: {\n * actions: cancel('some-id')\n * }\n * }\n * });\n * ```\n *\n * @param sendId The `id` of the `sendTo(...)` action to cancel.\n */\nfunction cancel(sendId) {\n function cancel(args, params) {\n }\n cancel.type = 'xstate.cancel';\n cancel.sendId = sendId;\n cancel.resolve = resolveCancel;\n cancel.execute = executeCancel;\n return cancel;\n}\n\nfunction resolveSpawn(actorScope, snapshot, actionArgs, _actionParams, {\n id,\n systemId,\n src,\n input,\n syncSnapshot\n}) {\n const logic = typeof src === 'string' ? resolveReferencedActor(snapshot.machine, src) : src;\n const resolvedId = typeof id === 'function' ? id(actionArgs) : id;\n let actorRef;\n if (logic) {\n actorRef = createActor(logic, {\n id: resolvedId,\n src,\n parent: actorScope.self,\n syncSnapshot,\n systemId,\n input: typeof input === 'function' ? input({\n context: snapshot.context,\n event: actionArgs.event,\n self: actorScope.self\n }) : input\n });\n }\n return [cloneMachineSnapshot(snapshot, {\n children: {\n ...snapshot.children,\n [resolvedId]: actorRef\n }\n }), {\n id,\n actorRef\n }];\n}\nfunction executeSpawn(actorScope, {\n id,\n actorRef\n}) {\n if (!actorRef) {\n return;\n }\n actorScope.defer(() => {\n if (actorRef._processingStatus === ProcessingStatus.Stopped) {\n return;\n }\n actorRef.start();\n });\n}\nfunction spawnChild(...[src, {\n id,\n systemId,\n input,\n syncSnapshot = false\n} = {}]) {\n function spawnChild(args, params) {\n }\n spawnChild.type = 'snapshot.spawnChild';\n spawnChild.id = id;\n spawnChild.systemId = systemId;\n spawnChild.src = src;\n spawnChild.input = input;\n spawnChild.syncSnapshot = syncSnapshot;\n spawnChild.resolve = resolveSpawn;\n spawnChild.execute = executeSpawn;\n return spawnChild;\n}\n\nfunction resolveStop(_, snapshot, args, actionParams, {\n actorRef\n}) {\n const actorRefOrString = typeof actorRef === 'function' ? actorRef(args, actionParams) : actorRef;\n const resolvedActorRef = typeof actorRefOrString === 'string' ? snapshot.children[actorRefOrString] : actorRefOrString;\n let children = snapshot.children;\n if (resolvedActorRef) {\n children = {\n ...children\n };\n delete children[resolvedActorRef.id];\n }\n return [cloneMachineSnapshot(snapshot, {\n children\n }), resolvedActorRef];\n}\nfunction executeStop(actorScope, actorRef) {\n if (!actorRef) {\n return;\n }\n\n // we need to eagerly unregister it here so a new actor with the same systemId can be registered immediately\n // since we defer actual stopping of the actor but we don't defer actor creations (and we can't do that)\n // this could throw on `systemId` collision, for example, when dealing with reentering transitions\n actorScope.system._unregister(actorRef);\n\n // this allows us to prevent an actor from being started if it gets stopped within the same macrostep\n // this can happen, for example, when the invoking state is being exited immediately by an always transition\n if (actorRef._processingStatus !== ProcessingStatus.Running) {\n actorScope.stopChild(actorRef);\n return;\n }\n // stopping a child enqueues a stop event in the child actor's mailbox\n // we need for all of the already enqueued events to be processed before we stop the child\n // the parent itself might want to send some events to a child (for example from exit actions on the invoking state)\n // and we don't want to ignore those events\n actorScope.defer(() => {\n actorScope.stopChild(actorRef);\n });\n}\n/**\n * Stops a child actor.\n *\n * @param actorRef The actor to stop.\n */\nfunction stopChild(actorRef) {\n function stop(args, params) {\n }\n stop.type = 'xstate.stopChild';\n stop.actorRef = actorRef;\n stop.resolve = resolveStop;\n stop.execute = executeStop;\n return stop;\n}\n\n/**\n * Stops a child actor.\n *\n * @deprecated Use `stopChild(...)` instead\n * @alias\n */\nconst stop = stopChild;\n\nfunction checkStateIn(snapshot, _, {\n stateValue\n}) {\n if (typeof stateValue === 'string' && isStateId(stateValue)) {\n const target = snapshot.machine.getStateNodeById(stateValue);\n return snapshot._nodes.some(sn => sn === target);\n }\n return snapshot.matches(stateValue);\n}\nfunction stateIn(stateValue) {\n function stateIn(args, params) {\n return false;\n }\n stateIn.check = checkStateIn;\n stateIn.stateValue = stateValue;\n return stateIn;\n}\nfunction checkNot(snapshot, {\n context,\n event\n}, {\n guards\n}) {\n return !evaluateGuard(guards[0], context, event, snapshot);\n}\n\n/**\n * Higher-order guard that evaluates to `true` if the `guard` passed to it\n * evaluates to `false`.\n *\n * @category Guards\n * @example\n *\n * ```ts\n * import { setup, not } from 'xstate';\n *\n * const machine = setup({\n * guards: {\n * someNamedGuard: () => false\n * }\n * }).createMachine({\n * on: {\n * someEvent: {\n * guard: not('someNamedGuard'),\n * actions: () => {\n * // will be executed if guard in `not(...)`\n * // evaluates to `false`\n * }\n * }\n * }\n * });\n * ```\n *\n * @returns A guard\n */\nfunction not(guard) {\n function not(args, params) {\n return false;\n }\n not.check = checkNot;\n not.guards = [guard];\n return not;\n}\nfunction checkAnd(snapshot, {\n context,\n event\n}, {\n guards\n}) {\n return guards.every(guard => evaluateGuard(guard, context, event, snapshot));\n}\n\n/**\n * Higher-order guard that evaluates to `true` if all `guards` passed to it\n * evaluate to `true`.\n *\n * @category Guards\n * @example\n *\n * ```ts\n * import { setup, and } from 'xstate';\n *\n * const machine = setup({\n * guards: {\n * someNamedGuard: () => true\n * }\n * }).createMachine({\n * on: {\n * someEvent: {\n * guard: and([({ context }) => context.value > 0, 'someNamedGuard']),\n * actions: () => {\n * // will be executed if all guards in `and(...)`\n * // evaluate to true\n * }\n * }\n * }\n * });\n * ```\n *\n * @returns A guard action object\n */\nfunction and(guards) {\n function and(args, params) {\n return false;\n }\n and.check = checkAnd;\n and.guards = guards;\n return and;\n}\nfunction checkOr(snapshot, {\n context,\n event\n}, {\n guards\n}) {\n return guards.some(guard => evaluateGuard(guard, context, event, snapshot));\n}\n\n/**\n * Higher-order guard that evaluates to `true` if any of the `guards` passed to\n * it evaluate to `true`.\n *\n * @category Guards\n * @example\n *\n * ```ts\n * import { setup, or } from 'xstate';\n *\n * const machine = setup({\n * guards: {\n * someNamedGuard: () => true\n * }\n * }).createMachine({\n * on: {\n * someEvent: {\n * guard: or([({ context }) => context.value > 0, 'someNamedGuard']),\n * actions: () => {\n * // will be executed if any of the guards in `or(...)`\n * // evaluate to true\n * }\n * }\n * }\n * });\n * ```\n *\n * @returns A guard action object\n */\nfunction or(guards) {\n function or(args, params) {\n return false;\n }\n or.check = checkOr;\n or.guards = guards;\n return or;\n}\n\n// TODO: throw on cycles (depth check should be enough)\nfunction evaluateGuard(guard, context, event, snapshot) {\n const {\n machine\n } = snapshot;\n const isInline = typeof guard === 'function';\n const resolved = isInline ? guard : machine.implementations.guards[typeof guard === 'string' ? guard : guard.type];\n if (!isInline && !resolved) {\n throw new Error(`Guard '${typeof guard === 'string' ? guard : guard.type}' is not implemented.'.`);\n }\n if (typeof resolved !== 'function') {\n return evaluateGuard(resolved, context, event, snapshot);\n }\n const guardArgs = {\n context,\n event\n };\n const guardParams = isInline || typeof guard === 'string' ? undefined : 'params' in guard ? typeof guard.params === 'function' ? guard.params({\n context,\n event\n }) : guard.params : undefined;\n if (!('check' in resolved)) {\n // the existing type of `.guards` assumes non-nullable `TExpressionGuard`\n // inline guards expect `TExpressionGuard` to be set to `undefined`\n // it's fine to cast this here, our logic makes sure that we call those 2 \"variants\" correctly\n return resolved(guardArgs, guardParams);\n }\n const builtinGuard = resolved;\n return builtinGuard.check(snapshot, guardArgs, resolved // this holds all params\n );\n}\n\nconst isAtomicStateNode = stateNode => stateNode.type === 'atomic' || stateNode.type === 'final';\nfunction getChildren(stateNode) {\n return Object.values(stateNode.states).filter(sn => sn.type !== 'history');\n}\nfunction getProperAncestors(stateNode, toStateNode) {\n const ancestors = [];\n if (toStateNode === stateNode) {\n return ancestors;\n }\n\n // add all ancestors\n let m = stateNode.parent;\n while (m && m !== toStateNode) {\n ancestors.push(m);\n m = m.parent;\n }\n return ancestors;\n}\nfunction getAllStateNodes(stateNodes) {\n const nodeSet = new Set(stateNodes);\n const adjList = getAdjList(nodeSet);\n\n // add descendants\n for (const s of nodeSet) {\n // if previously active, add existing child nodes\n if (s.type === 'compound' && (!adjList.get(s) || !adjList.get(s).length)) {\n getInitialStateNodesWithTheirAncestors(s).forEach(sn => nodeSet.add(sn));\n } else {\n if (s.type === 'parallel') {\n for (const child of getChildren(s)) {\n if (child.type === 'history') {\n continue;\n }\n if (!nodeSet.has(child)) {\n const initialStates = getInitialStateNodesWithTheirAncestors(child);\n for (const initialStateNode of initialStates) {\n nodeSet.add(initialStateNode);\n }\n }\n }\n }\n }\n }\n\n // add all ancestors\n for (const s of nodeSet) {\n let m = s.parent;\n while (m) {\n nodeSet.add(m);\n m = m.parent;\n }\n }\n return nodeSet;\n}\nfunction getValueFromAdj(baseNode, adjList) {\n const childStateNodes = adjList.get(baseNode);\n if (!childStateNodes) {\n return {}; // todo: fix?\n }\n\n if (baseNode.type === 'compound') {\n const childStateNode = childStateNodes[0];\n if (childStateNode) {\n if (isAtomicStateNode(childStateNode)) {\n return childStateNode.key;\n }\n } else {\n return {};\n }\n }\n const stateValue = {};\n for (const childStateNode of childStateNodes) {\n stateValue[childStateNode.key] = getValueFromAdj(childStateNode, adjList);\n }\n return stateValue;\n}\nfunction getAdjList(stateNodes) {\n const adjList = new Map();\n for (const s of stateNodes) {\n if (!adjList.has(s)) {\n adjList.set(s, []);\n }\n if (s.parent) {\n if (!adjList.has(s.parent)) {\n adjList.set(s.parent, []);\n }\n adjList.get(s.parent).push(s);\n }\n }\n return adjList;\n}\nfunction getStateValue(rootNode, stateNodes) {\n const config = getAllStateNodes(stateNodes);\n return getValueFromAdj(rootNode, getAdjList(config));\n}\nfunction isInFinalState(stateNodeSet, stateNode) {\n if (stateNode.type === 'compound') {\n return getChildren(stateNode).some(s => s.type === 'final' && stateNodeSet.has(s));\n }\n if (stateNode.type === 'parallel') {\n return getChildren(stateNode).every(sn => isInFinalState(stateNodeSet, sn));\n }\n return stateNode.type === 'final';\n}\nconst isStateId = str => str[0] === STATE_IDENTIFIER;\nfunction getCandidates(stateNode, receivedEventType) {\n const candidates = stateNode.transitions.get(receivedEventType) || [...stateNode.transitions.keys()].filter(eventDescriptor => {\n // check if transition is a wildcard transition,\n // which matches any non-transient events\n if (eventDescriptor === WILDCARD) {\n return true;\n }\n if (!eventDescriptor.endsWith('.*')) {\n return false;\n }\n const partialEventTokens = eventDescriptor.split('.');\n const eventTokens = receivedEventType.split('.');\n for (let tokenIndex = 0; tokenIndex < partialEventTokens.length; tokenIndex++) {\n const partialEventToken = partialEventTokens[tokenIndex];\n const eventToken = eventTokens[tokenIndex];\n if (partialEventToken === '*') {\n const isLastToken = tokenIndex === partialEventTokens.length - 1;\n return isLastToken;\n }\n if (partialEventToken !== eventToken) {\n return false;\n }\n }\n return true;\n }).sort((a, b) => b.length - a.length).flatMap(key => stateNode.transitions.get(key));\n return candidates;\n}\n\n/** All delayed transitions from the config. */\nfunction getDelayedTransitions(stateNode) {\n const afterConfig = stateNode.config.after;\n if (!afterConfig) {\n return [];\n }\n const mutateEntryExit = (delay, i) => {\n const afterEvent = createAfterEvent(delay, stateNode.id);\n const eventType = afterEvent.type;\n stateNode.entry.push(raise(afterEvent, {\n id: eventType,\n delay\n }));\n stateNode.exit.push(cancel(eventType));\n return eventType;\n };\n const delayedTransitions = Object.keys(afterConfig).flatMap((delay, i) => {\n const configTransition = afterConfig[delay];\n const resolvedTransition = typeof configTransition === 'string' ? {\n target: configTransition\n } : configTransition;\n const resolvedDelay = Number.isNaN(+delay) ? delay : +delay;\n const eventType = mutateEntryExit(resolvedDelay);\n return toArray(resolvedTransition).map(transition => ({\n ...transition,\n event: eventType,\n delay: resolvedDelay\n }));\n });\n return delayedTransitions.map(delayedTransition => {\n const {\n delay\n } = delayedTransition;\n return {\n ...formatTransition(stateNode, delayedTransition.event, delayedTransition),\n delay\n };\n });\n}\nfunction formatTransition(stateNode, descriptor, transitionConfig) {\n const normalizedTarget = normalizeTarget(transitionConfig.target);\n const reenter = transitionConfig.reenter ?? false;\n const target = resolveTarget(stateNode, normalizedTarget);\n const transition = {\n ...transitionConfig,\n actions: toArray(transitionConfig.actions),\n guard: transitionConfig.guard,\n target,\n source: stateNode,\n reenter,\n eventType: descriptor,\n toJSON: () => ({\n ...transition,\n source: `#${stateNode.id}`,\n target: target ? target.map(t => `#${t.id}`) : undefined\n })\n };\n return transition;\n}\nfunction formatTransitions(stateNode) {\n const transitions = new Map();\n if (stateNode.config.on) {\n for (const descriptor of Object.keys(stateNode.config.on)) {\n if (descriptor === NULL_EVENT) {\n throw new Error('Null events (\"\") cannot be specified as a transition key. Use `always: { ... }` instead.');\n }\n const transitionsConfig = stateNode.config.on[descriptor];\n transitions.set(descriptor, toTransitionConfigArray(transitionsConfig).map(t => formatTransition(stateNode, descriptor, t)));\n }\n }\n if (stateNode.config.onDone) {\n const descriptor = `xstate.done.state.${stateNode.id}`;\n transitions.set(descriptor, toTransitionConfigArray(stateNode.config.onDone).map(t => formatTransition(stateNode, descriptor, t)));\n }\n for (const invokeDef of stateNode.invoke) {\n if (invokeDef.onDone) {\n const descriptor = `xstate.done.actor.${invokeDef.id}`;\n transitions.set(descriptor, toTransitionConfigArray(invokeDef.onDone).map(t => formatTransition(stateNode, descriptor, t)));\n }\n if (invokeDef.onError) {\n const descriptor = `xstate.error.actor.${invokeDef.id}`;\n transitions.set(descriptor, toTransitionConfigArray(invokeDef.onError).map(t => formatTransition(stateNode, descriptor, t)));\n }\n if (invokeDef.onSnapshot) {\n const descriptor = `xstate.snapshot.${invokeDef.id}`;\n transitions.set(descriptor, toTransitionConfigArray(invokeDef.onSnapshot).map(t => formatTransition(stateNode, descriptor, t)));\n }\n }\n for (const delayedTransition of stateNode.after) {\n let existing = transitions.get(delayedTransition.eventType);\n if (!existing) {\n existing = [];\n transitions.set(delayedTransition.eventType, existing);\n }\n existing.push(delayedTransition);\n }\n return transitions;\n}\nfunction formatInitialTransition(stateNode, _target) {\n const resolvedTarget = typeof _target === 'string' ? stateNode.states[_target] : _target ? stateNode.states[_target.target] : undefined;\n if (!resolvedTarget && _target) {\n throw new Error(`Initial state node \"${_target}\" not found on parent state node #${stateNode.id}`);\n }\n const transition = {\n source: stateNode,\n actions: !_target || typeof _target === 'string' ? [] : toArray(_target.actions),\n eventType: null,\n reenter: false,\n target: resolvedTarget ? [resolvedTarget] : [],\n toJSON: () => ({\n ...transition,\n source: `#${stateNode.id}`,\n target: resolvedTarget ? [`#${resolvedTarget.id}`] : []\n })\n };\n return transition;\n}\nfunction resolveTarget(stateNode, targets) {\n if (targets === undefined) {\n // an undefined target signals that the state node should not transition from that state when receiving that event\n return undefined;\n }\n return targets.map(target => {\n if (typeof target !== 'string') {\n return target;\n }\n if (isStateId(target)) {\n return stateNode.machine.getStateNodeById(target);\n }\n const isInternalTarget = target[0] === STATE_DELIMITER;\n // If internal target is defined on machine,\n // do not include machine key on target\n if (isInternalTarget && !stateNode.parent) {\n return getStateNodeByPath(stateNode, target.slice(1));\n }\n const resolvedTarget = isInternalTarget ? stateNode.key + target : target;\n if (stateNode.parent) {\n try {\n const targetStateNode = getStateNodeByPath(stateNode.parent, resolvedTarget);\n return targetStateNode;\n } catch (err) {\n throw new Error(`Invalid transition definition for state node '${stateNode.id}':\\n${err.message}`);\n }\n } else {\n throw new Error(`Invalid target: \"${target}\" is not a valid target from the root node. Did you mean \".${target}\"?`);\n }\n });\n}\nfunction resolveHistoryDefaultTransition(stateNode) {\n const normalizedTarget = normalizeTarget(stateNode.config.target);\n if (!normalizedTarget) {\n return stateNode.parent.initial;\n }\n return {\n target: normalizedTarget.map(t => typeof t === 'string' ? getStateNodeByPath(stateNode.parent, t) : t)\n };\n}\nfunction isHistoryNode(stateNode) {\n return stateNode.type === 'history';\n}\nfunction getInitialStateNodesWithTheirAncestors(stateNode) {\n const states = getInitialStateNodes(stateNode);\n for (const initialState of states) {\n for (const ancestor of getProperAncestors(initialState, stateNode)) {\n states.add(ancestor);\n }\n }\n return states;\n}\nfunction getInitialStateNodes(stateNode) {\n const set = new Set();\n function iter(descStateNode) {\n if (set.has(descStateNode)) {\n return;\n }\n set.add(descStateNode);\n if (descStateNode.type === 'compound') {\n iter(descStateNode.initial.target[0]);\n } else if (descStateNode.type === 'parallel') {\n for (const child of getChildren(descStateNode)) {\n iter(child);\n }\n }\n }\n iter(stateNode);\n return set;\n}\n/** Returns the child state node from its relative `stateKey`, or throws. */\nfunction getStateNode(stateNode, stateKey) {\n if (isStateId(stateKey)) {\n return stateNode.machine.getStateNodeById(stateKey);\n }\n if (!stateNode.states) {\n throw new Error(`Unable to retrieve child state '${stateKey}' from '${stateNode.id}'; no child states exist.`);\n }\n const result = stateNode.states[stateKey];\n if (!result) {\n throw new Error(`Child state '${stateKey}' does not exist on '${stateNode.id}'`);\n }\n return result;\n}\n\n/**\n * Returns the relative state node from the given `statePath`, or throws.\n *\n * @param statePath The string or string array relative path to the state node.\n */\nfunction getStateNodeByPath(stateNode, statePath) {\n if (typeof statePath === 'string' && isStateId(statePath)) {\n try {\n return stateNode.machine.getStateNodeById(statePath);\n } catch (e) {\n // try individual paths\n // throw e;\n }\n }\n const arrayStatePath = toStatePath(statePath).slice();\n let currentStateNode = stateNode;\n while (arrayStatePath.length) {\n const key = arrayStatePath.shift();\n if (!key.length) {\n break;\n }\n currentStateNode = getStateNode(currentStateNode, key);\n }\n return currentStateNode;\n}\n\n/**\n * Returns the state nodes represented by the current state value.\n *\n * @param stateValue The state value or State instance\n */\nfunction getStateNodes(stateNode, stateValue) {\n if (typeof stateValue === 'string') {\n const childStateNode = stateNode.states[stateValue];\n if (!childStateNode) {\n throw new Error(`State '${stateValue}' does not exist on '${stateNode.id}'`);\n }\n return [stateNode, childStateNode];\n }\n const childStateKeys = Object.keys(stateValue);\n const childStateNodes = childStateKeys.map(subStateKey => getStateNode(stateNode, subStateKey)).filter(Boolean);\n return [stateNode.machine.root, stateNode].concat(childStateNodes, childStateKeys.reduce((allSubStateNodes, subStateKey) => {\n const subStateNode = getStateNode(stateNode, subStateKey);\n if (!subStateNode) {\n return allSubStateNodes;\n }\n const subStateNodes = getStateNodes(subStateNode, stateValue[subStateKey]);\n return allSubStateNodes.concat(subStateNodes);\n }, []));\n}\nfunction transitionAtomicNode(stateNode, stateValue, snapshot, event) {\n const childStateNode = getStateNode(stateNode, stateValue);\n const next = childStateNode.next(snapshot, event);\n if (!next || !next.length) {\n return stateNode.next(snapshot, event);\n }\n return next;\n}\nfunction transitionCompoundNode(stateNode, stateValue, snapshot, event) {\n const subStateKeys = Object.keys(stateValue);\n const childStateNode = getStateNode(stateNode, subStateKeys[0]);\n const next = transitionNode(childStateNode, stateValue[subStateKeys[0]], snapshot, event);\n if (!next || !next.length) {\n return stateNode.next(snapshot, event);\n }\n return next;\n}\nfunction transitionParallelNode(stateNode, stateValue, snapshot, event) {\n const allInnerTransitions = [];\n for (const subStateKey of Object.keys(stateValue)) {\n const subStateValue = stateValue[subStateKey];\n if (!subStateValue) {\n continue;\n }\n const subStateNode = getStateNode(stateNode, subStateKey);\n const innerTransitions = transitionNode(subStateNode, subStateValue, snapshot, event);\n if (innerTransitions) {\n allInnerTransitions.push(...innerTransitions);\n }\n }\n if (!allInnerTransitions.length) {\n return stateNode.next(snapshot, event);\n }\n return allInnerTransitions;\n}\nfunction transitionNode(stateNode, stateValue, snapshot, event) {\n // leaf node\n if (typeof stateValue === 'string') {\n return transitionAtomicNode(stateNode, stateValue, snapshot, event);\n }\n\n // compound node\n if (Object.keys(stateValue).length === 1) {\n return transitionCompoundNode(stateNode, stateValue, snapshot, event);\n }\n\n // parallel node\n return transitionParallelNode(stateNode, stateValue, snapshot, event);\n}\nfunction getHistoryNodes(stateNode) {\n return Object.keys(stateNode.states).map(key => stateNode.states[key]).filter(sn => sn.type === 'history');\n}\nfunction isDescendant(childStateNode, parentStateNode) {\n let marker = childStateNode;\n while (marker.parent && marker.parent !== parentStateNode) {\n marker = marker.parent;\n }\n return marker.parent === parentStateNode;\n}\nfunction hasIntersection(s1, s2) {\n const set1 = new Set(s1);\n const set2 = new Set(s2);\n for (const item of set1) {\n if (set2.has(item)) {\n return true;\n }\n }\n for (const item of set2) {\n if (set1.has(item)) {\n return true;\n }\n }\n return false;\n}\nfunction removeConflictingTransitions(enabledTransitions, stateNodeSet, historyValue) {\n const filteredTransitions = new Set();\n for (const t1 of enabledTransitions) {\n let t1Preempted = false;\n const transitionsToRemove = new Set();\n for (const t2 of filteredTransitions) {\n if (hasIntersection(computeExitSet([t1], stateNodeSet, historyValue), computeExitSet([t2], stateNodeSet, historyValue))) {\n if (isDescendant(t1.source, t2.source)) {\n transitionsToRemove.add(t2);\n } else {\n t1Preempted = true;\n break;\n }\n }\n }\n if (!t1Preempted) {\n for (const t3 of transitionsToRemove) {\n filteredTransitions.delete(t3);\n }\n filteredTransitions.add(t1);\n }\n }\n return Array.from(filteredTransitions);\n}\nfunction findLeastCommonAncestor(stateNodes) {\n const [head, ...tail] = stateNodes;\n for (const ancestor of getProperAncestors(head, undefined)) {\n if (tail.every(sn => isDescendant(sn, ancestor))) {\n return ancestor;\n }\n }\n}\nfunction getEffectiveTargetStates(transition, historyValue) {\n if (!transition.target) {\n return [];\n }\n const targets = new Set();\n for (const targetNode of transition.target) {\n if (isHistoryNode(targetNode)) {\n if (historyValue[targetNode.id]) {\n for (const node of historyValue[targetNode.id]) {\n targets.add(node);\n }\n } else {\n for (const node of getEffectiveTargetStates(resolveHistoryDefaultTransition(targetNode), historyValue)) {\n targets.add(node);\n }\n }\n } else {\n targets.add(targetNode);\n }\n }\n return [...targets];\n}\nfunction getTransitionDomain(transition, historyValue) {\n const targetStates = getEffectiveTargetStates(transition, historyValue);\n if (!targetStates) {\n return;\n }\n if (!transition.reenter && targetStates.every(target => target === transition.source || isDescendant(target, transition.source))) {\n return transition.source;\n }\n const lca = findLeastCommonAncestor(targetStates.concat(transition.source));\n if (lca) {\n return lca;\n }\n\n // at this point we know that it's a root transition since LCA couldn't be found\n if (transition.reenter) {\n return;\n }\n return transition.source.machine.root;\n}\nfunction computeExitSet(transitions, stateNodeSet, historyValue) {\n const statesToExit = new Set();\n for (const t of transitions) {\n if (t.target?.length) {\n const domain = getTransitionDomain(t, historyValue);\n if (t.reenter && t.source === domain) {\n statesToExit.add(domain);\n }\n for (const stateNode of stateNodeSet) {\n if (isDescendant(stateNode, domain)) {\n statesToExit.add(stateNode);\n }\n }\n }\n }\n return [...statesToExit];\n}\nfunction areStateNodeCollectionsEqual(prevStateNodes, nextStateNodeSet) {\n if (prevStateNodes.length !== nextStateNodeSet.size) {\n return false;\n }\n for (const node of prevStateNodes) {\n if (!nextStateNodeSet.has(node)) {\n return false;\n }\n }\n return true;\n}\n\n/** https://www.w3.org/TR/scxml/#microstepProcedure */\nfunction microstep(transitions, currentSnapshot, actorScope, event, isInitial, internalQueue) {\n if (!transitions.length) {\n return currentSnapshot;\n }\n const mutStateNodeSet = new Set(currentSnapshot._nodes);\n let historyValue = currentSnapshot.historyValue;\n const filteredTransitions = removeConflictingTransitions(transitions, mutStateNodeSet, historyValue);\n let nextState = currentSnapshot;\n\n // Exit states\n if (!isInitial) {\n [nextState, historyValue] = exitStates(nextState, event, actorScope, filteredTransitions, mutStateNodeSet, historyValue, internalQueue);\n }\n\n // Execute transition content\n nextState = resolveActionsAndContext(nextState, event, actorScope, filteredTransitions.flatMap(t => t.actions), internalQueue);\n\n // Enter states\n nextState = enterStates(nextState, event, actorScope, filteredTransitions, mutStateNodeSet, internalQueue, historyValue, isInitial);\n const nextStateNodes = [...mutStateNodeSet];\n if (nextState.status === 'done') {\n nextState = resolveActionsAndContext(nextState, event, actorScope, nextStateNodes.sort((a, b) => b.order - a.order).flatMap(state => state.exit), internalQueue);\n }\n try {\n if (historyValue === currentSnapshot.historyValue && areStateNodeCollectionsEqual(currentSnapshot._nodes, mutStateNodeSet)) {\n return nextState;\n }\n return cloneMachineSnapshot(nextState, {\n _nodes: nextStateNodes,\n historyValue\n });\n } catch (e) {\n // TODO: Refactor this once proper error handling is implemented.\n // See https://github.com/statelyai/rfcs/pull/4\n throw e;\n }\n}\nfunction getMachineOutput(snapshot, event, actorScope, rootNode, rootCompletionNode) {\n if (rootNode.output === undefined) {\n return;\n }\n const doneStateEvent = createDoneStateEvent(rootCompletionNode.id, rootCompletionNode.output !== undefined && rootCompletionNode.parent ? resolveOutput(rootCompletionNode.output, snapshot.context, event, actorScope.self) : undefined);\n return resolveOutput(rootNode.output, snapshot.context, doneStateEvent, actorScope.self);\n}\nfunction enterStates(currentSnapshot, event, actorScope, filteredTransitions, mutStateNodeSet, internalQueue, historyValue, isInitial) {\n let nextSnapshot = currentSnapshot;\n const statesToEnter = new Set();\n // those are states that were directly targeted or indirectly targeted by the explicit target\n // in other words, those are states for which initial actions should be executed\n // when we target `#deep_child` initial actions of its ancestors shouldn't be executed\n const statesForDefaultEntry = new Set();\n computeEntrySet(filteredTransitions, historyValue, statesForDefaultEntry, statesToEnter);\n\n // In the initial state, the root state node is \"entered\".\n if (isInitial) {\n statesForDefaultEntry.add(currentSnapshot.machine.root);\n }\n const completedNodes = new Set();\n for (const stateNodeToEnter of [...statesToEnter].sort((a, b) => a.order - b.order)) {\n mutStateNodeSet.add(stateNodeToEnter);\n const actions = [];\n\n // Add entry actions\n actions.push(...stateNodeToEnter.entry);\n for (const invokeDef of stateNodeToEnter.invoke) {\n actions.push(spawnChild(invokeDef.src, {\n ...invokeDef,\n syncSnapshot: !!invokeDef.onSnapshot\n }));\n }\n if (statesForDefaultEntry.has(stateNodeToEnter)) {\n const initialActions = stateNodeToEnter.initial.actions;\n actions.push(...initialActions);\n }\n nextSnapshot = resolveActionsAndContext(nextSnapshot, event, actorScope, actions, internalQueue, stateNodeToEnter.invoke.map(invokeDef => invokeDef.id));\n if (stateNodeToEnter.type === 'final') {\n const parent = stateNodeToEnter.parent;\n let ancestorMarker = parent?.type === 'parallel' ? parent : parent?.parent;\n let rootCompletionNode = ancestorMarker || stateNodeToEnter;\n if (parent?.type === 'compound') {\n internalQueue.push(createDoneStateEvent(parent.id, stateNodeToEnter.output !== undefined ? resolveOutput(stateNodeToEnter.output, nextSnapshot.context, event, actorScope.self) : undefined));\n }\n while (ancestorMarker?.type === 'parallel' && !completedNodes.has(ancestorMarker) && isInFinalState(mutStateNodeSet, ancestorMarker)) {\n completedNodes.add(ancestorMarker);\n internalQueue.push(createDoneStateEvent(ancestorMarker.id));\n rootCompletionNode = ancestorMarker;\n ancestorMarker = ancestorMarker.parent;\n }\n if (ancestorMarker) {\n continue;\n }\n nextSnapshot = cloneMachineSnapshot(nextSnapshot, {\n status: 'done',\n output: getMachineOutput(nextSnapshot, event, actorScope, nextSnapshot.machine.root, rootCompletionNode)\n });\n }\n }\n return nextSnapshot;\n}\nfunction computeEntrySet(transitions, historyValue, statesForDefaultEntry, statesToEnter) {\n for (const t of transitions) {\n const domain = getTransitionDomain(t, historyValue);\n for (const s of t.target || []) {\n if (!isHistoryNode(s) && (\n // if the target is different than the source then it will *definitely* be entered\n t.source !== s ||\n // we know that the domain can't lie within the source\n // if it's different than the source then it's outside of it and it means that the target has to be entered as well\n t.source !== domain ||\n // reentering transitions always enter the target, even if it's the source itself\n t.reenter)) {\n statesToEnter.add(s);\n statesForDefaultEntry.add(s);\n }\n addDescendantStatesToEnter(s, historyValue, statesForDefaultEntry, statesToEnter);\n }\n const targetStates = getEffectiveTargetStates(t, historyValue);\n for (const s of targetStates) {\n const ancestors = getProperAncestors(s, domain);\n if (domain?.type === 'parallel') {\n ancestors.push(domain);\n }\n addAncestorStatesToEnter(statesToEnter, historyValue, statesForDefaultEntry, ancestors, !t.source.parent && t.reenter ? undefined : domain);\n }\n }\n}\nfunction addDescendantStatesToEnter(stateNode, historyValue, statesForDefaultEntry, statesToEnter) {\n if (isHistoryNode(stateNode)) {\n if (historyValue[stateNode.id]) {\n const historyStateNodes = historyValue[stateNode.id];\n for (const s of historyStateNodes) {\n statesToEnter.add(s);\n addDescendantStatesToEnter(s, historyValue, statesForDefaultEntry, statesToEnter);\n }\n for (const s of historyStateNodes) {\n addProperAncestorStatesToEnter(s, stateNode.parent, statesToEnter, historyValue, statesForDefaultEntry);\n }\n } else {\n const historyDefaultTransition = resolveHistoryDefaultTransition(stateNode);\n for (const s of historyDefaultTransition.target) {\n statesToEnter.add(s);\n if (historyDefaultTransition === stateNode.parent?.initial) {\n statesForDefaultEntry.add(stateNode.parent);\n }\n addDescendantStatesToEnter(s, historyValue, statesForDefaultEntry, statesToEnter);\n }\n for (const s of historyDefaultTransition.target) {\n addProperAncestorStatesToEnter(s, stateNode.parent, statesToEnter, historyValue, statesForDefaultEntry);\n }\n }\n } else {\n if (stateNode.type === 'compound') {\n const [initialState] = stateNode.initial.target;\n if (!isHistoryNode(initialState)) {\n statesToEnter.add(initialState);\n statesForDefaultEntry.add(initialState);\n }\n addDescendantStatesToEnter(initialState, historyValue, statesForDefaultEntry, statesToEnter);\n addProperAncestorStatesToEnter(initialState, stateNode, statesToEnter, historyValue, statesForDefaultEntry);\n } else {\n if (stateNode.type === 'parallel') {\n for (const child of getChildren(stateNode).filter(sn => !isHistoryNode(sn))) {\n if (![...statesToEnter].some(s => isDescendant(s, child))) {\n if (!isHistoryNode(child)) {\n statesToEnter.add(child);\n statesForDefaultEntry.add(child);\n }\n addDescendantStatesToEnter(child, historyValue, statesForDefaultEntry, statesToEnter);\n }\n }\n }\n }\n }\n}\nfunction addAncestorStatesToEnter(statesToEnter, historyValue, statesForDefaultEntry, ancestors, reentrancyDomain) {\n for (const anc of ancestors) {\n if (!reentrancyDomain || isDescendant(anc, reentrancyDomain)) {\n statesToEnter.add(anc);\n }\n if (anc.type === 'parallel') {\n for (const child of getChildren(anc).filter(sn => !isHistoryNode(sn))) {\n if (![...statesToEnter].some(s => isDescendant(s, child))) {\n statesToEnter.add(child);\n addDescendantStatesToEnter(child, historyValue, statesForDefaultEntry, statesToEnter);\n }\n }\n }\n }\n}\nfunction addProperAncestorStatesToEnter(stateNode, toStateNode, statesToEnter, historyValue, statesForDefaultEntry) {\n addAncestorStatesToEnter(statesToEnter, historyValue, statesForDefaultEntry, getProperAncestors(stateNode, toStateNode));\n}\nfunction exitStates(currentSnapshot, event, actorScope, transitions, mutStateNodeSet, historyValue, internalQueue) {\n let nextSnapshot = currentSnapshot;\n const statesToExit = computeExitSet(transitions, mutStateNodeSet, historyValue);\n statesToExit.sort((a, b) => b.order - a.order);\n let changedHistory;\n\n // From SCXML algorithm: https://www.w3.org/TR/scxml/#exitStates\n for (const exitStateNode of statesToExit) {\n for (const historyNode of getHistoryNodes(exitStateNode)) {\n let predicate;\n if (historyNode.history === 'deep') {\n predicate = sn => isAtomicStateNode(sn) && isDescendant(sn, exitStateNode);\n } else {\n predicate = sn => {\n return sn.parent === exitStateNode;\n };\n }\n changedHistory ??= {\n ...historyValue\n };\n changedHistory[historyNode.id] = Array.from(mutStateNodeSet).filter(predicate);\n }\n }\n for (const s of statesToExit) {\n nextSnapshot = resolveActionsAndContext(nextSnapshot, event, actorScope, [...s.exit, ...s.invoke.map(def => stopChild(def.id))], internalQueue);\n mutStateNodeSet.delete(s);\n }\n return [nextSnapshot, changedHistory || historyValue];\n}\nlet executingCustomAction = false;\nfunction resolveAndExecuteActionsWithContext(currentSnapshot, event, actorScope, actions, extra, retries) {\n const {\n machine\n } = currentSnapshot;\n let intermediateSnapshot = currentSnapshot;\n for (const action of actions) {\n const isInline = typeof action === 'function';\n const resolvedAction = isInline ? action :\n // the existing type of `.actions` assumes non-nullable `TExpressionAction`\n // it's fine to cast this here to get a common type and lack of errors in the rest of the code\n // our logic below makes sure that we call those 2 \"variants\" correctly\n machine.implementations.actions[typeof action === 'string' ? action : action.type];\n if (!resolvedAction) {\n continue;\n }\n const actionArgs = {\n context: intermediateSnapshot.context,\n event,\n self: actorScope.self,\n system: actorScope.system\n };\n const actionParams = isInline || typeof action === 'string' ? undefined : 'params' in action ? typeof action.params === 'function' ? action.params({\n context: intermediateSnapshot.context,\n event\n }) : action.params : undefined;\n function executeAction() {\n actorScope.system._sendInspectionEvent({\n type: '@xstate.action',\n actorRef: actorScope.self,\n action: {\n type: typeof action === 'string' ? action : typeof action === 'object' ? action.type : action.name || '(anonymous)',\n params: actionParams\n }\n });\n try {\n executingCustomAction = resolvedAction;\n resolvedAction(actionArgs, actionParams);\n } finally {\n executingCustomAction = false;\n }\n }\n if (!('resolve' in resolvedAction)) {\n if (actorScope.self._processingStatus === ProcessingStatus.Running) {\n executeAction();\n } else {\n actorScope.defer(() => {\n executeAction();\n });\n }\n continue;\n }\n const builtinAction = resolvedAction;\n const [nextState, params, actions] = builtinAction.resolve(actorScope, intermediateSnapshot, actionArgs, actionParams, resolvedAction,\n // this holds all params\n extra);\n intermediateSnapshot = nextState;\n if ('retryResolve' in builtinAction) {\n retries?.push([builtinAction, params]);\n }\n if ('execute' in builtinAction) {\n if (actorScope.self._processingStatus === ProcessingStatus.Running) {\n builtinAction.execute(actorScope, params);\n } else {\n actorScope.defer(builtinAction.execute.bind(null, actorScope, params));\n }\n }\n if (actions) {\n intermediateSnapshot = resolveAndExecuteActionsWithContext(intermediateSnapshot, event, actorScope, actions, extra, retries);\n }\n }\n return intermediateSnapshot;\n}\nfunction resolveActionsAndContext(currentSnapshot, event, actorScope, actions, internalQueue, deferredActorIds) {\n const retries = deferredActorIds ? [] : undefined;\n const nextState = resolveAndExecuteActionsWithContext(currentSnapshot, event, actorScope, actions, {\n internalQueue,\n deferredActorIds\n }, retries);\n retries?.forEach(([builtinAction, params]) => {\n builtinAction.retryResolve(actorScope, nextState, params);\n });\n return nextState;\n}\nfunction macrostep(snapshot, event, actorScope, internalQueue = []) {\n let nextSnapshot = snapshot;\n const microstates = [];\n function addMicrostate(microstate, event, transitions) {\n actorScope.system._sendInspectionEvent({\n type: '@xstate.microstep',\n actorRef: actorScope.self,\n event,\n snapshot: microstate,\n _transitions: transitions\n });\n microstates.push(microstate);\n }\n\n // Handle stop event\n if (event.type === XSTATE_STOP) {\n nextSnapshot = cloneMachineSnapshot(stopChildren(nextSnapshot, event, actorScope), {\n status: 'stopped'\n });\n addMicrostate(nextSnapshot, event, []);\n return {\n snapshot: nextSnapshot,\n microstates\n };\n }\n let nextEvent = event;\n\n // Assume the state is at rest (no raised events)\n // Determine the next state based on the next microstep\n if (nextEvent.type !== XSTATE_INIT) {\n const currentEvent = nextEvent;\n const isErr = isErrorActorEvent(currentEvent);\n const transitions = selectTransitions(currentEvent, nextSnapshot);\n if (isErr && !transitions.length) {\n // TODO: we should likely only allow transitions selected by very explicit descriptors\n // `*` shouldn't be matched, likely `xstate.error.*` shouldnt be either\n // similarly `xstate.error.actor.*` and `xstate.error.actor.todo.*` have to be considered too\n nextSnapshot = cloneMachineSnapshot(snapshot, {\n status: 'error',\n error: currentEvent.error\n });\n addMicrostate(nextSnapshot, currentEvent, []);\n return {\n snapshot: nextSnapshot,\n microstates\n };\n }\n nextSnapshot = microstep(transitions, snapshot, actorScope, nextEvent, false,\n // isInitial\n internalQueue);\n addMicrostate(nextSnapshot, currentEvent, transitions);\n }\n let shouldSelectEventlessTransitions = true;\n while (nextSnapshot.status === 'active') {\n let enabledTransitions = shouldSelectEventlessTransitions ? selectEventlessTransitions(nextSnapshot, nextEvent) : [];\n\n // eventless transitions should always be selected after selecting *regular* transitions\n // by assigning `undefined` to `previousState` we ensure that `shouldSelectEventlessTransitions` gets always computed to true in such a case\n const previousState = enabledTransitions.length ? nextSnapshot : undefined;\n if (!enabledTransitions.length) {\n if (!internalQueue.length) {\n break;\n }\n nextEvent = internalQueue.shift();\n enabledTransitions = selectTransitions(nextEvent, nextSnapshot);\n }\n nextSnapshot = microstep(enabledTransitions, nextSnapshot, actorScope, nextEvent, false, internalQueue);\n shouldSelectEventlessTransitions = nextSnapshot !== previousState;\n addMicrostate(nextSnapshot, nextEvent, enabledTransitions);\n }\n if (nextSnapshot.status !== 'active') {\n stopChildren(nextSnapshot, nextEvent, actorScope);\n }\n return {\n snapshot: nextSnapshot,\n microstates\n };\n}\nfunction stopChildren(nextState, event, actorScope) {\n return resolveActionsAndContext(nextState, event, actorScope, Object.values(nextState.children).map(child => stopChild(child)), []);\n}\nfunction selectTransitions(event, nextState) {\n return nextState.machine.getTransitionData(nextState, event);\n}\nfunction selectEventlessTransitions(nextState, event) {\n const enabledTransitionSet = new Set();\n const atomicStates = nextState._nodes.filter(isAtomicStateNode);\n for (const stateNode of atomicStates) {\n loop: for (const s of [stateNode].concat(getProperAncestors(stateNode, undefined))) {\n if (!s.always) {\n continue;\n }\n for (const transition of s.always) {\n if (transition.guard === undefined || evaluateGuard(transition.guard, nextState.context, event, nextState)) {\n enabledTransitionSet.add(transition);\n break loop;\n }\n }\n }\n }\n return removeConflictingTransitions(Array.from(enabledTransitionSet), new Set(nextState._nodes), nextState.historyValue);\n}\n\n/**\n * Resolves a partial state value with its full representation in the state\n * node's machine.\n *\n * @param stateValue The partial state value to resolve.\n */\nfunction resolveStateValue(rootNode, stateValue) {\n const allStateNodes = getAllStateNodes(getStateNodes(rootNode, stateValue));\n return getStateValue(rootNode, [...allStateNodes]);\n}\n\nfunction isMachineSnapshot(value) {\n return !!value && typeof value === 'object' && 'machine' in value && 'value' in value;\n}\nconst machineSnapshotMatches = function matches(testValue) {\n return matchesState(testValue, this.value);\n};\nconst machineSnapshotHasTag = function hasTag(tag) {\n return this.tags.has(tag);\n};\nconst machineSnapshotCan = function can(event) {\n const transitionData = this.machine.getTransitionData(this, event);\n return !!transitionData?.length &&\n // Check that at least one transition is not forbidden\n transitionData.some(t => t.target !== undefined || t.actions.length);\n};\nconst machineSnapshotToJSON = function toJSON() {\n const {\n _nodes: nodes,\n tags,\n machine,\n getMeta,\n toJSON,\n can,\n hasTag,\n matches,\n ...jsonValues\n } = this;\n return {\n ...jsonValues,\n tags: Array.from(tags)\n };\n};\nconst machineSnapshotGetMeta = function getMeta() {\n return this._nodes.reduce((acc, stateNode) => {\n if (stateNode.meta !== undefined) {\n acc[stateNode.id] = stateNode.meta;\n }\n return acc;\n }, {});\n};\nfunction createMachineSnapshot(config, machine) {\n return {\n status: config.status,\n output: config.output,\n error: config.error,\n machine,\n context: config.context,\n _nodes: config._nodes,\n value: getStateValue(machine.root, config._nodes),\n tags: new Set(config._nodes.flatMap(sn => sn.tags)),\n children: config.children,\n historyValue: config.historyValue || {},\n matches: machineSnapshotMatches,\n hasTag: machineSnapshotHasTag,\n can: machineSnapshotCan,\n getMeta: machineSnapshotGetMeta,\n toJSON: machineSnapshotToJSON\n };\n}\nfunction cloneMachineSnapshot(snapshot, config = {}) {\n return createMachineSnapshot({\n ...snapshot,\n ...config\n }, snapshot.machine);\n}\nfunction getPersistedSnapshot(snapshot, options) {\n const {\n _nodes: nodes,\n tags,\n machine,\n children,\n context,\n can,\n hasTag,\n matches,\n getMeta,\n toJSON,\n ...jsonValues\n } = snapshot;\n const childrenJson = {};\n for (const id in children) {\n const child = children[id];\n childrenJson[id] = {\n snapshot: child.getPersistedSnapshot(options),\n src: child.src,\n systemId: child._systemId,\n syncSnapshot: child._syncSnapshot\n };\n }\n const persisted = {\n ...jsonValues,\n context: persistContext(context),\n children: childrenJson\n };\n return persisted;\n}\nfunction persistContext(contextPart) {\n let copy;\n for (const key in contextPart) {\n const value = contextPart[key];\n if (value && typeof value === 'object') {\n if ('sessionId' in value && 'send' in value && 'ref' in value) {\n copy ??= Array.isArray(contextPart) ? contextPart.slice() : {\n ...contextPart\n };\n copy[key] = {\n xstate$$type: $$ACTOR_TYPE,\n id: value.id\n };\n } else {\n const result = persistContext(value);\n if (result !== value) {\n copy ??= Array.isArray(contextPart) ? contextPart.slice() : {\n ...contextPart\n };\n copy[key] = result;\n }\n }\n }\n }\n return copy ?? contextPart;\n}\n\nfunction resolveRaise(_, snapshot, args, actionParams, {\n event: eventOrExpr,\n id,\n delay\n}, {\n internalQueue\n}) {\n const delaysMap = snapshot.machine.implementations.delays;\n if (typeof eventOrExpr === 'string') {\n throw new Error(`Only event objects may be used with raise; use raise({ type: \"${eventOrExpr}\" }) instead`);\n }\n const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args, actionParams) : eventOrExpr;\n let resolvedDelay;\n if (typeof delay === 'string') {\n const configDelay = delaysMap && delaysMap[delay];\n resolvedDelay = typeof configDelay === 'function' ? configDelay(args, actionParams) : configDelay;\n } else {\n resolvedDelay = typeof delay === 'function' ? delay(args, actionParams) : delay;\n }\n if (typeof resolvedDelay !== 'number') {\n internalQueue.push(resolvedEvent);\n }\n return [snapshot, {\n event: resolvedEvent,\n id,\n delay: resolvedDelay\n }];\n}\nfunction executeRaise(actorScope, params) {\n const {\n event,\n delay,\n id\n } = params;\n if (typeof delay === 'number') {\n actorScope.defer(() => {\n const self = actorScope.self;\n actorScope.system.scheduler.schedule(self, self, event, delay, id);\n });\n return;\n }\n}\n/**\n * Raises an event. This places the event in the internal event queue, so that\n * the event is immediately consumed by the machine in the current step.\n *\n * @param eventType The event to raise.\n */\nfunction raise(eventOrExpr, options) {\n function raise(args, params) {\n }\n raise.type = 'xstate.raise';\n raise.event = eventOrExpr;\n raise.id = options?.id;\n raise.delay = options?.delay;\n raise.resolve = resolveRaise;\n raise.execute = executeRaise;\n return raise;\n}\n\nexport { $$ACTOR_TYPE as $, createActor as A, Actor as B, interpret as C, and as D, not as E, or as F, stateIn as G, isMachineSnapshot as H, getAllOwnEventDescriptors as I, matchesState as J, pathToStateValue as K, toObserver as L, cancel as M, NULL_EVENT as N, raise as O, spawnChild as P, stop as Q, stopChild as R, STATE_DELIMITER as S, ProcessingStatus as T, cloneMachineSnapshot as U, XSTATE_ERROR as V, createErrorActorEvent as W, XSTATE_STOP as X, toTransitionConfigArray as a, formatTransition as b, createInvokeId as c, formatInitialTransition as d, evaluateGuard as e, formatTransitions as f, getDelayedTransitions as g, getCandidates as h, getAllStateNodes as i, getStateNodes as j, createMachineSnapshot as k, isInFinalState as l, mapValues as m, macrostep as n, transitionNode as o, resolveActionsAndContext as p, createInitEvent as q, resolveStateValue as r, microstep as s, toArray as t, getInitialStateNodes as u, toStatePath as v, isStateId as w, getStateNodeByPath as x, getPersistedSnapshot as y, resolveReferencedActor as z };\n","import { T as ProcessingStatus, z as resolveReferencedActor, A as createActor, U as cloneMachineSnapshot, V as XSTATE_ERROR, W as createErrorActorEvent, e as evaluateGuard, M as cancel, O as raise, P as spawnChild, R as stopChild } from './raise-c0e3c984.esm.js';\n\nfunction createSpawner(actorScope, {\n machine,\n context\n}, event, spawnedChildren) {\n const spawn = (src, options = {}) => {\n const {\n systemId,\n input\n } = options;\n if (typeof src === 'string') {\n const logic = resolveReferencedActor(machine, src);\n if (!logic) {\n throw new Error(`Actor logic '${src}' not implemented in machine '${machine.id}'`);\n }\n const actorRef = createActor(logic, {\n id: options.id,\n parent: actorScope.self,\n syncSnapshot: options.syncSnapshot,\n input: typeof input === 'function' ? input({\n context,\n event,\n self: actorScope.self\n }) : input,\n src,\n systemId\n });\n spawnedChildren[actorRef.id] = actorRef;\n return actorRef;\n } else {\n const actorRef = createActor(src, {\n id: options.id,\n parent: actorScope.self,\n syncSnapshot: options.syncSnapshot,\n input: options.input,\n src,\n systemId\n });\n return actorRef;\n }\n };\n return (src, options) => {\n const actorRef = spawn(src, options); // TODO: fix types\n spawnedChildren[actorRef.id] = actorRef;\n actorScope.defer(() => {\n if (actorRef._processingStatus === ProcessingStatus.Stopped) {\n return;\n }\n actorRef.start();\n });\n return actorRef;\n };\n}\n\nfunction resolveAssign(actorScope, snapshot, actionArgs, actionParams, {\n assignment\n}) {\n if (!snapshot.context) {\n throw new Error('Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.');\n }\n const spawnedChildren = {};\n const assignArgs = {\n context: snapshot.context,\n event: actionArgs.event,\n spawn: createSpawner(actorScope, snapshot, actionArgs.event, spawnedChildren),\n self: actorScope.self,\n system: actorScope.system\n };\n let partialUpdate = {};\n if (typeof assignment === 'function') {\n partialUpdate = assignment(assignArgs, actionParams);\n } else {\n for (const key of Object.keys(assignment)) {\n const propAssignment = assignment[key];\n partialUpdate[key] = typeof propAssignment === 'function' ? propAssignment(assignArgs, actionParams) : propAssignment;\n }\n }\n const updatedContext = Object.assign({}, snapshot.context, partialUpdate);\n return [cloneMachineSnapshot(snapshot, {\n context: updatedContext,\n children: Object.keys(spawnedChildren).length ? {\n ...snapshot.children,\n ...spawnedChildren\n } : snapshot.children\n })];\n}\n/**\n * Updates the current context of the machine.\n *\n * @example\n *\n * ```ts\n * import { createMachine, assign } from 'xstate';\n *\n * const countMachine = createMachine({\n * context: {\n * count: 0,\n * message: ''\n * },\n * on: {\n * inc: {\n * actions: assign({\n * count: ({ context }) => context.count + 1\n * })\n * },\n * updateMessage: {\n * actions: assign(({ context, event }) => {\n * return {\n * message: event.message.trim()\n * };\n * })\n * }\n * }\n * });\n * ```\n *\n * @param assignment An object that represents the partial context to update, or\n * a function that returns an object that represents the partial context to\n * update.\n */\nfunction assign(assignment) {\n function assign(args, params) {\n }\n assign.type = 'xstate.assign';\n assign.assignment = assignment;\n assign.resolve = resolveAssign;\n return assign;\n}\n\nfunction resolveEmit(_, snapshot, args, actionParams, {\n event: eventOrExpr\n}) {\n const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args, actionParams) : eventOrExpr;\n return [snapshot, {\n event: resolvedEvent\n }];\n}\nfunction executeEmit(actorScope, {\n event\n}) {\n actorScope.defer(() => actorScope.emit(event));\n}\n/**\n * Emits an event to event handlers registered on the actor via `actor.on(event,\n * handler)`.\n *\n * @example\n *\n * ```ts\n * import { emit } from 'xstate';\n *\n * const machine = createMachine({\n * // ...\n * on: {\n * something: {\n * actions: emit({\n * type: 'emitted',\n * some: 'data'\n * })\n * }\n * }\n * // ...\n * });\n *\n * const actor = createActor(machine).start();\n *\n * actor.on('emitted', (event) => {\n * console.log(event);\n * });\n *\n * actor.send({ type: 'something' });\n * // logs:\n * // {\n * // type: 'emitted',\n * // some: 'data'\n * // }\n * ```\n */\nfunction emit( /** The event to emit, or an expression that returns an event to emit. */\neventOrExpr) {\n function emit(args, params) {\n }\n emit.type = 'xstate.emit';\n emit.event = eventOrExpr;\n emit.resolve = resolveEmit;\n emit.execute = executeEmit;\n return emit;\n}\n\n/**\n * @remarks\n * `T | unknown` reduces to `unknown` and that can be problematic when it comes\n * to contextual typing. It especially is a problem when the union has a\n * function member, like here:\n *\n * ```ts\n * declare function test(\n * cbOrVal: ((arg: number) => unknown) | unknown\n * ): void;\n * test((arg) => {}); // oops, implicit any\n * ```\n *\n * This type can be used to avoid this problem. This union represents the same\n * value space as `unknown`.\n */\n\n// https://github.com/microsoft/TypeScript/issues/23182#issuecomment-379091887\n\n// @TODO: Replace with native `NoInfer` when TS issue gets fixed:\n// https://github.com/microsoft/TypeScript/pull/57673\n/** @deprecated Use the built-in `NoInfer` type instead */\n/** The full definition of an event, with a string `type`. */\n/**\n * The string or object representing the state value relative to the parent\n * state node.\n *\n * @remarks\n * - For a child atomic state node, this is a string, e.g., `\"pending\"`.\n * - For complex state nodes, this is an object, e.g., `{ success:\n * \"someChildState\" }`.\n */\n// TODO: remove once TS fixes this type-widening issue\n/** @deprecated Use `AnyMachineSnapshot` instead */\n// TODO: possibly refactor this somehow, use even a simpler type, and maybe even make `machine.options` private or something\n/** @ignore */\nlet SpecialTargets = /*#__PURE__*/function (SpecialTargets) {\n SpecialTargets[\"Parent\"] = \"#_parent\";\n SpecialTargets[\"Internal\"] = \"#_internal\";\n return SpecialTargets;\n}({});\n\n/** @deprecated Use `AnyActor` instead. */\n\n// Based on RxJS types\n\n// TODO: in v6, this should only accept AnyActorLogic, like ActorRefFromLogic\n\n/** @deprecated Use `Actor<T>` instead. */\n\n/**\n * Represents logic which can be used by an actor.\n *\n * @template TSnapshot - The type of the snapshot.\n * @template TEvent - The type of the event object.\n * @template TInput - The type of the input.\n * @template TSystem - The type of the actor system.\n */\n\n/** @deprecated */\n\nfunction resolveSendTo(actorScope, snapshot, args, actionParams, {\n to,\n event: eventOrExpr,\n id,\n delay\n}, extra) {\n const delaysMap = snapshot.machine.implementations.delays;\n if (typeof eventOrExpr === 'string') {\n throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: \"${eventOrExpr}\" }) instead`);\n }\n const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args, actionParams) : eventOrExpr;\n let resolvedDelay;\n if (typeof delay === 'string') {\n const configDelay = delaysMap && delaysMap[delay];\n resolvedDelay = typeof configDelay === 'function' ? configDelay(args, actionParams) : configDelay;\n } else {\n resolvedDelay = typeof delay === 'function' ? delay(args, actionParams) : delay;\n }\n const resolvedTarget = typeof to === 'function' ? to(args, actionParams) : to;\n let targetActorRef;\n if (typeof resolvedTarget === 'string') {\n if (resolvedTarget === SpecialTargets.Parent) {\n targetActorRef = actorScope.self._parent;\n } else if (resolvedTarget === SpecialTargets.Internal) {\n targetActorRef = actorScope.self;\n } else if (resolvedTarget.startsWith('#_')) {\n // SCXML compatibility: https://www.w3.org/TR/scxml/#SCXMLEventProcessor\n // #_invokeid. If the target is the special term '#_invokeid', where invokeid is the invokeid of an SCXML session that the sending session has created by <invoke>, the Processor must add the event to the external queue of that session.\n targetActorRef = snapshot.children[resolvedTarget.slice(2)];\n } else {\n targetActorRef = extra.deferredActorIds?.includes(resolvedTarget) ? resolvedTarget : snapshot.children[resolvedTarget];\n }\n if (!targetActorRef) {\n throw new Error(`Unable to send event to actor '${resolvedTarget}' from machine '${snapshot.machine.id}'.`);\n }\n } else {\n targetActorRef = resolvedTarget || actorScope.self;\n }\n return [snapshot, {\n to: targetActorRef,\n event: resolvedEvent,\n id,\n delay: resolvedDelay\n }];\n}\nfunction retryResolveSendTo(_, snapshot, params) {\n if (typeof params.to === 'string') {\n params.to = snapshot.children[params.to];\n }\n}\nfunction executeSendTo(actorScope, params) {\n // this forms an outgoing events queue\n // thanks to that the recipient actors are able to read the *updated* snapshot value of the sender\n actorScope.defer(() => {\n const {\n to,\n event,\n delay,\n id\n } = params;\n if (typeof delay === 'number') {\n actorScope.system.scheduler.schedule(actorScope.self, to, event, delay, id);\n return;\n }\n actorScope.system._relay(actorScope.self,\n // at this point, in a deferred task, it should already be mutated by retryResolveSendTo\n // if it initially started as a string\n to, event.type === XSTATE_ERROR ? createErrorActorEvent(actorScope.self.id, event.data) : event);\n });\n}\n/**\n * Sends an event to an actor.\n *\n * @param actor The `ActorRef` to send the event to.\n * @param event The event to send, or an expression that evaluates to the event\n * to send\n * @param options Send action options\n *\n * - `id` - The unique send event identifier (used with `cancel()`).\n * - `delay` - The number of milliseconds to delay the sending of the event.\n */\nfunction sendTo(to, eventOrExpr, options) {\n function sendTo(args, params) {\n }\n sendTo.type = 'xsnapshot.sendTo';\n sendTo.to = to;\n sendTo.event = eventOrExpr;\n sendTo.id = options?.id;\n sendTo.delay = options?.delay;\n sendTo.resolve = resolveSendTo;\n sendTo.retryResolve = retryResolveSendTo;\n sendTo.execute = executeSendTo;\n return sendTo;\n}\n\n/**\n * Sends an event to this machine's parent.\n *\n * @param event The event to send to the parent machine.\n * @param options Options to pass into the send event.\n */\nfunction sendParent(event, options) {\n return sendTo(SpecialTargets.Parent, event, options);\n}\n/**\n * Forwards (sends) an event to the `target` actor.\n *\n * @param target The target actor to forward the event to.\n * @param options Options to pass into the send action creator.\n */\nfunction forwardTo(target, options) {\n return sendTo(target, ({\n event\n }) => event, options);\n}\n\nfunction resolveEnqueueActions(actorScope, snapshot, args, actionParams, {\n collect\n}) {\n const actions = [];\n const enqueue = function enqueue(action) {\n actions.push(action);\n };\n enqueue.assign = (...args) => {\n actions.push(assign(...args));\n };\n enqueue.cancel = (...args) => {\n actions.push(cancel(...args));\n };\n enqueue.raise = (...args) => {\n // for some reason it fails to infer `TDelay` from `...args` here and picks its default (`never`)\n // then it fails to typecheck that because `...args` use `string` in place of `TDelay`\n actions.push(raise(...args));\n };\n enqueue.sendTo = (...args) => {\n // for some reason it fails to infer `TDelay` from `...args` here and picks its default (`never`)\n // then it fails to typecheck that because `...args` use `string` in place of `TDelay\n actions.push(sendTo(...args));\n };\n enqueue.sendParent = (...args) => {\n actions.push(sendParent(...args));\n };\n enqueue.spawnChild = (...args) => {\n actions.push(spawnChild(...args));\n };\n enqueue.stopChild = (...args) => {\n actions.push(stopChild(...args));\n };\n enqueue.emit = (...args) => {\n actions.push(emit(...args));\n };\n collect({\n context: args.context,\n event: args.event,\n enqueue,\n check: guard => evaluateGuard(guard, snapshot.context, args.event, snapshot),\n self: actorScope.self,\n system: actorScope.system\n }, actionParams);\n return [snapshot, undefined, actions];\n}\n/**\n * Creates an action object that will execute actions that are queued by the\n * `enqueue(action)` function.\n *\n * @example\n *\n * ```ts\n * import { createMachine, enqueueActions } from 'xstate';\n *\n * const machine = createMachine({\n * entry: enqueueActions(({ enqueue, check }) => {\n * enqueue.assign({ count: 0 });\n *\n * if (check('someGuard')) {\n * enqueue.assign({ count: 1 });\n * }\n *\n * enqueue('someAction');\n * })\n * });\n * ```\n */\nfunction enqueueActions(collect) {\n function enqueueActions(args, params) {\n }\n enqueueActions.type = 'xstate.enqueueActions';\n enqueueActions.collect = collect;\n enqueueActions.resolve = resolveEnqueueActions;\n return enqueueActions;\n}\n\nfunction resolveLog(_, snapshot, actionArgs, actionParams, {\n value,\n label\n}) {\n return [snapshot, {\n value: typeof value === 'function' ? value(actionArgs, actionParams) : value,\n label\n }];\n}\nfunction executeLog({\n logger\n}, {\n value,\n label\n}) {\n if (label) {\n logger(label, value);\n } else {\n logger(value);\n }\n}\n/**\n * @param expr The expression function to evaluate which will be logged. Takes\n * in 2 arguments:\n *\n * - `ctx` - the current state context\n * - `event` - the event that caused this action to be executed.\n *\n * @param label The label to give to the logged expression.\n */\nfunction log(value = ({\n context,\n event\n}) => ({\n context,\n event\n}), label) {\n function log(args, params) {\n }\n log.type = 'xstate.log';\n log.value = value;\n log.label = label;\n log.resolve = resolveLog;\n log.execute = executeLog;\n return log;\n}\n\nexport { SpecialTargets as S, assign as a, enqueueActions as b, sendTo as c, emit as e, forwardTo as f, log as l, sendParent as s };\n","export { createEmptyActor, fromCallback, fromEventObservable, fromObservable, fromPromise, fromTransition } from '../actors/dist/xstate-actors.esm.js';\nimport { t as toArray, S as STATE_DELIMITER, m as mapValues, f as formatTransitions, a as toTransitionConfigArray, b as formatTransition, N as NULL_EVENT, e as evaluateGuard, c as createInvokeId, g as getDelayedTransitions, d as formatInitialTransition, h as getCandidates, r as resolveStateValue, i as getAllStateNodes, j as getStateNodes, k as createMachineSnapshot, l as isInFinalState, n as macrostep, o as transitionNode, p as resolveActionsAndContext, q as createInitEvent, s as microstep, u as getInitialStateNodes, v as toStatePath, w as isStateId, x as getStateNodeByPath, y as getPersistedSnapshot, z as resolveReferencedActor, A as createActor, $ as $$ACTOR_TYPE } from './raise-c0e3c984.esm.js';\nexport { B as Actor, I as __unsafe_getAllOwnEventDescriptors, D as and, M as cancel, A as createActor, j as getStateNodes, C as interpret, H as isMachineSnapshot, J as matchesState, E as not, F as or, K as pathToStateValue, O as raise, P as spawnChild, G as stateIn, Q as stop, R as stopChild, L as toObserver } from './raise-c0e3c984.esm.js';\nimport { a as assign } from './log-a2c94240.esm.js';\nexport { S as SpecialTargets, a as assign, e as emit, b as enqueueActions, f as forwardTo, l as log, s as sendParent, c as sendTo } from './log-a2c94240.esm.js';\nimport '../dev/dist/xstate-dev.esm.js';\n\n/**\n * Asserts that the given event object is of the specified type or types. Throws\n * an error if the event object is not of the specified types.\n *\n * @example\n *\n * ```ts\n * // ...\n * entry: ({ event }) => {\n * assertEvent(event, 'doNothing');\n * // event is { type: 'doNothing' }\n * },\n * // ...\n * exit: ({ event }) => {\n * assertEvent(event, 'greet');\n * // event is { type: 'greet'; message: string }\n *\n * assertEvent(event, ['greet', 'notify']);\n * // event is { type: 'greet'; message: string }\n * // or { type: 'notify'; message: string; level: 'info' | 'error' }\n * },\n * ```\n */\nfunction assertEvent(event, type) {\n const types = toArray(type);\n if (!types.includes(event.type)) {\n const typesText = types.length === 1 ? `type \"${types[0]}\"` : `one of types \"${types.join('\", \"')}\"`;\n throw new Error(`Expected event ${JSON.stringify(event)} to have ${typesText}`);\n }\n}\n\nconst cache = new WeakMap();\nfunction memo(object, key, fn) {\n let memoizedData = cache.get(object);\n if (!memoizedData) {\n memoizedData = {\n [key]: fn()\n };\n cache.set(object, memoizedData);\n } else if (!(key in memoizedData)) {\n memoizedData[key] = fn();\n }\n return memoizedData[key];\n}\n\nconst EMPTY_OBJECT = {};\nconst toSerializableAction = action => {\n if (typeof action === 'string') {\n return {\n type: action\n };\n }\n if (typeof action === 'function') {\n if ('resolve' in action) {\n return {\n type: action.type\n };\n }\n return {\n type: action.name\n };\n }\n return action;\n};\nclass StateNode {\n constructor( /** The raw config used to create the machine. */\n config, options) {\n this.config = config;\n /**\n * The relative key of the state node, which represents its location in the\n * overall state value.\n */\n this.key = void 0;\n /** The unique ID of the state node. */\n this.id = void 0;\n /**\n * The type of this state node:\n *\n * - `'atomic'` - no child state nodes\n * - `'compound'` - nested child state nodes (XOR)\n * - `'parallel'` - orthogonal nested child state nodes (AND)\n * - `'history'` - history state node\n * - `'final'` - final state node\n */\n this.type = void 0;\n /** The string path from the root machine node to this node. */\n this.path = void 0;\n /** The child state nodes. */\n this.states = void 0;\n /**\n * The type of history on this state node. Can be:\n *\n * - `'shallow'` - recalls only top-level historical state value\n * - `'deep'` - recalls historical state value at all levels\n */\n this.history = void 0;\n /** The action(s) to be executed upon entering the state node. */\n this.entry = void 0;\n /** The action(s) to be executed upon exiting the state node. */\n this.exit = void 0;\n /** The parent state node. */\n this.parent = void 0;\n /** The root machine node. */\n this.machine = void 0;\n /**\n * The meta data associated with this state node, which will be returned in\n * State instances.\n */\n this.meta = void 0;\n /**\n * The output data sent with the \"xstate.done.state._id_\" event if this is a\n * final state node.\n */\n this.output = void 0;\n /**\n * The order this state node appears. Corresponds to the implicit document\n * order.\n */\n this.order = -1;\n this.description = void 0;\n this.tags = [];\n this.transitions = void 0;\n this.always = void 0;\n this.parent = options._parent;\n this.key = options._key;\n this.machine = options._machine;\n this.path = this.parent ? this.parent.path.concat(this.key) : [];\n this.id = this.config.id || [this.machine.id, ...this.path].join(STATE_DELIMITER);\n this.type = this.config.type || (this.config.states && Object.keys(this.config.states).length ? 'compound' : this.config.history ? 'history' : 'atomic');\n this.description = this.config.description;\n this.order = this.machine.idMap.size;\n this.machine.idMap.set(this.id, this);\n this.states = this.config.states ? mapValues(this.config.states, (stateConfig, key) => {\n const stateNode = new StateNode(stateConfig, {\n _parent: this,\n _key: key,\n _machine: this.machine\n });\n return stateNode;\n }) : EMPTY_OBJECT;\n if (this.type === 'compound' && !this.config.initial) {\n throw new Error(`No initial state specified for compound state node \"#${this.id}\". Try adding { initial: \"${Object.keys(this.states)[0]}\" } to the state config.`);\n }\n\n // History config\n this.history = this.config.history === true ? 'shallow' : this.config.history || false;\n this.entry = toArray(this.config.entry).slice();\n this.exit = toArray(this.config.exit).slice();\n this.meta = this.config.meta;\n this.output = this.type === 'final' || !this.parent ? this.config.output : undefined;\n this.tags = toArray(config.tags).slice();\n }\n\n /** @internal */\n _initialize() {\n this.transitions = formatTransitions(this);\n if (this.config.always) {\n this.always = toTransitionConfigArray(this.config.always).map(t => formatTransition(this, NULL_EVENT, t));\n }\n Object.keys(this.states).forEach(key => {\n this.states[key]._initialize();\n });\n }\n\n /** The well-structured state node definition. */\n get definition() {\n return {\n id: this.id,\n key: this.key,\n version: this.machine.version,\n type: this.type,\n initial: this.initial ? {\n target: this.initial.target,\n source: this,\n actions: this.initial.actions.map(toSerializableAction),\n eventType: null,\n reenter: false,\n toJSON: () => ({\n target: this.initial.target.map(t => `#${t.id}`),\n source: `#${this.id}`,\n actions: this.initial.actions.map(toSerializableAction),\n eventType: null\n })\n } : undefined,\n history: this.history,\n states: mapValues(this.states, state => {\n return state.definition;\n }),\n on: this.on,\n transitions: [...this.transitions.values()].flat().map(t => ({\n ...t,\n actions: t.actions.map(toSerializableAction)\n })),\n entry: this.entry.map(toSerializableAction),\n exit: this.exit.map(toSerializableAction),\n meta: this.meta,\n order: this.order || -1,\n output: this.output,\n invoke: this.invoke,\n description: this.description,\n tags: this.tags\n };\n }\n\n /** @internal */\n toJSON() {\n return this.definition;\n }\n\n /** The logic invoked as actors by this state node. */\n get invoke() {\n return memo(this, 'invoke', () => toArray(this.config.invoke).map((invokeConfig, i) => {\n const {\n src,\n systemId\n } = invokeConfig;\n const resolvedId = invokeConfig.id ?? createInvokeId(this.id, i);\n const resolvedSrc = typeof src === 'string' ? src : `xstate.invoke.${createInvokeId(this.id, i)}`;\n return {\n ...invokeConfig,\n src: resolvedSrc,\n id: resolvedId,\n systemId: systemId,\n toJSON() {\n const {\n onDone,\n onError,\n ...invokeDefValues\n } = invokeConfig;\n return {\n ...invokeDefValues,\n type: 'xstate.invoke',\n src: resolvedSrc,\n id: resolvedId\n };\n }\n };\n }));\n }\n\n /** The mapping of events to transitions. */\n get on() {\n return memo(this, 'on', () => {\n const transitions = this.transitions;\n return [...transitions].flatMap(([descriptor, t]) => t.map(t => [descriptor, t])).reduce((map, [descriptor, transition]) => {\n map[descriptor] = map[descriptor] || [];\n map[descriptor].push(transition);\n return map;\n }, {});\n });\n }\n get after() {\n return memo(this, 'delayedTransitions', () => getDelayedTransitions(this));\n }\n get initial() {\n return memo(this, 'initial', () => formatInitialTransition(this, this.config.initial));\n }\n\n /** @internal */\n next(snapshot, event) {\n const eventType = event.type;\n const actions = [];\n let selectedTransition;\n const candidates = memo(this, `candidates-${eventType}`, () => getCandidates(this, eventType));\n for (const candidate of candidates) {\n const {\n guard\n } = candidate;\n const resolvedContext = snapshot.context;\n let guardPassed = false;\n try {\n guardPassed = !guard || evaluateGuard(guard, resolvedContext, event, snapshot);\n } catch (err) {\n const guardType = typeof guard === 'string' ? guard : typeof guard === 'object' ? guard.type : undefined;\n throw new Error(`Unable to evaluate guard ${guardType ? `'${guardType}' ` : ''}in transition for event '${eventType}' in state node '${this.id}':\\n${err.message}`);\n }\n if (guardPassed) {\n actions.push(...candidate.actions);\n selectedTransition = candidate;\n break;\n }\n }\n return selectedTransition ? [selectedTransition] : undefined;\n }\n\n /** All the event types accepted by this state node and its descendants. */\n get events() {\n return memo(this, 'events', () => {\n const {\n states\n } = this;\n const events = new Set(this.ownEvents);\n if (states) {\n for (const stateId of Object.keys(states)) {\n const state = states[stateId];\n if (state.states) {\n for (const event of state.events) {\n events.add(`${event}`);\n }\n }\n }\n }\n return Array.from(events);\n });\n }\n\n /**\n * All the events that have transitions directly from this state node.\n *\n * Excludes any inert events.\n */\n get ownEvents() {\n const events = new Set([...this.transitions.keys()].filter(descriptor => {\n return this.transitions.get(descriptor).some(transition => !(!transition.target && !transition.actions.length && !transition.reenter));\n }));\n return Array.from(events);\n }\n}\n\nconst STATE_IDENTIFIER = '#';\nclass StateMachine {\n constructor( /** The raw config used to create the machine. */\n config, implementations) {\n this.config = config;\n /** The machine's own version. */\n this.version = void 0;\n this.schemas = void 0;\n this.implementations = void 0;\n /** @internal */\n this.__xstatenode = true;\n /** @internal */\n this.idMap = new Map();\n this.root = void 0;\n this.id = void 0;\n this.states = void 0;\n this.events = void 0;\n this.id = config.id || '(machine)';\n this.implementations = {\n actors: implementations?.actors ?? {},\n actions: implementations?.actions ?? {},\n delays: implementations?.delays ?? {},\n guards: implementations?.guards ?? {}\n };\n this.version = this.config.version;\n this.schemas = this.config.schemas;\n this.transition = this.transition.bind(this);\n this.getInitialSnapshot = this.getInitialSnapshot.bind(this);\n this.getPersistedSnapshot = this.getPersistedSnapshot.bind(this);\n this.restoreSnapshot = this.restoreSnapshot.bind(this);\n this.start = this.start.bind(this);\n this.root = new StateNode(config, {\n _key: this.id,\n _machine: this\n });\n this.root._initialize();\n this.states = this.root.states; // TODO: remove!\n this.events = this.root.events;\n }\n\n /**\n * Clones this state machine with the provided implementations and merges the\n * `context` (if provided).\n *\n * @param implementations Options (`actions`, `guards`, `actors`, `delays`,\n * `context`) to recursively merge with the existing options.\n * @returns A new `StateMachine` instance with the provided implementations.\n */\n provide(implementations) {\n const {\n actions,\n guards,\n actors,\n delays\n } = this.implementations;\n return new StateMachine(this.config, {\n actions: {\n ...actions,\n ...implementations.actions\n },\n guards: {\n ...guards,\n ...implementations.guards\n },\n actors: {\n ...actors,\n ...implementations.actors\n },\n delays: {\n ...delays,\n ...implementations.delays\n }\n });\n }\n resolveState(config) {\n const resolvedStateValue = resolveStateValue(this.root, config.value);\n const nodeSet = getAllStateNodes(getStateNodes(this.root, resolvedStateValue));\n return createMachineSnapshot({\n _nodes: [...nodeSet],\n context: config.context || {},\n children: {},\n status: isInFinalState(nodeSet, this.root) ? 'done' : config.status || 'active',\n output: config.output,\n error: config.error,\n historyValue: config.historyValue\n }, this);\n }\n\n /**\n * Determines the next snapshot given the current `snapshot` and received\n * `event`. Calculates a full macrostep from all microsteps.\n *\n * @param snapshot The current snapshot\n * @param event The received event\n */\n transition(snapshot, event, actorScope) {\n return macrostep(snapshot, event, actorScope).snapshot;\n }\n\n /**\n * Determines the next state given the current `state` and `event`. Calculates\n * a microstep.\n *\n * @param state The current state\n * @param event The received event\n */\n microstep(snapshot, event, actorScope) {\n return macrostep(snapshot, event, actorScope).microstates;\n }\n getTransitionData(snapshot, event) {\n return transitionNode(this.root, snapshot.value, snapshot, event) || [];\n }\n\n /**\n * The initial state _before_ evaluating any microsteps. This \"pre-initial\"\n * state is provided to initial actions executed in the initial state.\n */\n getPreInitialState(actorScope, initEvent, internalQueue) {\n const {\n context\n } = this.config;\n const preInitial = createMachineSnapshot({\n context: typeof context !== 'function' && context ? context : {},\n _nodes: [this.root],\n children: {},\n status: 'active'\n }, this);\n if (typeof context === 'function') {\n const assignment = ({\n spawn,\n event,\n self\n }) => context({\n spawn,\n input: event.input,\n self\n });\n return resolveActionsAndContext(preInitial, initEvent, actorScope, [assign(assignment)], internalQueue);\n }\n return preInitial;\n }\n\n /**\n * Returns the initial `State` instance, with reference to `self` as an\n * `ActorRef`.\n */\n getInitialSnapshot(actorScope, input) {\n const initEvent = createInitEvent(input); // TODO: fix;\n const internalQueue = [];\n const preInitialState = this.getPreInitialState(actorScope, initEvent, internalQueue);\n const nextState = microstep([{\n target: [...getInitialStateNodes(this.root)],\n source: this.root,\n reenter: true,\n actions: [],\n eventType: null,\n toJSON: null // TODO: fix\n }], preInitialState, actorScope, initEvent, true, internalQueue);\n const {\n snapshot: macroState\n } = macrostep(nextState, initEvent, actorScope, internalQueue);\n return macroState;\n }\n start(snapshot) {\n Object.values(snapshot.children).forEach(child => {\n if (child.getSnapshot().status === 'active') {\n child.start();\n }\n });\n }\n getStateNodeById(stateId) {\n const fullPath = toStatePath(stateId);\n const relativePath = fullPath.slice(1);\n const resolvedStateId = isStateId(fullPath[0]) ? fullPath[0].slice(STATE_IDENTIFIER.length) : fullPath[0];\n const stateNode = this.idMap.get(resolvedStateId);\n if (!stateNode) {\n throw new Error(`Child state node '#${resolvedStateId}' does not exist on machine '${this.id}'`);\n }\n return getStateNodeByPath(stateNode, relativePath);\n }\n get definition() {\n return this.root.definition;\n }\n toJSON() {\n return this.definition;\n }\n getPersistedSnapshot(snapshot, options) {\n return getPersistedSnapshot(snapshot, options);\n }\n restoreSnapshot(snapshot, _actorScope) {\n const children = {};\n const snapshotChildren = snapshot.children;\n Object.keys(snapshotChildren).forEach(actorId => {\n const actorData = snapshotChildren[actorId];\n const childState = actorData.snapshot;\n const src = actorData.src;\n const logic = typeof src === 'string' ? resolveReferencedActor(this, src) : src;\n if (!logic) {\n return;\n }\n const actorRef = createActor(logic, {\n id: actorId,\n parent: _actorScope.self,\n syncSnapshot: actorData.syncSnapshot,\n snapshot: childState,\n src,\n systemId: actorData.systemId\n });\n children[actorId] = actorRef;\n });\n const restoredSnapshot = createMachineSnapshot({\n ...snapshot,\n children,\n _nodes: Array.from(getAllStateNodes(getStateNodes(this.root, snapshot.value)))\n }, this);\n let seen = new Set();\n function reviveContext(contextPart, children) {\n if (seen.has(contextPart)) {\n return;\n }\n seen.add(contextPart);\n for (let key in contextPart) {\n const value = contextPart[key];\n if (value && typeof value === 'object') {\n if ('xstate$$type' in value && value.xstate$$type === $$ACTOR_TYPE) {\n contextPart[key] = children[value.id];\n continue;\n }\n reviveContext(value, children);\n }\n }\n }\n reviveContext(restoredSnapshot.context, children);\n return restoredSnapshot;\n }\n}\n\n// this is not 100% accurate since we can't make parallel regions required in the result\n// `TTestValue` doesn't encode this information anyhow for us to be able to do that\n// this is fine for most practical use cases anyway though\n/**\n * Creates a state machine (statechart) with the given configuration.\n *\n * The state machine represents the pure logic of a state machine actor.\n *\n * @example\n *\n * ```ts\n * import { createMachine } from 'xstate';\n *\n * const lightMachine = createMachine({\n * id: 'light',\n * initial: 'green',\n * states: {\n * green: {\n * on: {\n * TIMER: { target: 'yellow' }\n * }\n * },\n * yellow: {\n * on: {\n * TIMER: { target: 'red' }\n * }\n * },\n * red: {\n * on: {\n * TIMER: { target: 'green' }\n * }\n * }\n * }\n * });\n *\n * const lightActor = createActor(lightMachine);\n * lightActor.start();\n *\n * lightActor.send({ type: 'TIMER' });\n * ```\n *\n * @param config The state machine configuration.\n * @param options DEPRECATED: use `setup({ ... })` or `machine.provide({ ... })`\n * to provide machine implementations instead.\n */\nfunction createMachine(config, implementations) {\n return new StateMachine(config, implementations);\n}\n\n/** @internal */\nfunction createInertActorScope(actorLogic) {\n const self = createActor(actorLogic);\n const inertActorScope = {\n self,\n defer: () => {},\n id: '',\n logger: () => {},\n sessionId: '',\n stopChild: () => {},\n system: self.system,\n emit: () => {}\n };\n return inertActorScope;\n}\nfunction getInitialSnapshot(actorLogic, ...[input]) {\n const actorScope = createInertActorScope(actorLogic);\n return actorLogic.getInitialSnapshot(actorScope, input);\n}\n\n/**\n * Determines the next snapshot for the given `actorLogic` based on the given\n * `snapshot` and `event`.\n *\n * If the `snapshot` is `undefined`, the initial snapshot of the `actorLogic` is\n * used.\n *\n * @example\n *\n * ```ts\n * import { getNextSnapshot } from 'xstate';\n * import { trafficLightMachine } from './trafficLightMachine.ts';\n *\n * const nextSnapshot = getNextSnapshot(\n * trafficLightMachine, // actor logic\n * undefined, // snapshot (or initial state if undefined)\n * { type: 'TIMER' }\n * ); // event object\n *\n * console.log(nextSnapshot.value);\n * // => 'yellow'\n *\n * const nextSnapshot2 = getNextSnapshot(\n * trafficLightMachine, // actor logic\n * nextSnapshot, // snapshot\n * { type: 'TIMER' }\n * ); // event object\n *\n * console.log(nextSnapshot2.value);\n * // =>'red'\n * ```\n */\nfunction getNextSnapshot(actorLogic, snapshot, event) {\n const inertActorScope = createInertActorScope(actorLogic);\n inertActorScope.self._snapshot = snapshot;\n return actorLogic.transition(snapshot, event, inertActorScope);\n}\n\n// at the moment we allow extra actors - ones that are not specified by `children`\n// this could be reconsidered in the future\nfunction setup({\n schemas,\n actors,\n actions,\n guards,\n delays\n}) {\n return {\n createMachine: config => createMachine({\n ...config,\n schemas\n }, {\n actors,\n actions,\n guards,\n delays\n })\n };\n}\n\nclass SimulatedClock {\n constructor() {\n this.timeouts = new Map();\n this._now = 0;\n this._id = 0;\n this._flushing = false;\n this._flushingInvalidated = false;\n }\n now() {\n return this._now;\n }\n getId() {\n return this._id++;\n }\n setTimeout(fn, timeout) {\n this._flushingInvalidated = this._flushing;\n const id = this.getId();\n this.timeouts.set(id, {\n start: this.now(),\n timeout,\n fn\n });\n return id;\n }\n clearTimeout(id) {\n this._flushingInvalidated = this._flushing;\n this.timeouts.delete(id);\n }\n set(time) {\n if (this._now > time) {\n throw new Error('Unable to travel back in time');\n }\n this._now = time;\n this.flushTimeouts();\n }\n flushTimeouts() {\n if (this._flushing) {\n this._flushingInvalidated = true;\n return;\n }\n this._flushing = true;\n const sorted = [...this.timeouts].sort(([_idA, timeoutA], [_idB, timeoutB]) => {\n const endA = timeoutA.start + timeoutA.timeout;\n const endB = timeoutB.start + timeoutB.timeout;\n return endB > endA ? -1 : 1;\n });\n for (const [id, timeout] of sorted) {\n if (this._flushingInvalidated) {\n this._flushingInvalidated = false;\n this._flushing = false;\n this.flushTimeouts();\n return;\n }\n if (this.now() - timeout.start >= timeout.timeout) {\n this.timeouts.delete(id);\n timeout.fn.call(null);\n }\n }\n this._flushing = false;\n }\n increment(ms) {\n this._now += ms;\n this.flushTimeouts();\n }\n}\n\n/**\n * Returns a promise that resolves to the `output` of the actor when it is done.\n *\n * @example\n *\n * ```ts\n * const machine = createMachine({\n * // ...\n * output: {\n * count: 42\n * }\n * });\n *\n * const actor = createActor(machine);\n *\n * actor.start();\n *\n * const output = await toPromise(actor);\n *\n * console.log(output);\n * // logs { count: 42 }\n * ```\n */\nfunction toPromise(actor) {\n return new Promise((resolve, reject) => {\n actor.subscribe({\n complete: () => {\n resolve(actor.getSnapshot().output);\n },\n error: reject\n });\n });\n}\n\nconst defaultWaitForOptions = {\n timeout: Infinity // much more than 10 seconds\n};\n\n/**\n * Subscribes to an actor ref and waits for its emitted value to satisfy a\n * predicate, and then resolves with that value. Will throw if the desired state\n * is not reached after an optional timeout. (defaults to Infinity).\n *\n * @example\n *\n * ```js\n * const state = await waitFor(someService, (state) => {\n * return state.hasTag('loaded');\n * });\n *\n * state.hasTag('loaded'); // true\n * ```\n *\n * @param actorRef The actor ref to subscribe to\n * @param predicate Determines if a value matches the condition to wait for\n * @param options\n * @returns A promise that eventually resolves to the emitted value that matches\n * the condition\n */\nfunction waitFor(actorRef, predicate, options) {\n const resolvedOptions = {\n ...defaultWaitForOptions,\n ...options\n };\n return new Promise((res, rej) => {\n const {\n signal\n } = resolvedOptions;\n if (signal?.aborted) {\n rej(signal.reason);\n return;\n }\n let done = false;\n const handle = resolvedOptions.timeout === Infinity ? undefined : setTimeout(() => {\n dispose();\n rej(new Error(`Timeout of ${resolvedOptions.timeout} ms exceeded`));\n }, resolvedOptions.timeout);\n const dispose = () => {\n clearTimeout(handle);\n done = true;\n sub?.unsubscribe();\n if (abortListener) {\n signal.removeEventListener('abort', abortListener);\n }\n };\n function checkEmitted(emitted) {\n if (predicate(emitted)) {\n dispose();\n res(emitted);\n }\n }\n\n /**\n * If the `signal` option is provided, this will be the listener for its\n * `abort` event\n */\n let abortListener;\n let sub; // avoid TDZ when disposing synchronously\n\n // See if the current snapshot already matches the predicate\n checkEmitted(actorRef.getSnapshot());\n if (done) {\n return;\n }\n\n // only define the `abortListener` if the `signal` option is provided\n if (signal) {\n abortListener = () => {\n dispose();\n // XState does not \"own\" the signal, so we should reject with its reason (if any)\n rej(signal.reason);\n };\n signal.addEventListener('abort', abortListener);\n }\n sub = actorRef.subscribe({\n next: checkEmitted,\n error: err => {\n dispose();\n rej(err);\n },\n complete: () => {\n dispose();\n rej(new Error(`Actor terminated without satisfying predicate`));\n }\n });\n if (done) {\n sub.unsubscribe();\n }\n });\n}\n\nexport { SimulatedClock, StateMachine, StateNode, assertEvent, createMachine, getInitialSnapshot, getNextSnapshot, setup, toPromise, waitFor };\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.isBytes = isBytes;\nexports.number = number;\nexports.bool = bool;\nexports.bytes = bytes;\nexports.hash = hash;\nexports.exists = exists;\nexports.output = output;\nfunction number(n) {\n if (!Number.isSafeInteger(n) || n < 0)\n throw new Error(`positive integer expected, not ${n}`);\n}\nfunction bool(b) {\n if (typeof b !== 'boolean')\n throw new Error(`boolean expected, not ${b}`);\n}\n// copied from utils\nfunction isBytes(a) {\n return (a instanceof Uint8Array ||\n (a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));\n}\nfunction bytes(b, ...lengths) {\n if (!isBytes(b))\n throw new Error('Uint8Array expected');\n if (lengths.length > 0 && !lengths.includes(b.length))\n throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`);\n}\nfunction hash(h) {\n if (typeof h !== 'function' || typeof h.create !== 'function')\n throw new Error('Hash should be wrapped by utils.wrapConstructor');\n number(h.outputLen);\n number(h.blockLen);\n}\nfunction exists(instance, checkFinished = true) {\n if (instance.destroyed)\n throw new Error('Hash instance has been destroyed');\n if (checkFinished && instance.finished)\n throw new Error('Hash#digest() has already been called');\n}\nfunction output(out, instance) {\n bytes(out);\n const min = instance.outputLen;\n if (out.length < min) {\n throw new Error(`digestInto() expects output buffer of length at least ${min}`);\n }\n}\nconst assert = { number, bool, bytes, hash, exists, output };\nexports.default = assert;\n//# sourceMappingURL=_assert.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.crypto = void 0;\nexports.crypto = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;\n//# sourceMappingURL=crypto.js.map","\"use strict\";\n/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Hash = exports.nextTick = exports.byteSwapIfBE = exports.byteSwap = exports.isLE = exports.rotl = exports.rotr = exports.createView = exports.u32 = exports.u8 = void 0;\nexports.isBytes = isBytes;\nexports.byteSwap32 = byteSwap32;\nexports.bytesToHex = bytesToHex;\nexports.hexToBytes = hexToBytes;\nexports.asyncLoop = asyncLoop;\nexports.utf8ToBytes = utf8ToBytes;\nexports.toBytes = toBytes;\nexports.concatBytes = concatBytes;\nexports.checkOpts = checkOpts;\nexports.wrapConstructor = wrapConstructor;\nexports.wrapConstructorWithOpts = wrapConstructorWithOpts;\nexports.wrapXOFConstructorWithOpts = wrapXOFConstructorWithOpts;\nexports.randomBytes = randomBytes;\n// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.\n// node.js versions earlier than v19 don't declare it in global scope.\n// For node.js, package.json#exports field mapping rewrites import\n// from `crypto` to `cryptoNode`, which imports native module.\n// Makes the utils un-importable in browsers without a bundler.\n// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.\nconst crypto_1 = require(\"@noble/hashes/crypto\");\nconst _assert_js_1 = require(\"./_assert.js\");\n// export { isBytes } from './_assert.js';\n// We can't reuse isBytes from _assert, because somehow this causes huge perf issues\nfunction isBytes(a) {\n return (a instanceof Uint8Array ||\n (a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));\n}\n// Cast array to different type\nconst u8 = (arr) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);\nexports.u8 = u8;\nconst u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));\nexports.u32 = u32;\n// Cast array to view\nconst createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\nexports.createView = createView;\n// The rotate right (circular right shift) operation for uint32\nconst rotr = (word, shift) => (word << (32 - shift)) | (word >>> shift);\nexports.rotr = rotr;\n// The rotate left (circular left shift) operation for uint32\nconst rotl = (word, shift) => (word << shift) | ((word >>> (32 - shift)) >>> 0);\nexports.rotl = rotl;\nexports.isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;\n// The byte swap operation for uint32\nconst byteSwap = (word) => ((word << 24) & 0xff000000) |\n ((word << 8) & 0xff0000) |\n ((word >>> 8) & 0xff00) |\n ((word >>> 24) & 0xff);\nexports.byteSwap = byteSwap;\n// Conditionally byte swap if on a big-endian platform\nexports.byteSwapIfBE = exports.isLE ? (n) => n : (n) => (0, exports.byteSwap)(n);\n// In place byte swap for Uint32Array\nfunction byteSwap32(arr) {\n for (let i = 0; i < arr.length; i++) {\n arr[i] = (0, exports.byteSwap)(arr[i]);\n }\n}\n// Array where index 0xf0 (240) is mapped to string 'f0'\nconst hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));\n/**\n * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'\n */\nfunction bytesToHex(bytes) {\n (0, _assert_js_1.bytes)(bytes);\n // pre-caching improves the speed 6x\n let hex = '';\n for (let i = 0; i < bytes.length; i++) {\n hex += hexes[bytes[i]];\n }\n return hex;\n}\n// We use optimized technique to convert hex string to byte array\nconst asciis = { _0: 48, _9: 57, _A: 65, _F: 70, _a: 97, _f: 102 };\nfunction asciiToBase16(char) {\n if (char >= asciis._0 && char <= asciis._9)\n return char - asciis._0;\n if (char >= asciis._A && char <= asciis._F)\n return char - (asciis._A - 10);\n if (char >= asciis._a && char <= asciis._f)\n return char - (asciis._a - 10);\n return;\n}\n/**\n * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n */\nfunction hexToBytes(hex) {\n if (typeof hex !== 'string')\n throw new Error('hex string expected, got ' + typeof hex);\n const hl = hex.length;\n const al = hl / 2;\n if (hl % 2)\n throw new Error('padded hex string expected, got unpadded hex of length ' + hl);\n const array = new Uint8Array(al);\n for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {\n const n1 = asciiToBase16(hex.charCodeAt(hi));\n const n2 = asciiToBase16(hex.charCodeAt(hi + 1));\n if (n1 === undefined || n2 === undefined) {\n const char = hex[hi] + hex[hi + 1];\n throw new Error('hex string expected, got non-hex character \"' + char + '\" at index ' + hi);\n }\n array[ai] = n1 * 16 + n2;\n }\n return array;\n}\n// There is no setImmediate in browser and setTimeout is slow.\n// call of async fn will return Promise, which will be fullfiled only on\n// next scheduler queue processing step and this is exactly what we need.\nconst nextTick = async () => { };\nexports.nextTick = nextTick;\n// Returns control to thread each 'tick' ms to avoid blocking\nasync function asyncLoop(iters, tick, cb) {\n let ts = Date.now();\n for (let i = 0; i < iters; i++) {\n cb(i);\n // Date.now() is not monotonic, so in case if clock goes backwards we return return control too\n const diff = Date.now() - ts;\n if (diff >= 0 && diff < tick)\n continue;\n await (0, exports.nextTick)();\n ts += diff;\n }\n}\n/**\n * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])\n */\nfunction utf8ToBytes(str) {\n if (typeof str !== 'string')\n throw new Error(`utf8ToBytes expected string, got ${typeof str}`);\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\n/**\n * Normalizes (non-hex) string or Uint8Array to Uint8Array.\n * Warning: when Uint8Array is passed, it would NOT get copied.\n * Keep in mind for future mutable operations.\n */\nfunction toBytes(data) {\n if (typeof data === 'string')\n data = utf8ToBytes(data);\n (0, _assert_js_1.bytes)(data);\n return data;\n}\n/**\n * Copies several Uint8Arrays into one.\n */\nfunction concatBytes(...arrays) {\n let sum = 0;\n for (let i = 0; i < arrays.length; i++) {\n const a = arrays[i];\n (0, _assert_js_1.bytes)(a);\n sum += a.length;\n }\n const res = new Uint8Array(sum);\n for (let i = 0, pad = 0; i < arrays.length; i++) {\n const a = arrays[i];\n res.set(a, pad);\n pad += a.length;\n }\n return res;\n}\n// For runtime check if class implements interface\nclass Hash {\n // Safe version that clones internal state\n clone() {\n return this._cloneInto();\n }\n}\nexports.Hash = Hash;\nconst toStr = {}.toString;\nfunction checkOpts(defaults, opts) {\n if (opts !== undefined && toStr.call(opts) !== '[object Object]')\n throw new Error('Options should be object or undefined');\n const merged = Object.assign(defaults, opts);\n return merged;\n}\nfunction wrapConstructor(hashCons) {\n const hashC = (msg) => hashCons().update(toBytes(msg)).digest();\n const tmp = hashCons();\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = () => hashCons();\n return hashC;\n}\nfunction wrapConstructorWithOpts(hashCons) {\n const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({});\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts) => hashCons(opts);\n return hashC;\n}\nfunction wrapXOFConstructorWithOpts(hashCons) {\n const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({});\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts) => hashCons(opts);\n return hashC;\n}\n/**\n * Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS.\n */\nfunction randomBytes(bytesLength = 32) {\n if (crypto_1.crypto && typeof crypto_1.crypto.getRandomValues === 'function') {\n return crypto_1.crypto.getRandomValues(new Uint8Array(bytesLength));\n }\n // Legacy Node.js compatibility\n if (crypto_1.crypto && typeof crypto_1.crypto.randomBytes === 'function') {\n return crypto_1.crypto.randomBytes(bytesLength);\n }\n throw new Error('crypto.getRandomValues must be defined');\n}\n//# sourceMappingURL=utils.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.HashMD = exports.Maj = exports.Chi = void 0;\nconst _assert_js_1 = require(\"./_assert.js\");\nconst utils_js_1 = require(\"./utils.js\");\n/**\n * Polyfill for Safari 14\n */\nfunction setBigUint64(view, byteOffset, value, isLE) {\n if (typeof view.setBigUint64 === 'function')\n return view.setBigUint64(byteOffset, value, isLE);\n const _32n = BigInt(32);\n const _u32_max = BigInt(0xffffffff);\n const wh = Number((value >> _32n) & _u32_max);\n const wl = Number(value & _u32_max);\n const h = isLE ? 4 : 0;\n const l = isLE ? 0 : 4;\n view.setUint32(byteOffset + h, wh, isLE);\n view.setUint32(byteOffset + l, wl, isLE);\n}\n/**\n * Choice: a ? b : c\n */\nconst Chi = (a, b, c) => (a & b) ^ (~a & c);\nexports.Chi = Chi;\n/**\n * Majority function, true if any two inputs is true\n */\nconst Maj = (a, b, c) => (a & b) ^ (a & c) ^ (b & c);\nexports.Maj = Maj;\n/**\n * Merkle-Damgard hash construction base class.\n * Could be used to create MD5, RIPEMD, SHA1, SHA2.\n */\nclass HashMD extends utils_js_1.Hash {\n constructor(blockLen, outputLen, padOffset, isLE) {\n super();\n this.blockLen = blockLen;\n this.outputLen = outputLen;\n this.padOffset = padOffset;\n this.isLE = isLE;\n this.finished = false;\n this.length = 0;\n this.pos = 0;\n this.destroyed = false;\n this.buffer = new Uint8Array(blockLen);\n this.view = (0, utils_js_1.createView)(this.buffer);\n }\n update(data) {\n (0, _assert_js_1.exists)(this);\n const { view, buffer, blockLen } = this;\n data = (0, utils_js_1.toBytes)(data);\n const len = data.length;\n for (let pos = 0; pos < len;) {\n const take = Math.min(blockLen - this.pos, len - pos);\n // Fast path: we have at least one block in input, cast it to view and process\n if (take === blockLen) {\n const dataView = (0, utils_js_1.createView)(data);\n for (; blockLen <= len - pos; pos += blockLen)\n this.process(dataView, pos);\n continue;\n }\n buffer.set(data.subarray(pos, pos + take), this.pos);\n this.pos += take;\n pos += take;\n if (this.pos === blockLen) {\n this.process(view, 0);\n this.pos = 0;\n }\n }\n this.length += data.length;\n this.roundClean();\n return this;\n }\n digestInto(out) {\n (0, _assert_js_1.exists)(this);\n (0, _assert_js_1.output)(out, this);\n this.finished = true;\n // Padding\n // We can avoid allocation of buffer for padding completely if it\n // was previously not allocated here. But it won't change performance.\n const { buffer, view, blockLen, isLE } = this;\n let { pos } = this;\n // append the bit '1' to the message\n buffer[pos++] = 0b10000000;\n this.buffer.subarray(pos).fill(0);\n // we have less than padOffset left in buffer, so we cannot put length in\n // current block, need process it and pad again\n if (this.padOffset > blockLen - pos) {\n this.process(view, 0);\n pos = 0;\n }\n // Pad until full block byte with zeros\n for (let i = pos; i < blockLen; i++)\n buffer[i] = 0;\n // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that\n // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.\n // So we just write lowest 64 bits of that value.\n setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);\n this.process(view, 0);\n const oview = (0, utils_js_1.createView)(out);\n const len = this.outputLen;\n // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT\n if (len % 4)\n throw new Error('_sha2: outputLen should be aligned to 32bit');\n const outLen = len / 4;\n const state = this.get();\n if (outLen > state.length)\n throw new Error('_sha2: outputLen bigger than state');\n for (let i = 0; i < outLen; i++)\n oview.setUint32(4 * i, state[i], isLE);\n }\n digest() {\n const { buffer, outputLen } = this;\n this.digestInto(buffer);\n const res = buffer.slice(0, outputLen);\n this.destroy();\n return res;\n }\n _cloneInto(to) {\n to || (to = new this.constructor());\n to.set(...this.get());\n const { blockLen, buffer, length, finished, destroyed, pos } = this;\n to.length = length;\n to.pos = pos;\n to.finished = finished;\n to.destroyed = destroyed;\n if (length % blockLen)\n to.buffer.set(buffer);\n return to;\n }\n}\nexports.HashMD = HashMD;\n//# sourceMappingURL=_md.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.sha224 = exports.sha256 = exports.SHA256 = void 0;\nconst _md_js_1 = require(\"./_md.js\");\nconst utils_js_1 = require(\"./utils.js\");\n// SHA2-256 need to try 2^128 hashes to execute birthday attack.\n// BTC network is doing 2^67 hashes/sec as per early 2023.\n// Round constants:\n// first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)\n// prettier-ignore\nconst SHA256_K = /* @__PURE__ */ new Uint32Array([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2\n]);\n// Initial state:\n// first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19\n// prettier-ignore\nconst SHA256_IV = /* @__PURE__ */ new Uint32Array([\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19\n]);\n// Temporary buffer, not used to store anything between runs\n// Named this way because it matches specification.\nconst SHA256_W = /* @__PURE__ */ new Uint32Array(64);\nclass SHA256 extends _md_js_1.HashMD {\n constructor() {\n super(64, 32, 8, false);\n // We cannot use array here since array allows indexing by variable\n // which means optimizer/compiler cannot use registers.\n this.A = SHA256_IV[0] | 0;\n this.B = SHA256_IV[1] | 0;\n this.C = SHA256_IV[2] | 0;\n this.D = SHA256_IV[3] | 0;\n this.E = SHA256_IV[4] | 0;\n this.F = SHA256_IV[5] | 0;\n this.G = SHA256_IV[6] | 0;\n this.H = SHA256_IV[7] | 0;\n }\n get() {\n const { A, B, C, D, E, F, G, H } = this;\n return [A, B, C, D, E, F, G, H];\n }\n // prettier-ignore\n set(A, B, C, D, E, F, G, H) {\n this.A = A | 0;\n this.B = B | 0;\n this.C = C | 0;\n this.D = D | 0;\n this.E = E | 0;\n this.F = F | 0;\n this.G = G | 0;\n this.H = H | 0;\n }\n process(view, offset) {\n // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4)\n SHA256_W[i] = view.getUint32(offset, false);\n for (let i = 16; i < 64; i++) {\n const W15 = SHA256_W[i - 15];\n const W2 = SHA256_W[i - 2];\n const s0 = (0, utils_js_1.rotr)(W15, 7) ^ (0, utils_js_1.rotr)(W15, 18) ^ (W15 >>> 3);\n const s1 = (0, utils_js_1.rotr)(W2, 17) ^ (0, utils_js_1.rotr)(W2, 19) ^ (W2 >>> 10);\n SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;\n }\n // Compression function main loop, 64 rounds\n let { A, B, C, D, E, F, G, H } = this;\n for (let i = 0; i < 64; i++) {\n const sigma1 = (0, utils_js_1.rotr)(E, 6) ^ (0, utils_js_1.rotr)(E, 11) ^ (0, utils_js_1.rotr)(E, 25);\n const T1 = (H + sigma1 + (0, _md_js_1.Chi)(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const sigma0 = (0, utils_js_1.rotr)(A, 2) ^ (0, utils_js_1.rotr)(A, 13) ^ (0, utils_js_1.rotr)(A, 22);\n const T2 = (sigma0 + (0, _md_js_1.Maj)(A, B, C)) | 0;\n H = G;\n G = F;\n F = E;\n E = (D + T1) | 0;\n D = C;\n C = B;\n B = A;\n A = (T1 + T2) | 0;\n }\n // Add the compressed chunk to the current hash value\n A = (A + this.A) | 0;\n B = (B + this.B) | 0;\n C = (C + this.C) | 0;\n D = (D + this.D) | 0;\n E = (E + this.E) | 0;\n F = (F + this.F) | 0;\n G = (G + this.G) | 0;\n H = (H + this.H) | 0;\n this.set(A, B, C, D, E, F, G, H);\n }\n roundClean() {\n SHA256_W.fill(0);\n }\n destroy() {\n this.set(0, 0, 0, 0, 0, 0, 0, 0);\n this.buffer.fill(0);\n }\n}\nexports.SHA256 = SHA256;\n// Constants from https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf\nclass SHA224 extends SHA256 {\n constructor() {\n super();\n this.A = 0xc1059ed8 | 0;\n this.B = 0x367cd507 | 0;\n this.C = 0x3070dd17 | 0;\n this.D = 0xf70e5939 | 0;\n this.E = 0xffc00b31 | 0;\n this.F = 0x68581511 | 0;\n this.G = 0x64f98fa7 | 0;\n this.H = 0xbefa4fa4 | 0;\n this.outputLen = 28;\n }\n}\n/**\n * SHA2-256 hash function\n * @param message - data that would be hashed\n */\nexports.sha256 = (0, utils_js_1.wrapConstructor)(() => new SHA256());\n/**\n * SHA2-224 hash function\n */\nexports.sha224 = (0, utils_js_1.wrapConstructor)(() => new SHA224());\n//# sourceMappingURL=sha256.js.map","'use strict'\n// base-x encoding / decoding\n// Copyright (c) 2018 base-x contributors\n// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)\n// Distributed under the MIT software license, see the accompanying\n// file LICENSE or http://www.opensource.org/licenses/mit-license.php.\nfunction base (ALPHABET) {\n if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }\n var BASE_MAP = new Uint8Array(256)\n for (var j = 0; j < BASE_MAP.length; j++) {\n BASE_MAP[j] = 255\n }\n for (var i = 0; i < ALPHABET.length; i++) {\n var x = ALPHABET.charAt(i)\n var xc = x.charCodeAt(0)\n if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }\n BASE_MAP[xc] = i\n }\n var BASE = ALPHABET.length\n var LEADER = ALPHABET.charAt(0)\n var FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up\n var iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up\n function encode (source) {\n if (source instanceof Uint8Array) {\n } else if (ArrayBuffer.isView(source)) {\n source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength)\n } else if (Array.isArray(source)) {\n source = Uint8Array.from(source)\n }\n if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }\n if (source.length === 0) { return '' }\n // Skip & count leading zeroes.\n var zeroes = 0\n var length = 0\n var pbegin = 0\n var pend = source.length\n while (pbegin !== pend && source[pbegin] === 0) {\n pbegin++\n zeroes++\n }\n // Allocate enough space in big-endian base58 representation.\n var size = ((pend - pbegin) * iFACTOR + 1) >>> 0\n var b58 = new Uint8Array(size)\n // Process the bytes.\n while (pbegin !== pend) {\n var carry = source[pbegin]\n // Apply \"b58 = b58 * 256 + ch\".\n var i = 0\n for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {\n carry += (256 * b58[it1]) >>> 0\n b58[it1] = (carry % BASE) >>> 0\n carry = (carry / BASE) >>> 0\n }\n if (carry !== 0) { throw new Error('Non-zero carry') }\n length = i\n pbegin++\n }\n // Skip leading zeroes in base58 result.\n var it2 = size - length\n while (it2 !== size && b58[it2] === 0) {\n it2++\n }\n // Translate the result into a string.\n var str = LEADER.repeat(zeroes)\n for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]) }\n return str\n }\n function decodeUnsafe (source) {\n if (typeof source !== 'string') { throw new TypeError('Expected String') }\n if (source.length === 0) { return new Uint8Array() }\n var psz = 0\n // Skip and count leading '1's.\n var zeroes = 0\n var length = 0\n while (source[psz] === LEADER) {\n zeroes++\n psz++\n }\n // Allocate enough space in big-endian base256 representation.\n var size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up.\n var b256 = new Uint8Array(size)\n // Process the characters.\n while (source[psz]) {\n // Decode character\n var carry = BASE_MAP[source.charCodeAt(psz)]\n // Invalid character\n if (carry === 255) { return }\n var i = 0\n for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {\n carry += (BASE * b256[it3]) >>> 0\n b256[it3] = (carry % 256) >>> 0\n carry = (carry / 256) >>> 0\n }\n if (carry !== 0) { throw new Error('Non-zero carry') }\n length = i\n psz++\n }\n // Skip leading zeroes in b256.\n var it4 = size - length\n while (it4 !== size && b256[it4] === 0) {\n it4++\n }\n var vch = new Uint8Array(zeroes + (size - it4))\n var j = zeroes\n while (it4 !== size) {\n vch[j++] = b256[it4++]\n }\n return vch\n }\n function decode (string) {\n var buffer = decodeUnsafe(string)\n if (buffer) { return buffer }\n throw new Error('Non-base' + BASE + ' character')\n }\n return {\n encode: encode,\n decodeUnsafe: decodeUnsafe,\n decode: decode\n }\n}\nmodule.exports = base\n","const basex = require('base-x')\nconst ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'\n\nmodule.exports = basex(ALPHABET)\n","'use strict'\n\nvar base58 = require('bs58')\n\nmodule.exports = function (checksumFn) {\n // Encode a buffer as a base58-check encoded string\n function encode (payload) {\n var payloadU8 = Uint8Array.from(payload)\n var checksum = checksumFn(payloadU8)\n var length = payloadU8.length + 4\n var both = new Uint8Array(length)\n both.set(payloadU8, 0)\n both.set(checksum.subarray(0, 4), payloadU8.length)\n return base58.encode(both, length)\n }\n\n function decodeRaw (buffer) {\n var payload = buffer.slice(0, -4)\n var checksum = buffer.slice(-4)\n var newChecksum = checksumFn(payload)\n\n if (checksum[0] ^ newChecksum[0] |\n checksum[1] ^ newChecksum[1] |\n checksum[2] ^ newChecksum[2] |\n checksum[3] ^ newChecksum[3]) return\n\n return payload\n }\n\n // Decode a base58-check encoded string to a buffer, no result if checksum is wrong\n function decodeUnsafe (string) {\n var buffer = base58.decodeUnsafe(string)\n if (!buffer) return\n\n return decodeRaw(buffer)\n }\n\n function decode (string) {\n var buffer = base58.decode(string)\n var payload = decodeRaw(buffer, checksumFn)\n if (!payload) throw new Error('Invalid checksum')\n return payload\n }\n\n return {\n encode: encode,\n decode: decode,\n decodeUnsafe: decodeUnsafe\n }\n}\n","'use strict'\n\nvar { sha256 } = require('@noble/hashes/sha256')\nvar bs58checkBase = require('./base')\n\n// SHA256(SHA256(buffer))\nfunction sha256x2 (buffer) {\n return sha256(sha256(buffer))\n}\n\nmodule.exports = bs58checkBase(sha256x2)\n","import * as Uuid from \"uuid\";\nimport bs58check from \"bs58check\";\nexport const urlPrefix = \"automerge:\";\n/** Given an Automerge URL, returns the DocumentId in both base58check-encoded form and binary form */\nexport const parseAutomergeUrl = (url) => {\n const regex = new RegExp(`^${urlPrefix}(\\\\w+)$`);\n const [, docMatch] = url.match(regex) || [];\n const documentId = docMatch;\n const binaryDocumentId = documentIdToBinary(documentId);\n if (!binaryDocumentId)\n throw new Error(\"Invalid document URL: \" + url);\n return {\n /** unencoded DocumentId */\n binaryDocumentId,\n /** encoded DocumentId */\n documentId,\n };\n};\n/**\n * Given a documentId in either binary or base58check-encoded form, returns an Automerge URL.\n * Throws on invalid input.\n */\nexport const stringifyAutomergeUrl = (arg) => {\n const documentId = arg instanceof Uint8Array || typeof arg === \"string\"\n ? arg\n : \"documentId\" in arg\n ? arg.documentId\n : undefined;\n const encodedDocumentId = documentId instanceof Uint8Array\n ? binaryToDocumentId(documentId)\n : typeof documentId === \"string\"\n ? documentId\n : undefined;\n if (encodedDocumentId === undefined)\n throw new Error(\"Invalid documentId: \" + documentId);\n return (urlPrefix + encodedDocumentId);\n};\n/**\n * Given a string, returns true if it is a valid Automerge URL. This function also acts as a type\n * discriminator in Typescript.\n */\nexport const isValidAutomergeUrl = (str) => {\n if (typeof str !== \"string\")\n return false;\n if (!str || !str.startsWith(urlPrefix))\n return false;\n const automergeUrl = str;\n try {\n const { documentId } = parseAutomergeUrl(automergeUrl);\n return isValidDocumentId(documentId);\n }\n catch {\n return false;\n }\n};\nexport const isValidDocumentId = (str) => {\n if (typeof str !== \"string\")\n return false;\n // try to decode from base58\n const binaryDocumentID = documentIdToBinary(str);\n if (binaryDocumentID === undefined)\n return false; // invalid base58check encoding\n // confirm that the document ID is a valid UUID\n const documentId = Uuid.stringify(binaryDocumentID);\n return Uuid.validate(documentId);\n};\nexport const isValidUuid = (str) => typeof str === \"string\" && Uuid.validate(str);\n/**\n * Returns a new Automerge URL with a random UUID documentId. Called by Repo.create(), and also used by tests.\n */\nexport const generateAutomergeUrl = () => {\n const documentId = Uuid.v4(null, new Uint8Array(16));\n return stringifyAutomergeUrl({ documentId });\n};\nexport const documentIdToBinary = (docId) => bs58check.decodeUnsafe(docId);\nexport const binaryToDocumentId = (docId) => bs58check.encode(docId);\nexport const parseLegacyUUID = (str) => {\n if (!Uuid.validate(str))\n return undefined;\n const documentId = Uuid.parse(str);\n return stringifyAutomergeUrl({ documentId });\n};\n/**\n * Given any valid expression of a document ID, returns a DocumentId in base58check-encoded form.\n *\n * Currently supports:\n * - base58check-encoded DocumentId\n * - Automerge URL\n * - legacy UUID\n * - binary DocumentId\n *\n * Throws on invalid input.\n */\nexport const interpretAsDocumentId = (id) => {\n // binary\n if (id instanceof Uint8Array)\n return binaryToDocumentId(id);\n // url\n if (isValidAutomergeUrl(id))\n return parseAutomergeUrl(id).documentId;\n // base58check\n if (isValidDocumentId(id))\n return id;\n // legacy UUID\n if (isValidUuid(id)) {\n console.warn(\"Future versions will not support UUIDs as document IDs; use Automerge URLs instead.\");\n const binaryDocumentID = Uuid.parse(id);\n return binaryToDocumentId(binaryDocumentID);\n }\n // none of the above\n throw new Error(`Invalid AutomergeUrl: '${id}'`);\n};\n","let decoder\ntry {\n\tdecoder = new TextDecoder()\n} catch(error) {}\nlet src\nlet srcEnd\nlet position = 0\nlet alreadySet\nconst EMPTY_ARRAY = []\nconst LEGACY_RECORD_INLINE_ID = 105\nconst RECORD_DEFINITIONS_ID = 0xdffe\nconst RECORD_INLINE_ID = 0xdfff // temporary first-come first-serve tag // proposed tag: 0x7265 // 're'\nconst BUNDLED_STRINGS_ID = 0xdff9\nconst PACKED_TABLE_TAG_ID = 51\nconst PACKED_REFERENCE_TAG_ID = 6\nconst STOP_CODE = {}\nlet maxArraySize = 112810000 // This is the maximum array size in V8. We would potentially detect and set it higher\n// for JSC, but this is pretty large and should be sufficient for most use cases\nlet maxMapSize = 16810000 // JavaScript has a fixed maximum map size of about 16710000, but JS itself enforces this,\n// so we don't need to\n\nlet maxObjectSize = 16710000; // This is the maximum number of keys in a Map. It takes over a minute to create this\n// many keys in an object, so also probably a reasonable choice there.\nlet strings = EMPTY_ARRAY\nlet stringPosition = 0\nlet currentDecoder = {}\nlet currentStructures\nlet srcString\nlet srcStringStart = 0\nlet srcStringEnd = 0\nlet bundledStrings\nlet referenceMap\nlet currentExtensions = []\nlet currentExtensionRanges = []\nlet packedValues\nlet dataView\nlet restoreMapsAsObject\nlet defaultOptions = {\n\tuseRecords: false,\n\tmapsAsObjects: true\n}\nlet sequentialMode = false\nlet inlineObjectReadThreshold = 2;\nvar BlockedFunction // we use search and replace to change the next call to BlockedFunction to avoid CSP issues for\n// no-eval build\ntry {\n\tnew Function('')\n} catch(error) {\n\t// if eval variants are not supported, do not create inline object readers ever\n\tinlineObjectReadThreshold = Infinity\n}\n\n\n\nexport class Decoder {\n\tconstructor(options) {\n\t\tif (options) {\n\t\t\tif ((options.keyMap || options._keyMap) && !options.useRecords) {\n\t\t\t\toptions.useRecords = false\n\t\t\t\toptions.mapsAsObjects = true\n\t\t\t}\n\t\t\tif (options.useRecords === false && options.mapsAsObjects === undefined)\n\t\t\t\toptions.mapsAsObjects = true\n\t\t\tif (options.getStructures)\n\t\t\t\toptions.getShared = options.getStructures\n\t\t\tif (options.getShared && !options.structures)\n\t\t\t\t(options.structures = []).uninitialized = true // this is what we use to denote an uninitialized structures\n\t\t\tif (options.keyMap) {\n\t\t\t\tthis.mapKey = new Map()\n\t\t\t\tfor (let [k,v] of Object.entries(options.keyMap)) this.mapKey.set(v,k)\n\t\t\t}\n\t\t}\n\t\tObject.assign(this, options)\n\t}\n\t/*\n\tdecodeKey(key) {\n\t\treturn this.keyMap\n\t\t\t? Object.keys(this.keyMap)[Object.values(this.keyMap).indexOf(key)] || key\n\t\t\t: key\n\t}\n\t*/\n\tdecodeKey(key) {\n\t\treturn this.keyMap ? this.mapKey.get(key) || key : key\n\t}\n\t\n\tencodeKey(key) {\n\t\treturn this.keyMap && this.keyMap.hasOwnProperty(key) ? this.keyMap[key] : key\n\t}\n\n\tencodeKeys(rec) {\n\t\tif (!this._keyMap) return rec\n\t\tlet map = new Map()\n\t\tfor (let [k,v] of Object.entries(rec)) map.set((this._keyMap.hasOwnProperty(k) ? this._keyMap[k] : k), v)\n\t\treturn map\n\t}\n\n\tdecodeKeys(map) {\n\t\tif (!this._keyMap || map.constructor.name != 'Map') return map\n\t\tif (!this._mapKey) {\n\t\t\tthis._mapKey = new Map()\n\t\t\tfor (let [k,v] of Object.entries(this._keyMap)) this._mapKey.set(v,k)\n\t\t}\n\t\tlet res = {}\n\t\t//map.forEach((v,k) => res[Object.keys(this._keyMap)[Object.values(this._keyMap).indexOf(k)] || k] = v)\n\t\tmap.forEach((v,k) => res[safeKey(this._mapKey.has(k) ? this._mapKey.get(k) : k)] = v)\n\t\treturn res\n\t}\n\t\n\tmapDecode(source, end) {\n\t\n\t\tlet res = this.decode(source)\n\t\tif (this._keyMap) { \n\t\t\t//Experiemntal support for Optimised KeyMap decoding \n\t\t\tswitch (res.constructor.name) {\n\t\t\t\tcase 'Array': return res.map(r => this.decodeKeys(r))\n\t\t\t\t//case 'Map': return this.decodeKeys(res)\n\t\t\t}\n\t\t}\n\t\treturn res\n\t}\n\n\tdecode(source, end) {\n\t\tif (src) {\n\t\t\t// re-entrant execution, save the state and restore it after we do this decode\n\t\t\treturn saveState(() => {\n\t\t\t\tclearSource()\n\t\t\t\treturn this ? this.decode(source, end) : Decoder.prototype.decode.call(defaultOptions, source, end)\n\t\t\t})\n\t\t}\n\t\tsrcEnd = end > -1 ? end : source.length\n\t\tposition = 0\n\t\tstringPosition = 0\n\t\tsrcStringEnd = 0\n\t\tsrcString = null\n\t\tstrings = EMPTY_ARRAY\n\t\tbundledStrings = null\n\t\tsrc = source\n\t\t// this provides cached access to the data view for a buffer if it is getting reused, which is a recommend\n\t\t// technique for getting data from a database where it can be copied into an existing buffer instead of creating\n\t\t// new ones\n\t\ttry {\n\t\t\tdataView = source.dataView || (source.dataView = new DataView(source.buffer, source.byteOffset, source.byteLength))\n\t\t} catch(error) {\n\t\t\t// if it doesn't have a buffer, maybe it is the wrong type of object\n\t\t\tsrc = null\n\t\t\tif (source instanceof Uint8Array)\n\t\t\t\tthrow error\n\t\t\tthrow new Error('Source must be a Uint8Array or Buffer but was a ' + ((source && typeof source == 'object') ? source.constructor.name : typeof source))\n\t\t}\n\t\tif (this instanceof Decoder) {\n\t\t\tcurrentDecoder = this\n\t\t\tpackedValues = this.sharedValues &&\n\t\t\t\t(this.pack ? new Array(this.maxPrivatePackedValues || 16).concat(this.sharedValues) :\n\t\t\t\tthis.sharedValues)\n\t\t\tif (this.structures) {\n\t\t\t\tcurrentStructures = this.structures\n\t\t\t\treturn checkedRead()\n\t\t\t} else if (!currentStructures || currentStructures.length > 0) {\n\t\t\t\tcurrentStructures = []\n\t\t\t}\n\t\t} else {\n\t\t\tcurrentDecoder = defaultOptions\n\t\t\tif (!currentStructures || currentStructures.length > 0)\n\t\t\t\tcurrentStructures = []\n\t\t\tpackedValues = null\n\t\t}\n\t\treturn checkedRead()\n\t}\n\tdecodeMultiple(source, forEach) {\n\t\tlet values, lastPosition = 0\n\t\ttry {\n\t\t\tlet size = source.length\n\t\t\tsequentialMode = true\n\t\t\tlet value = this ? this.decode(source, size) : defaultDecoder.decode(source, size)\n\t\t\tif (forEach) {\n\t\t\t\tif (forEach(value) === false) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\twhile(position < size) {\n\t\t\t\t\tlastPosition = position\n\t\t\t\t\tif (forEach(checkedRead()) === false) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tvalues = [ value ]\n\t\t\t\twhile(position < size) {\n\t\t\t\t\tlastPosition = position\n\t\t\t\t\tvalues.push(checkedRead())\n\t\t\t\t}\n\t\t\t\treturn values\n\t\t\t}\n\t\t} catch(error) {\n\t\t\terror.lastPosition = lastPosition\n\t\t\terror.values = values\n\t\t\tthrow error\n\t\t} finally {\n\t\t\tsequentialMode = false\n\t\t\tclearSource()\n\t\t}\n\t}\n}\nexport function getPosition() {\n\treturn position\n}\nexport function checkedRead() {\n\ttry {\n\t\tlet result = read()\n\t\tif (bundledStrings) {\n\t\t\tif (position >= bundledStrings.postBundlePosition) {\n\t\t\t\tlet error = new Error('Unexpected bundle position');\n\t\t\t\terror.incomplete = true;\n\t\t\t\tthrow error\n\t\t\t}\n\t\t\t// bundled strings to skip past\n\t\t\tposition = bundledStrings.postBundlePosition;\n\t\t\tbundledStrings = null;\n\t\t}\n\n\t\tif (position == srcEnd) {\n\t\t\t// finished reading this source, cleanup references\n\t\t\tcurrentStructures = null\n\t\t\tsrc = null\n\t\t\tif (referenceMap)\n\t\t\t\treferenceMap = null\n\t\t} else if (position > srcEnd) {\n\t\t\t// over read\n\t\t\tlet error = new Error('Unexpected end of CBOR data')\n\t\t\terror.incomplete = true\n\t\t\tthrow error\n\t\t} else if (!sequentialMode) {\n\t\t\tthrow new Error('Data read, but end of buffer not reached')\n\t\t}\n\t\t// else more to read, but we are reading sequentially, so don't clear source yet\n\t\treturn result\n\t} catch(error) {\n\t\tclearSource()\n\t\tif (error instanceof RangeError || error.message.startsWith('Unexpected end of buffer')) {\n\t\t\terror.incomplete = true\n\t\t}\n\t\tthrow error\n\t}\n}\n\nexport function read() {\n\tlet token = src[position++]\n\tlet majorType = token >> 5\n\ttoken = token & 0x1f\n\tif (token > 0x17) {\n\t\tswitch (token) {\n\t\t\tcase 0x18:\n\t\t\t\ttoken = src[position++]\n\t\t\t\tbreak\n\t\t\tcase 0x19:\n\t\t\t\tif (majorType == 7) {\n\t\t\t\t\treturn getFloat16()\n\t\t\t\t}\n\t\t\t\ttoken = dataView.getUint16(position)\n\t\t\t\tposition += 2\n\t\t\t\tbreak\n\t\t\tcase 0x1a:\n\t\t\t\tif (majorType == 7) {\n\t\t\t\t\tlet value = dataView.getFloat32(position)\n\t\t\t\t\tif (currentDecoder.useFloat32 > 2) {\n\t\t\t\t\t\t// this does rounding of numbers that were encoded in 32-bit float to nearest significant decimal digit that could be preserved\n\t\t\t\t\t\tlet multiplier = mult10[((src[position] & 0x7f) << 1) | (src[position + 1] >> 7)]\n\t\t\t\t\t\tposition += 4\n\t\t\t\t\t\treturn ((multiplier * value + (value > 0 ? 0.5 : -0.5)) >> 0) / multiplier\n\t\t\t\t\t}\n\t\t\t\t\tposition += 4\n\t\t\t\t\treturn value\n\t\t\t\t}\n\t\t\t\ttoken = dataView.getUint32(position)\n\t\t\t\tposition += 4\n\t\t\t\tbreak\n\t\t\tcase 0x1b:\n\t\t\t\tif (majorType == 7) {\n\t\t\t\t\tlet value = dataView.getFloat64(position)\n\t\t\t\t\tposition += 8\n\t\t\t\t\treturn value\n\t\t\t\t}\n\t\t\t\tif (majorType > 1) {\n\t\t\t\t\tif (dataView.getUint32(position) > 0)\n\t\t\t\t\t\tthrow new Error('JavaScript does not support arrays, maps, or strings with length over 4294967295')\n\t\t\t\t\ttoken = dataView.getUint32(position + 4)\n\t\t\t\t} else if (currentDecoder.int64AsNumber) {\n\t\t\t\t\ttoken = dataView.getUint32(position) * 0x100000000\n\t\t\t\t\ttoken += dataView.getUint32(position + 4)\n\t\t\t\t} else\n\t\t\t\t\ttoken = dataView.getBigUint64(position)\n\t\t\t\tposition += 8\n\t\t\t\tbreak\n\t\t\tcase 0x1f: \n\t\t\t\t// indefinite length\n\t\t\t\tswitch(majorType) {\n\t\t\t\t\tcase 2: // byte string\n\t\t\t\t\tcase 3: // text string\n\t\t\t\t\t\tthrow new Error('Indefinite length not supported for byte or text strings')\n\t\t\t\t\tcase 4: // array\n\t\t\t\t\t\tlet array = []\n\t\t\t\t\t\tlet value, i = 0\n\t\t\t\t\t\twhile ((value = read()) != STOP_CODE) {\n\t\t\t\t\t\t\tif (i >= maxArraySize) throw new Error(`Array length exceeds ${maxArraySize}`)\n\t\t\t\t\t\t\tarray[i++] = value\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn majorType == 4 ? array : majorType == 3 ? array.join('') : Buffer.concat(array)\n\t\t\t\t\tcase 5: // map\n\t\t\t\t\t\tlet key\n\t\t\t\t\t\tif (currentDecoder.mapsAsObjects) {\n\t\t\t\t\t\t\tlet object = {}\n\t\t\t\t\t\t\tlet i = 0;\n\t\t\t\t\t\t\tif (currentDecoder.keyMap) {\n\t\t\t\t\t\t\t\twhile((key = read()) != STOP_CODE) {\n\t\t\t\t\t\t\t\t\tif (i++ >= maxMapSize) throw new Error(`Property count exceeds ${maxMapSize}`)\n\t\t\t\t\t\t\t\t\tobject[safeKey(currentDecoder.decodeKey(key))] = read()\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\twhile ((key = read()) != STOP_CODE) {\n\t\t\t\t\t\t\t\t\tif (i++ >= maxMapSize) throw new Error(`Property count exceeds ${maxMapSize}`)\n\t\t\t\t\t\t\t\t\tobject[safeKey(key)] = read()\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn object\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (restoreMapsAsObject) {\n\t\t\t\t\t\t\t\tcurrentDecoder.mapsAsObjects = true\n\t\t\t\t\t\t\t\trestoreMapsAsObject = false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tlet map = new Map()\n\t\t\t\t\t\t\tif (currentDecoder.keyMap) {\n\t\t\t\t\t\t\t\tlet i = 0;\n\t\t\t\t\t\t\t\twhile((key = read()) != STOP_CODE) {\n\t\t\t\t\t\t\t\t\tif (i++ >= maxMapSize) {\n\t\t\t\t\t\t\t\t\t\tthrow new Error(`Map size exceeds ${maxMapSize}`);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tmap.set(currentDecoder.decodeKey(key), read())\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tlet i = 0;\n\t\t\t\t\t\t\t\twhile ((key = read()) != STOP_CODE) {\n\t\t\t\t\t\t\t\t\tif (i++ >= maxMapSize) {\n\t\t\t\t\t\t\t\t\t\tthrow new Error(`Map size exceeds ${maxMapSize}`);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tmap.set(key, read())\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn map\n\t\t\t\t\t\t}\n\t\t\t\t\tcase 7:\n\t\t\t\t\t\treturn STOP_CODE\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthrow new Error('Invalid major type for indefinite length ' + majorType)\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tthrow new Error('Unknown token ' + token)\n\t\t}\n\t}\n\tswitch (majorType) {\n\t\tcase 0: // positive int\n\t\t\treturn token\n\t\tcase 1: // negative int\n\t\t\treturn ~token\n\t\tcase 2: // buffer\n\t\t\treturn readBin(token)\n\t\tcase 3: // string\n\t\t\tif (srcStringEnd >= position) {\n\t\t\t\treturn srcString.slice(position - srcStringStart, (position += token) - srcStringStart)\n\t\t\t}\n\t\t\tif (srcStringEnd == 0 && srcEnd < 140 && token < 32) {\n\t\t\t\t// for small blocks, avoiding the overhead of the extract call is helpful\n\t\t\t\tlet string = token < 16 ? shortStringInJS(token) : longStringInJS(token)\n\t\t\t\tif (string != null)\n\t\t\t\t\treturn string\n\t\t\t}\n\t\t\treturn readFixedString(token)\n\t\tcase 4: // array\n\t\t\tif (token >= maxArraySize) throw new Error(`Array length exceeds ${maxArraySize}`)\n\t\t\tlet array = new Array(token)\n\t\t //if (currentDecoder.keyMap) for (let i = 0; i < token; i++) array[i] = currentDecoder.decodeKey(read())\t\n\t\t\t//else \n\t\t\tfor (let i = 0; i < token; i++) array[i] = read()\n\t\t\treturn array\n\t\tcase 5: // map\n\t\t\tif (token >= maxMapSize) throw new Error(`Map size exceeds ${maxArraySize}`)\n\t\t\tif (currentDecoder.mapsAsObjects) {\n\t\t\t\tlet object = {}\n\t\t\t\tif (currentDecoder.keyMap) for (let i = 0; i < token; i++) object[safeKey(currentDecoder.decodeKey(read()))] = read()\n\t\t\t\telse for (let i = 0; i < token; i++) object[safeKey(read())] = read()\n\t\t\t\treturn object\n\t\t\t} else {\n\t\t\t\tif (restoreMapsAsObject) {\n\t\t\t\t\tcurrentDecoder.mapsAsObjects = true\n\t\t\t\t\trestoreMapsAsObject = false\n\t\t\t\t}\n\t\t\t\tlet map = new Map()\n\t\t\t\tif (currentDecoder.keyMap) for (let i = 0; i < token; i++) map.set(currentDecoder.decodeKey(read()),read())\n\t\t\t\telse for (let i = 0; i < token; i++) map.set(read(), read())\n\t\t\t\treturn map\n\t\t\t}\n\t\tcase 6: // extension\n\t\t\tif (token >= BUNDLED_STRINGS_ID) {\n\t\t\t\tlet structure = currentStructures[token & 0x1fff] // check record structures first\n\t\t\t\t// At some point we may provide an option for dynamic tag assignment with a range like token >= 8 && (token < 16 || (token > 0x80 && token < 0xc0) || (token > 0x130 && token < 0x4000))\n\t\t\t\tif (structure) {\n\t\t\t\t\tif (!structure.read) structure.read = createStructureReader(structure)\n\t\t\t\t\treturn structure.read()\n\t\t\t\t}\n\t\t\t\tif (token < 0x10000) {\n\t\t\t\t\tif (token == RECORD_INLINE_ID) { // we do a special check for this so that we can keep the\n\t\t\t\t\t\t// currentExtensions as densely stored array (v8 stores arrays densely under about 3000 elements)\n\t\t\t\t\t\tlet length = readJustLength()\n\t\t\t\t\t\tlet id = read()\n\t\t\t\t\t\tlet structure = read()\n\t\t\t\t\t\trecordDefinition(id, structure)\n\t\t\t\t\t\tlet object = {}\n\t\t\t\t\t\tif (currentDecoder.keyMap) for (let i = 2; i < length; i++) {\n\t\t\t\t\t\t\tlet key = currentDecoder.decodeKey(structure[i - 2])\n\t\t\t\t\t\t\tobject[safeKey(key)] = read()\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse for (let i = 2; i < length; i++) {\n\t\t\t\t\t\t\tlet key = structure[i - 2]\n\t\t\t\t\t\t\tobject[safeKey(key)] = read()\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn object\n\t\t\t\t\t}\n\t\t\t\t\telse if (token == RECORD_DEFINITIONS_ID) {\n\t\t\t\t\t\tlet length = readJustLength()\n\t\t\t\t\t\tlet id = read()\n\t\t\t\t\t\tfor (let i = 2; i < length; i++) {\n\t\t\t\t\t\t\trecordDefinition(id++, read())\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn read()\n\t\t\t\t\t} else if (token == BUNDLED_STRINGS_ID) {\n\t\t\t\t\t\treturn readBundleExt()\n\t\t\t\t\t}\n\t\t\t\t\tif (currentDecoder.getShared) {\n\t\t\t\t\t\tloadShared()\n\t\t\t\t\t\tstructure = currentStructures[token & 0x1fff]\n\t\t\t\t\t\tif (structure) {\n\t\t\t\t\t\t\tif (!structure.read)\n\t\t\t\t\t\t\t\tstructure.read = createStructureReader(structure)\n\t\t\t\t\t\t\treturn structure.read()\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tlet extension = currentExtensions[token]\n\t\t\tif (extension) {\n\t\t\t\tif (extension.handlesRead)\n\t\t\t\t\treturn extension(read)\n\t\t\t\telse\n\t\t\t\t\treturn extension(read())\n\t\t\t} else {\n\t\t\t\tlet input = read()\n\t\t\t\tfor (let i = 0; i < currentExtensionRanges.length; i++) {\n\t\t\t\t\tlet value = currentExtensionRanges[i](token, input)\n\t\t\t\t\tif (value !== undefined)\n\t\t\t\t\t\treturn value\n\t\t\t\t}\n\t\t\t\treturn new Tag(input, token)\n\t\t\t}\n\t\tcase 7: // fixed value\n\t\t\tswitch (token) {\n\t\t\t\tcase 0x14: return false\n\t\t\t\tcase 0x15: return true\n\t\t\t\tcase 0x16: return null\n\t\t\t\tcase 0x17: return; // undefined\n\t\t\t\tcase 0x1f:\n\t\t\t\tdefault:\n\t\t\t\t\tlet packedValue = (packedValues || getPackedValues())[token]\n\t\t\t\t\tif (packedValue !== undefined)\n\t\t\t\t\t\treturn packedValue\n\t\t\t\t\tthrow new Error('Unknown token ' + token)\n\t\t\t}\n\t\tdefault: // negative int\n\t\t\tif (isNaN(token)) {\n\t\t\t\tlet error = new Error('Unexpected end of CBOR data')\n\t\t\t\terror.incomplete = true\n\t\t\t\tthrow error\n\t\t\t}\n\t\t\tthrow new Error('Unknown CBOR token ' + token)\n\t}\n}\nconst validName = /^[a-zA-Z_$][a-zA-Z\\d_$]*$/\nfunction createStructureReader(structure) {\n\tif (!structure) throw new Error('Structure is required in record definition');\n\tfunction readObject() {\n\t\t// get the array size from the header\n\t\tlet length = src[position++]\n\t\t//let majorType = token >> 5\n\t\tlength = length & 0x1f\n\t\tif (length > 0x17) {\n\t\t\tswitch (length) {\n\t\t\t\tcase 0x18:\n\t\t\t\t\tlength = src[position++]\n\t\t\t\t\tbreak\n\t\t\t\tcase 0x19:\n\t\t\t\t\tlength = dataView.getUint16(position)\n\t\t\t\t\tposition += 2\n\t\t\t\t\tbreak\n\t\t\t\tcase 0x1a:\n\t\t\t\t\tlength = dataView.getUint32(position)\n\t\t\t\t\tposition += 4\n\t\t\t\t\tbreak\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error('Expected array header, but got ' + src[position - 1])\n\t\t\t}\n\t\t}\n\t\t// This initial function is quick to instantiate, but runs slower. After several iterations pay the cost to build the faster function\n\t\tlet compiledReader = this.compiledReader // first look to see if we have the fast compiled function\n\t\twhile(compiledReader) {\n\t\t\t// we have a fast compiled object literal reader\n\t\t\tif (compiledReader.propertyCount === length)\n\t\t\t\treturn compiledReader(read) // with the right length, so we use it\n\t\t\tcompiledReader = compiledReader.next // see if there is another reader with the right length\n\t\t}\n\t\tif (this.slowReads++ >= inlineObjectReadThreshold) { // create a fast compiled reader\n\t\t\tlet array = this.length == length ? this : this.slice(0, length)\n\t\t\tcompiledReader = currentDecoder.keyMap \n\t\t\t? new Function('r', 'return {' + array.map(k => currentDecoder.decodeKey(k)).map(k => validName.test(k) ? safeKey(k) + ':r()' : ('[' + JSON.stringify(k) + ']:r()')).join(',') + '}')\n\t\t\t: new Function('r', 'return {' + array.map(key => validName.test(key) ? safeKey(key) + ':r()' : ('[' + JSON.stringify(key) + ']:r()')).join(',') + '}')\n\t\t\tif (this.compiledReader)\n\t\t\t\tcompiledReader.next = this.compiledReader // if there is an existing one, we store multiple readers as a linked list because it is usually pretty rare to have multiple readers (of different length) for the same structure\n\t\t\tcompiledReader.propertyCount = length\n\t\t\tthis.compiledReader = compiledReader\n\t\t\treturn compiledReader(read)\n\t\t}\n\t\tlet object = {}\n\t\tif (currentDecoder.keyMap) for (let i = 0; i < length; i++) object[safeKey(currentDecoder.decodeKey(this[i]))] = read()\n\t\telse for (let i = 0; i < length; i++) {\n\t\t\tobject[safeKey(this[i])] = read();\n\t\t}\n\t\treturn object\n\t}\n\tstructure.slowReads = 0\n\treturn readObject\n}\n\nfunction safeKey(key) {\n\t// protect against prototype pollution\n\tif (typeof key === 'string') return key === '__proto__' ? '__proto_' : key\n\tif (typeof key === 'number' || typeof key === 'boolean' || typeof key === 'bigint') return key.toString();\n\tif (key == null) return key + '';\n\t// protect against expensive (DoS) string conversions\n\tthrow new Error('Invalid property name type ' + typeof key);\n}\n\nlet readFixedString = readStringJS\nlet readString8 = readStringJS\nlet readString16 = readStringJS\nlet readString32 = readStringJS\n\nexport let isNativeAccelerationEnabled = false\nexport function setExtractor(extractStrings) {\n\tisNativeAccelerationEnabled = true\n\treadFixedString = readString(1)\n\treadString8 = readString(2)\n\treadString16 = readString(3)\n\treadString32 = readString(5)\n\tfunction readString(headerLength) {\n\t\treturn function readString(length) {\n\t\t\tlet string = strings[stringPosition++]\n\t\t\tif (string == null) {\n\t\t\t\tif (bundledStrings)\n\t\t\t\t\treturn readStringJS(length)\n\t\t\t\tlet extraction = extractStrings(position, srcEnd, length, src)\n\t\t\t\tif (typeof extraction == 'string') {\n\t\t\t\t\tstring = extraction\n\t\t\t\t\tstrings = EMPTY_ARRAY\n\t\t\t\t} else {\n\t\t\t\t\tstrings = extraction\n\t\t\t\t\tstringPosition = 1\n\t\t\t\t\tsrcStringEnd = 1 // even if a utf-8 string was decoded, must indicate we are in the midst of extracted strings and can't skip strings\n\t\t\t\t\tstring = strings[0]\n\t\t\t\t\tif (string === undefined)\n\t\t\t\t\t\tthrow new Error('Unexpected end of buffer')\n\t\t\t\t}\n\t\t\t}\n\t\t\tlet srcStringLength = string.length\n\t\t\tif (srcStringLength <= length) {\n\t\t\t\tposition += length\n\t\t\t\treturn string\n\t\t\t}\n\t\t\tsrcString = string\n\t\t\tsrcStringStart = position\n\t\t\tsrcStringEnd = position + srcStringLength\n\t\t\tposition += length\n\t\t\treturn string.slice(0, length) // we know we just want the beginning\n\t\t}\n\t}\n}\nfunction readStringJS(length) {\n\tlet result\n\tif (length < 16) {\n\t\tif (result = shortStringInJS(length))\n\t\t\treturn result\n\t}\n\tif (length > 64 && decoder)\n\t\treturn decoder.decode(src.subarray(position, position += length))\n\tconst end = position + length\n\tconst units = []\n\tresult = ''\n\twhile (position < end) {\n\t\tconst byte1 = src[position++]\n\t\tif ((byte1 & 0x80) === 0) {\n\t\t\t// 1 byte\n\t\t\tunits.push(byte1)\n\t\t} else if ((byte1 & 0xe0) === 0xc0) {\n\t\t\t// 2 bytes\n\t\t\tconst byte2 = src[position++] & 0x3f\n\t\t\tunits.push(((byte1 & 0x1f) << 6) | byte2)\n\t\t} else if ((byte1 & 0xf0) === 0xe0) {\n\t\t\t// 3 bytes\n\t\t\tconst byte2 = src[position++] & 0x3f\n\t\t\tconst byte3 = src[position++] & 0x3f\n\t\t\tunits.push(((byte1 & 0x1f) << 12) | (byte2 << 6) | byte3)\n\t\t} else if ((byte1 & 0xf8) === 0xf0) {\n\t\t\t// 4 bytes\n\t\t\tconst byte2 = src[position++] & 0x3f\n\t\t\tconst byte3 = src[position++] & 0x3f\n\t\t\tconst byte4 = src[position++] & 0x3f\n\t\t\tlet unit = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0c) | (byte3 << 0x06) | byte4\n\t\t\tif (unit > 0xffff) {\n\t\t\t\tunit -= 0x10000\n\t\t\t\tunits.push(((unit >>> 10) & 0x3ff) | 0xd800)\n\t\t\t\tunit = 0xdc00 | (unit & 0x3ff)\n\t\t\t}\n\t\t\tunits.push(unit)\n\t\t} else {\n\t\t\tunits.push(byte1)\n\t\t}\n\n\t\tif (units.length >= 0x1000) {\n\t\t\tresult += fromCharCode.apply(String, units)\n\t\t\tunits.length = 0\n\t\t}\n\t}\n\n\tif (units.length > 0) {\n\t\tresult += fromCharCode.apply(String, units)\n\t}\n\n\treturn result\n}\nlet fromCharCode = String.fromCharCode\nfunction longStringInJS(length) {\n\tlet start = position\n\tlet bytes = new Array(length)\n\tfor (let i = 0; i < length; i++) {\n\t\tconst byte = src[position++];\n\t\tif ((byte & 0x80) > 0) {\n\t\t\tposition = start\n \t\t\treturn\n \t\t}\n \t\tbytes[i] = byte\n \t}\n \treturn fromCharCode.apply(String, bytes)\n}\nfunction shortStringInJS(length) {\n\tif (length < 4) {\n\t\tif (length < 2) {\n\t\t\tif (length === 0)\n\t\t\t\treturn ''\n\t\t\telse {\n\t\t\t\tlet a = src[position++]\n\t\t\t\tif ((a & 0x80) > 1) {\n\t\t\t\t\tposition -= 1\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\treturn fromCharCode(a)\n\t\t\t}\n\t\t} else {\n\t\t\tlet a = src[position++]\n\t\t\tlet b = src[position++]\n\t\t\tif ((a & 0x80) > 0 || (b & 0x80) > 0) {\n\t\t\t\tposition -= 2\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (length < 3)\n\t\t\t\treturn fromCharCode(a, b)\n\t\t\tlet c = src[position++]\n\t\t\tif ((c & 0x80) > 0) {\n\t\t\t\tposition -= 3\n\t\t\t\treturn\n\t\t\t}\n\t\t\treturn fromCharCode(a, b, c)\n\t\t}\n\t} else {\n\t\tlet a = src[position++]\n\t\tlet b = src[position++]\n\t\tlet c = src[position++]\n\t\tlet d = src[position++]\n\t\tif ((a & 0x80) > 0 || (b & 0x80) > 0 || (c & 0x80) > 0 || (d & 0x80) > 0) {\n\t\t\tposition -= 4\n\t\t\treturn\n\t\t}\n\t\tif (length < 6) {\n\t\t\tif (length === 4)\n\t\t\t\treturn fromCharCode(a, b, c, d)\n\t\t\telse {\n\t\t\t\tlet e = src[position++]\n\t\t\t\tif ((e & 0x80) > 0) {\n\t\t\t\t\tposition -= 5\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\treturn fromCharCode(a, b, c, d, e)\n\t\t\t}\n\t\t} else if (length < 8) {\n\t\t\tlet e = src[position++]\n\t\t\tlet f = src[position++]\n\t\t\tif ((e & 0x80) > 0 || (f & 0x80) > 0) {\n\t\t\t\tposition -= 6\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (length < 7)\n\t\t\t\treturn fromCharCode(a, b, c, d, e, f)\n\t\t\tlet g = src[position++]\n\t\t\tif ((g & 0x80) > 0) {\n\t\t\t\tposition -= 7\n\t\t\t\treturn\n\t\t\t}\n\t\t\treturn fromCharCode(a, b, c, d, e, f, g)\n\t\t} else {\n\t\t\tlet e = src[position++]\n\t\t\tlet f = src[position++]\n\t\t\tlet g = src[position++]\n\t\t\tlet h = src[position++]\n\t\t\tif ((e & 0x80) > 0 || (f & 0x80) > 0 || (g & 0x80) > 0 || (h & 0x80) > 0) {\n\t\t\t\tposition -= 8\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (length < 10) {\n\t\t\t\tif (length === 8)\n\t\t\t\t\treturn fromCharCode(a, b, c, d, e, f, g, h)\n\t\t\t\telse {\n\t\t\t\t\tlet i = src[position++]\n\t\t\t\t\tif ((i & 0x80) > 0) {\n\t\t\t\t\t\tposition -= 9\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\treturn fromCharCode(a, b, c, d, e, f, g, h, i)\n\t\t\t\t}\n\t\t\t} else if (length < 12) {\n\t\t\t\tlet i = src[position++]\n\t\t\t\tlet j = src[position++]\n\t\t\t\tif ((i & 0x80) > 0 || (j & 0x80) > 0) {\n\t\t\t\t\tposition -= 10\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif (length < 11)\n\t\t\t\t\treturn fromCharCode(a, b, c, d, e, f, g, h, i, j)\n\t\t\t\tlet k = src[position++]\n\t\t\t\tif ((k & 0x80) > 0) {\n\t\t\t\t\tposition -= 11\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\treturn fromCharCode(a, b, c, d, e, f, g, h, i, j, k)\n\t\t\t} else {\n\t\t\t\tlet i = src[position++]\n\t\t\t\tlet j = src[position++]\n\t\t\t\tlet k = src[position++]\n\t\t\t\tlet l = src[position++]\n\t\t\t\tif ((i & 0x80) > 0 || (j & 0x80) > 0 || (k & 0x80) > 0 || (l & 0x80) > 0) {\n\t\t\t\t\tposition -= 12\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif (length < 14) {\n\t\t\t\t\tif (length === 12)\n\t\t\t\t\t\treturn fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l)\n\t\t\t\t\telse {\n\t\t\t\t\t\tlet m = src[position++]\n\t\t\t\t\t\tif ((m & 0x80) > 0) {\n\t\t\t\t\t\t\tposition -= 13\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l, m)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tlet m = src[position++]\n\t\t\t\t\tlet n = src[position++]\n\t\t\t\t\tif ((m & 0x80) > 0 || (n & 0x80) > 0) {\n\t\t\t\t\t\tposition -= 14\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tif (length < 15)\n\t\t\t\t\t\treturn fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l, m, n)\n\t\t\t\t\tlet o = src[position++]\n\t\t\t\t\tif ((o & 0x80) > 0) {\n\t\t\t\t\t\tposition -= 15\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\treturn fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction readBin(length) {\n\treturn currentDecoder.copyBuffers ?\n\t\t// specifically use the copying slice (not the node one)\n\t\tUint8Array.prototype.slice.call(src, position, position += length) :\n\t\tsrc.subarray(position, position += length)\n}\nfunction readExt(length) {\n\tlet type = src[position++]\n\tif (currentExtensions[type]) {\n\t\treturn currentExtensions[type](src.subarray(position, position += length))\n\t}\n\telse\n\t\tthrow new Error('Unknown extension type ' + type)\n}\nlet f32Array = new Float32Array(1)\nlet u8Array = new Uint8Array(f32Array.buffer, 0, 4)\nfunction getFloat16() {\n\tlet byte0 = src[position++]\n\tlet byte1 = src[position++]\n\tlet exponent = (byte0 & 0x7f) >> 2;\n\tif (exponent === 0x1f) { // specials\n\t\tif (byte1 || (byte0 & 3))\n\t\t\treturn NaN;\n\t\treturn (byte0 & 0x80) ? -Infinity : Infinity;\n\t}\n\tif (exponent === 0) { // sub-normals\n\t\t// significand with 10 fractional bits and divided by 2^14\n\t\tlet abs = (((byte0 & 3) << 8) | byte1) / (1 << 24)\n\t\treturn (byte0 & 0x80) ? -abs : abs\n\t}\n\n\tu8Array[3] = (byte0 & 0x80) | // sign bit\n\t\t((exponent >> 1) + 56) // 4 of 5 of the exponent bits, re-offset-ed\n\tu8Array[2] = ((byte0 & 7) << 5) | // last exponent bit and first two mantissa bits\n\t\t(byte1 >> 3) // next 5 bits of mantissa\n\tu8Array[1] = byte1 << 5; // last three bits of mantissa\n\tu8Array[0] = 0;\n\treturn f32Array[0];\n}\n\nlet keyCache = new Array(4096)\nfunction readKey() {\n\tlet length = src[position++]\n\tif (length >= 0x60 && length < 0x78) {\n\t\t// fixstr, potentially use key cache\n\t\tlength = length - 0x60\n\t\tif (srcStringEnd >= position) // if it has been extracted, must use it (and faster anyway)\n\t\t\treturn srcString.slice(position - srcStringStart, (position += length) - srcStringStart)\n\t\telse if (!(srcStringEnd == 0 && srcEnd < 180))\n\t\t\treturn readFixedString(length)\n\t} else { // not cacheable, go back and do a standard read\n\t\tposition--\n\t\treturn read()\n\t}\n\tlet key = ((length << 5) ^ (length > 1 ? dataView.getUint16(position) : length > 0 ? src[position] : 0)) & 0xfff\n\tlet entry = keyCache[key]\n\tlet checkPosition = position\n\tlet end = position + length - 3\n\tlet chunk\n\tlet i = 0\n\tif (entry && entry.bytes == length) {\n\t\twhile (checkPosition < end) {\n\t\t\tchunk = dataView.getUint32(checkPosition)\n\t\t\tif (chunk != entry[i++]) {\n\t\t\t\tcheckPosition = 0x70000000\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcheckPosition += 4\n\t\t}\n\t\tend += 3\n\t\twhile (checkPosition < end) {\n\t\t\tchunk = src[checkPosition++]\n\t\t\tif (chunk != entry[i++]) {\n\t\t\t\tcheckPosition = 0x70000000\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif (checkPosition === end) {\n\t\t\tposition = checkPosition\n\t\t\treturn entry.string\n\t\t}\n\t\tend -= 3\n\t\tcheckPosition = position\n\t}\n\tentry = []\n\tkeyCache[key] = entry\n\tentry.bytes = length\n\twhile (checkPosition < end) {\n\t\tchunk = dataView.getUint32(checkPosition)\n\t\tentry.push(chunk)\n\t\tcheckPosition += 4\n\t}\n\tend += 3\n\twhile (checkPosition < end) {\n\t\tchunk = src[checkPosition++]\n\t\tentry.push(chunk)\n\t}\n\t// for small blocks, avoiding the overhead of the extract call is helpful\n\tlet string = length < 16 ? shortStringInJS(length) : longStringInJS(length)\n\tif (string != null)\n\t\treturn entry.string = string\n\treturn entry.string = readFixedString(length)\n}\n\nexport class Tag {\n\tconstructor(value, tag) {\n\t\tthis.value = value\n\t\tthis.tag = tag\n\t}\n}\n\ncurrentExtensions[0] = (dateString) => {\n\t// string date extension\n\treturn new Date(dateString)\n}\n\ncurrentExtensions[1] = (epochSec) => {\n\t// numeric date extension\n\treturn new Date(Math.round(epochSec * 1000))\n}\n\ncurrentExtensions[2] = (buffer) => {\n\t// bigint extension\n\tlet value = BigInt(0)\n\tfor (let i = 0, l = buffer.byteLength; i < l; i++) {\n\t\tvalue = BigInt(buffer[i]) + (value << BigInt(8))\n\t}\n\treturn value\n}\n\ncurrentExtensions[3] = (buffer) => {\n\t// negative bigint extension\n\treturn BigInt(-1) - currentExtensions[2](buffer)\n}\ncurrentExtensions[4] = (fraction) => {\n\t// best to reparse to maintain accuracy\n\treturn +(fraction[1] + 'e' + fraction[0])\n}\n\ncurrentExtensions[5] = (fraction) => {\n\t// probably not sufficiently accurate\n\treturn fraction[1] * Math.exp(fraction[0] * Math.log(2))\n}\n\n// the registration of the record definition extension\nconst recordDefinition = (id, structure) => {\n\tid = id - 0xe000\n\tlet existingStructure = currentStructures[id]\n\tif (existingStructure && existingStructure.isShared) {\n\t\t(currentStructures.restoreStructures || (currentStructures.restoreStructures = []))[id] = existingStructure\n\t}\n\tcurrentStructures[id] = structure\n\n\tstructure.read = createStructureReader(structure)\n}\ncurrentExtensions[LEGACY_RECORD_INLINE_ID] = (data) => {\n\tlet length = data.length\n\tlet structure = data[1]\n\trecordDefinition(data[0], structure)\n\tlet object = {}\n\tfor (let i = 2; i < length; i++) {\n\t\tlet key = structure[i - 2]\n\t\tobject[safeKey(key)] = data[i]\n\t}\n\treturn object\n}\ncurrentExtensions[14] = (value) => {\n\tif (bundledStrings)\n\t\treturn bundledStrings[0].slice(bundledStrings.position0, bundledStrings.position0 += value)\n\treturn new Tag(value, 14)\n}\ncurrentExtensions[15] = (value) => {\n\tif (bundledStrings)\n\t\treturn bundledStrings[1].slice(bundledStrings.position1, bundledStrings.position1 += value)\n\treturn new Tag(value, 15)\n}\nlet glbl = { Error, RegExp }\ncurrentExtensions[27] = (data) => { // http://cbor.schmorp.de/generic-object\n\treturn (glbl[data[0]] || Error)(data[1], data[2])\n}\nconst packedTable = (read) => {\n\tif (src[position++] != 0x84) {\n\t\tlet error = new Error('Packed values structure must be followed by a 4 element array')\n\t\tif (src.length < position)\n\t\t\terror.incomplete = true\n\t\tthrow error\n\t}\n\tlet newPackedValues = read() // packed values\n\tif (!newPackedValues || !newPackedValues.length) {\n\t\tlet error = new Error('Packed values structure must be followed by a 4 element array')\n\t\terror.incomplete = true\n\t\tthrow error\n\t}\n\tpackedValues = packedValues ? newPackedValues.concat(packedValues.slice(newPackedValues.length)) : newPackedValues\n\tpackedValues.prefixes = read()\n\tpackedValues.suffixes = read()\n\treturn read() // read the rump\n}\npackedTable.handlesRead = true\ncurrentExtensions[51] = packedTable\n\ncurrentExtensions[PACKED_REFERENCE_TAG_ID] = (data) => { // packed reference\n\tif (!packedValues) {\n\t\tif (currentDecoder.getShared)\n\t\t\tloadShared()\n\t\telse\n\t\t\treturn new Tag(data, PACKED_REFERENCE_TAG_ID)\n\t}\n\tif (typeof data == 'number')\n\t\treturn packedValues[16 + (data >= 0 ? 2 * data : (-2 * data - 1))]\n\tlet error = new Error('No support for non-integer packed references yet')\n\tif (data === undefined)\n\t\terror.incomplete = true\n\tthrow error\n}\n\n// The following code is an incomplete implementation of http://cbor.schmorp.de/stringref\n// the real thing would need to implemennt more logic to populate the stringRefs table and\n// maintain a stack of stringRef \"namespaces\".\n//\n// currentExtensions[25] = (id) => {\n// \treturn stringRefs[id]\n// }\n// currentExtensions[256] = (read) => {\n// \tstringRefs = []\n// \ttry {\n// \t\treturn read()\n// \t} finally {\n// \t\tstringRefs = null\n// \t}\n// }\n// currentExtensions[256].handlesRead = true\n\ncurrentExtensions[28] = (read) => { \n\t// shareable http://cbor.schmorp.de/value-sharing (for structured clones)\n\tif (!referenceMap) {\n\t\treferenceMap = new Map()\n\t\treferenceMap.id = 0\n\t}\n\tlet id = referenceMap.id++\n\tlet startingPosition = position\n\tlet token = src[position]\n\tlet target\n\t// TODO: handle Maps, Sets, and other types that can cycle; this is complicated, because you potentially need to read\n\t// ahead past references to record structure definitions\n\tif ((token >> 5) == 4)\n\t\ttarget = []\n\telse\n\t\ttarget = {}\n\n\tlet refEntry = { target } // a placeholder object\n\treferenceMap.set(id, refEntry)\n\tlet targetProperties = read() // read the next value as the target object to id\n\tif (refEntry.used) {// there is a cycle, so we have to assign properties to original target\n\t\tif (Object.getPrototypeOf(target) !== Object.getPrototypeOf(targetProperties)) {\n\t\t\t// this means that the returned target does not match the targetProperties, so we need rerun the read to\n\t\t\t// have the correctly create instance be assigned as a reference, then we do the copy the properties back to the\n\t\t\t// target\n\t\t\t// reset the position so that the read can be repeated\n\t\t\tposition = startingPosition\n\t\t\t// the returned instance is our new target for references\n\t\t\ttarget = targetProperties\n\t\t\treferenceMap.set(id, { target })\n\t\t\ttargetProperties = read()\n\t\t}\n\t\treturn Object.assign(target, targetProperties)\n\t}\n\trefEntry.target = targetProperties // the placeholder wasn't used, replace with the deserialized one\n\treturn targetProperties // no cycle, can just use the returned read object\n}\ncurrentExtensions[28].handlesRead = true\n\ncurrentExtensions[29] = (id) => {\n\t// sharedref http://cbor.schmorp.de/value-sharing (for structured clones)\n\tlet refEntry = referenceMap.get(id)\n\trefEntry.used = true\n\treturn refEntry.target\n}\n\ncurrentExtensions[258] = (array) => new Set(array); // https://github.com/input-output-hk/cbor-sets-spec/blob/master/CBOR_SETS.md\n(currentExtensions[259] = (read) => {\n\t// https://github.com/shanewholloway/js-cbor-codec/blob/master/docs/CBOR-259-spec\n\t// for decoding as a standard Map\n\tif (currentDecoder.mapsAsObjects) {\n\t\tcurrentDecoder.mapsAsObjects = false\n\t\trestoreMapsAsObject = true\n\t}\n\treturn read()\n}).handlesRead = true\nfunction combine(a, b) {\n\tif (typeof a === 'string')\n\t\treturn a + b\n\tif (a instanceof Array)\n\t\treturn a.concat(b)\n\treturn Object.assign({}, a, b)\n}\nfunction getPackedValues() {\n\tif (!packedValues) {\n\t\tif (currentDecoder.getShared)\n\t\t\tloadShared()\n\t\telse\n\t\t\tthrow new Error('No packed values available')\n\t}\n\treturn packedValues\n}\nconst SHARED_DATA_TAG_ID = 0x53687264 // ascii 'Shrd'\ncurrentExtensionRanges.push((tag, input) => {\n\tif (tag >= 225 && tag <= 255)\n\t\treturn combine(getPackedValues().prefixes[tag - 224], input)\n\tif (tag >= 28704 && tag <= 32767)\n\t\treturn combine(getPackedValues().prefixes[tag - 28672], input)\n\tif (tag >= 1879052288 && tag <= 2147483647)\n\t\treturn combine(getPackedValues().prefixes[tag - 1879048192], input)\n\tif (tag >= 216 && tag <= 223)\n\t\treturn combine(input, getPackedValues().suffixes[tag - 216])\n\tif (tag >= 27647 && tag <= 28671)\n\t\treturn combine(input, getPackedValues().suffixes[tag - 27639])\n\tif (tag >= 1811940352 && tag <= 1879048191)\n\t\treturn combine(input, getPackedValues().suffixes[tag - 1811939328])\n\tif (tag == SHARED_DATA_TAG_ID) {// we do a special check for this so that we can keep the currentExtensions as densely stored array (v8 stores arrays densely under about 3000 elements)\n\t\treturn {\n\t\t\tpackedValues: packedValues,\n\t\t\tstructures: currentStructures.slice(0),\n\t\t\tversion: input,\n\t\t}\n\t}\n\tif (tag == 55799) // self-descriptive CBOR tag, just return input value\n\t\treturn input\n})\n\nconst isLittleEndianMachine = new Uint8Array(new Uint16Array([1]).buffer)[0] == 1\nexport const typedArrays = [Uint8Array, Uint8ClampedArray, Uint16Array, Uint32Array,\n\ttypeof BigUint64Array == 'undefined' ? { name:'BigUint64Array' } : BigUint64Array, Int8Array, Int16Array, Int32Array,\n\ttypeof BigInt64Array == 'undefined' ? { name:'BigInt64Array' } : BigInt64Array, Float32Array, Float64Array]\nconst typedArrayTags = [64, 68, 69, 70, 71, 72, 77, 78, 79, 85, 86]\nfor (let i = 0; i < typedArrays.length; i++) {\n\tregisterTypedArray(typedArrays[i], typedArrayTags[i])\n}\nfunction registerTypedArray(TypedArray, tag) {\n\tlet dvMethod = 'get' + TypedArray.name.slice(0, -5)\n\tlet bytesPerElement;\n\tif (typeof TypedArray === 'function')\n\t\tbytesPerElement = TypedArray.BYTES_PER_ELEMENT;\n\telse\n\t\tTypedArray = null;\n\tfor (let littleEndian = 0; littleEndian < 2; littleEndian++) {\n\t\tif (!littleEndian && bytesPerElement == 1)\n\t\t\tcontinue\n\t\tlet sizeShift = bytesPerElement == 2 ? 1 : bytesPerElement == 4 ? 2 : bytesPerElement == 8 ? 3 : 0\n\t\tcurrentExtensions[littleEndian ? tag : (tag - 4)] = (bytesPerElement == 1 || littleEndian == isLittleEndianMachine) ? (buffer) => {\n\t\t\tif (!TypedArray)\n\t\t\t\tthrow new Error('Could not find typed array for code ' + tag)\n\t\t\tif (!currentDecoder.copyBuffers) {\n\t\t\t\t// try provide a direct view, but will only work if we are byte-aligned\n\t\t\t\tif (bytesPerElement === 1 ||\n\t\t\t\t\tbytesPerElement === 2 && !(buffer.byteOffset & 1) ||\n\t\t\t\t\tbytesPerElement === 4 && !(buffer.byteOffset & 3) ||\n\t\t\t\t\tbytesPerElement === 8 && !(buffer.byteOffset & 7))\n\t\t\t\t\treturn new TypedArray(buffer.buffer, buffer.byteOffset, buffer.byteLength >> sizeShift);\n\t\t\t}\n\t\t\t// we have to slice/copy here to get a new ArrayBuffer, if we are not word/byte aligned\n\t\t\treturn new TypedArray(Uint8Array.prototype.slice.call(buffer, 0).buffer)\n\t\t} : buffer => {\n\t\t\tif (!TypedArray)\n\t\t\t\tthrow new Error('Could not find typed array for code ' + tag)\n\t\t\tlet dv = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength)\n\t\t\tlet elements = buffer.length >> sizeShift\n\t\t\tlet ta = new TypedArray(elements)\n\t\t\tlet method = dv[dvMethod]\n\t\t\tfor (let i = 0; i < elements; i++) {\n\t\t\t\tta[i] = method.call(dv, i << sizeShift, littleEndian)\n\t\t\t}\n\t\t\treturn ta\n\t\t}\n\t}\n}\n\nfunction readBundleExt() {\n\tlet length = readJustLength()\n\tlet bundlePosition = position + read()\n\tfor (let i = 2; i < length; i++) {\n\t\t// skip past bundles that were already read\n\t\tlet bundleLength = readJustLength() // this will increment position, so must add to position afterwards\n\t\tposition += bundleLength\n\t}\n\tlet dataPosition = position\n\tposition = bundlePosition\n\tbundledStrings = [readStringJS(readJustLength()), readStringJS(readJustLength())]\n\tbundledStrings.position0 = 0\n\tbundledStrings.position1 = 0\n\tbundledStrings.postBundlePosition = position\n\tposition = dataPosition\n\treturn read()\n}\n\nfunction readJustLength() {\n\tlet token = src[position++] & 0x1f\n\tif (token > 0x17) {\n\t\tswitch (token) {\n\t\t\tcase 0x18:\n\t\t\t\ttoken = src[position++]\n\t\t\t\tbreak\n\t\t\tcase 0x19:\n\t\t\t\ttoken = dataView.getUint16(position)\n\t\t\t\tposition += 2\n\t\t\t\tbreak\n\t\t\tcase 0x1a:\n\t\t\t\ttoken = dataView.getUint32(position)\n\t\t\t\tposition += 4\n\t\t\t\tbreak\n\t\t}\n\t}\n\treturn token\n}\n\nfunction loadShared() {\n\tif (currentDecoder.getShared) {\n\t\tlet sharedData = saveState(() => {\n\t\t\t// save the state in case getShared modifies our buffer\n\t\t\tsrc = null\n\t\t\treturn currentDecoder.getShared()\n\t\t}) || {}\n\t\tlet updatedStructures = sharedData.structures || []\n\t\tcurrentDecoder.sharedVersion = sharedData.version\n\t\tpackedValues = currentDecoder.sharedValues = sharedData.packedValues\n\t\tif (currentStructures === true)\n\t\t\tcurrentDecoder.structures = currentStructures = updatedStructures\n\t\telse\n\t\t\tcurrentStructures.splice.apply(currentStructures, [0, updatedStructures.length].concat(updatedStructures))\n\t}\n}\n\nfunction saveState(callback) {\n\tlet savedSrcEnd = srcEnd\n\tlet savedPosition = position\n\tlet savedStringPosition = stringPosition\n\tlet savedSrcStringStart = srcStringStart\n\tlet savedSrcStringEnd = srcStringEnd\n\tlet savedSrcString = srcString\n\tlet savedStrings = strings\n\tlet savedReferenceMap = referenceMap\n\tlet savedBundledStrings = bundledStrings\n\n\t// TODO: We may need to revisit this if we do more external calls to user code (since it could be slow)\n\tlet savedSrc = new Uint8Array(src.slice(0, srcEnd)) // we copy the data in case it changes while external data is processed\n\tlet savedStructures = currentStructures\n\tlet savedDecoder = currentDecoder\n\tlet savedSequentialMode = sequentialMode\n\tlet value = callback()\n\tsrcEnd = savedSrcEnd\n\tposition = savedPosition\n\tstringPosition = savedStringPosition\n\tsrcStringStart = savedSrcStringStart\n\tsrcStringEnd = savedSrcStringEnd\n\tsrcString = savedSrcString\n\tstrings = savedStrings\n\treferenceMap = savedReferenceMap\n\tbundledStrings = savedBundledStrings\n\tsrc = savedSrc\n\tsequentialMode = savedSequentialMode\n\tcurrentStructures = savedStructures\n\tcurrentDecoder = savedDecoder\n\tdataView = new DataView(src.buffer, src.byteOffset, src.byteLength)\n\treturn value\n}\nexport function clearSource() {\n\tsrc = null\n\treferenceMap = null\n\tcurrentStructures = null\n}\n\nexport function addExtension(extension) {\n\tcurrentExtensions[extension.tag] = extension.decode\n}\n\nexport function setSizeLimits(limits) {\n\tif (limits.maxMapSize) maxMapSize = limits.maxMapSize;\n\tif (limits.maxArraySize) maxArraySize = limits.maxArraySize;\n\tif (limits.maxObjectSize) maxObjectSize = limits.maxObjectSize;\n}\n\nexport const mult10 = new Array(147) // this is a table matching binary exponents to the multiplier to determine significant digit rounding\nfor (let i = 0; i < 256; i++) {\n\tmult10[i] = +('1e' + Math.floor(45.15 - i * 0.30103))\n}\nlet defaultDecoder = new Decoder({ useRecords: false })\nexport const decode = defaultDecoder.decode\nexport const decodeMultiple = defaultDecoder.decodeMultiple\nexport const FLOAT32_OPTIONS = {\n\tNEVER: 0,\n\tALWAYS: 1,\n\tDECIMAL_ROUND: 3,\n\tDECIMAL_FIT: 4\n}\nexport function roundFloat32(float32Number) {\n\tf32Array[0] = float32Number\n\tlet multiplier = mult10[((u8Array[3] & 0x7f) << 1) | (u8Array[2] >> 7)]\n\treturn ((multiplier * float32Number + (float32Number > 0 ? 0.5 : -0.5)) >> 0) / multiplier\n}\n","import { Decoder, mult10, Tag, typedArrays, addExtension as decodeAddExtension } from './decode.js'\nlet textEncoder\ntry {\n\ttextEncoder = new TextEncoder()\n} catch (error) {}\nlet extensions, extensionClasses\nconst Buffer = typeof globalThis === 'object' && globalThis.Buffer;\nconst hasNodeBuffer = typeof Buffer !== 'undefined'\nconst ByteArrayAllocate = hasNodeBuffer ? Buffer.allocUnsafeSlow : Uint8Array\nconst ByteArray = hasNodeBuffer ? Buffer : Uint8Array\nconst MAX_STRUCTURES = 0x100\nconst MAX_BUFFER_SIZE = hasNodeBuffer ? 0x100000000 : 0x7fd00000\nlet serializationId = 1\nlet throwOnIterable\nlet target\nlet targetView\nlet position = 0\nlet safeEnd\nlet bundledStrings = null\nconst MAX_BUNDLE_SIZE = 0xf000\nconst hasNonLatin = /[\\u0080-\\uFFFF]/\nconst RECORD_SYMBOL = Symbol('record-id')\nexport class Encoder extends Decoder {\n\tconstructor(options) {\n\t\tsuper(options)\n\t\tthis.offset = 0\n\t\tlet typeBuffer\n\t\tlet start\n\t\tlet sharedStructures\n\t\tlet hasSharedUpdate\n\t\tlet structures\n\t\tlet referenceMap\n\t\toptions = options || {}\n\t\tlet encodeUtf8 = ByteArray.prototype.utf8Write ? function(string, position, maxBytes) {\n\t\t\treturn target.utf8Write(string, position, maxBytes)\n\t\t} : (textEncoder && textEncoder.encodeInto) ?\n\t\t\tfunction(string, position) {\n\t\t\t\treturn textEncoder.encodeInto(string, target.subarray(position)).written\n\t\t\t} : false\n\n\t\tlet encoder = this\n\t\tlet hasSharedStructures = options.structures || options.saveStructures\n\t\tlet maxSharedStructures = options.maxSharedStructures\n\t\tif (maxSharedStructures == null)\n\t\t\tmaxSharedStructures = hasSharedStructures ? 128 : 0\n\t\tif (maxSharedStructures > 8190)\n\t\t\tthrow new Error('Maximum maxSharedStructure is 8190')\n\t\tlet isSequential = options.sequential\n\t\tif (isSequential) {\n\t\t\tmaxSharedStructures = 0\n\t\t}\n\t\tif (!this.structures)\n\t\t\tthis.structures = []\n\t\tif (this.saveStructures)\n\t\t\tthis.saveShared = this.saveStructures\n\t\tlet samplingPackedValues, packedObjectMap, sharedValues = options.sharedValues\n\t\tlet sharedPackedObjectMap\n\t\tif (sharedValues) {\n\t\t\tsharedPackedObjectMap = Object.create(null)\n\t\t\tfor (let i = 0, l = sharedValues.length; i < l; i++) {\n\t\t\t\tsharedPackedObjectMap[sharedValues[i]] = i\n\t\t\t}\n\t\t}\n\t\tlet recordIdsToRemove = []\n\t\tlet transitionsCount = 0\n\t\tlet serializationsSinceTransitionRebuild = 0\n\t\t\n\t\tthis.mapEncode = function(value, encodeOptions) {\n\t\t\t// Experimental support for premapping keys using _keyMap instad of keyMap - not optiimised yet)\n\t\t\tif (this._keyMap && !this._mapped) {\n\t\t\t\t//console.log('encoding ', value)\n\t\t\t\tswitch (value.constructor.name) {\n\t\t\t\t\tcase 'Array': \n\t\t\t\t\t\tvalue = value.map(r => this.encodeKeys(r))\n\t\t\t\t\t\tbreak\n\t\t\t\t\t//case 'Map': \n\t\t\t\t\t//\tvalue = this.encodeKeys(value)\n\t\t\t\t\t//\tbreak\n\t\t\t\t}\n\t\t\t\t//this._mapped = true\n\t\t\t}\n\t\t\treturn this.encode(value, encodeOptions)\n\t\t}\n\t\t\n\t\tthis.encode = function(value, encodeOptions)\t{\n\t\t\tif (!target) {\n\t\t\t\ttarget = new ByteArrayAllocate(8192)\n\t\t\t\ttargetView = new DataView(target.buffer, 0, 8192)\n\t\t\t\tposition = 0\n\t\t\t}\n\t\t\tsafeEnd = target.length - 10\n\t\t\tif (safeEnd - position < 0x800) {\n\t\t\t\t// don't start too close to the end, \n\t\t\t\ttarget = new ByteArrayAllocate(target.length)\n\t\t\t\ttargetView = new DataView(target.buffer, 0, target.length)\n\t\t\t\tsafeEnd = target.length - 10\n\t\t\t\tposition = 0\n\t\t\t} else if (encodeOptions === REUSE_BUFFER_MODE)\n\t\t\t\tposition = (position + 7) & 0x7ffffff8 // Word align to make any future copying of this buffer faster\n\t\t\tstart = position\n\t\t\tif (encoder.useSelfDescribedHeader) {\n\t\t\t\ttargetView.setUint32(position, 0xd9d9f700) // tag two byte, then self-descriptive tag\n\t\t\t\tposition += 3\n\t\t\t}\n\t\t\treferenceMap = encoder.structuredClone ? new Map() : null\n\t\t\tif (encoder.bundleStrings && typeof value !== 'string') {\n\t\t\t\tbundledStrings = []\n\t\t\t\tbundledStrings.size = Infinity // force a new bundle start on first string\n\t\t\t} else\n\t\t\t\tbundledStrings = null\n\n\t\t\tsharedStructures = encoder.structures\n\t\t\tif (sharedStructures) {\n\t\t\t\tif (sharedStructures.uninitialized) {\n\t\t\t\t\tlet sharedData = encoder.getShared() || {}\n\t\t\t\t\tencoder.structures = sharedStructures = sharedData.structures || []\n\t\t\t\t\tencoder.sharedVersion = sharedData.version\n\t\t\t\t\tlet sharedValues = encoder.sharedValues = sharedData.packedValues\n\t\t\t\t\tif (sharedValues) {\n\t\t\t\t\t\tsharedPackedObjectMap = {}\n\t\t\t\t\t\tfor (let i = 0, l = sharedValues.length; i < l; i++)\n\t\t\t\t\t\t\tsharedPackedObjectMap[sharedValues[i]] = i\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tlet sharedStructuresLength = sharedStructures.length\n\t\t\t\tif (sharedStructuresLength > maxSharedStructures && !isSequential)\n\t\t\t\t\tsharedStructuresLength = maxSharedStructures\n\t\t\t\tif (!sharedStructures.transitions) {\n\t\t\t\t\t// rebuild our structure transitions\n\t\t\t\t\tsharedStructures.transitions = Object.create(null)\n\t\t\t\t\tfor (let i = 0; i < sharedStructuresLength; i++) {\n\t\t\t\t\t\tlet keys = sharedStructures[i]\n\t\t\t\t\t\t//console.log('shared struct keys:', keys)\n\t\t\t\t\t\tif (!keys)\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\tlet nextTransition, transition = sharedStructures.transitions\n\t\t\t\t\t\tfor (let j = 0, l = keys.length; j < l; j++) {\n\t\t\t\t\t\t\tif (transition[RECORD_SYMBOL] === undefined)\n\t\t\t\t\t\t\t\ttransition[RECORD_SYMBOL] = i\n\t\t\t\t\t\t\tlet key = keys[j]\n\t\t\t\t\t\t\tnextTransition = transition[key]\n\t\t\t\t\t\t\tif (!nextTransition) {\n\t\t\t\t\t\t\t\tnextTransition = transition[key] = Object.create(null)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttransition = nextTransition\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttransition[RECORD_SYMBOL] = i | 0x100000\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!isSequential)\n\t\t\t\t\tsharedStructures.nextId = sharedStructuresLength\n\t\t\t}\n\t\t\tif (hasSharedUpdate)\n\t\t\t\thasSharedUpdate = false\n\t\t\tstructures = sharedStructures || []\n\t\t\tpackedObjectMap = sharedPackedObjectMap\n\t\t\tif (options.pack) {\n\t\t\t\tlet packedValues = new Map()\n\t\t\t\tpackedValues.values = []\n\t\t\t\tpackedValues.encoder = encoder\n\t\t\t\tpackedValues.maxValues = options.maxPrivatePackedValues || (sharedPackedObjectMap ? 16 : Infinity)\n\t\t\t\tpackedValues.objectMap = sharedPackedObjectMap || false\n\t\t\t\tpackedValues.samplingPackedValues = samplingPackedValues\n\t\t\t\tfindRepetitiveStrings(value, packedValues)\n\t\t\t\tif (packedValues.values.length > 0) {\n\t\t\t\t\ttarget[position++] = 0xd8 // one-byte tag\n\t\t\t\t\ttarget[position++] = 51 // tag 51 for packed shared structures https://www.potaroo.net/ietf/ids/draft-ietf-cbor-packed-03.txt\n\t\t\t\t\twriteArrayHeader(4)\n\t\t\t\t\tlet valuesArray = packedValues.values\n\t\t\t\t\tencode(valuesArray)\n\t\t\t\t\twriteArrayHeader(0) // prefixes\n\t\t\t\t\twriteArrayHeader(0) // suffixes\n\t\t\t\t\tpackedObjectMap = Object.create(sharedPackedObjectMap || null)\n\t\t\t\t\tfor (let i = 0, l = valuesArray.length; i < l; i++) {\n\t\t\t\t\t\tpackedObjectMap[valuesArray[i]] = i\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrowOnIterable = encodeOptions & THROW_ON_ITERABLE;\n\t\t\ttry {\n\t\t\t\tif (throwOnIterable)\n\t\t\t\t\treturn;\n\t\t\t\tencode(value)\n\t\t\t\tif (bundledStrings) {\n\t\t\t\t\twriteBundles(start, encode)\n\t\t\t\t}\n\t\t\t\tencoder.offset = position // update the offset so next serialization doesn't write over our buffer, but can continue writing to same buffer sequentially\n\t\t\t\tif (referenceMap && referenceMap.idsToInsert) {\n\t\t\t\t\tposition += referenceMap.idsToInsert.length * 2\n\t\t\t\t\tif (position > safeEnd)\n\t\t\t\t\t\tmakeRoom(position)\n\t\t\t\t\tencoder.offset = position\n\t\t\t\t\tlet serialized = insertIds(target.subarray(start, position), referenceMap.idsToInsert)\n\t\t\t\t\treferenceMap = null\n\t\t\t\t\treturn serialized\n\t\t\t\t}\n\t\t\t\tif (encodeOptions & REUSE_BUFFER_MODE) {\n\t\t\t\t\ttarget.start = start\n\t\t\t\t\ttarget.end = position\n\t\t\t\t\treturn target\n\t\t\t\t}\n\t\t\t\treturn target.subarray(start, position) // position can change if we call encode again in saveShared, so we get the buffer now\n\t\t\t} finally {\n\t\t\t\tif (sharedStructures) {\n\t\t\t\t\tif (serializationsSinceTransitionRebuild < 10)\n\t\t\t\t\t\tserializationsSinceTransitionRebuild++\n\t\t\t\t\tif (sharedStructures.length > maxSharedStructures)\n\t\t\t\t\t\tsharedStructures.length = maxSharedStructures\n\t\t\t\t\tif (transitionsCount > 10000) {\n\t\t\t\t\t\t// force a rebuild occasionally after a lot of transitions so it can get cleaned up\n\t\t\t\t\t\tsharedStructures.transitions = null\n\t\t\t\t\t\tserializationsSinceTransitionRebuild = 0\n\t\t\t\t\t\ttransitionsCount = 0\n\t\t\t\t\t\tif (recordIdsToRemove.length > 0)\n\t\t\t\t\t\t\trecordIdsToRemove = []\n\t\t\t\t\t} else if (recordIdsToRemove.length > 0 && !isSequential) {\n\t\t\t\t\t\tfor (let i = 0, l = recordIdsToRemove.length; i < l; i++) {\n\t\t\t\t\t\t\trecordIdsToRemove[i][RECORD_SYMBOL] = undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t\trecordIdsToRemove = []\n\t\t\t\t\t\t//sharedStructures.nextId = maxSharedStructures\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (hasSharedUpdate && encoder.saveShared) {\n\t\t\t\t\tif (encoder.structures.length > maxSharedStructures) {\n\t\t\t\t\t\tencoder.structures = encoder.structures.slice(0, maxSharedStructures)\n\t\t\t\t\t}\n\t\t\t\t\t// we can't rely on start/end with REUSE_BUFFER_MODE since they will (probably) change when we save\n\t\t\t\t\tlet returnBuffer = target.subarray(start, position)\n\t\t\t\t\tif (encoder.updateSharedData() === false)\n\t\t\t\t\t\treturn encoder.encode(value) // re-encode if it fails\n\t\t\t\t\treturn returnBuffer\n\t\t\t\t}\n\t\t\t\tif (encodeOptions & RESET_BUFFER_MODE)\n\t\t\t\t\tposition = start\n\t\t\t}\n\t\t}\n\t\tthis.findCommonStringsToPack = () => {\n\t\t\tsamplingPackedValues = new Map()\n\t\t\tif (!sharedPackedObjectMap)\n\t\t\t\tsharedPackedObjectMap = Object.create(null)\n\t\t\treturn (options) => {\n\t\t\t\tlet threshold = options && options.threshold || 4\n\t\t\t\tlet position = this.pack ? options.maxPrivatePackedValues || 16 : 0\n\t\t\t\tif (!sharedValues)\n\t\t\t\t\tsharedValues = this.sharedValues = []\n\t\t\t\tfor (let [ key, status ] of samplingPackedValues) {\n\t\t\t\t\tif (status.count > threshold) {\n\t\t\t\t\t\tsharedPackedObjectMap[key] = position++\n\t\t\t\t\t\tsharedValues.push(key)\n\t\t\t\t\t\thasSharedUpdate = true\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\twhile (this.saveShared && this.updateSharedData() === false) {}\n\t\t\t\tsamplingPackedValues = null\n\t\t\t}\n\t\t}\n\t\tconst encode = (value) => {\n\t\t\tif (position > safeEnd)\n\t\t\t\ttarget = makeRoom(position)\n\n\t\t\tvar type = typeof value\n\t\t\tvar length\n\t\t\tif (type === 'string') {\n\t\t\t\tif (packedObjectMap) {\n\t\t\t\t\tlet packedPosition = packedObjectMap[value]\n\t\t\t\t\tif (packedPosition >= 0) {\n\t\t\t\t\t\tif (packedPosition < 16)\n\t\t\t\t\t\t\ttarget[position++] = packedPosition + 0xe0 // simple values, defined in https://www.potaroo.net/ietf/ids/draft-ietf-cbor-packed-03.txt\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\ttarget[position++] = 0xc6 // tag 6 defined in https://www.potaroo.net/ietf/ids/draft-ietf-cbor-packed-03.txt\n\t\t\t\t\t\t\tif (packedPosition & 1)\n\t\t\t\t\t\t\t\tencode((15 - packedPosition) >> 1)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tencode((packedPosition - 16) >> 1)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn\n/*\t\t\t\t\t\t} else if (packedStatus.serializationId != serializationId) {\n\t\t\t\t\t\t\tpackedStatus.serializationId = serializationId\n\t\t\t\t\t\t\tpackedStatus.count = 1\n\t\t\t\t\t\t\tif (options.sharedPack) {\n\t\t\t\t\t\t\t\tlet sharedCount = packedStatus.sharedCount = (packedStatus.sharedCount || 0) + 1\n\t\t\t\t\t\t\t\tif (shareCount > (options.sharedPack.threshold || 5)) {\n\t\t\t\t\t\t\t\t\tlet sharedPosition = packedStatus.position = packedStatus.nextSharedPosition\n\t\t\t\t\t\t\t\t\thasSharedUpdate = true\n\t\t\t\t\t\t\t\t\tif (sharedPosition < 16)\n\t\t\t\t\t\t\t\t\t\ttarget[position++] = sharedPosition + 0xc0\n\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} // else any in-doc incrementation?*/\n\t\t\t\t\t} else if (samplingPackedValues && !options.pack) {\n\t\t\t\t\t\tlet status = samplingPackedValues.get(value)\n\t\t\t\t\t\tif (status)\n\t\t\t\t\t\t\tstatus.count++\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tsamplingPackedValues.set(value, {\n\t\t\t\t\t\t\t\tcount: 1,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tlet strLength = value.length\n\t\t\t\tif (bundledStrings && strLength >= 4 && strLength < 0x400) {\n\t\t\t\t\tif ((bundledStrings.size += strLength) > MAX_BUNDLE_SIZE) {\n\t\t\t\t\t\tlet extStart\n\t\t\t\t\t\tlet maxBytes = (bundledStrings[0] ? bundledStrings[0].length * 3 + bundledStrings[1].length : 0) + 10\n\t\t\t\t\t\tif (position + maxBytes > safeEnd)\n\t\t\t\t\t\t\ttarget = makeRoom(position + maxBytes)\n\t\t\t\t\t\ttarget[position++] = 0xd9 // tag 16-bit\n\t\t\t\t\t\ttarget[position++] = 0xdf // tag 0xdff9\n\t\t\t\t\t\ttarget[position++] = 0xf9\n\t\t\t\t\t\t// TODO: If we only have one bundle with any string data, only write one string bundle\n\t\t\t\t\t\ttarget[position++] = bundledStrings.position ? 0x84 : 0x82 // array of 4 or 2 elements depending on if we write bundles\n\t\t\t\t\t\ttarget[position++] = 0x1a // 32-bit unsigned int\n\t\t\t\t\t\textStart = position - start\n\t\t\t\t\t\tposition += 4 // reserve for writing bundle reference\n\t\t\t\t\t\tif (bundledStrings.position) {\n\t\t\t\t\t\t\twriteBundles(start, encode) // write the last bundles\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbundledStrings = ['', ''] // create new ones\n\t\t\t\t\t\tbundledStrings.size = 0\n\t\t\t\t\t\tbundledStrings.position = extStart\n\t\t\t\t\t}\n\t\t\t\t\tlet twoByte = hasNonLatin.test(value)\n\t\t\t\t\tbundledStrings[twoByte ? 0 : 1] += value\n\t\t\t\t\ttarget[position++] = twoByte ? 0xce : 0xcf\n\t\t\t\t\tencode(strLength);\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tlet headerSize\n\t\t\t\t// first we estimate the header size, so we can write to the correct location\n\t\t\t\tif (strLength < 0x20) {\n\t\t\t\t\theaderSize = 1\n\t\t\t\t} else if (strLength < 0x100) {\n\t\t\t\t\theaderSize = 2\n\t\t\t\t} else if (strLength < 0x10000) {\n\t\t\t\t\theaderSize = 3\n\t\t\t\t} else {\n\t\t\t\t\theaderSize = 5\n\t\t\t\t}\n\t\t\t\tlet maxBytes = strLength * 3\n\t\t\t\tif (position + maxBytes > safeEnd)\n\t\t\t\t\ttarget = makeRoom(position + maxBytes)\n\n\t\t\t\tif (strLength < 0x40 || !encodeUtf8) {\n\t\t\t\t\tlet i, c1, c2, strPosition = position + headerSize\n\t\t\t\t\tfor (i = 0; i < strLength; i++) {\n\t\t\t\t\t\tc1 = value.charCodeAt(i)\n\t\t\t\t\t\tif (c1 < 0x80) {\n\t\t\t\t\t\t\ttarget[strPosition++] = c1\n\t\t\t\t\t\t} else if (c1 < 0x800) {\n\t\t\t\t\t\t\ttarget[strPosition++] = c1 >> 6 | 0xc0\n\t\t\t\t\t\t\ttarget[strPosition++] = c1 & 0x3f | 0x80\n\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t(c1 & 0xfc00) === 0xd800 &&\n\t\t\t\t\t\t\t((c2 = value.charCodeAt(i + 1)) & 0xfc00) === 0xdc00\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tc1 = 0x10000 + ((c1 & 0x03ff) << 10) + (c2 & 0x03ff)\n\t\t\t\t\t\t\ti++\n\t\t\t\t\t\t\ttarget[strPosition++] = c1 >> 18 | 0xf0\n\t\t\t\t\t\t\ttarget[strPosition++] = c1 >> 12 & 0x3f | 0x80\n\t\t\t\t\t\t\ttarget[strPosition++] = c1 >> 6 & 0x3f | 0x80\n\t\t\t\t\t\t\ttarget[strPosition++] = c1 & 0x3f | 0x80\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ttarget[strPosition++] = c1 >> 12 | 0xe0\n\t\t\t\t\t\t\ttarget[strPosition++] = c1 >> 6 & 0x3f | 0x80\n\t\t\t\t\t\t\ttarget[strPosition++] = c1 & 0x3f | 0x80\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tlength = strPosition - position - headerSize\n\t\t\t\t} else {\n\t\t\t\t\tlength = encodeUtf8(value, position + headerSize, maxBytes)\n\t\t\t\t}\n\n\t\t\t\tif (length < 0x18) {\n\t\t\t\t\ttarget[position++] = 0x60 | length\n\t\t\t\t} else if (length < 0x100) {\n\t\t\t\t\tif (headerSize < 2) {\n\t\t\t\t\t\ttarget.copyWithin(position + 2, position + 1, position + 1 + length)\n\t\t\t\t\t}\n\t\t\t\t\ttarget[position++] = 0x78\n\t\t\t\t\ttarget[position++] = length\n\t\t\t\t} else if (length < 0x10000) {\n\t\t\t\t\tif (headerSize < 3) {\n\t\t\t\t\t\ttarget.copyWithin(position + 3, position + 2, position + 2 + length)\n\t\t\t\t\t}\n\t\t\t\t\ttarget[position++] = 0x79\n\t\t\t\t\ttarget[position++] = length >> 8\n\t\t\t\t\ttarget[position++] = length & 0xff\n\t\t\t\t} else {\n\t\t\t\t\tif (headerSize < 5) {\n\t\t\t\t\t\ttarget.copyWithin(position + 5, position + 3, position + 3 + length)\n\t\t\t\t\t}\n\t\t\t\t\ttarget[position++] = 0x7a\n\t\t\t\t\ttargetView.setUint32(position, length)\n\t\t\t\t\tposition += 4\n\t\t\t\t}\n\t\t\t\tposition += length\n\t\t\t} else if (type === 'number') {\n\t\t\t\tif (!this.alwaysUseFloat && value >>> 0 === value) {// positive integer, 32-bit or less\n\t\t\t\t\t// positive uint\n\t\t\t\t\tif (value < 0x18) {\n\t\t\t\t\t\ttarget[position++] = value\n\t\t\t\t\t} else if (value < 0x100) {\n\t\t\t\t\t\ttarget[position++] = 0x18\n\t\t\t\t\t\ttarget[position++] = value\n\t\t\t\t\t} else if (value < 0x10000) {\n\t\t\t\t\t\ttarget[position++] = 0x19\n\t\t\t\t\t\ttarget[position++] = value >> 8\n\t\t\t\t\t\ttarget[position++] = value & 0xff\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttarget[position++] = 0x1a\n\t\t\t\t\t\ttargetView.setUint32(position, value)\n\t\t\t\t\t\tposition += 4\n\t\t\t\t\t}\n\t\t\t\t} else if (!this.alwaysUseFloat && value >> 0 === value) { // negative integer\n\t\t\t\t\tif (value >= -0x18) {\n\t\t\t\t\t\ttarget[position++] = 0x1f - value\n\t\t\t\t\t} else if (value >= -0x100) {\n\t\t\t\t\t\ttarget[position++] = 0x38\n\t\t\t\t\t\ttarget[position++] = ~value\n\t\t\t\t\t} else if (value >= -0x10000) {\n\t\t\t\t\t\ttarget[position++] = 0x39\n\t\t\t\t\t\ttargetView.setUint16(position, ~value)\n\t\t\t\t\t\tposition += 2\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttarget[position++] = 0x3a\n\t\t\t\t\t\ttargetView.setUint32(position, ~value)\n\t\t\t\t\t\tposition += 4\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tlet useFloat32\n\t\t\t\t\tif ((useFloat32 = this.useFloat32) > 0 && value < 0x100000000 && value >= -0x80000000) {\n\t\t\t\t\t\ttarget[position++] = 0xfa\n\t\t\t\t\t\ttargetView.setFloat32(position, value)\n\t\t\t\t\t\tlet xShifted\n\t\t\t\t\t\tif (useFloat32 < 4 ||\n\t\t\t\t\t\t\t\t// this checks for rounding of numbers that were encoded in 32-bit float to nearest significant decimal digit that could be preserved\n\t\t\t\t\t\t\t\t((xShifted = value * mult10[((target[position] & 0x7f) << 1) | (target[position + 1] >> 7)]) >> 0) === xShifted) {\n\t\t\t\t\t\t\tposition += 4\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t} else\n\t\t\t\t\t\t\tposition-- // move back into position for writing a double\n\t\t\t\t\t}\n\t\t\t\t\ttarget[position++] = 0xfb\n\t\t\t\t\ttargetView.setFloat64(position, value)\n\t\t\t\t\tposition += 8\n\t\t\t\t}\n\t\t\t} else if (type === 'object') {\n\t\t\t\tif (!value)\n\t\t\t\t\ttarget[position++] = 0xf6\n\t\t\t\telse {\n\t\t\t\t\tif (referenceMap) {\n\t\t\t\t\t\tlet referee = referenceMap.get(value)\n\t\t\t\t\t\tif (referee) {\n\t\t\t\t\t\t\ttarget[position++] = 0xd8\n\t\t\t\t\t\t\ttarget[position++] = 29 // http://cbor.schmorp.de/value-sharing\n\t\t\t\t\t\t\ttarget[position++] = 0x19 // 16-bit uint\n\t\t\t\t\t\t\tif (!referee.references) {\n\t\t\t\t\t\t\t\tlet idsToInsert = referenceMap.idsToInsert || (referenceMap.idsToInsert = [])\n\t\t\t\t\t\t\t\treferee.references = []\n\t\t\t\t\t\t\t\tidsToInsert.push(referee)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treferee.references.push(position - start)\n\t\t\t\t\t\t\tposition += 2 // TODO: also support 32-bit\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t} else \n\t\t\t\t\t\t\treferenceMap.set(value, { offset: position - start })\n\t\t\t\t\t}\n\t\t\t\t\tlet constructor = value.constructor\n\t\t\t\t\tif (constructor === Object) {\n\t\t\t\t\t\twriteObject(value)\n\t\t\t\t\t} else if (constructor === Array) {\n\t\t\t\t\t\tlength = value.length\n\t\t\t\t\t\tif (length < 0x18) {\n\t\t\t\t\t\t\ttarget[position++] = 0x80 | length\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\twriteArrayHeader(length)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (let i = 0; i < length; i++) {\n\t\t\t\t\t\t\tencode(value[i])\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (constructor === Map) {\n\t\t\t\t\t\tif (this.mapsAsObjects ? this.useTag259ForMaps !== false : this.useTag259ForMaps) {\n\t\t\t\t\t\t\t// use Tag 259 (https://github.com/shanewholloway/js-cbor-codec/blob/master/docs/CBOR-259-spec--explicit-maps.md) for maps if the user wants it that way\n\t\t\t\t\t\t\ttarget[position++] = 0xd9\n\t\t\t\t\t\t\ttarget[position++] = 1\n\t\t\t\t\t\t\ttarget[position++] = 3\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlength = value.size\n\t\t\t\t\t\tif (length < 0x18) {\n\t\t\t\t\t\t\ttarget[position++] = 0xa0 | length\n\t\t\t\t\t\t} else if (length < 0x100) {\n\t\t\t\t\t\t\ttarget[position++] = 0xb8\n\t\t\t\t\t\t\ttarget[position++] = length\n\t\t\t\t\t\t} else if (length < 0x10000) {\n\t\t\t\t\t\t\ttarget[position++] = 0xb9\n\t\t\t\t\t\t\ttarget[position++] = length >> 8\n\t\t\t\t\t\t\ttarget[position++] = length & 0xff\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ttarget[position++] = 0xba\n\t\t\t\t\t\t\ttargetView.setUint32(position, length)\n\t\t\t\t\t\t\tposition += 4\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (encoder.keyMap) { \n\t\t\t\t\t\t\tfor (let [ key, entryValue ] of value) {\n\t\t\t\t\t\t\t\tencode(encoder.encodeKey(key))\n\t\t\t\t\t\t\t\tencode(entryValue)\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t} else { \n\t\t\t\t\t\t\tfor (let [ key, entryValue ] of value) {\n\t\t\t\t\t\t\t\tencode(key) \n\t\t\t\t\t\t\t\tencode(entryValue)\n\t\t\t\t\t\t\t} \t\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfor (let i = 0, l = extensions.length; i < l; i++) {\n\t\t\t\t\t\t\tlet extensionClass = extensionClasses[i]\n\t\t\t\t\t\t\tif (value instanceof extensionClass) {\n\t\t\t\t\t\t\t\tlet extension = extensions[i]\n\t\t\t\t\t\t\t\tlet tag = extension.tag\n\t\t\t\t\t\t\t\tif (tag == undefined)\n\t\t\t\t\t\t\t\t\ttag = extension.getTag && extension.getTag.call(this, value)\n\t\t\t\t\t\t\t\tif (tag < 0x18) {\n\t\t\t\t\t\t\t\t\ttarget[position++] = 0xc0 | tag\n\t\t\t\t\t\t\t\t} else if (tag < 0x100) {\n\t\t\t\t\t\t\t\t\ttarget[position++] = 0xd8\n\t\t\t\t\t\t\t\t\ttarget[position++] = tag\n\t\t\t\t\t\t\t\t} else if (tag < 0x10000) {\n\t\t\t\t\t\t\t\t\ttarget[position++] = 0xd9\n\t\t\t\t\t\t\t\t\ttarget[position++] = tag >> 8\n\t\t\t\t\t\t\t\t\ttarget[position++] = tag & 0xff\n\t\t\t\t\t\t\t\t} else if (tag > -1) {\n\t\t\t\t\t\t\t\t\ttarget[position++] = 0xda\n\t\t\t\t\t\t\t\t\ttargetView.setUint32(position, tag)\n\t\t\t\t\t\t\t\t\tposition += 4\n\t\t\t\t\t\t\t\t} // else undefined, don't write tag\n\t\t\t\t\t\t\t\textension.encode.call(this, value, encode, makeRoom)\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (value[Symbol.iterator]) {\n\t\t\t\t\t\t\tif (throwOnIterable) {\n\t\t\t\t\t\t\t\tlet error = new Error('Iterable should be serialized as iterator')\n\t\t\t\t\t\t\t\terror.iteratorNotHandled = true;\n\t\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttarget[position++] = 0x9f // indefinite length array\n\t\t\t\t\t\t\tfor (let entry of value) {\n\t\t\t\t\t\t\t\tencode(entry)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttarget[position++] = 0xff // stop-code\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (value[Symbol.asyncIterator] || isBlob(value)) {\n\t\t\t\t\t\t\tlet error = new Error('Iterable/blob should be serialized as iterator')\n\t\t\t\t\t\t\terror.iteratorNotHandled = true;\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (this.useToJSON && value.toJSON) {\n\t\t\t\t\t\t\tconst json = value.toJSON()\n\t\t\t\t\t\t\t// if for some reason value.toJSON returns itself it'll loop forever\n\t\t\t\t\t\t\tif (json !== value)\n\t\t\t\t\t\t\t\treturn encode(json)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// no extension found, write as a plain object\n\t\t\t\t\t\twriteObject(value)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (type === 'boolean') {\n\t\t\t\ttarget[position++] = value ? 0xf5 : 0xf4\n\t\t\t} else if (type === 'bigint') {\n\t\t\t\tif (value < (BigInt(1)<<BigInt(64)) && value >= 0) {\n\t\t\t\t\t// use an unsigned int as long as it fits\n\t\t\t\t\ttarget[position++] = 0x1b\n\t\t\t\t\ttargetView.setBigUint64(position, value)\n\t\t\t\t} else if (value > -(BigInt(1)<<BigInt(64)) && value < 0) {\n\t\t\t\t\t// if we can fit an unsigned int, use that\n\t\t\t\t\ttarget[position++] = 0x3b\n\t\t\t\t\ttargetView.setBigUint64(position, -value - BigInt(1))\n\t\t\t\t} else {\n\t\t\t\t\t// overflow\n\t\t\t\t\tif (this.largeBigIntToFloat) {\n\t\t\t\t\t\ttarget[position++] = 0xfb\n\t\t\t\t\t\ttargetView.setFloat64(position, Number(value))\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (value >= BigInt(0))\n\t\t\t\t\t\t\ttarget[position++] = 0xc2 // tag 2\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\ttarget[position++] = 0xc3 // tag 2\n\t\t\t\t\t\t\tvalue = BigInt(-1) - value;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlet bytes = [];\n\t\t\t\t\t\twhile (value) {\n\t\t\t\t\t\t\tbytes.push(Number(value & BigInt(0xff)));\n\t\t\t\t\t\t\tvalue >>= BigInt(8);\n\t\t\t\t\t\t}\n\t\t\t\t\t\twriteBuffer(new Uint8Array(bytes.reverse()), makeRoom);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tposition += 8\n\t\t\t} else if (type === 'undefined') {\n\t\t\t\ttarget[position++] = 0xf7\n\t\t\t} else {\n\t\t\t\tthrow new Error('Unknown type: ' + type)\n\t\t\t}\n\t\t}\n\n\t\tconst writeObject = this.useRecords === false ? this.variableMapSize ? (object) => {\n\t\t\t// this method is slightly slower, but generates \"preferred serialization\" (optimally small for smaller objects)\n\t\t\tlet keys = Object.keys(object)\n\t\t\tlet vals = Object.values(object)\n\t\t\tlet length = keys.length\n\t\t\tif (length < 0x18) {\n\t\t\t\ttarget[position++] = 0xa0 | length\n\t\t\t} else if (length < 0x100) {\n\t\t\t\ttarget[position++] = 0xb8\n\t\t\t\ttarget[position++] = length\n\t\t\t} else if (length < 0x10000) {\n\t\t\t\ttarget[position++] = 0xb9\n\t\t\t\ttarget[position++] = length >> 8\n\t\t\t\ttarget[position++] = length & 0xff\n\t\t\t} else {\n\t\t\t\ttarget[position++] = 0xba\n\t\t\t\ttargetView.setUint32(position, length)\n\t\t\t\tposition += 4\n\t\t\t}\n\t\t\tlet key\n\t\t\tif (encoder.keyMap) { \n\t\t\t\tfor (let i = 0; i < length; i++) {\n\t\t\t\t\tencode(encoder.encodeKey(keys[i]))\n\t\t\t\t\tencode(vals[i])\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor (let i = 0; i < length; i++) {\n\t\t\t\t\tencode(keys[i])\n\t\t\t\t\tencode(vals[i])\n\t\t\t\t}\n\t\t\t}\n\t\t} :\n\t\t(object) => {\n\t\t\ttarget[position++] = 0xb9 // always use map 16, so we can preallocate and set the length afterwards\n\t\t\tlet objectOffset = position - start\n\t\t\tposition += 2\n\t\t\tlet size = 0\n\t\t\tif (encoder.keyMap) {\n\t\t\t\tfor (let key in object) if (typeof object.hasOwnProperty !== 'function' || object.hasOwnProperty(key)) {\n\t\t\t\t\tencode(encoder.encodeKey(key))\n\t\t\t\t\tencode(object[key])\n\t\t\t\t\tsize++\n\t\t\t\t}\n\t\t\t} else { \n\t\t\t\tfor (let key in object) if (typeof object.hasOwnProperty !== 'function' || object.hasOwnProperty(key)) {\n\t\t\t\t\t\tencode(key)\n\t\t\t\t\t\tencode(object[key])\n\t\t\t\t\tsize++\n\t\t\t\t}\n\t\t\t}\n\t\t\ttarget[objectOffset++ + start] = size >> 8\n\t\t\ttarget[objectOffset + start] = size & 0xff\n\t\t} :\n\t\t(object, skipValues) => {\n\t\t\tlet nextTransition, transition = structures.transitions || (structures.transitions = Object.create(null))\n\t\t\tlet newTransitions = 0\n\t\t\tlet length = 0\n\t\t\tlet parentRecordId\n\t\t\tlet keys\n\t\t\tif (this.keyMap) {\n\t\t\t\tkeys = Object.keys(object).map(k => this.encodeKey(k))\n\t\t\t\tlength = keys.length\n\t\t\t\tfor (let i = 0; i < length; i++) {\n\t\t\t\t\tlet key = keys[i]\n\t\t\t\t\tnextTransition = transition[key]\n\t\t\t\t\tif (!nextTransition) {\n\t\t\t\t\t\tnextTransition = transition[key] = Object.create(null)\n\t\t\t\t\t\tnewTransitions++\n\t\t\t\t\t}\n\t\t\t\t\ttransition = nextTransition\n\t\t\t\t}\t\t\t\t\n\t\t\t} else {\n\t\t\t\tfor (let key in object) if (typeof object.hasOwnProperty !== 'function' || object.hasOwnProperty(key)) {\n\t\t\t\t\tnextTransition = transition[key]\n\t\t\t\t\tif (!nextTransition) {\n\t\t\t\t\t\tif (transition[RECORD_SYMBOL] & 0x100000) {// this indicates it is a brancheable/extendable terminal node, so we will use this record id and extend it\n\t\t\t\t\t\t\tparentRecordId = transition[RECORD_SYMBOL] & 0xffff\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnextTransition = transition[key] = Object.create(null)\n\t\t\t\t\t\tnewTransitions++\n\t\t\t\t\t}\n\t\t\t\t\ttransition = nextTransition\n\t\t\t\t\tlength++\n\t\t\t\t}\n\t\t\t}\n\t\t\tlet recordId = transition[RECORD_SYMBOL]\n\t\t\tif (recordId !== undefined) {\n\t\t\t\trecordId &= 0xffff\n\t\t\t\ttarget[position++] = 0xd9\n\t\t\t\ttarget[position++] = (recordId >> 8) | 0xe0\n\t\t\t\ttarget[position++] = recordId & 0xff\n\t\t\t} else {\n\t\t\t\tif (!keys)\n\t\t\t\t\tkeys = transition.__keys__ || (transition.__keys__ = Object.keys(object))\n\t\t\t\tif (parentRecordId === undefined) {\n\t\t\t\t\trecordId = structures.nextId++\n\t\t\t\t\tif (!recordId) {\n\t\t\t\t\t\trecordId = 0\n\t\t\t\t\t\tstructures.nextId = 1\n\t\t\t\t\t}\n\t\t\t\t\tif (recordId >= MAX_STRUCTURES) {// cycle back around\n\t\t\t\t\t\tstructures.nextId = (recordId = maxSharedStructures) + 1\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\trecordId = parentRecordId\n\t\t\t\t}\n\t\t\t\tstructures[recordId] = keys\n\t\t\t\tif (recordId < maxSharedStructures) {\n\t\t\t\t\ttarget[position++] = 0xd9\n\t\t\t\t\ttarget[position++] = (recordId >> 8) | 0xe0\n\t\t\t\t\ttarget[position++] = recordId & 0xff\n\t\t\t\t\ttransition = structures.transitions\n\t\t\t\t\tfor (let i = 0; i < length; i++) {\n\t\t\t\t\t\tif (transition[RECORD_SYMBOL] === undefined || (transition[RECORD_SYMBOL] & 0x100000))\n\t\t\t\t\t\t\ttransition[RECORD_SYMBOL] = recordId\n\t\t\t\t\t\ttransition = transition[keys[i]]\n\t\t\t\t\t}\n\t\t\t\t\ttransition[RECORD_SYMBOL] = recordId | 0x100000 // indicates it is a extendable terminal\n\t\t\t\t\thasSharedUpdate = true\n\t\t\t\t} else {\n\t\t\t\t\ttransition[RECORD_SYMBOL] = recordId\n\t\t\t\t\ttargetView.setUint32(position, 0xd9dfff00) // tag two byte, then record definition id\n\t\t\t\t\tposition += 3\n\t\t\t\t\tif (newTransitions)\n\t\t\t\t\t\ttransitionsCount += serializationsSinceTransitionRebuild * newTransitions\n\t\t\t\t\t// record the removal of the id, we can maintain our shared structure\n\t\t\t\t\tif (recordIdsToRemove.length >= MAX_STRUCTURES - maxSharedStructures)\n\t\t\t\t\t\trecordIdsToRemove.shift()[RECORD_SYMBOL] = undefined // we are cycling back through, and have to remove old ones\n\t\t\t\t\trecordIdsToRemove.push(transition)\n\t\t\t\t\twriteArrayHeader(length + 2)\n\t\t\t\t\tencode(0xe000 + recordId)\n\t\t\t\t\tencode(keys)\n\t\t\t\t\tif (skipValues) return; // special exit for iterator\n\t\t\t\t\tfor (let key in object)\n\t\t\t\t\t\tif (typeof object.hasOwnProperty !== 'function' || object.hasOwnProperty(key))\n\t\t\t\t\t\t\tencode(object[key])\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (length < 0x18) { // write the array header\n\t\t\t\ttarget[position++] = 0x80 | length\n\t\t\t} else {\n\t\t\t\twriteArrayHeader(length)\n\t\t\t}\n\t\t\tif (skipValues) return; // special exit for iterator\n\t\t\tfor (let key in object)\n\t\t\t\tif (typeof object.hasOwnProperty !== 'function' || object.hasOwnProperty(key))\n\t\t\t\t\tencode(object[key])\n\t\t}\n\t\tconst makeRoom = (end) => {\n\t\t\tlet newSize\n\t\t\tif (end > 0x1000000) {\n\t\t\t\t// special handling for really large buffers\n\t\t\t\tif ((end - start) > MAX_BUFFER_SIZE)\n\t\t\t\t\tthrow new Error('Encoded buffer would be larger than maximum buffer size')\n\t\t\t\tnewSize = Math.min(MAX_BUFFER_SIZE,\n\t\t\t\t\tMath.round(Math.max((end - start) * (end > 0x4000000 ? 1.25 : 2), 0x400000) / 0x1000) * 0x1000)\n\t\t\t} else // faster handling for smaller buffers\n\t\t\t\tnewSize = ((Math.max((end - start) << 2, target.length - 1) >> 12) + 1) << 12\n\t\t\tlet newBuffer = new ByteArrayAllocate(newSize)\n\t\t\ttargetView = new DataView(newBuffer.buffer, 0, newSize)\n\t\t\tif (target.copy)\n\t\t\t\ttarget.copy(newBuffer, 0, start, end)\n\t\t\telse\n\t\t\t\tnewBuffer.set(target.slice(start, end))\n\t\t\tposition -= start\n\t\t\tstart = 0\n\t\t\tsafeEnd = newBuffer.length - 10\n\t\t\treturn target = newBuffer\n\t\t}\n\t\tlet chunkThreshold = 100;\n\t\tlet continuedChunkThreshold = 1000;\n\t\tthis.encodeAsIterable = function(value, options) {\n\t\t\treturn startEncoding(value, options, encodeObjectAsIterable);\n\t\t}\n\t\tthis.encodeAsAsyncIterable = function(value, options) {\n\t\t\treturn startEncoding(value, options, encodeObjectAsAsyncIterable);\n\t\t}\n\n\t\tfunction* encodeObjectAsIterable(object, iterateProperties, finalIterable) {\n\t\t\tlet constructor = object.constructor;\n\t\t\tif (constructor === Object) {\n\t\t\t\tlet useRecords = encoder.useRecords !== false;\n\t\t\t\tif (useRecords)\n\t\t\t\t\twriteObject(object, true); // write the record identifier\n\t\t\t\telse\n\t\t\t\t\twriteEntityLength(Object.keys(object).length, 0xa0);\n\t\t\t\tfor (let key in object) {\n\t\t\t\t\tlet value = object[key];\n\t\t\t\t\tif (!useRecords) encode(key);\n\t\t\t\t\tif (value && typeof value === 'object') {\n\t\t\t\t\t\tif (iterateProperties[key])\n\t\t\t\t\t\t\tyield* encodeObjectAsIterable(value, iterateProperties[key]);\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tyield* tryEncode(value, iterateProperties, key);\n\t\t\t\t\t} else encode(value);\n\t\t\t\t}\n\t\t\t} else if (constructor === Array) {\n\t\t\t\tlet length = object.length;\n\t\t\t\twriteArrayHeader(length);\n\t\t\t\tfor (let i = 0; i < length; i++) {\n\t\t\t\t\tlet value = object[i];\n\t\t\t\t\tif (value && (typeof value === 'object' || position - start > chunkThreshold)) {\n\t\t\t\t\t\tif (iterateProperties.element)\n\t\t\t\t\t\t\tyield* encodeObjectAsIterable(value, iterateProperties.element);\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tyield* tryEncode(value, iterateProperties, 'element');\n\t\t\t\t\t} else encode(value);\n\t\t\t\t}\n\t\t\t} else if (object[Symbol.iterator] && !object.buffer) { // iterator, but exclude typed arrays\n\t\t\t\ttarget[position++] = 0x9f; // start indefinite array\n\t\t\t\tfor (let value of object) {\n\t\t\t\t\tif (value && (typeof value === 'object' || position - start > chunkThreshold)) {\n\t\t\t\t\t\tif (iterateProperties.element)\n\t\t\t\t\t\t\tyield* encodeObjectAsIterable(value, iterateProperties.element);\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tyield* tryEncode(value, iterateProperties, 'element');\n\t\t\t\t\t} else encode(value);\n\t\t\t\t}\n\t\t\t\ttarget[position++] = 0xff; // stop byte\n\t\t\t} else if (isBlob(object)){\n\t\t\t\twriteEntityLength(object.size, 0x40); // encode as binary data\n\t\t\t\tyield target.subarray(start, position);\n\t\t\t\tyield object; // directly return blobs, they have to be encoded asynchronously\n\t\t\t\trestartEncoding();\n\t\t\t} else if (object[Symbol.asyncIterator]) {\n\t\t\t\ttarget[position++] = 0x9f; // start indefinite array\n\t\t\t\tyield target.subarray(start, position);\n\t\t\t\tyield object; // directly return async iterators, they have to be encoded asynchronously\n\t\t\t\trestartEncoding();\n\t\t\t\ttarget[position++] = 0xff; // stop byte\n\t\t\t} else {\n\t\t\t\tencode(object);\n\t\t\t}\n\t\t\tif (finalIterable && position > start) yield target.subarray(start, position);\n\t\t\telse if (position - start > chunkThreshold) {\n\t\t\t\tyield target.subarray(start, position);\n\t\t\t\trestartEncoding();\n\t\t\t}\n\t\t}\n\t\tfunction* tryEncode(value, iterateProperties, key) {\n\t\t\tlet restart = position - start;\n\t\t\ttry {\n\t\t\t\tencode(value);\n\t\t\t\tif (position - start > chunkThreshold) {\n\t\t\t\t\tyield target.subarray(start, position);\n\t\t\t\t\trestartEncoding();\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tif (error.iteratorNotHandled) {\n\t\t\t\t\titerateProperties[key] = {};\n\t\t\t\t\tposition = start + restart; // restart our position so we don't have partial data from last encode\n\t\t\t\t\tyield* encodeObjectAsIterable.call(this, value, iterateProperties[key]);\n\t\t\t\t} else throw error;\n\t\t\t}\n\t\t}\n\t\tfunction restartEncoding() {\n\t\t\tchunkThreshold = continuedChunkThreshold;\n\t\t\tencoder.encode(null, THROW_ON_ITERABLE); // restart encoding\n\t\t}\n\t\tfunction startEncoding(value, options, encodeIterable) {\n\t\t\tif (options && options.chunkThreshold) // explicitly specified chunk sizes\n\t\t\t\tchunkThreshold = continuedChunkThreshold = options.chunkThreshold;\n\t\t\telse // we start with a smaller threshold to get initial bytes sent quickly\n\t\t\t\tchunkThreshold = 100;\n\t\t\tif (value && typeof value === 'object') {\n\t\t\t\tencoder.encode(null, THROW_ON_ITERABLE); // start encoding\n\t\t\t\treturn encodeIterable(value, encoder.iterateProperties || (encoder.iterateProperties = {}), true);\n\t\t\t}\n\t\t\treturn [encoder.encode(value)];\n\t\t}\n\n\t\tasync function* encodeObjectAsAsyncIterable(value, iterateProperties) {\n\t\t\tfor (let encodedValue of encodeObjectAsIterable(value, iterateProperties, true)) {\n\t\t\t\tlet constructor = encodedValue.constructor;\n\t\t\t\tif (constructor === ByteArray || constructor === Uint8Array)\n\t\t\t\t\tyield encodedValue;\n\t\t\t\telse if (isBlob(encodedValue)) {\n\t\t\t\t\tlet reader = encodedValue.stream().getReader();\n\t\t\t\t\tlet next;\n\t\t\t\t\twhile (!(next = await reader.read()).done) {\n\t\t\t\t\t\tyield next.value;\n\t\t\t\t\t}\n\t\t\t\t} else if (encodedValue[Symbol.asyncIterator]) {\n\t\t\t\t\tfor await (let asyncValue of encodedValue) {\n\t\t\t\t\t\trestartEncoding();\n\t\t\t\t\t\tif (asyncValue)\n\t\t\t\t\t\t\tyield* encodeObjectAsAsyncIterable(asyncValue, iterateProperties.async || (iterateProperties.async = {}));\n\t\t\t\t\t\telse yield encoder.encode(asyncValue);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tyield encodedValue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tuseBuffer(buffer) {\n\t\t// this means we are finished using our own buffer and we can write over it safely\n\t\ttarget = buffer\n\t\ttargetView = new DataView(target.buffer, target.byteOffset, target.byteLength)\n\t\tposition = 0\n\t}\n\tclearSharedData() {\n\t\tif (this.structures)\n\t\t\tthis.structures = []\n\t\tif (this.sharedValues)\n\t\t\tthis.sharedValues = undefined\n\t}\n\tupdateSharedData() {\n\t\tlet lastVersion = this.sharedVersion || 0\n\t\tthis.sharedVersion = lastVersion + 1\n\t\tlet structuresCopy = this.structures.slice(0)\n\t\tlet sharedData = new SharedData(structuresCopy, this.sharedValues, this.sharedVersion)\n\t\tlet saveResults = this.saveShared(sharedData,\n\t\t\t\texistingShared => (existingShared && existingShared.version || 0) == lastVersion)\n\t\tif (saveResults === false) {\n\t\t\t// get updated structures and try again if the update failed\n\t\t\tsharedData = this.getShared() || {}\n\t\t\tthis.structures = sharedData.structures || []\n\t\t\tthis.sharedValues = sharedData.packedValues\n\t\t\tthis.sharedVersion = sharedData.version\n\t\t\tthis.structures.nextId = this.structures.length\n\t\t} else {\n\t\t\t// restore structures\n\t\t\tstructuresCopy.forEach((structure, i) => this.structures[i] = structure)\n\t\t}\n\t\t// saveShared may fail to write and reload, or may have reloaded to check compatibility and overwrite saved data, either way load the correct shared data\n\t\treturn saveResults\n\t}\n}\nfunction writeEntityLength(length, majorValue) {\n\tif (length < 0x18)\n\t\ttarget[position++] = majorValue | length\n\telse if (length < 0x100) {\n\t\ttarget[position++] = majorValue | 0x18\n\t\ttarget[position++] = length\n\t} else if (length < 0x10000) {\n\t\ttarget[position++] = majorValue | 0x19\n\t\ttarget[position++] = length >> 8\n\t\ttarget[position++] = length & 0xff\n\t} else {\n\t\ttarget[position++] = majorValue | 0x1a\n\t\ttargetView.setUint32(position, length)\n\t\tposition += 4\n\t}\n\n}\nclass SharedData {\n\tconstructor(structures, values, version) {\n\t\tthis.structures = structures\n\t\tthis.packedValues = values\n\t\tthis.version = version\n\t}\n}\n\nfunction writeArrayHeader(length) {\n\tif (length < 0x18)\n\t\ttarget[position++] = 0x80 | length\n\telse if (length < 0x100) {\n\t\ttarget[position++] = 0x98\n\t\ttarget[position++] = length\n\t} else if (length < 0x10000) {\n\t\ttarget[position++] = 0x99\n\t\ttarget[position++] = length >> 8\n\t\ttarget[position++] = length & 0xff\n\t} else {\n\t\ttarget[position++] = 0x9a\n\t\ttargetView.setUint32(position, length)\n\t\tposition += 4\n\t}\n}\n\nconst BlobConstructor = typeof Blob === 'undefined' ? function(){} : Blob;\nfunction isBlob(object) {\n\tif (object instanceof BlobConstructor)\n\t\treturn true;\n\tlet tag = object[Symbol.toStringTag];\n\treturn tag === 'Blob' || tag === 'File';\n}\nfunction findRepetitiveStrings(value, packedValues) {\n\tswitch(typeof value) {\n\t\tcase 'string':\n\t\t\tif (value.length > 3) {\n\t\t\t\tif (packedValues.objectMap[value] > -1 || packedValues.values.length >= packedValues.maxValues)\n\t\t\t\t\treturn\n\t\t\t\tlet packedStatus = packedValues.get(value)\n\t\t\t\tif (packedStatus) {\n\t\t\t\t\tif (++packedStatus.count == 2) {\n\t\t\t\t\t\tpackedValues.values.push(value)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tpackedValues.set(value, {\n\t\t\t\t\t\tcount: 1,\n\t\t\t\t\t})\n\t\t\t\t\tif (packedValues.samplingPackedValues) {\n\t\t\t\t\t\tlet status = packedValues.samplingPackedValues.get(value)\n\t\t\t\t\t\tif (status)\n\t\t\t\t\t\t\tstatus.count++\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tpackedValues.samplingPackedValues.set(value, {\n\t\t\t\t\t\t\t\tcount: 1,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak\n\t\tcase 'object':\n\t\t\tif (value) {\n\t\t\t\tif (value instanceof Array) {\n\t\t\t\t\tfor (let i = 0, l = value.length; i < l; i++) {\n\t\t\t\t\t\tfindRepetitiveStrings(value[i], packedValues)\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\t\t\t\t\tlet includeKeys = !packedValues.encoder.useRecords\n\t\t\t\t\tfor (var key in value) {\n\t\t\t\t\t\tif (value.hasOwnProperty(key)) {\n\t\t\t\t\t\t\tif (includeKeys)\n\t\t\t\t\t\t\t\tfindRepetitiveStrings(key, packedValues)\n\t\t\t\t\t\t\tfindRepetitiveStrings(value[key], packedValues)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak\n\t\tcase 'function': console.log(value)\n\t}\n}\nconst isLittleEndianMachine = new Uint8Array(new Uint16Array([1]).buffer)[0] == 1\nextensionClasses = [ Date, Set, Error, RegExp, Tag, ArrayBuffer,\n\tUint8Array, Uint8ClampedArray, Uint16Array, Uint32Array,\n\ttypeof BigUint64Array == 'undefined' ? function() {} : BigUint64Array, Int8Array, Int16Array, Int32Array,\n\ttypeof BigInt64Array == 'undefined' ? function() {} : BigInt64Array,\n\tFloat32Array, Float64Array, SharedData ]\n\n//Object.getPrototypeOf(Uint8Array.prototype).constructor /*TypedArray*/\nextensions = [{ // Date\n\ttag: 1,\n\tencode(date, encode) {\n\t\tlet seconds = date.getTime() / 1000\n\t\tif ((this.useTimestamp32 || date.getMilliseconds() === 0) && seconds >= 0 && seconds < 0x100000000) {\n\t\t\t// Timestamp 32\n\t\t\ttarget[position++] = 0x1a\n\t\t\ttargetView.setUint32(position, seconds)\n\t\t\tposition += 4\n\t\t} else {\n\t\t\t// Timestamp float64\n\t\t\ttarget[position++] = 0xfb\n\t\t\ttargetView.setFloat64(position, seconds)\n\t\t\tposition += 8\n\t\t}\n\t}\n}, { // Set\n\ttag: 258, // https://github.com/input-output-hk/cbor-sets-spec/blob/master/CBOR_SETS.md\n\tencode(set, encode) {\n\t\tlet array = Array.from(set)\n\t\tencode(array)\n\t}\n}, { // Error\n\ttag: 27, // http://cbor.schmorp.de/generic-object\n\tencode(error, encode) {\n\t\tencode([ error.name, error.message ])\n\t}\n}, { // RegExp\n\ttag: 27, // http://cbor.schmorp.de/generic-object\n\tencode(regex, encode) {\n\t\tencode([ 'RegExp', regex.source, regex.flags ])\n\t}\n}, { // Tag\n\tgetTag(tag) {\n\t\treturn tag.tag\n\t},\n\tencode(tag, encode) {\n\t\tencode(tag.value)\n\t}\n}, { // ArrayBuffer\n\tencode(arrayBuffer, encode, makeRoom) {\n\t\twriteBuffer(arrayBuffer, makeRoom)\n\t}\n}, { // Uint8Array\n\tgetTag(typedArray) {\n\t\tif (typedArray.constructor === Uint8Array) {\n\t\t\tif (this.tagUint8Array || hasNodeBuffer && this.tagUint8Array !== false)\n\t\t\t\treturn 64;\n\t\t} // else no tag\n\t},\n\tencode(typedArray, encode, makeRoom) {\n\t\twriteBuffer(typedArray, makeRoom)\n\t}\n},\n\ttypedArrayEncoder(68, 1),\n\ttypedArrayEncoder(69, 2),\n\ttypedArrayEncoder(70, 4),\n\ttypedArrayEncoder(71, 8),\n\ttypedArrayEncoder(72, 1),\n\ttypedArrayEncoder(77, 2),\n\ttypedArrayEncoder(78, 4),\n\ttypedArrayEncoder(79, 8),\n\ttypedArrayEncoder(85, 4),\n\ttypedArrayEncoder(86, 8),\n{\n\tencode(sharedData, encode) { // write SharedData\n\t\tlet packedValues = sharedData.packedValues || []\n\t\tlet sharedStructures = sharedData.structures || []\n\t\tif (packedValues.values.length > 0) {\n\t\t\ttarget[position++] = 0xd8 // one-byte tag\n\t\t\ttarget[position++] = 51 // tag 51 for packed shared structures https://www.potaroo.net/ietf/ids/draft-ietf-cbor-packed-03.txt\n\t\t\twriteArrayHeader(4)\n\t\t\tlet valuesArray = packedValues.values\n\t\t\tencode(valuesArray)\n\t\t\twriteArrayHeader(0) // prefixes\n\t\t\twriteArrayHeader(0) // suffixes\n\t\t\tpackedObjectMap = Object.create(sharedPackedObjectMap || null)\n\t\t\tfor (let i = 0, l = valuesArray.length; i < l; i++) {\n\t\t\t\tpackedObjectMap[valuesArray[i]] = i\n\t\t\t}\n\t\t}\n\t\tif (sharedStructures) {\n\t\t\ttargetView.setUint32(position, 0xd9dffe00)\n\t\t\tposition += 3\n\t\t\tlet definitions = sharedStructures.slice(0)\n\t\t\tdefinitions.unshift(0xe000)\n\t\t\tdefinitions.push(new Tag(sharedData.version, 0x53687264))\n\t\t\tencode(definitions)\n\t\t} else\n\t\t\tencode(new Tag(sharedData.version, 0x53687264))\n\t\t}\n\t}]\nfunction typedArrayEncoder(tag, size) {\n\tif (!isLittleEndianMachine && size > 1)\n\t\ttag -= 4 // the big endian equivalents are 4 less\n\treturn {\n\t\ttag: tag,\n\t\tencode: function writeExtBuffer(typedArray, encode) {\n\t\t\tlet length = typedArray.byteLength\n\t\t\tlet offset = typedArray.byteOffset || 0\n\t\t\tlet buffer = typedArray.buffer || typedArray\n\t\t\tencode(hasNodeBuffer ? Buffer.from(buffer, offset, length) :\n\t\t\t\tnew Uint8Array(buffer, offset, length))\n\t\t}\n\t}\n}\nfunction writeBuffer(buffer, makeRoom) {\n\tlet length = buffer.byteLength\n\tif (length < 0x18) {\n\t\ttarget[position++] = 0x40 + length\n\t} else if (length < 0x100) {\n\t\ttarget[position++] = 0x58\n\t\ttarget[position++] = length\n\t} else if (length < 0x10000) {\n\t\ttarget[position++] = 0x59\n\t\ttarget[position++] = length >> 8\n\t\ttarget[position++] = length & 0xff\n\t} else {\n\t\ttarget[position++] = 0x5a\n\t\ttargetView.setUint32(position, length)\n\t\tposition += 4\n\t}\n\tif (position + length >= target.length) {\n\t\tmakeRoom(position + length)\n\t}\n\t// if it is already a typed array (has an ArrayBuffer), use that, but if it is an ArrayBuffer itself,\n\t// must wrap it to set it.\n\ttarget.set(buffer.buffer ? buffer : new Uint8Array(buffer), position)\n\tposition += length\n}\n\nfunction insertIds(serialized, idsToInsert) {\n\t// insert the ids that need to be referenced for structured clones\n\tlet nextId\n\tlet distanceToMove = idsToInsert.length * 2\n\tlet lastEnd = serialized.length - distanceToMove\n\tidsToInsert.sort((a, b) => a.offset > b.offset ? 1 : -1)\n\tfor (let id = 0; id < idsToInsert.length; id++) {\n\t\tlet referee = idsToInsert[id]\n\t\treferee.id = id\n\t\tfor (let position of referee.references) {\n\t\t\tserialized[position++] = id >> 8\n\t\t\tserialized[position] = id & 0xff\n\t\t}\n\t}\n\twhile (nextId = idsToInsert.pop()) {\n\t\tlet offset = nextId.offset\n\t\tserialized.copyWithin(offset + distanceToMove, offset, lastEnd)\n\t\tdistanceToMove -= 2\n\t\tlet position = offset + distanceToMove\n\t\tserialized[position++] = 0xd8\n\t\tserialized[position++] = 28 // http://cbor.schmorp.de/value-sharing\n\t\tlastEnd = offset\n\t}\n\treturn serialized\n}\nfunction writeBundles(start, encode) {\n\ttargetView.setUint32(bundledStrings.position + start, position - bundledStrings.position - start + 1) // the offset to bundle\n\tlet writeStrings = bundledStrings\n\tbundledStrings = null\n\tencode(writeStrings[0])\n\tencode(writeStrings[1])\n}\n\nexport function addExtension(extension) {\n\tif (extension.Class) {\n\t\tif (!extension.encode)\n\t\t\tthrow new Error('Extension has no encode function')\n\t\textensionClasses.unshift(extension.Class)\n\t\textensions.unshift(extension)\n\t}\n\tdecodeAddExtension(extension)\n}\nlet defaultEncoder = new Encoder({ useRecords: false })\nexport const encode = defaultEncoder.encode\nexport const encodeAsIterable = defaultEncoder.encodeAsIterable\nexport const encodeAsAsyncIterable = defaultEncoder.encodeAsAsyncIterable\nexport { FLOAT32_OPTIONS } from './decode.js'\nimport { FLOAT32_OPTIONS } from './decode.js'\nexport const { NEVER, ALWAYS, DECIMAL_ROUND, DECIMAL_FIT } = FLOAT32_OPTIONS\nexport const REUSE_BUFFER_MODE = 512\nexport const RESET_BUFFER_MODE = 1024\nexport const THROW_ON_ITERABLE = 2048\n\n\n","import { Encoder, decode as cborXdecode } from \"cbor-x\";\nexport function encode(obj) {\n const encoder = new Encoder({ tagUint8Array: false, useRecords: false });\n return encoder.encode(obj);\n}\nexport function decode(buf) {\n return cborXdecode(buf);\n}\n","export const arraysAreEqual = (a, b) => a.length === b.length && a.every((element, index) => element === b[index]);\n","import { arraysAreEqual } from \"./arraysAreEqual.js\";\nexport const headsAreSame = (a, b) => {\n return arraysAreEqual(a, b);\n};\n","/* c8 ignore start */\n/**\n * If `promise` is resolved before `t` ms elapse, the timeout is cleared and the result of the\n * promise is returned. If the timeout ends first, a `TimeoutError` is thrown.\n */\nexport const withTimeout = async (promise, t) => {\n let timeoutId;\n const timeoutPromise = new Promise((_, reject) => {\n timeoutId = setTimeout(() => reject(new TimeoutError(`withTimeout: timed out after ${t}ms`)), t);\n });\n try {\n return await Promise.race([promise, timeoutPromise]);\n }\n finally {\n clearTimeout(timeoutId);\n }\n};\nexport class TimeoutError extends Error {\n constructor(message) {\n super(message);\n this.name = \"TimeoutError\";\n }\n}\n/* c8 ignore end */\n","import * as A from \"@automerge/automerge/slim/next\";\nimport debug from \"debug\";\nimport { EventEmitter } from \"eventemitter3\";\nimport { assertEvent, assign, createActor, setup, waitFor } from \"xstate\";\nimport { stringifyAutomergeUrl } from \"./AutomergeUrl.js\";\nimport { encode } from \"./helpers/cbor.js\";\nimport { headsAreSame } from \"./helpers/headsAreSame.js\";\nimport { withTimeout } from \"./helpers/withTimeout.js\";\n/**\n * A DocHandle is a wrapper around a single Automerge document that lets us listen for changes and\n * notify the network and storage of new changes.\n *\n * @remarks\n * A `DocHandle` represents a document which is being managed by a {@link Repo}. You shouldn't ever\n * instantiate this yourself. To obtain `DocHandle` use {@link Repo.find} or {@link Repo.create}.\n *\n * To modify the underlying document use either {@link DocHandle.change} or\n * {@link DocHandle.changeAt}. These methods will notify the `Repo` that some change has occured and\n * the `Repo` will save any new changes to the attached {@link StorageAdapter} and send sync\n * messages to connected peers.\n */\nexport class DocHandle extends EventEmitter {\n documentId;\n #log;\n /** The XState actor running our state machine. */\n #machine;\n /** The last known state of our document. */\n #prevDocState = A.init();\n /** How long to wait before giving up on a document. (Note that a document will be marked\n * unavailable much sooner if all known peers respond that they don't have it.) */\n #timeoutDelay = 60_000;\n /** A dictionary mapping each peer to the last heads we know they have. */\n #remoteHeads = {};\n /** @hidden */\n constructor(documentId, options = {}) {\n super();\n this.documentId = documentId;\n if (\"timeoutDelay\" in options && options.timeoutDelay) {\n this.#timeoutDelay = options.timeoutDelay;\n }\n const doc = A.init();\n this.#log = debug(`automerge-repo:dochandle:${this.documentId.slice(0, 5)}`);\n const delay = this.#timeoutDelay;\n const machine = setup({\n types: {\n context: {},\n events: {},\n },\n actions: {\n /** Update the doc using the given callback and put the modified doc in context */\n onUpdate: assign(({ context, event }) => {\n const oldDoc = context.doc;\n assertEvent(event, UPDATE);\n const { callback } = event.payload;\n const doc = callback(oldDoc);\n return { doc };\n }),\n onDelete: assign(() => {\n this.emit(\"delete\", { handle: this });\n return { doc: A.init() };\n }),\n onUnavailable: () => {\n this.emit(\"unavailable\", { handle: this });\n },\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QAoC2BDAxgCwJYDswBKAYgFUAFAEQEEAVAUQG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oR74qUknBRmzholpv3OkpRQNNRpTzaKTWKbIWR5FDxm9AIkA7e9skUYCWayLILBZGoLkUSKbIyIdpxHPoyTeN4QA */\n // You can use the XState extension for VS Code to visualize this machine.\n // Or, you can see this static visualization (last updated April 2024): https://stately.ai/registry/editor/d7af9b58-c518-44f1-9c36-92a238b04a7a?machineId=91c387e7-0f01-42c9-a21d-293e9bf95bb7\n initial: \"idle\",\n context: { documentId, doc },\n on: {\n UPDATE: { actions: \"onUpdate\" },\n DELETE: \".deleted\",\n },\n states: {\n idle: {\n on: {\n BEGIN: \"loading\",\n },\n },\n loading: {\n on: {\n REQUEST: \"requesting\",\n DOC_READY: \"ready\",\n },\n after: { [delay]: \"unavailable\" },\n },\n requesting: {\n on: {\n DOC_UNAVAILABLE: \"unavailable\",\n DOC_READY: \"ready\",\n },\n after: { [delay]: \"unavailable\" },\n },\n unavailable: {\n entry: \"onUnavailable\",\n on: { DOC_READY: \"ready\" },\n },\n ready: {},\n deleted: { entry: \"onDelete\", type: \"final\" },\n },\n });\n // Instantiate the state machine\n this.#machine = createActor(machine);\n // Listen for state transitions\n this.#machine.subscribe(state => {\n const before = this.#prevDocState;\n const after = state.context.doc;\n this.#log(`→ ${state.value} %o`, after);\n // if the document has changed, emit a change event\n this.#checkForChanges(before, after);\n });\n // Start the machine, and send a create or find event to get things going\n this.#machine.start();\n this.#machine.send({ type: BEGIN });\n }\n // PRIVATE\n /** Returns the current document, regardless of state */\n get #doc() {\n return this.#machine?.getSnapshot().context.doc;\n }\n /** Returns the docHandle's state (READY, etc.) */\n get #state() {\n return this.#machine?.getSnapshot().value;\n }\n /** Returns a promise that resolves when the docHandle is in one of the given states */\n #statePromise(awaitStates) {\n const awaitStatesArray = Array.isArray(awaitStates)\n ? awaitStates\n : [awaitStates];\n return waitFor(this.#machine, s => awaitStatesArray.some(state => s.matches(state)), \n // use a longer delay here so as not to race with other delays\n { timeout: this.#timeoutDelay * 2 });\n }\n /**\n * Called after state transitions. If the document has changed, emits a change event. If we just\n * received the document for the first time, signal that our request has been completed.\n */\n #checkForChanges(before, after) {\n const beforeHeads = A.getHeads(before);\n const afterHeads = A.getHeads(after);\n const docChanged = !headsAreSame(afterHeads, beforeHeads);\n if (docChanged) {\n this.emit(\"heads-changed\", { handle: this, doc: after });\n const patches = A.diff(after, beforeHeads, afterHeads);\n if (patches.length > 0) {\n this.emit(\"change\", {\n handle: this,\n doc: after,\n patches,\n // TODO: pass along the source (load/change/network)\n patchInfo: { before, after, source: \"change\" },\n });\n }\n // If we didn't have the document yet, signal that we now do\n if (!this.isReady())\n this.#machine.send({ type: DOC_READY });\n }\n this.#prevDocState = after;\n }\n // PUBLIC\n /** Our documentId in Automerge URL form.\n */\n get url() {\n return stringifyAutomergeUrl({ documentId: this.documentId });\n }\n /**\n * @returns true if the document is ready for accessing or changes.\n *\n * Note that for documents already stored locally this occurs before synchronization with any\n * peers. We do not currently have an equivalent `whenSynced()`.\n */\n isReady = () => this.inState([\"ready\"]);\n /**\n * @returns true if the document has been marked as deleted.\n *\n * Deleted documents are removed from local storage and the sync process. It's not currently\n * possible at runtime to undelete a document.\n */\n isDeleted = () => this.inState([\"deleted\"]);\n /**\n * @returns true if the document is currently unavailable.\n *\n * This will be the case if the document is not found in storage and no peers have shared it with us.\n */\n isUnavailable = () => this.inState([\"unavailable\"]);\n /**\n * @returns true if the handle is in one of the given states.\n */\n inState = (states) => states.some(s => this.#machine.getSnapshot().matches(s));\n /** @hidden */\n get state() {\n return this.#machine.getSnapshot().value;\n }\n /**\n * @returns a promise that resolves when the document is in one of the given states (if no states\n * are passed, when the document is ready)\n *\n * Use this to block until the document handle has finished loading. The async equivalent to\n * checking `inState()`.\n */\n async whenReady(awaitStates = [\"ready\"]) {\n await withTimeout(this.#statePromise(awaitStates), this.#timeoutDelay);\n }\n /**\n * @returns the current state of this handle's Automerge document.\n *\n * This is the recommended way to access a handle's document. Note that this waits for the handle\n * to be ready if necessary. If loading (or synchronization) fails, this will never resolve.\n */\n async doc(\n /** states to wait for, such as \"LOADING\". mostly for internal use. */\n awaitStates = [\"ready\", \"unavailable\"]) {\n try {\n // wait for the document to enter one of the desired states\n await this.#statePromise(awaitStates);\n }\n catch (error) {\n // if we timed out, return undefined\n return undefined;\n }\n // Return the document\n return !this.isUnavailable() ? this.#doc : undefined;\n }\n /**\n * Synchronously returns the current state of the Automerge document this handle manages, or\n * undefined. Consider using `await handle.doc()` instead. Check `isReady()`, or use `whenReady()`\n * if you want to make sure loading is complete first.\n *\n * Not to be confused with the SyncState of the document, which describes the state of the\n * synchronization process.\n *\n * Note that `undefined` is not a valid Automerge document, so the return from this function is\n * unambigous.\n *\n * @returns the current document, or undefined if the document is not ready.\n */\n docSync() {\n if (!this.isReady())\n return undefined;\n else\n return this.#doc;\n }\n /**\n * Returns the current \"heads\" of the document, akin to a git commit.\n * This precisely defines the state of a document.\n * @returns the current document's heads, or undefined if the document is not ready\n */\n heads() {\n if (!this.isReady()) {\n return undefined;\n }\n return A.getHeads(this.#doc);\n }\n /**\n * Creates a fixed \"view\" of an automerge document at the given point in time represented\n * by the `heads` passed in. The return value is the same type as docSync() and will return\n * undefined if the object hasn't finished loading.\n *\n * @remarks\n * A point-in-time in an automerge document is an *array* of heads since there may be\n * concurrent edits. This API just returns a topologically sorted history of all edits\n * so every previous entry will be (in some sense) before later ones, but the set of all possible\n * history views would be quite large under concurrency (every thing in each branch against each other).\n * There might be a clever way to think about this, but we haven't found it yet, so for now at least\n * we present a single traversable view which excludes concurrency.\n * @returns The individual heads for every change in the document.\n */\n history() {\n if (!this.isReady()) {\n return undefined;\n }\n // This just returns all the heads as individual strings.\n return A.topoHistoryTraversal(this.#doc).map(h => [h]);\n }\n /**\n * Creates a fixed \"view\" of an automerge document at the given point in time represented\n * by the `heads` passed in. The return value is the same type as docSync() and will return\n * undefined if the object hasn't finished loading.\n *\n * @remarks\n * Note that our Typescript types do not consider change over time and the current version\n * of Automerge doesn't check types at runtime, so if you go back to an old set of heads\n * that doesn't match the heads here, Typescript will not save you.\n *\n * @returns An Automerge.Doc<T> at the point in time.\n */\n view(heads) {\n if (!this.isReady()) {\n return undefined;\n }\n return A.view(this.#doc, heads);\n }\n /**\n * Returns a set of Patch operations that will move a materialized document from one state to another\n * if applied.\n *\n * @remarks\n * We allow specifying both a from/to heads or just a single comparison point, in which case\n * the base will be the current document heads.\n *\n * @returns Automerge patches that go from one document state to the other. Use view() to get the full state.\n */\n diff(first, second) {\n if (!this.isReady()) {\n return undefined;\n }\n // We allow only one set of heads to be specified, in which case we use the doc's heads\n const from = second ? first : this.heads() || []; // because we guard above this should always have useful data\n const to = second ? second : first;\n return A.diff(this.#doc, from, to);\n }\n /**\n * `metadata(head?)` allows you to look at the metadata for a change\n * this can be used to build history graphs to find commit messages and edit times.\n * this interface.\n *\n * @remarks\n * I'm really not convinced this is the right way to surface this information so\n * I'm leaving this API \"hidden\".\n *\n * @hidden\n */\n metadata(change) {\n if (!this.isReady()) {\n return undefined;\n }\n if (!change) {\n change = this.heads()[0];\n }\n // we return undefined instead of null by convention in this API\n return A.inspectChange(this.#doc, change) || undefined;\n }\n /**\n * `update` is called any time we have a new document state; could be\n * from a local change, a remote change, or a new document from storage.\n * Does not cause state changes.\n * @hidden\n */\n update(callback) {\n this.#machine.send({ type: UPDATE, payload: { callback } });\n }\n /**\n * `doneLoading` is called by the repo after it decides it has all the changes\n * it's going to get during setup. This might mean it was created locally,\n * or that it was loaded from storage, or that it was received from a peer.\n */\n doneLoading() {\n this.#machine.send({ type: DOC_READY });\n }\n /**\n * Called by the repo either when a doc handle changes or we receive new remote heads.\n * @hidden\n */\n setRemoteHeads(storageId, heads) {\n this.#remoteHeads[storageId] = heads;\n this.emit(\"remote-heads\", { storageId, heads });\n }\n /** Returns the heads of the storageId. */\n getRemoteHeads(storageId) {\n return this.#remoteHeads[storageId];\n }\n /**\n * All changes to an Automerge document should be made through this method.\n * Inside the callback, the document should be treated as mutable: all edits will be recorded\n * using a Proxy and translated into operations as part of a single recorded \"change\".\n *\n * Note that assignment via ES6 spread operators will result in *replacing* the object\n * instead of mutating it which will prevent clean merges. This may be what you want, but\n * `doc.foo = { ...doc.foo, bar: \"baz\" }` is not equivalent to `doc.foo.bar = \"baz\"`.\n *\n * Local changes will be stored (by the StorageSubsystem) and synchronized (by the\n * DocSynchronizer) to any peers you are sharing it with.\n *\n * @param callback - A function that takes the current document and mutates it.\n *\n */\n change(callback, options = {}) {\n if (!this.isReady()) {\n throw new Error(`DocHandle#${this.documentId} is in ${this.state} and not ready. Check \\`handle.isReady()\\` before accessing the document.`);\n }\n this.#machine.send({\n type: UPDATE,\n payload: { callback: doc => A.change(doc, options, callback) },\n });\n }\n /**\n * Makes a change as if the document were at `heads`.\n *\n * @returns A set of heads representing the concurrent change that was made.\n */\n changeAt(heads, callback, options = {}) {\n if (!this.isReady()) {\n throw new Error(`DocHandle#${this.documentId} is not ready. Check \\`handle.isReady()\\` before accessing the document.`);\n }\n let resultHeads = undefined;\n this.#machine.send({\n type: UPDATE,\n payload: {\n callback: doc => {\n const result = A.changeAt(doc, heads, options, callback);\n resultHeads = result.newHeads || undefined;\n return result.newDoc;\n },\n },\n });\n // the callback above will always run before we get here, so this should always contain the new heads\n return resultHeads;\n }\n /**\n * Merges another document into this document. Any peers we are sharing changes with will be\n * notified of the changes resulting from the merge.\n *\n * @returns the merged document.\n *\n * @throws if either document is not ready or if `otherHandle` is unavailable.\n */\n merge(\n /** the handle of the document to merge into this one */\n otherHandle) {\n if (!this.isReady() || !otherHandle.isReady()) {\n throw new Error(\"Both handles must be ready to merge\");\n }\n const mergingDoc = otherHandle.docSync();\n if (!mergingDoc) {\n throw new Error(\"The document to be merged in is falsy, aborting.\");\n }\n this.update(doc => {\n return A.merge(doc, mergingDoc);\n });\n }\n /**\n * Used in testing to mark this document as unavailable.\n * @hidden\n */\n unavailable() {\n this.#machine.send({ type: DOC_UNAVAILABLE });\n }\n /** Called by the repo when the document is not found in storage.\n * @hidden\n * */\n request() {\n if (this.#state === \"loading\")\n this.#machine.send({ type: REQUEST });\n }\n /** Called by the repo when the document is deleted. */\n delete() {\n this.#machine.send({ type: DELETE });\n }\n /**\n * Sends an arbitrary ephemeral message out to all reachable peers who would receive sync messages\n * from you. It has no guarantee of delivery, and is not persisted to the underlying automerge doc\n * in any way. Messages will have a sending PeerId but this is *not* a useful user identifier (a\n * user could have multiple tabs open and would appear as multiple PeerIds). Every message source\n * must have a unique PeerId.\n */\n broadcast(message) {\n this.emit(\"ephemeral-message-outbound\", {\n handle: this,\n data: encode(message),\n });\n }\n metrics() {\n return A.stats(this.#doc);\n }\n}\n// STATE MACHINE TYPES & CONSTANTS\n// state\n/**\n * Possible internal states for a DocHandle\n */\nexport const HandleState = {\n /** The handle has been created but not yet loaded or requested */\n IDLE: \"idle\",\n /** We are waiting for storage to finish loading */\n LOADING: \"loading\",\n /** We are waiting for someone in the network to respond to a sync request */\n REQUESTING: \"requesting\",\n /** The document is available */\n READY: \"ready\",\n /** The document has been deleted from the repo */\n DELETED: \"deleted\",\n /** The document was not available in storage or from any connected peers */\n UNAVAILABLE: \"unavailable\",\n};\nexport const { IDLE, LOADING, REQUESTING, READY, DELETED, UNAVAILABLE } = HandleState;\nconst BEGIN = \"BEGIN\";\nconst REQUEST = \"REQUEST\";\nconst DOC_READY = \"DOC_READY\";\nconst UPDATE = \"UPDATE\";\nconst DELETE = \"DELETE\";\nconst TIMEOUT = \"TIMEOUT\";\nconst DOC_UNAVAILABLE = \"DOC_UNAVAILABLE\";\n","import { EventEmitter } from \"eventemitter3\";\nimport debug from \"debug\";\nexport class RemoteHeadsSubscriptions extends EventEmitter {\n // Storage IDs we have received remote heads from\n #knownHeads = new Map();\n // Storage IDs we have subscribed to via Repo.subscribeToRemoteHeads\n #ourSubscriptions = new Set();\n // Storage IDs other peers have subscribed to by sending us a control message\n #theirSubscriptions = new Map();\n // Peers we will always share remote heads with even if they are not subscribed\n #generousPeers = new Set();\n // Documents each peer has open, we need this information so we only send remote heads of documents that the peer knows\n #subscribedDocsByPeer = new Map();\n #log = debug(\"automerge-repo:remote-heads-subscriptions\");\n subscribeToRemotes(remotes) {\n this.#log(\"subscribeToRemotes\", remotes);\n const remotesToAdd = [];\n for (const remote of remotes) {\n if (!this.#ourSubscriptions.has(remote)) {\n this.#ourSubscriptions.add(remote);\n remotesToAdd.push(remote);\n }\n }\n if (remotesToAdd.length > 0) {\n this.emit(\"change-remote-subs\", {\n add: remotesToAdd,\n peers: Array.from(this.#generousPeers),\n });\n }\n }\n unsubscribeFromRemotes(remotes) {\n this.#log(\"subscribeToRemotes\", remotes);\n const remotesToRemove = [];\n for (const remote of remotes) {\n if (this.#ourSubscriptions.has(remote)) {\n this.#ourSubscriptions.delete(remote);\n if (!this.#theirSubscriptions.has(remote)) {\n remotesToRemove.push(remote);\n }\n }\n }\n if (remotesToRemove.length > 0) {\n this.emit(\"change-remote-subs\", {\n remove: remotesToRemove,\n peers: Array.from(this.#generousPeers),\n });\n }\n }\n handleControlMessage(control) {\n const remotesToAdd = [];\n const remotesToRemove = [];\n const addedRemotesWeKnow = [];\n this.#log(\"handleControlMessage\", control);\n if (control.add) {\n for (const remote of control.add) {\n let theirSubs = this.#theirSubscriptions.get(remote);\n if (this.#ourSubscriptions.has(remote) || theirSubs) {\n addedRemotesWeKnow.push(remote);\n }\n if (!theirSubs) {\n theirSubs = new Set();\n this.#theirSubscriptions.set(remote, theirSubs);\n if (!this.#ourSubscriptions.has(remote)) {\n remotesToAdd.push(remote);\n }\n }\n theirSubs.add(control.senderId);\n }\n }\n if (control.remove) {\n for (const remote of control.remove) {\n const theirSubs = this.#theirSubscriptions.get(remote);\n if (theirSubs) {\n theirSubs.delete(control.senderId);\n // if no one is subscribed anymore remove remote\n if (theirSubs.size == 0 && !this.#ourSubscriptions.has(remote)) {\n remotesToRemove.push(remote);\n }\n }\n }\n }\n if (remotesToAdd.length > 0 || remotesToRemove.length > 0) {\n this.emit(\"change-remote-subs\", {\n peers: Array.from(this.#generousPeers),\n add: remotesToAdd,\n remove: remotesToRemove,\n });\n }\n // send all our stored heads of documents the peer knows for the remotes they've added\n for (const remote of addedRemotesWeKnow) {\n const subscribedDocs = this.#subscribedDocsByPeer.get(control.senderId);\n if (subscribedDocs) {\n for (const documentId of subscribedDocs) {\n const knownHeads = this.#knownHeads.get(documentId);\n if (!knownHeads) {\n continue;\n }\n const lastHeads = knownHeads.get(remote);\n if (lastHeads) {\n this.emit(\"notify-remote-heads\", {\n targetId: control.senderId,\n documentId,\n heads: lastHeads.heads,\n timestamp: lastHeads.timestamp,\n storageId: remote,\n });\n }\n }\n }\n }\n }\n /** A peer we are not directly connected to has changed their heads */\n handleRemoteHeads(msg) {\n this.#log(\"handleRemoteHeads\", msg);\n const changedHeads = this.#changedHeads(msg);\n // Emit a remote-heads-changed event to update local dochandles\n for (const event of changedHeads) {\n if (this.#ourSubscriptions.has(event.storageId)) {\n this.emit(\"remote-heads-changed\", event);\n }\n }\n // Notify generous peers of these changes regardless of if they are subscribed to us\n for (const event of changedHeads) {\n for (const peer of this.#generousPeers) {\n // don't emit event to sender if sender is a generous peer\n if (peer === msg.senderId) {\n continue;\n }\n this.emit(\"notify-remote-heads\", {\n targetId: peer,\n documentId: event.documentId,\n heads: event.remoteHeads,\n timestamp: event.timestamp,\n storageId: event.storageId,\n });\n }\n }\n // Notify subscribers of these changes\n for (const event of changedHeads) {\n const theirSubs = this.#theirSubscriptions.get(event.storageId);\n if (theirSubs) {\n for (const peerId of theirSubs) {\n if (this.#isPeerSubscribedToDoc(peerId, event.documentId)) {\n this.emit(\"notify-remote-heads\", {\n targetId: peerId,\n documentId: event.documentId,\n heads: event.remoteHeads,\n timestamp: event.timestamp,\n storageId: event.storageId,\n });\n }\n }\n }\n }\n }\n /** A peer we are directly connected to has updated their heads */\n handleImmediateRemoteHeadsChanged(documentId, storageId, heads) {\n this.#log(\"handleLocalHeadsChanged\", documentId, storageId, heads);\n const remote = this.#knownHeads.get(documentId);\n const timestamp = Date.now();\n if (!remote) {\n this.#knownHeads.set(documentId, new Map([[storageId, { heads, timestamp }]]));\n }\n else {\n const docRemote = remote.get(storageId);\n if (!docRemote || docRemote.timestamp < Date.now()) {\n remote.set(storageId, { heads, timestamp: Date.now() });\n }\n }\n const theirSubs = this.#theirSubscriptions.get(storageId);\n if (theirSubs) {\n for (const peerId of theirSubs) {\n if (this.#isPeerSubscribedToDoc(peerId, documentId)) {\n this.emit(\"notify-remote-heads\", {\n targetId: peerId,\n documentId: documentId,\n heads: heads,\n timestamp: timestamp,\n storageId: storageId,\n });\n }\n }\n }\n }\n addGenerousPeer(peerId) {\n this.#log(\"addGenerousPeer\", peerId);\n this.#generousPeers.add(peerId);\n if (this.#ourSubscriptions.size > 0) {\n this.emit(\"change-remote-subs\", {\n add: Array.from(this.#ourSubscriptions),\n peers: [peerId],\n });\n }\n for (const [documentId, remote] of this.#knownHeads) {\n for (const [storageId, { heads, timestamp }] of remote) {\n this.emit(\"notify-remote-heads\", {\n targetId: peerId,\n documentId: documentId,\n heads: heads,\n timestamp: timestamp,\n storageId: storageId,\n });\n }\n }\n }\n removePeer(peerId) {\n this.#log(\"removePeer\", peerId);\n const remotesToRemove = [];\n this.#generousPeers.delete(peerId);\n this.#subscribedDocsByPeer.delete(peerId);\n for (const [storageId, peerIds] of this.#theirSubscriptions) {\n if (peerIds.has(peerId)) {\n peerIds.delete(peerId);\n if (peerIds.size == 0) {\n remotesToRemove.push(storageId);\n this.#theirSubscriptions.delete(storageId);\n }\n }\n }\n if (remotesToRemove.length > 0) {\n this.emit(\"change-remote-subs\", {\n remove: remotesToRemove,\n peers: Array.from(this.#generousPeers),\n });\n }\n }\n subscribePeerToDoc(peerId, documentId) {\n let subscribedDocs = this.#subscribedDocsByPeer.get(peerId);\n if (!subscribedDocs) {\n subscribedDocs = new Set();\n this.#subscribedDocsByPeer.set(peerId, subscribedDocs);\n }\n subscribedDocs.add(documentId);\n const remoteHeads = this.#knownHeads.get(documentId);\n if (remoteHeads) {\n for (const [storageId, lastHeads] of remoteHeads) {\n const subscribedPeers = this.#theirSubscriptions.get(storageId);\n if (subscribedPeers && subscribedPeers.has(peerId)) {\n this.emit(\"notify-remote-heads\", {\n targetId: peerId,\n documentId,\n heads: lastHeads.heads,\n timestamp: lastHeads.timestamp,\n storageId,\n });\n }\n }\n }\n }\n #isPeerSubscribedToDoc(peerId, documentId) {\n const subscribedDocs = this.#subscribedDocsByPeer.get(peerId);\n return subscribedDocs && subscribedDocs.has(documentId);\n }\n /** Returns the (document, storageId) pairs which have changed after processing msg */\n #changedHeads(msg) {\n const changedHeads = [];\n const { documentId, newHeads } = msg;\n for (const [storageId, { heads, timestamp }] of Object.entries(newHeads)) {\n if (!this.#ourSubscriptions.has(storageId) &&\n !this.#theirSubscriptions.has(storageId)) {\n continue;\n }\n let remote = this.#knownHeads.get(documentId);\n if (!remote) {\n remote = new Map();\n this.#knownHeads.set(documentId, remote);\n }\n const docRemote = remote.get(storageId);\n if (docRemote && docRemote.timestamp >= timestamp) {\n continue;\n }\n else {\n remote.set(storageId, { timestamp, heads });\n changedHeads.push({\n documentId,\n storageId: storageId,\n remoteHeads: heads,\n timestamp,\n });\n }\n }\n return changedHeads;\n }\n}\n","/** Throttle\n * Returns a function with a built in throttle timer that runs after `delay` ms.\n *\n * This function differs from a conventional `throttle` in that it ensures the final\n * call will also execute and delays sending the first one until `delay` ms to allow\n * additional work to accumulate.\n *\n * Here's a diagram:\n *\n * calls +----++++++-----++----\n * dlay ^--v ^--v^--v ^--v\n * execs ---+----+---+------+--\n *\n * The goal in this design is to create batches of changes without flooding\n * communication or storage systems while still feeling responsive.\n * (By default we communicate at 10hz / every 100ms.)\n *\n * Note that the args go inside the parameter and you should be careful not to\n * recreate the function on each usage. (In React, see useMemo().)\n *\n *\n * Example usage:\n * const callback = throttle((ev) => { doSomethingExpensiveOrOccasional() }, 100)\n * target.addEventListener('frequent-event', callback);\n *\n */\nexport const throttle = (fn, delay) => {\n let lastCall = Date.now();\n let wait;\n let timeout;\n return function (...args) {\n wait = lastCall + delay - Date.now();\n clearTimeout(timeout);\n timeout = setTimeout(() => {\n fn(...args);\n lastCall = Date.now();\n }, wait);\n };\n};\n","// TYPE GUARDS\nexport const isRepoMessage = (message) => isSyncMessage(message) ||\n isEphemeralMessage(message) ||\n isRequestMessage(message) ||\n isDocumentUnavailableMessage(message) ||\n isRemoteSubscriptionControlMessage(message) ||\n isRemoteHeadsChanged(message);\n// prettier-ignore\nexport const isDocumentUnavailableMessage = (msg) => msg.type === \"doc-unavailable\";\nexport const isRequestMessage = (msg) => msg.type === \"request\";\nexport const isSyncMessage = (msg) => msg.type === \"sync\";\nexport const isEphemeralMessage = (msg) => msg.type === \"ephemeral\";\n// prettier-ignore\nexport const isRemoteSubscriptionControlMessage = (msg) => msg.type === \"remote-subscription-change\";\nexport const isRemoteHeadsChanged = (msg) => msg.type === \"remote-heads-changed\";\n","import debug from \"debug\";\nimport { EventEmitter } from \"eventemitter3\";\nimport { isEphemeralMessage, isRepoMessage, } from \"./messages.js\";\nconst getEphemeralMessageSource = (message) => `${message.senderId}:${message.sessionId}`;\nexport class NetworkSubsystem extends EventEmitter {\n peerId;\n peerMetadata;\n #log;\n #adaptersByPeer = {};\n #count = 0;\n #sessionId = Math.random().toString(36).slice(2);\n #ephemeralSessionCounts = {};\n adapters = [];\n constructor(adapters, peerId, peerMetadata) {\n super();\n this.peerId = peerId;\n this.peerMetadata = peerMetadata;\n this.#log = debug(`automerge-repo:network:${this.peerId}`);\n adapters.forEach(a => this.addNetworkAdapter(a));\n }\n disconnect() {\n this.adapters.forEach(a => a.disconnect());\n }\n reconnect() {\n this.adapters.forEach(a => a.connect(this.peerId));\n }\n addNetworkAdapter(networkAdapter) {\n this.adapters.push(networkAdapter);\n networkAdapter.on(\"peer-candidate\", ({ peerId, peerMetadata }) => {\n this.#log(`peer candidate: ${peerId} `);\n // TODO: This is where authentication would happen\n // TODO: on reconnection, this would create problems!\n // the server would see a reconnection as a late-arriving channel\n // for an existing peer and decide to ignore it until the connection\n // times out: turns out my ICE/SIP emulation laziness did not pay off here\n if (!this.#adaptersByPeer[peerId]) {\n // TODO: handle losing a server here\n this.#adaptersByPeer[peerId] = networkAdapter;\n }\n this.emit(\"peer\", { peerId, peerMetadata });\n });\n networkAdapter.on(\"peer-disconnected\", ({ peerId }) => {\n this.#log(`peer disconnected: ${peerId} `);\n delete this.#adaptersByPeer[peerId];\n this.emit(\"peer-disconnected\", { peerId });\n });\n networkAdapter.on(\"message\", msg => {\n if (!isRepoMessage(msg)) {\n this.#log(`invalid message: ${JSON.stringify(msg)}`);\n return;\n }\n this.#log(`message from ${msg.senderId}`);\n if (isEphemeralMessage(msg)) {\n const source = getEphemeralMessageSource(msg);\n if (this.#ephemeralSessionCounts[source] === undefined ||\n msg.count > this.#ephemeralSessionCounts[source]) {\n this.#ephemeralSessionCounts[source] = msg.count;\n this.emit(\"message\", msg);\n }\n return;\n }\n this.emit(\"message\", msg);\n });\n networkAdapter.on(\"close\", () => {\n this.#log(\"adapter closed\");\n Object.entries(this.#adaptersByPeer).forEach(([peerId, other]) => {\n if (other === networkAdapter) {\n delete this.#adaptersByPeer[peerId];\n }\n });\n });\n this.peerMetadata\n .then(peerMetadata => {\n networkAdapter.connect(this.peerId, peerMetadata);\n })\n .catch(err => {\n this.#log(\"error connecting to network\", err);\n });\n }\n // TODO: this probably introduces a race condition for the ready event\n // but I plan to refactor that as part of this branch in another patch\n removeNetworkAdapter(networkAdapter) {\n this.adapters = this.adapters.filter(a => a !== networkAdapter);\n networkAdapter.disconnect();\n }\n send(message) {\n const peer = this.#adaptersByPeer[message.targetId];\n if (!peer) {\n this.#log(`Tried to send message but peer not found: ${message.targetId}`);\n return;\n }\n /** Messages come in without a senderId and other required information; this is where we make\n * sure they have everything they need.\n */\n const prepareMessage = (message) => {\n if (message.type === \"ephemeral\") {\n if (\"count\" in message) {\n // existing ephemeral message from another peer; pass on without changes\n return message;\n }\n else {\n // new ephemeral message from us; add our senderId as well as a counter and session id\n return {\n ...message,\n count: ++this.#count,\n sessionId: this.#sessionId,\n senderId: this.peerId,\n };\n }\n }\n else {\n // other message type; just add our senderId\n return {\n ...message,\n senderId: this.peerId,\n };\n }\n };\n const outbound = prepareMessage(message);\n this.#log(\"sending message %o\", outbound);\n peer.send(outbound);\n }\n isReady = () => {\n return this.adapters.every(a => a.isReady());\n };\n whenReady = async () => {\n return Promise.all(this.adapters.map(a => a.whenReady()));\n };\n}\n","export function mergeArrays(myArrays) {\n // Get the total length of all arrays.\n let length = 0;\n myArrays.forEach(item => {\n length += item.length;\n });\n // Create a new array with total length and merge all source arrays.\n const mergedArray = new Uint8Array(length);\n let offset = 0;\n myArrays.forEach(item => {\n mergedArray.set(item, offset);\n offset += item.length;\n });\n return mergedArray;\n}\n","(function (root, factory) {\n // Hack to make all exports of this module sha256 function object properties.\n var exports = {};\n factory(exports);\n var sha256 = exports[\"default\"];\n for (var k in exports) {\n sha256[k] = exports[k];\n }\n \n if (typeof module === 'object' && typeof module.exports === 'object') {\n module.exports = sha256;\n } else if (typeof define === 'function' && define.amd) {\n define(function() { return sha256; }); \n } else {\n root.sha256 = sha256;\n }\n})(this, function(exports) {\n\"use strict\";\nexports.__esModule = true;\n// SHA-256 (+ HMAC and PBKDF2) for JavaScript.\n//\n// Written in 2014-2016 by Dmitry Chestnykh.\n// Public domain, no warranty.\n//\n// Functions (accept and return Uint8Arrays):\n//\n// sha256(message) -> hash\n// sha256.hmac(key, message) -> mac\n// sha256.pbkdf2(password, salt, rounds, dkLen) -> dk\n//\n// Classes:\n//\n// new sha256.Hash()\n// new sha256.HMAC(key)\n//\nexports.digestLength = 32;\nexports.blockSize = 64;\n// SHA-256 constants\nvar K = new Uint32Array([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b,\n 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01,\n 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7,\n 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,\n 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152,\n 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,\n 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc,\n 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819,\n 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08,\n 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f,\n 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,\n 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2\n]);\nfunction hashBlocks(w, v, p, pos, len) {\n var a, b, c, d, e, f, g, h, u, i, j, t1, t2;\n while (len >= 64) {\n a = v[0];\n b = v[1];\n c = v[2];\n d = v[3];\n e = v[4];\n f = v[5];\n g = v[6];\n h = v[7];\n for (i = 0; i < 16; i++) {\n j = pos + i * 4;\n w[i] = (((p[j] & 0xff) << 24) | ((p[j + 1] & 0xff) << 16) |\n ((p[j + 2] & 0xff) << 8) | (p[j + 3] & 0xff));\n }\n for (i = 16; i < 64; i++) {\n u = w[i - 2];\n t1 = (u >>> 17 | u << (32 - 17)) ^ (u >>> 19 | u << (32 - 19)) ^ (u >>> 10);\n u = w[i - 15];\n t2 = (u >>> 7 | u << (32 - 7)) ^ (u >>> 18 | u << (32 - 18)) ^ (u >>> 3);\n w[i] = (t1 + w[i - 7] | 0) + (t2 + w[i - 16] | 0);\n }\n for (i = 0; i < 64; i++) {\n t1 = (((((e >>> 6 | e << (32 - 6)) ^ (e >>> 11 | e << (32 - 11)) ^\n (e >>> 25 | e << (32 - 25))) + ((e & f) ^ (~e & g))) | 0) +\n ((h + ((K[i] + w[i]) | 0)) | 0)) | 0;\n t2 = (((a >>> 2 | a << (32 - 2)) ^ (a >>> 13 | a << (32 - 13)) ^\n (a >>> 22 | a << (32 - 22))) + ((a & b) ^ (a & c) ^ (b & c))) | 0;\n h = g;\n g = f;\n f = e;\n e = (d + t1) | 0;\n d = c;\n c = b;\n b = a;\n a = (t1 + t2) | 0;\n }\n v[0] += a;\n v[1] += b;\n v[2] += c;\n v[3] += d;\n v[4] += e;\n v[5] += f;\n v[6] += g;\n v[7] += h;\n pos += 64;\n len -= 64;\n }\n return pos;\n}\n// Hash implements SHA256 hash algorithm.\nvar Hash = /** @class */ (function () {\n function Hash() {\n this.digestLength = exports.digestLength;\n this.blockSize = exports.blockSize;\n // Note: Int32Array is used instead of Uint32Array for performance reasons.\n this.state = new Int32Array(8); // hash state\n this.temp = new Int32Array(64); // temporary state\n this.buffer = new Uint8Array(128); // buffer for data to hash\n this.bufferLength = 0; // number of bytes in buffer\n this.bytesHashed = 0; // number of total bytes hashed\n this.finished = false; // indicates whether the hash was finalized\n this.reset();\n }\n // Resets hash state making it possible\n // to re-use this instance to hash other data.\n Hash.prototype.reset = function () {\n this.state[0] = 0x6a09e667;\n this.state[1] = 0xbb67ae85;\n this.state[2] = 0x3c6ef372;\n this.state[3] = 0xa54ff53a;\n this.state[4] = 0x510e527f;\n this.state[5] = 0x9b05688c;\n this.state[6] = 0x1f83d9ab;\n this.state[7] = 0x5be0cd19;\n this.bufferLength = 0;\n this.bytesHashed = 0;\n this.finished = false;\n return this;\n };\n // Cleans internal buffers and re-initializes hash state.\n Hash.prototype.clean = function () {\n for (var i = 0; i < this.buffer.length; i++) {\n this.buffer[i] = 0;\n }\n for (var i = 0; i < this.temp.length; i++) {\n this.temp[i] = 0;\n }\n this.reset();\n };\n // Updates hash state with the given data.\n //\n // Optionally, length of the data can be specified to hash\n // fewer bytes than data.length.\n //\n // Throws error when trying to update already finalized hash:\n // instance must be reset to use it again.\n Hash.prototype.update = function (data, dataLength) {\n if (dataLength === void 0) { dataLength = data.length; }\n if (this.finished) {\n throw new Error(\"SHA256: can't update because hash was finished.\");\n }\n var dataPos = 0;\n this.bytesHashed += dataLength;\n if (this.bufferLength > 0) {\n while (this.bufferLength < 64 && dataLength > 0) {\n this.buffer[this.bufferLength++] = data[dataPos++];\n dataLength--;\n }\n if (this.bufferLength === 64) {\n hashBlocks(this.temp, this.state, this.buffer, 0, 64);\n this.bufferLength = 0;\n }\n }\n if (dataLength >= 64) {\n dataPos = hashBlocks(this.temp, this.state, data, dataPos, dataLength);\n dataLength %= 64;\n }\n while (dataLength > 0) {\n this.buffer[this.bufferLength++] = data[dataPos++];\n dataLength--;\n }\n return this;\n };\n // Finalizes hash state and puts hash into out.\n //\n // If hash was already finalized, puts the same value.\n Hash.prototype.finish = function (out) {\n if (!this.finished) {\n var bytesHashed = this.bytesHashed;\n var left = this.bufferLength;\n var bitLenHi = (bytesHashed / 0x20000000) | 0;\n var bitLenLo = bytesHashed << 3;\n var padLength = (bytesHashed % 64 < 56) ? 64 : 128;\n this.buffer[left] = 0x80;\n for (var i = left + 1; i < padLength - 8; i++) {\n this.buffer[i] = 0;\n }\n this.buffer[padLength - 8] = (bitLenHi >>> 24) & 0xff;\n this.buffer[padLength - 7] = (bitLenHi >>> 16) & 0xff;\n this.buffer[padLength - 6] = (bitLenHi >>> 8) & 0xff;\n this.buffer[padLength - 5] = (bitLenHi >>> 0) & 0xff;\n this.buffer[padLength - 4] = (bitLenLo >>> 24) & 0xff;\n this.buffer[padLength - 3] = (bitLenLo >>> 16) & 0xff;\n this.buffer[padLength - 2] = (bitLenLo >>> 8) & 0xff;\n this.buffer[padLength - 1] = (bitLenLo >>> 0) & 0xff;\n hashBlocks(this.temp, this.state, this.buffer, 0, padLength);\n this.finished = true;\n }\n for (var i = 0; i < 8; i++) {\n out[i * 4 + 0] = (this.state[i] >>> 24) & 0xff;\n out[i * 4 + 1] = (this.state[i] >>> 16) & 0xff;\n out[i * 4 + 2] = (this.state[i] >>> 8) & 0xff;\n out[i * 4 + 3] = (this.state[i] >>> 0) & 0xff;\n }\n return this;\n };\n // Returns the final hash digest.\n Hash.prototype.digest = function () {\n var out = new Uint8Array(this.digestLength);\n this.finish(out);\n return out;\n };\n // Internal function for use in HMAC for optimization.\n Hash.prototype._saveState = function (out) {\n for (var i = 0; i < this.state.length; i++) {\n out[i] = this.state[i];\n }\n };\n // Internal function for use in HMAC for optimization.\n Hash.prototype._restoreState = function (from, bytesHashed) {\n for (var i = 0; i < this.state.length; i++) {\n this.state[i] = from[i];\n }\n this.bytesHashed = bytesHashed;\n this.finished = false;\n this.bufferLength = 0;\n };\n return Hash;\n}());\nexports.Hash = Hash;\n// HMAC implements HMAC-SHA256 message authentication algorithm.\nvar HMAC = /** @class */ (function () {\n function HMAC(key) {\n this.inner = new Hash();\n this.outer = new Hash();\n this.blockSize = this.inner.blockSize;\n this.digestLength = this.inner.digestLength;\n var pad = new Uint8Array(this.blockSize);\n if (key.length > this.blockSize) {\n (new Hash()).update(key).finish(pad).clean();\n }\n else {\n for (var i = 0; i < key.length; i++) {\n pad[i] = key[i];\n }\n }\n for (var i = 0; i < pad.length; i++) {\n pad[i] ^= 0x36;\n }\n this.inner.update(pad);\n for (var i = 0; i < pad.length; i++) {\n pad[i] ^= 0x36 ^ 0x5c;\n }\n this.outer.update(pad);\n this.istate = new Uint32Array(8);\n this.ostate = new Uint32Array(8);\n this.inner._saveState(this.istate);\n this.outer._saveState(this.ostate);\n for (var i = 0; i < pad.length; i++) {\n pad[i] = 0;\n }\n }\n // Returns HMAC state to the state initialized with key\n // to make it possible to run HMAC over the other data with the same\n // key without creating a new instance.\n HMAC.prototype.reset = function () {\n this.inner._restoreState(this.istate, this.inner.blockSize);\n this.outer._restoreState(this.ostate, this.outer.blockSize);\n return this;\n };\n // Cleans HMAC state.\n HMAC.prototype.clean = function () {\n for (var i = 0; i < this.istate.length; i++) {\n this.ostate[i] = this.istate[i] = 0;\n }\n this.inner.clean();\n this.outer.clean();\n };\n // Updates state with provided data.\n HMAC.prototype.update = function (data) {\n this.inner.update(data);\n return this;\n };\n // Finalizes HMAC and puts the result in out.\n HMAC.prototype.finish = function (out) {\n if (this.outer.finished) {\n this.outer.finish(out);\n }\n else {\n this.inner.finish(out);\n this.outer.update(out, this.digestLength).finish(out);\n }\n return this;\n };\n // Returns message authentication code.\n HMAC.prototype.digest = function () {\n var out = new Uint8Array(this.digestLength);\n this.finish(out);\n return out;\n };\n return HMAC;\n}());\nexports.HMAC = HMAC;\n// Returns SHA256 hash of data.\nfunction hash(data) {\n var h = (new Hash()).update(data);\n var digest = h.digest();\n h.clean();\n return digest;\n}\nexports.hash = hash;\n// Function hash is both available as module.hash and as default export.\nexports[\"default\"] = hash;\n// Returns HMAC-SHA256 of data under the key.\nfunction hmac(key, data) {\n var h = (new HMAC(key)).update(data);\n var digest = h.digest();\n h.clean();\n return digest;\n}\nexports.hmac = hmac;\n// Fills hkdf buffer like this:\n// T(1) = HMAC-Hash(PRK, T(0) | info | 0x01)\nfunction fillBuffer(buffer, hmac, info, counter) {\n // Counter is a byte value: check if it overflowed.\n var num = counter[0];\n if (num === 0) {\n throw new Error(\"hkdf: cannot expand more\");\n }\n // Prepare HMAC instance for new data with old key.\n hmac.reset();\n // Hash in previous output if it was generated\n // (i.e. counter is greater than 1).\n if (num > 1) {\n hmac.update(buffer);\n }\n // Hash in info if it exists.\n if (info) {\n hmac.update(info);\n }\n // Hash in the counter.\n hmac.update(counter);\n // Output result to buffer and clean HMAC instance.\n hmac.finish(buffer);\n // Increment counter inside typed array, this works properly.\n counter[0]++;\n}\nvar hkdfSalt = new Uint8Array(exports.digestLength); // Filled with zeroes.\nfunction hkdf(key, salt, info, length) {\n if (salt === void 0) { salt = hkdfSalt; }\n if (length === void 0) { length = 32; }\n var counter = new Uint8Array([1]);\n // HKDF-Extract uses salt as HMAC key, and key as data.\n var okm = hmac(salt, key);\n // Initialize HMAC for expanding with extracted key.\n // Ensure no collisions with `hmac` function.\n var hmac_ = new HMAC(okm);\n // Allocate buffer.\n var buffer = new Uint8Array(hmac_.digestLength);\n var bufpos = buffer.length;\n var out = new Uint8Array(length);\n for (var i = 0; i < length; i++) {\n if (bufpos === buffer.length) {\n fillBuffer(buffer, hmac_, info, counter);\n bufpos = 0;\n }\n out[i] = buffer[bufpos++];\n }\n hmac_.clean();\n buffer.fill(0);\n counter.fill(0);\n return out;\n}\nexports.hkdf = hkdf;\n// Derives a key from password and salt using PBKDF2-HMAC-SHA256\n// with the given number of iterations.\n//\n// The number of bytes returned is equal to dkLen.\n//\n// (For better security, avoid dkLen greater than hash length - 32 bytes).\nfunction pbkdf2(password, salt, iterations, dkLen) {\n var prf = new HMAC(password);\n var len = prf.digestLength;\n var ctr = new Uint8Array(4);\n var t = new Uint8Array(len);\n var u = new Uint8Array(len);\n var dk = new Uint8Array(dkLen);\n for (var i = 0; i * len < dkLen; i++) {\n var c = i + 1;\n ctr[0] = (c >>> 24) & 0xff;\n ctr[1] = (c >>> 16) & 0xff;\n ctr[2] = (c >>> 8) & 0xff;\n ctr[3] = (c >>> 0) & 0xff;\n prf.reset();\n prf.update(salt);\n prf.update(ctr);\n prf.finish(u);\n for (var j = 0; j < len; j++) {\n t[j] = u[j];\n }\n for (var j = 2; j <= iterations; j++) {\n prf.reset();\n prf.update(u).finish(u);\n for (var k = 0; k < len; k++) {\n t[k] ^= u[k];\n }\n }\n for (var j = 0; j < len && i * len + j < dkLen; j++) {\n dk[i * len + j] = t[j];\n }\n }\n for (var i = 0; i < len; i++) {\n t[i] = u[i] = 0;\n }\n for (var i = 0; i < 4; i++) {\n ctr[i] = 0;\n }\n prf.clean();\n return dk;\n}\nexports.pbkdf2 = pbkdf2;\n});\n","import * as sha256 from \"fast-sha256\";\nimport { mergeArrays } from \"../helpers/mergeArrays.js\";\nexport function keyHash(binary) {\n // calculate hash\n const hash = sha256.hash(binary);\n return bufferToHexString(hash);\n}\nexport function headsHash(heads) {\n const encoder = new TextEncoder();\n const headsbinary = mergeArrays(heads.map((h) => encoder.encode(h)));\n return keyHash(headsbinary);\n}\nfunction bufferToHexString(data) {\n return Array.from(data, byte => byte.toString(16).padStart(2, \"0\")).join(\"\");\n}\n","/**\n * Keys for storing Automerge documents are of the form:\n * ```ts\n * [documentId, \"snapshot\", hash] // OR\n * [documentId, \"incremental\", hash]\n * ```\n * This function returns the chunk type (\"snapshot\" or \"incremental\") if the key is in one of these\n * forms.\n */\nexport function chunkTypeFromKey(key) {\n if (key.length < 2)\n return null;\n const chunkTypeStr = key[key.length - 2]; // next-to-last element in key\n if (chunkTypeStr === \"snapshot\" || chunkTypeStr === \"incremental\") {\n return chunkTypeStr;\n }\n return null;\n}\n","import * as A from \"@automerge/automerge/slim/next\";\nimport debug from \"debug\";\nimport { headsAreSame } from \"../helpers/headsAreSame.js\";\nimport { mergeArrays } from \"../helpers/mergeArrays.js\";\nimport { keyHash, headsHash } from \"./keyHash.js\";\nimport { chunkTypeFromKey } from \"./chunkTypeFromKey.js\";\nimport * as Uuid from \"uuid\";\n/**\n * The storage subsystem is responsible for saving and loading Automerge documents to and from\n * storage adapter. It also provides a generic key/value storage interface for other uses.\n */\nexport class StorageSubsystem {\n /** The storage adapter to use for saving and loading documents */\n #storageAdapter;\n /** Record of the latest heads we've loaded or saved for each document */\n #storedHeads = new Map();\n /** Metadata on the chunks we've already loaded for each document */\n #chunkInfos = new Map();\n /** Flag to avoid compacting when a compaction is already underway */\n #compacting = false;\n #log = debug(`automerge-repo:storage-subsystem`);\n constructor(storageAdapter) {\n this.#storageAdapter = storageAdapter;\n }\n async id() {\n const storedId = await this.#storageAdapter.load([\"storage-adapter-id\"]);\n let id;\n if (storedId) {\n id = new TextDecoder().decode(storedId);\n }\n else {\n id = Uuid.v4();\n await this.#storageAdapter.save([\"storage-adapter-id\"], new TextEncoder().encode(id));\n }\n return id;\n }\n // ARBITRARY KEY/VALUE STORAGE\n // The `load`, `save`, and `remove` methods are for generic key/value storage, as opposed to\n // Automerge documents. For example, they're used by the LocalFirstAuthProvider to persist the\n // encrypted team graph that encodes group membership and permissions.\n //\n // The namespace parameter is to prevent collisions with other users of the storage subsystem.\n // Typically this will be the name of the plug-in, adapter, or other system that is using it. For\n // example, the LocalFirstAuthProvider uses the namespace `LocalFirstAuthProvider`.\n /** Loads a value from storage. */\n async load(\n /** Namespace to prevent collisions with other users of the storage subsystem. */\n namespace, \n /** Key to load. Typically a UUID or other unique identifier, but could be any string. */\n key) {\n const storageKey = [namespace, key];\n return await this.#storageAdapter.load(storageKey);\n }\n /** Saves a value in storage. */\n async save(\n /** Namespace to prevent collisions with other users of the storage subsystem. */\n namespace, \n /** Key to load. Typically a UUID or other unique identifier, but could be any string. */\n key, \n /** Data to save, as a binary blob. */\n data) {\n const storageKey = [namespace, key];\n await this.#storageAdapter.save(storageKey, data);\n }\n /** Removes a value from storage. */\n async remove(\n /** Namespace to prevent collisions with other users of the storage subsystem. */\n namespace, \n /** Key to remove. Typically a UUID or other unique identifier, but could be any string. */\n key) {\n const storageKey = [namespace, key];\n await this.#storageAdapter.remove(storageKey);\n }\n // AUTOMERGE DOCUMENT STORAGE\n /**\n * Loads the Automerge document with the given ID from storage.\n */\n async loadDoc(documentId) {\n // Load all the chunks for this document\n const chunks = await this.#storageAdapter.loadRange([documentId]);\n const binaries = [];\n const chunkInfos = [];\n for (const chunk of chunks) {\n // chunks might have been deleted in the interim\n if (chunk.data === undefined)\n continue;\n const chunkType = chunkTypeFromKey(chunk.key);\n if (chunkType == null)\n continue;\n chunkInfos.push({\n key: chunk.key,\n type: chunkType,\n size: chunk.data.length,\n });\n binaries.push(chunk.data);\n }\n this.#chunkInfos.set(documentId, chunkInfos);\n // Merge the chunks into a single binary\n const binary = mergeArrays(binaries);\n if (binary.length === 0)\n return null;\n // Load into an Automerge document\n const newDoc = A.loadIncremental(A.init(), binary);\n // Record the latest heads for the document\n this.#storedHeads.set(documentId, A.getHeads(newDoc));\n return newDoc;\n }\n /**\n * Saves the provided Automerge document to storage.\n *\n * @remarks\n * Under the hood this makes incremental saves until the incremental size is greater than the\n * snapshot size, at which point the document is compacted into a single snapshot.\n */\n async saveDoc(documentId, doc) {\n // Don't bother saving if the document hasn't changed\n if (!this.#shouldSave(documentId, doc))\n return;\n const sourceChunks = this.#chunkInfos.get(documentId) ?? [];\n if (this.#shouldCompact(sourceChunks)) {\n await this.#saveTotal(documentId, doc, sourceChunks);\n }\n else {\n await this.#saveIncremental(documentId, doc);\n }\n this.#storedHeads.set(documentId, A.getHeads(doc));\n }\n /**\n * Removes the Automerge document with the given ID from storage\n */\n async removeDoc(documentId) {\n await this.#storageAdapter.removeRange([documentId, \"snapshot\"]);\n await this.#storageAdapter.removeRange([documentId, \"incremental\"]);\n await this.#storageAdapter.removeRange([documentId, \"sync-state\"]);\n }\n /**\n * Saves just the incremental changes since the last save.\n */\n async #saveIncremental(documentId, doc) {\n const binary = A.saveSince(doc, this.#storedHeads.get(documentId) ?? []);\n if (binary && binary.length > 0) {\n const key = [documentId, \"incremental\", keyHash(binary)];\n this.#log(`Saving incremental ${key} for document ${documentId}`);\n await this.#storageAdapter.save(key, binary);\n if (!this.#chunkInfos.has(documentId)) {\n this.#chunkInfos.set(documentId, []);\n }\n this.#chunkInfos.get(documentId).push({\n key,\n type: \"incremental\",\n size: binary.length,\n });\n this.#storedHeads.set(documentId, A.getHeads(doc));\n }\n else {\n return Promise.resolve();\n }\n }\n /**\n * Compacts the document storage into a single shapshot.\n */\n async #saveTotal(documentId, doc, sourceChunks) {\n this.#compacting = true;\n const binary = A.save(doc);\n const snapshotHash = headsHash(A.getHeads(doc));\n const key = [documentId, \"snapshot\", snapshotHash];\n const oldKeys = new Set(sourceChunks.map(c => c.key).filter(k => k[2] !== snapshotHash));\n this.#log(`Saving snapshot ${key} for document ${documentId}`);\n this.#log(`deleting old chunks ${Array.from(oldKeys)}`);\n await this.#storageAdapter.save(key, binary);\n for (const key of oldKeys) {\n await this.#storageAdapter.remove(key);\n }\n const newChunkInfos = this.#chunkInfos.get(documentId)?.filter(c => !oldKeys.has(c.key)) ?? [];\n newChunkInfos.push({ key, type: \"snapshot\", size: binary.length });\n this.#chunkInfos.set(documentId, newChunkInfos);\n this.#compacting = false;\n }\n async loadSyncState(documentId, storageId) {\n const key = [documentId, \"sync-state\", storageId];\n try {\n const loaded = await this.#storageAdapter.load(key);\n return loaded ? A.decodeSyncState(loaded) : undefined;\n }\n catch (e) {\n this.#log(`Error loading sync state for ${documentId} from ${storageId}`);\n return undefined;\n }\n }\n async saveSyncState(documentId, storageId, syncState) {\n const key = [documentId, \"sync-state\", storageId];\n await this.#storageAdapter.save(key, A.encodeSyncState(syncState));\n }\n /**\n * Returns true if the document has changed since the last time it was saved.\n */\n #shouldSave(documentId, doc) {\n const oldHeads = this.#storedHeads.get(documentId);\n if (!oldHeads) {\n // we haven't saved this document before\n return true;\n }\n const newHeads = A.getHeads(doc);\n if (headsAreSame(newHeads, oldHeads)) {\n // the document hasn't changed\n return false;\n }\n return true; // the document has changed\n }\n /**\n * We only compact if the incremental size is greater than the snapshot size.\n */\n #shouldCompact(sourceChunks) {\n if (this.#compacting)\n return false;\n let snapshotSize = 0;\n let incrementalSize = 0;\n for (const chunk of sourceChunks) {\n if (chunk.type === \"snapshot\") {\n snapshotSize += chunk.size;\n }\n else {\n incrementalSize += chunk.size;\n }\n }\n // if the file is currently small, don't worry, just compact\n // this might seem a bit arbitrary (1k is arbitrary) but is designed to ensure compaction\n // for documents with only a single large change on top of an empty (or nearly empty) document\n // for example: imported NPM modules, images, etc.\n // if we have even more incrementals (so far) than the snapshot, compact\n return snapshotSize < 1024 || incrementalSize >= snapshotSize;\n }\n}\n","import { EventEmitter } from \"eventemitter3\";\nexport class Synchronizer extends EventEmitter {\n}\n","import * as A from \"@automerge/automerge/slim/next\";\nimport { decode } from \"cbor-x\";\nimport debug from \"debug\";\nimport { READY, REQUESTING, UNAVAILABLE, } from \"../DocHandle.js\";\nimport { isRequestMessage, } from \"../network/messages.js\";\nimport { Synchronizer } from \"./Synchronizer.js\";\nimport { throttle } from \"../helpers/throttle.js\";\n/**\n * DocSynchronizer takes a handle to an Automerge document, and receives & dispatches sync messages\n * to bring it inline with all other peers' versions.\n */\nexport class DocSynchronizer extends Synchronizer {\n #log;\n syncDebounceRate = 100;\n /** Active peers */\n #peers = [];\n #pendingSyncStateCallbacks = {};\n #peerDocumentStatuses = {};\n /** Sync state for each peer we've communicated with (including inactive peers) */\n #syncStates = {};\n #pendingSyncMessages = [];\n #syncStarted = false;\n #handle;\n #onLoadSyncState;\n constructor({ handle, onLoadSyncState }) {\n super();\n this.#handle = handle;\n this.#onLoadSyncState =\n onLoadSyncState ?? (() => Promise.resolve(undefined));\n const docId = handle.documentId.slice(0, 5);\n this.#log = debug(`automerge-repo:docsync:${docId}`);\n handle.on(\"change\", throttle(() => this.#syncWithPeers(), this.syncDebounceRate));\n handle.on(\"ephemeral-message-outbound\", payload => this.#broadcastToPeers(payload));\n // Process pending sync messages immediately after the handle becomes ready.\n void (async () => {\n await handle.doc([READY, REQUESTING]);\n this.#processAllPendingSyncMessages();\n })();\n }\n get peerStates() {\n return this.#peerDocumentStatuses;\n }\n get documentId() {\n return this.#handle.documentId;\n }\n /// PRIVATE\n async #syncWithPeers() {\n this.#log(`syncWithPeers`);\n const doc = await this.#handle.doc();\n if (doc === undefined)\n return;\n this.#peers.forEach(peerId => this.#sendSyncMessage(peerId, doc));\n }\n async #broadcastToPeers({ data, }) {\n this.#log(`broadcastToPeers`, this.#peers);\n this.#peers.forEach(peerId => this.#sendEphemeralMessage(peerId, data));\n }\n #sendEphemeralMessage(peerId, data) {\n this.#log(`sendEphemeralMessage ->${peerId}`);\n const message = {\n type: \"ephemeral\",\n targetId: peerId,\n documentId: this.#handle.documentId,\n data,\n };\n this.emit(\"message\", message);\n }\n #withSyncState(peerId, callback) {\n this.#addPeer(peerId);\n if (!(peerId in this.#peerDocumentStatuses)) {\n this.#peerDocumentStatuses[peerId] = \"unknown\";\n }\n const syncState = this.#syncStates[peerId];\n if (syncState) {\n callback(syncState);\n return;\n }\n let pendingCallbacks = this.#pendingSyncStateCallbacks[peerId];\n if (!pendingCallbacks) {\n this.#onLoadSyncState(peerId)\n .then(syncState => {\n this.#initSyncState(peerId, syncState ?? A.initSyncState());\n })\n .catch(err => {\n this.#log(`Error loading sync state for ${peerId}: ${err}`);\n });\n pendingCallbacks = this.#pendingSyncStateCallbacks[peerId] = [];\n }\n pendingCallbacks.push(callback);\n }\n #addPeer(peerId) {\n if (!this.#peers.includes(peerId)) {\n this.#peers.push(peerId);\n this.emit(\"open-doc\", { documentId: this.documentId, peerId });\n }\n }\n #initSyncState(peerId, syncState) {\n const pendingCallbacks = this.#pendingSyncStateCallbacks[peerId];\n if (pendingCallbacks) {\n for (const callback of pendingCallbacks) {\n callback(syncState);\n }\n }\n delete this.#pendingSyncStateCallbacks[peerId];\n this.#syncStates[peerId] = syncState;\n }\n #setSyncState(peerId, syncState) {\n this.#syncStates[peerId] = syncState;\n this.emit(\"sync-state\", {\n peerId,\n syncState,\n documentId: this.#handle.documentId,\n });\n }\n #sendSyncMessage(peerId, doc) {\n this.#log(`sendSyncMessage ->${peerId}`);\n this.#withSyncState(peerId, syncState => {\n const [newSyncState, message] = A.generateSyncMessage(doc, syncState);\n if (message) {\n this.#setSyncState(peerId, newSyncState);\n const isNew = A.getHeads(doc).length === 0;\n if (!this.#handle.isReady() &&\n isNew &&\n newSyncState.sharedHeads.length === 0 &&\n !Object.values(this.#peerDocumentStatuses).includes(\"has\") &&\n this.#peerDocumentStatuses[peerId] === \"unknown\") {\n // we don't have the document (or access to it), so we request it\n this.emit(\"message\", {\n type: \"request\",\n targetId: peerId,\n documentId: this.#handle.documentId,\n data: message,\n });\n }\n else {\n this.emit(\"message\", {\n type: \"sync\",\n targetId: peerId,\n data: message,\n documentId: this.#handle.documentId,\n });\n }\n // if we have sent heads, then the peer now has or will have the document\n if (!isNew) {\n this.#peerDocumentStatuses[peerId] = \"has\";\n }\n }\n });\n }\n /// PUBLIC\n hasPeer(peerId) {\n return this.#peers.includes(peerId);\n }\n beginSync(peerIds) {\n const noPeersWithDocument = peerIds.every(peerId => this.#peerDocumentStatuses[peerId] in [\"unavailable\", \"wants\"]);\n // At this point if we don't have anything in our storage, we need to use an empty doc to sync\n // with; but we don't want to surface that state to the front end\n const docPromise = this.#handle\n .doc([READY, REQUESTING, UNAVAILABLE])\n .then(doc => {\n // we register out peers first, then say that sync has started\n this.#syncStarted = true;\n this.#checkDocUnavailable();\n const wasUnavailable = doc === undefined;\n if (wasUnavailable && noPeersWithDocument) {\n return;\n }\n // If the doc is unavailable we still need a blank document to generate\n // the sync message from\n return doc ?? A.init();\n });\n this.#log(`beginSync: ${peerIds.join(\", \")}`);\n peerIds.forEach(peerId => {\n this.#withSyncState(peerId, syncState => {\n // HACK: if we have a sync state already, we round-trip it through the encoding system to make\n // sure state is preserved. This prevents an infinite loop caused by failed attempts to send\n // messages during disconnection.\n // TODO: cover that case with a test and remove this hack\n const reparsedSyncState = A.decodeSyncState(A.encodeSyncState(syncState));\n this.#setSyncState(peerId, reparsedSyncState);\n docPromise\n .then(doc => {\n if (doc) {\n this.#sendSyncMessage(peerId, doc);\n }\n })\n .catch(err => {\n this.#log(`Error loading doc for ${peerId}: ${err}`);\n });\n });\n });\n }\n endSync(peerId) {\n this.#log(`removing peer ${peerId}`);\n this.#peers = this.#peers.filter(p => p !== peerId);\n }\n receiveMessage(message) {\n switch (message.type) {\n case \"sync\":\n case \"request\":\n this.receiveSyncMessage(message);\n break;\n case \"ephemeral\":\n this.receiveEphemeralMessage(message);\n break;\n case \"doc-unavailable\":\n this.#peerDocumentStatuses[message.senderId] = \"unavailable\";\n this.#checkDocUnavailable();\n break;\n default:\n throw new Error(`unknown message type: ${message}`);\n }\n }\n receiveEphemeralMessage(message) {\n if (message.documentId !== this.#handle.documentId)\n throw new Error(`channelId doesn't match documentId`);\n const { senderId, data } = message;\n const contents = decode(new Uint8Array(data));\n this.#handle.emit(\"ephemeral-message\", {\n handle: this.#handle,\n senderId,\n message: contents,\n });\n this.#peers.forEach(peerId => {\n if (peerId === senderId)\n return;\n this.emit(\"message\", {\n ...message,\n targetId: peerId,\n });\n });\n }\n receiveSyncMessage(message) {\n if (message.documentId !== this.#handle.documentId)\n throw new Error(`channelId doesn't match documentId`);\n // We need to block receiving the syncMessages until we've checked local storage\n if (!this.#handle.inState([READY, REQUESTING, UNAVAILABLE])) {\n this.#pendingSyncMessages.push({ message, received: new Date() });\n return;\n }\n this.#processAllPendingSyncMessages();\n this.#processSyncMessage(message);\n }\n #processSyncMessage(message) {\n if (isRequestMessage(message)) {\n this.#peerDocumentStatuses[message.senderId] = \"wants\";\n }\n this.#checkDocUnavailable();\n // if the message has heads, then the peer has the document\n if (A.decodeSyncMessage(message.data).heads.length > 0) {\n this.#peerDocumentStatuses[message.senderId] = \"has\";\n }\n this.#withSyncState(message.senderId, syncState => {\n this.#handle.update(doc => {\n const [newDoc, newSyncState] = A.receiveSyncMessage(doc, syncState, message.data);\n this.#setSyncState(message.senderId, newSyncState);\n // respond to just this peer (as required)\n this.#sendSyncMessage(message.senderId, doc);\n return newDoc;\n });\n this.#checkDocUnavailable();\n });\n }\n #checkDocUnavailable() {\n // if we know none of the peers have the document, tell all our peers that we don't either\n if (this.#syncStarted &&\n this.#handle.inState([REQUESTING]) &&\n this.#peers.every(peerId => this.#peerDocumentStatuses[peerId] === \"unavailable\" ||\n this.#peerDocumentStatuses[peerId] === \"wants\")) {\n this.#peers\n .filter(peerId => this.#peerDocumentStatuses[peerId] === \"wants\")\n .forEach(peerId => {\n const message = {\n type: \"doc-unavailable\",\n documentId: this.#handle.documentId,\n targetId: peerId,\n };\n this.emit(\"message\", message);\n });\n this.#handle.unavailable();\n }\n }\n #processAllPendingSyncMessages() {\n for (const message of this.#pendingSyncMessages) {\n this.#processSyncMessage(message.message);\n }\n this.#pendingSyncMessages = [];\n }\n metrics() {\n return {\n peers: this.#peers,\n size: this.#handle.metrics(),\n };\n }\n}\n","import debug from \"debug\";\nimport { stringifyAutomergeUrl } from \"../AutomergeUrl.js\";\nimport { DocSynchronizer } from \"./DocSynchronizer.js\";\nimport { Synchronizer } from \"./Synchronizer.js\";\nconst log = debug(\"automerge-repo:collectionsync\");\n/** A CollectionSynchronizer is responsible for synchronizing a DocCollection with peers. */\nexport class CollectionSynchronizer extends Synchronizer {\n repo;\n /** The set of peers we are connected with */\n #peers = new Set();\n /** A map of documentIds to their synchronizers */\n /** @hidden */\n docSynchronizers = {};\n /** Used to determine if the document is know to the Collection and a synchronizer exists or is being set up */\n #docSetUp = {};\n constructor(repo) {\n super();\n this.repo = repo;\n }\n /** Returns a synchronizer for the given document, creating one if it doesn't already exist. */\n #fetchDocSynchronizer(documentId) {\n if (!this.docSynchronizers[documentId]) {\n const handle = this.repo.find(stringifyAutomergeUrl({ documentId }));\n this.docSynchronizers[documentId] = this.#initDocSynchronizer(handle);\n }\n return this.docSynchronizers[documentId];\n }\n /** Creates a new docSynchronizer and sets it up to propagate messages */\n #initDocSynchronizer(handle) {\n const docSynchronizer = new DocSynchronizer({\n handle,\n onLoadSyncState: async (peerId) => {\n if (!this.repo.storageSubsystem) {\n return;\n }\n const { storageId, isEphemeral } = this.repo.peerMetadataByPeerId[peerId] || {};\n if (!storageId || isEphemeral) {\n return;\n }\n return this.repo.storageSubsystem.loadSyncState(handle.documentId, storageId);\n },\n });\n docSynchronizer.on(\"message\", event => this.emit(\"message\", event));\n docSynchronizer.on(\"open-doc\", event => this.emit(\"open-doc\", event));\n docSynchronizer.on(\"sync-state\", event => this.emit(\"sync-state\", event));\n return docSynchronizer;\n }\n /** returns an array of peerIds that we share this document generously with */\n async #documentGenerousPeers(documentId) {\n const peers = Array.from(this.#peers);\n const generousPeers = [];\n for (const peerId of peers) {\n const okToShare = await this.repo.sharePolicy(peerId, documentId);\n if (okToShare)\n generousPeers.push(peerId);\n }\n return generousPeers;\n }\n // PUBLIC\n /**\n * When we receive a sync message for a document we haven't got in memory, we\n * register it with the repo and start synchronizing\n */\n async receiveMessage(message) {\n log(`onSyncMessage: ${message.senderId}, ${message.documentId}, ${\"data\" in message ? message.data.byteLength + \"bytes\" : \"\"}`);\n const documentId = message.documentId;\n if (!documentId) {\n throw new Error(\"received a message with an invalid documentId\");\n }\n this.#docSetUp[documentId] = true;\n const docSynchronizer = this.#fetchDocSynchronizer(documentId);\n docSynchronizer.receiveMessage(message);\n // Initiate sync with any new peers\n const peers = await this.#documentGenerousPeers(documentId);\n docSynchronizer.beginSync(peers.filter(peerId => !docSynchronizer.hasPeer(peerId)));\n }\n /**\n * Starts synchronizing the given document with all peers that we share it generously with.\n */\n addDocument(documentId) {\n // HACK: this is a hack to prevent us from adding the same document twice\n if (this.#docSetUp[documentId]) {\n return;\n }\n const docSynchronizer = this.#fetchDocSynchronizer(documentId);\n void this.#documentGenerousPeers(documentId).then(peers => {\n docSynchronizer.beginSync(peers);\n });\n }\n // TODO: implement this\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n removeDocument(documentId) {\n throw new Error(\"not implemented\");\n }\n /** Adds a peer and maybe starts synchronizing with them */\n addPeer(peerId) {\n log(`adding ${peerId} & synchronizing with them`);\n if (this.#peers.has(peerId)) {\n return;\n }\n this.#peers.add(peerId);\n for (const docSynchronizer of Object.values(this.docSynchronizers)) {\n const { documentId } = docSynchronizer;\n void this.repo.sharePolicy(peerId, documentId).then(okToShare => {\n if (okToShare)\n docSynchronizer.beginSync([peerId]);\n });\n }\n }\n /** Removes a peer and stops synchronizing with them */\n removePeer(peerId) {\n log(`removing peer ${peerId}`);\n this.#peers.delete(peerId);\n for (const docSynchronizer of Object.values(this.docSynchronizers)) {\n docSynchronizer.endSync(peerId);\n }\n }\n /** Returns a list of all connected peer ids */\n get peers() {\n return Array.from(this.#peers);\n }\n metrics() {\n return Object.fromEntries(Object.entries(this.docSynchronizers).map(([documentId, synchronizer]) => {\n return [documentId, synchronizer.metrics()];\n }));\n }\n}\n","import { next as Automerge } from \"@automerge/automerge/slim\";\nimport debug from \"debug\";\nimport { EventEmitter } from \"eventemitter3\";\nimport { generateAutomergeUrl, interpretAsDocumentId, parseAutomergeUrl, } from \"./AutomergeUrl.js\";\nimport { DocHandle } from \"./DocHandle.js\";\nimport { RemoteHeadsSubscriptions } from \"./RemoteHeadsSubscriptions.js\";\nimport { headsAreSame } from \"./helpers/headsAreSame.js\";\nimport { throttle } from \"./helpers/throttle.js\";\nimport { NetworkSubsystem } from \"./network/NetworkSubsystem.js\";\nimport { StorageSubsystem } from \"./storage/StorageSubsystem.js\";\nimport { CollectionSynchronizer } from \"./synchronizer/CollectionSynchronizer.js\";\nfunction randomPeerId() {\n return (\"peer-\" + Math.random().toString(36).slice(4));\n}\n/** A Repo is a collection of documents with networking, syncing, and storage capabilities. */\n/** The `Repo` is the main entry point of this library\n *\n * @remarks\n * To construct a `Repo` you will need an {@link StorageAdapter} and one or\n * more {@link NetworkAdapter}s. Once you have a `Repo` you can use it to\n * obtain {@link DocHandle}s.\n */\nexport class Repo extends EventEmitter {\n #log;\n /** @hidden */\n networkSubsystem;\n /** @hidden */\n storageSubsystem;\n /** The debounce rate is adjustable on the repo. */\n /** @hidden */\n saveDebounceRate = 100;\n #handleCache = {};\n /** @hidden */\n synchronizer;\n /** By default, we share generously with all peers. */\n /** @hidden */\n sharePolicy = async () => true;\n /** maps peer id to to persistence information (storageId, isEphemeral), access by collection synchronizer */\n /** @hidden */\n peerMetadataByPeerId = {};\n #remoteHeadsSubscriptions = new RemoteHeadsSubscriptions();\n #remoteHeadsGossipingEnabled = false;\n constructor({ storage, network = [], peerId = randomPeerId(), sharePolicy, isEphemeral = storage === undefined, enableRemoteHeadsGossiping = false, } = {}) {\n super();\n this.#remoteHeadsGossipingEnabled = enableRemoteHeadsGossiping;\n this.#log = debug(`automerge-repo:repo`);\n this.sharePolicy = sharePolicy ?? this.sharePolicy;\n this.on(\"delete-document\", ({ documentId }) => {\n // TODO Pass the delete on to the network\n // synchronizer.removeDocument(documentId)\n if (storageSubsystem) {\n storageSubsystem.removeDoc(documentId).catch(err => {\n this.#log(\"error deleting document\", { documentId, err });\n });\n }\n });\n // SYNCHRONIZER\n // The synchronizer uses the network subsystem to keep documents in sync with peers.\n this.synchronizer = new CollectionSynchronizer(this);\n // When the synchronizer emits messages, send them to peers\n this.synchronizer.on(\"message\", message => {\n this.#log(`sending ${message.type} message to ${message.targetId}`);\n networkSubsystem.send(message);\n });\n if (this.#remoteHeadsGossipingEnabled) {\n this.synchronizer.on(\"open-doc\", ({ peerId, documentId }) => {\n this.#remoteHeadsSubscriptions.subscribePeerToDoc(peerId, documentId);\n });\n }\n // STORAGE\n // The storage subsystem has access to some form of persistence, and deals with save and loading documents.\n const storageSubsystem = storage ? new StorageSubsystem(storage) : undefined;\n this.storageSubsystem = storageSubsystem;\n // NETWORK\n // The network subsystem deals with sending and receiving messages to and from peers.\n const myPeerMetadata = (async () => ({\n storageId: await storageSubsystem?.id(),\n isEphemeral,\n }))();\n const networkSubsystem = new NetworkSubsystem(network, peerId, myPeerMetadata);\n this.networkSubsystem = networkSubsystem;\n // When we get a new peer, register it with the synchronizer\n networkSubsystem.on(\"peer\", async ({ peerId, peerMetadata }) => {\n this.#log(\"peer connected\", { peerId });\n if (peerMetadata) {\n this.peerMetadataByPeerId[peerId] = { ...peerMetadata };\n }\n this.sharePolicy(peerId)\n .then(shouldShare => {\n if (shouldShare && this.#remoteHeadsGossipingEnabled) {\n this.#remoteHeadsSubscriptions.addGenerousPeer(peerId);\n }\n })\n .catch(err => {\n console.log(\"error in share policy\", { err });\n });\n this.synchronizer.addPeer(peerId);\n });\n // When a peer disconnects, remove it from the synchronizer\n networkSubsystem.on(\"peer-disconnected\", ({ peerId }) => {\n this.synchronizer.removePeer(peerId);\n this.#remoteHeadsSubscriptions.removePeer(peerId);\n });\n // Handle incoming messages\n networkSubsystem.on(\"message\", async (msg) => {\n this.#receiveMessage(msg);\n });\n this.synchronizer.on(\"sync-state\", message => {\n this.#saveSyncState(message);\n const handle = this.#handleCache[message.documentId];\n const { storageId } = this.peerMetadataByPeerId[message.peerId] || {};\n if (!storageId) {\n return;\n }\n const heads = handle.getRemoteHeads(storageId);\n const haveHeadsChanged = message.syncState.theirHeads &&\n (!heads || !headsAreSame(heads, message.syncState.theirHeads));\n if (haveHeadsChanged && message.syncState.theirHeads) {\n handle.setRemoteHeads(storageId, message.syncState.theirHeads);\n if (storageId && this.#remoteHeadsGossipingEnabled) {\n this.#remoteHeadsSubscriptions.handleImmediateRemoteHeadsChanged(message.documentId, storageId, message.syncState.theirHeads);\n }\n }\n });\n if (this.#remoteHeadsGossipingEnabled) {\n this.#remoteHeadsSubscriptions.on(\"notify-remote-heads\", message => {\n this.networkSubsystem.send({\n type: \"remote-heads-changed\",\n targetId: message.targetId,\n documentId: message.documentId,\n newHeads: {\n [message.storageId]: {\n heads: message.heads,\n timestamp: message.timestamp,\n },\n },\n });\n });\n this.#remoteHeadsSubscriptions.on(\"change-remote-subs\", message => {\n this.#log(\"change-remote-subs\", message);\n for (const peer of message.peers) {\n this.networkSubsystem.send({\n type: \"remote-subscription-change\",\n targetId: peer,\n add: message.add,\n remove: message.remove,\n });\n }\n });\n this.#remoteHeadsSubscriptions.on(\"remote-heads-changed\", message => {\n const handle = this.#handleCache[message.documentId];\n handle.setRemoteHeads(message.storageId, message.remoteHeads);\n });\n }\n }\n // The `document` event is fired by the DocCollection any time we create a new document or look\n // up a document by ID. We listen for it in order to wire up storage and network synchronization.\n #registerHandleWithSubsystems(handle) {\n const { storageSubsystem } = this;\n if (storageSubsystem) {\n // Save when the document changes, but no more often than saveDebounceRate.\n const saveFn = ({ handle, doc }) => {\n void storageSubsystem.saveDoc(handle.documentId, doc);\n };\n handle.on(\"heads-changed\", throttle(saveFn, this.saveDebounceRate));\n }\n handle.on(\"unavailable\", () => {\n this.#log(\"document unavailable\", { documentId: handle.documentId });\n this.emit(\"unavailable-document\", {\n documentId: handle.documentId,\n });\n });\n // Register the document with the synchronizer. This advertises our interest in the document.\n this.synchronizer.addDocument(handle.documentId);\n // Preserve the old event in case anyone was using it.\n this.emit(\"document\", { handle });\n }\n #receiveMessage(message) {\n switch (message.type) {\n case \"remote-subscription-change\":\n if (this.#remoteHeadsGossipingEnabled) {\n this.#remoteHeadsSubscriptions.handleControlMessage(message);\n }\n break;\n case \"remote-heads-changed\":\n if (this.#remoteHeadsGossipingEnabled) {\n this.#remoteHeadsSubscriptions.handleRemoteHeads(message);\n }\n break;\n case \"sync\":\n case \"request\":\n case \"ephemeral\":\n case \"doc-unavailable\":\n this.synchronizer.receiveMessage(message).catch(err => {\n console.log(\"error receiving message\", { err });\n });\n }\n }\n #throttledSaveSyncStateHandlers = {};\n /** saves sync state throttled per storage id, if a peer doesn't have a storage id it's sync state is not persisted */\n #saveSyncState(payload) {\n if (!this.storageSubsystem) {\n return;\n }\n const { storageId, isEphemeral } = this.peerMetadataByPeerId[payload.peerId] || {};\n if (!storageId || isEphemeral) {\n return;\n }\n let handler = this.#throttledSaveSyncStateHandlers[storageId];\n if (!handler) {\n handler = this.#throttledSaveSyncStateHandlers[storageId] = throttle(({ documentId, syncState }) => {\n void this.storageSubsystem.saveSyncState(documentId, storageId, syncState);\n }, this.saveDebounceRate);\n }\n handler(payload);\n }\n /** Returns an existing handle if we have it; creates one otherwise. */\n #getHandle({ documentId, }) {\n // If we have the handle cached, return it\n if (this.#handleCache[documentId])\n return this.#handleCache[documentId];\n // If not, create a new handle, cache it, and return it\n if (!documentId)\n throw new Error(`Invalid documentId ${documentId}`);\n const handle = new DocHandle(documentId);\n this.#handleCache[documentId] = handle;\n return handle;\n }\n /** Returns all the handles we have cached. */\n get handles() {\n return this.#handleCache;\n }\n /** Returns a list of all connected peer ids */\n get peers() {\n return this.synchronizer.peers;\n }\n getStorageIdOfPeer(peerId) {\n return this.peerMetadataByPeerId[peerId]?.storageId;\n }\n /**\n * Creates a new document and returns a handle to it. The initial value of the document is an\n * empty object `{}` unless an initial value is provided. Its documentId is generated by the\n * system. we emit a `document` event to advertise interest in the document.\n */\n create(initialValue) {\n // Generate a new UUID and store it in the buffer\n const { documentId } = parseAutomergeUrl(generateAutomergeUrl());\n const handle = this.#getHandle({\n documentId,\n });\n this.#registerHandleWithSubsystems(handle);\n handle.update(() => {\n let nextDoc;\n if (initialValue) {\n nextDoc = Automerge.from(initialValue);\n }\n else {\n nextDoc = Automerge.emptyChange(Automerge.init());\n }\n return nextDoc;\n });\n handle.doneLoading();\n return handle;\n }\n /** Create a new DocHandle by cloning the history of an existing DocHandle.\n *\n * @param clonedHandle - The handle to clone\n *\n * @remarks This is a wrapper around the `clone` function in the Automerge library.\n * The new `DocHandle` will have a new URL but will share history with the original,\n * which means that changes made to the cloned handle can be sensibly merged back\n * into the original.\n *\n * Any peers this `Repo` is connected to for whom `sharePolicy` returns `true` will\n * be notified of the newly created DocHandle.\n *\n * @throws if the cloned handle is not yet ready or if\n * `clonedHandle.docSync()` returns `undefined` (i.e. the handle is unavailable).\n */\n clone(clonedHandle) {\n if (!clonedHandle.isReady()) {\n throw new Error(`Cloned handle is not yet in ready state.\n (Try await handle.whenReady() first.)`);\n }\n const sourceDoc = clonedHandle.docSync();\n if (!sourceDoc) {\n throw new Error(\"Cloned handle doesn't have a document.\");\n }\n const handle = this.create();\n handle.update(() => {\n // we replace the document with the new cloned one\n return Automerge.clone(sourceDoc);\n });\n return handle;\n }\n /**\n * Retrieves a document by id. It gets data from the local system, but also emits a `document`\n * event to advertise interest in the document.\n */\n find(\n /** The url or documentId of the handle to retrieve */\n id) {\n const documentId = interpretAsDocumentId(id);\n // If we have the handle cached, return it\n if (this.#handleCache[documentId]) {\n if (this.#handleCache[documentId].isUnavailable()) {\n // this ensures that the event fires after the handle has been returned\n setTimeout(() => {\n this.#handleCache[documentId].emit(\"unavailable\", {\n handle: this.#handleCache[documentId],\n });\n });\n }\n return this.#handleCache[documentId];\n }\n // If we don't already have the handle, make an empty one and try loading it\n const handle = this.#getHandle({\n documentId,\n });\n // Loading & network is going to be asynchronous no matter what,\n // but we want to return the handle immediately.\n const attemptLoad = this.storageSubsystem\n ? this.storageSubsystem.loadDoc(handle.documentId)\n : Promise.resolve(null);\n attemptLoad\n .then(async (loadedDoc) => {\n if (loadedDoc) {\n // uhhhh, sorry if you're reading this because we were lying to the type system\n handle.update(() => loadedDoc);\n handle.doneLoading();\n }\n else {\n // we want to wait for the network subsystem to be ready before\n // we request the document. this prevents entering unavailable during initialization.\n await this.networkSubsystem.whenReady();\n handle.request();\n }\n this.#registerHandleWithSubsystems(handle);\n })\n .catch(err => {\n this.#log(\"error waiting for network\", { err });\n });\n return handle;\n }\n delete(\n /** The url or documentId of the handle to delete */\n id) {\n const documentId = interpretAsDocumentId(id);\n const handle = this.#getHandle({ documentId });\n handle.delete();\n delete this.#handleCache[documentId];\n this.emit(\"delete-document\", { documentId });\n }\n /**\n * Exports a document to a binary format.\n * @param id - The url or documentId of the handle to export\n *\n * @returns Promise<Uint8Array | undefined> - A Promise containing the binary document,\n * or undefined if the document is unavailable.\n */\n async export(id) {\n const documentId = interpretAsDocumentId(id);\n const handle = this.#getHandle({ documentId });\n const doc = await handle.doc();\n if (!doc)\n return undefined;\n return Automerge.save(doc);\n }\n /**\n * Imports document binary into the repo.\n * @param binary - The binary to import\n */\n import(binary) {\n const doc = Automerge.load(binary);\n const handle = this.create();\n handle.update(() => {\n return Automerge.clone(doc);\n });\n return handle;\n }\n subscribeToRemotes = (remotes) => {\n if (this.#remoteHeadsGossipingEnabled) {\n this.#log(\"subscribeToRemotes\", { remotes });\n this.#remoteHeadsSubscriptions.subscribeToRemotes(remotes);\n }\n else {\n this.#log(\"WARN: subscribeToRemotes called but remote heads gossiping is not enabled\");\n }\n };\n storageId = async () => {\n if (!this.storageSubsystem) {\n return undefined;\n }\n else {\n return this.storageSubsystem.id();\n }\n };\n /**\n * Writes Documents to a disk.\n * @hidden this API is experimental and may change.\n * @param documents - if provided, only writes the specified documents.\n * @returns Promise<void>\n */\n async flush(documents) {\n if (!this.storageSubsystem) {\n return;\n }\n const handles = documents\n ? documents.map(id => this.#handleCache[id])\n : Object.values(this.#handleCache);\n await Promise.all(handles.map(async (handle) => {\n const doc = handle.docSync();\n if (!doc) {\n return;\n }\n return this.storageSubsystem.saveDoc(handle.documentId, doc);\n }));\n }\n shutdown() {\n this.networkSubsystem.adapters.forEach(adapter => {\n adapter.disconnect();\n });\n return this.flush();\n }\n metrics() {\n return { documents: this.synchronizer.metrics() };\n }\n}\n","/* c8 ignore start */\nimport { EventEmitter } from \"eventemitter3\";\n/** An interface representing some way to connect to other peers\n *\n * @remarks\n * The {@link Repo} uses one or more `NetworkAdapter`s to connect to other peers.\n * Because the network may take some time to be ready the {@link Repo} will wait\n * until the adapter emits a `ready` event before it starts trying to use it\n *\n * This utility class can be used as a base to build a custom network adapter. It\n * is most useful as a simple way to add the necessary event emitter functionality\n */\nexport class NetworkAdapter extends EventEmitter {\n peerId;\n peerMetadata;\n}\n","export default \"__VITE_ASSET__DG1CEUL7__\"","export default async (opts = {}, url) => {\n let result;\n if (url.startsWith(\"data:\")) {\n const urlContent = url.replace(/^data:.*?base64,/, \"\");\n let bytes;\n if (typeof Buffer === \"function\" && typeof Buffer.from === \"function\") {\n bytes = Buffer.from(urlContent, \"base64\");\n }\n else if (typeof atob === \"function\") {\n const binaryString = atob(urlContent);\n bytes = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i++) {\n bytes[i] = binaryString.charCodeAt(i);\n }\n }\n else {\n throw new Error(\"Cannot decode base64-encoded data URL\");\n }\n result = await WebAssembly.instantiate(bytes, opts);\n }\n else {\n // https://github.com/mdn/webassembly-examples/issues/5\n // WebAssembly.instantiateStreaming requires the server to provide the\n // correct MIME type for .wasm files, which unfortunately doesn't work for\n // a lot of static file servers, so we just work around it by getting the\n // raw buffer.\n // @ts-ignore\n const response = await fetch(url);\n const contentType = response.headers.get(\"Content-Type\") || \"\";\n if (\"instantiateStreaming\" in WebAssembly && contentType.startsWith(\"application/wasm\")) {\n result = await WebAssembly.instantiateStreaming(response, opts);\n }\n else {\n const buffer = await response.arrayBuffer();\n result = await WebAssembly.instantiate(buffer, opts);\n }\n }\n return result.instance.exports;\n}","let wasm;\nexport function __wbg_set_wasm(val) {\n wasm = val;\n}\n\n\nconst heap = new Array(128).fill(undefined);\n\nheap.push(undefined, null, true, false);\n\nfunction getObject(idx) { return heap[idx]; }\n\nlet heap_next = heap.length;\n\nfunction dropObject(idx) {\n if (idx < 132) return;\n heap[idx] = heap_next;\n heap_next = idx;\n}\n\nfunction takeObject(idx) {\n const ret = getObject(idx);\n dropObject(idx);\n return ret;\n}\n\nlet WASM_VECTOR_LEN = 0;\n\nlet cachedUint8Memory0 = null;\n\nfunction getUint8Memory0() {\n if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {\n cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);\n }\n return cachedUint8Memory0;\n}\n\nconst lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;\n\nlet cachedTextEncoder = new lTextEncoder('utf-8');\n\nconst encodeString = (typeof cachedTextEncoder.encodeInto === 'function'\n ? function (arg, view) {\n return cachedTextEncoder.encodeInto(arg, view);\n}\n : function (arg, view) {\n const buf = cachedTextEncoder.encode(arg);\n view.set(buf);\n return {\n read: arg.length,\n written: buf.length\n };\n});\n\nfunction passStringToWasm0(arg, malloc, realloc) {\n\n if (realloc === undefined) {\n const buf = cachedTextEncoder.encode(arg);\n const ptr = malloc(buf.length, 1) >>> 0;\n getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);\n WASM_VECTOR_LEN = buf.length;\n return ptr;\n }\n\n let len = arg.length;\n let ptr = malloc(len, 1) >>> 0;\n\n const mem = getUint8Memory0();\n\n let offset = 0;\n\n for (; offset < len; offset++) {\n const code = arg.charCodeAt(offset);\n if (code > 0x7F) break;\n mem[ptr + offset] = code;\n }\n\n if (offset !== len) {\n if (offset !== 0) {\n arg = arg.slice(offset);\n }\n ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;\n const view = getUint8Memory0().subarray(ptr + offset, ptr + len);\n const ret = encodeString(arg, view);\n\n offset += ret.written;\n ptr = realloc(ptr, len, offset, 1) >>> 0;\n }\n\n WASM_VECTOR_LEN = offset;\n return ptr;\n}\n\nfunction isLikeNone(x) {\n return x === undefined || x === null;\n}\n\nlet cachedInt32Memory0 = null;\n\nfunction getInt32Memory0() {\n if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {\n cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);\n }\n return cachedInt32Memory0;\n}\n\nconst lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;\n\nlet cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });\n\ncachedTextDecoder.decode();\n\nfunction getStringFromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));\n}\n\nfunction addHeapObject(obj) {\n if (heap_next === heap.length) heap.push(heap.length + 1);\n const idx = heap_next;\n heap_next = heap[idx];\n\n heap[idx] = obj;\n return idx;\n}\n\nlet cachedFloat64Memory0 = null;\n\nfunction getFloat64Memory0() {\n if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {\n cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);\n }\n return cachedFloat64Memory0;\n}\n\nfunction debugString(val) {\n // primitive types\n const type = typeof val;\n if (type == 'number' || type == 'boolean' || val == null) {\n return `${val}`;\n }\n if (type == 'string') {\n return `\"${val}\"`;\n }\n if (type == 'symbol') {\n const description = val.description;\n if (description == null) {\n return 'Symbol';\n } else {\n return `Symbol(${description})`;\n }\n }\n if (type == 'function') {\n const name = val.name;\n if (typeof name == 'string' && name.length > 0) {\n return `Function(${name})`;\n } else {\n return 'Function';\n }\n }\n // objects\n if (Array.isArray(val)) {\n const length = val.length;\n let debug = '[';\n if (length > 0) {\n debug += debugString(val[0]);\n }\n for(let i = 1; i < length; i++) {\n debug += ', ' + debugString(val[i]);\n }\n debug += ']';\n return debug;\n }\n // Test for built-in\n const builtInMatches = /\\[object ([^\\]]+)\\]/.exec(toString.call(val));\n let className;\n if (builtInMatches.length > 1) {\n className = builtInMatches[1];\n } else {\n // Failed to match the standard '[object ClassName]'\n return toString.call(val);\n }\n if (className == 'Object') {\n // we're a user defined class or Object\n // JSON.stringify avoids problems with cycles, and is generally much\n // easier than looping through ownProperties of `val`.\n try {\n return 'Object(' + JSON.stringify(val) + ')';\n } catch (_) {\n return 'Object';\n }\n }\n // errors\n if (val instanceof Error) {\n return `${val.name}: ${val.message}\\n${val.stack}`;\n }\n // TODO we could test for more things here, like `Set`s and `Map`s.\n return className;\n}\n\nfunction _assertClass(instance, klass) {\n if (!(instance instanceof klass)) {\n throw new Error(`expected instance of ${klass.name}`);\n }\n return instance.ptr;\n}\n/**\n* @param {any} options\n* @returns {Automerge}\n*/\nexport function create(options) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.create(retptr, addHeapObject(options));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return Automerge.__wrap(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n}\n\n/**\n* @param {Uint8Array} data\n* @param {any} options\n* @returns {Automerge}\n*/\nexport function load(data, options) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.load(retptr, addHeapObject(data), addHeapObject(options));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return Automerge.__wrap(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n}\n\n/**\n* @param {any} change\n* @returns {Uint8Array}\n*/\nexport function encodeChange(change) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.encodeChange(retptr, addHeapObject(change));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n}\n\n/**\n* @param {Uint8Array} change\n* @returns {any}\n*/\nexport function decodeChange(change) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.decodeChange(retptr, addHeapObject(change));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n}\n\n/**\n* @returns {SyncState}\n*/\nexport function initSyncState() {\n const ret = wasm.initSyncState();\n return SyncState.__wrap(ret);\n}\n\n/**\n* @param {any} state\n* @returns {SyncState}\n*/\nexport function importSyncState(state) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.importSyncState(retptr, addHeapObject(state));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return SyncState.__wrap(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n}\n\n/**\n* @param {SyncState} state\n* @returns {any}\n*/\nexport function exportSyncState(state) {\n _assertClass(state, SyncState);\n const ret = wasm.exportSyncState(state.__wbg_ptr);\n return takeObject(ret);\n}\n\n/**\n* @param {any} message\n* @returns {Uint8Array}\n*/\nexport function encodeSyncMessage(message) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.encodeSyncMessage(retptr, addHeapObject(message));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n}\n\n/**\n* @param {Uint8Array} msg\n* @returns {any}\n*/\nexport function decodeSyncMessage(msg) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.decodeSyncMessage(retptr, addHeapObject(msg));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n}\n\n/**\n* @param {SyncState} state\n* @returns {Uint8Array}\n*/\nexport function encodeSyncState(state) {\n _assertClass(state, SyncState);\n const ret = wasm.encodeSyncState(state.__wbg_ptr);\n return takeObject(ret);\n}\n\n/**\n* @param {Uint8Array} data\n* @returns {SyncState}\n*/\nexport function decodeSyncState(data) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.decodeSyncState(retptr, addHeapObject(data));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return SyncState.__wrap(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n}\n\nfunction handleError(f, args) {\n try {\n return f.apply(this, args);\n } catch (e) {\n wasm.__wbindgen_exn_store(addHeapObject(e));\n }\n}\n/**\n* How text is represented in materialized objects on the JS side\n*/\nexport const TextRepresentation = Object.freeze({\n/**\n* As an array of characters and objects\n*/\nArray:0,\"0\":\"Array\",\n/**\n* As a single JS string\n*/\nString:1,\"1\":\"String\", });\n\nconst AutomergeFinalization = (typeof FinalizationRegistry === 'undefined')\n ? { register: () => {}, unregister: () => {} }\n : new FinalizationRegistry(ptr => wasm.__wbg_automerge_free(ptr >>> 0));\n/**\n*/\nexport class Automerge {\n\n static __wrap(ptr) {\n ptr = ptr >>> 0;\n const obj = Object.create(Automerge.prototype);\n obj.__wbg_ptr = ptr;\n AutomergeFinalization.register(obj, obj.__wbg_ptr, obj);\n return obj;\n }\n\n __destroy_into_raw() {\n const ptr = this.__wbg_ptr;\n this.__wbg_ptr = 0;\n AutomergeFinalization.unregister(this);\n return ptr;\n }\n\n free() {\n const ptr = this.__destroy_into_raw();\n wasm.__wbg_automerge_free(ptr);\n }\n /**\n * @param {string | undefined} actor\n * @param {TextRepresentation} text_rep\n * @returns {Automerge}\n */\n static new(actor, text_rep) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n var ptr0 = isLikeNone(actor) ? 0 : passStringToWasm0(actor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len0 = WASM_VECTOR_LEN;\n wasm.automerge_new(retptr, ptr0, len0, text_rep);\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return Automerge.__wrap(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {string | undefined} [actor]\n * @returns {Automerge}\n */\n clone(actor) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n var ptr0 = isLikeNone(actor) ? 0 : passStringToWasm0(actor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len0 = WASM_VECTOR_LEN;\n wasm.automerge_clone(retptr, this.__wbg_ptr, ptr0, len0);\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return Automerge.__wrap(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {string | undefined} actor\n * @param {any} heads\n * @returns {Automerge}\n */\n fork(actor, heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n var ptr0 = isLikeNone(actor) ? 0 : passStringToWasm0(actor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len0 = WASM_VECTOR_LEN;\n wasm.automerge_fork(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return Automerge.__wrap(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @returns {any}\n */\n pendingOps() {\n const ret = wasm.automerge_pendingOps(this.__wbg_ptr);\n return takeObject(ret);\n }\n /**\n * @param {string | undefined} [message]\n * @param {number | undefined} [time]\n * @returns {any}\n */\n commit(message, time) {\n var ptr0 = isLikeNone(message) ? 0 : passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len0 = WASM_VECTOR_LEN;\n const ret = wasm.automerge_commit(this.__wbg_ptr, ptr0, len0, !isLikeNone(time), isLikeNone(time) ? 0 : time);\n return takeObject(ret);\n }\n /**\n * @param {Automerge} other\n * @returns {Array<any>}\n */\n merge(other) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n _assertClass(other, Automerge);\n wasm.automerge_merge(retptr, this.__wbg_ptr, other.__wbg_ptr);\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @returns {number}\n */\n rollback() {\n const ret = wasm.automerge_rollback(this.__wbg_ptr);\n return ret;\n }\n /**\n * @param {any} obj\n * @param {Array<any> | undefined} [heads]\n * @returns {Array<any>}\n */\n keys(obj, heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_keys(retptr, this.__wbg_ptr, addHeapObject(obj), isLikeNone(heads) ? 0 : addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {Array<any> | undefined} [heads]\n * @returns {string}\n */\n text(obj, heads) {\n let deferred2_0;\n let deferred2_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_text(retptr, this.__wbg_ptr, addHeapObject(obj), isLikeNone(heads) ? 0 : addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n var r3 = getInt32Memory0()[retptr / 4 + 3];\n var ptr1 = r0;\n var len1 = r1;\n if (r3) {\n ptr1 = 0; len1 = 0;\n throw takeObject(r2);\n }\n deferred2_0 = ptr1;\n deferred2_1 = len1;\n return getStringFromWasm0(ptr1, len1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);\n }\n }\n /**\n * @param {any} obj\n * @param {Array<any> | undefined} [heads]\n * @returns {Array<any>}\n */\n spans(obj, heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_spans(retptr, this.__wbg_ptr, addHeapObject(obj), isLikeNone(heads) ? 0 : addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {number} start\n * @param {number} delete_count\n * @param {any} text\n */\n splice(obj, start, delete_count, text) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_splice(retptr, this.__wbg_ptr, addHeapObject(obj), start, delete_count, addHeapObject(text));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {any} new_text\n */\n updateText(obj, new_text) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_updateText(retptr, this.__wbg_ptr, addHeapObject(obj), addHeapObject(new_text));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {any} args\n */\n updateSpans(obj, args) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_updateSpans(retptr, this.__wbg_ptr, addHeapObject(obj), addHeapObject(args));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {any} value\n * @param {any} datatype\n */\n push(obj, value, datatype) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_push(retptr, this.__wbg_ptr, addHeapObject(obj), addHeapObject(value), addHeapObject(datatype));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {any} value\n * @returns {string | undefined}\n */\n pushObject(obj, value) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_pushObject(retptr, this.__wbg_ptr, addHeapObject(obj), addHeapObject(value));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n var r3 = getInt32Memory0()[retptr / 4 + 3];\n if (r3) {\n throw takeObject(r2);\n }\n let v1;\n if (r0 !== 0) {\n v1 = getStringFromWasm0(r0, r1).slice();\n wasm.__wbindgen_free(r0, r1 * 1, 1);\n }\n return v1;\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {number} index\n * @param {any} value\n * @param {any} datatype\n */\n insert(obj, index, value, datatype) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_insert(retptr, this.__wbg_ptr, addHeapObject(obj), index, addHeapObject(value), addHeapObject(datatype));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {number} index\n * @param {any} args\n */\n splitBlock(obj, index, args) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_splitBlock(retptr, this.__wbg_ptr, addHeapObject(obj), index, addHeapObject(args));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} text\n * @param {number} index\n */\n joinBlock(text, index) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_joinBlock(retptr, this.__wbg_ptr, addHeapObject(text), index);\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} text\n * @param {number} index\n * @param {any} args\n */\n updateBlock(text, index, args) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_updateBlock(retptr, this.__wbg_ptr, addHeapObject(text), index, addHeapObject(args));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} text\n * @param {number} index\n * @param {Array<any> | undefined} [heads]\n * @returns {any}\n */\n getBlock(text, index, heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_getBlock(retptr, this.__wbg_ptr, addHeapObject(text), index, isLikeNone(heads) ? 0 : addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {number} index\n * @param {any} value\n * @returns {string | undefined}\n */\n insertObject(obj, index, value) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_insertObject(retptr, this.__wbg_ptr, addHeapObject(obj), index, addHeapObject(value));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n var r3 = getInt32Memory0()[retptr / 4 + 3];\n if (r3) {\n throw takeObject(r2);\n }\n let v1;\n if (r0 !== 0) {\n v1 = getStringFromWasm0(r0, r1).slice();\n wasm.__wbindgen_free(r0, r1 * 1, 1);\n }\n return v1;\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {any} prop\n * @param {any} value\n * @param {any} datatype\n */\n put(obj, prop, value, datatype) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_put(retptr, this.__wbg_ptr, addHeapObject(obj), addHeapObject(prop), addHeapObject(value), addHeapObject(datatype));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {any} prop\n * @param {any} value\n * @returns {any}\n */\n putObject(obj, prop, value) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_putObject(retptr, this.__wbg_ptr, addHeapObject(obj), addHeapObject(prop), addHeapObject(value));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {any} prop\n * @param {any} value\n */\n increment(obj, prop, value) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_increment(retptr, this.__wbg_ptr, addHeapObject(obj), addHeapObject(prop), addHeapObject(value));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {any} prop\n * @param {Array<any> | undefined} [heads]\n * @returns {any}\n */\n get(obj, prop, heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_get(retptr, this.__wbg_ptr, addHeapObject(obj), addHeapObject(prop), isLikeNone(heads) ? 0 : addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {any} prop\n * @param {Array<any> | undefined} [heads]\n * @returns {any}\n */\n getWithType(obj, prop, heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_getWithType(retptr, this.__wbg_ptr, addHeapObject(obj), addHeapObject(prop), isLikeNone(heads) ? 0 : addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {Array<any> | undefined} [heads]\n * @returns {object}\n */\n objInfo(obj, heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_objInfo(retptr, this.__wbg_ptr, addHeapObject(obj), isLikeNone(heads) ? 0 : addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {any} arg\n * @param {Array<any> | undefined} [heads]\n * @returns {Array<any>}\n */\n getAll(obj, arg, heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_getAll(retptr, this.__wbg_ptr, addHeapObject(obj), addHeapObject(arg), isLikeNone(heads) ? 0 : addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} enable\n * @returns {any}\n */\n enableFreeze(enable) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_enableFreeze(retptr, this.__wbg_ptr, addHeapObject(enable));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} datatype\n * @param {any} export_function\n * @param {any} import_function\n */\n registerDatatype(datatype, export_function, import_function) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_registerDatatype(retptr, this.__wbg_ptr, addHeapObject(datatype), addHeapObject(export_function), addHeapObject(import_function));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} object\n * @param {any} meta\n * @returns {any}\n */\n applyPatches(object, meta) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_applyPatches(retptr, this.__wbg_ptr, addHeapObject(object), addHeapObject(meta));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} object\n * @param {any} meta\n * @returns {any}\n */\n applyAndReturnPatches(object, meta) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_applyAndReturnPatches(retptr, this.__wbg_ptr, addHeapObject(object), addHeapObject(meta));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @returns {Array<any>}\n */\n diffIncremental() {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_diffIncremental(retptr, this.__wbg_ptr);\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n */\n updateDiffCursor() {\n wasm.automerge_updateDiffCursor(this.__wbg_ptr);\n }\n /**\n */\n resetDiffCursor() {\n wasm.automerge_resetDiffCursor(this.__wbg_ptr);\n }\n /**\n * @param {Array<any>} before\n * @param {Array<any>} after\n * @returns {Array<any>}\n */\n diff(before, after) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_diff(retptr, this.__wbg_ptr, addHeapObject(before), addHeapObject(after));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {Array<any>} heads\n */\n isolate(heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_isolate(retptr, this.__wbg_ptr, addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n */\n integrate() {\n wasm.automerge_integrate(this.__wbg_ptr);\n }\n /**\n * @param {any} obj\n * @param {Array<any> | undefined} [heads]\n * @returns {number}\n */\n length(obj, heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_length(retptr, this.__wbg_ptr, addHeapObject(obj), isLikeNone(heads) ? 0 : addHeapObject(heads));\n var r0 = getFloat64Memory0()[retptr / 8 + 0];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n var r3 = getInt32Memory0()[retptr / 4 + 3];\n if (r3) {\n throw takeObject(r2);\n }\n return r0;\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {any} prop\n */\n delete(obj, prop) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_delete(retptr, this.__wbg_ptr, addHeapObject(obj), addHeapObject(prop));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @returns {Uint8Array}\n */\n save() {\n const ret = wasm.automerge_save(this.__wbg_ptr);\n return takeObject(ret);\n }\n /**\n * @returns {Uint8Array}\n */\n saveIncremental() {\n const ret = wasm.automerge_saveIncremental(this.__wbg_ptr);\n return takeObject(ret);\n }\n /**\n * @param {Array<any>} heads\n * @returns {Uint8Array}\n */\n saveSince(heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_saveSince(retptr, this.__wbg_ptr, addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @returns {Uint8Array}\n */\n saveNoCompress() {\n const ret = wasm.automerge_saveNoCompress(this.__wbg_ptr);\n return takeObject(ret);\n }\n /**\n * @returns {Uint8Array}\n */\n saveAndVerify() {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_saveAndVerify(retptr, this.__wbg_ptr);\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {Uint8Array} data\n * @returns {number}\n */\n loadIncremental(data) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_loadIncremental(retptr, this.__wbg_ptr, addHeapObject(data));\n var r0 = getFloat64Memory0()[retptr / 8 + 0];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n var r3 = getInt32Memory0()[retptr / 4 + 3];\n if (r3) {\n throw takeObject(r2);\n }\n return r0;\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} changes\n */\n applyChanges(changes) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_applyChanges(retptr, this.__wbg_ptr, addHeapObject(changes));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} have_deps\n * @returns {Array<any>}\n */\n getChanges(have_deps) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_getChanges(retptr, this.__wbg_ptr, addHeapObject(have_deps));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} hash\n * @returns {any}\n */\n getChangeByHash(hash) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_getChangeByHash(retptr, this.__wbg_ptr, addHeapObject(hash));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} hash\n * @returns {any}\n */\n getDecodedChangeByHash(hash) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_getDecodedChangeByHash(retptr, this.__wbg_ptr, addHeapObject(hash));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {Automerge} other\n * @returns {Array<any>}\n */\n getChangesAdded(other) {\n _assertClass(other, Automerge);\n const ret = wasm.automerge_getChangesAdded(this.__wbg_ptr, other.__wbg_ptr);\n return takeObject(ret);\n }\n /**\n * @returns {Array<any>}\n */\n getHeads() {\n const ret = wasm.automerge_getHeads(this.__wbg_ptr);\n return takeObject(ret);\n }\n /**\n * @returns {string}\n */\n getActorId() {\n let deferred1_0;\n let deferred1_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_getActorId(retptr, this.__wbg_ptr);\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n deferred1_0 = r0;\n deferred1_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);\n }\n }\n /**\n * @returns {any}\n */\n getLastLocalChange() {\n const ret = wasm.automerge_getLastLocalChange(this.__wbg_ptr);\n return takeObject(ret);\n }\n /**\n */\n dump() {\n wasm.automerge_dump(this.__wbg_ptr);\n }\n /**\n * @param {Array<any> | undefined} [heads]\n * @returns {Array<any>}\n */\n getMissingDeps(heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_getMissingDeps(retptr, this.__wbg_ptr, isLikeNone(heads) ? 0 : addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {SyncState} state\n * @param {Uint8Array} message\n */\n receiveSyncMessage(state, message) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n _assertClass(state, SyncState);\n wasm.automerge_receiveSyncMessage(retptr, this.__wbg_ptr, state.__wbg_ptr, addHeapObject(message));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {SyncState} state\n * @returns {any}\n */\n generateSyncMessage(state) {\n _assertClass(state, SyncState);\n const ret = wasm.automerge_generateSyncMessage(this.__wbg_ptr, state.__wbg_ptr);\n return takeObject(ret);\n }\n /**\n * @param {any} meta\n * @returns {any}\n */\n toJS(meta) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_toJS(retptr, this.__wbg_ptr, addHeapObject(meta));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {Array<any> | undefined} heads\n * @param {any} meta\n * @returns {any}\n */\n materialize(obj, heads, meta) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_materialize(retptr, this.__wbg_ptr, addHeapObject(obj), isLikeNone(heads) ? 0 : addHeapObject(heads), addHeapObject(meta));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {number} index\n * @param {Array<any> | undefined} [heads]\n * @returns {string}\n */\n getCursor(obj, index, heads) {\n let deferred2_0;\n let deferred2_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_getCursor(retptr, this.__wbg_ptr, addHeapObject(obj), index, isLikeNone(heads) ? 0 : addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n var r3 = getInt32Memory0()[retptr / 4 + 3];\n var ptr1 = r0;\n var len1 = r1;\n if (r3) {\n ptr1 = 0; len1 = 0;\n throw takeObject(r2);\n }\n deferred2_0 = ptr1;\n deferred2_1 = len1;\n return getStringFromWasm0(ptr1, len1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);\n }\n }\n /**\n * @param {any} obj\n * @param {any} cursor\n * @param {Array<any> | undefined} [heads]\n * @returns {number}\n */\n getCursorPosition(obj, cursor, heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_getCursorPosition(retptr, this.__wbg_ptr, addHeapObject(obj), addHeapObject(cursor), isLikeNone(heads) ? 0 : addHeapObject(heads));\n var r0 = getFloat64Memory0()[retptr / 8 + 0];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n var r3 = getInt32Memory0()[retptr / 4 + 3];\n if (r3) {\n throw takeObject(r2);\n }\n return r0;\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {string | undefined} [message]\n * @param {number | undefined} [time]\n * @returns {any}\n */\n emptyChange(message, time) {\n var ptr0 = isLikeNone(message) ? 0 : passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len0 = WASM_VECTOR_LEN;\n const ret = wasm.automerge_emptyChange(this.__wbg_ptr, ptr0, len0, !isLikeNone(time), isLikeNone(time) ? 0 : time);\n return takeObject(ret);\n }\n /**\n * @param {any} obj\n * @param {any} range\n * @param {any} name\n * @param {any} value\n * @param {any} datatype\n */\n mark(obj, range, name, value, datatype) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_mark(retptr, this.__wbg_ptr, addHeapObject(obj), addHeapObject(range), addHeapObject(name), addHeapObject(value), addHeapObject(datatype));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {any} range\n * @param {any} name\n */\n unmark(obj, range, name) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_unmark(retptr, this.__wbg_ptr, addHeapObject(obj), addHeapObject(range), addHeapObject(name));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {Array<any> | undefined} [heads]\n * @returns {any}\n */\n marks(obj, heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_marks(retptr, this.__wbg_ptr, addHeapObject(obj), isLikeNone(heads) ? 0 : addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} obj\n * @param {number} index\n * @param {Array<any> | undefined} [heads]\n * @returns {object}\n */\n marksAt(obj, index, heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.automerge_marksAt(retptr, this.__wbg_ptr, addHeapObject(obj), index, isLikeNone(heads) ? 0 : addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var r2 = getInt32Memory0()[retptr / 4 + 2];\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {SyncState} state\n * @returns {any}\n */\n hasOurChanges(state) {\n _assertClass(state, SyncState);\n const ret = wasm.automerge_hasOurChanges(this.__wbg_ptr, state.__wbg_ptr);\n return takeObject(ret);\n }\n /**\n * @returns {any}\n */\n topoHistoryTraversal() {\n const ret = wasm.automerge_topoHistoryTraversal(this.__wbg_ptr);\n return takeObject(ret);\n }\n /**\n * @returns {any}\n */\n stats() {\n const ret = wasm.automerge_stats(this.__wbg_ptr);\n return takeObject(ret);\n }\n}\n\nconst SyncStateFinalization = (typeof FinalizationRegistry === 'undefined')\n ? { register: () => {}, unregister: () => {} }\n : new FinalizationRegistry(ptr => wasm.__wbg_syncstate_free(ptr >>> 0));\n/**\n*/\nexport class SyncState {\n\n static __wrap(ptr) {\n ptr = ptr >>> 0;\n const obj = Object.create(SyncState.prototype);\n obj.__wbg_ptr = ptr;\n SyncStateFinalization.register(obj, obj.__wbg_ptr, obj);\n return obj;\n }\n\n __destroy_into_raw() {\n const ptr = this.__wbg_ptr;\n this.__wbg_ptr = 0;\n SyncStateFinalization.unregister(this);\n return ptr;\n }\n\n free() {\n const ptr = this.__destroy_into_raw();\n wasm.__wbg_syncstate_free(ptr);\n }\n /**\n * @returns {any}\n */\n get sharedHeads() {\n const ret = wasm.syncstate_sharedHeads(this.__wbg_ptr);\n return takeObject(ret);\n }\n /**\n * @returns {any}\n */\n get lastSentHeads() {\n const ret = wasm.syncstate_lastSentHeads(this.__wbg_ptr);\n return takeObject(ret);\n }\n /**\n * @param {any} heads\n */\n set lastSentHeads(heads) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.syncstate_set_lastSentHeads(retptr, this.__wbg_ptr, addHeapObject(heads));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @param {any} hashes\n */\n set sentHashes(hashes) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.syncstate_set_sentHashes(retptr, this.__wbg_ptr, addHeapObject(hashes));\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @returns {SyncState}\n */\n clone() {\n const ret = wasm.syncstate_clone(this.__wbg_ptr);\n return SyncState.__wrap(ret);\n }\n}\n\nexport function __wbindgen_object_drop_ref(arg0) {\n takeObject(arg0);\n};\n\nexport function __wbindgen_string_get(arg0, arg1) {\n const obj = getObject(arg1);\n const ret = typeof(obj) === 'string' ? obj : undefined;\n var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len1 = WASM_VECTOR_LEN;\n getInt32Memory0()[arg0 / 4 + 1] = len1;\n getInt32Memory0()[arg0 / 4 + 0] = ptr1;\n};\n\nexport function __wbindgen_error_new(arg0, arg1) {\n const ret = new Error(getStringFromWasm0(arg0, arg1));\n return addHeapObject(ret);\n};\n\nexport function __wbindgen_string_new(arg0, arg1) {\n const ret = getStringFromWasm0(arg0, arg1);\n return addHeapObject(ret);\n};\n\nexport function __wbindgen_number_new(arg0) {\n const ret = arg0;\n return addHeapObject(ret);\n};\n\nexport function __wbindgen_object_clone_ref(arg0) {\n const ret = getObject(arg0);\n return addHeapObject(ret);\n};\n\nexport function __wbindgen_number_get(arg0, arg1) {\n const obj = getObject(arg1);\n const ret = typeof(obj) === 'number' ? obj : undefined;\n getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;\n getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);\n};\n\nexport function __wbindgen_is_undefined(arg0) {\n const ret = getObject(arg0) === undefined;\n return ret;\n};\n\nexport function __wbindgen_boolean_get(arg0) {\n const v = getObject(arg0);\n const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;\n return ret;\n};\n\nexport function __wbindgen_is_null(arg0) {\n const ret = getObject(arg0) === null;\n return ret;\n};\n\nexport function __wbindgen_is_string(arg0) {\n const ret = typeof(getObject(arg0)) === 'string';\n return ret;\n};\n\nexport function __wbindgen_is_function(arg0) {\n const ret = typeof(getObject(arg0)) === 'function';\n return ret;\n};\n\nexport function __wbindgen_is_object(arg0) {\n const val = getObject(arg0);\n const ret = typeof(val) === 'object' && val !== null;\n return ret;\n};\n\nexport function __wbindgen_is_array(arg0) {\n const ret = Array.isArray(getObject(arg0));\n return ret;\n};\n\nexport function __wbindgen_json_serialize(arg0, arg1) {\n const obj = getObject(arg1);\n const ret = JSON.stringify(obj === undefined ? null : obj);\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n getInt32Memory0()[arg0 / 4 + 1] = len1;\n getInt32Memory0()[arg0 / 4 + 0] = ptr1;\n};\n\nexport function __wbg_new_abda76e883ba8a5f() {\n const ret = new Error();\n return addHeapObject(ret);\n};\n\nexport function __wbg_stack_658279fe44541cf6(arg0, arg1) {\n const ret = getObject(arg1).stack;\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n getInt32Memory0()[arg0 / 4 + 1] = len1;\n getInt32Memory0()[arg0 / 4 + 0] = ptr1;\n};\n\nexport function __wbg_error_f851667af71bcfc6(arg0, arg1) {\n let deferred0_0;\n let deferred0_1;\n try {\n deferred0_0 = arg0;\n deferred0_1 = arg1;\n console.error(getStringFromWasm0(arg0, arg1));\n } finally {\n wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);\n }\n};\n\nexport function __wbindgen_jsval_loose_eq(arg0, arg1) {\n const ret = getObject(arg0) == getObject(arg1);\n return ret;\n};\n\nexport function __wbg_String_91fba7ded13ba54c(arg0, arg1) {\n const ret = String(getObject(arg1));\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n getInt32Memory0()[arg0 / 4 + 1] = len1;\n getInt32Memory0()[arg0 / 4 + 0] = ptr1;\n};\n\nexport function __wbindgen_bigint_from_i64(arg0) {\n const ret = arg0;\n return addHeapObject(ret);\n};\n\nexport function __wbindgen_bigint_from_u64(arg0) {\n const ret = BigInt.asUintN(64, arg0);\n return addHeapObject(ret);\n};\n\nexport function __wbg_set_20cbc34131e76824(arg0, arg1, arg2) {\n getObject(arg0)[takeObject(arg1)] = takeObject(arg2);\n};\n\nexport function __wbg_getRandomValues_3aa56aa6edec874c() { return handleError(function (arg0, arg1) {\n getObject(arg0).getRandomValues(getObject(arg1));\n}, arguments) };\n\nexport function __wbg_randomFillSync_5c9c955aa56b6049() { return handleError(function (arg0, arg1) {\n getObject(arg0).randomFillSync(takeObject(arg1));\n}, arguments) };\n\nexport function __wbg_crypto_1d1f22824a6a080c(arg0) {\n const ret = getObject(arg0).crypto;\n return addHeapObject(ret);\n};\n\nexport function __wbg_process_4a72847cc503995b(arg0) {\n const ret = getObject(arg0).process;\n return addHeapObject(ret);\n};\n\nexport function __wbg_versions_f686565e586dd935(arg0) {\n const ret = getObject(arg0).versions;\n return addHeapObject(ret);\n};\n\nexport function __wbg_node_104a2ff8d6ea03a2(arg0) {\n const ret = getObject(arg0).node;\n return addHeapObject(ret);\n};\n\nexport function __wbg_require_cca90b1a94a0255b() { return handleError(function () {\n const ret = module.require;\n return addHeapObject(ret);\n}, arguments) };\n\nexport function __wbg_msCrypto_eb05e62b530a1508(arg0) {\n const ret = getObject(arg0).msCrypto;\n return addHeapObject(ret);\n};\n\nexport function __wbg_log_5bb5f88f245d7762(arg0) {\n console.log(getObject(arg0));\n};\n\nexport function __wbg_log_1746d5c75ec89963(arg0, arg1) {\n console.log(getObject(arg0), getObject(arg1));\n};\n\nexport function __wbg_get_bd8e338fbd5f5cc8(arg0, arg1) {\n const ret = getObject(arg0)[arg1 >>> 0];\n return addHeapObject(ret);\n};\n\nexport function __wbg_length_cd7af8117672b8b8(arg0) {\n const ret = getObject(arg0).length;\n return ret;\n};\n\nexport function __wbg_new_16b304a2cfa7ff4a() {\n const ret = new Array();\n return addHeapObject(ret);\n};\n\nexport function __wbg_newnoargs_e258087cd0daa0ea(arg0, arg1) {\n const ret = new Function(getStringFromWasm0(arg0, arg1));\n return addHeapObject(ret);\n};\n\nexport function __wbg_next_40fc327bfc8770e6(arg0) {\n const ret = getObject(arg0).next;\n return addHeapObject(ret);\n};\n\nexport function __wbg_next_196c84450b364254() { return handleError(function (arg0) {\n const ret = getObject(arg0).next();\n return addHeapObject(ret);\n}, arguments) };\n\nexport function __wbg_done_298b57d23c0fc80c(arg0) {\n const ret = getObject(arg0).done;\n return ret;\n};\n\nexport function __wbg_value_d93c65011f51a456(arg0) {\n const ret = getObject(arg0).value;\n return addHeapObject(ret);\n};\n\nexport function __wbg_iterator_2cee6dadfd956dfa() {\n const ret = Symbol.iterator;\n return addHeapObject(ret);\n};\n\nexport function __wbg_get_e3c254076557e348() { return handleError(function (arg0, arg1) {\n const ret = Reflect.get(getObject(arg0), getObject(arg1));\n return addHeapObject(ret);\n}, arguments) };\n\nexport function __wbg_call_27c0f87801dedf93() { return handleError(function (arg0, arg1) {\n const ret = getObject(arg0).call(getObject(arg1));\n return addHeapObject(ret);\n}, arguments) };\n\nexport function __wbg_new_72fb9a18b5ae2624() {\n const ret = new Object();\n return addHeapObject(ret);\n};\n\nexport function __wbg_length_dee433d4c85c9387(arg0) {\n const ret = getObject(arg0).length;\n return ret;\n};\n\nexport function __wbg_set_d4638f722068f043(arg0, arg1, arg2) {\n getObject(arg0)[arg1 >>> 0] = takeObject(arg2);\n};\n\nexport function __wbg_from_89e3fc3ba5e6fb48(arg0) {\n const ret = Array.from(getObject(arg0));\n return addHeapObject(ret);\n};\n\nexport function __wbg_isArray_2ab64d95e09ea0ae(arg0) {\n const ret = Array.isArray(getObject(arg0));\n return ret;\n};\n\nexport function __wbg_push_a5b05aedc7234f9f(arg0, arg1) {\n const ret = getObject(arg0).push(getObject(arg1));\n return ret;\n};\n\nexport function __wbg_unshift_e22df4b34bcf5070(arg0, arg1) {\n const ret = getObject(arg0).unshift(getObject(arg1));\n return ret;\n};\n\nexport function __wbg_instanceof_ArrayBuffer_836825be07d4c9d2(arg0) {\n let result;\n try {\n result = getObject(arg0) instanceof ArrayBuffer;\n } catch (_) {\n result = false;\n }\n const ret = result;\n return ret;\n};\n\nexport function __wbg_new_28c511d9baebfa89(arg0, arg1) {\n const ret = new Error(getStringFromWasm0(arg0, arg1));\n return addHeapObject(ret);\n};\n\nexport function __wbg_call_b3ca7c6051f9bec1() { return handleError(function (arg0, arg1, arg2) {\n const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));\n return addHeapObject(ret);\n}, arguments) };\n\nexport function __wbg_instanceof_Date_f65cf97fb83fc369(arg0) {\n let result;\n try {\n result = getObject(arg0) instanceof Date;\n } catch (_) {\n result = false;\n }\n const ret = result;\n return ret;\n};\n\nexport function __wbg_getTime_2bc4375165f02d15(arg0) {\n const ret = getObject(arg0).getTime();\n return ret;\n};\n\nexport function __wbg_new_cf3ec55744a78578(arg0) {\n const ret = new Date(getObject(arg0));\n return addHeapObject(ret);\n};\n\nexport function __wbg_instanceof_Object_71ca3c0a59266746(arg0) {\n let result;\n try {\n result = getObject(arg0) instanceof Object;\n } catch (_) {\n result = false;\n }\n const ret = result;\n return ret;\n};\n\nexport function __wbg_assign_496d2d14fecafbcf(arg0, arg1) {\n const ret = Object.assign(getObject(arg0), getObject(arg1));\n return addHeapObject(ret);\n};\n\nexport function __wbg_defineProperty_cc00e2de8a0f5141(arg0, arg1, arg2) {\n const ret = Object.defineProperty(getObject(arg0), getObject(arg1), getObject(arg2));\n return addHeapObject(ret);\n};\n\nexport function __wbg_entries_95cc2c823b285a09(arg0) {\n const ret = Object.entries(getObject(arg0));\n return addHeapObject(ret);\n};\n\nexport function __wbg_freeze_cc6bc19f75299986(arg0) {\n const ret = Object.freeze(getObject(arg0));\n return addHeapObject(ret);\n};\n\nexport function __wbg_keys_91e412b4b222659f(arg0) {\n const ret = Object.keys(getObject(arg0));\n return addHeapObject(ret);\n};\n\nexport function __wbg_values_9c75e6e2bfbdb70d(arg0) {\n const ret = Object.values(getObject(arg0));\n return addHeapObject(ret);\n};\n\nexport function __wbg_new_dd6a5dd7b538af21(arg0, arg1) {\n const ret = new RangeError(getStringFromWasm0(arg0, arg1));\n return addHeapObject(ret);\n};\n\nexport function __wbg_apply_0a5aa603881e6d79() { return handleError(function (arg0, arg1, arg2) {\n const ret = Reflect.apply(getObject(arg0), getObject(arg1), getObject(arg2));\n return addHeapObject(ret);\n}, arguments) };\n\nexport function __wbg_deleteProperty_13e721a56f19e842() { return handleError(function (arg0, arg1) {\n const ret = Reflect.deleteProperty(getObject(arg0), getObject(arg1));\n return ret;\n}, arguments) };\n\nexport function __wbg_ownKeys_658942b7f28d1fe9() { return handleError(function (arg0) {\n const ret = Reflect.ownKeys(getObject(arg0));\n return addHeapObject(ret);\n}, arguments) };\n\nexport function __wbg_set_1f9b04f170055d33() { return handleError(function (arg0, arg1, arg2) {\n const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));\n return ret;\n}, arguments) };\n\nexport function __wbg_buffer_12d079cc21e14bdb(arg0) {\n const ret = getObject(arg0).buffer;\n return addHeapObject(ret);\n};\n\nexport function __wbg_concat_3de229fe4fe90fea(arg0, arg1) {\n const ret = getObject(arg0).concat(getObject(arg1));\n return addHeapObject(ret);\n};\n\nexport function __wbg_slice_52fb626ffdc8da8f(arg0, arg1, arg2) {\n const ret = getObject(arg0).slice(arg1 >>> 0, arg2 >>> 0);\n return addHeapObject(ret);\n};\n\nexport function __wbg_for_27c67e2dbdce22f6(arg0, arg1) {\n const ret = Symbol.for(getStringFromWasm0(arg0, arg1));\n return addHeapObject(ret);\n};\n\nexport function __wbg_toString_7df3c77999517c20(arg0) {\n const ret = getObject(arg0).toString();\n return addHeapObject(ret);\n};\n\nexport function __wbg_self_ce0dbfc45cf2f5be() { return handleError(function () {\n const ret = self.self;\n return addHeapObject(ret);\n}, arguments) };\n\nexport function __wbg_window_c6fb939a7f436783() { return handleError(function () {\n const ret = window.window;\n return addHeapObject(ret);\n}, arguments) };\n\nexport function __wbg_globalThis_d1e6af4856ba331b() { return handleError(function () {\n const ret = globalThis.globalThis;\n return addHeapObject(ret);\n}, arguments) };\n\nexport function __wbg_global_207b558942527489() { return handleError(function () {\n const ret = global.global;\n return addHeapObject(ret);\n}, arguments) };\n\nexport function __wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb(arg0, arg1, arg2) {\n const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);\n return addHeapObject(ret);\n};\n\nexport function __wbg_new_63b92bc8671ed464(arg0) {\n const ret = new Uint8Array(getObject(arg0));\n return addHeapObject(ret);\n};\n\nexport function __wbg_set_a47bac70306a19a7(arg0, arg1, arg2) {\n getObject(arg0).set(getObject(arg1), arg2 >>> 0);\n};\n\nexport function __wbg_length_c20a40f15020d68a(arg0) {\n const ret = getObject(arg0).length;\n return ret;\n};\n\nexport function __wbg_instanceof_Uint8Array_2b3bbecd033d19f6(arg0) {\n let result;\n try {\n result = getObject(arg0) instanceof Uint8Array;\n } catch (_) {\n result = false;\n }\n const ret = result;\n return ret;\n};\n\nexport function __wbg_newwithlength_e9b4878cebadb3d3(arg0) {\n const ret = new Uint8Array(arg0 >>> 0);\n return addHeapObject(ret);\n};\n\nexport function __wbg_subarray_a1f73cd4b5b42fe1(arg0, arg1, arg2) {\n const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);\n return addHeapObject(ret);\n};\n\nexport function __wbindgen_debug_string(arg0, arg1) {\n const ret = debugString(getObject(arg1));\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n getInt32Memory0()[arg0 / 4 + 1] = len1;\n getInt32Memory0()[arg0 / 4 + 0] = ptr1;\n};\n\nexport function __wbindgen_throw(arg0, arg1) {\n throw new Error(getStringFromWasm0(arg0, arg1));\n};\n\nexport function __wbindgen_memory() {\n const ret = wasm.memory;\n return addHeapObject(ret);\n};\n\n","\nURL = globalThis.URL\nimport __vite__wasmUrl from \"/Users/Reese/Code/action_merge/node_modules/@automerge/automerge/dist/mjs/wasm_bindgen_output/bundler/automerge_wasm_bg.wasm?url\"\nimport __vite__initWasm from \"/__vite-plugin-wasm-helper\"\n\nimport { __wbindgen_object_drop_ref as __vite__wasmImport_0_0, __wbindgen_string_get as __vite__wasmImport_0_1, __wbindgen_error_new as __vite__wasmImport_0_2, __wbindgen_string_new as __vite__wasmImport_0_3, __wbindgen_number_new as __vite__wasmImport_0_4, __wbindgen_object_clone_ref as __vite__wasmImport_0_5, __wbindgen_number_get as __vite__wasmImport_0_6, __wbindgen_is_undefined as __vite__wasmImport_0_7, __wbindgen_boolean_get as __vite__wasmImport_0_8, __wbindgen_is_null as __vite__wasmImport_0_9, __wbindgen_is_string as __vite__wasmImport_0_10, __wbindgen_is_function as __vite__wasmImport_0_11, __wbindgen_is_object as __vite__wasmImport_0_12, __wbindgen_is_array as __vite__wasmImport_0_13, __wbindgen_json_serialize as __vite__wasmImport_0_14, __wbg_new_abda76e883ba8a5f as __vite__wasmImport_0_15, __wbg_stack_658279fe44541cf6 as __vite__wasmImport_0_16, __wbg_error_f851667af71bcfc6 as __vite__wasmImport_0_17, __wbindgen_jsval_loose_eq as __vite__wasmImport_0_18, __wbg_String_91fba7ded13ba54c as __vite__wasmImport_0_19, __wbindgen_bigint_from_i64 as __vite__wasmImport_0_20, __wbindgen_bigint_from_u64 as __vite__wasmImport_0_21, __wbg_set_20cbc34131e76824 as __vite__wasmImport_0_22, __wbg_getRandomValues_3aa56aa6edec874c as __vite__wasmImport_0_23, __wbg_randomFillSync_5c9c955aa56b6049 as __vite__wasmImport_0_24, __wbg_crypto_1d1f22824a6a080c as __vite__wasmImport_0_25, __wbg_process_4a72847cc503995b as __vite__wasmImport_0_26, __wbg_versions_f686565e586dd935 as __vite__wasmImport_0_27, __wbg_node_104a2ff8d6ea03a2 as __vite__wasmImport_0_28, __wbg_require_cca90b1a94a0255b as __vite__wasmImport_0_29, __wbg_msCrypto_eb05e62b530a1508 as __vite__wasmImport_0_30, __wbg_log_5bb5f88f245d7762 as __vite__wasmImport_0_31, __wbg_log_1746d5c75ec89963 as __vite__wasmImport_0_32, __wbg_get_bd8e338fbd5f5cc8 as __vite__wasmImport_0_33, __wbg_length_cd7af8117672b8b8 as __vite__wasmImport_0_34, __wbg_new_16b304a2cfa7ff4a as __vite__wasmImport_0_35, __wbg_newnoargs_e258087cd0daa0ea as __vite__wasmImport_0_36, __wbg_next_40fc327bfc8770e6 as __vite__wasmImport_0_37, __wbg_next_196c84450b364254 as __vite__wasmImport_0_38, __wbg_done_298b57d23c0fc80c as __vite__wasmImport_0_39, __wbg_value_d93c65011f51a456 as __vite__wasmImport_0_40, __wbg_iterator_2cee6dadfd956dfa as __vite__wasmImport_0_41, __wbg_get_e3c254076557e348 as __vite__wasmImport_0_42, __wbg_call_27c0f87801dedf93 as __vite__wasmImport_0_43, __wbg_new_72fb9a18b5ae2624 as __vite__wasmImport_0_44, __wbg_length_dee433d4c85c9387 as __vite__wasmImport_0_45, __wbg_set_d4638f722068f043 as __vite__wasmImport_0_46, __wbg_from_89e3fc3ba5e6fb48 as __vite__wasmImport_0_47, __wbg_isArray_2ab64d95e09ea0ae as __vite__wasmImport_0_48, __wbg_push_a5b05aedc7234f9f as __vite__wasmImport_0_49, __wbg_unshift_e22df4b34bcf5070 as __vite__wasmImport_0_50, __wbg_instanceof_ArrayBuffer_836825be07d4c9d2 as __vite__wasmImport_0_51, __wbg_new_28c511d9baebfa89 as __vite__wasmImport_0_52, __wbg_call_b3ca7c6051f9bec1 as __vite__wasmImport_0_53, __wbg_instanceof_Date_f65cf97fb83fc369 as __vite__wasmImport_0_54, __wbg_getTime_2bc4375165f02d15 as __vite__wasmImport_0_55, __wbg_new_cf3ec55744a78578 as __vite__wasmImport_0_56, __wbg_instanceof_Object_71ca3c0a59266746 as __vite__wasmImport_0_57, __wbg_assign_496d2d14fecafbcf as __vite__wasmImport_0_58, __wbg_defineProperty_cc00e2de8a0f5141 as __vite__wasmImport_0_59, __wbg_entries_95cc2c823b285a09 as __vite__wasmImport_0_60, __wbg_freeze_cc6bc19f75299986 as __vite__wasmImport_0_61, __wbg_keys_91e412b4b222659f as __vite__wasmImport_0_62, __wbg_values_9c75e6e2bfbdb70d as __vite__wasmImport_0_63, __wbg_new_dd6a5dd7b538af21 as __vite__wasmImport_0_64, __wbg_apply_0a5aa603881e6d79 as __vite__wasmImport_0_65, __wbg_deleteProperty_13e721a56f19e842 as __vite__wasmImport_0_66, __wbg_ownKeys_658942b7f28d1fe9 as __vite__wasmImport_0_67, __wbg_set_1f9b04f170055d33 as __vite__wasmImport_0_68, __wbg_buffer_12d079cc21e14bdb as __vite__wasmImport_0_69, __wbg_concat_3de229fe4fe90fea as __vite__wasmImport_0_70, __wbg_slice_52fb626ffdc8da8f as __vite__wasmImport_0_71, __wbg_for_27c67e2dbdce22f6 as __vite__wasmImport_0_72, __wbg_toString_7df3c77999517c20 as __vite__wasmImport_0_73, __wbg_self_ce0dbfc45cf2f5be as __vite__wasmImport_0_74, __wbg_window_c6fb939a7f436783 as __vite__wasmImport_0_75, __wbg_globalThis_d1e6af4856ba331b as __vite__wasmImport_0_76, __wbg_global_207b558942527489 as __vite__wasmImport_0_77, __wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb as __vite__wasmImport_0_78, __wbg_new_63b92bc8671ed464 as __vite__wasmImport_0_79, __wbg_set_a47bac70306a19a7 as __vite__wasmImport_0_80, __wbg_length_c20a40f15020d68a as __vite__wasmImport_0_81, __wbg_instanceof_Uint8Array_2b3bbecd033d19f6 as __vite__wasmImport_0_82, __wbg_newwithlength_e9b4878cebadb3d3 as __vite__wasmImport_0_83, __wbg_subarray_a1f73cd4b5b42fe1 as __vite__wasmImport_0_84, __wbindgen_debug_string as __vite__wasmImport_0_85, __wbindgen_throw as __vite__wasmImport_0_86, __wbindgen_memory as __vite__wasmImport_0_87 } from \"./automerge_wasm_bg.js\";\nconst __vite__wasmModule = await __vite__initWasm({ \"./automerge_wasm_bg.js\": { __wbindgen_object_drop_ref: __vite__wasmImport_0_0, __wbindgen_string_get: __vite__wasmImport_0_1, __wbindgen_error_new: __vite__wasmImport_0_2, __wbindgen_string_new: __vite__wasmImport_0_3, __wbindgen_number_new: __vite__wasmImport_0_4, __wbindgen_object_clone_ref: __vite__wasmImport_0_5, __wbindgen_number_get: __vite__wasmImport_0_6, __wbindgen_is_undefined: __vite__wasmImport_0_7, __wbindgen_boolean_get: __vite__wasmImport_0_8, __wbindgen_is_null: __vite__wasmImport_0_9, __wbindgen_is_string: __vite__wasmImport_0_10, __wbindgen_is_function: __vite__wasmImport_0_11, __wbindgen_is_object: __vite__wasmImport_0_12, __wbindgen_is_array: __vite__wasmImport_0_13, __wbindgen_json_serialize: __vite__wasmImport_0_14, __wbg_new_abda76e883ba8a5f: __vite__wasmImport_0_15, __wbg_stack_658279fe44541cf6: __vite__wasmImport_0_16, __wbg_error_f851667af71bcfc6: __vite__wasmImport_0_17, __wbindgen_jsval_loose_eq: __vite__wasmImport_0_18, __wbg_String_91fba7ded13ba54c: __vite__wasmImport_0_19, __wbindgen_bigint_from_i64: __vite__wasmImport_0_20, __wbindgen_bigint_from_u64: __vite__wasmImport_0_21, __wbg_set_20cbc34131e76824: __vite__wasmImport_0_22, __wbg_getRandomValues_3aa56aa6edec874c: __vite__wasmImport_0_23, __wbg_randomFillSync_5c9c955aa56b6049: __vite__wasmImport_0_24, __wbg_crypto_1d1f22824a6a080c: __vite__wasmImport_0_25, __wbg_process_4a72847cc503995b: __vite__wasmImport_0_26, __wbg_versions_f686565e586dd935: __vite__wasmImport_0_27, __wbg_node_104a2ff8d6ea03a2: __vite__wasmImport_0_28, __wbg_require_cca90b1a94a0255b: __vite__wasmImport_0_29, __wbg_msCrypto_eb05e62b530a1508: __vite__wasmImport_0_30, __wbg_log_5bb5f88f245d7762: __vite__wasmImport_0_31, __wbg_log_1746d5c75ec89963: __vite__wasmImport_0_32, __wbg_get_bd8e338fbd5f5cc8: __vite__wasmImport_0_33, __wbg_length_cd7af8117672b8b8: __vite__wasmImport_0_34, __wbg_new_16b304a2cfa7ff4a: __vite__wasmImport_0_35, __wbg_newnoargs_e258087cd0daa0ea: __vite__wasmImport_0_36, __wbg_next_40fc327bfc8770e6: __vite__wasmImport_0_37, __wbg_next_196c84450b364254: __vite__wasmImport_0_38, __wbg_done_298b57d23c0fc80c: __vite__wasmImport_0_39, __wbg_value_d93c65011f51a456: __vite__wasmImport_0_40, __wbg_iterator_2cee6dadfd956dfa: __vite__wasmImport_0_41, __wbg_get_e3c254076557e348: __vite__wasmImport_0_42, __wbg_call_27c0f87801dedf93: __vite__wasmImport_0_43, __wbg_new_72fb9a18b5ae2624: __vite__wasmImport_0_44, __wbg_length_dee433d4c85c9387: __vite__wasmImport_0_45, __wbg_set_d4638f722068f043: __vite__wasmImport_0_46, __wbg_from_89e3fc3ba5e6fb48: __vite__wasmImport_0_47, __wbg_isArray_2ab64d95e09ea0ae: __vite__wasmImport_0_48, __wbg_push_a5b05aedc7234f9f: __vite__wasmImport_0_49, __wbg_unshift_e22df4b34bcf5070: __vite__wasmImport_0_50, __wbg_instanceof_ArrayBuffer_836825be07d4c9d2: __vite__wasmImport_0_51, __wbg_new_28c511d9baebfa89: __vite__wasmImport_0_52, __wbg_call_b3ca7c6051f9bec1: __vite__wasmImport_0_53, __wbg_instanceof_Date_f65cf97fb83fc369: __vite__wasmImport_0_54, __wbg_getTime_2bc4375165f02d15: __vite__wasmImport_0_55, __wbg_new_cf3ec55744a78578: __vite__wasmImport_0_56, __wbg_instanceof_Object_71ca3c0a59266746: __vite__wasmImport_0_57, __wbg_assign_496d2d14fecafbcf: __vite__wasmImport_0_58, __wbg_defineProperty_cc00e2de8a0f5141: __vite__wasmImport_0_59, __wbg_entries_95cc2c823b285a09: __vite__wasmImport_0_60, __wbg_freeze_cc6bc19f75299986: __vite__wasmImport_0_61, __wbg_keys_91e412b4b222659f: __vite__wasmImport_0_62, __wbg_values_9c75e6e2bfbdb70d: __vite__wasmImport_0_63, __wbg_new_dd6a5dd7b538af21: __vite__wasmImport_0_64, __wbg_apply_0a5aa603881e6d79: __vite__wasmImport_0_65, __wbg_deleteProperty_13e721a56f19e842: __vite__wasmImport_0_66, __wbg_ownKeys_658942b7f28d1fe9: __vite__wasmImport_0_67, __wbg_set_1f9b04f170055d33: __vite__wasmImport_0_68, __wbg_buffer_12d079cc21e14bdb: __vite__wasmImport_0_69, __wbg_concat_3de229fe4fe90fea: __vite__wasmImport_0_70, __wbg_slice_52fb626ffdc8da8f: __vite__wasmImport_0_71, __wbg_for_27c67e2dbdce22f6: __vite__wasmImport_0_72, __wbg_toString_7df3c77999517c20: __vite__wasmImport_0_73, __wbg_self_ce0dbfc45cf2f5be: __vite__wasmImport_0_74, __wbg_window_c6fb939a7f436783: __vite__wasmImport_0_75, __wbg_globalThis_d1e6af4856ba331b: __vite__wasmImport_0_76, __wbg_global_207b558942527489: __vite__wasmImport_0_77, __wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb: __vite__wasmImport_0_78, __wbg_new_63b92bc8671ed464: __vite__wasmImport_0_79, __wbg_set_a47bac70306a19a7: __vite__wasmImport_0_80, __wbg_length_c20a40f15020d68a: __vite__wasmImport_0_81, __wbg_instanceof_Uint8Array_2b3bbecd033d19f6: __vite__wasmImport_0_82, __wbg_newwithlength_e9b4878cebadb3d3: __vite__wasmImport_0_83, __wbg_subarray_a1f73cd4b5b42fe1: __vite__wasmImport_0_84, __wbindgen_debug_string: __vite__wasmImport_0_85, __wbindgen_throw: __vite__wasmImport_0_86, __wbindgen_memory: __vite__wasmImport_0_87 } }, __vite__wasmUrl);\nexport const memory = __vite__wasmModule.memory;\nexport const __wbg_syncstate_free = __vite__wasmModule.__wbg_syncstate_free;\nexport const syncstate_sharedHeads = __vite__wasmModule.syncstate_sharedHeads;\nexport const syncstate_lastSentHeads = __vite__wasmModule.syncstate_lastSentHeads;\nexport const syncstate_set_lastSentHeads = __vite__wasmModule.syncstate_set_lastSentHeads;\nexport const syncstate_set_sentHashes = __vite__wasmModule.syncstate_set_sentHashes;\nexport const syncstate_clone = __vite__wasmModule.syncstate_clone;\nexport const __wbg_automerge_free = __vite__wasmModule.__wbg_automerge_free;\nexport const automerge_new = __vite__wasmModule.automerge_new;\nexport const automerge_clone = __vite__wasmModule.automerge_clone;\nexport const automerge_fork = __vite__wasmModule.automerge_fork;\nexport const automerge_pendingOps = __vite__wasmModule.automerge_pendingOps;\nexport const automerge_commit = __vite__wasmModule.automerge_commit;\nexport const automerge_merge = __vite__wasmModule.automerge_merge;\nexport const automerge_rollback = __vite__wasmModule.automerge_rollback;\nexport const automerge_keys = __vite__wasmModule.automerge_keys;\nexport const automerge_text = __vite__wasmModule.automerge_text;\nexport const automerge_spans = __vite__wasmModule.automerge_spans;\nexport const automerge_splice = __vite__wasmModule.automerge_splice;\nexport const automerge_updateText = __vite__wasmModule.automerge_updateText;\nexport const automerge_updateSpans = __vite__wasmModule.automerge_updateSpans;\nexport const automerge_push = __vite__wasmModule.automerge_push;\nexport const automerge_pushObject = __vite__wasmModule.automerge_pushObject;\nexport const automerge_insert = __vite__wasmModule.automerge_insert;\nexport const automerge_splitBlock = __vite__wasmModule.automerge_splitBlock;\nexport const automerge_joinBlock = __vite__wasmModule.automerge_joinBlock;\nexport const automerge_updateBlock = __vite__wasmModule.automerge_updateBlock;\nexport const automerge_getBlock = __vite__wasmModule.automerge_getBlock;\nexport const automerge_insertObject = __vite__wasmModule.automerge_insertObject;\nexport const automerge_put = __vite__wasmModule.automerge_put;\nexport const automerge_putObject = __vite__wasmModule.automerge_putObject;\nexport const automerge_increment = __vite__wasmModule.automerge_increment;\nexport const automerge_get = __vite__wasmModule.automerge_get;\nexport const automerge_getWithType = __vite__wasmModule.automerge_getWithType;\nexport const automerge_objInfo = __vite__wasmModule.automerge_objInfo;\nexport const automerge_getAll = __vite__wasmModule.automerge_getAll;\nexport const automerge_enableFreeze = __vite__wasmModule.automerge_enableFreeze;\nexport const automerge_registerDatatype = __vite__wasmModule.automerge_registerDatatype;\nexport const automerge_applyPatches = __vite__wasmModule.automerge_applyPatches;\nexport const automerge_applyAndReturnPatches = __vite__wasmModule.automerge_applyAndReturnPatches;\nexport const automerge_diffIncremental = __vite__wasmModule.automerge_diffIncremental;\nexport const automerge_updateDiffCursor = __vite__wasmModule.automerge_updateDiffCursor;\nexport const automerge_resetDiffCursor = __vite__wasmModule.automerge_resetDiffCursor;\nexport const automerge_diff = __vite__wasmModule.automerge_diff;\nexport const automerge_isolate = __vite__wasmModule.automerge_isolate;\nexport const automerge_integrate = __vite__wasmModule.automerge_integrate;\nexport const automerge_length = __vite__wasmModule.automerge_length;\nexport const automerge_delete = __vite__wasmModule.automerge_delete;\nexport const automerge_save = __vite__wasmModule.automerge_save;\nexport const automerge_saveIncremental = __vite__wasmModule.automerge_saveIncremental;\nexport const automerge_saveSince = __vite__wasmModule.automerge_saveSince;\nexport const automerge_saveNoCompress = __vite__wasmModule.automerge_saveNoCompress;\nexport const automerge_saveAndVerify = __vite__wasmModule.automerge_saveAndVerify;\nexport const automerge_loadIncremental = __vite__wasmModule.automerge_loadIncremental;\nexport const automerge_applyChanges = __vite__wasmModule.automerge_applyChanges;\nexport const automerge_getChanges = __vite__wasmModule.automerge_getChanges;\nexport const automerge_getChangeByHash = __vite__wasmModule.automerge_getChangeByHash;\nexport const automerge_getDecodedChangeByHash = __vite__wasmModule.automerge_getDecodedChangeByHash;\nexport const automerge_getChangesAdded = __vite__wasmModule.automerge_getChangesAdded;\nexport const automerge_getHeads = __vite__wasmModule.automerge_getHeads;\nexport const automerge_getActorId = __vite__wasmModule.automerge_getActorId;\nexport const automerge_getLastLocalChange = __vite__wasmModule.automerge_getLastLocalChange;\nexport const automerge_dump = __vite__wasmModule.automerge_dump;\nexport const automerge_getMissingDeps = __vite__wasmModule.automerge_getMissingDeps;\nexport const automerge_receiveSyncMessage = __vite__wasmModule.automerge_receiveSyncMessage;\nexport const automerge_generateSyncMessage = __vite__wasmModule.automerge_generateSyncMessage;\nexport const automerge_toJS = __vite__wasmModule.automerge_toJS;\nexport const automerge_materialize = __vite__wasmModule.automerge_materialize;\nexport const automerge_getCursor = __vite__wasmModule.automerge_getCursor;\nexport const automerge_getCursorPosition = __vite__wasmModule.automerge_getCursorPosition;\nexport const automerge_emptyChange = __vite__wasmModule.automerge_emptyChange;\nexport const automerge_mark = __vite__wasmModule.automerge_mark;\nexport const automerge_unmark = __vite__wasmModule.automerge_unmark;\nexport const automerge_marks = __vite__wasmModule.automerge_marks;\nexport const automerge_marksAt = __vite__wasmModule.automerge_marksAt;\nexport const automerge_hasOurChanges = __vite__wasmModule.automerge_hasOurChanges;\nexport const automerge_topoHistoryTraversal = __vite__wasmModule.automerge_topoHistoryTraversal;\nexport const automerge_stats = __vite__wasmModule.automerge_stats;\nexport const create = __vite__wasmModule.create;\nexport const load = __vite__wasmModule.load;\nexport const encodeChange = __vite__wasmModule.encodeChange;\nexport const decodeChange = __vite__wasmModule.decodeChange;\nexport const initSyncState = __vite__wasmModule.initSyncState;\nexport const importSyncState = __vite__wasmModule.importSyncState;\nexport const exportSyncState = __vite__wasmModule.exportSyncState;\nexport const encodeSyncMessage = __vite__wasmModule.encodeSyncMessage;\nexport const decodeSyncMessage = __vite__wasmModule.decodeSyncMessage;\nexport const encodeSyncState = __vite__wasmModule.encodeSyncState;\nexport const decodeSyncState = __vite__wasmModule.decodeSyncState;\nexport const __wbindgen_malloc = __vite__wasmModule.__wbindgen_malloc;\nexport const __wbindgen_realloc = __vite__wasmModule.__wbindgen_realloc;\nexport const __wbindgen_add_to_stack_pointer = __vite__wasmModule.__wbindgen_add_to_stack_pointer;\nexport const __wbindgen_free = __vite__wasmModule.__wbindgen_free;\nexport const __wbindgen_exn_store = __vite__wasmModule.__wbindgen_exn_store;\n","import * as wasm from \"./automerge_wasm_bg.wasm\";\nimport { __wbg_set_wasm } from \"./automerge_wasm_bg.js\";\n__wbg_set_wasm(wasm);\nexport * from \"./automerge_wasm_bg.js\";\n","import { UseApi } from \"../low_level.js\";\nimport * as api from \"../wasm_bindgen_output/bundler/automerge_wasm.js\";\n//@ts-ignore\nUseApi(api);\nexport * from \"../stable.js\";\nimport * as next_1 from \"../next_slim.js\";\nexport { next_1 as next };\n","var adapters = {\n logger: typeof console !== \"undefined\" ? console : undefined,\n WebSocket: typeof WebSocket !== \"undefined\" ? WebSocket : undefined\n};\n\nvar logger = {\n log(...messages) {\n if (this.enabled) {\n messages.push(Date.now());\n adapters.logger.log(\"[ActionCable]\", ...messages);\n }\n }\n};\n\nconst now = () => (new Date).getTime();\n\nconst secondsSince = time => (now() - time) / 1e3;\n\nclass ConnectionMonitor {\n constructor(connection) {\n this.visibilityDidChange = this.visibilityDidChange.bind(this);\n this.connection = connection;\n this.reconnectAttempts = 0;\n }\n start() {\n if (!this.isRunning()) {\n this.startedAt = now();\n delete this.stoppedAt;\n this.startPolling();\n addEventListener(\"visibilitychange\", this.visibilityDidChange);\n logger.log(`ConnectionMonitor started. stale threshold = ${this.constructor.staleThreshold} s`);\n }\n }\n stop() {\n if (this.isRunning()) {\n this.stoppedAt = now();\n this.stopPolling();\n removeEventListener(\"visibilitychange\", this.visibilityDidChange);\n logger.log(\"ConnectionMonitor stopped\");\n }\n }\n isRunning() {\n return this.startedAt && !this.stoppedAt;\n }\n recordMessage() {\n this.pingedAt = now();\n }\n recordConnect() {\n this.reconnectAttempts = 0;\n delete this.disconnectedAt;\n logger.log(\"ConnectionMonitor recorded connect\");\n }\n recordDisconnect() {\n this.disconnectedAt = now();\n logger.log(\"ConnectionMonitor recorded disconnect\");\n }\n startPolling() {\n this.stopPolling();\n this.poll();\n }\n stopPolling() {\n clearTimeout(this.pollTimeout);\n }\n poll() {\n this.pollTimeout = setTimeout((() => {\n this.reconnectIfStale();\n this.poll();\n }), this.getPollInterval());\n }\n getPollInterval() {\n const {staleThreshold: staleThreshold, reconnectionBackoffRate: reconnectionBackoffRate} = this.constructor;\n const backoff = Math.pow(1 + reconnectionBackoffRate, Math.min(this.reconnectAttempts, 10));\n const jitterMax = this.reconnectAttempts === 0 ? 1 : reconnectionBackoffRate;\n const jitter = jitterMax * Math.random();\n return staleThreshold * 1e3 * backoff * (1 + jitter);\n }\n reconnectIfStale() {\n if (this.connectionIsStale()) {\n logger.log(`ConnectionMonitor detected stale connection. reconnectAttempts = ${this.reconnectAttempts}, time stale = ${secondsSince(this.refreshedAt)} s, stale threshold = ${this.constructor.staleThreshold} s`);\n this.reconnectAttempts++;\n if (this.disconnectedRecently()) {\n logger.log(`ConnectionMonitor skipping reopening recent disconnect. time disconnected = ${secondsSince(this.disconnectedAt)} s`);\n } else {\n logger.log(\"ConnectionMonitor reopening\");\n this.connection.reopen();\n }\n }\n }\n get refreshedAt() {\n return this.pingedAt ? this.pingedAt : this.startedAt;\n }\n connectionIsStale() {\n return secondsSince(this.refreshedAt) > this.constructor.staleThreshold;\n }\n disconnectedRecently() {\n return this.disconnectedAt && secondsSince(this.disconnectedAt) < this.constructor.staleThreshold;\n }\n visibilityDidChange() {\n if (document.visibilityState === \"visible\") {\n setTimeout((() => {\n if (this.connectionIsStale() || !this.connection.isOpen()) {\n logger.log(`ConnectionMonitor reopening stale connection on visibilitychange. visibilityState = ${document.visibilityState}`);\n this.connection.reopen();\n }\n }), 200);\n }\n }\n}\n\nConnectionMonitor.staleThreshold = 6;\n\nConnectionMonitor.reconnectionBackoffRate = .15;\n\nvar INTERNAL = {\n message_types: {\n welcome: \"welcome\",\n disconnect: \"disconnect\",\n ping: \"ping\",\n confirmation: \"confirm_subscription\",\n rejection: \"reject_subscription\"\n },\n disconnect_reasons: {\n unauthorized: \"unauthorized\",\n invalid_request: \"invalid_request\",\n server_restart: \"server_restart\",\n remote: \"remote\"\n },\n default_mount_path: \"/cable\",\n protocols: [ \"actioncable-v1-json\", \"actioncable-unsupported\" ]\n};\n\nconst {message_types: message_types, protocols: protocols} = INTERNAL;\n\nconst supportedProtocols = protocols.slice(0, protocols.length - 1);\n\nconst indexOf = [].indexOf;\n\nclass Connection {\n constructor(consumer) {\n this.open = this.open.bind(this);\n this.consumer = consumer;\n this.subscriptions = this.consumer.subscriptions;\n this.monitor = new ConnectionMonitor(this);\n this.disconnected = true;\n }\n send(data) {\n if (this.isOpen()) {\n this.webSocket.send(JSON.stringify(data));\n return true;\n } else {\n return false;\n }\n }\n open() {\n if (this.isActive()) {\n logger.log(`Attempted to open WebSocket, but existing socket is ${this.getState()}`);\n return false;\n } else {\n const socketProtocols = [ ...protocols, ...this.consumer.subprotocols || [] ];\n logger.log(`Opening WebSocket, current state is ${this.getState()}, subprotocols: ${socketProtocols}`);\n if (this.webSocket) {\n this.uninstallEventHandlers();\n }\n this.webSocket = new adapters.WebSocket(this.consumer.url, socketProtocols);\n this.installEventHandlers();\n this.monitor.start();\n return true;\n }\n }\n close({allowReconnect: allowReconnect} = {\n allowReconnect: true\n }) {\n if (!allowReconnect) {\n this.monitor.stop();\n }\n if (this.isOpen()) {\n return this.webSocket.close();\n }\n }\n reopen() {\n logger.log(`Reopening WebSocket, current state is ${this.getState()}`);\n if (this.isActive()) {\n try {\n return this.close();\n } catch (error) {\n logger.log(\"Failed to reopen WebSocket\", error);\n } finally {\n logger.log(`Reopening WebSocket in ${this.constructor.reopenDelay}ms`);\n setTimeout(this.open, this.constructor.reopenDelay);\n }\n } else {\n return this.open();\n }\n }\n getProtocol() {\n if (this.webSocket) {\n return this.webSocket.protocol;\n }\n }\n isOpen() {\n return this.isState(\"open\");\n }\n isActive() {\n return this.isState(\"open\", \"connecting\");\n }\n triedToReconnect() {\n return this.monitor.reconnectAttempts > 0;\n }\n isProtocolSupported() {\n return indexOf.call(supportedProtocols, this.getProtocol()) >= 0;\n }\n isState(...states) {\n return indexOf.call(states, this.getState()) >= 0;\n }\n getState() {\n if (this.webSocket) {\n for (let state in adapters.WebSocket) {\n if (adapters.WebSocket[state] === this.webSocket.readyState) {\n return state.toLowerCase();\n }\n }\n }\n return null;\n }\n installEventHandlers() {\n for (let eventName in this.events) {\n const handler = this.events[eventName].bind(this);\n this.webSocket[`on${eventName}`] = handler;\n }\n }\n uninstallEventHandlers() {\n for (let eventName in this.events) {\n this.webSocket[`on${eventName}`] = function() {};\n }\n }\n}\n\nConnection.reopenDelay = 500;\n\nConnection.prototype.events = {\n message(event) {\n if (!this.isProtocolSupported()) {\n return;\n }\n const {identifier: identifier, message: message, reason: reason, reconnect: reconnect, type: type} = JSON.parse(event.data);\n this.monitor.recordMessage();\n switch (type) {\n case message_types.welcome:\n if (this.triedToReconnect()) {\n this.reconnectAttempted = true;\n }\n this.monitor.recordConnect();\n return this.subscriptions.reload();\n\n case message_types.disconnect:\n logger.log(`Disconnecting. Reason: ${reason}`);\n return this.close({\n allowReconnect: reconnect\n });\n\n case message_types.ping:\n return null;\n\n case message_types.confirmation:\n this.subscriptions.confirmSubscription(identifier);\n if (this.reconnectAttempted) {\n this.reconnectAttempted = false;\n return this.subscriptions.notify(identifier, \"connected\", {\n reconnected: true\n });\n } else {\n return this.subscriptions.notify(identifier, \"connected\", {\n reconnected: false\n });\n }\n\n case message_types.rejection:\n return this.subscriptions.reject(identifier);\n\n default:\n return this.subscriptions.notify(identifier, \"received\", message);\n }\n },\n open() {\n logger.log(`WebSocket onopen event, using '${this.getProtocol()}' subprotocol`);\n this.disconnected = false;\n if (!this.isProtocolSupported()) {\n logger.log(\"Protocol is unsupported. Stopping monitor and disconnecting.\");\n return this.close({\n allowReconnect: false\n });\n }\n },\n close(event) {\n logger.log(\"WebSocket onclose event\");\n if (this.disconnected) {\n return;\n }\n this.disconnected = true;\n this.monitor.recordDisconnect();\n return this.subscriptions.notifyAll(\"disconnected\", {\n willAttemptReconnect: this.monitor.isRunning()\n });\n },\n error() {\n logger.log(\"WebSocket onerror event\");\n }\n};\n\nconst extend = function(object, properties) {\n if (properties != null) {\n for (let key in properties) {\n const value = properties[key];\n object[key] = value;\n }\n }\n return object;\n};\n\nclass Subscription {\n constructor(consumer, params = {}, mixin) {\n this.consumer = consumer;\n this.identifier = JSON.stringify(params);\n extend(this, mixin);\n }\n perform(action, data = {}) {\n data.action = action;\n return this.send(data);\n }\n send(data) {\n return this.consumer.send({\n command: \"message\",\n identifier: this.identifier,\n data: JSON.stringify(data)\n });\n }\n unsubscribe() {\n return this.consumer.subscriptions.remove(this);\n }\n}\n\nclass SubscriptionGuarantor {\n constructor(subscriptions) {\n this.subscriptions = subscriptions;\n this.pendingSubscriptions = [];\n }\n guarantee(subscription) {\n if (this.pendingSubscriptions.indexOf(subscription) == -1) {\n logger.log(`SubscriptionGuarantor guaranteeing ${subscription.identifier}`);\n this.pendingSubscriptions.push(subscription);\n } else {\n logger.log(`SubscriptionGuarantor already guaranteeing ${subscription.identifier}`);\n }\n this.startGuaranteeing();\n }\n forget(subscription) {\n logger.log(`SubscriptionGuarantor forgetting ${subscription.identifier}`);\n this.pendingSubscriptions = this.pendingSubscriptions.filter((s => s !== subscription));\n }\n startGuaranteeing() {\n this.stopGuaranteeing();\n this.retrySubscribing();\n }\n stopGuaranteeing() {\n clearTimeout(this.retryTimeout);\n }\n retrySubscribing() {\n this.retryTimeout = setTimeout((() => {\n if (this.subscriptions && typeof this.subscriptions.subscribe === \"function\") {\n this.pendingSubscriptions.map((subscription => {\n logger.log(`SubscriptionGuarantor resubscribing ${subscription.identifier}`);\n this.subscriptions.subscribe(subscription);\n }));\n }\n }), 500);\n }\n}\n\nclass Subscriptions {\n constructor(consumer) {\n this.consumer = consumer;\n this.guarantor = new SubscriptionGuarantor(this);\n this.subscriptions = [];\n }\n create(channelName, mixin) {\n const channel = channelName;\n const params = typeof channel === \"object\" ? channel : {\n channel: channel\n };\n const subscription = new Subscription(this.consumer, params, mixin);\n return this.add(subscription);\n }\n add(subscription) {\n this.subscriptions.push(subscription);\n this.consumer.ensureActiveConnection();\n this.notify(subscription, \"initialized\");\n this.subscribe(subscription);\n return subscription;\n }\n remove(subscription) {\n this.forget(subscription);\n if (!this.findAll(subscription.identifier).length) {\n this.sendCommand(subscription, \"unsubscribe\");\n }\n return subscription;\n }\n reject(identifier) {\n return this.findAll(identifier).map((subscription => {\n this.forget(subscription);\n this.notify(subscription, \"rejected\");\n return subscription;\n }));\n }\n forget(subscription) {\n this.guarantor.forget(subscription);\n this.subscriptions = this.subscriptions.filter((s => s !== subscription));\n return subscription;\n }\n findAll(identifier) {\n return this.subscriptions.filter((s => s.identifier === identifier));\n }\n reload() {\n return this.subscriptions.map((subscription => this.subscribe(subscription)));\n }\n notifyAll(callbackName, ...args) {\n return this.subscriptions.map((subscription => this.notify(subscription, callbackName, ...args)));\n }\n notify(subscription, callbackName, ...args) {\n let subscriptions;\n if (typeof subscription === \"string\") {\n subscriptions = this.findAll(subscription);\n } else {\n subscriptions = [ subscription ];\n }\n return subscriptions.map((subscription => typeof subscription[callbackName] === \"function\" ? subscription[callbackName](...args) : undefined));\n }\n subscribe(subscription) {\n if (this.sendCommand(subscription, \"subscribe\")) {\n this.guarantor.guarantee(subscription);\n }\n }\n confirmSubscription(identifier) {\n logger.log(`Subscription confirmed ${identifier}`);\n this.findAll(identifier).map((subscription => this.guarantor.forget(subscription)));\n }\n sendCommand(subscription, command) {\n const {identifier: identifier} = subscription;\n return this.consumer.send({\n command: command,\n identifier: identifier\n });\n }\n}\n\nclass Consumer {\n constructor(url) {\n this._url = url;\n this.subscriptions = new Subscriptions(this);\n this.connection = new Connection(this);\n this.subprotocols = [];\n }\n get url() {\n return createWebSocketURL(this._url);\n }\n send(data) {\n return this.connection.send(data);\n }\n connect() {\n return this.connection.open();\n }\n disconnect() {\n return this.connection.close({\n allowReconnect: false\n });\n }\n ensureActiveConnection() {\n if (!this.connection.isActive()) {\n return this.connection.open();\n }\n }\n addSubProtocol(subprotocol) {\n this.subprotocols = [ ...this.subprotocols, subprotocol ];\n }\n}\n\nfunction createWebSocketURL(url) {\n if (typeof url === \"function\") {\n url = url();\n }\n if (url && !/^wss?:/i.test(url)) {\n const a = document.createElement(\"a\");\n a.href = url;\n a.href = a.href;\n a.protocol = a.protocol.replace(\"http\", \"ws\");\n return a.href;\n } else {\n return url;\n }\n}\n\nfunction createConsumer(url = getConfig(\"url\") || INTERNAL.default_mount_path) {\n return new Consumer(url);\n}\n\nfunction getConfig(name) {\n const element = document.head.querySelector(`meta[name='action-cable-${name}']`);\n if (element) {\n return element.getAttribute(\"content\");\n }\n}\n\nexport { Connection, ConnectionMonitor, Consumer, INTERNAL, Subscription, SubscriptionGuarantor, Subscriptions, adapters, createConsumer, createWebSocketURL, getConfig, logger };\n","/**\n * lodash (Custom Build) <https://lodash.com/>\n * Build: `lodash modularize exports=\"npm\" -o ./`\n * Copyright jQuery Foundation and other contributors <https://jquery.org/>\n * Released under MIT license <https://lodash.com/license>\n * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>\n * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n */\n\n/** Used as the size to enable large array optimizations. */\nvar LARGE_ARRAY_SIZE = 200;\n\n/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/** Used as references for various `Number` constants. */\nvar INFINITY = 1 / 0,\n MAX_SAFE_INTEGER = 9007199254740991;\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]',\n funcTag = '[object Function]',\n genTag = '[object GeneratorFunction]',\n symbolTag = '[object Symbol]';\n\n/**\n * Used to match `RegExp`\n * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).\n */\nvar reRegExpChar = /[\\\\^$.*+?()[\\]{}|]/g;\n\n/** Used to detect host constructors (Safari). */\nvar reIsHostCtor = /^\\[object .+?Constructor\\]$/;\n\n/** Used to detect unsigned integer values. */\nvar reIsUint = /^(?:0|[1-9]\\d*)$/;\n\n/** Detect free variable `global` from Node.js. */\nvar freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\n/**\n * A faster alternative to `Function#apply`, this function invokes `func`\n * with the `this` binding of `thisArg` and the arguments of `args`.\n *\n * @private\n * @param {Function} func The function to invoke.\n * @param {*} thisArg The `this` binding of `func`.\n * @param {Array} args The arguments to invoke `func` with.\n * @returns {*} Returns the result of `func`.\n */\nfunction apply(func, thisArg, args) {\n switch (args.length) {\n case 0: return func.call(thisArg);\n case 1: return func.call(thisArg, args[0]);\n case 2: return func.call(thisArg, args[0], args[1]);\n case 3: return func.call(thisArg, args[0], args[1], args[2]);\n }\n return func.apply(thisArg, args);\n}\n\n/**\n * A specialized version of `_.includes` for arrays without support for\n * specifying an index to search from.\n *\n * @private\n * @param {Array} [array] The array to inspect.\n * @param {*} target The value to search for.\n * @returns {boolean} Returns `true` if `target` is found, else `false`.\n */\nfunction arrayIncludes(array, value) {\n var length = array ? array.length : 0;\n return !!length && baseIndexOf(array, value, 0) > -1;\n}\n\n/**\n * This function is like `arrayIncludes` except that it accepts a comparator.\n *\n * @private\n * @param {Array} [array] The array to inspect.\n * @param {*} target The value to search for.\n * @param {Function} comparator The comparator invoked per element.\n * @returns {boolean} Returns `true` if `target` is found, else `false`.\n */\nfunction arrayIncludesWith(array, value, comparator) {\n var index = -1,\n length = array ? array.length : 0;\n\n while (++index < length) {\n if (comparator(value, array[index])) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * A specialized version of `_.map` for arrays without support for iteratee\n * shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the new mapped array.\n */\nfunction arrayMap(array, iteratee) {\n var index = -1,\n length = array ? array.length : 0,\n result = Array(length);\n\n while (++index < length) {\n result[index] = iteratee(array[index], index, array);\n }\n return result;\n}\n\n/**\n * Appends the elements of `values` to `array`.\n *\n * @private\n * @param {Array} array The array to modify.\n * @param {Array} values The values to append.\n * @returns {Array} Returns `array`.\n */\nfunction arrayPush(array, values) {\n var index = -1,\n length = values.length,\n offset = array.length;\n\n while (++index < length) {\n array[offset + index] = values[index];\n }\n return array;\n}\n\n/**\n * The base implementation of `_.findIndex` and `_.findLastIndex` without\n * support for iteratee shorthands.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {Function} predicate The function invoked per iteration.\n * @param {number} fromIndex The index to search from.\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\nfunction baseFindIndex(array, predicate, fromIndex, fromRight) {\n var length = array.length,\n index = fromIndex + (fromRight ? 1 : -1);\n\n while ((fromRight ? index-- : ++index < length)) {\n if (predicate(array[index], index, array)) {\n return index;\n }\n }\n return -1;\n}\n\n/**\n * The base implementation of `_.indexOf` without `fromIndex` bounds checks.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} value The value to search for.\n * @param {number} fromIndex The index to search from.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\nfunction baseIndexOf(array, value, fromIndex) {\n if (value !== value) {\n return baseFindIndex(array, baseIsNaN, fromIndex);\n }\n var index = fromIndex - 1,\n length = array.length;\n\n while (++index < length) {\n if (array[index] === value) {\n return index;\n }\n }\n return -1;\n}\n\n/**\n * The base implementation of `_.isNaN` without support for number objects.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.\n */\nfunction baseIsNaN(value) {\n return value !== value;\n}\n\n/**\n * The base implementation of `_.times` without support for iteratee shorthands\n * or max array length checks.\n *\n * @private\n * @param {number} n The number of times to invoke `iteratee`.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the array of results.\n */\nfunction baseTimes(n, iteratee) {\n var index = -1,\n result = Array(n);\n\n while (++index < n) {\n result[index] = iteratee(index);\n }\n return result;\n}\n\n/**\n * The base implementation of `_.unary` without support for storing metadata.\n *\n * @private\n * @param {Function} func The function to cap arguments for.\n * @returns {Function} Returns the new capped function.\n */\nfunction baseUnary(func) {\n return function(value) {\n return func(value);\n };\n}\n\n/**\n * Checks if a cache value for `key` exists.\n *\n * @private\n * @param {Object} cache The cache to query.\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction cacheHas(cache, key) {\n return cache.has(key);\n}\n\n/**\n * Gets the value at `key` of `object`.\n *\n * @private\n * @param {Object} [object] The object to query.\n * @param {string} key The key of the property to get.\n * @returns {*} Returns the property value.\n */\nfunction getValue(object, key) {\n return object == null ? undefined : object[key];\n}\n\n/**\n * Checks if `value` is a host object in IE < 9.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a host object, else `false`.\n */\nfunction isHostObject(value) {\n // Many host objects are `Object` objects that can coerce to strings\n // despite having improperly defined `toString` methods.\n var result = false;\n if (value != null && typeof value.toString != 'function') {\n try {\n result = !!(value + '');\n } catch (e) {}\n }\n return result;\n}\n\n/**\n * Creates a unary function that invokes `func` with its argument transformed.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {Function} transform The argument transform.\n * @returns {Function} Returns the new function.\n */\nfunction overArg(func, transform) {\n return function(arg) {\n return func(transform(arg));\n };\n}\n\n/** Used for built-in method references. */\nvar arrayProto = Array.prototype,\n funcProto = Function.prototype,\n objectProto = Object.prototype;\n\n/** Used to detect overreaching core-js shims. */\nvar coreJsData = root['__core-js_shared__'];\n\n/** Used to detect methods masquerading as native. */\nvar maskSrcKey = (function() {\n var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');\n return uid ? ('Symbol(src)_1.' + uid) : '';\n}());\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar objectToString = objectProto.toString;\n\n/** Used to detect if a method is native. */\nvar reIsNative = RegExp('^' +\n funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\\\$&')\n .replace(/hasOwnProperty|(function).*?(?=\\\\\\()| for .+?(?=\\\\\\])/g, '$1.*?') + '$'\n);\n\n/** Built-in value references. */\nvar Symbol = root.Symbol,\n getPrototype = overArg(Object.getPrototypeOf, Object),\n propertyIsEnumerable = objectProto.propertyIsEnumerable,\n splice = arrayProto.splice,\n spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeGetSymbols = Object.getOwnPropertySymbols,\n nativeMax = Math.max;\n\n/* Built-in method references that are verified to be native. */\nvar Map = getNative(root, 'Map'),\n nativeCreate = getNative(Object, 'create');\n\n/**\n * Creates a hash object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction Hash(entries) {\n var index = -1,\n length = entries ? entries.length : 0;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n/**\n * Removes all key-value entries from the hash.\n *\n * @private\n * @name clear\n * @memberOf Hash\n */\nfunction hashClear() {\n this.__data__ = nativeCreate ? nativeCreate(null) : {};\n}\n\n/**\n * Removes `key` and its value from the hash.\n *\n * @private\n * @name delete\n * @memberOf Hash\n * @param {Object} hash The hash to modify.\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction hashDelete(key) {\n return this.has(key) && delete this.__data__[key];\n}\n\n/**\n * Gets the hash value for `key`.\n *\n * @private\n * @name get\n * @memberOf Hash\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction hashGet(key) {\n var data = this.__data__;\n if (nativeCreate) {\n var result = data[key];\n return result === HASH_UNDEFINED ? undefined : result;\n }\n return hasOwnProperty.call(data, key) ? data[key] : undefined;\n}\n\n/**\n * Checks if a hash value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Hash\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction hashHas(key) {\n var data = this.__data__;\n return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);\n}\n\n/**\n * Sets the hash `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Hash\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the hash instance.\n */\nfunction hashSet(key, value) {\n var data = this.__data__;\n data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;\n return this;\n}\n\n// Add methods to `Hash`.\nHash.prototype.clear = hashClear;\nHash.prototype['delete'] = hashDelete;\nHash.prototype.get = hashGet;\nHash.prototype.has = hashHas;\nHash.prototype.set = hashSet;\n\n/**\n * Creates an list cache object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction ListCache(entries) {\n var index = -1,\n length = entries ? entries.length : 0;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n/**\n * Removes all key-value entries from the list cache.\n *\n * @private\n * @name clear\n * @memberOf ListCache\n */\nfunction listCacheClear() {\n this.__data__ = [];\n}\n\n/**\n * Removes `key` and its value from the list cache.\n *\n * @private\n * @name delete\n * @memberOf ListCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction listCacheDelete(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n return false;\n }\n var lastIndex = data.length - 1;\n if (index == lastIndex) {\n data.pop();\n } else {\n splice.call(data, index, 1);\n }\n return true;\n}\n\n/**\n * Gets the list cache value for `key`.\n *\n * @private\n * @name get\n * @memberOf ListCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction listCacheGet(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n return index < 0 ? undefined : data[index][1];\n}\n\n/**\n * Checks if a list cache value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf ListCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction listCacheHas(key) {\n return assocIndexOf(this.__data__, key) > -1;\n}\n\n/**\n * Sets the list cache `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf ListCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the list cache instance.\n */\nfunction listCacheSet(key, value) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n data.push([key, value]);\n } else {\n data[index][1] = value;\n }\n return this;\n}\n\n// Add methods to `ListCache`.\nListCache.prototype.clear = listCacheClear;\nListCache.prototype['delete'] = listCacheDelete;\nListCache.prototype.get = listCacheGet;\nListCache.prototype.has = listCacheHas;\nListCache.prototype.set = listCacheSet;\n\n/**\n * Creates a map cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction MapCache(entries) {\n var index = -1,\n length = entries ? entries.length : 0;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n/**\n * Removes all key-value entries from the map.\n *\n * @private\n * @name clear\n * @memberOf MapCache\n */\nfunction mapCacheClear() {\n this.__data__ = {\n 'hash': new Hash,\n 'map': new (Map || ListCache),\n 'string': new Hash\n };\n}\n\n/**\n * Removes `key` and its value from the map.\n *\n * @private\n * @name delete\n * @memberOf MapCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction mapCacheDelete(key) {\n return getMapData(this, key)['delete'](key);\n}\n\n/**\n * Gets the map value for `key`.\n *\n * @private\n * @name get\n * @memberOf MapCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction mapCacheGet(key) {\n return getMapData(this, key).get(key);\n}\n\n/**\n * Checks if a map value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf MapCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction mapCacheHas(key) {\n return getMapData(this, key).has(key);\n}\n\n/**\n * Sets the map `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf MapCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the map cache instance.\n */\nfunction mapCacheSet(key, value) {\n getMapData(this, key).set(key, value);\n return this;\n}\n\n// Add methods to `MapCache`.\nMapCache.prototype.clear = mapCacheClear;\nMapCache.prototype['delete'] = mapCacheDelete;\nMapCache.prototype.get = mapCacheGet;\nMapCache.prototype.has = mapCacheHas;\nMapCache.prototype.set = mapCacheSet;\n\n/**\n *\n * Creates an array cache object to store unique values.\n *\n * @private\n * @constructor\n * @param {Array} [values] The values to cache.\n */\nfunction SetCache(values) {\n var index = -1,\n length = values ? values.length : 0;\n\n this.__data__ = new MapCache;\n while (++index < length) {\n this.add(values[index]);\n }\n}\n\n/**\n * Adds `value` to the array cache.\n *\n * @private\n * @name add\n * @memberOf SetCache\n * @alias push\n * @param {*} value The value to cache.\n * @returns {Object} Returns the cache instance.\n */\nfunction setCacheAdd(value) {\n this.__data__.set(value, HASH_UNDEFINED);\n return this;\n}\n\n/**\n * Checks if `value` is in the array cache.\n *\n * @private\n * @name has\n * @memberOf SetCache\n * @param {*} value The value to search for.\n * @returns {number} Returns `true` if `value` is found, else `false`.\n */\nfunction setCacheHas(value) {\n return this.__data__.has(value);\n}\n\n// Add methods to `SetCache`.\nSetCache.prototype.add = SetCache.prototype.push = setCacheAdd;\nSetCache.prototype.has = setCacheHas;\n\n/**\n * Creates an array of the enumerable property names of the array-like `value`.\n *\n * @private\n * @param {*} value The value to query.\n * @param {boolean} inherited Specify returning inherited property names.\n * @returns {Array} Returns the array of property names.\n */\nfunction arrayLikeKeys(value, inherited) {\n // Safari 8.1 makes `arguments.callee` enumerable in strict mode.\n // Safari 9 makes `arguments.length` enumerable in strict mode.\n var result = (isArray(value) || isArguments(value))\n ? baseTimes(value.length, String)\n : [];\n\n var length = result.length,\n skipIndexes = !!length;\n\n for (var key in value) {\n if ((inherited || hasOwnProperty.call(value, key)) &&\n !(skipIndexes && (key == 'length' || isIndex(key, length)))) {\n result.push(key);\n }\n }\n return result;\n}\n\n/**\n * Gets the index at which the `key` is found in `array` of key-value pairs.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} key The key to search for.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\nfunction assocIndexOf(array, key) {\n var length = array.length;\n while (length--) {\n if (eq(array[length][0], key)) {\n return length;\n }\n }\n return -1;\n}\n\n/**\n * The base implementation of methods like `_.difference` without support\n * for excluding multiple arrays or iteratee shorthands.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {Array} values The values to exclude.\n * @param {Function} [iteratee] The iteratee invoked per element.\n * @param {Function} [comparator] The comparator invoked per element.\n * @returns {Array} Returns the new array of filtered values.\n */\nfunction baseDifference(array, values, iteratee, comparator) {\n var index = -1,\n includes = arrayIncludes,\n isCommon = true,\n length = array.length,\n result = [],\n valuesLength = values.length;\n\n if (!length) {\n return result;\n }\n if (iteratee) {\n values = arrayMap(values, baseUnary(iteratee));\n }\n if (comparator) {\n includes = arrayIncludesWith;\n isCommon = false;\n }\n else if (values.length >= LARGE_ARRAY_SIZE) {\n includes = cacheHas;\n isCommon = false;\n values = new SetCache(values);\n }\n outer:\n while (++index < length) {\n var value = array[index],\n computed = iteratee ? iteratee(value) : value;\n\n value = (comparator || value !== 0) ? value : 0;\n if (isCommon && computed === computed) {\n var valuesIndex = valuesLength;\n while (valuesIndex--) {\n if (values[valuesIndex] === computed) {\n continue outer;\n }\n }\n result.push(value);\n }\n else if (!includes(values, computed, comparator)) {\n result.push(value);\n }\n }\n return result;\n}\n\n/**\n * The base implementation of `_.flatten` with support for restricting flattening.\n *\n * @private\n * @param {Array} array The array to flatten.\n * @param {number} depth The maximum recursion depth.\n * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.\n * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.\n * @param {Array} [result=[]] The initial result value.\n * @returns {Array} Returns the new flattened array.\n */\nfunction baseFlatten(array, depth, predicate, isStrict, result) {\n var index = -1,\n length = array.length;\n\n predicate || (predicate = isFlattenable);\n result || (result = []);\n\n while (++index < length) {\n var value = array[index];\n if (depth > 0 && predicate(value)) {\n if (depth > 1) {\n // Recursively flatten arrays (susceptible to call stack limits).\n baseFlatten(value, depth - 1, predicate, isStrict, result);\n } else {\n arrayPush(result, value);\n }\n } else if (!isStrict) {\n result[result.length] = value;\n }\n }\n return result;\n}\n\n/**\n * The base implementation of `getAllKeys` and `getAllKeysIn` which uses\n * `keysFunc` and `symbolsFunc` to get the enumerable property names and\n * symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Function} keysFunc The function to get the keys of `object`.\n * @param {Function} symbolsFunc The function to get the symbols of `object`.\n * @returns {Array} Returns the array of property names and symbols.\n */\nfunction baseGetAllKeys(object, keysFunc, symbolsFunc) {\n var result = keysFunc(object);\n return isArray(object) ? result : arrayPush(result, symbolsFunc(object));\n}\n\n/**\n * The base implementation of `_.isNative` without bad shim checks.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a native function,\n * else `false`.\n */\nfunction baseIsNative(value) {\n if (!isObject(value) || isMasked(value)) {\n return false;\n }\n var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;\n return pattern.test(toSource(value));\n}\n\n/**\n * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\nfunction baseKeysIn(object) {\n if (!isObject(object)) {\n return nativeKeysIn(object);\n }\n var isProto = isPrototype(object),\n result = [];\n\n for (var key in object) {\n if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {\n result.push(key);\n }\n }\n return result;\n}\n\n/**\n * The base implementation of `_.pick` without support for individual\n * property identifiers.\n *\n * @private\n * @param {Object} object The source object.\n * @param {string[]} props The property identifiers to pick.\n * @returns {Object} Returns the new object.\n */\nfunction basePick(object, props) {\n object = Object(object);\n return basePickBy(object, props, function(value, key) {\n return key in object;\n });\n}\n\n/**\n * The base implementation of `_.pickBy` without support for iteratee shorthands.\n *\n * @private\n * @param {Object} object The source object.\n * @param {string[]} props The property identifiers to pick from.\n * @param {Function} predicate The function invoked per property.\n * @returns {Object} Returns the new object.\n */\nfunction basePickBy(object, props, predicate) {\n var index = -1,\n length = props.length,\n result = {};\n\n while (++index < length) {\n var key = props[index],\n value = object[key];\n\n if (predicate(value, key)) {\n result[key] = value;\n }\n }\n return result;\n}\n\n/**\n * The base implementation of `_.rest` which doesn't validate or coerce arguments.\n *\n * @private\n * @param {Function} func The function to apply a rest parameter to.\n * @param {number} [start=func.length-1] The start position of the rest parameter.\n * @returns {Function} Returns the new function.\n */\nfunction baseRest(func, start) {\n start = nativeMax(start === undefined ? (func.length - 1) : start, 0);\n return function() {\n var args = arguments,\n index = -1,\n length = nativeMax(args.length - start, 0),\n array = Array(length);\n\n while (++index < length) {\n array[index] = args[start + index];\n }\n index = -1;\n var otherArgs = Array(start + 1);\n while (++index < start) {\n otherArgs[index] = args[index];\n }\n otherArgs[start] = array;\n return apply(func, this, otherArgs);\n };\n}\n\n/**\n * Creates an array of own and inherited enumerable property names and\n * symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names and symbols.\n */\nfunction getAllKeysIn(object) {\n return baseGetAllKeys(object, keysIn, getSymbolsIn);\n}\n\n/**\n * Gets the data for `map`.\n *\n * @private\n * @param {Object} map The map to query.\n * @param {string} key The reference key.\n * @returns {*} Returns the map data.\n */\nfunction getMapData(map, key) {\n var data = map.__data__;\n return isKeyable(key)\n ? data[typeof key == 'string' ? 'string' : 'hash']\n : data.map;\n}\n\n/**\n * Gets the native function at `key` of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {string} key The key of the method to get.\n * @returns {*} Returns the function if it's native, else `undefined`.\n */\nfunction getNative(object, key) {\n var value = getValue(object, key);\n return baseIsNative(value) ? value : undefined;\n}\n\n/**\n * Creates an array of the own enumerable symbol properties of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of symbols.\n */\nvar getSymbols = nativeGetSymbols ? overArg(nativeGetSymbols, Object) : stubArray;\n\n/**\n * Creates an array of the own and inherited enumerable symbol properties\n * of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of symbols.\n */\nvar getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {\n var result = [];\n while (object) {\n arrayPush(result, getSymbols(object));\n object = getPrototype(object);\n }\n return result;\n};\n\n/**\n * Checks if `value` is a flattenable `arguments` object or array.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.\n */\nfunction isFlattenable(value) {\n return isArray(value) || isArguments(value) ||\n !!(spreadableSymbol && value && value[spreadableSymbol]);\n}\n\n/**\n * Checks if `value` is a valid array-like index.\n *\n * @private\n * @param {*} value The value to check.\n * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.\n * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.\n */\nfunction isIndex(value, length) {\n length = length == null ? MAX_SAFE_INTEGER : length;\n return !!length &&\n (typeof value == 'number' || reIsUint.test(value)) &&\n (value > -1 && value % 1 == 0 && value < length);\n}\n\n/**\n * Checks if `value` is suitable for use as unique object key.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is suitable, else `false`.\n */\nfunction isKeyable(value) {\n var type = typeof value;\n return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')\n ? (value !== '__proto__')\n : (value === null);\n}\n\n/**\n * Checks if `func` has its source masked.\n *\n * @private\n * @param {Function} func The function to check.\n * @returns {boolean} Returns `true` if `func` is masked, else `false`.\n */\nfunction isMasked(func) {\n return !!maskSrcKey && (maskSrcKey in func);\n}\n\n/**\n * Checks if `value` is likely a prototype object.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.\n */\nfunction isPrototype(value) {\n var Ctor = value && value.constructor,\n proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;\n\n return value === proto;\n}\n\n/**\n * This function is like\n * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)\n * except that it includes inherited enumerable properties.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\nfunction nativeKeysIn(object) {\n var result = [];\n if (object != null) {\n for (var key in Object(object)) {\n result.push(key);\n }\n }\n return result;\n}\n\n/**\n * Converts `value` to a string key if it's not a string or symbol.\n *\n * @private\n * @param {*} value The value to inspect.\n * @returns {string|symbol} Returns the key.\n */\nfunction toKey(value) {\n if (typeof value == 'string' || isSymbol(value)) {\n return value;\n }\n var result = (value + '');\n return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;\n}\n\n/**\n * Converts `func` to its source code.\n *\n * @private\n * @param {Function} func The function to process.\n * @returns {string} Returns the source code.\n */\nfunction toSource(func) {\n if (func != null) {\n try {\n return funcToString.call(func);\n } catch (e) {}\n try {\n return (func + '');\n } catch (e) {}\n }\n return '';\n}\n\n/**\n * Performs a\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * comparison between two values to determine if they are equivalent.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.eq(object, object);\n * // => true\n *\n * _.eq(object, other);\n * // => false\n *\n * _.eq('a', 'a');\n * // => true\n *\n * _.eq('a', Object('a'));\n * // => false\n *\n * _.eq(NaN, NaN);\n * // => true\n */\nfunction eq(value, other) {\n return value === other || (value !== value && other !== other);\n}\n\n/**\n * Checks if `value` is likely an `arguments` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n * else `false`.\n * @example\n *\n * _.isArguments(function() { return arguments; }());\n * // => true\n *\n * _.isArguments([1, 2, 3]);\n * // => false\n */\nfunction isArguments(value) {\n // Safari 8.1 makes `arguments.callee` enumerable in strict mode.\n return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&\n (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);\n}\n\n/**\n * Checks if `value` is classified as an `Array` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array, else `false`.\n * @example\n *\n * _.isArray([1, 2, 3]);\n * // => true\n *\n * _.isArray(document.body.children);\n * // => false\n *\n * _.isArray('abc');\n * // => false\n *\n * _.isArray(_.noop);\n * // => false\n */\nvar isArray = Array.isArray;\n\n/**\n * Checks if `value` is array-like. A value is considered array-like if it's\n * not a function and has a `value.length` that's an integer greater than or\n * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is array-like, else `false`.\n * @example\n *\n * _.isArrayLike([1, 2, 3]);\n * // => true\n *\n * _.isArrayLike(document.body.children);\n * // => true\n *\n * _.isArrayLike('abc');\n * // => true\n *\n * _.isArrayLike(_.noop);\n * // => false\n */\nfunction isArrayLike(value) {\n return value != null && isLength(value.length) && !isFunction(value);\n}\n\n/**\n * This method is like `_.isArrayLike` except that it also checks if `value`\n * is an object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array-like object,\n * else `false`.\n * @example\n *\n * _.isArrayLikeObject([1, 2, 3]);\n * // => true\n *\n * _.isArrayLikeObject(document.body.children);\n * // => true\n *\n * _.isArrayLikeObject('abc');\n * // => false\n *\n * _.isArrayLikeObject(_.noop);\n * // => false\n */\nfunction isArrayLikeObject(value) {\n return isObjectLike(value) && isArrayLike(value);\n}\n\n/**\n * Checks if `value` is classified as a `Function` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n * @example\n *\n * _.isFunction(_);\n * // => true\n *\n * _.isFunction(/abc/);\n * // => false\n */\nfunction isFunction(value) {\n // The use of `Object#toString` avoids issues with the `typeof` operator\n // in Safari 8-9 which returns 'object' for typed array and other constructors.\n var tag = isObject(value) ? objectToString.call(value) : '';\n return tag == funcTag || tag == genTag;\n}\n\n/**\n * Checks if `value` is a valid array-like length.\n *\n * **Note:** This method is loosely based on\n * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.\n * @example\n *\n * _.isLength(3);\n * // => true\n *\n * _.isLength(Number.MIN_VALUE);\n * // => false\n *\n * _.isLength(Infinity);\n * // => false\n *\n * _.isLength('3');\n * // => false\n */\nfunction isLength(value) {\n return typeof value == 'number' &&\n value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;\n}\n\n/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return !!value && (type == 'object' || type == 'function');\n}\n\n/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return !!value && typeof value == 'object';\n}\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\nfunction isSymbol(value) {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && objectToString.call(value) == symbolTag);\n}\n\n/**\n * Creates an array of the own and inherited enumerable property names of `object`.\n *\n * **Note:** Non-object values are coerced to objects.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.keysIn(new Foo);\n * // => ['a', 'b', 'c'] (iteration order is not guaranteed)\n */\nfunction keysIn(object) {\n return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);\n}\n\n/**\n * The opposite of `_.pick`; this method creates an object composed of the\n * own and inherited enumerable string keyed properties of `object` that are\n * not omitted.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The source object.\n * @param {...(string|string[])} [props] The property identifiers to omit.\n * @returns {Object} Returns the new object.\n * @example\n *\n * var object = { 'a': 1, 'b': '2', 'c': 3 };\n *\n * _.omit(object, ['a', 'c']);\n * // => { 'b': '2' }\n */\nvar omit = baseRest(function(object, props) {\n if (object == null) {\n return {};\n }\n props = arrayMap(baseFlatten(props, 1), toKey);\n return basePick(object, baseDifference(getAllKeysIn(object), props));\n});\n\n/**\n * This method returns a new empty array.\n *\n * @static\n * @memberOf _\n * @since 4.13.0\n * @category Util\n * @returns {Array} Returns the new empty array.\n * @example\n *\n * var arrays = _.times(2, _.stubArray);\n *\n * console.log(arrays);\n * // => [[], []]\n *\n * console.log(arrays[0] === arrays[1]);\n * // => false\n */\nfunction stubArray() {\n return [];\n}\n\nmodule.exports = omit;\n","import { createConsumer, Consumer, Subscription } from \"@rails/actioncable\"\nimport { NetworkAdapter, PeerId, PeerMetadata, Message, cbor } from \"@automerge/automerge-repo/slim\"\nimport omit from \"lodash.omit\"\n\nclass ActionCableNetworkAdapter extends NetworkAdapter {\n\tchannelName: string\n\tconsumer: Consumer\n\t#isReady: boolean\n\tsubscription?: Subscription\n\tsyncableType: string\n\tsyncableId: any\n\tconstructor(channelName: string, syncableType: string, syncableId: any, serverUrl?: string) {\n\t\tsuper()\n\t\tthis.channelName = channelName\n\t\tthis.syncableType = syncableType\n\t\tthis.syncableId = syncableId\n\t\tthis.consumer = createConsumer(serverUrl)\n\t\tthis.#isReady = false\n\t}\n\n\tconnect(peerId: PeerId, peerMetadata?: PeerMetadata) {\n\t\tthis.peerId = peerId\n\t\tthis.peerMetadata = peerMetadata\n\n\t\tthis.subscription = this.consumer.subscriptions.create({ channel: this.channelName, id: this.peerId, metadata: this.peerMetadata || {}, syncable_id: this.syncableId, syncable_type: this.syncableType }, {\n\t\t\tconnected: () => {\n\t\t\t\tthis.#isReady = true\n\t\t\t\tthis.send({\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tsenderId: this.peerId,\n\t\t\t\t\ttype: \"arrive\",\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\ttargetId: null\n\t\t\t\t})\n\t\t\t},\n \n\t\t\tdisconnected: () => {\n\t\t\t\tthis.#isReady = false\n\t\t\t\tthis.emit(\"close\")\n\t\t\t},\n \n\t\t\treceived: (message) => { \n\t\t\t\t// @ts-ignore\n\t\t\t\twindow.message = message\n\t\t\t\tif (message.targetId != null && message.targetId !== this.peerId) {\n\t\t\t\t\tif (message.senderId == this.peerId) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"ActionCableNetworkAdapter should never receive messages for a different peer.\"\n\t\t\t\t\t)\n\t\t\t\t}\n \n\t\t\t\tconst { senderId, type } = message\n\t\t\t\t\t\t\t\t \n\t\t\t\tswitch (type) {\n\t\t\t\t\tcase \"arrive\":\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst { peerMetadata } = message\n\t\t\t\t\t\t\tthis.send({\n\t\t\t\t\t\t\t\ttype: \"welcome\",\n\t\t\t\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\t\t\tsenderId: this.peerId,\n\t\t\t\t\t\t\t\tpeerMetadata: this.peerMetadata,\n\t\t\t\t\t\t\t\ttargetId: senderId,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\tthis.emit(\"peer-candidate\", { peerId: senderId, peerMetadata })\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\tcase \"welcome\":\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst { peerMetadata } = message\n\t\t\t\t\t\t\tthis.emit(\"peer-candidate\", { peerId: senderId, peerMetadata })\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\tcase \"leave\":\n\t\t\t\t\t\tthis.emit(\"peer-disconnected\", { peerId: senderId })\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tif(message.data && Object.values(message.data).length > 0) {\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\tthis.emit(\"message\", {\n\t\t\t\t\t\t\t\t...omit(message, \"data\"),\n\t\t\t\t\t\t\t\tdata: new Uint8Array(Object.values(message.data)),\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.emit(\"message\", message)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t},\n\t\t})\n\t}\n\n\tdisconnect() {\n\t\tif (this.subscription) {\n\t\t\tthis.send({\n\t\t\t\ttype: \"leave\",\n\t\t\t\t// @ts-expect-error\n\t\t\t\tsenderId: this.peerId,\n\t\t\t})\n\t\t\t// @ts-expect-error\n\t\t\tthis.emit(\"peer-disconnected\", { peerId: this.peerId })\n\t\t\tthis.subscription.unsubscribe()\n\t\t\tthis.subscription = undefined\n\t\t}\n\t}\n \n\n\tsend(message: Message) {\n\t\tthis.subscription?.send(message)\n\t\tif (message.data) {\n\t\t\tconst data = message.data.buffer.slice(\n\t\t\t\tmessage.data.byteOffset,\n\t\t\t\tmessage.data.byteOffset + message.data.byteLength\n\t\t\t)\n\t\t\n\t\t\tthis.subscription?.send(\n\t\t\t\t{\n\t\t\t\t\t...message,\n\t\t\t\t\tdata,\n\t\t\t\t}\n\t\t\t)\n\t\t} else {\n\t\t\tthis.subscription?.send(message)\n\t\t}\n\t}\n\n\twhenReady() {\n\t\treturn new Promise<void>((resolve) => {\n\t\t\twhile (true) {\n\t\t\t\tif (this.#isReady) {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tresolve()\n\t\t})\n\t}\n \n\tisReady() {\n\t\treturn this.#isReady\n\t}\n}\n\nexport default ActionCableNetworkAdapter","/**\n * This module provides a storage adapter for IndexedDB.\n *\n * @packageDocumentation\n */\nexport class IndexedDBStorageAdapter {\n database;\n store;\n dbPromise;\n /** Create a new {@link IndexedDBStorageAdapter}.\n * @param database - The name of the database to use. Defaults to \"automerge\".\n * @param store - The name of the object store to use. Defaults to \"documents\".\n */\n constructor(database = \"automerge\", store = \"documents\") {\n this.database = database;\n this.store = store;\n this.dbPromise = this.createDatabasePromise();\n }\n createDatabasePromise() {\n return new Promise((resolve, reject) => {\n const request = indexedDB.open(this.database, 1);\n request.onerror = () => {\n reject(request.error);\n };\n request.onupgradeneeded = event => {\n const db = event.target.result;\n db.createObjectStore(this.store);\n };\n request.onsuccess = event => {\n const db = event.target.result;\n resolve(db);\n };\n });\n }\n async load(keyArray) {\n const db = await this.dbPromise;\n const transaction = db.transaction(this.store);\n const objectStore = transaction.objectStore(this.store);\n const request = objectStore.get(keyArray);\n return new Promise((resolve, reject) => {\n transaction.onerror = () => {\n reject(request.error);\n };\n request.onsuccess = event => {\n const result = event.target.result;\n if (result && typeof result === \"object\" && \"binary\" in result) {\n resolve(result.binary);\n }\n else {\n resolve(undefined);\n }\n };\n });\n }\n async save(keyArray, binary) {\n const db = await this.dbPromise;\n const transaction = db.transaction(this.store, \"readwrite\");\n const objectStore = transaction.objectStore(this.store);\n objectStore.put({ key: keyArray, binary: binary }, keyArray);\n return new Promise((resolve, reject) => {\n transaction.onerror = () => {\n reject(transaction.error);\n };\n transaction.oncomplete = () => {\n resolve();\n };\n });\n }\n async remove(keyArray) {\n const db = await this.dbPromise;\n const transaction = db.transaction(this.store, \"readwrite\");\n const objectStore = transaction.objectStore(this.store);\n objectStore.delete(keyArray);\n return new Promise((resolve, reject) => {\n transaction.onerror = () => {\n reject(transaction.error);\n };\n transaction.oncomplete = () => {\n resolve();\n };\n });\n }\n async loadRange(keyPrefix) {\n const db = await this.dbPromise;\n const lowerBound = keyPrefix;\n const upperBound = [...keyPrefix, \"\\uffff\"];\n const range = IDBKeyRange.bound(lowerBound, upperBound);\n const transaction = db.transaction(this.store);\n const objectStore = transaction.objectStore(this.store);\n const request = objectStore.openCursor(range);\n const result = [];\n return new Promise((resolve, reject) => {\n transaction.onerror = () => {\n reject(request.error);\n };\n request.onsuccess = event => {\n const cursor = event.target.result;\n if (cursor) {\n result.push({\n data: cursor.value.binary,\n key: cursor.key,\n });\n cursor.continue();\n }\n else {\n resolve(result);\n }\n };\n });\n }\n async removeRange(keyPrefix) {\n const db = await this.dbPromise;\n const lowerBound = keyPrefix;\n const upperBound = [...keyPrefix, \"\\uffff\"];\n const range = IDBKeyRange.bound(lowerBound, upperBound);\n const transaction = db.transaction(this.store, \"readwrite\");\n const objectStore = transaction.objectStore(this.store);\n objectStore.delete(range);\n return new Promise((resolve, reject) => {\n transaction.onerror = () => {\n reject(transaction.error);\n };\n transaction.oncomplete = () => {\n resolve();\n };\n });\n }\n}\n","import { Repo, type RepoConfig } from \"@automerge/automerge-repo\";\nimport ActionCableNetworkAdapter from \"./network-adapter.js\"\nimport { IndexedDBStorageAdapter } from \"@automerge/automerge-repo-storage-indexeddb\"\n\ndeclare global {\n\tinterface Window { Syncable?: any }\n}\n\ntype Syncable = { \n\tnew (klass: string, id: any, channel?: string, obj?: RepoConfig): Repo \n}\n\nconst Syncable: Syncable = new Proxy(Repo, {\n\tconstruct: (target, args) => {\n\t\tconst [ klass, id, channel = \"ActionMerge::SyncChannel\", obj = {} ] = args\n\t\treturn new target({\n\t\t network: [new ActionCableNetworkAdapter(channel, klass, id)],\n\t\t storage: new IndexedDBStorageAdapter(),\n\t\t ...obj\n\t\t});\n\t}\n}) as Syncable\n\nwindow.Syncable = Syncable\n","import \"./syncable.js\"\nimport { next as Am } from \"@automerge/automerge\"\n\n// @ts-ignore\nwindow.Am = Am"],"names":["STATE","TRACE","OBJECT_ID","IS_PROXY","CLEAR_CACHE","UINT","INT","F64","COUNTER","TEXT","Text","text","index","elems","elem","chars","value","values","v","numDelete","callback","searchElement","fromIndex","other","test","f","sep","start","end","Counter","_delta","WriteableCounter","context","path","objectId","key","delta","getWriteableCounter","Int","Uint","Float64","RawString","val","parseListIndex","valueAt","target","prop","textV2","datatype","mapProxy","listProxy","textProxy","import_value","type","isSameDocument","printPath","_b","_c","MapHandler","cache","list","proxyList","i","assertString","assertText","map","proxyMap","keys","ListHandler","instance","listMethods","TextHandler","textMethods","proxied","rootProxy","length","proxyText","o","last","len","first","del","vals","result","e","initialValue","search","num","spans","jsonPointerComponents","component","unstableConflictAt","conflictAt","conflictId","handleText","fullVal","getRandomValues","rnds8","rng","REGEX","validate","uuid","byteToHex","unsafeStringify","arr","offset","stringify","parse","randomUUID","native","v4","options","buf","rnds","wasm","heap","getObject","idx","heap_next","dropObject","takeObject","ret","WASM_VECTOR_LEN","cachedUint8Memory0","getUint8Memory0","cachedTextEncoder","encodeString","arg","view","passStringToWasm0","malloc","realloc","ptr","mem","code","isLikeNone","x","cachedInt32Memory0","getInt32Memory0","cachedTextDecoder","getStringFromWasm0","addHeapObject","obj","cachedFloat64Memory0","getFloat64Memory0","debugString","description","name","debug","builtInMatches","className","_assertClass","klass","create","retptr","r0","r1","r2","Automerge","load","data","encodeChange","change","decodeChange","initSyncState","SyncState","importSyncState","state","exportSyncState","encodeSyncMessage","message","decodeSyncMessage","msg","encodeSyncState","decodeSyncState","handleError","args","TextRepresentation","AutomergeFinalization","Automerge$1","actor","text_rep","ptr0","len0","heads","time","deferred2_0","deferred2_1","r3","ptr1","len1","delete_count","new_text","v1","enable","export_function","import_function","object","meta","before","after","changes","have_deps","hash","deferred1_0","deferred1_1","cursor","range","SyncStateFinalization","SyncState$1","hashes","__wbg_load","module","imports","bytes","__wbg_get_imports","arg0","arg1","deferred0_0","deferred0_1","arg2","__wbg_finalize_init","__wbg_init","initSync","input","_initialized","_initializeListeners","UseApi","api","k","ApiHandler","listener","initializeWasm","wasmBlob","initWasm","_","WasmApi","initializeBase64Wasm","wasmBase64","c","wasmInitialized","resolve","isWasmInitialized","_state","doc","checkroot","_obj","_clear_cache","_trace","_is_proxy","__rest","s","t","p","insertAt","deleteAt","getBackend","importOpts","_actor","init","_opts","opts","freeze","patchCallback","text_v1","handle","registerDatatypes","clone","stateSansHeads","free","from","initialState","_change","d","changeAt","scope","progressDocument","source","nextState","nextDoc","patches","newState","headsEqual","root","newHead","emptyChange","unchecked","allowMissingDeps","convertRawStringsToText","loadIncremental","saveIncremental","save","merge","local","remote","localState","remoteState","getActorId","getLastLocalChange","getObjectId","getChanges","oldState","getHeads","getAllChanges","applyChanges","getHistory","history","diff","checkHeads","equals","heads1","heads2","fieldname","val1","val2","isObject","keys1","keys2","sync","generateSyncMessage","inState","syncState","receiveSyncMessage","outSyncState","hasOurChanges","getMissingDeps","dump","toJS","enabled","isAutomerge","saveSince","hasHeads","topoHistoryTraversal","inspectChange","changeHash","stats","stable.getBackend","stable.init","stable.clone","stable.from","stable.loadIncremental","stable.load","cursorToIndex","splice","newText","objPath","absoluteObjPath","updateText","block","splitBlock","joinBlock","updateBlock","updateSpans","newSpans","getCursor","getCursorPosition","mark","unmark","marks","marksAt","getConflicts","functionName","m","h","w","y","ms","fmtLong","fmtShort","str","match","n","msAbs","plural","isPlural","setup","env","createDebug","coerce","disable","require$$0","destroy","selectColor","namespace","prevTime","enableOverride","namespacesCache","enabledCache","self","curr","format","formatter","extend","delimiter","newDebug","namespaces","split","toNamespace","regexp","common","exports","formatArgs","useColors","localstorage","warned","lastC","r","define_process_env_default","formatters","error","has","prefix","Events","EE","fn","once","addListener","emitter","event","evt","clearEvent","EventEmitter","names","events","handlers","l","ee","listeners","a1","a2","a3","a4","a5","j","getGlobal","getDevTools","devToolsAdapter","service","devTools","Mailbox","_process","enqueued","consumed","STATE_DELIMITER","TARGETLESS_KEY","NULL_EVENT","STATE_IDENTIFIER","WILDCARD","XSTATE_INIT","XSTATE_STOP","createAfterEvent","delayRef","id","createDoneStateEvent","output","createDoneActorEvent","invokeId","createErrorActorEvent","createInitEvent","reportUnhandledError","err","symbolObservable","matchesState","parentStateId","childStateId","parentStateValue","toStateValue","childStateValue","toStatePath","stateId","isArray","segment","stateValue","isMachineSnapshot","statePath","pathToStateValue","marker","previous","mapValues","collection","iteratee","collectionKeys","toArrayStrict","toArray","resolveOutput","mapper","isErrorActorEvent","toTransitionConfigArray","configLike","transitionLike","normalizeTarget","toObserver","nextHandler","errorHandler","completionHandler","isObserver","createInvokeId","stateNodeId","resolveReferencedActor","machine","src","indexStr","nodeId","invokeConfig","createScheduledEventId","actorRef","idCounter","createSystem","rootActor","children","keyedActors","reverseKeyedActors","inspectionObservers","timerMap","clock","logger","scheduler","delay","scheduledEvent","scheduledEventId","system","timeout","sendInspectionEvent","resolvedInspectionEvent","observer","sessionId","systemId","existing","observerOrFn","scheduledEvents","scheduledId","$$ACTOR_TYPE","ProcessingStatus","defaultOptions","Actor","logic","resolvedOptions","parent","syncSnapshot","inspect","child","emittedEvent","wildcardListener","allListeners","handler","persistedState","snapshot","deferredFn","nextListenerOrObserver","errorListener","completeListener","wrappedHandler","initEvent","caughtError","reportError","err2","createActor","resolveCancel","actionArgs","actionParams","sendId","resolvedSendId","executeCancel","actorScope","cancel","params","resolveSpawn","_actionParams","resolvedId","cloneMachineSnapshot","executeSpawn","spawnChild","resolveStop","actorRefOrString","resolvedActorRef","executeStop","stopChild","stop","evaluateGuard","guard","isInline","resolved","guardArgs","guardParams","isAtomicStateNode","stateNode","getChildren","sn","getProperAncestors","toStateNode","ancestors","getAllStateNodes","stateNodes","nodeSet","adjList","getAdjList","getInitialStateNodesWithTheirAncestors","initialStates","initialStateNode","getValueFromAdj","baseNode","childStateNodes","childStateNode","getStateValue","rootNode","config","isInFinalState","stateNodeSet","isStateId","getCandidates","receivedEventType","eventDescriptor","partialEventTokens","eventTokens","tokenIndex","partialEventToken","eventToken","a","b","getDelayedTransitions","afterConfig","mutateEntryExit","afterEvent","eventType","raise","configTransition","resolvedTransition","resolvedDelay","transition","delayedTransition","formatTransition","descriptor","transitionConfig","normalizedTarget","reenter","resolveTarget","formatTransitions","transitions","transitionsConfig","invokeDef","formatInitialTransition","_target","resolvedTarget","targets","isInternalTarget","getStateNodeByPath","resolveHistoryDefaultTransition","isHistoryNode","states","getInitialStateNodes","ancestor","set","iter","descStateNode","getStateNode","stateKey","arrayStatePath","currentStateNode","getStateNodes","childStateKeys","subStateKey","allSubStateNodes","subStateNode","subStateNodes","transitionAtomicNode","next","transitionCompoundNode","subStateKeys","transitionNode","transitionParallelNode","allInnerTransitions","subStateValue","innerTransitions","getHistoryNodes","isDescendant","parentStateNode","hasIntersection","s1","s2","set1","set2","item","removeConflictingTransitions","enabledTransitions","historyValue","filteredTransitions","t1","t1Preempted","transitionsToRemove","t2","computeExitSet","t3","findLeastCommonAncestor","head","tail","getEffectiveTargetStates","targetNode","node","getTransitionDomain","targetStates","lca","statesToExit","domain","areStateNodeCollectionsEqual","prevStateNodes","nextStateNodeSet","microstep","currentSnapshot","isInitial","internalQueue","mutStateNodeSet","exitStates","resolveActionsAndContext","enterStates","nextStateNodes","getMachineOutput","rootCompletionNode","doneStateEvent","nextSnapshot","statesToEnter","statesForDefaultEntry","computeEntrySet","completedNodes","stateNodeToEnter","actions","initialActions","ancestorMarker","addDescendantStatesToEnter","addAncestorStatesToEnter","historyStateNodes","addProperAncestorStatesToEnter","historyDefaultTransition","reentrancyDomain","anc","changedHistory","exitStateNode","historyNode","predicate","def","executingCustomAction","resolveAndExecuteActionsWithContext","extra","retries","intermediateSnapshot","action","executeAction","resolvedAction","builtinAction","deferredActorIds","macrostep","microstates","addMicrostate","microstate","stopChildren","nextEvent","currentEvent","isErr","selectTransitions","shouldSelectEventlessTransitions","selectEventlessTransitions","previousState","enabledTransitionSet","atomicStates","loop","resolveStateValue","allStateNodes","machineSnapshotMatches","testValue","machineSnapshotHasTag","tag","machineSnapshotCan","transitionData","machineSnapshotToJSON","nodes","tags","getMeta","toJSON","can","hasTag","matches","jsonValues","machineSnapshotGetMeta","acc","createMachineSnapshot","getPersistedSnapshot","childrenJson","persistContext","contextPart","copy","resolveRaise","eventOrExpr","delaysMap","resolvedEvent","configDelay","executeRaise","createSpawner","spawnedChildren","spawn","resolveAssign","assignment","assignArgs","partialUpdate","propAssignment","updatedContext","assign","assertEvent","types","typesText","memo","memoizedData","EMPTY_OBJECT","toSerializableAction","StateNode","stateConfig","resolvedSrc","onDone","onError","invokeDefValues","selectedTransition","candidates","candidate","resolvedContext","guardPassed","guardType","StateMachine","implementations","guards","actors","delays","resolvedStateValue","preInitial","preInitialState","macroState","fullPath","relativePath","resolvedStateId","_actorScope","snapshotChildren","actorId","actorData","childState","restoredSnapshot","seen","reviveContext","createMachine","schemas","defaultWaitForOptions","waitFor","res","rej","signal","done","dispose","sub","abortListener","checkEmitted","emitted","_assert","isBytes","number","bool","exists","lengths","checkFinished","out","min","assert","crypto","byteSwap32","bytesToHex","hexToBytes","asyncLoop","utf8ToBytes","toBytes","concatBytes","checkOpts","wrapConstructor","wrapConstructorWithOpts","wrapXOFConstructorWithOpts","randomBytes","crypto_1","_assert_js_1","require$$1","u8","u32","createView","rotr","word","shift","rotl","byteSwap","hexes","hex","asciis","asciiToBase16","char","hl","al","array","ai","hi","n1","n2","nextTick","iters","tick","cb","ts","arrays","sum","pad","Hash","toStr","defaults","hashCons","hashC","tmp","bytesLength","_md","utils_js_1","setBigUint64","byteOffset","isLE","_32n","_u32_max","wh","wl","Chi","Maj","HashMD","blockLen","outputLen","padOffset","buffer","pos","take","dataView","oview","outLen","to","finished","destroyed","sha256","_md_js_1","SHA256_K","SHA256_IV","SHA256_W","SHA256","A","B","C","D","E","F","G","H","W15","W2","s0","sigma1","T1","T2","SHA224","base","ALPHABET","BASE_MAP","xc","BASE","LEADER","FACTOR","iFACTOR","encode","zeroes","pbegin","pend","size","b58","carry","it1","it2","decodeUnsafe","psz","b256","it3","it4","vch","decode","string","basex","bs58","base58","checksumFn","payload","payloadU8","checksum","both","decodeRaw","newChecksum","bs58checkBase","sha256x2","bs58check","urlPrefix","parseAutomergeUrl","url","regex","docMatch","documentId","binaryDocumentId","documentIdToBinary","stringifyAutomergeUrl","encodedDocumentId","binaryToDocumentId","isValidAutomergeUrl","automergeUrl","isValidDocumentId","binaryDocumentID","Uuid.stringify","Uuid.validate","isValidUuid","generateAutomergeUrl","Uuid.v4","docId","interpretAsDocumentId","Uuid.parse","decoder","srcEnd","position","LEGACY_RECORD_INLINE_ID","RECORD_DEFINITIONS_ID","RECORD_INLINE_ID","BUNDLED_STRINGS_ID","PACKED_REFERENCE_TAG_ID","STOP_CODE","maxArraySize","maxMapSize","currentDecoder","currentStructures","srcString","srcStringStart","srcStringEnd","bundledStrings","referenceMap","currentExtensions","currentExtensionRanges","packedValues","restoreMapsAsObject","sequentialMode","inlineObjectReadThreshold","Decoder","rec","safeKey","saveState","clearSource","checkedRead","forEach","lastPosition","defaultDecoder","read","token","majorType","getFloat16","multiplier","mult10","readBin","shortStringInJS","longStringInJS","readFixedString","structure","createStructureReader","readJustLength","recordDefinition","readBundleExt","loadShared","extension","Tag","packedValue","getPackedValues","validName","readObject","compiledReader","readStringJS","units","byte1","byte2","byte3","byte4","unit","fromCharCode","byte","g","f32Array","u8Array","byte0","exponent","abs","dateString","epochSec","fraction","existingStructure","glbl","packedTable","newPackedValues","startingPosition","refEntry","targetProperties","combine","SHARED_DATA_TAG_ID","isLittleEndianMachine","typedArrays","typedArrayTags","registerTypedArray","TypedArray","dvMethod","bytesPerElement","littleEndian","sizeShift","dv","elements","ta","method","bundlePosition","bundleLength","dataPosition","sharedData","updatedStructures","savedSrcEnd","savedPosition","savedSrcStringStart","savedSrcStringEnd","savedSrcString","savedReferenceMap","savedBundledStrings","savedSrc","savedStructures","savedDecoder","savedSequentialMode","textEncoder","extensions","extensionClasses","Buffer","hasNodeBuffer","ByteArrayAllocate","ByteArray","MAX_STRUCTURES","MAX_BUFFER_SIZE","throwOnIterable","targetView","safeEnd","MAX_BUNDLE_SIZE","hasNonLatin","RECORD_SYMBOL","Encoder","sharedStructures","hasSharedUpdate","structures","encodeUtf8","maxBytes","encoder","hasSharedStructures","maxSharedStructures","isSequential","samplingPackedValues","packedObjectMap","sharedValues","sharedPackedObjectMap","recordIdsToRemove","transitionsCount","serializationsSinceTransitionRebuild","encodeOptions","REUSE_BUFFER_MODE","sharedStructuresLength","nextTransition","findRepetitiveStrings","writeArrayHeader","valuesArray","THROW_ON_ITERABLE","writeBundles","makeRoom","serialized","insertIds","returnBuffer","RESET_BUFFER_MODE","threshold","status","packedPosition","strLength","extStart","twoByte","headerSize","c1","c2","strPosition","useFloat32","xShifted","referee","idsToInsert","constructor","writeObject","entryValue","extensionClass","entry","isBlob","json","writeBuffer","objectOffset","skipValues","newTransitions","parentRecordId","recordId","newSize","newBuffer","chunkThreshold","continuedChunkThreshold","startEncoding","encodeObjectAsIterable","encodeObjectAsAsyncIterable","iterateProperties","finalIterable","useRecords","writeEntityLength","tryEncode","restartEncoding","restart","encodeIterable","encodedValue","reader","asyncValue","lastVersion","structuresCopy","SharedData","saveResults","existingShared","majorValue","version","BlobConstructor","packedStatus","includeKeys","date","seconds","arrayBuffer","typedArray","typedArrayEncoder","definitions","nextId","distanceToMove","lastEnd","writeStrings","defaultEncoder","arraysAreEqual","element","headsAreSame","withTimeout","promise","timeoutId","timeoutPromise","reject","TimeoutError","DocHandle","#log","#machine","#prevDocState","A.init","#timeoutDelay","#remoteHeads","oldDoc","UPDATE","#checkForChanges","BEGIN","#doc","#state","#statePromise","awaitStates","awaitStatesArray","beforeHeads","A.getHeads","afterHeads","A.diff","DOC_READY","A.topoHistoryTraversal","A.view","second","A.inspectChange","storageId","A.change","resultHeads","A.changeAt","otherHandle","mergingDoc","A.merge","DOC_UNAVAILABLE","REQUEST","DELETE","A.stats","HandleState","IDLE","LOADING","REQUESTING","READY","DELETED","UNAVAILABLE","RemoteHeadsSubscriptions","#knownHeads","#ourSubscriptions","#theirSubscriptions","#generousPeers","#subscribedDocsByPeer","remotes","remotesToAdd","remotesToRemove","control","addedRemotesWeKnow","theirSubs","subscribedDocs","knownHeads","lastHeads","changedHeads","#changedHeads","peer","peerId","#isPeerSubscribedToDoc","timestamp","docRemote","peerIds","remoteHeads","subscribedPeers","newHeads","throttle","lastCall","wait","isRepoMessage","isSyncMessage","isEphemeralMessage","isRequestMessage","isDocumentUnavailableMessage","isRemoteSubscriptionControlMessage","isRemoteHeadsChanged","getEphemeralMessageSource","NetworkSubsystem","#adaptersByPeer","#count","#sessionId","#ephemeralSessionCounts","adapters","peerMetadata","networkAdapter","outbound","mergeArrays","myArrays","mergedArray","factory","this","K","hashBlocks","u","dataLength","dataPos","bytesHashed","left","bitLenHi","bitLenLo","padLength","HMAC","digest","hmac","fillBuffer","info","counter","hkdfSalt","hkdf","salt","okm","hmac_","bufpos","pbkdf2","password","iterations","dkLen","prf","ctr","dk","keyHash","binary","sha256.hash","bufferToHexString","headsHash","headsbinary","chunkTypeFromKey","chunkTypeStr","StorageSubsystem","#storageAdapter","#storedHeads","#chunkInfos","#compacting","storageAdapter","storedId","storageKey","chunks","binaries","chunkInfos","chunk","chunkType","newDoc","A.loadIncremental","#shouldSave","sourceChunks","#shouldCompact","#saveTotal","#saveIncremental","A.saveSince","A.save","snapshotHash","oldKeys","newChunkInfos","loaded","A.decodeSyncState","A.encodeSyncState","oldHeads","snapshotSize","incrementalSize","Synchronizer","DocSynchronizer","#peers","#pendingSyncStateCallbacks","#peerDocumentStatuses","#syncStates","#pendingSyncMessages","#syncStarted","#handle","#onLoadSyncState","onLoadSyncState","#syncWithPeers","#broadcastToPeers","#processAllPendingSyncMessages","#sendSyncMessage","#sendEphemeralMessage","#withSyncState","#addPeer","pendingCallbacks","#initSyncState","A.initSyncState","#setSyncState","newSyncState","A.generateSyncMessage","isNew","noPeersWithDocument","docPromise","#checkDocUnavailable","reparsedSyncState","senderId","contents","#processSyncMessage","A.decodeSyncMessage","A.receiveSyncMessage","log","CollectionSynchronizer","#docSetUp","repo","#fetchDocSynchronizer","#initDocSynchronizer","docSynchronizer","isEphemeral","#documentGenerousPeers","peers","generousPeers","okToShare","synchronizer","randomPeerId","Repo","#handleCache","#remoteHeadsSubscriptions","#remoteHeadsGossipingEnabled","storage","network","sharePolicy","enableRemoteHeadsGossiping","storageSubsystem","networkSubsystem","myPeerMetadata","shouldShare","#receiveMessage","#saveSyncState","#registerHandleWithSubsystems","saveFn","#throttledSaveSyncStateHandlers","#getHandle","Automerge.from","Automerge.emptyChange","Automerge.init","clonedHandle","sourceDoc","Automerge.clone","loadedDoc","Automerge.save","Automerge.load","documents","handles","adapter","NetworkAdapter","__vite__wasmUrl","__vite__initWasm","urlContent","binaryString","response","contentType","__wbg_set_wasm","lTextEncoder","lTextDecoder","__wbindgen_object_drop_ref","__wbindgen_string_get","__wbindgen_error_new","__wbindgen_string_new","__wbindgen_number_new","__wbindgen_object_clone_ref","__wbindgen_number_get","__wbindgen_is_undefined","__wbindgen_boolean_get","__wbindgen_is_null","__wbindgen_is_string","__wbindgen_is_function","__wbindgen_is_object","__wbindgen_is_array","__wbindgen_json_serialize","__wbg_new_abda76e883ba8a5f","__wbg_stack_658279fe44541cf6","__wbg_error_f851667af71bcfc6","__wbindgen_jsval_loose_eq","__wbg_String_91fba7ded13ba54c","__wbindgen_bigint_from_i64","__wbindgen_bigint_from_u64","__wbg_set_20cbc34131e76824","__wbg_getRandomValues_3aa56aa6edec874c","__wbg_randomFillSync_5c9c955aa56b6049","__wbg_crypto_1d1f22824a6a080c","__wbg_process_4a72847cc503995b","__wbg_versions_f686565e586dd935","__wbg_node_104a2ff8d6ea03a2","__wbg_require_cca90b1a94a0255b","__wbg_msCrypto_eb05e62b530a1508","__wbg_log_5bb5f88f245d7762","__wbg_log_1746d5c75ec89963","__wbg_get_bd8e338fbd5f5cc8","__wbg_length_cd7af8117672b8b8","__wbg_new_16b304a2cfa7ff4a","__wbg_newnoargs_e258087cd0daa0ea","__wbg_next_40fc327bfc8770e6","__wbg_next_196c84450b364254","__wbg_done_298b57d23c0fc80c","__wbg_value_d93c65011f51a456","__wbg_iterator_2cee6dadfd956dfa","__wbg_get_e3c254076557e348","__wbg_call_27c0f87801dedf93","__wbg_new_72fb9a18b5ae2624","__wbg_length_dee433d4c85c9387","__wbg_set_d4638f722068f043","__wbg_from_89e3fc3ba5e6fb48","__wbg_isArray_2ab64d95e09ea0ae","__wbg_push_a5b05aedc7234f9f","__wbg_unshift_e22df4b34bcf5070","__wbg_instanceof_ArrayBuffer_836825be07d4c9d2","__wbg_new_28c511d9baebfa89","__wbg_call_b3ca7c6051f9bec1","__wbg_instanceof_Date_f65cf97fb83fc369","__wbg_getTime_2bc4375165f02d15","__wbg_new_cf3ec55744a78578","__wbg_instanceof_Object_71ca3c0a59266746","__wbg_assign_496d2d14fecafbcf","__wbg_defineProperty_cc00e2de8a0f5141","__wbg_entries_95cc2c823b285a09","__wbg_freeze_cc6bc19f75299986","__wbg_keys_91e412b4b222659f","__wbg_values_9c75e6e2bfbdb70d","__wbg_new_dd6a5dd7b538af21","__wbg_apply_0a5aa603881e6d79","__wbg_deleteProperty_13e721a56f19e842","__wbg_ownKeys_658942b7f28d1fe9","__wbg_set_1f9b04f170055d33","__wbg_buffer_12d079cc21e14bdb","__wbg_concat_3de229fe4fe90fea","__wbg_slice_52fb626ffdc8da8f","__wbg_for_27c67e2dbdce22f6","__wbg_toString_7df3c77999517c20","__wbg_self_ce0dbfc45cf2f5be","__wbg_window_c6fb939a7f436783","__wbg_globalThis_d1e6af4856ba331b","__wbg_global_207b558942527489","__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb","__wbg_new_63b92bc8671ed464","__wbg_set_a47bac70306a19a7","__wbg_length_c20a40f15020d68a","__wbg_instanceof_Uint8Array_2b3bbecd033d19f6","__wbg_newwithlength_e9b4878cebadb3d3","__wbg_subarray_a1f73cd4b5b42fe1","__wbindgen_debug_string","__wbindgen_throw","__wbindgen_memory","__vite__wasmModule","__vite__wasmImport_0_0","__vite__wasmImport_0_1","__vite__wasmImport_0_2","__vite__wasmImport_0_3","__vite__wasmImport_0_4","__vite__wasmImport_0_5","__vite__wasmImport_0_6","__vite__wasmImport_0_7","__vite__wasmImport_0_8","__vite__wasmImport_0_9","__vite__wasmImport_0_10","__vite__wasmImport_0_11","__vite__wasmImport_0_12","__vite__wasmImport_0_13","__vite__wasmImport_0_14","__vite__wasmImport_0_15","__vite__wasmImport_0_16","__vite__wasmImport_0_17","__vite__wasmImport_0_18","__vite__wasmImport_0_19","__vite__wasmImport_0_20","__vite__wasmImport_0_21","__vite__wasmImport_0_22","__vite__wasmImport_0_23","__vite__wasmImport_0_24","__vite__wasmImport_0_25","__vite__wasmImport_0_26","__vite__wasmImport_0_27","__vite__wasmImport_0_28","__vite__wasmImport_0_29","__vite__wasmImport_0_30","__vite__wasmImport_0_31","__vite__wasmImport_0_32","__vite__wasmImport_0_33","__vite__wasmImport_0_34","__vite__wasmImport_0_35","__vite__wasmImport_0_36","__vite__wasmImport_0_37","__vite__wasmImport_0_38","__vite__wasmImport_0_39","__vite__wasmImport_0_40","__vite__wasmImport_0_41","__vite__wasmImport_0_42","__vite__wasmImport_0_43","__vite__wasmImport_0_44","__vite__wasmImport_0_45","__vite__wasmImport_0_46","__vite__wasmImport_0_47","__vite__wasmImport_0_48","__vite__wasmImport_0_49","__vite__wasmImport_0_50","__vite__wasmImport_0_51","__vite__wasmImport_0_52","__vite__wasmImport_0_53","__vite__wasmImport_0_54","__vite__wasmImport_0_55","__vite__wasmImport_0_56","__vite__wasmImport_0_57","__vite__wasmImport_0_58","__vite__wasmImport_0_59","__vite__wasmImport_0_60","__vite__wasmImport_0_61","__vite__wasmImport_0_62","__vite__wasmImport_0_63","__vite__wasmImport_0_64","__vite__wasmImport_0_65","__vite__wasmImport_0_66","__vite__wasmImport_0_67","__vite__wasmImport_0_68","__vite__wasmImport_0_69","__vite__wasmImport_0_70","__vite__wasmImport_0_71","__vite__wasmImport_0_72","__vite__wasmImport_0_73","__vite__wasmImport_0_74","__vite__wasmImport_0_75","__vite__wasmImport_0_76","__vite__wasmImport_0_77","__vite__wasmImport_0_78","__vite__wasmImport_0_79","__vite__wasmImport_0_80","__vite__wasmImport_0_81","__vite__wasmImport_0_82","__vite__wasmImport_0_83","__vite__wasmImport_0_84","__vite__wasmImport_0_85","__vite__wasmImport_0_86","__vite__wasmImport_0_87","memory","__wbg_syncstate_free","syncstate_sharedHeads","syncstate_lastSentHeads","syncstate_set_lastSentHeads","syncstate_set_sentHashes","syncstate_clone","__wbg_automerge_free","automerge_new","automerge_clone","automerge_fork","automerge_pendingOps","automerge_commit","automerge_merge","automerge_rollback","automerge_keys","automerge_text","automerge_spans","automerge_splice","automerge_updateText","automerge_updateSpans","automerge_push","automerge_pushObject","automerge_insert","automerge_splitBlock","automerge_joinBlock","automerge_updateBlock","automerge_getBlock","automerge_insertObject","automerge_put","automerge_putObject","automerge_increment","automerge_get","automerge_getWithType","automerge_objInfo","automerge_getAll","automerge_enableFreeze","automerge_registerDatatype","automerge_applyPatches","automerge_applyAndReturnPatches","automerge_diffIncremental","automerge_updateDiffCursor","automerge_resetDiffCursor","automerge_diff","automerge_isolate","automerge_integrate","automerge_length","automerge_delete","automerge_save","automerge_saveIncremental","automerge_saveSince","automerge_saveNoCompress","automerge_saveAndVerify","automerge_loadIncremental","automerge_applyChanges","automerge_getChanges","automerge_getChangeByHash","automerge_getDecodedChangeByHash","automerge_getChangesAdded","automerge_getHeads","automerge_getActorId","automerge_getLastLocalChange","automerge_dump","automerge_getMissingDeps","automerge_receiveSyncMessage","automerge_generateSyncMessage","automerge_toJS","automerge_materialize","automerge_getCursor","automerge_getCursorPosition","automerge_emptyChange","automerge_mark","automerge_unmark","automerge_marks","automerge_marksAt","automerge_hasOurChanges","automerge_topoHistoryTraversal","automerge_stats","__wbindgen_malloc","__wbindgen_realloc","__wbindgen_add_to_stack_pointer","__wbindgen_free","__wbindgen_exn_store","messages","now","secondsSince","ConnectionMonitor","connection","staleThreshold","reconnectionBackoffRate","backoff","jitter","INTERNAL","message_types","protocols","supportedProtocols","indexOf","Connection","consumer","socketProtocols","allowReconnect","eventName","identifier","reason","reconnect","properties","Subscription","mixin","SubscriptionGuarantor","subscriptions","subscription","Subscriptions","channelName","channel","callbackName","command","Consumer","createWebSocketURL","subprotocol","createConsumer","getConfig","LARGE_ARRAY_SIZE","HASH_UNDEFINED","INFINITY","MAX_SAFE_INTEGER","argsTag","funcTag","genTag","symbolTag","reRegExpChar","reIsHostCtor","reIsUint","freeGlobal","global","freeSelf","apply","func","thisArg","arrayIncludes","baseIndexOf","arrayMap","arrayPush","baseFindIndex","fromRight","baseIsNaN","baseTimes","cacheHas","getValue","isHostObject","overArg","transform","arrayProto","funcProto","objectProto","coreJsData","maskSrcKey","uid","funcToString","hasOwnProperty","objectToString","reIsNative","Symbol","getPrototype","propertyIsEnumerable","spreadableSymbol","nativeGetSymbols","nativeMax","Map","getNative","nativeCreate","entries","hashClear","hashDelete","hashGet","hashHas","hashSet","ListCache","listCacheClear","listCacheDelete","assocIndexOf","lastIndex","listCacheGet","listCacheHas","listCacheSet","MapCache","mapCacheClear","mapCacheDelete","getMapData","mapCacheGet","mapCacheHas","mapCacheSet","SetCache","setCacheAdd","setCacheHas","arrayLikeKeys","inherited","isArguments","skipIndexes","isIndex","eq","baseDifference","comparator","includes","isCommon","valuesLength","outer","computed","valuesIndex","baseFlatten","depth","isStrict","isFlattenable","baseGetAllKeys","keysFunc","symbolsFunc","baseIsNative","isMasked","pattern","isFunction","toSource","baseKeysIn","nativeKeysIn","isProto","isPrototype","basePick","props","basePickBy","baseRest","otherArgs","getAllKeysIn","keysIn","getSymbolsIn","isKeyable","getSymbols","stubArray","Ctor","proto","toKey","isSymbol","isArrayLikeObject","isArrayLike","isLength","isObjectLike","omit","lodash_omit","ActionCableNetworkAdapter","#isReady","syncableType","syncableId","serverUrl","IndexedDBStorageAdapter","database","store","request","db","keyArray","transaction","keyPrefix","lowerBound","upperBound","Syncable","Am"],"mappings":"AACO,MAAMA,GAAQ,OAAO,IAAI,UAAU,EAC7BC,GAAQ,OAAO,IAAI,WAAW,EAC9BC,GAAY,OAAO,IAAI,cAAc,EACrCC,GAAW,OAAO,IAAI,aAAa,EACnCC,GAAc,OAAO,IAAI,gBAAgB,EACzCC,GAAO,OAAO,IAAI,UA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O6qB,EAAY,KAAK,CACxC,EACYA,EAAY,WAAa,IAAM,CAC3BnqD,GAChB,CACA,CAAS,CACJ,CACL,CCnHA,MAAMuqD,GAAqB,IAAI,MAAM7d,GAAM,CAC1C,UAAW,CAAC94C,EAAQmI,IAAS,CACtB,KAAA,CAAExB,EAAO4S,EAAIi0C,EAAU,2BAA4BvnD,EAAM,CAAA,CAAG,EAAIkC,EACtE,OAAO,IAAInI,EAAO,CAChB,QAAS,CAAC,IAAI41D,GAA0BpI,EAAS7mD,EAAO4S,CAAE,CAAC,EAC3D,QAAS,IAAI08C,GACb,GAAGhwD,CAAA,CACJ,CACF,CACD,CAAC,EAED,OAAO,SAAW0wD,GCnBlB,OAAO,GAAKC","x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,60,61,62,63,64,65,67]}