{"version":3,"file":"realm-CmyiTkom.cjs","names":["err_nice","err","unwrapOptional$2","unwrapOptional$1","unwrapOptional","getAtPath$1","ReliableLog","createMemoryReliableLogStore","getAtPath","WIRE_PROTOCOL_PREFIX","securityLevelMeets","securityLevelMeets","unwrapOptional","castNiceError","WIRE_PROTOCOL_PREFIX","WireProtocolMux","sha256Hex"],"sources":["../../connect-core/build/realmAcceptorProtocol-DqECRw9r.mjs","../../connect-core/build/state-DGS3KIFN.mjs","../../connect-core/build/RealmReplica-CVo40qsA.mjs","../../connect-core/build/realm/index.mjs"],"sourcesContent":["import { A as securityLevelMeets } from \"./wire-D7Nv6hx_.mjs\";\nimport { m as err, p as err_nice } from \"./error-BFAEkmpX.mjs\";\nimport { m as WIRE_PROTOCOL_PREFIX, n as createMemoryReliableLogStore, t as ReliableLog } from \"./ReliableLog-DudDQ2zp.mjs\";\nimport { t as unrefTimer } from \"./util-DiEla9R9.mjs\";\nimport { pack, unpack } from \"msgpackr\";\nimport { applyPatches, enablePatches, produceWithPatches } from \"immer\";\n//#region src/realm/RealmDefinition/errors/err_realm.ts\n/**\n* The realm base error domain. Rejection frames carry `packError` output (a msgpack\n* map), never positional tuples — rejections are the rare path, so they stay fully descriptive\n* and hydratable. User realms define their own domains for rule/intent rejections; these are the\n* engine's own errors. (`protocol_unsupported` lives in `connect-core/wire` — it is a link-level\n* concern, not a realm one.)\n*/\nconst err_realm = err_nice.createChildDomain({\n\tdomain: \"err_nice_realm\",\n\tschema: {\n\t\tschema_mismatch: err({\n\t\t\tmessage: ({ realmId, clientHash, serverHash }) => `Realm \"${realmId}\" schema mismatch — avatar ${clientHash.slice(0, 12)}… vs server ${serverHash.slice(0, 12)}…. The client and server were built from different realm definitions; refusing to attach (silent token skew would corrupt state).`,\n\t\t\tcontext: { required: true }\n\t\t}),\n\t\trealm_unknown: err({\n\t\t\tmessage: ({ realmId }) => `This server hosts no realm with id \"${realmId}\".`,\n\t\t\tcontext: { required: true }\n\t\t}),\n\t\tunauthorized_avatar_type: err({\n\t\t\tmessage: ({ avatarType, expected }) => `Client type \"${avatarType}\" is not permitted here (expected: ${expected.join(\", \")}).`,\n\t\t\tcontext: { required: true }\n\t\t}),\n\t\t/** The connection's identity could not be resolved to a realm avatar: the\n\t\t* server's `resolveAvatar`/`avatarType` mapping returned nothing for this connection. */\n\t\tavatar_unresolved: err({\n\t\t\tmessage: ({ realmId }) => `This connection's identity could not be resolved to an avatar of realm \"${realmId}\" — the server's resolveAvatar returned undefined (or the attachment carries no coordinate).`,\n\t\t\tcontext: { required: true }\n\t\t}),\n\t\t/**\n\t\t* The connection's negotiated wire security level is below the realm's declared minimum\n\t\t*. Fail-closed at attach: the avatar never attaches, so no avatar data\n\t\t* flows below the required level. Raise the connection's `securityLevel` (e.g. `encrypted`) to\n\t\t* attach — the realm requires it.\n\t\t*/\n\t\tinsufficient_security: err({\n\t\t\tmessage: ({ realmId, required, actual }) => `Realm \"${realmId}\" requires a \"${required}\" connection but this one negotiated \"${actual}\". Connect with at least the required security level — the realm refuses to move avatar data below it.`,\n\t\t\tcontext: { required: true }\n\t\t}),\n\t\tunauthorized_coordinate: err({\n\t\t\tmessage: ({ path }) => `This avatar's coordinates may not write \"${path}\".`,\n\t\t\tcontext: { required: true }\n\t\t}),\n\t\tvalue_invalid: err({\n\t\t\tmessage: ({ path, expected }) => `The value written to \"${path}\" does not match the schema (expected ${expected}).`,\n\t\t\tcontext: { required: true }\n\t\t}),\n\t\tlimits_exceeded: err({\n\t\t\tmessage: ({ limit }) => `Ingress limit exceeded: ${limit}.`,\n\t\t\tcontext: { required: true }\n\t\t}),\n\t\tintent_unknown: err({\n\t\t\tmessage: ({ intent }) => `Unknown intent \"${intent}\".`,\n\t\t\tcontext: { required: true }\n\t\t}),\n\t\tversion_gap_unrecoverable: err({\n\t\t\tmessage: ({ lastKnownVersion, oldestReplayable }) => `Version ${lastKnownVersion} is behind the replayable window (oldest ${oldestReplayable}) — full rehydration required.`,\n\t\t\tcontext: { required: true }\n\t\t}),\n\t\t/** A write or intent made before the first hydrate is queued for it; this is the queued\n\t\t* handle's rejection when that hydrate never came (the realm detached, or `pendingExpiryMs`\n\t\t* passed first). Definite: nothing was sent. A refused attach rejects with the attach error. */\n\t\twrite_before_hydrate: err({\n\t\t\tmessage: ({ realmId }) => `A write on \"${realmId}\" was queued for the first hydrate, which never arrived (the realm detached, or the pending expiry passed first) — nothing was sent.`,\n\t\t\tcontext: { required: true }\n\t\t}),\n\t\t/**\n\t\t* The optimistic frame expired / was rolled back before an authoritative answer arrived — an\n\t\t* **unknown outcome**, NOT proof the server rejected it. The\n\t\t* write may have committed on the server while the ack was lost, or the link dropped mid-flight.\n\t\t* Do not blindly re-issue a non-idempotent **intent** on this error — re-read state (it\n\t\t* converges via the next replay/hydrate) and decide. A rules rejection, by contrast, is a\n\t\t* definite \"no\" and carries the rule's own error, not this one.\n\t\t*/\n\t\tframe_too_stale: err({\n\t\t\tmessage: ({ basisVersion }) => `The optimistic frame (basis ${basisVersion}) expired before it could be confirmed — outcome unknown (it may have committed; re-read state rather than re-issuing a non-idempotent intent).`,\n\t\t\tcontext: { required: true }\n\t\t}),\n\t\t/** The durable-write backlog cap: too many unconfirmed\n\t\t* `durability: \"reassert\"` frames accumulated (a long outage). The app's cue to fall back to\n\t\t* its own source-of-truth re-sync instead of queueing more. */\n\t\tdurable_backlog_overflow: err({\n\t\t\tmessage: ({ pendingFrames }) => `The durable-write backlog is full (${pendingFrames} unconfirmed reassert frames) — this write was rejected. Re-sync from your source of truth after reconnecting.`,\n\t\t\tcontext: { required: true }\n\t\t}),\n\t\tframe_invalid: err({\n\t\t\tmessage: ({ reason }) => `Malformed realm frame: ${reason}.`,\n\t\t\tcontext: { required: true }\n\t\t}),\n\t\t/**\n\t\t* A structurally valid write (schema + rules passed) that does not APPLY to the current\n\t\t* authoritative state — its target's parent no longer exists (a record entry deleted by a\n\t\t* server-side prune, or a transient region reset by a hibernation wake between the write's\n\t\t* basis and its arrival). Distinct from {@link frame_invalid} (a malformed/hostile frame): the\n\t\t* frame was well-formed, the state simply moved out from under it. A predicted optimistic write\n\t\t* on this path rolls back; the app should re-read state (an assert-on-resume re-creates a\n\t\t* pruned own-entry) rather than re-issue blindly. Additive since 0.46 — pre-0.46 servers send\n\t\t* `frame_invalid` for this case.\n\t\t*/\n\t\twrite_target_missing: err({\n\t\t\tmessage: ({ path }) => `The write to \"${path}\" could not be applied — its parent no longer exists (a pruned entry or a transient region reset since the write's basis). Re-read state instead of re-issuing.`,\n\t\t\tcontext: { required: true }\n\t\t})\n\t}\n});\n//#endregion\n//#region src/realm/RealmDefinition/Schema/validateValue.ts\nfunction isPlainObject$1(value) {\n\treturn typeof value === \"object\" && value != null && !Array.isArray(value) && !(value instanceof Uint8Array);\n}\n/** `undefined` = valid; otherwise where and what was expected. */\nfunction validateValue(node, value) {\n\tswitch (node.kind) {\n\t\tcase \"string\":\n\t\t\tif (typeof value !== \"string\") return {\n\t\t\t\tpath: [],\n\t\t\t\texpected: \"string\"\n\t\t\t};\n\t\t\tif (node.maxLength != null && value.length > node.maxLength) return {\n\t\t\t\tpath: [],\n\t\t\t\texpected: `a string of at most ${node.maxLength} characters`\n\t\t\t};\n\t\t\treturn;\n\t\tcase \"number\":\n\t\t\tif (typeof value !== \"number\") return {\n\t\t\t\tpath: [],\n\t\t\t\texpected: \"number\"\n\t\t\t};\n\t\t\tif ((node.min != null || node.max != null || node.integer === true) && !Number.isFinite(value)) return {\n\t\t\t\tpath: [],\n\t\t\t\texpected: \"a finite number\"\n\t\t\t};\n\t\t\tif (node.integer === true && !Number.isInteger(value)) return {\n\t\t\t\tpath: [],\n\t\t\t\texpected: \"an integer\"\n\t\t\t};\n\t\t\tif (node.min != null && value < node.min) return {\n\t\t\t\tpath: [],\n\t\t\t\texpected: `a number >= ${node.min}`\n\t\t\t};\n\t\t\tif (node.max != null && value > node.max) return {\n\t\t\t\tpath: [],\n\t\t\t\texpected: `a number <= ${node.max}`\n\t\t\t};\n\t\t\treturn;\n\t\tcase \"boolean\": return typeof value === \"boolean\" ? void 0 : {\n\t\t\tpath: [],\n\t\t\texpected: \"boolean\"\n\t\t};\n\t\tcase \"literal\": return value === node.value ? void 0 : {\n\t\t\tpath: [],\n\t\t\texpected: `literal ${JSON.stringify(node.value)}`\n\t\t};\n\t\tcase \"optional\": return value === void 0 ? void 0 : validateValue(node.inner, value);\n\t\tcase \"union\":\n\t\t\tfor (const option of node.options) if (validateValue(option, value) == null) return void 0;\n\t\t\treturn {\n\t\t\t\tpath: [],\n\t\t\t\texpected: \"one of the union options\"\n\t\t\t};\n\t\tcase \"object\":\n\t\t\tif (!isPlainObject$1(value)) return {\n\t\t\t\tpath: [],\n\t\t\t\texpected: \"object\"\n\t\t\t};\n\t\t\tfor (const key of Object.keys(value)) if (node.entries[key] == null) return {\n\t\t\t\tpath: [key],\n\t\t\t\texpected: \"no such key in the schema\"\n\t\t\t};\n\t\t\tfor (const [key, child] of Object.entries(node.entries)) {\n\t\t\t\tconst childValue = value[key];\n\t\t\t\tif (childValue === void 0) {\n\t\t\t\t\tif (child.kind !== \"optional\") return {\n\t\t\t\t\t\tpath: [key],\n\t\t\t\t\t\texpected: child.kind\n\t\t\t\t\t};\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst invalid = validateValue(child, childValue);\n\t\t\t\tif (invalid != null) return {\n\t\t\t\t\tpath: [key, ...invalid.path],\n\t\t\t\t\texpected: invalid.expected\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn;\n\t\tcase \"record\":\n\t\t\tif (!isPlainObject$1(value)) return {\n\t\t\t\tpath: [],\n\t\t\t\texpected: \"record\"\n\t\t\t};\n\t\t\tif (node.maxKeys != null && Object.keys(value).length > node.maxKeys) return {\n\t\t\t\tpath: [],\n\t\t\t\texpected: `a record with at most ${node.maxKeys} entries`\n\t\t\t};\n\t\t\tfor (const [key, entry] of Object.entries(value)) {\n\t\t\t\tconst invalid = validateValue(node.value, entry);\n\t\t\t\tif (invalid != null) return {\n\t\t\t\t\tpath: [key, ...invalid.path],\n\t\t\t\t\texpected: invalid.expected\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn;\n\t\tcase \"array\":\n\t\t\tif (!Array.isArray(value)) return {\n\t\t\t\tpath: [],\n\t\t\t\texpected: \"array\"\n\t\t\t};\n\t\t\tif (node.maxItems != null && value.length > node.maxItems) return {\n\t\t\t\tpath: [],\n\t\t\t\texpected: `an array of at most ${node.maxItems} items`\n\t\t\t};\n\t\t\tfor (let i = 0; i < value.length; i++) {\n\t\t\t\tconst invalid = validateValue(node.item, value[i]);\n\t\t\t\tif (invalid != null) return {\n\t\t\t\t\tpath: [i, ...invalid.path],\n\t\t\t\t\texpected: invalid.expected\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn;\n\t\tcase \"standard\": {\n\t\t\tconst result = node.schema[\"~standard\"].validate(value);\n\t\t\tif (result instanceof Promise) return {\n\t\t\t\tpath: [],\n\t\t\t\texpected: \"a synchronous standard-schema validator\"\n\t\t\t};\n\t\t\treturn result.issues == null ? void 0 : {\n\t\t\t\tpath: [],\n\t\t\t\texpected: result.issues[0]?.message ?? \"standard-schema pass\"\n\t\t\t};\n\t\t}\n\t}\n}\n//#endregion\n//#region src/realm/RealmWire/keyDict.ts\n/**\n* Dynamic record-key interning: record keys are arbitrary strings\n* (nanoids, user ids); after their first appearance they travel as small ints. The server owns id\n* assignment (eager, on first committed write touching the key) and sends each connection the\n* `keyDict` delta entries it hasn't seen before any frame that uses them; clients only ever\n* *resolve*. Ids are engine-global per realm instance — the per-signature shared encode can then\n* contain interned ids while the (tiny) dict deltas stay per-connection.\n*/\nvar RealmKeyDict = class {\n\t_toId = /* @__PURE__ */ new Map();\n\t_toKey = [];\n\t/** Intern a key (assigning the next id on first sight) — server side. */\n\tintern(key) {\n\t\tlet id = this._toId.get(key);\n\t\tif (id == null) {\n\t\t\tid = this._toKey.length;\n\t\t\tthis._toId.set(key, id);\n\t\t\tthis._toKey.push(key);\n\t\t}\n\t\treturn id;\n\t}\n\t/** The id for a key when already interned (encode-side lookup that must not assign). */\n\tidOf(key) {\n\t\treturn this._toId.get(key);\n\t}\n\t/** Resolve an interned id back to its key — client side (undefined = unknown id). */\n\tkeyOf(id) {\n\t\treturn this._toKey[id];\n\t}\n\t/** Load delta entries from a `keyDict`/`hydrate` frame — client side. */\n\tload(entries) {\n\t\tfor (const [key, id] of entries) {\n\t\t\tthis._toId.set(key, id);\n\t\t\tthis._toKey[id] = key;\n\t\t}\n\t}\n\tget size() {\n\t\treturn this._toId.size;\n\t}\n\t/** Drop all entries — a client clears on re-hello (a woken server session reassigns ids). */\n\tclear() {\n\t\tthis._toId.clear();\n\t\tthis._toKey.length = 0;\n\t}\n};\n//#endregion\n//#region src/realm/RealmWire/realmFrame.types.ts\n/**\n* The realm wire protocol: every frame is a msgpack fixarray `[kind, slot, …]` riding\n* the wire frame-protocol port at prefix `0x01` (M1 seam). The **slot** is a client-assigned small\n* int established by `hello`, so several realms — or several instances — share one peer link with\n* a one-byte discriminator per frame.\n*\n* Identity note (deviation D-13): v1 protocols are secure-duplex-only (D-11), so the connection is\n* already authenticated when the first realm frame arrives — `hello` carries no credential of its\n* own; the server resolves coordinates from the connection identity via its `resolveAvatar` hook.\n*/\nconst REALM_FRAME_KIND = {\n\thello: 0,\n\thydrate: 1,\n\tpatches: 2,\n\twrite: 3,\n\tintent: 4,\n\tack: 5,\n\treject: 6,\n\tkeyDict: 7,\n\tdetach: 8,\n\t/**\n\t* Client→server capability advertisement. Sent right after\n\t* every `hello` (fresh attach, reconnect, probe) so a hibernation-woken server — which lost the\n\t* per-session feature state — re-learns them for free. An old server decodes an unknown kind →\n\t* drops it → never emits the features it names; a new server with a client that never sends this\n\t* frame sees no features and stays on the legacy per-frame path. Both skew directions are safe by\n\t* the drop-unknown rule the codec + acceptor already enforce.\n\t*/\n\tclientCaps: 9,\n\t/**\n\t* Server→client egress envelope (Phase 1 wire; Phase 2 emits it). Carries several complete realm\n\t* frames as one message — see {@link IRealmFrameBatch}. Emitted **only** to a connection that\n\t* advertised {@link REALM_FEATURE.batch}; never sent client→server. Nesting is forbidden.\n\t*/\n\tbatch: 10\n};\n/** Reverse lookup: frame-kind int → its name (devtools frame attribution). */\nconst REALM_FRAME_KIND_NAME = Object.fromEntries(Object.entries(REALM_FRAME_KIND).map(([name, kind]) => [kind, name]));\n/**\n* Negotiated egress features a client advertises via a `clientCaps` frame. Kept as short opaque\n* tokens (they travel per hello) — bump the token, never repurpose one, when the shape changes.\n*/\nconst REALM_FEATURE = { \n/** The v1 batch envelope: the server may fold this connection's frames into a {@link IRealmFrameBatch}. */\nbatch: \"b1\" };\n/** Patch op ints — 1:1 with immer's `replace`/`add`/`remove`. */\nconst REALM_OP = {\n\treplace: 0,\n\tadd: 1,\n\tremove: 2\n};\n/** The `detach.reason` asking the client to re-attach (hibernation wake / unknown slot heal). */\nconst REALM_DETACH_REASON_REHELLO = \"rehello\";\n//#endregion\n//#region src/realm/RealmWire/realmFrameCodec.ts\n/**\n* The realm frame codec: encode side builds each frame's msgpack fixarray; decode\n* side strictly validates shape and rejects with a typed `err_realm.frame_invalid` — garbage bytes\n* never throw-through as raw msgpackr/TypeErrors into the engines (the fuzz gate).\n*/\nfunction invalid(reason) {\n\tthrow err_realm.fromId(\"frame_invalid\", { reason });\n}\nfunction expectInt(value, what) {\n\tif (typeof value !== \"number\" || !Number.isInteger(value)) invalid(`${what} must be an int`);\n\treturn value;\n}\nfunction expectString(value, what) {\n\tif (typeof value !== \"string\") invalid(`${what} must be a string`);\n\treturn value;\n}\nfunction expectSlot(value) {\n\tconst slot = expectInt(value, \"slot\");\n\tif (slot < 0 || slot > 255) invalid(`slot ${slot} out of range`);\n\treturn slot;\n}\nfunction expectPath(value) {\n\tif (!Array.isArray(value) || value.length === 0) invalid(\"op path must be a non-empty array\");\n\tfor (const seg of value) if (typeof seg === \"number\") {\n\t\tif (!Number.isInteger(seg) || seg < 0) invalid(`invalid path token ${seg}`);\n\t} else if (typeof seg !== \"string\") invalid(\"path segments must be ints or strings\");\n\treturn value;\n}\nfunction expectOps(value) {\n\tif (!Array.isArray(value)) invalid(\"ops must be an array\");\n\tfor (const op of value) {\n\t\tif (!Array.isArray(op) || op.length < 2 || op.length > 3) invalid(\"malformed op\");\n\t\tconst kind = expectInt(op[0], \"op kind\");\n\t\tif (kind !== REALM_OP.replace && kind !== REALM_OP.add && kind !== REALM_OP.remove) invalid(`unknown op kind ${kind}`);\n\t\texpectPath(op[1]);\n\t\tif (kind === REALM_OP.remove && op.length !== 2) invalid(\"remove op carries no value\");\n\t\tif (kind !== REALM_OP.remove && op.length !== 3) invalid(\"replace/add op requires a value\");\n\t}\n\treturn value;\n}\nfunction expectLimits(value) {\n\tif (!Array.isArray(value) || value.length !== 3) invalid(\"hydrate limits must be 3 ints\");\n\texpectInt(value[0], \"limits.maxPatchesPerFrame\");\n\texpectInt(value[1], \"limits.maxFrameBytes\");\n\texpectInt(value[2], \"limits.writeRatePerSecond\");\n\treturn value;\n}\nfunction expectAvatarEcho(value) {\n\tif (!Array.isArray(value) || value.length !== 3) invalid(\"hydrate avatar must be 3 strings\");\n\texpectString(value[0], \"avatar.type\");\n\texpectString(value[1], \"avatar.persistentId\");\n\texpectString(value[2], \"avatar.instanceId\");\n\treturn value;\n}\n/** Hard caps on the capability advertisement — `clientCaps` is processed BEFORE the engine's\n* ingress limits (it is pre-rate-limit bookkeeping), so the codec itself must bound it. */\nconst MAX_CLIENT_CAPS_FEATURES = 16;\nconst MAX_CLIENT_CAPS_FEATURE_LENGTH = 32;\nfunction expectFeatures(value) {\n\tif (!Array.isArray(value)) invalid(\"clientCaps features must be an array\");\n\tif (value.length > MAX_CLIENT_CAPS_FEATURES) invalid(\"clientCaps features list too long\");\n\tfor (const feature of value) if (expectString(feature, \"clientCaps feature\").length > MAX_CLIENT_CAPS_FEATURE_LENGTH) invalid(\"clientCaps feature too long\");\n\treturn value;\n}\nfunction expectDictEntries(value) {\n\tif (!Array.isArray(value)) invalid(\"keyDict entries must be an array\");\n\tfor (const entry of value) {\n\t\tif (!Array.isArray(entry) || entry.length !== 2) invalid(\"malformed keyDict entry\");\n\t\texpectString(entry[0], \"keyDict key\");\n\t\tif (expectInt(entry[1], \"keyDict id\") < 0) invalid(\"keyDict id must be >= 0\");\n\t}\n\treturn value;\n}\nfunction encodeHello(frame) {\n\treturn pack([\n\t\tREALM_FRAME_KIND.hello,\n\t\tframe.slot,\n\t\tframe.realmId,\n\t\tframe.schemaHash,\n\t\tframe.lastKnownVersion,\n\t\tframe.epoch ?? null\n\t]);\n}\nfunction encodeHydrate(frame) {\n\treturn pack([\n\t\tREALM_FRAME_KIND.hydrate,\n\t\tframe.slot,\n\t\tframe.version,\n\t\tframe.stateBlob,\n\t\tframe.keyDictSeed,\n\t\tframe.more,\n\t\tframe.epoch,\n\t\tframe.limits,\n\t\tframe.avatar\n\t]);\n}\nfunction encodePatches(frame) {\n\treturn pack([\n\t\tREALM_FRAME_KIND.patches,\n\t\tframe.slot,\n\t\tframe.fromVersion,\n\t\tframe.toVersion,\n\t\tframe.ops\n\t]);\n}\nfunction encodeWrite(frame) {\n\treturn pack([\n\t\tREALM_FRAME_KIND.write,\n\t\tframe.slot,\n\t\tframe.clientSeq,\n\t\tframe.basisVersion,\n\t\tframe.ops\n\t]);\n}\nfunction encodeIntent(frame) {\n\treturn pack([\n\t\tREALM_FRAME_KIND.intent,\n\t\tframe.slot,\n\t\tframe.clientSeq,\n\t\tframe.intentToken,\n\t\tframe.input\n\t]);\n}\nfunction encodeAck(frame) {\n\treturn pack([\n\t\tREALM_FRAME_KIND.ack,\n\t\tframe.slot,\n\t\tframe.clientSeq,\n\t\tframe.version\n\t]);\n}\nfunction encodeReject(frame) {\n\treturn pack([\n\t\tREALM_FRAME_KIND.reject,\n\t\tframe.slot,\n\t\tframe.clientSeq,\n\t\tframe.error\n\t]);\n}\nfunction encodeKeyDict(frame) {\n\treturn pack([\n\t\tREALM_FRAME_KIND.keyDict,\n\t\tframe.slot,\n\t\tframe.entries\n\t]);\n}\nfunction encodeDetach(frame) {\n\treturn pack([\n\t\tREALM_FRAME_KIND.detach,\n\t\tframe.slot,\n\t\tframe.reason ?? null\n\t]);\n}\nfunction encodeClientCaps(frame) {\n\treturn pack([\n\t\tREALM_FRAME_KIND.clientCaps,\n\t\tframe.slot,\n\t\tframe.features\n\t]);\n}\n/**\n* The egress envelope (Phase 1 wire). Takes **already-encoded** child frame bytes — the server\n* batches the exact frames it would otherwise send one at a time. The decoder re-inflates them into\n* `frames`, so encode/decode are deliberately asymmetric (bytes in, decoded frames out).\n*/\nfunction encodeBatch(frame) {\n\treturn pack([\n\t\tREALM_FRAME_KIND.batch,\n\t\tframe.slot,\n\t\tframe.payloads\n\t]);\n}\n/**\n* Decode one realm protocol payload (prefix already stripped by the mux). Throws\n* `err_realm.frame_invalid` on any malformed input — never a raw decode error.\n*/\nfunction decodeRealmFrame(payload) {\n\tlet raw;\n\ttry {\n\t\traw = unpack(payload);\n\t} catch {\n\t\tinvalid(\"not msgpack\");\n\t}\n\tif (!Array.isArray(raw) || raw.length < 2) invalid(\"frame must be a [kind, slot, …] array\");\n\tconst kind = expectInt(raw[0], \"kind\");\n\tconst slot = expectSlot(raw[1]);\n\tswitch (kind) {\n\t\tcase REALM_FRAME_KIND.hello:\n\t\t\tif (raw.length !== 6) invalid(\"hello must have 6 elements\");\n\t\t\tif (raw[5] != null && typeof raw[5] !== \"string\") invalid(\"hello epoch must be a string\");\n\t\t\treturn {\n\t\t\t\tkind,\n\t\t\t\tslot,\n\t\t\t\trealmId: expectString(raw[2], \"realmId\"),\n\t\t\t\tschemaHash: expectString(raw[3], \"schemaHash\"),\n\t\t\t\tlastKnownVersion: expectInt(raw[4], \"lastKnownVersion\"),\n\t\t\t\tepoch: raw[5] ?? void 0\n\t\t\t};\n\t\tcase REALM_FRAME_KIND.hydrate:\n\t\t\tif (raw.length !== 9) invalid(\"hydrate must have 9 elements\");\n\t\t\tif (!(raw[3] instanceof Uint8Array)) invalid(\"hydrate stateBlob must be bytes\");\n\t\t\tif (typeof raw[5] !== \"boolean\") invalid(\"hydrate more must be a boolean\");\n\t\t\treturn {\n\t\t\t\tkind,\n\t\t\t\tslot,\n\t\t\t\tversion: expectInt(raw[2], \"version\"),\n\t\t\t\tstateBlob: raw[3],\n\t\t\t\tkeyDictSeed: expectDictEntries(raw[4]),\n\t\t\t\tmore: raw[5],\n\t\t\t\tepoch: expectString(raw[6], \"hydrate epoch\"),\n\t\t\t\tlimits: expectLimits(raw[7]),\n\t\t\t\tavatar: expectAvatarEcho(raw[8])\n\t\t\t};\n\t\tcase REALM_FRAME_KIND.patches:\n\t\t\tif (raw.length !== 5) invalid(\"patches must have 5 elements\");\n\t\t\treturn {\n\t\t\t\tkind,\n\t\t\t\tslot,\n\t\t\t\tfromVersion: expectInt(raw[2], \"fromVersion\"),\n\t\t\t\ttoVersion: expectInt(raw[3], \"toVersion\"),\n\t\t\t\tops: expectOps(raw[4])\n\t\t\t};\n\t\tcase REALM_FRAME_KIND.write:\n\t\t\tif (raw.length !== 5) invalid(\"write must have 5 elements\");\n\t\t\treturn {\n\t\t\t\tkind,\n\t\t\t\tslot,\n\t\t\t\tclientSeq: expectInt(raw[2], \"clientSeq\"),\n\t\t\t\tbasisVersion: expectInt(raw[3], \"basisVersion\"),\n\t\t\t\tops: expectOps(raw[4])\n\t\t\t};\n\t\tcase REALM_FRAME_KIND.intent:\n\t\t\tif (raw.length !== 5) invalid(\"intent must have 5 elements\");\n\t\t\treturn {\n\t\t\t\tkind,\n\t\t\t\tslot,\n\t\t\t\tclientSeq: expectInt(raw[2], \"clientSeq\"),\n\t\t\t\tintentToken: expectInt(raw[3], \"intentToken\"),\n\t\t\t\tinput: raw[4]\n\t\t\t};\n\t\tcase REALM_FRAME_KIND.ack:\n\t\t\tif (raw.length !== 4) invalid(\"ack must have 4 elements\");\n\t\t\treturn {\n\t\t\t\tkind,\n\t\t\t\tslot,\n\t\t\t\tclientSeq: expectInt(raw[2], \"clientSeq\"),\n\t\t\t\tversion: expectInt(raw[3], \"version\")\n\t\t\t};\n\t\tcase REALM_FRAME_KIND.reject:\n\t\t\tif (raw.length !== 4) invalid(\"reject must have 4 elements\");\n\t\t\tif (typeof raw[3] !== \"object\" || raw[3] == null || Array.isArray(raw[3])) invalid(\"reject error must be a map\");\n\t\t\treturn {\n\t\t\t\tkind,\n\t\t\t\tslot,\n\t\t\t\tclientSeq: expectInt(raw[2], \"clientSeq\"),\n\t\t\t\terror: raw[3]\n\t\t\t};\n\t\tcase REALM_FRAME_KIND.keyDict:\n\t\t\tif (raw.length !== 3) invalid(\"keyDict must have 3 elements\");\n\t\t\treturn {\n\t\t\t\tkind,\n\t\t\t\tslot,\n\t\t\t\tentries: expectDictEntries(raw[2])\n\t\t\t};\n\t\tcase REALM_FRAME_KIND.detach:\n\t\t\tif (raw.length !== 3) invalid(\"detach must have 3 elements\");\n\t\t\tif (raw[2] != null && typeof raw[2] !== \"string\") invalid(\"detach reason must be a string\");\n\t\t\treturn {\n\t\t\t\tkind,\n\t\t\t\tslot,\n\t\t\t\treason: raw[2] ?? void 0\n\t\t\t};\n\t\tcase REALM_FRAME_KIND.clientCaps:\n\t\t\tif (raw.length !== 3) invalid(\"clientCaps must have 3 elements\");\n\t\t\treturn {\n\t\t\t\tkind,\n\t\t\t\tslot,\n\t\t\t\tfeatures: expectFeatures(raw[2])\n\t\t\t};\n\t\tcase REALM_FRAME_KIND.batch: {\n\t\t\tif (raw.length !== 3) invalid(\"batch must have 3 elements\");\n\t\t\tif (!Array.isArray(raw[2])) invalid(\"batch payloads must be an array\");\n\t\t\tconst frames = [];\n\t\t\tfor (const payload of raw[2]) {\n\t\t\t\tif (!(payload instanceof Uint8Array)) invalid(\"batch payload must be bytes\");\n\t\t\t\tconst child = decodeRealmFrame(payload);\n\t\t\t\tif (child.kind === REALM_FRAME_KIND.batch) invalid(\"batch may not nest\");\n\t\t\t\tframes.push(child);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tkind,\n\t\t\t\tslot,\n\t\t\t\tframes\n\t\t\t};\n\t\t}\n\t\tdefault: invalid(`unknown frame kind ${kind}`);\n\t}\n}\n//#endregion\n//#region src/realm/RealmWire/unsafeKey.ts\n/**\n* Prototype-pollution deny-list for dynamic record keys. Wire segments\n* become object keys in the state tree — on server apply and on client/replica projection. Three of\n* them are never legitimate `t.id()` record keys and are actively dangerous as object keys:\n*\n* - `__proto__` — assigning it can repoint an object's prototype (classic prototype pollution).\n* - `constructor` / `prototype` — shadow built-ins; a stepping stone to the same class of attack.\n*\n* A hostile client (server-side) or a hostile/replayed server frame (client-side) is the threat; a\n* well-behaved peer never produces these, so the deny-list is a pure no-op in practice (a golden\n* asserts the reference schema uses none of them as field names either). One predicate, every path —\n* the server rejects the frame, the client/replica drops the offending patch.\n*/\nconst UNSAFE_KEYS = /* @__PURE__ */ new Set([\n\t\"__proto__\",\n\t\"constructor\",\n\t\"prototype\"\n]);\n/** True when a decoded path segment is a prototype-pollution vector. */\nfunction isUnsafeKey(segment) {\n\treturn typeof segment === \"string\" && UNSAFE_KEYS.has(segment);\n}\n/** True when any segment of a decoded (name) path is unsafe — the per-path screen for both sides. */\nfunction pathHasUnsafeKey(path) {\n\treturn path.some(isUnsafeKey);\n}\n/**\n* True when a patch **value** carries an unsafe own key anywhere in its object/array tree. A coarse\n* write/intent that creates a whole record entry emits the entry as one patch whose *value* holds\n* the dynamic keys (they never appear in the patch path), so the path screen alone would miss them.\n* Own keys only (`Object.entries`), so an inherited `constructor` is not falsely flagged; a decoded\n* own `__proto__` (e.g. from `JSON.parse`/msgpack) is. Values are schema-bounded, so the recursion\n* is bounded.\n*/\nfunction valueHasUnsafeKey(value) {\n\tif (value == null || typeof value !== \"object\") return false;\n\tif (Array.isArray(value)) return value.some(valueHasUnsafeKey);\n\tfor (const [key, child] of Object.entries(value)) if (isUnsafeKey(key) || valueHasUnsafeKey(child)) return true;\n\treturn false;\n}\n//#endregion\n//#region src/realm/RealmWire/wirePatch.ts\n/**\n* Immer patches ↔ realm wire ops. Wire ops always use **name-space string paths**\n* tokenized through the realm's token map; immer patches on realm state only ever contain string\n* segments *except* inside arrays — and arrays are leaf-replace-only on the wire (proposal §7.8),\n* so {@link canonicalizeStatePatches} lifts any array-interior patch to a whole-array `replace`\n* before encoding.\n*/\nconst IMMER_OP_TO_WIRE = {\n\treplace: REALM_OP.replace,\n\tadd: REALM_OP.add,\n\tremove: REALM_OP.remove\n};\nconst WIRE_OP_TO_IMMER = {\n\t[REALM_OP.replace]: \"replace\",\n\t[REALM_OP.add]: \"add\",\n\t[REALM_OP.remove]: \"remove\"\n};\nfunction unwrapOptional$3(node) {\n\treturn node.kind === \"optional\" ? unwrapOptional$3(node.inner) : node;\n}\n/** The schema node a name path addresses (undefined when the path leaves the schema). */\nfunction schemaNodeAtPath(root, path) {\n\tlet node;\n\tlet entries = root;\n\tfor (const seg of path) {\n\t\tif (entries != null) {\n\t\t\tnode = typeof seg === \"string\" ? entries[seg] : void 0;\n\t\t\tentries = void 0;\n\t\t} else if (node != null) {\n\t\t\tconst inner = unwrapOptional$3(node);\n\t\t\tif (inner.kind === \"object\") node = inner.entries[seg];\n\t\t\telse if (inner.kind === \"record\") node = inner.value;\n\t\t\telse return void 0;\n\t\t}\n\t\tif (node == null) return void 0;\n\t}\n\treturn node;\n}\nfunction getAtPath$4(state, path) {\n\tlet current = state;\n\tfor (const seg of path) {\n\t\tif (current == null || typeof current !== \"object\") return void 0;\n\t\tcurrent = current[seg];\n\t}\n\treturn current;\n}\n/** The path-prefix length up to (and including) the first array node, or `undefined` if none. */\nfunction arrayCutIndex(root, path) {\n\tfor (let i = 1; i < path.length; i++) {\n\t\tconst node = schemaNodeAtPath(root, path.slice(0, i));\n\t\tif (node != null && unwrapOptional$3(node).kind === \"array\") return i;\n\t}\n}\n/**\n* Normalize immer patches for the wire: any patch *inside* an array node is lifted to a single\n* whole-array `replace` (value read from the post-mutation state), and duplicate lifts of the\n* same array collapse. All surviving paths are pure string name paths.\n*/\nfunction canonicalizeStatePatches(patches, stateAfter, schemaRoot) {\n\tconst out = [];\n\tconst liftedArrays = /* @__PURE__ */ new Set();\n\tfor (const patch of patches) {\n\t\tconst cut = arrayCutIndex(schemaRoot, patch.path);\n\t\tif (cut == null || cut === patch.path.length) {\n\t\t\tout.push(patch);\n\t\t\tcontinue;\n\t\t}\n\t\tconst arrayPath = patch.path.slice(0, cut);\n\t\tconst key = arrayPath.join(\"\\0\");\n\t\tif (liftedArrays.has(key)) continue;\n\t\tliftedArrays.add(key);\n\t\tout.push({\n\t\t\top: \"replace\",\n\t\t\tpath: arrayPath,\n\t\t\tvalue: getAtPath$4(stateAfter, arrayPath)\n\t\t});\n\t}\n\treturn out;\n}\n/**\n* Conflate an ORDERED run of authoritative patch ops to the shortest final-state-equivalent run\n*. Used for replay: a reconnect inside the log window merges\n* every missed version's ops, which for a 60 Hz cursor is ~1000 dead intermediate positions in one\n* frame. Server→client ops are absolute-value ops (`add`/`replace` carry the whole subtree; `remove`\n* deletes it), so a later op at path `P` makes every earlier op AT `P` OR UNDER `P` redundant — the\n* later op overwrites/removes that whole subtree. One pass, evicting each new op's covered\n* predecessors and keeping everything else IN PLACE:\n*\n*   - a later op at `P` evicts earlier ops at `P` or a descendant of `P` (covered — dropped);\n*   - an earlier op at an ANCESTOR of `P` is kept, in place (it built the container `P` mutates —\n*     dropping it would orphan `P`);\n*   - unrelated ops are kept.\n*\n* Survivors keep their relative order, so the result is a **subsequence** of the input: on any base\n* where the raw run applies cleanly (i.e. every replay base — the server applied it), the conflated\n* run applies cleanly to the same final state.\n*\n* This is deliberately NOT the client's exact-path `dedupeByPath` (RealmClient) — that keeps only the\n* last write per *identical* path, which is right for a client's own single-leaf write stream but\n* would leave a stale `players.alice.x` beside a later whole-`players.alice` replace. Conflation is\n* subtree-aware; dedupe is not.\n*/\nfunction conflateOps(ops) {\n\tconst result = [];\n\tfor (const op of ops) {\n\t\tfor (let i = result.length - 1; i >= 0; i--) if (isPathPrefix(op.path, result[i].path)) result.splice(i, 1);\n\t\tresult.push(op);\n\t}\n\treturn result;\n}\n/** `prefix ⊑ path`: `path` equals `prefix` or is a descendant of it (segment-wise). */\nfunction isPathPrefix(prefix, path) {\n\tif (prefix.length > path.length) return false;\n\tfor (let i = 0; i < prefix.length; i++) if (prefix[i] !== path[i]) return false;\n\treturn true;\n}\n/** Name-space immer patches → wire ops (encode side). */\nfunction namePatchesToWireOps(patches, tokens, internKey) {\n\treturn patches.map((patch) => {\n\t\tconst path = tokens.tokenizePath(patch.path, internKey);\n\t\tif (patch.op === \"remove\") return [REALM_OP.remove, path];\n\t\treturn [\n\t\t\tIMMER_OP_TO_WIRE[patch.op],\n\t\t\tpath,\n\t\t\tpatch.value\n\t\t];\n\t});\n}\n/** Wire ops → name-space immer patches (decode side). */\nfunction wireOpsToNamePatches(ops, tokens, resolveKey) {\n\treturn ops.map((op) => {\n\t\tconst path = tokens.detokenizePath(op[1], resolveKey);\n\t\tif (op[0] === REALM_OP.remove) return {\n\t\t\top: \"remove\",\n\t\t\tpath\n\t\t};\n\t\treturn {\n\t\t\top: WIRE_OP_TO_IMMER[op[0]],\n\t\t\tpath,\n\t\t\tvalue: op[2]\n\t\t};\n\t});\n}\n//#endregion\n//#region src/realm/RealmDefinition/Rules/evalRules.ts\nfunction evalViewCond(cond, context) {\n\tif (typeof cond === \"function\") return cond(context);\n\tif (cond.kind === \"everyone\") return true;\n\treturn cond.types.includes(context.avatar.type);\n}\n/**\n* Evaluate an alter condition for an **avatar** write. Returns the rule verdict, or the sentinel\n* `\"serverOnly\"` when the path is not avatar-writable at all (callers map it to\n* `err_realm.unauthorized_coordinate`). Prediction passes `serverExtras: undefined`.\n*/\nfunction evalAlterCond(cond, context, serverExtras) {\n\tif (typeof cond === \"function\") return cond(context);\n\tswitch (cond.kind) {\n\t\tcase \"serverOnly\": return \"serverOnly\";\n\t\tcase \"serverChecked\":\n\t\t\tif (serverExtras == null) return true;\n\t\t\treturn cond.fn({\n\t\t\t\t...context,\n\t\t\t\t...serverExtras\n\t\t\t});\n\t\tcase \"all\":\n\t\t\tfor (const part of cond.conds) {\n\t\t\t\tconst verdict = evalAlterCond(part, context, serverExtras);\n\t\t\t\tif (verdict !== true) return verdict;\n\t\t\t}\n\t\t\treturn true;\n\t}\n}\n/** The slicer's signature-group key — view rules may not read `instanceId` (see module doc). */\nfunction viewSignatureKey(avatar) {\n\treturn `${avatar.type}\\0${avatar.persistentId}`;\n}\n//#endregion\n//#region src/realm/RealmServer/expandWrite.ts\n/**\n* Subtree-write expansion: an object-valued patch — including a\n* whole record-entry `add`/`remove` — expands to **every leaf path it covers**, and the write\n* passes only if every covered leaf's own most-specific rule passes. Creation is just the first\n* write; deletion is a `remove` through the same gate; rules never need \"create\" clauses.\n*\n* For `add`/`replace`, dynamic record keys are enumerated from the written value **and** the\n* current state at that path (a whole-record replace also removes entries the value omits — those\n* leaves are covered too). For `remove`, from the current state alone. Expansion is bounded by\n* `maxLeaves` (an ingress limit — a hostile deep-subtree write must not become CPU).\n*/\nfunction unwrapOptional$2(node) {\n\treturn node.kind === \"optional\" ? unwrapOptional$2(node.inner) : node;\n}\nfunction getAtPath$3(state, path) {\n\tlet current = state;\n\tfor (const seg of path) {\n\t\tif (current == null || typeof current !== \"object\") return void 0;\n\t\tcurrent = current[seg];\n\t}\n\treturn current;\n}\nvar ExpansionOverflowError = class extends Error {\n\tconstructor(max) {\n\t\tsuper(`subtree write expands past the ${max}-leaf limit`);\n\t}\n};\nfunction expandWriteToLeaves(options) {\n\tconst node = schemaNodeAtPath(options.schemaRoot, options.path);\n\tif (node == null) throw new Error(`expandWriteToLeaves: path leaves the schema (${options.path.join(\".\")})`);\n\tconst leaves = [];\n\tconst push = (leaf) => {\n\t\tif (leaves.length >= options.maxLeaves) throw new ExpansionOverflowError(options.maxLeaves);\n\t\tleaves.push(leaf);\n\t};\n\tconst walk = (schemaNode, path, value, prev) => {\n\t\tconst inner = unwrapOptional$2(schemaNode);\n\t\tif (inner.kind === \"object\") {\n\t\t\tfor (const [key, child] of Object.entries(inner.entries)) walk(child, [...path, key], value == null ? void 0 : value[key], prev == null ? void 0 : prev[key]);\n\t\t\treturn;\n\t\t}\n\t\tif (inner.kind === \"record\") {\n\t\t\tconst keys = /* @__PURE__ */ new Set();\n\t\t\tif (value != null && typeof value === \"object\") for (const key of Object.keys(value)) keys.add(key);\n\t\t\tif (prev != null && typeof prev === \"object\") for (const key of Object.keys(prev)) keys.add(key);\n\t\t\tfor (const key of keys) walk(inner.value, [...path, key], value == null ? void 0 : value[key], prev == null ? void 0 : prev[key]);\n\t\t\treturn;\n\t\t}\n\t\tpush(path);\n\t};\n\tconst prev = getAtPath$3(options.state, options.path);\n\twalk(node, [...options.path], options.op === \"remove\" ? void 0 : options.value, prev);\n\treturn leaves;\n}\n//#endregion\n//#region src/realm/RealmDefinition/Schema/boundedState.ts\n/**\n* State-aware bound enforcement (the second layer over `validateValue`'s per-value checks).\n* `validateValue` only ever sees the value being written, so it cannot catch a bound whose truth\n* lives in the *surrounding* state — the canonical case: `t.record(…, { maxKeys: 8 })` filled one\n* incremental `record.$id` add at a time, where each child value is individually valid. These\n* walks run against the **candidate next state** after a whole patch batch (so remove+add nets\n* out), and once over the full tree at boot/restore/migration.\n*\n* Everything here is bounds-only and skip-fast: a schema without bounds costs one memoized lookup\n* and nothing else, and subtrees carrying no bounds are never entered.\n*/\nconst HAS_BOUNDS = /* @__PURE__ */ new WeakMap();\nfunction nodeHasBounds(node) {\n\tconst cached = HAS_BOUNDS.get(node);\n\tif (cached != null) return cached;\n\tlet result;\n\tswitch (node.kind) {\n\t\tcase \"string\":\n\t\t\tresult = node.maxLength != null;\n\t\t\tbreak;\n\t\tcase \"number\":\n\t\t\tresult = node.min != null || node.max != null || node.integer === true;\n\t\t\tbreak;\n\t\tcase \"boolean\":\n\t\tcase \"literal\":\n\t\tcase \"standard\":\n\t\t\tresult = false;\n\t\t\tbreak;\n\t\tcase \"optional\":\n\t\t\tresult = nodeHasBounds(node.inner);\n\t\t\tbreak;\n\t\tcase \"union\":\n\t\t\tresult = node.options.some(nodeHasBounds);\n\t\t\tbreak;\n\t\tcase \"object\":\n\t\t\tresult = Object.values(node.entries).some(nodeHasBounds);\n\t\t\tbreak;\n\t\tcase \"record\":\n\t\t\tresult = node.maxKeys != null || nodeHasBounds(node.value);\n\t\t\tbreak;\n\t\tcase \"array\":\n\t\t\tresult = node.maxItems != null || nodeHasBounds(node.item);\n\t\t\tbreak;\n\t}\n\tHAS_BOUNDS.set(node, result);\n\treturn result;\n}\n/** Whether any node in the state tree declares a bound — the engine's do-nothing fast path. */\nfunction schemaRootHasBounds(root) {\n\treturn Object.values(root).some(nodeHasBounds);\n}\nfunction unwrapOptional$1(node) {\n\treturn node.kind === \"optional\" ? unwrapOptional$1(node.inner) : node;\n}\nfunction isPlainObject(value) {\n\treturn typeof value === \"object\" && value != null && !Array.isArray(value);\n}\nfunction getAtPath$2(state, path) {\n\tlet current = state;\n\tfor (const seg of path) {\n\t\tif (current == null || typeof current !== \"object\") return void 0;\n\t\tcurrent = current[seg];\n\t}\n\treturn current;\n}\n/**\n* Bounds-only walk of a value against its node. Type mismatches are NOT reported here — shape\n* validation belongs to `validateValue` on the paths that run it; this walk only answers \"does\n* any declared bound fail\". The one exception is a union carrying bounds: bounds inside a union\n* are only checkable by structurally matching an option, so `validateValue` (which includes\n* bounds) is the matcher and a value matching no option reports as invalid.\n*/\nfunction checkBoundsDeep(node, value) {\n\tif (!nodeHasBounds(node)) return void 0;\n\tswitch (node.kind) {\n\t\tcase \"string\":\n\t\t\tif (typeof value === \"string\" && node.maxLength != null && value.length > node.maxLength) return {\n\t\t\t\tpath: [],\n\t\t\t\texpected: `a string of at most ${node.maxLength} characters`\n\t\t\t};\n\t\t\treturn;\n\t\tcase \"number\": return typeof value === \"number\" ? validateValue(node, value) : void 0;\n\t\tcase \"optional\": return value === void 0 ? void 0 : checkBoundsDeep(node.inner, value);\n\t\tcase \"union\": return validateValue(node, value);\n\t\tcase \"object\":\n\t\t\tif (!isPlainObject(value)) return void 0;\n\t\t\tfor (const [key, child] of Object.entries(node.entries)) {\n\t\t\t\tconst childValue = value[key];\n\t\t\t\tif (childValue === void 0) continue;\n\t\t\t\tconst invalid = checkBoundsDeep(child, childValue);\n\t\t\t\tif (invalid != null) return {\n\t\t\t\t\tpath: [key, ...invalid.path],\n\t\t\t\t\texpected: invalid.expected\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn;\n\t\tcase \"record\":\n\t\t\tif (!isPlainObject(value)) return void 0;\n\t\t\tif (node.maxKeys != null && Object.keys(value).length > node.maxKeys) return {\n\t\t\t\tpath: [],\n\t\t\t\texpected: `a record with at most ${node.maxKeys} entries`\n\t\t\t};\n\t\t\tif (!nodeHasBounds(node.value)) return void 0;\n\t\t\tfor (const [key, entry] of Object.entries(value)) {\n\t\t\t\tconst invalid = checkBoundsDeep(node.value, entry);\n\t\t\t\tif (invalid != null) return {\n\t\t\t\t\tpath: [key, ...invalid.path],\n\t\t\t\t\texpected: invalid.expected\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn;\n\t\tcase \"array\":\n\t\t\tif (!Array.isArray(value)) return void 0;\n\t\t\tif (node.maxItems != null && value.length > node.maxItems) return {\n\t\t\t\tpath: [],\n\t\t\t\texpected: `an array of at most ${node.maxItems} items`\n\t\t\t};\n\t\t\tif (!nodeHasBounds(node.item)) return void 0;\n\t\t\tfor (let i = 0; i < value.length; i++) {\n\t\t\t\tconst invalid = checkBoundsDeep(node.item, value[i]);\n\t\t\t\tif (invalid != null) return {\n\t\t\t\t\tpath: [i, ...invalid.path],\n\t\t\t\t\texpected: invalid.expected\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn;\n\t\tdefault: return;\n\t}\n}\n/** Full-tree bounds walk — boot, restore, and migration output, before any client attaches. */\nfunction validateBoundedStateTree(root, state) {\n\tfor (const [name, node] of Object.entries(root)) {\n\t\tif (!nodeHasBounds(node)) continue;\n\t\tconst invalid = checkBoundsDeep(node, state[name]);\n\t\tif (invalid != null) return {\n\t\t\tpath: [name, ...invalid.path],\n\t\t\texpected: invalid.expected\n\t\t};\n\t}\n}\n/**\n* Bounds gate for one commit: given the **candidate next state** and the batch's canonical patch\n* paths, check (a) `maxKeys` on every record *ancestor* a path descends into — the constraint an\n* incremental entry add changes without ever writing the record itself — and (b) all bounds\n* within each patched subtree's final value. Checks dedupe across the batch and run against the\n* final state, so remove+add sequences net out and multi-patch frames are judged once, atomically.\n*/\nfunction validateBoundedPatches(root, stateAfter, paths) {\n\tconst checked = /* @__PURE__ */ new Set();\n\tfor (const path of paths) {\n\t\tlet entries = root;\n\t\tlet node;\n\t\tfor (let i = 0; i < path.length; i++) {\n\t\t\tconst seg = path[i];\n\t\t\tif (entries != null) {\n\t\t\t\tnode = typeof seg === \"string\" ? entries[seg] : void 0;\n\t\t\t\tentries = void 0;\n\t\t\t} else if (node != null) {\n\t\t\t\tconst inner = unwrapOptional$1(node);\n\t\t\t\tif (inner.kind === \"object\") node = inner.entries[seg];\n\t\t\t\telse if (inner.kind === \"record\") node = inner.value;\n\t\t\t\telse node = void 0;\n\t\t\t}\n\t\t\tif (node == null) break;\n\t\t\tconst inner = unwrapOptional$1(node);\n\t\t\tif (inner.kind === \"record\" && inner.maxKeys != null && i + 1 < path.length) {\n\t\t\t\tconst prefix = path.slice(0, i + 1);\n\t\t\t\tconst key = `A:${prefix.join(\"\\0\")}`;\n\t\t\t\tif (!checked.has(key)) {\n\t\t\t\t\tchecked.add(key);\n\t\t\t\t\tconst value = getAtPath$2(stateAfter, prefix);\n\t\t\t\t\tif (isPlainObject(value) && Object.keys(value).length > inner.maxKeys) return {\n\t\t\t\t\t\tpath: [...prefix],\n\t\t\t\t\t\texpected: `a record with at most ${inner.maxKeys} entries`\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (node != null) {\n\t\t\tconst key = `T:${path.join(\"\\0\")}`;\n\t\t\tif (!checked.has(key)) {\n\t\t\t\tchecked.add(key);\n\t\t\t\tconst value = getAtPath$2(stateAfter, path);\n\t\t\t\tif (value !== void 0) {\n\t\t\t\t\tconst invalid = checkBoundsDeep(node, value);\n\t\t\t\t\tif (invalid != null) return {\n\t\t\t\t\t\tpath: [...path, ...invalid.path],\n\t\t\t\t\t\texpected: invalid.expected\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n//#endregion\n//#region src/realm/RealmServer/viewSlice.ts\nfunction leafVisible(ctx, path) {\n\tconst match = ctx.trie.match(path);\n\tif (match == null) return false;\n\treturn evalViewCond(match.rule.view, {\n\t\tavatar: ctx.avatar,\n\t\tparams: match.params\n\t});\n}\nfunction unwrapOptional(node) {\n\treturn node.kind === \"optional\" ? unwrapOptional(node.inner) : node;\n}\nconst OMIT = {\n\tvalue: void 0,\n\tanyVisible: false,\n\tstructural: false\n};\n/** Does `path` pass through a record entry? Its containers are then data, not structure. */\nfunction underRecordEntry(schemaRoot, path) {\n\tfor (let depth = 1; depth < path.length; depth++) {\n\t\tconst parent = schemaNodeAtPath(schemaRoot, path.slice(0, depth));\n\t\tif (parent != null && unwrapOptional(parent).kind === \"record\") return true;\n\t}\n\treturn false;\n}\nfunction pruneNode(ctx, node, value, path, inEntry = underRecordEntry(ctx.schemaRoot, path)) {\n\tif (value === void 0) return OMIT;\n\tconst inner = unwrapOptional(node);\n\tconst required = node.kind !== \"optional\";\n\tif (inner.kind === \"object\") {\n\t\tconst out = {};\n\t\tlet anyVisible = false;\n\t\tlet structural = false;\n\t\tfor (const [key, child] of Object.entries(inner.entries)) {\n\t\t\tconst pruned = pruneNode(ctx, child, value[key], [...path, key], inEntry);\n\t\t\tif (pruned.anyVisible || pruned.structural) out[key] = pruned.value;\n\t\t\tif (pruned.anyVisible) anyVisible = true;\n\t\t\tif (pruned.structural) structural = true;\n\t\t}\n\t\treturn {\n\t\t\tvalue: out,\n\t\t\tanyVisible,\n\t\t\tstructural: required && structural\n\t\t};\n\t}\n\tif (inner.kind === \"record\") {\n\t\tconst out = {};\n\t\tlet anyVisible = false;\n\t\tif (value != null && typeof value === \"object\") for (const [key, entry] of Object.entries(value)) {\n\t\t\tconst pruned = pruneNode(ctx, inner.value, entry, [...path, key], true);\n\t\t\tif (pruned.anyVisible) {\n\t\t\t\tout[key] = pruned.value;\n\t\t\t\tanyVisible = true;\n\t\t\t}\n\t\t}\n\t\tconst structural = required && !inEntry && ctx.trie.reachesBeneath(path);\n\t\treturn {\n\t\t\tvalue: out,\n\t\t\tanyVisible: anyVisible || leafVisible(ctx, path),\n\t\t\tstructural\n\t\t};\n\t}\n\treturn leafVisible(ctx, path) ? {\n\t\tvalue,\n\t\tanyVisible: true,\n\t\tstructural: false\n\t} : OMIT;\n}\n/**\n* Whether the avatar holds `path`'s parent, so a structure-only patch there reveals nothing: true\n* unless an optional sits between the top level and `path` that neither state shows the avatar.\n*/\nfunction holdsParent(ctx, path, states) {\n\tfor (let depth = path.length - 1; depth >= 2; depth--) {\n\t\tconst ancestorPath = path.slice(0, depth);\n\t\tconst ancestor = schemaNodeAtPath(ctx.schemaRoot, ancestorPath);\n\t\tif (ancestor?.kind !== \"optional\") continue;\n\t\treturn states.some((state) => state != null && pruneNode(ctx, ancestor, getAtPath$1(state, ancestorPath), ancestorPath).anyVisible);\n\t}\n\treturn true;\n}\n/** A sliced patch target ships for its visible content, or as structure inside a held parent. */\nfunction patchTargetShips(ctx, pruned, path, states) {\n\tif (pruned.anyVisible) return true;\n\treturn pruned.structural && holdsParent(ctx, path, states);\n}\n/** The avatar's sliced view of the whole state — the hydrate payload. */\nfunction sliceStateForAvatar(ctx, state) {\n\tconst out = {};\n\tfor (const [key, node] of Object.entries(ctx.schemaRoot)) out[key] = pruneNode(ctx, node, state[key], [key]).value ?? {};\n\treturn out;\n}\n/**\n* Slice one committed patch for an avatar: `undefined` = not visible at all; otherwise the patch,\n* possibly with a pruned value (a subtree patch spanning mixed-visibility leaves sends each\n* audience only its slice). `statePrev` (pre-commit) drives `remove` expansion; a replay path may\n* pass `undefined` — a `remove` that can't be proven invisible is then included (removing a key\n* the avatar never had must be a client-side no-op). `stateAfter` (post-commit), with `statePrev`,\n* decides whether the avatar holds an optional ancestor of a structure-only container patch.\n*/\nfunction slicePatchForAvatar(ctx, patch, statePrev, stateAfter) {\n\tconst path = patch.path;\n\tconst node = schemaNodeAtPath(ctx.schemaRoot, path);\n\tif (node == null) return void 0;\n\tconst inner = unwrapOptional(node);\n\tif (inner.kind !== \"object\" && inner.kind !== \"record\") return leafVisible(ctx, path) ? patch : void 0;\n\tif (patch.op === \"remove\") {\n\t\tconst prev = statePrev == null ? void 0 : getAtPath$1(statePrev, path);\n\t\tif (prev === void 0) return patch;\n\t\treturn patchTargetShips(ctx, pruneNode(ctx, node, prev, [...path]), path, [statePrev, stateAfter]) ? patch : void 0;\n\t}\n\tconst pruned = pruneNode(ctx, node, patch.value, [...path]);\n\tif (!patchTargetShips(ctx, pruned, path, [statePrev, stateAfter])) return void 0;\n\treturn {\n\t\top: patch.op,\n\t\tpath,\n\t\tvalue: pruned.value\n\t};\n}\n/**\n* Slice a transient region's whole-region replay refresh (the `replace <root> = <regionValue>` ops\n* {@link RealmServerEngine._buildReplayOps} appends). Unlike {@link slicePatchForAvatar}, this\n* ALWAYS returns a patch: a fully-pruned or empty region ships as `replace <root> = {}` rather than\n* being dropped by the \"omit empty containers\" rule. That drop is the bug behind Overshot's\n* stranded-forever `write_target_missing`: when a same-epoch wake wipes a transient region to empty\n* (or leaves only entries the avatar can't see), the empty refresh was sliced away, so the resuming\n* avatar never learned its OWN entry had vanished — its `confirmed` kept the stale entry, its\n* guarded `assertOnAttach` saw the entry \"present\" and never re-owned, and it looped on doomed leaf\n* writes until a full reload. The region container is structural (already in every hydrate as `{}`),\n* so shipping an empty replace is safe — it only clears stale entries.\n*/\nfunction sliceTransientRefreshForAvatar(ctx, patch) {\n\tconst path = patch.path;\n\tconst node = schemaNodeAtPath(ctx.schemaRoot, path);\n\tif (node == null) return patch;\n\treturn {\n\t\top: \"replace\",\n\t\tpath,\n\t\tvalue: pruneNode(ctx, node, patch.value, [...path]).value ?? {}\n\t};\n}\nfunction getAtPath$1(state, path) {\n\tlet current = state;\n\tfor (const seg of path) {\n\t\tif (current == null || typeof current !== \"object\") return void 0;\n\t\tcurrent = current[seg];\n\t}\n\treturn current;\n}\n//#endregion\n//#region src/realm/RealmServer/RealmServerEngine.ts\nenablePatches();\nconst DEFAULT_REALM_LIMITS = {\n\tmaxPatchesPerFrame: 64,\n\tmaxFrameBytes: 64 * 1024,\n\tmaxRecordKeyLength: 128,\n\tmaxExpandedLeaves: 256,\n\twriteRatePerSecond: 100,\n\twriteRateBurst: 200,\n\tmaxBreachesBeforeDetach: 10\n};\nfunction newTrafficCounters() {\n\treturn {\n\t\tingressFrames: 0,\n\t\tingressBytes: 0,\n\t\tegressMessages: 0,\n\t\tegressFrames: 0,\n\t\tegressBytes: 0\n\t};\n}\nconst DEFAULT_LOG_WINDOW = 512;\nfunction clientKey(avatar) {\n\treturn `${avatar.type} ${avatar.persistentId}`;\n}\n/**\n* Mint a log epoch: a random id identifying one history of one realm instance.\n* Uniqueness only needs to hold across *rebuilds of the same realm* (wiped storage, re-created\n* DO, migration) — collision means a stale avatar silently replays a foreign diff, so time +\n* randomness is plenty. Platform-clean on purpose (no `crypto` dependency).\n*/\nfunction mintEpoch() {\n\treturn `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;\n}\nvar RealmServerEngine = class {\n\t_realm;\n\t_ctx;\n\t_limits;\n\t_now;\n\t_instanceId;\n\t_state;\n\t/** Whether the schema declares any bounds — false skips every bounded-state walk. */\n\t_hasBounds;\n\t_version = 0;\n\t_mutating = false;\n\t/** The log epoch: identifies this history — replay requires an exact match. */\n\t_epoch;\n\t_log;\n\t_logWindow;\n\t/** Recent write touches for `touchedSince` CAS — bounded by the log window. */\n\t_touches = [];\n\t_dict = new RealmKeyDict();\n\t_connections = /* @__PURE__ */ new Map();\n\t_avatarConnCounts = /* @__PURE__ */ new Map();\n\t/**\n\t* Connections with queued egress (Phase 2). Holds the record even after `detachConnection` removes\n\t* it from `_connections`, so a detach notice / breach reject already queued still flushes. Insertion\n\t* order = flush order (Set preserves it).\n\t*/\n\t_dirtyConns = /* @__PURE__ */ new Set();\n\t/** Re-entrancy guard: a raw send can synchronously re-enter an entry point on an in-memory link\n\t* (a resend), whose own flush must be a no-op — the owning drain loop picks up the new frames. */\n\t_flushing = false;\n\t/** Server wire-tap listeners (devtools). Empty in production, so the emit is a hot-path no-op. */\n\t_trafficListeners = /* @__PURE__ */ new Set();\n\t_broadcastCoalesceMs;\n\t_scheduleBroadcast;\n\t/** Canonical name-patches accumulated across the open window's commits (conflated at flush). */\n\t_windowOps = [];\n\t/** The `statePrev` of the window's FIRST commit — the slicing basis for its `remove`s (V1). */\n\t_windowStartState;\n\t/** The version the open window began from — the flushed frame's `fromVersion`. */\n\t_windowFromVersion = 0;\n\t/** Cancel handle for the armed window timer (undefined = disarmed / no open window). */\n\t_windowTimerCancel;\n\t/**\n\t* Acks deferred into the current window (P3): a successful write/intent's ack must reach the client\n\t* AFTER that window's patches frame, so it rides the window flush — never the immediate outbox (which\n\t* empties at the end of `receiveFrame`, ahead of the patches). Dropped for a connection that detaches\n\t* mid-window.\n\t*/\n\t_pendingAcks = [];\n\t/**\n\t* Replay/duplicate high-water per connection **key** — the highest\n\t* `clientSeq` accepted for processing on a `connKey`. Kept **outside** the `IEngineConnection`\n\t* record on purpose: a same-avatar re-hello swaps the conn record in place (`attach()`'s\n\t* reattach path, the reconnect contract — it no longer detaches at all), so a per-record counter would reset\n\t* to `-1` and a replayed `hello` could reopen the window (Fact B). This map survives the\n\t* re-attach trivially; `detachConnection` clears it on a *real* close. Phase 3b persists this\n\t* across a hibernation wake (Fact C).\n\t*/\n\t_seqHighWater = /* @__PURE__ */ new Map();\n\t_detachGraceMs;\n\t/** Parked last-connection detaches, keyed by `clientKey` — a re-attach swallows its entry. */\n\t_pendingDetaches = /* @__PURE__ */ new Map();\n\t/** The self-scheduling fallback timer (plain hosts — a host seam replaces it entirely). */\n\t_detachTimer;\n\t_traffic = newTrafficCounters();\n\t_trafficSinceMs = Date.now();\n\t_options;\n\tconstructor(realm, options) {\n\t\tthis._realm = realm;\n\t\tthis._options = options;\n\t\tthis._ctx = options.ctx;\n\t\tthis._limits = {\n\t\t\t...DEFAULT_REALM_LIMITS,\n\t\t\t...options.limits\n\t\t};\n\t\tthis._now = options.now ?? (() => Date.now());\n\t\tthis._detachGraceMs = options.avatarDetachGraceMs ?? 0;\n\t\tthis._broadcastCoalesceMs = options.broadcastCoalesceMs ?? 0;\n\t\tthis._scheduleBroadcast = options.scheduleBroadcast ?? ((flush, ms) => {\n\t\t\tconst handle = setTimeout(flush, ms);\n\t\t\tunrefTimer(handle);\n\t\t\treturn () => clearTimeout(handle);\n\t\t});\n\t\tthis._instanceId = options.instanceId ?? \"default\";\n\t\tthis._logWindow = options.logWindow ?? DEFAULT_LOG_WINDOW;\n\t\tthis._log = new ReliableLog(options.logStore ?? createMemoryReliableLogStore(), { keepDelivered: this._logWindow });\n\t\tif (options.restore != null) {\n\t\t\tthis._state = options.restore.state;\n\t\t\tthis._version = options.restore.version;\n\t\t\tthis._epoch = options.restore.epoch ?? mintEpoch();\n\t\t} else {\n\t\t\tthis._state = typeof options.initialState === \"function\" ? options.initialState({ instanceId: this._instanceId }) : options.initialState;\n\t\t\tthis._epoch = mintEpoch();\n\t\t}\n\t\tthis._hasBounds = schemaRootHasBounds(this._realm.stateDef);\n\t\tif (this._hasBounds) {\n\t\t\tconst invalid = validateBoundedStateTree(this._realm.stateDef, this._state);\n\t\t\tif (invalid != null) throw err_realm.fromId(\"value_invalid\", {\n\t\t\t\tpath: invalid.path.join(\".\"),\n\t\t\t\texpected: invalid.expected\n\t\t\t});\n\t\t}\n\t}\n\tget state() {\n\t\treturn this._state;\n\t}\n\tget version() {\n\t\treturn this._version;\n\t}\n\tget instanceId() {\n\t\treturn this._instanceId;\n\t}\n\t/** The log epoch — minted at genesis/migrate, persisted by the platform host. */\n\tget epoch() {\n\t\treturn this._epoch;\n\t}\n\tget realmId() {\n\t\treturn this._realm.id;\n\t}\n\tget avatarTypes() {\n\t\treturn this._realm.avatarTypes;\n\t}\n\t/**\n\t* Attach an authenticated avatar connection to this engine. Verifies the schema hash, sends\n\t* the initial `hydrate` (or a patch replay when `lastKnownVersion` is inside the log window),\n\t* and fires `onAvatarAttach` on an avatar's first live connection. Returns `false` (after a\n\t* `reject` with `clientSeq -1`, the attach-failure sentinel) when the hash mismatches.\n\t*\n\t* Calling it for a `connKey` that is already attached with the **same avatar** is a\n\t* **re-attach** (staleness probe / wake rehello): the connection record is swapped in place —\n\t* fresh `sentKeyIds`/`features`, preserved rate bucket, migrated window acks — and the avatar\n\t* lifecycle hooks do NOT fire. A different avatar on the\n\t* same `connKey` first runs the old avatar's full detach bookkeeping.\n\t*/\n\tattach(connKey, options) {\n\t\tconst { avatar, slot, send } = options;\n\t\tif (options.schemaHash !== this._realm.schemaHash) {\n\t\t\tsend(encodeReject({\n\t\t\t\tslot,\n\t\t\t\tclientSeq: -1,\n\t\t\t\terror: err_realm.fromId(\"schema_mismatch\", {\n\t\t\t\t\trealmId: this._realm.id,\n\t\t\t\t\tclientHash: options.schemaHash,\n\t\t\t\t\tserverHash: this._realm.schemaHash\n\t\t\t\t}).toWireJsonObject()\n\t\t\t}));\n\t\t\treturn false;\n\t\t}\n\t\tthis._flushWindow();\n\t\tconst existing = this._connections.get(connKey);\n\t\tconst reattachFrom = existing != null && clientKey(existing.avatar) === clientKey(avatar) ? existing : void 0;\n\t\tif (existing != null && reattachFrom == null) this.detachConnection(connKey, \"identity-changed\", false, false);\n\t\tconst conn = {\n\t\t\tkey: connKey,\n\t\t\tavatar,\n\t\t\tslot,\n\t\t\tsend,\n\t\t\tsentKeyIds: /* @__PURE__ */ new Set(),\n\t\t\tbucket: reattachFrom?.bucket ?? {\n\t\t\t\ttokens: this._limits.writeRateBurst,\n\t\t\t\tlast: this._now(),\n\t\t\t\tbreaches: 0\n\t\t\t},\n\t\t\tfeatures: /* @__PURE__ */ new Set(),\n\t\t\toutbox: [],\n\t\t\ttraffic: reattachFrom?.traffic ?? newTrafficCounters()\n\t\t};\n\t\tthis._connections.set(connKey, conn);\n\t\tif (reattachFrom != null) {\n\t\t\tif (this._pendingDetaches.delete(clientKey(avatar))) this._detachScheduleChanged();\n\t\t\tfor (const pendingAck of this._pendingAcks) if (pendingAck.conn === reattachFrom) pendingAck.conn = conn;\n\t\t\tif (this._dirtyConns.delete(reattachFrom)) {\n\t\t\t\tconn.outbox = reattachFrom.outbox;\n\t\t\t\tthis._dirtyConns.add(conn);\n\t\t\t}\n\t\t}\n\t\tif (!this._seqHighWater.has(connKey)) {\n\t\t\tconst persisted = this._options.restoreSeqHighWater?.(avatar, slot);\n\t\t\tif (persisted != null) this._seqHighWater.set(connKey, persisted);\n\t\t}\n\t\tif (reattachFrom == null) {\n\t\t\tconst ck = clientKey(avatar);\n\t\t\tconst count = this._avatarConnCounts.get(ck) ?? 0;\n\t\t\tthis._avatarConnCounts.set(ck, count + 1);\n\t\t\tif (count === 0) if (this._pendingDetaches.get(ck) != null) {\n\t\t\t\tthis._pendingDetaches.delete(ck);\n\t\t\t\tthis._detachScheduleChanged();\n\t\t\t} else queueMicrotask(() => this._options.onAvatarAttach?.(avatar, this._ctx));\n\t\t}\n\t\tif (options.lastKnownVersion >= 0 && options.lastKnownVersion <= this._version && options.epoch === this._epoch) {\n\t\t\tconst replay = this._buildReplayOps(options.lastKnownVersion);\n\t\t\tif (replay != null) {\n\t\t\t\tconst sliced = [];\n\t\t\t\tfor (const patch of replay) {\n\t\t\t\t\tif (patch.op === \"replace\" && this._isTransientRoot(patch.path)) {\n\t\t\t\t\t\tsliced.push(sliceTransientRefreshForAvatar(this._sliceCtx(avatar), patch));\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tconst slicedPatch = slicePatchForAvatar(this._sliceCtx(avatar), patch, void 0, this._state);\n\t\t\t\t\tif (slicedPatch != null) sliced.push(slicedPatch);\n\t\t\t\t}\n\t\t\t\tthis._sendPatchesFrame(conn, sliced, options.lastKnownVersion, this._version);\n\t\t\t\tthis._flushEgress();\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\tconst blob = pack(sliceStateForAvatar(this._sliceCtx(avatar), this._state));\n\t\tconst chunkBytes = this._options.hydrateChunkBytes ?? 900 * 1024;\n\t\tfor (let offset = 0; offset === 0 || offset < blob.byteLength; offset += chunkBytes) {\n\t\t\tconst end = Math.min(offset + chunkBytes, blob.byteLength);\n\t\t\tthis._enqueue(conn, encodeHydrate({\n\t\t\t\tslot,\n\t\t\t\tversion: this._version,\n\t\t\t\tstateBlob: blob.subarray(offset, end),\n\t\t\t\tkeyDictSeed: [],\n\t\t\t\tmore: end < blob.byteLength,\n\t\t\t\tepoch: this._epoch,\n\t\t\t\tlimits: [\n\t\t\t\t\tthis._limits.maxPatchesPerFrame,\n\t\t\t\t\tthis._limits.maxFrameBytes,\n\t\t\t\t\tthis._limits.writeRatePerSecond\n\t\t\t\t],\n\t\t\t\tavatar: [\n\t\t\t\t\tavatar.type,\n\t\t\t\t\tavatar.persistentId,\n\t\t\t\t\tavatar.instanceId\n\t\t\t\t]\n\t\t\t}));\n\t\t}\n\t\tthis._flushEgress();\n\t\treturn true;\n\t}\n\t/**\n\t* Detach one connection (socket closed / avatar left the realm / forced). Every real close\n\t* clears the replay high-water (the `connKey` is never reused — the acceptor mints a fresh one\n\t* per socket — so this is pure cleanup, not correctness). `preserveReplayHighWater` is retained\n\t* for compatibility but no longer has an internal caller: a same-realm re-hello no longer\n\t* detaches at all — `attach()` swaps the connection record in place without firing the avatar\n\t* lifecycle, and the high-water survives trivially.\n\t*/\n\tdetachConnection(connKey, reason = \"detached\", notifyPeer = false, preserveReplayHighWater = false, bypassGrace = false) {\n\t\tconst conn = this._connections.get(connKey);\n\t\tif (conn == null) return;\n\t\tthis._connections.delete(connKey);\n\t\tif (!preserveReplayHighWater) this._seqHighWater.delete(connKey);\n\t\tif (this._pendingAcks.length > 0) this._pendingAcks = this._pendingAcks.filter((pending) => pending.conn !== conn);\n\t\tif (notifyPeer) this._enqueue(conn, encodeDetach({\n\t\t\tslot: conn.slot,\n\t\t\treason\n\t\t}));\n\t\tthis._flushEgress();\n\t\tconst ck = clientKey(conn.avatar);\n\t\tconst count = this._avatarConnCounts.get(ck) ?? 0;\n\t\tif (count <= 1) {\n\t\t\tthis._avatarConnCounts.delete(ck);\n\t\t\tthis._deferOrFireDetach(conn.avatar, reason, bypassGrace);\n\t\t} else this._avatarConnCounts.set(ck, count - 1);\n\t}\n\t/** Forced detach / revocation: drop every connection of a persistent avatar. */\n\tdetachAvatar(persistentId, reason = \"revoked\") {\n\t\tfor (const conn of [...this._connections.values()]) if (conn.avatar.persistentId === persistentId) this.detachConnection(conn.key, reason, true, false, true);\n\t\tfor (const [ck, pending] of [...this._pendingDetaches]) {\n\t\t\tif (pending.avatar.persistentId !== persistentId) continue;\n\t\t\tthis._pendingDetaches.delete(ck);\n\t\t\tqueueMicrotask(() => this._options.onAvatarDetach?.(pending.avatar, reason, this._ctx, { via: \"immediate\" }));\n\t\t\tthis._detachScheduleChanged();\n\t\t}\n\t}\n\t/**\n\t* Park the per-avatar detach for the grace window (or fire it now with no/ bypassed grace) —\n\t* the one funnel every last-connection departure goes through, `reportAvatarLost` included.\n\t* Dispatch stays microtask-deferred so the hook may freely `engine.update()`.\n\t*/\n\t_deferOrFireDetach(avatar, reason, bypassGrace) {\n\t\tif (!bypassGrace && this._detachGraceMs > 0) {\n\t\t\tconst ck = clientKey(avatar);\n\t\t\tif (!this._pendingDetaches.has(ck)) {\n\t\t\t\tconst now = this._now();\n\t\t\t\tthis._pendingDetaches.set(ck, {\n\t\t\t\t\tavatar,\n\t\t\t\t\treason,\n\t\t\t\t\tsince: now,\n\t\t\t\t\tfireAt: now + this._detachGraceMs\n\t\t\t\t});\n\t\t\t\tthis._detachScheduleChanged();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tqueueMicrotask(() => this._options.onAvatarDetach?.(avatar, reason, this._ctx, { via: \"immediate\" }));\n\t}\n\t/**\n\t* Report an avatar known to be gone with no live engine connection — the DO host's wake\n\t* reconciliation (a socket that vanished while the DO hibernated). Runs the same\n\t* `avatarDetachGraceMs` funnel an ordinary last-connection close gets, so a prompt reconnect\n\t* after the wake swallows the detach instead of flapping presence.\n\t*/\n\treportAvatarLost(avatar, reason = \"hibernation-lost\") {\n\t\tif ((this._avatarConnCounts.get(clientKey(avatar)) ?? 0) > 0) return;\n\t\tthis._deferOrFireDetach(avatar, reason, false);\n\t}\n\t/** The earliest pending grace deadline (epoch ms), or `undefined` — the host's alarm target. */\n\tnextDetachDeadline() {\n\t\tlet next;\n\t\tfor (const pending of this._pendingDetaches.values()) if (next == null || pending.fireAt < next) next = pending.fireAt;\n\t\treturn next;\n\t}\n\t/** The parked detaches — a durable host persists these so they survive an eviction. */\n\tpendingDetaches() {\n\t\treturn [...this._pendingDetaches.values()];\n\t}\n\t/**\n\t* Re-park persisted pending detaches after a wake (the durable host's boot path). Entries whose\n\t* avatar re-attaches (the wake rehello) are swallowed as usual; the rest fire when the host's\n\t* alarm calls {@link fireExpiredDetaches}. Keeps the earlier deadline on a key collision.\n\t*/\n\trestorePendingDetaches(rows) {\n\t\tfor (const row of rows) {\n\t\t\tconst ck = clientKey(row.avatar);\n\t\t\tif (!this._pendingDetaches.has(ck)) this._pendingDetaches.set(ck, row);\n\t\t}\n\t\tif (rows.length > 0) this._detachScheduleChanged();\n\t}\n\t/**\n\t* Fire (and clear) every pending detach whose grace window elapsed — called by the host's\n\t* timer/alarm (or the engine's own fallback timer). Hooks fire with\n\t* `{ via: \"grace-expired\", deferredMs }`, microtask-deferred like every lifecycle dispatch.\n\t*/\n\tfireExpiredDetaches(now = this._now()) {\n\t\tlet fired = false;\n\t\tfor (const [ck, pending] of [...this._pendingDetaches]) {\n\t\t\tif (pending.fireAt > now) continue;\n\t\t\tthis._pendingDetaches.delete(ck);\n\t\t\tfired = true;\n\t\t\tconst deferredMs = now - pending.since;\n\t\t\tqueueMicrotask(() => this._options.onAvatarDetach?.(pending.avatar, pending.reason, this._ctx, {\n\t\t\t\tvia: \"grace-expired\",\n\t\t\t\tdeferredMs\n\t\t\t}));\n\t\t}\n\t\tif (fired || this._pendingDetaches.size > 0) this._detachScheduleChanged();\n\t}\n\t/**\n\t* The scheduling seam: hand the change to the host when it owns scheduling\n\t* (`onDetachScheduleChanged`), else self-schedule with an unref'd timeout — correct for plain\n\t* hosts; a DO host MUST own it (a raw timeout is not hibernation-safe).\n\t*/\n\t_detachScheduleChanged() {\n\t\tif (this._options.onDetachScheduleChanged != null) {\n\t\t\tthis._options.onDetachScheduleChanged();\n\t\t\treturn;\n\t\t}\n\t\tif (this._detachTimer != null) {\n\t\t\tclearTimeout(this._detachTimer);\n\t\t\tthis._detachTimer = void 0;\n\t\t}\n\t\tconst next = this.nextDetachDeadline();\n\t\tif (next == null) return;\n\t\tconst timer = setTimeout(() => {\n\t\t\tthis._detachTimer = void 0;\n\t\t\tthis.fireExpiredDetaches();\n\t\t}, Math.max(0, next - this._now()));\n\t\tunrefTimer(timer);\n\t\tthis._detachTimer = timer;\n\t}\n\t/** Currently attached connection keys (host adapters / tests). */\n\tget connectionCount() {\n\t\treturn this._connections.size;\n\t}\n\t/**\n\t* The engine's traffic totals since construction: ingress frames/bytes,\n\t* egress **messages** (the per-message billing unit) vs frames (pre-coalescing) and bytes.\n\t* `egressCoalesceRatio` is the batch-envelope + broadcast-tick win made measurable — frames\n\t* folded per WS message. Plain data; hosts expose it however they like (a dev-only debug\n\t* action, or `realmEngineScope(engine, id)` plugged into a server devtools host, …).\n\t* Hello/attach traffic is handled by the host adapter before the engine and is not counted here.\n\t*/\n\tgetTrafficSnapshot() {\n\t\treturn {\n\t\t\t...this._traffic,\n\t\t\tsinceMs: this._trafficSinceMs,\n\t\t\tegressCoalesceRatio: this._traffic.egressMessages > 0 ? this._traffic.egressFrames / this._traffic.egressMessages : 1,\n\t\t\tconnections: [...this._connections.values()].map((conn) => ({\n\t\t\t\tconnKey: conn.key,\n\t\t\t\tavatarType: conn.avatar.type,\n\t\t\t\tavatarId: conn.avatar.persistentId,\n\t\t\t\t...conn.traffic\n\t\t\t}))\n\t\t};\n\t}\n\t/**\n\t* Subscribe to the server wire-tap: a per-frame `ITrafficSample`-shaped event for every ingress frame\n\t* and egress WS message (with real byte lengths, on lane `\"realm\"`, tagged with the connection key).\n\t* The devtools' `serverWireTrafficScope` feeds these into a traffic core so a backend's sidebar traffic\n\t* panel is as live as a frontend's. No listeners ⇒ the emit below is a hot-path no-op, so this costs\n\t* nothing in production. Returns an unsubscribe.\n\t*/\n\tsubscribeTraffic(listener) {\n\t\tthis._trafficListeners.add(listener);\n\t\treturn () => this._trafficListeners.delete(listener);\n\t}\n\t_emitTraffic(dir, bytes, connKey) {\n\t\tif (this._trafficListeners.size === 0) return;\n\t\tconst sample = {\n\t\t\tatMs: this._now(),\n\t\t\tdir,\n\t\t\tbytes,\n\t\t\tlane: \"realm\",\n\t\t\tlinkId: connKey\n\t\t};\n\t\tfor (const listener of this._trafficListeners) listener(sample);\n\t}\n\t/**\n\t* The egress features a connection advertised via `clientCaps`\n\t*, or `undefined` when the connKey is not attached. Phase 2\n\t* consumes `REALM_FEATURE.batch` here to gate the `batch` envelope; exposed for hosts/tests.\n\t*/\n\tconnectionFeatures(connKey) {\n\t\treturn this._connections.get(connKey)?.features;\n\t}\n\t/**\n\t* Feed one decoded inbound frame from an attached connection. `byteLength` (when the host\n\t* knows it) drives the frame-size ingress limit.\n\t*/\n\treceiveFrame(connKey, frame, byteLength) {\n\t\tconst conn = this._connections.get(connKey);\n\t\tif (conn == null) return;\n\t\tconn.traffic.ingressFrames += 1;\n\t\tconn.traffic.ingressBytes += byteLength ?? 0;\n\t\tthis._traffic.ingressFrames += 1;\n\t\tthis._traffic.ingressBytes += byteLength ?? 0;\n\t\tthis._emitTraffic(\"in\", byteLength ?? 0, connKey);\n\t\tswitch (frame.kind) {\n\t\t\tcase REALM_FRAME_KIND.write:\n\t\t\t\tthis._handleWrite(conn, frame, byteLength);\n\t\t\t\tbreak;\n\t\t\tcase REALM_FRAME_KIND.intent:\n\t\t\t\tthis._handleIntent(conn, frame, byteLength);\n\t\t\t\tbreak;\n\t\t\tcase REALM_FRAME_KIND.clientCaps:\n\t\t\t\tconn.features = new Set(frame.features);\n\t\t\t\tbreak;\n\t\t\tcase REALM_FRAME_KIND.detach:\n\t\t\t\tthis.detachConnection(connKey, frame.reason ?? \"avatar detached\");\n\t\t\t\tbreak;\n\t\t\tdefault: break;\n\t\t}\n\t\tthis._flushEgress();\n\t}\n\t/**\n\t* Mutate authoritative state from server code (`r.serverOnly` paths — game ticks, fulfilment;\n\t* the protocol contract). Flows through the same version/log/slice tail, so server writes broadcast\n\t* identically. Throws when called re-entrantly from an intent `apply` or a rule (single-writer\n\t* invariant, the protocol contract).\n\t*/\n\tupdate(fn) {\n\t\tthis._guardReentrancy();\n\t\tthis._mutating = true;\n\t\tlet produced;\n\t\ttry {\n\t\t\tproduced = produceWithPatches(this._state, (draft) => {\n\t\t\t\tfn(draft);\n\t\t\t});\n\t\t} finally {\n\t\t\tthis._mutating = false;\n\t\t}\n\t\tconst [nextState, patches] = produced;\n\t\tif (patches.length === 0) return;\n\t\tconst canonical = canonicalizeStatePatches(patches, nextState, this._realm.stateDef);\n\t\tif (this._hasBounds) {\n\t\t\tconst bounded = validateBoundedPatches(this._realm.stateDef, nextState, canonical.map((patch) => patch.path));\n\t\t\tif (bounded != null) throw err_realm.fromId(\"value_invalid\", {\n\t\t\t\tpath: bounded.path.join(\".\"),\n\t\t\t\texpected: bounded.expected\n\t\t\t});\n\t\t}\n\t\tthis._commit(nextState, canonical, { source: \"server\" });\n\t\tthis._flushEgress();\n\t}\n\t_handleWrite(conn, frame, byteLength) {\n\t\tif (!this._passesSeq(conn, frame.clientSeq)) return;\n\t\tif (!this._passesIngress(conn, frame.clientSeq, byteLength, frame.ops.length)) return;\n\t\tthis._advanceSeqHighWater(conn, frame.clientSeq);\n\t\tlet namePatches;\n\t\ttry {\n\t\t\tnamePatches = wireOpsToNamePatches(frame.ops, this._realm.tokens, (id) => this._dict.keyOf(id));\n\t\t} catch (error) {\n\t\t\tthis._reject(conn, frame.clientSeq, err_realm.fromId(\"frame_invalid\", { reason: error instanceof Error ? error.message : \"bad wire path\" }));\n\t\t\treturn;\n\t\t}\n\t\tconst statePrev = this._state;\n\t\tconst extrasFor = (leafPath) => ({\n\t\t\tctx: this._ctx,\n\t\t\ttouchedSince: (basisVersion) => this._touchedSince(leafPath, basisVersion)\n\t\t});\n\t\tfor (const patch of namePatches) {\n\t\t\tconst path = patch.path;\n\t\t\tfor (const seg of path) {\n\t\t\t\tif (isUnsafeKey(seg)) {\n\t\t\t\t\tthis._reject(conn, frame.clientSeq, err_realm.fromId(\"frame_invalid\", { reason: \"unsafe record key\" }));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (typeof seg === \"string\" && seg.length > this._limits.maxRecordKeyLength) {\n\t\t\t\t\tthis._breach(conn, frame.clientSeq, \"maxRecordKeyLength\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (patch.op !== \"remove\" && valueHasUnsafeKey(patch.value)) {\n\t\t\t\tthis._reject(conn, frame.clientSeq, err_realm.fromId(\"frame_invalid\", { reason: \"unsafe record key\" }));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst node = schemaNodeAtPath(this._realm.stateDef, path);\n\t\t\tif (node == null) {\n\t\t\t\tthis._reject(conn, frame.clientSeq, err_realm.fromId(\"value_invalid\", {\n\t\t\t\t\tpath: path.join(\".\"),\n\t\t\t\t\texpected: \"a schema path\"\n\t\t\t\t}));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (patch.op === \"remove\") {\n\t\t\t\tconst parentNode = path.length === 1 ? void 0 : schemaNodeAtPath(this._realm.stateDef, path.slice(0, -1));\n\t\t\t\tif (!((parentNode?.kind === \"optional\" ? \"optional\" : parentNode?.kind) === \"record\" || node.kind === \"optional\")) {\n\t\t\t\t\tthis._reject(conn, frame.clientSeq, err_realm.fromId(\"value_invalid\", {\n\t\t\t\t\t\tpath: path.join(\".\"),\n\t\t\t\t\t\texpected: \"a removable path (record entry or optional key)\"\n\t\t\t\t\t}));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst invalid = validateValue(node, patch.value);\n\t\t\t\tif (invalid != null) {\n\t\t\t\t\tthis._reject(conn, frame.clientSeq, err_realm.fromId(\"value_invalid\", {\n\t\t\t\t\t\tpath: [...path, ...invalid.path].join(\".\"),\n\t\t\t\t\t\texpected: invalid.expected\n\t\t\t\t\t}));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tlet leaves;\n\t\t\ttry {\n\t\t\t\tleaves = expandWriteToLeaves({\n\t\t\t\t\tschemaRoot: this._realm.stateDef,\n\t\t\t\t\tpath,\n\t\t\t\t\top: patch.op,\n\t\t\t\t\tvalue: patch.value,\n\t\t\t\t\tstate: statePrev,\n\t\t\t\t\tmaxLeaves: this._limits.maxExpandedLeaves\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof ExpansionOverflowError) {\n\t\t\t\t\tthis._breach(conn, frame.clientSeq, \"maxExpandedLeaves\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tfor (const leafPath of leaves) {\n\t\t\t\tconst match = this._realm.ruleTrie.match(leafPath);\n\t\t\t\tif (match == null) {\n\t\t\t\t\tthis._reject(conn, frame.clientSeq, err_realm.fromId(\"unauthorized_coordinate\", { path: leafPath.join(\".\") }));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst rel = leafPath.slice(path.length);\n\t\t\t\tconst next = patch.op === \"remove\" ? void 0 : getAtPath(patch.value, rel);\n\t\t\t\tconst verdict = evalAlterCond(match.rule.alter, {\n\t\t\t\t\tavatar: conn.avatar,\n\t\t\t\t\tparams: match.params,\n\t\t\t\t\tprev: getAtPath(statePrev, leafPath),\n\t\t\t\t\tnext,\n\t\t\t\t\tstate: statePrev,\n\t\t\t\t\tbasisVersion: frame.basisVersion\n\t\t\t\t}, extrasFor(leafPath));\n\t\t\t\tif (verdict === \"serverOnly\") {\n\t\t\t\t\tthis._reject(conn, frame.clientSeq, err_realm.fromId(\"unauthorized_coordinate\", { path: leafPath.join(\".\") }));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (verdict !== true) {\n\t\t\t\t\tthis._reject(conn, frame.clientSeq, verdict);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tlet nextState;\n\t\ttry {\n\t\t\tnextState = applyPatches(this._state, namePatches);\n\t\t} catch {\n\t\t\tconst path = (namePatches[0]?.path)?.join(\".\") ?? \"(unknown)\";\n\t\t\tthis._options.onWriteTargetMissing?.({\n\t\t\t\tavatar: conn.avatar,\n\t\t\t\tconnKey: conn.key,\n\t\t\t\tpath,\n\t\t\t\tliveConnections: this._avatarConnCounts.get(clientKey(conn.avatar)) ?? 0\n\t\t\t});\n\t\t\tthis._reject(conn, frame.clientSeq, err_realm.fromId(\"write_target_missing\", { path }));\n\t\t\treturn;\n\t\t}\n\t\tif (this._hasBounds) {\n\t\t\tconst bounded = validateBoundedPatches(this._realm.stateDef, nextState, namePatches.map((patch) => patch.path));\n\t\t\tif (bounded != null) {\n\t\t\t\tthis._reject(conn, frame.clientSeq, err_realm.fromId(\"value_invalid\", {\n\t\t\t\t\tpath: bounded.path.join(\".\"),\n\t\t\t\t\texpected: bounded.expected\n\t\t\t\t}));\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tconst version = this._commit(nextState, namePatches, {\n\t\t\tsource: \"write\",\n\t\t\tavatar: conn.avatar\n\t\t});\n\t\tthis._settleAck(conn, frame.clientSeq, version);\n\t}\n\t_handleIntent(conn, frame, byteLength) {\n\t\tif (!this._passesSeq(conn, frame.clientSeq)) return;\n\t\tif (!this._passesIngress(conn, frame.clientSeq, byteLength, 0)) return;\n\t\tthis._advanceSeqHighWater(conn, frame.clientSeq);\n\t\tconst name = this._realm.intentNames[frame.intentToken];\n\t\tconst def = name == null ? void 0 : this._realm.intents[name];\n\t\tif (name == null || def == null) {\n\t\t\tthis._reject(conn, frame.clientSeq, err_realm.fromId(\"intent_unknown\", { intent: `#${frame.intentToken}` }));\n\t\t\treturn;\n\t\t}\n\t\tif (!def.allow.includes(conn.avatar.type)) {\n\t\t\tthis._reject(conn, frame.clientSeq, err_realm.fromId(\"unauthorized_avatar_type\", {\n\t\t\t\tavatarType: conn.avatar.type,\n\t\t\t\texpected: def.allow\n\t\t\t}));\n\t\t\treturn;\n\t\t}\n\t\tconst invalid = validateValue(def.input, frame.input);\n\t\tif (invalid != null) {\n\t\t\tthis._reject(conn, frame.clientSeq, err_realm.fromId(\"value_invalid\", {\n\t\t\t\tpath: [name, ...invalid.path].join(\".\"),\n\t\t\t\texpected: invalid.expected\n\t\t\t}));\n\t\t\treturn;\n\t\t}\n\t\tthis._guardReentrancy();\n\t\tthis._mutating = true;\n\t\tlet verdict = true;\n\t\tlet produced;\n\t\ttry {\n\t\t\tproduced = produceWithPatches(this._state, (draft) => {\n\t\t\t\tverdict = def.apply({\n\t\t\t\t\tstate: draft,\n\t\t\t\t\tavatar: conn.avatar,\n\t\t\t\t\tinput: frame.input,\n\t\t\t\t\tctx: this._ctx\n\t\t\t\t});\n\t\t\t});\n\t\t} finally {\n\t\t\tthis._mutating = false;\n\t\t}\n\t\tif (verdict !== true) {\n\t\t\tthis._reject(conn, frame.clientSeq, verdict);\n\t\t\treturn;\n\t\t}\n\t\tconst [nextState, patches] = produced;\n\t\tif (patches.length === 0) {\n\t\t\tthis._enqueue(conn, encodeAck({\n\t\t\t\tslot: conn.slot,\n\t\t\t\tclientSeq: frame.clientSeq,\n\t\t\t\tversion: this._version\n\t\t\t}));\n\t\t\treturn;\n\t\t}\n\t\tconst canonical = canonicalizeStatePatches(patches, nextState, this._realm.stateDef);\n\t\tfor (const patch of canonical) if (pathHasUnsafeKey(patch.path) || patch.op !== \"remove\" && valueHasUnsafeKey(patch.value)) {\n\t\t\tthis._reject(conn, frame.clientSeq, err_realm.fromId(\"frame_invalid\", { reason: \"unsafe record key\" }));\n\t\t\treturn;\n\t\t}\n\t\tif (this._hasBounds) {\n\t\t\tconst bounded = validateBoundedPatches(this._realm.stateDef, nextState, canonical.map((patch) => patch.path));\n\t\t\tif (bounded != null) {\n\t\t\t\tthis._reject(conn, frame.clientSeq, err_realm.fromId(\"value_invalid\", {\n\t\t\t\t\tpath: bounded.path.join(\".\"),\n\t\t\t\t\texpected: bounded.expected\n\t\t\t\t}));\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tconst version = this._commit(nextState, canonical, {\n\t\t\tsource: \"intent\",\n\t\t\tavatar: conn.avatar\n\t\t});\n\t\tthis._settleAck(conn, frame.clientSeq, version);\n\t}\n\t_commit(nextState, namePatches, meta) {\n\t\tconst statePrev = this._state;\n\t\tconst versionBefore = this._version;\n\t\tthis._state = nextState;\n\t\tconst durableOps = this._realm.transient.length === 0 ? namePatches : namePatches.filter((patch) => !this._isTransientPath(patch.path));\n\t\tconst isDurable = durableOps.length > 0;\n\t\tif (isDurable) {\n\t\t\tthis._version += 1;\n\t\t\tconst ops = durableOps.map((patch) => patch.op === \"remove\" ? {\n\t\t\t\top: patch.op,\n\t\t\t\tpath: patch.path\n\t\t\t} : {\n\t\t\t\top: patch.op,\n\t\t\t\tpath: patch.path,\n\t\t\t\tvalue: patch.value\n\t\t\t});\n\t\t\tthis._log.append(this._logStreamId(), ops);\n\t\t\tfor (const patch of durableOps) this._touches.push({\n\t\t\t\tpath: patch.path,\n\t\t\t\tversion: this._version\n\t\t\t});\n\t\t\tconst pruneBelow = this._version - this._logWindow;\n\t\t\tif (pruneBelow > 0 && this._touches[0] != null && this._touches[0].version <= pruneBelow) this._touches = this._touches.filter((touch) => touch.version > pruneBelow);\n\t\t}\n\t\tif (this._broadcastCoalesceMs > 0) {\n\t\t\tif (this._windowStartState === void 0) {\n\t\t\t\tthis._windowStartState = statePrev;\n\t\t\t\tthis._windowFromVersion = versionBefore;\n\t\t\t\tthis._armWindowTimer();\n\t\t\t}\n\t\t\tfor (const patch of namePatches) this._windowOps.push(patch);\n\t\t} else this._broadcast(namePatches, statePrev, versionBefore, this._version);\n\t\tif (isDurable) this._options.onMutation?.(namePatches, {\n\t\t\tversion: this._version,\n\t\t\t...meta\n\t\t});\n\t\treturn this._version;\n\t}\n\t/** A path is transient (Phase 5) when a declared transient root is a prefix of it. */\n\t_isTransientPath(path) {\n\t\tfor (const root of this._realm.transient) {\n\t\t\tif (root.length > path.length) continue;\n\t\t\tlet matches = true;\n\t\t\tfor (let i = 0; i < root.length; i++) if (root[i] !== path[i]) {\n\t\t\t\tmatches = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (matches) return true;\n\t\t}\n\t\treturn false;\n\t}\n\t/** A path is EXACTLY a declared transient root — the whole-region refresh key in a replay. */\n\t_isTransientRoot(path) {\n\t\treturn this._realm.transient.some((root) => root.length === path.length && root.every((seg, i) => seg === path[i]));\n\t}\n\t/**\n\t* Flush the open broadcast window (Phase 4): conflate its accumulated ops, fan out ONE patches\n\t* frame per connection (chunked under the ws ceiling — P4), then the window's deferred acks, all\n\t* via the outbox so each connection collapses to one WS message. Public so a host or test can force\n\t* a tick boundary; also the timer callback and the pre-hydrate flush in `attach`. A no-op when no\n\t* window is open (per-commit realms never open one).\n\t*/\n\tflushBroadcasts() {\n\t\tthis._flushWindow();\n\t\tthis._flushEgress();\n\t}\n\t_flushWindow() {\n\t\tthis._clearWindowTimer();\n\t\tif (this._windowStartState === void 0) return;\n\t\tconst startState = this._windowStartState;\n\t\tconst fromVersion = this._windowFromVersion;\n\t\tconst ops = conflateOps(this._windowOps);\n\t\tthis._windowOps = [];\n\t\tthis._windowStartState = void 0;\n\t\tthis._broadcast(ops, startState, fromVersion, this._version);\n\t\tthis._flushPendingAcks();\n\t}\n\t_armWindowTimer() {\n\t\tif (this._windowTimerCancel != null) return;\n\t\tthis._windowTimerCancel = this._scheduleBroadcast(() => {\n\t\t\tthis._windowTimerCancel = void 0;\n\t\t\tthis.flushBroadcasts();\n\t\t}, this._broadcastCoalesceMs);\n\t}\n\t_clearWindowTimer() {\n\t\tif (this._windowTimerCancel == null) return;\n\t\tthis._windowTimerCancel();\n\t\tthis._windowTimerCancel = void 0;\n\t}\n\t_flushPendingAcks() {\n\t\tif (this._pendingAcks.length === 0) return;\n\t\tconst acks = this._pendingAcks;\n\t\tthis._pendingAcks = [];\n\t\tfor (const { conn, clientSeq, version } of acks) {\n\t\t\tif (this._connections.get(conn.key) !== conn) continue;\n\t\t\tthis._enqueue(conn, encodeAck({\n\t\t\t\tslot: conn.slot,\n\t\t\t\tclientSeq,\n\t\t\t\tversion\n\t\t\t}));\n\t\t}\n\t}\n\t/** Settle a committed write/intent: immediate ack per-commit, or deferred into the window (P3). */\n\t_settleAck(conn, clientSeq, version) {\n\t\tif (this._broadcastCoalesceMs > 0) this._pendingAcks.push({\n\t\t\tconn,\n\t\t\tclientSeq,\n\t\t\tversion\n\t\t});\n\t\telse this._enqueue(conn, encodeAck({\n\t\t\tslot: conn.slot,\n\t\t\tclientSeq,\n\t\t\tversion\n\t\t}));\n\t}\n\t_broadcast(namePatches, statePrev, fromVersion, toVersion) {\n\t\tif (this._connections.size === 0) return;\n\t\tconst stateAfter = this._state;\n\t\tconst cache = /* @__PURE__ */ new Map();\n\t\tfor (const conn of this._connections.values()) {\n\t\t\tconst groupKey = `${viewSignatureKey(conn.avatar)}/${conn.slot}`;\n\t\t\tlet chunks = cache.get(groupKey);\n\t\t\tif (chunks === void 0) {\n\t\t\t\tconst sliced = [];\n\t\t\t\tfor (const patch of namePatches) {\n\t\t\t\t\tconst slicedPatch = slicePatchForAvatar(this._sliceCtx(conn.avatar), patch, statePrev, stateAfter);\n\t\t\t\t\tif (slicedPatch != null) sliced.push(slicedPatch);\n\t\t\t\t}\n\t\t\t\tchunks = sliced.length === 0 ? null : this._encodePatchesChunked(sliced, conn.slot, fromVersion, toVersion);\n\t\t\t\tcache.set(groupKey, chunks);\n\t\t\t}\n\t\t\tif (chunks == null) continue;\n\t\t\tfor (const chunk of chunks) {\n\t\t\t\tthis._sendKeyDictDelta(conn, chunk.usedIds);\n\t\t\t\tthis._enqueue(conn, chunk.bytes);\n\t\t\t}\n\t\t}\n\t}\n\t_encodePatches(sliced, slot, fromVersion, toVersion) {\n\t\tconst usedIds = /* @__PURE__ */ new Set();\n\t\treturn {\n\t\t\tbytes: encodePatches({\n\t\t\t\tslot,\n\t\t\t\tfromVersion,\n\t\t\t\ttoVersion,\n\t\t\t\tops: namePatchesToWireOps(sliced, this._realm.tokens, (key) => {\n\t\t\t\t\tconst id = this._dict.intern(key);\n\t\t\t\t\tusedIds.add(id);\n\t\t\t\t\treturn id;\n\t\t\t\t})\n\t\t\t}),\n\t\t\tusedIds\n\t\t};\n\t}\n\t/**\n\t* Encode sliced ops into one-or-more patches frames, each under the ws message ceiling (P4). Splits\n\t* by op-count (recursive halving) — the parts share `fromVersion`/`toVersion` and apply in order to\n\t* the same state, since server→client ops are order-preserving within a version. A single op that\n\t* alone exceeds the ceiling is emitted anyway (indivisible — the same as a single over-limit commit\n\t* today; the hydrate path is the only genuinely large payload and it chunks separately).\n\t*/\n\t_encodePatchesChunked(sliced, slot, fromVersion, toVersion) {\n\t\tconst whole = this._encodePatches(sliced, slot, fromVersion, toVersion);\n\t\tconst ceiling = this._options.hydrateChunkBytes ?? 900 * 1024;\n\t\tif (whole.bytes.byteLength <= ceiling || sliced.length <= 1) return [whole];\n\t\tconst mid = Math.ceil(sliced.length / 2);\n\t\treturn [...this._encodePatchesChunked(sliced.slice(0, mid), slot, fromVersion, toVersion), ...this._encodePatchesChunked(sliced.slice(mid), slot, fromVersion, toVersion)];\n\t}\n\t_sendPatchesFrame(conn, sliced, fromVersion, toVersion) {\n\t\tconst entry = this._encodePatches(sliced, conn.slot, fromVersion, toVersion);\n\t\tthis._sendKeyDictDelta(conn, entry.usedIds);\n\t\tthis._enqueue(conn, entry.bytes);\n\t}\n\t_sendKeyDictDelta(conn, usedIds) {\n\t\tconst entries = [];\n\t\tfor (const id of usedIds) {\n\t\t\tif (conn.sentKeyIds.has(id)) continue;\n\t\t\tconst key = this._dict.keyOf(id);\n\t\t\tif (key == null) continue;\n\t\t\tentries.push([key, id]);\n\t\t\tconn.sentKeyIds.add(id);\n\t\t}\n\t\tif (entries.length > 0) this._enqueue(conn, encodeKeyDict({\n\t\t\tslot: conn.slot,\n\t\t\tentries\n\t\t}));\n\t}\n\t/** Merged replay ops for versions `basis+1 … head`, or `undefined` when outside the window. */\n\t_buildReplayOps(basisVersion) {\n\t\tconst prefix = this._log.contiguousPrefix(this._logStreamId());\n\t\tconst oldestReplayableBasis = this._version - prefix.length;\n\t\tif (basisVersion < oldestReplayableBasis) return void 0;\n\t\tconst merged = [];\n\t\tfor (let i = basisVersion - oldestReplayableBasis; i < prefix.length; i++) for (const op of prefix[i]) merged.push(op.op === \"remove\" ? {\n\t\t\top: op.op,\n\t\t\tpath: op.path\n\t\t} : {\n\t\t\top: op.op,\n\t\t\tpath: op.path,\n\t\t\tvalue: op.value\n\t\t});\n\t\tconst conflated = conflateOps(merged);\n\t\tfor (const root of this._realm.transient) conflated.push({\n\t\t\top: \"replace\",\n\t\t\tpath: [...root],\n\t\t\tvalue: getAtPath(this._state, root)\n\t\t});\n\t\treturn conflated;\n\t}\n\t_logStreamId() {\n\t\treturn `realm:${this._realm.id}:${this._instanceId}`;\n\t}\n\t_sliceCtx(avatar) {\n\t\treturn {\n\t\t\tschemaRoot: this._realm.stateDef,\n\t\t\ttrie: this._realm.ruleTrie,\n\t\t\tavatar: {\n\t\t\t\ttype: avatar.type,\n\t\t\t\tpersistentId: avatar.persistentId\n\t\t\t}\n\t\t};\n\t}\n\t_touchedSince(leafPath, basisVersion) {\n\t\tif (this._isTransientPath(leafPath)) throw new Error(`realm \"${this._realm.id}\": touchedSince()/CAS is not supported under the transient region containing \"${leafPath.join(\".\")}\" — transient state keeps no touch history, so a CAS there would silently always pass. Drop the CAS, or make that region durable.`);\n\t\tif (basisVersion < this._version - this._logWindow) return true;\n\t\tfor (let i = this._touches.length - 1; i >= 0; i--) {\n\t\t\tconst touch = this._touches[i];\n\t\t\tif (touch.version <= basisVersion) break;\n\t\t\tif (pathsOverlap(touch.path, leafPath)) return true;\n\t\t}\n\t\treturn false;\n\t}\n\t/**\n\t* The replay/duplicate high-water gate. Returns `false` — caller\n\t* must stop — when `clientSeq` is at or below the connection's high-water: the frame is either a\n\t* replay (a captured frame re-injected into the framing layer) or a benign ack-lost resend, which\n\t* by seq alone are indistinguishable and both safe to treat as already-processed. It is settled\n\t* **idempotently** — re-ack the current authoritative version (the client's handle settles\n\t* read-your-writes via the version; no per-seq bookkeeping needed) — never re-applied and never\n\t* counted as a breach. New seqs (`> high-water`) return `true`; the caller advances the high-water\n\t* only after ingress also passes (so a rate-limited retry keeps its seq — see `_handleWrite`).\n\t*/\n\t_passesSeq(conn, clientSeq) {\n\t\tif (clientSeq < 0) return true;\n\t\tif (clientSeq <= (this._seqHighWater.get(conn.key) ?? -1)) {\n\t\t\tthis._enqueue(conn, encodeAck({\n\t\t\t\tslot: conn.slot,\n\t\t\t\tclientSeq,\n\t\t\t\tversion: this._version\n\t\t\t}));\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\t/**\n\t* Advance the connection's replay high-water and persist it. Persist\n\t* runs per accepted frame so the durable value never lags an arbitrary hibernation point (a\n\t* lagging value would reopen the wake-replay window). Cost: one host-side upsert per accepted\n\t* `write`/`intent` — see the host's `persistSeqHighWater`, which may batch if it proves hot.\n\t*/\n\t_advanceSeqHighWater(conn, clientSeq) {\n\t\tif (clientSeq < 0) return;\n\t\tthis._seqHighWater.set(conn.key, clientSeq);\n\t\tthis._options.persistSeqHighWater?.(conn.avatar, conn.slot, clientSeq);\n\t}\n\t_passesIngress(conn, clientSeq, byteLength, opsCount) {\n\t\tif (byteLength != null && byteLength > this._limits.maxFrameBytes) {\n\t\t\tthis._breach(conn, clientSeq, \"maxFrameBytes\");\n\t\t\treturn false;\n\t\t}\n\t\tif (opsCount > this._limits.maxPatchesPerFrame) {\n\t\t\tthis._breach(conn, clientSeq, \"maxPatchesPerFrame\");\n\t\t\treturn false;\n\t\t}\n\t\tconst now = this._now();\n\t\tconst bucket = conn.bucket;\n\t\tconst elapsed = Math.max(0, now - bucket.last) / 1e3;\n\t\tbucket.tokens = Math.min(this._limits.writeRateBurst, bucket.tokens + elapsed * this._limits.writeRatePerSecond);\n\t\tbucket.last = now;\n\t\tif (bucket.tokens < 1) {\n\t\t\tthis._breach(conn, clientSeq, \"writeRatePerSecond\");\n\t\t\treturn false;\n\t\t}\n\t\tbucket.tokens -= 1;\n\t\treturn true;\n\t}\n\t_breach(conn, clientSeq, limit) {\n\t\tthis._reject(conn, clientSeq, err_realm.fromId(\"limits_exceeded\", { limit }));\n\t\tconn.bucket.breaches += 1;\n\t\tif (conn.bucket.breaches >= this._limits.maxBreachesBeforeDetach) this.detachConnection(conn.key, \"repeated limit breaches\", true);\n\t}\n\t/**\n\t* Send a rejection to one connection. The wire carries **only** the error's public\n\t* `toJsonObject()` (ids, user-provided error context, message, stack) — never the realm's\n\t* `serverContext` (`ctx`), which the engine never places on an error (the protocol contract\n\t* secret-scrub, verified). Discipline this implies for realm authors: a rule/intent error's\n\t* **context and message are wire-visible**, so they must not embed server secrets (`ctx` values,\n\t* internal ids) — the same rule as the client bundle. Documented in the security guide (Phase 8).\n\t*/\n\t_reject(conn, clientSeq, error) {\n\t\tthis._enqueue(conn, encodeReject({\n\t\t\tslot: conn.slot,\n\t\t\tclientSeq,\n\t\t\terror: error.toWireJsonObject()\n\t\t}));\n\t}\n\t_guardReentrancy() {\n\t\tif (this._mutating) throw new Error(\"realm single-writer invariant: engine.update()/intents may not run inside an intent apply or a rule\");\n\t}\n\t/** Queue one already-encoded frame for a connection; the entry point's `_flushEgress` sends it. */\n\t_enqueue(conn, bytes) {\n\t\tconn.outbox.push(bytes);\n\t\tthis._dirtyConns.add(conn);\n\t}\n\t/**\n\t* Drain every connection's outbox (Phase 2). Runs at the end of each public entry point. Frames\n\t* queued during ONE entry point collapse to one WS message per connection — a `batch` when the\n\t* connection advertised {@link REALM_FEATURE.batch} and more than one frame is pending, else bare\n\t* sequential sends (byte-identical to pre-Phase-2 for a non-batch peer). Re-entrancy safe (F4):\n\t* the guard makes a nested flush (a raw send re-entered an entry point on an in-memory link) a\n\t* no-op, and each connection's queue is reference-swapped before its frames go out, so frames a\n\t* re-entrant call enqueues are picked up by the owning loop AFTER the current snapshot — never\n\t* interleaved. Insertion order of `_dirtyConns` (Set) is the per-connection flush order.\n\t*/\n\t_flushEgress() {\n\t\tif (this._flushing) return;\n\t\tthis._flushing = true;\n\t\ttry {\n\t\t\twhile (this._dirtyConns.size > 0) {\n\t\t\t\tconst conn = this._dirtyConns.values().next().value;\n\t\t\t\tif (conn == null) break;\n\t\t\t\tthis._dirtyConns.delete(conn);\n\t\t\t\tconst frames = conn.outbox;\n\t\t\t\tif (frames.length === 0) continue;\n\t\t\t\tconn.outbox = [];\n\t\t\t\tthis._transmit(conn, frames);\n\t\t\t}\n\t\t} finally {\n\t\t\tthis._flushing = false;\n\t\t}\n\t}\n\t/**\n\t* Send one connection's snapshot of queued frames. One frame → bare (no envelope overhead). More\n\t* than one on a batch-capable connection → a `batch` envelope, split so no single message exceeds\n\t* the host's ws ceiling (`hydrateChunkBytes`) — which also keeps near-ceiling hydrate chunks in\n\t* their own message (never re-merged). A non-batch connection gets today's sequential bare sends.\n\t*/\n\t_transmit(conn, frames) {\n\t\tconn.traffic.egressFrames += frames.length;\n\t\tthis._traffic.egressFrames += frames.length;\n\t\tconst rawSend = (bytes) => {\n\t\t\tconn.traffic.egressMessages += 1;\n\t\t\tconn.traffic.egressBytes += bytes.byteLength;\n\t\t\tthis._traffic.egressMessages += 1;\n\t\t\tthis._traffic.egressBytes += bytes.byteLength;\n\t\t\tthis._emitTraffic(\"out\", bytes.byteLength, conn.key);\n\t\t\ttry {\n\t\t\t\tconn.send(bytes);\n\t\t\t} catch {}\n\t\t};\n\t\tif (frames.length === 1) {\n\t\t\trawSend(frames[0]);\n\t\t\treturn;\n\t\t}\n\t\tif (!conn.features.has(REALM_FEATURE.batch)) {\n\t\t\tfor (const bytes of frames) rawSend(bytes);\n\t\t\treturn;\n\t\t}\n\t\tconst ceiling = this._options.hydrateChunkBytes ?? 900 * 1024;\n\t\tlet group = [];\n\t\tlet groupBytes = ENVELOPE_BASE_BYTES;\n\t\tconst flushGroup = () => {\n\t\t\tif (group.length === 0) return;\n\t\t\trawSend(group.length === 1 ? group[0] : encodeBatch({\n\t\t\t\tslot: conn.slot,\n\t\t\t\tpayloads: group\n\t\t\t}));\n\t\t\tgroup = [];\n\t\t\tgroupBytes = ENVELOPE_BASE_BYTES;\n\t\t};\n\t\tfor (const bytes of frames) {\n\t\t\tconst cost = bytes.byteLength + PAYLOAD_HEADER_BYTES;\n\t\t\tif (group.length > 0 && groupBytes + cost > ceiling) flushGroup();\n\t\t\tgroup.push(bytes);\n\t\t\tgroupBytes += cost;\n\t\t}\n\t\tflushGroup();\n\t}\n};\n/** Conservative msgpack overheads for the batch-envelope ceiling math (see {@link RealmServerEngine._transmit}). */\nconst ENVELOPE_BASE_BYTES = 16;\nconst PAYLOAD_HEADER_BYTES = 5;\nfunction getAtPath(state, path) {\n\tlet current = state;\n\tfor (const seg of path) {\n\t\tif (current == null || typeof current !== \"object\") return void 0;\n\t\tcurrent = current[seg];\n\t}\n\treturn current;\n}\nfunction pathsOverlap(a, b) {\n\tconst len = Math.min(a.length, b.length);\n\tfor (let i = 0; i < len; i++) if (a[i] !== b[i]) return false;\n\treturn true;\n}\n/** Factory with full inference from the realm definition. */\nfunction createRealmServerEngine(realm, options) {\n\treturn new RealmServerEngine(realm, options);\n}\n//#endregion\n//#region src/realm/RealmServer/realmAcceptorProtocol.ts\nfunction createRealmAcceptor(options) {\n\tfor (const [realmId, hosted] of Object.entries(options.realms)) if (hosted.resolveAvatar == null === (hosted.avatarType == null)) throw new Error(`createRealmAcceptor: realm \"${realmId}\" requires exactly one of \\`resolveAvatar\\` or \\`avatarType\\``);\n\tconst connStates = /* @__PURE__ */ new WeakMap();\n\tlet connCounter = 0;\n\tconst stateFor = (connection) => {\n\t\tlet state = connStates.get(connection);\n\t\tif (state == null) {\n\t\t\tconnCounter += 1;\n\t\t\tstate = {\n\t\t\t\tkey: `conn-${connCounter}`,\n\t\t\t\tslots: /* @__PURE__ */ new Map()\n\t\t\t};\n\t\t\tconnStates.set(connection, state);\n\t\t}\n\t\treturn state;\n\t};\n\tconst engineConnKey = (state, slot) => `${state.key}/${slot}`;\n\treturn {\n\t\tid: \"realm\",\n\t\tprefixByte: WIRE_PROTOCOL_PREFIX.realm,\n\t\tonFrame(connection, payload, send, suppliedContext) {\n\t\t\tconst context = suppliedContext ?? {\n\t\t\t\tclient: void 0,\n\t\t\t\tlevel: options.levelFor?.(connection) ?? \"none\"\n\t\t\t};\n\t\t\tlet frame;\n\t\t\ttry {\n\t\t\t\tframe = decodeRealmFrame(payload);\n\t\t\t} catch {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst state = stateFor(connection);\n\t\t\tif (frame.kind === REALM_FRAME_KIND.hello) {\n\t\t\t\tconst hosted = options.realms[frame.realmId];\n\t\t\t\tif (hosted == null) {\n\t\t\t\t\tsend(encodeReject({\n\t\t\t\t\t\tslot: frame.slot,\n\t\t\t\t\t\tclientSeq: -1,\n\t\t\t\t\t\terror: err_realm.fromId(\"realm_unknown\", { realmId: frame.realmId }).toWireJsonObject()\n\t\t\t\t\t}));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst avatar = hosted.resolveAvatar?.(connection, context) ?? (hosted.avatarType != null && context.client?.perId != null ? {\n\t\t\t\t\ttype: hosted.avatarType,\n\t\t\t\t\tpersistentId: context.client.perId,\n\t\t\t\t\tinstanceId: context.client.insId ?? \"default\"\n\t\t\t\t} : void 0);\n\t\t\t\tif (avatar == null) {\n\t\t\t\t\tsend(encodeReject({\n\t\t\t\t\t\tslot: frame.slot,\n\t\t\t\t\t\tclientSeq: -1,\n\t\t\t\t\t\terror: err_realm.fromId(\"avatar_unresolved\", { realmId: frame.realmId }).toWireJsonObject()\n\t\t\t\t\t}));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (hosted.minSecurity != null) {\n\t\t\t\t\tconst actual = context.level;\n\t\t\t\t\tif (!securityLevelMeets(actual, hosted.minSecurity)) {\n\t\t\t\t\t\tsend(encodeReject({\n\t\t\t\t\t\t\tslot: frame.slot,\n\t\t\t\t\t\t\tclientSeq: -1,\n\t\t\t\t\t\t\terror: err_realm.fromId(\"insufficient_security\", {\n\t\t\t\t\t\t\t\trealmId: frame.realmId,\n\t\t\t\t\t\t\t\trequired: hosted.minSecurity,\n\t\t\t\t\t\t\t\tactual\n\t\t\t\t\t\t\t}).toWireJsonObject()\n\t\t\t\t\t\t}));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst previousRealmId = state.slots.get(frame.slot);\n\t\t\t\tif (previousRealmId != null && previousRealmId !== frame.realmId) options.realms[previousRealmId]?.engine.detachConnection(engineConnKey(state, frame.slot), \"re-attached\", false);\n\t\t\t\tstate.slots.set(frame.slot, frame.realmId);\n\t\t\t\tif (!hosted.engine.attach(engineConnKey(state, frame.slot), {\n\t\t\t\t\tavatar,\n\t\t\t\t\tslot: frame.slot,\n\t\t\t\t\tschemaHash: frame.schemaHash,\n\t\t\t\t\tlastKnownVersion: frame.lastKnownVersion,\n\t\t\t\t\tepoch: frame.epoch,\n\t\t\t\t\tsend\n\t\t\t\t})) {\n\t\t\t\t\tif (previousRealmId === frame.realmId) hosted.engine.detachConnection(engineConnKey(state, frame.slot), \"re-attached\", false);\n\t\t\t\t\tstate.slots.delete(frame.slot);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst realmId = state.slots.get(frame.slot);\n\t\t\tconst hosted = realmId == null ? void 0 : options.realms[realmId];\n\t\t\tif (hosted == null) {\n\t\t\t\tif (frame.kind !== REALM_FRAME_KIND.detach) send(encodeDetach({\n\t\t\t\t\tslot: frame.slot,\n\t\t\t\t\treason: REALM_DETACH_REASON_REHELLO\n\t\t\t\t}));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\thosted.engine.receiveFrame(engineConnKey(state, frame.slot), frame, payload.byteLength);\n\t\t\tif (frame.kind === REALM_FRAME_KIND.detach) state.slots.delete(frame.slot);\n\t\t},\n\t\tonDetach(connection) {\n\t\t\tconst state = connStates.get(connection);\n\t\t\tif (state == null) return;\n\t\t\tfor (const [slot, realmId] of state.slots) options.realms[realmId]?.engine.detachConnection(engineConnKey(state, slot), \"connection lost\");\n\t\t\tstate.slots.clear();\n\t\t}\n\t};\n}\n//#endregion\nexport { RealmKeyDict as C, REALM_FRAME_KIND_NAME as S, err_realm as T, encodeIntent as _, sliceStateForAvatar as a, REALM_FEATURE as b, canonicalizeStatePatches as c, wireOpsToNamePatches as d, pathHasUnsafeKey as f, encodeHello as g, encodeDetach as h, createRealmServerEngine as i, namePatchesToWireOps as l, encodeClientCaps as m, DEFAULT_REALM_LIMITS as n, expandWriteToLeaves as o, decodeRealmFrame as p, RealmServerEngine as r, evalAlterCond as s, createRealmAcceptor as t, schemaNodeAtPath as u, encodeWrite as v, validateValue as w, REALM_FRAME_KIND as x, REALM_DETACH_REASON_REHELLO as y };\n\n//# sourceMappingURL=realmAcceptorProtocol-DqECRw9r.mjs.map","import { deepEqual } from \"fast-equals\";\nimport { applyPatches, enablePatches, produce, produceWithPatches } from \"immer\";\n//#region src/state/core/Store.ts\nenablePatches();\n/**\n* @internal\n*\n* Builds the per-emission runner for a selector subscription.\n*\n* Change detection follows the \"Fast-Path\" rule: Immer's structural sharing\n* means an untouched branch keeps its exact reference, so a strict `===` check\n* resolves the overwhelmingly common \"nothing changed\" case in 0ms. Only when\n* the reference actually changes do we pay for a `deepEqual` traversal to\n* confirm the change is structural and not just a new-but-equal reference.\n*/\nfunction makeSubscriptionFunction(store, watch, listener) {\n\tlet lastWatchState = watch(store.state);\n\treturn () => {\n\t\tconst currentState = store.state;\n\t\tconst nextWatchState = watch(currentState);\n\t\tif (nextWatchState === lastWatchState) return;\n\t\tif (deepEqual(nextWatchState, lastWatchState)) {\n\t\t\tlastWatchState = nextWatchState;\n\t\t\treturn;\n\t\t}\n\t\tconst previousWatched = lastWatchState;\n\t\tlastWatchState = nextWatchState;\n\t\tlistener(nextWatchState, currentState, previousWatched);\n\t};\n}\n/**\n* @internal\n*\n* Builds a reaction creator. Reactions follow the same Fast-Path rule as\n* subscriptions, then run their recipe inside Immer to derive further state.\n*/\nfunction makeReactionFunctionCreator(watch, reaction) {\n\treturn (store) => {\n\t\tlet lastWatchState = watch(store.state);\n\t\treturn (forceRun = false) => {\n\t\t\tconst currentState = store.state;\n\t\t\tconst nextWatchState = watch(currentState);\n\t\t\tif (!forceRun) {\n\t\t\t\tif (nextWatchState === lastWatchState) return;\n\t\t\t\tif (deepEqual(nextWatchState, lastWatchState)) {\n\t\t\t\t\tlastWatchState = nextWatchState;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst previousWatched = lastWatchState;\n\t\t\tlastWatchState = nextWatchState;\n\t\t\tif (store._hasPatchListeners()) {\n\t\t\t\tconst [nextState, patches, inversePatches] = produceWithPatches(currentState, (draft) => {\n\t\t\t\t\treaction(nextWatchState, draft, currentState, previousWatched);\n\t\t\t\t});\n\t\t\t\tstore._updateStateWithoutReaction(nextState);\n\t\t\t\tif (patches.length > 0) store._emitPatches(patches, inversePatches);\n\t\t\t} else {\n\t\t\t\tconst nextState = produce(currentState, (draft) => {\n\t\t\t\t\treaction(nextWatchState, draft, currentState, previousWatched);\n\t\t\t\t});\n\t\t\t\tstore._updateStateWithoutReaction(nextState);\n\t\t\t}\n\t\t};\n\t};\n}\n/**\n* A framework-agnostic, Immer-backed state container.\n*\n* The store owns a single immutable state value and a `Set` of plain\n* listeners. Every mutation runs through Immer's `produce`, and listeners are\n* only notified when the resulting root reference actually changes — making\n* \"no-op\" updates genuinely free for subscribers.\n*\n* @typeParam S  Your store's state interface.\n*/\nvar Store = class {\n\tcurrentState;\n\tcreateInitialState;\n\tssr = false;\n\t/** Plain pub/sub listeners — a Set both dedupes and dispatches fast. */\n\tlisteners = /* @__PURE__ */ new Set();\n\treactionCreators = [];\n\treactions = [];\n\tclientSubscriptions = [];\n\t/**\n\t* @internal\n\t*/\n\t_patchListeners = [];\n\tconstructor(initialState) {\n\t\tif (initialState instanceof Function) {\n\t\t\tthis.createInitialState = initialState;\n\t\t\tthis.currentState = initialState();\n\t\t} else {\n\t\t\tthis.createInitialState = () => initialState;\n\t\t\tthis.currentState = initialState;\n\t\t}\n\t}\n\t/**\n\t* The store's current state, frozen (shallow) for read safety — mutations must go through\n\t* {@link update} / {@link replace}, never by writing to this object.\n\t*\n\t* Reach for it in plain logic (event handlers, engines, tests). In React components use\n\t* `useStoreState` so the component re-renders on change; for side-effects use {@link watch}.\n\t*/\n\tget state() {\n\t\treturn Object.freeze(this.currentState);\n\t}\n\t/**\n\t* @internal\n\t*/\n\t_setInternalOptions({ ssr, reactionCreators = [] }) {\n\t\tthis.ssr = ssr;\n\t\tthis.reactionCreators = reactionCreators;\n\t\tthis.reactions = reactionCreators.map((rc) => rc(this));\n\t}\n\t/**\n\t* @internal\n\t*/\n\t_getReactionCreators() {\n\t\treturn this.reactionCreators;\n\t}\n\t/**\n\t* @internal\n\t*/\n\t_instantiateReactions() {\n\t\tthis.reactions = this.reactionCreators.map((rc) => rc(this));\n\t}\n\t/**\n\t* @internal\n\t*/\n\t_getInitialState() {\n\t\treturn this.createInitialState();\n\t}\n\t/**\n\t* @internal\n\t*/\n\t_hasPatchListeners() {\n\t\treturn this._patchListeners.length > 0;\n\t}\n\t/**\n\t* @internal\n\t*/\n\t_emitPatches(patches, inversePatches) {\n\t\tfor (const listener of this._patchListeners) listener(patches, inversePatches);\n\t}\n\t/**\n\t* @internal\n\t*\n\t* Writes a new state value without running reactions. Used by reactions\n\t* themselves to avoid re-entrancy.\n\t*/\n\t_updateStateWithoutReaction(nextState) {\n\t\tthis.currentState = nextState;\n\t}\n\t/**\n\t* @internal\n\t*\n\t* Commits a new root state, runs reactions, then dispatches to all\n\t* subscribers. Callers are responsible for the `nextState !== currentState`\n\t* reference guard before invoking this.\n\t*/\n\t_updateState(nextState) {\n\t\tthis.currentState = nextState;\n\t\tfor (const runReaction of this.reactions) runReaction();\n\t\tif (this.ssr) return;\n\t\tfor (const runSubscription of this.clientSubscriptions) runSubscription();\n\t\tfor (const listener of this.listeners) listener();\n\t}\n\t/**\n\t* Subscribe a plain listener to store mutations. The listener fires once per\n\t* committed update (root reference change) and receives no arguments — read\n\t* the latest value with {@link state}.\n\t*\n\t* This is the low-level primitive that vanilla code and framework adapters\n\t* (e.g. React's `useSyncExternalStore`) build upon.\n\t*\n\t* @returns An unsubscribe function.\n\t*/\n\tsubscribe(listener) {\n\t\tthis.listeners.add(listener);\n\t\treturn () => {\n\t\t\tthis.listeners.delete(listener);\n\t\t};\n\t}\n\t/**\n\t* Subscribe to a derived slice of state. The `listener` only fires when the\n\t* watched value changes structurally (per the Fast-Path rule).\n\t*\n\t* @returns An unsubscribe function.\n\t*/\n\twatch(watch, listener) {\n\t\tif (this.ssr) return () => {\n\t\t\tconsole.warn(`connect-core/state: Subscriptions made on the server side are not registered, so this unsubscribe call does nothing.`);\n\t\t};\n\t\tconst run = makeSubscriptionFunction(this, watch, listener);\n\t\tthis.clientSubscriptions.push(run);\n\t\treturn () => {\n\t\t\tthis.clientSubscriptions = this.clientSubscriptions.filter((f) => f !== run);\n\t\t};\n\t}\n\t/**\n\t* Register a reaction: when the watched slice changes, the `reaction` recipe\n\t* runs inside Immer to derive further state on the same store.\n\t*\n\t* @returns A function that removes the reaction.\n\t*/\n\tcreateReaction(watch, reaction, { runNow = false, runNowWithSideEffects = false } = {}) {\n\t\tconst creator = makeReactionFunctionCreator(watch, reaction);\n\t\tthis.reactionCreators.push(creator);\n\t\tconst run = creator(this);\n\t\tthis.reactions.push(run);\n\t\tif (runNow || runNowWithSideEffects) {\n\t\t\trun(true);\n\t\t\tif (runNowWithSideEffects && !this.ssr) this._updateState(this.currentState);\n\t\t}\n\t\treturn () => {\n\t\t\tthis.reactions = this.reactions.filter((f) => f !== run);\n\t\t\tthis.reactionCreators = this.reactionCreators.filter((f) => f !== creator);\n\t\t};\n\t}\n\t/**\n\t* Subscribe to the Immer patches produced by each update.\n\t*\n\t* @returns An unsubscribe function.\n\t*/\n\tlistenToPatches(patchListener) {\n\t\tthis._patchListeners.push(patchListener);\n\t\treturn () => {\n\t\t\tthis._patchListeners = this._patchListeners.filter((f) => f !== patchListener);\n\t\t};\n\t}\n\t/**\n\t* Mutate the store via one or more Immer update functions.\n\t*\n\t* @param updater          A single update function, or an array applied in order.\n\t* @param patchesCallback  Optional callback receiving the patches for this update.\n\t*/\n\tupdate(updater, patchesCallback) {\n\t\tupdate(this, updater, patchesCallback);\n\t}\n\t/**\n\t* Replace the store's state entirely with a new state value — the reset/swap counterpart to\n\t* {@link update} (whose update functions are mutate-only). A replace is a first-class citizen\n\t* of the patch stream: patch listeners receive one root `replace` patch (path `[]`) with its\n\t* inverse, so persistence/undo/sync layers built on {@link listenToPatches} see resets too.\n\t*/\n\treplace(newState) {\n\t\tif (newState === this.currentState) return;\n\t\tif (this._hasPatchListeners()) this._emitPatches([{\n\t\t\top: \"replace\",\n\t\t\tpath: [],\n\t\t\tvalue: newState\n\t\t}], [{\n\t\t\top: \"replace\",\n\t\t\tpath: [],\n\t\t\tvalue: this.currentState\n\t\t}]);\n\t\tthis._updateState(newState);\n\t}\n\t/**\n\t* Replace the store's state by mapping from the current state.\n\t*/\n\treplaceFromCurrent(replacer) {\n\t\tthis.replace(replacer(this.currentState));\n\t}\n\t/**\n\t* Apply a set of Immer patches to the store.\n\t*/\n\tapplyPatches(patches) {\n\t\tapplyPatchesToStore(this, patches);\n\t}\n};\n/**\n* Apply Immer patches to a store, committing only if the root reference changes.\n*/\nfunction applyPatchesToStore(store, patches) {\n\tconst currentState = store.state;\n\tconst nextState = applyPatches(currentState, patches);\n\tif (nextState !== currentState) store._updateState(nextState);\n}\n/**\n* @internal\n*\n* The \"returned a replacement state\" footgun guard: the update pipeline is mutate-only — unlike\n* immer's `produce`, a state returned from an update function is NOT honored. The natural\n* reset idiom `store.update(() => createInitialState())` therefore used to be a *silent no-op*.\n* An updater that returned an object while leaving its draft untouched almost certainly meant\n* exactly that, so it throws here instead. (Concise-arrow returns like `(d) => d.count++` or\n* `(d) => (d.x = value)` modify the draft and stay allowed.)\n*\n* **A returned *draft* is not the footgun** — `Object.assign(draft, next)` already applied the\n* mutation, and returning the draft is merely redundant. Judging it by whether the draft happened\n* to change made the throw data-dependent: the pattern passed every first run and blew up later\n* on the one reset where `next` was identical (meteor-connect-bridge feedback S1). Splitting on\n* draft identity instead is deterministic — a returned draft always passes, a returned\n* *replacement* with an untouched draft always throws.\n*/\nfunction assertNoReturnedState(returned, draftWasModified, returnedIsDraft) {\n\tif (returnedIsDraft) return;\n\tif (!draftWasModified && typeof returned === \"object\" && returned != null) throw new Error(\"connect-core/state: an update function returned a value without modifying its draft. Update functions are mutate-only — a returned state is ignored (unlike immer's produce). To reset or swap the state wholesale, use store.replace(next); to change part of it, mutate the draft.\");\n}\n/**\n* @internal\n*\n* Runs an updater (or array of updaters) through Immer, collecting patches.\n*/\nfunction applyUpdaterWithPatches(currentState, updater) {\n\tif (typeof updater === \"function\") {\n\t\tlet returned;\n\t\tlet returnedIsDraft = false;\n\t\tconst [next, patches, inversePatches] = produceWithPatches(currentState, (draft) => {\n\t\t\treturned = updater(draft, currentState);\n\t\t\treturnedIsDraft = returned === draft;\n\t\t});\n\t\tassertNoReturnedState(returned, next !== currentState, returnedIsDraft);\n\t\treturn [\n\t\t\tnext,\n\t\t\tpatches,\n\t\t\tinversePatches\n\t\t];\n\t}\n\tlet state = currentState;\n\tconst patches = [];\n\tconst inversePatches = [];\n\tfor (const single of updater) {\n\t\tlet returned;\n\t\tlet returnedIsDraft = false;\n\t\tconst [next, p, ip] = produceWithPatches(state, (draft) => {\n\t\t\treturned = single(draft, state);\n\t\t\treturnedIsDraft = returned === draft;\n\t\t});\n\t\tassertNoReturnedState(returned, next !== state, returnedIsDraft);\n\t\tstate = next;\n\t\tpatches.push(...p);\n\t\tinversePatches.push(...ip);\n\t}\n\treturn [\n\t\tstate,\n\t\tpatches,\n\t\tinversePatches\n\t];\n}\n/**\n* @internal\n*\n* Runs an updater (or array of updaters) through Immer without tracking patches.\n*/\nfunction applyUpdater(currentState, updater) {\n\tif (typeof updater === \"function\") {\n\t\tlet returned;\n\t\tlet returnedIsDraft = false;\n\t\tconst next = produce(currentState, (draft) => {\n\t\t\treturned = updater(draft, currentState);\n\t\t\treturnedIsDraft = returned === draft;\n\t\t});\n\t\tassertNoReturnedState(returned, next !== currentState, returnedIsDraft);\n\t\treturn next;\n\t}\n\treturn updater.reduce((previousState, single) => {\n\t\tlet returned;\n\t\tlet returnedIsDraft = false;\n\t\tconst next = produce(previousState, (draft) => {\n\t\t\treturned = single(draft, previousState);\n\t\t\treturnedIsDraft = returned === draft;\n\t\t});\n\t\tassertNoReturnedState(returned, next !== previousState, returnedIsDraft);\n\t\treturn next;\n\t}, currentState);\n}\n/**\n* Mutate a store via one or more Immer update functions.\n*\n* Patches are only computed when there's a consumer for them (a registered\n* patch listener or a `patchesCallback`), keeping the common path allocation-free.\n* Listeners are notified only when the root reference actually changes.\n*\n* @param store            The store to update.\n* @param updater          A single update function, or an array applied in order.\n* @param patchesCallback  Optional callback receiving the patches for this update.\n*/\nfunction update(store, updater, patchesCallback) {\n\tconst currentState = store.state;\n\tlet nextState;\n\tif (store._hasPatchListeners() || patchesCallback != null) {\n\t\tconst [next, patches, inversePatches] = applyUpdaterWithPatches(currentState, updater);\n\t\tif (patches.length > 0) {\n\t\t\tif (patchesCallback != null) patchesCallback(patches, inversePatches);\n\t\t\tstore._emitPatches(patches, inversePatches);\n\t\t}\n\t\tnextState = next;\n\t} else nextState = applyUpdater(currentState, updater);\n\tif (nextState !== currentState) store._updateState(nextState);\n}\n//#endregion\nexport { applyPatchesToStore as n, update as r, Store as t };\n\n//# sourceMappingURL=state-DGS3KIFN.mjs.map","import { A as securityLevelMeets } from \"./wire-D7Nv6hx_.mjs\";\nimport { s as castNiceError } from \"./error-BFAEkmpX.mjs\";\nimport \"./ReliableLog-DudDQ2zp.mjs\";\nimport { t as unrefTimer } from \"./util-DiEla9R9.mjs\";\nimport { t as Store } from \"./state-DGS3KIFN.mjs\";\nimport { C as RealmKeyDict, S as REALM_FRAME_KIND_NAME, T as err_realm, _ as encodeIntent, b as REALM_FEATURE, c as canonicalizeStatePatches, d as wireOpsToNamePatches, f as pathHasUnsafeKey, g as encodeHello, h as encodeDetach, l as namePatchesToWireOps, m as encodeClientCaps, o as expandWriteToLeaves, s as evalAlterCond, u as schemaNodeAtPath, v as encodeWrite, w as validateValue, x as REALM_FRAME_KIND } from \"./realmAcceptorProtocol-DqECRw9r.mjs\";\nimport { unpack } from \"msgpackr\";\nimport { applyPatches, enablePatches, produceWithPatches } from \"immer\";\n//#region src/realm/RealmClient/assertRealmSecurity.ts\n/**\n* The client-side security floor. The server's attach gate stops\n* *routing* an under-secured avatar — it does NOT stop this client from *sending*. So only this\n* local check keeps avatar identity/state from leaving the device as app-layer plaintext when a\n* realm marked `security: \"encrypted\"` is connected over an `authenticated` link (a misconfigured\n* client). It runs **before the first `hello`**, and a shortfall blocks every realm frame, `hello`\n* included.\n*\n* Shared by {@link connectRealm} and {@link connectRealmReplica} so the two connect paths can't\n* drift — the replica is the highest-value leak (an \"everything\" view of the realm) and a wholly\n* separate code path.\n*/\n/** Map the realm-local policy level to the wire enum for ranking (no `as`, per the code guide). */\nfunction realmLevelToWire(level) {\n\treturn level === \"encrypted\" ? \"encrypted\" : \"authenticated\";\n}\n/**\n* The effective client minimum = the higher of the realm's declared floor and an optional\n* per-connect override. The override can only *raise* the bar (checking against `realm.security`\n* alone would silently ignore a caller asking for more — Phase 4.2). The server enforces its own\n* floor independently.\n*/\nfunction effectiveClientMinimum(realmSecurity, connectOverride) {\n\tif (connectOverride == null) return realmSecurity;\n\treturn realmSecurity === \"encrypted\" || connectOverride === \"encrypted\" ? \"encrypted\" : \"authenticated\";\n}\n/**\n* Returns the `insufficient_security` reject error when the connection's negotiated level is below\n* the effective client minimum (`max(realm.security, connectOverride)`), or `undefined` to proceed.\n*\n* A bare-mux adapter (a test loopback) reports **no** level → the check is skipped: the level is\n* unknown, and production always attaches through a `ChannelConnector`, which carries one (Phase\n* 4.2). Callers apply the detach themselves (set `attachError`, status `detached`, skip `hello`) —\n* the *check* lives here so it can't diverge between the two connect paths.\n*/\nfunction computeRealmSecurityShortfall(adapter, realm, connectOverride) {\n\tconst actual = adapter.securityLevel;\n\tif (actual == null) return void 0;\n\tconst required = realmLevelToWire(effectiveClientMinimum(realm.security, connectOverride));\n\tif (securityLevelMeets(actual, required)) return void 0;\n\treturn err_realm.fromId(\"insufficient_security\", {\n\t\trealmId: realm.id,\n\t\trequired,\n\t\tactual\n\t});\n}\n//#endregion\n//#region src/realm/RealmClient/diffProjected.ts\n/**\n* Structural diff between two projections: the generic version of what imperative\n* renderers used to hand-roll per consumer (the pixel demo's 40-line identity-gated record\n* diff). Immer's structural sharing makes it cheap: an unchanged subtree keeps its reference\n* across `applyPatches`/rebase, so `prev === next` prunes it in O(1) — the walk only descends\n* where something actually changed.\n*\n* Semantics match the realm's canonical patch shape: plain objects/records diff per key\n* (`add`/`remove`/recurse); everything else — primitives, arrays (already canonicalized to\n* whole-array replaces on the wire), type changes — is a leaf `replace`.\n*/\nfunction diffProjected(prev, next, path = []) {\n\tif (prev === next) return [];\n\tif (!isPlainRecord(prev) || !isPlainRecord(next)) return [{\n\t\top: \"replace\",\n\t\tpath: [...path],\n\t\tvalue: next\n\t}];\n\tconst patches = [];\n\tfor (const key of Object.keys(next)) if (key in prev) patches.push(...diffProjected(prev[key], next[key], [...path, key]));\n\telse patches.push({\n\t\top: \"add\",\n\t\tpath: [...path, key],\n\t\tvalue: next[key]\n\t});\n\tfor (const key of Object.keys(prev)) if (!(key in next)) patches.push({\n\t\top: \"remove\",\n\t\tpath: [...path, key]\n\t});\n\treturn patches;\n}\nfunction isPlainRecord(value) {\n\treturn typeof value === \"object\" && value != null && !Array.isArray(value);\n}\n//#endregion\n//#region src/realm/RealmClient/predict.ts\n/**\n* Client-side write prediction: the same expansion + rule pipeline the server\n* runs, minus everything server-only — `r.serverChecked` parts auto-pass (that is exactly the\n* slice of optimism that can later roll back), `prev`/`state` come from the writer's projected\n* view. A NiceError here rejects the write in the same tick, before anything renders.\n*/\nfunction getProjectedAtPath(state, path) {\n\tlet current = state;\n\tfor (const seg of path) {\n\t\tif (current == null || typeof current !== \"object\") return void 0;\n\t\tcurrent = current[seg];\n\t}\n\treturn current;\n}\nfunction predictWrite(options) {\n\tconst { realm, avatar, state, basisVersion } = options;\n\tfor (const patch of options.patches) {\n\t\tconst path = patch.path;\n\t\tconst node = schemaNodeAtPath(realm.stateDef, path);\n\t\tif (node == null) return err_realm.fromId(\"value_invalid\", {\n\t\t\tpath: path.join(\".\"),\n\t\t\texpected: \"a schema path\"\n\t\t});\n\t\tif (patch.op !== \"remove\") {\n\t\t\tconst invalid = validateValue(node, patch.value);\n\t\t\tif (invalid != null) return err_realm.fromId(\"value_invalid\", {\n\t\t\t\tpath: [...path, ...invalid.path].join(\".\"),\n\t\t\t\texpected: invalid.expected\n\t\t\t});\n\t\t\tfor (let i = 1; i < path.length; i++) {\n\t\t\t\tlet ancestor = schemaNodeAtPath(realm.stateDef, path.slice(0, i));\n\t\t\t\twhile (ancestor?.kind === \"optional\") ancestor = ancestor.inner;\n\t\t\t\tif (ancestor?.kind !== \"record\" || ancestor.maxKeys == null) continue;\n\t\t\t\tconst container = getProjectedAtPath(state, path.slice(0, i));\n\t\t\t\tif (container == null || typeof container !== \"object\" || Array.isArray(container)) continue;\n\t\t\t\tif (!(path[i] in container) && Object.keys(container).length >= ancestor.maxKeys) return err_realm.fromId(\"value_invalid\", {\n\t\t\t\t\tpath: path.slice(0, i).join(\".\"),\n\t\t\t\t\texpected: `a record with at most ${ancestor.maxKeys} entries`\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tconst leaves = expandWriteToLeaves({\n\t\t\tschemaRoot: realm.stateDef,\n\t\t\tpath,\n\t\t\top: patch.op,\n\t\t\tvalue: patch.value,\n\t\t\tstate,\n\t\t\tmaxLeaves: Number.POSITIVE_INFINITY\n\t\t});\n\t\tfor (const leafPath of leaves) {\n\t\t\tconst match = realm.ruleTrie.match(leafPath);\n\t\t\tif (match == null) return err_realm.fromId(\"unauthorized_coordinate\", { path: leafPath.join(\".\") });\n\t\t\tconst rel = leafPath.slice(path.length);\n\t\t\tconst verdict = evalAlterCond(match.rule.alter, {\n\t\t\t\tavatar,\n\t\t\t\tparams: match.params,\n\t\t\t\tprev: getAtPath$1(state, leafPath),\n\t\t\t\tnext: patch.op === \"remove\" ? void 0 : getAtPath$1(patch.value, rel),\n\t\t\t\tstate,\n\t\t\t\tbasisVersion\n\t\t\t}, void 0);\n\t\t\tif (verdict === \"serverOnly\") return err_realm.fromId(\"unauthorized_coordinate\", { path: leafPath.join(\".\") });\n\t\t\tif (verdict !== true) return verdict;\n\t\t}\n\t}\n\treturn true;\n}\nfunction getAtPath$1(state, path) {\n\tlet current = state;\n\tfor (const seg of path) {\n\t\tif (current == null || typeof current !== \"object\") return void 0;\n\t\tcurrent = current[seg];\n\t}\n\treturn current;\n}\n//#endregion\n//#region src/realm/RealmClient/structuralParents.ts\n/**\n* Defense-in-depth for the confirmed-apply path: interleave synthetic `add <prefix> = {}` patches\n* so every inbound `add`/`replace` finds its **structural** parents. A slice may legitimately lack\n* a fixed container the schema declares (an empty nested record omitted by an older server, or a\n* container whose position only deeper exact rules cover) — immer's `applyPatches` would then\n* throw `path doesn't resolve` on the child patch, far from the cause. Fixed containers are\n* structural (the schema ships to every client), so synthesizing an empty shell reveals nothing.\n*\n* It deliberately does NOT synthesize a missing **dynamic record entry**: a missing\n* entry means a missed `add <entry> = {…}`, and fabricating a `{}` shell would produce a silent\n* partial entry (missing the add's fields) that persists until the next reconnect. There, the\n* throw is the right outcome — the Phase-3 inbound wrap turns it into a resync that re-fetches the\n* whole entry from authority.\n*/\nfunction withStructuralParents(state, patches, schemaRoot) {\n\tlet out;\n\tfor (let index = 0; index < patches.length; index++) {\n\t\tconst patch = patches[index];\n\t\tif (patch.op !== \"remove\" && patch.path.length > 1) for (let depth = 1; depth < patch.path.length; depth++) {\n\t\t\tconst prefix = patch.path.slice(0, depth);\n\t\t\tif (prefixResolves(state, out ?? patches.slice(0, index), prefix)) continue;\n\t\t\tconst parentNode = depth === 1 ? void 0 : schemaNodeAtPath(schemaRoot, prefix.slice(0, -1));\n\t\t\tif (parentNode != null && unwrapOptional(parentNode).kind === \"record\") break;\n\t\t\tconst node = schemaNodeAtPath(schemaRoot, prefix);\n\t\t\tif (node == null) break;\n\t\t\tconst kind = unwrapOptional(node).kind;\n\t\t\tif (kind !== \"object\" && kind !== \"record\") break;\n\t\t\tout ??= patches.slice(0, index);\n\t\t\tout.push({\n\t\t\t\top: \"add\",\n\t\t\t\tpath: prefix,\n\t\t\t\tvalue: {}\n\t\t\t});\n\t\t}\n\t\tout?.push(patch);\n\t}\n\treturn out ?? patches;\n}\n/** Whether `prefix` resolves in `state` as already patched by the `earlier` batch entries. */\nfunction prefixResolves(state, earlier, prefix) {\n\tfor (let i = earlier.length - 1; i >= 0; i--) {\n\t\tconst patch = earlier[i];\n\t\tif (patch.path.length > prefix.length) continue;\n\t\tif (!patch.path.every((seg, j) => String(seg) === String(prefix[j]))) continue;\n\t\tif (patch.op === \"remove\") return false;\n\t\treturn getAtPath(patch.value, prefix.slice(patch.path.length)) !== void 0;\n\t}\n\treturn getAtPath(state, prefix) !== void 0;\n}\nfunction unwrapOptional(node) {\n\treturn node.kind === \"optional\" ? unwrapOptional(node.inner) : node;\n}\nfunction getAtPath(value, path) {\n\tlet current = value;\n\tfor (const seg of path) {\n\t\tif (current == null || typeof current !== \"object\") return void 0;\n\t\tcurrent = current[seg];\n\t}\n\treturn current;\n}\n//#endregion\n//#region src/realm/RealmClient/writeHandle.ts\nfunction createWriteHandle() {\n\tlet status = \"pending\";\n\tlet settled;\n\tlet error;\n\tlet promise;\n\tlet resolvePromise;\n\tlet rejectPromise;\n\tconst materialize = () => {\n\t\tif (promise == null) if (status === \"confirmed\" && settled != null) promise = Promise.resolve(settled);\n\t\telse if (status === \"rejected\") promise = Promise.reject(error);\n\t\telse promise = new Promise((resolve, reject) => {\n\t\t\tresolvePromise = resolve;\n\t\t\trejectPromise = reject;\n\t\t});\n\t\treturn promise;\n\t};\n\treturn {\n\t\thandle: {\n\t\t\tget status() {\n\t\t\t\treturn status;\n\t\t\t},\n\t\t\tget error() {\n\t\t\t\treturn error;\n\t\t\t},\n\t\t\tthen: (onFulfilled, onRejected) => materialize().then(onFulfilled, onRejected)\n\t\t},\n\t\tconfirm(value) {\n\t\t\tif (status !== \"pending\") return;\n\t\t\tstatus = \"confirmed\";\n\t\t\tsettled = value;\n\t\t\tresolvePromise?.(value);\n\t\t},\n\t\treject(reason) {\n\t\t\tif (status !== \"pending\") return;\n\t\t\tstatus = \"rejected\";\n\t\t\terror = reason;\n\t\t\trejectPromise?.(reason);\n\t\t}\n\t};\n}\n//#endregion\n//#region src/realm/RealmClient/RealmClient.ts\nenablePatches();\nfunction createStepGuard() {\n\tlet failure;\n\treturn {\n\t\trun(step) {\n\t\t\ttry {\n\t\t\t\tstep();\n\t\t\t} catch (error) {\n\t\t\t\tfailure ??= { error };\n\t\t\t}\n\t\t},\n\t\trethrow() {\n\t\t\tif (failure != null) throw failure.error;\n\t\t}\n\t};\n}\n/** The durable-write backlog cap (§4): past this many unconfirmed reassert frames, new reassert\n* writes reject loudly instead of growing memory for the length of the outage. */\nconst MAX_REASSERT_PENDING_FRAMES = 256;\n/**\n* The sentinel `clientSeq` for a Phase 2 reassert-lane system-assert. Negative so it never collides\n* with a real client seq (0, 1, 2, …); the engine applies such a frame through the full rules\n* pipeline but skips the replay high-water, so it can be ordered on the wire before pending frames\n* without swallowing their seqs (the §0 constraint). An old server (≤ 0.47) dup-acks any `seq ≤ -1`,\n* degrading gracefully to the post-answer fallback re-own.\n*/\nconst SYSTEM_ASSERT_SEQ = -2;\n/** How many `limits_exceeded` rejects one write frame may absorb before settling as a reject. */\nconst MAX_LIMIT_RETRIES = 3;\n/** Backoff before resending a frame the server rate-limited (`writeRatePerSecond` breach). */\nconst RATE_RETRY_MS = 1e3;\n/**\n* Does this inbound frame prove we are **in sync** with the server — as opposed to merely proving\n* the socket is up?\n*\n* Everything the server sends carries sync information (`hydrate`/`patches` are state, `ack` says a\n* write landed, `keyDict` extends the intern dictionary those depend on) **except a `reject`**,\n* which says only \"that write of yours was refused\". A stream of nothing but rejects is a link that\n* is alive and a client that is learning nothing — precisely the state the staleness probe exists\n* to break out of.\n*\n* A `batch` is transparent: it is healthy if any child is, so an envelope of pure rejects counts as\n* what it is. (Nesting is forbidden by the codec; the recursion costs nothing and means this cannot\n* be wrong if that ever changes.)\n*/\nfunction provesSyncHealth(frame) {\n\tif (frame.kind === REALM_FRAME_KIND.batch) return frame.frames.some(provesSyncHealth);\n\treturn frame.kind !== REALM_FRAME_KIND.reject;\n}\nconst DEFAULT_PENDING_EXPIRY_MS = 1e4;\nconst DEFAULT_STALE_PROBE_AFTER_MS = 25e3;\n/** How long a probe may go unanswered before the link is presumed dead. */\nconst DEFAULT_PROBE_REPLY_TIMEOUT_MS = 1e4;\n/**\n* Attach a realm client to a connection. The store starts empty and fills on hydrate;\n* `realm.update()` is the blessed write API (LWW absolute-set contract — read-modify-write\n* belongs in an intent, the protocol contract).\n*/\nfunction connectRealm(realm, options) {\n\tconst coordinate = options.connection.coordinate;\n\tconst persistentId = options.avatar.persistentId ?? coordinate?.perId;\n\tif (persistentId == null) throw new Error(\"connectRealm: no avatar identity — the connection carries no persistent id. Give it one where you open the connection (identity: coord.withPersistentId(id)), or pass avatar.persistentId explicitly.\");\n\tconst avatar = {\n\t\ttype: options.avatar.type,\n\t\tpersistentId,\n\t\tinstanceId: options.avatar.instanceId ?? coordinate?.insId ?? \"default\"\n\t};\n\tconst expiryMs = options.pendingExpiryMs ?? DEFAULT_PENDING_EXPIRY_MS;\n\tconst slot = options.connection.slot;\n\tconst devtools = options.devtools;\n\tconst coalesceCfg = options.coalesce ?? (options.coalesceMs != null ? { ms: options.coalesceMs } : void 0);\n\tconst coalesceWindowMs = coalesceCfg != null && coalesceCfg.ms > 0 ? coalesceCfg.ms : 0;\n\tconst coalesceLeading = coalesceCfg?.leading === true && coalesceWindowMs > 0;\n\tconst store = new Store({});\n\tconst dict = new RealmKeyDict();\n\tconst pendingListeners = /* @__PURE__ */ new Set();\n\tlet confirmed = {};\n\tlet confirmedVersion = -1;\n\t/** The log epoch `confirmedVersion` belongs to — echoed in every hello. */\n\tlet serverEpoch;\n\t/** Server-advertised ingress limits off the hydrate — drives flush splitting. */\n\tlet advertisedLimits;\n\tlet identityWarned = false;\n\tlet status = \"connecting\";\n\tlet attachError;\n\t/**\n\t* The prefix for this handle's `console.warn` floors. The realm id alone is ambiguous with\n\t* several *instances* of the same realm on one page (two matches of one game realm), so once the\n\t* hydrate names the server's history the epoch's first chars disambiguate — and correlate with\n\t* the server's own logs. Pre-hydrate warns keep the plain prefix (never block a warn on identity).\n\t*/\n\tconst warnTag = () => serverEpoch == null ? `[realm:${realm.id}]` : `[realm:${realm.id}#${serverEpoch.slice(0, 8)}]`;\n\t/** Status-transition listeners: `subscribeStatus` subscribers + the `whenLive` waiters (B.4). */\n\tconst statusListeners = /* @__PURE__ */ new Set();\n\t/** Latched on the first `live` and never reset — joining vs reconnecting. */\n\tlet hasBeenLive = false;\n\tconst setStatus = (next) => {\n\t\tif (status === next) return;\n\t\tstatus = next;\n\t\tif (next === \"live\") hasBeenLive = true;\n\t\tconst guard = createStepGuard();\n\t\tif (next === \"detached\") guard.run(rejectHydrateQueue);\n\t\tfor (const listener of [...statusListeners]) guard.run(() => listener(next, { hasBeenLive }));\n\t\tguard.run(() => devtools?.onStatus?.(next, { hasBeenLive }));\n\t\tguard.rethrow();\n\t};\n\tlet pending = [];\n\tconst hydrateQueue = [];\n\t/** Set from the hydrate's `confirmedVersion` until its queue drains: new writes queue behind. */\n\tlet hydrating = false;\n\tlet nextSeq = 0;\n\tlet flushScheduled = false;\n\tlet projecting = false;\n\tlet port;\n\t/**\n\t* Staleness-probe clocks.\n\t*\n\t* `lastSyncInboundAt` is deliberately a **sync-health** clock, not a liveness one: only a frame\n\t* carrying real server sync information stamps it (see {@link provesSyncHealth}). A `reject`\n\t* proves the link is *up*, and proves nothing about whether we are in sync — so it must not\n\t* suppress the probe. That distinction matters because the two used to be one clock, and the\n\t* failure it allowed was self-sealing: a pathological reject loop is exactly the situation the\n\t* staleness probe exists to heal, and every reject in it pushed the probe further away\n\t*.\n\t*\n\t* There is no separate *liveness* clock here because nothing at this layer needs one — liveness is\n\t* the wire's job (`connectChannel({ heartbeat })`, which counts any inbound frame and drops a\n\t* silent link). The realm's probe is purely \"am I still in sync?\". If server-initiated liveness\n\t* ever lands and wants a pure inbound clock, it adds one then rather than re-merging these.\n\t*/\n\tlet lastSyncInboundAt = Date.now();\n\tlet lastProbeAt = 0;\n\t/** One-shot probe-reply deadline — armed after a probe, cleared by any inbound. */\n\tlet probeDeadline;\n\t/** An attach/recovery hello is out and unanswered — non-continuous frames drop, never apply. */\n\tlet helloInFlight = false;\n\tlet helloSentAt = 0;\n\t/** Suppress duplicate recovery hellos only while one is plausibly still being answered. */\n\tconst HELLO_REPLY_GRACE_MS = 1e4;\n\tconst warnedDiagnostics = /* @__PURE__ */ new Set();\n\t/** `subscribeDiagnostics` listeners — additive observers, multi-listener. */\n\tconst diagnosticListeners = /* @__PURE__ */ new Set();\n\tconst onDiagnostic = (event) => {\n\t\tdevtools?.onDiagnostic?.(event);\n\t\tfor (const listener of [...diagnosticListeners]) listener(event);\n\t\tif (options.onDiagnostic != null) {\n\t\t\toptions.onDiagnostic(event);\n\t\t\treturn;\n\t\t}\n\t\tif (diagnosticListeners.size > 0) return;\n\t\tif (!warnedDiagnostics.has(event.type)) {\n\t\t\twarnedDiagnostics.add(event.type);\n\t\t\tconsole.warn(`${warnTag()} sync-health event \"${event.type}\"`, event);\n\t\t}\n\t};\n\t/**\n\t* Deliver a rejection to `onMutationRejected`, or — when unwired — log a one-time floor for a\n\t* **silent rollback** (app-contract §2): a rejection that reverted already-shown optimistic state\n\t* (`rolledBackPaths` non-empty) would otherwise vanish with no trace (\"my move disappeared\"). A\n\t* rejection that never rendered (immediate predict/validation failures, `rolledBackPaths: []`) is\n\t* not warned — nothing was shown to roll back.\n\t*/\n\tlet warnedSilentRollback = false;\n\tconst emitRejection = (rejection) => {\n\t\tif (options.onMutationRejected != null) {\n\t\t\toptions.onMutationRejected(rejection);\n\t\t\treturn;\n\t\t}\n\t\tif (rejection.rolledBackPaths.length > 0 && !warnedSilentRollback) {\n\t\t\twarnedSilentRollback = true;\n\t\t\tconsole.warn(`${warnTag()} an optimistic ${rejection.kind} rolled back on [${rejection.rolledBackPaths.join(\", \")}] (${rejection.error.getIds().join(\", \")}) with no onMutationRejected handler — the change silently reverted. Wire onMutationRejected on connectRealm. Note: frame_too_stale is an UNKNOWN outcome (may have committed), not a definite reject.`);\n\t\t}\n\t};\n\tconst staleProbeAfterMs = options.staleProbeAfterMs ?? DEFAULT_STALE_PROBE_AFTER_MS;\n\tconst probeReplyTimeoutMs = options.probeReplyTimeoutMs ?? DEFAULT_PROBE_REPLY_TIMEOUT_MS;\n\t/**\n\t* Arm the escalation deadline after a probe-flavored hello (Phase 1.2 backstop): a probe/rehello\n\t* keeps `live` status for a one-round-trip heal on a link we still believe is up — but if NO\n\t* inbound frame lands within the window the link is genuinely dead/half-open, so flip to\n\t* `connecting` truthfully and ask the connection to re-dial. Status thus flips only on *evidence*\n\t* of an outage, never on a protocol chore (the Issue-1 contract). Cleared by any inbound frame.\n\t*/\n\tconst armProbeEscalation = () => {\n\t\tif (probeReplyTimeoutMs <= 0) return;\n\t\tif (probeDeadline != null) clearTimeout(probeDeadline);\n\t\tprobeDeadline = setTimeout(() => {\n\t\t\tprobeDeadline = void 0;\n\t\t\tif (status !== \"live\") return;\n\t\t\tif (lastSyncInboundAt >= lastProbeAt) return;\n\t\t\tonDiagnostic({ type: \"probe_escalated\" });\n\t\t\tsetStatus(\"connecting\");\n\t\t\toptions.connection.requestReconnect?.();\n\t\t}, probeReplyTimeoutMs);\n\t\tunrefTimer(probeDeadline);\n\t};\n\t/** A Phase 2 reassert-lane frame is awaiting its ack — the post-answer fallback re-own defers to it. */\n\tconst hasPendingSystemAssert = () => pending.some((frame) => frame.isSystemAssert);\n\t/** EWMA weight — ~last 5 samples dominate; steady under the occasional outlier. */\n\tconst STATS_ALPHA = .2;\n\tlet statsRttMs = null;\n\tlet statsJitterMs = null;\n\tlet statsSamples = 0;\n\tconst recordRttSample = (sampleMs) => {\n\t\tif (sampleMs < 0) return;\n\t\tstatsSamples += 1;\n\t\tif (statsRttMs == null || statsJitterMs == null) {\n\t\t\tstatsRttMs = sampleMs;\n\t\t\tstatsJitterMs = 0;\n\t\t} else {\n\t\t\tstatsJitterMs += STATS_ALPHA * (Math.abs(sampleMs - statsRttMs) - statsJitterMs);\n\t\t\tstatsRttMs += STATS_ALPHA * (sampleMs - statsRttMs);\n\t\t}\n\t\tdevtools?.onStats?.({\n\t\t\trttMs: statsRttMs,\n\t\t\tjitterMs: statsJitterMs,\n\t\t\tsamples: statsSamples\n\t\t});\n\t};\n\t/**\n\t* Declare lost-sync and heal via re-hello: the recovery hello is **probe-flavored**\n\t* — no status flap, since on a live link the heal is one round-trip (the server replays exactly\n\t* the missed span from `confirmedVersion`, or full-hydrates when out of window / epoch\n\t* mismatch). Safe in every trigger scenario because `applyConfirmed` is immutable — a detected\n\t* gap was never applied and a failed apply left `confirmed` untouched, so `confirmedVersion` is\n\t* always an honest basis. Suppressed while a hello is already in flight (time-bounded by the\n\t* reply grace, so a lost recovery hello cannot suppress forever). `sendHello` itself sets the\n\t* in-flight flag and arms escalation, so this just decides whether to fire (Phase 1.1).\n\t*/\n\tconst requestResync = (reason, detail) => {\n\t\tif (status === \"detached\") return;\n\t\tonDiagnostic({\n\t\t\ttype: \"resync\",\n\t\t\treason,\n\t\t\t...detail\n\t\t});\n\t\tif (helloInFlight && Date.now() - helloSentAt < HELLO_REPLY_GRACE_MS) return;\n\t\tif (port?.isOpen() !== true) return;\n\t\tsendHello({ probe: true });\n\t};\n\t/**\n\t* Parent paths a `write_target_missing` reject flagged, awaiting proof the recovery re-created\n\t* them. Keyed by `JSON.stringify(segments)` (a record key may contain a dot, so a string join is\n\t* not a safe key). Checked once the recovery has settled with no re-own in flight\n\t* ({@link checkReownWatch}); a still-missing parent emits `reown_missing` and escalates once.\n\t*/\n\tconst reownWatch = /* @__PURE__ */ new Map();\n\t/** Paths already escalated once (a forced full-hydrate) — the bound: at most one extra hydrate. */\n\tconst reownEscalated = /* @__PURE__ */ new Set();\n\t/** Walk `confirmed` to a path; `true` when every segment resolves to a non-null value. */\n\tconst confirmedHasPath = (segments) => {\n\t\tlet cursor = confirmed;\n\t\tfor (const seg of segments) {\n\t\t\tif (cursor == null || typeof cursor !== \"object\") return false;\n\t\t\tcursor = cursor[seg];\n\t\t}\n\t\treturn cursor != null;\n\t};\n\t/**\n\t* Verify the recovery re-created every watched parent (Phase 2). Runs only when no re-own is in\n\t* flight (a pending system-assert means \"wait — it may still land\"), so the sync loopback (assert\n\t* acked re-entrantly, `confirmed` already carries it) and the async wire (assert acks in a later\n\t* frame) both reach this with the outcome settled. A parent that is now present healed → cleared.\n\t* A parent still absent means the re-own produced no write for it (no `assertOnAttach`, a guard\n\t* that never observed the loss, or a rejected re-own): emit `reown_missing`, and on the FIRST such\n\t* event escalate with one forced full-hydrate (the in-place page-reload equivalent — the Phase 1\n\t* hydrate re-own gets a genuinely fresh basis). A second event for the same path (the forced\n\t* hydrate also failed) means the parent is legitimately gone — emit once more and stop (no loop).\n\t*/\n\tconst checkReownWatch = () => {\n\t\tif (reownWatch.size === 0) return;\n\t\tif (hasPendingSystemAssert()) return;\n\t\tfor (const [key, segments] of [...reownWatch]) {\n\t\t\tif (confirmedHasPath(segments)) {\n\t\t\t\treownWatch.delete(key);\n\t\t\t\treownEscalated.delete(key);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tonDiagnostic({\n\t\t\t\ttype: \"reown_missing\",\n\t\t\t\tpath: segments.join(\".\")\n\t\t\t});\n\t\t\tif (reownEscalated.has(key)) {\n\t\t\t\treownWatch.delete(key);\n\t\t\t\treownEscalated.delete(key);\n\t\t\t} else if (port?.isOpen() === true && status !== \"detached\") {\n\t\t\t\treownEscalated.add(key);\n\t\t\t\tsendHello({\n\t\t\t\t\tprobe: true,\n\t\t\t\t\tforceFullHydrate: true\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t};\n\t/** Backoff retry for a recovery whose ANSWER failed to apply: never a tight loop,\n\t* never a silent give-up — each retry re-emits the `resync` diagnostic via `requestResync`. */\n\tlet resyncAttempts = 0;\n\tlet resyncTimer;\n\tconst clearResyncRetry = () => {\n\t\tif (resyncTimer != null) {\n\t\t\tclearTimeout(resyncTimer);\n\t\t\tresyncTimer = void 0;\n\t\t}\n\t};\n\tconst scheduleResyncWithBackoff = () => {\n\t\thelloInFlight = false;\n\t\tif (resyncTimer != null) return;\n\t\tconst delay = Math.min(250 * 2 ** resyncAttempts, 5e3);\n\t\tresyncAttempts += 1;\n\t\tconst timer = setTimeout(() => {\n\t\t\tresyncTimer = void 0;\n\t\t\trequestResync(\"frame_error\");\n\t\t}, delay);\n\t\tunrefTimer(timer);\n\t\tresyncTimer = timer;\n\t};\n\tconst notifyPending = () => {\n\t\tfor (const listener of pendingListeners) listener();\n\t};\n\t/** Patch-feed listeners + the last projection they were told about. */\n\tconst patchListeners = /* @__PURE__ */ new Set();\n\tlet lastProjected = {};\n\t/**\n\t* Batch coalescing (Phase 2): while applying one `batch` envelope's children, per-child `project()`\n\t* calls are suppressed and collapsed into a single projection after the last child — N store\n\t* flushes / re-renders / patch-feed emissions become one.\n\t*/\n\tlet projectSuppressed = false;\n\tlet suppressedProjectPending = false;\n\t/**\n\t* Provenance through the suppression window (Dirt Derby item 7): the collapsed post-batch flush\n\t* reports `\"confirm\"` only when EVERY suppressed child projection was itself a confirm apply\n\t* (fresh authority, no optimistic overlay) — one non-confirm child (an ack settle, a rebase)\n\t* downgrades the whole collapse to `\"rebase\"`.\n\t*/\n\tlet batchAllConfirm = true;\n\t/** {@link IRealmPatchMeta.authoritative} through the suppression window: OR of the children. */\n\tlet batchAnyAuthoritative = false;\n\t/** Derive a flush's provenance from its delta (see {@link IRealmPatchMeta.cause}). */\n\tconst causeOfDelta = (delta) => {\n\t\tif (delta?.fullReplace === true) return \"hydrate\";\n\t\tif (delta?.confirmed != null) return \"confirm\";\n\t\treturn delta?.cause ?? \"rebase\";\n\t};\n\t/**\n\t* Did this flush apply fresh authoritative state? (see {@link IRealmPatchMeta.authoritative}).\n\t* Deliberately independent of `cause`: a hydrate and the C.2 fast path are authoritative by\n\t* construction, and a patches frame landing under an optimistic overlay is authoritative too —\n\t* it just cannot use the fast path, so it emits as `\"rebase\"`. That gap is the whole reason this\n\t* field exists (Dirt Derby's Phase B census: at +200 ms a writing client received 60% of fresh\n\t* authoritative ticks as `\"rebase\"`, because its outbox is non-empty for ~RTT after every input).\n\t*/\n\tconst isAuthoritative = (delta) => {\n\t\tif (delta == null) return false;\n\t\tif (delta.fullReplace === true || delta.confirmed != null) return true;\n\t\treturn delta.authoritative === true;\n\t};\n\t/**\n\t* `delta.confirmed` = the authoritative patches that triggered this flush, when the caller\n\t* verified the store carried no optimistic overlay (the C.2 fast path — emitted verbatim);\n\t* `delta.fullReplace` = a rebuild (hydrate) — emit the root replace instead of a diff;\n\t* `delta.cause` = an explicit provenance for flushes that emit a structural diff (an optimistic\n\t* apply, the collapsed batch projection). No delta ⇒ a `\"rebase\"`-class rebuild.\n\t*/\n\tconst project = (delta) => {\n\t\tif (projectSuppressed) {\n\t\t\tsuppressedProjectPending = true;\n\t\t\tif (causeOfDelta(delta) !== \"confirm\") batchAllConfirm = false;\n\t\t\tif (isAuthoritative(delta)) batchAnyAuthoritative = true;\n\t\t\treturn;\n\t\t}\n\t\tlet projected = confirmed;\n\t\tconst dropped = [];\n\t\tfor (const frame of pending) try {\n\t\t\tprojected = applyPatches(projected, frame.patches);\n\t\t} catch {\n\t\t\tdropped.push(frame);\n\t\t}\n\t\tif (dropped.length > 0) {\n\t\t\tpending = pending.filter((frame) => !dropped.includes(frame));\n\t\t\tfor (const frame of dropped) settleReject(frame, err_realm.fromId(\"frame_too_stale\", { basisVersion: frame.basisVersion }));\n\t\t}\n\t\tprojecting = true;\n\t\ttry {\n\t\t\tstore.replace(projected);\n\t\t} finally {\n\t\t\tprojecting = false;\n\t\t}\n\t\tif (projected !== lastProjected) {\n\t\t\tconst cause = causeOfDelta(delta);\n\t\t\tconst authoritative = isAuthoritative(delta);\n\t\t\tdevtools?.onFlush?.({\n\t\t\t\tcause,\n\t\t\t\tauthoritative,\n\t\t\t\tconfirmedVersion\n\t\t\t});\n\t\t\tif (patchListeners.size > 0) {\n\t\t\t\tconst emit = delta?.fullReplace === true ? [{\n\t\t\t\t\top: \"replace\",\n\t\t\t\t\tpath: [],\n\t\t\t\t\tvalue: projected\n\t\t\t\t}] : delta?.confirmed ?? diffProjected(lastProjected, projected);\n\t\t\t\tif (emit.length > 0) {\n\t\t\t\t\tconst meta = {\n\t\t\t\t\t\tcause,\n\t\t\t\t\t\tauthoritative,\n\t\t\t\t\t\tconfirmedVersion\n\t\t\t\t\t};\n\t\t\t\t\tfor (const listener of [...patchListeners]) listener(emit, meta);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tlastProjected = projected;\n\t\tnotifyPending();\n\t};\n\t/** Apply authoritative patches to `confirmed`, tolerant of slice no-ops (replayed removes). */\n\tconst applyConfirmed = (patches) => {\n\t\tconst applicable = patches.filter((patch) => {\n\t\t\tif (patch.op !== \"remove\") return true;\n\t\t\tlet cursor = confirmed;\n\t\t\tfor (const seg of patch.path.slice(0, -1)) {\n\t\t\t\tif (cursor == null || typeof cursor !== \"object\") return false;\n\t\t\t\tcursor = cursor[seg];\n\t\t\t}\n\t\t\treturn cursor != null && typeof cursor === \"object\" && String(patch.path[patch.path.length - 1]) in cursor;\n\t\t});\n\t\tconst prepared = withStructuralParents(confirmed, applicable, realm.stateDef);\n\t\tconfirmed = applyPatches(confirmed, prepared);\n\t\treturn prepared;\n\t};\n\tconst settleReject = (frame, error) => {\n\t\tif (frame.expiryTimer != null) clearTimeout(frame.expiryTimer);\n\t\tfor (const handle of frame.handles) handle.reject(error);\n\t\tdevtools?.onMutation?.({\n\t\t\ttype: \"rejected\",\n\t\t\tclientSeq: frame.clientSeq,\n\t\t\tkind: frame.kind,\n\t\t\tintentName: frame.intentName,\n\t\t\tdurability: frame.durability,\n\t\t\tsystemAssert: frame.isSystemAssert,\n\t\t\terrorIds: error.getIds(),\n\t\t\trolledBackPaths: frame.patches.map((patch) => patch.path.join(\".\"))\n\t\t});\n\t\tif (frame.isSystemAssert && error.getIds().includes(\"frame_too_stale\")) return;\n\t\temitRejection({\n\t\t\terror,\n\t\t\tkind: frame.kind,\n\t\t\tintentName: frame.intentName,\n\t\t\trolledBackPaths: frame.patches.map((patch) => patch.path.join(\".\"))\n\t\t});\n\t};\n\tconst settleConfirm = (frame, version) => {\n\t\tif (frame.expiryTimer != null) clearTimeout(frame.expiryTimer);\n\t\tif (frame.sentAt != null) recordRttSample(Date.now() - frame.sentAt);\n\t\tfor (const handle of frame.handles) handle.confirm({ version });\n\t\tdevtools?.onMutation?.({\n\t\t\ttype: \"confirmed\",\n\t\t\tclientSeq: frame.clientSeq,\n\t\t\tkind: frame.kind,\n\t\t\tintentName: frame.intentName,\n\t\t\tdurability: frame.durability,\n\t\t\tsystemAssert: frame.isSystemAssert,\n\t\t\tversion\n\t\t});\n\t};\n\tconst armExpiry = (frame) => {\n\t\tif (frame.durability === \"reassert\") return;\n\t\tframe.expiryTimer = setTimeout(() => {\n\t\t\tif (!pending.includes(frame)) return;\n\t\t\tpending = pending.filter((candidate) => candidate !== frame);\n\t\t\tsettleReject(frame, err_realm.fromId(\"frame_too_stale\", { basisVersion: frame.basisVersion }));\n\t\t\tproject();\n\t\t}, expiryMs);\n\t\tunrefTimer(frame.expiryTimer);\n\t};\n\tconst sendFrame = (frame) => {\n\t\tif (port == null || !port.isOpen()) return;\n\t\tframe.sentAt = Date.now();\n\t\tconst encoded = frame.buildFrame(frame.clientSeq, frame.basisVersion);\n\t\tdevtools?.onFrame?.(\"out\", frame.kind, encoded.byteLength);\n\t\tport.send(encoded);\n\t};\n\t/** One write frame per this many ops — the advertised limit, or a retry-halved local ceiling. */\n\tlet localMaxPatchesCeiling;\n\tconst effectiveMaxPatches = () => localMaxPatchesCeiling ?? advertisedLimits?.maxPatchesPerFrame ?? Number.POSITIVE_INFINITY;\n\tconst makeWritePart = (clientSeq, patches, basisVersion, handles, retries, durability) => {\n\t\tconst part = {\n\t\t\tclientSeq,\n\t\t\tkind: \"write\",\n\t\t\tpatches,\n\t\t\tbasisVersion,\n\t\t\thandles,\n\t\t\tbuildFrame: (seq, basis) => encodeWrite({\n\t\t\t\tslot,\n\t\t\t\tclientSeq: seq,\n\t\t\t\tbasisVersion: basis,\n\t\t\t\tops: namePatchesToWireOps(dedupeByPath(part.patches), realm.tokens)\n\t\t\t}),\n\t\t\texpiryTimer: void 0,\n\t\t\topenForMerge: false,\n\t\t\tretries,\n\t\t\tdurability\n\t\t};\n\t\treturn part;\n\t};\n\t/**\n\t* Split one over-limit write frame into consecutive ≤`limit` parts: each part is\n\t* atomic on the server; every settle handle rides the LAST part, so read-your-writes holds\n\t* (acks are ordered). The trade — a split flush loses whole-flush atomicity — is documented on\n\t* `update()`. Replaces `frame` in the pending queue in place, preserving projection order.\n\t*/\n\tconst splitFrame = (frame, deduped, limit) => {\n\t\tif (frame.expiryTimer != null) clearTimeout(frame.expiryTimer);\n\t\tconst parts = [];\n\t\tfor (let offset = 0; offset < deduped.length; offset += limit) {\n\t\t\tconst chunk = deduped.slice(offset, offset + limit);\n\t\t\tconst isLast = offset + limit >= deduped.length;\n\t\t\tparts.push(makeWritePart(parts.length === 0 ? frame.clientSeq : nextSeq++, chunk, frame.basisVersion, isLast ? frame.handles : [], frame.retries, frame.durability));\n\t\t}\n\t\tconst index = pending.indexOf(frame);\n\t\tif (index >= 0) pending.splice(index, 1, ...parts);\n\t\tfor (const part of parts) armExpiry(part);\n\t\treturn parts;\n\t};\n\t/** Seal one flushed frame: send it whole, or split first when it exceeds the advertised limit. */\n\tconst sealAndSend = (frame) => {\n\t\tif (frame.kind !== \"write\") {\n\t\t\tsendFrame(frame);\n\t\t\treturn;\n\t\t}\n\t\tconst deduped = dedupeByPath(frame.patches);\n\t\tconst limit = effectiveMaxPatches();\n\t\tif (deduped.length <= limit) {\n\t\t\tsendFrame(frame);\n\t\t\treturn;\n\t\t}\n\t\tfor (const part of splitFrame(frame, deduped, limit)) sendFrame(part);\n\t};\n\tconst flushOutbox = () => {\n\t\tflushScheduled = false;\n\t\tfor (const frame of [...pending]) {\n\t\t\tif (!frame.openForMerge) continue;\n\t\t\tframe.openForMerge = false;\n\t\t\tif (helloInFlight) continue;\n\t\t\tsealAndSend(frame);\n\t\t}\n\t};\n\t/**\n\t* The leading-edge cooldown (Dirt Derby item 1): armed right after a leading send. While it\n\t* runs, new writes open an ordinary merge frame; the window-END timer flushes them (the\n\t* trailing half) and — having sent — re-arms, so sends stay capped at one per window. An idle\n\t* window (nothing merged) simply expires: the next write is a fresh leading edge.\n\t*/\n\tlet leadingCooldownTimer;\n\tconst armLeadingCooldown = () => {\n\t\tconst timer = setTimeout(() => {\n\t\t\tleadingCooldownTimer = void 0;\n\t\t\tif (pending.some((frame) => frame.openForMerge)) {\n\t\t\t\tflushOutbox();\n\t\t\t\tarmLeadingCooldown();\n\t\t\t}\n\t\t}, coalesceWindowMs);\n\t\tunrefTimer(timer);\n\t\tleadingCooldownTimer = timer;\n\t};\n\tconst scheduleFlush = () => {\n\t\tif (flushScheduled) return;\n\t\tflushScheduled = true;\n\t\tif (coalesceLeading && leadingCooldownTimer != null) return;\n\t\tif (coalesceWindowMs > 0) unrefTimer(setTimeout(flushOutbox, coalesceWindowMs));\n\t\telse queueMicrotask(flushOutbox);\n\t};\n\tconst rejectUnsent = (controller, kind, error, intentName) => {\n\t\tcontroller.reject(error);\n\t\temitRejection({\n\t\t\terror,\n\t\t\tkind,\n\t\t\tintentName,\n\t\t\trolledBackPaths: []\n\t\t});\n\t\tdevtools?.onMutation?.({\n\t\t\ttype: \"rejected\",\n\t\t\tclientSeq: -1,\n\t\t\tkind,\n\t\t\tintentName,\n\t\t\terrorIds: error.getIds(),\n\t\t\trolledBackPaths: []\n\t\t});\n\t\treturn controller.handle;\n\t};\n\tconst rejectImmediately = (kind, error, intentName) => rejectUnsent(createWriteHandle(), kind, error, intentName);\n\tconst neverHydratedError = () => attachError ?? err_realm.fromId(\"write_before_hydrate\", { realmId: realm.id });\n\tconst rejectQueued = (queued, error) => {\n\t\tif (queued.expiryTimer != null) clearTimeout(queued.expiryTimer);\n\t\trejectUnsent(queued.controller, queued.kind, error, queued.intentName);\n\t};\n\tconst mustQueueUntilHydrate = () => confirmedVersion === -1 || hydrating;\n\tconst queueUntilHydrate = (queuedWrite, durability) => {\n\t\tconst controller = createWriteHandle();\n\t\tif (status === \"detached\") return rejectUnsent(controller, queuedWrite.kind, neverHydratedError(), queuedWrite.intentName);\n\t\tconst queued = {\n\t\t\t...queuedWrite,\n\t\t\tcontroller,\n\t\t\texpiryTimer: void 0\n\t\t};\n\t\tif (durability !== \"reassert\") {\n\t\t\tqueued.expiryTimer = setTimeout(() => {\n\t\t\t\tconst index = hydrateQueue.indexOf(queued);\n\t\t\t\tif (index < 0) return;\n\t\t\t\thydrateQueue.splice(index, 1);\n\t\t\t\tconst guard = createStepGuard();\n\t\t\t\tguard.run(() => rejectQueued(queued, neverHydratedError()));\n\t\t\t\tguard.run(notifyPending);\n\t\t\t\tguard.rethrow();\n\t\t\t}, expiryMs);\n\t\t\tunrefTimer(queued.expiryTimer);\n\t\t}\n\t\thydrateQueue.push(queued);\n\t\tnotifyPending();\n\t\treturn controller.handle;\n\t};\n\tconst runQueued = (queued) => {\n\t\tif (queued.expiryTimer != null) clearTimeout(queued.expiryTimer);\n\t\tconst { controller } = queued;\n\t\tlet sent;\n\t\ttry {\n\t\t\tsent = queued.run();\n\t\t} catch (cause) {\n\t\t\tconsole.error(`${warnTag()} a write queued before the first hydrate threw`, cause);\n\t\t\trejectQueued(queued, castNiceError(cause));\n\t\t\treturn;\n\t\t}\n\t\tconst settled = sent;\n\t\tsettled.then(controller.confirm, () => {\n\t\t\tif (settled.error != null) controller.reject(settled.error);\n\t\t});\n\t};\n\t/** Runs every queued write; a throwing app callback is held by `guard` and strands nothing. */\n\tconst drainHydrateQueue = (guard) => {\n\t\tfor (let queued = hydrateQueue.shift(); queued != null; queued = hydrateQueue.shift()) {\n\t\t\tconst next = queued;\n\t\t\tguard.run(() => runQueued(next));\n\t\t}\n\t\tguard.run(notifyPending);\n\t};\n\tconst rejectHydrateQueue = () => {\n\t\tif (hydrateQueue.length === 0) return;\n\t\tconst guard = createStepGuard();\n\t\tfor (const queued of hydrateQueue.splice(0)) guard.run(() => rejectQueued(queued, neverHydratedError()));\n\t\tguard.run(notifyPending);\n\t\tguard.rethrow();\n\t};\n\tconst enqueueWrite = (patches, writeOptions) => {\n\t\tconst durability = writeOptions?.durability;\n\t\tconst immediate = writeOptions?.flush === \"immediate\";\n\t\tif (durability === \"reassert\") {\n\t\t\tconst backlog = pending.filter((frame) => frame.durability === \"reassert\").length;\n\t\t\tif (backlog >= MAX_REASSERT_PENDING_FRAMES) return rejectImmediately(\"write\", err_realm.fromId(\"durable_backlog_overflow\", { pendingFrames: backlog }));\n\t\t}\n\t\tconst controller = createWriteHandle();\n\t\tif (immediate) flushOutbox();\n\t\tconst open = immediate ? void 0 : pending.find((frame) => frame.kind === \"write\" && frame.openForMerge && frame.durability === durability);\n\t\tif (open != null) {\n\t\t\topen.patches.push(...patches);\n\t\t\topen.handles.push(controller);\n\t\t\tproject({ cause: \"optimistic\" });\n\t\t\tscheduleFlush();\n\t\t\treturn controller.handle;\n\t\t}\n\t\tconst frame = {\n\t\t\tclientSeq: nextSeq++,\n\t\t\tkind: \"write\",\n\t\t\tpatches,\n\t\t\tbasisVersion: confirmedVersion,\n\t\t\thandles: [controller],\n\t\t\tbuildFrame: (clientSeq, basisVersion) => encodeWrite({\n\t\t\t\tslot,\n\t\t\t\tclientSeq,\n\t\t\t\tbasisVersion,\n\t\t\t\tops: namePatchesToWireOps(dedupeByPath(frame.patches), realm.tokens)\n\t\t\t}),\n\t\t\texpiryTimer: void 0,\n\t\t\topenForMerge: true,\n\t\t\tretries: 0,\n\t\t\tdurability\n\t\t};\n\t\tpending.push(frame);\n\t\tdevtools?.onMutation?.({\n\t\t\ttype: \"created\",\n\t\t\tclientSeq: frame.clientSeq,\n\t\t\tkind: \"write\",\n\t\t\tdurability\n\t\t});\n\t\tarmExpiry(frame);\n\t\tproject({ cause: \"optimistic\" });\n\t\tif (immediate) {\n\t\t\tframe.openForMerge = false;\n\t\t\tif (!helloInFlight) sealAndSend(frame);\n\t\t} else if (coalesceLeading && leadingCooldownTimer == null) {\n\t\t\tflushOutbox();\n\t\t\tarmLeadingCooldown();\n\t\t} else scheduleFlush();\n\t\treturn controller.handle;\n\t};\n\tconst applyUpdate = (fn, updateOptions) => {\n\t\tconst projected = store.state;\n\t\tlet returned;\n\t\tconst [next, patches] = produceWithPatches(projected, (draft) => {\n\t\t\treturned = fn(draft);\n\t\t});\n\t\tif (patches.length === 0) {\n\t\t\tif (typeof returned === \"object\" && returned != null) throw new Error(`[realm:${realm.id}] realm.update(fn): the update function returned a value without modifying its draft. Updates are mutate-only — a returned state is ignored (unlike immer's produce). Mutate the draft instead.`);\n\t\t\tconst controller = createWriteHandle();\n\t\t\tcontroller.confirm({ version: confirmedVersion });\n\t\t\treturn controller.handle;\n\t\t}\n\t\tconst canonical = canonicalizeStatePatches(patches, next, realm.stateDef);\n\t\tconst verdict = predictWrite({\n\t\t\trealm,\n\t\t\tpatches: canonical,\n\t\t\tavatar,\n\t\t\tstate: projected,\n\t\t\tbasisVersion: confirmedVersion\n\t\t});\n\t\tif (verdict !== true) return rejectImmediately(\"write\", verdict);\n\t\treturn enqueueWrite(canonical, updateOptions);\n\t};\n\tconst update = (fn, updateOptions) => mustQueueUntilHydrate() ? queueUntilHydrate({\n\t\tkind: \"write\",\n\t\trun: () => applyUpdate(fn, updateOptions)\n\t}, updateOptions?.durability) : applyUpdate(fn, updateOptions);\n\tconst runIntent = (name, input) => mustQueueUntilHydrate() ? queueUntilHydrate({\n\t\tkind: \"intent\",\n\t\tintentName: name,\n\t\trun: () => sendIntent(name, input)\n\t}) : sendIntent(name, input);\n\tconst sendIntent = (name, input) => {\n\t\tconst def = realm.intents[name];\n\t\tif (def == null) return rejectImmediately(\"intent\", err_realm.fromId(\"intent_unknown\", { intent: name }), name);\n\t\tconst invalid = validateValue(def.input, input);\n\t\tif (invalid != null) return rejectImmediately(\"intent\", err_realm.fromId(\"value_invalid\", {\n\t\t\tpath: [name, ...invalid.path].join(\".\"),\n\t\t\texpected: invalid.expected\n\t\t}), name);\n\t\tflushOutbox();\n\t\tlet predicted = [];\n\t\tif (def.optimistic != null) try {\n\t\t\tconst projected = store.state;\n\t\t\tconst [next, patches] = produceWithPatches(projected, (draft) => {\n\t\t\t\tdef.optimistic?.({\n\t\t\t\t\tview: draft,\n\t\t\t\t\tavatar,\n\t\t\t\t\tinput\n\t\t\t\t});\n\t\t\t});\n\t\t\tpredicted = canonicalizeStatePatches(patches, next, realm.stateDef);\n\t\t} catch {\n\t\t\tpredicted = [];\n\t\t}\n\t\tconst controller = createWriteHandle();\n\t\tconst intentToken = realm.intentNames.indexOf(name);\n\t\tconst frame = {\n\t\t\tclientSeq: nextSeq++,\n\t\t\tkind: \"intent\",\n\t\t\tintentName: name,\n\t\t\tpatches: predicted,\n\t\t\tbasisVersion: confirmedVersion,\n\t\t\thandles: [controller],\n\t\t\tbuildFrame: (clientSeq) => encodeIntent({\n\t\t\t\tslot,\n\t\t\t\tclientSeq,\n\t\t\t\tintentToken,\n\t\t\t\tinput\n\t\t\t}),\n\t\t\texpiryTimer: void 0,\n\t\t\topenForMerge: false,\n\t\t\tretries: 0\n\t\t};\n\t\tpending.push(frame);\n\t\tdevtools?.onMutation?.({\n\t\t\ttype: \"created\",\n\t\t\tclientSeq: frame.clientSeq,\n\t\t\tkind: \"intent\",\n\t\t\tintentName: name\n\t\t});\n\t\tarmExpiry(frame);\n\t\tif (predicted.length > 0) project({ cause: \"optimistic\" });\n\t\telse notifyPending();\n\t\tif (!helloInFlight) sendFrame(frame);\n\t\treturn controller.handle;\n\t};\n\t/**\n\t* `limits_exceeded` recovery: a well-behaved client must survive a breach — even\n\t* a mis-advertised limit — instead of settling the write as a fatal reject (and, ×10, being\n\t* forcibly detached). Frame-size breaches re-split against a halved local ceiling; a rate\n\t* breach resends after a backoff. Bounded by {@link MAX_LIMIT_RETRIES} and the frame's own\n\t* expiry; unsplittable limits (record key length, expansion overflow) settle as before.\n\t* Returns `true` when the reject was absorbed as a retry.\n\t*/\n\tconst retryLimitReject = (frame, error) => {\n\t\tif (frame.kind !== \"write\") return false;\n\t\tif (!error.getIds().includes(\"limits_exceeded\")) return false;\n\t\tif (frame.retries >= MAX_LIMIT_RETRIES) return false;\n\t\tconst breached = error.getContext(\"limits_exceeded\");\n\t\tconst limitName = typeof breached === \"object\" && breached != null && \"limit\" in breached ? String(breached.limit) : \"\";\n\t\tif (limitName === \"writeRatePerSecond\") {\n\t\t\tframe.retries += 1;\n\t\t\tunrefTimer(setTimeout(() => {\n\t\t\t\tif (pending.includes(frame) && !helloInFlight) sendFrame(frame);\n\t\t\t}, RATE_RETRY_MS));\n\t\t\treturn true;\n\t\t}\n\t\tif (limitName === \"maxPatchesPerFrame\" || limitName === \"maxFrameBytes\") {\n\t\t\tframe.retries += 1;\n\t\t\tconst deduped = dedupeByPath(frame.patches);\n\t\t\tif (deduped.length <= 1) return false;\n\t\t\tlocalMaxPatchesCeiling = Math.max(1, Math.floor(Math.min(effectiveMaxPatches(), deduped.length) / 2));\n\t\t\tfor (const part of splitFrame(frame, deduped, localMaxPatchesCeiling)) sendFrame(part);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t};\n\tconst revalidateAndResendPending = () => {\n\t\tconst kept = [];\n\t\tlet foldState = confirmed;\n\t\tfor (const frame of pending) if (frame.isSystemAssert) try {\n\t\t\tfoldState = applyPatches(foldState, frame.patches);\n\t\t} catch {}\n\t\tfor (const frame of pending) {\n\t\t\tif (frame.isSystemAssert) {\n\t\t\t\tkept.push(frame);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst verdict = frame.kind === \"intent\" ? true : predictWrite({\n\t\t\t\trealm,\n\t\t\t\tpatches: frame.patches,\n\t\t\t\tavatar,\n\t\t\t\tstate: confirmed,\n\t\t\t\tbasisVersion: confirmedVersion\n\t\t\t});\n\t\t\tif (verdict !== true) {\n\t\t\t\tsettleReject(frame, verdict);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (frame.kind === \"write\") {\n\t\t\t\tlet nextFold;\n\t\t\t\ttry {\n\t\t\t\t\tnextFold = applyPatches(foldState, frame.patches);\n\t\t\t\t} catch {\n\t\t\t\t\tsettleReject(frame, err_realm.fromId(\"frame_too_stale\", { basisVersion: frame.basisVersion }));\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tfoldState = nextFold;\n\t\t\t}\n\t\t\tframe.basisVersion = confirmedVersion;\n\t\t\tkept.push(frame);\n\t\t}\n\t\tpending = kept;\n\t\tfor (const frame of [...kept]) if (!frame.openForMerge) sendFrame(frame);\n\t};\n\tlet hydrateChunks = [];\n\tconst handleFrame = (frame) => {\n\t\tswitch (frame.kind) {\n\t\t\tcase REALM_FRAME_KIND.batch: {\n\t\t\t\tconst wasSuppressed = projectSuppressed;\n\t\t\t\tprojectSuppressed = true;\n\t\t\t\tif (!wasSuppressed) {\n\t\t\t\t\tbatchAllConfirm = true;\n\t\t\t\t\tbatchAnyAuthoritative = false;\n\t\t\t\t}\n\t\t\t\tlet childFailed = false;\n\t\t\t\tlet childError;\n\t\t\t\ttry {\n\t\t\t\t\tfor (const child of frame.frames) try {\n\t\t\t\t\t\thandleFrame(child);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (!childFailed) {\n\t\t\t\t\t\t\tchildFailed = true;\n\t\t\t\t\t\t\tchildError = error;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\tprojectSuppressed = wasSuppressed;\n\t\t\t\t}\n\t\t\t\tif (!projectSuppressed && suppressedProjectPending) {\n\t\t\t\t\tsuppressedProjectPending = false;\n\t\t\t\t\tproject({\n\t\t\t\t\t\tcause: batchAllConfirm ? \"confirm\" : \"rebase\",\n\t\t\t\t\t\tauthoritative: batchAnyAuthoritative\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (childFailed) throw childError;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase REALM_FRAME_KIND.hydrate: {\n\t\t\t\tdict.load(frame.keyDictSeed);\n\t\t\t\thydrateChunks.push(frame.stateBlob);\n\t\t\t\tif (frame.more) return;\n\t\t\t\tconst blob = concatChunks$1(hydrateChunks);\n\t\t\t\thydrateChunks = [];\n\t\t\t\tconst isFirstHydrate = confirmedVersion < 0;\n\t\t\t\tconfirmed = unpack(blob);\n\t\t\t\tconfirmedVersion = frame.version;\n\t\t\t\tserverEpoch = frame.epoch;\n\t\t\t\tadvertisedLimits = {\n\t\t\t\t\tmaxPatchesPerFrame: frame.limits[0],\n\t\t\t\t\tmaxFrameBytes: frame.limits[1],\n\t\t\t\t\twriteRatePerSecond: frame.limits[2]\n\t\t\t\t};\n\t\t\t\tlocalMaxPatchesCeiling = void 0;\n\t\t\t\twarnOnIdentityMismatch(frame.avatar);\n\t\t\t\thydrating = true;\n\t\t\t\tconst guard = createStepGuard();\n\t\t\t\ttry {\n\t\t\t\t\tguard.run(() => setStatus(\"live\"));\n\t\t\t\t\tif (helloInFlight) recordRttSample(Date.now() - helloSentAt);\n\t\t\t\t\thelloInFlight = false;\n\t\t\t\t\tif (!isFirstHydrate && realm.transient.length > 0 && options.assertOnAttach != null && !hasPendingSystemAssert()) guard.run(() => enqueueSystemAssert(confirmed));\n\t\t\t\t\tguard.run(revalidateAndResendPending);\n\t\t\t\t\tguard.run(() => project({ fullReplace: true }));\n\t\t\t\t\tconst assertOnAttach = options.assertOnAttach;\n\t\t\t\t\tif (assertOnAttach != null && !hasPendingSystemAssert()) guard.run(() => applyUpdate(assertOnAttach));\n\t\t\t\t} finally {\n\t\t\t\t\tdrainHydrateQueue(guard);\n\t\t\t\t\thydrating = false;\n\t\t\t\t}\n\t\t\t\tcheckReownWatch();\n\t\t\t\tguard.rethrow();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase REALM_FRAME_KIND.keyDict:\n\t\t\t\tdict.load(frame.entries);\n\t\t\t\treturn;\n\t\t\tcase REALM_FRAME_KIND.patches: {\n\t\t\t\tconst isContinuous = frame.fromVersion === confirmedVersion;\n\t\t\t\tconst isContinuation = frame.toVersion === confirmedVersion;\n\t\t\t\tif (!isContinuous && !isContinuation) {\n\t\t\t\t\tif (helloInFlight) onDiagnostic({\n\t\t\t\t\t\ttype: \"gap_dropped\",\n\t\t\t\t\t\tfromVersion: frame.fromVersion,\n\t\t\t\t\t\ttoVersion: frame.toVersion,\n\t\t\t\t\t\tconfirmedVersion\n\t\t\t\t\t});\n\t\t\t\t\telse requestResync(\"version_gap\", {\n\t\t\t\t\t\tfromVersion: frame.fromVersion,\n\t\t\t\t\t\ttoVersion: frame.toVersion,\n\t\t\t\t\t\tconfirmedVersion\n\t\t\t\t\t});\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst answeredHello = helloInFlight;\n\t\t\t\thelloInFlight = false;\n\t\t\t\tif (answeredHello) recordRttSample(Date.now() - helloSentAt);\n\t\t\t\tconst patches = wireOpsToNamePatches(frame.ops, realm.tokens, (id) => dict.keyOf(id)).filter((patch) => !pathHasUnsafeKey(patch.path));\n\t\t\t\tconst clean = pending.length === 0 && lastProjected === confirmed;\n\t\t\t\tconst applied = applyConfirmed(patches);\n\t\t\t\tconfirmedVersion = frame.toVersion;\n\t\t\t\tif (answeredHello) {\n\t\t\t\t\tif (!hasPendingSystemAssert()) enqueueSystemAssert(confirmed);\n\t\t\t\t\trevalidateAndResendPending();\n\t\t\t\t}\n\t\t\t\tif (status === \"connecting\") setStatus(\"live\");\n\t\t\t\tproject(clean && pending.length === 0 ? { confirmed: applied } : { authoritative: true });\n\t\t\t\tcheckReownWatch();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase REALM_FRAME_KIND.ack: {\n\t\t\t\tconst index = pending.findIndex((candidate) => candidate.clientSeq === frame.clientSeq);\n\t\t\t\tif (index < 0) return;\n\t\t\t\tconst [settledFrame] = pending.splice(index, 1);\n\t\t\t\tsettleConfirm(settledFrame, frame.version);\n\t\t\t\tproject();\n\t\t\t\tif (settledFrame.isSystemAssert) checkReownWatch();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase REALM_FRAME_KIND.reject: {\n\t\t\t\tconst error = castNiceError(frame.error);\n\t\t\t\tif (frame.clientSeq === -1) {\n\t\t\t\t\tattachError = error;\n\t\t\t\t\thelloInFlight = false;\n\t\t\t\t\tsetStatus(\"detached\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst index = pending.findIndex((candidate) => candidate.clientSeq === frame.clientSeq);\n\t\t\t\tif (index < 0) {\n\t\t\t\t\tonDiagnostic({\n\t\t\t\t\t\ttype: \"late_reject\",\n\t\t\t\t\t\tclientSeq: frame.clientSeq,\n\t\t\t\t\t\terrorIds: error.getIds()\n\t\t\t\t\t});\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (retryLimitReject(pending[index], error)) return;\n\t\t\t\tconst [rejectedFrame] = pending.splice(index, 1);\n\t\t\t\tsettleReject(rejectedFrame, error);\n\t\t\t\tproject();\n\t\t\t\tif (error.getIds().includes(\"write_target_missing\")) {\n\t\t\t\t\tfor (const patch of rejectedFrame.patches) if (patch.path.length > 1) {\n\t\t\t\t\t\tconst parent = patch.path.slice(0, -1);\n\t\t\t\t\t\treownWatch.set(JSON.stringify(parent), parent);\n\t\t\t\t\t}\n\t\t\t\t\trequestResync(\"write_target_missing\");\n\t\t\t\t}\n\t\t\t\tif (rejectedFrame.isSystemAssert) checkReownWatch();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase REALM_FRAME_KIND.detach:\n\t\t\t\tif (frame.reason === \"rehello\") {\n\t\t\t\t\tif (status === \"live\") sendHello({ probe: true });\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\thelloInFlight = false;\n\t\t\t\tsetStatus(\"detached\");\n\t\t\t\treturn;\n\t\t\tdefault: return;\n\t\t}\n\t};\n\t/**\n\t* The defensive inbound boundary: every inbound frame runs through `handleFrame`\n\t* inside this wrap. A decode/apply throw — an unknown interned key id (`detokenizePath`), a\n\t* patch that can't resolve its parent (`applyConfirmed`) — must NOT escape into the wire mux,\n\t* silently drop the frame, or (inside a batch) abort its siblings. On any failure we heal the\n\t* same way a version gap does: re-hello with backoff. `lastSyncInboundAt` is stamped only AFTER a\n\t* clean handling, so a throwing frame no longer fools the staleness probe into thinking the\n\t* link is healthy — and only for a frame that actually carries sync information\n\t* ({@link provesSyncHealth}), so a reject cannot either.\n\t*/\n\tconst onFrame = (frame, byteSize) => {\n\t\tdevtools?.onFrame?.(\"in\", REALM_FRAME_KIND_NAME[frame.kind] ?? String(frame.kind), byteSize ?? 0);\n\t\ttry {\n\t\t\thandleFrame(frame);\n\t\t} catch (error) {\n\t\t\tonDiagnostic({\n\t\t\t\ttype: \"frame_error\",\n\t\t\t\terror\n\t\t\t});\n\t\t\thydrateChunks = [];\n\t\t\tscheduleResyncWithBackoff();\n\t\t\treturn;\n\t\t}\n\t\tif (!provesSyncHealth(frame)) return;\n\t\tlastSyncInboundAt = Date.now();\n\t\tresyncAttempts = 0;\n\t\tclearResyncRetry();\n\t\tif (probeDeadline != null) {\n\t\t\tclearTimeout(probeDeadline);\n\t\t\tprobeDeadline = void 0;\n\t\t}\n\t};\n\t/**\n\t* The identity echo check: the hydrate names the avatar the server resolved —\n\t* the one verdicts and view slicing run against. A disagreement with our own ref is the\n\t* silent-flicker bug class (prediction passes locally, the server rejects every time), so it\n\t* warns loudly, once per handle.\n\t*/\n\tconst warnOnIdentityMismatch = (echo) => {\n\t\tconst [type, persistentId, instanceId] = echo;\n\t\tif (type === avatar.type && persistentId === avatar.persistentId && instanceId === avatar.instanceId) return;\n\t\tif (identityWarned) return;\n\t\tidentityWarned = true;\n\t\tconsole.warn(`${warnTag()} identity mismatch — this client predicts as ${avatar.type}/${avatar.persistentId}/${avatar.instanceId} but the server resolved it as ${type}/${persistentId}/${instanceId}. Prediction and view slicing run against DIFFERENT identities: owner-gated writes will pass locally and reject on the server. Fix the server's resolveAvatar/avatarType, or the avatar passed to connectRealm.`);\n\t};\n\t/**\n\t* The reassert lane (Phase 2 / Overshot Issue 2): ride a recovery hello with a re-own WRITE so a\n\t* transient entry a wake reset is re-created server-side BEFORE any resent frame executes — so an\n\t* intent that reads transient state (a `fire` reading `aim[me]`) runs against the re-owned entry,\n\t* not the wiped region. It uses the sentinel `clientSeq: -2`, which the engine applies through the\n\t* full rules pipeline but skips the replay high-water — so it can be ordered on the wire ahead of\n\t* pending frames without swallowing their seqs (the §0 constraint that makes a naive \"assert as a\n\t* normal write, sent first\" unsafe: its higher seq would advance the high-water and the resent\n\t* intents would be dup-acked as already-processed, falsely confirmed but never run).\n\t*\n\t* Skipped when there is nothing to re-own (no `assertOnAttach`, no transient region, or a no-op\n\t* draft) and before the first hydrate (the hydrate's own assert seeds the entry). Only one is\n\t* pending at a time; a second hello supersedes it (idempotent — no user handle).\n\t*\n\t* **Sampling basis (`sampleState`) is the whole fix for the guarded-assert stall (Overshot 0.48).**\n\t* A guarded re-own (`if (draft.mine != null) return`) can only fire against state that reflects a\n\t* wake wipe. Two call sites, deliberately different bases:\n\t* - `sendHello` samples `store.state` — the OPPORTUNISTIC pre-answer lane. The client has not yet\n\t*   learned a same-epoch wake wiped the region (no version advance, no broadcast), so a guarded\n\t*   assert sees its entry present and produces nothing here; an UNCONDITIONAL rewrite still fires\n\t*   and rides the recovery for a flicker-free re-own that preserves the pre-wake value.\n\t* - the resume answer (patches/hydrate) samples `confirmed` AFTER the answer's transient-region\n\t*   replace has been applied — the AUTHORITATIVE basis where a wiped entry is genuinely absent, so\n\t*   a guarded assert finally observes the loss and re-creates it. Skipped when the pre-answer lane\n\t*   already produced a frame (unconditional case) so that frame's pre-wake value is not clobbered.\n\t*/\n\tconst enqueueSystemAssert = (sampleState) => {\n\t\tif (options.assertOnAttach == null || realm.transient.length === 0) return;\n\t\tif (confirmedVersion < 0) return;\n\t\tif (port == null || !port.isOpen()) return;\n\t\tconst [next, patches] = produceWithPatches(sampleState, (draft) => {\n\t\t\toptions.assertOnAttach?.(draft);\n\t\t});\n\t\tif (patches.length === 0) return;\n\t\tconst canonical = canonicalizeStatePatches(patches, next, realm.stateDef);\n\t\tif (canonical.length === 0) return;\n\t\tif (pending.some((frame) => frame.isSystemAssert)) pending = pending.filter((frame) => !frame.isSystemAssert);\n\t\tconst frame = {\n\t\t\tclientSeq: SYSTEM_ASSERT_SEQ,\n\t\t\tkind: \"write\",\n\t\t\tpatches: canonical,\n\t\t\tbasisVersion: confirmedVersion,\n\t\t\thandles: [],\n\t\t\tbuildFrame: (clientSeq, basisVersion) => encodeWrite({\n\t\t\t\tslot,\n\t\t\t\tclientSeq,\n\t\t\t\tbasisVersion,\n\t\t\t\tops: namePatchesToWireOps(dedupeByPath(canonical), realm.tokens)\n\t\t\t}),\n\t\t\texpiryTimer: void 0,\n\t\t\topenForMerge: false,\n\t\t\tretries: 0,\n\t\t\tisSystemAssert: true\n\t\t};\n\t\tpending.unshift(frame);\n\t\tproject({ cause: \"optimistic\" });\n\t};\n\t/**\n\t* (Re-)attach to the server. Every hello is **tracked** (Phase 1.1): its answer runs the recovery\n\t* tail (revalidate + the transient re-own) regardless of shape, so a probe/rehello heals transient\n\t* state exactly like a reconnect. `probe` is presentation only — it decides the status flip and\n\t* the key-dict clear, not whether the answer heals:\n\t*\n\t* - A **non-probe** hello (first attach, reconnect) flips status to `connecting` and resets the\n\t*   key dict — a genuine re-attach may face a fresh/woken session that reassigns interned ids from\n\t*   zero.\n\t* - A **probe** hello (staleness probe, wake rehello, `write_target_missing` resync) keeps `live`\n\t*   status (no HUD flap on a link that never dropped) and KEEPS the dict: it rides the same-or-woken\n\t*   session where the server re-sends a delta before first use of any id and `RealmKeyDict.load`\n\t*   overwrites, so a reassigned id is corrected before it is ever resolved. It arms the\n\t*   escalation deadline instead — no inbound within the window ⇒ the link is genuinely dead and\n\t*   status flips to `connecting` truthfully (Phase 1.2).\n\t*/\n\tconst sendHello = (opts) => {\n\t\tif (opts?.probe !== true) {\n\t\t\tsetStatus(\"connecting\");\n\t\t\tattachError = void 0;\n\t\t\tdict.clear();\n\t\t} else {\n\t\t\tlastProbeAt = Date.now();\n\t\t\tarmProbeEscalation();\n\t\t}\n\t\thelloInFlight = true;\n\t\thelloSentAt = Date.now();\n\t\thydrateChunks = [];\n\t\tenqueueSystemAssert(store.state);\n\t\tconst hello = encodeHello({\n\t\t\tslot,\n\t\t\trealmId: realm.id,\n\t\t\tschemaHash: realm.schemaHash,\n\t\t\tlastKnownVersion: opts?.forceFullHydrate === true ? -1 : confirmedVersion,\n\t\t\tepoch: serverEpoch\n\t\t});\n\t\tdevtools?.onFrame?.(\"out\", \"hello\", hello.byteLength);\n\t\tport?.send(hello);\n\t\tconst caps = encodeClientCaps({\n\t\t\tslot,\n\t\t\tfeatures: [REALM_FEATURE.batch]\n\t\t});\n\t\tdevtools?.onFrame?.(\"out\", \"clientCaps\", caps.byteLength);\n\t\tport?.send(caps);\n\t};\n\tlet unsubscribeLinkEvents;\n\tconst securityShortfall = computeRealmSecurityShortfall(options.connection, realm, options.security);\n\tif (securityShortfall != null) {\n\t\tattachError = securityShortfall;\n\t\tsetStatus(\"detached\");\n\t\toptions.connection.release();\n\t} else {\n\t\tport = options.connection.register({\n\t\t\tonFrame,\n\t\t\tonAttach: () => sendHello(),\n\t\t\tonDetach: () => {\n\t\t\t\tif (status !== \"detached\") setStatus(\"connecting\");\n\t\t\t}\n\t\t});\n\t\tif (port.isOpen()) sendHello();\n\t\tunsubscribeLinkEvents = options.connection.subscribeLinkEvents?.((event) => {\n\t\t\tif (event.type === \"link_up\" && event.downForMs != null) onDiagnostic({\n\t\t\t\ttype: \"link_redialed\",\n\t\t\t\tdownForMs: event.downForMs\n\t\t\t});\n\t\t});\n\t}\n\tlet probeTimer;\n\tif (securityShortfall == null && staleProbeAfterMs > 0) {\n\t\tprobeTimer = setInterval(() => {\n\t\t\tif (status !== \"live\" || port?.isOpen() !== true) return;\n\t\t\tconst now = Date.now();\n\t\t\tif (now - lastSyncInboundAt < staleProbeAfterMs) return;\n\t\t\tif (now - lastProbeAt < staleProbeAfterMs) return;\n\t\t\tsendHello({ probe: true });\n\t\t}, Math.max(1e3, Math.floor(staleProbeAfterMs / 2)));\n\t\tunrefTimer(probeTimer);\n\t}\n\tif (options.experimental_writeThroughStore === true) store.listenToPatches((allPatches) => {\n\t\tif (projecting) return;\n\t\tconst patches = allPatches.filter((patch) => patch.path.length > 0);\n\t\tif (patches.length === 0) return;\n\t\tqueueMicrotask(() => {\n\t\t\tconst canonical = canonicalizeStatePatches(patches, store.state, realm.stateDef);\n\t\t\tif (canonical.length === 0) return;\n\t\t\tconst verdict = predictWrite({\n\t\t\t\trealm,\n\t\t\t\tpatches: canonical,\n\t\t\t\tavatar,\n\t\t\t\tstate: store.state,\n\t\t\t\tbasisVersion: confirmedVersion\n\t\t\t});\n\t\t\tif (verdict !== true) {\n\t\t\t\temitRejection({\n\t\t\t\t\terror: verdict,\n\t\t\t\t\tkind: \"write\",\n\t\t\t\t\trolledBackPaths: canonical.map((patch) => patch.path.join(\".\"))\n\t\t\t\t});\n\t\t\t\tproject();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tenqueueWrite(canonical);\n\t\t});\n\t});\n\telse {\n\t\tlet warnedStoreWrite = false;\n\t\tstore.listenToPatches(() => {\n\t\t\tif (projecting || warnedStoreWrite) return;\n\t\t\twarnedStoreWrite = true;\n\t\t\tconsole.warn(`${warnTag()} realm.store was written directly. The store is a read projection — this change was never sent to the server and will vanish on the next incoming flush. Did you mean realm.update()? (Raw store write-through requires the experimental_writeThroughStore option.)`);\n\t\t});\n\t}\n\tconst handle = {\n\t\tstore,\n\t\tavatar,\n\t\tupdate,\n\t\tintents: Object.fromEntries(realm.intentNames.map((name) => [name, (input) => runIntent(name, input)])),\n\t\tpending: {\n\t\t\tget count() {\n\t\t\t\treturn pending.reduce((n, frame) => frame.isSystemAssert ? n : n + 1, 0) + hydrateQueue.length;\n\t\t\t},\n\t\t\thas(pathPrefix) {\n\t\t\t\treturn pending.some((frame) => !frame.isSystemAssert && frame.patches.some((patch) => patch.path.join(\".\").startsWith(pathPrefix)));\n\t\t\t},\n\t\t\tsubscribe(listener) {\n\t\t\t\tpendingListeners.add(listener);\n\t\t\t\treturn () => pendingListeners.delete(listener);\n\t\t\t}\n\t\t},\n\t\tget status() {\n\t\t\treturn status;\n\t\t},\n\t\tget hasBeenLive() {\n\t\t\treturn hasBeenLive;\n\t\t},\n\t\tget version() {\n\t\t\treturn confirmedVersion;\n\t\t},\n\t\tget attachError() {\n\t\t\treturn attachError;\n\t\t},\n\t\twhenLive(opts) {\n\t\t\tif (status === \"live\") return Promise.resolve();\n\t\t\tif (attachError != null) return Promise.reject(attachError);\n\t\t\tif (status === \"detached\") return Promise.reject(/* @__PURE__ */ new Error(\"whenLive: the realm is detached\"));\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tconst timeoutMs = opts?.timeoutMs ?? 1e4;\n\t\t\t\tconst cleanup = () => {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tstatusListeners.delete(listener);\n\t\t\t\t};\n\t\t\t\tconst timer = setTimeout(() => {\n\t\t\t\t\tcleanup();\n\t\t\t\t\treject(/* @__PURE__ */ new Error(`whenLive: the realm did not hydrate within ${timeoutMs}ms`));\n\t\t\t\t}, timeoutMs);\n\t\t\t\tconst listener = () => {\n\t\t\t\t\tif (status === \"live\") {\n\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t} else if (attachError != null || status === \"detached\") {\n\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\treject(attachError ?? /* @__PURE__ */ new Error(\"whenLive: the realm detached before going live\"));\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tstatusListeners.add(listener);\n\t\t\t});\n\t\t},\n\t\tsubscribeStatus(listener) {\n\t\t\tstatusListeners.add(listener);\n\t\t\treturn () => statusListeners.delete(listener);\n\t\t},\n\t\tsubscribeDiagnostics(listener) {\n\t\t\tdiagnosticListeners.add(listener);\n\t\t\treturn () => diagnosticListeners.delete(listener);\n\t\t},\n\t\tlistenToPatches(listener) {\n\t\t\tpatchListeners.add(listener);\n\t\t\treturn () => patchListeners.delete(listener);\n\t\t},\n\t\tget stats() {\n\t\t\treturn {\n\t\t\t\trttMs: statsRttMs,\n\t\t\t\tjitterMs: statsJitterMs,\n\t\t\t\tsamples: statsSamples\n\t\t\t};\n\t\t},\n\t\tdetach() {\n\t\t\tif (probeTimer != null) clearInterval(probeTimer);\n\t\t\tif (probeDeadline != null) clearTimeout(probeDeadline);\n\t\t\tif (leadingCooldownTimer != null) {\n\t\t\t\tclearTimeout(leadingCooldownTimer);\n\t\t\t\tleadingCooldownTimer = void 0;\n\t\t\t}\n\t\t\tunsubscribeLinkEvents?.();\n\t\t\tclearResyncRetry();\n\t\t\treownWatch.clear();\n\t\t\treownEscalated.clear();\n\t\t\tif (port?.isOpen() === true) try {\n\t\t\t\tconst bye = encodeDetach({\n\t\t\t\t\tslot,\n\t\t\t\t\treason: void 0\n\t\t\t\t});\n\t\t\t\tdevtools?.onFrame?.(\"out\", \"detach\", bye.byteLength);\n\t\t\t\tport.send(bye);\n\t\t\t} catch {}\n\t\t\thelloInFlight = false;\n\t\t\tconst guard = createStepGuard();\n\t\t\tguard.run(() => setStatus(\"detached\"));\n\t\t\toptions.connection.release();\n\t\t\tfor (const frame of pending.splice(0)) guard.run(() => settleReject(frame, err_realm.fromId(\"frame_too_stale\", { basisVersion: frame.basisVersion })));\n\t\t\tguard.run(() => project());\n\t\t\tguard.rethrow();\n\t\t}\n\t};\n\tdevtools?.handleReady?.({\n\t\thandle,\n\t\trealmId: realm.id,\n\t\tslot,\n\t\tavatar,\n\t\tpeer: (options.connection.peer ?? options.connection.peerCoordinate)?.envId\n\t});\n\treturn handle;\n}\n/** Last write wins per exact path inside one coalesced frame. */\nfunction dedupeByPath(patches) {\n\tconst byPath = /* @__PURE__ */ new Map();\n\tfor (const patch of patches) byPath.set(patch.path.join(\" \"), patch);\n\treturn [...byPath.values()];\n}\nfunction concatChunks$1(chunks) {\n\tif (chunks.length === 1) return chunks[0];\n\tconst total = chunks.reduce((sum, chunk) => sum + chunk.byteLength, 0);\n\tconst out = new Uint8Array(total);\n\tlet offset = 0;\n\tfor (const chunk of chunks) {\n\t\tout.set(chunk, offset);\n\t\toffset += chunk.byteLength;\n\t}\n\treturn out;\n}\n//#endregion\n//#region src/realm/RealmClient/RealmReplica.ts\nenablePatches();\nfunction connectRealmReplica(realm, options) {\n\tconst slot = options.connection.slot;\n\tconst dict = new RealmKeyDict();\n\tlet state = {};\n\tlet version = -1;\n\t/** The log epoch `version` belongs to — echoed in every hello. */\n\tlet serverEpoch;\n\tlet identityWarned = false;\n\tlet status = \"connecting\";\n\tlet attachError;\n\tlet nextSeq = 0;\n\tlet hydrateChunks = [];\n\tlet port;\n\tconst inFlight = /* @__PURE__ */ new Map();\n\tconst expiryMs = options.pendingExpiryMs ?? 1e4;\n\t/** Settle one in-flight entry (ack/reject/expiry): clear its timer, drop it, run the callback. */\n\tconst settleInFlight = (clientSeq, settle) => {\n\t\tconst entry = inFlight.get(clientSeq);\n\t\tif (entry == null) return;\n\t\tif (entry.expiryTimer != null) clearTimeout(entry.expiryTimer);\n\t\tinFlight.delete(clientSeq);\n\t\tsettle(entry.controller);\n\t};\n\t/**\n\t* Resend every in-flight frame after a recovery (reconnect / probe) — the replica's analog of\n\t* the client's `revalidateAndResendPending`. Rebuilds at the CURRENT version; the\n\t* server's replay high-water re-acks an already-processed seq idempotently and applies a\n\t* genuinely lost one. Iterates a COPY: an in-memory link delivers the dup ack synchronously\n\t* inside `send`, which would otherwise mutate the map mid-iteration.\n\t*/\n\tconst resendInFlight = () => {\n\t\tif (port?.isOpen() !== true || inFlight.size === 0) return;\n\t\tfor (const [clientSeq, entry] of [...inFlight]) port.send(entry.build(clientSeq));\n\t};\n\t/** Staleness-probe clocks — stamped by every inbound frame / probe hello. */\n\tlet lastInboundAt = Date.now();\n\tlet lastProbeAt = 0;\n\t/** One-shot probe-reply deadline — armed after a probe, cleared by any inbound. */\n\tlet probeDeadline;\n\tconst statusListeners = /* @__PURE__ */ new Set();\n\t/** Latched on the first `live` and never reset. */\n\tlet hasBeenLive = false;\n\tconst setStatus = (next) => {\n\t\tif (status === next) return;\n\t\tstatus = next;\n\t\tif (next === \"live\") hasBeenLive = true;\n\t\tfor (const listener of [...statusListeners]) listener(next, { hasBeenLive });\n\t};\n\t/** An attach/recovery hello is out and unanswered — non-continuous frames drop, never apply. */\n\tlet helloInFlight = false;\n\tlet helloSentAt = 0;\n\tconst HELLO_REPLY_GRACE_MS = 1e4;\n\tconst warnedDiagnostics = /* @__PURE__ */ new Set();\n\t/** Warn prefix — the epoch disambiguates several instances of one realm id (RealmClient twin). */\n\tconst warnTag = () => serverEpoch == null ? `[realm:${realm.id}]` : `[realm:${realm.id}#${serverEpoch.slice(0, 8)}]`;\n\tconst onDiagnostic = (event) => {\n\t\tif (options.onDiagnostic != null) {\n\t\t\toptions.onDiagnostic(event);\n\t\t\treturn;\n\t\t}\n\t\tif (!warnedDiagnostics.has(event.type)) {\n\t\t\twarnedDiagnostics.add(event.type);\n\t\t\tconsole.warn(`${warnTag()} replica sync-health event \"${event.type}\"`, event);\n\t\t}\n\t};\n\tconst staleProbeAfterMs = options.staleProbeAfterMs ?? 25e3;\n\tconst probeReplyTimeoutMs = options.probeReplyTimeoutMs ?? 1e4;\n\t/**\n\t* Arm the escalation deadline after a probe-flavored hello (Phase 1.2 backstop): a probe/rehello\n\t* keeps `live` for a one-round-trip heal, but no inbound within the window ⇒ the link is dead, so\n\t* flip to `connecting` truthfully and re-dial. Status moves on evidence of an outage, not a\n\t* protocol chore. Cleared by any inbound frame.\n\t*/\n\tconst armProbeEscalation = () => {\n\t\tif (probeReplyTimeoutMs <= 0) return;\n\t\tif (probeDeadline != null) clearTimeout(probeDeadline);\n\t\tprobeDeadline = setTimeout(() => {\n\t\t\tprobeDeadline = void 0;\n\t\t\tif (status !== \"live\") return;\n\t\t\tif (lastInboundAt >= lastProbeAt) return;\n\t\t\tonDiagnostic({ type: \"probe_escalated\" });\n\t\t\tsetStatus(\"connecting\");\n\t\t\toptions.connection.requestReconnect?.();\n\t\t}, probeReplyTimeoutMs);\n\t\tunrefTimer(probeDeadline);\n\t};\n\t/** Probe-flavored recovery re-hello — see RealmClient's `requestResync` for the full why. */\n\tconst requestResync = (reason, detail) => {\n\t\tif (status === \"detached\") return;\n\t\tonDiagnostic({\n\t\t\ttype: \"resync\",\n\t\t\treason,\n\t\t\t...detail\n\t\t});\n\t\tif (helloInFlight && Date.now() - helloSentAt < HELLO_REPLY_GRACE_MS) return;\n\t\tif (port?.isOpen() !== true) return;\n\t\tsendHello({ probe: true });\n\t};\n\t/** Backoff retry for a recovery whose ANSWER failed to apply — the RealmClient twin. */\n\tlet resyncAttempts = 0;\n\tlet resyncTimer;\n\tconst clearResyncRetry = () => {\n\t\tif (resyncTimer != null) {\n\t\t\tclearTimeout(resyncTimer);\n\t\t\tresyncTimer = void 0;\n\t\t}\n\t};\n\tconst scheduleResyncWithBackoff = () => {\n\t\thelloInFlight = false;\n\t\tif (resyncTimer != null) return;\n\t\tconst delay = Math.min(250 * 2 ** resyncAttempts, 5e3);\n\t\tresyncAttempts += 1;\n\t\tconst timer = setTimeout(() => {\n\t\t\tresyncTimer = void 0;\n\t\t\trequestResync(\"frame_error\");\n\t\t}, delay);\n\t\tunrefTimer(timer);\n\t\tresyncTimer = timer;\n\t};\n\t/**\n\t* A `probe` hello keeps `live` status — see RealmClient's twin for the why. Only a\n\t* non-probe hello clears the key dict: a probe rides the same live session and\n\t* clearing there would strand in-flight interned ids.\n\t*/\n\tconst sendHello = (opts) => {\n\t\tif (opts?.probe !== true) {\n\t\t\tsetStatus(\"connecting\");\n\t\t\tattachError = void 0;\n\t\t\tdict.clear();\n\t\t} else {\n\t\t\tlastProbeAt = Date.now();\n\t\t\tarmProbeEscalation();\n\t\t}\n\t\thelloInFlight = true;\n\t\thelloSentAt = Date.now();\n\t\thydrateChunks = [];\n\t\tport?.send(encodeHello({\n\t\t\tslot,\n\t\t\trealmId: realm.id,\n\t\t\tschemaHash: realm.schemaHash,\n\t\t\tlastKnownVersion: version,\n\t\t\tepoch: serverEpoch\n\t\t}));\n\t\tport?.send(encodeClientCaps({\n\t\t\tslot,\n\t\t\tfeatures: [REALM_FEATURE.batch]\n\t\t}));\n\t};\n\tlet onPatchesSuppressed = false;\n\tlet accumulatedPatches = [];\n\tconst emitPatches = (patches) => {\n\t\tif (onPatchesSuppressed) {\n\t\t\taccumulatedPatches.push(...patches);\n\t\t\treturn;\n\t\t}\n\t\toptions.onPatches?.(patches, { version });\n\t};\n\tconst handleFrame = (frame) => {\n\t\tswitch (frame.kind) {\n\t\t\tcase REALM_FRAME_KIND.batch: {\n\t\t\t\tconst wasSuppressed = onPatchesSuppressed;\n\t\t\t\tonPatchesSuppressed = true;\n\t\t\t\tif (!wasSuppressed) accumulatedPatches = [];\n\t\t\t\tlet childFailed = false;\n\t\t\t\tlet childError;\n\t\t\t\ttry {\n\t\t\t\t\tfor (const child of frame.frames) try {\n\t\t\t\t\t\thandleFrame(child);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (!childFailed) {\n\t\t\t\t\t\t\tchildFailed = true;\n\t\t\t\t\t\t\tchildError = error;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\tonPatchesSuppressed = wasSuppressed;\n\t\t\t\t}\n\t\t\t\tif (!onPatchesSuppressed && accumulatedPatches.length > 0) {\n\t\t\t\t\tconst emitted = accumulatedPatches;\n\t\t\t\t\taccumulatedPatches = [];\n\t\t\t\t\toptions.onPatches?.(emitted, { version });\n\t\t\t\t}\n\t\t\t\tif (childFailed) throw childError;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase REALM_FRAME_KIND.hydrate: {\n\t\t\t\tdict.load(frame.keyDictSeed);\n\t\t\t\thydrateChunks.push(frame.stateBlob);\n\t\t\t\tif (frame.more) return;\n\t\t\t\tconst blob = concatChunks(hydrateChunks);\n\t\t\t\thydrateChunks = [];\n\t\t\t\tstate = unpack(blob);\n\t\t\t\tversion = frame.version;\n\t\t\t\tserverEpoch = frame.epoch;\n\t\t\t\tconst [echoType, echoPersistentId] = frame.avatar;\n\t\t\t\tif (!identityWarned && (echoType !== options.avatar.type || echoPersistentId !== options.avatar.persistentId)) {\n\t\t\t\t\tidentityWarned = true;\n\t\t\t\t\tconsole.warn(`${warnTag()} replica identity mismatch — connected as ${options.avatar.type}/${options.avatar.persistentId} but the server resolved ${echoType}/${echoPersistentId}. Writes/intents will be judged against the server's identity.`);\n\t\t\t\t}\n\t\t\t\tsetStatus(\"live\");\n\t\t\t\thelloInFlight = false;\n\t\t\t\tresendInFlight();\n\t\t\t\temitPatches([]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase REALM_FRAME_KIND.keyDict:\n\t\t\t\tdict.load(frame.entries);\n\t\t\t\treturn;\n\t\t\tcase REALM_FRAME_KIND.patches: {\n\t\t\t\tconst isContinuous = frame.fromVersion === version;\n\t\t\t\tconst isContinuation = frame.toVersion === version;\n\t\t\t\tif (!isContinuous && !isContinuation) {\n\t\t\t\t\tif (helloInFlight) onDiagnostic({\n\t\t\t\t\t\ttype: \"gap_dropped\",\n\t\t\t\t\t\tfromVersion: frame.fromVersion,\n\t\t\t\t\t\ttoVersion: frame.toVersion,\n\t\t\t\t\t\tconfirmedVersion: version\n\t\t\t\t\t});\n\t\t\t\t\telse requestResync(\"version_gap\", {\n\t\t\t\t\t\tfromVersion: frame.fromVersion,\n\t\t\t\t\t\ttoVersion: frame.toVersion,\n\t\t\t\t\t\tconfirmedVersion: version\n\t\t\t\t\t});\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst answeredHello = helloInFlight;\n\t\t\t\thelloInFlight = false;\n\t\t\t\tconst applicable = wireOpsToNamePatches(frame.ops, realm.tokens, (id) => dict.keyOf(id)).filter((patch) => {\n\t\t\t\t\tif (pathHasUnsafeKey(patch.path)) return false;\n\t\t\t\t\tif (patch.op !== \"remove\") return true;\n\t\t\t\t\tlet cursor = state;\n\t\t\t\t\tfor (const seg of patch.path.slice(0, -1)) {\n\t\t\t\t\t\tif (cursor == null || typeof cursor !== \"object\") return false;\n\t\t\t\t\t\tcursor = cursor[seg];\n\t\t\t\t\t}\n\t\t\t\t\treturn cursor != null && typeof cursor === \"object\" && String(patch.path[patch.path.length - 1]) in cursor;\n\t\t\t\t});\n\t\t\t\tconst prepared = withStructuralParents(state, applicable, realm.stateDef);\n\t\t\t\tstate = applyPatches(state, prepared);\n\t\t\t\tversion = frame.toVersion;\n\t\t\t\tif (answeredHello) resendInFlight();\n\t\t\t\tif (status === \"connecting\") setStatus(\"live\");\n\t\t\t\temitPatches(prepared);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase REALM_FRAME_KIND.ack:\n\t\t\t\tsettleInFlight(frame.clientSeq, (controller) => controller.confirm({ version: frame.version }));\n\t\t\t\treturn;\n\t\t\tcase REALM_FRAME_KIND.reject: {\n\t\t\t\tconst error = castNiceError(frame.error);\n\t\t\t\tif (frame.clientSeq === -1) {\n\t\t\t\t\tattachError = error;\n\t\t\t\t\thelloInFlight = false;\n\t\t\t\t\tsetStatus(\"detached\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsettleInFlight(frame.clientSeq, (controller) => controller.reject(error));\n\t\t\t\tif (error.getIds().includes(\"write_target_missing\")) requestResync(\"write_target_missing\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase REALM_FRAME_KIND.detach:\n\t\t\t\tif (frame.reason === \"rehello\") {\n\t\t\t\t\tif (status === \"live\") sendHello({ probe: true });\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\thelloInFlight = false;\n\t\t\t\tsetStatus(\"detached\");\n\t\t\t\treturn;\n\t\t\tdefault: return;\n\t\t}\n\t};\n\t/**\n\t* The defensive inbound boundary — the RealmClient twin: a decode/apply throw\n\t* (unknown interned key id, non-resolving patch parent) must not escape into the wire mux,\n\t* silently drop the frame, or abort a batch's siblings. On failure, heal via re-hello with\n\t* backoff; `lastInboundAt` is stamped only after clean handling, so a throwing frame no longer\n\t* fools the staleness probe.\n\t*/\n\tconst onFrame = (frame) => {\n\t\ttry {\n\t\t\thandleFrame(frame);\n\t\t} catch (error) {\n\t\t\tonDiagnostic({\n\t\t\t\ttype: \"frame_error\",\n\t\t\t\terror\n\t\t\t});\n\t\t\thydrateChunks = [];\n\t\t\tscheduleResyncWithBackoff();\n\t\t\treturn;\n\t\t}\n\t\tlastInboundAt = Date.now();\n\t\tresyncAttempts = 0;\n\t\tclearResyncRetry();\n\t\tif (probeDeadline != null) {\n\t\t\tclearTimeout(probeDeadline);\n\t\t\tprobeDeadline = void 0;\n\t\t}\n\t};\n\tlet unsubscribeLinkEvents;\n\tconst securityShortfall = computeRealmSecurityShortfall(options.connection, realm, options.security);\n\tif (securityShortfall != null) {\n\t\tattachError = securityShortfall;\n\t\tsetStatus(\"detached\");\n\t\toptions.connection.release();\n\t} else {\n\t\tport = options.connection.register({\n\t\t\tonFrame,\n\t\t\tonAttach: () => sendHello(),\n\t\t\tonDetach: () => {\n\t\t\t\tif (status !== \"detached\") setStatus(\"connecting\");\n\t\t\t}\n\t\t});\n\t\tif (port.isOpen()) sendHello();\n\t\tunsubscribeLinkEvents = options.connection.subscribeLinkEvents?.((event) => {\n\t\t\tif (event.type === \"link_up\" && event.downForMs != null) onDiagnostic({\n\t\t\t\ttype: \"link_redialed\",\n\t\t\t\tdownForMs: event.downForMs\n\t\t\t});\n\t\t});\n\t}\n\tlet probeTimer;\n\tif (securityShortfall == null && staleProbeAfterMs > 0) {\n\t\tprobeTimer = setInterval(() => {\n\t\t\tif (status !== \"live\" || port?.isOpen() !== true) return;\n\t\t\tconst now = Date.now();\n\t\t\tif (now - lastInboundAt < staleProbeAfterMs) return;\n\t\t\tif (now - lastProbeAt < staleProbeAfterMs) return;\n\t\t\tsendHello({ probe: true });\n\t\t}, Math.max(1e3, Math.floor(staleProbeAfterMs / 2)));\n\t\tunrefTimer(probeTimer);\n\t}\n\tconst runIntent = (name, input) => {\n\t\tconst intentToken = realm.intentNames.indexOf(name);\n\t\tif (intentToken < 0) {\n\t\t\tconst controller = createWriteHandle();\n\t\t\tcontroller.reject(err_realm.fromId(\"intent_unknown\", { intent: name }));\n\t\t\treturn controller.handle;\n\t\t}\n\t\treturn sendTracked((clientSeq) => encodeIntent({\n\t\t\tslot,\n\t\t\tclientSeq,\n\t\t\tintentToken,\n\t\t\tinput\n\t\t}));\n\t};\n\tconst sendTracked = (build) => {\n\t\tconst controller = createWriteHandle();\n\t\tif (port?.isOpen() !== true) {\n\t\t\tcontroller.reject(err_realm.fromId(\"frame_too_stale\", { basisVersion: version }));\n\t\t\treturn controller.handle;\n\t\t}\n\t\tconst clientSeq = nextSeq++;\n\t\tconst entry = {\n\t\t\tcontroller,\n\t\t\tbuild,\n\t\t\texpiryTimer: void 0\n\t\t};\n\t\tentry.expiryTimer = setTimeout(() => {\n\t\t\tif (inFlight.get(clientSeq) !== entry) return;\n\t\t\tinFlight.delete(clientSeq);\n\t\t\tcontroller.reject(err_realm.fromId(\"frame_too_stale\", { basisVersion: version }));\n\t\t}, expiryMs);\n\t\tunrefTimer(entry.expiryTimer);\n\t\tinFlight.set(clientSeq, entry);\n\t\tport.send(build(clientSeq));\n\t\treturn controller.handle;\n\t};\n\treturn {\n\t\tget state() {\n\t\t\treturn state;\n\t\t},\n\t\tget version() {\n\t\t\treturn version;\n\t\t},\n\t\tget status() {\n\t\t\treturn status;\n\t\t},\n\t\tget hasBeenLive() {\n\t\t\treturn hasBeenLive;\n\t\t},\n\t\tget attachError() {\n\t\t\treturn attachError;\n\t\t},\n\t\tsubscribeStatus(listener) {\n\t\t\tstatusListeners.add(listener);\n\t\t\treturn () => statusListeners.delete(listener);\n\t\t},\n\t\tupdate(fn) {\n\t\t\tconst [next, patches] = produceWithPatches(state, (draft) => {\n\t\t\t\tfn(draft);\n\t\t\t});\n\t\t\tconst canonical = canonicalizeStatePatches(patches, next, realm.stateDef);\n\t\t\tif (canonical.length === 0) {\n\t\t\t\tconst controller = createWriteHandle();\n\t\t\t\tcontroller.confirm({ version });\n\t\t\t\treturn controller.handle;\n\t\t\t}\n\t\t\treturn sendTracked((clientSeq) => encodeWrite({\n\t\t\t\tslot,\n\t\t\t\tclientSeq,\n\t\t\t\tbasisVersion: version,\n\t\t\t\tops: namePatchesToWireOps(canonical, realm.tokens)\n\t\t\t}));\n\t\t},\n\t\tintents: Object.fromEntries(realm.intentNames.map((name) => [name, (input) => runIntent(name, input)])),\n\t\tintent: runIntent,\n\t\tdetach() {\n\t\t\tif (probeTimer != null) clearInterval(probeTimer);\n\t\t\tif (probeDeadline != null) clearTimeout(probeDeadline);\n\t\t\tunsubscribeLinkEvents?.();\n\t\t\tclearResyncRetry();\n\t\t\tif (port?.isOpen() === true) try {\n\t\t\t\tport.send(encodeDetach({\n\t\t\t\t\tslot,\n\t\t\t\t\treason: void 0\n\t\t\t\t}));\n\t\t\t} catch {}\n\t\t\thelloInFlight = false;\n\t\t\tsetStatus(\"detached\");\n\t\t\toptions.connection.release();\n\t\t\tfor (const entry of inFlight.values()) {\n\t\t\t\tif (entry.expiryTimer != null) clearTimeout(entry.expiryTimer);\n\t\t\t\tentry.controller.reject(err_realm.fromId(\"frame_too_stale\", { basisVersion: version }));\n\t\t\t}\n\t\t\tinFlight.clear();\n\t\t}\n\t};\n}\nfunction concatChunks(chunks) {\n\tif (chunks.length === 1) return chunks[0];\n\tconst total = chunks.reduce((sum, chunk) => sum + chunk.byteLength, 0);\n\tconst out = new Uint8Array(total);\n\tlet offset = 0;\n\tfor (const chunk of chunks) {\n\t\tout.set(chunk, offset);\n\t\toffset += chunk.byteLength;\n\t}\n\treturn out;\n}\n//#endregion\nexport { connectRealm as n, connectRealmReplica as t };\n\n//# sourceMappingURL=RealmReplica-CVo40qsA.mjs.map","import { S as WireProtocolMux } from \"../wire-D7Nv6hx_.mjs\";\nimport { m as WIRE_PROTOCOL_PREFIX } from \"../ReliableLog-DudDQ2zp.mjs\";\nimport { _t as sha256Hex, t as unrefTimer } from \"../util-DiEla9R9.mjs\";\nimport { T as err_realm, i as createRealmServerEngine, n as DEFAULT_REALM_LIMITS, p as decodeRealmFrame, r as RealmServerEngine, t as createRealmAcceptor, x as REALM_FRAME_KIND } from \"../realmAcceptorProtocol-DqECRw9r.mjs\";\nimport { n as connectRealm, t as connectRealmReplica } from \"../RealmReplica-CVo40qsA.mjs\";\n//#region src/realm/RealmClient/realmMuxClient.ts\nconst managers = /* @__PURE__ */ new WeakMap();\n/** Grace period before a released slot number may be recycled — see `release()`. */\nconst SLOT_QUARANTINE_MS = 5e3;\nfunction managerFor(mux) {\n\tlet manager = managers.get(mux);\n\tif (manager != null) return manager;\n\tconst slots = /* @__PURE__ */ new Map();\n\tconst safeDeliver = (handlers, frame, byteSize) => {\n\t\ttry {\n\t\t\thandlers.onFrame(frame, byteSize);\n\t\t} catch (error) {\n\t\t\tconsole.error(\"[realm] a realm slot handler threw while dispatching an inbound frame\", error);\n\t\t}\n\t};\n\tconst dispatch = (frame, byteSize) => {\n\t\tif (frame.slot === 255) {\n\t\t\tfor (const handlers of slots.values()) safeDeliver(handlers, frame, byteSize);\n\t\t\treturn;\n\t\t}\n\t\tconst handlers = slots.get(frame.slot);\n\t\tif (handlers != null) safeDeliver(handlers, frame, byteSize);\n\t};\n\tmanager = {\n\t\tnextSlot: 0,\n\t\tfreeSlots: [],\n\t\tslots,\n\t\tport: mux.registerProtocol({\n\t\t\tid: \"realm\",\n\t\t\tprefixByte: WIRE_PROTOCOL_PREFIX.realm,\n\t\t\tonFrame: (payload) => {\n\t\t\t\tlet frame;\n\t\t\t\ttry {\n\t\t\t\t\tframe = decodeRealmFrame(payload);\n\t\t\t\t} catch {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (frame.kind === REALM_FRAME_KIND.batch) {\n\t\t\t\t\tconst groups = /* @__PURE__ */ new Map();\n\t\t\t\t\tfor (const child of frame.frames) {\n\t\t\t\t\t\tif (child.slot === 255) {\n\t\t\t\t\t\t\tdispatch(child);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst group = groups.get(child.slot);\n\t\t\t\t\t\tif (group == null) groups.set(child.slot, [child]);\n\t\t\t\t\t\telse group.push(child);\n\t\t\t\t\t}\n\t\t\t\t\tfor (const [slot, children] of groups) {\n\t\t\t\t\t\tconst handlers = slots.get(slot);\n\t\t\t\t\t\tif (handlers == null) continue;\n\t\t\t\t\t\tsafeDeliver(handlers, children.length === 1 ? children[0] : {\n\t\t\t\t\t\t\tkind: REALM_FRAME_KIND.batch,\n\t\t\t\t\t\t\tslot,\n\t\t\t\t\t\t\tframes: children\n\t\t\t\t\t\t}, groups.size === 1 ? payload.byteLength : void 0);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tdispatch(frame, payload.byteLength);\n\t\t\t},\n\t\t\tonAttach: () => {\n\t\t\t\tfor (const handlers of slots.values()) handlers.onAttach();\n\t\t\t},\n\t\t\tonDetach: () => {\n\t\t\t\tfor (const handlers of slots.values()) handlers.onDetach();\n\t\t\t}\n\t\t})\n\t};\n\tmanagers.set(mux, manager);\n\treturn manager;\n}\n/**\n* A slot-scoped connection adapter for `connectRealm({ connection })` — production path.\n*\n* **Call this (or `connectRealm` with it) BEFORE the first action runs on the link.** The\n* handshake advertises the mux's registered protocols as caps, and the acceptor persists them on\n* the connection's binding — that advertisement is what makes a hibernation-woken host re-attach\n* the realm protocol and send this connection its \"rehello\" resume broadcast. Registering after\n* the handshake still works live (server dispatch doesn't require negotiation, and the realm's\n* hello waits for the mux to attach), but an idle client would miss the wake resume and stay\n* stale until its own next write triggers the lazy unknown-slot heal.\n*/\nfunction realmConnection(source) {\n\tconst isMux = source instanceof WireProtocolMux;\n\tconst mux = isMux ? source : source.wireMux;\n\tif (mux == null) throw new Error(\"realmConnection: this link has no frame-protocol mux — connect it via connectChannel (which creates one per connection) or pass a WireProtocolMux directly.\");\n\tconst coordinate = isMux ? void 0 : source.localCoordinate;\n\tconst peer = isMux ? void 0 : \"peer\" in source ? source.peer : source.peerClient;\n\tconst securityLevel = isMux ? void 0 : source.securityLevel;\n\tconst requestReconnect = isMux ? void 0 : source.requestReconnect;\n\tconst linkEventSource = isMux ? void 0 : source.addLinkEventListener?.bind(source);\n\tconst manager = managerFor(mux);\n\tconst recycled = manager.freeSlots.pop();\n\tif (recycled == null && manager.nextSlot >= 255) throw new Error(`realmConnection: slot space exhausted (max 254)`);\n\tconst slot = recycled ?? manager.nextSlot++;\n\tlet released = false;\n\treturn {\n\t\tslot,\n\t\tcoordinate,\n\t\tpeer,\n\t\tpeerCoordinate: peer,\n\t\tsecurityLevel,\n\t\trequestReconnect,\n\t\tsubscribeLinkEvents: linkEventSource,\n\t\tregister(handlers) {\n\t\t\tmanager.slots.set(slot, handlers);\n\t\t\treturn {\n\t\t\t\tsend: (bytes) => manager.port.send(bytes),\n\t\t\t\tisOpen: () => manager.port.isOpen()\n\t\t\t};\n\t\t},\n\t\trelease() {\n\t\t\tif (released) return;\n\t\t\treleased = true;\n\t\t\tmanager.slots.delete(slot);\n\t\t\tunrefTimer(setTimeout(() => manager.freeSlots.push(slot), SLOT_QUARANTINE_MS));\n\t\t}\n\t};\n}\n//#endregion\n//#region src/realm/RealmDefinition/Intents/intents.types.ts\nfunction createIntentBuilder() {\n\treturn { define: (def) => def };\n}\n//#endregion\n//#region src/realm/RealmDefinition/Rules/ruleBuilder.ts\n/** Runtime `r` — one shared instance is fine per definition (it holds no state). */\nfunction createRuleBuilder() {\n\treturn {\n\t\tpath(pattern) {\n\t\t\treturn { view: (view) => ({ alter: (alter) => ({\n\t\t\t\tpattern,\n\t\t\t\tview,\n\t\t\t\talter\n\t\t\t}) }) };\n\t\t},\n\t\teveryone: { kind: \"everyone\" },\n\t\tserverOnly: { kind: \"serverOnly\" },\n\t\tavatarTypes: (...types) => ({\n\t\t\tkind: \"avatarTypes\",\n\t\t\ttypes\n\t\t}),\n\t\tserverChecked: (fn) => ({\n\t\t\tkind: \"serverChecked\",\n\t\t\tfn\n\t\t}),\n\t\tall: (...conds) => ({\n\t\t\tkind: \"all\",\n\t\t\tconds\n\t\t})\n\t};\n}\n//#endregion\n//#region src/realm/RealmDefinition/Rules/rulePattern.ts\n/** Parse + brace-expand one pattern into its concrete forms. Throws on malformed patterns. */\nfunction parseRulePattern(pattern) {\n\tif (pattern.length === 0) throw new Error(\"rule pattern may not be empty\");\n\tconst rawSegments = pattern.split(\".\");\n\tlet expanded = [[]];\n\trawSegments.forEach((raw, index) => {\n\t\tconst isLast = index === rawSegments.length - 1;\n\t\tif (raw.startsWith(\"{\") && raw.endsWith(\"}\")) {\n\t\t\tconst names = raw.slice(1, -1).split(\",\").map((n) => n.trim());\n\t\t\tif (names.some((n) => n.length === 0)) throw new Error(`rule pattern \"${pattern}\": empty name in brace group \"${raw}\"`);\n\t\t\texpanded = expanded.flatMap((prefix) => names.map((n) => [...prefix, n]));\n\t\t\treturn;\n\t\t}\n\t\tif ((raw === \"*\" || raw === \"**\") && !isLast) throw new Error(`rule pattern \"${pattern}\": \"${raw}\" is only valid as the final segment`);\n\t\texpanded = expanded.map((prefix) => [...prefix, raw]);\n\t});\n\treturn expanded.map((names) => ({\n\t\tsource: pattern,\n\t\tsegments: names.map((name) => {\n\t\t\tif (name === \"*\") return { kind: \"star\" };\n\t\t\tif (name === \"**\") return { kind: \"deep\" };\n\t\t\tif (name.startsWith(\"$\")) {\n\t\t\t\tconst varName = name.slice(1);\n\t\t\t\tif (varName.length === 0) throw new Error(`rule pattern \"${pattern}\": bare \"$\" segment`);\n\t\t\t\treturn {\n\t\t\t\t\tkind: \"var\",\n\t\t\t\t\tname: varName\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (name.includes(\"{\") || name.includes(\"}\") || name.includes(\"$\")) throw new Error(`rule pattern \"${pattern}\": malformed segment \"${name}\"`);\n\t\t\treturn {\n\t\t\t\tkind: \"lit\",\n\t\t\t\tname\n\t\t\t};\n\t\t})\n\t}));\n}\n//#endregion\n//#region src/realm/RealmDefinition/Rules/ruleSchemaLint.ts\n/**\n* Compile-time (defineRealm-time) lint: every rule pattern must be able to match at least one\n* path the schema can ever produce. The failure mode this kills is the silent default-deny —\n* e.g. `terrain.**` over `terrain: t.array(...)` compiles happily but matches *nothing*, because\n* arrays (and every other wire-leaf) are patched and visibility-checked at exactly their own\n* path, and `**`/`*` need at least one further segment. Dead rules throw here, at definition\n* time, instead of a branch quietly never reaching any client.\n*/\nfunction assertRulePatternsMatchSchema(root, patterns) {\n\tfor (const pattern of patterns) for (const parsed of parseRulePattern(pattern)) {\n\t\tconst problem = checkSegments({\n\t\t\tkind: \"object\",\n\t\t\tentries: root\n\t\t}, parsed.segments, 0);\n\t\tif (problem != null) throw new Error(`rule pattern \"${pattern}\" can never match: ${problem}`);\n\t}\n}\n/**\n* Validate + parse a realm's `transient` region paths. v1\n* accepts only **concrete, wildcard-free** dot-paths, each naming a subtree root that exists in the\n* schema (`\"presence\"`, `\"board.cursors\"`). Wildcards (`$var`, `*`, `**`, `{a,b}`) are rejected —\n* snapshot-strip and the replay refresh are a trivial root walk, not a pattern projection (that is a\n* recorded §7 deferral). Returns the parsed segment paths; throws at definition time on any problem.\n*/\nfunction assertTransientRoots(root, dotPaths) {\n\tconst parsed = [];\n\tfor (const dotPath of dotPaths) {\n\t\tconst segments = dotPath.split(\".\");\n\t\tfor (const seg of segments) if (seg.length === 0 || /[$*{}]/.test(seg)) throw new Error(`transient path \"${dotPath}\" must be a concrete, wildcard-free path (no $var, *, ** or {a,b}); offending segment \"${seg}\". Wildcard transient regions are not supported in v1.`);\n\t\tif (resolveConcretePath({\n\t\t\tkind: \"object\",\n\t\t\tentries: root\n\t\t}, segments, 0) == null) throw new Error(`transient path \"${dotPath}\" does not resolve to any node in the realm schema.`);\n\t\tparsed.push(segments);\n\t}\n\treturn parsed;\n}\n/** Walk a concrete (literal-only) path through the schema; `undefined` if it leaves the schema. */\nfunction resolveConcretePath(node, segments, index) {\n\tif (index >= segments.length) return node;\n\tconst inner = unwrapOptional$1(node);\n\tif (inner.kind === \"object\") {\n\t\tconst child = inner.entries[segments[index]];\n\t\treturn child == null ? void 0 : resolveConcretePath(child, segments, index + 1);\n\t}\n\tif (inner.kind === \"record\") return resolveConcretePath(inner.value, segments, index + 1);\n}\nfunction unwrapOptional$1(node) {\n\treturn node.kind === \"optional\" ? unwrapOptional$1(node.inner) : node;\n}\n/** `undefined` = the pattern can match; otherwise a description of why it never will. */\nfunction checkSegments(node, segments, index) {\n\tif (index >= segments.length) return void 0;\n\tconst inner = unwrapOptional$1(node);\n\tconst seg = segments[index];\n\tconst at = describePrefix(segments, index);\n\tif (inner.kind === \"object\") {\n\t\tif (seg.kind === \"lit\") {\n\t\t\tconst child = inner.entries[seg.name];\n\t\t\tif (child == null) return `\"${seg.name}\" is not a key of the object at ${at}`;\n\t\t\treturn checkSegments(child, segments, index + 1);\n\t\t}\n\t\tif (seg.kind === \"var\") {\n\t\t\tconst children = Object.values(inner.entries);\n\t\t\tif (children.length === 0) return `the object at ${at} has no keys`;\n\t\t\treturn children.some((child) => checkSegments(child, segments, index + 1) == null) ? void 0 : `no key of the object at ${at} admits the rest of the pattern`;\n\t\t}\n\t\treturn;\n\t}\n\tif (inner.kind === \"record\") {\n\t\tif (seg.kind === \"lit\" || seg.kind === \"var\") return checkSegments(inner.value, segments, index + 1);\n\t\treturn;\n\t}\n\tconst hint = inner.kind === \"array\" ? ` (t.array is leaf-replace-only on the wire — rule it with the exact path, e.g. \"${describePrefix(segments, index, true)}\")` : \"\";\n\treturn `it descends into the ${inner.kind} wire-leaf at ${at}${hint}`;\n}\nfunction describePrefix(segments, index, bare = false) {\n\tconst prefix = segments.slice(0, index).map((seg) => seg.kind === \"lit\" ? seg.name : seg.kind === \"var\" ? `$${seg.name}` : seg.kind === \"star\" ? \"*\" : \"**\").join(\".\");\n\tif (prefix.length === 0) return \"the state root\";\n\treturn bare ? prefix : `\"${prefix}\"`;\n}\n//#endregion\n//#region src/realm/RealmDefinition/Rules/ruleTrie.ts\nvar RealmRuleTrie = class {\n\t_root = {};\n\t_patterns = [];\n\tconstructor(rules) {\n\t\tfor (const rule of rules) {\n\t\t\tfor (const parsed of parseRulePattern(rule.pattern)) this._insert(parsed, rule);\n\t\t\tthis._patterns.push(rule.pattern);\n\t\t}\n\t}\n\t/** The source patterns, in definition order (schema-hash input). */\n\tget patterns() {\n\t\treturn this._patterns;\n\t}\n\t_insert(parsed, rule) {\n\t\tconst varNames = [];\n\t\tlet node = this._root;\n\t\tfor (let i = 0; i < parsed.segments.length; i++) {\n\t\t\tconst seg = parsed.segments[i];\n\t\t\tif (seg.kind === \"star\") {\n\t\t\t\tif (node.star != null) throw new Error(`duplicate rule pattern at \"${parsed.source}\"`);\n\t\t\t\tnode.star = {\n\t\t\t\t\trule,\n\t\t\t\t\tvarNames\n\t\t\t\t};\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (seg.kind === \"deep\") {\n\t\t\t\tif (node.deep != null) throw new Error(`duplicate rule pattern at \"${parsed.source}\"`);\n\t\t\t\tnode.deep = {\n\t\t\t\t\trule,\n\t\t\t\t\tvarNames\n\t\t\t\t};\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (seg.kind === \"var\") {\n\t\t\t\tvarNames[i] = seg.name;\n\t\t\t\tif (node.var == null) node.var = {\n\t\t\t\t\tname: seg.name,\n\t\t\t\t\tnode: {}\n\t\t\t\t};\n\t\t\t\telse if (node.var.name !== seg.name) throw new Error(`conflicting $var names at the same trie position: \"$${node.var.name}\" vs \"$${seg.name}\" (${parsed.source})`);\n\t\t\t\tnode = node.var.node;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tnode.lit ??= /* @__PURE__ */ new Map();\n\t\t\tlet child = node.lit.get(seg.name);\n\t\t\tif (child == null) {\n\t\t\t\tchild = {};\n\t\t\t\tnode.lit.set(seg.name, child);\n\t\t\t}\n\t\t\tnode = child;\n\t\t}\n\t\tif (node.exact != null) throw new Error(`duplicate rule pattern at \"${parsed.source}\"`);\n\t\tnode.exact = {\n\t\t\trule,\n\t\t\tvarNames\n\t\t};\n\t}\n\t/** Match a concrete (name-space) path; `undefined` when no rule covers it. */\n\tmatch(path) {\n\t\tconst found = this._match(this._root, path, 0);\n\t\tif (found == null) return void 0;\n\t\tconst params = {};\n\t\tfound.varNames.forEach((name, i) => {\n\t\t\tif (name != null) params[name] = path[i];\n\t\t});\n\t\treturn {\n\t\t\trule: found.rule,\n\t\t\tparams\n\t\t};\n\t}\n\t/**\n\t* Whether some rule's pattern can match a path strictly BENEATH `path` (a `**` at or above it\n\t* counts). Ignores `view` conditions — the answer is about schema reachability, not access.\n\t*/\n\treachesBeneath(path) {\n\t\treturn this._reachesBeneath(this._root, path, 0);\n\t}\n\t_reachesBeneath(node, path, depth) {\n\t\tif (node.deep != null) return true;\n\t\tif (depth === path.length) return (node.lit?.size ?? 0) > 0 || node.var != null || node.star != null;\n\t\tconst litChild = node.lit?.get(path[depth]);\n\t\tif (litChild != null && this._reachesBeneath(litChild, path, depth + 1)) return true;\n\t\treturn node.var != null && this._reachesBeneath(node.var.node, path, depth + 1);\n\t}\n\t_match(node, path, depth) {\n\t\tif (depth === path.length) return node.exact;\n\t\tconst seg = path[depth];\n\t\tconst isLast = depth === path.length - 1;\n\t\tconst litChild = node.lit?.get(seg);\n\t\tif (litChild != null) {\n\t\t\tconst hit = this._match(litChild, path, depth + 1);\n\t\t\tif (hit != null) return hit;\n\t\t}\n\t\tif (node.var != null) {\n\t\t\tconst hit = this._match(node.var.node, path, depth + 1);\n\t\t\tif (hit != null) return hit;\n\t\t}\n\t\tif (isLast && node.star != null) return node.star;\n\t\tif (node.deep != null) return node.deep;\n\t}\n};\n//#endregion\n//#region src/realm/RealmDefinition/Schema/schemaHash.ts\n/**\n* The realm schema hash: SHA-256 over a canonical serialization of\n* everything both sides must agree on for the wire to be meaningful — realm id, state shape\n* (sorted), client-type names, intent names + input shapes, and rule path patterns. It rides the\n* realm `hello` and hard-fails a mismatch (`err_realm.schema_mismatch`): silent token skew on a\n* stale mobile client would be data corruption, not an error.\n*\n* Known, documented limitation: an embedded standard-schema validator (`t.schema(...)`) is opaque\n* — its internals don't affect the hash (canonicalized as just `std`) unless the leaf opts in\n* with `t.schema(v, { hashTag })`, which the consumer bumps on contract changes. Untagged, treat\n* embedded-validator edits as value-rule changes, not shape changes.\n*/\nfunction canonNode(node) {\n\tswitch (node.kind) {\n\t\tcase \"string\": return node.maxLength == null ? node.kind : {\n\t\t\tk: \"string\",\n\t\t\tmax: node.maxLength\n\t\t};\n\t\tcase \"number\":\n\t\t\tif (node.min == null && node.max == null && node.integer !== true) return node.kind;\n\t\t\treturn {\n\t\t\t\tk: \"number\",\n\t\t\t\t...node.min != null ? { min: node.min } : {},\n\t\t\t\t...node.max != null ? { max: node.max } : {},\n\t\t\t\t...node.integer === true ? { int: true } : {}\n\t\t\t};\n\t\tcase \"boolean\": return node.kind;\n\t\tcase \"literal\": return {\n\t\t\tk: \"lit\",\n\t\t\tv: node.value\n\t\t};\n\t\tcase \"union\": return {\n\t\t\tk: \"u\",\n\t\t\to: node.options.map((o) => JSON.stringify(canonNode(o))).sort()\n\t\t};\n\t\tcase \"optional\": return {\n\t\t\tk: \"opt\",\n\t\t\ti: canonNode(node.inner)\n\t\t};\n\t\tcase \"object\": return {\n\t\t\tk: \"obj\",\n\t\t\te: Object.keys(node.entries).sort().map((n) => [n, canonNode(node.entries[n])])\n\t\t};\n\t\tcase \"record\": {\n\t\t\tconst base = {\n\t\t\t\tk: \"rec\",\n\t\t\t\tid: node.keyVar,\n\t\t\t\tv: canonNode(node.value)\n\t\t\t};\n\t\t\treturn node.maxKeys == null ? base : {\n\t\t\t\t...base,\n\t\t\t\tmax: node.maxKeys\n\t\t\t};\n\t\t}\n\t\tcase \"array\": {\n\t\t\tconst base = {\n\t\t\t\tk: \"arr\",\n\t\t\t\ti: canonNode(node.item)\n\t\t\t};\n\t\t\treturn node.maxItems == null ? base : {\n\t\t\t\t...base,\n\t\t\t\tmax: node.maxItems\n\t\t\t};\n\t\t}\n\t\tcase \"standard\": return node.hashTag == null ? { k: \"std\" } : {\n\t\t\tk: \"std\",\n\t\t\ttag: node.hashTag\n\t\t};\n\t}\n}\n/** Canonical serialization (deterministic across platforms — everything sorted). */\nfunction canonicalSchemaString(inputs) {\n\tconst names = Object.keys(inputs.state).sort();\n\treturn JSON.stringify({\n\t\tid: inputs.id,\n\t\tstate: names.map((n) => [n, canonNode(inputs.state[n])]),\n\t\tclients: [...inputs.avatarTypes].sort(),\n\t\tintents: [...inputs.intents].sort((a, b) => a[0] < b[0] ? -1 : 1).map(([name, input]) => [name, canonNode(input)]),\n\t\trules: [...inputs.rulePatterns].sort()\n\t});\n}\nfunction computeSchemaHash(inputs) {\n\treturn sha256Hex(canonicalSchemaString(inputs));\n}\n//#endregion\n//#region src/realm/RealmDefinition/Schema/tokenMap.ts\nfunction unwrapOptional(node) {\n\treturn node.kind === \"optional\" ? unwrapOptional(node.inner) : node;\n}\nfunction buildLevelForNode(node) {\n\tconst inner = unwrapOptional(node);\n\tif (inner.kind === \"object\") return buildLevel(inner.entries);\n\tif (inner.kind === \"record\") return {\n\t\ttoToken: /* @__PURE__ */ new Map(),\n\t\ttoName: [],\n\t\tchildren: /* @__PURE__ */ new Map(),\n\t\trecordChild: buildLevelForNode(inner.value)\n\t};\n\treturn \"leaf\";\n}\nfunction buildLevel(entries) {\n\tconst names = Object.keys(entries).sort();\n\tconst level = {\n\t\ttoToken: /* @__PURE__ */ new Map(),\n\t\ttoName: [],\n\t\tchildren: /* @__PURE__ */ new Map()\n\t};\n\tnames.forEach((name, i) => {\n\t\tlevel.toToken.set(name, i);\n\t\tlevel.toName.push(name);\n\t\tlevel.children.set(name, buildLevelForNode(entries[name]));\n\t});\n\treturn level;\n}\nvar RealmTokenMap = class {\n\t_root;\n\tconstructor(stateRoot) {\n\t\tthis._root = buildLevel(stateRoot);\n\t}\n\t/**\n\t* Name path → wire path (object keys → ints; record keys pass through as strings, or as\n\t* interned ids when `internKey` resolves one — the protocol contract key interning).\n\t*/\n\ttokenizePath(path, internKey) {\n\t\tconst out = [];\n\t\tlet level = this._root;\n\t\tfor (const seg of path) {\n\t\t\tif (level === \"leaf\" || level == null) throw new Error(`tokenizePath: path descends past a leaf at \"${seg}\" (${path.join(\".\")})`);\n\t\t\tif (level === \"record\") throw new Error(`tokenizePath: internal record level error at \"${seg}\"`);\n\t\t\tif (level.recordChild != null) {\n\t\t\t\tout.push(internKey?.(seg) ?? seg);\n\t\t\t\tlevel = level.recordChild;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst token = level.toToken.get(seg);\n\t\t\tif (token == null) throw new Error(`tokenizePath: unknown key \"${seg}\" in path ${path.join(\".\")}`);\n\t\t\tout.push(token);\n\t\t\tlevel = level.children.get(seg) ?? \"leaf\";\n\t\t}\n\t\treturn out;\n\t}\n\t/**\n\t* Wire path → name path (inverse of {@link tokenizePath}). At record levels an int segment is\n\t* an interned key id, resolved through `resolveKey` (absence of a resolver, or an unknown id,\n\t* is a hard error — silent misresolution would corrupt paths).\n\t*/\n\tdetokenizePath(wirePath, resolveKey) {\n\t\tconst out = [];\n\t\tlet level = this._root;\n\t\tfor (const seg of wirePath) {\n\t\t\tif (level === \"leaf\" || level === \"record\" || level == null) throw new Error(`detokenizePath: path descends past a leaf (${wirePath.join(\".\")})`);\n\t\t\tif (level.recordChild != null) {\n\t\t\t\tif (typeof seg === \"number\") {\n\t\t\t\t\tconst key = resolveKey?.(seg);\n\t\t\t\t\tif (key == null) throw new Error(`detokenizePath: unknown interned key id ${seg}`);\n\t\t\t\t\tout.push(key);\n\t\t\t\t} else out.push(seg);\n\t\t\t\tlevel = level.recordChild;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (typeof seg !== \"number\" || seg < 0 || seg >= level.toName.length) throw new Error(`detokenizePath: invalid token \"${seg}\" (${wirePath.join(\".\")})`);\n\t\t\tconst name = level.toName[seg];\n\t\t\tout.push(name);\n\t\t\tlevel = level.children.get(name) ?? \"leaf\";\n\t\t}\n\t\treturn out;\n\t}\n\t/** The schema node names at the root level, in token order (test/debug surface). */\n\trootTokenNames() {\n\t\treturn this._root.toName;\n\t}\n};\n//#endregion\n//#region src/realm/RealmDefinition/defineRealm.ts\n/**\n* The single source of truth: one block declaring the state shape, the client types,\n* the rules, and the intents — from which the types, token map, schema hash, rule trie, and\n* prediction bundle all derive. **This module ships to clients**: nothing here may close over\n* secrets; server-only data enters via `createRealmServerEngine(realm, { ctx })`.\n*/\nfunction defineRealm(input) {\n\tconst rules = input.rules(createRuleBuilder());\n\tassertRulePatternsMatchSchema(input.state, rules.map((rule) => rule.pattern));\n\tconst ruleTrie = new RealmRuleTrie(rules);\n\tconst transient = assertTransientRoots(input.state, input.transient ?? []);\n\tconst intents = input.intents?.(createIntentBuilder()) ?? {};\n\tconst intentNames = Object.keys(intents).sort();\n\tconst avatarTypes = Object.keys(input.avatars).sort();\n\tconst tokens = new RealmTokenMap(input.state);\n\tconst schemaHash = computeSchemaHash({\n\t\tid: input.id,\n\t\tstate: input.state,\n\t\tavatarTypes,\n\t\tintents: intentNames.map((name) => [name, intents[name].input]),\n\t\trulePatterns: rules.map((rule) => rule.pattern)\n\t});\n\treturn {\n\t\tid: input.id,\n\t\tsecurity: input.security ?? \"authenticated\",\n\t\tavatarTypes,\n\t\tstateDef: input.state,\n\t\trules,\n\t\truleTrie,\n\t\tintents,\n\t\tintentNames,\n\t\ttokens,\n\t\ttransient,\n\t\tschemaHash\n\t};\n}\n//#endregion\n//#region src/realm/RealmDefinition/errors/isUnknownOutcomeRejection.ts\n/**\n* `true` ⇒ this rejection means the intent/write expired **unconfirmed** — the outcome is\n* *unknown*, not \"rejected\". The write may have committed on the server while the ack was lost, or\n* the link dropped mid-flight.\n*\n* Re-read state (it converges via the next replay/hydrate) and decide — do **not** blindly\n* re-issue a non-idempotent intent on this error. A rules rejection, by contrast, is a definite\n* \"no\" (it carries the rule's own error, from the realm's own domain) and returns `false` here.\n*\n* Named for the semantic rather than the error id so the guidance travels with the API — this is\n* the supported way to detect the unknown-outcome case in a `catch`, instead of importing\n* {@link err_realm} into UI code or duck-typing `hasId`.\n*\n* @example\n* ```ts\n* try {\n*   await realm.intent.fireShot({ angle, power });\n* } catch (e) {\n*   if (isUnknownOutcomeRejection(e)) {\n*     // Outcome unknown — the shot may have landed. Re-read state, don't re-fire.\n*     await refreshFromRealmState();\n*   } else {\n*     showRejection(e); // a definite \"no\" (rules rejection or transport failure)\n*   }\n* }\n* ```\n*/\nfunction isUnknownOutcomeRejection(e) {\n\treturn err_realm.isExact(e) && e.hasId(\"frame_too_stale\");\n}\n//#endregion\n//#region src/realm/RealmDefinition/Schema/t.ts\n/** Bounds are declaration errors when malformed — caught at `defineRealm` time, not at runtime. */\nfunction checkCount(name, value) {\n\tif (value == null) return void 0;\n\tif (!Number.isSafeInteger(value) || value < 0) throw new Error(`t: ${name} must be a non-negative safe integer, got ${value}`);\n\treturn value;\n}\nfunction checkNumberOptions(options) {\n\tconst { min, max, integer } = options;\n\tif (min != null && !Number.isFinite(min)) throw new Error(`t: number min must be finite, got ${min}`);\n\tif (max != null && !Number.isFinite(max)) throw new Error(`t: number max must be finite, got ${max}`);\n\tif (min != null && max != null && min > max) throw new Error(`t: number min (${min}) must be <= max (${max})`);\n\tif (integer != null && typeof integer !== \"boolean\") throw new Error(`t: number integer must be a boolean`);\n\treturn {\n\t\t...min != null ? { min } : {},\n\t\t...max != null ? { max } : {},\n\t\t...integer === true ? { integer: true } : {}\n\t};\n}\nfunction union(...args) {\n\tconst options = args.flatMap((arg) => Array.isArray(arg) ? arg : [arg]);\n\tif (options.length < 2) throw new Error(`t.union needs at least 2 options, got ${options.length}`);\n\treturn {\n\t\tkind: \"union\",\n\t\toptions\n\t};\n}\n/**\n* The realm schema builder — `t.*`. One `defineRealm` block uses these to declare the\n* state shape; from that single declaration the library derives the TS types, the token map, the\n* schema hash, and (M4) the server-side value validator.\n*/\nconst t = {\n\tstring(options = {}) {\n\t\tconst maxLength = checkCount(\"string maxLength\", options.maxLength);\n\t\treturn {\n\t\t\tkind: \"string\",\n\t\t\t...maxLength != null ? { maxLength } : {}\n\t\t};\n\t},\n\tnumber(options = {}) {\n\t\treturn {\n\t\t\tkind: \"number\",\n\t\t\t...checkNumberOptions(options)\n\t\t};\n\t},\n\tboolean() {\n\t\treturn { kind: \"boolean\" };\n\t},\n\tliteral(value) {\n\t\treturn {\n\t\t\tkind: \"literal\",\n\t\t\tvalue\n\t\t};\n\t},\n\tunion,\n\toptional(inner) {\n\t\treturn {\n\t\t\tkind: \"optional\",\n\t\t\tinner\n\t\t};\n\t},\n\tobject(entries) {\n\t\treturn {\n\t\t\tkind: \"object\",\n\t\t\tentries\n\t\t};\n\t},\n\t/** Record-key marker for {@link t.record} — binds `$varName` in rule paths. */\n\tid(varName) {\n\t\treturn {\n\t\t\tkind: \"id\",\n\t\t\tvarName\n\t\t};\n\t},\n\trecord(key, value, options = {}) {\n\t\tconst maxKeys = checkCount(\"record maxKeys\", options.maxKeys);\n\t\treturn {\n\t\t\tkind: \"record\",\n\t\t\tkeyVar: key.varName,\n\t\t\tvalue,\n\t\t\t...maxKeys != null ? { maxKeys } : {}\n\t\t};\n\t},\n\t/** Leaf-replace semantics only in v1 (proposal §7.8) — prefer keyed {@link t.record} collections. */\n\tarray(item, options = {}) {\n\t\tconst maxItems = checkCount(\"array maxItems\", options.maxItems);\n\t\treturn {\n\t\t\tkind: \"array\",\n\t\t\titem,\n\t\t\t...maxItems != null ? { maxItems } : {}\n\t\t};\n\t},\n\t/**\n\t* Embed a standard-schema validator (e.g. valibot) at a leaf. The embedded schema's internals\n\t* are opaque to the schema hash — editing it does NOT change the realm's schemaHash. Pass a\n\t* `hashTag` (and bump it on every contract change) to opt the leaf's contract into the hash;\n\t* untagged, treat embedded-validator changes as value-rule changes, not shape changes.\n\t*/\n\tschema(schema, options = {}) {\n\t\tif (options.hashTag != null && (typeof options.hashTag !== \"string\" || options.hashTag === \"\")) throw new Error(\"t.schema: hashTag must be a non-empty string\");\n\t\treturn {\n\t\t\tkind: \"standard\",\n\t\t\tschema,\n\t\t\t...options.hashTag != null ? { hashTag: options.hashTag } : {}\n\t\t};\n\t},\n\t/**\n\t* Declare the server-only context TYPE. The value is injected at\n\t* `createRealmServerEngine(realm, { ctx })` time — nothing here exists in client bundles, and\n\t* nothing secret may be closed over in the definition module.\n\t*/\n\tserverContext() {\n\t\treturn { kind: \"serverContext\" };\n\t}\n};\n//#endregion\nexport { DEFAULT_REALM_LIMITS, RealmServerEngine, connectRealm, connectRealmReplica, createRealmAcceptor, createRealmServerEngine, defineRealm, err_realm, isUnknownOutcomeRejection, realmConnection, t };\n\n//# sourceMappingURL=index.mjs.map"],"mappings":";;;;;;;;;;;;;;AAcA,MAAM,YAAYA,uBAAAA,SAAS,kBAAkB;CAC5C,QAAQ;CACR,QAAQ;EACP,iBAAiBC,uBAAAA,IAAI;GACpB,UAAU,EAAE,SAAS,YAAY,iBAAiB,UAAU,QAAQ,6BAA6B,WAAW,MAAM,GAAG,EAAE,EAAE,cAAc,WAAW,MAAM,GAAG,EAAE,EAAE;GAC/J,SAAS,EAAE,UAAU,KAAK;EAC3B,CAAC;EACD,eAAeA,uBAAAA,IAAI;GAClB,UAAU,EAAE,cAAc,uCAAuC,QAAQ;GACzE,SAAS,EAAE,UAAU,KAAK;EAC3B,CAAC;EACD,0BAA0BA,uBAAAA,IAAI;GAC7B,UAAU,EAAE,YAAY,eAAe,gBAAgB,WAAW,qCAAqC,SAAS,KAAK,IAAI,EAAE;GAC3H,SAAS,EAAE,UAAU,KAAK;EAC3B,CAAC;;;EAGD,mBAAmBA,uBAAAA,IAAI;GACtB,UAAU,EAAE,cAAc,2EAA2E,QAAQ;GAC7G,SAAS,EAAE,UAAU,KAAK;EAC3B,CAAC;;;;;;;EAOD,uBAAuBA,uBAAAA,IAAI;GAC1B,UAAU,EAAE,SAAS,UAAU,aAAa,UAAU,QAAQ,gBAAgB,SAAS,wCAAwC,OAAO;GACtI,SAAS,EAAE,UAAU,KAAK;EAC3B,CAAC;EACD,yBAAyBA,uBAAAA,IAAI;GAC5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