OverviewFilesCommitsIssuesDocsReleasesPeers

holepunchto-deps commits / 0ac5f33

keet-core 4.23.8 + keet-indexing 6.4.2 (Keet 4.23.0)
From hyper-fleeky/keet-audit-4.23/extracted (extract-bundle.cjs on Keet 4.23.0's core-worker.bundle; self-verified 1026 files, 0 bad JSON, 0 truncated JS): keet-core 4.22.28 -> 4.23.8, keet-indexing 6.4.1 -> 6.4.2. The other vendored packages are not in the core-worker bundle and are unchanged, as in the 4.22.5 refresh. Why: the network's production hyperconf now sets versions.autoupgrade=37 (minVersion 4.23.1). keet-core 4.22.28's production ceiling (STABLE) is 35, so every room a 4.22.28 node creates upgrades itself to 37, the @keet/upgrade handler interrupts, and the room never applies another op — room.invite failed with "null anchor" on stortron and ashatron. keet-core 4.23.8 has STABLE=37 (contract schemaVersion 29 -> 31); an isolated repro on it creates the invite. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0ac5f33b8b227f7fc634403d7251136106a2974d
by plankatron <fleeky@gmail.com> · 2026-10-12T01:16:53.000Z

Changed files (34) +160 -36

@holepunchto/keet-core/env.json +2 -2
……@@ -34,7 +34,7 @@
3434 },
3535 "config": {
3636 "key": "q9nbmhfe9m4jrdqdxhfojaabhndkguj8wo8czhqhbdzu1nxa6ady",
37 "length": 29
37 "length": 31
3838 },
3939 "roomRegistry": {
4040 "key": "3jogtatsod7urw7zxuksk7t8qxpscxwosfnnd11qt17mphu63tky",
……@@ -44,7 +44,7 @@
4444 "prerelease": {
4545 "config": {
4646 "key": "3i34itm8zqhweq4oxjw3ebg1kyhywqn9359shn9sr1twmm7jdpuo",
47 "length": 29
47 "length": 31
4848 },
4949 "roomRegistry": {
5050 "key": "zxwyg5387zr1gy6okeyqhpdkhwp3csh167ndze83eyun6za13acy",
@holepunchto/keet-core/index.js +1 -1
……@@ -1 +1 @@
1const e=require("keet-identity-key"),{ProofEncoding:t}=require("keet-identity-key/lib/encoding"),i=require("hypercore-storage"),s=require("hypercore-id-encoding"),o=require("ready-resource"),r=require("ready-guard"),a=require("hyperswarm"),n=require("@holepunchto/call-swarm"),l=require("hyperdht"),c=require("corestore"),h=require("hypercore"),d=require("hyperblobs"),y=require("scope-lock"),u=require("rache"),p=require("protomux-wakeup"),m=require("promaphore"),g=require("safety-catch"),w=require("task-backoff"),f=require("hypercore-crypto"),b=require("z32"),v=require("b4a"),k=require("compact-encoding"),P=require("fs"),K=require("path"),_=require("blind-peering"),C=require("multi-profile-store"),R=require("hyperconf");h.enable(h.SMALL_WANTS),h.setRecoveryPeers&&h.setRecoveryPeers([]);const T=require("@holepunchto/keet-push"),L=require("@holepunchto/keet-unread-anchors"),{generateMnemonic:E}=require("bip39-mnemonic"),{HyperDiscoveryClient:I}=require("@holepunchto/hyperdiscovery"),S=require("./schema/versions"),{FEATURES:D}=S,A=require("./lib/api/v1"),x=require("./lib/api/v2"),B=require("./lib/core/crypto"),O=require("./lib/core/local"),V=require("./lib/core/files"),M=require("./lib/core/tasks"),q=require("./lib/core/sync/processor"),U=require("./lib/core/room-engine"),{SwarmWorker:N}=require("./lib/core/swarm"),{getWriterKey:F,getInvitationId:W,createInvitation:H,generateWakeupTopic:$,generateRoomCapabilities:j,generateIdentityPairingName:G,generateRoomPairingName:J}=require("./lib/core/invitations"),{getMemberForDeviceKey:z}=require("./lib/core/contract/query"),{restoreAvatar:Y}=require("./lib/core/contract/avatars"),{RoomStatus:Q}=require("./lib/core/contract/identity/private"),{DEBUG_FLAGS:X,DHT_SETTINGS:Z,SWARM_SETTINGS:ee}=require("./lib/core/debug/debugging"),te=require("./lib/core/log"),{contract:{hyperschema:{getEnum:ie,getEncoding:se,encode:oe,decode:re}},local:{hyperschema:{getEnum:ae}},config:{hyperconf:ne}}=require("./schema/spec"),le=se("@keet-private-id/profile-discovery-record"),ce=ie("@keet/build-type"),he=require("./lib/core/users"),de=require("./lib/core/rooms/index.js"),ye=require("protomux-rpc-client"),{KeetErrorManager:ue,KeetErrorV2:pe,ERRORS:me}=require("./lib/errors"),{Version:ge}=require("bare-semver"),{roomMigrationsStats:we}=require("./lib/core/contract/stats/local"),fe=require("./lib/bundle"),be=require("./lib/core/contract/index.js"),ve=ae("@local/keet-state"),ke=2592e6,Pe=v.alloc(32),Ke=require("./lib/env"),{ActiveCall:_e,KeetCallProxy:Ce}=require("./lib/core/call");class Re{constructor(e,t){this.keet=e,this.roomId=t,this.batch=null,this.length=0,this.timestamp=0,this.pushLength=0}get key(){return this.room.engine.local.key}_open(){this.room=this.keet.internalOpenExistingRoom(this.roomId),this.batch=this.room.engine.batch(),this.timestamp=Date.now()}_noop(){return this.close(),this.length}async dispatch(e,t,{dryRun:i=!0}={}){this.room||this._open(),this.room.opened||await this.room.ready();const s=be.encodeOperation(e,{header:{timestamp:this.timestamp},...t});return i&&!await this.keet.internalDryRun(this.room,this.room.view,[s])?this._noop():(this.length=await this.append(s),!this.pushLength&&Ie(e)&&(this.pushLength=this.length),this.length)}async append(e){return this.batch.append(e)}async flush(){try{return await this.batch.flush(),await this.room._postAppend({encoded:this.batch.blocks,pushLength:this.pushLength,timestamp:this.timestamp}),await this.keet.roomProcessor.process(this.room),{key:this.key,length:this.length}}finally{this.close()}}close(){this.room&&this.keet.internalReleaseRoom(this.room),this.batch&&this.batch.close(),this.batch=null,this.length=0,this.shouldPush=!1}}class Te extends o{constructor(e,t,i,o,r,a){super(),this.keet=e,this.id=t,this.key=i,this.engine=a,this.externalBlobs=null,this.discoveryKey=o,this.discoveryId=s.encode(this.discoveryKey),this.view=this.engine.view,this.db=this.view.db,this.core=this.view.core,this.router=this.view.router,this.priority=r,this.push=null,this.keet.push&&(this.push=this.keet.push.room(this.key,this.discoveryKey)),this.refs=0,this.idleTicks=0,this._pushLock=new y({debounce:!0}),this.ready().catch(Se)}static create(e,t,i,s,o,r={}){const a=new U(e,t,s,r),{priority:n=1}=r;let l=null;return a.auto.on("interrupt",t=>{e.logger.warn("room=",a.auto.id,"got interrupted"),e.emit("room-interrupted",i,t)}),a.auto.on("warning",t=>{e.logger.warn("[autobee warning] room=",a.auto.id,"error=",t),e.onerror(t,{roomKey:s,prefix:"AUTOBEE_WARNING"})}),a.auto.on("error",t=>{e.logger.warn("[autobee error] room=",a.auto.id,"error=",t),e.onerror(t,{roomKey:s,prefix:"AUTOBEE_ERROR"}),t.code===me.ROOM_DISABLED&&null!==l&&(e.internalCloseRoom(l),l.close().catch(e.onerror))}),l=new Te(e,i,s,o,n,a),l}get deviceId(){return s.encode(this.deviceKey)}get deviceKey(){return this.engine.local.key}get encryptionKey(){return this.engine.encryptionKey}get blobs(){return this.engine.blobs}getQuickStats(){return{view:this.engine.viewStats,system:this.engine.systemStats,base:this.engine.stats,writer:this.engine.writerStats}}async getStats(){const[e,t,i]=await Promise.all([this.keet.local.get("@local/rooms",{roomKey:this.key}),this.keet.local.get("@local/room-preferences",{roomKey:this.key}),this.keet.local.get("@local/writers-by-room-key",{roomKey:this.key})]),{view:o,system:r,base:a,writer:n}=this.getQuickStats();return{view:o,system:r,base:a,writer:{...n,key:i?.key?s.encode(i.key):null},status:e?.status,preferences:t?.status}}async _createDeviceAttestation(e,t){const i=await this.keet.internalEnterLocalTransaction();try{const s=this.keet.internalAttestData(e,t);return await i.insert("@local/device-attestations",{deviceKey:e,proof:s,createdAt:Date.now()}),await i.flush(),s}finally{await this.keet.internalExitLocalTransaction()}}async _attestedPushNotify(e){const t=this.deviceKey,[i,s]=await Promise.all([this.keet.local.get("@local/identity"),this.keet.local.get("@local/device-attestations",{deviceKey:t})]),o=s?.createdAt||0,r=i.proofShortenedAt||0,a=!s||o<r?await this._createDeviceAttestation(t,i):s.proof;if(this.push&&this.keet.gatekeeperKeys?.length)return void await this.push.send(this.engine.local,e,{version:1,attest:a});const n=this.engine.wakeupCapability&&this.engine.wakeupCapability.key;if(!n)throw new Error("Wakeup capability key must be defined when sending a notification");for(const t of e)await this.keet.blindPeering.sendNotification(this.engine.local,{roomKey:this.engine.key,index:t-1,extra:a,target:n})}async _safePushNotify(e){if(this._pushLengths||(this._pushLengths=[]),this._pushLengths.push(e),!await this._pushLock.lock())return;const t=this._pushLengths;if(this._pushLengths=null,!this.closing&&t){try{await this._attestedPushNotify(t)}catch(e){this.keet.onerror(e,{roomKey:this.key})}this._pushLock.unlock()}else this._pushLock.unlock()}async _safeBumpDiscovery(e){await new Promise(e=>setTimeout(e,100));try{if(this.keet.closing)return;const t=await this.keet.local.get("@local/rooms",{roomKey:this.key});if(!t)return;this.keet.discovery.announce(t.capabilities.discoveryKeyPair,{bump:e})}catch(e){this.keet.onerror(e,{roomKey:this.key})}}async _open(){await this.engine.auto.ready();const e=this.keet.internalIsRoomDisabled(this.key);e||this.internalEnsureMirroring(),await this.engine.ready(),this.engine.auto.on("writer",async e=>{try{if(await this.keet.local.get("@local/devices",{device:{key:e.core.key}}))return;const t=await this.db.get("@keet/devices",{key:e.core.key});t&&await this.db.get("@keet/members",{key:t.memberKey})}catch(e){g(e)}}),this.engine.local.on("remote-contiguous-length",this._handleSentLengthChanged.bind(this)),this.engine.on("rotate-local-writer",()=>{this.engine.local.on("remote-contiguous-length",this._handleSentLengthChanged.bind(this))}),this.db.get("@keet/room-config").then(e=>{this.keet.logger.debug("opened id: "+this.id+" title: "+e?.title)},g),this.externalBlobs=new d(this.keet.store.get({name:this.id+"/blobs",encryptionKey:this.encryptionKey,encrypted:!0,exclusive:!0,active:!1})),await this.externalBlobs.ready(),await this._ensureMetadata(),e||(this.internalEnsureProfileUpdated(),this.internalEnsureUpgraded(),this.internalEnsureAutobeeMigrationShared(),this.internalEnsureRepaired())}async internalCloseAutobee(){this.keet.internalTime(`internal-close-autobee-${this.id}`),await this.engine.close(),this.keet.internalTimeEnd(`internal-close-autobee-${this.id}`)}async internalCloseExternalBlobs(){this.keet.internalTime(`internal-close-blobs-${this.id}`),await this.externalBlobs.close(),this.keet.internalTimeEnd(`internal-close-blobs-${this.id}`)}async internalPushDestroy(){this.push&&(this.keet.internalTime(`internal-close-push-${this.id}`),await this.push.destroy(),this.keet.internalTimeEnd(`internal-close-push-${this.id}`))}_close(){return Promise.all([this.internalCloseAutobee(),this.internalCloseExternalBlobs(),this.internalPushDestroy()])}_handleSentLengthChanged(){if(!this.engine.writable)return;const{length:e,remoteContiguousLength:t}=this.engine.local;e===t&&this.keet.emit("room-sent-message",this.engine.id)}async _ensureMetadata(){const e=await this.keet.internalEnterLocalTransaction();try{const[t,i]=await Promise.all([e.get("@local/room-metadata",{roomKey:this.key}),e.get("@local/rooms",{roomKey:this.key})]);if(t)return;const s=i?0:1;await e.insert("@local/room-metadata",{roomKey:this.key,repairs:s}),await e.flush()}finally{await this.keet.internalExitLocalTransaction()}}async internalEnsureMirroring(){this.refs++;try{const e=this.engine.wakeupCapability||await this.keet.internalGetMailbox(this.key),t=e&&e.key;if(!t)return;const i=await this.keet._getMirrorKeys(this.key);if(this.closing)return;this.keet.blindPeering.addAutobaseBackground(this.engine.auto,{target:t,keys:i,priority:this.priority});try{await this.engine.ready()}catch{return}if(this.closing)return;for(const e of this.engine.migratedViews)this.keet.blindPeering.addCoreBackground(e,{target:t,keys:i,priority:this.priority})}finally{this.refs--}}async internalIsMirroringView(){const e=this.engine.viewCore;if(!e||e.remoteContiguousLength===e.length)return!1;const t=await this.keet.local.get("@local/rooms",{roomKey:this.key});return!!t?.selfMember?.status.isAdmin&&(await this.keet._getMirrorKeys(this.key,t)).length>0}async internalEnsureUpgraded({opening:e=!1}={}){this.refs++;try{e||this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready();const[t,i]=await Promise.all([this.db.get("@keet/system-digest"),z(this.db,this.deviceKey)]);if(!i?.status.isModerator||t?.abi.version>=this.keet.abi.autoupgrade)return;await this.keet.internalDispatchUpgrade(this.id,this.keet.abi.autoupgrade)}catch(e){this.keet.onerror(e,{roomKey:this.key})}finally{this.refs--}}async internalEnsureProfileUpdated(){this.refs++;try{this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready();const[e,t]=await Promise.all([this.keet.local.get("@local/identity"),z(this.db,this.deviceKey)]);if(this.closing||!e||!t||v.equals(this.key,e.privateProfileKey))return;const i=await this.keet.local.get("@local/rooms",{roomKey:e.privateProfileKey});if(this.closing)return;if(t.profile.timestamp>=i.selfMember.profile.timestamp)return;const s={profile:i.selfMember.profile,attestation:{memberKey:i.selfMember.key,proof:i.selfMember.proofs.profileAttestation}};await this.dispatch("@keet/update-member",{member:s})}catch(e){this.keet.onerror(e,{roomKey:this.key})}finally{this.refs--}}async internalEnsureAutobeeMigrationShared(){this.refs++;try{if(this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready(),this.closing)return;const e=this.key,t=await this.keet.local.get("@local/rooms",{roomKey:e});if(!t||!t.status.isWritable)return;if(!t.selfMember||!t.selfMember.status.isAdmin)return;const i=await this.db.get("@keet/autobee-migration");if(this.closing||i)return;const s=await this.keet.local.get("@local/autobee-migrations",{roomKey:e});if(!s)return;const o={head:s.autobeeMigrationHead};s.legacyViewHead&&(o.legacyViewHead=s.legacyViewHead),s.dbViewHead&&(o.dbViewHead=s.dbViewHead),s.blobsViewHead&&(o.blobsViewHead=s.blobsViewHead),await this.dispatch("@keet/autobee-migration",o)}catch(e){this.keet.onerror(e,{roomKey:this.key})}finally{this.refs--}}async internalGetBootFrom(){const[e,t]=await Promise.all([this.keet.local.get("@local/autobee-migrations",{roomKey:this.key}),this.db.get("@keet-private-id/identity")]);if(e&&!await this.db.get("@keet/autobee-migration")){const t=e.autobeeMigrationHead;return t?{key:t.key,length:0}:null}const i=this.engine.auto.local;return t?{key:i.key,length:i.length+1}:this.engine.getMostRecentAdmin()}async internalEnsureRepaired(){this.refs++;try{if(this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready(),this.closing||this.keet.closing)return;if(this===this.keet.privateProfile)return;const e=await this.keet.local.get("@local/room-metadata",{roomKey:this.key});if(this.closing||this.keet.closing||e.repairs>=1)return;if(!this.engine.shouldRepair())return;const t=await this.db.get("@keet-private-id/identity");if(this.closing||this.keet.closing||t)return;if(e.repairs=1,await this.engine.repair(),this.closing||this.keet.closing)return;const i=await this.keet.internalEnterLocalTransaction();try{await i.insert("@local/room-metadata",e),await i.flush()}finally{await this.keet.internalExitLocalTransaction()}}finally{this.refs--}}_encodeBatch(e){const t=Array.isArray(e)?e:[e],i=Date.now(),s=[];let o=!1;for(const{type:e,op:r}of t)s.push(be.encodeOperation(e,{header:{timestamp:i},...r})),Ie(e)&&(o=!0);return{encoded:s,timestamp:i,shouldPush:o}}async _postAppend({encoded:e=[],pushLength:t=0,timestamp:i=Date.now()}){this.keet.stats.ops+=e.length,(this.push||this.keet.blindPeering?.keys.length)&&t>0&&this._safePushNotify(t),this.keet.discovery&&this._safeBumpDiscovery(i),this.db.update()}async dispatchBatch(e,{view:t=this.view,dryRun:i=!0,optimistic:s=!1}={}){this.opened||await this.ready();const{encoded:o,timestamp:r,shouldPush:a}=await this._encodeBatch(e,{view:t});if(i&&!await this.keet.internalDryRun(this,t,o))return null;await this.engine.append(o,{optimistic:s});const n=this.engine.local.length,l=a?n:0;return await this._postAppend({encoded:o,pushLength:l,timestamp:r}),await this.keet.roomProcessor.process(this),{key:this.engine.local.key,length:n}}dispatch(e,t,i){return this.dispatchBatch([{type:e,op:t}],i)}}function Le(t,i,s){const o=e.attestDevice(s,t.deviceKeyPair,t.deviceProof),r=e.attestData(i,t.deviceKeyPair,t.deviceProof);return{privateProfileIdentity:{memberKey:t.publicKey,proof:r},deviceProof:o}}function Ee(e){return e.map(({mediaStreamId:e,type:t,muted:i})=>({streamKey:f.randomBytes(32),mediaStreamId:e,type:t,muted:i}))}function Ie(e){return"@keet/add-chat-message"===e||"@keet/start-call"===e||"@keet/join-call"===e||"@keet/leave-call"===e||"@keet/end-call"===e}function Se(){}module.exports=class extends o{constructor(e,t={}){if(super(),this.dir=e,this.opts=t,this.isMobile=!!t.mobile,this.isTesting=!!t.testing,this.appVersion=t.appVersion?ge.parse(t.appVersion):null,this.forceBuildType=!!t.forceBuildType,!t.buildType)throw pe.INVALID_BUILD_TYPE();this.buildType=function(e){switch(e){case"nightly":return ce.Nightly;case"internal":return ce.Internal;case"production":return ce.Production;default:throw pe.INVALID_BUILD_TYPE()}}(t.buildType),this.logger=new te(t.logger),this.isTesting&&this.logger.mute(),this.callHeartbeatOpts=t.callHeartbeat||{},this.callProxy=new Ce;const o=Ke(t.buildType);this.isNightly=this.buildType===ce.Nightly,this.isExperimental=this.isTesting?t.experimental??this.isNightly:this.isNightly,this.offlineBoot=new r,this.onlineBoot=new r,this.debug={},this.versions=S,this.abi=t.testingABI||{max:this.isExperimental?S.EXPERIMENTAL:S.STABLE,autoupgrade:this.isExperimental?S.EXPERIMENTAL:S.AUTOUPGRADE,production:S.STABLE},this.abi.min=S.MIN_AUTOBEE_ABI,this.logout=t.logout,this.storage=new i(e,t.storage),this.rootCorestore=new c(this.storage,{globalCache:new u({maxSize:t.maxCacheSize}),manifestVersion:2}),this.store=this.rootCorestore.namespace("keet-core"),this.rootCorestore.watch(this._handleCoreOpen.bind(this)),this.local=O.rocks(this.storage.rocks.columnFamily("keet/local-database")),this.discovery=null,this.gatekeepers=t.gatekeepers||[],this.push=null,this.protomuxWakeup=new p(this._handleWakeup.bind(this)),this.backoff=new w,this.rooms=new Map,this.activeRooms=new Set,this._transactionLock=new y,this._tx=null,this.hyperconf=null,this.config=null,this.configMinVersion=null,this.configDesktopMinVersion=null,this.errorManager=new ue(this,this.opts),this.swarmWorker=new N(this,this.opts.swarmWorker),this.files=new V(this,this.opts),this._onerror=t.onerror||g,this.onerror=this._handleError.bind(this),this.apiV1=new A(this,t),this.backendAPI=this.apiV1,this.api=this.backendAPI.api.core,this.blindPeeringOpts=t.blindPeeringOpts||{},this.contractBundles=null,this.roomProcessor=null,this.tasks=null,this.swarm=null,this.swarmId=null,this.blindPeering=null,this.privateProfile=null,this.unreads=null,this.unreadsLoading=null,this.userRegistry=null,this.roomRegistry=null,this.discoveryCore=null,this.discoveryCoreSession=null,this.push=null,this.state=ve.RESUME,this._bundlesKey=t.bundlesKey||o.bundles.key,this._bundlesLength=t.bundlesLength||o.bundles.length,this._hyperconfKey=t.hyperconfKey||o.config.key,this._hyperconfLength=t.hyperconfLength||o.config.length,this._roomRegistryOpts=t.roomRegistry||o.roomRegistry,this._disabledRooms=this.isTesting?new Set((t.disabledRooms||[]).map(e=>s.normalize(e))):null,this._verifiedRooms=this.isTesting?new Set:null,this._relayKeys=this.isTesting?t.blindRelays||[]:null,this._blindPeerKeys=this.isTesting?t.blindMirroring||[]:null,this._gatekeeperKeys=this.isTesting?t.gatekeepers||[]:null,this._discoveryBootstrapKeys=this.isTesting?t.discoveryBootstrapKeys||[]:null,this._disableUnreadSync=this.isTesting&&t.disableUnreadSync||!1,this._otaResyncPrivateProfileBump=this.isTesting&&t.otaResyncPrivateProfileBump||0,this._migratedFrom=0,this._unreadsLock=new y({debounce:!0}),this._dhtOpts=t.dht,this._swarmOpts=t.swarm,this._pendingTasks=[],this._swarmTasks=[],this._runningTasks=new Set,this._waitingForCompletion=new Map,this._completedRequests=new Set,this._pendingCandidates=new Map,this._swarming=new Map,this._pendingTraces=[],this._cacheLock=new y({debounce:!0}),this._gcEnabled=!1!==t.gc,this._gcIdleTicks=t.gcIdleTicks||4,this._gcInterval=t.gcInterval||5e3,this._gcTimer=null,this._gcClosingRooms=new Set,this._boundAutobeeTrace=this._autobeeTrace.bind(this),this.internalPairingTimeout=t.pairingTimeout||3e3,this._profileDiscoveryTimeout=t.profileDiscoveryTimeout||1e4,this.migrationStatus=null,this._roomMigrations=new m(5),this._discoveryLock=new y({debounce:!0}),this._discoverySemaphore=new m(10),this._discovering=new Map,this.internalFastJoinSemaphore=new m(4),this.debugRunningFastJoins=0,this.debugMaxRunningFastJoins=0,this._rejectAnonymousProfiles=!1!==t.rejectAnonymousProfiles,this._registryOpts=this.isTesting?t.userRegistry:null,this.rpcClient=null,this.ackThreshold=t.ackThreshold,this.ackInterval=t.ackInterval,this.stats={ops:0,appends:0,bytesAppended:0,uploaded:0,bytesUploaded:0,downloaded:0,bytesDownloaded:0},this.debugForceMigrationFailure=t.debugForceMigrationFailure||null,this.debugJoinPeer=t.debugJoinPeer||this._debugJoinPeer.bind(this),this.debugLeavePeer=t.debugLeavePeer||this._debugLeavePeer.bind(this),this.debugDisableCacheBump=!1,this.debugClosing=!1,this.debugFailRoomSync=t.debugFailRoomSync||null,this.debugFailNextRoomSync=t.debugFailNextRoomSync||null,this.ready().catch(this.onerror)}async backendReady(){this.backendAPI.opened||await this.backendAPI.ready()}get readOnly(){return this.rootCorestore.storage.readOnly||!1}get suspended(){return this.state===ve.SUSPEND}get gatekeeperKeys(){return this._gatekeeperKeys}async _openNetworking(){const e=await this.getDHTSettings(),t=await this.getSwarmSettings();this.swarm=new a({deferRandomPunch:!0,dht:new l({...e,...this._swarmOpts,...this._dhtOpts}),maxPeers:t.maxPeers,...this._swarmOpts,relayThrough:this._relayThrough.bind(this),keyPair:await this.rootCorestore.createKeyPair("keet-swarm-keypair")}),this.swarmId=s.encode(this.swarm.keyPair.publicKey),this.swarm.on("connection",this._handleConnection.bind(this)),this.callSwarmKeyPair=await this.rootCorestore.createKeyPair("keet-call-swarm-keypair"),this.activeCall=null,this.discovery=this._discoveryBootstrapKeys.length?new I(this._discoveryBootstrapKeys[0],{dht:this.swarm.dht}):null,this.rpcClient=new ye(this.swarm.dht,{suspended:this.state===ve.SUSPEND,relayThrough:this._relayThrough.bind(this)}),this.blindPeering=new _(this.swarm.dht,this.store,{pick:2,wakeup:this.protomuxWakeup,keys:this.debug.disableMirrors?[]:this._blindPeerKeys,relayThrough:this._relayThrough.bind(this),...this.blindPeeringOpts}),this._gatekeeperKeys.length>0&&(this.push=new T(this._gatekeeperKeys,{dht:this.swarm.dht})),await this.swarmWorker.ready(),await this.files.ready(),this.readOnly&&(this.blindPeering.suspend(),this.swarm.suspend())}async _runBootOffline(){if(!this.offlineBoot.enter())return;await this._ensureDebugState(),await this.store.ready(),this.hyperconf=new R(ne,this.store.get(this._hyperconfKey),{minLength:this._hyperconfLength,production:this.buildType===ce.Production}),this.hyperconf.on("update",this._handleConfigUpdated.bind(this)),await this.hyperconf.ready(),await this._handleConfigUpdated(),this.config?.versions.autoupgrade>0&&(this.abi.autoupgrade=this.config.versions.autoupgrade);const e=await this.local.get("@local/environment"),t=!!e&&e.latestOfflineAbi<this.abi.production;this.contractBundles=new fe(this,"keet-bundles",{hydrate:t}),await this.contractBundles.ready(),t&&await this._bumpLocalAbiVersion(),this.roomProcessor=new q(this),await this.roomProcessor.ready(),await this._openNetworking(),this.tasks=new M(this),await this.tasks.ready(),this.roomProcessor.bump(),this._gcEnabled&&(this._gcTimer=setInterval(this._closeIdleRooms.bind(this),this._gcInterval)),this.offlineBoot.exit()}async _runBootOnline(){if(this.onlineBoot.enter()){await this.offlineBoot.ready(),this.discovery&&(this.discovery.on("announce",({publicKey:e})=>{this.scheduleDiscoverySwarming(e)}),this.discovery.on("connect",this._onDiscoveryConnect.bind(this)),this.discovery.connect()),this._refreshDiscoverySwarming(),this._migratedFrom=await this._ensureMigrated();try{await this._loadIdentity()}catch(e){this.onerror(e)}this._migratedFrom>0&&await this._maybeRunPostMigrations(this._migratedFrom),this._registryOpts&&(this.userRegistry=new he(this,this._registryOpts),await this.userRegistry.ready()),this._roomRegistryOpts&&(this.roomRegistry=new de(this,this._roomRegistryOpts),await this.roomRegistry.ready()),this.onlineBoot.exit()}}async _open(){!1!==await this._ensureBuildType()&&(this._runBootOffline().catch(this.onerror),this._runBootOnline().catch(this.onerror),await this.offlineBoot.ready())}async _close(){this.internalTime("keet-close"),this.internalVerboseLog("Closing keet core"),this._gcTimer&&clearInterval(this._gcTimer),this.backoff.destroy(),this.internalTimeLog("keet-close","destroyed backoff"),this.state===ve.SUSPEND&&await this.store.resume(),this.internalTimeLog("keet-close","resumed from suspend"),this.internalVerboseLog("Closing active calls"),await this.backendAPI.closeActiveCalls(),this.internalTimeLog("keet-close","closed active calls"),this.internalVerboseLog("Closing discovery cores"),this.discoveryCore&&await this.discoveryCore.close(),this.discoveryCoreSession&&this.discoveryCoreSession.destroy(),this.internalTimeLog("keet-close","closed discovery cores"),this.internalVerboseLog("Closing tasks"),this.tasks&&await this.tasks.close(),this.internalFastJoinSemaphore.destroy(),this.internalTimeLog("keet-close","stopped running tasks");for(const e of this._gcClosingRooms)this.internalTime(`gc-room-close-${e.id}`),this.internalTimeLog(`gc-room-close-${e.id}`),this.internalVerboseLog("Closing room in gc list",e.id,e.opened),await e.close(),this.internalTimeEnd(`gc-room-close-${e.id}`,"closed");this.internalTimeLog("keet-close","closed rooms in gc"),this.internalVerboseLog("Closing user registry"),this.userRegistry&&await this.userRegistry.close(),this.internalTimeLog("keet-close","closed user registry"),this.internalVerboseLog("Closing room registry"),this.roomRegistry&&await this.roomRegistry.close(),this.internalTimeLog("keet-close","closed room registry"),this.internalVerboseLog("Closing rpc client"),this.rpcClient&&await this.rpcClient.close(),this.internalTimeLog("keet-close","closed rpc client"),this.internalVerboseLog("Closing swarm worker"),await this.swarmWorker.close(),this.internalTimeLog("keet-close","closed swarm worker"),this.internalVerboseLog("Closing discovery"),this.discovery&&await this.discovery.close(),this.internalTimeLog("keet-close","closed discovery"),this.internalVerboseLog("Closing push"),this.push&&await this.push.destroy(),this.internalTimeLog("keet-close","closed push"),this.internalVerboseLog("Closing blind peering"),this.blindPeering&&await this.blindPeering.close(),this.internalTimeLog("keet-close","closed blind peering"),this.internalVerboseLog("Flushing DHT cache"),this.swarm&&await this._flushDHTCache(),this.internalTimeLog("keet-close","flushed dht"),this.internalVerboseLog("Closing active call"),this.activeCall&&await this.internalEndActiveCall(),this.internalTimeLog("keet-close","closed active call"),this.internalVerboseLog("Closing swarm"),this.swarm&&await this.swarm.destroy(),this.internalTimeLog("keet-close","destroyed swarm"),this.internalVerboseLog("Closing files"),await this.files.close(),this.internalTimeLog("keet-close","closed files"),this.internalVerboseLog("Closing all pending rooms and workers"),await Promise.allSettled([...[...this.rooms.values()].map(async e=>{this.internalTime(`pending-room-close-${e.id}`),this.internalTimeLog(`pending-room-close-${e.id}`),await e.close(),this.internalTimeEnd(`pending-room-close-${e.id}`)})]),this.internalTimeLog("keet-close","closed all pending rooms and workers"),this.internalVerboseLog("Closing room processor"),this.roomProcessor&&await this.roomProcessor.close(),this.internalTimeLog("keet-close","closed room processor"),this.internalVerboseLog("Closing backend"),await this.apiV1.close(),this.internalTimeLog("keet-close","closed backend"),await this.internalEnterLocalTransaction(),await this.internalExitLocalTransaction(),this.internalVerboseLog("Closing unread anchors"),this.unreadsLoading&&await this.unreadsLoading,this.unreads&&await this.unreads.close(),this.internalTimeLog("keet-close","closed unreads"),this.internalVerboseLog("Closing wakeup"),this.protomuxWakeup.destroy(),this.internalTimeLog("keet-close","protomux"),this.internalVerboseLog("Closing hyperconf"),this.hyperconf&&await this.hyperconf.close(),this.internalVerboseLog("Closing error manager"),this.errorManager&&await this.errorManager.close(),this.internalVerboseLog("Closing local db"),await this.local.close(),this.internalVerboseLog("Closing contract bundles"),this.contractBundles&&await this.contractBundles.close(),this.internalVerboseLog("Closing store"),await this.store.close(),this.internalVerboseLog("Closing root corestore"),await this.rootCorestore.close(),this.internalTimeLog("keet-close","closed cores"),this.internalVerboseLog("Close done"),this.internalTimeEnd("keet-close")}async _ensureDebugState(){const e=await this.internalEnterLocalTransaction();try{const t=await e.get("@local/debug")||{};t.flags||(t.flags=X);const i=new Set,s={};for(const e of t.flags)i.add(e.key),s[e.key]=e.value;for(const{key:e,value:s,description:o}of X)i.has(e)||t.flags.push({key:e,value:s,description:o});await e.insert("@local/debug",t),await e.flush(),this.debug={...s}}finally{await this.internalExitLocalTransaction()}}isValidBuildType(e){if(!e)return!0;if(this.isTesting&&!this.forceBuildType)return!0;const t=ce.Production===this.buildType;return!(!t&&!e.settings.buildType||!t&&e.settings.buildType!==this.buildType)}async _ensureBuildType(){if(this.isTesting&&!this.forceBuildType)return;const e=ce.Production===this.buildType,t=await this.internalEnterLocalTransaction();try{const[i,s]=await Promise.all([t.get("@local/identity"),t.get("@local/environment")]);if(!e&&i&&!s?.buildType)throw pe.INVALID_BUILD_TYPE();if(s&&s.buildType!==this.buildType)throw pe.INVALID_BUILD_TYPE();if(s)return;await t.insert("@local/environment",{buildType:this.buildType}),await t.flush()}catch(e){return this.onerror(e),!1}finally{await this.internalExitLocalTransaction()}}async _bumpLocalAbiVersion(){const e=await this.internalEnterLocalTransaction();try{const t=await e.get("@local/environment");t.latestOfflineAbi=this.abi.production,await e.insert("@local/environment",t),await e.flush()}finally{await this.internalExitLocalTransaction()}}async _onDiscoveryConnect(){const e=await this.local.find("@local/rooms-by-timestamp",{reverse:!0,limit:256}).toArray();this.discovery.cork();for(const t of e){const e=t.capabilities.discoveryKeyPair.publicKey,i=await this.local.get("@local/background-sync",{discoveryPublicKey:e}),s=Math.max(t.timestamps.latestSync,i?i.lastSynced:0);this.discovery.subscribe(t.capabilities.discoveryKeyPair.publicKey,{since:s})}this.discovery.uncork()}async internalEnterLocalTransaction(){return await this._transactionLock.lock(),this._tx=this.local.transaction(),this._tx}async internalExitLocalTransaction(){await this._tx.close(),this._transactionLock.unlock()}async _handleConfigUpdated(){if(!this.isTesting||this.opts.hyperconfKey){if(this.config=this.hyperconf.current,this.internalVerboseLog("OTA config updated, dkey:",s.encode(this.hyperconf.core.discoveryKey),"length:",this.hyperconf.core.length),this._blindPeerKeys=this.config.services.blindPeers,this._relayKeys=this.config.services.blindRelays,this._gatekeeperKeys=this.config.services.gatekeepers,this._discoveryBootstrapKeys=this.config.services.discovery,h.setRecoveryPeers&&h.setRecoveryPeers(this.config.services.blindPeers),this._disabledRooms=new Set(this.config.rooms.disabled.map(e=>s.encode(e))),this._verifiedRooms=new Set(this.config.rooms.verified?.map(e=>s.encode(e))),this._disableUnreadSync=!0===this.config.profile?.disableUnreadSync,this._otaResyncPrivateProfileBump=this.config.profile?.otaResyncPrivateProfileBump||0,this._maybeOtaResyncPrivateProfile().catch(this.onerror),this._maybeUpgradeOpenRooms().catch(this.onerror),this._closeDisabledRooms().catch(this.onerror),this.config.services.userRegistries?.length&&(this._registryOpts=this.config.services.userRegistries[0]),this.blindPeering&&this.blindPeering.setKeys(this._blindPeerKeys),this.config.versions.minVersion){const{major:e,minor:t,patch:i}=this.config.versions.minVersion;this.configMinVersion=new ge(e,t,i)}if(this.config.versions.desktopMinVersion){const{major:e,minor:t,patch:i}=this.config.versions.desktopMinVersion;this.configDesktopMinVersion=new ge(e,t,i)}this.config.versions.autoupgrade>0&&(this.abi.autoupgrade=this.config.versions.autoupgrade),this.emit("force-update"),this.emit("verified-rooms-changed")}}async _maybeUpgradeOpenRooms({debug:e=!1}={}){this.onlineBoot.opened||await this.onlineBoot.ready();const t=this.abi.autoupgrade,i=this.config?.versions.autoupgrade;if(!(t<i)&&!0!==e)return;const s=[],o=async function(e,t){try{await e.ready();const[i,s]=await Promise.all([e.db.get("@keet/system-digest"),z(e.db,e.deviceKey)]);if(!s?.status.isModerator||i?.abi.version>=t)return;await this.internalDispatchUpgrade(e.id,t)}catch(e){this.onerror(e)}}.bind(this);for(const[e,t]of this.rooms.entries())s.push(o(t,i));return await Promise.all(s)}async _maybeOtaResyncPrivateProfile(){this.onlineBoot.opened||await this.onlineBoot.ready();const e=this._otaResyncPrivateProfileBump||0,t=await this.internalEnterLocalTransaction();try{if(!(e>((await t.get("@local/ota-actions"))?.otaResyncPrivateProfileBump||0)))return;if(null===await this.internalResyncPrivateProfile())return;await t.insert("@local/ota-actions",{otaResyncPrivateProfileBump:e}),await t.flush()}catch(e){this.onerror(e)}finally{await this.internalExitLocalTransaction()}}shouldForceUpdate(){return this.config.versions.forceUpdate>S.FORCE_UPDATE||(this.isMobile?this._shouldForceUpdateMobile():this._shouldForceUpdateDesktop())}_shouldForceUpdateMobile(){return!(!this.configMinVersion||!this.appVersion)&&1===this.configMinVersion.compare(this.appVersion)}_shouldForceUpdateDesktop(){return!(!this.configDesktopMinVersion||!this.appVersion)&&1===this.configDesktopMinVersion.compare(this.appVersion)}isRoomVerified(e){return this._verifiedRooms.has(e)}internalIsRoomDisabled(e){return!!this._disabledRooms&&this._disabledRooms.has(s.encode(e))}async _bumpRoom(e){if(this.closing)return;if(!await this.local.get("@local/writers-by-room-key",{roomKey:e}))return;const t=await this.local.get("@local/rooms",{roomKey:e});if(!t||t.status.isRemoved)return;if(this.closing)return;const i=this.internalOpenExistingRoom(e);try{await i.ready()}finally{this.internalReleaseRoom(i)}}async _roomCoreReferrer(e){const t=e.state.storage.read(),i=[t.getUserData("referrer"),t.getUserData("autobase/view")];t.tryFlush();const[s,o]=await Promise.all(i);return s&&!o?s:null}async _tagLegacyCore(e){if(await e.ready(),e.core.header.group)return;if(e.writable)return;const t=await this._roomCoreReferrer(e.core);if(!t)return;const i=await this.internalGetMailbox(t);i&&(await e.setGroup(i.discoveryKey),await this._bumpRoom(t))}_handleCoreOpen(e){const t=new h({core:e,weak:!0}),i=new y({debounce:!0});this._tagLegacyCore(t).catch(this.onerror),t.on("verification-error",e=>{this.onerror(e,{coreKey:t.key,prefix:"CORE_VERIFICATION_ERROR"})}),t.on("conflict",()=>{this.onerror(new Error("Conflict in Hypercore"),{coreKey:t.key,prefix:"CORE_CONFLICT"})}),t.on("invalid-request",e=>{this.onerror(e,{coreKey:t.key,prefix:"CORE_INVALID_REQUEST"})}),t.on("append",async()=>{if(await i.lock())try{const t=await this._roomCoreReferrer(e);if(!t)return;await this._bumpRoom(t)}catch(e){this.onerror(e)}finally{i.unlock()}}),t.on("upload",(e,t)=>{this.stats.uploaded++,this.stats.bytesUploaded+=t}),t.on("download",(e,t)=>{this.stats.downloaded++,this.stats.bytesDownloaded+=t}),t.once("ready",()=>{if(t.writable){let e=t.length,i=t.byteLength;t.on("append",()=>{const s=t.length,o=t.byteLength;this.stats.appends+=s-e,this.stats.bytesAppended+=o-i,e=s,i=o})}})}async _handleWakeup(e){if(!this.discovery)try{const[t,i]=await Promise.all([this.local.get("@local/writers-by-wakeup-topic",{wakeupTopic:e}),this.local.get("@local/rooms-by-wakeup-topic",{capabilities:{wakeupTopic:e}})]);if(!t&&!i)return;const s=t?.mailbox||i?.capabilities.mailboxKeyPair.publicKey,o=this.protomuxWakeup.session(s,{active:!1,discoveryKey:e,onpeeractive:e=>{t&&o.announce(e,[{key:t.key,length:1}])}});i&&await this._bumpRoom(i.roomKey)}catch(e){this.onerror(e)}}async _maybeRunMigrations(e,t){3===t&&await require("./lib/core/migrations/3")(this,e),4===t&&await require("./lib/core/migrations/4")(this,e),5===t&&await require("./lib/core/migrations/4")(this,e),t<8&&await require("./lib/core/migrations/7")(e),t<9&&await require("./lib/core/migrations/8")(e)}async _maybeRunPostMigrations(e){4===e&&await require("./lib/core/migrations/4/post")(this),5===e&&await require("./lib/core/migrations/4/post")(this)}async _ensureMigrated(){let e=0;const t=await this.internalEnterLocalTransaction();try{const i=await t.get("@local/migrations"),s=i?i.version:3;s<9&&(e=s,await this._maybeRunMigrations(t,s),await t.insert("@local/migrations",{version:9})),await t.flush()}finally{await this.internalExitLocalTransaction()}const i=await this.local.find("@local/room-migrations-by-priority").toArray(),o=[],r=[],a=[];for(const e of i)this._disabledRooms.has(s.encode(e.roomKey))?a.push(e):e.v3?.privateProfile?o.push(e):r.push(e);if(a.length>0){const e=await this.internalEnterLocalTransaction();try{for(const t of a){const i=await e.get("@local/room-migrations",{roomKey:t.roomKey});await e.delete("@local/room-migrations",t),await we(e,null,i)}await e.flush()}finally{await this.internalExitLocalTransaction()}}await Promise.all(o.map(e=>this._migrateRoom(e,{migratingRooms:r})));for(const e of r)this._migrateRoom(e).catch(this.onerror);return e}async _migrateRoom(e,{migratingRooms:t}={}){await this._roomMigrations.wait();try{const i=e.errored;if(i||(this.migrationStatus||(this.migrationStatus={remaining:0}),this.migrationStatus.remaining++,this.emit("migration-status",this.migrationStatus)),!e.timestamp){const t=await this.internalEnterLocalTransaction();try{e.timestamp=Date.now();const i=await t.get("@local/room-migrations",e);await t.insert("@local/room-migrations",e),await we(t,e,i),await t.flush()}finally{await this.internalExitLocalTransaction()}}const s=Date.now()-e.timestamp>1728e5;let o=!1,r=!1;try{e.v3&&!s&&await require("./lib/core/migrations/3/room")(this,e.roomKey,e.v3,{migratingRooms:t})}catch(e){this.onerror(e),r=!0,o=!!this.closing}const a=await this.internalEnterLocalTransaction();try{const t=await a.get("@local/room-migrations",e);r?(i||(e.errored=!o),await a.insert("@local/room-migrations",e),await we(a,e,t)):(await a.delete("@local/room-migrations",e),await we(a,null,t)),await a.flush()}finally{await this.internalExitLocalTransaction()}i||(this.migrationStatus.remaining--,this.emit("migration-status",this.migrationStatus))}finally{this._roomMigrations.signal()}}async _closeIdleRooms(){const e=[],t=[];for(const i of this.rooms.values())i.refs>0||(i.engine.busy?i.idleTicks=0:this.activeRooms.has(i)||++i.idleTicks<this._gcIdleTicks||i.refs>0||this.rooms.get(i.id)!==i||(this.rooms.delete(i.id),this._gcClosingRooms.add(i),e.push(i.close()),t.push(i)));const i=await Promise.allSettled(e);for(let e=0;e<i.length;e++)"rejected"===i[e].status&&this.onerror(i[e].reason,{roomKey:t[e].key,prefix:"ROOM_GC_CLOSE"});for(const e of t)this._gcClosingRooms.delete(e)}async _closeDisabledRooms(){for(const e of[...this.rooms.values()])this._disabledRooms.has(e.id)&&(this.internalCloseRoom(e),await e.close())}internalCloseRoom(e){this.rooms.delete(e.id),this._gcClosingRooms.add(e)}_debugJoinPeer(e){this.logger.info("Call join:",e)}_debugLeavePeer(e){this.logger.info("Call leave:",e)}async debugPauseCacheBump(){this.debugDisableCacheBump=!0,await this._cacheLock.flush()}debugResumeCacheBump(){this.debugDisableCacheBump=!1}debugPauseGC(){this._gcTimer&&(clearInterval(this._gcTimer),this._gcTimer=null)}debugResumeGC(){this._gcTimer||(this._gcTimer=setInterval(this._closeIdleRooms.bind(this),this._gcInterval))}debugMaybeUpgradeOpenRooms(e={}){return this._maybeUpgradeOpenRooms({debug:!0,...e})}async internalDiscoveryCompleted(e,t){try{const e=this._discovering.get(t);if(!e)return;const i=await this.internalEnterLocalTransaction();try{const t=e.roomInfo.capabilities.discoveryKeyPair.publicKey;e.room&&this.internalReleaseRoom(e.room);const s=await i.get("@local/background-sync",{discoveryPublicKey:t});s&&await i.insert("@local/background-sync",{...s,lastSynced:Date.now(),dirty:!1}),await i.flush()}finally{await this.internalExitLocalTransaction()}this._discovering.delete(t),this._discoverySemaphore.signal()}catch(e){this.onerror(e)}}async _startDiscoverySwarming(e,t){if(!await this._discoverySemaphore.wait())return!1;if(this.closing)return!1;const i=this._discovering.get(t);return!!i&&(this.swarmWorker.startDiscoverySwarming(e,{roomId:t}),i.updated&&this.swarmWorker.notifyDiscoveryUpdate(e),!0)}async _refreshDiscoverySwarming(){if(await this._discoveryLock.lock()&&!this.closing)try{const e=await this.internalEnterLocalTransaction();try{for await(const{discoveryPublicKey:t}of e.find("@local/background-sync-by-dirty",{reverse:!0})){const e=await this.local.get("@local/rooms-by-discovery",{capabilities:{discoveryKeyPair:{publicKey:t}}});if(!e||e.status.isRemoved)continue;const i=s.encode(e.discoveryKey);if(this._discovering.has(i))continue;const o=this.internalOpenExistingRoom(e.roomKey);this._discovering.set(i,{updated:!1,room:o,roomInfo:e}),this._startDiscoverySwarming(e.capabilities.swarmTopic,i)||this.internalReleaseRoom(o)}await e.flush()}finally{await this.internalExitLocalTransaction()}}catch(e){this.onerror(e)}finally{this._discoveryLock.unlock()}}async scheduleDiscoverySwarmingFromDiscoveryKey(e){const t=await this.local.get("@local/rooms-by-discovery-key",{discoveryKey:e});if(t)return this.scheduleDiscoverySwarming(t.capabilities.discoveryKeyPair.publicKey)}async scheduleDiscoverySwarming(e){const t=await this.internalEnterLocalTransaction();try{const i=await t.get("@local/background-sync",{discoveryPublicKey:e}),s=i?.lastSynced||0;await t.insert("@local/background-sync",{discoveryPublicKey:e,timestamp:Date.now(),lastSynced:s,dirty:!0}),await t.flush()}finally{await this.internalExitLocalTransaction()}this._refreshDiscoverySwarming()}async internalMarkRoomUpdated(e,t,i){const s=await this.internalEnterLocalTransaction();try{await s.insert("@local/room-updates",{roomKey:e,head:t,timestamp:Date.now(),incremental:i}),await s.flush()}finally{await this.internalExitLocalTransaction()}}async internalBlobsActiveInRoom(e){const t=s.encode(e),i=this.rooms.get(t);if(!i)return;const o=await this.local.get("@local/rooms",{roomKey:e});if(!o)return;const{capabilities:r}=o;if(!r||!r.mailboxKeyPair)return;try{await i.ready()}catch{return}if(!i.externalBlobs)return;const a=await this._getMirrorKeys(e,o);i.closing||this.blindPeering.addCoreBackground(i.externalBlobs.core,{target:r.mailboxKeyPair.publicKey,keys:a,pick:1})}async _getMirrorKeys(e,t){if(this.debug.disableMirrors)return[];if(!e)return this._blindPeerKeys;const i=t||await this.local.get("@local/rooms",{roomKey:e});return i&&i.config.blindPeers?.length?i.config.blindPeers:this._blindPeerKeys}_relayThrough(e){return e||this.swarm.dht.randomized?this._relayKeys:null}_callSwarmRelayThrough(e,t){return e||this.swarm.dht.randomized||t.dht.randomized?this._relayKeys:null}internalCreateCallSwarm(){return new n({...this._swarmOpts,keyPair:this.callSwarmKeyPair,dht:this.swarm.dht,relayThrough:this._callSwarmRelayThrough.bind(this)})}async internalStartCall(e,t){if(this.activeCall)throw pe.CALL_SWARM_ACTIVE("",{callId:this.activeCall.callId});const i=s.decode(e),o=await this.local.get("@local/rooms",{roomKey:i}),r=f.randomBytes(32),a=await this.dispatch(e,"@keet/start-call",{version:3,callKey:r,encryptionKey:o.encryptionKey,swarmKey:this.callSwarmKeyPair.publicKey,streamInputs:Ee(t)});if(!a)throw pe.CALL_DISPATCH_REJECTED("",{roomId:e,op:"@keet/start-call"});return await this.internalStartActiveCall(e,s.encode(r)),a}async internalJoinCall(e,t,i){if(this.activeCall)throw pe.CALL_SWARM_ACTIVE("",{callId:this.activeCall.callId});const o=s.decode(t),r=this.internalOpenExistingRoom(e);let a=null;try{r.opened||await r.ready(),a=await r.db.get("@keet/call-devices",{callKey:o,deviceKey:r.deviceKey})}finally{await this.internalReleaseRoom(r)}let n=null;if(!a&&(n=await this.dispatch(e,"@keet/join-call",{callKey:o,swarmKey:this.callSwarmKeyPair.publicKey,streamInputs:Ee(i)}),!n))throw pe.CALL_DISPATCH_REJECTED("",{roomId:e,callId:t,op:"@keet/join-call"});return await this.internalStartActiveCall(e,t),n}async internalLeaveCall(e,t){const i=await this.dispatch(e,"@keet/leave-call",{callKey:s.decode(t)});if(!i)throw pe.CALL_DISPATCH_REJECTED("",{roomId:e,callId:t,op:"@keet/leave-call"});return this.activeCall&&this.activeCall.callId===t&&await this.internalEndActiveCall(),i}async internalEndCall(e,t){const i=await this.dispatch(e,"@keet/end-call",{callKey:s.decode(t)});if(!i)throw pe.CALL_DISPATCH_REJECTED("",{roomId:e,callId:t,op:"@keet/end-call"});return this.activeCall&&this.activeCall.callId===t&&await this.internalEndActiveCall(),i}async internalStartActiveCall(e,t){if(this.activeCall)throw pe.CALL_SWARM_ACTIVE("",{callId:this.activeCall.callId});if(this.suspended)throw pe.CALL_SWARM_SUSPENDED("",{callId:t});const i=new _e(this,e,t);this.activeCall=i;try{await i.ready()}catch(e){throw this.activeCall=null,e}return i}internalEndActiveCall(){if(!this.activeCall)throw pe.CALL_NOT_ACTIVE();const e=this.activeCall;this.activeCall=null;const t=e.close();return t.catch(this.onerror),t}internalSyncActiveCall(e){if(this.activeCall&&this.activeCall.roomId===e)return this.activeCall.sync()}internalVerboseLog(...e){const t=new Date;this.logger.info(t,...e)}internalTime(...e){this.isTesting||console.time(...e)}internalTimeLog(...e){this.isTesting||console.timeLog(...e)}internalTimeEnd(...e){this.isTesting||console.timeEnd(...e)}_handleConnection(e){if(this.closing)return void e.on("error",()=>{});const t=s.encode(e.publicKey),i=s.encode(e.remotePublicKey),o=Date.now();let r=0;this.internalVerboseLog(`got ${e.isInitiator?"client":"server"} connection from ${t} to ${i}`);let a=null;e.once("error",e=>{a=e}),e.once("close",()=>{this.internalVerboseLog(`connection closed to ${i}, with err: ${a} (${Date.now()-o} ms ${r} bytes recv)`)}),e.on("data",e=>{r+=e.byteLength}),this.protomuxWakeup.addStream(e),this.rootCorestore.replicate(e)}async _createInitialIdentity(){const t=e.generateMnemonic(),i=this.tasks.restoreIdentity(Pe,{mnemonic:t,recover:!1});await i.run()}async _loadIdentity(){let e=await this.local.get("@local/identity");if(e||await this._createInitialIdentity(),e=await this.local.get("@local/identity"),this.privateProfile)return;const t=await this.local.get("@local/rooms",{roomKey:e.privateProfileKey});t&&this.swarmWorker.startActiveSwarming(t.capabilities.swarmTopic),this.privateProfile=await this.internalOpenPrivateProfile({opening:!0}),this._shortenDeviceAttestations().catch(this.onerror),await this.internalRefreshUnreads()}async internalResyncPrivateProfile(){if(!this.privateProfile)return null;const e=[];for await(const t of this.privateProfile.db.find("@keet-private-id/rooms"))await this.local.get("@local/rooms",{roomKey:t.roomKey})||e.push(t);for(const t of e)this.tasks.joinRoomKeys(t.mailbox,{keys:t,activeClock:t.activeClock,isReadOnly:t.status.isReadOnly}).runBackground()}async _shortenDeviceAttestations(){const e=await this.local.get("@local/identity");if(!e)return;const i=s.encode(e.privateProfileKey);if(!await this.internalFeatureSupported(i,D.SHORTEN_ATTESTATION))return;const o=this.privateProfile.engine.local.key,r=k.decode(t,e.deviceProof).chain.length;for await(const i of this.privateProfile.db.find("@keet-private-id/device-identities")){const s=v.equals(i.deviceKey,o),a=k.decode(t,i.deviceProof),n=a.chain.length,l=a.chain[n-1].publicKey;if(!s&&r+1<n){const t=Le(e,i.deviceKey,l);await this.privateProfile.dispatch("@keet-private-id/shorten-device-attestation",{deviceKey:i.deviceKey,deviceProof:t.deviceProof,writerProof:t.privateProfileIdentity.proof})}if(s&&k.decode(t,i.deviceProof).chain.length<r){const t=await this.internalEnterLocalTransaction();try{const s=await t.get("@local/identity");v.equals(s.publicKey,e.publicKey)&&(s.deviceProof=i.deviceProof,s.proofShortenedAt=Date.now(),await t.insert("@local/identity",s),await t.flush())}finally{await this.internalExitLocalTransaction()}}}}async internalDispatchUpgrade(e,t){if(!e||!t)return;const i=this.internalOpenExistingRoom(e);try{const e=this.batch(i.id);if(0===await e.dispatch("@keet/upgrade",{version:t}))return;if(t>=14){const s=await i.db.get("@keet/system-digest"),o="@keet/migrate-abi",r={header:{timestamp:e.timestamp},from:s?.abi.version,to:t,buildType:this.buildType},a=t<this.abi.min?this.abi.min:t,n=(await this.contractBundles.loadBundle(a)).encodeOperation(o,r);await e.append(n)}await e.flush()}finally{this.internalReleaseRoom(i)}}async _bumpCache(){if(!this.closing&&!0!==this.debugDisableCacheBump)try{if(!await this._cacheLock.lock())return;try{if(this.closing||!0===this.debugDisableCacheBump)return;await this._processCache()}finally{this._cacheLock.unlock()}}catch(e){this.onerror(e)}}async _processCache(){const e=[];for(;this._pendingTraces.length>0;){const t=this._pendingTraces.pop();e.push(this._updateCache(t))}const t=await Promise.all(e),i=await this.internalEnterLocalTransaction();try{for(const e of t)e&&await i.insert(e.collection,e.record);await i.flush()}finally{await this.internalExitLocalTransaction()}}async _updateCache({roomKey:e,collection:t,record:i}){if("@keet/members"===t){if(i?.profile.avatar){const t=this.internalOpenExistingRoom(e);try{await Y(t.db,t.blobs,i.profile.avatar)}catch{return null}finally{this.internalReleaseRoom(t)}}return{collection:"@local/members",record:i}}return"@keet/devices"===t?{collection:"@local/devices",record:{roomKey:e,device:i}}:null}_cacheRoomReads(e,t,i){this._pendingTraces.push({roomKey:e,collection:t,record:i}),this._bumpCache()}_maybeLogAutobeeApply(e,t,i,o,r){try{const a=s.encode(r),n=this.rooms.get(a),l=n?n.getQuickStats():null;this.logger.verboseDebug("[autobeeApply]",{"op.name":e.name,"op.id":e.id,dryRun:t,"nodes.length":i,abi:o,roomId:a,"roomStats.view":l?.view,"roomStats.system":l?.system,"roomStats.base":l?.base})}catch(e){console.error("Failed to log autobee apply",e)}}_autobeeTrace({type:e,value:t}){if("@keet/add-device"!==e)return;const{request:i,response:s,invitation:o}=t,r=o?.metadata.expiration;if(r>0&&r<Date.now())return;const a=i.member.profile.mailbox,n=i.keyPair;a&&n&&this._processAutobeeTrace(a,n,s).catch(this.onerror)}async _processAutobeeTrace(e,t,i){this.onlineBoot.opened||await this.onlineBoot.ready();const s=await this.local.get("@local/identity"),o=await this.local.get("@local/rooms",{roomKey:s.privateProfileKey});v.equals(e,o.capabilities.mailboxKeyPair.publicKey)||this.tasks.joinRoomResponse(t.publicKey,{mailbox:e,keyPair:t,response:i}).runBackground()}async _backgroundDrain(e){let t=await e.next();try{for(;!t.done&&!this.closing;){const i=await t.value;if(this.closing)return;t=await e.next(i)}}finally{!t.done&&e.return&&await e.return()}}async _safeLoadLegacyUnreads(){try{const e=[];for await(const t of this.local.find("@local/rooms")){const i=await this.local.get("@local/unreads",{roomKey:t.roomKey});i&&e.push(i)}return e}catch{return[]}}async*_migrateUnreadAnchors(){const e=yield this._safeLoadLegacyUnreads();try{const t=yield this.internalEnterLocalTransaction(),i=this.unreads.write(),s=Date.now();for(const{roomKey:o,count:r}of e)i.tryPut(o,{length:r+1,timestamp:s}),yield t.delete("@local/unreads",{roomKey:o});yield i.flush(),yield t.flush()}finally{yield this.internalExitLocalTransaction()}}async*_internalRefreshUnreads(){if(!this.privateProfile)return;let e=yield this.privateProfile.db.get("@keet/system-digest");if(e&&(yield this.privateProfile.internalEnsureUpgraded({opening:!0}),e=yield this.privateProfile.db.get("@keet/system-digest"),S.isFeatureSupported(e.abi.version,S.FEATURES.UNREADS)))try{if(!(yield this._unreadsLock.lock()))return;const t=[];let i=!0;const s=S.isFeatureSupported(e.abi.version,S.FEATURES.V2_UNREADS)?"@keet-private-id/unreads-v2":"@keet-private-id/unreads",o=yield this.privateProfile.db.find(s).toArray();for(const{deviceKey:e,key:s}of o)v.equals(e,this.privateProfile.engine.local.key)&&(i=!1),t.push(s);if(this.unreads&&function(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!v.equals(e[i],t[i]))return!1;return!0}(t,this.unreads.keys))return;this.unreads&&(yield this.unreads.close(),this.unreads=null);const r=this.privateProfile,a=r.engine.encryptionKey,n=this.store.namespace(r.key),l=n.namespace("keet-unreads");yield n.close();const c=yield r.engine.wakeupKey;this.unreads=new L(l,t,{blindPeering:this.blindPeering,encryptionKey:a,target:c}),this.unreads.on("remote-update",()=>this.emit("unread-anchors-changed")),yield this.unreads.ready(),i&&(yield this._backgroundDrain(this._migrateUnreadAnchors()),yield this.privateProfile.dispatch("@keet-private-id/add-unreads-key",{key:this.unreads.local.key}))}finally{this._unreadsLock.unlock()}}internalRefreshUnreads(){return this._disableUnreadSync?Promise.resolve():this._backgroundDrain(this._internalRefreshUnreads())}async internalLoadDiscoveryCore(){try{const e=await this.privateProfile.db.get("@keet-private-id/identity");if(!e||!e.discoveryCoreKey||this.closing)return;if(this.discoveryCore)return;this.discoveryCore=this.store.get({key:e.discoveryCoreKey}),await this.discoveryCore.ready(),this.blindPeering.addCoreBackground(this.discoveryCore,{pick:3,priority:2})}catch(e){this.onerror(e)}}async internalCreateDiscoveryCore(e){const t=e.getProfileDiscoveryEncryptionKey(),i={version:2,signers:[{publicKey:e.profileDiscoveryKeyPair.publicKey}]};return this.discoveryCore&&await this.discoveryCore.close(),this.discoveryCore=this.store.get({keyPair:e.profileDiscoveryKeyPair,valueEncoding:le,encryptionKey:t,manifest:i}),await this.discoveryCore.ready(),this.blindPeering.addCoreBackground(this.discoveryCore,{pick:3,priority:2}),this.discoveryCoreSession=this.swarm.join(this.discoveryCore.discoveryKey,{server:!1,client:!0}),!0}async internalDryRun(e,t,i){const s=i.map((t,i)=>({length:e.engine.local.length+1+i,from:e.engine.local,value:t,heads:[],version:0}));return!!await e.engine.dryRun(s,t)}internalGetHeads(e,t){const i=[];let s=!1;if(t)for(const o of t.engine.heads())e&&v.equals(o.key,e.key)?(s=!0,i.push({key:o.key,length:Math.max(o.length,e.length)})):i.push(o);return e&&!s&&i.push(e),i}async internalGetKeyPair(e){const t=await this.local.get("@local/writers-by-room-key",{roomKey:e});return t?t.pending?null:t.keyPair:null}async internalEnsureWriter(e,t,{rotate:i=!1,activeClock:s=0}={}){let o=null;if(!i){const i=await this.local.get("@local/writers",{mailbox:t});if(i&&i.roomKey&&v.equals(i.roomKey,e))return i;o=i}if(o)o.roomKey=e;else{const i=f.keyPair(),r=this.store.get({keyPair:i});await r.ready(),o={keyPair:i,key:r.key,mailbox:t,responseKeyPair:null,roomKey:e,pending:!0,activeClock:s},await r.close()}const r=await this.internalEnterLocalTransaction();try{await r.insert("@local/writers",o),await r.flush()}finally{await this.internalExitLocalTransaction()}return o}async internalGetMailbox(e){const t=await this.local.get("@local/rooms",{roomKey:e});if(t)return{key:t.capabilities.mailboxKeyPair.publicKey,discoveryKey:t.capabilities.wakeupTopic};const i=await this.local.get("@local/writers-by-room-key",{roomKey:e});return i?{key:i.mailbox,discoveryKey:$(i.mailbox)}:null}async internalGetEncryptionKey(e){const t=await this.local.get("@local/rooms",{roomKey:e});return!t||t.status.isRemoved?null:t.encryptionKey}getAutobeeMigrationInfo(e){return this.local.get("@local/autobee-migrations",{roomKey:e})}internalReleaseRoom(e){if(0===e.refs)throw new Error("Cannot release a room that was not previously opened");e.refs-=1}internalOpenExistingRoom(e,t={}){return this.internalOpenRoom(s.decode(e),null,t)}async internalOpenPrivateProfile({opening:e=!1}={}){e||this.onlineBoot.opened||await this.onlineBoot.ready();const t=await this.local.get("@local/identity"),i=this.internalOpenExistingRoom(t.privateProfileKey,{bigBatches:!0,priority:2});return await i.ready(),this.privateProfile&&v.equals(i.key,this.privateProfile.key)||(this.privateProfile&&this.internalReleaseRoom(this.privateProfile),this.privateProfile=this.internalOpenExistingRoom(t.privateProfileKey,{bigBatches:!0,priority:2}),this.unreadsLoading=this.internalRefreshUnreads().catch(()=>null)),this.internalLoadDiscoveryCore(),i}async internalSafeSwapPrivateProfiles(){try{const e=await this.internalOpenPrivateProfile();this.internalReleaseRoom(e)}catch(e){this.onerror(e)}}async internalFeatureSupported(e,t){const i=s.decode(e),o=await this.local.get("@local/rooms",{roomKey:i});return!!o&&this.versions.isFeatureSupported(o.digest.abi.version,t)}internalOpenRoom(e,t,{bootFrom:i,mailbox:o,keyPair:r,bigBatches:a,priority:n=1}={}){if(this.closing)throw new Error("Keet is closing");const l=s.encode(e),c=this.rooms.get(l);if(c)return c.idleTicks=0,c.refs+=1,c;const h=f.discoveryKey(e),d=this.store.namespace(h);let y=null,u=null,p=null;o||(u=this.internalGetMailbox(e),u.catch(this.onerror)),r||(y=this.internalGetKeyPair(e),y.catch(this.onerror)),t||(p=this.internalGetEncryptionKey(e),p.catch(this.onerror)),o&&(o={key:o,discoveryKey:f.discoveryKey(o)});const m={backoff:this.backoff,encryptionKey:t||p,wakeupCapability:o||u,keyPair:r||y,fastForward:!this.debug.disableFastForward&&{boot:i},ackThreshold:this.ackThreshold,ackInterval:this.ackInterval,wakeup:this.protomuxWakeup,optimistic:!0,encrypted:!0,bigBatches:!!a,priority:n},g=Te.create(this,d,l,e,h,m);return this.rooms.set(l,g),g.refs+=1,g}async updateDevice({name:e,deviceId:t}={}){this.onlineBoot.opened||await this.onlineBoot.ready();const i={swarmKey:this.swarm.keyPair.publicKey,name:e,isMobile:this.isMobile},o=await this.internalOpenPrivateProfile();try{if(t&&!v.equals(s.decode(t),o.deviceKey)){if(!await this.internalFeatureSupported(this.privateProfile.id,D.CROSS_DEVICE_RENAME))throw new Error("Renaming other devices not supported");if(!await o.dispatch("@keet/update-device",{key:s.decode(t),profile:{name:e}}))throw pe.UPDATE_DEVICE_FAILED("Failed to update device",{deviceId:t})}else await o.dispatch("@keet/update-device",{profile:i})}finally{this.internalReleaseRoom(o)}}async internalUpdateProfile(e,{forceUpdateRegistry:t=!1,opening:i=!1}={}){const s=await this.internalGetIdentityInfo({opening:i});if(this.closing)return;if(this._rejectAnonymousProfiles&&!e.displayName&&!t)throw new Error("A member must have a profile name");const o=this.internalCreateMemberUpdate(s,{profile:e}),r=await this.internalOpenPrivateProfile({opening:i});if(this.closing)return;let a=null;try{a=await r.dispatch("@keet/update-member",{member:o})}finally{this.internalReleaseRoom(r)}(a||t)&&o.profile.username&&this.userRegistry?.internalUpdateRegistryMember(o)}async updateProfile(e={}){return this.onlineBoot.opened||await this.onlineBoot.ready(),this.internalUpdateProfile(e)}async internalVerifyOptimisticCore(e){return!await e.getUserData("referrer")}async internalAppendOptimisticOperation(e,t){const i=this.store.get({key:e,exclusive:!0});await i.ready();try{if(!await this.internalVerifyOptimisticCore(i))return!1;if(0!==i.length)return!1;const{length:e}=await i.append(t,{maxLength:1});return 1===e}finally{await i.close()}}async internalCreateRoom(e={}){const t=e.seed||f.randomBytes(32),i=e.keyPair||f.keyPair(),s=e.encryptionKey||f.randomBytes(32),o=F(i.publicKey),r=f.discoveryKey(o),a=j(o,t),n=a.mailboxKeyPair.publicKey,l=await this.internalEnterLocalTransaction();try{await l.insert("@local/writers",{mailbox:n,keyPair:i,key:o,roomKey:o}),await l.flush()}finally{await this.internalExitLocalTransaction()}const c={header:{timestamp:Date.now()},digest:{abi:{version:this.isExperimental?this.abi.production:this.abi.autoupgrade},creationTime:Date.now(),settings:{roomType:1,...e.settings,isExperimental:this.isExperimental,buildType:this.buildType}},capabilities:{seed:t},config:e.config,identity:e.identity,initialMembers:e.initialMembers,bootstrapDevice:e.bootstrapDevice},h=this.tasks.createRoom(r,{roomKey:o,encryptionKey:s,mailbox:n,keyPair:i,genesis:c,isPrivateProfile:!!e.isPrivateProfile});return await h.run(),this.discovery&&this.discovery.subscribe(a.discoveryKeyPair.publicKey,{since:Date.now()}),this.swarmWorker.refresh().catch(Se),this.internalOpenExistingRoom(o)}async createRoom(e){this.opened||await this.ready();const t=await this.internalCreateRoom(e);return this.internalReleaseRoom(t),t.key}async leaveRoom(e){this.onlineBoot.opened||await this.onlineBoot.ready();const t=await this.local.get("@local/identity"),i=this.internalOpenExistingRoom(e);await i.ready();try{await i.dispatch("@keet/remove-member",{key:t.publicKey})}catch(e){this.onerror(e)}finally{this.internalReleaseRoom(i)}await this.privateProfile.dispatch("@keet-private-id/update-room-status",{roomKey:e,key:Q.IsActive,status:{isActive:!1}})}async activateRoom(e){if(this.closing)return;const t=await this.local.get("@local/rooms",{roomKey:e});if(!t||this.closing)return;const i=this.internalOpenExistingRoom(e);this.activeRooms.has(i)?this.internalReleaseRoom(i):(this.activeRooms.add(i),this.swarmWorker.startActiveSwarming(t.capabilities.swarmTopic),await i.ready())}async deactivateRoom(e){const t=this.internalOpenExistingRoom(e);if(!this.activeRooms.has(t))return void this.internalReleaseRoom(t);const i=await this.local.get("@local/rooms",{roomKey:e});this.activeRooms.delete(t),this.swarmWorker.stopActiveSwarming(i.capabilities.swarmTopic),this.internalReleaseRoom(t),this.internalReleaseRoom(t)}async internalGetIdentityInfo({opening:e=!1}={}){e||this.onlineBoot.opened||await this.onlineBoot.ready();const t=await this.local.get("@local/identity");if(!t)throw new Error("Identity does not exist");const i=await this.local.get("@local/rooms",{roomKey:t.privateProfileKey});if(!i)throw new Error("Private profile does not exist");return{identity:t,privateProfile:i}}internalGetMemberUpdate(e,{profile:t}={}){const i=e.privateProfile;return i?.selfMember?i.selfMember.proofs?{profile:i.selfMember.profile,attestation:{memberKey:i.selfMember.key,proof:i.selfMember.proofs.profileAttestation}}:this.internalCreateMemberUpdate(e):null}internalAttestData(t,i){return e.attestData(t,i.deviceKeyPair,i.deviceProof)}internalCreateDeviceUpdate(e,t,{isPrivateProfile:i=!1,buildType:s=null}={}){const o=e.identity;let r=null;e.privateProfile?.selfDevice&&i&&(r=e.privateProfile.selfDevice.profile.name);const a=e.privateProfile?.digest.settings.buildType,n=ce.Production===a;return{profile:{swarmKey:this.swarm.keyPair.publicKey,name:r,isMobile:this.isMobile,buildType:n&&null===s?null:a},attestation:{memberKey:o.publicKey,proof:this.internalAttestData(t,o)}}}internalCreateMemberUpdate(t,{profile:i}={}){const s=t.privateProfile?.selfMember?.profile||null,o=t.privateProfile?.capabilities.mailboxKeyPair.publicKey||i.mailbox,r=t.identity,a={...s,...i,mailbox:o,timestamp:Date.now()},n=oe("@keet/member-profile",a);return{profile:a,attestation:{memberKey:r.publicKey,proof:e.attestData(n,r.deviceKeyPair,r.deviceProof)}}}internalGetLinkInfo(e){try{return this.internalDecodeInvitation(e)}catch{}try{return this.internalDecodeContactInfo(e)}catch{}return null}internalDecodeInvitation(e){try{const t="string"==typeof e?b.decode(e):e;return re("@keet/sendable-invitation",t)}catch{throw pe.INVALID_INVITE(`Invalid invite: ${e}`)}}internalDecodeContactInfo(e){try{const t=v.isBuffer(e)?e:v.from(e,"base64");return re("@keet/member-contact-info",t)}catch{throw pe.INVALID_CONTACT_INFO(`Invalid contact info: ${e}`)}}internalEncodeContactInfo(e){return oe("@keet/member-contact-info",e)}internalCreateContactInfoStruct(t,i,s={}){const o={...i.selfMember.profile,...s},r=oe("@keet/member-profile",o),a={profile:o,attestation:{memberKey:i.selfMember.key,proof:e.attestData(r,t.deviceKeyPair,t.deviceProof)}};return this.internalEncodeContactInfo(a)}async wakeup(){this.state=ve.WAKEUP,this.internalVerboseLog("[Keet Core]","await .ready"),this.opened||await this.ready();const e=[this.resume(),this.swarmWorker.background()];this.internalVerboseLog("[Keet Core]","await all promise"),await Promise.allSettled(e),this.internalVerboseLog("[Keet Core]","promise settled")}async presuspend(){this.state=ve.PRESUSPEND;const e=Date.now();this.opened||await this.ready(),this.swarmWorker.setServerMode(!1),this.internalVerboseLog("[Keet Core]",`presuspend done elapsed=${Date.now()-e}ms`)}async suspend(){if(this.internalVerboseLog("[Keet Core]","suspend called"),this.state===ve.SUSPEND)return;this.state=ve.SUSPEND,this.opened||await this.ready(),this.internalVerboseLog("[Keet Core]","suspend post ready");const e=Date.now(),t=(t,i)=>i.finally(()=>{this.internalVerboseLog("[Keet Core]",`suspend settled ${t} elapsed=${Date.now()-e}ms`)}),i=[t("dhtCache",this._flushDHTCache())];this.blindPeering&&(this.internalVerboseLog("[Keet Core]","suspend adding blind peering"),i.push(t("blindPeering",this.blindPeering.suspend()))),this.push&&(this.internalVerboseLog("[Keet Core]","suspend push"),i.push(t("push",this.push.suspend()))),this.discovery&&(this.internalVerboseLog("[Keet Core]","suspend discovery"),i.push(t("discovery",this.discovery.suspend()))),await Promise.allSettled(i),this.internalVerboseLog("[Keet Core]","all done"),await this.rpcClient.suspend(),this.internalVerboseLog("[Keet Core]","rpc suspended"),this.activeCall&&await this.activeCall.suspend(),this.internalVerboseLog("[Keet Core]","active call suspend");const s=this.swarm.connections.size;this.internalVerboseLog("[Keet Core]",`suspending swarm connections=${s}`);const o=Date.now();await this.swarm.suspend(),this.internalVerboseLog("[Keet Core]","swarm suspend"),this.internalVerboseLog("[Keet Core]",`swarm suspended elapsed=${Date.now()-o}ms connections=${this.swarm.connections.size}`),await this.files.server.suspend(),this.internalVerboseLog("[Keet Core]","files suspend"),await this.store.suspend({log:this.internalVerboseLog.bind(this)}),this.internalVerboseLog("[Keet Core]","store suspended, all done")}async resume(){if(this.internalVerboseLog("[Keet Core]","resume called"),this.state===ve.RESUME)return;this.state=ve.RESUME,this.internalVerboseLog("[Keet Core]","await this.ready"),this.opened||await this.ready(),this.internalVerboseLog("[Keet Core]","resume store"),await this.store.resume(),this.internalVerboseLog("[Keet Core]","resume file server"),await this.files.server.resume(),this.internalVerboseLog("[Keet Core]","resume swarm"),this.readOnly||await this.swarm.resume(),this.internalVerboseLog("[Keet Core]","resume active call"),this.activeCall&&!this.readOnly&&await this.activeCall.resume(),this.internalVerboseLog("[Keet Core]","resume rpc client"),await this.rpcClient.resume();const e=[];this.blindPeering&&!this.readOnly&&e.push(this.blindPeering.resume()),this.push&&e.push(this.push.resume()),this.discovery&&e.push(this.discovery.resume()),this.swarmWorker.setServerMode(!0),e.push(this.swarmWorker.unbackground()),this.internalVerboseLog("[Keet Core]","await all promises"),await Promise.allSettled(e),this.internalVerboseLog("[Keet Core]","all promises settled")}async _createInvitation(e,t){let{expiration:i=0,canAdmin:s=!1,canModerate:o=!1,identityPublicKey:r=null,requiresConfirmation:a=!1,readOnly:n=!1}=t;if("string"==typeof i)if("2h"===i)i=Date.now()+72e5;else if("2d"===i)i=Date.now()+1728e5;else{if("2w"!==i)throw pe.UNKNOWN_EXPIRATION(`Unknown expiration: ${i}`,{roomKey:e.key});i=Date.now()+12096e5}await e.ready();const[{seed:l},c,h]=await Promise.all([e.db.get("@keet/room-capabilities"),z(e.db,e.deviceKey),e.db.get("@keet/system-digest")]);if((o||s)&&!c?.status.isModerator)throw pe.MODERATORS_ONLY("Only moderators can create moderator invitations",{roomKey:e.key});const d=j(e.key,l),y=this.swarm.dht.toArray({limit:3}),u=await e.internalGetBootFrom();if(n)return oe("@keet/sendable-invitation",{"readonly-v2":{roomKey:e.key,encryptionKey:e.encryptionKey,seed:l,bootFrom:u},additionalNodes:y});const p={key:e.key,encryptionKey:e.encryptionKey,bootFrom:u},{invitation:m,seed:g}=H(p,{requiresConfirmation:a,expiration:i,canModerate:o,canAdmin:s});await e.dispatch("@keet/add-invitation",{invitation:m});const w=(await e.db.get("@keet/invitations",{id:m.id})).anchor,f=d.mailboxKeyPair.publicKey,b={identity:null,room:null,contact:null,additionalNodes:y,buildType:h.settings.buildType};return r?b.identity={mailbox:f,invitationSeed:g,anchor:w,identityPublicKey:r}:b.room={mailbox:f,invitationSeed:g,anchor:w},oe("@keet/sendable-invitation",b)}async createRoomInvitation(e,t={}){this.opened||await this.ready();const i=s.decode(e),o=this.internalOpenExistingRoom(i);try{const e=await this._createInvitation(o,t);return b.encode(e)}finally{this.internalReleaseRoom(o)}}async createIdentityInvitation(){this.onlineBoot.opened||await this.onlineBoot.ready();const e=await this.local.get("@local/identity"),t=this.internalOpenExistingRoom(e.privateProfileKey);this.blindPeering.addAutobaseBackground(t.engine.auto,{priority:2});try{const i=await this._createInvitation(t,{expiration:"2h",canAdmin:!0,canModerate:!0,requiresConfirmation:!0,identityPublicKey:e.publicKey});return b.encode(i)}finally{this.internalReleaseRoom(t)}}async _startPairing(e,{deviceKeyPair:t,buildType:i=null}={}){this.onlineBoot.opened||await this.onlineBoot.ready();const o=W(e.invitationSeed),r=e.invitationSeed,a=e.mailbox,n=e.anchor,l={key:null,seedId:s.encode(r)},c=await this.local.get("@local/rooms-by-mailbox",{capabilities:{mailboxKeyPair:{publicKey:a}}});let h=null;if(c){if(c.selfMember?.status.isRemoved)throw new Error("Removed member cannot rejoin");h=await this.local.get("@local/room-preferences",{roomKey:c.roomKey})}if(c?.status.isWritable&&h&&h.status.isActive&&!h.status.isReadOnly)return l.key=s.encode(c.roomKey),l;const d=f.keyPair(),y=await this.store.createKeyPair(J(d.publicKey)),u=this.store.get({keyPair:y,active:!1});await u.ready();const p={key:u.key,length:1};await u.close();let m=null;t&&(m={writerKey:u.key,publicKey:e.identityPublicKey,devicePublicKey:t.publicKey});const g={id:o,mailbox:a,inviter:n,identity:m,initiator:p,responseKeyPair:d,invitationSeed:r,buildType:i},w=await this.privateProfile.db.find("@keet-private-id/pending-invitations").toArray();for(const e of w)v.equals(e.mailbox,g.mailbox)&&await this.privateProfile.dispatch("@keet-private-id/remove-pending-invitation",e);return await this.privateProfile.dispatch("@keet-private-id/add-pending-invitation",{invitation:g}),l}async _openReadOnlyRoom({roomKey:e,encryptionKey:t,seed:i,fastForwardTo:o,bootFrom:r}){this.onlineBoot.opened||await this.onlineBoot.ready();const{mailboxKeyPair:a,swarmTopic:n}=j(e,i);!r&&o&&(r={key:o,length:0}),await this.internalEnsureWriter(e,a.publicKey);const l=this.internalOpenRoom(e,t,{mailbox:a.publicKey,bootFrom:U.getBootOption(r,o)});return this.swarmWorker.startDiscoverySwarming(n,{roomId:s.encode(e)}),await l.ready(),await this.privateProfile.dispatch("@keet-private-id/add-room-v2",{roomKey:e,encryptionKey:t,mailbox:a.publicKey,bootFrom:r,isReadOnly:!0}),{key:s.encode(e),seedId:s.encode(i)}}async startPairingRoom(e,t){this.onlineBoot.opened||await this.onlineBoot.ready();const i=this.internalDecodeInvitation(e),s=await this.local.get("@local/rooms",{roomKey:this.privateProfile.key}),o=i.buildType,r=s.digest.settings.buildType||ce.Production;if(o&&o!==r)throw pe.INVALID_BUILD_TYPE();const a=i.readonly||i["readonly-v2"];if(a)return this._openReadOnlyRoom(a);if(!i.room)throw pe.INVALID_INVITATION_TYPE("Invalid room invitation");return this._startPairing(i.room,{...t,buildType:o})}async startPairingIdentity(e){this.onlineBoot.opened||await this.onlineBoot.ready();const t=this.internalDecodeInvitation(e),i=await this.local.get("@local/rooms",{roomKey:this.privateProfile.key}),s=t.buildType,o=i.digest.settings.buildType||ce.Production;if(s&&s!==o)throw pe.INVALID_BUILD_TYPE();if(!t.identity)throw pe.INVALID_INVITATION_TYPE("Invalid device sync invitation");const r=G(t.identity.identityPublicKey),a=await this.store.createKeyPair(r);return this._startPairing(t.identity,{deviceKeyPair:a,buildType:s})}async stopPairing(e){this.opened||await this.ready();const t=await this.internalOpenPrivateProfile();try{if(!await t.db.get("@keet-private-id/pending-invitations",{id:e}))return;await t.dispatch("@keet-private-id/remove-pending-invitation",{id:e})}finally{this.internalReleaseRoom(t)}}async rotateWriter(e){this.onlineBoot.opened||await this.onlineBoot.ready();const[t,i,s]=await Promise.all([this.local.get("@local/writers-by-room-key",{roomKey:e}),this.local.get("@local/rooms",{roomKey:e}),this.privateProfile.db.get("@keet-private-id/rooms",{roomKey:e})]);i&&t&&s&&(await this.internalEnsureWriter(e,s.mailbox,{rotate:!0,activeClock:s.activeClock}),this.tasks.joinRoomKeys(s.mailbox,{keys:s,activeClock:s.activeClock,isReadOnly:s.status.isReadOnly}).runBackground())}async getRecoveryPhrase(){this.onlineBoot.opened||await this.onlineBoot.ready();const e=(await this.local.get("@local/identity")).entropy;return e?E({entropy:e}):null}async getRecoveryEntropy(){return this.onlineBoot.opened||await this.onlineBoot.ready(),(await this.local.get("@local/identity")).entropy||null}async getEncryptedRecoveryPhrase(e){if("string"!=typeof e)throw new Error("Password required");if(0===e.length)throw new Error("Password should not be empty");const t=await this.getRecoveryEntropy();if(!t)throw new Error("Recovery phrase reading failed");if(0===t.length)throw new Error("Recovery phrase reading failed");return B.encryptEntropy(t,e)}decryptEncryptedRecoveryPhrase(e,t){if(!ArrayBuffer.isView(e))throw new Error("Encrypted phrase should be an ArrayBuffer view");if(0===e.byteLength)throw new Error("Encrypted phrase should not be empty");if("string"!=typeof t)throw new Error("Password required");if(0===t.length)throw new Error("Password should not be empty");const i=B.decryptEntropy(e,t),s=E({entropy:i});return B.free(i),s}freeRecoveryPhrase(e){B.free(e)}async storeRecoveryPhrase(t){this.onlineBoot.opened||await this.onlineBoot.ready();const i=await e.from({mnemonic:t}),s=await this.local.get("@local/identity"),o=await this.local.get("@local/rooms",{roomKey:s.privateProfileKey});if(!v.equals(s.publicKey,i.identityPublicKey))throw new Error("Wrong recovery phrase");if(!o.identity.discoveryCoreKey){if(await this.internalCreateDiscoveryCore(i),this.discoveryCore.length>0){const e=Math.floor((Date.now()-1711547109544)/1e3);await this.discoveryCore.truncate(this.discoveryCore.length,e)}await this.discoveryCore.append({version:1,timestamp:Date.now(),key:o.roomKey,mailbox:o.capabilities.mailboxKeyPair.publicKey}),await this.privateProfile.dispatch("@keet-private-id/update-identity",{identity:{publicKey:i.identityPublicKey,discoveryCoreKey:this.discoveryCore.key}})}}async confirmRecoveryPhrase({persist:e=!1}={}){this.onlineBoot.opened||await this.onlineBoot.ready();const t=await this.internalEnterLocalTransaction();try{const i=await t.get("@local/identity");e||(i.entropy=null),i.status.isConfirmed=!0,await t.insert("@local/identity",i),await t.flush()}finally{await this.internalExitLocalTransaction()}this.emit("identity-changed")}async restoreIdentity(t,{create:i=!0}={}){this.onlineBoot.opened||await this.onlineBoot.ready();const[s]=await Promise.all([this.local.get("@local/identity"),e.from({mnemonic:t})]),o=f.discoveryKey(s.privateProfileKey),r=this.tasks.restoreIdentity(o,{mnemonic:t,recover:!1===i,profileDiscoveryTimeout:this._profileDiscoveryTimeout,buildType:this.buildType});await r.run();const a=await this.local.get("@local/identity"),n=await this.local.get("@local/rooms",{roomKey:a.privateProfileKey});this.privateProfile=await this.internalOpenPrivateProfile(),this.swarmWorker.startActiveSwarming(n.capabilities.swarmTopic)}async acceptJoinRequest(e,t){this.onlineBoot.opened||await this.onlineBoot.ready();const i=this.internalOpenExistingRoom(e);try{const s=await i.db.get("@keet/join-requests",{deviceKey:t});if(!s)return;const o=s.request;let r=null;if(o.identity){const i=await this.local.get("@local/identity");if(!v.equals(i.privateProfileKey,e))throw new Error("Accepting an identity device join request on a room that is not your private profile");r=Le(i,t,o.identity.devicePublicKey)}await i.dispatch("@keet/accept-join-request",{deviceKey:t,identity:r})}finally{this.internalReleaseRoom(i)}}async rejectJoinRequest(e,t){this.opened||await this.ready();const i=this.internalOpenExistingRoom(e);try{if(!await i.db.get("@keet/join-requests",{deviceKey:t}))throw new Error("Join request for that device key does not exist");await i.dispatch("@keet/reject-join-request",{deviceKey:t})}finally{this.internalReleaseRoom(i)}}async _sendContactRequest(e){this.onlineBoot.opened||await this.onlineBoot.ready();const t=await this.internalOpenPrivateProfile();try{this.tasks.sendContactRequest(e.memberKey,e).runBackground()}finally{this.internalReleaseRoom(t)}}async sendContactRequestFromContact(e,{message:t}){const i=(e=this.internalDecodeContactInfo(e)).attestation.memberKey,s=e.attestation.memberKey;return this._sendContactRequest({roomKey:i,memberKey:s,message:t,contactInfo:e})}async sendContactRequest(e,t,{message:i}){return this._sendContactRequest({roomKey:e,memberKey:t,message:i})}async addContact(t,i,{alias:s}={}){if(this.onlineBoot.opened||await this.onlineBoot.ready(),!i)throw pe.INVALID_CONTACT_INFO();if(!await this.internalFeatureSupported(this.privateProfile.id,D.CONTACT_BOOK))throw new Error("Adding contacts not supported");const o=await this.internalFeatureSupported(this.privateProfile.id,D.CONTACT_ALIAS);if(s&&!o)throw new Error("Adding contact alias not supported");try{const{profile:o,attestation:r}=this.internalDecodeContactInfo(i),a=oe("@keet/member-profile",o),n=e.verify(r.proof,a,{expectedIdentity:t});if(!n?.receipt)throw pe.INVALID_CONTACT_INFO();const l={memberKey:t,mailbox:o.mailbox,status:{isActive:!0,isBlocked:!1},contactInfo:{profile:o,attestation:r}};s&&(l.alias=s),await this.privateProfile.dispatch("@keet-private-id/add-contact",{contact:l})}catch(e){this.onerror(e)}}async setContactAlias(e,t){if(this.onlineBoot.opened||await this.onlineBoot.ready(),!await this.internalFeatureSupported(this.privateProfile.id,D.CONTACT_ALIAS))throw new Error("Setting contact alias not supported");await this.privateProfile.dispatch("@keet-private-id/update-contact-alias",{memberKey:e,alias:t})}async removeContact(e){if(this.onlineBoot.opened||await this.onlineBoot.ready(),!await this.internalFeatureSupported(this.privateProfile.id,D.CONTACT_BOOK))throw new Error("Removing contacts not supported");const t=await this.privateProfile.db.get("@keet-private-id/contacts",{memberKey:e});t&&await this.privateProfile.dispatch("@keet-private-id/add-contact",{contact:{memberKey:e,mailbox:t.mailbox,status:{...t.status,isActive:!1},contactInfo:t.contactInfo}})}async blockContact(e){this.onlineBoot.opened||await this.onlineBoot.ready();const[t,i,s]=await Promise.all([this.privateProfile.db.findOne("@keet-private-id/contact-requests-by-member",{gte:{memberKey:e},lte:{memberKey:e}}),this.privateProfile.db.get("@keet-private-id/contacts",{memberKey:e}),this.local.get("@local/members",{key:e})]),o=i?.mailbox||s?.profile.mailbox||t?.sender?.mailbox;if(!o)throw new Error("Cannot find contact");const r={memberKey:e,mailbox:o,status:{...i?.status,isBlocked:!0}};await this.internalFeatureSupported(this.privateProfile.id,D.CONTACT_BOOK)&&(r.contactInfo=i?.contactInfo),await this.privateProfile.dispatch("@keet-private-id/add-contact",{contact:r})}async unblockContact(e){this.onlineBoot.opened||await this.onlineBoot.ready();const[t,i,s]=await Promise.all([this.privateProfile.db.findOne("@keet-private-id/contact-requests-by-member",{gte:{memberKey:e},lte:{memberKey:e}}),this.privateProfile.db.get("@keet-private-id/contacts",{memberKey:e}),this.local.get("@local/members",{key:e})]),o=i?.mailbox||s?.profile.mailbox||t?.sender?.mailbox;if(!o)throw new Error("Cannot find contact");const r={memberKey:e,mailbox:o,status:{...i?.status,isBlocked:!1}};await this.internalFeatureSupported(this.privateProfile.id,D.CONTACT_BOOK)&&(r.contactInfo=i?.contactInfo),await this.privateProfile.dispatch("@keet-private-id/add-contact",{contact:r})}async _flushDHTCache(){if(this.readOnly)return;const e=this.swarm.dht.toArray({limit:64});try{await this._setCachedDHTNodes(e)}catch(e){this.onerror(e)}}async getDHTSettings(){const e=await this.local.get("@local/hyperdht")||{};return{nodes:e.nodes||[],concurrency:e.concurrency||Z.concurrency,maxWindow:e.maxWindow||Z.maxWindow,randomPunchInterval:e.randomPunchInterval||Z.randomPunchInterval,connectionKeepAlive:e.connectionKeepAlive||Z.connectionKeepAlive}}async getSwarmSettings(){return{maxPeers:(await this.local.get("@local/hyperswarm")||{}).maxPeers||ee.maxPeers}}async _setCachedDHTNodes(e){const t=await this.internalEnterLocalTransaction();try{const i={...await this.getDHTSettings(),nodes:e};await t.insert("@local/hyperdht",i),await t.flush()}finally{await this.internalExitLocalTransaction()}}batch(e){return new Re(this,e)}async dispatch(e,t,i){this.opened||await this.ready();const s=this.internalOpenExistingRoom(e);try{return await s.dispatch(t,i)}catch(e){this.onerror(e)}finally{this.internalReleaseRoom(s)}}async dispatchBatch(e,t){this.opened||await this.ready();const i=this.internalOpenExistingRoom(e);try{await i.dispatchBatch(t)}finally{this.internalReleaseRoom(i)}}async selfDestruct({confirm:e}={}){if("do not go gentle into that good night"!==e)throw new Error("Must confirm self destruction");await this.ready(),await this.close();const t=Math.random().toString(16).slice(2),i=K.join(this.dir,"gc",t);try{await P.promises.mkdir(i,{recursive:!0})}catch{}for(const e of["cores","db","cache","app-references"])try{await P.promises.rename(K.join(this.dir,e),K.join(i,e))}catch{}await P.promises.rm(i,{recursive:!0})}_handleError(e,t={}){const i=this.errorManager.normalize(e,t);this.errorManager.add(i),this.logger.error(i),this._onerror(i)}static from(e,t){const i=C.migrate(e),s=i.active()||i.create({name:"default"});i.gc({delay:ke});const o=new this(s.storage,{...t,logout:async()=>{i.remove(s),await new Promise(e=>setTimeout(e,1e3)),await o.close(),i.gc({delay:ke})}});return{profiles:i,keet:o}}static registerRPC(e,t,i){return new x(e,t,i)}};
1const e=require("keet-identity-key"),{ProofEncoding:t}=require("keet-identity-key/lib/encoding"),i=require("hypercore-storage"),s=require("hypercore-id-encoding"),o=require("ready-resource"),a=require("ready-guard"),r=require("hyperswarm"),n=require("@holepunchto/call-swarm"),l=require("hyperdht"),c=require("corestore"),h=require("hypercore"),d=require("hyperblobs"),y=require("scope-lock"),u=require("rache"),m=require("protomux-wakeup"),p=require("promaphore"),g=require("safety-catch"),w=require("task-backoff"),f=require("hypercore-crypto"),b=require("z32"),v=require("b4a"),k=require("compact-encoding"),P=require("fs"),K=require("path"),_=require("blind-peering"),C=require("multi-profile-store"),R=require("hyperconf");h.enable(h.SMALL_WANTS),h.setRecoveryPeers&&h.setRecoveryPeers([]);const T=require("@holepunchto/keet-push"),L=require("@holepunchto/keet-unread-anchors"),{generateMnemonic:E}=require("bip39-mnemonic"),{HyperDiscoveryClient:I}=require("@holepunchto/hyperdiscovery"),D=require("./schema/versions"),x=require("./lib/api/v1"),B=require("./lib/api/v2"),S=require("./lib/core/crypto"),A=require("./lib/core/local"),V=require("./lib/core/files"),M=require("./lib/core/tasks"),O=require("./lib/core/sync/processor"),q=require("./lib/core/room-engine"),{SwarmWorker:U}=require("./lib/core/swarm"),N=require("./lib/core/bluetooth"),{getWriterKey:F,getInvitationId:W,createInvitation:H,generateWakeupTopic:j,generateRoomCapabilities:$,generateIdentityPairingName:G,generateRoomPairingName:J}=require("./lib/core/invitations"),{getMemberForDeviceKey:z}=require("./lib/core/contract/query"),{restoreAvatar:Y}=require("./lib/core/contract/avatars"),{RoomStatus:Q}=require("./lib/core/contract/identity/private"),{DEBUG_FLAGS:X,DHT_SETTINGS:Z,SWARM_SETTINGS:ee}=require("./lib/core/debug/debugging"),te=require("./lib/core/log"),{contract:{hyperschema:{getEnum:ie,getEncoding:se,encode:oe,decode:ae}},local:{hyperschema:{getEnum:re}},config:{hyperconf:ne}}=require("./schema/spec"),le=se("@keet-private-id/profile-discovery-record"),ce=ie("@keet/build-type"),he=require("./lib/core/users"),de=require("./lib/core/rooms/index.js"),ye=require("protomux-rpc-client"),{KeetErrorManager:ue,KeetErrorV2:me,ERRORS:pe}=require("./lib/errors"),{Version:ge}=require("bare-semver"),{roomMigrationsStats:we}=require("./lib/core/contract/stats/local"),fe=require("./lib/bundle"),be=require("./lib/core/contract/index.js"),ve=re("@local/keet-state"),ke=2592e6,Pe=v.alloc(32),Ke=require("./lib/env"),{ActiveCall:_e,KeetCallProxy:Ce}=require("./lib/core/call");class Re{constructor(e,t){this.keet=e,this.roomId=t,this.batch=null,this.length=0,this.timestamp=0,this.pushLength=0}get key(){return this.room.engine.local.key}_open(){this.room=this.keet.internalOpenExistingRoom(this.roomId),this.batch=this.room.engine.batch(),this.timestamp=Date.now()}_noop(){return this.close(),this.length}async dispatch(e,t,{dryRun:i=!0}={}){this.room||this._open(),this.room.opened||await this.room.ready();const s=be.encodeOperation(e,{header:{timestamp:this.timestamp},...t});return i&&!await this.keet.internalDryRun(this.room,this.room.view,[s])?this._noop():(this.length=await this.append(s),!this.pushLength&&Ie(e)&&(this.pushLength=this.length),this.length)}async append(e){return this.batch.append(e)}async flush(){try{return await this.batch.flush(),await this.room._postAppend({encoded:this.batch.blocks,pushLength:this.pushLength,timestamp:this.timestamp}),await this.keet.roomProcessor.process(this.room),{key:this.key,length:this.length}}finally{this.close()}}close(){this.room&&this.keet.internalReleaseRoom(this.room),this.batch&&this.batch.close(),this.batch=null,this.length=0,this.shouldPush=!1}}class Te extends o{constructor(e,t,i,o,a,r){super(),this.keet=e,this.id=t,this.key=i,this.engine=r,this.externalBlobs=null,this.discoveryKey=o,this.discoveryId=s.encode(this.discoveryKey),this.view=this.engine.view,this.db=this.view.db,this.core=this.view.core,this.router=this.view.router,this.priority=a,this.push=null,this.keet.push&&(this.push=this.keet.push.room(this.key,this.discoveryKey)),this.refs=0,this.idleTicks=0,this._pushLock=new y({debounce:!0}),this.ready().catch(De)}static create(e,t,i,s,o,a={}){const r=new q(e,t,s,a),{priority:n=1}=a;let l=null;return r.auto.on("interrupt",t=>{e.logger.warn("room=",r.auto.id,"got interrupted"),e.emit("room-interrupted",i,t)}),r.auto.on("warning",t=>{e.logger.warn("[autobee warning] room=",r.auto.id,"error=",t),e.onerror(t,{roomKey:s,prefix:"AUTOBEE_WARNING"})}),r.auto.on("error",t=>{e.logger.warn("[autobee error] room=",r.auto.id,"error=",t),e.onerror(t,{roomKey:s,prefix:"AUTOBEE_ERROR"}),t.code===pe.ROOM_DISABLED&&null!==l&&(e.internalCloseRoom(l),l.close().catch(e.onerror))}),l=new Te(e,i,s,o,n,r),l}get deviceId(){return s.encode(this.deviceKey)}get deviceKey(){return this.engine.local.key}get encryptionKey(){return this.engine.encryptionKey}get blobs(){return this.engine.blobs}getQuickStats(){return{view:this.engine.viewStats,system:this.engine.systemStats,base:this.engine.stats,writer:this.engine.writerStats}}async getStats(){const[e,t,i]=await Promise.all([this.keet.local.get("@local/rooms",{roomKey:this.key}),this.keet.local.get("@local/room-preferences",{roomKey:this.key}),this.keet.local.get("@local/writers-by-room-key",{roomKey:this.key})]);return{...this.getQuickStats(),status:e?.status,preferences:t?.status}}async _createDeviceAttestation(e,t){const i=await this.keet.internalEnterLocalTransaction();try{const s=this.keet.internalAttestData(e,t);return await i.insert("@local/device-attestations",{deviceKey:e,proof:s,createdAt:Date.now()}),await i.flush(),s}finally{await this.keet.internalExitLocalTransaction()}}async _attestedPushNotify(e){const t=this.deviceKey,[i,s]=await Promise.all([this.keet.local.get("@local/identity"),this.keet.local.get("@local/device-attestations",{deviceKey:t})]),o=s?.createdAt||0,a=i.proofShortenedAt||0,r=!s||o<a?await this._createDeviceAttestation(t,i):s.proof;if(this.push&&this.keet.gatekeeperKeys?.length)return void await this.push.send(this.engine.local,e,{version:1,attest:r});const n=this.engine.wakeupCapability&&this.engine.wakeupCapability.key;if(!n)throw new Error("Wakeup capability key must be defined when sending a notification");for(const t of e)await this.keet.blindPeering.sendNotification(this.engine.local,{roomKey:this.engine.key,index:t-1,extra:r,target:n})}async _safePushNotify(e){if(this._pushLengths||(this._pushLengths=[]),this._pushLengths.push(e),!await this._pushLock.lock())return;const t=this._pushLengths;if(this._pushLengths=null,!this.closing&&t){try{await this._attestedPushNotify(t)}catch(e){this.keet.onerror(e,{roomKey:this.key})}this._pushLock.unlock()}else this._pushLock.unlock()}async _safeBumpDiscovery(e){await new Promise(e=>setTimeout(e,100));try{if(this.keet.closing)return;const t=await this.keet.local.get("@local/rooms",{roomKey:this.key});if(!t)return;this.keet.discovery.announce(t.capabilities.discoveryKeyPair,{bump:e})}catch(e){this.keet.onerror(e,{roomKey:this.key})}}async _open(){await this.engine.auto.ready();const e=this.keet.internalIsRoomDisabled(this.key);e||this.internalEnsureMirroring(),await this.engine.ready(),this.engine.auto.on("writer",async e=>{try{if(await this.keet.local.get("@local/devices",{device:{key:e.core.key}}))return;const t=await this.db.get("@keet/devices",{key:e.core.key});t&&await this.db.get("@keet/members",{key:t.memberKey})}catch(e){g(e)}}),this.engine.local.on("remote-contiguous-length",this._handleSentLengthChanged.bind(this)),this.engine.on("rotate-local-writer",()=>{this.engine.local.on("remote-contiguous-length",this._handleSentLengthChanged.bind(this))}),this.db.get("@keet/room-config").then(e=>{this.keet.logger.debug("opened id: "+this.id+" title: "+e?.title)},g),this.externalBlobs=new d(this.keet.store.get({name:this.id+"/blobs",encryptionKey:this.encryptionKey,encrypted:!0,exclusive:!0,active:!1})),await this.externalBlobs.ready(),await this._ensureMetadata(),e||(this.internalEnsureProfileUpdated(),this.internalEnsureUpgraded(),this.internalEnsureAutobeeMigrationShared(),this.internalEnsureAdminDevices(),this.internalEnsureRepaired())}async internalCloseAutobee(){this.keet.internalTime(`internal-close-autobee-${this.id}`),await this.engine.close(),this.keet.internalTimeEnd(`internal-close-autobee-${this.id}`)}async internalCloseExternalBlobs(){this.keet.internalTime(`internal-close-blobs-${this.id}`),await this.externalBlobs.close(),this.keet.internalTimeEnd(`internal-close-blobs-${this.id}`)}async internalPushDestroy(){this.push&&(this.keet.internalTime(`internal-close-push-${this.id}`),await this.push.destroy(),this.keet.internalTimeEnd(`internal-close-push-${this.id}`))}_close(){return Promise.all([this.internalCloseAutobee(),this.internalCloseExternalBlobs(),this.internalPushDestroy()])}_handleSentLengthChanged(){if(!this.engine.writable)return;const{length:e,remoteContiguousLength:t}=this.engine.local;e===t&&this.keet.emit("room-sent-message",this.engine.id)}async _ensureMetadata(){const e=await this.keet.internalEnterLocalTransaction();try{const[t,i]=await Promise.all([e.get("@local/room-metadata",{roomKey:this.key}),e.get("@local/rooms",{roomKey:this.key})]);if(t)return;const s=i?0:1;await e.insert("@local/room-metadata",{roomKey:this.key,repairs:s}),await e.flush()}finally{await this.keet.internalExitLocalTransaction()}}async internalEnsureMirroring(){this.refs++;try{const e=this.engine.wakeupCapability||await this.keet.internalGetMailbox(this.key),t=e&&e.key;if(!t)return;const i=await this.keet._getMirrorKeys(this.key);if(this.closing)return;this.keet.blindPeering.addAutobaseBackground(this.engine.auto,{target:t,keys:i,priority:this.priority});try{await this.engine.ready()}catch{return}if(this.closing)return;for(const e of this.engine.migratedViews)this.keet.blindPeering.addCoreBackground(e,{target:t,keys:i,priority:this.priority})}finally{this.refs--}}async internalIsMirroringView(){const e=this.engine.viewCore;if(!e||e.remoteContiguousLength===e.length)return!1;const t=await this.keet.local.get("@local/rooms",{roomKey:this.key});return!!t?.selfMember?.status.isAdmin&&(await this.keet._getMirrorKeys(this.key,t)).length>0}async internalEnsureUpgraded({opening:e=!1}={}){this.refs++;try{e||this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready();const[t,i]=await Promise.all([this.db.get("@keet/system-digest"),z(this.db,this.deviceKey)]);if(!i?.status.isModerator||t?.abi.version>=this.keet.abi.autoupgrade)return;await this.keet.internalDispatchUpgrade(this.id,this.keet.abi.autoupgrade)}catch(e){this.keet.onerror(e,{roomKey:this.key})}finally{this.refs--}}async internalEnsureProfileUpdated(){this.refs++;try{this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready();const[e,t]=await Promise.all([this.keet.local.get("@local/identity"),z(this.db,this.deviceKey)]);if(this.closing||!e||!t||v.equals(this.key,e.privateProfileKey))return;const i=await this.keet.local.get("@local/rooms",{roomKey:e.privateProfileKey});if(this.closing)return;if(t.profile.timestamp>=i.selfMember.profile.timestamp)return;const s={profile:i.selfMember.profile,attestation:{memberKey:i.selfMember.key,proof:i.selfMember.proofs.profileAttestation}};await this.dispatch("@keet/update-member",{member:s})}catch(e){this.keet.onerror(e,{roomKey:this.key})}finally{this.refs--}}async internalEnsureAdminDevices(){this.refs++;try{this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready();const e=await this.keet.local.get("@local/rooms",{roomKey:this.key});if(this.closing||!e)return;const t=D.FEATURES.ADMIN_DEVICE_INDEXING;if(!D.isFeatureSupported(e.digest.abi.version,t))return;if(!e.selfMember||!e.selfMember.status.isAdmin)return;if(!e.selfDevice||e.selfDevice.status.isIndexing)return;await this.dispatch("@keet/claim-admin-devices",{})}catch(e){this.keet.onerror(e,{roomKey:this.key})}finally{this.refs--}}async internalEnsureAutobeeMigrationShared(){this.refs++;try{if(this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready(),this.closing)return;const e=this.key,t=await this.keet.local.get("@local/rooms",{roomKey:e});if(!t||!t.status.isWritable)return;if(!t.selfMember||!t.selfMember.status.isAdmin)return;const i=await this.db.get("@keet/autobee-migration");if(this.closing||i)return;const s=await this.keet.local.get("@local/autobee-migrations",{roomKey:e});if(!s)return;const o={head:s.autobeeMigrationHead};s.legacyViewHead&&(o.legacyViewHead=s.legacyViewHead),s.dbViewHead&&(o.dbViewHead=s.dbViewHead),s.blobsViewHead&&(o.blobsViewHead=s.blobsViewHead),await this.dispatch("@keet/autobee-migration",o)}catch(e){this.keet.onerror(e,{roomKey:this.key})}finally{this.refs--}}async internalGetBootFrom(){const[e,t]=await Promise.all([this.keet.local.get("@local/autobee-migrations",{roomKey:this.key}),this.db.get("@keet-private-id/identity")]);if(e&&!await this.db.get("@keet/autobee-migration")){const t=e.autobeeMigrationHead;return t?{key:t.key,length:0}:null}const i=this.engine.auto.local;return t?{key:i.key,length:i.length+1}:this.engine.getMostRecentAdmin()}async internalEnsureRepaired(){this.refs++;try{if(this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready(),this.closing||this.keet.closing)return;if(this===this.keet.privateProfile)return;const e=await this.keet.local.get("@local/room-metadata",{roomKey:this.key});if(this.closing||this.keet.closing||e.repairs>=1)return;if(!this.engine.shouldRepair())return;const t=await this.db.get("@keet-private-id/identity");if(this.closing||this.keet.closing||t)return;if(e.repairs=1,await this.engine.repair(),this.closing||this.keet.closing)return;const i=await this.keet.internalEnterLocalTransaction();try{await i.insert("@local/room-metadata",e),await i.flush()}finally{await this.keet.internalExitLocalTransaction()}}finally{this.refs--}}_encodeBatch(e){const t=Array.isArray(e)?e:[e],i=Date.now(),s=[];let o=!1;for(const{type:e,op:a}of t)s.push(be.encodeOperation(e,{header:{timestamp:i},...a})),Ie(e)&&(o=!0);return{encoded:s,timestamp:i,shouldPush:o}}async _postAppend({encoded:e=[],pushLength:t=0,timestamp:i=Date.now()}){this.keet.stats.ops+=e.length,(this.push||this.keet.blindPeering?.keys.length)&&t>0&&this._safePushNotify(t),this.keet.discovery&&this._safeBumpDiscovery(i),this.db.update()}async dispatchBatch(e,{view:t=this.view,dryRun:i=!0,optimistic:s=!1}={}){this.opened||await this.ready();const{encoded:o,timestamp:a,shouldPush:r}=await this._encodeBatch(e,{view:t});if(i&&!await this.keet.internalDryRun(this,t,o))return null;await this.engine.append(o,{optimistic:s});const n=this.engine.local.length,l=r?n:0;return await this._postAppend({encoded:o,pushLength:l,timestamp:a}),await this.keet.roomProcessor.process(this),{key:this.engine.local.key,length:n}}dispatch(e,t,i){return this.dispatchBatch([{type:e,op:t}],i)}}function Le(t,i,s){const o=e.attestDevice(s,t.deviceKeyPair,t.deviceProof),a=e.attestData(i,t.deviceKeyPair,t.deviceProof);return{privateProfileIdentity:{memberKey:t.publicKey,proof:a},deviceProof:o}}function Ee(e){return e.map(({mediaStreamId:e,type:t,muted:i})=>({streamKey:f.randomBytes(32),mediaStreamId:e,type:t,muted:i}))}function Ie(e){return"@keet/add-chat-message"===e||"@keet/start-call"===e||"@keet/join-call"===e||"@keet/leave-call"===e||"@keet/end-call"===e||"@keet/update-read-length"===e}function De(){}module.exports=class extends o{constructor(e,t={}){if(super(),this.dir=e,this.opts=t,this.isMobile=!!t.mobile,this.isTesting=!!t.testing,this.appVersion=t.appVersion?ge.parse(t.appVersion):null,this.forceBuildType=!!t.forceBuildType,!t.buildType)throw me.INVALID_BUILD_TYPE();this.buildType=function(e){switch(e){case"nightly":return ce.Nightly;case"internal":return ce.Internal;case"production":return ce.Production;default:throw me.INVALID_BUILD_TYPE()}}(t.buildType),this.logger=new te(t.logger),this.isTesting&&this.logger.mute(),this.callHeartbeatOpts=t.callHeartbeat||{},this.callProxy=new Ce;const o=Ke(t.buildType);this.isNightly=this.buildType===ce.Nightly,this.isExperimental=this.isTesting?t.experimental??this.isNightly:this.isNightly,this.offlineBoot=new a,this.onlineBoot=new a,this.debug={},this.versions=D,this.abi=t.testingABI||{max:this.isExperimental?D.EXPERIMENTAL:D.STABLE,autoupgrade:this.isExperimental?D.EXPERIMENTAL:D.AUTOUPGRADE,production:D.STABLE},this.abi.min=D.MINIMUM,this.logout=t.logout,this.storage=new i(e,t.storage),this.rootCorestore=new c(this.storage,{globalCache:new u({maxSize:t.maxCacheSize}),manifestVersion:2}),this.store=this.rootCorestore.namespace("keet-core"),this.rootCorestore.watch(this._handleCoreOpen.bind(this)),this.local=A.rocks(this.storage.rocks.columnFamily("keet/local-database")),this.discovery=null,this.gatekeepers=t.gatekeepers||[],this.push=null,this.protomuxWakeup=new m(this._handleWakeup.bind(this)),this.backoff=new w,this.rooms=new Map,this.activeRooms=new Set,this._transactionLock=new y,this._tx=null,this.hyperconf=null,this.config=null,this.configMinVersion=null,this.configDesktopMinVersion=null,this.errorManager=new ue(this,this.opts),this.swarmWorker=new U(this,this.opts.swarmWorker),this.files=new V(this,this.opts),this._onerror=t.onerror||g,this.onerror=this._handleError.bind(this),this.apiV1=new x(this,t),this.backendAPI=this.apiV1,this.api=this.backendAPI.api.core,this.blindPeeringOpts=t.blindPeeringOpts||{},this.contractBundles=null,this.roomProcessor=null,this.tasks=null,this.swarm=null,this.swarmId=null,this.blindPeering=null,this.privateProfile=null,this.unreads=null,this.unreadsLoading=null,this.userRegistry=null,this.roomRegistry=null,this.discoveryCore=null,this.discoveryCoreSession=null,this.push=null,this.state=ve.RESUME,this._bundlesKey=t.bundlesKey||o.bundles.key,this._bundlesLength=t.bundlesLength||o.bundles.length,this._hyperconfKey=t.hyperconfKey||o.config.key,this._hyperconfLength=t.hyperconfLength||o.config.length,this._roomRegistryOpts=t.roomRegistry||o.roomRegistry,this._disabledRooms=this.isTesting?new Set((t.disabledRooms||[]).map(e=>s.normalize(e))):null,this._verifiedRooms=this.isTesting?new Set:null,this._relayKeys=this.isTesting?t.blindRelays||[]:null,this._blindPeerKeys=this.isTesting?t.blindMirroring||[]:null,this._gatekeeperKeys=this.isTesting?t.gatekeepers||[]:null,this._discoveryBootstrapKeys=this.isTesting?t.discoveryBootstrapKeys||[]:null,this._disableUnreadSync=this.isTesting&&t.disableUnreadSync||!1,this._otaResyncPrivateProfileBump=this.isTesting&&t.otaResyncPrivateProfileBump||0,this._migratedFrom=0,this._unreadsLock=new y({debounce:!0}),this._dhtOpts=t.dht,this._swarmOpts=t.swarm,this._bluetoothOpts=t.bluetooth,this._pendingTasks=[],this._swarmTasks=[],this._runningTasks=new Set,this._waitingForCompletion=new Map,this._completedRequests=new Set,this._pendingCandidates=new Map,this._swarming=new Map,this._pendingTraces=[],this._cacheLock=new y({debounce:!0}),this._gcEnabled=!1!==t.gc,this._gcIdleTicks=t.gcIdleTicks||4,this._gcInterval=t.gcInterval||5e3,this._gcTimer=null,this._gcClosingRooms=new Set,this._boundAutobeeTrace=this._autobeeTrace.bind(this),this.internalPairingTimeout=t.pairingTimeout||3e3,this._profileDiscoveryTimeout=t.profileDiscoveryTimeout||1e4,this.migrationStatus=null,this._roomMigrations=new p(5),this._discoveryLock=new y({debounce:!0}),this._discoverySemaphore=new p(10),this._discovering=new Map,this.internalFastJoinSemaphore=new p(4),this.debugRunningFastJoins=0,this.debugMaxRunningFastJoins=0,this._rejectAnonymousProfiles=!1!==t.rejectAnonymousProfiles,this._registryOpts=this.isTesting?t.userRegistry:null,this.rpcClient=null,this.ackThreshold=t.ackThreshold,this.ackInterval=t.ackInterval,this.stats={ops:0,appends:0,bytesAppended:0,uploaded:0,bytesUploaded:0,downloaded:0,bytesDownloaded:0},this.debugForceMigrationFailure=t.debugForceMigrationFailure||null,this.debugJoinPeer=t.debugJoinPeer||this._debugJoinPeer.bind(this),this.debugLeavePeer=t.debugLeavePeer||this._debugLeavePeer.bind(this),this.debugDisableCacheBump=!1,this.debugClosing=!1,this.debugFailRoomSync=t.debugFailRoomSync||null,this.debugFailNextRoomSync=t.debugFailNextRoomSync||null,this.debugDisableSyncing=!0===t.debugDisableSyncing,this.ready().catch(this.onerror)}async backendReady(){this.backendAPI.opened||await this.backendAPI.ready()}get readOnly(){return this.rootCorestore.storage.readOnly||!1}get suspended(){return this.state===ve.SUSPEND}async internalEnableBluetooth(){"unsupported"!==this.bluetooth.state&&await this.bluetooth.setEnabled(!0)}async internalDisableBluetooth(){"unsupported"!==this.bluetooth.state&&await this.bluetooth.setEnabled(!1)}get gatekeeperKeys(){return this._gatekeeperKeys}async _openNetworking(){const e=await this.getDHTSettings(),t=await this.getSwarmSettings();this.swarm=new r({deferRandomPunch:!0,dht:new l({...e,...this._swarmOpts,...this._dhtOpts}),maxPeers:t.maxPeers,...this._swarmOpts,relayThrough:this._relayThrough.bind(this),keyPair:await this.rootCorestore.createKeyPair("keet-swarm-keypair")}),this.swarmId=s.encode(this.swarm.keyPair.publicKey),this.swarm.on("connection",this._handleConnection.bind(this)),this.bluetooth=new N(this,this._bluetoothOpts),this.callSwarmKeyPair=await this.rootCorestore.createKeyPair("keet-call-swarm-keypair"),this.activeCall=null,this.closingCallSwarms=new Set,this.discovery=this._discoveryBootstrapKeys.length?new I(this._discoveryBootstrapKeys[0],{dht:this.swarm.dht}):null,this.rpcClient=new ye(this.swarm.dht,{suspended:this.state===ve.SUSPEND,relayThrough:this._relayThrough.bind(this)}),this.blindPeering=new _(this.swarm.dht,this.store,{pick:2,wakeup:this.protomuxWakeup,keys:this.debug.disableMirrors?[]:this._blindPeerKeys,relayThrough:this._relayThrough.bind(this),...this.blindPeeringOpts}),this._gatekeeperKeys.length>0&&(this.push=new T(this._gatekeeperKeys,{dht:this.swarm.dht})),await this.swarmWorker.ready(),await this.files.ready(),this.readOnly&&(this.blindPeering.suspend(),this.swarm.suspend())}async _runBootOffline(){if(!this.offlineBoot.enter())return;await this._ensureDebugState(),await this.store.ready(),this.hyperconf=new R(ne,this.store.get(this._hyperconfKey),{minLength:this._hyperconfLength,production:this.buildType===ce.Production}),this.hyperconf.on("update",this._handleConfigUpdated.bind(this)),await this.hyperconf.ready(),await this._handleConfigUpdated(),this.config?.versions.autoupgrade>0&&(this.abi.autoupgrade=this.config.versions.autoupgrade);const e=await this.local.get("@local/environment"),t=!!e&&e.latestOfflineAbi<this.abi.production;this.contractBundles=new fe(this,"keet-bundles",{hydrate:t}),await this.contractBundles.ready(),t&&await this._bumpLocalAbiVersion(),this.roomProcessor=new O(this),await this.roomProcessor.ready(),await this._openNetworking(),this.tasks=new M(this),await this.tasks.ready(),this.roomProcessor.bump(),this._gcEnabled&&(this._gcTimer=setInterval(this._closeIdleRooms.bind(this),this._gcInterval)),this.offlineBoot.exit()}async _runBootOnline(){if(this.onlineBoot.enter()){await this.offlineBoot.ready(),this.discovery&&(this.discovery.on("announce",({publicKey:e})=>{this.scheduleDiscoverySwarming(e)}),this.discovery.on("connect",this._onDiscoveryConnect.bind(this)),this.discovery.connect()),this._refreshDiscoverySwarming(),this._migratedFrom=await this._ensureMigrated();try{await this._loadIdentity()}catch(e){this.onerror(e)}this._migratedFrom>0&&await this._maybeRunPostMigrations(this._migratedFrom),this._registryOpts&&(this.userRegistry=new he(this,this._registryOpts),await this.userRegistry.ready()),this._roomRegistryOpts&&(this.roomRegistry=new de(this,this._roomRegistryOpts),await this.roomRegistry.ready()),this.onlineBoot.exit(),this._resyncPrivateProfileOnBoot().catch(this.onerror)}}async _open(){!1!==await this._ensureBuildType()&&(this._runBootOffline().catch(this.onerror),this._runBootOnline().catch(this.onerror),await this.offlineBoot.ready())}async _close(){this.internalTime("keet-close"),this.internalVerboseLog("Closing keet core"),this._gcTimer&&clearInterval(this._gcTimer),this.backoff.destroy(),this.internalTimeLog("keet-close","destroyed backoff"),this.state===ve.SUSPEND&&await this.store.resume(),this.internalTimeLog("keet-close","resumed from suspend"),this.internalVerboseLog("Closing active calls"),await this.backendAPI.closeActiveCalls(),this.internalTimeLog("keet-close","closed active calls"),this.internalVerboseLog("Closing discovery cores"),this.discoveryCore&&await this.discoveryCore.close(),this.discoveryCoreSession&&this.discoveryCoreSession.destroy(),this.internalTimeLog("keet-close","closed discovery cores"),this.internalVerboseLog("Closing tasks"),this.tasks&&await this.tasks.close(),this.internalFastJoinSemaphore.destroy(),this.internalTimeLog("keet-close","stopped running tasks");for(const e of this._gcClosingRooms)this.internalTime(`gc-room-close-${e.id}`),this.internalTimeLog(`gc-room-close-${e.id}`),this.internalVerboseLog("Closing room in gc list",e.id,e.opened),await e.close(),this.internalTimeEnd(`gc-room-close-${e.id}`,"closed");this.internalTimeLog("keet-close","closed rooms in gc"),this.internalVerboseLog("Closing user registry"),this.userRegistry&&await this.userRegistry.close(),this.internalTimeLog("keet-close","closed user registry"),this.internalVerboseLog("Closing room registry"),this.roomRegistry&&await this.roomRegistry.close(),this.internalTimeLog("keet-close","closed room registry"),this.internalVerboseLog("Closing rpc client"),this.rpcClient&&await this.rpcClient.close(),this.internalTimeLog("keet-close","closed rpc client"),this.internalVerboseLog("Closing swarm worker"),await this.swarmWorker.close(),this.internalTimeLog("keet-close","closed swarm worker"),this.internalVerboseLog("Closing discovery"),this.discovery&&await this.discovery.close(),this.internalTimeLog("keet-close","closed discovery"),this.internalVerboseLog("Closing push"),this.push&&await this.push.destroy(),this.internalTimeLog("keet-close","closed push"),this.internalVerboseLog("Closing blind peering"),this.blindPeering&&await this.blindPeering.close(),this.internalTimeLog("keet-close","closed blind peering"),this.internalVerboseLog("Flushing DHT cache"),this.swarm&&await this._flushDHTCache(),this.internalTimeLog("keet-close","flushed dht"),this.internalVerboseLog("Closing active call"),this.activeCall&&await this.internalEndActiveCall(),this.internalTimeLog("keet-close","closed active call"),this.internalVerboseLog("Closing swarm"),this.swarm&&await this.swarm.destroy(),this.internalTimeLog("keet-close","destroyed swarm"),this.internalVerboseLog("Closing files"),await this.files.close(),this.internalTimeLog("keet-close","closed files"),this.internalVerboseLog("Closing all pending rooms and workers"),await Promise.allSettled([...[...this.rooms.values()].map(async e=>{this.internalTime(`pending-room-close-${e.id}`),this.internalTimeLog(`pending-room-close-${e.id}`),await e.close(),this.internalTimeEnd(`pending-room-close-${e.id}`)})]),this.internalTimeLog("keet-close","closed all pending rooms and workers"),this.internalVerboseLog("Closing room processor"),this.roomProcessor&&await this.roomProcessor.close(),this.internalTimeLog("keet-close","closed room processor"),this.internalVerboseLog("Closing backend"),await this.apiV1.close(),this.internalTimeLog("keet-close","closed backend"),await this.internalEnterLocalTransaction(),await this.internalExitLocalTransaction(),this.internalVerboseLog("Closing unread anchors"),this.unreadsLoading&&await this.unreadsLoading,this.unreads&&await this.unreads.close(),this.internalTimeLog("keet-close","closed unreads"),this.internalVerboseLog("Closing bluetooth"),this.bluetooth&&await this.bluetooth.close(),this.internalTimeLog("keet-close","bluetooth"),this.internalVerboseLog("Closing wakeup"),this.protomuxWakeup.destroy(),this.internalTimeLog("keet-close","protomux"),this.internalVerboseLog("Closing hyperconf"),this.hyperconf&&await this.hyperconf.close(),this.internalVerboseLog("Closing error manager"),this.errorManager&&await this.errorManager.close(),this.internalVerboseLog("Closing local db"),await this.local.close(),this.internalVerboseLog("Closing contract bundles"),this.contractBundles&&await this.contractBundles.close(),this.internalVerboseLog("Closing store"),await this.store.close(),this.internalVerboseLog("Closing root corestore"),await this.rootCorestore.close(),this.internalTimeLog("keet-close","closed cores"),this.internalVerboseLog("Close done"),this.internalTimeEnd("keet-close")}async _ensureDebugState(){const e=await this.internalEnterLocalTransaction();try{const t=await e.get("@local/debug")||{};t.flags||(t.flags=X);const i=new Set,s={};for(const e of t.flags)i.add(e.key),s[e.key]=e.value;for(const{key:e,value:s,description:o}of X)i.has(e)||t.flags.push({key:e,value:s,description:o});await e.insert("@local/debug",t),await e.flush(),this.debug={...s}}finally{await this.internalExitLocalTransaction()}}isValidBuildType(e){if(!e)return!0;if(this.isTesting&&!this.forceBuildType)return!0;const t=ce.Production===this.buildType;return!(!t&&!e.settings.buildType||!t&&e.settings.buildType!==this.buildType)}async _ensureBuildType(){if(this.isTesting&&!this.forceBuildType)return;const e=ce.Production===this.buildType,t=await this.internalEnterLocalTransaction();try{const[i,s]=await Promise.all([t.get("@local/identity"),t.get("@local/environment")]);if(!e&&i&&!s?.buildType)throw me.INVALID_BUILD_TYPE();if(s&&s.buildType!==this.buildType)throw me.INVALID_BUILD_TYPE();if(s)return;await t.insert("@local/environment",{buildType:this.buildType}),await t.flush()}catch(e){return this.onerror(e),!1}finally{await this.internalExitLocalTransaction()}}async _bumpLocalAbiVersion(){const e=await this.internalEnterLocalTransaction();try{const t=await e.get("@local/environment");t.latestOfflineAbi=this.abi.production,await e.insert("@local/environment",t),await e.flush()}finally{await this.internalExitLocalTransaction()}}async _onDiscoveryConnect(){const e=await this.local.find("@local/rooms-by-timestamp",{reverse:!0,limit:256}).toArray();this.discovery.cork();for(const t of e){const e=t.capabilities.discoveryKeyPair.publicKey,i=await this.local.get("@local/background-sync",{discoveryPublicKey:e}),s=Math.max(t.timestamps.latestSync,i?i.lastSynced:0);this.discovery.subscribe(t.capabilities.discoveryKeyPair.publicKey,{since:s})}this.discovery.uncork()}async internalEnterLocalTransaction(){return await this._transactionLock.lock(),this._tx=this.local.transaction(),this._tx}async internalExitLocalTransaction(){await this._tx.close(),this._transactionLock.unlock()}async _handleConfigUpdated(){if(!this.isTesting||this.opts.hyperconfKey){if(this.config=this.hyperconf.current,this.internalVerboseLog("OTA config updated, dkey:",s.encode(this.hyperconf.core.discoveryKey),"length:",this.hyperconf.core.length),this._blindPeerKeys=this.config.services.blindPeers,this._relayKeys=this.config.services.blindRelays,this._gatekeeperKeys=this.config.services.gatekeepers,this._discoveryBootstrapKeys=this.config.services.discovery,h.setRecoveryPeers&&h.setRecoveryPeers(this.config.services.blindPeers),this._disabledRooms=new Set(this.config.rooms.disabled.map(e=>s.encode(e))),this._verifiedRooms=new Set(this.config.rooms.verified?.map(e=>s.encode(e))),this._disableUnreadSync=!0===this.config.profile?.disableUnreadSync,this._otaResyncPrivateProfileBump=this.config.profile?.otaResyncPrivateProfileBump||0,this._maybeOtaResyncPrivateProfile().catch(this.onerror),this._maybeUpgradeOpenRooms().catch(this.onerror),this._closeDisabledRooms().catch(this.onerror),this.config.services.userRegistries?.length&&(this._registryOpts=this.config.services.userRegistries[0]),this.blindPeering&&this.blindPeering.setKeys(this._blindPeerKeys),this.config.versions.minVersion){const{major:e,minor:t,patch:i}=this.config.versions.minVersion;this.configMinVersion=new ge(e,t,i)}if(this.config.versions.desktopMinVersion){const{major:e,minor:t,patch:i}=this.config.versions.desktopMinVersion;this.configDesktopMinVersion=new ge(e,t,i)}this.config.versions.autoupgrade>0&&(this.abi.autoupgrade=this.config.versions.autoupgrade),this.emit("force-update"),this.emit("verified-rooms-changed")}}async _maybeUpgradeOpenRooms({debug:e=!1}={}){this.onlineBoot.opened||await this.onlineBoot.ready();const t=this.abi.autoupgrade,i=this.config?.versions.autoupgrade;if(!(t<i)&&!0!==e)return;const s=[],o=async function(e,t){try{await e.ready();const[i,s]=await Promise.all([e.db.get("@keet/system-digest"),z(e.db,e.deviceKey)]);if(!s?.status.isModerator||i?.abi.version>=t)return;await this.internalDispatchUpgrade(e.id,t)}catch(e){this.onerror(e)}}.bind(this);for(const[e,t]of this.rooms.entries())s.push(o(t,i));return await Promise.all(s)}async _maybeOtaResyncPrivateProfile(){this.onlineBoot.opened||await this.onlineBoot.ready();const e=this._otaResyncPrivateProfileBump||0;try{if(e<=((await this.local.get("@local/ota-actions"))?.otaResyncPrivateProfileBump||0))return;if(null===await this.internalResyncPrivateProfile())return;const t=await this.internalEnterLocalTransaction();try{await t.insert("@local/ota-actions",{otaResyncPrivateProfileBump:e}),await t.flush()}finally{await this.internalExitLocalTransaction()}}catch(e){this.onerror(e)}}shouldForceUpdate(){return this.config.versions.forceUpdate>D.FORCE_UPDATE||(this.isMobile?this._shouldForceUpdateMobile():this._shouldForceUpdateDesktop())}_shouldForceUpdateMobile(){return!(!this.configMinVersion||!this.appVersion)&&1===this.configMinVersion.compare(this.appVersion)}_shouldForceUpdateDesktop(){return!(!this.configDesktopMinVersion||!this.appVersion)&&1===this.configDesktopMinVersion.compare(this.appVersion)}isRoomVerified(e){return this._verifiedRooms.has(e)}internalIsRoomDisabled(e){return!!this._disabledRooms&&this._disabledRooms.has(s.encode(e))}async _bumpRoom(e){if(this.closing)return;if(!await this.local.get("@local/writers-by-room-key",{roomKey:e}))return;const t=await this.local.get("@local/rooms",{roomKey:e});if(!t||t.status.isRemoved)return;if(this.closing)return;const i=this.internalOpenExistingRoom(e);try{await i.ready()}finally{this.internalReleaseRoom(i)}}async _roomCoreReferrer(e){const t=e.state.storage.read(),i=[t.getUserData("referrer"),t.getUserData("autobase/view")];t.tryFlush();const[s,o]=await Promise.all(i);return s&&!o?s:null}async _tagLegacyCore(e){if(await e.ready(),e.core.header.group)return;if(e.writable)return;const t=await this._roomCoreReferrer(e.core);if(!t)return;const i=await this.internalGetMailbox(t);i&&(await e.setGroup(i.discoveryKey),await this._bumpRoom(t))}_handleCoreOpen(e){const t=new h({core:e,weak:!0}),i=new y({debounce:!0});this._tagLegacyCore(t).catch(this.onerror),t.on("verification-error",e=>{this.onerror(e,{coreKey:t.key,prefix:"CORE_VERIFICATION_ERROR"})}),t.on("conflict",()=>{this.onerror(new Error("Conflict in Hypercore"),{coreKey:t.key,prefix:"CORE_CONFLICT"})}),t.on("invalid-request",e=>{this.onerror(e,{coreKey:t.key,prefix:"CORE_INVALID_REQUEST"})}),t.on("append",async()=>{if(await i.lock())try{const t=await this._roomCoreReferrer(e);if(!t)return;await this._bumpRoom(t)}catch(e){this.onerror(e)}finally{i.unlock()}}),t.on("upload",(e,t)=>{this.stats.uploaded++,this.stats.bytesUploaded+=t}),t.on("download",(e,t)=>{this.stats.downloaded++,this.stats.bytesDownloaded+=t}),t.once("ready",()=>{if(t.writable){let e=t.length,i=t.byteLength;t.on("append",()=>{const s=t.length,o=t.byteLength;this.stats.appends+=s-e,this.stats.bytesAppended+=o-i,e=s,i=o})}})}async _handleWakeup(e,t){if(!this.discovery||this._isBluetoothConnection(t.stream))try{const[t,i]=await Promise.all([this.local.get("@local/writers-by-wakeup-topic",{wakeupTopic:e}),this.local.get("@local/rooms-by-wakeup-topic",{capabilities:{wakeupTopic:e}})]);if(!t&&!i)return;const s=t?.mailbox||i?.capabilities.mailboxKeyPair.publicKey,o=this.protomuxWakeup.session(s,{active:!1,discoveryKey:e,onpeeractive:e=>{t&&o.announce(e,[{key:t.key,length:1}])}});i&&await this._bumpRoom(i.roomKey)}catch(e){this.onerror(e)}}_isBluetoothConnection(e){return!(!this.bluetooth||!this.bluetooth.isEnabled)&&this.bluetooth.swarm.connections.has(e)}async _maybeRunMigrations(e,t){3===t&&await require("./lib/core/migrations/3")(this,e),4===t&&await require("./lib/core/migrations/4")(this,e),5===t&&await require("./lib/core/migrations/4")(this,e),t<8&&await require("./lib/core/migrations/7")(e),t<9&&await require("./lib/core/migrations/8")(e)}async _maybeRunPostMigrations(e){4===e&&await require("./lib/core/migrations/4/post")(this),5===e&&await require("./lib/core/migrations/4/post")(this)}async _ensureMigrated(){let e=0;const t=await this.internalEnterLocalTransaction();try{const i=await t.get("@local/migrations"),s=i?i.version:3;s<9&&(e=s,await this._maybeRunMigrations(t,s),await t.insert("@local/migrations",{version:9})),await t.flush()}finally{await this.internalExitLocalTransaction()}const i=await this.local.find("@local/room-migrations-by-priority").toArray(),o=[],a=[],r=[];for(const e of i)this._disabledRooms.has(s.encode(e.roomKey))?r.push(e):e.v3?.privateProfile?o.push(e):a.push(e);if(r.length>0){const e=await this.internalEnterLocalTransaction();try{for(const t of r){const i=await e.get("@local/room-migrations",{roomKey:t.roomKey});await e.delete("@local/room-migrations",t),await we(e,null,i)}await e.flush()}finally{await this.internalExitLocalTransaction()}}await Promise.all(o.map(e=>this._migrateRoom(e,{migratingRooms:a})));for(const e of a)this._migrateRoom(e).catch(this.onerror);return e}async _migrateRoom(e,{migratingRooms:t}={}){await this._roomMigrations.wait();try{const i=e.errored;if(i||(this.migrationStatus||(this.migrationStatus={remaining:0}),this.migrationStatus.remaining++,this.emit("migration-status",this.migrationStatus)),!e.timestamp){const t=await this.internalEnterLocalTransaction();try{e.timestamp=Date.now();const i=await t.get("@local/room-migrations",e);await t.insert("@local/room-migrations",e),await we(t,e,i),await t.flush()}finally{await this.internalExitLocalTransaction()}}const s=Date.now()-e.timestamp>1728e5;let o=!1,a=!1;try{e.v3&&!s&&await require("./lib/core/migrations/3/room")(this,e.roomKey,e.v3,{migratingRooms:t})}catch(e){this.onerror(e),a=!0,o=!!this.closing}const r=await this.internalEnterLocalTransaction();try{const t=await r.get("@local/room-migrations",e);a?(i||(e.errored=!o),await r.insert("@local/room-migrations",e),await we(r,e,t)):(await r.delete("@local/room-migrations",e),await we(r,null,t)),await r.flush()}finally{await this.internalExitLocalTransaction()}i||(this.migrationStatus.remaining--,this.emit("migration-status",this.migrationStatus))}finally{this._roomMigrations.signal()}}async _closeIdleRooms(){const e=[],t=[];for(const i of this.rooms.values())i.refs>0||(i.engine.busy?i.idleTicks=0:this.activeRooms.has(i)||++i.idleTicks<this._gcIdleTicks||i.refs>0||this.rooms.get(i.id)!==i||(this.rooms.delete(i.id),this._gcClosingRooms.add(i),e.push(i.close()),t.push(i)));const i=await Promise.allSettled(e);for(let e=0;e<i.length;e++)"rejected"===i[e].status&&this.onerror(i[e].reason,{roomKey:t[e].key,prefix:"ROOM_GC_CLOSE"});for(const e of t)this._gcClosingRooms.delete(e)}async _closeDisabledRooms(){for(const e of[...this.rooms.values()])this._disabledRooms.has(e.id)&&(this.internalCloseRoom(e),await e.close())}internalCloseRoom(e){this.rooms.delete(e.id),this._gcClosingRooms.add(e)}_debugJoinPeer(e){this.logger.info("Call join:",e)}_debugLeavePeer(e){this.logger.info("Call leave:",e)}async debugPauseCacheBump(){this.debugDisableCacheBump=!0,await this._cacheLock.flush()}debugResumeCacheBump(){this.debugDisableCacheBump=!1}debugPauseGC(){this._gcTimer&&(clearInterval(this._gcTimer),this._gcTimer=null)}debugResumeGC(){this._gcTimer||(this._gcTimer=setInterval(this._closeIdleRooms.bind(this),this._gcInterval))}debugMaybeUpgradeOpenRooms(e={}){return this._maybeUpgradeOpenRooms({debug:!0,...e})}async internalDiscoveryCompleted(e,t){try{const e=this._discovering.get(t);if(!e)return;const i=await this.internalEnterLocalTransaction();try{const t=e.roomInfo.capabilities.discoveryKeyPair.publicKey;e.room&&this.internalReleaseRoom(e.room);const s=await i.get("@local/background-sync",{discoveryPublicKey:t});s&&await i.insert("@local/background-sync",{...s,lastSynced:Date.now(),dirty:!1}),await i.flush()}finally{await this.internalExitLocalTransaction()}this._discovering.delete(t),this._discoverySemaphore.signal()}catch(e){this.onerror(e)}}async _startDiscoverySwarming(e,t){if(!await this._discoverySemaphore.wait())return!1;if(this.closing)return!1;const i=this._discovering.get(t);return!!i&&(this.swarmWorker.startDiscoverySwarming(e,{roomId:t}),i.updated&&this.swarmWorker.notifyDiscoveryUpdate(e),!0)}async _refreshDiscoverySwarming(){if(await this._discoveryLock.lock()&&!this.closing)try{const e=await this.internalEnterLocalTransaction();try{for await(const{discoveryPublicKey:t}of e.find("@local/background-sync-by-dirty",{reverse:!0})){const e=await this.local.get("@local/rooms-by-discovery",{capabilities:{discoveryKeyPair:{publicKey:t}}});if(!e||e.status.isRemoved)continue;const i=s.encode(e.discoveryKey);if(this._discovering.has(i))continue;const o=this.internalOpenExistingRoom(e.roomKey);this._discovering.set(i,{updated:!1,room:o,roomInfo:e}),this._startDiscoverySwarming(e.capabilities.swarmTopic,i)||this.internalReleaseRoom(o)}await e.flush()}finally{await this.internalExitLocalTransaction()}}catch(e){this.onerror(e)}finally{this._discoveryLock.unlock()}}async scheduleDiscoverySwarmingFromDiscoveryKey(e){const t=await this.local.get("@local/rooms-by-discovery-key",{discoveryKey:e});if(t)return this.scheduleDiscoverySwarming(t.capabilities.discoveryKeyPair.publicKey)}async scheduleDiscoverySwarming(e){const t=await this.internalEnterLocalTransaction();try{const i=await t.get("@local/background-sync",{discoveryPublicKey:e}),s=i?.lastSynced||0;await t.insert("@local/background-sync",{discoveryPublicKey:e,timestamp:Date.now(),lastSynced:s,dirty:!0}),await t.flush()}finally{await this.internalExitLocalTransaction()}this._refreshDiscoverySwarming()}async internalMarkRoomUpdated(e,t,i){const s=await this.internalEnterLocalTransaction();try{await s.insert("@local/room-updates",{roomKey:e,head:t,timestamp:Date.now(),incremental:i}),await s.flush()}finally{await this.internalExitLocalTransaction()}}async internalBlobsActiveInRoom(e){const t=s.encode(e),i=this.rooms.get(t);if(!i)return;const o=await this.local.get("@local/rooms",{roomKey:e});if(!o)return;const{capabilities:a}=o;if(!a||!a.mailboxKeyPair)return;try{await i.ready()}catch{return}if(!i.externalBlobs)return;const r=await this._getMirrorKeys(e,o);i.closing||this.blindPeering.addCoreBackground(i.externalBlobs.core,{target:a.mailboxKeyPair.publicKey,keys:r,pick:1})}async _getMirrorKeys(e,t){if(this.debug.disableMirrors)return[];if(!e)return this._blindPeerKeys;const i=t||await this.local.get("@local/rooms",{roomKey:e});return i&&i.config.blindPeers?.length?i.config.blindPeers:this._blindPeerKeys}_relayThrough(e){return e||this.swarm.dht.randomized?this._relayKeys:null}_callSwarmRelayThrough(e,t){return e||this.swarm.dht.randomized||t.dht.randomized?this._relayKeys:null}internalCreateCallSwarm(){return new n({...this._swarmOpts,keyPair:this.callSwarmKeyPair,dht:this.swarm.dht,relayThrough:this._callSwarmRelayThrough.bind(this)})}async internalStartCall(e,t){if(this.activeCall)throw me.CALL_SWARM_ACTIVE("",{callId:this.activeCall.callId});const i=s.decode(e),o=await this.local.get("@local/rooms",{roomKey:i}),a=f.randomBytes(32),r=await this.dispatch(e,"@keet/start-call",{version:3,callKey:a,encryptionKey:o.encryptionKey,swarmKey:this.callSwarmKeyPair.publicKey,streamInputs:Ee(t)});if(!r)throw me.CALL_DISPATCH_REJECTED("",{roomId:e,op:"@keet/start-call"});return await this.internalStartActiveCall(e,s.encode(a)),r}async internalJoinCall(e,t,i){if(this.activeCall)throw me.CALL_SWARM_ACTIVE("",{callId:this.activeCall.callId});const o=s.decode(t),a=this.internalOpenExistingRoom(e);let r=null;try{a.opened||await a.ready(),r=await a.db.get("@keet/call-devices",{callKey:o,deviceKey:a.deviceKey})}finally{await this.internalReleaseRoom(a)}let n=null;if(!r&&(n=await this.dispatch(e,"@keet/join-call",{callKey:o,swarmKey:this.callSwarmKeyPair.publicKey,streamInputs:Ee(i)}),!n))throw me.CALL_DISPATCH_REJECTED("",{roomId:e,callId:t,op:"@keet/join-call"});return await this.internalStartActiveCall(e,t),n}async internalLeaveCall(e,t){const i=await this.dispatch(e,"@keet/leave-call",{callKey:s.decode(t)});if(!i)throw me.CALL_DISPATCH_REJECTED("",{roomId:e,callId:t,op:"@keet/leave-call"});return this.activeCall&&this.activeCall.callId===t&&await this.internalEndActiveCall(),i}async internalEndCall(e,t){const i=await this.dispatch(e,"@keet/end-call",{callKey:s.decode(t)});if(!i)throw me.CALL_DISPATCH_REJECTED("",{roomId:e,callId:t,op:"@keet/end-call"});return this.activeCall&&this.activeCall.callId===t&&await this.internalEndActiveCall(),i}async internalStartActiveCall(e,t){if(this.activeCall)throw me.CALL_SWARM_ACTIVE("",{callId:this.activeCall.callId});if(this.suspended)throw me.CALL_SWARM_SUSPENDED("",{callId:t});const i=new _e(this,e,t);this.activeCall=i;try{await i.ready()}catch(e){throw this.activeCall=null,e}return i}internalEndActiveCall(){if(!this.activeCall)throw me.CALL_NOT_ACTIVE();const e=this.activeCall;this.activeCall=null;const t=e.close();return t.catch(this.onerror),t}internalSyncActiveCall(e){if(this.activeCall&&this.activeCall.roomId===e)return this.activeCall.sync()}internalVerboseLog(...e){const t=new Date;this.logger.info(t,...e)}internalTime(...e){this.isTesting||console.time(...e)}internalTimeLog(...e){this.isTesting||console.timeLog(...e)}internalTimeEnd(...e){this.isTesting||console.timeEnd(...e)}_handleConnection(e){if(this.closing)return void e.on("error",()=>{});const t=s.encode(e.publicKey),i=s.encode(e.remotePublicKey),o=Date.now();let a=0;this.internalVerboseLog(`got ${e.isInitiator?"client":"server"} connection from ${t} to ${i}`);let r=null;e.once("error",e=>{r=e}),e.once("close",()=>{this.internalVerboseLog(`connection closed to ${i}, with err: ${r} (${Date.now()-o} ms ${a} bytes recv)`)}),e.on("data",e=>{a+=e.byteLength}),this.protomuxWakeup.addStream(e),this.rootCorestore.replicate(e)}async _createInitialIdentity(){const t=e.generateMnemonic(),i=this.tasks.restoreIdentity(Pe,{mnemonic:t,recover:!1});await i.run()}async _loadIdentity(){let e=await this.local.get("@local/identity");if(e||await this._createInitialIdentity(),e=await this.local.get("@local/identity"),this.privateProfile)return;const t=await this.local.get("@local/rooms",{roomKey:e.privateProfileKey});t&&this.swarmWorker.startActiveSwarming(t.capabilities.swarmTopic),this.privateProfile=await this.internalOpenPrivateProfile({opening:!0}),this._shortenDeviceAttestations().catch(this.onerror),await this.internalRefreshUnreads()}async internalResyncPrivateProfile(){if(!this.privateProfile)return null;const e=[],t=[];for await(const s of this.privateProfile.db.find("@keet-private-id/rooms")){if(this.closing)return null;if(s.identitySwapV2)continue;if(this.internalIsRoomDisabled(s.roomKey))continue;const[o,a,r]=await Promise.all([this.local.get("@local/rooms",{roomKey:s.roomKey}),this.local.get("@local/writers",{mailbox:s.mailbox}),this.local.get("@local/room-preferences",{roomKey:s.roomKey})]);s.status.isActive?i(s,o,a)&&e.push(s):!o||r&&!r.status.isActive||t.push(s)}if(this.closing)return null;if(t.length>0){const e=await this.internalEnterLocalTransaction();try{for(const i of t){const t={roomKey:i.roomKey,status:i.status};await e.insert("@local/room-preferences",t);const s=await e.get("@local/rooms",t);s&&(s.preferences=t.status,await e.insert("@local/rooms",s))}await e.flush()}finally{await this.internalExitLocalTransaction()}}for(const t of e)this.tasks.joinRoomKeys(t.mailbox,{keys:t,activeClock:t.activeClock,isReadOnly:t.status.isReadOnly}).runBackground();for(const e of t)this.tasks.leaveRoom(e.mailbox,{roomKey:e.roomKey}).runBackground();return{joins:e.length,leaves:t.length};function i(e,t,i){if(!t)return!0;if(e.status.isReadOnly||t.status?.isWritable)return!1;if(!(e.initiator&&i&&v.equals(i.key,e.initiator.key))){if(!i||i.pending)return!0;if((i.activeClock||0)<(e.activeClock||0))return!0}return!!t.selfMember?.status.isActive&&!t.selfDevice?.status.isActive}}async _resyncPrivateProfileOnBoot(){if(this.readOnly||this.closing||!this.privateProfile)return;const[e,t]=await Promise.all([this.local.get("@local/identity"),this.local.get("@local/pending-recovery")]);!e||e.swapV2||t||await this.internalResyncPrivateProfile()}async _shortenDeviceAttestations(){const e=await this.local.get("@local/identity");if(!e)return;const i=this.privateProfile.engine.local.key,s=k.decode(t,e.deviceProof).chain.length;for await(const o of this.privateProfile.db.find("@keet-private-id/device-identities")){const a=v.equals(o.deviceKey,i),r=k.decode(t,o.deviceProof),n=r.chain.length,l=r.chain[n-1].publicKey;if(!a&&s+1<n){const t=Le(e,o.deviceKey,l);await this.privateProfile.dispatch("@keet-private-id/shorten-device-attestation",{deviceKey:o.deviceKey,deviceProof:t.deviceProof,writerProof:t.privateProfileIdentity.proof})}if(a&&k.decode(t,o.deviceProof).chain.length<s){const t=await this.internalEnterLocalTransaction();try{const i=await t.get("@local/identity");v.equals(i.publicKey,e.publicKey)&&(i.deviceProof=o.deviceProof,i.proofShortenedAt=Date.now(),await t.insert("@local/identity",i),await t.flush())}finally{await this.internalExitLocalTransaction()}}}}async internalDispatchUpgrade(e,t){if(!e||!t)return;const i=this.internalOpenExistingRoom(e);try{const e=this.batch(i.id);if(0===await e.dispatch("@keet/upgrade",{version:t}))return;if(t>=14){const s=await i.db.get("@keet/system-digest"),o="@keet/migrate-abi",a={header:{timestamp:e.timestamp},from:s?.abi.version,to:t,buildType:this.buildType},r=t<this.abi.min?this.abi.min:t,n=(await this.contractBundles.loadBundle(r)).encodeOperation(o,a);await e.append(n)}await e.flush()}finally{this.internalReleaseRoom(i)}}async _bumpCache(){if(!this.closing&&!0!==this.debugDisableCacheBump)try{if(!await this._cacheLock.lock())return;try{if(this.closing||!0===this.debugDisableCacheBump)return;await this._processCache()}finally{this._cacheLock.unlock()}}catch(e){this.onerror(e)}}async _processCache(){const e=[];for(;this._pendingTraces.length>0;){const t=this._pendingTraces.pop();e.push(this._updateCache(t))}const t=await Promise.all(e),i=await this.internalEnterLocalTransaction();try{for(const e of t)e&&await i.insert(e.collection,e.record);await i.flush()}finally{await this.internalExitLocalTransaction()}}async _updateCache({roomKey:e,collection:t,record:i}){if("@keet/members"===t){if(i?.profile.avatar){const t=this.internalOpenExistingRoom(e);try{await Y(t.db,t.blobs,i.profile.avatar)}catch{return null}finally{this.internalReleaseRoom(t)}}return{collection:"@local/members",record:i}}return"@keet/devices"===t?{collection:"@local/devices",record:{roomKey:e,device:i}}:null}_cacheRoomReads(e,t,i){this._pendingTraces.push({roomKey:e,collection:t,record:i}),this._bumpCache()}_maybeLogAutobeeApply(e,t,i,o,a){try{const r=s.encode(a),n=this.rooms.get(r),l=n?n.getQuickStats():null;this.logger.verboseDebug("[autobeeApply]",{"op.name":e.name,"op.id":e.id,dryRun:t,"nodes.length":i,abi:o,roomId:r,"roomStats.view":l?.view,"roomStats.system":l?.system,"roomStats.base":l?.base})}catch(e){console.error("Failed to log autobee apply",e)}}_autobeeTrace({type:e,value:t}){if("@keet/add-device"!==e)return;const{request:i,response:s,invitation:o}=t,a=o?.metadata.expiration;if(a>0&&a<Date.now())return;const r=i.member.profile.mailbox,n=i.keyPair;r&&n&&this._processAutobeeTrace(r,n,s).catch(this.onerror)}async _processAutobeeTrace(e,t,i){this.onlineBoot.opened||await this.onlineBoot.ready();const s=await this.local.get("@local/identity"),o=await this.local.get("@local/rooms",{roomKey:s.privateProfileKey});v.equals(e,o.capabilities.mailboxKeyPair.publicKey)||this.tasks.joinRoomResponse(t.publicKey,{mailbox:e,keyPair:t,response:i}).runBackground()}async _backgroundDrain(e){let t=await e.next();try{for(;!t.done&&!this.closing;){const i=await t.value;if(this.closing)return;t=await e.next(i)}}finally{!t.done&&e.return&&await e.return()}}async _safeLoadLegacyUnreads(){try{const e=[];for await(const t of this.local.find("@local/rooms")){const i=await this.local.get("@local/unreads",{roomKey:t.roomKey});i&&e.push(i)}return e}catch{return[]}}async*_migrateUnreadAnchors(){const e=yield this._safeLoadLegacyUnreads();try{const t=yield this.internalEnterLocalTransaction(),i=this.unreads.write(),s=Date.now();for(const{roomKey:o,count:a}of e)i.tryPut(o,{length:a+1,timestamp:s}),yield t.delete("@local/unreads",{roomKey:o});yield i.flush(),yield t.flush()}finally{yield this.internalExitLocalTransaction()}}async*_internalRefreshUnreads(){if(this.privateProfile&&(yield this.privateProfile.db.get("@keet/system-digest"))){yield this.privateProfile.internalEnsureUpgraded({opening:!0});try{if(!(yield this._unreadsLock.lock()))return;const e=[];let t=!0;const i=yield this.privateProfile.db.find("@keet-private-id/unreads-v2").toArray();for(const{deviceKey:s,key:o}of i)v.equals(s,this.privateProfile.engine.local.key)&&(t=!1),e.push(o);if(this.unreads&&function(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!v.equals(e[i],t[i]))return!1;return!0}(e,this.unreads.keys))return;this.unreads&&(yield this.unreads.close(),this.unreads=null);const s=this.privateProfile,o=s.engine.encryptionKey,a=this.store.namespace(s.key),r=a.namespace("keet-unreads");yield a.close();const n=yield s.engine.wakeupKey;this.unreads=new L(r,e,{blindPeering:this.blindPeering,encryptionKey:o,target:n}),this.unreads.on("remote-update",()=>this.emit("unread-anchors-changed")),yield this.unreads.ready(),this.emit("unread-anchors-changed"),t&&(yield this._backgroundDrain(this._migrateUnreadAnchors()),yield this.privateProfile.dispatch("@keet-private-id/add-unreads-key",{key:this.unreads.local.key}))}finally{this._unreadsLock.unlock()}}}internalRefreshUnreads(){return this._disableUnreadSync?Promise.resolve():this._backgroundDrain(this._internalRefreshUnreads())}async internalLoadDiscoveryCore(){try{const e=await this.privateProfile.db.get("@keet-private-id/identity");if(!e||!e.discoveryCoreKey||this.closing)return;if(this.discoveryCore)return;this.discoveryCore=this.store.get({key:e.discoveryCoreKey}),await this.discoveryCore.ready(),this.blindPeering.addCoreBackground(this.discoveryCore,{pick:3,priority:2})}catch(e){this.onerror(e)}}async internalCreateDiscoveryCore(e){const t=e.getProfileDiscoveryEncryptionKey(),i={version:2,signers:[{publicKey:e.profileDiscoveryKeyPair.publicKey}]};return this.discoveryCore&&await this.discoveryCore.close(),this.discoveryCore=this.store.get({keyPair:e.profileDiscoveryKeyPair,valueEncoding:le,encryptionKey:t,manifest:i}),await this.discoveryCore.ready(),this.blindPeering.addCoreBackground(this.discoveryCore,{pick:3,priority:2}),this.discoveryCoreSession=this.swarm.join(this.discoveryCore.discoveryKey,{server:!1,client:!0}),!0}async internalDryRun(e,t,i){const s=i.map((t,i)=>({length:e.engine.local.length+1+i,from:e.engine.local,value:t,heads:[],version:0}));return!!await e.engine.dryRun(s,t)}internalGetHeads(e,t){const i=[];let s=!1;if(t)for(const o of t.engine.heads())e&&v.equals(o.key,e.key)?(s=!0,i.push({key:o.key,length:Math.max(o.length,e.length)})):i.push(o);return e&&!s&&i.push(e),i}async internalGetKeyPair(e){const t=await this.local.get("@local/writers-by-room-key",{roomKey:e});return t?t.pending?null:t.keyPair:null}async internalEnsureWriter(e,t,{rotate:i=!1,activeClock:s=0}={}){let o=null;if(!i){const i=await this.local.get("@local/writers",{mailbox:t});if(i&&i.roomKey&&v.equals(i.roomKey,e))return i;o=i}if(o)o.roomKey=e;else{const i=f.keyPair(),a=this.store.get({keyPair:i});await a.ready(),o={keyPair:i,key:a.key,mailbox:t,responseKeyPair:null,roomKey:e,pending:!0,activeClock:s},await a.close()}const a=await this.internalEnterLocalTransaction();try{await a.insert("@local/writers",o),await a.flush()}finally{await this.internalExitLocalTransaction()}return o}async internalGetMailbox(e){const t=await this.local.get("@local/rooms",{roomKey:e});if(t)return{key:t.capabilities.mailboxKeyPair.publicKey,discoveryKey:t.capabilities.wakeupTopic};const i=await this.local.get("@local/writers-by-room-key",{roomKey:e});return i?{key:i.mailbox,discoveryKey:j(i.mailbox)}:null}async internalGetEncryptionKey(e){const t=await this.local.get("@local/rooms",{roomKey:e});return!t||t.status.isRemoved?null:t.encryptionKey}getAutobeeMigrationInfo(e){return this.local.get("@local/autobee-migrations",{roomKey:e})}internalReleaseRoom(e){if(0===e.refs)throw new Error("Cannot release a room that was not previously opened");e.refs-=1}internalOpenExistingRoom(e,t={}){return this.internalOpenRoom(s.decode(e),null,t)}async internalOpenPrivateProfile({opening:e=!1}={}){e||this.onlineBoot.opened||await this.onlineBoot.ready();const t=await this.local.get("@local/identity"),i=this.internalOpenExistingRoom(t.privateProfileKey,{bigBatches:!0,priority:2});return await i.ready(),this.privateProfile&&v.equals(i.key,this.privateProfile.key)||(this.privateProfile&&this.internalReleaseRoom(this.privateProfile),this.privateProfile=this.internalOpenExistingRoom(t.privateProfileKey,{bigBatches:!0,priority:2}),this.unreadsLoading=this.internalRefreshUnreads().catch(()=>null)),this.internalLoadDiscoveryCore(),i}async internalSafeSwapPrivateProfiles(){try{const e=await this.internalOpenPrivateProfile();this.internalReleaseRoom(e)}catch(e){this.onerror(e)}}async internalFeatureSupported(e,t){const i=s.decode(e),o=await this.local.get("@local/rooms",{roomKey:i});return!!o&&this.versions.isFeatureSupported(o.digest.abi.version,t)}internalOpenRoom(e,t,{bootFrom:i,mailbox:o,keyPair:a,bigBatches:r,priority:n=1}={}){if(this.closing)throw new Error("Keet is closing");const l=s.encode(e),c=this.rooms.get(l);if(c)return c.idleTicks=0,c.refs+=1,c;const h=f.discoveryKey(e),d=this.store.namespace(h);let y=null,u=null,m=null;o||(u=this.internalGetMailbox(e),u.catch(this.onerror)),a||(y=this.internalGetKeyPair(e),y.catch(this.onerror)),t||(m=this.internalGetEncryptionKey(e),m.catch(this.onerror)),o&&(o={key:o,discoveryKey:f.discoveryKey(o)});const p={backoff:this.backoff,encryptionKey:t||m,wakeupCapability:o||u,keyPair:a||y,fastForward:!this.debug.disableFastForward&&{boot:i},ackThreshold:this.ackThreshold,ackInterval:this.ackInterval,wakeup:this.protomuxWakeup,optimistic:!0,encrypted:!0,bigBatches:!!r,priority:n},g=Te.create(this,d,l,e,h,p);return this.rooms.set(l,g),g.refs+=1,g}async updateDevice({name:e,deviceId:t}={}){this.onlineBoot.opened||await this.onlineBoot.ready();const i={swarmKey:this.swarm.keyPair.publicKey,name:e,isMobile:this.isMobile},o=await this.internalOpenPrivateProfile();try{if(t&&!v.equals(s.decode(t),o.deviceKey)){if(!await o.dispatch("@keet/update-device",{key:s.decode(t),profile:{name:e}}))throw me.UPDATE_DEVICE_FAILED("Failed to update device",{deviceId:t})}else await o.dispatch("@keet/update-device",{profile:i})}finally{this.internalReleaseRoom(o)}}async internalUpdateProfile(e,{forceUpdateRegistry:t=!1,opening:i=!1}={}){const s=await this.internalGetIdentityInfo({opening:i});if(this.closing)return;if(this._rejectAnonymousProfiles&&!e.displayName&&!t)throw new Error("A member must have a profile name");const o=this.internalCreateMemberUpdate(s,{profile:e}),a=await this.internalOpenPrivateProfile({opening:i});if(this.closing)return;let r=null;try{r=await a.dispatch("@keet/update-member",{member:o})}finally{this.internalReleaseRoom(a)}(r||t)&&o.profile.username&&this.userRegistry?.internalUpdateRegistryMember(o)}async updateProfile(e={}){return this.onlineBoot.opened||await this.onlineBoot.ready(),this.internalUpdateProfile(e)}async internalVerifyOptimisticCore(e){return!await e.getUserData("referrer")}async internalAppendOptimisticOperation(e,t){const i=this.store.get({key:e,exclusive:!0});await i.ready();try{if(!await this.internalVerifyOptimisticCore(i))return!1;if(0!==i.length)return!1;const{length:e}=await i.append(t,{maxLength:1});return 1===e}finally{await i.close()}}async internalCreateRoom(e={}){const t=e.seed||f.randomBytes(32),i=e.keyPair||f.keyPair(),s=e.encryptionKey||f.randomBytes(32),o=F(i.publicKey),a=f.discoveryKey(o),r=$(o,t),n=r.mailboxKeyPair.publicKey,l=await this.internalEnterLocalTransaction();try{await l.insert("@local/writers",{mailbox:n,keyPair:i,key:o,roomKey:o}),await l.flush()}finally{await this.internalExitLocalTransaction()}const c={header:{timestamp:Date.now()},digest:{abi:{version:this.isExperimental?this.abi.production:this.abi.autoupgrade},creationTime:Date.now(),settings:{roomType:1,...e.settings,isExperimental:this.isExperimental,buildType:this.buildType}},capabilities:{seed:t},config:e.config,identity:e.identity,initialMembers:e.initialMembers,bootstrapDevice:e.bootstrapDevice},h=this.tasks.createRoom(a,{roomKey:o,encryptionKey:s,mailbox:n,keyPair:i,genesis:c,isPrivateProfile:!!e.isPrivateProfile});return await h.run(),this.discovery&&this.discovery.subscribe(r.discoveryKeyPair.publicKey,{since:Date.now()}),this.swarmWorker.refresh().catch(De),this.internalOpenExistingRoom(o)}async createRoom(e){this.opened||await this.ready();const t=await this.internalCreateRoom(e);return this.internalReleaseRoom(t),t.key}async leaveRoom(e){this.onlineBoot.opened||await this.onlineBoot.ready();const t=await this.local.get("@local/identity"),i=this.internalOpenExistingRoom(e);await i.ready();try{await i.dispatch("@keet/remove-member",{key:t.publicKey})}catch(e){this.onerror(e)}finally{this.internalReleaseRoom(i)}await this.privateProfile.dispatch("@keet-private-id/update-room-status",{roomKey:e,key:Q.IsActive,status:{isActive:!1}})}async activateRoom(e){if(this.closing)return;const t=await this.local.get("@local/rooms",{roomKey:e});if(!t||this.closing)return;const i=this.internalOpenExistingRoom(e);this.activeRooms.has(i)?this.internalReleaseRoom(i):(this.activeRooms.add(i),this.swarmWorker.startActiveSwarming(t.capabilities.swarmTopic),await i.ready())}async deactivateRoom(e){const t=this.internalOpenExistingRoom(e);if(!this.activeRooms.has(t))return void this.internalReleaseRoom(t);const i=await this.local.get("@local/rooms",{roomKey:e});this.activeRooms.delete(t),this.swarmWorker.stopActiveSwarming(i.capabilities.swarmTopic),this.internalReleaseRoom(t),this.internalReleaseRoom(t)}async internalGetIdentityInfo({opening:e=!1}={}){e||this.onlineBoot.opened||await this.onlineBoot.ready();const t=await this.local.get("@local/identity");if(!t)throw new Error("Identity does not exist");const i=await this.local.get("@local/rooms",{roomKey:t.privateProfileKey});if(!i)throw new Error("Private profile does not exist");return{identity:t,privateProfile:i}}internalGetMemberUpdate(e,{profile:t}={}){const i=e.privateProfile;return i?.selfMember?i.selfMember.proofs?{profile:i.selfMember.profile,attestation:{memberKey:i.selfMember.key,proof:i.selfMember.proofs.profileAttestation}}:this.internalCreateMemberUpdate(e):null}internalAttestData(t,i){return e.attestData(t,i.deviceKeyPair,i.deviceProof)}internalCreateDeviceUpdate(e,t,{isPrivateProfile:i=!1,buildType:s=null}={}){const o=e.identity;let a=null;e.privateProfile?.selfDevice&&i&&(a=e.privateProfile.selfDevice.profile.name);const r=e.privateProfile?.digest.settings.buildType,n=ce.Production===r;return{profile:{swarmKey:this.swarm.keyPair.publicKey,name:a,isMobile:this.isMobile,buildType:n&&null===s?null:r},attestation:{memberKey:o.publicKey,proof:this.internalAttestData(t,o)}}}internalCreateMemberUpdate(t,{profile:i}={}){const s=t.privateProfile?.selfMember?.profile||null,o=t.privateProfile?.capabilities.mailboxKeyPair.publicKey||i.mailbox,a=t.identity,r={...s,...i,mailbox:o,timestamp:Date.now()},n=oe("@keet/member-profile",r);return{profile:r,attestation:{memberKey:a.publicKey,proof:e.attestData(n,a.deviceKeyPair,a.deviceProof)}}}internalGetLinkInfo(e){try{return this.internalDecodeInvitation(e)}catch{}try{return this.internalDecodeContactInfo(e)}catch{}return null}internalDecodeInvitation(e){try{const t="string"==typeof e?b.decode(e):e;return ae("@keet/sendable-invitation",t)}catch{throw me.INVALID_INVITE(`Invalid invite: ${e}`)}}internalDecodeContactInfo(e){try{const t=v.isBuffer(e)?e:v.from(e,"base64");return ae("@keet/member-contact-info",t)}catch{throw me.INVALID_CONTACT_INFO(`Invalid contact info: ${e}`)}}internalEncodeContactInfo(e){return oe("@keet/member-contact-info",e)}internalCreateContactInfoStruct(t,i,s={}){const o={...i.selfMember.profile,...s},a=oe("@keet/member-profile",o),r={profile:o,attestation:{memberKey:i.selfMember.key,proof:e.attestData(a,t.deviceKeyPair,t.deviceProof)}};return this.internalEncodeContactInfo(r)}async wakeup(){this.state=ve.WAKEUP,this.internalVerboseLog("[Keet Core]","await .ready"),this.opened||await this.ready();const e=[this.resume(),this.swarmWorker.background()];this.internalVerboseLog("[Keet Core]","await all promise"),await Promise.allSettled(e),this.internalVerboseLog("[Keet Core]","promise settled")}async presuspend(){this.state=ve.PRESUSPEND;const e=Date.now();this.opened||await this.ready(),this.swarmWorker.setServerMode(!1),this.internalVerboseLog("[Keet Core]",`presuspend done elapsed=${Date.now()-e}ms`)}async suspend(){if(this.internalVerboseLog("[Keet Core]","suspend called"),this.state===ve.SUSPEND)return;this.state=ve.SUSPEND,this.opened||await this.ready(),this.internalVerboseLog("[Keet Core]","suspend post ready");const e=Date.now(),t=(t,i)=>i.finally(()=>{this.internalVerboseLog("[Keet Core]",`suspend settled ${t} elapsed=${Date.now()-e}ms`)}),i=[t("dhtCache",this._flushDHTCache())];this.blindPeering&&(this.internalVerboseLog("[Keet Core]","suspend adding blind peering"),i.push(t("blindPeering",this.blindPeering.suspend()))),this.push&&(this.internalVerboseLog("[Keet Core]","suspend push"),i.push(t("push",this.push.suspend()))),this.discovery&&(this.internalVerboseLog("[Keet Core]","suspend discovery"),i.push(t("discovery",this.discovery.suspend()))),this.bluetooth&&(this.internalVerboseLog("[Keet Core]","suspend bluetooth"),i.push(t("bluetooth",this.bluetooth.suspend()))),await Promise.allSettled(i),this.internalVerboseLog("[Keet Core]","all done"),await this.rpcClient.suspend(),this.internalVerboseLog("[Keet Core]","rpc suspended"),this.activeCall&&await this.activeCall.suspend(),this.internalVerboseLog("[Keet Core]","active call suspend");const s=this.swarm.connections.size;this.internalVerboseLog("[Keet Core]",`suspending swarm connections=${s}`);const o=Date.now();await this.swarm.suspend(),this.internalVerboseLog("[Keet Core]","swarm suspend"),this.internalVerboseLog("[Keet Core]",`swarm suspended elapsed=${Date.now()-o}ms connections=${this.swarm.connections.size}`),await this.files.server.suspend(),this.internalVerboseLog("[Keet Core]","files suspend"),await this.store.suspend({log:this.internalVerboseLog.bind(this)}),this.internalVerboseLog("[Keet Core]","store suspended, all done")}async resume(){if(this.internalVerboseLog("[Keet Core]","resume called"),this.state===ve.RESUME)return;this.state=ve.RESUME,this.internalVerboseLog("[Keet Core]","await this.ready"),this.opened||await this.ready(),this.internalVerboseLog("[Keet Core]","resume store"),await this.store.resume(),this.internalVerboseLog("[Keet Core]","resume file server"),await this.files.server.resume(),this.internalVerboseLog("[Keet Core]","resume swarm"),this.readOnly||await this.swarm.resume(),this.internalVerboseLog("[Keet Core]","resume active call"),this.activeCall&&!this.readOnly&&await this.activeCall.resume(),this.internalVerboseLog("[Keet Core]","resume rpc client"),await this.rpcClient.resume();const e=[];this.blindPeering&&!this.readOnly&&e.push(this.blindPeering.resume()),this.push&&e.push(this.push.resume()),this.discovery&&e.push(this.discovery.resume()),this.bluetooth&&!this.readOnly&&e.push(this.bluetooth.resume()),this.swarmWorker.setServerMode(!0),e.push(this.swarmWorker.unbackground()),this.internalVerboseLog("[Keet Core]","await all promises"),await Promise.allSettled(e),this.internalVerboseLog("[Keet Core]","all promises settled")}async _createInvitation(e,t){let{expiration:i=0,canAdmin:s=!1,canModerate:o=!1,identityPublicKey:a=null,requiresConfirmation:r=!1,readOnly:n=!1}=t;if("string"==typeof i)if("2h"===i)i=Date.now()+72e5;else if("2d"===i)i=Date.now()+1728e5;else{if("2w"!==i)throw me.UNKNOWN_EXPIRATION(`Unknown expiration: ${i}`,{roomKey:e.key});i=Date.now()+12096e5}await e.ready();const[{seed:l},c,h]=await Promise.all([e.db.get("@keet/room-capabilities"),z(e.db,e.deviceKey),e.db.get("@keet/system-digest")]);if((o||s)&&!c?.status.isModerator)throw me.MODERATORS_ONLY("Only moderators can create moderator invitations",{roomKey:e.key});const d=$(e.key,l),y=this.swarm.dht.toArray({limit:3}),u=await e.internalGetBootFrom();if(n)return oe("@keet/sendable-invitation",{"readonly-v2":{roomKey:e.key,encryptionKey:e.encryptionKey,seed:l,bootFrom:u},additionalNodes:y});const m={key:e.key,encryptionKey:e.encryptionKey,bootFrom:u},{invitation:p,seed:g}=H(m,{requiresConfirmation:r,expiration:i,canModerate:o,canAdmin:s});await e.dispatch("@keet/add-invitation",{invitation:p});const w=(await e.db.get("@keet/invitations",{id:p.id})).anchor,f=d.mailboxKeyPair.publicKey,b={identity:null,room:null,contact:null,additionalNodes:y,buildType:h.settings.buildType};return a?b.identity={mailbox:f,invitationSeed:g,anchor:w,identityPublicKey:a}:b.room={mailbox:f,invitationSeed:g,anchor:w},oe("@keet/sendable-invitation",b)}async createRoomInvitation(e,t={}){this.opened||await this.ready();const i=s.decode(e),o=this.internalOpenExistingRoom(i);try{const e=await this._createInvitation(o,t);return b.encode(e)}finally{this.internalReleaseRoom(o)}}async createIdentityInvitation(){this.onlineBoot.opened||await this.onlineBoot.ready();const e=await this.local.get("@local/identity"),t=this.internalOpenExistingRoom(e.privateProfileKey);this.blindPeering.addAutobaseBackground(t.engine.auto,{priority:2});try{const i=await this._createInvitation(t,{expiration:"2h",canAdmin:!0,canModerate:!0,requiresConfirmation:!0,identityPublicKey:e.publicKey});return b.encode(i)}finally{this.internalReleaseRoom(t)}}async _startPairing(e,{deviceKeyPair:t,buildType:i=null}={}){this.onlineBoot.opened||await this.onlineBoot.ready();const o=W(e.invitationSeed),a=e.invitationSeed,r=e.mailbox,n=e.anchor,l={key:null,seedId:s.encode(a)},c=await this.local.get("@local/rooms-by-mailbox",{capabilities:{mailboxKeyPair:{publicKey:r}}});let h=null;if(c){if(c.selfMember?.status.isRemoved)throw me.MEMBER_REMOVED("Removed member cannot rejoin");h=await this.local.get("@local/room-preferences",{roomKey:c.roomKey})}if(c?.status.isWritable&&h&&h.status.isActive&&!h.status.isReadOnly)return l.key=s.encode(c.roomKey),l;const d=f.keyPair(),y=await this.store.createKeyPair(J(d.publicKey)),u=this.store.get({keyPair:y,active:!1});await u.ready();const m={key:u.key,length:1};await u.close();let p=null;t&&(p={writerKey:u.key,publicKey:e.identityPublicKey,devicePublicKey:t.publicKey});const g={id:o,mailbox:r,inviter:n,identity:p,initiator:m,responseKeyPair:d,invitationSeed:a,buildType:i},w=await this.privateProfile.db.find("@keet-private-id/pending-invitations").toArray();for(const e of w)v.equals(e.mailbox,g.mailbox)&&await this.privateProfile.dispatch("@keet-private-id/remove-pending-invitation",e);return await this.privateProfile.dispatch("@keet-private-id/add-pending-invitation",{invitation:g}),l}async _openReadOnlyRoom({roomKey:e,encryptionKey:t,seed:i,fastForwardTo:o,bootFrom:a}){this.onlineBoot.opened||await this.onlineBoot.ready();const{mailboxKeyPair:r,swarmTopic:n}=$(e,i);!a&&o&&(a={key:o,length:0}),await this.internalEnsureWriter(e,r.publicKey);const l=this.internalOpenRoom(e,t,{mailbox:r.publicKey,bootFrom:q.getBootOption(a,o)});return this.swarmWorker.startDiscoverySwarming(n,{roomId:s.encode(e)}),await l.ready(),await this.privateProfile.dispatch("@keet-private-id/add-room-v2",{roomKey:e,encryptionKey:t,mailbox:r.publicKey,bootFrom:a,isReadOnly:!0}),{key:s.encode(e),seedId:s.encode(i)}}async startPairingRoom(e,t){this.onlineBoot.opened||await this.onlineBoot.ready();const i=this.internalDecodeInvitation(e),s=await this.local.get("@local/rooms",{roomKey:this.privateProfile.key}),o=i.buildType,a=s.digest.settings.buildType||ce.Production;if(o&&o!==a)throw me.INVALID_BUILD_TYPE();const r=i.readonly||i["readonly-v2"];if(r)return this._openReadOnlyRoom(r);if(!i.room)throw me.INVALID_INVITATION_TYPE("Invalid room invitation");return this._startPairing(i.room,{...t,buildType:o})}async startPairingIdentity(e){this.onlineBoot.opened||await this.onlineBoot.ready();const t=this.internalDecodeInvitation(e),i=await this.local.get("@local/rooms",{roomKey:this.privateProfile.key}),s=t.buildType,o=i.digest.settings.buildType||ce.Production;if(s&&s!==o)throw me.INVALID_BUILD_TYPE();if(!t.identity)throw me.INVALID_INVITATION_TYPE("Invalid device sync invitation");const a=G(t.identity.identityPublicKey),r=await this.store.createKeyPair(a);return this._startPairing(t.identity,{deviceKeyPair:r,buildType:s})}async stopPairing(e){this.opened||await this.ready();const t=await this.internalOpenPrivateProfile();try{if(!await t.db.get("@keet-private-id/pending-invitations",{id:e}))return;await t.dispatch("@keet-private-id/remove-pending-invitation",{id:e})}finally{this.internalReleaseRoom(t)}}async rotateWriter(e){this.onlineBoot.opened||await this.onlineBoot.ready();const[t,i,s]=await Promise.all([this.local.get("@local/writers-by-room-key",{roomKey:e}),this.local.get("@local/rooms",{roomKey:e}),this.privateProfile.db.get("@keet-private-id/rooms",{roomKey:e})]);i&&t&&s&&(await this.internalEnsureWriter(e,s.mailbox,{rotate:!0,activeClock:s.activeClock}),this.tasks.joinRoomKeys(s.mailbox,{keys:s,activeClock:s.activeClock,isReadOnly:s.status.isReadOnly}).runBackground())}async getRecoveryPhrase(){this.onlineBoot.opened||await this.onlineBoot.ready();const e=(await this.local.get("@local/identity")).entropy;return e?E({entropy:e}):null}async getRecoveryEntropy(){return this.onlineBoot.opened||await this.onlineBoot.ready(),(await this.local.get("@local/identity")).entropy||null}async getEncryptedRecoveryPhrase(e){if("string"!=typeof e)throw new Error("Password required");if(0===e.length)throw new Error("Password should not be empty");const t=await this.getRecoveryEntropy();if(!t)throw new Error("Recovery phrase reading failed");if(0===t.length)throw new Error("Recovery phrase reading failed");return S.encryptEntropy(t,e)}decryptEncryptedRecoveryPhrase(e,t){if(!ArrayBuffer.isView(e))throw new Error("Encrypted phrase should be an ArrayBuffer view");if(0===e.byteLength)throw new Error("Encrypted phrase should not be empty");if("string"!=typeof t)throw new Error("Password required");if(0===t.length)throw new Error("Password should not be empty");const i=S.decryptEntropy(e,t),s=E({entropy:i});return S.free(i),s}freeRecoveryPhrase(e){S.free(e)}async storeRecoveryPhrase(t){this.onlineBoot.opened||await this.onlineBoot.ready();const i=await e.from({mnemonic:t}),s=await this.local.get("@local/identity"),o=await this.local.get("@local/rooms",{roomKey:s.privateProfileKey});if(!v.equals(s.publicKey,i.identityPublicKey))throw new Error("Wrong recovery phrase");if(!o.identity.discoveryCoreKey){if(await this.internalCreateDiscoveryCore(i),this.discoveryCore.length>0){const e=Math.floor((Date.now()-1711547109544)/1e3);await this.discoveryCore.truncate(this.discoveryCore.length,e)}await this.discoveryCore.append({version:1,timestamp:Date.now(),key:o.roomKey,mailbox:o.capabilities.mailboxKeyPair.publicKey}),await this.privateProfile.dispatch("@keet-private-id/update-identity",{identity:{publicKey:i.identityPublicKey,discoveryCoreKey:this.discoveryCore.key}})}}async confirmRecoveryPhrase({persist:e=!1}={}){this.onlineBoot.opened||await this.onlineBoot.ready();const t=await this.internalEnterLocalTransaction();try{const i=await t.get("@local/identity");e||(i.entropy=null),i.status.isConfirmed=!0,await t.insert("@local/identity",i),await t.flush()}finally{await this.internalExitLocalTransaction()}this.emit("identity-changed")}async restoreIdentity(t,{create:i=!0}={}){this.onlineBoot.opened||await this.onlineBoot.ready();const[s]=await Promise.all([this.local.get("@local/identity"),e.from({mnemonic:t})]),o=f.discoveryKey(s.privateProfileKey),a=this.tasks.restoreIdentity(o,{mnemonic:t,recover:!1===i,profileDiscoveryTimeout:this._profileDiscoveryTimeout,buildType:this.buildType});await a.run();const r=await this.local.get("@local/identity"),n=await this.local.get("@local/rooms",{roomKey:r.privateProfileKey});this.privateProfile=await this.internalOpenPrivateProfile(),this.swarmWorker.startActiveSwarming(n.capabilities.swarmTopic)}async acceptJoinRequest(e,t){this.onlineBoot.opened||await this.onlineBoot.ready();const i=this.internalOpenExistingRoom(e);try{const s=await i.db.get("@keet/join-requests",{deviceKey:t});if(!s)return;const o=s.request;let a=null;if(o.identity){const i=await this.local.get("@local/identity");if(!v.equals(i.privateProfileKey,e))throw new Error("Accepting an identity device join request on a room that is not your private profile");a=Le(i,t,o.identity.devicePublicKey)}await i.dispatch("@keet/accept-join-request",{deviceKey:t,identity:a})}finally{this.internalReleaseRoom(i)}}async rejectJoinRequest(e,t){this.opened||await this.ready();const i=this.internalOpenExistingRoom(e);try{if(!await i.db.get("@keet/join-requests",{deviceKey:t}))throw new Error("Join request for that device key does not exist");await i.dispatch("@keet/reject-join-request",{deviceKey:t})}finally{this.internalReleaseRoom(i)}}async _sendContactRequest(e){this.onlineBoot.opened||await this.onlineBoot.ready();const t=await this.internalOpenPrivateProfile();try{this.tasks.sendContactRequest(e.memberKey,e).runBackground()}finally{this.internalReleaseRoom(t)}}async sendContactRequestFromContact(e,{message:t}){const i=(e=this.internalDecodeContactInfo(e)).attestation.memberKey,s=e.attestation.memberKey;return this._sendContactRequest({roomKey:i,memberKey:s,message:t,contactInfo:e})}async sendContactRequest(e,t,{message:i}){return this._sendContactRequest({roomKey:e,memberKey:t,message:i})}async addContact(t,i,{alias:s}={}){if(this.onlineBoot.opened||await this.onlineBoot.ready(),!i)throw me.INVALID_CONTACT_INFO();try{const{profile:o,attestation:a}=this.internalDecodeContactInfo(i),r=oe("@keet/member-profile",o),n=e.verify(a.proof,r,{expectedIdentity:t});if(!n?.receipt)throw me.INVALID_CONTACT_INFO();const l={memberKey:t,mailbox:o.mailbox,status:{isActive:!0,isBlocked:!1},contactInfo:{profile:o,attestation:a}};s&&(l.alias=s),await this.privateProfile.dispatch("@keet-private-id/add-contact",{contact:l})}catch(e){this.onerror(e)}}async setContactAlias(e,t){this.onlineBoot.opened||await this.onlineBoot.ready(),await this.privateProfile.dispatch("@keet-private-id/update-contact-alias",{memberKey:e,alias:t})}async removeContact(e){this.onlineBoot.opened||await this.onlineBoot.ready();const t=await this.privateProfile.db.get("@keet-private-id/contacts",{memberKey:e});t&&await this.privateProfile.dispatch("@keet-private-id/add-contact",{contact:{memberKey:e,mailbox:t.mailbox,status:{...t.status,isActive:!1},contactInfo:t.contactInfo}})}async blockContact(e){this.onlineBoot.opened||await this.onlineBoot.ready();const[t,i,s]=await Promise.all([this.privateProfile.db.findOne("@keet-private-id/contact-requests-by-member",{gte:{memberKey:e},lte:{memberKey:e}}),this.privateProfile.db.get("@keet-private-id/contacts",{memberKey:e}),this.local.get("@local/members",{key:e})]),o=i?.mailbox||s?.profile.mailbox||t?.sender?.mailbox;if(!o)throw new Error("Cannot find contact");const a={memberKey:e,mailbox:o,status:{...i?.status,isBlocked:!0},contactInfo:i?.contactInfo};await this.privateProfile.dispatch("@keet-private-id/add-contact",{contact:a})}async unblockContact(e){this.onlineBoot.opened||await this.onlineBoot.ready();const[t,i,s]=await Promise.all([this.privateProfile.db.findOne("@keet-private-id/contact-requests-by-member",{gte:{memberKey:e},lte:{memberKey:e}}),this.privateProfile.db.get("@keet-private-id/contacts",{memberKey:e}),this.local.get("@local/members",{key:e})]),o=i?.mailbox||s?.profile.mailbox||t?.sender?.mailbox;if(!o)throw new Error("Cannot find contact");const a={memberKey:e,mailbox:o,status:{...i?.status,isBlocked:!1},contactInfo:i?.contactInfo};await this.privateProfile.dispatch("@keet-private-id/add-contact",{contact:a})}async _flushDHTCache(){if(this.readOnly)return;const e=this.swarm.dht.toArray({limit:64});try{await this._setCachedDHTNodes(e)}catch(e){this.onerror(e)}}async getDHTSettings(){const e=await this.local.get("@local/hyperdht")||{};return{nodes:e.nodes||[],concurrency:e.concurrency||Z.concurrency,maxWindow:e.maxWindow||Z.maxWindow,randomPunchInterval:e.randomPunchInterval||Z.randomPunchInterval,connectionKeepAlive:e.connectionKeepAlive||Z.connectionKeepAlive}}async getSwarmSettings(){return{maxPeers:(await this.local.get("@local/hyperswarm")||{}).maxPeers||ee.maxPeers}}async _setCachedDHTNodes(e){const t=await this.internalEnterLocalTransaction();try{const i={...await this.getDHTSettings(),nodes:e};await t.insert("@local/hyperdht",i),await t.flush()}finally{await this.internalExitLocalTransaction()}}batch(e){return new Re(this,e)}async dispatch(e,t,i){this.opened||await this.ready();const s=this.internalOpenExistingRoom(e);try{return await s.dispatch(t,i)}catch(e){this.onerror(e)}finally{this.internalReleaseRoom(s)}}async dispatchBatch(e,t){this.opened||await this.ready();const i=this.internalOpenExistingRoom(e);try{await i.dispatchBatch(t)}finally{this.internalReleaseRoom(i)}}async selfDestruct({confirm:e}={}){if("do not go gentle into that good night"!==e)throw new Error("Must confirm self destruction");await this.ready(),await this.close();const t=Math.random().toString(16).slice(2),i=K.join(this.dir,"gc",t);try{await P.promises.mkdir(i,{recursive:!0})}catch{}for(const e of["cores","db","cache","app-references"])try{await P.promises.rename(K.join(this.dir,e),K.join(i,e))}catch{}await P.promises.rm(i,{recursive:!0})}_handleError(e,t={}){const i=this.errorManager.normalize(e,t);this.errorManager.add(i),this.logger.error(i),this._onerror(i)}static from(e,t){const i=C.migrate(e),s=i.active()||i.create({name:"default"});i.gc({delay:ke});const o=new this(s.storage,{...t,logout:async()=>{i.remove(s),await new Promise(e=>setTimeout(e,1e3)),await o.close(),i.gc({delay:ke})}});return{profiles:i,keet:o}}static registerRPC(e,t,i){return new B(e,t,i)}};
@holepunchto/keet-core/lib/api/v1/helpers.js +1 -1
……@@ -1 +1 @@
1const{encodeChatMessage:e,encodeReactionsDigest:t,encodeMyReactions:s}=require("./encode"),{getMemberForDeviceKey:n}=require("../../core/contract/query"),a=require("b4a");async function i({roomKey:e,local:n,snapshot:a,room:i,oplog:l,msgId:o}){const[r,c]=await Promise.all([o?{id:o}:a.get("@keet/chat-by-message-id",{oplog:l}),i||n.get("@local/rooms",{roomKey:e})]);if(!r||!c)return null;const{selfMember:m}=c,[u,y]=await Promise.all([a.get("@keet/reaction-digests",{id:r.id}),m?a.find("@keet/reactions",{gte:{id:r.id,sender:m.key},lte:{id:r.id,sender:m.key}}).toArray():[]]);return{digest:t(u),mine:s(y)}}async function l({snapshot:e,msgId:t,localRoom:s}){if(!t||!s)return null;const{selfMember:n}=s,[a,i]=await Promise.all([e.get("@keet/chat-label-digests",{id:t}),n?e.find("@keet/chat-labels",{gte:{id:t,sender:n.key},lte:{id:t,sender:n.key}}).toArray():[]]);return a&&{digest:a,mine:i}}function o({dm:e,readLengths:t,selfMember:s},n){return!!(e?.length&&n&&t?.length&&s)&&!!t.find(e=>!a.equals(e.memberKey,s.key)&&n.index<e.length)}async function r(t,s,a,r,c,u){const y=n(s,u.oplog.key),{filePromises:d,linkFilePromises:f}=function(e,t,s,n,a){const i=[],l=[];if(a.message?.files?.length>0)for(const l of a.message.files)i.push(m(e,n,t,s,l));const o=a.message?.display?.httpLink||[];for(const e of o)c(e);const r=a.message?.display?.pearLink||[];for(const e of r)c(e);return{filePromises:i,linkFilePromises:l};function c(a){if((a?.preview?.files||[]).length){const i=a.preview.files.map(async i=>{a.preview.file=await m(e,n,t,s,i)});l.push(...i)}}}(t,s,a,c,u),[g,b,h,k]=await Promise.all([y,Promise.all(d),i({snapshot:s,room:r,msgId:u.id}),l({snapshot:s,localRoom:r,msgId:u.id}),Promise.all(f)]);return u.reactions=h,b.length&&(u.message.files=b),u.read=o(r,u.id),e({record:u,labels:k,member:g,localRoom:r})}async function c(e,t,s){if(e.bee){const s=await t.get("@keet/blobs",e.bee);return s?s.data:null}return e.blob&&s?s.get(e.blob):null}async function m(e,t,s,n,a){const i=await s.get("@keet/files",{id:a});if(!i)return null;const l=await t.getFileEntryWithPreview(e,i.file,{loadBlob:e=>c(e,s,n)});return{...i.file,entry:l}}function u(e){return async function(e){return{...e,members:await t(e)}};async function t({callKey:t}){return y(e.find("@keet/call-members",{gte:{callKey:t},lte:{callKey:t}}),async e=>({...e,devices:await s(e)}))}async function s({callKey:t,memberKey:s}){const a={gte:{callKey:t,memberKey:s},lte:{callKey:t,memberKey:s}};return y(e.find("@keet/call-devices-by-member-key",a),async e=>({...e,streams:await n(e)}))}async function n({callKey:t,deviceKey:s}){const n={gte:{callKey:t,deviceKey:s},lte:{callKey:t,deviceKey:s}};return y(e.find("@keet/call-streams-by-device-key",n),async t=>{const s=await e.get("@keet/call-stream-statuses",{statusKey:t.statusKey});return{...t,muted:!!s&&s.muted}})}}async function y(e,t){const s=[];for await(const n of e)s.push(t(n));return Promise.all(s)}module.exports={getChatMessages:async function(e,t,s,n,a,i){const[l,o]=await Promise.all([s.get("@local/rooms",{roomKey:t}),e()]);if(!o||!l)return[];const c=Array.isArray(o)?o:[o],m=[];for(const e of c)m.push(r(t,n,a,l,i,e));return Promise.all(m)},getReactions:i,getChatLabels:l,getChatMessage:r,getCalls:async function(e,t){const s=u(e);return y(e.find(t),s)},getCall:async function(e,t){const s=u(e),n=await e.findOne(t);return n?s(n):null},isDMRead:o,loadBlob:c,parallel:y};
1const{encodeChatMessage:e,encodeReactionsDigest:t,encodeMyReactions:s}=require("./encode"),{getMemberForDeviceKey:n}=require("../../core/contract/query"),a=require("b4a");async function i({roomKey:e,local:n,snapshot:a,room:i,oplog:r,msgId:o}){const[l,c]=await Promise.all([o?{id:o}:a.get("@keet/chat-by-message-id",{oplog:r}),i||n.get("@local/rooms",{roomKey:e})]);if(!l||!c)return null;const{selfMember:u}=c,[d,m]=await Promise.all([a.get("@keet/reaction-digests",{id:l.id}),u?a.find("@keet/reactions",{gte:{id:l.id,sender:u.key},lte:{id:l.id,sender:u.key}}).toArray():[]]);return{digest:t(d),mine:s(m)}}async function r({snapshot:e,msgId:t,localRoom:s}){if(!t||!s)return null;const{selfMember:n}=s,[a,i]=await Promise.all([e.get("@keet/chat-label-digests",{id:t}),n?e.find("@keet/chat-labels",{gte:{id:t,sender:n.key},lte:{id:t,sender:n.key}}).toArray():[]]);return a&&{digest:a,mine:i}}function o({dm:e,readLengths:t,selfMember:s},n){return!!(e?.length&&n&&t?.length&&s)&&!!t.find(e=>!a.equals(e.memberKey,s.key)&&n.index<e.length)}async function l(t,s,a,l,c,d){const m=n(s,d.oplog.key),{filePromises:f,linkFilePromises:y}=function(e,t,s,n,a){const i=[],r=[];if(a.message?.files?.length>0)for(const r of a.message.files)i.push(u(e,n,t,s,r));const o=a.message?.display?.httpLink||[];for(const e of o)c(e);const l=a.message?.display?.pearLink||[];for(const e of l)c(e);return{filePromises:i,linkFilePromises:r};function c(a){if((a?.preview?.files||[]).length){const i=a.preview.files.map(async i=>{a.preview.file=await u(e,n,t,s,i)});r.push(...i)}}}(t,s,a,c,d),[g,b,h,k]=await Promise.all([m,Promise.all(f),i({snapshot:s,room:l,msgId:d.id}),r({snapshot:s,localRoom:l,msgId:d.id}),Promise.all(y)]);return d.reactions=h,b.length&&(d.message.files=b),d.read=o(l,d.id),e({record:d,labels:k,member:g,localRoom:l})}async function c(e,t,s){if(e.bee){const s=await t.get("@keet/blobs",e.bee);return s?s.data:null}return e.blob&&s?s.get(e.blob):null}async function u(e,t,s,n,a){const i=await s.get("@keet/files",{id:a});if(!i)return null;const r=await t.getFileEntryWithPreview(e,i.file,{loadBlob:e=>c(e,s,n)});return{...i.file,entry:r}}function d(e){return async function(e){return{...e,members:await t(e)}};async function t({callKey:t}){return m(e.find("@keet/call-members",{gte:{callKey:t},lte:{callKey:t}}),async e=>({...e,devices:await s(e)}))}async function s({callKey:t,memberKey:s}){const a={gte:{callKey:t,memberKey:s},lte:{callKey:t,memberKey:s}};return m(e.find("@keet/call-devices-by-member-key",a),async e=>({...e,streams:await n(e)}))}async function n({callKey:t,deviceKey:s}){const n={gte:{callKey:t,deviceKey:s},lte:{callKey:t,deviceKey:s}};return m(e.find("@keet/call-streams-by-device-key",n),async t=>{const s=await e.get("@keet/call-stream-statuses",{statusKey:t.statusKey});return{...t,muted:!!s&&s.muted}})}}async function m(e,t){const s=[];for await(const n of e)s.push(t(n));return Promise.all(s)}module.exports={getChatMessages:async function(e,t,s,n,a,i){const[r,o]=await Promise.all([s.get("@local/rooms",{roomKey:t}),e()]);if(!o||!r)return[];const c=Array.isArray(o)?o:[o],u=[];for(const e of c)u.push(l(t,n,a,r,i,e));return Promise.all(u)},getReactions:i,getChatLabels:r,getChatMessage:l,getCalls:async function(e,t){const s=d(e);return m(e.find(t),s)},getCall:async function(e,t){const s=d(e),n=await e.findOne(t);return n?s(n):null},isDMRead:o,roomHasUnread:function(e,t,s){if(!e||e.status?.isRemoved||e.status?.isPrivateProfile)return!1;if(!t||!t.isActive)return!1;if(t.isUnread)return!0;const n=e.lastMessage;return!!n?.id&&!!s&&n.id.index>=s.length},loadBlob:c,parallel:m};
@holepunchto/keet-core/lib/api/v1/index.js +1 -1
……@@ -1 +1 @@
1const e=require("path"),t=require("ready-resource"),s=require("hypercore-id-encoding"),i=require("hypercore-crypto"),o=require("debounceify"),r=require("safety-catch"),a=require("b4a"),n=require("uncaughts"),{Readable:c,Transform:l,pipeline:h}=require("streamx"),{Session:d,HeapSnapshot:u}=require("bare-inspector"),m=require("bare-fs"),p=require("process-top")(),g=require("tiny-preferences"),b=require("@holepunchto/keet-call/server"),{contract:{hyperschema:{getEnum:y}},local:{hyperschema:{getEnum:f}}}=require("../../../schema/spec"),{encodeRoomRecord:k,encodeConfig:_,encodeDevice:w,encodeMemberRecord:v,encodeInvitationRecord:R,encodeFile:S,encodeIdentityPairingRequest:C,encodeDmRequest:I,encodeReaction:M,encodeUser:E,encodeContactInfo:K,encodeImageFile:D,encodeReservation:P,encodeFileEntry:A,encodeUserSettings:q,encodeErrorRecord:F,encodeNotification:x,encodeHyperDHTSettings:T,encodeSwarmSettings:L,encodeCallRecord:B,encodeLocalActiveCall:U,encodeContact:N,encodePublicRoom:O}=require("./encode.js"),{decodeChatRangeOptions:j,decodeChatMessage:H,decodeMessageId:V,decodeKeyRangeOptions:G,decodeFile:z,decodeConfig:W,decodeImageFile:Y,decodeFileRangeOptions:J,decodeUserSettings:$}=require("./decode.js"),X=y("@keet/build-type"),Z=y("@keet/room-type"),Q=y("@keet/display-type"),ee=y("@keet/label-type"),te=y("@keet/member-label-type"),se=y("@keet/system-settings-keys"),ie=y("@keet-private-id/user-settings-key"),{ContactRequestStatus:oe,RoomStatus:re}=require("../../core/contract/identity/private.js"),{Config:ae,CONFIG_INDEX_TO_KEY:ne}=require("../../core/contract/config"),{Settings:ce}=require("../../core/contract/internal"),{getChatMessages:le,getChatMessage:he,getReactions:de,isDMRead:ue,getCalls:me,loadBlob:pe,parallel:ge}=require("./helpers.js"),{MemberStatus:be}=require("../../core/contract/members/index.js"),{MemberRoles:ye,DM_STATUSES:fe,isValidPreferenceKey:ke,getPreferenceKeyName:_e,CHAT_MESSAGE_REPORT_COUNT:we,GENERIC_EVENTS:ve}=require("@holepunchto/keet-core-api"),{restoreAvatar:Re}=require("../../core/contract/avatars.js"),{getMemberForDeviceKey:Se}=require("../../core/contract/query.js"),Ce=require("compact-encoding"),{DEBUG_FLAG_INDEX_BY_KEY:Ie,DHT_SETTINGS:Me,SWARM_SETTINGS:Ee}=require("../../core/debug/debugging.js"),{KeetErrorV2:Ke}=require("../../errors"),De=require("./inspector.js"),{FEATURES:Pe}=require("../../../schema/versions"),{constants:Ae}=require("rocksdb-native"),qe=f("@local/keet-state"),Fe="recent-rooms",xe="favorite-rooms",Te="dm-rooms",Le="chat-changed",Be="identity",Ue="private-profile",Ne="members",Oe="migration-status",je="room-preferences",He="unreads",Ve="errors",Ge="force-updates",ze="all-active-calls",We={"keet-core":require("../../../package.json").version,autobee:require("autobee/package.json").version,hypercore:require("hypercore/package.json").version,hyperbee:require("hyperbee/package.json").version,hyperbee2:require("hyperbee2/package.json").version,"keet-identity-key":require("keet-identity-key/package.json").version,"keet-push":require("@holepunchto/keet-push/package.json").version,corestore:require("corestore/package.json").version};class Ye{constructor(e,t){this.api=e,this.id=t,this.subscriptions=[]}destroy(){for(const{stream:e}of this.subscriptions)e.destroy()}refresh(e){for(const t of this.subscriptions)e&&e.name&&e.name!==t.name||t.query&&t.query()}push(e,t){for(const s of this.subscriptions)t&&t.name&&t.name!==s.name||s.map&&s.stream.push(s.map(e))}_onDestroy(e,t){const s=this.subscriptions.pop();s!==e&&(this.subscriptions[e.idx]=s,s.idx=e.idx),0===this.subscriptions.length&&this.api._subscriptions.get(this.id)===this&&this.api._subscriptions.delete(this.id),t(null)}_create(e){const t={name:e||null,stream:null,query:null,map:null,idx:0};return t.stream=new c({destroy:e=>this._onDestroy(t,e)}),t.idx=this.subscriptions.push(t)-1,t}add({query:e,map:t,name:s}){if(!e&&!t)throw new Error("Must have either a query or a map");const i=this._create(s);return e&&(i.query=o(async()=>{try{const t=await e();null!==t&&i.stream.push(t)}catch(e){i.stream.destroy(e)}}),i.query()),i.map=t,i.stream}}class Je{constructor(e){this.keet=e}create(e,t){return async(s,...i)=>{if(this.keet.closing)return null;const o=["files","engine","drive","db","snapshot","blobs","blobsSnapshot"],r=!!t.find(e=>o.includes(e));if(r&&!s)throw new Error("Room ID is required for methods that require room resources");("object"==typeof s&&null!==s||!r)&&(i=[s,...i],s=null);const a=s?this.keet.internalOpenExistingRoom(s):null;if(a&&(await a.ready(),await a.engine.flush()),this.keet.closing)return null;const n={roomId:s,roomKey:a?.key||null,discoveryKey:a?.discoveryKey||null};let c=null;try{for(const e of t)a&&"db"===e&&(n.db=a.db),a&&"snapshot"===e&&(n.snapshot=a.db.snapshot()),a&&"blobsSnapshot"===e&&(n.blobsSnapshot=a.blobs?a.blobs.snapshot():null),a&&"engine"===e&&(n.engine=a.engine),a&&"drive"===e&&(n.drive=a.drive),"local"===e&&(n.local=this.keet.local),"localSnapshot"===e&&(n.localSnapshot=this.keet.local.snapshot()),"files"===e&&(n.files=this.keet.files),"myKey"===e&&(this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready(),n.localSnapshot||(n.localSnapshot=this.keet.local.snapshot()),n.id=await n.localSnapshot.get("@local/identity"),n.profileInfo=await n.localSnapshot.get("@local/rooms",{roomKey:n.id.privateProfileKey}),n.myKey=n.profileInfo?.selfMember?.key||null),"profile"===e&&(this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready(),n.localSnapshot||(n.localSnapshot=this.keet.local.snapshot()),n.id||(n.id=await n.localSnapshot.get("@local/identity")),n.profileInfo||(n.profileInfo=await n.localSnapshot.get("@local/rooms",{roomKey:n.id.privateProfileKey})),n.profile=this.keet.internalOpenExistingRoom(n.id.privateProfileKey),await n.profile.ready()),n.profile&&"profileDb"===e&&(n.profileDb=n.profile.db),n.profile&&"profileSnapshot"===e&&(n.profileSnapshot=n.profile.db.snapshot()),n.profile&&"profileBlobs"===e&&(n.profileBlobs=n.profile.profileBlobs);const s=Date.now();return c=await e(n,...i),this.keet.logger.debug("[Keet API]",e.name,"duration:",Date.now()-s,"args:",i),c}catch(e){if(this.keet.closing)return null;const t=a?.engine.getLastError();if(t)throw t;throw this.keet.onerror(e),e}finally{n.snapshot&&await n.snapshot.close(),n.blobsSnapshot&&await n.blobsSnapshot.close(),n.localSnapshot&&await n.localSnapshot.close(),n.profileSnapshot&&await n.profileSnapshot.close(),n.profile&&await this.keet.internalReleaseRoom(n.profile),a&&await this.keet.internalReleaseRoom(a)}}}}class $e{constructor(e,{onerror:t=r}={}){this.keet=e,this.context=new Je(this.keet),this._onerror=t,this._subscriptions=new Map,this._profileSubscriptions=new Ye(this,null,{isProfileSub:!0}),this._activeCallStates=new Map,this.keet.on("room-interrupted",this._handleRoomInterrupted.bind(this)),this.keet.on("room-changed",this._handleRoomChanged.bind(this)),this.keet.on("identity-changed",this._handleIdentityChanged.bind(this)),this.keet.on("recent-rooms-changed",this._handleRecentRoomsChanged.bind(this)),this.keet.on("dm-rooms-changed",this._handleDmRoomsChanged.bind(this)),this.keet.on("chat-changed",this._handleChatChanged.bind(this)),this.keet.on("identity-pairing-request",this._handleIdentityPairingRequest.bind(this)),this.keet.on("migration-status",this._handleMigrationStatus.bind(this)),this.keet.on("room-preferences-changed",this._handleRoomPreferencesChanged.bind(this)),this.keet.on("unread-anchors-changed",this._handleUnreadAnchorsChanged.bind(this)),this.keet.on("room-sent-message",this._handleRoomSentMessageLengthChanged.bind(this)),this.keet.on("caught-error",this._handleKeetError.bind(this)),this.keet.on("force-update",this._handleForceUpdate.bind(this)),this.keet.on("verified-rooms-changed",this._handleVerifiedRoomsChanged.bind(this)),this.keet.on("local-files-changed",this._handleLocalFilesChanged.bind(this)),this.keet.on("favorite-rooms-changed",this._handleFavoriteRoomsChanged.bind(this)),this.keet.on("contacts-changed",this._handleContactsChanged.bind(this)),this.keet.on("call-changed",this._handleAllActiveCallsChanged.bind(this)),this.keet.on("call-changed-v3",this._handleAllActiveCallsChanged.bind(this)),this.boot=this._timed(this._boot.bind(this)),this.createInvitation=this._timed(this._createInvitation.bind(this)),this.confirmPairingRequest=this._timed(this._confirmPairingRequest.bind(this)),this.startPairingRoom=this._timed(this._startPairingRoom.bind(this)),this.stopPairingRoom=this.context.create(this._stopPairingRoom.bind(this),["profile"]),this.searchRooms=this.context.create(this._searchRooms.bind(this),["local"]),this.getRoomInfo=this.context.create(this._getRoomInfo.bind(this),["localSnapshot"]),this.getRecentRooms=this.context.create(this._getRecentRooms.bind(this),["local"]),this.getPendingRooms=this.context.create(this._getPendingRooms.bind(this),["profile"]),this.getLocalRoomMetadata=this.context.create(this._getLocalRoomMetadata.bind(this),["local"]),this.getConfig=this.context.create(this._getConfig.bind(this),["snapshot","local"]),this.updateRoomSettings=this._updateRoomSettings.bind(this),this.getChatMessage=this.context.create(this._getChatMessage.bind(this),["snapshot","blobsSnapshot","files","local"]),this.getChatMessageById=this.context.create(this._getChatMessageById.bind(this),["snapshot","blobsSnapshot","files","local"]),this.getChatMessages=this.context.create(this._getChatMessages.bind(this),["snapshot","blobsSnapshot","files","local"]),this.getChatLength=this.context.create(this._getChatLength.bind(this),["db"]),this.removeChatMessage=this.context.create(this._removeChatMessage.bind(this),["snapshot","blobsSnapshot","files","local"]),this.searchChatMessages=this.context.create(this._searchChatMessages.bind(this),["local","snapshot","blobsSnapshot","files"]),this.addChatMessage=this._timed(this._addChatMessage.bind(this)),this.updateChatMessage=this._timed(this._updateChatMessage.bind(this)),this.forwardChatMessage=this.context.create(this._forwardChatMessage.bind(this),["snapshot","blobsSnapshot","files","local"]),this.pinChatMessage=this._timed(this._pinChatMessage.bind(this)),this.unpinChatMessage=this._timed(this._unpinChatMessage.bind(this)),this.addCallStartedEvent=this._timed(this._addCallStartedEvent.bind(this)),this.addCallHangupEvent=this._timed(this._addCallHangupEvent.bind(this)),this.addCallMissedEvent=this._timed(this._addCallMissedEvent.bind(this)),this.addLocationSharedEvent=this._timed(this._addLocationSharedEvent.bind(this)),this.getActiveCalls=this.context.create(this._getActiveCalls.bind(this),["engine","snapshot"]),this.getAllActiveCalls=this.context.create(this._getAllActiveCalls.bind(this),["localSnapshot"]),this.getCalls=this.context.create(this._getCalls.bind(this),["snapshot"]),this.getReactions=this.context.create(this._getReactions.bind(this),["snapshot","local"]),this.getLatestReactions=this.context.create(this._getLatestReactions.bind(this),["snapshot"]),this.addReaction=this._timed(this._addReaction.bind(this)),this.removeReaction=this._timed(this._removeReaction.bind(this)),this.getReportedMembers=this.context.create(this._getReportedMembers.bind(this),["snapshot","blobsSnapshot","localSnapshot"]),this.addChatReport=this._timed(this._addChatReport.bind(this)),this.removeChatReport=this._timed(this._removeChatReport.bind(this)),this.dismissChatReports=this._timed(this._dismissChatReports.bind(this)),this.getReportedMessages=this.context.create(this._getReportedMessages.bind(this),["roomKey","local","snapshot","blobsSnapshot","files"]),this.getPinnedChatMessages=this.context.create(this._getPinnedChatMessages.bind(this),["local","snapshot","blobsSnapshot","files"]),this.getActiveMember=this.context.create(this._getActiveMember.bind(this),["snapshot","blobsSnapshot","localSnapshot","myKey"]),this.getActiveMembers=this.context.create(this._getActiveMembers.bind(this),["snapshot","blobsSnapshot","localSnapshot","myKey"]),this.getMembers=this.context.create(this._getMembers.bind(this),["snapshot","blobsSnapshot","localSnapshot","myKey"]),this.getMember=this.context.create(this._getMember.bind(this),["snapshot","blobsSnapshot","localSnapshot","myKey"]),this.getMemberCount=this.context.create(this._getMemberCount.bind(this),["db"]),this.getMemberBySwarmId=this.context.create(this._getMemberBySwarmId.bind(this),["snapshot","blobsSnapshot","localSnapshot","myKey"]),this.getMemberByDeviceId=this.context.create(this._getMemberByDeviceId.bind(this),["snapshot","blobsSnapshot","localSnapshot","myKey"]),this.isMemberMuted=this.context.create(this._isMemberMuted.bind(this),["db"]),this.getSearchMembers=this.context.create(this._getSearchMembers.bind(this),["snapshot","blobsSnapshot","localSnapshot","myKey"]),this.updateMember=this._timed(this._updateMember.bind(this)),this.removeMember=this._timed(this._removeMember.bind(this)),this.changeMemberRole=this._timed(this._changeMemberRole.bind(this)),this.muteMember=this._timed(this._muteMember.bind(this)),this.unmuteMember=this._timed(this._unmuteMember.bind(this)),this.blockMember=this._timed(this._blockMember.bind(this)),this.unblockMember=this._timed(this._unblockMember.bind(this)),this.getDevices=this.context.create(this._getDevices.bind(this),["db"]),this.getDevice=this.context.create(this._getDevice.bind(this),["db"]),this.getDevicesByMemberId=this.context.create(this._getDevicesByMemberId.bind(this),["db"]),this.getModerators=this.context.create(this._getModerators.bind(this),["snapshot","blobsSnapshot","localSnapshot","myKey"]),this.saveFile=this.context.create(this._saveFile.bind(this),["files"]),this.saveFileBlob=this.context.create(this._saveFileBlob.bind(this),["files"]),this.getFileEntry=this.context.create(this._getFileEntry.bind(this),["files"]),this.getFileCleared=this.context.create(this._getFileCleared.bind(this),["files"]),this.clearFile=this.context.create(this._clearFile.bind(this),["files"]),this.unclearFile=this.context.create(this._unclearFile.bind(this),["files"]),this.clearAllFiles=this.context.create(this._clearAllFiles.bind(this),["files"]),this.clearOldFiles=this._timed(this._clearOldFiles.bind(this)),this.getLocalFiles=this.context.create(this._getLocalFiles.bind(this),["files","snapshot","blobsSnapshot"]),this.getFiles=this.context.create(this._getFiles.bind(this),["files","snapshot","blobsSnapshot"]),this.startDownload=this.context.create(this._startDownload.bind(this),["files"]),this.cancelDownload=this.context.create(this._cancelDownload.bind(this),["files"]),this.saveToDisk=this.context.create(this._saveToDisk.bind(this),["files"]),this.sendFile=this._timed(this._sendFile.bind(this)),this.sendFiles=this._timed(this._sendFiles.bind(this)),this.refreshFileLinks=this._timed(this._refreshFileLinks.bind(this)),this.createRoom=this._timed(this._createRoom.bind(this)),this.leaveRoom=this._timed(this._leaveRoom.bind(this)),this.getSystemDigest=this.context.create(this._getSystemDigest.bind(this),["db"]),this.getTipSize=this.context.create(this._getTipSize.bind(this),["engine"]),this.getRoomKeys=this._timed(this._getRoomKeys.bind(this)),this.resyncPrivateProfile=this._timed(this._resyncPrivateProfile.bind(this)),this.restoreIdentity=this._timed(this._restoreIdentity.bind(this)),this.getRecoveryPhrase=this._timed(this._getRecoveryPhrase.bind(this)),this.getEncryptedRecoveryPhrase=this._timed(this._getEncryptedRecoveryPhrase.bind(this)),this.decryptEncryptedRecoveryPhrase=this._timed(this._decryptEncryptedRecoveryPhrase.bind(this)),this.freeRecoveryPhrase=this._timed(this._freeRecoveryPhrase.bind(this)),this.confirmRecoveryPhrase=this._timed(this._confirmRecoveryPhrase.bind(this)),this.storeRecoveryPhrase=this._timed(this._storeRecoveryPhrase.bind(this)),this.getIdentity=this.context.create(this._getIdentity.bind(this),["local","profile","profileSnapshot"]),this.getSelfContactInfo=this.context.create(this._getSelfContactInfo.bind(this),["local","profile"]),this.removeIdentityDevice=this.context.create(this._removeIdentityDevice.bind(this),["profile"]),this.createIdentityInvitation=this._timed(this._createIdentityInvitation.bind(this)),this.startPairingIdentity=this._timed(this._startPairingIdentity.bind(this)),this.updateIdentityProfile=this._timed(this._updateIdentityProfile.bind(this)),this.updateIdentityDevice=this._timed(this._updateIdentityDevice.bind(this)),this.getIdentityPairingRequest=this._timed(this._getIdentityPairingRequest.bind(this)),this.updateUserSettings=this._timed(this._updateUserSettings.bind(this)),this.updateDHTSettings=this._timed(this._updateDHTSettings.bind(this)),this.getDHTSettings=this._timed(this._getDHTSettings.bind(this)),this.getSwarmSettings=this._timed(this._getSwarmSettings.bind(this)),this.updateSwarmSettings=this._timed(this._updateSwarmSettings.bind(this)),this.addContact=this._timed(this._addContact.bind(this)),this.setContactAlias=this._timed(this._setContactAlias.bind(this)),this.removeContact=this._timed(this._removeContact.bind(this)),this.getActiveContacts=this.context.create(this._getActiveContacts.bind(this),["localSnapshot"]),this.getContactInfo=this.context.create(this._getContactInfo.bind(this),["local","profile"]),this.getBlockedMembers=this.context.create(this._getBlockedMembers.bind(this),["localSnapshot"]),this.getDmRequestsByStatus=this.context.create(this._getDmRequestsByStatus.bind(this),["localSnapshot","profile","profileDb"]),this.sendDMFromContact=this._timed(this._sendDMFromContact.bind(this)),this.sendDMRequest=this._timed(this._sendDMRequest.bind(this)),this.sendInvitations=this._timed(this._sendInvitations.bind(this)),this.updatePrivateMailboxRecord=this._timed(this._updatePrivateMailboxRecord.bind(this)),this.acceptDmRequest=this._timed(this._acceptDmRequest.bind(this)),this.rejectDmRequest=this._timed(this._rejectDmRequest.bind(this)),this.getRoomPreferences=this.context.create(this._getRoomPreferences.bind(this),["local"]),this.updateRoomPreferences=this.context.create(this._updateRoomPreferences.bind(this),["profile"]),this.snoozeRoom=this.context.create(this._snoozeRoom.bind(this),["profile"]),this.updateConfig=this._timed(this._updateConfig.bind(this)),this.disableMembershipEvents=this._timed(this._disableMembershipEvents.bind(this)),this.enableMembershipEvents=this._timed(this._enableMembershipEvents.bind(this)),this.setRoomUnread=this._timed(this._setRoomUnread.bind(this)),this.getLinkInfo=this._timed(this._getLinkInfo.bind(this)),this.lookupUsername=this._timed(this._lookupUsername.bind(this)),this.lookupUserByMemberId=this._timed(this._lookupUserByMemberId.bind(this)),this.registerUsername=this._timed(this._registerUsername.bind(this)),this.updateUsername=this._timed(this._updateUsername.bind(this)),this.searchUsername=this._timed(this._searchUsername.bind(this)),this.getReservationsByKey=this._timed(this._getReservationsByKey.bind(this)),this.checkUsername=this._timed(this._checkUsername.bind(this)),this.repair=this._timed(this._repair.bind(this)),this.rotateWriter=this._timed(this._rotateWriter.bind(this)),this.audit=this._timed(this._audit.bind(this)),this.setUnread=this._setUnread.bind(this),this.getUnread=this._getUnread.bind(this),this.setUnreadAnchor=this._setUnreadAnchor.bind(this),this.getUnreadAnchor=this._getUnreadAnchor.bind(this),this.subscribeUnreadAnchor=this._subscribeUnreadAnchor.bind(this),this.updateTypingIndicator=this.context.create(this._updateTypingIndicator.bind(this),["db"]),this.getTypingIndicator=this.context.create(this._getTypingIndicator.bind(this),["db"]),this.subscribeTypingIndicator=this._subscribeTypingIndicator.bind(this),this.setRoomFavorite=this._setRoomFavorite.bind(this)}_timed(e){return async function(...t){const s=Date.now();try{const i=await e(...t);return this.keet.logger.debug("[Keet API]",e.name,"duration:",Date.now()-s,"args:",t),i}catch(e){throw this.keet.onerror(e),e}}}_boot(){return this.keet.backendReady()}_disableMembershipEvents(e){return this.keet.dispatch(e,"@keet/update-system-settings",{key:ce.IsMembershipEventsDisabled,settings:{isMembershipEventsDisabled:!0}})}_enableMembershipEvents(e){return this.keet.dispatch(e,"@keet/update-system-settings",{key:ce.IsMembershipEventsDisabled,settings:{isMembershipEventsDisabled:!1}})}_addKeetSubscription(e="keet",t){return this._addRoomSubscription(e,t)}_addRoomSubscription(e,t,{isProfileSub:s=!1,_isRoomSub:i=!0}={}){if(null===e&&s)return this._profileSubscriptions.add(t);let o=this._subscriptions.get(e);return o||(o=new Ye(this,e),this._subscriptions.set(e,o)),o.add(t)}_refreshSubscriptionsById(e){const t=e===this.keet.privateProfile?.id?this._subscriptions.get(Ue):this._subscriptions.get(e);t&&t.refresh()}_handleIdentityPairingRequest(e){this._identityPairingRequestsByDeviceId.set(s.encode(e.deviceKey),e),this._refreshSubscriptionsById("identity-pairing-requests")}_handleRoomInterrupted(e,{unsupportedABI:t,digest:s}){const i=this._subscriptions.get(e);if(i)for(const e of i.subscriptions)"room-version"===e.name&&e.stream.push({version:t,experimental:s&&s.settings.isExperimental})}async _handleRoomChanged(e){try{this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready(),this._refreshSubscriptionsById(e)}catch(e){this.keet.onerror(e)}}_handleRecentRoomsChanged(...e){const t=this._subscriptions.get(Fe);t&&t.push(e)}_handleDmRoomsChanged(){const e=this._subscriptions.get(Te);e&&e.refresh()}_handleRoomPreferencesChanged(...e){const t=this._subscriptions.get(je);t&&t.push(e)}_handleUnreadAnchorsChanged(){const e=this._subscriptions.get(He);e&&e.refresh()}_handleAllActiveCallsChanged(e,t,i){let o=null;t&&(o={callId:s.encode(t.callKey),joined:!!i});if(a=o,(r=this._activeCallStates.get(e)||null)&&a?r.callId===a.callId&&r.joined===a.joined:r===a)return;var r,a;o?this._activeCallStates.set(e,o):this._activeCallStates.delete(e);const n=this._subscriptions.get(ze);n&&n.refresh()}_handleRoomSentMessageLengthChanged(e){const t=this._subscriptions.get(e);t&&t.refresh({name:"room-info"})}_handleIdentityChanged(){this._refreshSubscriptionsById(Be)}async _handleChatChanged(...e){try{this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready();const t=this._subscriptions.get(Le);if(!t)return;const[s,i]=e;if(s===this.keet.privateProfile.id)return;t.push({roomId:s,index:i})}catch(e){this.keet.onerror(e)}}_handleMigrationStatus(e){const t=this._subscriptions.get(Oe);t&&t.push(e)}_handleKeetError(e){const t=this._subscriptions.get(Ve);t&&t.push(e)}_handleForceUpdate(){const e=this._subscriptions.get(Ge);e&&e.refresh()}_handleVerifiedRoomsChanged(){for(const e of this._subscriptions.values())e.refresh({name:"room-info"})}_handleLocalFilesChanged(e){const t=this._subscriptions.get(e);t&&t.refresh({name:"room-info"})}_handleFavoriteRoomsChanged(...e){const t=this._subscriptions.get(xe);t&&t.push(e)}_handleContactsChanged(){for(const e of this._subscriptions.values())e.refresh({name:Ne})}getVersion(){return{buildType:this.keet.buildType,abi:this.keet.abi,modules:We}}async _getSystemDigest({db:e}){return await e.get("@keet/system-digest")}subscribeSentLength(e){return this._addRoomSubscription(e,{query:async()=>{const t=this.keet.internalOpenExistingRoom(e);await t.ready();const s={deviceId:t.engine.local.id,length:t.engine.local.remoteContiguousLength};return this.keet.internalReleaseRoom(t),s},name:"room-sent-message"})}subscribeRoomVersion(e){return this._addRoomSubscription(e,{query:async()=>{const t=await this.getSystemDigest(e);return{version:t.abi.version,experimental:t.settings.isExperimental}},name:"room-version"})}subscribeForceUpdates(){return this._addKeetSubscription(Ge,{query:()=>({showBanner:this.keet.shouldForceUpdate()})})}async upgradeRoom(e){this.keet.opened||await this.keet.ready();const t=this.keet.isNightly?this.keet.abi.max:this.keet.abi.production;await this.keet.internalDispatchUpgrade(e,t)}async _getLinkInfo(e){const t=this.keet.internalGetLinkInfo(e);if(!t)return null;if(t.identity)return{isIdentityInvitation:!0,memberId:s.encode(t.identity.identityPublicKey),invitationSeed:s.encode(t.identity.invitationSeed),additionalNodes:t.additionalNodes};if(t.room){const e={capabilities:{mailboxKeyPair:{publicKey:t.room.mailbox}}},i=await this.keet.local.get("@local/rooms-by-mailbox",e);return{isRoomInvitation:!0,roomId:i?s.encode(i.roomKey):null,title:i?i.config.title:null,description:i?i.config.description:null,avatar:i?D(i.config.avatar):null,invitationSeed:s.encode(t.room.invitationSeed),additionalNodes:t.additionalNodes}}return t.profile?{isContactInfo:!0,memberId:s.encode(t.attestation.memberKey),displayName:t.profile.displayName,username:t.profile.username,additionalNodes:t.additionalNodes}:t.readonly||t["readonly-v2"]?{isReadOnly:!0,additionalNodes:t.additionalNodes}:void 0}async _getSelfContactInfo({id:e,profileInfo:t}){const s=this.keet.internalCreateContactInfoStruct(e,t,{avatar:null,timestamp:0});return a.toString(s,"base64")}async _getIdentity({id:e,profile:t,profileSnapshot:i,profileInfo:o}){const[r,a]=await Promise.all([i.find("@keet/devices").toArray(),i.get("@keet-private-id/settings")]),n=[];for(const e of r)e.status.isActive&&n.push({...w(e),confirmed:!0});const c=v(o.selfMember,o.selfMember.key);return c.hasDiscoveryKey=!!o.identity.discoveryCoreKey,c.anonymous=!1,c.confirmed=e.status.isConfirmed,c.devices=n,c.profileId=t.id,c.profileDiscoveryId=t.discoveryId,c.local={deviceId:s.encode(t.deviceKey)},c.settings=q(a),c.isLoggedOut=o.selfDevice&&!o.selfDevice.status.isActive,c.version=o?.digest.abi.version,c}_removeIdentityDevice({profile:e},t){return e.dispatch("@keet/remove-device",{key:s.decode(t)})}subscribeIdentity(){return this._addKeetSubscription(Be,{query:()=>this.getIdentity()})}async _restoreIdentity(e,t={}){await this.keet.restoreIdentity(e,t)}_getRecoveryPhrase(){return this.keet.getRecoveryPhrase()}_getEncryptedRecoveryPhrase(e){return this.keet.getEncryptedRecoveryPhrase(e)}_decryptEncryptedRecoveryPhrase(e,t){return this.keet.decryptEncryptedRecoveryPhrase(e,t)}_freeRecoveryPhrase(e){return this.keet.freeRecoveryPhrase(e)}_confirmRecoveryPhrase(e){return this.keet.confirmRecoveryPhrase(e)}_storeRecoveryPhrase(e){return this.keet.storeRecoveryPhrase(e)}confirmIdentity(...e){throw console.log("confirmIdentity",...e),new Error("Missing required method: confirmIdentity")}async _confirmPairingRequest({deviceId:e},t=!0){this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready();const i=this.keet.privateProfile.key,o=s.decode(e);return t?this.keet.acceptJoinRequest(i,o):this.keet.rejectJoinRequest(i,o)}async _getIdentityPairingRequest(){const e=await this.keet.internalOpenPrivateProfile(),t=await e.db.find("@keet/join-requests").toArray();return this.keet.internalReleaseRoom(e),0===t.length?null:C(t[0])}subscribeIdentityPairingRequests(...e){return this._addKeetSubscription(Be,{query:()=>this.getIdentityPairingRequest()})}async _updateIdentityProfile({displayName:e,avatar:t}){await this.updateMember(e,t)}_updateIdentityDevice(e){return this.keet.updateDevice(e)}_startPairingIdentity(e){return this.keet.startPairingIdentity(e)}pairIdentity(...e){throw console.log("pairIdentity",...e),new Error("Missing required method: pairIdentity")}async _updateUserSettings(e,t){this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready();const s={[e]:t};if(e===ie.stripAttachmentMetadata&&!await this.keet.internalFeatureSupported(this.keet.privateProfile.id,Pe.STRIP_ATTACHMENT_METADATA))throw new Error("Stripping attachment metadata not supported");if(e===ie.profileSnoozeTime&&!await this.keet.internalFeatureSupported(this.keet.privateProfile.id,Pe.PROFILE_SNOOZE_TIME))throw new Error("Profile snoozing not supported");return this.keet.privateProfile.dispatch("@keet-private-id/update-settings",{key:e,settings:$(s)})}async _getDHTSettings(){const e=await this.keet.getDHTSettings();return T(e)}async _updateDHTSettings(e,t){if(!(e in Me))throw Ke.INVALID_SETTINGS_KEY(`Invalid DHT settings key: ${e}`);const s=await this.keet.internalEnterLocalTransaction();try{const i=await this.keet.getDHTSettings();i[e]=t,await s.insert("@local/hyperdht",i),await s.flush()}finally{await this.keet.internalExitLocalTransaction()}}async _getSwarmSettings(){const e=await this.keet.getSwarmSettings();return L(e)}async _updateSwarmSettings(e,t){if(!(e in Ee))throw Ke.INVALID_SETTINGS_KEY(`Invalid swarm settings key: ${e}`);const s=await this.keet.internalEnterLocalTransaction();try{const i=await this.keet.getSwarmSettings();i[e]=t,await s.insert("@local/hyperswarm",i),await s.flush()}finally{await this.keet.internalExitLocalTransaction()}}async _createRoom(e={}){const t=await this.keet.createRoom(function(e={}){return{config:{title:e.config?.title,description:e.config?.description},settings:{roomType:rt(e.config?.roomType),isCallingDisabled:"false"===e.config?.canCall}}}(e));return s.encode(t)}_pairRoom(...e){throw console.log("pairRoom",...e),new Error("Missing required method: pairRoom")}_leaveRoom(e,t={}){return this.keet.leaveRoom(s.decode(e))}async _startPairingRoom(e,t={}){return await this.keet.startPairingRoom(e,t)}async _stopPairingRoom({profile:e},t){const i=s.decode(t),o=await e.db.find("@keet-private-id/pending-invitations").toArray();for(const e of o)if(a.equals(e.invitationSeed,i)){await this.keet.stopPairing(e.id);break}}subscribePendingRooms(){return this._addKeetSubscription(Be,{query:()=>this.getPendingRooms()})}subscribePushNotificationChanges(){return this._addKeetSubscription(je,{map:function(e){const[t,o,r]=e,a=r||i.discoveryKey(o);return{type:t,roomId:s.encode(o),discoveryId:s.encode(a)}}})}subscribeActivateRoom(e){const t=s.decode(e);return new c({eagerOpen:!0,open:async e=>{let s=null;try{await this.keet.activateRoom(t)}catch(e){s=e}e(s)},destroy:async e=>{let s=null;try{await this.keet.deactivateRoom(t)}catch(e){s=e}e(s)}})}_getRoomKeys(e){try{const t=s.decode(e);return{discoveryKey:a.toString(i.discoveryKey(t),"hex")}}catch{return{discoveryKey:""}}}_getTipSize({engine:e}){return e.tipSize}async _resyncPrivateProfile(){this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready(),await this.keet.internalResyncPrivateProfile()}bookmark(...e){throw console.log("bookmark",...e),new Error("Missing required method: bookmark")}unbookmark(...e){throw console.log("unbookmark",...e),new Error("Missing required method: unbookmark")}subscribeBookmarks(...e){return console.log("subscribeBookmarks",...e),new c}async _loadRecents(e,t={}){const{index:s,range:i}=function(e){return e.favorites?{index:"@local/rooms-by-favorite-and-timestamp",range:{}}:e.default||e.dms||e.broadcast?{index:"@local/rooms-by-type-and-timestamp",range:{lte:{type:a(e)},gte:{type:a(e)}}}:{index:"@local/rooms-by-timestamp",range:{}}}(t),o=await e.find(s,{...t,...i,reverse:!0}).toArray(),r=await Promise.all(o.map(t=>e.get("@local/room-preferences",{roomKey:t.roomKey})));for(let e=0;e<r.length;e++){const t=r[e];t&&!t.status.isActive&&(o[e]=null)}return o;function a(e){return e.default?Z.Default:e.dms?Z.DirectMessage:e.broadcast?Z.Broadcast:void 0}}async _getRoomInfo({localSnapshot:e},t){const o=s.decode(t),r=await e.get("@local/rooms",{roomKey:o});if(!r)return null;let a=v(r.lastMember);const[n,c,l]=await Promise.all([e.get("@local/room-preferences",{roomKey:r.roomKey}),r.lastMessage&&!a?e.get("@local/devices",{device:{key:r.lastMessage.oplog.key}}):null,e.get("@local/file-stats",{roomKey:r.roomKey})]);if(c){const t=await e.get("@local/members",{key:c.device.memberKey});t&&(a={id:s.encode(t.key),memberId:s.encode(t.key),displayName:t.profile.displayName})}if(r.lastMessage){const e=ue(r,r.lastMessage.id);r.lastMessage.read=e}if(r.lastMessage?.event?.memberRemoved){const t=await e.get("@local/members",{key:r.lastMessage.event.memberRemoved.memberKey}),s=t?.profile?.displayName;r.lastMessage.event.memberRemoved.displayName=s}const h=r.selfDevice?i.discoveryKey(r.selfDevice.key):null,d=h?await this.keet.storage.getInfo(h,{hints:!0,auth:!1,head:!1}):null,u=k({roomInfo:r,preferences:n,lastMessageMember:a,storageInfo:d,fileStats:l});return u.isVerified=this.keet.isRoomVerified(t),u}async _searchRooms({local:e}){const t=await this._loadRecents(e),i=[];for(const e of t)e&&i.push({title:e.config.title,roomId:s.encode(e.roomKey)});return i}searchPublicRooms(e,t){return c.from(this._searchPublicRooms(e,t))}async*_searchPublicRooms(e=[],t={}){if(!this.keet.roomRegistry)return;const s=this.keet.local.snapshot();try{for await(const s of this.keet.roomRegistry.search(e)){const e=await i(s.roomKey);t.unjoined&&e||(this.keet.buildType===X.Nightly&&(s.invitation=null),yield O(s,e))}}finally{await s.close()}async function i(e){const t=await s.get("@local/rooms",{roomKey:e});return!!t&&!t.status.isRemoved}}async _getRecentRooms({local:e},t){const[i,o]=await Promise.all([this._loadRecents(e,t),e.get("@local/stats")]),r=[];for(const e of i)e&&r.push({timestamp:e.timestamps.latestChatMessage||e.timestamps.latestSync,roomId:s.encode(e.roomKey)});return{type:"all",total:o?o.activeRooms:0,rooms:r}}async _getPendingRooms({profile:e}){return(await e.db.find("@keet-private-id/pending-invitations").toArray()).map(R)}_getLocalRoomMetadata({local:e},t){return e.get("@local/rooms",{discoveryKey:s.decode(t)})}subscribeRecentRooms(e){return this._addKeetSubscription(Fe,{map:function(e){const[t,s,i]=e;return{type:t,timestamp:s,roomId:i}},query:()=>this.getRecentRooms(e)})}subscribeFavoriteRooms(){return this._addKeetSubscription(xe,{map:function(e){const[t,s,i]=e;return{type:t,timestamp:s,roomId:i}},query:()=>this.getRecentRooms({favorites:!0})})}subscribeRoomInfo(e,t){return this._addRoomSubscription(e,{query:()=>this.getRoomInfo(e,t),name:"room-info"})}subscribeUnreadActivity(e={}){return this._addKeetSubscription(Le,{map:({roomId:t,index:s})=>t?e.includeLength||e.includeIndex?{roomId:t,index:s}:{roomId:t}:null})}subscribeErrors(){return this._addKeetSubscription(Ve,{map:e=>F(e)})}subscribeNotifications(){const e=this.subscribeUnreadActivity({includeIndex:!0}),t=c.from(this._subscribeNotifications(e));return t.once("close",()=>{e.destroy()}),t}setCallRingingId(e){this._callRingingRoomId=e}setProcessingNotifications(e){this._processingNotifications=e}async*_subscribeNotifications(e){for await(const{roomId:i,index:o}of e){if(this.keet.closing)return;if(this._callRingingRoomId){if(i!==this._callRingingRoomId)continue;const e=await this.getChatMessage(i,o);if(this.keet.closing)return;e?.event?.type===ve.CALL_HANGUP&&(yield{type:ve.CALL_HANGUP})}if(this._processingNotifications)continue;const e=await this.keet.local.get("@local/room-preferences",{roomKey:s.decode(i)});if(this.keet.closing)return;const r=e?.status.isFullyMuted||!1,a=(e?.status.roomSnoozeTime||0)>Date.now();if(r||a||this._processingNotifications)continue;const[n,c,l]=await Promise.all([this.getConfig(i),this.getChatMessage(i,o),this.keet.local.get("@local/identity")]);if(this.keet.closing)return;if(!c||Math.abs(Date.now()-c.timestamp)>6e5)continue;const h=await this.getBlockedMembers();if(this.keet.closing)return;if(h.some(e=>e.memberId===c.memberId)||this._processingNotifications)continue;if(l&&s.encode(l.publicKey)===c.memberId)continue;const{settings:d}=await this.keet.local.get("@local/rooms",{roomKey:l.privateProfileKey});if(this.keet.closing)return;if((d?.profileSnoozeTime||0)>Date.now())continue;const u=`${c.id.deviceId}/b${c.id.seq}`,m=t(c),p=c.files.length>0&&c.files[0].metadata?.mimetype||"",g=await this.getMember(i,c.memberId);if(this.keet.closing)return;const b=c.chat?.text||"",y=rt(n.roomType)===Z.DirectMessage;if(!this._processingNotifications&&(b||m)){if(y&&"call"===m){if(Math.abs(Date.now()-c.timestamp)>2e4)continue;if(!(await this.getActiveCalls(i)).length)continue;yield{type:ve.CALL_STARTED}}const e=await this.getRoomInfo(i);if(this.keet.closing)return;const t=e?.config?.avatar?.small?.pointer?.inlined??"",s=c.message?.generic?.locationShared;yield x({messageId:u,roomId:i,avatar:t,location:s,messageText:b,messageType:m,fileType:p},n,g)}}function t(e){return e.event?.type===ve.CALL_STARTED?"call":e.files?.length>0?"file":e.message?.generic?.locationShared?"location":""}}async _setRoomUnread(e,t=!0){this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready();const{privateProfileKey:i}=await this.keet.local.get("@local/identity"),o=await this.keet.local.get("@local/rooms",{roomKey:i});if(!o)return;const{isFeatureSupported:r,FEATURES:a}=this.keet.versions;if(!r(o.digest.abi.version,a.ROOM_MARK_UNREAD))throw new Error("Manual unread is not supported");await this.keet.privateProfile.dispatch("@keet-private-id/update-room-status",{roomKey:s.decode(e),key:re.IsUnread,status:{isUnread:t}})}async _snoozeRoom({profile:e},t,i=0){if(!await this.keet.internalFeatureSupported(e.id,Pe.ROOM_SNOOZE_TIME))throw new Error("Room snoozing not supported");await e.dispatch("@keet-private-id/update-room-status",{roomKey:s.decode(t),key:re.RoomSnoozeTime,status:{roomSnoozeTime:i}})}bumpRoomPriority(...e){throw console.log("bumpRoomPriority",...e),new Error("Missing required method: bumpRoomPriority")}addDevice(...e){throw console.log("addDevice",...e),new Error("Missing required method: addDevice")}removeDevice(...e){throw console.log("removeDevice",...e),new Error("Missing required method: removeDevice")}async _getDevice({db:e},t){const s=await e.findOne("@keet/devices",G({gte:t,lte:t}));return s?w(s):null}async _getDevices({db:e},t){return(await e.find("@keet/devices",G(t)).toArray()).map(e=>w(e))}async moveIndexer(e,t,i){if(!await this.keet.internalFeatureSupported(e,Pe.MOVE_INDEXER))throw new Error("Move indexer not supported");const o=s.decode(t),r=s.decode(i);return this.keet.dispatch(e,"@keet/move-indexer",{deviceKey:o,fromDeviceKey:r})}subscribeDevice(e,...t){return this._addRoomSubscription(e,{query:()=>this.getDevice(e,...t)})}subscribeDevices(e,...t){return this._addRoomSubscription(e,{query:()=>this.getDevices(e,...t)})}async _createIdentityInvitation(){return this.keet.createIdentityInvitation()}_createInvitation(e,t={}){return!0===t.canIndex&&(t.canAdmin=!0),this.keet.createRoomInvitation(s.decode(e),t)}async _updateMember(e,t){this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready();const i=await this.keet.local.get("@local/identity");if(i&&s.encode(i.privateProfileKey))return t=Y(t),this.keet.updateProfile({displayName:e,avatar:t})}async _muteMember(e,t){const i=s.decode(t);return this.keet.dispatch(e,"@keet/change-member-status",{memberKey:i,key:be.IsMuted,status:{isMuted:!0}})}async _unmuteMember(e,t){const i=s.decode(t);return this.keet.dispatch(e,"@keet/change-member-status",{memberKey:i,key:be.IsMuted,status:{isMuted:!1}})}async _isMemberMuted({db:e},t){const i=s.decode(t);return!!await e.get("@keet/muted-members",{key:i})}async _getMemberByDeviceId({myKey:e,snapshot:t,blobsSnapshot:i,localSnapshot:o},r){const a=await Se(t,s.decode(r));if(!a)return null;const n=!!await o.get("@local/active-contacts",{memberKey:a.key});return await Re(t,i,a.profile.avatar),await ct(t,a),v(a,e,n)}async _getMemberBySwarmId({myKey:e,snapshot:t,blobsSnapshot:i,localSnapshot:o},r){const a=s.decode(r),n=await t.get("@keet/devices-by-swarm-key",{profile:{swarmKey:a}});if(!n)return null;const c=await Se(t,n.key);if(!c)return null;const l=!!await o.get("@local/active-contacts",{memberKey:c.key});return await Re(t,i,c.profile.avatar),await ct(t,c),v(c,e,l)}async _getMemberCount({db:e}){const t=await e.get("@keet/threads",{id:0});return t?t.stats.members.active:0}async _getDevicesByMemberId({db:e},t){const i=[],o=s.decode(t),r={gte:{memberKey:o},lte:{memberKey:o}};for await(const t of e.find("@keet/devices-by-member-key",r))i.push(w(t));return i}getCurrentDeviceId(e){const t=this.keet.internalOpenExistingRoom(e);try{return t.deviceId}finally{this.keet.internalReleaseRoom(t)}}async _getMember({roomId:e,myKey:t,snapshot:i,blobsSnapshot:o,localSnapshot:r},a,n={}){const c=s.decode(a);if(!0===n.swarmId)return this.getMemberBySwarmId(e,a);const l=await i.get("@keet/members",{key:c});if(!l)return null;const h=!!await r.get("@local/active-contacts",{memberKey:l.key});return await Re(i,o,l.profile.avatar),await ct(i,l),v(l,t,h)}async _getActiveMember({myKey:e,snapshot:t,blobsSnapshot:i,localSnapshot:o},r){const a=await t.get("@keet/active-members",{key:s.decode(r)});if(!a)return null;const n=!!await o.get("@local/active-contacts",{memberKey:a.key});return await Re(t,i,a.profile.avatar),await ct(t,a),v(a,e,n)}async _removeMember(e,t){const i=s.decode(e),o=await this.keet.local.get("@local/rooms",{roomKey:i});if(!o)return;const{isFeatureSupported:r,FEATURES:a}=this.keet.versions;return r(o.digest.abi.version,a.REMOVE_MEMBER_V2)?this.keet.dispatch(e,"@keet/remove-member",{key:s.decode(t)}):void 0}async _getMembers({myKey:e,snapshot:t,blobsSnapshot:s,localSnapshot:i},o={}){const r=await t.find("@keet/members",G(o)).toArray();return Promise.all(r.map(async o=>{const r=!!await i.get("@local/active-contacts",{memberKey:o.key});return await Re(t,s,o.profile.avatar),await ct(t,o),v(o,e,r)}))}async _getActiveMembers({myKey:e,snapshot:t,blobsSnapshot:s,localSnapshot:i},o={}){const r=await t.find("@keet/active-members",G(o)).toArray();return Promise.all(r.map(async o=>{const r=!!await i.get("@local/active-contacts",{memberKey:o.key});return await Re(t,s,o.profile.avatar),await ct(t,o),v(o,e,r)}))}async _getModerators({myKey:e,snapshot:t,blobsSnapshot:s,localSnapshot:i},o={}){const r=await t.find("@keet/moderators",G(o)).toArray();return Promise.all(r.map(async o=>{const r=!!await i.get("@local/active-contacts",{memberKey:o.key});return await Re(t,s,o.profile.avatar),await ct(t,o),v(o,e,r)}))}getMemberForDevice(...e){throw console.log("getMemberForDevice",...e),new Error("Missing required method: getMemberForDevice")}subscribeMemberCount(e,...t){return this._addRoomSubscription(e,{query:()=>this.getMemberCount(e,...t),name:Ne})}subscribeMember(e,...t){return this._addRoomSubscription(e,{query:()=>this.getMember(e,...t),name:Ne})}subscribeActiveMember(e,...t){return this._addRoomSubscription(e,{query:()=>this.getActiveMember(e,...t),name:Ne})}subscribeActiveMembers(e,...t){return this._addRoomSubscription(e,{query:()=>this.getActiveMembers(e,...t),name:Ne})}subscribeMembers(e,...t){return this._addRoomSubscription(e,{query:()=>this.getMembers(e,...t),name:Ne})}subscribeModerators(e,...t){return this._addRoomSubscription(e,{query:()=>this.getModerators(e,...t),name:Ne})}subscribeMemberForDevice(e,...t){return this._addRoomSubscription(e,{query:()=>this.getMemberByDeviceId(e,...t),name:Ne})}_changeMemberRole(e,{memberId:t,role:i}){return this.keet.dispatch(e,"@keet/change-member-role",{key:s.decode(t),isAdmin:i===ye.ADMIN,isModerator:i===ye.ADMIN||i===ye.MODERATOR})}async _getSearchMembers({myKey:e,snapshot:t,blobsSnapshot:s,localSnapshot:i},o,{limit:r=50}={}){o=o.toLowerCase();const a=await t.find("@keet/members-by-member-name",{gte:{name:o},limit:r}).toArray();return(await Promise.all(a.map(async o=>{const r=!!await i.get("@local/active-contacts",{memberKey:o.key});return await Re(t,s,o.profile.avatar),await ct(t,o),v(o,e,r)}))).filter(e=>e.name.startsWith(o))}getPushNotificationMembers(...e){throw console.log("getPushNotificationMembers",...e),new Error("Missing required method: getPushNotificationMembers")}subscribeSearchMembers(...e){return console.log("subscribeSearchMembers",...e),new c}subscribePushNotificationMembers(...e){return console.log("subscribePushNotificationMembers",...e),new c}async _addContact(e,t,i){const o=s.decode(e);await this.keet.addContact(o,t,i)}async _setContactAlias(e,t){const i=s.decode(e);await this.keet.setContactAlias(i,t)}async _removeContact(e){const t=s.decode(e);await this.keet.removeContact(t)}async _getActiveContacts({localSnapshot:e}){return ge(e.find("@local/active-contacts"),async t=>{const s=await e.get("@local/members",{key:t.memberKey});return N(t,s)})}subscribeActiveContacts(){return this._addRoomSubscription(Ue,{query:()=>this.getActiveContacts()})}async _getContactInfo({local:e,profile:t},i){const o=s.decode(i),[r,a,n]=await Promise.all([e.get("@local/contacts",{memberKey:o}),e.findOne("@local/rooms-by-contact",{gte:{contact:o},lte:{contact:o}}),t.db.findOne("@keet-private-id/pending-contact-requests-by-member",{gte:{memberKey:o},lte:{memberKey:o}})]);return K(i,r,a,n)}subscribeContactInfo(e){return this._addRoomSubscription(Te,{query:async()=>{const t=this.keet.local.snapshot();try{const i=s.decode(e),[o,r]=await Promise.all([t.get("@local/contacts",{memberKey:i}),t.findOne("@local/rooms-by-contact",{gte:{contact:i},lte:{contact:i}})]);return K(e,o,r,null)}finally{await t.close()}}})}async _blockMember(e,t){const i=s.decode(t);return this.keet.blockContact(i)}async _unblockMember(e,t){const i=s.decode(t);return this.keet.unblockContact(i)}async _getBlockedMembers({localSnapshot:e}){return ge(e.find("@local/blocked-contacts"),async e=>N(e))}subscribeBlockedMembers(){return this._addRoomSubscription(Ue,{query:()=>this.getBlockedMembers()})}getConnectedMembers(...e){throw console.log("getConnectedMembers",...e),new Error("Missing required method: getConnectedMembers")}subscribeConnectedMembers(...e){return console.log("subscribeConnectedMembers",...e),new c}async _updateConfig(e,t,s){const i=function(e){switch(e){case"title":return ae.Title;case"avatar":return ae.Avatar;case"description":return ae.Description;case"supportedLanguages":return ae.SupportedLanguages;case"blindPeers":return ae.BlindPeers;default:return 0}}(t);if(0!==i){const t={[ne[i-1]]:s};await this.keet.dispatch(e,"@keet/update-room-config",{key:i,config:W(t)})}else if("roomType"===t){const t=rt(s);if(0===t)throw new Error("Invalid room type");await this.keet.dispatch(e,"@keet/update-system-settings",{key:ce.RoomType,settings:{roomType:t}})}else{if("canCall"!==t)throw new Error("Invalid config key");await this.keet.dispatch(e,"@keet/update-system-settings",{key:ce.IsCallingDisabled,settings:{isCallingDisabled:"false"===s}})}}async _updateRoomPreferences({profile:e},t,i,o){if(!ke(i))throw new Error(`invalid preference key: ${i}`);const r=s.decode(t);await this.keet.dispatch(e.id,"@keet-private-id/update-room-status",{roomKey:r,key:ot(i),status:{[_e(i)]:o}})}async _updateRoomSettings(e,t,i){if(t===se.IsAttachmentsDisabled&&!await this.keet.internalFeatureSupported(e,Pe.DISABLE_FILE_ATTACHMENTS))throw new Error("Disabling file attachments not supported");if(t===se.IsLinksDisabled&&!await this.keet.internalFeatureSupported(e,Pe.DISABLE_LINKS))throw new Error("Disabling links not supported");if(t===se.IsRoomInviteHidden&&!await this.keet.internalFeatureSupported(e,Pe.HIDE_ROOM_INVITE))throw new Error("Hiding room invite not supported");const o=s.decode(e);return this.keet.dispatch(o,"@keet/update-system-settings",{key:t,settings:i})}async _getRoomSettings(e){const t=s.decode(e),i=this.keet.internalOpenExistingRoom(t);try{return(await i.db.get("@keet/system-digest")).settings}finally{this.keet.internalReleaseRoom(i)}}async _getRoomPreferences({local:e},t,i){const o=s.decode(t),r=await e.get("@local/room-preferences",{roomKey:o});if(!r)return null;const{status:a}=r;return ke(i)?i?a[_e(i)]:a:null}async _getConfig({roomKey:e,local:t},s){const i=await t.get("@local/rooms",{roomKey:e});if(!i)return null;const{config:o,digest:r}=i,a=_(o,r)||{};return s?a[s]:a}subscribeConfig(e){return this._addRoomSubscription(e,{query:()=>this.getConfig(e)})}async _addChatMessage(e,t,i={}){const o=s.decode(e),r=await this.keet.local.get("@local/rooms",{roomKey:o});if(!r)return;const a=H(t,i),n=at(a),{isFeatureSupported:c,FEATURES:l}=this.keet.versions,h=c(r.digest.abi.version,l.MULTI_FILES);if(a.files.length&&!h)throw new Error("multi files not supported");const d=this.keet.batch(e);return 0!==await d.dispatch("@keet/add-chat-message",{timestamp:Date.now(),message:a})?((n.files.length||n.pearLink.length||n.httpLink.length)&&await nt(d,n),await d.flush()):void 0}async _updateChatMessage(e,t,i,o={}){const r=s.decode(e),a=await this.keet.local.get("@local/rooms",{roomKey:r});if(!a)return;const n=V(t),c=H(i,o),l=at(c),{isFeatureSupported:h,FEATURES:d}=this.keet.versions,u=h(a.digest.abi.version,d.MULTI_FILES);if(c.files.length&&!u)throw new Error("multi files not supported");const m=this.keet.batch(e);0!==await m.dispatch("@keet/update-chat-message",{oplog:n,message:c})&&((l.files.length||l.pearLink.length||l.httpLink.length)&&await nt(m,l,n),await m.flush())}async _removeChatMessage({roomKey:e,local:t,roomId:s,snapshot:i,blobsSnapshot:o,files:r},a){const n=await this._getChatMessageById({roomKey:e,local:t,snapshot:i,blobsSnapshot:o,files:r},a);if(!n)return null;if(n.files.length){const t=[];for(const s of n.files)t.push(this._clearFile({roomKey:e,files:r},s));await Promise.all(t)}return this.keet.dispatch(s,"@keet/remove-chat-message",{oplog:V(a)})}async _forwardChatMessage({roomKey:e,local:t,roomId:i,snapshot:o,blobsSnapshot:r,files:a},n,c){const[l,h]=await Promise.all([this.keet.local.get("@local/rooms",{roomKey:e}),this.keet.local.get("@local/rooms",{roomKey:s.decode(c)})]);if(!l||!h)return;const{isFeatureSupported:d,FEATURES:u}=this.keet.versions;if(!d(l.digest.abi.version,u.FORWARDED_MESSAGE))throw new Error("Message forwarding not supported");if(!d(h.digest.abi.version,u.FORWARDED_MESSAGE))throw new Error("Message forwarding not supported");const m=await o.get("@keet/chat-by-message-id",{oplog:V(n)});if(!m)throw new Error("Source message not found");if(!m.message.text)throw new Error("Source message has no text");const p=m.message.display||{};for(const e of p.httpLink||[])e.preview=null;for(const e of p.pearLink||[])e.preview=null;const g={text:m.message.text,forwarded:!0,files:[],display:p,replyTo:null,event:null};return this.keet.dispatch(c,"@keet/add-chat-message",{timestamp:Date.now(),message:g})}_pinChatMessage(e,t){return this.keet.dispatch(e,"@keet/pin-chat-message",{oplog:V(t),isPinned:!0})}_unpinChatMessage(e,t){return this.keet.dispatch(e,"@keet/pin-chat-message",{oplog:V(t),isPinned:!1})}async startCall(e,t={}){if(!await this.keet.internalFeatureSupported(e,Pe.CALLS_V2))return this.addCallStartedEvent(e);if(3!==t.version)throw new Error("Only calls v3 is supported");if(!t.streams)throw new Error("Streams are required");if((await this._getRoomSettings(e)).isCallingDisabled)throw Ke.CALL_DISABLED();if(!await this.keet.internalFeatureSupported(e,Pe.CALLS_V3))throw new Error("Calls v3 is not supported");return this.keet.internalStartCall(e,t.streams)}async joinCall(e,t,{version:s,streams:i=[]}={}){if(await this.keet.internalFeatureSupported(e,Pe.CALLS_V2)){if(3!==s)throw new Error("Only calls v3 is supported");if(!i.length)throw new Error("Streams are required");if(!await this.keet.internalFeatureSupported(e,Pe.CALLS_V3))throw new Error("Calls v3 is not supported");return this.keet.internalJoinCall(e,t,i)}}async leaveCall(e,t){if(await this.keet.internalFeatureSupported(e,Pe.CALLS_V2))return this.keet.internalLeaveCall(e,t)}async endCall(e,t){if(!await this.keet.internalFeatureSupported(e,Pe.CALLS_V2)){const t=s.decode(e);if(!(await this.keet.local.get("@local/rooms",{roomKey:t})).dm)return;return this.addCallHangupEvent(e)}return this.keet.internalEndCall(e,t)}async addCallStream(e,t,o){if(!await this.keet.internalFeatureSupported(e,Pe.CALLS_V2))throw new Error("Calls v2 is not supported");return this.keet.dispatch(e,"@keet/add-call-stream",{callKey:s.decode(t),streamKey:o.id?s.decode(o.id):i.randomBytes(32),mediaStreamId:o.mediaStreamId,type:o.type,muted:o.muted??!1})}async updateCallStream(e,t,i,{muted:o}){if(!await this.keet.internalFeatureSupported(e,Pe.CALL_STREAM_STATUS))throw new Error("Call stream status is not supported");return this.keet.dispatch(e,"@keet/update-call-stream",{callKey:s.decode(t),streamKey:s.decode(i),muted:o})}async removeCallStream(e,t,i){if(!await this.keet.internalFeatureSupported(e,Pe.CALLS_V2))throw new Error("Calls v2 is not supported");return this.keet.dispatch(e,"@keet/remove-call-stream",{callKey:s.decode(t),streamKey:s.decode(i)})}async startCallRecording(e,t){if(!await this.keet.internalFeatureSupported(e,Pe.CALL_RECORDING))throw new Error("Call recording is not supported");return this.keet.dispatch(e,"@keet/start-call-recording",{callKey:s.decode(t)})}async stopCallRecording(e,t){if(!await this.keet.internalFeatureSupported(e,Pe.CALL_RECORDING))throw new Error("Call recording is not supported");return this.keet.dispatch(e,"@keet/stop-call-recording",{callKey:s.decode(t)})}async _getActiveCalls({engine:e,snapshot:t},s={}){return(await me(t,"@keet/active-calls-by-timestamp")).map(t=>B(t,{...s,deviceKey:e.local.key}))}async _getCalls({snapshot:e},t={}){return(await me(e,"@keet/calls-by-timestamp")).map(e=>B(e,t))}async _getAllActiveCalls({localSnapshot:e},t={}){if(!0===t.rejoin){const t=e.find("@local/rooms-by-active-call",{reverse:!0});for await(const e of t)if(e.activeCall.selfDeviceKey)return lt(e);return null}const s=[];for await(const t of e.find("@local/rooms-by-active-call"))s.push(lt(t));return s}subscribeAllActiveCalls(e){return this._addKeetSubscription(ze,{query:()=>this.getAllActiveCalls(e)})}subscribeActiveCalls(e,...t){return this._addRoomSubscription(e,{query:()=>this.getActiveCalls(e,...t)})}subscribeCalls(e,...t){return this._addRoomSubscription(e,{query:()=>this.getCalls(e,...t)})}subscribeCallProxy(e){const t=this.keet.callProxy.getCallById(e);if(!t)throw Ke.CALL_NOT_ACTIVE("",{callId:e});const s=new c,i=({swarmId:e,proxyPort:t})=>s.push({type:"peer",swarmId:e,proxyPort:t}),o=({swarmId:e,data:t})=>s.push({type:"signal",swarmId:e,data:t}),r=({swarmId:e})=>s.push({type:"peer-close",swarmId:e});t.on("peer",i),t.on("signal",o),t.on("peer-close",r);for(const[e,i]of t.openPeers())s.push({type:"peer",swarmId:e,proxyPort:i});return s.once("close",()=>{t.off("peer",i),t.off("signal",o),t.off("peer-close",r)}),s}signalCallPeer(e,t,s){const i=this.keet.callProxy.getCallById(e);if(!i)throw Ke.CALL_NOT_ACTIVE("",{callId:e});i.signal(t,s)}_addCallStartedEvent(e){return this.addChatMessage(e,null,{callStarted:!0})}_addCallHangupEvent(e){return this.addChatMessage(e,null,{callHangup:!0})}_addCallMissedEvent(e){return this.addChatMessage(e,null,{callMissed:!0})}async _addLocationSharedEvent(e,t,{locationShared:{latitude:i,longitude:o}}){const r=s.decode(e),a=await this.keet.local.get("@local/rooms",{roomKey:r});if(!a)return;const{isFeatureSupported:n,FEATURES:c}=this.keet.versions;if(!n(a.digest.abi.version,c.LOCATION_SHARED_EVENT))throw new Error("Location sharing not supported");return this.addChatMessage(e,t,{locationShared:{latitude:i,longitude:o}})}addRoomAvatarChangedEvent(...e){console.log("addRoomAvatarChangedEvent",...e),console.warn("Missing required method: addRoomAvatarChangedEvent")}addEvent(...e){console.log("addEvent",...e),console.warn("Missing required method: addEvent")}removeEvent(...e){console.log("removeEvent",...e),console.warn("Missing required method: removeEvent")}async _getChatMessage({roomKey:e,local:t,snapshot:s,blobsSnapshot:i,files:o},r){return(await le(async function(){const t=j(e,{gte:r,lte:r});return await s.findOne("@keet/chat",t)},e,t,s,i,o))[0]}async _getChatMessageById({roomKey:e,local:t,snapshot:s,blobsSnapshot:i,files:o},r){return(await le(async function(){return await s.get("@keet/chat-by-message-id",{oplog:V(r)})},e,t,s,i,o))[0]}async _getChatMessages({roomKey:e,local:t,snapshot:s,blobsSnapshot:i,files:o},r){return await le(async function(){const t=j(e,r);return await s.find("@keet/chat",t).toArray()},e,t,s,i,o)}async _getPinnedChatMessages({roomKey:e,local:t,snapshot:s,blobsSnapshot:i,files:o},r){return await le(async function(){return await s.find("@keet/pinned-chat-messages",r).toArray()},e,t,s,i,o)}async _getChatLength({db:e}){const t=await e.get("@keet/threads",{id:0});return{length:t?t.count:0}}subscribeChatMessages(e,...t){return this._addRoomSubscription(e,{query:()=>this.getChatMessages(e,...t)})}subscribeChatLength(e,t){let s=null;return this._addRoomSubscription(e,{query:async()=>{if(!t||!t.reorders)return this.getChatLength(e);if(this.keet.closing)return null;const i=this.keet.internalOpenExistingRoom(e);try{const{length:t}=await this.getChatLength(e),{undos:o,fastForwards:r}=i.engine.stats,a=null!==s&&(o!==s.undos||r!==s.fastForwards);return s={undos:o,fastForwards:r},{length:t,reordered:a}}finally{this.keet.internalReleaseRoom(i)}}})}async _searchChatMessages({snapshot:e,roomKey:t,local:s,blobsSnapshot:i,files:o},a,{limit:n=1e3,reverse:c=!0}={}){if(!a||!a.length)return[];const l=await s.get("@local/rooms",{roomKey:t});if(!l)return[];if(!(a=a.map(e=>e.replace(/\s/g,"").toLowerCase()).filter(e=>e)).length)return[];const h=[];for await(const s of e.find("@keet/chat",{limit:n,reverse:c})){if(!s.message?.text)continue;const n=s.message.text.replace(/\s/g,"").toLowerCase();if(a.every(e=>n.indexOf(e)>-1)){const a=he(t,e,i,l,o,s);a.catch(r),h.push(a)}}return Promise.all(h)}createChatSearchStream(e,t,s){return c.from(this._createChatSearchGenerator(e,t,s))}async*_createChatSearchGenerator(e,t,{limit:i=1e3,reverse:o=!0}={}){if(!t||!t.length)return;if(!(t=t.map(e=>e.replace(/\s/g,"").toLowerCase()).filter(e=>e)).length)return;const r=s.decode(e),a=await this.keet.local.get("@local/rooms",{roomKey:r});if(!a)return;const n=this.keet.internalOpenExistingRoom(r);await n.ready();const c=n.db.snapshot(),l=n.blobs?n.blobs.snapshot():null,h=this.keet.local.snapshot(),d=this.keet.files,u=c.find("@keet/chat",{limit:i,reverse:o});try{for await(const e of u){const t=await m(e);t&&(yield t)}}catch(e){this.keet.onerror(e)}finally{await h.close(),await c.close(),l&&await l.close(),this.keet.internalReleaseRoom(n)}async function m(e){const t=p(e.message?.text);let i=!1;if(e&&e.message&&e.message.files&&(i=!!e.message.files.length),!i&&!g(t))return;const o=await he(r,c,l,a,d,e);if(i&&!g(t)&&!function(e){return e.files.some(e=>g(p(e.metadata?.name)))}(o))return;if(o.labels.flagged||o.labels.flags>=we)return;const n=s.decode(o.memberId);return await h.get("@local/blocked-contacts",{memberKey:n})||await c.get("@keet/muted-members",{key:n})||o.reactions.digest.reactions.find(e=>"⚠️"===e.text)?void 0:o}function p(e){return e?e.replace(/\s/g,"").toLowerCase():""}function g(e){return!!e&&t.every(t=>e.indexOf(t)>-1)}}_sendDMFromContact(e,{message:t=null}={}){return this.keet.sendContactRequestFromContact(e,{message:t})}_sendDMRequest(e,t,{message:s=null}={}){return this.sendInvitations(e,{receivers:[t],message:s})}async _sendInvitations(e,{receivers:t,message:i}){const o=s.decode(e),r=Array.isArray(t)?t[0]:t,a=s.decode(r);await this.keet.sendContactRequest(o,a,{message:i})}async _updatePrivateMailboxRecord({memberId:e,roomId:t},i={}){this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready();const o=i.isSeen||1===i.seen;return this.keet.privateProfile.dispatch("@keet-private-id/update-contact-request-status",{memberKey:s.decode(e),roomKey:s.decode(t),key:oe.IsSeen,status:{isSeen:o}})}async _getDmRequestsByStatus({localSnapshot:e,profileDb:t},s,{reverse:i=!0,limit:o=50}={}){if(!t)return[];const r={[fe.ACCEPTED]:"@keet-private-id/accepted-contact-requests-v2",[fe.REJECTED]:"@keet-private-id/rejected-contact-requests-v2",[fe.PENDING]:"@keet-private-id/pending-contact-requests-v2",[fe.DISCARDED]:"@keet-private-id/discarded-contact-requests-v2"}[s]||"@keet-private-id/pending-contact-requests-v2",a=t.find(r,{reverse:i,limit:o});return ge(a,async t=>{const s=await e.get("@local/active-contacts",{memberKey:t.memberKey});return I(t,s)})}subscribeDmRequestsByStatus(e,t={}){return this._addRoomSubscription(Ue,{query:()=>this.getDmRequestsByStatus(e,t)})}async _getPrivateMailboxRecords({profile:e},t={}){console.warn("Deprecated: getPrivateMailboxRecords")}subscribePrivateMailbox(){return console.warn("Deprecated: subscribePrivateMailbox"),new c}getSentPrivateMailboxRecords(...e){console.warn("Deprecated: getSentPrivateMailboxRecords")}subscribeSentPrivateMailbox(...e){return console.warn("Deprecated: subscribeSentPrivateMailbox"),new c}async _getDmByMemberId({profileSnapshot:e},t){const o=s.decode(t),[r,a]=await Promise.all([e.get("@keet-private-id/contacts",{memberKey:o}),e.get("@keet-private-id/contact-requests",{memberKey:o})]);let n=null;return r&&r.roomKey?n=r.roomKey:a&&(n=a.keys.key),{roomId:n?s.encode(n):null,discoveryId:n?s.encode(i.discoveryKey(n)):null,dmMemberId:t,recipient:t}}async updateRoomInvitationSeenStatus({discoveryId:e,invitationId:t},i){return this.keet.updateRoomInvitationSeenStatus(s.decode(e),s.decode(t),i)}async _acceptDmRequest({memberId:e,roomId:t}){return this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready(),this.keet.privateProfile.dispatch("@keet-private-id/update-contact-request-status",{memberKey:s.decode(e),roomKey:s.decode(t),key:oe.IsAccepted,status:{isAccepted:!0}})}async _rejectDmRequest({memberId:e,roomId:t}){return this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready(),this.keet.privateProfile.dispatch("@keet-private-id/update-contact-request-status",{memberKey:s.decode(e),roomKey:s.decode(t),key:oe.IsRejected,status:{isRejected:!0}})}async discardDmRequest({memberId:e,roomId:t}){return this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready(),this.keet.privateProfile.dispatch("@keet-private-id/update-contact-request-status",{memberKey:s.decode(e),roomKey:s.decode(t),key:oe.IsDiscarded,status:{isDiscarded:!0}})}_addReaction(e,t,i){return this.keet.dispatch(e,"@keet/add-reaction",{oplog:{key:s.decode(t.deviceId),seq:t.seq},reaction:i})}_removeReaction(e,t,i){return this.keet.dispatch(e,"@keet/remove-reaction",{oplog:{key:s.decode(t.deviceId),seq:t.seq},reaction:i})}async _getLatestReactions({snapshot:e},t,s,{limit:i}={}){const{id:o}=await e.get("@keet/chat-by-message-id",{oplog:V(t)});return(await e.find("@keet/reactions-by-clock",{gte:{id:o,reaction:s},lte:{id:o,reaction:s},limit:i,reverse:!0}).toArray()).map(e=>M(e))}async _getReactions({roomKey:e,snapshot:t,local:s},i){const o=V(i);return de({roomKey:e,snapshot:t,local:s,oplog:o})}subscribeReactions(e,t){return this._addRoomSubscription(e,{query:()=>this.getReactions(e,t)})}subscribeReportedMessages(e,...t){return this._addRoomSubscription(e,{query:()=>this.getReportedMessages(e,...t)})}subscribeReportedMembers(e,...t){return this._addRoomSubscription(e,{query:()=>this.getReportedMembers(e,...t),name:Ne})}async _getReportedMembers({snapshot:e,blobsSnapshot:t,localSnapshot:i},{clock:o,limit:r=50}={}){const a=await e.find("@keet/member-label-digests-by-clock",{gte:{label:te.Flag},lte:{label:te.Flag,clock:o},limit:r<=50?r:50,reverse:!0}),n=[];for await(const e of a){const t=c.bind(this);n.push(t(e))}return await Promise.all(n);async function c(o){const{key:r,total:a,flagsClock:n}=o,c=await this._getMember({snapshot:e,blobsSnapshot:t,localSnapshot:i},s.encode(r));return c.labels={total:a,flagsClock:n},c}}reportMember(e,t){return this.keet.dispatch(e,"@keet/add-member-label",{key:s.decode(t),label:te.Flag})}async _getReportedMessages({roomKey:e,local:t,snapshot:s,blobsSnapshot:i,files:o},{clock:r,limit:a=50}={}){const n=await t.get("@local/rooms",{roomKey:e});if(!n)return;const c=await s.find("@keet/chat-label-digests-by-clock",{gte:{label:ee.Flag},lte:{label:ee.Flag,clock:r},limit:a<=50?a:50,reverse:!0}),l=[];for await(const{id:e}of c)l.push(h(e));return await Promise.all(l);async function h(t){const r=await s.findOne("@keet/chat",{gte:{id:t},lte:{id:t}});return he(e,s,i,n,o,r)}}_addChatReport(e,t){const s=V(t);return this.keet.dispatch(e,"@keet/add-chat-label",{oplog:s,label:ee.Flag})}_removeChatReport(e,t){const s=V(t);return this.keet.dispatch(e,"@keet/remove-chat-label",{oplog:s,label:ee.Flag})}async _dismissChatReports(e,t){if(!await this.keet.internalFeatureSupported(e,Pe.DISMISS_CHAT_REPORTS))throw new Error("Dismissing chat reports is not supported");const s=V(t);return this.keet.dispatch(e,"@keet/dismiss-chat-reports",{oplog:s})}addFileBlob(...e){throw console.log("addFileBlob",...e),new Error("Missing required method: addFileBlob")}addFile(...e){throw console.log("addFile",...e),new Error("Missing required method: addFile")}async _saveFileBlob({roomKey:e,files:t},s,i){const o=await t.saveFileBlob(e,s,i);return S(o)}async _saveFile({roomKey:e,files:t},s,i){const o=await t.saveFile(e,s,i);return S(o)}subscribeAddFile(e,t,i){const o=s.decode(e);return h(this.keet.files.subscribeAddFile(o,t,i),new l({transform(e,t){t(null,{...e,result:S(e.result)})}}))}async _sendFile(e,t){const s=t.preview;t.preview=null;const i=this.keet.batch(e),o=await i.dispatch("@keet/add-chat-message",{timestamp:Date.now(),message:H(null,{files:[t]})});0!==o&&(s&&await i.dispatch("@keet/add-file-preview",{oplog:{key:i.key,seq:o-1},index:0,preview:Y(s)},{dryRun:!1}),await i.flush())}async _sendFiles(e,t=[]){const s=[];for(const e of t)s.push(e.preview),e.preview=null;const i=this.keet.batch(e),o=await i.dispatch("@keet/add-chat-message",{timestamp:Date.now(),message:H(null,{files:t})});if(0===o)return;const r={key:i.key,seq:o-1};for(let e=0;e<s.length;e++){const t=s[e];t&&await i.dispatch("@keet/add-file-preview",{oplog:r,index:e,preview:Y(t)},{dryRun:!1})}await i.flush()}removeFile(...e){throw console.log("removeFile",...e),new Error("Missing required method: removeFile")}subscribeFileInfo(e,t){const i=s.decode(e),o=this;let r=null;return new c({async open(e){let s=null;try{r=await o.keet.files.monitor(i,z(t)),r.on("update",e=>{this.push(r.stats)})}catch(e){s=e}e(s)},async destroy(e){r&&r.close(),e(null)}})}async _clearAllFiles({roomId:e,roomKey:t,files:s},i){const o=await s.clearAllFiles(t,i);return this.keet.emit("local-files-changed",e),o}async _clearOldFiles(){return this.keet.files.clearOldFiles()}async _getFileEntry({roomKey:e,files:t},s){const i=await t.getFileEntry(e,z(s));return A(i)}async _getLocalFiles({roomKey:e,files:t,snapshot:s,blobsSnapshot:i}){const o=await t.getLocalFiles(e);return Promise.all(o.map(async o=>{const r=await t.getFileEntryWithPreview(e,o.file,{loadBlob:e=>pe(e,s,i)});return{...S(r.file),entry:A(r)}}))}async _getFiles({roomKey:e,files:t,snapshot:i,blobsSnapshot:o},r={}){const a=J(r),n=await i.find(r.type?"@keet/files-by-major-type":"@keet/active-files",a).toArray();return Promise.all(n.map(async r=>{const a=await t.getFileEntryWithPreview(e,r.file,{loadBlob:e=>pe(e,i,o)});return{...S(a.file),id:r.id,messageId:{deviceId:s.encode(r.oplog.key),seq:r.oplog.seq},entry:A(a)}}))}_startDownload({roomKey:e,files:t},s){return t.startDownload(e,z(s))}_cancelDownload({roomKey:e,files:t},s){return t.cancelDownload(e,s)}readFileStream(e,t,i){const o=s.decode(e);return this.keet.files.readFileStream(o,z(t),i)}subscribeSaveToDisk(e,t,i,o={}){const r=s.decode(e);return this.keet.files.subscribeSaveToDisk(r,z(t),i,o)}_saveToDisk({roomKey:e,files:t},s,i){return t.saveToDisk(e,z(s),i)}async _clearFile({roomId:e,roomKey:t,files:s},i){i.preview?.large?.pointer?.externalBlob&&await s.clearFile(t,z(i.preview.large)),await s.clearFile(t,z(i)),this.keet.emit("local-files-changed",e)}async _unclearFile({roomId:e,roomKey:t,files:s},i){i.preview?.large?.pointer?.externalBlob&&await s.unclearFile(t,z(i.preview.large)),await s.unclearFile(t,z(i)),this.keet.emit("local-files-changed",e)}_getFileCleared({roomKey:e,files:t},s){return t.getFileCleared(e,z(s))}_refreshFileLinks(e){return this.keet.files.refreshLinks(e)}subscribeFileCleared(e,t){return this._addRoomSubscription(e,{query:()=>this.getFileCleared(e,t)})}subscribeFiles(e,...t){return this._addRoomSubscription(e,{query:async()=>this.getFiles(e,...t)})}getStats(){return{suspended:this.keet.state===qe.SUSPEND,onlineBoot:this.keet.onlineBoot.opened,connections:this.keet.swarm.connections.size,openRooms:this.keet.rooms.size,openRoomIds:[...this.keet.rooms.keys()],openCores:this.keet.store.cores.size,blindPeering:this.keet.blindPeering?.stats??null,activeRooms:this.keet.activeRooms.size,roomSubscriptions:[...this._subscriptions.values()].filter(e=>e.isRoomSub).size,backgroundSwarmingRooms:[...this.keet.swarmWorker.sessions.keys()],dht:this.keet.swarm.dht.stats,swarm:this.keet.swarm.stats,ops:this.keet.stats.ops,uploaded:this.keet.stats.uploaded,bytesUploaded:this.keet.stats.bytesUploaded,downloaded:this.keet.stats.downloaded,bytesDownloaded:this.keet.stats.bytesDownloaded,appends:this.keet.stats.appends,bytesAppended:this.keet.stats.bytesAppended,ipc:{sent:0,recv:0},threads:[]}}async getRoomStats(e){const t=this.keet.internalOpenExistingRoom(s.decode(e));try{return await t.getStats()}finally{this.keet.internalReleaseRoom(t)}}async _lookupUsername(e){if(!e)return;const t=await this.keet.userRegistry.lookup(e);return E(t)}async _lookupUserByMemberId(e){if(!e)return;const t=s.decode(e),i=await this.keet.userRegistry.lookupByKey(t);return E(i)}async _searchUsername(e,{limit:t=20}={}){return(await this.keet.userRegistry.search(e,{limit:t})).map(E)}_registerUsername(e){return this.keet.userRegistry.update(e)}_updateUsername(e){return this.keet.userRegistry.update(e)}async _getReservationsByKey(e){if(!e)return;const t=s.decode(e),i=await this.keet.userRegistry.getReservationsByKey(t);if(!i||!i.length)return null;const o=i[0];return P(o)}subscribeUsername(){const e=this.keet.userRegistry.subscribeUsername();return h(e,new l({transform(e,t){if(!e)return t(null);t(null,{status:e.status,reservation:P(e.reservation),record:E(e.record),error:e.error})}}))}_checkUsername(e){return this.keet.userRegistry.isAvailable(e)}subscribeSystemUpdateRequest(){return this._addKeetSubscription(Oe,{query:()=>this.keet.migrationStatus||{remaining:0}})}async autobeeLogs(e){const t=this.keet.internalOpenExistingRoom(s.decode(e));try{await t.ready(),await t.engine.logs()}finally{this.keet.internalReleaseRoom(t)}}close(){return this.keet.close()}suspend(){return this.keet.suspend()}resume(){return this.keet.resume()}async getDebugFlags(){const e=await this.keet.local.get("@local/debug");return e?.flags||[]}async updateDebugFlag(e,t){const s=Ie.get(e);if(!(s>=0))return;const i=await this.keet.internalEnterLocalTransaction();try{const e=await i.get("@local/debug");e.flags[s].value=!0===t,await i.insert("@local/debug",e),await i.flush()}finally{await this.keet.internalExitLocalTransaction()}}createErrorStream(){return h(this.keet.local.find("@local/errors"),new l({transform(e,t){t(null,F(e))}}))}async _repair(e){const t=this.keet.internalOpenExistingRoom(s.decode(e));try{await t.ready(),await t.engine.repair()}finally{this.keet.internalReleaseRoom(t)}}async _audit(e){const t=this.keet.rootCorestore.audit(e),s=[];for await(const e of t)s.push(e);return s}async _rotateWriter(e){return this.keet.rotateWriter(s.decode(e))}compact(e=!1){return e?this.keet.storage.compact({blobGarbageCollectionPolicy:Ae.garbageCollectionPolicy.FORCE,blobGarbageCollectionAgeCutoff:1,bottommostLevelCompaction:Ae.bottommostLevelCompaction.FORCE}):this.keet.storage.compact()}async _setUnread(e,t){const i=s.decode(e),o=await this.keet.internalEnterLocalTransaction();try{await o.insert("@local/unreads",{roomKey:i,count:t}),await o.flush()}finally{await this.keet.internalExitLocalTransaction()}}async _getUnread(e){const t=s.decode(e),i=await this.keet.local.get("@local/unreads",{roomKey:t});return i?i.count:0}async _setUnreadAnchor(e,t){const i=s.decode(e);this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready(),this.keet.unreads&&await this.keet.unreads.put(i,{timestamp:Date.now(),length:t});const o=await this.keet.local.get("@local/rooms",{roomKey:i});if(!o?.dm?.length)return;const{isFeatureSupported:r,FEATURES:a}=this.keet.versions;if(!r(o.digest.abi.version,a.READ_LENGTH))return;const n=await this.keet.internalOpenPrivateProfile();try{const s=await n.db.get("@keet-private-id/settings");if(s?.disableReadReceipts)return;await this.keet.dispatch(e,"@keet/update-read-length",{length:t})}finally{this.keet.internalReleaseRoom(n)}}async _getUnreadAnchor(e){if(this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready(),!this.keet.unreads)return null;const t=s.decode(e);return this.keet.unreads.get(t)}_subscribeUnreadAnchor(e){return this._addKeetSubscription(He,{query:()=>this.getUnreadAnchor(e)})}async _updateTypingIndicator({roomId:e,db:t}){this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready();const s=await t.get("@keet/system-digest");if(s.settings.roomType!==Z.DirectMessage)return;const{isFeatureSupported:i,FEATURES:o}=this.keet.versions;if(!i(s.abi.version,o.TYPING_INDICATOR))throw new Error("Typing indicator is not supported");await this.keet.dispatch(e,"@keet/update-typing-indicator",{})}async _getTypingIndicator({db:e},t){const i=s.decode(t),o=await e.get("@keet/typing-indicators",{memberKey:i});return o?{memberId:t,timestamp:o.timestamp}:null}_subscribeTypingIndicator(e,t){return this._addRoomSubscription(e,{query:()=>this.getTypingIndicator(e,t),name:"typing-indicator"})}async _setRoomFavorite(e,t=!0){this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready();const{privateProfileKey:i}=await this.keet.local.get("@local/identity"),o=await this.keet.local.get("@local/rooms",{roomKey:i});if(!o)return;const{isFeatureSupported:r,FEATURES:a}=this.keet.versions;if(!r(o.digest.abi.version,a.FAVORITE_ROOMS))throw new Error("Favorite rooms is not supported");await this.keet.privateProfile.dispatch("@keet-private-id/update-room-status",{roomKey:s.decode(e),key:re.IsFavorite,status:{isFavorite:t}})}}class Xe{constructor(e){this.keet=e}async ready(){return await this.keet.ready(),s.encode(this.keet.swarm.keyPair.publicKey)}}class Ze{constructor(t){this.keet=t,this.preferences=new g(e.join(t.dir,"preferences_v1.json")),this._subs=[]}async _bump(){const e=await this.preferences.list();for(const t of this._subs)t.push(e)}async update(e,t){await this.preferences.set(e,t),await this._bump()}query(){return this.preferences.list()}subscribe(){const e=this,t=new c({async open(e){let t=null;try{await this._bump()}catch(e){t=e}e(t)},destroy(t){const s=e._subs.indexOf(this);-1!==s&&e._subs.splice(s,1),t(null)}});return this._subs.push(t),t}}class Qe{constructor(e,{onerror:t=r}={}){this.keet=e,this._status=null,this._subs=[],this.keet.swarm.on("update",this._handleUpdate.bind(this)),this.keet.swarm.dht.on("network-update",this._handleUpdate.bind(this))}_handleUpdate(){this._status=this.query();for(const e of this._subs)e.push(this._status)}query(){const e=[];for(const[t,i]of this.keet.swarm.peers)e.push(s.encode(i.publicKey));return{host:this.keet.swarm.dht.host,port:this.keet.swarm.dht.port,online:this.keet.swarm.dht.online,degraded:this.keet.swarm.dht.degraded,connections:this.keet.swarm.connections.size,dhtPublicKey:s.encode(this.keet.swarm.dht.defaultKeyPair.publicKey),swarmPublicKey:s.encode(this.keet.swarm.keyPair.publicKey),peers:e}}subscribe(){const e=this,t=new c({open(t){e._status&&this.push(e._status),t(null)},destroy(t){const s=e._subs.indexOf(this);-1!==s&&e._subs.splice(s,1),t(null)}});return this._subs.push(t),t}subscribeDebug(e=5e3,t=0){const s=this;let i=null,o=0;const r=new c({open(t){a(),i=setInterval(()=>{a()},e),t(null)},destroy(e){i&&(clearInterval(i),i=null),e(null)}});return r;async function a(){const e=await s.debug();r.push(e),o+=1,t&&o>=t&&r.push(null)}}async debug(){return{tick:this.keet.swarm.dht._tick,localAddress:this.keet.swarm.dht.localAddress(),remoteAddress:this.keet.swarm.dht.remoteAddress(),connection:this.query(),stats:this.keet.swarm.dht.stats,health:this.keet.swarm.dht.health.stats,nodes:this.keet.swarm.dht.nodes.length,config:this.keet.swarm.dht.config,rttStats:await this.keet.swarm.dht.rttStats()}}}class et{constructor(e,{onerror:t=r}={}){this.keet=e,this._status=null,this._subs=[],this.swarm=null,this._onupdate=this._handleUpdate.bind(this),this.keet.on("call-swarm-changed",this._handleCallSwarmChanged.bind(this))}_handleCallSwarmChanged(e,t){this.swarm&&this.swarm.dht.removeListener("network-update",this._onupdate),this.swarm=t,this.swarm&&this.swarm.dht.on("network-update",this._onupdate),this._handleUpdate()}_handleUpdate(){this._status=this.query();for(const e of this._subs)e.push(this._status)}query(){if(!this.swarm)return{active:!1,host:null,port:0,online:!1,degraded:!1,connections:0,peers:[]};const e=[];for(const t of this.swarm.peers.values())e.push(s.encode(t.publicKey));return{active:!0,host:this.swarm.dht.host,port:this.swarm.dht.port,online:this.swarm.dht.online,degraded:this.swarm.dht.degraded,connections:this.swarm.connections.size,peers:e}}subscribe(){const e=this,t=new c({open(t){e._status&&this.push(e._status),t(null)},destroy(t){const s=e._subs.indexOf(this);-1!==s&&e._subs.splice(s,1),t(null)}});return this._subs.push(t),t}subscribeDebug(e=5e3,t=0){const s=this;let i=null,o=0;const r=new c({open(t){a(),i=setInterval(()=>{a()},e),t(null)},destroy(e){i&&(clearInterval(i),i=null),e(null)}});return r;async function a(){const e=await s.debug();r.push(e),o+=1,t&&o>=t&&r.push(null)}}async debug(){return this.swarm?{active:!0,tick:this.swarm.dht._tick,localAddress:this.swarm.dht.localAddress(),remoteAddress:this.swarm.dht.remoteAddress(),connection:this.query(),stats:this.swarm.dht.stats,health:this.swarm.dht.health.stats,nodes:this.swarm.dht.nodes.length,config:this.swarm.dht.config,rttStats:await this.swarm.dht.rttStats()}:{active:!1}}}class tt{constructor(){this.subscriptions=[],this._handleError=this._handleError.bind(this),this._listenersAttached=!1}_handleError(e){console.error("uncaught on worker",e);for(const t of this.subscriptions)t.push({message:e.message,stack:e.stack+""})}subscribe(e){const t=this;this._listenersAttached||(n.on(this._handleError),this._listenersAttached=!0);const s=new c({...e,destroy(e){const s=t.subscriptions.indexOf(this);-1!==s&&t.subscriptions.splice(s,1),e(null)}});return this.subscriptions.push(s),s}}class st{constructor(e){this.keet=e,this.inspector=new De}_getCurrentRoom(){let e=null;for(const t of this.keet.rooms.values())(!e||t.refs>e.refs)&&(e=t);return e}async getCurrentRoomStats(){const e=this._getCurrentRoom();return{hash:(await(e?.engine.core.treeHash())).toString("hex"),length:e?.engine.length}}enableInspector(){return this.inspector?.enable()}disableInspector(){return this.inspector?.disable()}getInspectorKey(){return this.inspector?.key}processTop(){return p.toJSON()}hash(e){return i.hash(e)}generateSyntheticError(e,t={}){const s=new Error(t.message??t.code??"KEET_SYNTHETIC_ERROR");if(s.code=t.code??s.message,Object.assign(s,t),!e)throw s;this.keet.onerror(s)}async getAccumulatedBytes(){let e=0;for await(const{value:t}of this.keet.rootCorestore.storage.db.iterator()){if(this.keet.closing)return e;e+=t.byteLength}return e}async heapSnapshot(e="/tmp/keet-heapsnapshot-"+Bare.pid+"."+Date.now()+".heapsnapshot"){const t=new d;t.connect();const s=new u(t),i=m.createWriteStream(e);return s.pipe(i),await new Promise(e=>i.once("close",e)),t.destroy(),e}async resetUnreads(){if(this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready(),!this.keet.unreads)return null;await this.keet.unreads.reset()}}class it{constructor(e){this._rpcClient=e.rpcClient,this.keet=e}send(e){if(this.keet.buildType===X.Production)return this._rpcClient.makeRequest(this.keet.config.services.feedback,"send",e,{requestEncoding:Ce.json})}}function ot(e){switch(e){case 1:return re.IsFullyMuted;case 2:return re.IsMentionsOnlyMuted;default:return 0}}function rt(e){switch(e){case"0":default:return Z.Default;case"1":return Z.Broadcast;case"2":return Z.DirectMessage}}function at(e){const t={files:[],httpLink:[],pearLink:[]},s=e.files||[];for(let e=0;e<s.length;e++){const i=s[e].preview;i&&(s[e].preview=null,t.files.push({index:e,preview:i}))}const i=e.display?.httpLink||[];for(let e=0;e<i.length;e++){const s=r(i[e]);s&&t.httpLink.push({index:e,preview:s})}const o=e.display?.pearLink||[];for(let e=0;e<o.length;e++){const s=r(o[e]);s&&t.pearLink.push({index:e,preview:s})}return t;function r(e){if(!e.preview?.file?.preview)return null;const t=e.preview.file.preview;return e.preview.file.preview=null,t}}async function nt(e,{files:t,httpLink:s,pearLink:i},o=null){const r=o||{key:e.key,seq:e.length-1};if(t.length)for(const{index:s,preview:i}of t)await e.dispatch("@keet/add-file-preview",{oplog:r,index:s,preview:Y(i)},{dryRun:!1});if(s.length)for(const{index:t,preview:i}of s)await e.dispatch("@keet/add-file-preview",{oplog:r,index:t,preview:Y(i),displayType:Q.HttpLink},{dryRun:!1});if(i.length)for(const{index:t,preview:s}of i)await e.dispatch("@keet/add-file-preview",{oplog:r,index:t,preview:Y(s),displayType:Q.PearLink},{dryRun:!1})}async function ct(e,t){t.proofs=await e.get("@keet/member-proofs",{key:t.key})}function lt(e){const t=U(e.activeCall);return{roomId:s.encode(e.roomKey),callId:t.callId,selfDeviceId:t.selfDeviceId,createdAt:t.createdAt}}module.exports=class extends t{constructor(e,t){super(),this.keet=e,this.opts=t,this.api={core:new $e(e,t),swarm:null,preferences:null,network:null,error:null,debug:null,console:null,call:null,pear:{teardown:()=>{console.log("[api] teardown initiated");const t=this.keet.close();return t.catch(e.onerror),t},selfDestruct:e=>this.keet.selfDestruct(e)}},this._callBootstraps=null,this.ready().catch(t?.onerror||r)}async _open(){await this.keet.ready(),this.api.swarm=new Xe(this.keet,this.opts),this.api.preferences=new Ze(this.keet,this.opts),this.api.network=new Qe(this.keet,this.opts),this.api.callNetwork=new et(this.keet,this.opts),this.api.error=new tt(this.keet,this.opts),this.api.debug=new st(this.keet,this.opts),this.api.feedback=new it(this.keet),this.call=this.api.call=new b(this.keet.swarm,{skipJoinLeave:!0}),this.keet.on("call-changed-v3",this._handleCallChangedV3.bind(this))}async _close(){this.call&&this.call.close(),await this.api.debug.disableInspector()}async closeActiveCalls(){if(!this.keet.activeCall)return;const{roomId:e,callKey:t}=this.keet.activeCall,i=await this.keet.local.get("@local/rooms",{roomKey:s.decode(e)});if(!i)return;const o=this.keet.rooms.get(e);if(!o)return;const r=i.dm?"@keet/end-call":"@keet/leave-call";await o.dispatch(r,{callKey:t},{dryRun:!1}),await new Promise(e=>setTimeout(e,1500))}_handleCallChangedV3(e){this.keet.internalSyncActiveCall(e)}async suspend(){await this.keet.suspend()}async resume(){await this.keet.resume()}};
1const e=require("path"),t=require("ready-resource"),s=require("hypercore-id-encoding"),i=require("hypercore-crypto"),o=require("debounceify"),a=require("safety-catch"),n=require("b4a"),r=require("uncaughts"),{Readable:c,Transform:l,pipeline:h}=require("streamx"),{Session:d,HeapSnapshot:u}=require("bare-inspector"),m=require("bare-fs"),p=require("process-top")(),g=require("tiny-preferences"),b=require("@holepunchto/keet-call/server"),{contract:{hyperschema:{getEnum:y}},local:{hyperschema:{getEnum:f}}}=require("../../../schema/spec"),{encodeRoomRecord:k,encodeConfig:_,encodeDevice:w,encodeMemberRecord:v,encodeInvitationRecord:R,encodeFile:S,encodeIdentityPairingRequest:C,encodeDmRequest:I,encodeReaction:M,encodeUser:K,encodeContactInfo:P,encodeImageFile:q,encodeReservation:D,encodeFileEntry:E,encodeUserSettings:x,encodeErrorRecord:A,encodeNotification:F,encodeHyperDHTSettings:B,encodeSwarmSettings:L,encodeCallRecord:T,encodeLocalActiveCall:U,encodeContact:N,encodePublicRoom:O}=require("./encode.js"),{decodeChatRangeOptions:j,decodeChatMessage:V,decodeMessageId:H,decodeKeyRangeOptions:z,decodeFile:G,decodeConfig:W,decodeImageFile:J,decodeFileRangeOptions:Y,decodeUserSettings:$}=require("./decode.js"),X=y("@keet/build-type"),Q=y("@keet/room-type"),Z=y("@keet/display-type"),ee=y("@keet/label-type"),te=y("@keet/member-label-type"),{ContactRequestStatus:se,RoomStatus:ie}=require("../../core/contract/identity/private.js"),{Config:oe,CONFIG_INDEX_TO_KEY:ae}=require("../../core/contract/config"),{Settings:ne}=require("../../core/contract/internal"),{getChatMessages:re,getChatMessage:ce,getReactions:le,isDMRead:he,roomHasUnread:de,getCalls:ue,loadBlob:me,parallel:pe}=require("./helpers.js"),{MemberStatus:ge}=require("../../core/contract/members/index.js"),{MemberRoles:be,DM_STATUSES:ye,isValidPreferenceKey:fe,getPreferenceKeyName:ke,CHAT_MESSAGE_REPORT_COUNT:_e,GENERIC_EVENTS:we}=require("@holepunchto/keet-core-api"),{restoreAvatar:ve}=require("../../core/contract/avatars.js"),{getMemberForDeviceKey:Re}=require("../../core/contract/query.js"),Se=require("compact-encoding"),{DEBUG_FLAG_INDEX_BY_KEY:Ce,DHT_SETTINGS:Ie,SWARM_SETTINGS:Me}=require("../../core/debug/debugging.js"),{KeetErrorV2:Ke}=require("../../errors"),Pe=require("./inspector.js"),{FEATURES:qe}=require("../../../schema/versions"),{constants:De}=require("rocksdb-native"),Ee=f("@local/keet-state"),xe="recent-rooms",Ae="favorite-rooms",Fe="dm-rooms",Be="chat-changed",Le="identity",Te="private-profile",Ue="members",Ne="migration-status",Oe="room-preferences",je="unreads",Ve="unread-rooms",He="errors",ze="force-updates",Ge="all-active-calls",We={"keet-core":require("../../../package.json").version,autobee:require("autobee/package.json").version,hypercore:require("hypercore/package.json").version,hyperbee:require("hyperbee/package.json").version,hyperbee2:require("hyperbee2/package.json").version,"keet-identity-key":require("keet-identity-key/package.json").version,"keet-push":require("@holepunchto/keet-push/package.json").version,corestore:require("corestore/package.json").version};class Je{constructor(e,t){this.api=e,this.id=t,this.subscriptions=[]}destroy(){for(const{stream:e}of this.subscriptions)e.destroy()}refresh(e){for(const t of this.subscriptions)e&&e.name&&e.name!==t.name||t.query&&t.query()}push(e,t){for(const s of this.subscriptions)t&&t.name&&t.name!==s.name||s.map&&s.stream.push(s.map(e))}_onDestroy(e,t){const s=this.subscriptions.pop();s!==e&&(this.subscriptions[e.idx]=s,s.idx=e.idx),0===this.subscriptions.length&&this.api._subscriptions.get(this.id)===this&&this.api._subscriptions.delete(this.id),t(null)}_create(e){const t={name:e||null,stream:null,query:null,map:null,idx:0};return t.stream=new c({destroy:e=>this._onDestroy(t,e)}),t.idx=this.subscriptions.push(t)-1,t}add({query:e,map:t,name:s}){if(!e&&!t)throw new Error("Must have either a query or a map");const i=this._create(s);return e&&(i.query=o(async()=>{try{const t=await e();null!==t&&i.stream.push(t)}catch(e){i.stream.destroy(e)}}),i.query()),i.map=t,i.stream}}class Ye{constructor(e){this.keet=e}create(e,t){return async(s,...i)=>{if(this.keet.closing)return null;const o=["files","engine","drive","db","snapshot","blobs","blobsSnapshot"],a=!!t.find(e=>o.includes(e));if(a&&!s)throw new Error("Room ID is required for methods that require room resources");("object"==typeof s&&null!==s||!a)&&(i=[s,...i],s=null);const n=s?this.keet.internalOpenExistingRoom(s):null;if(n&&(await n.ready(),await n.engine.flush()),this.keet.closing)return null;const r={roomId:s,roomKey:n?.key||null,discoveryKey:n?.discoveryKey||null};let c=null;try{for(const e of t)n&&"db"===e&&(r.db=n.db),n&&"snapshot"===e&&(r.snapshot=n.db.snapshot()),n&&"blobsSnapshot"===e&&(r.blobsSnapshot=n.blobs?n.blobs.snapshot():null),n&&"engine"===e&&(r.engine=n.engine),n&&"drive"===e&&(r.drive=n.drive),"local"===e&&(r.local=this.keet.local),"localSnapshot"===e&&(r.localSnapshot=this.keet.local.snapshot()),"files"===e&&(r.files=this.keet.files),"myKey"===e&&(this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready(),r.localSnapshot||(r.localSnapshot=this.keet.local.snapshot()),r.id=await r.localSnapshot.get("@local/identity"),r.profileInfo=await r.localSnapshot.get("@local/rooms",{roomKey:r.id.privateProfileKey}),r.myKey=r.profileInfo?.selfMember?.key||null),"profile"===e&&(this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready(),r.localSnapshot||(r.localSnapshot=this.keet.local.snapshot()),r.id||(r.id=await r.localSnapshot.get("@local/identity")),r.profileInfo||(r.profileInfo=await r.localSnapshot.get("@local/rooms",{roomKey:r.id.privateProfileKey})),r.profile=this.keet.internalOpenExistingRoom(r.id.privateProfileKey),await r.profile.ready()),r.profile&&"profileDb"===e&&(r.profileDb=r.profile.db),r.profile&&"profileSnapshot"===e&&(r.profileSnapshot=r.profile.db.snapshot()),r.profile&&"profileBlobs"===e&&(r.profileBlobs=r.profile.profileBlobs);const s=Date.now();return c=await e(r,...i),this.keet.logger.debug("[Keet API]",e.name,"duration:",Date.now()-s,"args:",i),c}catch(e){if(this.keet.closing)return null;const t=n?.engine.getLastError();if(t)throw t;throw this.keet.onerror(e),e}finally{r.snapshot&&await r.snapshot.close(),r.blobsSnapshot&&await r.blobsSnapshot.close(),r.localSnapshot&&await r.localSnapshot.close(),r.profileSnapshot&&await r.profileSnapshot.close(),r.profile&&await this.keet.internalReleaseRoom(r.profile),n&&await this.keet.internalReleaseRoom(n)}}}}class $e{constructor(e,{onerror:t=a}={}){this.keet=e,this.context=new Ye(this.keet),this._onerror=t,this._subscriptions=new Map,this._profileSubscriptions=new Je(this,null,{isProfileSub:!0}),this._activeCallStates=new Map,this.keet.on("room-interrupted",this._handleRoomInterrupted.bind(this)),this.keet.on("room-changed",this._handleRoomChanged.bind(this)),this.keet.on("identity-changed",this._handleIdentityChanged.bind(this)),this.keet.on("recent-rooms-changed",this._handleRecentRoomsChanged.bind(this)),this.keet.on("dm-rooms-changed",this._handleDmRoomsChanged.bind(this)),this.keet.on("chat-changed",this._handleChatChanged.bind(this)),this.keet.on("identity-pairing-request",this._handleIdentityPairingRequest.bind(this)),this.keet.on("migration-status",this._handleMigrationStatus.bind(this)),this.keet.on("room-preferences-changed",this._handleRoomPreferencesChanged.bind(this)),this.keet.on("unread-anchors-changed",this._handleUnreadAnchorsChanged.bind(this)),this.keet.on("room-sent-message",this._handleRoomSentMessageLengthChanged.bind(this)),this.keet.on("caught-error",this._handleKeetError.bind(this)),this.keet.on("force-update",this._handleForceUpdate.bind(this)),this.keet.on("verified-rooms-changed",this._handleVerifiedRoomsChanged.bind(this)),this.keet.on("local-files-changed",this._handleLocalFilesChanged.bind(this)),this.keet.on("favorite-rooms-changed",this._handleFavoriteRoomsChanged.bind(this)),this.keet.on("contacts-changed",this._handleContactsChanged.bind(this)),this.keet.on("call-changed",this._handleAllActiveCallsChanged.bind(this)),this.keet.on("call-changed-v3",this._handleAllActiveCallsChanged.bind(this)),this.boot=this._timed(this._boot.bind(this)),this.createInvitation=this._timed(this._createInvitation.bind(this)),this.confirmPairingRequest=this._timed(this._confirmPairingRequest.bind(this)),this.startPairingRoom=this._timed(this._startPairingRoom.bind(this)),this.stopPairingRoom=this.context.create(this._stopPairingRoom.bind(this),["profile"]),this.searchRooms=this.context.create(this._searchRooms.bind(this),["local"]),this.getRoomInfo=this.context.create(this._getRoomInfo.bind(this),["localSnapshot"]),this.getRecentRooms=this.context.create(this._getRecentRooms.bind(this),["local"]),this.getPendingRooms=this.context.create(this._getPendingRooms.bind(this),["profile"]),this.getLocalRoomMetadata=this.context.create(this._getLocalRoomMetadata.bind(this),["local"]),this.getConfig=this.context.create(this._getConfig.bind(this),["snapshot","local"]),this.updateRoomSettings=this._updateRoomSettings.bind(this),this.getChatMessage=this.context.create(this._getChatMessage.bind(this),["snapshot","blobsSnapshot","files","local"]),this.getChatMessageById=this.context.create(this._getChatMessageById.bind(this),["snapshot","blobsSnapshot","files","local"]),this.getChatMessages=this.context.create(this._getChatMessages.bind(this),["snapshot","blobsSnapshot","files","local"]),this.getChatLength=this.context.create(this._getChatLength.bind(this),["db"]),this.removeChatMessage=this.context.create(this._removeChatMessage.bind(this),["snapshot","blobsSnapshot","files","local"]),this.searchChatMessages=this.context.create(this._searchChatMessages.bind(this),["local","snapshot","blobsSnapshot","files"]),this.addChatMessage=this._timed(this._addChatMessage.bind(this)),this.updateChatMessage=this._timed(this._updateChatMessage.bind(this)),this.addFilePreview=this._timed(this._addFilePreview.bind(this)),this.removeFilePreview=this._timed(this._removeFilePreview.bind(this)),this.addLinkPreview=this._timed(this._addLinkPreview.bind(this)),this.removeLinkPreview=this._timed(this._removeLinkPreview.bind(this)),this.forwardChatMessage=this.context.create(this._forwardChatMessage.bind(this),["snapshot","blobsSnapshot","files","local"]),this.pinChatMessage=this._timed(this._pinChatMessage.bind(this)),this.unpinChatMessage=this._timed(this._unpinChatMessage.bind(this)),this.addCallStartedEvent=this._timed(this._addCallStartedEvent.bind(this)),this.addCallHangupEvent=this._timed(this._addCallHangupEvent.bind(this)),this.addCallMissedEvent=this._timed(this._addCallMissedEvent.bind(this)),this.addLocationSharedEvent=this._timed(this._addLocationSharedEvent.bind(this)),this.getActiveCalls=this.context.create(this._getActiveCalls.bind(this),["engine","snapshot"]),this.getAllActiveCalls=this.context.create(this._getAllActiveCalls.bind(this),["localSnapshot"]),this.getCalls=this.context.create(this._getCalls.bind(this),["snapshot"]),this.getReactions=this.context.create(this._getReactions.bind(this),["snapshot","local"]),this.getLatestReactions=this.context.create(this._getLatestReactions.bind(this),["snapshot"]),this.addReaction=this._timed(this._addReaction.bind(this)),this.removeReaction=this._timed(this._removeReaction.bind(this)),this.getReportedMembers=this.context.create(this._getReportedMembers.bind(this),["snapshot","blobsSnapshot","localSnapshot"]),this.addChatReport=this._timed(this._addChatReport.bind(this)),this.removeChatReport=this._timed(this._removeChatReport.bind(this)),this.dismissChatReports=this._timed(this._dismissChatReports.bind(this)),this.getReportedMessages=this.context.create(this._getReportedMessages.bind(this),["roomKey","local","snapshot","blobsSnapshot","files"]),this.getPinnedChatMessages=this.context.create(this._getPinnedChatMessages.bind(this),["local","snapshot","blobsSnapshot","files"]),this.getActiveMember=this.context.create(this._getActiveMember.bind(this),["snapshot","blobsSnapshot","localSnapshot","myKey"]),this.getActiveMembers=this.context.create(this._getActiveMembers.bind(this),["snapshot","blobsSnapshot","localSnapshot","myKey"]),this.getMembers=this.context.create(this._getMembers.bind(this),["snapshot","blobsSnapshot","localSnapshot","myKey"]),this.getMember=this.context.create(this._getMember.bind(this),["snapshot","blobsSnapshot","localSnapshot","myKey"]),this.getMemberCount=this.context.create(this._getMemberCount.bind(this),["db"]),this.getMemberBySwarmId=this.context.create(this._getMemberBySwarmId.bind(this),["snapshot","blobsSnapshot","localSnapshot","myKey"]),this.getMemberByDeviceId=this.context.create(this._getMemberByDeviceId.bind(this),["snapshot","blobsSnapshot","localSnapshot","myKey"]),this.isMemberMuted=this.context.create(this._isMemberMuted.bind(this),["db"]),this.getSearchMembers=this.context.create(this._getSearchMembers.bind(this),["snapshot","blobsSnapshot","localSnapshot","myKey"]),this.updateMember=this._timed(this._updateMember.bind(this)),this.removeMember=this._timed(this._removeMember.bind(this)),this.changeMemberRole=this._timed(this._changeMemberRole.bind(this)),this.muteMember=this._timed(this._muteMember.bind(this)),this.unmuteMember=this._timed(this._unmuteMember.bind(this)),this.blockMember=this._timed(this._blockMember.bind(this)),this.unblockMember=this._timed(this._unblockMember.bind(this)),this.getDevices=this.context.create(this._getDevices.bind(this),["db"]),this.getDevice=this.context.create(this._getDevice.bind(this),["db"]),this.getDevicesByMemberId=this.context.create(this._getDevicesByMemberId.bind(this),["db"]),this.getModerators=this.context.create(this._getModerators.bind(this),["snapshot","blobsSnapshot","localSnapshot","myKey"]),this.saveFile=this.context.create(this._saveFile.bind(this),["files"]),this.saveFileBlob=this.context.create(this._saveFileBlob.bind(this),["files"]),this.getFileEntry=this.context.create(this._getFileEntry.bind(this),["files"]),this.getFileCleared=this.context.create(this._getFileCleared.bind(this),["files"]),this.clearFile=this.context.create(this._clearFile.bind(this),["files"]),this.unclearFile=this.context.create(this._unclearFile.bind(this),["files"]),this.clearAllFiles=this.context.create(this._clearAllFiles.bind(this),["files"]),this.clearOldFiles=this._timed(this._clearOldFiles.bind(this)),this.getLocalFiles=this.context.create(this._getLocalFiles.bind(this),["files","snapshot","blobsSnapshot"]),this.getFiles=this.context.create(this._getFiles.bind(this),["files","snapshot","blobsSnapshot"]),this.startDownload=this.context.create(this._startDownload.bind(this),["files"]),this.cancelDownload=this.context.create(this._cancelDownload.bind(this),["files"]),this.saveToDisk=this.context.create(this._saveToDisk.bind(this),["files"]),this.sendFile=this._timed(this._sendFile.bind(this)),this.sendFiles=this._timed(this._sendFiles.bind(this)),this.refreshFileLinks=this._timed(this._refreshFileLinks.bind(this)),this.createRoom=this._timed(this._createRoom.bind(this)),this.leaveRoom=this._timed(this._leaveRoom.bind(this)),this.getSystemDigest=this.context.create(this._getSystemDigest.bind(this),["db"]),this.getTipSize=this.context.create(this._getTipSize.bind(this),["engine"]),this.getRoomKeys=this._timed(this._getRoomKeys.bind(this)),this.resyncPrivateProfile=this._timed(this._resyncPrivateProfile.bind(this)),this.restoreIdentity=this._timed(this._restoreIdentity.bind(this)),this.getRecoveryPhrase=this._timed(this._getRecoveryPhrase.bind(this)),this.getEncryptedRecoveryPhrase=this._timed(this._getEncryptedRecoveryPhrase.bind(this)),this.decryptEncryptedRecoveryPhrase=this._timed(this._decryptEncryptedRecoveryPhrase.bind(this)),this.freeRecoveryPhrase=this._timed(this._freeRecoveryPhrase.bind(this)),this.confirmRecoveryPhrase=this._timed(this._confirmRecoveryPhrase.bind(this)),this.storeRecoveryPhrase=this._timed(this._storeRecoveryPhrase.bind(this)),this.getIdentity=this.context.create(this._getIdentity.bind(this),["local","profile","profileSnapshot"]),this.getSelfContactInfo=this.context.create(this._getSelfContactInfo.bind(this),["local","profile"]),this.removeIdentityDevice=this.context.create(this._removeIdentityDevice.bind(this),["profile"]),this.createIdentityInvitation=this._timed(this._createIdentityInvitation.bind(this)),this.startPairingIdentity=this._timed(this._startPairingIdentity.bind(this)),this.updateIdentityProfile=this._timed(this._updateIdentityProfile.bind(this)),this.updateIdentityDevice=this._timed(this._updateIdentityDevice.bind(this)),this.getIdentityPairingRequest=this._timed(this._getIdentityPairingRequest.bind(this)),this.updateUserSettings=this._timed(this._updateUserSettings.bind(this)),this.updateDHTSettings=this._timed(this._updateDHTSettings.bind(this)),this.getDHTSettings=this._timed(this._getDHTSettings.bind(this)),this.getSwarmSettings=this._timed(this._getSwarmSettings.bind(this)),this.updateSwarmSettings=this._timed(this._updateSwarmSettings.bind(this)),this.addContact=this._timed(this._addContact.bind(this)),this.setContactAlias=this._timed(this._setContactAlias.bind(this)),this.removeContact=this._timed(this._removeContact.bind(this)),this.getActiveContacts=this.context.create(this._getActiveContacts.bind(this),["localSnapshot"]),this.getContactInfo=this.context.create(this._getContactInfo.bind(this),["local","profile"]),this.getBlockedMembers=this.context.create(this._getBlockedMembers.bind(this),["localSnapshot"]),this.getDmRequestsByStatus=this.context.create(this._getDmRequestsByStatus.bind(this),["localSnapshot","profile","profileDb"]),this.sendDMFromContact=this._timed(this._sendDMFromContact.bind(this)),this.sendDMRequest=this._timed(this._sendDMRequest.bind(this)),this.sendInvitations=this._timed(this._sendInvitations.bind(this)),this.updatePrivateMailboxRecord=this._timed(this._updatePrivateMailboxRecord.bind(this)),this.acceptDmRequest=this._timed(this._acceptDmRequest.bind(this)),this.rejectDmRequest=this._timed(this._rejectDmRequest.bind(this)),this.getRoomPreferences=this.context.create(this._getRoomPreferences.bind(this),["local"]),this.updateRoomPreferences=this.context.create(this._updateRoomPreferences.bind(this),["profile"]),this.snoozeRoom=this.context.create(this._snoozeRoom.bind(this),["profile"]),this.updateConfig=this._timed(this._updateConfig.bind(this)),this.disableMembershipEvents=this._timed(this._disableMembershipEvents.bind(this)),this.enableMembershipEvents=this._timed(this._enableMembershipEvents.bind(this)),this.setRoomUnread=this._timed(this._setRoomUnread.bind(this)),this.getLinkInfo=this._timed(this._getLinkInfo.bind(this)),this.lookupUsername=this._timed(this._lookupUsername.bind(this)),this.lookupUserByMemberId=this._timed(this._lookupUserByMemberId.bind(this)),this.registerUsername=this._timed(this._registerUsername.bind(this)),this.updateUsername=this._timed(this._updateUsername.bind(this)),this.searchUsername=this._timed(this._searchUsername.bind(this)),this.getReservationsByKey=this._timed(this._getReservationsByKey.bind(this)),this.checkUsername=this._timed(this._checkUsername.bind(this)),this.repair=this._timed(this._repair.bind(this)),this.rotateWriter=this._timed(this._rotateWriter.bind(this)),this.audit=this._timed(this._audit.bind(this)),this.setUnread=this._setUnread.bind(this),this.getUnread=this._getUnread.bind(this),this.setUnreadAnchor=this._setUnreadAnchor.bind(this),this.getUnreadAnchor=this._getUnreadAnchor.bind(this),this.subscribeUnreadAnchor=this._subscribeUnreadAnchor.bind(this),this.getUnreadRooms=this.context.create(this._getUnreadRooms.bind(this),["local"]),this.subscribeUnreadRooms=this._subscribeUnreadRooms.bind(this),this.updateTypingIndicator=this.context.create(this._updateTypingIndicator.bind(this),["db"]),this.getTypingIndicator=this.context.create(this._getTypingIndicator.bind(this),["db"]),this.subscribeTypingIndicator=this._subscribeTypingIndicator.bind(this),this.setRoomFavorite=this._setRoomFavorite.bind(this)}_timed(e){return async function(...t){const s=Date.now();try{const i=await e(...t);return this.keet.logger.debug("[Keet API]",e.name,"duration:",Date.now()-s,"args:",t),i}catch(e){throw this.keet.onerror(e),e}}}_boot(){return this.keet.backendReady()}_disableMembershipEvents(e){return this.keet.dispatch(e,"@keet/update-system-settings",{key:ne.IsMembershipEventsDisabled,settings:{isMembershipEventsDisabled:!0}})}_enableMembershipEvents(e){return this.keet.dispatch(e,"@keet/update-system-settings",{key:ne.IsMembershipEventsDisabled,settings:{isMembershipEventsDisabled:!1}})}_addKeetSubscription(e="keet",t){return this._addRoomSubscription(e,t)}_addRoomSubscription(e,t,{isProfileSub:s=!1,_isRoomSub:i=!0}={}){if(null===e&&s)return this._profileSubscriptions.add(t);let o=this._subscriptions.get(e);return o||(o=new Je(this,e),this._subscriptions.set(e,o)),o.add(t)}_refreshSubscriptionsById(e){const t=e===this.keet.privateProfile?.id?this._subscriptions.get(Te):this._subscriptions.get(e);t&&t.refresh()}_handleIdentityPairingRequest(e){this._identityPairingRequestsByDeviceId.set(s.encode(e.deviceKey),e),this._refreshSubscriptionsById("identity-pairing-requests")}_handleRoomInterrupted(e,{unsupportedABI:t,digest:s}){const i=this._subscriptions.get(e);if(i)for(const e of i.subscriptions)"room-version"===e.name&&e.stream.push({version:t,experimental:s&&s.settings.isExperimental})}async _handleRoomChanged(e){try{this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready(),this._refreshSubscriptionsById(e),this._refreshSubscriptionsById(Ve)}catch(e){this.keet.onerror(e)}}_handleRecentRoomsChanged(...e){const t=this._subscriptions.get(xe);t&&t.push(e)}_handleDmRoomsChanged(){const e=this._subscriptions.get(Fe);e&&e.refresh()}_handleRoomPreferencesChanged(...e){const t=this._subscriptions.get(Oe);t&&(t.push(e),this._refreshSubscriptionsById(Ve))}_handleUnreadAnchorsChanged(){this._refreshSubscriptionsById(je),this._refreshSubscriptionsById(Ve)}_handleAllActiveCallsChanged(e,t,i){let o=null;t&&(o={callId:s.encode(t.callKey),joined:!!i});if(n=o,(a=this._activeCallStates.get(e)||null)&&n?a.callId===n.callId&&a.joined===n.joined:a===n)return;var a,n;o?this._activeCallStates.set(e,o):this._activeCallStates.delete(e);const r=this._subscriptions.get(Ge);r&&r.refresh()}_handleRoomSentMessageLengthChanged(e){const t=this._subscriptions.get(e);t&&t.refresh({name:"room-info"})}_handleIdentityChanged(){this._refreshSubscriptionsById(Le)}async _handleChatChanged(...e){try{this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready();const t=this._subscriptions.get(Be);if(!t)return;const[s,i]=e;if(s===this.keet.privateProfile.id)return;t.push({roomId:s,index:i})}catch(e){this.keet.onerror(e)}}_handleMigrationStatus(e){const t=this._subscriptions.get(Ne);t&&t.push(e)}_handleKeetError(e){const t=this._subscriptions.get(He);t&&t.push(e)}_handleForceUpdate(){const e=this._subscriptions.get(ze);e&&e.refresh()}_handleVerifiedRoomsChanged(){for(const e of this._subscriptions.values())e.refresh({name:"room-info"})}_handleLocalFilesChanged(e){const t=this._subscriptions.get(e);t&&t.refresh({name:"room-info"})}_handleFavoriteRoomsChanged(...e){const t=this._subscriptions.get(Ae);t&&t.push(e)}_handleContactsChanged(){for(const e of this._subscriptions.values())e.refresh({name:Ue})}getVersion(){return{buildType:this.keet.buildType,abi:this.keet.abi,modules:We}}async _getSystemDigest({db:e}){return await e.get("@keet/system-digest")}subscribeSentLength(e){return this._addRoomSubscription(e,{query:async()=>{const t=this.keet.internalOpenExistingRoom(e);await t.ready();const s={deviceId:t.engine.local.id,length:t.engine.local.remoteContiguousLength};return this.keet.internalReleaseRoom(t),s},name:"room-sent-message"})}subscribeRoomVersion(e){return this._addRoomSubscription(e,{query:async()=>{const t=await this.getSystemDigest(e);return{version:t.abi.version,experimental:t.settings.isExperimental}},name:"room-version"})}subscribeForceUpdates(){return this._addKeetSubscription(ze,{query:()=>({showBanner:this.keet.shouldForceUpdate()})})}async upgradeRoom(e){this.keet.opened||await this.keet.ready();const t=this.keet.isNightly?this.keet.abi.max:this.keet.abi.production;await this.keet.internalDispatchUpgrade(e,t)}async _getLinkInfo(e){const t=this.keet.internalGetLinkInfo(e);if(!t)return null;if(t.identity)return{isIdentityInvitation:!0,memberId:s.encode(t.identity.identityPublicKey),invitationSeed:s.encode(t.identity.invitationSeed),additionalNodes:t.additionalNodes};if(t.room){const e={capabilities:{mailboxKeyPair:{publicKey:t.room.mailbox}}},i=await this.keet.local.get("@local/rooms-by-mailbox",e);return{isRoomInvitation:!0,roomId:i?s.encode(i.roomKey):null,title:i?i.config.title:null,description:i?i.config.description:null,avatar:i?q(i.config.avatar):null,invitationSeed:s.encode(t.room.invitationSeed),additionalNodes:t.additionalNodes}}return t.profile?{isContactInfo:!0,memberId:s.encode(t.attestation.memberKey),displayName:t.profile.displayName,username:t.profile.username,additionalNodes:t.additionalNodes}:t.readonly||t["readonly-v2"]?{isReadOnly:!0,additionalNodes:t.additionalNodes}:void 0}async _getSelfContactInfo({id:e,profileInfo:t}){const s=this.keet.internalCreateContactInfoStruct(e,t,{avatar:null,timestamp:0});return n.toString(s,"base64")}async _getIdentity({id:e,profile:t,profileSnapshot:i,profileInfo:o}){const[a,n]=await Promise.all([i.find("@keet/devices").toArray(),i.get("@keet-private-id/settings")]),r=[];for(const e of a)e.status.isActive&&r.push({...w(e),confirmed:!0});const c=v(o.selfMember,o.selfMember.key);return c.hasDiscoveryKey=!!o.identity.discoveryCoreKey,c.anonymous=!1,c.confirmed=e.status.isConfirmed,c.devices=r,c.profileId=t.id,c.profileDiscoveryId=t.discoveryId,c.local={deviceId:s.encode(t.deviceKey)},c.settings=x(n),c.isLoggedOut=o.selfDevice&&!o.selfDevice.status.isActive,c.version=o?.digest.abi.version,c}_removeIdentityDevice({profile:e},t){return e.dispatch("@keet/remove-device",{key:s.decode(t)})}subscribeIdentity(){return this._addKeetSubscription(Le,{query:()=>this.getIdentity()})}async _restoreIdentity(e,t={}){await this.keet.restoreIdentity(e,t)}_getRecoveryPhrase(){return this.keet.getRecoveryPhrase()}_getEncryptedRecoveryPhrase(e){return this.keet.getEncryptedRecoveryPhrase(e)}_decryptEncryptedRecoveryPhrase(e,t){return this.keet.decryptEncryptedRecoveryPhrase(e,t)}_freeRecoveryPhrase(e){return this.keet.freeRecoveryPhrase(e)}_confirmRecoveryPhrase(e){return this.keet.confirmRecoveryPhrase(e)}_storeRecoveryPhrase(e){return this.keet.storeRecoveryPhrase(e)}confirmIdentity(...e){throw console.log("confirmIdentity",...e),new Error("Missing required method: confirmIdentity")}async _confirmPairingRequest({deviceId:e},t=!0){this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready();const i=this.keet.privateProfile.key,o=s.decode(e);return t?this.keet.acceptJoinRequest(i,o):this.keet.rejectJoinRequest(i,o)}async _getIdentityPairingRequest(){const e=await this.keet.internalOpenPrivateProfile(),t=await e.db.find("@keet/join-requests").toArray();return this.keet.internalReleaseRoom(e),0===t.length?null:C(t[0])}subscribeIdentityPairingRequests(...e){return this._addKeetSubscription(Le,{query:()=>this.getIdentityPairingRequest()})}async _updateIdentityProfile({displayName:e,avatar:t}){await this.updateMember(e,t)}_updateIdentityDevice(e){return this.keet.updateDevice(e)}_startPairingIdentity(e){return this.keet.startPairingIdentity(e)}pairIdentity(...e){throw console.log("pairIdentity",...e),new Error("Missing required method: pairIdentity")}async _updateUserSettings(e,t){this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready();const s={[e]:t};return this.keet.privateProfile.dispatch("@keet-private-id/update-settings",{key:e,settings:$(s)})}async _getDHTSettings(){const e=await this.keet.getDHTSettings();return B(e)}async _updateDHTSettings(e,t){if(!(e in Ie))throw Ke.INVALID_SETTINGS_KEY(`Invalid DHT settings key: ${e}`);const s=await this.keet.internalEnterLocalTransaction();try{const i=await this.keet.getDHTSettings();i[e]=t,await s.insert("@local/hyperdht",i),await s.flush()}finally{await this.keet.internalExitLocalTransaction()}}async _getSwarmSettings(){const e=await this.keet.getSwarmSettings();return L(e)}async _updateSwarmSettings(e,t){if(!(e in Me))throw Ke.INVALID_SETTINGS_KEY(`Invalid swarm settings key: ${e}`);const s=await this.keet.internalEnterLocalTransaction();try{const i=await this.keet.getSwarmSettings();i[e]=t,await s.insert("@local/hyperswarm",i),await s.flush()}finally{await this.keet.internalExitLocalTransaction()}}async _createRoom(e={}){const t=await this.keet.createRoom(function(e={}){return{config:{title:e.config?.title,description:e.config?.description},settings:{roomType:at(e.config?.roomType),isCallingDisabled:"false"===e.config?.canCall}}}(e));return s.encode(t)}_pairRoom(...e){throw console.log("pairRoom",...e),new Error("Missing required method: pairRoom")}_leaveRoom(e,t={}){return this.keet.leaveRoom(s.decode(e))}async _startPairingRoom(e,t={}){return await this.keet.startPairingRoom(e,t)}async _stopPairingRoom({profile:e},t){const i=s.decode(t),o=await e.db.find("@keet-private-id/pending-invitations").toArray();for(const e of o)if(n.equals(e.invitationSeed,i)){await this.keet.stopPairing(e.id);break}}subscribePendingRooms(){return this._addKeetSubscription(Le,{query:()=>this.getPendingRooms()})}subscribePushNotificationChanges(){return this._addKeetSubscription(Oe,{map:function(e){const[t,o,a]=e,n=a||i.discoveryKey(o);return{type:t,roomId:s.encode(o),discoveryId:s.encode(n)}}})}subscribeActivateRoom(e){const t=s.decode(e);return new c({eagerOpen:!0,open:async e=>{let s=null;try{await this.keet.activateRoom(t)}catch(e){s=e}e(s)},destroy:async e=>{let s=null;try{await this.keet.deactivateRoom(t)}catch(e){s=e}e(s)}})}_getRoomKeys(e){try{const t=s.decode(e);return{discoveryKey:n.toString(i.discoveryKey(t),"hex")}}catch{return{discoveryKey:""}}}_getTipSize({engine:e}){return e.tipSize}async _resyncPrivateProfile(){this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready(),await this.keet.internalResyncPrivateProfile()}bookmark(...e){throw console.log("bookmark",...e),new Error("Missing required method: bookmark")}unbookmark(...e){throw console.log("unbookmark",...e),new Error("Missing required method: unbookmark")}subscribeBookmarks(...e){return console.log("subscribeBookmarks",...e),new c}async _loadRecents(e,t={}){const{index:s,range:i}=function(e){return e.favorites?{index:"@local/rooms-by-favorite-and-timestamp",range:{}}:e.default||e.dms||e.broadcast?{index:"@local/rooms-by-type-and-timestamp",range:{lte:{type:n(e)},gte:{type:n(e)}}}:{index:"@local/rooms-by-timestamp",range:{}}}(t),o=await e.find(s,{...t,...i,reverse:!0}).toArray(),a=await Promise.all(o.map(t=>e.get("@local/room-preferences",{roomKey:t.roomKey})));for(let e=0;e<a.length;e++){const t=a[e];t&&!t.status.isActive&&(o[e]=null)}return o;function n(e){return e.default?Q.Default:e.dms?Q.DirectMessage:e.broadcast?Q.Broadcast:void 0}}async _getRoomInfo({localSnapshot:e},t){const o=s.decode(t),a=await e.get("@local/rooms",{roomKey:o});if(!a)return null;let n=v(a.lastMember);const[r,c,l]=await Promise.all([e.get("@local/room-preferences",{roomKey:a.roomKey}),a.lastMessage&&!n?e.get("@local/devices",{device:{key:a.lastMessage.oplog.key}}):null,e.get("@local/file-stats",{roomKey:a.roomKey})]);if(c){const t=await e.get("@local/members",{key:c.device.memberKey});t&&(n={id:s.encode(t.key),memberId:s.encode(t.key),displayName:t.profile.displayName})}if(a.lastMessage){const e=he(a,a.lastMessage.id);a.lastMessage.read=e}if(a.lastMessage?.event?.memberRemoved){const t=await e.get("@local/members",{key:a.lastMessage.event.memberRemoved.memberKey}),s=t?.profile?.displayName;a.lastMessage.event.memberRemoved.displayName=s}const h=a.selfDevice?i.discoveryKey(a.selfDevice.key):null,d=h?await this.keet.storage.getInfo(h,{hints:!0,auth:!1,head:!1}):null,u=k({roomInfo:a,preferences:r,lastMessageMember:n,storageInfo:d,fileStats:l});return u.isVerified=this.keet.isRoomVerified(t),u}async _searchRooms({local:e}){const t=await this._loadRecents(e),i=[];for(const e of t)e&&i.push({title:e.config.title,roomId:s.encode(e.roomKey)});return i}searchPublicRooms(e,t){return c.from(this._searchPublicRooms(e,t))}async*_searchPublicRooms(e=[],t={}){if(!this.keet.roomRegistry)return;const s=this.keet.local.snapshot();try{for await(const s of this.keet.roomRegistry.search(e)){const e=await i(s.roomKey);t.unjoined&&e||(this.keet.buildType===X.Nightly&&(s.invitation=null),yield O(s,e))}}finally{await s.close()}async function i(e){const t=await s.get("@local/rooms",{roomKey:e});return!!t&&!t.status.isRemoved}}async _getRecentRooms({local:e},t){const[i,o]=await Promise.all([this._loadRecents(e,t),e.get("@local/stats")]),a=[];for(const e of i)e&&a.push({timestamp:e.timestamps.latestChatMessage||e.timestamps.latestSync,roomId:s.encode(e.roomKey)});return{type:"all",total:o?o.activeRooms:0,rooms:a}}async _getPendingRooms({profile:e}){return(await e.db.find("@keet-private-id/pending-invitations").toArray()).map(R)}_getLocalRoomMetadata({local:e},t){return e.get("@local/rooms",{discoveryKey:s.decode(t)})}subscribeRecentRooms(e){return this._addKeetSubscription(xe,{map:function(e){const[t,s,i]=e;return{type:t,timestamp:s,roomId:i}},query:()=>this.getRecentRooms(e)})}subscribeFavoriteRooms(){return this._addKeetSubscription(Ae,{map:function(e){const[t,s,i]=e;return{type:t,timestamp:s,roomId:i}},query:()=>this.getRecentRooms({favorites:!0})})}subscribeRoomInfo(e,t){return this._addRoomSubscription(e,{query:()=>this.getRoomInfo(e,t),name:"room-info"})}subscribeUnreadActivity(e={}){return this._addKeetSubscription(Be,{map:({roomId:t,index:s})=>t?e.includeLength||e.includeIndex?{roomId:t,index:s}:{roomId:t}:null})}subscribeErrors(){return this._addKeetSubscription(He,{map:e=>A(e)})}subscribeNotifications(){const e=this.subscribeUnreadActivity({includeIndex:!0}),t=c.from(this._subscribeNotifications(e));return t.once("close",()=>{e.destroy()}),t}setCallRingingId(e){this._callRingingRoomId=e}setProcessingNotifications(e){this._processingNotifications=e}async*_subscribeNotifications(e){for await(const{roomId:i,index:o}of e){if(this.keet.closing)return;if(this._callRingingRoomId){if(i!==this._callRingingRoomId)continue;const e=await this.getChatMessage(i,o);if(this.keet.closing)return;e?.event?.type===we.CALL_HANGUP&&(yield{type:we.CALL_HANGUP})}if(this._processingNotifications)continue;const e=await this.keet.local.get("@local/room-preferences",{roomKey:s.decode(i)});if(this.keet.closing)return;const a=e?.status.isFullyMuted||!1,n=(e?.status.roomSnoozeTime||0)>Date.now();if(a||n||this._processingNotifications)continue;const[r,c,l]=await Promise.all([this.getConfig(i),this.getChatMessage(i,o),this.keet.local.get("@local/identity")]);if(this.keet.closing)return;if(!c||Math.abs(Date.now()-c.timestamp)>6e5)continue;const h=await this.getBlockedMembers();if(this.keet.closing)return;if(h.some(e=>e.memberId===c.memberId)||this._processingNotifications)continue;if(l&&s.encode(l.publicKey)===c.memberId)continue;const{settings:d}=await this.keet.local.get("@local/rooms",{roomKey:l.privateProfileKey});if(this.keet.closing)return;if((d?.profileSnoozeTime||0)>Date.now())continue;const u=`${c.id.deviceId}/b${c.id.seq}`,m=t(c),p=c.files.length>0&&c.files[0].metadata?.mimetype||"",g=await this.getMember(i,c.memberId);if(this.keet.closing)return;const b=c.chat?.text||"",y=at(r.roomType)===Q.DirectMessage;if(!this._processingNotifications&&(b||m)){if(y&&"call"===m){if(Math.abs(Date.now()-c.timestamp)>2e4)continue;if(!(await this.getActiveCalls(i)).length)continue;yield{type:we.CALL_STARTED}}const e=await this.getRoomInfo(i);if(this.keet.closing)return;const t=e?.config?.avatar?.small?.pointer?.inlined??"",s=c.message?.generic?.locationShared;yield F({messageId:u,roomId:i,avatar:t,location:s,messageText:b,messageType:m,fileType:p},r,g)}}function t(e){return e.event?.type===we.CALL_STARTED?"call":e.files?.length>0?"file":e.message?.generic?.locationShared?"location":""}}async _setRoomUnread(e,t=!0){this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready();const{privateProfileKey:i}=await this.keet.local.get("@local/identity");await this.keet.local.get("@local/rooms",{roomKey:i})&&await this.keet.privateProfile.dispatch("@keet-private-id/update-room-status",{roomKey:s.decode(e),key:ie.IsUnread,status:{isUnread:t}})}async _snoozeRoom({profile:e},t,i=0){await e.dispatch("@keet-private-id/update-room-status",{roomKey:s.decode(t),key:ie.RoomSnoozeTime,status:{roomSnoozeTime:i}})}bumpRoomPriority(...e){throw console.log("bumpRoomPriority",...e),new Error("Missing required method: bumpRoomPriority")}addDevice(...e){throw console.log("addDevice",...e),new Error("Missing required method: addDevice")}removeDevice(...e){throw console.log("removeDevice",...e),new Error("Missing required method: removeDevice")}async _getDevice({db:e},t){const s=await e.findOne("@keet/devices",z({gte:t,lte:t}));return s?w(s):null}async _getDevices({db:e},t){return(await e.find("@keet/devices",z(t)).toArray()).map(e=>w(e))}async moveIndexer(e,t,i){const o=s.decode(t),a=s.decode(i);return this.keet.dispatch(e,"@keet/move-indexer",{deviceKey:o,fromDeviceKey:a})}subscribeDevice(e,...t){return this._addRoomSubscription(e,{query:()=>this.getDevice(e,...t)})}subscribeDevices(e,...t){return this._addRoomSubscription(e,{query:()=>this.getDevices(e,...t)})}async _createIdentityInvitation(){return this.keet.createIdentityInvitation()}_createInvitation(e,t={}){return!0===t.canIndex&&(t.canAdmin=!0),this.keet.createRoomInvitation(s.decode(e),t)}async _updateMember(e,t){this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready();const i=await this.keet.local.get("@local/identity");if(i&&s.encode(i.privateProfileKey))return t=J(t),this.keet.updateProfile({displayName:e,avatar:t})}async _muteMember(e,t){const i=s.decode(t);return this.keet.dispatch(e,"@keet/change-member-status",{memberKey:i,key:ge.IsMuted,status:{isMuted:!0}})}async _unmuteMember(e,t){const i=s.decode(t);return this.keet.dispatch(e,"@keet/change-member-status",{memberKey:i,key:ge.IsMuted,status:{isMuted:!1}})}async _isMemberMuted({db:e},t){const i=s.decode(t);return!!await e.get("@keet/muted-members",{key:i})}async _getMemberByDeviceId({myKey:e,snapshot:t,blobsSnapshot:i,localSnapshot:o},a){const n=await Re(t,s.decode(a));if(!n)return null;const r=!!await o.get("@local/active-contacts",{memberKey:n.key});return await ve(t,i,n.profile.avatar),await ct(t,n),v(n,e,r)}async _getMemberBySwarmId({myKey:e,snapshot:t,blobsSnapshot:i,localSnapshot:o},a){const n=s.decode(a),r=await t.get("@keet/devices-by-swarm-key",{profile:{swarmKey:n}});if(!r)return null;const c=await Re(t,r.key);if(!c)return null;const l=!!await o.get("@local/active-contacts",{memberKey:c.key});return await ve(t,i,c.profile.avatar),await ct(t,c),v(c,e,l)}async _getMemberCount({db:e}){const t=await e.get("@keet/threads",{id:0});return t?t.stats.members.active:0}async _getDevicesByMemberId({db:e},t){const i=[],o=s.decode(t),a={gte:{memberKey:o},lte:{memberKey:o}};for await(const t of e.find("@keet/devices-by-member-key",a))i.push(w(t));return i}getCurrentDeviceId(e){const t=this.keet.internalOpenExistingRoom(e);try{return t.deviceId}finally{this.keet.internalReleaseRoom(t)}}async _getMember({roomId:e,myKey:t,snapshot:i,blobsSnapshot:o,localSnapshot:a},n,r={}){const c=s.decode(n);if(!0===r.swarmId)return this.getMemberBySwarmId(e,n);const l=await i.get("@keet/members",{key:c});if(!l)return null;const h=!!await a.get("@local/active-contacts",{memberKey:l.key});return await ve(i,o,l.profile.avatar),await ct(i,l),v(l,t,h)}async _getActiveMember({myKey:e,snapshot:t,blobsSnapshot:i,localSnapshot:o},a){const n=await t.get("@keet/active-members",{key:s.decode(a)});if(!n)return null;const r=!!await o.get("@local/active-contacts",{memberKey:n.key});return await ve(t,i,n.profile.avatar),await ct(t,n),v(n,e,r)}async _removeMember(e,t){const i=s.decode(e);if(await this.keet.local.get("@local/rooms",{roomKey:i}))return this.keet.dispatch(e,"@keet/remove-member",{key:s.decode(t)})}async _getMembers({myKey:e,snapshot:t,blobsSnapshot:s,localSnapshot:i},o={}){const a=await t.find("@keet/members",z(o)).toArray();return Promise.all(a.map(async o=>{const a=!!await i.get("@local/active-contacts",{memberKey:o.key});return await ve(t,s,o.profile.avatar),await ct(t,o),v(o,e,a)}))}async _getActiveMembers({myKey:e,snapshot:t,blobsSnapshot:s,localSnapshot:i},o={}){const a=await t.find("@keet/active-members",z(o)).toArray();return Promise.all(a.map(async o=>{const a=!!await i.get("@local/active-contacts",{memberKey:o.key});return await ve(t,s,o.profile.avatar),await ct(t,o),v(o,e,a)}))}async _getModerators({myKey:e,snapshot:t,blobsSnapshot:s,localSnapshot:i},o={}){const a=await t.find("@keet/moderators",z(o)).toArray();return Promise.all(a.map(async o=>{const a=!!await i.get("@local/active-contacts",{memberKey:o.key});return await ve(t,s,o.profile.avatar),await ct(t,o),v(o,e,a)}))}getMemberForDevice(...e){throw console.log("getMemberForDevice",...e),new Error("Missing required method: getMemberForDevice")}subscribeMemberCount(e,...t){return this._addRoomSubscription(e,{query:()=>this.getMemberCount(e,...t),name:Ue})}subscribeMember(e,...t){return this._addRoomSubscription(e,{query:()=>this.getMember(e,...t),name:Ue})}subscribeActiveMember(e,...t){return this._addRoomSubscription(e,{query:()=>this.getActiveMember(e,...t),name:Ue})}subscribeActiveMembers(e,...t){return this._addRoomSubscription(e,{query:()=>this.getActiveMembers(e,...t),name:Ue})}subscribeMembers(e,...t){return this._addRoomSubscription(e,{query:()=>this.getMembers(e,...t),name:Ue})}subscribeModerators(e,...t){return this._addRoomSubscription(e,{query:()=>this.getModerators(e,...t),name:Ue})}subscribeMemberForDevice(e,...t){return this._addRoomSubscription(e,{query:()=>this.getMemberByDeviceId(e,...t),name:Ue})}_changeMemberRole(e,{memberId:t,role:i}){return this.keet.dispatch(e,"@keet/change-member-role",{key:s.decode(t),isAdmin:i===be.ADMIN,isModerator:i===be.ADMIN||i===be.MODERATOR})}async _getSearchMembers({myKey:e,snapshot:t,blobsSnapshot:s,localSnapshot:i},o,{limit:a=50}={}){o=o.toLowerCase();const n=await t.find("@keet/members-by-member-name",{gte:{name:o},limit:a}).toArray();return(await Promise.all(n.map(async o=>{const a=!!await i.get("@local/active-contacts",{memberKey:o.key});return await ve(t,s,o.profile.avatar),await ct(t,o),v(o,e,a)}))).filter(e=>e.name.startsWith(o))}getPushNotificationMembers(...e){throw console.log("getPushNotificationMembers",...e),new Error("Missing required method: getPushNotificationMembers")}subscribeSearchMembers(...e){return console.log("subscribeSearchMembers",...e),new c}subscribePushNotificationMembers(...e){return console.log("subscribePushNotificationMembers",...e),new c}async _addContact(e,t,i){const o=s.decode(e);await this.keet.addContact(o,t,i)}async _setContactAlias(e,t){const i=s.decode(e);await this.keet.setContactAlias(i,t)}async _removeContact(e){const t=s.decode(e);await this.keet.removeContact(t)}async _getActiveContacts({localSnapshot:e}){return pe(e.find("@local/active-contacts"),async t=>{const s=await e.get("@local/members",{key:t.memberKey});return N(t,s)})}subscribeActiveContacts(){return this._addRoomSubscription(Te,{query:()=>this.getActiveContacts()})}async _getContactInfo({local:e,profile:t},i){const o=s.decode(i),[a,n,r]=await Promise.all([e.get("@local/contacts",{memberKey:o}),e.findOne("@local/rooms-by-contact",{gte:{contact:o},lte:{contact:o}}),t.db.findOne("@keet-private-id/pending-contact-requests-by-member",{gte:{memberKey:o},lte:{memberKey:o}})]);return P(i,a,n,r)}subscribeContactInfo(e){return this._addRoomSubscription(Fe,{query:async()=>{const t=this.keet.local.snapshot();try{const i=s.decode(e),[o,a]=await Promise.all([t.get("@local/contacts",{memberKey:i}),t.findOne("@local/rooms-by-contact",{gte:{contact:i},lte:{contact:i}})]);return P(e,o,a,null)}finally{await t.close()}}})}async _blockMember(e,t){const i=s.decode(t);return this.keet.blockContact(i)}async _unblockMember(e,t){const i=s.decode(t);return this.keet.unblockContact(i)}async _getBlockedMembers({localSnapshot:e}){return pe(e.find("@local/blocked-contacts"),async e=>N(e))}subscribeBlockedMembers(){return this._addRoomSubscription(Te,{query:()=>this.getBlockedMembers()})}getConnectedMembers(...e){throw console.log("getConnectedMembers",...e),new Error("Missing required method: getConnectedMembers")}subscribeConnectedMembers(...e){return console.log("subscribeConnectedMembers",...e),new c}async _updateConfig(e,t,s){const i=function(e){switch(e){case"title":return oe.Title;case"avatar":return oe.Avatar;case"description":return oe.Description;case"supportedLanguages":return oe.SupportedLanguages;case"blindPeers":return oe.BlindPeers;default:return 0}}(t);if(0!==i){const t={[ae[i-1]]:s};await this.keet.dispatch(e,"@keet/update-room-config",{key:i,config:W(t)})}else if("roomType"===t){const t=at(s);if(0===t)throw new Error("Invalid room type");await this.keet.dispatch(e,"@keet/update-system-settings",{key:ne.RoomType,settings:{roomType:t}})}else{if("canCall"!==t)throw new Error("Invalid config key");await this.keet.dispatch(e,"@keet/update-system-settings",{key:ne.IsCallingDisabled,settings:{isCallingDisabled:"false"===s}})}}async _updateRoomPreferences({profile:e},t,i,o){if(!fe(i))throw new Error(`invalid preference key: ${i}`);const a=s.decode(t);await this.keet.dispatch(e.id,"@keet-private-id/update-room-status",{roomKey:a,key:ot(i),status:{[ke(i)]:o}})}async _updateRoomSettings(e,t,i){const o=s.decode(e);return this.keet.dispatch(o,"@keet/update-system-settings",{key:t,settings:i})}async _getRoomSettings(e){const t=s.decode(e),i=this.keet.internalOpenExistingRoom(t);try{return(await i.db.get("@keet/system-digest")).settings}finally{this.keet.internalReleaseRoom(i)}}async _getRoomPreferences({local:e},t,i){const o=s.decode(t),a=await e.get("@local/room-preferences",{roomKey:o});if(!a)return null;const{status:n}=a;return fe(i)?i?n[ke(i)]:n:null}async _getConfig({roomKey:e,local:t},s){const i=await t.get("@local/rooms",{roomKey:e});if(!i)return null;const{config:o,digest:a}=i,n=_(o,a)||{};return s?n[s]:n}subscribeConfig(e){return this._addRoomSubscription(e,{query:()=>this.getConfig(e)})}async _addChatMessage(e,t,i={}){const o=s.decode(e);if(!await this.keet.local.get("@local/rooms",{roomKey:o}))return;const a=V(t,i),n=nt(a),r=this.keet.batch(e);return 0!==await r.dispatch("@keet/add-chat-message",{timestamp:Date.now(),message:a})?((n.files.length||n.pearLink.length||n.httpLink.length)&&await rt(r,n),await r.flush()):void 0}async _updateChatMessage(e,t,i,o={}){const a=s.decode(e);if(!await this.keet.local.get("@local/rooms",{roomKey:a}))return;const n=H(t),r=V(i,o),c=nt(r),l=this.keet.batch(e);0!==await l.dispatch("@keet/update-chat-message",{oplog:n,message:r})&&((c.files.length||c.pearLink.length||c.httpLink.length)&&await rt(l,c,n),await l.flush())}async _addFilePreview(e,t,s,i,o={}){const a=J(i);if(a)return this.keet.dispatch(e,"@keet/add-file-preview",{oplog:H(t),index:s,preview:a,displayType:o.displayType})}async _removeFilePreview(e,t,s,i={}){if(!await this.keet.internalFeatureSupported(e,qe.PREVIEWS))throw new Error("Removing file previews not supported");return this.keet.dispatch(e,"@keet/remove-file-preview",{oplog:H(t),index:s,displayType:i.displayType})}async _addLinkPreview(e,t,s,i,o){if(s&&o){if(!await this.keet.internalFeatureSupported(e,qe.PREVIEWS))throw new Error("Adding link previews not supported");return this.keet.dispatch(e,"@keet/add-link-preview",{oplog:H(t),displayType:s,index:i,preview:{title:o.title,description:o.description,file:G(o.file)}})}}async _removeLinkPreview(e,t,s,i){if(s){if(!await this.keet.internalFeatureSupported(e,qe.PREVIEWS))throw new Error("Removing link previews not supported");return this.keet.dispatch(e,"@keet/remove-link-preview",{oplog:H(t),displayType:s,index:i})}}async _removeChatMessage({roomKey:e,local:t,roomId:s,snapshot:i,blobsSnapshot:o,files:a},n){const r=await this._getChatMessageById({roomKey:e,local:t,snapshot:i,blobsSnapshot:o,files:a},n);if(!r)return null;if(r.files.length){const t=[];for(const s of r.files)t.push(this._clearFile({roomKey:e,files:a},s));await Promise.all(t)}return this.keet.dispatch(s,"@keet/remove-chat-message",{oplog:H(n)})}async _forwardChatMessage({roomKey:e,local:t,roomId:i,snapshot:o,blobsSnapshot:a,files:n},r,c){const[l,h]=await Promise.all([this.keet.local.get("@local/rooms",{roomKey:e}),this.keet.local.get("@local/rooms",{roomKey:s.decode(c)})]);if(!l||!h)return;const d=await o.get("@keet/chat-by-message-id",{oplog:H(r)});if(!d)throw new Error("Source message not found");if(!d.message.text)throw new Error("Source message has no text");const u=d.message.display||{};for(const e of u.httpLink||[])e.preview=null;for(const e of u.pearLink||[])e.preview=null;const m={text:d.message.text,forwarded:!0,files:[],display:u,replyTo:null,event:null};return this.keet.dispatch(c,"@keet/add-chat-message",{timestamp:Date.now(),message:m})}_pinChatMessage(e,t){return this.keet.dispatch(e,"@keet/pin-chat-message",{oplog:H(t),isPinned:!0})}_unpinChatMessage(e,t){return this.keet.dispatch(e,"@keet/pin-chat-message",{oplog:H(t),isPinned:!1})}async startCall(e,t={}){if(!await this.keet.internalFeatureSupported(e,qe.CALLS_V2))return this.addCallStartedEvent(e);if(3!==t.version)throw new Error("Only calls v3 is supported");if(!t.streams)throw new Error("Streams are required");if((await this._getRoomSettings(e)).isCallingDisabled)throw Ke.CALL_DISABLED();if(!await this.keet.internalFeatureSupported(e,qe.CALLS_V3))throw new Error("Calls v3 is not supported");return this.keet.internalStartCall(e,t.streams)}async joinCall(e,t,{version:s,streams:i=[]}={}){if(await this.keet.internalFeatureSupported(e,qe.CALLS_V2)){if(3!==s)throw new Error("Only calls v3 is supported");if(!i.length)throw new Error("Streams are required");if(!await this.keet.internalFeatureSupported(e,qe.CALLS_V3))throw new Error("Calls v3 is not supported");return this.keet.internalJoinCall(e,t,i)}}async leaveCall(e,t){if(await this.keet.internalFeatureSupported(e,qe.CALLS_V2))return this.keet.internalLeaveCall(e,t)}async endCall(e,t){if(!await this.keet.internalFeatureSupported(e,qe.CALLS_V2)){const t=s.decode(e);if(!(await this.keet.local.get("@local/rooms",{roomKey:t})).dm)return;return this.addCallHangupEvent(e)}return this.keet.internalEndCall(e,t)}async addCallStream(e,t,o){if(!await this.keet.internalFeatureSupported(e,qe.CALLS_V2))throw new Error("Calls v2 is not supported");return this.keet.dispatch(e,"@keet/add-call-stream",{callKey:s.decode(t),streamKey:o.id?s.decode(o.id):i.randomBytes(32),mediaStreamId:o.mediaStreamId,type:o.type,muted:o.muted??!1})}async updateCallStream(e,t,i,{muted:o}){if(!await this.keet.internalFeatureSupported(e,qe.CALL_STREAM_STATUS))throw new Error("Call stream status is not supported");return this.keet.dispatch(e,"@keet/update-call-stream",{callKey:s.decode(t),streamKey:s.decode(i),muted:o})}async removeCallStream(e,t,i){if(!await this.keet.internalFeatureSupported(e,qe.CALLS_V2))throw new Error("Calls v2 is not supported");return this.keet.dispatch(e,"@keet/remove-call-stream",{callKey:s.decode(t),streamKey:s.decode(i)})}async startCallRecording(e,t){return this.keet.dispatch(e,"@keet/start-call-recording",{callKey:s.decode(t)})}async stopCallRecording(e,t){return this.keet.dispatch(e,"@keet/stop-call-recording",{callKey:s.decode(t)})}async _getActiveCalls({engine:e,snapshot:t},s={}){return(await ue(t,"@keet/active-calls-by-timestamp")).map(t=>T(t,{...s,deviceKey:e.local.key}))}async _getCalls({snapshot:e},t={}){return(await ue(e,"@keet/calls-by-timestamp")).map(e=>T(e,t))}async _getAllActiveCalls({localSnapshot:e},t={}){if(!0===t.rejoin){const t=e.find("@local/rooms-by-active-call",{reverse:!0});for await(const e of t)if(e.activeCall.selfDeviceKey)return lt(e);return null}const s=[];for await(const t of e.find("@local/rooms-by-active-call"))s.push(lt(t));return s}subscribeAllActiveCalls(e){return this._addKeetSubscription(Ge,{query:()=>this.getAllActiveCalls(e)})}subscribeActiveCalls(e,...t){return this._addRoomSubscription(e,{query:()=>this.getActiveCalls(e,...t)})}subscribeCalls(e,...t){return this._addRoomSubscription(e,{query:()=>this.getCalls(e,...t)})}subscribeCallProxy(e){const t=this.keet.callProxy.getCallById(e);if(!t)throw Ke.CALL_NOT_ACTIVE("",{callId:e});const s=new c,i=({swarmId:e,proxyPort:t})=>s.push({type:"peer",swarmId:e,proxyPort:t}),o=({swarmId:e,data:t})=>s.push({type:"signal",swarmId:e,data:t}),a=({swarmId:e})=>s.push({type:"peer-close",swarmId:e});t.on("peer",i),t.on("signal",o),t.on("peer-close",a);for(const[e,i]of t.openPeers())s.push({type:"peer",swarmId:e,proxyPort:i});return s.once("close",()=>{t.off("peer",i),t.off("signal",o),t.off("peer-close",a)}),s}signalCallPeer(e,t,s){const i=this.keet.callProxy.getCallById(e);if(!i)throw Ke.CALL_NOT_ACTIVE("",{callId:e});i.signal(t,s)}_addCallStartedEvent(e){return this.addChatMessage(e,null,{callStarted:!0})}_addCallHangupEvent(e){return this.addChatMessage(e,null,{callHangup:!0})}_addCallMissedEvent(e){return this.addChatMessage(e,null,{callMissed:!0})}_addLocationSharedEvent(e,t,{locationShared:{latitude:s,longitude:i}}){return this.addChatMessage(e,t,{locationShared:{latitude:s,longitude:i}})}addRoomAvatarChangedEvent(...e){console.log("addRoomAvatarChangedEvent",...e),console.warn("Missing required method: addRoomAvatarChangedEvent")}addEvent(...e){console.log("addEvent",...e),console.warn("Missing required method: addEvent")}removeEvent(...e){console.log("removeEvent",...e),console.warn("Missing required method: removeEvent")}async _getChatMessage({roomKey:e,local:t,snapshot:s,blobsSnapshot:i,files:o},a){return(await re(async function(){const t=j(e,{gte:a,lte:a});return await s.findOne("@keet/chat",t)},e,t,s,i,o))[0]}async _getChatMessageById({roomKey:e,local:t,snapshot:s,blobsSnapshot:i,files:o},a){return(await re(async function(){return await s.get("@keet/chat-by-message-id",{oplog:H(a)})},e,t,s,i,o))[0]}async _getChatMessages({roomKey:e,local:t,snapshot:s,blobsSnapshot:i,files:o},a){return await re(async function(){const t=j(e,a);return await s.find("@keet/chat",t).toArray()},e,t,s,i,o)}async _getPinnedChatMessages({roomKey:e,local:t,snapshot:s,blobsSnapshot:i,files:o},a){return await re(async function(){return await s.find("@keet/pinned-chat-messages",a).toArray()},e,t,s,i,o)}async _getChatLength({db:e}){const t=await e.get("@keet/threads",{id:0});return{length:t?t.count:0}}subscribeChatMessages(e,...t){return this._addRoomSubscription(e,{query:()=>this.getChatMessages(e,...t)})}subscribeChatLength(e,t){let s=null;return this._addRoomSubscription(e,{query:async()=>{if(!t||!t.reorders)return this.getChatLength(e);if(this.keet.closing)return null;const i=this.keet.internalOpenExistingRoom(e);try{const{length:t}=await this.getChatLength(e),{undos:o,fastForwards:a}=i.engine.stats,n=null!==s&&(o!==s.undos||a!==s.fastForwards);return s={undos:o,fastForwards:a},{length:t,reordered:n}}finally{this.keet.internalReleaseRoom(i)}}})}async _searchChatMessages({snapshot:e,roomKey:t,local:s,blobsSnapshot:i,files:o},n,{limit:r=1e3,reverse:c=!0}={}){if(!n||!n.length)return[];const l=await s.get("@local/rooms",{roomKey:t});if(!l)return[];if(!(n=n.map(e=>e.replace(/\s/g,"").toLowerCase()).filter(e=>e)).length)return[];const h=[];for await(const s of e.find("@keet/chat",{limit:r,reverse:c})){if(!s.message?.text)continue;const r=s.message.text.replace(/\s/g,"").toLowerCase();if(n.every(e=>r.indexOf(e)>-1)){const n=ce(t,e,i,l,o,s);n.catch(a),h.push(n)}}return Promise.all(h)}createChatSearchStream(e,t,s){return c.from(this._createChatSearchGenerator(e,t,s))}async*_createChatSearchGenerator(e,t,{limit:i=1e3,reverse:o=!0}={}){if(!t||!t.length)return;if(!(t=t.map(e=>e.replace(/\s/g,"").toLowerCase()).filter(e=>e)).length)return;const a=s.decode(e),n=await this.keet.local.get("@local/rooms",{roomKey:a});if(!n)return;const r=this.keet.internalOpenExistingRoom(a);await r.ready();const c=r.db.snapshot(),l=r.blobs?r.blobs.snapshot():null,h=this.keet.local.snapshot(),d=this.keet.files,u=c.find("@keet/chat",{limit:i,reverse:o});try{for await(const e of u){const t=await m(e);t&&(yield t)}}catch(e){this.keet.onerror(e)}finally{await h.close(),await c.close(),l&&await l.close(),this.keet.internalReleaseRoom(r)}async function m(e){const t=p(e.message?.text);let i=!1;if(e&&e.message&&e.message.files&&(i=!!e.message.files.length),!i&&!g(t))return;const o=await ce(a,c,l,n,d,e);if(i&&!g(t)&&!function(e){return e.files.some(e=>g(p(e.metadata?.name)))}(o))return;if(o.labels.flagged||o.labels.flags>=_e)return;const r=s.decode(o.memberId);return await h.get("@local/blocked-contacts",{memberKey:r})||await c.get("@keet/muted-members",{key:r})||o.reactions.digest.reactions.find(e=>"⚠️"===e.text)?void 0:o}function p(e){return e?e.replace(/\s/g,"").toLowerCase():""}function g(e){return!!e&&t.every(t=>e.indexOf(t)>-1)}}_sendDMFromContact(e,{message:t=null}={}){return this.keet.sendContactRequestFromContact(e,{message:t})}_sendDMRequest(e,t,{message:s=null}={}){return this.sendInvitations(e,{receivers:[t],message:s})}async _sendInvitations(e,{receivers:t,message:i}){const o=s.decode(e),a=Array.isArray(t)?t[0]:t,n=s.decode(a);await this.keet.sendContactRequest(o,n,{message:i})}async _updatePrivateMailboxRecord({memberId:e,roomId:t},i={}){this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready();const o=i.isSeen||1===i.seen;return this.keet.privateProfile.dispatch("@keet-private-id/update-contact-request-status",{memberKey:s.decode(e),roomKey:s.decode(t),key:se.IsSeen,status:{isSeen:o}})}async _getDmRequestsByStatus({localSnapshot:e,profileDb:t},s,{reverse:i=!0,limit:o=50}={}){if(!t)return[];const a={[ye.ACCEPTED]:"@keet-private-id/accepted-contact-requests-v2",[ye.REJECTED]:"@keet-private-id/rejected-contact-requests-v2",[ye.PENDING]:"@keet-private-id/pending-contact-requests-v2",[ye.DISCARDED]:"@keet-private-id/discarded-contact-requests-v2"}[s]||"@keet-private-id/pending-contact-requests-v2",n=t.find(a,{reverse:i,limit:o});return pe(n,async t=>{const s=await e.get("@local/active-contacts",{memberKey:t.memberKey});return I(t,s)})}subscribeDmRequestsByStatus(e,t={}){return this._addRoomSubscription(Te,{query:()=>this.getDmRequestsByStatus(e,t)})}async _getPrivateMailboxRecords({profile:e},t={}){console.warn("Deprecated: getPrivateMailboxRecords")}subscribePrivateMailbox(){return console.warn("Deprecated: subscribePrivateMailbox"),new c}getSentPrivateMailboxRecords(...e){console.warn("Deprecated: getSentPrivateMailboxRecords")}subscribeSentPrivateMailbox(...e){return console.warn("Deprecated: subscribeSentPrivateMailbox"),new c}async _getDmByMemberId({profileSnapshot:e},t){const o=s.decode(t),[a,n]=await Promise.all([e.get("@keet-private-id/contacts",{memberKey:o}),e.get("@keet-private-id/contact-requests",{memberKey:o})]);let r=null;return a&&a.roomKey?r=a.roomKey:n&&(r=n.keys.key),{roomId:r?s.encode(r):null,discoveryId:r?s.encode(i.discoveryKey(r)):null,dmMemberId:t,recipient:t}}async updateRoomInvitationSeenStatus({discoveryId:e,invitationId:t},i){return this.keet.updateRoomInvitationSeenStatus(s.decode(e),s.decode(t),i)}async _acceptDmRequest({memberId:e,roomId:t}){return this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready(),this.keet.privateProfile.dispatch("@keet-private-id/update-contact-request-status",{memberKey:s.decode(e),roomKey:s.decode(t),key:se.IsAccepted,status:{isAccepted:!0}})}async _rejectDmRequest({memberId:e,roomId:t}){return this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready(),this.keet.privateProfile.dispatch("@keet-private-id/update-contact-request-status",{memberKey:s.decode(e),roomKey:s.decode(t),key:se.IsRejected,status:{isRejected:!0}})}async discardDmRequest({memberId:e,roomId:t}){return this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready(),this.keet.privateProfile.dispatch("@keet-private-id/update-contact-request-status",{memberKey:s.decode(e),roomKey:s.decode(t),key:se.IsDiscarded,status:{isDiscarded:!0}})}_addReaction(e,t,i){return this.keet.dispatch(e,"@keet/add-reaction",{oplog:{key:s.decode(t.deviceId),seq:t.seq},reaction:i})}_removeReaction(e,t,i){return this.keet.dispatch(e,"@keet/remove-reaction",{oplog:{key:s.decode(t.deviceId),seq:t.seq},reaction:i})}async _getLatestReactions({snapshot:e},t,s,{limit:i}={}){const{id:o}=await e.get("@keet/chat-by-message-id",{oplog:H(t)});return(await e.find("@keet/reactions-by-clock",{gte:{id:o,reaction:s},lte:{id:o,reaction:s},limit:i,reverse:!0}).toArray()).map(e=>M(e))}async _getReactions({roomKey:e,snapshot:t,local:s},i){const o=H(i);return le({roomKey:e,snapshot:t,local:s,oplog:o})}subscribeReactions(e,t){return this._addRoomSubscription(e,{query:()=>this.getReactions(e,t)})}subscribeReportedMessages(e,...t){return this._addRoomSubscription(e,{query:()=>this.getReportedMessages(e,...t)})}subscribeReportedMembers(e,...t){return this._addRoomSubscription(e,{query:()=>this.getReportedMembers(e,...t),name:Ue})}async _getReportedMembers({snapshot:e,blobsSnapshot:t,localSnapshot:i},{clock:o,limit:a=50}={}){const n=await e.find("@keet/member-label-digests-by-clock",{gte:{label:te.Flag},lte:{label:te.Flag,clock:o},limit:a<=50?a:50,reverse:!0}),r=[];for await(const e of n){const t=c.bind(this);r.push(t(e))}return await Promise.all(r);async function c(o){const{key:a,total:n,flagsClock:r}=o,c=await this._getMember({snapshot:e,blobsSnapshot:t,localSnapshot:i},s.encode(a));return c.labels={total:n,flagsClock:r},c}}reportMember(e,t){return this.keet.dispatch(e,"@keet/add-member-label",{key:s.decode(t),label:te.Flag})}async _getReportedMessages({roomKey:e,local:t,snapshot:s,blobsSnapshot:i,files:o},{clock:a,limit:n=50}={}){const r=await t.get("@local/rooms",{roomKey:e});if(!r)return;const c=await s.find("@keet/chat-label-digests-by-clock",{gte:{label:ee.Flag},lte:{label:ee.Flag,clock:a},limit:n<=50?n:50,reverse:!0}),l=[];for await(const{id:e}of c)l.push(h(e));return await Promise.all(l);async function h(t){const a=await s.findOne("@keet/chat",{gte:{id:t},lte:{id:t}});return ce(e,s,i,r,o,a)}}_addChatReport(e,t){const s=H(t);return this.keet.dispatch(e,"@keet/add-chat-label",{oplog:s,label:ee.Flag})}_removeChatReport(e,t){const s=H(t);return this.keet.dispatch(e,"@keet/remove-chat-label",{oplog:s,label:ee.Flag})}async _dismissChatReports(e,t){const s=H(t);return this.keet.dispatch(e,"@keet/dismiss-chat-reports",{oplog:s})}addFileBlob(...e){throw console.log("addFileBlob",...e),new Error("Missing required method: addFileBlob")}addFile(...e){throw console.log("addFile",...e),new Error("Missing required method: addFile")}async _saveFileBlob({roomKey:e,files:t},s,i){const o=await t.saveFileBlob(e,s,i);return S(o)}async _saveFile({roomKey:e,files:t},s,i){const o=await t.saveFile(e,s,i);return S(o)}subscribeAddFile(e,t,i){const o=s.decode(e);return h(this.keet.files.subscribeAddFile(o,t,i),new l({transform(e,t){t(null,{...e,result:S(e.result)})}}))}async _sendFile(e,t){const s=t.preview;t.preview=null;const i=this.keet.batch(e),o=await i.dispatch("@keet/add-chat-message",{timestamp:Date.now(),message:V(null,{files:[t]})});0!==o&&(s&&await i.dispatch("@keet/add-file-preview",{oplog:{key:i.key,seq:o-1},index:0,preview:J(s)},{dryRun:!1}),await i.flush())}async _sendFiles(e,t=[]){const s=[];for(const e of t)s.push(e.preview),e.preview=null;const i=this.keet.batch(e),o=await i.dispatch("@keet/add-chat-message",{timestamp:Date.now(),message:V(null,{files:t})});if(0===o)return;const a={key:i.key,seq:o-1};for(let e=0;e<s.length;e++){const t=s[e];t&&await i.dispatch("@keet/add-file-preview",{oplog:a,index:e,preview:J(t)},{dryRun:!1})}await i.flush()}removeFile(...e){throw console.log("removeFile",...e),new Error("Missing required method: removeFile")}subscribeFileInfo(e,t){const i=s.decode(e),o=this;let a=null;return new c({async open(e){let s=null;try{a=await o.keet.files.monitor(i,G(t)),a.on("update",e=>{this.push(a.stats)})}catch(e){s=e}e(s)},async destroy(e){a&&a.close(),e(null)}})}async _clearAllFiles({roomId:e,roomKey:t,files:s},i){const o=await s.clearAllFiles(t,i);return this.keet.emit("local-files-changed",e),o}async _clearOldFiles(){return this.keet.files.clearOldFiles()}async _getFileEntry({roomKey:e,files:t},s){const i=await t.getFileEntry(e,G(s));return E(i)}async _getLocalFiles({roomKey:e,files:t,snapshot:s,blobsSnapshot:i}){const o=await t.getLocalFiles(e);return Promise.all(o.map(async o=>{const a=await t.getFileEntryWithPreview(e,o.file,{loadBlob:e=>me(e,s,i)});return{...S(a.file),entry:E(a)}}))}async _getFiles({roomKey:e,files:t,snapshot:i,blobsSnapshot:o},a={}){const n=Y(a),r=await i.find(a.type?"@keet/files-by-major-type":"@keet/active-files",n).toArray();return Promise.all(r.map(async a=>{const n=await t.getFileEntryWithPreview(e,a.file,{loadBlob:e=>me(e,i,o)});return{...S(n.file),id:a.id,messageId:{deviceId:s.encode(a.oplog.key),seq:a.oplog.seq},entry:E(n)}}))}_startDownload({roomKey:e,files:t},s){return t.startDownload(e,G(s))}_cancelDownload({roomKey:e,files:t},s){return t.cancelDownload(e,s)}readFileStream(e,t,i){const o=s.decode(e);return this.keet.files.readFileStream(o,G(t),i)}subscribeSaveToDisk(e,t,i,o={}){const a=s.decode(e);return this.keet.files.subscribeSaveToDisk(a,G(t),i,o)}_saveToDisk({roomKey:e,files:t},s,i){return t.saveToDisk(e,G(s),i)}async _clearFile({roomId:e,roomKey:t,files:s},i){i.preview?.large?.pointer?.externalBlob&&await s.clearFile(t,G(i.preview.large)),await s.clearFile(t,G(i)),this.keet.emit("local-files-changed",e)}async _unclearFile({roomId:e,roomKey:t,files:s},i){i.preview?.large?.pointer?.externalBlob&&await s.unclearFile(t,G(i.preview.large)),await s.unclearFile(t,G(i)),this.keet.emit("local-files-changed",e)}_getFileCleared({roomKey:e,files:t},s){return t.getFileCleared(e,G(s))}_refreshFileLinks(e){return this.keet.files.refreshLinks(e)}subscribeFileCleared(e,t){return this._addRoomSubscription(e,{query:()=>this.getFileCleared(e,t)})}subscribeFiles(e,...t){return this._addRoomSubscription(e,{query:async()=>this.getFiles(e,...t)})}getStats(){return{suspended:this.keet.state===Ee.SUSPEND,onlineBoot:this.keet.onlineBoot.opened,connections:this.keet.swarm.connections.size,openRooms:this.keet.rooms.size,openRoomIds:[...this.keet.rooms.keys()],openCores:this.keet.store.cores.size,blindPeering:this.keet.blindPeering?.stats??null,activeRooms:this.keet.activeRooms.size,roomSubscriptions:[...this._subscriptions.values()].filter(e=>e.isRoomSub).size,backgroundSwarmingRooms:[...this.keet.swarmWorker.sessions.keys()],dht:this.keet.swarm.dht.stats,swarm:this.keet.swarm.stats,ops:this.keet.stats.ops,uploaded:this.keet.stats.uploaded,bytesUploaded:this.keet.stats.bytesUploaded,downloaded:this.keet.stats.downloaded,bytesDownloaded:this.keet.stats.bytesDownloaded,appends:this.keet.stats.appends,bytesAppended:this.keet.stats.bytesAppended,ipc:{sent:0,recv:0},threads:[]}}async getRoomStats(e){const t=this.keet.internalOpenExistingRoom(s.decode(e));try{return await t.getStats()}finally{this.keet.internalReleaseRoom(t)}}async _lookupUsername(e){if(!e)return;const t=await this.keet.userRegistry.lookup(e);return K(t)}async _lookupUserByMemberId(e){if(!e)return;const t=s.decode(e),i=await this.keet.userRegistry.lookupByKey(t);return K(i)}async _searchUsername(e,{limit:t=20}={}){return(await this.keet.userRegistry.search(e,{limit:t})).map(K)}_registerUsername(e){return this.keet.userRegistry.update(e)}_updateUsername(e){return this.keet.userRegistry.update(e)}async _getReservationsByKey(e){if(!e)return;const t=s.decode(e),i=await this.keet.userRegistry.getReservationsByKey(t);if(!i||!i.length)return null;const o=i[0];return D(o)}subscribeUsername(){const e=this.keet.userRegistry.subscribeUsername();return h(e,new l({transform(e,t){if(!e)return t(null);t(null,{status:e.status,reservation:D(e.reservation),record:K(e.record),error:e.error})}}))}_checkUsername(e){return this.keet.userRegistry.isAvailable(e)}subscribeSystemUpdateRequest(){return this._addKeetSubscription(Ne,{query:()=>this.keet.migrationStatus||{remaining:0}})}async autobeeLogs(e){const t=this.keet.internalOpenExistingRoom(s.decode(e));try{await t.ready(),await t.engine.logs()}finally{this.keet.internalReleaseRoom(t)}}close(){return this.keet.close()}suspend(){return this.keet.suspend()}resume(){return this.keet.resume()}async getDebugFlags(){const e=await this.keet.local.get("@local/debug");return e?.flags||[]}async updateDebugFlag(e,t){const s=Ce.get(e);if(!(s>=0))return;const i=await this.keet.internalEnterLocalTransaction();try{const e=await i.get("@local/debug");e.flags[s].value=!0===t,await i.insert("@local/debug",e),await i.flush()}finally{await this.keet.internalExitLocalTransaction()}}createErrorStream(){return h(this.keet.local.find("@local/errors"),new l({transform(e,t){t(null,A(e))}}))}async _repair(e){const t=this.keet.internalOpenExistingRoom(s.decode(e));try{await t.ready(),await t.engine.repair()}finally{this.keet.internalReleaseRoom(t)}}async _audit(e){const t=this.keet.rootCorestore.audit(e),s=[];for await(const e of t)s.push(e);return s}async _rotateWriter(e){return this.keet.rotateWriter(s.decode(e))}compact(e=!1){return e?this.keet.storage.compact({blobGarbageCollectionPolicy:De.garbageCollectionPolicy.FORCE,blobGarbageCollectionAgeCutoff:1,bottommostLevelCompaction:De.bottommostLevelCompaction.FORCE}):this.keet.storage.compact()}async _setUnread(e,t){const i=s.decode(e),o=await this.keet.internalEnterLocalTransaction();try{await o.insert("@local/unreads",{roomKey:i,count:t}),await o.flush()}finally{await this.keet.internalExitLocalTransaction()}}async _getUnread(e){const t=s.decode(e),i=await this.keet.local.get("@local/unreads",{roomKey:t});return i?i.count:0}async _setUnreadAnchor(e,t){const i=s.decode(e);this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready(),this.keet.unreads&&(await this.keet.unreads.put(i,{timestamp:Date.now(),length:t}),this.keet.emit("unread-anchors-changed"));const o=await this.keet.local.get("@local/rooms",{roomKey:i});if(!o?.dm?.length)return;const a=await this.keet.internalOpenPrivateProfile();try{const s=await a.db.get("@keet-private-id/settings");if(s?.disableReadReceipts)return;await this.keet.dispatch(e,"@keet/update-read-length",{length:t})}finally{this.keet.internalReleaseRoom(a)}}async _getUnreadAnchor(e){if(this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready(),!this.keet.unreads)return null;const t=s.decode(e);return this.keet.unreads.get(t)}_subscribeUnreadAnchor(e){return this._addKeetSubscription(je,{query:async()=>{const t=await this.getUnreadAnchor(e);return null!==t?t:{length:0,timestamp:0}}})}async _getUnreadRooms({local:e}){this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready();const t=this.keet.unreads,i=[],o=[];for await(const t of e.find("@local/rooms-by-timestamp"))o.push(a(t));return await Promise.all(o),{rooms:i};async function a(e){const o=t?await t.get(e.roomKey):null;de(e,e.preferences,o)&&i.push({id:s.encode(e.roomKey),isFullyMuted:!!e.preferences?.isFullyMuted,roomSnoozeTime:e.preferences?.roomSnoozeTime??0})}}_subscribeUnreadRooms(){return this._addKeetSubscription(Ve,{query:()=>this.getUnreadRooms()})}async _updateTypingIndicator({roomId:e,db:t}){this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready(),(await t.get("@keet/system-digest")).settings.roomType===Q.DirectMessage&&await this.keet.dispatch(e,"@keet/update-typing-indicator",{})}async _getTypingIndicator({db:e},t){const i=s.decode(t),o=await e.get("@keet/typing-indicators",{memberKey:i});return o?{memberId:t,timestamp:o.timestamp}:null}_subscribeTypingIndicator(e,t){return this._addRoomSubscription(e,{query:()=>this.getTypingIndicator(e,t),name:"typing-indicator"})}async _setRoomFavorite(e,t=!0){this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready();const{privateProfileKey:i}=await this.keet.local.get("@local/identity");await this.keet.local.get("@local/rooms",{roomKey:i})&&await this.keet.privateProfile.dispatch("@keet-private-id/update-room-status",{roomKey:s.decode(e),key:ie.IsFavorite,status:{isFavorite:t}})}}class Xe{constructor(e){this.keet=e}async ready(){return await this.keet.ready(),s.encode(this.keet.swarm.keyPair.publicKey)}}class Qe{constructor(t){this.keet=t,this.preferences=new g(e.join(t.dir,"preferences_v1.json")),this._subs=[]}async _bump(){const e=await this.preferences.list();for(const t of this._subs)t.push(e)}async update(e,t){await this.preferences.set(e,t),await this._bump()}query(){return this.preferences.list()}subscribe(){const e=this,t=new c({async open(e){let t=null;try{await this._bump()}catch(e){t=e}e(t)},destroy(t){const s=e._subs.indexOf(this);-1!==s&&e._subs.splice(s,1),t(null)}});return this._subs.push(t),t}}class Ze{constructor(e,{onerror:t=a}={}){this.keet=e,this._status=null,this._subs=[],this.keet.swarm.on("update",this._handleUpdate.bind(this)),this.keet.swarm.dht.on("network-update",this._handleUpdate.bind(this)),this.keet.bluetooth&&this.keet.bluetooth.on("update",this._handleUpdate.bind(this))}_handleUpdate(){this._status=this.query();for(const e of this._subs)e.push(this._status)}query(){const e=[];for(const[t,i]of this.keet.swarm.peers)e.push(s.encode(i.publicKey));return{host:this.keet.swarm.dht.host,port:this.keet.swarm.dht.port,online:this.keet.swarm.dht.online,degraded:this.keet.swarm.dht.degraded,connections:this.keet.swarm.connections.size,dhtPublicKey:s.encode(this.keet.swarm.dht.defaultKeyPair.publicKey),swarmPublicKey:s.encode(this.keet.swarm.keyPair.publicKey),peers:e,bluetooth:this.keet.bluetooth?this.keet.bluetooth.status():{state:"unsupported",enabled:!1,peers:0,nearby:{sharing:!1,changes:0}}}}async setBluetoothEnabled(e){return!0===e?await this.keet.internalEnableBluetooth():await this.keet.internalDisableBluetooth(),this.query().bluetooth}async setNearbyContactInfo(e,t){return await this.keet.bluetooth.setNearbyContactInfo(e,t),this.keet.bluetooth.status()}async clearNearbyContactInfo(){return await this.keet.bluetooth.clearNearbyContactInfo(),this.keet.bluetooth.status()}async getNearbyContactInfos(){return this.keet.bluetooth.nearby.contactInfos()}subscribe(){const e=this,t=new c({open(t){e._status&&this.push(e._status),t(null)},destroy(t){const s=e._subs.indexOf(this);-1!==s&&e._subs.splice(s,1),t(null)}});return this._subs.push(t),t}subscribeDebug(e=5e3,t=0){const s=this;let i=null,o=0;const a=new c({open(t){n(),i=setInterval(()=>{n()},e),t(null)},destroy(e){i&&(clearInterval(i),i=null),e(null)}});return a;async function n(){const e=await s.debug();a.push(e),o+=1,t&&o>=t&&a.push(null)}}async debug(){return{tick:this.keet.swarm.dht._tick,localAddress:this.keet.swarm.dht.localAddress(),remoteAddress:this.keet.swarm.dht.remoteAddress(),connection:this.query(),stats:this.keet.swarm.dht.stats,health:this.keet.swarm.dht.health.stats,nodes:this.keet.swarm.dht.nodes.length,config:this.keet.swarm.dht.config,rttStats:await this.keet.swarm.dht.rttStats()}}}class et{constructor(e,{onerror:t=a}={}){this.keet=e,this._status=null,this._subs=[],this.swarm=null,this._onupdate=this._handleUpdate.bind(this),this.keet.on("call-swarm-changed",this._handleCallSwarmChanged.bind(this))}_handleCallSwarmChanged(e,t){this.swarm&&this.swarm.dht.removeListener("network-update",this._onupdate),this.swarm=t,this.swarm&&this.swarm.dht.on("network-update",this._onupdate),this._handleUpdate()}_handleUpdate(){this._status=this.query();for(const e of this._subs)e.push(this._status)}query(){if(!this.swarm)return{active:!1,host:null,port:0,online:!1,degraded:!1,connections:0,peers:[]};const e=[];for(const t of this.swarm.peers.values())e.push(s.encode(t.publicKey));return{active:!0,host:this.swarm.dht.host,port:this.swarm.dht.port,online:this.swarm.dht.online,degraded:this.swarm.dht.degraded,connections:this.swarm.connections.size,peers:e}}subscribe(){const e=this,t=new c({open(t){e._status&&this.push(e._status),t(null)},destroy(t){const s=e._subs.indexOf(this);-1!==s&&e._subs.splice(s,1),t(null)}});return this._subs.push(t),t}subscribeDebug(e=5e3,t=0){const s=this;let i=null,o=0;const a=new c({open(t){n(),i=setInterval(()=>{n()},e),t(null)},destroy(e){i&&(clearInterval(i),i=null),e(null)}});return a;async function n(){const e=await s.debug();a.push(e),o+=1,t&&o>=t&&a.push(null)}}async debug(){return this.swarm?{active:!0,tick:this.swarm.dht._tick,localAddress:this.swarm.dht.localAddress(),remoteAddress:this.swarm.dht.remoteAddress(),connection:this.query(),stats:this.swarm.dht.stats,health:this.swarm.dht.health.stats,nodes:this.swarm.dht.nodes.length,config:this.swarm.dht.config,rttStats:await this.swarm.dht.rttStats()}:{active:!1}}}class tt{constructor(){this.subscriptions=[],this._handleError=this._handleError.bind(this),this._listenersAttached=!1}_handleError(e){console.error("uncaught on worker",e);for(const t of this.subscriptions)t.push({message:e.message,stack:e.stack+""})}subscribe(e){const t=this;this._listenersAttached||(r.on(this._handleError),this._listenersAttached=!0);const s=new c({...e,destroy(e){const s=t.subscriptions.indexOf(this);-1!==s&&t.subscriptions.splice(s,1),e(null)}});return this.subscriptions.push(s),s}}class st{constructor(e){this.keet=e,this.inspector=new Pe}_getCurrentRoom(){let e=null;for(const t of this.keet.rooms.values())(!e||t.refs>e.refs)&&(e=t);return e}async getCurrentRoomStats(){const e=this._getCurrentRoom();return{hash:(await(e?.engine.core.treeHash())).toString("hex"),length:e?.engine.length}}enableInspector(){return this.inspector?.enable()}disableInspector(){return this.inspector?.disable()}getInspectorKey(){return this.inspector?.key}processTop(){return p.toJSON()}hash(e){return i.hash(e)}generateSyntheticError(e,t={}){const s=new Error(t.message??t.code??"KEET_SYNTHETIC_ERROR");if(s.code=t.code??s.message,Object.assign(s,t),!e)throw s;this.keet.onerror(s)}async getAccumulatedBytes(){let e=0;for await(const{value:t}of this.keet.rootCorestore.storage.db.iterator()){if(this.keet.closing)return e;e+=t.byteLength}return e}async heapSnapshot(e="/tmp/keet-heapsnapshot-"+Bare.pid+"."+Date.now()+".heapsnapshot"){const t=new d;t.connect();const s=new u(t),i=m.createWriteStream(e);return s.pipe(i),await new Promise(e=>i.once("close",e)),t.destroy(),e}async resetUnreads(){if(this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready(),!this.keet.unreads)return null;await this.keet.unreads.reset()}}class it{constructor(e){this._rpcClient=e.rpcClient,this.keet=e}send(e){if(this.keet.buildType===X.Production)return this._rpcClient.makeRequest(this.keet.config.services.feedback,"send",e,{requestEncoding:Se.json})}}function ot(e){switch(e){case 1:return ie.IsFullyMuted;case 2:return ie.IsMentionsOnlyMuted;default:return 0}}function at(e){switch(e){case"0":default:return Q.Default;case"1":return Q.Broadcast;case"2":return Q.DirectMessage}}function nt(e){const t={files:[],httpLink:[],pearLink:[]},s=e.files||[];for(let e=0;e<s.length;e++){const i=s[e].preview;i&&(s[e].preview=null,t.files.push({index:e,preview:i}))}const i=e.display?.httpLink||[];for(let e=0;e<i.length;e++){const s=a(i[e]);s&&t.httpLink.push({index:e,preview:s})}const o=e.display?.pearLink||[];for(let e=0;e<o.length;e++){const s=a(o[e]);s&&t.pearLink.push({index:e,preview:s})}return t;function a(e){if(!e.preview?.file?.preview)return null;const t=e.preview.file.preview;return e.preview.file.preview=null,t}}async function rt(e,{files:t,httpLink:s,pearLink:i},o=null){const a=o||{key:e.key,seq:e.length-1};if(t.length)for(const{index:s,preview:i}of t)await e.dispatch("@keet/add-file-preview",{oplog:a,index:s,preview:J(i)},{dryRun:!1});if(s.length)for(const{index:t,preview:i}of s)await e.dispatch("@keet/add-file-preview",{oplog:a,index:t,preview:J(i),displayType:Z.HttpLink},{dryRun:!1});if(i.length)for(const{index:t,preview:s}of i)await e.dispatch("@keet/add-file-preview",{oplog:a,index:t,preview:J(s),displayType:Z.PearLink},{dryRun:!1})}async function ct(e,t){t.proofs=await e.get("@keet/member-proofs",{key:t.key})}function lt(e){const t=U(e.activeCall);return{roomId:s.encode(e.roomKey),callId:t.callId,selfDeviceId:t.selfDeviceId,createdAt:t.createdAt}}module.exports=class extends t{constructor(e,t){super(),this.keet=e,this.opts=t,this.api={core:new $e(e,t),swarm:null,preferences:null,network:null,error:null,debug:null,console:null,call:null,pear:{teardown:()=>{console.log("[api] teardown initiated");const t=this.keet.close();return t.catch(e.onerror),t},selfDestruct:e=>this.keet.selfDestruct(e)}},this._callBootstraps=null,this.ready().catch(t?.onerror||a)}async _open(){await this.keet.ready(),this.api.swarm=new Xe(this.keet,this.opts),this.api.preferences=new Qe(this.keet,this.opts),this.api.network=new Ze(this.keet,this.opts),this.api.callNetwork=new et(this.keet,this.opts),this.api.error=new tt(this.keet,this.opts),this.api.debug=new st(this.keet,this.opts),this.api.feedback=new it(this.keet),this.call=this.api.call=new b(this.keet.swarm,{skipJoinLeave:!0}),this.keet.on("call-changed-v3",this._handleCallChangedV3.bind(this))}async _close(){this.call&&this.call.close(),await this.api.debug.disableInspector()}async closeActiveCalls(){if(!this.keet.activeCall)return;const{roomId:e,callKey:t}=this.keet.activeCall,i=await this.keet.local.get("@local/rooms",{roomKey:s.decode(e)});if(!i)return;const o=this.keet.rooms.get(e);if(!o)return;const a=i.dm?"@keet/end-call":"@keet/leave-call";await o.dispatch(a,{callKey:t},{dryRun:!1}),await new Promise(e=>setTimeout(e,1500))}_handleCallChangedV3(e){this.keet.internalSyncActiveCall(e)}async suspend(){await this.keet.suspend()}async resume(){await this.keet.resume()}};
@holepunchto/keet-core/lib/core/bluetooth/index.js +1 -0
……@@ -0,0 +1 @@
1const e=require("hypercore-id-encoding"),t=require("ready-resource"),a=require("ble-swarm"),s=require("./nearby"),{hash:n}=require("hypercore-crypto"),r=require("safety-catch"),i=n(require("b4a").from("keet-ble"));module.exports=class extends t{constructor(e,t={}){super(),this.keet=e,this.enabled=!1,this.swarm=new a({...t,keyPair:e.swarm.keyPair,topic:i,tag:"keet-ble-v1",online:!1!==e.swarm.dht.online}),this.nearby=new s({onupdate:()=>this.emit("update"),validate:e=>this._readableContactInfo(e)}),this._onNetworkUpdate=()=>this.swarm.setOnline(!1!==this.keet.swarm.dht.online),this.keet.swarm.dht.on("network-update",this._onNetworkUpdate),this.swarm.on("connection",e=>{this.keet._handleConnection(e),this.nearby.attach(e)}),this.swarm.on("update",()=>this.emit("update"))}get state(){return this.swarm.state}get isEnabled(){return!0===this.enabled}status(){const t=[];for(const a of this.swarm.connections)a.remotePublicKey&&t.push(e.encode(a.remotePublicKey));return{state:this.state,enabled:this.enabled,peers:t.length,peerIds:t,id:this.keet.swarmId,nearby:{sharing:this.nearby.sharing,changes:this.nearby.changes}}}async setEnabled(e){this.enabled=!0===e,this.enabled?await this.swarm.start():await this.swarm.stop(),this.emit("update")}_readableContactInfo(e){try{return this.keet.internalDecodeContactInfo(e),!0}catch{return!1}}async setNearbyContactInfo(e,t){this.keet.internalDecodeContactInfo(e),this.nearby.setContactInfo(e,t),this.emit("update")}async clearNearbyContactInfo(){this.nearby.clearContactInfo(),this.emit("update")}async suspend(){await this.swarm.suspend()}async resume(){await this.swarm.resume()}async _close(){this.nearby.clear(),this.keet.swarm.dht.off("network-update",this._onNetworkUpdate),await this.swarm.close().catch(r)}};
@holepunchto/keet-core/lib/core/bluetooth/nearby.js +1 -0
……@@ -0,0 +1 @@
1const t=require("compact-encoding"),e=require("protomux");function n(){}module.exports=class{constructor({onupdate:t=n,validate:e=null}={}){this._own=null,this._changes=0,this._onupdate=t,this._validate=e,this._links=new Map}get sharing(){return null!==this._own}get changes(){return this._changes}get peers(){let t=0;for(const e of this._links.values())e.remote&&t++;return t}contactInfos(){const t=[];for(const{remote:e}of this._links.values())e&&t.push(e);return t}setContactInfo(t,e=""){this._share({contactInfo:t,avatar:e||""})}clearContactInfo(){this._share(null)}_share(t){const e=null!==t&&null===this._own;if(this._own=t,!t)for(const t of this._links.values())t.remote=null;for(const t of this._links.keys())this._send(t,e);this._changed()}attach(n){const s=e.from(n).createChannel({protocol:"keet/nearby/v1",onopen:()=>this._send(s),onclose:()=>this._detach(s),ondestroy:()=>this._detach(s),messages:[{encoding:t.json,onmessage:t=>this._onremote(s,t)}]});s&&(this._links.set(s,{message:s.messages[0],remote:null}),s.open())}clear(){this._own=null,this._links.clear()}_send(t,e=!1){const n=this._links.get(t);if(!n)return;const s=this._own||{contactInfo:""};n.message.send(e?{...s,resend:!0}:s)}_onremote(t,e){const n=this._links.get(t);if(!n)return;const s="string"==typeof e?.contactInfo?e.contactInfo:"",o="string"==typeof e?.avatar?e.avatar:"";if(s.length>4096||o.length>65536)return void t.close();if(!0===e?.resend&&this.sharing&&this._send(t),!this.sharing)return;const a=s&&(null===this._validate||this._validate(s))?{contactInfo:s,avatar:o}:null;!!a==!!n.remote&&(!a||a.contactInfo===n.remote.contactInfo&&a.avatar===n.remote.avatar)||(n.remote=a,this._changed())}_detach(t){const e=this._links.get(t);this._links.delete(t),e?.remote&&this._changed()}_changed(){this._changes++,this._onupdate()}};
@holepunchto/keet-core/lib/core/call/active-call.js +1 -1
……@@ -1 +1 @@
1const e=require("ready-guard"),t=require("hypercore-id-encoding"),s=require("scope-lock"),a=require("b4a"),i=require("../sync/loader.js"),r=require("./ghost.js"),{KeetErrorV2:l}=require("../../errors");module.exports=class{constructor(a,i,r){this.keet=a,this.roomId=i,this.callId=r,this.callKey=t.decode(r),this.swarmId=t.encode(a.callSwarmKeyPair.publicKey),this.guard=new e,this.closing=null,this.room=null,this.callRecord=null,this.callDevice=null,this.swarm=null,this.joinedPeers=new Set,this.heartbeatPaused=!0===a.callHeartbeatOpts.paused,this.suspended=!1,this._opening=null,this._ghostThreshold=a.callHeartbeatOpts.ghostThreshold,this._heartbeatInterval=a.callHeartbeatOpts.heartbeatInterval||3e5,this._heartbeatTimer=null,this._heartbeatPromise=null,this._syncLock=new s({debounce:!0})}ready(){return this.guard.enter()&&(this._opening=this._open()),this.guard.ready()}close(){return this.closing||(this.closing=this._close()),this.closing}async _open(){try{this.room=this.keet.internalOpenExistingRoom(this.roomId),this.room.opened||await this.room.ready();const{call:e,callDevice:t}=await this._loadCallState();if(!e||!t)throw l.CALL_NOT_ACTIVE("",{callId:this.callId});this.callRecord=e,this.callDevice=t,this.swarm=this.keet.internalCreateCallSwarm(),this.keet.callProxy.open(this.callId,this.swarm),this._heartbeatTimer=setInterval(this._sendHeartbeat.bind(this),this._heartbeatInterval),this._syncPeers(),this.keet.emit("call-swarm-changed",this.callId,this.swarm),t.lastHeartbeatAt>0&&Date.now()-t.lastHeartbeatAt>=this._heartbeatInterval&&this._sendHeartbeat(),this.guard.exit()}catch(e){await this._teardown(),this.guard.destroy(e)}}async _close(){this.guard.destroy(),this._opening&&await this._opening,this._syncLock.destroy(),await this._syncLock.flush(),await this._teardown()}async _teardown(){clearInterval(this._heartbeatTimer),this._heartbeatTimer=null;for(const e of this.joinedPeers)this.keet.debugLeavePeer(e);this.joinedPeers.clear(),this.swarm&&(this.keet.callProxy.close(this.callId),this.keet.emit("call-swarm-changed",null,null),await this.swarm.destroy(),this.swarm=null),this.room&&(await this.keet.internalReleaseRoom(this.room),this.room=null)}async sync(){if(this.guard.opened&&await this._syncLock.lock())try{const{call:e,callDevice:t}=await this._loadCallState();if(this.keet.activeCall!==this)return;if(!e||!t)return void this.keet.internalEndActiveCall();this.callRecord=e,this.callDevice=t,this._syncPeers()}catch(e){this.keet.onerror(e)}finally{this._syncLock.unlock()}}pauseHeartbeat(){this.heartbeatPaused=!0}resumeHeartbeat(){this.heartbeatPaused=!1,this._sendHeartbeat()}async suspend(){this.suspended||(this.suspended=!0,this.swarm&&await this.swarm.suspend())}async resume(){this.suspended&&(this.suspended=!1,this.swarm&&await this.swarm.resume(),this._sendHeartbeat())}async _loadCallState(){await this.room.engine.flush();const e=new i(this.keet.local,this.room.view,this.room.engine);await e.ready();try{const t=await e.loadActiveCall();return t&&a.equals(t.callKey,this.callKey)?{call:t,callDevice:await e.loadActiveCallDevice(t.callKey,this.room.deviceKey)}:{call:null,callDevice:null}}finally{await e.close()}}_sendHeartbeat(){if(this.callRecord&&!this.closing&&!this.suspended&&!this.heartbeatPaused)return this._heartbeatPromise||(this._heartbeatPromise=this._dispatchHeartbeat()),this._heartbeatPromise}async _dispatchHeartbeat(){try{if(this.keet.closing||this.closing)return;await this.keet.dispatch(this.roomId,"@keet/call-device-heartbeat",{callKey:this.callKey})}finally{this._heartbeatPromise=null}}_syncPeers(){const e=Date.now(),s=new Set;for(const a of this.callRecord.members)for(const i of a.devices){if(!r(e,i,this._ghostThreshold))continue;const a=t.encode(i.swarmKey);a!==this.swarmId&&s.add(a)}for(const e of s)this.joinedPeers.has(e)||(this.swarm.joinPeer(t.decode(e)),this.joinedPeers.add(e),this.keet.debugJoinPeer(e));for(const e of this.joinedPeers)s.has(e)||(this.swarm.leavePeer(t.decode(e)),this.joinedPeers.delete(e),this.keet.debugLeavePeer(e))}};
1const e=require("ready-guard"),t=require("hypercore-id-encoding"),s=require("scope-lock"),a=require("b4a"),i=require("../sync/loader.js"),r=require("./ghost.js"),{KeetErrorV2:l}=require("../../errors");module.exports=class{constructor(a,i,r){this.keet=a,this.roomId=i,this.callId=r,this.callKey=t.decode(r),this.swarmId=t.encode(a.callSwarmKeyPair.publicKey),this.guard=new e,this.closing=null,this.room=null,this.callRecord=null,this.callDevice=null,this.swarm=null,this.joinedPeers=new Set,this.heartbeatPaused=!0===a.callHeartbeatOpts.paused,this.suspended=!1,this._opening=null,this._ghostThreshold=a.callHeartbeatOpts.ghostThreshold,this._heartbeatInterval=a.callHeartbeatOpts.heartbeatInterval||3e5,this._heartbeatTimer=null,this._heartbeatPromise=null,this._syncLock=new s({debounce:!0})}ready(){return this.guard.enter()&&(this._opening=this._open()),this.guard.ready()}close(){return this.closing||(this.closing=this._close()),this.closing}async _open(){try{this.room=this.keet.internalOpenExistingRoom(this.roomId),this.room.opened||await this.room.ready();const{call:e,callDevice:t}=await this._loadCallState();if(!e||!t)throw l.CALL_NOT_ACTIVE("",{callId:this.callId});this.callRecord=e,this.callDevice=t;for(const e of this.keet.closingCallSwarms)await e;this.swarm=this.keet.internalCreateCallSwarm(),this.keet.callProxy.open(this.callId,this.swarm),this._heartbeatTimer=setInterval(this._sendHeartbeat.bind(this),this._heartbeatInterval),this._syncPeers(),this.keet.emit("call-swarm-changed",this.callId,this.swarm),t.lastHeartbeatAt>0&&Date.now()-t.lastHeartbeatAt>=this._heartbeatInterval&&this._sendHeartbeat(),this.guard.exit()}catch(e){await this._teardown(),this.guard.destroy(e)}}async _close(){this.guard.destroy(),this._opening&&await this._opening,this._syncLock.destroy(),await this._syncLock.flush(),await this._teardown()}async _teardown(){clearInterval(this._heartbeatTimer),this._heartbeatTimer=null;for(const e of this.joinedPeers)this.keet.debugLeavePeer(e);if(this.joinedPeers.clear(),this.swarm){this.keet.callProxy.close(this.callId),this.keet.emit("call-swarm-changed",null,null);const e=this.swarm.destroy().catch(e=>this.keet.onerror(e));this.keet.closingCallSwarms.add(e),e.then(()=>this.keet.closingCallSwarms.delete(e)),this.swarm=null}this.room&&(await this.keet.internalReleaseRoom(this.room),this.room=null)}async sync(){if(this.guard.opened&&await this._syncLock.lock())try{const{call:e,callDevice:t}=await this._loadCallState();if(this.keet.activeCall!==this)return;if(!e||!t)return void this.keet.internalEndActiveCall();this.callRecord=e,this.callDevice=t,this._syncPeers()}catch(e){this.keet.onerror(e)}finally{this._syncLock.unlock()}}pauseHeartbeat(){this.heartbeatPaused=!0}resumeHeartbeat(){this.heartbeatPaused=!1,this._sendHeartbeat()}async suspend(){this.suspended||(this.suspended=!0,this.swarm&&await this.swarm.suspend())}async resume(){this.suspended&&(this.suspended=!1,this.swarm&&await this.swarm.resume(),this._sendHeartbeat())}async _loadCallState(){await this.room.engine.flush();const e=new i(this.keet.local,this.room.view,this.room.engine);await e.ready();try{const t=await e.loadActiveCall();return t&&a.equals(t.callKey,this.callKey)?{call:t,callDevice:await e.loadActiveCallDevice(t.callKey,this.room.deviceKey)}:{call:null,callDevice:null}}finally{await e.close()}}_sendHeartbeat(){if(this.callRecord&&!this.closing&&!this.suspended&&!this.heartbeatPaused)return this._heartbeatPromise||(this._heartbeatPromise=this._dispatchHeartbeat()),this._heartbeatPromise}async _dispatchHeartbeat(){try{if(this.keet.closing||this.closing)return;await this.keet.dispatch(this.roomId,"@keet/call-device-heartbeat",{callKey:this.callKey})}finally{this._heartbeatPromise=null}}_syncPeers(){const e=Date.now(),s=new Set;for(const a of this.callRecord.members)for(const i of a.devices){if(!r(e,i,this._ghostThreshold))continue;const a=t.encode(i.swarmKey);a!==this.swarmId&&s.add(a)}for(const e of s)this.joinedPeers.has(e)||(this.swarm.joinPeer(t.decode(e)),this.joinedPeers.add(e),this.keet.debugJoinPeer(e));for(const e of this.joinedPeers)s.has(e)||(this.swarm.leavePeer(t.decode(e)),this.joinedPeers.delete(e),this.keet.debugLeavePeer(e))}};
@holepunchto/keet-core/lib/core/contract/avatars.js +1 -1
……@@ -1 +1 @@
1const e=require("b4a"),i=require("hypercore-crypto"),{KeetContractError:r}=require("./errors"),{fileStats:n}=require("./stats"),t=524288;async function a(n,a,l){if(!a&&!l)return;if(!d(l))return;if(l.preview&&(l.preview=null),!l.pointer.inlined&&l.pointer.blob&&(l.pointer.blob=null),!l||!l.pointer.inlined)return a||l;if(a&&a.hash&&l.hash&&e.equals(a.hash,l.hash))return{...l,pointer:a.pointer};if(l.pointer.inlined.byteLength>t)throw r.INLINED_FILESIZE_TOO_LARGE("Cannot inline a blob that is larger than 512 KB");const s=i.hash(l.pointer.inlined);return await n.insert("@keet/blobs",{hash:s,data:l.pointer.inlined}),{...l,pointer:{bee:{hash:s}}}}async function l(e,i,r){return{small:await a(e,i?.small,r?.small),medium:await a(e,i?.medium,r?.medium),large:await a(e,i?.large,r?.large)}}async function s(e,i,r){r&&await Promise.all([o(e,i,r.small),o(e,i,r.medium),o(e,i,r.large)])}async function o(e,i,r){if(r)if(r.pointer.bee){const i=await e.get("@keet/blobs",r.pointer.bee);r.pointer={inlined:i.data}}else if(r.pointer.blob&&i){const e=await i.get(r.pointer.blob);r.pointer={inlined:e}}}async function p({primaryThread:e,id:i,db:r,oplog:t,file:a}){a.preview&&(a.preview=await l(r,null,a.preview)),a.pointer.inlined&&(a.pointer.inlined=null),a.pointer.blob&&(a.pointer.blob=null);const s={id:i,oplog:t,status:{isDeleted:!1},file:a};return await r.insert("@keet/files",s),await n(r,e,s),i}async function f({primaryThread:e,files:i,id:n,blobs:t,db:a,oplog:l}){if(!i||i.length<1)return[];if(!function(e){const i=Array.isArray(e)?e:[e];for(const e of i)if(!d(e))return!1;return!0}(i))throw r.FILE_RECORD_INVALID();const s=[];for(const r of i)s.push(await p({primaryThread:e,id:n++,blobs:t,db:a,oplog:l,file:r}));return s}function u(i,r){return!i&&!r||!(!i&&r)&&!(i&&!r)&&(i.hash&&r.hash?e.equals(i.hash,r.hash):e.equals(i.pointer.inlined,r.pointer.inlined))}function d(e){return e.preview&&(e.preview?.small?.preview&&(e.preview.small.preview=null),e.preview?.medium?.preview&&(e.preview.medium.preview=null),e.preview?.large?.preview&&(e.preview.large.preview=null)),!(e.pointer.externalDrive&&!e.pointer.externalDrive.path||e.pointer.externalDrive&&e.pointer.externalBlob)}module.exports={isSameAvatar:function(e,i){const r=u(e?.small,i?.small),n=u(e?.medium,i?.medium),t=u(e?.large,i?.large);return r&&n&&t},updateAvatar:async function(e,i,r){return await l(e,i,r)},updateImageFile:l,restoreAvatar:async function(e,i,r){return s(e,i,r)},restoreFile:s,insertMessageFiles:async function({primaryThread:e,clock:i,message:r,blobs:n,db:t,oplog:a}){const l=r.files||[],s=await f({primaryThread:e,files:l,id:i,blobs:n,db:t,oplog:a});return await async function({primaryThread:e,clock:i,message:r,blobs:n,db:t,oplog:a}){let l=0;const s=r?.display?.httpLink||[];for(const r of s)r.preview?.files&&(r.preview.files=[]),r.preview?.file&&(r.preview.files=await f({primaryThread:e,id:i+l,files:[r.preview.file],blobs:n,db:t,oplog:a}),l+=r.preview.files.length);const o=r?.display?.pearLink||[];for(const r of o)r.preview?.files&&(r.preview.files=[]),r.preview?.file&&(r.preview.files=await f({primaryThread:e,id:i+l,files:[r.preview.file],blobs:n,db:t,oplog:a}),l+=r.preview.files.length)}({primaryThread:e,clock:i+l.length,message:r,blobs:n,db:t,oplog:a}),s},deleteMessageFiles:async function({primaryThread:e,message:i,db:r,blobs:t}){const a=i.message?.files||[],l=i.message?.display?.httpLink||[];for(const{preview:e}of l)e&&e.files&&e.files.length&&a.push(...e.files);const s=i.message?.display?.pearLink||[];for(const{preview:e}of s)e&&e.files&&e.files.length&&a.push(...e.files);await async function({primaryThread:e,files:i,db:r,blobs:t}){if(!i||!i.length)return;const a=await Promise.all(i.map(e=>r.get("@keet/files",{id:e}))),l=[];for(const i of a)i.status.isDeleted=!0,l.push(r.insert("@keet/files",i)),l.push(n(r,e,i,i));await Promise.all(l)}({primaryThread:e,files:a,db:r,blobs:t})},MAX_INLINED_FILE_SIZE:t};
1const e=require("b4a"),i=require("hypercore-crypto"),{KeetContractError:r}=require("./errors"),{fileStats:n}=require("./stats"),t=524288;async function a(n,a,l){if(!a&&!l)return;if(!b(l))return;if(l.preview&&(l.preview=null),!l.pointer.inlined&&l.pointer.blob&&(l.pointer.blob=null),!l||!l.pointer.inlined)return a||l;if(a&&a.hash&&l.hash&&e.equals(a.hash,l.hash))return{...l,pointer:a.pointer};if(l.pointer.inlined.byteLength>t)throw r.INLINED_FILESIZE_TOO_LARGE("Cannot inline a blob that is larger than 512 KB");const s=i.hash(l.pointer.inlined);return await n.insert("@keet/blobs",{hash:s,data:l.pointer.inlined}),{...l,pointer:{bee:{hash:s}}}}async function l(e,i,r){return{small:await a(e,i?.small,r?.small),medium:await a(e,i?.medium,r?.medium),large:await a(e,i?.large,r?.large)}}async function s(e,i,r){r&&await Promise.all([o(e,i,r.small),o(e,i,r.medium),o(e,i,r.large)])}async function o(e,i,r){if(r)if(r.pointer.bee){const i=await e.get("@keet/blobs",r.pointer.bee);r.pointer={inlined:i.data}}else if(r.pointer.blob&&i){const e=await i.get(r.pointer.blob);r.pointer={inlined:e}}}async function p({primaryThread:e,id:i,db:r,oplog:t,file:a}){a.preview&&(a.preview=await l(r,null,a.preview)),a.pointer.inlined&&(a.pointer.inlined=null),a.pointer.blob&&(a.pointer.blob=null);const s={id:i,oplog:t,status:{isDeleted:!1},file:a};return await r.insert("@keet/files",s),await n(r,e,s),i}async function u({primaryThread:e,files:i,id:n,blobs:t,db:a,oplog:l}){if(!i||i.length<1)return[];if(!function(e){const i=Array.isArray(e)?e:[e];for(const e of i)if(!b(e))return!1;return!0}(i))throw r.FILE_RECORD_INVALID();const s=[];for(const r of i)s.push(await p({primaryThread:e,id:n++,blobs:t,db:a,oplog:l,file:r}));return s}async function f({primaryThread:e,clock:i,links:r,blobs:n,db:t,oplog:a}){let l=0;for(const s of r)s.preview?.files&&(s.preview.files=[]),s.preview?.file&&(s.preview.files=await u({primaryThread:e,id:i+l,files:[s.preview.file],blobs:n,db:t,oplog:a}),l+=s.preview.files.length)}async function d({primaryThread:e,files:i,db:r,blobs:t}){if(!i||!i.length)return;const a=await Promise.all(i.map(e=>r.get("@keet/files",{id:e}))),l=[];for(const i of a)i.status.isDeleted=!0,l.push(r.insert("@keet/files",i)),l.push(n(r,e,i,i));await Promise.all(l)}function c(i,r){return!i&&!r||!(!i&&r)&&!(i&&!r)&&(i.hash&&r.hash?e.equals(i.hash,r.hash):e.equals(i.pointer.inlined,r.pointer.inlined))}function b(e){return e.preview&&(e.preview?.small?.preview&&(e.preview.small.preview=null),e.preview?.medium?.preview&&(e.preview.medium.preview=null),e.preview?.large?.preview&&(e.preview.large.preview=null)),!(e.pointer.externalDrive&&!e.pointer.externalDrive.path||e.pointer.externalDrive&&e.pointer.externalBlob)}module.exports={isSameAvatar:function(e,i){const r=c(e?.small,i?.small),n=c(e?.medium,i?.medium),t=c(e?.large,i?.large);return r&&n&&t},updateAvatar:async function(e,i,r){return await l(e,i,r)},updateImageFile:l,restoreAvatar:async function(e,i,r){return s(e,i,r)},restoreFile:s,insertMessageFiles:async function({primaryThread:e,clock:i,message:r,blobs:n,db:t,oplog:a}){const l=r.files||[],s=await u({primaryThread:e,files:l,id:i,blobs:n,db:t,oplog:a});return await async function({primaryThread:e,clock:i,message:r,blobs:n,db:t,oplog:a}){const l=r?.display?.httpLink||[],s=r?.display?.pearLink||[];await f({primaryThread:e,clock:i,links:[...l,...s],blobs:n,db:t,oplog:a})}({primaryThread:e,clock:i+l.length,message:r,blobs:n,db:t,oplog:a}),s},insertLinkPreviewFiles:f,deleteMessageFiles:async function({primaryThread:e,message:i,db:r,blobs:n}){const t=i.message?.files||[],a=i.message?.display?.httpLink||[];for(const{preview:e}of a)e&&e.files&&e.files.length&&t.push(...e.files);const l=i.message?.display?.pearLink||[];for(const{preview:e}of l)e&&e.files&&e.files.length&&t.push(...e.files);await d({primaryThread:e,files:t,db:r,blobs:n})},deleteFileRecord:d,MAX_INLINED_FILE_SIZE:t};
@holepunchto/keet-core/lib/core/contract/chat.js +1 -1
……@@ -1 +1 @@
1const e=require("b4a"),t=require("./registration"),{getMemberForDeviceKey:s,isMemberActive:i}=require("./query"),{KeetContractError:a}=require("./errors"),{insertMessageFiles:r,deleteMessageFiles:o,updateImageFile:n}=require("./avatars"),{contract:{hyperschema:{getEnum:d}}}=require("../../../schema/spec"),{chatStats:l,fileStats:c}=require("./stats"),{trackActivity:g}=require("./hooks"),w=d("@keet/room-type");async function h({message:e,header:t},{db:o,blobs:n,writer:d}){let[c,g,h,m,p,k]=await Promise.all([s(o,d.key),o.get("@keet/threads",{id:0}),e.parent?o.get("@keet/threads-by-parent",{oplog:e.parent}):null,e.parent?o.get("@keet/chat-by-message-id",{oplog:e.parent}):null,e.replyTo?o.get("@keet/chat-by-message-id",{oplog:e.replyTo}):null,o.get("@keet/system-digest")]);if(!i(c))throw a.INACTIVE_MEMBER();if(c.status.isMuted)throw a.WRITER_IS_MUTED();const y=k.settings.roomType===w.Broadcast||k.settings.isAppendingDisabled;if(!c.status.isModerator&&y)throw a.MODERATORS_ONLY();if(e.parent&&!m)throw a.PARENT_MSG_INVALID();if(e.replyTo&&!p)throw a.REPLYTO_MSG_INVALID();if(e.parent||(h=g),e.event?.callMissed){const e=await o.get("@keet/chat",{id:{thread:h.id,index:h.count-1}});if(e&&e.event.callMissed)throw a.NO_DUPLICATE_CALL_EVENTS()}if(k.settings.isAttachmentsDisabled&&f(e))throw a.FILE_ATTACHMENTS_DISABLED();if(k.settings.isLinksDisabled&&T(e))throw a.LINKS_DISABLED();const E=g.stats.files.clock;e.files=await r({primaryThread:g,clock:E,message:e,blobs:n,db:o,oplog:d});const u={id:{thread:h.id,index:h.count},oplog:d,clock:g.stats.chat.clock,timestamp:t.timestamp,message:e,status:{isEdited:!1,isPinned:!1,isDeleted:!1},event:e.event};return await o.insert("@keet/chat",u),await l(o,g,u),{writer:d,writerMember:c}}async function m({header:t,oplog:n,message:d},{db:c,blobs:g,writer:w}){const[h,m,p,k,y,E]=await Promise.all([s(c,w.key),s(c,n.key),c.get("@keet/chat-by-message-id",{oplog:n}),c.get("@keet/threads",{id:0}),d.replyTo?c.get("@keet/chat-by-message-id",{oplog:d.replyTo}):null,c.get("@keet/system-digest")]);if(!i(h))throw a.INACTIVE_MEMBER();if(!p)throw a.TARGET_MSG_INVALID();if(!m)throw a.TARGET_MEMBER_NOT_FOUND();if(!e.equals(h.key,m.key))throw a.SELF_ONLY();if(p.status.isDeleted)throw a.TARGET_MSG_IS_DELETED();if(d.replyTo&&!y)throw a.REPLYTO_MSG_INVALID();if(E.settings.isAttachmentsDisabled&&f(d))throw a.FILE_ATTACHMENTS_DISABLED();if(E.settings.isLinksDisabled&&T(d))throw a.LINKS_DISABLED();const u=[];p.message?.files?.length&&(u.push(...p.message.files),p.message.files=[]),d.files=[],await o({primaryThread:k,message:p,db:c,blobs:g});const _=k.stats.files.clock;await r({primaryThread:k,clock:_,message:d,blobs:g,db:c,oplog:w});const b={...p,message:{...p.message,text:d.text,files:u,display:d.display},status:{...p.status,isEdited:!0},editedAt:t.timestamp};return await c.insert("@keet/chat",b),await l(c,k,b,p),{writer:w,writerMember:h}}async function p({oplog:t},{db:r,blobs:n,writer:d}){const[c,g,w,h]=await Promise.all([s(r,d.key),s(r,t.key),r.get("@keet/chat-by-message-id",{oplog:t}),r.get("@keet/threads",{id:0})]);if(!i(c))throw a.INACTIVE_MEMBER();if(!w)throw a.TARGET_MSG_INVALID();if(!c.status.isModerator&&!e.equals(c.key,g.key))throw a.MODERATORS_OR_SELF_ONLY();await o({primaryThread:h,message:w,db:r,blobs:n});const m={...w,message:null,status:{...w.status,isDeleted:!0,isPinned:!1}};await r.insert("@keet/chat",m),await l(r,h,m,w);const p=await r.get("@keet/chat-label-digests",{id:w.id});return p?(await r.insert("@keet/chat-label-digests",{...p,isDeleted:!0}),{writer:d,writerMember:c}):{writer:d,writerMember:c}}async function k({oplog:e,isPinned:t},{db:r,writer:o}){const[n,d,c]=await Promise.all([s(r,o.key),r.get("@keet/chat-by-message-id",{oplog:e}),r.get("@keet/threads",{id:0})]);if(!i(n))throw a.INACTIVE_MEMBER();if(!d)throw a.TARGET_MSG_INVALID();if(!n.status.isModerator)throw a.MODERATORS_ONLY();const g={...d,status:{...d.status,isPinned:t}};return await r.insert("@keet/chat",g),await l(r,c,g,d),{writer:o,writerMember:n}}async function y({oplog:t,index:r,preview:o,displayType:d},{db:l,writer:g}){const[w,h,m,p]=await Promise.all([s(l,g.key),s(l,t.key),l.get("@keet/chat-by-message-id",{oplog:t}),l.get("@keet/threads",{id:0})]);if(!i(w))throw a.INACTIVE_MEMBER();if(!m)throw a.TARGET_MSG_INVALID();if(!h)throw a.TARGET_MEMBER_NOT_FOUND();if(!e.equals(w.key,h.key))throw a.SELF_ONLY();const k=d?function(e,t,s){const i=e.message?.display;switch(t){case 1:return i?.httpLink?.[s]?.preview?.files;case 2:return i?.pearLink?.[s]?.preview?.files}}(m,d,r):m.message?.files,y=d?0:r;if(!k||k.length<=y)throw a.FILE_REFERENCE_INVALID("files is falsy or invalid index");const E=await l.get("@keet/files",{id:k[y]});if(!E)throw a.FILE_RECORD_INVALID("record is falsy");return E.file.preview=await n(l,null,o),await l.insert("@keet/files",E),await c(l,p,E,E),{writer:g,writerMember:w}}async function E({length:e},{db:t,writer:a}){const[r,o]=await Promise.all([t.get("@keet/system-digest"),s(t,a.key)]);if(i(o)&&!o.status.isMuted&&r.settings.roomType===w.DirectMessage)return await t.insert("@keet/read-lengths",{memberKey:o.key,length:e}),{writer:a,writerMember:o}}async function u({header:e},{db:t,writer:r}){const[o,n]=await Promise.all([t.get("@keet/system-digest"),s(t,r.key)]);if(!i(n))throw a.INACTIVE_MEMBER();if(o.settings.roomType!==w.DirectMessage)throw a.INVALID_ROOM_TYPE();await t.insert("@keet/typing-indicators",{memberKey:n.key,timestamp:e.timestamp})}function f(e){return e?.files?.length>0||e?.display?.httpLink?.some(e=>e.preview)||e?.display?.pearLink?.some(e=>e.preview)}function T(e){return e.display?.httpLink?.length>0||e?.display?.pearLink?.length>0}module.exports={addEvent:async function(e,t,s,i,a){const r=await e.get("@keet/threads",{id:0}),o={id:{thread:0,index:r.count},oplog:t,clock:r.stats.chat.clock,timestamp:i,event:s,status:{isEdited:!1,isPinned:!1,isDeleted:!1}};await e.insert("@keet/chat",o),await l(e,r,o)},[t]:function(e){e.add("@keet/add-chat-message",g(h)),e.add("@keet/update-chat-message",g(m)),e.add("@keet/remove-chat-message",g(p)),e.add("@keet/pin-chat-message",g(k)),e.add("@keet/add-file-preview",g(y)),e.add("@keet/update-read-length",g(E)),e.add("@keet/update-typing-indicator",u)}};
1const e=require("b4a"),t=require("./registration"),{getMemberForDeviceKey:i,isMemberActive:s}=require("./query"),{KeetContractError:a}=require("./errors"),{insertMessageFiles:r,insertLinkPreviewFiles:o,deleteMessageFiles:n,deleteFileRecord:l,updateImageFile:d}=require("./avatars"),{contract:{hyperschema:{getEnum:c}}}=require("../../../schema/spec"),{chatStats:w,fileStats:h}=require("./stats"),{trackActivity:g}=require("./hooks"),p=c("@keet/room-type");async function m({message:e,header:t},{db:o,blobs:n,writer:l}){let[d,c,h,g,m,k]=await Promise.all([i(o,l.key),o.get("@keet/threads",{id:0}),e.parent?o.get("@keet/threads-by-parent",{oplog:e.parent}):null,e.parent?o.get("@keet/chat-by-message-id",{oplog:e.parent}):null,e.replyTo?o.get("@keet/chat-by-message-id",{oplog:e.replyTo}):null,o.get("@keet/system-digest")]);if(!s(d))throw a.INACTIVE_MEMBER();if(d.status.isMuted)throw a.WRITER_IS_MUTED();const y=k.settings.roomType===p.Broadcast||k.settings.isAppendingDisabled;if(!d.status.isModerator&&y)throw a.MODERATORS_ONLY();if(e.parent&&!g)throw a.PARENT_MSG_INVALID();if(e.replyTo&&!m)throw a.REPLYTO_MSG_INVALID();if(e.parent||(h=c),e.event?.callMissed){const e=await o.get("@keet/chat",{id:{thread:h.id,index:h.count-1}});if(e&&e.event.callMissed)throw a.NO_DUPLICATE_CALL_EVENTS()}if(k.settings.isAttachmentsDisabled&&A(e))throw a.FILE_ATTACHMENTS_DISABLED();if(k.settings.isLinksDisabled&&N(e))throw a.LINKS_DISABLED();const E=c.stats.files.clock;e.files=await r({primaryThread:c,clock:E,message:e,blobs:n,db:o,oplog:l});const f={id:{thread:h.id,index:h.count},oplog:l,clock:c.stats.chat.clock,timestamp:t.timestamp,message:e,status:{isEdited:!1,isPinned:!1,isDeleted:!1},event:e.event};return await o.insert("@keet/chat",f),await w(o,c,f),{writer:l,writerMember:d}}async function k({header:t,oplog:o,message:l},{db:d,blobs:c,writer:h}){const[g,p,m,k,y,E]=await Promise.all([i(d,h.key),i(d,o.key),d.get("@keet/chat-by-message-id",{oplog:o}),d.get("@keet/threads",{id:0}),l.replyTo?d.get("@keet/chat-by-message-id",{oplog:l.replyTo}):null,d.get("@keet/system-digest")]);if(!s(g))throw a.INACTIVE_MEMBER();if(!m)throw a.TARGET_MSG_INVALID();if(!p)throw a.TARGET_MEMBER_NOT_FOUND();if(!e.equals(g.key,p.key))throw a.SELF_ONLY();if(m.status.isDeleted)throw a.TARGET_MSG_IS_DELETED();if(l.replyTo&&!y)throw a.REPLYTO_MSG_INVALID();if(E.settings.isAttachmentsDisabled&&A(l))throw a.FILE_ATTACHMENTS_DISABLED();if(E.settings.isLinksDisabled&&N(l))throw a.LINKS_DISABLED();const f=[];m.message?.files?.length&&(f.push(...m.message.files),m.message.files=[]),l.files=[],await n({primaryThread:k,message:m,db:d,blobs:c});const u=k.stats.files.clock;await r({primaryThread:k,clock:u,message:l,blobs:c,db:d,oplog:h});const b={...m,message:{...m.message,text:l.text,files:f,display:l.display},status:{...m.status,isEdited:!0},editedAt:t.timestamp};return await d.insert("@keet/chat",b),await w(d,k,b,m),{writer:h,writerMember:g}}async function y({oplog:t},{db:r,blobs:o,writer:l}){const[d,c,h,g]=await Promise.all([i(r,l.key),i(r,t.key),r.get("@keet/chat-by-message-id",{oplog:t}),r.get("@keet/threads",{id:0})]);if(!s(d))throw a.INACTIVE_MEMBER();if(!h)throw a.TARGET_MSG_INVALID();if(!d.status.isModerator&&!e.equals(d.key,c.key))throw a.MODERATORS_OR_SELF_ONLY();await n({primaryThread:g,message:h,db:r,blobs:o});const p={...h,message:null,status:{...h.status,isDeleted:!0,isPinned:!1}};await r.insert("@keet/chat",p),await w(r,g,p,h);const m=await r.get("@keet/chat-label-digests",{id:h.id});return m?(await r.insert("@keet/chat-label-digests",{...m,isDeleted:!0}),{writer:l,writerMember:d}):{writer:l,writerMember:d}}async function E({oplog:e,isPinned:t},{db:r,writer:o}){const[n,l,d]=await Promise.all([i(r,o.key),r.get("@keet/chat-by-message-id",{oplog:e}),r.get("@keet/threads",{id:0})]);if(!s(n))throw a.INACTIVE_MEMBER();if(!l)throw a.TARGET_MSG_INVALID();if(!n.status.isModerator)throw a.MODERATORS_ONLY();const c={...l,status:{...l.status,isPinned:t}};return await r.insert("@keet/chat",c),await w(r,d,c,l),{writer:o,writerMember:n}}async function f({header:t,oplog:r,index:o,preview:n,displayType:l},{db:c,writer:g}){const[p,m,k,y]=await Promise.all([i(c,g.key),i(c,r.key),c.get("@keet/chat-by-message-id",{oplog:r}),c.get("@keet/threads",{id:0})]);if(!s(p))throw a.INACTIVE_MEMBER();if(!k)throw a.TARGET_MSG_INVALID();if(!m)throw a.TARGET_MEMBER_NOT_FOUND();if(!e.equals(p.key,m.key))throw a.SELF_ONLY();const E=l?M(k,l,o):k.message?.files,f=l?0:o;if(!E||E.length<=f)throw a.FILE_REFERENCE_INVALID();const u=await c.get("@keet/files",{id:E[f]});if(!u)throw a.FILE_RECORD_INVALID();if(u.file.preview){const e={...k,status:{...k.status,isEdited:!0},editedAt:t.timestamp};await Promise.all([c.insert("@keet/chat",e),w(c,y,e,k)])}return u.file.preview=await d(c,null,n),await Promise.all([c.insert("@keet/files",u),h(c,y,u,u)]),{writer:g,writerMember:p}}async function u({header:t,oplog:r,index:o,displayType:n},{db:l,writer:d}){const[c,g,p,m]=await Promise.all([i(l,d.key),i(l,r.key),l.get("@keet/chat-by-message-id",{oplog:r}),l.get("@keet/threads",{id:0})]);if(!s(c))throw a.INACTIVE_MEMBER();if(!p)throw a.TARGET_MSG_INVALID();if(!e.equals(c.key,g.key))throw a.SELF_ONLY();const k=n?M(p,n,o):p.message?.files,y=n?0:o;if(!k||k.length<=y)throw a.FILE_REFERENCE_INVALID();const E=await l.get("@keet/files",{id:k[y]});if(!E)throw a.FILE_RECORD_INVALID();const f={...p,status:{...p.status,isEdited:!0},editedAt:t.timestamp};return E.file.preview=null,await Promise.all([l.insert("@keet/chat",f),l.insert("@keet/files",E),w(l,m,f,p),h(l,m,E,E)]),{writer:d,writerMember:c}}async function b({header:t,oplog:r,displayType:n,index:d,preview:c},{db:h,blobs:g,writer:p}){const[m,k,y,E]=await Promise.all([i(h,p.key),i(h,r.key),h.get("@keet/chat-by-message-id",{oplog:r}),h.get("@keet/threads",{id:0})]);if(!s(m))throw a.INACTIVE_MEMBER();if(!y)throw a.TARGET_MSG_INVALID();if(!e.equals(m.key,k.key))throw a.SELF_ONLY();const f=L(n),u=f?y.message?.display?.[f]:null;if(!u||u.length<=d)throw a.LINK_REFERENCE_INVALID();const b=u[d];b.preview?.files?.length&&await l({primaryThread:E,files:b.preview.files,db:h,blobs:g});const _={...b,preview:c},I=E.stats.files.clock;await o({primaryThread:E,clock:I,links:[_],blobs:g,db:h,oplog:p});const T={...y,message:{...y.message,display:{...y.message.display,[f]:u.with(d,_)}}};return b.preview&&(T.status={...y.status,isEdited:!0},T.editedAt=t.timestamp),await Promise.all([h.insert("@keet/chat",T),w(h,E,T,y)]),{writer:p,writerMember:m}}async function _({header:t,oplog:r,displayType:o,index:n},{db:d,blobs:c,writer:h}){const[g,p,m,k]=await Promise.all([i(d,h.key),i(d,r.key),d.get("@keet/chat-by-message-id",{oplog:r}),d.get("@keet/threads",{id:0})]);if(!s(g))throw a.INACTIVE_MEMBER();if(!m)throw a.TARGET_MSG_INVALID();if(!e.equals(g.key,p.key))throw a.SELF_ONLY();const y=L(o),E=y?m.message?.display?.[y]:null;if(!E||E.length<=n)throw a.LINK_REFERENCE_INVALID();const f=E[n];f.preview?.files?.length&&await l({primaryThread:k,files:f.preview.files,db:d,blobs:c});const u={...m,message:{...m.message,display:{...m.message.display,[y]:E.with(n,{...f,preview:null})}},status:{...m.status,isEdited:!0},editedAt:t.timestamp};return await Promise.all([d.insert("@keet/chat",u),w(d,k,u,m)]),{writer:h,writerMember:g}}async function I({length:e},{db:t,writer:a}){const[r,o,n]=await Promise.all([t.get("@keet/system-digest"),i(t,a.key),t.get("@keet/threads",{id:0})]);if(s(o)&&!o.status.isMuted&&r.settings.roomType===p.DirectMessage)return await t.insert("@keet/read-lengths",{memberKey:o.key,length:Math.min(e,n.count)}),{writer:a,writerMember:o}}async function T({header:e},{db:t,writer:r}){const[o,n]=await Promise.all([t.get("@keet/system-digest"),i(t,r.key)]);if(!s(n))throw a.INACTIVE_MEMBER();if(o.settings.roomType!==p.DirectMessage)throw a.INVALID_ROOM_TYPE();await t.insert("@keet/typing-indicators",{memberKey:n.key,timestamp:e.timestamp})}function M(e,t,i){const s=e.message?.display;switch(t){case 1:return s?.httpLink?.[i]?.preview?.files;case 2:return s?.pearLink?.[i]?.preview?.files}}function L(e){switch(e){case 1:return"httpLink";case 2:return"pearLink"}}function A(e){return e?.files?.length>0||e?.display?.httpLink?.some(e=>e.preview)||e?.display?.pearLink?.some(e=>e.preview)}function N(e){return e.display?.httpLink?.length>0||e?.display?.pearLink?.length>0}module.exports={addEvent:async function(e,t,i,s,a){const r=await e.get("@keet/threads",{id:0}),o={id:{thread:0,index:r.count},oplog:t,clock:r.stats.chat.clock,timestamp:s,event:i,status:{isEdited:!1,isPinned:!1,isDeleted:!1}};await e.insert("@keet/chat",o),await w(e,r,o)},[t]:function(e){e.add("@keet/add-chat-message",g(m)),e.add("@keet/update-chat-message",g(k)),e.add("@keet/remove-chat-message",g(y)),e.add("@keet/pin-chat-message",g(E)),e.add("@keet/add-file-preview",g(f)),e.add("@keet/remove-file-preview",g(u)),e.add("@keet/add-link-preview",g(b)),e.add("@keet/remove-link-preview",g(_)),e.add("@keet/update-read-length",g(I)),e.add("@keet/update-typing-indicator",T)}};
@holepunchto/keet-core/lib/core/contract/errors.js +1 -1
……@@ -1 +1 @@
1const _={CORRUPT:"KEET_CONTRACT_CORRUPT",ABORT:"KEET_CONTRACT_ABORT",BUNDLE_NOT_AVAILABLE:"BUNDLE_NOT_AVAILABLE",ADMINS_ONLY:"ADMINS_ONLY",MODERATORS_ONLY:"MODERATORS_ONLY",SELF_ONLY:"SELF_ONLY",MODERATORS_OR_SELF_ONLY:"MODERATORS_OR_SELF_ONLY",INVALID_ROOM_TYPE:"INVALID_ROOM_TYPE",WRITER_IS_MUTED:"WRITER_IS_MUTED",PARENT_MSG_INVALID:"PARENT_MSG_INVALID",REPLYTO_MSG_INVALID:"REPLYTO_MSG_INVALID",TARGET_MSG_INVALID:"TARGET_MSG_INVALID",TARGET_MSG_IS_DELETED:"TARGET_MSG_IS_DELETED",TARGET_MSG_IS_OWN:"TARGET_MSG_IS_OWN",CHAT_LABEL_EXISTS:"CHAT_LABEL_EXISTS",CHAT_LABEL_NOT_FOUND:"CHAT_LABEL_NOT_FOUND",CHAT_FLAG_LIMIT_EXCEEDED:"CHAT_FLAG_LIMIT_EXCEEDED",FILE_REFERENCE_INVALID:"FILE_REFERENCE_INVALID",FILE_RECORD_INVALID:"FILE_RECORD_INVALID",INLINED_FILESIZE_TOO_LARGE:"INLINED_FILESIZE_TOO_LARGE",FILE_ATTACHMENTS_DISABLED:"FILE_ATTACHMENTS_DISABLED",LINKS_DISABLED:"LINKS_DISABLED",INACTIVE_MEMBER:"INACTIVE_MEMBER",MUTED_MEMBER:"MUTED_MEMBER",TARGET_MEMBER_NOT_FOUND:"TARGET_MEMBER_NOT_FOUND",INVALID_MEMBER_STATUS:"INVALID_MEMBER_STATUS",CONTACT_NOT_FOUND:"CONTACT_NOT_FOUND",NO_DUPLICATE_CALL_EVENTS:"NO_DUPLICATE_CALL_EVENTS",GENESIS_NOT_FIRST:"GENESIS_NOT_FIRST",INVALID_SYSTEM_SETTING:"INVALID_SYSTEM_SETTING",ACTIVE_CALL_EXISTS:"ACTIVE_CALL_EXISTS",CALL_KEY_EXISTS:"CALL_KEY_EXISTS",CALL_NOT_FOUND:"CALL_NOT_FOUND",CALL_ENDED:"CALL_ENDED",CALL_DEVICE_EXISTS:"CALL_DEVICE_EXISTS",CALL_DEVICE_NOT_FOUND:"CALL_DEVICE_NOT_FOUND",CALL_MEMBER_NOT_FOUND:"CALL_MEMBER_NOT_FOUND",CALL_STREAM_EXISTS:"CALL_STREAM_EXISTS",CALL_STREAM_NOT_FOUND:"CALL_STREAM_NOT_FOUND",CALL_MEDIA_STREAM_ID_EXISTS:"CALL_MEDIA_STREAM_ID_EXISTS",CALL_STREAM_NOT_OWNED:"CALL_STREAM_NOT_OWNED",CALL_LEAVE_NOT_ALLOWED:"CALL_LEAVE_NOT_ALLOWED",CALL_RECORDING_ALREADY_ACTIVE:"CALL_RECORDING_ALREADY_ACTIVE",CALL_NOT_RECORDING:"CALL_NOT_RECORDING",CALL_DISABLED:"CALL_DISABLED",INVALID_BUILD_TYPE:"INVALID_BUILD_TYPE",DISPATCH_ERROR:"DISPATCH_ERROR",INVALID_TARGET_DEVICE:"INVALID_TARGET_DEVICE"};class E extends Error{constructor(_,L,T=E){super(_?`${L}: ${_}`:L),this.code=L,this.isContractError=!0,this.abi=null,this.roomKey=null,Error.captureStackTrace&&Error.captureStackTrace(this,T)}static isContractError(_){return!!_.isContractError||"KEET_CONTRACT_ABORT"===_.code}static CORRUPT(L=""){return new E(L,_.CORRUPT,E.CORRUPT)}static ABORT(L=""){return new E(L,_.ABORT,E.ABORT)}static BUNDLE_NOT_AVAILABLE(L,T=null){const A=new E(T?`ABI ${L}: ${T.message}`:"ABI "+L,_.BUNDLE_NOT_AVAILABLE,E.BUNDLE_NOT_AVAILABLE);return A.abi=L,A.cause=T,A}static ADMINS_ONLY(L=""){return new E(L,_.ADMINS_ONLY,E.ADMINS_ONLY)}static MODERATORS_ONLY(L=""){return new E(L,_.MODERATORS_ONLY,E.MODERATORS_ONLY)}static SELF_ONLY(L=""){return new E(L,_.SELF_ONLY,E.SELF_ONLY)}static MODERATORS_OR_SELF_ONLY(L=""){return new E(L,_.MODERATORS_OR_SELF_ONLY,E.MODERATORS_OR_SELF_ONLY)}static INVALID_ROOM_TYPE(L=""){return new E(L,_.INVALID_ROOM_TYPE,E.INVALID_ROOM_TYPE)}static WRITER_IS_MUTED(L=""){return new E(L,_.WRITER_IS_MUTED,E.WRITER_IS_MUTED)}static PARENT_MSG_INVALID(L=""){return new E(L,_.PARENT_MSG_INVALID,E.PARENT_MSG_INVALID)}static REPLYTO_MSG_INVALID(L=""){return new E(L,_.REPLYTO_MSG_INVALID,E.REPLYTO_MSG_INVALID)}static TARGET_MSG_INVALID(L=""){return new E(L,_.TARGET_MSG_INVALID,E.TARGET_MSG_INVALID)}static TARGET_MSG_IS_DELETED(L=""){return new E(L,_.TARGET_MSG_IS_DELETED,E.TARGET_MSG_IS_DELETED)}static TARGET_MSG_IS_OWN(L=""){return new E(L,_.TARGET_MSG_IS_OWN,E.TARGET_MSG_IS_OWN)}static CHAT_LABEL_EXISTS(L=""){return new E(L,_.CHAT_LABEL_EXISTS,E.CHAT_LABEL_EXISTS)}static CHAT_LABEL_NOT_FOUND(L=""){return new E(L,_.CHAT_LABEL_NOT_FOUND,E.CHAT_LABEL_NOT_FOUND)}static CHAT_FLAG_LIMIT_EXCEEDED(L=""){return new E(L,_.CHAT_FLAG_LIMIT_EXCEEDED,E.CHAT_FLAG_LIMIT_EXCEEDED)}static FILE_REFERENCE_INVALID(L=""){return new E(L,_.FILE_REFERENCE_INVALID,E.FILE_REFERENCE_INVALID)}static FILE_RECORD_INVALID(L=""){return new E(L,_.FILE_RECORD_INVALID,E.FILE_RECORD_INVALID)}static INLINED_FILESIZE_TOO_LARGE(L=""){return new E(L,_.INLINED_FILESIZE_TOO_LARGE,E.INLINED_FILESIZE_TOO_LARGE)}static FILE_ATTACHMENTS_DISABLED(L=""){return new E(L,_.FILE_ATTACHMENTS_DISABLED,E.FILE_ATTACHMENTS_DISABLED)}static LINKS_DISABLED(L=""){return new E(L,_.LINKS_DISABLED,E.LINKS_DISABLED)}static INACTIVE_MEMBER(L=""){return new E(L,_.INACTIVE_MEMBER,E.INACTIVE_MEMBER)}static MUTED_MEMBER(L=""){return new E(L,_.MUTED_MEMBER,E.MUTED_MEMBER)}static TARGET_MEMBER_NOT_FOUND(L=""){return new E(L,_.TARGET_MEMBER_NOT_FOUND,E.TARGET_MEMBER_NOT_FOUND)}static INVALID_MEMBER_STATUS(L=""){return new E(L,_.INVALID_MEMBER_STATUS,E.INVALID_MEMBER_STATUS)}static CONTACT_NOT_FOUND(L=""){return new E(L,_.CONTACT_NOT_FOUND,E.CONTACT_NOT_FOUND)}static NO_DUPLICATE_CALL_EVENTS(L=""){return new E(L,_.NO_DUPLICATE_CALL_EVENTS,E.NO_DUPLICATE_CALL_EVENTS)}static GENESIS_NOT_FIRST(L=""){return new E(L,_.GENESIS_NOT_FIRST,E.GENESIS_NOT_FIRST)}static INVALID_SYSTEM_SETTING(L=""){return new E(L,_.INVALID_SYSTEM_SETTING,E.INVALID_SYSTEM_SETTING)}static ACTIVE_CALL_EXISTS(L=""){return new E(L,_.ACTIVE_CALL_EXISTS,E.ACTIVE_CALL_EXISTS)}static CALL_KEY_EXISTS(L=""){return new E(L,_.CALL_KEY_EXISTS,E.CALL_KEY_EXISTS)}static CALL_NOT_FOUND(L=""){return new E(L,_.CALL_NOT_FOUND,E.CALL_NOT_FOUND)}static CALL_ENDED(L=""){return new E(L,_.CALL_ENDED,E.CALL_ENDED)}static CALL_DEVICE_EXISTS(L=""){return new E(L,_.CALL_DEVICE_EXISTS,E.CALL_DEVICE_EXISTS)}static CALL_DEVICE_NOT_FOUND(L=""){return new E(L,_.CALL_DEVICE_NOT_FOUND,E.CALL_DEVICE_NOT_FOUND)}static CALL_MEMBER_NOT_FOUND(L=""){return new E(L,_.CALL_MEMBER_NOT_FOUND,E.CALL_MEMBER_NOT_FOUND)}static CALL_STREAM_EXISTS(L=""){return new E(L,_.CALL_STREAM_EXISTS,E.CALL_STREAM_EXISTS)}static CALL_STREAM_NOT_FOUND(L=""){return new E(L,_.CALL_STREAM_NOT_FOUND,E.CALL_STREAM_NOT_FOUND)}static CALL_MEDIA_STREAM_ID_EXISTS(L=""){return new E(L,_.CALL_MEDIA_STREAM_ID_EXISTS,E.CALL_MEDIA_STREAM_ID_EXISTS)}static CALL_STREAM_NOT_OWNED(L=""){return new E(L,_.CALL_STREAM_NOT_OWNED,E.CALL_STREAM_NOT_OWNED)}static CALL_LEAVE_NOT_ALLOWED(L=""){return new E(L,_.CALL_LEAVE_NOT_ALLOWED,E.CALL_LEAVE_NOT_ALLOWED)}static CALL_RECORDING_ALREADY_ACTIVE(L=""){return new E(L,_.CALL_RECORDING_ALREADY_ACTIVE,E.CALL_RECORDING_ALREADY_ACTIVE)}static CALL_NOT_RECORDING(L=""){return new E(L,_.CALL_NOT_RECORDING,E.CALL_NOT_RECORDING)}static CALL_DISABLED(L=""){return new E(L,_.CALL_DISABLED,E.CALL_DISABLED)}static INVALID_BUILD_TYPE(L=""){return new E(L,_.INVALID_BUILD_TYPE,E.INVALID_BUILD_TYPE)}static DISPATCH_ERROR(L=""){return new E(L,_.DISPATCH_ERROR,E.DISPATCH_ERROR)}static INVALID_TARGET_DEVICE(L=""){return new E(L,_.INVALID_TARGET_DEVICE,E.INVALID_TARGET_DEVICE)}}module.exports={CONTRACT_ERRORS:_,KeetContractError:E};
1const _={CORRUPT:"KEET_CONTRACT_CORRUPT",ABORT:"KEET_CONTRACT_ABORT",BUNDLE_NOT_AVAILABLE:"BUNDLE_NOT_AVAILABLE",ADMINS_ONLY:"ADMINS_ONLY",MODERATORS_ONLY:"MODERATORS_ONLY",SELF_ONLY:"SELF_ONLY",MODERATORS_OR_SELF_ONLY:"MODERATORS_OR_SELF_ONLY",INVALID_ROOM_TYPE:"INVALID_ROOM_TYPE",WRITER_IS_MUTED:"WRITER_IS_MUTED",PARENT_MSG_INVALID:"PARENT_MSG_INVALID",REPLYTO_MSG_INVALID:"REPLYTO_MSG_INVALID",TARGET_MSG_INVALID:"TARGET_MSG_INVALID",TARGET_MSG_IS_DELETED:"TARGET_MSG_IS_DELETED",TARGET_MSG_IS_OWN:"TARGET_MSG_IS_OWN",CHAT_LABEL_EXISTS:"CHAT_LABEL_EXISTS",CHAT_LABEL_NOT_FOUND:"CHAT_LABEL_NOT_FOUND",CHAT_FLAG_LIMIT_EXCEEDED:"CHAT_FLAG_LIMIT_EXCEEDED",FILE_REFERENCE_INVALID:"FILE_REFERENCE_INVALID",FILE_RECORD_INVALID:"FILE_RECORD_INVALID",INLINED_FILESIZE_TOO_LARGE:"INLINED_FILESIZE_TOO_LARGE",FILE_ATTACHMENTS_DISABLED:"FILE_ATTACHMENTS_DISABLED",LINK_REFERENCE_INVALID:"LINK_REFERENCE_INVALID",LINKS_DISABLED:"LINKS_DISABLED",INACTIVE_MEMBER:"INACTIVE_MEMBER",MUTED_MEMBER:"MUTED_MEMBER",TARGET_MEMBER_NOT_FOUND:"TARGET_MEMBER_NOT_FOUND",INVALID_MEMBER_STATUS:"INVALID_MEMBER_STATUS",CONTACT_NOT_FOUND:"CONTACT_NOT_FOUND",NO_DUPLICATE_CALL_EVENTS:"NO_DUPLICATE_CALL_EVENTS",GENESIS_NOT_FIRST:"GENESIS_NOT_FIRST",INVALID_SYSTEM_SETTING:"INVALID_SYSTEM_SETTING",ACTIVE_CALL_EXISTS:"ACTIVE_CALL_EXISTS",CALL_KEY_EXISTS:"CALL_KEY_EXISTS",CALL_NOT_FOUND:"CALL_NOT_FOUND",CALL_ENDED:"CALL_ENDED",CALL_DEVICE_EXISTS:"CALL_DEVICE_EXISTS",CALL_DEVICE_NOT_FOUND:"CALL_DEVICE_NOT_FOUND",CALL_MEMBER_NOT_FOUND:"CALL_MEMBER_NOT_FOUND",CALL_STREAM_EXISTS:"CALL_STREAM_EXISTS",CALL_STREAM_NOT_FOUND:"CALL_STREAM_NOT_FOUND",CALL_MEDIA_STREAM_ID_EXISTS:"CALL_MEDIA_STREAM_ID_EXISTS",CALL_STREAM_NOT_OWNED:"CALL_STREAM_NOT_OWNED",CALL_LEAVE_NOT_ALLOWED:"CALL_LEAVE_NOT_ALLOWED",CALL_RECORDING_ALREADY_ACTIVE:"CALL_RECORDING_ALREADY_ACTIVE",CALL_NOT_RECORDING:"CALL_NOT_RECORDING",CALL_DISABLED:"CALL_DISABLED",INVALID_BUILD_TYPE:"INVALID_BUILD_TYPE",DISPATCH_ERROR:"DISPATCH_ERROR",INVALID_TARGET_DEVICE:"INVALID_TARGET_DEVICE"};class E extends Error{constructor(_,L,A=E){super(_?`${L}: ${_}`:L),this.code=L,this.isContractError=!0,this.abi=null,this.roomKey=null,Error.captureStackTrace&&Error.captureStackTrace(this,A)}static isContractError(_){return!!_.isContractError||"KEET_CONTRACT_ABORT"===_.code}static CORRUPT(L=""){return new E(L,_.CORRUPT,E.CORRUPT)}static ABORT(L=""){return new E(L,_.ABORT,E.ABORT)}static BUNDLE_NOT_AVAILABLE(L,A=null){const T=new E(A?`ABI ${L}: ${A.message}`:"ABI "+L,_.BUNDLE_NOT_AVAILABLE,E.BUNDLE_NOT_AVAILABLE);return T.abi=L,T.cause=A,T}static ADMINS_ONLY(L=""){return new E(L,_.ADMINS_ONLY,E.ADMINS_ONLY)}static MODERATORS_ONLY(L=""){return new E(L,_.MODERATORS_ONLY,E.MODERATORS_ONLY)}static SELF_ONLY(L=""){return new E(L,_.SELF_ONLY,E.SELF_ONLY)}static MODERATORS_OR_SELF_ONLY(L=""){return new E(L,_.MODERATORS_OR_SELF_ONLY,E.MODERATORS_OR_SELF_ONLY)}static INVALID_ROOM_TYPE(L=""){return new E(L,_.INVALID_ROOM_TYPE,E.INVALID_ROOM_TYPE)}static WRITER_IS_MUTED(L=""){return new E(L,_.WRITER_IS_MUTED,E.WRITER_IS_MUTED)}static PARENT_MSG_INVALID(L=""){return new E(L,_.PARENT_MSG_INVALID,E.PARENT_MSG_INVALID)}static REPLYTO_MSG_INVALID(L=""){return new E(L,_.REPLYTO_MSG_INVALID,E.REPLYTO_MSG_INVALID)}static TARGET_MSG_INVALID(L=""){return new E(L,_.TARGET_MSG_INVALID,E.TARGET_MSG_INVALID)}static TARGET_MSG_IS_DELETED(L=""){return new E(L,_.TARGET_MSG_IS_DELETED,E.TARGET_MSG_IS_DELETED)}static TARGET_MSG_IS_OWN(L=""){return new E(L,_.TARGET_MSG_IS_OWN,E.TARGET_MSG_IS_OWN)}static CHAT_LABEL_EXISTS(L=""){return new E(L,_.CHAT_LABEL_EXISTS,E.CHAT_LABEL_EXISTS)}static CHAT_LABEL_NOT_FOUND(L=""){return new E(L,_.CHAT_LABEL_NOT_FOUND,E.CHAT_LABEL_NOT_FOUND)}static CHAT_FLAG_LIMIT_EXCEEDED(L=""){return new E(L,_.CHAT_FLAG_LIMIT_EXCEEDED,E.CHAT_FLAG_LIMIT_EXCEEDED)}static FILE_REFERENCE_INVALID(L=""){return new E(L,_.FILE_REFERENCE_INVALID,E.FILE_REFERENCE_INVALID)}static FILE_RECORD_INVALID(L=""){return new E(L,_.FILE_RECORD_INVALID,E.FILE_RECORD_INVALID)}static INLINED_FILESIZE_TOO_LARGE(L=""){return new E(L,_.INLINED_FILESIZE_TOO_LARGE,E.INLINED_FILESIZE_TOO_LARGE)}static FILE_ATTACHMENTS_DISABLED(L=""){return new E(L,_.FILE_ATTACHMENTS_DISABLED,E.FILE_ATTACHMENTS_DISABLED)}static LINK_REFERENCE_INVALID(L=""){return new E(L,_.LINK_REFERENCE_INVALID,E.LINK_REFERENCE_INVALID)}static LINKS_DISABLED(L=""){return new E(L,_.LINKS_DISABLED,E.LINKS_DISABLED)}static INACTIVE_MEMBER(L=""){return new E(L,_.INACTIVE_MEMBER,E.INACTIVE_MEMBER)}static MUTED_MEMBER(L=""){return new E(L,_.MUTED_MEMBER,E.MUTED_MEMBER)}static TARGET_MEMBER_NOT_FOUND(L=""){return new E(L,_.TARGET_MEMBER_NOT_FOUND,E.TARGET_MEMBER_NOT_FOUND)}static INVALID_MEMBER_STATUS(L=""){return new E(L,_.INVALID_MEMBER_STATUS,E.INVALID_MEMBER_STATUS)}static CONTACT_NOT_FOUND(L=""){return new E(L,_.CONTACT_NOT_FOUND,E.CONTACT_NOT_FOUND)}static NO_DUPLICATE_CALL_EVENTS(L=""){return new E(L,_.NO_DUPLICATE_CALL_EVENTS,E.NO_DUPLICATE_CALL_EVENTS)}static GENESIS_NOT_FIRST(L=""){return new E(L,_.GENESIS_NOT_FIRST,E.GENESIS_NOT_FIRST)}static INVALID_SYSTEM_SETTING(L=""){return new E(L,_.INVALID_SYSTEM_SETTING,E.INVALID_SYSTEM_SETTING)}static ACTIVE_CALL_EXISTS(L=""){return new E(L,_.ACTIVE_CALL_EXISTS,E.ACTIVE_CALL_EXISTS)}static CALL_KEY_EXISTS(L=""){return new E(L,_.CALL_KEY_EXISTS,E.CALL_KEY_EXISTS)}static CALL_NOT_FOUND(L=""){return new E(L,_.CALL_NOT_FOUND,E.CALL_NOT_FOUND)}static CALL_ENDED(L=""){return new E(L,_.CALL_ENDED,E.CALL_ENDED)}static CALL_DEVICE_EXISTS(L=""){return new E(L,_.CALL_DEVICE_EXISTS,E.CALL_DEVICE_EXISTS)}static CALL_DEVICE_NOT_FOUND(L=""){return new E(L,_.CALL_DEVICE_NOT_FOUND,E.CALL_DEVICE_NOT_FOUND)}static CALL_MEMBER_NOT_FOUND(L=""){return new E(L,_.CALL_MEMBER_NOT_FOUND,E.CALL_MEMBER_NOT_FOUND)}static CALL_STREAM_EXISTS(L=""){return new E(L,_.CALL_STREAM_EXISTS,E.CALL_STREAM_EXISTS)}static CALL_STREAM_NOT_FOUND(L=""){return new E(L,_.CALL_STREAM_NOT_FOUND,E.CALL_STREAM_NOT_FOUND)}static CALL_MEDIA_STREAM_ID_EXISTS(L=""){return new E(L,_.CALL_MEDIA_STREAM_ID_EXISTS,E.CALL_MEDIA_STREAM_ID_EXISTS)}static CALL_STREAM_NOT_OWNED(L=""){return new E(L,_.CALL_STREAM_NOT_OWNED,E.CALL_STREAM_NOT_OWNED)}static CALL_LEAVE_NOT_ALLOWED(L=""){return new E(L,_.CALL_LEAVE_NOT_ALLOWED,E.CALL_LEAVE_NOT_ALLOWED)}static CALL_RECORDING_ALREADY_ACTIVE(L=""){return new E(L,_.CALL_RECORDING_ALREADY_ACTIVE,E.CALL_RECORDING_ALREADY_ACTIVE)}static CALL_NOT_RECORDING(L=""){return new E(L,_.CALL_NOT_RECORDING,E.CALL_NOT_RECORDING)}static CALL_DISABLED(L=""){return new E(L,_.CALL_DISABLED,E.CALL_DISABLED)}static INVALID_BUILD_TYPE(L=""){return new E(L,_.INVALID_BUILD_TYPE,E.INVALID_BUILD_TYPE)}static DISPATCH_ERROR(L=""){return new E(L,_.DISPATCH_ERROR,E.DISPATCH_ERROR)}static INVALID_TARGET_DEVICE(L=""){return new E(L,_.INVALID_TARGET_DEVICE,E.INVALID_TARGET_DEVICE)}}module.exports={CONTRACT_ERRORS:_,KeetContractError:E};
@holepunchto/keet-core/lib/core/contract/internal.js +1 -1
……@@ -1 +1 @@
1const e=require("b4a"),t=require("./registration"),{KeetContractError:i}=require("./errors"),{isMemberActive:s,getMemberForDeviceKey:a}=require("./query"),{trackActivity:r}=require("./hooks"),{addDevice:n,addMember:o}=require("./members"),{contract:{hyperschema:{getEnum:d}}}=require("../../../schema/spec"),c=d("@keet/room-type"),m=d("@keet/build-type"),l=["roomType","isExperimental","isJoiningDisabled","isAppendingDisabled","isCallingDisabled","isMembershipEventsDisabled","isAttachmentsDisabled","isLinksDisabled","isRoomInviteHidden"];async function u({header:t,digest:s,config:r,capabilities:d,identity:m,bootstrapDevice:l,initialMembers:u},b){const{db:y,writer:g,hostcalls:w,dryRun:p}=b;if(!w.genesis&&!p)throw i.GENESIS_NOT_FIRST();if(await y.insert("@keet/threads",{id:0,count:0,parent:null,stats:{devices:{total:0,active:0},members:{total:0,active:0,pending:0},chat:{clock:0,pinned:0,threads:0,timestamp:0},files:{clock:0},calls:{streams:0}}}),s.settings.roomType===c.Broadcast&&(s.settings.isCallingDisabled=!0),await y.insert("@keet/system-digest",s),d&&await y.insert("@keet/room-capabilities",d),m&&await y.insert("@keet-private-id/identity",m),r&&await y.insert("@keet/room-config",r),u)for(const i of u){const s=e.equals(i.attestation.memberKey,l.attestation.memberKey)?{isAdmin:!0,isModerator:!0}:{isAdmin:!1,isModerator:!0};await o(t,i.profile,i.attestation,s,b)}await n(t,g.key,l.profile,l.attestation,{isActive:!0,isIndexing:!0,isGenesis:!0},b);const k=await a(y,g.key);if(!l||!k)throw i.ABORT()}async function b({version:e},{db:t,writer:r,abi:n,hostcalls:o}){const[d,c]=await Promise.all([a(t,r.key),t.get("@keet/system-digest")]);if(9!==e||s(d)&&d.status.isModerator){if(!s(d)||!d.status.isModerator)throw i.ABORT();c.abi.version>=e||(e>(c.settings.isExperimental?n.max:n.production)&&o.interrupt({unsupportedABI:e,digest:c}),c.abi.version,c.abi.version=e,await Promise.resolve(),await t.insert("@keet/system-digest",c))}}async function y({key:e,settings:t},{db:r,writer:n}){const[o,d]=await Promise.all([a(r,n.key),r.get("@keet/system-digest")]);if(!s(o))throw i.INACTIVE_MEMBER();if(!o.status.isModerator)throw i.MODERATORS_ONLY();if(0===e||e>l.length)throw i.INVALID_SYSTEM_SETTING();const c=d?.settings,m=l[e-1],u={...c,[m]:t[m]};await r.insert("@keet/system-digest",{...d,settings:u})}async function g({header:e,head:t,legacyViewHead:i,dbViewHead:r,blobsViewHead:n},{db:o,writer:d}){const[c,m]=await Promise.all([a(o,d.key),o.get("@keet/autobee-migration")]);if(s(c)&&c.status.isAdmin)return m||await o.insert("@keet/autobee-migration",{autobeeMigrationHead:t,legacyViewHead:i,dbViewHead:r,blobsViewHead:n,createdAt:e.timestamp}),{writer:d,writerMember:c}}async function w({peer:e},{db:t,writer:i}){const r=await a(t,i.key);s(r)&&r.status.isModerator&&await t.insert("@keet/blind-peers",e)}async function p({key:e},{db:t,writer:i}){const r=await a(t,i.key);s(r)&&r.status.isModerator&&await t.delete("@keet/blind-peers",{key:e})}async function k({from:e,to:t,buildType:i},{db:r,writer:n}){const o=await a(r,n.key);s(o)&&o.status.isModerator&&(e<14&&t>=14&&(await async function(e){if(!await e.get("@keet-private-id/identity"))return;const t=[];for(const{memberKey:i,roomKey:s}of await e.find("@keet-private-id/contacts").toArray()){if(!s||!i)continue;const a=await e.get("@keet-private-id/rooms",{roomKey:s});a&&(a.contact=i,t.push(e.insert("@keet-private-id/rooms",a)))}await Promise.all(t)}(r),await async function(e){if(!await e.get("@keet-private-id/identity"))return;const t={isPending:!1,isAccepted:!1,isRejected:!1,isDiscarded:!1,isSeen:!1},i=[];for(const s of await e.find("@keet-private-id/contact-requests").toArray()){const{isSeen:a,isAccepted:r,isRejected:n,isDiscarded:o}=s.status;s.status.isAccepted&&(s.status={...t,isAccepted:r,isSeen:a}),s.status.isRejected&&(s.status={...t,isRejected:n,isSeen:a}),s.status.isDiscarded&&(s.status={...t,isDiscarded:o,isSeen:a}),i.push(e.insert("@keet-private-id/contact-requests-v2",s))}await Promise.all(i)}(r)),e<20&&t>=20&&await async function(e){const[t,i,s]=await Promise.all([e.get("@keet-private-id/identity"),e.get("@keet/threads",{id:0}),e.find("@keet/pinned-chat-messages").toArray()]);!t&&i&&(i.stats.chat.pinned=s.length,await e.insert("@keet/threads",i))}(r),e<24&&t>=24&&await async function(e){if((await e.get("@keet/system-digest")).settings.roomType===c.DirectMessage)for await(const t of e.find("@keet/members"))t.status.isModerator||(t.status.isModerator=!0,await e.insert("@keet/members",t))}(r),e<25&&t>=25&&await async function(e,t){const i=await e.get("@keet/system-digest");m[i.settings.buildType]||m[t]&&(i.settings.buildType=m[t],await e.insert("@keet/system-digest",i))}(r,i))}module.exports={[t]:function(e){e.add("@keet/genesis",u),e.add("@keet/upgrade",b),e.add("@keet/add-blind-peer",w),e.add("@keet/remove-blind-peer",p),e.add("@keet/autobee-migration",r(g)),e.add("@keet/update-system-settings",y),e.add("@keet/migrate-abi",k)},Settings:{RoomType:1,IsExperimental:2,IsJoiningDisabled:3,IsAppendingDisabled:4,IsCallingDisabled:5,IsMembershipEventsDisabled:6,IsAttachmentsDisabled:7,IsLinksDisabled:8,IsRoomInviteHidden:9}};
1const e=require("b4a"),t=require("./registration"),{KeetContractError:i}=require("./errors"),{isMemberActive:s,getMemberForDeviceKey:a}=require("./query"),{trackActivity:r}=require("./hooks"),{addDevice:n,addMember:o}=require("./members"),d=require("./roles"),{contract:{hyperschema:{getEnum:c}}}=require("../../../schema/spec"),m=c("@keet/room-type"),u=c("@keet/build-type"),l=["roomType","isExperimental","isJoiningDisabled","isAppendingDisabled","isCallingDisabled","isMembershipEventsDisabled","isAttachmentsDisabled","isLinksDisabled","isRoomInviteHidden"];async function g({header:t,digest:s,config:r,capabilities:d,identity:c,bootstrapDevice:u,initialMembers:l},g){const{db:y,writer:w,hostcalls:b,dryRun:k}=g;if(!b.genesis&&!k)throw i.GENESIS_NOT_FIRST();await y.insert("@keet/threads",{id:0,count:0,parent:null,stats:{devices:{total:0,active:0},members:{total:0,active:0,pending:0},chat:{clock:0,pinned:0,threads:0,timestamp:0},files:{clock:0},calls:{streams:0}}});const p=s.settings.roomType===m.DirectMessage;if(s.settings.roomType===m.Broadcast&&(s.settings.isCallingDisabled=!0),await y.insert("@keet/system-digest",s),d&&await y.insert("@keet/room-capabilities",d),c&&await y.insert("@keet-private-id/identity",c),r&&await y.insert("@keet/room-config",r),l)for(const i of l){const s=e.equals(i.attestation.memberKey,u.attestation.memberKey)||p?{isAdmin:!0,isModerator:!0}:{isAdmin:!1,isModerator:!0};await o(t,i.profile,i.attestation,s,g)}await n(t,w.key,u.profile,u.attestation,{isActive:!0,isIndexing:!0,isGenesis:!0},g);const f=await a(y,w.key);if(!u||!f)throw i.ABORT()}async function y({version:e},{db:t,writer:r,abi:n,hostcalls:o}){const[d,c]=await Promise.all([a(t,r.key),t.get("@keet/system-digest")]);if(9!==e||s(d)&&d.status.isModerator){if(!s(d)||!d.status.isModerator)throw i.ABORT();c.abi.version>=e||(e>(c.settings.isExperimental?n.max:n.production)&&o.interrupt({unsupportedABI:e,digest:c}),c.abi.version,c.abi.version=e,await Promise.resolve(),await t.insert("@keet/system-digest",c))}}async function w({key:e,settings:t},{db:r,writer:n}){const[o,d]=await Promise.all([a(r,n.key),r.get("@keet/system-digest")]);if(!s(o))throw i.INACTIVE_MEMBER();if(!o.status.isModerator)throw i.MODERATORS_ONLY();if(0===e||e>l.length)throw i.INVALID_SYSTEM_SETTING();const c=d?.settings,m=l[e-1],u={...c,[m]:t[m]};await r.insert("@keet/system-digest",{...d,settings:u})}async function b({header:e,head:t,legacyViewHead:i,dbViewHead:r,blobsViewHead:n},{db:o,writer:d}){const[c,m]=await Promise.all([a(o,d.key),o.get("@keet/autobee-migration")]);if(s(c)&&c.status.isAdmin)return m||await o.insert("@keet/autobee-migration",{autobeeMigrationHead:t,legacyViewHead:i,dbViewHead:r,blobsViewHead:n,createdAt:e.timestamp}),{writer:d,writerMember:c}}async function k({peer:e},{db:t,writer:i}){const r=await a(t,i.key);s(r)&&r.status.isModerator&&await t.insert("@keet/blind-peers",e)}async function p({key:e},{db:t,writer:i}){const r=await a(t,i.key);s(r)&&r.status.isModerator&&await t.delete("@keet/blind-peers",{key:e})}async function f({from:e,to:t,buildType:i},{db:r,writer:n,hostcalls:o}){const c=await a(r,n.key);s(c)&&c.status.isModerator&&(e<14&&t>=14&&(await async function(e){if(!await e.get("@keet-private-id/identity"))return;const t=[];for(const{memberKey:i,roomKey:s}of await e.find("@keet-private-id/contacts").toArray()){if(!s||!i)continue;const a=await e.get("@keet-private-id/rooms",{roomKey:s});a&&(a.contact=i,t.push(e.insert("@keet-private-id/rooms",a)))}await Promise.all(t)}(r),await async function(e){if(!await e.get("@keet-private-id/identity"))return;const t={isPending:!1,isAccepted:!1,isRejected:!1,isDiscarded:!1,isSeen:!1},i=[];for(const s of await e.find("@keet-private-id/contact-requests").toArray()){const{isSeen:a,isAccepted:r,isRejected:n,isDiscarded:o}=s.status;s.status.isAccepted&&(s.status={...t,isAccepted:r,isSeen:a}),s.status.isRejected&&(s.status={...t,isRejected:n,isSeen:a}),s.status.isDiscarded&&(s.status={...t,isDiscarded:o,isSeen:a}),i.push(e.insert("@keet-private-id/contact-requests-v2",s))}await Promise.all(i)}(r)),e<20&&t>=20&&await async function(e){const[t,i,s]=await Promise.all([e.get("@keet-private-id/identity"),e.get("@keet/threads",{id:0}),e.find("@keet/pinned-chat-messages").toArray()]);!t&&i&&(i.stats.chat.pinned=s.length,await e.insert("@keet/threads",i))}(r),e<24&&t>=24&&await async function(e){if((await e.get("@keet/system-digest")).settings.roomType===m.DirectMessage)for await(const t of e.find("@keet/members"))t.status.isModerator||(t.status.isModerator=!0,await e.insert("@keet/members",t))}(r),e<25&&t>=25&&await async function(e,t){const i=await e.get("@keet/system-digest");u[i.settings.buildType]||u[t]&&(i.settings.buildType=u[t],await e.insert("@keet/system-digest",i))}(r,i),e<37&&t>=37&&await async function(e,t,i){if((await e.get("@keet/system-digest")).settings.roomType!==m.DirectMessage)return;for await(const t of e.find("@keet/members"))t.status.isAdmin&&t.status.isModerator||(t.status.isAdmin=!0,t.status.isModerator=!0,await e.insert("@keet/members",t));const s=await e.get("@keet/devices",{key:t.key});s&&s.status.isActive&&!s.status.isIndexing&&(s.status.isIndexing=!0,await e.insert("@keet/devices",s),await i.addWriter(t.key,d.ADMIN))}(r,n,o))}module.exports={[t]:function(e){e.add("@keet/genesis",g),e.add("@keet/upgrade",y),e.add("@keet/add-blind-peer",k),e.add("@keet/remove-blind-peer",p),e.add("@keet/autobee-migration",r(b)),e.add("@keet/update-system-settings",w),e.add("@keet/migrate-abi",f)},Settings:{RoomType:1,IsExperimental:2,IsJoiningDisabled:3,IsAppendingDisabled:4,IsCallingDisabled:5,IsMembershipEventsDisabled:6,IsAttachmentsDisabled:7,IsLinksDisabled:8,IsRoomInviteHidden:9}};
@holepunchto/keet-core/lib/core/contract/members/index.js +1 -1
……@@ -1 +1 @@
1const e=require("autobee"),t=require("b4a"),{contract:{hyperschema:{getEnum:i,encode:a},hyperdispatch:{encode:r}}}=require("../../../../schema/spec"),{createDeviceResponse:s,decryptDeviceRequest:n,verifyAttestation:o,verifyInvitationDeviceRequest:d,generateMailboxKeyPair:m}=require("../../invitations"),c=i("@keet/room-type"),{deviceStats:y,memberStats:w}=require("../stats"),{isMemberActive:k,getMemberForDeviceKey:l}=require("../query"),{addEvent:u}=require("../chat"),{updateAvatar:b}=require("../avatars"),{KeetContractError:v}=require("../errors"),f=require("../registration"),{isValidBuildType:A}=require("../helpers"),{trackActivity:p}=require("../hooks"),h=require("../roles"),g=["isMuted","isBanned","isShadowBanned"];async function R(e,t,i,a,r,{db:s,writer:n,hostcalls:d}){const[m,k,l,b,f]=await Promise.all([s.get("@keet/devices",{key:t}),s.get("@keet/members",{key:a.memberKey}),s.get("@keet/member-proofs",{key:a.memberKey}),s.get("@keet/system-digest"),s.get("@keet/threads",{id:0})]);if(!k||!l)throw v.ABORT();if(m)return{added:!1,device:m};const A={...k,status:{...k.status}},p=k.status.isPending,g=o(a,t,l.latestReceipt);l.latestReceipt=g;const R={isActive:!0,isIndexing:!!r?.isIndexing};k.status.isActive=!0,k.status.isPending=!1,p&&!k.status.isModerator&&r?.isModerator&&(k.status.isModerator=!0),R.isIndexing&&!k.status.isAdmin&&(k.status.isAdmin=!0);const M={key:t,memberKey:k.key,status:R,profile:i};if(await s.insert("@keet/members",k),await w(s,f,k,A),await s.insert("@keet/devices",M),await y(s,f,M,null),await s.insert("@keet/member-proofs",l),r?.isGenesis||await d.addWriter(t,R.isIndexing?h.ADMIN:h.WRITER),!p||b.settings.roomType===c.Broadcast)return{added:!0,device:M};if(b.abi.version>=11&&b.settings.isMembershipEventsDisabled)return{added:!0,device:M};const T={memberJoined:{memberKey:k.key}};return await u(s,n,T,e.timestamp),{added:!0,device:M}}async function M(e,t,i,r,{db:s,writer:n}){const[d,m,c]=await Promise.all([s.get("@keet/members",{key:i.memberKey}),s.get("@keet/member-proofs",{key:i.memberKey}),s.get("@keet/threads",{id:0})]);if(d)throw v.ABORT();const y=a("@keet/member-profile",t),k=o(i,y,m?.latestReceipt);let l=m;l?(l.latestReceipt=k,l.profileAttestation=i.proof):l={key:i.memberKey,latestReceipt:k,profileAttestation:i.proof},t.avatar?t.avatar=await b(s,d?.profile.avatar,t.avatar):t.avatar=null;const u={isAdmin:!!r.isAdmin,isModerator:!!r.isModerator,isPending:!0,isActive:!0,isMuted:!1,isBanned:!1,isShadowBanned:!1},f={key:i.memberKey,devices:[],status:u,profile:t};return await s.insert("@keet/members",f),await w(s,c,f),await s.insert("@keet/member-proofs",l),f}async function T(e,t,i,{db:r}){const[s,n]=await Promise.all([r.get("@keet/members",{key:i.memberKey}),r.get("@keet/member-proofs",{key:i.memberKey})]);if(!s)throw v.ABORT();const d=a("@keet/member-profile",t),m=o(i,d,n?.latestReceipt);let c=n;c?(c.latestReceipt=m,c.profileAttestation=i.proof):c={key:i.memberKey,latestReceipt:m,profileAttestation:i.proof},s.profile.timestamp>=t.timestamp||(s.profile=t,t.avatar?s.profile.avatar=await b(r,s.profile.avatar,t.avatar):s.profile.avatar=null,await r.insert("@keet/members",s),await r.insert("@keet/member-proofs",c))}async function O(t,i,a,n,o,d){const{db:m,trace:c,hostcalls:k,dryRun:l}=d,u=await m.get("@keet/room-capabilities"),b=k.discoveryKey,f=k.key,A=n.metadata,p={isAdmin:A.canAdmin,isModerator:A.canModerate||A.canAdmin},g={isIndexing:A.canAdmin,isModerator:A.canModerate};let O=null;if(o)O=await async function(e,t,i){const{db:a,hostcalls:r}=i,[s,n]=await Promise.all([a.get("@keet-private-id/identity"),a.get("@keet/threads",{id:0})]),o=await a.get("@keet/members",{key:s.publicKey}),d={...o,status:{...o.status}},m={key:e,memberKey:s.publicKey,profile:t,status:{isActive:!0,isIndexing:!0}};return o.status.isPending=!1,await r.addWriter(e,h.ADMIN),await a.insert("@keet/members",o),await w(a,n,o,d),await a.insert("@keet/devices",m),await y(a,n,m,null),{added:!0,device:m}}(i,a.device.profile,d),await m.insert("@keet-private-id/device-identities",{deviceKey:i,privateProfileIdentity:o.privateProfileIdentity,deviceProof:o.deviceProof});else{const e=await m.get("@keet/members",{key:a.device.attestation.memberKey});if(e){if(e.status.isRemoved)throw v.ABORT();await T(0,a.member.profile,a.member.attestation,d)}else await M(0,a.member.profile,a.member.attestation,p,d);O=await R(t,i,a.device.profile,a.device.attestation,g,d)}const{device:K,added:B}=O,I=a.member.profile.mailbox,q=u.seed,{blindResponse:E}=s(I,q,n),P=r("@keet-private-id/resolve-pending-invitation-v2",{header:{timestamp:0},blindResponse:E}),D=e.encodeValue(P,{optimistic:!0,encrypted:!0,timestamp:0,links:a.link?[a.link]:[]});if(B&&(n.metadata.canAdmin=!1,n.metadata.canModerate=!1,K.invitation={id:n.id,response:D},await m.insert("@keet/devices",K),await m.insert("@keet/invitations",n)),c&&!l){const e={roomKey:f,discoveryKey:b,request:a,response:D,invitation:n};await c({type:"@keet/add-device",value:e})}}async function K({header:e,deviceKey:t,identity:i},a){const{db:r,writer:s}=a,[n,o]=await Promise.all([l(r,s.key),r.get("@keet/join-requests",{deviceKey:t})]);if(!k(n)||!o)throw v.ABORT();const{id:d,request:m}=o,c=await r.get("@keet/invitations",{id:d});if(!c)throw v.ABORT();return await O(e,t,m,c,i,a),await r.delete("@keet/join-requests",{deviceKey:t}),{writer:s,writerMember:n}}async function B({header:e,deviceKey:t},i){const{db:a,writer:r}=i,[s,n]=await Promise.all([l(a,r.key),a.get("@keet/join-requests",{deviceKey:t})]);if(!k(s)||!n)throw v.ABORT();return await a.delete("@keet/join-requests",{deviceKey:t}),{writer:r,writerMember:s}}async function I({invitation:e},{db:t,writer:i,hostcalls:a}){const[r,s,n]=await Promise.all([l(t,i.key),t.get("@keet/invitations",{id:e.id}),t.get("@keet/system-digest")]);if(!k(r))throw v.ABORT();if(r.status.isMuted)return;const o=e.metadata;if(s||n.settings.roomType===c.DirectMessage)throw v.ABORT();if(o.buildType=n.settings.buildType,n.settings.isRoomInviteHidden&&!r.status.isModerator)throw v.MODERATORS_ONLY();return o.canModerate&&!r.status.isModerator&&(o.canModerate=!1),o.canAdmin&&!r.status.isAdmin&&(o.canAdmin=!1),e.isActive=!0,e.anchor=await a.createAnchor(i.key,i.seq+1),await t.insert("@keet/invitations",e),{writer:i,writerMember:r}}async function q({id:e},{db:t,writer:i}){const[a,r]=await Promise.all([l(t,i.key),t.get("@keet/invitations",{id:e})]);if(!k(a)||!a.status.isModerator||!r)throw v.ABORT();return r.isActive=!1,await t.insert("@keet/invitations",r),{writer:i,writerMember:a}}async function E({deviceKey:e,fromDeviceKey:i},{db:a,writer:r,hostcalls:s}){const[n,o,d]=await Promise.all([l(a,r.key),l(a,e),l(a,i)]);if(!k(n))throw v.ABORT();if(!t.equals(n.key,o.key))throw v.ABORT();if(!t.equals(n.key,d.key))throw v.ABORT();const[m,c]=await Promise.all([a.get("@keet/devices",{key:i}),a.get("@keet/devices",{key:e})]);if(!m||!c)throw v.ABORT();if(!m.status.isActive)throw v.ABORT();if(!c.status.isActive)throw v.ABORT();if(!m.status.isIndexing)throw v.ABORT();if(c.status.isIndexing)throw v.ABORT();if(t.equals(m.key,c.key))throw v.ABORT();return await s.addWriter(c.key,h.ADMIN),await s.addWriter(m.key,h.WRITER),c.status.isIndexing=!0,m.status.isIndexing=!1,await a.insert("@keet/devices",m),await a.insert("@keet/devices",c),{writer:r,writerMember:n}}async function P(e,{db:t,writer:i,hostcalls:a}){const[r,s]=await Promise.all([t.get("@keet/devices",{key:i.key}),l(t,i.key)]);if(!r.status.isActive||!k(s)||!s.status.canAdmin)throw v.ABORT();return await a.addWriter(i.key,h.ADMIN),r.status.isIndexing=!0,await t.insert("@keet/devices",r),{writer:i,writerMember:s}}async function D(e,{db:t,writer:i,hostcalls:a}){const[r,s]=await Promise.all([t.get("@keet/devices",{key:i.key}),l(t,i.key)]);if(!r.status.isActive||!k(s)||!s.status.canAdmin)throw v.ABORT();return await a.addWriter(i.key,h.WRITER),r.status.isIndexing=!1,await t.insert("@keet/devices",r),{writer:i,writerMember:s}}async function _({header:e,blindRequest:i},a){const{db:r}=a,s=await r.get("@keet/room-capabilities");if(!s)throw v.ABORT();let o=null;try{const e=m(a.hostcalls.key,s.seed);o=n(e,i)}catch(e){throw v.ABORT()}if(!o)throw v.ABORT();const{withInvitation:y,withMemberProof:w}=o;return y?async function(e,i,a){const{db:r,hostcalls:s,writer:n}=a;let o=null;try{o=d(e)}catch(e){throw v.ABORT()}if(!o)throw v.ABORT();const{id:m,request:c}=o;if(!t.equals(c.deviceKey,n.key))throw v.ABORT();const[y,w,k]=await Promise.all([r.get("@keet/join-requests",{deviceKey:n.key}),r.get("@keet/invitations",{id:m}),r.get("@keet-private-id/identity")]);if(!w||y)throw v.ABORT();const l=w.metadata.buildType,u=c.device.profile.buildType;if(!A(u,l))throw v.INVALID_BUILD_TYPE();await s.ackWriter(n.key),w.requiresConfirmation||k?await r.insert("@keet/join-requests",{deviceKey:n.key,id:m,request:c}):await O(i,n.key,c,w,null,a)}(y,e,a):w?async function({device:e,member:t},i,a){const{db:r,hostcalls:s,writer:n}=a,[o,d,m,y]=await Promise.all([r.get("@keet/members",{key:e.attestation.memberKey}),r.get("@keet/member-proofs",{key:e.attestation.memberKey}),r.get("@keet/system-digest"),r.get("@keet-private-id/identity")]);if(!o||!d)throw v.ABORT();const w=m.settings.roomType===c.DirectMessage;if(m.abi.version>=12&&!o.status.isActive&&!w)throw v.ABORT();const k={isActive:!0,isIndexing:!!y};await R(i,n.key,e.profile,e.attestation,k,a),await s.ackWriter(n.key),t&&await T(0,t.profile,t.attestation,a)}(w,e,a):void 0}async function N({header:e,member:{profile:t,attestation:i}},a){const{db:r,writer:s}=a;return await T(0,t,i,a),{writer:s,writerMember:await l(r,s.key)}}async function x({key:e,profile:i},{db:a,writer:r}){const[s,n]=await Promise.all([l(a,r.key),a.get("@keet/devices",{key:e||r.key})]);if(!n||!n.status.isActive||!k(s))throw v.ABORT();if(!t.equals(n.memberKey,s.key))throw v.INVALID_TARGET_DEVICE();return t.equals(n.key,r.key)?n.profile=i:n.profile={...n.profile,name:i.name},await a.insert("@keet/devices",n),{writer:r,writerMember:s}}async function W({key:e},{db:i,writer:a,hostcalls:r}){const[s,n,o]=await Promise.all([l(i,a.key),i.get("@keet/devices",{key:e}),i.get("@keet/threads",{id:0})]);if(!n||!k(s)||!t.equals(n.memberKey,s.key))throw v.ABORT();const d={...n,status:{...n.status}};n.status.isActive=!1,n.status.isIndexing=!1,r.removeable(n.key)&&await r.removeWriter(n.key),await i.insert("@keet/devices",n),await y(i,o,n,d);const m=await i.get("@keet/admin-last-seen",{memberKey:n.memberKey});return m&&t.equals(m.deviceKey,e)&&await i.delete("@keet/admin-last-seen",{memberKey:n.memberKey}),{writer:a,writerMember:s}}async function S({memberKey:e,key:t,status:i},{db:a,writer:r}){const[s,n]=await Promise.all([l(a,r.key),a.get("@keet/members",{key:e})]);if(!k(s))throw v.INACTIVE_MEMBER();if(!n)throw v.TARGET_MEMBER_NOT_FOUND();if(!s.status.isModerator)throw v.MODERATORS_ONLY();if(0===t||t>g.length)throw v.INVALID_MEMBER_STATUS();const o=g[t-1];return n.status[o]=i[o],await a.insert("@keet/members",n),{writer:r,writerMember:s}}async function L({key:e,isModerator:i,isAdmin:a},{db:r,writer:s,hostcalls:n}){const[o,d,m]=await Promise.all([l(r,s.key),r.get("@keet/members",{key:e}),r.find("@keet/active-devices-by-member-key",{gte:{memberKey:e},lte:{memberKey:e}}).toArray()]);if(!k(o))throw v.INACTIVE_MEMBER();if(!d)throw v.TARGET_MEMBER_NOT_FOUND();const c=o.status.isAdmin,y=o.status.isModerator,w=d.status.isAdmin;if(!c&&(w||a))throw v.ADMINS_ONLY();if(!y)throw v.MODERATORS_ONLY();let u=!1;if(w&&!a){const i=await r.find("@keet/admins",{limit:2}).toArray();if(1===i.length&&t.equals(i[0].key,e))u=!0;else for(const e of m)n.removeable(e.key)?await n.addWriter(e.key,h.WRITER):u=!0}return u||(d.status.isAdmin=a),d.status.isModerator=i||a,await r.insert("@keet/members",d),w&&!d.status.isAdmin&&await r.delete("@keet/admin-last-seen",{memberKey:e}),{writer:s,writerMember:o}}async function j({header:e,key:i},{db:a,writer:r,hostcalls:s}){const[n,o,d,m,b]=await Promise.all([l(a,r.key),a.get("@keet/members",{key:i}),a.get("@keet/system-digest"),a.find("@keet/active-devices-by-member-key",{gte:{memberKey:i},lte:{memberKey:i}}).toArray(),a.get("@keet/threads",{id:0})]);if(!k(n))throw v.INACTIVE_MEMBER();if(!o)throw v.TARGET_MEMBER_NOT_FOUND();const f={...o,status:{...o.status}},A=t.equals(n.key,o.key),p=n.status.isModerator;if(o.status.isAdmin&&!A)throw v.SELF_ONLY();if(!A&&!p)throw v.MODERATORS_ONLY();o.status.isActive=!1,o.status.isModerator=!1,o.status.isAdmin=!1,o.status.isPending=!!A,A||(o.status.isRemoved=!0,await a.insert("@keet/tmp-removed-members",{key:o.key}));for(const e of m){const t={...e,status:{...e.status}};s.removeable(e.key)&&(await s.removeWriter(e.key,{indexer:!1}),e.status.isIndexing=!1),e.status.isActive=!1,await a.insert("@keet/devices",e),await y(a,b,e,t)}if(await a.insert("@keet/members",o),await w(a,b,o,f),f.status.isAdmin&&await a.delete("@keet/admin-last-seen",{memberKey:i}),d.settings.roomType===c.Broadcast)return{writer:r,writerMember:n};if(d.abi.version>=11&&d.settings.isMembershipEventsDisabled)return{writer:r,writerMember:n};const h=A?{memberLeft:{memberKey:o.key}}:{memberRemoved:{memberKey:o.key}};return await u(a,r,h,e.timestamp),{writer:r,writerMember:n}}module.exports={[f]:function(e){e.add("@keet/add-device",_),e.add("@keet/update-device",p(x)),e.add("@keet/remove-device",p(W)),e.add("@keet/start-indexing",p(P)),e.add("@keet/stop-indexing",p(D)),e.add("@keet/accept-join-request",p(K)),e.add("@keet/reject-join-request",p(B)),e.add("@keet/update-member",p(N)),e.add("@keet/change-member-role",p(L)),e.add("@keet/change-member-status",p(S)),e.add("@keet/remove-member",p(j)),e.add("@keet/add-invitation",p(I)),e.add("@keet/remove-invitation",p(q)),e.add("@keet/move-indexer",p(E))},MemberStatus:{IsMuted:1,IsBanned:2,IsShadowBanned:3},addDevice:R,addMember:M};
1const e=require("autobee"),t=require("b4a"),{contract:{hyperschema:{getEnum:i,encode:a},hyperdispatch:{encode:r}}}=require("../../../../schema/spec"),{createDeviceResponse:s,decryptDeviceRequest:n,verifyAttestation:o,verifyInvitationDeviceRequest:d,generateMailboxKeyPair:m}=require("../../invitations"),c=i("@keet/room-type"),{deviceStats:y,memberStats:w}=require("../stats"),{isMemberActive:k,getMemberForDeviceKey:l}=require("../query"),{addEvent:u}=require("../chat"),{updateAvatar:v}=require("../avatars"),{KeetContractError:b}=require("../errors"),f=require("../registration"),{isValidBuildType:A}=require("../helpers"),{trackActivity:h}=require("../hooks"),p=require("../roles"),g=["isMuted","isBanned","isShadowBanned"];async function R(e,t,i,a,r,{db:s,writer:n,hostcalls:d}){const[m,k,l,v,f]=await Promise.all([s.get("@keet/devices",{key:t}),s.get("@keet/members",{key:a.memberKey}),s.get("@keet/member-proofs",{key:a.memberKey}),s.get("@keet/system-digest"),s.get("@keet/threads",{id:0})]);if(!k||!l)throw b.ABORT();if(m)return{added:!1,device:m};const A={...k,status:{...k.status}},h=k.status.isPending,g=o(a,t,l.latestReceipt);l.latestReceipt=g;const R={isActive:!0,isIndexing:!!r?.isIndexing};k.status.isActive=!0,k.status.isPending=!1,h&&!k.status.isModerator&&r?.isModerator&&(k.status.isModerator=!0),R.isIndexing&&!k.status.isAdmin&&(k.status.isAdmin=!0);const M={key:t,memberKey:k.key,status:R,profile:i};if(await s.insert("@keet/members",k),await w(s,f,k,A),await s.insert("@keet/devices",M),await y(s,f,M,null),await s.insert("@keet/member-proofs",l),r?.isGenesis||await d.addWriter(t,R.isIndexing?p.ADMIN:p.WRITER),!h||v.settings.roomType===c.Broadcast)return{added:!0,device:M};if(v.abi.version>=11&&v.settings.isMembershipEventsDisabled)return{added:!0,device:M};const T={memberJoined:{memberKey:k.key}};return await u(s,n,T,e.timestamp),{added:!0,device:M}}async function M(e,t,i,r,{db:s,writer:n}){const[d,m,c]=await Promise.all([s.get("@keet/members",{key:i.memberKey}),s.get("@keet/member-proofs",{key:i.memberKey}),s.get("@keet/threads",{id:0})]);if(d)throw b.ABORT();const y=a("@keet/member-profile",t),k=o(i,y,m?.latestReceipt);let l=m;l?(l.latestReceipt=k,l.profileAttestation=i.proof):l={key:i.memberKey,latestReceipt:k,profileAttestation:i.proof},t.avatar?t.avatar=await v(s,d?.profile.avatar,t.avatar):t.avatar=null;const u={isAdmin:!!r.isAdmin,isModerator:!!r.isModerator,isPending:!0,isActive:!0,isMuted:!1,isBanned:!1,isShadowBanned:!1},f={key:i.memberKey,devices:[],status:u,profile:t};return await s.insert("@keet/members",f),await w(s,c,f),await s.insert("@keet/member-proofs",l),f}async function T(e,t,i,{db:r}){const[s,n]=await Promise.all([r.get("@keet/members",{key:i.memberKey}),r.get("@keet/member-proofs",{key:i.memberKey})]);if(!s)throw b.ABORT();const d=a("@keet/member-profile",t),m=o(i,d,n?.latestReceipt);let c=n;c?(c.latestReceipt=m,c.profileAttestation=i.proof):c={key:i.memberKey,latestReceipt:m,profileAttestation:i.proof},s.profile.timestamp>=t.timestamp||(s.profile=t,t.avatar?s.profile.avatar=await v(r,s.profile.avatar,t.avatar):s.profile.avatar=null,await r.insert("@keet/members",s),await r.insert("@keet/member-proofs",c))}async function O(t,i,a,n,o,d){const{db:m,trace:c,hostcalls:k,dryRun:l}=d,u=await m.get("@keet/room-capabilities"),v=k.discoveryKey,f=k.key,A=n.metadata,h={isAdmin:A.canAdmin,isModerator:A.canModerate||A.canAdmin},g={isIndexing:A.canAdmin,isModerator:A.canModerate};let O=null;if(o)O=await async function(e,t,i){const{db:a,hostcalls:r}=i,[s,n]=await Promise.all([a.get("@keet-private-id/identity"),a.get("@keet/threads",{id:0})]),o=await a.get("@keet/members",{key:s.publicKey}),d={...o,status:{...o.status}},m={key:e,memberKey:s.publicKey,profile:t,status:{isActive:!0,isIndexing:!0}};return o.status.isPending=!1,await r.addWriter(e,p.ADMIN),await a.insert("@keet/members",o),await w(a,n,o,d),await a.insert("@keet/devices",m),await y(a,n,m,null),{added:!0,device:m}}(i,a.device.profile,d),await m.insert("@keet-private-id/device-identities",{deviceKey:i,privateProfileIdentity:o.privateProfileIdentity,deviceProof:o.deviceProof});else{const e=await m.get("@keet/members",{key:a.device.attestation.memberKey});if(e){if(e.status.isRemoved)throw b.ABORT();await T(0,a.member.profile,a.member.attestation,d)}else await M(0,a.member.profile,a.member.attestation,h,d);O=await R(t,i,a.device.profile,a.device.attestation,g,d)}const{device:I,added:B}=O,K=a.member.profile.mailbox,q=u.seed,{blindResponse:E}=s(K,q,n),P=r("@keet-private-id/resolve-pending-invitation-v2",{header:{timestamp:0},blindResponse:E}),D=e.encodeValue(P,{optimistic:!0,encrypted:!0,timestamp:0,links:a.link?[a.link]:[]});if(B&&(n.metadata.canAdmin=!1,n.metadata.canModerate=!1,I.invitation={id:n.id,response:D},await m.insert("@keet/devices",I),await m.insert("@keet/invitations",n)),c&&!l){const e={roomKey:f,discoveryKey:v,request:a,response:D,invitation:n};await c({type:"@keet/add-device",value:e})}}async function I({header:e,deviceKey:t,identity:i},a){const{db:r,writer:s}=a,[n,o]=await Promise.all([l(r,s.key),r.get("@keet/join-requests",{deviceKey:t})]);if(!k(n)||!o)throw b.ABORT();const{id:d,request:m}=o,c=await r.get("@keet/invitations",{id:d});if(!c)throw b.ABORT();return await O(e,t,m,c,i,a),await r.delete("@keet/join-requests",{deviceKey:t}),{writer:s,writerMember:n}}async function B({header:e,deviceKey:t},i){const{db:a,writer:r}=i,[s,n]=await Promise.all([l(a,r.key),a.get("@keet/join-requests",{deviceKey:t})]);if(!k(s)||!n)throw b.ABORT();return await a.delete("@keet/join-requests",{deviceKey:t}),{writer:r,writerMember:s}}async function K({invitation:e},{db:t,writer:i,hostcalls:a}){const[r,s,n]=await Promise.all([l(t,i.key),t.get("@keet/invitations",{id:e.id}),t.get("@keet/system-digest")]);if(!k(r))throw b.ABORT();if(r.status.isMuted)return;const o=e.metadata;if(s||n.settings.roomType===c.DirectMessage)throw b.ABORT();if(o.buildType=n.settings.buildType,n.settings.isRoomInviteHidden&&!r.status.isModerator)throw b.MODERATORS_ONLY();return o.canModerate&&!r.status.isModerator&&(o.canModerate=!1),o.canAdmin&&!r.status.isAdmin&&(o.canAdmin=!1),e.isActive=!0,e.anchor=await a.createAnchor(i.key,i.seq+1),await t.insert("@keet/invitations",e),{writer:i,writerMember:r}}async function q({id:e},{db:t,writer:i}){const[a,r]=await Promise.all([l(t,i.key),t.get("@keet/invitations",{id:e})]);if(!k(a)||!a.status.isModerator||!r)throw b.ABORT();return r.isActive=!1,await t.insert("@keet/invitations",r),{writer:i,writerMember:a}}async function E({deviceKey:e,fromDeviceKey:i},{db:a,writer:r,hostcalls:s}){const[n,o,d]=await Promise.all([l(a,r.key),l(a,e),l(a,i)]);if(!k(n))throw b.ABORT();if(!t.equals(n.key,o.key))throw b.ABORT();if(!t.equals(n.key,d.key))throw b.ABORT();const[m,c]=await Promise.all([a.get("@keet/devices",{key:i}),a.get("@keet/devices",{key:e})]);if(!m||!c)throw b.ABORT();if(!m.status.isActive)throw b.ABORT();if(!c.status.isActive)throw b.ABORT();if(!m.status.isIndexing)throw b.ABORT();if(c.status.isIndexing)throw b.ABORT();if(t.equals(m.key,c.key))throw b.ABORT();return await s.addWriter(c.key,p.ADMIN),await s.addWriter(m.key,p.WRITER),c.status.isIndexing=!0,m.status.isIndexing=!1,await a.insert("@keet/devices",m),await a.insert("@keet/devices",c),{writer:r,writerMember:n}}async function P(e,{db:t,writer:i,hostcalls:a}){const[r,s]=await Promise.all([t.get("@keet/devices",{key:i.key}),l(t,i.key)]);if(!r.status.isActive||!k(s)||!s.status.canAdmin)throw b.ABORT();return await a.addWriter(i.key,p.ADMIN),r.status.isIndexing=!0,await t.insert("@keet/devices",r),{writer:i,writerMember:s}}async function D(e,{db:t,writer:i,hostcalls:a}){const[r,s]=await Promise.all([t.get("@keet/devices",{key:i.key}),l(t,i.key)]);if(!r.status.isActive||!k(s)||!s.status.canAdmin)throw b.ABORT();return await a.addWriter(i.key,p.WRITER),r.status.isIndexing=!1,await t.insert("@keet/devices",r),{writer:i,writerMember:s}}async function N({header:e,blindRequest:i},a){const{db:r}=a,s=await r.get("@keet/room-capabilities");if(!s)throw b.ABORT();let o=null;try{const e=m(a.hostcalls.key,s.seed);o=n(e,i)}catch(e){throw b.ABORT()}if(!o)throw b.ABORT();const{withInvitation:y,withMemberProof:w}=o;return y?async function(e,i,a){const{db:r,hostcalls:s,writer:n}=a;let o=null;try{o=d(e)}catch(e){throw b.ABORT()}if(!o)throw b.ABORT();const{id:m,request:c}=o;if(!t.equals(c.deviceKey,n.key))throw b.ABORT();const[y,w,k]=await Promise.all([r.get("@keet/join-requests",{deviceKey:n.key}),r.get("@keet/invitations",{id:m}),r.get("@keet-private-id/identity")]);if(!w||y)throw b.ABORT();const l=w.metadata.buildType,u=c.device.profile.buildType;if(!A(u,l))throw b.INVALID_BUILD_TYPE();await s.ackWriter(n.key),w.requiresConfirmation||k?await r.insert("@keet/join-requests",{deviceKey:n.key,id:m,request:c}):await O(i,n.key,c,w,null,a)}(y,e,a):w?async function({device:e,member:t},i,a){const{db:r,hostcalls:s,writer:n}=a,[o,d,m,y]=await Promise.all([r.get("@keet/members",{key:e.attestation.memberKey}),r.get("@keet/member-proofs",{key:e.attestation.memberKey}),r.get("@keet/system-digest"),r.get("@keet-private-id/identity")]);if(!o||!d)throw b.ABORT();const w=m.settings.roomType===c.DirectMessage;if(m.abi.version>=12&&!o.status.isActive&&!w)throw b.ABORT();const k={isActive:!0,isIndexing:!!y||o.status.isAdmin};await R(i,n.key,e.profile,e.attestation,k,a),await s.ackWriter(n.key),t&&await T(0,t.profile,t.attestation,a)}(w,e,a):void 0}async function _({header:e,member:{profile:t,attestation:i}},a){const{db:r,writer:s}=a;return await T(0,t,i,a),{writer:s,writerMember:await l(r,s.key)}}async function x({key:e,profile:i},{db:a,writer:r}){const[s,n]=await Promise.all([l(a,r.key),a.get("@keet/devices",{key:e||r.key})]);if(!n||!n.status.isActive||!k(s))throw b.ABORT();if(!t.equals(n.memberKey,s.key))throw b.INVALID_TARGET_DEVICE();return t.equals(n.key,r.key)?n.profile=i:n.profile={...n.profile,name:i.name},await a.insert("@keet/devices",n),{writer:r,writerMember:s}}async function W({key:e},{db:i,writer:a,hostcalls:r}){const[s,n,o]=await Promise.all([l(i,a.key),i.get("@keet/devices",{key:e}),i.get("@keet/threads",{id:0})]);if(!n||!k(s)||!t.equals(n.memberKey,s.key))throw b.ABORT();const d={...n,status:{...n.status}};n.status.isActive=!1,n.status.isIndexing=!1,r.removeable(n.key)&&await r.removeWriter(n.key),await i.insert("@keet/devices",n),await y(i,o,n,d);const m=await i.get("@keet/admin-last-seen",{memberKey:n.memberKey});return m&&t.equals(m.deviceKey,e)&&await i.delete("@keet/admin-last-seen",{memberKey:n.memberKey}),{writer:a,writerMember:s}}async function S({memberKey:e,key:t,status:i},{db:a,writer:r}){const[s,n]=await Promise.all([l(a,r.key),a.get("@keet/members",{key:e})]);if(!k(s))throw b.INACTIVE_MEMBER();if(!n)throw b.TARGET_MEMBER_NOT_FOUND();if(!s.status.isModerator)throw b.MODERATORS_ONLY();if(0===t||t>g.length)throw b.INVALID_MEMBER_STATUS();const o=g[t-1];return n.status[o]=i[o],await a.insert("@keet/members",n),{writer:r,writerMember:s}}async function L({key:e,isModerator:i,isAdmin:a},{db:r,writer:s,hostcalls:n}){const[o,d,m]=await Promise.all([l(r,s.key),r.get("@keet/members",{key:e}),r.find("@keet/active-devices-by-member-key",{gte:{memberKey:e},lte:{memberKey:e}}).toArray()]);if(!k(o))throw b.INACTIVE_MEMBER();if(!d)throw b.TARGET_MEMBER_NOT_FOUND();const c=o.status.isAdmin,y=o.status.isModerator,w=d.status.isAdmin;if(!c&&(w||a))throw b.ADMINS_ONLY();if(!y)throw b.MODERATORS_ONLY();let u=!1;if(w&&!a){const i=await r.find("@keet/admins",{limit:2}).toArray();if(1===i.length&&t.equals(i[0].key,e))u=!0;else for(const e of m)n.removeable(e.key)?await n.addWriter(e.key,p.WRITER):u=!0}return u||(d.status.isAdmin=a),d.status.isModerator=i||a,await r.insert("@keet/members",d),w&&!d.status.isAdmin&&await r.delete("@keet/admin-last-seen",{memberKey:e}),{writer:s,writerMember:o}}async function V(e,{db:t,writer:i,hostcalls:a}){const[r,s]=await Promise.all([t.get("@keet/devices",{key:i.key}),l(t,i.key)]);if(!k(s))throw b.INACTIVE_MEMBER();if(!s.status.isAdmin)throw b.ADMINS_ONLY();if(!r.status.isActive)throw b.ABORT();if(!r.status.isIndexing)return r.status.isIndexing=!0,await t.insert("@keet/devices",r),await a.addWriter(i.key,p.ADMIN),{writer:i,writerMember:s}}async function j({header:e,key:i},{db:a,writer:r,hostcalls:s}){const[n,o,d,m,v]=await Promise.all([l(a,r.key),a.get("@keet/members",{key:i}),a.get("@keet/system-digest"),a.find("@keet/active-devices-by-member-key",{gte:{memberKey:i},lte:{memberKey:i}}).toArray(),a.get("@keet/threads",{id:0})]);if(!k(n))throw b.INACTIVE_MEMBER();if(!o)throw b.TARGET_MEMBER_NOT_FOUND();const f={...o,status:{...o.status}},A=t.equals(n.key,o.key),h=n.status.isModerator;if(o.status.isAdmin&&!A)throw b.SELF_ONLY();if(!A&&!h)throw b.MODERATORS_ONLY();o.status.isActive=!1,o.status.isModerator=!1,o.status.isAdmin=!1,o.status.isPending=!!A,A||(o.status.isRemoved=!0,await a.insert("@keet/tmp-removed-members",{key:o.key}));for(const e of m){const t={...e,status:{...e.status}};s.removeable(e.key)&&(await s.removeWriter(e.key,{indexer:!1}),e.status.isIndexing=!1),e.status.isActive=!1,await a.insert("@keet/devices",e),await y(a,v,e,t)}if(await a.insert("@keet/members",o),await w(a,v,o,f),f.status.isAdmin&&await a.delete("@keet/admin-last-seen",{memberKey:i}),d.settings.roomType===c.Broadcast)return{writer:r,writerMember:n};if(d.abi.version>=11&&d.settings.isMembershipEventsDisabled)return{writer:r,writerMember:n};const p=A?{memberLeft:{memberKey:o.key}}:{memberRemoved:{memberKey:o.key}};return await u(a,r,p,e.timestamp),{writer:r,writerMember:n}}module.exports={[f]:function(e){e.add("@keet/add-device",N),e.add("@keet/update-device",h(x)),e.add("@keet/remove-device",h(W)),e.add("@keet/start-indexing",h(P)),e.add("@keet/stop-indexing",h(D)),e.add("@keet/accept-join-request",h(I)),e.add("@keet/reject-join-request",h(B)),e.add("@keet/update-member",h(_)),e.add("@keet/change-member-role",h(L)),e.add("@keet/claim-admin-devices",h(V)),e.add("@keet/change-member-status",h(S)),e.add("@keet/remove-member",h(j)),e.add("@keet/add-invitation",h(K)),e.add("@keet/remove-invitation",h(q)),e.add("@keet/move-indexer",h(E))},MemberStatus:{IsMuted:1,IsBanned:2,IsShadowBanned:3},addDevice:R,addMember:M};
@holepunchto/keet-core/lib/core/files/index.js +1 -1
……@@ -1 +1 @@
1const e=require("path"),t=require("fs"),a=require("hypercore-blob-server"),i=require("hyperblobs"),r=require("ready-resource"),n=require("safety-catch"),o=require("hypercore-id-encoding"),s=require("speedometer"),{pipelinePromise:l,Readable:c,Transform:d,pipeline:y}=require("streamx"),h=require("b4a"),{KeetErrorV2:p}=require("../../errors");function u(e){return"string"==typeof e&&!e.includes("\0")&&!e.split(/[/\\]/).includes("..")}module.exports=class extends r{constructor(e,t={}){super(),this.keet=e,this.local=e.local,this.store=e.store,this.server=new a(this.store.session(),{resolve:this._resolveEncryptionKey.bind(this)}),this._activeDownloads=new Map,this._onerror=t.onerror||n,this.ready().catch(this._onerror)}_open(){return this.server.listen()}_close(){return this.server.close()}async _resolveEncryptionKey(e,{blob:t,filename:a,drive:i,version:r}){const n=i?"@local/drive-files":"@local/blob-files",o={pointer:{externalDrive:{key:i,path:a&&a.startsWith("/")?a.slice(1):a,version:r},externalBlob:{key:e,blob:t}}},s=await this.local.get(n,{file:o});return s&&await this.keet.internalBlobsActiveInRoom(s.roomKey),s?{key:e,encryptionKey:s.encryptionKey}:null}_getLinkOptions(e){if(!e.pointer?.externalBlob&&!e.pointer?.externalDrive)throw new Error("Invalid file pointer");return e.pointer.externalBlob?{collection:"@local/blob-files",key:e.pointer.externalBlob.key,opts:{blob:e.pointer.externalBlob.blob,type:e.metadata?.mimetype}}:{collection:"@local/drive-files",key:e.pointer.externalDrive.key,opts:{filename:e.pointer.externalDrive.path,version:e.pointer.externalDrive.version}}}async _clearAllFiles(e,t,a,{leaving:i=!1}={}){const r=t?"@local/blob-files":"@local/drive-files",o=t?"@local/blob-files-by-room":"@local/drive-files-by-room",s=[];for await(const t of e.find(o,{gte:{roomKey:a},lte:{roomKey:a}})){if(t.cleared)continue;const{key:a,opts:o}=this._getLinkOptions(t.file),l=this.server.clear(a,o);l.catch(n),s.push(l),i?await e.delete(r,t):await e.insert(r,{...t,cleared:!0})}return(await Promise.allSettled(s)).filter(e=>"fulfilled"===e.status).reduce((e,t)=>e+t.value,0)}async _findAndClearOldFiles(e,t){const a=[];for await(const i of this.local.find(e,{lte:{lastAccessed:t}}))i.cleared||a.push(i);const i=[];for(const e of a){const{key:t,opts:a}=this._getLinkOptions(e.file),r=this.server.clear(t,a);r.catch(n),i.push(r)}return{recordsToClear:a,bytesCleared:(await Promise.allSettled(i)).filter(e=>"fulfilled"===e.status).reduce((e,t)=>e+t.value,0)}}async _createFile(e,t,a){const i={metadata:a,pointer:{externalBlob:{key:e.externalBlobs.key,blob:t}}};i.metadata?.userdata&&(i.metadata.userdata=h.from(i.metadata.userdata,"base64"));const r=await this.keet.internalEnterLocalTransaction();try{const t={file:i,roomKey:e.key,encryptionKey:e.encryptionKey,cleared:!1,own:!0,lastAccessed:Date.now()};await r.insert("@local/blob-files",t),await this._updateFileStats(r,t),await r.flush()}finally{await this.keet.internalExitLocalTransaction()}return i}async saveFile(a,i,r){if(this.opened||await this.ready(),!u(i))throw p.INVALID_FILE_PATH();const n=e.basename(i),o=this.keet.internalOpenExistingRoom(a);try{await this.keet.internalBlobsActiveInRoom(a);const e=t.createReadStream(i),s=o.externalBlobs.createWriteStream(r);return await l(e,s),this._createFile(o,s.id,{name:n,...r})}finally{this.keet.internalReleaseRoom(o)}}subscribeAddFile(a,i,r={}){if(!u(i))throw p.INVALID_FILE_PATH();const o=e.basename(i),s=this,l=new c;return t.stat(i,(e,c)=>{if(l.destroyed)return;if(e)return l.destroy(e);let d=0;const y=c.size,h=t.createReadStream(i),p=s.keet.internalOpenExistingRoom(a),u=p.externalBlobs.createWriteStream(r);this.keet.internalBlobsActiveInRoom(a).catch(n);let w=setInterval(()=>{l.destroyed||d<y&&l.push({bytesAdded:d,byteLength:y,result:null})},r?.debounceTime??500);h.pipe(u),h.on("data",e=>{d+=e.byteLength}),h.on("error",e=>l.destroy(e)),u.on("close",async()=>{if(w&&clearInterval(w),w=null,!l.destroyed)try{const e=await s._createFile(p,u.id,{name:o,...r});l.push({bytesAdded:d,byteLength:y,result:e}),l.push(null)}catch(e){l.destroy(e)}}),l.on("error",e=>{h.destroy(e)}),l.on("close",()=>{w&&clearInterval(w),w=null,h.destroy(),u.destroy(),s.keet.internalReleaseRoom(p)}),r.onFileStat&&r.onFileStat()}),l}async saveFileBlob(e,t,a){this.opened||await this.ready();const i=this.keet.internalOpenExistingRoom(e);try{await this.keet.internalBlobsActiveInRoom(e);const r=await i.externalBlobs.put(t);return this._createFile(i,r,a)}finally{this.keet.internalReleaseRoom(i)}}async clearAllFiles(e,t){let a=0,i=0;const r=await this.keet.internalEnterLocalTransaction();try{a=await this._clearAllFiles(r,!0,e,t),i=await this._clearAllFiles(r,!1,e,t),await r.insert("@local/file-stats",{roomKey:e,total:0}),await r.flush()}finally{await this.keet.internalExitLocalTransaction()}return{bytesCleared:a+i}}async clearOldFiles(){const e=Date.now()-6048e5,t=new Set,a=await this._findAndClearOldFiles("@local/blob-files-by-last-accessed",e),i=await this._findAndClearOldFiles("@local/drive-files-by-last-accessed",e),r=await this.keet.internalEnterLocalTransaction();try{for(const e of a.recordsToClear)await r.insert("@local/blob-files",{...e,cleared:!0}),await this._updateFileStats(r,{...e,cleared:!0}),t.add(o.encode(e.roomKey));for(const e of i.recordsToClear)await r.insert("@local/drive-files",{...e,cleared:!0}),await this._updateFileStats(r,{...e,cleared:!0}),t.add(o.encode(e.roomKey));await r.insert("@local/file-gc-info",{lastCleared:Date.now()}),await r.flush()}finally{await this.keet.internalExitLocalTransaction()}for(const e of t)this.keet.emit("local-files-changed",e);return{bytesCleared:a.bytesCleared+i.bytesCleared}}async _ensureLocalFile(e,t,a){const i=await this.keet.internalEnterLocalTransaction();try{await this.keet.internalBlobsActiveInRoom(t);const r=await i.get(e,{roomKey:t,file:a});let n=r?.encryptionKey;if(!n){const e=await i.get("@local/rooms",{roomKey:t});n=e?.encryptionKey}const s={...r,cleared:r?.cleared??!1,roomKey:t,encryptionKey:n,file:a,lastAccessed:Date.now()};return await i.insert(e,s),r||await this._updateFileStats(i,s),await i.flush(),r||this.keet.emit("local-files-changed",o.encode(t)),s}finally{await this.keet.internalExitLocalTransaction()}}async _loadBlob(e,t){const a=this.keet.internalOpenExistingRoom(e);try{return await a.ready(),await a.engine.getBlob(t)}finally{this.keet.internalReleaseRoom(a)}}async getFileLink(e,t){if(this.opened||await this.ready(),t.pointer.blob){const a=await this._loadBlob(e,t.pointer);return this.server.getBlobLink(a,{type:t.metadata?.mimetype})}const{collection:a,key:i,opts:r}=this._getLinkOptions(t);return await this._ensureLocalFile(a,e,t),this.server.getLink(i,r)}async getFileEntry(e,t,a={}){if(!t)return null;this.opened||await this.ready();const i={roomKey:e,encryptionKey:null,cleared:!1,httpLink:null};if(!(t.pointer.externalBlob||t.pointer.externalDrive||t.pointer.blob||t.pointer.bee))return i;if(t.pointer.blob||t.pointer.bee){const r=a.loadBlob?await a.loadBlob(t.pointer):await this._loadBlob(e,t.pointer);return i.httpLink=this.server.getBlobLink(r,{type:t.metadata?.mimetype}),i}const{collection:r,key:n,opts:o}=this._getLinkOptions(t);return{...await this._ensureLocalFile(r,e,t),httpLink:this.server.getLink(n,o)}}async getFileEntryWithPreview(e,t,a={}){this.opened||await this.ready();const i=await this.getFileEntry(e,t,a);if(!t.preview)return i;const[r,n,o]=await Promise.all([this.getFileEntry(e,t.preview.small,a),this.getFileEntry(e,t.preview.medium,a),this.getFileEntry(e,t.preview.large,a)]);return i.preview={small:r,medium:n,large:o},i}async getFileCleared(e,t){const{collection:a}=this._getLinkOptions(t),i=await this.local.get(a,{file:t});return!!i&&i.cleared}async getLocalFiles(e){return(await Promise.all([this.local.find("@local/blob-files-by-room",{gte:{roomKey:e},lte:{roomKey:e}}).toArray(),this.local.find("@local/drive-files-by-room",{gte:{roomKey:e},lte:{roomKey:e}}).toArray()])).flat()}async clearFile(e,t){if(!t?.pointer?.externalBlob&&!t?.pointer?.externalDrive)return;const{collection:a,key:i,opts:r}=this._getLinkOptions(t),n=await this.keet.internalEnterLocalTransaction();try{const o=await n.get(a,{roomKey:e,file:t});if(!o||o.cleared)return;await this.server.clear(i,r);const s={roomKey:e,file:t,lastAccessed:o.lastAccessed??Date.now(),cleared:!0};await n.insert(a,s),await this._updateFileStats(n,s),await n.flush()}finally{await this.keet.internalExitLocalTransaction()}}async unclearFile(e,t){const{collection:a}=this._getLinkOptions(t),i=await this.keet.internalEnterLocalTransaction();try{const r=await i.get(a,{roomKey:e,file:t});if(!r||!r.cleared)return;const n={roomKey:e,file:t,lastAccessed:Date.now(),cleared:!1};await i.insert(a,n),await this._updateFileStats(i,n),await i.flush()}finally{await this.keet.internalExitLocalTransaction()}}async startDownload(e,t){this.opened||await this.ready();const{key:a,opts:i}=this._getLinkOptions(t),r=this.server.getLink(a,{...i,url:!1}),n=this.server.download(a,i);return this._activeDownloads.set(r,n),n.done().then(()=>{this._activeDownloads.get(r)===n&&this._activeDownloads.delete(r)}),r}async cancelDownload(e,t){this.opened||await this.ready();const a=this._activeDownloads.get(t);t&&a&&await a.close().finally(()=>{this._activeDownloads.get(t)===a&&this._activeDownloads.delete(t)})}readFileStream(e,t,{includeProgress:a=!1}={}){if(!t.pointer.externalBlob)throw new Error("Only external blob files support streaming");const i=this,r=new c({open(n){i._openReadStream(e,t,r,a).then(n,n)}});return r}async _openReadStream(e,t,a,r){this.opened||await this.ready();const o=t.pointer.externalBlob.blob,l=t.pointer.externalBlob.key,{collection:c}=this._getLinkOptions(t),d=await this._ensureLocalFile(c,e,t),y=r?s():null,h=this.store.get({key:l,encryptionKey:d.encryptionKey,encrypted:!0,active:!1});await h.ready();const p=new i(h).createReadStream(o);let u=0;p.on("data",e=>{if(!r)return void a.push(e);u+=e.length;const t=y(e.length);a.push({data:e,speed:t,progress:{bytesRead:u,byteLength:o.byteLength,percentage:Math.round(u/o.byteLength*100)}})}),p.on("end",()=>{a.push(null)}),p.on("error",e=>a.destroy(e)),a.once("close",()=>{p.destroy(),h.close().catch(n)})}subscribeSaveToDisk(e,a,i,{progressInterval:r=50}={}){if(this.opened||this.ready(),!u(i))throw p.INVALID_FILE_PATH();const n=this.readFileStream(e,a,{includeProgress:!0}),o=t.createWriteStream(i),s=new c;s.once("close",()=>o.destroy()),s.once("error",e=>o.destroy(e));let l=0;return y(n,new d({transform(e,t){if(s.destroyed)return t(null);const{data:a,...i}=e,n=Date.now();i.done=i.progress.bytesRead===i.progress.byteLength,(i.done||n-l>r)&&(l=n,s.push(i)),this.push(a),t(null)}}),o,e=>{s.destroyed||(s.push(null),e&&s.destroy(e))}),s}async saveToDisk(e,a,i){if(this.opened||await this.ready(),!u(i))throw p.INVALID_FILE_PATH();const r=this.readFileStream(e,a),n=t.createWriteStream(i);await l(r,n)}async refreshLinks(e){this.opened||await this.ready();const t=[];for(const a of e)t.push(this.server.refreshLink(a));return t}async monitor(e,t){this.opened||await this.ready();const{key:a,opts:i}=this._getLinkOptions(t);return this.server.monitor(a,i)}async _updateFileStats(e,{roomKey:t,file:a,cleared:i}){const r=a.pointer.externalBlob?.blob.byteLength;if(!r)return;let n=await e.get("@local/file-stats",{roomKey:t});n||(n={roomKey:t,total:0});const o=i?-r:r;n.total=Math.max(n.total+o,0),await e.insert("@local/file-stats",n)}};
1const e=require("path"),t=require("fs"),a=require("hypercore-blob-server"),i=require("hyperblobs"),r=require("ready-resource"),n=require("safety-catch"),o=require("hypercore-id-encoding"),s=require("speedometer"),{pipelinePromise:l,Readable:c,Transform:d,pipeline:y}=require("streamx"),h=require("b4a"),{KeetErrorV2:p}=require("../../errors");function u(e){return"string"==typeof e&&!e.includes("\0")&&!e.split(/[/\\]/).includes("..")}module.exports=class extends r{constructor(e,t={}){super(),this.keet=e,this.local=e.local,this.store=e.store,this.server=new a(this.store.session(),{resolve:this._resolveEncryptionKey.bind(this)}),this._activeDownloads=new Map,this._onerror=t.onerror||n,this.ready().catch(this._onerror)}_open(){return this.server.listen()}_close(){return this.server.close()}async _resolveEncryptionKey(e,{blob:t,filename:a,drive:i,version:r}){const n=i?"@local/drive-files":"@local/blob-files",o={pointer:{externalDrive:{key:i,path:a&&a.startsWith("/")?a.slice(1):a,version:r},externalBlob:{key:e,blob:t}}},s=await this.local.get(n,{file:o});return s&&await this.keet.internalBlobsActiveInRoom(s.roomKey),s?{key:e,encryptionKey:s.encryptionKey}:null}_getLinkOptions(e){if(!e.pointer?.externalBlob&&!e.pointer?.externalDrive)throw new Error("Invalid file pointer");return e.pointer.externalBlob?{collection:"@local/blob-files",key:e.pointer.externalBlob.key,opts:{blob:e.pointer.externalBlob.blob,type:e.metadata?.mimetype}}:{collection:"@local/drive-files",key:e.pointer.externalDrive.key,opts:{filename:e.pointer.externalDrive.path,version:e.pointer.externalDrive.version}}}async _clearAllFiles(e,t,a,{leaving:i=!1}={}){const r=t?"@local/blob-files":"@local/drive-files",o=t?"@local/blob-files-by-room":"@local/drive-files-by-room",s=[];for await(const t of e.find(o,{gte:{roomKey:a},lte:{roomKey:a}})){if(t.cleared)continue;const{key:a,opts:o}=this._getLinkOptions(t.file),l=this.server.clear(a,o);l.catch(n),s.push(l),i?await e.delete(r,t):await e.insert(r,{...t,cleared:!0})}return(await Promise.allSettled(s)).filter(e=>"fulfilled"===e.status).reduce((e,t)=>e+t.value,0)}async _findAndClearOldFiles(e,t){const a=[];for await(const i of this.local.find(e,{lte:{lastAccessed:t}}))i.cleared||a.push(i);const i=[];for(const e of a){const{key:t,opts:a}=this._getLinkOptions(e.file),r=this.server.clear(t,a);r.catch(n),i.push(r)}return{recordsToClear:a,bytesCleared:(await Promise.allSettled(i)).filter(e=>"fulfilled"===e.status).reduce((e,t)=>e+t.value,0)}}async _createFile(e,t,a){const i={metadata:a,pointer:{externalBlob:{key:e.externalBlobs.key,blob:t}}};i.metadata?.userdata&&(i.metadata.userdata=h.from(i.metadata.userdata,"base64"));const r=await this.keet.internalEnterLocalTransaction();try{const t={file:i,roomKey:e.key,encryptionKey:e.encryptionKey,cleared:!1,own:!0,lastAccessed:Date.now()};await r.insert("@local/blob-files",t),await this._updateFileStats(r,t),await r.flush()}finally{await this.keet.internalExitLocalTransaction()}return i}async saveFile(a,i,r){if(this.opened||await this.ready(),!u(i))throw p.INVALID_FILE_PATH();const n=e.basename(i),o=this.keet.internalOpenExistingRoom(a);try{await this.keet.internalBlobsActiveInRoom(a);const e=t.createReadStream(i),s=o.externalBlobs.createWriteStream(r);return await l(e,s),this._createFile(o,s.id,{name:n,...r})}finally{this.keet.internalReleaseRoom(o)}}subscribeAddFile(a,i,r={}){if(!u(i))throw p.INVALID_FILE_PATH();const o=e.basename(i),s=this,l=new c;return t.stat(i,(e,c)=>{if(l.destroyed)return;if(e)return l.destroy(e);let d=0;const y=c.size,h=t.createReadStream(i),p=s.keet.internalOpenExistingRoom(a),u=p.externalBlobs.createWriteStream(r);this.keet.internalBlobsActiveInRoom(a).catch(n);let w=setInterval(()=>{l.destroyed||d<y&&l.push({bytesAdded:d,byteLength:y,result:null})},r?.debounceTime??500);h.pipe(u),h.on("data",e=>{d+=e.byteLength}),h.on("error",e=>l.destroy(e)),u.on("close",async()=>{if(w&&clearInterval(w),w=null,!l.destroyed)try{const e=await s._createFile(p,u.id,{name:o,...r});l.push({bytesAdded:d,byteLength:y,result:e}),l.push(null)}catch(e){l.destroy(e)}}),l.on("error",e=>{h.destroy(e)}),l.on("close",()=>{w&&clearInterval(w),w=null,h.destroy(),u.destroy(),s.keet.internalReleaseRoom(p)}),r.onFileStat&&r.onFileStat()}),l}async saveFileBlob(e,t,a){this.opened||await this.ready();const i=this.keet.internalOpenExistingRoom(e);try{await this.keet.internalBlobsActiveInRoom(e);const r=await i.externalBlobs.put(t);return this._createFile(i,r,a)}finally{this.keet.internalReleaseRoom(i)}}async clearAllFiles(e,t){let a=0,i=0;const r=await this.keet.internalEnterLocalTransaction();try{a=await this._clearAllFiles(r,!0,e,t),i=await this._clearAllFiles(r,!1,e,t),await r.insert("@local/file-stats",{roomKey:e,total:0}),await r.flush()}finally{await this.keet.internalExitLocalTransaction()}return{bytesCleared:a+i}}async clearOldFiles(){const e=Date.now()-6048e5,t=new Set,a=await this._findAndClearOldFiles("@local/blob-files-by-last-accessed",e),i=await this._findAndClearOldFiles("@local/drive-files-by-last-accessed",e),r=await this.keet.internalEnterLocalTransaction();try{for(const e of a.recordsToClear)await r.insert("@local/blob-files",{...e,cleared:!0}),await this._updateFileStats(r,{...e,cleared:!0}),t.add(o.encode(e.roomKey));for(const e of i.recordsToClear)await r.insert("@local/drive-files",{...e,cleared:!0}),await this._updateFileStats(r,{...e,cleared:!0}),t.add(o.encode(e.roomKey));await r.insert("@local/file-gc-info",{lastCleared:Date.now()}),await r.flush()}finally{await this.keet.internalExitLocalTransaction()}for(const e of t)this.keet.emit("local-files-changed",e);return{bytesCleared:a.bytesCleared+i.bytesCleared}}async _ensureLocalFile(e,t,a){await this.keet.internalBlobsActiveInRoom(t);const i=await this.keet.internalEnterLocalTransaction();try{const r=await i.get(e,{roomKey:t,file:a});let n=r?.encryptionKey;if(!n){const e=await i.get("@local/rooms",{roomKey:t});n=e?.encryptionKey}const s={...r,cleared:r?.cleared??!1,roomKey:t,encryptionKey:n,file:a,lastAccessed:Date.now()};return await i.insert(e,s),r||await this._updateFileStats(i,s),await i.flush(),r||this.keet.emit("local-files-changed",o.encode(t)),s}finally{await this.keet.internalExitLocalTransaction()}}async _loadBlob(e,t){const a=this.keet.internalOpenExistingRoom(e);try{return await a.ready(),await a.engine.getBlob(t)}finally{this.keet.internalReleaseRoom(a)}}async getFileLink(e,t){if(this.opened||await this.ready(),t.pointer.blob){const a=await this._loadBlob(e,t.pointer);return this.server.getBlobLink(a,{type:t.metadata?.mimetype})}const{collection:a,key:i,opts:r}=this._getLinkOptions(t);return await this._ensureLocalFile(a,e,t),this.server.getLink(i,r)}async getFileEntry(e,t,a={}){if(!t)return null;this.opened||await this.ready();const i={roomKey:e,encryptionKey:null,cleared:!1,httpLink:null};if(!(t.pointer.externalBlob||t.pointer.externalDrive||t.pointer.blob||t.pointer.bee))return i;if(t.pointer.blob||t.pointer.bee){const r=a.loadBlob?await a.loadBlob(t.pointer):await this._loadBlob(e,t.pointer);return i.httpLink=this.server.getBlobLink(r,{type:t.metadata?.mimetype}),i}const{collection:r,key:n,opts:o}=this._getLinkOptions(t);return{...await this._ensureLocalFile(r,e,t),httpLink:this.server.getLink(n,o)}}async getFileEntryWithPreview(e,t,a={}){this.opened||await this.ready();const i=await this.getFileEntry(e,t,a);if(!t.preview)return i;const[r,n,o]=await Promise.all([this.getFileEntry(e,t.preview.small,a),this.getFileEntry(e,t.preview.medium,a),this.getFileEntry(e,t.preview.large,a)]);return i.preview={small:r,medium:n,large:o},i}async getFileCleared(e,t){const{collection:a}=this._getLinkOptions(t),i=await this.local.get(a,{file:t});return!!i&&i.cleared}async getLocalFiles(e){return(await Promise.all([this.local.find("@local/blob-files-by-room",{gte:{roomKey:e},lte:{roomKey:e}}).toArray(),this.local.find("@local/drive-files-by-room",{gte:{roomKey:e},lte:{roomKey:e}}).toArray()])).flat()}async clearFile(e,t){if(!t?.pointer?.externalBlob&&!t?.pointer?.externalDrive)return;const{collection:a,key:i,opts:r}=this._getLinkOptions(t),n=await this.keet.internalEnterLocalTransaction();try{const o=await n.get(a,{roomKey:e,file:t});if(!o||o.cleared)return;await this.server.clear(i,r);const s={roomKey:e,file:t,lastAccessed:o.lastAccessed??Date.now(),cleared:!0};await n.insert(a,s),await this._updateFileStats(n,s),await n.flush()}finally{await this.keet.internalExitLocalTransaction()}}async unclearFile(e,t){const{collection:a}=this._getLinkOptions(t),i=await this.keet.internalEnterLocalTransaction();try{const r=await i.get(a,{roomKey:e,file:t});if(!r||!r.cleared)return;const n={roomKey:e,file:t,lastAccessed:Date.now(),cleared:!1};await i.insert(a,n),await this._updateFileStats(i,n),await i.flush()}finally{await this.keet.internalExitLocalTransaction()}}async startDownload(e,t){this.opened||await this.ready();const{key:a,opts:i}=this._getLinkOptions(t),r=this.server.getLink(a,{...i,url:!1}),n=this.server.download(a,i);return this._activeDownloads.set(r,n),n.done().then(()=>{this._activeDownloads.get(r)===n&&this._activeDownloads.delete(r)}),r}async cancelDownload(e,t){this.opened||await this.ready();const a=this._activeDownloads.get(t);t&&a&&await a.close().finally(()=>{this._activeDownloads.get(t)===a&&this._activeDownloads.delete(t)})}readFileStream(e,t,{includeProgress:a=!1}={}){if(!t.pointer.externalBlob)throw new Error("Only external blob files support streaming");const i=this,r=new c({open(n){i._openReadStream(e,t,r,a).then(n,n)}});return r}async _openReadStream(e,t,a,r){this.opened||await this.ready();const o=t.pointer.externalBlob.blob,l=t.pointer.externalBlob.key,{collection:c}=this._getLinkOptions(t),d=await this._ensureLocalFile(c,e,t),y=r?s():null,h=this.store.get({key:l,encryptionKey:d.encryptionKey,encrypted:!0,active:!1});await h.ready();const p=new i(h).createReadStream(o);let u=0;p.on("data",e=>{if(!r)return void a.push(e);u+=e.length;const t=y(e.length);a.push({data:e,speed:t,progress:{bytesRead:u,byteLength:o.byteLength,percentage:Math.round(u/o.byteLength*100)}})}),p.on("end",()=>{a.push(null)}),p.on("error",e=>a.destroy(e)),a.once("close",()=>{p.destroy(),h.close().catch(n)})}subscribeSaveToDisk(e,a,i,{progressInterval:r=50}={}){if(this.opened||this.ready(),!u(i))throw p.INVALID_FILE_PATH();const n=this.readFileStream(e,a,{includeProgress:!0}),o=t.createWriteStream(i),s=new c;s.once("close",()=>o.destroy()),s.once("error",e=>o.destroy(e));let l=0;return y(n,new d({transform(e,t){if(s.destroyed)return t(null);const{data:a,...i}=e,n=Date.now();i.done=i.progress.bytesRead===i.progress.byteLength,(i.done||n-l>r)&&(l=n,s.push(i)),this.push(a),t(null)}}),o,e=>{s.destroyed||(s.push(null),e&&s.destroy(e))}),s}async saveToDisk(e,a,i){if(this.opened||await this.ready(),!u(i))throw p.INVALID_FILE_PATH();const r=this.readFileStream(e,a),n=t.createWriteStream(i);await l(r,n)}async refreshLinks(e){this.opened||await this.ready();const t=[];for(const a of e)t.push(this.server.refreshLink(a));return t}async monitor(e,t){this.opened||await this.ready();const{key:a,opts:i}=this._getLinkOptions(t);return this.server.monitor(a,i)}async _updateFileStats(e,{roomKey:t,file:a,cleared:i}){const r=a.pointer.externalBlob?.blob.byteLength;if(!r)return;let n=await e.get("@local/file-stats",{roomKey:t});n||(n={roomKey:t,total:0});const o=i?-r:r;n.total=Math.max(n.total+o,0),await e.insert("@local/file-stats",n)}};
@holepunchto/keet-core/lib/core/invitations/index.js +1 -1
……@@ -1 +1 @@
1const e=require("autobee"),t=require("hypercore"),n=require("deterministic-sealed-box"),r=require("keet-identity-key"),i=require("hypercore-crypto"),{contract:{hyperschema:{encode:o,decode:c},hyperdispatch:{encode:a}}}=require("../../../schema/spec"),{KeetContractError:s}=require("./../contract/errors"),u=require("@holepunchto/keet-registry"),[y,d,p,v,f,l,m,K]=i.namespace("@holepunchto/keet-core/invitations",8);function b(e,t,n){const c=o("@keet-private-id/contact-request-body",n),a=r.attestData(c,t.deviceKeyPair,t.deviceProof),s={memberKey:t.publicKey,proof:a},u=o("@keet-private-id/contact-request",{body:n,attestation:s});return i.encrypt(u,e)}function h(t,{heads:n}={}){const r=a("@keet/add-device",{header:{timestamp:Date.now()},blindRequest:t});return e.encodeValue(r,{optimistic:!0,encrypted:!0,links:n})}function k(e,{device:t,member:n}){const r=o("@keet/device-request",{withMemberProof:{device:t,member:n}});return{blindRequest:i.encrypt(r,e)}}function q(e,t,n,r,{device:c,member:a},s){const u=g(r),y=u.publicKey,p={deviceKey:e,identity:s?.identity,keyPair:n,device:c,member:a,link:s?.link},v=o("@keet/device-request-with-invitation",p),f=i.sign(i.hash([d,v]),u.secretKey),l=o("@keet/device-request",{withInvitation:{id:y,request:p,signature:f}});return{blindRequest:i.encrypt(l,t)}}function g(e){return i.keyPair(i.hash([y,e]))}function P(e){return{version:2,signers:[{publicKey:e,namespace:K}]}}function R(e,t){return i.encryptionKeyPair(i.hash([v,e,t]))}function w(e){return i.keyPair(e)}function I(e){return i.discoveryKey(e)}function x(e){return i.discoveryKey(e)}module.exports={generateIdentityPairingName:function(e){return i.hash([l,e])},generateRoomPairingName:function(e){return i.hash([m,e])},generateSwarmTopic:x,generateWakeupTopic:I,generateMailboxKeyPair:R,generateDiscoveryKeyPair:w,generateRoomCapabilities:function(e,t){const n=R(e,t),r=w(n.publicKey),i=I(n.publicKey);return{mailboxKeyPair:n,discoveryKeyPair:r,swarmTopic:x(r.publicKey),wakeupTopic:i}},generatePairingCapabilities:function(e){const t=w(e),n=I(e);return{discoveryKeyPair:t,swarmTopic:x(t.publicKey),wakeupTopic:n}},getWakeup:function(e){return{key:e,discoveryKey:i.discoveryKey(e)}},getWriterKey:function(e){return t.key({version:2,signers:[{publicKey:e}]})},getResponseCoreManifest:P,getResponseCoreKey:function(e){return t.key(P(e))},getInvitationId:function(e){return g(e).publicKey},createInvitation:function(e,t={}){const{canModerate:n=!1,canAdmin:r=!1,expiration:c=0}=t,a=i.randomBytes(32),s=g(a),u=s.publicKey,y=o("@keet/room-keys",e);return{invitation:{id:u,metadata:{canModerate:n,canAdmin:r,expiration:c},anchor:null,response:{id:u,data:y,signature:i.sign(i.hash([p,y]),s.secretKey)}},seed:a}},createDeviceResponse:function(e,t,r){const c=o("@keet/device-response",{signedKeys:r.response}),a=i.hash([f,t]);return{blindResponse:n.encrypt(c,e,a)}},decryptDeviceRequest:function(e,t){const r=n.decrypt(t,e);return r?c("@keet/device-request",r):null},decryptContactRequest:function(e,t){const n=i.decrypt(t,e);return n?c("@keet-private-id/contact-request",n):null},verifyAttestation:function(e,t,n){let i=null;try{i=r.verify(e.proof,t,{expectedIdentity:e.memberKey})}catch{throw s.ABORT()}if(!i)throw s.ABORT();return i.receipt},verifyDeviceResponse:function(e,t){const n=i.decrypt(t,e);if(!n)return null;const r=c("@keet/device-response",n),{signedKeys:{id:o,data:a,signature:s},identity:u}=r;return i.verify(i.hash([p,a]),s,o)?{id:o,response:{roomKeys:c("@keet/room-keys",a),identity:u}}:null},verifyIdentityProofs:function(e,t){const n=t?.deviceProof,i=t?.privateProfileIdentity,o=e.writerKey,c=e.publicKey,a=e.devicePublicKey;if(!n||!i)return null;if(!i.memberKey||!i.proof)return null;const s=r.verify(n,null,{expectedIdentity:c,expectedDevice:a}),u=r.verify(i.proof,o,{expectedIdentity:c});return s&&u},verifyInvitationDeviceRequest:function({id:e,request:t,signature:n}){const r=o("@keet/device-request-with-invitation",t);return i.verify(i.hash([d,r]),n,e)?{id:e,request:t}:null},createMailboxKeyPair:function(){return i.encryptionKeyPair()},createDiscoveryKeyPair:function(){return i.keyPair()},createInvitationJoinRequest:q,createInvitationJoinOperation:function(e,t,n,r,i,o){const{blindRequest:c}=q(e,t,n,r,i,o);return h(c,o)},createMemberProofJoinRequest:k,createMemberProofJoinOperation:function(e,t,n){const{blindRequest:r}=k(e,t);return h(r,n)},createBlindContactRequest:b,createContactRequestOperation:function(t,n,r){const i=b(t,n,r),o=a("@keet-private-id/add-contact-request",{header:{timestamp:Date.now()},blindRequest:i});return e.encodeValue(o,{optimistic:!0,encrypted:!0})},createUsernameReservationRequest:function(e,{publicKey:t,deviceKeyPair:n,deviceProof:i}){const o=u.encodeReservation({username:e});return{username:e,attestation:{memberKey:t,proof:r.attestData(o,n,i)}}}};
1const e=require("autobee"),t=require("hypercore"),n=require("deterministic-sealed-box"),r=require("keet-identity-key"),i=require("hypercore-crypto"),{contract:{hyperschema:{encode:o,decode:c},hyperdispatch:{encode:a}}}=require("../../../schema/spec"),{KeetContractError:s}=require("./../contract/errors"),u=require("@holepunchto/keet-registry"),[y,d,p,f,v,l,m,K,h]=i.namespace("@holepunchto/keet-core/invitations",9);function b(e,t,n){const c=o("@keet-private-id/contact-request-body",n),a=r.attestData(c,t.deviceKeyPair,t.deviceProof),s={memberKey:t.publicKey,proof:a},u=k(c,e),y=r.attestData(u,t.deviceKeyPair,t.deviceProof),d=o("@keet-private-id/contact-request",{body:n,attestation:s,recipientProof:y});return i.encrypt(d,e)}function k(e,t){return i.hash([h,e,t])}function q(t,{heads:n}={}){const r=a("@keet/add-device",{header:{timestamp:Date.now()},blindRequest:t});return e.encodeValue(r,{optimistic:!0,encrypted:!0,links:n})}function P(e,{device:t,member:n}){const r=o("@keet/device-request",{withMemberProof:{device:t,member:n}});return{blindRequest:i.encrypt(r,e)}}function g(e,t,n,r,{device:c,member:a},s){const u=R(r),y=u.publicKey,p={deviceKey:e,identity:s?.identity,keyPair:n,device:c,member:a,link:s?.link},f=o("@keet/device-request-with-invitation",p),v=i.sign(i.hash([d,f]),u.secretKey),l=o("@keet/device-request",{withInvitation:{id:y,request:p,signature:v}});return{blindRequest:i.encrypt(l,t)}}function R(e){return i.keyPair(i.hash([y,e]))}function w(e){return{version:2,signers:[{publicKey:e,namespace:K}]}}function I(e,t){return i.encryptionKeyPair(i.hash([f,e,t]))}function D(e){return i.keyPair(e)}function x(e){return i.discoveryKey(e)}function C(e){return i.discoveryKey(e)}module.exports={generateIdentityPairingName:function(e){return i.hash([l,e])},generateRoomPairingName:function(e){return i.hash([m,e])},generateSwarmTopic:C,generateWakeupTopic:x,generateMailboxKeyPair:I,generateDiscoveryKeyPair:D,generateRoomCapabilities:function(e,t){const n=I(e,t),r=D(n.publicKey),i=x(n.publicKey);return{mailboxKeyPair:n,discoveryKeyPair:r,swarmTopic:C(r.publicKey),wakeupTopic:i}},generatePairingCapabilities:function(e){const t=D(e),n=x(e);return{discoveryKeyPair:t,swarmTopic:C(t.publicKey),wakeupTopic:n}},getWakeup:function(e){return{key:e,discoveryKey:i.discoveryKey(e)}},getWriterKey:function(e){return t.key({version:2,signers:[{publicKey:e}]})},getResponseCoreManifest:w,getResponseCoreKey:function(e){return t.key(w(e))},getInvitationId:function(e){return R(e).publicKey},createInvitation:function(e,t={}){const{canModerate:n=!1,canAdmin:r=!1,expiration:c=0}=t,a=i.randomBytes(32),s=R(a),u=s.publicKey,y=o("@keet/room-keys",e);return{invitation:{id:u,metadata:{canModerate:n,canAdmin:r,expiration:c},anchor:null,response:{id:u,data:y,signature:i.sign(i.hash([p,y]),s.secretKey)}},seed:a}},createDeviceResponse:function(e,t,r){const c=o("@keet/device-response",{signedKeys:r.response}),a=i.hash([v,t]);return{blindResponse:n.encrypt(c,e,a)}},decryptDeviceRequest:function(e,t){const r=n.decrypt(t,e);return r?c("@keet/device-request",r):null},decryptContactRequest:function(e,t){const n=i.decrypt(t,e);return n?c("@keet-private-id/contact-request",n):null},verifyAttestation:function(e,t,n){let i=null;try{i=r.verify(e.proof,t,{expectedIdentity:e.memberKey})}catch{throw s.ABORT()}if(!i)throw s.ABORT();return i.receipt},verifyDeviceResponse:function(e,t){const n=i.decrypt(t,e);if(!n)return null;const r=c("@keet/device-response",n),{signedKeys:{id:o,data:a,signature:s},identity:u}=r;return i.verify(i.hash([p,a]),s,o)?{id:o,response:{roomKeys:c("@keet/room-keys",a),identity:u}}:null},verifyIdentityProofs:function(e,t){const n=t?.deviceProof,i=t?.privateProfileIdentity,o=e.writerKey,c=e.publicKey,a=e.devicePublicKey;if(!n||!i)return null;if(!i.memberKey||!i.proof)return null;const s=r.verify(n,null,{expectedIdentity:c,expectedDevice:a}),u=r.verify(i.proof,o,{expectedIdentity:c});return s&&u},verifyInvitationDeviceRequest:function({id:e,request:t,signature:n}){const r=o("@keet/device-request-with-invitation",t);return i.verify(i.hash([d,r]),n,e)?{id:e,request:t}:null},createMailboxKeyPair:function(){return i.encryptionKeyPair()},createDiscoveryKeyPair:function(){return i.keyPair()},createInvitationJoinRequest:g,createInvitationJoinOperation:function(e,t,n,r,i,o){const{blindRequest:c}=g(e,t,n,r,i,o);return q(c,o)},createMemberProofJoinRequest:P,createMemberProofJoinOperation:function(e,t,n){const{blindRequest:r}=P(e,t);return q(r,n)},createBlindContactRequest:b,contactRecipientPayload:k,createContactRequestOperation:function(t,n,r){const i=b(t,n,r),o=a("@keet-private-id/add-contact-request",{header:{timestamp:Date.now()},blindRequest:i});return e.encodeValue(o,{optimistic:!0,encrypted:!0})},createUsernameReservationRequest:function(e,{publicKey:t,deviceKeyPair:n,deviceProof:i}){const o=u.encodeReservation({username:e});return{username:e,attestation:{memberKey:t,proof:r.attestData(o,n,i)}}}};
@holepunchto/keet-core/lib/core/sync/updater.js +1 -1
……@@ -1 +1 @@
1const e=require("ready-resource"),t=require("safety-catch"),s=require("b4a"),i=require("autobee"),a=require("./loader"),{contract:{hyperschema:{getEnum:o}}}=require("../../../schema/spec"),{verifyIdentityProofs:n,generateRoomCapabilities:r,generateIdentityPairingName:l}=require("../invitations"),{RoomStatus:h}=require("../contract/identity/private"),{KeetErrorV2:c}=require("../../errors"),d=o("@keet/room-type");module.exports=class extends e{constructor(e,t,s){super(),this.keet=e,this.swarm=e.swarm,this.local=e.local,this.view=t,this.engine=s,this.isCurrentPrivateProfile=!1,this.currentPrivateProfileInfo=null,this.currentIdentityInfo=null,this.currentWriterInfo=null,this.currentRoomInfo=null,this.currentUpdate=null,this.roomInfo=null,this.migratedFromAutobase=!1,this.updated=!1,this.processed=null,this.updates={cache:null,tasks:null,contacts:null,dispatches:null,shouldUpgrade:!1,profileDispatches:null,unreadKeys:!1,activeCall:null,activeCallDevice:null,activeCallSynced:!1,sharedRooms:null,sharedPreferences:null,pendingInvitations:null,startIdentitySwap:null,attemptIdentitySwap:null,attemptRecovery:null,finishIdentitySwap:null,logout:!1,settings:null},this.events=[],this._loader=null,this._running=null}_open(){return this._loader=new a(this.local,this.view,this.engine),this._loader.ready()}async _close(){this._running&&await this._running.catch(t),this._loader&&await this._loader.close()}async _syncDigest(e){if(e||(e=await this._loader.loadDigest()),e){if(!this.keet.isValidBuildType(e))throw c.INVALID_BUILD_TYPE();this.events.push({type:"v2:room-digest-changed",value:e}),this.roomInfo.digest=e}}async _syncConfig(){const e=await this._loader.loadConfig();e&&(this.events.push({type:"v2:room-config-changed",value:e}),this.roomInfo.config=e)}async _syncRoomCapabilities(e){e||(e=await this._loader.loadCapabilities()),e&&(this.roomInfo.seed&&s.equals(this.roomInfo.seed,e.seed)||(this.events.push({type:"v2:room-capabilities-changed",value:e}),this.roomInfo.seed=e.seed,this.roomInfo.capabilities=r(this.engine.key,e.seed)))}async _syncSelf(){const[e,t,s]=await Promise.all([this._loader.loadDigest(),this._loader.loadSelfDevice(),this._loader.loadSelfMember()]);if(this.roomInfo.selfDevice=t,this.roomInfo.selfMember=s,!e||e.settings.roomType!==d.DirectMessage)return;const[i,a]=await Promise.all([this._loader.loadConfig(),this._loader.loadDMMembers()]);this.roomInfo.config=i,this.roomInfo.dm=a}async _syncSelfMember(e){if(this.events.push({type:"v2:room-member-changed",value:e}),!e||s.equals(e.key,this.currentIdentityInfo.publicKey))return this._syncSelf()}async _syncDevice(e){if(this.events.push({type:"v2:room-device-changed",value:e}),!e||s.equals(e.key,this.engine.local.key))return this._syncSelf()}_setLastMessage(e){this.events.push({type:"v2:room-last-message-changed",value:e}),this.roomInfo.lastMessage=e.message,this.roomInfo.lastMember=e.member,this.roomInfo.lastMessageReactions=e.reactions,this.roomInfo.lastMessageLabels=e.labels,this.updates.cache={member:e.member,otherMembers:e.otherMembers,device:e.device};const t=this.currentRoomInfo?.lastMessageLabels;var i,a;i=t,a=e.labels,(i&&a?i.mine.length===a.mine.length&&i.digest.total===a.digest.total&&i.digest.editedAt===a.digest.editedAt:!i&&!a)||(this.updates.labels=e.labels);const o=this.currentRoomInfo?.lastMessage;var n,r;o&&(n=o,r=e.message,s.equals(n.oplog.key,r.oplog.key)&&n.oplog.seq===r.oplog.seq)||(this.updates.chat=e.message)}async _syncLastMessage(){const e=await this._loader.loadLastMessage();e&&this._setLastMessage(e)}async _syncMessage(e){if(!e)return;const[t,s]=await Promise.all([this._loader.loadPrimaryThread(),this._loader.loadMessage(e.id)]);0===e.id.thread&&e.id.index===t.count-1&&this._setLastMessage(s),this.events.push({type:"v2:room-chat-changed",value:s})}async _syncReactions(e){const t=await this._loader.input.get("@keet/chat",{id:e.id});this.events.push({type:"v2:room-reactions-changed",value:{id:t.oplog,reactions:e}})}async _syncChatLabels(e){const t=await this._loader.loadPrimaryThread();if(0!==e.id.thread||e.id.index!==t.count-1)return;const s=await this._loader.loadLabels(e.id);this.roomInfo.lastMessageLabels=s,this.updates.labels=s}_syncJoinRequests(e){this.events.push({type:"v2:room-join-requests-changed",value:e})}async _syncReadLengths(){const e=await this._loader.loadReadLengths();e?.length&&(this.events.push({type:"v2:read-lengths-changed",value:e}),this.roomInfo.readLengths=e)}async _syncActiveCall(){this.updates.activeCallSynced=!0;const e=await this._loader.loadActiveCall();let t=null;e&&(t=await this._loader.loadActiveCallDevice(e.callKey,this.engine.local.key),this.updates.activeCallDevice=t),this.updates.activeCall=e;let s=null;e&&(s={callKey:e.callKey,createdAt:e.createdAt,selfDeviceKey:null},t&&(s.selfDeviceKey=t.deviceKey)),this.roomInfo.activeCall=s}async _syncPreferences(){const e=await this._loader.loadPreferences();e&&(this.roomInfo.preferences=e.status)}async _syncStats(e){e||(e=await this._loader.loadPrimaryThread()),e&&(this.events.push({type:"v2:room-stats-changed",value:e}),this.roomInfo.stats=e.stats)}async _syncRoomIdentity(e){e||(e=await this._loader.loadIdentity()),e&&(this.events.push({type:"v2:room-identity-changed",value:e}),this.roomInfo.identity=e)}async _syncRoomSettings(e){e||(e=await this._loader.loadSettings()),e&&(this.roomInfo.settings=e)}async _syncUnreadAnchors(){this.updates.unreadKeys=!0}async _syncMember(e){const i=[this._syncSelfMember(e)];this.roomInfo.dm?.length&&i.push(this._syncConfig().catch(t));const{lastMember:a}=this.roomInfo;a&&s.equals(a.key,e.key)&&i.push(this._syncLastMessage().catch(t)),await Promise.all(i)}async _incrementalRoomInfoLoad(e){const s=[],i=["@keet/calls","@keet/call-devices","@keet/call-members","@keet/call-streams"];for await(const{type:a,collection:o,value:n}of this._loader.input.changes({from:e})){if(this.closing||this.keet.closing)return!1;if(!i.includes(o)&&"insert"!==a)continue;let e=null;switch(o){case"@keet/system-digest":e=this._syncDigest(n);break;case"@keet/room-config":e=this._syncConfig();break;case"@keet/room-capabilities":e=this._syncRoomCapabilities(n);break;case"@keet/members":e=this._syncMember(n);break;case"@keet/devices":e=this._syncDevice(n);break;case"@keet/chat":e=this._syncMessage(n);break;case"@keet/reaction-digests":e=this._syncReactions(n);break;case"@keet/chat-label-digests":e=this._syncChatLabels(n);break;case"@keet/threads":e=this._syncStats(n);break;case"@keet-private-id/identity":e=this._syncRoomIdentity(n);break;case"@keet-private-id/settings":e=this._syncRoomSettings(n);break;case"@keet/join-requests":e=this._syncJoinRequests(n);break;case"@keet-private-id/unreads-v2":case"@keet-private-id/unreads":e=this._syncUnreadAnchors();break;case"@keet/read-lengths":e=this._syncReadLengths();break;case"@keet/calls":case"@keet/call-devices":case"@keet/call-members":case"@keet/call-streams":e=this._syncActiveCall();break;default:continue}e&&(e.catch(t),s.push(e))}return await Promise.all(s),!!this.roomInfo.digest}async _fullRoomInfoLoad(){return this.events.push({type:"v2:room-fast-forward"}),this.roomInfo={roomKey:this.engine.key,discoveryKey:this.engine.discoveryKey,encryptionKey:this.engine.encryptionKey,digest:null,stats:null,fork:0,length:0,system:null,timestamps:{creation:0,latestActivity:0,latestChatMessage:0},status:null,mailbox:null,selfDevice:null,selfMember:null,config:null,capabilities:null,identity:null,lastMessage:null,lastMember:null,lastMessageReactions:null,lastMessageLabels:null,dm:null,activeCall:null,preferences:null,settings:null},await Promise.all([this._syncDigest(null),this._syncRoomCapabilities(null),this._syncDevice(null),this._syncMember(null),this._syncStats(null),this._syncRoomIdentity(null),this._syncUnreadAnchors(),this._syncConfig(),this._syncReadLengths(),this._syncLastMessage(),this._syncActiveCall(),this._syncPreferences(),this._syncRoomSettings()]),!!this.roomInfo.digest}async _loadPrivateProfileChanges(e){if(!0===this.keet.debugDisableSynching)return;let t=null;if(this.isCurrentPrivateProfile&&this.roomInfo.selfDevice){const[s,i,a,o]=await Promise.all([this._loader.loadContactChanges(e),this._loader.loadSharedRoomChanges(e),this._loader.loadPendingInvitations(),this.keet.getAutobeeMigrationInfo(this.engine.key)]);t=[s,i,a],this.migratedFromAutobase=!!o}t&&(this.updates.contacts=t[0],this.updates.sharedRooms=t[1],this.updates.pendingInvitations=t[2])}async _loadLocalInfo(){const[e,t,i,a]=await Promise.all([this._loader.loadLocalRoomInfo(),this._loader.loadRoomUpdate(),this._loader.loadLocalIdentityInfo(),this._loader.loadLocalPrivateProfileInfo()]);this.currentRoomInfo=e,this.currentUpdate=t,this.roomInfo={...this.currentRoomInfo},this.currentIdentityInfo=i,this.currentPrivateProfileInfo=a,this.isCurrentPrivateProfile=!!i&&s.equals(i.privateProfileKey,this.engine.key);const o=await this.local.get("@local/pending-recovery");if(o?.identity&&o.privateProfileKey&&s.equals(o.privateProfileKey,this.engine.key))return this.isCurrentPrivateProfile=!0,this.currentIdentityInfo=o.identity,this.currentPrivateProfileInfo=e,this.updates.attemptRecovery=o.identity,!0;const n=this.currentIdentityInfo?.swapV2;return!n||!s.equals(n.privateProfileKey,this.engine.key)||(this.updates.attemptIdentitySwap=n,!0)}async _load(){let[e,t]=await Promise.all([this._loadLocalInfo(),this._loader.loadWriterInfo()]);if(this.closing||!e)return!1;if(this.updates.attemptRecovery){const e=await this._loader.loadSelfDevice();e?.status.isActive&&(this.updates.finishIdentitySwap=this.updates.attemptRecovery)}if(this.updates.attemptIdentitySwap){const e=this.updates.attemptIdentitySwap,t=e.writerKey,[i,a,o]=await Promise.all([this._loader.input.get("@keet-private-id/device-identities",{deviceKey:t}),this._loader.input.get("@keet/devices",{key:t}),this.local.get("@local/rooms",{roomKey:this.engine.key})]);if(!i||!a||!n(e,i))return!1;const r=i.deviceProof,h=l(e.publicKey),c=await this.keet.store.createKeyPair(h);if(!s.equals(c.publicKey,e.devicePublicKey))return!1;this.isCurrentPrivateProfile=!0,this.currentPrivateProfileInfo=o,this.currentIdentityInfo=this.currentIdentityInfo.swapV2,this.updates.finishIdentitySwap={publicKey:this.updates.attemptIdentitySwap.publicKey,privateProfileKey:this.engine.key,deviceKeyPair:c,deviceProof:r,status:{isConfirmed:!0}}}this.currentWriterInfo=t;const a=this.currentRoomInfo?.processed||i.GENESIS;if(e=await this._fullRoomInfoLoad(),!e)return!1;this.events.push({type:"v2:room-changed"}),this.roomInfo.length=this._loader.core.length,this.roomInfo.fork=this._loader.core.fork,this.roomInfo.system=this._loader.systemHead,this.isCurrentPrivateProfile&&await this._loadPrivateProfileChanges(a);const o=!!this.roomInfo.selfMember?.status.isRemoved,r=!!this.roomInfo.selfMember?.status.isActive,h=!!this.roomInfo.selfDevice?.status.isActive,c=!!this.roomInfo.selfDevice&&!h,d=o||c&&!!this.currentWriterInfo,u=this.engine.writable&&h&&r,m=!!this.roomInfo.identity;return this.roomInfo.status={isWritable:u,isReadable:!0,isPrivateProfile:m,isRemoved:d},this.roomInfo.timestamps.latestSync=Date.now(),this.roomInfo.timestamps.creation=this.roomInfo.digest.creationTime,this.roomInfo.lastMessage&&(this.roomInfo.timestamps.latestChatMessage=this.roomInfo.lastMessage.timestamp),!0}_shouldUpgrade(){return this.roomInfo.selfMember.status.isModerator&&!(this.roomInfo.digest.abi.version>=this.keet.abi.autoupgrade)||null}_generateMemberUpdate(){const e=this.currentPrivateProfileInfo.selfMember,t=this.roomInfo.selfMember,s=t.profile.timestamp>0,i=e.profile.timestamp<=t.profile.timestamp;if(!e?.profile||s&&i)return null;const a={identity:this.currentIdentityInfo,privateProfile:this.currentPrivateProfileInfo};return{type:"@keet/update-member",op:{member:this.keet.internalGetMemberUpdate(a)}}}_generatePrivateProfileDispatches(){this.updates.profileDispatches=[],this.updates.profileDispatches.push({type:"@keet-private-id/update-room-status",op:{roomKey:this.roomInfo.roomKey,key:h.IsActive,status:{isActive:!1}}})}_generateDispatches(){if(this.updates.dispatches=[],this.updates.shouldUpgrade=this._shouldUpgrade(),!this.currentPrivateProfileInfo?.selfMember)return;const e=this._generateMemberUpdate();e&&this.updates.dispatches.push(e)}_generateTasks(){if(!this.updates.sharedRooms)return;this.updates.tasks=[],this.updates.sharedPreferences=[];const e=this.migratedFromAutobase&&!this.currentRoomInfo?.processed&&!this.updates.attemptRecovery&&!this.updates.attemptIdentitySwap;for(const t of this.updates.sharedRooms){const s=t.mailbox;if(t.identitySwapV2){this.updates.startIdentitySwap={...t.identitySwapV2,privateProfileKey:t.roomKey},this.updates.tasks=[this.keet.tasks.joinRoomKeys(s,{keys:t})];break}e||(t.status.isActive?this.updates.tasks.push(this.keet.tasks.joinRoomKeys(s,{keys:t,activeClock:t.activeClock,isReadOnly:t.status.isReadOnly})):this.updates.tasks.push(this.keet.tasks.leaveRoom(s,{roomKey:t.roomKey})),this.updates.sharedPreferences.push({roomKey:t.roomKey,status:t.status}))}if(!this.updates.startIdentitySwap&&this.updates.pendingInvitations)for(const e of this.updates.pendingInvitations)this.updates.tasks.push(this.keet.tasks.joinRoomInvitation(e.mailbox,{invitation:e}))}async _updateOpenRoomMember(e,t){await e.db.get("@keet/members",{key:t.attestation.memberKey})&&await e.dispatch("@keet/update-member",{member:t})}async _maybeUpdateOpenRooms(e){try{const t=this.currentRoomInfo?.selfMember?.profile.timestamp||0;if(!this.roomInfo?.selfMember||t>=this.roomInfo.selfMember.profile.timestamp)return;const i={profile:this.roomInfo.selfMember.profile,attestation:{memberKey:this.roomInfo.selfMember.key,proof:this.roomInfo.selfMember.proofs.profileAttestation}},a=[];for(const t of this.keet.rooms.values())s.equals(t.key,e)||a.push(this._updateOpenRoomMember(t,i));await Promise.allSettled(a)}catch(e){this.keet.onerror(e)}}async _run(){if(this.closing||this.keet.closing)return Promise.resolve(!1);if(this.opened||await this.ready(),!await this._load()||this.closing)return!1;if(this.roomInfo.status.isWritable&&this._generateDispatches(),this.isCurrentPrivateProfile){const e=this.roomInfo.selfDevice;e&&!e.status.isActive?this.updates.logout=!0:(this._generateTasks(),this._maybeUpdateOpenRooms(this.engine.key))}const e=this.roomInfo.selfMember,t=this.currentRoomInfo?.selfMember;return e?.status.isRemoved&&!t?.status.isRemoved&&this._generatePrivateProfileDispatches(),this._fullyProcessed()&&(this.processed=this._loader.head),!0}_fullyProcessed(){return!this.roomInfo.identity||!!this.roomInfo.selfDevice&&(!this.isCurrentPrivateProfile||!!this.updates.sharedRooms&&!this.updates.startIdentitySwap)}run(){return this._running||(this._running=this._run(),this._running.catch(t)),this._running}};
1const e=require("ready-resource"),t=require("safety-catch"),s=require("b4a"),i=require("autobee"),a=require("./loader"),{contract:{hyperschema:{getEnum:o}}}=require("../../../schema/spec"),{verifyIdentityProofs:n,generateRoomCapabilities:r,generateIdentityPairingName:l}=require("../invitations"),{RoomStatus:h}=require("../contract/identity/private"),{KeetErrorV2:c}=require("../../errors"),d=o("@keet/room-type");module.exports=class extends e{constructor(e,t,s){super(),this.keet=e,this.swarm=e.swarm,this.local=e.local,this.view=t,this.engine=s,this.isCurrentPrivateProfile=!1,this.currentPrivateProfileInfo=null,this.currentIdentityInfo=null,this.currentWriterInfo=null,this.currentRoomInfo=null,this.currentUpdate=null,this.roomInfo=null,this.migratedFromAutobase=!1,this.updated=!1,this.processed=null,this.updates={cache:null,tasks:null,contacts:null,dispatches:null,shouldUpgrade:!1,profileDispatches:null,unreadKeys:!1,activeCall:null,activeCallDevice:null,activeCallSynced:!1,sharedRooms:null,sharedPreferences:null,pendingInvitations:null,startIdentitySwap:null,attemptIdentitySwap:null,attemptRecovery:null,finishIdentitySwap:null,logout:!1,settings:null},this.events=[],this._loader=null,this._running=null}_open(){return this._loader=new a(this.local,this.view,this.engine),this._loader.ready()}async _close(){this._running&&await this._running.catch(t),this._loader&&await this._loader.close()}async _syncDigest(e){if(e||(e=await this._loader.loadDigest()),e){if(!this.keet.isValidBuildType(e))throw c.INVALID_BUILD_TYPE();this.events.push({type:"v2:room-digest-changed",value:e}),this.roomInfo.digest=e}}async _syncConfig(){const e=await this._loader.loadConfig();e&&(this.events.push({type:"v2:room-config-changed",value:e}),this.roomInfo.config=e)}async _syncRoomCapabilities(e){e||(e=await this._loader.loadCapabilities()),e&&(this.roomInfo.seed&&s.equals(this.roomInfo.seed,e.seed)||(this.events.push({type:"v2:room-capabilities-changed",value:e}),this.roomInfo.seed=e.seed,this.roomInfo.capabilities=r(this.engine.key,e.seed)))}async _syncSelf(){const[e,t,s]=await Promise.all([this._loader.loadDigest(),this._loader.loadSelfDevice(),this._loader.loadSelfMember()]);if(this.roomInfo.selfDevice=t,this.roomInfo.selfMember=s,!e||e.settings.roomType!==d.DirectMessage)return;const[i,a]=await Promise.all([this._loader.loadConfig(),this._loader.loadDMMembers()]);this.roomInfo.config=i,this.roomInfo.dm=a}async _syncSelfMember(e){if(this.events.push({type:"v2:room-member-changed",value:e}),!e||s.equals(e.key,this.currentIdentityInfo.publicKey))return this._syncSelf()}async _syncDevice(e){if(this.events.push({type:"v2:room-device-changed",value:e}),!e||s.equals(e.key,this.engine.local.key))return this._syncSelf()}_setLastMessage(e){this.events.push({type:"v2:room-last-message-changed",value:e}),this.roomInfo.lastMessage=e.message,this.roomInfo.lastMember=e.member,this.roomInfo.lastMessageReactions=e.reactions,this.roomInfo.lastMessageLabels=e.labels,this.updates.cache={member:e.member,otherMembers:e.otherMembers,device:e.device};const t=this.currentRoomInfo?.lastMessageLabels;var i,a;i=t,a=e.labels,(i&&a?i.mine.length===a.mine.length&&i.digest.total===a.digest.total&&i.digest.editedAt===a.digest.editedAt:!i&&!a)||(this.updates.labels=e.labels);const o=this.currentRoomInfo?.lastMessage;var n,r;o&&(n=o,r=e.message,s.equals(n.oplog.key,r.oplog.key)&&n.oplog.seq===r.oplog.seq)||(this.updates.chat=e.message)}async _syncLastMessage(){const e=await this._loader.loadLastMessage();e&&this._setLastMessage(e)}async _syncMessage(e){if(!e)return;const[t,s]=await Promise.all([this._loader.loadPrimaryThread(),this._loader.loadMessage(e.id)]);0===e.id.thread&&e.id.index===t.count-1&&this._setLastMessage(s),this.events.push({type:"v2:room-chat-changed",value:s})}async _syncReactions(e){const t=await this._loader.input.get("@keet/chat",{id:e.id});this.events.push({type:"v2:room-reactions-changed",value:{id:t.oplog,reactions:e}})}async _syncChatLabels(e){const t=await this._loader.loadPrimaryThread();if(0!==e.id.thread||e.id.index!==t.count-1)return;const s=await this._loader.loadLabels(e.id);this.roomInfo.lastMessageLabels=s,this.updates.labels=s}_syncJoinRequests(e){this.events.push({type:"v2:room-join-requests-changed",value:e})}async _syncReadLengths(){const e=await this._loader.loadReadLengths();e?.length&&(this.events.push({type:"v2:read-lengths-changed",value:e}),this.roomInfo.readLengths=e)}async _syncActiveCall(){this.updates.activeCallSynced=!0;const e=await this._loader.loadActiveCall();let t=null;e&&(t=await this._loader.loadActiveCallDevice(e.callKey,this.engine.local.key),this.updates.activeCallDevice=t),this.updates.activeCall=e;let s=null;e&&(s={callKey:e.callKey,createdAt:e.createdAt,selfDeviceKey:null},t&&(s.selfDeviceKey=t.deviceKey)),this.roomInfo.activeCall=s}async _syncPreferences(){const e=await this._loader.loadPreferences();e&&(this.roomInfo.preferences=e.status)}async _syncStats(e){e||(e=await this._loader.loadPrimaryThread()),e&&(this.events.push({type:"v2:room-stats-changed",value:e}),this.roomInfo.stats=e.stats)}async _syncRoomIdentity(e){e||(e=await this._loader.loadIdentity()),e&&(this.events.push({type:"v2:room-identity-changed",value:e}),this.roomInfo.identity=e)}async _syncRoomSettings(e){e||(e=await this._loader.loadSettings()),e&&(this.roomInfo.settings=e)}async _syncUnreadAnchors(){this.updates.unreadKeys=!0}async _syncMember(e){const i=[this._syncSelfMember(e)];this.roomInfo.dm?.length&&i.push(this._syncConfig().catch(t));const{lastMember:a}=this.roomInfo;a&&s.equals(a.key,e.key)&&i.push(this._syncLastMessage().catch(t)),await Promise.all(i)}async _incrementalRoomInfoLoad(e){const s=[],i=["@keet/calls","@keet/call-devices","@keet/call-members","@keet/call-streams"];for await(const{type:a,collection:o,value:n}of this._loader.input.changes({from:e})){if(this.closing||this.keet.closing)return!1;if(!i.includes(o)&&"insert"!==a)continue;let e=null;switch(o){case"@keet/system-digest":e=this._syncDigest(n);break;case"@keet/room-config":e=this._syncConfig();break;case"@keet/room-capabilities":e=this._syncRoomCapabilities(n);break;case"@keet/members":e=this._syncMember(n);break;case"@keet/devices":e=this._syncDevice(n);break;case"@keet/chat":e=this._syncMessage(n);break;case"@keet/reaction-digests":e=this._syncReactions(n);break;case"@keet/chat-label-digests":e=this._syncChatLabels(n);break;case"@keet/threads":e=this._syncStats(n);break;case"@keet-private-id/identity":e=this._syncRoomIdentity(n);break;case"@keet-private-id/settings":e=this._syncRoomSettings(n);break;case"@keet/join-requests":e=this._syncJoinRequests(n);break;case"@keet-private-id/unreads-v2":case"@keet-private-id/unreads":e=this._syncUnreadAnchors();break;case"@keet/read-lengths":e=this._syncReadLengths();break;case"@keet/calls":case"@keet/call-devices":case"@keet/call-members":case"@keet/call-streams":e=this._syncActiveCall();break;default:continue}e&&(e.catch(t),s.push(e))}return await Promise.all(s),!!this.roomInfo.digest}async _fullRoomInfoLoad(){return this.events.push({type:"v2:room-fast-forward"}),this.roomInfo={roomKey:this.engine.key,discoveryKey:this.engine.discoveryKey,encryptionKey:this.engine.encryptionKey,digest:null,stats:null,fork:0,length:0,system:null,timestamps:{creation:0,latestActivity:0,latestChatMessage:0},status:null,mailbox:null,selfDevice:null,selfMember:null,config:null,capabilities:null,identity:null,lastMessage:null,lastMember:null,lastMessageReactions:null,lastMessageLabels:null,dm:null,activeCall:null,preferences:null,settings:null},await Promise.all([this._syncDigest(null),this._syncRoomCapabilities(null),this._syncDevice(null),this._syncMember(null),this._syncStats(null),this._syncRoomIdentity(null),this._syncUnreadAnchors(),this._syncConfig(),this._syncReadLengths(),this._syncLastMessage(),this._syncActiveCall(),this._syncPreferences(),this._syncRoomSettings()]),!!this.roomInfo.digest}async _loadPrivateProfileChanges(e){if(!0===this.keet.debugDisableSyncing)return;let t=null;if(this.isCurrentPrivateProfile&&this.roomInfo.selfDevice){const[s,i,a,o]=await Promise.all([this._loader.loadContactChanges(e),this._loader.loadSharedRoomChanges(e),this._loader.loadPendingInvitations(),this.keet.getAutobeeMigrationInfo(this.engine.key)]);t=[s,i,a],this.migratedFromAutobase=!!o}t&&(this.updates.contacts=t[0],this.updates.sharedRooms=t[1],this.updates.pendingInvitations=t[2])}async _loadLocalInfo(){const[e,t,i,a]=await Promise.all([this._loader.loadLocalRoomInfo(),this._loader.loadRoomUpdate(),this._loader.loadLocalIdentityInfo(),this._loader.loadLocalPrivateProfileInfo()]);this.currentRoomInfo=e,this.currentUpdate=t,this.roomInfo={...this.currentRoomInfo},this.currentIdentityInfo=i,this.currentPrivateProfileInfo=a,this.isCurrentPrivateProfile=!!i&&s.equals(i.privateProfileKey,this.engine.key);const o=await this.local.get("@local/pending-recovery");if(o?.identity&&o.privateProfileKey&&s.equals(o.privateProfileKey,this.engine.key))return this.isCurrentPrivateProfile=!0,this.currentIdentityInfo=o.identity,this.currentPrivateProfileInfo=e,this.updates.attemptRecovery=o.identity,!0;const n=this.currentIdentityInfo?.swapV2;return!n||!s.equals(n.privateProfileKey,this.engine.key)||(this.updates.attemptIdentitySwap=n,!0)}async _load(){let[e,t]=await Promise.all([this._loadLocalInfo(),this._loader.loadWriterInfo()]);if(this.closing||!e)return!1;if(this.updates.attemptRecovery){const e=await this._loader.loadSelfDevice();e?.status.isActive&&(this.updates.finishIdentitySwap=this.updates.attemptRecovery)}if(this.updates.attemptIdentitySwap){const e=this.updates.attemptIdentitySwap,t=e.writerKey,[i,a,o]=await Promise.all([this._loader.input.get("@keet-private-id/device-identities",{deviceKey:t}),this._loader.input.get("@keet/devices",{key:t}),this.local.get("@local/rooms",{roomKey:this.engine.key})]);if(!i||!a||!n(e,i))return!1;const r=i.deviceProof,h=l(e.publicKey),c=await this.keet.store.createKeyPair(h);if(!s.equals(c.publicKey,e.devicePublicKey))return!1;this.isCurrentPrivateProfile=!0,this.currentPrivateProfileInfo=o,this.currentIdentityInfo=this.currentIdentityInfo.swapV2,this.updates.finishIdentitySwap={publicKey:this.updates.attemptIdentitySwap.publicKey,privateProfileKey:this.engine.key,deviceKeyPair:c,deviceProof:r,status:{isConfirmed:!0}}}this.currentWriterInfo=t;const a=this.currentRoomInfo?.processed||i.GENESIS;if(e=await this._fullRoomInfoLoad(),!e)return!1;this.events.push({type:"v2:room-changed"}),this.roomInfo.length=this._loader.core.length,this.roomInfo.fork=this._loader.core.fork,this.roomInfo.system=this._loader.systemHead,this.isCurrentPrivateProfile&&await this._loadPrivateProfileChanges(a);const o=!!this.roomInfo.selfMember?.status.isRemoved,r=!!this.roomInfo.selfMember?.status.isActive,h=!!this.roomInfo.selfDevice?.status.isActive,c=!!this.roomInfo.selfDevice&&!h,d=o||c&&!!this.currentWriterInfo,u=this.engine.writable&&h&&r,m=!!this.roomInfo.identity;return this.roomInfo.status={isWritable:u,isReadable:!0,isPrivateProfile:m,isRemoved:d},this.roomInfo.timestamps.latestSync=Date.now(),this.roomInfo.timestamps.creation=this.roomInfo.digest.creationTime,this.roomInfo.lastMessage&&(this.roomInfo.timestamps.latestChatMessage=this.roomInfo.lastMessage.timestamp),!0}_shouldUpgrade(){return this.roomInfo.selfMember.status.isModerator&&!(this.roomInfo.digest.abi.version>=this.keet.abi.autoupgrade)||null}_generateMemberUpdate(){const e=this.currentPrivateProfileInfo.selfMember,t=this.roomInfo.selfMember,s=t.profile.timestamp>0,i=e.profile.timestamp<=t.profile.timestamp;if(!e?.profile||s&&i)return null;const a={identity:this.currentIdentityInfo,privateProfile:this.currentPrivateProfileInfo};return{type:"@keet/update-member",op:{member:this.keet.internalGetMemberUpdate(a)}}}_generatePrivateProfileDispatches(){this.updates.profileDispatches=[],this.updates.profileDispatches.push({type:"@keet-private-id/update-room-status",op:{roomKey:this.roomInfo.roomKey,key:h.IsActive,status:{isActive:!1}}})}_generateDispatches(){if(this.updates.dispatches=[],this.updates.shouldUpgrade=this._shouldUpgrade(),!this.currentPrivateProfileInfo?.selfMember)return;const e=this._generateMemberUpdate();e&&this.updates.dispatches.push(e)}_generateTasks(){if(!this.updates.sharedRooms)return;this.updates.tasks=[],this.updates.sharedPreferences=[];const e=this.migratedFromAutobase&&!this.currentRoomInfo?.processed&&!this.updates.attemptRecovery&&!this.updates.attemptIdentitySwap;for(const t of this.updates.sharedRooms){const s=t.mailbox;if(t.identitySwapV2){this.updates.startIdentitySwap={...t.identitySwapV2,privateProfileKey:t.roomKey},this.updates.tasks=[this.keet.tasks.joinRoomKeys(s,{keys:t})];break}e||(t.status.isActive?this.updates.tasks.push(this.keet.tasks.joinRoomKeys(s,{keys:t,activeClock:t.activeClock,isReadOnly:t.status.isReadOnly})):this.updates.tasks.push(this.keet.tasks.leaveRoom(s,{roomKey:t.roomKey})),this.updates.sharedPreferences.push({roomKey:t.roomKey,status:t.status}))}if(!this.updates.startIdentitySwap&&this.updates.pendingInvitations)for(const e of this.updates.pendingInvitations)this.updates.tasks.push(this.keet.tasks.joinRoomInvitation(e.mailbox,{invitation:e}))}async _updateOpenRoomMember(e,t){await e.db.get("@keet/members",{key:t.attestation.memberKey})&&await e.dispatch("@keet/update-member",{member:t})}async _maybeUpdateOpenRooms(e){try{const t=this.currentRoomInfo?.selfMember?.profile.timestamp||0;if(!this.roomInfo?.selfMember||t>=this.roomInfo.selfMember.profile.timestamp)return;const i={profile:this.roomInfo.selfMember.profile,attestation:{memberKey:this.roomInfo.selfMember.key,proof:this.roomInfo.selfMember.proofs.profileAttestation}},a=[];for(const t of this.keet.rooms.values())s.equals(t.key,e)||a.push(this._updateOpenRoomMember(t,i));await Promise.allSettled(a)}catch(e){this.keet.onerror(e)}}async _run(){if(this.closing||this.keet.closing)return Promise.resolve(!1);if(this.opened||await this.ready(),!await this._load()||this.closing)return!1;if(this.roomInfo.status.isWritable&&this._generateDispatches(),this.isCurrentPrivateProfile){const e=this.roomInfo.selfDevice;e&&!e.status.isActive?this.updates.logout=!0:(this._generateTasks(),this._maybeUpdateOpenRooms(this.engine.key))}const e=this.roomInfo.selfMember,t=this.currentRoomInfo?.selfMember;return e?.status.isRemoved&&!t?.status.isRemoved&&this._generatePrivateProfileDispatches(),this._fullyProcessed()&&(this.processed=this._loader.head),!0}_fullyProcessed(){return!this.roomInfo.identity||!!this.roomInfo.selfDevice&&(!this.isCurrentPrivateProfile||!!this.updates.sharedRooms&&!this.updates.startIdentitySwap)}run(){return this._running||(this._running=this._run(),this._running.catch(t)),this._running}};
@holepunchto/keet-core/lib/core/tasks/contacts/request.js +1 -1
……@@ -1 +1 @@
1const e=require("hypercore-crypto"),t=require("signal-promise"),i=require("safety-catch"),{Task:o}=require("../task"),{restoreAvatar:s}=require("../../contract/avatars"),{contract:{hyperschema:{getEnum:r}}}=require("../../../../schema/spec"),{getWriterKey:a,createContactRequestOperation:n,generateRoomCapabilities:m,generatePairingCapabilities:h}=require("../../invitations"),{FEATURES:l}=require("../../../../schema/versions"),c=r("@keet/room-type");module.exports=class extends o{constructor(e){super(e);const t=this.description.sendContactRequest;this._roomKey=t.roomKey,this._memberKey=t.memberKey,this._message=t.message,this._contactInfo=t.contactInfo,this._member=null,this._contact=null,this._writerInfo=null,this._contactRoomInfo=null,this._privateContactRoom=null,this._selfMember=null,this._targetMember=null,this._roomMailbox=null,this._memberMailbox=null,this._memberMailboxDiscoveryKey=null,this._core=null,this._dmRoom=null,this._memberRoom=null,this._privateProfile=null,this._wakeupSession=null,this._watcher=null,this._privateProfileWatcher=null}async _close(){this._dmRoom&&(this._watcher&&this._dmRoom.db.unwatch(this._watcher),this.keet.internalReleaseRoom(this._dmRoom)),this._memberRoom&&this.keet.internalReleaseRoom(this._memberRoom),this._privateProfile&&(this._privateProfileWatcher&&this._privateProfile.db.unwatch(this._privateProfileWatcher),this.keet.internalReleaseRoom(this._privateProfile)),this._wakeupSession&&this._wakeupSession.destroy()}async _createRoom(){const t=e.keyPair(),i=e.randomBytes(32),o=a(t.publicKey),s=m(o,i),r={identity:this._identityInfo,privateProfile:this._privateProfileInfo},n=this.keet.internalCreateDeviceUpdate(r,o);return this._roomMailbox=s.mailboxKeyPair.publicKey,this._dmRoom=await this.keet.internalCreateRoom({settings:{roomType:c.DirectMessage},initialMembers:[this._selfMember,this._targetMember],bootstrapDevice:n,keyPair:t,seed:i}),this._message&&await this._dmRoom.dispatch("@keet/add-chat-message",{message:{text:this._message}}),!0}async _appendContactRequest(){if(!await this.keet.internalVerifyOptimisticCore(this._core)||this.closing)return;const e={message:this._message,sender:this._selfMember,mailbox:this._roomMailbox,keys:{key:this._dmRoom.key,encryptionKey:this._dmRoom.encryptionKey}},t=n(this._memberMailbox,this._identityInfo,e),i=await this.keet.internalFeatureSupported(this._privateProfile.id,l.CONTACT_BOOK),o={memberKey:this._memberKey,mailbox:this._memberMailbox,roomKey:this._dmRoom.key,status:{isBlocked:!1}};return i&&(o.status.isActive=!0,o.contactInfo={profile:this._targetMember.profile,attestation:this._targetMember.attestation}),await Promise.all([this._core.append(t),this._privateProfile.dispatch("@keet-private-id/add-contact",{contact:o})]),!0}async _loadRequestWriter(){if(this._writerInfo=await this.local.get("@local/writers",{mailbox:this._memberMailbox}),this._writerInfo)return;const t=e.keyPair(),i=a(t.publicKey);this._writerInfo={mailbox:this._memberMailbox,keyPair:t,key:i};const o=await this.keet.internalEnterLocalTransaction();try{await o.insert("@local/writers",this._writerInfo),await o.flush()}finally{await this.keet.internalExitLocalTransaction()}}_getQueryRange(){return{gte:{contact:this._targetMember.attestation.memberKey},lte:{contact:this._targetMember.attestation.memberKey}}}async _load(){if(this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready(),this._identityInfo=await this.local.get("@local/identity"),this.closing)return!1;const e=this._identityInfo.privateProfileKey;if(this._privateProfileInfo=await this.local.get("@local/rooms",{roomKey:e}),this.closing)return!1;if(this._privateProfile=this.keet.internalOpenExistingRoom(e),await this._privateProfile.ready(),this.closing)return!1;let t=!1;return t=this._contactInfo?await this._useContactInfo():await this._useRoomKey(),!(!this._targetMember?.profile?.displayName||(await this._loadRequestWriter(),this.closing||(this._core=this.store.get({keyPair:this._writerInfo.keyPair}),await this._core.ready(),this.closing||(this._privateContactRoom=await this._privateProfile.db.findOne("@keet-private-id/rooms-by-contact",this._getQueryRange()),(!t||this._privateContactRoom)&&(await this._waitForMember(),1)))))}async _useContactInfo(){const e=await this._privateProfile.db.get("@keet-private-id/contacts",{memberKey:this._memberKey});if(this._contact=e,this._memberMailbox=this._contactInfo.profile.mailbox,this._member=null,this._memberProofs=null,this._memberPairingCapabilities=h(this._memberMailbox),this._targetMember={profile:this._contactInfo.profile,attestation:this._contactInfo.attestation},e?.roomKey&&(this._contactRoomInfo=await this._privateProfile.db.get("@keet-private-id/rooms",{roomKey:this._contact.roomKey})),this.closing||this._contactRoomInfo?.status.isActive)return!1;const t=this._privateProfileInfo.selfMember;return this._selfMember={profile:t.profile,attestation:{memberKey:t.key,proof:t.proofs.profileAttestation}},!0}async _useRoomKey(){if(this._memberRoom=this.keet.internalOpenExistingRoom(this._roomKey),await this._memberRoom.ready(),this.closing)return!1;const e=this._memberRoom.db.snapshot();try{return await this._loadTargetMember(e)}finally{await e.close()}}async _loadTargetMember(e){const[t,i,o]=await Promise.all([this._privateProfile.db.get("@keet-private-id/contacts",{memberKey:this._memberKey}),e.get("@keet/members",{key:this._memberKey}),e.get("@keet/member-proofs",{key:this._memberKey})]);if(this._contact=t,this._member=i,this._memberProofs=o,this.closing||!i||!o)return!1;if(this._memberMailbox=this._member.profile.mailbox,this._memberPairingCapabilities=h(this._memberMailbox),this._targetMember={profile:this._member.profile,attestation:{memberKey:this._member.key,proof:this._memberProofs.profileAttestation}},t?.roomKey&&(this._contactRoomInfo=await this._privateProfile.db.get("@keet-private-id/rooms",{roomKey:this._contact.roomKey})),this.closing||this._contactRoomInfo?.status.isActive)return!1;const r=this._privateProfileInfo.selfMember;return this._selfMember={profile:r.profile,attestation:{memberKey:r.key,proof:r.proofs.profileAttestation}},this._targetMember.profile.avatar&&await s(e,this._memberRoom.blobs,this._targetMember.profile.avatar),!0}async _waitForMember(){if(!this._dmRoom){const e=this._privateContactRoom?.roomKey||this._contact.roomKey;this._dmRoom=this.keet.internalOpenExistingRoom(e)}this.swarmWorker.startActiveSwarming(this._memberPairingCapabilities.swarmTopic);const e=e=>{this._wakeupSession.announce(e,[{key:this._core.key,length:this._core.length}])};this._wakeupSession=this.keet.protomuxWakeup.session(this._memberMailbox,{discoveryKey:this._memberPairingCapabilities.wakeupTopic,onpeeractive:e});for(const t of this._wakeupSession.peers)t.active&&e(t);this.keet.blindPeering.addCoreBackground(this._core,{target:this._memberMailbox,referrer:this._memberMailbox,priority:1}),this._signal=new t,this._watcher=async()=>{try{const e=this._targetMember.attestation.memberKey;await this._dmRoom.db.findOne("@keet/devices-by-member-key",{gte:{memberKey:e},lte:{memberKey:e}})&&this._signal.notify()}catch(e){i(e)}},this._dmRoom.db.watch(this._watcher),this._watcher(),this._privateProfileWatcher=async()=>{try{const e=await await this._privateProfile.db.get("@keet-private-id/rooms",{roomKey:this._dmRoom.key});e&&!1===e.status.isActive&&this._signal.notify()}catch(e){i(e)}},this._privateProfile.db.watch(this._privateProfileWatcher),this._privateProfileWatcher(),await this._signal.wait(),this.swarmWorker.stopActiveSwarming(this._memberPairingCapabilities.swarmTopic)}async _run(){const e=await this._load();if(this.closing||!e)return;const t=await this._createRoom();if(this.closing||!t)return;const i=await this._appendContactRequest();!this.closing&&i&&await this._waitForMember()}};
1const e=require("hypercore-crypto"),t=require("signal-promise"),i=require("safety-catch"),{Task:o}=require("../task"),{restoreAvatar:s}=require("../../contract/avatars"),{contract:{hyperschema:{getEnum:r}}}=require("../../../../schema/spec"),{getWriterKey:a,createContactRequestOperation:n,generateRoomCapabilities:m,generatePairingCapabilities:h}=require("../../invitations"),l=r("@keet/room-type");module.exports=class extends o{constructor(e){super(e);const t=this.description.sendContactRequest;this._roomKey=t.roomKey,this._memberKey=t.memberKey,this._message=t.message,this._contactInfo=t.contactInfo,this._member=null,this._contact=null,this._writerInfo=null,this._contactRoomInfo=null,this._privateContactRoom=null,this._selfMember=null,this._targetMember=null,this._roomMailbox=null,this._memberMailbox=null,this._memberMailboxDiscoveryKey=null,this._core=null,this._dmRoom=null,this._memberRoom=null,this._privateProfile=null,this._wakeupSession=null,this._watcher=null,this._privateProfileWatcher=null}async _close(){this._dmRoom&&(this._watcher&&this._dmRoom.db.unwatch(this._watcher),this.keet.internalReleaseRoom(this._dmRoom)),this._memberRoom&&this.keet.internalReleaseRoom(this._memberRoom),this._privateProfile&&(this._privateProfileWatcher&&this._privateProfile.db.unwatch(this._privateProfileWatcher),this.keet.internalReleaseRoom(this._privateProfile)),this._wakeupSession&&this._wakeupSession.destroy()}async _createRoom(){const t=e.keyPair(),i=e.randomBytes(32),o=a(t.publicKey),s=m(o,i),r={identity:this._identityInfo,privateProfile:this._privateProfileInfo},n=this.keet.internalCreateDeviceUpdate(r,o);return this._roomMailbox=s.mailboxKeyPair.publicKey,this._dmRoom=await this.keet.internalCreateRoom({settings:{roomType:l.DirectMessage},initialMembers:[this._selfMember,this._targetMember],bootstrapDevice:n,keyPair:t,seed:i}),this._message&&await this._dmRoom.dispatch("@keet/add-chat-message",{message:{text:this._message}}),!0}async _appendContactRequest(){if(!await this.keet.internalVerifyOptimisticCore(this._core)||this.closing)return;const e={message:this._message,sender:this._selfMember,mailbox:this._roomMailbox,keys:{key:this._dmRoom.key,encryptionKey:this._dmRoom.encryptionKey}},t=n(this._memberMailbox,this._identityInfo,e),i={memberKey:this._memberKey,mailbox:this._memberMailbox,roomKey:this._dmRoom.key,status:{isActive:!0,isBlocked:!1},contactInfo:{profile:this._targetMember.profile,attestation:this._targetMember.attestation}};return await Promise.all([this._core.append(t),this._privateProfile.dispatch("@keet-private-id/add-contact",{contact:i})]),!0}async _loadRequestWriter(){if(this._writerInfo=await this.local.get("@local/writers",{mailbox:this._memberMailbox}),this._writerInfo)return;const t=e.keyPair(),i=a(t.publicKey);this._writerInfo={mailbox:this._memberMailbox,keyPair:t,key:i};const o=await this.keet.internalEnterLocalTransaction();try{await o.insert("@local/writers",this._writerInfo),await o.flush()}finally{await this.keet.internalExitLocalTransaction()}}_getQueryRange(){return{gte:{contact:this._targetMember.attestation.memberKey},lte:{contact:this._targetMember.attestation.memberKey}}}async _load(){if(this.keet.onlineBoot.opened||await this.keet.onlineBoot.ready(),this._identityInfo=await this.local.get("@local/identity"),this.closing)return!1;const e=this._identityInfo.privateProfileKey;if(this._privateProfileInfo=await this.local.get("@local/rooms",{roomKey:e}),this.closing)return!1;if(this._privateProfile=this.keet.internalOpenExistingRoom(e),await this._privateProfile.ready(),this.closing)return!1;let t=!1;return t=this._contactInfo?await this._useContactInfo():await this._useRoomKey(),!(!this._targetMember?.profile?.displayName||(await this._loadRequestWriter(),this.closing||(this._core=this.store.get({keyPair:this._writerInfo.keyPair}),await this._core.ready(),this.closing||(this._privateContactRoom=await this._privateProfile.db.findOne("@keet-private-id/rooms-by-contact",this._getQueryRange()),(!t||this._privateContactRoom)&&(await this._waitForMember(),1)))))}async _useContactInfo(){const e=await this._privateProfile.db.get("@keet-private-id/contacts",{memberKey:this._memberKey});if(this._contact=e,this._memberMailbox=this._contactInfo.profile.mailbox,this._member=null,this._memberProofs=null,this._memberPairingCapabilities=h(this._memberMailbox),this._targetMember={profile:this._contactInfo.profile,attestation:this._contactInfo.attestation},e?.roomKey&&(this._contactRoomInfo=await this._privateProfile.db.get("@keet-private-id/rooms",{roomKey:this._contact.roomKey})),this.closing||this._contactRoomInfo?.status.isActive)return!1;const t=this._privateProfileInfo.selfMember;return this._selfMember={profile:t.profile,attestation:{memberKey:t.key,proof:t.proofs.profileAttestation}},!0}async _useRoomKey(){if(this._memberRoom=this.keet.internalOpenExistingRoom(this._roomKey),await this._memberRoom.ready(),this.closing)return!1;const e=this._memberRoom.db.snapshot();try{return await this._loadTargetMember(e)}finally{await e.close()}}async _loadTargetMember(e){const[t,i,o]=await Promise.all([this._privateProfile.db.get("@keet-private-id/contacts",{memberKey:this._memberKey}),e.get("@keet/members",{key:this._memberKey}),e.get("@keet/member-proofs",{key:this._memberKey})]);if(this._contact=t,this._member=i,this._memberProofs=o,this.closing||!i||!o)return!1;if(this._memberMailbox=this._member.profile.mailbox,this._memberPairingCapabilities=h(this._memberMailbox),this._targetMember={profile:this._member.profile,attestation:{memberKey:this._member.key,proof:this._memberProofs.profileAttestation}},t?.roomKey&&(this._contactRoomInfo=await this._privateProfile.db.get("@keet-private-id/rooms",{roomKey:this._contact.roomKey})),this.closing||this._contactRoomInfo?.status.isActive)return!1;const r=this._privateProfileInfo.selfMember;return this._selfMember={profile:r.profile,attestation:{memberKey:r.key,proof:r.proofs.profileAttestation}},this._targetMember.profile.avatar&&await s(e,this._memberRoom.blobs,this._targetMember.profile.avatar),!0}async _waitForMember(){if(!this._dmRoom){const e=this._privateContactRoom?.roomKey||this._contact.roomKey;this._dmRoom=this.keet.internalOpenExistingRoom(e)}this.swarmWorker.startActiveSwarming(this._memberPairingCapabilities.swarmTopic);const e=e=>{this._wakeupSession.announce(e,[{key:this._core.key,length:this._core.length}])};this._wakeupSession=this.keet.protomuxWakeup.session(this._memberMailbox,{discoveryKey:this._memberPairingCapabilities.wakeupTopic,onpeeractive:e});for(const t of this._wakeupSession.peers)t.active&&e(t);this.keet.blindPeering.addCoreBackground(this._core,{target:this._memberMailbox,referrer:this._memberMailbox,priority:1}),this._signal=new t,this._watcher=async()=>{try{const e=this._targetMember.attestation.memberKey;await this._dmRoom.db.findOne("@keet/devices-by-member-key",{gte:{memberKey:e},lte:{memberKey:e}})&&this._signal.notify()}catch(e){i(e)}},this._dmRoom.db.watch(this._watcher),this._watcher(),this._privateProfileWatcher=async()=>{try{const e=await await this._privateProfile.db.get("@keet-private-id/rooms",{roomKey:this._dmRoom.key});e&&!1===e.status.isActive&&this._signal.notify()}catch(e){i(e)}},this._privateProfile.db.watch(this._privateProfileWatcher),this._privateProfileWatcher(),await this._signal.wait(),this.swarmWorker.stopActiveSwarming(this._memberPairingCapabilities.swarmTopic)}async _run(){const e=await this._load();if(this.closing||!e)return;const t=await this._createRoom();if(this.closing||!t)return;const i=await this._appendContactRequest();!this.closing&&i&&await this._waitForMember()}};
@holepunchto/keet-core/lib/core/tasks/pairing/keys.js +1 -1
……@@ -1 +1 @@
1const t=require("b4a"),i=require("safety-catch"),e=require("signal-promise"),{createMemberProofJoinOperation:s}=require("../../invitations"),{getBootOption:o}=require("../../room-engine"),{Task:n}=require("../task"),a=12e4;module.exports=class extends n{constructor(t){super(t);const i=this.description.joinRoomKeys;this._keys=i.keys,this._activeClock=i.activeClock||0,this._isReadOnly=i.isReadOnly,this._identityInfo=null,this._writerInfo=null,this._roomInfo=null,this._room=null,this._timer=null,this._signal=null,this._watcher=null,this._localWatcher=null,this._released=!1}async _close(){this._signal&&this._signal.notify(new Error("Fast join closed before resolving digest")),this._localWatcher&&this.local.unwatch(this._localWatcher),this._core&&await this._core.close(),this._room&&this.keet.internalReleaseRoom(this._room),this._timer&&clearTimeout(this._timer)}async _appendJoinRequest(){if(!await this.keet.internalVerifyOptimisticCore(this._core)||this.closing)return;const t={device:this.keet.internalCreateDeviceUpdate(this._identityInfo,this._core.key),member:this.keet.internalGetMemberUpdate(this._identityInfo)};let i=null;i=this._keys.initiator?this.keet.internalGetHeads(this._keys.initiator,this._room):[{key:this._keys.roomKey,length:1}];const e=s(this._keys.mailbox,t,{heads:i});await this.keet.internalAppendOptimisticOperation(this._core.key,e)}async _saveWriter(){this._writerInfo.pending=!1,this._activeClock&&(this._writerInfo.activeClock=this._activeClock);const t=await this.keet.internalEnterLocalTransaction();try{await t.insert("@local/writers",this._writerInfo),await t.flush()}finally{await this.keet.internalExitLocalTransaction()}}async _openRoom(){let t=o(this._keys.bootFrom,this._keys.fastForwardTo);this._roomInfo&&t?.head&&(t=null),this._room=this.keet.internalOpenRoom(this._keys.roomKey,this._keys.encryptionKey,{bootFrom:t,mailbox:this._keys.mailbox,bigBatches:!!this._keys.identitySwap}),await this._room.ready()}_isInitiator(i){const e=this._keys.initiator;return!!e&&t.equals(i.key,e.key)}_shouldRotate(t){return!(!t||this._isInitiator(t))&&(t.activeClock||0)<this._activeClock}async _doRun(){const s=await this.local.get("@local/pending-recovery");if(s?.identity&&s.privateProfileKey&&t.equals(s.privateProfileKey,this._keys.roomKey)?this._identityInfo={identity:s.identity,privateProfile:null}:this._identityInfo=await this.keet.internalGetIdentityInfo(),this.closing)return;const[o,n]=await Promise.all([this.local.get("@local/writers",{mailbox:this._keys.mailbox}),this.local.get("@local/rooms",{roomKey:this._keys.roomKey})]);this._roomInfo=n;const r=this._shouldRotate(o);if(this._writerInfo=await this.keet.internalEnsureWriter(this._keys.roomKey,this._keys.mailbox,{rotate:r,activeClock:this._activeClock}),this._core=this.store.get(this._writerInfo.key),await this._core.ready(),this.closing)return;if(this._roomInfo&&await this._openRoom(),this.closing)return;if(0!==this._core.length||this._isReadOnly||await this._appendJoinRequest(),this.closing)return;const h=this._isInitiator(this._writerInfo)&&this._writerInfo.activeClock!==this._activeClock;if(this._core.length>0&&(this._writerInfo.pending||h)&&await this._saveWriter(),this.closing)return;this._room||await this._openRoom(),this._isReadOnly||await this._room.engine.setLocal(this._core.key),this._signal=new e;const l=this._core.key;this._localWatcher=async()=>{try{const i=await this.local.get("@local/rooms",{roomKey:this._keys.roomKey});if(!i)return;if(this._isReadOnly)return void this._signal.notify();const e=i.selfDevice&&t.equals(i.selfDevice.key,l);i.status.isWritable&&e&&this._signal.notify()}catch(t){i(t)}},this.local.watch(this._localWatcher),this._localWatcher(),await this._signal.wait(a)}_release(){this._released||(this._released=!0,this.keet.debugRunningFastJoins--,this.keet.internalFastJoinSemaphore.signal())}async _run(){await this.keet.internalFastJoinSemaphore.wait(),this.keet.debugRunningFastJoins++,this.keet.debugMaxRunningFastJoins=Math.max(this.keet.debugMaxRunningFastJoins,this.keet.debugRunningFastJoins);try{if(this.closing)return;this._timer=setTimeout(()=>this._release(),a),await this._doRun()}finally{this._release()}}};
1const t=require("b4a"),i=require("safety-catch"),e=require("signal-promise"),{createMemberProofJoinOperation:s}=require("../../invitations"),{getBootOption:o}=require("../../room-engine"),{Task:n}=require("../task"),a=12e4;module.exports=class extends n{constructor(t){super(t);const i=this.description.joinRoomKeys;this._keys=i.keys,this._activeClock=i.activeClock||0,this._isReadOnly=i.isReadOnly,this._identityInfo=null,this._writerInfo=null,this._roomInfo=null,this._room=null,this._timer=null,this._signal=null,this._watcher=null,this._localWatcher=null,this._released=!1}async _close(){this._signal&&this._signal.notify(new Error("Fast join closed before resolving digest")),this._localWatcher&&this.local.unwatch(this._localWatcher),this._core&&await this._core.close(),this._room&&this.keet.internalReleaseRoom(this._room),this._timer&&clearTimeout(this._timer)}async _appendJoinRequest(){if(!await this.keet.internalVerifyOptimisticCore(this._core)||this.closing)return;const t={device:this.keet.internalCreateDeviceUpdate(this._identityInfo,this._core.key),member:this.keet.internalGetMemberUpdate(this._identityInfo)};let i=null;i=this._keys.initiator?this.keet.internalGetHeads(this._keys.initiator,this._room):[{key:this._keys.roomKey,length:1}];const e=s(this._keys.mailbox,t,{heads:i});await this.keet.internalAppendOptimisticOperation(this._core.key,e)}async _saveWriter(){this._writerInfo.pending=!1,this._activeClock&&(this._writerInfo.activeClock=this._activeClock);const t=await this.keet.internalEnterLocalTransaction();try{await t.insert("@local/writers",this._writerInfo),await t.flush()}finally{await this.keet.internalExitLocalTransaction()}}async _openRoom(){let t=o(this._keys.bootFrom,this._keys.fastForwardTo);this._roomInfo&&t?.head&&(t=null),this._room=this.keet.internalOpenRoom(this._keys.roomKey,this._keys.encryptionKey,{bootFrom:t,mailbox:this._keys.mailbox,bigBatches:!!this._keys.identitySwap}),await this._room.ready()}_isInitiator(i){const e=this._keys.initiator;return!!e&&t.equals(i.key,e.key)}_shouldRotate(t){if(!t)return!1;if(!this._isInitiator(t)&&(t.activeClock||0)<this._activeClock)return!0;const i=this._roomInfo;return!!i?.selfMember?.status.isActive&&!i.selfDevice?.status.isActive}async _doRun(){const s=await this.local.get("@local/pending-recovery");if(s?.identity&&s.privateProfileKey&&t.equals(s.privateProfileKey,this._keys.roomKey)?this._identityInfo={identity:s.identity,privateProfile:null}:this._identityInfo=await this.keet.internalGetIdentityInfo(),this.closing)return;const[o,n]=await Promise.all([this.local.get("@local/writers",{mailbox:this._keys.mailbox}),this.local.get("@local/rooms",{roomKey:this._keys.roomKey})]);this._roomInfo=n;const r=this._shouldRotate(o);if(this._writerInfo=await this.keet.internalEnsureWriter(this._keys.roomKey,this._keys.mailbox,{rotate:r,activeClock:this._activeClock}),this._core=this.store.get(this._writerInfo.key),await this._core.ready(),this.closing)return;if(this._roomInfo&&await this._openRoom(),this.closing)return;if(0!==this._core.length||this._isReadOnly||await this._appendJoinRequest(),this.closing)return;const h=this._isInitiator(this._writerInfo)&&this._writerInfo.activeClock!==this._activeClock;if(this._core.length>0&&(this._writerInfo.pending||h)&&await this._saveWriter(),this.closing)return;if(this._room||await this._openRoom(),this._isReadOnly||await this._room.engine.setLocal(this._core.key),this.closing)return;this._signal=new e;const l=this._core.key;this._localWatcher=async()=>{try{const i=await this.local.get("@local/rooms",{roomKey:this._keys.roomKey});if(!i)return;if(this._isReadOnly)return void this._signal.notify();const e=i.selfDevice&&t.equals(i.selfDevice.key,l);i.status.isWritable&&e&&this._signal.notify()}catch(t){i(t)}},this.local.watch(this._localWatcher),this._localWatcher(),await this._signal.wait(a)}_release(){this._released||(this._released=!0,this.keet.debugRunningFastJoins--,this.keet.internalFastJoinSemaphore.signal())}async _run(){await this.keet.internalFastJoinSemaphore.wait(),this.keet.debugRunningFastJoins++,this.keet.debugMaxRunningFastJoins=Math.max(this.keet.debugMaxRunningFastJoins,this.keet.debugRunningFastJoins);try{if(this.closing)return;this._timer=setTimeout(()=>this._release(),a),await this._doRun()}finally{this._release()}}};
@holepunchto/keet-core/lib/core/tasks/pairing/response.js +1 -1
……@@ -1 +1 @@
1const{Task:e}=require("../task"),{getResponseCoreManifest:i}=require("../../invitations");module.exports=class extends e{constructor(e){super(e);const i=this.description.joinRoomResponse;this._keyPair=i.keyPair,this._response=i.response,this._mailbox=i.mailbox,this._core=null}async _close(){this._core&&await this._core.close()}async _run(){if(this._core=this.store.get({keyPair:this._keyPair,manifest:i(this._keyPair.publicKey)}),await this._core.ready(),0===this._core.length){if(await this.keet.internalVerifyOptimisticCore(this._core),this.closing)return;0===this._core.length&&await this._core.append(this._response,{maxLength:1})}await this.keet.blindPeering.addCore(this._core,{target:this._mailbox,referrer:this._mailbox,priority:1}),await new Promise(e=>setTimeout(e,this.keet.internalPairingTimeout))}};
1const{Task:e}=require("../task"),{getResponseCoreManifest:i}=require("../../invitations");module.exports=class extends e{constructor(e){super(e);const i=this.description.joinRoomResponse;this._keyPair=i.keyPair,this._response=i.response,this._mailbox=i.mailbox,this._core=null}async _close(){this._core&&await this._core.close()}async _run(){if(this._core=this.store.get({keyPair:this._keyPair,manifest:i(this._keyPair.publicKey)}),await this._core.ready(),0===this._core.length){if(await this.keet.internalVerifyOptimisticCore(this._core),this.closing)return;0===this._core.length&&await this._core.append(this._response,{maxLength:1})}try{await this.keet.blindPeering.addCore(this._core,{target:this._mailbox,referrer:this._mailbox,priority:1})}catch(e){this.keet.onerror(e)}await new Promise(e=>setTimeout(e,this.keet.internalPairingTimeout))}};
@holepunchto/keet-core/lib/errors/index.js +1 -1
……@@ -1 +1 @@
1const t=require("ready-resource"),e=require("scope-lock"),{KeetContractError:r}=require("../core/contract/errors"),_={INVALID_INVITATION_TYPE:"INVALID_INVITATION_TYPE",UNKNOWN_EXPIRATION:"UNKNOWN_EXPIRATION",INVALID_INVITE:"INVALID_INVITE",INVALID_CONTACT_INFO:"INVALID_CONTACT_INFO",MODERATORS_ONLY:"MODERATORS_ONLY",UNEXPECTED_ERROR:"UNEXPECTED_ERROR",INVALID_BUILD_TYPE:"INVALID_BUILD_TYPE",KEET_IS_CLOSING:"KEET_IS_CLOSING",INVALID_SETTINGS_KEY:"INVALID_SETTINGS_KEY",INVALID_ROOM_TYPE:"INVALID_ROOM_TYPE",INVALID_FILE_PATH:"INVALID_FILE_PATH",ROOM_DISABLED:"ROOM_DISABLED",UPDATE_DEVICE_FAILED:"UPDATE_DEVICE_FAILED",CALL_DISABLED:"CALL_DISABLED",CALL_SWARM_ACTIVE:"CALL_SWARM_ACTIVE",CALL_SWARM_SUSPENDED:"CALL_SWARM_SUSPENDED",CALL_NOT_ACTIVE:"CALL_NOT_ACTIVE",CALL_DISPATCH_REJECTED:"CALL_DISPATCH_REJECTED"};class s extends Error{constructor(t,e,r={},_){super(e?`${t}: ${e}`:t),this.isKeetError=!0,this.code=t,this.details=r,this.timestamp=Date.now(),Error.captureStackTrace&&Error.captureStackTrace(this,_??this.constructor)}static isKeetError(t){return t?.isKeetError}static fromError(t,e={}){if(s.isKeetError(t))return t;const r=function(t,e){return t.cause?.code?t.cause.code:e.prefix?e.prefix:e.roomKey?"UNEXPECTED_ROOM_ERROR":"UNEXPECTED_ERROR"}(t,e),_={};e.roomKey&&(_.roomKey=e.roomKey),e.coreKey&&(_.coreKey=e.coreKey);const I=new s(r,t.message,_);return I.cause=t,I.stack=t.stack,I}static INVALID_INVITATION_TYPE(t="Attempting to use a device sync invitation as a room invitation",e={}){return new s(_.INVALID_INVITATION_TYPE,t,e,s.INVALID_INVITATION_TYPE)}static UNKNOWN_EXPIRATION(t="Unknown expiration",e={}){return new s(_.UNKNOWN_EXPIRATION,t,e,s.UNKNOWN_EXPIRATION)}static INVALID_INVITE(t="Invalid invite",e={}){return new s(_.INVALID_INVITE,t,e,s.INVALID_INVITE)}static INVALID_CONTACT_INFO(t="Invalid contact info",e={}){return new s(_.INVALID_CONTACT_INFO,t,e,s.INVALID_CONTACT_INFO)}static MODERATORS_ONLY(t="",e={}){return new s(_.MODERATORS_ONLY,t,e,s.MODERATORS_ONLY)}static UNEXPECTED_ERROR(t="",e={}){return new s(_.UNEXPECTED_ERROR,t,e,s.UNEXPECTED_ERROR)}static INVALID_BUILD_TYPE(t="",e={}){return new s(_.INVALID_BUILD_TYPE,t,e,s.INVALID_BUILD_TYPE)}static KEET_IS_CLOSING(t="",e={}){return new s(_.KEET_IS_CLOSING,t,e,s.KEET_IS_CLOSING)}static INVALID_SETTINGS_KEY(t="Invalid settings key",e={}){return new s(_.INVALID_SETTINGS_KEY,t,e,s.INVALID_SETTINGS_KEY)}static INVALID_ROOM_TYPE(t="Invalid room type",e={}){return new s(_.INVALID_ROOM_TYPE,t,e,s.INVALID_ROOM_TYPE)}static INVALID_FILE_PATH(t="Invalid file path",e={}){return new s(_.INVALID_FILE_PATH,t,e,s.INVALID_FILE_PATH)}static ROOM_DISABLED(t="Room is disabled",e={}){return new s(_.ROOM_DISABLED,t,e,s.ROOM_DISABLED)}static UPDATE_DEVICE_FAILED(t="Failed to update device",e={}){return new s(_.UPDATE_DEVICE_FAILED,t,e,s.UPDATE_DEVICE_FAILED)}static CALL_DISABLED(t="",e={}){return new s(_.CALL_DISABLED,t,e,s.CALL_DISABLED)}static CALL_SWARM_ACTIVE(t="",e={}){return new s(_.CALL_SWARM_ACTIVE,t,e,s.CALL_SWARM_ACTIVE)}static CALL_SWARM_SUSPENDED(t="",e={}){return new s(_.CALL_SWARM_SUSPENDED,t,e,s.CALL_SWARM_SUSPENDED)}static CALL_NOT_ACTIVE(t="",e={}){return new s(_.CALL_NOT_ACTIVE,t,e,s.CALL_NOT_ACTIVE)}static CALL_DISPATCH_REJECTED(t="",e={}){return new s(_.CALL_DISPATCH_REJECTED,t,e,s.CALL_DISPATCH_REJECTED)}}module.exports={ERRORS:_,KeetErrorV2:s,KeetErrorManager:class extends t{constructor(t,r){super(),this.keet=t,this.errors=[],this._flushLock=new e({debounce:!0}),this._flushInterval=r.errorFlushInterval||1e4,this._flushTimerDisabled=null===r.errorFlushTimer,this._flushTimer=null,this._gcMaxAge=r.errorGcMaxAge||12096e5,this.ready().catch(t.onerror)}async _open(){await this.keet.ready(),await this._gc()}async _close(){this._flushTimerDisabled=!0,this._resetTimeout(),await this._flush()}add(t){this.errors.push(t),this.keet.emit("caught-error",t),this._flushTimerDisabled||this._scheduleFlush()}normalize(t,e={}){return s.isKeetError(t)?t:r.isContractError(t)?(t.timestamp=Date.now(),t):s.fromError(t,e)}_scheduleFlush(){this._flushTimer||(this._flushTimer=setTimeout(this._flush.bind(this),this._flushInterval))}_resetTimeout(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=null)}debugPauseFlush(){this._resetTimeout()}debugResumeFlush(){this._scheduleFlush()}async _flush(){if(!this.keet.readOnly&&await this._flushLock.lock())try{const t=await this.keet.internalEnterLocalTransaction();try{const e=[...this.errors];this.errors=[];for(const r of e)await t.insert("@local/errors",{code:r.code,message:r.message,stack:r.stack,details:r.details,timestamp:r.timestamp});await t.flush()}finally{await this.keet.internalExitLocalTransaction()}}finally{this._flushLock.unlock(),this._resetTimeout()}}async _gc(){if(this.closing)return;const t=Date.now()-this._gcMaxAge,e=await this.keet.local.find("@local/errors",{lte:{timestamp:t}}).toArray(),r=await this.keet.internalEnterLocalTransaction();try{for(const t of e)await r.delete("@local/errors",t);await r.flush()}finally{await this.keet.internalExitLocalTransaction()}}}};
1const t=require("ready-resource"),e=require("scope-lock"),{KeetContractError:r}=require("../core/contract/errors"),_={INVALID_INVITATION_TYPE:"INVALID_INVITATION_TYPE",UNKNOWN_EXPIRATION:"UNKNOWN_EXPIRATION",INVALID_INVITE:"INVALID_INVITE",INVALID_CONTACT_INFO:"INVALID_CONTACT_INFO",MODERATORS_ONLY:"MODERATORS_ONLY",UNEXPECTED_ERROR:"UNEXPECTED_ERROR",INVALID_BUILD_TYPE:"INVALID_BUILD_TYPE",KEET_IS_CLOSING:"KEET_IS_CLOSING",INVALID_SETTINGS_KEY:"INVALID_SETTINGS_KEY",INVALID_ROOM_TYPE:"INVALID_ROOM_TYPE",INVALID_FILE_PATH:"INVALID_FILE_PATH",ROOM_DISABLED:"ROOM_DISABLED",UPDATE_DEVICE_FAILED:"UPDATE_DEVICE_FAILED",CALL_DISABLED:"CALL_DISABLED",MEMBER_REMOVED:"MEMBER_REMOVED",CALL_SWARM_ACTIVE:"CALL_SWARM_ACTIVE",CALL_SWARM_SUSPENDED:"CALL_SWARM_SUSPENDED",CALL_NOT_ACTIVE:"CALL_NOT_ACTIVE",CALL_DISPATCH_REJECTED:"CALL_DISPATCH_REJECTED"};class E extends Error{constructor(t,e,r={},_){super(e?`${t}: ${e}`:t),this.isKeetError=!0,this.code=t,this.details=r,this.timestamp=Date.now(),Error.captureStackTrace&&Error.captureStackTrace(this,_??this.constructor)}static isKeetError(t){return t?.isKeetError}static fromError(t,e={}){if(E.isKeetError(t))return t;const r=function(t,e){return t.cause?.code?t.cause.code:e.prefix?e.prefix:e.roomKey?"UNEXPECTED_ROOM_ERROR":"UNEXPECTED_ERROR"}(t,e),_={};e.roomKey&&(_.roomKey=e.roomKey),e.coreKey&&(_.coreKey=e.coreKey);const s=new E(r,t.message,_);return s.cause=t,s.stack=t.stack,s}static INVALID_INVITATION_TYPE(t="Attempting to use a device sync invitation as a room invitation",e={}){return new E(_.INVALID_INVITATION_TYPE,t,e,E.INVALID_INVITATION_TYPE)}static UNKNOWN_EXPIRATION(t="Unknown expiration",e={}){return new E(_.UNKNOWN_EXPIRATION,t,e,E.UNKNOWN_EXPIRATION)}static INVALID_INVITE(t="Invalid invite",e={}){return new E(_.INVALID_INVITE,t,e,E.INVALID_INVITE)}static INVALID_CONTACT_INFO(t="Invalid contact info",e={}){return new E(_.INVALID_CONTACT_INFO,t,e,E.INVALID_CONTACT_INFO)}static MODERATORS_ONLY(t="",e={}){return new E(_.MODERATORS_ONLY,t,e,E.MODERATORS_ONLY)}static UNEXPECTED_ERROR(t="",e={}){return new E(_.UNEXPECTED_ERROR,t,e,E.UNEXPECTED_ERROR)}static INVALID_BUILD_TYPE(t="",e={}){return new E(_.INVALID_BUILD_TYPE,t,e,E.INVALID_BUILD_TYPE)}static KEET_IS_CLOSING(t="",e={}){return new E(_.KEET_IS_CLOSING,t,e,E.KEET_IS_CLOSING)}static INVALID_SETTINGS_KEY(t="Invalid settings key",e={}){return new E(_.INVALID_SETTINGS_KEY,t,e,E.INVALID_SETTINGS_KEY)}static INVALID_ROOM_TYPE(t="Invalid room type",e={}){return new E(_.INVALID_ROOM_TYPE,t,e,E.INVALID_ROOM_TYPE)}static INVALID_FILE_PATH(t="Invalid file path",e={}){return new E(_.INVALID_FILE_PATH,t,e,E.INVALID_FILE_PATH)}static ROOM_DISABLED(t="Room is disabled",e={}){return new E(_.ROOM_DISABLED,t,e,E.ROOM_DISABLED)}static UPDATE_DEVICE_FAILED(t="Failed to update device",e={}){return new E(_.UPDATE_DEVICE_FAILED,t,e,E.UPDATE_DEVICE_FAILED)}static CALL_DISABLED(t="",e={}){return new E(_.CALL_DISABLED,t,e,E.CALL_DISABLED)}static MEMBER_REMOVED(t="",e={}){return new E(_.MEMBER_REMOVED,t,e,E.MEMBER_REMOVED)}static CALL_SWARM_ACTIVE(t="",e={}){return new E(_.CALL_SWARM_ACTIVE,t,e,E.CALL_SWARM_ACTIVE)}static CALL_SWARM_SUSPENDED(t="",e={}){return new E(_.CALL_SWARM_SUSPENDED,t,e,E.CALL_SWARM_SUSPENDED)}static CALL_NOT_ACTIVE(t="",e={}){return new E(_.CALL_NOT_ACTIVE,t,e,E.CALL_NOT_ACTIVE)}static CALL_DISPATCH_REJECTED(t="",e={}){return new E(_.CALL_DISPATCH_REJECTED,t,e,E.CALL_DISPATCH_REJECTED)}}module.exports={ERRORS:_,KeetErrorV2:E,KeetErrorManager:class extends t{constructor(t,r){super(),this.keet=t,this.errors=[],this._flushLock=new e({debounce:!0}),this._flushInterval=r.errorFlushInterval||1e4,this._flushTimerDisabled=null===r.errorFlushTimer,this._flushTimer=null,this._gcMaxAge=r.errorGcMaxAge||12096e5,this.ready().catch(t.onerror)}async _open(){await this.keet.ready(),await this._gc()}async _close(){this._flushTimerDisabled=!0,this._resetTimeout(),await this._flush()}add(t){this.errors.push(t),this.keet.emit("caught-error",t),this._flushTimerDisabled||this._scheduleFlush()}normalize(t,e={}){return E.isKeetError(t)?t:r.isContractError(t)?(t.timestamp=Date.now(),t):E.fromError(t,e)}_scheduleFlush(){this._flushTimer||(this._flushTimer=setTimeout(this._flush.bind(this),this._flushInterval))}_resetTimeout(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=null)}debugPauseFlush(){this._resetTimeout()}debugResumeFlush(){this._scheduleFlush()}async _flush(){if(!this.keet.readOnly&&await this._flushLock.lock())try{const t=await this.keet.internalEnterLocalTransaction();try{const e=[...this.errors];this.errors=[];for(const r of e)await t.insert("@local/errors",{code:r.code,message:r.message,stack:r.stack,details:r.details,timestamp:r.timestamp});await t.flush()}finally{await this.keet.internalExitLocalTransaction()}}finally{this._flushLock.unlock(),this._resetTimeout()}}async _gc(){if(this.closing)return;const t=Date.now()-this._gcMaxAge,e=await this.keet.local.find("@local/errors",{lte:{timestamp:t}}).toArray(),r=await this.keet.internalEnterLocalTransaction();try{for(const t of e)await r.delete("@local/errors",t);await r.flush()}finally{await this.keet.internalExitLocalTransaction()}}}};
@holepunchto/keet-core/lib/rpc/server.js +1 -1
……@@ -1 +1 @@
1const e=require("tiny-buffer-rpc/any"),{pipeline:r}=require("streamx");function s(){}module.exports=function(t,o){o.register(0,{request:e,response:e,onrequest:e=>t.api.swarm.ready(...e)}),o.register(1,{request:e,response:e,onrequest:e=>t.api.core.getVersion(...e)}),o.register(2,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeRoomVersion(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(3,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeForceUpdates(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(4,{request:e,response:e,onrequest:e=>t.api.core.upgradeRoom(...e)}),o.register(5,{request:e,response:e,onrequest:e=>t.api.core.updateUserSettings(...e)}),o.register(6,{request:e,response:e,onrequest:e=>t.api.core.getIdentity(...e)}),o.register(7,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeIdentity(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(8,{request:e,response:e,onrequest:e=>t.api.core.generateIdentity(...e)}),o.register(9,{request:e,response:e,onrequest:e=>t.api.core.restoreIdentity(...e)}),o.register(10,{request:e,response:e,onrequest:e=>t.api.core.getRecoveryPhrase(...e)}),o.register(11,{request:e,response:e,onrequest:e=>t.api.core.getEncryptedRecoveryPhrase(...e)}),o.register(12,{request:e,response:e,onrequest:e=>t.api.core.decryptEncryptedRecoveryPhrase(...e)}),o.register(13,{request:e,response:e,onrequest:e=>t.api.core.freeRecoveryPhrase(...e)}),o.register(14,{request:e,response:e,onrequest:e=>t.api.core.confirmRecoveryPhrase(...e)}),o.register(15,{request:e,response:e,onrequest:e=>t.api.core.storeRecoveryPhrase(...e)}),o.register(16,{request:e,response:e,onrequest:e=>t.api.core.confirmIdentity(...e)}),o.register(17,{request:e,response:e,onrequest:e=>t.api.core.confirmPairingRequest(...e)}),o.register(18,{request:e,response:e,dedup:!1,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeIdentityPairingRequests(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(19,{request:e,response:e,onrequest:e=>t.api.core.updateIdentityProfile(...e)}),o.register(20,{request:e,response:e,onrequest:e=>t.api.core.updateIdentityDevice(...e)}),o.register(21,{request:e,response:e,onrequest:e=>t.api.core.removeIdentityDevice(...e)}),o.register(22,{request:e,response:e,onrequest:e=>t.api.core.getLinkInfo(...e)}),o.register(23,{request:e,response:e,onrequest:e=>t.api.core.startPairingIdentity(...e)}),o.register(24,{request:e,response:e,onrequest:e=>t.api.core.pairIdentity(...e)}),o.register(25,{request:e,response:e,onrequest:e=>t.api.core.createRoom(...e)}),o.register(26,{request:e,response:e,onrequest:e=>t.api.core.pairRoom(...e)}),o.register(27,{request:e,response:e,onrequest:e=>t.api.core.leaveRoom(...e)}),o.register(28,{request:e,response:e,onrequest:e=>t.api.core.startPairingRoom(...e)}),o.register(29,{request:e,response:e,onrequest:e=>t.api.core.stopPairingRoom(...e)}),o.register(30,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribePendingRooms(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(31,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribePushNotificationChanges(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(32,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeActivateRoom(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(33,{request:e,response:e,onrequest:e=>t.api.core.getRoomKeys(...e)}),o.register(34,{request:e,response:e,onrequest:e=>t.api.core.resyncPrivateProfile(...e)}),o.register(35,{request:e,response:e,onrequest:e=>t.api.core.getTipSize(...e)}),o.register(36,{request:e,response:e,onrequest:e=>t.api.core.bookmark(...e)}),o.register(37,{request:e,response:e,onrequest:e=>t.api.core.unbookmark(...e)}),o.register(38,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeBookmarks(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(39,{request:e,response:e,onrequest:e=>t.api.core.getRoomInfo(...e)}),o.register(40,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeRoomInfo(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(41,{request:e,response:e,onrequest:e=>t.api.core.searchRooms(...e)}),o.register(42,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.searchPublicRooms(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(43,{request:e,response:e,onrequest:e=>t.api.core.getRecentRooms(...e)}),o.register(44,{request:e,response:e,onrequest:e=>t.api.core.getLocalRoomMetadata(...e)}),o.register(45,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeRecentRooms(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(46,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeFavoriteRooms(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(47,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeUnreadActivity(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(48,{request:e,response:e,onrequest:e=>t.api.core.setRoomUnread(...e)}),o.register(49,{request:e,response:e,onrequest:e=>t.api.core.bumpRoomPriority(...e)}),o.register(50,{request:e,response:e,onrequest:e=>t.api.core.snoozeRoom(...e)}),o.register(51,{request:e,response:e,onrequest:e=>t.api.core.addDevice(...e)}),o.register(52,{request:e,response:e,onrequest:e=>t.api.core.removeDevice(...e)}),o.register(53,{request:e,response:e,onrequest:e=>t.api.core.getDevice(...e)}),o.register(54,{request:e,response:e,onrequest:e=>t.api.core.getDevices(...e)}),o.register(55,{request:e,response:e,onrequest:e=>t.api.core.getDevicesByMemberId(...e)}),o.register(56,{request:e,response:e,onrequest:e=>t.api.core.getCurrentDeviceId(...e)}),o.register(57,{request:e,response:e,onrequest:e=>t.api.core.moveIndexer(...e)}),o.register(58,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeDevice(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(59,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeDevices(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(60,{request:e,response:e,onrequest:e=>t.api.core.createIdentityInvitation(...e)}),o.register(61,{request:e,response:e,onrequest:e=>t.api.core.createInvitation(...e)}),o.register(62,{request:e,response:e,onrequest:e=>t.api.core.updateMember(...e)}),o.register(63,{request:e,response:e,onrequest:e=>t.api.core.isMemberMuted(...e)}),o.register(64,{request:e,response:e,onrequest:e=>t.api.core.getMember(...e)}),o.register(65,{request:e,response:e,onrequest:e=>t.api.core.removeMember(...e)}),o.register(66,{request:e,response:e,onrequest:e=>t.api.core.getMembers(...e)}),o.register(67,{request:e,response:e,onrequest:e=>t.api.core.getActiveMembers(...e)}),o.register(68,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeActiveMembers(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(69,{request:e,response:e,onrequest:e=>t.api.core.getModerators(...e)}),o.register(70,{request:e,response:e,onrequest:e=>t.api.core.getMemberCount(...e)}),o.register(71,{request:e,response:e,onrequest:e=>t.api.core.getMemberForDevice(...e)}),o.register(72,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeMemberCount(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(73,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeMember(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(74,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeMembers(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(75,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeModerators(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(76,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeMemberForDevice(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(77,{request:e,response:e,onrequest:e=>t.api.core.changeMemberRole(...e)}),o.register(78,{request:e,response:e,onrequest:e=>t.api.core.muteMember(...e)}),o.register(79,{request:e,response:e,onrequest:e=>t.api.core.unmuteMember(...e)}),o.register(80,{request:e,response:e,onrequest:e=>t.api.core.getSearchMembers(...e)}),o.register(81,{request:e,response:e,onrequest:e=>t.api.core.getPushNotificationMembers(...e)}),o.register(82,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeSearchMembers(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(83,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribePushNotificationMembers(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(84,{request:e,response:e,onrequest:e=>t.api.core.addContact(...e)}),o.register(85,{request:e,response:e,onrequest:e=>t.api.core.setContactAlias(...e)}),o.register(86,{request:e,response:e,onrequest:e=>t.api.core.removeContact(...e)}),o.register(87,{request:e,response:e,onrequest:e=>t.api.core.getActiveContacts(...e)}),o.register(88,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeActiveContacts(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(89,{request:e,response:e,onrequest:e=>t.api.core.getContactInfo(...e)}),o.register(90,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeContactInfo(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(91,{request:e,response:e,onrequest:e=>t.api.core.getSelfContactInfo(...e)}),o.register(92,{request:e,response:e,onrequest:e=>t.api.core.blockMember(...e)}),o.register(93,{request:e,response:e,onrequest:e=>t.api.core.unblockMember(...e)}),o.register(94,{request:e,response:e,onrequest:e=>t.api.core.getBlockedMembers(...e)}),o.register(95,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeBlockedMembers(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(96,{request:e,response:e,onrequest:e=>t.api.core.getConnectedMembers(...e)}),o.register(97,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeConnectedMembers(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(98,{request:e,response:e,onrequest:e=>t.api.core.updateConfig(...e)}),o.register(99,{request:e,response:e,onrequest:e=>t.api.core.getConfig(...e)}),o.register(100,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeConfig(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(101,{request:e,response:e,onrequest:e=>t.api.core.updateRoomSettings(...e)}),o.register(102,{request:e,response:e,onrequest:e=>t.api.core.disableMembershipEvents(...e)}),o.register(103,{request:e,response:e,onrequest:e=>t.api.core.enableMembershipEvents(...e)}),o.register(104,{request:e,response:e,onrequest:e=>t.api.core.addChatMessage(...e)}),o.register(105,{request:e,response:e,onrequest:e=>t.api.core.updateChatMessage(...e)}),o.register(106,{request:e,response:e,onrequest:e=>t.api.core.removeChatMessage(...e)}),o.register(107,{request:e,response:e,onrequest:e=>t.api.core.forwardChatMessage(...e)}),o.register(108,{request:e,response:e,onrequest:e=>t.api.core.pinChatMessage(...e)}),o.register(109,{request:e,response:e,onrequest:e=>t.api.core.unpinChatMessage(...e)}),o.register(110,{request:e,response:e,onrequest:e=>t.api.core.startCall(...e)}),o.register(111,{request:e,response:e,onrequest:e=>t.api.core.joinCall(...e)}),o.register(112,{request:e,response:e,onrequest:e=>t.api.core.leaveCall(...e)}),o.register(113,{request:e,response:e,onrequest:e=>t.api.core.endCall(...e)}),o.register(114,{request:e,response:e,onrequest:e=>t.api.core.addCallStream(...e)}),o.register(115,{request:e,response:e,onrequest:e=>t.api.core.removeCallStream(...e)}),o.register(116,{request:e,response:e,onrequest:e=>t.api.core.updateCallStream(...e)}),o.register(117,{request:e,response:e,onrequest:e=>t.api.core.startCallRecording(...e)}),o.register(118,{request:e,response:e,onrequest:e=>t.api.core.stopCallRecording(...e)}),o.register(119,{request:e,response:e,onrequest:e=>t.api.core.getActiveCalls(...e)}),o.register(120,{request:e,response:e,onrequest:e=>t.api.core.getAllActiveCalls(...e)}),o.register(121,{request:e,response:e,onrequest:e=>t.api.core.getCalls(...e)}),o.register(122,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeActiveCalls(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(123,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeAllActiveCalls(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(124,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeCalls(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(125,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeCallProxy(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(126,{request:e,response:e,onrequest:e=>t.api.core.signalCallPeer(...e)}),o.register(127,{request:e,response:e,onrequest:e=>t.api.core.addCallStartedEvent(...e)}),o.register(128,{request:e,response:e,onrequest:e=>t.api.core.addCallHangupEvent(...e)}),o.register(129,{request:e,response:e,onrequest:e=>t.api.core.addCallMissedEvent(...e)}),o.register(130,{request:e,response:e,onrequest:e=>t.api.core.addLocationSharedEvent(...e)}),o.register(131,{request:e,response:e,onrequest:e=>t.api.core.addRoomAvatarChangedEvent(...e)}),o.register(132,{request:e,response:e,onrequest:e=>t.api.core.addEvent(...e)}),o.register(133,{request:e,response:e,onrequest:e=>t.api.core.removeEvent(...e)}),o.register(134,{request:e,response:e,onrequest:e=>t.api.core.getChatMessage(...e)}),o.register(135,{request:e,response:e,onrequest:e=>t.api.core.getChatMessageById(...e)}),o.register(136,{request:e,response:e,onrequest:e=>t.api.core.getChatMessages(...e)}),o.register(137,{request:e,response:e,onrequest:e=>t.api.core.getPinnedChatMessages(...e)}),o.register(138,{request:e,response:e,onrequest:e=>t.api.core.getChatLength(...e)}),o.register(139,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeChatMessages(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(140,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeChatLength(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(141,{request:e,response:e,onrequest:e=>t.api.core.searchChatMessages(...e)}),o.register(142,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.createChatSearchStream(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(143,{request:e,response:e,onrequest:e=>t.api.core.sendDMFromContact(...e)}),o.register(144,{request:e,response:e,onrequest:e=>t.api.core.sendDMRequest(...e)}),o.register(145,{request:e,response:e,onrequest:e=>t.api.core.sendInvitations(...e)}),o.register(146,{request:e,response:e,onrequest:e=>t.api.core.updatePrivateMailboxRecord(...e)}),o.register(147,{request:e,response:e,onrequest:e=>t.api.core.getPrivateMailboxRecords(...e)}),o.register(148,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribePrivateMailbox(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(149,{request:e,response:e,onrequest:e=>t.api.core.getSentPrivateMailboxRecords(...e)}),o.register(150,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeSentPrivateMailbox(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(151,{request:e,response:e,onrequest:e=>t.api.core.getDmByMemberId(...e)}),o.register(152,{request:e,response:e,onrequest:e=>t.api.core.getDmRequestsByStatus(...e)}),o.register(153,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeDmRequestsByStatus(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(154,{request:e,response:e,onrequest:e=>t.api.core.acceptDmRequest(...e)}),o.register(155,{request:e,response:e,onrequest:e=>t.api.core.rejectDmRequest(...e)}),o.register(156,{request:e,response:e,onrequest:e=>t.api.core.addReaction(...e)}),o.register(157,{request:e,response:e,onrequest:e=>t.api.core.removeReaction(...e)}),o.register(158,{request:e,response:e,onrequest:e=>t.api.core.getLatestReactions(...e)}),o.register(159,{request:e,response:e,onrequest:e=>t.api.core.getReactions(...e)}),o.register(160,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeReactions(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(161,{request:e,response:e,onrequest:e=>t.api.core.addChatReport(...e)}),o.register(162,{request:e,response:e,onrequest:e=>t.api.core.removeChatReport(...e)}),o.register(163,{request:e,response:e,onrequest:e=>t.api.core.dismissChatReports(...e)}),o.register(164,{request:e,response:e,onrequest:e=>t.api.core.reportMember(...e)}),o.register(165,{request:e,response:e,onrequest:e=>t.api.core.getReportedMembers(...e)}),o.register(166,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeReportedMembers(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(167,{request:e,response:e,onrequest:e=>t.api.core.getReportedMessages(...e)}),o.register(168,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeReportedMessages(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(169,{request:e,response:e,onrequest:e=>t.api.core.addFileBlob(...e)}),o.register(170,{request:e,response:e,onrequest:e=>t.api.core.addFile(...e)}),o.register(171,{request:e,response:e,onrequest:e=>t.api.core.saveFileBlob(...e)}),o.register(172,{request:e,response:e,onrequest:e=>t.api.core.saveFile(...e)}),o.register(173,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeAddFile(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(174,{request:e,response:e,onrequest:e=>t.api.core.sendFile(...e)}),o.register(175,{request:e,response:e,onrequest:e=>t.api.core.removeFile(...e)}),o.register(176,{request:e,response:e,onrequest:e=>t.api.core.refreshFileLinks(...e)}),o.register(177,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeFileInfo(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(178,{request:e,response:e,onrequest:e=>t.api.core.clearAllFiles(...e)}),o.register(179,{request:e,response:e,onrequest:e=>t.api.core.getFileEntry(...e)}),o.register(180,{request:e,response:e,onrequest:e=>t.api.core.getLocalFiles(...e)}),o.register(181,{request:e,response:e,onrequest:e=>t.api.core.getFiles(...e)}),o.register(182,{request:e,response:e,onrequest:e=>t.api.core.startDownload(...e)}),o.register(183,{request:e,response:e,onrequest:e=>t.api.core.cancelDownload(...e)}),o.register(184,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.readFileStream(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(185,{request:e,response:e,onrequest:e=>t.api.core.saveToDisk(...e)}),o.register(186,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeSaveToDisk(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(187,{request:e,response:e,onrequest:e=>t.api.core.clearFile(...e)}),o.register(188,{request:e,response:e,onrequest:e=>t.api.core.unclearFile(...e)}),o.register(189,{request:e,response:e,onrequest:e=>t.api.core.getFileCleared(...e)}),o.register(190,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeFileCleared(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(191,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeFiles(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(192,{request:e,response:e,onrequest:e=>t.api.core.getStats(...e)}),o.register(193,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeProgress(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(194,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeSystemUpdateRequest(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(195,{request:e,response:e,onrequest:e=>t.api.core.lookupUsername(...e)}),o.register(196,{request:e,response:e,onrequest:e=>t.api.core.lookupUserByMemberId(...e)}),o.register(197,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeUsername(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(198,{request:e,response:e,onrequest:e=>t.api.core.registerUsername(...e)}),o.register(199,{request:e,response:e,onrequest:e=>t.api.core.updateUsername(...e)}),o.register(200,{request:e,response:e,onrequest:e=>t.api.core.searchUsername(...e)}),o.register(201,{request:e,response:e,onrequest:e=>t.api.core.getReservationsByKey(...e)}),o.register(202,{request:e,response:e,onrequest:e=>t.api.core.checkUsername(...e)}),o.register(203,{request:e,response:e,onrequest:e=>t.api.core.updateRoomPreferences(...e)}),o.register(204,{request:e,response:e,onrequest:e=>t.api.core.getRoomPreferences(...e)}),o.register(205,{request:e,response:e,onrequest:e=>t.api.core.audit(...e)}),o.register(206,{request:e,response:e,onrequest:e=>t.api.core.autobeeLogs(...e)}),o.register(207,{request:e,response:e,onrequest:e=>t.api.core.close(...e)}),o.register(208,{request:e,response:e,onrequest:e=>t.api.core.suspend(...e)}),o.register(209,{request:e,response:e,onrequest:e=>t.api.core.resume(...e)}),o.register(210,{request:e,response:e,onrequest:e=>t.api.core.getDebugFlags(...e)}),o.register(211,{request:e,response:e,onrequest:e=>t.api.core.updateDebugFlag(...e)}),o.register(212,{request:e,response:e,onrequest:e=>t.api.core.repair(...e)}),o.register(213,{request:e,response:e,onrequest:e=>t.api.core.rotateWriter(...e)}),o.register(214,{request:e,response:e,onrequest:e=>t.api.core.getRoomStats(...e)}),o.register(215,{request:e,response:e,onrequest:e=>t.api.core.compact(...e)}),o.register(216,{request:e,response:e,onrequest:e=>t.api.core.setUnread(...e)}),o.register(217,{request:e,response:e,onrequest:e=>t.api.core.getUnread(...e)}),o.register(218,{request:e,response:e,onrequest:e=>t.api.core.getUnreadAnchor(...e)}),o.register(219,{request:e,response:e,onrequest:e=>t.api.core.setUnreadAnchor(...e)}),o.register(220,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeUnreadAnchor(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(221,{request:e,response:e,onrequest:e=>t.api.core.updateTypingIndicator(...e)}),o.register(222,{request:e,response:e,onrequest:e=>t.api.core.getTypingIndicator(...e)}),o.register(223,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeTypingIndicator(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(224,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeSentLength(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(225,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.createErrorStream(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(226,{request:e,response:e,onrequest:e=>t.api.core.boot(...e)}),o.register(227,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeErrors(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(228,{request:e,response:e,onrequest:e=>t.api.core.setCallRingingId(...e)}),o.register(229,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeNotifications(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(230,{request:e,response:e,onrequest:e=>t.api.core.getDHTSettings(...e)}),o.register(231,{request:e,response:e,onrequest:e=>t.api.core.updateDHTSettings(...e)}),o.register(232,{request:e,response:e,onrequest:e=>t.api.core.getSwarmSettings(...e)}),o.register(233,{request:e,response:e,onrequest:e=>t.api.core.updateSwarmSettings(...e)}),o.register(234,{request:e,response:e,onrequest:e=>t.api.core.setRoomFavorite(...e)}),o.register(235,{request:e,response:e,onrequest:e=>t.api.core.clearOldFiles(...e)}),o.register(236,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.preferences.subscribe(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(237,{request:e,response:e,onrequest:e=>t.api.preferences.update(...e)}),o.register(238,{request:e,response:e,onrequest:e=>t.api.preferences.query(...e)}),o.register(239,{request:e,response:e,onrequest:e=>t.api.call.authorize(...e)}),o.register(240,{request:e,response:e,onrequest:e=>t.api.call.deauthorize(...e)}),o.register(241,{request:e,response:e,onrequest:e=>t.api.call.joinPeer(...e)}),o.register(242,{request:e,response:e,onrequest:e=>t.api.call.leavePeer(...e)}),o.register(243,{request:e,response:e,onrequest:e=>t.api.call.requestTrack(...e)}),o.register(244,{request:e,response:e,onrequest:e=>t.api.call.unrequestTrack(...e)}),o.register(245,{request:e,response:e,onrequest:e=>t.api.call.signalMedia(...e)}),o.register(246,{request:e,response:e,onrequest:e=>t.api.call.getRequestedTracks(...e)}),o.register(247,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.call.subscribeRequestedTracks(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(248,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.call.subscribeMediaSignals(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(249,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.call.subscribeProxyUpdates(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(250,{request:e,response:e,onrequest:e=>t.api.call.shareTrack(...e)}),o.register(251,{request:e,response:e,onrequest:e=>t.api.call.unshareTrack(...e)}),o.register(252,{request:e,response:e,onrequest:e=>t.api.call.relayTrack(...e)}),o.register(253,{request:e,response:e,onrequest:e=>t.api.call.unrelayTrack(...e)}),o.register(254,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.call.subscribeAvailableTracks(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(255,{request:e,response:e,onrequest:e=>t.api.call.getAvailableTracks(...e)}),o.register(256,{request:e,response:e,onrequest:e=>t.api.call.setPresent(...e)}),o.register(257,{request:e,response:e,onrequest:e=>t.api.call.setNotPresent(...e)}),o.register(258,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.call.subscribePresence(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(259,{request:e,response:e,onrequest:e=>t.api.call.getPresence(...e)}),o.register(260,{request:e,response:e,onrequest:e=>t.api.tracing.start(...e)}),o.register(261,{request:e,response:e,onrequest:e=>t.api.tracing.addFrontendTrace(...e)}),o.register(262,{request:e,response:e,onrequest:e=>t.api.console.log(...e)}),o.register(263,{request:e,response:e,onrequest:e=>t.api.console.warn(...e)}),o.register(264,{request:e,response:e,onrequest:e=>t.api.console.error(...e)}),o.register(265,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.network.subscribe(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(266,{request:e,response:e,onrequest:e=>t.api.network.query(...e)}),o.register(267,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.network.subscribeDebug(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(268,{request:e,response:e,onrequest:e=>t.api.network.debug(...e)}),o.register(269,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.error.subscribe(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(270,{request:e,response:e,onrequest:e=>t.api.debug.getCurrentRoomStats(...e)}),o.register(271,{request:e,response:e,onrequest:e=>t.api.debug.enableInspector(...e)}),o.register(272,{request:e,response:e,onrequest:e=>t.api.debug.disableInspector(...e)}),o.register(273,{request:e,response:e,onrequest:e=>t.api.debug.getInspectorKey(...e)}),o.register(274,{request:e,response:e,onrequest:e=>t.api.debug.processTop(...e)}),o.register(275,{request:e,response:e,onrequest:e=>t.api.debug.heapSnapshot(...e)}),o.register(276,{request:e,response:e,onrequest:e=>t.api.debug.hash(...e)}),o.register(277,{request:e,response:e,onrequest:e=>t.api.debug.generateSyntheticError(...e)}),o.register(278,{request:e,response:e,onrequest:e=>t.api.debug.resetUnreads(...e)}),o.register(279,{request:e,response:e,onrequest:e=>t.api.debug.getAccumulatedBytes(...e)}),o.register(280,{request:e,response:e,onrequest:e=>t.api.pear.teardown(...e)}),o.register(281,{request:e,response:e,onrequest:e=>t.api.pear.selfDestruct(...e)}),o.register(282,{request:e,response:e,onrequest:e=>t.api.feedback.send(...e)}),o.register(283,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.callNetwork.subscribe(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(284,{request:e,response:e,onrequest:e=>t.api.callNetwork.query(...e)}),o.register(285,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.callNetwork.subscribeDebug(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(286,{request:e,response:e,onrequest:e=>t.api.callNetwork.debug(...e)})};
1const e=require("tiny-buffer-rpc/any"),{pipeline:r}=require("streamx");function s(){}module.exports=function(t,o){o.register(0,{request:e,response:e,onrequest:e=>t.api.swarm.ready(...e)}),o.register(1,{request:e,response:e,onrequest:e=>t.api.core.getVersion(...e)}),o.register(2,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeRoomVersion(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(3,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeForceUpdates(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(4,{request:e,response:e,onrequest:e=>t.api.core.upgradeRoom(...e)}),o.register(5,{request:e,response:e,onrequest:e=>t.api.core.updateUserSettings(...e)}),o.register(6,{request:e,response:e,onrequest:e=>t.api.core.getIdentity(...e)}),o.register(7,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeIdentity(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(8,{request:e,response:e,onrequest:e=>t.api.core.generateIdentity(...e)}),o.register(9,{request:e,response:e,onrequest:e=>t.api.core.restoreIdentity(...e)}),o.register(10,{request:e,response:e,onrequest:e=>t.api.core.getRecoveryPhrase(...e)}),o.register(11,{request:e,response:e,onrequest:e=>t.api.core.getEncryptedRecoveryPhrase(...e)}),o.register(12,{request:e,response:e,onrequest:e=>t.api.core.decryptEncryptedRecoveryPhrase(...e)}),o.register(13,{request:e,response:e,onrequest:e=>t.api.core.freeRecoveryPhrase(...e)}),o.register(14,{request:e,response:e,onrequest:e=>t.api.core.confirmRecoveryPhrase(...e)}),o.register(15,{request:e,response:e,onrequest:e=>t.api.core.storeRecoveryPhrase(...e)}),o.register(16,{request:e,response:e,onrequest:e=>t.api.core.confirmIdentity(...e)}),o.register(17,{request:e,response:e,onrequest:e=>t.api.core.confirmPairingRequest(...e)}),o.register(18,{request:e,response:e,dedup:!1,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeIdentityPairingRequests(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(19,{request:e,response:e,onrequest:e=>t.api.core.updateIdentityProfile(...e)}),o.register(20,{request:e,response:e,onrequest:e=>t.api.core.updateIdentityDevice(...e)}),o.register(21,{request:e,response:e,onrequest:e=>t.api.core.removeIdentityDevice(...e)}),o.register(22,{request:e,response:e,onrequest:e=>t.api.core.getLinkInfo(...e)}),o.register(23,{request:e,response:e,onrequest:e=>t.api.core.startPairingIdentity(...e)}),o.register(24,{request:e,response:e,onrequest:e=>t.api.core.pairIdentity(...e)}),o.register(25,{request:e,response:e,onrequest:e=>t.api.core.createRoom(...e)}),o.register(26,{request:e,response:e,onrequest:e=>t.api.core.pairRoom(...e)}),o.register(27,{request:e,response:e,onrequest:e=>t.api.core.leaveRoom(...e)}),o.register(28,{request:e,response:e,onrequest:e=>t.api.core.startPairingRoom(...e)}),o.register(29,{request:e,response:e,onrequest:e=>t.api.core.stopPairingRoom(...e)}),o.register(30,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribePendingRooms(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(31,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribePushNotificationChanges(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(32,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeActivateRoom(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(33,{request:e,response:e,onrequest:e=>t.api.core.getRoomKeys(...e)}),o.register(34,{request:e,response:e,onrequest:e=>t.api.core.resyncPrivateProfile(...e)}),o.register(35,{request:e,response:e,onrequest:e=>t.api.core.getTipSize(...e)}),o.register(36,{request:e,response:e,onrequest:e=>t.api.core.bookmark(...e)}),o.register(37,{request:e,response:e,onrequest:e=>t.api.core.unbookmark(...e)}),o.register(38,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeBookmarks(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(39,{request:e,response:e,onrequest:e=>t.api.core.getRoomInfo(...e)}),o.register(40,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeRoomInfo(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(41,{request:e,response:e,onrequest:e=>t.api.core.searchRooms(...e)}),o.register(42,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.searchPublicRooms(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(43,{request:e,response:e,onrequest:e=>t.api.core.getRecentRooms(...e)}),o.register(44,{request:e,response:e,onrequest:e=>t.api.core.getLocalRoomMetadata(...e)}),o.register(45,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeRecentRooms(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(46,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeFavoriteRooms(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(47,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeUnreadActivity(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(48,{request:e,response:e,onrequest:e=>t.api.core.setRoomUnread(...e)}),o.register(49,{request:e,response:e,onrequest:e=>t.api.core.bumpRoomPriority(...e)}),o.register(50,{request:e,response:e,onrequest:e=>t.api.core.snoozeRoom(...e)}),o.register(51,{request:e,response:e,onrequest:e=>t.api.core.addDevice(...e)}),o.register(52,{request:e,response:e,onrequest:e=>t.api.core.removeDevice(...e)}),o.register(53,{request:e,response:e,onrequest:e=>t.api.core.getDevice(...e)}),o.register(54,{request:e,response:e,onrequest:e=>t.api.core.getDevices(...e)}),o.register(55,{request:e,response:e,onrequest:e=>t.api.core.getDevicesByMemberId(...e)}),o.register(56,{request:e,response:e,onrequest:e=>t.api.core.getCurrentDeviceId(...e)}),o.register(57,{request:e,response:e,onrequest:e=>t.api.core.moveIndexer(...e)}),o.register(58,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeDevice(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(59,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeDevices(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(60,{request:e,response:e,onrequest:e=>t.api.core.createIdentityInvitation(...e)}),o.register(61,{request:e,response:e,onrequest:e=>t.api.core.createInvitation(...e)}),o.register(62,{request:e,response:e,onrequest:e=>t.api.core.updateMember(...e)}),o.register(63,{request:e,response:e,onrequest:e=>t.api.core.isMemberMuted(...e)}),o.register(64,{request:e,response:e,onrequest:e=>t.api.core.getMember(...e)}),o.register(65,{request:e,response:e,onrequest:e=>t.api.core.removeMember(...e)}),o.register(66,{request:e,response:e,onrequest:e=>t.api.core.getMembers(...e)}),o.register(67,{request:e,response:e,onrequest:e=>t.api.core.getActiveMembers(...e)}),o.register(68,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeActiveMembers(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(69,{request:e,response:e,onrequest:e=>t.api.core.getModerators(...e)}),o.register(70,{request:e,response:e,onrequest:e=>t.api.core.getMemberCount(...e)}),o.register(71,{request:e,response:e,onrequest:e=>t.api.core.getMemberForDevice(...e)}),o.register(72,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeMemberCount(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(73,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeMember(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(74,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeMembers(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(75,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeModerators(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(76,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeMemberForDevice(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(77,{request:e,response:e,onrequest:e=>t.api.core.changeMemberRole(...e)}),o.register(78,{request:e,response:e,onrequest:e=>t.api.core.muteMember(...e)}),o.register(79,{request:e,response:e,onrequest:e=>t.api.core.unmuteMember(...e)}),o.register(80,{request:e,response:e,onrequest:e=>t.api.core.getSearchMembers(...e)}),o.register(81,{request:e,response:e,onrequest:e=>t.api.core.getPushNotificationMembers(...e)}),o.register(82,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeSearchMembers(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(83,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribePushNotificationMembers(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(84,{request:e,response:e,onrequest:e=>t.api.core.addContact(...e)}),o.register(85,{request:e,response:e,onrequest:e=>t.api.core.setContactAlias(...e)}),o.register(86,{request:e,response:e,onrequest:e=>t.api.core.removeContact(...e)}),o.register(87,{request:e,response:e,onrequest:e=>t.api.core.getActiveContacts(...e)}),o.register(88,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeActiveContacts(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(89,{request:e,response:e,onrequest:e=>t.api.core.getContactInfo(...e)}),o.register(90,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeContactInfo(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(91,{request:e,response:e,onrequest:e=>t.api.core.getSelfContactInfo(...e)}),o.register(92,{request:e,response:e,onrequest:e=>t.api.core.blockMember(...e)}),o.register(93,{request:e,response:e,onrequest:e=>t.api.core.unblockMember(...e)}),o.register(94,{request:e,response:e,onrequest:e=>t.api.core.getBlockedMembers(...e)}),o.register(95,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeBlockedMembers(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(96,{request:e,response:e,onrequest:e=>t.api.core.getConnectedMembers(...e)}),o.register(97,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeConnectedMembers(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(98,{request:e,response:e,onrequest:e=>t.api.core.updateConfig(...e)}),o.register(99,{request:e,response:e,onrequest:e=>t.api.core.getConfig(...e)}),o.register(100,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeConfig(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(101,{request:e,response:e,onrequest:e=>t.api.core.updateRoomSettings(...e)}),o.register(102,{request:e,response:e,onrequest:e=>t.api.core.disableMembershipEvents(...e)}),o.register(103,{request:e,response:e,onrequest:e=>t.api.core.enableMembershipEvents(...e)}),o.register(104,{request:e,response:e,onrequest:e=>t.api.core.addChatMessage(...e)}),o.register(105,{request:e,response:e,onrequest:e=>t.api.core.updateChatMessage(...e)}),o.register(106,{request:e,response:e,onrequest:e=>t.api.core.addFilePreview(...e)}),o.register(107,{request:e,response:e,onrequest:e=>t.api.core.removeFilePreview(...e)}),o.register(108,{request:e,response:e,onrequest:e=>t.api.core.addLinkPreview(...e)}),o.register(109,{request:e,response:e,onrequest:e=>t.api.core.removeLinkPreview(...e)}),o.register(110,{request:e,response:e,onrequest:e=>t.api.core.removeChatMessage(...e)}),o.register(111,{request:e,response:e,onrequest:e=>t.api.core.forwardChatMessage(...e)}),o.register(112,{request:e,response:e,onrequest:e=>t.api.core.pinChatMessage(...e)}),o.register(113,{request:e,response:e,onrequest:e=>t.api.core.unpinChatMessage(...e)}),o.register(114,{request:e,response:e,onrequest:e=>t.api.core.startCall(...e)}),o.register(115,{request:e,response:e,onrequest:e=>t.api.core.joinCall(...e)}),o.register(116,{request:e,response:e,onrequest:e=>t.api.core.leaveCall(...e)}),o.register(117,{request:e,response:e,onrequest:e=>t.api.core.endCall(...e)}),o.register(118,{request:e,response:e,onrequest:e=>t.api.core.addCallStream(...e)}),o.register(119,{request:e,response:e,onrequest:e=>t.api.core.removeCallStream(...e)}),o.register(120,{request:e,response:e,onrequest:e=>t.api.core.updateCallStream(...e)}),o.register(121,{request:e,response:e,onrequest:e=>t.api.core.startCallRecording(...e)}),o.register(122,{request:e,response:e,onrequest:e=>t.api.core.stopCallRecording(...e)}),o.register(123,{request:e,response:e,onrequest:e=>t.api.core.getActiveCalls(...e)}),o.register(124,{request:e,response:e,onrequest:e=>t.api.core.getAllActiveCalls(...e)}),o.register(125,{request:e,response:e,onrequest:e=>t.api.core.getCalls(...e)}),o.register(126,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeActiveCalls(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(127,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeAllActiveCalls(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(128,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeCalls(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(129,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeCallProxy(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(130,{request:e,response:e,onrequest:e=>t.api.core.signalCallPeer(...e)}),o.register(131,{request:e,response:e,onrequest:e=>t.api.core.addCallStartedEvent(...e)}),o.register(132,{request:e,response:e,onrequest:e=>t.api.core.addCallHangupEvent(...e)}),o.register(133,{request:e,response:e,onrequest:e=>t.api.core.addCallMissedEvent(...e)}),o.register(134,{request:e,response:e,onrequest:e=>t.api.core.addLocationSharedEvent(...e)}),o.register(135,{request:e,response:e,onrequest:e=>t.api.core.addRoomAvatarChangedEvent(...e)}),o.register(136,{request:e,response:e,onrequest:e=>t.api.core.addEvent(...e)}),o.register(137,{request:e,response:e,onrequest:e=>t.api.core.removeEvent(...e)}),o.register(138,{request:e,response:e,onrequest:e=>t.api.core.getChatMessage(...e)}),o.register(139,{request:e,response:e,onrequest:e=>t.api.core.getChatMessageById(...e)}),o.register(140,{request:e,response:e,onrequest:e=>t.api.core.getChatMessages(...e)}),o.register(141,{request:e,response:e,onrequest:e=>t.api.core.getPinnedChatMessages(...e)}),o.register(142,{request:e,response:e,onrequest:e=>t.api.core.getChatLength(...e)}),o.register(143,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeChatMessages(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(144,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeChatLength(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(145,{request:e,response:e,onrequest:e=>t.api.core.searchChatMessages(...e)}),o.register(146,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.createChatSearchStream(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(147,{request:e,response:e,onrequest:e=>t.api.core.sendDMFromContact(...e)}),o.register(148,{request:e,response:e,onrequest:e=>t.api.core.sendDMRequest(...e)}),o.register(149,{request:e,response:e,onrequest:e=>t.api.core.sendInvitations(...e)}),o.register(150,{request:e,response:e,onrequest:e=>t.api.core.updatePrivateMailboxRecord(...e)}),o.register(151,{request:e,response:e,onrequest:e=>t.api.core.getPrivateMailboxRecords(...e)}),o.register(152,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribePrivateMailbox(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(153,{request:e,response:e,onrequest:e=>t.api.core.getSentPrivateMailboxRecords(...e)}),o.register(154,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeSentPrivateMailbox(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(155,{request:e,response:e,onrequest:e=>t.api.core.getDmByMemberId(...e)}),o.register(156,{request:e,response:e,onrequest:e=>t.api.core.getDmRequestsByStatus(...e)}),o.register(157,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeDmRequestsByStatus(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(158,{request:e,response:e,onrequest:e=>t.api.core.acceptDmRequest(...e)}),o.register(159,{request:e,response:e,onrequest:e=>t.api.core.rejectDmRequest(...e)}),o.register(160,{request:e,response:e,onrequest:e=>t.api.core.addReaction(...e)}),o.register(161,{request:e,response:e,onrequest:e=>t.api.core.removeReaction(...e)}),o.register(162,{request:e,response:e,onrequest:e=>t.api.core.getLatestReactions(...e)}),o.register(163,{request:e,response:e,onrequest:e=>t.api.core.getReactions(...e)}),o.register(164,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeReactions(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(165,{request:e,response:e,onrequest:e=>t.api.core.addChatReport(...e)}),o.register(166,{request:e,response:e,onrequest:e=>t.api.core.removeChatReport(...e)}),o.register(167,{request:e,response:e,onrequest:e=>t.api.core.dismissChatReports(...e)}),o.register(168,{request:e,response:e,onrequest:e=>t.api.core.reportMember(...e)}),o.register(169,{request:e,response:e,onrequest:e=>t.api.core.getReportedMembers(...e)}),o.register(170,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeReportedMembers(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(171,{request:e,response:e,onrequest:e=>t.api.core.getReportedMessages(...e)}),o.register(172,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeReportedMessages(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(173,{request:e,response:e,onrequest:e=>t.api.core.addFileBlob(...e)}),o.register(174,{request:e,response:e,onrequest:e=>t.api.core.addFile(...e)}),o.register(175,{request:e,response:e,onrequest:e=>t.api.core.saveFileBlob(...e)}),o.register(176,{request:e,response:e,onrequest:e=>t.api.core.saveFile(...e)}),o.register(177,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeAddFile(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(178,{request:e,response:e,onrequest:e=>t.api.core.sendFile(...e)}),o.register(179,{request:e,response:e,onrequest:e=>t.api.core.removeFile(...e)}),o.register(180,{request:e,response:e,onrequest:e=>t.api.core.refreshFileLinks(...e)}),o.register(181,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeFileInfo(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(182,{request:e,response:e,onrequest:e=>t.api.core.clearAllFiles(...e)}),o.register(183,{request:e,response:e,onrequest:e=>t.api.core.getFileEntry(...e)}),o.register(184,{request:e,response:e,onrequest:e=>t.api.core.getLocalFiles(...e)}),o.register(185,{request:e,response:e,onrequest:e=>t.api.core.getFiles(...e)}),o.register(186,{request:e,response:e,onrequest:e=>t.api.core.startDownload(...e)}),o.register(187,{request:e,response:e,onrequest:e=>t.api.core.cancelDownload(...e)}),o.register(188,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.readFileStream(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(189,{request:e,response:e,onrequest:e=>t.api.core.saveToDisk(...e)}),o.register(190,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeSaveToDisk(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(191,{request:e,response:e,onrequest:e=>t.api.core.clearFile(...e)}),o.register(192,{request:e,response:e,onrequest:e=>t.api.core.unclearFile(...e)}),o.register(193,{request:e,response:e,onrequest:e=>t.api.core.getFileCleared(...e)}),o.register(194,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeFileCleared(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(195,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeFiles(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(196,{request:e,response:e,onrequest:e=>t.api.core.getStats(...e)}),o.register(197,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeProgress(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(198,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeSystemUpdateRequest(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(199,{request:e,response:e,onrequest:e=>t.api.core.lookupUsername(...e)}),o.register(200,{request:e,response:e,onrequest:e=>t.api.core.lookupUserByMemberId(...e)}),o.register(201,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeUsername(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(202,{request:e,response:e,onrequest:e=>t.api.core.registerUsername(...e)}),o.register(203,{request:e,response:e,onrequest:e=>t.api.core.updateUsername(...e)}),o.register(204,{request:e,response:e,onrequest:e=>t.api.core.searchUsername(...e)}),o.register(205,{request:e,response:e,onrequest:e=>t.api.core.getReservationsByKey(...e)}),o.register(206,{request:e,response:e,onrequest:e=>t.api.core.checkUsername(...e)}),o.register(207,{request:e,response:e,onrequest:e=>t.api.core.updateRoomPreferences(...e)}),o.register(208,{request:e,response:e,onrequest:e=>t.api.core.getRoomPreferences(...e)}),o.register(209,{request:e,response:e,onrequest:e=>t.api.core.audit(...e)}),o.register(210,{request:e,response:e,onrequest:e=>t.api.core.autobeeLogs(...e)}),o.register(211,{request:e,response:e,onrequest:e=>t.api.core.close(...e)}),o.register(212,{request:e,response:e,onrequest:e=>t.api.core.suspend(...e)}),o.register(213,{request:e,response:e,onrequest:e=>t.api.core.resume(...e)}),o.register(214,{request:e,response:e,onrequest:e=>t.api.core.getDebugFlags(...e)}),o.register(215,{request:e,response:e,onrequest:e=>t.api.core.updateDebugFlag(...e)}),o.register(216,{request:e,response:e,onrequest:e=>t.api.core.repair(...e)}),o.register(217,{request:e,response:e,onrequest:e=>t.api.core.rotateWriter(...e)}),o.register(218,{request:e,response:e,onrequest:e=>t.api.core.getRoomStats(...e)}),o.register(219,{request:e,response:e,onrequest:e=>t.api.core.compact(...e)}),o.register(220,{request:e,response:e,onrequest:e=>t.api.core.setUnread(...e)}),o.register(221,{request:e,response:e,onrequest:e=>t.api.core.getUnread(...e)}),o.register(222,{request:e,response:e,onrequest:e=>t.api.core.getUnreadAnchor(...e)}),o.register(223,{request:e,response:e,onrequest:e=>t.api.core.setUnreadAnchor(...e)}),o.register(224,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeUnreadAnchor(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(225,{request:e,response:e,onrequest:e=>t.api.core.getUnreadRooms(...e)}),o.register(226,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeUnreadRooms(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(227,{request:e,response:e,onrequest:e=>t.api.core.updateTypingIndicator(...e)}),o.register(228,{request:e,response:e,onrequest:e=>t.api.core.getTypingIndicator(...e)}),o.register(229,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeTypingIndicator(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(230,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeSentLength(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(231,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.createErrorStream(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(232,{request:e,response:e,onrequest:e=>t.api.core.boot(...e)}),o.register(233,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeErrors(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(234,{request:e,response:e,onrequest:e=>t.api.core.setCallRingingId(...e)}),o.register(235,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.core.subscribeNotifications(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(236,{request:e,response:e,onrequest:e=>t.api.core.getDHTSettings(...e)}),o.register(237,{request:e,response:e,onrequest:e=>t.api.core.updateDHTSettings(...e)}),o.register(238,{request:e,response:e,onrequest:e=>t.api.core.getSwarmSettings(...e)}),o.register(239,{request:e,response:e,onrequest:e=>t.api.core.updateSwarmSettings(...e)}),o.register(240,{request:e,response:e,onrequest:e=>t.api.core.setRoomFavorite(...e)}),o.register(241,{request:e,response:e,onrequest:e=>t.api.core.clearOldFiles(...e)}),o.register(242,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.preferences.subscribe(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(243,{request:e,response:e,onrequest:e=>t.api.preferences.update(...e)}),o.register(244,{request:e,response:e,onrequest:e=>t.api.preferences.query(...e)}),o.register(245,{request:e,response:e,onrequest:e=>t.api.call.authorize(...e)}),o.register(246,{request:e,response:e,onrequest:e=>t.api.call.deauthorize(...e)}),o.register(247,{request:e,response:e,onrequest:e=>t.api.call.joinPeer(...e)}),o.register(248,{request:e,response:e,onrequest:e=>t.api.call.leavePeer(...e)}),o.register(249,{request:e,response:e,onrequest:e=>t.api.call.requestTrack(...e)}),o.register(250,{request:e,response:e,onrequest:e=>t.api.call.unrequestTrack(...e)}),o.register(251,{request:e,response:e,onrequest:e=>t.api.call.signalMedia(...e)}),o.register(252,{request:e,response:e,onrequest:e=>t.api.call.getRequestedTracks(...e)}),o.register(253,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.call.subscribeRequestedTracks(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(254,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.call.subscribeMediaSignals(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(255,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.call.subscribeProxyUpdates(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(256,{request:e,response:e,onrequest:e=>t.api.call.shareTrack(...e)}),o.register(257,{request:e,response:e,onrequest:e=>t.api.call.unshareTrack(...e)}),o.register(258,{request:e,response:e,onrequest:e=>t.api.call.relayTrack(...e)}),o.register(259,{request:e,response:e,onrequest:e=>t.api.call.unrelayTrack(...e)}),o.register(260,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.call.subscribeAvailableTracks(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(261,{request:e,response:e,onrequest:e=>t.api.call.getAvailableTracks(...e)}),o.register(262,{request:e,response:e,onrequest:e=>t.api.call.setPresent(...e)}),o.register(263,{request:e,response:e,onrequest:e=>t.api.call.setNotPresent(...e)}),o.register(264,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.call.subscribePresence(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(265,{request:e,response:e,onrequest:e=>t.api.call.getPresence(...e)}),o.register(266,{request:e,response:e,onrequest:e=>t.api.tracing.start(...e)}),o.register(267,{request:e,response:e,onrequest:e=>t.api.tracing.addFrontendTrace(...e)}),o.register(268,{request:e,response:e,onrequest:e=>t.api.console.log(...e)}),o.register(269,{request:e,response:e,onrequest:e=>t.api.console.warn(...e)}),o.register(270,{request:e,response:e,onrequest:e=>t.api.console.error(...e)}),o.register(271,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.network.subscribe(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(272,{request:e,response:e,onrequest:e=>t.api.network.query(...e)}),o.register(273,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.network.subscribeDebug(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(274,{request:e,response:e,onrequest:e=>t.api.network.debug(...e)}),o.register(275,{request:e,response:e,onrequest:e=>t.api.network.setBluetoothEnabled(...e)}),o.register(276,{request:e,response:e,onrequest:e=>t.api.network.setNearbyContactInfo(...e)}),o.register(277,{request:e,response:e,onrequest:e=>t.api.network.clearNearbyContactInfo(...e)}),o.register(278,{request:e,response:e,onrequest:e=>t.api.network.getNearbyContactInfos(...e)}),o.register(279,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.error.subscribe(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(280,{request:e,response:e,onrequest:e=>t.api.debug.getCurrentRoomStats(...e)}),o.register(281,{request:e,response:e,onrequest:e=>t.api.debug.enableInspector(...e)}),o.register(282,{request:e,response:e,onrequest:e=>t.api.debug.disableInspector(...e)}),o.register(283,{request:e,response:e,onrequest:e=>t.api.debug.getInspectorKey(...e)}),o.register(284,{request:e,response:e,onrequest:e=>t.api.debug.processTop(...e)}),o.register(285,{request:e,response:e,onrequest:e=>t.api.debug.heapSnapshot(...e)}),o.register(286,{request:e,response:e,onrequest:e=>t.api.debug.hash(...e)}),o.register(287,{request:e,response:e,onrequest:e=>t.api.debug.generateSyntheticError(...e)}),o.register(288,{request:e,response:e,onrequest:e=>t.api.debug.resetUnreads(...e)}),o.register(289,{request:e,response:e,onrequest:e=>t.api.debug.getAccumulatedBytes(...e)}),o.register(290,{request:e,response:e,onrequest:e=>t.api.pear.teardown(...e)}),o.register(291,{request:e,response:e,onrequest:e=>t.api.pear.selfDestruct(...e)}),o.register(292,{request:e,response:e,onrequest:e=>t.api.feedback.send(...e)}),o.register(293,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.callNetwork.subscribe(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(294,{request:e,response:e,onrequest:e=>t.api.callNetwork.query(...e)}),o.register(295,{request:e,response:e,dedup:!0,onstream:async e=>{try{for await(const o of e){const n=t.api.callNetwork.subscribeDebug(...o);r(n,e).on("error",s)}}catch(r){e.destroy(r)}}}),o.register(296,{request:e,response:e,onrequest:e=>t.api.callNetwork.debug(...e)})};
@holepunchto/keet-core/package.json +4 -3
……@@ -1,6 +1,6 @@
11{
22 "name": "@holepunchto/keet-core",
3 "version": "4.22.28",
3 "version": "4.23.8",
44 "description": "A version of keet-core built with rocksdb and hyperdb",
55 "main": "index.js",
66 "imports": {
……@@ -50,6 +50,7 @@
5050 "./features": "./lib/features.js",
5151 "./legacy-constants": "./lib/legacy-constants.js",
5252 "./debugging": "./lib/core/debug/debugging.js",
53 "./invitations": "./lib/core/invitations/index.js",
5354 "./worker-launcher": "./worker-launcher/index.js",
5455 "./package.json": "./package.json"
5556 },
……@@ -98,7 +99,7 @@
9899 "@holepunchto/keet-core-api": "^2.0.0",
99100 "@holepunchto/keet-debug-helper": "^2.0.3",
100101 "@holepunchto/keet-default-config": "^3.0.0",
101 "@holepunchto/keet-indexing": "6.4.1",
102 "@holepunchto/keet-indexing": "6.4.2",
102103 "@holepunchto/keet-push": "^4.0.0",
103104 "@holepunchto/keet-registry": "^3.3.1",
104105 "@holepunchto/keet-registry-client": "^5.0.0",
……@@ -106,7 +107,6 @@
106107 "@holepunchto/keet-unread-anchors": "^2.0.0",
107108 "@holepunchto/legacy-keet-core-schemas": "^2.17.0",
108109 "autobase": "^7.13.2",
109 "autobee-encryption": "^0.1.2",
110110 "autobee": "^2.10.0",
111111 "b4a": "^1.6.7",
112112 "bare-addon-resolve": "^1.9.4",
……@@ -122,6 +122,7 @@
122122 "bare-semver": "^1.0.2",
123123 "bare-zlib": "^1.3.1",
124124 "bip39-mnemonic": "^2.4.0",
125 "ble-swarm": "^2.2.0",
125126 "blind-peering": "^2.5.0",
126127 "blind-push": "^1.0.0",
127128 "bundlebee": "^1.2.0",
@holepunchto/keet-core/schema/spec/api/hrpc/messages.js +1 -1
……@@ -1 +1 @@
1const{c:e}=require("hyperschema/runtime");let d=15;const o={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.length)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.length)},decode:d=>({key:e.fixed32.decode(d),length:e.uint.decode(d)})},n={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.seq)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.seq)},decode:d=>({key:e.fixed32.decode(d),seq:e.uint.decode(d)})},c={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.secretKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.secretKey)},decode:d=>({publicKey:e.fixed32.decode(d),secretKey:e.fixed32.decode(d)})},r={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed64.preencode(d,o.secretKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed64.encode(d,o.secretKey)},decode:d=>({publicKey:e.fixed32.decode(d),secretKey:e.fixed64.decode(d)})},t={preencode(n,c){e.fixed32.preencode(n,c.key),n.end++,c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),d>=13&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=(c.encryptionKey?1:0)|(c.fastForwardTo?2:0)|(d>=13&&c.bootFrom?4:0);e.fixed32.encode(n,c.key),e.uint.encode(n,r),c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),d>=13&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.uint.decode(n);return{key:c,encryptionKey:1&r?e.buffer.decode(n):null,fastForwardTo:2&r?e.fixed32.decode(n):null,bootFrom:d>=13&&4&r?o.decode(n):null}}},i={preencode(d,o){e.uint.preencode(d,o.timestamp)},encode(d,o){e.uint.encode(d,o.timestamp)},decode:d=>({timestamp:e.uint.decode(d)})},a={preencode(d,o){e.uint.preencode(d,o.blockOffset),e.uint.preencode(d,o.blockLength),e.uint.preencode(d,o.byteOffset),e.uint.preencode(d,o.byteLength)},encode(d,o){e.uint.encode(d,o.blockOffset),e.uint.encode(d,o.blockLength),e.uint.encode(d,o.byteOffset),e.uint.encode(d,o.byteLength)},decode:d=>({blockOffset:e.uint.decode(d),blockLength:e.uint.decode(d),byteOffset:e.uint.decode(d),byteLength:e.uint.decode(d)})},s={preencode(d,o){e.uint.preencode(d,o.width),e.uint.preencode(d,o.height)},encode(d,o){e.uint.encode(d,o.width),e.uint.encode(d,o.height)},decode:d=>({width:e.uint.decode(d),height:e.uint.decode(d)})},p=e.frame(s),u={preencode(d,o){d.end++,o.name&&e.string.preencode(d,o.name),o.mimetype&&e.string.preencode(d,o.mimetype),o.dimensions&&p.preencode(d,o.dimensions),o.userdata&&e.buffer.preencode(d,o.userdata),o.duration&&e.uint.preencode(d,o.duration)},encode(d,o){const n=(o.name?1:0)|(o.mimetype?2:0)|(o.dimensions?4:0)|(o.userdata?8:0)|(o.duration?16:0)|(o.isPreview?32:0);e.uint.encode(d,n),o.name&&e.string.encode(d,o.name),o.mimetype&&e.string.encode(d,o.mimetype),o.dimensions&&p.encode(d,o.dimensions),o.userdata&&e.buffer.encode(d,o.userdata),o.duration&&e.uint.encode(d,o.duration)},decode(d){const o=e.uint.decode(d);return{name:1&o?e.string.decode(d):null,mimetype:2&o?e.string.decode(d):null,dimensions:4&o?p.decode(d):null,userdata:8&o?e.buffer.decode(d):null,duration:16&o?e.uint.decode(d):0,isPreview:!!(32&o)}}},l={preencode(d,o){e.fixed32.preencode(d,o.key),e.string.preencode(d,o.path),e.uint.preencode(d,o.version),e.uint.preencode(d,o.size)},encode(d,o){e.fixed32.encode(d,o.key),e.string.encode(d,o.path),e.uint.encode(d,o.version),e.uint.encode(d,o.size)},decode:d=>({key:e.fixed32.decode(d),path:e.string.decode(d),version:e.uint.decode(d),size:e.uint.decode(d)})},f={preencode(d,o){e.fixed32.preencode(d,o.key),a.preencode(d,o.blob)},encode(d,o){e.fixed32.encode(d,o.key),a.encode(d,o.blob)},decode:d=>({key:e.fixed32.decode(d),blob:a.decode(d)})},m=e.frame(f),y=e.frame(l),x={preencode(o,n){o.end++,n.inlined&&e.buffer.preencode(o,n.inlined),n.blob&&a.preencode(o,n.blob),n.externalBlob&&m.preencode(o,n.externalBlob),n.externalDrive&&y.preencode(o,n.externalDrive),d>=13&&n.bee&&vu.preencode(o,n.bee)},encode(o,n){const c=(n.inlined?1:0)|(n.blob?2:0)|(n.externalBlob?4:0)|(n.externalDrive?8:0)|(d>=13&&n.bee?16:0);e.uint.encode(o,c),n.inlined&&e.buffer.encode(o,n.inlined),n.blob&&a.encode(o,n.blob),n.externalBlob&&m.encode(o,n.externalBlob),n.externalDrive&&y.encode(o,n.externalDrive),d>=13&&n.bee&&vu.encode(o,n.bee)},decode(o){const n=e.uint.decode(o);return{inlined:1&n?e.buffer.decode(o):null,blob:2&n?a.decode(o):null,externalBlob:4&n?m.decode(o):null,externalDrive:8&n?y.decode(o):null,bee:d>=13&&16&n?vu.decode(o):null}}},b=e.frame(x),v=e.frame(u),g={preencode(d,o){b.preencode(d,o.pointer),d.end++,o.metadata&&v.preencode(d,o.metadata),o.preview&&Ou.preencode(d,o.preview),o.hash&&e.fixed32.preencode(d,o.hash)},encode(d,o){const n=(o.metadata?1:0)|(o.preview?2:0)|(o.hash?4:0);b.encode(d,o.pointer),e.uint.encode(d,n),o.metadata&&v.encode(d,o.metadata),o.preview&&Ou.encode(d,o.preview),o.hash&&e.fixed32.encode(d,o.hash)},decode(d){const o=b.decode(d),n=e.uint.decode(d);return{pointer:o,metadata:1&n?v.decode(d):null,preview:2&n?Ou.decode(d):null,hash:4&n?e.fixed32.decode(d):null}}},K=e.frame(g),k=K,h=K,w={preencode(e,d){e.end++,d.small&&K.preencode(e,d.small),d.medium&&k.preencode(e,d.medium),d.large&&h.preencode(e,d.large)},encode(d,o){const n=(o.small?1:0)|(o.medium?2:0)|(o.large?4:0);e.uint.encode(d,n),o.small&&K.encode(d,o.small),o.medium&&k.encode(d,o.medium),o.large&&h.encode(d,o.large)},decode(d){const o=e.uint.decode(d);return{small:1&o?K.decode(d):null,medium:2&o?k.decode(d):null,large:4&o?h.decode(d):null}}},P={preencode(e,d){e.end++},encode(d,o){const n=o.isDeleted?1:0;e.uint.encode(d,n)},decode:d=>({isDeleted:!!(1&e.uint.decode(d))})},R=e.frame(P),T=K,A={preencode(d,o){e.uint.preencode(d,o.id),n.preencode(d,o.oplog),R.preencode(d,o.status),T.preencode(d,o.file),d.end++,o.version&&e.uint.preencode(d,o.version)},encode(d,o){const c=o.version?1:0;e.uint.encode(d,o.id),n.encode(d,o.oplog),R.encode(d,o.status),T.encode(d,o.file),e.uint.encode(d,c),o.version&&e.uint.encode(d,o.version)},decode:d=>({id:e.uint.decode(d),oplog:n.decode(d),status:R.decode(d),file:T.decode(d),version:1&e.uint.decode(d)?e.uint.decode(d):0})},S={preencode(e,d){e.end++},encode(d,o){const n=(o.isActive?1:0)|(o.isIndexing?2:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isActive:!!(1&o),isIndexing:!!(2&o)}}},I={preencode(d,o){const n=(o.isAdmin?1:0)|(o.isModerator?2:0)|(o.isPending?4:0)|(o.isActive?8:0)|(o.isMuted?16:0)|(o.isBanned?32:0)|(o.isShadowBanned?64:0)|(o.isRemoved?128:0);e.uint.preencode(d,n)},encode(d,o){const n=(o.isAdmin?1:0)|(o.isModerator?2:0)|(o.isPending?4:0)|(o.isActive?8:0)|(o.isMuted?16:0)|(o.isBanned?32:0)|(o.isShadowBanned?64:0)|(o.isRemoved?128:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isAdmin:!!(1&o),isModerator:!!(2&o),isPending:!!(4&o),isActive:!!(8&o),isMuted:!!(16&o),isBanned:!!(32&o),isShadowBanned:!!(64&o),isRemoved:!!(128&o)}}},M={preencode(e,d){e.end++},encode(d,o){const n=(o.isMuted?1:0)|(o.isBanned?2:0)|(o.isShadowBanned?4:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isMuted:!!(1&o),isBanned:!!(2&o),isShadowBanned:!!(4&o)}}},F={preencode(d,o){e.uint.preencode(d,o.version)},encode(d,o){e.uint.encode(d,o.version)},decode:d=>({version:e.uint.decode(d)})},q={preencode(d,o){e.uint.preencode(d,o.total),e.uint.preencode(d,o.active)},encode(d,o){e.uint.encode(d,o.total),e.uint.encode(d,o.active)},decode:d=>({total:e.uint.decode(d),active:e.uint.decode(d)})},C={preencode(d,o){e.uint.preencode(d,o.total),e.uint.preencode(d,o.active),e.uint.preencode(d,o.pending)},encode(d,o){e.uint.encode(d,o.total),e.uint.encode(d,o.active),e.uint.encode(d,o.pending)},decode:d=>({total:e.uint.decode(d),active:e.uint.decode(d),pending:e.uint.decode(d)})},V={preencode(d,o){e.uint.preencode(d,o.clock),e.uint.preencode(d,o.pinned),e.uint.preencode(d,o.threads),e.uint.preencode(d,o.timestamp),d.end++,o.flagsClock&&e.uint.preencode(d,o.flagsClock)},encode(d,o){const n=o.flagsClock?1:0;e.uint.encode(d,o.clock),e.uint.encode(d,o.pinned),e.uint.encode(d,o.threads),e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.flagsClock&&e.uint.encode(d,o.flagsClock)},decode:d=>({clock:e.uint.decode(d),pinned:e.uint.decode(d),threads:e.uint.decode(d),timestamp:e.uint.decode(d),flagsClock:1&e.uint.decode(d)?e.uint.decode(d):0})},H={preencode(d,o){e.uint.preencode(d,o.clock)},encode(d,o){e.uint.encode(d,o.clock)},decode:d=>({clock:e.uint.decode(d)})},D=e.frame(q),L=e.frame(C),j=e.frame(V),E=e.frame(H),B={preencode(e,o){D.preencode(e,o.devices),L.preencode(e,o.members),j.preencode(e,o.chat),E.preencode(e,o.files),e.end++,d>=12&&o.calls&&Nu.preencode(e,o.calls)},encode(o,n){const c=d>=12&&n.calls?1:0;D.encode(o,n.devices),L.encode(o,n.members),j.encode(o,n.chat),E.encode(o,n.files),e.uint.encode(o,c),d>=12&&n.calls&&Nu.encode(o,n.calls)},decode(o){const n=D.decode(o),c=L.decode(o),r=j.decode(o),t=E.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{devices:n,members:c,chat:r,files:t,calls:d>=12&&1&i?Nu.decode(o):null}}},z={Default:1,Broadcast:2,DirectMessage:3},O={preencode(e,d){e.end++},encode(d,o){if(o>3)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},N={preencode(o,n){const c=(n.roomType?1:0)|(n.isExperimental?2:0)|(n.isJoiningDisabled?4:0)|(n.isAppendingDisabled?8:0)|(n.isCallingDisabled?16:0)|(n.isMembershipEventsDisabled?32:0)|(d>=4&&n.isAttachmentsDisabled?64:0)|(d>=4&&n.isLinksDisabled?128:0)|(d>=5&&n.buildType?256:0)|(d>=9&&n.isRoomInviteHidden?512:0);e.uint.preencode(o,c),n.roomType&&O.preencode(o,n.roomType),d>=5&&n.buildType&&Dp.preencode(o,n.buildType)},encode(o,n){const c=(n.roomType?1:0)|(n.isExperimental?2:0)|(n.isJoiningDisabled?4:0)|(n.isAppendingDisabled?8:0)|(n.isCallingDisabled?16:0)|(n.isMembershipEventsDisabled?32:0)|(d>=4&&n.isAttachmentsDisabled?64:0)|(d>=4&&n.isLinksDisabled?128:0)|(d>=5&&n.buildType?256:0)|(d>=9&&n.isRoomInviteHidden?512:0);e.uint.encode(o,c),n.roomType&&O.encode(o,n.roomType),d>=5&&n.buildType&&Dp.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{roomType:1&n?O.decode(o):0,isExperimental:!!(2&n),isJoiningDisabled:!!(4&n),isAppendingDisabled:!!(8&n),isCallingDisabled:!!(16&n),isMembershipEventsDisabled:!!(32&n),isAttachmentsDisabled:d>=4&&!!(64&n),isLinksDisabled:d>=4&&!!(128&n),buildType:d>=5&&256&n?Dp.decode(o):null,isRoomInviteHidden:d>=9&&!!(512&n)}}},U=e.frame(F),J=e.frame(N),W={preencode(d,o){U.preencode(d,o.abi),J.preencode(d,o.settings),e.uint.preencode(d,o.creationTime)},encode(d,o){U.encode(d,o.abi),J.encode(d,o.settings),e.uint.encode(d,o.creationTime)},decode:d=>({abi:U.decode(d),settings:J.decode(d),creationTime:e.uint.decode(d)})},G={preencode(d,o){e.fixed32.preencode(d,o.seed)},encode(d,o){e.fixed32.encode(d,o.seed)},decode:d=>({seed:e.fixed32.decode(d)})},Q={preencode(d,o){c.preencode(d,o.mailboxKeyPair),r.preencode(d,o.discoveryKeyPair),e.fixed32.preencode(d,o.wakeupTopic),e.fixed32.preencode(d,o.swarmTopic)},encode(d,o){c.encode(d,o.mailboxKeyPair),r.encode(d,o.discoveryKeyPair),e.fixed32.encode(d,o.wakeupTopic),e.fixed32.encode(d,o.swarmTopic)},decode:d=>({mailboxKeyPair:c.decode(d),discoveryKeyPair:r.decode(d),wakeupTopic:e.fixed32.decode(d),swarmTopic:e.fixed32.decode(d)})},X={en:"en",it:"it",ru:"ru",es:"es",de:"de"},Y={preencode(e,d){e.end++},encode(d,o){switch(o){case"en":e.uint.encode(d,1);break;case"it":e.uint.encode(d,2);break;case"ru":e.uint.encode(d,3);break;case"es":e.uint.encode(d,4);break;case"de":e.uint.encode(d,5);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"en";case 2:return"it";case 3:return"ru";case 4:return"es";case 5:return"de";default:return null}}},Z=e.array(Y),$=e.array(e.fixed32),_={preencode(d,o){d.end++,o.title&&e.string.preencode(d,o.title),o.avatar&&Uu.preencode(d,o.avatar),o.description&&e.string.preencode(d,o.description),o.supportedLanguages&&Z.preencode(d,o.supportedLanguages),o.blindPeers&&$.preencode(d,o.blindPeers)},encode(d,o){const n=(o.title?1:0)|(o.avatar?2:0)|(o.description?4:0)|(o.supportedLanguages?8:0)|(o.blindPeers?16:0);e.uint.encode(d,n),o.title&&e.string.encode(d,o.title),o.avatar&&Uu.encode(d,o.avatar),o.description&&e.string.encode(d,o.description),o.supportedLanguages&&Z.encode(d,o.supportedLanguages),o.blindPeers&&$.encode(d,o.blindPeers)},decode(d){const o=e.uint.decode(d);return{title:1&o?e.string.decode(d):null,avatar:2&o?Uu.decode(d):null,description:4&o?e.string.decode(d):null,supportedLanguages:8&o?Z.decode(d):null,blindPeers:16&o?$.decode(d):null}}},ee={preencode(d,o){e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.key)},decode:d=>({key:e.fixed32.decode(d)})},de=e.frame(i),oe=e.frame(ee),ne={preencode(e,d){de.preencode(e,d.header),oe.preencode(e,d.peer)},encode(e,d){de.encode(e,d.header),oe.encode(e,d.peer)},decode:e=>({header:de.decode(e),peer:oe.decode(e)})},ce=de,re={preencode(d,o){ce.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){ce.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:ce.decode(d),key:e.fixed32.decode(d)})},te={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.buffer.preencode(d,o.proof)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.buffer.encode(d,o.proof)},decode:d=>({memberKey:e.fixed32.decode(d),proof:e.buffer.decode(d)})},ie={preencode(d,o){e.fixed32.preencode(d,o.id),e.buffer.preencode(d,o.response)},encode(d,o){e.fixed32.encode(d,o.id),e.buffer.encode(d,o.response)},decode:d=>({id:e.fixed32.decode(d),response:e.buffer.decode(d)})},ae=e.frame(S),se=e.frame(ie),pe={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.memberKey),ae.preencode(d,o.status),Ju.preencode(d,o.profile),d.end++,o.invitation&&se.preencode(d,o.invitation)},encode(d,o){const n=o.invitation?1:0;e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.memberKey),ae.encode(d,o.status),Ju.encode(d,o.profile),e.uint.encode(d,n),o.invitation&&se.encode(d,o.invitation)},decode:d=>({key:e.fixed32.decode(d),memberKey:e.fixed32.decode(d),status:ae.decode(d),profile:Ju.decode(d),invitation:1&e.uint.decode(d)?se.decode(d):null})},ue={preencode(d,o){e.uint.preencode(d,o.timestamp),d.end++,o.mailbox&&e.fixed32.preencode(d,o.mailbox),o.displayName&&e.string.preencode(d,o.displayName),o.avatar&&Wu.preencode(d,o.avatar),o.username&&e.string.preencode(d,o.username)},encode(d,o){const n=(o.mailbox?1:0)|(o.displayName?2:0)|(o.avatar?4:0)|(o.username?8:0);e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.mailbox&&e.fixed32.encode(d,o.mailbox),o.displayName&&e.string.encode(d,o.displayName),o.avatar&&Wu.encode(d,o.avatar),o.username&&e.string.encode(d,o.username)},decode(d){const o=e.uint.decode(d),n=e.uint.decode(d);return{timestamp:o,mailbox:1&n?e.fixed32.decode(d):null,displayName:2&n?e.string.decode(d):null,avatar:4&n?Wu.decode(d):null,username:8&n?e.string.decode(d):null}}},le={preencode(o,n){o.end++,n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),n.name&&e.string.preencode(o,n.name),d>=5&&n.buildType&&Dp.preencode(o,n.buildType)},encode(o,n){const c=(n.swarmKey?1:0)|(n.name?2:0)|(n.isMobile?4:0)|(d>=5&&n.buildType?8:0);e.uint.encode(o,c),n.swarmKey&&e.fixed32.encode(o,n.swarmKey),n.name&&e.string.encode(o,n.name),d>=5&&n.buildType&&Dp.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{swarmKey:1&n?e.fixed32.decode(o):null,name:2&n?e.string.decode(o):null,isMobile:!!(4&n),buildType:d>=5&&8&n?Dp.decode(o):null}}},fe=e.frame(ue),me={preencode(e,d){fe.preencode(e,d.profile),te.preencode(e,d.attestation)},encode(e,d){fe.encode(e,d.profile),te.encode(e,d.attestation)},decode:e=>({profile:fe.decode(e),attestation:te.decode(e)})},ye={preencode(e,d){Gu.preencode(e,d.profile),te.preencode(e,d.attestation)},encode(e,d){Gu.encode(e,d.profile),te.encode(e,d.attestation)},decode:e=>({profile:Gu.decode(e),attestation:te.decode(e)})},xe=fe,be={preencode(e,d){xe.preencode(e,d.profile),te.preencode(e,d.attestation)},encode(e,d){xe.encode(e,d.profile),te.encode(e,d.attestation)},decode:e=>({profile:xe.decode(e),attestation:te.decode(e)})},ve={preencode(d,o){e.fixed32.preencode(d,o.id),e.buffer.preencode(d,o.data),e.buffer.preencode(d,o.signature)},encode(d,o){e.fixed32.encode(d,o.id),e.buffer.encode(d,o.data),e.buffer.encode(d,o.signature)},decode:d=>({id:e.fixed32.decode(d),data:e.buffer.decode(d),signature:e.buffer.decode(d)})},ge={preencode(d,o){e.fixed32.preencode(d,o.devicePublicKey)},encode(d,o){e.fixed32.encode(d,o.devicePublicKey)},decode:d=>({devicePublicKey:e.fixed32.decode(d)})},Ke={preencode(d,o){te.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){te.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({privateProfileIdentity:te.decode(d),deviceProof:e.buffer.decode(d)})},ke={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),te.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){e.fixed32.encode(d,o.deviceKey),te.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({deviceKey:e.fixed32.decode(d),privateProfileIdentity:te.decode(d),deviceProof:e.buffer.decode(d)})},he=e.frame(ye),we=e.frame(me),Pe=e.frame(ge),Re={preencode(n,c){e.fixed32.preencode(n,c.deviceKey),r.preencode(n,c.keyPair),he.preencode(n,c.device),we.preencode(n,c.member),n.end++,c.identity&&Pe.preencode(n,c.identity),d>=13&&c.link&&o.preencode(n,c.link)},encode(n,c){const t=(c.identity?1:0)|(d>=13&&c.link?2:0);e.fixed32.encode(n,c.deviceKey),r.encode(n,c.keyPair),he.encode(n,c.device),we.encode(n,c.member),e.uint.encode(n,t),c.identity&&Pe.encode(n,c.identity),d>=13&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),t=r.decode(n),i=he.decode(n),a=we.decode(n),s=e.uint.decode(n);return{deviceKey:c,keyPair:t,device:i,member:a,identity:1&s?Pe.decode(n):null,link:d>=13&&2&s?o.decode(n):null}}},Te=e.frame(Re),Ae={preencode(d,o){e.fixed32.preencode(d,o.id),Te.preencode(d,o.request),e.buffer.preencode(d,o.signature)},encode(d,o){e.fixed32.encode(d,o.id),Te.encode(d,o.request),e.buffer.encode(d,o.signature)},decode:d=>({id:e.fixed32.decode(d),request:Te.decode(d),signature:e.buffer.decode(d)})},Se=he,Ie=we,Me={preencode(e,d){Se.preencode(e,d.device),e.end++,d.member&&Ie.preencode(e,d.member)},encode(d,o){const n=o.member?1:0;Se.encode(d,o.device),e.uint.encode(d,n),o.member&&Ie.encode(d,o.member)},decode:d=>({device:Se.decode(d),member:1&e.uint.decode(d)?Ie.decode(d):null})},Fe=e.frame(Ae),qe=e.frame(Me),Ce={preencode(e,d){e.end++,d.withInvitation&&Fe.preencode(e,d.withInvitation),d.withMemberProof&&qe.preencode(e,d.withMemberProof)},encode(d,o){const n=(o.withInvitation?1:0)|(o.withMemberProof?2:0);e.uint.encode(d,n),o.withInvitation&&Fe.encode(d,o.withInvitation),o.withMemberProof&&qe.encode(d,o.withMemberProof)},decode(d){const o=e.uint.decode(d);return{withInvitation:1&o?Fe.decode(d):null,withMemberProof:2&o?qe.decode(d):null}}},Ve=e.frame(ve),He=e.frame(Ke),De={preencode(e,d){Ve.preencode(e,d.signedKeys),e.end++,d.identity&&He.preencode(e,d.identity)},encode(d,o){const n=o.identity?1:0;Ve.encode(d,o.signedKeys),e.uint.encode(d,n),o.identity&&He.encode(d,o.identity)},decode:d=>({signedKeys:Ve.decode(d),identity:1&e.uint.decode(d)?He.decode(d):null})},Le={preencode(o,n){o.end++,n.expiration&&e.uint.preencode(o,n.expiration),d>=5&&n.buildType&&Dp.preencode(o,n.buildType)},encode(o,n){const c=(n.expiration?1:0)|(n.requiresConfirmation?2:0)|(n.canModerate?4:0)|(n.canAdmin?8:0)|(d>=5&&n.buildType?16:0);e.uint.encode(o,c),n.expiration&&e.uint.encode(o,n.expiration),d>=5&&n.buildType&&Dp.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{expiration:1&n?e.uint.decode(o):0,requiresConfirmation:!!(2&n),canModerate:!!(4&n),canAdmin:!!(8&n),buildType:d>=5&&16&n?Dp.decode(o):null}}},je=Ve,Ee=e.frame(Le),Be={preencode(d,n){e.fixed32.preencode(d,n.id),je.preencode(d,n.response),Ee.preencode(d,n.metadata),d.end++,n.anchor&&o.preencode(d,n.anchor)},encode(d,n){const c=(n.anchor?1:0)|(n.isActive?2:0);e.fixed32.encode(d,n.id),je.encode(d,n.response),Ee.encode(d,n.metadata),e.uint.encode(d,c),n.anchor&&o.encode(d,n.anchor)},decode(d){const n=e.fixed32.decode(d),c=je.decode(d),r=Ee.decode(d),t=e.uint.decode(d);return{id:n,response:c,metadata:r,anchor:1&t?o.decode(d):null,isActive:!!(2&t)}}},ze=de,Oe=e.frame(Be),Ne={preencode(e,d){ze.preencode(e,d.header),Oe.preencode(e,d.invitation)},encode(e,d){ze.encode(e,d.header),Oe.encode(e,d.invitation)},decode:e=>({header:ze.decode(e),invitation:Oe.decode(e)})},Ue=de,Je={preencode(d,o){Ue.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){Ue.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:Ue.decode(d),id:e.fixed32.decode(d)})},We={preencode(d,n){e.fixed32.preencode(d,n.mailbox),e.fixed32.preencode(d,n.invitationSeed),o.preencode(d,n.anchor)},encode(d,n){e.fixed32.encode(d,n.mailbox),e.fixed32.encode(d,n.invitationSeed),o.encode(d,n.anchor)},decode:d=>({mailbox:e.fixed32.decode(d),invitationSeed:e.fixed32.decode(d),anchor:o.decode(d)})},Ge={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.fixed32.preencode(d,o.encryptionKey),e.fixed32.preencode(d,o.seed),d.end++,o.fastForwardTo&&e.fixed32.preencode(d,o.fastForwardTo)},encode(d,o){const n=o.fastForwardTo?1:0;e.fixed32.encode(d,o.roomKey),e.fixed32.encode(d,o.encryptionKey),e.fixed32.encode(d,o.seed),e.uint.encode(d,n),o.fastForwardTo&&e.fixed32.encode(d,o.fastForwardTo)},decode:d=>({roomKey:e.fixed32.decode(d),encryptionKey:e.fixed32.decode(d),seed:e.fixed32.decode(d),fastForwardTo:1&e.uint.decode(d)?e.fixed32.decode(d):null})},Qe={preencode(d,n){e.fixed32.preencode(d,n.mailbox),e.fixed32.preencode(d,n.invitationSeed),o.preencode(d,n.anchor),e.fixed32.preencode(d,n.identityPublicKey)},encode(d,n){e.fixed32.encode(d,n.mailbox),e.fixed32.encode(d,n.invitationSeed),o.encode(d,n.anchor),e.fixed32.encode(d,n.identityPublicKey)},decode:d=>({mailbox:e.fixed32.decode(d),invitationSeed:e.fixed32.decode(d),anchor:o.decode(d),identityPublicKey:e.fixed32.decode(d)})},Xe={preencode(d,o){e.fixed32.preencode(d,o.mailbox)},encode(d,o){e.fixed32.encode(d,o.mailbox)},decode:d=>({mailbox:e.fixed32.decode(d)})},Ye=e.frame(We),Ze=e.frame(Qe),$e=e.frame(Xe),_e=e.frame(Ge),ed=e.array(e.ipv4Address),dd={preencode(e,o){e.end++,o.room&&Ye.preencode(e,o.room),o.identity&&Ze.preencode(e,o.identity),o.contact&&$e.preencode(e,o.contact),o.readonly&&_e.preencode(e,o.readonly),o.additionalNodes&&ed.preencode(e,o.additionalNodes),d>=5&&o.buildType&&Dp.preencode(e,o.buildType),d>=13&&o["readonly-v2"]&&Qu.preencode(e,o["readonly-v2"])},encode(o,n){const c=(n.room?1:0)|(n.identity?2:0)|(n.contact?4:0)|(n.readonly?8:0)|(n.additionalNodes?16:0)|(d>=5&&n.buildType?32:0)|(d>=13&&n["readonly-v2"]?64:0);e.uint.encode(o,c),n.room&&Ye.encode(o,n.room),n.identity&&Ze.encode(o,n.identity),n.contact&&$e.encode(o,n.contact),n.readonly&&_e.encode(o,n.readonly),n.additionalNodes&&ed.encode(o,n.additionalNodes),d>=5&&n.buildType&&Dp.encode(o,n.buildType),d>=13&&n["readonly-v2"]&&Qu.encode(o,n["readonly-v2"])},decode(o){const n=e.uint.decode(o);return{room:1&n?Ye.decode(o):null,identity:2&n?Ze.decode(o):null,contact:4&n?$e.decode(o):null,readonly:8&n?_e.decode(o):null,additionalNodes:16&n?ed.decode(o):null,buildType:d>=5&&32&n?Dp.decode(o):null,"readonly-v2":d>=13&&64&n?Qu.decode(o):null}}},od=de,nd={preencode(d,o){od.preencode(d,o.header),e.buffer.preencode(d,o.blindRequest)},encode(d,o){od.encode(d,o.header),e.buffer.encode(d,o.blindRequest)},decode:d=>({header:od.decode(d),blindRequest:e.buffer.decode(d)})},cd=de,rd={preencode(o,n){cd.preencode(o,n.header),o.end++,n.profile&&Xu.preencode(o,n.profile),d>=10&&n.key&&e.fixed32.preencode(o,n.key)},encode(o,n){const c=(n.profile?1:0)|(d>=10&&n.key?2:0);cd.encode(o,n.header),e.uint.encode(o,c),n.profile&&Xu.encode(o,n.profile),d>=10&&n.key&&e.fixed32.encode(o,n.key)},decode(o){const n=cd.decode(o),c=e.uint.decode(o);return{header:n,profile:1&c?Xu.decode(o):null,key:d>=10&&2&c?e.fixed32.decode(o):null}}},td=de,id={preencode(d,o){td.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){td.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:td.decode(d),key:e.fixed32.decode(d)})},ad={preencode(e,d){},encode(e,d){},decode:e=>({})},sd=ad,pd=Te,ud={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.id),pd.preencode(d,o.request)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.id),pd.encode(d,o.request)},decode:d=>({deviceKey:e.fixed32.decode(d),id:e.fixed32.decode(d),request:pd.decode(d)})},ld=de,fd=He,md={preencode(d,o){ld.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),d.end++,o.identity&&fd.preencode(d,o.identity)},encode(d,o){const n=o.identity?1:0;ld.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,n),o.identity&&fd.encode(d,o.identity)},decode:d=>({header:ld.decode(d),deviceKey:e.fixed32.decode(d),identity:1&e.uint.decode(d)?fd.decode(d):null})},yd=de,xd={preencode(d,o){yd.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey)},encode(d,o){yd.encode(d,o.header),e.fixed32.encode(d,o.deviceKey)},decode:d=>({header:yd.decode(d),deviceKey:e.fixed32.decode(d)})},bd=e.frame(I),vd=fe,gd={preencode(d,o){e.fixed32.preencode(d,o.key),bd.preencode(d,o.status),vd.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),bd.encode(d,o.status),vd.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),status:bd.decode(d),profile:vd.decode(d)})},Kd=bd,kd=fe,hd={preencode(d,o){e.fixed32.preencode(d,o.key),Kd.preencode(d,o.status),kd.preencode(d,o.profile),d.end++,o.proofs&&Yu.preencode(d,o.proofs)},encode(d,o){const n=o.proofs?1:0;e.fixed32.encode(d,o.key),Kd.encode(d,o.status),kd.encode(d,o.profile),e.uint.encode(d,n),o.proofs&&Yu.encode(d,o.proofs)},decode:d=>({key:e.fixed32.decode(d),status:Kd.decode(d),profile:kd.decode(d),proofs:1&e.uint.decode(d)?Yu.decode(d):null})},wd={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++,o.profileAttestation&&e.buffer.preencode(d,o.profileAttestation),o.latestReceipt&&e.buffer.preencode(d,o.latestReceipt)},encode(d,o){const n=(o.profileAttestation?1:0)|(o.latestReceipt?2:0);e.fixed32.encode(d,o.key),e.uint.encode(d,n),o.profileAttestation&&e.buffer.encode(d,o.profileAttestation),o.latestReceipt&&e.buffer.encode(d,o.latestReceipt)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d);return{key:o,profileAttestation:1&n?e.buffer.decode(d):null,latestReceipt:2&n?e.buffer.decode(d):null}}},Pd=de,Rd=we,Td={preencode(e,d){Pd.preencode(e,d.header),Rd.preencode(e,d.member)},encode(e,d){Pd.encode(e,d.header),Rd.encode(e,d.member)},decode:e=>({header:Pd.decode(e),member:Rd.decode(e)})},Ad=de,Sd=e.frame(M),Id={preencode(d,o){Ad.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),Sd.preencode(d,o.status)},encode(d,o){Ad.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),Sd.encode(d,o.status)},decode:d=>({header:Ad.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:Sd.decode(d)})},Md=de,Fd={preencode(d,o){Md.preencode(d,o.header),e.fixed32.preencode(d,o.key),d.end++},encode(d,o){const n=(o.isModerator?1:0)|(o.isAdmin?2:0);Md.encode(d,o.header),e.fixed32.encode(d,o.key),e.uint.encode(d,n)},decode(d){const o=Md.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{header:o,key:n,isModerator:!!(1&c),isAdmin:!!(2&c)}}},qd=de,Cd={preencode(d,o){qd.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){qd.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:qd.decode(d),key:e.fixed32.decode(d)})},Vd={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.mentions)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.mentions)},decode:d=>({key:e.fixed32.decode(d),mentions:e.uint.decode(d)})},Hd={preencode(d,o){d.end++,o.memberKey&&e.fixed32.preencode(d,o.memberKey)},encode(d,o){const n=o.memberKey?1:0;e.uint.encode(d,n),o.memberKey&&e.fixed32.encode(d,o.memberKey)},decode:d=>({memberKey:1&e.uint.decode(d)?e.fixed32.decode(d):null})},Dd=Hd,Ld=Hd,jd={preencode(d,o){d.end++,o.from&&e.string.preencode(d,o.from),o.to&&e.string.preencode(d,o.to)},encode(d,o){const n=(o.from?1:0)|(o.to?2:0);e.uint.encode(d,n),o.from&&e.string.encode(d,o.from),o.to&&e.string.encode(d,o.to)},decode(d){const o=e.uint.decode(d);return{from:1&o?e.string.decode(d):null,to:2&o?e.string.decode(d):null}}},Ed=e.frame(Hd),Bd=e.frame(Dd),zd=e.frame(jd),Od=e.frame(Ld),Nd={preencode(o,n){const c=(n.memberJoined?1:0)|(n.memberLeft?2:0)|(n.titleChanged?4:0)|(n.callStarted?8:0)|(n.callHangup?16:0)|(n.callMissed?32:0)|(n.roomAvatarChanged?64:0)|(n.invitationCreated?128:0)|(n.memberRemoved?256:0)|(d>=3&&n.locationShared?512:0);e.uint.preencode(o,c),n.memberJoined&&Ed.preencode(o,n.memberJoined),n.memberLeft&&Bd.preencode(o,n.memberLeft),n.titleChanged&&zd.preencode(o,n.titleChanged),n.memberRemoved&&Od.preencode(o,n.memberRemoved),d>=3&&n.locationShared&&Zu.preencode(o,n.locationShared)},encode(o,n){const c=(n.memberJoined?1:0)|(n.memberLeft?2:0)|(n.titleChanged?4:0)|(n.callStarted?8:0)|(n.callHangup?16:0)|(n.callMissed?32:0)|(n.roomAvatarChanged?64:0)|(n.invitationCreated?128:0)|(n.memberRemoved?256:0)|(d>=3&&n.locationShared?512:0);e.uint.encode(o,c),n.memberJoined&&Ed.encode(o,n.memberJoined),n.memberLeft&&Bd.encode(o,n.memberLeft),n.titleChanged&&zd.encode(o,n.titleChanged),n.memberRemoved&&Od.encode(o,n.memberRemoved),d>=3&&n.locationShared&&Zu.encode(o,n.locationShared)},decode(o){const n=e.uint.decode(o);return{memberJoined:1&n?Ed.decode(o):null,memberLeft:2&n?Bd.decode(o):null,titleChanged:4&n?zd.decode(o):null,callStarted:!!(8&n),callHangup:!!(16&n),callMissed:!!(32&n),roomAvatarChanged:!!(64&n),invitationCreated:!!(128&n),memberRemoved:256&n?Od.decode(o):null,locationShared:d>=3&&512&n?Zu.decode(o):null}}},Ud={preencode(e,o){e.end++,d>=3&&o.locationShared&&$u.preencode(e,o.locationShared)},encode(o,n){const c=(n.callStarted?1:0)|(n.callHangup?2:0)|(n.callMissed?4:0)|(d>=3&&n.locationShared?8:0);e.uint.encode(o,c),d>=3&&n.locationShared&&$u.encode(o,n.locationShared)},decode(o){const n=e.uint.decode(o);return{callStarted:!!(1&n),callHangup:!!(2&n),callMissed:!!(4&n),locationShared:d>=3&&8&n?$u.decode(o):null}}},Jd={preencode(d,o){e.uint.preencode(d,o.start),e.uint.preencode(d,o.length)},encode(d,o){e.uint.encode(d,o.start),e.uint.encode(d,o.length)},decode:d=>({start:e.uint.decode(d),length:e.uint.decode(d)})},Wd=e.frame(Jd),Gd={preencode(d,o){Wd.preencode(d,o.range),e.string.preencode(d,o.content)},encode(d,o){Wd.encode(d,o.range),e.string.encode(d,o.content)},decode:d=>({range:Wd.decode(d),content:e.string.decode(d)})},Qd=Wd,Xd={preencode(d,o){Qd.preencode(d,o.range),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Qd.encode(d,o.range),e.fixed32.encode(d,o.memberKey)},decode:d=>({range:Qd.decode(d),memberKey:e.fixed32.decode(d)})},Yd=Wd,Zd={preencode(d,o){Yd.preencode(d,o.range),Y.preencode(d,o.language),e.string.preencode(d,o.text)},encode(d,o){Yd.encode(d,o.range),Y.encode(d,o.language),e.string.encode(d,o.text)},decode:d=>({range:Yd.decode(d),language:Y.decode(d),text:e.string.decode(d)})},$d=K,_d=e.array(e.uint),eo={preencode(d,o){d.end++,o.title&&e.string.preencode(d,o.title),o.description&&e.string.preencode(d,o.description),o.file&&$d.preencode(d,o.file),o.files&&_d.preencode(d,o.files)},encode(d,o){const n=(o.title?1:0)|(o.description?2:0)|(o.file?4:0)|(o.files?8:0);e.uint.encode(d,n),o.title&&e.string.encode(d,o.title),o.description&&e.string.encode(d,o.description),o.file&&$d.encode(d,o.file),o.files&&_d.encode(d,o.files)},decode(d){const o=e.uint.decode(d);return{title:1&o?e.string.decode(d):null,description:2&o?e.string.decode(d):null,file:4&o?$d.decode(d):null,files:8&o?_d.decode(d):null}}},oo=Wd,no=e.frame(eo),co={preencode(d,o){oo.preencode(d,o.range),e.string.preencode(d,o.url),d.end++,o.preview&&no.preencode(d,o.preview)},encode(d,o){const n=o.preview?1:0;oo.encode(d,o.range),e.string.encode(d,o.url),e.uint.encode(d,n),o.preview&&no.encode(d,o.preview)},decode:d=>({range:oo.decode(d),url:e.string.decode(d),preview:1&e.uint.decode(d)?no.decode(d):null})},ro=e.array(e.frame(Xd)),to=e.array(e.frame(co)),io=to,ao=e.array(e.frame(Jd)),so=ao,po=ao,uo=e.array(e.frame(Gd)),lo=ao,fo=ao,mo=e.array(e.frame(Zd)),yo={preencode(d,o){const n=(o.mention?1:0)|(o.httpLink?2:0)|(o.pearLink?4:0)|(o.bold?8:0)|(o.italic?16:0)|(o.code?32:0)|(o.emoji?64:0)|(o.codeBlock?128:0)|(o.strike?256:0)|(o.translation?512:0);e.uint.preencode(d,n),o.mention&&ro.preencode(d,o.mention),o.httpLink&&to.preencode(d,o.httpLink),o.pearLink&&io.preencode(d,o.pearLink),o.bold&&ao.preencode(d,o.bold),o.italic&&so.preencode(d,o.italic),o.code&&po.preencode(d,o.code),o.emoji&&uo.preencode(d,o.emoji),o.codeBlock&&lo.preencode(d,o.codeBlock),o.strike&&fo.preencode(d,o.strike),o.translation&&mo.preencode(d,o.translation)},encode(d,o){const n=(o.mention?1:0)|(o.httpLink?2:0)|(o.pearLink?4:0)|(o.bold?8:0)|(o.italic?16:0)|(o.code?32:0)|(o.emoji?64:0)|(o.codeBlock?128:0)|(o.strike?256:0)|(o.translation?512:0);e.uint.encode(d,n),o.mention&&ro.encode(d,o.mention),o.httpLink&&to.encode(d,o.httpLink),o.pearLink&&io.encode(d,o.pearLink),o.bold&&ao.encode(d,o.bold),o.italic&&so.encode(d,o.italic),o.code&&po.encode(d,o.code),o.emoji&&uo.encode(d,o.emoji),o.codeBlock&&lo.encode(d,o.codeBlock),o.strike&&fo.encode(d,o.strike),o.translation&&mo.encode(d,o.translation)},decode(d){const o=e.uint.decode(d);return{mention:1&o?ro.decode(d):null,httpLink:2&o?to.decode(d):null,pearLink:4&o?io.decode(d):null,bold:8&o?ao.decode(d):null,italic:16&o?so.decode(d):null,code:32&o?po.decode(d):null,emoji:64&o?uo.decode(d):null,codeBlock:128&o?lo.decode(d):null,strike:256&o?fo.decode(d):null,translation:512&o?mo.decode(d):null}}},xo=e.array(e.frame(g)),bo=e.frame(yo),vo=e.frame(Ud),go={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&xo.preencode(d,o.files),o.display&&bo.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent),o.event&&vo.preencode(d,o.event)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(c.event?32:0)|(d>=3&&c.forwarded?64:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&xo.encode(o,c.files),c.display&&bo.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent),c.event&&vo.encode(o,c.event)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?xo.decode(o):null,display:4&c?bo.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,event:32&c?vo.decode(o):null,forwarded:d>=3&&!!(64&c)}}},Ko=_d,ko=bo,ho={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&Ko.preencode(d,o.files),o.display&&ko.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(d>=3&&c.forwarded?32:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&Ko.encode(o,c.files),c.display&&ko.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?Ko.decode(o):null,display:4&c?ko.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,forwarded:d>=3&&!!(32&c)}}},wo=xo,Po=bo,Ro={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&wo.preencode(d,o.files),o.display&&Po.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(d>=3&&c.forwarded?32:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&wo.encode(o,c.files),c.display&&Po.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?wo.decode(o):null,display:4&c?Po.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,forwarded:d>=3&&!!(32&c)}}},To={preencode(e,d){e.end++},encode(d,o){const n=(o.isEdited?1:0)|(o.isDeleted?2:0)|(o.isPinned?4:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isEdited:!!(1&o),isDeleted:!!(2&o),isPinned:!!(4&o)}}},Ao={preencode(d,o){e.uint.preencode(d,o.thread),e.uint.preencode(d,o.index)},encode(d,o){e.uint.encode(d,o.thread),e.uint.encode(d,o.index)},decode:d=>({thread:e.uint.decode(d),index:e.uint.decode(d)})},So=e.frame(B),Io={preencode(d,o){e.uint.preencode(d,o.id),e.uint.preencode(d,o.count),d.end++,o.parent&&n.preencode(d,o.parent),o.stats&&So.preencode(d,o.stats)},encode(d,o){const c=(o.parent?1:0)|(o.stats?2:0);e.uint.encode(d,o.id),e.uint.encode(d,o.count),e.uint.encode(d,c),o.parent&&n.encode(d,o.parent),o.stats&&So.encode(d,o.stats)},decode(d){const o=e.uint.decode(d),c=e.uint.decode(d),r=e.uint.decode(d);return{id:o,count:c,parent:1&r?n.decode(d):null,stats:2&r?So.decode(d):null}}},Mo=e.frame(To),Fo=e.frame(ho),qo=e.frame(Nd),Co={preencode(d,o){Ao.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),Mo.preencode(d,o.status),o.message&&Fo.preencode(d,o.message),o.event&&qo.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);Ao.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),Mo.encode(d,o.status),o.message&&Fo.encode(d,o.message),o.event&&qo.encode(d,o.event)},decode(d){const o=Ao.decode(d),c=n.decode(d),r=e.uint.decode(d),t=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:r,timestamp:t,editedAt:1&i?e.uint.decode(d):0,status:Mo.decode(d),message:2&i?Fo.decode(d):null,event:4&i?qo.decode(d):null}}},Vo=Mo,Ho=e.frame(Ro),Do=qo,Lo={preencode(d,o){Ao.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),Vo.preencode(d,o.status),o.message&&Ho.preencode(d,o.message),o.event&&Do.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);Ao.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),Vo.encode(d,o.status),o.message&&Ho.encode(d,o.message),o.event&&Do.encode(d,o.event)},decode(d){const o=Ao.decode(d),c=n.decode(d),r=e.uint.decode(d),t=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:r,timestamp:t,editedAt:1&i?e.uint.decode(d):0,status:Vo.decode(d),message:2&i?Ho.decode(d):null,event:4&i?Do.decode(d):null}}},jo=de,Eo=e.frame(go),Bo={preencode(e,d){jo.preencode(e,d.header),Eo.preencode(e,d.message)},encode(e,d){jo.encode(e,d.header),Eo.encode(e,d.message)},decode:e=>({header:jo.decode(e),message:Eo.decode(e)})},zo=de,Oo={preencode(e,d){zo.preencode(e,d.header),n.preencode(e,d.oplog)},encode(e,d){zo.encode(e,d.header),n.encode(e,d.oplog)},decode:e=>({header:zo.decode(e),oplog:n.decode(e)})},No=de,Uo=Eo,Jo={preencode(e,d){No.preencode(e,d.header),n.preencode(e,d.oplog),Uo.preencode(e,d.message)},encode(e,d){No.encode(e,d.header),n.encode(e,d.oplog),Uo.encode(e,d.message)},decode:e=>({header:No.decode(e),oplog:n.decode(e),message:Uo.decode(e)})},Wo=de,Go={preencode(e,d){Wo.preencode(e,d.header),n.preencode(e,d.oplog),e.end++},encode(d,o){const c=o.isPinned?1:0;Wo.encode(d,o.header),n.encode(d,o.oplog),e.uint.encode(d,c)},decode:d=>({header:Wo.decode(d),oplog:n.decode(d),isPinned:!!(1&e.uint.decode(d))})},Qo={HttpLink:1,PearLink:2},Xo={preencode(e,d){e.end++},encode(d,o){if(o>2)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Yo=de,Zo={preencode(d,o){Yo.preencode(d,o.header),n.preencode(d,o.oplog),e.uint.preencode(d,o.index),_u.preencode(d,o.preview),d.end++,o.displayType&&Xo.preencode(d,o.displayType)},encode(d,o){const c=o.displayType?1:0;Yo.encode(d,o.header),n.encode(d,o.oplog),e.uint.encode(d,o.index),_u.encode(d,o.preview),e.uint.encode(d,c),o.displayType&&Xo.encode(d,o.displayType)},decode:d=>({header:Yo.decode(d),oplog:n.decode(d),index:e.uint.decode(d),preview:_u.decode(d),displayType:1&e.uint.decode(d)?Xo.decode(d):0})},$o={preencode(d,o){Ao.preencode(d,o.id),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),e.string.preencode(d,o.reaction)},encode(d,o){Ao.encode(d,o.id),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),e.string.encode(d,o.reaction)},decode:d=>({id:Ao.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),reaction:e.string.decode(d)})},_o={preencode(d,o){e.string.preencode(d,o.text),e.uint.preencode(d,o.count)},encode(d,o){e.string.encode(d,o.text),e.uint.encode(d,o.count)},decode:d=>({text:e.string.decode(d),count:e.uint.decode(d)})},en=e.array(e.frame(_o)),dn={preencode(d,o){Ao.preencode(d,o.id),e.uint.preencode(d,o.total),en.preencode(d,o.reactions),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt)},encode(d,o){const n=o.editedAt?1:0;Ao.encode(d,o.id),e.uint.encode(d,o.total),en.encode(d,o.reactions),e.uint.encode(d,n),o.editedAt&&e.uint.encode(d,o.editedAt)},decode:d=>({id:Ao.decode(d),total:e.uint.decode(d),reactions:en.decode(d),editedAt:1&e.uint.decode(d)?e.uint.decode(d):0})},on=de,nn={preencode(d,o){on.preencode(d,o.header),n.preencode(d,o.oplog),e.string.preencode(d,o.reaction)},encode(d,o){on.encode(d,o.header),n.encode(d,o.oplog),e.string.encode(d,o.reaction)},decode:d=>({header:on.decode(d),oplog:n.decode(d),reaction:e.string.decode(d)})},cn=de,rn={preencode(d,o){cn.preencode(d,o.header),n.preencode(d,o.oplog),e.string.preencode(d,o.reaction)},encode(d,o){cn.encode(d,o.header),n.encode(d,o.oplog),e.string.encode(d,o.reaction)},decode:d=>({header:cn.decode(d),oplog:n.decode(d),reaction:e.string.decode(d)})},tn=de,an=e.frame(_),sn={preencode(d,o){tn.preencode(d,o.header),e.uint.preencode(d,o.key),an.preencode(d,o.config)},encode(d,o){tn.encode(d,o.header),e.uint.encode(d,o.key),an.encode(d,o.config)},decode:d=>({header:tn.decode(d),key:e.uint.decode(d),config:an.decode(d)})},pn={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.string.preencode(d,o.displayName),d.end++,o.avatar&&el.preencode(d,o.avatar)},encode(d,o){const n=o.avatar?1:0;e.fixed32.encode(d,o.memberKey),e.string.encode(d,o.displayName),e.uint.encode(d,n),o.avatar&&el.encode(d,o.avatar)},decode:d=>({memberKey:e.fixed32.decode(d),displayName:e.string.decode(d),avatar:1&e.uint.decode(d)?el.decode(d):null})},un={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++,o.username&&e.string.preencode(d,o.username)},encode(d,o){const n=o.username?1:0;e.fixed32.encode(d,o.key),e.uint.encode(d,n),o.username&&e.string.encode(d,o.username)},decode:d=>({key:e.fixed32.decode(d),username:1&e.uint.decode(d)?e.string.decode(d):null})},ln=e.frame(un),fn={preencode(d,o){e.fixed32.preencode(d,o.publicKey),d.end++,o.discoveryCoreKey&&e.fixed32.preencode(d,o.discoveryCoreKey),o.userRegistry&&ln.preencode(d,o.userRegistry)},encode(d,o){const n=(o.discoveryCoreKey?1:0)|(o.userRegistry?2:0);e.fixed32.encode(d,o.publicKey),e.uint.encode(d,n),o.discoveryCoreKey&&e.fixed32.encode(d,o.discoveryCoreKey),o.userRegistry&&ln.encode(d,o.userRegistry)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d);return{publicKey:o,discoveryCoreKey:1&n?e.fixed32.decode(d):null,userRegistry:2&n?ln.decode(d):null}}},mn=de,yn=e.frame(W),xn=e.frame(G),bn=an,vn=e.frame(fn),gn=he,Kn=e.array(e.frame(me)),kn={preencode(e,d){mn.preencode(e,d.header),yn.preencode(e,d.digest),xn.preencode(e,d.capabilities),e.end++,d.config&&bn.preencode(e,d.config),d.identity&&vn.preencode(e,d.identity),d.bootstrapDevice&&gn.preencode(e,d.bootstrapDevice),d.initialMembers&&Kn.preencode(e,d.initialMembers)},encode(d,o){const n=(o.config?1:0)|(o.identity?2:0)|(o.bootstrapDevice?4:0)|(o.initialMembers?8:0);mn.encode(d,o.header),yn.encode(d,o.digest),xn.encode(d,o.capabilities),e.uint.encode(d,n),o.config&&bn.encode(d,o.config),o.identity&&vn.encode(d,o.identity),o.bootstrapDevice&&gn.encode(d,o.bootstrapDevice),o.initialMembers&&Kn.encode(d,o.initialMembers)},decode(d){const o=mn.decode(d),n=yn.decode(d),c=xn.decode(d),r=e.uint.decode(d);return{header:o,digest:n,capabilities:c,config:1&r?bn.decode(d):null,identity:2&r?vn.decode(d):null,bootstrapDevice:4&r?gn.decode(d):null,initialMembers:8&r?Kn.decode(d):null}}},hn=de,wn={preencode(d,o){hn.preencode(d,o.header),e.uint.preencode(d,o.version)},encode(d,o){hn.encode(d,o.header),e.uint.encode(d,o.version)},decode:d=>({header:hn.decode(d),version:e.uint.decode(d)})},Pn=de,Rn={preencode(o,n){Pn.preencode(o,n.header),e.uint.preencode(o,n.from),e.uint.preencode(o,n.to),o.end++,d>=5&&n.buildType&&Dp.preencode(o,n.buildType)},encode(o,n){const c=d>=5&&n.buildType?1:0;Pn.encode(o,n.header),e.uint.encode(o,n.from),e.uint.encode(o,n.to),e.uint.encode(o,c),d>=5&&n.buildType&&Dp.encode(o,n.buildType)},decode(o){const n=Pn.decode(o),c=e.uint.decode(o),r=e.uint.decode(o),t=o.start<o.end?e.uint.decode(o):0;return{header:n,from:c,to:r,buildType:d>=5&&1&t?Dp.decode(o):null}}},Tn={RoomType:1,IsExperimental:2,IsJoiningDisabled:3,IsAppendingDisabled:4,IsCallingDisabled:5,IsMembershipEventsDisabled:6,IsAttachmentsDisabled:7,IsLinksDisabled:8,IsRoomInviteHidden:9},An={preencode(e,d){e.end++},encode(d,o){if(o>9)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Sn=de,In=J,Mn={preencode(d,o){Sn.preencode(d,o.header),e.uint.preencode(d,o.key),In.preencode(d,o.settings)},encode(d,o){Sn.encode(d,o.header),e.uint.encode(d,o.key),In.encode(d,o.settings)},decode:d=>({header:Sn.decode(d),key:e.uint.decode(d),settings:In.decode(d)})},Fn=de,qn={preencode(d,o){Fn.preencode(d,o.header),e.uint.preencode(d,o.value)},encode(d,o){Fn.encode(d,o.header),e.uint.encode(d,o.value)},decode:d=>({header:Fn.decode(d),value:e.uint.decode(d)})},Cn={preencode(d,o){e.uint.preencode(d,o.key),e.uint.preencode(d,o.value)},encode(d,o){e.uint.encode(d,o.key),e.uint.encode(d,o.value)},decode:d=>({key:e.uint.decode(d),value:e.uint.decode(d)})},Vn={Flag:1},Hn={preencode(e,d){e.end++},encode(d,o){if(o>1)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Dn={preencode(d,o){Ao.preencode(d,o.id),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),Hn.preencode(d,o.label)},encode(d,o){Ao.encode(d,o.id),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),Hn.encode(d,o.label)},decode:d=>({id:Ao.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),label:Hn.decode(d)})},Ln=de,jn={preencode(e,d){Ln.preencode(e,d.header),n.preencode(e,d.oplog),Hn.preencode(e,d.label)},encode(e,d){Ln.encode(e,d.header),n.encode(e,d.oplog),Hn.encode(e,d.label)},decode:e=>({header:Ln.decode(e),oplog:n.decode(e),label:Hn.decode(e)})},En=de,Bn={preencode(e,d){En.preencode(e,d.header),n.preencode(e,d.oplog),Hn.preencode(e,d.label)},encode(e,d){En.encode(e,d.header),n.encode(e,d.oplog),Hn.encode(e,d.label)},decode:e=>({header:En.decode(e),oplog:n.decode(e),label:Hn.decode(e)})},zn={preencode(d,o){Hn.preencode(d,o.label),e.uint.preencode(d,o.count)},encode(d,o){Hn.encode(d,o.label),e.uint.encode(d,o.count)},decode:d=>({label:Hn.decode(d),count:e.uint.decode(d)})},On=e.array(e.frame(zn)),Nn={preencode(d,o){Ao.preencode(d,o.id),e.uint.preencode(d,o.total),On.preencode(d,o.labels),e.uint.preencode(d,o.editedAt),d.end++,o.flagsClock&&e.uint.preencode(d,o.flagsClock),o.version&&e.uint.preencode(d,o.version)},encode(d,o){const n=(o.flagsClock?1:0)|(o.version?2:0)|(o.isDeleted?4:0);Ao.encode(d,o.id),e.uint.encode(d,o.total),On.encode(d,o.labels),e.uint.encode(d,o.editedAt),e.uint.encode(d,n),o.flagsClock&&e.uint.encode(d,o.flagsClock),o.version&&e.uint.encode(d,o.version)},decode(d){const o=Ao.decode(d),n=e.uint.decode(d),c=On.decode(d),r=e.uint.decode(d),t=e.uint.decode(d);return{id:o,total:n,labels:c,editedAt:r,flagsClock:1&t?e.uint.decode(d):0,version:2&t?e.uint.decode(d):0,isDeleted:!!(4&t)}}},Un=de,Jn={preencode(d,o){Un.preencode(d,o.header),e.uint.preencode(d,o.length)},encode(d,o){Un.encode(d,o.header),e.uint.encode(d,o.length)},decode:d=>({header:Un.decode(d),length:e.uint.decode(d)})},Wn={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.length)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.length)},decode:d=>({memberKey:e.fixed32.decode(d),length:e.uint.decode(d)})},Gn=ee,Qn=e.frame(be),Xn={preencode(o,n){e.fixed32.preencode(o,n.memberKey),dl.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=8&&n.contactInfo&&Qn.preencode(o,n.contactInfo),d>=8&&n.version&&e.uint.preencode(o,n.version),d>=10&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=8&&n.contactInfo?4:0)|(d>=8&&n.version?8:0)|(d>=10&&n.alias?16:0);e.fixed32.encode(o,n.memberKey),dl.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=8&&n.contactInfo&&Qn.encode(o,n.contactInfo),d>=8&&n.version&&e.uint.encode(o,n.version),d>=10&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.fixed32.decode(o),c=dl.decode(o),r=e.uint.decode(o);return{memberKey:n,status:c,mailbox:1&r?e.fixed32.decode(o):null,roomKey:2&r?e.fixed32.decode(o):null,contactInfo:d>=8&&4&r?Qn.decode(o):null,version:d>=8&&8&r?e.uint.decode(o):0,alias:d>=10&&16&r?e.string.decode(o):null}}},Yn={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.seed),o.preencode(d,n.initiator),e.fixed32.preencode(d,n.fastForwardTo)},encode(d,n){e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.fixed32.encode(d,n.seed),o.encode(d,n.initiator),e.fixed32.encode(d,n.fastForwardTo)},decode:d=>({roomKey:e.fixed32.decode(d),encryptionKey:e.buffer.decode(d),seed:e.fixed32.decode(d),initiator:o.decode(d),fastForwardTo:e.fixed32.decode(d)})},Zn=e.array(e.frame(Yn)),$n=$,_n={preencode(e,d){Zn.preencode(e,d.sharedRooms),$n.preencode(e,d.blockedContacts)},encode(e,d){Zn.encode(e,d.sharedRooms),$n.encode(e,d.blockedContacts)},decode:e=>({sharedRooms:Zn.decode(e),blockedContacts:$n.decode(e)})},ec=vn,dc={preencode(e,d){ec.preencode(e,d.identity)},encode(e,d){ec.encode(e,d.identity)},decode:e=>({identity:ec.decode(e)})},oc={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.contacts)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.contacts)},decode:d=>({rooms:e.uint.decode(d),contacts:e.uint.decode(d)})},nc={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.contactRequests)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.contactRequests)},decode:d=>({rooms:e.uint.decode(d),contactRequests:e.uint.decode(d)})},cc={preencode(d,o){e.buffer.preencode(d,o.entropy)},encode(d,o){e.buffer.encode(d,o.entropy)},decode:d=>({entropy:e.buffer.decode(d)})},rc={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.devicePublicKey),e.fixed32.preencode(d,o.writerKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.devicePublicKey),e.fixed32.encode(d,o.writerKey)},decode:d=>({publicKey:e.fixed32.decode(d),devicePublicKey:e.fixed32.decode(d),writerKey:e.fixed32.decode(d)})},tc=e.frame(rc),ic={preencode(n,c){e.fixed32.preencode(n,c.id),e.fixed32.preencode(n,c.invitationSeed),e.fixed32.preencode(n,c.mailbox),r.preencode(n,c.responseKeyPair),o.preencode(n,c.initiator),o.preencode(n,c.inviter),n.end++,c.identity&&tc.preencode(n,c.identity),d>=5&&c.buildType&&Dp.preencode(n,c.buildType),d>=13&&c.link&&o.preencode(n,c.link)},encode(n,c){const t=(c.identity?1:0)|(d>=5&&c.buildType?2:0)|(d>=13&&c.link?4:0);e.fixed32.encode(n,c.id),e.fixed32.encode(n,c.invitationSeed),e.fixed32.encode(n,c.mailbox),r.encode(n,c.responseKeyPair),o.encode(n,c.initiator),o.encode(n,c.inviter),e.uint.encode(n,t),c.identity&&tc.encode(n,c.identity),d>=5&&c.buildType&&Dp.encode(n,c.buildType),d>=13&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),t=e.fixed32.decode(n),i=e.fixed32.decode(n),a=r.decode(n),s=o.decode(n),p=o.decode(n),u=e.uint.decode(n);return{id:c,invitationSeed:t,mailbox:i,responseKeyPair:a,initiator:s,inviter:p,identity:1&u?tc.decode(n):null,buildType:d>=5&&2&u?Dp.decode(n):null,link:d>=13&&4&u?o.decode(n):null}}},ac=de,sc={preencode(d,o){ac.preencode(d,o.header),e.buffer.preencode(d,o.blindResponse)},encode(d,o){ac.encode(d,o.header),e.buffer.encode(d,o.blindResponse)},decode:d=>({header:ac.decode(d),blindResponse:e.buffer.decode(d)})},pc=de,uc=e.frame(ic),lc={preencode(e,d){pc.preencode(e,d.header),uc.preencode(e,d.invitation)},encode(e,d){pc.encode(e,d.header),uc.encode(e,d.invitation)},decode:e=>({header:pc.decode(e),invitation:uc.decode(e)})},fc=de,mc={preencode(d,o){fc.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){fc.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:fc.decode(d),id:e.fixed32.decode(d)})},yc={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.devicePublicKey),d.end++,o.privateProfileKey&&e.fixed32.preencode(d,o.privateProfileKey),o.deviceKeyPair&&r.preencode(d,o.deviceKeyPair),e.buffer.preencode(d,o.deviceProof)},encode(d,o){const n=(o.privateProfileKey?1:0)|(o.deviceKeyPair?2:0);e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.devicePublicKey),e.uint.encode(d,n),o.privateProfileKey&&e.fixed32.encode(d,o.privateProfileKey),o.deviceKeyPair&&r.encode(d,o.deviceKeyPair),e.buffer.encode(d,o.deviceProof)},decode(d){const o=e.fixed32.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{publicKey:o,devicePublicKey:n,privateProfileKey:1&c?e.fixed32.decode(d):null,deviceKeyPair:2&c?r.decode(d):null,deviceProof:e.buffer.decode(d)}}},xc={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.writerKey),e.fixed32.preencode(d,o.devicePublicKey),d.end++,o.privateProfileKey&&e.fixed32.preencode(d,o.privateProfileKey)},encode(d,o){const n=o.privateProfileKey?1:0;e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.writerKey),e.fixed32.encode(d,o.devicePublicKey),e.uint.encode(d,n),o.privateProfileKey&&e.fixed32.encode(d,o.privateProfileKey)},decode:d=>({publicKey:e.fixed32.decode(d),writerKey:e.fixed32.decode(d),devicePublicKey:e.fixed32.decode(d),privateProfileKey:1&e.uint.decode(d)?e.fixed32.decode(d):null})},bc={preencode(o,n){o.end++,d>=11&&n.roomSnoozeTime&&e.uint.preencode(o,n.roomSnoozeTime)},encode(o,n){const c=(n.isActive?1:0)|(n.isFullyMuted?2:0)|(n.isMentionsOnlyMuted?4:0)|(n.isReadOnly?8:0)|(d>=3&&n.isFavorite?16:0)|(d>=7&&n.isUnread?32:0)|(d>=11&&n.roomSnoozeTime?64:0);e.uint.encode(o,c),d>=11&&n.roomSnoozeTime&&e.uint.encode(o,n.roomSnoozeTime)},decode(o){const n=e.uint.decode(o);return{isActive:!!(1&n),isFullyMuted:!!(2&n),isMentionsOnlyMuted:!!(4&n),isReadOnly:!!(8&n),isFavorite:d>=3&&!!(16&n),isUnread:d>=7&&!!(32&n),roomSnoozeTime:d>=11&&64&n?e.uint.decode(o):0}}},vc=e.frame(bc),gc=e.frame(yc),Kc=tc,kc={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),vc.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,c.initiator&&o.preencode(n,c.initiator),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),c.identitySwap&&gc.preencode(n,c.identitySwap),c.identitySwapV2&&Kc.preencode(n,c.identitySwapV2),c.contact&&e.fixed32.preencode(n,c.contact),d>=13&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=15&&c.activeClock&&e.uint.preencode(n,c.activeClock)},encode(n,c){const r=(c.initiator?1:0)|(c.fastForwardTo?2:0)|(c.identitySwap?4:0)|(c.identitySwapV2?8:0)|(c.contact?16:0)|(d>=13&&c.bootFrom?32:0)|(d>=15&&c.activeClock?64:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),vc.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,r),c.initiator&&o.encode(n,c.initiator),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),c.identitySwap&&gc.encode(n,c.identitySwap),c.identitySwapV2&&Kc.encode(n,c.identitySwapV2),c.contact&&e.fixed32.encode(n,c.contact),d>=13&&c.bootFrom&&o.encode(n,c.bootFrom),d>=15&&c.activeClock&&e.uint.encode(n,c.activeClock)},decode(n){const c=e.fixed32.decode(n),r=e.buffer.decode(n),t=e.fixed32.decode(n),i=vc.decode(n),a=e.uint.decode(n),s=e.uint.decode(n);return{roomKey:c,encryptionKey:r,mailbox:t,status:i,clock:a,initiator:1&s?o.decode(n):null,fastForwardTo:2&s?e.fixed32.decode(n):null,identitySwap:4&s?gc.decode(n):null,identitySwapV2:8&s?Kc.decode(n):null,contact:16&s?e.fixed32.decode(n):null,bootFrom:d>=13&&32&s?o.decode(n):null,activeClock:d>=15&&64&s?e.uint.decode(n):0}}},hc=de,wc={preencode(d,n){hc.preencode(d,n.header),e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.mailbox),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.dm&&e.fixed32.preencode(d,n.dm)},encode(d,n){const c=(n.fastForwardTo?1:0)|(n.initiator?2:0)|(n.dm?4:0)|(n.isReadOnly?8:0);hc.encode(d,n.header),e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.fixed32.encode(d,n.mailbox),e.uint.encode(d,c),n.fastForwardTo&&e.fixed32.encode(d,n.fastForwardTo),n.initiator&&o.encode(d,n.initiator),n.dm&&e.fixed32.encode(d,n.dm)},decode(d){const n=hc.decode(d),c=e.fixed32.decode(d),r=e.buffer.decode(d),t=e.fixed32.decode(d),i=e.uint.decode(d);return{header:n,roomKey:c,encryptionKey:r,mailbox:t,fastForwardTo:1&i?e.fixed32.decode(d):null,initiator:2&i?o.decode(d):null,dm:4&i?e.fixed32.decode(d):null,isReadOnly:!!(8&i)}}},Pc=de,Rc={preencode(d,o){Pc.preencode(d,o.header),e.fixed32.preencode(d,o.discoveryKey)},encode(d,o){Pc.encode(d,o.header),e.fixed32.encode(d,o.discoveryKey)},decode:d=>({header:Pc.decode(d),discoveryKey:e.fixed32.decode(d)})},Tc=de,Ac=vc,Sc={preencode(d,o){Tc.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.key),Ac.preencode(d,o.status)},encode(d,o){Tc.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.key),Ac.encode(d,o.status)},decode:d=>({header:Tc.decode(d),roomKey:e.fixed32.decode(d),key:e.uint.decode(d),status:Ac.decode(d)})},Ic={preencode(e,d){e.end++},encode(o,n){const c=(n.isBlocked?1:0)|(d>=8&&n.isActive?2:0);e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{isBlocked:!!(1&n),isActive:d>=8&&!!(2&n)}}},Mc=Qn,Fc={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.clock),ol.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=8&&n.contactInfo&&Mc.preencode(o,n.contactInfo),d>=10&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=8&&n.contactInfo?4:0)|(d>=10&&n.alias?8:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.clock),ol.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=8&&n.contactInfo&&Mc.encode(o,n.contactInfo),d>=10&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),r=ol.decode(o),t=e.uint.decode(o);return{memberKey:n,clock:c,status:r,mailbox:1&t?e.fixed32.decode(o):null,roomKey:2&t?e.fixed32.decode(o):null,contactInfo:d>=8&&4&t?Mc.decode(o):null,alias:d>=10&&8&t?e.string.decode(o):null}}},qc=de,Cc=e.frame(Xn),Vc={preencode(e,d){qc.preencode(e,d.header),Cc.preencode(e,d.contact)},encode(e,d){qc.encode(e,d.header),Cc.encode(e,d.contact)},decode:e=>({header:qc.decode(e),contact:Cc.decode(e)})},Hc=de,Dc={preencode(d,o){Hc.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),nl.preencode(d,o.status)},encode(d,o){Hc.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),nl.encode(d,o.status)},decode:d=>({header:Hc.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:nl.decode(d)})},Lc=de,jc={preencode(d,o){Lc.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Lc.encode(d,o.header),e.fixed32.encode(d,o.memberKey)},decode:d=>({header:Lc.decode(d),memberKey:e.fixed32.decode(d)})},Ec=de,Bc={preencode(d,o){Ec.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Ec.encode(d,o.header),e.fixed32.encode(d,o.memberKey)},decode:d=>({header:Ec.decode(d),memberKey:e.fixed32.decode(d)})},zc={preencode(e,d){e.end++},encode(d,o){const n=(o.isPending?1:0)|(o.isAccepted?2:0)|(o.isRejected?4:0)|(o.isDiscarded?8:0)|(o.isSeen?16:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isPending:!!(1&o),isAccepted:!!(2&o),isRejected:!!(4&o),isDiscarded:!!(8&o),isSeen:!!(16&o)}}},Oc=we,Nc=e.frame(t),Uc={preencode(d,o){Oc.preencode(d,o.sender),Nc.preencode(d,o.keys),e.fixed32.preencode(d,o.mailbox),d.end++,o.message&&e.string.preencode(d,o.message)},encode(d,o){const n=o.message?1:0;Oc.encode(d,o.sender),Nc.encode(d,o.keys),e.fixed32.encode(d,o.mailbox),e.uint.encode(d,n),o.message&&e.string.encode(d,o.message)},decode:d=>({sender:Oc.decode(d),keys:Nc.decode(d),mailbox:e.fixed32.decode(d),message:1&e.uint.decode(d)?e.string.decode(d):null})},Jc=e.frame(Uc),Wc={preencode(e,d){Jc.preencode(e,d.body),te.preencode(e,d.attestation)},encode(e,d){Jc.encode(e,d.body),te.encode(e,d.attestation)},decode:e=>({body:Jc.decode(e),attestation:te.decode(e)})},Gc=fe,Qc=e.frame(zc),Xc=Nc,Yc=Qn,Zc={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.clock),Gc.preencode(o,n.sender),Qc.preencode(o,n.status),Xc.preencode(o,n.keys),e.fixed32.preencode(o,n.mailbox),o.end++,n.message&&e.string.preencode(o,n.message),n.sentAt&&e.uint.preencode(o,n.sentAt),d>=8&&n.contactInfo&&Yc.preencode(o,n.contactInfo)},encode(o,n){const c=(n.message?1:0)|(n.sentAt?2:0)|(d>=8&&n.contactInfo?4:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.clock),Gc.encode(o,n.sender),Qc.encode(o,n.status),Xc.encode(o,n.keys),e.fixed32.encode(o,n.mailbox),e.uint.encode(o,c),n.message&&e.string.encode(o,n.message),n.sentAt&&e.uint.encode(o,n.sentAt),d>=8&&n.contactInfo&&Yc.encode(o,n.contactInfo)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),r=Gc.decode(o),t=Qc.decode(o),i=Xc.decode(o),a=e.fixed32.decode(o),s=e.uint.decode(o);return{memberKey:n,clock:c,sender:r,status:t,keys:i,mailbox:a,message:1&s?e.string.decode(o):null,sentAt:2&s?e.uint.decode(o):0,contactInfo:d>=8&&4&s?Yc.decode(o):null}}},$c=de,_c={preencode(d,o){$c.preencode(d,o.header),e.buffer.preencode(d,o.blindRequest)},encode(d,o){$c.encode(d,o.header),e.buffer.encode(d,o.blindRequest)},decode:d=>({header:$c.decode(d),blindRequest:e.buffer.decode(d)})},er=de,dr=Qc,or={preencode(d,o){er.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),dr.preencode(d,o.status),d.end++,o.roomKey&&e.fixed32.preencode(d,o.roomKey)},encode(d,o){const n=o.roomKey?1:0;er.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),dr.encode(d,o.status),e.uint.encode(d,n),o.roomKey&&e.fixed32.encode(d,o.roomKey)},decode:d=>({header:er.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:dr.decode(d),roomKey:1&e.uint.decode(d)?e.fixed32.decode(d):null})},nr={preencode(d,o){e.uint.preencode(d,o.timestamp),e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.mailbox)},encode(d,o){e.uint.encode(d,o.timestamp),e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.mailbox)},decode:d=>({version:e.uint.decode(d),timestamp:e.uint.decode(d),key:e.fixed32.decode(d),mailbox:e.fixed32.decode(d)})},cr={preencode(d,o){const n=o.version??1;switch(e.uint.preencode(d,n),n){case 0:case 1:nr.preencode(d,o);break;default:throw new Error("Unsupported version")}},encode(d,o){const n=o.version??1;switch(e.uint.encode(d,n),n){case 0:case 1:nr.encode(d,o);break;default:throw new Error("Unsupported version")}},decode(d){const o=d.start,n=e.uint.decode(d);switch(d.start=o,n){case 0:case 1:return nr.decode(d);default:throw new Error("Unsupported version")}}},rr={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.key)},decode:d=>({deviceKey:e.fixed32.decode(d),key:e.fixed32.decode(d)})},tr=de,ir={preencode(d,o){tr.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){tr.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:tr.decode(d),key:e.fixed32.decode(d)})},ar=de,sr={preencode(d,o){ar.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){ar.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:ar.decode(d),key:e.fixed32.decode(d)})},pr={preencode(o,n){o.end++,d>=9&&n.profileSnoozeTime&&e.uint.preencode(o,n.profileSnoozeTime)},encode(o,n){const c=(n.disableReadReceipts?1:0)|(d>=7&&n.stripAttachmentMetadata?2:0)|(d>=9&&n.profileSnoozeTime?4:0);e.uint.encode(o,c),d>=9&&n.profileSnoozeTime&&e.uint.encode(o,n.profileSnoozeTime)},decode(o){const n=e.uint.decode(o);return{disableReadReceipts:!!(1&n),stripAttachmentMetadata:d>=7&&!!(2&n),profileSnoozeTime:d>=9&&4&n?e.uint.decode(o):0}}},ur={disableReadReceipts:"disableReadReceipts",stripAttachmentMetadata:"stripAttachmentMetadata",profileSnoozeTime:"profileSnoozeTime"},lr={preencode(e,d){e.end++},encode(d,o){switch(o){case"disableReadReceipts":e.uint.encode(d,1);break;case"stripAttachmentMetadata":e.uint.encode(d,2);break;case"profileSnoozeTime":e.uint.encode(d,3);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"disableReadReceipts";case 2:return"stripAttachmentMetadata";case 3:return"profileSnoozeTime";default:return null}}},fr=de,mr=e.frame(pr),yr={preencode(e,d){fr.preencode(e,d.header),lr.preencode(e,d.key),mr.preencode(e,d.settings)},encode(e,d){fr.encode(e,d.header),lr.encode(e,d.key),mr.encode(e,d.settings)},decode:e=>({header:fr.decode(e),key:lr.decode(e),settings:mr.decode(e)})},xr={preencode(d,o){e.fixed32.preencode(d,o.discoveryPublicKey),e.uint.preencode(d,o.timestamp),d.end++,o.lastSynced&&e.uint.preencode(d,o.lastSynced)},encode(d,o){const n=(o.lastSynced?1:0)|(o.dirty?2:0);e.fixed32.encode(d,o.discoveryPublicKey),e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.lastSynced&&e.uint.encode(d,o.lastSynced)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d),c=e.uint.decode(d);return{discoveryPublicKey:o,timestamp:n,lastSynced:1&c?e.uint.decode(d):0,dirty:!!(2&c)}}},br={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.activeRooms)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.activeRooms)},decode:d=>({rooms:e.uint.decode(d),activeRooms:e.uint.decode(d)})},vr=F,gr=$,Kr={preencode(e,d){e.end++,d.blockedMembers&&gr.preencode(e,d.blockedMembers)},encode(d,o){const n=o.blockedMembers?1:0;e.uint.encode(d,n),o.blockedMembers&&gr.encode(d,o.blockedMembers)},decode:d=>({blockedMembers:1&e.uint.decode(d)?gr.decode(d):null})},kr=e.frame(Q),hr=e.frame(Kr),wr={preencode(d,n){e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.seed),kr.preencode(d,n.capabilities),o.preencode(d,n.initiator),e.fixed32.preencode(d,n.fastForwardTo),d.end++,n.privateProfile&&hr.preencode(d,n.privateProfile)},encode(d,n){const c=n.privateProfile?1:0;e.buffer.encode(d,n.encryptionKey),e.fixed32.encode(d,n.seed),kr.encode(d,n.capabilities),o.encode(d,n.initiator),e.fixed32.encode(d,n.fastForwardTo),e.uint.encode(d,c),n.privateProfile&&hr.encode(d,n.privateProfile)},decode:d=>({encryptionKey:e.buffer.decode(d),seed:e.fixed32.decode(d),capabilities:kr.decode(d),initiator:o.decode(d),fastForwardTo:e.fixed32.decode(d),privateProfile:1&e.uint.decode(d)?hr.decode(d):null})},Pr={preencode(d,o){d.end++,o.count&&e.uint.preencode(d,o.count)},encode(d,o){const n=o.count?1:0;e.uint.encode(d,n),o.count&&e.uint.encode(d,o.count)},decode:d=>({count:1&e.uint.decode(d)?e.uint.decode(d):0})},Rr=e.frame(wr),Tr={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.priority),d.end++,o.v3&&Rr.preencode(d,o.v3),o.timestamp&&e.uint.preencode(d,o.timestamp)},encode(d,o){const n=(o.v3?1:0)|(o.errored?2:0)|(o.timestamp?4:0);e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.priority),e.uint.encode(d,n),o.v3&&Rr.encode(d,o.v3),o.timestamp&&e.uint.encode(d,o.timestamp)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d),c=e.uint.decode(d);return{roomKey:o,priority:n,v3:1&c?Rr.decode(d):null,errored:!!(2&c),timestamp:4&c?e.uint.decode(d):0}}},Ar={preencode(e,d){e.end++},encode(d,o){const n=o.isConfirmed?1:0;e.uint.encode(d,n)},decode:d=>({isConfirmed:!!(1&e.uint.decode(d))})},Sr={preencode(d,o){e.fixed32.preencode(d,o.privateProfileKey)},encode(d,o){e.fixed32.encode(d,o.privateProfileKey)},decode:d=>({privateProfileKey:e.fixed32.decode(d)})},Ir=e.frame(Ar),Mr=gc,Fr=e.frame(xc),qr={preencode(o,n){e.fixed32.preencode(o,n.publicKey),e.fixed32.preencode(o,n.privateProfileKey),r.preencode(o,n.deviceKeyPair),e.buffer.preencode(o,n.deviceProof),Ir.preencode(o,n.status),o.end++,n.entropy&&e.buffer.preencode(o,n.entropy),n.swap&&Mr.preencode(o,n.swap),n.swapV2&&Fr.preencode(o,n.swapV2),d>=7&&n.proofShortenedAt&&e.uint.preencode(o,n.proofShortenedAt)},encode(o,n){const c=(n.entropy?1:0)|(n.swap?2:0)|(n.swapV2?4:0)|(d>=7&&n.proofShortenedAt?8:0);e.fixed32.encode(o,n.publicKey),e.fixed32.encode(o,n.privateProfileKey),r.encode(o,n.deviceKeyPair),e.buffer.encode(o,n.deviceProof),Ir.encode(o,n.status),e.uint.encode(o,c),n.entropy&&e.buffer.encode(o,n.entropy),n.swap&&Mr.encode(o,n.swap),n.swapV2&&Fr.encode(o,n.swapV2),d>=7&&n.proofShortenedAt&&e.uint.encode(o,n.proofShortenedAt)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=r.decode(o),i=e.buffer.decode(o),a=Ir.decode(o),s=e.uint.decode(o);return{publicKey:n,privateProfileKey:c,deviceKeyPair:t,deviceProof:i,status:a,entropy:1&s?e.buffer.decode(o):null,swap:2&s?Mr.decode(o):null,swapV2:4&s?Fr.decode(o):null,proofShortenedAt:d>=7&&8&s?e.uint.decode(o):0}}},Cr={RestoreIdentity:1,CreateRoom:2,LeaveRoom:3,ClearRoom:4,JoinRoomInvitation:5,JoinRoomKeys:6,JoinRoomResponse:7,SendContactRequest:8,TestFastTask:9,TestSlowTask:10,TestErrorTask:11},Vr={preencode(e,d){e.end++},encode(d,o){if(o>11)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Hr={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator)},encode(d,n){const c=(n.fastForwardTo?1:0)|(n.initiator?2:0);e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.uint.encode(d,c),n.fastForwardTo&&e.fixed32.encode(d,n.fastForwardTo),n.initiator&&o.encode(d,n.initiator)},decode(d){const n=e.fixed32.decode(d),c=e.buffer.decode(d),r=e.uint.decode(d);return{roomKey:n,encryptionKey:c,fastForwardTo:1&r?e.fixed32.decode(d):null,initiator:2&r?o.decode(d):null}}},Dr=uc,Lr={preencode(e,d){Dr.preencode(e,d.invitation)},encode(e,d){Dr.encode(e,d.invitation)},decode:e=>({invitation:Dr.decode(e)})},jr={preencode(d,o){e.fixed32.preencode(d,o.mailbox),r.preencode(d,o.keyPair),e.buffer.preencode(d,o.response)},encode(d,o){e.fixed32.encode(d,o.mailbox),r.encode(d,o.keyPair),e.buffer.encode(d,o.response)},decode:d=>({mailbox:e.fixed32.decode(d),keyPair:r.decode(d),response:e.buffer.decode(d)})},Er=ee,Br={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.mailbox&&e.fixed32.preencode(d,n.mailbox)},encode(d,n){const c=(n.fastForwardTo?1:0)|(n.initiator?2:0)|(n.mailbox?4:0);e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.uint.encode(d,c),n.fastForwardTo&&e.fixed32.encode(d,n.fastForwardTo),n.initiator&&o.encode(d,n.initiator),n.mailbox&&e.fixed32.encode(d,n.mailbox)},decode(d){const n=e.fixed32.decode(d),c=e.buffer.decode(d),r=e.uint.decode(d);return{roomKey:n,encryptionKey:c,fastForwardTo:1&r?e.fixed32.decode(d):null,initiator:2&r?o.decode(d):null,mailbox:4&r?e.fixed32.decode(d):null}}},zr=e.frame(Br),Or={preencode(o,n){zr.preencode(o,n.keys),o.end++,d>=15&&n.activeClock&&e.uint.preencode(o,n.activeClock)},encode(o,n){const c=(d>=15&&n.activeClock?1:0)|(d>=15&&n.isReadOnly?2:0);zr.encode(o,n.keys),e.uint.encode(o,c),d>=15&&n.activeClock&&e.uint.encode(o,n.activeClock)},decode(o){const n=zr.decode(o),c=o.start<o.end?e.uint.decode(o):0;return{keys:n,activeClock:d>=15&&1&c?e.uint.decode(o):0,isReadOnly:d>=15&&!!(2&c)}}},Nr=e.frame(kn),Ur={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.mailbox&&e.fixed32.preencode(d,n.mailbox),n.keyPair&&r.preencode(d,n.keyPair),n.genesis&&Nr.preencode(d,n.genesis)},encode(d,n){const c=(n.fastForwardTo?1:0)|(n.initiator?2:0)|(n.mailbox?4:0)|(n.keyPair?8:0)|(n.genesis?16:0)|(n.isPrivateProfile?32:0);e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.uint.encode(d,c),n.fastForwardTo&&e.fixed32.encode(d,n.fastForwardTo),n.initiator&&o.encode(d,n.initiator),n.mailbox&&e.fixed32.encode(d,n.mailbox),n.keyPair&&r.encode(d,n.keyPair),n.genesis&&Nr.encode(d,n.genesis)},decode(d){const n=e.fixed32.decode(d),c=e.buffer.decode(d),t=e.uint.decode(d);return{roomKey:n,encryptionKey:c,fastForwardTo:1&t?e.fixed32.decode(d):null,initiator:2&t?o.decode(d):null,mailbox:4&t?e.fixed32.decode(d):null,keyPair:8&t?r.decode(d):null,genesis:16&t?Nr.decode(d):null,isPrivateProfile:!!(32&t)}}},Jr={preencode(d,o){e.fixed32.preencode(d,o.roomKey),d.end++},encode(d,o){const n=o.isGossiped?1:0;e.fixed32.encode(d,o.roomKey),e.uint.encode(d,n)},decode:d=>({roomKey:e.fixed32.decode(d),isGossiped:!!(1&e.uint.decode(d))})},Wr={preencode(d,o){e.fixed32.preencode(d,o.roomKey)},encode(d,o){e.fixed32.encode(d,o.roomKey)},decode:d=>({roomKey:e.fixed32.decode(d)})},Gr={preencode(d,o){e.string.preencode(d,o.mnemonic),d.end++,o.profileDiscoveryTimeout&&e.uint.preencode(d,o.profileDiscoveryTimeout)},encode(d,o){const n=(o.profileDiscoveryTimeout?1:0)|(o.recover?2:0);e.string.encode(d,o.mnemonic),e.uint.encode(d,n),o.profileDiscoveryTimeout&&e.uint.encode(d,o.profileDiscoveryTimeout)},decode(d){const o=e.string.decode(d),n=e.uint.decode(d);return{mnemonic:o,profileDiscoveryTimeout:1&n?e.uint.decode(d):0,recover:!!(2&n)}}},Qr=Qn,Xr={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.fixed32.preencode(d,o.memberKey),d.end++,o.message&&e.string.preencode(d,o.message),o.contactInfo&&Qr.preencode(d,o.contactInfo)},encode(d,o){const n=(o.message?1:0)|(o.contactInfo?2:0);e.fixed32.encode(d,o.roomKey),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,n),o.message&&e.string.encode(d,o.message),o.contactInfo&&Qr.encode(d,o.contactInfo)},decode(d){const o=e.fixed32.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{roomKey:o,memberKey:n,message:1&c?e.string.decode(d):null,contactInfo:2&c?Qr.decode(d):null}}},Yr={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++},encode(d,o){const n=o.isPrivateProfile?1:0;e.fixed32.encode(d,o.key),e.uint.encode(d,n)},decode:d=>({key:e.fixed32.decode(d),isPrivateProfile:!!(1&e.uint.decode(d))})},Zr=e.frame(Gr),$r=e.frame(Ur),_r=e.frame(Jr),et=e.frame(Wr),dt=e.frame(Lr),ot=e.frame(Or),nt=e.frame(jr),ct=e.frame(Xr),rt=e.frame(Yr),tt={preencode(d,o){const n=(o.restoreIdentity?1:0)|(o.createRoom?2:0)|(o.leaveRoom?4:0)|(o.clearRoom?8:0)|(o.joinRoomInvitation?16:0)|(o.joinRoomKeys?32:0)|(o.joinRoomResponse?64:0)|(o.sendContactRequest?128:0)|(o.migrateV2Room?256:0);e.fixed32.preencode(d,o.discoveryKey),e.uint.preencode(d,o.priority),e.uint.preencode(d,o.timestamp),e.uint.preencode(d,o.type),e.uint.preencode(d,n),o.restoreIdentity&&Zr.preencode(d,o.restoreIdentity),o.createRoom&&$r.preencode(d,o.createRoom),o.leaveRoom&&_r.preencode(d,o.leaveRoom),o.clearRoom&&et.preencode(d,o.clearRoom),o.joinRoomInvitation&&dt.preencode(d,o.joinRoomInvitation),o.joinRoomKeys&&ot.preencode(d,o.joinRoomKeys),o.joinRoomResponse&&nt.preencode(d,o.joinRoomResponse),o.sendContactRequest&&ct.preencode(d,o.sendContactRequest),o.migrateV2Room&&rt.preencode(d,o.migrateV2Room)},encode(d,o){const n=(o.restoreIdentity?1:0)|(o.createRoom?2:0)|(o.leaveRoom?4:0)|(o.clearRoom?8:0)|(o.joinRoomInvitation?16:0)|(o.joinRoomKeys?32:0)|(o.joinRoomResponse?64:0)|(o.sendContactRequest?128:0)|(o.migrateV2Room?256:0);e.fixed32.encode(d,o.discoveryKey),e.uint.encode(d,o.priority),e.uint.encode(d,o.timestamp),e.uint.encode(d,o.type),e.uint.encode(d,n),o.restoreIdentity&&Zr.encode(d,o.restoreIdentity),o.createRoom&&$r.encode(d,o.createRoom),o.leaveRoom&&_r.encode(d,o.leaveRoom),o.clearRoom&&et.encode(d,o.clearRoom),o.joinRoomInvitation&&dt.encode(d,o.joinRoomInvitation),o.joinRoomKeys&&ot.encode(d,o.joinRoomKeys),o.joinRoomResponse&&nt.encode(d,o.joinRoomResponse),o.sendContactRequest&&ct.encode(d,o.sendContactRequest),o.migrateV2Room&&rt.encode(d,o.migrateV2Room)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d),c=e.uint.decode(d),r=e.uint.decode(d),t=e.uint.decode(d);return{discoveryKey:o,priority:n,timestamp:c,type:r,restoreIdentity:1&t?Zr.decode(d):null,createRoom:2&t?$r.decode(d):null,leaveRoom:4&t?_r.decode(d):null,clearRoom:8&t?et.decode(d):null,joinRoomInvitation:16&t?dt.decode(d):null,joinRoomKeys:32&t?ot.decode(d):null,joinRoomResponse:64&t?nt.decode(d):null,sendContactRequest:128&t?ct.decode(d):null,migrateV2Room:256&t?rt.decode(d):null}}},it=Oe,at={preencode(d,o){e.buffer.preencode(d,o.seed),it.preencode(d,o.invitation)},encode(d,o){e.buffer.encode(d,o.seed),it.encode(d,o.invitation)},decode:d=>({seed:e.buffer.decode(d),invitation:it.decode(d)})},st={preencode(e,d){e.end++},encode(d,o){const n=(o.isWritable?1:0)|(o.isReadable?2:0)|(o.isPrivateProfile?4:0)|(o.isRemoved?8:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isWritable:!!(1&o),isReadable:!!(2&o),isPrivateProfile:!!(4&o),isRemoved:!!(8&o)}}},pt={preencode(d,o){e.uint.preencode(d,o.creation),e.uint.preencode(d,o.latestSync),e.uint.preencode(d,o.latestChatMessage)},encode(d,o){e.uint.encode(d,o.creation),e.uint.encode(d,o.latestSync),e.uint.encode(d,o.latestChatMessage)},decode:d=>({creation:e.uint.decode(d),latestSync:e.uint.decode(d),latestChatMessage:e.uint.decode(d)})},ut=yn,lt=So,ft=e.frame(pt),mt=kr,yt=e.frame(st),xt=e.frame(pe),bt=e.frame(hd),vt=an,gt=vn,Kt=e.frame(Lo),kt=$,ht=e.array(e.frame(Wn)),wt=e.frame(gd),Pt=vc,Rt={preencode(o,n){const c=(n.selfDevice?1:0)|(n.selfMember?2:0)|(n.config?4:0)|(n.identity?8:0)|(n.lastMessage?16:0)|(n.dm?32:0)|(n.readLengths?64:0)|(n.lastMember?128:0)|(n.version?256:0)|(d>=3&&n.preferences?512:0)|(d>=4&&n.activeCall?1024:0)|(d>=8&&n.lastMessageLabels?2048:0)|(d>=9&&n.settings?4096:0)|(d>=13&&n.system?8192:0)|(d>=13&&n.processed?16384:0);e.fixed32.preencode(o,n.roomKey),e.fixed32.preencode(o,n.discoveryKey),e.buffer.preencode(o,n.encryptionKey),ut.preencode(o,n.digest),lt.preencode(o,n.stats),ft.preencode(o,n.timestamps),e.uint.preencode(o,n.fork),e.uint.preencode(o,n.length),e.fixed32.preencode(o,n.seed),mt.preencode(o,n.capabilities),yt.preencode(o,n.status),e.uint.preencode(o,c),n.selfDevice&&xt.preencode(o,n.selfDevice),n.selfMember&&bt.preencode(o,n.selfMember),n.config&&vt.preencode(o,n.config),n.identity&&gt.preencode(o,n.identity),n.lastMessage&&Kt.preencode(o,n.lastMessage),n.dm&&kt.preencode(o,n.dm),n.readLengths&&ht.preencode(o,n.readLengths),n.lastMember&&wt.preencode(o,n.lastMember),n.version&&e.uint.preencode(o,n.version),d>=3&&n.preferences&&Pt.preencode(o,n.preferences),d>=4&&n.activeCall&&cl.preencode(o,n.activeCall),d>=8&&n.lastMessageLabels&&rl.preencode(o,n.lastMessageLabels),d>=9&&n.settings&&tl.preencode(o,n.settings),d>=13&&n.system&&il.preencode(o,n.system),d>=13&&n.processed&&al.preencode(o,n.processed)},encode(o,n){const c=(n.selfDevice?1:0)|(n.selfMember?2:0)|(n.config?4:0)|(n.identity?8:0)|(n.lastMessage?16:0)|(n.dm?32:0)|(n.readLengths?64:0)|(n.lastMember?128:0)|(n.version?256:0)|(d>=3&&n.preferences?512:0)|(d>=4&&n.activeCall?1024:0)|(d>=8&&n.lastMessageLabels?2048:0)|(d>=9&&n.settings?4096:0)|(d>=13&&n.system?8192:0)|(d>=13&&n.processed?16384:0);e.fixed32.encode(o,n.roomKey),e.fixed32.encode(o,n.discoveryKey),e.buffer.encode(o,n.encryptionKey),ut.encode(o,n.digest),lt.encode(o,n.stats),ft.encode(o,n.timestamps),e.uint.encode(o,n.fork),e.uint.encode(o,n.length),e.fixed32.encode(o,n.seed),mt.encode(o,n.capabilities),yt.encode(o,n.status),e.uint.encode(o,c),n.selfDevice&&xt.encode(o,n.selfDevice),n.selfMember&&bt.encode(o,n.selfMember),n.config&&vt.encode(o,n.config),n.identity&&gt.encode(o,n.identity),n.lastMessage&&Kt.encode(o,n.lastMessage),n.dm&&kt.encode(o,n.dm),n.readLengths&&ht.encode(o,n.readLengths),n.lastMember&&wt.encode(o,n.lastMember),n.version&&e.uint.encode(o,n.version),d>=3&&n.preferences&&Pt.encode(o,n.preferences),d>=4&&n.activeCall&&cl.encode(o,n.activeCall),d>=8&&n.lastMessageLabels&&rl.encode(o,n.lastMessageLabels),d>=9&&n.settings&&tl.encode(o,n.settings),d>=13&&n.system&&il.encode(o,n.system),d>=13&&n.processed&&al.encode(o,n.processed)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.buffer.decode(o),t=ut.decode(o),i=lt.decode(o),a=ft.decode(o),s=e.uint.decode(o),p=e.uint.decode(o),u=e.fixed32.decode(o),l=mt.decode(o),f=yt.decode(o),m=e.uint.decode(o);return{roomKey:n,discoveryKey:c,encryptionKey:r,digest:t,stats:i,timestamps:a,fork:s,length:p,seed:u,capabilities:l,status:f,selfDevice:1&m?xt.decode(o):null,selfMember:2&m?bt.decode(o):null,config:4&m?vt.decode(o):null,identity:8&m?gt.decode(o):null,lastMessage:16&m?Kt.decode(o):null,dm:32&m?kt.decode(o):null,readLengths:64&m?ht.decode(o):null,lastMember:128&m?wt.decode(o):null,version:256&m?e.uint.decode(o):0,preferences:d>=3&&512&m?Pt.decode(o):null,activeCall:d>=4&&1024&m?cl.decode(o):null,lastMessageLabels:d>=8&&2048&m?rl.decode(o):null,settings:d>=9&&4096&m?tl.decode(o):null,system:d>=13&&8192&m?il.decode(o):null,processed:d>=13&&16384&m?al.decode(o):null}}},Tt=vc,At={preencode(d,o){e.fixed32.preencode(d,o.roomKey),Tt.preencode(d,o.status)},encode(d,o){e.fixed32.encode(d,o.roomKey),Tt.encode(d,o.status)},decode:d=>({roomKey:e.fixed32.decode(d),status:Tt.decode(d)})},St={preencode(d,o){e.fixed32.preencode(d,o.roomKey),d.end++,o.repairs&&e.uint.preencode(d,o.repairs)},encode(d,o){const n=o.repairs?1:0;e.fixed32.encode(d,o.roomKey),e.uint.encode(d,n),o.repairs&&e.uint.encode(d,o.repairs)},decode:d=>({roomKey:e.fixed32.decode(d),repairs:1&e.uint.decode(d)?e.uint.decode(d):0})},It={preencode(o,n){e.fixed32.preencode(o,n.mailbox),e.fixed32.preencode(o,n.key),o.end++,n.roomKey&&e.fixed32.preencode(o,n.roomKey),n.keyPair&&r.preencode(o,n.keyPair),n.responseKeyPair&&r.preencode(o,n.responseKeyPair),d>=15&&n.activeClock&&e.uint.preencode(o,n.activeClock)},encode(o,n){const c=(n.roomKey?1:0)|(n.keyPair?2:0)|(n.responseKeyPair?4:0)|(d>=14&&n.pending?8:0)|(d>=15&&n.activeClock?16:0);e.fixed32.encode(o,n.mailbox),e.fixed32.encode(o,n.key),e.uint.encode(o,c),n.roomKey&&e.fixed32.encode(o,n.roomKey),n.keyPair&&r.encode(o,n.keyPair),n.responseKeyPair&&r.encode(o,n.responseKeyPair),d>=15&&n.activeClock&&e.uint.encode(o,n.activeClock)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=e.uint.decode(o);return{mailbox:n,key:c,roomKey:1&t?e.fixed32.decode(o):null,keyPair:2&t?r.decode(o):null,responseKeyPair:4&t?r.decode(o):null,pending:d>=14&&!!(8&t),activeClock:d>=15&&16&t?e.uint.decode(o):0}}},Mt={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.responsePublicKey)},encode(d,o){e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.responsePublicKey)},decode:d=>({key:e.fixed32.decode(d),responsePublicKey:e.fixed32.decode(d)})},Ft=fe,qt={preencode(d,o){e.fixed32.preencode(d,o.key),Ft.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),Ft.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),profile:Ft.decode(d)})},Ct=xt,Vt={preencode(d,o){e.fixed32.preencode(d,o.roomKey),Ct.preencode(d,o.device)},encode(d,o){e.fixed32.encode(d,o.roomKey),Ct.encode(d,o.device)},decode:d=>({roomKey:e.fixed32.decode(d),device:Ct.decode(d)})},Ht=K,Dt={preencode(o,n){Ht.preencode(o,n.file),e.fixed32.preencode(o,n.roomKey),o.end++,n.encryptionKey&&e.buffer.preencode(o,n.encryptionKey),d>=4&&n.lastAccessed&&e.uint.preencode(o,n.lastAccessed),d>=4&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(n.encryptionKey?1:0)|(n.cleared?2:0)|(n.own?4:0)|(d>=4&&n.lastAccessed?8:0)|(d>=4&&n.version?16:0);Ht.encode(o,n.file),e.fixed32.encode(o,n.roomKey),e.uint.encode(o,c),n.encryptionKey&&e.buffer.encode(o,n.encryptionKey),d>=4&&n.lastAccessed&&e.uint.encode(o,n.lastAccessed),d>=4&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=Ht.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{file:n,roomKey:c,encryptionKey:1&r?e.buffer.decode(o):null,cleared:!!(2&r),own:!!(4&r),lastAccessed:d>=4&&8&r?e.uint.decode(o):0,version:d>=4&&16&r?e.uint.decode(o):0}}},Lt={preencode(d,o){d.end++,o.key&&e.string.preencode(d,o.key),o.description&&e.string.preencode(d,o.description)},encode(d,o){const n=(o.key?1:0)|(o.value?2:0)|(o.description?4:0);e.uint.encode(d,n),o.key&&e.string.encode(d,o.key),o.description&&e.string.encode(d,o.description)},decode(d){const o=e.uint.decode(d);return{key:1&o?e.string.decode(d):null,value:!!(2&o),description:4&o?e.string.decode(d):null}}},jt=e.array(e.frame(Lt)),Et={preencode(e,d){e.end++,d.flags&&jt.preencode(e,d.flags)},encode(d,o){const n=o.flags?1:0;e.uint.encode(d,n),o.flags&&jt.encode(d,o.flags)},decode:d=>({flags:1&e.uint.decode(d)?jt.decode(d):null})},Bt=ed,zt={preencode(d,o){d.end++,o.nodes&&Bt.preencode(d,o.nodes),o.concurrency&&e.uint.preencode(d,o.concurrency),o.maxWindow&&e.uint.preencode(d,o.maxWindow),o.randomPunchInterval&&e.uint.preencode(d,o.randomPunchInterval),o.connectionKeepAlive&&e.uint.preencode(d,o.connectionKeepAlive)},encode(d,o){const n=(o.nodes?1:0)|(o.concurrency?2:0)|(o.maxWindow?4:0)|(o.randomPunchInterval?8:0)|(o.connectionKeepAlive?16:0);e.uint.encode(d,n),o.nodes&&Bt.encode(d,o.nodes),o.concurrency&&e.uint.encode(d,o.concurrency),o.maxWindow&&e.uint.encode(d,o.maxWindow),o.randomPunchInterval&&e.uint.encode(d,o.randomPunchInterval),o.connectionKeepAlive&&e.uint.encode(d,o.connectionKeepAlive)},decode(d){const o=e.uint.decode(d);return{nodes:1&o?Bt.decode(d):null,concurrency:2&o?e.uint.decode(d):0,maxWindow:4&o?e.uint.decode(d):0,randomPunchInterval:8&o?e.uint.decode(d):0,connectionKeepAlive:16&o?e.uint.decode(d):0}}},Ot={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.count)},encode(d,o){e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.count)},decode:d=>({roomKey:e.fixed32.decode(d),count:e.uint.decode(d)})},Nt={preencode(d,o){d.end++,o.roomKey&&e.fixed32.preencode(d,o.roomKey),o.coreKey&&e.fixed32.preencode(d,o.coreKey)},encode(d,o){const n=(o.roomKey?1:0)|(o.coreKey?2:0);e.uint.encode(d,n),o.roomKey&&e.fixed32.encode(d,o.roomKey),o.coreKey&&e.fixed32.encode(d,o.coreKey)},decode(d){const o=e.uint.decode(d);return{roomKey:1&o?e.fixed32.decode(d):null,coreKey:2&o?e.fixed32.decode(d):null}}},Ut=e.frame(Nt),Jt={preencode(d,o){e.string.preencode(d,o.code),e.string.preencode(d,o.message),e.string.preencode(d,o.stack),e.uint.preencode(d,o.timestamp),d.end++,o.details&&Ut.preencode(d,o.details)},encode(d,o){const n=o.details?1:0;e.string.encode(d,o.code),e.string.encode(d,o.message),e.string.encode(d,o.stack),e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.details&&Ut.encode(d,o.details)},decode:d=>({code:e.string.decode(d),message:e.string.decode(d),stack:e.string.decode(d),timestamp:e.uint.decode(d),details:1&e.uint.decode(d)?Ut.decode(d):null})},Wt={RESUME:1,WAKEUP:2,PRESUSPEND:3,SUSPEND:4},Gt={preencode(e,d){e.end++},encode(d,o){if(o>4)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Qt={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.total)},encode(d,o){e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.total)},decode:d=>({roomKey:e.fixed32.decode(d),total:e.uint.decode(d)})},Xt=i,Yt={preencode(d,o){e.uint.preencode(d,o.duration)},encode(d,o){e.uint.encode(d,o.duration)},decode:d=>({duration:e.uint.decode(d)})},Zt=H,$t=H,_t=e.frame(Xt),ei={preencode(e,d){_t.preencode(e,d.header)},encode(e,d){_t.encode(e,d.header)},decode:e=>({header:_t.decode(e)})},di=e.frame(Yt),oi={preencode(e,d){di.preencode(e,d.header)},encode(e,d){di.encode(e,d.header)},decode:e=>({header:di.decode(e)})},ni=_t,ci={preencode(e,d){ni.preencode(e,d.header)},encode(e,d){ni.encode(e,d.header)},decode:e=>({header:ni.decode(e)})},ri=H,ti=_t,ii=an,ai=J,si={preencode(e,d){ti.preencode(e,d.header),e.end++,d.config&&ii.preencode(e,d.config),d.settings&&ai.preencode(e,d.settings)},encode(d,o){const n=(o.config?1:0)|(o.settings?2:0);ti.encode(d,o.header),e.uint.encode(d,n),o.config&&ii.encode(d,o.config),o.settings&&ai.encode(d,o.settings)},decode(d){const o=ti.decode(d),n=e.uint.decode(d);return{header:o,config:1&n?ii.decode(d):null,settings:2&n?ai.decode(d):null}}},pi=di,ui={preencode(d,o){pi.preencode(d,o.header),d.end++,o.roomKey&&e.fixed32.preencode(d,o.roomKey)},encode(d,o){const n=o.roomKey?1:0;pi.encode(d,o.header),e.uint.encode(d,n),o.roomKey&&e.fixed32.encode(d,o.roomKey)},decode:d=>({header:pi.decode(d),roomKey:1&e.uint.decode(d)?e.fixed32.decode(d):null})},li=_t,fi={preencode(d,o){li.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey)},encode(d,o){li.encode(d,o.header),e.fixed32.encode(d,o.roomKey)},decode:d=>({header:li.decode(d),roomKey:e.fixed32.decode(d)})},mi=_t,yi={preencode(d,o){mi.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey)},encode(d,o){mi.encode(d,o.header),e.fixed32.encode(d,o.roomKey)},decode:d=>({header:mi.decode(d),roomKey:e.fixed32.decode(d)})},xi=_t,bi={preencode(d,o){xi.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey)},encode(d,o){xi.encode(d,o.header),e.fixed32.encode(d,o.roomKey)},decode:d=>({header:xi.decode(d),roomKey:e.fixed32.decode(d)})},vi=di,gi={preencode(e,d){vi.preencode(e,d.header)},encode(e,d){vi.encode(e,d.header)},decode:e=>({header:vi.decode(e)})},Ki=_t,ki=an,hi={preencode(d,o){Ki.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.key),ki.preencode(d,o.config)},encode(d,o){Ki.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.key),ki.encode(d,o.config)},decode:d=>({header:Ki.decode(d),roomKey:e.fixed32.decode(d),key:e.uint.decode(d),config:ki.decode(d)})},wi=_t,Pi=J,Ri={preencode(d,o){wi.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.key),Pi.preencode(d,o.settings)},encode(d,o){wi.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.key),Pi.encode(d,o.settings)},decode:d=>({header:wi.decode(d),roomKey:e.fixed32.decode(d),key:e.uint.decode(d),settings:Pi.decode(d)})},Ti=_t,Ai=vc,Si={preencode(d,o){Ti.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.key),Ai.preencode(d,o.status)},encode(d,o){Ti.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.key),Ai.encode(d,o.status)},decode:d=>({header:Ti.decode(d),roomKey:e.fixed32.decode(d),key:e.uint.decode(d),status:Ai.decode(d)})},Ii=_t,Mi=Eo,Fi={preencode(d,o){Ii.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),Mi.preencode(d,o.message)},encode(d,o){Ii.encode(d,o.header),e.fixed32.encode(d,o.roomKey),Mi.encode(d,o.message)},decode:d=>({header:Ii.decode(d),roomKey:e.fixed32.decode(d),message:Mi.decode(d)})},qi=di,Ci={preencode(e,d){qi.preencode(e,d.header)},encode(e,d){qi.encode(e,d.header)},decode:e=>({header:qi.decode(e)})},Vi=_t,Hi=Eo,Di={preencode(d,o){Vi.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),n.preencode(d,o.id),Hi.preencode(d,o.message)},encode(d,o){Vi.encode(d,o.header),e.fixed32.encode(d,o.roomKey),n.encode(d,o.id),Hi.encode(d,o.message)},decode:d=>({header:Vi.decode(d),roomKey:e.fixed32.decode(d),id:n.decode(d),message:Hi.decode(d)})},Li=di,ji={preencode(e,d){Li.preencode(e,d.header)},encode(e,d){Li.encode(e,d.header)},decode:e=>({header:Li.decode(e)})},Ei=_t,Bi={preencode(d,o){Ei.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),n.preencode(d,o.id)},encode(d,o){Ei.encode(d,o.header),e.fixed32.encode(d,o.roomKey),n.encode(d,o.id)},decode:d=>({header:Ei.decode(d),roomKey:e.fixed32.decode(d),id:n.decode(d)})},zi=di,Oi={preencode(e,d){zi.preencode(e,d.header)},encode(e,d){zi.encode(e,d.header)},decode:e=>({header:zi.decode(e)})},Ni=_t,Ui={preencode(d,o){Ni.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),n.preencode(d,o.id),e.string.preencode(d,o.reaction)},encode(d,o){Ni.encode(d,o.header),e.fixed32.encode(d,o.roomKey),n.encode(d,o.id),e.string.encode(d,o.reaction)},decode:d=>({header:Ni.decode(d),roomKey:e.fixed32.decode(d),id:n.decode(d),reaction:e.string.decode(d)})},Ji=di,Wi={preencode(e,d){Ji.preencode(e,d.header)},encode(e,d){Ji.encode(e,d.header)},decode:e=>({header:Ji.decode(e)})},Gi=_t,Qi={preencode(d,o){Gi.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),n.preencode(d,o.id),e.string.preencode(d,o.reaction)},encode(d,o){Gi.encode(d,o.header),e.fixed32.encode(d,o.roomKey),n.encode(d,o.id),e.string.encode(d,o.reaction)},decode:d=>({header:Gi.decode(d),roomKey:e.fixed32.decode(d),id:n.decode(d),reaction:e.string.decode(d)})},Xi=di,Yi={preencode(e,d){Xi.preencode(e,d.header)},encode(e,d){Xi.encode(e,d.header)},decode:e=>({header:Xi.decode(e)})},Zi={preencode(d,o){e.uint.preencode(d,o.clock),e.uint.preencode(d,o.start),e.uint.preencode(d,o.end)},encode(d,o){e.uint.encode(d,o.clock),e.uint.encode(d,o.start),e.uint.encode(d,o.end)},decode:d=>({clock:e.uint.decode(d),start:e.uint.decode(d),end:e.uint.decode(d)})},$i=H,_i=$,ea={preencode(d,o){e.uint.preencode(d,o.clock),_i.preencode(d,o.keys)},encode(d,o){e.uint.encode(d,o.clock),_i.encode(d,o.keys)},decode:d=>({clock:e.uint.decode(d),keys:_i.decode(d)})},da={preencode(d,o){e.uint.preencode(d,o.clock),e.fixed32.preencode(d,o.roomKey),d.end++,o.start&&e.uint.preencode(d,o.start),o.size&&e.uint.preencode(d,o.size)},encode(d,o){const n=(o.start?1:0)|(o.size?2:0)|(o.isBottom?4:0);e.uint.encode(d,o.clock),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,n),o.start&&e.uint.encode(d,o.start),o.size&&e.uint.encode(d,o.size)},decode(d){const o=e.uint.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{clock:o,roomKey:n,start:1&c?e.uint.decode(d):0,size:2&c?e.uint.decode(d):0,isBottom:!!(4&c)}}},oa=H,na={preencode(d,o){e.uint.preencode(d,o.clock),e.fixed32.preencode(d,o.roomKey),d.end++,o.offset&&e.fixed32.preencode(d,o.offset),o.count&&e.uint.preencode(d,o.count)},encode(d,o){const n=(o.offset?1:0)|(o.count?2:0);e.uint.encode(d,o.clock),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,n),o.offset&&e.fixed32.encode(d,o.offset),o.count&&e.uint.encode(d,o.count)},decode(d){const o=e.uint.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{clock:o,roomKey:n,offset:1&c?e.fixed32.decode(d):null,count:2&c?e.uint.decode(d):0}}},ca=H,ra={preencode(d,o){e.uint.preencode(d,o.timestamp),e.fixed32.preencode(d,o.id)},encode(d,o){e.uint.encode(d,o.timestamp),e.fixed32.encode(d,o.id)},decode:d=>({timestamp:e.uint.decode(d),id:e.fixed32.decode(d)})},ta={Changed:1,Removed:2},ia={preencode(e,d){e.end++},encode(d,o){if(o>2)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},aa=$,sa={preencode(d,o){aa.preencode(d,o.keys),e.uint.preencode(d,o.start),e.uint.preencode(d,o.end),e.uint.preencode(d,o.total)},encode(d,o){aa.encode(d,o.keys),e.uint.encode(d,o.start),e.uint.encode(d,o.end),e.uint.encode(d,o.total)},decode:d=>({keys:aa.decode(d),start:e.uint.decode(d),end:e.uint.decode(d),total:e.uint.decode(d)})},pa={preencode(e,d){ia.preencode(e,d.type),ra.preencode(e,d.room)},encode(e,d){ia.encode(e,d.type),ra.encode(e,d.room)},decode:e=>({type:ia.decode(e),room:ra.decode(e)})},ua=yt,la=bd,fa={preencode(e,d){ua.preencode(e,d.device),e.end++,d.member&&la.preencode(e,d.member)},encode(d,o){const n=o.member?1:0;ua.encode(d,o.device),e.uint.encode(d,n),o.member&&la.encode(d,o.member)},decode:d=>({device:ua.decode(d),member:1&e.uint.decode(d)?la.decode(d):null})},ma=e.frame(fa),ya=yn,xa=an,ba={preencode(d,o){e.fixed32.preencode(d,o.id),ma.preencode(d,o.role),ya.preencode(d,o.digest),xa.preencode(d,o.config),d.end++,o.messageId&&n.preencode(d,o.messageId)},encode(d,o){const c=o.messageId?1:0;e.fixed32.encode(d,o.id),ma.encode(d,o.role),ya.encode(d,o.digest),xa.encode(d,o.config),e.uint.encode(d,c),o.messageId&&n.encode(d,o.messageId)},decode:d=>({id:e.fixed32.decode(d),role:ma.decode(d),digest:ya.decode(d),config:xa.decode(d),messageId:1&e.uint.decode(d)?n.decode(d):null})},va=yt,ga={preencode(d,o){e.fixed32.preencode(d,o.id),va.preencode(d,o.status)},encode(d,o){e.fixed32.encode(d,o.id),va.encode(d,o.status)},decode:d=>({id:e.fixed32.decode(d),status:va.decode(d)})},Ka=yn,ka={preencode(d,o){e.fixed32.preencode(d,o.id),Ka.preencode(d,o.digest)},encode(d,o){e.fixed32.encode(d,o.id),Ka.encode(d,o.digest)},decode:d=>({id:e.fixed32.decode(d),digest:Ka.decode(d)})},ha=an,wa={preencode(d,o){e.fixed32.preencode(d,o.id),ha.preencode(d,o.config)},encode(d,o){e.fixed32.encode(d,o.id),ha.encode(d,o.config)},decode:d=>({id:e.fixed32.decode(d),config:ha.decode(d)})},Pa=ma,Ra={preencode(d,o){e.fixed32.preencode(d,o.id),d.end++,o.role&&Pa.preencode(d,o.role)},encode(d,o){const n=o.role?1:0;e.fixed32.encode(d,o.id),e.uint.encode(d,n),o.role&&Pa.encode(d,o.role)},decode:d=>({id:e.fixed32.decode(d),role:1&e.uint.decode(d)?Pa.decode(d):null})},Ta={preencode(d,o){e.fixed32.preencode(d,o.id),n.preencode(d,o.lastMessage)},encode(d,o){e.fixed32.encode(d,o.id),n.encode(d,o.lastMessage)},decode:d=>({id:e.fixed32.decode(d),lastMessage:n.decode(d)})},Aa=fe,Sa={preencode(d,o){e.fixed32.preencode(d,o.key),Aa.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),Aa.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),profile:Aa.decode(d)})},Ia=ae,Ma={preencode(d,o){e.fixed32.preencode(d,o.key),Ia.preencode(d,o.status),sl.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),Ia.encode(d,o.status),sl.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),status:Ia.decode(d),profile:sl.decode(d)})},Fa={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.roomKey),e.fixed32.encode(d,o.key)},decode:d=>({roomKey:e.fixed32.decode(d),key:e.fixed32.decode(d)})},qa=Fa,Ca=e.array(n),Va={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.start),e.uint.preencode(d,o.size),e.uint.preencode(d,o.total),Ca.preencode(d,o.ids),d.end++},encode(d,o){const n=o.isBottom?1:0;e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.start),e.uint.encode(d,o.size),e.uint.encode(d,o.total),Ca.encode(d,o.ids),e.uint.encode(d,n)},decode:d=>({roomKey:e.fixed32.decode(d),start:e.uint.decode(d),size:e.uint.decode(d),total:e.uint.decode(d),ids:Ca.decode(d),isBottom:!!(1&e.uint.decode(d))})},Ha={preencode(d,o){e.uint.preencode(d,o.sent),d.end++,o.edited&&e.uint.preencode(d,o.edited)},encode(d,o){const n=o.edited?1:0;e.uint.encode(d,o.sent),e.uint.encode(d,n),o.edited&&e.uint.encode(d,o.edited)},decode:d=>({sent:e.uint.decode(d),edited:1&e.uint.decode(d)?e.uint.decode(d):0})},Da=e.frame(Ha),La=Mo,ja=Fo,Ea=qo,Ba={preencode(d,o){n.preencode(d,o.id),e.uint.preencode(d,o.clock),Da.preencode(d,o.timestamps),La.preencode(d,o.status),d.end++,o.message&&ja.preencode(d,o.message),o.event&&Ea.preencode(d,o.event)},encode(d,o){const c=(o.message?1:0)|(o.event?2:0);n.encode(d,o.id),e.uint.encode(d,o.clock),Da.encode(d,o.timestamps),La.encode(d,o.status),e.uint.encode(d,c),o.message&&ja.encode(d,o.message),o.event&&Ea.encode(d,o.event)},decode(d){const o=n.decode(d),c=e.uint.decode(d),r=Da.decode(d),t=La.decode(d),i=e.uint.decode(d);return{id:o,clock:c,timestamps:r,status:t,message:1&i?ja.decode(d):null,event:2&i?Ea.decode(d):null}}},za=e.frame(Ba),Oa=bd,Na={preencode(d,o){za.preencode(d,o.chat),e.fixed32.preencode(d,o.memberKey),Oa.preencode(d,o.role)},encode(d,o){za.encode(d,o.chat),e.fixed32.encode(d,o.memberKey),Oa.encode(d,o.role)},decode:d=>({chat:za.decode(d),memberKey:e.fixed32.decode(d),role:Oa.decode(d)})},Ua=za,Ja={preencode(e,d){Ua.preencode(e,d.chat)},encode(e,d){Ua.encode(e,d.chat)},decode:e=>({chat:Ua.decode(e)})},Wa=Ca,Ga={preencode(d,o){Wa.preencode(d,o.ids),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Wa.encode(d,o.ids),e.fixed32.encode(d,o.memberKey)},decode:d=>({ids:Wa.decode(d),memberKey:e.fixed32.decode(d)})},Qa=Ca,Xa=bd,Ya={preencode(e,d){Qa.preencode(e,d.ids),Xa.preencode(e,d.role)},encode(e,d){Qa.encode(e,d.ids),Xa.encode(e,d.role)},decode:e=>({ids:Qa.decode(e),role:Xa.decode(e)})},Za=e.frame(dn),$a={preencode(e,d){n.preencode(e,d.id),Za.preencode(e,d.reactions)},encode(e,d){n.encode(e,d.id),Za.encode(e,d.reactions)},decode:e=>({id:n.decode(e),reactions:Za.decode(e)})},_a=Za,es={preencode(e,d){n.preencode(e,d.id),_a.preencode(e,d.digest)},encode(e,d){n.encode(e,d.id),_a.encode(e,d.digest)},decode:e=>({id:n.decode(e),digest:_a.decode(e)})},ds=H,os=H,ns=e.array(e.frame(ic)),cs={preencode(e,d){ns.preencode(e,d.invitations)},encode(e,d){ns.encode(e,d.invitations)},decode:e=>({invitations:ns.decode(e)})},rs=e.frame(ud),ts={preencode(d,o){e.fixed32.preencode(d,o.roomKey),rs.preencode(d,o.request)},encode(d,o){e.fixed32.encode(d,o.roomKey),rs.encode(d,o.request)},decode:d=>({roomKey:e.fixed32.decode(d),request:rs.decode(d)})},is=e.array(e.frame(ts)),as={preencode(e,d){is.preencode(e,d.requests)},encode(e,d){is.encode(e,d.requests)},decode:e=>({requests:is.decode(e)})},ss=ns,ps=e.array(e.frame(ud)),us={preencode(e,d){ss.preencode(e,d.pendingInvitations),ps.preencode(e,d.identityJoinRequests)},encode(e,d){ss.encode(e,d.pendingInvitations),ps.encode(e,d.identityJoinRequests)},decode:e=>({pendingInvitations:ss.decode(e),identityJoinRequests:ps.decode(e)})},ls=_t,fs={preencode(d,o){ls.preencode(d,o.header),e.string.preencode(d,o.invitation),d.end++},encode(d,o){const n=o.isIdentity?1:0;ls.encode(d,o.header),e.string.encode(d,o.invitation),e.uint.encode(d,n)},decode:d=>({header:ls.decode(d),invitation:e.string.decode(d),isIdentity:!!(1&e.uint.decode(d))})},ms=di,ys={preencode(e,d){ms.preencode(e,d.header)},encode(e,d){ms.encode(e,d.header)},decode:e=>({header:ms.decode(e)})},xs={preencode(e,d){e.end++},encode(d,o){const n=(o.canModerate?1:0)|(o.canAdmin?2:0)|(o.requiresConfirmation?4:0)|(o.isReadOnly?8:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{canModerate:!!(1&o),canAdmin:!!(2&o),requiresConfirmation:!!(4&o),isReadOnly:!!(8&o)}}},bs=_t,vs=e.frame(xs),gs={preencode(d,o){bs.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),d.end++,o.permissions&&vs.preencode(d,o.permissions),o.expiration&&e.uint.preencode(d,o.expiration)},encode(d,o){const n=(o.permissions?1:0)|(o.expiration?2:0);bs.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,n),o.permissions&&vs.encode(d,o.permissions),o.expiration&&e.uint.encode(d,o.expiration)},decode(d){const o=bs.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{header:o,roomKey:n,permissions:1&c?vs.decode(d):null,expiration:2&c?e.uint.decode(d):0}}},Ks=di,ks={preencode(d,o){Ks.preencode(d,o.header),e.string.preencode(d,o.invitation)},encode(d,o){Ks.encode(d,o.header),e.string.encode(d,o.invitation)},decode:d=>({header:Ks.decode(d),invitation:e.string.decode(d)})},hs=_t,ws={preencode(e,d){hs.preencode(e,d.header)},encode(e,d){hs.encode(e,d.header)},decode:e=>({header:hs.decode(e)})},Ps=di,Rs={preencode(d,o){Ps.preencode(d,o.header),e.string.preencode(d,o.invitation)},encode(d,o){Ps.encode(d,o.header),e.string.encode(d,o.invitation)},decode:d=>({header:Ps.decode(d),invitation:e.string.decode(d)})},Ts=_t,As=rs,Ss={preencode(d,o){Ts.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),As.preencode(d,o.request)},encode(d,o){Ts.encode(d,o.header),e.fixed32.encode(d,o.roomKey),As.encode(d,o.request)},decode:d=>({header:Ts.decode(d),roomKey:e.fixed32.decode(d),request:As.decode(d)})},Is=di,Ms={preencode(e,d){Is.preencode(e,d.header)},encode(e,d){Is.encode(e,d.header)},decode:e=>({header:Is.decode(e)})},Fs=_t,qs=rs,Cs={preencode(d,o){Fs.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),qs.preencode(d,o.request)},encode(d,o){Fs.encode(d,o.header),e.fixed32.encode(d,o.roomKey),qs.encode(d,o.request)},decode:d=>({header:Fs.decode(d),roomKey:e.fixed32.decode(d),request:qs.decode(d)})},Vs=di,Hs={preencode(e,d){Vs.preencode(e,d.header)},encode(e,d){Vs.encode(e,d.header)},decode:e=>({header:Vs.decode(e)})},Ds=_t,Ls={preencode(d,o){Ds.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){Ds.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:Ds.decode(d),id:e.fixed32.decode(d)})},js=di,Es={preencode(e,d){js.preencode(e,d.header)},encode(e,d){js.encode(e,d.header)},decode:e=>({header:js.decode(e)})},Bs=_t,zs={preencode(d,o){Bs.preencode(d,o.header),e.string.preencode(d,o.displayName),d.end++,o.avatar&&e.buffer.preencode(d,o.avatar)},encode(d,o){const n=o.avatar?1:0;Bs.encode(d,o.header),e.string.encode(d,o.displayName),e.uint.encode(d,n),o.avatar&&e.buffer.encode(d,o.avatar)},decode:d=>({header:Bs.decode(d),displayName:e.string.decode(d),avatar:1&e.uint.decode(d)?e.buffer.decode(d):null})},Os=H,Ns=H,Us={preencode(e,d){e.end++},encode(d,o){const n=(o.isConfirmed?1:0)|(o.isLoggedOut?2:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isConfirmed:!!(1&o),isLoggedOut:!!(2&o)}}},Js=e.frame(Us),Ws=$,Gs={preencode(d,o){e.fixed32.preencode(d,o.memberKey),Js.preencode(d,o.status),Ws.preencode(d,o.deviceKeys)},encode(d,o){e.fixed32.encode(d,o.memberKey),Js.encode(d,o.status),Ws.encode(d,o.deviceKeys)},decode:d=>({memberKey:e.fixed32.decode(d),status:Js.decode(d),deviceKeys:Ws.decode(d)})},Qs={preencode(d,o){e.fixed32.preencode(d,o.memberKey)},encode(d,o){e.fixed32.encode(d,o.memberKey)},decode:d=>({memberKey:e.fixed32.decode(d)})},Xs={preencode(d,o){e.fixed32.preencode(d,o.deviceKey)},encode(d,o){e.fixed32.encode(d,o.deviceKey)},decode:d=>({deviceKey:e.fixed32.decode(d)})},Ys=_t,Zs={preencode(d,o){Ys.preencode(d,o.header),e.string.preencode(d,o.password)},encode(d,o){Ys.encode(d,o.header),e.string.encode(d,o.password)},decode:d=>({header:Ys.decode(d),password:e.string.decode(d)})},$s=di,_s={preencode(d,o){$s.preencode(d,o.header),e.string.preencode(d,o.inspector)},encode(d,o){$s.encode(d,o.header),e.string.encode(d,o.inspector)},decode:d=>({header:$s.decode(d),inspector:e.string.decode(d)})},ep=di,dp={preencode(e,d){ep.preencode(e,d.header)},encode(e,d){ep.encode(e,d.header)},decode:e=>({header:ep.decode(e)})},op=di,np={preencode(e,d){op.preencode(e,d.header)},encode(e,d){op.encode(e,d.header)},decode:e=>({header:op.decode(e)})},cp={Flag:1},rp={preencode(e,d){e.end++},encode(d,o){if(o>1)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},tp={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),rp.preencode(d,o.label)},encode(d,o){e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),rp.encode(d,o.label)},decode:d=>({key:e.fixed32.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),label:rp.decode(d)})},ip=de,ap={preencode(d,o){ip.preencode(d,o.header),e.fixed32.preencode(d,o.key),rp.preencode(d,o.label)},encode(d,o){ip.encode(d,o.header),e.fixed32.encode(d,o.key),rp.encode(d,o.label)},decode:d=>({header:ip.decode(d),key:e.fixed32.decode(d),label:rp.decode(d)})},sp={preencode(d,o){rp.preencode(d,o.label),e.uint.preencode(d,o.count)},encode(d,o){rp.encode(d,o.label),e.uint.encode(d,o.count)},decode:d=>({label:rp.decode(d),count:e.uint.decode(d)})},pp=e.array(e.frame(sp)),up={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.total),pp.preencode(d,o.labels),e.uint.preencode(d,o.editedAt),e.uint.preencode(d,o.flagsClock)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.total),pp.encode(d,o.labels),e.uint.encode(d,o.editedAt),e.uint.encode(d,o.flagsClock)},decode:d=>({key:e.fixed32.decode(d),total:e.uint.decode(d),labels:pp.decode(d),editedAt:e.uint.decode(d),flagsClock:e.uint.decode(d)})},lp=de,fp={preencode(d,o){lp.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.fromDeviceKey)},encode(d,o){lp.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.fromDeviceKey)},decode:d=>({header:lp.decode(d),deviceKey:e.fixed32.decode(d),fromDeviceKey:e.fixed32.decode(d)})},mp={preencode(d,o){e.float64.preencode(d,o.latitude),e.float64.preencode(d,o.longitude)},encode(d,o){e.float64.encode(d,o.latitude),e.float64.encode(d,o.longitude)},decode:d=>({latitude:e.float64.decode(d),longitude:e.float64.decode(d)})},yp=de,xp=$,bp={preencode(o,n){yp.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),e.buffer.preencode(o,n.encryptionKey),o.end++,d>=4&&n.streams&&xp.preencode(o,n.streams),d>=4&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=4&&n.version&&e.uint.preencode(o,n.version),d>=12&&n.streamInputs&&pl.preencode(o,n.streamInputs),d>=12&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey)},encode(o,n){const c=(d>=4&&n.streams?1:0)|(d>=4&&n.discoveryKey?2:0)|(d>=4&&n.version?4:0)|(d>=12&&n.streamInputs?8:0)|(d>=12&&n.swarmKey?16:0);yp.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,c),d>=4&&n.streams&&xp.encode(o,n.streams),d>=4&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=4&&n.version&&e.uint.encode(o,n.version),d>=12&&n.streamInputs&&pl.encode(o,n.streamInputs),d>=12&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey)},decode(o){const n=yp.decode(o),c=e.fixed32.decode(o),r=e.buffer.decode(o),t=e.uint.decode(o);return{header:n,callKey:c,encryptionKey:r,streams:d>=4&&1&t?xp.decode(o):null,discoveryKey:d>=4&&2&t?e.fixed32.decode(o):null,version:d>=4&&4&t?e.uint.decode(o):0,streamInputs:d>=12&&8&t?pl.decode(o):null,swarmKey:d>=12&&16&t?e.fixed32.decode(o):null}}},vp=de,gp=$,Kp={preencode(o,n){vp.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),o.end++,d>=4&&n.streams&&gp.preencode(o,n.streams),d>=12&&n.streamInputs&&ul.preencode(o,n.streamInputs),d>=12&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey)},encode(o,n){const c=(d>=4&&n.streams?1:0)|(d>=12&&n.streamInputs?2:0)|(d>=12&&n.swarmKey?4:0);vp.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.uint.encode(o,c),d>=4&&n.streams&&gp.encode(o,n.streams),d>=12&&n.streamInputs&&ul.encode(o,n.streamInputs),d>=12&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey)},decode(o){const n=vp.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{header:n,callKey:c,streams:d>=4&&1&r?gp.decode(o):null,streamInputs:d>=12&&2&r?ul.decode(o):null,swarmKey:d>=12&&4&r?e.fixed32.decode(o):null}}},kp=de,hp={preencode(d,o){kp.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){kp.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:kp.decode(d),callKey:e.fixed32.decode(d)})},wp=de,Pp={preencode(d,o){wp.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){wp.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:wp.decode(d),callKey:e.fixed32.decode(d)})},Rp=de,Tp={preencode(o,n){Rp.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.streamKey),o.end++,d>=12&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=12&&n.type&&e.string.preencode(o,n.type)},encode(o,n){const c=(d>=12&&n.mediaStreamId?1:0)|(d>=12&&n.type?2:0)|(d>=12&&n.muted?4:0);Rp.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.streamKey),e.uint.encode(o,c),d>=12&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=12&&n.type&&e.string.encode(o,n.type)},decode(o){const n=Rp.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=o.start<o.end?e.uint.decode(o):0;return{header:n,callKey:c,streamKey:r,mediaStreamId:d>=12&&1&t?e.string.decode(o):null,type:d>=12&&2&t?e.string.decode(o):null,muted:d>=12&&!!(4&t)}}},Ap=de,Sp={preencode(d,o){Ap.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.streamKey)},encode(d,o){Ap.encode(d,o.header),e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.streamKey)},decode:d=>({header:Ap.decode(d),callKey:e.fixed32.decode(d),streamKey:e.fixed32.decode(d)})},Ip={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.buffer.preencode(o,n.encryptionKey),e.uint.preencode(o,n.createdAt),o.end++,d>=4&&n.endedAt&&e.uint.preencode(o,n.endedAt),d>=4&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=4&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(d>=4&&n.endedAt?1:0)|(d>=4&&n.discoveryKey?2:0)|(d>=4&&n.version?4:0);e.fixed32.encode(o,n.callKey),e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=4&&n.endedAt&&e.uint.encode(o,n.endedAt),d>=4&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=4&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=e.fixed32.decode(o),c=e.buffer.decode(o),r=e.uint.decode(o),t=e.uint.decode(o);return{callKey:n,encryptionKey:c,createdAt:r,endedAt:d>=4&&1&t?e.uint.decode(o):0,discoveryKey:d>=4&&2&t?e.fixed32.decode(o):null,version:d>=4&&4&t?e.uint.decode(o):0}}},Mp={preencode(d,o){e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.createdAt)},encode(d,o){e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.createdAt)},decode:d=>({callKey:e.fixed32.decode(d),memberKey:e.fixed32.decode(d),createdAt:e.uint.decode(d)})},Fp={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.deviceKey),e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.createdAt),o.end++,d>=4&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),d>=8&&n.lastHeartbeatAt&&e.uint.preencode(o,n.lastHeartbeatAt)},encode(o,n){const c=(d>=4&&n.swarmKey?1:0)|(d>=8&&n.lastHeartbeatAt?2:0)|(d>=9&&n.isRecording?4:0);e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.deviceKey),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=4&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey),d>=8&&n.lastHeartbeatAt&&e.uint.encode(o,n.lastHeartbeatAt)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o),i=e.uint.decode(o);return{callKey:n,deviceKey:c,memberKey:r,createdAt:t,swarmKey:d>=4&&1&i?e.fixed32.decode(o):null,lastHeartbeatAt:d>=8&&2&i?e.uint.decode(o):0,isRecording:d>=9&&!!(4&i)}}},qp={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.deviceKey),e.buffer.preencode(o,n.streamKey),e.uint.preencode(o,n.createdAt),o.end++,d>=12&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=12&&n.type&&e.string.preencode(o,n.type),d>=12&&n.statusKey&&e.uint.preencode(o,n.statusKey)},encode(o,n){const c=(d>=12&&n.mediaStreamId?1:0)|(d>=12&&n.type?2:0)|(d>=12&&n.statusKey?4:0);e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.deviceKey),e.buffer.encode(o,n.streamKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=12&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=12&&n.type&&e.string.encode(o,n.type),d>=12&&n.statusKey&&e.uint.encode(o,n.statusKey)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.buffer.decode(o),t=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{callKey:n,deviceKey:c,streamKey:r,createdAt:t,mediaStreamId:d>=12&&1&i?e.string.decode(o):null,type:d>=12&&2&i?e.string.decode(o):null,statusKey:d>=12&&4&i?e.uint.decode(o):0}}},Cp={preencode(o,n){e.fixed32.preencode(o,n.callKey),o.end++,d>=4&&n.selfDeviceKey&&e.fixed32.preencode(o,n.selfDeviceKey),d>=12&&n.createdAt&&e.uint.preencode(o,n.createdAt)},encode(o,n){const c=(d>=4&&n.selfDeviceKey?1:0)|(d>=12&&n.createdAt?2:0);e.fixed32.encode(o,n.callKey),e.uint.encode(o,c),d>=4&&n.selfDeviceKey&&e.fixed32.encode(o,n.selfDeviceKey),d>=12&&n.createdAt&&e.uint.encode(o,n.createdAt)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o);return{callKey:n,selfDeviceKey:d>=4&&1&c?e.fixed32.decode(o):null,createdAt:d>=12&&2&c?e.uint.decode(o):0}}},Vp={preencode(d,o){e.uint.preencode(d,o.lastCleared)},encode(d,o){e.uint.encode(d,o.lastCleared)},decode:d=>({lastCleared:e.uint.decode(d)})},Hp={Nightly:"Nightly",Internal:"Internal",Production:"Production"},Dp={preencode(e,d){e.end++},encode(d,o){switch(o){case"Nightly":e.uint.encode(d,1);break;case"Internal":e.uint.encode(d,2);break;case"Production":e.uint.encode(d,3);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"Nightly";case 2:return"Internal";case 3:return"Production";default:return null}}},Lp=de,jp={preencode(e,d){Lp.preencode(e,d.header)},encode(e,d){Lp.encode(e,d.header)},decode:e=>({header:Lp.decode(e)})},Ep=de,Bp={preencode(e,d){Ep.preencode(e,d.header)},encode(e,d){Ep.encode(e,d.header)},decode:e=>({header:Ep.decode(e)})},zp={preencode(o,n){Dp.preencode(o,n.buildType),o.end++,d>=6&&n.latestOfflineAbi&&e.uint.preencode(o,n.latestOfflineAbi)},encode(o,n){const c=d>=6&&n.latestOfflineAbi?1:0;Dp.encode(o,n.buildType),e.uint.encode(o,c),d>=6&&n.latestOfflineAbi&&e.uint.encode(o,n.latestOfflineAbi)},decode(o){const n=Dp.decode(o),c=o.start<o.end?e.uint.decode(o):0;return{buildType:n,latestOfflineAbi:d>=6&&1&c?e.uint.decode(o):0}}},Op=de,Np={preencode(d,o){Op.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),e.buffer.preencode(d,o.deviceProof),e.buffer.preencode(d,o.writerProof)},encode(d,o){Op.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.buffer.encode(d,o.deviceProof),e.buffer.encode(d,o.writerProof)},decode:d=>({header:Op.decode(d),deviceKey:e.fixed32.decode(d),deviceProof:e.buffer.decode(d),writerProof:e.buffer.decode(d)})},Up={preencode(o,n){o.end++,d>=7&&n.otaResyncPrivateProfileBump&&e.uint.preencode(o,n.otaResyncPrivateProfileBump)},encode(o,n){const c=d>=7&&n.otaResyncPrivateProfileBump?1:0;e.uint.encode(o,c),d>=7&&n.otaResyncPrivateProfileBump&&e.uint.encode(o,n.otaResyncPrivateProfileBump)},decode(o){const n=e.uint.decode(o);return{otaResyncPrivateProfileBump:d>=7&&1&n?e.uint.decode(o):0}}},Jp={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.buffer.preencode(d,o.proof),e.uint.preencode(d,o.createdAt)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.buffer.encode(d,o.proof),e.uint.encode(d,o.createdAt)},decode:d=>({deviceKey:e.fixed32.decode(d),proof:e.buffer.decode(d),createdAt:e.uint.decode(d)})},Wp=de,Gp={preencode(d,o){Wp.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Wp.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Wp.decode(d),callKey:e.fixed32.decode(d)})},Qp=de,Xp={preencode(d,o){Qp.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.deviceKey)},encode(d,o){Qp.encode(d,o.header),e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.deviceKey)},decode:d=>({header:Qp.decode(d),callKey:e.fixed32.decode(d),deviceKey:e.fixed32.decode(d)})},Yp=e.frame(Nn),Zp=e.array(e.frame(Dn)),$p={preencode(e,d){Yp.preencode(e,d.digest),Zp.preencode(e,d.mine)},encode(e,d){Yp.encode(e,d.digest),Zp.encode(e,d.mine)},decode:e=>({digest:Yp.decode(e),mine:Zp.decode(e)})},_p=de,eu={preencode(d,o){_p.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){_p.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:_p.decode(d),callKey:e.fixed32.decode(d)})},du=de,ou={preencode(d,o){du.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){du.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:du.decode(d),callKey:e.fixed32.decode(d)})},nu={preencode(o,n){o.end++,d>=9&&n.profileSnoozeTime&&e.uint.preencode(o,n.profileSnoozeTime)},encode(o,n){const c=(d>=9&&n.disableReadReceipts?1:0)|(d>=9&&n.stripAttachmentMetadata?2:0)|(d>=9&&n.profileSnoozeTime?4:0);e.uint.encode(o,c),d>=9&&n.profileSnoozeTime&&e.uint.encode(o,n.profileSnoozeTime)},decode(o){const n=e.uint.decode(o);return{disableReadReceipts:d>=9&&!!(1&n),stripAttachmentMetadata:d>=9&&!!(2&n),profileSnoozeTime:d>=9&&4&n?e.uint.decode(o):0}}},cu={preencode(o,n){o.end++,d>=9&&n.maxPeers&&e.uint.preencode(o,n.maxPeers)},encode(o,n){const c=d>=9&&n.maxPeers?1:0;e.uint.encode(o,c),d>=9&&n.maxPeers&&e.uint.encode(o,n.maxPeers)},decode(o){const n=e.uint.decode(o);return{maxPeers:d>=9&&1&n?e.uint.decode(o):0}}},ru=de,tu={preencode(e,d){ru.preencode(e,d.header),n.preencode(e,d.oplog)},encode(e,d){ru.encode(e,d.header),n.encode(e,d.oplog)},decode:e=>({header:ru.decode(e),oplog:n.decode(e)})},iu=de,au={preencode(e,d){iu.preencode(e,d.header)},encode(e,d){iu.encode(e,d.header)},decode:e=>({header:iu.decode(e)})},su={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.timestamp)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.timestamp)},decode:d=>({memberKey:e.fixed32.decode(d),timestamp:e.uint.decode(d)})},pu=de,uu={preencode(o,n){pu.preencode(o,n.header),e.fixed32.preencode(o,n.memberKey),o.end++,d>=10&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=d>=10&&n.alias?1:0;pu.encode(o,n.header),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,c),d>=10&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=pu.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{header:n,memberKey:c,alias:d>=10&&1&r?e.string.decode(o):null}}},lu={preencode(d,o){e.uint.preencode(d,o.streams)},encode(d,o){e.uint.encode(d,o.streams)},decode:d=>({streams:e.uint.decode(d)})},fu={preencode(d,o){e.fixed32.preencode(d,o.streamKey),e.string.preencode(d,o.mediaStreamId),e.string.preencode(d,o.type),d.end++},encode(o,n){const c=d>=12&&n.muted?1:0;e.fixed32.encode(o,n.streamKey),e.string.encode(o,n.mediaStreamId),e.string.encode(o,n.type),e.uint.encode(o,c)},decode(o){const n=e.fixed32.decode(o),c=e.string.decode(o),r=e.string.decode(o),t=e.uint.decode(o);return{streamKey:n,mediaStreamId:c,type:r,muted:d>=12&&!!(1&t)}}},mu=de,yu={preencode(d,o){mu.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.streamKey),d.end++},encode(o,n){const c=d>=12&&n.muted?1:0;mu.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.streamKey),e.uint.encode(o,c)},decode(o){const n=mu.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o);return{header:n,callKey:c,streamKey:r,muted:d>=12&&!!(1&t)}}},xu={preencode(d,o){e.uint.preencode(d,o.statusKey),d.end++},encode(o,n){const c=d>=12&&n.muted?1:0;e.uint.encode(o,n.statusKey),e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o),c=e.uint.decode(o);return{statusKey:n,muted:d>=12&&!!(1&c)}}},bu={preencode(n,c){e.fixed32.preencode(n,c.key),n.end++,d>=13&&c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),d>=13&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=(d>=13&&c.encryptionKey?1:0)|(d>=13&&c.bootFrom?2:0);e.fixed32.encode(n,c.key),e.uint.encode(n,r),d>=13&&c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),d>=13&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.uint.decode(n);return{key:c,encryptionKey:d>=13&&1&r?e.buffer.decode(n):null,bootFrom:d>=13&&2&r?o.decode(n):null}}},vu={preencode(d,o){e.fixed32.preencode(d,o.hash)},encode(d,o){e.fixed32.encode(d,o.hash)},decode:d=>({hash:e.fixed32.decode(d)})},gu={preencode(d,o){e.fixed32.preencode(d,o.hash),e.buffer.preencode(d,o.data)},encode(d,o){e.fixed32.encode(d,o.hash),e.buffer.encode(d,o.data)},decode:d=>({hash:e.fixed32.decode(d),data:e.buffer.decode(d)})},Ku={preencode(n,c){o.preencode(n,c.autobeeMigrationHead),n.end++,d>=13&&c.legacyViewHead&&o.preencode(n,c.legacyViewHead),d>=13&&c.dbViewHead&&o.preencode(n,c.dbViewHead),d>=13&&c.blobsViewHead&&o.preencode(n,c.blobsViewHead),e.uint.preencode(n,c.createdAt)},encode(n,c){const r=(d>=13&&c.legacyViewHead?1:0)|(d>=13&&c.dbViewHead?2:0)|(d>=13&&c.blobsViewHead?4:0);o.encode(n,c.autobeeMigrationHead),e.uint.encode(n,r),d>=13&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=13&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=13&&c.blobsViewHead&&o.encode(n,c.blobsViewHead),e.uint.encode(n,c.createdAt)},decode(n){const c=o.decode(n),r=e.uint.decode(n);return{autobeeMigrationHead:c,legacyViewHead:d>=13&&1&r?o.decode(n):null,dbViewHead:d>=13&&2&r?o.decode(n):null,blobsViewHead:d>=13&&4&r?o.decode(n):null,createdAt:e.uint.decode(n)}}},ku=de,hu={preencode(e,n){ku.preencode(e,n.header),o.preencode(e,n.head),e.end++,d>=13&&n.legacyViewHead&&o.preencode(e,n.legacyViewHead),d>=13&&n.dbViewHead&&o.preencode(e,n.dbViewHead),d>=13&&n.blobsViewHead&&o.preencode(e,n.blobsViewHead)},encode(n,c){const r=(d>=13&&c.legacyViewHead?1:0)|(d>=13&&c.dbViewHead?2:0)|(d>=13&&c.blobsViewHead?4:0);ku.encode(n,c.header),o.encode(n,c.head),e.uint.encode(n,r),d>=13&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=13&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=13&&c.blobsViewHead&&o.encode(n,c.blobsViewHead)},decode(n){const c=ku.decode(n),r=o.decode(n),t=e.uint.decode(n);return{header:c,head:r,legacyViewHead:d>=13&&1&t?o.decode(n):null,dbViewHead:d>=13&&2&t?o.decode(n):null,blobsViewHead:d>=13&&4&t?o.decode(n):null}}},wu={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.fixed32.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.seed),n.end++,d>=13&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=d>=13&&c.bootFrom?1:0;e.fixed32.encode(n,c.roomKey),e.fixed32.encode(n,c.encryptionKey),e.fixed32.encode(n,c.seed),e.uint.encode(n,r),d>=13&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.fixed32.decode(n),t=e.fixed32.decode(n),i=e.uint.decode(n);return{roomKey:c,encryptionKey:r,seed:t,bootFrom:d>=13&&1&i?o.decode(n):null}}},Pu=bd,Ru={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.fixed32.preencode(d,o.deviceKey),e.uint.preencode(d,o.deviceLength),e.uint.preencode(d,o.clock),Pu.preencode(d,o.status)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,o.deviceLength),e.uint.encode(d,o.clock),Pu.encode(d,o.status)},decode:d=>({memberKey:e.fixed32.decode(d),deviceKey:e.fixed32.decode(d),deviceLength:e.uint.decode(d),clock:e.uint.decode(d),status:Pu.decode(d)})},Tu={preencode(d,o){e.fixed32.preencode(d,o.hash),e.buffer.preencode(d,o.blob)},encode(d,o){e.fixed32.encode(d,o.hash),e.buffer.encode(d,o.blob)},decode:d=>({hash:e.fixed32.decode(d),blob:e.buffer.decode(d)})},Au=vc,Su=gc,Iu=tc,Mu={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),Au.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,d>=13&&c.initiator&&o.preencode(n,c.initiator),d>=13&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=13&&c.identitySwap&&Su.preencode(n,c.identitySwap),d>=13&&c.identitySwapV2&&Iu.preencode(n,c.identitySwapV2),d>=13&&c.contact&&e.fixed32.preencode(n,c.contact)},encode(n,c){const r=(d>=13&&c.initiator?1:0)|(d>=13&&c.bootFrom?2:0)|(d>=13&&c.identitySwap?4:0)|(d>=13&&c.identitySwapV2?8:0)|(d>=13&&c.contact?16:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),Au.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,r),d>=13&&c.initiator&&o.encode(n,c.initiator),d>=13&&c.bootFrom&&o.encode(n,c.bootFrom),d>=13&&c.identitySwap&&Su.encode(n,c.identitySwap),d>=13&&c.identitySwapV2&&Iu.encode(n,c.identitySwapV2),d>=13&&c.contact&&e.fixed32.encode(n,c.contact)},decode(n){const c=e.fixed32.decode(n),r=e.buffer.decode(n),t=e.fixed32.decode(n),i=Au.decode(n),a=e.uint.decode(n),s=e.uint.decode(n);return{roomKey:c,encryptionKey:r,mailbox:t,status:i,clock:a,initiator:d>=13&&1&s?o.decode(n):null,bootFrom:d>=13&&2&s?o.decode(n):null,identitySwap:d>=13&&4&s?Su.decode(n):null,identitySwapV2:d>=13&&8&s?Iu.decode(n):null,contact:d>=13&&16&s?e.fixed32.decode(n):null}}},Fu=de,qu={preencode(n,c){Fu.preencode(n,c.header),e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),n.end++,d>=13&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=13&&c.initiator&&o.preencode(n,c.initiator),d>=13&&c.dm&&e.fixed32.preencode(n,c.dm)},encode(n,c){const r=(d>=13&&c.bootFrom?1:0)|(d>=13&&c.initiator?2:0)|(d>=13&&c.dm?4:0)|(d>=13&&c.isReadOnly?8:0);Fu.encode(n,c.header),e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),e.uint.encode(n,r),d>=13&&c.bootFrom&&o.encode(n,c.bootFrom),d>=13&&c.initiator&&o.encode(n,c.initiator),d>=13&&c.dm&&e.fixed32.encode(n,c.dm)},decode(n){const c=Fu.decode(n),r=e.fixed32.decode(n),t=e.buffer.decode(n),i=e.fixed32.decode(n),a=e.uint.decode(n);return{header:c,roomKey:r,encryptionKey:t,mailbox:i,bootFrom:d>=13&&1&a?o.decode(n):null,initiator:d>=13&&2&a?o.decode(n):null,dm:d>=13&&4&a?e.fixed32.decode(n):null,isReadOnly:d>=13&&!!(8&a)}}},Cu={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),n.end++,d>=13&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=13&&c.initiator&&o.preencode(n,c.initiator)},encode(n,c){const r=(d>=13&&c.bootFrom?1:0)|(d>=13&&c.initiator?2:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.uint.encode(n,r),d>=13&&c.bootFrom&&o.encode(n,c.bootFrom),d>=13&&c.initiator&&o.encode(n,c.initiator)},decode(n){const c=e.fixed32.decode(n),r=e.buffer.decode(n),t=e.uint.decode(n);return{roomKey:c,encryptionKey:r,bootFrom:d>=13&&1&t?o.decode(n):null,initiator:d>=13&&2&t?o.decode(n):null}}},Vu={preencode(d,o){e.fixed32.preencode(d,o.roomKey),ll.preencode(d,o.head),e.uint.preencode(d,o.timestamp),d.end++},encode(o,n){const c=d>=13&&n.incremental?1:0;e.fixed32.encode(o,n.roomKey),ll.encode(o,n.head),e.uint.encode(o,n.timestamp),e.uint.encode(o,c)},decode(o){const n=e.fixed32.decode(o),c=ll.decode(o),r=e.uint.decode(o),t=e.uint.decode(o);return{roomKey:n,head:c,timestamp:r,incremental:d>=13&&!!(1&t)}}},Hu={preencode(o,n){o.end++,d>=13&&n.key&&e.fixed32.preencode(o,n.key),e.uint.preencode(o,n.length)},encode(o,n){const c=d>=13&&n.key?1:0;e.uint.encode(o,c),d>=13&&n.key&&e.fixed32.encode(o,n.key),e.uint.encode(o,n.length)},decode(o){const n=e.uint.decode(o);return{key:d>=13&&1&n?e.fixed32.decode(o):null,length:e.uint.decode(o)}}},Du={preencode(n,c){e.fixed32.preencode(n,c.roomKey),n.end++,d>=13&&c.legacyViewHead&&o.preencode(n,c.legacyViewHead),d>=13&&c.dbViewHead&&o.preencode(n,c.dbViewHead),d>=13&&c.blobsViewHead&&o.preencode(n,c.blobsViewHead),d>=13&&c.autobeeMigrationHead&&o.preencode(n,c.autobeeMigrationHead)},encode(n,c){const r=(d>=13&&c.legacyViewHead?1:0)|(d>=13&&c.dbViewHead?2:0)|(d>=13&&c.blobsViewHead?4:0)|(d>=13&&c.autobeeMigrationHead?8:0);e.fixed32.encode(n,c.roomKey),e.uint.encode(n,r),d>=13&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=13&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=13&&c.blobsViewHead&&o.encode(n,c.blobsViewHead),d>=13&&c.autobeeMigrationHead&&o.encode(n,c.autobeeMigrationHead)},decode(n){const c=e.fixed32.decode(n),r=e.uint.decode(n);return{roomKey:c,legacyViewHead:d>=13&&1&r?o.decode(n):null,dbViewHead:d>=13&&2&r?o.decode(n):null,blobsViewHead:d>=13&&4&r?o.decode(n):null,autobeeMigrationHead:d>=13&&8&r?o.decode(n):null}}},Lu={preencode(d,o){e.fixed32.preencode(d,o.id),e.fixed32.preencode(d,o.writerKey),e.buffer.preencode(d,o.blindResponse)},encode(d,o){e.fixed32.encode(d,o.id),e.fixed32.encode(d,o.writerKey),e.buffer.encode(d,o.blindResponse)},decode:d=>({id:e.fixed32.decode(d),writerKey:e.fixed32.decode(d),blindResponse:e.buffer.decode(d)})},ju=de,Eu={preencode(d,o){ju.preencode(d,o.header),e.buffer.preencode(d,o.blindResponse)},encode(d,o){ju.encode(d,o.header),e.buffer.encode(d,o.blindResponse)},decode:d=>({header:ju.decode(d),blindResponse:e.buffer.decode(d)})},Bu=e.frame(qr),zu={preencode(o,n){e.string.preencode(o,n.mnemonic),o.end++,d>=15&&n.profileDiscoveryTimeout&&e.uint.preencode(o,n.profileDiscoveryTimeout),d>=15&&n.privateProfileKey&&e.fixed32.preencode(o,n.privateProfileKey),d>=15&&n.identity&&Bu.preencode(o,n.identity)},encode(o,n){const c=(d>=15&&n.profileDiscoveryTimeout?1:0)|(d>=15&&n.privateProfileKey?2:0)|(d>=15&&n.identity?4:0);e.string.encode(o,n.mnemonic),e.uint.encode(o,c),d>=15&&n.profileDiscoveryTimeout&&e.uint.encode(o,n.profileDiscoveryTimeout),d>=15&&n.privateProfileKey&&e.fixed32.encode(o,n.privateProfileKey),d>=15&&n.identity&&Bu.encode(o,n.identity)},decode(o){const n=e.string.decode(o),c=e.uint.decode(o);return{mnemonic:n,profileDiscoveryTimeout:d>=15&&1&c?e.uint.decode(o):0,privateProfileKey:d>=15&&2&c?e.fixed32.decode(o):null,identity:d>=15&&4&c?Bu.decode(o):null}}},Ou=e.frame(w),Nu=e.frame(lu),Uu=Ou,Ju=e.frame(le),Wu=Ou,Gu=Ju,Qu=e.frame(wu),Xu=Ju,Yu=e.frame(wd),Zu=e.frame(mp),$u=Zu,_u=Ou,el=Ou,dl=e.frame(Ic),ol=dl,nl=dl,cl=e.frame(Cp),rl=e.frame($p),tl=e.frame(nu),il=e.frame(Hu),al=il,sl=Ju,pl=e.array(e.frame(fu)),ul=pl,ll=il;function fl(e){switch(e){case"@keet/head":return o;case"@keet/oplog-id":return n;case"@keet/encryption-keypair":return c;case"@keet/signing-keypair":return r;case"@keet/room-keys":return t;case"@keet/operation-header":return i;case"@keet/blob-pointer":return a;case"@keet/file-dimensions":return s;case"@keet/file-metadata":return u;case"@keet/external-drive-pointer":return l;case"@keet/external-blob-pointer":return f;case"@keet/file-pointer":return x;case"@keet/file":return g;case"@keet/image-file":return w;case"@keet/file-status":return P;case"@keet/file-record":return A;case"@keet/device-status":return S;case"@keet/member-status":return I;case"@keet/member-moderation-status":return M;case"@keet/abi":return F;case"@keet/device-stats":return q;case"@keet/member-stats":return C;case"@keet/chat-stats":return V;case"@keet/file-stats":return H;case"@keet/stats":return B;case"@keet/room-type":return O;case"@keet/system-settings":return N;case"@keet/system-digest":return W;case"@keet/room-seed":return G;case"@keet/room-capabilities":return Q;case"@keet/room-supported-language":return Y;case"@keet/room-config":return _;case"@keet/blind-peer":return ee;case"@keet/add-blind-peer-operation":return ne;case"@keet/remove-blind-peer-operation":return re;case"@keet/identity-attestation":return te;case"@keet/device-invitation":return ie;case"@keet/device":return pe;case"@keet/member-profile":return ue;case"@keet/device-profile":return le;case"@keet/member-update":return me;case"@keet/device-update":return ye;case"@keet/member-contact-info":return be;case"@keet/signed-pairing-data":return ve;case"@keet/device-request-identity":return ge;case"@keet/device-response-identity":return Ke;case"@keet/device-identity":return ke;case"@keet/device-request-with-invitation":return Re;case"@keet/device-request-with-invitation-and-proof":return Ae;case"@keet/device-request-with-member-proof":return Me;case"@keet/device-request":return Ce;case"@keet/device-response":return De;case"@keet/invitation-metadata":return Le;case"@keet/invitation":return Be;case"@keet/add-invitation-operation":return Ne;case"@keet/remove-invitation-operation":return Je;case"@keet/sendable-room-invitation":return We;case"@keet/readonly-room-invitation":return Ge;case"@keet/sendable-identity-invitation":return Qe;case"@keet/sendable-contact-invitation":return Xe;case"@keet/sendable-invitation":return dd;case"@keet/add-device-operation":return nd;case"@keet/update-device-operation":return rd;case"@keet/remove-device-operation":return id;case"@keet/start-indexing-operation":return ad;case"@keet/stop-indexing-operation":return sd;case"@keet/join-request":return ud;case"@keet/accept-join-request-operation":return md;case"@keet/reject-join-request-operation":return xd;case"@keet/member":return gd;case"@keet/full-member":return hd;case"@keet/member-proofs":return wd;case"@keet/update-member-operation":return Td;case"@keet/change-member-status-operation":return Id;case"@keet/change-member-role-operation":return Fd;case"@keet/remove-member-operation":return Cd;case"@keet/member-activity":return Vd;case"@keet/member-joined-event":return Hd;case"@keet/member-left-event":return Dd;case"@keet/member-removed-event":return Ld;case"@keet/title-changed-chat-event":return jd;case"@keet/chat-event":return Nd;case"@keet/sendable-event":return Ud;case"@keet/display-range":return Jd;case"@keet/display-content-range":return Gd;case"@keet/mention-display-item":return Xd;case"@keet/translation-display-item":return Zd;case"@keet/link-preview":return eo;case"@keet/display-link-item":return co;case"@keet/display":return yo;case"@keet/oplog-message":return go;case"@keet/index-message":return ho;case"@keet/full-index-message":return Ro;case"@keet/message-status":return To;case"@keet/message-index-id":return Ao;case"@keet/thread":return Io;case"@keet/chat-message-record":return Co;case"@keet/full-chat-message-record":return Lo;case"@keet/add-chat-message-operation":return Bo;case"@keet/remove-chat-message-operation":return Oo;case"@keet/update-chat-message-operation":return Jo;case"@keet/pin-chat-message-operation":return Go;case"@keet/display-type":return Xo;case"@keet/add-file-preview-operation":return Zo;case"@keet/reaction":return $o;case"@keet/reactions-summary":return _o;case"@keet/reactions-digest":return dn;case"@keet/add-reaction-operation":return nn;case"@keet/remove-reaction-operation":return rn;case"@keet/update-room-config-operation":return sn;case"@keet/group-member":return pn;case"@keet/user-registry-info":return un;case"@keet/room-identity":return fn;case"@keet/genesis-operation":return kn;case"@keet/upgrade-operation":return wn;case"@keet/migrate-abi-operation":return Rn;case"@keet/system-settings-keys":return An;case"@keet/update-system-settings-operation":return Mn;case"@keet/test-increment-operation":return qn;case"@keet/test-collection-record-1":return Cn;case"@keet/label-type":return Hn;case"@keet/chat-label":return Dn;case"@keet/add-chat-label-operation":return jn;case"@keet/remove-chat-label-operation":return Bn;case"@keet/chat-label-summary":return zn;case"@keet/chat-label-digest":return Nn;case"@keet/update-read-length-operation":return Jn;case"@keet/read-length":return Wn;case"@keet/tmp-removed-member":return Gn;case"@keet-private-id/contact":return Xn;case"@keet-private-id/v3-room-migration-info":return Yn;case"@keet-private-id/run-v3-migration-operation":return _n;case"@keet-private-id/update-identity-operation":return dc;case"@keet-private-id/counters":return oc;case"@keet-private-id/stats":return nc;case"@keet-private-id/add-entropy-operation":return cc;case"@keet-private-id/pending-invitation-identity":return rc;case"@keet-private-id/pending-invitation":return ic;case"@keet-private-id/resolve-pending-invitation-operation":return sc;case"@keet-private-id/add-pending-invitation-operation":return lc;case"@keet-private-id/remove-pending-invitation-operation":return mc;case"@keet-private-id/identity-swap":return yc;case"@keet-private-id/identity-swap-v2":return xc;case"@keet-private-id/room-status":return bc;case"@keet-private-id/room":return kc;case"@keet-private-id/add-room-operation":return wc;case"@keet-private-id/remove-room-operation":return Rc;case"@keet-private-id/update-room-status-operation":return Sc;case"@keet-private-id/contact-status":return Ic;case"@keet-private-id/contact-record":return Fc;case"@keet-private-id/add-contact-operation":return Vc;case"@keet-private-id/update-contact-status-operation":return Dc;case"@keet-private-id/remove-contact-operation":return jc;case"@keet-private-id/activate-contact-room-operation":return Bc;case"@keet-private-id/contact-request-status":return zc;case"@keet-private-id/contact-request-body":return Uc;case"@keet-private-id/contact-request":return Wc;case"@keet-private-id/contact-request-record":return Zc;case"@keet-private-id/add-contact-request-operation":return _c;case"@keet-private-id/update-contact-request-status-operation":return or;case"@keet-private-id/profile-discovery-record-v1":return nr;case"@keet-private-id/profile-discovery-record":return cr;case"@keet-private-id/unreads":return rr;case"@keet-private-id/add-unreads-key-operation":return ir;case"@keet-private-id/remove-unreads-key-operation":return sr;case"@keet-private-id/settings":return pr;case"@keet-private-id/user-settings-key":return lr;case"@keet-private-id/update-settings-operation":return yr;case"@local/background-sync-room":return xr;case"@local/stats":return br;case"@local/migration-status":return vr;case"@local/v3-private-profile-migration":return Kr;case"@local/v3-room-migration":return wr;case"@local/room-migration-stats":return Pr;case"@local/room-migration":return Tr;case"@local/identity-status":return Ar;case"@local/identity-swap":return Sr;case"@local/identity-record":return qr;case"@local/tasks":return Vr;case"@local/room-keys":return Hr;case"@local/join-room-invitation-task":return Lr;case"@local/join-room-response-task":return jr;case"@local/fast-forward-to":return Er;case"@local/add-room-fields":return Br;case"@local/join-room-keys-task":return Or;case"@local/create-room-task":return Ur;case"@local/leave-room-task":return Jr;case"@local/clear-room-task":return Wr;case"@local/restore-identity-task":return Gr;case"@local/send-contact-request-task":return Xr;case"@local/migrate-v2-room-task":return Yr;case"@local/task":return tt;case"@local/shared-invitation":return at;case"@local/room-status":return st;case"@local/room-timestamps":return pt;case"@local/room":return Rt;case"@local/room-preferences":return At;case"@local/room-metadata":return St;case"@local/writer":return It;case"@local/writer-append":return Mt;case"@local/member":return qt;case"@local/device":return Vt;case"@local/file":return Dt;case"@local/debug-flag":return Lt;case"@local/debug":return Et;case"@local/hyperdht-record":return zt;case"@local/unread":return Ot;case"@local/error-record-details":return Nt;case"@local/error-record":return Jt;case"@local/keet-state":return Gt;case"@local/file-stats":return Qt;case"@api/request-header":return Xt;case"@api/response-header":return Yt;case"@api/subscription-request-header":return Zt;case"@api/subscription-response-header":return $t;case"@api/boot-request":return ei;case"@api/boot-response":return oi;case"@api/self-destruct-request":return ci;case"@api/core/have":return ri;case"@api/core/create-room-request":return si;case"@api/core/create-room-response":return ui;case"@api/core/activate-room-request":return fi;case"@api/core/deactivate-room-request":return yi;case"@api/core/leave-room-request":return bi;case"@api/core/leave-room-response":return gi;case"@api/core/update-room-config-request":return hi;case"@api/core/update-room-settings-request":return Ri;case"@api/core/update-room-status-request":return Si;case"@api/core/add-chat-message-request":return Fi;case"@api/core/add-chat-message-response":return Ci;case"@api/core/edit-chat-message-request":return Di;case"@api/core/edit-chat-message-response":return ji;case"@api/core/remove-chat-message-request":return Bi;case"@api/core/remove-chat-message-response":return Oi;case"@api/core/add-chat-reaction-request":return Ui;case"@api/core/add-chat-reaction-response":return Wi;case"@api/core/remove-chat-reaction-request":return Qi;case"@api/core/remove-chat-reaction-response":return Yi;case"@api/core/want-lobby":return Zi;case"@api/core/unwant-lobby":return $i;case"@api/core/want-room-info":return ea;case"@api/core/want-chat":return da;case"@api/core/unwant-chat":return oa;case"@api/core/want-members":return na;case"@api/core/unwant-members":return ca;case"@api/core/lobby-record":return ra;case"@api/core/lobby-record-change-type":return ia;case"@api/core/lobby":return sa;case"@api/core/lobby-room":return pa;case"@api/core/room-role":return fa;case"@api/core/room-info":return ba;case"@api/core/room-info-status":return ga;case"@api/core/room-info-digest":return ka;case"@api/core/room-info-config":return wa;case"@api/core/room-info-role":return Ra;case"@api/core/room-info-last-message":return Ta;case"@api/core/member":return Sa;case"@api/core/device":return Ma;case"@api/core/member-list-add":return Fa;case"@api/core/member-list-remove":return qa;case"@api/core/chat-reset":return Va;case"@api/core/message-timestamps":return Ha;case"@api/core/message":return Ba;case"@api/core/message-info":return Na;case"@api/core/message-info-chat":return Ja;case"@api/core/message-info-member":return Ga;case"@api/core/message-info-role":return Ya;case"@api/core/message-info-reactions":return $a;case"@api/core/reactions":return es;case"@api/core/want-pairing":return ds;case"@api/core/unwant-pairing":return os;case"@api/core/pending-invitations":return cs;case"@api/core/join-request":return ts;case"@api/core/join-requests":return as;case"@api/core/pairing":return us;case"@api/core/start-pairing-request":return fs;case"@api/core/start-pairing-response":return ys;case"@api/core/invitation-permissions":return xs;case"@api/core/create-room-invitation-request":return gs;case"@api/core/create-room-invitation-response":return ks;case"@api/core/create-identity-invitation-request":return ws;case"@api/core/create-identity-invitation-response":return Rs;case"@api/core/accept-join-request-request":return Ss;case"@api/core/accept-join-request-response":return Ms;case"@api/core/reject-join-request-request":return Cs;case"@api/core/reject-join-request-response":return Hs;case"@api/core/stop-pairing-request":return Ls;case"@api/core/stop-pairing-response":return Es;case"@api/core/update-profile-request":return zs;case"@api/core/want-identity":return Os;case"@api/core/unwant-identity":return Ns;case"@api/core/identity-status":return Us;case"@api/core/identity":return Gs;case"@api/core/identity-member":return Qs;case"@api/core/identity-device":return Xs;case"@api/debug/enable-request":return Zs;case"@api/debug/enable-response":return _s;case"@api/debug/disable-request":return dp;case"@api/debug/disable-response":return np;case"@keet/member-label-type":return rp;case"@keet/member-label":return tp;case"@keet/add-member-label-operation":return ap;case"@keet/member-label-summary":return sp;case"@keet/member-label-digest":return up;case"@keet/move-indexer-operation":return fp;case"@keet/location-shared-event":return mp;case"@keet/start-call":return bp;case"@keet/join-call":return Kp;case"@keet/leave-call":return hp;case"@keet/end-call":return Pp;case"@keet/add-call-stream":return Tp;case"@keet/remove-call-stream":return Sp;case"@keet/call-record":return Ip;case"@keet/call-member-record":return Mp;case"@keet/call-device-record":return Fp;case"@keet/call-stream-record":return qp;case"@local/active-call":return Cp;case"@local/file-gc-info":return Vp;case"@keet/build-type":return Dp;case"@keet/test-crash-operation":return jp;case"@keet/test-dispatch-error-operation":return Bp;case"@local/environment-record":return zp;case"@keet-private-id/shorten-device-attestation-operation":return Np;case"@local/ota-actions":return Up;case"@local/device-attestation":return Jp;case"@keet/call-device-heartbeat":return Gp;case"@keet/remove-call-device":return Xp;case"@local/chat-labels":return $p;case"@keet/start-call-recording":return eu;case"@keet/stop-call-recording":return ou;case"@local/settings":return nu;case"@local/hyperswarm-record":return cu;case"@keet/dismiss-chat-reports-operation":return tu;case"@keet/update-typing-indicator-operation":return au;case"@keet/typing-indicator":return su;case"@keet-private-id/update-contact-alias-operation":return uu;case"@keet/call-stats":return lu;case"@keet/call-stream-input":return fu;case"@keet/update-call-stream":return yu;case"@keet/call-stream-status-record":return xu;case"@keet/room-keys-v2":return bu;case"@keet/blob-pointer-v2":return vu;case"@keet/blob":return gu;case"@keet/autobee-migration":return Ku;case"@keet/autobee-migration-operation":return hu;case"@keet/readonly-room-invitation-v2":return wu;case"@keet/admin-last-seen":return Ru;case"@keet/blob-record":return Tu;case"@keet-private-id/room-v2":return Mu;case"@keet-private-id/add-room-operation-v2":return qu;case"@local/room-keys/v2":return Cu;case"@local/room-update":return Vu;case"@local/view-head":return Hu;case"@local/autobee-migration":return Du;case"@keet-private-id/pending-invitation-response":return Lu;case"@keet-private-id/resolve-pending-invitation-operation-v2":return Eu;case"@local/pending-recovery":return zu;default:throw new Error("Encoder not found "+e)}}function ml(e,o=15){const n=fl(e);return{preencode(e,c){d=o,n.preencode(e,c)},encode(e,c){d=o,n.encode(e,c)},decode:e=>(d=o,n.decode(e))}}const yl=ml;module.exports={resolveStruct:yl,getStruct:ml,getEnum:function(e){switch(e){case"@keet/room-type":return z;case"@keet/room-supported-language":return X;case"@keet/display-type":return Qo;case"@keet/system-settings-keys":return Tn;case"@keet/label-type":return Vn;case"@keet-private-id/user-settings-key":return ur;case"@local/tasks":return Cr;case"@local/keet-state":return Wt;case"@api/core/lobby-record-change-type":return ta;case"@keet/member-label-type":return cp;case"@keet/build-type":return Hp;default:throw new Error("Enum not found "+e)}},getEncoding:fl,encode:function(o,n,c=15){return d=c,e.encode(fl(o),n)},decode:function(o,n,c=15){return d=c,e.decode(fl(o),n)},setVersion:function(e){d=e},version:d};
1const{c:e}=require("hyperschema/runtime");let d=17;const o={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.length)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.length)},decode:d=>({key:e.fixed32.decode(d),length:e.uint.decode(d)})},n={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.seq)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.seq)},decode:d=>({key:e.fixed32.decode(d),seq:e.uint.decode(d)})},c={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.secretKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.secretKey)},decode:d=>({publicKey:e.fixed32.decode(d),secretKey:e.fixed32.decode(d)})},r={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed64.preencode(d,o.secretKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed64.encode(d,o.secretKey)},decode:d=>({publicKey:e.fixed32.decode(d),secretKey:e.fixed64.decode(d)})},t={preencode(n,c){e.fixed32.preencode(n,c.key),n.end++,c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),d>=13&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=(c.encryptionKey?1:0)|(c.fastForwardTo?2:0)|(d>=13&&c.bootFrom?4:0);e.fixed32.encode(n,c.key),e.uint.encode(n,r),c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),d>=13&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.uint.decode(n);return{key:c,encryptionKey:1&r?e.buffer.decode(n):null,fastForwardTo:2&r?e.fixed32.decode(n):null,bootFrom:d>=13&&4&r?o.decode(n):null}}},i={preencode(d,o){e.uint.preencode(d,o.timestamp)},encode(d,o){e.uint.encode(d,o.timestamp)},decode:d=>({timestamp:e.uint.decode(d)})},a={preencode(d,o){e.uint.preencode(d,o.blockOffset),e.uint.preencode(d,o.blockLength),e.uint.preencode(d,o.byteOffset),e.uint.preencode(d,o.byteLength)},encode(d,o){e.uint.encode(d,o.blockOffset),e.uint.encode(d,o.blockLength),e.uint.encode(d,o.byteOffset),e.uint.encode(d,o.byteLength)},decode:d=>({blockOffset:e.uint.decode(d),blockLength:e.uint.decode(d),byteOffset:e.uint.decode(d),byteLength:e.uint.decode(d)})},s={preencode(d,o){e.uint.preencode(d,o.width),e.uint.preencode(d,o.height)},encode(d,o){e.uint.encode(d,o.width),e.uint.encode(d,o.height)},decode:d=>({width:e.uint.decode(d),height:e.uint.decode(d)})},p=e.frame(s),u={preencode(d,o){d.end++,o.name&&e.string.preencode(d,o.name),o.mimetype&&e.string.preencode(d,o.mimetype),o.dimensions&&p.preencode(d,o.dimensions),o.userdata&&e.buffer.preencode(d,o.userdata),o.duration&&e.uint.preencode(d,o.duration)},encode(d,o){const n=(o.name?1:0)|(o.mimetype?2:0)|(o.dimensions?4:0)|(o.userdata?8:0)|(o.duration?16:0)|(o.isPreview?32:0);e.uint.encode(d,n),o.name&&e.string.encode(d,o.name),o.mimetype&&e.string.encode(d,o.mimetype),o.dimensions&&p.encode(d,o.dimensions),o.userdata&&e.buffer.encode(d,o.userdata),o.duration&&e.uint.encode(d,o.duration)},decode(d){const o=e.uint.decode(d);return{name:1&o?e.string.decode(d):null,mimetype:2&o?e.string.decode(d):null,dimensions:4&o?p.decode(d):null,userdata:8&o?e.buffer.decode(d):null,duration:16&o?e.uint.decode(d):0,isPreview:!!(32&o)}}},l={preencode(d,o){e.fixed32.preencode(d,o.key),e.string.preencode(d,o.path),e.uint.preencode(d,o.version),e.uint.preencode(d,o.size)},encode(d,o){e.fixed32.encode(d,o.key),e.string.encode(d,o.path),e.uint.encode(d,o.version),e.uint.encode(d,o.size)},decode:d=>({key:e.fixed32.decode(d),path:e.string.decode(d),version:e.uint.decode(d),size:e.uint.decode(d)})},f={preencode(d,o){e.fixed32.preencode(d,o.key),a.preencode(d,o.blob)},encode(d,o){e.fixed32.encode(d,o.key),a.encode(d,o.blob)},decode:d=>({key:e.fixed32.decode(d),blob:a.decode(d)})},m=e.frame(f),y=e.frame(l),x={preencode(o,n){o.end++,n.inlined&&e.buffer.preencode(o,n.inlined),n.blob&&a.preencode(o,n.blob),n.externalBlob&&m.preencode(o,n.externalBlob),n.externalDrive&&y.preencode(o,n.externalDrive),d>=13&&n.bee&&vu.preencode(o,n.bee)},encode(o,n){const c=(n.inlined?1:0)|(n.blob?2:0)|(n.externalBlob?4:0)|(n.externalDrive?8:0)|(d>=13&&n.bee?16:0);e.uint.encode(o,c),n.inlined&&e.buffer.encode(o,n.inlined),n.blob&&a.encode(o,n.blob),n.externalBlob&&m.encode(o,n.externalBlob),n.externalDrive&&y.encode(o,n.externalDrive),d>=13&&n.bee&&vu.encode(o,n.bee)},decode(o){const n=e.uint.decode(o);return{inlined:1&n?e.buffer.decode(o):null,blob:2&n?a.decode(o):null,externalBlob:4&n?m.decode(o):null,externalDrive:8&n?y.decode(o):null,bee:d>=13&&16&n?vu.decode(o):null}}},b=e.frame(x),v=e.frame(u),g={preencode(d,o){b.preencode(d,o.pointer),d.end++,o.metadata&&v.preencode(d,o.metadata),o.preview&&Zu.preencode(d,o.preview),o.hash&&e.fixed32.preencode(d,o.hash)},encode(d,o){const n=(o.metadata?1:0)|(o.preview?2:0)|(o.hash?4:0);b.encode(d,o.pointer),e.uint.encode(d,n),o.metadata&&v.encode(d,o.metadata),o.preview&&Zu.encode(d,o.preview),o.hash&&e.fixed32.encode(d,o.hash)},decode(d){const o=b.decode(d),n=e.uint.decode(d);return{pointer:o,metadata:1&n?v.decode(d):null,preview:2&n?Zu.decode(d):null,hash:4&n?e.fixed32.decode(d):null}}},k=e.frame(g),K=k,h=k,w={preencode(e,d){e.end++,d.small&&k.preencode(e,d.small),d.medium&&K.preencode(e,d.medium),d.large&&h.preencode(e,d.large)},encode(d,o){const n=(o.small?1:0)|(o.medium?2:0)|(o.large?4:0);e.uint.encode(d,n),o.small&&k.encode(d,o.small),o.medium&&K.encode(d,o.medium),o.large&&h.encode(d,o.large)},decode(d){const o=e.uint.decode(d);return{small:1&o?k.decode(d):null,medium:2&o?K.decode(d):null,large:4&o?h.decode(d):null}}},P={preencode(e,d){e.end++},encode(d,o){const n=o.isDeleted?1:0;e.uint.encode(d,n)},decode:d=>({isDeleted:!!(1&e.uint.decode(d))})},T=e.frame(P),R=k,A={preencode(d,o){e.uint.preencode(d,o.id),n.preencode(d,o.oplog),T.preencode(d,o.status),R.preencode(d,o.file),d.end++,o.version&&e.uint.preencode(d,o.version)},encode(d,o){const c=o.version?1:0;e.uint.encode(d,o.id),n.encode(d,o.oplog),T.encode(d,o.status),R.encode(d,o.file),e.uint.encode(d,c),o.version&&e.uint.encode(d,o.version)},decode:d=>({id:e.uint.decode(d),oplog:n.decode(d),status:T.decode(d),file:R.decode(d),version:1&e.uint.decode(d)?e.uint.decode(d):0})},S={preencode(e,d){e.end++},encode(d,o){const n=(o.isActive?1:0)|(o.isIndexing?2:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isActive:!!(1&o),isIndexing:!!(2&o)}}},I={preencode(d,o){const n=(o.isAdmin?1:0)|(o.isModerator?2:0)|(o.isPending?4:0)|(o.isActive?8:0)|(o.isMuted?16:0)|(o.isBanned?32:0)|(o.isShadowBanned?64:0)|(o.isRemoved?128:0);e.uint.preencode(d,n)},encode(d,o){const n=(o.isAdmin?1:0)|(o.isModerator?2:0)|(o.isPending?4:0)|(o.isActive?8:0)|(o.isMuted?16:0)|(o.isBanned?32:0)|(o.isShadowBanned?64:0)|(o.isRemoved?128:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isAdmin:!!(1&o),isModerator:!!(2&o),isPending:!!(4&o),isActive:!!(8&o),isMuted:!!(16&o),isBanned:!!(32&o),isShadowBanned:!!(64&o),isRemoved:!!(128&o)}}},M={preencode(e,d){e.end++},encode(d,o){const n=(o.isMuted?1:0)|(o.isBanned?2:0)|(o.isShadowBanned?4:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isMuted:!!(1&o),isBanned:!!(2&o),isShadowBanned:!!(4&o)}}},F={preencode(d,o){e.uint.preencode(d,o.version)},encode(d,o){e.uint.encode(d,o.version)},decode:d=>({version:e.uint.decode(d)})},q={preencode(d,o){e.uint.preencode(d,o.total),e.uint.preencode(d,o.active)},encode(d,o){e.uint.encode(d,o.total),e.uint.encode(d,o.active)},decode:d=>({total:e.uint.decode(d),active:e.uint.decode(d)})},C={preencode(d,o){e.uint.preencode(d,o.total),e.uint.preencode(d,o.active),e.uint.preencode(d,o.pending)},encode(d,o){e.uint.encode(d,o.total),e.uint.encode(d,o.active),e.uint.encode(d,o.pending)},decode:d=>({total:e.uint.decode(d),active:e.uint.decode(d),pending:e.uint.decode(d)})},V={preencode(d,o){e.uint.preencode(d,o.clock),e.uint.preencode(d,o.pinned),e.uint.preencode(d,o.threads),e.uint.preencode(d,o.timestamp),d.end++,o.flagsClock&&e.uint.preencode(d,o.flagsClock)},encode(d,o){const n=o.flagsClock?1:0;e.uint.encode(d,o.clock),e.uint.encode(d,o.pinned),e.uint.encode(d,o.threads),e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.flagsClock&&e.uint.encode(d,o.flagsClock)},decode:d=>({clock:e.uint.decode(d),pinned:e.uint.decode(d),threads:e.uint.decode(d),timestamp:e.uint.decode(d),flagsClock:1&e.uint.decode(d)?e.uint.decode(d):0})},H={preencode(d,o){e.uint.preencode(d,o.clock)},encode(d,o){e.uint.encode(d,o.clock)},decode:d=>({clock:e.uint.decode(d)})},D=e.frame(q),L=e.frame(C),j=e.frame(V),E=e.frame(H),B={preencode(e,o){D.preencode(e,o.devices),L.preencode(e,o.members),j.preencode(e,o.chat),E.preencode(e,o.files),e.end++,d>=12&&o.calls&&$u.preencode(e,o.calls)},encode(o,n){const c=d>=12&&n.calls?1:0;D.encode(o,n.devices),L.encode(o,n.members),j.encode(o,n.chat),E.encode(o,n.files),e.uint.encode(o,c),d>=12&&n.calls&&$u.encode(o,n.calls)},decode(o){const n=D.decode(o),c=L.decode(o),r=j.decode(o),t=E.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{devices:n,members:c,chat:r,files:t,calls:d>=12&&1&i?$u.decode(o):null}}},z={Default:1,Broadcast:2,DirectMessage:3},O={preencode(e,d){e.end++},encode(d,o){if(o>3)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},N={preencode(o,n){const c=(n.roomType?1:0)|(n.isExperimental?2:0)|(n.isJoiningDisabled?4:0)|(n.isAppendingDisabled?8:0)|(n.isCallingDisabled?16:0)|(n.isMembershipEventsDisabled?32:0)|(d>=4&&n.isAttachmentsDisabled?64:0)|(d>=4&&n.isLinksDisabled?128:0)|(d>=5&&n.buildType?256:0)|(d>=9&&n.isRoomInviteHidden?512:0);e.uint.preencode(o,c),n.roomType&&O.preencode(o,n.roomType),d>=5&&n.buildType&&Dp.preencode(o,n.buildType)},encode(o,n){const c=(n.roomType?1:0)|(n.isExperimental?2:0)|(n.isJoiningDisabled?4:0)|(n.isAppendingDisabled?8:0)|(n.isCallingDisabled?16:0)|(n.isMembershipEventsDisabled?32:0)|(d>=4&&n.isAttachmentsDisabled?64:0)|(d>=4&&n.isLinksDisabled?128:0)|(d>=5&&n.buildType?256:0)|(d>=9&&n.isRoomInviteHidden?512:0);e.uint.encode(o,c),n.roomType&&O.encode(o,n.roomType),d>=5&&n.buildType&&Dp.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{roomType:1&n?O.decode(o):0,isExperimental:!!(2&n),isJoiningDisabled:!!(4&n),isAppendingDisabled:!!(8&n),isCallingDisabled:!!(16&n),isMembershipEventsDisabled:!!(32&n),isAttachmentsDisabled:d>=4&&!!(64&n),isLinksDisabled:d>=4&&!!(128&n),buildType:d>=5&&256&n?Dp.decode(o):null,isRoomInviteHidden:d>=9&&!!(512&n)}}},U=e.frame(F),J=e.frame(N),W={preencode(d,o){U.preencode(d,o.abi),J.preencode(d,o.settings),e.uint.preencode(d,o.creationTime)},encode(d,o){U.encode(d,o.abi),J.encode(d,o.settings),e.uint.encode(d,o.creationTime)},decode:d=>({abi:U.decode(d),settings:J.decode(d),creationTime:e.uint.decode(d)})},G={preencode(d,o){e.fixed32.preencode(d,o.seed)},encode(d,o){e.fixed32.encode(d,o.seed)},decode:d=>({seed:e.fixed32.decode(d)})},Q={preencode(d,o){c.preencode(d,o.mailboxKeyPair),r.preencode(d,o.discoveryKeyPair),e.fixed32.preencode(d,o.wakeupTopic),e.fixed32.preencode(d,o.swarmTopic)},encode(d,o){c.encode(d,o.mailboxKeyPair),r.encode(d,o.discoveryKeyPair),e.fixed32.encode(d,o.wakeupTopic),e.fixed32.encode(d,o.swarmTopic)},decode:d=>({mailboxKeyPair:c.decode(d),discoveryKeyPair:r.decode(d),wakeupTopic:e.fixed32.decode(d),swarmTopic:e.fixed32.decode(d)})},X={en:"en",it:"it",ru:"ru",es:"es",de:"de"},Y={preencode(e,d){e.end++},encode(d,o){switch(o){case"en":e.uint.encode(d,1);break;case"it":e.uint.encode(d,2);break;case"ru":e.uint.encode(d,3);break;case"es":e.uint.encode(d,4);break;case"de":e.uint.encode(d,5);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"en";case 2:return"it";case 3:return"ru";case 4:return"es";case 5:return"de";default:return null}}},Z=e.array(Y),$=e.array(e.fixed32),_={preencode(d,o){d.end++,o.title&&e.string.preencode(d,o.title),o.avatar&&_u.preencode(d,o.avatar),o.description&&e.string.preencode(d,o.description),o.supportedLanguages&&Z.preencode(d,o.supportedLanguages),o.blindPeers&&$.preencode(d,o.blindPeers)},encode(d,o){const n=(o.title?1:0)|(o.avatar?2:0)|(o.description?4:0)|(o.supportedLanguages?8:0)|(o.blindPeers?16:0);e.uint.encode(d,n),o.title&&e.string.encode(d,o.title),o.avatar&&_u.encode(d,o.avatar),o.description&&e.string.encode(d,o.description),o.supportedLanguages&&Z.encode(d,o.supportedLanguages),o.blindPeers&&$.encode(d,o.blindPeers)},decode(d){const o=e.uint.decode(d);return{title:1&o?e.string.decode(d):null,avatar:2&o?_u.decode(d):null,description:4&o?e.string.decode(d):null,supportedLanguages:8&o?Z.decode(d):null,blindPeers:16&o?$.decode(d):null}}},ee={preencode(d,o){e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.key)},decode:d=>({key:e.fixed32.decode(d)})},de=e.frame(i),oe=e.frame(ee),ne={preencode(e,d){de.preencode(e,d.header),oe.preencode(e,d.peer)},encode(e,d){de.encode(e,d.header),oe.encode(e,d.peer)},decode:e=>({header:de.decode(e),peer:oe.decode(e)})},ce=de,re={preencode(d,o){ce.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){ce.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:ce.decode(d),key:e.fixed32.decode(d)})},te={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.buffer.preencode(d,o.proof)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.buffer.encode(d,o.proof)},decode:d=>({memberKey:e.fixed32.decode(d),proof:e.buffer.decode(d)})},ie={preencode(d,o){e.fixed32.preencode(d,o.id),e.buffer.preencode(d,o.response)},encode(d,o){e.fixed32.encode(d,o.id),e.buffer.encode(d,o.response)},decode:d=>({id:e.fixed32.decode(d),response:e.buffer.decode(d)})},ae=e.frame(S),se=e.frame(ie),pe={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.memberKey),ae.preencode(d,o.status),el.preencode(d,o.profile),d.end++,o.invitation&&se.preencode(d,o.invitation)},encode(d,o){const n=o.invitation?1:0;e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.memberKey),ae.encode(d,o.status),el.encode(d,o.profile),e.uint.encode(d,n),o.invitation&&se.encode(d,o.invitation)},decode:d=>({key:e.fixed32.decode(d),memberKey:e.fixed32.decode(d),status:ae.decode(d),profile:el.decode(d),invitation:1&e.uint.decode(d)?se.decode(d):null})},ue={preencode(d,o){e.uint.preencode(d,o.timestamp),d.end++,o.mailbox&&e.fixed32.preencode(d,o.mailbox),o.displayName&&e.string.preencode(d,o.displayName),o.avatar&&dl.preencode(d,o.avatar),o.username&&e.string.preencode(d,o.username)},encode(d,o){const n=(o.mailbox?1:0)|(o.displayName?2:0)|(o.avatar?4:0)|(o.username?8:0);e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.mailbox&&e.fixed32.encode(d,o.mailbox),o.displayName&&e.string.encode(d,o.displayName),o.avatar&&dl.encode(d,o.avatar),o.username&&e.string.encode(d,o.username)},decode(d){const o=e.uint.decode(d),n=e.uint.decode(d);return{timestamp:o,mailbox:1&n?e.fixed32.decode(d):null,displayName:2&n?e.string.decode(d):null,avatar:4&n?dl.decode(d):null,username:8&n?e.string.decode(d):null}}},le={preencode(o,n){o.end++,n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),n.name&&e.string.preencode(o,n.name),d>=5&&n.buildType&&Dp.preencode(o,n.buildType)},encode(o,n){const c=(n.swarmKey?1:0)|(n.name?2:0)|(n.isMobile?4:0)|(d>=5&&n.buildType?8:0);e.uint.encode(o,c),n.swarmKey&&e.fixed32.encode(o,n.swarmKey),n.name&&e.string.encode(o,n.name),d>=5&&n.buildType&&Dp.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{swarmKey:1&n?e.fixed32.decode(o):null,name:2&n?e.string.decode(o):null,isMobile:!!(4&n),buildType:d>=5&&8&n?Dp.decode(o):null}}},fe=e.frame(ue),me={preencode(e,d){fe.preencode(e,d.profile),te.preencode(e,d.attestation)},encode(e,d){fe.encode(e,d.profile),te.encode(e,d.attestation)},decode:e=>({profile:fe.decode(e),attestation:te.decode(e)})},ye={preencode(e,d){ol.preencode(e,d.profile),te.preencode(e,d.attestation)},encode(e,d){ol.encode(e,d.profile),te.encode(e,d.attestation)},decode:e=>({profile:ol.decode(e),attestation:te.decode(e)})},xe=fe,be={preencode(e,d){xe.preencode(e,d.profile),te.preencode(e,d.attestation)},encode(e,d){xe.encode(e,d.profile),te.encode(e,d.attestation)},decode:e=>({profile:xe.decode(e),attestation:te.decode(e)})},ve={preencode(d,o){e.fixed32.preencode(d,o.id),e.buffer.preencode(d,o.data),e.buffer.preencode(d,o.signature)},encode(d,o){e.fixed32.encode(d,o.id),e.buffer.encode(d,o.data),e.buffer.encode(d,o.signature)},decode:d=>({id:e.fixed32.decode(d),data:e.buffer.decode(d),signature:e.buffer.decode(d)})},ge={preencode(d,o){e.fixed32.preencode(d,o.devicePublicKey)},encode(d,o){e.fixed32.encode(d,o.devicePublicKey)},decode:d=>({devicePublicKey:e.fixed32.decode(d)})},ke={preencode(d,o){te.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){te.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({privateProfileIdentity:te.decode(d),deviceProof:e.buffer.decode(d)})},Ke={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),te.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){e.fixed32.encode(d,o.deviceKey),te.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({deviceKey:e.fixed32.decode(d),privateProfileIdentity:te.decode(d),deviceProof:e.buffer.decode(d)})},he=e.frame(ye),we=e.frame(me),Pe=e.frame(ge),Te={preencode(n,c){e.fixed32.preencode(n,c.deviceKey),r.preencode(n,c.keyPair),he.preencode(n,c.device),we.preencode(n,c.member),n.end++,c.identity&&Pe.preencode(n,c.identity),d>=13&&c.link&&o.preencode(n,c.link)},encode(n,c){const t=(c.identity?1:0)|(d>=13&&c.link?2:0);e.fixed32.encode(n,c.deviceKey),r.encode(n,c.keyPair),he.encode(n,c.device),we.encode(n,c.member),e.uint.encode(n,t),c.identity&&Pe.encode(n,c.identity),d>=13&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),t=r.decode(n),i=he.decode(n),a=we.decode(n),s=e.uint.decode(n);return{deviceKey:c,keyPair:t,device:i,member:a,identity:1&s?Pe.decode(n):null,link:d>=13&&2&s?o.decode(n):null}}},Re=e.frame(Te),Ae={preencode(d,o){e.fixed32.preencode(d,o.id),Re.preencode(d,o.request),e.buffer.preencode(d,o.signature)},encode(d,o){e.fixed32.encode(d,o.id),Re.encode(d,o.request),e.buffer.encode(d,o.signature)},decode:d=>({id:e.fixed32.decode(d),request:Re.decode(d),signature:e.buffer.decode(d)})},Se=he,Ie=we,Me={preencode(e,d){Se.preencode(e,d.device),e.end++,d.member&&Ie.preencode(e,d.member)},encode(d,o){const n=o.member?1:0;Se.encode(d,o.device),e.uint.encode(d,n),o.member&&Ie.encode(d,o.member)},decode:d=>({device:Se.decode(d),member:1&e.uint.decode(d)?Ie.decode(d):null})},Fe=e.frame(Ae),qe=e.frame(Me),Ce={preencode(e,d){e.end++,d.withInvitation&&Fe.preencode(e,d.withInvitation),d.withMemberProof&&qe.preencode(e,d.withMemberProof)},encode(d,o){const n=(o.withInvitation?1:0)|(o.withMemberProof?2:0);e.uint.encode(d,n),o.withInvitation&&Fe.encode(d,o.withInvitation),o.withMemberProof&&qe.encode(d,o.withMemberProof)},decode(d){const o=e.uint.decode(d);return{withInvitation:1&o?Fe.decode(d):null,withMemberProof:2&o?qe.decode(d):null}}},Ve=e.frame(ve),He=e.frame(ke),De={preencode(e,d){Ve.preencode(e,d.signedKeys),e.end++,d.identity&&He.preencode(e,d.identity)},encode(d,o){const n=o.identity?1:0;Ve.encode(d,o.signedKeys),e.uint.encode(d,n),o.identity&&He.encode(d,o.identity)},decode:d=>({signedKeys:Ve.decode(d),identity:1&e.uint.decode(d)?He.decode(d):null})},Le={preencode(o,n){o.end++,n.expiration&&e.uint.preencode(o,n.expiration),d>=5&&n.buildType&&Dp.preencode(o,n.buildType)},encode(o,n){const c=(n.expiration?1:0)|(n.requiresConfirmation?2:0)|(n.canModerate?4:0)|(n.canAdmin?8:0)|(d>=5&&n.buildType?16:0);e.uint.encode(o,c),n.expiration&&e.uint.encode(o,n.expiration),d>=5&&n.buildType&&Dp.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{expiration:1&n?e.uint.decode(o):0,requiresConfirmation:!!(2&n),canModerate:!!(4&n),canAdmin:!!(8&n),buildType:d>=5&&16&n?Dp.decode(o):null}}},je=Ve,Ee=e.frame(Le),Be={preencode(d,n){e.fixed32.preencode(d,n.id),je.preencode(d,n.response),Ee.preencode(d,n.metadata),d.end++,n.anchor&&o.preencode(d,n.anchor)},encode(d,n){const c=(n.anchor?1:0)|(n.isActive?2:0);e.fixed32.encode(d,n.id),je.encode(d,n.response),Ee.encode(d,n.metadata),e.uint.encode(d,c),n.anchor&&o.encode(d,n.anchor)},decode(d){const n=e.fixed32.decode(d),c=je.decode(d),r=Ee.decode(d),t=e.uint.decode(d);return{id:n,response:c,metadata:r,anchor:1&t?o.decode(d):null,isActive:!!(2&t)}}},ze=de,Oe=e.frame(Be),Ne={preencode(e,d){ze.preencode(e,d.header),Oe.preencode(e,d.invitation)},encode(e,d){ze.encode(e,d.header),Oe.encode(e,d.invitation)},decode:e=>({header:ze.decode(e),invitation:Oe.decode(e)})},Ue=de,Je={preencode(d,o){Ue.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){Ue.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:Ue.decode(d),id:e.fixed32.decode(d)})},We={preencode(d,n){e.fixed32.preencode(d,n.mailbox),e.fixed32.preencode(d,n.invitationSeed),o.preencode(d,n.anchor)},encode(d,n){e.fixed32.encode(d,n.mailbox),e.fixed32.encode(d,n.invitationSeed),o.encode(d,n.anchor)},decode:d=>({mailbox:e.fixed32.decode(d),invitationSeed:e.fixed32.decode(d),anchor:o.decode(d)})},Ge={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.fixed32.preencode(d,o.encryptionKey),e.fixed32.preencode(d,o.seed),d.end++,o.fastForwardTo&&e.fixed32.preencode(d,o.fastForwardTo)},encode(d,o){const n=o.fastForwardTo?1:0;e.fixed32.encode(d,o.roomKey),e.fixed32.encode(d,o.encryptionKey),e.fixed32.encode(d,o.seed),e.uint.encode(d,n),o.fastForwardTo&&e.fixed32.encode(d,o.fastForwardTo)},decode:d=>({roomKey:e.fixed32.decode(d),encryptionKey:e.fixed32.decode(d),seed:e.fixed32.decode(d),fastForwardTo:1&e.uint.decode(d)?e.fixed32.decode(d):null})},Qe={preencode(d,n){e.fixed32.preencode(d,n.mailbox),e.fixed32.preencode(d,n.invitationSeed),o.preencode(d,n.anchor),e.fixed32.preencode(d,n.identityPublicKey)},encode(d,n){e.fixed32.encode(d,n.mailbox),e.fixed32.encode(d,n.invitationSeed),o.encode(d,n.anchor),e.fixed32.encode(d,n.identityPublicKey)},decode:d=>({mailbox:e.fixed32.decode(d),invitationSeed:e.fixed32.decode(d),anchor:o.decode(d),identityPublicKey:e.fixed32.decode(d)})},Xe={preencode(d,o){e.fixed32.preencode(d,o.mailbox)},encode(d,o){e.fixed32.encode(d,o.mailbox)},decode:d=>({mailbox:e.fixed32.decode(d)})},Ye=e.frame(We),Ze=e.frame(Qe),$e=e.frame(Xe),_e=e.frame(Ge),ed=e.array(e.ipv4Address),dd={preencode(e,o){e.end++,o.room&&Ye.preencode(e,o.room),o.identity&&Ze.preencode(e,o.identity),o.contact&&$e.preencode(e,o.contact),o.readonly&&_e.preencode(e,o.readonly),o.additionalNodes&&ed.preencode(e,o.additionalNodes),d>=5&&o.buildType&&Dp.preencode(e,o.buildType),d>=13&&o["readonly-v2"]&&nl.preencode(e,o["readonly-v2"])},encode(o,n){const c=(n.room?1:0)|(n.identity?2:0)|(n.contact?4:0)|(n.readonly?8:0)|(n.additionalNodes?16:0)|(d>=5&&n.buildType?32:0)|(d>=13&&n["readonly-v2"]?64:0);e.uint.encode(o,c),n.room&&Ye.encode(o,n.room),n.identity&&Ze.encode(o,n.identity),n.contact&&$e.encode(o,n.contact),n.readonly&&_e.encode(o,n.readonly),n.additionalNodes&&ed.encode(o,n.additionalNodes),d>=5&&n.buildType&&Dp.encode(o,n.buildType),d>=13&&n["readonly-v2"]&&nl.encode(o,n["readonly-v2"])},decode(o){const n=e.uint.decode(o);return{room:1&n?Ye.decode(o):null,identity:2&n?Ze.decode(o):null,contact:4&n?$e.decode(o):null,readonly:8&n?_e.decode(o):null,additionalNodes:16&n?ed.decode(o):null,buildType:d>=5&&32&n?Dp.decode(o):null,"readonly-v2":d>=13&&64&n?nl.decode(o):null}}},od=de,nd={preencode(d,o){od.preencode(d,o.header),e.buffer.preencode(d,o.blindRequest)},encode(d,o){od.encode(d,o.header),e.buffer.encode(d,o.blindRequest)},decode:d=>({header:od.decode(d),blindRequest:e.buffer.decode(d)})},cd=de,rd={preencode(o,n){cd.preencode(o,n.header),o.end++,n.profile&&cl.preencode(o,n.profile),d>=10&&n.key&&e.fixed32.preencode(o,n.key)},encode(o,n){const c=(n.profile?1:0)|(d>=10&&n.key?2:0);cd.encode(o,n.header),e.uint.encode(o,c),n.profile&&cl.encode(o,n.profile),d>=10&&n.key&&e.fixed32.encode(o,n.key)},decode(o){const n=cd.decode(o),c=e.uint.decode(o);return{header:n,profile:1&c?cl.decode(o):null,key:d>=10&&2&c?e.fixed32.decode(o):null}}},td=de,id={preencode(d,o){td.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){td.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:td.decode(d),key:e.fixed32.decode(d)})},ad={preencode(e,d){},encode(e,d){},decode:e=>({})},sd=ad,pd=Re,ud={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.id),pd.preencode(d,o.request)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.id),pd.encode(d,o.request)},decode:d=>({deviceKey:e.fixed32.decode(d),id:e.fixed32.decode(d),request:pd.decode(d)})},ld=de,fd=He,md={preencode(d,o){ld.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),d.end++,o.identity&&fd.preencode(d,o.identity)},encode(d,o){const n=o.identity?1:0;ld.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,n),o.identity&&fd.encode(d,o.identity)},decode:d=>({header:ld.decode(d),deviceKey:e.fixed32.decode(d),identity:1&e.uint.decode(d)?fd.decode(d):null})},yd=de,xd={preencode(d,o){yd.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey)},encode(d,o){yd.encode(d,o.header),e.fixed32.encode(d,o.deviceKey)},decode:d=>({header:yd.decode(d),deviceKey:e.fixed32.decode(d)})},bd=e.frame(I),vd=fe,gd={preencode(d,o){e.fixed32.preencode(d,o.key),bd.preencode(d,o.status),vd.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),bd.encode(d,o.status),vd.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),status:bd.decode(d),profile:vd.decode(d)})},kd=bd,Kd=fe,hd={preencode(d,o){e.fixed32.preencode(d,o.key),kd.preencode(d,o.status),Kd.preencode(d,o.profile),d.end++,o.proofs&&rl.preencode(d,o.proofs)},encode(d,o){const n=o.proofs?1:0;e.fixed32.encode(d,o.key),kd.encode(d,o.status),Kd.encode(d,o.profile),e.uint.encode(d,n),o.proofs&&rl.encode(d,o.proofs)},decode:d=>({key:e.fixed32.decode(d),status:kd.decode(d),profile:Kd.decode(d),proofs:1&e.uint.decode(d)?rl.decode(d):null})},wd={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++,o.profileAttestation&&e.buffer.preencode(d,o.profileAttestation),o.latestReceipt&&e.buffer.preencode(d,o.latestReceipt)},encode(d,o){const n=(o.profileAttestation?1:0)|(o.latestReceipt?2:0);e.fixed32.encode(d,o.key),e.uint.encode(d,n),o.profileAttestation&&e.buffer.encode(d,o.profileAttestation),o.latestReceipt&&e.buffer.encode(d,o.latestReceipt)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d);return{key:o,profileAttestation:1&n?e.buffer.decode(d):null,latestReceipt:2&n?e.buffer.decode(d):null}}},Pd=de,Td=we,Rd={preencode(e,d){Pd.preencode(e,d.header),Td.preencode(e,d.member)},encode(e,d){Pd.encode(e,d.header),Td.encode(e,d.member)},decode:e=>({header:Pd.decode(e),member:Td.decode(e)})},Ad=de,Sd=e.frame(M),Id={preencode(d,o){Ad.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),Sd.preencode(d,o.status)},encode(d,o){Ad.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),Sd.encode(d,o.status)},decode:d=>({header:Ad.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:Sd.decode(d)})},Md=de,Fd={preencode(d,o){Md.preencode(d,o.header),e.fixed32.preencode(d,o.key),d.end++},encode(d,o){const n=(o.isModerator?1:0)|(o.isAdmin?2:0);Md.encode(d,o.header),e.fixed32.encode(d,o.key),e.uint.encode(d,n)},decode(d){const o=Md.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{header:o,key:n,isModerator:!!(1&c),isAdmin:!!(2&c)}}},qd=de,Cd={preencode(d,o){qd.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){qd.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:qd.decode(d),key:e.fixed32.decode(d)})},Vd={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.mentions)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.mentions)},decode:d=>({key:e.fixed32.decode(d),mentions:e.uint.decode(d)})},Hd={preencode(d,o){d.end++,o.memberKey&&e.fixed32.preencode(d,o.memberKey)},encode(d,o){const n=o.memberKey?1:0;e.uint.encode(d,n),o.memberKey&&e.fixed32.encode(d,o.memberKey)},decode:d=>({memberKey:1&e.uint.decode(d)?e.fixed32.decode(d):null})},Dd=Hd,Ld=Hd,jd={preencode(d,o){d.end++,o.from&&e.string.preencode(d,o.from),o.to&&e.string.preencode(d,o.to)},encode(d,o){const n=(o.from?1:0)|(o.to?2:0);e.uint.encode(d,n),o.from&&e.string.encode(d,o.from),o.to&&e.string.encode(d,o.to)},decode(d){const o=e.uint.decode(d);return{from:1&o?e.string.decode(d):null,to:2&o?e.string.decode(d):null}}},Ed=e.frame(Hd),Bd=e.frame(Dd),zd=e.frame(jd),Od=e.frame(Ld),Nd={preencode(o,n){const c=(n.memberJoined?1:0)|(n.memberLeft?2:0)|(n.titleChanged?4:0)|(n.callStarted?8:0)|(n.callHangup?16:0)|(n.callMissed?32:0)|(n.roomAvatarChanged?64:0)|(n.invitationCreated?128:0)|(n.memberRemoved?256:0)|(d>=3&&n.locationShared?512:0);e.uint.preencode(o,c),n.memberJoined&&Ed.preencode(o,n.memberJoined),n.memberLeft&&Bd.preencode(o,n.memberLeft),n.titleChanged&&zd.preencode(o,n.titleChanged),n.memberRemoved&&Od.preencode(o,n.memberRemoved),d>=3&&n.locationShared&&tl.preencode(o,n.locationShared)},encode(o,n){const c=(n.memberJoined?1:0)|(n.memberLeft?2:0)|(n.titleChanged?4:0)|(n.callStarted?8:0)|(n.callHangup?16:0)|(n.callMissed?32:0)|(n.roomAvatarChanged?64:0)|(n.invitationCreated?128:0)|(n.memberRemoved?256:0)|(d>=3&&n.locationShared?512:0);e.uint.encode(o,c),n.memberJoined&&Ed.encode(o,n.memberJoined),n.memberLeft&&Bd.encode(o,n.memberLeft),n.titleChanged&&zd.encode(o,n.titleChanged),n.memberRemoved&&Od.encode(o,n.memberRemoved),d>=3&&n.locationShared&&tl.encode(o,n.locationShared)},decode(o){const n=e.uint.decode(o);return{memberJoined:1&n?Ed.decode(o):null,memberLeft:2&n?Bd.decode(o):null,titleChanged:4&n?zd.decode(o):null,callStarted:!!(8&n),callHangup:!!(16&n),callMissed:!!(32&n),roomAvatarChanged:!!(64&n),invitationCreated:!!(128&n),memberRemoved:256&n?Od.decode(o):null,locationShared:d>=3&&512&n?tl.decode(o):null}}},Ud={preencode(e,o){e.end++,d>=3&&o.locationShared&&il.preencode(e,o.locationShared)},encode(o,n){const c=(n.callStarted?1:0)|(n.callHangup?2:0)|(n.callMissed?4:0)|(d>=3&&n.locationShared?8:0);e.uint.encode(o,c),d>=3&&n.locationShared&&il.encode(o,n.locationShared)},decode(o){const n=e.uint.decode(o);return{callStarted:!!(1&n),callHangup:!!(2&n),callMissed:!!(4&n),locationShared:d>=3&&8&n?il.decode(o):null}}},Jd={preencode(d,o){e.uint.preencode(d,o.start),e.uint.preencode(d,o.length)},encode(d,o){e.uint.encode(d,o.start),e.uint.encode(d,o.length)},decode:d=>({start:e.uint.decode(d),length:e.uint.decode(d)})},Wd=e.frame(Jd),Gd={preencode(d,o){Wd.preencode(d,o.range),e.string.preencode(d,o.content)},encode(d,o){Wd.encode(d,o.range),e.string.encode(d,o.content)},decode:d=>({range:Wd.decode(d),content:e.string.decode(d)})},Qd=Wd,Xd={preencode(d,o){Qd.preencode(d,o.range),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Qd.encode(d,o.range),e.fixed32.encode(d,o.memberKey)},decode:d=>({range:Qd.decode(d),memberKey:e.fixed32.decode(d)})},Yd=Wd,Zd={preencode(d,o){Yd.preencode(d,o.range),Y.preencode(d,o.language),e.string.preencode(d,o.text)},encode(d,o){Yd.encode(d,o.range),Y.encode(d,o.language),e.string.encode(d,o.text)},decode:d=>({range:Yd.decode(d),language:Y.decode(d),text:e.string.decode(d)})},$d=k,_d=e.array(e.uint),eo={preencode(d,o){d.end++,o.title&&e.string.preencode(d,o.title),o.description&&e.string.preencode(d,o.description),o.file&&$d.preencode(d,o.file),o.files&&_d.preencode(d,o.files)},encode(d,o){const n=(o.title?1:0)|(o.description?2:0)|(o.file?4:0)|(o.files?8:0);e.uint.encode(d,n),o.title&&e.string.encode(d,o.title),o.description&&e.string.encode(d,o.description),o.file&&$d.encode(d,o.file),o.files&&_d.encode(d,o.files)},decode(d){const o=e.uint.decode(d);return{title:1&o?e.string.decode(d):null,description:2&o?e.string.decode(d):null,file:4&o?$d.decode(d):null,files:8&o?_d.decode(d):null}}},oo=Wd,no=e.frame(eo),co={preencode(d,o){oo.preencode(d,o.range),e.string.preencode(d,o.url),d.end++,o.preview&&no.preencode(d,o.preview)},encode(d,o){const n=o.preview?1:0;oo.encode(d,o.range),e.string.encode(d,o.url),e.uint.encode(d,n),o.preview&&no.encode(d,o.preview)},decode:d=>({range:oo.decode(d),url:e.string.decode(d),preview:1&e.uint.decode(d)?no.decode(d):null})},ro=e.array(e.frame(Xd)),to=e.array(e.frame(co)),io=to,ao=e.array(e.frame(Jd)),so=ao,po=ao,uo=e.array(e.frame(Gd)),lo=ao,fo=ao,mo=e.array(e.frame(Zd)),yo={preencode(d,o){const n=(o.mention?1:0)|(o.httpLink?2:0)|(o.pearLink?4:0)|(o.bold?8:0)|(o.italic?16:0)|(o.code?32:0)|(o.emoji?64:0)|(o.codeBlock?128:0)|(o.strike?256:0)|(o.translation?512:0);e.uint.preencode(d,n),o.mention&&ro.preencode(d,o.mention),o.httpLink&&to.preencode(d,o.httpLink),o.pearLink&&io.preencode(d,o.pearLink),o.bold&&ao.preencode(d,o.bold),o.italic&&so.preencode(d,o.italic),o.code&&po.preencode(d,o.code),o.emoji&&uo.preencode(d,o.emoji),o.codeBlock&&lo.preencode(d,o.codeBlock),o.strike&&fo.preencode(d,o.strike),o.translation&&mo.preencode(d,o.translation)},encode(d,o){const n=(o.mention?1:0)|(o.httpLink?2:0)|(o.pearLink?4:0)|(o.bold?8:0)|(o.italic?16:0)|(o.code?32:0)|(o.emoji?64:0)|(o.codeBlock?128:0)|(o.strike?256:0)|(o.translation?512:0);e.uint.encode(d,n),o.mention&&ro.encode(d,o.mention),o.httpLink&&to.encode(d,o.httpLink),o.pearLink&&io.encode(d,o.pearLink),o.bold&&ao.encode(d,o.bold),o.italic&&so.encode(d,o.italic),o.code&&po.encode(d,o.code),o.emoji&&uo.encode(d,o.emoji),o.codeBlock&&lo.encode(d,o.codeBlock),o.strike&&fo.encode(d,o.strike),o.translation&&mo.encode(d,o.translation)},decode(d){const o=e.uint.decode(d);return{mention:1&o?ro.decode(d):null,httpLink:2&o?to.decode(d):null,pearLink:4&o?io.decode(d):null,bold:8&o?ao.decode(d):null,italic:16&o?so.decode(d):null,code:32&o?po.decode(d):null,emoji:64&o?uo.decode(d):null,codeBlock:128&o?lo.decode(d):null,strike:256&o?fo.decode(d):null,translation:512&o?mo.decode(d):null}}},xo=e.array(e.frame(g)),bo=e.frame(yo),vo=e.frame(Ud),go={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&xo.preencode(d,o.files),o.display&&bo.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent),o.event&&vo.preencode(d,o.event)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(c.event?32:0)|(d>=3&&c.forwarded?64:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&xo.encode(o,c.files),c.display&&bo.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent),c.event&&vo.encode(o,c.event)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?xo.decode(o):null,display:4&c?bo.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,event:32&c?vo.decode(o):null,forwarded:d>=3&&!!(64&c)}}},ko=_d,Ko=bo,ho={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&ko.preencode(d,o.files),o.display&&Ko.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(d>=3&&c.forwarded?32:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&ko.encode(o,c.files),c.display&&Ko.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?ko.decode(o):null,display:4&c?Ko.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,forwarded:d>=3&&!!(32&c)}}},wo=xo,Po=bo,To={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&wo.preencode(d,o.files),o.display&&Po.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(d>=3&&c.forwarded?32:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&wo.encode(o,c.files),c.display&&Po.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?wo.decode(o):null,display:4&c?Po.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,forwarded:d>=3&&!!(32&c)}}},Ro={preencode(e,d){e.end++},encode(d,o){const n=(o.isEdited?1:0)|(o.isDeleted?2:0)|(o.isPinned?4:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isEdited:!!(1&o),isDeleted:!!(2&o),isPinned:!!(4&o)}}},Ao={preencode(d,o){e.uint.preencode(d,o.thread),e.uint.preencode(d,o.index)},encode(d,o){e.uint.encode(d,o.thread),e.uint.encode(d,o.index)},decode:d=>({thread:e.uint.decode(d),index:e.uint.decode(d)})},So=e.frame(B),Io={preencode(d,o){e.uint.preencode(d,o.id),e.uint.preencode(d,o.count),d.end++,o.parent&&n.preencode(d,o.parent),o.stats&&So.preencode(d,o.stats)},encode(d,o){const c=(o.parent?1:0)|(o.stats?2:0);e.uint.encode(d,o.id),e.uint.encode(d,o.count),e.uint.encode(d,c),o.parent&&n.encode(d,o.parent),o.stats&&So.encode(d,o.stats)},decode(d){const o=e.uint.decode(d),c=e.uint.decode(d),r=e.uint.decode(d);return{id:o,count:c,parent:1&r?n.decode(d):null,stats:2&r?So.decode(d):null}}},Mo=e.frame(Ro),Fo=e.frame(ho),qo=e.frame(Nd),Co={preencode(d,o){Ao.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),Mo.preencode(d,o.status),o.message&&Fo.preencode(d,o.message),o.event&&qo.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);Ao.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),Mo.encode(d,o.status),o.message&&Fo.encode(d,o.message),o.event&&qo.encode(d,o.event)},decode(d){const o=Ao.decode(d),c=n.decode(d),r=e.uint.decode(d),t=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:r,timestamp:t,editedAt:1&i?e.uint.decode(d):0,status:Mo.decode(d),message:2&i?Fo.decode(d):null,event:4&i?qo.decode(d):null}}},Vo=Mo,Ho=e.frame(To),Do=qo,Lo={preencode(d,o){Ao.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),Vo.preencode(d,o.status),o.message&&Ho.preencode(d,o.message),o.event&&Do.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);Ao.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),Vo.encode(d,o.status),o.message&&Ho.encode(d,o.message),o.event&&Do.encode(d,o.event)},decode(d){const o=Ao.decode(d),c=n.decode(d),r=e.uint.decode(d),t=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:r,timestamp:t,editedAt:1&i?e.uint.decode(d):0,status:Vo.decode(d),message:2&i?Ho.decode(d):null,event:4&i?Do.decode(d):null}}},jo=de,Eo=e.frame(go),Bo={preencode(e,d){jo.preencode(e,d.header),Eo.preencode(e,d.message)},encode(e,d){jo.encode(e,d.header),Eo.encode(e,d.message)},decode:e=>({header:jo.decode(e),message:Eo.decode(e)})},zo=de,Oo={preencode(e,d){zo.preencode(e,d.header),n.preencode(e,d.oplog)},encode(e,d){zo.encode(e,d.header),n.encode(e,d.oplog)},decode:e=>({header:zo.decode(e),oplog:n.decode(e)})},No=de,Uo=Eo,Jo={preencode(e,d){No.preencode(e,d.header),n.preencode(e,d.oplog),Uo.preencode(e,d.message)},encode(e,d){No.encode(e,d.header),n.encode(e,d.oplog),Uo.encode(e,d.message)},decode:e=>({header:No.decode(e),oplog:n.decode(e),message:Uo.decode(e)})},Wo=de,Go={preencode(e,d){Wo.preencode(e,d.header),n.preencode(e,d.oplog),e.end++},encode(d,o){const c=o.isPinned?1:0;Wo.encode(d,o.header),n.encode(d,o.oplog),e.uint.encode(d,c)},decode:d=>({header:Wo.decode(d),oplog:n.decode(d),isPinned:!!(1&e.uint.decode(d))})},Qo={HttpLink:1,PearLink:2},Xo={preencode(e,d){e.end++},encode(d,o){if(o>2)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Yo=de,Zo={preencode(d,o){Yo.preencode(d,o.header),n.preencode(d,o.oplog),e.uint.preencode(d,o.index),al.preencode(d,o.preview),d.end++,o.displayType&&Xo.preencode(d,o.displayType)},encode(d,o){const c=o.displayType?1:0;Yo.encode(d,o.header),n.encode(d,o.oplog),e.uint.encode(d,o.index),al.encode(d,o.preview),e.uint.encode(d,c),o.displayType&&Xo.encode(d,o.displayType)},decode:d=>({header:Yo.decode(d),oplog:n.decode(d),index:e.uint.decode(d),preview:al.decode(d),displayType:1&e.uint.decode(d)?Xo.decode(d):0})},$o={preencode(d,o){Ao.preencode(d,o.id),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),e.string.preencode(d,o.reaction)},encode(d,o){Ao.encode(d,o.id),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),e.string.encode(d,o.reaction)},decode:d=>({id:Ao.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),reaction:e.string.decode(d)})},_o={preencode(d,o){e.string.preencode(d,o.text),e.uint.preencode(d,o.count)},encode(d,o){e.string.encode(d,o.text),e.uint.encode(d,o.count)},decode:d=>({text:e.string.decode(d),count:e.uint.decode(d)})},en=e.array(e.frame(_o)),dn={preencode(d,o){Ao.preencode(d,o.id),e.uint.preencode(d,o.total),en.preencode(d,o.reactions),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt)},encode(d,o){const n=o.editedAt?1:0;Ao.encode(d,o.id),e.uint.encode(d,o.total),en.encode(d,o.reactions),e.uint.encode(d,n),o.editedAt&&e.uint.encode(d,o.editedAt)},decode:d=>({id:Ao.decode(d),total:e.uint.decode(d),reactions:en.decode(d),editedAt:1&e.uint.decode(d)?e.uint.decode(d):0})},on=de,nn={preencode(d,o){on.preencode(d,o.header),n.preencode(d,o.oplog),e.string.preencode(d,o.reaction)},encode(d,o){on.encode(d,o.header),n.encode(d,o.oplog),e.string.encode(d,o.reaction)},decode:d=>({header:on.decode(d),oplog:n.decode(d),reaction:e.string.decode(d)})},cn=de,rn={preencode(d,o){cn.preencode(d,o.header),n.preencode(d,o.oplog),e.string.preencode(d,o.reaction)},encode(d,o){cn.encode(d,o.header),n.encode(d,o.oplog),e.string.encode(d,o.reaction)},decode:d=>({header:cn.decode(d),oplog:n.decode(d),reaction:e.string.decode(d)})},tn=de,an=e.frame(_),sn={preencode(d,o){tn.preencode(d,o.header),e.uint.preencode(d,o.key),an.preencode(d,o.config)},encode(d,o){tn.encode(d,o.header),e.uint.encode(d,o.key),an.encode(d,o.config)},decode:d=>({header:tn.decode(d),key:e.uint.decode(d),config:an.decode(d)})},pn={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.string.preencode(d,o.displayName),d.end++,o.avatar&&sl.preencode(d,o.avatar)},encode(d,o){const n=o.avatar?1:0;e.fixed32.encode(d,o.memberKey),e.string.encode(d,o.displayName),e.uint.encode(d,n),o.avatar&&sl.encode(d,o.avatar)},decode:d=>({memberKey:e.fixed32.decode(d),displayName:e.string.decode(d),avatar:1&e.uint.decode(d)?sl.decode(d):null})},un={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++,o.username&&e.string.preencode(d,o.username)},encode(d,o){const n=o.username?1:0;e.fixed32.encode(d,o.key),e.uint.encode(d,n),o.username&&e.string.encode(d,o.username)},decode:d=>({key:e.fixed32.decode(d),username:1&e.uint.decode(d)?e.string.decode(d):null})},ln=e.frame(un),fn={preencode(d,o){e.fixed32.preencode(d,o.publicKey),d.end++,o.discoveryCoreKey&&e.fixed32.preencode(d,o.discoveryCoreKey),o.userRegistry&&ln.preencode(d,o.userRegistry)},encode(d,o){const n=(o.discoveryCoreKey?1:0)|(o.userRegistry?2:0);e.fixed32.encode(d,o.publicKey),e.uint.encode(d,n),o.discoveryCoreKey&&e.fixed32.encode(d,o.discoveryCoreKey),o.userRegistry&&ln.encode(d,o.userRegistry)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d);return{publicKey:o,discoveryCoreKey:1&n?e.fixed32.decode(d):null,userRegistry:2&n?ln.decode(d):null}}},mn=de,yn=e.frame(W),xn=e.frame(G),bn=an,vn=e.frame(fn),gn=he,kn=e.array(e.frame(me)),Kn={preencode(e,d){mn.preencode(e,d.header),yn.preencode(e,d.digest),xn.preencode(e,d.capabilities),e.end++,d.config&&bn.preencode(e,d.config),d.identity&&vn.preencode(e,d.identity),d.bootstrapDevice&&gn.preencode(e,d.bootstrapDevice),d.initialMembers&&kn.preencode(e,d.initialMembers)},encode(d,o){const n=(o.config?1:0)|(o.identity?2:0)|(o.bootstrapDevice?4:0)|(o.initialMembers?8:0);mn.encode(d,o.header),yn.encode(d,o.digest),xn.encode(d,o.capabilities),e.uint.encode(d,n),o.config&&bn.encode(d,o.config),o.identity&&vn.encode(d,o.identity),o.bootstrapDevice&&gn.encode(d,o.bootstrapDevice),o.initialMembers&&kn.encode(d,o.initialMembers)},decode(d){const o=mn.decode(d),n=yn.decode(d),c=xn.decode(d),r=e.uint.decode(d);return{header:o,digest:n,capabilities:c,config:1&r?bn.decode(d):null,identity:2&r?vn.decode(d):null,bootstrapDevice:4&r?gn.decode(d):null,initialMembers:8&r?kn.decode(d):null}}},hn=de,wn={preencode(d,o){hn.preencode(d,o.header),e.uint.preencode(d,o.version)},encode(d,o){hn.encode(d,o.header),e.uint.encode(d,o.version)},decode:d=>({header:hn.decode(d),version:e.uint.decode(d)})},Pn=de,Tn={preencode(o,n){Pn.preencode(o,n.header),e.uint.preencode(o,n.from),e.uint.preencode(o,n.to),o.end++,d>=5&&n.buildType&&Dp.preencode(o,n.buildType)},encode(o,n){const c=d>=5&&n.buildType?1:0;Pn.encode(o,n.header),e.uint.encode(o,n.from),e.uint.encode(o,n.to),e.uint.encode(o,c),d>=5&&n.buildType&&Dp.encode(o,n.buildType)},decode(o){const n=Pn.decode(o),c=e.uint.decode(o),r=e.uint.decode(o),t=o.start<o.end?e.uint.decode(o):0;return{header:n,from:c,to:r,buildType:d>=5&&1&t?Dp.decode(o):null}}},Rn={RoomType:1,IsExperimental:2,IsJoiningDisabled:3,IsAppendingDisabled:4,IsCallingDisabled:5,IsMembershipEventsDisabled:6,IsAttachmentsDisabled:7,IsLinksDisabled:8,IsRoomInviteHidden:9},An={preencode(e,d){e.end++},encode(d,o){if(o>9)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Sn=de,In=J,Mn={preencode(d,o){Sn.preencode(d,o.header),e.uint.preencode(d,o.key),In.preencode(d,o.settings)},encode(d,o){Sn.encode(d,o.header),e.uint.encode(d,o.key),In.encode(d,o.settings)},decode:d=>({header:Sn.decode(d),key:e.uint.decode(d),settings:In.decode(d)})},Fn=de,qn={preencode(d,o){Fn.preencode(d,o.header),e.uint.preencode(d,o.value)},encode(d,o){Fn.encode(d,o.header),e.uint.encode(d,o.value)},decode:d=>({header:Fn.decode(d),value:e.uint.decode(d)})},Cn={preencode(d,o){e.uint.preencode(d,o.key),e.uint.preencode(d,o.value)},encode(d,o){e.uint.encode(d,o.key),e.uint.encode(d,o.value)},decode:d=>({key:e.uint.decode(d),value:e.uint.decode(d)})},Vn={Flag:1},Hn={preencode(e,d){e.end++},encode(d,o){if(o>1)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Dn={preencode(d,o){Ao.preencode(d,o.id),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),Hn.preencode(d,o.label)},encode(d,o){Ao.encode(d,o.id),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),Hn.encode(d,o.label)},decode:d=>({id:Ao.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),label:Hn.decode(d)})},Ln=de,jn={preencode(e,d){Ln.preencode(e,d.header),n.preencode(e,d.oplog),Hn.preencode(e,d.label)},encode(e,d){Ln.encode(e,d.header),n.encode(e,d.oplog),Hn.encode(e,d.label)},decode:e=>({header:Ln.decode(e),oplog:n.decode(e),label:Hn.decode(e)})},En=de,Bn={preencode(e,d){En.preencode(e,d.header),n.preencode(e,d.oplog),Hn.preencode(e,d.label)},encode(e,d){En.encode(e,d.header),n.encode(e,d.oplog),Hn.encode(e,d.label)},decode:e=>({header:En.decode(e),oplog:n.decode(e),label:Hn.decode(e)})},zn={preencode(d,o){Hn.preencode(d,o.label),e.uint.preencode(d,o.count)},encode(d,o){Hn.encode(d,o.label),e.uint.encode(d,o.count)},decode:d=>({label:Hn.decode(d),count:e.uint.decode(d)})},On=e.array(e.frame(zn)),Nn={preencode(d,o){Ao.preencode(d,o.id),e.uint.preencode(d,o.total),On.preencode(d,o.labels),e.uint.preencode(d,o.editedAt),d.end++,o.flagsClock&&e.uint.preencode(d,o.flagsClock),o.version&&e.uint.preencode(d,o.version)},encode(d,o){const n=(o.flagsClock?1:0)|(o.version?2:0)|(o.isDeleted?4:0);Ao.encode(d,o.id),e.uint.encode(d,o.total),On.encode(d,o.labels),e.uint.encode(d,o.editedAt),e.uint.encode(d,n),o.flagsClock&&e.uint.encode(d,o.flagsClock),o.version&&e.uint.encode(d,o.version)},decode(d){const o=Ao.decode(d),n=e.uint.decode(d),c=On.decode(d),r=e.uint.decode(d),t=e.uint.decode(d);return{id:o,total:n,labels:c,editedAt:r,flagsClock:1&t?e.uint.decode(d):0,version:2&t?e.uint.decode(d):0,isDeleted:!!(4&t)}}},Un=de,Jn={preencode(d,o){Un.preencode(d,o.header),e.uint.preencode(d,o.length)},encode(d,o){Un.encode(d,o.header),e.uint.encode(d,o.length)},decode:d=>({header:Un.decode(d),length:e.uint.decode(d)})},Wn={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.length)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.length)},decode:d=>({memberKey:e.fixed32.decode(d),length:e.uint.decode(d)})},Gn=ee,Qn=e.frame(be),Xn={preencode(o,n){e.fixed32.preencode(o,n.memberKey),pl.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=8&&n.contactInfo&&Qn.preencode(o,n.contactInfo),d>=8&&n.version&&e.uint.preencode(o,n.version),d>=10&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=8&&n.contactInfo?4:0)|(d>=8&&n.version?8:0)|(d>=10&&n.alias?16:0);e.fixed32.encode(o,n.memberKey),pl.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=8&&n.contactInfo&&Qn.encode(o,n.contactInfo),d>=8&&n.version&&e.uint.encode(o,n.version),d>=10&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.fixed32.decode(o),c=pl.decode(o),r=e.uint.decode(o);return{memberKey:n,status:c,mailbox:1&r?e.fixed32.decode(o):null,roomKey:2&r?e.fixed32.decode(o):null,contactInfo:d>=8&&4&r?Qn.decode(o):null,version:d>=8&&8&r?e.uint.decode(o):0,alias:d>=10&&16&r?e.string.decode(o):null}}},Yn={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.seed),o.preencode(d,n.initiator),e.fixed32.preencode(d,n.fastForwardTo)},encode(d,n){e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.fixed32.encode(d,n.seed),o.encode(d,n.initiator),e.fixed32.encode(d,n.fastForwardTo)},decode:d=>({roomKey:e.fixed32.decode(d),encryptionKey:e.buffer.decode(d),seed:e.fixed32.decode(d),initiator:o.decode(d),fastForwardTo:e.fixed32.decode(d)})},Zn=e.array(e.frame(Yn)),$n=$,_n={preencode(e,d){Zn.preencode(e,d.sharedRooms),$n.preencode(e,d.blockedContacts)},encode(e,d){Zn.encode(e,d.sharedRooms),$n.encode(e,d.blockedContacts)},decode:e=>({sharedRooms:Zn.decode(e),blockedContacts:$n.decode(e)})},ec=vn,dc={preencode(e,d){ec.preencode(e,d.identity)},encode(e,d){ec.encode(e,d.identity)},decode:e=>({identity:ec.decode(e)})},oc={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.contacts)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.contacts)},decode:d=>({rooms:e.uint.decode(d),contacts:e.uint.decode(d)})},nc={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.contactRequests)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.contactRequests)},decode:d=>({rooms:e.uint.decode(d),contactRequests:e.uint.decode(d)})},cc={preencode(d,o){e.buffer.preencode(d,o.entropy)},encode(d,o){e.buffer.encode(d,o.entropy)},decode:d=>({entropy:e.buffer.decode(d)})},rc={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.devicePublicKey),e.fixed32.preencode(d,o.writerKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.devicePublicKey),e.fixed32.encode(d,o.writerKey)},decode:d=>({publicKey:e.fixed32.decode(d),devicePublicKey:e.fixed32.decode(d),writerKey:e.fixed32.decode(d)})},tc=e.frame(rc),ic={preencode(n,c){e.fixed32.preencode(n,c.id),e.fixed32.preencode(n,c.invitationSeed),e.fixed32.preencode(n,c.mailbox),r.preencode(n,c.responseKeyPair),o.preencode(n,c.initiator),o.preencode(n,c.inviter),n.end++,c.identity&&tc.preencode(n,c.identity),d>=5&&c.buildType&&Dp.preencode(n,c.buildType),d>=13&&c.link&&o.preencode(n,c.link)},encode(n,c){const t=(c.identity?1:0)|(d>=5&&c.buildType?2:0)|(d>=13&&c.link?4:0);e.fixed32.encode(n,c.id),e.fixed32.encode(n,c.invitationSeed),e.fixed32.encode(n,c.mailbox),r.encode(n,c.responseKeyPair),o.encode(n,c.initiator),o.encode(n,c.inviter),e.uint.encode(n,t),c.identity&&tc.encode(n,c.identity),d>=5&&c.buildType&&Dp.encode(n,c.buildType),d>=13&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),t=e.fixed32.decode(n),i=e.fixed32.decode(n),a=r.decode(n),s=o.decode(n),p=o.decode(n),u=e.uint.decode(n);return{id:c,invitationSeed:t,mailbox:i,responseKeyPair:a,initiator:s,inviter:p,identity:1&u?tc.decode(n):null,buildType:d>=5&&2&u?Dp.decode(n):null,link:d>=13&&4&u?o.decode(n):null}}},ac=de,sc={preencode(d,o){ac.preencode(d,o.header),e.buffer.preencode(d,o.blindResponse)},encode(d,o){ac.encode(d,o.header),e.buffer.encode(d,o.blindResponse)},decode:d=>({header:ac.decode(d),blindResponse:e.buffer.decode(d)})},pc=de,uc=e.frame(ic),lc={preencode(e,d){pc.preencode(e,d.header),uc.preencode(e,d.invitation)},encode(e,d){pc.encode(e,d.header),uc.encode(e,d.invitation)},decode:e=>({header:pc.decode(e),invitation:uc.decode(e)})},fc=de,mc={preencode(d,o){fc.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){fc.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:fc.decode(d),id:e.fixed32.decode(d)})},yc={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.devicePublicKey),d.end++,o.privateProfileKey&&e.fixed32.preencode(d,o.privateProfileKey),o.deviceKeyPair&&r.preencode(d,o.deviceKeyPair),e.buffer.preencode(d,o.deviceProof)},encode(d,o){const n=(o.privateProfileKey?1:0)|(o.deviceKeyPair?2:0);e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.devicePublicKey),e.uint.encode(d,n),o.privateProfileKey&&e.fixed32.encode(d,o.privateProfileKey),o.deviceKeyPair&&r.encode(d,o.deviceKeyPair),e.buffer.encode(d,o.deviceProof)},decode(d){const o=e.fixed32.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{publicKey:o,devicePublicKey:n,privateProfileKey:1&c?e.fixed32.decode(d):null,deviceKeyPair:2&c?r.decode(d):null,deviceProof:e.buffer.decode(d)}}},xc={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.writerKey),e.fixed32.preencode(d,o.devicePublicKey),d.end++,o.privateProfileKey&&e.fixed32.preencode(d,o.privateProfileKey)},encode(d,o){const n=o.privateProfileKey?1:0;e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.writerKey),e.fixed32.encode(d,o.devicePublicKey),e.uint.encode(d,n),o.privateProfileKey&&e.fixed32.encode(d,o.privateProfileKey)},decode:d=>({publicKey:e.fixed32.decode(d),writerKey:e.fixed32.decode(d),devicePublicKey:e.fixed32.decode(d),privateProfileKey:1&e.uint.decode(d)?e.fixed32.decode(d):null})},bc={preencode(o,n){o.end++,d>=11&&n.roomSnoozeTime&&e.uint.preencode(o,n.roomSnoozeTime)},encode(o,n){const c=(n.isActive?1:0)|(n.isFullyMuted?2:0)|(n.isMentionsOnlyMuted?4:0)|(n.isReadOnly?8:0)|(d>=3&&n.isFavorite?16:0)|(d>=7&&n.isUnread?32:0)|(d>=11&&n.roomSnoozeTime?64:0);e.uint.encode(o,c),d>=11&&n.roomSnoozeTime&&e.uint.encode(o,n.roomSnoozeTime)},decode(o){const n=e.uint.decode(o);return{isActive:!!(1&n),isFullyMuted:!!(2&n),isMentionsOnlyMuted:!!(4&n),isReadOnly:!!(8&n),isFavorite:d>=3&&!!(16&n),isUnread:d>=7&&!!(32&n),roomSnoozeTime:d>=11&&64&n?e.uint.decode(o):0}}},vc=e.frame(bc),gc=e.frame(yc),kc=tc,Kc={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),vc.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,c.initiator&&o.preencode(n,c.initiator),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),c.identitySwap&&gc.preencode(n,c.identitySwap),c.identitySwapV2&&kc.preencode(n,c.identitySwapV2),c.contact&&e.fixed32.preencode(n,c.contact),d>=13&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=15&&c.activeClock&&e.uint.preencode(n,c.activeClock)},encode(n,c){const r=(c.initiator?1:0)|(c.fastForwardTo?2:0)|(c.identitySwap?4:0)|(c.identitySwapV2?8:0)|(c.contact?16:0)|(d>=13&&c.bootFrom?32:0)|(d>=15&&c.activeClock?64:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),vc.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,r),c.initiator&&o.encode(n,c.initiator),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),c.identitySwap&&gc.encode(n,c.identitySwap),c.identitySwapV2&&kc.encode(n,c.identitySwapV2),c.contact&&e.fixed32.encode(n,c.contact),d>=13&&c.bootFrom&&o.encode(n,c.bootFrom),d>=15&&c.activeClock&&e.uint.encode(n,c.activeClock)},decode(n){const c=e.fixed32.decode(n),r=e.buffer.decode(n),t=e.fixed32.decode(n),i=vc.decode(n),a=e.uint.decode(n),s=e.uint.decode(n);return{roomKey:c,encryptionKey:r,mailbox:t,status:i,clock:a,initiator:1&s?o.decode(n):null,fastForwardTo:2&s?e.fixed32.decode(n):null,identitySwap:4&s?gc.decode(n):null,identitySwapV2:8&s?kc.decode(n):null,contact:16&s?e.fixed32.decode(n):null,bootFrom:d>=13&&32&s?o.decode(n):null,activeClock:d>=15&&64&s?e.uint.decode(n):0}}},hc=de,wc={preencode(d,n){hc.preencode(d,n.header),e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.mailbox),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.dm&&e.fixed32.preencode(d,n.dm)},encode(d,n){const c=(n.fastForwardTo?1:0)|(n.initiator?2:0)|(n.dm?4:0)|(n.isReadOnly?8:0);hc.encode(d,n.header),e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.fixed32.encode(d,n.mailbox),e.uint.encode(d,c),n.fastForwardTo&&e.fixed32.encode(d,n.fastForwardTo),n.initiator&&o.encode(d,n.initiator),n.dm&&e.fixed32.encode(d,n.dm)},decode(d){const n=hc.decode(d),c=e.fixed32.decode(d),r=e.buffer.decode(d),t=e.fixed32.decode(d),i=e.uint.decode(d);return{header:n,roomKey:c,encryptionKey:r,mailbox:t,fastForwardTo:1&i?e.fixed32.decode(d):null,initiator:2&i?o.decode(d):null,dm:4&i?e.fixed32.decode(d):null,isReadOnly:!!(8&i)}}},Pc=de,Tc={preencode(d,o){Pc.preencode(d,o.header),e.fixed32.preencode(d,o.discoveryKey)},encode(d,o){Pc.encode(d,o.header),e.fixed32.encode(d,o.discoveryKey)},decode:d=>({header:Pc.decode(d),discoveryKey:e.fixed32.decode(d)})},Rc=de,Ac=vc,Sc={preencode(d,o){Rc.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.key),Ac.preencode(d,o.status)},encode(d,o){Rc.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.key),Ac.encode(d,o.status)},decode:d=>({header:Rc.decode(d),roomKey:e.fixed32.decode(d),key:e.uint.decode(d),status:Ac.decode(d)})},Ic={preencode(e,d){e.end++},encode(o,n){const c=(n.isBlocked?1:0)|(d>=8&&n.isActive?2:0);e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{isBlocked:!!(1&n),isActive:d>=8&&!!(2&n)}}},Mc=Qn,Fc={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.clock),ul.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=8&&n.contactInfo&&Mc.preencode(o,n.contactInfo),d>=10&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=8&&n.contactInfo?4:0)|(d>=10&&n.alias?8:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.clock),ul.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=8&&n.contactInfo&&Mc.encode(o,n.contactInfo),d>=10&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),r=ul.decode(o),t=e.uint.decode(o);return{memberKey:n,clock:c,status:r,mailbox:1&t?e.fixed32.decode(o):null,roomKey:2&t?e.fixed32.decode(o):null,contactInfo:d>=8&&4&t?Mc.decode(o):null,alias:d>=10&&8&t?e.string.decode(o):null}}},qc=de,Cc=e.frame(Xn),Vc={preencode(e,d){qc.preencode(e,d.header),Cc.preencode(e,d.contact)},encode(e,d){qc.encode(e,d.header),Cc.encode(e,d.contact)},decode:e=>({header:qc.decode(e),contact:Cc.decode(e)})},Hc=de,Dc={preencode(d,o){Hc.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),ll.preencode(d,o.status)},encode(d,o){Hc.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),ll.encode(d,o.status)},decode:d=>({header:Hc.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:ll.decode(d)})},Lc=de,jc={preencode(d,o){Lc.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Lc.encode(d,o.header),e.fixed32.encode(d,o.memberKey)},decode:d=>({header:Lc.decode(d),memberKey:e.fixed32.decode(d)})},Ec=de,Bc={preencode(d,o){Ec.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Ec.encode(d,o.header),e.fixed32.encode(d,o.memberKey)},decode:d=>({header:Ec.decode(d),memberKey:e.fixed32.decode(d)})},zc={preencode(e,d){e.end++},encode(d,o){const n=(o.isPending?1:0)|(o.isAccepted?2:0)|(o.isRejected?4:0)|(o.isDiscarded?8:0)|(o.isSeen?16:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isPending:!!(1&o),isAccepted:!!(2&o),isRejected:!!(4&o),isDiscarded:!!(8&o),isSeen:!!(16&o)}}},Oc=we,Nc=e.frame(t),Uc={preencode(d,o){Oc.preencode(d,o.sender),Nc.preencode(d,o.keys),e.fixed32.preencode(d,o.mailbox),d.end++,o.message&&e.string.preencode(d,o.message)},encode(d,o){const n=o.message?1:0;Oc.encode(d,o.sender),Nc.encode(d,o.keys),e.fixed32.encode(d,o.mailbox),e.uint.encode(d,n),o.message&&e.string.encode(d,o.message)},decode:d=>({sender:Oc.decode(d),keys:Nc.decode(d),mailbox:e.fixed32.decode(d),message:1&e.uint.decode(d)?e.string.decode(d):null})},Jc=e.frame(Uc),Wc={preencode(o,n){Jc.preencode(o,n.body),te.preencode(o,n.attestation),o.end++,d>=17&&n.recipientProof&&e.buffer.preencode(o,n.recipientProof)},encode(o,n){const c=d>=17&&n.recipientProof?1:0;Jc.encode(o,n.body),te.encode(o,n.attestation),e.uint.encode(o,c),d>=17&&n.recipientProof&&e.buffer.encode(o,n.recipientProof)},decode(o){const n=Jc.decode(o),c=te.decode(o),r=o.start<o.end?e.uint.decode(o):0;return{body:n,attestation:c,recipientProof:d>=17&&1&r?e.buffer.decode(o):null}}},Gc=fe,Qc=e.frame(zc),Xc=Nc,Yc=Qn,Zc={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.clock),Gc.preencode(o,n.sender),Qc.preencode(o,n.status),Xc.preencode(o,n.keys),e.fixed32.preencode(o,n.mailbox),o.end++,n.message&&e.string.preencode(o,n.message),n.sentAt&&e.uint.preencode(o,n.sentAt),d>=8&&n.contactInfo&&Yc.preencode(o,n.contactInfo)},encode(o,n){const c=(n.message?1:0)|(n.sentAt?2:0)|(d>=8&&n.contactInfo?4:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.clock),Gc.encode(o,n.sender),Qc.encode(o,n.status),Xc.encode(o,n.keys),e.fixed32.encode(o,n.mailbox),e.uint.encode(o,c),n.message&&e.string.encode(o,n.message),n.sentAt&&e.uint.encode(o,n.sentAt),d>=8&&n.contactInfo&&Yc.encode(o,n.contactInfo)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),r=Gc.decode(o),t=Qc.decode(o),i=Xc.decode(o),a=e.fixed32.decode(o),s=e.uint.decode(o);return{memberKey:n,clock:c,sender:r,status:t,keys:i,mailbox:a,message:1&s?e.string.decode(o):null,sentAt:2&s?e.uint.decode(o):0,contactInfo:d>=8&&4&s?Yc.decode(o):null}}},$c=de,_c={preencode(d,o){$c.preencode(d,o.header),e.buffer.preencode(d,o.blindRequest)},encode(d,o){$c.encode(d,o.header),e.buffer.encode(d,o.blindRequest)},decode:d=>({header:$c.decode(d),blindRequest:e.buffer.decode(d)})},er=de,dr=Qc,or={preencode(d,o){er.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),dr.preencode(d,o.status),d.end++,o.roomKey&&e.fixed32.preencode(d,o.roomKey)},encode(d,o){const n=o.roomKey?1:0;er.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),dr.encode(d,o.status),e.uint.encode(d,n),o.roomKey&&e.fixed32.encode(d,o.roomKey)},decode:d=>({header:er.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:dr.decode(d),roomKey:1&e.uint.decode(d)?e.fixed32.decode(d):null})},nr={preencode(d,o){e.uint.preencode(d,o.timestamp),e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.mailbox)},encode(d,o){e.uint.encode(d,o.timestamp),e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.mailbox)},decode:d=>({version:0,timestamp:e.uint.decode(d),key:e.fixed32.decode(d),mailbox:e.fixed32.decode(d)})},cr={preencode(d,o){const n=o.version??1;switch(e.uint.preencode(d,n),n){case 0:case 1:nr.preencode(d,o);break;default:throw new Error("Unsupported version")}},encode(d,o){const n=o.version??1;switch(e.uint.encode(d,n),n){case 0:case 1:nr.encode(d,o);break;default:throw new Error("Unsupported version")}},decode(d){const o=e.uint.decode(d);switch(o){case 0:case 1:{const e=nr.decode(d);return e.version=o,e}default:throw new Error("Unsupported version")}}},rr={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.key)},decode:d=>({deviceKey:e.fixed32.decode(d),key:e.fixed32.decode(d)})},tr=de,ir={preencode(d,o){tr.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){tr.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:tr.decode(d),key:e.fixed32.decode(d)})},ar=de,sr={preencode(d,o){ar.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){ar.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:ar.decode(d),key:e.fixed32.decode(d)})},pr={preencode(o,n){o.end++,d>=9&&n.profileSnoozeTime&&e.uint.preencode(o,n.profileSnoozeTime)},encode(o,n){const c=(n.disableReadReceipts?1:0)|(d>=7&&n.stripAttachmentMetadata?2:0)|(d>=9&&n.profileSnoozeTime?4:0);e.uint.encode(o,c),d>=9&&n.profileSnoozeTime&&e.uint.encode(o,n.profileSnoozeTime)},decode(o){const n=e.uint.decode(o);return{disableReadReceipts:!!(1&n),stripAttachmentMetadata:d>=7&&!!(2&n),profileSnoozeTime:d>=9&&4&n?e.uint.decode(o):0}}},ur={disableReadReceipts:"disableReadReceipts",stripAttachmentMetadata:"stripAttachmentMetadata",profileSnoozeTime:"profileSnoozeTime"},lr={preencode(e,d){e.end++},encode(d,o){switch(o){case"disableReadReceipts":e.uint.encode(d,1);break;case"stripAttachmentMetadata":e.uint.encode(d,2);break;case"profileSnoozeTime":e.uint.encode(d,3);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"disableReadReceipts";case 2:return"stripAttachmentMetadata";case 3:return"profileSnoozeTime";default:return null}}},fr=de,mr=e.frame(pr),yr={preencode(e,d){fr.preencode(e,d.header),lr.preencode(e,d.key),mr.preencode(e,d.settings)},encode(e,d){fr.encode(e,d.header),lr.encode(e,d.key),mr.encode(e,d.settings)},decode:e=>({header:fr.decode(e),key:lr.decode(e),settings:mr.decode(e)})},xr={preencode(d,o){e.fixed32.preencode(d,o.discoveryPublicKey),e.uint.preencode(d,o.timestamp),d.end++,o.lastSynced&&e.uint.preencode(d,o.lastSynced)},encode(d,o){const n=(o.lastSynced?1:0)|(o.dirty?2:0);e.fixed32.encode(d,o.discoveryPublicKey),e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.lastSynced&&e.uint.encode(d,o.lastSynced)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d),c=e.uint.decode(d);return{discoveryPublicKey:o,timestamp:n,lastSynced:1&c?e.uint.decode(d):0,dirty:!!(2&c)}}},br={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.activeRooms)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.activeRooms)},decode:d=>({rooms:e.uint.decode(d),activeRooms:e.uint.decode(d)})},vr=F,gr=$,kr={preencode(e,d){e.end++,d.blockedMembers&&gr.preencode(e,d.blockedMembers)},encode(d,o){const n=o.blockedMembers?1:0;e.uint.encode(d,n),o.blockedMembers&&gr.encode(d,o.blockedMembers)},decode:d=>({blockedMembers:1&e.uint.decode(d)?gr.decode(d):null})},Kr=e.frame(Q),hr=e.frame(kr),wr={preencode(d,n){e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.seed),Kr.preencode(d,n.capabilities),o.preencode(d,n.initiator),e.fixed32.preencode(d,n.fastForwardTo),d.end++,n.privateProfile&&hr.preencode(d,n.privateProfile)},encode(d,n){const c=n.privateProfile?1:0;e.buffer.encode(d,n.encryptionKey),e.fixed32.encode(d,n.seed),Kr.encode(d,n.capabilities),o.encode(d,n.initiator),e.fixed32.encode(d,n.fastForwardTo),e.uint.encode(d,c),n.privateProfile&&hr.encode(d,n.privateProfile)},decode:d=>({encryptionKey:e.buffer.decode(d),seed:e.fixed32.decode(d),capabilities:Kr.decode(d),initiator:o.decode(d),fastForwardTo:e.fixed32.decode(d),privateProfile:1&e.uint.decode(d)?hr.decode(d):null})},Pr={preencode(d,o){d.end++,o.count&&e.uint.preencode(d,o.count)},encode(d,o){const n=o.count?1:0;e.uint.encode(d,n),o.count&&e.uint.encode(d,o.count)},decode:d=>({count:1&e.uint.decode(d)?e.uint.decode(d):0})},Tr=e.frame(wr),Rr={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.priority),d.end++,o.v3&&Tr.preencode(d,o.v3),o.timestamp&&e.uint.preencode(d,o.timestamp)},encode(d,o){const n=(o.v3?1:0)|(o.errored?2:0)|(o.timestamp?4:0);e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.priority),e.uint.encode(d,n),o.v3&&Tr.encode(d,o.v3),o.timestamp&&e.uint.encode(d,o.timestamp)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d),c=e.uint.decode(d);return{roomKey:o,priority:n,v3:1&c?Tr.decode(d):null,errored:!!(2&c),timestamp:4&c?e.uint.decode(d):0}}},Ar={preencode(e,d){e.end++},encode(d,o){const n=o.isConfirmed?1:0;e.uint.encode(d,n)},decode:d=>({isConfirmed:!!(1&e.uint.decode(d))})},Sr={preencode(d,o){e.fixed32.preencode(d,o.privateProfileKey)},encode(d,o){e.fixed32.encode(d,o.privateProfileKey)},decode:d=>({privateProfileKey:e.fixed32.decode(d)})},Ir=e.frame(Ar),Mr=gc,Fr=e.frame(xc),qr={preencode(o,n){e.fixed32.preencode(o,n.publicKey),e.fixed32.preencode(o,n.privateProfileKey),r.preencode(o,n.deviceKeyPair),e.buffer.preencode(o,n.deviceProof),Ir.preencode(o,n.status),o.end++,n.entropy&&e.buffer.preencode(o,n.entropy),n.swap&&Mr.preencode(o,n.swap),n.swapV2&&Fr.preencode(o,n.swapV2),d>=7&&n.proofShortenedAt&&e.uint.preencode(o,n.proofShortenedAt)},encode(o,n){const c=(n.entropy?1:0)|(n.swap?2:0)|(n.swapV2?4:0)|(d>=7&&n.proofShortenedAt?8:0);e.fixed32.encode(o,n.publicKey),e.fixed32.encode(o,n.privateProfileKey),r.encode(o,n.deviceKeyPair),e.buffer.encode(o,n.deviceProof),Ir.encode(o,n.status),e.uint.encode(o,c),n.entropy&&e.buffer.encode(o,n.entropy),n.swap&&Mr.encode(o,n.swap),n.swapV2&&Fr.encode(o,n.swapV2),d>=7&&n.proofShortenedAt&&e.uint.encode(o,n.proofShortenedAt)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=r.decode(o),i=e.buffer.decode(o),a=Ir.decode(o),s=e.uint.decode(o);return{publicKey:n,privateProfileKey:c,deviceKeyPair:t,deviceProof:i,status:a,entropy:1&s?e.buffer.decode(o):null,swap:2&s?Mr.decode(o):null,swapV2:4&s?Fr.decode(o):null,proofShortenedAt:d>=7&&8&s?e.uint.decode(o):0}}},Cr={RestoreIdentity:1,CreateRoom:2,LeaveRoom:3,ClearRoom:4,JoinRoomInvitation:5,JoinRoomKeys:6,JoinRoomResponse:7,SendContactRequest:8,TestFastTask:9,TestSlowTask:10,TestErrorTask:11},Vr={preencode(e,d){e.end++},encode(d,o){if(o>11)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Hr={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator)},encode(d,n){const c=(n.fastForwardTo?1:0)|(n.initiator?2:0);e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.uint.encode(d,c),n.fastForwardTo&&e.fixed32.encode(d,n.fastForwardTo),n.initiator&&o.encode(d,n.initiator)},decode(d){const n=e.fixed32.decode(d),c=e.buffer.decode(d),r=e.uint.decode(d);return{roomKey:n,encryptionKey:c,fastForwardTo:1&r?e.fixed32.decode(d):null,initiator:2&r?o.decode(d):null}}},Dr=uc,Lr={preencode(e,d){Dr.preencode(e,d.invitation)},encode(e,d){Dr.encode(e,d.invitation)},decode:e=>({invitation:Dr.decode(e)})},jr={preencode(d,o){e.fixed32.preencode(d,o.mailbox),r.preencode(d,o.keyPair),e.buffer.preencode(d,o.response)},encode(d,o){e.fixed32.encode(d,o.mailbox),r.encode(d,o.keyPair),e.buffer.encode(d,o.response)},decode:d=>({mailbox:e.fixed32.decode(d),keyPair:r.decode(d),response:e.buffer.decode(d)})},Er=ee,Br={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.mailbox&&e.fixed32.preencode(d,n.mailbox)},encode(d,n){const c=(n.fastForwardTo?1:0)|(n.initiator?2:0)|(n.mailbox?4:0);e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.uint.encode(d,c),n.fastForwardTo&&e.fixed32.encode(d,n.fastForwardTo),n.initiator&&o.encode(d,n.initiator),n.mailbox&&e.fixed32.encode(d,n.mailbox)},decode(d){const n=e.fixed32.decode(d),c=e.buffer.decode(d),r=e.uint.decode(d);return{roomKey:n,encryptionKey:c,fastForwardTo:1&r?e.fixed32.decode(d):null,initiator:2&r?o.decode(d):null,mailbox:4&r?e.fixed32.decode(d):null}}},zr=e.frame(Br),Or={preencode(o,n){zr.preencode(o,n.keys),o.end++,d>=15&&n.activeClock&&e.uint.preencode(o,n.activeClock)},encode(o,n){const c=(d>=15&&n.activeClock?1:0)|(d>=15&&n.isReadOnly?2:0);zr.encode(o,n.keys),e.uint.encode(o,c),d>=15&&n.activeClock&&e.uint.encode(o,n.activeClock)},decode(o){const n=zr.decode(o),c=o.start<o.end?e.uint.decode(o):0;return{keys:n,activeClock:d>=15&&1&c?e.uint.decode(o):0,isReadOnly:d>=15&&!!(2&c)}}},Nr=e.frame(Kn),Ur={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.mailbox&&e.fixed32.preencode(d,n.mailbox),n.keyPair&&r.preencode(d,n.keyPair),n.genesis&&Nr.preencode(d,n.genesis)},encode(d,n){const c=(n.fastForwardTo?1:0)|(n.initiator?2:0)|(n.mailbox?4:0)|(n.keyPair?8:0)|(n.genesis?16:0)|(n.isPrivateProfile?32:0);e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.uint.encode(d,c),n.fastForwardTo&&e.fixed32.encode(d,n.fastForwardTo),n.initiator&&o.encode(d,n.initiator),n.mailbox&&e.fixed32.encode(d,n.mailbox),n.keyPair&&r.encode(d,n.keyPair),n.genesis&&Nr.encode(d,n.genesis)},decode(d){const n=e.fixed32.decode(d),c=e.buffer.decode(d),t=e.uint.decode(d);return{roomKey:n,encryptionKey:c,fastForwardTo:1&t?e.fixed32.decode(d):null,initiator:2&t?o.decode(d):null,mailbox:4&t?e.fixed32.decode(d):null,keyPair:8&t?r.decode(d):null,genesis:16&t?Nr.decode(d):null,isPrivateProfile:!!(32&t)}}},Jr={preencode(d,o){e.fixed32.preencode(d,o.roomKey),d.end++},encode(d,o){const n=o.isGossiped?1:0;e.fixed32.encode(d,o.roomKey),e.uint.encode(d,n)},decode:d=>({roomKey:e.fixed32.decode(d),isGossiped:!!(1&e.uint.decode(d))})},Wr={preencode(d,o){e.fixed32.preencode(d,o.roomKey)},encode(d,o){e.fixed32.encode(d,o.roomKey)},decode:d=>({roomKey:e.fixed32.decode(d)})},Gr={preencode(d,o){e.string.preencode(d,o.mnemonic),d.end++,o.profileDiscoveryTimeout&&e.uint.preencode(d,o.profileDiscoveryTimeout)},encode(d,o){const n=(o.profileDiscoveryTimeout?1:0)|(o.recover?2:0);e.string.encode(d,o.mnemonic),e.uint.encode(d,n),o.profileDiscoveryTimeout&&e.uint.encode(d,o.profileDiscoveryTimeout)},decode(d){const o=e.string.decode(d),n=e.uint.decode(d);return{mnemonic:o,profileDiscoveryTimeout:1&n?e.uint.decode(d):0,recover:!!(2&n)}}},Qr=Qn,Xr={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.fixed32.preencode(d,o.memberKey),d.end++,o.message&&e.string.preencode(d,o.message),o.contactInfo&&Qr.preencode(d,o.contactInfo)},encode(d,o){const n=(o.message?1:0)|(o.contactInfo?2:0);e.fixed32.encode(d,o.roomKey),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,n),o.message&&e.string.encode(d,o.message),o.contactInfo&&Qr.encode(d,o.contactInfo)},decode(d){const o=e.fixed32.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{roomKey:o,memberKey:n,message:1&c?e.string.decode(d):null,contactInfo:2&c?Qr.decode(d):null}}},Yr={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++},encode(d,o){const n=o.isPrivateProfile?1:0;e.fixed32.encode(d,o.key),e.uint.encode(d,n)},decode:d=>({key:e.fixed32.decode(d),isPrivateProfile:!!(1&e.uint.decode(d))})},Zr=e.frame(Gr),$r=e.frame(Ur),_r=e.frame(Jr),et=e.frame(Wr),dt=e.frame(Lr),ot=e.frame(Or),nt=e.frame(jr),ct=e.frame(Xr),rt=e.frame(Yr),tt={preencode(d,o){const n=(o.restoreIdentity?1:0)|(o.createRoom?2:0)|(o.leaveRoom?4:0)|(o.clearRoom?8:0)|(o.joinRoomInvitation?16:0)|(o.joinRoomKeys?32:0)|(o.joinRoomResponse?64:0)|(o.sendContactRequest?128:0)|(o.migrateV2Room?256:0);e.fixed32.preencode(d,o.discoveryKey),e.uint.preencode(d,o.priority),e.uint.preencode(d,o.timestamp),e.uint.preencode(d,o.type),e.uint.preencode(d,n),o.restoreIdentity&&Zr.preencode(d,o.restoreIdentity),o.createRoom&&$r.preencode(d,o.createRoom),o.leaveRoom&&_r.preencode(d,o.leaveRoom),o.clearRoom&&et.preencode(d,o.clearRoom),o.joinRoomInvitation&&dt.preencode(d,o.joinRoomInvitation),o.joinRoomKeys&&ot.preencode(d,o.joinRoomKeys),o.joinRoomResponse&&nt.preencode(d,o.joinRoomResponse),o.sendContactRequest&&ct.preencode(d,o.sendContactRequest),o.migrateV2Room&&rt.preencode(d,o.migrateV2Room)},encode(d,o){const n=(o.restoreIdentity?1:0)|(o.createRoom?2:0)|(o.leaveRoom?4:0)|(o.clearRoom?8:0)|(o.joinRoomInvitation?16:0)|(o.joinRoomKeys?32:0)|(o.joinRoomResponse?64:0)|(o.sendContactRequest?128:0)|(o.migrateV2Room?256:0);e.fixed32.encode(d,o.discoveryKey),e.uint.encode(d,o.priority),e.uint.encode(d,o.timestamp),e.uint.encode(d,o.type),e.uint.encode(d,n),o.restoreIdentity&&Zr.encode(d,o.restoreIdentity),o.createRoom&&$r.encode(d,o.createRoom),o.leaveRoom&&_r.encode(d,o.leaveRoom),o.clearRoom&&et.encode(d,o.clearRoom),o.joinRoomInvitation&&dt.encode(d,o.joinRoomInvitation),o.joinRoomKeys&&ot.encode(d,o.joinRoomKeys),o.joinRoomResponse&&nt.encode(d,o.joinRoomResponse),o.sendContactRequest&&ct.encode(d,o.sendContactRequest),o.migrateV2Room&&rt.encode(d,o.migrateV2Room)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d),c=e.uint.decode(d),r=e.uint.decode(d),t=e.uint.decode(d);return{discoveryKey:o,priority:n,timestamp:c,type:r,restoreIdentity:1&t?Zr.decode(d):null,createRoom:2&t?$r.decode(d):null,leaveRoom:4&t?_r.decode(d):null,clearRoom:8&t?et.decode(d):null,joinRoomInvitation:16&t?dt.decode(d):null,joinRoomKeys:32&t?ot.decode(d):null,joinRoomResponse:64&t?nt.decode(d):null,sendContactRequest:128&t?ct.decode(d):null,migrateV2Room:256&t?rt.decode(d):null}}},it=Oe,at={preencode(d,o){e.buffer.preencode(d,o.seed),it.preencode(d,o.invitation)},encode(d,o){e.buffer.encode(d,o.seed),it.encode(d,o.invitation)},decode:d=>({seed:e.buffer.decode(d),invitation:it.decode(d)})},st={preencode(e,d){e.end++},encode(d,o){const n=(o.isWritable?1:0)|(o.isReadable?2:0)|(o.isPrivateProfile?4:0)|(o.isRemoved?8:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isWritable:!!(1&o),isReadable:!!(2&o),isPrivateProfile:!!(4&o),isRemoved:!!(8&o)}}},pt={preencode(d,o){e.uint.preencode(d,o.creation),e.uint.preencode(d,o.latestSync),e.uint.preencode(d,o.latestChatMessage)},encode(d,o){e.uint.encode(d,o.creation),e.uint.encode(d,o.latestSync),e.uint.encode(d,o.latestChatMessage)},decode:d=>({creation:e.uint.decode(d),latestSync:e.uint.decode(d),latestChatMessage:e.uint.decode(d)})},ut=yn,lt=So,ft=e.frame(pt),mt=Kr,yt=e.frame(st),xt=e.frame(pe),bt=e.frame(hd),vt=an,gt=vn,kt=e.frame(Lo),Kt=$,ht=e.array(e.frame(Wn)),wt=e.frame(gd),Pt=vc,Tt={preencode(o,n){const c=(n.selfDevice?1:0)|(n.selfMember?2:0)|(n.config?4:0)|(n.identity?8:0)|(n.lastMessage?16:0)|(n.dm?32:0)|(n.readLengths?64:0)|(n.lastMember?128:0)|(n.version?256:0)|(d>=3&&n.preferences?512:0)|(d>=4&&n.activeCall?1024:0)|(d>=8&&n.lastMessageLabels?2048:0)|(d>=9&&n.settings?4096:0)|(d>=13&&n.system?8192:0)|(d>=13&&n.processed?16384:0);e.fixed32.preencode(o,n.roomKey),e.fixed32.preencode(o,n.discoveryKey),e.buffer.preencode(o,n.encryptionKey),ut.preencode(o,n.digest),lt.preencode(o,n.stats),ft.preencode(o,n.timestamps),e.uint.preencode(o,n.fork),e.uint.preencode(o,n.length),e.fixed32.preencode(o,n.seed),mt.preencode(o,n.capabilities),yt.preencode(o,n.status),e.uint.preencode(o,c),n.selfDevice&&xt.preencode(o,n.selfDevice),n.selfMember&&bt.preencode(o,n.selfMember),n.config&&vt.preencode(o,n.config),n.identity&&gt.preencode(o,n.identity),n.lastMessage&&kt.preencode(o,n.lastMessage),n.dm&&Kt.preencode(o,n.dm),n.readLengths&&ht.preencode(o,n.readLengths),n.lastMember&&wt.preencode(o,n.lastMember),n.version&&e.uint.preencode(o,n.version),d>=3&&n.preferences&&Pt.preencode(o,n.preferences),d>=4&&n.activeCall&&fl.preencode(o,n.activeCall),d>=8&&n.lastMessageLabels&&ml.preencode(o,n.lastMessageLabels),d>=9&&n.settings&&yl.preencode(o,n.settings),d>=13&&n.system&&xl.preencode(o,n.system),d>=13&&n.processed&&bl.preencode(o,n.processed)},encode(o,n){const c=(n.selfDevice?1:0)|(n.selfMember?2:0)|(n.config?4:0)|(n.identity?8:0)|(n.lastMessage?16:0)|(n.dm?32:0)|(n.readLengths?64:0)|(n.lastMember?128:0)|(n.version?256:0)|(d>=3&&n.preferences?512:0)|(d>=4&&n.activeCall?1024:0)|(d>=8&&n.lastMessageLabels?2048:0)|(d>=9&&n.settings?4096:0)|(d>=13&&n.system?8192:0)|(d>=13&&n.processed?16384:0);e.fixed32.encode(o,n.roomKey),e.fixed32.encode(o,n.discoveryKey),e.buffer.encode(o,n.encryptionKey),ut.encode(o,n.digest),lt.encode(o,n.stats),ft.encode(o,n.timestamps),e.uint.encode(o,n.fork),e.uint.encode(o,n.length),e.fixed32.encode(o,n.seed),mt.encode(o,n.capabilities),yt.encode(o,n.status),e.uint.encode(o,c),n.selfDevice&&xt.encode(o,n.selfDevice),n.selfMember&&bt.encode(o,n.selfMember),n.config&&vt.encode(o,n.config),n.identity&&gt.encode(o,n.identity),n.lastMessage&&kt.encode(o,n.lastMessage),n.dm&&Kt.encode(o,n.dm),n.readLengths&&ht.encode(o,n.readLengths),n.lastMember&&wt.encode(o,n.lastMember),n.version&&e.uint.encode(o,n.version),d>=3&&n.preferences&&Pt.encode(o,n.preferences),d>=4&&n.activeCall&&fl.encode(o,n.activeCall),d>=8&&n.lastMessageLabels&&ml.encode(o,n.lastMessageLabels),d>=9&&n.settings&&yl.encode(o,n.settings),d>=13&&n.system&&xl.encode(o,n.system),d>=13&&n.processed&&bl.encode(o,n.processed)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.buffer.decode(o),t=ut.decode(o),i=lt.decode(o),a=ft.decode(o),s=e.uint.decode(o),p=e.uint.decode(o),u=e.fixed32.decode(o),l=mt.decode(o),f=yt.decode(o),m=e.uint.decode(o);return{roomKey:n,discoveryKey:c,encryptionKey:r,digest:t,stats:i,timestamps:a,fork:s,length:p,seed:u,capabilities:l,status:f,selfDevice:1&m?xt.decode(o):null,selfMember:2&m?bt.decode(o):null,config:4&m?vt.decode(o):null,identity:8&m?gt.decode(o):null,lastMessage:16&m?kt.decode(o):null,dm:32&m?Kt.decode(o):null,readLengths:64&m?ht.decode(o):null,lastMember:128&m?wt.decode(o):null,version:256&m?e.uint.decode(o):0,preferences:d>=3&&512&m?Pt.decode(o):null,activeCall:d>=4&&1024&m?fl.decode(o):null,lastMessageLabels:d>=8&&2048&m?ml.decode(o):null,settings:d>=9&&4096&m?yl.decode(o):null,system:d>=13&&8192&m?xl.decode(o):null,processed:d>=13&&16384&m?bl.decode(o):null}}},Rt=vc,At={preencode(d,o){e.fixed32.preencode(d,o.roomKey),Rt.preencode(d,o.status)},encode(d,o){e.fixed32.encode(d,o.roomKey),Rt.encode(d,o.status)},decode:d=>({roomKey:e.fixed32.decode(d),status:Rt.decode(d)})},St={preencode(d,o){e.fixed32.preencode(d,o.roomKey),d.end++,o.repairs&&e.uint.preencode(d,o.repairs)},encode(d,o){const n=o.repairs?1:0;e.fixed32.encode(d,o.roomKey),e.uint.encode(d,n),o.repairs&&e.uint.encode(d,o.repairs)},decode:d=>({roomKey:e.fixed32.decode(d),repairs:1&e.uint.decode(d)?e.uint.decode(d):0})},It={preencode(o,n){e.fixed32.preencode(o,n.mailbox),e.fixed32.preencode(o,n.key),o.end++,n.roomKey&&e.fixed32.preencode(o,n.roomKey),n.keyPair&&r.preencode(o,n.keyPair),n.responseKeyPair&&r.preencode(o,n.responseKeyPair),d>=15&&n.activeClock&&e.uint.preencode(o,n.activeClock)},encode(o,n){const c=(n.roomKey?1:0)|(n.keyPair?2:0)|(n.responseKeyPair?4:0)|(d>=14&&n.pending?8:0)|(d>=15&&n.activeClock?16:0);e.fixed32.encode(o,n.mailbox),e.fixed32.encode(o,n.key),e.uint.encode(o,c),n.roomKey&&e.fixed32.encode(o,n.roomKey),n.keyPair&&r.encode(o,n.keyPair),n.responseKeyPair&&r.encode(o,n.responseKeyPair),d>=15&&n.activeClock&&e.uint.encode(o,n.activeClock)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=e.uint.decode(o);return{mailbox:n,key:c,roomKey:1&t?e.fixed32.decode(o):null,keyPair:2&t?r.decode(o):null,responseKeyPair:4&t?r.decode(o):null,pending:d>=14&&!!(8&t),activeClock:d>=15&&16&t?e.uint.decode(o):0}}},Mt={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.responsePublicKey)},encode(d,o){e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.responsePublicKey)},decode:d=>({key:e.fixed32.decode(d),responsePublicKey:e.fixed32.decode(d)})},Ft=fe,qt={preencode(d,o){e.fixed32.preencode(d,o.key),Ft.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),Ft.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),profile:Ft.decode(d)})},Ct=xt,Vt={preencode(d,o){e.fixed32.preencode(d,o.roomKey),Ct.preencode(d,o.device)},encode(d,o){e.fixed32.encode(d,o.roomKey),Ct.encode(d,o.device)},decode:d=>({roomKey:e.fixed32.decode(d),device:Ct.decode(d)})},Ht=k,Dt={preencode(o,n){Ht.preencode(o,n.file),e.fixed32.preencode(o,n.roomKey),o.end++,n.encryptionKey&&e.buffer.preencode(o,n.encryptionKey),d>=4&&n.lastAccessed&&e.uint.preencode(o,n.lastAccessed),d>=4&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(n.encryptionKey?1:0)|(n.cleared?2:0)|(n.own?4:0)|(d>=4&&n.lastAccessed?8:0)|(d>=4&&n.version?16:0);Ht.encode(o,n.file),e.fixed32.encode(o,n.roomKey),e.uint.encode(o,c),n.encryptionKey&&e.buffer.encode(o,n.encryptionKey),d>=4&&n.lastAccessed&&e.uint.encode(o,n.lastAccessed),d>=4&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=Ht.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{file:n,roomKey:c,encryptionKey:1&r?e.buffer.decode(o):null,cleared:!!(2&r),own:!!(4&r),lastAccessed:d>=4&&8&r?e.uint.decode(o):0,version:d>=4&&16&r?e.uint.decode(o):0}}},Lt={preencode(d,o){d.end++,o.key&&e.string.preencode(d,o.key),o.description&&e.string.preencode(d,o.description)},encode(d,o){const n=(o.key?1:0)|(o.value?2:0)|(o.description?4:0);e.uint.encode(d,n),o.key&&e.string.encode(d,o.key),o.description&&e.string.encode(d,o.description)},decode(d){const o=e.uint.decode(d);return{key:1&o?e.string.decode(d):null,value:!!(2&o),description:4&o?e.string.decode(d):null}}},jt=e.array(e.frame(Lt)),Et={preencode(e,d){e.end++,d.flags&&jt.preencode(e,d.flags)},encode(d,o){const n=o.flags?1:0;e.uint.encode(d,n),o.flags&&jt.encode(d,o.flags)},decode:d=>({flags:1&e.uint.decode(d)?jt.decode(d):null})},Bt=ed,zt={preencode(d,o){d.end++,o.nodes&&Bt.preencode(d,o.nodes),o.concurrency&&e.uint.preencode(d,o.concurrency),o.maxWindow&&e.uint.preencode(d,o.maxWindow),o.randomPunchInterval&&e.uint.preencode(d,o.randomPunchInterval),o.connectionKeepAlive&&e.uint.preencode(d,o.connectionKeepAlive)},encode(d,o){const n=(o.nodes?1:0)|(o.concurrency?2:0)|(o.maxWindow?4:0)|(o.randomPunchInterval?8:0)|(o.connectionKeepAlive?16:0);e.uint.encode(d,n),o.nodes&&Bt.encode(d,o.nodes),o.concurrency&&e.uint.encode(d,o.concurrency),o.maxWindow&&e.uint.encode(d,o.maxWindow),o.randomPunchInterval&&e.uint.encode(d,o.randomPunchInterval),o.connectionKeepAlive&&e.uint.encode(d,o.connectionKeepAlive)},decode(d){const o=e.uint.decode(d);return{nodes:1&o?Bt.decode(d):null,concurrency:2&o?e.uint.decode(d):0,maxWindow:4&o?e.uint.decode(d):0,randomPunchInterval:8&o?e.uint.decode(d):0,connectionKeepAlive:16&o?e.uint.decode(d):0}}},Ot={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.count)},encode(d,o){e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.count)},decode:d=>({roomKey:e.fixed32.decode(d),count:e.uint.decode(d)})},Nt={preencode(d,o){d.end++,o.roomKey&&e.fixed32.preencode(d,o.roomKey),o.coreKey&&e.fixed32.preencode(d,o.coreKey)},encode(d,o){const n=(o.roomKey?1:0)|(o.coreKey?2:0);e.uint.encode(d,n),o.roomKey&&e.fixed32.encode(d,o.roomKey),o.coreKey&&e.fixed32.encode(d,o.coreKey)},decode(d){const o=e.uint.decode(d);return{roomKey:1&o?e.fixed32.decode(d):null,coreKey:2&o?e.fixed32.decode(d):null}}},Ut=e.frame(Nt),Jt={preencode(d,o){e.string.preencode(d,o.code),e.string.preencode(d,o.message),e.string.preencode(d,o.stack),e.uint.preencode(d,o.timestamp),d.end++,o.details&&Ut.preencode(d,o.details)},encode(d,o){const n=o.details?1:0;e.string.encode(d,o.code),e.string.encode(d,o.message),e.string.encode(d,o.stack),e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.details&&Ut.encode(d,o.details)},decode:d=>({code:e.string.decode(d),message:e.string.decode(d),stack:e.string.decode(d),timestamp:e.uint.decode(d),details:1&e.uint.decode(d)?Ut.decode(d):null})},Wt={RESUME:1,WAKEUP:2,PRESUSPEND:3,SUSPEND:4},Gt={preencode(e,d){e.end++},encode(d,o){if(o>4)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Qt={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.total)},encode(d,o){e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.total)},decode:d=>({roomKey:e.fixed32.decode(d),total:e.uint.decode(d)})},Xt=i,Yt={preencode(d,o){e.uint.preencode(d,o.duration)},encode(d,o){e.uint.encode(d,o.duration)},decode:d=>({duration:e.uint.decode(d)})},Zt=H,$t=H,_t=e.frame(Xt),ei={preencode(e,d){_t.preencode(e,d.header)},encode(e,d){_t.encode(e,d.header)},decode:e=>({header:_t.decode(e)})},di=e.frame(Yt),oi={preencode(e,d){di.preencode(e,d.header)},encode(e,d){di.encode(e,d.header)},decode:e=>({header:di.decode(e)})},ni=_t,ci={preencode(e,d){ni.preencode(e,d.header)},encode(e,d){ni.encode(e,d.header)},decode:e=>({header:ni.decode(e)})},ri=H,ti=_t,ii=an,ai=J,si={preencode(e,d){ti.preencode(e,d.header),e.end++,d.config&&ii.preencode(e,d.config),d.settings&&ai.preencode(e,d.settings)},encode(d,o){const n=(o.config?1:0)|(o.settings?2:0);ti.encode(d,o.header),e.uint.encode(d,n),o.config&&ii.encode(d,o.config),o.settings&&ai.encode(d,o.settings)},decode(d){const o=ti.decode(d),n=e.uint.decode(d);return{header:o,config:1&n?ii.decode(d):null,settings:2&n?ai.decode(d):null}}},pi=di,ui={preencode(d,o){pi.preencode(d,o.header),d.end++,o.roomKey&&e.fixed32.preencode(d,o.roomKey)},encode(d,o){const n=o.roomKey?1:0;pi.encode(d,o.header),e.uint.encode(d,n),o.roomKey&&e.fixed32.encode(d,o.roomKey)},decode:d=>({header:pi.decode(d),roomKey:1&e.uint.decode(d)?e.fixed32.decode(d):null})},li=_t,fi={preencode(d,o){li.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey)},encode(d,o){li.encode(d,o.header),e.fixed32.encode(d,o.roomKey)},decode:d=>({header:li.decode(d),roomKey:e.fixed32.decode(d)})},mi=_t,yi={preencode(d,o){mi.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey)},encode(d,o){mi.encode(d,o.header),e.fixed32.encode(d,o.roomKey)},decode:d=>({header:mi.decode(d),roomKey:e.fixed32.decode(d)})},xi=_t,bi={preencode(d,o){xi.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey)},encode(d,o){xi.encode(d,o.header),e.fixed32.encode(d,o.roomKey)},decode:d=>({header:xi.decode(d),roomKey:e.fixed32.decode(d)})},vi=di,gi={preencode(e,d){vi.preencode(e,d.header)},encode(e,d){vi.encode(e,d.header)},decode:e=>({header:vi.decode(e)})},ki=_t,Ki=an,hi={preencode(d,o){ki.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.key),Ki.preencode(d,o.config)},encode(d,o){ki.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.key),Ki.encode(d,o.config)},decode:d=>({header:ki.decode(d),roomKey:e.fixed32.decode(d),key:e.uint.decode(d),config:Ki.decode(d)})},wi=_t,Pi=J,Ti={preencode(d,o){wi.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.key),Pi.preencode(d,o.settings)},encode(d,o){wi.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.key),Pi.encode(d,o.settings)},decode:d=>({header:wi.decode(d),roomKey:e.fixed32.decode(d),key:e.uint.decode(d),settings:Pi.decode(d)})},Ri=_t,Ai=vc,Si={preencode(d,o){Ri.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.key),Ai.preencode(d,o.status)},encode(d,o){Ri.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.key),Ai.encode(d,o.status)},decode:d=>({header:Ri.decode(d),roomKey:e.fixed32.decode(d),key:e.uint.decode(d),status:Ai.decode(d)})},Ii=_t,Mi=Eo,Fi={preencode(d,o){Ii.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),Mi.preencode(d,o.message)},encode(d,o){Ii.encode(d,o.header),e.fixed32.encode(d,o.roomKey),Mi.encode(d,o.message)},decode:d=>({header:Ii.decode(d),roomKey:e.fixed32.decode(d),message:Mi.decode(d)})},qi=di,Ci={preencode(e,d){qi.preencode(e,d.header)},encode(e,d){qi.encode(e,d.header)},decode:e=>({header:qi.decode(e)})},Vi=_t,Hi=Eo,Di={preencode(d,o){Vi.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),n.preencode(d,o.id),Hi.preencode(d,o.message)},encode(d,o){Vi.encode(d,o.header),e.fixed32.encode(d,o.roomKey),n.encode(d,o.id),Hi.encode(d,o.message)},decode:d=>({header:Vi.decode(d),roomKey:e.fixed32.decode(d),id:n.decode(d),message:Hi.decode(d)})},Li=di,ji={preencode(e,d){Li.preencode(e,d.header)},encode(e,d){Li.encode(e,d.header)},decode:e=>({header:Li.decode(e)})},Ei=_t,Bi={preencode(d,o){Ei.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),n.preencode(d,o.id)},encode(d,o){Ei.encode(d,o.header),e.fixed32.encode(d,o.roomKey),n.encode(d,o.id)},decode:d=>({header:Ei.decode(d),roomKey:e.fixed32.decode(d),id:n.decode(d)})},zi=di,Oi={preencode(e,d){zi.preencode(e,d.header)},encode(e,d){zi.encode(e,d.header)},decode:e=>({header:zi.decode(e)})},Ni=_t,Ui={preencode(d,o){Ni.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),n.preencode(d,o.id),e.string.preencode(d,o.reaction)},encode(d,o){Ni.encode(d,o.header),e.fixed32.encode(d,o.roomKey),n.encode(d,o.id),e.string.encode(d,o.reaction)},decode:d=>({header:Ni.decode(d),roomKey:e.fixed32.decode(d),id:n.decode(d),reaction:e.string.decode(d)})},Ji=di,Wi={preencode(e,d){Ji.preencode(e,d.header)},encode(e,d){Ji.encode(e,d.header)},decode:e=>({header:Ji.decode(e)})},Gi=_t,Qi={preencode(d,o){Gi.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),n.preencode(d,o.id),e.string.preencode(d,o.reaction)},encode(d,o){Gi.encode(d,o.header),e.fixed32.encode(d,o.roomKey),n.encode(d,o.id),e.string.encode(d,o.reaction)},decode:d=>({header:Gi.decode(d),roomKey:e.fixed32.decode(d),id:n.decode(d),reaction:e.string.decode(d)})},Xi=di,Yi={preencode(e,d){Xi.preencode(e,d.header)},encode(e,d){Xi.encode(e,d.header)},decode:e=>({header:Xi.decode(e)})},Zi={preencode(d,o){e.uint.preencode(d,o.clock),e.uint.preencode(d,o.start),e.uint.preencode(d,o.end)},encode(d,o){e.uint.encode(d,o.clock),e.uint.encode(d,o.start),e.uint.encode(d,o.end)},decode:d=>({clock:e.uint.decode(d),start:e.uint.decode(d),end:e.uint.decode(d)})},$i=H,_i=$,ea={preencode(d,o){e.uint.preencode(d,o.clock),_i.preencode(d,o.keys)},encode(d,o){e.uint.encode(d,o.clock),_i.encode(d,o.keys)},decode:d=>({clock:e.uint.decode(d),keys:_i.decode(d)})},da={preencode(d,o){e.uint.preencode(d,o.clock),e.fixed32.preencode(d,o.roomKey),d.end++,o.start&&e.uint.preencode(d,o.start),o.size&&e.uint.preencode(d,o.size)},encode(d,o){const n=(o.start?1:0)|(o.size?2:0)|(o.isBottom?4:0);e.uint.encode(d,o.clock),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,n),o.start&&e.uint.encode(d,o.start),o.size&&e.uint.encode(d,o.size)},decode(d){const o=e.uint.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{clock:o,roomKey:n,start:1&c?e.uint.decode(d):0,size:2&c?e.uint.decode(d):0,isBottom:!!(4&c)}}},oa=H,na={preencode(d,o){e.uint.preencode(d,o.clock),e.fixed32.preencode(d,o.roomKey),d.end++,o.offset&&e.fixed32.preencode(d,o.offset),o.count&&e.uint.preencode(d,o.count)},encode(d,o){const n=(o.offset?1:0)|(o.count?2:0);e.uint.encode(d,o.clock),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,n),o.offset&&e.fixed32.encode(d,o.offset),o.count&&e.uint.encode(d,o.count)},decode(d){const o=e.uint.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{clock:o,roomKey:n,offset:1&c?e.fixed32.decode(d):null,count:2&c?e.uint.decode(d):0}}},ca=H,ra={preencode(d,o){e.uint.preencode(d,o.timestamp),e.fixed32.preencode(d,o.id)},encode(d,o){e.uint.encode(d,o.timestamp),e.fixed32.encode(d,o.id)},decode:d=>({timestamp:e.uint.decode(d),id:e.fixed32.decode(d)})},ta={Changed:1,Removed:2},ia={preencode(e,d){e.end++},encode(d,o){if(o>2)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},aa=$,sa={preencode(d,o){aa.preencode(d,o.keys),e.uint.preencode(d,o.start),e.uint.preencode(d,o.end),e.uint.preencode(d,o.total)},encode(d,o){aa.encode(d,o.keys),e.uint.encode(d,o.start),e.uint.encode(d,o.end),e.uint.encode(d,o.total)},decode:d=>({keys:aa.decode(d),start:e.uint.decode(d),end:e.uint.decode(d),total:e.uint.decode(d)})},pa={preencode(e,d){ia.preencode(e,d.type),ra.preencode(e,d.room)},encode(e,d){ia.encode(e,d.type),ra.encode(e,d.room)},decode:e=>({type:ia.decode(e),room:ra.decode(e)})},ua=yt,la=bd,fa={preencode(e,d){ua.preencode(e,d.device),e.end++,d.member&&la.preencode(e,d.member)},encode(d,o){const n=o.member?1:0;ua.encode(d,o.device),e.uint.encode(d,n),o.member&&la.encode(d,o.member)},decode:d=>({device:ua.decode(d),member:1&e.uint.decode(d)?la.decode(d):null})},ma=e.frame(fa),ya=yn,xa=an,ba={preencode(d,o){e.fixed32.preencode(d,o.id),ma.preencode(d,o.role),ya.preencode(d,o.digest),xa.preencode(d,o.config),d.end++,o.messageId&&n.preencode(d,o.messageId)},encode(d,o){const c=o.messageId?1:0;e.fixed32.encode(d,o.id),ma.encode(d,o.role),ya.encode(d,o.digest),xa.encode(d,o.config),e.uint.encode(d,c),o.messageId&&n.encode(d,o.messageId)},decode:d=>({id:e.fixed32.decode(d),role:ma.decode(d),digest:ya.decode(d),config:xa.decode(d),messageId:1&e.uint.decode(d)?n.decode(d):null})},va=yt,ga={preencode(d,o){e.fixed32.preencode(d,o.id),va.preencode(d,o.status)},encode(d,o){e.fixed32.encode(d,o.id),va.encode(d,o.status)},decode:d=>({id:e.fixed32.decode(d),status:va.decode(d)})},ka=yn,Ka={preencode(d,o){e.fixed32.preencode(d,o.id),ka.preencode(d,o.digest)},encode(d,o){e.fixed32.encode(d,o.id),ka.encode(d,o.digest)},decode:d=>({id:e.fixed32.decode(d),digest:ka.decode(d)})},ha=an,wa={preencode(d,o){e.fixed32.preencode(d,o.id),ha.preencode(d,o.config)},encode(d,o){e.fixed32.encode(d,o.id),ha.encode(d,o.config)},decode:d=>({id:e.fixed32.decode(d),config:ha.decode(d)})},Pa=ma,Ta={preencode(d,o){e.fixed32.preencode(d,o.id),d.end++,o.role&&Pa.preencode(d,o.role)},encode(d,o){const n=o.role?1:0;e.fixed32.encode(d,o.id),e.uint.encode(d,n),o.role&&Pa.encode(d,o.role)},decode:d=>({id:e.fixed32.decode(d),role:1&e.uint.decode(d)?Pa.decode(d):null})},Ra={preencode(d,o){e.fixed32.preencode(d,o.id),n.preencode(d,o.lastMessage)},encode(d,o){e.fixed32.encode(d,o.id),n.encode(d,o.lastMessage)},decode:d=>({id:e.fixed32.decode(d),lastMessage:n.decode(d)})},Aa=fe,Sa={preencode(d,o){e.fixed32.preencode(d,o.key),Aa.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),Aa.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),profile:Aa.decode(d)})},Ia=ae,Ma={preencode(d,o){e.fixed32.preencode(d,o.key),Ia.preencode(d,o.status),vl.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),Ia.encode(d,o.status),vl.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),status:Ia.decode(d),profile:vl.decode(d)})},Fa={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.roomKey),e.fixed32.encode(d,o.key)},decode:d=>({roomKey:e.fixed32.decode(d),key:e.fixed32.decode(d)})},qa=Fa,Ca=e.array(n),Va={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.start),e.uint.preencode(d,o.size),e.uint.preencode(d,o.total),Ca.preencode(d,o.ids),d.end++},encode(d,o){const n=o.isBottom?1:0;e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.start),e.uint.encode(d,o.size),e.uint.encode(d,o.total),Ca.encode(d,o.ids),e.uint.encode(d,n)},decode:d=>({roomKey:e.fixed32.decode(d),start:e.uint.decode(d),size:e.uint.decode(d),total:e.uint.decode(d),ids:Ca.decode(d),isBottom:!!(1&e.uint.decode(d))})},Ha={preencode(d,o){e.uint.preencode(d,o.sent),d.end++,o.edited&&e.uint.preencode(d,o.edited)},encode(d,o){const n=o.edited?1:0;e.uint.encode(d,o.sent),e.uint.encode(d,n),o.edited&&e.uint.encode(d,o.edited)},decode:d=>({sent:e.uint.decode(d),edited:1&e.uint.decode(d)?e.uint.decode(d):0})},Da=e.frame(Ha),La=Mo,ja=Fo,Ea=qo,Ba={preencode(d,o){n.preencode(d,o.id),e.uint.preencode(d,o.clock),Da.preencode(d,o.timestamps),La.preencode(d,o.status),d.end++,o.message&&ja.preencode(d,o.message),o.event&&Ea.preencode(d,o.event)},encode(d,o){const c=(o.message?1:0)|(o.event?2:0);n.encode(d,o.id),e.uint.encode(d,o.clock),Da.encode(d,o.timestamps),La.encode(d,o.status),e.uint.encode(d,c),o.message&&ja.encode(d,o.message),o.event&&Ea.encode(d,o.event)},decode(d){const o=n.decode(d),c=e.uint.decode(d),r=Da.decode(d),t=La.decode(d),i=e.uint.decode(d);return{id:o,clock:c,timestamps:r,status:t,message:1&i?ja.decode(d):null,event:2&i?Ea.decode(d):null}}},za=e.frame(Ba),Oa=bd,Na={preencode(d,o){za.preencode(d,o.chat),e.fixed32.preencode(d,o.memberKey),Oa.preencode(d,o.role)},encode(d,o){za.encode(d,o.chat),e.fixed32.encode(d,o.memberKey),Oa.encode(d,o.role)},decode:d=>({chat:za.decode(d),memberKey:e.fixed32.decode(d),role:Oa.decode(d)})},Ua=za,Ja={preencode(e,d){Ua.preencode(e,d.chat)},encode(e,d){Ua.encode(e,d.chat)},decode:e=>({chat:Ua.decode(e)})},Wa=Ca,Ga={preencode(d,o){Wa.preencode(d,o.ids),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Wa.encode(d,o.ids),e.fixed32.encode(d,o.memberKey)},decode:d=>({ids:Wa.decode(d),memberKey:e.fixed32.decode(d)})},Qa=Ca,Xa=bd,Ya={preencode(e,d){Qa.preencode(e,d.ids),Xa.preencode(e,d.role)},encode(e,d){Qa.encode(e,d.ids),Xa.encode(e,d.role)},decode:e=>({ids:Qa.decode(e),role:Xa.decode(e)})},Za=e.frame(dn),$a={preencode(e,d){n.preencode(e,d.id),Za.preencode(e,d.reactions)},encode(e,d){n.encode(e,d.id),Za.encode(e,d.reactions)},decode:e=>({id:n.decode(e),reactions:Za.decode(e)})},_a=Za,es={preencode(e,d){n.preencode(e,d.id),_a.preencode(e,d.digest)},encode(e,d){n.encode(e,d.id),_a.encode(e,d.digest)},decode:e=>({id:n.decode(e),digest:_a.decode(e)})},ds=H,os=H,ns=e.array(e.frame(ic)),cs={preencode(e,d){ns.preencode(e,d.invitations)},encode(e,d){ns.encode(e,d.invitations)},decode:e=>({invitations:ns.decode(e)})},rs=e.frame(ud),ts={preencode(d,o){e.fixed32.preencode(d,o.roomKey),rs.preencode(d,o.request)},encode(d,o){e.fixed32.encode(d,o.roomKey),rs.encode(d,o.request)},decode:d=>({roomKey:e.fixed32.decode(d),request:rs.decode(d)})},is=e.array(e.frame(ts)),as={preencode(e,d){is.preencode(e,d.requests)},encode(e,d){is.encode(e,d.requests)},decode:e=>({requests:is.decode(e)})},ss=ns,ps=e.array(e.frame(ud)),us={preencode(e,d){ss.preencode(e,d.pendingInvitations),ps.preencode(e,d.identityJoinRequests)},encode(e,d){ss.encode(e,d.pendingInvitations),ps.encode(e,d.identityJoinRequests)},decode:e=>({pendingInvitations:ss.decode(e),identityJoinRequests:ps.decode(e)})},ls=_t,fs={preencode(d,o){ls.preencode(d,o.header),e.string.preencode(d,o.invitation),d.end++},encode(d,o){const n=o.isIdentity?1:0;ls.encode(d,o.header),e.string.encode(d,o.invitation),e.uint.encode(d,n)},decode:d=>({header:ls.decode(d),invitation:e.string.decode(d),isIdentity:!!(1&e.uint.decode(d))})},ms=di,ys={preencode(e,d){ms.preencode(e,d.header)},encode(e,d){ms.encode(e,d.header)},decode:e=>({header:ms.decode(e)})},xs={preencode(e,d){e.end++},encode(d,o){const n=(o.canModerate?1:0)|(o.canAdmin?2:0)|(o.requiresConfirmation?4:0)|(o.isReadOnly?8:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{canModerate:!!(1&o),canAdmin:!!(2&o),requiresConfirmation:!!(4&o),isReadOnly:!!(8&o)}}},bs=_t,vs=e.frame(xs),gs={preencode(d,o){bs.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),d.end++,o.permissions&&vs.preencode(d,o.permissions),o.expiration&&e.uint.preencode(d,o.expiration)},encode(d,o){const n=(o.permissions?1:0)|(o.expiration?2:0);bs.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,n),o.permissions&&vs.encode(d,o.permissions),o.expiration&&e.uint.encode(d,o.expiration)},decode(d){const o=bs.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{header:o,roomKey:n,permissions:1&c?vs.decode(d):null,expiration:2&c?e.uint.decode(d):0}}},ks=di,Ks={preencode(d,o){ks.preencode(d,o.header),e.string.preencode(d,o.invitation)},encode(d,o){ks.encode(d,o.header),e.string.encode(d,o.invitation)},decode:d=>({header:ks.decode(d),invitation:e.string.decode(d)})},hs=_t,ws={preencode(e,d){hs.preencode(e,d.header)},encode(e,d){hs.encode(e,d.header)},decode:e=>({header:hs.decode(e)})},Ps=di,Ts={preencode(d,o){Ps.preencode(d,o.header),e.string.preencode(d,o.invitation)},encode(d,o){Ps.encode(d,o.header),e.string.encode(d,o.invitation)},decode:d=>({header:Ps.decode(d),invitation:e.string.decode(d)})},Rs=_t,As=rs,Ss={preencode(d,o){Rs.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),As.preencode(d,o.request)},encode(d,o){Rs.encode(d,o.header),e.fixed32.encode(d,o.roomKey),As.encode(d,o.request)},decode:d=>({header:Rs.decode(d),roomKey:e.fixed32.decode(d),request:As.decode(d)})},Is=di,Ms={preencode(e,d){Is.preencode(e,d.header)},encode(e,d){Is.encode(e,d.header)},decode:e=>({header:Is.decode(e)})},Fs=_t,qs=rs,Cs={preencode(d,o){Fs.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),qs.preencode(d,o.request)},encode(d,o){Fs.encode(d,o.header),e.fixed32.encode(d,o.roomKey),qs.encode(d,o.request)},decode:d=>({header:Fs.decode(d),roomKey:e.fixed32.decode(d),request:qs.decode(d)})},Vs=di,Hs={preencode(e,d){Vs.preencode(e,d.header)},encode(e,d){Vs.encode(e,d.header)},decode:e=>({header:Vs.decode(e)})},Ds=_t,Ls={preencode(d,o){Ds.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){Ds.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:Ds.decode(d),id:e.fixed32.decode(d)})},js=di,Es={preencode(e,d){js.preencode(e,d.header)},encode(e,d){js.encode(e,d.header)},decode:e=>({header:js.decode(e)})},Bs=_t,zs={preencode(d,o){Bs.preencode(d,o.header),e.string.preencode(d,o.displayName),d.end++,o.avatar&&e.buffer.preencode(d,o.avatar)},encode(d,o){const n=o.avatar?1:0;Bs.encode(d,o.header),e.string.encode(d,o.displayName),e.uint.encode(d,n),o.avatar&&e.buffer.encode(d,o.avatar)},decode:d=>({header:Bs.decode(d),displayName:e.string.decode(d),avatar:1&e.uint.decode(d)?e.buffer.decode(d):null})},Os=H,Ns=H,Us={preencode(e,d){e.end++},encode(d,o){const n=(o.isConfirmed?1:0)|(o.isLoggedOut?2:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isConfirmed:!!(1&o),isLoggedOut:!!(2&o)}}},Js=e.frame(Us),Ws=$,Gs={preencode(d,o){e.fixed32.preencode(d,o.memberKey),Js.preencode(d,o.status),Ws.preencode(d,o.deviceKeys)},encode(d,o){e.fixed32.encode(d,o.memberKey),Js.encode(d,o.status),Ws.encode(d,o.deviceKeys)},decode:d=>({memberKey:e.fixed32.decode(d),status:Js.decode(d),deviceKeys:Ws.decode(d)})},Qs={preencode(d,o){e.fixed32.preencode(d,o.memberKey)},encode(d,o){e.fixed32.encode(d,o.memberKey)},decode:d=>({memberKey:e.fixed32.decode(d)})},Xs={preencode(d,o){e.fixed32.preencode(d,o.deviceKey)},encode(d,o){e.fixed32.encode(d,o.deviceKey)},decode:d=>({deviceKey:e.fixed32.decode(d)})},Ys=_t,Zs={preencode(d,o){Ys.preencode(d,o.header),e.string.preencode(d,o.password)},encode(d,o){Ys.encode(d,o.header),e.string.encode(d,o.password)},decode:d=>({header:Ys.decode(d),password:e.string.decode(d)})},$s=di,_s={preencode(d,o){$s.preencode(d,o.header),e.string.preencode(d,o.inspector)},encode(d,o){$s.encode(d,o.header),e.string.encode(d,o.inspector)},decode:d=>({header:$s.decode(d),inspector:e.string.decode(d)})},ep=di,dp={preencode(e,d){ep.preencode(e,d.header)},encode(e,d){ep.encode(e,d.header)},decode:e=>({header:ep.decode(e)})},op=di,np={preencode(e,d){op.preencode(e,d.header)},encode(e,d){op.encode(e,d.header)},decode:e=>({header:op.decode(e)})},cp={Flag:1},rp={preencode(e,d){e.end++},encode(d,o){if(o>1)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},tp={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),rp.preencode(d,o.label)},encode(d,o){e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),rp.encode(d,o.label)},decode:d=>({key:e.fixed32.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),label:rp.decode(d)})},ip=de,ap={preencode(d,o){ip.preencode(d,o.header),e.fixed32.preencode(d,o.key),rp.preencode(d,o.label)},encode(d,o){ip.encode(d,o.header),e.fixed32.encode(d,o.key),rp.encode(d,o.label)},decode:d=>({header:ip.decode(d),key:e.fixed32.decode(d),label:rp.decode(d)})},sp={preencode(d,o){rp.preencode(d,o.label),e.uint.preencode(d,o.count)},encode(d,o){rp.encode(d,o.label),e.uint.encode(d,o.count)},decode:d=>({label:rp.decode(d),count:e.uint.decode(d)})},pp=e.array(e.frame(sp)),up={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.total),pp.preencode(d,o.labels),e.uint.preencode(d,o.editedAt),e.uint.preencode(d,o.flagsClock)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.total),pp.encode(d,o.labels),e.uint.encode(d,o.editedAt),e.uint.encode(d,o.flagsClock)},decode:d=>({key:e.fixed32.decode(d),total:e.uint.decode(d),labels:pp.decode(d),editedAt:e.uint.decode(d),flagsClock:e.uint.decode(d)})},lp=de,fp={preencode(d,o){lp.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.fromDeviceKey)},encode(d,o){lp.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.fromDeviceKey)},decode:d=>({header:lp.decode(d),deviceKey:e.fixed32.decode(d),fromDeviceKey:e.fixed32.decode(d)})},mp={preencode(d,o){e.float64.preencode(d,o.latitude),e.float64.preencode(d,o.longitude)},encode(d,o){e.float64.encode(d,o.latitude),e.float64.encode(d,o.longitude)},decode:d=>({latitude:e.float64.decode(d),longitude:e.float64.decode(d)})},yp=de,xp=$,bp={preencode(o,n){yp.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),e.buffer.preencode(o,n.encryptionKey),o.end++,d>=4&&n.streams&&xp.preencode(o,n.streams),d>=4&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=4&&n.version&&e.uint.preencode(o,n.version),d>=12&&n.streamInputs&&gl.preencode(o,n.streamInputs),d>=12&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey)},encode(o,n){const c=(d>=4&&n.streams?1:0)|(d>=4&&n.discoveryKey?2:0)|(d>=4&&n.version?4:0)|(d>=12&&n.streamInputs?8:0)|(d>=12&&n.swarmKey?16:0);yp.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,c),d>=4&&n.streams&&xp.encode(o,n.streams),d>=4&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=4&&n.version&&e.uint.encode(o,n.version),d>=12&&n.streamInputs&&gl.encode(o,n.streamInputs),d>=12&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey)},decode(o){const n=yp.decode(o),c=e.fixed32.decode(o),r=e.buffer.decode(o),t=e.uint.decode(o);return{header:n,callKey:c,encryptionKey:r,streams:d>=4&&1&t?xp.decode(o):null,discoveryKey:d>=4&&2&t?e.fixed32.decode(o):null,version:d>=4&&4&t?e.uint.decode(o):0,streamInputs:d>=12&&8&t?gl.decode(o):null,swarmKey:d>=12&&16&t?e.fixed32.decode(o):null}}},vp=de,gp=$,kp={preencode(o,n){vp.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),o.end++,d>=4&&n.streams&&gp.preencode(o,n.streams),d>=12&&n.streamInputs&&kl.preencode(o,n.streamInputs),d>=12&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey)},encode(o,n){const c=(d>=4&&n.streams?1:0)|(d>=12&&n.streamInputs?2:0)|(d>=12&&n.swarmKey?4:0);vp.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.uint.encode(o,c),d>=4&&n.streams&&gp.encode(o,n.streams),d>=12&&n.streamInputs&&kl.encode(o,n.streamInputs),d>=12&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey)},decode(o){const n=vp.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{header:n,callKey:c,streams:d>=4&&1&r?gp.decode(o):null,streamInputs:d>=12&&2&r?kl.decode(o):null,swarmKey:d>=12&&4&r?e.fixed32.decode(o):null}}},Kp=de,hp={preencode(d,o){Kp.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Kp.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Kp.decode(d),callKey:e.fixed32.decode(d)})},wp=de,Pp={preencode(d,o){wp.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){wp.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:wp.decode(d),callKey:e.fixed32.decode(d)})},Tp=de,Rp={preencode(o,n){Tp.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.streamKey),o.end++,d>=12&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=12&&n.type&&e.string.preencode(o,n.type)},encode(o,n){const c=(d>=12&&n.mediaStreamId?1:0)|(d>=12&&n.type?2:0)|(d>=12&&n.muted?4:0);Tp.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.streamKey),e.uint.encode(o,c),d>=12&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=12&&n.type&&e.string.encode(o,n.type)},decode(o){const n=Tp.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=o.start<o.end?e.uint.decode(o):0;return{header:n,callKey:c,streamKey:r,mediaStreamId:d>=12&&1&t?e.string.decode(o):null,type:d>=12&&2&t?e.string.decode(o):null,muted:d>=12&&!!(4&t)}}},Ap=de,Sp={preencode(d,o){Ap.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.streamKey)},encode(d,o){Ap.encode(d,o.header),e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.streamKey)},decode:d=>({header:Ap.decode(d),callKey:e.fixed32.decode(d),streamKey:e.fixed32.decode(d)})},Ip={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.buffer.preencode(o,n.encryptionKey),e.uint.preencode(o,n.createdAt),o.end++,d>=4&&n.endedAt&&e.uint.preencode(o,n.endedAt),d>=4&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=4&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(d>=4&&n.endedAt?1:0)|(d>=4&&n.discoveryKey?2:0)|(d>=4&&n.version?4:0);e.fixed32.encode(o,n.callKey),e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=4&&n.endedAt&&e.uint.encode(o,n.endedAt),d>=4&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=4&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=e.fixed32.decode(o),c=e.buffer.decode(o),r=e.uint.decode(o),t=e.uint.decode(o);return{callKey:n,encryptionKey:c,createdAt:r,endedAt:d>=4&&1&t?e.uint.decode(o):0,discoveryKey:d>=4&&2&t?e.fixed32.decode(o):null,version:d>=4&&4&t?e.uint.decode(o):0}}},Mp={preencode(d,o){e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.createdAt)},encode(d,o){e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.createdAt)},decode:d=>({callKey:e.fixed32.decode(d),memberKey:e.fixed32.decode(d),createdAt:e.uint.decode(d)})},Fp={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.deviceKey),e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.createdAt),o.end++,d>=4&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),d>=8&&n.lastHeartbeatAt&&e.uint.preencode(o,n.lastHeartbeatAt)},encode(o,n){const c=(d>=4&&n.swarmKey?1:0)|(d>=8&&n.lastHeartbeatAt?2:0)|(d>=9&&n.isRecording?4:0);e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.deviceKey),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=4&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey),d>=8&&n.lastHeartbeatAt&&e.uint.encode(o,n.lastHeartbeatAt)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o),i=e.uint.decode(o);return{callKey:n,deviceKey:c,memberKey:r,createdAt:t,swarmKey:d>=4&&1&i?e.fixed32.decode(o):null,lastHeartbeatAt:d>=8&&2&i?e.uint.decode(o):0,isRecording:d>=9&&!!(4&i)}}},qp={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.deviceKey),e.buffer.preencode(o,n.streamKey),e.uint.preencode(o,n.createdAt),o.end++,d>=12&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=12&&n.type&&e.string.preencode(o,n.type),d>=12&&n.statusKey&&e.uint.preencode(o,n.statusKey)},encode(o,n){const c=(d>=12&&n.mediaStreamId?1:0)|(d>=12&&n.type?2:0)|(d>=12&&n.statusKey?4:0);e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.deviceKey),e.buffer.encode(o,n.streamKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=12&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=12&&n.type&&e.string.encode(o,n.type),d>=12&&n.statusKey&&e.uint.encode(o,n.statusKey)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.buffer.decode(o),t=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{callKey:n,deviceKey:c,streamKey:r,createdAt:t,mediaStreamId:d>=12&&1&i?e.string.decode(o):null,type:d>=12&&2&i?e.string.decode(o):null,statusKey:d>=12&&4&i?e.uint.decode(o):0}}},Cp={preencode(o,n){e.fixed32.preencode(o,n.callKey),o.end++,d>=4&&n.selfDeviceKey&&e.fixed32.preencode(o,n.selfDeviceKey),d>=12&&n.createdAt&&e.uint.preencode(o,n.createdAt)},encode(o,n){const c=(d>=4&&n.selfDeviceKey?1:0)|(d>=12&&n.createdAt?2:0);e.fixed32.encode(o,n.callKey),e.uint.encode(o,c),d>=4&&n.selfDeviceKey&&e.fixed32.encode(o,n.selfDeviceKey),d>=12&&n.createdAt&&e.uint.encode(o,n.createdAt)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o);return{callKey:n,selfDeviceKey:d>=4&&1&c?e.fixed32.decode(o):null,createdAt:d>=12&&2&c?e.uint.decode(o):0}}},Vp={preencode(d,o){e.uint.preencode(d,o.lastCleared)},encode(d,o){e.uint.encode(d,o.lastCleared)},decode:d=>({lastCleared:e.uint.decode(d)})},Hp={Nightly:"Nightly",Internal:"Internal",Production:"Production"},Dp={preencode(e,d){e.end++},encode(d,o){switch(o){case"Nightly":e.uint.encode(d,1);break;case"Internal":e.uint.encode(d,2);break;case"Production":e.uint.encode(d,3);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"Nightly";case 2:return"Internal";case 3:return"Production";default:return null}}},Lp=de,jp={preencode(e,d){Lp.preencode(e,d.header)},encode(e,d){Lp.encode(e,d.header)},decode:e=>({header:Lp.decode(e)})},Ep=de,Bp={preencode(e,d){Ep.preencode(e,d.header)},encode(e,d){Ep.encode(e,d.header)},decode:e=>({header:Ep.decode(e)})},zp={preencode(o,n){Dp.preencode(o,n.buildType),o.end++,d>=6&&n.latestOfflineAbi&&e.uint.preencode(o,n.latestOfflineAbi)},encode(o,n){const c=d>=6&&n.latestOfflineAbi?1:0;Dp.encode(o,n.buildType),e.uint.encode(o,c),d>=6&&n.latestOfflineAbi&&e.uint.encode(o,n.latestOfflineAbi)},decode(o){const n=Dp.decode(o),c=o.start<o.end?e.uint.decode(o):0;return{buildType:n,latestOfflineAbi:d>=6&&1&c?e.uint.decode(o):0}}},Op=de,Np={preencode(d,o){Op.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),e.buffer.preencode(d,o.deviceProof),e.buffer.preencode(d,o.writerProof)},encode(d,o){Op.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.buffer.encode(d,o.deviceProof),e.buffer.encode(d,o.writerProof)},decode:d=>({header:Op.decode(d),deviceKey:e.fixed32.decode(d),deviceProof:e.buffer.decode(d),writerProof:e.buffer.decode(d)})},Up={preencode(o,n){o.end++,d>=7&&n.otaResyncPrivateProfileBump&&e.uint.preencode(o,n.otaResyncPrivateProfileBump)},encode(o,n){const c=d>=7&&n.otaResyncPrivateProfileBump?1:0;e.uint.encode(o,c),d>=7&&n.otaResyncPrivateProfileBump&&e.uint.encode(o,n.otaResyncPrivateProfileBump)},decode(o){const n=e.uint.decode(o);return{otaResyncPrivateProfileBump:d>=7&&1&n?e.uint.decode(o):0}}},Jp={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.buffer.preencode(d,o.proof),e.uint.preencode(d,o.createdAt)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.buffer.encode(d,o.proof),e.uint.encode(d,o.createdAt)},decode:d=>({deviceKey:e.fixed32.decode(d),proof:e.buffer.decode(d),createdAt:e.uint.decode(d)})},Wp=de,Gp={preencode(d,o){Wp.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Wp.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Wp.decode(d),callKey:e.fixed32.decode(d)})},Qp=de,Xp={preencode(d,o){Qp.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.deviceKey)},encode(d,o){Qp.encode(d,o.header),e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.deviceKey)},decode:d=>({header:Qp.decode(d),callKey:e.fixed32.decode(d),deviceKey:e.fixed32.decode(d)})},Yp=e.frame(Nn),Zp=e.array(e.frame(Dn)),$p={preencode(e,d){Yp.preencode(e,d.digest),Zp.preencode(e,d.mine)},encode(e,d){Yp.encode(e,d.digest),Zp.encode(e,d.mine)},decode:e=>({digest:Yp.decode(e),mine:Zp.decode(e)})},_p=de,eu={preencode(d,o){_p.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){_p.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:_p.decode(d),callKey:e.fixed32.decode(d)})},du=de,ou={preencode(d,o){du.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){du.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:du.decode(d),callKey:e.fixed32.decode(d)})},nu={preencode(o,n){o.end++,d>=9&&n.profileSnoozeTime&&e.uint.preencode(o,n.profileSnoozeTime)},encode(o,n){const c=(d>=9&&n.disableReadReceipts?1:0)|(d>=9&&n.stripAttachmentMetadata?2:0)|(d>=9&&n.profileSnoozeTime?4:0);e.uint.encode(o,c),d>=9&&n.profileSnoozeTime&&e.uint.encode(o,n.profileSnoozeTime)},decode(o){const n=e.uint.decode(o);return{disableReadReceipts:d>=9&&!!(1&n),stripAttachmentMetadata:d>=9&&!!(2&n),profileSnoozeTime:d>=9&&4&n?e.uint.decode(o):0}}},cu={preencode(o,n){o.end++,d>=9&&n.maxPeers&&e.uint.preencode(o,n.maxPeers)},encode(o,n){const c=d>=9&&n.maxPeers?1:0;e.uint.encode(o,c),d>=9&&n.maxPeers&&e.uint.encode(o,n.maxPeers)},decode(o){const n=e.uint.decode(o);return{maxPeers:d>=9&&1&n?e.uint.decode(o):0}}},ru=de,tu={preencode(e,d){ru.preencode(e,d.header),n.preencode(e,d.oplog)},encode(e,d){ru.encode(e,d.header),n.encode(e,d.oplog)},decode:e=>({header:ru.decode(e),oplog:n.decode(e)})},iu=de,au={preencode(e,d){iu.preencode(e,d.header)},encode(e,d){iu.encode(e,d.header)},decode:e=>({header:iu.decode(e)})},su={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.timestamp)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.timestamp)},decode:d=>({memberKey:e.fixed32.decode(d),timestamp:e.uint.decode(d)})},pu=de,uu={preencode(o,n){pu.preencode(o,n.header),e.fixed32.preencode(o,n.memberKey),o.end++,d>=10&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=d>=10&&n.alias?1:0;pu.encode(o,n.header),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,c),d>=10&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=pu.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{header:n,memberKey:c,alias:d>=10&&1&r?e.string.decode(o):null}}},lu={preencode(d,o){e.uint.preencode(d,o.streams)},encode(d,o){e.uint.encode(d,o.streams)},decode:d=>({streams:e.uint.decode(d)})},fu={preencode(d,o){e.fixed32.preencode(d,o.streamKey),e.string.preencode(d,o.mediaStreamId),e.string.preencode(d,o.type),d.end++},encode(o,n){const c=d>=12&&n.muted?1:0;e.fixed32.encode(o,n.streamKey),e.string.encode(o,n.mediaStreamId),e.string.encode(o,n.type),e.uint.encode(o,c)},decode(o){const n=e.fixed32.decode(o),c=e.string.decode(o),r=e.string.decode(o),t=e.uint.decode(o);return{streamKey:n,mediaStreamId:c,type:r,muted:d>=12&&!!(1&t)}}},mu=de,yu={preencode(d,o){mu.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.streamKey),d.end++},encode(o,n){const c=d>=12&&n.muted?1:0;mu.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.streamKey),e.uint.encode(o,c)},decode(o){const n=mu.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o);return{header:n,callKey:c,streamKey:r,muted:d>=12&&!!(1&t)}}},xu={preencode(d,o){e.uint.preencode(d,o.statusKey),d.end++},encode(o,n){const c=d>=12&&n.muted?1:0;e.uint.encode(o,n.statusKey),e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o),c=e.uint.decode(o);return{statusKey:n,muted:d>=12&&!!(1&c)}}},bu={preencode(n,c){e.fixed32.preencode(n,c.key),n.end++,d>=13&&c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),d>=13&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=(d>=13&&c.encryptionKey?1:0)|(d>=13&&c.bootFrom?2:0);e.fixed32.encode(n,c.key),e.uint.encode(n,r),d>=13&&c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),d>=13&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.uint.decode(n);return{key:c,encryptionKey:d>=13&&1&r?e.buffer.decode(n):null,bootFrom:d>=13&&2&r?o.decode(n):null}}},vu={preencode(d,o){e.fixed32.preencode(d,o.hash)},encode(d,o){e.fixed32.encode(d,o.hash)},decode:d=>({hash:e.fixed32.decode(d)})},gu={preencode(d,o){e.fixed32.preencode(d,o.hash),e.buffer.preencode(d,o.data)},encode(d,o){e.fixed32.encode(d,o.hash),e.buffer.encode(d,o.data)},decode:d=>({hash:e.fixed32.decode(d),data:e.buffer.decode(d)})},ku={preencode(n,c){o.preencode(n,c.autobeeMigrationHead),n.end++,d>=13&&c.legacyViewHead&&o.preencode(n,c.legacyViewHead),d>=13&&c.dbViewHead&&o.preencode(n,c.dbViewHead),d>=13&&c.blobsViewHead&&o.preencode(n,c.blobsViewHead),e.uint.preencode(n,c.createdAt)},encode(n,c){const r=(d>=13&&c.legacyViewHead?1:0)|(d>=13&&c.dbViewHead?2:0)|(d>=13&&c.blobsViewHead?4:0);o.encode(n,c.autobeeMigrationHead),e.uint.encode(n,r),d>=13&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=13&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=13&&c.blobsViewHead&&o.encode(n,c.blobsViewHead),e.uint.encode(n,c.createdAt)},decode(n){const c=o.decode(n),r=e.uint.decode(n);return{autobeeMigrationHead:c,legacyViewHead:d>=13&&1&r?o.decode(n):null,dbViewHead:d>=13&&2&r?o.decode(n):null,blobsViewHead:d>=13&&4&r?o.decode(n):null,createdAt:e.uint.decode(n)}}},Ku=de,hu={preencode(e,n){Ku.preencode(e,n.header),o.preencode(e,n.head),e.end++,d>=13&&n.legacyViewHead&&o.preencode(e,n.legacyViewHead),d>=13&&n.dbViewHead&&o.preencode(e,n.dbViewHead),d>=13&&n.blobsViewHead&&o.preencode(e,n.blobsViewHead)},encode(n,c){const r=(d>=13&&c.legacyViewHead?1:0)|(d>=13&&c.dbViewHead?2:0)|(d>=13&&c.blobsViewHead?4:0);Ku.encode(n,c.header),o.encode(n,c.head),e.uint.encode(n,r),d>=13&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=13&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=13&&c.blobsViewHead&&o.encode(n,c.blobsViewHead)},decode(n){const c=Ku.decode(n),r=o.decode(n),t=e.uint.decode(n);return{header:c,head:r,legacyViewHead:d>=13&&1&t?o.decode(n):null,dbViewHead:d>=13&&2&t?o.decode(n):null,blobsViewHead:d>=13&&4&t?o.decode(n):null}}},wu={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.fixed32.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.seed),n.end++,d>=13&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=d>=13&&c.bootFrom?1:0;e.fixed32.encode(n,c.roomKey),e.fixed32.encode(n,c.encryptionKey),e.fixed32.encode(n,c.seed),e.uint.encode(n,r),d>=13&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.fixed32.decode(n),t=e.fixed32.decode(n),i=e.uint.decode(n);return{roomKey:c,encryptionKey:r,seed:t,bootFrom:d>=13&&1&i?o.decode(n):null}}},Pu=bd,Tu={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.fixed32.preencode(d,o.deviceKey),e.uint.preencode(d,o.deviceLength),e.uint.preencode(d,o.clock),Pu.preencode(d,o.status)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,o.deviceLength),e.uint.encode(d,o.clock),Pu.encode(d,o.status)},decode:d=>({memberKey:e.fixed32.decode(d),deviceKey:e.fixed32.decode(d),deviceLength:e.uint.decode(d),clock:e.uint.decode(d),status:Pu.decode(d)})},Ru={preencode(d,o){e.fixed32.preencode(d,o.hash),e.buffer.preencode(d,o.blob)},encode(d,o){e.fixed32.encode(d,o.hash),e.buffer.encode(d,o.blob)},decode:d=>({hash:e.fixed32.decode(d),blob:e.buffer.decode(d)})},Au=vc,Su=gc,Iu=tc,Mu={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),Au.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,d>=13&&c.initiator&&o.preencode(n,c.initiator),d>=13&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=13&&c.identitySwap&&Su.preencode(n,c.identitySwap),d>=13&&c.identitySwapV2&&Iu.preencode(n,c.identitySwapV2),d>=13&&c.contact&&e.fixed32.preencode(n,c.contact)},encode(n,c){const r=(d>=13&&c.initiator?1:0)|(d>=13&&c.bootFrom?2:0)|(d>=13&&c.identitySwap?4:0)|(d>=13&&c.identitySwapV2?8:0)|(d>=13&&c.contact?16:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),Au.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,r),d>=13&&c.initiator&&o.encode(n,c.initiator),d>=13&&c.bootFrom&&o.encode(n,c.bootFrom),d>=13&&c.identitySwap&&Su.encode(n,c.identitySwap),d>=13&&c.identitySwapV2&&Iu.encode(n,c.identitySwapV2),d>=13&&c.contact&&e.fixed32.encode(n,c.contact)},decode(n){const c=e.fixed32.decode(n),r=e.buffer.decode(n),t=e.fixed32.decode(n),i=Au.decode(n),a=e.uint.decode(n),s=e.uint.decode(n);return{roomKey:c,encryptionKey:r,mailbox:t,status:i,clock:a,initiator:d>=13&&1&s?o.decode(n):null,bootFrom:d>=13&&2&s?o.decode(n):null,identitySwap:d>=13&&4&s?Su.decode(n):null,identitySwapV2:d>=13&&8&s?Iu.decode(n):null,contact:d>=13&&16&s?e.fixed32.decode(n):null}}},Fu=de,qu={preencode(n,c){Fu.preencode(n,c.header),e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),n.end++,d>=13&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=13&&c.initiator&&o.preencode(n,c.initiator),d>=13&&c.dm&&e.fixed32.preencode(n,c.dm)},encode(n,c){const r=(d>=13&&c.bootFrom?1:0)|(d>=13&&c.initiator?2:0)|(d>=13&&c.dm?4:0)|(d>=13&&c.isReadOnly?8:0);Fu.encode(n,c.header),e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),e.uint.encode(n,r),d>=13&&c.bootFrom&&o.encode(n,c.bootFrom),d>=13&&c.initiator&&o.encode(n,c.initiator),d>=13&&c.dm&&e.fixed32.encode(n,c.dm)},decode(n){const c=Fu.decode(n),r=e.fixed32.decode(n),t=e.buffer.decode(n),i=e.fixed32.decode(n),a=e.uint.decode(n);return{header:c,roomKey:r,encryptionKey:t,mailbox:i,bootFrom:d>=13&&1&a?o.decode(n):null,initiator:d>=13&&2&a?o.decode(n):null,dm:d>=13&&4&a?e.fixed32.decode(n):null,isReadOnly:d>=13&&!!(8&a)}}},Cu={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),n.end++,d>=13&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=13&&c.initiator&&o.preencode(n,c.initiator)},encode(n,c){const r=(d>=13&&c.bootFrom?1:0)|(d>=13&&c.initiator?2:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.uint.encode(n,r),d>=13&&c.bootFrom&&o.encode(n,c.bootFrom),d>=13&&c.initiator&&o.encode(n,c.initiator)},decode(n){const c=e.fixed32.decode(n),r=e.buffer.decode(n),t=e.uint.decode(n);return{roomKey:c,encryptionKey:r,bootFrom:d>=13&&1&t?o.decode(n):null,initiator:d>=13&&2&t?o.decode(n):null}}},Vu={preencode(d,o){e.fixed32.preencode(d,o.roomKey),Kl.preencode(d,o.head),e.uint.preencode(d,o.timestamp),d.end++},encode(o,n){const c=d>=13&&n.incremental?1:0;e.fixed32.encode(o,n.roomKey),Kl.encode(o,n.head),e.uint.encode(o,n.timestamp),e.uint.encode(o,c)},decode(o){const n=e.fixed32.decode(o),c=Kl.decode(o),r=e.uint.decode(o),t=e.uint.decode(o);return{roomKey:n,head:c,timestamp:r,incremental:d>=13&&!!(1&t)}}},Hu={preencode(o,n){o.end++,d>=13&&n.key&&e.fixed32.preencode(o,n.key),e.uint.preencode(o,n.length)},encode(o,n){const c=d>=13&&n.key?1:0;e.uint.encode(o,c),d>=13&&n.key&&e.fixed32.encode(o,n.key),e.uint.encode(o,n.length)},decode(o){const n=e.uint.decode(o);return{key:d>=13&&1&n?e.fixed32.decode(o):null,length:e.uint.decode(o)}}},Du={preencode(n,c){e.fixed32.preencode(n,c.roomKey),n.end++,d>=13&&c.legacyViewHead&&o.preencode(n,c.legacyViewHead),d>=13&&c.dbViewHead&&o.preencode(n,c.dbViewHead),d>=13&&c.blobsViewHead&&o.preencode(n,c.blobsViewHead),d>=13&&c.autobeeMigrationHead&&o.preencode(n,c.autobeeMigrationHead)},encode(n,c){const r=(d>=13&&c.legacyViewHead?1:0)|(d>=13&&c.dbViewHead?2:0)|(d>=13&&c.blobsViewHead?4:0)|(d>=13&&c.autobeeMigrationHead?8:0);e.fixed32.encode(n,c.roomKey),e.uint.encode(n,r),d>=13&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=13&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=13&&c.blobsViewHead&&o.encode(n,c.blobsViewHead),d>=13&&c.autobeeMigrationHead&&o.encode(n,c.autobeeMigrationHead)},decode(n){const c=e.fixed32.decode(n),r=e.uint.decode(n);return{roomKey:c,legacyViewHead:d>=13&&1&r?o.decode(n):null,dbViewHead:d>=13&&2&r?o.decode(n):null,blobsViewHead:d>=13&&4&r?o.decode(n):null,autobeeMigrationHead:d>=13&&8&r?o.decode(n):null}}},Lu={preencode(d,o){e.fixed32.preencode(d,o.id),e.fixed32.preencode(d,o.writerKey),e.buffer.preencode(d,o.blindResponse)},encode(d,o){e.fixed32.encode(d,o.id),e.fixed32.encode(d,o.writerKey),e.buffer.encode(d,o.blindResponse)},decode:d=>({id:e.fixed32.decode(d),writerKey:e.fixed32.decode(d),blindResponse:e.buffer.decode(d)})},ju=de,Eu={preencode(d,o){ju.preencode(d,o.header),e.buffer.preencode(d,o.blindResponse)},encode(d,o){ju.encode(d,o.header),e.buffer.encode(d,o.blindResponse)},decode:d=>({header:ju.decode(d),blindResponse:e.buffer.decode(d)})},Bu=e.frame(qr),zu={preencode(o,n){e.string.preencode(o,n.mnemonic),o.end++,d>=15&&n.profileDiscoveryTimeout&&e.uint.preencode(o,n.profileDiscoveryTimeout),d>=15&&n.privateProfileKey&&e.fixed32.preencode(o,n.privateProfileKey),d>=15&&n.identity&&Bu.preencode(o,n.identity)},encode(o,n){const c=(d>=15&&n.profileDiscoveryTimeout?1:0)|(d>=15&&n.privateProfileKey?2:0)|(d>=15&&n.identity?4:0);e.string.encode(o,n.mnemonic),e.uint.encode(o,c),d>=15&&n.profileDiscoveryTimeout&&e.uint.encode(o,n.profileDiscoveryTimeout),d>=15&&n.privateProfileKey&&e.fixed32.encode(o,n.privateProfileKey),d>=15&&n.identity&&Bu.encode(o,n.identity)},decode(o){const n=e.string.decode(o),c=e.uint.decode(o);return{mnemonic:n,profileDiscoveryTimeout:d>=15&&1&c?e.uint.decode(o):0,privateProfileKey:d>=15&&2&c?e.fixed32.decode(o):null,identity:d>=15&&4&c?Bu.decode(o):null}}},Ou=de,Nu={preencode(e,d){Ou.preencode(e,d.header)},encode(e,d){Ou.encode(e,d.header)},decode:e=>({header:Ou.decode(e)})},Uu=de,Ju={preencode(o,c){Uu.preencode(o,c.header),n.preencode(o,c.oplog),e.uint.preencode(o,c.index),o.end++,d>=16&&c.displayType&&Xo.preencode(o,c.displayType)},encode(o,c){const r=d>=16&&c.displayType?1:0;Uu.encode(o,c.header),n.encode(o,c.oplog),e.uint.encode(o,c.index),e.uint.encode(o,r),d>=16&&c.displayType&&Xo.encode(o,c.displayType)},decode(o){const c=Uu.decode(o),r=n.decode(o),t=e.uint.decode(o),i=e.uint.decode(o);return{header:c,oplog:r,index:t,displayType:d>=16&&1&i?Xo.decode(o):0}}},Wu=de,Gu=no,Qu={preencode(d,o){Wu.preencode(d,o.header),n.preencode(d,o.oplog),Xo.preencode(d,o.displayType),e.uint.preencode(d,o.index),Gu.preencode(d,o.preview)},encode(d,o){Wu.encode(d,o.header),n.encode(d,o.oplog),Xo.encode(d,o.displayType),e.uint.encode(d,o.index),Gu.encode(d,o.preview)},decode:d=>({header:Wu.decode(d),oplog:n.decode(d),displayType:Xo.decode(d),index:e.uint.decode(d),preview:Gu.decode(d)})},Xu=de,Yu={preencode(d,o){Xu.preencode(d,o.header),n.preencode(d,o.oplog),Xo.preencode(d,o.displayType),e.uint.preencode(d,o.index)},encode(d,o){Xu.encode(d,o.header),n.encode(d,o.oplog),Xo.encode(d,o.displayType),e.uint.encode(d,o.index)},decode:d=>({header:Xu.decode(d),oplog:n.decode(d),displayType:Xo.decode(d),index:e.uint.decode(d)})},Zu=e.frame(w),$u=e.frame(lu),_u=Zu,el=e.frame(le),dl=Zu,ol=el,nl=e.frame(wu),cl=el,rl=e.frame(wd),tl=e.frame(mp),il=tl,al=Zu,sl=Zu,pl=e.frame(Ic),ul=pl,ll=pl,fl=e.frame(Cp),ml=e.frame($p),yl=e.frame(nu),xl=e.frame(Hu),bl=xl,vl=el,gl=e.array(e.frame(fu)),kl=gl,Kl=xl;function hl(e){switch(e){case"@keet/head":return o;case"@keet/oplog-id":return n;case"@keet/encryption-keypair":return c;case"@keet/signing-keypair":return r;case"@keet/room-keys":return t;case"@keet/operation-header":return i;case"@keet/blob-pointer":return a;case"@keet/file-dimensions":return s;case"@keet/file-metadata":return u;case"@keet/external-drive-pointer":return l;case"@keet/external-blob-pointer":return f;case"@keet/file-pointer":return x;case"@keet/file":return g;case"@keet/image-file":return w;case"@keet/file-status":return P;case"@keet/file-record":return A;case"@keet/device-status":return S;case"@keet/member-status":return I;case"@keet/member-moderation-status":return M;case"@keet/abi":return F;case"@keet/device-stats":return q;case"@keet/member-stats":return C;case"@keet/chat-stats":return V;case"@keet/file-stats":return H;case"@keet/stats":return B;case"@keet/room-type":return O;case"@keet/system-settings":return N;case"@keet/system-digest":return W;case"@keet/room-seed":return G;case"@keet/room-capabilities":return Q;case"@keet/room-supported-language":return Y;case"@keet/room-config":return _;case"@keet/blind-peer":return ee;case"@keet/add-blind-peer-operation":return ne;case"@keet/remove-blind-peer-operation":return re;case"@keet/identity-attestation":return te;case"@keet/device-invitation":return ie;case"@keet/device":return pe;case"@keet/member-profile":return ue;case"@keet/device-profile":return le;case"@keet/member-update":return me;case"@keet/device-update":return ye;case"@keet/member-contact-info":return be;case"@keet/signed-pairing-data":return ve;case"@keet/device-request-identity":return ge;case"@keet/device-response-identity":return ke;case"@keet/device-identity":return Ke;case"@keet/device-request-with-invitation":return Te;case"@keet/device-request-with-invitation-and-proof":return Ae;case"@keet/device-request-with-member-proof":return Me;case"@keet/device-request":return Ce;case"@keet/device-response":return De;case"@keet/invitation-metadata":return Le;case"@keet/invitation":return Be;case"@keet/add-invitation-operation":return Ne;case"@keet/remove-invitation-operation":return Je;case"@keet/sendable-room-invitation":return We;case"@keet/readonly-room-invitation":return Ge;case"@keet/sendable-identity-invitation":return Qe;case"@keet/sendable-contact-invitation":return Xe;case"@keet/sendable-invitation":return dd;case"@keet/add-device-operation":return nd;case"@keet/update-device-operation":return rd;case"@keet/remove-device-operation":return id;case"@keet/start-indexing-operation":return ad;case"@keet/stop-indexing-operation":return sd;case"@keet/join-request":return ud;case"@keet/accept-join-request-operation":return md;case"@keet/reject-join-request-operation":return xd;case"@keet/member":return gd;case"@keet/full-member":return hd;case"@keet/member-proofs":return wd;case"@keet/update-member-operation":return Rd;case"@keet/change-member-status-operation":return Id;case"@keet/change-member-role-operation":return Fd;case"@keet/remove-member-operation":return Cd;case"@keet/member-activity":return Vd;case"@keet/member-joined-event":return Hd;case"@keet/member-left-event":return Dd;case"@keet/member-removed-event":return Ld;case"@keet/title-changed-chat-event":return jd;case"@keet/chat-event":return Nd;case"@keet/sendable-event":return Ud;case"@keet/display-range":return Jd;case"@keet/display-content-range":return Gd;case"@keet/mention-display-item":return Xd;case"@keet/translation-display-item":return Zd;case"@keet/link-preview":return eo;case"@keet/display-link-item":return co;case"@keet/display":return yo;case"@keet/oplog-message":return go;case"@keet/index-message":return ho;case"@keet/full-index-message":return To;case"@keet/message-status":return Ro;case"@keet/message-index-id":return Ao;case"@keet/thread":return Io;case"@keet/chat-message-record":return Co;case"@keet/full-chat-message-record":return Lo;case"@keet/add-chat-message-operation":return Bo;case"@keet/remove-chat-message-operation":return Oo;case"@keet/update-chat-message-operation":return Jo;case"@keet/pin-chat-message-operation":return Go;case"@keet/display-type":return Xo;case"@keet/add-file-preview-operation":return Zo;case"@keet/reaction":return $o;case"@keet/reactions-summary":return _o;case"@keet/reactions-digest":return dn;case"@keet/add-reaction-operation":return nn;case"@keet/remove-reaction-operation":return rn;case"@keet/update-room-config-operation":return sn;case"@keet/group-member":return pn;case"@keet/user-registry-info":return un;case"@keet/room-identity":return fn;case"@keet/genesis-operation":return Kn;case"@keet/upgrade-operation":return wn;case"@keet/migrate-abi-operation":return Tn;case"@keet/system-settings-keys":return An;case"@keet/update-system-settings-operation":return Mn;case"@keet/test-increment-operation":return qn;case"@keet/test-collection-record-1":return Cn;case"@keet/label-type":return Hn;case"@keet/chat-label":return Dn;case"@keet/add-chat-label-operation":return jn;case"@keet/remove-chat-label-operation":return Bn;case"@keet/chat-label-summary":return zn;case"@keet/chat-label-digest":return Nn;case"@keet/update-read-length-operation":return Jn;case"@keet/read-length":return Wn;case"@keet/tmp-removed-member":return Gn;case"@keet-private-id/contact":return Xn;case"@keet-private-id/v3-room-migration-info":return Yn;case"@keet-private-id/run-v3-migration-operation":return _n;case"@keet-private-id/update-identity-operation":return dc;case"@keet-private-id/counters":return oc;case"@keet-private-id/stats":return nc;case"@keet-private-id/add-entropy-operation":return cc;case"@keet-private-id/pending-invitation-identity":return rc;case"@keet-private-id/pending-invitation":return ic;case"@keet-private-id/resolve-pending-invitation-operation":return sc;case"@keet-private-id/add-pending-invitation-operation":return lc;case"@keet-private-id/remove-pending-invitation-operation":return mc;case"@keet-private-id/identity-swap":return yc;case"@keet-private-id/identity-swap-v2":return xc;case"@keet-private-id/room-status":return bc;case"@keet-private-id/room":return Kc;case"@keet-private-id/add-room-operation":return wc;case"@keet-private-id/remove-room-operation":return Tc;case"@keet-private-id/update-room-status-operation":return Sc;case"@keet-private-id/contact-status":return Ic;case"@keet-private-id/contact-record":return Fc;case"@keet-private-id/add-contact-operation":return Vc;case"@keet-private-id/update-contact-status-operation":return Dc;case"@keet-private-id/remove-contact-operation":return jc;case"@keet-private-id/activate-contact-room-operation":return Bc;case"@keet-private-id/contact-request-status":return zc;case"@keet-private-id/contact-request-body":return Uc;case"@keet-private-id/contact-request":return Wc;case"@keet-private-id/contact-request-record":return Zc;case"@keet-private-id/add-contact-request-operation":return _c;case"@keet-private-id/update-contact-request-status-operation":return or;case"@keet-private-id/profile-discovery-record-v1":return nr;case"@keet-private-id/profile-discovery-record":return cr;case"@keet-private-id/unreads":return rr;case"@keet-private-id/add-unreads-key-operation":return ir;case"@keet-private-id/remove-unreads-key-operation":return sr;case"@keet-private-id/settings":return pr;case"@keet-private-id/user-settings-key":return lr;case"@keet-private-id/update-settings-operation":return yr;case"@local/background-sync-room":return xr;case"@local/stats":return br;case"@local/migration-status":return vr;case"@local/v3-private-profile-migration":return kr;case"@local/v3-room-migration":return wr;case"@local/room-migration-stats":return Pr;case"@local/room-migration":return Rr;case"@local/identity-status":return Ar;case"@local/identity-swap":return Sr;case"@local/identity-record":return qr;case"@local/tasks":return Vr;case"@local/room-keys":return Hr;case"@local/join-room-invitation-task":return Lr;case"@local/join-room-response-task":return jr;case"@local/fast-forward-to":return Er;case"@local/add-room-fields":return Br;case"@local/join-room-keys-task":return Or;case"@local/create-room-task":return Ur;case"@local/leave-room-task":return Jr;case"@local/clear-room-task":return Wr;case"@local/restore-identity-task":return Gr;case"@local/send-contact-request-task":return Xr;case"@local/migrate-v2-room-task":return Yr;case"@local/task":return tt;case"@local/shared-invitation":return at;case"@local/room-status":return st;case"@local/room-timestamps":return pt;case"@local/room":return Tt;case"@local/room-preferences":return At;case"@local/room-metadata":return St;case"@local/writer":return It;case"@local/writer-append":return Mt;case"@local/member":return qt;case"@local/device":return Vt;case"@local/file":return Dt;case"@local/debug-flag":return Lt;case"@local/debug":return Et;case"@local/hyperdht-record":return zt;case"@local/unread":return Ot;case"@local/error-record-details":return Nt;case"@local/error-record":return Jt;case"@local/keet-state":return Gt;case"@local/file-stats":return Qt;case"@api/request-header":return Xt;case"@api/response-header":return Yt;case"@api/subscription-request-header":return Zt;case"@api/subscription-response-header":return $t;case"@api/boot-request":return ei;case"@api/boot-response":return oi;case"@api/self-destruct-request":return ci;case"@api/core/have":return ri;case"@api/core/create-room-request":return si;case"@api/core/create-room-response":return ui;case"@api/core/activate-room-request":return fi;case"@api/core/deactivate-room-request":return yi;case"@api/core/leave-room-request":return bi;case"@api/core/leave-room-response":return gi;case"@api/core/update-room-config-request":return hi;case"@api/core/update-room-settings-request":return Ti;case"@api/core/update-room-status-request":return Si;case"@api/core/add-chat-message-request":return Fi;case"@api/core/add-chat-message-response":return Ci;case"@api/core/edit-chat-message-request":return Di;case"@api/core/edit-chat-message-response":return ji;case"@api/core/remove-chat-message-request":return Bi;case"@api/core/remove-chat-message-response":return Oi;case"@api/core/add-chat-reaction-request":return Ui;case"@api/core/add-chat-reaction-response":return Wi;case"@api/core/remove-chat-reaction-request":return Qi;case"@api/core/remove-chat-reaction-response":return Yi;case"@api/core/want-lobby":return Zi;case"@api/core/unwant-lobby":return $i;case"@api/core/want-room-info":return ea;case"@api/core/want-chat":return da;case"@api/core/unwant-chat":return oa;case"@api/core/want-members":return na;case"@api/core/unwant-members":return ca;case"@api/core/lobby-record":return ra;case"@api/core/lobby-record-change-type":return ia;case"@api/core/lobby":return sa;case"@api/core/lobby-room":return pa;case"@api/core/room-role":return fa;case"@api/core/room-info":return ba;case"@api/core/room-info-status":return ga;case"@api/core/room-info-digest":return Ka;case"@api/core/room-info-config":return wa;case"@api/core/room-info-role":return Ta;case"@api/core/room-info-last-message":return Ra;case"@api/core/member":return Sa;case"@api/core/device":return Ma;case"@api/core/member-list-add":return Fa;case"@api/core/member-list-remove":return qa;case"@api/core/chat-reset":return Va;case"@api/core/message-timestamps":return Ha;case"@api/core/message":return Ba;case"@api/core/message-info":return Na;case"@api/core/message-info-chat":return Ja;case"@api/core/message-info-member":return Ga;case"@api/core/message-info-role":return Ya;case"@api/core/message-info-reactions":return $a;case"@api/core/reactions":return es;case"@api/core/want-pairing":return ds;case"@api/core/unwant-pairing":return os;case"@api/core/pending-invitations":return cs;case"@api/core/join-request":return ts;case"@api/core/join-requests":return as;case"@api/core/pairing":return us;case"@api/core/start-pairing-request":return fs;case"@api/core/start-pairing-response":return ys;case"@api/core/invitation-permissions":return xs;case"@api/core/create-room-invitation-request":return gs;case"@api/core/create-room-invitation-response":return Ks;case"@api/core/create-identity-invitation-request":return ws;case"@api/core/create-identity-invitation-response":return Ts;case"@api/core/accept-join-request-request":return Ss;case"@api/core/accept-join-request-response":return Ms;case"@api/core/reject-join-request-request":return Cs;case"@api/core/reject-join-request-response":return Hs;case"@api/core/stop-pairing-request":return Ls;case"@api/core/stop-pairing-response":return Es;case"@api/core/update-profile-request":return zs;case"@api/core/want-identity":return Os;case"@api/core/unwant-identity":return Ns;case"@api/core/identity-status":return Us;case"@api/core/identity":return Gs;case"@api/core/identity-member":return Qs;case"@api/core/identity-device":return Xs;case"@api/debug/enable-request":return Zs;case"@api/debug/enable-response":return _s;case"@api/debug/disable-request":return dp;case"@api/debug/disable-response":return np;case"@keet/member-label-type":return rp;case"@keet/member-label":return tp;case"@keet/add-member-label-operation":return ap;case"@keet/member-label-summary":return sp;case"@keet/member-label-digest":return up;case"@keet/move-indexer-operation":return fp;case"@keet/location-shared-event":return mp;case"@keet/start-call":return bp;case"@keet/join-call":return kp;case"@keet/leave-call":return hp;case"@keet/end-call":return Pp;case"@keet/add-call-stream":return Rp;case"@keet/remove-call-stream":return Sp;case"@keet/call-record":return Ip;case"@keet/call-member-record":return Mp;case"@keet/call-device-record":return Fp;case"@keet/call-stream-record":return qp;case"@local/active-call":return Cp;case"@local/file-gc-info":return Vp;case"@keet/build-type":return Dp;case"@keet/test-crash-operation":return jp;case"@keet/test-dispatch-error-operation":return Bp;case"@local/environment-record":return zp;case"@keet-private-id/shorten-device-attestation-operation":return Np;case"@local/ota-actions":return Up;case"@local/device-attestation":return Jp;case"@keet/call-device-heartbeat":return Gp;case"@keet/remove-call-device":return Xp;case"@local/chat-labels":return $p;case"@keet/start-call-recording":return eu;case"@keet/stop-call-recording":return ou;case"@local/settings":return nu;case"@local/hyperswarm-record":return cu;case"@keet/dismiss-chat-reports-operation":return tu;case"@keet/update-typing-indicator-operation":return au;case"@keet/typing-indicator":return su;case"@keet-private-id/update-contact-alias-operation":return uu;case"@keet/call-stats":return lu;case"@keet/call-stream-input":return fu;case"@keet/update-call-stream":return yu;case"@keet/call-stream-status-record":return xu;case"@keet/room-keys-v2":return bu;case"@keet/blob-pointer-v2":return vu;case"@keet/blob":return gu;case"@keet/autobee-migration":return ku;case"@keet/autobee-migration-operation":return hu;case"@keet/readonly-room-invitation-v2":return wu;case"@keet/admin-last-seen":return Tu;case"@keet/blob-record":return Ru;case"@keet-private-id/room-v2":return Mu;case"@keet-private-id/add-room-operation-v2":return qu;case"@local/room-keys/v2":return Cu;case"@local/room-update":return Vu;case"@local/view-head":return Hu;case"@local/autobee-migration":return Du;case"@keet-private-id/pending-invitation-response":return Lu;case"@keet-private-id/resolve-pending-invitation-operation-v2":return Eu;case"@local/pending-recovery":return zu;case"@keet/claim-admin-devices-operation":return Nu;case"@keet/remove-file-preview-operation":return Ju;case"@keet/add-link-preview-operation":return Qu;case"@keet/remove-link-preview-operation":return Yu;default:throw new Error("Encoder not found "+e)}}function wl(e,o=17){const n=hl(e);return{preencode(e,c){d=o,n.preencode(e,c)},encode(e,c){d=o,n.encode(e,c)},decode:e=>(d=o,n.decode(e))}}const Pl=wl;module.exports={resolveStruct:Pl,getStruct:wl,getEnum:function(e){switch(e){case"@keet/room-type":return z;case"@keet/room-supported-language":return X;case"@keet/display-type":return Qo;case"@keet/system-settings-keys":return Rn;case"@keet/label-type":return Vn;case"@keet-private-id/user-settings-key":return ur;case"@local/tasks":return Cr;case"@local/keet-state":return Wt;case"@api/core/lobby-record-change-type":return ta;case"@keet/member-label-type":return cp;case"@keet/build-type":return Hp;default:throw new Error("Enum not found "+e)}},getEncoding:hl,encode:function(o,n,c=17){return d=c,e.encode(hl(o),n)},decode:function(o,n,c=17){return d=c,e.decode(hl(o),n)},setVersion:function(e){d=e},version:d};
@holepunchto/keet-core/schema/spec/api/hyperschema/index.js +1 -1
……@@ -1 +1 @@
1const{c:e}=require("hyperschema/runtime");let d=15;const o={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.length)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.length)},decode:d=>({key:e.fixed32.decode(d),length:e.uint.decode(d)})},n={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.seq)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.seq)},decode:d=>({key:e.fixed32.decode(d),seq:e.uint.decode(d)})},c={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.secretKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.secretKey)},decode:d=>({publicKey:e.fixed32.decode(d),secretKey:e.fixed32.decode(d)})},r={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed64.preencode(d,o.secretKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed64.encode(d,o.secretKey)},decode:d=>({publicKey:e.fixed32.decode(d),secretKey:e.fixed64.decode(d)})},t={preencode(n,c){e.fixed32.preencode(n,c.key),n.end++,c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),d>=13&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=(c.encryptionKey?1:0)|(c.fastForwardTo?2:0)|(d>=13&&c.bootFrom?4:0);e.fixed32.encode(n,c.key),e.uint.encode(n,r),c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),d>=13&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.uint.decode(n);return{key:c,encryptionKey:1&r?e.buffer.decode(n):null,fastForwardTo:2&r?e.fixed32.decode(n):null,bootFrom:d>=13&&4&r?o.decode(n):null}}},i={preencode(d,o){e.uint.preencode(d,o.timestamp)},encode(d,o){e.uint.encode(d,o.timestamp)},decode:d=>({timestamp:e.uint.decode(d)})},a={preencode(d,o){e.uint.preencode(d,o.blockOffset),e.uint.preencode(d,o.blockLength),e.uint.preencode(d,o.byteOffset),e.uint.preencode(d,o.byteLength)},encode(d,o){e.uint.encode(d,o.blockOffset),e.uint.encode(d,o.blockLength),e.uint.encode(d,o.byteOffset),e.uint.encode(d,o.byteLength)},decode:d=>({blockOffset:e.uint.decode(d),blockLength:e.uint.decode(d),byteOffset:e.uint.decode(d),byteLength:e.uint.decode(d)})},s={preencode(d,o){e.uint.preencode(d,o.width),e.uint.preencode(d,o.height)},encode(d,o){e.uint.encode(d,o.width),e.uint.encode(d,o.height)},decode:d=>({width:e.uint.decode(d),height:e.uint.decode(d)})},p=e.frame(s),u={preencode(d,o){d.end++,o.name&&e.string.preencode(d,o.name),o.mimetype&&e.string.preencode(d,o.mimetype),o.dimensions&&p.preencode(d,o.dimensions),o.userdata&&e.buffer.preencode(d,o.userdata),o.duration&&e.uint.preencode(d,o.duration)},encode(d,o){const n=(o.name?1:0)|(o.mimetype?2:0)|(o.dimensions?4:0)|(o.userdata?8:0)|(o.duration?16:0)|(o.isPreview?32:0);e.uint.encode(d,n),o.name&&e.string.encode(d,o.name),o.mimetype&&e.string.encode(d,o.mimetype),o.dimensions&&p.encode(d,o.dimensions),o.userdata&&e.buffer.encode(d,o.userdata),o.duration&&e.uint.encode(d,o.duration)},decode(d){const o=e.uint.decode(d);return{name:1&o?e.string.decode(d):null,mimetype:2&o?e.string.decode(d):null,dimensions:4&o?p.decode(d):null,userdata:8&o?e.buffer.decode(d):null,duration:16&o?e.uint.decode(d):0,isPreview:!!(32&o)}}},l={preencode(d,o){e.fixed32.preencode(d,o.key),e.string.preencode(d,o.path),e.uint.preencode(d,o.version),e.uint.preencode(d,o.size)},encode(d,o){e.fixed32.encode(d,o.key),e.string.encode(d,o.path),e.uint.encode(d,o.version),e.uint.encode(d,o.size)},decode:d=>({key:e.fixed32.decode(d),path:e.string.decode(d),version:e.uint.decode(d),size:e.uint.decode(d)})},f={preencode(d,o){e.fixed32.preencode(d,o.key),a.preencode(d,o.blob)},encode(d,o){e.fixed32.encode(d,o.key),a.encode(d,o.blob)},decode:d=>({key:e.fixed32.decode(d),blob:a.decode(d)})},m=e.frame(f),y=e.frame(l),x={preencode(o,n){o.end++,n.inlined&&e.buffer.preencode(o,n.inlined),n.blob&&a.preencode(o,n.blob),n.externalBlob&&m.preencode(o,n.externalBlob),n.externalDrive&&y.preencode(o,n.externalDrive),d>=13&&n.bee&&vu.preencode(o,n.bee)},encode(o,n){const c=(n.inlined?1:0)|(n.blob?2:0)|(n.externalBlob?4:0)|(n.externalDrive?8:0)|(d>=13&&n.bee?16:0);e.uint.encode(o,c),n.inlined&&e.buffer.encode(o,n.inlined),n.blob&&a.encode(o,n.blob),n.externalBlob&&m.encode(o,n.externalBlob),n.externalDrive&&y.encode(o,n.externalDrive),d>=13&&n.bee&&vu.encode(o,n.bee)},decode(o){const n=e.uint.decode(o);return{inlined:1&n?e.buffer.decode(o):null,blob:2&n?a.decode(o):null,externalBlob:4&n?m.decode(o):null,externalDrive:8&n?y.decode(o):null,bee:d>=13&&16&n?vu.decode(o):null}}},b=e.frame(x),v=e.frame(u),g={preencode(d,o){b.preencode(d,o.pointer),d.end++,o.metadata&&v.preencode(d,o.metadata),o.preview&&Ou.preencode(d,o.preview),o.hash&&e.fixed32.preencode(d,o.hash)},encode(d,o){const n=(o.metadata?1:0)|(o.preview?2:0)|(o.hash?4:0);b.encode(d,o.pointer),e.uint.encode(d,n),o.metadata&&v.encode(d,o.metadata),o.preview&&Ou.encode(d,o.preview),o.hash&&e.fixed32.encode(d,o.hash)},decode(d){const o=b.decode(d),n=e.uint.decode(d);return{pointer:o,metadata:1&n?v.decode(d):null,preview:2&n?Ou.decode(d):null,hash:4&n?e.fixed32.decode(d):null}}},K=e.frame(g),k=K,h=K,w={preencode(e,d){e.end++,d.small&&K.preencode(e,d.small),d.medium&&k.preencode(e,d.medium),d.large&&h.preencode(e,d.large)},encode(d,o){const n=(o.small?1:0)|(o.medium?2:0)|(o.large?4:0);e.uint.encode(d,n),o.small&&K.encode(d,o.small),o.medium&&k.encode(d,o.medium),o.large&&h.encode(d,o.large)},decode(d){const o=e.uint.decode(d);return{small:1&o?K.decode(d):null,medium:2&o?k.decode(d):null,large:4&o?h.decode(d):null}}},P={preencode(e,d){e.end++},encode(d,o){const n=o.isDeleted?1:0;e.uint.encode(d,n)},decode:d=>({isDeleted:!!(1&e.uint.decode(d))})},R=e.frame(P),T=K,A={preencode(d,o){e.uint.preencode(d,o.id),n.preencode(d,o.oplog),R.preencode(d,o.status),T.preencode(d,o.file),d.end++,o.version&&e.uint.preencode(d,o.version)},encode(d,o){const c=o.version?1:0;e.uint.encode(d,o.id),n.encode(d,o.oplog),R.encode(d,o.status),T.encode(d,o.file),e.uint.encode(d,c),o.version&&e.uint.encode(d,o.version)},decode:d=>({id:e.uint.decode(d),oplog:n.decode(d),status:R.decode(d),file:T.decode(d),version:1&e.uint.decode(d)?e.uint.decode(d):0})},S={preencode(e,d){e.end++},encode(d,o){const n=(o.isActive?1:0)|(o.isIndexing?2:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isActive:!!(1&o),isIndexing:!!(2&o)}}},I={preencode(d,o){const n=(o.isAdmin?1:0)|(o.isModerator?2:0)|(o.isPending?4:0)|(o.isActive?8:0)|(o.isMuted?16:0)|(o.isBanned?32:0)|(o.isShadowBanned?64:0)|(o.isRemoved?128:0);e.uint.preencode(d,n)},encode(d,o){const n=(o.isAdmin?1:0)|(o.isModerator?2:0)|(o.isPending?4:0)|(o.isActive?8:0)|(o.isMuted?16:0)|(o.isBanned?32:0)|(o.isShadowBanned?64:0)|(o.isRemoved?128:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isAdmin:!!(1&o),isModerator:!!(2&o),isPending:!!(4&o),isActive:!!(8&o),isMuted:!!(16&o),isBanned:!!(32&o),isShadowBanned:!!(64&o),isRemoved:!!(128&o)}}},M={preencode(e,d){e.end++},encode(d,o){const n=(o.isMuted?1:0)|(o.isBanned?2:0)|(o.isShadowBanned?4:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isMuted:!!(1&o),isBanned:!!(2&o),isShadowBanned:!!(4&o)}}},F={preencode(d,o){e.uint.preencode(d,o.version)},encode(d,o){e.uint.encode(d,o.version)},decode:d=>({version:e.uint.decode(d)})},q={preencode(d,o){e.uint.preencode(d,o.total),e.uint.preencode(d,o.active)},encode(d,o){e.uint.encode(d,o.total),e.uint.encode(d,o.active)},decode:d=>({total:e.uint.decode(d),active:e.uint.decode(d)})},C={preencode(d,o){e.uint.preencode(d,o.total),e.uint.preencode(d,o.active),e.uint.preencode(d,o.pending)},encode(d,o){e.uint.encode(d,o.total),e.uint.encode(d,o.active),e.uint.encode(d,o.pending)},decode:d=>({total:e.uint.decode(d),active:e.uint.decode(d),pending:e.uint.decode(d)})},V={preencode(d,o){e.uint.preencode(d,o.clock),e.uint.preencode(d,o.pinned),e.uint.preencode(d,o.threads),e.uint.preencode(d,o.timestamp),d.end++,o.flagsClock&&e.uint.preencode(d,o.flagsClock)},encode(d,o){const n=o.flagsClock?1:0;e.uint.encode(d,o.clock),e.uint.encode(d,o.pinned),e.uint.encode(d,o.threads),e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.flagsClock&&e.uint.encode(d,o.flagsClock)},decode:d=>({clock:e.uint.decode(d),pinned:e.uint.decode(d),threads:e.uint.decode(d),timestamp:e.uint.decode(d),flagsClock:1&e.uint.decode(d)?e.uint.decode(d):0})},H={preencode(d,o){e.uint.preencode(d,o.clock)},encode(d,o){e.uint.encode(d,o.clock)},decode:d=>({clock:e.uint.decode(d)})},D=e.frame(q),L=e.frame(C),j=e.frame(V),E=e.frame(H),B={preencode(e,o){D.preencode(e,o.devices),L.preencode(e,o.members),j.preencode(e,o.chat),E.preencode(e,o.files),e.end++,d>=12&&o.calls&&Nu.preencode(e,o.calls)},encode(o,n){const c=d>=12&&n.calls?1:0;D.encode(o,n.devices),L.encode(o,n.members),j.encode(o,n.chat),E.encode(o,n.files),e.uint.encode(o,c),d>=12&&n.calls&&Nu.encode(o,n.calls)},decode(o){const n=D.decode(o),c=L.decode(o),r=j.decode(o),t=E.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{devices:n,members:c,chat:r,files:t,calls:d>=12&&1&i?Nu.decode(o):null}}},z={Default:1,Broadcast:2,DirectMessage:3},O={preencode(e,d){e.end++},encode(d,o){if(o>3)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},N={preencode(o,n){const c=(n.roomType?1:0)|(n.isExperimental?2:0)|(n.isJoiningDisabled?4:0)|(n.isAppendingDisabled?8:0)|(n.isCallingDisabled?16:0)|(n.isMembershipEventsDisabled?32:0)|(d>=4&&n.isAttachmentsDisabled?64:0)|(d>=4&&n.isLinksDisabled?128:0)|(d>=5&&n.buildType?256:0)|(d>=9&&n.isRoomInviteHidden?512:0);e.uint.preencode(o,c),n.roomType&&O.preencode(o,n.roomType),d>=5&&n.buildType&&Dp.preencode(o,n.buildType)},encode(o,n){const c=(n.roomType?1:0)|(n.isExperimental?2:0)|(n.isJoiningDisabled?4:0)|(n.isAppendingDisabled?8:0)|(n.isCallingDisabled?16:0)|(n.isMembershipEventsDisabled?32:0)|(d>=4&&n.isAttachmentsDisabled?64:0)|(d>=4&&n.isLinksDisabled?128:0)|(d>=5&&n.buildType?256:0)|(d>=9&&n.isRoomInviteHidden?512:0);e.uint.encode(o,c),n.roomType&&O.encode(o,n.roomType),d>=5&&n.buildType&&Dp.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{roomType:1&n?O.decode(o):0,isExperimental:!!(2&n),isJoiningDisabled:!!(4&n),isAppendingDisabled:!!(8&n),isCallingDisabled:!!(16&n),isMembershipEventsDisabled:!!(32&n),isAttachmentsDisabled:d>=4&&!!(64&n),isLinksDisabled:d>=4&&!!(128&n),buildType:d>=5&&256&n?Dp.decode(o):null,isRoomInviteHidden:d>=9&&!!(512&n)}}},U=e.frame(F),J=e.frame(N),W={preencode(d,o){U.preencode(d,o.abi),J.preencode(d,o.settings),e.uint.preencode(d,o.creationTime)},encode(d,o){U.encode(d,o.abi),J.encode(d,o.settings),e.uint.encode(d,o.creationTime)},decode:d=>({abi:U.decode(d),settings:J.decode(d),creationTime:e.uint.decode(d)})},G={preencode(d,o){e.fixed32.preencode(d,o.seed)},encode(d,o){e.fixed32.encode(d,o.seed)},decode:d=>({seed:e.fixed32.decode(d)})},Q={preencode(d,o){c.preencode(d,o.mailboxKeyPair),r.preencode(d,o.discoveryKeyPair),e.fixed32.preencode(d,o.wakeupTopic),e.fixed32.preencode(d,o.swarmTopic)},encode(d,o){c.encode(d,o.mailboxKeyPair),r.encode(d,o.discoveryKeyPair),e.fixed32.encode(d,o.wakeupTopic),e.fixed32.encode(d,o.swarmTopic)},decode:d=>({mailboxKeyPair:c.decode(d),discoveryKeyPair:r.decode(d),wakeupTopic:e.fixed32.decode(d),swarmTopic:e.fixed32.decode(d)})},X={en:"en",it:"it",ru:"ru",es:"es",de:"de"},Y={preencode(e,d){e.end++},encode(d,o){switch(o){case"en":e.uint.encode(d,1);break;case"it":e.uint.encode(d,2);break;case"ru":e.uint.encode(d,3);break;case"es":e.uint.encode(d,4);break;case"de":e.uint.encode(d,5);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"en";case 2:return"it";case 3:return"ru";case 4:return"es";case 5:return"de";default:return null}}},Z=e.array(Y),$=e.array(e.fixed32),_={preencode(d,o){d.end++,o.title&&e.string.preencode(d,o.title),o.avatar&&Uu.preencode(d,o.avatar),o.description&&e.string.preencode(d,o.description),o.supportedLanguages&&Z.preencode(d,o.supportedLanguages),o.blindPeers&&$.preencode(d,o.blindPeers)},encode(d,o){const n=(o.title?1:0)|(o.avatar?2:0)|(o.description?4:0)|(o.supportedLanguages?8:0)|(o.blindPeers?16:0);e.uint.encode(d,n),o.title&&e.string.encode(d,o.title),o.avatar&&Uu.encode(d,o.avatar),o.description&&e.string.encode(d,o.description),o.supportedLanguages&&Z.encode(d,o.supportedLanguages),o.blindPeers&&$.encode(d,o.blindPeers)},decode(d){const o=e.uint.decode(d);return{title:1&o?e.string.decode(d):null,avatar:2&o?Uu.decode(d):null,description:4&o?e.string.decode(d):null,supportedLanguages:8&o?Z.decode(d):null,blindPeers:16&o?$.decode(d):null}}},ee={preencode(d,o){e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.key)},decode:d=>({key:e.fixed32.decode(d)})},de=e.frame(i),oe=e.frame(ee),ne={preencode(e,d){de.preencode(e,d.header),oe.preencode(e,d.peer)},encode(e,d){de.encode(e,d.header),oe.encode(e,d.peer)},decode:e=>({header:de.decode(e),peer:oe.decode(e)})},ce=de,re={preencode(d,o){ce.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){ce.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:ce.decode(d),key:e.fixed32.decode(d)})},te={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.buffer.preencode(d,o.proof)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.buffer.encode(d,o.proof)},decode:d=>({memberKey:e.fixed32.decode(d),proof:e.buffer.decode(d)})},ie={preencode(d,o){e.fixed32.preencode(d,o.id),e.buffer.preencode(d,o.response)},encode(d,o){e.fixed32.encode(d,o.id),e.buffer.encode(d,o.response)},decode:d=>({id:e.fixed32.decode(d),response:e.buffer.decode(d)})},ae=e.frame(S),se=e.frame(ie),pe={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.memberKey),ae.preencode(d,o.status),Ju.preencode(d,o.profile),d.end++,o.invitation&&se.preencode(d,o.invitation)},encode(d,o){const n=o.invitation?1:0;e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.memberKey),ae.encode(d,o.status),Ju.encode(d,o.profile),e.uint.encode(d,n),o.invitation&&se.encode(d,o.invitation)},decode:d=>({key:e.fixed32.decode(d),memberKey:e.fixed32.decode(d),status:ae.decode(d),profile:Ju.decode(d),invitation:1&e.uint.decode(d)?se.decode(d):null})},ue={preencode(d,o){e.uint.preencode(d,o.timestamp),d.end++,o.mailbox&&e.fixed32.preencode(d,o.mailbox),o.displayName&&e.string.preencode(d,o.displayName),o.avatar&&Wu.preencode(d,o.avatar),o.username&&e.string.preencode(d,o.username)},encode(d,o){const n=(o.mailbox?1:0)|(o.displayName?2:0)|(o.avatar?4:0)|(o.username?8:0);e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.mailbox&&e.fixed32.encode(d,o.mailbox),o.displayName&&e.string.encode(d,o.displayName),o.avatar&&Wu.encode(d,o.avatar),o.username&&e.string.encode(d,o.username)},decode(d){const o=e.uint.decode(d),n=e.uint.decode(d);return{timestamp:o,mailbox:1&n?e.fixed32.decode(d):null,displayName:2&n?e.string.decode(d):null,avatar:4&n?Wu.decode(d):null,username:8&n?e.string.decode(d):null}}},le={preencode(o,n){o.end++,n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),n.name&&e.string.preencode(o,n.name),d>=5&&n.buildType&&Dp.preencode(o,n.buildType)},encode(o,n){const c=(n.swarmKey?1:0)|(n.name?2:0)|(n.isMobile?4:0)|(d>=5&&n.buildType?8:0);e.uint.encode(o,c),n.swarmKey&&e.fixed32.encode(o,n.swarmKey),n.name&&e.string.encode(o,n.name),d>=5&&n.buildType&&Dp.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{swarmKey:1&n?e.fixed32.decode(o):null,name:2&n?e.string.decode(o):null,isMobile:!!(4&n),buildType:d>=5&&8&n?Dp.decode(o):null}}},fe=e.frame(ue),me={preencode(e,d){fe.preencode(e,d.profile),te.preencode(e,d.attestation)},encode(e,d){fe.encode(e,d.profile),te.encode(e,d.attestation)},decode:e=>({profile:fe.decode(e),attestation:te.decode(e)})},ye={preencode(e,d){Gu.preencode(e,d.profile),te.preencode(e,d.attestation)},encode(e,d){Gu.encode(e,d.profile),te.encode(e,d.attestation)},decode:e=>({profile:Gu.decode(e),attestation:te.decode(e)})},xe=fe,be={preencode(e,d){xe.preencode(e,d.profile),te.preencode(e,d.attestation)},encode(e,d){xe.encode(e,d.profile),te.encode(e,d.attestation)},decode:e=>({profile:xe.decode(e),attestation:te.decode(e)})},ve={preencode(d,o){e.fixed32.preencode(d,o.id),e.buffer.preencode(d,o.data),e.buffer.preencode(d,o.signature)},encode(d,o){e.fixed32.encode(d,o.id),e.buffer.encode(d,o.data),e.buffer.encode(d,o.signature)},decode:d=>({id:e.fixed32.decode(d),data:e.buffer.decode(d),signature:e.buffer.decode(d)})},ge={preencode(d,o){e.fixed32.preencode(d,o.devicePublicKey)},encode(d,o){e.fixed32.encode(d,o.devicePublicKey)},decode:d=>({devicePublicKey:e.fixed32.decode(d)})},Ke={preencode(d,o){te.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){te.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({privateProfileIdentity:te.decode(d),deviceProof:e.buffer.decode(d)})},ke={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),te.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){e.fixed32.encode(d,o.deviceKey),te.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({deviceKey:e.fixed32.decode(d),privateProfileIdentity:te.decode(d),deviceProof:e.buffer.decode(d)})},he=e.frame(ye),we=e.frame(me),Pe=e.frame(ge),Re={preencode(n,c){e.fixed32.preencode(n,c.deviceKey),r.preencode(n,c.keyPair),he.preencode(n,c.device),we.preencode(n,c.member),n.end++,c.identity&&Pe.preencode(n,c.identity),d>=13&&c.link&&o.preencode(n,c.link)},encode(n,c){const t=(c.identity?1:0)|(d>=13&&c.link?2:0);e.fixed32.encode(n,c.deviceKey),r.encode(n,c.keyPair),he.encode(n,c.device),we.encode(n,c.member),e.uint.encode(n,t),c.identity&&Pe.encode(n,c.identity),d>=13&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),t=r.decode(n),i=he.decode(n),a=we.decode(n),s=e.uint.decode(n);return{deviceKey:c,keyPair:t,device:i,member:a,identity:1&s?Pe.decode(n):null,link:d>=13&&2&s?o.decode(n):null}}},Te=e.frame(Re),Ae={preencode(d,o){e.fixed32.preencode(d,o.id),Te.preencode(d,o.request),e.buffer.preencode(d,o.signature)},encode(d,o){e.fixed32.encode(d,o.id),Te.encode(d,o.request),e.buffer.encode(d,o.signature)},decode:d=>({id:e.fixed32.decode(d),request:Te.decode(d),signature:e.buffer.decode(d)})},Se=he,Ie=we,Me={preencode(e,d){Se.preencode(e,d.device),e.end++,d.member&&Ie.preencode(e,d.member)},encode(d,o){const n=o.member?1:0;Se.encode(d,o.device),e.uint.encode(d,n),o.member&&Ie.encode(d,o.member)},decode:d=>({device:Se.decode(d),member:1&e.uint.decode(d)?Ie.decode(d):null})},Fe=e.frame(Ae),qe=e.frame(Me),Ce={preencode(e,d){e.end++,d.withInvitation&&Fe.preencode(e,d.withInvitation),d.withMemberProof&&qe.preencode(e,d.withMemberProof)},encode(d,o){const n=(o.withInvitation?1:0)|(o.withMemberProof?2:0);e.uint.encode(d,n),o.withInvitation&&Fe.encode(d,o.withInvitation),o.withMemberProof&&qe.encode(d,o.withMemberProof)},decode(d){const o=e.uint.decode(d);return{withInvitation:1&o?Fe.decode(d):null,withMemberProof:2&o?qe.decode(d):null}}},Ve=e.frame(ve),He=e.frame(Ke),De={preencode(e,d){Ve.preencode(e,d.signedKeys),e.end++,d.identity&&He.preencode(e,d.identity)},encode(d,o){const n=o.identity?1:0;Ve.encode(d,o.signedKeys),e.uint.encode(d,n),o.identity&&He.encode(d,o.identity)},decode:d=>({signedKeys:Ve.decode(d),identity:1&e.uint.decode(d)?He.decode(d):null})},Le={preencode(o,n){o.end++,n.expiration&&e.uint.preencode(o,n.expiration),d>=5&&n.buildType&&Dp.preencode(o,n.buildType)},encode(o,n){const c=(n.expiration?1:0)|(n.requiresConfirmation?2:0)|(n.canModerate?4:0)|(n.canAdmin?8:0)|(d>=5&&n.buildType?16:0);e.uint.encode(o,c),n.expiration&&e.uint.encode(o,n.expiration),d>=5&&n.buildType&&Dp.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{expiration:1&n?e.uint.decode(o):0,requiresConfirmation:!!(2&n),canModerate:!!(4&n),canAdmin:!!(8&n),buildType:d>=5&&16&n?Dp.decode(o):null}}},je=Ve,Ee=e.frame(Le),Be={preencode(d,n){e.fixed32.preencode(d,n.id),je.preencode(d,n.response),Ee.preencode(d,n.metadata),d.end++,n.anchor&&o.preencode(d,n.anchor)},encode(d,n){const c=(n.anchor?1:0)|(n.isActive?2:0);e.fixed32.encode(d,n.id),je.encode(d,n.response),Ee.encode(d,n.metadata),e.uint.encode(d,c),n.anchor&&o.encode(d,n.anchor)},decode(d){const n=e.fixed32.decode(d),c=je.decode(d),r=Ee.decode(d),t=e.uint.decode(d);return{id:n,response:c,metadata:r,anchor:1&t?o.decode(d):null,isActive:!!(2&t)}}},ze=de,Oe=e.frame(Be),Ne={preencode(e,d){ze.preencode(e,d.header),Oe.preencode(e,d.invitation)},encode(e,d){ze.encode(e,d.header),Oe.encode(e,d.invitation)},decode:e=>({header:ze.decode(e),invitation:Oe.decode(e)})},Ue=de,Je={preencode(d,o){Ue.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){Ue.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:Ue.decode(d),id:e.fixed32.decode(d)})},We={preencode(d,n){e.fixed32.preencode(d,n.mailbox),e.fixed32.preencode(d,n.invitationSeed),o.preencode(d,n.anchor)},encode(d,n){e.fixed32.encode(d,n.mailbox),e.fixed32.encode(d,n.invitationSeed),o.encode(d,n.anchor)},decode:d=>({mailbox:e.fixed32.decode(d),invitationSeed:e.fixed32.decode(d),anchor:o.decode(d)})},Ge={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.fixed32.preencode(d,o.encryptionKey),e.fixed32.preencode(d,o.seed),d.end++,o.fastForwardTo&&e.fixed32.preencode(d,o.fastForwardTo)},encode(d,o){const n=o.fastForwardTo?1:0;e.fixed32.encode(d,o.roomKey),e.fixed32.encode(d,o.encryptionKey),e.fixed32.encode(d,o.seed),e.uint.encode(d,n),o.fastForwardTo&&e.fixed32.encode(d,o.fastForwardTo)},decode:d=>({roomKey:e.fixed32.decode(d),encryptionKey:e.fixed32.decode(d),seed:e.fixed32.decode(d),fastForwardTo:1&e.uint.decode(d)?e.fixed32.decode(d):null})},Qe={preencode(d,n){e.fixed32.preencode(d,n.mailbox),e.fixed32.preencode(d,n.invitationSeed),o.preencode(d,n.anchor),e.fixed32.preencode(d,n.identityPublicKey)},encode(d,n){e.fixed32.encode(d,n.mailbox),e.fixed32.encode(d,n.invitationSeed),o.encode(d,n.anchor),e.fixed32.encode(d,n.identityPublicKey)},decode:d=>({mailbox:e.fixed32.decode(d),invitationSeed:e.fixed32.decode(d),anchor:o.decode(d),identityPublicKey:e.fixed32.decode(d)})},Xe={preencode(d,o){e.fixed32.preencode(d,o.mailbox)},encode(d,o){e.fixed32.encode(d,o.mailbox)},decode:d=>({mailbox:e.fixed32.decode(d)})},Ye=e.frame(We),Ze=e.frame(Qe),$e=e.frame(Xe),_e=e.frame(Ge),ed=e.array(e.ipv4Address),dd={preencode(e,o){e.end++,o.room&&Ye.preencode(e,o.room),o.identity&&Ze.preencode(e,o.identity),o.contact&&$e.preencode(e,o.contact),o.readonly&&_e.preencode(e,o.readonly),o.additionalNodes&&ed.preencode(e,o.additionalNodes),d>=5&&o.buildType&&Dp.preencode(e,o.buildType),d>=13&&o["readonly-v2"]&&Qu.preencode(e,o["readonly-v2"])},encode(o,n){const c=(n.room?1:0)|(n.identity?2:0)|(n.contact?4:0)|(n.readonly?8:0)|(n.additionalNodes?16:0)|(d>=5&&n.buildType?32:0)|(d>=13&&n["readonly-v2"]?64:0);e.uint.encode(o,c),n.room&&Ye.encode(o,n.room),n.identity&&Ze.encode(o,n.identity),n.contact&&$e.encode(o,n.contact),n.readonly&&_e.encode(o,n.readonly),n.additionalNodes&&ed.encode(o,n.additionalNodes),d>=5&&n.buildType&&Dp.encode(o,n.buildType),d>=13&&n["readonly-v2"]&&Qu.encode(o,n["readonly-v2"])},decode(o){const n=e.uint.decode(o);return{room:1&n?Ye.decode(o):null,identity:2&n?Ze.decode(o):null,contact:4&n?$e.decode(o):null,readonly:8&n?_e.decode(o):null,additionalNodes:16&n?ed.decode(o):null,buildType:d>=5&&32&n?Dp.decode(o):null,"readonly-v2":d>=13&&64&n?Qu.decode(o):null}}},od=de,nd={preencode(d,o){od.preencode(d,o.header),e.buffer.preencode(d,o.blindRequest)},encode(d,o){od.encode(d,o.header),e.buffer.encode(d,o.blindRequest)},decode:d=>({header:od.decode(d),blindRequest:e.buffer.decode(d)})},cd=de,rd={preencode(o,n){cd.preencode(o,n.header),o.end++,n.profile&&Xu.preencode(o,n.profile),d>=10&&n.key&&e.fixed32.preencode(o,n.key)},encode(o,n){const c=(n.profile?1:0)|(d>=10&&n.key?2:0);cd.encode(o,n.header),e.uint.encode(o,c),n.profile&&Xu.encode(o,n.profile),d>=10&&n.key&&e.fixed32.encode(o,n.key)},decode(o){const n=cd.decode(o),c=e.uint.decode(o);return{header:n,profile:1&c?Xu.decode(o):null,key:d>=10&&2&c?e.fixed32.decode(o):null}}},td=de,id={preencode(d,o){td.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){td.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:td.decode(d),key:e.fixed32.decode(d)})},ad={preencode(e,d){},encode(e,d){},decode:e=>({})},sd=ad,pd=Te,ud={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.id),pd.preencode(d,o.request)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.id),pd.encode(d,o.request)},decode:d=>({deviceKey:e.fixed32.decode(d),id:e.fixed32.decode(d),request:pd.decode(d)})},ld=de,fd=He,md={preencode(d,o){ld.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),d.end++,o.identity&&fd.preencode(d,o.identity)},encode(d,o){const n=o.identity?1:0;ld.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,n),o.identity&&fd.encode(d,o.identity)},decode:d=>({header:ld.decode(d),deviceKey:e.fixed32.decode(d),identity:1&e.uint.decode(d)?fd.decode(d):null})},yd=de,xd={preencode(d,o){yd.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey)},encode(d,o){yd.encode(d,o.header),e.fixed32.encode(d,o.deviceKey)},decode:d=>({header:yd.decode(d),deviceKey:e.fixed32.decode(d)})},bd=e.frame(I),vd=fe,gd={preencode(d,o){e.fixed32.preencode(d,o.key),bd.preencode(d,o.status),vd.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),bd.encode(d,o.status),vd.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),status:bd.decode(d),profile:vd.decode(d)})},Kd=bd,kd=fe,hd={preencode(d,o){e.fixed32.preencode(d,o.key),Kd.preencode(d,o.status),kd.preencode(d,o.profile),d.end++,o.proofs&&Yu.preencode(d,o.proofs)},encode(d,o){const n=o.proofs?1:0;e.fixed32.encode(d,o.key),Kd.encode(d,o.status),kd.encode(d,o.profile),e.uint.encode(d,n),o.proofs&&Yu.encode(d,o.proofs)},decode:d=>({key:e.fixed32.decode(d),status:Kd.decode(d),profile:kd.decode(d),proofs:1&e.uint.decode(d)?Yu.decode(d):null})},wd={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++,o.profileAttestation&&e.buffer.preencode(d,o.profileAttestation),o.latestReceipt&&e.buffer.preencode(d,o.latestReceipt)},encode(d,o){const n=(o.profileAttestation?1:0)|(o.latestReceipt?2:0);e.fixed32.encode(d,o.key),e.uint.encode(d,n),o.profileAttestation&&e.buffer.encode(d,o.profileAttestation),o.latestReceipt&&e.buffer.encode(d,o.latestReceipt)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d);return{key:o,profileAttestation:1&n?e.buffer.decode(d):null,latestReceipt:2&n?e.buffer.decode(d):null}}},Pd=de,Rd=we,Td={preencode(e,d){Pd.preencode(e,d.header),Rd.preencode(e,d.member)},encode(e,d){Pd.encode(e,d.header),Rd.encode(e,d.member)},decode:e=>({header:Pd.decode(e),member:Rd.decode(e)})},Ad=de,Sd=e.frame(M),Id={preencode(d,o){Ad.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),Sd.preencode(d,o.status)},encode(d,o){Ad.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),Sd.encode(d,o.status)},decode:d=>({header:Ad.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:Sd.decode(d)})},Md=de,Fd={preencode(d,o){Md.preencode(d,o.header),e.fixed32.preencode(d,o.key),d.end++},encode(d,o){const n=(o.isModerator?1:0)|(o.isAdmin?2:0);Md.encode(d,o.header),e.fixed32.encode(d,o.key),e.uint.encode(d,n)},decode(d){const o=Md.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{header:o,key:n,isModerator:!!(1&c),isAdmin:!!(2&c)}}},qd=de,Cd={preencode(d,o){qd.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){qd.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:qd.decode(d),key:e.fixed32.decode(d)})},Vd={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.mentions)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.mentions)},decode:d=>({key:e.fixed32.decode(d),mentions:e.uint.decode(d)})},Hd={preencode(d,o){d.end++,o.memberKey&&e.fixed32.preencode(d,o.memberKey)},encode(d,o){const n=o.memberKey?1:0;e.uint.encode(d,n),o.memberKey&&e.fixed32.encode(d,o.memberKey)},decode:d=>({memberKey:1&e.uint.decode(d)?e.fixed32.decode(d):null})},Dd=Hd,Ld=Hd,jd={preencode(d,o){d.end++,o.from&&e.string.preencode(d,o.from),o.to&&e.string.preencode(d,o.to)},encode(d,o){const n=(o.from?1:0)|(o.to?2:0);e.uint.encode(d,n),o.from&&e.string.encode(d,o.from),o.to&&e.string.encode(d,o.to)},decode(d){const o=e.uint.decode(d);return{from:1&o?e.string.decode(d):null,to:2&o?e.string.decode(d):null}}},Ed=e.frame(Hd),Bd=e.frame(Dd),zd=e.frame(jd),Od=e.frame(Ld),Nd={preencode(o,n){const c=(n.memberJoined?1:0)|(n.memberLeft?2:0)|(n.titleChanged?4:0)|(n.callStarted?8:0)|(n.callHangup?16:0)|(n.callMissed?32:0)|(n.roomAvatarChanged?64:0)|(n.invitationCreated?128:0)|(n.memberRemoved?256:0)|(d>=3&&n.locationShared?512:0);e.uint.preencode(o,c),n.memberJoined&&Ed.preencode(o,n.memberJoined),n.memberLeft&&Bd.preencode(o,n.memberLeft),n.titleChanged&&zd.preencode(o,n.titleChanged),n.memberRemoved&&Od.preencode(o,n.memberRemoved),d>=3&&n.locationShared&&Zu.preencode(o,n.locationShared)},encode(o,n){const c=(n.memberJoined?1:0)|(n.memberLeft?2:0)|(n.titleChanged?4:0)|(n.callStarted?8:0)|(n.callHangup?16:0)|(n.callMissed?32:0)|(n.roomAvatarChanged?64:0)|(n.invitationCreated?128:0)|(n.memberRemoved?256:0)|(d>=3&&n.locationShared?512:0);e.uint.encode(o,c),n.memberJoined&&Ed.encode(o,n.memberJoined),n.memberLeft&&Bd.encode(o,n.memberLeft),n.titleChanged&&zd.encode(o,n.titleChanged),n.memberRemoved&&Od.encode(o,n.memberRemoved),d>=3&&n.locationShared&&Zu.encode(o,n.locationShared)},decode(o){const n=e.uint.decode(o);return{memberJoined:1&n?Ed.decode(o):null,memberLeft:2&n?Bd.decode(o):null,titleChanged:4&n?zd.decode(o):null,callStarted:!!(8&n),callHangup:!!(16&n),callMissed:!!(32&n),roomAvatarChanged:!!(64&n),invitationCreated:!!(128&n),memberRemoved:256&n?Od.decode(o):null,locationShared:d>=3&&512&n?Zu.decode(o):null}}},Ud={preencode(e,o){e.end++,d>=3&&o.locationShared&&$u.preencode(e,o.locationShared)},encode(o,n){const c=(n.callStarted?1:0)|(n.callHangup?2:0)|(n.callMissed?4:0)|(d>=3&&n.locationShared?8:0);e.uint.encode(o,c),d>=3&&n.locationShared&&$u.encode(o,n.locationShared)},decode(o){const n=e.uint.decode(o);return{callStarted:!!(1&n),callHangup:!!(2&n),callMissed:!!(4&n),locationShared:d>=3&&8&n?$u.decode(o):null}}},Jd={preencode(d,o){e.uint.preencode(d,o.start),e.uint.preencode(d,o.length)},encode(d,o){e.uint.encode(d,o.start),e.uint.encode(d,o.length)},decode:d=>({start:e.uint.decode(d),length:e.uint.decode(d)})},Wd=e.frame(Jd),Gd={preencode(d,o){Wd.preencode(d,o.range),e.string.preencode(d,o.content)},encode(d,o){Wd.encode(d,o.range),e.string.encode(d,o.content)},decode:d=>({range:Wd.decode(d),content:e.string.decode(d)})},Qd=Wd,Xd={preencode(d,o){Qd.preencode(d,o.range),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Qd.encode(d,o.range),e.fixed32.encode(d,o.memberKey)},decode:d=>({range:Qd.decode(d),memberKey:e.fixed32.decode(d)})},Yd=Wd,Zd={preencode(d,o){Yd.preencode(d,o.range),Y.preencode(d,o.language),e.string.preencode(d,o.text)},encode(d,o){Yd.encode(d,o.range),Y.encode(d,o.language),e.string.encode(d,o.text)},decode:d=>({range:Yd.decode(d),language:Y.decode(d),text:e.string.decode(d)})},$d=K,_d=e.array(e.uint),eo={preencode(d,o){d.end++,o.title&&e.string.preencode(d,o.title),o.description&&e.string.preencode(d,o.description),o.file&&$d.preencode(d,o.file),o.files&&_d.preencode(d,o.files)},encode(d,o){const n=(o.title?1:0)|(o.description?2:0)|(o.file?4:0)|(o.files?8:0);e.uint.encode(d,n),o.title&&e.string.encode(d,o.title),o.description&&e.string.encode(d,o.description),o.file&&$d.encode(d,o.file),o.files&&_d.encode(d,o.files)},decode(d){const o=e.uint.decode(d);return{title:1&o?e.string.decode(d):null,description:2&o?e.string.decode(d):null,file:4&o?$d.decode(d):null,files:8&o?_d.decode(d):null}}},oo=Wd,no=e.frame(eo),co={preencode(d,o){oo.preencode(d,o.range),e.string.preencode(d,o.url),d.end++,o.preview&&no.preencode(d,o.preview)},encode(d,o){const n=o.preview?1:0;oo.encode(d,o.range),e.string.encode(d,o.url),e.uint.encode(d,n),o.preview&&no.encode(d,o.preview)},decode:d=>({range:oo.decode(d),url:e.string.decode(d),preview:1&e.uint.decode(d)?no.decode(d):null})},ro=e.array(e.frame(Xd)),to=e.array(e.frame(co)),io=to,ao=e.array(e.frame(Jd)),so=ao,po=ao,uo=e.array(e.frame(Gd)),lo=ao,fo=ao,mo=e.array(e.frame(Zd)),yo={preencode(d,o){const n=(o.mention?1:0)|(o.httpLink?2:0)|(o.pearLink?4:0)|(o.bold?8:0)|(o.italic?16:0)|(o.code?32:0)|(o.emoji?64:0)|(o.codeBlock?128:0)|(o.strike?256:0)|(o.translation?512:0);e.uint.preencode(d,n),o.mention&&ro.preencode(d,o.mention),o.httpLink&&to.preencode(d,o.httpLink),o.pearLink&&io.preencode(d,o.pearLink),o.bold&&ao.preencode(d,o.bold),o.italic&&so.preencode(d,o.italic),o.code&&po.preencode(d,o.code),o.emoji&&uo.preencode(d,o.emoji),o.codeBlock&&lo.preencode(d,o.codeBlock),o.strike&&fo.preencode(d,o.strike),o.translation&&mo.preencode(d,o.translation)},encode(d,o){const n=(o.mention?1:0)|(o.httpLink?2:0)|(o.pearLink?4:0)|(o.bold?8:0)|(o.italic?16:0)|(o.code?32:0)|(o.emoji?64:0)|(o.codeBlock?128:0)|(o.strike?256:0)|(o.translation?512:0);e.uint.encode(d,n),o.mention&&ro.encode(d,o.mention),o.httpLink&&to.encode(d,o.httpLink),o.pearLink&&io.encode(d,o.pearLink),o.bold&&ao.encode(d,o.bold),o.italic&&so.encode(d,o.italic),o.code&&po.encode(d,o.code),o.emoji&&uo.encode(d,o.emoji),o.codeBlock&&lo.encode(d,o.codeBlock),o.strike&&fo.encode(d,o.strike),o.translation&&mo.encode(d,o.translation)},decode(d){const o=e.uint.decode(d);return{mention:1&o?ro.decode(d):null,httpLink:2&o?to.decode(d):null,pearLink:4&o?io.decode(d):null,bold:8&o?ao.decode(d):null,italic:16&o?so.decode(d):null,code:32&o?po.decode(d):null,emoji:64&o?uo.decode(d):null,codeBlock:128&o?lo.decode(d):null,strike:256&o?fo.decode(d):null,translation:512&o?mo.decode(d):null}}},xo=e.array(e.frame(g)),bo=e.frame(yo),vo=e.frame(Ud),go={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&xo.preencode(d,o.files),o.display&&bo.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent),o.event&&vo.preencode(d,o.event)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(c.event?32:0)|(d>=3&&c.forwarded?64:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&xo.encode(o,c.files),c.display&&bo.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent),c.event&&vo.encode(o,c.event)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?xo.decode(o):null,display:4&c?bo.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,event:32&c?vo.decode(o):null,forwarded:d>=3&&!!(64&c)}}},Ko=_d,ko=bo,ho={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&Ko.preencode(d,o.files),o.display&&ko.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(d>=3&&c.forwarded?32:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&Ko.encode(o,c.files),c.display&&ko.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?Ko.decode(o):null,display:4&c?ko.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,forwarded:d>=3&&!!(32&c)}}},wo=xo,Po=bo,Ro={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&wo.preencode(d,o.files),o.display&&Po.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(d>=3&&c.forwarded?32:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&wo.encode(o,c.files),c.display&&Po.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?wo.decode(o):null,display:4&c?Po.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,forwarded:d>=3&&!!(32&c)}}},To={preencode(e,d){e.end++},encode(d,o){const n=(o.isEdited?1:0)|(o.isDeleted?2:0)|(o.isPinned?4:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isEdited:!!(1&o),isDeleted:!!(2&o),isPinned:!!(4&o)}}},Ao={preencode(d,o){e.uint.preencode(d,o.thread),e.uint.preencode(d,o.index)},encode(d,o){e.uint.encode(d,o.thread),e.uint.encode(d,o.index)},decode:d=>({thread:e.uint.decode(d),index:e.uint.decode(d)})},So=e.frame(B),Io={preencode(d,o){e.uint.preencode(d,o.id),e.uint.preencode(d,o.count),d.end++,o.parent&&n.preencode(d,o.parent),o.stats&&So.preencode(d,o.stats)},encode(d,o){const c=(o.parent?1:0)|(o.stats?2:0);e.uint.encode(d,o.id),e.uint.encode(d,o.count),e.uint.encode(d,c),o.parent&&n.encode(d,o.parent),o.stats&&So.encode(d,o.stats)},decode(d){const o=e.uint.decode(d),c=e.uint.decode(d),r=e.uint.decode(d);return{id:o,count:c,parent:1&r?n.decode(d):null,stats:2&r?So.decode(d):null}}},Mo=e.frame(To),Fo=e.frame(ho),qo=e.frame(Nd),Co={preencode(d,o){Ao.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),Mo.preencode(d,o.status),o.message&&Fo.preencode(d,o.message),o.event&&qo.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);Ao.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),Mo.encode(d,o.status),o.message&&Fo.encode(d,o.message),o.event&&qo.encode(d,o.event)},decode(d){const o=Ao.decode(d),c=n.decode(d),r=e.uint.decode(d),t=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:r,timestamp:t,editedAt:1&i?e.uint.decode(d):0,status:Mo.decode(d),message:2&i?Fo.decode(d):null,event:4&i?qo.decode(d):null}}},Vo=Mo,Ho=e.frame(Ro),Do=qo,Lo={preencode(d,o){Ao.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),Vo.preencode(d,o.status),o.message&&Ho.preencode(d,o.message),o.event&&Do.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);Ao.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),Vo.encode(d,o.status),o.message&&Ho.encode(d,o.message),o.event&&Do.encode(d,o.event)},decode(d){const o=Ao.decode(d),c=n.decode(d),r=e.uint.decode(d),t=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:r,timestamp:t,editedAt:1&i?e.uint.decode(d):0,status:Vo.decode(d),message:2&i?Ho.decode(d):null,event:4&i?Do.decode(d):null}}},jo=de,Eo=e.frame(go),Bo={preencode(e,d){jo.preencode(e,d.header),Eo.preencode(e,d.message)},encode(e,d){jo.encode(e,d.header),Eo.encode(e,d.message)},decode:e=>({header:jo.decode(e),message:Eo.decode(e)})},zo=de,Oo={preencode(e,d){zo.preencode(e,d.header),n.preencode(e,d.oplog)},encode(e,d){zo.encode(e,d.header),n.encode(e,d.oplog)},decode:e=>({header:zo.decode(e),oplog:n.decode(e)})},No=de,Uo=Eo,Jo={preencode(e,d){No.preencode(e,d.header),n.preencode(e,d.oplog),Uo.preencode(e,d.message)},encode(e,d){No.encode(e,d.header),n.encode(e,d.oplog),Uo.encode(e,d.message)},decode:e=>({header:No.decode(e),oplog:n.decode(e),message:Uo.decode(e)})},Wo=de,Go={preencode(e,d){Wo.preencode(e,d.header),n.preencode(e,d.oplog),e.end++},encode(d,o){const c=o.isPinned?1:0;Wo.encode(d,o.header),n.encode(d,o.oplog),e.uint.encode(d,c)},decode:d=>({header:Wo.decode(d),oplog:n.decode(d),isPinned:!!(1&e.uint.decode(d))})},Qo={HttpLink:1,PearLink:2},Xo={preencode(e,d){e.end++},encode(d,o){if(o>2)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Yo=de,Zo={preencode(d,o){Yo.preencode(d,o.header),n.preencode(d,o.oplog),e.uint.preencode(d,o.index),_u.preencode(d,o.preview),d.end++,o.displayType&&Xo.preencode(d,o.displayType)},encode(d,o){const c=o.displayType?1:0;Yo.encode(d,o.header),n.encode(d,o.oplog),e.uint.encode(d,o.index),_u.encode(d,o.preview),e.uint.encode(d,c),o.displayType&&Xo.encode(d,o.displayType)},decode:d=>({header:Yo.decode(d),oplog:n.decode(d),index:e.uint.decode(d),preview:_u.decode(d),displayType:1&e.uint.decode(d)?Xo.decode(d):0})},$o={preencode(d,o){Ao.preencode(d,o.id),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),e.string.preencode(d,o.reaction)},encode(d,o){Ao.encode(d,o.id),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),e.string.encode(d,o.reaction)},decode:d=>({id:Ao.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),reaction:e.string.decode(d)})},_o={preencode(d,o){e.string.preencode(d,o.text),e.uint.preencode(d,o.count)},encode(d,o){e.string.encode(d,o.text),e.uint.encode(d,o.count)},decode:d=>({text:e.string.decode(d),count:e.uint.decode(d)})},en=e.array(e.frame(_o)),dn={preencode(d,o){Ao.preencode(d,o.id),e.uint.preencode(d,o.total),en.preencode(d,o.reactions),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt)},encode(d,o){const n=o.editedAt?1:0;Ao.encode(d,o.id),e.uint.encode(d,o.total),en.encode(d,o.reactions),e.uint.encode(d,n),o.editedAt&&e.uint.encode(d,o.editedAt)},decode:d=>({id:Ao.decode(d),total:e.uint.decode(d),reactions:en.decode(d),editedAt:1&e.uint.decode(d)?e.uint.decode(d):0})},on=de,nn={preencode(d,o){on.preencode(d,o.header),n.preencode(d,o.oplog),e.string.preencode(d,o.reaction)},encode(d,o){on.encode(d,o.header),n.encode(d,o.oplog),e.string.encode(d,o.reaction)},decode:d=>({header:on.decode(d),oplog:n.decode(d),reaction:e.string.decode(d)})},cn=de,rn={preencode(d,o){cn.preencode(d,o.header),n.preencode(d,o.oplog),e.string.preencode(d,o.reaction)},encode(d,o){cn.encode(d,o.header),n.encode(d,o.oplog),e.string.encode(d,o.reaction)},decode:d=>({header:cn.decode(d),oplog:n.decode(d),reaction:e.string.decode(d)})},tn=de,an=e.frame(_),sn={preencode(d,o){tn.preencode(d,o.header),e.uint.preencode(d,o.key),an.preencode(d,o.config)},encode(d,o){tn.encode(d,o.header),e.uint.encode(d,o.key),an.encode(d,o.config)},decode:d=>({header:tn.decode(d),key:e.uint.decode(d),config:an.decode(d)})},pn={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.string.preencode(d,o.displayName),d.end++,o.avatar&&el.preencode(d,o.avatar)},encode(d,o){const n=o.avatar?1:0;e.fixed32.encode(d,o.memberKey),e.string.encode(d,o.displayName),e.uint.encode(d,n),o.avatar&&el.encode(d,o.avatar)},decode:d=>({memberKey:e.fixed32.decode(d),displayName:e.string.decode(d),avatar:1&e.uint.decode(d)?el.decode(d):null})},un={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++,o.username&&e.string.preencode(d,o.username)},encode(d,o){const n=o.username?1:0;e.fixed32.encode(d,o.key),e.uint.encode(d,n),o.username&&e.string.encode(d,o.username)},decode:d=>({key:e.fixed32.decode(d),username:1&e.uint.decode(d)?e.string.decode(d):null})},ln=e.frame(un),fn={preencode(d,o){e.fixed32.preencode(d,o.publicKey),d.end++,o.discoveryCoreKey&&e.fixed32.preencode(d,o.discoveryCoreKey),o.userRegistry&&ln.preencode(d,o.userRegistry)},encode(d,o){const n=(o.discoveryCoreKey?1:0)|(o.userRegistry?2:0);e.fixed32.encode(d,o.publicKey),e.uint.encode(d,n),o.discoveryCoreKey&&e.fixed32.encode(d,o.discoveryCoreKey),o.userRegistry&&ln.encode(d,o.userRegistry)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d);return{publicKey:o,discoveryCoreKey:1&n?e.fixed32.decode(d):null,userRegistry:2&n?ln.decode(d):null}}},mn=de,yn=e.frame(W),xn=e.frame(G),bn=an,vn=e.frame(fn),gn=he,Kn=e.array(e.frame(me)),kn={preencode(e,d){mn.preencode(e,d.header),yn.preencode(e,d.digest),xn.preencode(e,d.capabilities),e.end++,d.config&&bn.preencode(e,d.config),d.identity&&vn.preencode(e,d.identity),d.bootstrapDevice&&gn.preencode(e,d.bootstrapDevice),d.initialMembers&&Kn.preencode(e,d.initialMembers)},encode(d,o){const n=(o.config?1:0)|(o.identity?2:0)|(o.bootstrapDevice?4:0)|(o.initialMembers?8:0);mn.encode(d,o.header),yn.encode(d,o.digest),xn.encode(d,o.capabilities),e.uint.encode(d,n),o.config&&bn.encode(d,o.config),o.identity&&vn.encode(d,o.identity),o.bootstrapDevice&&gn.encode(d,o.bootstrapDevice),o.initialMembers&&Kn.encode(d,o.initialMembers)},decode(d){const o=mn.decode(d),n=yn.decode(d),c=xn.decode(d),r=e.uint.decode(d);return{header:o,digest:n,capabilities:c,config:1&r?bn.decode(d):null,identity:2&r?vn.decode(d):null,bootstrapDevice:4&r?gn.decode(d):null,initialMembers:8&r?Kn.decode(d):null}}},hn=de,wn={preencode(d,o){hn.preencode(d,o.header),e.uint.preencode(d,o.version)},encode(d,o){hn.encode(d,o.header),e.uint.encode(d,o.version)},decode:d=>({header:hn.decode(d),version:e.uint.decode(d)})},Pn=de,Rn={preencode(o,n){Pn.preencode(o,n.header),e.uint.preencode(o,n.from),e.uint.preencode(o,n.to),o.end++,d>=5&&n.buildType&&Dp.preencode(o,n.buildType)},encode(o,n){const c=d>=5&&n.buildType?1:0;Pn.encode(o,n.header),e.uint.encode(o,n.from),e.uint.encode(o,n.to),e.uint.encode(o,c),d>=5&&n.buildType&&Dp.encode(o,n.buildType)},decode(o){const n=Pn.decode(o),c=e.uint.decode(o),r=e.uint.decode(o),t=o.start<o.end?e.uint.decode(o):0;return{header:n,from:c,to:r,buildType:d>=5&&1&t?Dp.decode(o):null}}},Tn={RoomType:1,IsExperimental:2,IsJoiningDisabled:3,IsAppendingDisabled:4,IsCallingDisabled:5,IsMembershipEventsDisabled:6,IsAttachmentsDisabled:7,IsLinksDisabled:8,IsRoomInviteHidden:9},An={preencode(e,d){e.end++},encode(d,o){if(o>9)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Sn=de,In=J,Mn={preencode(d,o){Sn.preencode(d,o.header),e.uint.preencode(d,o.key),In.preencode(d,o.settings)},encode(d,o){Sn.encode(d,o.header),e.uint.encode(d,o.key),In.encode(d,o.settings)},decode:d=>({header:Sn.decode(d),key:e.uint.decode(d),settings:In.decode(d)})},Fn=de,qn={preencode(d,o){Fn.preencode(d,o.header),e.uint.preencode(d,o.value)},encode(d,o){Fn.encode(d,o.header),e.uint.encode(d,o.value)},decode:d=>({header:Fn.decode(d),value:e.uint.decode(d)})},Cn={preencode(d,o){e.uint.preencode(d,o.key),e.uint.preencode(d,o.value)},encode(d,o){e.uint.encode(d,o.key),e.uint.encode(d,o.value)},decode:d=>({key:e.uint.decode(d),value:e.uint.decode(d)})},Vn={Flag:1},Hn={preencode(e,d){e.end++},encode(d,o){if(o>1)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Dn={preencode(d,o){Ao.preencode(d,o.id),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),Hn.preencode(d,o.label)},encode(d,o){Ao.encode(d,o.id),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),Hn.encode(d,o.label)},decode:d=>({id:Ao.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),label:Hn.decode(d)})},Ln=de,jn={preencode(e,d){Ln.preencode(e,d.header),n.preencode(e,d.oplog),Hn.preencode(e,d.label)},encode(e,d){Ln.encode(e,d.header),n.encode(e,d.oplog),Hn.encode(e,d.label)},decode:e=>({header:Ln.decode(e),oplog:n.decode(e),label:Hn.decode(e)})},En=de,Bn={preencode(e,d){En.preencode(e,d.header),n.preencode(e,d.oplog),Hn.preencode(e,d.label)},encode(e,d){En.encode(e,d.header),n.encode(e,d.oplog),Hn.encode(e,d.label)},decode:e=>({header:En.decode(e),oplog:n.decode(e),label:Hn.decode(e)})},zn={preencode(d,o){Hn.preencode(d,o.label),e.uint.preencode(d,o.count)},encode(d,o){Hn.encode(d,o.label),e.uint.encode(d,o.count)},decode:d=>({label:Hn.decode(d),count:e.uint.decode(d)})},On=e.array(e.frame(zn)),Nn={preencode(d,o){Ao.preencode(d,o.id),e.uint.preencode(d,o.total),On.preencode(d,o.labels),e.uint.preencode(d,o.editedAt),d.end++,o.flagsClock&&e.uint.preencode(d,o.flagsClock),o.version&&e.uint.preencode(d,o.version)},encode(d,o){const n=(o.flagsClock?1:0)|(o.version?2:0)|(o.isDeleted?4:0);Ao.encode(d,o.id),e.uint.encode(d,o.total),On.encode(d,o.labels),e.uint.encode(d,o.editedAt),e.uint.encode(d,n),o.flagsClock&&e.uint.encode(d,o.flagsClock),o.version&&e.uint.encode(d,o.version)},decode(d){const o=Ao.decode(d),n=e.uint.decode(d),c=On.decode(d),r=e.uint.decode(d),t=e.uint.decode(d);return{id:o,total:n,labels:c,editedAt:r,flagsClock:1&t?e.uint.decode(d):0,version:2&t?e.uint.decode(d):0,isDeleted:!!(4&t)}}},Un=de,Jn={preencode(d,o){Un.preencode(d,o.header),e.uint.preencode(d,o.length)},encode(d,o){Un.encode(d,o.header),e.uint.encode(d,o.length)},decode:d=>({header:Un.decode(d),length:e.uint.decode(d)})},Wn={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.length)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.length)},decode:d=>({memberKey:e.fixed32.decode(d),length:e.uint.decode(d)})},Gn=ee,Qn=e.frame(be),Xn={preencode(o,n){e.fixed32.preencode(o,n.memberKey),dl.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=8&&n.contactInfo&&Qn.preencode(o,n.contactInfo),d>=8&&n.version&&e.uint.preencode(o,n.version),d>=10&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=8&&n.contactInfo?4:0)|(d>=8&&n.version?8:0)|(d>=10&&n.alias?16:0);e.fixed32.encode(o,n.memberKey),dl.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=8&&n.contactInfo&&Qn.encode(o,n.contactInfo),d>=8&&n.version&&e.uint.encode(o,n.version),d>=10&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.fixed32.decode(o),c=dl.decode(o),r=e.uint.decode(o);return{memberKey:n,status:c,mailbox:1&r?e.fixed32.decode(o):null,roomKey:2&r?e.fixed32.decode(o):null,contactInfo:d>=8&&4&r?Qn.decode(o):null,version:d>=8&&8&r?e.uint.decode(o):0,alias:d>=10&&16&r?e.string.decode(o):null}}},Yn={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.seed),o.preencode(d,n.initiator),e.fixed32.preencode(d,n.fastForwardTo)},encode(d,n){e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.fixed32.encode(d,n.seed),o.encode(d,n.initiator),e.fixed32.encode(d,n.fastForwardTo)},decode:d=>({roomKey:e.fixed32.decode(d),encryptionKey:e.buffer.decode(d),seed:e.fixed32.decode(d),initiator:o.decode(d),fastForwardTo:e.fixed32.decode(d)})},Zn=e.array(e.frame(Yn)),$n=$,_n={preencode(e,d){Zn.preencode(e,d.sharedRooms),$n.preencode(e,d.blockedContacts)},encode(e,d){Zn.encode(e,d.sharedRooms),$n.encode(e,d.blockedContacts)},decode:e=>({sharedRooms:Zn.decode(e),blockedContacts:$n.decode(e)})},ec=vn,dc={preencode(e,d){ec.preencode(e,d.identity)},encode(e,d){ec.encode(e,d.identity)},decode:e=>({identity:ec.decode(e)})},oc={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.contacts)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.contacts)},decode:d=>({rooms:e.uint.decode(d),contacts:e.uint.decode(d)})},nc={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.contactRequests)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.contactRequests)},decode:d=>({rooms:e.uint.decode(d),contactRequests:e.uint.decode(d)})},cc={preencode(d,o){e.buffer.preencode(d,o.entropy)},encode(d,o){e.buffer.encode(d,o.entropy)},decode:d=>({entropy:e.buffer.decode(d)})},rc={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.devicePublicKey),e.fixed32.preencode(d,o.writerKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.devicePublicKey),e.fixed32.encode(d,o.writerKey)},decode:d=>({publicKey:e.fixed32.decode(d),devicePublicKey:e.fixed32.decode(d),writerKey:e.fixed32.decode(d)})},tc=e.frame(rc),ic={preencode(n,c){e.fixed32.preencode(n,c.id),e.fixed32.preencode(n,c.invitationSeed),e.fixed32.preencode(n,c.mailbox),r.preencode(n,c.responseKeyPair),o.preencode(n,c.initiator),o.preencode(n,c.inviter),n.end++,c.identity&&tc.preencode(n,c.identity),d>=5&&c.buildType&&Dp.preencode(n,c.buildType),d>=13&&c.link&&o.preencode(n,c.link)},encode(n,c){const t=(c.identity?1:0)|(d>=5&&c.buildType?2:0)|(d>=13&&c.link?4:0);e.fixed32.encode(n,c.id),e.fixed32.encode(n,c.invitationSeed),e.fixed32.encode(n,c.mailbox),r.encode(n,c.responseKeyPair),o.encode(n,c.initiator),o.encode(n,c.inviter),e.uint.encode(n,t),c.identity&&tc.encode(n,c.identity),d>=5&&c.buildType&&Dp.encode(n,c.buildType),d>=13&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),t=e.fixed32.decode(n),i=e.fixed32.decode(n),a=r.decode(n),s=o.decode(n),p=o.decode(n),u=e.uint.decode(n);return{id:c,invitationSeed:t,mailbox:i,responseKeyPair:a,initiator:s,inviter:p,identity:1&u?tc.decode(n):null,buildType:d>=5&&2&u?Dp.decode(n):null,link:d>=13&&4&u?o.decode(n):null}}},ac=de,sc={preencode(d,o){ac.preencode(d,o.header),e.buffer.preencode(d,o.blindResponse)},encode(d,o){ac.encode(d,o.header),e.buffer.encode(d,o.blindResponse)},decode:d=>({header:ac.decode(d),blindResponse:e.buffer.decode(d)})},pc=de,uc=e.frame(ic),lc={preencode(e,d){pc.preencode(e,d.header),uc.preencode(e,d.invitation)},encode(e,d){pc.encode(e,d.header),uc.encode(e,d.invitation)},decode:e=>({header:pc.decode(e),invitation:uc.decode(e)})},fc=de,mc={preencode(d,o){fc.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){fc.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:fc.decode(d),id:e.fixed32.decode(d)})},yc={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.devicePublicKey),d.end++,o.privateProfileKey&&e.fixed32.preencode(d,o.privateProfileKey),o.deviceKeyPair&&r.preencode(d,o.deviceKeyPair),e.buffer.preencode(d,o.deviceProof)},encode(d,o){const n=(o.privateProfileKey?1:0)|(o.deviceKeyPair?2:0);e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.devicePublicKey),e.uint.encode(d,n),o.privateProfileKey&&e.fixed32.encode(d,o.privateProfileKey),o.deviceKeyPair&&r.encode(d,o.deviceKeyPair),e.buffer.encode(d,o.deviceProof)},decode(d){const o=e.fixed32.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{publicKey:o,devicePublicKey:n,privateProfileKey:1&c?e.fixed32.decode(d):null,deviceKeyPair:2&c?r.decode(d):null,deviceProof:e.buffer.decode(d)}}},xc={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.writerKey),e.fixed32.preencode(d,o.devicePublicKey),d.end++,o.privateProfileKey&&e.fixed32.preencode(d,o.privateProfileKey)},encode(d,o){const n=o.privateProfileKey?1:0;e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.writerKey),e.fixed32.encode(d,o.devicePublicKey),e.uint.encode(d,n),o.privateProfileKey&&e.fixed32.encode(d,o.privateProfileKey)},decode:d=>({publicKey:e.fixed32.decode(d),writerKey:e.fixed32.decode(d),devicePublicKey:e.fixed32.decode(d),privateProfileKey:1&e.uint.decode(d)?e.fixed32.decode(d):null})},bc={preencode(o,n){o.end++,d>=11&&n.roomSnoozeTime&&e.uint.preencode(o,n.roomSnoozeTime)},encode(o,n){const c=(n.isActive?1:0)|(n.isFullyMuted?2:0)|(n.isMentionsOnlyMuted?4:0)|(n.isReadOnly?8:0)|(d>=3&&n.isFavorite?16:0)|(d>=7&&n.isUnread?32:0)|(d>=11&&n.roomSnoozeTime?64:0);e.uint.encode(o,c),d>=11&&n.roomSnoozeTime&&e.uint.encode(o,n.roomSnoozeTime)},decode(o){const n=e.uint.decode(o);return{isActive:!!(1&n),isFullyMuted:!!(2&n),isMentionsOnlyMuted:!!(4&n),isReadOnly:!!(8&n),isFavorite:d>=3&&!!(16&n),isUnread:d>=7&&!!(32&n),roomSnoozeTime:d>=11&&64&n?e.uint.decode(o):0}}},vc=e.frame(bc),gc=e.frame(yc),Kc=tc,kc={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),vc.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,c.initiator&&o.preencode(n,c.initiator),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),c.identitySwap&&gc.preencode(n,c.identitySwap),c.identitySwapV2&&Kc.preencode(n,c.identitySwapV2),c.contact&&e.fixed32.preencode(n,c.contact),d>=13&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=15&&c.activeClock&&e.uint.preencode(n,c.activeClock)},encode(n,c){const r=(c.initiator?1:0)|(c.fastForwardTo?2:0)|(c.identitySwap?4:0)|(c.identitySwapV2?8:0)|(c.contact?16:0)|(d>=13&&c.bootFrom?32:0)|(d>=15&&c.activeClock?64:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),vc.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,r),c.initiator&&o.encode(n,c.initiator),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),c.identitySwap&&gc.encode(n,c.identitySwap),c.identitySwapV2&&Kc.encode(n,c.identitySwapV2),c.contact&&e.fixed32.encode(n,c.contact),d>=13&&c.bootFrom&&o.encode(n,c.bootFrom),d>=15&&c.activeClock&&e.uint.encode(n,c.activeClock)},decode(n){const c=e.fixed32.decode(n),r=e.buffer.decode(n),t=e.fixed32.decode(n),i=vc.decode(n),a=e.uint.decode(n),s=e.uint.decode(n);return{roomKey:c,encryptionKey:r,mailbox:t,status:i,clock:a,initiator:1&s?o.decode(n):null,fastForwardTo:2&s?e.fixed32.decode(n):null,identitySwap:4&s?gc.decode(n):null,identitySwapV2:8&s?Kc.decode(n):null,contact:16&s?e.fixed32.decode(n):null,bootFrom:d>=13&&32&s?o.decode(n):null,activeClock:d>=15&&64&s?e.uint.decode(n):0}}},hc=de,wc={preencode(d,n){hc.preencode(d,n.header),e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.mailbox),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.dm&&e.fixed32.preencode(d,n.dm)},encode(d,n){const c=(n.fastForwardTo?1:0)|(n.initiator?2:0)|(n.dm?4:0)|(n.isReadOnly?8:0);hc.encode(d,n.header),e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.fixed32.encode(d,n.mailbox),e.uint.encode(d,c),n.fastForwardTo&&e.fixed32.encode(d,n.fastForwardTo),n.initiator&&o.encode(d,n.initiator),n.dm&&e.fixed32.encode(d,n.dm)},decode(d){const n=hc.decode(d),c=e.fixed32.decode(d),r=e.buffer.decode(d),t=e.fixed32.decode(d),i=e.uint.decode(d);return{header:n,roomKey:c,encryptionKey:r,mailbox:t,fastForwardTo:1&i?e.fixed32.decode(d):null,initiator:2&i?o.decode(d):null,dm:4&i?e.fixed32.decode(d):null,isReadOnly:!!(8&i)}}},Pc=de,Rc={preencode(d,o){Pc.preencode(d,o.header),e.fixed32.preencode(d,o.discoveryKey)},encode(d,o){Pc.encode(d,o.header),e.fixed32.encode(d,o.discoveryKey)},decode:d=>({header:Pc.decode(d),discoveryKey:e.fixed32.decode(d)})},Tc=de,Ac=vc,Sc={preencode(d,o){Tc.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.key),Ac.preencode(d,o.status)},encode(d,o){Tc.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.key),Ac.encode(d,o.status)},decode:d=>({header:Tc.decode(d),roomKey:e.fixed32.decode(d),key:e.uint.decode(d),status:Ac.decode(d)})},Ic={preencode(e,d){e.end++},encode(o,n){const c=(n.isBlocked?1:0)|(d>=8&&n.isActive?2:0);e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{isBlocked:!!(1&n),isActive:d>=8&&!!(2&n)}}},Mc=Qn,Fc={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.clock),ol.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=8&&n.contactInfo&&Mc.preencode(o,n.contactInfo),d>=10&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=8&&n.contactInfo?4:0)|(d>=10&&n.alias?8:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.clock),ol.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=8&&n.contactInfo&&Mc.encode(o,n.contactInfo),d>=10&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),r=ol.decode(o),t=e.uint.decode(o);return{memberKey:n,clock:c,status:r,mailbox:1&t?e.fixed32.decode(o):null,roomKey:2&t?e.fixed32.decode(o):null,contactInfo:d>=8&&4&t?Mc.decode(o):null,alias:d>=10&&8&t?e.string.decode(o):null}}},qc=de,Cc=e.frame(Xn),Vc={preencode(e,d){qc.preencode(e,d.header),Cc.preencode(e,d.contact)},encode(e,d){qc.encode(e,d.header),Cc.encode(e,d.contact)},decode:e=>({header:qc.decode(e),contact:Cc.decode(e)})},Hc=de,Dc={preencode(d,o){Hc.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),nl.preencode(d,o.status)},encode(d,o){Hc.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),nl.encode(d,o.status)},decode:d=>({header:Hc.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:nl.decode(d)})},Lc=de,jc={preencode(d,o){Lc.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Lc.encode(d,o.header),e.fixed32.encode(d,o.memberKey)},decode:d=>({header:Lc.decode(d),memberKey:e.fixed32.decode(d)})},Ec=de,Bc={preencode(d,o){Ec.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Ec.encode(d,o.header),e.fixed32.encode(d,o.memberKey)},decode:d=>({header:Ec.decode(d),memberKey:e.fixed32.decode(d)})},zc={preencode(e,d){e.end++},encode(d,o){const n=(o.isPending?1:0)|(o.isAccepted?2:0)|(o.isRejected?4:0)|(o.isDiscarded?8:0)|(o.isSeen?16:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isPending:!!(1&o),isAccepted:!!(2&o),isRejected:!!(4&o),isDiscarded:!!(8&o),isSeen:!!(16&o)}}},Oc=we,Nc=e.frame(t),Uc={preencode(d,o){Oc.preencode(d,o.sender),Nc.preencode(d,o.keys),e.fixed32.preencode(d,o.mailbox),d.end++,o.message&&e.string.preencode(d,o.message)},encode(d,o){const n=o.message?1:0;Oc.encode(d,o.sender),Nc.encode(d,o.keys),e.fixed32.encode(d,o.mailbox),e.uint.encode(d,n),o.message&&e.string.encode(d,o.message)},decode:d=>({sender:Oc.decode(d),keys:Nc.decode(d),mailbox:e.fixed32.decode(d),message:1&e.uint.decode(d)?e.string.decode(d):null})},Jc=e.frame(Uc),Wc={preencode(e,d){Jc.preencode(e,d.body),te.preencode(e,d.attestation)},encode(e,d){Jc.encode(e,d.body),te.encode(e,d.attestation)},decode:e=>({body:Jc.decode(e),attestation:te.decode(e)})},Gc=fe,Qc=e.frame(zc),Xc=Nc,Yc=Qn,Zc={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.clock),Gc.preencode(o,n.sender),Qc.preencode(o,n.status),Xc.preencode(o,n.keys),e.fixed32.preencode(o,n.mailbox),o.end++,n.message&&e.string.preencode(o,n.message),n.sentAt&&e.uint.preencode(o,n.sentAt),d>=8&&n.contactInfo&&Yc.preencode(o,n.contactInfo)},encode(o,n){const c=(n.message?1:0)|(n.sentAt?2:0)|(d>=8&&n.contactInfo?4:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.clock),Gc.encode(o,n.sender),Qc.encode(o,n.status),Xc.encode(o,n.keys),e.fixed32.encode(o,n.mailbox),e.uint.encode(o,c),n.message&&e.string.encode(o,n.message),n.sentAt&&e.uint.encode(o,n.sentAt),d>=8&&n.contactInfo&&Yc.encode(o,n.contactInfo)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),r=Gc.decode(o),t=Qc.decode(o),i=Xc.decode(o),a=e.fixed32.decode(o),s=e.uint.decode(o);return{memberKey:n,clock:c,sender:r,status:t,keys:i,mailbox:a,message:1&s?e.string.decode(o):null,sentAt:2&s?e.uint.decode(o):0,contactInfo:d>=8&&4&s?Yc.decode(o):null}}},$c=de,_c={preencode(d,o){$c.preencode(d,o.header),e.buffer.preencode(d,o.blindRequest)},encode(d,o){$c.encode(d,o.header),e.buffer.encode(d,o.blindRequest)},decode:d=>({header:$c.decode(d),blindRequest:e.buffer.decode(d)})},er=de,dr=Qc,or={preencode(d,o){er.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),dr.preencode(d,o.status),d.end++,o.roomKey&&e.fixed32.preencode(d,o.roomKey)},encode(d,o){const n=o.roomKey?1:0;er.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),dr.encode(d,o.status),e.uint.encode(d,n),o.roomKey&&e.fixed32.encode(d,o.roomKey)},decode:d=>({header:er.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:dr.decode(d),roomKey:1&e.uint.decode(d)?e.fixed32.decode(d):null})},nr={preencode(d,o){e.uint.preencode(d,o.timestamp),e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.mailbox)},encode(d,o){e.uint.encode(d,o.timestamp),e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.mailbox)},decode:d=>({version:e.uint.decode(d),timestamp:e.uint.decode(d),key:e.fixed32.decode(d),mailbox:e.fixed32.decode(d)})},cr={preencode(d,o){const n=o.version??1;switch(e.uint.preencode(d,n),n){case 0:case 1:nr.preencode(d,o);break;default:throw new Error("Unsupported version")}},encode(d,o){const n=o.version??1;switch(e.uint.encode(d,n),n){case 0:case 1:nr.encode(d,o);break;default:throw new Error("Unsupported version")}},decode(d){const o=d.start,n=e.uint.decode(d);switch(d.start=o,n){case 0:case 1:return nr.decode(d);default:throw new Error("Unsupported version")}}},rr={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.key)},decode:d=>({deviceKey:e.fixed32.decode(d),key:e.fixed32.decode(d)})},tr=de,ir={preencode(d,o){tr.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){tr.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:tr.decode(d),key:e.fixed32.decode(d)})},ar=de,sr={preencode(d,o){ar.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){ar.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:ar.decode(d),key:e.fixed32.decode(d)})},pr={preencode(o,n){o.end++,d>=9&&n.profileSnoozeTime&&e.uint.preencode(o,n.profileSnoozeTime)},encode(o,n){const c=(n.disableReadReceipts?1:0)|(d>=7&&n.stripAttachmentMetadata?2:0)|(d>=9&&n.profileSnoozeTime?4:0);e.uint.encode(o,c),d>=9&&n.profileSnoozeTime&&e.uint.encode(o,n.profileSnoozeTime)},decode(o){const n=e.uint.decode(o);return{disableReadReceipts:!!(1&n),stripAttachmentMetadata:d>=7&&!!(2&n),profileSnoozeTime:d>=9&&4&n?e.uint.decode(o):0}}},ur={disableReadReceipts:"disableReadReceipts",stripAttachmentMetadata:"stripAttachmentMetadata",profileSnoozeTime:"profileSnoozeTime"},lr={preencode(e,d){e.end++},encode(d,o){switch(o){case"disableReadReceipts":e.uint.encode(d,1);break;case"stripAttachmentMetadata":e.uint.encode(d,2);break;case"profileSnoozeTime":e.uint.encode(d,3);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"disableReadReceipts";case 2:return"stripAttachmentMetadata";case 3:return"profileSnoozeTime";default:return null}}},fr=de,mr=e.frame(pr),yr={preencode(e,d){fr.preencode(e,d.header),lr.preencode(e,d.key),mr.preencode(e,d.settings)},encode(e,d){fr.encode(e,d.header),lr.encode(e,d.key),mr.encode(e,d.settings)},decode:e=>({header:fr.decode(e),key:lr.decode(e),settings:mr.decode(e)})},xr={preencode(d,o){e.fixed32.preencode(d,o.discoveryPublicKey),e.uint.preencode(d,o.timestamp),d.end++,o.lastSynced&&e.uint.preencode(d,o.lastSynced)},encode(d,o){const n=(o.lastSynced?1:0)|(o.dirty?2:0);e.fixed32.encode(d,o.discoveryPublicKey),e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.lastSynced&&e.uint.encode(d,o.lastSynced)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d),c=e.uint.decode(d);return{discoveryPublicKey:o,timestamp:n,lastSynced:1&c?e.uint.decode(d):0,dirty:!!(2&c)}}},br={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.activeRooms)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.activeRooms)},decode:d=>({rooms:e.uint.decode(d),activeRooms:e.uint.decode(d)})},vr=F,gr=$,Kr={preencode(e,d){e.end++,d.blockedMembers&&gr.preencode(e,d.blockedMembers)},encode(d,o){const n=o.blockedMembers?1:0;e.uint.encode(d,n),o.blockedMembers&&gr.encode(d,o.blockedMembers)},decode:d=>({blockedMembers:1&e.uint.decode(d)?gr.decode(d):null})},kr=e.frame(Q),hr=e.frame(Kr),wr={preencode(d,n){e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.seed),kr.preencode(d,n.capabilities),o.preencode(d,n.initiator),e.fixed32.preencode(d,n.fastForwardTo),d.end++,n.privateProfile&&hr.preencode(d,n.privateProfile)},encode(d,n){const c=n.privateProfile?1:0;e.buffer.encode(d,n.encryptionKey),e.fixed32.encode(d,n.seed),kr.encode(d,n.capabilities),o.encode(d,n.initiator),e.fixed32.encode(d,n.fastForwardTo),e.uint.encode(d,c),n.privateProfile&&hr.encode(d,n.privateProfile)},decode:d=>({encryptionKey:e.buffer.decode(d),seed:e.fixed32.decode(d),capabilities:kr.decode(d),initiator:o.decode(d),fastForwardTo:e.fixed32.decode(d),privateProfile:1&e.uint.decode(d)?hr.decode(d):null})},Pr={preencode(d,o){d.end++,o.count&&e.uint.preencode(d,o.count)},encode(d,o){const n=o.count?1:0;e.uint.encode(d,n),o.count&&e.uint.encode(d,o.count)},decode:d=>({count:1&e.uint.decode(d)?e.uint.decode(d):0})},Rr=e.frame(wr),Tr={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.priority),d.end++,o.v3&&Rr.preencode(d,o.v3),o.timestamp&&e.uint.preencode(d,o.timestamp)},encode(d,o){const n=(o.v3?1:0)|(o.errored?2:0)|(o.timestamp?4:0);e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.priority),e.uint.encode(d,n),o.v3&&Rr.encode(d,o.v3),o.timestamp&&e.uint.encode(d,o.timestamp)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d),c=e.uint.decode(d);return{roomKey:o,priority:n,v3:1&c?Rr.decode(d):null,errored:!!(2&c),timestamp:4&c?e.uint.decode(d):0}}},Ar={preencode(e,d){e.end++},encode(d,o){const n=o.isConfirmed?1:0;e.uint.encode(d,n)},decode:d=>({isConfirmed:!!(1&e.uint.decode(d))})},Sr={preencode(d,o){e.fixed32.preencode(d,o.privateProfileKey)},encode(d,o){e.fixed32.encode(d,o.privateProfileKey)},decode:d=>({privateProfileKey:e.fixed32.decode(d)})},Ir=e.frame(Ar),Mr=gc,Fr=e.frame(xc),qr={preencode(o,n){e.fixed32.preencode(o,n.publicKey),e.fixed32.preencode(o,n.privateProfileKey),r.preencode(o,n.deviceKeyPair),e.buffer.preencode(o,n.deviceProof),Ir.preencode(o,n.status),o.end++,n.entropy&&e.buffer.preencode(o,n.entropy),n.swap&&Mr.preencode(o,n.swap),n.swapV2&&Fr.preencode(o,n.swapV2),d>=7&&n.proofShortenedAt&&e.uint.preencode(o,n.proofShortenedAt)},encode(o,n){const c=(n.entropy?1:0)|(n.swap?2:0)|(n.swapV2?4:0)|(d>=7&&n.proofShortenedAt?8:0);e.fixed32.encode(o,n.publicKey),e.fixed32.encode(o,n.privateProfileKey),r.encode(o,n.deviceKeyPair),e.buffer.encode(o,n.deviceProof),Ir.encode(o,n.status),e.uint.encode(o,c),n.entropy&&e.buffer.encode(o,n.entropy),n.swap&&Mr.encode(o,n.swap),n.swapV2&&Fr.encode(o,n.swapV2),d>=7&&n.proofShortenedAt&&e.uint.encode(o,n.proofShortenedAt)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=r.decode(o),i=e.buffer.decode(o),a=Ir.decode(o),s=e.uint.decode(o);return{publicKey:n,privateProfileKey:c,deviceKeyPair:t,deviceProof:i,status:a,entropy:1&s?e.buffer.decode(o):null,swap:2&s?Mr.decode(o):null,swapV2:4&s?Fr.decode(o):null,proofShortenedAt:d>=7&&8&s?e.uint.decode(o):0}}},Cr={RestoreIdentity:1,CreateRoom:2,LeaveRoom:3,ClearRoom:4,JoinRoomInvitation:5,JoinRoomKeys:6,JoinRoomResponse:7,SendContactRequest:8,TestFastTask:9,TestSlowTask:10,TestErrorTask:11},Vr={preencode(e,d){e.end++},encode(d,o){if(o>11)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Hr={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator)},encode(d,n){const c=(n.fastForwardTo?1:0)|(n.initiator?2:0);e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.uint.encode(d,c),n.fastForwardTo&&e.fixed32.encode(d,n.fastForwardTo),n.initiator&&o.encode(d,n.initiator)},decode(d){const n=e.fixed32.decode(d),c=e.buffer.decode(d),r=e.uint.decode(d);return{roomKey:n,encryptionKey:c,fastForwardTo:1&r?e.fixed32.decode(d):null,initiator:2&r?o.decode(d):null}}},Dr=uc,Lr={preencode(e,d){Dr.preencode(e,d.invitation)},encode(e,d){Dr.encode(e,d.invitation)},decode:e=>({invitation:Dr.decode(e)})},jr={preencode(d,o){e.fixed32.preencode(d,o.mailbox),r.preencode(d,o.keyPair),e.buffer.preencode(d,o.response)},encode(d,o){e.fixed32.encode(d,o.mailbox),r.encode(d,o.keyPair),e.buffer.encode(d,o.response)},decode:d=>({mailbox:e.fixed32.decode(d),keyPair:r.decode(d),response:e.buffer.decode(d)})},Er=ee,Br={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.mailbox&&e.fixed32.preencode(d,n.mailbox)},encode(d,n){const c=(n.fastForwardTo?1:0)|(n.initiator?2:0)|(n.mailbox?4:0);e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.uint.encode(d,c),n.fastForwardTo&&e.fixed32.encode(d,n.fastForwardTo),n.initiator&&o.encode(d,n.initiator),n.mailbox&&e.fixed32.encode(d,n.mailbox)},decode(d){const n=e.fixed32.decode(d),c=e.buffer.decode(d),r=e.uint.decode(d);return{roomKey:n,encryptionKey:c,fastForwardTo:1&r?e.fixed32.decode(d):null,initiator:2&r?o.decode(d):null,mailbox:4&r?e.fixed32.decode(d):null}}},zr=e.frame(Br),Or={preencode(o,n){zr.preencode(o,n.keys),o.end++,d>=15&&n.activeClock&&e.uint.preencode(o,n.activeClock)},encode(o,n){const c=(d>=15&&n.activeClock?1:0)|(d>=15&&n.isReadOnly?2:0);zr.encode(o,n.keys),e.uint.encode(o,c),d>=15&&n.activeClock&&e.uint.encode(o,n.activeClock)},decode(o){const n=zr.decode(o),c=o.start<o.end?e.uint.decode(o):0;return{keys:n,activeClock:d>=15&&1&c?e.uint.decode(o):0,isReadOnly:d>=15&&!!(2&c)}}},Nr=e.frame(kn),Ur={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.mailbox&&e.fixed32.preencode(d,n.mailbox),n.keyPair&&r.preencode(d,n.keyPair),n.genesis&&Nr.preencode(d,n.genesis)},encode(d,n){const c=(n.fastForwardTo?1:0)|(n.initiator?2:0)|(n.mailbox?4:0)|(n.keyPair?8:0)|(n.genesis?16:0)|(n.isPrivateProfile?32:0);e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.uint.encode(d,c),n.fastForwardTo&&e.fixed32.encode(d,n.fastForwardTo),n.initiator&&o.encode(d,n.initiator),n.mailbox&&e.fixed32.encode(d,n.mailbox),n.keyPair&&r.encode(d,n.keyPair),n.genesis&&Nr.encode(d,n.genesis)},decode(d){const n=e.fixed32.decode(d),c=e.buffer.decode(d),t=e.uint.decode(d);return{roomKey:n,encryptionKey:c,fastForwardTo:1&t?e.fixed32.decode(d):null,initiator:2&t?o.decode(d):null,mailbox:4&t?e.fixed32.decode(d):null,keyPair:8&t?r.decode(d):null,genesis:16&t?Nr.decode(d):null,isPrivateProfile:!!(32&t)}}},Jr={preencode(d,o){e.fixed32.preencode(d,o.roomKey),d.end++},encode(d,o){const n=o.isGossiped?1:0;e.fixed32.encode(d,o.roomKey),e.uint.encode(d,n)},decode:d=>({roomKey:e.fixed32.decode(d),isGossiped:!!(1&e.uint.decode(d))})},Wr={preencode(d,o){e.fixed32.preencode(d,o.roomKey)},encode(d,o){e.fixed32.encode(d,o.roomKey)},decode:d=>({roomKey:e.fixed32.decode(d)})},Gr={preencode(d,o){e.string.preencode(d,o.mnemonic),d.end++,o.profileDiscoveryTimeout&&e.uint.preencode(d,o.profileDiscoveryTimeout)},encode(d,o){const n=(o.profileDiscoveryTimeout?1:0)|(o.recover?2:0);e.string.encode(d,o.mnemonic),e.uint.encode(d,n),o.profileDiscoveryTimeout&&e.uint.encode(d,o.profileDiscoveryTimeout)},decode(d){const o=e.string.decode(d),n=e.uint.decode(d);return{mnemonic:o,profileDiscoveryTimeout:1&n?e.uint.decode(d):0,recover:!!(2&n)}}},Qr=Qn,Xr={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.fixed32.preencode(d,o.memberKey),d.end++,o.message&&e.string.preencode(d,o.message),o.contactInfo&&Qr.preencode(d,o.contactInfo)},encode(d,o){const n=(o.message?1:0)|(o.contactInfo?2:0);e.fixed32.encode(d,o.roomKey),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,n),o.message&&e.string.encode(d,o.message),o.contactInfo&&Qr.encode(d,o.contactInfo)},decode(d){const o=e.fixed32.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{roomKey:o,memberKey:n,message:1&c?e.string.decode(d):null,contactInfo:2&c?Qr.decode(d):null}}},Yr={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++},encode(d,o){const n=o.isPrivateProfile?1:0;e.fixed32.encode(d,o.key),e.uint.encode(d,n)},decode:d=>({key:e.fixed32.decode(d),isPrivateProfile:!!(1&e.uint.decode(d))})},Zr=e.frame(Gr),$r=e.frame(Ur),_r=e.frame(Jr),et=e.frame(Wr),dt=e.frame(Lr),ot=e.frame(Or),nt=e.frame(jr),ct=e.frame(Xr),rt=e.frame(Yr),tt={preencode(d,o){const n=(o.restoreIdentity?1:0)|(o.createRoom?2:0)|(o.leaveRoom?4:0)|(o.clearRoom?8:0)|(o.joinRoomInvitation?16:0)|(o.joinRoomKeys?32:0)|(o.joinRoomResponse?64:0)|(o.sendContactRequest?128:0)|(o.migrateV2Room?256:0);e.fixed32.preencode(d,o.discoveryKey),e.uint.preencode(d,o.priority),e.uint.preencode(d,o.timestamp),e.uint.preencode(d,o.type),e.uint.preencode(d,n),o.restoreIdentity&&Zr.preencode(d,o.restoreIdentity),o.createRoom&&$r.preencode(d,o.createRoom),o.leaveRoom&&_r.preencode(d,o.leaveRoom),o.clearRoom&&et.preencode(d,o.clearRoom),o.joinRoomInvitation&&dt.preencode(d,o.joinRoomInvitation),o.joinRoomKeys&&ot.preencode(d,o.joinRoomKeys),o.joinRoomResponse&&nt.preencode(d,o.joinRoomResponse),o.sendContactRequest&&ct.preencode(d,o.sendContactRequest),o.migrateV2Room&&rt.preencode(d,o.migrateV2Room)},encode(d,o){const n=(o.restoreIdentity?1:0)|(o.createRoom?2:0)|(o.leaveRoom?4:0)|(o.clearRoom?8:0)|(o.joinRoomInvitation?16:0)|(o.joinRoomKeys?32:0)|(o.joinRoomResponse?64:0)|(o.sendContactRequest?128:0)|(o.migrateV2Room?256:0);e.fixed32.encode(d,o.discoveryKey),e.uint.encode(d,o.priority),e.uint.encode(d,o.timestamp),e.uint.encode(d,o.type),e.uint.encode(d,n),o.restoreIdentity&&Zr.encode(d,o.restoreIdentity),o.createRoom&&$r.encode(d,o.createRoom),o.leaveRoom&&_r.encode(d,o.leaveRoom),o.clearRoom&&et.encode(d,o.clearRoom),o.joinRoomInvitation&&dt.encode(d,o.joinRoomInvitation),o.joinRoomKeys&&ot.encode(d,o.joinRoomKeys),o.joinRoomResponse&&nt.encode(d,o.joinRoomResponse),o.sendContactRequest&&ct.encode(d,o.sendContactRequest),o.migrateV2Room&&rt.encode(d,o.migrateV2Room)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d),c=e.uint.decode(d),r=e.uint.decode(d),t=e.uint.decode(d);return{discoveryKey:o,priority:n,timestamp:c,type:r,restoreIdentity:1&t?Zr.decode(d):null,createRoom:2&t?$r.decode(d):null,leaveRoom:4&t?_r.decode(d):null,clearRoom:8&t?et.decode(d):null,joinRoomInvitation:16&t?dt.decode(d):null,joinRoomKeys:32&t?ot.decode(d):null,joinRoomResponse:64&t?nt.decode(d):null,sendContactRequest:128&t?ct.decode(d):null,migrateV2Room:256&t?rt.decode(d):null}}},it=Oe,at={preencode(d,o){e.buffer.preencode(d,o.seed),it.preencode(d,o.invitation)},encode(d,o){e.buffer.encode(d,o.seed),it.encode(d,o.invitation)},decode:d=>({seed:e.buffer.decode(d),invitation:it.decode(d)})},st={preencode(e,d){e.end++},encode(d,o){const n=(o.isWritable?1:0)|(o.isReadable?2:0)|(o.isPrivateProfile?4:0)|(o.isRemoved?8:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isWritable:!!(1&o),isReadable:!!(2&o),isPrivateProfile:!!(4&o),isRemoved:!!(8&o)}}},pt={preencode(d,o){e.uint.preencode(d,o.creation),e.uint.preencode(d,o.latestSync),e.uint.preencode(d,o.latestChatMessage)},encode(d,o){e.uint.encode(d,o.creation),e.uint.encode(d,o.latestSync),e.uint.encode(d,o.latestChatMessage)},decode:d=>({creation:e.uint.decode(d),latestSync:e.uint.decode(d),latestChatMessage:e.uint.decode(d)})},ut=yn,lt=So,ft=e.frame(pt),mt=kr,yt=e.frame(st),xt=e.frame(pe),bt=e.frame(hd),vt=an,gt=vn,Kt=e.frame(Lo),kt=$,ht=e.array(e.frame(Wn)),wt=e.frame(gd),Pt=vc,Rt={preencode(o,n){const c=(n.selfDevice?1:0)|(n.selfMember?2:0)|(n.config?4:0)|(n.identity?8:0)|(n.lastMessage?16:0)|(n.dm?32:0)|(n.readLengths?64:0)|(n.lastMember?128:0)|(n.version?256:0)|(d>=3&&n.preferences?512:0)|(d>=4&&n.activeCall?1024:0)|(d>=8&&n.lastMessageLabels?2048:0)|(d>=9&&n.settings?4096:0)|(d>=13&&n.system?8192:0)|(d>=13&&n.processed?16384:0);e.fixed32.preencode(o,n.roomKey),e.fixed32.preencode(o,n.discoveryKey),e.buffer.preencode(o,n.encryptionKey),ut.preencode(o,n.digest),lt.preencode(o,n.stats),ft.preencode(o,n.timestamps),e.uint.preencode(o,n.fork),e.uint.preencode(o,n.length),e.fixed32.preencode(o,n.seed),mt.preencode(o,n.capabilities),yt.preencode(o,n.status),e.uint.preencode(o,c),n.selfDevice&&xt.preencode(o,n.selfDevice),n.selfMember&&bt.preencode(o,n.selfMember),n.config&&vt.preencode(o,n.config),n.identity&&gt.preencode(o,n.identity),n.lastMessage&&Kt.preencode(o,n.lastMessage),n.dm&&kt.preencode(o,n.dm),n.readLengths&&ht.preencode(o,n.readLengths),n.lastMember&&wt.preencode(o,n.lastMember),n.version&&e.uint.preencode(o,n.version),d>=3&&n.preferences&&Pt.preencode(o,n.preferences),d>=4&&n.activeCall&&cl.preencode(o,n.activeCall),d>=8&&n.lastMessageLabels&&rl.preencode(o,n.lastMessageLabels),d>=9&&n.settings&&tl.preencode(o,n.settings),d>=13&&n.system&&il.preencode(o,n.system),d>=13&&n.processed&&al.preencode(o,n.processed)},encode(o,n){const c=(n.selfDevice?1:0)|(n.selfMember?2:0)|(n.config?4:0)|(n.identity?8:0)|(n.lastMessage?16:0)|(n.dm?32:0)|(n.readLengths?64:0)|(n.lastMember?128:0)|(n.version?256:0)|(d>=3&&n.preferences?512:0)|(d>=4&&n.activeCall?1024:0)|(d>=8&&n.lastMessageLabels?2048:0)|(d>=9&&n.settings?4096:0)|(d>=13&&n.system?8192:0)|(d>=13&&n.processed?16384:0);e.fixed32.encode(o,n.roomKey),e.fixed32.encode(o,n.discoveryKey),e.buffer.encode(o,n.encryptionKey),ut.encode(o,n.digest),lt.encode(o,n.stats),ft.encode(o,n.timestamps),e.uint.encode(o,n.fork),e.uint.encode(o,n.length),e.fixed32.encode(o,n.seed),mt.encode(o,n.capabilities),yt.encode(o,n.status),e.uint.encode(o,c),n.selfDevice&&xt.encode(o,n.selfDevice),n.selfMember&&bt.encode(o,n.selfMember),n.config&&vt.encode(o,n.config),n.identity&&gt.encode(o,n.identity),n.lastMessage&&Kt.encode(o,n.lastMessage),n.dm&&kt.encode(o,n.dm),n.readLengths&&ht.encode(o,n.readLengths),n.lastMember&&wt.encode(o,n.lastMember),n.version&&e.uint.encode(o,n.version),d>=3&&n.preferences&&Pt.encode(o,n.preferences),d>=4&&n.activeCall&&cl.encode(o,n.activeCall),d>=8&&n.lastMessageLabels&&rl.encode(o,n.lastMessageLabels),d>=9&&n.settings&&tl.encode(o,n.settings),d>=13&&n.system&&il.encode(o,n.system),d>=13&&n.processed&&al.encode(o,n.processed)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.buffer.decode(o),t=ut.decode(o),i=lt.decode(o),a=ft.decode(o),s=e.uint.decode(o),p=e.uint.decode(o),u=e.fixed32.decode(o),l=mt.decode(o),f=yt.decode(o),m=e.uint.decode(o);return{roomKey:n,discoveryKey:c,encryptionKey:r,digest:t,stats:i,timestamps:a,fork:s,length:p,seed:u,capabilities:l,status:f,selfDevice:1&m?xt.decode(o):null,selfMember:2&m?bt.decode(o):null,config:4&m?vt.decode(o):null,identity:8&m?gt.decode(o):null,lastMessage:16&m?Kt.decode(o):null,dm:32&m?kt.decode(o):null,readLengths:64&m?ht.decode(o):null,lastMember:128&m?wt.decode(o):null,version:256&m?e.uint.decode(o):0,preferences:d>=3&&512&m?Pt.decode(o):null,activeCall:d>=4&&1024&m?cl.decode(o):null,lastMessageLabels:d>=8&&2048&m?rl.decode(o):null,settings:d>=9&&4096&m?tl.decode(o):null,system:d>=13&&8192&m?il.decode(o):null,processed:d>=13&&16384&m?al.decode(o):null}}},Tt=vc,At={preencode(d,o){e.fixed32.preencode(d,o.roomKey),Tt.preencode(d,o.status)},encode(d,o){e.fixed32.encode(d,o.roomKey),Tt.encode(d,o.status)},decode:d=>({roomKey:e.fixed32.decode(d),status:Tt.decode(d)})},St={preencode(d,o){e.fixed32.preencode(d,o.roomKey),d.end++,o.repairs&&e.uint.preencode(d,o.repairs)},encode(d,o){const n=o.repairs?1:0;e.fixed32.encode(d,o.roomKey),e.uint.encode(d,n),o.repairs&&e.uint.encode(d,o.repairs)},decode:d=>({roomKey:e.fixed32.decode(d),repairs:1&e.uint.decode(d)?e.uint.decode(d):0})},It={preencode(o,n){e.fixed32.preencode(o,n.mailbox),e.fixed32.preencode(o,n.key),o.end++,n.roomKey&&e.fixed32.preencode(o,n.roomKey),n.keyPair&&r.preencode(o,n.keyPair),n.responseKeyPair&&r.preencode(o,n.responseKeyPair),d>=15&&n.activeClock&&e.uint.preencode(o,n.activeClock)},encode(o,n){const c=(n.roomKey?1:0)|(n.keyPair?2:0)|(n.responseKeyPair?4:0)|(d>=14&&n.pending?8:0)|(d>=15&&n.activeClock?16:0);e.fixed32.encode(o,n.mailbox),e.fixed32.encode(o,n.key),e.uint.encode(o,c),n.roomKey&&e.fixed32.encode(o,n.roomKey),n.keyPair&&r.encode(o,n.keyPair),n.responseKeyPair&&r.encode(o,n.responseKeyPair),d>=15&&n.activeClock&&e.uint.encode(o,n.activeClock)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=e.uint.decode(o);return{mailbox:n,key:c,roomKey:1&t?e.fixed32.decode(o):null,keyPair:2&t?r.decode(o):null,responseKeyPair:4&t?r.decode(o):null,pending:d>=14&&!!(8&t),activeClock:d>=15&&16&t?e.uint.decode(o):0}}},Mt={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.responsePublicKey)},encode(d,o){e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.responsePublicKey)},decode:d=>({key:e.fixed32.decode(d),responsePublicKey:e.fixed32.decode(d)})},Ft=fe,qt={preencode(d,o){e.fixed32.preencode(d,o.key),Ft.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),Ft.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),profile:Ft.decode(d)})},Ct=xt,Vt={preencode(d,o){e.fixed32.preencode(d,o.roomKey),Ct.preencode(d,o.device)},encode(d,o){e.fixed32.encode(d,o.roomKey),Ct.encode(d,o.device)},decode:d=>({roomKey:e.fixed32.decode(d),device:Ct.decode(d)})},Ht=K,Dt={preencode(o,n){Ht.preencode(o,n.file),e.fixed32.preencode(o,n.roomKey),o.end++,n.encryptionKey&&e.buffer.preencode(o,n.encryptionKey),d>=4&&n.lastAccessed&&e.uint.preencode(o,n.lastAccessed),d>=4&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(n.encryptionKey?1:0)|(n.cleared?2:0)|(n.own?4:0)|(d>=4&&n.lastAccessed?8:0)|(d>=4&&n.version?16:0);Ht.encode(o,n.file),e.fixed32.encode(o,n.roomKey),e.uint.encode(o,c),n.encryptionKey&&e.buffer.encode(o,n.encryptionKey),d>=4&&n.lastAccessed&&e.uint.encode(o,n.lastAccessed),d>=4&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=Ht.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{file:n,roomKey:c,encryptionKey:1&r?e.buffer.decode(o):null,cleared:!!(2&r),own:!!(4&r),lastAccessed:d>=4&&8&r?e.uint.decode(o):0,version:d>=4&&16&r?e.uint.decode(o):0}}},Lt={preencode(d,o){d.end++,o.key&&e.string.preencode(d,o.key),o.description&&e.string.preencode(d,o.description)},encode(d,o){const n=(o.key?1:0)|(o.value?2:0)|(o.description?4:0);e.uint.encode(d,n),o.key&&e.string.encode(d,o.key),o.description&&e.string.encode(d,o.description)},decode(d){const o=e.uint.decode(d);return{key:1&o?e.string.decode(d):null,value:!!(2&o),description:4&o?e.string.decode(d):null}}},jt=e.array(e.frame(Lt)),Et={preencode(e,d){e.end++,d.flags&&jt.preencode(e,d.flags)},encode(d,o){const n=o.flags?1:0;e.uint.encode(d,n),o.flags&&jt.encode(d,o.flags)},decode:d=>({flags:1&e.uint.decode(d)?jt.decode(d):null})},Bt=ed,zt={preencode(d,o){d.end++,o.nodes&&Bt.preencode(d,o.nodes),o.concurrency&&e.uint.preencode(d,o.concurrency),o.maxWindow&&e.uint.preencode(d,o.maxWindow),o.randomPunchInterval&&e.uint.preencode(d,o.randomPunchInterval),o.connectionKeepAlive&&e.uint.preencode(d,o.connectionKeepAlive)},encode(d,o){const n=(o.nodes?1:0)|(o.concurrency?2:0)|(o.maxWindow?4:0)|(o.randomPunchInterval?8:0)|(o.connectionKeepAlive?16:0);e.uint.encode(d,n),o.nodes&&Bt.encode(d,o.nodes),o.concurrency&&e.uint.encode(d,o.concurrency),o.maxWindow&&e.uint.encode(d,o.maxWindow),o.randomPunchInterval&&e.uint.encode(d,o.randomPunchInterval),o.connectionKeepAlive&&e.uint.encode(d,o.connectionKeepAlive)},decode(d){const o=e.uint.decode(d);return{nodes:1&o?Bt.decode(d):null,concurrency:2&o?e.uint.decode(d):0,maxWindow:4&o?e.uint.decode(d):0,randomPunchInterval:8&o?e.uint.decode(d):0,connectionKeepAlive:16&o?e.uint.decode(d):0}}},Ot={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.count)},encode(d,o){e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.count)},decode:d=>({roomKey:e.fixed32.decode(d),count:e.uint.decode(d)})},Nt={preencode(d,o){d.end++,o.roomKey&&e.fixed32.preencode(d,o.roomKey),o.coreKey&&e.fixed32.preencode(d,o.coreKey)},encode(d,o){const n=(o.roomKey?1:0)|(o.coreKey?2:0);e.uint.encode(d,n),o.roomKey&&e.fixed32.encode(d,o.roomKey),o.coreKey&&e.fixed32.encode(d,o.coreKey)},decode(d){const o=e.uint.decode(d);return{roomKey:1&o?e.fixed32.decode(d):null,coreKey:2&o?e.fixed32.decode(d):null}}},Ut=e.frame(Nt),Jt={preencode(d,o){e.string.preencode(d,o.code),e.string.preencode(d,o.message),e.string.preencode(d,o.stack),e.uint.preencode(d,o.timestamp),d.end++,o.details&&Ut.preencode(d,o.details)},encode(d,o){const n=o.details?1:0;e.string.encode(d,o.code),e.string.encode(d,o.message),e.string.encode(d,o.stack),e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.details&&Ut.encode(d,o.details)},decode:d=>({code:e.string.decode(d),message:e.string.decode(d),stack:e.string.decode(d),timestamp:e.uint.decode(d),details:1&e.uint.decode(d)?Ut.decode(d):null})},Wt={RESUME:1,WAKEUP:2,PRESUSPEND:3,SUSPEND:4},Gt={preencode(e,d){e.end++},encode(d,o){if(o>4)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Qt={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.total)},encode(d,o){e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.total)},decode:d=>({roomKey:e.fixed32.decode(d),total:e.uint.decode(d)})},Xt=i,Yt={preencode(d,o){e.uint.preencode(d,o.duration)},encode(d,o){e.uint.encode(d,o.duration)},decode:d=>({duration:e.uint.decode(d)})},Zt=H,$t=H,_t=e.frame(Xt),ei={preencode(e,d){_t.preencode(e,d.header)},encode(e,d){_t.encode(e,d.header)},decode:e=>({header:_t.decode(e)})},di=e.frame(Yt),oi={preencode(e,d){di.preencode(e,d.header)},encode(e,d){di.encode(e,d.header)},decode:e=>({header:di.decode(e)})},ni=_t,ci={preencode(e,d){ni.preencode(e,d.header)},encode(e,d){ni.encode(e,d.header)},decode:e=>({header:ni.decode(e)})},ri=H,ti=_t,ii=an,ai=J,si={preencode(e,d){ti.preencode(e,d.header),e.end++,d.config&&ii.preencode(e,d.config),d.settings&&ai.preencode(e,d.settings)},encode(d,o){const n=(o.config?1:0)|(o.settings?2:0);ti.encode(d,o.header),e.uint.encode(d,n),o.config&&ii.encode(d,o.config),o.settings&&ai.encode(d,o.settings)},decode(d){const o=ti.decode(d),n=e.uint.decode(d);return{header:o,config:1&n?ii.decode(d):null,settings:2&n?ai.decode(d):null}}},pi=di,ui={preencode(d,o){pi.preencode(d,o.header),d.end++,o.roomKey&&e.fixed32.preencode(d,o.roomKey)},encode(d,o){const n=o.roomKey?1:0;pi.encode(d,o.header),e.uint.encode(d,n),o.roomKey&&e.fixed32.encode(d,o.roomKey)},decode:d=>({header:pi.decode(d),roomKey:1&e.uint.decode(d)?e.fixed32.decode(d):null})},li=_t,fi={preencode(d,o){li.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey)},encode(d,o){li.encode(d,o.header),e.fixed32.encode(d,o.roomKey)},decode:d=>({header:li.decode(d),roomKey:e.fixed32.decode(d)})},mi=_t,yi={preencode(d,o){mi.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey)},encode(d,o){mi.encode(d,o.header),e.fixed32.encode(d,o.roomKey)},decode:d=>({header:mi.decode(d),roomKey:e.fixed32.decode(d)})},xi=_t,bi={preencode(d,o){xi.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey)},encode(d,o){xi.encode(d,o.header),e.fixed32.encode(d,o.roomKey)},decode:d=>({header:xi.decode(d),roomKey:e.fixed32.decode(d)})},vi=di,gi={preencode(e,d){vi.preencode(e,d.header)},encode(e,d){vi.encode(e,d.header)},decode:e=>({header:vi.decode(e)})},Ki=_t,ki=an,hi={preencode(d,o){Ki.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.key),ki.preencode(d,o.config)},encode(d,o){Ki.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.key),ki.encode(d,o.config)},decode:d=>({header:Ki.decode(d),roomKey:e.fixed32.decode(d),key:e.uint.decode(d),config:ki.decode(d)})},wi=_t,Pi=J,Ri={preencode(d,o){wi.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.key),Pi.preencode(d,o.settings)},encode(d,o){wi.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.key),Pi.encode(d,o.settings)},decode:d=>({header:wi.decode(d),roomKey:e.fixed32.decode(d),key:e.uint.decode(d),settings:Pi.decode(d)})},Ti=_t,Ai=vc,Si={preencode(d,o){Ti.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.key),Ai.preencode(d,o.status)},encode(d,o){Ti.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.key),Ai.encode(d,o.status)},decode:d=>({header:Ti.decode(d),roomKey:e.fixed32.decode(d),key:e.uint.decode(d),status:Ai.decode(d)})},Ii=_t,Mi=Eo,Fi={preencode(d,o){Ii.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),Mi.preencode(d,o.message)},encode(d,o){Ii.encode(d,o.header),e.fixed32.encode(d,o.roomKey),Mi.encode(d,o.message)},decode:d=>({header:Ii.decode(d),roomKey:e.fixed32.decode(d),message:Mi.decode(d)})},qi=di,Ci={preencode(e,d){qi.preencode(e,d.header)},encode(e,d){qi.encode(e,d.header)},decode:e=>({header:qi.decode(e)})},Vi=_t,Hi=Eo,Di={preencode(d,o){Vi.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),n.preencode(d,o.id),Hi.preencode(d,o.message)},encode(d,o){Vi.encode(d,o.header),e.fixed32.encode(d,o.roomKey),n.encode(d,o.id),Hi.encode(d,o.message)},decode:d=>({header:Vi.decode(d),roomKey:e.fixed32.decode(d),id:n.decode(d),message:Hi.decode(d)})},Li=di,ji={preencode(e,d){Li.preencode(e,d.header)},encode(e,d){Li.encode(e,d.header)},decode:e=>({header:Li.decode(e)})},Ei=_t,Bi={preencode(d,o){Ei.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),n.preencode(d,o.id)},encode(d,o){Ei.encode(d,o.header),e.fixed32.encode(d,o.roomKey),n.encode(d,o.id)},decode:d=>({header:Ei.decode(d),roomKey:e.fixed32.decode(d),id:n.decode(d)})},zi=di,Oi={preencode(e,d){zi.preencode(e,d.header)},encode(e,d){zi.encode(e,d.header)},decode:e=>({header:zi.decode(e)})},Ni=_t,Ui={preencode(d,o){Ni.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),n.preencode(d,o.id),e.string.preencode(d,o.reaction)},encode(d,o){Ni.encode(d,o.header),e.fixed32.encode(d,o.roomKey),n.encode(d,o.id),e.string.encode(d,o.reaction)},decode:d=>({header:Ni.decode(d),roomKey:e.fixed32.decode(d),id:n.decode(d),reaction:e.string.decode(d)})},Ji=di,Wi={preencode(e,d){Ji.preencode(e,d.header)},encode(e,d){Ji.encode(e,d.header)},decode:e=>({header:Ji.decode(e)})},Gi=_t,Qi={preencode(d,o){Gi.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),n.preencode(d,o.id),e.string.preencode(d,o.reaction)},encode(d,o){Gi.encode(d,o.header),e.fixed32.encode(d,o.roomKey),n.encode(d,o.id),e.string.encode(d,o.reaction)},decode:d=>({header:Gi.decode(d),roomKey:e.fixed32.decode(d),id:n.decode(d),reaction:e.string.decode(d)})},Xi=di,Yi={preencode(e,d){Xi.preencode(e,d.header)},encode(e,d){Xi.encode(e,d.header)},decode:e=>({header:Xi.decode(e)})},Zi={preencode(d,o){e.uint.preencode(d,o.clock),e.uint.preencode(d,o.start),e.uint.preencode(d,o.end)},encode(d,o){e.uint.encode(d,o.clock),e.uint.encode(d,o.start),e.uint.encode(d,o.end)},decode:d=>({clock:e.uint.decode(d),start:e.uint.decode(d),end:e.uint.decode(d)})},$i=H,_i=$,ea={preencode(d,o){e.uint.preencode(d,o.clock),_i.preencode(d,o.keys)},encode(d,o){e.uint.encode(d,o.clock),_i.encode(d,o.keys)},decode:d=>({clock:e.uint.decode(d),keys:_i.decode(d)})},da={preencode(d,o){e.uint.preencode(d,o.clock),e.fixed32.preencode(d,o.roomKey),d.end++,o.start&&e.uint.preencode(d,o.start),o.size&&e.uint.preencode(d,o.size)},encode(d,o){const n=(o.start?1:0)|(o.size?2:0)|(o.isBottom?4:0);e.uint.encode(d,o.clock),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,n),o.start&&e.uint.encode(d,o.start),o.size&&e.uint.encode(d,o.size)},decode(d){const o=e.uint.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{clock:o,roomKey:n,start:1&c?e.uint.decode(d):0,size:2&c?e.uint.decode(d):0,isBottom:!!(4&c)}}},oa=H,na={preencode(d,o){e.uint.preencode(d,o.clock),e.fixed32.preencode(d,o.roomKey),d.end++,o.offset&&e.fixed32.preencode(d,o.offset),o.count&&e.uint.preencode(d,o.count)},encode(d,o){const n=(o.offset?1:0)|(o.count?2:0);e.uint.encode(d,o.clock),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,n),o.offset&&e.fixed32.encode(d,o.offset),o.count&&e.uint.encode(d,o.count)},decode(d){const o=e.uint.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{clock:o,roomKey:n,offset:1&c?e.fixed32.decode(d):null,count:2&c?e.uint.decode(d):0}}},ca=H,ra={preencode(d,o){e.uint.preencode(d,o.timestamp),e.fixed32.preencode(d,o.id)},encode(d,o){e.uint.encode(d,o.timestamp),e.fixed32.encode(d,o.id)},decode:d=>({timestamp:e.uint.decode(d),id:e.fixed32.decode(d)})},ta={Changed:1,Removed:2},ia={preencode(e,d){e.end++},encode(d,o){if(o>2)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},aa=$,sa={preencode(d,o){aa.preencode(d,o.keys),e.uint.preencode(d,o.start),e.uint.preencode(d,o.end),e.uint.preencode(d,o.total)},encode(d,o){aa.encode(d,o.keys),e.uint.encode(d,o.start),e.uint.encode(d,o.end),e.uint.encode(d,o.total)},decode:d=>({keys:aa.decode(d),start:e.uint.decode(d),end:e.uint.decode(d),total:e.uint.decode(d)})},pa={preencode(e,d){ia.preencode(e,d.type),ra.preencode(e,d.room)},encode(e,d){ia.encode(e,d.type),ra.encode(e,d.room)},decode:e=>({type:ia.decode(e),room:ra.decode(e)})},ua=yt,la=bd,fa={preencode(e,d){ua.preencode(e,d.device),e.end++,d.member&&la.preencode(e,d.member)},encode(d,o){const n=o.member?1:0;ua.encode(d,o.device),e.uint.encode(d,n),o.member&&la.encode(d,o.member)},decode:d=>({device:ua.decode(d),member:1&e.uint.decode(d)?la.decode(d):null})},ma=e.frame(fa),ya=yn,xa=an,ba={preencode(d,o){e.fixed32.preencode(d,o.id),ma.preencode(d,o.role),ya.preencode(d,o.digest),xa.preencode(d,o.config),d.end++,o.messageId&&n.preencode(d,o.messageId)},encode(d,o){const c=o.messageId?1:0;e.fixed32.encode(d,o.id),ma.encode(d,o.role),ya.encode(d,o.digest),xa.encode(d,o.config),e.uint.encode(d,c),o.messageId&&n.encode(d,o.messageId)},decode:d=>({id:e.fixed32.decode(d),role:ma.decode(d),digest:ya.decode(d),config:xa.decode(d),messageId:1&e.uint.decode(d)?n.decode(d):null})},va=yt,ga={preencode(d,o){e.fixed32.preencode(d,o.id),va.preencode(d,o.status)},encode(d,o){e.fixed32.encode(d,o.id),va.encode(d,o.status)},decode:d=>({id:e.fixed32.decode(d),status:va.decode(d)})},Ka=yn,ka={preencode(d,o){e.fixed32.preencode(d,o.id),Ka.preencode(d,o.digest)},encode(d,o){e.fixed32.encode(d,o.id),Ka.encode(d,o.digest)},decode:d=>({id:e.fixed32.decode(d),digest:Ka.decode(d)})},ha=an,wa={preencode(d,o){e.fixed32.preencode(d,o.id),ha.preencode(d,o.config)},encode(d,o){e.fixed32.encode(d,o.id),ha.encode(d,o.config)},decode:d=>({id:e.fixed32.decode(d),config:ha.decode(d)})},Pa=ma,Ra={preencode(d,o){e.fixed32.preencode(d,o.id),d.end++,o.role&&Pa.preencode(d,o.role)},encode(d,o){const n=o.role?1:0;e.fixed32.encode(d,o.id),e.uint.encode(d,n),o.role&&Pa.encode(d,o.role)},decode:d=>({id:e.fixed32.decode(d),role:1&e.uint.decode(d)?Pa.decode(d):null})},Ta={preencode(d,o){e.fixed32.preencode(d,o.id),n.preencode(d,o.lastMessage)},encode(d,o){e.fixed32.encode(d,o.id),n.encode(d,o.lastMessage)},decode:d=>({id:e.fixed32.decode(d),lastMessage:n.decode(d)})},Aa=fe,Sa={preencode(d,o){e.fixed32.preencode(d,o.key),Aa.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),Aa.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),profile:Aa.decode(d)})},Ia=ae,Ma={preencode(d,o){e.fixed32.preencode(d,o.key),Ia.preencode(d,o.status),sl.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),Ia.encode(d,o.status),sl.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),status:Ia.decode(d),profile:sl.decode(d)})},Fa={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.roomKey),e.fixed32.encode(d,o.key)},decode:d=>({roomKey:e.fixed32.decode(d),key:e.fixed32.decode(d)})},qa=Fa,Ca=e.array(n),Va={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.start),e.uint.preencode(d,o.size),e.uint.preencode(d,o.total),Ca.preencode(d,o.ids),d.end++},encode(d,o){const n=o.isBottom?1:0;e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.start),e.uint.encode(d,o.size),e.uint.encode(d,o.total),Ca.encode(d,o.ids),e.uint.encode(d,n)},decode:d=>({roomKey:e.fixed32.decode(d),start:e.uint.decode(d),size:e.uint.decode(d),total:e.uint.decode(d),ids:Ca.decode(d),isBottom:!!(1&e.uint.decode(d))})},Ha={preencode(d,o){e.uint.preencode(d,o.sent),d.end++,o.edited&&e.uint.preencode(d,o.edited)},encode(d,o){const n=o.edited?1:0;e.uint.encode(d,o.sent),e.uint.encode(d,n),o.edited&&e.uint.encode(d,o.edited)},decode:d=>({sent:e.uint.decode(d),edited:1&e.uint.decode(d)?e.uint.decode(d):0})},Da=e.frame(Ha),La=Mo,ja=Fo,Ea=qo,Ba={preencode(d,o){n.preencode(d,o.id),e.uint.preencode(d,o.clock),Da.preencode(d,o.timestamps),La.preencode(d,o.status),d.end++,o.message&&ja.preencode(d,o.message),o.event&&Ea.preencode(d,o.event)},encode(d,o){const c=(o.message?1:0)|(o.event?2:0);n.encode(d,o.id),e.uint.encode(d,o.clock),Da.encode(d,o.timestamps),La.encode(d,o.status),e.uint.encode(d,c),o.message&&ja.encode(d,o.message),o.event&&Ea.encode(d,o.event)},decode(d){const o=n.decode(d),c=e.uint.decode(d),r=Da.decode(d),t=La.decode(d),i=e.uint.decode(d);return{id:o,clock:c,timestamps:r,status:t,message:1&i?ja.decode(d):null,event:2&i?Ea.decode(d):null}}},za=e.frame(Ba),Oa=bd,Na={preencode(d,o){za.preencode(d,o.chat),e.fixed32.preencode(d,o.memberKey),Oa.preencode(d,o.role)},encode(d,o){za.encode(d,o.chat),e.fixed32.encode(d,o.memberKey),Oa.encode(d,o.role)},decode:d=>({chat:za.decode(d),memberKey:e.fixed32.decode(d),role:Oa.decode(d)})},Ua=za,Ja={preencode(e,d){Ua.preencode(e,d.chat)},encode(e,d){Ua.encode(e,d.chat)},decode:e=>({chat:Ua.decode(e)})},Wa=Ca,Ga={preencode(d,o){Wa.preencode(d,o.ids),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Wa.encode(d,o.ids),e.fixed32.encode(d,o.memberKey)},decode:d=>({ids:Wa.decode(d),memberKey:e.fixed32.decode(d)})},Qa=Ca,Xa=bd,Ya={preencode(e,d){Qa.preencode(e,d.ids),Xa.preencode(e,d.role)},encode(e,d){Qa.encode(e,d.ids),Xa.encode(e,d.role)},decode:e=>({ids:Qa.decode(e),role:Xa.decode(e)})},Za=e.frame(dn),$a={preencode(e,d){n.preencode(e,d.id),Za.preencode(e,d.reactions)},encode(e,d){n.encode(e,d.id),Za.encode(e,d.reactions)},decode:e=>({id:n.decode(e),reactions:Za.decode(e)})},_a=Za,es={preencode(e,d){n.preencode(e,d.id),_a.preencode(e,d.digest)},encode(e,d){n.encode(e,d.id),_a.encode(e,d.digest)},decode:e=>({id:n.decode(e),digest:_a.decode(e)})},ds=H,os=H,ns=e.array(e.frame(ic)),cs={preencode(e,d){ns.preencode(e,d.invitations)},encode(e,d){ns.encode(e,d.invitations)},decode:e=>({invitations:ns.decode(e)})},rs=e.frame(ud),ts={preencode(d,o){e.fixed32.preencode(d,o.roomKey),rs.preencode(d,o.request)},encode(d,o){e.fixed32.encode(d,o.roomKey),rs.encode(d,o.request)},decode:d=>({roomKey:e.fixed32.decode(d),request:rs.decode(d)})},is=e.array(e.frame(ts)),as={preencode(e,d){is.preencode(e,d.requests)},encode(e,d){is.encode(e,d.requests)},decode:e=>({requests:is.decode(e)})},ss=ns,ps=e.array(e.frame(ud)),us={preencode(e,d){ss.preencode(e,d.pendingInvitations),ps.preencode(e,d.identityJoinRequests)},encode(e,d){ss.encode(e,d.pendingInvitations),ps.encode(e,d.identityJoinRequests)},decode:e=>({pendingInvitations:ss.decode(e),identityJoinRequests:ps.decode(e)})},ls=_t,fs={preencode(d,o){ls.preencode(d,o.header),e.string.preencode(d,o.invitation),d.end++},encode(d,o){const n=o.isIdentity?1:0;ls.encode(d,o.header),e.string.encode(d,o.invitation),e.uint.encode(d,n)},decode:d=>({header:ls.decode(d),invitation:e.string.decode(d),isIdentity:!!(1&e.uint.decode(d))})},ms=di,ys={preencode(e,d){ms.preencode(e,d.header)},encode(e,d){ms.encode(e,d.header)},decode:e=>({header:ms.decode(e)})},xs={preencode(e,d){e.end++},encode(d,o){const n=(o.canModerate?1:0)|(o.canAdmin?2:0)|(o.requiresConfirmation?4:0)|(o.isReadOnly?8:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{canModerate:!!(1&o),canAdmin:!!(2&o),requiresConfirmation:!!(4&o),isReadOnly:!!(8&o)}}},bs=_t,vs=e.frame(xs),gs={preencode(d,o){bs.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),d.end++,o.permissions&&vs.preencode(d,o.permissions),o.expiration&&e.uint.preencode(d,o.expiration)},encode(d,o){const n=(o.permissions?1:0)|(o.expiration?2:0);bs.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,n),o.permissions&&vs.encode(d,o.permissions),o.expiration&&e.uint.encode(d,o.expiration)},decode(d){const o=bs.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{header:o,roomKey:n,permissions:1&c?vs.decode(d):null,expiration:2&c?e.uint.decode(d):0}}},Ks=di,ks={preencode(d,o){Ks.preencode(d,o.header),e.string.preencode(d,o.invitation)},encode(d,o){Ks.encode(d,o.header),e.string.encode(d,o.invitation)},decode:d=>({header:Ks.decode(d),invitation:e.string.decode(d)})},hs=_t,ws={preencode(e,d){hs.preencode(e,d.header)},encode(e,d){hs.encode(e,d.header)},decode:e=>({header:hs.decode(e)})},Ps=di,Rs={preencode(d,o){Ps.preencode(d,o.header),e.string.preencode(d,o.invitation)},encode(d,o){Ps.encode(d,o.header),e.string.encode(d,o.invitation)},decode:d=>({header:Ps.decode(d),invitation:e.string.decode(d)})},Ts=_t,As=rs,Ss={preencode(d,o){Ts.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),As.preencode(d,o.request)},encode(d,o){Ts.encode(d,o.header),e.fixed32.encode(d,o.roomKey),As.encode(d,o.request)},decode:d=>({header:Ts.decode(d),roomKey:e.fixed32.decode(d),request:As.decode(d)})},Is=di,Ms={preencode(e,d){Is.preencode(e,d.header)},encode(e,d){Is.encode(e,d.header)},decode:e=>({header:Is.decode(e)})},Fs=_t,qs=rs,Cs={preencode(d,o){Fs.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),qs.preencode(d,o.request)},encode(d,o){Fs.encode(d,o.header),e.fixed32.encode(d,o.roomKey),qs.encode(d,o.request)},decode:d=>({header:Fs.decode(d),roomKey:e.fixed32.decode(d),request:qs.decode(d)})},Vs=di,Hs={preencode(e,d){Vs.preencode(e,d.header)},encode(e,d){Vs.encode(e,d.header)},decode:e=>({header:Vs.decode(e)})},Ds=_t,Ls={preencode(d,o){Ds.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){Ds.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:Ds.decode(d),id:e.fixed32.decode(d)})},js=di,Es={preencode(e,d){js.preencode(e,d.header)},encode(e,d){js.encode(e,d.header)},decode:e=>({header:js.decode(e)})},Bs=_t,zs={preencode(d,o){Bs.preencode(d,o.header),e.string.preencode(d,o.displayName),d.end++,o.avatar&&e.buffer.preencode(d,o.avatar)},encode(d,o){const n=o.avatar?1:0;Bs.encode(d,o.header),e.string.encode(d,o.displayName),e.uint.encode(d,n),o.avatar&&e.buffer.encode(d,o.avatar)},decode:d=>({header:Bs.decode(d),displayName:e.string.decode(d),avatar:1&e.uint.decode(d)?e.buffer.decode(d):null})},Os=H,Ns=H,Us={preencode(e,d){e.end++},encode(d,o){const n=(o.isConfirmed?1:0)|(o.isLoggedOut?2:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isConfirmed:!!(1&o),isLoggedOut:!!(2&o)}}},Js=e.frame(Us),Ws=$,Gs={preencode(d,o){e.fixed32.preencode(d,o.memberKey),Js.preencode(d,o.status),Ws.preencode(d,o.deviceKeys)},encode(d,o){e.fixed32.encode(d,o.memberKey),Js.encode(d,o.status),Ws.encode(d,o.deviceKeys)},decode:d=>({memberKey:e.fixed32.decode(d),status:Js.decode(d),deviceKeys:Ws.decode(d)})},Qs={preencode(d,o){e.fixed32.preencode(d,o.memberKey)},encode(d,o){e.fixed32.encode(d,o.memberKey)},decode:d=>({memberKey:e.fixed32.decode(d)})},Xs={preencode(d,o){e.fixed32.preencode(d,o.deviceKey)},encode(d,o){e.fixed32.encode(d,o.deviceKey)},decode:d=>({deviceKey:e.fixed32.decode(d)})},Ys=_t,Zs={preencode(d,o){Ys.preencode(d,o.header),e.string.preencode(d,o.password)},encode(d,o){Ys.encode(d,o.header),e.string.encode(d,o.password)},decode:d=>({header:Ys.decode(d),password:e.string.decode(d)})},$s=di,_s={preencode(d,o){$s.preencode(d,o.header),e.string.preencode(d,o.inspector)},encode(d,o){$s.encode(d,o.header),e.string.encode(d,o.inspector)},decode:d=>({header:$s.decode(d),inspector:e.string.decode(d)})},ep=di,dp={preencode(e,d){ep.preencode(e,d.header)},encode(e,d){ep.encode(e,d.header)},decode:e=>({header:ep.decode(e)})},op=di,np={preencode(e,d){op.preencode(e,d.header)},encode(e,d){op.encode(e,d.header)},decode:e=>({header:op.decode(e)})},cp={Flag:1},rp={preencode(e,d){e.end++},encode(d,o){if(o>1)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},tp={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),rp.preencode(d,o.label)},encode(d,o){e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),rp.encode(d,o.label)},decode:d=>({key:e.fixed32.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),label:rp.decode(d)})},ip=de,ap={preencode(d,o){ip.preencode(d,o.header),e.fixed32.preencode(d,o.key),rp.preencode(d,o.label)},encode(d,o){ip.encode(d,o.header),e.fixed32.encode(d,o.key),rp.encode(d,o.label)},decode:d=>({header:ip.decode(d),key:e.fixed32.decode(d),label:rp.decode(d)})},sp={preencode(d,o){rp.preencode(d,o.label),e.uint.preencode(d,o.count)},encode(d,o){rp.encode(d,o.label),e.uint.encode(d,o.count)},decode:d=>({label:rp.decode(d),count:e.uint.decode(d)})},pp=e.array(e.frame(sp)),up={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.total),pp.preencode(d,o.labels),e.uint.preencode(d,o.editedAt),e.uint.preencode(d,o.flagsClock)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.total),pp.encode(d,o.labels),e.uint.encode(d,o.editedAt),e.uint.encode(d,o.flagsClock)},decode:d=>({key:e.fixed32.decode(d),total:e.uint.decode(d),labels:pp.decode(d),editedAt:e.uint.decode(d),flagsClock:e.uint.decode(d)})},lp=de,fp={preencode(d,o){lp.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.fromDeviceKey)},encode(d,o){lp.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.fromDeviceKey)},decode:d=>({header:lp.decode(d),deviceKey:e.fixed32.decode(d),fromDeviceKey:e.fixed32.decode(d)})},mp={preencode(d,o){e.float64.preencode(d,o.latitude),e.float64.preencode(d,o.longitude)},encode(d,o){e.float64.encode(d,o.latitude),e.float64.encode(d,o.longitude)},decode:d=>({latitude:e.float64.decode(d),longitude:e.float64.decode(d)})},yp=de,xp=$,bp={preencode(o,n){yp.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),e.buffer.preencode(o,n.encryptionKey),o.end++,d>=4&&n.streams&&xp.preencode(o,n.streams),d>=4&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=4&&n.version&&e.uint.preencode(o,n.version),d>=12&&n.streamInputs&&pl.preencode(o,n.streamInputs),d>=12&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey)},encode(o,n){const c=(d>=4&&n.streams?1:0)|(d>=4&&n.discoveryKey?2:0)|(d>=4&&n.version?4:0)|(d>=12&&n.streamInputs?8:0)|(d>=12&&n.swarmKey?16:0);yp.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,c),d>=4&&n.streams&&xp.encode(o,n.streams),d>=4&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=4&&n.version&&e.uint.encode(o,n.version),d>=12&&n.streamInputs&&pl.encode(o,n.streamInputs),d>=12&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey)},decode(o){const n=yp.decode(o),c=e.fixed32.decode(o),r=e.buffer.decode(o),t=e.uint.decode(o);return{header:n,callKey:c,encryptionKey:r,streams:d>=4&&1&t?xp.decode(o):null,discoveryKey:d>=4&&2&t?e.fixed32.decode(o):null,version:d>=4&&4&t?e.uint.decode(o):0,streamInputs:d>=12&&8&t?pl.decode(o):null,swarmKey:d>=12&&16&t?e.fixed32.decode(o):null}}},vp=de,gp=$,Kp={preencode(o,n){vp.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),o.end++,d>=4&&n.streams&&gp.preencode(o,n.streams),d>=12&&n.streamInputs&&ul.preencode(o,n.streamInputs),d>=12&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey)},encode(o,n){const c=(d>=4&&n.streams?1:0)|(d>=12&&n.streamInputs?2:0)|(d>=12&&n.swarmKey?4:0);vp.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.uint.encode(o,c),d>=4&&n.streams&&gp.encode(o,n.streams),d>=12&&n.streamInputs&&ul.encode(o,n.streamInputs),d>=12&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey)},decode(o){const n=vp.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{header:n,callKey:c,streams:d>=4&&1&r?gp.decode(o):null,streamInputs:d>=12&&2&r?ul.decode(o):null,swarmKey:d>=12&&4&r?e.fixed32.decode(o):null}}},kp=de,hp={preencode(d,o){kp.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){kp.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:kp.decode(d),callKey:e.fixed32.decode(d)})},wp=de,Pp={preencode(d,o){wp.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){wp.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:wp.decode(d),callKey:e.fixed32.decode(d)})},Rp=de,Tp={preencode(o,n){Rp.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.streamKey),o.end++,d>=12&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=12&&n.type&&e.string.preencode(o,n.type)},encode(o,n){const c=(d>=12&&n.mediaStreamId?1:0)|(d>=12&&n.type?2:0)|(d>=12&&n.muted?4:0);Rp.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.streamKey),e.uint.encode(o,c),d>=12&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=12&&n.type&&e.string.encode(o,n.type)},decode(o){const n=Rp.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=o.start<o.end?e.uint.decode(o):0;return{header:n,callKey:c,streamKey:r,mediaStreamId:d>=12&&1&t?e.string.decode(o):null,type:d>=12&&2&t?e.string.decode(o):null,muted:d>=12&&!!(4&t)}}},Ap=de,Sp={preencode(d,o){Ap.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.streamKey)},encode(d,o){Ap.encode(d,o.header),e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.streamKey)},decode:d=>({header:Ap.decode(d),callKey:e.fixed32.decode(d),streamKey:e.fixed32.decode(d)})},Ip={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.buffer.preencode(o,n.encryptionKey),e.uint.preencode(o,n.createdAt),o.end++,d>=4&&n.endedAt&&e.uint.preencode(o,n.endedAt),d>=4&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=4&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(d>=4&&n.endedAt?1:0)|(d>=4&&n.discoveryKey?2:0)|(d>=4&&n.version?4:0);e.fixed32.encode(o,n.callKey),e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=4&&n.endedAt&&e.uint.encode(o,n.endedAt),d>=4&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=4&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=e.fixed32.decode(o),c=e.buffer.decode(o),r=e.uint.decode(o),t=e.uint.decode(o);return{callKey:n,encryptionKey:c,createdAt:r,endedAt:d>=4&&1&t?e.uint.decode(o):0,discoveryKey:d>=4&&2&t?e.fixed32.decode(o):null,version:d>=4&&4&t?e.uint.decode(o):0}}},Mp={preencode(d,o){e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.createdAt)},encode(d,o){e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.createdAt)},decode:d=>({callKey:e.fixed32.decode(d),memberKey:e.fixed32.decode(d),createdAt:e.uint.decode(d)})},Fp={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.deviceKey),e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.createdAt),o.end++,d>=4&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),d>=8&&n.lastHeartbeatAt&&e.uint.preencode(o,n.lastHeartbeatAt)},encode(o,n){const c=(d>=4&&n.swarmKey?1:0)|(d>=8&&n.lastHeartbeatAt?2:0)|(d>=9&&n.isRecording?4:0);e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.deviceKey),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=4&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey),d>=8&&n.lastHeartbeatAt&&e.uint.encode(o,n.lastHeartbeatAt)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o),i=e.uint.decode(o);return{callKey:n,deviceKey:c,memberKey:r,createdAt:t,swarmKey:d>=4&&1&i?e.fixed32.decode(o):null,lastHeartbeatAt:d>=8&&2&i?e.uint.decode(o):0,isRecording:d>=9&&!!(4&i)}}},qp={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.deviceKey),e.buffer.preencode(o,n.streamKey),e.uint.preencode(o,n.createdAt),o.end++,d>=12&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=12&&n.type&&e.string.preencode(o,n.type),d>=12&&n.statusKey&&e.uint.preencode(o,n.statusKey)},encode(o,n){const c=(d>=12&&n.mediaStreamId?1:0)|(d>=12&&n.type?2:0)|(d>=12&&n.statusKey?4:0);e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.deviceKey),e.buffer.encode(o,n.streamKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=12&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=12&&n.type&&e.string.encode(o,n.type),d>=12&&n.statusKey&&e.uint.encode(o,n.statusKey)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.buffer.decode(o),t=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{callKey:n,deviceKey:c,streamKey:r,createdAt:t,mediaStreamId:d>=12&&1&i?e.string.decode(o):null,type:d>=12&&2&i?e.string.decode(o):null,statusKey:d>=12&&4&i?e.uint.decode(o):0}}},Cp={preencode(o,n){e.fixed32.preencode(o,n.callKey),o.end++,d>=4&&n.selfDeviceKey&&e.fixed32.preencode(o,n.selfDeviceKey),d>=12&&n.createdAt&&e.uint.preencode(o,n.createdAt)},encode(o,n){const c=(d>=4&&n.selfDeviceKey?1:0)|(d>=12&&n.createdAt?2:0);e.fixed32.encode(o,n.callKey),e.uint.encode(o,c),d>=4&&n.selfDeviceKey&&e.fixed32.encode(o,n.selfDeviceKey),d>=12&&n.createdAt&&e.uint.encode(o,n.createdAt)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o);return{callKey:n,selfDeviceKey:d>=4&&1&c?e.fixed32.decode(o):null,createdAt:d>=12&&2&c?e.uint.decode(o):0}}},Vp={preencode(d,o){e.uint.preencode(d,o.lastCleared)},encode(d,o){e.uint.encode(d,o.lastCleared)},decode:d=>({lastCleared:e.uint.decode(d)})},Hp={Nightly:"Nightly",Internal:"Internal",Production:"Production"},Dp={preencode(e,d){e.end++},encode(d,o){switch(o){case"Nightly":e.uint.encode(d,1);break;case"Internal":e.uint.encode(d,2);break;case"Production":e.uint.encode(d,3);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"Nightly";case 2:return"Internal";case 3:return"Production";default:return null}}},Lp=de,jp={preencode(e,d){Lp.preencode(e,d.header)},encode(e,d){Lp.encode(e,d.header)},decode:e=>({header:Lp.decode(e)})},Ep=de,Bp={preencode(e,d){Ep.preencode(e,d.header)},encode(e,d){Ep.encode(e,d.header)},decode:e=>({header:Ep.decode(e)})},zp={preencode(o,n){Dp.preencode(o,n.buildType),o.end++,d>=6&&n.latestOfflineAbi&&e.uint.preencode(o,n.latestOfflineAbi)},encode(o,n){const c=d>=6&&n.latestOfflineAbi?1:0;Dp.encode(o,n.buildType),e.uint.encode(o,c),d>=6&&n.latestOfflineAbi&&e.uint.encode(o,n.latestOfflineAbi)},decode(o){const n=Dp.decode(o),c=o.start<o.end?e.uint.decode(o):0;return{buildType:n,latestOfflineAbi:d>=6&&1&c?e.uint.decode(o):0}}},Op=de,Np={preencode(d,o){Op.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),e.buffer.preencode(d,o.deviceProof),e.buffer.preencode(d,o.writerProof)},encode(d,o){Op.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.buffer.encode(d,o.deviceProof),e.buffer.encode(d,o.writerProof)},decode:d=>({header:Op.decode(d),deviceKey:e.fixed32.decode(d),deviceProof:e.buffer.decode(d),writerProof:e.buffer.decode(d)})},Up={preencode(o,n){o.end++,d>=7&&n.otaResyncPrivateProfileBump&&e.uint.preencode(o,n.otaResyncPrivateProfileBump)},encode(o,n){const c=d>=7&&n.otaResyncPrivateProfileBump?1:0;e.uint.encode(o,c),d>=7&&n.otaResyncPrivateProfileBump&&e.uint.encode(o,n.otaResyncPrivateProfileBump)},decode(o){const n=e.uint.decode(o);return{otaResyncPrivateProfileBump:d>=7&&1&n?e.uint.decode(o):0}}},Jp={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.buffer.preencode(d,o.proof),e.uint.preencode(d,o.createdAt)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.buffer.encode(d,o.proof),e.uint.encode(d,o.createdAt)},decode:d=>({deviceKey:e.fixed32.decode(d),proof:e.buffer.decode(d),createdAt:e.uint.decode(d)})},Wp=de,Gp={preencode(d,o){Wp.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Wp.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Wp.decode(d),callKey:e.fixed32.decode(d)})},Qp=de,Xp={preencode(d,o){Qp.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.deviceKey)},encode(d,o){Qp.encode(d,o.header),e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.deviceKey)},decode:d=>({header:Qp.decode(d),callKey:e.fixed32.decode(d),deviceKey:e.fixed32.decode(d)})},Yp=e.frame(Nn),Zp=e.array(e.frame(Dn)),$p={preencode(e,d){Yp.preencode(e,d.digest),Zp.preencode(e,d.mine)},encode(e,d){Yp.encode(e,d.digest),Zp.encode(e,d.mine)},decode:e=>({digest:Yp.decode(e),mine:Zp.decode(e)})},_p=de,eu={preencode(d,o){_p.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){_p.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:_p.decode(d),callKey:e.fixed32.decode(d)})},du=de,ou={preencode(d,o){du.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){du.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:du.decode(d),callKey:e.fixed32.decode(d)})},nu={preencode(o,n){o.end++,d>=9&&n.profileSnoozeTime&&e.uint.preencode(o,n.profileSnoozeTime)},encode(o,n){const c=(d>=9&&n.disableReadReceipts?1:0)|(d>=9&&n.stripAttachmentMetadata?2:0)|(d>=9&&n.profileSnoozeTime?4:0);e.uint.encode(o,c),d>=9&&n.profileSnoozeTime&&e.uint.encode(o,n.profileSnoozeTime)},decode(o){const n=e.uint.decode(o);return{disableReadReceipts:d>=9&&!!(1&n),stripAttachmentMetadata:d>=9&&!!(2&n),profileSnoozeTime:d>=9&&4&n?e.uint.decode(o):0}}},cu={preencode(o,n){o.end++,d>=9&&n.maxPeers&&e.uint.preencode(o,n.maxPeers)},encode(o,n){const c=d>=9&&n.maxPeers?1:0;e.uint.encode(o,c),d>=9&&n.maxPeers&&e.uint.encode(o,n.maxPeers)},decode(o){const n=e.uint.decode(o);return{maxPeers:d>=9&&1&n?e.uint.decode(o):0}}},ru=de,tu={preencode(e,d){ru.preencode(e,d.header),n.preencode(e,d.oplog)},encode(e,d){ru.encode(e,d.header),n.encode(e,d.oplog)},decode:e=>({header:ru.decode(e),oplog:n.decode(e)})},iu=de,au={preencode(e,d){iu.preencode(e,d.header)},encode(e,d){iu.encode(e,d.header)},decode:e=>({header:iu.decode(e)})},su={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.timestamp)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.timestamp)},decode:d=>({memberKey:e.fixed32.decode(d),timestamp:e.uint.decode(d)})},pu=de,uu={preencode(o,n){pu.preencode(o,n.header),e.fixed32.preencode(o,n.memberKey),o.end++,d>=10&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=d>=10&&n.alias?1:0;pu.encode(o,n.header),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,c),d>=10&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=pu.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{header:n,memberKey:c,alias:d>=10&&1&r?e.string.decode(o):null}}},lu={preencode(d,o){e.uint.preencode(d,o.streams)},encode(d,o){e.uint.encode(d,o.streams)},decode:d=>({streams:e.uint.decode(d)})},fu={preencode(d,o){e.fixed32.preencode(d,o.streamKey),e.string.preencode(d,o.mediaStreamId),e.string.preencode(d,o.type),d.end++},encode(o,n){const c=d>=12&&n.muted?1:0;e.fixed32.encode(o,n.streamKey),e.string.encode(o,n.mediaStreamId),e.string.encode(o,n.type),e.uint.encode(o,c)},decode(o){const n=e.fixed32.decode(o),c=e.string.decode(o),r=e.string.decode(o),t=e.uint.decode(o);return{streamKey:n,mediaStreamId:c,type:r,muted:d>=12&&!!(1&t)}}},mu=de,yu={preencode(d,o){mu.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.streamKey),d.end++},encode(o,n){const c=d>=12&&n.muted?1:0;mu.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.streamKey),e.uint.encode(o,c)},decode(o){const n=mu.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o);return{header:n,callKey:c,streamKey:r,muted:d>=12&&!!(1&t)}}},xu={preencode(d,o){e.uint.preencode(d,o.statusKey),d.end++},encode(o,n){const c=d>=12&&n.muted?1:0;e.uint.encode(o,n.statusKey),e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o),c=e.uint.decode(o);return{statusKey:n,muted:d>=12&&!!(1&c)}}},bu={preencode(n,c){e.fixed32.preencode(n,c.key),n.end++,d>=13&&c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),d>=13&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=(d>=13&&c.encryptionKey?1:0)|(d>=13&&c.bootFrom?2:0);e.fixed32.encode(n,c.key),e.uint.encode(n,r),d>=13&&c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),d>=13&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.uint.decode(n);return{key:c,encryptionKey:d>=13&&1&r?e.buffer.decode(n):null,bootFrom:d>=13&&2&r?o.decode(n):null}}},vu={preencode(d,o){e.fixed32.preencode(d,o.hash)},encode(d,o){e.fixed32.encode(d,o.hash)},decode:d=>({hash:e.fixed32.decode(d)})},gu={preencode(d,o){e.fixed32.preencode(d,o.hash),e.buffer.preencode(d,o.data)},encode(d,o){e.fixed32.encode(d,o.hash),e.buffer.encode(d,o.data)},decode:d=>({hash:e.fixed32.decode(d),data:e.buffer.decode(d)})},Ku={preencode(n,c){o.preencode(n,c.autobeeMigrationHead),n.end++,d>=13&&c.legacyViewHead&&o.preencode(n,c.legacyViewHead),d>=13&&c.dbViewHead&&o.preencode(n,c.dbViewHead),d>=13&&c.blobsViewHead&&o.preencode(n,c.blobsViewHead),e.uint.preencode(n,c.createdAt)},encode(n,c){const r=(d>=13&&c.legacyViewHead?1:0)|(d>=13&&c.dbViewHead?2:0)|(d>=13&&c.blobsViewHead?4:0);o.encode(n,c.autobeeMigrationHead),e.uint.encode(n,r),d>=13&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=13&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=13&&c.blobsViewHead&&o.encode(n,c.blobsViewHead),e.uint.encode(n,c.createdAt)},decode(n){const c=o.decode(n),r=e.uint.decode(n);return{autobeeMigrationHead:c,legacyViewHead:d>=13&&1&r?o.decode(n):null,dbViewHead:d>=13&&2&r?o.decode(n):null,blobsViewHead:d>=13&&4&r?o.decode(n):null,createdAt:e.uint.decode(n)}}},ku=de,hu={preencode(e,n){ku.preencode(e,n.header),o.preencode(e,n.head),e.end++,d>=13&&n.legacyViewHead&&o.preencode(e,n.legacyViewHead),d>=13&&n.dbViewHead&&o.preencode(e,n.dbViewHead),d>=13&&n.blobsViewHead&&o.preencode(e,n.blobsViewHead)},encode(n,c){const r=(d>=13&&c.legacyViewHead?1:0)|(d>=13&&c.dbViewHead?2:0)|(d>=13&&c.blobsViewHead?4:0);ku.encode(n,c.header),o.encode(n,c.head),e.uint.encode(n,r),d>=13&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=13&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=13&&c.blobsViewHead&&o.encode(n,c.blobsViewHead)},decode(n){const c=ku.decode(n),r=o.decode(n),t=e.uint.decode(n);return{header:c,head:r,legacyViewHead:d>=13&&1&t?o.decode(n):null,dbViewHead:d>=13&&2&t?o.decode(n):null,blobsViewHead:d>=13&&4&t?o.decode(n):null}}},wu={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.fixed32.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.seed),n.end++,d>=13&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=d>=13&&c.bootFrom?1:0;e.fixed32.encode(n,c.roomKey),e.fixed32.encode(n,c.encryptionKey),e.fixed32.encode(n,c.seed),e.uint.encode(n,r),d>=13&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.fixed32.decode(n),t=e.fixed32.decode(n),i=e.uint.decode(n);return{roomKey:c,encryptionKey:r,seed:t,bootFrom:d>=13&&1&i?o.decode(n):null}}},Pu=bd,Ru={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.fixed32.preencode(d,o.deviceKey),e.uint.preencode(d,o.deviceLength),e.uint.preencode(d,o.clock),Pu.preencode(d,o.status)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,o.deviceLength),e.uint.encode(d,o.clock),Pu.encode(d,o.status)},decode:d=>({memberKey:e.fixed32.decode(d),deviceKey:e.fixed32.decode(d),deviceLength:e.uint.decode(d),clock:e.uint.decode(d),status:Pu.decode(d)})},Tu={preencode(d,o){e.fixed32.preencode(d,o.hash),e.buffer.preencode(d,o.blob)},encode(d,o){e.fixed32.encode(d,o.hash),e.buffer.encode(d,o.blob)},decode:d=>({hash:e.fixed32.decode(d),blob:e.buffer.decode(d)})},Au=vc,Su=gc,Iu=tc,Mu={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),Au.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,d>=13&&c.initiator&&o.preencode(n,c.initiator),d>=13&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=13&&c.identitySwap&&Su.preencode(n,c.identitySwap),d>=13&&c.identitySwapV2&&Iu.preencode(n,c.identitySwapV2),d>=13&&c.contact&&e.fixed32.preencode(n,c.contact)},encode(n,c){const r=(d>=13&&c.initiator?1:0)|(d>=13&&c.bootFrom?2:0)|(d>=13&&c.identitySwap?4:0)|(d>=13&&c.identitySwapV2?8:0)|(d>=13&&c.contact?16:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),Au.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,r),d>=13&&c.initiator&&o.encode(n,c.initiator),d>=13&&c.bootFrom&&o.encode(n,c.bootFrom),d>=13&&c.identitySwap&&Su.encode(n,c.identitySwap),d>=13&&c.identitySwapV2&&Iu.encode(n,c.identitySwapV2),d>=13&&c.contact&&e.fixed32.encode(n,c.contact)},decode(n){const c=e.fixed32.decode(n),r=e.buffer.decode(n),t=e.fixed32.decode(n),i=Au.decode(n),a=e.uint.decode(n),s=e.uint.decode(n);return{roomKey:c,encryptionKey:r,mailbox:t,status:i,clock:a,initiator:d>=13&&1&s?o.decode(n):null,bootFrom:d>=13&&2&s?o.decode(n):null,identitySwap:d>=13&&4&s?Su.decode(n):null,identitySwapV2:d>=13&&8&s?Iu.decode(n):null,contact:d>=13&&16&s?e.fixed32.decode(n):null}}},Fu=de,qu={preencode(n,c){Fu.preencode(n,c.header),e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),n.end++,d>=13&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=13&&c.initiator&&o.preencode(n,c.initiator),d>=13&&c.dm&&e.fixed32.preencode(n,c.dm)},encode(n,c){const r=(d>=13&&c.bootFrom?1:0)|(d>=13&&c.initiator?2:0)|(d>=13&&c.dm?4:0)|(d>=13&&c.isReadOnly?8:0);Fu.encode(n,c.header),e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),e.uint.encode(n,r),d>=13&&c.bootFrom&&o.encode(n,c.bootFrom),d>=13&&c.initiator&&o.encode(n,c.initiator),d>=13&&c.dm&&e.fixed32.encode(n,c.dm)},decode(n){const c=Fu.decode(n),r=e.fixed32.decode(n),t=e.buffer.decode(n),i=e.fixed32.decode(n),a=e.uint.decode(n);return{header:c,roomKey:r,encryptionKey:t,mailbox:i,bootFrom:d>=13&&1&a?o.decode(n):null,initiator:d>=13&&2&a?o.decode(n):null,dm:d>=13&&4&a?e.fixed32.decode(n):null,isReadOnly:d>=13&&!!(8&a)}}},Cu={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),n.end++,d>=13&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=13&&c.initiator&&o.preencode(n,c.initiator)},encode(n,c){const r=(d>=13&&c.bootFrom?1:0)|(d>=13&&c.initiator?2:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.uint.encode(n,r),d>=13&&c.bootFrom&&o.encode(n,c.bootFrom),d>=13&&c.initiator&&o.encode(n,c.initiator)},decode(n){const c=e.fixed32.decode(n),r=e.buffer.decode(n),t=e.uint.decode(n);return{roomKey:c,encryptionKey:r,bootFrom:d>=13&&1&t?o.decode(n):null,initiator:d>=13&&2&t?o.decode(n):null}}},Vu={preencode(d,o){e.fixed32.preencode(d,o.roomKey),ll.preencode(d,o.head),e.uint.preencode(d,o.timestamp),d.end++},encode(o,n){const c=d>=13&&n.incremental?1:0;e.fixed32.encode(o,n.roomKey),ll.encode(o,n.head),e.uint.encode(o,n.timestamp),e.uint.encode(o,c)},decode(o){const n=e.fixed32.decode(o),c=ll.decode(o),r=e.uint.decode(o),t=e.uint.decode(o);return{roomKey:n,head:c,timestamp:r,incremental:d>=13&&!!(1&t)}}},Hu={preencode(o,n){o.end++,d>=13&&n.key&&e.fixed32.preencode(o,n.key),e.uint.preencode(o,n.length)},encode(o,n){const c=d>=13&&n.key?1:0;e.uint.encode(o,c),d>=13&&n.key&&e.fixed32.encode(o,n.key),e.uint.encode(o,n.length)},decode(o){const n=e.uint.decode(o);return{key:d>=13&&1&n?e.fixed32.decode(o):null,length:e.uint.decode(o)}}},Du={preencode(n,c){e.fixed32.preencode(n,c.roomKey),n.end++,d>=13&&c.legacyViewHead&&o.preencode(n,c.legacyViewHead),d>=13&&c.dbViewHead&&o.preencode(n,c.dbViewHead),d>=13&&c.blobsViewHead&&o.preencode(n,c.blobsViewHead),d>=13&&c.autobeeMigrationHead&&o.preencode(n,c.autobeeMigrationHead)},encode(n,c){const r=(d>=13&&c.legacyViewHead?1:0)|(d>=13&&c.dbViewHead?2:0)|(d>=13&&c.blobsViewHead?4:0)|(d>=13&&c.autobeeMigrationHead?8:0);e.fixed32.encode(n,c.roomKey),e.uint.encode(n,r),d>=13&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=13&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=13&&c.blobsViewHead&&o.encode(n,c.blobsViewHead),d>=13&&c.autobeeMigrationHead&&o.encode(n,c.autobeeMigrationHead)},decode(n){const c=e.fixed32.decode(n),r=e.uint.decode(n);return{roomKey:c,legacyViewHead:d>=13&&1&r?o.decode(n):null,dbViewHead:d>=13&&2&r?o.decode(n):null,blobsViewHead:d>=13&&4&r?o.decode(n):null,autobeeMigrationHead:d>=13&&8&r?o.decode(n):null}}},Lu={preencode(d,o){e.fixed32.preencode(d,o.id),e.fixed32.preencode(d,o.writerKey),e.buffer.preencode(d,o.blindResponse)},encode(d,o){e.fixed32.encode(d,o.id),e.fixed32.encode(d,o.writerKey),e.buffer.encode(d,o.blindResponse)},decode:d=>({id:e.fixed32.decode(d),writerKey:e.fixed32.decode(d),blindResponse:e.buffer.decode(d)})},ju=de,Eu={preencode(d,o){ju.preencode(d,o.header),e.buffer.preencode(d,o.blindResponse)},encode(d,o){ju.encode(d,o.header),e.buffer.encode(d,o.blindResponse)},decode:d=>({header:ju.decode(d),blindResponse:e.buffer.decode(d)})},Bu=e.frame(qr),zu={preencode(o,n){e.string.preencode(o,n.mnemonic),o.end++,d>=15&&n.profileDiscoveryTimeout&&e.uint.preencode(o,n.profileDiscoveryTimeout),d>=15&&n.privateProfileKey&&e.fixed32.preencode(o,n.privateProfileKey),d>=15&&n.identity&&Bu.preencode(o,n.identity)},encode(o,n){const c=(d>=15&&n.profileDiscoveryTimeout?1:0)|(d>=15&&n.privateProfileKey?2:0)|(d>=15&&n.identity?4:0);e.string.encode(o,n.mnemonic),e.uint.encode(o,c),d>=15&&n.profileDiscoveryTimeout&&e.uint.encode(o,n.profileDiscoveryTimeout),d>=15&&n.privateProfileKey&&e.fixed32.encode(o,n.privateProfileKey),d>=15&&n.identity&&Bu.encode(o,n.identity)},decode(o){const n=e.string.decode(o),c=e.uint.decode(o);return{mnemonic:n,profileDiscoveryTimeout:d>=15&&1&c?e.uint.decode(o):0,privateProfileKey:d>=15&&2&c?e.fixed32.decode(o):null,identity:d>=15&&4&c?Bu.decode(o):null}}},Ou=e.frame(w),Nu=e.frame(lu),Uu=Ou,Ju=e.frame(le),Wu=Ou,Gu=Ju,Qu=e.frame(wu),Xu=Ju,Yu=e.frame(wd),Zu=e.frame(mp),$u=Zu,_u=Ou,el=Ou,dl=e.frame(Ic),ol=dl,nl=dl,cl=e.frame(Cp),rl=e.frame($p),tl=e.frame(nu),il=e.frame(Hu),al=il,sl=Ju,pl=e.array(e.frame(fu)),ul=pl,ll=il;function fl(e){switch(e){case"@keet/head":return o;case"@keet/oplog-id":return n;case"@keet/encryption-keypair":return c;case"@keet/signing-keypair":return r;case"@keet/room-keys":return t;case"@keet/operation-header":return i;case"@keet/blob-pointer":return a;case"@keet/file-dimensions":return s;case"@keet/file-metadata":return u;case"@keet/external-drive-pointer":return l;case"@keet/external-blob-pointer":return f;case"@keet/file-pointer":return x;case"@keet/file":return g;case"@keet/image-file":return w;case"@keet/file-status":return P;case"@keet/file-record":return A;case"@keet/device-status":return S;case"@keet/member-status":return I;case"@keet/member-moderation-status":return M;case"@keet/abi":return F;case"@keet/device-stats":return q;case"@keet/member-stats":return C;case"@keet/chat-stats":return V;case"@keet/file-stats":return H;case"@keet/stats":return B;case"@keet/room-type":return O;case"@keet/system-settings":return N;case"@keet/system-digest":return W;case"@keet/room-seed":return G;case"@keet/room-capabilities":return Q;case"@keet/room-supported-language":return Y;case"@keet/room-config":return _;case"@keet/blind-peer":return ee;case"@keet/add-blind-peer-operation":return ne;case"@keet/remove-blind-peer-operation":return re;case"@keet/identity-attestation":return te;case"@keet/device-invitation":return ie;case"@keet/device":return pe;case"@keet/member-profile":return ue;case"@keet/device-profile":return le;case"@keet/member-update":return me;case"@keet/device-update":return ye;case"@keet/member-contact-info":return be;case"@keet/signed-pairing-data":return ve;case"@keet/device-request-identity":return ge;case"@keet/device-response-identity":return Ke;case"@keet/device-identity":return ke;case"@keet/device-request-with-invitation":return Re;case"@keet/device-request-with-invitation-and-proof":return Ae;case"@keet/device-request-with-member-proof":return Me;case"@keet/device-request":return Ce;case"@keet/device-response":return De;case"@keet/invitation-metadata":return Le;case"@keet/invitation":return Be;case"@keet/add-invitation-operation":return Ne;case"@keet/remove-invitation-operation":return Je;case"@keet/sendable-room-invitation":return We;case"@keet/readonly-room-invitation":return Ge;case"@keet/sendable-identity-invitation":return Qe;case"@keet/sendable-contact-invitation":return Xe;case"@keet/sendable-invitation":return dd;case"@keet/add-device-operation":return nd;case"@keet/update-device-operation":return rd;case"@keet/remove-device-operation":return id;case"@keet/start-indexing-operation":return ad;case"@keet/stop-indexing-operation":return sd;case"@keet/join-request":return ud;case"@keet/accept-join-request-operation":return md;case"@keet/reject-join-request-operation":return xd;case"@keet/member":return gd;case"@keet/full-member":return hd;case"@keet/member-proofs":return wd;case"@keet/update-member-operation":return Td;case"@keet/change-member-status-operation":return Id;case"@keet/change-member-role-operation":return Fd;case"@keet/remove-member-operation":return Cd;case"@keet/member-activity":return Vd;case"@keet/member-joined-event":return Hd;case"@keet/member-left-event":return Dd;case"@keet/member-removed-event":return Ld;case"@keet/title-changed-chat-event":return jd;case"@keet/chat-event":return Nd;case"@keet/sendable-event":return Ud;case"@keet/display-range":return Jd;case"@keet/display-content-range":return Gd;case"@keet/mention-display-item":return Xd;case"@keet/translation-display-item":return Zd;case"@keet/link-preview":return eo;case"@keet/display-link-item":return co;case"@keet/display":return yo;case"@keet/oplog-message":return go;case"@keet/index-message":return ho;case"@keet/full-index-message":return Ro;case"@keet/message-status":return To;case"@keet/message-index-id":return Ao;case"@keet/thread":return Io;case"@keet/chat-message-record":return Co;case"@keet/full-chat-message-record":return Lo;case"@keet/add-chat-message-operation":return Bo;case"@keet/remove-chat-message-operation":return Oo;case"@keet/update-chat-message-operation":return Jo;case"@keet/pin-chat-message-operation":return Go;case"@keet/display-type":return Xo;case"@keet/add-file-preview-operation":return Zo;case"@keet/reaction":return $o;case"@keet/reactions-summary":return _o;case"@keet/reactions-digest":return dn;case"@keet/add-reaction-operation":return nn;case"@keet/remove-reaction-operation":return rn;case"@keet/update-room-config-operation":return sn;case"@keet/group-member":return pn;case"@keet/user-registry-info":return un;case"@keet/room-identity":return fn;case"@keet/genesis-operation":return kn;case"@keet/upgrade-operation":return wn;case"@keet/migrate-abi-operation":return Rn;case"@keet/system-settings-keys":return An;case"@keet/update-system-settings-operation":return Mn;case"@keet/test-increment-operation":return qn;case"@keet/test-collection-record-1":return Cn;case"@keet/label-type":return Hn;case"@keet/chat-label":return Dn;case"@keet/add-chat-label-operation":return jn;case"@keet/remove-chat-label-operation":return Bn;case"@keet/chat-label-summary":return zn;case"@keet/chat-label-digest":return Nn;case"@keet/update-read-length-operation":return Jn;case"@keet/read-length":return Wn;case"@keet/tmp-removed-member":return Gn;case"@keet-private-id/contact":return Xn;case"@keet-private-id/v3-room-migration-info":return Yn;case"@keet-private-id/run-v3-migration-operation":return _n;case"@keet-private-id/update-identity-operation":return dc;case"@keet-private-id/counters":return oc;case"@keet-private-id/stats":return nc;case"@keet-private-id/add-entropy-operation":return cc;case"@keet-private-id/pending-invitation-identity":return rc;case"@keet-private-id/pending-invitation":return ic;case"@keet-private-id/resolve-pending-invitation-operation":return sc;case"@keet-private-id/add-pending-invitation-operation":return lc;case"@keet-private-id/remove-pending-invitation-operation":return mc;case"@keet-private-id/identity-swap":return yc;case"@keet-private-id/identity-swap-v2":return xc;case"@keet-private-id/room-status":return bc;case"@keet-private-id/room":return kc;case"@keet-private-id/add-room-operation":return wc;case"@keet-private-id/remove-room-operation":return Rc;case"@keet-private-id/update-room-status-operation":return Sc;case"@keet-private-id/contact-status":return Ic;case"@keet-private-id/contact-record":return Fc;case"@keet-private-id/add-contact-operation":return Vc;case"@keet-private-id/update-contact-status-operation":return Dc;case"@keet-private-id/remove-contact-operation":return jc;case"@keet-private-id/activate-contact-room-operation":return Bc;case"@keet-private-id/contact-request-status":return zc;case"@keet-private-id/contact-request-body":return Uc;case"@keet-private-id/contact-request":return Wc;case"@keet-private-id/contact-request-record":return Zc;case"@keet-private-id/add-contact-request-operation":return _c;case"@keet-private-id/update-contact-request-status-operation":return or;case"@keet-private-id/profile-discovery-record-v1":return nr;case"@keet-private-id/profile-discovery-record":return cr;case"@keet-private-id/unreads":return rr;case"@keet-private-id/add-unreads-key-operation":return ir;case"@keet-private-id/remove-unreads-key-operation":return sr;case"@keet-private-id/settings":return pr;case"@keet-private-id/user-settings-key":return lr;case"@keet-private-id/update-settings-operation":return yr;case"@local/background-sync-room":return xr;case"@local/stats":return br;case"@local/migration-status":return vr;case"@local/v3-private-profile-migration":return Kr;case"@local/v3-room-migration":return wr;case"@local/room-migration-stats":return Pr;case"@local/room-migration":return Tr;case"@local/identity-status":return Ar;case"@local/identity-swap":return Sr;case"@local/identity-record":return qr;case"@local/tasks":return Vr;case"@local/room-keys":return Hr;case"@local/join-room-invitation-task":return Lr;case"@local/join-room-response-task":return jr;case"@local/fast-forward-to":return Er;case"@local/add-room-fields":return Br;case"@local/join-room-keys-task":return Or;case"@local/create-room-task":return Ur;case"@local/leave-room-task":return Jr;case"@local/clear-room-task":return Wr;case"@local/restore-identity-task":return Gr;case"@local/send-contact-request-task":return Xr;case"@local/migrate-v2-room-task":return Yr;case"@local/task":return tt;case"@local/shared-invitation":return at;case"@local/room-status":return st;case"@local/room-timestamps":return pt;case"@local/room":return Rt;case"@local/room-preferences":return At;case"@local/room-metadata":return St;case"@local/writer":return It;case"@local/writer-append":return Mt;case"@local/member":return qt;case"@local/device":return Vt;case"@local/file":return Dt;case"@local/debug-flag":return Lt;case"@local/debug":return Et;case"@local/hyperdht-record":return zt;case"@local/unread":return Ot;case"@local/error-record-details":return Nt;case"@local/error-record":return Jt;case"@local/keet-state":return Gt;case"@local/file-stats":return Qt;case"@api/request-header":return Xt;case"@api/response-header":return Yt;case"@api/subscription-request-header":return Zt;case"@api/subscription-response-header":return $t;case"@api/boot-request":return ei;case"@api/boot-response":return oi;case"@api/self-destruct-request":return ci;case"@api/core/have":return ri;case"@api/core/create-room-request":return si;case"@api/core/create-room-response":return ui;case"@api/core/activate-room-request":return fi;case"@api/core/deactivate-room-request":return yi;case"@api/core/leave-room-request":return bi;case"@api/core/leave-room-response":return gi;case"@api/core/update-room-config-request":return hi;case"@api/core/update-room-settings-request":return Ri;case"@api/core/update-room-status-request":return Si;case"@api/core/add-chat-message-request":return Fi;case"@api/core/add-chat-message-response":return Ci;case"@api/core/edit-chat-message-request":return Di;case"@api/core/edit-chat-message-response":return ji;case"@api/core/remove-chat-message-request":return Bi;case"@api/core/remove-chat-message-response":return Oi;case"@api/core/add-chat-reaction-request":return Ui;case"@api/core/add-chat-reaction-response":return Wi;case"@api/core/remove-chat-reaction-request":return Qi;case"@api/core/remove-chat-reaction-response":return Yi;case"@api/core/want-lobby":return Zi;case"@api/core/unwant-lobby":return $i;case"@api/core/want-room-info":return ea;case"@api/core/want-chat":return da;case"@api/core/unwant-chat":return oa;case"@api/core/want-members":return na;case"@api/core/unwant-members":return ca;case"@api/core/lobby-record":return ra;case"@api/core/lobby-record-change-type":return ia;case"@api/core/lobby":return sa;case"@api/core/lobby-room":return pa;case"@api/core/room-role":return fa;case"@api/core/room-info":return ba;case"@api/core/room-info-status":return ga;case"@api/core/room-info-digest":return ka;case"@api/core/room-info-config":return wa;case"@api/core/room-info-role":return Ra;case"@api/core/room-info-last-message":return Ta;case"@api/core/member":return Sa;case"@api/core/device":return Ma;case"@api/core/member-list-add":return Fa;case"@api/core/member-list-remove":return qa;case"@api/core/chat-reset":return Va;case"@api/core/message-timestamps":return Ha;case"@api/core/message":return Ba;case"@api/core/message-info":return Na;case"@api/core/message-info-chat":return Ja;case"@api/core/message-info-member":return Ga;case"@api/core/message-info-role":return Ya;case"@api/core/message-info-reactions":return $a;case"@api/core/reactions":return es;case"@api/core/want-pairing":return ds;case"@api/core/unwant-pairing":return os;case"@api/core/pending-invitations":return cs;case"@api/core/join-request":return ts;case"@api/core/join-requests":return as;case"@api/core/pairing":return us;case"@api/core/start-pairing-request":return fs;case"@api/core/start-pairing-response":return ys;case"@api/core/invitation-permissions":return xs;case"@api/core/create-room-invitation-request":return gs;case"@api/core/create-room-invitation-response":return ks;case"@api/core/create-identity-invitation-request":return ws;case"@api/core/create-identity-invitation-response":return Rs;case"@api/core/accept-join-request-request":return Ss;case"@api/core/accept-join-request-response":return Ms;case"@api/core/reject-join-request-request":return Cs;case"@api/core/reject-join-request-response":return Hs;case"@api/core/stop-pairing-request":return Ls;case"@api/core/stop-pairing-response":return Es;case"@api/core/update-profile-request":return zs;case"@api/core/want-identity":return Os;case"@api/core/unwant-identity":return Ns;case"@api/core/identity-status":return Us;case"@api/core/identity":return Gs;case"@api/core/identity-member":return Qs;case"@api/core/identity-device":return Xs;case"@api/debug/enable-request":return Zs;case"@api/debug/enable-response":return _s;case"@api/debug/disable-request":return dp;case"@api/debug/disable-response":return np;case"@keet/member-label-type":return rp;case"@keet/member-label":return tp;case"@keet/add-member-label-operation":return ap;case"@keet/member-label-summary":return sp;case"@keet/member-label-digest":return up;case"@keet/move-indexer-operation":return fp;case"@keet/location-shared-event":return mp;case"@keet/start-call":return bp;case"@keet/join-call":return Kp;case"@keet/leave-call":return hp;case"@keet/end-call":return Pp;case"@keet/add-call-stream":return Tp;case"@keet/remove-call-stream":return Sp;case"@keet/call-record":return Ip;case"@keet/call-member-record":return Mp;case"@keet/call-device-record":return Fp;case"@keet/call-stream-record":return qp;case"@local/active-call":return Cp;case"@local/file-gc-info":return Vp;case"@keet/build-type":return Dp;case"@keet/test-crash-operation":return jp;case"@keet/test-dispatch-error-operation":return Bp;case"@local/environment-record":return zp;case"@keet-private-id/shorten-device-attestation-operation":return Np;case"@local/ota-actions":return Up;case"@local/device-attestation":return Jp;case"@keet/call-device-heartbeat":return Gp;case"@keet/remove-call-device":return Xp;case"@local/chat-labels":return $p;case"@keet/start-call-recording":return eu;case"@keet/stop-call-recording":return ou;case"@local/settings":return nu;case"@local/hyperswarm-record":return cu;case"@keet/dismiss-chat-reports-operation":return tu;case"@keet/update-typing-indicator-operation":return au;case"@keet/typing-indicator":return su;case"@keet-private-id/update-contact-alias-operation":return uu;case"@keet/call-stats":return lu;case"@keet/call-stream-input":return fu;case"@keet/update-call-stream":return yu;case"@keet/call-stream-status-record":return xu;case"@keet/room-keys-v2":return bu;case"@keet/blob-pointer-v2":return vu;case"@keet/blob":return gu;case"@keet/autobee-migration":return Ku;case"@keet/autobee-migration-operation":return hu;case"@keet/readonly-room-invitation-v2":return wu;case"@keet/admin-last-seen":return Ru;case"@keet/blob-record":return Tu;case"@keet-private-id/room-v2":return Mu;case"@keet-private-id/add-room-operation-v2":return qu;case"@local/room-keys/v2":return Cu;case"@local/room-update":return Vu;case"@local/view-head":return Hu;case"@local/autobee-migration":return Du;case"@keet-private-id/pending-invitation-response":return Lu;case"@keet-private-id/resolve-pending-invitation-operation-v2":return Eu;case"@local/pending-recovery":return zu;default:throw new Error("Encoder not found "+e)}}function ml(e,o=15){const n=fl(e);return{preencode(e,c){d=o,n.preencode(e,c)},encode(e,c){d=o,n.encode(e,c)},decode:e=>(d=o,n.decode(e))}}const yl=ml;module.exports={resolveStruct:yl,getStruct:ml,getEnum:function(e){switch(e){case"@keet/room-type":return z;case"@keet/room-supported-language":return X;case"@keet/display-type":return Qo;case"@keet/system-settings-keys":return Tn;case"@keet/label-type":return Vn;case"@keet-private-id/user-settings-key":return ur;case"@local/tasks":return Cr;case"@local/keet-state":return Wt;case"@api/core/lobby-record-change-type":return ta;case"@keet/member-label-type":return cp;case"@keet/build-type":return Hp;default:throw new Error("Enum not found "+e)}},getEncoding:fl,encode:function(o,n,c=15){return d=c,e.encode(fl(o),n)},decode:function(o,n,c=15){return d=c,e.decode(fl(o),n)},setVersion:function(e){d=e},version:d};
1const{c:e}=require("hyperschema/runtime");let d=17;const o={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.length)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.length)},decode:d=>({key:e.fixed32.decode(d),length:e.uint.decode(d)})},n={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.seq)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.seq)},decode:d=>({key:e.fixed32.decode(d),seq:e.uint.decode(d)})},c={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.secretKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.secretKey)},decode:d=>({publicKey:e.fixed32.decode(d),secretKey:e.fixed32.decode(d)})},r={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed64.preencode(d,o.secretKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed64.encode(d,o.secretKey)},decode:d=>({publicKey:e.fixed32.decode(d),secretKey:e.fixed64.decode(d)})},t={preencode(n,c){e.fixed32.preencode(n,c.key),n.end++,c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),d>=13&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=(c.encryptionKey?1:0)|(c.fastForwardTo?2:0)|(d>=13&&c.bootFrom?4:0);e.fixed32.encode(n,c.key),e.uint.encode(n,r),c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),d>=13&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.uint.decode(n);return{key:c,encryptionKey:1&r?e.buffer.decode(n):null,fastForwardTo:2&r?e.fixed32.decode(n):null,bootFrom:d>=13&&4&r?o.decode(n):null}}},i={preencode(d,o){e.uint.preencode(d,o.timestamp)},encode(d,o){e.uint.encode(d,o.timestamp)},decode:d=>({timestamp:e.uint.decode(d)})},a={preencode(d,o){e.uint.preencode(d,o.blockOffset),e.uint.preencode(d,o.blockLength),e.uint.preencode(d,o.byteOffset),e.uint.preencode(d,o.byteLength)},encode(d,o){e.uint.encode(d,o.blockOffset),e.uint.encode(d,o.blockLength),e.uint.encode(d,o.byteOffset),e.uint.encode(d,o.byteLength)},decode:d=>({blockOffset:e.uint.decode(d),blockLength:e.uint.decode(d),byteOffset:e.uint.decode(d),byteLength:e.uint.decode(d)})},s={preencode(d,o){e.uint.preencode(d,o.width),e.uint.preencode(d,o.height)},encode(d,o){e.uint.encode(d,o.width),e.uint.encode(d,o.height)},decode:d=>({width:e.uint.decode(d),height:e.uint.decode(d)})},p=e.frame(s),u={preencode(d,o){d.end++,o.name&&e.string.preencode(d,o.name),o.mimetype&&e.string.preencode(d,o.mimetype),o.dimensions&&p.preencode(d,o.dimensions),o.userdata&&e.buffer.preencode(d,o.userdata),o.duration&&e.uint.preencode(d,o.duration)},encode(d,o){const n=(o.name?1:0)|(o.mimetype?2:0)|(o.dimensions?4:0)|(o.userdata?8:0)|(o.duration?16:0)|(o.isPreview?32:0);e.uint.encode(d,n),o.name&&e.string.encode(d,o.name),o.mimetype&&e.string.encode(d,o.mimetype),o.dimensions&&p.encode(d,o.dimensions),o.userdata&&e.buffer.encode(d,o.userdata),o.duration&&e.uint.encode(d,o.duration)},decode(d){const o=e.uint.decode(d);return{name:1&o?e.string.decode(d):null,mimetype:2&o?e.string.decode(d):null,dimensions:4&o?p.decode(d):null,userdata:8&o?e.buffer.decode(d):null,duration:16&o?e.uint.decode(d):0,isPreview:!!(32&o)}}},l={preencode(d,o){e.fixed32.preencode(d,o.key),e.string.preencode(d,o.path),e.uint.preencode(d,o.version),e.uint.preencode(d,o.size)},encode(d,o){e.fixed32.encode(d,o.key),e.string.encode(d,o.path),e.uint.encode(d,o.version),e.uint.encode(d,o.size)},decode:d=>({key:e.fixed32.decode(d),path:e.string.decode(d),version:e.uint.decode(d),size:e.uint.decode(d)})},f={preencode(d,o){e.fixed32.preencode(d,o.key),a.preencode(d,o.blob)},encode(d,o){e.fixed32.encode(d,o.key),a.encode(d,o.blob)},decode:d=>({key:e.fixed32.decode(d),blob:a.decode(d)})},m=e.frame(f),y=e.frame(l),x={preencode(o,n){o.end++,n.inlined&&e.buffer.preencode(o,n.inlined),n.blob&&a.preencode(o,n.blob),n.externalBlob&&m.preencode(o,n.externalBlob),n.externalDrive&&y.preencode(o,n.externalDrive),d>=13&&n.bee&&vu.preencode(o,n.bee)},encode(o,n){const c=(n.inlined?1:0)|(n.blob?2:0)|(n.externalBlob?4:0)|(n.externalDrive?8:0)|(d>=13&&n.bee?16:0);e.uint.encode(o,c),n.inlined&&e.buffer.encode(o,n.inlined),n.blob&&a.encode(o,n.blob),n.externalBlob&&m.encode(o,n.externalBlob),n.externalDrive&&y.encode(o,n.externalDrive),d>=13&&n.bee&&vu.encode(o,n.bee)},decode(o){const n=e.uint.decode(o);return{inlined:1&n?e.buffer.decode(o):null,blob:2&n?a.decode(o):null,externalBlob:4&n?m.decode(o):null,externalDrive:8&n?y.decode(o):null,bee:d>=13&&16&n?vu.decode(o):null}}},b=e.frame(x),v=e.frame(u),g={preencode(d,o){b.preencode(d,o.pointer),d.end++,o.metadata&&v.preencode(d,o.metadata),o.preview&&Zu.preencode(d,o.preview),o.hash&&e.fixed32.preencode(d,o.hash)},encode(d,o){const n=(o.metadata?1:0)|(o.preview?2:0)|(o.hash?4:0);b.encode(d,o.pointer),e.uint.encode(d,n),o.metadata&&v.encode(d,o.metadata),o.preview&&Zu.encode(d,o.preview),o.hash&&e.fixed32.encode(d,o.hash)},decode(d){const o=b.decode(d),n=e.uint.decode(d);return{pointer:o,metadata:1&n?v.decode(d):null,preview:2&n?Zu.decode(d):null,hash:4&n?e.fixed32.decode(d):null}}},k=e.frame(g),K=k,h=k,w={preencode(e,d){e.end++,d.small&&k.preencode(e,d.small),d.medium&&K.preencode(e,d.medium),d.large&&h.preencode(e,d.large)},encode(d,o){const n=(o.small?1:0)|(o.medium?2:0)|(o.large?4:0);e.uint.encode(d,n),o.small&&k.encode(d,o.small),o.medium&&K.encode(d,o.medium),o.large&&h.encode(d,o.large)},decode(d){const o=e.uint.decode(d);return{small:1&o?k.decode(d):null,medium:2&o?K.decode(d):null,large:4&o?h.decode(d):null}}},P={preencode(e,d){e.end++},encode(d,o){const n=o.isDeleted?1:0;e.uint.encode(d,n)},decode:d=>({isDeleted:!!(1&e.uint.decode(d))})},T=e.frame(P),R=k,A={preencode(d,o){e.uint.preencode(d,o.id),n.preencode(d,o.oplog),T.preencode(d,o.status),R.preencode(d,o.file),d.end++,o.version&&e.uint.preencode(d,o.version)},encode(d,o){const c=o.version?1:0;e.uint.encode(d,o.id),n.encode(d,o.oplog),T.encode(d,o.status),R.encode(d,o.file),e.uint.encode(d,c),o.version&&e.uint.encode(d,o.version)},decode:d=>({id:e.uint.decode(d),oplog:n.decode(d),status:T.decode(d),file:R.decode(d),version:1&e.uint.decode(d)?e.uint.decode(d):0})},S={preencode(e,d){e.end++},encode(d,o){const n=(o.isActive?1:0)|(o.isIndexing?2:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isActive:!!(1&o),isIndexing:!!(2&o)}}},I={preencode(d,o){const n=(o.isAdmin?1:0)|(o.isModerator?2:0)|(o.isPending?4:0)|(o.isActive?8:0)|(o.isMuted?16:0)|(o.isBanned?32:0)|(o.isShadowBanned?64:0)|(o.isRemoved?128:0);e.uint.preencode(d,n)},encode(d,o){const n=(o.isAdmin?1:0)|(o.isModerator?2:0)|(o.isPending?4:0)|(o.isActive?8:0)|(o.isMuted?16:0)|(o.isBanned?32:0)|(o.isShadowBanned?64:0)|(o.isRemoved?128:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isAdmin:!!(1&o),isModerator:!!(2&o),isPending:!!(4&o),isActive:!!(8&o),isMuted:!!(16&o),isBanned:!!(32&o),isShadowBanned:!!(64&o),isRemoved:!!(128&o)}}},M={preencode(e,d){e.end++},encode(d,o){const n=(o.isMuted?1:0)|(o.isBanned?2:0)|(o.isShadowBanned?4:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isMuted:!!(1&o),isBanned:!!(2&o),isShadowBanned:!!(4&o)}}},F={preencode(d,o){e.uint.preencode(d,o.version)},encode(d,o){e.uint.encode(d,o.version)},decode:d=>({version:e.uint.decode(d)})},q={preencode(d,o){e.uint.preencode(d,o.total),e.uint.preencode(d,o.active)},encode(d,o){e.uint.encode(d,o.total),e.uint.encode(d,o.active)},decode:d=>({total:e.uint.decode(d),active:e.uint.decode(d)})},C={preencode(d,o){e.uint.preencode(d,o.total),e.uint.preencode(d,o.active),e.uint.preencode(d,o.pending)},encode(d,o){e.uint.encode(d,o.total),e.uint.encode(d,o.active),e.uint.encode(d,o.pending)},decode:d=>({total:e.uint.decode(d),active:e.uint.decode(d),pending:e.uint.decode(d)})},V={preencode(d,o){e.uint.preencode(d,o.clock),e.uint.preencode(d,o.pinned),e.uint.preencode(d,o.threads),e.uint.preencode(d,o.timestamp),d.end++,o.flagsClock&&e.uint.preencode(d,o.flagsClock)},encode(d,o){const n=o.flagsClock?1:0;e.uint.encode(d,o.clock),e.uint.encode(d,o.pinned),e.uint.encode(d,o.threads),e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.flagsClock&&e.uint.encode(d,o.flagsClock)},decode:d=>({clock:e.uint.decode(d),pinned:e.uint.decode(d),threads:e.uint.decode(d),timestamp:e.uint.decode(d),flagsClock:1&e.uint.decode(d)?e.uint.decode(d):0})},H={preencode(d,o){e.uint.preencode(d,o.clock)},encode(d,o){e.uint.encode(d,o.clock)},decode:d=>({clock:e.uint.decode(d)})},D=e.frame(q),L=e.frame(C),j=e.frame(V),E=e.frame(H),B={preencode(e,o){D.preencode(e,o.devices),L.preencode(e,o.members),j.preencode(e,o.chat),E.preencode(e,o.files),e.end++,d>=12&&o.calls&&$u.preencode(e,o.calls)},encode(o,n){const c=d>=12&&n.calls?1:0;D.encode(o,n.devices),L.encode(o,n.members),j.encode(o,n.chat),E.encode(o,n.files),e.uint.encode(o,c),d>=12&&n.calls&&$u.encode(o,n.calls)},decode(o){const n=D.decode(o),c=L.decode(o),r=j.decode(o),t=E.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{devices:n,members:c,chat:r,files:t,calls:d>=12&&1&i?$u.decode(o):null}}},z={Default:1,Broadcast:2,DirectMessage:3},O={preencode(e,d){e.end++},encode(d,o){if(o>3)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},N={preencode(o,n){const c=(n.roomType?1:0)|(n.isExperimental?2:0)|(n.isJoiningDisabled?4:0)|(n.isAppendingDisabled?8:0)|(n.isCallingDisabled?16:0)|(n.isMembershipEventsDisabled?32:0)|(d>=4&&n.isAttachmentsDisabled?64:0)|(d>=4&&n.isLinksDisabled?128:0)|(d>=5&&n.buildType?256:0)|(d>=9&&n.isRoomInviteHidden?512:0);e.uint.preencode(o,c),n.roomType&&O.preencode(o,n.roomType),d>=5&&n.buildType&&Dp.preencode(o,n.buildType)},encode(o,n){const c=(n.roomType?1:0)|(n.isExperimental?2:0)|(n.isJoiningDisabled?4:0)|(n.isAppendingDisabled?8:0)|(n.isCallingDisabled?16:0)|(n.isMembershipEventsDisabled?32:0)|(d>=4&&n.isAttachmentsDisabled?64:0)|(d>=4&&n.isLinksDisabled?128:0)|(d>=5&&n.buildType?256:0)|(d>=9&&n.isRoomInviteHidden?512:0);e.uint.encode(o,c),n.roomType&&O.encode(o,n.roomType),d>=5&&n.buildType&&Dp.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{roomType:1&n?O.decode(o):0,isExperimental:!!(2&n),isJoiningDisabled:!!(4&n),isAppendingDisabled:!!(8&n),isCallingDisabled:!!(16&n),isMembershipEventsDisabled:!!(32&n),isAttachmentsDisabled:d>=4&&!!(64&n),isLinksDisabled:d>=4&&!!(128&n),buildType:d>=5&&256&n?Dp.decode(o):null,isRoomInviteHidden:d>=9&&!!(512&n)}}},U=e.frame(F),J=e.frame(N),W={preencode(d,o){U.preencode(d,o.abi),J.preencode(d,o.settings),e.uint.preencode(d,o.creationTime)},encode(d,o){U.encode(d,o.abi),J.encode(d,o.settings),e.uint.encode(d,o.creationTime)},decode:d=>({abi:U.decode(d),settings:J.decode(d),creationTime:e.uint.decode(d)})},G={preencode(d,o){e.fixed32.preencode(d,o.seed)},encode(d,o){e.fixed32.encode(d,o.seed)},decode:d=>({seed:e.fixed32.decode(d)})},Q={preencode(d,o){c.preencode(d,o.mailboxKeyPair),r.preencode(d,o.discoveryKeyPair),e.fixed32.preencode(d,o.wakeupTopic),e.fixed32.preencode(d,o.swarmTopic)},encode(d,o){c.encode(d,o.mailboxKeyPair),r.encode(d,o.discoveryKeyPair),e.fixed32.encode(d,o.wakeupTopic),e.fixed32.encode(d,o.swarmTopic)},decode:d=>({mailboxKeyPair:c.decode(d),discoveryKeyPair:r.decode(d),wakeupTopic:e.fixed32.decode(d),swarmTopic:e.fixed32.decode(d)})},X={en:"en",it:"it",ru:"ru",es:"es",de:"de"},Y={preencode(e,d){e.end++},encode(d,o){switch(o){case"en":e.uint.encode(d,1);break;case"it":e.uint.encode(d,2);break;case"ru":e.uint.encode(d,3);break;case"es":e.uint.encode(d,4);break;case"de":e.uint.encode(d,5);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"en";case 2:return"it";case 3:return"ru";case 4:return"es";case 5:return"de";default:return null}}},Z=e.array(Y),$=e.array(e.fixed32),_={preencode(d,o){d.end++,o.title&&e.string.preencode(d,o.title),o.avatar&&_u.preencode(d,o.avatar),o.description&&e.string.preencode(d,o.description),o.supportedLanguages&&Z.preencode(d,o.supportedLanguages),o.blindPeers&&$.preencode(d,o.blindPeers)},encode(d,o){const n=(o.title?1:0)|(o.avatar?2:0)|(o.description?4:0)|(o.supportedLanguages?8:0)|(o.blindPeers?16:0);e.uint.encode(d,n),o.title&&e.string.encode(d,o.title),o.avatar&&_u.encode(d,o.avatar),o.description&&e.string.encode(d,o.description),o.supportedLanguages&&Z.encode(d,o.supportedLanguages),o.blindPeers&&$.encode(d,o.blindPeers)},decode(d){const o=e.uint.decode(d);return{title:1&o?e.string.decode(d):null,avatar:2&o?_u.decode(d):null,description:4&o?e.string.decode(d):null,supportedLanguages:8&o?Z.decode(d):null,blindPeers:16&o?$.decode(d):null}}},ee={preencode(d,o){e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.key)},decode:d=>({key:e.fixed32.decode(d)})},de=e.frame(i),oe=e.frame(ee),ne={preencode(e,d){de.preencode(e,d.header),oe.preencode(e,d.peer)},encode(e,d){de.encode(e,d.header),oe.encode(e,d.peer)},decode:e=>({header:de.decode(e),peer:oe.decode(e)})},ce=de,re={preencode(d,o){ce.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){ce.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:ce.decode(d),key:e.fixed32.decode(d)})},te={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.buffer.preencode(d,o.proof)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.buffer.encode(d,o.proof)},decode:d=>({memberKey:e.fixed32.decode(d),proof:e.buffer.decode(d)})},ie={preencode(d,o){e.fixed32.preencode(d,o.id),e.buffer.preencode(d,o.response)},encode(d,o){e.fixed32.encode(d,o.id),e.buffer.encode(d,o.response)},decode:d=>({id:e.fixed32.decode(d),response:e.buffer.decode(d)})},ae=e.frame(S),se=e.frame(ie),pe={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.memberKey),ae.preencode(d,o.status),el.preencode(d,o.profile),d.end++,o.invitation&&se.preencode(d,o.invitation)},encode(d,o){const n=o.invitation?1:0;e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.memberKey),ae.encode(d,o.status),el.encode(d,o.profile),e.uint.encode(d,n),o.invitation&&se.encode(d,o.invitation)},decode:d=>({key:e.fixed32.decode(d),memberKey:e.fixed32.decode(d),status:ae.decode(d),profile:el.decode(d),invitation:1&e.uint.decode(d)?se.decode(d):null})},ue={preencode(d,o){e.uint.preencode(d,o.timestamp),d.end++,o.mailbox&&e.fixed32.preencode(d,o.mailbox),o.displayName&&e.string.preencode(d,o.displayName),o.avatar&&dl.preencode(d,o.avatar),o.username&&e.string.preencode(d,o.username)},encode(d,o){const n=(o.mailbox?1:0)|(o.displayName?2:0)|(o.avatar?4:0)|(o.username?8:0);e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.mailbox&&e.fixed32.encode(d,o.mailbox),o.displayName&&e.string.encode(d,o.displayName),o.avatar&&dl.encode(d,o.avatar),o.username&&e.string.encode(d,o.username)},decode(d){const o=e.uint.decode(d),n=e.uint.decode(d);return{timestamp:o,mailbox:1&n?e.fixed32.decode(d):null,displayName:2&n?e.string.decode(d):null,avatar:4&n?dl.decode(d):null,username:8&n?e.string.decode(d):null}}},le={preencode(o,n){o.end++,n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),n.name&&e.string.preencode(o,n.name),d>=5&&n.buildType&&Dp.preencode(o,n.buildType)},encode(o,n){const c=(n.swarmKey?1:0)|(n.name?2:0)|(n.isMobile?4:0)|(d>=5&&n.buildType?8:0);e.uint.encode(o,c),n.swarmKey&&e.fixed32.encode(o,n.swarmKey),n.name&&e.string.encode(o,n.name),d>=5&&n.buildType&&Dp.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{swarmKey:1&n?e.fixed32.decode(o):null,name:2&n?e.string.decode(o):null,isMobile:!!(4&n),buildType:d>=5&&8&n?Dp.decode(o):null}}},fe=e.frame(ue),me={preencode(e,d){fe.preencode(e,d.profile),te.preencode(e,d.attestation)},encode(e,d){fe.encode(e,d.profile),te.encode(e,d.attestation)},decode:e=>({profile:fe.decode(e),attestation:te.decode(e)})},ye={preencode(e,d){ol.preencode(e,d.profile),te.preencode(e,d.attestation)},encode(e,d){ol.encode(e,d.profile),te.encode(e,d.attestation)},decode:e=>({profile:ol.decode(e),attestation:te.decode(e)})},xe=fe,be={preencode(e,d){xe.preencode(e,d.profile),te.preencode(e,d.attestation)},encode(e,d){xe.encode(e,d.profile),te.encode(e,d.attestation)},decode:e=>({profile:xe.decode(e),attestation:te.decode(e)})},ve={preencode(d,o){e.fixed32.preencode(d,o.id),e.buffer.preencode(d,o.data),e.buffer.preencode(d,o.signature)},encode(d,o){e.fixed32.encode(d,o.id),e.buffer.encode(d,o.data),e.buffer.encode(d,o.signature)},decode:d=>({id:e.fixed32.decode(d),data:e.buffer.decode(d),signature:e.buffer.decode(d)})},ge={preencode(d,o){e.fixed32.preencode(d,o.devicePublicKey)},encode(d,o){e.fixed32.encode(d,o.devicePublicKey)},decode:d=>({devicePublicKey:e.fixed32.decode(d)})},ke={preencode(d,o){te.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){te.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({privateProfileIdentity:te.decode(d),deviceProof:e.buffer.decode(d)})},Ke={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),te.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){e.fixed32.encode(d,o.deviceKey),te.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({deviceKey:e.fixed32.decode(d),privateProfileIdentity:te.decode(d),deviceProof:e.buffer.decode(d)})},he=e.frame(ye),we=e.frame(me),Pe=e.frame(ge),Te={preencode(n,c){e.fixed32.preencode(n,c.deviceKey),r.preencode(n,c.keyPair),he.preencode(n,c.device),we.preencode(n,c.member),n.end++,c.identity&&Pe.preencode(n,c.identity),d>=13&&c.link&&o.preencode(n,c.link)},encode(n,c){const t=(c.identity?1:0)|(d>=13&&c.link?2:0);e.fixed32.encode(n,c.deviceKey),r.encode(n,c.keyPair),he.encode(n,c.device),we.encode(n,c.member),e.uint.encode(n,t),c.identity&&Pe.encode(n,c.identity),d>=13&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),t=r.decode(n),i=he.decode(n),a=we.decode(n),s=e.uint.decode(n);return{deviceKey:c,keyPair:t,device:i,member:a,identity:1&s?Pe.decode(n):null,link:d>=13&&2&s?o.decode(n):null}}},Re=e.frame(Te),Ae={preencode(d,o){e.fixed32.preencode(d,o.id),Re.preencode(d,o.request),e.buffer.preencode(d,o.signature)},encode(d,o){e.fixed32.encode(d,o.id),Re.encode(d,o.request),e.buffer.encode(d,o.signature)},decode:d=>({id:e.fixed32.decode(d),request:Re.decode(d),signature:e.buffer.decode(d)})},Se=he,Ie=we,Me={preencode(e,d){Se.preencode(e,d.device),e.end++,d.member&&Ie.preencode(e,d.member)},encode(d,o){const n=o.member?1:0;Se.encode(d,o.device),e.uint.encode(d,n),o.member&&Ie.encode(d,o.member)},decode:d=>({device:Se.decode(d),member:1&e.uint.decode(d)?Ie.decode(d):null})},Fe=e.frame(Ae),qe=e.frame(Me),Ce={preencode(e,d){e.end++,d.withInvitation&&Fe.preencode(e,d.withInvitation),d.withMemberProof&&qe.preencode(e,d.withMemberProof)},encode(d,o){const n=(o.withInvitation?1:0)|(o.withMemberProof?2:0);e.uint.encode(d,n),o.withInvitation&&Fe.encode(d,o.withInvitation),o.withMemberProof&&qe.encode(d,o.withMemberProof)},decode(d){const o=e.uint.decode(d);return{withInvitation:1&o?Fe.decode(d):null,withMemberProof:2&o?qe.decode(d):null}}},Ve=e.frame(ve),He=e.frame(ke),De={preencode(e,d){Ve.preencode(e,d.signedKeys),e.end++,d.identity&&He.preencode(e,d.identity)},encode(d,o){const n=o.identity?1:0;Ve.encode(d,o.signedKeys),e.uint.encode(d,n),o.identity&&He.encode(d,o.identity)},decode:d=>({signedKeys:Ve.decode(d),identity:1&e.uint.decode(d)?He.decode(d):null})},Le={preencode(o,n){o.end++,n.expiration&&e.uint.preencode(o,n.expiration),d>=5&&n.buildType&&Dp.preencode(o,n.buildType)},encode(o,n){const c=(n.expiration?1:0)|(n.requiresConfirmation?2:0)|(n.canModerate?4:0)|(n.canAdmin?8:0)|(d>=5&&n.buildType?16:0);e.uint.encode(o,c),n.expiration&&e.uint.encode(o,n.expiration),d>=5&&n.buildType&&Dp.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{expiration:1&n?e.uint.decode(o):0,requiresConfirmation:!!(2&n),canModerate:!!(4&n),canAdmin:!!(8&n),buildType:d>=5&&16&n?Dp.decode(o):null}}},je=Ve,Ee=e.frame(Le),Be={preencode(d,n){e.fixed32.preencode(d,n.id),je.preencode(d,n.response),Ee.preencode(d,n.metadata),d.end++,n.anchor&&o.preencode(d,n.anchor)},encode(d,n){const c=(n.anchor?1:0)|(n.isActive?2:0);e.fixed32.encode(d,n.id),je.encode(d,n.response),Ee.encode(d,n.metadata),e.uint.encode(d,c),n.anchor&&o.encode(d,n.anchor)},decode(d){const n=e.fixed32.decode(d),c=je.decode(d),r=Ee.decode(d),t=e.uint.decode(d);return{id:n,response:c,metadata:r,anchor:1&t?o.decode(d):null,isActive:!!(2&t)}}},ze=de,Oe=e.frame(Be),Ne={preencode(e,d){ze.preencode(e,d.header),Oe.preencode(e,d.invitation)},encode(e,d){ze.encode(e,d.header),Oe.encode(e,d.invitation)},decode:e=>({header:ze.decode(e),invitation:Oe.decode(e)})},Ue=de,Je={preencode(d,o){Ue.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){Ue.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:Ue.decode(d),id:e.fixed32.decode(d)})},We={preencode(d,n){e.fixed32.preencode(d,n.mailbox),e.fixed32.preencode(d,n.invitationSeed),o.preencode(d,n.anchor)},encode(d,n){e.fixed32.encode(d,n.mailbox),e.fixed32.encode(d,n.invitationSeed),o.encode(d,n.anchor)},decode:d=>({mailbox:e.fixed32.decode(d),invitationSeed:e.fixed32.decode(d),anchor:o.decode(d)})},Ge={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.fixed32.preencode(d,o.encryptionKey),e.fixed32.preencode(d,o.seed),d.end++,o.fastForwardTo&&e.fixed32.preencode(d,o.fastForwardTo)},encode(d,o){const n=o.fastForwardTo?1:0;e.fixed32.encode(d,o.roomKey),e.fixed32.encode(d,o.encryptionKey),e.fixed32.encode(d,o.seed),e.uint.encode(d,n),o.fastForwardTo&&e.fixed32.encode(d,o.fastForwardTo)},decode:d=>({roomKey:e.fixed32.decode(d),encryptionKey:e.fixed32.decode(d),seed:e.fixed32.decode(d),fastForwardTo:1&e.uint.decode(d)?e.fixed32.decode(d):null})},Qe={preencode(d,n){e.fixed32.preencode(d,n.mailbox),e.fixed32.preencode(d,n.invitationSeed),o.preencode(d,n.anchor),e.fixed32.preencode(d,n.identityPublicKey)},encode(d,n){e.fixed32.encode(d,n.mailbox),e.fixed32.encode(d,n.invitationSeed),o.encode(d,n.anchor),e.fixed32.encode(d,n.identityPublicKey)},decode:d=>({mailbox:e.fixed32.decode(d),invitationSeed:e.fixed32.decode(d),anchor:o.decode(d),identityPublicKey:e.fixed32.decode(d)})},Xe={preencode(d,o){e.fixed32.preencode(d,o.mailbox)},encode(d,o){e.fixed32.encode(d,o.mailbox)},decode:d=>({mailbox:e.fixed32.decode(d)})},Ye=e.frame(We),Ze=e.frame(Qe),$e=e.frame(Xe),_e=e.frame(Ge),ed=e.array(e.ipv4Address),dd={preencode(e,o){e.end++,o.room&&Ye.preencode(e,o.room),o.identity&&Ze.preencode(e,o.identity),o.contact&&$e.preencode(e,o.contact),o.readonly&&_e.preencode(e,o.readonly),o.additionalNodes&&ed.preencode(e,o.additionalNodes),d>=5&&o.buildType&&Dp.preencode(e,o.buildType),d>=13&&o["readonly-v2"]&&nl.preencode(e,o["readonly-v2"])},encode(o,n){const c=(n.room?1:0)|(n.identity?2:0)|(n.contact?4:0)|(n.readonly?8:0)|(n.additionalNodes?16:0)|(d>=5&&n.buildType?32:0)|(d>=13&&n["readonly-v2"]?64:0);e.uint.encode(o,c),n.room&&Ye.encode(o,n.room),n.identity&&Ze.encode(o,n.identity),n.contact&&$e.encode(o,n.contact),n.readonly&&_e.encode(o,n.readonly),n.additionalNodes&&ed.encode(o,n.additionalNodes),d>=5&&n.buildType&&Dp.encode(o,n.buildType),d>=13&&n["readonly-v2"]&&nl.encode(o,n["readonly-v2"])},decode(o){const n=e.uint.decode(o);return{room:1&n?Ye.decode(o):null,identity:2&n?Ze.decode(o):null,contact:4&n?$e.decode(o):null,readonly:8&n?_e.decode(o):null,additionalNodes:16&n?ed.decode(o):null,buildType:d>=5&&32&n?Dp.decode(o):null,"readonly-v2":d>=13&&64&n?nl.decode(o):null}}},od=de,nd={preencode(d,o){od.preencode(d,o.header),e.buffer.preencode(d,o.blindRequest)},encode(d,o){od.encode(d,o.header),e.buffer.encode(d,o.blindRequest)},decode:d=>({header:od.decode(d),blindRequest:e.buffer.decode(d)})},cd=de,rd={preencode(o,n){cd.preencode(o,n.header),o.end++,n.profile&&cl.preencode(o,n.profile),d>=10&&n.key&&e.fixed32.preencode(o,n.key)},encode(o,n){const c=(n.profile?1:0)|(d>=10&&n.key?2:0);cd.encode(o,n.header),e.uint.encode(o,c),n.profile&&cl.encode(o,n.profile),d>=10&&n.key&&e.fixed32.encode(o,n.key)},decode(o){const n=cd.decode(o),c=e.uint.decode(o);return{header:n,profile:1&c?cl.decode(o):null,key:d>=10&&2&c?e.fixed32.decode(o):null}}},td=de,id={preencode(d,o){td.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){td.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:td.decode(d),key:e.fixed32.decode(d)})},ad={preencode(e,d){},encode(e,d){},decode:e=>({})},sd=ad,pd=Re,ud={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.id),pd.preencode(d,o.request)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.id),pd.encode(d,o.request)},decode:d=>({deviceKey:e.fixed32.decode(d),id:e.fixed32.decode(d),request:pd.decode(d)})},ld=de,fd=He,md={preencode(d,o){ld.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),d.end++,o.identity&&fd.preencode(d,o.identity)},encode(d,o){const n=o.identity?1:0;ld.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,n),o.identity&&fd.encode(d,o.identity)},decode:d=>({header:ld.decode(d),deviceKey:e.fixed32.decode(d),identity:1&e.uint.decode(d)?fd.decode(d):null})},yd=de,xd={preencode(d,o){yd.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey)},encode(d,o){yd.encode(d,o.header),e.fixed32.encode(d,o.deviceKey)},decode:d=>({header:yd.decode(d),deviceKey:e.fixed32.decode(d)})},bd=e.frame(I),vd=fe,gd={preencode(d,o){e.fixed32.preencode(d,o.key),bd.preencode(d,o.status),vd.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),bd.encode(d,o.status),vd.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),status:bd.decode(d),profile:vd.decode(d)})},kd=bd,Kd=fe,hd={preencode(d,o){e.fixed32.preencode(d,o.key),kd.preencode(d,o.status),Kd.preencode(d,o.profile),d.end++,o.proofs&&rl.preencode(d,o.proofs)},encode(d,o){const n=o.proofs?1:0;e.fixed32.encode(d,o.key),kd.encode(d,o.status),Kd.encode(d,o.profile),e.uint.encode(d,n),o.proofs&&rl.encode(d,o.proofs)},decode:d=>({key:e.fixed32.decode(d),status:kd.decode(d),profile:Kd.decode(d),proofs:1&e.uint.decode(d)?rl.decode(d):null})},wd={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++,o.profileAttestation&&e.buffer.preencode(d,o.profileAttestation),o.latestReceipt&&e.buffer.preencode(d,o.latestReceipt)},encode(d,o){const n=(o.profileAttestation?1:0)|(o.latestReceipt?2:0);e.fixed32.encode(d,o.key),e.uint.encode(d,n),o.profileAttestation&&e.buffer.encode(d,o.profileAttestation),o.latestReceipt&&e.buffer.encode(d,o.latestReceipt)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d);return{key:o,profileAttestation:1&n?e.buffer.decode(d):null,latestReceipt:2&n?e.buffer.decode(d):null}}},Pd=de,Td=we,Rd={preencode(e,d){Pd.preencode(e,d.header),Td.preencode(e,d.member)},encode(e,d){Pd.encode(e,d.header),Td.encode(e,d.member)},decode:e=>({header:Pd.decode(e),member:Td.decode(e)})},Ad=de,Sd=e.frame(M),Id={preencode(d,o){Ad.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),Sd.preencode(d,o.status)},encode(d,o){Ad.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),Sd.encode(d,o.status)},decode:d=>({header:Ad.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:Sd.decode(d)})},Md=de,Fd={preencode(d,o){Md.preencode(d,o.header),e.fixed32.preencode(d,o.key),d.end++},encode(d,o){const n=(o.isModerator?1:0)|(o.isAdmin?2:0);Md.encode(d,o.header),e.fixed32.encode(d,o.key),e.uint.encode(d,n)},decode(d){const o=Md.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{header:o,key:n,isModerator:!!(1&c),isAdmin:!!(2&c)}}},qd=de,Cd={preencode(d,o){qd.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){qd.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:qd.decode(d),key:e.fixed32.decode(d)})},Vd={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.mentions)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.mentions)},decode:d=>({key:e.fixed32.decode(d),mentions:e.uint.decode(d)})},Hd={preencode(d,o){d.end++,o.memberKey&&e.fixed32.preencode(d,o.memberKey)},encode(d,o){const n=o.memberKey?1:0;e.uint.encode(d,n),o.memberKey&&e.fixed32.encode(d,o.memberKey)},decode:d=>({memberKey:1&e.uint.decode(d)?e.fixed32.decode(d):null})},Dd=Hd,Ld=Hd,jd={preencode(d,o){d.end++,o.from&&e.string.preencode(d,o.from),o.to&&e.string.preencode(d,o.to)},encode(d,o){const n=(o.from?1:0)|(o.to?2:0);e.uint.encode(d,n),o.from&&e.string.encode(d,o.from),o.to&&e.string.encode(d,o.to)},decode(d){const o=e.uint.decode(d);return{from:1&o?e.string.decode(d):null,to:2&o?e.string.decode(d):null}}},Ed=e.frame(Hd),Bd=e.frame(Dd),zd=e.frame(jd),Od=e.frame(Ld),Nd={preencode(o,n){const c=(n.memberJoined?1:0)|(n.memberLeft?2:0)|(n.titleChanged?4:0)|(n.callStarted?8:0)|(n.callHangup?16:0)|(n.callMissed?32:0)|(n.roomAvatarChanged?64:0)|(n.invitationCreated?128:0)|(n.memberRemoved?256:0)|(d>=3&&n.locationShared?512:0);e.uint.preencode(o,c),n.memberJoined&&Ed.preencode(o,n.memberJoined),n.memberLeft&&Bd.preencode(o,n.memberLeft),n.titleChanged&&zd.preencode(o,n.titleChanged),n.memberRemoved&&Od.preencode(o,n.memberRemoved),d>=3&&n.locationShared&&tl.preencode(o,n.locationShared)},encode(o,n){const c=(n.memberJoined?1:0)|(n.memberLeft?2:0)|(n.titleChanged?4:0)|(n.callStarted?8:0)|(n.callHangup?16:0)|(n.callMissed?32:0)|(n.roomAvatarChanged?64:0)|(n.invitationCreated?128:0)|(n.memberRemoved?256:0)|(d>=3&&n.locationShared?512:0);e.uint.encode(o,c),n.memberJoined&&Ed.encode(o,n.memberJoined),n.memberLeft&&Bd.encode(o,n.memberLeft),n.titleChanged&&zd.encode(o,n.titleChanged),n.memberRemoved&&Od.encode(o,n.memberRemoved),d>=3&&n.locationShared&&tl.encode(o,n.locationShared)},decode(o){const n=e.uint.decode(o);return{memberJoined:1&n?Ed.decode(o):null,memberLeft:2&n?Bd.decode(o):null,titleChanged:4&n?zd.decode(o):null,callStarted:!!(8&n),callHangup:!!(16&n),callMissed:!!(32&n),roomAvatarChanged:!!(64&n),invitationCreated:!!(128&n),memberRemoved:256&n?Od.decode(o):null,locationShared:d>=3&&512&n?tl.decode(o):null}}},Ud={preencode(e,o){e.end++,d>=3&&o.locationShared&&il.preencode(e,o.locationShared)},encode(o,n){const c=(n.callStarted?1:0)|(n.callHangup?2:0)|(n.callMissed?4:0)|(d>=3&&n.locationShared?8:0);e.uint.encode(o,c),d>=3&&n.locationShared&&il.encode(o,n.locationShared)},decode(o){const n=e.uint.decode(o);return{callStarted:!!(1&n),callHangup:!!(2&n),callMissed:!!(4&n),locationShared:d>=3&&8&n?il.decode(o):null}}},Jd={preencode(d,o){e.uint.preencode(d,o.start),e.uint.preencode(d,o.length)},encode(d,o){e.uint.encode(d,o.start),e.uint.encode(d,o.length)},decode:d=>({start:e.uint.decode(d),length:e.uint.decode(d)})},Wd=e.frame(Jd),Gd={preencode(d,o){Wd.preencode(d,o.range),e.string.preencode(d,o.content)},encode(d,o){Wd.encode(d,o.range),e.string.encode(d,o.content)},decode:d=>({range:Wd.decode(d),content:e.string.decode(d)})},Qd=Wd,Xd={preencode(d,o){Qd.preencode(d,o.range),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Qd.encode(d,o.range),e.fixed32.encode(d,o.memberKey)},decode:d=>({range:Qd.decode(d),memberKey:e.fixed32.decode(d)})},Yd=Wd,Zd={preencode(d,o){Yd.preencode(d,o.range),Y.preencode(d,o.language),e.string.preencode(d,o.text)},encode(d,o){Yd.encode(d,o.range),Y.encode(d,o.language),e.string.encode(d,o.text)},decode:d=>({range:Yd.decode(d),language:Y.decode(d),text:e.string.decode(d)})},$d=k,_d=e.array(e.uint),eo={preencode(d,o){d.end++,o.title&&e.string.preencode(d,o.title),o.description&&e.string.preencode(d,o.description),o.file&&$d.preencode(d,o.file),o.files&&_d.preencode(d,o.files)},encode(d,o){const n=(o.title?1:0)|(o.description?2:0)|(o.file?4:0)|(o.files?8:0);e.uint.encode(d,n),o.title&&e.string.encode(d,o.title),o.description&&e.string.encode(d,o.description),o.file&&$d.encode(d,o.file),o.files&&_d.encode(d,o.files)},decode(d){const o=e.uint.decode(d);return{title:1&o?e.string.decode(d):null,description:2&o?e.string.decode(d):null,file:4&o?$d.decode(d):null,files:8&o?_d.decode(d):null}}},oo=Wd,no=e.frame(eo),co={preencode(d,o){oo.preencode(d,o.range),e.string.preencode(d,o.url),d.end++,o.preview&&no.preencode(d,o.preview)},encode(d,o){const n=o.preview?1:0;oo.encode(d,o.range),e.string.encode(d,o.url),e.uint.encode(d,n),o.preview&&no.encode(d,o.preview)},decode:d=>({range:oo.decode(d),url:e.string.decode(d),preview:1&e.uint.decode(d)?no.decode(d):null})},ro=e.array(e.frame(Xd)),to=e.array(e.frame(co)),io=to,ao=e.array(e.frame(Jd)),so=ao,po=ao,uo=e.array(e.frame(Gd)),lo=ao,fo=ao,mo=e.array(e.frame(Zd)),yo={preencode(d,o){const n=(o.mention?1:0)|(o.httpLink?2:0)|(o.pearLink?4:0)|(o.bold?8:0)|(o.italic?16:0)|(o.code?32:0)|(o.emoji?64:0)|(o.codeBlock?128:0)|(o.strike?256:0)|(o.translation?512:0);e.uint.preencode(d,n),o.mention&&ro.preencode(d,o.mention),o.httpLink&&to.preencode(d,o.httpLink),o.pearLink&&io.preencode(d,o.pearLink),o.bold&&ao.preencode(d,o.bold),o.italic&&so.preencode(d,o.italic),o.code&&po.preencode(d,o.code),o.emoji&&uo.preencode(d,o.emoji),o.codeBlock&&lo.preencode(d,o.codeBlock),o.strike&&fo.preencode(d,o.strike),o.translation&&mo.preencode(d,o.translation)},encode(d,o){const n=(o.mention?1:0)|(o.httpLink?2:0)|(o.pearLink?4:0)|(o.bold?8:0)|(o.italic?16:0)|(o.code?32:0)|(o.emoji?64:0)|(o.codeBlock?128:0)|(o.strike?256:0)|(o.translation?512:0);e.uint.encode(d,n),o.mention&&ro.encode(d,o.mention),o.httpLink&&to.encode(d,o.httpLink),o.pearLink&&io.encode(d,o.pearLink),o.bold&&ao.encode(d,o.bold),o.italic&&so.encode(d,o.italic),o.code&&po.encode(d,o.code),o.emoji&&uo.encode(d,o.emoji),o.codeBlock&&lo.encode(d,o.codeBlock),o.strike&&fo.encode(d,o.strike),o.translation&&mo.encode(d,o.translation)},decode(d){const o=e.uint.decode(d);return{mention:1&o?ro.decode(d):null,httpLink:2&o?to.decode(d):null,pearLink:4&o?io.decode(d):null,bold:8&o?ao.decode(d):null,italic:16&o?so.decode(d):null,code:32&o?po.decode(d):null,emoji:64&o?uo.decode(d):null,codeBlock:128&o?lo.decode(d):null,strike:256&o?fo.decode(d):null,translation:512&o?mo.decode(d):null}}},xo=e.array(e.frame(g)),bo=e.frame(yo),vo=e.frame(Ud),go={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&xo.preencode(d,o.files),o.display&&bo.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent),o.event&&vo.preencode(d,o.event)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(c.event?32:0)|(d>=3&&c.forwarded?64:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&xo.encode(o,c.files),c.display&&bo.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent),c.event&&vo.encode(o,c.event)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?xo.decode(o):null,display:4&c?bo.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,event:32&c?vo.decode(o):null,forwarded:d>=3&&!!(64&c)}}},ko=_d,Ko=bo,ho={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&ko.preencode(d,o.files),o.display&&Ko.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(d>=3&&c.forwarded?32:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&ko.encode(o,c.files),c.display&&Ko.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?ko.decode(o):null,display:4&c?Ko.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,forwarded:d>=3&&!!(32&c)}}},wo=xo,Po=bo,To={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&wo.preencode(d,o.files),o.display&&Po.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(d>=3&&c.forwarded?32:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&wo.encode(o,c.files),c.display&&Po.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?wo.decode(o):null,display:4&c?Po.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,forwarded:d>=3&&!!(32&c)}}},Ro={preencode(e,d){e.end++},encode(d,o){const n=(o.isEdited?1:0)|(o.isDeleted?2:0)|(o.isPinned?4:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isEdited:!!(1&o),isDeleted:!!(2&o),isPinned:!!(4&o)}}},Ao={preencode(d,o){e.uint.preencode(d,o.thread),e.uint.preencode(d,o.index)},encode(d,o){e.uint.encode(d,o.thread),e.uint.encode(d,o.index)},decode:d=>({thread:e.uint.decode(d),index:e.uint.decode(d)})},So=e.frame(B),Io={preencode(d,o){e.uint.preencode(d,o.id),e.uint.preencode(d,o.count),d.end++,o.parent&&n.preencode(d,o.parent),o.stats&&So.preencode(d,o.stats)},encode(d,o){const c=(o.parent?1:0)|(o.stats?2:0);e.uint.encode(d,o.id),e.uint.encode(d,o.count),e.uint.encode(d,c),o.parent&&n.encode(d,o.parent),o.stats&&So.encode(d,o.stats)},decode(d){const o=e.uint.decode(d),c=e.uint.decode(d),r=e.uint.decode(d);return{id:o,count:c,parent:1&r?n.decode(d):null,stats:2&r?So.decode(d):null}}},Mo=e.frame(Ro),Fo=e.frame(ho),qo=e.frame(Nd),Co={preencode(d,o){Ao.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),Mo.preencode(d,o.status),o.message&&Fo.preencode(d,o.message),o.event&&qo.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);Ao.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),Mo.encode(d,o.status),o.message&&Fo.encode(d,o.message),o.event&&qo.encode(d,o.event)},decode(d){const o=Ao.decode(d),c=n.decode(d),r=e.uint.decode(d),t=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:r,timestamp:t,editedAt:1&i?e.uint.decode(d):0,status:Mo.decode(d),message:2&i?Fo.decode(d):null,event:4&i?qo.decode(d):null}}},Vo=Mo,Ho=e.frame(To),Do=qo,Lo={preencode(d,o){Ao.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),Vo.preencode(d,o.status),o.message&&Ho.preencode(d,o.message),o.event&&Do.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);Ao.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),Vo.encode(d,o.status),o.message&&Ho.encode(d,o.message),o.event&&Do.encode(d,o.event)},decode(d){const o=Ao.decode(d),c=n.decode(d),r=e.uint.decode(d),t=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:r,timestamp:t,editedAt:1&i?e.uint.decode(d):0,status:Vo.decode(d),message:2&i?Ho.decode(d):null,event:4&i?Do.decode(d):null}}},jo=de,Eo=e.frame(go),Bo={preencode(e,d){jo.preencode(e,d.header),Eo.preencode(e,d.message)},encode(e,d){jo.encode(e,d.header),Eo.encode(e,d.message)},decode:e=>({header:jo.decode(e),message:Eo.decode(e)})},zo=de,Oo={preencode(e,d){zo.preencode(e,d.header),n.preencode(e,d.oplog)},encode(e,d){zo.encode(e,d.header),n.encode(e,d.oplog)},decode:e=>({header:zo.decode(e),oplog:n.decode(e)})},No=de,Uo=Eo,Jo={preencode(e,d){No.preencode(e,d.header),n.preencode(e,d.oplog),Uo.preencode(e,d.message)},encode(e,d){No.encode(e,d.header),n.encode(e,d.oplog),Uo.encode(e,d.message)},decode:e=>({header:No.decode(e),oplog:n.decode(e),message:Uo.decode(e)})},Wo=de,Go={preencode(e,d){Wo.preencode(e,d.header),n.preencode(e,d.oplog),e.end++},encode(d,o){const c=o.isPinned?1:0;Wo.encode(d,o.header),n.encode(d,o.oplog),e.uint.encode(d,c)},decode:d=>({header:Wo.decode(d),oplog:n.decode(d),isPinned:!!(1&e.uint.decode(d))})},Qo={HttpLink:1,PearLink:2},Xo={preencode(e,d){e.end++},encode(d,o){if(o>2)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Yo=de,Zo={preencode(d,o){Yo.preencode(d,o.header),n.preencode(d,o.oplog),e.uint.preencode(d,o.index),al.preencode(d,o.preview),d.end++,o.displayType&&Xo.preencode(d,o.displayType)},encode(d,o){const c=o.displayType?1:0;Yo.encode(d,o.header),n.encode(d,o.oplog),e.uint.encode(d,o.index),al.encode(d,o.preview),e.uint.encode(d,c),o.displayType&&Xo.encode(d,o.displayType)},decode:d=>({header:Yo.decode(d),oplog:n.decode(d),index:e.uint.decode(d),preview:al.decode(d),displayType:1&e.uint.decode(d)?Xo.decode(d):0})},$o={preencode(d,o){Ao.preencode(d,o.id),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),e.string.preencode(d,o.reaction)},encode(d,o){Ao.encode(d,o.id),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),e.string.encode(d,o.reaction)},decode:d=>({id:Ao.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),reaction:e.string.decode(d)})},_o={preencode(d,o){e.string.preencode(d,o.text),e.uint.preencode(d,o.count)},encode(d,o){e.string.encode(d,o.text),e.uint.encode(d,o.count)},decode:d=>({text:e.string.decode(d),count:e.uint.decode(d)})},en=e.array(e.frame(_o)),dn={preencode(d,o){Ao.preencode(d,o.id),e.uint.preencode(d,o.total),en.preencode(d,o.reactions),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt)},encode(d,o){const n=o.editedAt?1:0;Ao.encode(d,o.id),e.uint.encode(d,o.total),en.encode(d,o.reactions),e.uint.encode(d,n),o.editedAt&&e.uint.encode(d,o.editedAt)},decode:d=>({id:Ao.decode(d),total:e.uint.decode(d),reactions:en.decode(d),editedAt:1&e.uint.decode(d)?e.uint.decode(d):0})},on=de,nn={preencode(d,o){on.preencode(d,o.header),n.preencode(d,o.oplog),e.string.preencode(d,o.reaction)},encode(d,o){on.encode(d,o.header),n.encode(d,o.oplog),e.string.encode(d,o.reaction)},decode:d=>({header:on.decode(d),oplog:n.decode(d),reaction:e.string.decode(d)})},cn=de,rn={preencode(d,o){cn.preencode(d,o.header),n.preencode(d,o.oplog),e.string.preencode(d,o.reaction)},encode(d,o){cn.encode(d,o.header),n.encode(d,o.oplog),e.string.encode(d,o.reaction)},decode:d=>({header:cn.decode(d),oplog:n.decode(d),reaction:e.string.decode(d)})},tn=de,an=e.frame(_),sn={preencode(d,o){tn.preencode(d,o.header),e.uint.preencode(d,o.key),an.preencode(d,o.config)},encode(d,o){tn.encode(d,o.header),e.uint.encode(d,o.key),an.encode(d,o.config)},decode:d=>({header:tn.decode(d),key:e.uint.decode(d),config:an.decode(d)})},pn={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.string.preencode(d,o.displayName),d.end++,o.avatar&&sl.preencode(d,o.avatar)},encode(d,o){const n=o.avatar?1:0;e.fixed32.encode(d,o.memberKey),e.string.encode(d,o.displayName),e.uint.encode(d,n),o.avatar&&sl.encode(d,o.avatar)},decode:d=>({memberKey:e.fixed32.decode(d),displayName:e.string.decode(d),avatar:1&e.uint.decode(d)?sl.decode(d):null})},un={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++,o.username&&e.string.preencode(d,o.username)},encode(d,o){const n=o.username?1:0;e.fixed32.encode(d,o.key),e.uint.encode(d,n),o.username&&e.string.encode(d,o.username)},decode:d=>({key:e.fixed32.decode(d),username:1&e.uint.decode(d)?e.string.decode(d):null})},ln=e.frame(un),fn={preencode(d,o){e.fixed32.preencode(d,o.publicKey),d.end++,o.discoveryCoreKey&&e.fixed32.preencode(d,o.discoveryCoreKey),o.userRegistry&&ln.preencode(d,o.userRegistry)},encode(d,o){const n=(o.discoveryCoreKey?1:0)|(o.userRegistry?2:0);e.fixed32.encode(d,o.publicKey),e.uint.encode(d,n),o.discoveryCoreKey&&e.fixed32.encode(d,o.discoveryCoreKey),o.userRegistry&&ln.encode(d,o.userRegistry)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d);return{publicKey:o,discoveryCoreKey:1&n?e.fixed32.decode(d):null,userRegistry:2&n?ln.decode(d):null}}},mn=de,yn=e.frame(W),xn=e.frame(G),bn=an,vn=e.frame(fn),gn=he,kn=e.array(e.frame(me)),Kn={preencode(e,d){mn.preencode(e,d.header),yn.preencode(e,d.digest),xn.preencode(e,d.capabilities),e.end++,d.config&&bn.preencode(e,d.config),d.identity&&vn.preencode(e,d.identity),d.bootstrapDevice&&gn.preencode(e,d.bootstrapDevice),d.initialMembers&&kn.preencode(e,d.initialMembers)},encode(d,o){const n=(o.config?1:0)|(o.identity?2:0)|(o.bootstrapDevice?4:0)|(o.initialMembers?8:0);mn.encode(d,o.header),yn.encode(d,o.digest),xn.encode(d,o.capabilities),e.uint.encode(d,n),o.config&&bn.encode(d,o.config),o.identity&&vn.encode(d,o.identity),o.bootstrapDevice&&gn.encode(d,o.bootstrapDevice),o.initialMembers&&kn.encode(d,o.initialMembers)},decode(d){const o=mn.decode(d),n=yn.decode(d),c=xn.decode(d),r=e.uint.decode(d);return{header:o,digest:n,capabilities:c,config:1&r?bn.decode(d):null,identity:2&r?vn.decode(d):null,bootstrapDevice:4&r?gn.decode(d):null,initialMembers:8&r?kn.decode(d):null}}},hn=de,wn={preencode(d,o){hn.preencode(d,o.header),e.uint.preencode(d,o.version)},encode(d,o){hn.encode(d,o.header),e.uint.encode(d,o.version)},decode:d=>({header:hn.decode(d),version:e.uint.decode(d)})},Pn=de,Tn={preencode(o,n){Pn.preencode(o,n.header),e.uint.preencode(o,n.from),e.uint.preencode(o,n.to),o.end++,d>=5&&n.buildType&&Dp.preencode(o,n.buildType)},encode(o,n){const c=d>=5&&n.buildType?1:0;Pn.encode(o,n.header),e.uint.encode(o,n.from),e.uint.encode(o,n.to),e.uint.encode(o,c),d>=5&&n.buildType&&Dp.encode(o,n.buildType)},decode(o){const n=Pn.decode(o),c=e.uint.decode(o),r=e.uint.decode(o),t=o.start<o.end?e.uint.decode(o):0;return{header:n,from:c,to:r,buildType:d>=5&&1&t?Dp.decode(o):null}}},Rn={RoomType:1,IsExperimental:2,IsJoiningDisabled:3,IsAppendingDisabled:4,IsCallingDisabled:5,IsMembershipEventsDisabled:6,IsAttachmentsDisabled:7,IsLinksDisabled:8,IsRoomInviteHidden:9},An={preencode(e,d){e.end++},encode(d,o){if(o>9)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Sn=de,In=J,Mn={preencode(d,o){Sn.preencode(d,o.header),e.uint.preencode(d,o.key),In.preencode(d,o.settings)},encode(d,o){Sn.encode(d,o.header),e.uint.encode(d,o.key),In.encode(d,o.settings)},decode:d=>({header:Sn.decode(d),key:e.uint.decode(d),settings:In.decode(d)})},Fn=de,qn={preencode(d,o){Fn.preencode(d,o.header),e.uint.preencode(d,o.value)},encode(d,o){Fn.encode(d,o.header),e.uint.encode(d,o.value)},decode:d=>({header:Fn.decode(d),value:e.uint.decode(d)})},Cn={preencode(d,o){e.uint.preencode(d,o.key),e.uint.preencode(d,o.value)},encode(d,o){e.uint.encode(d,o.key),e.uint.encode(d,o.value)},decode:d=>({key:e.uint.decode(d),value:e.uint.decode(d)})},Vn={Flag:1},Hn={preencode(e,d){e.end++},encode(d,o){if(o>1)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Dn={preencode(d,o){Ao.preencode(d,o.id),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),Hn.preencode(d,o.label)},encode(d,o){Ao.encode(d,o.id),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),Hn.encode(d,o.label)},decode:d=>({id:Ao.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),label:Hn.decode(d)})},Ln=de,jn={preencode(e,d){Ln.preencode(e,d.header),n.preencode(e,d.oplog),Hn.preencode(e,d.label)},encode(e,d){Ln.encode(e,d.header),n.encode(e,d.oplog),Hn.encode(e,d.label)},decode:e=>({header:Ln.decode(e),oplog:n.decode(e),label:Hn.decode(e)})},En=de,Bn={preencode(e,d){En.preencode(e,d.header),n.preencode(e,d.oplog),Hn.preencode(e,d.label)},encode(e,d){En.encode(e,d.header),n.encode(e,d.oplog),Hn.encode(e,d.label)},decode:e=>({header:En.decode(e),oplog:n.decode(e),label:Hn.decode(e)})},zn={preencode(d,o){Hn.preencode(d,o.label),e.uint.preencode(d,o.count)},encode(d,o){Hn.encode(d,o.label),e.uint.encode(d,o.count)},decode:d=>({label:Hn.decode(d),count:e.uint.decode(d)})},On=e.array(e.frame(zn)),Nn={preencode(d,o){Ao.preencode(d,o.id),e.uint.preencode(d,o.total),On.preencode(d,o.labels),e.uint.preencode(d,o.editedAt),d.end++,o.flagsClock&&e.uint.preencode(d,o.flagsClock),o.version&&e.uint.preencode(d,o.version)},encode(d,o){const n=(o.flagsClock?1:0)|(o.version?2:0)|(o.isDeleted?4:0);Ao.encode(d,o.id),e.uint.encode(d,o.total),On.encode(d,o.labels),e.uint.encode(d,o.editedAt),e.uint.encode(d,n),o.flagsClock&&e.uint.encode(d,o.flagsClock),o.version&&e.uint.encode(d,o.version)},decode(d){const o=Ao.decode(d),n=e.uint.decode(d),c=On.decode(d),r=e.uint.decode(d),t=e.uint.decode(d);return{id:o,total:n,labels:c,editedAt:r,flagsClock:1&t?e.uint.decode(d):0,version:2&t?e.uint.decode(d):0,isDeleted:!!(4&t)}}},Un=de,Jn={preencode(d,o){Un.preencode(d,o.header),e.uint.preencode(d,o.length)},encode(d,o){Un.encode(d,o.header),e.uint.encode(d,o.length)},decode:d=>({header:Un.decode(d),length:e.uint.decode(d)})},Wn={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.length)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.length)},decode:d=>({memberKey:e.fixed32.decode(d),length:e.uint.decode(d)})},Gn=ee,Qn=e.frame(be),Xn={preencode(o,n){e.fixed32.preencode(o,n.memberKey),pl.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=8&&n.contactInfo&&Qn.preencode(o,n.contactInfo),d>=8&&n.version&&e.uint.preencode(o,n.version),d>=10&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=8&&n.contactInfo?4:0)|(d>=8&&n.version?8:0)|(d>=10&&n.alias?16:0);e.fixed32.encode(o,n.memberKey),pl.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=8&&n.contactInfo&&Qn.encode(o,n.contactInfo),d>=8&&n.version&&e.uint.encode(o,n.version),d>=10&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.fixed32.decode(o),c=pl.decode(o),r=e.uint.decode(o);return{memberKey:n,status:c,mailbox:1&r?e.fixed32.decode(o):null,roomKey:2&r?e.fixed32.decode(o):null,contactInfo:d>=8&&4&r?Qn.decode(o):null,version:d>=8&&8&r?e.uint.decode(o):0,alias:d>=10&&16&r?e.string.decode(o):null}}},Yn={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.seed),o.preencode(d,n.initiator),e.fixed32.preencode(d,n.fastForwardTo)},encode(d,n){e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.fixed32.encode(d,n.seed),o.encode(d,n.initiator),e.fixed32.encode(d,n.fastForwardTo)},decode:d=>({roomKey:e.fixed32.decode(d),encryptionKey:e.buffer.decode(d),seed:e.fixed32.decode(d),initiator:o.decode(d),fastForwardTo:e.fixed32.decode(d)})},Zn=e.array(e.frame(Yn)),$n=$,_n={preencode(e,d){Zn.preencode(e,d.sharedRooms),$n.preencode(e,d.blockedContacts)},encode(e,d){Zn.encode(e,d.sharedRooms),$n.encode(e,d.blockedContacts)},decode:e=>({sharedRooms:Zn.decode(e),blockedContacts:$n.decode(e)})},ec=vn,dc={preencode(e,d){ec.preencode(e,d.identity)},encode(e,d){ec.encode(e,d.identity)},decode:e=>({identity:ec.decode(e)})},oc={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.contacts)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.contacts)},decode:d=>({rooms:e.uint.decode(d),contacts:e.uint.decode(d)})},nc={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.contactRequests)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.contactRequests)},decode:d=>({rooms:e.uint.decode(d),contactRequests:e.uint.decode(d)})},cc={preencode(d,o){e.buffer.preencode(d,o.entropy)},encode(d,o){e.buffer.encode(d,o.entropy)},decode:d=>({entropy:e.buffer.decode(d)})},rc={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.devicePublicKey),e.fixed32.preencode(d,o.writerKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.devicePublicKey),e.fixed32.encode(d,o.writerKey)},decode:d=>({publicKey:e.fixed32.decode(d),devicePublicKey:e.fixed32.decode(d),writerKey:e.fixed32.decode(d)})},tc=e.frame(rc),ic={preencode(n,c){e.fixed32.preencode(n,c.id),e.fixed32.preencode(n,c.invitationSeed),e.fixed32.preencode(n,c.mailbox),r.preencode(n,c.responseKeyPair),o.preencode(n,c.initiator),o.preencode(n,c.inviter),n.end++,c.identity&&tc.preencode(n,c.identity),d>=5&&c.buildType&&Dp.preencode(n,c.buildType),d>=13&&c.link&&o.preencode(n,c.link)},encode(n,c){const t=(c.identity?1:0)|(d>=5&&c.buildType?2:0)|(d>=13&&c.link?4:0);e.fixed32.encode(n,c.id),e.fixed32.encode(n,c.invitationSeed),e.fixed32.encode(n,c.mailbox),r.encode(n,c.responseKeyPair),o.encode(n,c.initiator),o.encode(n,c.inviter),e.uint.encode(n,t),c.identity&&tc.encode(n,c.identity),d>=5&&c.buildType&&Dp.encode(n,c.buildType),d>=13&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),t=e.fixed32.decode(n),i=e.fixed32.decode(n),a=r.decode(n),s=o.decode(n),p=o.decode(n),u=e.uint.decode(n);return{id:c,invitationSeed:t,mailbox:i,responseKeyPair:a,initiator:s,inviter:p,identity:1&u?tc.decode(n):null,buildType:d>=5&&2&u?Dp.decode(n):null,link:d>=13&&4&u?o.decode(n):null}}},ac=de,sc={preencode(d,o){ac.preencode(d,o.header),e.buffer.preencode(d,o.blindResponse)},encode(d,o){ac.encode(d,o.header),e.buffer.encode(d,o.blindResponse)},decode:d=>({header:ac.decode(d),blindResponse:e.buffer.decode(d)})},pc=de,uc=e.frame(ic),lc={preencode(e,d){pc.preencode(e,d.header),uc.preencode(e,d.invitation)},encode(e,d){pc.encode(e,d.header),uc.encode(e,d.invitation)},decode:e=>({header:pc.decode(e),invitation:uc.decode(e)})},fc=de,mc={preencode(d,o){fc.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){fc.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:fc.decode(d),id:e.fixed32.decode(d)})},yc={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.devicePublicKey),d.end++,o.privateProfileKey&&e.fixed32.preencode(d,o.privateProfileKey),o.deviceKeyPair&&r.preencode(d,o.deviceKeyPair),e.buffer.preencode(d,o.deviceProof)},encode(d,o){const n=(o.privateProfileKey?1:0)|(o.deviceKeyPair?2:0);e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.devicePublicKey),e.uint.encode(d,n),o.privateProfileKey&&e.fixed32.encode(d,o.privateProfileKey),o.deviceKeyPair&&r.encode(d,o.deviceKeyPair),e.buffer.encode(d,o.deviceProof)},decode(d){const o=e.fixed32.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{publicKey:o,devicePublicKey:n,privateProfileKey:1&c?e.fixed32.decode(d):null,deviceKeyPair:2&c?r.decode(d):null,deviceProof:e.buffer.decode(d)}}},xc={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.writerKey),e.fixed32.preencode(d,o.devicePublicKey),d.end++,o.privateProfileKey&&e.fixed32.preencode(d,o.privateProfileKey)},encode(d,o){const n=o.privateProfileKey?1:0;e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.writerKey),e.fixed32.encode(d,o.devicePublicKey),e.uint.encode(d,n),o.privateProfileKey&&e.fixed32.encode(d,o.privateProfileKey)},decode:d=>({publicKey:e.fixed32.decode(d),writerKey:e.fixed32.decode(d),devicePublicKey:e.fixed32.decode(d),privateProfileKey:1&e.uint.decode(d)?e.fixed32.decode(d):null})},bc={preencode(o,n){o.end++,d>=11&&n.roomSnoozeTime&&e.uint.preencode(o,n.roomSnoozeTime)},encode(o,n){const c=(n.isActive?1:0)|(n.isFullyMuted?2:0)|(n.isMentionsOnlyMuted?4:0)|(n.isReadOnly?8:0)|(d>=3&&n.isFavorite?16:0)|(d>=7&&n.isUnread?32:0)|(d>=11&&n.roomSnoozeTime?64:0);e.uint.encode(o,c),d>=11&&n.roomSnoozeTime&&e.uint.encode(o,n.roomSnoozeTime)},decode(o){const n=e.uint.decode(o);return{isActive:!!(1&n),isFullyMuted:!!(2&n),isMentionsOnlyMuted:!!(4&n),isReadOnly:!!(8&n),isFavorite:d>=3&&!!(16&n),isUnread:d>=7&&!!(32&n),roomSnoozeTime:d>=11&&64&n?e.uint.decode(o):0}}},vc=e.frame(bc),gc=e.frame(yc),kc=tc,Kc={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),vc.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,c.initiator&&o.preencode(n,c.initiator),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),c.identitySwap&&gc.preencode(n,c.identitySwap),c.identitySwapV2&&kc.preencode(n,c.identitySwapV2),c.contact&&e.fixed32.preencode(n,c.contact),d>=13&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=15&&c.activeClock&&e.uint.preencode(n,c.activeClock)},encode(n,c){const r=(c.initiator?1:0)|(c.fastForwardTo?2:0)|(c.identitySwap?4:0)|(c.identitySwapV2?8:0)|(c.contact?16:0)|(d>=13&&c.bootFrom?32:0)|(d>=15&&c.activeClock?64:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),vc.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,r),c.initiator&&o.encode(n,c.initiator),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),c.identitySwap&&gc.encode(n,c.identitySwap),c.identitySwapV2&&kc.encode(n,c.identitySwapV2),c.contact&&e.fixed32.encode(n,c.contact),d>=13&&c.bootFrom&&o.encode(n,c.bootFrom),d>=15&&c.activeClock&&e.uint.encode(n,c.activeClock)},decode(n){const c=e.fixed32.decode(n),r=e.buffer.decode(n),t=e.fixed32.decode(n),i=vc.decode(n),a=e.uint.decode(n),s=e.uint.decode(n);return{roomKey:c,encryptionKey:r,mailbox:t,status:i,clock:a,initiator:1&s?o.decode(n):null,fastForwardTo:2&s?e.fixed32.decode(n):null,identitySwap:4&s?gc.decode(n):null,identitySwapV2:8&s?kc.decode(n):null,contact:16&s?e.fixed32.decode(n):null,bootFrom:d>=13&&32&s?o.decode(n):null,activeClock:d>=15&&64&s?e.uint.decode(n):0}}},hc=de,wc={preencode(d,n){hc.preencode(d,n.header),e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.mailbox),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.dm&&e.fixed32.preencode(d,n.dm)},encode(d,n){const c=(n.fastForwardTo?1:0)|(n.initiator?2:0)|(n.dm?4:0)|(n.isReadOnly?8:0);hc.encode(d,n.header),e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.fixed32.encode(d,n.mailbox),e.uint.encode(d,c),n.fastForwardTo&&e.fixed32.encode(d,n.fastForwardTo),n.initiator&&o.encode(d,n.initiator),n.dm&&e.fixed32.encode(d,n.dm)},decode(d){const n=hc.decode(d),c=e.fixed32.decode(d),r=e.buffer.decode(d),t=e.fixed32.decode(d),i=e.uint.decode(d);return{header:n,roomKey:c,encryptionKey:r,mailbox:t,fastForwardTo:1&i?e.fixed32.decode(d):null,initiator:2&i?o.decode(d):null,dm:4&i?e.fixed32.decode(d):null,isReadOnly:!!(8&i)}}},Pc=de,Tc={preencode(d,o){Pc.preencode(d,o.header),e.fixed32.preencode(d,o.discoveryKey)},encode(d,o){Pc.encode(d,o.header),e.fixed32.encode(d,o.discoveryKey)},decode:d=>({header:Pc.decode(d),discoveryKey:e.fixed32.decode(d)})},Rc=de,Ac=vc,Sc={preencode(d,o){Rc.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.key),Ac.preencode(d,o.status)},encode(d,o){Rc.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.key),Ac.encode(d,o.status)},decode:d=>({header:Rc.decode(d),roomKey:e.fixed32.decode(d),key:e.uint.decode(d),status:Ac.decode(d)})},Ic={preencode(e,d){e.end++},encode(o,n){const c=(n.isBlocked?1:0)|(d>=8&&n.isActive?2:0);e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{isBlocked:!!(1&n),isActive:d>=8&&!!(2&n)}}},Mc=Qn,Fc={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.clock),ul.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=8&&n.contactInfo&&Mc.preencode(o,n.contactInfo),d>=10&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=8&&n.contactInfo?4:0)|(d>=10&&n.alias?8:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.clock),ul.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=8&&n.contactInfo&&Mc.encode(o,n.contactInfo),d>=10&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),r=ul.decode(o),t=e.uint.decode(o);return{memberKey:n,clock:c,status:r,mailbox:1&t?e.fixed32.decode(o):null,roomKey:2&t?e.fixed32.decode(o):null,contactInfo:d>=8&&4&t?Mc.decode(o):null,alias:d>=10&&8&t?e.string.decode(o):null}}},qc=de,Cc=e.frame(Xn),Vc={preencode(e,d){qc.preencode(e,d.header),Cc.preencode(e,d.contact)},encode(e,d){qc.encode(e,d.header),Cc.encode(e,d.contact)},decode:e=>({header:qc.decode(e),contact:Cc.decode(e)})},Hc=de,Dc={preencode(d,o){Hc.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),ll.preencode(d,o.status)},encode(d,o){Hc.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),ll.encode(d,o.status)},decode:d=>({header:Hc.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:ll.decode(d)})},Lc=de,jc={preencode(d,o){Lc.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Lc.encode(d,o.header),e.fixed32.encode(d,o.memberKey)},decode:d=>({header:Lc.decode(d),memberKey:e.fixed32.decode(d)})},Ec=de,Bc={preencode(d,o){Ec.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Ec.encode(d,o.header),e.fixed32.encode(d,o.memberKey)},decode:d=>({header:Ec.decode(d),memberKey:e.fixed32.decode(d)})},zc={preencode(e,d){e.end++},encode(d,o){const n=(o.isPending?1:0)|(o.isAccepted?2:0)|(o.isRejected?4:0)|(o.isDiscarded?8:0)|(o.isSeen?16:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isPending:!!(1&o),isAccepted:!!(2&o),isRejected:!!(4&o),isDiscarded:!!(8&o),isSeen:!!(16&o)}}},Oc=we,Nc=e.frame(t),Uc={preencode(d,o){Oc.preencode(d,o.sender),Nc.preencode(d,o.keys),e.fixed32.preencode(d,o.mailbox),d.end++,o.message&&e.string.preencode(d,o.message)},encode(d,o){const n=o.message?1:0;Oc.encode(d,o.sender),Nc.encode(d,o.keys),e.fixed32.encode(d,o.mailbox),e.uint.encode(d,n),o.message&&e.string.encode(d,o.message)},decode:d=>({sender:Oc.decode(d),keys:Nc.decode(d),mailbox:e.fixed32.decode(d),message:1&e.uint.decode(d)?e.string.decode(d):null})},Jc=e.frame(Uc),Wc={preencode(o,n){Jc.preencode(o,n.body),te.preencode(o,n.attestation),o.end++,d>=17&&n.recipientProof&&e.buffer.preencode(o,n.recipientProof)},encode(o,n){const c=d>=17&&n.recipientProof?1:0;Jc.encode(o,n.body),te.encode(o,n.attestation),e.uint.encode(o,c),d>=17&&n.recipientProof&&e.buffer.encode(o,n.recipientProof)},decode(o){const n=Jc.decode(o),c=te.decode(o),r=o.start<o.end?e.uint.decode(o):0;return{body:n,attestation:c,recipientProof:d>=17&&1&r?e.buffer.decode(o):null}}},Gc=fe,Qc=e.frame(zc),Xc=Nc,Yc=Qn,Zc={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.clock),Gc.preencode(o,n.sender),Qc.preencode(o,n.status),Xc.preencode(o,n.keys),e.fixed32.preencode(o,n.mailbox),o.end++,n.message&&e.string.preencode(o,n.message),n.sentAt&&e.uint.preencode(o,n.sentAt),d>=8&&n.contactInfo&&Yc.preencode(o,n.contactInfo)},encode(o,n){const c=(n.message?1:0)|(n.sentAt?2:0)|(d>=8&&n.contactInfo?4:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.clock),Gc.encode(o,n.sender),Qc.encode(o,n.status),Xc.encode(o,n.keys),e.fixed32.encode(o,n.mailbox),e.uint.encode(o,c),n.message&&e.string.encode(o,n.message),n.sentAt&&e.uint.encode(o,n.sentAt),d>=8&&n.contactInfo&&Yc.encode(o,n.contactInfo)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),r=Gc.decode(o),t=Qc.decode(o),i=Xc.decode(o),a=e.fixed32.decode(o),s=e.uint.decode(o);return{memberKey:n,clock:c,sender:r,status:t,keys:i,mailbox:a,message:1&s?e.string.decode(o):null,sentAt:2&s?e.uint.decode(o):0,contactInfo:d>=8&&4&s?Yc.decode(o):null}}},$c=de,_c={preencode(d,o){$c.preencode(d,o.header),e.buffer.preencode(d,o.blindRequest)},encode(d,o){$c.encode(d,o.header),e.buffer.encode(d,o.blindRequest)},decode:d=>({header:$c.decode(d),blindRequest:e.buffer.decode(d)})},er=de,dr=Qc,or={preencode(d,o){er.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),dr.preencode(d,o.status),d.end++,o.roomKey&&e.fixed32.preencode(d,o.roomKey)},encode(d,o){const n=o.roomKey?1:0;er.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),dr.encode(d,o.status),e.uint.encode(d,n),o.roomKey&&e.fixed32.encode(d,o.roomKey)},decode:d=>({header:er.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:dr.decode(d),roomKey:1&e.uint.decode(d)?e.fixed32.decode(d):null})},nr={preencode(d,o){e.uint.preencode(d,o.timestamp),e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.mailbox)},encode(d,o){e.uint.encode(d,o.timestamp),e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.mailbox)},decode:d=>({version:0,timestamp:e.uint.decode(d),key:e.fixed32.decode(d),mailbox:e.fixed32.decode(d)})},cr={preencode(d,o){const n=o.version??1;switch(e.uint.preencode(d,n),n){case 0:case 1:nr.preencode(d,o);break;default:throw new Error("Unsupported version")}},encode(d,o){const n=o.version??1;switch(e.uint.encode(d,n),n){case 0:case 1:nr.encode(d,o);break;default:throw new Error("Unsupported version")}},decode(d){const o=e.uint.decode(d);switch(o){case 0:case 1:{const e=nr.decode(d);return e.version=o,e}default:throw new Error("Unsupported version")}}},rr={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.key)},decode:d=>({deviceKey:e.fixed32.decode(d),key:e.fixed32.decode(d)})},tr=de,ir={preencode(d,o){tr.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){tr.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:tr.decode(d),key:e.fixed32.decode(d)})},ar=de,sr={preencode(d,o){ar.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){ar.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:ar.decode(d),key:e.fixed32.decode(d)})},pr={preencode(o,n){o.end++,d>=9&&n.profileSnoozeTime&&e.uint.preencode(o,n.profileSnoozeTime)},encode(o,n){const c=(n.disableReadReceipts?1:0)|(d>=7&&n.stripAttachmentMetadata?2:0)|(d>=9&&n.profileSnoozeTime?4:0);e.uint.encode(o,c),d>=9&&n.profileSnoozeTime&&e.uint.encode(o,n.profileSnoozeTime)},decode(o){const n=e.uint.decode(o);return{disableReadReceipts:!!(1&n),stripAttachmentMetadata:d>=7&&!!(2&n),profileSnoozeTime:d>=9&&4&n?e.uint.decode(o):0}}},ur={disableReadReceipts:"disableReadReceipts",stripAttachmentMetadata:"stripAttachmentMetadata",profileSnoozeTime:"profileSnoozeTime"},lr={preencode(e,d){e.end++},encode(d,o){switch(o){case"disableReadReceipts":e.uint.encode(d,1);break;case"stripAttachmentMetadata":e.uint.encode(d,2);break;case"profileSnoozeTime":e.uint.encode(d,3);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"disableReadReceipts";case 2:return"stripAttachmentMetadata";case 3:return"profileSnoozeTime";default:return null}}},fr=de,mr=e.frame(pr),yr={preencode(e,d){fr.preencode(e,d.header),lr.preencode(e,d.key),mr.preencode(e,d.settings)},encode(e,d){fr.encode(e,d.header),lr.encode(e,d.key),mr.encode(e,d.settings)},decode:e=>({header:fr.decode(e),key:lr.decode(e),settings:mr.decode(e)})},xr={preencode(d,o){e.fixed32.preencode(d,o.discoveryPublicKey),e.uint.preencode(d,o.timestamp),d.end++,o.lastSynced&&e.uint.preencode(d,o.lastSynced)},encode(d,o){const n=(o.lastSynced?1:0)|(o.dirty?2:0);e.fixed32.encode(d,o.discoveryPublicKey),e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.lastSynced&&e.uint.encode(d,o.lastSynced)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d),c=e.uint.decode(d);return{discoveryPublicKey:o,timestamp:n,lastSynced:1&c?e.uint.decode(d):0,dirty:!!(2&c)}}},br={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.activeRooms)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.activeRooms)},decode:d=>({rooms:e.uint.decode(d),activeRooms:e.uint.decode(d)})},vr=F,gr=$,kr={preencode(e,d){e.end++,d.blockedMembers&&gr.preencode(e,d.blockedMembers)},encode(d,o){const n=o.blockedMembers?1:0;e.uint.encode(d,n),o.blockedMembers&&gr.encode(d,o.blockedMembers)},decode:d=>({blockedMembers:1&e.uint.decode(d)?gr.decode(d):null})},Kr=e.frame(Q),hr=e.frame(kr),wr={preencode(d,n){e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.seed),Kr.preencode(d,n.capabilities),o.preencode(d,n.initiator),e.fixed32.preencode(d,n.fastForwardTo),d.end++,n.privateProfile&&hr.preencode(d,n.privateProfile)},encode(d,n){const c=n.privateProfile?1:0;e.buffer.encode(d,n.encryptionKey),e.fixed32.encode(d,n.seed),Kr.encode(d,n.capabilities),o.encode(d,n.initiator),e.fixed32.encode(d,n.fastForwardTo),e.uint.encode(d,c),n.privateProfile&&hr.encode(d,n.privateProfile)},decode:d=>({encryptionKey:e.buffer.decode(d),seed:e.fixed32.decode(d),capabilities:Kr.decode(d),initiator:o.decode(d),fastForwardTo:e.fixed32.decode(d),privateProfile:1&e.uint.decode(d)?hr.decode(d):null})},Pr={preencode(d,o){d.end++,o.count&&e.uint.preencode(d,o.count)},encode(d,o){const n=o.count?1:0;e.uint.encode(d,n),o.count&&e.uint.encode(d,o.count)},decode:d=>({count:1&e.uint.decode(d)?e.uint.decode(d):0})},Tr=e.frame(wr),Rr={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.priority),d.end++,o.v3&&Tr.preencode(d,o.v3),o.timestamp&&e.uint.preencode(d,o.timestamp)},encode(d,o){const n=(o.v3?1:0)|(o.errored?2:0)|(o.timestamp?4:0);e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.priority),e.uint.encode(d,n),o.v3&&Tr.encode(d,o.v3),o.timestamp&&e.uint.encode(d,o.timestamp)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d),c=e.uint.decode(d);return{roomKey:o,priority:n,v3:1&c?Tr.decode(d):null,errored:!!(2&c),timestamp:4&c?e.uint.decode(d):0}}},Ar={preencode(e,d){e.end++},encode(d,o){const n=o.isConfirmed?1:0;e.uint.encode(d,n)},decode:d=>({isConfirmed:!!(1&e.uint.decode(d))})},Sr={preencode(d,o){e.fixed32.preencode(d,o.privateProfileKey)},encode(d,o){e.fixed32.encode(d,o.privateProfileKey)},decode:d=>({privateProfileKey:e.fixed32.decode(d)})},Ir=e.frame(Ar),Mr=gc,Fr=e.frame(xc),qr={preencode(o,n){e.fixed32.preencode(o,n.publicKey),e.fixed32.preencode(o,n.privateProfileKey),r.preencode(o,n.deviceKeyPair),e.buffer.preencode(o,n.deviceProof),Ir.preencode(o,n.status),o.end++,n.entropy&&e.buffer.preencode(o,n.entropy),n.swap&&Mr.preencode(o,n.swap),n.swapV2&&Fr.preencode(o,n.swapV2),d>=7&&n.proofShortenedAt&&e.uint.preencode(o,n.proofShortenedAt)},encode(o,n){const c=(n.entropy?1:0)|(n.swap?2:0)|(n.swapV2?4:0)|(d>=7&&n.proofShortenedAt?8:0);e.fixed32.encode(o,n.publicKey),e.fixed32.encode(o,n.privateProfileKey),r.encode(o,n.deviceKeyPair),e.buffer.encode(o,n.deviceProof),Ir.encode(o,n.status),e.uint.encode(o,c),n.entropy&&e.buffer.encode(o,n.entropy),n.swap&&Mr.encode(o,n.swap),n.swapV2&&Fr.encode(o,n.swapV2),d>=7&&n.proofShortenedAt&&e.uint.encode(o,n.proofShortenedAt)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=r.decode(o),i=e.buffer.decode(o),a=Ir.decode(o),s=e.uint.decode(o);return{publicKey:n,privateProfileKey:c,deviceKeyPair:t,deviceProof:i,status:a,entropy:1&s?e.buffer.decode(o):null,swap:2&s?Mr.decode(o):null,swapV2:4&s?Fr.decode(o):null,proofShortenedAt:d>=7&&8&s?e.uint.decode(o):0}}},Cr={RestoreIdentity:1,CreateRoom:2,LeaveRoom:3,ClearRoom:4,JoinRoomInvitation:5,JoinRoomKeys:6,JoinRoomResponse:7,SendContactRequest:8,TestFastTask:9,TestSlowTask:10,TestErrorTask:11},Vr={preencode(e,d){e.end++},encode(d,o){if(o>11)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Hr={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator)},encode(d,n){const c=(n.fastForwardTo?1:0)|(n.initiator?2:0);e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.uint.encode(d,c),n.fastForwardTo&&e.fixed32.encode(d,n.fastForwardTo),n.initiator&&o.encode(d,n.initiator)},decode(d){const n=e.fixed32.decode(d),c=e.buffer.decode(d),r=e.uint.decode(d);return{roomKey:n,encryptionKey:c,fastForwardTo:1&r?e.fixed32.decode(d):null,initiator:2&r?o.decode(d):null}}},Dr=uc,Lr={preencode(e,d){Dr.preencode(e,d.invitation)},encode(e,d){Dr.encode(e,d.invitation)},decode:e=>({invitation:Dr.decode(e)})},jr={preencode(d,o){e.fixed32.preencode(d,o.mailbox),r.preencode(d,o.keyPair),e.buffer.preencode(d,o.response)},encode(d,o){e.fixed32.encode(d,o.mailbox),r.encode(d,o.keyPair),e.buffer.encode(d,o.response)},decode:d=>({mailbox:e.fixed32.decode(d),keyPair:r.decode(d),response:e.buffer.decode(d)})},Er=ee,Br={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.mailbox&&e.fixed32.preencode(d,n.mailbox)},encode(d,n){const c=(n.fastForwardTo?1:0)|(n.initiator?2:0)|(n.mailbox?4:0);e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.uint.encode(d,c),n.fastForwardTo&&e.fixed32.encode(d,n.fastForwardTo),n.initiator&&o.encode(d,n.initiator),n.mailbox&&e.fixed32.encode(d,n.mailbox)},decode(d){const n=e.fixed32.decode(d),c=e.buffer.decode(d),r=e.uint.decode(d);return{roomKey:n,encryptionKey:c,fastForwardTo:1&r?e.fixed32.decode(d):null,initiator:2&r?o.decode(d):null,mailbox:4&r?e.fixed32.decode(d):null}}},zr=e.frame(Br),Or={preencode(o,n){zr.preencode(o,n.keys),o.end++,d>=15&&n.activeClock&&e.uint.preencode(o,n.activeClock)},encode(o,n){const c=(d>=15&&n.activeClock?1:0)|(d>=15&&n.isReadOnly?2:0);zr.encode(o,n.keys),e.uint.encode(o,c),d>=15&&n.activeClock&&e.uint.encode(o,n.activeClock)},decode(o){const n=zr.decode(o),c=o.start<o.end?e.uint.decode(o):0;return{keys:n,activeClock:d>=15&&1&c?e.uint.decode(o):0,isReadOnly:d>=15&&!!(2&c)}}},Nr=e.frame(Kn),Ur={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.mailbox&&e.fixed32.preencode(d,n.mailbox),n.keyPair&&r.preencode(d,n.keyPair),n.genesis&&Nr.preencode(d,n.genesis)},encode(d,n){const c=(n.fastForwardTo?1:0)|(n.initiator?2:0)|(n.mailbox?4:0)|(n.keyPair?8:0)|(n.genesis?16:0)|(n.isPrivateProfile?32:0);e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.uint.encode(d,c),n.fastForwardTo&&e.fixed32.encode(d,n.fastForwardTo),n.initiator&&o.encode(d,n.initiator),n.mailbox&&e.fixed32.encode(d,n.mailbox),n.keyPair&&r.encode(d,n.keyPair),n.genesis&&Nr.encode(d,n.genesis)},decode(d){const n=e.fixed32.decode(d),c=e.buffer.decode(d),t=e.uint.decode(d);return{roomKey:n,encryptionKey:c,fastForwardTo:1&t?e.fixed32.decode(d):null,initiator:2&t?o.decode(d):null,mailbox:4&t?e.fixed32.decode(d):null,keyPair:8&t?r.decode(d):null,genesis:16&t?Nr.decode(d):null,isPrivateProfile:!!(32&t)}}},Jr={preencode(d,o){e.fixed32.preencode(d,o.roomKey),d.end++},encode(d,o){const n=o.isGossiped?1:0;e.fixed32.encode(d,o.roomKey),e.uint.encode(d,n)},decode:d=>({roomKey:e.fixed32.decode(d),isGossiped:!!(1&e.uint.decode(d))})},Wr={preencode(d,o){e.fixed32.preencode(d,o.roomKey)},encode(d,o){e.fixed32.encode(d,o.roomKey)},decode:d=>({roomKey:e.fixed32.decode(d)})},Gr={preencode(d,o){e.string.preencode(d,o.mnemonic),d.end++,o.profileDiscoveryTimeout&&e.uint.preencode(d,o.profileDiscoveryTimeout)},encode(d,o){const n=(o.profileDiscoveryTimeout?1:0)|(o.recover?2:0);e.string.encode(d,o.mnemonic),e.uint.encode(d,n),o.profileDiscoveryTimeout&&e.uint.encode(d,o.profileDiscoveryTimeout)},decode(d){const o=e.string.decode(d),n=e.uint.decode(d);return{mnemonic:o,profileDiscoveryTimeout:1&n?e.uint.decode(d):0,recover:!!(2&n)}}},Qr=Qn,Xr={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.fixed32.preencode(d,o.memberKey),d.end++,o.message&&e.string.preencode(d,o.message),o.contactInfo&&Qr.preencode(d,o.contactInfo)},encode(d,o){const n=(o.message?1:0)|(o.contactInfo?2:0);e.fixed32.encode(d,o.roomKey),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,n),o.message&&e.string.encode(d,o.message),o.contactInfo&&Qr.encode(d,o.contactInfo)},decode(d){const o=e.fixed32.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{roomKey:o,memberKey:n,message:1&c?e.string.decode(d):null,contactInfo:2&c?Qr.decode(d):null}}},Yr={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++},encode(d,o){const n=o.isPrivateProfile?1:0;e.fixed32.encode(d,o.key),e.uint.encode(d,n)},decode:d=>({key:e.fixed32.decode(d),isPrivateProfile:!!(1&e.uint.decode(d))})},Zr=e.frame(Gr),$r=e.frame(Ur),_r=e.frame(Jr),et=e.frame(Wr),dt=e.frame(Lr),ot=e.frame(Or),nt=e.frame(jr),ct=e.frame(Xr),rt=e.frame(Yr),tt={preencode(d,o){const n=(o.restoreIdentity?1:0)|(o.createRoom?2:0)|(o.leaveRoom?4:0)|(o.clearRoom?8:0)|(o.joinRoomInvitation?16:0)|(o.joinRoomKeys?32:0)|(o.joinRoomResponse?64:0)|(o.sendContactRequest?128:0)|(o.migrateV2Room?256:0);e.fixed32.preencode(d,o.discoveryKey),e.uint.preencode(d,o.priority),e.uint.preencode(d,o.timestamp),e.uint.preencode(d,o.type),e.uint.preencode(d,n),o.restoreIdentity&&Zr.preencode(d,o.restoreIdentity),o.createRoom&&$r.preencode(d,o.createRoom),o.leaveRoom&&_r.preencode(d,o.leaveRoom),o.clearRoom&&et.preencode(d,o.clearRoom),o.joinRoomInvitation&&dt.preencode(d,o.joinRoomInvitation),o.joinRoomKeys&&ot.preencode(d,o.joinRoomKeys),o.joinRoomResponse&&nt.preencode(d,o.joinRoomResponse),o.sendContactRequest&&ct.preencode(d,o.sendContactRequest),o.migrateV2Room&&rt.preencode(d,o.migrateV2Room)},encode(d,o){const n=(o.restoreIdentity?1:0)|(o.createRoom?2:0)|(o.leaveRoom?4:0)|(o.clearRoom?8:0)|(o.joinRoomInvitation?16:0)|(o.joinRoomKeys?32:0)|(o.joinRoomResponse?64:0)|(o.sendContactRequest?128:0)|(o.migrateV2Room?256:0);e.fixed32.encode(d,o.discoveryKey),e.uint.encode(d,o.priority),e.uint.encode(d,o.timestamp),e.uint.encode(d,o.type),e.uint.encode(d,n),o.restoreIdentity&&Zr.encode(d,o.restoreIdentity),o.createRoom&&$r.encode(d,o.createRoom),o.leaveRoom&&_r.encode(d,o.leaveRoom),o.clearRoom&&et.encode(d,o.clearRoom),o.joinRoomInvitation&&dt.encode(d,o.joinRoomInvitation),o.joinRoomKeys&&ot.encode(d,o.joinRoomKeys),o.joinRoomResponse&&nt.encode(d,o.joinRoomResponse),o.sendContactRequest&&ct.encode(d,o.sendContactRequest),o.migrateV2Room&&rt.encode(d,o.migrateV2Room)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d),c=e.uint.decode(d),r=e.uint.decode(d),t=e.uint.decode(d);return{discoveryKey:o,priority:n,timestamp:c,type:r,restoreIdentity:1&t?Zr.decode(d):null,createRoom:2&t?$r.decode(d):null,leaveRoom:4&t?_r.decode(d):null,clearRoom:8&t?et.decode(d):null,joinRoomInvitation:16&t?dt.decode(d):null,joinRoomKeys:32&t?ot.decode(d):null,joinRoomResponse:64&t?nt.decode(d):null,sendContactRequest:128&t?ct.decode(d):null,migrateV2Room:256&t?rt.decode(d):null}}},it=Oe,at={preencode(d,o){e.buffer.preencode(d,o.seed),it.preencode(d,o.invitation)},encode(d,o){e.buffer.encode(d,o.seed),it.encode(d,o.invitation)},decode:d=>({seed:e.buffer.decode(d),invitation:it.decode(d)})},st={preencode(e,d){e.end++},encode(d,o){const n=(o.isWritable?1:0)|(o.isReadable?2:0)|(o.isPrivateProfile?4:0)|(o.isRemoved?8:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isWritable:!!(1&o),isReadable:!!(2&o),isPrivateProfile:!!(4&o),isRemoved:!!(8&o)}}},pt={preencode(d,o){e.uint.preencode(d,o.creation),e.uint.preencode(d,o.latestSync),e.uint.preencode(d,o.latestChatMessage)},encode(d,o){e.uint.encode(d,o.creation),e.uint.encode(d,o.latestSync),e.uint.encode(d,o.latestChatMessage)},decode:d=>({creation:e.uint.decode(d),latestSync:e.uint.decode(d),latestChatMessage:e.uint.decode(d)})},ut=yn,lt=So,ft=e.frame(pt),mt=Kr,yt=e.frame(st),xt=e.frame(pe),bt=e.frame(hd),vt=an,gt=vn,kt=e.frame(Lo),Kt=$,ht=e.array(e.frame(Wn)),wt=e.frame(gd),Pt=vc,Tt={preencode(o,n){const c=(n.selfDevice?1:0)|(n.selfMember?2:0)|(n.config?4:0)|(n.identity?8:0)|(n.lastMessage?16:0)|(n.dm?32:0)|(n.readLengths?64:0)|(n.lastMember?128:0)|(n.version?256:0)|(d>=3&&n.preferences?512:0)|(d>=4&&n.activeCall?1024:0)|(d>=8&&n.lastMessageLabels?2048:0)|(d>=9&&n.settings?4096:0)|(d>=13&&n.system?8192:0)|(d>=13&&n.processed?16384:0);e.fixed32.preencode(o,n.roomKey),e.fixed32.preencode(o,n.discoveryKey),e.buffer.preencode(o,n.encryptionKey),ut.preencode(o,n.digest),lt.preencode(o,n.stats),ft.preencode(o,n.timestamps),e.uint.preencode(o,n.fork),e.uint.preencode(o,n.length),e.fixed32.preencode(o,n.seed),mt.preencode(o,n.capabilities),yt.preencode(o,n.status),e.uint.preencode(o,c),n.selfDevice&&xt.preencode(o,n.selfDevice),n.selfMember&&bt.preencode(o,n.selfMember),n.config&&vt.preencode(o,n.config),n.identity&&gt.preencode(o,n.identity),n.lastMessage&&kt.preencode(o,n.lastMessage),n.dm&&Kt.preencode(o,n.dm),n.readLengths&&ht.preencode(o,n.readLengths),n.lastMember&&wt.preencode(o,n.lastMember),n.version&&e.uint.preencode(o,n.version),d>=3&&n.preferences&&Pt.preencode(o,n.preferences),d>=4&&n.activeCall&&fl.preencode(o,n.activeCall),d>=8&&n.lastMessageLabels&&ml.preencode(o,n.lastMessageLabels),d>=9&&n.settings&&yl.preencode(o,n.settings),d>=13&&n.system&&xl.preencode(o,n.system),d>=13&&n.processed&&bl.preencode(o,n.processed)},encode(o,n){const c=(n.selfDevice?1:0)|(n.selfMember?2:0)|(n.config?4:0)|(n.identity?8:0)|(n.lastMessage?16:0)|(n.dm?32:0)|(n.readLengths?64:0)|(n.lastMember?128:0)|(n.version?256:0)|(d>=3&&n.preferences?512:0)|(d>=4&&n.activeCall?1024:0)|(d>=8&&n.lastMessageLabels?2048:0)|(d>=9&&n.settings?4096:0)|(d>=13&&n.system?8192:0)|(d>=13&&n.processed?16384:0);e.fixed32.encode(o,n.roomKey),e.fixed32.encode(o,n.discoveryKey),e.buffer.encode(o,n.encryptionKey),ut.encode(o,n.digest),lt.encode(o,n.stats),ft.encode(o,n.timestamps),e.uint.encode(o,n.fork),e.uint.encode(o,n.length),e.fixed32.encode(o,n.seed),mt.encode(o,n.capabilities),yt.encode(o,n.status),e.uint.encode(o,c),n.selfDevice&&xt.encode(o,n.selfDevice),n.selfMember&&bt.encode(o,n.selfMember),n.config&&vt.encode(o,n.config),n.identity&&gt.encode(o,n.identity),n.lastMessage&&kt.encode(o,n.lastMessage),n.dm&&Kt.encode(o,n.dm),n.readLengths&&ht.encode(o,n.readLengths),n.lastMember&&wt.encode(o,n.lastMember),n.version&&e.uint.encode(o,n.version),d>=3&&n.preferences&&Pt.encode(o,n.preferences),d>=4&&n.activeCall&&fl.encode(o,n.activeCall),d>=8&&n.lastMessageLabels&&ml.encode(o,n.lastMessageLabels),d>=9&&n.settings&&yl.encode(o,n.settings),d>=13&&n.system&&xl.encode(o,n.system),d>=13&&n.processed&&bl.encode(o,n.processed)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.buffer.decode(o),t=ut.decode(o),i=lt.decode(o),a=ft.decode(o),s=e.uint.decode(o),p=e.uint.decode(o),u=e.fixed32.decode(o),l=mt.decode(o),f=yt.decode(o),m=e.uint.decode(o);return{roomKey:n,discoveryKey:c,encryptionKey:r,digest:t,stats:i,timestamps:a,fork:s,length:p,seed:u,capabilities:l,status:f,selfDevice:1&m?xt.decode(o):null,selfMember:2&m?bt.decode(o):null,config:4&m?vt.decode(o):null,identity:8&m?gt.decode(o):null,lastMessage:16&m?kt.decode(o):null,dm:32&m?Kt.decode(o):null,readLengths:64&m?ht.decode(o):null,lastMember:128&m?wt.decode(o):null,version:256&m?e.uint.decode(o):0,preferences:d>=3&&512&m?Pt.decode(o):null,activeCall:d>=4&&1024&m?fl.decode(o):null,lastMessageLabels:d>=8&&2048&m?ml.decode(o):null,settings:d>=9&&4096&m?yl.decode(o):null,system:d>=13&&8192&m?xl.decode(o):null,processed:d>=13&&16384&m?bl.decode(o):null}}},Rt=vc,At={preencode(d,o){e.fixed32.preencode(d,o.roomKey),Rt.preencode(d,o.status)},encode(d,o){e.fixed32.encode(d,o.roomKey),Rt.encode(d,o.status)},decode:d=>({roomKey:e.fixed32.decode(d),status:Rt.decode(d)})},St={preencode(d,o){e.fixed32.preencode(d,o.roomKey),d.end++,o.repairs&&e.uint.preencode(d,o.repairs)},encode(d,o){const n=o.repairs?1:0;e.fixed32.encode(d,o.roomKey),e.uint.encode(d,n),o.repairs&&e.uint.encode(d,o.repairs)},decode:d=>({roomKey:e.fixed32.decode(d),repairs:1&e.uint.decode(d)?e.uint.decode(d):0})},It={preencode(o,n){e.fixed32.preencode(o,n.mailbox),e.fixed32.preencode(o,n.key),o.end++,n.roomKey&&e.fixed32.preencode(o,n.roomKey),n.keyPair&&r.preencode(o,n.keyPair),n.responseKeyPair&&r.preencode(o,n.responseKeyPair),d>=15&&n.activeClock&&e.uint.preencode(o,n.activeClock)},encode(o,n){const c=(n.roomKey?1:0)|(n.keyPair?2:0)|(n.responseKeyPair?4:0)|(d>=14&&n.pending?8:0)|(d>=15&&n.activeClock?16:0);e.fixed32.encode(o,n.mailbox),e.fixed32.encode(o,n.key),e.uint.encode(o,c),n.roomKey&&e.fixed32.encode(o,n.roomKey),n.keyPair&&r.encode(o,n.keyPair),n.responseKeyPair&&r.encode(o,n.responseKeyPair),d>=15&&n.activeClock&&e.uint.encode(o,n.activeClock)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=e.uint.decode(o);return{mailbox:n,key:c,roomKey:1&t?e.fixed32.decode(o):null,keyPair:2&t?r.decode(o):null,responseKeyPair:4&t?r.decode(o):null,pending:d>=14&&!!(8&t),activeClock:d>=15&&16&t?e.uint.decode(o):0}}},Mt={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.responsePublicKey)},encode(d,o){e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.responsePublicKey)},decode:d=>({key:e.fixed32.decode(d),responsePublicKey:e.fixed32.decode(d)})},Ft=fe,qt={preencode(d,o){e.fixed32.preencode(d,o.key),Ft.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),Ft.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),profile:Ft.decode(d)})},Ct=xt,Vt={preencode(d,o){e.fixed32.preencode(d,o.roomKey),Ct.preencode(d,o.device)},encode(d,o){e.fixed32.encode(d,o.roomKey),Ct.encode(d,o.device)},decode:d=>({roomKey:e.fixed32.decode(d),device:Ct.decode(d)})},Ht=k,Dt={preencode(o,n){Ht.preencode(o,n.file),e.fixed32.preencode(o,n.roomKey),o.end++,n.encryptionKey&&e.buffer.preencode(o,n.encryptionKey),d>=4&&n.lastAccessed&&e.uint.preencode(o,n.lastAccessed),d>=4&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(n.encryptionKey?1:0)|(n.cleared?2:0)|(n.own?4:0)|(d>=4&&n.lastAccessed?8:0)|(d>=4&&n.version?16:0);Ht.encode(o,n.file),e.fixed32.encode(o,n.roomKey),e.uint.encode(o,c),n.encryptionKey&&e.buffer.encode(o,n.encryptionKey),d>=4&&n.lastAccessed&&e.uint.encode(o,n.lastAccessed),d>=4&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=Ht.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{file:n,roomKey:c,encryptionKey:1&r?e.buffer.decode(o):null,cleared:!!(2&r),own:!!(4&r),lastAccessed:d>=4&&8&r?e.uint.decode(o):0,version:d>=4&&16&r?e.uint.decode(o):0}}},Lt={preencode(d,o){d.end++,o.key&&e.string.preencode(d,o.key),o.description&&e.string.preencode(d,o.description)},encode(d,o){const n=(o.key?1:0)|(o.value?2:0)|(o.description?4:0);e.uint.encode(d,n),o.key&&e.string.encode(d,o.key),o.description&&e.string.encode(d,o.description)},decode(d){const o=e.uint.decode(d);return{key:1&o?e.string.decode(d):null,value:!!(2&o),description:4&o?e.string.decode(d):null}}},jt=e.array(e.frame(Lt)),Et={preencode(e,d){e.end++,d.flags&&jt.preencode(e,d.flags)},encode(d,o){const n=o.flags?1:0;e.uint.encode(d,n),o.flags&&jt.encode(d,o.flags)},decode:d=>({flags:1&e.uint.decode(d)?jt.decode(d):null})},Bt=ed,zt={preencode(d,o){d.end++,o.nodes&&Bt.preencode(d,o.nodes),o.concurrency&&e.uint.preencode(d,o.concurrency),o.maxWindow&&e.uint.preencode(d,o.maxWindow),o.randomPunchInterval&&e.uint.preencode(d,o.randomPunchInterval),o.connectionKeepAlive&&e.uint.preencode(d,o.connectionKeepAlive)},encode(d,o){const n=(o.nodes?1:0)|(o.concurrency?2:0)|(o.maxWindow?4:0)|(o.randomPunchInterval?8:0)|(o.connectionKeepAlive?16:0);e.uint.encode(d,n),o.nodes&&Bt.encode(d,o.nodes),o.concurrency&&e.uint.encode(d,o.concurrency),o.maxWindow&&e.uint.encode(d,o.maxWindow),o.randomPunchInterval&&e.uint.encode(d,o.randomPunchInterval),o.connectionKeepAlive&&e.uint.encode(d,o.connectionKeepAlive)},decode(d){const o=e.uint.decode(d);return{nodes:1&o?Bt.decode(d):null,concurrency:2&o?e.uint.decode(d):0,maxWindow:4&o?e.uint.decode(d):0,randomPunchInterval:8&o?e.uint.decode(d):0,connectionKeepAlive:16&o?e.uint.decode(d):0}}},Ot={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.count)},encode(d,o){e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.count)},decode:d=>({roomKey:e.fixed32.decode(d),count:e.uint.decode(d)})},Nt={preencode(d,o){d.end++,o.roomKey&&e.fixed32.preencode(d,o.roomKey),o.coreKey&&e.fixed32.preencode(d,o.coreKey)},encode(d,o){const n=(o.roomKey?1:0)|(o.coreKey?2:0);e.uint.encode(d,n),o.roomKey&&e.fixed32.encode(d,o.roomKey),o.coreKey&&e.fixed32.encode(d,o.coreKey)},decode(d){const o=e.uint.decode(d);return{roomKey:1&o?e.fixed32.decode(d):null,coreKey:2&o?e.fixed32.decode(d):null}}},Ut=e.frame(Nt),Jt={preencode(d,o){e.string.preencode(d,o.code),e.string.preencode(d,o.message),e.string.preencode(d,o.stack),e.uint.preencode(d,o.timestamp),d.end++,o.details&&Ut.preencode(d,o.details)},encode(d,o){const n=o.details?1:0;e.string.encode(d,o.code),e.string.encode(d,o.message),e.string.encode(d,o.stack),e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.details&&Ut.encode(d,o.details)},decode:d=>({code:e.string.decode(d),message:e.string.decode(d),stack:e.string.decode(d),timestamp:e.uint.decode(d),details:1&e.uint.decode(d)?Ut.decode(d):null})},Wt={RESUME:1,WAKEUP:2,PRESUSPEND:3,SUSPEND:4},Gt={preencode(e,d){e.end++},encode(d,o){if(o>4)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Qt={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.total)},encode(d,o){e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.total)},decode:d=>({roomKey:e.fixed32.decode(d),total:e.uint.decode(d)})},Xt=i,Yt={preencode(d,o){e.uint.preencode(d,o.duration)},encode(d,o){e.uint.encode(d,o.duration)},decode:d=>({duration:e.uint.decode(d)})},Zt=H,$t=H,_t=e.frame(Xt),ei={preencode(e,d){_t.preencode(e,d.header)},encode(e,d){_t.encode(e,d.header)},decode:e=>({header:_t.decode(e)})},di=e.frame(Yt),oi={preencode(e,d){di.preencode(e,d.header)},encode(e,d){di.encode(e,d.header)},decode:e=>({header:di.decode(e)})},ni=_t,ci={preencode(e,d){ni.preencode(e,d.header)},encode(e,d){ni.encode(e,d.header)},decode:e=>({header:ni.decode(e)})},ri=H,ti=_t,ii=an,ai=J,si={preencode(e,d){ti.preencode(e,d.header),e.end++,d.config&&ii.preencode(e,d.config),d.settings&&ai.preencode(e,d.settings)},encode(d,o){const n=(o.config?1:0)|(o.settings?2:0);ti.encode(d,o.header),e.uint.encode(d,n),o.config&&ii.encode(d,o.config),o.settings&&ai.encode(d,o.settings)},decode(d){const o=ti.decode(d),n=e.uint.decode(d);return{header:o,config:1&n?ii.decode(d):null,settings:2&n?ai.decode(d):null}}},pi=di,ui={preencode(d,o){pi.preencode(d,o.header),d.end++,o.roomKey&&e.fixed32.preencode(d,o.roomKey)},encode(d,o){const n=o.roomKey?1:0;pi.encode(d,o.header),e.uint.encode(d,n),o.roomKey&&e.fixed32.encode(d,o.roomKey)},decode:d=>({header:pi.decode(d),roomKey:1&e.uint.decode(d)?e.fixed32.decode(d):null})},li=_t,fi={preencode(d,o){li.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey)},encode(d,o){li.encode(d,o.header),e.fixed32.encode(d,o.roomKey)},decode:d=>({header:li.decode(d),roomKey:e.fixed32.decode(d)})},mi=_t,yi={preencode(d,o){mi.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey)},encode(d,o){mi.encode(d,o.header),e.fixed32.encode(d,o.roomKey)},decode:d=>({header:mi.decode(d),roomKey:e.fixed32.decode(d)})},xi=_t,bi={preencode(d,o){xi.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey)},encode(d,o){xi.encode(d,o.header),e.fixed32.encode(d,o.roomKey)},decode:d=>({header:xi.decode(d),roomKey:e.fixed32.decode(d)})},vi=di,gi={preencode(e,d){vi.preencode(e,d.header)},encode(e,d){vi.encode(e,d.header)},decode:e=>({header:vi.decode(e)})},ki=_t,Ki=an,hi={preencode(d,o){ki.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.key),Ki.preencode(d,o.config)},encode(d,o){ki.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.key),Ki.encode(d,o.config)},decode:d=>({header:ki.decode(d),roomKey:e.fixed32.decode(d),key:e.uint.decode(d),config:Ki.decode(d)})},wi=_t,Pi=J,Ti={preencode(d,o){wi.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.key),Pi.preencode(d,o.settings)},encode(d,o){wi.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.key),Pi.encode(d,o.settings)},decode:d=>({header:wi.decode(d),roomKey:e.fixed32.decode(d),key:e.uint.decode(d),settings:Pi.decode(d)})},Ri=_t,Ai=vc,Si={preencode(d,o){Ri.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.key),Ai.preencode(d,o.status)},encode(d,o){Ri.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.key),Ai.encode(d,o.status)},decode:d=>({header:Ri.decode(d),roomKey:e.fixed32.decode(d),key:e.uint.decode(d),status:Ai.decode(d)})},Ii=_t,Mi=Eo,Fi={preencode(d,o){Ii.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),Mi.preencode(d,o.message)},encode(d,o){Ii.encode(d,o.header),e.fixed32.encode(d,o.roomKey),Mi.encode(d,o.message)},decode:d=>({header:Ii.decode(d),roomKey:e.fixed32.decode(d),message:Mi.decode(d)})},qi=di,Ci={preencode(e,d){qi.preencode(e,d.header)},encode(e,d){qi.encode(e,d.header)},decode:e=>({header:qi.decode(e)})},Vi=_t,Hi=Eo,Di={preencode(d,o){Vi.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),n.preencode(d,o.id),Hi.preencode(d,o.message)},encode(d,o){Vi.encode(d,o.header),e.fixed32.encode(d,o.roomKey),n.encode(d,o.id),Hi.encode(d,o.message)},decode:d=>({header:Vi.decode(d),roomKey:e.fixed32.decode(d),id:n.decode(d),message:Hi.decode(d)})},Li=di,ji={preencode(e,d){Li.preencode(e,d.header)},encode(e,d){Li.encode(e,d.header)},decode:e=>({header:Li.decode(e)})},Ei=_t,Bi={preencode(d,o){Ei.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),n.preencode(d,o.id)},encode(d,o){Ei.encode(d,o.header),e.fixed32.encode(d,o.roomKey),n.encode(d,o.id)},decode:d=>({header:Ei.decode(d),roomKey:e.fixed32.decode(d),id:n.decode(d)})},zi=di,Oi={preencode(e,d){zi.preencode(e,d.header)},encode(e,d){zi.encode(e,d.header)},decode:e=>({header:zi.decode(e)})},Ni=_t,Ui={preencode(d,o){Ni.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),n.preencode(d,o.id),e.string.preencode(d,o.reaction)},encode(d,o){Ni.encode(d,o.header),e.fixed32.encode(d,o.roomKey),n.encode(d,o.id),e.string.encode(d,o.reaction)},decode:d=>({header:Ni.decode(d),roomKey:e.fixed32.decode(d),id:n.decode(d),reaction:e.string.decode(d)})},Ji=di,Wi={preencode(e,d){Ji.preencode(e,d.header)},encode(e,d){Ji.encode(e,d.header)},decode:e=>({header:Ji.decode(e)})},Gi=_t,Qi={preencode(d,o){Gi.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),n.preencode(d,o.id),e.string.preencode(d,o.reaction)},encode(d,o){Gi.encode(d,o.header),e.fixed32.encode(d,o.roomKey),n.encode(d,o.id),e.string.encode(d,o.reaction)},decode:d=>({header:Gi.decode(d),roomKey:e.fixed32.decode(d),id:n.decode(d),reaction:e.string.decode(d)})},Xi=di,Yi={preencode(e,d){Xi.preencode(e,d.header)},encode(e,d){Xi.encode(e,d.header)},decode:e=>({header:Xi.decode(e)})},Zi={preencode(d,o){e.uint.preencode(d,o.clock),e.uint.preencode(d,o.start),e.uint.preencode(d,o.end)},encode(d,o){e.uint.encode(d,o.clock),e.uint.encode(d,o.start),e.uint.encode(d,o.end)},decode:d=>({clock:e.uint.decode(d),start:e.uint.decode(d),end:e.uint.decode(d)})},$i=H,_i=$,ea={preencode(d,o){e.uint.preencode(d,o.clock),_i.preencode(d,o.keys)},encode(d,o){e.uint.encode(d,o.clock),_i.encode(d,o.keys)},decode:d=>({clock:e.uint.decode(d),keys:_i.decode(d)})},da={preencode(d,o){e.uint.preencode(d,o.clock),e.fixed32.preencode(d,o.roomKey),d.end++,o.start&&e.uint.preencode(d,o.start),o.size&&e.uint.preencode(d,o.size)},encode(d,o){const n=(o.start?1:0)|(o.size?2:0)|(o.isBottom?4:0);e.uint.encode(d,o.clock),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,n),o.start&&e.uint.encode(d,o.start),o.size&&e.uint.encode(d,o.size)},decode(d){const o=e.uint.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{clock:o,roomKey:n,start:1&c?e.uint.decode(d):0,size:2&c?e.uint.decode(d):0,isBottom:!!(4&c)}}},oa=H,na={preencode(d,o){e.uint.preencode(d,o.clock),e.fixed32.preencode(d,o.roomKey),d.end++,o.offset&&e.fixed32.preencode(d,o.offset),o.count&&e.uint.preencode(d,o.count)},encode(d,o){const n=(o.offset?1:0)|(o.count?2:0);e.uint.encode(d,o.clock),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,n),o.offset&&e.fixed32.encode(d,o.offset),o.count&&e.uint.encode(d,o.count)},decode(d){const o=e.uint.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{clock:o,roomKey:n,offset:1&c?e.fixed32.decode(d):null,count:2&c?e.uint.decode(d):0}}},ca=H,ra={preencode(d,o){e.uint.preencode(d,o.timestamp),e.fixed32.preencode(d,o.id)},encode(d,o){e.uint.encode(d,o.timestamp),e.fixed32.encode(d,o.id)},decode:d=>({timestamp:e.uint.decode(d),id:e.fixed32.decode(d)})},ta={Changed:1,Removed:2},ia={preencode(e,d){e.end++},encode(d,o){if(o>2)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},aa=$,sa={preencode(d,o){aa.preencode(d,o.keys),e.uint.preencode(d,o.start),e.uint.preencode(d,o.end),e.uint.preencode(d,o.total)},encode(d,o){aa.encode(d,o.keys),e.uint.encode(d,o.start),e.uint.encode(d,o.end),e.uint.encode(d,o.total)},decode:d=>({keys:aa.decode(d),start:e.uint.decode(d),end:e.uint.decode(d),total:e.uint.decode(d)})},pa={preencode(e,d){ia.preencode(e,d.type),ra.preencode(e,d.room)},encode(e,d){ia.encode(e,d.type),ra.encode(e,d.room)},decode:e=>({type:ia.decode(e),room:ra.decode(e)})},ua=yt,la=bd,fa={preencode(e,d){ua.preencode(e,d.device),e.end++,d.member&&la.preencode(e,d.member)},encode(d,o){const n=o.member?1:0;ua.encode(d,o.device),e.uint.encode(d,n),o.member&&la.encode(d,o.member)},decode:d=>({device:ua.decode(d),member:1&e.uint.decode(d)?la.decode(d):null})},ma=e.frame(fa),ya=yn,xa=an,ba={preencode(d,o){e.fixed32.preencode(d,o.id),ma.preencode(d,o.role),ya.preencode(d,o.digest),xa.preencode(d,o.config),d.end++,o.messageId&&n.preencode(d,o.messageId)},encode(d,o){const c=o.messageId?1:0;e.fixed32.encode(d,o.id),ma.encode(d,o.role),ya.encode(d,o.digest),xa.encode(d,o.config),e.uint.encode(d,c),o.messageId&&n.encode(d,o.messageId)},decode:d=>({id:e.fixed32.decode(d),role:ma.decode(d),digest:ya.decode(d),config:xa.decode(d),messageId:1&e.uint.decode(d)?n.decode(d):null})},va=yt,ga={preencode(d,o){e.fixed32.preencode(d,o.id),va.preencode(d,o.status)},encode(d,o){e.fixed32.encode(d,o.id),va.encode(d,o.status)},decode:d=>({id:e.fixed32.decode(d),status:va.decode(d)})},ka=yn,Ka={preencode(d,o){e.fixed32.preencode(d,o.id),ka.preencode(d,o.digest)},encode(d,o){e.fixed32.encode(d,o.id),ka.encode(d,o.digest)},decode:d=>({id:e.fixed32.decode(d),digest:ka.decode(d)})},ha=an,wa={preencode(d,o){e.fixed32.preencode(d,o.id),ha.preencode(d,o.config)},encode(d,o){e.fixed32.encode(d,o.id),ha.encode(d,o.config)},decode:d=>({id:e.fixed32.decode(d),config:ha.decode(d)})},Pa=ma,Ta={preencode(d,o){e.fixed32.preencode(d,o.id),d.end++,o.role&&Pa.preencode(d,o.role)},encode(d,o){const n=o.role?1:0;e.fixed32.encode(d,o.id),e.uint.encode(d,n),o.role&&Pa.encode(d,o.role)},decode:d=>({id:e.fixed32.decode(d),role:1&e.uint.decode(d)?Pa.decode(d):null})},Ra={preencode(d,o){e.fixed32.preencode(d,o.id),n.preencode(d,o.lastMessage)},encode(d,o){e.fixed32.encode(d,o.id),n.encode(d,o.lastMessage)},decode:d=>({id:e.fixed32.decode(d),lastMessage:n.decode(d)})},Aa=fe,Sa={preencode(d,o){e.fixed32.preencode(d,o.key),Aa.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),Aa.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),profile:Aa.decode(d)})},Ia=ae,Ma={preencode(d,o){e.fixed32.preencode(d,o.key),Ia.preencode(d,o.status),vl.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),Ia.encode(d,o.status),vl.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),status:Ia.decode(d),profile:vl.decode(d)})},Fa={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.roomKey),e.fixed32.encode(d,o.key)},decode:d=>({roomKey:e.fixed32.decode(d),key:e.fixed32.decode(d)})},qa=Fa,Ca=e.array(n),Va={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.start),e.uint.preencode(d,o.size),e.uint.preencode(d,o.total),Ca.preencode(d,o.ids),d.end++},encode(d,o){const n=o.isBottom?1:0;e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.start),e.uint.encode(d,o.size),e.uint.encode(d,o.total),Ca.encode(d,o.ids),e.uint.encode(d,n)},decode:d=>({roomKey:e.fixed32.decode(d),start:e.uint.decode(d),size:e.uint.decode(d),total:e.uint.decode(d),ids:Ca.decode(d),isBottom:!!(1&e.uint.decode(d))})},Ha={preencode(d,o){e.uint.preencode(d,o.sent),d.end++,o.edited&&e.uint.preencode(d,o.edited)},encode(d,o){const n=o.edited?1:0;e.uint.encode(d,o.sent),e.uint.encode(d,n),o.edited&&e.uint.encode(d,o.edited)},decode:d=>({sent:e.uint.decode(d),edited:1&e.uint.decode(d)?e.uint.decode(d):0})},Da=e.frame(Ha),La=Mo,ja=Fo,Ea=qo,Ba={preencode(d,o){n.preencode(d,o.id),e.uint.preencode(d,o.clock),Da.preencode(d,o.timestamps),La.preencode(d,o.status),d.end++,o.message&&ja.preencode(d,o.message),o.event&&Ea.preencode(d,o.event)},encode(d,o){const c=(o.message?1:0)|(o.event?2:0);n.encode(d,o.id),e.uint.encode(d,o.clock),Da.encode(d,o.timestamps),La.encode(d,o.status),e.uint.encode(d,c),o.message&&ja.encode(d,o.message),o.event&&Ea.encode(d,o.event)},decode(d){const o=n.decode(d),c=e.uint.decode(d),r=Da.decode(d),t=La.decode(d),i=e.uint.decode(d);return{id:o,clock:c,timestamps:r,status:t,message:1&i?ja.decode(d):null,event:2&i?Ea.decode(d):null}}},za=e.frame(Ba),Oa=bd,Na={preencode(d,o){za.preencode(d,o.chat),e.fixed32.preencode(d,o.memberKey),Oa.preencode(d,o.role)},encode(d,o){za.encode(d,o.chat),e.fixed32.encode(d,o.memberKey),Oa.encode(d,o.role)},decode:d=>({chat:za.decode(d),memberKey:e.fixed32.decode(d),role:Oa.decode(d)})},Ua=za,Ja={preencode(e,d){Ua.preencode(e,d.chat)},encode(e,d){Ua.encode(e,d.chat)},decode:e=>({chat:Ua.decode(e)})},Wa=Ca,Ga={preencode(d,o){Wa.preencode(d,o.ids),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Wa.encode(d,o.ids),e.fixed32.encode(d,o.memberKey)},decode:d=>({ids:Wa.decode(d),memberKey:e.fixed32.decode(d)})},Qa=Ca,Xa=bd,Ya={preencode(e,d){Qa.preencode(e,d.ids),Xa.preencode(e,d.role)},encode(e,d){Qa.encode(e,d.ids),Xa.encode(e,d.role)},decode:e=>({ids:Qa.decode(e),role:Xa.decode(e)})},Za=e.frame(dn),$a={preencode(e,d){n.preencode(e,d.id),Za.preencode(e,d.reactions)},encode(e,d){n.encode(e,d.id),Za.encode(e,d.reactions)},decode:e=>({id:n.decode(e),reactions:Za.decode(e)})},_a=Za,es={preencode(e,d){n.preencode(e,d.id),_a.preencode(e,d.digest)},encode(e,d){n.encode(e,d.id),_a.encode(e,d.digest)},decode:e=>({id:n.decode(e),digest:_a.decode(e)})},ds=H,os=H,ns=e.array(e.frame(ic)),cs={preencode(e,d){ns.preencode(e,d.invitations)},encode(e,d){ns.encode(e,d.invitations)},decode:e=>({invitations:ns.decode(e)})},rs=e.frame(ud),ts={preencode(d,o){e.fixed32.preencode(d,o.roomKey),rs.preencode(d,o.request)},encode(d,o){e.fixed32.encode(d,o.roomKey),rs.encode(d,o.request)},decode:d=>({roomKey:e.fixed32.decode(d),request:rs.decode(d)})},is=e.array(e.frame(ts)),as={preencode(e,d){is.preencode(e,d.requests)},encode(e,d){is.encode(e,d.requests)},decode:e=>({requests:is.decode(e)})},ss=ns,ps=e.array(e.frame(ud)),us={preencode(e,d){ss.preencode(e,d.pendingInvitations),ps.preencode(e,d.identityJoinRequests)},encode(e,d){ss.encode(e,d.pendingInvitations),ps.encode(e,d.identityJoinRequests)},decode:e=>({pendingInvitations:ss.decode(e),identityJoinRequests:ps.decode(e)})},ls=_t,fs={preencode(d,o){ls.preencode(d,o.header),e.string.preencode(d,o.invitation),d.end++},encode(d,o){const n=o.isIdentity?1:0;ls.encode(d,o.header),e.string.encode(d,o.invitation),e.uint.encode(d,n)},decode:d=>({header:ls.decode(d),invitation:e.string.decode(d),isIdentity:!!(1&e.uint.decode(d))})},ms=di,ys={preencode(e,d){ms.preencode(e,d.header)},encode(e,d){ms.encode(e,d.header)},decode:e=>({header:ms.decode(e)})},xs={preencode(e,d){e.end++},encode(d,o){const n=(o.canModerate?1:0)|(o.canAdmin?2:0)|(o.requiresConfirmation?4:0)|(o.isReadOnly?8:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{canModerate:!!(1&o),canAdmin:!!(2&o),requiresConfirmation:!!(4&o),isReadOnly:!!(8&o)}}},bs=_t,vs=e.frame(xs),gs={preencode(d,o){bs.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),d.end++,o.permissions&&vs.preencode(d,o.permissions),o.expiration&&e.uint.preencode(d,o.expiration)},encode(d,o){const n=(o.permissions?1:0)|(o.expiration?2:0);bs.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,n),o.permissions&&vs.encode(d,o.permissions),o.expiration&&e.uint.encode(d,o.expiration)},decode(d){const o=bs.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{header:o,roomKey:n,permissions:1&c?vs.decode(d):null,expiration:2&c?e.uint.decode(d):0}}},ks=di,Ks={preencode(d,o){ks.preencode(d,o.header),e.string.preencode(d,o.invitation)},encode(d,o){ks.encode(d,o.header),e.string.encode(d,o.invitation)},decode:d=>({header:ks.decode(d),invitation:e.string.decode(d)})},hs=_t,ws={preencode(e,d){hs.preencode(e,d.header)},encode(e,d){hs.encode(e,d.header)},decode:e=>({header:hs.decode(e)})},Ps=di,Ts={preencode(d,o){Ps.preencode(d,o.header),e.string.preencode(d,o.invitation)},encode(d,o){Ps.encode(d,o.header),e.string.encode(d,o.invitation)},decode:d=>({header:Ps.decode(d),invitation:e.string.decode(d)})},Rs=_t,As=rs,Ss={preencode(d,o){Rs.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),As.preencode(d,o.request)},encode(d,o){Rs.encode(d,o.header),e.fixed32.encode(d,o.roomKey),As.encode(d,o.request)},decode:d=>({header:Rs.decode(d),roomKey:e.fixed32.decode(d),request:As.decode(d)})},Is=di,Ms={preencode(e,d){Is.preencode(e,d.header)},encode(e,d){Is.encode(e,d.header)},decode:e=>({header:Is.decode(e)})},Fs=_t,qs=rs,Cs={preencode(d,o){Fs.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),qs.preencode(d,o.request)},encode(d,o){Fs.encode(d,o.header),e.fixed32.encode(d,o.roomKey),qs.encode(d,o.request)},decode:d=>({header:Fs.decode(d),roomKey:e.fixed32.decode(d),request:qs.decode(d)})},Vs=di,Hs={preencode(e,d){Vs.preencode(e,d.header)},encode(e,d){Vs.encode(e,d.header)},decode:e=>({header:Vs.decode(e)})},Ds=_t,Ls={preencode(d,o){Ds.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){Ds.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:Ds.decode(d),id:e.fixed32.decode(d)})},js=di,Es={preencode(e,d){js.preencode(e,d.header)},encode(e,d){js.encode(e,d.header)},decode:e=>({header:js.decode(e)})},Bs=_t,zs={preencode(d,o){Bs.preencode(d,o.header),e.string.preencode(d,o.displayName),d.end++,o.avatar&&e.buffer.preencode(d,o.avatar)},encode(d,o){const n=o.avatar?1:0;Bs.encode(d,o.header),e.string.encode(d,o.displayName),e.uint.encode(d,n),o.avatar&&e.buffer.encode(d,o.avatar)},decode:d=>({header:Bs.decode(d),displayName:e.string.decode(d),avatar:1&e.uint.decode(d)?e.buffer.decode(d):null})},Os=H,Ns=H,Us={preencode(e,d){e.end++},encode(d,o){const n=(o.isConfirmed?1:0)|(o.isLoggedOut?2:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isConfirmed:!!(1&o),isLoggedOut:!!(2&o)}}},Js=e.frame(Us),Ws=$,Gs={preencode(d,o){e.fixed32.preencode(d,o.memberKey),Js.preencode(d,o.status),Ws.preencode(d,o.deviceKeys)},encode(d,o){e.fixed32.encode(d,o.memberKey),Js.encode(d,o.status),Ws.encode(d,o.deviceKeys)},decode:d=>({memberKey:e.fixed32.decode(d),status:Js.decode(d),deviceKeys:Ws.decode(d)})},Qs={preencode(d,o){e.fixed32.preencode(d,o.memberKey)},encode(d,o){e.fixed32.encode(d,o.memberKey)},decode:d=>({memberKey:e.fixed32.decode(d)})},Xs={preencode(d,o){e.fixed32.preencode(d,o.deviceKey)},encode(d,o){e.fixed32.encode(d,o.deviceKey)},decode:d=>({deviceKey:e.fixed32.decode(d)})},Ys=_t,Zs={preencode(d,o){Ys.preencode(d,o.header),e.string.preencode(d,o.password)},encode(d,o){Ys.encode(d,o.header),e.string.encode(d,o.password)},decode:d=>({header:Ys.decode(d),password:e.string.decode(d)})},$s=di,_s={preencode(d,o){$s.preencode(d,o.header),e.string.preencode(d,o.inspector)},encode(d,o){$s.encode(d,o.header),e.string.encode(d,o.inspector)},decode:d=>({header:$s.decode(d),inspector:e.string.decode(d)})},ep=di,dp={preencode(e,d){ep.preencode(e,d.header)},encode(e,d){ep.encode(e,d.header)},decode:e=>({header:ep.decode(e)})},op=di,np={preencode(e,d){op.preencode(e,d.header)},encode(e,d){op.encode(e,d.header)},decode:e=>({header:op.decode(e)})},cp={Flag:1},rp={preencode(e,d){e.end++},encode(d,o){if(o>1)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},tp={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),rp.preencode(d,o.label)},encode(d,o){e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),rp.encode(d,o.label)},decode:d=>({key:e.fixed32.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),label:rp.decode(d)})},ip=de,ap={preencode(d,o){ip.preencode(d,o.header),e.fixed32.preencode(d,o.key),rp.preencode(d,o.label)},encode(d,o){ip.encode(d,o.header),e.fixed32.encode(d,o.key),rp.encode(d,o.label)},decode:d=>({header:ip.decode(d),key:e.fixed32.decode(d),label:rp.decode(d)})},sp={preencode(d,o){rp.preencode(d,o.label),e.uint.preencode(d,o.count)},encode(d,o){rp.encode(d,o.label),e.uint.encode(d,o.count)},decode:d=>({label:rp.decode(d),count:e.uint.decode(d)})},pp=e.array(e.frame(sp)),up={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.total),pp.preencode(d,o.labels),e.uint.preencode(d,o.editedAt),e.uint.preencode(d,o.flagsClock)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.total),pp.encode(d,o.labels),e.uint.encode(d,o.editedAt),e.uint.encode(d,o.flagsClock)},decode:d=>({key:e.fixed32.decode(d),total:e.uint.decode(d),labels:pp.decode(d),editedAt:e.uint.decode(d),flagsClock:e.uint.decode(d)})},lp=de,fp={preencode(d,o){lp.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.fromDeviceKey)},encode(d,o){lp.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.fromDeviceKey)},decode:d=>({header:lp.decode(d),deviceKey:e.fixed32.decode(d),fromDeviceKey:e.fixed32.decode(d)})},mp={preencode(d,o){e.float64.preencode(d,o.latitude),e.float64.preencode(d,o.longitude)},encode(d,o){e.float64.encode(d,o.latitude),e.float64.encode(d,o.longitude)},decode:d=>({latitude:e.float64.decode(d),longitude:e.float64.decode(d)})},yp=de,xp=$,bp={preencode(o,n){yp.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),e.buffer.preencode(o,n.encryptionKey),o.end++,d>=4&&n.streams&&xp.preencode(o,n.streams),d>=4&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=4&&n.version&&e.uint.preencode(o,n.version),d>=12&&n.streamInputs&&gl.preencode(o,n.streamInputs),d>=12&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey)},encode(o,n){const c=(d>=4&&n.streams?1:0)|(d>=4&&n.discoveryKey?2:0)|(d>=4&&n.version?4:0)|(d>=12&&n.streamInputs?8:0)|(d>=12&&n.swarmKey?16:0);yp.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,c),d>=4&&n.streams&&xp.encode(o,n.streams),d>=4&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=4&&n.version&&e.uint.encode(o,n.version),d>=12&&n.streamInputs&&gl.encode(o,n.streamInputs),d>=12&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey)},decode(o){const n=yp.decode(o),c=e.fixed32.decode(o),r=e.buffer.decode(o),t=e.uint.decode(o);return{header:n,callKey:c,encryptionKey:r,streams:d>=4&&1&t?xp.decode(o):null,discoveryKey:d>=4&&2&t?e.fixed32.decode(o):null,version:d>=4&&4&t?e.uint.decode(o):0,streamInputs:d>=12&&8&t?gl.decode(o):null,swarmKey:d>=12&&16&t?e.fixed32.decode(o):null}}},vp=de,gp=$,kp={preencode(o,n){vp.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),o.end++,d>=4&&n.streams&&gp.preencode(o,n.streams),d>=12&&n.streamInputs&&kl.preencode(o,n.streamInputs),d>=12&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey)},encode(o,n){const c=(d>=4&&n.streams?1:0)|(d>=12&&n.streamInputs?2:0)|(d>=12&&n.swarmKey?4:0);vp.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.uint.encode(o,c),d>=4&&n.streams&&gp.encode(o,n.streams),d>=12&&n.streamInputs&&kl.encode(o,n.streamInputs),d>=12&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey)},decode(o){const n=vp.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{header:n,callKey:c,streams:d>=4&&1&r?gp.decode(o):null,streamInputs:d>=12&&2&r?kl.decode(o):null,swarmKey:d>=12&&4&r?e.fixed32.decode(o):null}}},Kp=de,hp={preencode(d,o){Kp.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Kp.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Kp.decode(d),callKey:e.fixed32.decode(d)})},wp=de,Pp={preencode(d,o){wp.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){wp.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:wp.decode(d),callKey:e.fixed32.decode(d)})},Tp=de,Rp={preencode(o,n){Tp.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.streamKey),o.end++,d>=12&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=12&&n.type&&e.string.preencode(o,n.type)},encode(o,n){const c=(d>=12&&n.mediaStreamId?1:0)|(d>=12&&n.type?2:0)|(d>=12&&n.muted?4:0);Tp.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.streamKey),e.uint.encode(o,c),d>=12&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=12&&n.type&&e.string.encode(o,n.type)},decode(o){const n=Tp.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=o.start<o.end?e.uint.decode(o):0;return{header:n,callKey:c,streamKey:r,mediaStreamId:d>=12&&1&t?e.string.decode(o):null,type:d>=12&&2&t?e.string.decode(o):null,muted:d>=12&&!!(4&t)}}},Ap=de,Sp={preencode(d,o){Ap.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.streamKey)},encode(d,o){Ap.encode(d,o.header),e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.streamKey)},decode:d=>({header:Ap.decode(d),callKey:e.fixed32.decode(d),streamKey:e.fixed32.decode(d)})},Ip={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.buffer.preencode(o,n.encryptionKey),e.uint.preencode(o,n.createdAt),o.end++,d>=4&&n.endedAt&&e.uint.preencode(o,n.endedAt),d>=4&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=4&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(d>=4&&n.endedAt?1:0)|(d>=4&&n.discoveryKey?2:0)|(d>=4&&n.version?4:0);e.fixed32.encode(o,n.callKey),e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=4&&n.endedAt&&e.uint.encode(o,n.endedAt),d>=4&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=4&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=e.fixed32.decode(o),c=e.buffer.decode(o),r=e.uint.decode(o),t=e.uint.decode(o);return{callKey:n,encryptionKey:c,createdAt:r,endedAt:d>=4&&1&t?e.uint.decode(o):0,discoveryKey:d>=4&&2&t?e.fixed32.decode(o):null,version:d>=4&&4&t?e.uint.decode(o):0}}},Mp={preencode(d,o){e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.createdAt)},encode(d,o){e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.createdAt)},decode:d=>({callKey:e.fixed32.decode(d),memberKey:e.fixed32.decode(d),createdAt:e.uint.decode(d)})},Fp={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.deviceKey),e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.createdAt),o.end++,d>=4&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),d>=8&&n.lastHeartbeatAt&&e.uint.preencode(o,n.lastHeartbeatAt)},encode(o,n){const c=(d>=4&&n.swarmKey?1:0)|(d>=8&&n.lastHeartbeatAt?2:0)|(d>=9&&n.isRecording?4:0);e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.deviceKey),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=4&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey),d>=8&&n.lastHeartbeatAt&&e.uint.encode(o,n.lastHeartbeatAt)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o),i=e.uint.decode(o);return{callKey:n,deviceKey:c,memberKey:r,createdAt:t,swarmKey:d>=4&&1&i?e.fixed32.decode(o):null,lastHeartbeatAt:d>=8&&2&i?e.uint.decode(o):0,isRecording:d>=9&&!!(4&i)}}},qp={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.deviceKey),e.buffer.preencode(o,n.streamKey),e.uint.preencode(o,n.createdAt),o.end++,d>=12&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=12&&n.type&&e.string.preencode(o,n.type),d>=12&&n.statusKey&&e.uint.preencode(o,n.statusKey)},encode(o,n){const c=(d>=12&&n.mediaStreamId?1:0)|(d>=12&&n.type?2:0)|(d>=12&&n.statusKey?4:0);e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.deviceKey),e.buffer.encode(o,n.streamKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=12&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=12&&n.type&&e.string.encode(o,n.type),d>=12&&n.statusKey&&e.uint.encode(o,n.statusKey)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.buffer.decode(o),t=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{callKey:n,deviceKey:c,streamKey:r,createdAt:t,mediaStreamId:d>=12&&1&i?e.string.decode(o):null,type:d>=12&&2&i?e.string.decode(o):null,statusKey:d>=12&&4&i?e.uint.decode(o):0}}},Cp={preencode(o,n){e.fixed32.preencode(o,n.callKey),o.end++,d>=4&&n.selfDeviceKey&&e.fixed32.preencode(o,n.selfDeviceKey),d>=12&&n.createdAt&&e.uint.preencode(o,n.createdAt)},encode(o,n){const c=(d>=4&&n.selfDeviceKey?1:0)|(d>=12&&n.createdAt?2:0);e.fixed32.encode(o,n.callKey),e.uint.encode(o,c),d>=4&&n.selfDeviceKey&&e.fixed32.encode(o,n.selfDeviceKey),d>=12&&n.createdAt&&e.uint.encode(o,n.createdAt)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o);return{callKey:n,selfDeviceKey:d>=4&&1&c?e.fixed32.decode(o):null,createdAt:d>=12&&2&c?e.uint.decode(o):0}}},Vp={preencode(d,o){e.uint.preencode(d,o.lastCleared)},encode(d,o){e.uint.encode(d,o.lastCleared)},decode:d=>({lastCleared:e.uint.decode(d)})},Hp={Nightly:"Nightly",Internal:"Internal",Production:"Production"},Dp={preencode(e,d){e.end++},encode(d,o){switch(o){case"Nightly":e.uint.encode(d,1);break;case"Internal":e.uint.encode(d,2);break;case"Production":e.uint.encode(d,3);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"Nightly";case 2:return"Internal";case 3:return"Production";default:return null}}},Lp=de,jp={preencode(e,d){Lp.preencode(e,d.header)},encode(e,d){Lp.encode(e,d.header)},decode:e=>({header:Lp.decode(e)})},Ep=de,Bp={preencode(e,d){Ep.preencode(e,d.header)},encode(e,d){Ep.encode(e,d.header)},decode:e=>({header:Ep.decode(e)})},zp={preencode(o,n){Dp.preencode(o,n.buildType),o.end++,d>=6&&n.latestOfflineAbi&&e.uint.preencode(o,n.latestOfflineAbi)},encode(o,n){const c=d>=6&&n.latestOfflineAbi?1:0;Dp.encode(o,n.buildType),e.uint.encode(o,c),d>=6&&n.latestOfflineAbi&&e.uint.encode(o,n.latestOfflineAbi)},decode(o){const n=Dp.decode(o),c=o.start<o.end?e.uint.decode(o):0;return{buildType:n,latestOfflineAbi:d>=6&&1&c?e.uint.decode(o):0}}},Op=de,Np={preencode(d,o){Op.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),e.buffer.preencode(d,o.deviceProof),e.buffer.preencode(d,o.writerProof)},encode(d,o){Op.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.buffer.encode(d,o.deviceProof),e.buffer.encode(d,o.writerProof)},decode:d=>({header:Op.decode(d),deviceKey:e.fixed32.decode(d),deviceProof:e.buffer.decode(d),writerProof:e.buffer.decode(d)})},Up={preencode(o,n){o.end++,d>=7&&n.otaResyncPrivateProfileBump&&e.uint.preencode(o,n.otaResyncPrivateProfileBump)},encode(o,n){const c=d>=7&&n.otaResyncPrivateProfileBump?1:0;e.uint.encode(o,c),d>=7&&n.otaResyncPrivateProfileBump&&e.uint.encode(o,n.otaResyncPrivateProfileBump)},decode(o){const n=e.uint.decode(o);return{otaResyncPrivateProfileBump:d>=7&&1&n?e.uint.decode(o):0}}},Jp={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.buffer.preencode(d,o.proof),e.uint.preencode(d,o.createdAt)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.buffer.encode(d,o.proof),e.uint.encode(d,o.createdAt)},decode:d=>({deviceKey:e.fixed32.decode(d),proof:e.buffer.decode(d),createdAt:e.uint.decode(d)})},Wp=de,Gp={preencode(d,o){Wp.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Wp.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Wp.decode(d),callKey:e.fixed32.decode(d)})},Qp=de,Xp={preencode(d,o){Qp.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.deviceKey)},encode(d,o){Qp.encode(d,o.header),e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.deviceKey)},decode:d=>({header:Qp.decode(d),callKey:e.fixed32.decode(d),deviceKey:e.fixed32.decode(d)})},Yp=e.frame(Nn),Zp=e.array(e.frame(Dn)),$p={preencode(e,d){Yp.preencode(e,d.digest),Zp.preencode(e,d.mine)},encode(e,d){Yp.encode(e,d.digest),Zp.encode(e,d.mine)},decode:e=>({digest:Yp.decode(e),mine:Zp.decode(e)})},_p=de,eu={preencode(d,o){_p.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){_p.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:_p.decode(d),callKey:e.fixed32.decode(d)})},du=de,ou={preencode(d,o){du.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){du.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:du.decode(d),callKey:e.fixed32.decode(d)})},nu={preencode(o,n){o.end++,d>=9&&n.profileSnoozeTime&&e.uint.preencode(o,n.profileSnoozeTime)},encode(o,n){const c=(d>=9&&n.disableReadReceipts?1:0)|(d>=9&&n.stripAttachmentMetadata?2:0)|(d>=9&&n.profileSnoozeTime?4:0);e.uint.encode(o,c),d>=9&&n.profileSnoozeTime&&e.uint.encode(o,n.profileSnoozeTime)},decode(o){const n=e.uint.decode(o);return{disableReadReceipts:d>=9&&!!(1&n),stripAttachmentMetadata:d>=9&&!!(2&n),profileSnoozeTime:d>=9&&4&n?e.uint.decode(o):0}}},cu={preencode(o,n){o.end++,d>=9&&n.maxPeers&&e.uint.preencode(o,n.maxPeers)},encode(o,n){const c=d>=9&&n.maxPeers?1:0;e.uint.encode(o,c),d>=9&&n.maxPeers&&e.uint.encode(o,n.maxPeers)},decode(o){const n=e.uint.decode(o);return{maxPeers:d>=9&&1&n?e.uint.decode(o):0}}},ru=de,tu={preencode(e,d){ru.preencode(e,d.header),n.preencode(e,d.oplog)},encode(e,d){ru.encode(e,d.header),n.encode(e,d.oplog)},decode:e=>({header:ru.decode(e),oplog:n.decode(e)})},iu=de,au={preencode(e,d){iu.preencode(e,d.header)},encode(e,d){iu.encode(e,d.header)},decode:e=>({header:iu.decode(e)})},su={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.timestamp)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.timestamp)},decode:d=>({memberKey:e.fixed32.decode(d),timestamp:e.uint.decode(d)})},pu=de,uu={preencode(o,n){pu.preencode(o,n.header),e.fixed32.preencode(o,n.memberKey),o.end++,d>=10&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=d>=10&&n.alias?1:0;pu.encode(o,n.header),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,c),d>=10&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=pu.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{header:n,memberKey:c,alias:d>=10&&1&r?e.string.decode(o):null}}},lu={preencode(d,o){e.uint.preencode(d,o.streams)},encode(d,o){e.uint.encode(d,o.streams)},decode:d=>({streams:e.uint.decode(d)})},fu={preencode(d,o){e.fixed32.preencode(d,o.streamKey),e.string.preencode(d,o.mediaStreamId),e.string.preencode(d,o.type),d.end++},encode(o,n){const c=d>=12&&n.muted?1:0;e.fixed32.encode(o,n.streamKey),e.string.encode(o,n.mediaStreamId),e.string.encode(o,n.type),e.uint.encode(o,c)},decode(o){const n=e.fixed32.decode(o),c=e.string.decode(o),r=e.string.decode(o),t=e.uint.decode(o);return{streamKey:n,mediaStreamId:c,type:r,muted:d>=12&&!!(1&t)}}},mu=de,yu={preencode(d,o){mu.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.streamKey),d.end++},encode(o,n){const c=d>=12&&n.muted?1:0;mu.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.streamKey),e.uint.encode(o,c)},decode(o){const n=mu.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o);return{header:n,callKey:c,streamKey:r,muted:d>=12&&!!(1&t)}}},xu={preencode(d,o){e.uint.preencode(d,o.statusKey),d.end++},encode(o,n){const c=d>=12&&n.muted?1:0;e.uint.encode(o,n.statusKey),e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o),c=e.uint.decode(o);return{statusKey:n,muted:d>=12&&!!(1&c)}}},bu={preencode(n,c){e.fixed32.preencode(n,c.key),n.end++,d>=13&&c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),d>=13&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=(d>=13&&c.encryptionKey?1:0)|(d>=13&&c.bootFrom?2:0);e.fixed32.encode(n,c.key),e.uint.encode(n,r),d>=13&&c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),d>=13&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.uint.decode(n);return{key:c,encryptionKey:d>=13&&1&r?e.buffer.decode(n):null,bootFrom:d>=13&&2&r?o.decode(n):null}}},vu={preencode(d,o){e.fixed32.preencode(d,o.hash)},encode(d,o){e.fixed32.encode(d,o.hash)},decode:d=>({hash:e.fixed32.decode(d)})},gu={preencode(d,o){e.fixed32.preencode(d,o.hash),e.buffer.preencode(d,o.data)},encode(d,o){e.fixed32.encode(d,o.hash),e.buffer.encode(d,o.data)},decode:d=>({hash:e.fixed32.decode(d),data:e.buffer.decode(d)})},ku={preencode(n,c){o.preencode(n,c.autobeeMigrationHead),n.end++,d>=13&&c.legacyViewHead&&o.preencode(n,c.legacyViewHead),d>=13&&c.dbViewHead&&o.preencode(n,c.dbViewHead),d>=13&&c.blobsViewHead&&o.preencode(n,c.blobsViewHead),e.uint.preencode(n,c.createdAt)},encode(n,c){const r=(d>=13&&c.legacyViewHead?1:0)|(d>=13&&c.dbViewHead?2:0)|(d>=13&&c.blobsViewHead?4:0);o.encode(n,c.autobeeMigrationHead),e.uint.encode(n,r),d>=13&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=13&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=13&&c.blobsViewHead&&o.encode(n,c.blobsViewHead),e.uint.encode(n,c.createdAt)},decode(n){const c=o.decode(n),r=e.uint.decode(n);return{autobeeMigrationHead:c,legacyViewHead:d>=13&&1&r?o.decode(n):null,dbViewHead:d>=13&&2&r?o.decode(n):null,blobsViewHead:d>=13&&4&r?o.decode(n):null,createdAt:e.uint.decode(n)}}},Ku=de,hu={preencode(e,n){Ku.preencode(e,n.header),o.preencode(e,n.head),e.end++,d>=13&&n.legacyViewHead&&o.preencode(e,n.legacyViewHead),d>=13&&n.dbViewHead&&o.preencode(e,n.dbViewHead),d>=13&&n.blobsViewHead&&o.preencode(e,n.blobsViewHead)},encode(n,c){const r=(d>=13&&c.legacyViewHead?1:0)|(d>=13&&c.dbViewHead?2:0)|(d>=13&&c.blobsViewHead?4:0);Ku.encode(n,c.header),o.encode(n,c.head),e.uint.encode(n,r),d>=13&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=13&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=13&&c.blobsViewHead&&o.encode(n,c.blobsViewHead)},decode(n){const c=Ku.decode(n),r=o.decode(n),t=e.uint.decode(n);return{header:c,head:r,legacyViewHead:d>=13&&1&t?o.decode(n):null,dbViewHead:d>=13&&2&t?o.decode(n):null,blobsViewHead:d>=13&&4&t?o.decode(n):null}}},wu={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.fixed32.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.seed),n.end++,d>=13&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=d>=13&&c.bootFrom?1:0;e.fixed32.encode(n,c.roomKey),e.fixed32.encode(n,c.encryptionKey),e.fixed32.encode(n,c.seed),e.uint.encode(n,r),d>=13&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.fixed32.decode(n),t=e.fixed32.decode(n),i=e.uint.decode(n);return{roomKey:c,encryptionKey:r,seed:t,bootFrom:d>=13&&1&i?o.decode(n):null}}},Pu=bd,Tu={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.fixed32.preencode(d,o.deviceKey),e.uint.preencode(d,o.deviceLength),e.uint.preencode(d,o.clock),Pu.preencode(d,o.status)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,o.deviceLength),e.uint.encode(d,o.clock),Pu.encode(d,o.status)},decode:d=>({memberKey:e.fixed32.decode(d),deviceKey:e.fixed32.decode(d),deviceLength:e.uint.decode(d),clock:e.uint.decode(d),status:Pu.decode(d)})},Ru={preencode(d,o){e.fixed32.preencode(d,o.hash),e.buffer.preencode(d,o.blob)},encode(d,o){e.fixed32.encode(d,o.hash),e.buffer.encode(d,o.blob)},decode:d=>({hash:e.fixed32.decode(d),blob:e.buffer.decode(d)})},Au=vc,Su=gc,Iu=tc,Mu={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),Au.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,d>=13&&c.initiator&&o.preencode(n,c.initiator),d>=13&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=13&&c.identitySwap&&Su.preencode(n,c.identitySwap),d>=13&&c.identitySwapV2&&Iu.preencode(n,c.identitySwapV2),d>=13&&c.contact&&e.fixed32.preencode(n,c.contact)},encode(n,c){const r=(d>=13&&c.initiator?1:0)|(d>=13&&c.bootFrom?2:0)|(d>=13&&c.identitySwap?4:0)|(d>=13&&c.identitySwapV2?8:0)|(d>=13&&c.contact?16:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),Au.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,r),d>=13&&c.initiator&&o.encode(n,c.initiator),d>=13&&c.bootFrom&&o.encode(n,c.bootFrom),d>=13&&c.identitySwap&&Su.encode(n,c.identitySwap),d>=13&&c.identitySwapV2&&Iu.encode(n,c.identitySwapV2),d>=13&&c.contact&&e.fixed32.encode(n,c.contact)},decode(n){const c=e.fixed32.decode(n),r=e.buffer.decode(n),t=e.fixed32.decode(n),i=Au.decode(n),a=e.uint.decode(n),s=e.uint.decode(n);return{roomKey:c,encryptionKey:r,mailbox:t,status:i,clock:a,initiator:d>=13&&1&s?o.decode(n):null,bootFrom:d>=13&&2&s?o.decode(n):null,identitySwap:d>=13&&4&s?Su.decode(n):null,identitySwapV2:d>=13&&8&s?Iu.decode(n):null,contact:d>=13&&16&s?e.fixed32.decode(n):null}}},Fu=de,qu={preencode(n,c){Fu.preencode(n,c.header),e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),n.end++,d>=13&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=13&&c.initiator&&o.preencode(n,c.initiator),d>=13&&c.dm&&e.fixed32.preencode(n,c.dm)},encode(n,c){const r=(d>=13&&c.bootFrom?1:0)|(d>=13&&c.initiator?2:0)|(d>=13&&c.dm?4:0)|(d>=13&&c.isReadOnly?8:0);Fu.encode(n,c.header),e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),e.uint.encode(n,r),d>=13&&c.bootFrom&&o.encode(n,c.bootFrom),d>=13&&c.initiator&&o.encode(n,c.initiator),d>=13&&c.dm&&e.fixed32.encode(n,c.dm)},decode(n){const c=Fu.decode(n),r=e.fixed32.decode(n),t=e.buffer.decode(n),i=e.fixed32.decode(n),a=e.uint.decode(n);return{header:c,roomKey:r,encryptionKey:t,mailbox:i,bootFrom:d>=13&&1&a?o.decode(n):null,initiator:d>=13&&2&a?o.decode(n):null,dm:d>=13&&4&a?e.fixed32.decode(n):null,isReadOnly:d>=13&&!!(8&a)}}},Cu={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),n.end++,d>=13&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=13&&c.initiator&&o.preencode(n,c.initiator)},encode(n,c){const r=(d>=13&&c.bootFrom?1:0)|(d>=13&&c.initiator?2:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.uint.encode(n,r),d>=13&&c.bootFrom&&o.encode(n,c.bootFrom),d>=13&&c.initiator&&o.encode(n,c.initiator)},decode(n){const c=e.fixed32.decode(n),r=e.buffer.decode(n),t=e.uint.decode(n);return{roomKey:c,encryptionKey:r,bootFrom:d>=13&&1&t?o.decode(n):null,initiator:d>=13&&2&t?o.decode(n):null}}},Vu={preencode(d,o){e.fixed32.preencode(d,o.roomKey),Kl.preencode(d,o.head),e.uint.preencode(d,o.timestamp),d.end++},encode(o,n){const c=d>=13&&n.incremental?1:0;e.fixed32.encode(o,n.roomKey),Kl.encode(o,n.head),e.uint.encode(o,n.timestamp),e.uint.encode(o,c)},decode(o){const n=e.fixed32.decode(o),c=Kl.decode(o),r=e.uint.decode(o),t=e.uint.decode(o);return{roomKey:n,head:c,timestamp:r,incremental:d>=13&&!!(1&t)}}},Hu={preencode(o,n){o.end++,d>=13&&n.key&&e.fixed32.preencode(o,n.key),e.uint.preencode(o,n.length)},encode(o,n){const c=d>=13&&n.key?1:0;e.uint.encode(o,c),d>=13&&n.key&&e.fixed32.encode(o,n.key),e.uint.encode(o,n.length)},decode(o){const n=e.uint.decode(o);return{key:d>=13&&1&n?e.fixed32.decode(o):null,length:e.uint.decode(o)}}},Du={preencode(n,c){e.fixed32.preencode(n,c.roomKey),n.end++,d>=13&&c.legacyViewHead&&o.preencode(n,c.legacyViewHead),d>=13&&c.dbViewHead&&o.preencode(n,c.dbViewHead),d>=13&&c.blobsViewHead&&o.preencode(n,c.blobsViewHead),d>=13&&c.autobeeMigrationHead&&o.preencode(n,c.autobeeMigrationHead)},encode(n,c){const r=(d>=13&&c.legacyViewHead?1:0)|(d>=13&&c.dbViewHead?2:0)|(d>=13&&c.blobsViewHead?4:0)|(d>=13&&c.autobeeMigrationHead?8:0);e.fixed32.encode(n,c.roomKey),e.uint.encode(n,r),d>=13&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=13&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=13&&c.blobsViewHead&&o.encode(n,c.blobsViewHead),d>=13&&c.autobeeMigrationHead&&o.encode(n,c.autobeeMigrationHead)},decode(n){const c=e.fixed32.decode(n),r=e.uint.decode(n);return{roomKey:c,legacyViewHead:d>=13&&1&r?o.decode(n):null,dbViewHead:d>=13&&2&r?o.decode(n):null,blobsViewHead:d>=13&&4&r?o.decode(n):null,autobeeMigrationHead:d>=13&&8&r?o.decode(n):null}}},Lu={preencode(d,o){e.fixed32.preencode(d,o.id),e.fixed32.preencode(d,o.writerKey),e.buffer.preencode(d,o.blindResponse)},encode(d,o){e.fixed32.encode(d,o.id),e.fixed32.encode(d,o.writerKey),e.buffer.encode(d,o.blindResponse)},decode:d=>({id:e.fixed32.decode(d),writerKey:e.fixed32.decode(d),blindResponse:e.buffer.decode(d)})},ju=de,Eu={preencode(d,o){ju.preencode(d,o.header),e.buffer.preencode(d,o.blindResponse)},encode(d,o){ju.encode(d,o.header),e.buffer.encode(d,o.blindResponse)},decode:d=>({header:ju.decode(d),blindResponse:e.buffer.decode(d)})},Bu=e.frame(qr),zu={preencode(o,n){e.string.preencode(o,n.mnemonic),o.end++,d>=15&&n.profileDiscoveryTimeout&&e.uint.preencode(o,n.profileDiscoveryTimeout),d>=15&&n.privateProfileKey&&e.fixed32.preencode(o,n.privateProfileKey),d>=15&&n.identity&&Bu.preencode(o,n.identity)},encode(o,n){const c=(d>=15&&n.profileDiscoveryTimeout?1:0)|(d>=15&&n.privateProfileKey?2:0)|(d>=15&&n.identity?4:0);e.string.encode(o,n.mnemonic),e.uint.encode(o,c),d>=15&&n.profileDiscoveryTimeout&&e.uint.encode(o,n.profileDiscoveryTimeout),d>=15&&n.privateProfileKey&&e.fixed32.encode(o,n.privateProfileKey),d>=15&&n.identity&&Bu.encode(o,n.identity)},decode(o){const n=e.string.decode(o),c=e.uint.decode(o);return{mnemonic:n,profileDiscoveryTimeout:d>=15&&1&c?e.uint.decode(o):0,privateProfileKey:d>=15&&2&c?e.fixed32.decode(o):null,identity:d>=15&&4&c?Bu.decode(o):null}}},Ou=de,Nu={preencode(e,d){Ou.preencode(e,d.header)},encode(e,d){Ou.encode(e,d.header)},decode:e=>({header:Ou.decode(e)})},Uu=de,Ju={preencode(o,c){Uu.preencode(o,c.header),n.preencode(o,c.oplog),e.uint.preencode(o,c.index),o.end++,d>=16&&c.displayType&&Xo.preencode(o,c.displayType)},encode(o,c){const r=d>=16&&c.displayType?1:0;Uu.encode(o,c.header),n.encode(o,c.oplog),e.uint.encode(o,c.index),e.uint.encode(o,r),d>=16&&c.displayType&&Xo.encode(o,c.displayType)},decode(o){const c=Uu.decode(o),r=n.decode(o),t=e.uint.decode(o),i=e.uint.decode(o);return{header:c,oplog:r,index:t,displayType:d>=16&&1&i?Xo.decode(o):0}}},Wu=de,Gu=no,Qu={preencode(d,o){Wu.preencode(d,o.header),n.preencode(d,o.oplog),Xo.preencode(d,o.displayType),e.uint.preencode(d,o.index),Gu.preencode(d,o.preview)},encode(d,o){Wu.encode(d,o.header),n.encode(d,o.oplog),Xo.encode(d,o.displayType),e.uint.encode(d,o.index),Gu.encode(d,o.preview)},decode:d=>({header:Wu.decode(d),oplog:n.decode(d),displayType:Xo.decode(d),index:e.uint.decode(d),preview:Gu.decode(d)})},Xu=de,Yu={preencode(d,o){Xu.preencode(d,o.header),n.preencode(d,o.oplog),Xo.preencode(d,o.displayType),e.uint.preencode(d,o.index)},encode(d,o){Xu.encode(d,o.header),n.encode(d,o.oplog),Xo.encode(d,o.displayType),e.uint.encode(d,o.index)},decode:d=>({header:Xu.decode(d),oplog:n.decode(d),displayType:Xo.decode(d),index:e.uint.decode(d)})},Zu=e.frame(w),$u=e.frame(lu),_u=Zu,el=e.frame(le),dl=Zu,ol=el,nl=e.frame(wu),cl=el,rl=e.frame(wd),tl=e.frame(mp),il=tl,al=Zu,sl=Zu,pl=e.frame(Ic),ul=pl,ll=pl,fl=e.frame(Cp),ml=e.frame($p),yl=e.frame(nu),xl=e.frame(Hu),bl=xl,vl=el,gl=e.array(e.frame(fu)),kl=gl,Kl=xl;function hl(e){switch(e){case"@keet/head":return o;case"@keet/oplog-id":return n;case"@keet/encryption-keypair":return c;case"@keet/signing-keypair":return r;case"@keet/room-keys":return t;case"@keet/operation-header":return i;case"@keet/blob-pointer":return a;case"@keet/file-dimensions":return s;case"@keet/file-metadata":return u;case"@keet/external-drive-pointer":return l;case"@keet/external-blob-pointer":return f;case"@keet/file-pointer":return x;case"@keet/file":return g;case"@keet/image-file":return w;case"@keet/file-status":return P;case"@keet/file-record":return A;case"@keet/device-status":return S;case"@keet/member-status":return I;case"@keet/member-moderation-status":return M;case"@keet/abi":return F;case"@keet/device-stats":return q;case"@keet/member-stats":return C;case"@keet/chat-stats":return V;case"@keet/file-stats":return H;case"@keet/stats":return B;case"@keet/room-type":return O;case"@keet/system-settings":return N;case"@keet/system-digest":return W;case"@keet/room-seed":return G;case"@keet/room-capabilities":return Q;case"@keet/room-supported-language":return Y;case"@keet/room-config":return _;case"@keet/blind-peer":return ee;case"@keet/add-blind-peer-operation":return ne;case"@keet/remove-blind-peer-operation":return re;case"@keet/identity-attestation":return te;case"@keet/device-invitation":return ie;case"@keet/device":return pe;case"@keet/member-profile":return ue;case"@keet/device-profile":return le;case"@keet/member-update":return me;case"@keet/device-update":return ye;case"@keet/member-contact-info":return be;case"@keet/signed-pairing-data":return ve;case"@keet/device-request-identity":return ge;case"@keet/device-response-identity":return ke;case"@keet/device-identity":return Ke;case"@keet/device-request-with-invitation":return Te;case"@keet/device-request-with-invitation-and-proof":return Ae;case"@keet/device-request-with-member-proof":return Me;case"@keet/device-request":return Ce;case"@keet/device-response":return De;case"@keet/invitation-metadata":return Le;case"@keet/invitation":return Be;case"@keet/add-invitation-operation":return Ne;case"@keet/remove-invitation-operation":return Je;case"@keet/sendable-room-invitation":return We;case"@keet/readonly-room-invitation":return Ge;case"@keet/sendable-identity-invitation":return Qe;case"@keet/sendable-contact-invitation":return Xe;case"@keet/sendable-invitation":return dd;case"@keet/add-device-operation":return nd;case"@keet/update-device-operation":return rd;case"@keet/remove-device-operation":return id;case"@keet/start-indexing-operation":return ad;case"@keet/stop-indexing-operation":return sd;case"@keet/join-request":return ud;case"@keet/accept-join-request-operation":return md;case"@keet/reject-join-request-operation":return xd;case"@keet/member":return gd;case"@keet/full-member":return hd;case"@keet/member-proofs":return wd;case"@keet/update-member-operation":return Rd;case"@keet/change-member-status-operation":return Id;case"@keet/change-member-role-operation":return Fd;case"@keet/remove-member-operation":return Cd;case"@keet/member-activity":return Vd;case"@keet/member-joined-event":return Hd;case"@keet/member-left-event":return Dd;case"@keet/member-removed-event":return Ld;case"@keet/title-changed-chat-event":return jd;case"@keet/chat-event":return Nd;case"@keet/sendable-event":return Ud;case"@keet/display-range":return Jd;case"@keet/display-content-range":return Gd;case"@keet/mention-display-item":return Xd;case"@keet/translation-display-item":return Zd;case"@keet/link-preview":return eo;case"@keet/display-link-item":return co;case"@keet/display":return yo;case"@keet/oplog-message":return go;case"@keet/index-message":return ho;case"@keet/full-index-message":return To;case"@keet/message-status":return Ro;case"@keet/message-index-id":return Ao;case"@keet/thread":return Io;case"@keet/chat-message-record":return Co;case"@keet/full-chat-message-record":return Lo;case"@keet/add-chat-message-operation":return Bo;case"@keet/remove-chat-message-operation":return Oo;case"@keet/update-chat-message-operation":return Jo;case"@keet/pin-chat-message-operation":return Go;case"@keet/display-type":return Xo;case"@keet/add-file-preview-operation":return Zo;case"@keet/reaction":return $o;case"@keet/reactions-summary":return _o;case"@keet/reactions-digest":return dn;case"@keet/add-reaction-operation":return nn;case"@keet/remove-reaction-operation":return rn;case"@keet/update-room-config-operation":return sn;case"@keet/group-member":return pn;case"@keet/user-registry-info":return un;case"@keet/room-identity":return fn;case"@keet/genesis-operation":return Kn;case"@keet/upgrade-operation":return wn;case"@keet/migrate-abi-operation":return Tn;case"@keet/system-settings-keys":return An;case"@keet/update-system-settings-operation":return Mn;case"@keet/test-increment-operation":return qn;case"@keet/test-collection-record-1":return Cn;case"@keet/label-type":return Hn;case"@keet/chat-label":return Dn;case"@keet/add-chat-label-operation":return jn;case"@keet/remove-chat-label-operation":return Bn;case"@keet/chat-label-summary":return zn;case"@keet/chat-label-digest":return Nn;case"@keet/update-read-length-operation":return Jn;case"@keet/read-length":return Wn;case"@keet/tmp-removed-member":return Gn;case"@keet-private-id/contact":return Xn;case"@keet-private-id/v3-room-migration-info":return Yn;case"@keet-private-id/run-v3-migration-operation":return _n;case"@keet-private-id/update-identity-operation":return dc;case"@keet-private-id/counters":return oc;case"@keet-private-id/stats":return nc;case"@keet-private-id/add-entropy-operation":return cc;case"@keet-private-id/pending-invitation-identity":return rc;case"@keet-private-id/pending-invitation":return ic;case"@keet-private-id/resolve-pending-invitation-operation":return sc;case"@keet-private-id/add-pending-invitation-operation":return lc;case"@keet-private-id/remove-pending-invitation-operation":return mc;case"@keet-private-id/identity-swap":return yc;case"@keet-private-id/identity-swap-v2":return xc;case"@keet-private-id/room-status":return bc;case"@keet-private-id/room":return Kc;case"@keet-private-id/add-room-operation":return wc;case"@keet-private-id/remove-room-operation":return Tc;case"@keet-private-id/update-room-status-operation":return Sc;case"@keet-private-id/contact-status":return Ic;case"@keet-private-id/contact-record":return Fc;case"@keet-private-id/add-contact-operation":return Vc;case"@keet-private-id/update-contact-status-operation":return Dc;case"@keet-private-id/remove-contact-operation":return jc;case"@keet-private-id/activate-contact-room-operation":return Bc;case"@keet-private-id/contact-request-status":return zc;case"@keet-private-id/contact-request-body":return Uc;case"@keet-private-id/contact-request":return Wc;case"@keet-private-id/contact-request-record":return Zc;case"@keet-private-id/add-contact-request-operation":return _c;case"@keet-private-id/update-contact-request-status-operation":return or;case"@keet-private-id/profile-discovery-record-v1":return nr;case"@keet-private-id/profile-discovery-record":return cr;case"@keet-private-id/unreads":return rr;case"@keet-private-id/add-unreads-key-operation":return ir;case"@keet-private-id/remove-unreads-key-operation":return sr;case"@keet-private-id/settings":return pr;case"@keet-private-id/user-settings-key":return lr;case"@keet-private-id/update-settings-operation":return yr;case"@local/background-sync-room":return xr;case"@local/stats":return br;case"@local/migration-status":return vr;case"@local/v3-private-profile-migration":return kr;case"@local/v3-room-migration":return wr;case"@local/room-migration-stats":return Pr;case"@local/room-migration":return Rr;case"@local/identity-status":return Ar;case"@local/identity-swap":return Sr;case"@local/identity-record":return qr;case"@local/tasks":return Vr;case"@local/room-keys":return Hr;case"@local/join-room-invitation-task":return Lr;case"@local/join-room-response-task":return jr;case"@local/fast-forward-to":return Er;case"@local/add-room-fields":return Br;case"@local/join-room-keys-task":return Or;case"@local/create-room-task":return Ur;case"@local/leave-room-task":return Jr;case"@local/clear-room-task":return Wr;case"@local/restore-identity-task":return Gr;case"@local/send-contact-request-task":return Xr;case"@local/migrate-v2-room-task":return Yr;case"@local/task":return tt;case"@local/shared-invitation":return at;case"@local/room-status":return st;case"@local/room-timestamps":return pt;case"@local/room":return Tt;case"@local/room-preferences":return At;case"@local/room-metadata":return St;case"@local/writer":return It;case"@local/writer-append":return Mt;case"@local/member":return qt;case"@local/device":return Vt;case"@local/file":return Dt;case"@local/debug-flag":return Lt;case"@local/debug":return Et;case"@local/hyperdht-record":return zt;case"@local/unread":return Ot;case"@local/error-record-details":return Nt;case"@local/error-record":return Jt;case"@local/keet-state":return Gt;case"@local/file-stats":return Qt;case"@api/request-header":return Xt;case"@api/response-header":return Yt;case"@api/subscription-request-header":return Zt;case"@api/subscription-response-header":return $t;case"@api/boot-request":return ei;case"@api/boot-response":return oi;case"@api/self-destruct-request":return ci;case"@api/core/have":return ri;case"@api/core/create-room-request":return si;case"@api/core/create-room-response":return ui;case"@api/core/activate-room-request":return fi;case"@api/core/deactivate-room-request":return yi;case"@api/core/leave-room-request":return bi;case"@api/core/leave-room-response":return gi;case"@api/core/update-room-config-request":return hi;case"@api/core/update-room-settings-request":return Ti;case"@api/core/update-room-status-request":return Si;case"@api/core/add-chat-message-request":return Fi;case"@api/core/add-chat-message-response":return Ci;case"@api/core/edit-chat-message-request":return Di;case"@api/core/edit-chat-message-response":return ji;case"@api/core/remove-chat-message-request":return Bi;case"@api/core/remove-chat-message-response":return Oi;case"@api/core/add-chat-reaction-request":return Ui;case"@api/core/add-chat-reaction-response":return Wi;case"@api/core/remove-chat-reaction-request":return Qi;case"@api/core/remove-chat-reaction-response":return Yi;case"@api/core/want-lobby":return Zi;case"@api/core/unwant-lobby":return $i;case"@api/core/want-room-info":return ea;case"@api/core/want-chat":return da;case"@api/core/unwant-chat":return oa;case"@api/core/want-members":return na;case"@api/core/unwant-members":return ca;case"@api/core/lobby-record":return ra;case"@api/core/lobby-record-change-type":return ia;case"@api/core/lobby":return sa;case"@api/core/lobby-room":return pa;case"@api/core/room-role":return fa;case"@api/core/room-info":return ba;case"@api/core/room-info-status":return ga;case"@api/core/room-info-digest":return Ka;case"@api/core/room-info-config":return wa;case"@api/core/room-info-role":return Ta;case"@api/core/room-info-last-message":return Ra;case"@api/core/member":return Sa;case"@api/core/device":return Ma;case"@api/core/member-list-add":return Fa;case"@api/core/member-list-remove":return qa;case"@api/core/chat-reset":return Va;case"@api/core/message-timestamps":return Ha;case"@api/core/message":return Ba;case"@api/core/message-info":return Na;case"@api/core/message-info-chat":return Ja;case"@api/core/message-info-member":return Ga;case"@api/core/message-info-role":return Ya;case"@api/core/message-info-reactions":return $a;case"@api/core/reactions":return es;case"@api/core/want-pairing":return ds;case"@api/core/unwant-pairing":return os;case"@api/core/pending-invitations":return cs;case"@api/core/join-request":return ts;case"@api/core/join-requests":return as;case"@api/core/pairing":return us;case"@api/core/start-pairing-request":return fs;case"@api/core/start-pairing-response":return ys;case"@api/core/invitation-permissions":return xs;case"@api/core/create-room-invitation-request":return gs;case"@api/core/create-room-invitation-response":return Ks;case"@api/core/create-identity-invitation-request":return ws;case"@api/core/create-identity-invitation-response":return Ts;case"@api/core/accept-join-request-request":return Ss;case"@api/core/accept-join-request-response":return Ms;case"@api/core/reject-join-request-request":return Cs;case"@api/core/reject-join-request-response":return Hs;case"@api/core/stop-pairing-request":return Ls;case"@api/core/stop-pairing-response":return Es;case"@api/core/update-profile-request":return zs;case"@api/core/want-identity":return Os;case"@api/core/unwant-identity":return Ns;case"@api/core/identity-status":return Us;case"@api/core/identity":return Gs;case"@api/core/identity-member":return Qs;case"@api/core/identity-device":return Xs;case"@api/debug/enable-request":return Zs;case"@api/debug/enable-response":return _s;case"@api/debug/disable-request":return dp;case"@api/debug/disable-response":return np;case"@keet/member-label-type":return rp;case"@keet/member-label":return tp;case"@keet/add-member-label-operation":return ap;case"@keet/member-label-summary":return sp;case"@keet/member-label-digest":return up;case"@keet/move-indexer-operation":return fp;case"@keet/location-shared-event":return mp;case"@keet/start-call":return bp;case"@keet/join-call":return kp;case"@keet/leave-call":return hp;case"@keet/end-call":return Pp;case"@keet/add-call-stream":return Rp;case"@keet/remove-call-stream":return Sp;case"@keet/call-record":return Ip;case"@keet/call-member-record":return Mp;case"@keet/call-device-record":return Fp;case"@keet/call-stream-record":return qp;case"@local/active-call":return Cp;case"@local/file-gc-info":return Vp;case"@keet/build-type":return Dp;case"@keet/test-crash-operation":return jp;case"@keet/test-dispatch-error-operation":return Bp;case"@local/environment-record":return zp;case"@keet-private-id/shorten-device-attestation-operation":return Np;case"@local/ota-actions":return Up;case"@local/device-attestation":return Jp;case"@keet/call-device-heartbeat":return Gp;case"@keet/remove-call-device":return Xp;case"@local/chat-labels":return $p;case"@keet/start-call-recording":return eu;case"@keet/stop-call-recording":return ou;case"@local/settings":return nu;case"@local/hyperswarm-record":return cu;case"@keet/dismiss-chat-reports-operation":return tu;case"@keet/update-typing-indicator-operation":return au;case"@keet/typing-indicator":return su;case"@keet-private-id/update-contact-alias-operation":return uu;case"@keet/call-stats":return lu;case"@keet/call-stream-input":return fu;case"@keet/update-call-stream":return yu;case"@keet/call-stream-status-record":return xu;case"@keet/room-keys-v2":return bu;case"@keet/blob-pointer-v2":return vu;case"@keet/blob":return gu;case"@keet/autobee-migration":return ku;case"@keet/autobee-migration-operation":return hu;case"@keet/readonly-room-invitation-v2":return wu;case"@keet/admin-last-seen":return Tu;case"@keet/blob-record":return Ru;case"@keet-private-id/room-v2":return Mu;case"@keet-private-id/add-room-operation-v2":return qu;case"@local/room-keys/v2":return Cu;case"@local/room-update":return Vu;case"@local/view-head":return Hu;case"@local/autobee-migration":return Du;case"@keet-private-id/pending-invitation-response":return Lu;case"@keet-private-id/resolve-pending-invitation-operation-v2":return Eu;case"@local/pending-recovery":return zu;case"@keet/claim-admin-devices-operation":return Nu;case"@keet/remove-file-preview-operation":return Ju;case"@keet/add-link-preview-operation":return Qu;case"@keet/remove-link-preview-operation":return Yu;default:throw new Error("Encoder not found "+e)}}function wl(e,o=17){const n=hl(e);return{preencode(e,c){d=o,n.preencode(e,c)},encode(e,c){d=o,n.encode(e,c)},decode:e=>(d=o,n.decode(e))}}const Pl=wl;module.exports={resolveStruct:Pl,getStruct:wl,getEnum:function(e){switch(e){case"@keet/room-type":return z;case"@keet/room-supported-language":return X;case"@keet/display-type":return Qo;case"@keet/system-settings-keys":return Rn;case"@keet/label-type":return Vn;case"@keet-private-id/user-settings-key":return ur;case"@local/tasks":return Cr;case"@local/keet-state":return Wt;case"@api/core/lobby-record-change-type":return ta;case"@keet/member-label-type":return cp;case"@keet/build-type":return Hp;default:throw new Error("Enum not found "+e)}},getEncoding:hl,encode:function(o,n,c=17){return d=c,e.encode(hl(o),n)},decode:function(o,n,c=17){return d=c,e.decode(hl(o),n)},setVersion:function(e){d=e},version:d};
@holepunchto/keet-core/schema/spec/config/hyperconf/index.js +1 -1
……@@ -1 +1 @@
1const o=require("../hyperschema"),e=require("hyperconf/runtime"),n=o.getEncoding("@config/keet-config"),A=U(n,e.b4a.from("CA4HIwEDBBUAC/1IBD8Bwdf7MOoNiStwh63v4euvhB1sw4cMcwo40mS9JJ/f/7ABQhRuwr3PX8TvUmi1ybxJTO7ToKjLiyn/ap0g7YbbLJLkVobzZEaSwMoXDf2jR2df2WqVskOkG+QlPuL1XDxSUwPNk2Sd+XmE6wXbzAErGnCEO8wASM5KT3vuT/gihUsC09MeR6o2SxeeKfOvILau/u2lPAxfiw1reo00DWfQyJnA2z96XG0uEWnh1UFTqConLdHUGrD2y8DDVF2e+dwU7xMQQ3QXuEqwUVU1LP/VUNeZloucwf7WZHNA1+s2TGmoY5wWCYAuNsdgE+ws43F7d8NzkFsydXQ8wb6OAqfTBL/NWkoJL8z7HUKWDwHjCRkZHLkjN+mYhbbd4ckqW0zgDhKIlLDCpyuB35aR2dHQcs514Hk8KCje32iAKtYVGZPDNgfp3uq3HlcTcNJlTk9UwWdZ/mv2bPvhD+a0zWsMNkwFs5ZzFvJ5l5RjJa7PIYUs2mLSQKjS0iT7iqlxgjH4A7cqnXXUTgD09mPjDx6+/Y/GgiRq+/PF8/mb/Lg223je7d7B/oJzQVrzKppRFrbFmJMvbLqLafulJqv5Q4YhhY/9KNMz8WfUPyGjujNzDTmdtJhn6HHk1R0kvcnoycdpOUD5c3To3MVEF/BMEyM+3adgOZa0oKY1yBns13oo1LTw2pzobtxhPYPaPZSYm0RgJE6WAkTXA8bvvtTZOXIvECOYiGXMQdX6AnMfYyQIeV4TxGixlh3o2gJKUPVRMGUBUKvU6HSv73DeK7gnGDAfru5VFlnyuKEhvVdQKs7M1gzRLBE1WBwb7FYhvvdbgaOCAQCe8iJ6Pq7EkUNH3nE3o50p3CT1KOBR8T0JfMH10hK7NkF7l5RTqU1CljhC4d7JFWAR2fQUg1CULAXcaFKh+VYR8FE8L7ymCZoxxbUMVfHzSwwK+K7I7Ioahi5ojYqGhUIRTeMvi020VLFoRt3VatWGz08y9HeG9JqWL69/pRXt04Xp3QYKegSilqkFMzU5nVDzOv3I7/Vc8PzFw+CVpp4fe/AifmnbnwWclXYAEnwQv6mrobso8iZe4hSOZtDNFfgtuuB20AtIS3ftA6A6W8a3MRv7mRubH2UKe3GHEuJpqGPfrvlgXpkem21PUqpQj6polil9/sdY6nBewlhwOe4zNyjOJbpPSARt9unzvHG9fp7/nBoK17ZcZ9jYX09F4lRQfjkhVSSZys7KJr5TKj8DY3ELBNx9yBd4NxK1AQMjT4LcQfISezhSJwN015OfiwoIRsgG30FHjzwEape8KJQgwDxYsGANLEuVFgxEyUyA65GJ7M9oaCgKWATaz+bTfe+3P2cSwNs5f1F5IWhdHWxIFX8AASxk6bqnUpUYk3xUFWfLKg2jcSOZN6uc0ahcNywYs5byBfHslhGKAZ0aAr6nUnRdR7aoxWKso8tl1rp2oWQfyDv9gwMDAeaJ/dz5HDyyraW3tTR3TeM/wjAo+NjqAbi0XZ3U7+NzGyZkT3ealPYVuR7bcvqn8B1hA2TsVrb0nc/8iaCpz/BY/Tsl6c9vffFkC7V6zsehJO/EraKAWNN6N9El8FwsH3aQV7ESpLYciJqI47nF6+hwRgEyOeHwe7wDmR7yU76Oge/bjE0AOGdyRHceOk9E1T/Ic4tZIwEsMwWVCexPgytUkoKHTJG/hwfnwG6wJAIIxCZ5JUfgl8hIYz2sSQDnrk5CJyRjnd98HqeZV1JksVGapUV7OhqI/EHNMsHoUk1H77PtNlVTcr0G1kQclr7311Chqx5zopif2bigQy+A/upH8jAIEr6y1pOITzJ+0GXCdJ7X5HMtOQXhYK7c7jE3VMDXdKoL+R+jdmcD6ugMiZKwu6xpQ8P6l7QlBymgUeiTINdYX/bWuEltKCzEU/zGhpgzLDHrOZ8ydDekJzNJKpfgUM5Nvq5w+7oh6Rzotk8NxoLADdHMFUNZk20+55YbhAgS5CwFPKHkAkzSMshSsPlr+kenLjvJxgJwFFFBapyDd5MGFu0sm5yqd2qrPGb1O5zyV2VoVYeqqR0uQRJZcIC9wUm6goPHWTxM+EQ0pe+6hHvG6uZfBEZOXG9ShhYjwBl2L97P7b0As86hylbZ2aV7pKRObXFUzC5GJAUG9Fnn5WJTfk/aCnsfj8MFliNC1bDkBjUrdgVPgyxC0ckXZCTgWG9h2O/AJ8g7stwgS8o/qRLQF4meWugoBnV91q/5Y5uTl27MBVbvNflJ3DQjPAAuUUAcrMhYoshh4AqhpScP62j3ZgZZ39KV5r1jssAef3P9400gylnpZRKOZxp+0CyBxpiLE8oc4WhNaX8Fb0vu91zAcBvNGRXeUEthMWIoYuCtv3yg2zARjnwe278yL8beHjLMRgia06WyUT5PmSE6tynRJto5ovQBILMu99stqRcHJJcEwRulAOJQ/oUQntH8Pyji0s83iED4XJCG0G9vLLZjDvGR/hwsTIJ9NXfU/y5/mrqcsodOWKXR2JvF4YaYp/BnNOSEvQJLqBPqFnx7OLl3jpP4BvHW8TVdn6iT4WzWMGVj0gHK01Ao6wJXmyAv57ZJ2l8tfQ2MZSR1FhVL8/iF6FFJnEGjTD+ndk7/+CopqOuLovpWn0IRuLCh2NeIEODfxeMkWbyMX3OvTT+aeCEBzyWoHGWLqPMhjXEwrYJD8EqaJLzUbzAsncqVWrOsFaU=","base64")),w=o.getEncoding("@config/keet-config"),J=U(w,e.b4a.from("DQ4fIwEDBBIAIwMEFQAL/QgCPwHBaBNp4Ca499IsQ9N/sE191PVLB1HfRWvFkxTnQtDrC/wbyNxepDcG9pgKVd9SO5hSSQu4rYjwtkeLW1UKXj04nN32rbtJ493XMaxv+sfNd394HyTwbs6DSjiNrm1hwIugA4ZrxPAnQ2TeVPJrSbjdGZfFuHib+GEd2f8ozW1j4HYIFWHEIwUCjBKGS6gsVHO/UDMqOmq1dA+UpMHyfRxQcY6eV+9e3lLaiI4zF57xmOpjvxriBWSKMtklRFUhOouWxATnsNh1OwidaKG82XFI2jbfsPcU4zuNFmJOHnaGw+rVNNGZJrDt/55MLPi/xESUtxgQin3Ajlc2obBQwi1n3PhENTAOA0SEQZbi6C9JTUIR9diS2G9ZkeBjNG81xTpn/Ufpu0Vda3E3sunmXtLNS43XdHck3yFMePGsWpMeaG0tQASo0VsroQmgbC6xcWZ/2xWmzAg0KiXmbO6C4s0oCuZaqyfg4QnOYYQaRfUjkxBbrnao92k4BHDlbWFGvtklopt5YPqtPbUJ7HwGlwfJI8/JMAjRtpfbvjN4AjhHYZUxfucxiJOnza5m31qwnj3yLEJhUiGMdPpuH/TDofvpKm9S7QABLGTpuqdSlRiTfFQVZ8sqDaNxI5k3q5zRqFw3LBizlvIF8eyWEYoBnRoCvqdSdF1HtqjFYqyjy2XWunahZB/IO0MDAeaJ/dz5HDyyraW3tTR3TeM/wjAo+NjqAbi0XZ3U7+NzAeOkjQFpOge9PEvU62JJ18yGq8vr98BQQP45MqyqD+M9IQHPJagcZYuo8yGNcTCtgkPwSpokvNRvMCydypVas6wVpQ==","base64"));function U(o,e){return o.decode({start:0,end:e.byteLength,buffer:e})}module.exports={production:A,development:J,productionEncoding:n,developmentEncoding:w};
1const n=require("../hyperschema"),o=require("hyperconf/runtime"),d=n.getEncoding("@config/keet-config"),w=B(d,o.b4a.from("CA4HIwEDBBYCC/1oBD8Bwdf7MOoNiStwh63v4euvhB1sw4cMcwo40mS9JJ/f/7ABQhRuwr3PX8TvUmi1ybxJTO7ToKjLiyn/ap0g7YbbLJLkVobzZEaSwMoXDf2jR2df2WqVskOkG+QlPuL1XDxSUwPNk2Sd+XmE6wXbzAErGnCEO8wASM5KT3vuT/gihUsC09MeR6o2SxeeKfOvILau/u2lPAxfiw1reo00DWfQyJnA2z96XG0uEWnh1UFTqConLdHUGrD2y8DDVF2e+dwU7xMRQ3QXuEqwUVU1LP/VUNeZloucwf7WZHNA1+s2TGmoY5wWCYAuNsdgE+ws43F7d8NzkFsydXQ8wb6OAqfTBL/NWkoJL8z7HUKWDwHjCRkZHLkjN+mYhbbd4ckqW0zgDhKIlLDCpyuB35aR2dHQcs514Hk8KCje32iAKtYVGZPDNgfp3uq3HlcTcNJlTk9UwWdZ/mv2bPvhD+a0zWsMNkwFs5ZzFvJ5l5RjJa7PIYUs2mLSQKjS0iT7iqlxgjH4A7cqnXXUTgD09mPjDx6+/Y/GgiRq+/PF8/mb/Lg223je7d7B/oJzQVrzKppRFrbFmJMvbLqLafulJqv5Q4YhhY/9KNMz8WfUPyGjujNzDTmdtJhn6HHk1R0kvcnoycdpOUD5c3To3MVEF/BMEyM+3adgOZa0oKY1yBns13oo1LTw2pzobtxhPYPaPZSYm0RgJE6WAkTXA8bvvtTZOXIvECOYiGXMQdX6AnMfYyQIeV4TxGixlh3o2gJKUPVRMGUBUKvU6HSv73DeK7gnGDAfru5VFlnyuKEhvVdQKs7M1gzRLBE1WBwb7FYhvvdbgaOCAQCe8iJ6Pq7EkUNH3nE3o50p3CT1KOBR8T0JfMH10hK7NkF7l5RTqU1CljhC4d7JFWAR2fQUg1CULAXcaFKh+VYR8FE8L7ymCZoxxbUMVfHzSwwpw7IGJSyaICtfiBtVKz+iomn8ML8fnBmTkyoynqWpYwr4rsjsihqGLmiNioaFQhFN4y+LTbRUsWhG3dVq1YbPTzL0d4b0mpYvr3+lFe3ThendBgp6BKKWqQUzNTmdUPM6/cjv9Vzw/MXD4JWmnh978CJ+adufBZyVdgASfBC/qauhuyjyJl7iFI5m0M0V+C264HbQC0hLd+0DoDpbxrcxG/uZG5sfZQp7cYcS4mmoY9+u+WBemR6bbU9SqlCPqmiWKX3+x1jqcF7CWHA57jM3KM4luk9IBG326fO8cb1+nv+cGgrXtlxn2NhfT0XiVFB+OSFVJJnKzsomvlMqPwNjcQsE3H3IF3g3ErUBAyNPgtxB8hJ7OFInA3TXk5+LCghGyAbfQUePPARql7wolCDAPFiwYA0sS5UWDETJTIDrkYnsz2hoKApYBNrP5tN977c/ZxLA2zl/UXkhaF0dbEgVfwABLGTpuqdSlRiTfFQVZ8sqDaNxI5k3q5zRqFw3LBizlvIF8eyWEYoBnRoCvqdSdF1HtqjFYqyjy2XWunahZB/IO/2DAwMB5on93PkcPLKtpbe1NHdN4z/CMCj42OoBuLRdndTv43MbJmRPd5qU9hW5Htty+qfwHWEDZOxWtvSdz/yJoKnP8Fj9OyXpz2998WQLtXrOx6Ek78StooBY03o30SXwXCwfdpBXsRKkthyImojjucXr6HBGATI54fB7vAOZHvJTvo6B79uMTQA4Z3JEdx46T0TVP8hzi1kjASwzBZUJ7E+DK1SSgodMkb+HB+fAbrAkAgjEJnklR+CXyEhjPaxJAOeuTkInJGOd33wep5lXUmSxUZqlRXs6Goj8Qc0ywehSTUfvs+02VVNyvQbWRByWvvfXUKGrHnOimJ/ZuKBDL4D+6kfyMAgSvrLWk4hPMn7QZcJ0ntfkcy05BeFgrtzuMTdUwNd0qgv5H6N2ZwPq6AyJkrC7rGlDw/qXtCUHKaBR6JMg11hf9ta4SW0oLMRT/MaGmDMsMes5nzJ0N6QnM0kql+BQzk2+rnD7uiHpHOi2Tw3GgsAN0cwVQ1mTbT7nlhuECBLkLAU8oeQCTNIyyFKw+Wv6R6cuO8nGAnAUUUFqnIN3kwYW7SybnKp3aqs8ZvU7nPJXZWhVh6qpHS5BEllwgL3BSbqCg8dZPEz4RDSl77qEe8bq5l8ERk5cb1KGFiPAGXYv3s/tvQCzzqHKVtnZpXukpE5tcVTMLkYkBQb0WeflYlN+T9oKex+PwwWWI0LVsOQGNSt2BU+DLELRyRdkJOBYb2HY78AnyDuy3CBLyj+pEtAXiZ5a6CgGdX3Wr/ljm5OXbswFVu81+UncNCM8AC5RQBysyFiiyGHgCqGlJw/raPdmBlnf0pXmvWOywB5/c/3jTSDKWellEo5nGn7QLIHGmIsTyhzhaE1pfwVvS+73XMBwG80ZFd5QS2ExYihi4K2/fKDbMBGOfB7bvzIvxt4eMsxGCJrTpbJRPk+ZITq3KdEm2jmi9AEgsy732y2pFwcklwTBG6UA4lD+hRCe0fw/KOLSzzeIQPhckIbQb28stmMO8ZH+HCxMgn01d9T/Ln+aupyyh05YpdHYm8Xhhpin8Gc05IS9AkuoE+oWfHs4uXeOk/gG8dbxNV2fqJPhbNYwZWPSAcrTUCjrAlebIC/ntknaXy19DYxlJHUWFUvz+IXoUUmcQaNMP6d2Tv/4Kimo64ui+lafQhG4sKHY14gQ4N/F4yRZvIxfc69NP5p4IQHPJagcZYuo8yGNcTCtgkPwSpokvNRvMCydypVas6wVpQ==","base64")),e=n.getEncoding("@config/keet-config"),y=B(e,o.b4a.from("DQ4fIwEDBBIAIwMEFQAL/QgCPwHBaBNp4Ca499IsQ9N/sE191PVLB1HfRWvFkxTnQtDrC/wbyNxepDcG9pgKVd9SO5hSSQu4rYjwtkeLW1UKXj04nN32rbtJ493XMaxv+sfNd394HyTwbs6DSjiNrm1hwIugA4ZrxPAnQ2TeVPJrSbjdGZfFuHib+GEd2f8ozW1j4HYIFWHEIwUCjBKGS6gsVHO/UDMqOmq1dA+UpMHyfRxQcY6eV+9e3lLaiI4zF57xmOpjvxriBWSKMtklRFUhOouWxATnsNh1OwidaKG82XFI2jbfsPcU4zuNFmJOHnaGw+rVNNGZJrDt/55MLPi/xESUtxgQin3Ajlc2obBQwi1n3PhENTAOA0SEQZbi6C9JTUIR9diS2G9ZkeBjNG81xTpn/Ufpu0Vda3E3sunmXtLNS43XdHck3yFMePGsWpMeaG0tQASo0VsroQmgbC6xcWZ/2xWmzAg0KiXmbO6C4s0oCuZaqyfg4QnOYYQaRfUjkxBbrnao92k4BHDlbWFGvtklopt5YPqtPbUJ7HwGlwfJI8/JMAjRtpfbvjN4AjhHYZUxfucxiJOnza5m31qwnj3yLEJhUiGMdPpuH/TDofvpKm9S7QABLGTpuqdSlRiTfFQVZ8sqDaNxI5k3q5zRqFw3LBizlvIF8eyWEYoBnRoCvqdSdF1HtqjFYqyjy2XWunahZB/IO0MDAeaJ/dz5HDyyraW3tTR3TeM/wjAo+NjqAbi0XZ3U7+NzAeOkjQFpOge9PEvU62JJ18yGq8vr98BQQP45MqyqD+M9IQHPJagcZYuo8yGNcTCtgkPwSpokvNRvMCydypVas6wVpQ==","base64"));function B(n,o){return n.decode({start:0,end:o.byteLength,buffer:o})}module.exports={production:w,development:y,productionEncoding:d,developmentEncoding:e};
@holepunchto/keet-core/schema/spec/contract/hyperdb/messages.js +1 -1
……@@ -1 +1 @@
1const{c:e}=require("hyperschema/runtime");let d=29;const o={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.length)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.length)},decode:d=>({key:e.fixed32.decode(d),length:e.uint.decode(d)})},n={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.seq)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.seq)},decode:d=>({key:e.fixed32.decode(d),seq:e.uint.decode(d)})},c={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.secretKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.secretKey)},decode:d=>({publicKey:e.fixed32.decode(d),secretKey:e.fixed32.decode(d)})},t={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed64.preencode(d,o.secretKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed64.encode(d,o.secretKey)},decode:d=>({publicKey:e.fixed32.decode(d),secretKey:e.fixed64.decode(d)})},r={preencode(n,c){e.fixed32.preencode(n,c.key),n.end++,c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const t=(c.encryptionKey?1:0)|(c.fastForwardTo?2:0)|(d>=27&&c.bootFrom?4:0);e.fixed32.encode(n,c.key),e.uint.encode(n,t),c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),t=e.uint.decode(n);return{key:c,encryptionKey:1&t?e.buffer.decode(n):null,fastForwardTo:2&t?e.fixed32.decode(n):null,bootFrom:d>=27&&4&t?o.decode(n):null}}},i={preencode(d,o){e.uint.preencode(d,o.timestamp)},encode(d,o){e.uint.encode(d,o.timestamp)},decode:d=>({timestamp:e.uint.decode(d)})},a={preencode(d,o){e.uint.preencode(d,o.blockOffset),e.uint.preencode(d,o.blockLength),e.uint.preencode(d,o.byteOffset),e.uint.preencode(d,o.byteLength)},encode(d,o){e.uint.encode(d,o.blockOffset),e.uint.encode(d,o.blockLength),e.uint.encode(d,o.byteOffset),e.uint.encode(d,o.byteLength)},decode:d=>({blockOffset:e.uint.decode(d),blockLength:e.uint.decode(d),byteOffset:e.uint.decode(d),byteLength:e.uint.decode(d)})},s={preencode(d,o){e.uint.preencode(d,o.width),e.uint.preencode(d,o.height)},encode(d,o){e.uint.encode(d,o.width),e.uint.encode(d,o.height)},decode:d=>({width:e.uint.decode(d),height:e.uint.decode(d)})},p=e.frame(s),u={preencode(d,o){d.end++,o.name&&e.string.preencode(d,o.name),o.mimetype&&e.string.preencode(d,o.mimetype),o.dimensions&&p.preencode(d,o.dimensions),o.userdata&&e.buffer.preencode(d,o.userdata),o.duration&&e.uint.preencode(d,o.duration)},encode(d,o){const n=(o.name?1:0)|(o.mimetype?2:0)|(o.dimensions?4:0)|(o.userdata?8:0)|(o.duration?16:0)|(o.isPreview?32:0);e.uint.encode(d,n),o.name&&e.string.encode(d,o.name),o.mimetype&&e.string.encode(d,o.mimetype),o.dimensions&&p.encode(d,o.dimensions),o.userdata&&e.buffer.encode(d,o.userdata),o.duration&&e.uint.encode(d,o.duration)},decode(d){const o=e.uint.decode(d);return{name:1&o?e.string.decode(d):null,mimetype:2&o?e.string.decode(d):null,dimensions:4&o?p.decode(d):null,userdata:8&o?e.buffer.decode(d):null,duration:16&o?e.uint.decode(d):0,isPreview:!!(32&o)}}},l={preencode(d,o){e.fixed32.preencode(d,o.key),e.string.preencode(d,o.path),e.uint.preencode(d,o.version),e.uint.preencode(d,o.size)},encode(d,o){e.fixed32.encode(d,o.key),e.string.encode(d,o.path),e.uint.encode(d,o.version),e.uint.encode(d,o.size)},decode:d=>({key:e.fixed32.decode(d),path:e.string.decode(d),version:e.uint.decode(d),size:e.uint.decode(d)})},f={preencode(d,o){e.fixed32.preencode(d,o.key),a.preencode(d,o.blob)},encode(d,o){e.fixed32.encode(d,o.key),a.encode(d,o.blob)},decode:d=>({key:e.fixed32.decode(d),blob:a.decode(d)})},m=e.frame(f),y=e.frame(l),b={preencode(o,n){o.end++,n.inlined&&e.buffer.preencode(o,n.inlined),n.blob&&a.preencode(o,n.blob),n.externalBlob&&m.preencode(o,n.externalBlob),n.externalDrive&&y.preencode(o,n.externalDrive),d>=27&&n.bee&&fr.preencode(o,n.bee)},encode(o,n){const c=(n.inlined?1:0)|(n.blob?2:0)|(n.externalBlob?4:0)|(n.externalDrive?8:0)|(d>=27&&n.bee?16:0);e.uint.encode(o,c),n.inlined&&e.buffer.encode(o,n.inlined),n.blob&&a.encode(o,n.blob),n.externalBlob&&m.encode(o,n.externalBlob),n.externalDrive&&y.encode(o,n.externalDrive),d>=27&&n.bee&&fr.encode(o,n.bee)},decode(o){const n=e.uint.decode(o);return{inlined:1&n?e.buffer.decode(o):null,blob:2&n?a.decode(o):null,externalBlob:4&n?m.decode(o):null,externalDrive:8&n?y.decode(o):null,bee:d>=27&&16&n?fr.decode(o):null}}},x=e.frame(b),k=e.frame(u),v={preencode(d,o){x.preencode(d,o.pointer),d.end++,o.metadata&&k.preencode(d,o.metadata),o.preview&&Gi.preencode(d,o.preview),o.hash&&e.fixed32.preencode(d,o.hash)},encode(d,o){const n=(o.metadata?1:0)|(o.preview?2:0)|(o.hash?4:0);x.encode(d,o.pointer),e.uint.encode(d,n),o.metadata&&k.encode(d,o.metadata),o.preview&&Gi.encode(d,o.preview),o.hash&&e.fixed32.encode(d,o.hash)},decode(d){const o=x.decode(d),n=e.uint.decode(d);return{pointer:o,metadata:1&n?k.decode(d):null,preview:2&n?Gi.decode(d):null,hash:4&n?e.fixed32.decode(d):null}}},g=e.frame(v),h=g,K=g,w={preencode(e,d){e.end++,d.small&&g.preencode(e,d.small),d.medium&&h.preencode(e,d.medium),d.large&&K.preencode(e,d.large)},encode(d,o){const n=(o.small?1:0)|(o.medium?2:0)|(o.large?4:0);e.uint.encode(d,n),o.small&&g.encode(d,o.small),o.medium&&h.encode(d,o.medium),o.large&&K.encode(d,o.large)},decode(d){const o=e.uint.decode(d);return{small:1&o?g.decode(d):null,medium:2&o?h.decode(d):null,large:4&o?K.decode(d):null}}},A={preencode(e,d){e.end++},encode(d,o){const n=o.isDeleted?1:0;e.uint.encode(d,n)},decode:d=>({isDeleted:!!(1&e.uint.decode(d))})},T=e.frame(A),S=g,P={preencode(o,c){e.uint.preencode(o,c.id),n.preencode(o,c.oplog),T.preencode(o,c.status),S.preencode(o,c.file),o.end++,d>=14&&c.version&&e.uint.preencode(o,c.version)},encode(o,c){const t=d>=14&&c.version?1:0;e.uint.encode(o,c.id),n.encode(o,c.oplog),T.encode(o,c.status),S.encode(o,c.file),e.uint.encode(o,t),d>=14&&c.version&&e.uint.encode(o,c.version)},decode(o){const c=e.uint.decode(o),t=n.decode(o),r=T.decode(o),i=S.decode(o),a=o.start<o.end?e.uint.decode(o):0;return{id:c,oplog:t,status:r,file:i,version:d>=14&&1&a?e.uint.decode(o):0}}},I={preencode(e,d){e.end++},encode(d,o){const n=(o.isActive?1:0)|(o.isIndexing?2:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isActive:!!(1&o),isIndexing:!!(2&o)}}},F={preencode(o,n){const c=(n.isAdmin?1:0)|(n.isModerator?2:0)|(n.isPending?4:0)|(n.isActive?8:0)|(n.isMuted?16:0)|(n.isBanned?32:0)|(n.isShadowBanned?64:0)|(d>=13&&n.isRemoved?128:0);e.uint.preencode(o,c)},encode(o,n){const c=(n.isAdmin?1:0)|(n.isModerator?2:0)|(n.isPending?4:0)|(n.isActive?8:0)|(n.isMuted?16:0)|(n.isBanned?32:0)|(n.isShadowBanned?64:0)|(d>=13&&n.isRemoved?128:0);e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{isAdmin:!!(1&n),isModerator:!!(2&n),isPending:!!(4&n),isActive:!!(8&n),isMuted:!!(16&n),isBanned:!!(32&n),isShadowBanned:!!(64&n),isRemoved:d>=13&&!!(128&n)}}},R={preencode(e,d){e.end++},encode(d,o){const n=(o.isMuted?1:0)|(o.isBanned?2:0)|(o.isShadowBanned?4:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isMuted:!!(1&o),isBanned:!!(2&o),isShadowBanned:!!(4&o)}}},C={preencode(d,o){e.uint.preencode(d,o.version)},encode(d,o){e.uint.encode(d,o.version)},decode:d=>({version:e.uint.decode(d)})},H={preencode(d,o){e.uint.preencode(d,o.total),e.uint.preencode(d,o.active)},encode(d,o){e.uint.encode(d,o.total),e.uint.encode(d,o.active)},decode:d=>({total:e.uint.decode(d),active:e.uint.decode(d)})},V={preencode(d,o){e.uint.preencode(d,o.total),e.uint.preencode(d,o.active),e.uint.preencode(d,o.pending)},encode(d,o){e.uint.encode(d,o.total),e.uint.encode(d,o.active),e.uint.encode(d,o.pending)},decode:d=>({total:e.uint.decode(d),active:e.uint.decode(d),pending:e.uint.decode(d)})},D={preencode(o,n){e.uint.preencode(o,n.clock),e.uint.preencode(o,n.pinned),e.uint.preencode(o,n.threads),e.uint.preencode(o,n.timestamp),o.end++,d>=15&&n.flagsClock&&e.uint.preencode(o,n.flagsClock)},encode(o,n){const c=d>=15&&n.flagsClock?1:0;e.uint.encode(o,n.clock),e.uint.encode(o,n.pinned),e.uint.encode(o,n.threads),e.uint.encode(o,n.timestamp),e.uint.encode(o,c),d>=15&&n.flagsClock&&e.uint.encode(o,n.flagsClock)},decode(o){const n=e.uint.decode(o),c=e.uint.decode(o),t=e.uint.decode(o),r=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{clock:n,pinned:c,threads:t,timestamp:r,flagsClock:d>=15&&1&i?e.uint.decode(o):0}}},M={preencode(d,o){e.uint.preencode(d,o.clock)},encode(d,o){e.uint.encode(d,o.clock)},decode:d=>({clock:e.uint.decode(d)})},L=e.frame(H),q=e.frame(V),E=e.frame(D),B=e.frame(M),z={preencode(e,o){L.preencode(e,o.devices),q.preencode(e,o.members),E.preencode(e,o.chat),B.preencode(e,o.files),e.end++,d>=26&&o.calls&&Qi.preencode(e,o.calls)},encode(o,n){const c=d>=26&&n.calls?1:0;L.encode(o,n.devices),q.encode(o,n.members),E.encode(o,n.chat),B.encode(o,n.files),e.uint.encode(o,c),d>=26&&n.calls&&Qi.encode(o,n.calls)},decode(o){const n=L.decode(o),c=q.decode(o),t=E.decode(o),r=B.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{devices:n,members:c,chat:t,files:r,calls:d>=26&&1&i?Qi.decode(o):null}}},N={Default:1,Broadcast:2,DirectMessage:3},j={preencode(e,d){e.end++},encode(d,o){if(o>3)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},O={preencode(o,n){const c=(n.roomType?1:0)|(n.isExperimental?2:0)|(n.isJoiningDisabled?4:0)|(n.isAppendingDisabled?8:0)|(n.isCallingDisabled?16:0)|(n.isMembershipEventsDisabled?32:0)|(d>=19&&n.isAttachmentsDisabled?64:0)|(d>=19&&n.isLinksDisabled?128:0)|(d>=20&&n.buildType?256:0)|(d>=23&&n.isRoomInviteHidden?512:0);e.uint.preencode(o,c),n.roomType&&j.preencode(o,n.roomType),d>=20&&n.buildType&&Bt.preencode(o,n.buildType)},encode(o,n){const c=(n.roomType?1:0)|(n.isExperimental?2:0)|(n.isJoiningDisabled?4:0)|(n.isAppendingDisabled?8:0)|(n.isCallingDisabled?16:0)|(n.isMembershipEventsDisabled?32:0)|(d>=19&&n.isAttachmentsDisabled?64:0)|(d>=19&&n.isLinksDisabled?128:0)|(d>=20&&n.buildType?256:0)|(d>=23&&n.isRoomInviteHidden?512:0);e.uint.encode(o,c),n.roomType&&j.encode(o,n.roomType),d>=20&&n.buildType&&Bt.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{roomType:1&n?j.decode(o):0,isExperimental:!!(2&n),isJoiningDisabled:!!(4&n),isAppendingDisabled:!!(8&n),isCallingDisabled:!!(16&n),isMembershipEventsDisabled:!!(32&n),isAttachmentsDisabled:d>=19&&!!(64&n),isLinksDisabled:d>=19&&!!(128&n),buildType:d>=20&&256&n?Bt.decode(o):null,isRoomInviteHidden:d>=23&&!!(512&n)}}},U=e.frame(C),J=e.frame(O),G={preencode(d,o){U.preencode(d,o.abi),J.preencode(d,o.settings),e.uint.preencode(d,o.creationTime)},encode(d,o){U.encode(d,o.abi),J.encode(d,o.settings),e.uint.encode(d,o.creationTime)},decode:d=>({abi:U.decode(d),settings:J.decode(d),creationTime:e.uint.decode(d)})},Q={preencode(d,o){e.fixed32.preencode(d,o.seed)},encode(d,o){e.fixed32.encode(d,o.seed)},decode:d=>({seed:e.fixed32.decode(d)})},W={preencode(d,o){c.preencode(d,o.mailboxKeyPair),t.preencode(d,o.discoveryKeyPair),e.fixed32.preencode(d,o.wakeupTopic),e.fixed32.preencode(d,o.swarmTopic)},encode(d,o){c.encode(d,o.mailboxKeyPair),t.encode(d,o.discoveryKeyPair),e.fixed32.encode(d,o.wakeupTopic),e.fixed32.encode(d,o.swarmTopic)},decode:d=>({mailboxKeyPair:c.decode(d),discoveryKeyPair:t.decode(d),wakeupTopic:e.fixed32.decode(d),swarmTopic:e.fixed32.decode(d)})},X=e.array(e.fixed32),Y={preencode(o,n){o.end++,n.title&&e.string.preencode(o,n.title),n.avatar&&Wi.preencode(o,n.avatar),n.description&&e.string.preencode(o,n.description),d>=11&&n.supportedLanguages&&Xi.preencode(o,n.supportedLanguages),d>=13&&n.blindPeers&&X.preencode(o,n.blindPeers)},encode(o,n){const c=(n.title?1:0)|(n.avatar?2:0)|(n.description?4:0)|(d>=11&&n.supportedLanguages?8:0)|(d>=13&&n.blindPeers?16:0);e.uint.encode(o,c),n.title&&e.string.encode(o,n.title),n.avatar&&Wi.encode(o,n.avatar),n.description&&e.string.encode(o,n.description),d>=11&&n.supportedLanguages&&Xi.encode(o,n.supportedLanguages),d>=13&&n.blindPeers&&X.encode(o,n.blindPeers)},decode(o){const n=e.uint.decode(o);return{title:1&n?e.string.decode(o):null,avatar:2&n?Wi.decode(o):null,description:4&n?e.string.decode(o):null,supportedLanguages:d>=11&&8&n?Xi.decode(o):null,blindPeers:d>=13&&16&n?X.decode(o):null}}},Z={preencode(d,o){e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.key)},decode:d=>({key:e.fixed32.decode(d)})},$=e.frame(i),_=e.frame(Z),ee={preencode(e,d){$.preencode(e,d.header),_.preencode(e,d.peer)},encode(e,d){$.encode(e,d.header),_.encode(e,d.peer)},decode:e=>({header:$.decode(e),peer:_.decode(e)})},de=$,oe={preencode(d,o){de.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){de.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:de.decode(d),key:e.fixed32.decode(d)})},ne={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.buffer.preencode(d,o.proof)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.buffer.encode(d,o.proof)},decode:d=>({memberKey:e.fixed32.decode(d),proof:e.buffer.decode(d)})},ce={preencode(d,o){e.fixed32.preencode(d,o.id),e.buffer.preencode(d,o.response)},encode(d,o){e.fixed32.encode(d,o.id),e.buffer.encode(d,o.response)},decode:d=>({id:e.fixed32.decode(d),response:e.buffer.decode(d)})},te=e.frame(I),re=e.frame(ce),ie={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.memberKey),te.preencode(d,o.status),Yi.preencode(d,o.profile),d.end++,o.invitation&&re.preencode(d,o.invitation)},encode(d,o){const n=o.invitation?1:0;e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.memberKey),te.encode(d,o.status),Yi.encode(d,o.profile),e.uint.encode(d,n),o.invitation&&re.encode(d,o.invitation)},decode:d=>({key:e.fixed32.decode(d),memberKey:e.fixed32.decode(d),status:te.decode(d),profile:Yi.decode(d),invitation:1&e.uint.decode(d)?re.decode(d):null})},ae={preencode(d,o){e.uint.preencode(d,o.timestamp),d.end++,o.mailbox&&e.fixed32.preencode(d,o.mailbox),o.displayName&&e.string.preencode(d,o.displayName),o.avatar&&Zi.preencode(d,o.avatar),o.username&&e.string.preencode(d,o.username)},encode(d,o){const n=(o.mailbox?1:0)|(o.displayName?2:0)|(o.avatar?4:0)|(o.username?8:0);e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.mailbox&&e.fixed32.encode(d,o.mailbox),o.displayName&&e.string.encode(d,o.displayName),o.avatar&&Zi.encode(d,o.avatar),o.username&&e.string.encode(d,o.username)},decode(d){const o=e.uint.decode(d),n=e.uint.decode(d);return{timestamp:o,mailbox:1&n?e.fixed32.decode(d):null,displayName:2&n?e.string.decode(d):null,avatar:4&n?Zi.decode(d):null,username:8&n?e.string.decode(d):null}}},se={preencode(o,n){o.end++,n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),n.name&&e.string.preencode(o,n.name),d>=20&&n.buildType&&Bt.preencode(o,n.buildType)},encode(o,n){const c=(n.swarmKey?1:0)|(n.name?2:0)|(n.isMobile?4:0)|(d>=20&&n.buildType?8:0);e.uint.encode(o,c),n.swarmKey&&e.fixed32.encode(o,n.swarmKey),n.name&&e.string.encode(o,n.name),d>=20&&n.buildType&&Bt.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{swarmKey:1&n?e.fixed32.decode(o):null,name:2&n?e.string.decode(o):null,isMobile:!!(4&n),buildType:d>=20&&8&n?Bt.decode(o):null}}},pe=e.frame(ae),ue={preencode(e,d){pe.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){pe.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:pe.decode(e),attestation:ne.decode(e)})},le={preencode(e,d){$i.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){$i.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:$i.decode(e),attestation:ne.decode(e)})},fe={preencode(d,o){e.fixed32.preencode(d,o.id),e.buffer.preencode(d,o.data),e.buffer.preencode(d,o.signature)},encode(d,o){e.fixed32.encode(d,o.id),e.buffer.encode(d,o.data),e.buffer.encode(d,o.signature)},decode:d=>({id:e.fixed32.decode(d),data:e.buffer.decode(d),signature:e.buffer.decode(d)})},me={preencode(d,o){e.fixed32.preencode(d,o.devicePublicKey)},encode(d,o){e.fixed32.encode(d,o.devicePublicKey)},decode:d=>({devicePublicKey:e.fixed32.decode(d)})},ye={preencode(d,o){ne.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){ne.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({privateProfileIdentity:ne.decode(d),deviceProof:e.buffer.decode(d)})},be=e.frame(le),xe=e.frame(ue),ke=e.frame(me),ve={preencode(n,c){e.fixed32.preencode(n,c.deviceKey),t.preencode(n,c.keyPair),be.preencode(n,c.device),xe.preencode(n,c.member),n.end++,c.identity&&ke.preencode(n,c.identity),d>=27&&c.link&&o.preencode(n,c.link)},encode(n,c){const r=(c.identity?1:0)|(d>=27&&c.link?2:0);e.fixed32.encode(n,c.deviceKey),t.encode(n,c.keyPair),be.encode(n,c.device),xe.encode(n,c.member),e.uint.encode(n,r),c.identity&&ke.encode(n,c.identity),d>=27&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),r=t.decode(n),i=be.decode(n),a=xe.decode(n),s=e.uint.decode(n);return{deviceKey:c,keyPair:r,device:i,member:a,identity:1&s?ke.decode(n):null,link:d>=27&&2&s?o.decode(n):null}}},ge=e.frame(ve),he={preencode(d,o){e.fixed32.preencode(d,o.id),ge.preencode(d,o.request),e.buffer.preencode(d,o.signature)},encode(d,o){e.fixed32.encode(d,o.id),ge.encode(d,o.request),e.buffer.encode(d,o.signature)},decode:d=>({id:e.fixed32.decode(d),request:ge.decode(d),signature:e.buffer.decode(d)})},Ke=be,we=xe,Ae={preencode(e,d){Ke.preencode(e,d.device),e.end++,d.member&&we.preencode(e,d.member)},encode(d,o){const n=o.member?1:0;Ke.encode(d,o.device),e.uint.encode(d,n),o.member&&we.encode(d,o.member)},decode:d=>({device:Ke.decode(d),member:1&e.uint.decode(d)?we.decode(d):null})},Te=e.frame(he),Se=e.frame(Ae),Pe={preencode(e,d){e.end++,d.withInvitation&&Te.preencode(e,d.withInvitation),d.withMemberProof&&Se.preencode(e,d.withMemberProof)},encode(d,o){const n=(o.withInvitation?1:0)|(o.withMemberProof?2:0);e.uint.encode(d,n),o.withInvitation&&Te.encode(d,o.withInvitation),o.withMemberProof&&Se.encode(d,o.withMemberProof)},decode(d){const o=e.uint.decode(d);return{withInvitation:1&o?Te.decode(d):null,withMemberProof:2&o?Se.decode(d):null}}},Ie=e.frame(fe),Fe=e.frame(ye),Re={preencode(e,d){Ie.preencode(e,d.signedKeys),e.end++,d.identity&&Fe.preencode(e,d.identity)},encode(d,o){const n=o.identity?1:0;Ie.encode(d,o.signedKeys),e.uint.encode(d,n),o.identity&&Fe.encode(d,o.identity)},decode:d=>({signedKeys:Ie.decode(d),identity:1&e.uint.decode(d)?Fe.decode(d):null})},Ce={preencode(o,n){o.end++,n.expiration&&e.uint.preencode(o,n.expiration),d>=20&&n.buildType&&Bt.preencode(o,n.buildType)},encode(o,n){const c=(n.expiration?1:0)|(n.requiresConfirmation?2:0)|(n.canModerate?4:0)|(n.canAdmin?8:0)|(d>=20&&n.buildType?16:0);e.uint.encode(o,c),n.expiration&&e.uint.encode(o,n.expiration),d>=20&&n.buildType&&Bt.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{expiration:1&n?e.uint.decode(o):0,requiresConfirmation:!!(2&n),canModerate:!!(4&n),canAdmin:!!(8&n),buildType:d>=20&&16&n?Bt.decode(o):null}}},He=Ie,Ve=e.frame(Ce),De={preencode(d,n){e.fixed32.preencode(d,n.id),He.preencode(d,n.response),Ve.preencode(d,n.metadata),d.end++,n.anchor&&o.preencode(d,n.anchor)},encode(d,n){const c=(n.anchor?1:0)|(n.isActive?2:0);e.fixed32.encode(d,n.id),He.encode(d,n.response),Ve.encode(d,n.metadata),e.uint.encode(d,c),n.anchor&&o.encode(d,n.anchor)},decode(d){const n=e.fixed32.decode(d),c=He.decode(d),t=Ve.decode(d),r=e.uint.decode(d);return{id:n,response:c,metadata:t,anchor:1&r?o.decode(d):null,isActive:!!(2&r)}}},Me=$,Le=e.frame(De),qe={preencode(e,d){Me.preencode(e,d.header),Le.preencode(e,d.invitation)},encode(e,d){Me.encode(e,d.header),Le.encode(e,d.invitation)},decode:e=>({header:Me.decode(e),invitation:Le.decode(e)})},Ee=$,Be={preencode(d,o){Ee.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){Ee.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:Ee.decode(d),id:e.fixed32.decode(d)})},ze={preencode(d,n){e.fixed32.preencode(d,n.mailbox),e.fixed32.preencode(d,n.invitationSeed),o.preencode(d,n.anchor)},encode(d,n){e.fixed32.encode(d,n.mailbox),e.fixed32.encode(d,n.invitationSeed),o.encode(d,n.anchor)},decode:d=>({mailbox:e.fixed32.decode(d),invitationSeed:e.fixed32.decode(d),anchor:o.decode(d)})},Ne={preencode(d,n){e.fixed32.preencode(d,n.mailbox),e.fixed32.preencode(d,n.invitationSeed),o.preencode(d,n.anchor),e.fixed32.preencode(d,n.identityPublicKey)},encode(d,n){e.fixed32.encode(d,n.mailbox),e.fixed32.encode(d,n.invitationSeed),o.encode(d,n.anchor),e.fixed32.encode(d,n.identityPublicKey)},decode:d=>({mailbox:e.fixed32.decode(d),invitationSeed:e.fixed32.decode(d),anchor:o.decode(d),identityPublicKey:e.fixed32.decode(d)})},je={preencode(d,o){e.fixed32.preencode(d,o.mailbox)},encode(d,o){e.fixed32.encode(d,o.mailbox)},decode:d=>({mailbox:e.fixed32.decode(d)})},Oe=e.frame(ze),Ue=e.frame(Ne),Je=e.frame(je),Ge=e.array(e.ipv4Address),Qe={preencode(e,o){e.end++,o.room&&Oe.preencode(e,o.room),o.identity&&Ue.preencode(e,o.identity),o.contact&&Je.preencode(e,o.contact),d>=6&&o.readonly&&_i.preencode(e,o.readonly),d>=11&&o.additionalNodes&&Ge.preencode(e,o.additionalNodes),d>=20&&o.buildType&&Bt.preencode(e,o.buildType),d>=27&&o["readonly-v2"]&&ea.preencode(e,o["readonly-v2"])},encode(o,n){const c=(n.room?1:0)|(n.identity?2:0)|(n.contact?4:0)|(d>=6&&n.readonly?8:0)|(d>=11&&n.additionalNodes?16:0)|(d>=20&&n.buildType?32:0)|(d>=27&&n["readonly-v2"]?64:0);e.uint.encode(o,c),n.room&&Oe.encode(o,n.room),n.identity&&Ue.encode(o,n.identity),n.contact&&Je.encode(o,n.contact),d>=6&&n.readonly&&_i.encode(o,n.readonly),d>=11&&n.additionalNodes&&Ge.encode(o,n.additionalNodes),d>=20&&n.buildType&&Bt.encode(o,n.buildType),d>=27&&n["readonly-v2"]&&ea.encode(o,n["readonly-v2"])},decode(o){const n=e.uint.decode(o);return{room:1&n?Oe.decode(o):null,identity:2&n?Ue.decode(o):null,contact:4&n?Je.decode(o):null,readonly:d>=6&&8&n?_i.decode(o):null,additionalNodes:d>=11&&16&n?Ge.decode(o):null,buildType:d>=20&&32&n?Bt.decode(o):null,"readonly-v2":d>=27&&64&n?ea.decode(o):null}}},We=$,Xe={preencode(d,o){We.preencode(d,o.header),e.buffer.preencode(d,o.blindRequest)},encode(d,o){We.encode(d,o.header),e.buffer.encode(d,o.blindRequest)},decode:d=>({header:We.decode(d),blindRequest:e.buffer.decode(d)})},Ye=$,Ze={preencode(o,n){Ye.preencode(o,n.header),o.end++,n.profile&&da.preencode(o,n.profile),d>=24&&n.key&&e.fixed32.preencode(o,n.key)},encode(o,n){const c=(n.profile?1:0)|(d>=24&&n.key?2:0);Ye.encode(o,n.header),e.uint.encode(o,c),n.profile&&da.encode(o,n.profile),d>=24&&n.key&&e.fixed32.encode(o,n.key)},decode(o){const n=Ye.decode(o),c=e.uint.decode(o);return{header:n,profile:1&c?da.decode(o):null,key:d>=24&&2&c?e.fixed32.decode(o):null}}},$e={preencode(e,d){},encode(e,d){},decode:e=>({})},_e=$e,ed=ge,dd={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.id),ed.preencode(d,o.request)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.id),ed.encode(d,o.request)},decode:d=>({deviceKey:e.fixed32.decode(d),id:e.fixed32.decode(d),request:ed.decode(d)})},od=$,nd=Fe,cd={preencode(d,o){od.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),d.end++,o.identity&&nd.preencode(d,o.identity)},encode(d,o){const n=o.identity?1:0;od.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,n),o.identity&&nd.encode(d,o.identity)},decode:d=>({header:od.decode(d),deviceKey:e.fixed32.decode(d),identity:1&e.uint.decode(d)?nd.decode(d):null})},td=$,rd={preencode(d,o){td.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey)},encode(d,o){td.encode(d,o.header),e.fixed32.encode(d,o.deviceKey)},decode:d=>({header:td.decode(d),deviceKey:e.fixed32.decode(d)})},id=e.frame(F),ad=pe,sd={preencode(d,o){e.fixed32.preencode(d,o.key),id.preencode(d,o.status),ad.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),id.encode(d,o.status),ad.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),status:id.decode(d),profile:ad.decode(d)})},pd=id,ud=pe,ld={preencode(d,o){e.fixed32.preencode(d,o.key),pd.preencode(d,o.status),ud.preencode(d,o.profile),d.end++,o.proofs&&oa.preencode(d,o.proofs)},encode(d,o){const n=o.proofs?1:0;e.fixed32.encode(d,o.key),pd.encode(d,o.status),ud.encode(d,o.profile),e.uint.encode(d,n),o.proofs&&oa.encode(d,o.proofs)},decode:d=>({key:e.fixed32.decode(d),status:pd.decode(d),profile:ud.decode(d),proofs:1&e.uint.decode(d)?oa.decode(d):null})},fd={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++,o.profileAttestation&&e.buffer.preencode(d,o.profileAttestation),o.latestReceipt&&e.buffer.preencode(d,o.latestReceipt)},encode(d,o){const n=(o.profileAttestation?1:0)|(o.latestReceipt?2:0);e.fixed32.encode(d,o.key),e.uint.encode(d,n),o.profileAttestation&&e.buffer.encode(d,o.profileAttestation),o.latestReceipt&&e.buffer.encode(d,o.latestReceipt)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d);return{key:o,profileAttestation:1&n?e.buffer.decode(d):null,latestReceipt:2&n?e.buffer.decode(d):null}}},md=$,yd=xe,bd={preencode(e,d){md.preencode(e,d.header),yd.preencode(e,d.member)},encode(e,d){md.encode(e,d.header),yd.encode(e,d.member)},decode:e=>({header:md.decode(e),member:yd.decode(e)})},xd=$,kd=e.frame(R),vd={preencode(d,o){xd.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),kd.preencode(d,o.status)},encode(d,o){xd.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),kd.encode(d,o.status)},decode:d=>({header:xd.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:kd.decode(d)})},gd=$,hd={preencode(d,o){gd.preencode(d,o.header),e.fixed32.preencode(d,o.key),d.end++},encode(d,o){const n=(o.isModerator?1:0)|(o.isAdmin?2:0);gd.encode(d,o.header),e.fixed32.encode(d,o.key),e.uint.encode(d,n)},decode(d){const o=gd.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{header:o,key:n,isModerator:!!(1&c),isAdmin:!!(2&c)}}},Kd=$,wd={preencode(d,o){Kd.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){Kd.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:Kd.decode(d),key:e.fixed32.decode(d)})},Ad={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.mentions)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.mentions)},decode:d=>({key:e.fixed32.decode(d),mentions:e.uint.decode(d)})},Td={preencode(d,o){d.end++,o.memberKey&&e.fixed32.preencode(d,o.memberKey)},encode(d,o){const n=o.memberKey?1:0;e.uint.encode(d,n),o.memberKey&&e.fixed32.encode(d,o.memberKey)},decode:d=>({memberKey:1&e.uint.decode(d)?e.fixed32.decode(d):null})},Sd=Td,Pd={preencode(d,o){d.end++,o.from&&e.string.preencode(d,o.from),o.to&&e.string.preencode(d,o.to)},encode(d,o){const n=(o.from?1:0)|(o.to?2:0);e.uint.encode(d,n),o.from&&e.string.encode(d,o.from),o.to&&e.string.encode(d,o.to)},decode(d){const o=e.uint.decode(d);return{from:1&o?e.string.decode(d):null,to:2&o?e.string.decode(d):null}}},Id=e.frame(Td),Fd=e.frame(Sd),Rd=e.frame(Pd),Cd={preencode(o,n){const c=(n.memberJoined?1:0)|(n.memberLeft?2:0)|(n.titleChanged?4:0)|(n.callStarted?8:0)|(n.callHangup?16:0)|(n.callMissed?32:0)|(d>=3&&n.roomAvatarChanged?64:0)|(d>=3&&n.invitationCreated?128:0)|(d>=3&&n.memberRemoved?256:0)|(d>=18&&n.locationShared?512:0);e.uint.preencode(o,c),n.memberJoined&&Id.preencode(o,n.memberJoined),n.memberLeft&&Fd.preencode(o,n.memberLeft),n.titleChanged&&Rd.preencode(o,n.titleChanged),d>=3&&n.memberRemoved&&na.preencode(o,n.memberRemoved),d>=18&&n.locationShared&&ca.preencode(o,n.locationShared)},encode(o,n){const c=(n.memberJoined?1:0)|(n.memberLeft?2:0)|(n.titleChanged?4:0)|(n.callStarted?8:0)|(n.callHangup?16:0)|(n.callMissed?32:0)|(d>=3&&n.roomAvatarChanged?64:0)|(d>=3&&n.invitationCreated?128:0)|(d>=3&&n.memberRemoved?256:0)|(d>=18&&n.locationShared?512:0);e.uint.encode(o,c),n.memberJoined&&Id.encode(o,n.memberJoined),n.memberLeft&&Fd.encode(o,n.memberLeft),n.titleChanged&&Rd.encode(o,n.titleChanged),d>=3&&n.memberRemoved&&na.encode(o,n.memberRemoved),d>=18&&n.locationShared&&ca.encode(o,n.locationShared)},decode(o){const n=e.uint.decode(o);return{memberJoined:1&n?Id.decode(o):null,memberLeft:2&n?Fd.decode(o):null,titleChanged:4&n?Rd.decode(o):null,callStarted:!!(8&n),callHangup:!!(16&n),callMissed:!!(32&n),roomAvatarChanged:d>=3&&!!(64&n),invitationCreated:d>=3&&!!(128&n),memberRemoved:d>=3&&256&n?na.decode(o):null,locationShared:d>=18&&512&n?ca.decode(o):null}}},Hd={preencode(e,o){e.end++,d>=18&&o.locationShared&&ta.preencode(e,o.locationShared)},encode(o,n){const c=(n.callStarted?1:0)|(n.callHangup?2:0)|(n.callMissed?4:0)|(d>=18&&n.locationShared?8:0);e.uint.encode(o,c),d>=18&&n.locationShared&&ta.encode(o,n.locationShared)},decode(o){const n=e.uint.decode(o);return{callStarted:!!(1&n),callHangup:!!(2&n),callMissed:!!(4&n),locationShared:d>=18&&8&n?ta.decode(o):null}}},Vd={preencode(d,o){e.uint.preencode(d,o.start),e.uint.preencode(d,o.length)},encode(d,o){e.uint.encode(d,o.start),e.uint.encode(d,o.length)},decode:d=>({start:e.uint.decode(d),length:e.uint.decode(d)})},Dd=e.frame(Vd),Md={preencode(d,o){Dd.preencode(d,o.range),e.string.preencode(d,o.content)},encode(d,o){Dd.encode(d,o.range),e.string.encode(d,o.content)},decode:d=>({range:Dd.decode(d),content:e.string.decode(d)})},Ld=Dd,qd={preencode(d,o){Ld.preencode(d,o.range),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Ld.encode(d,o.range),e.fixed32.encode(d,o.memberKey)},decode:d=>({range:Ld.decode(d),memberKey:e.fixed32.decode(d)})},Ed=g,Bd=e.array(e.uint),zd={preencode(o,n){o.end++,n.title&&e.string.preencode(o,n.title),n.description&&e.string.preencode(o,n.description),n.file&&Ed.preencode(o,n.file),d>=7&&n.files&&Bd.preencode(o,n.files)},encode(o,n){const c=(n.title?1:0)|(n.description?2:0)|(n.file?4:0)|(d>=7&&n.files?8:0);e.uint.encode(o,c),n.title&&e.string.encode(o,n.title),n.description&&e.string.encode(o,n.description),n.file&&Ed.encode(o,n.file),d>=7&&n.files&&Bd.encode(o,n.files)},decode(o){const n=e.uint.decode(o);return{title:1&n?e.string.decode(o):null,description:2&n?e.string.decode(o):null,file:4&n?Ed.decode(o):null,files:d>=7&&8&n?Bd.decode(o):null}}},Nd=Dd,jd=e.frame(zd),Od={preencode(d,o){Nd.preencode(d,o.range),e.string.preencode(d,o.url),d.end++,o.preview&&jd.preencode(d,o.preview)},encode(d,o){const n=o.preview?1:0;Nd.encode(d,o.range),e.string.encode(d,o.url),e.uint.encode(d,n),o.preview&&jd.encode(d,o.preview)},decode:d=>({range:Nd.decode(d),url:e.string.decode(d),preview:1&e.uint.decode(d)?jd.decode(d):null})},Ud=e.array(e.frame(qd)),Jd=e.array(e.frame(Od)),Gd=Jd,Qd=e.array(e.frame(Vd)),Wd=Qd,Xd=Qd,Yd=e.array(e.frame(Md)),Zd=Qd,$d=Qd,_d={preencode(o,n){const c=(n.mention?1:0)|(n.httpLink?2:0)|(n.pearLink?4:0)|(n.bold?8:0)|(n.italic?16:0)|(n.code?32:0)|(n.emoji?64:0)|(n.codeBlock?128:0)|(n.strike?256:0)|(d>=11&&n.translation?512:0);e.uint.preencode(o,c),n.mention&&Ud.preencode(o,n.mention),n.httpLink&&Jd.preencode(o,n.httpLink),n.pearLink&&Gd.preencode(o,n.pearLink),n.bold&&Qd.preencode(o,n.bold),n.italic&&Wd.preencode(o,n.italic),n.code&&Xd.preencode(o,n.code),n.emoji&&Yd.preencode(o,n.emoji),n.codeBlock&&Zd.preencode(o,n.codeBlock),n.strike&&$d.preencode(o,n.strike),d>=11&&n.translation&&ra.preencode(o,n.translation)},encode(o,n){const c=(n.mention?1:0)|(n.httpLink?2:0)|(n.pearLink?4:0)|(n.bold?8:0)|(n.italic?16:0)|(n.code?32:0)|(n.emoji?64:0)|(n.codeBlock?128:0)|(n.strike?256:0)|(d>=11&&n.translation?512:0);e.uint.encode(o,c),n.mention&&Ud.encode(o,n.mention),n.httpLink&&Jd.encode(o,n.httpLink),n.pearLink&&Gd.encode(o,n.pearLink),n.bold&&Qd.encode(o,n.bold),n.italic&&Wd.encode(o,n.italic),n.code&&Xd.encode(o,n.code),n.emoji&&Yd.encode(o,n.emoji),n.codeBlock&&Zd.encode(o,n.codeBlock),n.strike&&$d.encode(o,n.strike),d>=11&&n.translation&&ra.encode(o,n.translation)},decode(o){const n=e.uint.decode(o);return{mention:1&n?Ud.decode(o):null,httpLink:2&n?Jd.decode(o):null,pearLink:4&n?Gd.decode(o):null,bold:8&n?Qd.decode(o):null,italic:16&n?Wd.decode(o):null,code:32&n?Xd.decode(o):null,emoji:64&n?Yd.decode(o):null,codeBlock:128&n?Zd.decode(o):null,strike:256&n?$d.decode(o):null,translation:d>=11&&512&n?ra.decode(o):null}}},eo=e.array(e.frame(v)),oo=e.frame(_d),no=e.frame(Hd),co={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&eo.preencode(d,o.files),o.display&&oo.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent),o.event&&no.preencode(d,o.event)},encode(o,c){const t=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(c.event?32:0)|(d>=18&&c.forwarded?64:0);e.uint.encode(o,t),c.text&&e.string.encode(o,c.text),c.files&&eo.encode(o,c.files),c.display&&oo.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent),c.event&&no.encode(o,c.event)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?eo.decode(o):null,display:4&c?oo.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,event:32&c?no.decode(o):null,forwarded:d>=18&&!!(64&c)}}},to=Bd,ro=oo,io={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&to.preencode(d,o.files),o.display&&ro.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent)},encode(o,c){const t=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(d>=18&&c.forwarded?32:0);e.uint.encode(o,t),c.text&&e.string.encode(o,c.text),c.files&&to.encode(o,c.files),c.display&&ro.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?to.decode(o):null,display:4&c?ro.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,forwarded:d>=18&&!!(32&c)}}},ao=eo,so=oo,po={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&ao.preencode(d,o.files),o.display&&so.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent)},encode(o,c){const t=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(d>=18&&c.forwarded?32:0);e.uint.encode(o,t),c.text&&e.string.encode(o,c.text),c.files&&ao.encode(o,c.files),c.display&&so.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?ao.decode(o):null,display:4&c?so.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,forwarded:d>=18&&!!(32&c)}}},uo={preencode(e,d){e.end++},encode(d,o){const n=(o.isEdited?1:0)|(o.isDeleted?2:0)|(o.isPinned?4:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isEdited:!!(1&o),isDeleted:!!(2&o),isPinned:!!(4&o)}}},lo={preencode(d,o){e.uint.preencode(d,o.thread),e.uint.preencode(d,o.index)},encode(d,o){e.uint.encode(d,o.thread),e.uint.encode(d,o.index)},decode:d=>({thread:e.uint.decode(d),index:e.uint.decode(d)})},fo=e.frame(z),mo={preencode(d,o){e.uint.preencode(d,o.id),e.uint.preencode(d,o.count),d.end++,o.parent&&n.preencode(d,o.parent),o.stats&&fo.preencode(d,o.stats)},encode(d,o){const c=(o.parent?1:0)|(o.stats?2:0);e.uint.encode(d,o.id),e.uint.encode(d,o.count),e.uint.encode(d,c),o.parent&&n.encode(d,o.parent),o.stats&&fo.encode(d,o.stats)},decode(d){const o=e.uint.decode(d),c=e.uint.decode(d),t=e.uint.decode(d);return{id:o,count:c,parent:1&t?n.decode(d):null,stats:2&t?fo.decode(d):null}}},yo=e.frame(uo),bo=e.frame(io),xo=e.frame(Cd),ko={preencode(d,o){lo.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),yo.preencode(d,o.status),o.message&&bo.preencode(d,o.message),o.event&&xo.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);lo.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),yo.encode(d,o.status),o.message&&bo.encode(d,o.message),o.event&&xo.encode(d,o.event)},decode(d){const o=lo.decode(d),c=n.decode(d),t=e.uint.decode(d),r=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:t,timestamp:r,editedAt:1&i?e.uint.decode(d):0,status:yo.decode(d),message:2&i?bo.decode(d):null,event:4&i?xo.decode(d):null}}},vo=yo,go=e.frame(po),ho=xo,Ko={preencode(d,o){lo.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),vo.preencode(d,o.status),o.message&&go.preencode(d,o.message),o.event&&ho.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);lo.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),vo.encode(d,o.status),o.message&&go.encode(d,o.message),o.event&&ho.encode(d,o.event)},decode(d){const o=lo.decode(d),c=n.decode(d),t=e.uint.decode(d),r=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:t,timestamp:r,editedAt:1&i?e.uint.decode(d):0,status:vo.decode(d),message:2&i?go.decode(d):null,event:4&i?ho.decode(d):null}}},wo=$,Ao=e.frame(co),To={preencode(e,d){wo.preencode(e,d.header),Ao.preencode(e,d.message)},encode(e,d){wo.encode(e,d.header),Ao.encode(e,d.message)},decode:e=>({header:wo.decode(e),message:Ao.decode(e)})},So=$,Po={preencode(e,d){So.preencode(e,d.header),n.preencode(e,d.oplog)},encode(e,d){So.encode(e,d.header),n.encode(e,d.oplog)},decode:e=>({header:So.decode(e),oplog:n.decode(e)})},Io=$,Fo=Ao,Ro={preencode(e,d){Io.preencode(e,d.header),n.preencode(e,d.oplog),Fo.preencode(e,d.message)},encode(e,d){Io.encode(e,d.header),n.encode(e,d.oplog),Fo.encode(e,d.message)},decode:e=>({header:Io.decode(e),oplog:n.decode(e),message:Fo.decode(e)})},Co=$,Ho={preencode(e,d){Co.preencode(e,d.header),n.preencode(e,d.oplog),e.end++},encode(d,o){const c=o.isPinned?1:0;Co.encode(d,o.header),n.encode(d,o.oplog),e.uint.encode(d,c)},decode:d=>({header:Co.decode(d),oplog:n.decode(d),isPinned:!!(1&e.uint.decode(d))})},Vo={preencode(d,o){lo.preencode(d,o.id),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),e.string.preencode(d,o.reaction)},encode(d,o){lo.encode(d,o.id),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),e.string.encode(d,o.reaction)},decode:d=>({id:lo.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),reaction:e.string.decode(d)})},Do={preencode(d,o){e.string.preencode(d,o.text),e.uint.preencode(d,o.count)},encode(d,o){e.string.encode(d,o.text),e.uint.encode(d,o.count)},decode:d=>({text:e.string.decode(d),count:e.uint.decode(d)})},Mo=e.array(e.frame(Do)),Lo={preencode(o,n){lo.preencode(o,n.id),e.uint.preencode(o,n.total),Mo.preencode(o,n.reactions),o.end++,d>=11&&n.editedAt&&e.uint.preencode(o,n.editedAt)},encode(o,n){const c=d>=11&&n.editedAt?1:0;lo.encode(o,n.id),e.uint.encode(o,n.total),Mo.encode(o,n.reactions),e.uint.encode(o,c),d>=11&&n.editedAt&&e.uint.encode(o,n.editedAt)},decode(o){const n=lo.decode(o),c=e.uint.decode(o),t=Mo.decode(o),r=o.start<o.end?e.uint.decode(o):0;return{id:n,total:c,reactions:t,editedAt:d>=11&&1&r?e.uint.decode(o):0}}},qo=$,Eo={preencode(d,o){qo.preencode(d,o.header),n.preencode(d,o.oplog),e.string.preencode(d,o.reaction)},encode(d,o){qo.encode(d,o.header),n.encode(d,o.oplog),e.string.encode(d,o.reaction)},decode:d=>({header:qo.decode(d),oplog:n.decode(d),reaction:e.string.decode(d)})},Bo=$,zo={preencode(d,o){Bo.preencode(d,o.header),n.preencode(d,o.oplog),e.string.preencode(d,o.reaction)},encode(d,o){Bo.encode(d,o.header),n.encode(d,o.oplog),e.string.encode(d,o.reaction)},decode:d=>({header:Bo.decode(d),oplog:n.decode(d),reaction:e.string.decode(d)})},No=$,jo=e.frame(Y),Oo={preencode(d,o){No.preencode(d,o.header),e.uint.preencode(d,o.key),jo.preencode(d,o.config)},encode(d,o){No.encode(d,o.header),e.uint.encode(d,o.key),jo.encode(d,o.config)},decode:d=>({header:No.decode(d),key:e.uint.decode(d),config:jo.decode(d)})},Uo={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.string.preencode(d,o.displayName),d.end++,o.avatar&&ia.preencode(d,o.avatar)},encode(d,o){const n=o.avatar?1:0;e.fixed32.encode(d,o.memberKey),e.string.encode(d,o.displayName),e.uint.encode(d,n),o.avatar&&ia.encode(d,o.avatar)},decode:d=>({memberKey:e.fixed32.decode(d),displayName:e.string.decode(d),avatar:1&e.uint.decode(d)?ia.decode(d):null})},Jo={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++,o.username&&e.string.preencode(d,o.username)},encode(d,o){const n=o.username?1:0;e.fixed32.encode(d,o.key),e.uint.encode(d,n),o.username&&e.string.encode(d,o.username)},decode:d=>({key:e.fixed32.decode(d),username:1&e.uint.decode(d)?e.string.decode(d):null})},Go=e.frame(Jo),Qo={preencode(d,o){e.fixed32.preencode(d,o.publicKey),d.end++,o.discoveryCoreKey&&e.fixed32.preencode(d,o.discoveryCoreKey),o.userRegistry&&Go.preencode(d,o.userRegistry)},encode(d,o){const n=(o.discoveryCoreKey?1:0)|(o.userRegistry?2:0);e.fixed32.encode(d,o.publicKey),e.uint.encode(d,n),o.discoveryCoreKey&&e.fixed32.encode(d,o.discoveryCoreKey),o.userRegistry&&Go.encode(d,o.userRegistry)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d);return{publicKey:o,discoveryCoreKey:1&n?e.fixed32.decode(d):null,userRegistry:2&n?Go.decode(d):null}}},Wo=$,Xo=e.frame(G),Yo=e.frame(Q),Zo=jo,$o=e.frame(Qo),_o=be,en=e.array(e.frame(ue)),dn={preencode(e,d){Wo.preencode(e,d.header),Xo.preencode(e,d.digest),Yo.preencode(e,d.capabilities),e.end++,d.config&&Zo.preencode(e,d.config),d.identity&&$o.preencode(e,d.identity),d.bootstrapDevice&&_o.preencode(e,d.bootstrapDevice),d.initialMembers&&en.preencode(e,d.initialMembers)},encode(d,o){const n=(o.config?1:0)|(o.identity?2:0)|(o.bootstrapDevice?4:0)|(o.initialMembers?8:0);Wo.encode(d,o.header),Xo.encode(d,o.digest),Yo.encode(d,o.capabilities),e.uint.encode(d,n),o.config&&Zo.encode(d,o.config),o.identity&&$o.encode(d,o.identity),o.bootstrapDevice&&_o.encode(d,o.bootstrapDevice),o.initialMembers&&en.encode(d,o.initialMembers)},decode(d){const o=Wo.decode(d),n=Xo.decode(d),c=Yo.decode(d),t=e.uint.decode(d);return{header:o,digest:n,capabilities:c,config:1&t?Zo.decode(d):null,identity:2&t?$o.decode(d):null,bootstrapDevice:4&t?_o.decode(d):null,initialMembers:8&t?en.decode(d):null}}},on=$,nn={preencode(d,o){on.preencode(d,o.header),e.uint.preencode(d,o.version)},encode(d,o){on.encode(d,o.header),e.uint.encode(d,o.version)},decode:d=>({header:on.decode(d),version:e.uint.decode(d)})},cn=$,tn=J,rn={preencode(d,o){cn.preencode(d,o.header),e.uint.preencode(d,o.key),tn.preencode(d,o.settings)},encode(d,o){cn.encode(d,o.header),e.uint.encode(d,o.key),tn.encode(d,o.settings)},decode:d=>({header:cn.decode(d),key:e.uint.decode(d),settings:tn.decode(d)})},an={preencode(o,n){e.fixed32.preencode(o,n.memberKey),aa.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=22&&n.contactInfo&&sa.preencode(o,n.contactInfo),d>=22&&n.version&&e.uint.preencode(o,n.version),d>=24&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=22&&n.contactInfo?4:0)|(d>=22&&n.version?8:0)|(d>=24&&n.alias?16:0);e.fixed32.encode(o,n.memberKey),aa.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=22&&n.contactInfo&&sa.encode(o,n.contactInfo),d>=22&&n.version&&e.uint.encode(o,n.version),d>=24&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.fixed32.decode(o),c=aa.decode(o),t=e.uint.decode(o);return{memberKey:n,status:c,mailbox:1&t?e.fixed32.decode(o):null,roomKey:2&t?e.fixed32.decode(o):null,contactInfo:d>=22&&4&t?sa.decode(o):null,version:d>=22&&8&t?e.uint.decode(o):0,alias:d>=24&&16&t?e.string.decode(o):null}}},sn={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.seed),o.preencode(d,n.initiator),e.fixed32.preencode(d,n.fastForwardTo)},encode(d,n){e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.fixed32.encode(d,n.seed),o.encode(d,n.initiator),e.fixed32.encode(d,n.fastForwardTo)},decode:d=>({roomKey:e.fixed32.decode(d),encryptionKey:e.buffer.decode(d),seed:e.fixed32.decode(d),initiator:o.decode(d),fastForwardTo:e.fixed32.decode(d)})},pn=e.array(e.frame(sn)),un=X,ln={preencode(e,d){pn.preencode(e,d.sharedRooms),un.preencode(e,d.blockedContacts)},encode(e,d){pn.encode(e,d.sharedRooms),un.encode(e,d.blockedContacts)},decode:e=>({sharedRooms:pn.decode(e),blockedContacts:un.decode(e)})},fn=$o,mn={preencode(e,d){fn.preencode(e,d.identity)},encode(e,d){fn.encode(e,d.identity)},decode:e=>({identity:fn.decode(e)})},yn={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.contacts)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.contacts)},decode:d=>({rooms:e.uint.decode(d),contacts:e.uint.decode(d)})},bn={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.contactRequests)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.contactRequests)},decode:d=>({rooms:e.uint.decode(d),contactRequests:e.uint.decode(d)})},xn={preencode(d,o){e.buffer.preencode(d,o.entropy)},encode(d,o){e.buffer.encode(d,o.entropy)},decode:d=>({entropy:e.buffer.decode(d)})},kn={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.devicePublicKey),e.fixed32.preencode(d,o.writerKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.devicePublicKey),e.fixed32.encode(d,o.writerKey)},decode:d=>({publicKey:e.fixed32.decode(d),devicePublicKey:e.fixed32.decode(d),writerKey:e.fixed32.decode(d)})},vn=e.frame(kn),gn={preencode(n,c){e.fixed32.preencode(n,c.id),e.fixed32.preencode(n,c.invitationSeed),e.fixed32.preencode(n,c.mailbox),t.preencode(n,c.responseKeyPair),o.preencode(n,c.initiator),o.preencode(n,c.inviter),n.end++,c.identity&&vn.preencode(n,c.identity),d>=20&&c.buildType&&Bt.preencode(n,c.buildType),d>=27&&c.link&&o.preencode(n,c.link)},encode(n,c){const r=(c.identity?1:0)|(d>=20&&c.buildType?2:0)|(d>=27&&c.link?4:0);e.fixed32.encode(n,c.id),e.fixed32.encode(n,c.invitationSeed),e.fixed32.encode(n,c.mailbox),t.encode(n,c.responseKeyPair),o.encode(n,c.initiator),o.encode(n,c.inviter),e.uint.encode(n,r),c.identity&&vn.encode(n,c.identity),d>=20&&c.buildType&&Bt.encode(n,c.buildType),d>=27&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),r=e.fixed32.decode(n),i=e.fixed32.decode(n),a=t.decode(n),s=o.decode(n),p=o.decode(n),u=e.uint.decode(n);return{id:c,invitationSeed:r,mailbox:i,responseKeyPair:a,initiator:s,inviter:p,identity:1&u?vn.decode(n):null,buildType:d>=20&&2&u?Bt.decode(n):null,link:d>=27&&4&u?o.decode(n):null}}},hn=$,Kn={preencode(d,o){hn.preencode(d,o.header),e.buffer.preencode(d,o.blindResponse)},encode(d,o){hn.encode(d,o.header),e.buffer.encode(d,o.blindResponse)},decode:d=>({header:hn.decode(d),blindResponse:e.buffer.decode(d)})},wn=$,An=e.frame(gn),Tn={preencode(e,d){wn.preencode(e,d.header),An.preencode(e,d.invitation)},encode(e,d){wn.encode(e,d.header),An.encode(e,d.invitation)},decode:e=>({header:wn.decode(e),invitation:An.decode(e)})},Sn=$,Pn={preencode(d,o){Sn.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){Sn.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:Sn.decode(d),id:e.fixed32.decode(d)})},In={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.devicePublicKey),d.end++,o.privateProfileKey&&e.fixed32.preencode(d,o.privateProfileKey),o.deviceKeyPair&&t.preencode(d,o.deviceKeyPair),e.buffer.preencode(d,o.deviceProof)},encode(d,o){const n=(o.privateProfileKey?1:0)|(o.deviceKeyPair?2:0);e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.devicePublicKey),e.uint.encode(d,n),o.privateProfileKey&&e.fixed32.encode(d,o.privateProfileKey),o.deviceKeyPair&&t.encode(d,o.deviceKeyPair),e.buffer.encode(d,o.deviceProof)},decode(d){const o=e.fixed32.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{publicKey:o,devicePublicKey:n,privateProfileKey:1&c?e.fixed32.decode(d):null,deviceKeyPair:2&c?t.decode(d):null,deviceProof:e.buffer.decode(d)}}},Fn={preencode(o,n){o.end++,d>=25&&n.roomSnoozeTime&&e.uint.preencode(o,n.roomSnoozeTime)},encode(o,n){const c=(n.isActive?1:0)|(n.isFullyMuted?2:0)|(n.isMentionsOnlyMuted?4:0)|(d>=9&&n.isReadOnly?8:0)|(d>=18&&n.isFavorite?16:0)|(d>=21&&n.isUnread?32:0)|(d>=25&&n.roomSnoozeTime?64:0);e.uint.encode(o,c),d>=25&&n.roomSnoozeTime&&e.uint.encode(o,n.roomSnoozeTime)},decode(o){const n=e.uint.decode(o);return{isActive:!!(1&n),isFullyMuted:!!(2&n),isMentionsOnlyMuted:!!(4&n),isReadOnly:d>=9&&!!(8&n),isFavorite:d>=18&&!!(16&n),isUnread:d>=21&&!!(32&n),roomSnoozeTime:d>=25&&64&n?e.uint.decode(o):0}}},Rn=e.frame(Fn),Cn=e.frame(In),Hn=vn,Vn={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),Rn.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,c.initiator&&o.preencode(n,c.initiator),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),c.identitySwap&&Cn.preencode(n,c.identitySwap),d>=6&&c.identitySwapV2&&Hn.preencode(n,c.identitySwapV2),d>=10&&c.contact&&e.fixed32.preencode(n,c.contact),d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=29&&c.activeClock&&e.uint.preencode(n,c.activeClock)},encode(n,c){const t=(c.initiator?1:0)|(c.fastForwardTo?2:0)|(c.identitySwap?4:0)|(d>=6&&c.identitySwapV2?8:0)|(d>=10&&c.contact?16:0)|(d>=27&&c.bootFrom?32:0)|(d>=29&&c.activeClock?64:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),Rn.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,t),c.initiator&&o.encode(n,c.initiator),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),c.identitySwap&&Cn.encode(n,c.identitySwap),d>=6&&c.identitySwapV2&&Hn.encode(n,c.identitySwapV2),d>=10&&c.contact&&e.fixed32.encode(n,c.contact),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom),d>=29&&c.activeClock&&e.uint.encode(n,c.activeClock)},decode(n){const c=e.fixed32.decode(n),t=e.buffer.decode(n),r=e.fixed32.decode(n),i=Rn.decode(n),a=e.uint.decode(n),s=e.uint.decode(n);return{roomKey:c,encryptionKey:t,mailbox:r,status:i,clock:a,initiator:1&s?o.decode(n):null,fastForwardTo:2&s?e.fixed32.decode(n):null,identitySwap:4&s?Cn.decode(n):null,identitySwapV2:d>=6&&8&s?Hn.decode(n):null,contact:d>=10&&16&s?e.fixed32.decode(n):null,bootFrom:d>=27&&32&s?o.decode(n):null,activeClock:d>=29&&64&s?e.uint.decode(n):0}}},Dn=$,Mn={preencode(d,n){Dn.preencode(d,n.header),e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.mailbox),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.dm&&e.fixed32.preencode(d,n.dm)},encode(n,c){const t=(c.fastForwardTo?1:0)|(c.initiator?2:0)|(c.dm?4:0)|(d>=9&&c.isReadOnly?8:0);Dn.encode(n,c.header),e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),e.uint.encode(n,t),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),c.initiator&&o.encode(n,c.initiator),c.dm&&e.fixed32.encode(n,c.dm)},decode(n){const c=Dn.decode(n),t=e.fixed32.decode(n),r=e.buffer.decode(n),i=e.fixed32.decode(n),a=e.uint.decode(n);return{header:c,roomKey:t,encryptionKey:r,mailbox:i,fastForwardTo:1&a?e.fixed32.decode(n):null,initiator:2&a?o.decode(n):null,dm:4&a?e.fixed32.decode(n):null,isReadOnly:d>=9&&!!(8&a)}}},Ln=$,qn={preencode(d,o){Ln.preencode(d,o.header),e.fixed32.preencode(d,o.discoveryKey)},encode(d,o){Ln.encode(d,o.header),e.fixed32.encode(d,o.discoveryKey)},decode:d=>({header:Ln.decode(d),discoveryKey:e.fixed32.decode(d)})},En=$,Bn=Rn,zn={preencode(d,o){En.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.key),Bn.preencode(d,o.status)},encode(d,o){En.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.key),Bn.encode(d,o.status)},decode:d=>({header:En.decode(d),roomKey:e.fixed32.decode(d),key:e.uint.decode(d),status:Bn.decode(d)})},Nn={preencode(e,d){e.end++},encode(o,n){const c=(n.isBlocked?1:0)|(d>=22&&n.isActive?2:0);e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{isBlocked:!!(1&n),isActive:d>=22&&!!(2&n)}}},jn={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.clock),pa.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=22&&n.contactInfo&&ua.preencode(o,n.contactInfo),d>=24&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=22&&n.contactInfo?4:0)|(d>=24&&n.alias?8:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.clock),pa.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=22&&n.contactInfo&&ua.encode(o,n.contactInfo),d>=24&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),t=pa.decode(o),r=e.uint.decode(o);return{memberKey:n,clock:c,status:t,mailbox:1&r?e.fixed32.decode(o):null,roomKey:2&r?e.fixed32.decode(o):null,contactInfo:d>=22&&4&r?ua.decode(o):null,alias:d>=24&&8&r?e.string.decode(o):null}}},On=$,Un=e.frame(an),Jn={preencode(e,d){On.preencode(e,d.header),Un.preencode(e,d.contact)},encode(e,d){On.encode(e,d.header),Un.encode(e,d.contact)},decode:e=>({header:On.decode(e),contact:Un.decode(e)})},Gn=$,Qn={preencode(d,o){Gn.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),la.preencode(d,o.status)},encode(d,o){Gn.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),la.encode(d,o.status)},decode:d=>({header:Gn.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:la.decode(d)})},Wn=$,Xn={preencode(d,o){Wn.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Wn.encode(d,o.header),e.fixed32.encode(d,o.memberKey)},decode:d=>({header:Wn.decode(d),memberKey:e.fixed32.decode(d)})},Yn={preencode(e,d){e.end++},encode(d,o){const n=(o.isPending?1:0)|(o.isAccepted?2:0)|(o.isRejected?4:0)|(o.isDiscarded?8:0)|(o.isSeen?16:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isPending:!!(1&o),isAccepted:!!(2&o),isRejected:!!(4&o),isDiscarded:!!(8&o),isSeen:!!(16&o)}}},Zn=xe,$n=e.frame(r),_n={preencode(d,o){Zn.preencode(d,o.sender),$n.preencode(d,o.keys),e.fixed32.preencode(d,o.mailbox),d.end++,o.message&&e.string.preencode(d,o.message)},encode(d,o){const n=o.message?1:0;Zn.encode(d,o.sender),$n.encode(d,o.keys),e.fixed32.encode(d,o.mailbox),e.uint.encode(d,n),o.message&&e.string.encode(d,o.message)},decode:d=>({sender:Zn.decode(d),keys:$n.decode(d),mailbox:e.fixed32.decode(d),message:1&e.uint.decode(d)?e.string.decode(d):null})},ec=e.frame(_n),dc={preencode(e,d){ec.preencode(e,d.body),ne.preencode(e,d.attestation)},encode(e,d){ec.encode(e,d.body),ne.encode(e,d.attestation)},decode:e=>({body:ec.decode(e),attestation:ne.decode(e)})},oc=pe,nc=e.frame(Yn),cc=$n,tc={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.clock),oc.preencode(o,n.sender),nc.preencode(o,n.status),cc.preencode(o,n.keys),e.fixed32.preencode(o,n.mailbox),o.end++,n.message&&e.string.preencode(o,n.message),d>=11&&n.sentAt&&e.uint.preencode(o,n.sentAt),d>=22&&n.contactInfo&&fa.preencode(o,n.contactInfo)},encode(o,n){const c=(n.message?1:0)|(d>=11&&n.sentAt?2:0)|(d>=22&&n.contactInfo?4:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.clock),oc.encode(o,n.sender),nc.encode(o,n.status),cc.encode(o,n.keys),e.fixed32.encode(o,n.mailbox),e.uint.encode(o,c),n.message&&e.string.encode(o,n.message),d>=11&&n.sentAt&&e.uint.encode(o,n.sentAt),d>=22&&n.contactInfo&&fa.encode(o,n.contactInfo)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),t=oc.decode(o),r=nc.decode(o),i=cc.decode(o),a=e.fixed32.decode(o),s=e.uint.decode(o);return{memberKey:n,clock:c,sender:t,status:r,keys:i,mailbox:a,message:1&s?e.string.decode(o):null,sentAt:d>=11&&2&s?e.uint.decode(o):0,contactInfo:d>=22&&4&s?fa.decode(o):null}}},rc=$,ic={preencode(d,o){rc.preencode(d,o.header),e.buffer.preencode(d,o.blindRequest)},encode(d,o){rc.encode(d,o.header),e.buffer.encode(d,o.blindRequest)},decode:d=>({header:rc.decode(d),blindRequest:e.buffer.decode(d)})},ac=$,sc=nc,pc={preencode(o,n){ac.preencode(o,n.header),e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.key),sc.preencode(o,n.status),o.end++,d>=10&&n.roomKey&&e.fixed32.preencode(o,n.roomKey)},encode(o,n){const c=d>=10&&n.roomKey?1:0;ac.encode(o,n.header),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.key),sc.encode(o,n.status),e.uint.encode(o,c),d>=10&&n.roomKey&&e.fixed32.encode(o,n.roomKey)},decode(o){const n=ac.decode(o),c=e.fixed32.decode(o),t=e.uint.decode(o),r=sc.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{header:n,memberKey:c,key:t,status:r,roomKey:d>=10&&1&i?e.fixed32.decode(o):null}}},uc={preencode(d,o){e.uint.preencode(d,o.timestamp),e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.mailbox)},encode(d,o){e.uint.encode(d,o.timestamp),e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.mailbox)},decode:d=>({version:e.uint.decode(d),timestamp:e.uint.decode(d),key:e.fixed32.decode(d),mailbox:e.fixed32.decode(d)})},lc={preencode(d,o){const n=o.version??1;switch(e.uint.preencode(d,n),n){case 0:case 1:uc.preencode(d,o);break;default:throw new Error("Unsupported version")}},encode(d,o){const n=o.version??1;switch(e.uint.encode(d,n),n){case 0:case 1:uc.encode(d,o);break;default:throw new Error("Unsupported version")}},decode(d){const o=d.start,n=e.uint.decode(d);switch(d.start=o,n){case 0:case 1:return uc.decode(d);default:throw new Error("Unsupported version")}}},fc=$,mc={preencode(o,c){fc.preencode(o,c.header),n.preencode(o,c.oplog),e.uint.preencode(o,c.index),ma.preencode(o,c.preview),o.end++,d>=7&&c.displayType&&Sc.preencode(o,c.displayType)},encode(o,c){const t=d>=7&&c.displayType?1:0;fc.encode(o,c.header),n.encode(o,c.oplog),e.uint.encode(o,c.index),ma.encode(o,c.preview),e.uint.encode(o,t),d>=7&&c.displayType&&Sc.encode(o,c.displayType)},decode(o){const c=fc.decode(o),t=n.decode(o),r=e.uint.decode(o),i=ma.decode(o),a=o.start<o.end?e.uint.decode(o):0;return{header:c,oplog:t,index:r,preview:i,displayType:d>=7&&1&a?Sc.decode(o):0}}},yc={preencode(o,n){o.end++,d>=3&&n.memberKey&&e.fixed32.preencode(o,n.memberKey)},encode(o,n){const c=d>=3&&n.memberKey?1:0;e.uint.encode(o,c),d>=3&&n.memberKey&&e.fixed32.encode(o,n.memberKey)},decode(o){const n=e.uint.decode(o);return{memberKey:d>=3&&1&n?e.fixed32.decode(o):null}}},bc=pe,xc={preencode(e,d){bc.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){bc.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:bc.decode(e),attestation:ne.decode(e)})},kc=$,vc={preencode(d,o){kc.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){kc.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:kc.decode(d),key:e.fixed32.decode(d)})},gc={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),ne.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){e.fixed32.encode(d,o.deviceKey),ne.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({deviceKey:e.fixed32.decode(d),privateProfileIdentity:ne.decode(d),deviceProof:e.buffer.decode(d)})},hc={preencode(o,n){e.fixed32.preencode(o,n.roomKey),e.fixed32.preencode(o,n.encryptionKey),e.fixed32.preencode(o,n.seed),o.end++,d>=6&&n.fastForwardTo&&e.fixed32.preencode(o,n.fastForwardTo)},encode(o,n){const c=d>=6&&n.fastForwardTo?1:0;e.fixed32.encode(o,n.roomKey),e.fixed32.encode(o,n.encryptionKey),e.fixed32.encode(o,n.seed),e.uint.encode(o,c),d>=6&&n.fastForwardTo&&e.fixed32.encode(o,n.fastForwardTo)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=e.fixed32.decode(o),r=e.uint.decode(o);return{roomKey:n,encryptionKey:c,seed:t,fastForwardTo:d>=6&&1&r?e.fixed32.decode(o):null}}},Kc={preencode(o,n){e.fixed32.preencode(o,n.publicKey),e.fixed32.preencode(o,n.writerKey),e.fixed32.preencode(o,n.devicePublicKey),o.end++,d>=6&&n.privateProfileKey&&e.fixed32.preencode(o,n.privateProfileKey)},encode(o,n){const c=d>=6&&n.privateProfileKey?1:0;e.fixed32.encode(o,n.publicKey),e.fixed32.encode(o,n.writerKey),e.fixed32.encode(o,n.devicePublicKey),e.uint.encode(o,c),d>=6&&n.privateProfileKey&&e.fixed32.encode(o,n.privateProfileKey)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=e.fixed32.decode(o),r=e.uint.decode(o);return{publicKey:n,writerKey:c,devicePublicKey:t,privateProfileKey:d>=6&&1&r?e.fixed32.decode(o):null}}},wc=$,Ac={preencode(d,o){wc.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey)},encode(d,o){wc.encode(d,o.header),e.fixed32.encode(d,o.memberKey)},decode:d=>({header:wc.decode(d),memberKey:e.fixed32.decode(d)})},Tc={HttpLink:1,PearLink:2},Sc={preencode(e,d){e.end++},encode(d,o){if(o>2)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Pc=$,Ic={preencode(d,o){Pc.preencode(d,o.header),e.uint.preencode(d,o.value)},encode(d,o){Pc.encode(d,o.header),e.uint.encode(d,o.value)},decode:d=>({header:Pc.decode(d),value:e.uint.decode(d)})},Fc={preencode(d,o){e.uint.preencode(d,o.key),e.uint.preencode(d,o.value)},encode(d,o){e.uint.encode(d,o.key),e.uint.encode(d,o.value)},decode:d=>({key:e.uint.decode(d),value:e.uint.decode(d)})},Rc=$,Cc={preencode(o,n){Rc.preencode(o,n.header),e.uint.preencode(o,n.from),e.uint.preencode(o,n.to),o.end++,d>=20&&n.buildType&&Bt.preencode(o,n.buildType)},encode(o,n){const c=d>=20&&n.buildType?1:0;Rc.encode(o,n.header),e.uint.encode(o,n.from),e.uint.encode(o,n.to),e.uint.encode(o,c),d>=20&&n.buildType&&Bt.encode(o,n.buildType)},decode(o){const n=Rc.decode(o),c=e.uint.decode(o),t=e.uint.decode(o),r=o.start<o.end?e.uint.decode(o):0;return{header:n,from:c,to:t,buildType:d>=20&&1&r?Bt.decode(o):null}}},Hc={RoomType:1,IsExperimental:2,IsJoiningDisabled:3,IsAppendingDisabled:4,IsCallingDisabled:5,IsMembershipEventsDisabled:6,IsAttachmentsDisabled:7,IsLinksDisabled:8,IsRoomInviteHidden:9},Vc={preencode(e,d){e.end++},encode(d,o){if(o>9)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Dc={en:"en",it:"it",ru:"ru",es:"es",de:"de"},Mc={preencode(e,d){e.end++},encode(d,o){switch(o){case"en":e.uint.encode(d,1);break;case"it":e.uint.encode(d,2);break;case"ru":e.uint.encode(d,3);break;case"es":e.uint.encode(d,4);break;case"de":e.uint.encode(d,5);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"en";case 2:return"it";case 3:return"ru";case 4:return"es";case 5:return"de";default:return null}}},Lc=Dd,qc={preencode(d,o){Lc.preencode(d,o.range),Mc.preencode(d,o.language),e.string.preencode(d,o.text)},encode(d,o){Lc.encode(d,o.range),Mc.encode(d,o.language),e.string.encode(d,o.text)},decode:d=>({range:Lc.decode(d),language:Mc.decode(d),text:e.string.decode(d)})},Ec={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.key)},decode:d=>({deviceKey:e.fixed32.decode(d),key:e.fixed32.decode(d)})},Bc=$,zc={preencode(d,o){Bc.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){Bc.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:Bc.decode(d),key:e.fixed32.decode(d)})},Nc=$,jc={preencode(d,o){Nc.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){Nc.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:Nc.decode(d),key:e.fixed32.decode(d)})},Oc={Flag:1},Uc={preencode(e,d){e.end++},encode(d,o){if(o>1)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Jc={preencode(d,o){lo.preencode(d,o.id),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),Uc.preencode(d,o.label)},encode(d,o){lo.encode(d,o.id),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),Uc.encode(d,o.label)},decode:d=>({id:lo.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),label:Uc.decode(d)})},Gc=$,Qc={preencode(e,d){Gc.preencode(e,d.header),n.preencode(e,d.oplog),Uc.preencode(e,d.label)},encode(e,d){Gc.encode(e,d.header),n.encode(e,d.oplog),Uc.encode(e,d.label)},decode:e=>({header:Gc.decode(e),oplog:n.decode(e),label:Uc.decode(e)})},Wc=$,Xc={preencode(e,d){Wc.preencode(e,d.header),n.preencode(e,d.oplog),Uc.preencode(e,d.label)},encode(e,d){Wc.encode(e,d.header),n.encode(e,d.oplog),Uc.encode(e,d.label)},decode:e=>({header:Wc.decode(e),oplog:n.decode(e),label:Uc.decode(e)})},Yc={preencode(d,o){Uc.preencode(d,o.label),e.uint.preencode(d,o.count)},encode(d,o){Uc.encode(d,o.label),e.uint.encode(d,o.count)},decode:d=>({label:Uc.decode(d),count:e.uint.decode(d)})},Zc=e.array(e.frame(Yc)),$c={preencode(o,n){lo.preencode(o,n.id),e.uint.preencode(o,n.total),Zc.preencode(o,n.labels),e.uint.preencode(o,n.editedAt),o.end++,d>=15&&n.flagsClock&&e.uint.preencode(o,n.flagsClock),d>=15&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(d>=15&&n.flagsClock?1:0)|(d>=15&&n.version?2:0)|(d>=16&&n.isDeleted?4:0);lo.encode(o,n.id),e.uint.encode(o,n.total),Zc.encode(o,n.labels),e.uint.encode(o,n.editedAt),e.uint.encode(o,c),d>=15&&n.flagsClock&&e.uint.encode(o,n.flagsClock),d>=15&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=lo.decode(o),c=e.uint.decode(o),t=Zc.decode(o),r=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{id:n,total:c,labels:t,editedAt:r,flagsClock:d>=15&&1&i?e.uint.decode(o):0,version:d>=15&&2&i?e.uint.decode(o):0,isDeleted:d>=16&&!!(4&i)}}},_c=$,et={preencode(d,o){_c.preencode(d,o.header),e.uint.preencode(d,o.length)},encode(d,o){_c.encode(d,o.header),e.uint.encode(d,o.length)},decode:d=>({header:_c.decode(d),length:e.uint.decode(d)})},dt={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.length)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.length)},decode:d=>({memberKey:e.fixed32.decode(d),length:e.uint.decode(d)})},ot=Z,nt={preencode(o,n){o.end++,d>=23&&n.profileSnoozeTime&&e.uint.preencode(o,n.profileSnoozeTime)},encode(o,n){const c=(d>=13&&n.disableReadReceipts?1:0)|(d>=21&&n.stripAttachmentMetadata?2:0)|(d>=23&&n.profileSnoozeTime?4:0);e.uint.encode(o,c),d>=23&&n.profileSnoozeTime&&e.uint.encode(o,n.profileSnoozeTime)},decode(o){const n=e.uint.decode(o);return{disableReadReceipts:d>=13&&!!(1&n),stripAttachmentMetadata:d>=21&&!!(2&n),profileSnoozeTime:d>=23&&4&n?e.uint.decode(o):0}}},ct={disableReadReceipts:"disableReadReceipts",stripAttachmentMetadata:"stripAttachmentMetadata",profileSnoozeTime:"profileSnoozeTime"},tt={preencode(e,d){e.end++},encode(d,o){switch(o){case"disableReadReceipts":e.uint.encode(d,1);break;case"stripAttachmentMetadata":e.uint.encode(d,2);break;case"profileSnoozeTime":e.uint.encode(d,3);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"disableReadReceipts";case 2:return"stripAttachmentMetadata";case 3:return"profileSnoozeTime";default:return null}}},rt=$,it=e.frame(nt),at={preencode(e,d){rt.preencode(e,d.header),tt.preencode(e,d.key),it.preencode(e,d.settings)},encode(e,d){rt.encode(e,d.header),tt.encode(e,d.key),it.encode(e,d.settings)},decode:e=>({header:rt.decode(e),key:tt.decode(e),settings:it.decode(e)})},st={Flag:1},pt={preencode(e,d){e.end++},encode(d,o){if(o>1)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},ut={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),pt.preencode(d,o.label)},encode(d,o){e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),pt.encode(d,o.label)},decode:d=>({key:e.fixed32.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),label:pt.decode(d)})},lt=$,ft={preencode(d,o){lt.preencode(d,o.header),e.fixed32.preencode(d,o.key),pt.preencode(d,o.label)},encode(d,o){lt.encode(d,o.header),e.fixed32.encode(d,o.key),pt.encode(d,o.label)},decode:d=>({header:lt.decode(d),key:e.fixed32.decode(d),label:pt.decode(d)})},mt={preencode(d,o){pt.preencode(d,o.label),e.uint.preencode(d,o.count)},encode(d,o){pt.encode(d,o.label),e.uint.encode(d,o.count)},decode:d=>({label:pt.decode(d),count:e.uint.decode(d)})},yt=e.array(e.frame(mt)),bt={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.total),yt.preencode(d,o.labels),e.uint.preencode(d,o.editedAt),e.uint.preencode(d,o.flagsClock)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.total),yt.encode(d,o.labels),e.uint.encode(d,o.editedAt),e.uint.encode(d,o.flagsClock)},decode:d=>({key:e.fixed32.decode(d),total:e.uint.decode(d),labels:yt.decode(d),editedAt:e.uint.decode(d),flagsClock:e.uint.decode(d)})},xt={preencode(d,o){e.float64.preencode(d,o.latitude),e.float64.preencode(d,o.longitude)},encode(d,o){e.float64.encode(d,o.latitude),e.float64.encode(d,o.longitude)},decode:d=>({latitude:e.float64.decode(d),longitude:e.float64.decode(d)})},kt=$,vt={preencode(d,o){kt.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.fromDeviceKey)},encode(d,o){kt.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.fromDeviceKey)},decode:d=>({header:kt.decode(d),deviceKey:e.fixed32.decode(d),fromDeviceKey:e.fixed32.decode(d)})},gt=$,ht=X,Kt={preencode(o,n){gt.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),e.buffer.preencode(o,n.encryptionKey),o.end++,d>=19&&n.streams&&ht.preencode(o,n.streams),d>=19&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=19&&n.version&&e.uint.preencode(o,n.version),d>=26&&n.streamInputs&&ya.preencode(o,n.streamInputs),d>=26&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey)},encode(o,n){const c=(d>=19&&n.streams?1:0)|(d>=19&&n.discoveryKey?2:0)|(d>=19&&n.version?4:0)|(d>=26&&n.streamInputs?8:0)|(d>=26&&n.swarmKey?16:0);gt.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,c),d>=19&&n.streams&&ht.encode(o,n.streams),d>=19&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=19&&n.version&&e.uint.encode(o,n.version),d>=26&&n.streamInputs&&ya.encode(o,n.streamInputs),d>=26&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey)},decode(o){const n=gt.decode(o),c=e.fixed32.decode(o),t=e.buffer.decode(o),r=e.uint.decode(o);return{header:n,callKey:c,encryptionKey:t,streams:d>=19&&1&r?ht.decode(o):null,discoveryKey:d>=19&&2&r?e.fixed32.decode(o):null,version:d>=19&&4&r?e.uint.decode(o):0,streamInputs:d>=26&&8&r?ya.decode(o):null,swarmKey:d>=26&&16&r?e.fixed32.decode(o):null}}},wt=$,At=X,Tt={preencode(o,n){wt.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),o.end++,d>=19&&n.streams&&At.preencode(o,n.streams),d>=26&&n.streamInputs&&ba.preencode(o,n.streamInputs),d>=26&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey)},encode(o,n){const c=(d>=19&&n.streams?1:0)|(d>=26&&n.streamInputs?2:0)|(d>=26&&n.swarmKey?4:0);wt.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.uint.encode(o,c),d>=19&&n.streams&&At.encode(o,n.streams),d>=26&&n.streamInputs&&ba.encode(o,n.streamInputs),d>=26&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey)},decode(o){const n=wt.decode(o),c=e.fixed32.decode(o),t=e.uint.decode(o);return{header:n,callKey:c,streams:d>=19&&1&t?At.decode(o):null,streamInputs:d>=26&&2&t?ba.decode(o):null,swarmKey:d>=26&&4&t?e.fixed32.decode(o):null}}},St=$,Pt={preencode(d,o){St.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){St.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:St.decode(d),callKey:e.fixed32.decode(d)})},It=$,Ft={preencode(d,o){It.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){It.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:It.decode(d),callKey:e.fixed32.decode(d)})},Rt=$,Ct={preencode(o,n){Rt.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.streamKey),o.end++,d>=26&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=26&&n.type&&e.string.preencode(o,n.type)},encode(o,n){const c=(d>=26&&n.mediaStreamId?1:0)|(d>=26&&n.type?2:0)|(d>=26&&n.muted?4:0);Rt.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.streamKey),e.uint.encode(o,c),d>=26&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=26&&n.type&&e.string.encode(o,n.type)},decode(o){const n=Rt.decode(o),c=e.fixed32.decode(o),t=e.fixed32.decode(o),r=o.start<o.end?e.uint.decode(o):0;return{header:n,callKey:c,streamKey:t,mediaStreamId:d>=26&&1&r?e.string.decode(o):null,type:d>=26&&2&r?e.string.decode(o):null,muted:d>=26&&!!(4&r)}}},Ht=$,Vt={preencode(d,o){Ht.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.streamKey)},encode(d,o){Ht.encode(d,o.header),e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.streamKey)},decode:d=>({header:Ht.decode(d),callKey:e.fixed32.decode(d),streamKey:e.fixed32.decode(d)})},Dt={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.buffer.preencode(o,n.encryptionKey),e.uint.preencode(o,n.createdAt),o.end++,d>=19&&n.endedAt&&e.uint.preencode(o,n.endedAt),d>=19&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=19&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(d>=19&&n.endedAt?1:0)|(d>=19&&n.discoveryKey?2:0)|(d>=19&&n.version?4:0);e.fixed32.encode(o,n.callKey),e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=19&&n.endedAt&&e.uint.encode(o,n.endedAt),d>=19&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=19&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=e.fixed32.decode(o),c=e.buffer.decode(o),t=e.uint.decode(o),r=e.uint.decode(o);return{callKey:n,encryptionKey:c,createdAt:t,endedAt:d>=19&&1&r?e.uint.decode(o):0,discoveryKey:d>=19&&2&r?e.fixed32.decode(o):null,version:d>=19&&4&r?e.uint.decode(o):0}}},Mt={preencode(d,o){e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.createdAt)},encode(d,o){e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.createdAt)},decode:d=>({callKey:e.fixed32.decode(d),memberKey:e.fixed32.decode(d),createdAt:e.uint.decode(d)})},Lt={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.deviceKey),e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.createdAt),o.end++,d>=19&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),d>=22&&n.lastHeartbeatAt&&e.uint.preencode(o,n.lastHeartbeatAt)},encode(o,n){const c=(d>=19&&n.swarmKey?1:0)|(d>=22&&n.lastHeartbeatAt?2:0)|(d>=23&&n.isRecording?4:0);e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.deviceKey),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=19&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey),d>=22&&n.lastHeartbeatAt&&e.uint.encode(o,n.lastHeartbeatAt)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=e.fixed32.decode(o),r=e.uint.decode(o),i=e.uint.decode(o);return{callKey:n,deviceKey:c,memberKey:t,createdAt:r,swarmKey:d>=19&&1&i?e.fixed32.decode(o):null,lastHeartbeatAt:d>=22&&2&i?e.uint.decode(o):0,isRecording:d>=23&&!!(4&i)}}},qt={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.deviceKey),e.buffer.preencode(o,n.streamKey),e.uint.preencode(o,n.createdAt),o.end++,d>=26&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=26&&n.type&&e.string.preencode(o,n.type),d>=26&&n.statusKey&&e.uint.preencode(o,n.statusKey)},encode(o,n){const c=(d>=26&&n.mediaStreamId?1:0)|(d>=26&&n.type?2:0)|(d>=26&&n.statusKey?4:0);e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.deviceKey),e.buffer.encode(o,n.streamKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=26&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=26&&n.type&&e.string.encode(o,n.type),d>=26&&n.statusKey&&e.uint.encode(o,n.statusKey)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=e.buffer.decode(o),r=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{callKey:n,deviceKey:c,streamKey:t,createdAt:r,mediaStreamId:d>=26&&1&i?e.string.decode(o):null,type:d>=26&&2&i?e.string.decode(o):null,statusKey:d>=26&&4&i?e.uint.decode(o):0}}},Et={Nightly:"Nightly",Internal:"Internal",Production:"Production"},Bt={preencode(e,d){e.end++},encode(d,o){switch(o){case"Nightly":e.uint.encode(d,1);break;case"Internal":e.uint.encode(d,2);break;case"Production":e.uint.encode(d,3);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"Nightly";case 2:return"Internal";case 3:return"Production";default:return null}}},zt=$,Nt={preencode(e,d){zt.preencode(e,d.header)},encode(e,d){zt.encode(e,d.header)},decode:e=>({header:zt.decode(e)})},jt=$,Ot={preencode(e,d){jt.preencode(e,d.header)},encode(e,d){jt.encode(e,d.header)},decode:e=>({header:jt.decode(e)})},Ut=$,Jt={preencode(d,o){Ut.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),e.buffer.preencode(d,o.deviceProof),e.buffer.preencode(d,o.writerProof)},encode(d,o){Ut.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.buffer.encode(d,o.deviceProof),e.buffer.encode(d,o.writerProof)},decode:d=>({header:Ut.decode(d),deviceKey:e.fixed32.decode(d),deviceProof:e.buffer.decode(d),writerProof:e.buffer.decode(d)})},Gt=$,Qt={preencode(d,o){Gt.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Gt.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Gt.decode(d),callKey:e.fixed32.decode(d)})},Wt=$,Xt={preencode(d,o){Wt.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.deviceKey)},encode(d,o){Wt.encode(d,o.header),e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.deviceKey)},decode:d=>({header:Wt.decode(d),callKey:e.fixed32.decode(d),deviceKey:e.fixed32.decode(d)})},Yt=$,Zt={preencode(d,o){Yt.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Yt.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Yt.decode(d),callKey:e.fixed32.decode(d)})},$t=$,_t={preencode(d,o){$t.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){$t.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:$t.decode(d),callKey:e.fixed32.decode(d)})},er=$,dr={preencode(e,d){er.preencode(e,d.header),n.preencode(e,d.oplog)},encode(e,d){er.encode(e,d.header),n.encode(e,d.oplog)},decode:e=>({header:er.decode(e),oplog:n.decode(e)})},or=$,nr={preencode(e,d){or.preencode(e,d.header)},encode(e,d){or.encode(e,d.header)},decode:e=>({header:or.decode(e)})},cr={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.timestamp)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.timestamp)},decode:d=>({memberKey:e.fixed32.decode(d),timestamp:e.uint.decode(d)})},tr=$,rr={preencode(o,n){tr.preencode(o,n.header),e.fixed32.preencode(o,n.memberKey),o.end++,d>=24&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=d>=24&&n.alias?1:0;tr.encode(o,n.header),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,c),d>=24&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=tr.decode(o),c=e.fixed32.decode(o),t=e.uint.decode(o);return{header:n,memberKey:c,alias:d>=24&&1&t?e.string.decode(o):null}}},ir={preencode(d,o){e.uint.preencode(d,o.streams)},encode(d,o){e.uint.encode(d,o.streams)},decode:d=>({streams:e.uint.decode(d)})},ar={preencode(d,o){e.fixed32.preencode(d,o.streamKey),e.string.preencode(d,o.mediaStreamId),e.string.preencode(d,o.type),d.end++},encode(o,n){const c=d>=26&&n.muted?1:0;e.fixed32.encode(o,n.streamKey),e.string.encode(o,n.mediaStreamId),e.string.encode(o,n.type),e.uint.encode(o,c)},decode(o){const n=e.fixed32.decode(o),c=e.string.decode(o),t=e.string.decode(o),r=e.uint.decode(o);return{streamKey:n,mediaStreamId:c,type:t,muted:d>=26&&!!(1&r)}}},sr=$,pr={preencode(d,o){sr.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.streamKey),d.end++},encode(o,n){const c=d>=26&&n.muted?1:0;sr.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.streamKey),e.uint.encode(o,c)},decode(o){const n=sr.decode(o),c=e.fixed32.decode(o),t=e.fixed32.decode(o),r=e.uint.decode(o);return{header:n,callKey:c,streamKey:t,muted:d>=26&&!!(1&r)}}},ur={preencode(d,o){e.uint.preencode(d,o.statusKey),d.end++},encode(o,n){const c=d>=26&&n.muted?1:0;e.uint.encode(o,n.statusKey),e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o),c=e.uint.decode(o);return{statusKey:n,muted:d>=26&&!!(1&c)}}},lr={preencode(n,c){e.fixed32.preencode(n,c.key),n.end++,d>=27&&c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const t=(d>=27&&c.encryptionKey?1:0)|(d>=27&&c.bootFrom?2:0);e.fixed32.encode(n,c.key),e.uint.encode(n,t),d>=27&&c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),t=e.uint.decode(n);return{key:c,encryptionKey:d>=27&&1&t?e.buffer.decode(n):null,bootFrom:d>=27&&2&t?o.decode(n):null}}},fr={preencode(d,o){e.fixed32.preencode(d,o.hash)},encode(d,o){e.fixed32.encode(d,o.hash)},decode:d=>({hash:e.fixed32.decode(d)})},mr={preencode(d,o){e.fixed32.preencode(d,o.hash),e.buffer.preencode(d,o.data)},encode(d,o){e.fixed32.encode(d,o.hash),e.buffer.encode(d,o.data)},decode:d=>({hash:e.fixed32.decode(d),data:e.buffer.decode(d)})},yr={preencode(n,c){o.preencode(n,c.autobeeMigrationHead),n.end++,d>=27&&c.legacyViewHead&&o.preencode(n,c.legacyViewHead),d>=27&&c.dbViewHead&&o.preencode(n,c.dbViewHead),d>=27&&c.blobsViewHead&&o.preencode(n,c.blobsViewHead),e.uint.preencode(n,c.createdAt)},encode(n,c){const t=(d>=27&&c.legacyViewHead?1:0)|(d>=27&&c.dbViewHead?2:0)|(d>=27&&c.blobsViewHead?4:0);o.encode(n,c.autobeeMigrationHead),e.uint.encode(n,t),d>=27&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=27&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=27&&c.blobsViewHead&&o.encode(n,c.blobsViewHead),e.uint.encode(n,c.createdAt)},decode(n){const c=o.decode(n),t=e.uint.decode(n);return{autobeeMigrationHead:c,legacyViewHead:d>=27&&1&t?o.decode(n):null,dbViewHead:d>=27&&2&t?o.decode(n):null,blobsViewHead:d>=27&&4&t?o.decode(n):null,createdAt:e.uint.decode(n)}}},br=$,xr={preencode(e,n){br.preencode(e,n.header),o.preencode(e,n.head),e.end++,d>=27&&n.legacyViewHead&&o.preencode(e,n.legacyViewHead),d>=27&&n.dbViewHead&&o.preencode(e,n.dbViewHead),d>=27&&n.blobsViewHead&&o.preencode(e,n.blobsViewHead)},encode(n,c){const t=(d>=27&&c.legacyViewHead?1:0)|(d>=27&&c.dbViewHead?2:0)|(d>=27&&c.blobsViewHead?4:0);br.encode(n,c.header),o.encode(n,c.head),e.uint.encode(n,t),d>=27&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=27&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=27&&c.blobsViewHead&&o.encode(n,c.blobsViewHead)},decode(n){const c=br.decode(n),t=o.decode(n),r=e.uint.decode(n);return{header:c,head:t,legacyViewHead:d>=27&&1&r?o.decode(n):null,dbViewHead:d>=27&&2&r?o.decode(n):null,blobsViewHead:d>=27&&4&r?o.decode(n):null}}},kr={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.fixed32.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.seed),n.end++,d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const t=d>=27&&c.bootFrom?1:0;e.fixed32.encode(n,c.roomKey),e.fixed32.encode(n,c.encryptionKey),e.fixed32.encode(n,c.seed),e.uint.encode(n,t),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),t=e.fixed32.decode(n),r=e.fixed32.decode(n),i=e.uint.decode(n);return{roomKey:c,encryptionKey:t,seed:r,bootFrom:d>=27&&1&i?o.decode(n):null}}},vr=id,gr={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.fixed32.preencode(d,o.deviceKey),e.uint.preencode(d,o.deviceLength),e.uint.preencode(d,o.clock),vr.preencode(d,o.status)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,o.deviceLength),e.uint.encode(d,o.clock),vr.encode(d,o.status)},decode:d=>({memberKey:e.fixed32.decode(d),deviceKey:e.fixed32.decode(d),deviceLength:e.uint.decode(d),clock:e.uint.decode(d),status:vr.decode(d)})},hr={preencode(d,o){e.fixed32.preencode(d,o.hash),e.buffer.preencode(d,o.blob)},encode(d,o){e.fixed32.encode(d,o.hash),e.buffer.encode(d,o.blob)},decode:d=>({hash:e.fixed32.decode(d),blob:e.buffer.decode(d)})},Kr=Rn,wr=Cn,Ar=vn,Tr={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),Kr.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,d>=27&&c.initiator&&o.preencode(n,c.initiator),d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=27&&c.identitySwap&&wr.preencode(n,c.identitySwap),d>=27&&c.identitySwapV2&&Ar.preencode(n,c.identitySwapV2),d>=27&&c.contact&&e.fixed32.preencode(n,c.contact)},encode(n,c){const t=(d>=27&&c.initiator?1:0)|(d>=27&&c.bootFrom?2:0)|(d>=27&&c.identitySwap?4:0)|(d>=27&&c.identitySwapV2?8:0)|(d>=27&&c.contact?16:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),Kr.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,t),d>=27&&c.initiator&&o.encode(n,c.initiator),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom),d>=27&&c.identitySwap&&wr.encode(n,c.identitySwap),d>=27&&c.identitySwapV2&&Ar.encode(n,c.identitySwapV2),d>=27&&c.contact&&e.fixed32.encode(n,c.contact)},decode(n){const c=e.fixed32.decode(n),t=e.buffer.decode(n),r=e.fixed32.decode(n),i=Kr.decode(n),a=e.uint.decode(n),s=e.uint.decode(n);return{roomKey:c,encryptionKey:t,mailbox:r,status:i,clock:a,initiator:d>=27&&1&s?o.decode(n):null,bootFrom:d>=27&&2&s?o.decode(n):null,identitySwap:d>=27&&4&s?wr.decode(n):null,identitySwapV2:d>=27&&8&s?Ar.decode(n):null,contact:d>=27&&16&s?e.fixed32.decode(n):null}}},Sr=$,Pr={preencode(n,c){Sr.preencode(n,c.header),e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),n.end++,d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=27&&c.initiator&&o.preencode(n,c.initiator),d>=27&&c.dm&&e.fixed32.preencode(n,c.dm)},encode(n,c){const t=(d>=27&&c.bootFrom?1:0)|(d>=27&&c.initiator?2:0)|(d>=27&&c.dm?4:0)|(d>=27&&c.isReadOnly?8:0);Sr.encode(n,c.header),e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),e.uint.encode(n,t),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom),d>=27&&c.initiator&&o.encode(n,c.initiator),d>=27&&c.dm&&e.fixed32.encode(n,c.dm)},decode(n){const c=Sr.decode(n),t=e.fixed32.decode(n),r=e.buffer.decode(n),i=e.fixed32.decode(n),a=e.uint.decode(n);return{header:c,roomKey:t,encryptionKey:r,mailbox:i,bootFrom:d>=27&&1&a?o.decode(n):null,initiator:d>=27&&2&a?o.decode(n):null,dm:d>=27&&4&a?e.fixed32.decode(n):null,isReadOnly:d>=27&&!!(8&a)}}},Ir={preencode(d,o){e.fixed32.preencode(d,o.id),e.fixed32.preencode(d,o.writerKey),e.buffer.preencode(d,o.blindResponse)},encode(d,o){e.fixed32.encode(d,o.id),e.fixed32.encode(d,o.writerKey),e.buffer.encode(d,o.blindResponse)},decode:d=>({id:e.fixed32.decode(d),writerKey:e.fixed32.decode(d),blindResponse:e.buffer.decode(d)})},Fr=$,Rr={preencode(d,o){Fr.preencode(d,o.header),e.buffer.preencode(d,o.blindResponse)},encode(d,o){Fr.encode(d,o.header),e.buffer.encode(d,o.blindResponse)},decode:d=>({header:Fr.decode(d),blindResponse:e.buffer.decode(d)})},Cr={preencode(e,d){},encode(e,d){},decode:e=>({key:null})},Hr=ge,Vr={preencode(d,o){e.fixed32.preencode(d,o.id),Hr.preencode(d,o.request)},encode(d,o){e.fixed32.encode(d,o.id),Hr.encode(d,o.request)},decode:d=>({deviceKey:null,id:e.fixed32.decode(d),request:Hr.decode(d)})},Dr=te,Mr=re,Lr={preencode(d,o){e.fixed32.preencode(d,o.memberKey),Dr.preencode(d,o.status),xa.preencode(d,o.profile),d.end++,o.invitation&&Mr.preencode(d,o.invitation)},encode(d,o){const n=o.invitation?1:0;e.fixed32.encode(d,o.memberKey),Dr.encode(d,o.status),xa.encode(d,o.profile),e.uint.encode(d,n),o.invitation&&Mr.encode(d,o.invitation)},decode:d=>({key:null,memberKey:e.fixed32.decode(d),status:Dr.decode(d),profile:xa.decode(d),invitation:1&e.uint.decode(d)?Mr.decode(d):null})},qr={preencode(d,o){d.end++,o.profileAttestation&&e.buffer.preencode(d,o.profileAttestation),o.latestReceipt&&e.buffer.preencode(d,o.latestReceipt)},encode(d,o){const n=(o.profileAttestation?1:0)|(o.latestReceipt?2:0);e.uint.encode(d,n),o.profileAttestation&&e.buffer.encode(d,o.profileAttestation),o.latestReceipt&&e.buffer.encode(d,o.latestReceipt)},decode(d){const o=e.uint.decode(d);return{key:null,profileAttestation:1&o?e.buffer.decode(d):null,latestReceipt:2&o?e.buffer.decode(d):null}}},Er=id,Br=pe,zr={preencode(e,d){Er.preencode(e,d.status),Br.preencode(e,d.profile)},encode(e,d){Er.encode(e,d.status),Br.encode(e,d.profile)},decode:e=>({key:null,status:Er.decode(e),profile:Br.decode(e)})},Nr={preencode(d,o){e.uint.preencode(d,o.mentions)},encode(d,o){e.uint.encode(d,o.mentions)},decode:d=>({key:null,mentions:e.uint.decode(d)})},jr=Ie,Or=Ve,Ur={preencode(e,d){jr.preencode(e,d.response),Or.preencode(e,d.metadata),e.end++,d.anchor&&o.preencode(e,d.anchor)},encode(d,n){const c=(n.anchor?1:0)|(n.isActive?2:0);jr.encode(d,n.response),Or.encode(d,n.metadata),e.uint.encode(d,c),n.anchor&&o.encode(d,n.anchor)},decode(d){const n=jr.decode(d),c=Or.decode(d),t=e.uint.decode(d);return{id:null,response:n,metadata:c,anchor:1&t?o.decode(d):null,isActive:!!(2&t)}}},Jr=fo,Gr={preencode(d,o){e.uint.preencode(d,o.count),d.end++,o.parent&&n.preencode(d,o.parent),o.stats&&Jr.preencode(d,o.stats)},encode(d,o){const c=(o.parent?1:0)|(o.stats?2:0);e.uint.encode(d,o.count),e.uint.encode(d,c),o.parent&&n.encode(d,o.parent),o.stats&&Jr.encode(d,o.stats)},decode(d){const o=e.uint.decode(d),c=e.uint.decode(d);return{id:0,count:o,parent:1&c?n.decode(d):null,stats:2&c?Jr.decode(d):null}}},Qr={preencode(e,d){},encode(e,d){},decode:e=>({thread:0,index:0})},Wr=yo,Xr=bo,Yr=xo,Zr={preencode(d,o){lo.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),Wr.preencode(d,o.status),o.message&&Xr.preencode(d,o.message),o.event&&Yr.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);lo.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),Wr.encode(d,o.status),o.message&&Xr.encode(d,o.message),o.event&&Yr.encode(d,o.event)},decode(d){const o=lo.decode(d),c=n.decode(d),t=e.uint.decode(d),r=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:t,timestamp:r,editedAt:1&i?e.uint.decode(d):0,status:Wr.decode(d),message:2&i?Xr.decode(d):null,event:4&i?Yr.decode(d):null}}},$r=Qr,_r=Mo,ei={preencode(o,n){lo.preencode(o,n.id),e.uint.preencode(o,n.total),_r.preencode(o,n.reactions),o.end++,d>=11&&n.editedAt&&e.uint.preencode(o,n.editedAt)},encode(o,n){const c=d>=11&&n.editedAt?1:0;lo.encode(o,n.id),e.uint.encode(o,n.total),_r.encode(o,n.reactions),e.uint.encode(o,c),d>=11&&n.editedAt&&e.uint.encode(o,n.editedAt)},decode(o){const n=lo.decode(o),c=e.uint.decode(o),t=_r.decode(o),r=o.start<o.end?e.uint.decode(o):0;return{id:n,total:c,reactions:t,editedAt:d>=11&&1&r?e.uint.decode(o):0}}},di=Qr,oi={preencode(d,o){lo.preencode(d,o.id),e.uint.preencode(d,o.clock)},encode(d,o){lo.encode(d,o.id),e.uint.encode(d,o.clock)},decode:d=>({id:lo.decode(d),sender:null,clock:e.uint.decode(d),reaction:null})},ni=T,ci=g,ti={preencode(o,c){n.preencode(o,c.oplog),ni.preencode(o,c.status),ci.preencode(o,c.file),o.end++,d>=14&&c.version&&e.uint.preencode(o,c.version)},encode(o,c){const t=d>=14&&c.version?1:0;n.encode(o,c.oplog),ni.encode(o,c.status),ci.encode(o,c.file),e.uint.encode(o,t),d>=14&&c.version&&e.uint.encode(o,c.version)},decode(o){const c=n.decode(o),t=ni.decode(o),r=ci.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{id:0,oplog:c,status:t,file:r,version:d>=14&&1&i?e.uint.decode(o):0}}},ri=vn,ii={preencode(n,c){e.fixed32.preencode(n,c.invitationSeed),e.fixed32.preencode(n,c.mailbox),t.preencode(n,c.responseKeyPair),o.preencode(n,c.initiator),o.preencode(n,c.inviter),n.end++,c.identity&&ri.preencode(n,c.identity),d>=20&&c.buildType&&Bt.preencode(n,c.buildType),d>=27&&c.link&&o.preencode(n,c.link)},encode(n,c){const r=(c.identity?1:0)|(d>=20&&c.buildType?2:0)|(d>=27&&c.link?4:0);e.fixed32.encode(n,c.invitationSeed),e.fixed32.encode(n,c.mailbox),t.encode(n,c.responseKeyPair),o.encode(n,c.initiator),o.encode(n,c.inviter),e.uint.encode(n,r),c.identity&&ri.encode(n,c.identity),d>=20&&c.buildType&&Bt.encode(n,c.buildType),d>=27&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),r=e.fixed32.decode(n),i=t.decode(n),a=o.decode(n),s=o.decode(n),p=e.uint.decode(n);return{id:null,invitationSeed:c,mailbox:r,responseKeyPair:i,initiator:a,inviter:s,identity:1&p?ri.decode(n):null,buildType:d>=20&&2&p?Bt.decode(n):null,link:d>=27&&4&p?o.decode(n):null}}},ai=Rn,si=Cn,pi=vn,ui={preencode(n,c){e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),ai.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,c.initiator&&o.preencode(n,c.initiator),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),c.identitySwap&&si.preencode(n,c.identitySwap),d>=6&&c.identitySwapV2&&pi.preencode(n,c.identitySwapV2),d>=10&&c.contact&&e.fixed32.preencode(n,c.contact),d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=29&&c.activeClock&&e.uint.preencode(n,c.activeClock)},encode(n,c){const t=(c.initiator?1:0)|(c.fastForwardTo?2:0)|(c.identitySwap?4:0)|(d>=6&&c.identitySwapV2?8:0)|(d>=10&&c.contact?16:0)|(d>=27&&c.bootFrom?32:0)|(d>=29&&c.activeClock?64:0);e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),ai.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,t),c.initiator&&o.encode(n,c.initiator),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),c.identitySwap&&si.encode(n,c.identitySwap),d>=6&&c.identitySwapV2&&pi.encode(n,c.identitySwapV2),d>=10&&c.contact&&e.fixed32.encode(n,c.contact),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom),d>=29&&c.activeClock&&e.uint.encode(n,c.activeClock)},decode(n){const c=e.buffer.decode(n),t=e.fixed32.decode(n),r=ai.decode(n),i=e.uint.decode(n),a=e.uint.decode(n);return{roomKey:null,encryptionKey:c,mailbox:t,status:r,clock:i,initiator:1&a?o.decode(n):null,fastForwardTo:2&a?e.fixed32.decode(n):null,identitySwap:4&a?si.decode(n):null,identitySwapV2:d>=6&&8&a?pi.decode(n):null,contact:d>=10&&16&a?e.fixed32.decode(n):null,bootFrom:d>=27&&32&a?o.decode(n):null,activeClock:d>=29&&64&a?e.uint.decode(n):0}}},li={preencode(o,n){e.uint.preencode(o,n.clock),ka.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=22&&n.contactInfo&&va.preencode(o,n.contactInfo),d>=24&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=22&&n.contactInfo?4:0)|(d>=24&&n.alias?8:0);e.uint.encode(o,n.clock),ka.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=22&&n.contactInfo&&va.encode(o,n.contactInfo),d>=24&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.uint.decode(o),c=ka.decode(o),t=e.uint.decode(o);return{memberKey:null,clock:n,status:c,mailbox:1&t?e.fixed32.decode(o):null,roomKey:2&t?e.fixed32.decode(o):null,contactInfo:d>=22&&4&t?va.decode(o):null,alias:d>=24&&8&t?e.string.decode(o):null}}},fi=pe,mi=nc,yi=$n,bi={preencode(o,n){e.uint.preencode(o,n.clock),fi.preencode(o,n.sender),mi.preencode(o,n.status),yi.preencode(o,n.keys),e.fixed32.preencode(o,n.mailbox),o.end++,n.message&&e.string.preencode(o,n.message),d>=11&&n.sentAt&&e.uint.preencode(o,n.sentAt),d>=22&&n.contactInfo&&ga.preencode(o,n.contactInfo)},encode(o,n){const c=(n.message?1:0)|(d>=11&&n.sentAt?2:0)|(d>=22&&n.contactInfo?4:0);e.uint.encode(o,n.clock),fi.encode(o,n.sender),mi.encode(o,n.status),yi.encode(o,n.keys),e.fixed32.encode(o,n.mailbox),e.uint.encode(o,c),n.message&&e.string.encode(o,n.message),d>=11&&n.sentAt&&e.uint.encode(o,n.sentAt),d>=22&&n.contactInfo&&ga.encode(o,n.contactInfo)},decode(o){const n=e.uint.decode(o),c=fi.decode(o),t=mi.decode(o),r=yi.decode(o),i=e.fixed32.decode(o),a=e.uint.decode(o);return{memberKey:null,clock:n,sender:c,status:t,keys:r,mailbox:i,message:1&a?e.string.decode(o):null,sentAt:d>=11&&2&a?e.uint.decode(o):0,contactInfo:d>=22&&4&a?ga.decode(o):null}}},xi={preencode(d,o){e.uint.preencode(d,o.value)},encode(d,o){e.uint.encode(d,o.value)},decode:d=>({key:0,value:e.uint.decode(d)})},ki={preencode(d,o){ne.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){ne.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({deviceKey:null,privateProfileIdentity:ne.decode(d),deviceProof:e.buffer.decode(d)})},vi={preencode(n,c){n.end++,c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const t=(c.encryptionKey?1:0)|(c.fastForwardTo?2:0)|(d>=27&&c.bootFrom?4:0);e.uint.encode(n,t),c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.uint.decode(n);return{key:null,encryptionKey:1&c?e.buffer.decode(n):null,fastForwardTo:2&c?e.fixed32.decode(n):null,bootFrom:d>=27&&4&c?o.decode(n):null}}},gi=pe,hi=nc,Ki=$n,wi={preencode(o,n){e.uint.preencode(o,n.clock),gi.preencode(o,n.sender),hi.preencode(o,n.status),Ki.preencode(o,n.keys),e.fixed32.preencode(o,n.mailbox),o.end++,n.message&&e.string.preencode(o,n.message),d>=11&&n.sentAt&&e.uint.preencode(o,n.sentAt),d>=22&&n.contactInfo&&ha.preencode(o,n.contactInfo)},encode(o,n){const c=(n.message?1:0)|(d>=11&&n.sentAt?2:0)|(d>=22&&n.contactInfo?4:0);e.uint.encode(o,n.clock),gi.encode(o,n.sender),hi.encode(o,n.status),Ki.encode(o,n.keys),e.fixed32.encode(o,n.mailbox),e.uint.encode(o,c),n.message&&e.string.encode(o,n.message),d>=11&&n.sentAt&&e.uint.encode(o,n.sentAt),d>=22&&n.contactInfo&&ha.encode(o,n.contactInfo)},decode(o){const n=e.uint.decode(o),c=gi.decode(o),t=hi.decode(o),r=Ki.decode(o),i=e.fixed32.decode(o),a=e.uint.decode(o);return{memberKey:null,clock:n,sender:c,status:t,keys:r,mailbox:i,message:1&a?e.string.decode(o):null,sentAt:d>=11&&2&a?e.uint.decode(o):0,contactInfo:d>=22&&4&a?ha.decode(o):null}}},Ai={preencode(d,o){e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.key)},decode:d=>({deviceKey:null,key:e.fixed32.decode(d)})},Ti=Qr,Si={preencode(d,o){lo.preencode(d,o.id),e.uint.preencode(d,o.clock)},encode(d,o){lo.encode(d,o.id),e.uint.encode(d,o.clock)},decode:d=>({id:lo.decode(d),sender:null,clock:e.uint.decode(d),label:0})},Pi=Qr,Ii=Zc,Fi={preencode(o,n){lo.preencode(o,n.id),e.uint.preencode(o,n.total),Ii.preencode(o,n.labels),e.uint.preencode(o,n.editedAt),o.end++,d>=15&&n.flagsClock&&e.uint.preencode(o,n.flagsClock),d>=15&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(d>=15&&n.flagsClock?1:0)|(d>=15&&n.version?2:0)|(d>=16&&n.isDeleted?4:0);lo.encode(o,n.id),e.uint.encode(o,n.total),Ii.encode(o,n.labels),e.uint.encode(o,n.editedAt),e.uint.encode(o,c),d>=15&&n.flagsClock&&e.uint.encode(o,n.flagsClock),d>=15&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=lo.decode(o),c=e.uint.decode(o),t=Ii.decode(o),r=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{id:n,total:c,labels:t,editedAt:r,flagsClock:d>=15&&1&i?e.uint.decode(o):0,version:d>=15&&2&i?e.uint.decode(o):0,isDeleted:d>=16&&!!(4&i)}}},Ri={preencode(d,o){e.uint.preencode(d,o.length)},encode(d,o){e.uint.encode(d,o.length)},decode:d=>({memberKey:null,length:e.uint.decode(d)})},Ci=Cr,Hi={preencode(d,o){e.uint.preencode(d,o.clock)},encode(d,o){e.uint.encode(d,o.clock)},decode:d=>({key:null,sender:null,clock:e.uint.decode(d),label:0})},Vi=yt,Di={preencode(d,o){e.uint.preencode(d,o.total),Vi.preencode(d,o.labels),e.uint.preencode(d,o.editedAt),e.uint.preencode(d,o.flagsClock)},encode(d,o){e.uint.encode(d,o.total),Vi.encode(d,o.labels),e.uint.encode(d,o.editedAt),e.uint.encode(d,o.flagsClock)},decode:d=>({key:null,total:e.uint.decode(d),labels:Vi.decode(d),editedAt:e.uint.decode(d),flagsClock:e.uint.decode(d)})},Mi={preencode(o,n){e.buffer.preencode(o,n.encryptionKey),e.uint.preencode(o,n.createdAt),o.end++,d>=19&&n.endedAt&&e.uint.preencode(o,n.endedAt),d>=19&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=19&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(d>=19&&n.endedAt?1:0)|(d>=19&&n.discoveryKey?2:0)|(d>=19&&n.version?4:0);e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=19&&n.endedAt&&e.uint.encode(o,n.endedAt),d>=19&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=19&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=e.buffer.decode(o),c=e.uint.decode(o),t=e.uint.decode(o);return{callKey:null,encryptionKey:n,createdAt:c,endedAt:d>=19&&1&t?e.uint.decode(o):0,discoveryKey:d>=19&&2&t?e.fixed32.decode(o):null,version:d>=19&&4&t?e.uint.decode(o):0}}},Li={preencode(d,o){e.uint.preencode(d,o.createdAt)},encode(d,o){e.uint.encode(d,o.createdAt)},decode:d=>({callKey:null,memberKey:null,createdAt:e.uint.decode(d)})},qi={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.createdAt),o.end++,d>=19&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),d>=22&&n.lastHeartbeatAt&&e.uint.preencode(o,n.lastHeartbeatAt)},encode(o,n){const c=(d>=19&&n.swarmKey?1:0)|(d>=22&&n.lastHeartbeatAt?2:0)|(d>=23&&n.isRecording?4:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=19&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey),d>=22&&n.lastHeartbeatAt&&e.uint.encode(o,n.lastHeartbeatAt)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),t=e.uint.decode(o);return{callKey:null,deviceKey:null,memberKey:n,createdAt:c,swarmKey:d>=19&&1&t?e.fixed32.decode(o):null,lastHeartbeatAt:d>=22&&2&t?e.uint.decode(o):0,isRecording:d>=23&&!!(4&t)}}},Ei={preencode(o,n){e.fixed32.preencode(o,n.deviceKey),e.uint.preencode(o,n.createdAt),o.end++,d>=26&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=26&&n.type&&e.string.preencode(o,n.type),d>=26&&n.statusKey&&e.uint.preencode(o,n.statusKey)},encode(o,n){const c=(d>=26&&n.mediaStreamId?1:0)|(d>=26&&n.type?2:0)|(d>=26&&n.statusKey?4:0);e.fixed32.encode(o,n.deviceKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=26&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=26&&n.type&&e.string.encode(o,n.type),d>=26&&n.statusKey&&e.uint.encode(o,n.statusKey)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),t=o.start<o.end?e.uint.decode(o):0;return{callKey:null,deviceKey:n,streamKey:null,createdAt:c,mediaStreamId:d>=26&&1&t?e.string.decode(o):null,type:d>=26&&2&t?e.string.decode(o):null,statusKey:d>=26&&4&t?e.uint.decode(o):0}}},Bi=Ai,zi={preencode(d,o){e.uint.preencode(d,o.timestamp)},encode(d,o){e.uint.encode(d,o.timestamp)},decode:d=>({memberKey:null,timestamp:e.uint.decode(d)})},Ni={preencode(e,d){e.end++},encode(o,n){const c=d>=26&&n.muted?1:0;e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{statusKey:0,muted:d>=26&&!!(1&n)}}},ji=id,Oi={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.uint.preencode(d,o.deviceLength),e.uint.preencode(d,o.clock),ji.preencode(d,o.status)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,o.deviceLength),e.uint.encode(d,o.clock),ji.encode(d,o.status)},decode:d=>({memberKey:null,deviceKey:e.fixed32.decode(d),deviceLength:e.uint.decode(d),clock:e.uint.decode(d),status:ji.decode(d)})},Ui={preencode(d,o){e.buffer.preencode(d,o.data)},encode(d,o){e.buffer.encode(d,o.data)},decode:d=>({hash:null,data:e.buffer.decode(d)})},Ji={preencode(d,o){e.fixed32.preencode(d,o.writerKey),e.buffer.preencode(d,o.blindResponse)},encode(d,o){e.fixed32.encode(d,o.writerKey),e.buffer.encode(d,o.blindResponse)},decode:d=>({id:null,writerKey:e.fixed32.decode(d),blindResponse:e.buffer.decode(d)})},Gi=e.frame(w),Qi=e.frame(ir),Wi=Gi,Xi=e.array(Mc),Yi=e.frame(se),Zi=Gi,$i=Yi,_i=e.frame(hc),ea=e.frame(kr),da=Yi,oa=e.frame(fd),na=e.frame(yc),ca=e.frame(xt),ta=ca,ra=e.array(e.frame(qc)),ia=Gi,aa=e.frame(Nn),sa=e.frame(xc),pa=aa,ua=sa,la=aa,fa=sa,ma=Gi,ya=e.array(e.frame(ar)),ba=ya,xa=Yi,ka=aa,va=sa,ga=sa,ha=sa;function Ka(e){switch(e){case"@keet/head":return o;case"@keet/oplog-id":return n;case"@keet/encryption-keypair":return c;case"@keet/signing-keypair":return t;case"@keet/room-keys":return r;case"@keet/operation-header":return i;case"@keet/blob-pointer":return a;case"@keet/file-dimensions":return s;case"@keet/file-metadata":return u;case"@keet/external-drive-pointer":return l;case"@keet/external-blob-pointer":return f;case"@keet/file-pointer":return b;case"@keet/file":return v;case"@keet/image-file":return w;case"@keet/file-status":return A;case"@keet/file-record":return P;case"@keet/device-status":return I;case"@keet/member-status":return F;case"@keet/member-moderation-status":return R;case"@keet/abi":return C;case"@keet/device-stats":return H;case"@keet/member-stats":return V;case"@keet/chat-stats":return D;case"@keet/file-stats":return M;case"@keet/stats":return z;case"@keet/room-type":return j;case"@keet/system-settings":return O;case"@keet/system-digest":return G;case"@keet/room-seed":return Q;case"@keet/room-capabilities":return W;case"@keet/room-config":return Y;case"@keet/blind-peer":return Z;case"@keet/add-blind-peer-operation":return ee;case"@keet/remove-blind-peer-operation":return oe;case"@keet/identity-attestation":return ne;case"@keet/device-invitation":return ce;case"@keet/device":return ie;case"@keet/member-profile":return ae;case"@keet/device-profile":return se;case"@keet/member-update":return ue;case"@keet/device-update":return le;case"@keet/signed-pairing-data":return fe;case"@keet/device-request-identity":return me;case"@keet/device-response-identity":return ye;case"@keet/device-request-with-invitation":return ve;case"@keet/device-request-with-invitation-and-proof":return he;case"@keet/device-request-with-member-proof":return Ae;case"@keet/device-request":return Pe;case"@keet/device-response":return Re;case"@keet/invitation-metadata":return Ce;case"@keet/invitation":return De;case"@keet/add-invitation-operation":return qe;case"@keet/remove-invitation-operation":return Be;case"@keet/sendable-room-invitation":return ze;case"@keet/sendable-identity-invitation":return Ne;case"@keet/sendable-contact-invitation":return je;case"@keet/sendable-invitation":return Qe;case"@keet/add-device-operation":return Xe;case"@keet/update-device-operation":return Ze;case"@keet/start-indexing-operation":return $e;case"@keet/stop-indexing-operation":return _e;case"@keet/join-request":return dd;case"@keet/accept-join-request-operation":return cd;case"@keet/reject-join-request-operation":return rd;case"@keet/member":return sd;case"@keet/full-member":return ld;case"@keet/member-proofs":return fd;case"@keet/update-member-operation":return bd;case"@keet/change-member-status-operation":return vd;case"@keet/change-member-role-operation":return hd;case"@keet/remove-member-operation":return wd;case"@keet/member-activity":return Ad;case"@keet/member-joined-event":return Td;case"@keet/member-left-event":return Sd;case"@keet/title-changed-chat-event":return Pd;case"@keet/chat-event":return Cd;case"@keet/sendable-event":return Hd;case"@keet/display-range":return Vd;case"@keet/display-content-range":return Md;case"@keet/mention-display-item":return qd;case"@keet/link-preview":return zd;case"@keet/display-link-item":return Od;case"@keet/display":return _d;case"@keet/oplog-message":return co;case"@keet/index-message":return io;case"@keet/full-index-message":return po;case"@keet/message-status":return uo;case"@keet/message-index-id":return lo;case"@keet/thread":return mo;case"@keet/chat-message-record":return ko;case"@keet/full-chat-message-record":return Ko;case"@keet/add-chat-message-operation":return To;case"@keet/remove-chat-message-operation":return Po;case"@keet/update-chat-message-operation":return Ro;case"@keet/pin-chat-message-operation":return Ho;case"@keet/reaction":return Vo;case"@keet/reactions-summary":return Do;case"@keet/reactions-digest":return Lo;case"@keet/add-reaction-operation":return Eo;case"@keet/remove-reaction-operation":return zo;case"@keet/update-room-config-operation":return Oo;case"@keet/group-member":return Uo;case"@keet/user-registry-info":return Jo;case"@keet/room-identity":return Qo;case"@keet/genesis-operation":return dn;case"@keet/upgrade-operation":return nn;case"@keet/update-system-settings-operation":return rn;case"@keet-private-id/contact":return an;case"@keet-private-id/v3-room-migration-info":return sn;case"@keet-private-id/run-v3-migration-operation":return ln;case"@keet-private-id/update-identity-operation":return mn;case"@keet-private-id/counters":return yn;case"@keet-private-id/stats":return bn;case"@keet-private-id/add-entropy-operation":return xn;case"@keet-private-id/pending-invitation-identity":return kn;case"@keet-private-id/pending-invitation":return gn;case"@keet-private-id/resolve-pending-invitation-operation":return Kn;case"@keet-private-id/add-pending-invitation-operation":return Tn;case"@keet-private-id/remove-pending-invitation-operation":return Pn;case"@keet-private-id/identity-swap":return In;case"@keet-private-id/room-status":return Fn;case"@keet-private-id/room":return Vn;case"@keet-private-id/add-room-operation":return Mn;case"@keet-private-id/remove-room-operation":return qn;case"@keet-private-id/update-room-status-operation":return zn;case"@keet-private-id/contact-status":return Nn;case"@keet-private-id/contact-record":return jn;case"@keet-private-id/add-contact-operation":return Jn;case"@keet-private-id/update-contact-status-operation":return Qn;case"@keet-private-id/remove-contact-operation":return Xn;case"@keet-private-id/contact-request-status":return Yn;case"@keet-private-id/contact-request-body":return _n;case"@keet-private-id/contact-request":return dc;case"@keet-private-id/contact-request-record":return tc;case"@keet-private-id/add-contact-request-operation":return ic;case"@keet-private-id/update-contact-request-status-operation":return pc;case"@keet-private-id/profile-discovery-record-v1":return uc;case"@keet-private-id/profile-discovery-record":return lc;case"@keet/add-file-preview-operation":return mc;case"@keet/member-removed-event":return yc;case"@keet/member-contact-info":return xc;case"@keet/remove-device-operation":return vc;case"@keet/device-identity":return gc;case"@keet/readonly-room-invitation":return hc;case"@keet-private-id/identity-swap-v2":return Kc;case"@keet-private-id/activate-contact-room-operation":return Ac;case"@keet/display-type":return Sc;case"@keet/test-increment-operation":return Ic;case"@keet/test-collection-record-1":return Fc;case"@keet/migrate-abi-operation":return Cc;case"@keet/system-settings-keys":return Vc;case"@keet/room-supported-language":return Mc;case"@keet/translation-display-item":return qc;case"@keet-private-id/unreads":return Ec;case"@keet-private-id/add-unreads-key-operation":return zc;case"@keet-private-id/remove-unreads-key-operation":return jc;case"@keet/label-type":return Uc;case"@keet/chat-label":return Jc;case"@keet/add-chat-label-operation":return Qc;case"@keet/remove-chat-label-operation":return Xc;case"@keet/chat-label-summary":return Yc;case"@keet/chat-label-digest":return $c;case"@keet/update-read-length-operation":return et;case"@keet/read-length":return dt;case"@keet/tmp-removed-member":return ot;case"@keet-private-id/settings":return nt;case"@keet-private-id/user-settings-key":return tt;case"@keet-private-id/update-settings-operation":return at;case"@keet/member-label-type":return pt;case"@keet/member-label":return ut;case"@keet/add-member-label-operation":return ft;case"@keet/member-label-summary":return mt;case"@keet/member-label-digest":return bt;case"@keet/location-shared-event":return xt;case"@keet/move-indexer-operation":return vt;case"@keet/start-call":return Kt;case"@keet/join-call":return Tt;case"@keet/leave-call":return Pt;case"@keet/end-call":return Ft;case"@keet/add-call-stream":return Ct;case"@keet/remove-call-stream":return Vt;case"@keet/call-record":return Dt;case"@keet/call-member-record":return Mt;case"@keet/call-device-record":return Lt;case"@keet/call-stream-record":return qt;case"@keet/build-type":return Bt;case"@keet/test-crash-operation":return Nt;case"@keet/test-dispatch-error-operation":return Ot;case"@keet-private-id/shorten-device-attestation-operation":return Jt;case"@keet/call-device-heartbeat":return Qt;case"@keet/remove-call-device":return Xt;case"@keet/start-call-recording":return Zt;case"@keet/stop-call-recording":return _t;case"@keet/dismiss-chat-reports-operation":return dr;case"@keet/update-typing-indicator-operation":return nr;case"@keet/typing-indicator":return cr;case"@keet-private-id/update-contact-alias-operation":return rr;case"@keet/call-stats":return ir;case"@keet/call-stream-input":return ar;case"@keet/update-call-stream":return pr;case"@keet/call-stream-status-record":return ur;case"@keet/room-keys-v2":return lr;case"@keet/blob-pointer-v2":return fr;case"@keet/blob":return mr;case"@keet/autobee-migration":return yr;case"@keet/autobee-migration-operation":return xr;case"@keet/readonly-room-invitation-v2":return kr;case"@keet/admin-last-seen":return gr;case"@keet/blob-record":return hr;case"@keet-private-id/room-v2":return Tr;case"@keet-private-id/add-room-operation-v2":return Pr;case"@keet-private-id/pending-invitation-response":return Ir;case"@keet-private-id/resolve-pending-invitation-operation-v2":return Rr;case"@keet/blind-peer/hyperdb#1":return Cr;case"@keet/join-request/hyperdb#4":return Vr;case"@keet/device/hyperdb#5":return Lr;case"@keet/member-proofs/hyperdb#10":return qr;case"@keet/member/hyperdb#11":return zr;case"@keet/member-activity/hyperdb#17":return Nr;case"@keet/invitation/hyperdb#18":return Ur;case"@keet/thread/hyperdb#19":return Gr;case"@keet/message-index-id/hyperdb#21":return Qr;case"@keet/chat-message-record/hyperdb#21":return Zr;case"@keet/message-index-id/hyperdb#25":return $r;case"@keet/reactions-digest/hyperdb#25":return ei;case"@keet/message-index-id/hyperdb#26":return di;case"@keet/reaction/hyperdb#26":return oi;case"@keet/file-record/hyperdb#28":return ti;case"@keet-private-id/pending-invitation/hyperdb#35":return ii;case"@keet-private-id/room/hyperdb#36":return ui;case"@keet-private-id/contact-record/hyperdb#38":return li;case"@keet-private-id/contact-request-record/hyperdb#40":return bi;case"@keet/test-collection-record-1/hyperdb#46":return xi;case"@keet/device-identity/hyperdb#50":return ki;case"@keet/room-keys/hyperdb#51":return vi;case"@keet-private-id/contact-request-record/hyperdb#51":return wi;case"@keet-private-id/unreads/hyperdb#59":return Ai;case"@keet/message-index-id/hyperdb#60":return Ti;case"@keet/chat-label/hyperdb#60":return Si;case"@keet/message-index-id/hyperdb#61":return Pi;case"@keet/chat-label-digest/hyperdb#61":return Fi;case"@keet/read-length/hyperdb#62":return Ri;case"@keet/tmp-removed-member/hyperdb#63":return Ci;case"@keet/member-label/hyperdb#66":return Hi;case"@keet/member-label-digest/hyperdb#67":return Di;case"@keet/call-record/hyperdb#69":return Mi;case"@keet/call-member-record/hyperdb#72":return Li;case"@keet/call-device-record/hyperdb#73":return qi;case"@keet/call-stream-record/hyperdb#75":return Ei;case"@keet-private-id/unreads/hyperdb#77":return Bi;case"@keet/typing-indicator/hyperdb#78":return zi;case"@keet/call-stream-status-record/hyperdb#80":return Ni;case"@keet/admin-last-seen/hyperdb#81":return Oi;case"@keet/blob/hyperdb#83":return Ui;case"@keet-private-id/pending-invitation-response/hyperdb#85":return Ji;default:throw new Error("Encoder not found "+e)}}function wa(e,o=29){const n=Ka(e);return{preencode(e,c){d=o,n.preencode(e,c)},encode(e,c){d=o,n.encode(e,c)},decode:e=>(d=o,n.decode(e))}}const Aa=wa;module.exports={resolveStruct:Aa,getStruct:wa,getEnum:function(e){switch(e){case"@keet/room-type":return N;case"@keet/display-type":return Tc;case"@keet/system-settings-keys":return Hc;case"@keet/room-supported-language":return Dc;case"@keet/label-type":return Oc;case"@keet-private-id/user-settings-key":return ct;case"@keet/member-label-type":return st;case"@keet/build-type":return Et;default:throw new Error("Enum not found "+e)}},getEncoding:Ka,encode:function(o,n,c=29){return d=c,e.encode(Ka(o),n)},decode:function(o,n,c=29){return d=c,e.decode(Ka(o),n)},setVersion:function(e){d=e},version:d};
1const{c:e}=require("hyperschema/runtime");let d=31;const o={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.length)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.length)},decode:d=>({key:e.fixed32.decode(d),length:e.uint.decode(d)})},n={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.seq)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.seq)},decode:d=>({key:e.fixed32.decode(d),seq:e.uint.decode(d)})},c={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.secretKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.secretKey)},decode:d=>({publicKey:e.fixed32.decode(d),secretKey:e.fixed32.decode(d)})},t={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed64.preencode(d,o.secretKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed64.encode(d,o.secretKey)},decode:d=>({publicKey:e.fixed32.decode(d),secretKey:e.fixed64.decode(d)})},r={preencode(n,c){e.fixed32.preencode(n,c.key),n.end++,c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const t=(c.encryptionKey?1:0)|(c.fastForwardTo?2:0)|(d>=27&&c.bootFrom?4:0);e.fixed32.encode(n,c.key),e.uint.encode(n,t),c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),t=e.uint.decode(n);return{key:c,encryptionKey:1&t?e.buffer.decode(n):null,fastForwardTo:2&t?e.fixed32.decode(n):null,bootFrom:d>=27&&4&t?o.decode(n):null}}},i={preencode(d,o){e.uint.preencode(d,o.timestamp)},encode(d,o){e.uint.encode(d,o.timestamp)},decode:d=>({timestamp:e.uint.decode(d)})},a={preencode(d,o){e.uint.preencode(d,o.blockOffset),e.uint.preencode(d,o.blockLength),e.uint.preencode(d,o.byteOffset),e.uint.preencode(d,o.byteLength)},encode(d,o){e.uint.encode(d,o.blockOffset),e.uint.encode(d,o.blockLength),e.uint.encode(d,o.byteOffset),e.uint.encode(d,o.byteLength)},decode:d=>({blockOffset:e.uint.decode(d),blockLength:e.uint.decode(d),byteOffset:e.uint.decode(d),byteLength:e.uint.decode(d)})},s={preencode(d,o){e.uint.preencode(d,o.width),e.uint.preencode(d,o.height)},encode(d,o){e.uint.encode(d,o.width),e.uint.encode(d,o.height)},decode:d=>({width:e.uint.decode(d),height:e.uint.decode(d)})},p=e.frame(s),u={preencode(d,o){d.end++,o.name&&e.string.preencode(d,o.name),o.mimetype&&e.string.preencode(d,o.mimetype),o.dimensions&&p.preencode(d,o.dimensions),o.userdata&&e.buffer.preencode(d,o.userdata),o.duration&&e.uint.preencode(d,o.duration)},encode(d,o){const n=(o.name?1:0)|(o.mimetype?2:0)|(o.dimensions?4:0)|(o.userdata?8:0)|(o.duration?16:0)|(o.isPreview?32:0);e.uint.encode(d,n),o.name&&e.string.encode(d,o.name),o.mimetype&&e.string.encode(d,o.mimetype),o.dimensions&&p.encode(d,o.dimensions),o.userdata&&e.buffer.encode(d,o.userdata),o.duration&&e.uint.encode(d,o.duration)},decode(d){const o=e.uint.decode(d);return{name:1&o?e.string.decode(d):null,mimetype:2&o?e.string.decode(d):null,dimensions:4&o?p.decode(d):null,userdata:8&o?e.buffer.decode(d):null,duration:16&o?e.uint.decode(d):0,isPreview:!!(32&o)}}},l={preencode(d,o){e.fixed32.preencode(d,o.key),e.string.preencode(d,o.path),e.uint.preencode(d,o.version),e.uint.preencode(d,o.size)},encode(d,o){e.fixed32.encode(d,o.key),e.string.encode(d,o.path),e.uint.encode(d,o.version),e.uint.encode(d,o.size)},decode:d=>({key:e.fixed32.decode(d),path:e.string.decode(d),version:e.uint.decode(d),size:e.uint.decode(d)})},f={preencode(d,o){e.fixed32.preencode(d,o.key),a.preencode(d,o.blob)},encode(d,o){e.fixed32.encode(d,o.key),a.encode(d,o.blob)},decode:d=>({key:e.fixed32.decode(d),blob:a.decode(d)})},m=e.frame(f),y=e.frame(l),b={preencode(o,n){o.end++,n.inlined&&e.buffer.preencode(o,n.inlined),n.blob&&a.preencode(o,n.blob),n.externalBlob&&m.preencode(o,n.externalBlob),n.externalDrive&&y.preencode(o,n.externalDrive),d>=27&&n.bee&&fr.preencode(o,n.bee)},encode(o,n){const c=(n.inlined?1:0)|(n.blob?2:0)|(n.externalBlob?4:0)|(n.externalDrive?8:0)|(d>=27&&n.bee?16:0);e.uint.encode(o,c),n.inlined&&e.buffer.encode(o,n.inlined),n.blob&&a.encode(o,n.blob),n.externalBlob&&m.encode(o,n.externalBlob),n.externalDrive&&y.encode(o,n.externalDrive),d>=27&&n.bee&&fr.encode(o,n.bee)},decode(o){const n=e.uint.decode(o);return{inlined:1&n?e.buffer.decode(o):null,blob:2&n?a.decode(o):null,externalBlob:4&n?m.decode(o):null,externalDrive:8&n?y.decode(o):null,bee:d>=27&&16&n?fr.decode(o):null}}},x=e.frame(b),k=e.frame(u),v={preencode(d,o){x.preencode(d,o.pointer),d.end++,o.metadata&&k.preencode(d,o.metadata),o.preview&&da.preencode(d,o.preview),o.hash&&e.fixed32.preencode(d,o.hash)},encode(d,o){const n=(o.metadata?1:0)|(o.preview?2:0)|(o.hash?4:0);x.encode(d,o.pointer),e.uint.encode(d,n),o.metadata&&k.encode(d,o.metadata),o.preview&&da.encode(d,o.preview),o.hash&&e.fixed32.encode(d,o.hash)},decode(d){const o=x.decode(d),n=e.uint.decode(d);return{pointer:o,metadata:1&n?k.decode(d):null,preview:2&n?da.decode(d):null,hash:4&n?e.fixed32.decode(d):null}}},g=e.frame(v),h=g,K=g,w={preencode(e,d){e.end++,d.small&&g.preencode(e,d.small),d.medium&&h.preencode(e,d.medium),d.large&&K.preencode(e,d.large)},encode(d,o){const n=(o.small?1:0)|(o.medium?2:0)|(o.large?4:0);e.uint.encode(d,n),o.small&&g.encode(d,o.small),o.medium&&h.encode(d,o.medium),o.large&&K.encode(d,o.large)},decode(d){const o=e.uint.decode(d);return{small:1&o?g.decode(d):null,medium:2&o?h.decode(d):null,large:4&o?K.decode(d):null}}},A={preencode(e,d){e.end++},encode(d,o){const n=o.isDeleted?1:0;e.uint.encode(d,n)},decode:d=>({isDeleted:!!(1&e.uint.decode(d))})},T=e.frame(A),S=g,P={preencode(o,c){e.uint.preencode(o,c.id),n.preencode(o,c.oplog),T.preencode(o,c.status),S.preencode(o,c.file),o.end++,d>=14&&c.version&&e.uint.preencode(o,c.version)},encode(o,c){const t=d>=14&&c.version?1:0;e.uint.encode(o,c.id),n.encode(o,c.oplog),T.encode(o,c.status),S.encode(o,c.file),e.uint.encode(o,t),d>=14&&c.version&&e.uint.encode(o,c.version)},decode(o){const c=e.uint.decode(o),t=n.decode(o),r=T.decode(o),i=S.decode(o),a=o.start<o.end?e.uint.decode(o):0;return{id:c,oplog:t,status:r,file:i,version:d>=14&&1&a?e.uint.decode(o):0}}},I={preencode(e,d){e.end++},encode(d,o){const n=(o.isActive?1:0)|(o.isIndexing?2:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isActive:!!(1&o),isIndexing:!!(2&o)}}},F={preencode(o,n){const c=(n.isAdmin?1:0)|(n.isModerator?2:0)|(n.isPending?4:0)|(n.isActive?8:0)|(n.isMuted?16:0)|(n.isBanned?32:0)|(n.isShadowBanned?64:0)|(d>=13&&n.isRemoved?128:0);e.uint.preencode(o,c)},encode(o,n){const c=(n.isAdmin?1:0)|(n.isModerator?2:0)|(n.isPending?4:0)|(n.isActive?8:0)|(n.isMuted?16:0)|(n.isBanned?32:0)|(n.isShadowBanned?64:0)|(d>=13&&n.isRemoved?128:0);e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{isAdmin:!!(1&n),isModerator:!!(2&n),isPending:!!(4&n),isActive:!!(8&n),isMuted:!!(16&n),isBanned:!!(32&n),isShadowBanned:!!(64&n),isRemoved:d>=13&&!!(128&n)}}},R={preencode(e,d){e.end++},encode(d,o){const n=(o.isMuted?1:0)|(o.isBanned?2:0)|(o.isShadowBanned?4:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isMuted:!!(1&o),isBanned:!!(2&o),isShadowBanned:!!(4&o)}}},C={preencode(d,o){e.uint.preencode(d,o.version)},encode(d,o){e.uint.encode(d,o.version)},decode:d=>({version:e.uint.decode(d)})},H={preencode(d,o){e.uint.preencode(d,o.total),e.uint.preencode(d,o.active)},encode(d,o){e.uint.encode(d,o.total),e.uint.encode(d,o.active)},decode:d=>({total:e.uint.decode(d),active:e.uint.decode(d)})},V={preencode(d,o){e.uint.preencode(d,o.total),e.uint.preencode(d,o.active),e.uint.preencode(d,o.pending)},encode(d,o){e.uint.encode(d,o.total),e.uint.encode(d,o.active),e.uint.encode(d,o.pending)},decode:d=>({total:e.uint.decode(d),active:e.uint.decode(d),pending:e.uint.decode(d)})},D={preencode(o,n){e.uint.preencode(o,n.clock),e.uint.preencode(o,n.pinned),e.uint.preencode(o,n.threads),e.uint.preencode(o,n.timestamp),o.end++,d>=15&&n.flagsClock&&e.uint.preencode(o,n.flagsClock)},encode(o,n){const c=d>=15&&n.flagsClock?1:0;e.uint.encode(o,n.clock),e.uint.encode(o,n.pinned),e.uint.encode(o,n.threads),e.uint.encode(o,n.timestamp),e.uint.encode(o,c),d>=15&&n.flagsClock&&e.uint.encode(o,n.flagsClock)},decode(o){const n=e.uint.decode(o),c=e.uint.decode(o),t=e.uint.decode(o),r=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{clock:n,pinned:c,threads:t,timestamp:r,flagsClock:d>=15&&1&i?e.uint.decode(o):0}}},M={preencode(d,o){e.uint.preencode(d,o.clock)},encode(d,o){e.uint.encode(d,o.clock)},decode:d=>({clock:e.uint.decode(d)})},L=e.frame(H),q=e.frame(V),E=e.frame(D),B=e.frame(M),z={preencode(e,o){L.preencode(e,o.devices),q.preencode(e,o.members),E.preencode(e,o.chat),B.preencode(e,o.files),e.end++,d>=26&&o.calls&&oa.preencode(e,o.calls)},encode(o,n){const c=d>=26&&n.calls?1:0;L.encode(o,n.devices),q.encode(o,n.members),E.encode(o,n.chat),B.encode(o,n.files),e.uint.encode(o,c),d>=26&&n.calls&&oa.encode(o,n.calls)},decode(o){const n=L.decode(o),c=q.decode(o),t=E.decode(o),r=B.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{devices:n,members:c,chat:t,files:r,calls:d>=26&&1&i?oa.decode(o):null}}},N={Default:1,Broadcast:2,DirectMessage:3},j={preencode(e,d){e.end++},encode(d,o){if(o>3)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},O={preencode(o,n){const c=(n.roomType?1:0)|(n.isExperimental?2:0)|(n.isJoiningDisabled?4:0)|(n.isAppendingDisabled?8:0)|(n.isCallingDisabled?16:0)|(n.isMembershipEventsDisabled?32:0)|(d>=19&&n.isAttachmentsDisabled?64:0)|(d>=19&&n.isLinksDisabled?128:0)|(d>=20&&n.buildType?256:0)|(d>=23&&n.isRoomInviteHidden?512:0);e.uint.preencode(o,c),n.roomType&&j.preencode(o,n.roomType),d>=20&&n.buildType&&Bt.preencode(o,n.buildType)},encode(o,n){const c=(n.roomType?1:0)|(n.isExperimental?2:0)|(n.isJoiningDisabled?4:0)|(n.isAppendingDisabled?8:0)|(n.isCallingDisabled?16:0)|(n.isMembershipEventsDisabled?32:0)|(d>=19&&n.isAttachmentsDisabled?64:0)|(d>=19&&n.isLinksDisabled?128:0)|(d>=20&&n.buildType?256:0)|(d>=23&&n.isRoomInviteHidden?512:0);e.uint.encode(o,c),n.roomType&&j.encode(o,n.roomType),d>=20&&n.buildType&&Bt.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{roomType:1&n?j.decode(o):0,isExperimental:!!(2&n),isJoiningDisabled:!!(4&n),isAppendingDisabled:!!(8&n),isCallingDisabled:!!(16&n),isMembershipEventsDisabled:!!(32&n),isAttachmentsDisabled:d>=19&&!!(64&n),isLinksDisabled:d>=19&&!!(128&n),buildType:d>=20&&256&n?Bt.decode(o):null,isRoomInviteHidden:d>=23&&!!(512&n)}}},U=e.frame(C),J=e.frame(O),G={preencode(d,o){U.preencode(d,o.abi),J.preencode(d,o.settings),e.uint.preencode(d,o.creationTime)},encode(d,o){U.encode(d,o.abi),J.encode(d,o.settings),e.uint.encode(d,o.creationTime)},decode:d=>({abi:U.decode(d),settings:J.decode(d),creationTime:e.uint.decode(d)})},Q={preencode(d,o){e.fixed32.preencode(d,o.seed)},encode(d,o){e.fixed32.encode(d,o.seed)},decode:d=>({seed:e.fixed32.decode(d)})},W={preencode(d,o){c.preencode(d,o.mailboxKeyPair),t.preencode(d,o.discoveryKeyPair),e.fixed32.preencode(d,o.wakeupTopic),e.fixed32.preencode(d,o.swarmTopic)},encode(d,o){c.encode(d,o.mailboxKeyPair),t.encode(d,o.discoveryKeyPair),e.fixed32.encode(d,o.wakeupTopic),e.fixed32.encode(d,o.swarmTopic)},decode:d=>({mailboxKeyPair:c.decode(d),discoveryKeyPair:t.decode(d),wakeupTopic:e.fixed32.decode(d),swarmTopic:e.fixed32.decode(d)})},X=e.array(e.fixed32),Y={preencode(o,n){o.end++,n.title&&e.string.preencode(o,n.title),n.avatar&&na.preencode(o,n.avatar),n.description&&e.string.preencode(o,n.description),d>=11&&n.supportedLanguages&&ca.preencode(o,n.supportedLanguages),d>=13&&n.blindPeers&&X.preencode(o,n.blindPeers)},encode(o,n){const c=(n.title?1:0)|(n.avatar?2:0)|(n.description?4:0)|(d>=11&&n.supportedLanguages?8:0)|(d>=13&&n.blindPeers?16:0);e.uint.encode(o,c),n.title&&e.string.encode(o,n.title),n.avatar&&na.encode(o,n.avatar),n.description&&e.string.encode(o,n.description),d>=11&&n.supportedLanguages&&ca.encode(o,n.supportedLanguages),d>=13&&n.blindPeers&&X.encode(o,n.blindPeers)},decode(o){const n=e.uint.decode(o);return{title:1&n?e.string.decode(o):null,avatar:2&n?na.decode(o):null,description:4&n?e.string.decode(o):null,supportedLanguages:d>=11&&8&n?ca.decode(o):null,blindPeers:d>=13&&16&n?X.decode(o):null}}},Z={preencode(d,o){e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.key)},decode:d=>({key:e.fixed32.decode(d)})},$=e.frame(i),_=e.frame(Z),ee={preencode(e,d){$.preencode(e,d.header),_.preencode(e,d.peer)},encode(e,d){$.encode(e,d.header),_.encode(e,d.peer)},decode:e=>({header:$.decode(e),peer:_.decode(e)})},de=$,oe={preencode(d,o){de.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){de.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:de.decode(d),key:e.fixed32.decode(d)})},ne={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.buffer.preencode(d,o.proof)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.buffer.encode(d,o.proof)},decode:d=>({memberKey:e.fixed32.decode(d),proof:e.buffer.decode(d)})},ce={preencode(d,o){e.fixed32.preencode(d,o.id),e.buffer.preencode(d,o.response)},encode(d,o){e.fixed32.encode(d,o.id),e.buffer.encode(d,o.response)},decode:d=>({id:e.fixed32.decode(d),response:e.buffer.decode(d)})},te=e.frame(I),re=e.frame(ce),ie={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.memberKey),te.preencode(d,o.status),ta.preencode(d,o.profile),d.end++,o.invitation&&re.preencode(d,o.invitation)},encode(d,o){const n=o.invitation?1:0;e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.memberKey),te.encode(d,o.status),ta.encode(d,o.profile),e.uint.encode(d,n),o.invitation&&re.encode(d,o.invitation)},decode:d=>({key:e.fixed32.decode(d),memberKey:e.fixed32.decode(d),status:te.decode(d),profile:ta.decode(d),invitation:1&e.uint.decode(d)?re.decode(d):null})},ae={preencode(d,o){e.uint.preencode(d,o.timestamp),d.end++,o.mailbox&&e.fixed32.preencode(d,o.mailbox),o.displayName&&e.string.preencode(d,o.displayName),o.avatar&&ra.preencode(d,o.avatar),o.username&&e.string.preencode(d,o.username)},encode(d,o){const n=(o.mailbox?1:0)|(o.displayName?2:0)|(o.avatar?4:0)|(o.username?8:0);e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.mailbox&&e.fixed32.encode(d,o.mailbox),o.displayName&&e.string.encode(d,o.displayName),o.avatar&&ra.encode(d,o.avatar),o.username&&e.string.encode(d,o.username)},decode(d){const o=e.uint.decode(d),n=e.uint.decode(d);return{timestamp:o,mailbox:1&n?e.fixed32.decode(d):null,displayName:2&n?e.string.decode(d):null,avatar:4&n?ra.decode(d):null,username:8&n?e.string.decode(d):null}}},se={preencode(o,n){o.end++,n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),n.name&&e.string.preencode(o,n.name),d>=20&&n.buildType&&Bt.preencode(o,n.buildType)},encode(o,n){const c=(n.swarmKey?1:0)|(n.name?2:0)|(n.isMobile?4:0)|(d>=20&&n.buildType?8:0);e.uint.encode(o,c),n.swarmKey&&e.fixed32.encode(o,n.swarmKey),n.name&&e.string.encode(o,n.name),d>=20&&n.buildType&&Bt.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{swarmKey:1&n?e.fixed32.decode(o):null,name:2&n?e.string.decode(o):null,isMobile:!!(4&n),buildType:d>=20&&8&n?Bt.decode(o):null}}},pe=e.frame(ae),ue={preencode(e,d){pe.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){pe.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:pe.decode(e),attestation:ne.decode(e)})},le={preencode(e,d){ia.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){ia.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:ia.decode(e),attestation:ne.decode(e)})},fe={preencode(d,o){e.fixed32.preencode(d,o.id),e.buffer.preencode(d,o.data),e.buffer.preencode(d,o.signature)},encode(d,o){e.fixed32.encode(d,o.id),e.buffer.encode(d,o.data),e.buffer.encode(d,o.signature)},decode:d=>({id:e.fixed32.decode(d),data:e.buffer.decode(d),signature:e.buffer.decode(d)})},me={preencode(d,o){e.fixed32.preencode(d,o.devicePublicKey)},encode(d,o){e.fixed32.encode(d,o.devicePublicKey)},decode:d=>({devicePublicKey:e.fixed32.decode(d)})},ye={preencode(d,o){ne.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){ne.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({privateProfileIdentity:ne.decode(d),deviceProof:e.buffer.decode(d)})},be=e.frame(le),xe=e.frame(ue),ke=e.frame(me),ve={preencode(n,c){e.fixed32.preencode(n,c.deviceKey),t.preencode(n,c.keyPair),be.preencode(n,c.device),xe.preencode(n,c.member),n.end++,c.identity&&ke.preencode(n,c.identity),d>=27&&c.link&&o.preencode(n,c.link)},encode(n,c){const r=(c.identity?1:0)|(d>=27&&c.link?2:0);e.fixed32.encode(n,c.deviceKey),t.encode(n,c.keyPair),be.encode(n,c.device),xe.encode(n,c.member),e.uint.encode(n,r),c.identity&&ke.encode(n,c.identity),d>=27&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),r=t.decode(n),i=be.decode(n),a=xe.decode(n),s=e.uint.decode(n);return{deviceKey:c,keyPair:r,device:i,member:a,identity:1&s?ke.decode(n):null,link:d>=27&&2&s?o.decode(n):null}}},ge=e.frame(ve),he={preencode(d,o){e.fixed32.preencode(d,o.id),ge.preencode(d,o.request),e.buffer.preencode(d,o.signature)},encode(d,o){e.fixed32.encode(d,o.id),ge.encode(d,o.request),e.buffer.encode(d,o.signature)},decode:d=>({id:e.fixed32.decode(d),request:ge.decode(d),signature:e.buffer.decode(d)})},Ke=be,we=xe,Ae={preencode(e,d){Ke.preencode(e,d.device),e.end++,d.member&&we.preencode(e,d.member)},encode(d,o){const n=o.member?1:0;Ke.encode(d,o.device),e.uint.encode(d,n),o.member&&we.encode(d,o.member)},decode:d=>({device:Ke.decode(d),member:1&e.uint.decode(d)?we.decode(d):null})},Te=e.frame(he),Se=e.frame(Ae),Pe={preencode(e,d){e.end++,d.withInvitation&&Te.preencode(e,d.withInvitation),d.withMemberProof&&Se.preencode(e,d.withMemberProof)},encode(d,o){const n=(o.withInvitation?1:0)|(o.withMemberProof?2:0);e.uint.encode(d,n),o.withInvitation&&Te.encode(d,o.withInvitation),o.withMemberProof&&Se.encode(d,o.withMemberProof)},decode(d){const o=e.uint.decode(d);return{withInvitation:1&o?Te.decode(d):null,withMemberProof:2&o?Se.decode(d):null}}},Ie=e.frame(fe),Fe=e.frame(ye),Re={preencode(e,d){Ie.preencode(e,d.signedKeys),e.end++,d.identity&&Fe.preencode(e,d.identity)},encode(d,o){const n=o.identity?1:0;Ie.encode(d,o.signedKeys),e.uint.encode(d,n),o.identity&&Fe.encode(d,o.identity)},decode:d=>({signedKeys:Ie.decode(d),identity:1&e.uint.decode(d)?Fe.decode(d):null})},Ce={preencode(o,n){o.end++,n.expiration&&e.uint.preencode(o,n.expiration),d>=20&&n.buildType&&Bt.preencode(o,n.buildType)},encode(o,n){const c=(n.expiration?1:0)|(n.requiresConfirmation?2:0)|(n.canModerate?4:0)|(n.canAdmin?8:0)|(d>=20&&n.buildType?16:0);e.uint.encode(o,c),n.expiration&&e.uint.encode(o,n.expiration),d>=20&&n.buildType&&Bt.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{expiration:1&n?e.uint.decode(o):0,requiresConfirmation:!!(2&n),canModerate:!!(4&n),canAdmin:!!(8&n),buildType:d>=20&&16&n?Bt.decode(o):null}}},He=Ie,Ve=e.frame(Ce),De={preencode(d,n){e.fixed32.preencode(d,n.id),He.preencode(d,n.response),Ve.preencode(d,n.metadata),d.end++,n.anchor&&o.preencode(d,n.anchor)},encode(d,n){const c=(n.anchor?1:0)|(n.isActive?2:0);e.fixed32.encode(d,n.id),He.encode(d,n.response),Ve.encode(d,n.metadata),e.uint.encode(d,c),n.anchor&&o.encode(d,n.anchor)},decode(d){const n=e.fixed32.decode(d),c=He.decode(d),t=Ve.decode(d),r=e.uint.decode(d);return{id:n,response:c,metadata:t,anchor:1&r?o.decode(d):null,isActive:!!(2&r)}}},Me=$,Le=e.frame(De),qe={preencode(e,d){Me.preencode(e,d.header),Le.preencode(e,d.invitation)},encode(e,d){Me.encode(e,d.header),Le.encode(e,d.invitation)},decode:e=>({header:Me.decode(e),invitation:Le.decode(e)})},Ee=$,Be={preencode(d,o){Ee.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){Ee.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:Ee.decode(d),id:e.fixed32.decode(d)})},ze={preencode(d,n){e.fixed32.preencode(d,n.mailbox),e.fixed32.preencode(d,n.invitationSeed),o.preencode(d,n.anchor)},encode(d,n){e.fixed32.encode(d,n.mailbox),e.fixed32.encode(d,n.invitationSeed),o.encode(d,n.anchor)},decode:d=>({mailbox:e.fixed32.decode(d),invitationSeed:e.fixed32.decode(d),anchor:o.decode(d)})},Ne={preencode(d,n){e.fixed32.preencode(d,n.mailbox),e.fixed32.preencode(d,n.invitationSeed),o.preencode(d,n.anchor),e.fixed32.preencode(d,n.identityPublicKey)},encode(d,n){e.fixed32.encode(d,n.mailbox),e.fixed32.encode(d,n.invitationSeed),o.encode(d,n.anchor),e.fixed32.encode(d,n.identityPublicKey)},decode:d=>({mailbox:e.fixed32.decode(d),invitationSeed:e.fixed32.decode(d),anchor:o.decode(d),identityPublicKey:e.fixed32.decode(d)})},je={preencode(d,o){e.fixed32.preencode(d,o.mailbox)},encode(d,o){e.fixed32.encode(d,o.mailbox)},decode:d=>({mailbox:e.fixed32.decode(d)})},Oe=e.frame(ze),Ue=e.frame(Ne),Je=e.frame(je),Ge=e.array(e.ipv4Address),Qe={preencode(e,o){e.end++,o.room&&Oe.preencode(e,o.room),o.identity&&Ue.preencode(e,o.identity),o.contact&&Je.preencode(e,o.contact),d>=6&&o.readonly&&aa.preencode(e,o.readonly),d>=11&&o.additionalNodes&&Ge.preencode(e,o.additionalNodes),d>=20&&o.buildType&&Bt.preencode(e,o.buildType),d>=27&&o["readonly-v2"]&&sa.preencode(e,o["readonly-v2"])},encode(o,n){const c=(n.room?1:0)|(n.identity?2:0)|(n.contact?4:0)|(d>=6&&n.readonly?8:0)|(d>=11&&n.additionalNodes?16:0)|(d>=20&&n.buildType?32:0)|(d>=27&&n["readonly-v2"]?64:0);e.uint.encode(o,c),n.room&&Oe.encode(o,n.room),n.identity&&Ue.encode(o,n.identity),n.contact&&Je.encode(o,n.contact),d>=6&&n.readonly&&aa.encode(o,n.readonly),d>=11&&n.additionalNodes&&Ge.encode(o,n.additionalNodes),d>=20&&n.buildType&&Bt.encode(o,n.buildType),d>=27&&n["readonly-v2"]&&sa.encode(o,n["readonly-v2"])},decode(o){const n=e.uint.decode(o);return{room:1&n?Oe.decode(o):null,identity:2&n?Ue.decode(o):null,contact:4&n?Je.decode(o):null,readonly:d>=6&&8&n?aa.decode(o):null,additionalNodes:d>=11&&16&n?Ge.decode(o):null,buildType:d>=20&&32&n?Bt.decode(o):null,"readonly-v2":d>=27&&64&n?sa.decode(o):null}}},We=$,Xe={preencode(d,o){We.preencode(d,o.header),e.buffer.preencode(d,o.blindRequest)},encode(d,o){We.encode(d,o.header),e.buffer.encode(d,o.blindRequest)},decode:d=>({header:We.decode(d),blindRequest:e.buffer.decode(d)})},Ye=$,Ze={preencode(o,n){Ye.preencode(o,n.header),o.end++,n.profile&&pa.preencode(o,n.profile),d>=24&&n.key&&e.fixed32.preencode(o,n.key)},encode(o,n){const c=(n.profile?1:0)|(d>=24&&n.key?2:0);Ye.encode(o,n.header),e.uint.encode(o,c),n.profile&&pa.encode(o,n.profile),d>=24&&n.key&&e.fixed32.encode(o,n.key)},decode(o){const n=Ye.decode(o),c=e.uint.decode(o);return{header:n,profile:1&c?pa.decode(o):null,key:d>=24&&2&c?e.fixed32.decode(o):null}}},$e={preencode(e,d){},encode(e,d){},decode:e=>({})},_e=$e,ed=ge,dd={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.id),ed.preencode(d,o.request)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.id),ed.encode(d,o.request)},decode:d=>({deviceKey:e.fixed32.decode(d),id:e.fixed32.decode(d),request:ed.decode(d)})},od=$,nd=Fe,cd={preencode(d,o){od.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),d.end++,o.identity&&nd.preencode(d,o.identity)},encode(d,o){const n=o.identity?1:0;od.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,n),o.identity&&nd.encode(d,o.identity)},decode:d=>({header:od.decode(d),deviceKey:e.fixed32.decode(d),identity:1&e.uint.decode(d)?nd.decode(d):null})},td=$,rd={preencode(d,o){td.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey)},encode(d,o){td.encode(d,o.header),e.fixed32.encode(d,o.deviceKey)},decode:d=>({header:td.decode(d),deviceKey:e.fixed32.decode(d)})},id=e.frame(F),ad=pe,sd={preencode(d,o){e.fixed32.preencode(d,o.key),id.preencode(d,o.status),ad.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),id.encode(d,o.status),ad.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),status:id.decode(d),profile:ad.decode(d)})},pd=id,ud=pe,ld={preencode(d,o){e.fixed32.preencode(d,o.key),pd.preencode(d,o.status),ud.preencode(d,o.profile),d.end++,o.proofs&&ua.preencode(d,o.proofs)},encode(d,o){const n=o.proofs?1:0;e.fixed32.encode(d,o.key),pd.encode(d,o.status),ud.encode(d,o.profile),e.uint.encode(d,n),o.proofs&&ua.encode(d,o.proofs)},decode:d=>({key:e.fixed32.decode(d),status:pd.decode(d),profile:ud.decode(d),proofs:1&e.uint.decode(d)?ua.decode(d):null})},fd={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++,o.profileAttestation&&e.buffer.preencode(d,o.profileAttestation),o.latestReceipt&&e.buffer.preencode(d,o.latestReceipt)},encode(d,o){const n=(o.profileAttestation?1:0)|(o.latestReceipt?2:0);e.fixed32.encode(d,o.key),e.uint.encode(d,n),o.profileAttestation&&e.buffer.encode(d,o.profileAttestation),o.latestReceipt&&e.buffer.encode(d,o.latestReceipt)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d);return{key:o,profileAttestation:1&n?e.buffer.decode(d):null,latestReceipt:2&n?e.buffer.decode(d):null}}},md=$,yd=xe,bd={preencode(e,d){md.preencode(e,d.header),yd.preencode(e,d.member)},encode(e,d){md.encode(e,d.header),yd.encode(e,d.member)},decode:e=>({header:md.decode(e),member:yd.decode(e)})},xd=$,kd=e.frame(R),vd={preencode(d,o){xd.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),kd.preencode(d,o.status)},encode(d,o){xd.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),kd.encode(d,o.status)},decode:d=>({header:xd.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:kd.decode(d)})},gd=$,hd={preencode(d,o){gd.preencode(d,o.header),e.fixed32.preencode(d,o.key),d.end++},encode(d,o){const n=(o.isModerator?1:0)|(o.isAdmin?2:0);gd.encode(d,o.header),e.fixed32.encode(d,o.key),e.uint.encode(d,n)},decode(d){const o=gd.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{header:o,key:n,isModerator:!!(1&c),isAdmin:!!(2&c)}}},Kd=$,wd={preencode(d,o){Kd.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){Kd.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:Kd.decode(d),key:e.fixed32.decode(d)})},Ad={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.mentions)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.mentions)},decode:d=>({key:e.fixed32.decode(d),mentions:e.uint.decode(d)})},Td={preencode(d,o){d.end++,o.memberKey&&e.fixed32.preencode(d,o.memberKey)},encode(d,o){const n=o.memberKey?1:0;e.uint.encode(d,n),o.memberKey&&e.fixed32.encode(d,o.memberKey)},decode:d=>({memberKey:1&e.uint.decode(d)?e.fixed32.decode(d):null})},Sd=Td,Pd={preencode(d,o){d.end++,o.from&&e.string.preencode(d,o.from),o.to&&e.string.preencode(d,o.to)},encode(d,o){const n=(o.from?1:0)|(o.to?2:0);e.uint.encode(d,n),o.from&&e.string.encode(d,o.from),o.to&&e.string.encode(d,o.to)},decode(d){const o=e.uint.decode(d);return{from:1&o?e.string.decode(d):null,to:2&o?e.string.decode(d):null}}},Id=e.frame(Td),Fd=e.frame(Sd),Rd=e.frame(Pd),Cd={preencode(o,n){const c=(n.memberJoined?1:0)|(n.memberLeft?2:0)|(n.titleChanged?4:0)|(n.callStarted?8:0)|(n.callHangup?16:0)|(n.callMissed?32:0)|(d>=3&&n.roomAvatarChanged?64:0)|(d>=3&&n.invitationCreated?128:0)|(d>=3&&n.memberRemoved?256:0)|(d>=18&&n.locationShared?512:0);e.uint.preencode(o,c),n.memberJoined&&Id.preencode(o,n.memberJoined),n.memberLeft&&Fd.preencode(o,n.memberLeft),n.titleChanged&&Rd.preencode(o,n.titleChanged),d>=3&&n.memberRemoved&&la.preencode(o,n.memberRemoved),d>=18&&n.locationShared&&fa.preencode(o,n.locationShared)},encode(o,n){const c=(n.memberJoined?1:0)|(n.memberLeft?2:0)|(n.titleChanged?4:0)|(n.callStarted?8:0)|(n.callHangup?16:0)|(n.callMissed?32:0)|(d>=3&&n.roomAvatarChanged?64:0)|(d>=3&&n.invitationCreated?128:0)|(d>=3&&n.memberRemoved?256:0)|(d>=18&&n.locationShared?512:0);e.uint.encode(o,c),n.memberJoined&&Id.encode(o,n.memberJoined),n.memberLeft&&Fd.encode(o,n.memberLeft),n.titleChanged&&Rd.encode(o,n.titleChanged),d>=3&&n.memberRemoved&&la.encode(o,n.memberRemoved),d>=18&&n.locationShared&&fa.encode(o,n.locationShared)},decode(o){const n=e.uint.decode(o);return{memberJoined:1&n?Id.decode(o):null,memberLeft:2&n?Fd.decode(o):null,titleChanged:4&n?Rd.decode(o):null,callStarted:!!(8&n),callHangup:!!(16&n),callMissed:!!(32&n),roomAvatarChanged:d>=3&&!!(64&n),invitationCreated:d>=3&&!!(128&n),memberRemoved:d>=3&&256&n?la.decode(o):null,locationShared:d>=18&&512&n?fa.decode(o):null}}},Hd={preencode(e,o){e.end++,d>=18&&o.locationShared&&ma.preencode(e,o.locationShared)},encode(o,n){const c=(n.callStarted?1:0)|(n.callHangup?2:0)|(n.callMissed?4:0)|(d>=18&&n.locationShared?8:0);e.uint.encode(o,c),d>=18&&n.locationShared&&ma.encode(o,n.locationShared)},decode(o){const n=e.uint.decode(o);return{callStarted:!!(1&n),callHangup:!!(2&n),callMissed:!!(4&n),locationShared:d>=18&&8&n?ma.decode(o):null}}},Vd={preencode(d,o){e.uint.preencode(d,o.start),e.uint.preencode(d,o.length)},encode(d,o){e.uint.encode(d,o.start),e.uint.encode(d,o.length)},decode:d=>({start:e.uint.decode(d),length:e.uint.decode(d)})},Dd=e.frame(Vd),Md={preencode(d,o){Dd.preencode(d,o.range),e.string.preencode(d,o.content)},encode(d,o){Dd.encode(d,o.range),e.string.encode(d,o.content)},decode:d=>({range:Dd.decode(d),content:e.string.decode(d)})},Ld=Dd,qd={preencode(d,o){Ld.preencode(d,o.range),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Ld.encode(d,o.range),e.fixed32.encode(d,o.memberKey)},decode:d=>({range:Ld.decode(d),memberKey:e.fixed32.decode(d)})},Ed=g,Bd=e.array(e.uint),zd={preencode(o,n){o.end++,n.title&&e.string.preencode(o,n.title),n.description&&e.string.preencode(o,n.description),n.file&&Ed.preencode(o,n.file),d>=7&&n.files&&Bd.preencode(o,n.files)},encode(o,n){const c=(n.title?1:0)|(n.description?2:0)|(n.file?4:0)|(d>=7&&n.files?8:0);e.uint.encode(o,c),n.title&&e.string.encode(o,n.title),n.description&&e.string.encode(o,n.description),n.file&&Ed.encode(o,n.file),d>=7&&n.files&&Bd.encode(o,n.files)},decode(o){const n=e.uint.decode(o);return{title:1&n?e.string.decode(o):null,description:2&n?e.string.decode(o):null,file:4&n?Ed.decode(o):null,files:d>=7&&8&n?Bd.decode(o):null}}},Nd=Dd,jd=e.frame(zd),Od={preencode(d,o){Nd.preencode(d,o.range),e.string.preencode(d,o.url),d.end++,o.preview&&jd.preencode(d,o.preview)},encode(d,o){const n=o.preview?1:0;Nd.encode(d,o.range),e.string.encode(d,o.url),e.uint.encode(d,n),o.preview&&jd.encode(d,o.preview)},decode:d=>({range:Nd.decode(d),url:e.string.decode(d),preview:1&e.uint.decode(d)?jd.decode(d):null})},Ud=e.array(e.frame(qd)),Jd=e.array(e.frame(Od)),Gd=Jd,Qd=e.array(e.frame(Vd)),Wd=Qd,Xd=Qd,Yd=e.array(e.frame(Md)),Zd=Qd,$d=Qd,_d={preencode(o,n){const c=(n.mention?1:0)|(n.httpLink?2:0)|(n.pearLink?4:0)|(n.bold?8:0)|(n.italic?16:0)|(n.code?32:0)|(n.emoji?64:0)|(n.codeBlock?128:0)|(n.strike?256:0)|(d>=11&&n.translation?512:0);e.uint.preencode(o,c),n.mention&&Ud.preencode(o,n.mention),n.httpLink&&Jd.preencode(o,n.httpLink),n.pearLink&&Gd.preencode(o,n.pearLink),n.bold&&Qd.preencode(o,n.bold),n.italic&&Wd.preencode(o,n.italic),n.code&&Xd.preencode(o,n.code),n.emoji&&Yd.preencode(o,n.emoji),n.codeBlock&&Zd.preencode(o,n.codeBlock),n.strike&&$d.preencode(o,n.strike),d>=11&&n.translation&&ya.preencode(o,n.translation)},encode(o,n){const c=(n.mention?1:0)|(n.httpLink?2:0)|(n.pearLink?4:0)|(n.bold?8:0)|(n.italic?16:0)|(n.code?32:0)|(n.emoji?64:0)|(n.codeBlock?128:0)|(n.strike?256:0)|(d>=11&&n.translation?512:0);e.uint.encode(o,c),n.mention&&Ud.encode(o,n.mention),n.httpLink&&Jd.encode(o,n.httpLink),n.pearLink&&Gd.encode(o,n.pearLink),n.bold&&Qd.encode(o,n.bold),n.italic&&Wd.encode(o,n.italic),n.code&&Xd.encode(o,n.code),n.emoji&&Yd.encode(o,n.emoji),n.codeBlock&&Zd.encode(o,n.codeBlock),n.strike&&$d.encode(o,n.strike),d>=11&&n.translation&&ya.encode(o,n.translation)},decode(o){const n=e.uint.decode(o);return{mention:1&n?Ud.decode(o):null,httpLink:2&n?Jd.decode(o):null,pearLink:4&n?Gd.decode(o):null,bold:8&n?Qd.decode(o):null,italic:16&n?Wd.decode(o):null,code:32&n?Xd.decode(o):null,emoji:64&n?Yd.decode(o):null,codeBlock:128&n?Zd.decode(o):null,strike:256&n?$d.decode(o):null,translation:d>=11&&512&n?ya.decode(o):null}}},eo=e.array(e.frame(v)),oo=e.frame(_d),no=e.frame(Hd),co={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&eo.preencode(d,o.files),o.display&&oo.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent),o.event&&no.preencode(d,o.event)},encode(o,c){const t=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(c.event?32:0)|(d>=18&&c.forwarded?64:0);e.uint.encode(o,t),c.text&&e.string.encode(o,c.text),c.files&&eo.encode(o,c.files),c.display&&oo.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent),c.event&&no.encode(o,c.event)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?eo.decode(o):null,display:4&c?oo.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,event:32&c?no.decode(o):null,forwarded:d>=18&&!!(64&c)}}},to=Bd,ro=oo,io={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&to.preencode(d,o.files),o.display&&ro.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent)},encode(o,c){const t=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(d>=18&&c.forwarded?32:0);e.uint.encode(o,t),c.text&&e.string.encode(o,c.text),c.files&&to.encode(o,c.files),c.display&&ro.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?to.decode(o):null,display:4&c?ro.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,forwarded:d>=18&&!!(32&c)}}},ao=eo,so=oo,po={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&ao.preencode(d,o.files),o.display&&so.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent)},encode(o,c){const t=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(d>=18&&c.forwarded?32:0);e.uint.encode(o,t),c.text&&e.string.encode(o,c.text),c.files&&ao.encode(o,c.files),c.display&&so.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?ao.decode(o):null,display:4&c?so.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,forwarded:d>=18&&!!(32&c)}}},uo={preencode(e,d){e.end++},encode(d,o){const n=(o.isEdited?1:0)|(o.isDeleted?2:0)|(o.isPinned?4:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isEdited:!!(1&o),isDeleted:!!(2&o),isPinned:!!(4&o)}}},lo={preencode(d,o){e.uint.preencode(d,o.thread),e.uint.preencode(d,o.index)},encode(d,o){e.uint.encode(d,o.thread),e.uint.encode(d,o.index)},decode:d=>({thread:e.uint.decode(d),index:e.uint.decode(d)})},fo=e.frame(z),mo={preencode(d,o){e.uint.preencode(d,o.id),e.uint.preencode(d,o.count),d.end++,o.parent&&n.preencode(d,o.parent),o.stats&&fo.preencode(d,o.stats)},encode(d,o){const c=(o.parent?1:0)|(o.stats?2:0);e.uint.encode(d,o.id),e.uint.encode(d,o.count),e.uint.encode(d,c),o.parent&&n.encode(d,o.parent),o.stats&&fo.encode(d,o.stats)},decode(d){const o=e.uint.decode(d),c=e.uint.decode(d),t=e.uint.decode(d);return{id:o,count:c,parent:1&t?n.decode(d):null,stats:2&t?fo.decode(d):null}}},yo=e.frame(uo),bo=e.frame(io),xo=e.frame(Cd),ko={preencode(d,o){lo.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),yo.preencode(d,o.status),o.message&&bo.preencode(d,o.message),o.event&&xo.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);lo.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),yo.encode(d,o.status),o.message&&bo.encode(d,o.message),o.event&&xo.encode(d,o.event)},decode(d){const o=lo.decode(d),c=n.decode(d),t=e.uint.decode(d),r=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:t,timestamp:r,editedAt:1&i?e.uint.decode(d):0,status:yo.decode(d),message:2&i?bo.decode(d):null,event:4&i?xo.decode(d):null}}},vo=yo,go=e.frame(po),ho=xo,Ko={preencode(d,o){lo.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),vo.preencode(d,o.status),o.message&&go.preencode(d,o.message),o.event&&ho.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);lo.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),vo.encode(d,o.status),o.message&&go.encode(d,o.message),o.event&&ho.encode(d,o.event)},decode(d){const o=lo.decode(d),c=n.decode(d),t=e.uint.decode(d),r=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:t,timestamp:r,editedAt:1&i?e.uint.decode(d):0,status:vo.decode(d),message:2&i?go.decode(d):null,event:4&i?ho.decode(d):null}}},wo=$,Ao=e.frame(co),To={preencode(e,d){wo.preencode(e,d.header),Ao.preencode(e,d.message)},encode(e,d){wo.encode(e,d.header),Ao.encode(e,d.message)},decode:e=>({header:wo.decode(e),message:Ao.decode(e)})},So=$,Po={preencode(e,d){So.preencode(e,d.header),n.preencode(e,d.oplog)},encode(e,d){So.encode(e,d.header),n.encode(e,d.oplog)},decode:e=>({header:So.decode(e),oplog:n.decode(e)})},Io=$,Fo=Ao,Ro={preencode(e,d){Io.preencode(e,d.header),n.preencode(e,d.oplog),Fo.preencode(e,d.message)},encode(e,d){Io.encode(e,d.header),n.encode(e,d.oplog),Fo.encode(e,d.message)},decode:e=>({header:Io.decode(e),oplog:n.decode(e),message:Fo.decode(e)})},Co=$,Ho={preencode(e,d){Co.preencode(e,d.header),n.preencode(e,d.oplog),e.end++},encode(d,o){const c=o.isPinned?1:0;Co.encode(d,o.header),n.encode(d,o.oplog),e.uint.encode(d,c)},decode:d=>({header:Co.decode(d),oplog:n.decode(d),isPinned:!!(1&e.uint.decode(d))})},Vo={preencode(d,o){lo.preencode(d,o.id),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),e.string.preencode(d,o.reaction)},encode(d,o){lo.encode(d,o.id),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),e.string.encode(d,o.reaction)},decode:d=>({id:lo.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),reaction:e.string.decode(d)})},Do={preencode(d,o){e.string.preencode(d,o.text),e.uint.preencode(d,o.count)},encode(d,o){e.string.encode(d,o.text),e.uint.encode(d,o.count)},decode:d=>({text:e.string.decode(d),count:e.uint.decode(d)})},Mo=e.array(e.frame(Do)),Lo={preencode(o,n){lo.preencode(o,n.id),e.uint.preencode(o,n.total),Mo.preencode(o,n.reactions),o.end++,d>=11&&n.editedAt&&e.uint.preencode(o,n.editedAt)},encode(o,n){const c=d>=11&&n.editedAt?1:0;lo.encode(o,n.id),e.uint.encode(o,n.total),Mo.encode(o,n.reactions),e.uint.encode(o,c),d>=11&&n.editedAt&&e.uint.encode(o,n.editedAt)},decode(o){const n=lo.decode(o),c=e.uint.decode(o),t=Mo.decode(o),r=o.start<o.end?e.uint.decode(o):0;return{id:n,total:c,reactions:t,editedAt:d>=11&&1&r?e.uint.decode(o):0}}},qo=$,Eo={preencode(d,o){qo.preencode(d,o.header),n.preencode(d,o.oplog),e.string.preencode(d,o.reaction)},encode(d,o){qo.encode(d,o.header),n.encode(d,o.oplog),e.string.encode(d,o.reaction)},decode:d=>({header:qo.decode(d),oplog:n.decode(d),reaction:e.string.decode(d)})},Bo=$,zo={preencode(d,o){Bo.preencode(d,o.header),n.preencode(d,o.oplog),e.string.preencode(d,o.reaction)},encode(d,o){Bo.encode(d,o.header),n.encode(d,o.oplog),e.string.encode(d,o.reaction)},decode:d=>({header:Bo.decode(d),oplog:n.decode(d),reaction:e.string.decode(d)})},No=$,jo=e.frame(Y),Oo={preencode(d,o){No.preencode(d,o.header),e.uint.preencode(d,o.key),jo.preencode(d,o.config)},encode(d,o){No.encode(d,o.header),e.uint.encode(d,o.key),jo.encode(d,o.config)},decode:d=>({header:No.decode(d),key:e.uint.decode(d),config:jo.decode(d)})},Uo={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.string.preencode(d,o.displayName),d.end++,o.avatar&&ba.preencode(d,o.avatar)},encode(d,o){const n=o.avatar?1:0;e.fixed32.encode(d,o.memberKey),e.string.encode(d,o.displayName),e.uint.encode(d,n),o.avatar&&ba.encode(d,o.avatar)},decode:d=>({memberKey:e.fixed32.decode(d),displayName:e.string.decode(d),avatar:1&e.uint.decode(d)?ba.decode(d):null})},Jo={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++,o.username&&e.string.preencode(d,o.username)},encode(d,o){const n=o.username?1:0;e.fixed32.encode(d,o.key),e.uint.encode(d,n),o.username&&e.string.encode(d,o.username)},decode:d=>({key:e.fixed32.decode(d),username:1&e.uint.decode(d)?e.string.decode(d):null})},Go=e.frame(Jo),Qo={preencode(d,o){e.fixed32.preencode(d,o.publicKey),d.end++,o.discoveryCoreKey&&e.fixed32.preencode(d,o.discoveryCoreKey),o.userRegistry&&Go.preencode(d,o.userRegistry)},encode(d,o){const n=(o.discoveryCoreKey?1:0)|(o.userRegistry?2:0);e.fixed32.encode(d,o.publicKey),e.uint.encode(d,n),o.discoveryCoreKey&&e.fixed32.encode(d,o.discoveryCoreKey),o.userRegistry&&Go.encode(d,o.userRegistry)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d);return{publicKey:o,discoveryCoreKey:1&n?e.fixed32.decode(d):null,userRegistry:2&n?Go.decode(d):null}}},Wo=$,Xo=e.frame(G),Yo=e.frame(Q),Zo=jo,$o=e.frame(Qo),_o=be,en=e.array(e.frame(ue)),dn={preencode(e,d){Wo.preencode(e,d.header),Xo.preencode(e,d.digest),Yo.preencode(e,d.capabilities),e.end++,d.config&&Zo.preencode(e,d.config),d.identity&&$o.preencode(e,d.identity),d.bootstrapDevice&&_o.preencode(e,d.bootstrapDevice),d.initialMembers&&en.preencode(e,d.initialMembers)},encode(d,o){const n=(o.config?1:0)|(o.identity?2:0)|(o.bootstrapDevice?4:0)|(o.initialMembers?8:0);Wo.encode(d,o.header),Xo.encode(d,o.digest),Yo.encode(d,o.capabilities),e.uint.encode(d,n),o.config&&Zo.encode(d,o.config),o.identity&&$o.encode(d,o.identity),o.bootstrapDevice&&_o.encode(d,o.bootstrapDevice),o.initialMembers&&en.encode(d,o.initialMembers)},decode(d){const o=Wo.decode(d),n=Xo.decode(d),c=Yo.decode(d),t=e.uint.decode(d);return{header:o,digest:n,capabilities:c,config:1&t?Zo.decode(d):null,identity:2&t?$o.decode(d):null,bootstrapDevice:4&t?_o.decode(d):null,initialMembers:8&t?en.decode(d):null}}},on=$,nn={preencode(d,o){on.preencode(d,o.header),e.uint.preencode(d,o.version)},encode(d,o){on.encode(d,o.header),e.uint.encode(d,o.version)},decode:d=>({header:on.decode(d),version:e.uint.decode(d)})},cn=$,tn=J,rn={preencode(d,o){cn.preencode(d,o.header),e.uint.preencode(d,o.key),tn.preencode(d,o.settings)},encode(d,o){cn.encode(d,o.header),e.uint.encode(d,o.key),tn.encode(d,o.settings)},decode:d=>({header:cn.decode(d),key:e.uint.decode(d),settings:tn.decode(d)})},an={preencode(o,n){e.fixed32.preencode(o,n.memberKey),xa.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=22&&n.contactInfo&&ka.preencode(o,n.contactInfo),d>=22&&n.version&&e.uint.preencode(o,n.version),d>=24&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=22&&n.contactInfo?4:0)|(d>=22&&n.version?8:0)|(d>=24&&n.alias?16:0);e.fixed32.encode(o,n.memberKey),xa.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=22&&n.contactInfo&&ka.encode(o,n.contactInfo),d>=22&&n.version&&e.uint.encode(o,n.version),d>=24&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.fixed32.decode(o),c=xa.decode(o),t=e.uint.decode(o);return{memberKey:n,status:c,mailbox:1&t?e.fixed32.decode(o):null,roomKey:2&t?e.fixed32.decode(o):null,contactInfo:d>=22&&4&t?ka.decode(o):null,version:d>=22&&8&t?e.uint.decode(o):0,alias:d>=24&&16&t?e.string.decode(o):null}}},sn={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.seed),o.preencode(d,n.initiator),e.fixed32.preencode(d,n.fastForwardTo)},encode(d,n){e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.fixed32.encode(d,n.seed),o.encode(d,n.initiator),e.fixed32.encode(d,n.fastForwardTo)},decode:d=>({roomKey:e.fixed32.decode(d),encryptionKey:e.buffer.decode(d),seed:e.fixed32.decode(d),initiator:o.decode(d),fastForwardTo:e.fixed32.decode(d)})},pn=e.array(e.frame(sn)),un=X,ln={preencode(e,d){pn.preencode(e,d.sharedRooms),un.preencode(e,d.blockedContacts)},encode(e,d){pn.encode(e,d.sharedRooms),un.encode(e,d.blockedContacts)},decode:e=>({sharedRooms:pn.decode(e),blockedContacts:un.decode(e)})},fn=$o,mn={preencode(e,d){fn.preencode(e,d.identity)},encode(e,d){fn.encode(e,d.identity)},decode:e=>({identity:fn.decode(e)})},yn={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.contacts)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.contacts)},decode:d=>({rooms:e.uint.decode(d),contacts:e.uint.decode(d)})},bn={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.contactRequests)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.contactRequests)},decode:d=>({rooms:e.uint.decode(d),contactRequests:e.uint.decode(d)})},xn={preencode(d,o){e.buffer.preencode(d,o.entropy)},encode(d,o){e.buffer.encode(d,o.entropy)},decode:d=>({entropy:e.buffer.decode(d)})},kn={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.devicePublicKey),e.fixed32.preencode(d,o.writerKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.devicePublicKey),e.fixed32.encode(d,o.writerKey)},decode:d=>({publicKey:e.fixed32.decode(d),devicePublicKey:e.fixed32.decode(d),writerKey:e.fixed32.decode(d)})},vn=e.frame(kn),gn={preencode(n,c){e.fixed32.preencode(n,c.id),e.fixed32.preencode(n,c.invitationSeed),e.fixed32.preencode(n,c.mailbox),t.preencode(n,c.responseKeyPair),o.preencode(n,c.initiator),o.preencode(n,c.inviter),n.end++,c.identity&&vn.preencode(n,c.identity),d>=20&&c.buildType&&Bt.preencode(n,c.buildType),d>=27&&c.link&&o.preencode(n,c.link)},encode(n,c){const r=(c.identity?1:0)|(d>=20&&c.buildType?2:0)|(d>=27&&c.link?4:0);e.fixed32.encode(n,c.id),e.fixed32.encode(n,c.invitationSeed),e.fixed32.encode(n,c.mailbox),t.encode(n,c.responseKeyPair),o.encode(n,c.initiator),o.encode(n,c.inviter),e.uint.encode(n,r),c.identity&&vn.encode(n,c.identity),d>=20&&c.buildType&&Bt.encode(n,c.buildType),d>=27&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),r=e.fixed32.decode(n),i=e.fixed32.decode(n),a=t.decode(n),s=o.decode(n),p=o.decode(n),u=e.uint.decode(n);return{id:c,invitationSeed:r,mailbox:i,responseKeyPair:a,initiator:s,inviter:p,identity:1&u?vn.decode(n):null,buildType:d>=20&&2&u?Bt.decode(n):null,link:d>=27&&4&u?o.decode(n):null}}},hn=$,Kn={preencode(d,o){hn.preencode(d,o.header),e.buffer.preencode(d,o.blindResponse)},encode(d,o){hn.encode(d,o.header),e.buffer.encode(d,o.blindResponse)},decode:d=>({header:hn.decode(d),blindResponse:e.buffer.decode(d)})},wn=$,An=e.frame(gn),Tn={preencode(e,d){wn.preencode(e,d.header),An.preencode(e,d.invitation)},encode(e,d){wn.encode(e,d.header),An.encode(e,d.invitation)},decode:e=>({header:wn.decode(e),invitation:An.decode(e)})},Sn=$,Pn={preencode(d,o){Sn.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){Sn.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:Sn.decode(d),id:e.fixed32.decode(d)})},In={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.devicePublicKey),d.end++,o.privateProfileKey&&e.fixed32.preencode(d,o.privateProfileKey),o.deviceKeyPair&&t.preencode(d,o.deviceKeyPair),e.buffer.preencode(d,o.deviceProof)},encode(d,o){const n=(o.privateProfileKey?1:0)|(o.deviceKeyPair?2:0);e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.devicePublicKey),e.uint.encode(d,n),o.privateProfileKey&&e.fixed32.encode(d,o.privateProfileKey),o.deviceKeyPair&&t.encode(d,o.deviceKeyPair),e.buffer.encode(d,o.deviceProof)},decode(d){const o=e.fixed32.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{publicKey:o,devicePublicKey:n,privateProfileKey:1&c?e.fixed32.decode(d):null,deviceKeyPair:2&c?t.decode(d):null,deviceProof:e.buffer.decode(d)}}},Fn={preencode(o,n){o.end++,d>=25&&n.roomSnoozeTime&&e.uint.preencode(o,n.roomSnoozeTime)},encode(o,n){const c=(n.isActive?1:0)|(n.isFullyMuted?2:0)|(n.isMentionsOnlyMuted?4:0)|(d>=9&&n.isReadOnly?8:0)|(d>=18&&n.isFavorite?16:0)|(d>=21&&n.isUnread?32:0)|(d>=25&&n.roomSnoozeTime?64:0);e.uint.encode(o,c),d>=25&&n.roomSnoozeTime&&e.uint.encode(o,n.roomSnoozeTime)},decode(o){const n=e.uint.decode(o);return{isActive:!!(1&n),isFullyMuted:!!(2&n),isMentionsOnlyMuted:!!(4&n),isReadOnly:d>=9&&!!(8&n),isFavorite:d>=18&&!!(16&n),isUnread:d>=21&&!!(32&n),roomSnoozeTime:d>=25&&64&n?e.uint.decode(o):0}}},Rn=e.frame(Fn),Cn=e.frame(In),Hn=vn,Vn={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),Rn.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,c.initiator&&o.preencode(n,c.initiator),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),c.identitySwap&&Cn.preencode(n,c.identitySwap),d>=6&&c.identitySwapV2&&Hn.preencode(n,c.identitySwapV2),d>=10&&c.contact&&e.fixed32.preencode(n,c.contact),d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=29&&c.activeClock&&e.uint.preencode(n,c.activeClock)},encode(n,c){const t=(c.initiator?1:0)|(c.fastForwardTo?2:0)|(c.identitySwap?4:0)|(d>=6&&c.identitySwapV2?8:0)|(d>=10&&c.contact?16:0)|(d>=27&&c.bootFrom?32:0)|(d>=29&&c.activeClock?64:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),Rn.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,t),c.initiator&&o.encode(n,c.initiator),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),c.identitySwap&&Cn.encode(n,c.identitySwap),d>=6&&c.identitySwapV2&&Hn.encode(n,c.identitySwapV2),d>=10&&c.contact&&e.fixed32.encode(n,c.contact),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom),d>=29&&c.activeClock&&e.uint.encode(n,c.activeClock)},decode(n){const c=e.fixed32.decode(n),t=e.buffer.decode(n),r=e.fixed32.decode(n),i=Rn.decode(n),a=e.uint.decode(n),s=e.uint.decode(n);return{roomKey:c,encryptionKey:t,mailbox:r,status:i,clock:a,initiator:1&s?o.decode(n):null,fastForwardTo:2&s?e.fixed32.decode(n):null,identitySwap:4&s?Cn.decode(n):null,identitySwapV2:d>=6&&8&s?Hn.decode(n):null,contact:d>=10&&16&s?e.fixed32.decode(n):null,bootFrom:d>=27&&32&s?o.decode(n):null,activeClock:d>=29&&64&s?e.uint.decode(n):0}}},Dn=$,Mn={preencode(d,n){Dn.preencode(d,n.header),e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.mailbox),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.dm&&e.fixed32.preencode(d,n.dm)},encode(n,c){const t=(c.fastForwardTo?1:0)|(c.initiator?2:0)|(c.dm?4:0)|(d>=9&&c.isReadOnly?8:0);Dn.encode(n,c.header),e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),e.uint.encode(n,t),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),c.initiator&&o.encode(n,c.initiator),c.dm&&e.fixed32.encode(n,c.dm)},decode(n){const c=Dn.decode(n),t=e.fixed32.decode(n),r=e.buffer.decode(n),i=e.fixed32.decode(n),a=e.uint.decode(n);return{header:c,roomKey:t,encryptionKey:r,mailbox:i,fastForwardTo:1&a?e.fixed32.decode(n):null,initiator:2&a?o.decode(n):null,dm:4&a?e.fixed32.decode(n):null,isReadOnly:d>=9&&!!(8&a)}}},Ln=$,qn={preencode(d,o){Ln.preencode(d,o.header),e.fixed32.preencode(d,o.discoveryKey)},encode(d,o){Ln.encode(d,o.header),e.fixed32.encode(d,o.discoveryKey)},decode:d=>({header:Ln.decode(d),discoveryKey:e.fixed32.decode(d)})},En=$,Bn=Rn,zn={preencode(d,o){En.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.key),Bn.preencode(d,o.status)},encode(d,o){En.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.key),Bn.encode(d,o.status)},decode:d=>({header:En.decode(d),roomKey:e.fixed32.decode(d),key:e.uint.decode(d),status:Bn.decode(d)})},Nn={preencode(e,d){e.end++},encode(o,n){const c=(n.isBlocked?1:0)|(d>=22&&n.isActive?2:0);e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{isBlocked:!!(1&n),isActive:d>=22&&!!(2&n)}}},jn={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.clock),va.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=22&&n.contactInfo&&ga.preencode(o,n.contactInfo),d>=24&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=22&&n.contactInfo?4:0)|(d>=24&&n.alias?8:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.clock),va.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=22&&n.contactInfo&&ga.encode(o,n.contactInfo),d>=24&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),t=va.decode(o),r=e.uint.decode(o);return{memberKey:n,clock:c,status:t,mailbox:1&r?e.fixed32.decode(o):null,roomKey:2&r?e.fixed32.decode(o):null,contactInfo:d>=22&&4&r?ga.decode(o):null,alias:d>=24&&8&r?e.string.decode(o):null}}},On=$,Un=e.frame(an),Jn={preencode(e,d){On.preencode(e,d.header),Un.preencode(e,d.contact)},encode(e,d){On.encode(e,d.header),Un.encode(e,d.contact)},decode:e=>({header:On.decode(e),contact:Un.decode(e)})},Gn=$,Qn={preencode(d,o){Gn.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),ha.preencode(d,o.status)},encode(d,o){Gn.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),ha.encode(d,o.status)},decode:d=>({header:Gn.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:ha.decode(d)})},Wn=$,Xn={preencode(d,o){Wn.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Wn.encode(d,o.header),e.fixed32.encode(d,o.memberKey)},decode:d=>({header:Wn.decode(d),memberKey:e.fixed32.decode(d)})},Yn={preencode(e,d){e.end++},encode(d,o){const n=(o.isPending?1:0)|(o.isAccepted?2:0)|(o.isRejected?4:0)|(o.isDiscarded?8:0)|(o.isSeen?16:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isPending:!!(1&o),isAccepted:!!(2&o),isRejected:!!(4&o),isDiscarded:!!(8&o),isSeen:!!(16&o)}}},Zn=xe,$n=e.frame(r),_n={preencode(d,o){Zn.preencode(d,o.sender),$n.preencode(d,o.keys),e.fixed32.preencode(d,o.mailbox),d.end++,o.message&&e.string.preencode(d,o.message)},encode(d,o){const n=o.message?1:0;Zn.encode(d,o.sender),$n.encode(d,o.keys),e.fixed32.encode(d,o.mailbox),e.uint.encode(d,n),o.message&&e.string.encode(d,o.message)},decode:d=>({sender:Zn.decode(d),keys:$n.decode(d),mailbox:e.fixed32.decode(d),message:1&e.uint.decode(d)?e.string.decode(d):null})},ec=e.frame(_n),dc={preencode(o,n){ec.preencode(o,n.body),ne.preencode(o,n.attestation),o.end++,d>=31&&n.recipientProof&&e.buffer.preencode(o,n.recipientProof)},encode(o,n){const c=d>=31&&n.recipientProof?1:0;ec.encode(o,n.body),ne.encode(o,n.attestation),e.uint.encode(o,c),d>=31&&n.recipientProof&&e.buffer.encode(o,n.recipientProof)},decode(o){const n=ec.decode(o),c=ne.decode(o),t=o.start<o.end?e.uint.decode(o):0;return{body:n,attestation:c,recipientProof:d>=31&&1&t?e.buffer.decode(o):null}}},oc=pe,nc=e.frame(Yn),cc=$n,tc={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.clock),oc.preencode(o,n.sender),nc.preencode(o,n.status),cc.preencode(o,n.keys),e.fixed32.preencode(o,n.mailbox),o.end++,n.message&&e.string.preencode(o,n.message),d>=11&&n.sentAt&&e.uint.preencode(o,n.sentAt),d>=22&&n.contactInfo&&Ka.preencode(o,n.contactInfo)},encode(o,n){const c=(n.message?1:0)|(d>=11&&n.sentAt?2:0)|(d>=22&&n.contactInfo?4:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.clock),oc.encode(o,n.sender),nc.encode(o,n.status),cc.encode(o,n.keys),e.fixed32.encode(o,n.mailbox),e.uint.encode(o,c),n.message&&e.string.encode(o,n.message),d>=11&&n.sentAt&&e.uint.encode(o,n.sentAt),d>=22&&n.contactInfo&&Ka.encode(o,n.contactInfo)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),t=oc.decode(o),r=nc.decode(o),i=cc.decode(o),a=e.fixed32.decode(o),s=e.uint.decode(o);return{memberKey:n,clock:c,sender:t,status:r,keys:i,mailbox:a,message:1&s?e.string.decode(o):null,sentAt:d>=11&&2&s?e.uint.decode(o):0,contactInfo:d>=22&&4&s?Ka.decode(o):null}}},rc=$,ic={preencode(d,o){rc.preencode(d,o.header),e.buffer.preencode(d,o.blindRequest)},encode(d,o){rc.encode(d,o.header),e.buffer.encode(d,o.blindRequest)},decode:d=>({header:rc.decode(d),blindRequest:e.buffer.decode(d)})},ac=$,sc=nc,pc={preencode(o,n){ac.preencode(o,n.header),e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.key),sc.preencode(o,n.status),o.end++,d>=10&&n.roomKey&&e.fixed32.preencode(o,n.roomKey)},encode(o,n){const c=d>=10&&n.roomKey?1:0;ac.encode(o,n.header),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.key),sc.encode(o,n.status),e.uint.encode(o,c),d>=10&&n.roomKey&&e.fixed32.encode(o,n.roomKey)},decode(o){const n=ac.decode(o),c=e.fixed32.decode(o),t=e.uint.decode(o),r=sc.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{header:n,memberKey:c,key:t,status:r,roomKey:d>=10&&1&i?e.fixed32.decode(o):null}}},uc={preencode(d,o){e.uint.preencode(d,o.timestamp),e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.mailbox)},encode(d,o){e.uint.encode(d,o.timestamp),e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.mailbox)},decode:d=>({version:0,timestamp:e.uint.decode(d),key:e.fixed32.decode(d),mailbox:e.fixed32.decode(d)})},lc={preencode(d,o){const n=o.version??1;switch(e.uint.preencode(d,n),n){case 0:case 1:uc.preencode(d,o);break;default:throw new Error("Unsupported version")}},encode(d,o){const n=o.version??1;switch(e.uint.encode(d,n),n){case 0:case 1:uc.encode(d,o);break;default:throw new Error("Unsupported version")}},decode(d){const o=e.uint.decode(d);switch(o){case 0:case 1:{const e=uc.decode(d);return e.version=o,e}default:throw new Error("Unsupported version")}}},fc=$,mc={preencode(o,c){fc.preencode(o,c.header),n.preencode(o,c.oplog),e.uint.preencode(o,c.index),wa.preencode(o,c.preview),o.end++,d>=7&&c.displayType&&Sc.preencode(o,c.displayType)},encode(o,c){const t=d>=7&&c.displayType?1:0;fc.encode(o,c.header),n.encode(o,c.oplog),e.uint.encode(o,c.index),wa.encode(o,c.preview),e.uint.encode(o,t),d>=7&&c.displayType&&Sc.encode(o,c.displayType)},decode(o){const c=fc.decode(o),t=n.decode(o),r=e.uint.decode(o),i=wa.decode(o),a=o.start<o.end?e.uint.decode(o):0;return{header:c,oplog:t,index:r,preview:i,displayType:d>=7&&1&a?Sc.decode(o):0}}},yc={preencode(o,n){o.end++,d>=3&&n.memberKey&&e.fixed32.preencode(o,n.memberKey)},encode(o,n){const c=d>=3&&n.memberKey?1:0;e.uint.encode(o,c),d>=3&&n.memberKey&&e.fixed32.encode(o,n.memberKey)},decode(o){const n=e.uint.decode(o);return{memberKey:d>=3&&1&n?e.fixed32.decode(o):null}}},bc=pe,xc={preencode(e,d){bc.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){bc.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:bc.decode(e),attestation:ne.decode(e)})},kc=$,vc={preencode(d,o){kc.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){kc.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:kc.decode(d),key:e.fixed32.decode(d)})},gc={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),ne.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){e.fixed32.encode(d,o.deviceKey),ne.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({deviceKey:e.fixed32.decode(d),privateProfileIdentity:ne.decode(d),deviceProof:e.buffer.decode(d)})},hc={preencode(o,n){e.fixed32.preencode(o,n.roomKey),e.fixed32.preencode(o,n.encryptionKey),e.fixed32.preencode(o,n.seed),o.end++,d>=6&&n.fastForwardTo&&e.fixed32.preencode(o,n.fastForwardTo)},encode(o,n){const c=d>=6&&n.fastForwardTo?1:0;e.fixed32.encode(o,n.roomKey),e.fixed32.encode(o,n.encryptionKey),e.fixed32.encode(o,n.seed),e.uint.encode(o,c),d>=6&&n.fastForwardTo&&e.fixed32.encode(o,n.fastForwardTo)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=e.fixed32.decode(o),r=e.uint.decode(o);return{roomKey:n,encryptionKey:c,seed:t,fastForwardTo:d>=6&&1&r?e.fixed32.decode(o):null}}},Kc={preencode(o,n){e.fixed32.preencode(o,n.publicKey),e.fixed32.preencode(o,n.writerKey),e.fixed32.preencode(o,n.devicePublicKey),o.end++,d>=6&&n.privateProfileKey&&e.fixed32.preencode(o,n.privateProfileKey)},encode(o,n){const c=d>=6&&n.privateProfileKey?1:0;e.fixed32.encode(o,n.publicKey),e.fixed32.encode(o,n.writerKey),e.fixed32.encode(o,n.devicePublicKey),e.uint.encode(o,c),d>=6&&n.privateProfileKey&&e.fixed32.encode(o,n.privateProfileKey)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=e.fixed32.decode(o),r=e.uint.decode(o);return{publicKey:n,writerKey:c,devicePublicKey:t,privateProfileKey:d>=6&&1&r?e.fixed32.decode(o):null}}},wc=$,Ac={preencode(d,o){wc.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey)},encode(d,o){wc.encode(d,o.header),e.fixed32.encode(d,o.memberKey)},decode:d=>({header:wc.decode(d),memberKey:e.fixed32.decode(d)})},Tc={HttpLink:1,PearLink:2},Sc={preencode(e,d){e.end++},encode(d,o){if(o>2)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Pc=$,Ic={preencode(d,o){Pc.preencode(d,o.header),e.uint.preencode(d,o.value)},encode(d,o){Pc.encode(d,o.header),e.uint.encode(d,o.value)},decode:d=>({header:Pc.decode(d),value:e.uint.decode(d)})},Fc={preencode(d,o){e.uint.preencode(d,o.key),e.uint.preencode(d,o.value)},encode(d,o){e.uint.encode(d,o.key),e.uint.encode(d,o.value)},decode:d=>({key:e.uint.decode(d),value:e.uint.decode(d)})},Rc=$,Cc={preencode(o,n){Rc.preencode(o,n.header),e.uint.preencode(o,n.from),e.uint.preencode(o,n.to),o.end++,d>=20&&n.buildType&&Bt.preencode(o,n.buildType)},encode(o,n){const c=d>=20&&n.buildType?1:0;Rc.encode(o,n.header),e.uint.encode(o,n.from),e.uint.encode(o,n.to),e.uint.encode(o,c),d>=20&&n.buildType&&Bt.encode(o,n.buildType)},decode(o){const n=Rc.decode(o),c=e.uint.decode(o),t=e.uint.decode(o),r=o.start<o.end?e.uint.decode(o):0;return{header:n,from:c,to:t,buildType:d>=20&&1&r?Bt.decode(o):null}}},Hc={RoomType:1,IsExperimental:2,IsJoiningDisabled:3,IsAppendingDisabled:4,IsCallingDisabled:5,IsMembershipEventsDisabled:6,IsAttachmentsDisabled:7,IsLinksDisabled:8,IsRoomInviteHidden:9},Vc={preencode(e,d){e.end++},encode(d,o){if(o>9)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Dc={en:"en",it:"it",ru:"ru",es:"es",de:"de"},Mc={preencode(e,d){e.end++},encode(d,o){switch(o){case"en":e.uint.encode(d,1);break;case"it":e.uint.encode(d,2);break;case"ru":e.uint.encode(d,3);break;case"es":e.uint.encode(d,4);break;case"de":e.uint.encode(d,5);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"en";case 2:return"it";case 3:return"ru";case 4:return"es";case 5:return"de";default:return null}}},Lc=Dd,qc={preencode(d,o){Lc.preencode(d,o.range),Mc.preencode(d,o.language),e.string.preencode(d,o.text)},encode(d,o){Lc.encode(d,o.range),Mc.encode(d,o.language),e.string.encode(d,o.text)},decode:d=>({range:Lc.decode(d),language:Mc.decode(d),text:e.string.decode(d)})},Ec={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.key)},decode:d=>({deviceKey:e.fixed32.decode(d),key:e.fixed32.decode(d)})},Bc=$,zc={preencode(d,o){Bc.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){Bc.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:Bc.decode(d),key:e.fixed32.decode(d)})},Nc=$,jc={preencode(d,o){Nc.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){Nc.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:Nc.decode(d),key:e.fixed32.decode(d)})},Oc={Flag:1},Uc={preencode(e,d){e.end++},encode(d,o){if(o>1)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Jc={preencode(d,o){lo.preencode(d,o.id),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),Uc.preencode(d,o.label)},encode(d,o){lo.encode(d,o.id),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),Uc.encode(d,o.label)},decode:d=>({id:lo.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),label:Uc.decode(d)})},Gc=$,Qc={preencode(e,d){Gc.preencode(e,d.header),n.preencode(e,d.oplog),Uc.preencode(e,d.label)},encode(e,d){Gc.encode(e,d.header),n.encode(e,d.oplog),Uc.encode(e,d.label)},decode:e=>({header:Gc.decode(e),oplog:n.decode(e),label:Uc.decode(e)})},Wc=$,Xc={preencode(e,d){Wc.preencode(e,d.header),n.preencode(e,d.oplog),Uc.preencode(e,d.label)},encode(e,d){Wc.encode(e,d.header),n.encode(e,d.oplog),Uc.encode(e,d.label)},decode:e=>({header:Wc.decode(e),oplog:n.decode(e),label:Uc.decode(e)})},Yc={preencode(d,o){Uc.preencode(d,o.label),e.uint.preencode(d,o.count)},encode(d,o){Uc.encode(d,o.label),e.uint.encode(d,o.count)},decode:d=>({label:Uc.decode(d),count:e.uint.decode(d)})},Zc=e.array(e.frame(Yc)),$c={preencode(o,n){lo.preencode(o,n.id),e.uint.preencode(o,n.total),Zc.preencode(o,n.labels),e.uint.preencode(o,n.editedAt),o.end++,d>=15&&n.flagsClock&&e.uint.preencode(o,n.flagsClock),d>=15&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(d>=15&&n.flagsClock?1:0)|(d>=15&&n.version?2:0)|(d>=16&&n.isDeleted?4:0);lo.encode(o,n.id),e.uint.encode(o,n.total),Zc.encode(o,n.labels),e.uint.encode(o,n.editedAt),e.uint.encode(o,c),d>=15&&n.flagsClock&&e.uint.encode(o,n.flagsClock),d>=15&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=lo.decode(o),c=e.uint.decode(o),t=Zc.decode(o),r=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{id:n,total:c,labels:t,editedAt:r,flagsClock:d>=15&&1&i?e.uint.decode(o):0,version:d>=15&&2&i?e.uint.decode(o):0,isDeleted:d>=16&&!!(4&i)}}},_c=$,et={preencode(d,o){_c.preencode(d,o.header),e.uint.preencode(d,o.length)},encode(d,o){_c.encode(d,o.header),e.uint.encode(d,o.length)},decode:d=>({header:_c.decode(d),length:e.uint.decode(d)})},dt={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.length)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.length)},decode:d=>({memberKey:e.fixed32.decode(d),length:e.uint.decode(d)})},ot=Z,nt={preencode(o,n){o.end++,d>=23&&n.profileSnoozeTime&&e.uint.preencode(o,n.profileSnoozeTime)},encode(o,n){const c=(d>=13&&n.disableReadReceipts?1:0)|(d>=21&&n.stripAttachmentMetadata?2:0)|(d>=23&&n.profileSnoozeTime?4:0);e.uint.encode(o,c),d>=23&&n.profileSnoozeTime&&e.uint.encode(o,n.profileSnoozeTime)},decode(o){const n=e.uint.decode(o);return{disableReadReceipts:d>=13&&!!(1&n),stripAttachmentMetadata:d>=21&&!!(2&n),profileSnoozeTime:d>=23&&4&n?e.uint.decode(o):0}}},ct={disableReadReceipts:"disableReadReceipts",stripAttachmentMetadata:"stripAttachmentMetadata",profileSnoozeTime:"profileSnoozeTime"},tt={preencode(e,d){e.end++},encode(d,o){switch(o){case"disableReadReceipts":e.uint.encode(d,1);break;case"stripAttachmentMetadata":e.uint.encode(d,2);break;case"profileSnoozeTime":e.uint.encode(d,3);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"disableReadReceipts";case 2:return"stripAttachmentMetadata";case 3:return"profileSnoozeTime";default:return null}}},rt=$,it=e.frame(nt),at={preencode(e,d){rt.preencode(e,d.header),tt.preencode(e,d.key),it.preencode(e,d.settings)},encode(e,d){rt.encode(e,d.header),tt.encode(e,d.key),it.encode(e,d.settings)},decode:e=>({header:rt.decode(e),key:tt.decode(e),settings:it.decode(e)})},st={Flag:1},pt={preencode(e,d){e.end++},encode(d,o){if(o>1)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},ut={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),pt.preencode(d,o.label)},encode(d,o){e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),pt.encode(d,o.label)},decode:d=>({key:e.fixed32.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),label:pt.decode(d)})},lt=$,ft={preencode(d,o){lt.preencode(d,o.header),e.fixed32.preencode(d,o.key),pt.preencode(d,o.label)},encode(d,o){lt.encode(d,o.header),e.fixed32.encode(d,o.key),pt.encode(d,o.label)},decode:d=>({header:lt.decode(d),key:e.fixed32.decode(d),label:pt.decode(d)})},mt={preencode(d,o){pt.preencode(d,o.label),e.uint.preencode(d,o.count)},encode(d,o){pt.encode(d,o.label),e.uint.encode(d,o.count)},decode:d=>({label:pt.decode(d),count:e.uint.decode(d)})},yt=e.array(e.frame(mt)),bt={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.total),yt.preencode(d,o.labels),e.uint.preencode(d,o.editedAt),e.uint.preencode(d,o.flagsClock)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.total),yt.encode(d,o.labels),e.uint.encode(d,o.editedAt),e.uint.encode(d,o.flagsClock)},decode:d=>({key:e.fixed32.decode(d),total:e.uint.decode(d),labels:yt.decode(d),editedAt:e.uint.decode(d),flagsClock:e.uint.decode(d)})},xt={preencode(d,o){e.float64.preencode(d,o.latitude),e.float64.preencode(d,o.longitude)},encode(d,o){e.float64.encode(d,o.latitude),e.float64.encode(d,o.longitude)},decode:d=>({latitude:e.float64.decode(d),longitude:e.float64.decode(d)})},kt=$,vt={preencode(d,o){kt.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.fromDeviceKey)},encode(d,o){kt.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.fromDeviceKey)},decode:d=>({header:kt.decode(d),deviceKey:e.fixed32.decode(d),fromDeviceKey:e.fixed32.decode(d)})},gt=$,ht=X,Kt={preencode(o,n){gt.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),e.buffer.preencode(o,n.encryptionKey),o.end++,d>=19&&n.streams&&ht.preencode(o,n.streams),d>=19&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=19&&n.version&&e.uint.preencode(o,n.version),d>=26&&n.streamInputs&&Aa.preencode(o,n.streamInputs),d>=26&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey)},encode(o,n){const c=(d>=19&&n.streams?1:0)|(d>=19&&n.discoveryKey?2:0)|(d>=19&&n.version?4:0)|(d>=26&&n.streamInputs?8:0)|(d>=26&&n.swarmKey?16:0);gt.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,c),d>=19&&n.streams&&ht.encode(o,n.streams),d>=19&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=19&&n.version&&e.uint.encode(o,n.version),d>=26&&n.streamInputs&&Aa.encode(o,n.streamInputs),d>=26&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey)},decode(o){const n=gt.decode(o),c=e.fixed32.decode(o),t=e.buffer.decode(o),r=e.uint.decode(o);return{header:n,callKey:c,encryptionKey:t,streams:d>=19&&1&r?ht.decode(o):null,discoveryKey:d>=19&&2&r?e.fixed32.decode(o):null,version:d>=19&&4&r?e.uint.decode(o):0,streamInputs:d>=26&&8&r?Aa.decode(o):null,swarmKey:d>=26&&16&r?e.fixed32.decode(o):null}}},wt=$,At=X,Tt={preencode(o,n){wt.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),o.end++,d>=19&&n.streams&&At.preencode(o,n.streams),d>=26&&n.streamInputs&&Ta.preencode(o,n.streamInputs),d>=26&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey)},encode(o,n){const c=(d>=19&&n.streams?1:0)|(d>=26&&n.streamInputs?2:0)|(d>=26&&n.swarmKey?4:0);wt.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.uint.encode(o,c),d>=19&&n.streams&&At.encode(o,n.streams),d>=26&&n.streamInputs&&Ta.encode(o,n.streamInputs),d>=26&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey)},decode(o){const n=wt.decode(o),c=e.fixed32.decode(o),t=e.uint.decode(o);return{header:n,callKey:c,streams:d>=19&&1&t?At.decode(o):null,streamInputs:d>=26&&2&t?Ta.decode(o):null,swarmKey:d>=26&&4&t?e.fixed32.decode(o):null}}},St=$,Pt={preencode(d,o){St.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){St.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:St.decode(d),callKey:e.fixed32.decode(d)})},It=$,Ft={preencode(d,o){It.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){It.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:It.decode(d),callKey:e.fixed32.decode(d)})},Rt=$,Ct={preencode(o,n){Rt.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.streamKey),o.end++,d>=26&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=26&&n.type&&e.string.preencode(o,n.type)},encode(o,n){const c=(d>=26&&n.mediaStreamId?1:0)|(d>=26&&n.type?2:0)|(d>=26&&n.muted?4:0);Rt.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.streamKey),e.uint.encode(o,c),d>=26&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=26&&n.type&&e.string.encode(o,n.type)},decode(o){const n=Rt.decode(o),c=e.fixed32.decode(o),t=e.fixed32.decode(o),r=o.start<o.end?e.uint.decode(o):0;return{header:n,callKey:c,streamKey:t,mediaStreamId:d>=26&&1&r?e.string.decode(o):null,type:d>=26&&2&r?e.string.decode(o):null,muted:d>=26&&!!(4&r)}}},Ht=$,Vt={preencode(d,o){Ht.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.streamKey)},encode(d,o){Ht.encode(d,o.header),e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.streamKey)},decode:d=>({header:Ht.decode(d),callKey:e.fixed32.decode(d),streamKey:e.fixed32.decode(d)})},Dt={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.buffer.preencode(o,n.encryptionKey),e.uint.preencode(o,n.createdAt),o.end++,d>=19&&n.endedAt&&e.uint.preencode(o,n.endedAt),d>=19&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=19&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(d>=19&&n.endedAt?1:0)|(d>=19&&n.discoveryKey?2:0)|(d>=19&&n.version?4:0);e.fixed32.encode(o,n.callKey),e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=19&&n.endedAt&&e.uint.encode(o,n.endedAt),d>=19&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=19&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=e.fixed32.decode(o),c=e.buffer.decode(o),t=e.uint.decode(o),r=e.uint.decode(o);return{callKey:n,encryptionKey:c,createdAt:t,endedAt:d>=19&&1&r?e.uint.decode(o):0,discoveryKey:d>=19&&2&r?e.fixed32.decode(o):null,version:d>=19&&4&r?e.uint.decode(o):0}}},Mt={preencode(d,o){e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.createdAt)},encode(d,o){e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.createdAt)},decode:d=>({callKey:e.fixed32.decode(d),memberKey:e.fixed32.decode(d),createdAt:e.uint.decode(d)})},Lt={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.deviceKey),e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.createdAt),o.end++,d>=19&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),d>=22&&n.lastHeartbeatAt&&e.uint.preencode(o,n.lastHeartbeatAt)},encode(o,n){const c=(d>=19&&n.swarmKey?1:0)|(d>=22&&n.lastHeartbeatAt?2:0)|(d>=23&&n.isRecording?4:0);e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.deviceKey),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=19&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey),d>=22&&n.lastHeartbeatAt&&e.uint.encode(o,n.lastHeartbeatAt)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=e.fixed32.decode(o),r=e.uint.decode(o),i=e.uint.decode(o);return{callKey:n,deviceKey:c,memberKey:t,createdAt:r,swarmKey:d>=19&&1&i?e.fixed32.decode(o):null,lastHeartbeatAt:d>=22&&2&i?e.uint.decode(o):0,isRecording:d>=23&&!!(4&i)}}},qt={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.deviceKey),e.buffer.preencode(o,n.streamKey),e.uint.preencode(o,n.createdAt),o.end++,d>=26&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=26&&n.type&&e.string.preencode(o,n.type),d>=26&&n.statusKey&&e.uint.preencode(o,n.statusKey)},encode(o,n){const c=(d>=26&&n.mediaStreamId?1:0)|(d>=26&&n.type?2:0)|(d>=26&&n.statusKey?4:0);e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.deviceKey),e.buffer.encode(o,n.streamKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=26&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=26&&n.type&&e.string.encode(o,n.type),d>=26&&n.statusKey&&e.uint.encode(o,n.statusKey)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=e.buffer.decode(o),r=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{callKey:n,deviceKey:c,streamKey:t,createdAt:r,mediaStreamId:d>=26&&1&i?e.string.decode(o):null,type:d>=26&&2&i?e.string.decode(o):null,statusKey:d>=26&&4&i?e.uint.decode(o):0}}},Et={Nightly:"Nightly",Internal:"Internal",Production:"Production"},Bt={preencode(e,d){e.end++},encode(d,o){switch(o){case"Nightly":e.uint.encode(d,1);break;case"Internal":e.uint.encode(d,2);break;case"Production":e.uint.encode(d,3);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"Nightly";case 2:return"Internal";case 3:return"Production";default:return null}}},zt=$,Nt={preencode(e,d){zt.preencode(e,d.header)},encode(e,d){zt.encode(e,d.header)},decode:e=>({header:zt.decode(e)})},jt=$,Ot={preencode(e,d){jt.preencode(e,d.header)},encode(e,d){jt.encode(e,d.header)},decode:e=>({header:jt.decode(e)})},Ut=$,Jt={preencode(d,o){Ut.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),e.buffer.preencode(d,o.deviceProof),e.buffer.preencode(d,o.writerProof)},encode(d,o){Ut.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.buffer.encode(d,o.deviceProof),e.buffer.encode(d,o.writerProof)},decode:d=>({header:Ut.decode(d),deviceKey:e.fixed32.decode(d),deviceProof:e.buffer.decode(d),writerProof:e.buffer.decode(d)})},Gt=$,Qt={preencode(d,o){Gt.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Gt.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Gt.decode(d),callKey:e.fixed32.decode(d)})},Wt=$,Xt={preencode(d,o){Wt.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.deviceKey)},encode(d,o){Wt.encode(d,o.header),e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.deviceKey)},decode:d=>({header:Wt.decode(d),callKey:e.fixed32.decode(d),deviceKey:e.fixed32.decode(d)})},Yt=$,Zt={preencode(d,o){Yt.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Yt.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Yt.decode(d),callKey:e.fixed32.decode(d)})},$t=$,_t={preencode(d,o){$t.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){$t.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:$t.decode(d),callKey:e.fixed32.decode(d)})},er=$,dr={preencode(e,d){er.preencode(e,d.header),n.preencode(e,d.oplog)},encode(e,d){er.encode(e,d.header),n.encode(e,d.oplog)},decode:e=>({header:er.decode(e),oplog:n.decode(e)})},or=$,nr={preencode(e,d){or.preencode(e,d.header)},encode(e,d){or.encode(e,d.header)},decode:e=>({header:or.decode(e)})},cr={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.timestamp)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.timestamp)},decode:d=>({memberKey:e.fixed32.decode(d),timestamp:e.uint.decode(d)})},tr=$,rr={preencode(o,n){tr.preencode(o,n.header),e.fixed32.preencode(o,n.memberKey),o.end++,d>=24&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=d>=24&&n.alias?1:0;tr.encode(o,n.header),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,c),d>=24&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=tr.decode(o),c=e.fixed32.decode(o),t=e.uint.decode(o);return{header:n,memberKey:c,alias:d>=24&&1&t?e.string.decode(o):null}}},ir={preencode(d,o){e.uint.preencode(d,o.streams)},encode(d,o){e.uint.encode(d,o.streams)},decode:d=>({streams:e.uint.decode(d)})},ar={preencode(d,o){e.fixed32.preencode(d,o.streamKey),e.string.preencode(d,o.mediaStreamId),e.string.preencode(d,o.type),d.end++},encode(o,n){const c=d>=26&&n.muted?1:0;e.fixed32.encode(o,n.streamKey),e.string.encode(o,n.mediaStreamId),e.string.encode(o,n.type),e.uint.encode(o,c)},decode(o){const n=e.fixed32.decode(o),c=e.string.decode(o),t=e.string.decode(o),r=e.uint.decode(o);return{streamKey:n,mediaStreamId:c,type:t,muted:d>=26&&!!(1&r)}}},sr=$,pr={preencode(d,o){sr.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.streamKey),d.end++},encode(o,n){const c=d>=26&&n.muted?1:0;sr.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.streamKey),e.uint.encode(o,c)},decode(o){const n=sr.decode(o),c=e.fixed32.decode(o),t=e.fixed32.decode(o),r=e.uint.decode(o);return{header:n,callKey:c,streamKey:t,muted:d>=26&&!!(1&r)}}},ur={preencode(d,o){e.uint.preencode(d,o.statusKey),d.end++},encode(o,n){const c=d>=26&&n.muted?1:0;e.uint.encode(o,n.statusKey),e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o),c=e.uint.decode(o);return{statusKey:n,muted:d>=26&&!!(1&c)}}},lr={preencode(n,c){e.fixed32.preencode(n,c.key),n.end++,d>=27&&c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const t=(d>=27&&c.encryptionKey?1:0)|(d>=27&&c.bootFrom?2:0);e.fixed32.encode(n,c.key),e.uint.encode(n,t),d>=27&&c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),t=e.uint.decode(n);return{key:c,encryptionKey:d>=27&&1&t?e.buffer.decode(n):null,bootFrom:d>=27&&2&t?o.decode(n):null}}},fr={preencode(d,o){e.fixed32.preencode(d,o.hash)},encode(d,o){e.fixed32.encode(d,o.hash)},decode:d=>({hash:e.fixed32.decode(d)})},mr={preencode(d,o){e.fixed32.preencode(d,o.hash),e.buffer.preencode(d,o.data)},encode(d,o){e.fixed32.encode(d,o.hash),e.buffer.encode(d,o.data)},decode:d=>({hash:e.fixed32.decode(d),data:e.buffer.decode(d)})},yr={preencode(n,c){o.preencode(n,c.autobeeMigrationHead),n.end++,d>=27&&c.legacyViewHead&&o.preencode(n,c.legacyViewHead),d>=27&&c.dbViewHead&&o.preencode(n,c.dbViewHead),d>=27&&c.blobsViewHead&&o.preencode(n,c.blobsViewHead),e.uint.preencode(n,c.createdAt)},encode(n,c){const t=(d>=27&&c.legacyViewHead?1:0)|(d>=27&&c.dbViewHead?2:0)|(d>=27&&c.blobsViewHead?4:0);o.encode(n,c.autobeeMigrationHead),e.uint.encode(n,t),d>=27&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=27&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=27&&c.blobsViewHead&&o.encode(n,c.blobsViewHead),e.uint.encode(n,c.createdAt)},decode(n){const c=o.decode(n),t=e.uint.decode(n);return{autobeeMigrationHead:c,legacyViewHead:d>=27&&1&t?o.decode(n):null,dbViewHead:d>=27&&2&t?o.decode(n):null,blobsViewHead:d>=27&&4&t?o.decode(n):null,createdAt:e.uint.decode(n)}}},br=$,xr={preencode(e,n){br.preencode(e,n.header),o.preencode(e,n.head),e.end++,d>=27&&n.legacyViewHead&&o.preencode(e,n.legacyViewHead),d>=27&&n.dbViewHead&&o.preencode(e,n.dbViewHead),d>=27&&n.blobsViewHead&&o.preencode(e,n.blobsViewHead)},encode(n,c){const t=(d>=27&&c.legacyViewHead?1:0)|(d>=27&&c.dbViewHead?2:0)|(d>=27&&c.blobsViewHead?4:0);br.encode(n,c.header),o.encode(n,c.head),e.uint.encode(n,t),d>=27&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=27&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=27&&c.blobsViewHead&&o.encode(n,c.blobsViewHead)},decode(n){const c=br.decode(n),t=o.decode(n),r=e.uint.decode(n);return{header:c,head:t,legacyViewHead:d>=27&&1&r?o.decode(n):null,dbViewHead:d>=27&&2&r?o.decode(n):null,blobsViewHead:d>=27&&4&r?o.decode(n):null}}},kr={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.fixed32.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.seed),n.end++,d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const t=d>=27&&c.bootFrom?1:0;e.fixed32.encode(n,c.roomKey),e.fixed32.encode(n,c.encryptionKey),e.fixed32.encode(n,c.seed),e.uint.encode(n,t),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),t=e.fixed32.decode(n),r=e.fixed32.decode(n),i=e.uint.decode(n);return{roomKey:c,encryptionKey:t,seed:r,bootFrom:d>=27&&1&i?o.decode(n):null}}},vr=id,gr={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.fixed32.preencode(d,o.deviceKey),e.uint.preencode(d,o.deviceLength),e.uint.preencode(d,o.clock),vr.preencode(d,o.status)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,o.deviceLength),e.uint.encode(d,o.clock),vr.encode(d,o.status)},decode:d=>({memberKey:e.fixed32.decode(d),deviceKey:e.fixed32.decode(d),deviceLength:e.uint.decode(d),clock:e.uint.decode(d),status:vr.decode(d)})},hr={preencode(d,o){e.fixed32.preencode(d,o.hash),e.buffer.preencode(d,o.blob)},encode(d,o){e.fixed32.encode(d,o.hash),e.buffer.encode(d,o.blob)},decode:d=>({hash:e.fixed32.decode(d),blob:e.buffer.decode(d)})},Kr=Rn,wr=Cn,Ar=vn,Tr={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),Kr.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,d>=27&&c.initiator&&o.preencode(n,c.initiator),d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=27&&c.identitySwap&&wr.preencode(n,c.identitySwap),d>=27&&c.identitySwapV2&&Ar.preencode(n,c.identitySwapV2),d>=27&&c.contact&&e.fixed32.preencode(n,c.contact)},encode(n,c){const t=(d>=27&&c.initiator?1:0)|(d>=27&&c.bootFrom?2:0)|(d>=27&&c.identitySwap?4:0)|(d>=27&&c.identitySwapV2?8:0)|(d>=27&&c.contact?16:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),Kr.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,t),d>=27&&c.initiator&&o.encode(n,c.initiator),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom),d>=27&&c.identitySwap&&wr.encode(n,c.identitySwap),d>=27&&c.identitySwapV2&&Ar.encode(n,c.identitySwapV2),d>=27&&c.contact&&e.fixed32.encode(n,c.contact)},decode(n){const c=e.fixed32.decode(n),t=e.buffer.decode(n),r=e.fixed32.decode(n),i=Kr.decode(n),a=e.uint.decode(n),s=e.uint.decode(n);return{roomKey:c,encryptionKey:t,mailbox:r,status:i,clock:a,initiator:d>=27&&1&s?o.decode(n):null,bootFrom:d>=27&&2&s?o.decode(n):null,identitySwap:d>=27&&4&s?wr.decode(n):null,identitySwapV2:d>=27&&8&s?Ar.decode(n):null,contact:d>=27&&16&s?e.fixed32.decode(n):null}}},Sr=$,Pr={preencode(n,c){Sr.preencode(n,c.header),e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),n.end++,d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=27&&c.initiator&&o.preencode(n,c.initiator),d>=27&&c.dm&&e.fixed32.preencode(n,c.dm)},encode(n,c){const t=(d>=27&&c.bootFrom?1:0)|(d>=27&&c.initiator?2:0)|(d>=27&&c.dm?4:0)|(d>=27&&c.isReadOnly?8:0);Sr.encode(n,c.header),e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),e.uint.encode(n,t),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom),d>=27&&c.initiator&&o.encode(n,c.initiator),d>=27&&c.dm&&e.fixed32.encode(n,c.dm)},decode(n){const c=Sr.decode(n),t=e.fixed32.decode(n),r=e.buffer.decode(n),i=e.fixed32.decode(n),a=e.uint.decode(n);return{header:c,roomKey:t,encryptionKey:r,mailbox:i,bootFrom:d>=27&&1&a?o.decode(n):null,initiator:d>=27&&2&a?o.decode(n):null,dm:d>=27&&4&a?e.fixed32.decode(n):null,isReadOnly:d>=27&&!!(8&a)}}},Ir={preencode(d,o){e.fixed32.preencode(d,o.id),e.fixed32.preencode(d,o.writerKey),e.buffer.preencode(d,o.blindResponse)},encode(d,o){e.fixed32.encode(d,o.id),e.fixed32.encode(d,o.writerKey),e.buffer.encode(d,o.blindResponse)},decode:d=>({id:e.fixed32.decode(d),writerKey:e.fixed32.decode(d),blindResponse:e.buffer.decode(d)})},Fr=$,Rr={preencode(d,o){Fr.preencode(d,o.header),e.buffer.preencode(d,o.blindResponse)},encode(d,o){Fr.encode(d,o.header),e.buffer.encode(d,o.blindResponse)},decode:d=>({header:Fr.decode(d),blindResponse:e.buffer.decode(d)})},Cr=$,Hr={preencode(e,d){Cr.preencode(e,d.header)},encode(e,d){Cr.encode(e,d.header)},decode:e=>({header:Cr.decode(e)})},Vr=$,Dr={preencode(o,c){Vr.preencode(o,c.header),n.preencode(o,c.oplog),e.uint.preencode(o,c.index),o.end++,d>=30&&c.displayType&&Sc.preencode(o,c.displayType)},encode(o,c){const t=d>=30&&c.displayType?1:0;Vr.encode(o,c.header),n.encode(o,c.oplog),e.uint.encode(o,c.index),e.uint.encode(o,t),d>=30&&c.displayType&&Sc.encode(o,c.displayType)},decode(o){const c=Vr.decode(o),t=n.decode(o),r=e.uint.decode(o),i=e.uint.decode(o);return{header:c,oplog:t,index:r,displayType:d>=30&&1&i?Sc.decode(o):0}}},Mr=$,Lr=jd,qr={preencode(d,o){Mr.preencode(d,o.header),n.preencode(d,o.oplog),Sc.preencode(d,o.displayType),e.uint.preencode(d,o.index),Lr.preencode(d,o.preview)},encode(d,o){Mr.encode(d,o.header),n.encode(d,o.oplog),Sc.encode(d,o.displayType),e.uint.encode(d,o.index),Lr.encode(d,o.preview)},decode:d=>({header:Mr.decode(d),oplog:n.decode(d),displayType:Sc.decode(d),index:e.uint.decode(d),preview:Lr.decode(d)})},Er=$,Br={preencode(d,o){Er.preencode(d,o.header),n.preencode(d,o.oplog),Sc.preencode(d,o.displayType),e.uint.preencode(d,o.index)},encode(d,o){Er.encode(d,o.header),n.encode(d,o.oplog),Sc.encode(d,o.displayType),e.uint.encode(d,o.index)},decode:d=>({header:Er.decode(d),oplog:n.decode(d),displayType:Sc.decode(d),index:e.uint.decode(d)})},zr={preencode(e,d){},encode(e,d){},decode:e=>({key:null})},Nr=ge,jr={preencode(d,o){e.fixed32.preencode(d,o.id),Nr.preencode(d,o.request)},encode(d,o){e.fixed32.encode(d,o.id),Nr.encode(d,o.request)},decode:d=>({deviceKey:null,id:e.fixed32.decode(d),request:Nr.decode(d)})},Or=te,Ur=re,Jr={preencode(d,o){e.fixed32.preencode(d,o.memberKey),Or.preencode(d,o.status),Sa.preencode(d,o.profile),d.end++,o.invitation&&Ur.preencode(d,o.invitation)},encode(d,o){const n=o.invitation?1:0;e.fixed32.encode(d,o.memberKey),Or.encode(d,o.status),Sa.encode(d,o.profile),e.uint.encode(d,n),o.invitation&&Ur.encode(d,o.invitation)},decode:d=>({key:null,memberKey:e.fixed32.decode(d),status:Or.decode(d),profile:Sa.decode(d),invitation:1&e.uint.decode(d)?Ur.decode(d):null})},Gr={preencode(d,o){d.end++,o.profileAttestation&&e.buffer.preencode(d,o.profileAttestation),o.latestReceipt&&e.buffer.preencode(d,o.latestReceipt)},encode(d,o){const n=(o.profileAttestation?1:0)|(o.latestReceipt?2:0);e.uint.encode(d,n),o.profileAttestation&&e.buffer.encode(d,o.profileAttestation),o.latestReceipt&&e.buffer.encode(d,o.latestReceipt)},decode(d){const o=e.uint.decode(d);return{key:null,profileAttestation:1&o?e.buffer.decode(d):null,latestReceipt:2&o?e.buffer.decode(d):null}}},Qr=id,Wr=pe,Xr={preencode(e,d){Qr.preencode(e,d.status),Wr.preencode(e,d.profile)},encode(e,d){Qr.encode(e,d.status),Wr.encode(e,d.profile)},decode:e=>({key:null,status:Qr.decode(e),profile:Wr.decode(e)})},Yr={preencode(d,o){e.uint.preencode(d,o.mentions)},encode(d,o){e.uint.encode(d,o.mentions)},decode:d=>({key:null,mentions:e.uint.decode(d)})},Zr=Ie,$r=Ve,_r={preencode(e,d){Zr.preencode(e,d.response),$r.preencode(e,d.metadata),e.end++,d.anchor&&o.preencode(e,d.anchor)},encode(d,n){const c=(n.anchor?1:0)|(n.isActive?2:0);Zr.encode(d,n.response),$r.encode(d,n.metadata),e.uint.encode(d,c),n.anchor&&o.encode(d,n.anchor)},decode(d){const n=Zr.decode(d),c=$r.decode(d),t=e.uint.decode(d);return{id:null,response:n,metadata:c,anchor:1&t?o.decode(d):null,isActive:!!(2&t)}}},ei=fo,di={preencode(d,o){e.uint.preencode(d,o.count),d.end++,o.parent&&n.preencode(d,o.parent),o.stats&&ei.preencode(d,o.stats)},encode(d,o){const c=(o.parent?1:0)|(o.stats?2:0);e.uint.encode(d,o.count),e.uint.encode(d,c),o.parent&&n.encode(d,o.parent),o.stats&&ei.encode(d,o.stats)},decode(d){const o=e.uint.decode(d),c=e.uint.decode(d);return{id:0,count:o,parent:1&c?n.decode(d):null,stats:2&c?ei.decode(d):null}}},oi={preencode(e,d){},encode(e,d){},decode:e=>({thread:0,index:0})},ni=yo,ci=bo,ti=xo,ri={preencode(d,o){lo.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),ni.preencode(d,o.status),o.message&&ci.preencode(d,o.message),o.event&&ti.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);lo.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),ni.encode(d,o.status),o.message&&ci.encode(d,o.message),o.event&&ti.encode(d,o.event)},decode(d){const o=lo.decode(d),c=n.decode(d),t=e.uint.decode(d),r=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:t,timestamp:r,editedAt:1&i?e.uint.decode(d):0,status:ni.decode(d),message:2&i?ci.decode(d):null,event:4&i?ti.decode(d):null}}},ii=oi,ai=Mo,si={preencode(o,n){lo.preencode(o,n.id),e.uint.preencode(o,n.total),ai.preencode(o,n.reactions),o.end++,d>=11&&n.editedAt&&e.uint.preencode(o,n.editedAt)},encode(o,n){const c=d>=11&&n.editedAt?1:0;lo.encode(o,n.id),e.uint.encode(o,n.total),ai.encode(o,n.reactions),e.uint.encode(o,c),d>=11&&n.editedAt&&e.uint.encode(o,n.editedAt)},decode(o){const n=lo.decode(o),c=e.uint.decode(o),t=ai.decode(o),r=o.start<o.end?e.uint.decode(o):0;return{id:n,total:c,reactions:t,editedAt:d>=11&&1&r?e.uint.decode(o):0}}},pi=oi,ui={preencode(d,o){lo.preencode(d,o.id),e.uint.preencode(d,o.clock)},encode(d,o){lo.encode(d,o.id),e.uint.encode(d,o.clock)},decode:d=>({id:lo.decode(d),sender:null,clock:e.uint.decode(d),reaction:null})},li=T,fi=g,mi={preencode(o,c){n.preencode(o,c.oplog),li.preencode(o,c.status),fi.preencode(o,c.file),o.end++,d>=14&&c.version&&e.uint.preencode(o,c.version)},encode(o,c){const t=d>=14&&c.version?1:0;n.encode(o,c.oplog),li.encode(o,c.status),fi.encode(o,c.file),e.uint.encode(o,t),d>=14&&c.version&&e.uint.encode(o,c.version)},decode(o){const c=n.decode(o),t=li.decode(o),r=fi.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{id:0,oplog:c,status:t,file:r,version:d>=14&&1&i?e.uint.decode(o):0}}},yi=vn,bi={preencode(n,c){e.fixed32.preencode(n,c.invitationSeed),e.fixed32.preencode(n,c.mailbox),t.preencode(n,c.responseKeyPair),o.preencode(n,c.initiator),o.preencode(n,c.inviter),n.end++,c.identity&&yi.preencode(n,c.identity),d>=20&&c.buildType&&Bt.preencode(n,c.buildType),d>=27&&c.link&&o.preencode(n,c.link)},encode(n,c){const r=(c.identity?1:0)|(d>=20&&c.buildType?2:0)|(d>=27&&c.link?4:0);e.fixed32.encode(n,c.invitationSeed),e.fixed32.encode(n,c.mailbox),t.encode(n,c.responseKeyPair),o.encode(n,c.initiator),o.encode(n,c.inviter),e.uint.encode(n,r),c.identity&&yi.encode(n,c.identity),d>=20&&c.buildType&&Bt.encode(n,c.buildType),d>=27&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),r=e.fixed32.decode(n),i=t.decode(n),a=o.decode(n),s=o.decode(n),p=e.uint.decode(n);return{id:null,invitationSeed:c,mailbox:r,responseKeyPair:i,initiator:a,inviter:s,identity:1&p?yi.decode(n):null,buildType:d>=20&&2&p?Bt.decode(n):null,link:d>=27&&4&p?o.decode(n):null}}},xi=Rn,ki=Cn,vi=vn,gi={preencode(n,c){e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),xi.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,c.initiator&&o.preencode(n,c.initiator),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),c.identitySwap&&ki.preencode(n,c.identitySwap),d>=6&&c.identitySwapV2&&vi.preencode(n,c.identitySwapV2),d>=10&&c.contact&&e.fixed32.preencode(n,c.contact),d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=29&&c.activeClock&&e.uint.preencode(n,c.activeClock)},encode(n,c){const t=(c.initiator?1:0)|(c.fastForwardTo?2:0)|(c.identitySwap?4:0)|(d>=6&&c.identitySwapV2?8:0)|(d>=10&&c.contact?16:0)|(d>=27&&c.bootFrom?32:0)|(d>=29&&c.activeClock?64:0);e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),xi.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,t),c.initiator&&o.encode(n,c.initiator),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),c.identitySwap&&ki.encode(n,c.identitySwap),d>=6&&c.identitySwapV2&&vi.encode(n,c.identitySwapV2),d>=10&&c.contact&&e.fixed32.encode(n,c.contact),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom),d>=29&&c.activeClock&&e.uint.encode(n,c.activeClock)},decode(n){const c=e.buffer.decode(n),t=e.fixed32.decode(n),r=xi.decode(n),i=e.uint.decode(n),a=e.uint.decode(n);return{roomKey:null,encryptionKey:c,mailbox:t,status:r,clock:i,initiator:1&a?o.decode(n):null,fastForwardTo:2&a?e.fixed32.decode(n):null,identitySwap:4&a?ki.decode(n):null,identitySwapV2:d>=6&&8&a?vi.decode(n):null,contact:d>=10&&16&a?e.fixed32.decode(n):null,bootFrom:d>=27&&32&a?o.decode(n):null,activeClock:d>=29&&64&a?e.uint.decode(n):0}}},hi={preencode(o,n){e.uint.preencode(o,n.clock),Pa.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=22&&n.contactInfo&&Ia.preencode(o,n.contactInfo),d>=24&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=22&&n.contactInfo?4:0)|(d>=24&&n.alias?8:0);e.uint.encode(o,n.clock),Pa.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=22&&n.contactInfo&&Ia.encode(o,n.contactInfo),d>=24&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.uint.decode(o),c=Pa.decode(o),t=e.uint.decode(o);return{memberKey:null,clock:n,status:c,mailbox:1&t?e.fixed32.decode(o):null,roomKey:2&t?e.fixed32.decode(o):null,contactInfo:d>=22&&4&t?Ia.decode(o):null,alias:d>=24&&8&t?e.string.decode(o):null}}},Ki=pe,wi=nc,Ai=$n,Ti={preencode(o,n){e.uint.preencode(o,n.clock),Ki.preencode(o,n.sender),wi.preencode(o,n.status),Ai.preencode(o,n.keys),e.fixed32.preencode(o,n.mailbox),o.end++,n.message&&e.string.preencode(o,n.message),d>=11&&n.sentAt&&e.uint.preencode(o,n.sentAt),d>=22&&n.contactInfo&&Fa.preencode(o,n.contactInfo)},encode(o,n){const c=(n.message?1:0)|(d>=11&&n.sentAt?2:0)|(d>=22&&n.contactInfo?4:0);e.uint.encode(o,n.clock),Ki.encode(o,n.sender),wi.encode(o,n.status),Ai.encode(o,n.keys),e.fixed32.encode(o,n.mailbox),e.uint.encode(o,c),n.message&&e.string.encode(o,n.message),d>=11&&n.sentAt&&e.uint.encode(o,n.sentAt),d>=22&&n.contactInfo&&Fa.encode(o,n.contactInfo)},decode(o){const n=e.uint.decode(o),c=Ki.decode(o),t=wi.decode(o),r=Ai.decode(o),i=e.fixed32.decode(o),a=e.uint.decode(o);return{memberKey:null,clock:n,sender:c,status:t,keys:r,mailbox:i,message:1&a?e.string.decode(o):null,sentAt:d>=11&&2&a?e.uint.decode(o):0,contactInfo:d>=22&&4&a?Fa.decode(o):null}}},Si={preencode(d,o){e.uint.preencode(d,o.value)},encode(d,o){e.uint.encode(d,o.value)},decode:d=>({key:0,value:e.uint.decode(d)})},Pi={preencode(d,o){ne.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){ne.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({deviceKey:null,privateProfileIdentity:ne.decode(d),deviceProof:e.buffer.decode(d)})},Ii={preencode(n,c){n.end++,c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const t=(c.encryptionKey?1:0)|(c.fastForwardTo?2:0)|(d>=27&&c.bootFrom?4:0);e.uint.encode(n,t),c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.uint.decode(n);return{key:null,encryptionKey:1&c?e.buffer.decode(n):null,fastForwardTo:2&c?e.fixed32.decode(n):null,bootFrom:d>=27&&4&c?o.decode(n):null}}},Fi=pe,Ri=nc,Ci=$n,Hi={preencode(o,n){e.uint.preencode(o,n.clock),Fi.preencode(o,n.sender),Ri.preencode(o,n.status),Ci.preencode(o,n.keys),e.fixed32.preencode(o,n.mailbox),o.end++,n.message&&e.string.preencode(o,n.message),d>=11&&n.sentAt&&e.uint.preencode(o,n.sentAt),d>=22&&n.contactInfo&&Ra.preencode(o,n.contactInfo)},encode(o,n){const c=(n.message?1:0)|(d>=11&&n.sentAt?2:0)|(d>=22&&n.contactInfo?4:0);e.uint.encode(o,n.clock),Fi.encode(o,n.sender),Ri.encode(o,n.status),Ci.encode(o,n.keys),e.fixed32.encode(o,n.mailbox),e.uint.encode(o,c),n.message&&e.string.encode(o,n.message),d>=11&&n.sentAt&&e.uint.encode(o,n.sentAt),d>=22&&n.contactInfo&&Ra.encode(o,n.contactInfo)},decode(o){const n=e.uint.decode(o),c=Fi.decode(o),t=Ri.decode(o),r=Ci.decode(o),i=e.fixed32.decode(o),a=e.uint.decode(o);return{memberKey:null,clock:n,sender:c,status:t,keys:r,mailbox:i,message:1&a?e.string.decode(o):null,sentAt:d>=11&&2&a?e.uint.decode(o):0,contactInfo:d>=22&&4&a?Ra.decode(o):null}}},Vi={preencode(d,o){e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.key)},decode:d=>({deviceKey:null,key:e.fixed32.decode(d)})},Di=oi,Mi={preencode(d,o){lo.preencode(d,o.id),e.uint.preencode(d,o.clock)},encode(d,o){lo.encode(d,o.id),e.uint.encode(d,o.clock)},decode:d=>({id:lo.decode(d),sender:null,clock:e.uint.decode(d),label:0})},Li=oi,qi=Zc,Ei={preencode(o,n){lo.preencode(o,n.id),e.uint.preencode(o,n.total),qi.preencode(o,n.labels),e.uint.preencode(o,n.editedAt),o.end++,d>=15&&n.flagsClock&&e.uint.preencode(o,n.flagsClock),d>=15&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(d>=15&&n.flagsClock?1:0)|(d>=15&&n.version?2:0)|(d>=16&&n.isDeleted?4:0);lo.encode(o,n.id),e.uint.encode(o,n.total),qi.encode(o,n.labels),e.uint.encode(o,n.editedAt),e.uint.encode(o,c),d>=15&&n.flagsClock&&e.uint.encode(o,n.flagsClock),d>=15&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=lo.decode(o),c=e.uint.decode(o),t=qi.decode(o),r=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{id:n,total:c,labels:t,editedAt:r,flagsClock:d>=15&&1&i?e.uint.decode(o):0,version:d>=15&&2&i?e.uint.decode(o):0,isDeleted:d>=16&&!!(4&i)}}},Bi={preencode(d,o){e.uint.preencode(d,o.length)},encode(d,o){e.uint.encode(d,o.length)},decode:d=>({memberKey:null,length:e.uint.decode(d)})},zi=zr,Ni={preencode(d,o){e.uint.preencode(d,o.clock)},encode(d,o){e.uint.encode(d,o.clock)},decode:d=>({key:null,sender:null,clock:e.uint.decode(d),label:0})},ji=yt,Oi={preencode(d,o){e.uint.preencode(d,o.total),ji.preencode(d,o.labels),e.uint.preencode(d,o.editedAt),e.uint.preencode(d,o.flagsClock)},encode(d,o){e.uint.encode(d,o.total),ji.encode(d,o.labels),e.uint.encode(d,o.editedAt),e.uint.encode(d,o.flagsClock)},decode:d=>({key:null,total:e.uint.decode(d),labels:ji.decode(d),editedAt:e.uint.decode(d),flagsClock:e.uint.decode(d)})},Ui={preencode(o,n){e.buffer.preencode(o,n.encryptionKey),e.uint.preencode(o,n.createdAt),o.end++,d>=19&&n.endedAt&&e.uint.preencode(o,n.endedAt),d>=19&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=19&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(d>=19&&n.endedAt?1:0)|(d>=19&&n.discoveryKey?2:0)|(d>=19&&n.version?4:0);e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=19&&n.endedAt&&e.uint.encode(o,n.endedAt),d>=19&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=19&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=e.buffer.decode(o),c=e.uint.decode(o),t=e.uint.decode(o);return{callKey:null,encryptionKey:n,createdAt:c,endedAt:d>=19&&1&t?e.uint.decode(o):0,discoveryKey:d>=19&&2&t?e.fixed32.decode(o):null,version:d>=19&&4&t?e.uint.decode(o):0}}},Ji={preencode(d,o){e.uint.preencode(d,o.createdAt)},encode(d,o){e.uint.encode(d,o.createdAt)},decode:d=>({callKey:null,memberKey:null,createdAt:e.uint.decode(d)})},Gi={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.createdAt),o.end++,d>=19&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),d>=22&&n.lastHeartbeatAt&&e.uint.preencode(o,n.lastHeartbeatAt)},encode(o,n){const c=(d>=19&&n.swarmKey?1:0)|(d>=22&&n.lastHeartbeatAt?2:0)|(d>=23&&n.isRecording?4:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=19&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey),d>=22&&n.lastHeartbeatAt&&e.uint.encode(o,n.lastHeartbeatAt)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),t=e.uint.decode(o);return{callKey:null,deviceKey:null,memberKey:n,createdAt:c,swarmKey:d>=19&&1&t?e.fixed32.decode(o):null,lastHeartbeatAt:d>=22&&2&t?e.uint.decode(o):0,isRecording:d>=23&&!!(4&t)}}},Qi={preencode(o,n){e.fixed32.preencode(o,n.deviceKey),e.uint.preencode(o,n.createdAt),o.end++,d>=26&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=26&&n.type&&e.string.preencode(o,n.type),d>=26&&n.statusKey&&e.uint.preencode(o,n.statusKey)},encode(o,n){const c=(d>=26&&n.mediaStreamId?1:0)|(d>=26&&n.type?2:0)|(d>=26&&n.statusKey?4:0);e.fixed32.encode(o,n.deviceKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=26&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=26&&n.type&&e.string.encode(o,n.type),d>=26&&n.statusKey&&e.uint.encode(o,n.statusKey)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),t=o.start<o.end?e.uint.decode(o):0;return{callKey:null,deviceKey:n,streamKey:null,createdAt:c,mediaStreamId:d>=26&&1&t?e.string.decode(o):null,type:d>=26&&2&t?e.string.decode(o):null,statusKey:d>=26&&4&t?e.uint.decode(o):0}}},Wi=Vi,Xi={preencode(d,o){e.uint.preencode(d,o.timestamp)},encode(d,o){e.uint.encode(d,o.timestamp)},decode:d=>({memberKey:null,timestamp:e.uint.decode(d)})},Yi={preencode(e,d){e.end++},encode(o,n){const c=d>=26&&n.muted?1:0;e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{statusKey:0,muted:d>=26&&!!(1&n)}}},Zi=id,$i={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.uint.preencode(d,o.deviceLength),e.uint.preencode(d,o.clock),Zi.preencode(d,o.status)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,o.deviceLength),e.uint.encode(d,o.clock),Zi.encode(d,o.status)},decode:d=>({memberKey:null,deviceKey:e.fixed32.decode(d),deviceLength:e.uint.decode(d),clock:e.uint.decode(d),status:Zi.decode(d)})},_i={preencode(d,o){e.buffer.preencode(d,o.data)},encode(d,o){e.buffer.encode(d,o.data)},decode:d=>({hash:null,data:e.buffer.decode(d)})},ea={preencode(d,o){e.fixed32.preencode(d,o.writerKey),e.buffer.preencode(d,o.blindResponse)},encode(d,o){e.fixed32.encode(d,o.writerKey),e.buffer.encode(d,o.blindResponse)},decode:d=>({id:null,writerKey:e.fixed32.decode(d),blindResponse:e.buffer.decode(d)})},da=e.frame(w),oa=e.frame(ir),na=da,ca=e.array(Mc),ta=e.frame(se),ra=da,ia=ta,aa=e.frame(hc),sa=e.frame(kr),pa=ta,ua=e.frame(fd),la=e.frame(yc),fa=e.frame(xt),ma=fa,ya=e.array(e.frame(qc)),ba=da,xa=e.frame(Nn),ka=e.frame(xc),va=xa,ga=ka,ha=xa,Ka=ka,wa=da,Aa=e.array(e.frame(ar)),Ta=Aa,Sa=ta,Pa=xa,Ia=ka,Fa=ka,Ra=ka;function Ca(e){switch(e){case"@keet/head":return o;case"@keet/oplog-id":return n;case"@keet/encryption-keypair":return c;case"@keet/signing-keypair":return t;case"@keet/room-keys":return r;case"@keet/operation-header":return i;case"@keet/blob-pointer":return a;case"@keet/file-dimensions":return s;case"@keet/file-metadata":return u;case"@keet/external-drive-pointer":return l;case"@keet/external-blob-pointer":return f;case"@keet/file-pointer":return b;case"@keet/file":return v;case"@keet/image-file":return w;case"@keet/file-status":return A;case"@keet/file-record":return P;case"@keet/device-status":return I;case"@keet/member-status":return F;case"@keet/member-moderation-status":return R;case"@keet/abi":return C;case"@keet/device-stats":return H;case"@keet/member-stats":return V;case"@keet/chat-stats":return D;case"@keet/file-stats":return M;case"@keet/stats":return z;case"@keet/room-type":return j;case"@keet/system-settings":return O;case"@keet/system-digest":return G;case"@keet/room-seed":return Q;case"@keet/room-capabilities":return W;case"@keet/room-config":return Y;case"@keet/blind-peer":return Z;case"@keet/add-blind-peer-operation":return ee;case"@keet/remove-blind-peer-operation":return oe;case"@keet/identity-attestation":return ne;case"@keet/device-invitation":return ce;case"@keet/device":return ie;case"@keet/member-profile":return ae;case"@keet/device-profile":return se;case"@keet/member-update":return ue;case"@keet/device-update":return le;case"@keet/signed-pairing-data":return fe;case"@keet/device-request-identity":return me;case"@keet/device-response-identity":return ye;case"@keet/device-request-with-invitation":return ve;case"@keet/device-request-with-invitation-and-proof":return he;case"@keet/device-request-with-member-proof":return Ae;case"@keet/device-request":return Pe;case"@keet/device-response":return Re;case"@keet/invitation-metadata":return Ce;case"@keet/invitation":return De;case"@keet/add-invitation-operation":return qe;case"@keet/remove-invitation-operation":return Be;case"@keet/sendable-room-invitation":return ze;case"@keet/sendable-identity-invitation":return Ne;case"@keet/sendable-contact-invitation":return je;case"@keet/sendable-invitation":return Qe;case"@keet/add-device-operation":return Xe;case"@keet/update-device-operation":return Ze;case"@keet/start-indexing-operation":return $e;case"@keet/stop-indexing-operation":return _e;case"@keet/join-request":return dd;case"@keet/accept-join-request-operation":return cd;case"@keet/reject-join-request-operation":return rd;case"@keet/member":return sd;case"@keet/full-member":return ld;case"@keet/member-proofs":return fd;case"@keet/update-member-operation":return bd;case"@keet/change-member-status-operation":return vd;case"@keet/change-member-role-operation":return hd;case"@keet/remove-member-operation":return wd;case"@keet/member-activity":return Ad;case"@keet/member-joined-event":return Td;case"@keet/member-left-event":return Sd;case"@keet/title-changed-chat-event":return Pd;case"@keet/chat-event":return Cd;case"@keet/sendable-event":return Hd;case"@keet/display-range":return Vd;case"@keet/display-content-range":return Md;case"@keet/mention-display-item":return qd;case"@keet/link-preview":return zd;case"@keet/display-link-item":return Od;case"@keet/display":return _d;case"@keet/oplog-message":return co;case"@keet/index-message":return io;case"@keet/full-index-message":return po;case"@keet/message-status":return uo;case"@keet/message-index-id":return lo;case"@keet/thread":return mo;case"@keet/chat-message-record":return ko;case"@keet/full-chat-message-record":return Ko;case"@keet/add-chat-message-operation":return To;case"@keet/remove-chat-message-operation":return Po;case"@keet/update-chat-message-operation":return Ro;case"@keet/pin-chat-message-operation":return Ho;case"@keet/reaction":return Vo;case"@keet/reactions-summary":return Do;case"@keet/reactions-digest":return Lo;case"@keet/add-reaction-operation":return Eo;case"@keet/remove-reaction-operation":return zo;case"@keet/update-room-config-operation":return Oo;case"@keet/group-member":return Uo;case"@keet/user-registry-info":return Jo;case"@keet/room-identity":return Qo;case"@keet/genesis-operation":return dn;case"@keet/upgrade-operation":return nn;case"@keet/update-system-settings-operation":return rn;case"@keet-private-id/contact":return an;case"@keet-private-id/v3-room-migration-info":return sn;case"@keet-private-id/run-v3-migration-operation":return ln;case"@keet-private-id/update-identity-operation":return mn;case"@keet-private-id/counters":return yn;case"@keet-private-id/stats":return bn;case"@keet-private-id/add-entropy-operation":return xn;case"@keet-private-id/pending-invitation-identity":return kn;case"@keet-private-id/pending-invitation":return gn;case"@keet-private-id/resolve-pending-invitation-operation":return Kn;case"@keet-private-id/add-pending-invitation-operation":return Tn;case"@keet-private-id/remove-pending-invitation-operation":return Pn;case"@keet-private-id/identity-swap":return In;case"@keet-private-id/room-status":return Fn;case"@keet-private-id/room":return Vn;case"@keet-private-id/add-room-operation":return Mn;case"@keet-private-id/remove-room-operation":return qn;case"@keet-private-id/update-room-status-operation":return zn;case"@keet-private-id/contact-status":return Nn;case"@keet-private-id/contact-record":return jn;case"@keet-private-id/add-contact-operation":return Jn;case"@keet-private-id/update-contact-status-operation":return Qn;case"@keet-private-id/remove-contact-operation":return Xn;case"@keet-private-id/contact-request-status":return Yn;case"@keet-private-id/contact-request-body":return _n;case"@keet-private-id/contact-request":return dc;case"@keet-private-id/contact-request-record":return tc;case"@keet-private-id/add-contact-request-operation":return ic;case"@keet-private-id/update-contact-request-status-operation":return pc;case"@keet-private-id/profile-discovery-record-v1":return uc;case"@keet-private-id/profile-discovery-record":return lc;case"@keet/add-file-preview-operation":return mc;case"@keet/member-removed-event":return yc;case"@keet/member-contact-info":return xc;case"@keet/remove-device-operation":return vc;case"@keet/device-identity":return gc;case"@keet/readonly-room-invitation":return hc;case"@keet-private-id/identity-swap-v2":return Kc;case"@keet-private-id/activate-contact-room-operation":return Ac;case"@keet/display-type":return Sc;case"@keet/test-increment-operation":return Ic;case"@keet/test-collection-record-1":return Fc;case"@keet/migrate-abi-operation":return Cc;case"@keet/system-settings-keys":return Vc;case"@keet/room-supported-language":return Mc;case"@keet/translation-display-item":return qc;case"@keet-private-id/unreads":return Ec;case"@keet-private-id/add-unreads-key-operation":return zc;case"@keet-private-id/remove-unreads-key-operation":return jc;case"@keet/label-type":return Uc;case"@keet/chat-label":return Jc;case"@keet/add-chat-label-operation":return Qc;case"@keet/remove-chat-label-operation":return Xc;case"@keet/chat-label-summary":return Yc;case"@keet/chat-label-digest":return $c;case"@keet/update-read-length-operation":return et;case"@keet/read-length":return dt;case"@keet/tmp-removed-member":return ot;case"@keet-private-id/settings":return nt;case"@keet-private-id/user-settings-key":return tt;case"@keet-private-id/update-settings-operation":return at;case"@keet/member-label-type":return pt;case"@keet/member-label":return ut;case"@keet/add-member-label-operation":return ft;case"@keet/member-label-summary":return mt;case"@keet/member-label-digest":return bt;case"@keet/location-shared-event":return xt;case"@keet/move-indexer-operation":return vt;case"@keet/start-call":return Kt;case"@keet/join-call":return Tt;case"@keet/leave-call":return Pt;case"@keet/end-call":return Ft;case"@keet/add-call-stream":return Ct;case"@keet/remove-call-stream":return Vt;case"@keet/call-record":return Dt;case"@keet/call-member-record":return Mt;case"@keet/call-device-record":return Lt;case"@keet/call-stream-record":return qt;case"@keet/build-type":return Bt;case"@keet/test-crash-operation":return Nt;case"@keet/test-dispatch-error-operation":return Ot;case"@keet-private-id/shorten-device-attestation-operation":return Jt;case"@keet/call-device-heartbeat":return Qt;case"@keet/remove-call-device":return Xt;case"@keet/start-call-recording":return Zt;case"@keet/stop-call-recording":return _t;case"@keet/dismiss-chat-reports-operation":return dr;case"@keet/update-typing-indicator-operation":return nr;case"@keet/typing-indicator":return cr;case"@keet-private-id/update-contact-alias-operation":return rr;case"@keet/call-stats":return ir;case"@keet/call-stream-input":return ar;case"@keet/update-call-stream":return pr;case"@keet/call-stream-status-record":return ur;case"@keet/room-keys-v2":return lr;case"@keet/blob-pointer-v2":return fr;case"@keet/blob":return mr;case"@keet/autobee-migration":return yr;case"@keet/autobee-migration-operation":return xr;case"@keet/readonly-room-invitation-v2":return kr;case"@keet/admin-last-seen":return gr;case"@keet/blob-record":return hr;case"@keet-private-id/room-v2":return Tr;case"@keet-private-id/add-room-operation-v2":return Pr;case"@keet-private-id/pending-invitation-response":return Ir;case"@keet-private-id/resolve-pending-invitation-operation-v2":return Rr;case"@keet/claim-admin-devices-operation":return Hr;case"@keet/remove-file-preview-operation":return Dr;case"@keet/add-link-preview-operation":return qr;case"@keet/remove-link-preview-operation":return Br;case"@keet/blind-peer/hyperdb#1":return zr;case"@keet/join-request/hyperdb#4":return jr;case"@keet/device/hyperdb#5":return Jr;case"@keet/member-proofs/hyperdb#10":return Gr;case"@keet/member/hyperdb#11":return Xr;case"@keet/member-activity/hyperdb#17":return Yr;case"@keet/invitation/hyperdb#18":return _r;case"@keet/thread/hyperdb#19":return di;case"@keet/message-index-id/hyperdb#21":return oi;case"@keet/chat-message-record/hyperdb#21":return ri;case"@keet/message-index-id/hyperdb#25":return ii;case"@keet/reactions-digest/hyperdb#25":return si;case"@keet/message-index-id/hyperdb#26":return pi;case"@keet/reaction/hyperdb#26":return ui;case"@keet/file-record/hyperdb#28":return mi;case"@keet-private-id/pending-invitation/hyperdb#35":return bi;case"@keet-private-id/room/hyperdb#36":return gi;case"@keet-private-id/contact-record/hyperdb#38":return hi;case"@keet-private-id/contact-request-record/hyperdb#40":return Ti;case"@keet/test-collection-record-1/hyperdb#46":return Si;case"@keet/device-identity/hyperdb#50":return Pi;case"@keet/room-keys/hyperdb#51":return Ii;case"@keet-private-id/contact-request-record/hyperdb#51":return Hi;case"@keet-private-id/unreads/hyperdb#59":return Vi;case"@keet/message-index-id/hyperdb#60":return Di;case"@keet/chat-label/hyperdb#60":return Mi;case"@keet/message-index-id/hyperdb#61":return Li;case"@keet/chat-label-digest/hyperdb#61":return Ei;case"@keet/read-length/hyperdb#62":return Bi;case"@keet/tmp-removed-member/hyperdb#63":return zi;case"@keet/member-label/hyperdb#66":return Ni;case"@keet/member-label-digest/hyperdb#67":return Oi;case"@keet/call-record/hyperdb#69":return Ui;case"@keet/call-member-record/hyperdb#72":return Ji;case"@keet/call-device-record/hyperdb#73":return Gi;case"@keet/call-stream-record/hyperdb#75":return Qi;case"@keet-private-id/unreads/hyperdb#77":return Wi;case"@keet/typing-indicator/hyperdb#78":return Xi;case"@keet/call-stream-status-record/hyperdb#80":return Yi;case"@keet/admin-last-seen/hyperdb#81":return $i;case"@keet/blob/hyperdb#83":return _i;case"@keet-private-id/pending-invitation-response/hyperdb#85":return ea;default:throw new Error("Encoder not found "+e)}}function Ha(e,o=31){const n=Ca(e);return{preencode(e,c){d=o,n.preencode(e,c)},encode(e,c){d=o,n.encode(e,c)},decode:e=>(d=o,n.decode(e))}}const Va=Ha;module.exports={resolveStruct:Va,getStruct:Ha,getEnum:function(e){switch(e){case"@keet/room-type":return N;case"@keet/display-type":return Tc;case"@keet/system-settings-keys":return Hc;case"@keet/room-supported-language":return Dc;case"@keet/label-type":return Oc;case"@keet-private-id/user-settings-key":return ct;case"@keet/member-label-type":return st;case"@keet/build-type":return Et;default:throw new Error("Enum not found "+e)}},getEncoding:Ca,encode:function(o,n,c=31){return d=c,e.encode(Ca(o),n)},decode:function(o,n,c=31){return d=c,e.decode(Ca(o),n)},setVersion:function(e){d=e},version:d};
@holepunchto/keet-core/schema/spec/contract/hyperdispatch/index.js +1 -1
……@@ -1 +1 @@
1const{c:e,b4a:t,assert:a,DispatchError:r,ERRORS:n}=require("hyperdispatch/runtime"),{version:i,getEncoding:s,setVersion:d}=require("./messages.js"),l=i;function h(t,{version:a=l}={}){const n={buffer:t,start:0,end:t.length},i=e.uint.decode(n),s=function(e){switch(e){case 2:return c;case 3:return u;case 4:return o;case 5:return k;case 6:return v;case 7:return p;case 8:return _;case 9:return m;case 10:return g;case 11:return b;case 12:return f;case 13:return M;case 14:return y;case 15:return q;case 16:return j;case 17:return x;case 18:return w;case 19:return E;case 20:return N;case 21:return O;case 22:return R;case 23:return D;case 24:return T;case 25:return U;case 26:return A;case 27:return B;case 28:return F;case 29:return I;case 30:return S;case 31:return Y;case 32:return H;case 33:return L;case 34:return V;case 35:return X;case 36:return z;case 37:return C;case 38:return G;case 39:return J;case 40:return K;case 41:return P;case 42:return Q;case 43:return W;case 44:return Z;case 45:return $;case 46:return ee;case 47:return te;case 48:return ae;case 49:return re;case 50:return ne;case 51:return ie;case 52:return se;case 53:return de;case 54:return le;case 55:return he;case 56:return ce;case 57:return ue;case 58:return oe;case 59:return ke;case 60:return ve;case 61:return pe;case 62:return _e;case 63:return me;case 64:return ge;case 65:return be;case 66:return fe;case 67:return Me;case 68:return ye;case 69:return qe;case 70:return je;case 71:return xe;default:throw r.HANDLER_NOT_FOUND_BY_ID(e)}}(i);d(a);const h=s.enc.decode(n);return{id:i,name:s.name,value:h}}const c={name:"@keet/genesis",id:2,enc:s("@keet/genesis-operation")},u={name:"@keet/upgrade",id:3,enc:s("@keet/upgrade-operation")},o={name:"@keet/update-system-settings",id:4,enc:s("@keet/update-system-settings-operation")},k={name:"@keet/add-blind-peer",id:5,enc:s("@keet/add-blind-peer-operation")},v={name:"@keet/remove-blind-peer",id:6,enc:s("@keet/remove-blind-peer-operation")},p={name:"@keet/add-device",id:7,enc:s("@keet/add-device-operation")},_={name:"@keet/update-device",id:8,enc:s("@keet/update-device-operation")},m={name:"@keet/start-indexing",id:9,enc:s("@keet/start-indexing-operation")},g={name:"@keet/stop-indexing",id:10,enc:s("@keet/stop-indexing-operation")},b={name:"@keet/accept-join-request",id:11,enc:s("@keet/accept-join-request-operation")},f={name:"@keet/reject-join-request",id:12,enc:s("@keet/reject-join-request-operation")},M={name:"@keet/update-member",id:13,enc:s("@keet/update-member-operation")},y={name:"@keet/change-member-role",id:14,enc:s("@keet/change-member-role-operation")},q={name:"@keet/change-member-status",id:15,enc:s("@keet/change-member-status-operation")},j={name:"@keet/remove-member",id:16,enc:s("@keet/remove-member-operation")},x={name:"@keet/add-invitation",id:17,enc:s("@keet/add-invitation-operation")},w={name:"@keet/remove-invitation",id:18,enc:s("@keet/remove-invitation-operation")},E={name:"@keet/add-chat-message",id:19,enc:s("@keet/add-chat-message-operation")},N={name:"@keet/remove-chat-message",id:20,enc:s("@keet/remove-chat-message-operation")},O={name:"@keet/update-chat-message",id:21,enc:s("@keet/update-chat-message-operation")},R={name:"@keet/pin-chat-message",id:22,enc:s("@keet/pin-chat-message-operation")},D={name:"@keet/add-reaction",id:23,enc:s("@keet/add-reaction-operation")},T={name:"@keet/remove-reaction",id:24,enc:s("@keet/remove-reaction-operation")},U={name:"@keet/update-room-config",id:25,enc:s("@keet/update-room-config-operation")},A={name:"@keet-private-id/run-v3-migration",id:26,enc:s("@keet-private-id/run-v3-migration-operation")},B={name:"@keet-private-id/update-identity",id:27,enc:s("@keet-private-id/update-identity-operation")},F={name:"@keet-private-id/resolve-pending-invitation",id:28,enc:s("@keet-private-id/resolve-pending-invitation-operation")},I={name:"@keet-private-id/add-pending-invitation",id:29,enc:s("@keet-private-id/add-pending-invitation-operation")},S={name:"@keet-private-id/remove-pending-invitation",id:30,enc:s("@keet-private-id/remove-pending-invitation-operation")},Y={name:"@keet-private-id/add-room",id:31,enc:s("@keet-private-id/add-room-operation")},H={name:"@keet-private-id/remove-room",id:32,enc:s("@keet-private-id/remove-room-operation")},L={name:"@keet-private-id/update-room-status",id:33,enc:s("@keet-private-id/update-room-status-operation")},V={name:"@keet-private-id/add-contact",id:34,enc:s("@keet-private-id/add-contact-operation")},X={name:"@keet-private-id/update-contact-status",id:35,enc:s("@keet-private-id/update-contact-status-operation")},z={name:"@keet-private-id/remove-contact",id:36,enc:s("@keet-private-id/remove-contact-operation")},C={name:"@keet-private-id/add-contact-request",id:37,enc:s("@keet-private-id/add-contact-request-operation")},G={name:"@keet-private-id/update-contact-request-status",id:38,enc:s("@keet-private-id/update-contact-request-status-operation")},J={name:"@keet/add-file-preview",id:39,enc:s("@keet/add-file-preview-operation")},K={name:"@keet/remove-device",id:40,enc:s("@keet/remove-device-operation")},P={name:"@keet-private-id/activate-contact-room",id:41,enc:s("@keet-private-id/activate-contact-room-operation")},Q={name:"@keet/test-increment",id:42,enc:s("@keet/test-increment-operation")},W={name:"@keet/migrate-abi",id:43,enc:s("@keet/migrate-abi-operation")},Z={name:"@keet-private-id/add-unreads-key",id:44,enc:s("@keet-private-id/add-unreads-key-operation")},$={name:"@keet-private-id/remove-unreads-key",id:45,enc:s("@keet-private-id/remove-unreads-key-operation")},ee={name:"@keet/add-chat-label",id:46,enc:s("@keet/add-chat-label-operation")},te={name:"@keet/remove-chat-label",id:47,enc:s("@keet/remove-chat-label-operation")},ae={name:"@keet/update-read-length",id:48,enc:s("@keet/update-read-length-operation")},re={name:"@keet-private-id/update-settings",id:49,enc:s("@keet-private-id/update-settings-operation")},ne={name:"@keet/add-member-label",id:50,enc:s("@keet/add-member-label-operation")},ie={name:"@keet/move-indexer",id:51,enc:s("@keet/move-indexer-operation")},se={name:"@keet/start-call",id:52,enc:s("@keet/start-call")},de={name:"@keet/join-call",id:53,enc:s("@keet/join-call")},le={name:"@keet/leave-call",id:54,enc:s("@keet/leave-call")},he={name:"@keet/end-call",id:55,enc:s("@keet/end-call")},ce={name:"@keet/add-call-stream",id:56,enc:s("@keet/add-call-stream")},ue={name:"@keet/remove-call-stream",id:57,enc:s("@keet/remove-call-stream")},oe={name:"@keet/test-crash",id:58,enc:s("@keet/test-crash-operation")},ke={name:"@keet/test-dispatch-error",id:59,enc:s("@keet/test-dispatch-error-operation")},ve={name:"@keet-private-id/shorten-device-attestation",id:60,enc:s("@keet-private-id/shorten-device-attestation-operation")},pe={name:"@keet/call-device-heartbeat",id:61,enc:s("@keet/call-device-heartbeat")},_e={name:"@keet/remove-call-device",id:62,enc:s("@keet/remove-call-device")},me={name:"@keet/start-call-recording",id:63,enc:s("@keet/start-call-recording")},ge={name:"@keet/stop-call-recording",id:64,enc:s("@keet/stop-call-recording")},be={name:"@keet/update-typing-indicator",id:65,enc:s("@keet/update-typing-indicator-operation")},fe={name:"@keet/dismiss-chat-reports",id:66,enc:s("@keet/dismiss-chat-reports-operation")},Me={name:"@keet-private-id/update-contact-alias",id:67,enc:s("@keet-private-id/update-contact-alias-operation")},ye={name:"@keet/update-call-stream",id:68,enc:s("@keet/update-call-stream")},qe={name:"@keet-private-id/add-room-v2",id:69,enc:s("@keet-private-id/add-room-operation-v2")},je={name:"@keet/autobee-migration",id:70,enc:s("@keet/autobee-migration-operation")},xe={name:"@keet-private-id/resolve-pending-invitation-v2",id:71,enc:s("@keet-private-id/resolve-pending-invitation-operation-v2")};module.exports={version:i,encode:function(a,n,{version:i=l}={}){const s={buffer:null,start:0,end:0},h=function(e){switch(e){case"@keet/genesis":return c;case"@keet/upgrade":return u;case"@keet/update-system-settings":return o;case"@keet/add-blind-peer":return k;case"@keet/remove-blind-peer":return v;case"@keet/add-device":return p;case"@keet/update-device":return _;case"@keet/start-indexing":return m;case"@keet/stop-indexing":return g;case"@keet/accept-join-request":return b;case"@keet/reject-join-request":return f;case"@keet/update-member":return M;case"@keet/change-member-role":return y;case"@keet/change-member-status":return q;case"@keet/remove-member":return j;case"@keet/add-invitation":return x;case"@keet/remove-invitation":return w;case"@keet/add-chat-message":return E;case"@keet/remove-chat-message":return N;case"@keet/update-chat-message":return O;case"@keet/pin-chat-message":return R;case"@keet/add-reaction":return D;case"@keet/remove-reaction":return T;case"@keet/update-room-config":return U;case"@keet-private-id/run-v3-migration":return A;case"@keet-private-id/update-identity":return B;case"@keet-private-id/resolve-pending-invitation":return F;case"@keet-private-id/add-pending-invitation":return I;case"@keet-private-id/remove-pending-invitation":return S;case"@keet-private-id/add-room":return Y;case"@keet-private-id/remove-room":return H;case"@keet-private-id/update-room-status":return L;case"@keet-private-id/add-contact":return V;case"@keet-private-id/update-contact-status":return X;case"@keet-private-id/remove-contact":return z;case"@keet-private-id/add-contact-request":return C;case"@keet-private-id/update-contact-request-status":return G;case"@keet/add-file-preview":return J;case"@keet/remove-device":return K;case"@keet-private-id/activate-contact-room":return P;case"@keet/test-increment":return Q;case"@keet/migrate-abi":return W;case"@keet-private-id/add-unreads-key":return Z;case"@keet-private-id/remove-unreads-key":return $;case"@keet/add-chat-label":return ee;case"@keet/remove-chat-label":return te;case"@keet/update-read-length":return ae;case"@keet-private-id/update-settings":return re;case"@keet/add-member-label":return ne;case"@keet/move-indexer":return ie;case"@keet/start-call":return se;case"@keet/join-call":return de;case"@keet/leave-call":return le;case"@keet/end-call":return he;case"@keet/add-call-stream":return ce;case"@keet/remove-call-stream":return ue;case"@keet/test-crash":return oe;case"@keet/test-dispatch-error":return ke;case"@keet-private-id/shorten-device-attestation":return ve;case"@keet/call-device-heartbeat":return pe;case"@keet/remove-call-device":return _e;case"@keet/start-call-recording":return me;case"@keet/stop-call-recording":return ge;case"@keet/update-typing-indicator":return be;case"@keet/dismiss-chat-reports":return fe;case"@keet-private-id/update-contact-alias":return Me;case"@keet/update-call-stream":return ye;case"@keet-private-id/add-room-v2":return qe;case"@keet/autobee-migration":return je;case"@keet-private-id/resolve-pending-invitation-v2":return xe;default:throw r.ROUTE_NOT_FOUND_BY_NAME(e)}}(a);return d(i),e.uint.preencode(s,h.id),h.enc.preencode(s,n),s.buffer=t.allocUnsafe(s.end),e.uint.encode(s,h.id),h.enc.encode(s,n),s.buffer},decode:h,Router:class{constructor(){this._handler2=null,this._handler3=null,this._handler4=null,this._handler5=null,this._handler6=null,this._handler7=null,this._handler8=null,this._handler9=null,this._handler10=null,this._handler11=null,this._handler12=null,this._handler13=null,this._handler14=null,this._handler15=null,this._handler16=null,this._handler17=null,this._handler18=null,this._handler19=null,this._handler20=null,this._handler21=null,this._handler22=null,this._handler23=null,this._handler24=null,this._handler25=null,this._handler26=null,this._handler27=null,this._handler28=null,this._handler29=null,this._handler30=null,this._handler31=null,this._handler32=null,this._handler33=null,this._handler34=null,this._handler35=null,this._handler36=null,this._handler37=null,this._handler38=null,this._handler39=null,this._handler40=null,this._handler41=null,this._handler42=null,this._handler43=null,this._handler44=null,this._handler45=null,this._handler46=null,this._handler47=null,this._handler48=null,this._handler49=null,this._handler50=null,this._handler51=null,this._handler52=null,this._handler53=null,this._handler54=null,this._handler55=null,this._handler56=null,this._handler57=null,this._handler58=null,this._handler59=null,this._handler60=null,this._handler61=null,this._handler62=null,this._handler63=null,this._handler64=null,this._handler65=null,this._handler66=null,this._handler67=null,this._handler68=null,this._handler69=null,this._handler70=null,this._handler71=null,this._missing=70}add(e,t){switch(e){case"@keet/genesis":this._handler2=t;break;case"@keet/upgrade":this._handler3=t;break;case"@keet/update-system-settings":this._handler4=t;break;case"@keet/add-blind-peer":this._handler5=t;break;case"@keet/remove-blind-peer":this._handler6=t;break;case"@keet/add-device":this._handler7=t;break;case"@keet/update-device":this._handler8=t;break;case"@keet/start-indexing":this._handler9=t;break;case"@keet/stop-indexing":this._handler10=t;break;case"@keet/accept-join-request":this._handler11=t;break;case"@keet/reject-join-request":this._handler12=t;break;case"@keet/update-member":this._handler13=t;break;case"@keet/change-member-role":this._handler14=t;break;case"@keet/change-member-status":this._handler15=t;break;case"@keet/remove-member":this._handler16=t;break;case"@keet/add-invitation":this._handler17=t;break;case"@keet/remove-invitation":this._handler18=t;break;case"@keet/add-chat-message":this._handler19=t;break;case"@keet/remove-chat-message":this._handler20=t;break;case"@keet/update-chat-message":this._handler21=t;break;case"@keet/pin-chat-message":this._handler22=t;break;case"@keet/add-reaction":this._handler23=t;break;case"@keet/remove-reaction":this._handler24=t;break;case"@keet/update-room-config":this._handler25=t;break;case"@keet-private-id/run-v3-migration":this._handler26=t;break;case"@keet-private-id/update-identity":this._handler27=t;break;case"@keet-private-id/resolve-pending-invitation":this._handler28=t;break;case"@keet-private-id/add-pending-invitation":this._handler29=t;break;case"@keet-private-id/remove-pending-invitation":this._handler30=t;break;case"@keet-private-id/add-room":this._handler31=t;break;case"@keet-private-id/remove-room":this._handler32=t;break;case"@keet-private-id/update-room-status":this._handler33=t;break;case"@keet-private-id/add-contact":this._handler34=t;break;case"@keet-private-id/update-contact-status":this._handler35=t;break;case"@keet-private-id/remove-contact":this._handler36=t;break;case"@keet-private-id/add-contact-request":this._handler37=t;break;case"@keet-private-id/update-contact-request-status":this._handler38=t;break;case"@keet/add-file-preview":this._handler39=t;break;case"@keet/remove-device":this._handler40=t;break;case"@keet-private-id/activate-contact-room":this._handler41=t;break;case"@keet/test-increment":this._handler42=t;break;case"@keet/migrate-abi":this._handler43=t;break;case"@keet-private-id/add-unreads-key":this._handler44=t;break;case"@keet-private-id/remove-unreads-key":this._handler45=t;break;case"@keet/add-chat-label":this._handler46=t;break;case"@keet/remove-chat-label":this._handler47=t;break;case"@keet/update-read-length":this._handler48=t;break;case"@keet-private-id/update-settings":this._handler49=t;break;case"@keet/add-member-label":this._handler50=t;break;case"@keet/move-indexer":this._handler51=t;break;case"@keet/start-call":this._handler52=t;break;case"@keet/join-call":this._handler53=t;break;case"@keet/leave-call":this._handler54=t;break;case"@keet/end-call":this._handler55=t;break;case"@keet/add-call-stream":this._handler56=t;break;case"@keet/remove-call-stream":this._handler57=t;break;case"@keet/test-crash":this._handler58=t;break;case"@keet/test-dispatch-error":this._handler59=t;break;case"@keet-private-id/shorten-device-attestation":this._handler60=t;break;case"@keet/call-device-heartbeat":this._handler61=t;break;case"@keet/remove-call-device":this._handler62=t;break;case"@keet/start-call-recording":this._handler63=t;break;case"@keet/stop-call-recording":this._handler64=t;break;case"@keet/update-typing-indicator":this._handler65=t;break;case"@keet/dismiss-chat-reports":this._handler66=t;break;case"@keet-private-id/update-contact-alias":this._handler67=t;break;case"@keet/update-call-stream":this._handler68=t;break;case"@keet-private-id/add-room-v2":this._handler69=t;break;case"@keet/autobee-migration":this._handler70=t;break;case"@keet-private-id/resolve-pending-invitation-v2":this._handler71=t;break;default:throw r.NONEXISTENT_ROUTE(e)}this._missing--}_checkAll(){a(null!==this._handler2,'Missing handler for "@keet/genesis"'),a(null!==this._handler3,'Missing handler for "@keet/upgrade"'),a(null!==this._handler4,'Missing handler for "@keet/update-system-settings"'),a(null!==this._handler5,'Missing handler for "@keet/add-blind-peer"'),a(null!==this._handler6,'Missing handler for "@keet/remove-blind-peer"'),a(null!==this._handler7,'Missing handler for "@keet/add-device"'),a(null!==this._handler8,'Missing handler for "@keet/update-device"'),a(null!==this._handler9,'Missing handler for "@keet/start-indexing"'),a(null!==this._handler10,'Missing handler for "@keet/stop-indexing"'),a(null!==this._handler11,'Missing handler for "@keet/accept-join-request"'),a(null!==this._handler12,'Missing handler for "@keet/reject-join-request"'),a(null!==this._handler13,'Missing handler for "@keet/update-member"'),a(null!==this._handler14,'Missing handler for "@keet/change-member-role"'),a(null!==this._handler15,'Missing handler for "@keet/change-member-status"'),a(null!==this._handler16,'Missing handler for "@keet/remove-member"'),a(null!==this._handler17,'Missing handler for "@keet/add-invitation"'),a(null!==this._handler18,'Missing handler for "@keet/remove-invitation"'),a(null!==this._handler19,'Missing handler for "@keet/add-chat-message"'),a(null!==this._handler20,'Missing handler for "@keet/remove-chat-message"'),a(null!==this._handler21,'Missing handler for "@keet/update-chat-message"'),a(null!==this._handler22,'Missing handler for "@keet/pin-chat-message"'),a(null!==this._handler23,'Missing handler for "@keet/add-reaction"'),a(null!==this._handler24,'Missing handler for "@keet/remove-reaction"'),a(null!==this._handler25,'Missing handler for "@keet/update-room-config"'),a(null!==this._handler26,'Missing handler for "@keet-private-id/run-v3-migration"'),a(null!==this._handler27,'Missing handler for "@keet-private-id/update-identity"'),a(null!==this._handler28,'Missing handler for "@keet-private-id/resolve-pending-invitation"'),a(null!==this._handler29,'Missing handler for "@keet-private-id/add-pending-invitation"'),a(null!==this._handler30,'Missing handler for "@keet-private-id/remove-pending-invitation"'),a(null!==this._handler31,'Missing handler for "@keet-private-id/add-room"'),a(null!==this._handler32,'Missing handler for "@keet-private-id/remove-room"'),a(null!==this._handler33,'Missing handler for "@keet-private-id/update-room-status"'),a(null!==this._handler34,'Missing handler for "@keet-private-id/add-contact"'),a(null!==this._handler35,'Missing handler for "@keet-private-id/update-contact-status"'),a(null!==this._handler36,'Missing handler for "@keet-private-id/remove-contact"'),a(null!==this._handler37,'Missing handler for "@keet-private-id/add-contact-request"'),a(null!==this._handler38,'Missing handler for "@keet-private-id/update-contact-request-status"'),a(null!==this._handler39,'Missing handler for "@keet/add-file-preview"'),a(null!==this._handler40,'Missing handler for "@keet/remove-device"'),a(null!==this._handler41,'Missing handler for "@keet-private-id/activate-contact-room"'),a(null!==this._handler42,'Missing handler for "@keet/test-increment"'),a(null!==this._handler43,'Missing handler for "@keet/migrate-abi"'),a(null!==this._handler44,'Missing handler for "@keet-private-id/add-unreads-key"'),a(null!==this._handler45,'Missing handler for "@keet-private-id/remove-unreads-key"'),a(null!==this._handler46,'Missing handler for "@keet/add-chat-label"'),a(null!==this._handler47,'Missing handler for "@keet/remove-chat-label"'),a(null!==this._handler48,'Missing handler for "@keet/update-read-length"'),a(null!==this._handler49,'Missing handler for "@keet-private-id/update-settings"'),a(null!==this._handler50,'Missing handler for "@keet/add-member-label"'),a(null!==this._handler51,'Missing handler for "@keet/move-indexer"'),a(null!==this._handler52,'Missing handler for "@keet/start-call"'),a(null!==this._handler53,'Missing handler for "@keet/join-call"'),a(null!==this._handler54,'Missing handler for "@keet/leave-call"'),a(null!==this._handler55,'Missing handler for "@keet/end-call"'),a(null!==this._handler56,'Missing handler for "@keet/add-call-stream"'),a(null!==this._handler57,'Missing handler for "@keet/remove-call-stream"'),a(null!==this._handler58,'Missing handler for "@keet/test-crash"'),a(null!==this._handler59,'Missing handler for "@keet/test-dispatch-error"'),a(null!==this._handler60,'Missing handler for "@keet-private-id/shorten-device-attestation"'),a(null!==this._handler61,'Missing handler for "@keet/call-device-heartbeat"'),a(null!==this._handler62,'Missing handler for "@keet/remove-call-device"'),a(null!==this._handler63,'Missing handler for "@keet/start-call-recording"'),a(null!==this._handler64,'Missing handler for "@keet/stop-call-recording"'),a(null!==this._handler65,'Missing handler for "@keet/update-typing-indicator"'),a(null!==this._handler66,'Missing handler for "@keet/dismiss-chat-reports"'),a(null!==this._handler67,'Missing handler for "@keet-private-id/update-contact-alias"'),a(null!==this._handler68,'Missing handler for "@keet/update-call-stream"'),a(null!==this._handler69,'Missing handler for "@keet-private-id/add-room-v2"'),a(null!==this._handler70,'Missing handler for "@keet/autobee-migration"'),a(null!==this._handler71,'Missing handler for "@keet-private-id/resolve-pending-invitation-v2"')}async dispatch(e,a){this._missing>0&&this._checkAll(),d(l);const n=t.isBuffer(e)?h(e):e;switch(n.id){case 2:return this._handler2(n.value,a);case 3:return this._handler3(n.value,a);case 4:return this._handler4(n.value,a);case 5:return this._handler5(n.value,a);case 6:return this._handler6(n.value,a);case 7:return this._handler7(n.value,a);case 8:return this._handler8(n.value,a);case 9:return this._handler9(n.value,a);case 10:return this._handler10(n.value,a);case 11:return this._handler11(n.value,a);case 12:return this._handler12(n.value,a);case 13:return this._handler13(n.value,a);case 14:return this._handler14(n.value,a);case 15:return this._handler15(n.value,a);case 16:return this._handler16(n.value,a);case 17:return this._handler17(n.value,a);case 18:return this._handler18(n.value,a);case 19:return this._handler19(n.value,a);case 20:return this._handler20(n.value,a);case 21:return this._handler21(n.value,a);case 22:return this._handler22(n.value,a);case 23:return this._handler23(n.value,a);case 24:return this._handler24(n.value,a);case 25:return this._handler25(n.value,a);case 26:return this._handler26(n.value,a);case 27:return this._handler27(n.value,a);case 28:return this._handler28(n.value,a);case 29:return this._handler29(n.value,a);case 30:return this._handler30(n.value,a);case 31:return this._handler31(n.value,a);case 32:return this._handler32(n.value,a);case 33:return this._handler33(n.value,a);case 34:return this._handler34(n.value,a);case 35:return this._handler35(n.value,a);case 36:return this._handler36(n.value,a);case 37:return this._handler37(n.value,a);case 38:return this._handler38(n.value,a);case 39:return this._handler39(n.value,a);case 40:return this._handler40(n.value,a);case 41:return this._handler41(n.value,a);case 42:return this._handler42(n.value,a);case 43:return this._handler43(n.value,a);case 44:return this._handler44(n.value,a);case 45:return this._handler45(n.value,a);case 46:return this._handler46(n.value,a);case 47:return this._handler47(n.value,a);case 48:return this._handler48(n.value,a);case 49:return this._handler49(n.value,a);case 50:return this._handler50(n.value,a);case 51:return this._handler51(n.value,a);case 52:return this._handler52(n.value,a);case 53:return this._handler53(n.value,a);case 54:return this._handler54(n.value,a);case 55:return this._handler55(n.value,a);case 56:return this._handler56(n.value,a);case 57:return this._handler57(n.value,a);case 58:return this._handler58(n.value,a);case 59:return this._handler59(n.value,a);case 60:return this._handler60(n.value,a);case 61:return this._handler61(n.value,a);case 62:return this._handler62(n.value,a);case 63:return this._handler63(n.value,a);case 64:return this._handler64(n.value,a);case 65:return this._handler65(n.value,a);case 66:return this._handler66(n.value,a);case 67:return this._handler67(n.value,a);case 68:return this._handler68(n.value,a);case 69:return this._handler69(n.value,a);case 70:return this._handler70(n.value,a);case 71:return this._handler71(n.value,a);default:throw r.HANDLER_NOT_FOUND_BY_ID(n.id)}}},DispatchError:r,ERRORS:n};
1const{c:e,b4a:t,assert:a,DispatchError:r,ERRORS:n}=require("hyperdispatch/runtime"),{version:i,getEncoding:s,setVersion:l}=require("./messages.js"),d=i;function h(t,{version:a=d}={}){const n={buffer:t,start:0,end:t.length},i=e.uint.decode(n),s=function(e){switch(e){case 2:return c;case 3:return u;case 4:return o;case 5:return k;case 6:return v;case 7:return p;case 8:return m;case 9:return _;case 10:return g;case 11:return b;case 12:return f;case 13:return M;case 14:return w;case 15:return y;case 16:return q;case 17:return j;case 18:return x;case 19:return E;case 20:return N;case 21:return O;case 22:return R;case 23:return D;case 24:return T;case 25:return U;case 26:return A;case 27:return B;case 28:return F;case 29:return I;case 30:return S;case 31:return Y;case 32:return H;case 33:return L;case 34:return V;case 35:return X;case 36:return z;case 37:return C;case 38:return G;case 39:return J;case 40:return K;case 41:return P;case 42:return Q;case 43:return W;case 44:return Z;case 45:return $;case 46:return ee;case 47:return te;case 48:return ae;case 49:return re;case 50:return ne;case 51:return ie;case 52:return se;case 53:return le;case 54:return de;case 55:return he;case 56:return ce;case 57:return ue;case 58:return oe;case 59:return ke;case 60:return ve;case 61:return pe;case 62:return me;case 63:return _e;case 64:return ge;case 65:return be;case 66:return fe;case 67:return Me;case 68:return we;case 69:return ye;case 70:return qe;case 71:return je;case 72:return xe;case 73:return Ee;case 74:return Ne;case 75:return Oe;default:throw r.HANDLER_NOT_FOUND_BY_ID(e)}}(i);l(a);const h=s.enc.decode(n);return{id:i,name:s.name,value:h}}const c={name:"@keet/genesis",id:2,enc:s("@keet/genesis-operation")},u={name:"@keet/upgrade",id:3,enc:s("@keet/upgrade-operation")},o={name:"@keet/update-system-settings",id:4,enc:s("@keet/update-system-settings-operation")},k={name:"@keet/add-blind-peer",id:5,enc:s("@keet/add-blind-peer-operation")},v={name:"@keet/remove-blind-peer",id:6,enc:s("@keet/remove-blind-peer-operation")},p={name:"@keet/add-device",id:7,enc:s("@keet/add-device-operation")},m={name:"@keet/update-device",id:8,enc:s("@keet/update-device-operation")},_={name:"@keet/start-indexing",id:9,enc:s("@keet/start-indexing-operation")},g={name:"@keet/stop-indexing",id:10,enc:s("@keet/stop-indexing-operation")},b={name:"@keet/accept-join-request",id:11,enc:s("@keet/accept-join-request-operation")},f={name:"@keet/reject-join-request",id:12,enc:s("@keet/reject-join-request-operation")},M={name:"@keet/update-member",id:13,enc:s("@keet/update-member-operation")},w={name:"@keet/change-member-role",id:14,enc:s("@keet/change-member-role-operation")},y={name:"@keet/change-member-status",id:15,enc:s("@keet/change-member-status-operation")},q={name:"@keet/remove-member",id:16,enc:s("@keet/remove-member-operation")},j={name:"@keet/add-invitation",id:17,enc:s("@keet/add-invitation-operation")},x={name:"@keet/remove-invitation",id:18,enc:s("@keet/remove-invitation-operation")},E={name:"@keet/add-chat-message",id:19,enc:s("@keet/add-chat-message-operation")},N={name:"@keet/remove-chat-message",id:20,enc:s("@keet/remove-chat-message-operation")},O={name:"@keet/update-chat-message",id:21,enc:s("@keet/update-chat-message-operation")},R={name:"@keet/pin-chat-message",id:22,enc:s("@keet/pin-chat-message-operation")},D={name:"@keet/add-reaction",id:23,enc:s("@keet/add-reaction-operation")},T={name:"@keet/remove-reaction",id:24,enc:s("@keet/remove-reaction-operation")},U={name:"@keet/update-room-config",id:25,enc:s("@keet/update-room-config-operation")},A={name:"@keet-private-id/run-v3-migration",id:26,enc:s("@keet-private-id/run-v3-migration-operation")},B={name:"@keet-private-id/update-identity",id:27,enc:s("@keet-private-id/update-identity-operation")},F={name:"@keet-private-id/resolve-pending-invitation",id:28,enc:s("@keet-private-id/resolve-pending-invitation-operation")},I={name:"@keet-private-id/add-pending-invitation",id:29,enc:s("@keet-private-id/add-pending-invitation-operation")},S={name:"@keet-private-id/remove-pending-invitation",id:30,enc:s("@keet-private-id/remove-pending-invitation-operation")},Y={name:"@keet-private-id/add-room",id:31,enc:s("@keet-private-id/add-room-operation")},H={name:"@keet-private-id/remove-room",id:32,enc:s("@keet-private-id/remove-room-operation")},L={name:"@keet-private-id/update-room-status",id:33,enc:s("@keet-private-id/update-room-status-operation")},V={name:"@keet-private-id/add-contact",id:34,enc:s("@keet-private-id/add-contact-operation")},X={name:"@keet-private-id/update-contact-status",id:35,enc:s("@keet-private-id/update-contact-status-operation")},z={name:"@keet-private-id/remove-contact",id:36,enc:s("@keet-private-id/remove-contact-operation")},C={name:"@keet-private-id/add-contact-request",id:37,enc:s("@keet-private-id/add-contact-request-operation")},G={name:"@keet-private-id/update-contact-request-status",id:38,enc:s("@keet-private-id/update-contact-request-status-operation")},J={name:"@keet/add-file-preview",id:39,enc:s("@keet/add-file-preview-operation")},K={name:"@keet/remove-device",id:40,enc:s("@keet/remove-device-operation")},P={name:"@keet-private-id/activate-contact-room",id:41,enc:s("@keet-private-id/activate-contact-room-operation")},Q={name:"@keet/test-increment",id:42,enc:s("@keet/test-increment-operation")},W={name:"@keet/migrate-abi",id:43,enc:s("@keet/migrate-abi-operation")},Z={name:"@keet-private-id/add-unreads-key",id:44,enc:s("@keet-private-id/add-unreads-key-operation")},$={name:"@keet-private-id/remove-unreads-key",id:45,enc:s("@keet-private-id/remove-unreads-key-operation")},ee={name:"@keet/add-chat-label",id:46,enc:s("@keet/add-chat-label-operation")},te={name:"@keet/remove-chat-label",id:47,enc:s("@keet/remove-chat-label-operation")},ae={name:"@keet/update-read-length",id:48,enc:s("@keet/update-read-length-operation")},re={name:"@keet-private-id/update-settings",id:49,enc:s("@keet-private-id/update-settings-operation")},ne={name:"@keet/add-member-label",id:50,enc:s("@keet/add-member-label-operation")},ie={name:"@keet/move-indexer",id:51,enc:s("@keet/move-indexer-operation")},se={name:"@keet/start-call",id:52,enc:s("@keet/start-call")},le={name:"@keet/join-call",id:53,enc:s("@keet/join-call")},de={name:"@keet/leave-call",id:54,enc:s("@keet/leave-call")},he={name:"@keet/end-call",id:55,enc:s("@keet/end-call")},ce={name:"@keet/add-call-stream",id:56,enc:s("@keet/add-call-stream")},ue={name:"@keet/remove-call-stream",id:57,enc:s("@keet/remove-call-stream")},oe={name:"@keet/test-crash",id:58,enc:s("@keet/test-crash-operation")},ke={name:"@keet/test-dispatch-error",id:59,enc:s("@keet/test-dispatch-error-operation")},ve={name:"@keet-private-id/shorten-device-attestation",id:60,enc:s("@keet-private-id/shorten-device-attestation-operation")},pe={name:"@keet/call-device-heartbeat",id:61,enc:s("@keet/call-device-heartbeat")},me={name:"@keet/remove-call-device",id:62,enc:s("@keet/remove-call-device")},_e={name:"@keet/start-call-recording",id:63,enc:s("@keet/start-call-recording")},ge={name:"@keet/stop-call-recording",id:64,enc:s("@keet/stop-call-recording")},be={name:"@keet/update-typing-indicator",id:65,enc:s("@keet/update-typing-indicator-operation")},fe={name:"@keet/dismiss-chat-reports",id:66,enc:s("@keet/dismiss-chat-reports-operation")},Me={name:"@keet-private-id/update-contact-alias",id:67,enc:s("@keet-private-id/update-contact-alias-operation")},we={name:"@keet/update-call-stream",id:68,enc:s("@keet/update-call-stream")},ye={name:"@keet-private-id/add-room-v2",id:69,enc:s("@keet-private-id/add-room-operation-v2")},qe={name:"@keet/autobee-migration",id:70,enc:s("@keet/autobee-migration-operation")},je={name:"@keet-private-id/resolve-pending-invitation-v2",id:71,enc:s("@keet-private-id/resolve-pending-invitation-operation-v2")},xe={name:"@keet/remove-file-preview",id:72,enc:s("@keet/remove-file-preview-operation")},Ee={name:"@keet/add-link-preview",id:73,enc:s("@keet/add-link-preview-operation")},Ne={name:"@keet/remove-link-preview",id:74,enc:s("@keet/remove-link-preview-operation")},Oe={name:"@keet/claim-admin-devices",id:75,enc:s("@keet/claim-admin-devices-operation")};module.exports={version:i,encode:function(a,n,{version:i=d}={}){const s={buffer:null,start:0,end:0},h=function(e){switch(e){case"@keet/genesis":return c;case"@keet/upgrade":return u;case"@keet/update-system-settings":return o;case"@keet/add-blind-peer":return k;case"@keet/remove-blind-peer":return v;case"@keet/add-device":return p;case"@keet/update-device":return m;case"@keet/start-indexing":return _;case"@keet/stop-indexing":return g;case"@keet/accept-join-request":return b;case"@keet/reject-join-request":return f;case"@keet/update-member":return M;case"@keet/change-member-role":return w;case"@keet/change-member-status":return y;case"@keet/remove-member":return q;case"@keet/add-invitation":return j;case"@keet/remove-invitation":return x;case"@keet/add-chat-message":return E;case"@keet/remove-chat-message":return N;case"@keet/update-chat-message":return O;case"@keet/pin-chat-message":return R;case"@keet/add-reaction":return D;case"@keet/remove-reaction":return T;case"@keet/update-room-config":return U;case"@keet-private-id/run-v3-migration":return A;case"@keet-private-id/update-identity":return B;case"@keet-private-id/resolve-pending-invitation":return F;case"@keet-private-id/add-pending-invitation":return I;case"@keet-private-id/remove-pending-invitation":return S;case"@keet-private-id/add-room":return Y;case"@keet-private-id/remove-room":return H;case"@keet-private-id/update-room-status":return L;case"@keet-private-id/add-contact":return V;case"@keet-private-id/update-contact-status":return X;case"@keet-private-id/remove-contact":return z;case"@keet-private-id/add-contact-request":return C;case"@keet-private-id/update-contact-request-status":return G;case"@keet/add-file-preview":return J;case"@keet/remove-device":return K;case"@keet-private-id/activate-contact-room":return P;case"@keet/test-increment":return Q;case"@keet/migrate-abi":return W;case"@keet-private-id/add-unreads-key":return Z;case"@keet-private-id/remove-unreads-key":return $;case"@keet/add-chat-label":return ee;case"@keet/remove-chat-label":return te;case"@keet/update-read-length":return ae;case"@keet-private-id/update-settings":return re;case"@keet/add-member-label":return ne;case"@keet/move-indexer":return ie;case"@keet/start-call":return se;case"@keet/join-call":return le;case"@keet/leave-call":return de;case"@keet/end-call":return he;case"@keet/add-call-stream":return ce;case"@keet/remove-call-stream":return ue;case"@keet/test-crash":return oe;case"@keet/test-dispatch-error":return ke;case"@keet-private-id/shorten-device-attestation":return ve;case"@keet/call-device-heartbeat":return pe;case"@keet/remove-call-device":return me;case"@keet/start-call-recording":return _e;case"@keet/stop-call-recording":return ge;case"@keet/update-typing-indicator":return be;case"@keet/dismiss-chat-reports":return fe;case"@keet-private-id/update-contact-alias":return Me;case"@keet/update-call-stream":return we;case"@keet-private-id/add-room-v2":return ye;case"@keet/autobee-migration":return qe;case"@keet-private-id/resolve-pending-invitation-v2":return je;case"@keet/remove-file-preview":return xe;case"@keet/add-link-preview":return Ee;case"@keet/remove-link-preview":return Ne;case"@keet/claim-admin-devices":return Oe;default:throw r.ROUTE_NOT_FOUND_BY_NAME(e)}}(a);return l(i),e.uint.preencode(s,h.id),h.enc.preencode(s,n),s.buffer=t.allocUnsafe(s.end),e.uint.encode(s,h.id),h.enc.encode(s,n),s.buffer},decode:h,Router:class{constructor(){this._handler2=null,this._handler3=null,this._handler4=null,this._handler5=null,this._handler6=null,this._handler7=null,this._handler8=null,this._handler9=null,this._handler10=null,this._handler11=null,this._handler12=null,this._handler13=null,this._handler14=null,this._handler15=null,this._handler16=null,this._handler17=null,this._handler18=null,this._handler19=null,this._handler20=null,this._handler21=null,this._handler22=null,this._handler23=null,this._handler24=null,this._handler25=null,this._handler26=null,this._handler27=null,this._handler28=null,this._handler29=null,this._handler30=null,this._handler31=null,this._handler32=null,this._handler33=null,this._handler34=null,this._handler35=null,this._handler36=null,this._handler37=null,this._handler38=null,this._handler39=null,this._handler40=null,this._handler41=null,this._handler42=null,this._handler43=null,this._handler44=null,this._handler45=null,this._handler46=null,this._handler47=null,this._handler48=null,this._handler49=null,this._handler50=null,this._handler51=null,this._handler52=null,this._handler53=null,this._handler54=null,this._handler55=null,this._handler56=null,this._handler57=null,this._handler58=null,this._handler59=null,this._handler60=null,this._handler61=null,this._handler62=null,this._handler63=null,this._handler64=null,this._handler65=null,this._handler66=null,this._handler67=null,this._handler68=null,this._handler69=null,this._handler70=null,this._handler71=null,this._handler72=null,this._handler73=null,this._handler74=null,this._handler75=null,this._missing=74}add(e,t){switch(e){case"@keet/genesis":this._handler2=t;break;case"@keet/upgrade":this._handler3=t;break;case"@keet/update-system-settings":this._handler4=t;break;case"@keet/add-blind-peer":this._handler5=t;break;case"@keet/remove-blind-peer":this._handler6=t;break;case"@keet/add-device":this._handler7=t;break;case"@keet/update-device":this._handler8=t;break;case"@keet/start-indexing":this._handler9=t;break;case"@keet/stop-indexing":this._handler10=t;break;case"@keet/accept-join-request":this._handler11=t;break;case"@keet/reject-join-request":this._handler12=t;break;case"@keet/update-member":this._handler13=t;break;case"@keet/change-member-role":this._handler14=t;break;case"@keet/change-member-status":this._handler15=t;break;case"@keet/remove-member":this._handler16=t;break;case"@keet/add-invitation":this._handler17=t;break;case"@keet/remove-invitation":this._handler18=t;break;case"@keet/add-chat-message":this._handler19=t;break;case"@keet/remove-chat-message":this._handler20=t;break;case"@keet/update-chat-message":this._handler21=t;break;case"@keet/pin-chat-message":this._handler22=t;break;case"@keet/add-reaction":this._handler23=t;break;case"@keet/remove-reaction":this._handler24=t;break;case"@keet/update-room-config":this._handler25=t;break;case"@keet-private-id/run-v3-migration":this._handler26=t;break;case"@keet-private-id/update-identity":this._handler27=t;break;case"@keet-private-id/resolve-pending-invitation":this._handler28=t;break;case"@keet-private-id/add-pending-invitation":this._handler29=t;break;case"@keet-private-id/remove-pending-invitation":this._handler30=t;break;case"@keet-private-id/add-room":this._handler31=t;break;case"@keet-private-id/remove-room":this._handler32=t;break;case"@keet-private-id/update-room-status":this._handler33=t;break;case"@keet-private-id/add-contact":this._handler34=t;break;case"@keet-private-id/update-contact-status":this._handler35=t;break;case"@keet-private-id/remove-contact":this._handler36=t;break;case"@keet-private-id/add-contact-request":this._handler37=t;break;case"@keet-private-id/update-contact-request-status":this._handler38=t;break;case"@keet/add-file-preview":this._handler39=t;break;case"@keet/remove-device":this._handler40=t;break;case"@keet-private-id/activate-contact-room":this._handler41=t;break;case"@keet/test-increment":this._handler42=t;break;case"@keet/migrate-abi":this._handler43=t;break;case"@keet-private-id/add-unreads-key":this._handler44=t;break;case"@keet-private-id/remove-unreads-key":this._handler45=t;break;case"@keet/add-chat-label":this._handler46=t;break;case"@keet/remove-chat-label":this._handler47=t;break;case"@keet/update-read-length":this._handler48=t;break;case"@keet-private-id/update-settings":this._handler49=t;break;case"@keet/add-member-label":this._handler50=t;break;case"@keet/move-indexer":this._handler51=t;break;case"@keet/start-call":this._handler52=t;break;case"@keet/join-call":this._handler53=t;break;case"@keet/leave-call":this._handler54=t;break;case"@keet/end-call":this._handler55=t;break;case"@keet/add-call-stream":this._handler56=t;break;case"@keet/remove-call-stream":this._handler57=t;break;case"@keet/test-crash":this._handler58=t;break;case"@keet/test-dispatch-error":this._handler59=t;break;case"@keet-private-id/shorten-device-attestation":this._handler60=t;break;case"@keet/call-device-heartbeat":this._handler61=t;break;case"@keet/remove-call-device":this._handler62=t;break;case"@keet/start-call-recording":this._handler63=t;break;case"@keet/stop-call-recording":this._handler64=t;break;case"@keet/update-typing-indicator":this._handler65=t;break;case"@keet/dismiss-chat-reports":this._handler66=t;break;case"@keet-private-id/update-contact-alias":this._handler67=t;break;case"@keet/update-call-stream":this._handler68=t;break;case"@keet-private-id/add-room-v2":this._handler69=t;break;case"@keet/autobee-migration":this._handler70=t;break;case"@keet-private-id/resolve-pending-invitation-v2":this._handler71=t;break;case"@keet/remove-file-preview":this._handler72=t;break;case"@keet/add-link-preview":this._handler73=t;break;case"@keet/remove-link-preview":this._handler74=t;break;case"@keet/claim-admin-devices":this._handler75=t;break;default:throw r.NONEXISTENT_ROUTE(e)}this._missing--}_checkAll(){a(null!==this._handler2,'Missing handler for "@keet/genesis"'),a(null!==this._handler3,'Missing handler for "@keet/upgrade"'),a(null!==this._handler4,'Missing handler for "@keet/update-system-settings"'),a(null!==this._handler5,'Missing handler for "@keet/add-blind-peer"'),a(null!==this._handler6,'Missing handler for "@keet/remove-blind-peer"'),a(null!==this._handler7,'Missing handler for "@keet/add-device"'),a(null!==this._handler8,'Missing handler for "@keet/update-device"'),a(null!==this._handler9,'Missing handler for "@keet/start-indexing"'),a(null!==this._handler10,'Missing handler for "@keet/stop-indexing"'),a(null!==this._handler11,'Missing handler for "@keet/accept-join-request"'),a(null!==this._handler12,'Missing handler for "@keet/reject-join-request"'),a(null!==this._handler13,'Missing handler for "@keet/update-member"'),a(null!==this._handler14,'Missing handler for "@keet/change-member-role"'),a(null!==this._handler15,'Missing handler for "@keet/change-member-status"'),a(null!==this._handler16,'Missing handler for "@keet/remove-member"'),a(null!==this._handler17,'Missing handler for "@keet/add-invitation"'),a(null!==this._handler18,'Missing handler for "@keet/remove-invitation"'),a(null!==this._handler19,'Missing handler for "@keet/add-chat-message"'),a(null!==this._handler20,'Missing handler for "@keet/remove-chat-message"'),a(null!==this._handler21,'Missing handler for "@keet/update-chat-message"'),a(null!==this._handler22,'Missing handler for "@keet/pin-chat-message"'),a(null!==this._handler23,'Missing handler for "@keet/add-reaction"'),a(null!==this._handler24,'Missing handler for "@keet/remove-reaction"'),a(null!==this._handler25,'Missing handler for "@keet/update-room-config"'),a(null!==this._handler26,'Missing handler for "@keet-private-id/run-v3-migration"'),a(null!==this._handler27,'Missing handler for "@keet-private-id/update-identity"'),a(null!==this._handler28,'Missing handler for "@keet-private-id/resolve-pending-invitation"'),a(null!==this._handler29,'Missing handler for "@keet-private-id/add-pending-invitation"'),a(null!==this._handler30,'Missing handler for "@keet-private-id/remove-pending-invitation"'),a(null!==this._handler31,'Missing handler for "@keet-private-id/add-room"'),a(null!==this._handler32,'Missing handler for "@keet-private-id/remove-room"'),a(null!==this._handler33,'Missing handler for "@keet-private-id/update-room-status"'),a(null!==this._handler34,'Missing handler for "@keet-private-id/add-contact"'),a(null!==this._handler35,'Missing handler for "@keet-private-id/update-contact-status"'),a(null!==this._handler36,'Missing handler for "@keet-private-id/remove-contact"'),a(null!==this._handler37,'Missing handler for "@keet-private-id/add-contact-request"'),a(null!==this._handler38,'Missing handler for "@keet-private-id/update-contact-request-status"'),a(null!==this._handler39,'Missing handler for "@keet/add-file-preview"'),a(null!==this._handler40,'Missing handler for "@keet/remove-device"'),a(null!==this._handler41,'Missing handler for "@keet-private-id/activate-contact-room"'),a(null!==this._handler42,'Missing handler for "@keet/test-increment"'),a(null!==this._handler43,'Missing handler for "@keet/migrate-abi"'),a(null!==this._handler44,'Missing handler for "@keet-private-id/add-unreads-key"'),a(null!==this._handler45,'Missing handler for "@keet-private-id/remove-unreads-key"'),a(null!==this._handler46,'Missing handler for "@keet/add-chat-label"'),a(null!==this._handler47,'Missing handler for "@keet/remove-chat-label"'),a(null!==this._handler48,'Missing handler for "@keet/update-read-length"'),a(null!==this._handler49,'Missing handler for "@keet-private-id/update-settings"'),a(null!==this._handler50,'Missing handler for "@keet/add-member-label"'),a(null!==this._handler51,'Missing handler for "@keet/move-indexer"'),a(null!==this._handler52,'Missing handler for "@keet/start-call"'),a(null!==this._handler53,'Missing handler for "@keet/join-call"'),a(null!==this._handler54,'Missing handler for "@keet/leave-call"'),a(null!==this._handler55,'Missing handler for "@keet/end-call"'),a(null!==this._handler56,'Missing handler for "@keet/add-call-stream"'),a(null!==this._handler57,'Missing handler for "@keet/remove-call-stream"'),a(null!==this._handler58,'Missing handler for "@keet/test-crash"'),a(null!==this._handler59,'Missing handler for "@keet/test-dispatch-error"'),a(null!==this._handler60,'Missing handler for "@keet-private-id/shorten-device-attestation"'),a(null!==this._handler61,'Missing handler for "@keet/call-device-heartbeat"'),a(null!==this._handler62,'Missing handler for "@keet/remove-call-device"'),a(null!==this._handler63,'Missing handler for "@keet/start-call-recording"'),a(null!==this._handler64,'Missing handler for "@keet/stop-call-recording"'),a(null!==this._handler65,'Missing handler for "@keet/update-typing-indicator"'),a(null!==this._handler66,'Missing handler for "@keet/dismiss-chat-reports"'),a(null!==this._handler67,'Missing handler for "@keet-private-id/update-contact-alias"'),a(null!==this._handler68,'Missing handler for "@keet/update-call-stream"'),a(null!==this._handler69,'Missing handler for "@keet-private-id/add-room-v2"'),a(null!==this._handler70,'Missing handler for "@keet/autobee-migration"'),a(null!==this._handler71,'Missing handler for "@keet-private-id/resolve-pending-invitation-v2"'),a(null!==this._handler72,'Missing handler for "@keet/remove-file-preview"'),a(null!==this._handler73,'Missing handler for "@keet/add-link-preview"'),a(null!==this._handler74,'Missing handler for "@keet/remove-link-preview"'),a(null!==this._handler75,'Missing handler for "@keet/claim-admin-devices"')}async dispatch(e,a){this._missing>0&&this._checkAll(),l(d);const n=t.isBuffer(e)?h(e):e;switch(n.id){case 2:return this._handler2(n.value,a);case 3:return this._handler3(n.value,a);case 4:return this._handler4(n.value,a);case 5:return this._handler5(n.value,a);case 6:return this._handler6(n.value,a);case 7:return this._handler7(n.value,a);case 8:return this._handler8(n.value,a);case 9:return this._handler9(n.value,a);case 10:return this._handler10(n.value,a);case 11:return this._handler11(n.value,a);case 12:return this._handler12(n.value,a);case 13:return this._handler13(n.value,a);case 14:return this._handler14(n.value,a);case 15:return this._handler15(n.value,a);case 16:return this._handler16(n.value,a);case 17:return this._handler17(n.value,a);case 18:return this._handler18(n.value,a);case 19:return this._handler19(n.value,a);case 20:return this._handler20(n.value,a);case 21:return this._handler21(n.value,a);case 22:return this._handler22(n.value,a);case 23:return this._handler23(n.value,a);case 24:return this._handler24(n.value,a);case 25:return this._handler25(n.value,a);case 26:return this._handler26(n.value,a);case 27:return this._handler27(n.value,a);case 28:return this._handler28(n.value,a);case 29:return this._handler29(n.value,a);case 30:return this._handler30(n.value,a);case 31:return this._handler31(n.value,a);case 32:return this._handler32(n.value,a);case 33:return this._handler33(n.value,a);case 34:return this._handler34(n.value,a);case 35:return this._handler35(n.value,a);case 36:return this._handler36(n.value,a);case 37:return this._handler37(n.value,a);case 38:return this._handler38(n.value,a);case 39:return this._handler39(n.value,a);case 40:return this._handler40(n.value,a);case 41:return this._handler41(n.value,a);case 42:return this._handler42(n.value,a);case 43:return this._handler43(n.value,a);case 44:return this._handler44(n.value,a);case 45:return this._handler45(n.value,a);case 46:return this._handler46(n.value,a);case 47:return this._handler47(n.value,a);case 48:return this._handler48(n.value,a);case 49:return this._handler49(n.value,a);case 50:return this._handler50(n.value,a);case 51:return this._handler51(n.value,a);case 52:return this._handler52(n.value,a);case 53:return this._handler53(n.value,a);case 54:return this._handler54(n.value,a);case 55:return this._handler55(n.value,a);case 56:return this._handler56(n.value,a);case 57:return this._handler57(n.value,a);case 58:return this._handler58(n.value,a);case 59:return this._handler59(n.value,a);case 60:return this._handler60(n.value,a);case 61:return this._handler61(n.value,a);case 62:return this._handler62(n.value,a);case 63:return this._handler63(n.value,a);case 64:return this._handler64(n.value,a);case 65:return this._handler65(n.value,a);case 66:return this._handler66(n.value,a);case 67:return this._handler67(n.value,a);case 68:return this._handler68(n.value,a);case 69:return this._handler69(n.value,a);case 70:return this._handler70(n.value,a);case 71:return this._handler71(n.value,a);case 72:return this._handler72(n.value,a);case 73:return this._handler73(n.value,a);case 74:return this._handler74(n.value,a);case 75:return this._handler75(n.value,a);default:throw r.HANDLER_NOT_FOUND_BY_ID(n.id)}}},DispatchError:r,ERRORS:n};
@holepunchto/keet-core/schema/spec/contract/hyperdispatch/messages.js +1 -1
……@@ -1 +1 @@
1const{c:e}=require("hyperschema/runtime");let d=29;const o={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.length)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.length)},decode:d=>({key:e.fixed32.decode(d),length:e.uint.decode(d)})},n={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.seq)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.seq)},decode:d=>({key:e.fixed32.decode(d),seq:e.uint.decode(d)})},c={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.secretKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.secretKey)},decode:d=>({publicKey:e.fixed32.decode(d),secretKey:e.fixed32.decode(d)})},t={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed64.preencode(d,o.secretKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed64.encode(d,o.secretKey)},decode:d=>({publicKey:e.fixed32.decode(d),secretKey:e.fixed64.decode(d)})},r={preencode(n,c){e.fixed32.preencode(n,c.key),n.end++,c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const t=(c.encryptionKey?1:0)|(c.fastForwardTo?2:0)|(d>=27&&c.bootFrom?4:0);e.fixed32.encode(n,c.key),e.uint.encode(n,t),c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),t=e.uint.decode(n);return{key:c,encryptionKey:1&t?e.buffer.decode(n):null,fastForwardTo:2&t?e.fixed32.decode(n):null,bootFrom:d>=27&&4&t?o.decode(n):null}}},i={preencode(d,o){e.uint.preencode(d,o.timestamp)},encode(d,o){e.uint.encode(d,o.timestamp)},decode:d=>({timestamp:e.uint.decode(d)})},a={preencode(d,o){e.uint.preencode(d,o.blockOffset),e.uint.preencode(d,o.blockLength),e.uint.preencode(d,o.byteOffset),e.uint.preencode(d,o.byteLength)},encode(d,o){e.uint.encode(d,o.blockOffset),e.uint.encode(d,o.blockLength),e.uint.encode(d,o.byteOffset),e.uint.encode(d,o.byteLength)},decode:d=>({blockOffset:e.uint.decode(d),blockLength:e.uint.decode(d),byteOffset:e.uint.decode(d),byteLength:e.uint.decode(d)})},s={preencode(d,o){e.uint.preencode(d,o.width),e.uint.preencode(d,o.height)},encode(d,o){e.uint.encode(d,o.width),e.uint.encode(d,o.height)},decode:d=>({width:e.uint.decode(d),height:e.uint.decode(d)})},p=e.frame(s),u={preencode(d,o){d.end++,o.name&&e.string.preencode(d,o.name),o.mimetype&&e.string.preencode(d,o.mimetype),o.dimensions&&p.preencode(d,o.dimensions),o.userdata&&e.buffer.preencode(d,o.userdata),o.duration&&e.uint.preencode(d,o.duration)},encode(d,o){const n=(o.name?1:0)|(o.mimetype?2:0)|(o.dimensions?4:0)|(o.userdata?8:0)|(o.duration?16:0)|(o.isPreview?32:0);e.uint.encode(d,n),o.name&&e.string.encode(d,o.name),o.mimetype&&e.string.encode(d,o.mimetype),o.dimensions&&p.encode(d,o.dimensions),o.userdata&&e.buffer.encode(d,o.userdata),o.duration&&e.uint.encode(d,o.duration)},decode(d){const o=e.uint.decode(d);return{name:1&o?e.string.decode(d):null,mimetype:2&o?e.string.decode(d):null,dimensions:4&o?p.decode(d):null,userdata:8&o?e.buffer.decode(d):null,duration:16&o?e.uint.decode(d):0,isPreview:!!(32&o)}}},l={preencode(d,o){e.fixed32.preencode(d,o.key),e.string.preencode(d,o.path),e.uint.preencode(d,o.version),e.uint.preencode(d,o.size)},encode(d,o){e.fixed32.encode(d,o.key),e.string.encode(d,o.path),e.uint.encode(d,o.version),e.uint.encode(d,o.size)},decode:d=>({key:e.fixed32.decode(d),path:e.string.decode(d),version:e.uint.decode(d),size:e.uint.decode(d)})},f={preencode(d,o){e.fixed32.preencode(d,o.key),a.preencode(d,o.blob)},encode(d,o){e.fixed32.encode(d,o.key),a.encode(d,o.blob)},decode:d=>({key:e.fixed32.decode(d),blob:a.decode(d)})},m=e.frame(f),y=e.frame(l),b={preencode(o,n){o.end++,n.inlined&&e.buffer.preencode(o,n.inlined),n.blob&&a.preencode(o,n.blob),n.externalBlob&&m.preencode(o,n.externalBlob),n.externalDrive&&y.preencode(o,n.externalDrive),d>=27&&n.bee&&fr.preencode(o,n.bee)},encode(o,n){const c=(n.inlined?1:0)|(n.blob?2:0)|(n.externalBlob?4:0)|(n.externalDrive?8:0)|(d>=27&&n.bee?16:0);e.uint.encode(o,c),n.inlined&&e.buffer.encode(o,n.inlined),n.blob&&a.encode(o,n.blob),n.externalBlob&&m.encode(o,n.externalBlob),n.externalDrive&&y.encode(o,n.externalDrive),d>=27&&n.bee&&fr.encode(o,n.bee)},decode(o){const n=e.uint.decode(o);return{inlined:1&n?e.buffer.decode(o):null,blob:2&n?a.decode(o):null,externalBlob:4&n?m.decode(o):null,externalDrive:8&n?y.decode(o):null,bee:d>=27&&16&n?fr.decode(o):null}}},x=e.frame(b),k=e.frame(u),v={preencode(d,o){x.preencode(d,o.pointer),d.end++,o.metadata&&k.preencode(d,o.metadata),o.preview&&Hr.preencode(d,o.preview),o.hash&&e.fixed32.preencode(d,o.hash)},encode(d,o){const n=(o.metadata?1:0)|(o.preview?2:0)|(o.hash?4:0);x.encode(d,o.pointer),e.uint.encode(d,n),o.metadata&&k.encode(d,o.metadata),o.preview&&Hr.encode(d,o.preview),o.hash&&e.fixed32.encode(d,o.hash)},decode(d){const o=x.decode(d),n=e.uint.decode(d);return{pointer:o,metadata:1&n?k.decode(d):null,preview:2&n?Hr.decode(d):null,hash:4&n?e.fixed32.decode(d):null}}},g=e.frame(v),h=g,K=g,w={preencode(e,d){e.end++,d.small&&g.preencode(e,d.small),d.medium&&h.preencode(e,d.medium),d.large&&K.preencode(e,d.large)},encode(d,o){const n=(o.small?1:0)|(o.medium?2:0)|(o.large?4:0);e.uint.encode(d,n),o.small&&g.encode(d,o.small),o.medium&&h.encode(d,o.medium),o.large&&K.encode(d,o.large)},decode(d){const o=e.uint.decode(d);return{small:1&o?g.decode(d):null,medium:2&o?h.decode(d):null,large:4&o?K.decode(d):null}}},T={preencode(e,d){e.end++},encode(d,o){const n=o.isDeleted?1:0;e.uint.encode(d,n)},decode:d=>({isDeleted:!!(1&e.uint.decode(d))})},A=e.frame(T),P=g,S={preencode(o,c){e.uint.preencode(o,c.id),n.preencode(o,c.oplog),A.preencode(o,c.status),P.preencode(o,c.file),o.end++,d>=14&&c.version&&e.uint.preencode(o,c.version)},encode(o,c){const t=d>=14&&c.version?1:0;e.uint.encode(o,c.id),n.encode(o,c.oplog),A.encode(o,c.status),P.encode(o,c.file),e.uint.encode(o,t),d>=14&&c.version&&e.uint.encode(o,c.version)},decode(o){const c=e.uint.decode(o),t=n.decode(o),r=A.decode(o),i=P.decode(o),a=o.start<o.end?e.uint.decode(o):0;return{id:c,oplog:t,status:r,file:i,version:d>=14&&1&a?e.uint.decode(o):0}}},I={preencode(e,d){e.end++},encode(d,o){const n=(o.isActive?1:0)|(o.isIndexing?2:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isActive:!!(1&o),isIndexing:!!(2&o)}}},R={preencode(o,n){const c=(n.isAdmin?1:0)|(n.isModerator?2:0)|(n.isPending?4:0)|(n.isActive?8:0)|(n.isMuted?16:0)|(n.isBanned?32:0)|(n.isShadowBanned?64:0)|(d>=13&&n.isRemoved?128:0);e.uint.preencode(o,c)},encode(o,n){const c=(n.isAdmin?1:0)|(n.isModerator?2:0)|(n.isPending?4:0)|(n.isActive?8:0)|(n.isMuted?16:0)|(n.isBanned?32:0)|(n.isShadowBanned?64:0)|(d>=13&&n.isRemoved?128:0);e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{isAdmin:!!(1&n),isModerator:!!(2&n),isPending:!!(4&n),isActive:!!(8&n),isMuted:!!(16&n),isBanned:!!(32&n),isShadowBanned:!!(64&n),isRemoved:d>=13&&!!(128&n)}}},F={preencode(e,d){e.end++},encode(d,o){const n=(o.isMuted?1:0)|(o.isBanned?2:0)|(o.isShadowBanned?4:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isMuted:!!(1&o),isBanned:!!(2&o),isShadowBanned:!!(4&o)}}},H={preencode(d,o){e.uint.preencode(d,o.version)},encode(d,o){e.uint.encode(d,o.version)},decode:d=>({version:e.uint.decode(d)})},M={preencode(d,o){e.uint.preencode(d,o.total),e.uint.preencode(d,o.active)},encode(d,o){e.uint.encode(d,o.total),e.uint.encode(d,o.active)},decode:d=>({total:e.uint.decode(d),active:e.uint.decode(d)})},C={preencode(d,o){e.uint.preencode(d,o.total),e.uint.preencode(d,o.active),e.uint.preencode(d,o.pending)},encode(d,o){e.uint.encode(d,o.total),e.uint.encode(d,o.active),e.uint.encode(d,o.pending)},decode:d=>({total:e.uint.decode(d),active:e.uint.decode(d),pending:e.uint.decode(d)})},D={preencode(o,n){e.uint.preencode(o,n.clock),e.uint.preencode(o,n.pinned),e.uint.preencode(o,n.threads),e.uint.preencode(o,n.timestamp),o.end++,d>=15&&n.flagsClock&&e.uint.preencode(o,n.flagsClock)},encode(o,n){const c=d>=15&&n.flagsClock?1:0;e.uint.encode(o,n.clock),e.uint.encode(o,n.pinned),e.uint.encode(o,n.threads),e.uint.encode(o,n.timestamp),e.uint.encode(o,c),d>=15&&n.flagsClock&&e.uint.encode(o,n.flagsClock)},decode(o){const n=e.uint.decode(o),c=e.uint.decode(o),t=e.uint.decode(o),r=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{clock:n,pinned:c,threads:t,timestamp:r,flagsClock:d>=15&&1&i?e.uint.decode(o):0}}},V={preencode(d,o){e.uint.preencode(d,o.clock)},encode(d,o){e.uint.encode(d,o.clock)},decode:d=>({clock:e.uint.decode(d)})},L=e.frame(M),q=e.frame(C),E=e.frame(D),B=e.frame(V),z={preencode(e,o){L.preencode(e,o.devices),q.preencode(e,o.members),E.preencode(e,o.chat),B.preencode(e,o.files),e.end++,d>=26&&o.calls&&Mr.preencode(e,o.calls)},encode(o,n){const c=d>=26&&n.calls?1:0;L.encode(o,n.devices),q.encode(o,n.members),E.encode(o,n.chat),B.encode(o,n.files),e.uint.encode(o,c),d>=26&&n.calls&&Mr.encode(o,n.calls)},decode(o){const n=L.decode(o),c=q.decode(o),t=E.decode(o),r=B.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{devices:n,members:c,chat:t,files:r,calls:d>=26&&1&i?Mr.decode(o):null}}},N={Default:1,Broadcast:2,DirectMessage:3},j={preencode(e,d){e.end++},encode(d,o){if(o>3)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},O={preencode(o,n){const c=(n.roomType?1:0)|(n.isExperimental?2:0)|(n.isJoiningDisabled?4:0)|(n.isAppendingDisabled?8:0)|(n.isCallingDisabled?16:0)|(n.isMembershipEventsDisabled?32:0)|(d>=19&&n.isAttachmentsDisabled?64:0)|(d>=19&&n.isLinksDisabled?128:0)|(d>=20&&n.buildType?256:0)|(d>=23&&n.isRoomInviteHidden?512:0);e.uint.preencode(o,c),n.roomType&&j.preencode(o,n.roomType),d>=20&&n.buildType&&Bt.preencode(o,n.buildType)},encode(o,n){const c=(n.roomType?1:0)|(n.isExperimental?2:0)|(n.isJoiningDisabled?4:0)|(n.isAppendingDisabled?8:0)|(n.isCallingDisabled?16:0)|(n.isMembershipEventsDisabled?32:0)|(d>=19&&n.isAttachmentsDisabled?64:0)|(d>=19&&n.isLinksDisabled?128:0)|(d>=20&&n.buildType?256:0)|(d>=23&&n.isRoomInviteHidden?512:0);e.uint.encode(o,c),n.roomType&&j.encode(o,n.roomType),d>=20&&n.buildType&&Bt.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{roomType:1&n?j.decode(o):0,isExperimental:!!(2&n),isJoiningDisabled:!!(4&n),isAppendingDisabled:!!(8&n),isCallingDisabled:!!(16&n),isMembershipEventsDisabled:!!(32&n),isAttachmentsDisabled:d>=19&&!!(64&n),isLinksDisabled:d>=19&&!!(128&n),buildType:d>=20&&256&n?Bt.decode(o):null,isRoomInviteHidden:d>=23&&!!(512&n)}}},U=e.frame(H),J=e.frame(O),G={preencode(d,o){U.preencode(d,o.abi),J.preencode(d,o.settings),e.uint.preencode(d,o.creationTime)},encode(d,o){U.encode(d,o.abi),J.encode(d,o.settings),e.uint.encode(d,o.creationTime)},decode:d=>({abi:U.decode(d),settings:J.decode(d),creationTime:e.uint.decode(d)})},Q={preencode(d,o){e.fixed32.preencode(d,o.seed)},encode(d,o){e.fixed32.encode(d,o.seed)},decode:d=>({seed:e.fixed32.decode(d)})},W={preencode(d,o){c.preencode(d,o.mailboxKeyPair),t.preencode(d,o.discoveryKeyPair),e.fixed32.preencode(d,o.wakeupTopic),e.fixed32.preencode(d,o.swarmTopic)},encode(d,o){c.encode(d,o.mailboxKeyPair),t.encode(d,o.discoveryKeyPair),e.fixed32.encode(d,o.wakeupTopic),e.fixed32.encode(d,o.swarmTopic)},decode:d=>({mailboxKeyPair:c.decode(d),discoveryKeyPair:t.decode(d),wakeupTopic:e.fixed32.decode(d),swarmTopic:e.fixed32.decode(d)})},X=e.array(e.fixed32),Y={preencode(o,n){o.end++,n.title&&e.string.preencode(o,n.title),n.avatar&&Cr.preencode(o,n.avatar),n.description&&e.string.preencode(o,n.description),d>=11&&n.supportedLanguages&&Dr.preencode(o,n.supportedLanguages),d>=13&&n.blindPeers&&X.preencode(o,n.blindPeers)},encode(o,n){const c=(n.title?1:0)|(n.avatar?2:0)|(n.description?4:0)|(d>=11&&n.supportedLanguages?8:0)|(d>=13&&n.blindPeers?16:0);e.uint.encode(o,c),n.title&&e.string.encode(o,n.title),n.avatar&&Cr.encode(o,n.avatar),n.description&&e.string.encode(o,n.description),d>=11&&n.supportedLanguages&&Dr.encode(o,n.supportedLanguages),d>=13&&n.blindPeers&&X.encode(o,n.blindPeers)},decode(o){const n=e.uint.decode(o);return{title:1&n?e.string.decode(o):null,avatar:2&n?Cr.decode(o):null,description:4&n?e.string.decode(o):null,supportedLanguages:d>=11&&8&n?Dr.decode(o):null,blindPeers:d>=13&&16&n?X.decode(o):null}}},Z={preencode(d,o){e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.key)},decode:d=>({key:e.fixed32.decode(d)})},$=e.frame(i),_=e.frame(Z),ee={preencode(e,d){$.preencode(e,d.header),_.preencode(e,d.peer)},encode(e,d){$.encode(e,d.header),_.encode(e,d.peer)},decode:e=>({header:$.decode(e),peer:_.decode(e)})},de=$,oe={preencode(d,o){de.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){de.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:de.decode(d),key:e.fixed32.decode(d)})},ne={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.buffer.preencode(d,o.proof)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.buffer.encode(d,o.proof)},decode:d=>({memberKey:e.fixed32.decode(d),proof:e.buffer.decode(d)})},ce={preencode(d,o){e.fixed32.preencode(d,o.id),e.buffer.preencode(d,o.response)},encode(d,o){e.fixed32.encode(d,o.id),e.buffer.encode(d,o.response)},decode:d=>({id:e.fixed32.decode(d),response:e.buffer.decode(d)})},te=e.frame(I),re=e.frame(ce),ie={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.memberKey),te.preencode(d,o.status),Vr.preencode(d,o.profile),d.end++,o.invitation&&re.preencode(d,o.invitation)},encode(d,o){const n=o.invitation?1:0;e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.memberKey),te.encode(d,o.status),Vr.encode(d,o.profile),e.uint.encode(d,n),o.invitation&&re.encode(d,o.invitation)},decode:d=>({key:e.fixed32.decode(d),memberKey:e.fixed32.decode(d),status:te.decode(d),profile:Vr.decode(d),invitation:1&e.uint.decode(d)?re.decode(d):null})},ae={preencode(d,o){e.uint.preencode(d,o.timestamp),d.end++,o.mailbox&&e.fixed32.preencode(d,o.mailbox),o.displayName&&e.string.preencode(d,o.displayName),o.avatar&&Lr.preencode(d,o.avatar),o.username&&e.string.preencode(d,o.username)},encode(d,o){const n=(o.mailbox?1:0)|(o.displayName?2:0)|(o.avatar?4:0)|(o.username?8:0);e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.mailbox&&e.fixed32.encode(d,o.mailbox),o.displayName&&e.string.encode(d,o.displayName),o.avatar&&Lr.encode(d,o.avatar),o.username&&e.string.encode(d,o.username)},decode(d){const o=e.uint.decode(d),n=e.uint.decode(d);return{timestamp:o,mailbox:1&n?e.fixed32.decode(d):null,displayName:2&n?e.string.decode(d):null,avatar:4&n?Lr.decode(d):null,username:8&n?e.string.decode(d):null}}},se={preencode(o,n){o.end++,n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),n.name&&e.string.preencode(o,n.name),d>=20&&n.buildType&&Bt.preencode(o,n.buildType)},encode(o,n){const c=(n.swarmKey?1:0)|(n.name?2:0)|(n.isMobile?4:0)|(d>=20&&n.buildType?8:0);e.uint.encode(o,c),n.swarmKey&&e.fixed32.encode(o,n.swarmKey),n.name&&e.string.encode(o,n.name),d>=20&&n.buildType&&Bt.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{swarmKey:1&n?e.fixed32.decode(o):null,name:2&n?e.string.decode(o):null,isMobile:!!(4&n),buildType:d>=20&&8&n?Bt.decode(o):null}}},pe=e.frame(ae),ue={preencode(e,d){pe.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){pe.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:pe.decode(e),attestation:ne.decode(e)})},le={preencode(e,d){qr.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){qr.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:qr.decode(e),attestation:ne.decode(e)})},fe={preencode(d,o){e.fixed32.preencode(d,o.id),e.buffer.preencode(d,o.data),e.buffer.preencode(d,o.signature)},encode(d,o){e.fixed32.encode(d,o.id),e.buffer.encode(d,o.data),e.buffer.encode(d,o.signature)},decode:d=>({id:e.fixed32.decode(d),data:e.buffer.decode(d),signature:e.buffer.decode(d)})},me={preencode(d,o){e.fixed32.preencode(d,o.devicePublicKey)},encode(d,o){e.fixed32.encode(d,o.devicePublicKey)},decode:d=>({devicePublicKey:e.fixed32.decode(d)})},ye={preencode(d,o){ne.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){ne.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({privateProfileIdentity:ne.decode(d),deviceProof:e.buffer.decode(d)})},be=e.frame(le),xe=e.frame(ue),ke=e.frame(me),ve={preencode(n,c){e.fixed32.preencode(n,c.deviceKey),t.preencode(n,c.keyPair),be.preencode(n,c.device),xe.preencode(n,c.member),n.end++,c.identity&&ke.preencode(n,c.identity),d>=27&&c.link&&o.preencode(n,c.link)},encode(n,c){const r=(c.identity?1:0)|(d>=27&&c.link?2:0);e.fixed32.encode(n,c.deviceKey),t.encode(n,c.keyPair),be.encode(n,c.device),xe.encode(n,c.member),e.uint.encode(n,r),c.identity&&ke.encode(n,c.identity),d>=27&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),r=t.decode(n),i=be.decode(n),a=xe.decode(n),s=e.uint.decode(n);return{deviceKey:c,keyPair:r,device:i,member:a,identity:1&s?ke.decode(n):null,link:d>=27&&2&s?o.decode(n):null}}},ge=e.frame(ve),he={preencode(d,o){e.fixed32.preencode(d,o.id),ge.preencode(d,o.request),e.buffer.preencode(d,o.signature)},encode(d,o){e.fixed32.encode(d,o.id),ge.encode(d,o.request),e.buffer.encode(d,o.signature)},decode:d=>({id:e.fixed32.decode(d),request:ge.decode(d),signature:e.buffer.decode(d)})},Ke=be,we=xe,Te={preencode(e,d){Ke.preencode(e,d.device),e.end++,d.member&&we.preencode(e,d.member)},encode(d,o){const n=o.member?1:0;Ke.encode(d,o.device),e.uint.encode(d,n),o.member&&we.encode(d,o.member)},decode:d=>({device:Ke.decode(d),member:1&e.uint.decode(d)?we.decode(d):null})},Ae=e.frame(he),Pe=e.frame(Te),Se={preencode(e,d){e.end++,d.withInvitation&&Ae.preencode(e,d.withInvitation),d.withMemberProof&&Pe.preencode(e,d.withMemberProof)},encode(d,o){const n=(o.withInvitation?1:0)|(o.withMemberProof?2:0);e.uint.encode(d,n),o.withInvitation&&Ae.encode(d,o.withInvitation),o.withMemberProof&&Pe.encode(d,o.withMemberProof)},decode(d){const o=e.uint.decode(d);return{withInvitation:1&o?Ae.decode(d):null,withMemberProof:2&o?Pe.decode(d):null}}},Ie=e.frame(fe),Re=e.frame(ye),Fe={preencode(e,d){Ie.preencode(e,d.signedKeys),e.end++,d.identity&&Re.preencode(e,d.identity)},encode(d,o){const n=o.identity?1:0;Ie.encode(d,o.signedKeys),e.uint.encode(d,n),o.identity&&Re.encode(d,o.identity)},decode:d=>({signedKeys:Ie.decode(d),identity:1&e.uint.decode(d)?Re.decode(d):null})},He={preencode(o,n){o.end++,n.expiration&&e.uint.preencode(o,n.expiration),d>=20&&n.buildType&&Bt.preencode(o,n.buildType)},encode(o,n){const c=(n.expiration?1:0)|(n.requiresConfirmation?2:0)|(n.canModerate?4:0)|(n.canAdmin?8:0)|(d>=20&&n.buildType?16:0);e.uint.encode(o,c),n.expiration&&e.uint.encode(o,n.expiration),d>=20&&n.buildType&&Bt.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{expiration:1&n?e.uint.decode(o):0,requiresConfirmation:!!(2&n),canModerate:!!(4&n),canAdmin:!!(8&n),buildType:d>=20&&16&n?Bt.decode(o):null}}},Me=Ie,Ce=e.frame(He),De={preencode(d,n){e.fixed32.preencode(d,n.id),Me.preencode(d,n.response),Ce.preencode(d,n.metadata),d.end++,n.anchor&&o.preencode(d,n.anchor)},encode(d,n){const c=(n.anchor?1:0)|(n.isActive?2:0);e.fixed32.encode(d,n.id),Me.encode(d,n.response),Ce.encode(d,n.metadata),e.uint.encode(d,c),n.anchor&&o.encode(d,n.anchor)},decode(d){const n=e.fixed32.decode(d),c=Me.decode(d),t=Ce.decode(d),r=e.uint.decode(d);return{id:n,response:c,metadata:t,anchor:1&r?o.decode(d):null,isActive:!!(2&r)}}},Ve=$,Le=e.frame(De),qe={preencode(e,d){Ve.preencode(e,d.header),Le.preencode(e,d.invitation)},encode(e,d){Ve.encode(e,d.header),Le.encode(e,d.invitation)},decode:e=>({header:Ve.decode(e),invitation:Le.decode(e)})},Ee=$,Be={preencode(d,o){Ee.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){Ee.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:Ee.decode(d),id:e.fixed32.decode(d)})},ze={preencode(d,n){e.fixed32.preencode(d,n.mailbox),e.fixed32.preencode(d,n.invitationSeed),o.preencode(d,n.anchor)},encode(d,n){e.fixed32.encode(d,n.mailbox),e.fixed32.encode(d,n.invitationSeed),o.encode(d,n.anchor)},decode:d=>({mailbox:e.fixed32.decode(d),invitationSeed:e.fixed32.decode(d),anchor:o.decode(d)})},Ne={preencode(d,n){e.fixed32.preencode(d,n.mailbox),e.fixed32.preencode(d,n.invitationSeed),o.preencode(d,n.anchor),e.fixed32.preencode(d,n.identityPublicKey)},encode(d,n){e.fixed32.encode(d,n.mailbox),e.fixed32.encode(d,n.invitationSeed),o.encode(d,n.anchor),e.fixed32.encode(d,n.identityPublicKey)},decode:d=>({mailbox:e.fixed32.decode(d),invitationSeed:e.fixed32.decode(d),anchor:o.decode(d),identityPublicKey:e.fixed32.decode(d)})},je={preencode(d,o){e.fixed32.preencode(d,o.mailbox)},encode(d,o){e.fixed32.encode(d,o.mailbox)},decode:d=>({mailbox:e.fixed32.decode(d)})},Oe=e.frame(ze),Ue=e.frame(Ne),Je=e.frame(je),Ge=e.array(e.ipv4Address),Qe={preencode(e,o){e.end++,o.room&&Oe.preencode(e,o.room),o.identity&&Ue.preencode(e,o.identity),o.contact&&Je.preencode(e,o.contact),d>=6&&o.readonly&&Er.preencode(e,o.readonly),d>=11&&o.additionalNodes&&Ge.preencode(e,o.additionalNodes),d>=20&&o.buildType&&Bt.preencode(e,o.buildType),d>=27&&o["readonly-v2"]&&Br.preencode(e,o["readonly-v2"])},encode(o,n){const c=(n.room?1:0)|(n.identity?2:0)|(n.contact?4:0)|(d>=6&&n.readonly?8:0)|(d>=11&&n.additionalNodes?16:0)|(d>=20&&n.buildType?32:0)|(d>=27&&n["readonly-v2"]?64:0);e.uint.encode(o,c),n.room&&Oe.encode(o,n.room),n.identity&&Ue.encode(o,n.identity),n.contact&&Je.encode(o,n.contact),d>=6&&n.readonly&&Er.encode(o,n.readonly),d>=11&&n.additionalNodes&&Ge.encode(o,n.additionalNodes),d>=20&&n.buildType&&Bt.encode(o,n.buildType),d>=27&&n["readonly-v2"]&&Br.encode(o,n["readonly-v2"])},decode(o){const n=e.uint.decode(o);return{room:1&n?Oe.decode(o):null,identity:2&n?Ue.decode(o):null,contact:4&n?Je.decode(o):null,readonly:d>=6&&8&n?Er.decode(o):null,additionalNodes:d>=11&&16&n?Ge.decode(o):null,buildType:d>=20&&32&n?Bt.decode(o):null,"readonly-v2":d>=27&&64&n?Br.decode(o):null}}},We=$,Xe={preencode(d,o){We.preencode(d,o.header),e.buffer.preencode(d,o.blindRequest)},encode(d,o){We.encode(d,o.header),e.buffer.encode(d,o.blindRequest)},decode:d=>({header:We.decode(d),blindRequest:e.buffer.decode(d)})},Ye=$,Ze={preencode(o,n){Ye.preencode(o,n.header),o.end++,n.profile&&zr.preencode(o,n.profile),d>=24&&n.key&&e.fixed32.preencode(o,n.key)},encode(o,n){const c=(n.profile?1:0)|(d>=24&&n.key?2:0);Ye.encode(o,n.header),e.uint.encode(o,c),n.profile&&zr.encode(o,n.profile),d>=24&&n.key&&e.fixed32.encode(o,n.key)},decode(o){const n=Ye.decode(o),c=e.uint.decode(o);return{header:n,profile:1&c?zr.decode(o):null,key:d>=24&&2&c?e.fixed32.decode(o):null}}},$e={preencode(e,d){},encode(e,d){},decode:e=>({})},_e=$e,ed=ge,dd={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.id),ed.preencode(d,o.request)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.id),ed.encode(d,o.request)},decode:d=>({deviceKey:e.fixed32.decode(d),id:e.fixed32.decode(d),request:ed.decode(d)})},od=$,nd=Re,cd={preencode(d,o){od.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),d.end++,o.identity&&nd.preencode(d,o.identity)},encode(d,o){const n=o.identity?1:0;od.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,n),o.identity&&nd.encode(d,o.identity)},decode:d=>({header:od.decode(d),deviceKey:e.fixed32.decode(d),identity:1&e.uint.decode(d)?nd.decode(d):null})},td=$,rd={preencode(d,o){td.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey)},encode(d,o){td.encode(d,o.header),e.fixed32.encode(d,o.deviceKey)},decode:d=>({header:td.decode(d),deviceKey:e.fixed32.decode(d)})},id=e.frame(R),ad=pe,sd={preencode(d,o){e.fixed32.preencode(d,o.key),id.preencode(d,o.status),ad.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),id.encode(d,o.status),ad.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),status:id.decode(d),profile:ad.decode(d)})},pd=id,ud=pe,ld={preencode(d,o){e.fixed32.preencode(d,o.key),pd.preencode(d,o.status),ud.preencode(d,o.profile),d.end++,o.proofs&&Nr.preencode(d,o.proofs)},encode(d,o){const n=o.proofs?1:0;e.fixed32.encode(d,o.key),pd.encode(d,o.status),ud.encode(d,o.profile),e.uint.encode(d,n),o.proofs&&Nr.encode(d,o.proofs)},decode:d=>({key:e.fixed32.decode(d),status:pd.decode(d),profile:ud.decode(d),proofs:1&e.uint.decode(d)?Nr.decode(d):null})},fd={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++,o.profileAttestation&&e.buffer.preencode(d,o.profileAttestation),o.latestReceipt&&e.buffer.preencode(d,o.latestReceipt)},encode(d,o){const n=(o.profileAttestation?1:0)|(o.latestReceipt?2:0);e.fixed32.encode(d,o.key),e.uint.encode(d,n),o.profileAttestation&&e.buffer.encode(d,o.profileAttestation),o.latestReceipt&&e.buffer.encode(d,o.latestReceipt)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d);return{key:o,profileAttestation:1&n?e.buffer.decode(d):null,latestReceipt:2&n?e.buffer.decode(d):null}}},md=$,yd=xe,bd={preencode(e,d){md.preencode(e,d.header),yd.preencode(e,d.member)},encode(e,d){md.encode(e,d.header),yd.encode(e,d.member)},decode:e=>({header:md.decode(e),member:yd.decode(e)})},xd=$,kd=e.frame(F),vd={preencode(d,o){xd.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),kd.preencode(d,o.status)},encode(d,o){xd.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),kd.encode(d,o.status)},decode:d=>({header:xd.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:kd.decode(d)})},gd=$,hd={preencode(d,o){gd.preencode(d,o.header),e.fixed32.preencode(d,o.key),d.end++},encode(d,o){const n=(o.isModerator?1:0)|(o.isAdmin?2:0);gd.encode(d,o.header),e.fixed32.encode(d,o.key),e.uint.encode(d,n)},decode(d){const o=gd.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{header:o,key:n,isModerator:!!(1&c),isAdmin:!!(2&c)}}},Kd=$,wd={preencode(d,o){Kd.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){Kd.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:Kd.decode(d),key:e.fixed32.decode(d)})},Td={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.mentions)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.mentions)},decode:d=>({key:e.fixed32.decode(d),mentions:e.uint.decode(d)})},Ad={preencode(d,o){d.end++,o.memberKey&&e.fixed32.preencode(d,o.memberKey)},encode(d,o){const n=o.memberKey?1:0;e.uint.encode(d,n),o.memberKey&&e.fixed32.encode(d,o.memberKey)},decode:d=>({memberKey:1&e.uint.decode(d)?e.fixed32.decode(d):null})},Pd=Ad,Sd={preencode(d,o){d.end++,o.from&&e.string.preencode(d,o.from),o.to&&e.string.preencode(d,o.to)},encode(d,o){const n=(o.from?1:0)|(o.to?2:0);e.uint.encode(d,n),o.from&&e.string.encode(d,o.from),o.to&&e.string.encode(d,o.to)},decode(d){const o=e.uint.decode(d);return{from:1&o?e.string.decode(d):null,to:2&o?e.string.decode(d):null}}},Id=e.frame(Ad),Rd=e.frame(Pd),Fd=e.frame(Sd),Hd={preencode(o,n){const c=(n.memberJoined?1:0)|(n.memberLeft?2:0)|(n.titleChanged?4:0)|(n.callStarted?8:0)|(n.callHangup?16:0)|(n.callMissed?32:0)|(d>=3&&n.roomAvatarChanged?64:0)|(d>=3&&n.invitationCreated?128:0)|(d>=3&&n.memberRemoved?256:0)|(d>=18&&n.locationShared?512:0);e.uint.preencode(o,c),n.memberJoined&&Id.preencode(o,n.memberJoined),n.memberLeft&&Rd.preencode(o,n.memberLeft),n.titleChanged&&Fd.preencode(o,n.titleChanged),d>=3&&n.memberRemoved&&jr.preencode(o,n.memberRemoved),d>=18&&n.locationShared&&Or.preencode(o,n.locationShared)},encode(o,n){const c=(n.memberJoined?1:0)|(n.memberLeft?2:0)|(n.titleChanged?4:0)|(n.callStarted?8:0)|(n.callHangup?16:0)|(n.callMissed?32:0)|(d>=3&&n.roomAvatarChanged?64:0)|(d>=3&&n.invitationCreated?128:0)|(d>=3&&n.memberRemoved?256:0)|(d>=18&&n.locationShared?512:0);e.uint.encode(o,c),n.memberJoined&&Id.encode(o,n.memberJoined),n.memberLeft&&Rd.encode(o,n.memberLeft),n.titleChanged&&Fd.encode(o,n.titleChanged),d>=3&&n.memberRemoved&&jr.encode(o,n.memberRemoved),d>=18&&n.locationShared&&Or.encode(o,n.locationShared)},decode(o){const n=e.uint.decode(o);return{memberJoined:1&n?Id.decode(o):null,memberLeft:2&n?Rd.decode(o):null,titleChanged:4&n?Fd.decode(o):null,callStarted:!!(8&n),callHangup:!!(16&n),callMissed:!!(32&n),roomAvatarChanged:d>=3&&!!(64&n),invitationCreated:d>=3&&!!(128&n),memberRemoved:d>=3&&256&n?jr.decode(o):null,locationShared:d>=18&&512&n?Or.decode(o):null}}},Md={preencode(e,o){e.end++,d>=18&&o.locationShared&&Ur.preencode(e,o.locationShared)},encode(o,n){const c=(n.callStarted?1:0)|(n.callHangup?2:0)|(n.callMissed?4:0)|(d>=18&&n.locationShared?8:0);e.uint.encode(o,c),d>=18&&n.locationShared&&Ur.encode(o,n.locationShared)},decode(o){const n=e.uint.decode(o);return{callStarted:!!(1&n),callHangup:!!(2&n),callMissed:!!(4&n),locationShared:d>=18&&8&n?Ur.decode(o):null}}},Cd={preencode(d,o){e.uint.preencode(d,o.start),e.uint.preencode(d,o.length)},encode(d,o){e.uint.encode(d,o.start),e.uint.encode(d,o.length)},decode:d=>({start:e.uint.decode(d),length:e.uint.decode(d)})},Dd=e.frame(Cd),Vd={preencode(d,o){Dd.preencode(d,o.range),e.string.preencode(d,o.content)},encode(d,o){Dd.encode(d,o.range),e.string.encode(d,o.content)},decode:d=>({range:Dd.decode(d),content:e.string.decode(d)})},Ld=Dd,qd={preencode(d,o){Ld.preencode(d,o.range),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Ld.encode(d,o.range),e.fixed32.encode(d,o.memberKey)},decode:d=>({range:Ld.decode(d),memberKey:e.fixed32.decode(d)})},Ed=g,Bd=e.array(e.uint),zd={preencode(o,n){o.end++,n.title&&e.string.preencode(o,n.title),n.description&&e.string.preencode(o,n.description),n.file&&Ed.preencode(o,n.file),d>=7&&n.files&&Bd.preencode(o,n.files)},encode(o,n){const c=(n.title?1:0)|(n.description?2:0)|(n.file?4:0)|(d>=7&&n.files?8:0);e.uint.encode(o,c),n.title&&e.string.encode(o,n.title),n.description&&e.string.encode(o,n.description),n.file&&Ed.encode(o,n.file),d>=7&&n.files&&Bd.encode(o,n.files)},decode(o){const n=e.uint.decode(o);return{title:1&n?e.string.decode(o):null,description:2&n?e.string.decode(o):null,file:4&n?Ed.decode(o):null,files:d>=7&&8&n?Bd.decode(o):null}}},Nd=Dd,jd=e.frame(zd),Od={preencode(d,o){Nd.preencode(d,o.range),e.string.preencode(d,o.url),d.end++,o.preview&&jd.preencode(d,o.preview)},encode(d,o){const n=o.preview?1:0;Nd.encode(d,o.range),e.string.encode(d,o.url),e.uint.encode(d,n),o.preview&&jd.encode(d,o.preview)},decode:d=>({range:Nd.decode(d),url:e.string.decode(d),preview:1&e.uint.decode(d)?jd.decode(d):null})},Ud=e.array(e.frame(qd)),Jd=e.array(e.frame(Od)),Gd=Jd,Qd=e.array(e.frame(Cd)),Wd=Qd,Xd=Qd,Yd=e.array(e.frame(Vd)),Zd=Qd,$d=Qd,_d={preencode(o,n){const c=(n.mention?1:0)|(n.httpLink?2:0)|(n.pearLink?4:0)|(n.bold?8:0)|(n.italic?16:0)|(n.code?32:0)|(n.emoji?64:0)|(n.codeBlock?128:0)|(n.strike?256:0)|(d>=11&&n.translation?512:0);e.uint.preencode(o,c),n.mention&&Ud.preencode(o,n.mention),n.httpLink&&Jd.preencode(o,n.httpLink),n.pearLink&&Gd.preencode(o,n.pearLink),n.bold&&Qd.preencode(o,n.bold),n.italic&&Wd.preencode(o,n.italic),n.code&&Xd.preencode(o,n.code),n.emoji&&Yd.preencode(o,n.emoji),n.codeBlock&&Zd.preencode(o,n.codeBlock),n.strike&&$d.preencode(o,n.strike),d>=11&&n.translation&&Jr.preencode(o,n.translation)},encode(o,n){const c=(n.mention?1:0)|(n.httpLink?2:0)|(n.pearLink?4:0)|(n.bold?8:0)|(n.italic?16:0)|(n.code?32:0)|(n.emoji?64:0)|(n.codeBlock?128:0)|(n.strike?256:0)|(d>=11&&n.translation?512:0);e.uint.encode(o,c),n.mention&&Ud.encode(o,n.mention),n.httpLink&&Jd.encode(o,n.httpLink),n.pearLink&&Gd.encode(o,n.pearLink),n.bold&&Qd.encode(o,n.bold),n.italic&&Wd.encode(o,n.italic),n.code&&Xd.encode(o,n.code),n.emoji&&Yd.encode(o,n.emoji),n.codeBlock&&Zd.encode(o,n.codeBlock),n.strike&&$d.encode(o,n.strike),d>=11&&n.translation&&Jr.encode(o,n.translation)},decode(o){const n=e.uint.decode(o);return{mention:1&n?Ud.decode(o):null,httpLink:2&n?Jd.decode(o):null,pearLink:4&n?Gd.decode(o):null,bold:8&n?Qd.decode(o):null,italic:16&n?Wd.decode(o):null,code:32&n?Xd.decode(o):null,emoji:64&n?Yd.decode(o):null,codeBlock:128&n?Zd.decode(o):null,strike:256&n?$d.decode(o):null,translation:d>=11&&512&n?Jr.decode(o):null}}},eo=e.array(e.frame(v)),oo=e.frame(_d),no=e.frame(Md),co={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&eo.preencode(d,o.files),o.display&&oo.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent),o.event&&no.preencode(d,o.event)},encode(o,c){const t=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(c.event?32:0)|(d>=18&&c.forwarded?64:0);e.uint.encode(o,t),c.text&&e.string.encode(o,c.text),c.files&&eo.encode(o,c.files),c.display&&oo.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent),c.event&&no.encode(o,c.event)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?eo.decode(o):null,display:4&c?oo.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,event:32&c?no.decode(o):null,forwarded:d>=18&&!!(64&c)}}},to=Bd,ro=oo,io={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&to.preencode(d,o.files),o.display&&ro.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent)},encode(o,c){const t=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(d>=18&&c.forwarded?32:0);e.uint.encode(o,t),c.text&&e.string.encode(o,c.text),c.files&&to.encode(o,c.files),c.display&&ro.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?to.decode(o):null,display:4&c?ro.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,forwarded:d>=18&&!!(32&c)}}},ao=eo,so=oo,po={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&ao.preencode(d,o.files),o.display&&so.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent)},encode(o,c){const t=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(d>=18&&c.forwarded?32:0);e.uint.encode(o,t),c.text&&e.string.encode(o,c.text),c.files&&ao.encode(o,c.files),c.display&&so.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?ao.decode(o):null,display:4&c?so.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,forwarded:d>=18&&!!(32&c)}}},uo={preencode(e,d){e.end++},encode(d,o){const n=(o.isEdited?1:0)|(o.isDeleted?2:0)|(o.isPinned?4:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isEdited:!!(1&o),isDeleted:!!(2&o),isPinned:!!(4&o)}}},lo={preencode(d,o){e.uint.preencode(d,o.thread),e.uint.preencode(d,o.index)},encode(d,o){e.uint.encode(d,o.thread),e.uint.encode(d,o.index)},decode:d=>({thread:e.uint.decode(d),index:e.uint.decode(d)})},fo=e.frame(z),mo={preencode(d,o){e.uint.preencode(d,o.id),e.uint.preencode(d,o.count),d.end++,o.parent&&n.preencode(d,o.parent),o.stats&&fo.preencode(d,o.stats)},encode(d,o){const c=(o.parent?1:0)|(o.stats?2:0);e.uint.encode(d,o.id),e.uint.encode(d,o.count),e.uint.encode(d,c),o.parent&&n.encode(d,o.parent),o.stats&&fo.encode(d,o.stats)},decode(d){const o=e.uint.decode(d),c=e.uint.decode(d),t=e.uint.decode(d);return{id:o,count:c,parent:1&t?n.decode(d):null,stats:2&t?fo.decode(d):null}}},yo=e.frame(uo),bo=e.frame(io),xo=e.frame(Hd),ko={preencode(d,o){lo.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),yo.preencode(d,o.status),o.message&&bo.preencode(d,o.message),o.event&&xo.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);lo.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),yo.encode(d,o.status),o.message&&bo.encode(d,o.message),o.event&&xo.encode(d,o.event)},decode(d){const o=lo.decode(d),c=n.decode(d),t=e.uint.decode(d),r=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:t,timestamp:r,editedAt:1&i?e.uint.decode(d):0,status:yo.decode(d),message:2&i?bo.decode(d):null,event:4&i?xo.decode(d):null}}},vo=yo,go=e.frame(po),ho=xo,Ko={preencode(d,o){lo.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),vo.preencode(d,o.status),o.message&&go.preencode(d,o.message),o.event&&ho.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);lo.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),vo.encode(d,o.status),o.message&&go.encode(d,o.message),o.event&&ho.encode(d,o.event)},decode(d){const o=lo.decode(d),c=n.decode(d),t=e.uint.decode(d),r=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:t,timestamp:r,editedAt:1&i?e.uint.decode(d):0,status:vo.decode(d),message:2&i?go.decode(d):null,event:4&i?ho.decode(d):null}}},wo=$,To=e.frame(co),Ao={preencode(e,d){wo.preencode(e,d.header),To.preencode(e,d.message)},encode(e,d){wo.encode(e,d.header),To.encode(e,d.message)},decode:e=>({header:wo.decode(e),message:To.decode(e)})},Po=$,So={preencode(e,d){Po.preencode(e,d.header),n.preencode(e,d.oplog)},encode(e,d){Po.encode(e,d.header),n.encode(e,d.oplog)},decode:e=>({header:Po.decode(e),oplog:n.decode(e)})},Io=$,Ro=To,Fo={preencode(e,d){Io.preencode(e,d.header),n.preencode(e,d.oplog),Ro.preencode(e,d.message)},encode(e,d){Io.encode(e,d.header),n.encode(e,d.oplog),Ro.encode(e,d.message)},decode:e=>({header:Io.decode(e),oplog:n.decode(e),message:Ro.decode(e)})},Ho=$,Mo={preencode(e,d){Ho.preencode(e,d.header),n.preencode(e,d.oplog),e.end++},encode(d,o){const c=o.isPinned?1:0;Ho.encode(d,o.header),n.encode(d,o.oplog),e.uint.encode(d,c)},decode:d=>({header:Ho.decode(d),oplog:n.decode(d),isPinned:!!(1&e.uint.decode(d))})},Co={preencode(d,o){lo.preencode(d,o.id),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),e.string.preencode(d,o.reaction)},encode(d,o){lo.encode(d,o.id),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),e.string.encode(d,o.reaction)},decode:d=>({id:lo.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),reaction:e.string.decode(d)})},Do={preencode(d,o){e.string.preencode(d,o.text),e.uint.preencode(d,o.count)},encode(d,o){e.string.encode(d,o.text),e.uint.encode(d,o.count)},decode:d=>({text:e.string.decode(d),count:e.uint.decode(d)})},Vo=e.array(e.frame(Do)),Lo={preencode(o,n){lo.preencode(o,n.id),e.uint.preencode(o,n.total),Vo.preencode(o,n.reactions),o.end++,d>=11&&n.editedAt&&e.uint.preencode(o,n.editedAt)},encode(o,n){const c=d>=11&&n.editedAt?1:0;lo.encode(o,n.id),e.uint.encode(o,n.total),Vo.encode(o,n.reactions),e.uint.encode(o,c),d>=11&&n.editedAt&&e.uint.encode(o,n.editedAt)},decode(o){const n=lo.decode(o),c=e.uint.decode(o),t=Vo.decode(o),r=o.start<o.end?e.uint.decode(o):0;return{id:n,total:c,reactions:t,editedAt:d>=11&&1&r?e.uint.decode(o):0}}},qo=$,Eo={preencode(d,o){qo.preencode(d,o.header),n.preencode(d,o.oplog),e.string.preencode(d,o.reaction)},encode(d,o){qo.encode(d,o.header),n.encode(d,o.oplog),e.string.encode(d,o.reaction)},decode:d=>({header:qo.decode(d),oplog:n.decode(d),reaction:e.string.decode(d)})},Bo=$,zo={preencode(d,o){Bo.preencode(d,o.header),n.preencode(d,o.oplog),e.string.preencode(d,o.reaction)},encode(d,o){Bo.encode(d,o.header),n.encode(d,o.oplog),e.string.encode(d,o.reaction)},decode:d=>({header:Bo.decode(d),oplog:n.decode(d),reaction:e.string.decode(d)})},No=$,jo=e.frame(Y),Oo={preencode(d,o){No.preencode(d,o.header),e.uint.preencode(d,o.key),jo.preencode(d,o.config)},encode(d,o){No.encode(d,o.header),e.uint.encode(d,o.key),jo.encode(d,o.config)},decode:d=>({header:No.decode(d),key:e.uint.decode(d),config:jo.decode(d)})},Uo={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.string.preencode(d,o.displayName),d.end++,o.avatar&&Gr.preencode(d,o.avatar)},encode(d,o){const n=o.avatar?1:0;e.fixed32.encode(d,o.memberKey),e.string.encode(d,o.displayName),e.uint.encode(d,n),o.avatar&&Gr.encode(d,o.avatar)},decode:d=>({memberKey:e.fixed32.decode(d),displayName:e.string.decode(d),avatar:1&e.uint.decode(d)?Gr.decode(d):null})},Jo={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++,o.username&&e.string.preencode(d,o.username)},encode(d,o){const n=o.username?1:0;e.fixed32.encode(d,o.key),e.uint.encode(d,n),o.username&&e.string.encode(d,o.username)},decode:d=>({key:e.fixed32.decode(d),username:1&e.uint.decode(d)?e.string.decode(d):null})},Go=e.frame(Jo),Qo={preencode(d,o){e.fixed32.preencode(d,o.publicKey),d.end++,o.discoveryCoreKey&&e.fixed32.preencode(d,o.discoveryCoreKey),o.userRegistry&&Go.preencode(d,o.userRegistry)},encode(d,o){const n=(o.discoveryCoreKey?1:0)|(o.userRegistry?2:0);e.fixed32.encode(d,o.publicKey),e.uint.encode(d,n),o.discoveryCoreKey&&e.fixed32.encode(d,o.discoveryCoreKey),o.userRegistry&&Go.encode(d,o.userRegistry)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d);return{publicKey:o,discoveryCoreKey:1&n?e.fixed32.decode(d):null,userRegistry:2&n?Go.decode(d):null}}},Wo=$,Xo=e.frame(G),Yo=e.frame(Q),Zo=jo,$o=e.frame(Qo),_o=be,en=e.array(e.frame(ue)),dn={preencode(e,d){Wo.preencode(e,d.header),Xo.preencode(e,d.digest),Yo.preencode(e,d.capabilities),e.end++,d.config&&Zo.preencode(e,d.config),d.identity&&$o.preencode(e,d.identity),d.bootstrapDevice&&_o.preencode(e,d.bootstrapDevice),d.initialMembers&&en.preencode(e,d.initialMembers)},encode(d,o){const n=(o.config?1:0)|(o.identity?2:0)|(o.bootstrapDevice?4:0)|(o.initialMembers?8:0);Wo.encode(d,o.header),Xo.encode(d,o.digest),Yo.encode(d,o.capabilities),e.uint.encode(d,n),o.config&&Zo.encode(d,o.config),o.identity&&$o.encode(d,o.identity),o.bootstrapDevice&&_o.encode(d,o.bootstrapDevice),o.initialMembers&&en.encode(d,o.initialMembers)},decode(d){const o=Wo.decode(d),n=Xo.decode(d),c=Yo.decode(d),t=e.uint.decode(d);return{header:o,digest:n,capabilities:c,config:1&t?Zo.decode(d):null,identity:2&t?$o.decode(d):null,bootstrapDevice:4&t?_o.decode(d):null,initialMembers:8&t?en.decode(d):null}}},on=$,nn={preencode(d,o){on.preencode(d,o.header),e.uint.preencode(d,o.version)},encode(d,o){on.encode(d,o.header),e.uint.encode(d,o.version)},decode:d=>({header:on.decode(d),version:e.uint.decode(d)})},cn=$,tn=J,rn={preencode(d,o){cn.preencode(d,o.header),e.uint.preencode(d,o.key),tn.preencode(d,o.settings)},encode(d,o){cn.encode(d,o.header),e.uint.encode(d,o.key),tn.encode(d,o.settings)},decode:d=>({header:cn.decode(d),key:e.uint.decode(d),settings:tn.decode(d)})},an={preencode(o,n){e.fixed32.preencode(o,n.memberKey),Qr.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=22&&n.contactInfo&&Wr.preencode(o,n.contactInfo),d>=22&&n.version&&e.uint.preencode(o,n.version),d>=24&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=22&&n.contactInfo?4:0)|(d>=22&&n.version?8:0)|(d>=24&&n.alias?16:0);e.fixed32.encode(o,n.memberKey),Qr.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=22&&n.contactInfo&&Wr.encode(o,n.contactInfo),d>=22&&n.version&&e.uint.encode(o,n.version),d>=24&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.fixed32.decode(o),c=Qr.decode(o),t=e.uint.decode(o);return{memberKey:n,status:c,mailbox:1&t?e.fixed32.decode(o):null,roomKey:2&t?e.fixed32.decode(o):null,contactInfo:d>=22&&4&t?Wr.decode(o):null,version:d>=22&&8&t?e.uint.decode(o):0,alias:d>=24&&16&t?e.string.decode(o):null}}},sn={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.seed),o.preencode(d,n.initiator),e.fixed32.preencode(d,n.fastForwardTo)},encode(d,n){e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.fixed32.encode(d,n.seed),o.encode(d,n.initiator),e.fixed32.encode(d,n.fastForwardTo)},decode:d=>({roomKey:e.fixed32.decode(d),encryptionKey:e.buffer.decode(d),seed:e.fixed32.decode(d),initiator:o.decode(d),fastForwardTo:e.fixed32.decode(d)})},pn=e.array(e.frame(sn)),un=X,ln={preencode(e,d){pn.preencode(e,d.sharedRooms),un.preencode(e,d.blockedContacts)},encode(e,d){pn.encode(e,d.sharedRooms),un.encode(e,d.blockedContacts)},decode:e=>({sharedRooms:pn.decode(e),blockedContacts:un.decode(e)})},fn=$o,mn={preencode(e,d){fn.preencode(e,d.identity)},encode(e,d){fn.encode(e,d.identity)},decode:e=>({identity:fn.decode(e)})},yn={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.contacts)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.contacts)},decode:d=>({rooms:e.uint.decode(d),contacts:e.uint.decode(d)})},bn={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.contactRequests)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.contactRequests)},decode:d=>({rooms:e.uint.decode(d),contactRequests:e.uint.decode(d)})},xn={preencode(d,o){e.buffer.preencode(d,o.entropy)},encode(d,o){e.buffer.encode(d,o.entropy)},decode:d=>({entropy:e.buffer.decode(d)})},kn={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.devicePublicKey),e.fixed32.preencode(d,o.writerKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.devicePublicKey),e.fixed32.encode(d,o.writerKey)},decode:d=>({publicKey:e.fixed32.decode(d),devicePublicKey:e.fixed32.decode(d),writerKey:e.fixed32.decode(d)})},vn=e.frame(kn),gn={preencode(n,c){e.fixed32.preencode(n,c.id),e.fixed32.preencode(n,c.invitationSeed),e.fixed32.preencode(n,c.mailbox),t.preencode(n,c.responseKeyPair),o.preencode(n,c.initiator),o.preencode(n,c.inviter),n.end++,c.identity&&vn.preencode(n,c.identity),d>=20&&c.buildType&&Bt.preencode(n,c.buildType),d>=27&&c.link&&o.preencode(n,c.link)},encode(n,c){const r=(c.identity?1:0)|(d>=20&&c.buildType?2:0)|(d>=27&&c.link?4:0);e.fixed32.encode(n,c.id),e.fixed32.encode(n,c.invitationSeed),e.fixed32.encode(n,c.mailbox),t.encode(n,c.responseKeyPair),o.encode(n,c.initiator),o.encode(n,c.inviter),e.uint.encode(n,r),c.identity&&vn.encode(n,c.identity),d>=20&&c.buildType&&Bt.encode(n,c.buildType),d>=27&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),r=e.fixed32.decode(n),i=e.fixed32.decode(n),a=t.decode(n),s=o.decode(n),p=o.decode(n),u=e.uint.decode(n);return{id:c,invitationSeed:r,mailbox:i,responseKeyPair:a,initiator:s,inviter:p,identity:1&u?vn.decode(n):null,buildType:d>=20&&2&u?Bt.decode(n):null,link:d>=27&&4&u?o.decode(n):null}}},hn=$,Kn={preencode(d,o){hn.preencode(d,o.header),e.buffer.preencode(d,o.blindResponse)},encode(d,o){hn.encode(d,o.header),e.buffer.encode(d,o.blindResponse)},decode:d=>({header:hn.decode(d),blindResponse:e.buffer.decode(d)})},wn=$,Tn=e.frame(gn),An={preencode(e,d){wn.preencode(e,d.header),Tn.preencode(e,d.invitation)},encode(e,d){wn.encode(e,d.header),Tn.encode(e,d.invitation)},decode:e=>({header:wn.decode(e),invitation:Tn.decode(e)})},Pn=$,Sn={preencode(d,o){Pn.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){Pn.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:Pn.decode(d),id:e.fixed32.decode(d)})},In={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.devicePublicKey),d.end++,o.privateProfileKey&&e.fixed32.preencode(d,o.privateProfileKey),o.deviceKeyPair&&t.preencode(d,o.deviceKeyPair),e.buffer.preencode(d,o.deviceProof)},encode(d,o){const n=(o.privateProfileKey?1:0)|(o.deviceKeyPair?2:0);e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.devicePublicKey),e.uint.encode(d,n),o.privateProfileKey&&e.fixed32.encode(d,o.privateProfileKey),o.deviceKeyPair&&t.encode(d,o.deviceKeyPair),e.buffer.encode(d,o.deviceProof)},decode(d){const o=e.fixed32.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{publicKey:o,devicePublicKey:n,privateProfileKey:1&c?e.fixed32.decode(d):null,deviceKeyPair:2&c?t.decode(d):null,deviceProof:e.buffer.decode(d)}}},Rn={preencode(o,n){o.end++,d>=25&&n.roomSnoozeTime&&e.uint.preencode(o,n.roomSnoozeTime)},encode(o,n){const c=(n.isActive?1:0)|(n.isFullyMuted?2:0)|(n.isMentionsOnlyMuted?4:0)|(d>=9&&n.isReadOnly?8:0)|(d>=18&&n.isFavorite?16:0)|(d>=21&&n.isUnread?32:0)|(d>=25&&n.roomSnoozeTime?64:0);e.uint.encode(o,c),d>=25&&n.roomSnoozeTime&&e.uint.encode(o,n.roomSnoozeTime)},decode(o){const n=e.uint.decode(o);return{isActive:!!(1&n),isFullyMuted:!!(2&n),isMentionsOnlyMuted:!!(4&n),isReadOnly:d>=9&&!!(8&n),isFavorite:d>=18&&!!(16&n),isUnread:d>=21&&!!(32&n),roomSnoozeTime:d>=25&&64&n?e.uint.decode(o):0}}},Fn=e.frame(Rn),Hn=e.frame(In),Mn=vn,Cn={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),Fn.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,c.initiator&&o.preencode(n,c.initiator),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),c.identitySwap&&Hn.preencode(n,c.identitySwap),d>=6&&c.identitySwapV2&&Mn.preencode(n,c.identitySwapV2),d>=10&&c.contact&&e.fixed32.preencode(n,c.contact),d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=29&&c.activeClock&&e.uint.preencode(n,c.activeClock)},encode(n,c){const t=(c.initiator?1:0)|(c.fastForwardTo?2:0)|(c.identitySwap?4:0)|(d>=6&&c.identitySwapV2?8:0)|(d>=10&&c.contact?16:0)|(d>=27&&c.bootFrom?32:0)|(d>=29&&c.activeClock?64:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),Fn.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,t),c.initiator&&o.encode(n,c.initiator),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),c.identitySwap&&Hn.encode(n,c.identitySwap),d>=6&&c.identitySwapV2&&Mn.encode(n,c.identitySwapV2),d>=10&&c.contact&&e.fixed32.encode(n,c.contact),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom),d>=29&&c.activeClock&&e.uint.encode(n,c.activeClock)},decode(n){const c=e.fixed32.decode(n),t=e.buffer.decode(n),r=e.fixed32.decode(n),i=Fn.decode(n),a=e.uint.decode(n),s=e.uint.decode(n);return{roomKey:c,encryptionKey:t,mailbox:r,status:i,clock:a,initiator:1&s?o.decode(n):null,fastForwardTo:2&s?e.fixed32.decode(n):null,identitySwap:4&s?Hn.decode(n):null,identitySwapV2:d>=6&&8&s?Mn.decode(n):null,contact:d>=10&&16&s?e.fixed32.decode(n):null,bootFrom:d>=27&&32&s?o.decode(n):null,activeClock:d>=29&&64&s?e.uint.decode(n):0}}},Dn=$,Vn={preencode(d,n){Dn.preencode(d,n.header),e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.mailbox),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.dm&&e.fixed32.preencode(d,n.dm)},encode(n,c){const t=(c.fastForwardTo?1:0)|(c.initiator?2:0)|(c.dm?4:0)|(d>=9&&c.isReadOnly?8:0);Dn.encode(n,c.header),e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),e.uint.encode(n,t),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),c.initiator&&o.encode(n,c.initiator),c.dm&&e.fixed32.encode(n,c.dm)},decode(n){const c=Dn.decode(n),t=e.fixed32.decode(n),r=e.buffer.decode(n),i=e.fixed32.decode(n),a=e.uint.decode(n);return{header:c,roomKey:t,encryptionKey:r,mailbox:i,fastForwardTo:1&a?e.fixed32.decode(n):null,initiator:2&a?o.decode(n):null,dm:4&a?e.fixed32.decode(n):null,isReadOnly:d>=9&&!!(8&a)}}},Ln=$,qn={preencode(d,o){Ln.preencode(d,o.header),e.fixed32.preencode(d,o.discoveryKey)},encode(d,o){Ln.encode(d,o.header),e.fixed32.encode(d,o.discoveryKey)},decode:d=>({header:Ln.decode(d),discoveryKey:e.fixed32.decode(d)})},En=$,Bn=Fn,zn={preencode(d,o){En.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.key),Bn.preencode(d,o.status)},encode(d,o){En.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.key),Bn.encode(d,o.status)},decode:d=>({header:En.decode(d),roomKey:e.fixed32.decode(d),key:e.uint.decode(d),status:Bn.decode(d)})},Nn={preencode(e,d){e.end++},encode(o,n){const c=(n.isBlocked?1:0)|(d>=22&&n.isActive?2:0);e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{isBlocked:!!(1&n),isActive:d>=22&&!!(2&n)}}},jn={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.clock),Xr.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=22&&n.contactInfo&&Yr.preencode(o,n.contactInfo),d>=24&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=22&&n.contactInfo?4:0)|(d>=24&&n.alias?8:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.clock),Xr.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=22&&n.contactInfo&&Yr.encode(o,n.contactInfo),d>=24&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),t=Xr.decode(o),r=e.uint.decode(o);return{memberKey:n,clock:c,status:t,mailbox:1&r?e.fixed32.decode(o):null,roomKey:2&r?e.fixed32.decode(o):null,contactInfo:d>=22&&4&r?Yr.decode(o):null,alias:d>=24&&8&r?e.string.decode(o):null}}},On=$,Un=e.frame(an),Jn={preencode(e,d){On.preencode(e,d.header),Un.preencode(e,d.contact)},encode(e,d){On.encode(e,d.header),Un.encode(e,d.contact)},decode:e=>({header:On.decode(e),contact:Un.decode(e)})},Gn=$,Qn={preencode(d,o){Gn.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),Zr.preencode(d,o.status)},encode(d,o){Gn.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),Zr.encode(d,o.status)},decode:d=>({header:Gn.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:Zr.decode(d)})},Wn=$,Xn={preencode(d,o){Wn.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Wn.encode(d,o.header),e.fixed32.encode(d,o.memberKey)},decode:d=>({header:Wn.decode(d),memberKey:e.fixed32.decode(d)})},Yn={preencode(e,d){e.end++},encode(d,o){const n=(o.isPending?1:0)|(o.isAccepted?2:0)|(o.isRejected?4:0)|(o.isDiscarded?8:0)|(o.isSeen?16:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isPending:!!(1&o),isAccepted:!!(2&o),isRejected:!!(4&o),isDiscarded:!!(8&o),isSeen:!!(16&o)}}},Zn=xe,$n=e.frame(r),_n={preencode(d,o){Zn.preencode(d,o.sender),$n.preencode(d,o.keys),e.fixed32.preencode(d,o.mailbox),d.end++,o.message&&e.string.preencode(d,o.message)},encode(d,o){const n=o.message?1:0;Zn.encode(d,o.sender),$n.encode(d,o.keys),e.fixed32.encode(d,o.mailbox),e.uint.encode(d,n),o.message&&e.string.encode(d,o.message)},decode:d=>({sender:Zn.decode(d),keys:$n.decode(d),mailbox:e.fixed32.decode(d),message:1&e.uint.decode(d)?e.string.decode(d):null})},ec=e.frame(_n),dc={preencode(e,d){ec.preencode(e,d.body),ne.preencode(e,d.attestation)},encode(e,d){ec.encode(e,d.body),ne.encode(e,d.attestation)},decode:e=>({body:ec.decode(e),attestation:ne.decode(e)})},oc=pe,nc=e.frame(Yn),cc=$n,tc={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.clock),oc.preencode(o,n.sender),nc.preencode(o,n.status),cc.preencode(o,n.keys),e.fixed32.preencode(o,n.mailbox),o.end++,n.message&&e.string.preencode(o,n.message),d>=11&&n.sentAt&&e.uint.preencode(o,n.sentAt),d>=22&&n.contactInfo&&$r.preencode(o,n.contactInfo)},encode(o,n){const c=(n.message?1:0)|(d>=11&&n.sentAt?2:0)|(d>=22&&n.contactInfo?4:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.clock),oc.encode(o,n.sender),nc.encode(o,n.status),cc.encode(o,n.keys),e.fixed32.encode(o,n.mailbox),e.uint.encode(o,c),n.message&&e.string.encode(o,n.message),d>=11&&n.sentAt&&e.uint.encode(o,n.sentAt),d>=22&&n.contactInfo&&$r.encode(o,n.contactInfo)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),t=oc.decode(o),r=nc.decode(o),i=cc.decode(o),a=e.fixed32.decode(o),s=e.uint.decode(o);return{memberKey:n,clock:c,sender:t,status:r,keys:i,mailbox:a,message:1&s?e.string.decode(o):null,sentAt:d>=11&&2&s?e.uint.decode(o):0,contactInfo:d>=22&&4&s?$r.decode(o):null}}},rc=$,ic={preencode(d,o){rc.preencode(d,o.header),e.buffer.preencode(d,o.blindRequest)},encode(d,o){rc.encode(d,o.header),e.buffer.encode(d,o.blindRequest)},decode:d=>({header:rc.decode(d),blindRequest:e.buffer.decode(d)})},ac=$,sc=nc,pc={preencode(o,n){ac.preencode(o,n.header),e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.key),sc.preencode(o,n.status),o.end++,d>=10&&n.roomKey&&e.fixed32.preencode(o,n.roomKey)},encode(o,n){const c=d>=10&&n.roomKey?1:0;ac.encode(o,n.header),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.key),sc.encode(o,n.status),e.uint.encode(o,c),d>=10&&n.roomKey&&e.fixed32.encode(o,n.roomKey)},decode(o){const n=ac.decode(o),c=e.fixed32.decode(o),t=e.uint.decode(o),r=sc.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{header:n,memberKey:c,key:t,status:r,roomKey:d>=10&&1&i?e.fixed32.decode(o):null}}},uc={preencode(d,o){e.uint.preencode(d,o.timestamp),e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.mailbox)},encode(d,o){e.uint.encode(d,o.timestamp),e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.mailbox)},decode:d=>({version:e.uint.decode(d),timestamp:e.uint.decode(d),key:e.fixed32.decode(d),mailbox:e.fixed32.decode(d)})},lc={preencode(d,o){const n=o.version??1;switch(e.uint.preencode(d,n),n){case 0:case 1:uc.preencode(d,o);break;default:throw new Error("Unsupported version")}},encode(d,o){const n=o.version??1;switch(e.uint.encode(d,n),n){case 0:case 1:uc.encode(d,o);break;default:throw new Error("Unsupported version")}},decode(d){const o=d.start,n=e.uint.decode(d);switch(d.start=o,n){case 0:case 1:return uc.decode(d);default:throw new Error("Unsupported version")}}},fc=$,mc={preencode(o,c){fc.preencode(o,c.header),n.preencode(o,c.oplog),e.uint.preencode(o,c.index),_r.preencode(o,c.preview),o.end++,d>=7&&c.displayType&&Pc.preencode(o,c.displayType)},encode(o,c){const t=d>=7&&c.displayType?1:0;fc.encode(o,c.header),n.encode(o,c.oplog),e.uint.encode(o,c.index),_r.encode(o,c.preview),e.uint.encode(o,t),d>=7&&c.displayType&&Pc.encode(o,c.displayType)},decode(o){const c=fc.decode(o),t=n.decode(o),r=e.uint.decode(o),i=_r.decode(o),a=o.start<o.end?e.uint.decode(o):0;return{header:c,oplog:t,index:r,preview:i,displayType:d>=7&&1&a?Pc.decode(o):0}}},yc={preencode(o,n){o.end++,d>=3&&n.memberKey&&e.fixed32.preencode(o,n.memberKey)},encode(o,n){const c=d>=3&&n.memberKey?1:0;e.uint.encode(o,c),d>=3&&n.memberKey&&e.fixed32.encode(o,n.memberKey)},decode(o){const n=e.uint.decode(o);return{memberKey:d>=3&&1&n?e.fixed32.decode(o):null}}},bc=pe,xc={preencode(e,d){bc.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){bc.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:bc.decode(e),attestation:ne.decode(e)})},kc=$,vc={preencode(d,o){kc.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){kc.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:kc.decode(d),key:e.fixed32.decode(d)})},gc={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),ne.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){e.fixed32.encode(d,o.deviceKey),ne.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({deviceKey:e.fixed32.decode(d),privateProfileIdentity:ne.decode(d),deviceProof:e.buffer.decode(d)})},hc={preencode(o,n){e.fixed32.preencode(o,n.roomKey),e.fixed32.preencode(o,n.encryptionKey),e.fixed32.preencode(o,n.seed),o.end++,d>=6&&n.fastForwardTo&&e.fixed32.preencode(o,n.fastForwardTo)},encode(o,n){const c=d>=6&&n.fastForwardTo?1:0;e.fixed32.encode(o,n.roomKey),e.fixed32.encode(o,n.encryptionKey),e.fixed32.encode(o,n.seed),e.uint.encode(o,c),d>=6&&n.fastForwardTo&&e.fixed32.encode(o,n.fastForwardTo)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=e.fixed32.decode(o),r=e.uint.decode(o);return{roomKey:n,encryptionKey:c,seed:t,fastForwardTo:d>=6&&1&r?e.fixed32.decode(o):null}}},Kc={preencode(o,n){e.fixed32.preencode(o,n.publicKey),e.fixed32.preencode(o,n.writerKey),e.fixed32.preencode(o,n.devicePublicKey),o.end++,d>=6&&n.privateProfileKey&&e.fixed32.preencode(o,n.privateProfileKey)},encode(o,n){const c=d>=6&&n.privateProfileKey?1:0;e.fixed32.encode(o,n.publicKey),e.fixed32.encode(o,n.writerKey),e.fixed32.encode(o,n.devicePublicKey),e.uint.encode(o,c),d>=6&&n.privateProfileKey&&e.fixed32.encode(o,n.privateProfileKey)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=e.fixed32.decode(o),r=e.uint.decode(o);return{publicKey:n,writerKey:c,devicePublicKey:t,privateProfileKey:d>=6&&1&r?e.fixed32.decode(o):null}}},wc=$,Tc={preencode(d,o){wc.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey)},encode(d,o){wc.encode(d,o.header),e.fixed32.encode(d,o.memberKey)},decode:d=>({header:wc.decode(d),memberKey:e.fixed32.decode(d)})},Ac={HttpLink:1,PearLink:2},Pc={preencode(e,d){e.end++},encode(d,o){if(o>2)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Sc=$,Ic={preencode(d,o){Sc.preencode(d,o.header),e.uint.preencode(d,o.value)},encode(d,o){Sc.encode(d,o.header),e.uint.encode(d,o.value)},decode:d=>({header:Sc.decode(d),value:e.uint.decode(d)})},Rc={preencode(d,o){e.uint.preencode(d,o.key),e.uint.preencode(d,o.value)},encode(d,o){e.uint.encode(d,o.key),e.uint.encode(d,o.value)},decode:d=>({key:e.uint.decode(d),value:e.uint.decode(d)})},Fc=$,Hc={preencode(o,n){Fc.preencode(o,n.header),e.uint.preencode(o,n.from),e.uint.preencode(o,n.to),o.end++,d>=20&&n.buildType&&Bt.preencode(o,n.buildType)},encode(o,n){const c=d>=20&&n.buildType?1:0;Fc.encode(o,n.header),e.uint.encode(o,n.from),e.uint.encode(o,n.to),e.uint.encode(o,c),d>=20&&n.buildType&&Bt.encode(o,n.buildType)},decode(o){const n=Fc.decode(o),c=e.uint.decode(o),t=e.uint.decode(o),r=o.start<o.end?e.uint.decode(o):0;return{header:n,from:c,to:t,buildType:d>=20&&1&r?Bt.decode(o):null}}},Mc={RoomType:1,IsExperimental:2,IsJoiningDisabled:3,IsAppendingDisabled:4,IsCallingDisabled:5,IsMembershipEventsDisabled:6,IsAttachmentsDisabled:7,IsLinksDisabled:8,IsRoomInviteHidden:9},Cc={preencode(e,d){e.end++},encode(d,o){if(o>9)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Dc={en:"en",it:"it",ru:"ru",es:"es",de:"de"},Vc={preencode(e,d){e.end++},encode(d,o){switch(o){case"en":e.uint.encode(d,1);break;case"it":e.uint.encode(d,2);break;case"ru":e.uint.encode(d,3);break;case"es":e.uint.encode(d,4);break;case"de":e.uint.encode(d,5);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"en";case 2:return"it";case 3:return"ru";case 4:return"es";case 5:return"de";default:return null}}},Lc=Dd,qc={preencode(d,o){Lc.preencode(d,o.range),Vc.preencode(d,o.language),e.string.preencode(d,o.text)},encode(d,o){Lc.encode(d,o.range),Vc.encode(d,o.language),e.string.encode(d,o.text)},decode:d=>({range:Lc.decode(d),language:Vc.decode(d),text:e.string.decode(d)})},Ec={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.key)},decode:d=>({deviceKey:e.fixed32.decode(d),key:e.fixed32.decode(d)})},Bc=$,zc={preencode(d,o){Bc.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){Bc.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:Bc.decode(d),key:e.fixed32.decode(d)})},Nc=$,jc={preencode(d,o){Nc.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){Nc.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:Nc.decode(d),key:e.fixed32.decode(d)})},Oc={Flag:1},Uc={preencode(e,d){e.end++},encode(d,o){if(o>1)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Jc={preencode(d,o){lo.preencode(d,o.id),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),Uc.preencode(d,o.label)},encode(d,o){lo.encode(d,o.id),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),Uc.encode(d,o.label)},decode:d=>({id:lo.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),label:Uc.decode(d)})},Gc=$,Qc={preencode(e,d){Gc.preencode(e,d.header),n.preencode(e,d.oplog),Uc.preencode(e,d.label)},encode(e,d){Gc.encode(e,d.header),n.encode(e,d.oplog),Uc.encode(e,d.label)},decode:e=>({header:Gc.decode(e),oplog:n.decode(e),label:Uc.decode(e)})},Wc=$,Xc={preencode(e,d){Wc.preencode(e,d.header),n.preencode(e,d.oplog),Uc.preencode(e,d.label)},encode(e,d){Wc.encode(e,d.header),n.encode(e,d.oplog),Uc.encode(e,d.label)},decode:e=>({header:Wc.decode(e),oplog:n.decode(e),label:Uc.decode(e)})},Yc={preencode(d,o){Uc.preencode(d,o.label),e.uint.preencode(d,o.count)},encode(d,o){Uc.encode(d,o.label),e.uint.encode(d,o.count)},decode:d=>({label:Uc.decode(d),count:e.uint.decode(d)})},Zc=e.array(e.frame(Yc)),$c={preencode(o,n){lo.preencode(o,n.id),e.uint.preencode(o,n.total),Zc.preencode(o,n.labels),e.uint.preencode(o,n.editedAt),o.end++,d>=15&&n.flagsClock&&e.uint.preencode(o,n.flagsClock),d>=15&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(d>=15&&n.flagsClock?1:0)|(d>=15&&n.version?2:0)|(d>=16&&n.isDeleted?4:0);lo.encode(o,n.id),e.uint.encode(o,n.total),Zc.encode(o,n.labels),e.uint.encode(o,n.editedAt),e.uint.encode(o,c),d>=15&&n.flagsClock&&e.uint.encode(o,n.flagsClock),d>=15&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=lo.decode(o),c=e.uint.decode(o),t=Zc.decode(o),r=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{id:n,total:c,labels:t,editedAt:r,flagsClock:d>=15&&1&i?e.uint.decode(o):0,version:d>=15&&2&i?e.uint.decode(o):0,isDeleted:d>=16&&!!(4&i)}}},_c=$,et={preencode(d,o){_c.preencode(d,o.header),e.uint.preencode(d,o.length)},encode(d,o){_c.encode(d,o.header),e.uint.encode(d,o.length)},decode:d=>({header:_c.decode(d),length:e.uint.decode(d)})},dt={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.length)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.length)},decode:d=>({memberKey:e.fixed32.decode(d),length:e.uint.decode(d)})},ot=Z,nt={preencode(o,n){o.end++,d>=23&&n.profileSnoozeTime&&e.uint.preencode(o,n.profileSnoozeTime)},encode(o,n){const c=(d>=13&&n.disableReadReceipts?1:0)|(d>=21&&n.stripAttachmentMetadata?2:0)|(d>=23&&n.profileSnoozeTime?4:0);e.uint.encode(o,c),d>=23&&n.profileSnoozeTime&&e.uint.encode(o,n.profileSnoozeTime)},decode(o){const n=e.uint.decode(o);return{disableReadReceipts:d>=13&&!!(1&n),stripAttachmentMetadata:d>=21&&!!(2&n),profileSnoozeTime:d>=23&&4&n?e.uint.decode(o):0}}},ct={disableReadReceipts:"disableReadReceipts",stripAttachmentMetadata:"stripAttachmentMetadata",profileSnoozeTime:"profileSnoozeTime"},tt={preencode(e,d){e.end++},encode(d,o){switch(o){case"disableReadReceipts":e.uint.encode(d,1);break;case"stripAttachmentMetadata":e.uint.encode(d,2);break;case"profileSnoozeTime":e.uint.encode(d,3);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"disableReadReceipts";case 2:return"stripAttachmentMetadata";case 3:return"profileSnoozeTime";default:return null}}},rt=$,it=e.frame(nt),at={preencode(e,d){rt.preencode(e,d.header),tt.preencode(e,d.key),it.preencode(e,d.settings)},encode(e,d){rt.encode(e,d.header),tt.encode(e,d.key),it.encode(e,d.settings)},decode:e=>({header:rt.decode(e),key:tt.decode(e),settings:it.decode(e)})},st={Flag:1},pt={preencode(e,d){e.end++},encode(d,o){if(o>1)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},ut={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),pt.preencode(d,o.label)},encode(d,o){e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),pt.encode(d,o.label)},decode:d=>({key:e.fixed32.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),label:pt.decode(d)})},lt=$,ft={preencode(d,o){lt.preencode(d,o.header),e.fixed32.preencode(d,o.key),pt.preencode(d,o.label)},encode(d,o){lt.encode(d,o.header),e.fixed32.encode(d,o.key),pt.encode(d,o.label)},decode:d=>({header:lt.decode(d),key:e.fixed32.decode(d),label:pt.decode(d)})},mt={preencode(d,o){pt.preencode(d,o.label),e.uint.preencode(d,o.count)},encode(d,o){pt.encode(d,o.label),e.uint.encode(d,o.count)},decode:d=>({label:pt.decode(d),count:e.uint.decode(d)})},yt=e.array(e.frame(mt)),bt={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.total),yt.preencode(d,o.labels),e.uint.preencode(d,o.editedAt),e.uint.preencode(d,o.flagsClock)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.total),yt.encode(d,o.labels),e.uint.encode(d,o.editedAt),e.uint.encode(d,o.flagsClock)},decode:d=>({key:e.fixed32.decode(d),total:e.uint.decode(d),labels:yt.decode(d),editedAt:e.uint.decode(d),flagsClock:e.uint.decode(d)})},xt={preencode(d,o){e.float64.preencode(d,o.latitude),e.float64.preencode(d,o.longitude)},encode(d,o){e.float64.encode(d,o.latitude),e.float64.encode(d,o.longitude)},decode:d=>({latitude:e.float64.decode(d),longitude:e.float64.decode(d)})},kt=$,vt={preencode(d,o){kt.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.fromDeviceKey)},encode(d,o){kt.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.fromDeviceKey)},decode:d=>({header:kt.decode(d),deviceKey:e.fixed32.decode(d),fromDeviceKey:e.fixed32.decode(d)})},gt=$,ht=X,Kt={preencode(o,n){gt.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),e.buffer.preencode(o,n.encryptionKey),o.end++,d>=19&&n.streams&&ht.preencode(o,n.streams),d>=19&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=19&&n.version&&e.uint.preencode(o,n.version),d>=26&&n.streamInputs&&ei.preencode(o,n.streamInputs),d>=26&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey)},encode(o,n){const c=(d>=19&&n.streams?1:0)|(d>=19&&n.discoveryKey?2:0)|(d>=19&&n.version?4:0)|(d>=26&&n.streamInputs?8:0)|(d>=26&&n.swarmKey?16:0);gt.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,c),d>=19&&n.streams&&ht.encode(o,n.streams),d>=19&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=19&&n.version&&e.uint.encode(o,n.version),d>=26&&n.streamInputs&&ei.encode(o,n.streamInputs),d>=26&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey)},decode(o){const n=gt.decode(o),c=e.fixed32.decode(o),t=e.buffer.decode(o),r=e.uint.decode(o);return{header:n,callKey:c,encryptionKey:t,streams:d>=19&&1&r?ht.decode(o):null,discoveryKey:d>=19&&2&r?e.fixed32.decode(o):null,version:d>=19&&4&r?e.uint.decode(o):0,streamInputs:d>=26&&8&r?ei.decode(o):null,swarmKey:d>=26&&16&r?e.fixed32.decode(o):null}}},wt=$,Tt=X,At={preencode(o,n){wt.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),o.end++,d>=19&&n.streams&&Tt.preencode(o,n.streams),d>=26&&n.streamInputs&&di.preencode(o,n.streamInputs),d>=26&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey)},encode(o,n){const c=(d>=19&&n.streams?1:0)|(d>=26&&n.streamInputs?2:0)|(d>=26&&n.swarmKey?4:0);wt.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.uint.encode(o,c),d>=19&&n.streams&&Tt.encode(o,n.streams),d>=26&&n.streamInputs&&di.encode(o,n.streamInputs),d>=26&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey)},decode(o){const n=wt.decode(o),c=e.fixed32.decode(o),t=e.uint.decode(o);return{header:n,callKey:c,streams:d>=19&&1&t?Tt.decode(o):null,streamInputs:d>=26&&2&t?di.decode(o):null,swarmKey:d>=26&&4&t?e.fixed32.decode(o):null}}},Pt=$,St={preencode(d,o){Pt.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Pt.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Pt.decode(d),callKey:e.fixed32.decode(d)})},It=$,Rt={preencode(d,o){It.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){It.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:It.decode(d),callKey:e.fixed32.decode(d)})},Ft=$,Ht={preencode(o,n){Ft.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.streamKey),o.end++,d>=26&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=26&&n.type&&e.string.preencode(o,n.type)},encode(o,n){const c=(d>=26&&n.mediaStreamId?1:0)|(d>=26&&n.type?2:0)|(d>=26&&n.muted?4:0);Ft.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.streamKey),e.uint.encode(o,c),d>=26&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=26&&n.type&&e.string.encode(o,n.type)},decode(o){const n=Ft.decode(o),c=e.fixed32.decode(o),t=e.fixed32.decode(o),r=o.start<o.end?e.uint.decode(o):0;return{header:n,callKey:c,streamKey:t,mediaStreamId:d>=26&&1&r?e.string.decode(o):null,type:d>=26&&2&r?e.string.decode(o):null,muted:d>=26&&!!(4&r)}}},Mt=$,Ct={preencode(d,o){Mt.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.streamKey)},encode(d,o){Mt.encode(d,o.header),e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.streamKey)},decode:d=>({header:Mt.decode(d),callKey:e.fixed32.decode(d),streamKey:e.fixed32.decode(d)})},Dt={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.buffer.preencode(o,n.encryptionKey),e.uint.preencode(o,n.createdAt),o.end++,d>=19&&n.endedAt&&e.uint.preencode(o,n.endedAt),d>=19&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=19&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(d>=19&&n.endedAt?1:0)|(d>=19&&n.discoveryKey?2:0)|(d>=19&&n.version?4:0);e.fixed32.encode(o,n.callKey),e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=19&&n.endedAt&&e.uint.encode(o,n.endedAt),d>=19&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=19&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=e.fixed32.decode(o),c=e.buffer.decode(o),t=e.uint.decode(o),r=e.uint.decode(o);return{callKey:n,encryptionKey:c,createdAt:t,endedAt:d>=19&&1&r?e.uint.decode(o):0,discoveryKey:d>=19&&2&r?e.fixed32.decode(o):null,version:d>=19&&4&r?e.uint.decode(o):0}}},Vt={preencode(d,o){e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.createdAt)},encode(d,o){e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.createdAt)},decode:d=>({callKey:e.fixed32.decode(d),memberKey:e.fixed32.decode(d),createdAt:e.uint.decode(d)})},Lt={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.deviceKey),e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.createdAt),o.end++,d>=19&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),d>=22&&n.lastHeartbeatAt&&e.uint.preencode(o,n.lastHeartbeatAt)},encode(o,n){const c=(d>=19&&n.swarmKey?1:0)|(d>=22&&n.lastHeartbeatAt?2:0)|(d>=23&&n.isRecording?4:0);e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.deviceKey),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=19&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey),d>=22&&n.lastHeartbeatAt&&e.uint.encode(o,n.lastHeartbeatAt)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=e.fixed32.decode(o),r=e.uint.decode(o),i=e.uint.decode(o);return{callKey:n,deviceKey:c,memberKey:t,createdAt:r,swarmKey:d>=19&&1&i?e.fixed32.decode(o):null,lastHeartbeatAt:d>=22&&2&i?e.uint.decode(o):0,isRecording:d>=23&&!!(4&i)}}},qt={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.deviceKey),e.buffer.preencode(o,n.streamKey),e.uint.preencode(o,n.createdAt),o.end++,d>=26&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=26&&n.type&&e.string.preencode(o,n.type),d>=26&&n.statusKey&&e.uint.preencode(o,n.statusKey)},encode(o,n){const c=(d>=26&&n.mediaStreamId?1:0)|(d>=26&&n.type?2:0)|(d>=26&&n.statusKey?4:0);e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.deviceKey),e.buffer.encode(o,n.streamKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=26&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=26&&n.type&&e.string.encode(o,n.type),d>=26&&n.statusKey&&e.uint.encode(o,n.statusKey)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=e.buffer.decode(o),r=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{callKey:n,deviceKey:c,streamKey:t,createdAt:r,mediaStreamId:d>=26&&1&i?e.string.decode(o):null,type:d>=26&&2&i?e.string.decode(o):null,statusKey:d>=26&&4&i?e.uint.decode(o):0}}},Et={Nightly:"Nightly",Internal:"Internal",Production:"Production"},Bt={preencode(e,d){e.end++},encode(d,o){switch(o){case"Nightly":e.uint.encode(d,1);break;case"Internal":e.uint.encode(d,2);break;case"Production":e.uint.encode(d,3);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"Nightly";case 2:return"Internal";case 3:return"Production";default:return null}}},zt=$,Nt={preencode(e,d){zt.preencode(e,d.header)},encode(e,d){zt.encode(e,d.header)},decode:e=>({header:zt.decode(e)})},jt=$,Ot={preencode(e,d){jt.preencode(e,d.header)},encode(e,d){jt.encode(e,d.header)},decode:e=>({header:jt.decode(e)})},Ut=$,Jt={preencode(d,o){Ut.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),e.buffer.preencode(d,o.deviceProof),e.buffer.preencode(d,o.writerProof)},encode(d,o){Ut.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.buffer.encode(d,o.deviceProof),e.buffer.encode(d,o.writerProof)},decode:d=>({header:Ut.decode(d),deviceKey:e.fixed32.decode(d),deviceProof:e.buffer.decode(d),writerProof:e.buffer.decode(d)})},Gt=$,Qt={preencode(d,o){Gt.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Gt.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Gt.decode(d),callKey:e.fixed32.decode(d)})},Wt=$,Xt={preencode(d,o){Wt.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.deviceKey)},encode(d,o){Wt.encode(d,o.header),e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.deviceKey)},decode:d=>({header:Wt.decode(d),callKey:e.fixed32.decode(d),deviceKey:e.fixed32.decode(d)})},Yt=$,Zt={preencode(d,o){Yt.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Yt.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Yt.decode(d),callKey:e.fixed32.decode(d)})},$t=$,_t={preencode(d,o){$t.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){$t.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:$t.decode(d),callKey:e.fixed32.decode(d)})},er=$,dr={preencode(e,d){er.preencode(e,d.header),n.preencode(e,d.oplog)},encode(e,d){er.encode(e,d.header),n.encode(e,d.oplog)},decode:e=>({header:er.decode(e),oplog:n.decode(e)})},or=$,nr={preencode(e,d){or.preencode(e,d.header)},encode(e,d){or.encode(e,d.header)},decode:e=>({header:or.decode(e)})},cr={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.timestamp)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.timestamp)},decode:d=>({memberKey:e.fixed32.decode(d),timestamp:e.uint.decode(d)})},tr=$,rr={preencode(o,n){tr.preencode(o,n.header),e.fixed32.preencode(o,n.memberKey),o.end++,d>=24&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=d>=24&&n.alias?1:0;tr.encode(o,n.header),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,c),d>=24&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=tr.decode(o),c=e.fixed32.decode(o),t=e.uint.decode(o);return{header:n,memberKey:c,alias:d>=24&&1&t?e.string.decode(o):null}}},ir={preencode(d,o){e.uint.preencode(d,o.streams)},encode(d,o){e.uint.encode(d,o.streams)},decode:d=>({streams:e.uint.decode(d)})},ar={preencode(d,o){e.fixed32.preencode(d,o.streamKey),e.string.preencode(d,o.mediaStreamId),e.string.preencode(d,o.type),d.end++},encode(o,n){const c=d>=26&&n.muted?1:0;e.fixed32.encode(o,n.streamKey),e.string.encode(o,n.mediaStreamId),e.string.encode(o,n.type),e.uint.encode(o,c)},decode(o){const n=e.fixed32.decode(o),c=e.string.decode(o),t=e.string.decode(o),r=e.uint.decode(o);return{streamKey:n,mediaStreamId:c,type:t,muted:d>=26&&!!(1&r)}}},sr=$,pr={preencode(d,o){sr.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.streamKey),d.end++},encode(o,n){const c=d>=26&&n.muted?1:0;sr.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.streamKey),e.uint.encode(o,c)},decode(o){const n=sr.decode(o),c=e.fixed32.decode(o),t=e.fixed32.decode(o),r=e.uint.decode(o);return{header:n,callKey:c,streamKey:t,muted:d>=26&&!!(1&r)}}},ur={preencode(d,o){e.uint.preencode(d,o.statusKey),d.end++},encode(o,n){const c=d>=26&&n.muted?1:0;e.uint.encode(o,n.statusKey),e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o),c=e.uint.decode(o);return{statusKey:n,muted:d>=26&&!!(1&c)}}},lr={preencode(n,c){e.fixed32.preencode(n,c.key),n.end++,d>=27&&c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const t=(d>=27&&c.encryptionKey?1:0)|(d>=27&&c.bootFrom?2:0);e.fixed32.encode(n,c.key),e.uint.encode(n,t),d>=27&&c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),t=e.uint.decode(n);return{key:c,encryptionKey:d>=27&&1&t?e.buffer.decode(n):null,bootFrom:d>=27&&2&t?o.decode(n):null}}},fr={preencode(d,o){e.fixed32.preencode(d,o.hash)},encode(d,o){e.fixed32.encode(d,o.hash)},decode:d=>({hash:e.fixed32.decode(d)})},mr={preencode(d,o){e.fixed32.preencode(d,o.hash),e.buffer.preencode(d,o.data)},encode(d,o){e.fixed32.encode(d,o.hash),e.buffer.encode(d,o.data)},decode:d=>({hash:e.fixed32.decode(d),data:e.buffer.decode(d)})},yr={preencode(n,c){o.preencode(n,c.autobeeMigrationHead),n.end++,d>=27&&c.legacyViewHead&&o.preencode(n,c.legacyViewHead),d>=27&&c.dbViewHead&&o.preencode(n,c.dbViewHead),d>=27&&c.blobsViewHead&&o.preencode(n,c.blobsViewHead),e.uint.preencode(n,c.createdAt)},encode(n,c){const t=(d>=27&&c.legacyViewHead?1:0)|(d>=27&&c.dbViewHead?2:0)|(d>=27&&c.blobsViewHead?4:0);o.encode(n,c.autobeeMigrationHead),e.uint.encode(n,t),d>=27&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=27&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=27&&c.blobsViewHead&&o.encode(n,c.blobsViewHead),e.uint.encode(n,c.createdAt)},decode(n){const c=o.decode(n),t=e.uint.decode(n);return{autobeeMigrationHead:c,legacyViewHead:d>=27&&1&t?o.decode(n):null,dbViewHead:d>=27&&2&t?o.decode(n):null,blobsViewHead:d>=27&&4&t?o.decode(n):null,createdAt:e.uint.decode(n)}}},br=$,xr={preencode(e,n){br.preencode(e,n.header),o.preencode(e,n.head),e.end++,d>=27&&n.legacyViewHead&&o.preencode(e,n.legacyViewHead),d>=27&&n.dbViewHead&&o.preencode(e,n.dbViewHead),d>=27&&n.blobsViewHead&&o.preencode(e,n.blobsViewHead)},encode(n,c){const t=(d>=27&&c.legacyViewHead?1:0)|(d>=27&&c.dbViewHead?2:0)|(d>=27&&c.blobsViewHead?4:0);br.encode(n,c.header),o.encode(n,c.head),e.uint.encode(n,t),d>=27&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=27&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=27&&c.blobsViewHead&&o.encode(n,c.blobsViewHead)},decode(n){const c=br.decode(n),t=o.decode(n),r=e.uint.decode(n);return{header:c,head:t,legacyViewHead:d>=27&&1&r?o.decode(n):null,dbViewHead:d>=27&&2&r?o.decode(n):null,blobsViewHead:d>=27&&4&r?o.decode(n):null}}},kr={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.fixed32.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.seed),n.end++,d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const t=d>=27&&c.bootFrom?1:0;e.fixed32.encode(n,c.roomKey),e.fixed32.encode(n,c.encryptionKey),e.fixed32.encode(n,c.seed),e.uint.encode(n,t),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),t=e.fixed32.decode(n),r=e.fixed32.decode(n),i=e.uint.decode(n);return{roomKey:c,encryptionKey:t,seed:r,bootFrom:d>=27&&1&i?o.decode(n):null}}},vr=id,gr={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.fixed32.preencode(d,o.deviceKey),e.uint.preencode(d,o.deviceLength),e.uint.preencode(d,o.clock),vr.preencode(d,o.status)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,o.deviceLength),e.uint.encode(d,o.clock),vr.encode(d,o.status)},decode:d=>({memberKey:e.fixed32.decode(d),deviceKey:e.fixed32.decode(d),deviceLength:e.uint.decode(d),clock:e.uint.decode(d),status:vr.decode(d)})},hr={preencode(d,o){e.fixed32.preencode(d,o.hash),e.buffer.preencode(d,o.blob)},encode(d,o){e.fixed32.encode(d,o.hash),e.buffer.encode(d,o.blob)},decode:d=>({hash:e.fixed32.decode(d),blob:e.buffer.decode(d)})},Kr=Fn,wr=Hn,Tr=vn,Ar={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),Kr.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,d>=27&&c.initiator&&o.preencode(n,c.initiator),d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=27&&c.identitySwap&&wr.preencode(n,c.identitySwap),d>=27&&c.identitySwapV2&&Tr.preencode(n,c.identitySwapV2),d>=27&&c.contact&&e.fixed32.preencode(n,c.contact)},encode(n,c){const t=(d>=27&&c.initiator?1:0)|(d>=27&&c.bootFrom?2:0)|(d>=27&&c.identitySwap?4:0)|(d>=27&&c.identitySwapV2?8:0)|(d>=27&&c.contact?16:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),Kr.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,t),d>=27&&c.initiator&&o.encode(n,c.initiator),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom),d>=27&&c.identitySwap&&wr.encode(n,c.identitySwap),d>=27&&c.identitySwapV2&&Tr.encode(n,c.identitySwapV2),d>=27&&c.contact&&e.fixed32.encode(n,c.contact)},decode(n){const c=e.fixed32.decode(n),t=e.buffer.decode(n),r=e.fixed32.decode(n),i=Kr.decode(n),a=e.uint.decode(n),s=e.uint.decode(n);return{roomKey:c,encryptionKey:t,mailbox:r,status:i,clock:a,initiator:d>=27&&1&s?o.decode(n):null,bootFrom:d>=27&&2&s?o.decode(n):null,identitySwap:d>=27&&4&s?wr.decode(n):null,identitySwapV2:d>=27&&8&s?Tr.decode(n):null,contact:d>=27&&16&s?e.fixed32.decode(n):null}}},Pr=$,Sr={preencode(n,c){Pr.preencode(n,c.header),e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),n.end++,d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=27&&c.initiator&&o.preencode(n,c.initiator),d>=27&&c.dm&&e.fixed32.preencode(n,c.dm)},encode(n,c){const t=(d>=27&&c.bootFrom?1:0)|(d>=27&&c.initiator?2:0)|(d>=27&&c.dm?4:0)|(d>=27&&c.isReadOnly?8:0);Pr.encode(n,c.header),e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),e.uint.encode(n,t),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom),d>=27&&c.initiator&&o.encode(n,c.initiator),d>=27&&c.dm&&e.fixed32.encode(n,c.dm)},decode(n){const c=Pr.decode(n),t=e.fixed32.decode(n),r=e.buffer.decode(n),i=e.fixed32.decode(n),a=e.uint.decode(n);return{header:c,roomKey:t,encryptionKey:r,mailbox:i,bootFrom:d>=27&&1&a?o.decode(n):null,initiator:d>=27&&2&a?o.decode(n):null,dm:d>=27&&4&a?e.fixed32.decode(n):null,isReadOnly:d>=27&&!!(8&a)}}},Ir={preencode(d,o){e.fixed32.preencode(d,o.id),e.fixed32.preencode(d,o.writerKey),e.buffer.preencode(d,o.blindResponse)},encode(d,o){e.fixed32.encode(d,o.id),e.fixed32.encode(d,o.writerKey),e.buffer.encode(d,o.blindResponse)},decode:d=>({id:e.fixed32.decode(d),writerKey:e.fixed32.decode(d),blindResponse:e.buffer.decode(d)})},Rr=$,Fr={preencode(d,o){Rr.preencode(d,o.header),e.buffer.preencode(d,o.blindResponse)},encode(d,o){Rr.encode(d,o.header),e.buffer.encode(d,o.blindResponse)},decode:d=>({header:Rr.decode(d),blindResponse:e.buffer.decode(d)})},Hr=e.frame(w),Mr=e.frame(ir),Cr=Hr,Dr=e.array(Vc),Vr=e.frame(se),Lr=Hr,qr=Vr,Er=e.frame(hc),Br=e.frame(kr),zr=Vr,Nr=e.frame(fd),jr=e.frame(yc),Or=e.frame(xt),Ur=Or,Jr=e.array(e.frame(qc)),Gr=Hr,Qr=e.frame(Nn),Wr=e.frame(xc),Xr=Qr,Yr=Wr,Zr=Qr,$r=Wr,_r=Hr,ei=e.array(e.frame(ar)),di=ei;function oi(e){switch(e){case"@keet/head":return o;case"@keet/oplog-id":return n;case"@keet/encryption-keypair":return c;case"@keet/signing-keypair":return t;case"@keet/room-keys":return r;case"@keet/operation-header":return i;case"@keet/blob-pointer":return a;case"@keet/file-dimensions":return s;case"@keet/file-metadata":return u;case"@keet/external-drive-pointer":return l;case"@keet/external-blob-pointer":return f;case"@keet/file-pointer":return b;case"@keet/file":return v;case"@keet/image-file":return w;case"@keet/file-status":return T;case"@keet/file-record":return S;case"@keet/device-status":return I;case"@keet/member-status":return R;case"@keet/member-moderation-status":return F;case"@keet/abi":return H;case"@keet/device-stats":return M;case"@keet/member-stats":return C;case"@keet/chat-stats":return D;case"@keet/file-stats":return V;case"@keet/stats":return z;case"@keet/room-type":return j;case"@keet/system-settings":return O;case"@keet/system-digest":return G;case"@keet/room-seed":return Q;case"@keet/room-capabilities":return W;case"@keet/room-config":return Y;case"@keet/blind-peer":return Z;case"@keet/add-blind-peer-operation":return ee;case"@keet/remove-blind-peer-operation":return oe;case"@keet/identity-attestation":return ne;case"@keet/device-invitation":return ce;case"@keet/device":return ie;case"@keet/member-profile":return ae;case"@keet/device-profile":return se;case"@keet/member-update":return ue;case"@keet/device-update":return le;case"@keet/signed-pairing-data":return fe;case"@keet/device-request-identity":return me;case"@keet/device-response-identity":return ye;case"@keet/device-request-with-invitation":return ve;case"@keet/device-request-with-invitation-and-proof":return he;case"@keet/device-request-with-member-proof":return Te;case"@keet/device-request":return Se;case"@keet/device-response":return Fe;case"@keet/invitation-metadata":return He;case"@keet/invitation":return De;case"@keet/add-invitation-operation":return qe;case"@keet/remove-invitation-operation":return Be;case"@keet/sendable-room-invitation":return ze;case"@keet/sendable-identity-invitation":return Ne;case"@keet/sendable-contact-invitation":return je;case"@keet/sendable-invitation":return Qe;case"@keet/add-device-operation":return Xe;case"@keet/update-device-operation":return Ze;case"@keet/start-indexing-operation":return $e;case"@keet/stop-indexing-operation":return _e;case"@keet/join-request":return dd;case"@keet/accept-join-request-operation":return cd;case"@keet/reject-join-request-operation":return rd;case"@keet/member":return sd;case"@keet/full-member":return ld;case"@keet/member-proofs":return fd;case"@keet/update-member-operation":return bd;case"@keet/change-member-status-operation":return vd;case"@keet/change-member-role-operation":return hd;case"@keet/remove-member-operation":return wd;case"@keet/member-activity":return Td;case"@keet/member-joined-event":return Ad;case"@keet/member-left-event":return Pd;case"@keet/title-changed-chat-event":return Sd;case"@keet/chat-event":return Hd;case"@keet/sendable-event":return Md;case"@keet/display-range":return Cd;case"@keet/display-content-range":return Vd;case"@keet/mention-display-item":return qd;case"@keet/link-preview":return zd;case"@keet/display-link-item":return Od;case"@keet/display":return _d;case"@keet/oplog-message":return co;case"@keet/index-message":return io;case"@keet/full-index-message":return po;case"@keet/message-status":return uo;case"@keet/message-index-id":return lo;case"@keet/thread":return mo;case"@keet/chat-message-record":return ko;case"@keet/full-chat-message-record":return Ko;case"@keet/add-chat-message-operation":return Ao;case"@keet/remove-chat-message-operation":return So;case"@keet/update-chat-message-operation":return Fo;case"@keet/pin-chat-message-operation":return Mo;case"@keet/reaction":return Co;case"@keet/reactions-summary":return Do;case"@keet/reactions-digest":return Lo;case"@keet/add-reaction-operation":return Eo;case"@keet/remove-reaction-operation":return zo;case"@keet/update-room-config-operation":return Oo;case"@keet/group-member":return Uo;case"@keet/user-registry-info":return Jo;case"@keet/room-identity":return Qo;case"@keet/genesis-operation":return dn;case"@keet/upgrade-operation":return nn;case"@keet/update-system-settings-operation":return rn;case"@keet-private-id/contact":return an;case"@keet-private-id/v3-room-migration-info":return sn;case"@keet-private-id/run-v3-migration-operation":return ln;case"@keet-private-id/update-identity-operation":return mn;case"@keet-private-id/counters":return yn;case"@keet-private-id/stats":return bn;case"@keet-private-id/add-entropy-operation":return xn;case"@keet-private-id/pending-invitation-identity":return kn;case"@keet-private-id/pending-invitation":return gn;case"@keet-private-id/resolve-pending-invitation-operation":return Kn;case"@keet-private-id/add-pending-invitation-operation":return An;case"@keet-private-id/remove-pending-invitation-operation":return Sn;case"@keet-private-id/identity-swap":return In;case"@keet-private-id/room-status":return Rn;case"@keet-private-id/room":return Cn;case"@keet-private-id/add-room-operation":return Vn;case"@keet-private-id/remove-room-operation":return qn;case"@keet-private-id/update-room-status-operation":return zn;case"@keet-private-id/contact-status":return Nn;case"@keet-private-id/contact-record":return jn;case"@keet-private-id/add-contact-operation":return Jn;case"@keet-private-id/update-contact-status-operation":return Qn;case"@keet-private-id/remove-contact-operation":return Xn;case"@keet-private-id/contact-request-status":return Yn;case"@keet-private-id/contact-request-body":return _n;case"@keet-private-id/contact-request":return dc;case"@keet-private-id/contact-request-record":return tc;case"@keet-private-id/add-contact-request-operation":return ic;case"@keet-private-id/update-contact-request-status-operation":return pc;case"@keet-private-id/profile-discovery-record-v1":return uc;case"@keet-private-id/profile-discovery-record":return lc;case"@keet/add-file-preview-operation":return mc;case"@keet/member-removed-event":return yc;case"@keet/member-contact-info":return xc;case"@keet/remove-device-operation":return vc;case"@keet/device-identity":return gc;case"@keet/readonly-room-invitation":return hc;case"@keet-private-id/identity-swap-v2":return Kc;case"@keet-private-id/activate-contact-room-operation":return Tc;case"@keet/display-type":return Pc;case"@keet/test-increment-operation":return Ic;case"@keet/test-collection-record-1":return Rc;case"@keet/migrate-abi-operation":return Hc;case"@keet/system-settings-keys":return Cc;case"@keet/room-supported-language":return Vc;case"@keet/translation-display-item":return qc;case"@keet-private-id/unreads":return Ec;case"@keet-private-id/add-unreads-key-operation":return zc;case"@keet-private-id/remove-unreads-key-operation":return jc;case"@keet/label-type":return Uc;case"@keet/chat-label":return Jc;case"@keet/add-chat-label-operation":return Qc;case"@keet/remove-chat-label-operation":return Xc;case"@keet/chat-label-summary":return Yc;case"@keet/chat-label-digest":return $c;case"@keet/update-read-length-operation":return et;case"@keet/read-length":return dt;case"@keet/tmp-removed-member":return ot;case"@keet-private-id/settings":return nt;case"@keet-private-id/user-settings-key":return tt;case"@keet-private-id/update-settings-operation":return at;case"@keet/member-label-type":return pt;case"@keet/member-label":return ut;case"@keet/add-member-label-operation":return ft;case"@keet/member-label-summary":return mt;case"@keet/member-label-digest":return bt;case"@keet/location-shared-event":return xt;case"@keet/move-indexer-operation":return vt;case"@keet/start-call":return Kt;case"@keet/join-call":return At;case"@keet/leave-call":return St;case"@keet/end-call":return Rt;case"@keet/add-call-stream":return Ht;case"@keet/remove-call-stream":return Ct;case"@keet/call-record":return Dt;case"@keet/call-member-record":return Vt;case"@keet/call-device-record":return Lt;case"@keet/call-stream-record":return qt;case"@keet/build-type":return Bt;case"@keet/test-crash-operation":return Nt;case"@keet/test-dispatch-error-operation":return Ot;case"@keet-private-id/shorten-device-attestation-operation":return Jt;case"@keet/call-device-heartbeat":return Qt;case"@keet/remove-call-device":return Xt;case"@keet/start-call-recording":return Zt;case"@keet/stop-call-recording":return _t;case"@keet/dismiss-chat-reports-operation":return dr;case"@keet/update-typing-indicator-operation":return nr;case"@keet/typing-indicator":return cr;case"@keet-private-id/update-contact-alias-operation":return rr;case"@keet/call-stats":return ir;case"@keet/call-stream-input":return ar;case"@keet/update-call-stream":return pr;case"@keet/call-stream-status-record":return ur;case"@keet/room-keys-v2":return lr;case"@keet/blob-pointer-v2":return fr;case"@keet/blob":return mr;case"@keet/autobee-migration":return yr;case"@keet/autobee-migration-operation":return xr;case"@keet/readonly-room-invitation-v2":return kr;case"@keet/admin-last-seen":return gr;case"@keet/blob-record":return hr;case"@keet-private-id/room-v2":return Ar;case"@keet-private-id/add-room-operation-v2":return Sr;case"@keet-private-id/pending-invitation-response":return Ir;case"@keet-private-id/resolve-pending-invitation-operation-v2":return Fr;default:throw new Error("Encoder not found "+e)}}function ni(e,o=29){const n=oi(e);return{preencode(e,c){d=o,n.preencode(e,c)},encode(e,c){d=o,n.encode(e,c)},decode:e=>(d=o,n.decode(e))}}const ci=ni;module.exports={resolveStruct:ci,getStruct:ni,getEnum:function(e){switch(e){case"@keet/room-type":return N;case"@keet/display-type":return Ac;case"@keet/system-settings-keys":return Mc;case"@keet/room-supported-language":return Dc;case"@keet/label-type":return Oc;case"@keet-private-id/user-settings-key":return ct;case"@keet/member-label-type":return st;case"@keet/build-type":return Et;default:throw new Error("Enum not found "+e)}},getEncoding:oi,encode:function(o,n,c=29){return d=c,e.encode(oi(o),n)},decode:function(o,n,c=29){return d=c,e.decode(oi(o),n)},setVersion:function(e){d=e},version:d};
1const{c:e}=require("hyperschema/runtime");let d=31;const o={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.length)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.length)},decode:d=>({key:e.fixed32.decode(d),length:e.uint.decode(d)})},n={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.seq)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.seq)},decode:d=>({key:e.fixed32.decode(d),seq:e.uint.decode(d)})},c={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.secretKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.secretKey)},decode:d=>({publicKey:e.fixed32.decode(d),secretKey:e.fixed32.decode(d)})},r={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed64.preencode(d,o.secretKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed64.encode(d,o.secretKey)},decode:d=>({publicKey:e.fixed32.decode(d),secretKey:e.fixed64.decode(d)})},t={preencode(n,c){e.fixed32.preencode(n,c.key),n.end++,c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=(c.encryptionKey?1:0)|(c.fastForwardTo?2:0)|(d>=27&&c.bootFrom?4:0);e.fixed32.encode(n,c.key),e.uint.encode(n,r),c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.uint.decode(n);return{key:c,encryptionKey:1&r?e.buffer.decode(n):null,fastForwardTo:2&r?e.fixed32.decode(n):null,bootFrom:d>=27&&4&r?o.decode(n):null}}},i={preencode(d,o){e.uint.preencode(d,o.timestamp)},encode(d,o){e.uint.encode(d,o.timestamp)},decode:d=>({timestamp:e.uint.decode(d)})},a={preencode(d,o){e.uint.preencode(d,o.blockOffset),e.uint.preencode(d,o.blockLength),e.uint.preencode(d,o.byteOffset),e.uint.preencode(d,o.byteLength)},encode(d,o){e.uint.encode(d,o.blockOffset),e.uint.encode(d,o.blockLength),e.uint.encode(d,o.byteOffset),e.uint.encode(d,o.byteLength)},decode:d=>({blockOffset:e.uint.decode(d),blockLength:e.uint.decode(d),byteOffset:e.uint.decode(d),byteLength:e.uint.decode(d)})},s={preencode(d,o){e.uint.preencode(d,o.width),e.uint.preencode(d,o.height)},encode(d,o){e.uint.encode(d,o.width),e.uint.encode(d,o.height)},decode:d=>({width:e.uint.decode(d),height:e.uint.decode(d)})},p=e.frame(s),u={preencode(d,o){d.end++,o.name&&e.string.preencode(d,o.name),o.mimetype&&e.string.preencode(d,o.mimetype),o.dimensions&&p.preencode(d,o.dimensions),o.userdata&&e.buffer.preencode(d,o.userdata),o.duration&&e.uint.preencode(d,o.duration)},encode(d,o){const n=(o.name?1:0)|(o.mimetype?2:0)|(o.dimensions?4:0)|(o.userdata?8:0)|(o.duration?16:0)|(o.isPreview?32:0);e.uint.encode(d,n),o.name&&e.string.encode(d,o.name),o.mimetype&&e.string.encode(d,o.mimetype),o.dimensions&&p.encode(d,o.dimensions),o.userdata&&e.buffer.encode(d,o.userdata),o.duration&&e.uint.encode(d,o.duration)},decode(d){const o=e.uint.decode(d);return{name:1&o?e.string.decode(d):null,mimetype:2&o?e.string.decode(d):null,dimensions:4&o?p.decode(d):null,userdata:8&o?e.buffer.decode(d):null,duration:16&o?e.uint.decode(d):0,isPreview:!!(32&o)}}},l={preencode(d,o){e.fixed32.preencode(d,o.key),e.string.preencode(d,o.path),e.uint.preencode(d,o.version),e.uint.preencode(d,o.size)},encode(d,o){e.fixed32.encode(d,o.key),e.string.encode(d,o.path),e.uint.encode(d,o.version),e.uint.encode(d,o.size)},decode:d=>({key:e.fixed32.decode(d),path:e.string.decode(d),version:e.uint.decode(d),size:e.uint.decode(d)})},f={preencode(d,o){e.fixed32.preencode(d,o.key),a.preencode(d,o.blob)},encode(d,o){e.fixed32.encode(d,o.key),a.encode(d,o.blob)},decode:d=>({key:e.fixed32.decode(d),blob:a.decode(d)})},m=e.frame(f),y=e.frame(l),b={preencode(o,n){o.end++,n.inlined&&e.buffer.preencode(o,n.inlined),n.blob&&a.preencode(o,n.blob),n.externalBlob&&m.preencode(o,n.externalBlob),n.externalDrive&&y.preencode(o,n.externalDrive),d>=27&&n.bee&&ft.preencode(o,n.bee)},encode(o,n){const c=(n.inlined?1:0)|(n.blob?2:0)|(n.externalBlob?4:0)|(n.externalDrive?8:0)|(d>=27&&n.bee?16:0);e.uint.encode(o,c),n.inlined&&e.buffer.encode(o,n.inlined),n.blob&&a.encode(o,n.blob),n.externalBlob&&m.encode(o,n.externalBlob),n.externalDrive&&y.encode(o,n.externalDrive),d>=27&&n.bee&&ft.encode(o,n.bee)},decode(o){const n=e.uint.decode(o);return{inlined:1&n?e.buffer.decode(o):null,blob:2&n?a.decode(o):null,externalBlob:4&n?m.decode(o):null,externalDrive:8&n?y.decode(o):null,bee:d>=27&&16&n?ft.decode(o):null}}},x=e.frame(b),k=e.frame(u),v={preencode(d,o){x.preencode(d,o.pointer),d.end++,o.metadata&&k.preencode(d,o.metadata),o.preview&&zt.preencode(d,o.preview),o.hash&&e.fixed32.preencode(d,o.hash)},encode(d,o){const n=(o.metadata?1:0)|(o.preview?2:0)|(o.hash?4:0);x.encode(d,o.pointer),e.uint.encode(d,n),o.metadata&&k.encode(d,o.metadata),o.preview&&zt.encode(d,o.preview),o.hash&&e.fixed32.encode(d,o.hash)},decode(d){const o=x.decode(d),n=e.uint.decode(d);return{pointer:o,metadata:1&n?k.decode(d):null,preview:2&n?zt.decode(d):null,hash:4&n?e.fixed32.decode(d):null}}},g=e.frame(v),h=g,K=g,w={preencode(e,d){e.end++,d.small&&g.preencode(e,d.small),d.medium&&h.preencode(e,d.medium),d.large&&K.preencode(e,d.large)},encode(d,o){const n=(o.small?1:0)|(o.medium?2:0)|(o.large?4:0);e.uint.encode(d,n),o.small&&g.encode(d,o.small),o.medium&&h.encode(d,o.medium),o.large&&K.encode(d,o.large)},decode(d){const o=e.uint.decode(d);return{small:1&o?g.decode(d):null,medium:2&o?h.decode(d):null,large:4&o?K.decode(d):null}}},T={preencode(e,d){e.end++},encode(d,o){const n=o.isDeleted?1:0;e.uint.encode(d,n)},decode:d=>({isDeleted:!!(1&e.uint.decode(d))})},A=e.frame(T),P=g,S={preencode(o,c){e.uint.preencode(o,c.id),n.preencode(o,c.oplog),A.preencode(o,c.status),P.preencode(o,c.file),o.end++,d>=14&&c.version&&e.uint.preencode(o,c.version)},encode(o,c){const r=d>=14&&c.version?1:0;e.uint.encode(o,c.id),n.encode(o,c.oplog),A.encode(o,c.status),P.encode(o,c.file),e.uint.encode(o,r),d>=14&&c.version&&e.uint.encode(o,c.version)},decode(o){const c=e.uint.decode(o),r=n.decode(o),t=A.decode(o),i=P.decode(o),a=o.start<o.end?e.uint.decode(o):0;return{id:c,oplog:r,status:t,file:i,version:d>=14&&1&a?e.uint.decode(o):0}}},I={preencode(e,d){e.end++},encode(d,o){const n=(o.isActive?1:0)|(o.isIndexing?2:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isActive:!!(1&o),isIndexing:!!(2&o)}}},R={preencode(o,n){const c=(n.isAdmin?1:0)|(n.isModerator?2:0)|(n.isPending?4:0)|(n.isActive?8:0)|(n.isMuted?16:0)|(n.isBanned?32:0)|(n.isShadowBanned?64:0)|(d>=13&&n.isRemoved?128:0);e.uint.preencode(o,c)},encode(o,n){const c=(n.isAdmin?1:0)|(n.isModerator?2:0)|(n.isPending?4:0)|(n.isActive?8:0)|(n.isMuted?16:0)|(n.isBanned?32:0)|(n.isShadowBanned?64:0)|(d>=13&&n.isRemoved?128:0);e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{isAdmin:!!(1&n),isModerator:!!(2&n),isPending:!!(4&n),isActive:!!(8&n),isMuted:!!(16&n),isBanned:!!(32&n),isShadowBanned:!!(64&n),isRemoved:d>=13&&!!(128&n)}}},F={preencode(e,d){e.end++},encode(d,o){const n=(o.isMuted?1:0)|(o.isBanned?2:0)|(o.isShadowBanned?4:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isMuted:!!(1&o),isBanned:!!(2&o),isShadowBanned:!!(4&o)}}},H={preencode(d,o){e.uint.preencode(d,o.version)},encode(d,o){e.uint.encode(d,o.version)},decode:d=>({version:e.uint.decode(d)})},M={preencode(d,o){e.uint.preencode(d,o.total),e.uint.preencode(d,o.active)},encode(d,o){e.uint.encode(d,o.total),e.uint.encode(d,o.active)},decode:d=>({total:e.uint.decode(d),active:e.uint.decode(d)})},C={preencode(d,o){e.uint.preencode(d,o.total),e.uint.preencode(d,o.active),e.uint.preencode(d,o.pending)},encode(d,o){e.uint.encode(d,o.total),e.uint.encode(d,o.active),e.uint.encode(d,o.pending)},decode:d=>({total:e.uint.decode(d),active:e.uint.decode(d),pending:e.uint.decode(d)})},D={preencode(o,n){e.uint.preencode(o,n.clock),e.uint.preencode(o,n.pinned),e.uint.preencode(o,n.threads),e.uint.preencode(o,n.timestamp),o.end++,d>=15&&n.flagsClock&&e.uint.preencode(o,n.flagsClock)},encode(o,n){const c=d>=15&&n.flagsClock?1:0;e.uint.encode(o,n.clock),e.uint.encode(o,n.pinned),e.uint.encode(o,n.threads),e.uint.encode(o,n.timestamp),e.uint.encode(o,c),d>=15&&n.flagsClock&&e.uint.encode(o,n.flagsClock)},decode(o){const n=e.uint.decode(o),c=e.uint.decode(o),r=e.uint.decode(o),t=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{clock:n,pinned:c,threads:r,timestamp:t,flagsClock:d>=15&&1&i?e.uint.decode(o):0}}},V={preencode(d,o){e.uint.preencode(d,o.clock)},encode(d,o){e.uint.encode(d,o.clock)},decode:d=>({clock:e.uint.decode(d)})},L=e.frame(M),q=e.frame(C),E=e.frame(D),B=e.frame(V),z={preencode(e,o){L.preencode(e,o.devices),q.preencode(e,o.members),E.preencode(e,o.chat),B.preencode(e,o.files),e.end++,d>=26&&o.calls&&Nt.preencode(e,o.calls)},encode(o,n){const c=d>=26&&n.calls?1:0;L.encode(o,n.devices),q.encode(o,n.members),E.encode(o,n.chat),B.encode(o,n.files),e.uint.encode(o,c),d>=26&&n.calls&&Nt.encode(o,n.calls)},decode(o){const n=L.decode(o),c=q.decode(o),r=E.decode(o),t=B.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{devices:n,members:c,chat:r,files:t,calls:d>=26&&1&i?Nt.decode(o):null}}},N={Default:1,Broadcast:2,DirectMessage:3},j={preencode(e,d){e.end++},encode(d,o){if(o>3)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},O={preencode(o,n){const c=(n.roomType?1:0)|(n.isExperimental?2:0)|(n.isJoiningDisabled?4:0)|(n.isAppendingDisabled?8:0)|(n.isCallingDisabled?16:0)|(n.isMembershipEventsDisabled?32:0)|(d>=19&&n.isAttachmentsDisabled?64:0)|(d>=19&&n.isLinksDisabled?128:0)|(d>=20&&n.buildType?256:0)|(d>=23&&n.isRoomInviteHidden?512:0);e.uint.preencode(o,c),n.roomType&&j.preencode(o,n.roomType),d>=20&&n.buildType&&Br.preencode(o,n.buildType)},encode(o,n){const c=(n.roomType?1:0)|(n.isExperimental?2:0)|(n.isJoiningDisabled?4:0)|(n.isAppendingDisabled?8:0)|(n.isCallingDisabled?16:0)|(n.isMembershipEventsDisabled?32:0)|(d>=19&&n.isAttachmentsDisabled?64:0)|(d>=19&&n.isLinksDisabled?128:0)|(d>=20&&n.buildType?256:0)|(d>=23&&n.isRoomInviteHidden?512:0);e.uint.encode(o,c),n.roomType&&j.encode(o,n.roomType),d>=20&&n.buildType&&Br.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{roomType:1&n?j.decode(o):0,isExperimental:!!(2&n),isJoiningDisabled:!!(4&n),isAppendingDisabled:!!(8&n),isCallingDisabled:!!(16&n),isMembershipEventsDisabled:!!(32&n),isAttachmentsDisabled:d>=19&&!!(64&n),isLinksDisabled:d>=19&&!!(128&n),buildType:d>=20&&256&n?Br.decode(o):null,isRoomInviteHidden:d>=23&&!!(512&n)}}},U=e.frame(H),J=e.frame(O),G={preencode(d,o){U.preencode(d,o.abi),J.preencode(d,o.settings),e.uint.preencode(d,o.creationTime)},encode(d,o){U.encode(d,o.abi),J.encode(d,o.settings),e.uint.encode(d,o.creationTime)},decode:d=>({abi:U.decode(d),settings:J.decode(d),creationTime:e.uint.decode(d)})},Q={preencode(d,o){e.fixed32.preencode(d,o.seed)},encode(d,o){e.fixed32.encode(d,o.seed)},decode:d=>({seed:e.fixed32.decode(d)})},W={preencode(d,o){c.preencode(d,o.mailboxKeyPair),r.preencode(d,o.discoveryKeyPair),e.fixed32.preencode(d,o.wakeupTopic),e.fixed32.preencode(d,o.swarmTopic)},encode(d,o){c.encode(d,o.mailboxKeyPair),r.encode(d,o.discoveryKeyPair),e.fixed32.encode(d,o.wakeupTopic),e.fixed32.encode(d,o.swarmTopic)},decode:d=>({mailboxKeyPair:c.decode(d),discoveryKeyPair:r.decode(d),wakeupTopic:e.fixed32.decode(d),swarmTopic:e.fixed32.decode(d)})},X=e.array(e.fixed32),Y={preencode(o,n){o.end++,n.title&&e.string.preencode(o,n.title),n.avatar&&jt.preencode(o,n.avatar),n.description&&e.string.preencode(o,n.description),d>=11&&n.supportedLanguages&&Ot.preencode(o,n.supportedLanguages),d>=13&&n.blindPeers&&X.preencode(o,n.blindPeers)},encode(o,n){const c=(n.title?1:0)|(n.avatar?2:0)|(n.description?4:0)|(d>=11&&n.supportedLanguages?8:0)|(d>=13&&n.blindPeers?16:0);e.uint.encode(o,c),n.title&&e.string.encode(o,n.title),n.avatar&&jt.encode(o,n.avatar),n.description&&e.string.encode(o,n.description),d>=11&&n.supportedLanguages&&Ot.encode(o,n.supportedLanguages),d>=13&&n.blindPeers&&X.encode(o,n.blindPeers)},decode(o){const n=e.uint.decode(o);return{title:1&n?e.string.decode(o):null,avatar:2&n?jt.decode(o):null,description:4&n?e.string.decode(o):null,supportedLanguages:d>=11&&8&n?Ot.decode(o):null,blindPeers:d>=13&&16&n?X.decode(o):null}}},Z={preencode(d,o){e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.key)},decode:d=>({key:e.fixed32.decode(d)})},$=e.frame(i),_=e.frame(Z),ee={preencode(e,d){$.preencode(e,d.header),_.preencode(e,d.peer)},encode(e,d){$.encode(e,d.header),_.encode(e,d.peer)},decode:e=>({header:$.decode(e),peer:_.decode(e)})},de=$,oe={preencode(d,o){de.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){de.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:de.decode(d),key:e.fixed32.decode(d)})},ne={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.buffer.preencode(d,o.proof)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.buffer.encode(d,o.proof)},decode:d=>({memberKey:e.fixed32.decode(d),proof:e.buffer.decode(d)})},ce={preencode(d,o){e.fixed32.preencode(d,o.id),e.buffer.preencode(d,o.response)},encode(d,o){e.fixed32.encode(d,o.id),e.buffer.encode(d,o.response)},decode:d=>({id:e.fixed32.decode(d),response:e.buffer.decode(d)})},re=e.frame(I),te=e.frame(ce),ie={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.memberKey),re.preencode(d,o.status),Ut.preencode(d,o.profile),d.end++,o.invitation&&te.preencode(d,o.invitation)},encode(d,o){const n=o.invitation?1:0;e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.memberKey),re.encode(d,o.status),Ut.encode(d,o.profile),e.uint.encode(d,n),o.invitation&&te.encode(d,o.invitation)},decode:d=>({key:e.fixed32.decode(d),memberKey:e.fixed32.decode(d),status:re.decode(d),profile:Ut.decode(d),invitation:1&e.uint.decode(d)?te.decode(d):null})},ae={preencode(d,o){e.uint.preencode(d,o.timestamp),d.end++,o.mailbox&&e.fixed32.preencode(d,o.mailbox),o.displayName&&e.string.preencode(d,o.displayName),o.avatar&&Jt.preencode(d,o.avatar),o.username&&e.string.preencode(d,o.username)},encode(d,o){const n=(o.mailbox?1:0)|(o.displayName?2:0)|(o.avatar?4:0)|(o.username?8:0);e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.mailbox&&e.fixed32.encode(d,o.mailbox),o.displayName&&e.string.encode(d,o.displayName),o.avatar&&Jt.encode(d,o.avatar),o.username&&e.string.encode(d,o.username)},decode(d){const o=e.uint.decode(d),n=e.uint.decode(d);return{timestamp:o,mailbox:1&n?e.fixed32.decode(d):null,displayName:2&n?e.string.decode(d):null,avatar:4&n?Jt.decode(d):null,username:8&n?e.string.decode(d):null}}},se={preencode(o,n){o.end++,n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),n.name&&e.string.preencode(o,n.name),d>=20&&n.buildType&&Br.preencode(o,n.buildType)},encode(o,n){const c=(n.swarmKey?1:0)|(n.name?2:0)|(n.isMobile?4:0)|(d>=20&&n.buildType?8:0);e.uint.encode(o,c),n.swarmKey&&e.fixed32.encode(o,n.swarmKey),n.name&&e.string.encode(o,n.name),d>=20&&n.buildType&&Br.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{swarmKey:1&n?e.fixed32.decode(o):null,name:2&n?e.string.decode(o):null,isMobile:!!(4&n),buildType:d>=20&&8&n?Br.decode(o):null}}},pe=e.frame(ae),ue={preencode(e,d){pe.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){pe.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:pe.decode(e),attestation:ne.decode(e)})},le={preencode(e,d){Gt.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){Gt.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:Gt.decode(e),attestation:ne.decode(e)})},fe={preencode(d,o){e.fixed32.preencode(d,o.id),e.buffer.preencode(d,o.data),e.buffer.preencode(d,o.signature)},encode(d,o){e.fixed32.encode(d,o.id),e.buffer.encode(d,o.data),e.buffer.encode(d,o.signature)},decode:d=>({id:e.fixed32.decode(d),data:e.buffer.decode(d),signature:e.buffer.decode(d)})},me={preencode(d,o){e.fixed32.preencode(d,o.devicePublicKey)},encode(d,o){e.fixed32.encode(d,o.devicePublicKey)},decode:d=>({devicePublicKey:e.fixed32.decode(d)})},ye={preencode(d,o){ne.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){ne.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({privateProfileIdentity:ne.decode(d),deviceProof:e.buffer.decode(d)})},be=e.frame(le),xe=e.frame(ue),ke=e.frame(me),ve={preencode(n,c){e.fixed32.preencode(n,c.deviceKey),r.preencode(n,c.keyPair),be.preencode(n,c.device),xe.preencode(n,c.member),n.end++,c.identity&&ke.preencode(n,c.identity),d>=27&&c.link&&o.preencode(n,c.link)},encode(n,c){const t=(c.identity?1:0)|(d>=27&&c.link?2:0);e.fixed32.encode(n,c.deviceKey),r.encode(n,c.keyPair),be.encode(n,c.device),xe.encode(n,c.member),e.uint.encode(n,t),c.identity&&ke.encode(n,c.identity),d>=27&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),t=r.decode(n),i=be.decode(n),a=xe.decode(n),s=e.uint.decode(n);return{deviceKey:c,keyPair:t,device:i,member:a,identity:1&s?ke.decode(n):null,link:d>=27&&2&s?o.decode(n):null}}},ge=e.frame(ve),he={preencode(d,o){e.fixed32.preencode(d,o.id),ge.preencode(d,o.request),e.buffer.preencode(d,o.signature)},encode(d,o){e.fixed32.encode(d,o.id),ge.encode(d,o.request),e.buffer.encode(d,o.signature)},decode:d=>({id:e.fixed32.decode(d),request:ge.decode(d),signature:e.buffer.decode(d)})},Ke=be,we=xe,Te={preencode(e,d){Ke.preencode(e,d.device),e.end++,d.member&&we.preencode(e,d.member)},encode(d,o){const n=o.member?1:0;Ke.encode(d,o.device),e.uint.encode(d,n),o.member&&we.encode(d,o.member)},decode:d=>({device:Ke.decode(d),member:1&e.uint.decode(d)?we.decode(d):null})},Ae=e.frame(he),Pe=e.frame(Te),Se={preencode(e,d){e.end++,d.withInvitation&&Ae.preencode(e,d.withInvitation),d.withMemberProof&&Pe.preencode(e,d.withMemberProof)},encode(d,o){const n=(o.withInvitation?1:0)|(o.withMemberProof?2:0);e.uint.encode(d,n),o.withInvitation&&Ae.encode(d,o.withInvitation),o.withMemberProof&&Pe.encode(d,o.withMemberProof)},decode(d){const o=e.uint.decode(d);return{withInvitation:1&o?Ae.decode(d):null,withMemberProof:2&o?Pe.decode(d):null}}},Ie=e.frame(fe),Re=e.frame(ye),Fe={preencode(e,d){Ie.preencode(e,d.signedKeys),e.end++,d.identity&&Re.preencode(e,d.identity)},encode(d,o){const n=o.identity?1:0;Ie.encode(d,o.signedKeys),e.uint.encode(d,n),o.identity&&Re.encode(d,o.identity)},decode:d=>({signedKeys:Ie.decode(d),identity:1&e.uint.decode(d)?Re.decode(d):null})},He={preencode(o,n){o.end++,n.expiration&&e.uint.preencode(o,n.expiration),d>=20&&n.buildType&&Br.preencode(o,n.buildType)},encode(o,n){const c=(n.expiration?1:0)|(n.requiresConfirmation?2:0)|(n.canModerate?4:0)|(n.canAdmin?8:0)|(d>=20&&n.buildType?16:0);e.uint.encode(o,c),n.expiration&&e.uint.encode(o,n.expiration),d>=20&&n.buildType&&Br.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{expiration:1&n?e.uint.decode(o):0,requiresConfirmation:!!(2&n),canModerate:!!(4&n),canAdmin:!!(8&n),buildType:d>=20&&16&n?Br.decode(o):null}}},Me=Ie,Ce=e.frame(He),De={preencode(d,n){e.fixed32.preencode(d,n.id),Me.preencode(d,n.response),Ce.preencode(d,n.metadata),d.end++,n.anchor&&o.preencode(d,n.anchor)},encode(d,n){const c=(n.anchor?1:0)|(n.isActive?2:0);e.fixed32.encode(d,n.id),Me.encode(d,n.response),Ce.encode(d,n.metadata),e.uint.encode(d,c),n.anchor&&o.encode(d,n.anchor)},decode(d){const n=e.fixed32.decode(d),c=Me.decode(d),r=Ce.decode(d),t=e.uint.decode(d);return{id:n,response:c,metadata:r,anchor:1&t?o.decode(d):null,isActive:!!(2&t)}}},Ve=$,Le=e.frame(De),qe={preencode(e,d){Ve.preencode(e,d.header),Le.preencode(e,d.invitation)},encode(e,d){Ve.encode(e,d.header),Le.encode(e,d.invitation)},decode:e=>({header:Ve.decode(e),invitation:Le.decode(e)})},Ee=$,Be={preencode(d,o){Ee.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){Ee.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:Ee.decode(d),id:e.fixed32.decode(d)})},ze={preencode(d,n){e.fixed32.preencode(d,n.mailbox),e.fixed32.preencode(d,n.invitationSeed),o.preencode(d,n.anchor)},encode(d,n){e.fixed32.encode(d,n.mailbox),e.fixed32.encode(d,n.invitationSeed),o.encode(d,n.anchor)},decode:d=>({mailbox:e.fixed32.decode(d),invitationSeed:e.fixed32.decode(d),anchor:o.decode(d)})},Ne={preencode(d,n){e.fixed32.preencode(d,n.mailbox),e.fixed32.preencode(d,n.invitationSeed),o.preencode(d,n.anchor),e.fixed32.preencode(d,n.identityPublicKey)},encode(d,n){e.fixed32.encode(d,n.mailbox),e.fixed32.encode(d,n.invitationSeed),o.encode(d,n.anchor),e.fixed32.encode(d,n.identityPublicKey)},decode:d=>({mailbox:e.fixed32.decode(d),invitationSeed:e.fixed32.decode(d),anchor:o.decode(d),identityPublicKey:e.fixed32.decode(d)})},je={preencode(d,o){e.fixed32.preencode(d,o.mailbox)},encode(d,o){e.fixed32.encode(d,o.mailbox)},decode:d=>({mailbox:e.fixed32.decode(d)})},Oe=e.frame(ze),Ue=e.frame(Ne),Je=e.frame(je),Ge=e.array(e.ipv4Address),Qe={preencode(e,o){e.end++,o.room&&Oe.preencode(e,o.room),o.identity&&Ue.preencode(e,o.identity),o.contact&&Je.preencode(e,o.contact),d>=6&&o.readonly&&Qt.preencode(e,o.readonly),d>=11&&o.additionalNodes&&Ge.preencode(e,o.additionalNodes),d>=20&&o.buildType&&Br.preencode(e,o.buildType),d>=27&&o["readonly-v2"]&&Wt.preencode(e,o["readonly-v2"])},encode(o,n){const c=(n.room?1:0)|(n.identity?2:0)|(n.contact?4:0)|(d>=6&&n.readonly?8:0)|(d>=11&&n.additionalNodes?16:0)|(d>=20&&n.buildType?32:0)|(d>=27&&n["readonly-v2"]?64:0);e.uint.encode(o,c),n.room&&Oe.encode(o,n.room),n.identity&&Ue.encode(o,n.identity),n.contact&&Je.encode(o,n.contact),d>=6&&n.readonly&&Qt.encode(o,n.readonly),d>=11&&n.additionalNodes&&Ge.encode(o,n.additionalNodes),d>=20&&n.buildType&&Br.encode(o,n.buildType),d>=27&&n["readonly-v2"]&&Wt.encode(o,n["readonly-v2"])},decode(o){const n=e.uint.decode(o);return{room:1&n?Oe.decode(o):null,identity:2&n?Ue.decode(o):null,contact:4&n?Je.decode(o):null,readonly:d>=6&&8&n?Qt.decode(o):null,additionalNodes:d>=11&&16&n?Ge.decode(o):null,buildType:d>=20&&32&n?Br.decode(o):null,"readonly-v2":d>=27&&64&n?Wt.decode(o):null}}},We=$,Xe={preencode(d,o){We.preencode(d,o.header),e.buffer.preencode(d,o.blindRequest)},encode(d,o){We.encode(d,o.header),e.buffer.encode(d,o.blindRequest)},decode:d=>({header:We.decode(d),blindRequest:e.buffer.decode(d)})},Ye=$,Ze={preencode(o,n){Ye.preencode(o,n.header),o.end++,n.profile&&Xt.preencode(o,n.profile),d>=24&&n.key&&e.fixed32.preencode(o,n.key)},encode(o,n){const c=(n.profile?1:0)|(d>=24&&n.key?2:0);Ye.encode(o,n.header),e.uint.encode(o,c),n.profile&&Xt.encode(o,n.profile),d>=24&&n.key&&e.fixed32.encode(o,n.key)},decode(o){const n=Ye.decode(o),c=e.uint.decode(o);return{header:n,profile:1&c?Xt.decode(o):null,key:d>=24&&2&c?e.fixed32.decode(o):null}}},$e={preencode(e,d){},encode(e,d){},decode:e=>({})},_e=$e,ed=ge,dd={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.id),ed.preencode(d,o.request)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.id),ed.encode(d,o.request)},decode:d=>({deviceKey:e.fixed32.decode(d),id:e.fixed32.decode(d),request:ed.decode(d)})},od=$,nd=Re,cd={preencode(d,o){od.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),d.end++,o.identity&&nd.preencode(d,o.identity)},encode(d,o){const n=o.identity?1:0;od.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,n),o.identity&&nd.encode(d,o.identity)},decode:d=>({header:od.decode(d),deviceKey:e.fixed32.decode(d),identity:1&e.uint.decode(d)?nd.decode(d):null})},rd=$,td={preencode(d,o){rd.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey)},encode(d,o){rd.encode(d,o.header),e.fixed32.encode(d,o.deviceKey)},decode:d=>({header:rd.decode(d),deviceKey:e.fixed32.decode(d)})},id=e.frame(R),ad=pe,sd={preencode(d,o){e.fixed32.preencode(d,o.key),id.preencode(d,o.status),ad.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),id.encode(d,o.status),ad.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),status:id.decode(d),profile:ad.decode(d)})},pd=id,ud=pe,ld={preencode(d,o){e.fixed32.preencode(d,o.key),pd.preencode(d,o.status),ud.preencode(d,o.profile),d.end++,o.proofs&&Yt.preencode(d,o.proofs)},encode(d,o){const n=o.proofs?1:0;e.fixed32.encode(d,o.key),pd.encode(d,o.status),ud.encode(d,o.profile),e.uint.encode(d,n),o.proofs&&Yt.encode(d,o.proofs)},decode:d=>({key:e.fixed32.decode(d),status:pd.decode(d),profile:ud.decode(d),proofs:1&e.uint.decode(d)?Yt.decode(d):null})},fd={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++,o.profileAttestation&&e.buffer.preencode(d,o.profileAttestation),o.latestReceipt&&e.buffer.preencode(d,o.latestReceipt)},encode(d,o){const n=(o.profileAttestation?1:0)|(o.latestReceipt?2:0);e.fixed32.encode(d,o.key),e.uint.encode(d,n),o.profileAttestation&&e.buffer.encode(d,o.profileAttestation),o.latestReceipt&&e.buffer.encode(d,o.latestReceipt)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d);return{key:o,profileAttestation:1&n?e.buffer.decode(d):null,latestReceipt:2&n?e.buffer.decode(d):null}}},md=$,yd=xe,bd={preencode(e,d){md.preencode(e,d.header),yd.preencode(e,d.member)},encode(e,d){md.encode(e,d.header),yd.encode(e,d.member)},decode:e=>({header:md.decode(e),member:yd.decode(e)})},xd=$,kd=e.frame(F),vd={preencode(d,o){xd.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),kd.preencode(d,o.status)},encode(d,o){xd.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),kd.encode(d,o.status)},decode:d=>({header:xd.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:kd.decode(d)})},gd=$,hd={preencode(d,o){gd.preencode(d,o.header),e.fixed32.preencode(d,o.key),d.end++},encode(d,o){const n=(o.isModerator?1:0)|(o.isAdmin?2:0);gd.encode(d,o.header),e.fixed32.encode(d,o.key),e.uint.encode(d,n)},decode(d){const o=gd.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{header:o,key:n,isModerator:!!(1&c),isAdmin:!!(2&c)}}},Kd=$,wd={preencode(d,o){Kd.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){Kd.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:Kd.decode(d),key:e.fixed32.decode(d)})},Td={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.mentions)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.mentions)},decode:d=>({key:e.fixed32.decode(d),mentions:e.uint.decode(d)})},Ad={preencode(d,o){d.end++,o.memberKey&&e.fixed32.preencode(d,o.memberKey)},encode(d,o){const n=o.memberKey?1:0;e.uint.encode(d,n),o.memberKey&&e.fixed32.encode(d,o.memberKey)},decode:d=>({memberKey:1&e.uint.decode(d)?e.fixed32.decode(d):null})},Pd=Ad,Sd={preencode(d,o){d.end++,o.from&&e.string.preencode(d,o.from),o.to&&e.string.preencode(d,o.to)},encode(d,o){const n=(o.from?1:0)|(o.to?2:0);e.uint.encode(d,n),o.from&&e.string.encode(d,o.from),o.to&&e.string.encode(d,o.to)},decode(d){const o=e.uint.decode(d);return{from:1&o?e.string.decode(d):null,to:2&o?e.string.decode(d):null}}},Id=e.frame(Ad),Rd=e.frame(Pd),Fd=e.frame(Sd),Hd={preencode(o,n){const c=(n.memberJoined?1:0)|(n.memberLeft?2:0)|(n.titleChanged?4:0)|(n.callStarted?8:0)|(n.callHangup?16:0)|(n.callMissed?32:0)|(d>=3&&n.roomAvatarChanged?64:0)|(d>=3&&n.invitationCreated?128:0)|(d>=3&&n.memberRemoved?256:0)|(d>=18&&n.locationShared?512:0);e.uint.preencode(o,c),n.memberJoined&&Id.preencode(o,n.memberJoined),n.memberLeft&&Rd.preencode(o,n.memberLeft),n.titleChanged&&Fd.preencode(o,n.titleChanged),d>=3&&n.memberRemoved&&Zt.preencode(o,n.memberRemoved),d>=18&&n.locationShared&&$t.preencode(o,n.locationShared)},encode(o,n){const c=(n.memberJoined?1:0)|(n.memberLeft?2:0)|(n.titleChanged?4:0)|(n.callStarted?8:0)|(n.callHangup?16:0)|(n.callMissed?32:0)|(d>=3&&n.roomAvatarChanged?64:0)|(d>=3&&n.invitationCreated?128:0)|(d>=3&&n.memberRemoved?256:0)|(d>=18&&n.locationShared?512:0);e.uint.encode(o,c),n.memberJoined&&Id.encode(o,n.memberJoined),n.memberLeft&&Rd.encode(o,n.memberLeft),n.titleChanged&&Fd.encode(o,n.titleChanged),d>=3&&n.memberRemoved&&Zt.encode(o,n.memberRemoved),d>=18&&n.locationShared&&$t.encode(o,n.locationShared)},decode(o){const n=e.uint.decode(o);return{memberJoined:1&n?Id.decode(o):null,memberLeft:2&n?Rd.decode(o):null,titleChanged:4&n?Fd.decode(o):null,callStarted:!!(8&n),callHangup:!!(16&n),callMissed:!!(32&n),roomAvatarChanged:d>=3&&!!(64&n),invitationCreated:d>=3&&!!(128&n),memberRemoved:d>=3&&256&n?Zt.decode(o):null,locationShared:d>=18&&512&n?$t.decode(o):null}}},Md={preencode(e,o){e.end++,d>=18&&o.locationShared&&_t.preencode(e,o.locationShared)},encode(o,n){const c=(n.callStarted?1:0)|(n.callHangup?2:0)|(n.callMissed?4:0)|(d>=18&&n.locationShared?8:0);e.uint.encode(o,c),d>=18&&n.locationShared&&_t.encode(o,n.locationShared)},decode(o){const n=e.uint.decode(o);return{callStarted:!!(1&n),callHangup:!!(2&n),callMissed:!!(4&n),locationShared:d>=18&&8&n?_t.decode(o):null}}},Cd={preencode(d,o){e.uint.preencode(d,o.start),e.uint.preencode(d,o.length)},encode(d,o){e.uint.encode(d,o.start),e.uint.encode(d,o.length)},decode:d=>({start:e.uint.decode(d),length:e.uint.decode(d)})},Dd=e.frame(Cd),Vd={preencode(d,o){Dd.preencode(d,o.range),e.string.preencode(d,o.content)},encode(d,o){Dd.encode(d,o.range),e.string.encode(d,o.content)},decode:d=>({range:Dd.decode(d),content:e.string.decode(d)})},Ld=Dd,qd={preencode(d,o){Ld.preencode(d,o.range),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Ld.encode(d,o.range),e.fixed32.encode(d,o.memberKey)},decode:d=>({range:Ld.decode(d),memberKey:e.fixed32.decode(d)})},Ed=g,Bd=e.array(e.uint),zd={preencode(o,n){o.end++,n.title&&e.string.preencode(o,n.title),n.description&&e.string.preencode(o,n.description),n.file&&Ed.preencode(o,n.file),d>=7&&n.files&&Bd.preencode(o,n.files)},encode(o,n){const c=(n.title?1:0)|(n.description?2:0)|(n.file?4:0)|(d>=7&&n.files?8:0);e.uint.encode(o,c),n.title&&e.string.encode(o,n.title),n.description&&e.string.encode(o,n.description),n.file&&Ed.encode(o,n.file),d>=7&&n.files&&Bd.encode(o,n.files)},decode(o){const n=e.uint.decode(o);return{title:1&n?e.string.decode(o):null,description:2&n?e.string.decode(o):null,file:4&n?Ed.decode(o):null,files:d>=7&&8&n?Bd.decode(o):null}}},Nd=Dd,jd=e.frame(zd),Od={preencode(d,o){Nd.preencode(d,o.range),e.string.preencode(d,o.url),d.end++,o.preview&&jd.preencode(d,o.preview)},encode(d,o){const n=o.preview?1:0;Nd.encode(d,o.range),e.string.encode(d,o.url),e.uint.encode(d,n),o.preview&&jd.encode(d,o.preview)},decode:d=>({range:Nd.decode(d),url:e.string.decode(d),preview:1&e.uint.decode(d)?jd.decode(d):null})},Ud=e.array(e.frame(qd)),Jd=e.array(e.frame(Od)),Gd=Jd,Qd=e.array(e.frame(Cd)),Wd=Qd,Xd=Qd,Yd=e.array(e.frame(Vd)),Zd=Qd,$d=Qd,_d={preencode(o,n){const c=(n.mention?1:0)|(n.httpLink?2:0)|(n.pearLink?4:0)|(n.bold?8:0)|(n.italic?16:0)|(n.code?32:0)|(n.emoji?64:0)|(n.codeBlock?128:0)|(n.strike?256:0)|(d>=11&&n.translation?512:0);e.uint.preencode(o,c),n.mention&&Ud.preencode(o,n.mention),n.httpLink&&Jd.preencode(o,n.httpLink),n.pearLink&&Gd.preencode(o,n.pearLink),n.bold&&Qd.preencode(o,n.bold),n.italic&&Wd.preencode(o,n.italic),n.code&&Xd.preencode(o,n.code),n.emoji&&Yd.preencode(o,n.emoji),n.codeBlock&&Zd.preencode(o,n.codeBlock),n.strike&&$d.preencode(o,n.strike),d>=11&&n.translation&&ei.preencode(o,n.translation)},encode(o,n){const c=(n.mention?1:0)|(n.httpLink?2:0)|(n.pearLink?4:0)|(n.bold?8:0)|(n.italic?16:0)|(n.code?32:0)|(n.emoji?64:0)|(n.codeBlock?128:0)|(n.strike?256:0)|(d>=11&&n.translation?512:0);e.uint.encode(o,c),n.mention&&Ud.encode(o,n.mention),n.httpLink&&Jd.encode(o,n.httpLink),n.pearLink&&Gd.encode(o,n.pearLink),n.bold&&Qd.encode(o,n.bold),n.italic&&Wd.encode(o,n.italic),n.code&&Xd.encode(o,n.code),n.emoji&&Yd.encode(o,n.emoji),n.codeBlock&&Zd.encode(o,n.codeBlock),n.strike&&$d.encode(o,n.strike),d>=11&&n.translation&&ei.encode(o,n.translation)},decode(o){const n=e.uint.decode(o);return{mention:1&n?Ud.decode(o):null,httpLink:2&n?Jd.decode(o):null,pearLink:4&n?Gd.decode(o):null,bold:8&n?Qd.decode(o):null,italic:16&n?Wd.decode(o):null,code:32&n?Xd.decode(o):null,emoji:64&n?Yd.decode(o):null,codeBlock:128&n?Zd.decode(o):null,strike:256&n?$d.decode(o):null,translation:d>=11&&512&n?ei.decode(o):null}}},eo=e.array(e.frame(v)),oo=e.frame(_d),no=e.frame(Md),co={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&eo.preencode(d,o.files),o.display&&oo.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent),o.event&&no.preencode(d,o.event)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(c.event?32:0)|(d>=18&&c.forwarded?64:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&eo.encode(o,c.files),c.display&&oo.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent),c.event&&no.encode(o,c.event)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?eo.decode(o):null,display:4&c?oo.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,event:32&c?no.decode(o):null,forwarded:d>=18&&!!(64&c)}}},ro=Bd,to=oo,io={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&ro.preencode(d,o.files),o.display&&to.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(d>=18&&c.forwarded?32:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&ro.encode(o,c.files),c.display&&to.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?ro.decode(o):null,display:4&c?to.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,forwarded:d>=18&&!!(32&c)}}},ao=eo,so=oo,po={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&ao.preencode(d,o.files),o.display&&so.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(d>=18&&c.forwarded?32:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&ao.encode(o,c.files),c.display&&so.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?ao.decode(o):null,display:4&c?so.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,forwarded:d>=18&&!!(32&c)}}},uo={preencode(e,d){e.end++},encode(d,o){const n=(o.isEdited?1:0)|(o.isDeleted?2:0)|(o.isPinned?4:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isEdited:!!(1&o),isDeleted:!!(2&o),isPinned:!!(4&o)}}},lo={preencode(d,o){e.uint.preencode(d,o.thread),e.uint.preencode(d,o.index)},encode(d,o){e.uint.encode(d,o.thread),e.uint.encode(d,o.index)},decode:d=>({thread:e.uint.decode(d),index:e.uint.decode(d)})},fo=e.frame(z),mo={preencode(d,o){e.uint.preencode(d,o.id),e.uint.preencode(d,o.count),d.end++,o.parent&&n.preencode(d,o.parent),o.stats&&fo.preencode(d,o.stats)},encode(d,o){const c=(o.parent?1:0)|(o.stats?2:0);e.uint.encode(d,o.id),e.uint.encode(d,o.count),e.uint.encode(d,c),o.parent&&n.encode(d,o.parent),o.stats&&fo.encode(d,o.stats)},decode(d){const o=e.uint.decode(d),c=e.uint.decode(d),r=e.uint.decode(d);return{id:o,count:c,parent:1&r?n.decode(d):null,stats:2&r?fo.decode(d):null}}},yo=e.frame(uo),bo=e.frame(io),xo=e.frame(Hd),ko={preencode(d,o){lo.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),yo.preencode(d,o.status),o.message&&bo.preencode(d,o.message),o.event&&xo.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);lo.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),yo.encode(d,o.status),o.message&&bo.encode(d,o.message),o.event&&xo.encode(d,o.event)},decode(d){const o=lo.decode(d),c=n.decode(d),r=e.uint.decode(d),t=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:r,timestamp:t,editedAt:1&i?e.uint.decode(d):0,status:yo.decode(d),message:2&i?bo.decode(d):null,event:4&i?xo.decode(d):null}}},vo=yo,go=e.frame(po),ho=xo,Ko={preencode(d,o){lo.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),vo.preencode(d,o.status),o.message&&go.preencode(d,o.message),o.event&&ho.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);lo.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),vo.encode(d,o.status),o.message&&go.encode(d,o.message),o.event&&ho.encode(d,o.event)},decode(d){const o=lo.decode(d),c=n.decode(d),r=e.uint.decode(d),t=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:r,timestamp:t,editedAt:1&i?e.uint.decode(d):0,status:vo.decode(d),message:2&i?go.decode(d):null,event:4&i?ho.decode(d):null}}},wo=$,To=e.frame(co),Ao={preencode(e,d){wo.preencode(e,d.header),To.preencode(e,d.message)},encode(e,d){wo.encode(e,d.header),To.encode(e,d.message)},decode:e=>({header:wo.decode(e),message:To.decode(e)})},Po=$,So={preencode(e,d){Po.preencode(e,d.header),n.preencode(e,d.oplog)},encode(e,d){Po.encode(e,d.header),n.encode(e,d.oplog)},decode:e=>({header:Po.decode(e),oplog:n.decode(e)})},Io=$,Ro=To,Fo={preencode(e,d){Io.preencode(e,d.header),n.preencode(e,d.oplog),Ro.preencode(e,d.message)},encode(e,d){Io.encode(e,d.header),n.encode(e,d.oplog),Ro.encode(e,d.message)},decode:e=>({header:Io.decode(e),oplog:n.decode(e),message:Ro.decode(e)})},Ho=$,Mo={preencode(e,d){Ho.preencode(e,d.header),n.preencode(e,d.oplog),e.end++},encode(d,o){const c=o.isPinned?1:0;Ho.encode(d,o.header),n.encode(d,o.oplog),e.uint.encode(d,c)},decode:d=>({header:Ho.decode(d),oplog:n.decode(d),isPinned:!!(1&e.uint.decode(d))})},Co={preencode(d,o){lo.preencode(d,o.id),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),e.string.preencode(d,o.reaction)},encode(d,o){lo.encode(d,o.id),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),e.string.encode(d,o.reaction)},decode:d=>({id:lo.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),reaction:e.string.decode(d)})},Do={preencode(d,o){e.string.preencode(d,o.text),e.uint.preencode(d,o.count)},encode(d,o){e.string.encode(d,o.text),e.uint.encode(d,o.count)},decode:d=>({text:e.string.decode(d),count:e.uint.decode(d)})},Vo=e.array(e.frame(Do)),Lo={preencode(o,n){lo.preencode(o,n.id),e.uint.preencode(o,n.total),Vo.preencode(o,n.reactions),o.end++,d>=11&&n.editedAt&&e.uint.preencode(o,n.editedAt)},encode(o,n){const c=d>=11&&n.editedAt?1:0;lo.encode(o,n.id),e.uint.encode(o,n.total),Vo.encode(o,n.reactions),e.uint.encode(o,c),d>=11&&n.editedAt&&e.uint.encode(o,n.editedAt)},decode(o){const n=lo.decode(o),c=e.uint.decode(o),r=Vo.decode(o),t=o.start<o.end?e.uint.decode(o):0;return{id:n,total:c,reactions:r,editedAt:d>=11&&1&t?e.uint.decode(o):0}}},qo=$,Eo={preencode(d,o){qo.preencode(d,o.header),n.preencode(d,o.oplog),e.string.preencode(d,o.reaction)},encode(d,o){qo.encode(d,o.header),n.encode(d,o.oplog),e.string.encode(d,o.reaction)},decode:d=>({header:qo.decode(d),oplog:n.decode(d),reaction:e.string.decode(d)})},Bo=$,zo={preencode(d,o){Bo.preencode(d,o.header),n.preencode(d,o.oplog),e.string.preencode(d,o.reaction)},encode(d,o){Bo.encode(d,o.header),n.encode(d,o.oplog),e.string.encode(d,o.reaction)},decode:d=>({header:Bo.decode(d),oplog:n.decode(d),reaction:e.string.decode(d)})},No=$,jo=e.frame(Y),Oo={preencode(d,o){No.preencode(d,o.header),e.uint.preencode(d,o.key),jo.preencode(d,o.config)},encode(d,o){No.encode(d,o.header),e.uint.encode(d,o.key),jo.encode(d,o.config)},decode:d=>({header:No.decode(d),key:e.uint.decode(d),config:jo.decode(d)})},Uo={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.string.preencode(d,o.displayName),d.end++,o.avatar&&di.preencode(d,o.avatar)},encode(d,o){const n=o.avatar?1:0;e.fixed32.encode(d,o.memberKey),e.string.encode(d,o.displayName),e.uint.encode(d,n),o.avatar&&di.encode(d,o.avatar)},decode:d=>({memberKey:e.fixed32.decode(d),displayName:e.string.decode(d),avatar:1&e.uint.decode(d)?di.decode(d):null})},Jo={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++,o.username&&e.string.preencode(d,o.username)},encode(d,o){const n=o.username?1:0;e.fixed32.encode(d,o.key),e.uint.encode(d,n),o.username&&e.string.encode(d,o.username)},decode:d=>({key:e.fixed32.decode(d),username:1&e.uint.decode(d)?e.string.decode(d):null})},Go=e.frame(Jo),Qo={preencode(d,o){e.fixed32.preencode(d,o.publicKey),d.end++,o.discoveryCoreKey&&e.fixed32.preencode(d,o.discoveryCoreKey),o.userRegistry&&Go.preencode(d,o.userRegistry)},encode(d,o){const n=(o.discoveryCoreKey?1:0)|(o.userRegistry?2:0);e.fixed32.encode(d,o.publicKey),e.uint.encode(d,n),o.discoveryCoreKey&&e.fixed32.encode(d,o.discoveryCoreKey),o.userRegistry&&Go.encode(d,o.userRegistry)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d);return{publicKey:o,discoveryCoreKey:1&n?e.fixed32.decode(d):null,userRegistry:2&n?Go.decode(d):null}}},Wo=$,Xo=e.frame(G),Yo=e.frame(Q),Zo=jo,$o=e.frame(Qo),_o=be,en=e.array(e.frame(ue)),dn={preencode(e,d){Wo.preencode(e,d.header),Xo.preencode(e,d.digest),Yo.preencode(e,d.capabilities),e.end++,d.config&&Zo.preencode(e,d.config),d.identity&&$o.preencode(e,d.identity),d.bootstrapDevice&&_o.preencode(e,d.bootstrapDevice),d.initialMembers&&en.preencode(e,d.initialMembers)},encode(d,o){const n=(o.config?1:0)|(o.identity?2:0)|(o.bootstrapDevice?4:0)|(o.initialMembers?8:0);Wo.encode(d,o.header),Xo.encode(d,o.digest),Yo.encode(d,o.capabilities),e.uint.encode(d,n),o.config&&Zo.encode(d,o.config),o.identity&&$o.encode(d,o.identity),o.bootstrapDevice&&_o.encode(d,o.bootstrapDevice),o.initialMembers&&en.encode(d,o.initialMembers)},decode(d){const o=Wo.decode(d),n=Xo.decode(d),c=Yo.decode(d),r=e.uint.decode(d);return{header:o,digest:n,capabilities:c,config:1&r?Zo.decode(d):null,identity:2&r?$o.decode(d):null,bootstrapDevice:4&r?_o.decode(d):null,initialMembers:8&r?en.decode(d):null}}},on=$,nn={preencode(d,o){on.preencode(d,o.header),e.uint.preencode(d,o.version)},encode(d,o){on.encode(d,o.header),e.uint.encode(d,o.version)},decode:d=>({header:on.decode(d),version:e.uint.decode(d)})},cn=$,rn=J,tn={preencode(d,o){cn.preencode(d,o.header),e.uint.preencode(d,o.key),rn.preencode(d,o.settings)},encode(d,o){cn.encode(d,o.header),e.uint.encode(d,o.key),rn.encode(d,o.settings)},decode:d=>({header:cn.decode(d),key:e.uint.decode(d),settings:rn.decode(d)})},an={preencode(o,n){e.fixed32.preencode(o,n.memberKey),oi.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=22&&n.contactInfo&&ni.preencode(o,n.contactInfo),d>=22&&n.version&&e.uint.preencode(o,n.version),d>=24&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=22&&n.contactInfo?4:0)|(d>=22&&n.version?8:0)|(d>=24&&n.alias?16:0);e.fixed32.encode(o,n.memberKey),oi.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=22&&n.contactInfo&&ni.encode(o,n.contactInfo),d>=22&&n.version&&e.uint.encode(o,n.version),d>=24&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.fixed32.decode(o),c=oi.decode(o),r=e.uint.decode(o);return{memberKey:n,status:c,mailbox:1&r?e.fixed32.decode(o):null,roomKey:2&r?e.fixed32.decode(o):null,contactInfo:d>=22&&4&r?ni.decode(o):null,version:d>=22&&8&r?e.uint.decode(o):0,alias:d>=24&&16&r?e.string.decode(o):null}}},sn={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.seed),o.preencode(d,n.initiator),e.fixed32.preencode(d,n.fastForwardTo)},encode(d,n){e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.fixed32.encode(d,n.seed),o.encode(d,n.initiator),e.fixed32.encode(d,n.fastForwardTo)},decode:d=>({roomKey:e.fixed32.decode(d),encryptionKey:e.buffer.decode(d),seed:e.fixed32.decode(d),initiator:o.decode(d),fastForwardTo:e.fixed32.decode(d)})},pn=e.array(e.frame(sn)),un=X,ln={preencode(e,d){pn.preencode(e,d.sharedRooms),un.preencode(e,d.blockedContacts)},encode(e,d){pn.encode(e,d.sharedRooms),un.encode(e,d.blockedContacts)},decode:e=>({sharedRooms:pn.decode(e),blockedContacts:un.decode(e)})},fn=$o,mn={preencode(e,d){fn.preencode(e,d.identity)},encode(e,d){fn.encode(e,d.identity)},decode:e=>({identity:fn.decode(e)})},yn={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.contacts)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.contacts)},decode:d=>({rooms:e.uint.decode(d),contacts:e.uint.decode(d)})},bn={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.contactRequests)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.contactRequests)},decode:d=>({rooms:e.uint.decode(d),contactRequests:e.uint.decode(d)})},xn={preencode(d,o){e.buffer.preencode(d,o.entropy)},encode(d,o){e.buffer.encode(d,o.entropy)},decode:d=>({entropy:e.buffer.decode(d)})},kn={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.devicePublicKey),e.fixed32.preencode(d,o.writerKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.devicePublicKey),e.fixed32.encode(d,o.writerKey)},decode:d=>({publicKey:e.fixed32.decode(d),devicePublicKey:e.fixed32.decode(d),writerKey:e.fixed32.decode(d)})},vn=e.frame(kn),gn={preencode(n,c){e.fixed32.preencode(n,c.id),e.fixed32.preencode(n,c.invitationSeed),e.fixed32.preencode(n,c.mailbox),r.preencode(n,c.responseKeyPair),o.preencode(n,c.initiator),o.preencode(n,c.inviter),n.end++,c.identity&&vn.preencode(n,c.identity),d>=20&&c.buildType&&Br.preencode(n,c.buildType),d>=27&&c.link&&o.preencode(n,c.link)},encode(n,c){const t=(c.identity?1:0)|(d>=20&&c.buildType?2:0)|(d>=27&&c.link?4:0);e.fixed32.encode(n,c.id),e.fixed32.encode(n,c.invitationSeed),e.fixed32.encode(n,c.mailbox),r.encode(n,c.responseKeyPair),o.encode(n,c.initiator),o.encode(n,c.inviter),e.uint.encode(n,t),c.identity&&vn.encode(n,c.identity),d>=20&&c.buildType&&Br.encode(n,c.buildType),d>=27&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),t=e.fixed32.decode(n),i=e.fixed32.decode(n),a=r.decode(n),s=o.decode(n),p=o.decode(n),u=e.uint.decode(n);return{id:c,invitationSeed:t,mailbox:i,responseKeyPair:a,initiator:s,inviter:p,identity:1&u?vn.decode(n):null,buildType:d>=20&&2&u?Br.decode(n):null,link:d>=27&&4&u?o.decode(n):null}}},hn=$,Kn={preencode(d,o){hn.preencode(d,o.header),e.buffer.preencode(d,o.blindResponse)},encode(d,o){hn.encode(d,o.header),e.buffer.encode(d,o.blindResponse)},decode:d=>({header:hn.decode(d),blindResponse:e.buffer.decode(d)})},wn=$,Tn=e.frame(gn),An={preencode(e,d){wn.preencode(e,d.header),Tn.preencode(e,d.invitation)},encode(e,d){wn.encode(e,d.header),Tn.encode(e,d.invitation)},decode:e=>({header:wn.decode(e),invitation:Tn.decode(e)})},Pn=$,Sn={preencode(d,o){Pn.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){Pn.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:Pn.decode(d),id:e.fixed32.decode(d)})},In={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.devicePublicKey),d.end++,o.privateProfileKey&&e.fixed32.preencode(d,o.privateProfileKey),o.deviceKeyPair&&r.preencode(d,o.deviceKeyPair),e.buffer.preencode(d,o.deviceProof)},encode(d,o){const n=(o.privateProfileKey?1:0)|(o.deviceKeyPair?2:0);e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.devicePublicKey),e.uint.encode(d,n),o.privateProfileKey&&e.fixed32.encode(d,o.privateProfileKey),o.deviceKeyPair&&r.encode(d,o.deviceKeyPair),e.buffer.encode(d,o.deviceProof)},decode(d){const o=e.fixed32.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{publicKey:o,devicePublicKey:n,privateProfileKey:1&c?e.fixed32.decode(d):null,deviceKeyPair:2&c?r.decode(d):null,deviceProof:e.buffer.decode(d)}}},Rn={preencode(o,n){o.end++,d>=25&&n.roomSnoozeTime&&e.uint.preencode(o,n.roomSnoozeTime)},encode(o,n){const c=(n.isActive?1:0)|(n.isFullyMuted?2:0)|(n.isMentionsOnlyMuted?4:0)|(d>=9&&n.isReadOnly?8:0)|(d>=18&&n.isFavorite?16:0)|(d>=21&&n.isUnread?32:0)|(d>=25&&n.roomSnoozeTime?64:0);e.uint.encode(o,c),d>=25&&n.roomSnoozeTime&&e.uint.encode(o,n.roomSnoozeTime)},decode(o){const n=e.uint.decode(o);return{isActive:!!(1&n),isFullyMuted:!!(2&n),isMentionsOnlyMuted:!!(4&n),isReadOnly:d>=9&&!!(8&n),isFavorite:d>=18&&!!(16&n),isUnread:d>=21&&!!(32&n),roomSnoozeTime:d>=25&&64&n?e.uint.decode(o):0}}},Fn=e.frame(Rn),Hn=e.frame(In),Mn=vn,Cn={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),Fn.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,c.initiator&&o.preencode(n,c.initiator),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),c.identitySwap&&Hn.preencode(n,c.identitySwap),d>=6&&c.identitySwapV2&&Mn.preencode(n,c.identitySwapV2),d>=10&&c.contact&&e.fixed32.preencode(n,c.contact),d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=29&&c.activeClock&&e.uint.preencode(n,c.activeClock)},encode(n,c){const r=(c.initiator?1:0)|(c.fastForwardTo?2:0)|(c.identitySwap?4:0)|(d>=6&&c.identitySwapV2?8:0)|(d>=10&&c.contact?16:0)|(d>=27&&c.bootFrom?32:0)|(d>=29&&c.activeClock?64:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),Fn.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,r),c.initiator&&o.encode(n,c.initiator),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),c.identitySwap&&Hn.encode(n,c.identitySwap),d>=6&&c.identitySwapV2&&Mn.encode(n,c.identitySwapV2),d>=10&&c.contact&&e.fixed32.encode(n,c.contact),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom),d>=29&&c.activeClock&&e.uint.encode(n,c.activeClock)},decode(n){const c=e.fixed32.decode(n),r=e.buffer.decode(n),t=e.fixed32.decode(n),i=Fn.decode(n),a=e.uint.decode(n),s=e.uint.decode(n);return{roomKey:c,encryptionKey:r,mailbox:t,status:i,clock:a,initiator:1&s?o.decode(n):null,fastForwardTo:2&s?e.fixed32.decode(n):null,identitySwap:4&s?Hn.decode(n):null,identitySwapV2:d>=6&&8&s?Mn.decode(n):null,contact:d>=10&&16&s?e.fixed32.decode(n):null,bootFrom:d>=27&&32&s?o.decode(n):null,activeClock:d>=29&&64&s?e.uint.decode(n):0}}},Dn=$,Vn={preencode(d,n){Dn.preencode(d,n.header),e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.mailbox),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.dm&&e.fixed32.preencode(d,n.dm)},encode(n,c){const r=(c.fastForwardTo?1:0)|(c.initiator?2:0)|(c.dm?4:0)|(d>=9&&c.isReadOnly?8:0);Dn.encode(n,c.header),e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),e.uint.encode(n,r),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),c.initiator&&o.encode(n,c.initiator),c.dm&&e.fixed32.encode(n,c.dm)},decode(n){const c=Dn.decode(n),r=e.fixed32.decode(n),t=e.buffer.decode(n),i=e.fixed32.decode(n),a=e.uint.decode(n);return{header:c,roomKey:r,encryptionKey:t,mailbox:i,fastForwardTo:1&a?e.fixed32.decode(n):null,initiator:2&a?o.decode(n):null,dm:4&a?e.fixed32.decode(n):null,isReadOnly:d>=9&&!!(8&a)}}},Ln=$,qn={preencode(d,o){Ln.preencode(d,o.header),e.fixed32.preencode(d,o.discoveryKey)},encode(d,o){Ln.encode(d,o.header),e.fixed32.encode(d,o.discoveryKey)},decode:d=>({header:Ln.decode(d),discoveryKey:e.fixed32.decode(d)})},En=$,Bn=Fn,zn={preencode(d,o){En.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.key),Bn.preencode(d,o.status)},encode(d,o){En.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.key),Bn.encode(d,o.status)},decode:d=>({header:En.decode(d),roomKey:e.fixed32.decode(d),key:e.uint.decode(d),status:Bn.decode(d)})},Nn={preencode(e,d){e.end++},encode(o,n){const c=(n.isBlocked?1:0)|(d>=22&&n.isActive?2:0);e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{isBlocked:!!(1&n),isActive:d>=22&&!!(2&n)}}},jn={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.clock),ci.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=22&&n.contactInfo&&ri.preencode(o,n.contactInfo),d>=24&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=22&&n.contactInfo?4:0)|(d>=24&&n.alias?8:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.clock),ci.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=22&&n.contactInfo&&ri.encode(o,n.contactInfo),d>=24&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),r=ci.decode(o),t=e.uint.decode(o);return{memberKey:n,clock:c,status:r,mailbox:1&t?e.fixed32.decode(o):null,roomKey:2&t?e.fixed32.decode(o):null,contactInfo:d>=22&&4&t?ri.decode(o):null,alias:d>=24&&8&t?e.string.decode(o):null}}},On=$,Un=e.frame(an),Jn={preencode(e,d){On.preencode(e,d.header),Un.preencode(e,d.contact)},encode(e,d){On.encode(e,d.header),Un.encode(e,d.contact)},decode:e=>({header:On.decode(e),contact:Un.decode(e)})},Gn=$,Qn={preencode(d,o){Gn.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),ti.preencode(d,o.status)},encode(d,o){Gn.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),ti.encode(d,o.status)},decode:d=>({header:Gn.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:ti.decode(d)})},Wn=$,Xn={preencode(d,o){Wn.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Wn.encode(d,o.header),e.fixed32.encode(d,o.memberKey)},decode:d=>({header:Wn.decode(d),memberKey:e.fixed32.decode(d)})},Yn={preencode(e,d){e.end++},encode(d,o){const n=(o.isPending?1:0)|(o.isAccepted?2:0)|(o.isRejected?4:0)|(o.isDiscarded?8:0)|(o.isSeen?16:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isPending:!!(1&o),isAccepted:!!(2&o),isRejected:!!(4&o),isDiscarded:!!(8&o),isSeen:!!(16&o)}}},Zn=xe,$n=e.frame(t),_n={preencode(d,o){Zn.preencode(d,o.sender),$n.preencode(d,o.keys),e.fixed32.preencode(d,o.mailbox),d.end++,o.message&&e.string.preencode(d,o.message)},encode(d,o){const n=o.message?1:0;Zn.encode(d,o.sender),$n.encode(d,o.keys),e.fixed32.encode(d,o.mailbox),e.uint.encode(d,n),o.message&&e.string.encode(d,o.message)},decode:d=>({sender:Zn.decode(d),keys:$n.decode(d),mailbox:e.fixed32.decode(d),message:1&e.uint.decode(d)?e.string.decode(d):null})},ec=e.frame(_n),dc={preencode(o,n){ec.preencode(o,n.body),ne.preencode(o,n.attestation),o.end++,d>=31&&n.recipientProof&&e.buffer.preencode(o,n.recipientProof)},encode(o,n){const c=d>=31&&n.recipientProof?1:0;ec.encode(o,n.body),ne.encode(o,n.attestation),e.uint.encode(o,c),d>=31&&n.recipientProof&&e.buffer.encode(o,n.recipientProof)},decode(o){const n=ec.decode(o),c=ne.decode(o),r=o.start<o.end?e.uint.decode(o):0;return{body:n,attestation:c,recipientProof:d>=31&&1&r?e.buffer.decode(o):null}}},oc=pe,nc=e.frame(Yn),cc=$n,rc={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.clock),oc.preencode(o,n.sender),nc.preencode(o,n.status),cc.preencode(o,n.keys),e.fixed32.preencode(o,n.mailbox),o.end++,n.message&&e.string.preencode(o,n.message),d>=11&&n.sentAt&&e.uint.preencode(o,n.sentAt),d>=22&&n.contactInfo&&ii.preencode(o,n.contactInfo)},encode(o,n){const c=(n.message?1:0)|(d>=11&&n.sentAt?2:0)|(d>=22&&n.contactInfo?4:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.clock),oc.encode(o,n.sender),nc.encode(o,n.status),cc.encode(o,n.keys),e.fixed32.encode(o,n.mailbox),e.uint.encode(o,c),n.message&&e.string.encode(o,n.message),d>=11&&n.sentAt&&e.uint.encode(o,n.sentAt),d>=22&&n.contactInfo&&ii.encode(o,n.contactInfo)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),r=oc.decode(o),t=nc.decode(o),i=cc.decode(o),a=e.fixed32.decode(o),s=e.uint.decode(o);return{memberKey:n,clock:c,sender:r,status:t,keys:i,mailbox:a,message:1&s?e.string.decode(o):null,sentAt:d>=11&&2&s?e.uint.decode(o):0,contactInfo:d>=22&&4&s?ii.decode(o):null}}},tc=$,ic={preencode(d,o){tc.preencode(d,o.header),e.buffer.preencode(d,o.blindRequest)},encode(d,o){tc.encode(d,o.header),e.buffer.encode(d,o.blindRequest)},decode:d=>({header:tc.decode(d),blindRequest:e.buffer.decode(d)})},ac=$,sc=nc,pc={preencode(o,n){ac.preencode(o,n.header),e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.key),sc.preencode(o,n.status),o.end++,d>=10&&n.roomKey&&e.fixed32.preencode(o,n.roomKey)},encode(o,n){const c=d>=10&&n.roomKey?1:0;ac.encode(o,n.header),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.key),sc.encode(o,n.status),e.uint.encode(o,c),d>=10&&n.roomKey&&e.fixed32.encode(o,n.roomKey)},decode(o){const n=ac.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o),t=sc.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{header:n,memberKey:c,key:r,status:t,roomKey:d>=10&&1&i?e.fixed32.decode(o):null}}},uc={preencode(d,o){e.uint.preencode(d,o.timestamp),e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.mailbox)},encode(d,o){e.uint.encode(d,o.timestamp),e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.mailbox)},decode:d=>({version:0,timestamp:e.uint.decode(d),key:e.fixed32.decode(d),mailbox:e.fixed32.decode(d)})},lc={preencode(d,o){const n=o.version??1;switch(e.uint.preencode(d,n),n){case 0:case 1:uc.preencode(d,o);break;default:throw new Error("Unsupported version")}},encode(d,o){const n=o.version??1;switch(e.uint.encode(d,n),n){case 0:case 1:uc.encode(d,o);break;default:throw new Error("Unsupported version")}},decode(d){const o=e.uint.decode(d);switch(o){case 0:case 1:{const e=uc.decode(d);return e.version=o,e}default:throw new Error("Unsupported version")}}},fc=$,mc={preencode(o,c){fc.preencode(o,c.header),n.preencode(o,c.oplog),e.uint.preencode(o,c.index),ai.preencode(o,c.preview),o.end++,d>=7&&c.displayType&&Pc.preencode(o,c.displayType)},encode(o,c){const r=d>=7&&c.displayType?1:0;fc.encode(o,c.header),n.encode(o,c.oplog),e.uint.encode(o,c.index),ai.encode(o,c.preview),e.uint.encode(o,r),d>=7&&c.displayType&&Pc.encode(o,c.displayType)},decode(o){const c=fc.decode(o),r=n.decode(o),t=e.uint.decode(o),i=ai.decode(o),a=o.start<o.end?e.uint.decode(o):0;return{header:c,oplog:r,index:t,preview:i,displayType:d>=7&&1&a?Pc.decode(o):0}}},yc={preencode(o,n){o.end++,d>=3&&n.memberKey&&e.fixed32.preencode(o,n.memberKey)},encode(o,n){const c=d>=3&&n.memberKey?1:0;e.uint.encode(o,c),d>=3&&n.memberKey&&e.fixed32.encode(o,n.memberKey)},decode(o){const n=e.uint.decode(o);return{memberKey:d>=3&&1&n?e.fixed32.decode(o):null}}},bc=pe,xc={preencode(e,d){bc.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){bc.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:bc.decode(e),attestation:ne.decode(e)})},kc=$,vc={preencode(d,o){kc.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){kc.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:kc.decode(d),key:e.fixed32.decode(d)})},gc={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),ne.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){e.fixed32.encode(d,o.deviceKey),ne.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({deviceKey:e.fixed32.decode(d),privateProfileIdentity:ne.decode(d),deviceProof:e.buffer.decode(d)})},hc={preencode(o,n){e.fixed32.preencode(o,n.roomKey),e.fixed32.preencode(o,n.encryptionKey),e.fixed32.preencode(o,n.seed),o.end++,d>=6&&n.fastForwardTo&&e.fixed32.preencode(o,n.fastForwardTo)},encode(o,n){const c=d>=6&&n.fastForwardTo?1:0;e.fixed32.encode(o,n.roomKey),e.fixed32.encode(o,n.encryptionKey),e.fixed32.encode(o,n.seed),e.uint.encode(o,c),d>=6&&n.fastForwardTo&&e.fixed32.encode(o,n.fastForwardTo)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o);return{roomKey:n,encryptionKey:c,seed:r,fastForwardTo:d>=6&&1&t?e.fixed32.decode(o):null}}},Kc={preencode(o,n){e.fixed32.preencode(o,n.publicKey),e.fixed32.preencode(o,n.writerKey),e.fixed32.preencode(o,n.devicePublicKey),o.end++,d>=6&&n.privateProfileKey&&e.fixed32.preencode(o,n.privateProfileKey)},encode(o,n){const c=d>=6&&n.privateProfileKey?1:0;e.fixed32.encode(o,n.publicKey),e.fixed32.encode(o,n.writerKey),e.fixed32.encode(o,n.devicePublicKey),e.uint.encode(o,c),d>=6&&n.privateProfileKey&&e.fixed32.encode(o,n.privateProfileKey)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o);return{publicKey:n,writerKey:c,devicePublicKey:r,privateProfileKey:d>=6&&1&t?e.fixed32.decode(o):null}}},wc=$,Tc={preencode(d,o){wc.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey)},encode(d,o){wc.encode(d,o.header),e.fixed32.encode(d,o.memberKey)},decode:d=>({header:wc.decode(d),memberKey:e.fixed32.decode(d)})},Ac={HttpLink:1,PearLink:2},Pc={preencode(e,d){e.end++},encode(d,o){if(o>2)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Sc=$,Ic={preencode(d,o){Sc.preencode(d,o.header),e.uint.preencode(d,o.value)},encode(d,o){Sc.encode(d,o.header),e.uint.encode(d,o.value)},decode:d=>({header:Sc.decode(d),value:e.uint.decode(d)})},Rc={preencode(d,o){e.uint.preencode(d,o.key),e.uint.preencode(d,o.value)},encode(d,o){e.uint.encode(d,o.key),e.uint.encode(d,o.value)},decode:d=>({key:e.uint.decode(d),value:e.uint.decode(d)})},Fc=$,Hc={preencode(o,n){Fc.preencode(o,n.header),e.uint.preencode(o,n.from),e.uint.preencode(o,n.to),o.end++,d>=20&&n.buildType&&Br.preencode(o,n.buildType)},encode(o,n){const c=d>=20&&n.buildType?1:0;Fc.encode(o,n.header),e.uint.encode(o,n.from),e.uint.encode(o,n.to),e.uint.encode(o,c),d>=20&&n.buildType&&Br.encode(o,n.buildType)},decode(o){const n=Fc.decode(o),c=e.uint.decode(o),r=e.uint.decode(o),t=o.start<o.end?e.uint.decode(o):0;return{header:n,from:c,to:r,buildType:d>=20&&1&t?Br.decode(o):null}}},Mc={RoomType:1,IsExperimental:2,IsJoiningDisabled:3,IsAppendingDisabled:4,IsCallingDisabled:5,IsMembershipEventsDisabled:6,IsAttachmentsDisabled:7,IsLinksDisabled:8,IsRoomInviteHidden:9},Cc={preencode(e,d){e.end++},encode(d,o){if(o>9)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Dc={en:"en",it:"it",ru:"ru",es:"es",de:"de"},Vc={preencode(e,d){e.end++},encode(d,o){switch(o){case"en":e.uint.encode(d,1);break;case"it":e.uint.encode(d,2);break;case"ru":e.uint.encode(d,3);break;case"es":e.uint.encode(d,4);break;case"de":e.uint.encode(d,5);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"en";case 2:return"it";case 3:return"ru";case 4:return"es";case 5:return"de";default:return null}}},Lc=Dd,qc={preencode(d,o){Lc.preencode(d,o.range),Vc.preencode(d,o.language),e.string.preencode(d,o.text)},encode(d,o){Lc.encode(d,o.range),Vc.encode(d,o.language),e.string.encode(d,o.text)},decode:d=>({range:Lc.decode(d),language:Vc.decode(d),text:e.string.decode(d)})},Ec={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.key)},decode:d=>({deviceKey:e.fixed32.decode(d),key:e.fixed32.decode(d)})},Bc=$,zc={preencode(d,o){Bc.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){Bc.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:Bc.decode(d),key:e.fixed32.decode(d)})},Nc=$,jc={preencode(d,o){Nc.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){Nc.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:Nc.decode(d),key:e.fixed32.decode(d)})},Oc={Flag:1},Uc={preencode(e,d){e.end++},encode(d,o){if(o>1)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Jc={preencode(d,o){lo.preencode(d,o.id),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),Uc.preencode(d,o.label)},encode(d,o){lo.encode(d,o.id),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),Uc.encode(d,o.label)},decode:d=>({id:lo.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),label:Uc.decode(d)})},Gc=$,Qc={preencode(e,d){Gc.preencode(e,d.header),n.preencode(e,d.oplog),Uc.preencode(e,d.label)},encode(e,d){Gc.encode(e,d.header),n.encode(e,d.oplog),Uc.encode(e,d.label)},decode:e=>({header:Gc.decode(e),oplog:n.decode(e),label:Uc.decode(e)})},Wc=$,Xc={preencode(e,d){Wc.preencode(e,d.header),n.preencode(e,d.oplog),Uc.preencode(e,d.label)},encode(e,d){Wc.encode(e,d.header),n.encode(e,d.oplog),Uc.encode(e,d.label)},decode:e=>({header:Wc.decode(e),oplog:n.decode(e),label:Uc.decode(e)})},Yc={preencode(d,o){Uc.preencode(d,o.label),e.uint.preencode(d,o.count)},encode(d,o){Uc.encode(d,o.label),e.uint.encode(d,o.count)},decode:d=>({label:Uc.decode(d),count:e.uint.decode(d)})},Zc=e.array(e.frame(Yc)),$c={preencode(o,n){lo.preencode(o,n.id),e.uint.preencode(o,n.total),Zc.preencode(o,n.labels),e.uint.preencode(o,n.editedAt),o.end++,d>=15&&n.flagsClock&&e.uint.preencode(o,n.flagsClock),d>=15&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(d>=15&&n.flagsClock?1:0)|(d>=15&&n.version?2:0)|(d>=16&&n.isDeleted?4:0);lo.encode(o,n.id),e.uint.encode(o,n.total),Zc.encode(o,n.labels),e.uint.encode(o,n.editedAt),e.uint.encode(o,c),d>=15&&n.flagsClock&&e.uint.encode(o,n.flagsClock),d>=15&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=lo.decode(o),c=e.uint.decode(o),r=Zc.decode(o),t=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{id:n,total:c,labels:r,editedAt:t,flagsClock:d>=15&&1&i?e.uint.decode(o):0,version:d>=15&&2&i?e.uint.decode(o):0,isDeleted:d>=16&&!!(4&i)}}},_c=$,er={preencode(d,o){_c.preencode(d,o.header),e.uint.preencode(d,o.length)},encode(d,o){_c.encode(d,o.header),e.uint.encode(d,o.length)},decode:d=>({header:_c.decode(d),length:e.uint.decode(d)})},dr={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.length)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.length)},decode:d=>({memberKey:e.fixed32.decode(d),length:e.uint.decode(d)})},or=Z,nr={preencode(o,n){o.end++,d>=23&&n.profileSnoozeTime&&e.uint.preencode(o,n.profileSnoozeTime)},encode(o,n){const c=(d>=13&&n.disableReadReceipts?1:0)|(d>=21&&n.stripAttachmentMetadata?2:0)|(d>=23&&n.profileSnoozeTime?4:0);e.uint.encode(o,c),d>=23&&n.profileSnoozeTime&&e.uint.encode(o,n.profileSnoozeTime)},decode(o){const n=e.uint.decode(o);return{disableReadReceipts:d>=13&&!!(1&n),stripAttachmentMetadata:d>=21&&!!(2&n),profileSnoozeTime:d>=23&&4&n?e.uint.decode(o):0}}},cr={disableReadReceipts:"disableReadReceipts",stripAttachmentMetadata:"stripAttachmentMetadata",profileSnoozeTime:"profileSnoozeTime"},rr={preencode(e,d){e.end++},encode(d,o){switch(o){case"disableReadReceipts":e.uint.encode(d,1);break;case"stripAttachmentMetadata":e.uint.encode(d,2);break;case"profileSnoozeTime":e.uint.encode(d,3);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"disableReadReceipts";case 2:return"stripAttachmentMetadata";case 3:return"profileSnoozeTime";default:return null}}},tr=$,ir=e.frame(nr),ar={preencode(e,d){tr.preencode(e,d.header),rr.preencode(e,d.key),ir.preencode(e,d.settings)},encode(e,d){tr.encode(e,d.header),rr.encode(e,d.key),ir.encode(e,d.settings)},decode:e=>({header:tr.decode(e),key:rr.decode(e),settings:ir.decode(e)})},sr={Flag:1},pr={preencode(e,d){e.end++},encode(d,o){if(o>1)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},ur={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),pr.preencode(d,o.label)},encode(d,o){e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),pr.encode(d,o.label)},decode:d=>({key:e.fixed32.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),label:pr.decode(d)})},lr=$,fr={preencode(d,o){lr.preencode(d,o.header),e.fixed32.preencode(d,o.key),pr.preencode(d,o.label)},encode(d,o){lr.encode(d,o.header),e.fixed32.encode(d,o.key),pr.encode(d,o.label)},decode:d=>({header:lr.decode(d),key:e.fixed32.decode(d),label:pr.decode(d)})},mr={preencode(d,o){pr.preencode(d,o.label),e.uint.preencode(d,o.count)},encode(d,o){pr.encode(d,o.label),e.uint.encode(d,o.count)},decode:d=>({label:pr.decode(d),count:e.uint.decode(d)})},yr=e.array(e.frame(mr)),br={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.total),yr.preencode(d,o.labels),e.uint.preencode(d,o.editedAt),e.uint.preencode(d,o.flagsClock)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.total),yr.encode(d,o.labels),e.uint.encode(d,o.editedAt),e.uint.encode(d,o.flagsClock)},decode:d=>({key:e.fixed32.decode(d),total:e.uint.decode(d),labels:yr.decode(d),editedAt:e.uint.decode(d),flagsClock:e.uint.decode(d)})},xr={preencode(d,o){e.float64.preencode(d,o.latitude),e.float64.preencode(d,o.longitude)},encode(d,o){e.float64.encode(d,o.latitude),e.float64.encode(d,o.longitude)},decode:d=>({latitude:e.float64.decode(d),longitude:e.float64.decode(d)})},kr=$,vr={preencode(d,o){kr.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.fromDeviceKey)},encode(d,o){kr.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.fromDeviceKey)},decode:d=>({header:kr.decode(d),deviceKey:e.fixed32.decode(d),fromDeviceKey:e.fixed32.decode(d)})},gr=$,hr=X,Kr={preencode(o,n){gr.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),e.buffer.preencode(o,n.encryptionKey),o.end++,d>=19&&n.streams&&hr.preencode(o,n.streams),d>=19&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=19&&n.version&&e.uint.preencode(o,n.version),d>=26&&n.streamInputs&&si.preencode(o,n.streamInputs),d>=26&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey)},encode(o,n){const c=(d>=19&&n.streams?1:0)|(d>=19&&n.discoveryKey?2:0)|(d>=19&&n.version?4:0)|(d>=26&&n.streamInputs?8:0)|(d>=26&&n.swarmKey?16:0);gr.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,c),d>=19&&n.streams&&hr.encode(o,n.streams),d>=19&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=19&&n.version&&e.uint.encode(o,n.version),d>=26&&n.streamInputs&&si.encode(o,n.streamInputs),d>=26&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey)},decode(o){const n=gr.decode(o),c=e.fixed32.decode(o),r=e.buffer.decode(o),t=e.uint.decode(o);return{header:n,callKey:c,encryptionKey:r,streams:d>=19&&1&t?hr.decode(o):null,discoveryKey:d>=19&&2&t?e.fixed32.decode(o):null,version:d>=19&&4&t?e.uint.decode(o):0,streamInputs:d>=26&&8&t?si.decode(o):null,swarmKey:d>=26&&16&t?e.fixed32.decode(o):null}}},wr=$,Tr=X,Ar={preencode(o,n){wr.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),o.end++,d>=19&&n.streams&&Tr.preencode(o,n.streams),d>=26&&n.streamInputs&&pi.preencode(o,n.streamInputs),d>=26&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey)},encode(o,n){const c=(d>=19&&n.streams?1:0)|(d>=26&&n.streamInputs?2:0)|(d>=26&&n.swarmKey?4:0);wr.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.uint.encode(o,c),d>=19&&n.streams&&Tr.encode(o,n.streams),d>=26&&n.streamInputs&&pi.encode(o,n.streamInputs),d>=26&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey)},decode(o){const n=wr.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{header:n,callKey:c,streams:d>=19&&1&r?Tr.decode(o):null,streamInputs:d>=26&&2&r?pi.decode(o):null,swarmKey:d>=26&&4&r?e.fixed32.decode(o):null}}},Pr=$,Sr={preencode(d,o){Pr.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Pr.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Pr.decode(d),callKey:e.fixed32.decode(d)})},Ir=$,Rr={preencode(d,o){Ir.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Ir.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Ir.decode(d),callKey:e.fixed32.decode(d)})},Fr=$,Hr={preencode(o,n){Fr.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.streamKey),o.end++,d>=26&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=26&&n.type&&e.string.preencode(o,n.type)},encode(o,n){const c=(d>=26&&n.mediaStreamId?1:0)|(d>=26&&n.type?2:0)|(d>=26&&n.muted?4:0);Fr.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.streamKey),e.uint.encode(o,c),d>=26&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=26&&n.type&&e.string.encode(o,n.type)},decode(o){const n=Fr.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=o.start<o.end?e.uint.decode(o):0;return{header:n,callKey:c,streamKey:r,mediaStreamId:d>=26&&1&t?e.string.decode(o):null,type:d>=26&&2&t?e.string.decode(o):null,muted:d>=26&&!!(4&t)}}},Mr=$,Cr={preencode(d,o){Mr.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.streamKey)},encode(d,o){Mr.encode(d,o.header),e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.streamKey)},decode:d=>({header:Mr.decode(d),callKey:e.fixed32.decode(d),streamKey:e.fixed32.decode(d)})},Dr={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.buffer.preencode(o,n.encryptionKey),e.uint.preencode(o,n.createdAt),o.end++,d>=19&&n.endedAt&&e.uint.preencode(o,n.endedAt),d>=19&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=19&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(d>=19&&n.endedAt?1:0)|(d>=19&&n.discoveryKey?2:0)|(d>=19&&n.version?4:0);e.fixed32.encode(o,n.callKey),e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=19&&n.endedAt&&e.uint.encode(o,n.endedAt),d>=19&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=19&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=e.fixed32.decode(o),c=e.buffer.decode(o),r=e.uint.decode(o),t=e.uint.decode(o);return{callKey:n,encryptionKey:c,createdAt:r,endedAt:d>=19&&1&t?e.uint.decode(o):0,discoveryKey:d>=19&&2&t?e.fixed32.decode(o):null,version:d>=19&&4&t?e.uint.decode(o):0}}},Vr={preencode(d,o){e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.createdAt)},encode(d,o){e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.createdAt)},decode:d=>({callKey:e.fixed32.decode(d),memberKey:e.fixed32.decode(d),createdAt:e.uint.decode(d)})},Lr={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.deviceKey),e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.createdAt),o.end++,d>=19&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),d>=22&&n.lastHeartbeatAt&&e.uint.preencode(o,n.lastHeartbeatAt)},encode(o,n){const c=(d>=19&&n.swarmKey?1:0)|(d>=22&&n.lastHeartbeatAt?2:0)|(d>=23&&n.isRecording?4:0);e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.deviceKey),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=19&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey),d>=22&&n.lastHeartbeatAt&&e.uint.encode(o,n.lastHeartbeatAt)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o),i=e.uint.decode(o);return{callKey:n,deviceKey:c,memberKey:r,createdAt:t,swarmKey:d>=19&&1&i?e.fixed32.decode(o):null,lastHeartbeatAt:d>=22&&2&i?e.uint.decode(o):0,isRecording:d>=23&&!!(4&i)}}},qr={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.deviceKey),e.buffer.preencode(o,n.streamKey),e.uint.preencode(o,n.createdAt),o.end++,d>=26&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=26&&n.type&&e.string.preencode(o,n.type),d>=26&&n.statusKey&&e.uint.preencode(o,n.statusKey)},encode(o,n){const c=(d>=26&&n.mediaStreamId?1:0)|(d>=26&&n.type?2:0)|(d>=26&&n.statusKey?4:0);e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.deviceKey),e.buffer.encode(o,n.streamKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=26&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=26&&n.type&&e.string.encode(o,n.type),d>=26&&n.statusKey&&e.uint.encode(o,n.statusKey)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.buffer.decode(o),t=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{callKey:n,deviceKey:c,streamKey:r,createdAt:t,mediaStreamId:d>=26&&1&i?e.string.decode(o):null,type:d>=26&&2&i?e.string.decode(o):null,statusKey:d>=26&&4&i?e.uint.decode(o):0}}},Er={Nightly:"Nightly",Internal:"Internal",Production:"Production"},Br={preencode(e,d){e.end++},encode(d,o){switch(o){case"Nightly":e.uint.encode(d,1);break;case"Internal":e.uint.encode(d,2);break;case"Production":e.uint.encode(d,3);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"Nightly";case 2:return"Internal";case 3:return"Production";default:return null}}},zr=$,Nr={preencode(e,d){zr.preencode(e,d.header)},encode(e,d){zr.encode(e,d.header)},decode:e=>({header:zr.decode(e)})},jr=$,Or={preencode(e,d){jr.preencode(e,d.header)},encode(e,d){jr.encode(e,d.header)},decode:e=>({header:jr.decode(e)})},Ur=$,Jr={preencode(d,o){Ur.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),e.buffer.preencode(d,o.deviceProof),e.buffer.preencode(d,o.writerProof)},encode(d,o){Ur.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.buffer.encode(d,o.deviceProof),e.buffer.encode(d,o.writerProof)},decode:d=>({header:Ur.decode(d),deviceKey:e.fixed32.decode(d),deviceProof:e.buffer.decode(d),writerProof:e.buffer.decode(d)})},Gr=$,Qr={preencode(d,o){Gr.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Gr.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Gr.decode(d),callKey:e.fixed32.decode(d)})},Wr=$,Xr={preencode(d,o){Wr.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.deviceKey)},encode(d,o){Wr.encode(d,o.header),e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.deviceKey)},decode:d=>({header:Wr.decode(d),callKey:e.fixed32.decode(d),deviceKey:e.fixed32.decode(d)})},Yr=$,Zr={preencode(d,o){Yr.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Yr.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Yr.decode(d),callKey:e.fixed32.decode(d)})},$r=$,_r={preencode(d,o){$r.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){$r.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:$r.decode(d),callKey:e.fixed32.decode(d)})},et=$,dt={preencode(e,d){et.preencode(e,d.header),n.preencode(e,d.oplog)},encode(e,d){et.encode(e,d.header),n.encode(e,d.oplog)},decode:e=>({header:et.decode(e),oplog:n.decode(e)})},ot=$,nt={preencode(e,d){ot.preencode(e,d.header)},encode(e,d){ot.encode(e,d.header)},decode:e=>({header:ot.decode(e)})},ct={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.timestamp)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.timestamp)},decode:d=>({memberKey:e.fixed32.decode(d),timestamp:e.uint.decode(d)})},rt=$,tt={preencode(o,n){rt.preencode(o,n.header),e.fixed32.preencode(o,n.memberKey),o.end++,d>=24&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=d>=24&&n.alias?1:0;rt.encode(o,n.header),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,c),d>=24&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=rt.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{header:n,memberKey:c,alias:d>=24&&1&r?e.string.decode(o):null}}},it={preencode(d,o){e.uint.preencode(d,o.streams)},encode(d,o){e.uint.encode(d,o.streams)},decode:d=>({streams:e.uint.decode(d)})},at={preencode(d,o){e.fixed32.preencode(d,o.streamKey),e.string.preencode(d,o.mediaStreamId),e.string.preencode(d,o.type),d.end++},encode(o,n){const c=d>=26&&n.muted?1:0;e.fixed32.encode(o,n.streamKey),e.string.encode(o,n.mediaStreamId),e.string.encode(o,n.type),e.uint.encode(o,c)},decode(o){const n=e.fixed32.decode(o),c=e.string.decode(o),r=e.string.decode(o),t=e.uint.decode(o);return{streamKey:n,mediaStreamId:c,type:r,muted:d>=26&&!!(1&t)}}},st=$,pt={preencode(d,o){st.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.streamKey),d.end++},encode(o,n){const c=d>=26&&n.muted?1:0;st.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.streamKey),e.uint.encode(o,c)},decode(o){const n=st.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o);return{header:n,callKey:c,streamKey:r,muted:d>=26&&!!(1&t)}}},ut={preencode(d,o){e.uint.preencode(d,o.statusKey),d.end++},encode(o,n){const c=d>=26&&n.muted?1:0;e.uint.encode(o,n.statusKey),e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o),c=e.uint.decode(o);return{statusKey:n,muted:d>=26&&!!(1&c)}}},lt={preencode(n,c){e.fixed32.preencode(n,c.key),n.end++,d>=27&&c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=(d>=27&&c.encryptionKey?1:0)|(d>=27&&c.bootFrom?2:0);e.fixed32.encode(n,c.key),e.uint.encode(n,r),d>=27&&c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.uint.decode(n);return{key:c,encryptionKey:d>=27&&1&r?e.buffer.decode(n):null,bootFrom:d>=27&&2&r?o.decode(n):null}}},ft={preencode(d,o){e.fixed32.preencode(d,o.hash)},encode(d,o){e.fixed32.encode(d,o.hash)},decode:d=>({hash:e.fixed32.decode(d)})},mt={preencode(d,o){e.fixed32.preencode(d,o.hash),e.buffer.preencode(d,o.data)},encode(d,o){e.fixed32.encode(d,o.hash),e.buffer.encode(d,o.data)},decode:d=>({hash:e.fixed32.decode(d),data:e.buffer.decode(d)})},yt={preencode(n,c){o.preencode(n,c.autobeeMigrationHead),n.end++,d>=27&&c.legacyViewHead&&o.preencode(n,c.legacyViewHead),d>=27&&c.dbViewHead&&o.preencode(n,c.dbViewHead),d>=27&&c.blobsViewHead&&o.preencode(n,c.blobsViewHead),e.uint.preencode(n,c.createdAt)},encode(n,c){const r=(d>=27&&c.legacyViewHead?1:0)|(d>=27&&c.dbViewHead?2:0)|(d>=27&&c.blobsViewHead?4:0);o.encode(n,c.autobeeMigrationHead),e.uint.encode(n,r),d>=27&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=27&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=27&&c.blobsViewHead&&o.encode(n,c.blobsViewHead),e.uint.encode(n,c.createdAt)},decode(n){const c=o.decode(n),r=e.uint.decode(n);return{autobeeMigrationHead:c,legacyViewHead:d>=27&&1&r?o.decode(n):null,dbViewHead:d>=27&&2&r?o.decode(n):null,blobsViewHead:d>=27&&4&r?o.decode(n):null,createdAt:e.uint.decode(n)}}},bt=$,xt={preencode(e,n){bt.preencode(e,n.header),o.preencode(e,n.head),e.end++,d>=27&&n.legacyViewHead&&o.preencode(e,n.legacyViewHead),d>=27&&n.dbViewHead&&o.preencode(e,n.dbViewHead),d>=27&&n.blobsViewHead&&o.preencode(e,n.blobsViewHead)},encode(n,c){const r=(d>=27&&c.legacyViewHead?1:0)|(d>=27&&c.dbViewHead?2:0)|(d>=27&&c.blobsViewHead?4:0);bt.encode(n,c.header),o.encode(n,c.head),e.uint.encode(n,r),d>=27&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=27&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=27&&c.blobsViewHead&&o.encode(n,c.blobsViewHead)},decode(n){const c=bt.decode(n),r=o.decode(n),t=e.uint.decode(n);return{header:c,head:r,legacyViewHead:d>=27&&1&t?o.decode(n):null,dbViewHead:d>=27&&2&t?o.decode(n):null,blobsViewHead:d>=27&&4&t?o.decode(n):null}}},kt={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.fixed32.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.seed),n.end++,d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=d>=27&&c.bootFrom?1:0;e.fixed32.encode(n,c.roomKey),e.fixed32.encode(n,c.encryptionKey),e.fixed32.encode(n,c.seed),e.uint.encode(n,r),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.fixed32.decode(n),t=e.fixed32.decode(n),i=e.uint.decode(n);return{roomKey:c,encryptionKey:r,seed:t,bootFrom:d>=27&&1&i?o.decode(n):null}}},vt=id,gt={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.fixed32.preencode(d,o.deviceKey),e.uint.preencode(d,o.deviceLength),e.uint.preencode(d,o.clock),vt.preencode(d,o.status)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,o.deviceLength),e.uint.encode(d,o.clock),vt.encode(d,o.status)},decode:d=>({memberKey:e.fixed32.decode(d),deviceKey:e.fixed32.decode(d),deviceLength:e.uint.decode(d),clock:e.uint.decode(d),status:vt.decode(d)})},ht={preencode(d,o){e.fixed32.preencode(d,o.hash),e.buffer.preencode(d,o.blob)},encode(d,o){e.fixed32.encode(d,o.hash),e.buffer.encode(d,o.blob)},decode:d=>({hash:e.fixed32.decode(d),blob:e.buffer.decode(d)})},Kt=Fn,wt=Hn,Tt=vn,At={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),Kt.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,d>=27&&c.initiator&&o.preencode(n,c.initiator),d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=27&&c.identitySwap&&wt.preencode(n,c.identitySwap),d>=27&&c.identitySwapV2&&Tt.preencode(n,c.identitySwapV2),d>=27&&c.contact&&e.fixed32.preencode(n,c.contact)},encode(n,c){const r=(d>=27&&c.initiator?1:0)|(d>=27&&c.bootFrom?2:0)|(d>=27&&c.identitySwap?4:0)|(d>=27&&c.identitySwapV2?8:0)|(d>=27&&c.contact?16:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),Kt.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,r),d>=27&&c.initiator&&o.encode(n,c.initiator),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom),d>=27&&c.identitySwap&&wt.encode(n,c.identitySwap),d>=27&&c.identitySwapV2&&Tt.encode(n,c.identitySwapV2),d>=27&&c.contact&&e.fixed32.encode(n,c.contact)},decode(n){const c=e.fixed32.decode(n),r=e.buffer.decode(n),t=e.fixed32.decode(n),i=Kt.decode(n),a=e.uint.decode(n),s=e.uint.decode(n);return{roomKey:c,encryptionKey:r,mailbox:t,status:i,clock:a,initiator:d>=27&&1&s?o.decode(n):null,bootFrom:d>=27&&2&s?o.decode(n):null,identitySwap:d>=27&&4&s?wt.decode(n):null,identitySwapV2:d>=27&&8&s?Tt.decode(n):null,contact:d>=27&&16&s?e.fixed32.decode(n):null}}},Pt=$,St={preencode(n,c){Pt.preencode(n,c.header),e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),n.end++,d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=27&&c.initiator&&o.preencode(n,c.initiator),d>=27&&c.dm&&e.fixed32.preencode(n,c.dm)},encode(n,c){const r=(d>=27&&c.bootFrom?1:0)|(d>=27&&c.initiator?2:0)|(d>=27&&c.dm?4:0)|(d>=27&&c.isReadOnly?8:0);Pt.encode(n,c.header),e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),e.uint.encode(n,r),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom),d>=27&&c.initiator&&o.encode(n,c.initiator),d>=27&&c.dm&&e.fixed32.encode(n,c.dm)},decode(n){const c=Pt.decode(n),r=e.fixed32.decode(n),t=e.buffer.decode(n),i=e.fixed32.decode(n),a=e.uint.decode(n);return{header:c,roomKey:r,encryptionKey:t,mailbox:i,bootFrom:d>=27&&1&a?o.decode(n):null,initiator:d>=27&&2&a?o.decode(n):null,dm:d>=27&&4&a?e.fixed32.decode(n):null,isReadOnly:d>=27&&!!(8&a)}}},It={preencode(d,o){e.fixed32.preencode(d,o.id),e.fixed32.preencode(d,o.writerKey),e.buffer.preencode(d,o.blindResponse)},encode(d,o){e.fixed32.encode(d,o.id),e.fixed32.encode(d,o.writerKey),e.buffer.encode(d,o.blindResponse)},decode:d=>({id:e.fixed32.decode(d),writerKey:e.fixed32.decode(d),blindResponse:e.buffer.decode(d)})},Rt=$,Ft={preencode(d,o){Rt.preencode(d,o.header),e.buffer.preencode(d,o.blindResponse)},encode(d,o){Rt.encode(d,o.header),e.buffer.encode(d,o.blindResponse)},decode:d=>({header:Rt.decode(d),blindResponse:e.buffer.decode(d)})},Ht=$,Mt={preencode(e,d){Ht.preencode(e,d.header)},encode(e,d){Ht.encode(e,d.header)},decode:e=>({header:Ht.decode(e)})},Ct=$,Dt={preencode(o,c){Ct.preencode(o,c.header),n.preencode(o,c.oplog),e.uint.preencode(o,c.index),o.end++,d>=30&&c.displayType&&Pc.preencode(o,c.displayType)},encode(o,c){const r=d>=30&&c.displayType?1:0;Ct.encode(o,c.header),n.encode(o,c.oplog),e.uint.encode(o,c.index),e.uint.encode(o,r),d>=30&&c.displayType&&Pc.encode(o,c.displayType)},decode(o){const c=Ct.decode(o),r=n.decode(o),t=e.uint.decode(o),i=e.uint.decode(o);return{header:c,oplog:r,index:t,displayType:d>=30&&1&i?Pc.decode(o):0}}},Vt=$,Lt=jd,qt={preencode(d,o){Vt.preencode(d,o.header),n.preencode(d,o.oplog),Pc.preencode(d,o.displayType),e.uint.preencode(d,o.index),Lt.preencode(d,o.preview)},encode(d,o){Vt.encode(d,o.header),n.encode(d,o.oplog),Pc.encode(d,o.displayType),e.uint.encode(d,o.index),Lt.encode(d,o.preview)},decode:d=>({header:Vt.decode(d),oplog:n.decode(d),displayType:Pc.decode(d),index:e.uint.decode(d),preview:Lt.decode(d)})},Et=$,Bt={preencode(d,o){Et.preencode(d,o.header),n.preencode(d,o.oplog),Pc.preencode(d,o.displayType),e.uint.preencode(d,o.index)},encode(d,o){Et.encode(d,o.header),n.encode(d,o.oplog),Pc.encode(d,o.displayType),e.uint.encode(d,o.index)},decode:d=>({header:Et.decode(d),oplog:n.decode(d),displayType:Pc.decode(d),index:e.uint.decode(d)})},zt=e.frame(w),Nt=e.frame(it),jt=zt,Ot=e.array(Vc),Ut=e.frame(se),Jt=zt,Gt=Ut,Qt=e.frame(hc),Wt=e.frame(kt),Xt=Ut,Yt=e.frame(fd),Zt=e.frame(yc),$t=e.frame(xr),_t=$t,ei=e.array(e.frame(qc)),di=zt,oi=e.frame(Nn),ni=e.frame(xc),ci=oi,ri=ni,ti=oi,ii=ni,ai=zt,si=e.array(e.frame(at)),pi=si;function ui(e){switch(e){case"@keet/head":return o;case"@keet/oplog-id":return n;case"@keet/encryption-keypair":return c;case"@keet/signing-keypair":return r;case"@keet/room-keys":return t;case"@keet/operation-header":return i;case"@keet/blob-pointer":return a;case"@keet/file-dimensions":return s;case"@keet/file-metadata":return u;case"@keet/external-drive-pointer":return l;case"@keet/external-blob-pointer":return f;case"@keet/file-pointer":return b;case"@keet/file":return v;case"@keet/image-file":return w;case"@keet/file-status":return T;case"@keet/file-record":return S;case"@keet/device-status":return I;case"@keet/member-status":return R;case"@keet/member-moderation-status":return F;case"@keet/abi":return H;case"@keet/device-stats":return M;case"@keet/member-stats":return C;case"@keet/chat-stats":return D;case"@keet/file-stats":return V;case"@keet/stats":return z;case"@keet/room-type":return j;case"@keet/system-settings":return O;case"@keet/system-digest":return G;case"@keet/room-seed":return Q;case"@keet/room-capabilities":return W;case"@keet/room-config":return Y;case"@keet/blind-peer":return Z;case"@keet/add-blind-peer-operation":return ee;case"@keet/remove-blind-peer-operation":return oe;case"@keet/identity-attestation":return ne;case"@keet/device-invitation":return ce;case"@keet/device":return ie;case"@keet/member-profile":return ae;case"@keet/device-profile":return se;case"@keet/member-update":return ue;case"@keet/device-update":return le;case"@keet/signed-pairing-data":return fe;case"@keet/device-request-identity":return me;case"@keet/device-response-identity":return ye;case"@keet/device-request-with-invitation":return ve;case"@keet/device-request-with-invitation-and-proof":return he;case"@keet/device-request-with-member-proof":return Te;case"@keet/device-request":return Se;case"@keet/device-response":return Fe;case"@keet/invitation-metadata":return He;case"@keet/invitation":return De;case"@keet/add-invitation-operation":return qe;case"@keet/remove-invitation-operation":return Be;case"@keet/sendable-room-invitation":return ze;case"@keet/sendable-identity-invitation":return Ne;case"@keet/sendable-contact-invitation":return je;case"@keet/sendable-invitation":return Qe;case"@keet/add-device-operation":return Xe;case"@keet/update-device-operation":return Ze;case"@keet/start-indexing-operation":return $e;case"@keet/stop-indexing-operation":return _e;case"@keet/join-request":return dd;case"@keet/accept-join-request-operation":return cd;case"@keet/reject-join-request-operation":return td;case"@keet/member":return sd;case"@keet/full-member":return ld;case"@keet/member-proofs":return fd;case"@keet/update-member-operation":return bd;case"@keet/change-member-status-operation":return vd;case"@keet/change-member-role-operation":return hd;case"@keet/remove-member-operation":return wd;case"@keet/member-activity":return Td;case"@keet/member-joined-event":return Ad;case"@keet/member-left-event":return Pd;case"@keet/title-changed-chat-event":return Sd;case"@keet/chat-event":return Hd;case"@keet/sendable-event":return Md;case"@keet/display-range":return Cd;case"@keet/display-content-range":return Vd;case"@keet/mention-display-item":return qd;case"@keet/link-preview":return zd;case"@keet/display-link-item":return Od;case"@keet/display":return _d;case"@keet/oplog-message":return co;case"@keet/index-message":return io;case"@keet/full-index-message":return po;case"@keet/message-status":return uo;case"@keet/message-index-id":return lo;case"@keet/thread":return mo;case"@keet/chat-message-record":return ko;case"@keet/full-chat-message-record":return Ko;case"@keet/add-chat-message-operation":return Ao;case"@keet/remove-chat-message-operation":return So;case"@keet/update-chat-message-operation":return Fo;case"@keet/pin-chat-message-operation":return Mo;case"@keet/reaction":return Co;case"@keet/reactions-summary":return Do;case"@keet/reactions-digest":return Lo;case"@keet/add-reaction-operation":return Eo;case"@keet/remove-reaction-operation":return zo;case"@keet/update-room-config-operation":return Oo;case"@keet/group-member":return Uo;case"@keet/user-registry-info":return Jo;case"@keet/room-identity":return Qo;case"@keet/genesis-operation":return dn;case"@keet/upgrade-operation":return nn;case"@keet/update-system-settings-operation":return tn;case"@keet-private-id/contact":return an;case"@keet-private-id/v3-room-migration-info":return sn;case"@keet-private-id/run-v3-migration-operation":return ln;case"@keet-private-id/update-identity-operation":return mn;case"@keet-private-id/counters":return yn;case"@keet-private-id/stats":return bn;case"@keet-private-id/add-entropy-operation":return xn;case"@keet-private-id/pending-invitation-identity":return kn;case"@keet-private-id/pending-invitation":return gn;case"@keet-private-id/resolve-pending-invitation-operation":return Kn;case"@keet-private-id/add-pending-invitation-operation":return An;case"@keet-private-id/remove-pending-invitation-operation":return Sn;case"@keet-private-id/identity-swap":return In;case"@keet-private-id/room-status":return Rn;case"@keet-private-id/room":return Cn;case"@keet-private-id/add-room-operation":return Vn;case"@keet-private-id/remove-room-operation":return qn;case"@keet-private-id/update-room-status-operation":return zn;case"@keet-private-id/contact-status":return Nn;case"@keet-private-id/contact-record":return jn;case"@keet-private-id/add-contact-operation":return Jn;case"@keet-private-id/update-contact-status-operation":return Qn;case"@keet-private-id/remove-contact-operation":return Xn;case"@keet-private-id/contact-request-status":return Yn;case"@keet-private-id/contact-request-body":return _n;case"@keet-private-id/contact-request":return dc;case"@keet-private-id/contact-request-record":return rc;case"@keet-private-id/add-contact-request-operation":return ic;case"@keet-private-id/update-contact-request-status-operation":return pc;case"@keet-private-id/profile-discovery-record-v1":return uc;case"@keet-private-id/profile-discovery-record":return lc;case"@keet/add-file-preview-operation":return mc;case"@keet/member-removed-event":return yc;case"@keet/member-contact-info":return xc;case"@keet/remove-device-operation":return vc;case"@keet/device-identity":return gc;case"@keet/readonly-room-invitation":return hc;case"@keet-private-id/identity-swap-v2":return Kc;case"@keet-private-id/activate-contact-room-operation":return Tc;case"@keet/display-type":return Pc;case"@keet/test-increment-operation":return Ic;case"@keet/test-collection-record-1":return Rc;case"@keet/migrate-abi-operation":return Hc;case"@keet/system-settings-keys":return Cc;case"@keet/room-supported-language":return Vc;case"@keet/translation-display-item":return qc;case"@keet-private-id/unreads":return Ec;case"@keet-private-id/add-unreads-key-operation":return zc;case"@keet-private-id/remove-unreads-key-operation":return jc;case"@keet/label-type":return Uc;case"@keet/chat-label":return Jc;case"@keet/add-chat-label-operation":return Qc;case"@keet/remove-chat-label-operation":return Xc;case"@keet/chat-label-summary":return Yc;case"@keet/chat-label-digest":return $c;case"@keet/update-read-length-operation":return er;case"@keet/read-length":return dr;case"@keet/tmp-removed-member":return or;case"@keet-private-id/settings":return nr;case"@keet-private-id/user-settings-key":return rr;case"@keet-private-id/update-settings-operation":return ar;case"@keet/member-label-type":return pr;case"@keet/member-label":return ur;case"@keet/add-member-label-operation":return fr;case"@keet/member-label-summary":return mr;case"@keet/member-label-digest":return br;case"@keet/location-shared-event":return xr;case"@keet/move-indexer-operation":return vr;case"@keet/start-call":return Kr;case"@keet/join-call":return Ar;case"@keet/leave-call":return Sr;case"@keet/end-call":return Rr;case"@keet/add-call-stream":return Hr;case"@keet/remove-call-stream":return Cr;case"@keet/call-record":return Dr;case"@keet/call-member-record":return Vr;case"@keet/call-device-record":return Lr;case"@keet/call-stream-record":return qr;case"@keet/build-type":return Br;case"@keet/test-crash-operation":return Nr;case"@keet/test-dispatch-error-operation":return Or;case"@keet-private-id/shorten-device-attestation-operation":return Jr;case"@keet/call-device-heartbeat":return Qr;case"@keet/remove-call-device":return Xr;case"@keet/start-call-recording":return Zr;case"@keet/stop-call-recording":return _r;case"@keet/dismiss-chat-reports-operation":return dt;case"@keet/update-typing-indicator-operation":return nt;case"@keet/typing-indicator":return ct;case"@keet-private-id/update-contact-alias-operation":return tt;case"@keet/call-stats":return it;case"@keet/call-stream-input":return at;case"@keet/update-call-stream":return pt;case"@keet/call-stream-status-record":return ut;case"@keet/room-keys-v2":return lt;case"@keet/blob-pointer-v2":return ft;case"@keet/blob":return mt;case"@keet/autobee-migration":return yt;case"@keet/autobee-migration-operation":return xt;case"@keet/readonly-room-invitation-v2":return kt;case"@keet/admin-last-seen":return gt;case"@keet/blob-record":return ht;case"@keet-private-id/room-v2":return At;case"@keet-private-id/add-room-operation-v2":return St;case"@keet-private-id/pending-invitation-response":return It;case"@keet-private-id/resolve-pending-invitation-operation-v2":return Ft;case"@keet/claim-admin-devices-operation":return Mt;case"@keet/remove-file-preview-operation":return Dt;case"@keet/add-link-preview-operation":return qt;case"@keet/remove-link-preview-operation":return Bt;default:throw new Error("Encoder not found "+e)}}function li(e,o=31){const n=ui(e);return{preencode(e,c){d=o,n.preencode(e,c)},encode(e,c){d=o,n.encode(e,c)},decode:e=>(d=o,n.decode(e))}}const fi=li;module.exports={resolveStruct:fi,getStruct:li,getEnum:function(e){switch(e){case"@keet/room-type":return N;case"@keet/display-type":return Ac;case"@keet/system-settings-keys":return Mc;case"@keet/room-supported-language":return Dc;case"@keet/label-type":return Oc;case"@keet-private-id/user-settings-key":return cr;case"@keet/member-label-type":return sr;case"@keet/build-type":return Er;default:throw new Error("Enum not found "+e)}},getEncoding:ui,encode:function(o,n,c=31){return d=c,e.encode(ui(o),n)},decode:function(o,n,c=31){return d=c,e.decode(ui(o),n)},setVersion:function(e){d=e},version:d};
@holepunchto/keet-core/schema/spec/contract/hyperschema/index.js +1 -1
……@@ -1 +1 @@
1const{c:e}=require("hyperschema/runtime");let d=29;const o={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.length)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.length)},decode:d=>({key:e.fixed32.decode(d),length:e.uint.decode(d)})},n={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.seq)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.seq)},decode:d=>({key:e.fixed32.decode(d),seq:e.uint.decode(d)})},c={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.secretKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.secretKey)},decode:d=>({publicKey:e.fixed32.decode(d),secretKey:e.fixed32.decode(d)})},t={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed64.preencode(d,o.secretKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed64.encode(d,o.secretKey)},decode:d=>({publicKey:e.fixed32.decode(d),secretKey:e.fixed64.decode(d)})},r={preencode(n,c){e.fixed32.preencode(n,c.key),n.end++,c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const t=(c.encryptionKey?1:0)|(c.fastForwardTo?2:0)|(d>=27&&c.bootFrom?4:0);e.fixed32.encode(n,c.key),e.uint.encode(n,t),c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),t=e.uint.decode(n);return{key:c,encryptionKey:1&t?e.buffer.decode(n):null,fastForwardTo:2&t?e.fixed32.decode(n):null,bootFrom:d>=27&&4&t?o.decode(n):null}}},i={preencode(d,o){e.uint.preencode(d,o.timestamp)},encode(d,o){e.uint.encode(d,o.timestamp)},decode:d=>({timestamp:e.uint.decode(d)})},a={preencode(d,o){e.uint.preencode(d,o.blockOffset),e.uint.preencode(d,o.blockLength),e.uint.preencode(d,o.byteOffset),e.uint.preencode(d,o.byteLength)},encode(d,o){e.uint.encode(d,o.blockOffset),e.uint.encode(d,o.blockLength),e.uint.encode(d,o.byteOffset),e.uint.encode(d,o.byteLength)},decode:d=>({blockOffset:e.uint.decode(d),blockLength:e.uint.decode(d),byteOffset:e.uint.decode(d),byteLength:e.uint.decode(d)})},s={preencode(d,o){e.uint.preencode(d,o.width),e.uint.preencode(d,o.height)},encode(d,o){e.uint.encode(d,o.width),e.uint.encode(d,o.height)},decode:d=>({width:e.uint.decode(d),height:e.uint.decode(d)})},p=e.frame(s),u={preencode(d,o){d.end++,o.name&&e.string.preencode(d,o.name),o.mimetype&&e.string.preencode(d,o.mimetype),o.dimensions&&p.preencode(d,o.dimensions),o.userdata&&e.buffer.preencode(d,o.userdata),o.duration&&e.uint.preencode(d,o.duration)},encode(d,o){const n=(o.name?1:0)|(o.mimetype?2:0)|(o.dimensions?4:0)|(o.userdata?8:0)|(o.duration?16:0)|(o.isPreview?32:0);e.uint.encode(d,n),o.name&&e.string.encode(d,o.name),o.mimetype&&e.string.encode(d,o.mimetype),o.dimensions&&p.encode(d,o.dimensions),o.userdata&&e.buffer.encode(d,o.userdata),o.duration&&e.uint.encode(d,o.duration)},decode(d){const o=e.uint.decode(d);return{name:1&o?e.string.decode(d):null,mimetype:2&o?e.string.decode(d):null,dimensions:4&o?p.decode(d):null,userdata:8&o?e.buffer.decode(d):null,duration:16&o?e.uint.decode(d):0,isPreview:!!(32&o)}}},l={preencode(d,o){e.fixed32.preencode(d,o.key),e.string.preencode(d,o.path),e.uint.preencode(d,o.version),e.uint.preencode(d,o.size)},encode(d,o){e.fixed32.encode(d,o.key),e.string.encode(d,o.path),e.uint.encode(d,o.version),e.uint.encode(d,o.size)},decode:d=>({key:e.fixed32.decode(d),path:e.string.decode(d),version:e.uint.decode(d),size:e.uint.decode(d)})},f={preencode(d,o){e.fixed32.preencode(d,o.key),a.preencode(d,o.blob)},encode(d,o){e.fixed32.encode(d,o.key),a.encode(d,o.blob)},decode:d=>({key:e.fixed32.decode(d),blob:a.decode(d)})},m=e.frame(f),y=e.frame(l),b={preencode(o,n){o.end++,n.inlined&&e.buffer.preencode(o,n.inlined),n.blob&&a.preencode(o,n.blob),n.externalBlob&&m.preencode(o,n.externalBlob),n.externalDrive&&y.preencode(o,n.externalDrive),d>=27&&n.bee&&fr.preencode(o,n.bee)},encode(o,n){const c=(n.inlined?1:0)|(n.blob?2:0)|(n.externalBlob?4:0)|(n.externalDrive?8:0)|(d>=27&&n.bee?16:0);e.uint.encode(o,c),n.inlined&&e.buffer.encode(o,n.inlined),n.blob&&a.encode(o,n.blob),n.externalBlob&&m.encode(o,n.externalBlob),n.externalDrive&&y.encode(o,n.externalDrive),d>=27&&n.bee&&fr.encode(o,n.bee)},decode(o){const n=e.uint.decode(o);return{inlined:1&n?e.buffer.decode(o):null,blob:2&n?a.decode(o):null,externalBlob:4&n?m.decode(o):null,externalDrive:8&n?y.decode(o):null,bee:d>=27&&16&n?fr.decode(o):null}}},x=e.frame(b),k=e.frame(u),v={preencode(d,o){x.preencode(d,o.pointer),d.end++,o.metadata&&k.preencode(d,o.metadata),o.preview&&Hr.preencode(d,o.preview),o.hash&&e.fixed32.preencode(d,o.hash)},encode(d,o){const n=(o.metadata?1:0)|(o.preview?2:0)|(o.hash?4:0);x.encode(d,o.pointer),e.uint.encode(d,n),o.metadata&&k.encode(d,o.metadata),o.preview&&Hr.encode(d,o.preview),o.hash&&e.fixed32.encode(d,o.hash)},decode(d){const o=x.decode(d),n=e.uint.decode(d);return{pointer:o,metadata:1&n?k.decode(d):null,preview:2&n?Hr.decode(d):null,hash:4&n?e.fixed32.decode(d):null}}},g=e.frame(v),h=g,K=g,w={preencode(e,d){e.end++,d.small&&g.preencode(e,d.small),d.medium&&h.preencode(e,d.medium),d.large&&K.preencode(e,d.large)},encode(d,o){const n=(o.small?1:0)|(o.medium?2:0)|(o.large?4:0);e.uint.encode(d,n),o.small&&g.encode(d,o.small),o.medium&&h.encode(d,o.medium),o.large&&K.encode(d,o.large)},decode(d){const o=e.uint.decode(d);return{small:1&o?g.decode(d):null,medium:2&o?h.decode(d):null,large:4&o?K.decode(d):null}}},T={preencode(e,d){e.end++},encode(d,o){const n=o.isDeleted?1:0;e.uint.encode(d,n)},decode:d=>({isDeleted:!!(1&e.uint.decode(d))})},A=e.frame(T),P=g,S={preencode(o,c){e.uint.preencode(o,c.id),n.preencode(o,c.oplog),A.preencode(o,c.status),P.preencode(o,c.file),o.end++,d>=14&&c.version&&e.uint.preencode(o,c.version)},encode(o,c){const t=d>=14&&c.version?1:0;e.uint.encode(o,c.id),n.encode(o,c.oplog),A.encode(o,c.status),P.encode(o,c.file),e.uint.encode(o,t),d>=14&&c.version&&e.uint.encode(o,c.version)},decode(o){const c=e.uint.decode(o),t=n.decode(o),r=A.decode(o),i=P.decode(o),a=o.start<o.end?e.uint.decode(o):0;return{id:c,oplog:t,status:r,file:i,version:d>=14&&1&a?e.uint.decode(o):0}}},I={preencode(e,d){e.end++},encode(d,o){const n=(o.isActive?1:0)|(o.isIndexing?2:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isActive:!!(1&o),isIndexing:!!(2&o)}}},R={preencode(o,n){const c=(n.isAdmin?1:0)|(n.isModerator?2:0)|(n.isPending?4:0)|(n.isActive?8:0)|(n.isMuted?16:0)|(n.isBanned?32:0)|(n.isShadowBanned?64:0)|(d>=13&&n.isRemoved?128:0);e.uint.preencode(o,c)},encode(o,n){const c=(n.isAdmin?1:0)|(n.isModerator?2:0)|(n.isPending?4:0)|(n.isActive?8:0)|(n.isMuted?16:0)|(n.isBanned?32:0)|(n.isShadowBanned?64:0)|(d>=13&&n.isRemoved?128:0);e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{isAdmin:!!(1&n),isModerator:!!(2&n),isPending:!!(4&n),isActive:!!(8&n),isMuted:!!(16&n),isBanned:!!(32&n),isShadowBanned:!!(64&n),isRemoved:d>=13&&!!(128&n)}}},F={preencode(e,d){e.end++},encode(d,o){const n=(o.isMuted?1:0)|(o.isBanned?2:0)|(o.isShadowBanned?4:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isMuted:!!(1&o),isBanned:!!(2&o),isShadowBanned:!!(4&o)}}},H={preencode(d,o){e.uint.preencode(d,o.version)},encode(d,o){e.uint.encode(d,o.version)},decode:d=>({version:e.uint.decode(d)})},M={preencode(d,o){e.uint.preencode(d,o.total),e.uint.preencode(d,o.active)},encode(d,o){e.uint.encode(d,o.total),e.uint.encode(d,o.active)},decode:d=>({total:e.uint.decode(d),active:e.uint.decode(d)})},C={preencode(d,o){e.uint.preencode(d,o.total),e.uint.preencode(d,o.active),e.uint.preencode(d,o.pending)},encode(d,o){e.uint.encode(d,o.total),e.uint.encode(d,o.active),e.uint.encode(d,o.pending)},decode:d=>({total:e.uint.decode(d),active:e.uint.decode(d),pending:e.uint.decode(d)})},D={preencode(o,n){e.uint.preencode(o,n.clock),e.uint.preencode(o,n.pinned),e.uint.preencode(o,n.threads),e.uint.preencode(o,n.timestamp),o.end++,d>=15&&n.flagsClock&&e.uint.preencode(o,n.flagsClock)},encode(o,n){const c=d>=15&&n.flagsClock?1:0;e.uint.encode(o,n.clock),e.uint.encode(o,n.pinned),e.uint.encode(o,n.threads),e.uint.encode(o,n.timestamp),e.uint.encode(o,c),d>=15&&n.flagsClock&&e.uint.encode(o,n.flagsClock)},decode(o){const n=e.uint.decode(o),c=e.uint.decode(o),t=e.uint.decode(o),r=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{clock:n,pinned:c,threads:t,timestamp:r,flagsClock:d>=15&&1&i?e.uint.decode(o):0}}},V={preencode(d,o){e.uint.preencode(d,o.clock)},encode(d,o){e.uint.encode(d,o.clock)},decode:d=>({clock:e.uint.decode(d)})},L=e.frame(M),q=e.frame(C),E=e.frame(D),B=e.frame(V),z={preencode(e,o){L.preencode(e,o.devices),q.preencode(e,o.members),E.preencode(e,o.chat),B.preencode(e,o.files),e.end++,d>=26&&o.calls&&Mr.preencode(e,o.calls)},encode(o,n){const c=d>=26&&n.calls?1:0;L.encode(o,n.devices),q.encode(o,n.members),E.encode(o,n.chat),B.encode(o,n.files),e.uint.encode(o,c),d>=26&&n.calls&&Mr.encode(o,n.calls)},decode(o){const n=L.decode(o),c=q.decode(o),t=E.decode(o),r=B.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{devices:n,members:c,chat:t,files:r,calls:d>=26&&1&i?Mr.decode(o):null}}},N={Default:1,Broadcast:2,DirectMessage:3},j={preencode(e,d){e.end++},encode(d,o){if(o>3)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},O={preencode(o,n){const c=(n.roomType?1:0)|(n.isExperimental?2:0)|(n.isJoiningDisabled?4:0)|(n.isAppendingDisabled?8:0)|(n.isCallingDisabled?16:0)|(n.isMembershipEventsDisabled?32:0)|(d>=19&&n.isAttachmentsDisabled?64:0)|(d>=19&&n.isLinksDisabled?128:0)|(d>=20&&n.buildType?256:0)|(d>=23&&n.isRoomInviteHidden?512:0);e.uint.preencode(o,c),n.roomType&&j.preencode(o,n.roomType),d>=20&&n.buildType&&Bt.preencode(o,n.buildType)},encode(o,n){const c=(n.roomType?1:0)|(n.isExperimental?2:0)|(n.isJoiningDisabled?4:0)|(n.isAppendingDisabled?8:0)|(n.isCallingDisabled?16:0)|(n.isMembershipEventsDisabled?32:0)|(d>=19&&n.isAttachmentsDisabled?64:0)|(d>=19&&n.isLinksDisabled?128:0)|(d>=20&&n.buildType?256:0)|(d>=23&&n.isRoomInviteHidden?512:0);e.uint.encode(o,c),n.roomType&&j.encode(o,n.roomType),d>=20&&n.buildType&&Bt.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{roomType:1&n?j.decode(o):0,isExperimental:!!(2&n),isJoiningDisabled:!!(4&n),isAppendingDisabled:!!(8&n),isCallingDisabled:!!(16&n),isMembershipEventsDisabled:!!(32&n),isAttachmentsDisabled:d>=19&&!!(64&n),isLinksDisabled:d>=19&&!!(128&n),buildType:d>=20&&256&n?Bt.decode(o):null,isRoomInviteHidden:d>=23&&!!(512&n)}}},U=e.frame(H),J=e.frame(O),G={preencode(d,o){U.preencode(d,o.abi),J.preencode(d,o.settings),e.uint.preencode(d,o.creationTime)},encode(d,o){U.encode(d,o.abi),J.encode(d,o.settings),e.uint.encode(d,o.creationTime)},decode:d=>({abi:U.decode(d),settings:J.decode(d),creationTime:e.uint.decode(d)})},Q={preencode(d,o){e.fixed32.preencode(d,o.seed)},encode(d,o){e.fixed32.encode(d,o.seed)},decode:d=>({seed:e.fixed32.decode(d)})},W={preencode(d,o){c.preencode(d,o.mailboxKeyPair),t.preencode(d,o.discoveryKeyPair),e.fixed32.preencode(d,o.wakeupTopic),e.fixed32.preencode(d,o.swarmTopic)},encode(d,o){c.encode(d,o.mailboxKeyPair),t.encode(d,o.discoveryKeyPair),e.fixed32.encode(d,o.wakeupTopic),e.fixed32.encode(d,o.swarmTopic)},decode:d=>({mailboxKeyPair:c.decode(d),discoveryKeyPair:t.decode(d),wakeupTopic:e.fixed32.decode(d),swarmTopic:e.fixed32.decode(d)})},X=e.array(e.fixed32),Y={preencode(o,n){o.end++,n.title&&e.string.preencode(o,n.title),n.avatar&&Cr.preencode(o,n.avatar),n.description&&e.string.preencode(o,n.description),d>=11&&n.supportedLanguages&&Dr.preencode(o,n.supportedLanguages),d>=13&&n.blindPeers&&X.preencode(o,n.blindPeers)},encode(o,n){const c=(n.title?1:0)|(n.avatar?2:0)|(n.description?4:0)|(d>=11&&n.supportedLanguages?8:0)|(d>=13&&n.blindPeers?16:0);e.uint.encode(o,c),n.title&&e.string.encode(o,n.title),n.avatar&&Cr.encode(o,n.avatar),n.description&&e.string.encode(o,n.description),d>=11&&n.supportedLanguages&&Dr.encode(o,n.supportedLanguages),d>=13&&n.blindPeers&&X.encode(o,n.blindPeers)},decode(o){const n=e.uint.decode(o);return{title:1&n?e.string.decode(o):null,avatar:2&n?Cr.decode(o):null,description:4&n?e.string.decode(o):null,supportedLanguages:d>=11&&8&n?Dr.decode(o):null,blindPeers:d>=13&&16&n?X.decode(o):null}}},Z={preencode(d,o){e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.key)},decode:d=>({key:e.fixed32.decode(d)})},$=e.frame(i),_=e.frame(Z),ee={preencode(e,d){$.preencode(e,d.header),_.preencode(e,d.peer)},encode(e,d){$.encode(e,d.header),_.encode(e,d.peer)},decode:e=>({header:$.decode(e),peer:_.decode(e)})},de=$,oe={preencode(d,o){de.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){de.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:de.decode(d),key:e.fixed32.decode(d)})},ne={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.buffer.preencode(d,o.proof)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.buffer.encode(d,o.proof)},decode:d=>({memberKey:e.fixed32.decode(d),proof:e.buffer.decode(d)})},ce={preencode(d,o){e.fixed32.preencode(d,o.id),e.buffer.preencode(d,o.response)},encode(d,o){e.fixed32.encode(d,o.id),e.buffer.encode(d,o.response)},decode:d=>({id:e.fixed32.decode(d),response:e.buffer.decode(d)})},te=e.frame(I),re=e.frame(ce),ie={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.memberKey),te.preencode(d,o.status),Vr.preencode(d,o.profile),d.end++,o.invitation&&re.preencode(d,o.invitation)},encode(d,o){const n=o.invitation?1:0;e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.memberKey),te.encode(d,o.status),Vr.encode(d,o.profile),e.uint.encode(d,n),o.invitation&&re.encode(d,o.invitation)},decode:d=>({key:e.fixed32.decode(d),memberKey:e.fixed32.decode(d),status:te.decode(d),profile:Vr.decode(d),invitation:1&e.uint.decode(d)?re.decode(d):null})},ae={preencode(d,o){e.uint.preencode(d,o.timestamp),d.end++,o.mailbox&&e.fixed32.preencode(d,o.mailbox),o.displayName&&e.string.preencode(d,o.displayName),o.avatar&&Lr.preencode(d,o.avatar),o.username&&e.string.preencode(d,o.username)},encode(d,o){const n=(o.mailbox?1:0)|(o.displayName?2:0)|(o.avatar?4:0)|(o.username?8:0);e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.mailbox&&e.fixed32.encode(d,o.mailbox),o.displayName&&e.string.encode(d,o.displayName),o.avatar&&Lr.encode(d,o.avatar),o.username&&e.string.encode(d,o.username)},decode(d){const o=e.uint.decode(d),n=e.uint.decode(d);return{timestamp:o,mailbox:1&n?e.fixed32.decode(d):null,displayName:2&n?e.string.decode(d):null,avatar:4&n?Lr.decode(d):null,username:8&n?e.string.decode(d):null}}},se={preencode(o,n){o.end++,n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),n.name&&e.string.preencode(o,n.name),d>=20&&n.buildType&&Bt.preencode(o,n.buildType)},encode(o,n){const c=(n.swarmKey?1:0)|(n.name?2:0)|(n.isMobile?4:0)|(d>=20&&n.buildType?8:0);e.uint.encode(o,c),n.swarmKey&&e.fixed32.encode(o,n.swarmKey),n.name&&e.string.encode(o,n.name),d>=20&&n.buildType&&Bt.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{swarmKey:1&n?e.fixed32.decode(o):null,name:2&n?e.string.decode(o):null,isMobile:!!(4&n),buildType:d>=20&&8&n?Bt.decode(o):null}}},pe=e.frame(ae),ue={preencode(e,d){pe.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){pe.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:pe.decode(e),attestation:ne.decode(e)})},le={preencode(e,d){qr.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){qr.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:qr.decode(e),attestation:ne.decode(e)})},fe={preencode(d,o){e.fixed32.preencode(d,o.id),e.buffer.preencode(d,o.data),e.buffer.preencode(d,o.signature)},encode(d,o){e.fixed32.encode(d,o.id),e.buffer.encode(d,o.data),e.buffer.encode(d,o.signature)},decode:d=>({id:e.fixed32.decode(d),data:e.buffer.decode(d),signature:e.buffer.decode(d)})},me={preencode(d,o){e.fixed32.preencode(d,o.devicePublicKey)},encode(d,o){e.fixed32.encode(d,o.devicePublicKey)},decode:d=>({devicePublicKey:e.fixed32.decode(d)})},ye={preencode(d,o){ne.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){ne.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({privateProfileIdentity:ne.decode(d),deviceProof:e.buffer.decode(d)})},be=e.frame(le),xe=e.frame(ue),ke=e.frame(me),ve={preencode(n,c){e.fixed32.preencode(n,c.deviceKey),t.preencode(n,c.keyPair),be.preencode(n,c.device),xe.preencode(n,c.member),n.end++,c.identity&&ke.preencode(n,c.identity),d>=27&&c.link&&o.preencode(n,c.link)},encode(n,c){const r=(c.identity?1:0)|(d>=27&&c.link?2:0);e.fixed32.encode(n,c.deviceKey),t.encode(n,c.keyPair),be.encode(n,c.device),xe.encode(n,c.member),e.uint.encode(n,r),c.identity&&ke.encode(n,c.identity),d>=27&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),r=t.decode(n),i=be.decode(n),a=xe.decode(n),s=e.uint.decode(n);return{deviceKey:c,keyPair:r,device:i,member:a,identity:1&s?ke.decode(n):null,link:d>=27&&2&s?o.decode(n):null}}},ge=e.frame(ve),he={preencode(d,o){e.fixed32.preencode(d,o.id),ge.preencode(d,o.request),e.buffer.preencode(d,o.signature)},encode(d,o){e.fixed32.encode(d,o.id),ge.encode(d,o.request),e.buffer.encode(d,o.signature)},decode:d=>({id:e.fixed32.decode(d),request:ge.decode(d),signature:e.buffer.decode(d)})},Ke=be,we=xe,Te={preencode(e,d){Ke.preencode(e,d.device),e.end++,d.member&&we.preencode(e,d.member)},encode(d,o){const n=o.member?1:0;Ke.encode(d,o.device),e.uint.encode(d,n),o.member&&we.encode(d,o.member)},decode:d=>({device:Ke.decode(d),member:1&e.uint.decode(d)?we.decode(d):null})},Ae=e.frame(he),Pe=e.frame(Te),Se={preencode(e,d){e.end++,d.withInvitation&&Ae.preencode(e,d.withInvitation),d.withMemberProof&&Pe.preencode(e,d.withMemberProof)},encode(d,o){const n=(o.withInvitation?1:0)|(o.withMemberProof?2:0);e.uint.encode(d,n),o.withInvitation&&Ae.encode(d,o.withInvitation),o.withMemberProof&&Pe.encode(d,o.withMemberProof)},decode(d){const o=e.uint.decode(d);return{withInvitation:1&o?Ae.decode(d):null,withMemberProof:2&o?Pe.decode(d):null}}},Ie=e.frame(fe),Re=e.frame(ye),Fe={preencode(e,d){Ie.preencode(e,d.signedKeys),e.end++,d.identity&&Re.preencode(e,d.identity)},encode(d,o){const n=o.identity?1:0;Ie.encode(d,o.signedKeys),e.uint.encode(d,n),o.identity&&Re.encode(d,o.identity)},decode:d=>({signedKeys:Ie.decode(d),identity:1&e.uint.decode(d)?Re.decode(d):null})},He={preencode(o,n){o.end++,n.expiration&&e.uint.preencode(o,n.expiration),d>=20&&n.buildType&&Bt.preencode(o,n.buildType)},encode(o,n){const c=(n.expiration?1:0)|(n.requiresConfirmation?2:0)|(n.canModerate?4:0)|(n.canAdmin?8:0)|(d>=20&&n.buildType?16:0);e.uint.encode(o,c),n.expiration&&e.uint.encode(o,n.expiration),d>=20&&n.buildType&&Bt.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{expiration:1&n?e.uint.decode(o):0,requiresConfirmation:!!(2&n),canModerate:!!(4&n),canAdmin:!!(8&n),buildType:d>=20&&16&n?Bt.decode(o):null}}},Me=Ie,Ce=e.frame(He),De={preencode(d,n){e.fixed32.preencode(d,n.id),Me.preencode(d,n.response),Ce.preencode(d,n.metadata),d.end++,n.anchor&&o.preencode(d,n.anchor)},encode(d,n){const c=(n.anchor?1:0)|(n.isActive?2:0);e.fixed32.encode(d,n.id),Me.encode(d,n.response),Ce.encode(d,n.metadata),e.uint.encode(d,c),n.anchor&&o.encode(d,n.anchor)},decode(d){const n=e.fixed32.decode(d),c=Me.decode(d),t=Ce.decode(d),r=e.uint.decode(d);return{id:n,response:c,metadata:t,anchor:1&r?o.decode(d):null,isActive:!!(2&r)}}},Ve=$,Le=e.frame(De),qe={preencode(e,d){Ve.preencode(e,d.header),Le.preencode(e,d.invitation)},encode(e,d){Ve.encode(e,d.header),Le.encode(e,d.invitation)},decode:e=>({header:Ve.decode(e),invitation:Le.decode(e)})},Ee=$,Be={preencode(d,o){Ee.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){Ee.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:Ee.decode(d),id:e.fixed32.decode(d)})},ze={preencode(d,n){e.fixed32.preencode(d,n.mailbox),e.fixed32.preencode(d,n.invitationSeed),o.preencode(d,n.anchor)},encode(d,n){e.fixed32.encode(d,n.mailbox),e.fixed32.encode(d,n.invitationSeed),o.encode(d,n.anchor)},decode:d=>({mailbox:e.fixed32.decode(d),invitationSeed:e.fixed32.decode(d),anchor:o.decode(d)})},Ne={preencode(d,n){e.fixed32.preencode(d,n.mailbox),e.fixed32.preencode(d,n.invitationSeed),o.preencode(d,n.anchor),e.fixed32.preencode(d,n.identityPublicKey)},encode(d,n){e.fixed32.encode(d,n.mailbox),e.fixed32.encode(d,n.invitationSeed),o.encode(d,n.anchor),e.fixed32.encode(d,n.identityPublicKey)},decode:d=>({mailbox:e.fixed32.decode(d),invitationSeed:e.fixed32.decode(d),anchor:o.decode(d),identityPublicKey:e.fixed32.decode(d)})},je={preencode(d,o){e.fixed32.preencode(d,o.mailbox)},encode(d,o){e.fixed32.encode(d,o.mailbox)},decode:d=>({mailbox:e.fixed32.decode(d)})},Oe=e.frame(ze),Ue=e.frame(Ne),Je=e.frame(je),Ge=e.array(e.ipv4Address),Qe={preencode(e,o){e.end++,o.room&&Oe.preencode(e,o.room),o.identity&&Ue.preencode(e,o.identity),o.contact&&Je.preencode(e,o.contact),d>=6&&o.readonly&&Er.preencode(e,o.readonly),d>=11&&o.additionalNodes&&Ge.preencode(e,o.additionalNodes),d>=20&&o.buildType&&Bt.preencode(e,o.buildType),d>=27&&o["readonly-v2"]&&Br.preencode(e,o["readonly-v2"])},encode(o,n){const c=(n.room?1:0)|(n.identity?2:0)|(n.contact?4:0)|(d>=6&&n.readonly?8:0)|(d>=11&&n.additionalNodes?16:0)|(d>=20&&n.buildType?32:0)|(d>=27&&n["readonly-v2"]?64:0);e.uint.encode(o,c),n.room&&Oe.encode(o,n.room),n.identity&&Ue.encode(o,n.identity),n.contact&&Je.encode(o,n.contact),d>=6&&n.readonly&&Er.encode(o,n.readonly),d>=11&&n.additionalNodes&&Ge.encode(o,n.additionalNodes),d>=20&&n.buildType&&Bt.encode(o,n.buildType),d>=27&&n["readonly-v2"]&&Br.encode(o,n["readonly-v2"])},decode(o){const n=e.uint.decode(o);return{room:1&n?Oe.decode(o):null,identity:2&n?Ue.decode(o):null,contact:4&n?Je.decode(o):null,readonly:d>=6&&8&n?Er.decode(o):null,additionalNodes:d>=11&&16&n?Ge.decode(o):null,buildType:d>=20&&32&n?Bt.decode(o):null,"readonly-v2":d>=27&&64&n?Br.decode(o):null}}},We=$,Xe={preencode(d,o){We.preencode(d,o.header),e.buffer.preencode(d,o.blindRequest)},encode(d,o){We.encode(d,o.header),e.buffer.encode(d,o.blindRequest)},decode:d=>({header:We.decode(d),blindRequest:e.buffer.decode(d)})},Ye=$,Ze={preencode(o,n){Ye.preencode(o,n.header),o.end++,n.profile&&zr.preencode(o,n.profile),d>=24&&n.key&&e.fixed32.preencode(o,n.key)},encode(o,n){const c=(n.profile?1:0)|(d>=24&&n.key?2:0);Ye.encode(o,n.header),e.uint.encode(o,c),n.profile&&zr.encode(o,n.profile),d>=24&&n.key&&e.fixed32.encode(o,n.key)},decode(o){const n=Ye.decode(o),c=e.uint.decode(o);return{header:n,profile:1&c?zr.decode(o):null,key:d>=24&&2&c?e.fixed32.decode(o):null}}},$e={preencode(e,d){},encode(e,d){},decode:e=>({})},_e=$e,ed=ge,dd={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.id),ed.preencode(d,o.request)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.id),ed.encode(d,o.request)},decode:d=>({deviceKey:e.fixed32.decode(d),id:e.fixed32.decode(d),request:ed.decode(d)})},od=$,nd=Re,cd={preencode(d,o){od.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),d.end++,o.identity&&nd.preencode(d,o.identity)},encode(d,o){const n=o.identity?1:0;od.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,n),o.identity&&nd.encode(d,o.identity)},decode:d=>({header:od.decode(d),deviceKey:e.fixed32.decode(d),identity:1&e.uint.decode(d)?nd.decode(d):null})},td=$,rd={preencode(d,o){td.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey)},encode(d,o){td.encode(d,o.header),e.fixed32.encode(d,o.deviceKey)},decode:d=>({header:td.decode(d),deviceKey:e.fixed32.decode(d)})},id=e.frame(R),ad=pe,sd={preencode(d,o){e.fixed32.preencode(d,o.key),id.preencode(d,o.status),ad.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),id.encode(d,o.status),ad.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),status:id.decode(d),profile:ad.decode(d)})},pd=id,ud=pe,ld={preencode(d,o){e.fixed32.preencode(d,o.key),pd.preencode(d,o.status),ud.preencode(d,o.profile),d.end++,o.proofs&&Nr.preencode(d,o.proofs)},encode(d,o){const n=o.proofs?1:0;e.fixed32.encode(d,o.key),pd.encode(d,o.status),ud.encode(d,o.profile),e.uint.encode(d,n),o.proofs&&Nr.encode(d,o.proofs)},decode:d=>({key:e.fixed32.decode(d),status:pd.decode(d),profile:ud.decode(d),proofs:1&e.uint.decode(d)?Nr.decode(d):null})},fd={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++,o.profileAttestation&&e.buffer.preencode(d,o.profileAttestation),o.latestReceipt&&e.buffer.preencode(d,o.latestReceipt)},encode(d,o){const n=(o.profileAttestation?1:0)|(o.latestReceipt?2:0);e.fixed32.encode(d,o.key),e.uint.encode(d,n),o.profileAttestation&&e.buffer.encode(d,o.profileAttestation),o.latestReceipt&&e.buffer.encode(d,o.latestReceipt)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d);return{key:o,profileAttestation:1&n?e.buffer.decode(d):null,latestReceipt:2&n?e.buffer.decode(d):null}}},md=$,yd=xe,bd={preencode(e,d){md.preencode(e,d.header),yd.preencode(e,d.member)},encode(e,d){md.encode(e,d.header),yd.encode(e,d.member)},decode:e=>({header:md.decode(e),member:yd.decode(e)})},xd=$,kd=e.frame(F),vd={preencode(d,o){xd.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),kd.preencode(d,o.status)},encode(d,o){xd.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),kd.encode(d,o.status)},decode:d=>({header:xd.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:kd.decode(d)})},gd=$,hd={preencode(d,o){gd.preencode(d,o.header),e.fixed32.preencode(d,o.key),d.end++},encode(d,o){const n=(o.isModerator?1:0)|(o.isAdmin?2:0);gd.encode(d,o.header),e.fixed32.encode(d,o.key),e.uint.encode(d,n)},decode(d){const o=gd.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{header:o,key:n,isModerator:!!(1&c),isAdmin:!!(2&c)}}},Kd=$,wd={preencode(d,o){Kd.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){Kd.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:Kd.decode(d),key:e.fixed32.decode(d)})},Td={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.mentions)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.mentions)},decode:d=>({key:e.fixed32.decode(d),mentions:e.uint.decode(d)})},Ad={preencode(d,o){d.end++,o.memberKey&&e.fixed32.preencode(d,o.memberKey)},encode(d,o){const n=o.memberKey?1:0;e.uint.encode(d,n),o.memberKey&&e.fixed32.encode(d,o.memberKey)},decode:d=>({memberKey:1&e.uint.decode(d)?e.fixed32.decode(d):null})},Pd=Ad,Sd={preencode(d,o){d.end++,o.from&&e.string.preencode(d,o.from),o.to&&e.string.preencode(d,o.to)},encode(d,o){const n=(o.from?1:0)|(o.to?2:0);e.uint.encode(d,n),o.from&&e.string.encode(d,o.from),o.to&&e.string.encode(d,o.to)},decode(d){const o=e.uint.decode(d);return{from:1&o?e.string.decode(d):null,to:2&o?e.string.decode(d):null}}},Id=e.frame(Ad),Rd=e.frame(Pd),Fd=e.frame(Sd),Hd={preencode(o,n){const c=(n.memberJoined?1:0)|(n.memberLeft?2:0)|(n.titleChanged?4:0)|(n.callStarted?8:0)|(n.callHangup?16:0)|(n.callMissed?32:0)|(d>=3&&n.roomAvatarChanged?64:0)|(d>=3&&n.invitationCreated?128:0)|(d>=3&&n.memberRemoved?256:0)|(d>=18&&n.locationShared?512:0);e.uint.preencode(o,c),n.memberJoined&&Id.preencode(o,n.memberJoined),n.memberLeft&&Rd.preencode(o,n.memberLeft),n.titleChanged&&Fd.preencode(o,n.titleChanged),d>=3&&n.memberRemoved&&jr.preencode(o,n.memberRemoved),d>=18&&n.locationShared&&Or.preencode(o,n.locationShared)},encode(o,n){const c=(n.memberJoined?1:0)|(n.memberLeft?2:0)|(n.titleChanged?4:0)|(n.callStarted?8:0)|(n.callHangup?16:0)|(n.callMissed?32:0)|(d>=3&&n.roomAvatarChanged?64:0)|(d>=3&&n.invitationCreated?128:0)|(d>=3&&n.memberRemoved?256:0)|(d>=18&&n.locationShared?512:0);e.uint.encode(o,c),n.memberJoined&&Id.encode(o,n.memberJoined),n.memberLeft&&Rd.encode(o,n.memberLeft),n.titleChanged&&Fd.encode(o,n.titleChanged),d>=3&&n.memberRemoved&&jr.encode(o,n.memberRemoved),d>=18&&n.locationShared&&Or.encode(o,n.locationShared)},decode(o){const n=e.uint.decode(o);return{memberJoined:1&n?Id.decode(o):null,memberLeft:2&n?Rd.decode(o):null,titleChanged:4&n?Fd.decode(o):null,callStarted:!!(8&n),callHangup:!!(16&n),callMissed:!!(32&n),roomAvatarChanged:d>=3&&!!(64&n),invitationCreated:d>=3&&!!(128&n),memberRemoved:d>=3&&256&n?jr.decode(o):null,locationShared:d>=18&&512&n?Or.decode(o):null}}},Md={preencode(e,o){e.end++,d>=18&&o.locationShared&&Ur.preencode(e,o.locationShared)},encode(o,n){const c=(n.callStarted?1:0)|(n.callHangup?2:0)|(n.callMissed?4:0)|(d>=18&&n.locationShared?8:0);e.uint.encode(o,c),d>=18&&n.locationShared&&Ur.encode(o,n.locationShared)},decode(o){const n=e.uint.decode(o);return{callStarted:!!(1&n),callHangup:!!(2&n),callMissed:!!(4&n),locationShared:d>=18&&8&n?Ur.decode(o):null}}},Cd={preencode(d,o){e.uint.preencode(d,o.start),e.uint.preencode(d,o.length)},encode(d,o){e.uint.encode(d,o.start),e.uint.encode(d,o.length)},decode:d=>({start:e.uint.decode(d),length:e.uint.decode(d)})},Dd=e.frame(Cd),Vd={preencode(d,o){Dd.preencode(d,o.range),e.string.preencode(d,o.content)},encode(d,o){Dd.encode(d,o.range),e.string.encode(d,o.content)},decode:d=>({range:Dd.decode(d),content:e.string.decode(d)})},Ld=Dd,qd={preencode(d,o){Ld.preencode(d,o.range),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Ld.encode(d,o.range),e.fixed32.encode(d,o.memberKey)},decode:d=>({range:Ld.decode(d),memberKey:e.fixed32.decode(d)})},Ed=g,Bd=e.array(e.uint),zd={preencode(o,n){o.end++,n.title&&e.string.preencode(o,n.title),n.description&&e.string.preencode(o,n.description),n.file&&Ed.preencode(o,n.file),d>=7&&n.files&&Bd.preencode(o,n.files)},encode(o,n){const c=(n.title?1:0)|(n.description?2:0)|(n.file?4:0)|(d>=7&&n.files?8:0);e.uint.encode(o,c),n.title&&e.string.encode(o,n.title),n.description&&e.string.encode(o,n.description),n.file&&Ed.encode(o,n.file),d>=7&&n.files&&Bd.encode(o,n.files)},decode(o){const n=e.uint.decode(o);return{title:1&n?e.string.decode(o):null,description:2&n?e.string.decode(o):null,file:4&n?Ed.decode(o):null,files:d>=7&&8&n?Bd.decode(o):null}}},Nd=Dd,jd=e.frame(zd),Od={preencode(d,o){Nd.preencode(d,o.range),e.string.preencode(d,o.url),d.end++,o.preview&&jd.preencode(d,o.preview)},encode(d,o){const n=o.preview?1:0;Nd.encode(d,o.range),e.string.encode(d,o.url),e.uint.encode(d,n),o.preview&&jd.encode(d,o.preview)},decode:d=>({range:Nd.decode(d),url:e.string.decode(d),preview:1&e.uint.decode(d)?jd.decode(d):null})},Ud=e.array(e.frame(qd)),Jd=e.array(e.frame(Od)),Gd=Jd,Qd=e.array(e.frame(Cd)),Wd=Qd,Xd=Qd,Yd=e.array(e.frame(Vd)),Zd=Qd,$d=Qd,_d={preencode(o,n){const c=(n.mention?1:0)|(n.httpLink?2:0)|(n.pearLink?4:0)|(n.bold?8:0)|(n.italic?16:0)|(n.code?32:0)|(n.emoji?64:0)|(n.codeBlock?128:0)|(n.strike?256:0)|(d>=11&&n.translation?512:0);e.uint.preencode(o,c),n.mention&&Ud.preencode(o,n.mention),n.httpLink&&Jd.preencode(o,n.httpLink),n.pearLink&&Gd.preencode(o,n.pearLink),n.bold&&Qd.preencode(o,n.bold),n.italic&&Wd.preencode(o,n.italic),n.code&&Xd.preencode(o,n.code),n.emoji&&Yd.preencode(o,n.emoji),n.codeBlock&&Zd.preencode(o,n.codeBlock),n.strike&&$d.preencode(o,n.strike),d>=11&&n.translation&&Jr.preencode(o,n.translation)},encode(o,n){const c=(n.mention?1:0)|(n.httpLink?2:0)|(n.pearLink?4:0)|(n.bold?8:0)|(n.italic?16:0)|(n.code?32:0)|(n.emoji?64:0)|(n.codeBlock?128:0)|(n.strike?256:0)|(d>=11&&n.translation?512:0);e.uint.encode(o,c),n.mention&&Ud.encode(o,n.mention),n.httpLink&&Jd.encode(o,n.httpLink),n.pearLink&&Gd.encode(o,n.pearLink),n.bold&&Qd.encode(o,n.bold),n.italic&&Wd.encode(o,n.italic),n.code&&Xd.encode(o,n.code),n.emoji&&Yd.encode(o,n.emoji),n.codeBlock&&Zd.encode(o,n.codeBlock),n.strike&&$d.encode(o,n.strike),d>=11&&n.translation&&Jr.encode(o,n.translation)},decode(o){const n=e.uint.decode(o);return{mention:1&n?Ud.decode(o):null,httpLink:2&n?Jd.decode(o):null,pearLink:4&n?Gd.decode(o):null,bold:8&n?Qd.decode(o):null,italic:16&n?Wd.decode(o):null,code:32&n?Xd.decode(o):null,emoji:64&n?Yd.decode(o):null,codeBlock:128&n?Zd.decode(o):null,strike:256&n?$d.decode(o):null,translation:d>=11&&512&n?Jr.decode(o):null}}},eo=e.array(e.frame(v)),oo=e.frame(_d),no=e.frame(Md),co={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&eo.preencode(d,o.files),o.display&&oo.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent),o.event&&no.preencode(d,o.event)},encode(o,c){const t=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(c.event?32:0)|(d>=18&&c.forwarded?64:0);e.uint.encode(o,t),c.text&&e.string.encode(o,c.text),c.files&&eo.encode(o,c.files),c.display&&oo.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent),c.event&&no.encode(o,c.event)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?eo.decode(o):null,display:4&c?oo.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,event:32&c?no.decode(o):null,forwarded:d>=18&&!!(64&c)}}},to=Bd,ro=oo,io={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&to.preencode(d,o.files),o.display&&ro.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent)},encode(o,c){const t=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(d>=18&&c.forwarded?32:0);e.uint.encode(o,t),c.text&&e.string.encode(o,c.text),c.files&&to.encode(o,c.files),c.display&&ro.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?to.decode(o):null,display:4&c?ro.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,forwarded:d>=18&&!!(32&c)}}},ao=eo,so=oo,po={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&ao.preencode(d,o.files),o.display&&so.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent)},encode(o,c){const t=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(d>=18&&c.forwarded?32:0);e.uint.encode(o,t),c.text&&e.string.encode(o,c.text),c.files&&ao.encode(o,c.files),c.display&&so.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?ao.decode(o):null,display:4&c?so.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,forwarded:d>=18&&!!(32&c)}}},uo={preencode(e,d){e.end++},encode(d,o){const n=(o.isEdited?1:0)|(o.isDeleted?2:0)|(o.isPinned?4:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isEdited:!!(1&o),isDeleted:!!(2&o),isPinned:!!(4&o)}}},lo={preencode(d,o){e.uint.preencode(d,o.thread),e.uint.preencode(d,o.index)},encode(d,o){e.uint.encode(d,o.thread),e.uint.encode(d,o.index)},decode:d=>({thread:e.uint.decode(d),index:e.uint.decode(d)})},fo=e.frame(z),mo={preencode(d,o){e.uint.preencode(d,o.id),e.uint.preencode(d,o.count),d.end++,o.parent&&n.preencode(d,o.parent),o.stats&&fo.preencode(d,o.stats)},encode(d,o){const c=(o.parent?1:0)|(o.stats?2:0);e.uint.encode(d,o.id),e.uint.encode(d,o.count),e.uint.encode(d,c),o.parent&&n.encode(d,o.parent),o.stats&&fo.encode(d,o.stats)},decode(d){const o=e.uint.decode(d),c=e.uint.decode(d),t=e.uint.decode(d);return{id:o,count:c,parent:1&t?n.decode(d):null,stats:2&t?fo.decode(d):null}}},yo=e.frame(uo),bo=e.frame(io),xo=e.frame(Hd),ko={preencode(d,o){lo.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),yo.preencode(d,o.status),o.message&&bo.preencode(d,o.message),o.event&&xo.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);lo.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),yo.encode(d,o.status),o.message&&bo.encode(d,o.message),o.event&&xo.encode(d,o.event)},decode(d){const o=lo.decode(d),c=n.decode(d),t=e.uint.decode(d),r=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:t,timestamp:r,editedAt:1&i?e.uint.decode(d):0,status:yo.decode(d),message:2&i?bo.decode(d):null,event:4&i?xo.decode(d):null}}},vo=yo,go=e.frame(po),ho=xo,Ko={preencode(d,o){lo.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),vo.preencode(d,o.status),o.message&&go.preencode(d,o.message),o.event&&ho.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);lo.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),vo.encode(d,o.status),o.message&&go.encode(d,o.message),o.event&&ho.encode(d,o.event)},decode(d){const o=lo.decode(d),c=n.decode(d),t=e.uint.decode(d),r=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:t,timestamp:r,editedAt:1&i?e.uint.decode(d):0,status:vo.decode(d),message:2&i?go.decode(d):null,event:4&i?ho.decode(d):null}}},wo=$,To=e.frame(co),Ao={preencode(e,d){wo.preencode(e,d.header),To.preencode(e,d.message)},encode(e,d){wo.encode(e,d.header),To.encode(e,d.message)},decode:e=>({header:wo.decode(e),message:To.decode(e)})},Po=$,So={preencode(e,d){Po.preencode(e,d.header),n.preencode(e,d.oplog)},encode(e,d){Po.encode(e,d.header),n.encode(e,d.oplog)},decode:e=>({header:Po.decode(e),oplog:n.decode(e)})},Io=$,Ro=To,Fo={preencode(e,d){Io.preencode(e,d.header),n.preencode(e,d.oplog),Ro.preencode(e,d.message)},encode(e,d){Io.encode(e,d.header),n.encode(e,d.oplog),Ro.encode(e,d.message)},decode:e=>({header:Io.decode(e),oplog:n.decode(e),message:Ro.decode(e)})},Ho=$,Mo={preencode(e,d){Ho.preencode(e,d.header),n.preencode(e,d.oplog),e.end++},encode(d,o){const c=o.isPinned?1:0;Ho.encode(d,o.header),n.encode(d,o.oplog),e.uint.encode(d,c)},decode:d=>({header:Ho.decode(d),oplog:n.decode(d),isPinned:!!(1&e.uint.decode(d))})},Co={preencode(d,o){lo.preencode(d,o.id),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),e.string.preencode(d,o.reaction)},encode(d,o){lo.encode(d,o.id),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),e.string.encode(d,o.reaction)},decode:d=>({id:lo.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),reaction:e.string.decode(d)})},Do={preencode(d,o){e.string.preencode(d,o.text),e.uint.preencode(d,o.count)},encode(d,o){e.string.encode(d,o.text),e.uint.encode(d,o.count)},decode:d=>({text:e.string.decode(d),count:e.uint.decode(d)})},Vo=e.array(e.frame(Do)),Lo={preencode(o,n){lo.preencode(o,n.id),e.uint.preencode(o,n.total),Vo.preencode(o,n.reactions),o.end++,d>=11&&n.editedAt&&e.uint.preencode(o,n.editedAt)},encode(o,n){const c=d>=11&&n.editedAt?1:0;lo.encode(o,n.id),e.uint.encode(o,n.total),Vo.encode(o,n.reactions),e.uint.encode(o,c),d>=11&&n.editedAt&&e.uint.encode(o,n.editedAt)},decode(o){const n=lo.decode(o),c=e.uint.decode(o),t=Vo.decode(o),r=o.start<o.end?e.uint.decode(o):0;return{id:n,total:c,reactions:t,editedAt:d>=11&&1&r?e.uint.decode(o):0}}},qo=$,Eo={preencode(d,o){qo.preencode(d,o.header),n.preencode(d,o.oplog),e.string.preencode(d,o.reaction)},encode(d,o){qo.encode(d,o.header),n.encode(d,o.oplog),e.string.encode(d,o.reaction)},decode:d=>({header:qo.decode(d),oplog:n.decode(d),reaction:e.string.decode(d)})},Bo=$,zo={preencode(d,o){Bo.preencode(d,o.header),n.preencode(d,o.oplog),e.string.preencode(d,o.reaction)},encode(d,o){Bo.encode(d,o.header),n.encode(d,o.oplog),e.string.encode(d,o.reaction)},decode:d=>({header:Bo.decode(d),oplog:n.decode(d),reaction:e.string.decode(d)})},No=$,jo=e.frame(Y),Oo={preencode(d,o){No.preencode(d,o.header),e.uint.preencode(d,o.key),jo.preencode(d,o.config)},encode(d,o){No.encode(d,o.header),e.uint.encode(d,o.key),jo.encode(d,o.config)},decode:d=>({header:No.decode(d),key:e.uint.decode(d),config:jo.decode(d)})},Uo={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.string.preencode(d,o.displayName),d.end++,o.avatar&&Gr.preencode(d,o.avatar)},encode(d,o){const n=o.avatar?1:0;e.fixed32.encode(d,o.memberKey),e.string.encode(d,o.displayName),e.uint.encode(d,n),o.avatar&&Gr.encode(d,o.avatar)},decode:d=>({memberKey:e.fixed32.decode(d),displayName:e.string.decode(d),avatar:1&e.uint.decode(d)?Gr.decode(d):null})},Jo={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++,o.username&&e.string.preencode(d,o.username)},encode(d,o){const n=o.username?1:0;e.fixed32.encode(d,o.key),e.uint.encode(d,n),o.username&&e.string.encode(d,o.username)},decode:d=>({key:e.fixed32.decode(d),username:1&e.uint.decode(d)?e.string.decode(d):null})},Go=e.frame(Jo),Qo={preencode(d,o){e.fixed32.preencode(d,o.publicKey),d.end++,o.discoveryCoreKey&&e.fixed32.preencode(d,o.discoveryCoreKey),o.userRegistry&&Go.preencode(d,o.userRegistry)},encode(d,o){const n=(o.discoveryCoreKey?1:0)|(o.userRegistry?2:0);e.fixed32.encode(d,o.publicKey),e.uint.encode(d,n),o.discoveryCoreKey&&e.fixed32.encode(d,o.discoveryCoreKey),o.userRegistry&&Go.encode(d,o.userRegistry)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d);return{publicKey:o,discoveryCoreKey:1&n?e.fixed32.decode(d):null,userRegistry:2&n?Go.decode(d):null}}},Wo=$,Xo=e.frame(G),Yo=e.frame(Q),Zo=jo,$o=e.frame(Qo),_o=be,en=e.array(e.frame(ue)),dn={preencode(e,d){Wo.preencode(e,d.header),Xo.preencode(e,d.digest),Yo.preencode(e,d.capabilities),e.end++,d.config&&Zo.preencode(e,d.config),d.identity&&$o.preencode(e,d.identity),d.bootstrapDevice&&_o.preencode(e,d.bootstrapDevice),d.initialMembers&&en.preencode(e,d.initialMembers)},encode(d,o){const n=(o.config?1:0)|(o.identity?2:0)|(o.bootstrapDevice?4:0)|(o.initialMembers?8:0);Wo.encode(d,o.header),Xo.encode(d,o.digest),Yo.encode(d,o.capabilities),e.uint.encode(d,n),o.config&&Zo.encode(d,o.config),o.identity&&$o.encode(d,o.identity),o.bootstrapDevice&&_o.encode(d,o.bootstrapDevice),o.initialMembers&&en.encode(d,o.initialMembers)},decode(d){const o=Wo.decode(d),n=Xo.decode(d),c=Yo.decode(d),t=e.uint.decode(d);return{header:o,digest:n,capabilities:c,config:1&t?Zo.decode(d):null,identity:2&t?$o.decode(d):null,bootstrapDevice:4&t?_o.decode(d):null,initialMembers:8&t?en.decode(d):null}}},on=$,nn={preencode(d,o){on.preencode(d,o.header),e.uint.preencode(d,o.version)},encode(d,o){on.encode(d,o.header),e.uint.encode(d,o.version)},decode:d=>({header:on.decode(d),version:e.uint.decode(d)})},cn=$,tn=J,rn={preencode(d,o){cn.preencode(d,o.header),e.uint.preencode(d,o.key),tn.preencode(d,o.settings)},encode(d,o){cn.encode(d,o.header),e.uint.encode(d,o.key),tn.encode(d,o.settings)},decode:d=>({header:cn.decode(d),key:e.uint.decode(d),settings:tn.decode(d)})},an={preencode(o,n){e.fixed32.preencode(o,n.memberKey),Qr.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=22&&n.contactInfo&&Wr.preencode(o,n.contactInfo),d>=22&&n.version&&e.uint.preencode(o,n.version),d>=24&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=22&&n.contactInfo?4:0)|(d>=22&&n.version?8:0)|(d>=24&&n.alias?16:0);e.fixed32.encode(o,n.memberKey),Qr.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=22&&n.contactInfo&&Wr.encode(o,n.contactInfo),d>=22&&n.version&&e.uint.encode(o,n.version),d>=24&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.fixed32.decode(o),c=Qr.decode(o),t=e.uint.decode(o);return{memberKey:n,status:c,mailbox:1&t?e.fixed32.decode(o):null,roomKey:2&t?e.fixed32.decode(o):null,contactInfo:d>=22&&4&t?Wr.decode(o):null,version:d>=22&&8&t?e.uint.decode(o):0,alias:d>=24&&16&t?e.string.decode(o):null}}},sn={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.seed),o.preencode(d,n.initiator),e.fixed32.preencode(d,n.fastForwardTo)},encode(d,n){e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.fixed32.encode(d,n.seed),o.encode(d,n.initiator),e.fixed32.encode(d,n.fastForwardTo)},decode:d=>({roomKey:e.fixed32.decode(d),encryptionKey:e.buffer.decode(d),seed:e.fixed32.decode(d),initiator:o.decode(d),fastForwardTo:e.fixed32.decode(d)})},pn=e.array(e.frame(sn)),un=X,ln={preencode(e,d){pn.preencode(e,d.sharedRooms),un.preencode(e,d.blockedContacts)},encode(e,d){pn.encode(e,d.sharedRooms),un.encode(e,d.blockedContacts)},decode:e=>({sharedRooms:pn.decode(e),blockedContacts:un.decode(e)})},fn=$o,mn={preencode(e,d){fn.preencode(e,d.identity)},encode(e,d){fn.encode(e,d.identity)},decode:e=>({identity:fn.decode(e)})},yn={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.contacts)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.contacts)},decode:d=>({rooms:e.uint.decode(d),contacts:e.uint.decode(d)})},bn={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.contactRequests)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.contactRequests)},decode:d=>({rooms:e.uint.decode(d),contactRequests:e.uint.decode(d)})},xn={preencode(d,o){e.buffer.preencode(d,o.entropy)},encode(d,o){e.buffer.encode(d,o.entropy)},decode:d=>({entropy:e.buffer.decode(d)})},kn={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.devicePublicKey),e.fixed32.preencode(d,o.writerKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.devicePublicKey),e.fixed32.encode(d,o.writerKey)},decode:d=>({publicKey:e.fixed32.decode(d),devicePublicKey:e.fixed32.decode(d),writerKey:e.fixed32.decode(d)})},vn=e.frame(kn),gn={preencode(n,c){e.fixed32.preencode(n,c.id),e.fixed32.preencode(n,c.invitationSeed),e.fixed32.preencode(n,c.mailbox),t.preencode(n,c.responseKeyPair),o.preencode(n,c.initiator),o.preencode(n,c.inviter),n.end++,c.identity&&vn.preencode(n,c.identity),d>=20&&c.buildType&&Bt.preencode(n,c.buildType),d>=27&&c.link&&o.preencode(n,c.link)},encode(n,c){const r=(c.identity?1:0)|(d>=20&&c.buildType?2:0)|(d>=27&&c.link?4:0);e.fixed32.encode(n,c.id),e.fixed32.encode(n,c.invitationSeed),e.fixed32.encode(n,c.mailbox),t.encode(n,c.responseKeyPair),o.encode(n,c.initiator),o.encode(n,c.inviter),e.uint.encode(n,r),c.identity&&vn.encode(n,c.identity),d>=20&&c.buildType&&Bt.encode(n,c.buildType),d>=27&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),r=e.fixed32.decode(n),i=e.fixed32.decode(n),a=t.decode(n),s=o.decode(n),p=o.decode(n),u=e.uint.decode(n);return{id:c,invitationSeed:r,mailbox:i,responseKeyPair:a,initiator:s,inviter:p,identity:1&u?vn.decode(n):null,buildType:d>=20&&2&u?Bt.decode(n):null,link:d>=27&&4&u?o.decode(n):null}}},hn=$,Kn={preencode(d,o){hn.preencode(d,o.header),e.buffer.preencode(d,o.blindResponse)},encode(d,o){hn.encode(d,o.header),e.buffer.encode(d,o.blindResponse)},decode:d=>({header:hn.decode(d),blindResponse:e.buffer.decode(d)})},wn=$,Tn=e.frame(gn),An={preencode(e,d){wn.preencode(e,d.header),Tn.preencode(e,d.invitation)},encode(e,d){wn.encode(e,d.header),Tn.encode(e,d.invitation)},decode:e=>({header:wn.decode(e),invitation:Tn.decode(e)})},Pn=$,Sn={preencode(d,o){Pn.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){Pn.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:Pn.decode(d),id:e.fixed32.decode(d)})},In={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.devicePublicKey),d.end++,o.privateProfileKey&&e.fixed32.preencode(d,o.privateProfileKey),o.deviceKeyPair&&t.preencode(d,o.deviceKeyPair),e.buffer.preencode(d,o.deviceProof)},encode(d,o){const n=(o.privateProfileKey?1:0)|(o.deviceKeyPair?2:0);e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.devicePublicKey),e.uint.encode(d,n),o.privateProfileKey&&e.fixed32.encode(d,o.privateProfileKey),o.deviceKeyPair&&t.encode(d,o.deviceKeyPair),e.buffer.encode(d,o.deviceProof)},decode(d){const o=e.fixed32.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{publicKey:o,devicePublicKey:n,privateProfileKey:1&c?e.fixed32.decode(d):null,deviceKeyPair:2&c?t.decode(d):null,deviceProof:e.buffer.decode(d)}}},Rn={preencode(o,n){o.end++,d>=25&&n.roomSnoozeTime&&e.uint.preencode(o,n.roomSnoozeTime)},encode(o,n){const c=(n.isActive?1:0)|(n.isFullyMuted?2:0)|(n.isMentionsOnlyMuted?4:0)|(d>=9&&n.isReadOnly?8:0)|(d>=18&&n.isFavorite?16:0)|(d>=21&&n.isUnread?32:0)|(d>=25&&n.roomSnoozeTime?64:0);e.uint.encode(o,c),d>=25&&n.roomSnoozeTime&&e.uint.encode(o,n.roomSnoozeTime)},decode(o){const n=e.uint.decode(o);return{isActive:!!(1&n),isFullyMuted:!!(2&n),isMentionsOnlyMuted:!!(4&n),isReadOnly:d>=9&&!!(8&n),isFavorite:d>=18&&!!(16&n),isUnread:d>=21&&!!(32&n),roomSnoozeTime:d>=25&&64&n?e.uint.decode(o):0}}},Fn=e.frame(Rn),Hn=e.frame(In),Mn=vn,Cn={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),Fn.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,c.initiator&&o.preencode(n,c.initiator),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),c.identitySwap&&Hn.preencode(n,c.identitySwap),d>=6&&c.identitySwapV2&&Mn.preencode(n,c.identitySwapV2),d>=10&&c.contact&&e.fixed32.preencode(n,c.contact),d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=29&&c.activeClock&&e.uint.preencode(n,c.activeClock)},encode(n,c){const t=(c.initiator?1:0)|(c.fastForwardTo?2:0)|(c.identitySwap?4:0)|(d>=6&&c.identitySwapV2?8:0)|(d>=10&&c.contact?16:0)|(d>=27&&c.bootFrom?32:0)|(d>=29&&c.activeClock?64:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),Fn.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,t),c.initiator&&o.encode(n,c.initiator),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),c.identitySwap&&Hn.encode(n,c.identitySwap),d>=6&&c.identitySwapV2&&Mn.encode(n,c.identitySwapV2),d>=10&&c.contact&&e.fixed32.encode(n,c.contact),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom),d>=29&&c.activeClock&&e.uint.encode(n,c.activeClock)},decode(n){const c=e.fixed32.decode(n),t=e.buffer.decode(n),r=e.fixed32.decode(n),i=Fn.decode(n),a=e.uint.decode(n),s=e.uint.decode(n);return{roomKey:c,encryptionKey:t,mailbox:r,status:i,clock:a,initiator:1&s?o.decode(n):null,fastForwardTo:2&s?e.fixed32.decode(n):null,identitySwap:4&s?Hn.decode(n):null,identitySwapV2:d>=6&&8&s?Mn.decode(n):null,contact:d>=10&&16&s?e.fixed32.decode(n):null,bootFrom:d>=27&&32&s?o.decode(n):null,activeClock:d>=29&&64&s?e.uint.decode(n):0}}},Dn=$,Vn={preencode(d,n){Dn.preencode(d,n.header),e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.mailbox),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.dm&&e.fixed32.preencode(d,n.dm)},encode(n,c){const t=(c.fastForwardTo?1:0)|(c.initiator?2:0)|(c.dm?4:0)|(d>=9&&c.isReadOnly?8:0);Dn.encode(n,c.header),e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),e.uint.encode(n,t),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),c.initiator&&o.encode(n,c.initiator),c.dm&&e.fixed32.encode(n,c.dm)},decode(n){const c=Dn.decode(n),t=e.fixed32.decode(n),r=e.buffer.decode(n),i=e.fixed32.decode(n),a=e.uint.decode(n);return{header:c,roomKey:t,encryptionKey:r,mailbox:i,fastForwardTo:1&a?e.fixed32.decode(n):null,initiator:2&a?o.decode(n):null,dm:4&a?e.fixed32.decode(n):null,isReadOnly:d>=9&&!!(8&a)}}},Ln=$,qn={preencode(d,o){Ln.preencode(d,o.header),e.fixed32.preencode(d,o.discoveryKey)},encode(d,o){Ln.encode(d,o.header),e.fixed32.encode(d,o.discoveryKey)},decode:d=>({header:Ln.decode(d),discoveryKey:e.fixed32.decode(d)})},En=$,Bn=Fn,zn={preencode(d,o){En.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.key),Bn.preencode(d,o.status)},encode(d,o){En.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.key),Bn.encode(d,o.status)},decode:d=>({header:En.decode(d),roomKey:e.fixed32.decode(d),key:e.uint.decode(d),status:Bn.decode(d)})},Nn={preencode(e,d){e.end++},encode(o,n){const c=(n.isBlocked?1:0)|(d>=22&&n.isActive?2:0);e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{isBlocked:!!(1&n),isActive:d>=22&&!!(2&n)}}},jn={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.clock),Xr.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=22&&n.contactInfo&&Yr.preencode(o,n.contactInfo),d>=24&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=22&&n.contactInfo?4:0)|(d>=24&&n.alias?8:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.clock),Xr.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=22&&n.contactInfo&&Yr.encode(o,n.contactInfo),d>=24&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),t=Xr.decode(o),r=e.uint.decode(o);return{memberKey:n,clock:c,status:t,mailbox:1&r?e.fixed32.decode(o):null,roomKey:2&r?e.fixed32.decode(o):null,contactInfo:d>=22&&4&r?Yr.decode(o):null,alias:d>=24&&8&r?e.string.decode(o):null}}},On=$,Un=e.frame(an),Jn={preencode(e,d){On.preencode(e,d.header),Un.preencode(e,d.contact)},encode(e,d){On.encode(e,d.header),Un.encode(e,d.contact)},decode:e=>({header:On.decode(e),contact:Un.decode(e)})},Gn=$,Qn={preencode(d,o){Gn.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),Zr.preencode(d,o.status)},encode(d,o){Gn.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),Zr.encode(d,o.status)},decode:d=>({header:Gn.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:Zr.decode(d)})},Wn=$,Xn={preencode(d,o){Wn.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Wn.encode(d,o.header),e.fixed32.encode(d,o.memberKey)},decode:d=>({header:Wn.decode(d),memberKey:e.fixed32.decode(d)})},Yn={preencode(e,d){e.end++},encode(d,o){const n=(o.isPending?1:0)|(o.isAccepted?2:0)|(o.isRejected?4:0)|(o.isDiscarded?8:0)|(o.isSeen?16:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isPending:!!(1&o),isAccepted:!!(2&o),isRejected:!!(4&o),isDiscarded:!!(8&o),isSeen:!!(16&o)}}},Zn=xe,$n=e.frame(r),_n={preencode(d,o){Zn.preencode(d,o.sender),$n.preencode(d,o.keys),e.fixed32.preencode(d,o.mailbox),d.end++,o.message&&e.string.preencode(d,o.message)},encode(d,o){const n=o.message?1:0;Zn.encode(d,o.sender),$n.encode(d,o.keys),e.fixed32.encode(d,o.mailbox),e.uint.encode(d,n),o.message&&e.string.encode(d,o.message)},decode:d=>({sender:Zn.decode(d),keys:$n.decode(d),mailbox:e.fixed32.decode(d),message:1&e.uint.decode(d)?e.string.decode(d):null})},ec=e.frame(_n),dc={preencode(e,d){ec.preencode(e,d.body),ne.preencode(e,d.attestation)},encode(e,d){ec.encode(e,d.body),ne.encode(e,d.attestation)},decode:e=>({body:ec.decode(e),attestation:ne.decode(e)})},oc=pe,nc=e.frame(Yn),cc=$n,tc={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.clock),oc.preencode(o,n.sender),nc.preencode(o,n.status),cc.preencode(o,n.keys),e.fixed32.preencode(o,n.mailbox),o.end++,n.message&&e.string.preencode(o,n.message),d>=11&&n.sentAt&&e.uint.preencode(o,n.sentAt),d>=22&&n.contactInfo&&$r.preencode(o,n.contactInfo)},encode(o,n){const c=(n.message?1:0)|(d>=11&&n.sentAt?2:0)|(d>=22&&n.contactInfo?4:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.clock),oc.encode(o,n.sender),nc.encode(o,n.status),cc.encode(o,n.keys),e.fixed32.encode(o,n.mailbox),e.uint.encode(o,c),n.message&&e.string.encode(o,n.message),d>=11&&n.sentAt&&e.uint.encode(o,n.sentAt),d>=22&&n.contactInfo&&$r.encode(o,n.contactInfo)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),t=oc.decode(o),r=nc.decode(o),i=cc.decode(o),a=e.fixed32.decode(o),s=e.uint.decode(o);return{memberKey:n,clock:c,sender:t,status:r,keys:i,mailbox:a,message:1&s?e.string.decode(o):null,sentAt:d>=11&&2&s?e.uint.decode(o):0,contactInfo:d>=22&&4&s?$r.decode(o):null}}},rc=$,ic={preencode(d,o){rc.preencode(d,o.header),e.buffer.preencode(d,o.blindRequest)},encode(d,o){rc.encode(d,o.header),e.buffer.encode(d,o.blindRequest)},decode:d=>({header:rc.decode(d),blindRequest:e.buffer.decode(d)})},ac=$,sc=nc,pc={preencode(o,n){ac.preencode(o,n.header),e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.key),sc.preencode(o,n.status),o.end++,d>=10&&n.roomKey&&e.fixed32.preencode(o,n.roomKey)},encode(o,n){const c=d>=10&&n.roomKey?1:0;ac.encode(o,n.header),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.key),sc.encode(o,n.status),e.uint.encode(o,c),d>=10&&n.roomKey&&e.fixed32.encode(o,n.roomKey)},decode(o){const n=ac.decode(o),c=e.fixed32.decode(o),t=e.uint.decode(o),r=sc.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{header:n,memberKey:c,key:t,status:r,roomKey:d>=10&&1&i?e.fixed32.decode(o):null}}},uc={preencode(d,o){e.uint.preencode(d,o.timestamp),e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.mailbox)},encode(d,o){e.uint.encode(d,o.timestamp),e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.mailbox)},decode:d=>({version:e.uint.decode(d),timestamp:e.uint.decode(d),key:e.fixed32.decode(d),mailbox:e.fixed32.decode(d)})},lc={preencode(d,o){const n=o.version??1;switch(e.uint.preencode(d,n),n){case 0:case 1:uc.preencode(d,o);break;default:throw new Error("Unsupported version")}},encode(d,o){const n=o.version??1;switch(e.uint.encode(d,n),n){case 0:case 1:uc.encode(d,o);break;default:throw new Error("Unsupported version")}},decode(d){const o=d.start,n=e.uint.decode(d);switch(d.start=o,n){case 0:case 1:return uc.decode(d);default:throw new Error("Unsupported version")}}},fc=$,mc={preencode(o,c){fc.preencode(o,c.header),n.preencode(o,c.oplog),e.uint.preencode(o,c.index),_r.preencode(o,c.preview),o.end++,d>=7&&c.displayType&&Pc.preencode(o,c.displayType)},encode(o,c){const t=d>=7&&c.displayType?1:0;fc.encode(o,c.header),n.encode(o,c.oplog),e.uint.encode(o,c.index),_r.encode(o,c.preview),e.uint.encode(o,t),d>=7&&c.displayType&&Pc.encode(o,c.displayType)},decode(o){const c=fc.decode(o),t=n.decode(o),r=e.uint.decode(o),i=_r.decode(o),a=o.start<o.end?e.uint.decode(o):0;return{header:c,oplog:t,index:r,preview:i,displayType:d>=7&&1&a?Pc.decode(o):0}}},yc={preencode(o,n){o.end++,d>=3&&n.memberKey&&e.fixed32.preencode(o,n.memberKey)},encode(o,n){const c=d>=3&&n.memberKey?1:0;e.uint.encode(o,c),d>=3&&n.memberKey&&e.fixed32.encode(o,n.memberKey)},decode(o){const n=e.uint.decode(o);return{memberKey:d>=3&&1&n?e.fixed32.decode(o):null}}},bc=pe,xc={preencode(e,d){bc.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){bc.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:bc.decode(e),attestation:ne.decode(e)})},kc=$,vc={preencode(d,o){kc.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){kc.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:kc.decode(d),key:e.fixed32.decode(d)})},gc={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),ne.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){e.fixed32.encode(d,o.deviceKey),ne.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({deviceKey:e.fixed32.decode(d),privateProfileIdentity:ne.decode(d),deviceProof:e.buffer.decode(d)})},hc={preencode(o,n){e.fixed32.preencode(o,n.roomKey),e.fixed32.preencode(o,n.encryptionKey),e.fixed32.preencode(o,n.seed),o.end++,d>=6&&n.fastForwardTo&&e.fixed32.preencode(o,n.fastForwardTo)},encode(o,n){const c=d>=6&&n.fastForwardTo?1:0;e.fixed32.encode(o,n.roomKey),e.fixed32.encode(o,n.encryptionKey),e.fixed32.encode(o,n.seed),e.uint.encode(o,c),d>=6&&n.fastForwardTo&&e.fixed32.encode(o,n.fastForwardTo)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=e.fixed32.decode(o),r=e.uint.decode(o);return{roomKey:n,encryptionKey:c,seed:t,fastForwardTo:d>=6&&1&r?e.fixed32.decode(o):null}}},Kc={preencode(o,n){e.fixed32.preencode(o,n.publicKey),e.fixed32.preencode(o,n.writerKey),e.fixed32.preencode(o,n.devicePublicKey),o.end++,d>=6&&n.privateProfileKey&&e.fixed32.preencode(o,n.privateProfileKey)},encode(o,n){const c=d>=6&&n.privateProfileKey?1:0;e.fixed32.encode(o,n.publicKey),e.fixed32.encode(o,n.writerKey),e.fixed32.encode(o,n.devicePublicKey),e.uint.encode(o,c),d>=6&&n.privateProfileKey&&e.fixed32.encode(o,n.privateProfileKey)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=e.fixed32.decode(o),r=e.uint.decode(o);return{publicKey:n,writerKey:c,devicePublicKey:t,privateProfileKey:d>=6&&1&r?e.fixed32.decode(o):null}}},wc=$,Tc={preencode(d,o){wc.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey)},encode(d,o){wc.encode(d,o.header),e.fixed32.encode(d,o.memberKey)},decode:d=>({header:wc.decode(d),memberKey:e.fixed32.decode(d)})},Ac={HttpLink:1,PearLink:2},Pc={preencode(e,d){e.end++},encode(d,o){if(o>2)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Sc=$,Ic={preencode(d,o){Sc.preencode(d,o.header),e.uint.preencode(d,o.value)},encode(d,o){Sc.encode(d,o.header),e.uint.encode(d,o.value)},decode:d=>({header:Sc.decode(d),value:e.uint.decode(d)})},Rc={preencode(d,o){e.uint.preencode(d,o.key),e.uint.preencode(d,o.value)},encode(d,o){e.uint.encode(d,o.key),e.uint.encode(d,o.value)},decode:d=>({key:e.uint.decode(d),value:e.uint.decode(d)})},Fc=$,Hc={preencode(o,n){Fc.preencode(o,n.header),e.uint.preencode(o,n.from),e.uint.preencode(o,n.to),o.end++,d>=20&&n.buildType&&Bt.preencode(o,n.buildType)},encode(o,n){const c=d>=20&&n.buildType?1:0;Fc.encode(o,n.header),e.uint.encode(o,n.from),e.uint.encode(o,n.to),e.uint.encode(o,c),d>=20&&n.buildType&&Bt.encode(o,n.buildType)},decode(o){const n=Fc.decode(o),c=e.uint.decode(o),t=e.uint.decode(o),r=o.start<o.end?e.uint.decode(o):0;return{header:n,from:c,to:t,buildType:d>=20&&1&r?Bt.decode(o):null}}},Mc={RoomType:1,IsExperimental:2,IsJoiningDisabled:3,IsAppendingDisabled:4,IsCallingDisabled:5,IsMembershipEventsDisabled:6,IsAttachmentsDisabled:7,IsLinksDisabled:8,IsRoomInviteHidden:9},Cc={preencode(e,d){e.end++},encode(d,o){if(o>9)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Dc={en:"en",it:"it",ru:"ru",es:"es",de:"de"},Vc={preencode(e,d){e.end++},encode(d,o){switch(o){case"en":e.uint.encode(d,1);break;case"it":e.uint.encode(d,2);break;case"ru":e.uint.encode(d,3);break;case"es":e.uint.encode(d,4);break;case"de":e.uint.encode(d,5);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"en";case 2:return"it";case 3:return"ru";case 4:return"es";case 5:return"de";default:return null}}},Lc=Dd,qc={preencode(d,o){Lc.preencode(d,o.range),Vc.preencode(d,o.language),e.string.preencode(d,o.text)},encode(d,o){Lc.encode(d,o.range),Vc.encode(d,o.language),e.string.encode(d,o.text)},decode:d=>({range:Lc.decode(d),language:Vc.decode(d),text:e.string.decode(d)})},Ec={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.key)},decode:d=>({deviceKey:e.fixed32.decode(d),key:e.fixed32.decode(d)})},Bc=$,zc={preencode(d,o){Bc.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){Bc.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:Bc.decode(d),key:e.fixed32.decode(d)})},Nc=$,jc={preencode(d,o){Nc.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){Nc.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:Nc.decode(d),key:e.fixed32.decode(d)})},Oc={Flag:1},Uc={preencode(e,d){e.end++},encode(d,o){if(o>1)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Jc={preencode(d,o){lo.preencode(d,o.id),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),Uc.preencode(d,o.label)},encode(d,o){lo.encode(d,o.id),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),Uc.encode(d,o.label)},decode:d=>({id:lo.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),label:Uc.decode(d)})},Gc=$,Qc={preencode(e,d){Gc.preencode(e,d.header),n.preencode(e,d.oplog),Uc.preencode(e,d.label)},encode(e,d){Gc.encode(e,d.header),n.encode(e,d.oplog),Uc.encode(e,d.label)},decode:e=>({header:Gc.decode(e),oplog:n.decode(e),label:Uc.decode(e)})},Wc=$,Xc={preencode(e,d){Wc.preencode(e,d.header),n.preencode(e,d.oplog),Uc.preencode(e,d.label)},encode(e,d){Wc.encode(e,d.header),n.encode(e,d.oplog),Uc.encode(e,d.label)},decode:e=>({header:Wc.decode(e),oplog:n.decode(e),label:Uc.decode(e)})},Yc={preencode(d,o){Uc.preencode(d,o.label),e.uint.preencode(d,o.count)},encode(d,o){Uc.encode(d,o.label),e.uint.encode(d,o.count)},decode:d=>({label:Uc.decode(d),count:e.uint.decode(d)})},Zc=e.array(e.frame(Yc)),$c={preencode(o,n){lo.preencode(o,n.id),e.uint.preencode(o,n.total),Zc.preencode(o,n.labels),e.uint.preencode(o,n.editedAt),o.end++,d>=15&&n.flagsClock&&e.uint.preencode(o,n.flagsClock),d>=15&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(d>=15&&n.flagsClock?1:0)|(d>=15&&n.version?2:0)|(d>=16&&n.isDeleted?4:0);lo.encode(o,n.id),e.uint.encode(o,n.total),Zc.encode(o,n.labels),e.uint.encode(o,n.editedAt),e.uint.encode(o,c),d>=15&&n.flagsClock&&e.uint.encode(o,n.flagsClock),d>=15&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=lo.decode(o),c=e.uint.decode(o),t=Zc.decode(o),r=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{id:n,total:c,labels:t,editedAt:r,flagsClock:d>=15&&1&i?e.uint.decode(o):0,version:d>=15&&2&i?e.uint.decode(o):0,isDeleted:d>=16&&!!(4&i)}}},_c=$,et={preencode(d,o){_c.preencode(d,o.header),e.uint.preencode(d,o.length)},encode(d,o){_c.encode(d,o.header),e.uint.encode(d,o.length)},decode:d=>({header:_c.decode(d),length:e.uint.decode(d)})},dt={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.length)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.length)},decode:d=>({memberKey:e.fixed32.decode(d),length:e.uint.decode(d)})},ot=Z,nt={preencode(o,n){o.end++,d>=23&&n.profileSnoozeTime&&e.uint.preencode(o,n.profileSnoozeTime)},encode(o,n){const c=(d>=13&&n.disableReadReceipts?1:0)|(d>=21&&n.stripAttachmentMetadata?2:0)|(d>=23&&n.profileSnoozeTime?4:0);e.uint.encode(o,c),d>=23&&n.profileSnoozeTime&&e.uint.encode(o,n.profileSnoozeTime)},decode(o){const n=e.uint.decode(o);return{disableReadReceipts:d>=13&&!!(1&n),stripAttachmentMetadata:d>=21&&!!(2&n),profileSnoozeTime:d>=23&&4&n?e.uint.decode(o):0}}},ct={disableReadReceipts:"disableReadReceipts",stripAttachmentMetadata:"stripAttachmentMetadata",profileSnoozeTime:"profileSnoozeTime"},tt={preencode(e,d){e.end++},encode(d,o){switch(o){case"disableReadReceipts":e.uint.encode(d,1);break;case"stripAttachmentMetadata":e.uint.encode(d,2);break;case"profileSnoozeTime":e.uint.encode(d,3);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"disableReadReceipts";case 2:return"stripAttachmentMetadata";case 3:return"profileSnoozeTime";default:return null}}},rt=$,it=e.frame(nt),at={preencode(e,d){rt.preencode(e,d.header),tt.preencode(e,d.key),it.preencode(e,d.settings)},encode(e,d){rt.encode(e,d.header),tt.encode(e,d.key),it.encode(e,d.settings)},decode:e=>({header:rt.decode(e),key:tt.decode(e),settings:it.decode(e)})},st={Flag:1},pt={preencode(e,d){e.end++},encode(d,o){if(o>1)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},ut={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),pt.preencode(d,o.label)},encode(d,o){e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),pt.encode(d,o.label)},decode:d=>({key:e.fixed32.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),label:pt.decode(d)})},lt=$,ft={preencode(d,o){lt.preencode(d,o.header),e.fixed32.preencode(d,o.key),pt.preencode(d,o.label)},encode(d,o){lt.encode(d,o.header),e.fixed32.encode(d,o.key),pt.encode(d,o.label)},decode:d=>({header:lt.decode(d),key:e.fixed32.decode(d),label:pt.decode(d)})},mt={preencode(d,o){pt.preencode(d,o.label),e.uint.preencode(d,o.count)},encode(d,o){pt.encode(d,o.label),e.uint.encode(d,o.count)},decode:d=>({label:pt.decode(d),count:e.uint.decode(d)})},yt=e.array(e.frame(mt)),bt={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.total),yt.preencode(d,o.labels),e.uint.preencode(d,o.editedAt),e.uint.preencode(d,o.flagsClock)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.total),yt.encode(d,o.labels),e.uint.encode(d,o.editedAt),e.uint.encode(d,o.flagsClock)},decode:d=>({key:e.fixed32.decode(d),total:e.uint.decode(d),labels:yt.decode(d),editedAt:e.uint.decode(d),flagsClock:e.uint.decode(d)})},xt={preencode(d,o){e.float64.preencode(d,o.latitude),e.float64.preencode(d,o.longitude)},encode(d,o){e.float64.encode(d,o.latitude),e.float64.encode(d,o.longitude)},decode:d=>({latitude:e.float64.decode(d),longitude:e.float64.decode(d)})},kt=$,vt={preencode(d,o){kt.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.fromDeviceKey)},encode(d,o){kt.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.fromDeviceKey)},decode:d=>({header:kt.decode(d),deviceKey:e.fixed32.decode(d),fromDeviceKey:e.fixed32.decode(d)})},gt=$,ht=X,Kt={preencode(o,n){gt.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),e.buffer.preencode(o,n.encryptionKey),o.end++,d>=19&&n.streams&&ht.preencode(o,n.streams),d>=19&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=19&&n.version&&e.uint.preencode(o,n.version),d>=26&&n.streamInputs&&ei.preencode(o,n.streamInputs),d>=26&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey)},encode(o,n){const c=(d>=19&&n.streams?1:0)|(d>=19&&n.discoveryKey?2:0)|(d>=19&&n.version?4:0)|(d>=26&&n.streamInputs?8:0)|(d>=26&&n.swarmKey?16:0);gt.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,c),d>=19&&n.streams&&ht.encode(o,n.streams),d>=19&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=19&&n.version&&e.uint.encode(o,n.version),d>=26&&n.streamInputs&&ei.encode(o,n.streamInputs),d>=26&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey)},decode(o){const n=gt.decode(o),c=e.fixed32.decode(o),t=e.buffer.decode(o),r=e.uint.decode(o);return{header:n,callKey:c,encryptionKey:t,streams:d>=19&&1&r?ht.decode(o):null,discoveryKey:d>=19&&2&r?e.fixed32.decode(o):null,version:d>=19&&4&r?e.uint.decode(o):0,streamInputs:d>=26&&8&r?ei.decode(o):null,swarmKey:d>=26&&16&r?e.fixed32.decode(o):null}}},wt=$,Tt=X,At={preencode(o,n){wt.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),o.end++,d>=19&&n.streams&&Tt.preencode(o,n.streams),d>=26&&n.streamInputs&&di.preencode(o,n.streamInputs),d>=26&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey)},encode(o,n){const c=(d>=19&&n.streams?1:0)|(d>=26&&n.streamInputs?2:0)|(d>=26&&n.swarmKey?4:0);wt.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.uint.encode(o,c),d>=19&&n.streams&&Tt.encode(o,n.streams),d>=26&&n.streamInputs&&di.encode(o,n.streamInputs),d>=26&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey)},decode(o){const n=wt.decode(o),c=e.fixed32.decode(o),t=e.uint.decode(o);return{header:n,callKey:c,streams:d>=19&&1&t?Tt.decode(o):null,streamInputs:d>=26&&2&t?di.decode(o):null,swarmKey:d>=26&&4&t?e.fixed32.decode(o):null}}},Pt=$,St={preencode(d,o){Pt.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Pt.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Pt.decode(d),callKey:e.fixed32.decode(d)})},It=$,Rt={preencode(d,o){It.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){It.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:It.decode(d),callKey:e.fixed32.decode(d)})},Ft=$,Ht={preencode(o,n){Ft.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.streamKey),o.end++,d>=26&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=26&&n.type&&e.string.preencode(o,n.type)},encode(o,n){const c=(d>=26&&n.mediaStreamId?1:0)|(d>=26&&n.type?2:0)|(d>=26&&n.muted?4:0);Ft.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.streamKey),e.uint.encode(o,c),d>=26&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=26&&n.type&&e.string.encode(o,n.type)},decode(o){const n=Ft.decode(o),c=e.fixed32.decode(o),t=e.fixed32.decode(o),r=o.start<o.end?e.uint.decode(o):0;return{header:n,callKey:c,streamKey:t,mediaStreamId:d>=26&&1&r?e.string.decode(o):null,type:d>=26&&2&r?e.string.decode(o):null,muted:d>=26&&!!(4&r)}}},Mt=$,Ct={preencode(d,o){Mt.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.streamKey)},encode(d,o){Mt.encode(d,o.header),e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.streamKey)},decode:d=>({header:Mt.decode(d),callKey:e.fixed32.decode(d),streamKey:e.fixed32.decode(d)})},Dt={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.buffer.preencode(o,n.encryptionKey),e.uint.preencode(o,n.createdAt),o.end++,d>=19&&n.endedAt&&e.uint.preencode(o,n.endedAt),d>=19&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=19&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(d>=19&&n.endedAt?1:0)|(d>=19&&n.discoveryKey?2:0)|(d>=19&&n.version?4:0);e.fixed32.encode(o,n.callKey),e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=19&&n.endedAt&&e.uint.encode(o,n.endedAt),d>=19&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=19&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=e.fixed32.decode(o),c=e.buffer.decode(o),t=e.uint.decode(o),r=e.uint.decode(o);return{callKey:n,encryptionKey:c,createdAt:t,endedAt:d>=19&&1&r?e.uint.decode(o):0,discoveryKey:d>=19&&2&r?e.fixed32.decode(o):null,version:d>=19&&4&r?e.uint.decode(o):0}}},Vt={preencode(d,o){e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.createdAt)},encode(d,o){e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.createdAt)},decode:d=>({callKey:e.fixed32.decode(d),memberKey:e.fixed32.decode(d),createdAt:e.uint.decode(d)})},Lt={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.deviceKey),e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.createdAt),o.end++,d>=19&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),d>=22&&n.lastHeartbeatAt&&e.uint.preencode(o,n.lastHeartbeatAt)},encode(o,n){const c=(d>=19&&n.swarmKey?1:0)|(d>=22&&n.lastHeartbeatAt?2:0)|(d>=23&&n.isRecording?4:0);e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.deviceKey),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=19&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey),d>=22&&n.lastHeartbeatAt&&e.uint.encode(o,n.lastHeartbeatAt)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=e.fixed32.decode(o),r=e.uint.decode(o),i=e.uint.decode(o);return{callKey:n,deviceKey:c,memberKey:t,createdAt:r,swarmKey:d>=19&&1&i?e.fixed32.decode(o):null,lastHeartbeatAt:d>=22&&2&i?e.uint.decode(o):0,isRecording:d>=23&&!!(4&i)}}},qt={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.deviceKey),e.buffer.preencode(o,n.streamKey),e.uint.preencode(o,n.createdAt),o.end++,d>=26&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=26&&n.type&&e.string.preencode(o,n.type),d>=26&&n.statusKey&&e.uint.preencode(o,n.statusKey)},encode(o,n){const c=(d>=26&&n.mediaStreamId?1:0)|(d>=26&&n.type?2:0)|(d>=26&&n.statusKey?4:0);e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.deviceKey),e.buffer.encode(o,n.streamKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=26&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=26&&n.type&&e.string.encode(o,n.type),d>=26&&n.statusKey&&e.uint.encode(o,n.statusKey)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=e.buffer.decode(o),r=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{callKey:n,deviceKey:c,streamKey:t,createdAt:r,mediaStreamId:d>=26&&1&i?e.string.decode(o):null,type:d>=26&&2&i?e.string.decode(o):null,statusKey:d>=26&&4&i?e.uint.decode(o):0}}},Et={Nightly:"Nightly",Internal:"Internal",Production:"Production"},Bt={preencode(e,d){e.end++},encode(d,o){switch(o){case"Nightly":e.uint.encode(d,1);break;case"Internal":e.uint.encode(d,2);break;case"Production":e.uint.encode(d,3);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"Nightly";case 2:return"Internal";case 3:return"Production";default:return null}}},zt=$,Nt={preencode(e,d){zt.preencode(e,d.header)},encode(e,d){zt.encode(e,d.header)},decode:e=>({header:zt.decode(e)})},jt=$,Ot={preencode(e,d){jt.preencode(e,d.header)},encode(e,d){jt.encode(e,d.header)},decode:e=>({header:jt.decode(e)})},Ut=$,Jt={preencode(d,o){Ut.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),e.buffer.preencode(d,o.deviceProof),e.buffer.preencode(d,o.writerProof)},encode(d,o){Ut.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.buffer.encode(d,o.deviceProof),e.buffer.encode(d,o.writerProof)},decode:d=>({header:Ut.decode(d),deviceKey:e.fixed32.decode(d),deviceProof:e.buffer.decode(d),writerProof:e.buffer.decode(d)})},Gt=$,Qt={preencode(d,o){Gt.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Gt.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Gt.decode(d),callKey:e.fixed32.decode(d)})},Wt=$,Xt={preencode(d,o){Wt.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.deviceKey)},encode(d,o){Wt.encode(d,o.header),e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.deviceKey)},decode:d=>({header:Wt.decode(d),callKey:e.fixed32.decode(d),deviceKey:e.fixed32.decode(d)})},Yt=$,Zt={preencode(d,o){Yt.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Yt.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Yt.decode(d),callKey:e.fixed32.decode(d)})},$t=$,_t={preencode(d,o){$t.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){$t.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:$t.decode(d),callKey:e.fixed32.decode(d)})},er=$,dr={preencode(e,d){er.preencode(e,d.header),n.preencode(e,d.oplog)},encode(e,d){er.encode(e,d.header),n.encode(e,d.oplog)},decode:e=>({header:er.decode(e),oplog:n.decode(e)})},or=$,nr={preencode(e,d){or.preencode(e,d.header)},encode(e,d){or.encode(e,d.header)},decode:e=>({header:or.decode(e)})},cr={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.timestamp)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.timestamp)},decode:d=>({memberKey:e.fixed32.decode(d),timestamp:e.uint.decode(d)})},tr=$,rr={preencode(o,n){tr.preencode(o,n.header),e.fixed32.preencode(o,n.memberKey),o.end++,d>=24&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=d>=24&&n.alias?1:0;tr.encode(o,n.header),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,c),d>=24&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=tr.decode(o),c=e.fixed32.decode(o),t=e.uint.decode(o);return{header:n,memberKey:c,alias:d>=24&&1&t?e.string.decode(o):null}}},ir={preencode(d,o){e.uint.preencode(d,o.streams)},encode(d,o){e.uint.encode(d,o.streams)},decode:d=>({streams:e.uint.decode(d)})},ar={preencode(d,o){e.fixed32.preencode(d,o.streamKey),e.string.preencode(d,o.mediaStreamId),e.string.preencode(d,o.type),d.end++},encode(o,n){const c=d>=26&&n.muted?1:0;e.fixed32.encode(o,n.streamKey),e.string.encode(o,n.mediaStreamId),e.string.encode(o,n.type),e.uint.encode(o,c)},decode(o){const n=e.fixed32.decode(o),c=e.string.decode(o),t=e.string.decode(o),r=e.uint.decode(o);return{streamKey:n,mediaStreamId:c,type:t,muted:d>=26&&!!(1&r)}}},sr=$,pr={preencode(d,o){sr.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.streamKey),d.end++},encode(o,n){const c=d>=26&&n.muted?1:0;sr.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.streamKey),e.uint.encode(o,c)},decode(o){const n=sr.decode(o),c=e.fixed32.decode(o),t=e.fixed32.decode(o),r=e.uint.decode(o);return{header:n,callKey:c,streamKey:t,muted:d>=26&&!!(1&r)}}},ur={preencode(d,o){e.uint.preencode(d,o.statusKey),d.end++},encode(o,n){const c=d>=26&&n.muted?1:0;e.uint.encode(o,n.statusKey),e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o),c=e.uint.decode(o);return{statusKey:n,muted:d>=26&&!!(1&c)}}},lr={preencode(n,c){e.fixed32.preencode(n,c.key),n.end++,d>=27&&c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const t=(d>=27&&c.encryptionKey?1:0)|(d>=27&&c.bootFrom?2:0);e.fixed32.encode(n,c.key),e.uint.encode(n,t),d>=27&&c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),t=e.uint.decode(n);return{key:c,encryptionKey:d>=27&&1&t?e.buffer.decode(n):null,bootFrom:d>=27&&2&t?o.decode(n):null}}},fr={preencode(d,o){e.fixed32.preencode(d,o.hash)},encode(d,o){e.fixed32.encode(d,o.hash)},decode:d=>({hash:e.fixed32.decode(d)})},mr={preencode(d,o){e.fixed32.preencode(d,o.hash),e.buffer.preencode(d,o.data)},encode(d,o){e.fixed32.encode(d,o.hash),e.buffer.encode(d,o.data)},decode:d=>({hash:e.fixed32.decode(d),data:e.buffer.decode(d)})},yr={preencode(n,c){o.preencode(n,c.autobeeMigrationHead),n.end++,d>=27&&c.legacyViewHead&&o.preencode(n,c.legacyViewHead),d>=27&&c.dbViewHead&&o.preencode(n,c.dbViewHead),d>=27&&c.blobsViewHead&&o.preencode(n,c.blobsViewHead),e.uint.preencode(n,c.createdAt)},encode(n,c){const t=(d>=27&&c.legacyViewHead?1:0)|(d>=27&&c.dbViewHead?2:0)|(d>=27&&c.blobsViewHead?4:0);o.encode(n,c.autobeeMigrationHead),e.uint.encode(n,t),d>=27&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=27&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=27&&c.blobsViewHead&&o.encode(n,c.blobsViewHead),e.uint.encode(n,c.createdAt)},decode(n){const c=o.decode(n),t=e.uint.decode(n);return{autobeeMigrationHead:c,legacyViewHead:d>=27&&1&t?o.decode(n):null,dbViewHead:d>=27&&2&t?o.decode(n):null,blobsViewHead:d>=27&&4&t?o.decode(n):null,createdAt:e.uint.decode(n)}}},br=$,xr={preencode(e,n){br.preencode(e,n.header),o.preencode(e,n.head),e.end++,d>=27&&n.legacyViewHead&&o.preencode(e,n.legacyViewHead),d>=27&&n.dbViewHead&&o.preencode(e,n.dbViewHead),d>=27&&n.blobsViewHead&&o.preencode(e,n.blobsViewHead)},encode(n,c){const t=(d>=27&&c.legacyViewHead?1:0)|(d>=27&&c.dbViewHead?2:0)|(d>=27&&c.blobsViewHead?4:0);br.encode(n,c.header),o.encode(n,c.head),e.uint.encode(n,t),d>=27&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=27&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=27&&c.blobsViewHead&&o.encode(n,c.blobsViewHead)},decode(n){const c=br.decode(n),t=o.decode(n),r=e.uint.decode(n);return{header:c,head:t,legacyViewHead:d>=27&&1&r?o.decode(n):null,dbViewHead:d>=27&&2&r?o.decode(n):null,blobsViewHead:d>=27&&4&r?o.decode(n):null}}},kr={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.fixed32.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.seed),n.end++,d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const t=d>=27&&c.bootFrom?1:0;e.fixed32.encode(n,c.roomKey),e.fixed32.encode(n,c.encryptionKey),e.fixed32.encode(n,c.seed),e.uint.encode(n,t),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),t=e.fixed32.decode(n),r=e.fixed32.decode(n),i=e.uint.decode(n);return{roomKey:c,encryptionKey:t,seed:r,bootFrom:d>=27&&1&i?o.decode(n):null}}},vr=id,gr={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.fixed32.preencode(d,o.deviceKey),e.uint.preencode(d,o.deviceLength),e.uint.preencode(d,o.clock),vr.preencode(d,o.status)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,o.deviceLength),e.uint.encode(d,o.clock),vr.encode(d,o.status)},decode:d=>({memberKey:e.fixed32.decode(d),deviceKey:e.fixed32.decode(d),deviceLength:e.uint.decode(d),clock:e.uint.decode(d),status:vr.decode(d)})},hr={preencode(d,o){e.fixed32.preencode(d,o.hash),e.buffer.preencode(d,o.blob)},encode(d,o){e.fixed32.encode(d,o.hash),e.buffer.encode(d,o.blob)},decode:d=>({hash:e.fixed32.decode(d),blob:e.buffer.decode(d)})},Kr=Fn,wr=Hn,Tr=vn,Ar={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),Kr.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,d>=27&&c.initiator&&o.preencode(n,c.initiator),d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=27&&c.identitySwap&&wr.preencode(n,c.identitySwap),d>=27&&c.identitySwapV2&&Tr.preencode(n,c.identitySwapV2),d>=27&&c.contact&&e.fixed32.preencode(n,c.contact)},encode(n,c){const t=(d>=27&&c.initiator?1:0)|(d>=27&&c.bootFrom?2:0)|(d>=27&&c.identitySwap?4:0)|(d>=27&&c.identitySwapV2?8:0)|(d>=27&&c.contact?16:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),Kr.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,t),d>=27&&c.initiator&&o.encode(n,c.initiator),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom),d>=27&&c.identitySwap&&wr.encode(n,c.identitySwap),d>=27&&c.identitySwapV2&&Tr.encode(n,c.identitySwapV2),d>=27&&c.contact&&e.fixed32.encode(n,c.contact)},decode(n){const c=e.fixed32.decode(n),t=e.buffer.decode(n),r=e.fixed32.decode(n),i=Kr.decode(n),a=e.uint.decode(n),s=e.uint.decode(n);return{roomKey:c,encryptionKey:t,mailbox:r,status:i,clock:a,initiator:d>=27&&1&s?o.decode(n):null,bootFrom:d>=27&&2&s?o.decode(n):null,identitySwap:d>=27&&4&s?wr.decode(n):null,identitySwapV2:d>=27&&8&s?Tr.decode(n):null,contact:d>=27&&16&s?e.fixed32.decode(n):null}}},Pr=$,Sr={preencode(n,c){Pr.preencode(n,c.header),e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),n.end++,d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=27&&c.initiator&&o.preencode(n,c.initiator),d>=27&&c.dm&&e.fixed32.preencode(n,c.dm)},encode(n,c){const t=(d>=27&&c.bootFrom?1:0)|(d>=27&&c.initiator?2:0)|(d>=27&&c.dm?4:0)|(d>=27&&c.isReadOnly?8:0);Pr.encode(n,c.header),e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),e.uint.encode(n,t),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom),d>=27&&c.initiator&&o.encode(n,c.initiator),d>=27&&c.dm&&e.fixed32.encode(n,c.dm)},decode(n){const c=Pr.decode(n),t=e.fixed32.decode(n),r=e.buffer.decode(n),i=e.fixed32.decode(n),a=e.uint.decode(n);return{header:c,roomKey:t,encryptionKey:r,mailbox:i,bootFrom:d>=27&&1&a?o.decode(n):null,initiator:d>=27&&2&a?o.decode(n):null,dm:d>=27&&4&a?e.fixed32.decode(n):null,isReadOnly:d>=27&&!!(8&a)}}},Ir={preencode(d,o){e.fixed32.preencode(d,o.id),e.fixed32.preencode(d,o.writerKey),e.buffer.preencode(d,o.blindResponse)},encode(d,o){e.fixed32.encode(d,o.id),e.fixed32.encode(d,o.writerKey),e.buffer.encode(d,o.blindResponse)},decode:d=>({id:e.fixed32.decode(d),writerKey:e.fixed32.decode(d),blindResponse:e.buffer.decode(d)})},Rr=$,Fr={preencode(d,o){Rr.preencode(d,o.header),e.buffer.preencode(d,o.blindResponse)},encode(d,o){Rr.encode(d,o.header),e.buffer.encode(d,o.blindResponse)},decode:d=>({header:Rr.decode(d),blindResponse:e.buffer.decode(d)})},Hr=e.frame(w),Mr=e.frame(ir),Cr=Hr,Dr=e.array(Vc),Vr=e.frame(se),Lr=Hr,qr=Vr,Er=e.frame(hc),Br=e.frame(kr),zr=Vr,Nr=e.frame(fd),jr=e.frame(yc),Or=e.frame(xt),Ur=Or,Jr=e.array(e.frame(qc)),Gr=Hr,Qr=e.frame(Nn),Wr=e.frame(xc),Xr=Qr,Yr=Wr,Zr=Qr,$r=Wr,_r=Hr,ei=e.array(e.frame(ar)),di=ei;function oi(e){switch(e){case"@keet/head":return o;case"@keet/oplog-id":return n;case"@keet/encryption-keypair":return c;case"@keet/signing-keypair":return t;case"@keet/room-keys":return r;case"@keet/operation-header":return i;case"@keet/blob-pointer":return a;case"@keet/file-dimensions":return s;case"@keet/file-metadata":return u;case"@keet/external-drive-pointer":return l;case"@keet/external-blob-pointer":return f;case"@keet/file-pointer":return b;case"@keet/file":return v;case"@keet/image-file":return w;case"@keet/file-status":return T;case"@keet/file-record":return S;case"@keet/device-status":return I;case"@keet/member-status":return R;case"@keet/member-moderation-status":return F;case"@keet/abi":return H;case"@keet/device-stats":return M;case"@keet/member-stats":return C;case"@keet/chat-stats":return D;case"@keet/file-stats":return V;case"@keet/stats":return z;case"@keet/room-type":return j;case"@keet/system-settings":return O;case"@keet/system-digest":return G;case"@keet/room-seed":return Q;case"@keet/room-capabilities":return W;case"@keet/room-config":return Y;case"@keet/blind-peer":return Z;case"@keet/add-blind-peer-operation":return ee;case"@keet/remove-blind-peer-operation":return oe;case"@keet/identity-attestation":return ne;case"@keet/device-invitation":return ce;case"@keet/device":return ie;case"@keet/member-profile":return ae;case"@keet/device-profile":return se;case"@keet/member-update":return ue;case"@keet/device-update":return le;case"@keet/signed-pairing-data":return fe;case"@keet/device-request-identity":return me;case"@keet/device-response-identity":return ye;case"@keet/device-request-with-invitation":return ve;case"@keet/device-request-with-invitation-and-proof":return he;case"@keet/device-request-with-member-proof":return Te;case"@keet/device-request":return Se;case"@keet/device-response":return Fe;case"@keet/invitation-metadata":return He;case"@keet/invitation":return De;case"@keet/add-invitation-operation":return qe;case"@keet/remove-invitation-operation":return Be;case"@keet/sendable-room-invitation":return ze;case"@keet/sendable-identity-invitation":return Ne;case"@keet/sendable-contact-invitation":return je;case"@keet/sendable-invitation":return Qe;case"@keet/add-device-operation":return Xe;case"@keet/update-device-operation":return Ze;case"@keet/start-indexing-operation":return $e;case"@keet/stop-indexing-operation":return _e;case"@keet/join-request":return dd;case"@keet/accept-join-request-operation":return cd;case"@keet/reject-join-request-operation":return rd;case"@keet/member":return sd;case"@keet/full-member":return ld;case"@keet/member-proofs":return fd;case"@keet/update-member-operation":return bd;case"@keet/change-member-status-operation":return vd;case"@keet/change-member-role-operation":return hd;case"@keet/remove-member-operation":return wd;case"@keet/member-activity":return Td;case"@keet/member-joined-event":return Ad;case"@keet/member-left-event":return Pd;case"@keet/title-changed-chat-event":return Sd;case"@keet/chat-event":return Hd;case"@keet/sendable-event":return Md;case"@keet/display-range":return Cd;case"@keet/display-content-range":return Vd;case"@keet/mention-display-item":return qd;case"@keet/link-preview":return zd;case"@keet/display-link-item":return Od;case"@keet/display":return _d;case"@keet/oplog-message":return co;case"@keet/index-message":return io;case"@keet/full-index-message":return po;case"@keet/message-status":return uo;case"@keet/message-index-id":return lo;case"@keet/thread":return mo;case"@keet/chat-message-record":return ko;case"@keet/full-chat-message-record":return Ko;case"@keet/add-chat-message-operation":return Ao;case"@keet/remove-chat-message-operation":return So;case"@keet/update-chat-message-operation":return Fo;case"@keet/pin-chat-message-operation":return Mo;case"@keet/reaction":return Co;case"@keet/reactions-summary":return Do;case"@keet/reactions-digest":return Lo;case"@keet/add-reaction-operation":return Eo;case"@keet/remove-reaction-operation":return zo;case"@keet/update-room-config-operation":return Oo;case"@keet/group-member":return Uo;case"@keet/user-registry-info":return Jo;case"@keet/room-identity":return Qo;case"@keet/genesis-operation":return dn;case"@keet/upgrade-operation":return nn;case"@keet/update-system-settings-operation":return rn;case"@keet-private-id/contact":return an;case"@keet-private-id/v3-room-migration-info":return sn;case"@keet-private-id/run-v3-migration-operation":return ln;case"@keet-private-id/update-identity-operation":return mn;case"@keet-private-id/counters":return yn;case"@keet-private-id/stats":return bn;case"@keet-private-id/add-entropy-operation":return xn;case"@keet-private-id/pending-invitation-identity":return kn;case"@keet-private-id/pending-invitation":return gn;case"@keet-private-id/resolve-pending-invitation-operation":return Kn;case"@keet-private-id/add-pending-invitation-operation":return An;case"@keet-private-id/remove-pending-invitation-operation":return Sn;case"@keet-private-id/identity-swap":return In;case"@keet-private-id/room-status":return Rn;case"@keet-private-id/room":return Cn;case"@keet-private-id/add-room-operation":return Vn;case"@keet-private-id/remove-room-operation":return qn;case"@keet-private-id/update-room-status-operation":return zn;case"@keet-private-id/contact-status":return Nn;case"@keet-private-id/contact-record":return jn;case"@keet-private-id/add-contact-operation":return Jn;case"@keet-private-id/update-contact-status-operation":return Qn;case"@keet-private-id/remove-contact-operation":return Xn;case"@keet-private-id/contact-request-status":return Yn;case"@keet-private-id/contact-request-body":return _n;case"@keet-private-id/contact-request":return dc;case"@keet-private-id/contact-request-record":return tc;case"@keet-private-id/add-contact-request-operation":return ic;case"@keet-private-id/update-contact-request-status-operation":return pc;case"@keet-private-id/profile-discovery-record-v1":return uc;case"@keet-private-id/profile-discovery-record":return lc;case"@keet/add-file-preview-operation":return mc;case"@keet/member-removed-event":return yc;case"@keet/member-contact-info":return xc;case"@keet/remove-device-operation":return vc;case"@keet/device-identity":return gc;case"@keet/readonly-room-invitation":return hc;case"@keet-private-id/identity-swap-v2":return Kc;case"@keet-private-id/activate-contact-room-operation":return Tc;case"@keet/display-type":return Pc;case"@keet/test-increment-operation":return Ic;case"@keet/test-collection-record-1":return Rc;case"@keet/migrate-abi-operation":return Hc;case"@keet/system-settings-keys":return Cc;case"@keet/room-supported-language":return Vc;case"@keet/translation-display-item":return qc;case"@keet-private-id/unreads":return Ec;case"@keet-private-id/add-unreads-key-operation":return zc;case"@keet-private-id/remove-unreads-key-operation":return jc;case"@keet/label-type":return Uc;case"@keet/chat-label":return Jc;case"@keet/add-chat-label-operation":return Qc;case"@keet/remove-chat-label-operation":return Xc;case"@keet/chat-label-summary":return Yc;case"@keet/chat-label-digest":return $c;case"@keet/update-read-length-operation":return et;case"@keet/read-length":return dt;case"@keet/tmp-removed-member":return ot;case"@keet-private-id/settings":return nt;case"@keet-private-id/user-settings-key":return tt;case"@keet-private-id/update-settings-operation":return at;case"@keet/member-label-type":return pt;case"@keet/member-label":return ut;case"@keet/add-member-label-operation":return ft;case"@keet/member-label-summary":return mt;case"@keet/member-label-digest":return bt;case"@keet/location-shared-event":return xt;case"@keet/move-indexer-operation":return vt;case"@keet/start-call":return Kt;case"@keet/join-call":return At;case"@keet/leave-call":return St;case"@keet/end-call":return Rt;case"@keet/add-call-stream":return Ht;case"@keet/remove-call-stream":return Ct;case"@keet/call-record":return Dt;case"@keet/call-member-record":return Vt;case"@keet/call-device-record":return Lt;case"@keet/call-stream-record":return qt;case"@keet/build-type":return Bt;case"@keet/test-crash-operation":return Nt;case"@keet/test-dispatch-error-operation":return Ot;case"@keet-private-id/shorten-device-attestation-operation":return Jt;case"@keet/call-device-heartbeat":return Qt;case"@keet/remove-call-device":return Xt;case"@keet/start-call-recording":return Zt;case"@keet/stop-call-recording":return _t;case"@keet/dismiss-chat-reports-operation":return dr;case"@keet/update-typing-indicator-operation":return nr;case"@keet/typing-indicator":return cr;case"@keet-private-id/update-contact-alias-operation":return rr;case"@keet/call-stats":return ir;case"@keet/call-stream-input":return ar;case"@keet/update-call-stream":return pr;case"@keet/call-stream-status-record":return ur;case"@keet/room-keys-v2":return lr;case"@keet/blob-pointer-v2":return fr;case"@keet/blob":return mr;case"@keet/autobee-migration":return yr;case"@keet/autobee-migration-operation":return xr;case"@keet/readonly-room-invitation-v2":return kr;case"@keet/admin-last-seen":return gr;case"@keet/blob-record":return hr;case"@keet-private-id/room-v2":return Ar;case"@keet-private-id/add-room-operation-v2":return Sr;case"@keet-private-id/pending-invitation-response":return Ir;case"@keet-private-id/resolve-pending-invitation-operation-v2":return Fr;default:throw new Error("Encoder not found "+e)}}function ni(e,o=29){const n=oi(e);return{preencode(e,c){d=o,n.preencode(e,c)},encode(e,c){d=o,n.encode(e,c)},decode:e=>(d=o,n.decode(e))}}const ci=ni;module.exports={resolveStruct:ci,getStruct:ni,getEnum:function(e){switch(e){case"@keet/room-type":return N;case"@keet/display-type":return Ac;case"@keet/system-settings-keys":return Mc;case"@keet/room-supported-language":return Dc;case"@keet/label-type":return Oc;case"@keet-private-id/user-settings-key":return ct;case"@keet/member-label-type":return st;case"@keet/build-type":return Et;default:throw new Error("Enum not found "+e)}},getEncoding:oi,encode:function(o,n,c=29){return d=c,e.encode(oi(o),n)},decode:function(o,n,c=29){return d=c,e.decode(oi(o),n)},setVersion:function(e){d=e},version:d};
1const{c:e}=require("hyperschema/runtime");let d=31;const o={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.length)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.length)},decode:d=>({key:e.fixed32.decode(d),length:e.uint.decode(d)})},n={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.seq)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.seq)},decode:d=>({key:e.fixed32.decode(d),seq:e.uint.decode(d)})},c={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.secretKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.secretKey)},decode:d=>({publicKey:e.fixed32.decode(d),secretKey:e.fixed32.decode(d)})},r={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed64.preencode(d,o.secretKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed64.encode(d,o.secretKey)},decode:d=>({publicKey:e.fixed32.decode(d),secretKey:e.fixed64.decode(d)})},t={preencode(n,c){e.fixed32.preencode(n,c.key),n.end++,c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=(c.encryptionKey?1:0)|(c.fastForwardTo?2:0)|(d>=27&&c.bootFrom?4:0);e.fixed32.encode(n,c.key),e.uint.encode(n,r),c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.uint.decode(n);return{key:c,encryptionKey:1&r?e.buffer.decode(n):null,fastForwardTo:2&r?e.fixed32.decode(n):null,bootFrom:d>=27&&4&r?o.decode(n):null}}},i={preencode(d,o){e.uint.preencode(d,o.timestamp)},encode(d,o){e.uint.encode(d,o.timestamp)},decode:d=>({timestamp:e.uint.decode(d)})},a={preencode(d,o){e.uint.preencode(d,o.blockOffset),e.uint.preencode(d,o.blockLength),e.uint.preencode(d,o.byteOffset),e.uint.preencode(d,o.byteLength)},encode(d,o){e.uint.encode(d,o.blockOffset),e.uint.encode(d,o.blockLength),e.uint.encode(d,o.byteOffset),e.uint.encode(d,o.byteLength)},decode:d=>({blockOffset:e.uint.decode(d),blockLength:e.uint.decode(d),byteOffset:e.uint.decode(d),byteLength:e.uint.decode(d)})},s={preencode(d,o){e.uint.preencode(d,o.width),e.uint.preencode(d,o.height)},encode(d,o){e.uint.encode(d,o.width),e.uint.encode(d,o.height)},decode:d=>({width:e.uint.decode(d),height:e.uint.decode(d)})},p=e.frame(s),u={preencode(d,o){d.end++,o.name&&e.string.preencode(d,o.name),o.mimetype&&e.string.preencode(d,o.mimetype),o.dimensions&&p.preencode(d,o.dimensions),o.userdata&&e.buffer.preencode(d,o.userdata),o.duration&&e.uint.preencode(d,o.duration)},encode(d,o){const n=(o.name?1:0)|(o.mimetype?2:0)|(o.dimensions?4:0)|(o.userdata?8:0)|(o.duration?16:0)|(o.isPreview?32:0);e.uint.encode(d,n),o.name&&e.string.encode(d,o.name),o.mimetype&&e.string.encode(d,o.mimetype),o.dimensions&&p.encode(d,o.dimensions),o.userdata&&e.buffer.encode(d,o.userdata),o.duration&&e.uint.encode(d,o.duration)},decode(d){const o=e.uint.decode(d);return{name:1&o?e.string.decode(d):null,mimetype:2&o?e.string.decode(d):null,dimensions:4&o?p.decode(d):null,userdata:8&o?e.buffer.decode(d):null,duration:16&o?e.uint.decode(d):0,isPreview:!!(32&o)}}},l={preencode(d,o){e.fixed32.preencode(d,o.key),e.string.preencode(d,o.path),e.uint.preencode(d,o.version),e.uint.preencode(d,o.size)},encode(d,o){e.fixed32.encode(d,o.key),e.string.encode(d,o.path),e.uint.encode(d,o.version),e.uint.encode(d,o.size)},decode:d=>({key:e.fixed32.decode(d),path:e.string.decode(d),version:e.uint.decode(d),size:e.uint.decode(d)})},f={preencode(d,o){e.fixed32.preencode(d,o.key),a.preencode(d,o.blob)},encode(d,o){e.fixed32.encode(d,o.key),a.encode(d,o.blob)},decode:d=>({key:e.fixed32.decode(d),blob:a.decode(d)})},m=e.frame(f),y=e.frame(l),b={preencode(o,n){o.end++,n.inlined&&e.buffer.preencode(o,n.inlined),n.blob&&a.preencode(o,n.blob),n.externalBlob&&m.preencode(o,n.externalBlob),n.externalDrive&&y.preencode(o,n.externalDrive),d>=27&&n.bee&&ft.preencode(o,n.bee)},encode(o,n){const c=(n.inlined?1:0)|(n.blob?2:0)|(n.externalBlob?4:0)|(n.externalDrive?8:0)|(d>=27&&n.bee?16:0);e.uint.encode(o,c),n.inlined&&e.buffer.encode(o,n.inlined),n.blob&&a.encode(o,n.blob),n.externalBlob&&m.encode(o,n.externalBlob),n.externalDrive&&y.encode(o,n.externalDrive),d>=27&&n.bee&&ft.encode(o,n.bee)},decode(o){const n=e.uint.decode(o);return{inlined:1&n?e.buffer.decode(o):null,blob:2&n?a.decode(o):null,externalBlob:4&n?m.decode(o):null,externalDrive:8&n?y.decode(o):null,bee:d>=27&&16&n?ft.decode(o):null}}},x=e.frame(b),k=e.frame(u),v={preencode(d,o){x.preencode(d,o.pointer),d.end++,o.metadata&&k.preencode(d,o.metadata),o.preview&&zt.preencode(d,o.preview),o.hash&&e.fixed32.preencode(d,o.hash)},encode(d,o){const n=(o.metadata?1:0)|(o.preview?2:0)|(o.hash?4:0);x.encode(d,o.pointer),e.uint.encode(d,n),o.metadata&&k.encode(d,o.metadata),o.preview&&zt.encode(d,o.preview),o.hash&&e.fixed32.encode(d,o.hash)},decode(d){const o=x.decode(d),n=e.uint.decode(d);return{pointer:o,metadata:1&n?k.decode(d):null,preview:2&n?zt.decode(d):null,hash:4&n?e.fixed32.decode(d):null}}},g=e.frame(v),h=g,K=g,w={preencode(e,d){e.end++,d.small&&g.preencode(e,d.small),d.medium&&h.preencode(e,d.medium),d.large&&K.preencode(e,d.large)},encode(d,o){const n=(o.small?1:0)|(o.medium?2:0)|(o.large?4:0);e.uint.encode(d,n),o.small&&g.encode(d,o.small),o.medium&&h.encode(d,o.medium),o.large&&K.encode(d,o.large)},decode(d){const o=e.uint.decode(d);return{small:1&o?g.decode(d):null,medium:2&o?h.decode(d):null,large:4&o?K.decode(d):null}}},T={preencode(e,d){e.end++},encode(d,o){const n=o.isDeleted?1:0;e.uint.encode(d,n)},decode:d=>({isDeleted:!!(1&e.uint.decode(d))})},A=e.frame(T),P=g,S={preencode(o,c){e.uint.preencode(o,c.id),n.preencode(o,c.oplog),A.preencode(o,c.status),P.preencode(o,c.file),o.end++,d>=14&&c.version&&e.uint.preencode(o,c.version)},encode(o,c){const r=d>=14&&c.version?1:0;e.uint.encode(o,c.id),n.encode(o,c.oplog),A.encode(o,c.status),P.encode(o,c.file),e.uint.encode(o,r),d>=14&&c.version&&e.uint.encode(o,c.version)},decode(o){const c=e.uint.decode(o),r=n.decode(o),t=A.decode(o),i=P.decode(o),a=o.start<o.end?e.uint.decode(o):0;return{id:c,oplog:r,status:t,file:i,version:d>=14&&1&a?e.uint.decode(o):0}}},I={preencode(e,d){e.end++},encode(d,o){const n=(o.isActive?1:0)|(o.isIndexing?2:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isActive:!!(1&o),isIndexing:!!(2&o)}}},R={preencode(o,n){const c=(n.isAdmin?1:0)|(n.isModerator?2:0)|(n.isPending?4:0)|(n.isActive?8:0)|(n.isMuted?16:0)|(n.isBanned?32:0)|(n.isShadowBanned?64:0)|(d>=13&&n.isRemoved?128:0);e.uint.preencode(o,c)},encode(o,n){const c=(n.isAdmin?1:0)|(n.isModerator?2:0)|(n.isPending?4:0)|(n.isActive?8:0)|(n.isMuted?16:0)|(n.isBanned?32:0)|(n.isShadowBanned?64:0)|(d>=13&&n.isRemoved?128:0);e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{isAdmin:!!(1&n),isModerator:!!(2&n),isPending:!!(4&n),isActive:!!(8&n),isMuted:!!(16&n),isBanned:!!(32&n),isShadowBanned:!!(64&n),isRemoved:d>=13&&!!(128&n)}}},F={preencode(e,d){e.end++},encode(d,o){const n=(o.isMuted?1:0)|(o.isBanned?2:0)|(o.isShadowBanned?4:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isMuted:!!(1&o),isBanned:!!(2&o),isShadowBanned:!!(4&o)}}},H={preencode(d,o){e.uint.preencode(d,o.version)},encode(d,o){e.uint.encode(d,o.version)},decode:d=>({version:e.uint.decode(d)})},M={preencode(d,o){e.uint.preencode(d,o.total),e.uint.preencode(d,o.active)},encode(d,o){e.uint.encode(d,o.total),e.uint.encode(d,o.active)},decode:d=>({total:e.uint.decode(d),active:e.uint.decode(d)})},C={preencode(d,o){e.uint.preencode(d,o.total),e.uint.preencode(d,o.active),e.uint.preencode(d,o.pending)},encode(d,o){e.uint.encode(d,o.total),e.uint.encode(d,o.active),e.uint.encode(d,o.pending)},decode:d=>({total:e.uint.decode(d),active:e.uint.decode(d),pending:e.uint.decode(d)})},D={preencode(o,n){e.uint.preencode(o,n.clock),e.uint.preencode(o,n.pinned),e.uint.preencode(o,n.threads),e.uint.preencode(o,n.timestamp),o.end++,d>=15&&n.flagsClock&&e.uint.preencode(o,n.flagsClock)},encode(o,n){const c=d>=15&&n.flagsClock?1:0;e.uint.encode(o,n.clock),e.uint.encode(o,n.pinned),e.uint.encode(o,n.threads),e.uint.encode(o,n.timestamp),e.uint.encode(o,c),d>=15&&n.flagsClock&&e.uint.encode(o,n.flagsClock)},decode(o){const n=e.uint.decode(o),c=e.uint.decode(o),r=e.uint.decode(o),t=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{clock:n,pinned:c,threads:r,timestamp:t,flagsClock:d>=15&&1&i?e.uint.decode(o):0}}},V={preencode(d,o){e.uint.preencode(d,o.clock)},encode(d,o){e.uint.encode(d,o.clock)},decode:d=>({clock:e.uint.decode(d)})},L=e.frame(M),q=e.frame(C),E=e.frame(D),B=e.frame(V),z={preencode(e,o){L.preencode(e,o.devices),q.preencode(e,o.members),E.preencode(e,o.chat),B.preencode(e,o.files),e.end++,d>=26&&o.calls&&Nt.preencode(e,o.calls)},encode(o,n){const c=d>=26&&n.calls?1:0;L.encode(o,n.devices),q.encode(o,n.members),E.encode(o,n.chat),B.encode(o,n.files),e.uint.encode(o,c),d>=26&&n.calls&&Nt.encode(o,n.calls)},decode(o){const n=L.decode(o),c=q.decode(o),r=E.decode(o),t=B.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{devices:n,members:c,chat:r,files:t,calls:d>=26&&1&i?Nt.decode(o):null}}},N={Default:1,Broadcast:2,DirectMessage:3},j={preencode(e,d){e.end++},encode(d,o){if(o>3)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},O={preencode(o,n){const c=(n.roomType?1:0)|(n.isExperimental?2:0)|(n.isJoiningDisabled?4:0)|(n.isAppendingDisabled?8:0)|(n.isCallingDisabled?16:0)|(n.isMembershipEventsDisabled?32:0)|(d>=19&&n.isAttachmentsDisabled?64:0)|(d>=19&&n.isLinksDisabled?128:0)|(d>=20&&n.buildType?256:0)|(d>=23&&n.isRoomInviteHidden?512:0);e.uint.preencode(o,c),n.roomType&&j.preencode(o,n.roomType),d>=20&&n.buildType&&Br.preencode(o,n.buildType)},encode(o,n){const c=(n.roomType?1:0)|(n.isExperimental?2:0)|(n.isJoiningDisabled?4:0)|(n.isAppendingDisabled?8:0)|(n.isCallingDisabled?16:0)|(n.isMembershipEventsDisabled?32:0)|(d>=19&&n.isAttachmentsDisabled?64:0)|(d>=19&&n.isLinksDisabled?128:0)|(d>=20&&n.buildType?256:0)|(d>=23&&n.isRoomInviteHidden?512:0);e.uint.encode(o,c),n.roomType&&j.encode(o,n.roomType),d>=20&&n.buildType&&Br.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{roomType:1&n?j.decode(o):0,isExperimental:!!(2&n),isJoiningDisabled:!!(4&n),isAppendingDisabled:!!(8&n),isCallingDisabled:!!(16&n),isMembershipEventsDisabled:!!(32&n),isAttachmentsDisabled:d>=19&&!!(64&n),isLinksDisabled:d>=19&&!!(128&n),buildType:d>=20&&256&n?Br.decode(o):null,isRoomInviteHidden:d>=23&&!!(512&n)}}},U=e.frame(H),J=e.frame(O),G={preencode(d,o){U.preencode(d,o.abi),J.preencode(d,o.settings),e.uint.preencode(d,o.creationTime)},encode(d,o){U.encode(d,o.abi),J.encode(d,o.settings),e.uint.encode(d,o.creationTime)},decode:d=>({abi:U.decode(d),settings:J.decode(d),creationTime:e.uint.decode(d)})},Q={preencode(d,o){e.fixed32.preencode(d,o.seed)},encode(d,o){e.fixed32.encode(d,o.seed)},decode:d=>({seed:e.fixed32.decode(d)})},W={preencode(d,o){c.preencode(d,o.mailboxKeyPair),r.preencode(d,o.discoveryKeyPair),e.fixed32.preencode(d,o.wakeupTopic),e.fixed32.preencode(d,o.swarmTopic)},encode(d,o){c.encode(d,o.mailboxKeyPair),r.encode(d,o.discoveryKeyPair),e.fixed32.encode(d,o.wakeupTopic),e.fixed32.encode(d,o.swarmTopic)},decode:d=>({mailboxKeyPair:c.decode(d),discoveryKeyPair:r.decode(d),wakeupTopic:e.fixed32.decode(d),swarmTopic:e.fixed32.decode(d)})},X=e.array(e.fixed32),Y={preencode(o,n){o.end++,n.title&&e.string.preencode(o,n.title),n.avatar&&jt.preencode(o,n.avatar),n.description&&e.string.preencode(o,n.description),d>=11&&n.supportedLanguages&&Ot.preencode(o,n.supportedLanguages),d>=13&&n.blindPeers&&X.preencode(o,n.blindPeers)},encode(o,n){const c=(n.title?1:0)|(n.avatar?2:0)|(n.description?4:0)|(d>=11&&n.supportedLanguages?8:0)|(d>=13&&n.blindPeers?16:0);e.uint.encode(o,c),n.title&&e.string.encode(o,n.title),n.avatar&&jt.encode(o,n.avatar),n.description&&e.string.encode(o,n.description),d>=11&&n.supportedLanguages&&Ot.encode(o,n.supportedLanguages),d>=13&&n.blindPeers&&X.encode(o,n.blindPeers)},decode(o){const n=e.uint.decode(o);return{title:1&n?e.string.decode(o):null,avatar:2&n?jt.decode(o):null,description:4&n?e.string.decode(o):null,supportedLanguages:d>=11&&8&n?Ot.decode(o):null,blindPeers:d>=13&&16&n?X.decode(o):null}}},Z={preencode(d,o){e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.key)},decode:d=>({key:e.fixed32.decode(d)})},$=e.frame(i),_=e.frame(Z),ee={preencode(e,d){$.preencode(e,d.header),_.preencode(e,d.peer)},encode(e,d){$.encode(e,d.header),_.encode(e,d.peer)},decode:e=>({header:$.decode(e),peer:_.decode(e)})},de=$,oe={preencode(d,o){de.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){de.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:de.decode(d),key:e.fixed32.decode(d)})},ne={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.buffer.preencode(d,o.proof)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.buffer.encode(d,o.proof)},decode:d=>({memberKey:e.fixed32.decode(d),proof:e.buffer.decode(d)})},ce={preencode(d,o){e.fixed32.preencode(d,o.id),e.buffer.preencode(d,o.response)},encode(d,o){e.fixed32.encode(d,o.id),e.buffer.encode(d,o.response)},decode:d=>({id:e.fixed32.decode(d),response:e.buffer.decode(d)})},re=e.frame(I),te=e.frame(ce),ie={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.memberKey),re.preencode(d,o.status),Ut.preencode(d,o.profile),d.end++,o.invitation&&te.preencode(d,o.invitation)},encode(d,o){const n=o.invitation?1:0;e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.memberKey),re.encode(d,o.status),Ut.encode(d,o.profile),e.uint.encode(d,n),o.invitation&&te.encode(d,o.invitation)},decode:d=>({key:e.fixed32.decode(d),memberKey:e.fixed32.decode(d),status:re.decode(d),profile:Ut.decode(d),invitation:1&e.uint.decode(d)?te.decode(d):null})},ae={preencode(d,o){e.uint.preencode(d,o.timestamp),d.end++,o.mailbox&&e.fixed32.preencode(d,o.mailbox),o.displayName&&e.string.preencode(d,o.displayName),o.avatar&&Jt.preencode(d,o.avatar),o.username&&e.string.preencode(d,o.username)},encode(d,o){const n=(o.mailbox?1:0)|(o.displayName?2:0)|(o.avatar?4:0)|(o.username?8:0);e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.mailbox&&e.fixed32.encode(d,o.mailbox),o.displayName&&e.string.encode(d,o.displayName),o.avatar&&Jt.encode(d,o.avatar),o.username&&e.string.encode(d,o.username)},decode(d){const o=e.uint.decode(d),n=e.uint.decode(d);return{timestamp:o,mailbox:1&n?e.fixed32.decode(d):null,displayName:2&n?e.string.decode(d):null,avatar:4&n?Jt.decode(d):null,username:8&n?e.string.decode(d):null}}},se={preencode(o,n){o.end++,n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),n.name&&e.string.preencode(o,n.name),d>=20&&n.buildType&&Br.preencode(o,n.buildType)},encode(o,n){const c=(n.swarmKey?1:0)|(n.name?2:0)|(n.isMobile?4:0)|(d>=20&&n.buildType?8:0);e.uint.encode(o,c),n.swarmKey&&e.fixed32.encode(o,n.swarmKey),n.name&&e.string.encode(o,n.name),d>=20&&n.buildType&&Br.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{swarmKey:1&n?e.fixed32.decode(o):null,name:2&n?e.string.decode(o):null,isMobile:!!(4&n),buildType:d>=20&&8&n?Br.decode(o):null}}},pe=e.frame(ae),ue={preencode(e,d){pe.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){pe.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:pe.decode(e),attestation:ne.decode(e)})},le={preencode(e,d){Gt.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){Gt.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:Gt.decode(e),attestation:ne.decode(e)})},fe={preencode(d,o){e.fixed32.preencode(d,o.id),e.buffer.preencode(d,o.data),e.buffer.preencode(d,o.signature)},encode(d,o){e.fixed32.encode(d,o.id),e.buffer.encode(d,o.data),e.buffer.encode(d,o.signature)},decode:d=>({id:e.fixed32.decode(d),data:e.buffer.decode(d),signature:e.buffer.decode(d)})},me={preencode(d,o){e.fixed32.preencode(d,o.devicePublicKey)},encode(d,o){e.fixed32.encode(d,o.devicePublicKey)},decode:d=>({devicePublicKey:e.fixed32.decode(d)})},ye={preencode(d,o){ne.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){ne.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({privateProfileIdentity:ne.decode(d),deviceProof:e.buffer.decode(d)})},be=e.frame(le),xe=e.frame(ue),ke=e.frame(me),ve={preencode(n,c){e.fixed32.preencode(n,c.deviceKey),r.preencode(n,c.keyPair),be.preencode(n,c.device),xe.preencode(n,c.member),n.end++,c.identity&&ke.preencode(n,c.identity),d>=27&&c.link&&o.preencode(n,c.link)},encode(n,c){const t=(c.identity?1:0)|(d>=27&&c.link?2:0);e.fixed32.encode(n,c.deviceKey),r.encode(n,c.keyPair),be.encode(n,c.device),xe.encode(n,c.member),e.uint.encode(n,t),c.identity&&ke.encode(n,c.identity),d>=27&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),t=r.decode(n),i=be.decode(n),a=xe.decode(n),s=e.uint.decode(n);return{deviceKey:c,keyPair:t,device:i,member:a,identity:1&s?ke.decode(n):null,link:d>=27&&2&s?o.decode(n):null}}},ge=e.frame(ve),he={preencode(d,o){e.fixed32.preencode(d,o.id),ge.preencode(d,o.request),e.buffer.preencode(d,o.signature)},encode(d,o){e.fixed32.encode(d,o.id),ge.encode(d,o.request),e.buffer.encode(d,o.signature)},decode:d=>({id:e.fixed32.decode(d),request:ge.decode(d),signature:e.buffer.decode(d)})},Ke=be,we=xe,Te={preencode(e,d){Ke.preencode(e,d.device),e.end++,d.member&&we.preencode(e,d.member)},encode(d,o){const n=o.member?1:0;Ke.encode(d,o.device),e.uint.encode(d,n),o.member&&we.encode(d,o.member)},decode:d=>({device:Ke.decode(d),member:1&e.uint.decode(d)?we.decode(d):null})},Ae=e.frame(he),Pe=e.frame(Te),Se={preencode(e,d){e.end++,d.withInvitation&&Ae.preencode(e,d.withInvitation),d.withMemberProof&&Pe.preencode(e,d.withMemberProof)},encode(d,o){const n=(o.withInvitation?1:0)|(o.withMemberProof?2:0);e.uint.encode(d,n),o.withInvitation&&Ae.encode(d,o.withInvitation),o.withMemberProof&&Pe.encode(d,o.withMemberProof)},decode(d){const o=e.uint.decode(d);return{withInvitation:1&o?Ae.decode(d):null,withMemberProof:2&o?Pe.decode(d):null}}},Ie=e.frame(fe),Re=e.frame(ye),Fe={preencode(e,d){Ie.preencode(e,d.signedKeys),e.end++,d.identity&&Re.preencode(e,d.identity)},encode(d,o){const n=o.identity?1:0;Ie.encode(d,o.signedKeys),e.uint.encode(d,n),o.identity&&Re.encode(d,o.identity)},decode:d=>({signedKeys:Ie.decode(d),identity:1&e.uint.decode(d)?Re.decode(d):null})},He={preencode(o,n){o.end++,n.expiration&&e.uint.preencode(o,n.expiration),d>=20&&n.buildType&&Br.preencode(o,n.buildType)},encode(o,n){const c=(n.expiration?1:0)|(n.requiresConfirmation?2:0)|(n.canModerate?4:0)|(n.canAdmin?8:0)|(d>=20&&n.buildType?16:0);e.uint.encode(o,c),n.expiration&&e.uint.encode(o,n.expiration),d>=20&&n.buildType&&Br.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{expiration:1&n?e.uint.decode(o):0,requiresConfirmation:!!(2&n),canModerate:!!(4&n),canAdmin:!!(8&n),buildType:d>=20&&16&n?Br.decode(o):null}}},Me=Ie,Ce=e.frame(He),De={preencode(d,n){e.fixed32.preencode(d,n.id),Me.preencode(d,n.response),Ce.preencode(d,n.metadata),d.end++,n.anchor&&o.preencode(d,n.anchor)},encode(d,n){const c=(n.anchor?1:0)|(n.isActive?2:0);e.fixed32.encode(d,n.id),Me.encode(d,n.response),Ce.encode(d,n.metadata),e.uint.encode(d,c),n.anchor&&o.encode(d,n.anchor)},decode(d){const n=e.fixed32.decode(d),c=Me.decode(d),r=Ce.decode(d),t=e.uint.decode(d);return{id:n,response:c,metadata:r,anchor:1&t?o.decode(d):null,isActive:!!(2&t)}}},Ve=$,Le=e.frame(De),qe={preencode(e,d){Ve.preencode(e,d.header),Le.preencode(e,d.invitation)},encode(e,d){Ve.encode(e,d.header),Le.encode(e,d.invitation)},decode:e=>({header:Ve.decode(e),invitation:Le.decode(e)})},Ee=$,Be={preencode(d,o){Ee.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){Ee.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:Ee.decode(d),id:e.fixed32.decode(d)})},ze={preencode(d,n){e.fixed32.preencode(d,n.mailbox),e.fixed32.preencode(d,n.invitationSeed),o.preencode(d,n.anchor)},encode(d,n){e.fixed32.encode(d,n.mailbox),e.fixed32.encode(d,n.invitationSeed),o.encode(d,n.anchor)},decode:d=>({mailbox:e.fixed32.decode(d),invitationSeed:e.fixed32.decode(d),anchor:o.decode(d)})},Ne={preencode(d,n){e.fixed32.preencode(d,n.mailbox),e.fixed32.preencode(d,n.invitationSeed),o.preencode(d,n.anchor),e.fixed32.preencode(d,n.identityPublicKey)},encode(d,n){e.fixed32.encode(d,n.mailbox),e.fixed32.encode(d,n.invitationSeed),o.encode(d,n.anchor),e.fixed32.encode(d,n.identityPublicKey)},decode:d=>({mailbox:e.fixed32.decode(d),invitationSeed:e.fixed32.decode(d),anchor:o.decode(d),identityPublicKey:e.fixed32.decode(d)})},je={preencode(d,o){e.fixed32.preencode(d,o.mailbox)},encode(d,o){e.fixed32.encode(d,o.mailbox)},decode:d=>({mailbox:e.fixed32.decode(d)})},Oe=e.frame(ze),Ue=e.frame(Ne),Je=e.frame(je),Ge=e.array(e.ipv4Address),Qe={preencode(e,o){e.end++,o.room&&Oe.preencode(e,o.room),o.identity&&Ue.preencode(e,o.identity),o.contact&&Je.preencode(e,o.contact),d>=6&&o.readonly&&Qt.preencode(e,o.readonly),d>=11&&o.additionalNodes&&Ge.preencode(e,o.additionalNodes),d>=20&&o.buildType&&Br.preencode(e,o.buildType),d>=27&&o["readonly-v2"]&&Wt.preencode(e,o["readonly-v2"])},encode(o,n){const c=(n.room?1:0)|(n.identity?2:0)|(n.contact?4:0)|(d>=6&&n.readonly?8:0)|(d>=11&&n.additionalNodes?16:0)|(d>=20&&n.buildType?32:0)|(d>=27&&n["readonly-v2"]?64:0);e.uint.encode(o,c),n.room&&Oe.encode(o,n.room),n.identity&&Ue.encode(o,n.identity),n.contact&&Je.encode(o,n.contact),d>=6&&n.readonly&&Qt.encode(o,n.readonly),d>=11&&n.additionalNodes&&Ge.encode(o,n.additionalNodes),d>=20&&n.buildType&&Br.encode(o,n.buildType),d>=27&&n["readonly-v2"]&&Wt.encode(o,n["readonly-v2"])},decode(o){const n=e.uint.decode(o);return{room:1&n?Oe.decode(o):null,identity:2&n?Ue.decode(o):null,contact:4&n?Je.decode(o):null,readonly:d>=6&&8&n?Qt.decode(o):null,additionalNodes:d>=11&&16&n?Ge.decode(o):null,buildType:d>=20&&32&n?Br.decode(o):null,"readonly-v2":d>=27&&64&n?Wt.decode(o):null}}},We=$,Xe={preencode(d,o){We.preencode(d,o.header),e.buffer.preencode(d,o.blindRequest)},encode(d,o){We.encode(d,o.header),e.buffer.encode(d,o.blindRequest)},decode:d=>({header:We.decode(d),blindRequest:e.buffer.decode(d)})},Ye=$,Ze={preencode(o,n){Ye.preencode(o,n.header),o.end++,n.profile&&Xt.preencode(o,n.profile),d>=24&&n.key&&e.fixed32.preencode(o,n.key)},encode(o,n){const c=(n.profile?1:0)|(d>=24&&n.key?2:0);Ye.encode(o,n.header),e.uint.encode(o,c),n.profile&&Xt.encode(o,n.profile),d>=24&&n.key&&e.fixed32.encode(o,n.key)},decode(o){const n=Ye.decode(o),c=e.uint.decode(o);return{header:n,profile:1&c?Xt.decode(o):null,key:d>=24&&2&c?e.fixed32.decode(o):null}}},$e={preencode(e,d){},encode(e,d){},decode:e=>({})},_e=$e,ed=ge,dd={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.id),ed.preencode(d,o.request)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.id),ed.encode(d,o.request)},decode:d=>({deviceKey:e.fixed32.decode(d),id:e.fixed32.decode(d),request:ed.decode(d)})},od=$,nd=Re,cd={preencode(d,o){od.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),d.end++,o.identity&&nd.preencode(d,o.identity)},encode(d,o){const n=o.identity?1:0;od.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,n),o.identity&&nd.encode(d,o.identity)},decode:d=>({header:od.decode(d),deviceKey:e.fixed32.decode(d),identity:1&e.uint.decode(d)?nd.decode(d):null})},rd=$,td={preencode(d,o){rd.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey)},encode(d,o){rd.encode(d,o.header),e.fixed32.encode(d,o.deviceKey)},decode:d=>({header:rd.decode(d),deviceKey:e.fixed32.decode(d)})},id=e.frame(R),ad=pe,sd={preencode(d,o){e.fixed32.preencode(d,o.key),id.preencode(d,o.status),ad.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),id.encode(d,o.status),ad.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),status:id.decode(d),profile:ad.decode(d)})},pd=id,ud=pe,ld={preencode(d,o){e.fixed32.preencode(d,o.key),pd.preencode(d,o.status),ud.preencode(d,o.profile),d.end++,o.proofs&&Yt.preencode(d,o.proofs)},encode(d,o){const n=o.proofs?1:0;e.fixed32.encode(d,o.key),pd.encode(d,o.status),ud.encode(d,o.profile),e.uint.encode(d,n),o.proofs&&Yt.encode(d,o.proofs)},decode:d=>({key:e.fixed32.decode(d),status:pd.decode(d),profile:ud.decode(d),proofs:1&e.uint.decode(d)?Yt.decode(d):null})},fd={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++,o.profileAttestation&&e.buffer.preencode(d,o.profileAttestation),o.latestReceipt&&e.buffer.preencode(d,o.latestReceipt)},encode(d,o){const n=(o.profileAttestation?1:0)|(o.latestReceipt?2:0);e.fixed32.encode(d,o.key),e.uint.encode(d,n),o.profileAttestation&&e.buffer.encode(d,o.profileAttestation),o.latestReceipt&&e.buffer.encode(d,o.latestReceipt)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d);return{key:o,profileAttestation:1&n?e.buffer.decode(d):null,latestReceipt:2&n?e.buffer.decode(d):null}}},md=$,yd=xe,bd={preencode(e,d){md.preencode(e,d.header),yd.preencode(e,d.member)},encode(e,d){md.encode(e,d.header),yd.encode(e,d.member)},decode:e=>({header:md.decode(e),member:yd.decode(e)})},xd=$,kd=e.frame(F),vd={preencode(d,o){xd.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),kd.preencode(d,o.status)},encode(d,o){xd.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),kd.encode(d,o.status)},decode:d=>({header:xd.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:kd.decode(d)})},gd=$,hd={preencode(d,o){gd.preencode(d,o.header),e.fixed32.preencode(d,o.key),d.end++},encode(d,o){const n=(o.isModerator?1:0)|(o.isAdmin?2:0);gd.encode(d,o.header),e.fixed32.encode(d,o.key),e.uint.encode(d,n)},decode(d){const o=gd.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{header:o,key:n,isModerator:!!(1&c),isAdmin:!!(2&c)}}},Kd=$,wd={preencode(d,o){Kd.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){Kd.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:Kd.decode(d),key:e.fixed32.decode(d)})},Td={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.mentions)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.mentions)},decode:d=>({key:e.fixed32.decode(d),mentions:e.uint.decode(d)})},Ad={preencode(d,o){d.end++,o.memberKey&&e.fixed32.preencode(d,o.memberKey)},encode(d,o){const n=o.memberKey?1:0;e.uint.encode(d,n),o.memberKey&&e.fixed32.encode(d,o.memberKey)},decode:d=>({memberKey:1&e.uint.decode(d)?e.fixed32.decode(d):null})},Pd=Ad,Sd={preencode(d,o){d.end++,o.from&&e.string.preencode(d,o.from),o.to&&e.string.preencode(d,o.to)},encode(d,o){const n=(o.from?1:0)|(o.to?2:0);e.uint.encode(d,n),o.from&&e.string.encode(d,o.from),o.to&&e.string.encode(d,o.to)},decode(d){const o=e.uint.decode(d);return{from:1&o?e.string.decode(d):null,to:2&o?e.string.decode(d):null}}},Id=e.frame(Ad),Rd=e.frame(Pd),Fd=e.frame(Sd),Hd={preencode(o,n){const c=(n.memberJoined?1:0)|(n.memberLeft?2:0)|(n.titleChanged?4:0)|(n.callStarted?8:0)|(n.callHangup?16:0)|(n.callMissed?32:0)|(d>=3&&n.roomAvatarChanged?64:0)|(d>=3&&n.invitationCreated?128:0)|(d>=3&&n.memberRemoved?256:0)|(d>=18&&n.locationShared?512:0);e.uint.preencode(o,c),n.memberJoined&&Id.preencode(o,n.memberJoined),n.memberLeft&&Rd.preencode(o,n.memberLeft),n.titleChanged&&Fd.preencode(o,n.titleChanged),d>=3&&n.memberRemoved&&Zt.preencode(o,n.memberRemoved),d>=18&&n.locationShared&&$t.preencode(o,n.locationShared)},encode(o,n){const c=(n.memberJoined?1:0)|(n.memberLeft?2:0)|(n.titleChanged?4:0)|(n.callStarted?8:0)|(n.callHangup?16:0)|(n.callMissed?32:0)|(d>=3&&n.roomAvatarChanged?64:0)|(d>=3&&n.invitationCreated?128:0)|(d>=3&&n.memberRemoved?256:0)|(d>=18&&n.locationShared?512:0);e.uint.encode(o,c),n.memberJoined&&Id.encode(o,n.memberJoined),n.memberLeft&&Rd.encode(o,n.memberLeft),n.titleChanged&&Fd.encode(o,n.titleChanged),d>=3&&n.memberRemoved&&Zt.encode(o,n.memberRemoved),d>=18&&n.locationShared&&$t.encode(o,n.locationShared)},decode(o){const n=e.uint.decode(o);return{memberJoined:1&n?Id.decode(o):null,memberLeft:2&n?Rd.decode(o):null,titleChanged:4&n?Fd.decode(o):null,callStarted:!!(8&n),callHangup:!!(16&n),callMissed:!!(32&n),roomAvatarChanged:d>=3&&!!(64&n),invitationCreated:d>=3&&!!(128&n),memberRemoved:d>=3&&256&n?Zt.decode(o):null,locationShared:d>=18&&512&n?$t.decode(o):null}}},Md={preencode(e,o){e.end++,d>=18&&o.locationShared&&_t.preencode(e,o.locationShared)},encode(o,n){const c=(n.callStarted?1:0)|(n.callHangup?2:0)|(n.callMissed?4:0)|(d>=18&&n.locationShared?8:0);e.uint.encode(o,c),d>=18&&n.locationShared&&_t.encode(o,n.locationShared)},decode(o){const n=e.uint.decode(o);return{callStarted:!!(1&n),callHangup:!!(2&n),callMissed:!!(4&n),locationShared:d>=18&&8&n?_t.decode(o):null}}},Cd={preencode(d,o){e.uint.preencode(d,o.start),e.uint.preencode(d,o.length)},encode(d,o){e.uint.encode(d,o.start),e.uint.encode(d,o.length)},decode:d=>({start:e.uint.decode(d),length:e.uint.decode(d)})},Dd=e.frame(Cd),Vd={preencode(d,o){Dd.preencode(d,o.range),e.string.preencode(d,o.content)},encode(d,o){Dd.encode(d,o.range),e.string.encode(d,o.content)},decode:d=>({range:Dd.decode(d),content:e.string.decode(d)})},Ld=Dd,qd={preencode(d,o){Ld.preencode(d,o.range),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Ld.encode(d,o.range),e.fixed32.encode(d,o.memberKey)},decode:d=>({range:Ld.decode(d),memberKey:e.fixed32.decode(d)})},Ed=g,Bd=e.array(e.uint),zd={preencode(o,n){o.end++,n.title&&e.string.preencode(o,n.title),n.description&&e.string.preencode(o,n.description),n.file&&Ed.preencode(o,n.file),d>=7&&n.files&&Bd.preencode(o,n.files)},encode(o,n){const c=(n.title?1:0)|(n.description?2:0)|(n.file?4:0)|(d>=7&&n.files?8:0);e.uint.encode(o,c),n.title&&e.string.encode(o,n.title),n.description&&e.string.encode(o,n.description),n.file&&Ed.encode(o,n.file),d>=7&&n.files&&Bd.encode(o,n.files)},decode(o){const n=e.uint.decode(o);return{title:1&n?e.string.decode(o):null,description:2&n?e.string.decode(o):null,file:4&n?Ed.decode(o):null,files:d>=7&&8&n?Bd.decode(o):null}}},Nd=Dd,jd=e.frame(zd),Od={preencode(d,o){Nd.preencode(d,o.range),e.string.preencode(d,o.url),d.end++,o.preview&&jd.preencode(d,o.preview)},encode(d,o){const n=o.preview?1:0;Nd.encode(d,o.range),e.string.encode(d,o.url),e.uint.encode(d,n),o.preview&&jd.encode(d,o.preview)},decode:d=>({range:Nd.decode(d),url:e.string.decode(d),preview:1&e.uint.decode(d)?jd.decode(d):null})},Ud=e.array(e.frame(qd)),Jd=e.array(e.frame(Od)),Gd=Jd,Qd=e.array(e.frame(Cd)),Wd=Qd,Xd=Qd,Yd=e.array(e.frame(Vd)),Zd=Qd,$d=Qd,_d={preencode(o,n){const c=(n.mention?1:0)|(n.httpLink?2:0)|(n.pearLink?4:0)|(n.bold?8:0)|(n.italic?16:0)|(n.code?32:0)|(n.emoji?64:0)|(n.codeBlock?128:0)|(n.strike?256:0)|(d>=11&&n.translation?512:0);e.uint.preencode(o,c),n.mention&&Ud.preencode(o,n.mention),n.httpLink&&Jd.preencode(o,n.httpLink),n.pearLink&&Gd.preencode(o,n.pearLink),n.bold&&Qd.preencode(o,n.bold),n.italic&&Wd.preencode(o,n.italic),n.code&&Xd.preencode(o,n.code),n.emoji&&Yd.preencode(o,n.emoji),n.codeBlock&&Zd.preencode(o,n.codeBlock),n.strike&&$d.preencode(o,n.strike),d>=11&&n.translation&&ei.preencode(o,n.translation)},encode(o,n){const c=(n.mention?1:0)|(n.httpLink?2:0)|(n.pearLink?4:0)|(n.bold?8:0)|(n.italic?16:0)|(n.code?32:0)|(n.emoji?64:0)|(n.codeBlock?128:0)|(n.strike?256:0)|(d>=11&&n.translation?512:0);e.uint.encode(o,c),n.mention&&Ud.encode(o,n.mention),n.httpLink&&Jd.encode(o,n.httpLink),n.pearLink&&Gd.encode(o,n.pearLink),n.bold&&Qd.encode(o,n.bold),n.italic&&Wd.encode(o,n.italic),n.code&&Xd.encode(o,n.code),n.emoji&&Yd.encode(o,n.emoji),n.codeBlock&&Zd.encode(o,n.codeBlock),n.strike&&$d.encode(o,n.strike),d>=11&&n.translation&&ei.encode(o,n.translation)},decode(o){const n=e.uint.decode(o);return{mention:1&n?Ud.decode(o):null,httpLink:2&n?Jd.decode(o):null,pearLink:4&n?Gd.decode(o):null,bold:8&n?Qd.decode(o):null,italic:16&n?Wd.decode(o):null,code:32&n?Xd.decode(o):null,emoji:64&n?Yd.decode(o):null,codeBlock:128&n?Zd.decode(o):null,strike:256&n?$d.decode(o):null,translation:d>=11&&512&n?ei.decode(o):null}}},eo=e.array(e.frame(v)),oo=e.frame(_d),no=e.frame(Md),co={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&eo.preencode(d,o.files),o.display&&oo.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent),o.event&&no.preencode(d,o.event)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(c.event?32:0)|(d>=18&&c.forwarded?64:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&eo.encode(o,c.files),c.display&&oo.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent),c.event&&no.encode(o,c.event)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?eo.decode(o):null,display:4&c?oo.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,event:32&c?no.decode(o):null,forwarded:d>=18&&!!(64&c)}}},ro=Bd,to=oo,io={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&ro.preencode(d,o.files),o.display&&to.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(d>=18&&c.forwarded?32:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&ro.encode(o,c.files),c.display&&to.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?ro.decode(o):null,display:4&c?to.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,forwarded:d>=18&&!!(32&c)}}},ao=eo,so=oo,po={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&ao.preencode(d,o.files),o.display&&so.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(d>=18&&c.forwarded?32:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&ao.encode(o,c.files),c.display&&so.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?ao.decode(o):null,display:4&c?so.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,forwarded:d>=18&&!!(32&c)}}},uo={preencode(e,d){e.end++},encode(d,o){const n=(o.isEdited?1:0)|(o.isDeleted?2:0)|(o.isPinned?4:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isEdited:!!(1&o),isDeleted:!!(2&o),isPinned:!!(4&o)}}},lo={preencode(d,o){e.uint.preencode(d,o.thread),e.uint.preencode(d,o.index)},encode(d,o){e.uint.encode(d,o.thread),e.uint.encode(d,o.index)},decode:d=>({thread:e.uint.decode(d),index:e.uint.decode(d)})},fo=e.frame(z),mo={preencode(d,o){e.uint.preencode(d,o.id),e.uint.preencode(d,o.count),d.end++,o.parent&&n.preencode(d,o.parent),o.stats&&fo.preencode(d,o.stats)},encode(d,o){const c=(o.parent?1:0)|(o.stats?2:0);e.uint.encode(d,o.id),e.uint.encode(d,o.count),e.uint.encode(d,c),o.parent&&n.encode(d,o.parent),o.stats&&fo.encode(d,o.stats)},decode(d){const o=e.uint.decode(d),c=e.uint.decode(d),r=e.uint.decode(d);return{id:o,count:c,parent:1&r?n.decode(d):null,stats:2&r?fo.decode(d):null}}},yo=e.frame(uo),bo=e.frame(io),xo=e.frame(Hd),ko={preencode(d,o){lo.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),yo.preencode(d,o.status),o.message&&bo.preencode(d,o.message),o.event&&xo.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);lo.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),yo.encode(d,o.status),o.message&&bo.encode(d,o.message),o.event&&xo.encode(d,o.event)},decode(d){const o=lo.decode(d),c=n.decode(d),r=e.uint.decode(d),t=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:r,timestamp:t,editedAt:1&i?e.uint.decode(d):0,status:yo.decode(d),message:2&i?bo.decode(d):null,event:4&i?xo.decode(d):null}}},vo=yo,go=e.frame(po),ho=xo,Ko={preencode(d,o){lo.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),vo.preencode(d,o.status),o.message&&go.preencode(d,o.message),o.event&&ho.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);lo.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),vo.encode(d,o.status),o.message&&go.encode(d,o.message),o.event&&ho.encode(d,o.event)},decode(d){const o=lo.decode(d),c=n.decode(d),r=e.uint.decode(d),t=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:r,timestamp:t,editedAt:1&i?e.uint.decode(d):0,status:vo.decode(d),message:2&i?go.decode(d):null,event:4&i?ho.decode(d):null}}},wo=$,To=e.frame(co),Ao={preencode(e,d){wo.preencode(e,d.header),To.preencode(e,d.message)},encode(e,d){wo.encode(e,d.header),To.encode(e,d.message)},decode:e=>({header:wo.decode(e),message:To.decode(e)})},Po=$,So={preencode(e,d){Po.preencode(e,d.header),n.preencode(e,d.oplog)},encode(e,d){Po.encode(e,d.header),n.encode(e,d.oplog)},decode:e=>({header:Po.decode(e),oplog:n.decode(e)})},Io=$,Ro=To,Fo={preencode(e,d){Io.preencode(e,d.header),n.preencode(e,d.oplog),Ro.preencode(e,d.message)},encode(e,d){Io.encode(e,d.header),n.encode(e,d.oplog),Ro.encode(e,d.message)},decode:e=>({header:Io.decode(e),oplog:n.decode(e),message:Ro.decode(e)})},Ho=$,Mo={preencode(e,d){Ho.preencode(e,d.header),n.preencode(e,d.oplog),e.end++},encode(d,o){const c=o.isPinned?1:0;Ho.encode(d,o.header),n.encode(d,o.oplog),e.uint.encode(d,c)},decode:d=>({header:Ho.decode(d),oplog:n.decode(d),isPinned:!!(1&e.uint.decode(d))})},Co={preencode(d,o){lo.preencode(d,o.id),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),e.string.preencode(d,o.reaction)},encode(d,o){lo.encode(d,o.id),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),e.string.encode(d,o.reaction)},decode:d=>({id:lo.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),reaction:e.string.decode(d)})},Do={preencode(d,o){e.string.preencode(d,o.text),e.uint.preencode(d,o.count)},encode(d,o){e.string.encode(d,o.text),e.uint.encode(d,o.count)},decode:d=>({text:e.string.decode(d),count:e.uint.decode(d)})},Vo=e.array(e.frame(Do)),Lo={preencode(o,n){lo.preencode(o,n.id),e.uint.preencode(o,n.total),Vo.preencode(o,n.reactions),o.end++,d>=11&&n.editedAt&&e.uint.preencode(o,n.editedAt)},encode(o,n){const c=d>=11&&n.editedAt?1:0;lo.encode(o,n.id),e.uint.encode(o,n.total),Vo.encode(o,n.reactions),e.uint.encode(o,c),d>=11&&n.editedAt&&e.uint.encode(o,n.editedAt)},decode(o){const n=lo.decode(o),c=e.uint.decode(o),r=Vo.decode(o),t=o.start<o.end?e.uint.decode(o):0;return{id:n,total:c,reactions:r,editedAt:d>=11&&1&t?e.uint.decode(o):0}}},qo=$,Eo={preencode(d,o){qo.preencode(d,o.header),n.preencode(d,o.oplog),e.string.preencode(d,o.reaction)},encode(d,o){qo.encode(d,o.header),n.encode(d,o.oplog),e.string.encode(d,o.reaction)},decode:d=>({header:qo.decode(d),oplog:n.decode(d),reaction:e.string.decode(d)})},Bo=$,zo={preencode(d,o){Bo.preencode(d,o.header),n.preencode(d,o.oplog),e.string.preencode(d,o.reaction)},encode(d,o){Bo.encode(d,o.header),n.encode(d,o.oplog),e.string.encode(d,o.reaction)},decode:d=>({header:Bo.decode(d),oplog:n.decode(d),reaction:e.string.decode(d)})},No=$,jo=e.frame(Y),Oo={preencode(d,o){No.preencode(d,o.header),e.uint.preencode(d,o.key),jo.preencode(d,o.config)},encode(d,o){No.encode(d,o.header),e.uint.encode(d,o.key),jo.encode(d,o.config)},decode:d=>({header:No.decode(d),key:e.uint.decode(d),config:jo.decode(d)})},Uo={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.string.preencode(d,o.displayName),d.end++,o.avatar&&di.preencode(d,o.avatar)},encode(d,o){const n=o.avatar?1:0;e.fixed32.encode(d,o.memberKey),e.string.encode(d,o.displayName),e.uint.encode(d,n),o.avatar&&di.encode(d,o.avatar)},decode:d=>({memberKey:e.fixed32.decode(d),displayName:e.string.decode(d),avatar:1&e.uint.decode(d)?di.decode(d):null})},Jo={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++,o.username&&e.string.preencode(d,o.username)},encode(d,o){const n=o.username?1:0;e.fixed32.encode(d,o.key),e.uint.encode(d,n),o.username&&e.string.encode(d,o.username)},decode:d=>({key:e.fixed32.decode(d),username:1&e.uint.decode(d)?e.string.decode(d):null})},Go=e.frame(Jo),Qo={preencode(d,o){e.fixed32.preencode(d,o.publicKey),d.end++,o.discoveryCoreKey&&e.fixed32.preencode(d,o.discoveryCoreKey),o.userRegistry&&Go.preencode(d,o.userRegistry)},encode(d,o){const n=(o.discoveryCoreKey?1:0)|(o.userRegistry?2:0);e.fixed32.encode(d,o.publicKey),e.uint.encode(d,n),o.discoveryCoreKey&&e.fixed32.encode(d,o.discoveryCoreKey),o.userRegistry&&Go.encode(d,o.userRegistry)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d);return{publicKey:o,discoveryCoreKey:1&n?e.fixed32.decode(d):null,userRegistry:2&n?Go.decode(d):null}}},Wo=$,Xo=e.frame(G),Yo=e.frame(Q),Zo=jo,$o=e.frame(Qo),_o=be,en=e.array(e.frame(ue)),dn={preencode(e,d){Wo.preencode(e,d.header),Xo.preencode(e,d.digest),Yo.preencode(e,d.capabilities),e.end++,d.config&&Zo.preencode(e,d.config),d.identity&&$o.preencode(e,d.identity),d.bootstrapDevice&&_o.preencode(e,d.bootstrapDevice),d.initialMembers&&en.preencode(e,d.initialMembers)},encode(d,o){const n=(o.config?1:0)|(o.identity?2:0)|(o.bootstrapDevice?4:0)|(o.initialMembers?8:0);Wo.encode(d,o.header),Xo.encode(d,o.digest),Yo.encode(d,o.capabilities),e.uint.encode(d,n),o.config&&Zo.encode(d,o.config),o.identity&&$o.encode(d,o.identity),o.bootstrapDevice&&_o.encode(d,o.bootstrapDevice),o.initialMembers&&en.encode(d,o.initialMembers)},decode(d){const o=Wo.decode(d),n=Xo.decode(d),c=Yo.decode(d),r=e.uint.decode(d);return{header:o,digest:n,capabilities:c,config:1&r?Zo.decode(d):null,identity:2&r?$o.decode(d):null,bootstrapDevice:4&r?_o.decode(d):null,initialMembers:8&r?en.decode(d):null}}},on=$,nn={preencode(d,o){on.preencode(d,o.header),e.uint.preencode(d,o.version)},encode(d,o){on.encode(d,o.header),e.uint.encode(d,o.version)},decode:d=>({header:on.decode(d),version:e.uint.decode(d)})},cn=$,rn=J,tn={preencode(d,o){cn.preencode(d,o.header),e.uint.preencode(d,o.key),rn.preencode(d,o.settings)},encode(d,o){cn.encode(d,o.header),e.uint.encode(d,o.key),rn.encode(d,o.settings)},decode:d=>({header:cn.decode(d),key:e.uint.decode(d),settings:rn.decode(d)})},an={preencode(o,n){e.fixed32.preencode(o,n.memberKey),oi.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=22&&n.contactInfo&&ni.preencode(o,n.contactInfo),d>=22&&n.version&&e.uint.preencode(o,n.version),d>=24&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=22&&n.contactInfo?4:0)|(d>=22&&n.version?8:0)|(d>=24&&n.alias?16:0);e.fixed32.encode(o,n.memberKey),oi.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=22&&n.contactInfo&&ni.encode(o,n.contactInfo),d>=22&&n.version&&e.uint.encode(o,n.version),d>=24&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.fixed32.decode(o),c=oi.decode(o),r=e.uint.decode(o);return{memberKey:n,status:c,mailbox:1&r?e.fixed32.decode(o):null,roomKey:2&r?e.fixed32.decode(o):null,contactInfo:d>=22&&4&r?ni.decode(o):null,version:d>=22&&8&r?e.uint.decode(o):0,alias:d>=24&&16&r?e.string.decode(o):null}}},sn={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.seed),o.preencode(d,n.initiator),e.fixed32.preencode(d,n.fastForwardTo)},encode(d,n){e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.fixed32.encode(d,n.seed),o.encode(d,n.initiator),e.fixed32.encode(d,n.fastForwardTo)},decode:d=>({roomKey:e.fixed32.decode(d),encryptionKey:e.buffer.decode(d),seed:e.fixed32.decode(d),initiator:o.decode(d),fastForwardTo:e.fixed32.decode(d)})},pn=e.array(e.frame(sn)),un=X,ln={preencode(e,d){pn.preencode(e,d.sharedRooms),un.preencode(e,d.blockedContacts)},encode(e,d){pn.encode(e,d.sharedRooms),un.encode(e,d.blockedContacts)},decode:e=>({sharedRooms:pn.decode(e),blockedContacts:un.decode(e)})},fn=$o,mn={preencode(e,d){fn.preencode(e,d.identity)},encode(e,d){fn.encode(e,d.identity)},decode:e=>({identity:fn.decode(e)})},yn={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.contacts)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.contacts)},decode:d=>({rooms:e.uint.decode(d),contacts:e.uint.decode(d)})},bn={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.contactRequests)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.contactRequests)},decode:d=>({rooms:e.uint.decode(d),contactRequests:e.uint.decode(d)})},xn={preencode(d,o){e.buffer.preencode(d,o.entropy)},encode(d,o){e.buffer.encode(d,o.entropy)},decode:d=>({entropy:e.buffer.decode(d)})},kn={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.devicePublicKey),e.fixed32.preencode(d,o.writerKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.devicePublicKey),e.fixed32.encode(d,o.writerKey)},decode:d=>({publicKey:e.fixed32.decode(d),devicePublicKey:e.fixed32.decode(d),writerKey:e.fixed32.decode(d)})},vn=e.frame(kn),gn={preencode(n,c){e.fixed32.preencode(n,c.id),e.fixed32.preencode(n,c.invitationSeed),e.fixed32.preencode(n,c.mailbox),r.preencode(n,c.responseKeyPair),o.preencode(n,c.initiator),o.preencode(n,c.inviter),n.end++,c.identity&&vn.preencode(n,c.identity),d>=20&&c.buildType&&Br.preencode(n,c.buildType),d>=27&&c.link&&o.preencode(n,c.link)},encode(n,c){const t=(c.identity?1:0)|(d>=20&&c.buildType?2:0)|(d>=27&&c.link?4:0);e.fixed32.encode(n,c.id),e.fixed32.encode(n,c.invitationSeed),e.fixed32.encode(n,c.mailbox),r.encode(n,c.responseKeyPair),o.encode(n,c.initiator),o.encode(n,c.inviter),e.uint.encode(n,t),c.identity&&vn.encode(n,c.identity),d>=20&&c.buildType&&Br.encode(n,c.buildType),d>=27&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),t=e.fixed32.decode(n),i=e.fixed32.decode(n),a=r.decode(n),s=o.decode(n),p=o.decode(n),u=e.uint.decode(n);return{id:c,invitationSeed:t,mailbox:i,responseKeyPair:a,initiator:s,inviter:p,identity:1&u?vn.decode(n):null,buildType:d>=20&&2&u?Br.decode(n):null,link:d>=27&&4&u?o.decode(n):null}}},hn=$,Kn={preencode(d,o){hn.preencode(d,o.header),e.buffer.preencode(d,o.blindResponse)},encode(d,o){hn.encode(d,o.header),e.buffer.encode(d,o.blindResponse)},decode:d=>({header:hn.decode(d),blindResponse:e.buffer.decode(d)})},wn=$,Tn=e.frame(gn),An={preencode(e,d){wn.preencode(e,d.header),Tn.preencode(e,d.invitation)},encode(e,d){wn.encode(e,d.header),Tn.encode(e,d.invitation)},decode:e=>({header:wn.decode(e),invitation:Tn.decode(e)})},Pn=$,Sn={preencode(d,o){Pn.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){Pn.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:Pn.decode(d),id:e.fixed32.decode(d)})},In={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.devicePublicKey),d.end++,o.privateProfileKey&&e.fixed32.preencode(d,o.privateProfileKey),o.deviceKeyPair&&r.preencode(d,o.deviceKeyPair),e.buffer.preencode(d,o.deviceProof)},encode(d,o){const n=(o.privateProfileKey?1:0)|(o.deviceKeyPair?2:0);e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.devicePublicKey),e.uint.encode(d,n),o.privateProfileKey&&e.fixed32.encode(d,o.privateProfileKey),o.deviceKeyPair&&r.encode(d,o.deviceKeyPair),e.buffer.encode(d,o.deviceProof)},decode(d){const o=e.fixed32.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{publicKey:o,devicePublicKey:n,privateProfileKey:1&c?e.fixed32.decode(d):null,deviceKeyPair:2&c?r.decode(d):null,deviceProof:e.buffer.decode(d)}}},Rn={preencode(o,n){o.end++,d>=25&&n.roomSnoozeTime&&e.uint.preencode(o,n.roomSnoozeTime)},encode(o,n){const c=(n.isActive?1:0)|(n.isFullyMuted?2:0)|(n.isMentionsOnlyMuted?4:0)|(d>=9&&n.isReadOnly?8:0)|(d>=18&&n.isFavorite?16:0)|(d>=21&&n.isUnread?32:0)|(d>=25&&n.roomSnoozeTime?64:0);e.uint.encode(o,c),d>=25&&n.roomSnoozeTime&&e.uint.encode(o,n.roomSnoozeTime)},decode(o){const n=e.uint.decode(o);return{isActive:!!(1&n),isFullyMuted:!!(2&n),isMentionsOnlyMuted:!!(4&n),isReadOnly:d>=9&&!!(8&n),isFavorite:d>=18&&!!(16&n),isUnread:d>=21&&!!(32&n),roomSnoozeTime:d>=25&&64&n?e.uint.decode(o):0}}},Fn=e.frame(Rn),Hn=e.frame(In),Mn=vn,Cn={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),Fn.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,c.initiator&&o.preencode(n,c.initiator),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),c.identitySwap&&Hn.preencode(n,c.identitySwap),d>=6&&c.identitySwapV2&&Mn.preencode(n,c.identitySwapV2),d>=10&&c.contact&&e.fixed32.preencode(n,c.contact),d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=29&&c.activeClock&&e.uint.preencode(n,c.activeClock)},encode(n,c){const r=(c.initiator?1:0)|(c.fastForwardTo?2:0)|(c.identitySwap?4:0)|(d>=6&&c.identitySwapV2?8:0)|(d>=10&&c.contact?16:0)|(d>=27&&c.bootFrom?32:0)|(d>=29&&c.activeClock?64:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),Fn.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,r),c.initiator&&o.encode(n,c.initiator),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),c.identitySwap&&Hn.encode(n,c.identitySwap),d>=6&&c.identitySwapV2&&Mn.encode(n,c.identitySwapV2),d>=10&&c.contact&&e.fixed32.encode(n,c.contact),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom),d>=29&&c.activeClock&&e.uint.encode(n,c.activeClock)},decode(n){const c=e.fixed32.decode(n),r=e.buffer.decode(n),t=e.fixed32.decode(n),i=Fn.decode(n),a=e.uint.decode(n),s=e.uint.decode(n);return{roomKey:c,encryptionKey:r,mailbox:t,status:i,clock:a,initiator:1&s?o.decode(n):null,fastForwardTo:2&s?e.fixed32.decode(n):null,identitySwap:4&s?Hn.decode(n):null,identitySwapV2:d>=6&&8&s?Mn.decode(n):null,contact:d>=10&&16&s?e.fixed32.decode(n):null,bootFrom:d>=27&&32&s?o.decode(n):null,activeClock:d>=29&&64&s?e.uint.decode(n):0}}},Dn=$,Vn={preencode(d,n){Dn.preencode(d,n.header),e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.mailbox),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.dm&&e.fixed32.preencode(d,n.dm)},encode(n,c){const r=(c.fastForwardTo?1:0)|(c.initiator?2:0)|(c.dm?4:0)|(d>=9&&c.isReadOnly?8:0);Dn.encode(n,c.header),e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),e.uint.encode(n,r),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),c.initiator&&o.encode(n,c.initiator),c.dm&&e.fixed32.encode(n,c.dm)},decode(n){const c=Dn.decode(n),r=e.fixed32.decode(n),t=e.buffer.decode(n),i=e.fixed32.decode(n),a=e.uint.decode(n);return{header:c,roomKey:r,encryptionKey:t,mailbox:i,fastForwardTo:1&a?e.fixed32.decode(n):null,initiator:2&a?o.decode(n):null,dm:4&a?e.fixed32.decode(n):null,isReadOnly:d>=9&&!!(8&a)}}},Ln=$,qn={preencode(d,o){Ln.preencode(d,o.header),e.fixed32.preencode(d,o.discoveryKey)},encode(d,o){Ln.encode(d,o.header),e.fixed32.encode(d,o.discoveryKey)},decode:d=>({header:Ln.decode(d),discoveryKey:e.fixed32.decode(d)})},En=$,Bn=Fn,zn={preencode(d,o){En.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.key),Bn.preencode(d,o.status)},encode(d,o){En.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.key),Bn.encode(d,o.status)},decode:d=>({header:En.decode(d),roomKey:e.fixed32.decode(d),key:e.uint.decode(d),status:Bn.decode(d)})},Nn={preencode(e,d){e.end++},encode(o,n){const c=(n.isBlocked?1:0)|(d>=22&&n.isActive?2:0);e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{isBlocked:!!(1&n),isActive:d>=22&&!!(2&n)}}},jn={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.clock),ci.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=22&&n.contactInfo&&ri.preencode(o,n.contactInfo),d>=24&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=22&&n.contactInfo?4:0)|(d>=24&&n.alias?8:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.clock),ci.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=22&&n.contactInfo&&ri.encode(o,n.contactInfo),d>=24&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),r=ci.decode(o),t=e.uint.decode(o);return{memberKey:n,clock:c,status:r,mailbox:1&t?e.fixed32.decode(o):null,roomKey:2&t?e.fixed32.decode(o):null,contactInfo:d>=22&&4&t?ri.decode(o):null,alias:d>=24&&8&t?e.string.decode(o):null}}},On=$,Un=e.frame(an),Jn={preencode(e,d){On.preencode(e,d.header),Un.preencode(e,d.contact)},encode(e,d){On.encode(e,d.header),Un.encode(e,d.contact)},decode:e=>({header:On.decode(e),contact:Un.decode(e)})},Gn=$,Qn={preencode(d,o){Gn.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),ti.preencode(d,o.status)},encode(d,o){Gn.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),ti.encode(d,o.status)},decode:d=>({header:Gn.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:ti.decode(d)})},Wn=$,Xn={preencode(d,o){Wn.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Wn.encode(d,o.header),e.fixed32.encode(d,o.memberKey)},decode:d=>({header:Wn.decode(d),memberKey:e.fixed32.decode(d)})},Yn={preencode(e,d){e.end++},encode(d,o){const n=(o.isPending?1:0)|(o.isAccepted?2:0)|(o.isRejected?4:0)|(o.isDiscarded?8:0)|(o.isSeen?16:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isPending:!!(1&o),isAccepted:!!(2&o),isRejected:!!(4&o),isDiscarded:!!(8&o),isSeen:!!(16&o)}}},Zn=xe,$n=e.frame(t),_n={preencode(d,o){Zn.preencode(d,o.sender),$n.preencode(d,o.keys),e.fixed32.preencode(d,o.mailbox),d.end++,o.message&&e.string.preencode(d,o.message)},encode(d,o){const n=o.message?1:0;Zn.encode(d,o.sender),$n.encode(d,o.keys),e.fixed32.encode(d,o.mailbox),e.uint.encode(d,n),o.message&&e.string.encode(d,o.message)},decode:d=>({sender:Zn.decode(d),keys:$n.decode(d),mailbox:e.fixed32.decode(d),message:1&e.uint.decode(d)?e.string.decode(d):null})},ec=e.frame(_n),dc={preencode(o,n){ec.preencode(o,n.body),ne.preencode(o,n.attestation),o.end++,d>=31&&n.recipientProof&&e.buffer.preencode(o,n.recipientProof)},encode(o,n){const c=d>=31&&n.recipientProof?1:0;ec.encode(o,n.body),ne.encode(o,n.attestation),e.uint.encode(o,c),d>=31&&n.recipientProof&&e.buffer.encode(o,n.recipientProof)},decode(o){const n=ec.decode(o),c=ne.decode(o),r=o.start<o.end?e.uint.decode(o):0;return{body:n,attestation:c,recipientProof:d>=31&&1&r?e.buffer.decode(o):null}}},oc=pe,nc=e.frame(Yn),cc=$n,rc={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.clock),oc.preencode(o,n.sender),nc.preencode(o,n.status),cc.preencode(o,n.keys),e.fixed32.preencode(o,n.mailbox),o.end++,n.message&&e.string.preencode(o,n.message),d>=11&&n.sentAt&&e.uint.preencode(o,n.sentAt),d>=22&&n.contactInfo&&ii.preencode(o,n.contactInfo)},encode(o,n){const c=(n.message?1:0)|(d>=11&&n.sentAt?2:0)|(d>=22&&n.contactInfo?4:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.clock),oc.encode(o,n.sender),nc.encode(o,n.status),cc.encode(o,n.keys),e.fixed32.encode(o,n.mailbox),e.uint.encode(o,c),n.message&&e.string.encode(o,n.message),d>=11&&n.sentAt&&e.uint.encode(o,n.sentAt),d>=22&&n.contactInfo&&ii.encode(o,n.contactInfo)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),r=oc.decode(o),t=nc.decode(o),i=cc.decode(o),a=e.fixed32.decode(o),s=e.uint.decode(o);return{memberKey:n,clock:c,sender:r,status:t,keys:i,mailbox:a,message:1&s?e.string.decode(o):null,sentAt:d>=11&&2&s?e.uint.decode(o):0,contactInfo:d>=22&&4&s?ii.decode(o):null}}},tc=$,ic={preencode(d,o){tc.preencode(d,o.header),e.buffer.preencode(d,o.blindRequest)},encode(d,o){tc.encode(d,o.header),e.buffer.encode(d,o.blindRequest)},decode:d=>({header:tc.decode(d),blindRequest:e.buffer.decode(d)})},ac=$,sc=nc,pc={preencode(o,n){ac.preencode(o,n.header),e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.key),sc.preencode(o,n.status),o.end++,d>=10&&n.roomKey&&e.fixed32.preencode(o,n.roomKey)},encode(o,n){const c=d>=10&&n.roomKey?1:0;ac.encode(o,n.header),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.key),sc.encode(o,n.status),e.uint.encode(o,c),d>=10&&n.roomKey&&e.fixed32.encode(o,n.roomKey)},decode(o){const n=ac.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o),t=sc.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{header:n,memberKey:c,key:r,status:t,roomKey:d>=10&&1&i?e.fixed32.decode(o):null}}},uc={preencode(d,o){e.uint.preencode(d,o.timestamp),e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.mailbox)},encode(d,o){e.uint.encode(d,o.timestamp),e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.mailbox)},decode:d=>({version:0,timestamp:e.uint.decode(d),key:e.fixed32.decode(d),mailbox:e.fixed32.decode(d)})},lc={preencode(d,o){const n=o.version??1;switch(e.uint.preencode(d,n),n){case 0:case 1:uc.preencode(d,o);break;default:throw new Error("Unsupported version")}},encode(d,o){const n=o.version??1;switch(e.uint.encode(d,n),n){case 0:case 1:uc.encode(d,o);break;default:throw new Error("Unsupported version")}},decode(d){const o=e.uint.decode(d);switch(o){case 0:case 1:{const e=uc.decode(d);return e.version=o,e}default:throw new Error("Unsupported version")}}},fc=$,mc={preencode(o,c){fc.preencode(o,c.header),n.preencode(o,c.oplog),e.uint.preencode(o,c.index),ai.preencode(o,c.preview),o.end++,d>=7&&c.displayType&&Pc.preencode(o,c.displayType)},encode(o,c){const r=d>=7&&c.displayType?1:0;fc.encode(o,c.header),n.encode(o,c.oplog),e.uint.encode(o,c.index),ai.encode(o,c.preview),e.uint.encode(o,r),d>=7&&c.displayType&&Pc.encode(o,c.displayType)},decode(o){const c=fc.decode(o),r=n.decode(o),t=e.uint.decode(o),i=ai.decode(o),a=o.start<o.end?e.uint.decode(o):0;return{header:c,oplog:r,index:t,preview:i,displayType:d>=7&&1&a?Pc.decode(o):0}}},yc={preencode(o,n){o.end++,d>=3&&n.memberKey&&e.fixed32.preencode(o,n.memberKey)},encode(o,n){const c=d>=3&&n.memberKey?1:0;e.uint.encode(o,c),d>=3&&n.memberKey&&e.fixed32.encode(o,n.memberKey)},decode(o){const n=e.uint.decode(o);return{memberKey:d>=3&&1&n?e.fixed32.decode(o):null}}},bc=pe,xc={preencode(e,d){bc.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){bc.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:bc.decode(e),attestation:ne.decode(e)})},kc=$,vc={preencode(d,o){kc.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){kc.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:kc.decode(d),key:e.fixed32.decode(d)})},gc={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),ne.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){e.fixed32.encode(d,o.deviceKey),ne.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({deviceKey:e.fixed32.decode(d),privateProfileIdentity:ne.decode(d),deviceProof:e.buffer.decode(d)})},hc={preencode(o,n){e.fixed32.preencode(o,n.roomKey),e.fixed32.preencode(o,n.encryptionKey),e.fixed32.preencode(o,n.seed),o.end++,d>=6&&n.fastForwardTo&&e.fixed32.preencode(o,n.fastForwardTo)},encode(o,n){const c=d>=6&&n.fastForwardTo?1:0;e.fixed32.encode(o,n.roomKey),e.fixed32.encode(o,n.encryptionKey),e.fixed32.encode(o,n.seed),e.uint.encode(o,c),d>=6&&n.fastForwardTo&&e.fixed32.encode(o,n.fastForwardTo)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o);return{roomKey:n,encryptionKey:c,seed:r,fastForwardTo:d>=6&&1&t?e.fixed32.decode(o):null}}},Kc={preencode(o,n){e.fixed32.preencode(o,n.publicKey),e.fixed32.preencode(o,n.writerKey),e.fixed32.preencode(o,n.devicePublicKey),o.end++,d>=6&&n.privateProfileKey&&e.fixed32.preencode(o,n.privateProfileKey)},encode(o,n){const c=d>=6&&n.privateProfileKey?1:0;e.fixed32.encode(o,n.publicKey),e.fixed32.encode(o,n.writerKey),e.fixed32.encode(o,n.devicePublicKey),e.uint.encode(o,c),d>=6&&n.privateProfileKey&&e.fixed32.encode(o,n.privateProfileKey)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o);return{publicKey:n,writerKey:c,devicePublicKey:r,privateProfileKey:d>=6&&1&t?e.fixed32.decode(o):null}}},wc=$,Tc={preencode(d,o){wc.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey)},encode(d,o){wc.encode(d,o.header),e.fixed32.encode(d,o.memberKey)},decode:d=>({header:wc.decode(d),memberKey:e.fixed32.decode(d)})},Ac={HttpLink:1,PearLink:2},Pc={preencode(e,d){e.end++},encode(d,o){if(o>2)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Sc=$,Ic={preencode(d,o){Sc.preencode(d,o.header),e.uint.preencode(d,o.value)},encode(d,o){Sc.encode(d,o.header),e.uint.encode(d,o.value)},decode:d=>({header:Sc.decode(d),value:e.uint.decode(d)})},Rc={preencode(d,o){e.uint.preencode(d,o.key),e.uint.preencode(d,o.value)},encode(d,o){e.uint.encode(d,o.key),e.uint.encode(d,o.value)},decode:d=>({key:e.uint.decode(d),value:e.uint.decode(d)})},Fc=$,Hc={preencode(o,n){Fc.preencode(o,n.header),e.uint.preencode(o,n.from),e.uint.preencode(o,n.to),o.end++,d>=20&&n.buildType&&Br.preencode(o,n.buildType)},encode(o,n){const c=d>=20&&n.buildType?1:0;Fc.encode(o,n.header),e.uint.encode(o,n.from),e.uint.encode(o,n.to),e.uint.encode(o,c),d>=20&&n.buildType&&Br.encode(o,n.buildType)},decode(o){const n=Fc.decode(o),c=e.uint.decode(o),r=e.uint.decode(o),t=o.start<o.end?e.uint.decode(o):0;return{header:n,from:c,to:r,buildType:d>=20&&1&t?Br.decode(o):null}}},Mc={RoomType:1,IsExperimental:2,IsJoiningDisabled:3,IsAppendingDisabled:4,IsCallingDisabled:5,IsMembershipEventsDisabled:6,IsAttachmentsDisabled:7,IsLinksDisabled:8,IsRoomInviteHidden:9},Cc={preencode(e,d){e.end++},encode(d,o){if(o>9)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Dc={en:"en",it:"it",ru:"ru",es:"es",de:"de"},Vc={preencode(e,d){e.end++},encode(d,o){switch(o){case"en":e.uint.encode(d,1);break;case"it":e.uint.encode(d,2);break;case"ru":e.uint.encode(d,3);break;case"es":e.uint.encode(d,4);break;case"de":e.uint.encode(d,5);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"en";case 2:return"it";case 3:return"ru";case 4:return"es";case 5:return"de";default:return null}}},Lc=Dd,qc={preencode(d,o){Lc.preencode(d,o.range),Vc.preencode(d,o.language),e.string.preencode(d,o.text)},encode(d,o){Lc.encode(d,o.range),Vc.encode(d,o.language),e.string.encode(d,o.text)},decode:d=>({range:Lc.decode(d),language:Vc.decode(d),text:e.string.decode(d)})},Ec={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.key)},decode:d=>({deviceKey:e.fixed32.decode(d),key:e.fixed32.decode(d)})},Bc=$,zc={preencode(d,o){Bc.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){Bc.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:Bc.decode(d),key:e.fixed32.decode(d)})},Nc=$,jc={preencode(d,o){Nc.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){Nc.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:Nc.decode(d),key:e.fixed32.decode(d)})},Oc={Flag:1},Uc={preencode(e,d){e.end++},encode(d,o){if(o>1)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Jc={preencode(d,o){lo.preencode(d,o.id),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),Uc.preencode(d,o.label)},encode(d,o){lo.encode(d,o.id),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),Uc.encode(d,o.label)},decode:d=>({id:lo.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),label:Uc.decode(d)})},Gc=$,Qc={preencode(e,d){Gc.preencode(e,d.header),n.preencode(e,d.oplog),Uc.preencode(e,d.label)},encode(e,d){Gc.encode(e,d.header),n.encode(e,d.oplog),Uc.encode(e,d.label)},decode:e=>({header:Gc.decode(e),oplog:n.decode(e),label:Uc.decode(e)})},Wc=$,Xc={preencode(e,d){Wc.preencode(e,d.header),n.preencode(e,d.oplog),Uc.preencode(e,d.label)},encode(e,d){Wc.encode(e,d.header),n.encode(e,d.oplog),Uc.encode(e,d.label)},decode:e=>({header:Wc.decode(e),oplog:n.decode(e),label:Uc.decode(e)})},Yc={preencode(d,o){Uc.preencode(d,o.label),e.uint.preencode(d,o.count)},encode(d,o){Uc.encode(d,o.label),e.uint.encode(d,o.count)},decode:d=>({label:Uc.decode(d),count:e.uint.decode(d)})},Zc=e.array(e.frame(Yc)),$c={preencode(o,n){lo.preencode(o,n.id),e.uint.preencode(o,n.total),Zc.preencode(o,n.labels),e.uint.preencode(o,n.editedAt),o.end++,d>=15&&n.flagsClock&&e.uint.preencode(o,n.flagsClock),d>=15&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(d>=15&&n.flagsClock?1:0)|(d>=15&&n.version?2:0)|(d>=16&&n.isDeleted?4:0);lo.encode(o,n.id),e.uint.encode(o,n.total),Zc.encode(o,n.labels),e.uint.encode(o,n.editedAt),e.uint.encode(o,c),d>=15&&n.flagsClock&&e.uint.encode(o,n.flagsClock),d>=15&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=lo.decode(o),c=e.uint.decode(o),r=Zc.decode(o),t=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{id:n,total:c,labels:r,editedAt:t,flagsClock:d>=15&&1&i?e.uint.decode(o):0,version:d>=15&&2&i?e.uint.decode(o):0,isDeleted:d>=16&&!!(4&i)}}},_c=$,er={preencode(d,o){_c.preencode(d,o.header),e.uint.preencode(d,o.length)},encode(d,o){_c.encode(d,o.header),e.uint.encode(d,o.length)},decode:d=>({header:_c.decode(d),length:e.uint.decode(d)})},dr={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.length)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.length)},decode:d=>({memberKey:e.fixed32.decode(d),length:e.uint.decode(d)})},or=Z,nr={preencode(o,n){o.end++,d>=23&&n.profileSnoozeTime&&e.uint.preencode(o,n.profileSnoozeTime)},encode(o,n){const c=(d>=13&&n.disableReadReceipts?1:0)|(d>=21&&n.stripAttachmentMetadata?2:0)|(d>=23&&n.profileSnoozeTime?4:0);e.uint.encode(o,c),d>=23&&n.profileSnoozeTime&&e.uint.encode(o,n.profileSnoozeTime)},decode(o){const n=e.uint.decode(o);return{disableReadReceipts:d>=13&&!!(1&n),stripAttachmentMetadata:d>=21&&!!(2&n),profileSnoozeTime:d>=23&&4&n?e.uint.decode(o):0}}},cr={disableReadReceipts:"disableReadReceipts",stripAttachmentMetadata:"stripAttachmentMetadata",profileSnoozeTime:"profileSnoozeTime"},rr={preencode(e,d){e.end++},encode(d,o){switch(o){case"disableReadReceipts":e.uint.encode(d,1);break;case"stripAttachmentMetadata":e.uint.encode(d,2);break;case"profileSnoozeTime":e.uint.encode(d,3);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"disableReadReceipts";case 2:return"stripAttachmentMetadata";case 3:return"profileSnoozeTime";default:return null}}},tr=$,ir=e.frame(nr),ar={preencode(e,d){tr.preencode(e,d.header),rr.preencode(e,d.key),ir.preencode(e,d.settings)},encode(e,d){tr.encode(e,d.header),rr.encode(e,d.key),ir.encode(e,d.settings)},decode:e=>({header:tr.decode(e),key:rr.decode(e),settings:ir.decode(e)})},sr={Flag:1},pr={preencode(e,d){e.end++},encode(d,o){if(o>1)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},ur={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),pr.preencode(d,o.label)},encode(d,o){e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),pr.encode(d,o.label)},decode:d=>({key:e.fixed32.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),label:pr.decode(d)})},lr=$,fr={preencode(d,o){lr.preencode(d,o.header),e.fixed32.preencode(d,o.key),pr.preencode(d,o.label)},encode(d,o){lr.encode(d,o.header),e.fixed32.encode(d,o.key),pr.encode(d,o.label)},decode:d=>({header:lr.decode(d),key:e.fixed32.decode(d),label:pr.decode(d)})},mr={preencode(d,o){pr.preencode(d,o.label),e.uint.preencode(d,o.count)},encode(d,o){pr.encode(d,o.label),e.uint.encode(d,o.count)},decode:d=>({label:pr.decode(d),count:e.uint.decode(d)})},yr=e.array(e.frame(mr)),br={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.total),yr.preencode(d,o.labels),e.uint.preencode(d,o.editedAt),e.uint.preencode(d,o.flagsClock)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.total),yr.encode(d,o.labels),e.uint.encode(d,o.editedAt),e.uint.encode(d,o.flagsClock)},decode:d=>({key:e.fixed32.decode(d),total:e.uint.decode(d),labels:yr.decode(d),editedAt:e.uint.decode(d),flagsClock:e.uint.decode(d)})},xr={preencode(d,o){e.float64.preencode(d,o.latitude),e.float64.preencode(d,o.longitude)},encode(d,o){e.float64.encode(d,o.latitude),e.float64.encode(d,o.longitude)},decode:d=>({latitude:e.float64.decode(d),longitude:e.float64.decode(d)})},kr=$,vr={preencode(d,o){kr.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.fromDeviceKey)},encode(d,o){kr.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.fromDeviceKey)},decode:d=>({header:kr.decode(d),deviceKey:e.fixed32.decode(d),fromDeviceKey:e.fixed32.decode(d)})},gr=$,hr=X,Kr={preencode(o,n){gr.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),e.buffer.preencode(o,n.encryptionKey),o.end++,d>=19&&n.streams&&hr.preencode(o,n.streams),d>=19&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=19&&n.version&&e.uint.preencode(o,n.version),d>=26&&n.streamInputs&&si.preencode(o,n.streamInputs),d>=26&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey)},encode(o,n){const c=(d>=19&&n.streams?1:0)|(d>=19&&n.discoveryKey?2:0)|(d>=19&&n.version?4:0)|(d>=26&&n.streamInputs?8:0)|(d>=26&&n.swarmKey?16:0);gr.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,c),d>=19&&n.streams&&hr.encode(o,n.streams),d>=19&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=19&&n.version&&e.uint.encode(o,n.version),d>=26&&n.streamInputs&&si.encode(o,n.streamInputs),d>=26&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey)},decode(o){const n=gr.decode(o),c=e.fixed32.decode(o),r=e.buffer.decode(o),t=e.uint.decode(o);return{header:n,callKey:c,encryptionKey:r,streams:d>=19&&1&t?hr.decode(o):null,discoveryKey:d>=19&&2&t?e.fixed32.decode(o):null,version:d>=19&&4&t?e.uint.decode(o):0,streamInputs:d>=26&&8&t?si.decode(o):null,swarmKey:d>=26&&16&t?e.fixed32.decode(o):null}}},wr=$,Tr=X,Ar={preencode(o,n){wr.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),o.end++,d>=19&&n.streams&&Tr.preencode(o,n.streams),d>=26&&n.streamInputs&&pi.preencode(o,n.streamInputs),d>=26&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey)},encode(o,n){const c=(d>=19&&n.streams?1:0)|(d>=26&&n.streamInputs?2:0)|(d>=26&&n.swarmKey?4:0);wr.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.uint.encode(o,c),d>=19&&n.streams&&Tr.encode(o,n.streams),d>=26&&n.streamInputs&&pi.encode(o,n.streamInputs),d>=26&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey)},decode(o){const n=wr.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{header:n,callKey:c,streams:d>=19&&1&r?Tr.decode(o):null,streamInputs:d>=26&&2&r?pi.decode(o):null,swarmKey:d>=26&&4&r?e.fixed32.decode(o):null}}},Pr=$,Sr={preencode(d,o){Pr.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Pr.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Pr.decode(d),callKey:e.fixed32.decode(d)})},Ir=$,Rr={preencode(d,o){Ir.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Ir.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Ir.decode(d),callKey:e.fixed32.decode(d)})},Fr=$,Hr={preencode(o,n){Fr.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.streamKey),o.end++,d>=26&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=26&&n.type&&e.string.preencode(o,n.type)},encode(o,n){const c=(d>=26&&n.mediaStreamId?1:0)|(d>=26&&n.type?2:0)|(d>=26&&n.muted?4:0);Fr.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.streamKey),e.uint.encode(o,c),d>=26&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=26&&n.type&&e.string.encode(o,n.type)},decode(o){const n=Fr.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=o.start<o.end?e.uint.decode(o):0;return{header:n,callKey:c,streamKey:r,mediaStreamId:d>=26&&1&t?e.string.decode(o):null,type:d>=26&&2&t?e.string.decode(o):null,muted:d>=26&&!!(4&t)}}},Mr=$,Cr={preencode(d,o){Mr.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.streamKey)},encode(d,o){Mr.encode(d,o.header),e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.streamKey)},decode:d=>({header:Mr.decode(d),callKey:e.fixed32.decode(d),streamKey:e.fixed32.decode(d)})},Dr={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.buffer.preencode(o,n.encryptionKey),e.uint.preencode(o,n.createdAt),o.end++,d>=19&&n.endedAt&&e.uint.preencode(o,n.endedAt),d>=19&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=19&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(d>=19&&n.endedAt?1:0)|(d>=19&&n.discoveryKey?2:0)|(d>=19&&n.version?4:0);e.fixed32.encode(o,n.callKey),e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=19&&n.endedAt&&e.uint.encode(o,n.endedAt),d>=19&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=19&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=e.fixed32.decode(o),c=e.buffer.decode(o),r=e.uint.decode(o),t=e.uint.decode(o);return{callKey:n,encryptionKey:c,createdAt:r,endedAt:d>=19&&1&t?e.uint.decode(o):0,discoveryKey:d>=19&&2&t?e.fixed32.decode(o):null,version:d>=19&&4&t?e.uint.decode(o):0}}},Vr={preencode(d,o){e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.createdAt)},encode(d,o){e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.createdAt)},decode:d=>({callKey:e.fixed32.decode(d),memberKey:e.fixed32.decode(d),createdAt:e.uint.decode(d)})},Lr={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.deviceKey),e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.createdAt),o.end++,d>=19&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),d>=22&&n.lastHeartbeatAt&&e.uint.preencode(o,n.lastHeartbeatAt)},encode(o,n){const c=(d>=19&&n.swarmKey?1:0)|(d>=22&&n.lastHeartbeatAt?2:0)|(d>=23&&n.isRecording?4:0);e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.deviceKey),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=19&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey),d>=22&&n.lastHeartbeatAt&&e.uint.encode(o,n.lastHeartbeatAt)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o),i=e.uint.decode(o);return{callKey:n,deviceKey:c,memberKey:r,createdAt:t,swarmKey:d>=19&&1&i?e.fixed32.decode(o):null,lastHeartbeatAt:d>=22&&2&i?e.uint.decode(o):0,isRecording:d>=23&&!!(4&i)}}},qr={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.deviceKey),e.buffer.preencode(o,n.streamKey),e.uint.preencode(o,n.createdAt),o.end++,d>=26&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=26&&n.type&&e.string.preencode(o,n.type),d>=26&&n.statusKey&&e.uint.preencode(o,n.statusKey)},encode(o,n){const c=(d>=26&&n.mediaStreamId?1:0)|(d>=26&&n.type?2:0)|(d>=26&&n.statusKey?4:0);e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.deviceKey),e.buffer.encode(o,n.streamKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=26&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=26&&n.type&&e.string.encode(o,n.type),d>=26&&n.statusKey&&e.uint.encode(o,n.statusKey)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.buffer.decode(o),t=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{callKey:n,deviceKey:c,streamKey:r,createdAt:t,mediaStreamId:d>=26&&1&i?e.string.decode(o):null,type:d>=26&&2&i?e.string.decode(o):null,statusKey:d>=26&&4&i?e.uint.decode(o):0}}},Er={Nightly:"Nightly",Internal:"Internal",Production:"Production"},Br={preencode(e,d){e.end++},encode(d,o){switch(o){case"Nightly":e.uint.encode(d,1);break;case"Internal":e.uint.encode(d,2);break;case"Production":e.uint.encode(d,3);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"Nightly";case 2:return"Internal";case 3:return"Production";default:return null}}},zr=$,Nr={preencode(e,d){zr.preencode(e,d.header)},encode(e,d){zr.encode(e,d.header)},decode:e=>({header:zr.decode(e)})},jr=$,Or={preencode(e,d){jr.preencode(e,d.header)},encode(e,d){jr.encode(e,d.header)},decode:e=>({header:jr.decode(e)})},Ur=$,Jr={preencode(d,o){Ur.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),e.buffer.preencode(d,o.deviceProof),e.buffer.preencode(d,o.writerProof)},encode(d,o){Ur.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.buffer.encode(d,o.deviceProof),e.buffer.encode(d,o.writerProof)},decode:d=>({header:Ur.decode(d),deviceKey:e.fixed32.decode(d),deviceProof:e.buffer.decode(d),writerProof:e.buffer.decode(d)})},Gr=$,Qr={preencode(d,o){Gr.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Gr.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Gr.decode(d),callKey:e.fixed32.decode(d)})},Wr=$,Xr={preencode(d,o){Wr.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.deviceKey)},encode(d,o){Wr.encode(d,o.header),e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.deviceKey)},decode:d=>({header:Wr.decode(d),callKey:e.fixed32.decode(d),deviceKey:e.fixed32.decode(d)})},Yr=$,Zr={preencode(d,o){Yr.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Yr.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Yr.decode(d),callKey:e.fixed32.decode(d)})},$r=$,_r={preencode(d,o){$r.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){$r.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:$r.decode(d),callKey:e.fixed32.decode(d)})},et=$,dt={preencode(e,d){et.preencode(e,d.header),n.preencode(e,d.oplog)},encode(e,d){et.encode(e,d.header),n.encode(e,d.oplog)},decode:e=>({header:et.decode(e),oplog:n.decode(e)})},ot=$,nt={preencode(e,d){ot.preencode(e,d.header)},encode(e,d){ot.encode(e,d.header)},decode:e=>({header:ot.decode(e)})},ct={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.timestamp)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.timestamp)},decode:d=>({memberKey:e.fixed32.decode(d),timestamp:e.uint.decode(d)})},rt=$,tt={preencode(o,n){rt.preencode(o,n.header),e.fixed32.preencode(o,n.memberKey),o.end++,d>=24&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=d>=24&&n.alias?1:0;rt.encode(o,n.header),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,c),d>=24&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=rt.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{header:n,memberKey:c,alias:d>=24&&1&r?e.string.decode(o):null}}},it={preencode(d,o){e.uint.preencode(d,o.streams)},encode(d,o){e.uint.encode(d,o.streams)},decode:d=>({streams:e.uint.decode(d)})},at={preencode(d,o){e.fixed32.preencode(d,o.streamKey),e.string.preencode(d,o.mediaStreamId),e.string.preencode(d,o.type),d.end++},encode(o,n){const c=d>=26&&n.muted?1:0;e.fixed32.encode(o,n.streamKey),e.string.encode(o,n.mediaStreamId),e.string.encode(o,n.type),e.uint.encode(o,c)},decode(o){const n=e.fixed32.decode(o),c=e.string.decode(o),r=e.string.decode(o),t=e.uint.decode(o);return{streamKey:n,mediaStreamId:c,type:r,muted:d>=26&&!!(1&t)}}},st=$,pt={preencode(d,o){st.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.streamKey),d.end++},encode(o,n){const c=d>=26&&n.muted?1:0;st.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.streamKey),e.uint.encode(o,c)},decode(o){const n=st.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o);return{header:n,callKey:c,streamKey:r,muted:d>=26&&!!(1&t)}}},ut={preencode(d,o){e.uint.preencode(d,o.statusKey),d.end++},encode(o,n){const c=d>=26&&n.muted?1:0;e.uint.encode(o,n.statusKey),e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o),c=e.uint.decode(o);return{statusKey:n,muted:d>=26&&!!(1&c)}}},lt={preencode(n,c){e.fixed32.preencode(n,c.key),n.end++,d>=27&&c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=(d>=27&&c.encryptionKey?1:0)|(d>=27&&c.bootFrom?2:0);e.fixed32.encode(n,c.key),e.uint.encode(n,r),d>=27&&c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.uint.decode(n);return{key:c,encryptionKey:d>=27&&1&r?e.buffer.decode(n):null,bootFrom:d>=27&&2&r?o.decode(n):null}}},ft={preencode(d,o){e.fixed32.preencode(d,o.hash)},encode(d,o){e.fixed32.encode(d,o.hash)},decode:d=>({hash:e.fixed32.decode(d)})},mt={preencode(d,o){e.fixed32.preencode(d,o.hash),e.buffer.preencode(d,o.data)},encode(d,o){e.fixed32.encode(d,o.hash),e.buffer.encode(d,o.data)},decode:d=>({hash:e.fixed32.decode(d),data:e.buffer.decode(d)})},yt={preencode(n,c){o.preencode(n,c.autobeeMigrationHead),n.end++,d>=27&&c.legacyViewHead&&o.preencode(n,c.legacyViewHead),d>=27&&c.dbViewHead&&o.preencode(n,c.dbViewHead),d>=27&&c.blobsViewHead&&o.preencode(n,c.blobsViewHead),e.uint.preencode(n,c.createdAt)},encode(n,c){const r=(d>=27&&c.legacyViewHead?1:0)|(d>=27&&c.dbViewHead?2:0)|(d>=27&&c.blobsViewHead?4:0);o.encode(n,c.autobeeMigrationHead),e.uint.encode(n,r),d>=27&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=27&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=27&&c.blobsViewHead&&o.encode(n,c.blobsViewHead),e.uint.encode(n,c.createdAt)},decode(n){const c=o.decode(n),r=e.uint.decode(n);return{autobeeMigrationHead:c,legacyViewHead:d>=27&&1&r?o.decode(n):null,dbViewHead:d>=27&&2&r?o.decode(n):null,blobsViewHead:d>=27&&4&r?o.decode(n):null,createdAt:e.uint.decode(n)}}},bt=$,xt={preencode(e,n){bt.preencode(e,n.header),o.preencode(e,n.head),e.end++,d>=27&&n.legacyViewHead&&o.preencode(e,n.legacyViewHead),d>=27&&n.dbViewHead&&o.preencode(e,n.dbViewHead),d>=27&&n.blobsViewHead&&o.preencode(e,n.blobsViewHead)},encode(n,c){const r=(d>=27&&c.legacyViewHead?1:0)|(d>=27&&c.dbViewHead?2:0)|(d>=27&&c.blobsViewHead?4:0);bt.encode(n,c.header),o.encode(n,c.head),e.uint.encode(n,r),d>=27&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=27&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=27&&c.blobsViewHead&&o.encode(n,c.blobsViewHead)},decode(n){const c=bt.decode(n),r=o.decode(n),t=e.uint.decode(n);return{header:c,head:r,legacyViewHead:d>=27&&1&t?o.decode(n):null,dbViewHead:d>=27&&2&t?o.decode(n):null,blobsViewHead:d>=27&&4&t?o.decode(n):null}}},kt={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.fixed32.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.seed),n.end++,d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=d>=27&&c.bootFrom?1:0;e.fixed32.encode(n,c.roomKey),e.fixed32.encode(n,c.encryptionKey),e.fixed32.encode(n,c.seed),e.uint.encode(n,r),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.fixed32.decode(n),t=e.fixed32.decode(n),i=e.uint.decode(n);return{roomKey:c,encryptionKey:r,seed:t,bootFrom:d>=27&&1&i?o.decode(n):null}}},vt=id,gt={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.fixed32.preencode(d,o.deviceKey),e.uint.preencode(d,o.deviceLength),e.uint.preencode(d,o.clock),vt.preencode(d,o.status)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,o.deviceLength),e.uint.encode(d,o.clock),vt.encode(d,o.status)},decode:d=>({memberKey:e.fixed32.decode(d),deviceKey:e.fixed32.decode(d),deviceLength:e.uint.decode(d),clock:e.uint.decode(d),status:vt.decode(d)})},ht={preencode(d,o){e.fixed32.preencode(d,o.hash),e.buffer.preencode(d,o.blob)},encode(d,o){e.fixed32.encode(d,o.hash),e.buffer.encode(d,o.blob)},decode:d=>({hash:e.fixed32.decode(d),blob:e.buffer.decode(d)})},Kt=Fn,wt=Hn,Tt=vn,At={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),Kt.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,d>=27&&c.initiator&&o.preencode(n,c.initiator),d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=27&&c.identitySwap&&wt.preencode(n,c.identitySwap),d>=27&&c.identitySwapV2&&Tt.preencode(n,c.identitySwapV2),d>=27&&c.contact&&e.fixed32.preencode(n,c.contact)},encode(n,c){const r=(d>=27&&c.initiator?1:0)|(d>=27&&c.bootFrom?2:0)|(d>=27&&c.identitySwap?4:0)|(d>=27&&c.identitySwapV2?8:0)|(d>=27&&c.contact?16:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),Kt.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,r),d>=27&&c.initiator&&o.encode(n,c.initiator),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom),d>=27&&c.identitySwap&&wt.encode(n,c.identitySwap),d>=27&&c.identitySwapV2&&Tt.encode(n,c.identitySwapV2),d>=27&&c.contact&&e.fixed32.encode(n,c.contact)},decode(n){const c=e.fixed32.decode(n),r=e.buffer.decode(n),t=e.fixed32.decode(n),i=Kt.decode(n),a=e.uint.decode(n),s=e.uint.decode(n);return{roomKey:c,encryptionKey:r,mailbox:t,status:i,clock:a,initiator:d>=27&&1&s?o.decode(n):null,bootFrom:d>=27&&2&s?o.decode(n):null,identitySwap:d>=27&&4&s?wt.decode(n):null,identitySwapV2:d>=27&&8&s?Tt.decode(n):null,contact:d>=27&&16&s?e.fixed32.decode(n):null}}},Pt=$,St={preencode(n,c){Pt.preencode(n,c.header),e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),n.end++,d>=27&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=27&&c.initiator&&o.preencode(n,c.initiator),d>=27&&c.dm&&e.fixed32.preencode(n,c.dm)},encode(n,c){const r=(d>=27&&c.bootFrom?1:0)|(d>=27&&c.initiator?2:0)|(d>=27&&c.dm?4:0)|(d>=27&&c.isReadOnly?8:0);Pt.encode(n,c.header),e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),e.uint.encode(n,r),d>=27&&c.bootFrom&&o.encode(n,c.bootFrom),d>=27&&c.initiator&&o.encode(n,c.initiator),d>=27&&c.dm&&e.fixed32.encode(n,c.dm)},decode(n){const c=Pt.decode(n),r=e.fixed32.decode(n),t=e.buffer.decode(n),i=e.fixed32.decode(n),a=e.uint.decode(n);return{header:c,roomKey:r,encryptionKey:t,mailbox:i,bootFrom:d>=27&&1&a?o.decode(n):null,initiator:d>=27&&2&a?o.decode(n):null,dm:d>=27&&4&a?e.fixed32.decode(n):null,isReadOnly:d>=27&&!!(8&a)}}},It={preencode(d,o){e.fixed32.preencode(d,o.id),e.fixed32.preencode(d,o.writerKey),e.buffer.preencode(d,o.blindResponse)},encode(d,o){e.fixed32.encode(d,o.id),e.fixed32.encode(d,o.writerKey),e.buffer.encode(d,o.blindResponse)},decode:d=>({id:e.fixed32.decode(d),writerKey:e.fixed32.decode(d),blindResponse:e.buffer.decode(d)})},Rt=$,Ft={preencode(d,o){Rt.preencode(d,o.header),e.buffer.preencode(d,o.blindResponse)},encode(d,o){Rt.encode(d,o.header),e.buffer.encode(d,o.blindResponse)},decode:d=>({header:Rt.decode(d),blindResponse:e.buffer.decode(d)})},Ht=$,Mt={preencode(e,d){Ht.preencode(e,d.header)},encode(e,d){Ht.encode(e,d.header)},decode:e=>({header:Ht.decode(e)})},Ct=$,Dt={preencode(o,c){Ct.preencode(o,c.header),n.preencode(o,c.oplog),e.uint.preencode(o,c.index),o.end++,d>=30&&c.displayType&&Pc.preencode(o,c.displayType)},encode(o,c){const r=d>=30&&c.displayType?1:0;Ct.encode(o,c.header),n.encode(o,c.oplog),e.uint.encode(o,c.index),e.uint.encode(o,r),d>=30&&c.displayType&&Pc.encode(o,c.displayType)},decode(o){const c=Ct.decode(o),r=n.decode(o),t=e.uint.decode(o),i=e.uint.decode(o);return{header:c,oplog:r,index:t,displayType:d>=30&&1&i?Pc.decode(o):0}}},Vt=$,Lt=jd,qt={preencode(d,o){Vt.preencode(d,o.header),n.preencode(d,o.oplog),Pc.preencode(d,o.displayType),e.uint.preencode(d,o.index),Lt.preencode(d,o.preview)},encode(d,o){Vt.encode(d,o.header),n.encode(d,o.oplog),Pc.encode(d,o.displayType),e.uint.encode(d,o.index),Lt.encode(d,o.preview)},decode:d=>({header:Vt.decode(d),oplog:n.decode(d),displayType:Pc.decode(d),index:e.uint.decode(d),preview:Lt.decode(d)})},Et=$,Bt={preencode(d,o){Et.preencode(d,o.header),n.preencode(d,o.oplog),Pc.preencode(d,o.displayType),e.uint.preencode(d,o.index)},encode(d,o){Et.encode(d,o.header),n.encode(d,o.oplog),Pc.encode(d,o.displayType),e.uint.encode(d,o.index)},decode:d=>({header:Et.decode(d),oplog:n.decode(d),displayType:Pc.decode(d),index:e.uint.decode(d)})},zt=e.frame(w),Nt=e.frame(it),jt=zt,Ot=e.array(Vc),Ut=e.frame(se),Jt=zt,Gt=Ut,Qt=e.frame(hc),Wt=e.frame(kt),Xt=Ut,Yt=e.frame(fd),Zt=e.frame(yc),$t=e.frame(xr),_t=$t,ei=e.array(e.frame(qc)),di=zt,oi=e.frame(Nn),ni=e.frame(xc),ci=oi,ri=ni,ti=oi,ii=ni,ai=zt,si=e.array(e.frame(at)),pi=si;function ui(e){switch(e){case"@keet/head":return o;case"@keet/oplog-id":return n;case"@keet/encryption-keypair":return c;case"@keet/signing-keypair":return r;case"@keet/room-keys":return t;case"@keet/operation-header":return i;case"@keet/blob-pointer":return a;case"@keet/file-dimensions":return s;case"@keet/file-metadata":return u;case"@keet/external-drive-pointer":return l;case"@keet/external-blob-pointer":return f;case"@keet/file-pointer":return b;case"@keet/file":return v;case"@keet/image-file":return w;case"@keet/file-status":return T;case"@keet/file-record":return S;case"@keet/device-status":return I;case"@keet/member-status":return R;case"@keet/member-moderation-status":return F;case"@keet/abi":return H;case"@keet/device-stats":return M;case"@keet/member-stats":return C;case"@keet/chat-stats":return D;case"@keet/file-stats":return V;case"@keet/stats":return z;case"@keet/room-type":return j;case"@keet/system-settings":return O;case"@keet/system-digest":return G;case"@keet/room-seed":return Q;case"@keet/room-capabilities":return W;case"@keet/room-config":return Y;case"@keet/blind-peer":return Z;case"@keet/add-blind-peer-operation":return ee;case"@keet/remove-blind-peer-operation":return oe;case"@keet/identity-attestation":return ne;case"@keet/device-invitation":return ce;case"@keet/device":return ie;case"@keet/member-profile":return ae;case"@keet/device-profile":return se;case"@keet/member-update":return ue;case"@keet/device-update":return le;case"@keet/signed-pairing-data":return fe;case"@keet/device-request-identity":return me;case"@keet/device-response-identity":return ye;case"@keet/device-request-with-invitation":return ve;case"@keet/device-request-with-invitation-and-proof":return he;case"@keet/device-request-with-member-proof":return Te;case"@keet/device-request":return Se;case"@keet/device-response":return Fe;case"@keet/invitation-metadata":return He;case"@keet/invitation":return De;case"@keet/add-invitation-operation":return qe;case"@keet/remove-invitation-operation":return Be;case"@keet/sendable-room-invitation":return ze;case"@keet/sendable-identity-invitation":return Ne;case"@keet/sendable-contact-invitation":return je;case"@keet/sendable-invitation":return Qe;case"@keet/add-device-operation":return Xe;case"@keet/update-device-operation":return Ze;case"@keet/start-indexing-operation":return $e;case"@keet/stop-indexing-operation":return _e;case"@keet/join-request":return dd;case"@keet/accept-join-request-operation":return cd;case"@keet/reject-join-request-operation":return td;case"@keet/member":return sd;case"@keet/full-member":return ld;case"@keet/member-proofs":return fd;case"@keet/update-member-operation":return bd;case"@keet/change-member-status-operation":return vd;case"@keet/change-member-role-operation":return hd;case"@keet/remove-member-operation":return wd;case"@keet/member-activity":return Td;case"@keet/member-joined-event":return Ad;case"@keet/member-left-event":return Pd;case"@keet/title-changed-chat-event":return Sd;case"@keet/chat-event":return Hd;case"@keet/sendable-event":return Md;case"@keet/display-range":return Cd;case"@keet/display-content-range":return Vd;case"@keet/mention-display-item":return qd;case"@keet/link-preview":return zd;case"@keet/display-link-item":return Od;case"@keet/display":return _d;case"@keet/oplog-message":return co;case"@keet/index-message":return io;case"@keet/full-index-message":return po;case"@keet/message-status":return uo;case"@keet/message-index-id":return lo;case"@keet/thread":return mo;case"@keet/chat-message-record":return ko;case"@keet/full-chat-message-record":return Ko;case"@keet/add-chat-message-operation":return Ao;case"@keet/remove-chat-message-operation":return So;case"@keet/update-chat-message-operation":return Fo;case"@keet/pin-chat-message-operation":return Mo;case"@keet/reaction":return Co;case"@keet/reactions-summary":return Do;case"@keet/reactions-digest":return Lo;case"@keet/add-reaction-operation":return Eo;case"@keet/remove-reaction-operation":return zo;case"@keet/update-room-config-operation":return Oo;case"@keet/group-member":return Uo;case"@keet/user-registry-info":return Jo;case"@keet/room-identity":return Qo;case"@keet/genesis-operation":return dn;case"@keet/upgrade-operation":return nn;case"@keet/update-system-settings-operation":return tn;case"@keet-private-id/contact":return an;case"@keet-private-id/v3-room-migration-info":return sn;case"@keet-private-id/run-v3-migration-operation":return ln;case"@keet-private-id/update-identity-operation":return mn;case"@keet-private-id/counters":return yn;case"@keet-private-id/stats":return bn;case"@keet-private-id/add-entropy-operation":return xn;case"@keet-private-id/pending-invitation-identity":return kn;case"@keet-private-id/pending-invitation":return gn;case"@keet-private-id/resolve-pending-invitation-operation":return Kn;case"@keet-private-id/add-pending-invitation-operation":return An;case"@keet-private-id/remove-pending-invitation-operation":return Sn;case"@keet-private-id/identity-swap":return In;case"@keet-private-id/room-status":return Rn;case"@keet-private-id/room":return Cn;case"@keet-private-id/add-room-operation":return Vn;case"@keet-private-id/remove-room-operation":return qn;case"@keet-private-id/update-room-status-operation":return zn;case"@keet-private-id/contact-status":return Nn;case"@keet-private-id/contact-record":return jn;case"@keet-private-id/add-contact-operation":return Jn;case"@keet-private-id/update-contact-status-operation":return Qn;case"@keet-private-id/remove-contact-operation":return Xn;case"@keet-private-id/contact-request-status":return Yn;case"@keet-private-id/contact-request-body":return _n;case"@keet-private-id/contact-request":return dc;case"@keet-private-id/contact-request-record":return rc;case"@keet-private-id/add-contact-request-operation":return ic;case"@keet-private-id/update-contact-request-status-operation":return pc;case"@keet-private-id/profile-discovery-record-v1":return uc;case"@keet-private-id/profile-discovery-record":return lc;case"@keet/add-file-preview-operation":return mc;case"@keet/member-removed-event":return yc;case"@keet/member-contact-info":return xc;case"@keet/remove-device-operation":return vc;case"@keet/device-identity":return gc;case"@keet/readonly-room-invitation":return hc;case"@keet-private-id/identity-swap-v2":return Kc;case"@keet-private-id/activate-contact-room-operation":return Tc;case"@keet/display-type":return Pc;case"@keet/test-increment-operation":return Ic;case"@keet/test-collection-record-1":return Rc;case"@keet/migrate-abi-operation":return Hc;case"@keet/system-settings-keys":return Cc;case"@keet/room-supported-language":return Vc;case"@keet/translation-display-item":return qc;case"@keet-private-id/unreads":return Ec;case"@keet-private-id/add-unreads-key-operation":return zc;case"@keet-private-id/remove-unreads-key-operation":return jc;case"@keet/label-type":return Uc;case"@keet/chat-label":return Jc;case"@keet/add-chat-label-operation":return Qc;case"@keet/remove-chat-label-operation":return Xc;case"@keet/chat-label-summary":return Yc;case"@keet/chat-label-digest":return $c;case"@keet/update-read-length-operation":return er;case"@keet/read-length":return dr;case"@keet/tmp-removed-member":return or;case"@keet-private-id/settings":return nr;case"@keet-private-id/user-settings-key":return rr;case"@keet-private-id/update-settings-operation":return ar;case"@keet/member-label-type":return pr;case"@keet/member-label":return ur;case"@keet/add-member-label-operation":return fr;case"@keet/member-label-summary":return mr;case"@keet/member-label-digest":return br;case"@keet/location-shared-event":return xr;case"@keet/move-indexer-operation":return vr;case"@keet/start-call":return Kr;case"@keet/join-call":return Ar;case"@keet/leave-call":return Sr;case"@keet/end-call":return Rr;case"@keet/add-call-stream":return Hr;case"@keet/remove-call-stream":return Cr;case"@keet/call-record":return Dr;case"@keet/call-member-record":return Vr;case"@keet/call-device-record":return Lr;case"@keet/call-stream-record":return qr;case"@keet/build-type":return Br;case"@keet/test-crash-operation":return Nr;case"@keet/test-dispatch-error-operation":return Or;case"@keet-private-id/shorten-device-attestation-operation":return Jr;case"@keet/call-device-heartbeat":return Qr;case"@keet/remove-call-device":return Xr;case"@keet/start-call-recording":return Zr;case"@keet/stop-call-recording":return _r;case"@keet/dismiss-chat-reports-operation":return dt;case"@keet/update-typing-indicator-operation":return nt;case"@keet/typing-indicator":return ct;case"@keet-private-id/update-contact-alias-operation":return tt;case"@keet/call-stats":return it;case"@keet/call-stream-input":return at;case"@keet/update-call-stream":return pt;case"@keet/call-stream-status-record":return ut;case"@keet/room-keys-v2":return lt;case"@keet/blob-pointer-v2":return ft;case"@keet/blob":return mt;case"@keet/autobee-migration":return yt;case"@keet/autobee-migration-operation":return xt;case"@keet/readonly-room-invitation-v2":return kt;case"@keet/admin-last-seen":return gt;case"@keet/blob-record":return ht;case"@keet-private-id/room-v2":return At;case"@keet-private-id/add-room-operation-v2":return St;case"@keet-private-id/pending-invitation-response":return It;case"@keet-private-id/resolve-pending-invitation-operation-v2":return Ft;case"@keet/claim-admin-devices-operation":return Mt;case"@keet/remove-file-preview-operation":return Dt;case"@keet/add-link-preview-operation":return qt;case"@keet/remove-link-preview-operation":return Bt;default:throw new Error("Encoder not found "+e)}}function li(e,o=31){const n=ui(e);return{preencode(e,c){d=o,n.preencode(e,c)},encode(e,c){d=o,n.encode(e,c)},decode:e=>(d=o,n.decode(e))}}const fi=li;module.exports={resolveStruct:fi,getStruct:li,getEnum:function(e){switch(e){case"@keet/room-type":return N;case"@keet/display-type":return Ac;case"@keet/system-settings-keys":return Mc;case"@keet/room-supported-language":return Dc;case"@keet/label-type":return Oc;case"@keet-private-id/user-settings-key":return cr;case"@keet/member-label-type":return sr;case"@keet/build-type":return Er;default:throw new Error("Enum not found "+e)}},getEncoding:ui,encode:function(o,n,c=31){return d=c,e.encode(ui(o),n)},decode:function(o,n,c=31){return d=c,e.decode(ui(o),n)},setVersion:function(e){d=e},version:d};
@holepunchto/keet-core/schema/spec/contract/hyperschema/schema.json +123 -2
……@@ -1,5 +1,5 @@
11{
2 "version": 29,
2 "version": 31,
33 "schema": [
44 {
55 "name": "public-key",
……@@ -3668,7 +3668,7 @@
36683668 "name": "contact-request",
36693669 "namespace": "keet-private-id",
36703670 "compact": false,
3671 "flagsPosition": -1,
3671 "flagsPosition": 2,
36723672 "fields": [
36733673 {
36743674 "name": "body",
……@@ -3681,6 +3681,11 @@
36813681 "required": true,
36823682 "type": "@keet/identity-attestation",
36833683 "version": 1
3684 },
3685 {
3686 "name": "recipientProof",
3687 "type": "buffer",
3688 "version": 31
36843689 }
36853690 ]
36863691 },
……@@ -3829,6 +3834,7 @@
38293834 {
38303835 "name": "profile-discovery-record",
38313836 "namespace": "keet-private-id",
3837 "framed": false,
38323838 "versions": [
38333839 {
38343840 "type": "@keet-private-id/profile-discovery-record-v1",
……@@ -5819,6 +5825,121 @@
58195825 "version": 28
58205826 }
58215827 ]
5828 },
5829 {
5830 "name": "claim-admin-devices-operation",
5831 "namespace": "keet",
5832 "compact": false,
5833 "flagsPosition": -1,
5834 "fields": [
5835 {
5836 "name": "header",
5837 "required": true,
5838 "type": "@keet/operation-header",
5839 "version": 30
5840 }
5841 ]
5842 },
5843 {
5844 "name": "remove-file-preview-operation",
5845 "namespace": "keet",
5846 "compact": false,
5847 "flagsPosition": 3,
5848 "fields": [
5849 {
5850 "name": "header",
5851 "required": true,
5852 "type": "@keet/operation-header",
5853 "version": 30
5854 },
5855 {
5856 "name": "oplog",
5857 "required": true,
5858 "type": "@keet/oplog-id",
5859 "version": 30
5860 },
5861 {
5862 "name": "index",
5863 "required": true,
5864 "type": "uint",
5865 "version": 30
5866 },
5867 {
5868 "name": "displayType",
5869 "type": "@keet/display-type",
5870 "version": 30
5871 }
5872 ]
5873 },
5874 {
5875 "name": "add-link-preview-operation",
5876 "namespace": "keet",
5877 "compact": false,
5878 "flagsPosition": -1,
5879 "fields": [
5880 {
5881 "name": "header",
5882 "required": true,
5883 "type": "@keet/operation-header",
5884 "version": 30
5885 },
5886 {
5887 "name": "oplog",
5888 "required": true,
5889 "type": "@keet/oplog-id",
5890 "version": 30
5891 },
5892 {
5893 "name": "displayType",
5894 "required": true,
5895 "type": "@keet/display-type",
5896 "version": 30
5897 },
5898 {
5899 "name": "index",
5900 "required": true,
5901 "type": "uint",
5902 "version": 30
5903 },
5904 {
5905 "name": "preview",
5906 "required": true,
5907 "type": "@keet/link-preview",
5908 "version": 30
5909 }
5910 ]
5911 },
5912 {
5913 "name": "remove-link-preview-operation",
5914 "namespace": "keet",
5915 "compact": false,
5916 "flagsPosition": -1,
5917 "fields": [
5918 {
5919 "name": "header",
5920 "required": true,
5921 "type": "@keet/operation-header",
5922 "version": 30
5923 },
5924 {
5925 "name": "oplog",
5926 "required": true,
5927 "type": "@keet/oplog-id",
5928 "version": 30
5929 },
5930 {
5931 "name": "displayType",
5932 "required": true,
5933 "type": "@keet/display-type",
5934 "version": 30
5935 },
5936 {
5937 "name": "index",
5938 "required": true,
5939 "type": "uint",
5940 "version": 30
5941 }
5942 ]
58225943 }
58235944 ]
58245945}
@holepunchto/keet-core/schema/spec/local/hyperdb/messages.js +1 -1
……@@ -1 +1 @@
1const{c:e}=require("hyperschema/runtime");let d=39;const o={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.length)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.length)},decode:d=>({key:e.fixed32.decode(d),length:e.uint.decode(d)})},n={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.seq)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.seq)},decode:d=>({key:e.fixed32.decode(d),seq:e.uint.decode(d)})},c={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.secretKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.secretKey)},decode:d=>({publicKey:e.fixed32.decode(d),secretKey:e.fixed32.decode(d)})},r={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed64.preencode(d,o.secretKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed64.encode(d,o.secretKey)},decode:d=>({publicKey:e.fixed32.decode(d),secretKey:e.fixed64.decode(d)})},t={preencode(n,c){e.fixed32.preencode(n,c.key),n.end++,c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),d>=37&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=(c.encryptionKey?1:0)|(c.fastForwardTo?2:0)|(d>=37&&c.bootFrom?4:0);e.fixed32.encode(n,c.key),e.uint.encode(n,r),c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),d>=37&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.uint.decode(n);return{key:c,encryptionKey:1&r?e.buffer.decode(n):null,fastForwardTo:2&r?e.fixed32.decode(n):null,bootFrom:d>=37&&4&r?o.decode(n):null}}},i={preencode(d,o){e.uint.preencode(d,o.timestamp)},encode(d,o){e.uint.encode(d,o.timestamp)},decode:d=>({timestamp:e.uint.decode(d)})},a={preencode(d,o){e.uint.preencode(d,o.blockOffset),e.uint.preencode(d,o.blockLength),e.uint.preencode(d,o.byteOffset),e.uint.preencode(d,o.byteLength)},encode(d,o){e.uint.encode(d,o.blockOffset),e.uint.encode(d,o.blockLength),e.uint.encode(d,o.byteOffset),e.uint.encode(d,o.byteLength)},decode:d=>({blockOffset:e.uint.decode(d),blockLength:e.uint.decode(d),byteOffset:e.uint.decode(d),byteLength:e.uint.decode(d)})},s={preencode(d,o){e.uint.preencode(d,o.width),e.uint.preencode(d,o.height)},encode(d,o){e.uint.encode(d,o.width),e.uint.encode(d,o.height)},decode:d=>({width:e.uint.decode(d),height:e.uint.decode(d)})},l=e.frame(s),p={preencode(d,o){d.end++,o.name&&e.string.preencode(d,o.name),o.mimetype&&e.string.preencode(d,o.mimetype),o.dimensions&&l.preencode(d,o.dimensions),o.userdata&&e.buffer.preencode(d,o.userdata),o.duration&&e.uint.preencode(d,o.duration)},encode(d,o){const n=(o.name?1:0)|(o.mimetype?2:0)|(o.dimensions?4:0)|(o.userdata?8:0)|(o.duration?16:0)|(o.isPreview?32:0);e.uint.encode(d,n),o.name&&e.string.encode(d,o.name),o.mimetype&&e.string.encode(d,o.mimetype),o.dimensions&&l.encode(d,o.dimensions),o.userdata&&e.buffer.encode(d,o.userdata),o.duration&&e.uint.encode(d,o.duration)},decode(d){const o=e.uint.decode(d);return{name:1&o?e.string.decode(d):null,mimetype:2&o?e.string.decode(d):null,dimensions:4&o?l.decode(d):null,userdata:8&o?e.buffer.decode(d):null,duration:16&o?e.uint.decode(d):0,isPreview:!!(32&o)}}},u={preencode(d,o){e.fixed32.preencode(d,o.key),e.string.preencode(d,o.path),e.uint.preencode(d,o.version),e.uint.preencode(d,o.size)},encode(d,o){e.fixed32.encode(d,o.key),e.string.encode(d,o.path),e.uint.encode(d,o.version),e.uint.encode(d,o.size)},decode:d=>({key:e.fixed32.decode(d),path:e.string.decode(d),version:e.uint.decode(d),size:e.uint.decode(d)})},f={preencode(d,o){e.fixed32.preencode(d,o.key),a.preencode(d,o.blob)},encode(d,o){e.fixed32.encode(d,o.key),a.encode(d,o.blob)},decode:d=>({key:e.fixed32.decode(d),blob:a.decode(d)})},m=e.frame(f),y=e.frame(u),b={preencode(o,n){o.end++,n.inlined&&e.buffer.preencode(o,n.inlined),n.blob&&a.preencode(o,n.blob),n.externalBlob&&m.preencode(o,n.externalBlob),n.externalDrive&&y.preencode(o,n.externalDrive),d>=37&&n.bee&&_i.preencode(o,n.bee)},encode(o,n){const c=(n.inlined?1:0)|(n.blob?2:0)|(n.externalBlob?4:0)|(n.externalDrive?8:0)|(d>=37&&n.bee?16:0);e.uint.encode(o,c),n.inlined&&e.buffer.encode(o,n.inlined),n.blob&&a.encode(o,n.blob),n.externalBlob&&m.encode(o,n.externalBlob),n.externalDrive&&y.encode(o,n.externalDrive),d>=37&&n.bee&&_i.encode(o,n.bee)},decode(o){const n=e.uint.decode(o);return{inlined:1&n?e.buffer.decode(o):null,blob:2&n?a.decode(o):null,externalBlob:4&n?m.decode(o):null,externalDrive:8&n?y.decode(o):null,bee:d>=37&&16&n?_i.decode(o):null}}},x=e.frame(b),v=e.frame(p),g={preencode(d,o){x.preencode(d,o.pointer),d.end++,o.metadata&&v.preencode(d,o.metadata),o.preview&&Ds.preencode(d,o.preview),o.hash&&e.fixed32.preencode(d,o.hash)},encode(d,o){const n=(o.metadata?1:0)|(o.preview?2:0)|(o.hash?4:0);x.encode(d,o.pointer),e.uint.encode(d,n),o.metadata&&v.encode(d,o.metadata),o.preview&&Ds.encode(d,o.preview),o.hash&&e.fixed32.encode(d,o.hash)},decode(d){const o=x.decode(d),n=e.uint.decode(d);return{pointer:o,metadata:1&n?v.decode(d):null,preview:2&n?Ds.decode(d):null,hash:4&n?e.fixed32.decode(d):null}}},k=e.frame(g),K=k,h=k,w={preencode(e,d){e.end++,d.small&&k.preencode(e,d.small),d.medium&&K.preencode(e,d.medium),d.large&&h.preencode(e,d.large)},encode(d,o){const n=(o.small?1:0)|(o.medium?2:0)|(o.large?4:0);e.uint.encode(d,n),o.small&&k.encode(d,o.small),o.medium&&K.encode(d,o.medium),o.large&&h.encode(d,o.large)},decode(d){const o=e.uint.decode(d);return{small:1&o?k.decode(d):null,medium:2&o?K.decode(d):null,large:4&o?h.decode(d):null}}},R={preencode(e,d){e.end++},encode(d,o){const n=o.isDeleted?1:0;e.uint.encode(d,n)},decode:d=>({isDeleted:!!(1&e.uint.decode(d))})},P=e.frame(R),T=k,A={preencode(o,c){e.uint.preencode(o,c.id),n.preencode(o,c.oplog),P.preencode(o,c.status),T.preencode(o,c.file),o.end++,d>=22&&c.version&&e.uint.preencode(o,c.version)},encode(o,c){const r=d>=22&&c.version?1:0;e.uint.encode(o,c.id),n.encode(o,c.oplog),P.encode(o,c.status),T.encode(o,c.file),e.uint.encode(o,r),d>=22&&c.version&&e.uint.encode(o,c.version)},decode(o){const c=e.uint.decode(o),r=n.decode(o),t=P.decode(o),i=T.decode(o),a=o.start<o.end?e.uint.decode(o):0;return{id:c,oplog:r,status:t,file:i,version:d>=22&&1&a?e.uint.decode(o):0}}},M={preencode(e,d){e.end++},encode(d,o){const n=(o.isActive?1:0)|(o.isIndexing?2:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isActive:!!(1&o),isIndexing:!!(2&o)}}},S={preencode(o,n){const c=(n.isAdmin?1:0)|(n.isModerator?2:0)|(n.isPending?4:0)|(n.isActive?8:0)|(n.isMuted?16:0)|(n.isBanned?32:0)|(n.isShadowBanned?64:0)|(d>=19&&n.isRemoved?128:0);e.uint.preencode(o,c)},encode(o,n){const c=(n.isAdmin?1:0)|(n.isModerator?2:0)|(n.isPending?4:0)|(n.isActive?8:0)|(n.isMuted?16:0)|(n.isBanned?32:0)|(n.isShadowBanned?64:0)|(d>=19&&n.isRemoved?128:0);e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{isAdmin:!!(1&n),isModerator:!!(2&n),isPending:!!(4&n),isActive:!!(8&n),isMuted:!!(16&n),isBanned:!!(32&n),isShadowBanned:!!(64&n),isRemoved:d>=19&&!!(128&n)}}},I={preencode(e,d){e.end++},encode(d,o){const n=(o.isMuted?1:0)|(o.isBanned?2:0)|(o.isShadowBanned?4:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isMuted:!!(1&o),isBanned:!!(2&o),isShadowBanned:!!(4&o)}}},C={preencode(d,o){e.uint.preencode(d,o.version)},encode(d,o){e.uint.encode(d,o.version)},decode:d=>({version:e.uint.decode(d)})},V={preencode(d,o){e.uint.preencode(d,o.total),e.uint.preencode(d,o.active)},encode(d,o){e.uint.encode(d,o.total),e.uint.encode(d,o.active)},decode:d=>({total:e.uint.decode(d),active:e.uint.decode(d)})},H={preencode(d,o){e.uint.preencode(d,o.total),e.uint.preencode(d,o.active),e.uint.preencode(d,o.pending)},encode(d,o){e.uint.encode(d,o.total),e.uint.encode(d,o.active),e.uint.encode(d,o.pending)},decode:d=>({total:e.uint.decode(d),active:e.uint.decode(d),pending:e.uint.decode(d)})},F={preencode(o,n){e.uint.preencode(o,n.clock),e.uint.preencode(o,n.pinned),e.uint.preencode(o,n.threads),e.uint.preencode(o,n.timestamp),o.end++,d>=24&&n.flagsClock&&e.uint.preencode(o,n.flagsClock)},encode(o,n){const c=d>=24&&n.flagsClock?1:0;e.uint.encode(o,n.clock),e.uint.encode(o,n.pinned),e.uint.encode(o,n.threads),e.uint.encode(o,n.timestamp),e.uint.encode(o,c),d>=24&&n.flagsClock&&e.uint.encode(o,n.flagsClock)},decode(o){const n=e.uint.decode(o),c=e.uint.decode(o),r=e.uint.decode(o),t=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{clock:n,pinned:c,threads:r,timestamp:t,flagsClock:d>=24&&1&i?e.uint.decode(o):0}}},D={preencode(d,o){e.uint.preencode(d,o.clock)},encode(d,o){e.uint.encode(d,o.clock)},decode:d=>({clock:e.uint.decode(d)})},L=e.frame(V),j=e.frame(H),q=e.frame(F),B=e.frame(D),E={preencode(e,o){L.preencode(e,o.devices),j.preencode(e,o.members),q.preencode(e,o.chat),B.preencode(e,o.files),e.end++,d>=36&&o.calls&&Ls.preencode(e,o.calls)},encode(o,n){const c=d>=36&&n.calls?1:0;L.encode(o,n.devices),j.encode(o,n.members),q.encode(o,n.chat),B.encode(o,n.files),e.uint.encode(o,c),d>=36&&n.calls&&Ls.encode(o,n.calls)},decode(o){const n=L.decode(o),c=j.decode(o),r=q.decode(o),t=B.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{devices:n,members:c,chat:r,files:t,calls:d>=36&&1&i?Ls.decode(o):null}}},z={Default:1,Broadcast:2,DirectMessage:3},O={preencode(e,d){e.end++},encode(d,o){if(o>3)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},N={preencode(o,n){const c=(n.roomType?1:0)|(n.isExperimental?2:0)|(n.isJoiningDisabled?4:0)|(n.isAppendingDisabled?8:0)|(n.isCallingDisabled?16:0)|(n.isMembershipEventsDisabled?32:0)|(d>=28&&n.isAttachmentsDisabled?64:0)|(d>=28&&n.isLinksDisabled?128:0)|(d>=29&&n.buildType?256:0)|(d>=33&&n.isRoomInviteHidden?512:0);e.uint.preencode(o,c),n.roomType&&O.preencode(o,n.roomType),d>=29&&n.buildType&&xi.preencode(o,n.buildType)},encode(o,n){const c=(n.roomType?1:0)|(n.isExperimental?2:0)|(n.isJoiningDisabled?4:0)|(n.isAppendingDisabled?8:0)|(n.isCallingDisabled?16:0)|(n.isMembershipEventsDisabled?32:0)|(d>=28&&n.isAttachmentsDisabled?64:0)|(d>=28&&n.isLinksDisabled?128:0)|(d>=29&&n.buildType?256:0)|(d>=33&&n.isRoomInviteHidden?512:0);e.uint.encode(o,c),n.roomType&&O.encode(o,n.roomType),d>=29&&n.buildType&&xi.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{roomType:1&n?O.decode(o):0,isExperimental:!!(2&n),isJoiningDisabled:!!(4&n),isAppendingDisabled:!!(8&n),isCallingDisabled:!!(16&n),isMembershipEventsDisabled:!!(32&n),isAttachmentsDisabled:d>=28&&!!(64&n),isLinksDisabled:d>=28&&!!(128&n),buildType:d>=29&&256&n?xi.decode(o):null,isRoomInviteHidden:d>=33&&!!(512&n)}}},U=e.frame(C),J=e.frame(N),W={preencode(d,o){U.preencode(d,o.abi),J.preencode(d,o.settings),e.uint.preencode(d,o.creationTime)},encode(d,o){U.encode(d,o.abi),J.encode(d,o.settings),e.uint.encode(d,o.creationTime)},decode:d=>({abi:U.decode(d),settings:J.decode(d),creationTime:e.uint.decode(d)})},G={preencode(d,o){e.fixed32.preencode(d,o.seed)},encode(d,o){e.fixed32.encode(d,o.seed)},decode:d=>({seed:e.fixed32.decode(d)})},Q={preencode(d,o){c.preencode(d,o.mailboxKeyPair),r.preencode(d,o.discoveryKeyPair),e.fixed32.preencode(d,o.wakeupTopic),e.fixed32.preencode(d,o.swarmTopic)},encode(d,o){c.encode(d,o.mailboxKeyPair),r.encode(d,o.discoveryKeyPair),e.fixed32.encode(d,o.wakeupTopic),e.fixed32.encode(d,o.swarmTopic)},decode:d=>({mailboxKeyPair:c.decode(d),discoveryKeyPair:r.decode(d),wakeupTopic:e.fixed32.decode(d),swarmTopic:e.fixed32.decode(d)})},X=e.array(e.fixed32),Y={preencode(o,n){o.end++,n.title&&e.string.preencode(o,n.title),n.avatar&&js.preencode(o,n.avatar),n.description&&e.string.preencode(o,n.description),d>=17&&n.supportedLanguages&&qs.preencode(o,n.supportedLanguages),d>=19&&n.blindPeers&&X.preencode(o,n.blindPeers)},encode(o,n){const c=(n.title?1:0)|(n.avatar?2:0)|(n.description?4:0)|(d>=17&&n.supportedLanguages?8:0)|(d>=19&&n.blindPeers?16:0);e.uint.encode(o,c),n.title&&e.string.encode(o,n.title),n.avatar&&js.encode(o,n.avatar),n.description&&e.string.encode(o,n.description),d>=17&&n.supportedLanguages&&qs.encode(o,n.supportedLanguages),d>=19&&n.blindPeers&&X.encode(o,n.blindPeers)},decode(o){const n=e.uint.decode(o);return{title:1&n?e.string.decode(o):null,avatar:2&n?js.decode(o):null,description:4&n?e.string.decode(o):null,supportedLanguages:d>=17&&8&n?qs.decode(o):null,blindPeers:d>=19&&16&n?X.decode(o):null}}},Z={preencode(d,o){e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.key)},decode:d=>({key:e.fixed32.decode(d)})},$=e.frame(i),_=e.frame(Z),ee={preencode(e,d){$.preencode(e,d.header),_.preencode(e,d.peer)},encode(e,d){$.encode(e,d.header),_.encode(e,d.peer)},decode:e=>({header:$.decode(e),peer:_.decode(e)})},de=$,oe={preencode(d,o){de.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){de.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:de.decode(d),key:e.fixed32.decode(d)})},ne={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.buffer.preencode(d,o.proof)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.buffer.encode(d,o.proof)},decode:d=>({memberKey:e.fixed32.decode(d),proof:e.buffer.decode(d)})},ce={preencode(d,o){e.fixed32.preencode(d,o.id),e.buffer.preencode(d,o.response)},encode(d,o){e.fixed32.encode(d,o.id),e.buffer.encode(d,o.response)},decode:d=>({id:e.fixed32.decode(d),response:e.buffer.decode(d)})},re=e.frame(M),te=e.frame(ce),ie={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.memberKey),re.preencode(d,o.status),Bs.preencode(d,o.profile),d.end++,o.invitation&&te.preencode(d,o.invitation)},encode(d,o){const n=o.invitation?1:0;e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.memberKey),re.encode(d,o.status),Bs.encode(d,o.profile),e.uint.encode(d,n),o.invitation&&te.encode(d,o.invitation)},decode:d=>({key:e.fixed32.decode(d),memberKey:e.fixed32.decode(d),status:re.decode(d),profile:Bs.decode(d),invitation:1&e.uint.decode(d)?te.decode(d):null})},ae={preencode(d,o){e.uint.preencode(d,o.timestamp),d.end++,o.mailbox&&e.fixed32.preencode(d,o.mailbox),o.displayName&&e.string.preencode(d,o.displayName),o.avatar&&Es.preencode(d,o.avatar),o.username&&e.string.preencode(d,o.username)},encode(d,o){const n=(o.mailbox?1:0)|(o.displayName?2:0)|(o.avatar?4:0)|(o.username?8:0);e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.mailbox&&e.fixed32.encode(d,o.mailbox),o.displayName&&e.string.encode(d,o.displayName),o.avatar&&Es.encode(d,o.avatar),o.username&&e.string.encode(d,o.username)},decode(d){const o=e.uint.decode(d),n=e.uint.decode(d);return{timestamp:o,mailbox:1&n?e.fixed32.decode(d):null,displayName:2&n?e.string.decode(d):null,avatar:4&n?Es.decode(d):null,username:8&n?e.string.decode(d):null}}},se={preencode(o,n){o.end++,n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),n.name&&e.string.preencode(o,n.name),d>=29&&n.buildType&&xi.preencode(o,n.buildType)},encode(o,n){const c=(n.swarmKey?1:0)|(n.name?2:0)|(n.isMobile?4:0)|(d>=29&&n.buildType?8:0);e.uint.encode(o,c),n.swarmKey&&e.fixed32.encode(o,n.swarmKey),n.name&&e.string.encode(o,n.name),d>=29&&n.buildType&&xi.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{swarmKey:1&n?e.fixed32.decode(o):null,name:2&n?e.string.decode(o):null,isMobile:!!(4&n),buildType:d>=29&&8&n?xi.decode(o):null}}},le=e.frame(ae),pe={preencode(e,d){le.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){le.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:le.decode(e),attestation:ne.decode(e)})},ue={preencode(e,d){zs.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){zs.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:zs.decode(e),attestation:ne.decode(e)})},fe={preencode(d,o){e.fixed32.preencode(d,o.id),e.buffer.preencode(d,o.data),e.buffer.preencode(d,o.signature)},encode(d,o){e.fixed32.encode(d,o.id),e.buffer.encode(d,o.data),e.buffer.encode(d,o.signature)},decode:d=>({id:e.fixed32.decode(d),data:e.buffer.decode(d),signature:e.buffer.decode(d)})},me={preencode(d,o){e.fixed32.preencode(d,o.devicePublicKey)},encode(d,o){e.fixed32.encode(d,o.devicePublicKey)},decode:d=>({devicePublicKey:e.fixed32.decode(d)})},ye={preencode(d,o){ne.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){ne.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({privateProfileIdentity:ne.decode(d),deviceProof:e.buffer.decode(d)})},be=e.frame(ue),xe=e.frame(pe),ve=e.frame(me),ge={preencode(n,c){e.fixed32.preencode(n,c.deviceKey),r.preencode(n,c.keyPair),be.preencode(n,c.device),xe.preencode(n,c.member),n.end++,c.identity&&ve.preencode(n,c.identity),d>=37&&c.link&&o.preencode(n,c.link)},encode(n,c){const t=(c.identity?1:0)|(d>=37&&c.link?2:0);e.fixed32.encode(n,c.deviceKey),r.encode(n,c.keyPair),be.encode(n,c.device),xe.encode(n,c.member),e.uint.encode(n,t),c.identity&&ve.encode(n,c.identity),d>=37&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),t=r.decode(n),i=be.decode(n),a=xe.decode(n),s=e.uint.decode(n);return{deviceKey:c,keyPair:t,device:i,member:a,identity:1&s?ve.decode(n):null,link:d>=37&&2&s?o.decode(n):null}}},ke=e.frame(ge),Ke={preencode(d,o){e.fixed32.preencode(d,o.id),ke.preencode(d,o.request),e.buffer.preencode(d,o.signature)},encode(d,o){e.fixed32.encode(d,o.id),ke.encode(d,o.request),e.buffer.encode(d,o.signature)},decode:d=>({id:e.fixed32.decode(d),request:ke.decode(d),signature:e.buffer.decode(d)})},he=be,we=xe,Re={preencode(e,d){he.preencode(e,d.device),e.end++,d.member&&we.preencode(e,d.member)},encode(d,o){const n=o.member?1:0;he.encode(d,o.device),e.uint.encode(d,n),o.member&&we.encode(d,o.member)},decode:d=>({device:he.decode(d),member:1&e.uint.decode(d)?we.decode(d):null})},Pe=e.frame(Ke),Te=e.frame(Re),Ae={preencode(e,d){e.end++,d.withInvitation&&Pe.preencode(e,d.withInvitation),d.withMemberProof&&Te.preencode(e,d.withMemberProof)},encode(d,o){const n=(o.withInvitation?1:0)|(o.withMemberProof?2:0);e.uint.encode(d,n),o.withInvitation&&Pe.encode(d,o.withInvitation),o.withMemberProof&&Te.encode(d,o.withMemberProof)},decode(d){const o=e.uint.decode(d);return{withInvitation:1&o?Pe.decode(d):null,withMemberProof:2&o?Te.decode(d):null}}},Me=e.frame(fe),Se=e.frame(ye),Ie={preencode(e,d){Me.preencode(e,d.signedKeys),e.end++,d.identity&&Se.preencode(e,d.identity)},encode(d,o){const n=o.identity?1:0;Me.encode(d,o.signedKeys),e.uint.encode(d,n),o.identity&&Se.encode(d,o.identity)},decode:d=>({signedKeys:Me.decode(d),identity:1&e.uint.decode(d)?Se.decode(d):null})},Ce={preencode(o,n){o.end++,n.expiration&&e.uint.preencode(o,n.expiration),d>=29&&n.buildType&&xi.preencode(o,n.buildType)},encode(o,n){const c=(n.expiration?1:0)|(n.requiresConfirmation?2:0)|(n.canModerate?4:0)|(n.canAdmin?8:0)|(d>=29&&n.buildType?16:0);e.uint.encode(o,c),n.expiration&&e.uint.encode(o,n.expiration),d>=29&&n.buildType&&xi.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{expiration:1&n?e.uint.decode(o):0,requiresConfirmation:!!(2&n),canModerate:!!(4&n),canAdmin:!!(8&n),buildType:d>=29&&16&n?xi.decode(o):null}}},Ve=Me,He=e.frame(Ce),Fe={preencode(d,n){e.fixed32.preencode(d,n.id),Ve.preencode(d,n.response),He.preencode(d,n.metadata),d.end++,n.anchor&&o.preencode(d,n.anchor)},encode(d,n){const c=(n.anchor?1:0)|(n.isActive?2:0);e.fixed32.encode(d,n.id),Ve.encode(d,n.response),He.encode(d,n.metadata),e.uint.encode(d,c),n.anchor&&o.encode(d,n.anchor)},decode(d){const n=e.fixed32.decode(d),c=Ve.decode(d),r=He.decode(d),t=e.uint.decode(d);return{id:n,response:c,metadata:r,anchor:1&t?o.decode(d):null,isActive:!!(2&t)}}},De=$,Le=e.frame(Fe),je={preencode(e,d){De.preencode(e,d.header),Le.preencode(e,d.invitation)},encode(e,d){De.encode(e,d.header),Le.encode(e,d.invitation)},decode:e=>({header:De.decode(e),invitation:Le.decode(e)})},qe=$,Be={preencode(d,o){qe.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){qe.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:qe.decode(d),id:e.fixed32.decode(d)})},Ee={preencode(d,n){e.fixed32.preencode(d,n.mailbox),e.fixed32.preencode(d,n.invitationSeed),o.preencode(d,n.anchor)},encode(d,n){e.fixed32.encode(d,n.mailbox),e.fixed32.encode(d,n.invitationSeed),o.encode(d,n.anchor)},decode:d=>({mailbox:e.fixed32.decode(d),invitationSeed:e.fixed32.decode(d),anchor:o.decode(d)})},ze={preencode(d,n){e.fixed32.preencode(d,n.mailbox),e.fixed32.preencode(d,n.invitationSeed),o.preencode(d,n.anchor),e.fixed32.preencode(d,n.identityPublicKey)},encode(d,n){e.fixed32.encode(d,n.mailbox),e.fixed32.encode(d,n.invitationSeed),o.encode(d,n.anchor),e.fixed32.encode(d,n.identityPublicKey)},decode:d=>({mailbox:e.fixed32.decode(d),invitationSeed:e.fixed32.decode(d),anchor:o.decode(d),identityPublicKey:e.fixed32.decode(d)})},Oe={preencode(d,o){e.fixed32.preencode(d,o.mailbox)},encode(d,o){e.fixed32.encode(d,o.mailbox)},decode:d=>({mailbox:e.fixed32.decode(d)})},Ne=e.frame(Ee),Ue=e.frame(ze),Je=e.frame(Oe),We=e.array(e.ipv4Address),Ge={preencode(e,o){e.end++,o.room&&Ne.preencode(e,o.room),o.identity&&Ue.preencode(e,o.identity),o.contact&&Je.preencode(e,o.contact),d>=9&&o.readonly&&Os.preencode(e,o.readonly),d>=17&&o.additionalNodes&&We.preencode(e,o.additionalNodes),d>=29&&o.buildType&&xi.preencode(e,o.buildType),d>=37&&o["readonly-v2"]&&Ns.preencode(e,o["readonly-v2"])},encode(o,n){const c=(n.room?1:0)|(n.identity?2:0)|(n.contact?4:0)|(d>=9&&n.readonly?8:0)|(d>=17&&n.additionalNodes?16:0)|(d>=29&&n.buildType?32:0)|(d>=37&&n["readonly-v2"]?64:0);e.uint.encode(o,c),n.room&&Ne.encode(o,n.room),n.identity&&Ue.encode(o,n.identity),n.contact&&Je.encode(o,n.contact),d>=9&&n.readonly&&Os.encode(o,n.readonly),d>=17&&n.additionalNodes&&We.encode(o,n.additionalNodes),d>=29&&n.buildType&&xi.encode(o,n.buildType),d>=37&&n["readonly-v2"]&&Ns.encode(o,n["readonly-v2"])},decode(o){const n=e.uint.decode(o);return{room:1&n?Ne.decode(o):null,identity:2&n?Ue.decode(o):null,contact:4&n?Je.decode(o):null,readonly:d>=9&&8&n?Os.decode(o):null,additionalNodes:d>=17&&16&n?We.decode(o):null,buildType:d>=29&&32&n?xi.decode(o):null,"readonly-v2":d>=37&&64&n?Ns.decode(o):null}}},Qe=$,Xe={preencode(d,o){Qe.preencode(d,o.header),e.buffer.preencode(d,o.blindRequest)},encode(d,o){Qe.encode(d,o.header),e.buffer.encode(d,o.blindRequest)},decode:d=>({header:Qe.decode(d),blindRequest:e.buffer.decode(d)})},Ye=$,Ze={preencode(o,n){Ye.preencode(o,n.header),o.end++,n.profile&&Us.preencode(o,n.profile),d>=34&&n.key&&e.fixed32.preencode(o,n.key)},encode(o,n){const c=(n.profile?1:0)|(d>=34&&n.key?2:0);Ye.encode(o,n.header),e.uint.encode(o,c),n.profile&&Us.encode(o,n.profile),d>=34&&n.key&&e.fixed32.encode(o,n.key)},decode(o){const n=Ye.decode(o),c=e.uint.decode(o);return{header:n,profile:1&c?Us.decode(o):null,key:d>=34&&2&c?e.fixed32.decode(o):null}}},$e={preencode(e,d){},encode(e,d){},decode:e=>({})},_e=$e,ed=ke,dd={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.id),ed.preencode(d,o.request)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.id),ed.encode(d,o.request)},decode:d=>({deviceKey:e.fixed32.decode(d),id:e.fixed32.decode(d),request:ed.decode(d)})},od=$,nd=Se,cd={preencode(d,o){od.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),d.end++,o.identity&&nd.preencode(d,o.identity)},encode(d,o){const n=o.identity?1:0;od.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,n),o.identity&&nd.encode(d,o.identity)},decode:d=>({header:od.decode(d),deviceKey:e.fixed32.decode(d),identity:1&e.uint.decode(d)?nd.decode(d):null})},rd=$,td={preencode(d,o){rd.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey)},encode(d,o){rd.encode(d,o.header),e.fixed32.encode(d,o.deviceKey)},decode:d=>({header:rd.decode(d),deviceKey:e.fixed32.decode(d)})},id=e.frame(S),ad=le,sd={preencode(d,o){e.fixed32.preencode(d,o.key),id.preencode(d,o.status),ad.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),id.encode(d,o.status),ad.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),status:id.decode(d),profile:ad.decode(d)})},ld=id,pd=le,ud={preencode(d,o){e.fixed32.preencode(d,o.key),ld.preencode(d,o.status),pd.preencode(d,o.profile),d.end++,o.proofs&&Js.preencode(d,o.proofs)},encode(d,o){const n=o.proofs?1:0;e.fixed32.encode(d,o.key),ld.encode(d,o.status),pd.encode(d,o.profile),e.uint.encode(d,n),o.proofs&&Js.encode(d,o.proofs)},decode:d=>({key:e.fixed32.decode(d),status:ld.decode(d),profile:pd.decode(d),proofs:1&e.uint.decode(d)?Js.decode(d):null})},fd={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++,o.profileAttestation&&e.buffer.preencode(d,o.profileAttestation),o.latestReceipt&&e.buffer.preencode(d,o.latestReceipt)},encode(d,o){const n=(o.profileAttestation?1:0)|(o.latestReceipt?2:0);e.fixed32.encode(d,o.key),e.uint.encode(d,n),o.profileAttestation&&e.buffer.encode(d,o.profileAttestation),o.latestReceipt&&e.buffer.encode(d,o.latestReceipt)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d);return{key:o,profileAttestation:1&n?e.buffer.decode(d):null,latestReceipt:2&n?e.buffer.decode(d):null}}},md=$,yd=xe,bd={preencode(e,d){md.preencode(e,d.header),yd.preencode(e,d.member)},encode(e,d){md.encode(e,d.header),yd.encode(e,d.member)},decode:e=>({header:md.decode(e),member:yd.decode(e)})},xd=$,vd=e.frame(I),gd={preencode(d,o){xd.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),vd.preencode(d,o.status)},encode(d,o){xd.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),vd.encode(d,o.status)},decode:d=>({header:xd.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:vd.decode(d)})},kd=$,Kd={preencode(d,o){kd.preencode(d,o.header),e.fixed32.preencode(d,o.key),d.end++},encode(d,o){const n=(o.isModerator?1:0)|(o.isAdmin?2:0);kd.encode(d,o.header),e.fixed32.encode(d,o.key),e.uint.encode(d,n)},decode(d){const o=kd.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{header:o,key:n,isModerator:!!(1&c),isAdmin:!!(2&c)}}},hd=$,wd={preencode(d,o){hd.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){hd.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:hd.decode(d),key:e.fixed32.decode(d)})},Rd={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.mentions)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.mentions)},decode:d=>({key:e.fixed32.decode(d),mentions:e.uint.decode(d)})},Pd={preencode(d,o){d.end++,o.memberKey&&e.fixed32.preencode(d,o.memberKey)},encode(d,o){const n=o.memberKey?1:0;e.uint.encode(d,n),o.memberKey&&e.fixed32.encode(d,o.memberKey)},decode:d=>({memberKey:1&e.uint.decode(d)?e.fixed32.decode(d):null})},Td=Pd,Ad={preencode(d,o){d.end++,o.from&&e.string.preencode(d,o.from),o.to&&e.string.preencode(d,o.to)},encode(d,o){const n=(o.from?1:0)|(o.to?2:0);e.uint.encode(d,n),o.from&&e.string.encode(d,o.from),o.to&&e.string.encode(d,o.to)},decode(d){const o=e.uint.decode(d);return{from:1&o?e.string.decode(d):null,to:2&o?e.string.decode(d):null}}},Md=e.frame(Pd),Sd=e.frame(Td),Id=e.frame(Ad),Cd={preencode(o,n){const c=(n.memberJoined?1:0)|(n.memberLeft?2:0)|(n.titleChanged?4:0)|(n.callStarted?8:0)|(n.callHangup?16:0)|(n.callMissed?32:0)|(d>=4&&n.roomAvatarChanged?64:0)|(d>=4&&n.invitationCreated?128:0)|(d>=4&&n.memberRemoved?256:0)|(d>=27&&n.locationShared?512:0);e.uint.preencode(o,c),n.memberJoined&&Md.preencode(o,n.memberJoined),n.memberLeft&&Sd.preencode(o,n.memberLeft),n.titleChanged&&Id.preencode(o,n.titleChanged),d>=4&&n.memberRemoved&&Ws.preencode(o,n.memberRemoved),d>=27&&n.locationShared&&Gs.preencode(o,n.locationShared)},encode(o,n){const c=(n.memberJoined?1:0)|(n.memberLeft?2:0)|(n.titleChanged?4:0)|(n.callStarted?8:0)|(n.callHangup?16:0)|(n.callMissed?32:0)|(d>=4&&n.roomAvatarChanged?64:0)|(d>=4&&n.invitationCreated?128:0)|(d>=4&&n.memberRemoved?256:0)|(d>=27&&n.locationShared?512:0);e.uint.encode(o,c),n.memberJoined&&Md.encode(o,n.memberJoined),n.memberLeft&&Sd.encode(o,n.memberLeft),n.titleChanged&&Id.encode(o,n.titleChanged),d>=4&&n.memberRemoved&&Ws.encode(o,n.memberRemoved),d>=27&&n.locationShared&&Gs.encode(o,n.locationShared)},decode(o){const n=e.uint.decode(o);return{memberJoined:1&n?Md.decode(o):null,memberLeft:2&n?Sd.decode(o):null,titleChanged:4&n?Id.decode(o):null,callStarted:!!(8&n),callHangup:!!(16&n),callMissed:!!(32&n),roomAvatarChanged:d>=4&&!!(64&n),invitationCreated:d>=4&&!!(128&n),memberRemoved:d>=4&&256&n?Ws.decode(o):null,locationShared:d>=27&&512&n?Gs.decode(o):null}}},Vd={preencode(e,o){e.end++,d>=27&&o.locationShared&&Qs.preencode(e,o.locationShared)},encode(o,n){const c=(n.callStarted?1:0)|(n.callHangup?2:0)|(n.callMissed?4:0)|(d>=27&&n.locationShared?8:0);e.uint.encode(o,c),d>=27&&n.locationShared&&Qs.encode(o,n.locationShared)},decode(o){const n=e.uint.decode(o);return{callStarted:!!(1&n),callHangup:!!(2&n),callMissed:!!(4&n),locationShared:d>=27&&8&n?Qs.decode(o):null}}},Hd={preencode(d,o){e.uint.preencode(d,o.start),e.uint.preencode(d,o.length)},encode(d,o){e.uint.encode(d,o.start),e.uint.encode(d,o.length)},decode:d=>({start:e.uint.decode(d),length:e.uint.decode(d)})},Fd=e.frame(Hd),Dd={preencode(d,o){Fd.preencode(d,o.range),e.string.preencode(d,o.content)},encode(d,o){Fd.encode(d,o.range),e.string.encode(d,o.content)},decode:d=>({range:Fd.decode(d),content:e.string.decode(d)})},Ld=Fd,jd={preencode(d,o){Ld.preencode(d,o.range),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Ld.encode(d,o.range),e.fixed32.encode(d,o.memberKey)},decode:d=>({range:Ld.decode(d),memberKey:e.fixed32.decode(d)})},qd=k,Bd=e.array(e.uint),Ed={preencode(o,n){o.end++,n.title&&e.string.preencode(o,n.title),n.description&&e.string.preencode(o,n.description),n.file&&qd.preencode(o,n.file),d>=12&&n.files&&Bd.preencode(o,n.files)},encode(o,n){const c=(n.title?1:0)|(n.description?2:0)|(n.file?4:0)|(d>=12&&n.files?8:0);e.uint.encode(o,c),n.title&&e.string.encode(o,n.title),n.description&&e.string.encode(o,n.description),n.file&&qd.encode(o,n.file),d>=12&&n.files&&Bd.encode(o,n.files)},decode(o){const n=e.uint.decode(o);return{title:1&n?e.string.decode(o):null,description:2&n?e.string.decode(o):null,file:4&n?qd.decode(o):null,files:d>=12&&8&n?Bd.decode(o):null}}},zd=Fd,Od=e.frame(Ed),Nd={preencode(d,o){zd.preencode(d,o.range),e.string.preencode(d,o.url),d.end++,o.preview&&Od.preencode(d,o.preview)},encode(d,o){const n=o.preview?1:0;zd.encode(d,o.range),e.string.encode(d,o.url),e.uint.encode(d,n),o.preview&&Od.encode(d,o.preview)},decode:d=>({range:zd.decode(d),url:e.string.decode(d),preview:1&e.uint.decode(d)?Od.decode(d):null})},Ud=e.array(e.frame(jd)),Jd=e.array(e.frame(Nd)),Wd=Jd,Gd=e.array(e.frame(Hd)),Qd=Gd,Xd=Gd,Yd=e.array(e.frame(Dd)),Zd=Gd,$d=Gd,_d={preencode(o,n){const c=(n.mention?1:0)|(n.httpLink?2:0)|(n.pearLink?4:0)|(n.bold?8:0)|(n.italic?16:0)|(n.code?32:0)|(n.emoji?64:0)|(n.codeBlock?128:0)|(n.strike?256:0)|(d>=17&&n.translation?512:0);e.uint.preencode(o,c),n.mention&&Ud.preencode(o,n.mention),n.httpLink&&Jd.preencode(o,n.httpLink),n.pearLink&&Wd.preencode(o,n.pearLink),n.bold&&Gd.preencode(o,n.bold),n.italic&&Qd.preencode(o,n.italic),n.code&&Xd.preencode(o,n.code),n.emoji&&Yd.preencode(o,n.emoji),n.codeBlock&&Zd.preencode(o,n.codeBlock),n.strike&&$d.preencode(o,n.strike),d>=17&&n.translation&&Xs.preencode(o,n.translation)},encode(o,n){const c=(n.mention?1:0)|(n.httpLink?2:0)|(n.pearLink?4:0)|(n.bold?8:0)|(n.italic?16:0)|(n.code?32:0)|(n.emoji?64:0)|(n.codeBlock?128:0)|(n.strike?256:0)|(d>=17&&n.translation?512:0);e.uint.encode(o,c),n.mention&&Ud.encode(o,n.mention),n.httpLink&&Jd.encode(o,n.httpLink),n.pearLink&&Wd.encode(o,n.pearLink),n.bold&&Gd.encode(o,n.bold),n.italic&&Qd.encode(o,n.italic),n.code&&Xd.encode(o,n.code),n.emoji&&Yd.encode(o,n.emoji),n.codeBlock&&Zd.encode(o,n.codeBlock),n.strike&&$d.encode(o,n.strike),d>=17&&n.translation&&Xs.encode(o,n.translation)},decode(o){const n=e.uint.decode(o);return{mention:1&n?Ud.decode(o):null,httpLink:2&n?Jd.decode(o):null,pearLink:4&n?Wd.decode(o):null,bold:8&n?Gd.decode(o):null,italic:16&n?Qd.decode(o):null,code:32&n?Xd.decode(o):null,emoji:64&n?Yd.decode(o):null,codeBlock:128&n?Zd.decode(o):null,strike:256&n?$d.decode(o):null,translation:d>=17&&512&n?Xs.decode(o):null}}},eo=e.array(e.frame(g)),oo=e.frame(_d),no=e.frame(Vd),co={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&eo.preencode(d,o.files),o.display&&oo.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent),o.event&&no.preencode(d,o.event)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(c.event?32:0)|(d>=27&&c.forwarded?64:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&eo.encode(o,c.files),c.display&&oo.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent),c.event&&no.encode(o,c.event)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?eo.decode(o):null,display:4&c?oo.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,event:32&c?no.decode(o):null,forwarded:d>=27&&!!(64&c)}}},ro=Bd,to=oo,io={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&ro.preencode(d,o.files),o.display&&to.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(d>=27&&c.forwarded?32:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&ro.encode(o,c.files),c.display&&to.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?ro.decode(o):null,display:4&c?to.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,forwarded:d>=27&&!!(32&c)}}},ao=eo,so=oo,lo={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&ao.preencode(d,o.files),o.display&&so.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(d>=27&&c.forwarded?32:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&ao.encode(o,c.files),c.display&&so.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?ao.decode(o):null,display:4&c?so.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,forwarded:d>=27&&!!(32&c)}}},po={preencode(e,d){e.end++},encode(d,o){const n=(o.isEdited?1:0)|(o.isDeleted?2:0)|(o.isPinned?4:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isEdited:!!(1&o),isDeleted:!!(2&o),isPinned:!!(4&o)}}},uo={preencode(d,o){e.uint.preencode(d,o.thread),e.uint.preencode(d,o.index)},encode(d,o){e.uint.encode(d,o.thread),e.uint.encode(d,o.index)},decode:d=>({thread:e.uint.decode(d),index:e.uint.decode(d)})},fo=e.frame(E),mo={preencode(d,o){e.uint.preencode(d,o.id),e.uint.preencode(d,o.count),d.end++,o.parent&&n.preencode(d,o.parent),o.stats&&fo.preencode(d,o.stats)},encode(d,o){const c=(o.parent?1:0)|(o.stats?2:0);e.uint.encode(d,o.id),e.uint.encode(d,o.count),e.uint.encode(d,c),o.parent&&n.encode(d,o.parent),o.stats&&fo.encode(d,o.stats)},decode(d){const o=e.uint.decode(d),c=e.uint.decode(d),r=e.uint.decode(d);return{id:o,count:c,parent:1&r?n.decode(d):null,stats:2&r?fo.decode(d):null}}},yo=e.frame(po),bo=e.frame(io),xo=e.frame(Cd),vo={preencode(d,o){uo.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),yo.preencode(d,o.status),o.message&&bo.preencode(d,o.message),o.event&&xo.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);uo.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),yo.encode(d,o.status),o.message&&bo.encode(d,o.message),o.event&&xo.encode(d,o.event)},decode(d){const o=uo.decode(d),c=n.decode(d),r=e.uint.decode(d),t=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:r,timestamp:t,editedAt:1&i?e.uint.decode(d):0,status:yo.decode(d),message:2&i?bo.decode(d):null,event:4&i?xo.decode(d):null}}},go=yo,ko=e.frame(lo),Ko=xo,ho={preencode(d,o){uo.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),go.preencode(d,o.status),o.message&&ko.preencode(d,o.message),o.event&&Ko.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);uo.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),go.encode(d,o.status),o.message&&ko.encode(d,o.message),o.event&&Ko.encode(d,o.event)},decode(d){const o=uo.decode(d),c=n.decode(d),r=e.uint.decode(d),t=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:r,timestamp:t,editedAt:1&i?e.uint.decode(d):0,status:go.decode(d),message:2&i?ko.decode(d):null,event:4&i?Ko.decode(d):null}}},wo=$,Ro=e.frame(co),Po={preencode(e,d){wo.preencode(e,d.header),Ro.preencode(e,d.message)},encode(e,d){wo.encode(e,d.header),Ro.encode(e,d.message)},decode:e=>({header:wo.decode(e),message:Ro.decode(e)})},To=$,Ao={preencode(e,d){To.preencode(e,d.header),n.preencode(e,d.oplog)},encode(e,d){To.encode(e,d.header),n.encode(e,d.oplog)},decode:e=>({header:To.decode(e),oplog:n.decode(e)})},Mo=$,So=Ro,Io={preencode(e,d){Mo.preencode(e,d.header),n.preencode(e,d.oplog),So.preencode(e,d.message)},encode(e,d){Mo.encode(e,d.header),n.encode(e,d.oplog),So.encode(e,d.message)},decode:e=>({header:Mo.decode(e),oplog:n.decode(e),message:So.decode(e)})},Co=$,Vo={preencode(e,d){Co.preencode(e,d.header),n.preencode(e,d.oplog),e.end++},encode(d,o){const c=o.isPinned?1:0;Co.encode(d,o.header),n.encode(d,o.oplog),e.uint.encode(d,c)},decode:d=>({header:Co.decode(d),oplog:n.decode(d),isPinned:!!(1&e.uint.decode(d))})},Ho={preencode(d,o){uo.preencode(d,o.id),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),e.string.preencode(d,o.reaction)},encode(d,o){uo.encode(d,o.id),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),e.string.encode(d,o.reaction)},decode:d=>({id:uo.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),reaction:e.string.decode(d)})},Fo={preencode(d,o){e.string.preencode(d,o.text),e.uint.preencode(d,o.count)},encode(d,o){e.string.encode(d,o.text),e.uint.encode(d,o.count)},decode:d=>({text:e.string.decode(d),count:e.uint.decode(d)})},Do=e.array(e.frame(Fo)),Lo={preencode(o,n){uo.preencode(o,n.id),e.uint.preencode(o,n.total),Do.preencode(o,n.reactions),o.end++,d>=17&&n.editedAt&&e.uint.preencode(o,n.editedAt)},encode(o,n){const c=d>=17&&n.editedAt?1:0;uo.encode(o,n.id),e.uint.encode(o,n.total),Do.encode(o,n.reactions),e.uint.encode(o,c),d>=17&&n.editedAt&&e.uint.encode(o,n.editedAt)},decode(o){const n=uo.decode(o),c=e.uint.decode(o),r=Do.decode(o),t=o.start<o.end?e.uint.decode(o):0;return{id:n,total:c,reactions:r,editedAt:d>=17&&1&t?e.uint.decode(o):0}}},jo=$,qo={preencode(d,o){jo.preencode(d,o.header),n.preencode(d,o.oplog),e.string.preencode(d,o.reaction)},encode(d,o){jo.encode(d,o.header),n.encode(d,o.oplog),e.string.encode(d,o.reaction)},decode:d=>({header:jo.decode(d),oplog:n.decode(d),reaction:e.string.decode(d)})},Bo=$,Eo={preencode(d,o){Bo.preencode(d,o.header),n.preencode(d,o.oplog),e.string.preencode(d,o.reaction)},encode(d,o){Bo.encode(d,o.header),n.encode(d,o.oplog),e.string.encode(d,o.reaction)},decode:d=>({header:Bo.decode(d),oplog:n.decode(d),reaction:e.string.decode(d)})},zo=$,Oo=e.frame(Y),No={preencode(d,o){zo.preencode(d,o.header),e.uint.preencode(d,o.key),Oo.preencode(d,o.config)},encode(d,o){zo.encode(d,o.header),e.uint.encode(d,o.key),Oo.encode(d,o.config)},decode:d=>({header:zo.decode(d),key:e.uint.decode(d),config:Oo.decode(d)})},Uo={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.string.preencode(d,o.displayName),d.end++,o.avatar&&Ys.preencode(d,o.avatar)},encode(d,o){const n=o.avatar?1:0;e.fixed32.encode(d,o.memberKey),e.string.encode(d,o.displayName),e.uint.encode(d,n),o.avatar&&Ys.encode(d,o.avatar)},decode:d=>({memberKey:e.fixed32.decode(d),displayName:e.string.decode(d),avatar:1&e.uint.decode(d)?Ys.decode(d):null})},Jo={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++,o.username&&e.string.preencode(d,o.username)},encode(d,o){const n=o.username?1:0;e.fixed32.encode(d,o.key),e.uint.encode(d,n),o.username&&e.string.encode(d,o.username)},decode:d=>({key:e.fixed32.decode(d),username:1&e.uint.decode(d)?e.string.decode(d):null})},Wo=e.frame(Jo),Go={preencode(d,o){e.fixed32.preencode(d,o.publicKey),d.end++,o.discoveryCoreKey&&e.fixed32.preencode(d,o.discoveryCoreKey),o.userRegistry&&Wo.preencode(d,o.userRegistry)},encode(d,o){const n=(o.discoveryCoreKey?1:0)|(o.userRegistry?2:0);e.fixed32.encode(d,o.publicKey),e.uint.encode(d,n),o.discoveryCoreKey&&e.fixed32.encode(d,o.discoveryCoreKey),o.userRegistry&&Wo.encode(d,o.userRegistry)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d);return{publicKey:o,discoveryCoreKey:1&n?e.fixed32.decode(d):null,userRegistry:2&n?Wo.decode(d):null}}},Qo=$,Xo=e.frame(W),Yo=e.frame(G),Zo=Oo,$o=e.frame(Go),_o=be,en=e.array(e.frame(pe)),dn={preencode(e,d){Qo.preencode(e,d.header),Xo.preencode(e,d.digest),Yo.preencode(e,d.capabilities),e.end++,d.config&&Zo.preencode(e,d.config),d.identity&&$o.preencode(e,d.identity),d.bootstrapDevice&&_o.preencode(e,d.bootstrapDevice),d.initialMembers&&en.preencode(e,d.initialMembers)},encode(d,o){const n=(o.config?1:0)|(o.identity?2:0)|(o.bootstrapDevice?4:0)|(o.initialMembers?8:0);Qo.encode(d,o.header),Xo.encode(d,o.digest),Yo.encode(d,o.capabilities),e.uint.encode(d,n),o.config&&Zo.encode(d,o.config),o.identity&&$o.encode(d,o.identity),o.bootstrapDevice&&_o.encode(d,o.bootstrapDevice),o.initialMembers&&en.encode(d,o.initialMembers)},decode(d){const o=Qo.decode(d),n=Xo.decode(d),c=Yo.decode(d),r=e.uint.decode(d);return{header:o,digest:n,capabilities:c,config:1&r?Zo.decode(d):null,identity:2&r?$o.decode(d):null,bootstrapDevice:4&r?_o.decode(d):null,initialMembers:8&r?en.decode(d):null}}},on=$,nn={preencode(d,o){on.preencode(d,o.header),e.uint.preencode(d,o.version)},encode(d,o){on.encode(d,o.header),e.uint.encode(d,o.version)},decode:d=>({header:on.decode(d),version:e.uint.decode(d)})},cn=$,rn=J,tn={preencode(d,o){cn.preencode(d,o.header),e.uint.preencode(d,o.key),rn.preencode(d,o.settings)},encode(d,o){cn.encode(d,o.header),e.uint.encode(d,o.key),rn.encode(d,o.settings)},decode:d=>({header:cn.decode(d),key:e.uint.decode(d),settings:rn.decode(d)})},an={preencode(o,n){e.fixed32.preencode(o,n.memberKey),Zs.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=32&&n.contactInfo&&$s.preencode(o,n.contactInfo),d>=32&&n.version&&e.uint.preencode(o,n.version),d>=34&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=32&&n.contactInfo?4:0)|(d>=32&&n.version?8:0)|(d>=34&&n.alias?16:0);e.fixed32.encode(o,n.memberKey),Zs.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=32&&n.contactInfo&&$s.encode(o,n.contactInfo),d>=32&&n.version&&e.uint.encode(o,n.version),d>=34&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.fixed32.decode(o),c=Zs.decode(o),r=e.uint.decode(o);return{memberKey:n,status:c,mailbox:1&r?e.fixed32.decode(o):null,roomKey:2&r?e.fixed32.decode(o):null,contactInfo:d>=32&&4&r?$s.decode(o):null,version:d>=32&&8&r?e.uint.decode(o):0,alias:d>=34&&16&r?e.string.decode(o):null}}},sn={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.seed),o.preencode(d,n.initiator),e.fixed32.preencode(d,n.fastForwardTo)},encode(d,n){e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.fixed32.encode(d,n.seed),o.encode(d,n.initiator),e.fixed32.encode(d,n.fastForwardTo)},decode:d=>({roomKey:e.fixed32.decode(d),encryptionKey:e.buffer.decode(d),seed:e.fixed32.decode(d),initiator:o.decode(d),fastForwardTo:e.fixed32.decode(d)})},ln=e.array(e.frame(sn)),pn=X,un={preencode(e,d){ln.preencode(e,d.sharedRooms),pn.preencode(e,d.blockedContacts)},encode(e,d){ln.encode(e,d.sharedRooms),pn.encode(e,d.blockedContacts)},decode:e=>({sharedRooms:ln.decode(e),blockedContacts:pn.decode(e)})},fn=$o,mn={preencode(e,d){fn.preencode(e,d.identity)},encode(e,d){fn.encode(e,d.identity)},decode:e=>({identity:fn.decode(e)})},yn={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.contacts)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.contacts)},decode:d=>({rooms:e.uint.decode(d),contacts:e.uint.decode(d)})},bn={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.contactRequests)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.contactRequests)},decode:d=>({rooms:e.uint.decode(d),contactRequests:e.uint.decode(d)})},xn={preencode(d,o){e.buffer.preencode(d,o.entropy)},encode(d,o){e.buffer.encode(d,o.entropy)},decode:d=>({entropy:e.buffer.decode(d)})},vn={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.devicePublicKey),e.fixed32.preencode(d,o.writerKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.devicePublicKey),e.fixed32.encode(d,o.writerKey)},decode:d=>({publicKey:e.fixed32.decode(d),devicePublicKey:e.fixed32.decode(d),writerKey:e.fixed32.decode(d)})},gn=e.frame(vn),kn={preencode(n,c){e.fixed32.preencode(n,c.id),e.fixed32.preencode(n,c.invitationSeed),e.fixed32.preencode(n,c.mailbox),r.preencode(n,c.responseKeyPair),o.preencode(n,c.initiator),o.preencode(n,c.inviter),n.end++,c.identity&&gn.preencode(n,c.identity),d>=29&&c.buildType&&xi.preencode(n,c.buildType),d>=37&&c.link&&o.preencode(n,c.link)},encode(n,c){const t=(c.identity?1:0)|(d>=29&&c.buildType?2:0)|(d>=37&&c.link?4:0);e.fixed32.encode(n,c.id),e.fixed32.encode(n,c.invitationSeed),e.fixed32.encode(n,c.mailbox),r.encode(n,c.responseKeyPair),o.encode(n,c.initiator),o.encode(n,c.inviter),e.uint.encode(n,t),c.identity&&gn.encode(n,c.identity),d>=29&&c.buildType&&xi.encode(n,c.buildType),d>=37&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),t=e.fixed32.decode(n),i=e.fixed32.decode(n),a=r.decode(n),s=o.decode(n),l=o.decode(n),p=e.uint.decode(n);return{id:c,invitationSeed:t,mailbox:i,responseKeyPair:a,initiator:s,inviter:l,identity:1&p?gn.decode(n):null,buildType:d>=29&&2&p?xi.decode(n):null,link:d>=37&&4&p?o.decode(n):null}}},Kn=$,hn={preencode(d,o){Kn.preencode(d,o.header),e.buffer.preencode(d,o.blindResponse)},encode(d,o){Kn.encode(d,o.header),e.buffer.encode(d,o.blindResponse)},decode:d=>({header:Kn.decode(d),blindResponse:e.buffer.decode(d)})},wn=$,Rn=e.frame(kn),Pn={preencode(e,d){wn.preencode(e,d.header),Rn.preencode(e,d.invitation)},encode(e,d){wn.encode(e,d.header),Rn.encode(e,d.invitation)},decode:e=>({header:wn.decode(e),invitation:Rn.decode(e)})},Tn=$,An={preencode(d,o){Tn.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){Tn.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:Tn.decode(d),id:e.fixed32.decode(d)})},Mn={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.devicePublicKey),d.end++,o.privateProfileKey&&e.fixed32.preencode(d,o.privateProfileKey),o.deviceKeyPair&&r.preencode(d,o.deviceKeyPair),e.buffer.preencode(d,o.deviceProof)},encode(d,o){const n=(o.privateProfileKey?1:0)|(o.deviceKeyPair?2:0);e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.devicePublicKey),e.uint.encode(d,n),o.privateProfileKey&&e.fixed32.encode(d,o.privateProfileKey),o.deviceKeyPair&&r.encode(d,o.deviceKeyPair),e.buffer.encode(d,o.deviceProof)},decode(d){const o=e.fixed32.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{publicKey:o,devicePublicKey:n,privateProfileKey:1&c?e.fixed32.decode(d):null,deviceKeyPair:2&c?r.decode(d):null,deviceProof:e.buffer.decode(d)}}},Sn={preencode(o,n){o.end++,d>=35&&n.roomSnoozeTime&&e.uint.preencode(o,n.roomSnoozeTime)},encode(o,n){const c=(n.isActive?1:0)|(n.isFullyMuted?2:0)|(n.isMentionsOnlyMuted?4:0)|(d>=14&&n.isReadOnly?8:0)|(d>=27&&n.isFavorite?16:0)|(d>=31&&n.isUnread?32:0)|(d>=35&&n.roomSnoozeTime?64:0);e.uint.encode(o,c),d>=35&&n.roomSnoozeTime&&e.uint.encode(o,n.roomSnoozeTime)},decode(o){const n=e.uint.decode(o);return{isActive:!!(1&n),isFullyMuted:!!(2&n),isMentionsOnlyMuted:!!(4&n),isReadOnly:d>=14&&!!(8&n),isFavorite:d>=27&&!!(16&n),isUnread:d>=31&&!!(32&n),roomSnoozeTime:d>=35&&64&n?e.uint.decode(o):0}}},In=e.frame(Sn),Cn=e.frame(Mn),Vn=gn,Hn={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),In.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,c.initiator&&o.preencode(n,c.initiator),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),c.identitySwap&&Cn.preencode(n,c.identitySwap),d>=9&&c.identitySwapV2&&Vn.preencode(n,c.identitySwapV2),d>=15&&c.contact&&e.fixed32.preencode(n,c.contact),d>=37&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=39&&c.activeClock&&e.uint.preencode(n,c.activeClock)},encode(n,c){const r=(c.initiator?1:0)|(c.fastForwardTo?2:0)|(c.identitySwap?4:0)|(d>=9&&c.identitySwapV2?8:0)|(d>=15&&c.contact?16:0)|(d>=37&&c.bootFrom?32:0)|(d>=39&&c.activeClock?64:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),In.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,r),c.initiator&&o.encode(n,c.initiator),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),c.identitySwap&&Cn.encode(n,c.identitySwap),d>=9&&c.identitySwapV2&&Vn.encode(n,c.identitySwapV2),d>=15&&c.contact&&e.fixed32.encode(n,c.contact),d>=37&&c.bootFrom&&o.encode(n,c.bootFrom),d>=39&&c.activeClock&&e.uint.encode(n,c.activeClock)},decode(n){const c=e.fixed32.decode(n),r=e.buffer.decode(n),t=e.fixed32.decode(n),i=In.decode(n),a=e.uint.decode(n),s=e.uint.decode(n);return{roomKey:c,encryptionKey:r,mailbox:t,status:i,clock:a,initiator:1&s?o.decode(n):null,fastForwardTo:2&s?e.fixed32.decode(n):null,identitySwap:4&s?Cn.decode(n):null,identitySwapV2:d>=9&&8&s?Vn.decode(n):null,contact:d>=15&&16&s?e.fixed32.decode(n):null,bootFrom:d>=37&&32&s?o.decode(n):null,activeClock:d>=39&&64&s?e.uint.decode(n):0}}},Fn=$,Dn={preencode(d,n){Fn.preencode(d,n.header),e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.mailbox),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.dm&&e.fixed32.preencode(d,n.dm)},encode(n,c){const r=(c.fastForwardTo?1:0)|(c.initiator?2:0)|(c.dm?4:0)|(d>=14&&c.isReadOnly?8:0);Fn.encode(n,c.header),e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),e.uint.encode(n,r),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),c.initiator&&o.encode(n,c.initiator),c.dm&&e.fixed32.encode(n,c.dm)},decode(n){const c=Fn.decode(n),r=e.fixed32.decode(n),t=e.buffer.decode(n),i=e.fixed32.decode(n),a=e.uint.decode(n);return{header:c,roomKey:r,encryptionKey:t,mailbox:i,fastForwardTo:1&a?e.fixed32.decode(n):null,initiator:2&a?o.decode(n):null,dm:4&a?e.fixed32.decode(n):null,isReadOnly:d>=14&&!!(8&a)}}},Ln=$,jn={preencode(d,o){Ln.preencode(d,o.header),e.fixed32.preencode(d,o.discoveryKey)},encode(d,o){Ln.encode(d,o.header),e.fixed32.encode(d,o.discoveryKey)},decode:d=>({header:Ln.decode(d),discoveryKey:e.fixed32.decode(d)})},qn=$,Bn=In,En={preencode(d,o){qn.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.key),Bn.preencode(d,o.status)},encode(d,o){qn.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.key),Bn.encode(d,o.status)},decode:d=>({header:qn.decode(d),roomKey:e.fixed32.decode(d),key:e.uint.decode(d),status:Bn.decode(d)})},zn={preencode(e,d){e.end++},encode(o,n){const c=(n.isBlocked?1:0)|(d>=32&&n.isActive?2:0);e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{isBlocked:!!(1&n),isActive:d>=32&&!!(2&n)}}},On={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.clock),_s.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=32&&n.contactInfo&&el.preencode(o,n.contactInfo),d>=34&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=32&&n.contactInfo?4:0)|(d>=34&&n.alias?8:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.clock),_s.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=32&&n.contactInfo&&el.encode(o,n.contactInfo),d>=34&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),r=_s.decode(o),t=e.uint.decode(o);return{memberKey:n,clock:c,status:r,mailbox:1&t?e.fixed32.decode(o):null,roomKey:2&t?e.fixed32.decode(o):null,contactInfo:d>=32&&4&t?el.decode(o):null,alias:d>=34&&8&t?e.string.decode(o):null}}},Nn=$,Un=e.frame(an),Jn={preencode(e,d){Nn.preencode(e,d.header),Un.preencode(e,d.contact)},encode(e,d){Nn.encode(e,d.header),Un.encode(e,d.contact)},decode:e=>({header:Nn.decode(e),contact:Un.decode(e)})},Wn=$,Gn={preencode(d,o){Wn.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),dl.preencode(d,o.status)},encode(d,o){Wn.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),dl.encode(d,o.status)},decode:d=>({header:Wn.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:dl.decode(d)})},Qn=$,Xn={preencode(d,o){Qn.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Qn.encode(d,o.header),e.fixed32.encode(d,o.memberKey)},decode:d=>({header:Qn.decode(d),memberKey:e.fixed32.decode(d)})},Yn={preencode(e,d){e.end++},encode(d,o){const n=(o.isPending?1:0)|(o.isAccepted?2:0)|(o.isRejected?4:0)|(o.isDiscarded?8:0)|(o.isSeen?16:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isPending:!!(1&o),isAccepted:!!(2&o),isRejected:!!(4&o),isDiscarded:!!(8&o),isSeen:!!(16&o)}}},Zn=xe,$n=e.frame(t),_n={preencode(d,o){Zn.preencode(d,o.sender),$n.preencode(d,o.keys),e.fixed32.preencode(d,o.mailbox),d.end++,o.message&&e.string.preencode(d,o.message)},encode(d,o){const n=o.message?1:0;Zn.encode(d,o.sender),$n.encode(d,o.keys),e.fixed32.encode(d,o.mailbox),e.uint.encode(d,n),o.message&&e.string.encode(d,o.message)},decode:d=>({sender:Zn.decode(d),keys:$n.decode(d),mailbox:e.fixed32.decode(d),message:1&e.uint.decode(d)?e.string.decode(d):null})},ec=e.frame(_n),dc={preencode(e,d){ec.preencode(e,d.body),ne.preencode(e,d.attestation)},encode(e,d){ec.encode(e,d.body),ne.encode(e,d.attestation)},decode:e=>({body:ec.decode(e),attestation:ne.decode(e)})},oc=le,nc=e.frame(Yn),cc=$n,rc={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.clock),oc.preencode(o,n.sender),nc.preencode(o,n.status),cc.preencode(o,n.keys),e.fixed32.preencode(o,n.mailbox),o.end++,n.message&&e.string.preencode(o,n.message),d>=17&&n.sentAt&&e.uint.preencode(o,n.sentAt),d>=32&&n.contactInfo&&ol.preencode(o,n.contactInfo)},encode(o,n){const c=(n.message?1:0)|(d>=17&&n.sentAt?2:0)|(d>=32&&n.contactInfo?4:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.clock),oc.encode(o,n.sender),nc.encode(o,n.status),cc.encode(o,n.keys),e.fixed32.encode(o,n.mailbox),e.uint.encode(o,c),n.message&&e.string.encode(o,n.message),d>=17&&n.sentAt&&e.uint.encode(o,n.sentAt),d>=32&&n.contactInfo&&ol.encode(o,n.contactInfo)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),r=oc.decode(o),t=nc.decode(o),i=cc.decode(o),a=e.fixed32.decode(o),s=e.uint.decode(o);return{memberKey:n,clock:c,sender:r,status:t,keys:i,mailbox:a,message:1&s?e.string.decode(o):null,sentAt:d>=17&&2&s?e.uint.decode(o):0,contactInfo:d>=32&&4&s?ol.decode(o):null}}},tc=$,ic={preencode(d,o){tc.preencode(d,o.header),e.buffer.preencode(d,o.blindRequest)},encode(d,o){tc.encode(d,o.header),e.buffer.encode(d,o.blindRequest)},decode:d=>({header:tc.decode(d),blindRequest:e.buffer.decode(d)})},ac=$,sc=nc,lc={preencode(o,n){ac.preencode(o,n.header),e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.key),sc.preencode(o,n.status),o.end++,d>=15&&n.roomKey&&e.fixed32.preencode(o,n.roomKey)},encode(o,n){const c=d>=15&&n.roomKey?1:0;ac.encode(o,n.header),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.key),sc.encode(o,n.status),e.uint.encode(o,c),d>=15&&n.roomKey&&e.fixed32.encode(o,n.roomKey)},decode(o){const n=ac.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o),t=sc.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{header:n,memberKey:c,key:r,status:t,roomKey:d>=15&&1&i?e.fixed32.decode(o):null}}},pc={preencode(d,o){e.uint.preencode(d,o.timestamp),e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.mailbox)},encode(d,o){e.uint.encode(d,o.timestamp),e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.mailbox)},decode:d=>({version:e.uint.decode(d),timestamp:e.uint.decode(d),key:e.fixed32.decode(d),mailbox:e.fixed32.decode(d)})},uc={preencode(d,o){const n=o.version??1;switch(e.uint.preencode(d,n),n){case 0:case 1:pc.preencode(d,o);break;default:throw new Error("Unsupported version")}},encode(d,o){const n=o.version??1;switch(e.uint.encode(d,n),n){case 0:case 1:pc.encode(d,o);break;default:throw new Error("Unsupported version")}},decode(d){const o=d.start,n=e.uint.decode(d);switch(d.start=o,n){case 0:case 1:return pc.decode(d);default:throw new Error("Unsupported version")}}},fc={preencode(d,o){e.fixed32.preencode(d,o.discoveryPublicKey),e.uint.preencode(d,o.timestamp),d.end++,o.lastSynced&&e.uint.preencode(d,o.lastSynced)},encode(d,o){const n=(o.lastSynced?1:0)|(o.dirty?2:0);e.fixed32.encode(d,o.discoveryPublicKey),e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.lastSynced&&e.uint.encode(d,o.lastSynced)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d),c=e.uint.decode(d);return{discoveryPublicKey:o,timestamp:n,lastSynced:1&c?e.uint.decode(d):0,dirty:!!(2&c)}}},mc={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.activeRooms)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.activeRooms)},decode:d=>({rooms:e.uint.decode(d),activeRooms:e.uint.decode(d)})},yc=C,bc=X,xc={preencode(e,d){e.end++,d.blockedMembers&&bc.preencode(e,d.blockedMembers)},encode(d,o){const n=o.blockedMembers?1:0;e.uint.encode(d,n),o.blockedMembers&&bc.encode(d,o.blockedMembers)},decode:d=>({blockedMembers:1&e.uint.decode(d)?bc.decode(d):null})},vc=e.frame(Q),gc=e.frame(xc),kc={preencode(d,n){e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.seed),vc.preencode(d,n.capabilities),o.preencode(d,n.initiator),e.fixed32.preencode(d,n.fastForwardTo),d.end++,n.privateProfile&&gc.preencode(d,n.privateProfile)},encode(d,n){const c=n.privateProfile?1:0;e.buffer.encode(d,n.encryptionKey),e.fixed32.encode(d,n.seed),vc.encode(d,n.capabilities),o.encode(d,n.initiator),e.fixed32.encode(d,n.fastForwardTo),e.uint.encode(d,c),n.privateProfile&&gc.encode(d,n.privateProfile)},decode:d=>({encryptionKey:e.buffer.decode(d),seed:e.fixed32.decode(d),capabilities:vc.decode(d),initiator:o.decode(d),fastForwardTo:e.fixed32.decode(d),privateProfile:1&e.uint.decode(d)?gc.decode(d):null})},Kc={preencode(d,o){d.end++,o.count&&e.uint.preencode(d,o.count)},encode(d,o){const n=o.count?1:0;e.uint.encode(d,n),o.count&&e.uint.encode(d,o.count)},decode:d=>({count:1&e.uint.decode(d)?e.uint.decode(d):0})},hc=e.frame(kc),wc={preencode(o,n){e.fixed32.preencode(o,n.roomKey),e.uint.preencode(o,n.priority),o.end++,n.v3&&hc.preencode(o,n.v3),d>=5&&n.timestamp&&e.uint.preencode(o,n.timestamp)},encode(o,n){const c=(n.v3?1:0)|(d>=3&&n.errored?2:0)|(d>=5&&n.timestamp?4:0);e.fixed32.encode(o,n.roomKey),e.uint.encode(o,n.priority),e.uint.encode(o,c),n.v3&&hc.encode(o,n.v3),d>=5&&n.timestamp&&e.uint.encode(o,n.timestamp)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),r=e.uint.decode(o);return{roomKey:n,priority:c,v3:1&r?hc.decode(o):null,errored:d>=3&&!!(2&r),timestamp:d>=5&&4&r?e.uint.decode(o):0}}},Rc={preencode(e,d){e.end++},encode(d,o){const n=o.isConfirmed?1:0;e.uint.encode(d,n)},decode:d=>({isConfirmed:!!(1&e.uint.decode(d))})},Pc=e.frame(Rc),Tc=Cn,Ac={preencode(o,n){e.fixed32.preencode(o,n.publicKey),e.fixed32.preencode(o,n.privateProfileKey),r.preencode(o,n.deviceKeyPair),e.buffer.preencode(o,n.deviceProof),Pc.preencode(o,n.status),o.end++,n.entropy&&e.buffer.preencode(o,n.entropy),n.swap&&Tc.preencode(o,n.swap),d>=9&&n.swapV2&&nl.preencode(o,n.swapV2),d>=31&&n.proofShortenedAt&&e.uint.preencode(o,n.proofShortenedAt)},encode(o,n){const c=(n.entropy?1:0)|(n.swap?2:0)|(d>=9&&n.swapV2?4:0)|(d>=31&&n.proofShortenedAt?8:0);e.fixed32.encode(o,n.publicKey),e.fixed32.encode(o,n.privateProfileKey),r.encode(o,n.deviceKeyPair),e.buffer.encode(o,n.deviceProof),Pc.encode(o,n.status),e.uint.encode(o,c),n.entropy&&e.buffer.encode(o,n.entropy),n.swap&&Tc.encode(o,n.swap),d>=9&&n.swapV2&&nl.encode(o,n.swapV2),d>=31&&n.proofShortenedAt&&e.uint.encode(o,n.proofShortenedAt)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=r.decode(o),i=e.buffer.decode(o),a=Pc.decode(o),s=e.uint.decode(o);return{publicKey:n,privateProfileKey:c,deviceKeyPair:t,deviceProof:i,status:a,entropy:1&s?e.buffer.decode(o):null,swap:2&s?Tc.decode(o):null,swapV2:d>=9&&4&s?nl.decode(o):null,proofShortenedAt:d>=31&&8&s?e.uint.decode(o):0}}},Mc={RestoreIdentity:1,CreateRoom:2,LeaveRoom:3,ClearRoom:4,JoinRoomInvitation:5,JoinRoomKeys:6,JoinRoomResponse:7,SendContactRequest:8,TestFastTask:9,TestSlowTask:10,TestErrorTask:11},Sc={preencode(e,d){e.end++},encode(d,o){if(o>11)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Ic={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator)},encode(d,n){const c=(n.fastForwardTo?1:0)|(n.initiator?2:0);e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.uint.encode(d,c),n.fastForwardTo&&e.fixed32.encode(d,n.fastForwardTo),n.initiator&&o.encode(d,n.initiator)},decode(d){const n=e.fixed32.decode(d),c=e.buffer.decode(d),r=e.uint.decode(d);return{roomKey:n,encryptionKey:c,fastForwardTo:1&r?e.fixed32.decode(d):null,initiator:2&r?o.decode(d):null}}},Cc=Rn,Vc={preencode(e,d){Cc.preencode(e,d.invitation)},encode(e,d){Cc.encode(e,d.invitation)},decode:e=>({invitation:Cc.decode(e)})},Hc={preencode(d,o){e.fixed32.preencode(d,o.mailbox),r.preencode(d,o.keyPair),e.buffer.preencode(d,o.response)},encode(d,o){e.fixed32.encode(d,o.mailbox),r.encode(d,o.keyPair),e.buffer.encode(d,o.response)},decode:d=>({mailbox:e.fixed32.decode(d),keyPair:r.decode(d),response:e.buffer.decode(d)})},Fc=Z,Dc={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.mailbox&&e.fixed32.preencode(d,n.mailbox)},encode(d,n){const c=(n.fastForwardTo?1:0)|(n.initiator?2:0)|(n.mailbox?4:0);e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.uint.encode(d,c),n.fastForwardTo&&e.fixed32.encode(d,n.fastForwardTo),n.initiator&&o.encode(d,n.initiator),n.mailbox&&e.fixed32.encode(d,n.mailbox)},decode(d){const n=e.fixed32.decode(d),c=e.buffer.decode(d),r=e.uint.decode(d);return{roomKey:n,encryptionKey:c,fastForwardTo:1&r?e.fixed32.decode(d):null,initiator:2&r?o.decode(d):null,mailbox:4&r?e.fixed32.decode(d):null}}},Lc=e.frame(Dc),jc={preencode(o,n){Lc.preencode(o,n.keys),o.end++,d>=39&&n.activeClock&&e.uint.preencode(o,n.activeClock)},encode(o,n){const c=(d>=39&&n.activeClock?1:0)|(d>=39&&n.isReadOnly?2:0);Lc.encode(o,n.keys),e.uint.encode(o,c),d>=39&&n.activeClock&&e.uint.encode(o,n.activeClock)},decode(o){const n=Lc.decode(o),c=o.start<o.end?e.uint.decode(o):0;return{keys:n,activeClock:d>=39&&1&c?e.uint.decode(o):0,isReadOnly:d>=39&&!!(2&c)}}},qc=e.frame(dn),Bc={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.mailbox&&e.fixed32.preencode(d,n.mailbox),n.keyPair&&r.preencode(d,n.keyPair),n.genesis&&qc.preencode(d,n.genesis)},encode(d,n){const c=(n.fastForwardTo?1:0)|(n.initiator?2:0)|(n.mailbox?4:0)|(n.keyPair?8:0)|(n.genesis?16:0)|(n.isPrivateProfile?32:0);e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.uint.encode(d,c),n.fastForwardTo&&e.fixed32.encode(d,n.fastForwardTo),n.initiator&&o.encode(d,n.initiator),n.mailbox&&e.fixed32.encode(d,n.mailbox),n.keyPair&&r.encode(d,n.keyPair),n.genesis&&qc.encode(d,n.genesis)},decode(d){const n=e.fixed32.decode(d),c=e.buffer.decode(d),t=e.uint.decode(d);return{roomKey:n,encryptionKey:c,fastForwardTo:1&t?e.fixed32.decode(d):null,initiator:2&t?o.decode(d):null,mailbox:4&t?e.fixed32.decode(d):null,keyPair:8&t?r.decode(d):null,genesis:16&t?qc.decode(d):null,isPrivateProfile:!!(32&t)}}},Ec={preencode(d,o){e.fixed32.preencode(d,o.roomKey),d.end++},encode(d,o){const n=o.isGossiped?1:0;e.fixed32.encode(d,o.roomKey),e.uint.encode(d,n)},decode:d=>({roomKey:e.fixed32.decode(d),isGossiped:!!(1&e.uint.decode(d))})},zc={preencode(d,o){e.fixed32.preencode(d,o.roomKey)},encode(d,o){e.fixed32.encode(d,o.roomKey)},decode:d=>({roomKey:e.fixed32.decode(d)})},Oc={preencode(d,o){e.string.preencode(d,o.mnemonic),d.end++,o.profileDiscoveryTimeout&&e.uint.preencode(d,o.profileDiscoveryTimeout)},encode(d,o){const n=(o.profileDiscoveryTimeout?1:0)|(o.recover?2:0);e.string.encode(d,o.mnemonic),e.uint.encode(d,n),o.profileDiscoveryTimeout&&e.uint.encode(d,o.profileDiscoveryTimeout)},decode(d){const o=e.string.decode(d),n=e.uint.decode(d);return{mnemonic:o,profileDiscoveryTimeout:1&n?e.uint.decode(d):0,recover:!!(2&n)}}},Nc={preencode(o,n){e.fixed32.preencode(o,n.roomKey),e.fixed32.preencode(o,n.memberKey),o.end++,n.message&&e.string.preencode(o,n.message),d>=6&&n.contactInfo&&cl.preencode(o,n.contactInfo)},encode(o,n){const c=(n.message?1:0)|(d>=6&&n.contactInfo?2:0);e.fixed32.encode(o,n.roomKey),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,c),n.message&&e.string.encode(o,n.message),d>=6&&n.contactInfo&&cl.encode(o,n.contactInfo)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{roomKey:n,memberKey:c,message:1&r?e.string.decode(o):null,contactInfo:d>=6&&2&r?cl.decode(o):null}}},Uc={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++},encode(d,o){const n=o.isPrivateProfile?1:0;e.fixed32.encode(d,o.key),e.uint.encode(d,n)},decode:d=>({key:e.fixed32.decode(d),isPrivateProfile:!!(1&e.uint.decode(d))})},Jc=e.frame(Oc),Wc=e.frame(Bc),Gc=e.frame(Ec),Qc=e.frame(zc),Xc=e.frame(Vc),Yc=e.frame(jc),Zc=e.frame(Hc),$c=e.frame(Nc),_c=e.frame(Uc),er={preencode(d,o){const n=(o.restoreIdentity?1:0)|(o.createRoom?2:0)|(o.leaveRoom?4:0)|(o.clearRoom?8:0)|(o.joinRoomInvitation?16:0)|(o.joinRoomKeys?32:0)|(o.joinRoomResponse?64:0)|(o.sendContactRequest?128:0)|(o.migrateV2Room?256:0);e.fixed32.preencode(d,o.discoveryKey),e.uint.preencode(d,o.priority),e.uint.preencode(d,o.timestamp),e.uint.preencode(d,o.type),e.uint.preencode(d,n),o.restoreIdentity&&Jc.preencode(d,o.restoreIdentity),o.createRoom&&Wc.preencode(d,o.createRoom),o.leaveRoom&&Gc.preencode(d,o.leaveRoom),o.clearRoom&&Qc.preencode(d,o.clearRoom),o.joinRoomInvitation&&Xc.preencode(d,o.joinRoomInvitation),o.joinRoomKeys&&Yc.preencode(d,o.joinRoomKeys),o.joinRoomResponse&&Zc.preencode(d,o.joinRoomResponse),o.sendContactRequest&&$c.preencode(d,o.sendContactRequest),o.migrateV2Room&&_c.preencode(d,o.migrateV2Room)},encode(d,o){const n=(o.restoreIdentity?1:0)|(o.createRoom?2:0)|(o.leaveRoom?4:0)|(o.clearRoom?8:0)|(o.joinRoomInvitation?16:0)|(o.joinRoomKeys?32:0)|(o.joinRoomResponse?64:0)|(o.sendContactRequest?128:0)|(o.migrateV2Room?256:0);e.fixed32.encode(d,o.discoveryKey),e.uint.encode(d,o.priority),e.uint.encode(d,o.timestamp),e.uint.encode(d,o.type),e.uint.encode(d,n),o.restoreIdentity&&Jc.encode(d,o.restoreIdentity),o.createRoom&&Wc.encode(d,o.createRoom),o.leaveRoom&&Gc.encode(d,o.leaveRoom),o.clearRoom&&Qc.encode(d,o.clearRoom),o.joinRoomInvitation&&Xc.encode(d,o.joinRoomInvitation),o.joinRoomKeys&&Yc.encode(d,o.joinRoomKeys),o.joinRoomResponse&&Zc.encode(d,o.joinRoomResponse),o.sendContactRequest&&$c.encode(d,o.sendContactRequest),o.migrateV2Room&&_c.encode(d,o.migrateV2Room)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d),c=e.uint.decode(d),r=e.uint.decode(d),t=e.uint.decode(d);return{discoveryKey:o,priority:n,timestamp:c,type:r,restoreIdentity:1&t?Jc.decode(d):null,createRoom:2&t?Wc.decode(d):null,leaveRoom:4&t?Gc.decode(d):null,clearRoom:8&t?Qc.decode(d):null,joinRoomInvitation:16&t?Xc.decode(d):null,joinRoomKeys:32&t?Yc.decode(d):null,joinRoomResponse:64&t?Zc.decode(d):null,sendContactRequest:128&t?$c.decode(d):null,migrateV2Room:256&t?_c.decode(d):null}}},dr=Le,or={preencode(d,o){e.buffer.preencode(d,o.seed),dr.preencode(d,o.invitation)},encode(d,o){e.buffer.encode(d,o.seed),dr.encode(d,o.invitation)},decode:d=>({seed:e.buffer.decode(d),invitation:dr.decode(d)})},nr={preencode(e,d){e.end++},encode(o,n){const c=(n.isWritable?1:0)|(n.isReadable?2:0)|(n.isPrivateProfile?4:0)|(d>=8&&n.isRemoved?8:0);e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{isWritable:!!(1&n),isReadable:!!(2&n),isPrivateProfile:!!(4&n),isRemoved:d>=8&&!!(8&n)}}},cr={preencode(d,o){e.uint.preencode(d,o.creation),e.uint.preencode(d,o.latestSync),e.uint.preencode(d,o.latestChatMessage)},encode(d,o){e.uint.encode(d,o.creation),e.uint.encode(d,o.latestSync),e.uint.encode(d,o.latestChatMessage)},decode:d=>({creation:e.uint.decode(d),latestSync:e.uint.decode(d),latestChatMessage:e.uint.decode(d)})},rr=Xo,tr=fo,ir=e.frame(cr),ar=vc,sr=e.frame(nr),lr=e.frame(ie),pr=e.frame(ud),ur=Oo,fr=$o,mr=e.frame(ho),yr=X,br=e.frame(sd),xr=In,vr={preencode(o,n){const c=(n.selfDevice?1:0)|(n.selfMember?2:0)|(n.config?4:0)|(n.identity?8:0)|(n.lastMessage?16:0)|(n.dm?32:0)|(d>=19&&n.readLengths?64:0)|(d>=19&&n.lastMember?128:0)|(d>=21&&n.version?256:0)|(d>=27&&n.preferences?512:0)|(d>=28&&n.activeCall?1024:0)|(d>=32&&n.lastMessageLabels?2048:0)|(d>=33&&n.settings?4096:0)|(d>=37&&n.system?8192:0)|(d>=37&&n.processed?16384:0);e.fixed32.preencode(o,n.roomKey),e.fixed32.preencode(o,n.discoveryKey),e.buffer.preencode(o,n.encryptionKey),rr.preencode(o,n.digest),tr.preencode(o,n.stats),ir.preencode(o,n.timestamps),e.uint.preencode(o,n.fork),e.uint.preencode(o,n.length),e.fixed32.preencode(o,n.seed),ar.preencode(o,n.capabilities),sr.preencode(o,n.status),e.uint.preencode(o,c),n.selfDevice&&lr.preencode(o,n.selfDevice),n.selfMember&&pr.preencode(o,n.selfMember),n.config&&ur.preencode(o,n.config),n.identity&&fr.preencode(o,n.identity),n.lastMessage&&mr.preencode(o,n.lastMessage),n.dm&&yr.preencode(o,n.dm),d>=19&&n.readLengths&&rl.preencode(o,n.readLengths),d>=19&&n.lastMember&&br.preencode(o,n.lastMember),d>=21&&n.version&&e.uint.preencode(o,n.version),d>=27&&n.preferences&&xr.preencode(o,n.preferences),d>=28&&n.activeCall&&tl.preencode(o,n.activeCall),d>=32&&n.lastMessageLabels&&il.preencode(o,n.lastMessageLabels),d>=33&&n.settings&&al.preencode(o,n.settings),d>=37&&n.system&&sl.preencode(o,n.system),d>=37&&n.processed&&ll.preencode(o,n.processed)},encode(o,n){const c=(n.selfDevice?1:0)|(n.selfMember?2:0)|(n.config?4:0)|(n.identity?8:0)|(n.lastMessage?16:0)|(n.dm?32:0)|(d>=19&&n.readLengths?64:0)|(d>=19&&n.lastMember?128:0)|(d>=21&&n.version?256:0)|(d>=27&&n.preferences?512:0)|(d>=28&&n.activeCall?1024:0)|(d>=32&&n.lastMessageLabels?2048:0)|(d>=33&&n.settings?4096:0)|(d>=37&&n.system?8192:0)|(d>=37&&n.processed?16384:0);e.fixed32.encode(o,n.roomKey),e.fixed32.encode(o,n.discoveryKey),e.buffer.encode(o,n.encryptionKey),rr.encode(o,n.digest),tr.encode(o,n.stats),ir.encode(o,n.timestamps),e.uint.encode(o,n.fork),e.uint.encode(o,n.length),e.fixed32.encode(o,n.seed),ar.encode(o,n.capabilities),sr.encode(o,n.status),e.uint.encode(o,c),n.selfDevice&&lr.encode(o,n.selfDevice),n.selfMember&&pr.encode(o,n.selfMember),n.config&&ur.encode(o,n.config),n.identity&&fr.encode(o,n.identity),n.lastMessage&&mr.encode(o,n.lastMessage),n.dm&&yr.encode(o,n.dm),d>=19&&n.readLengths&&rl.encode(o,n.readLengths),d>=19&&n.lastMember&&br.encode(o,n.lastMember),d>=21&&n.version&&e.uint.encode(o,n.version),d>=27&&n.preferences&&xr.encode(o,n.preferences),d>=28&&n.activeCall&&tl.encode(o,n.activeCall),d>=32&&n.lastMessageLabels&&il.encode(o,n.lastMessageLabels),d>=33&&n.settings&&al.encode(o,n.settings),d>=37&&n.system&&sl.encode(o,n.system),d>=37&&n.processed&&ll.encode(o,n.processed)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.buffer.decode(o),t=rr.decode(o),i=tr.decode(o),a=ir.decode(o),s=e.uint.decode(o),l=e.uint.decode(o),p=e.fixed32.decode(o),u=ar.decode(o),f=sr.decode(o),m=e.uint.decode(o);return{roomKey:n,discoveryKey:c,encryptionKey:r,digest:t,stats:i,timestamps:a,fork:s,length:l,seed:p,capabilities:u,status:f,selfDevice:1&m?lr.decode(o):null,selfMember:2&m?pr.decode(o):null,config:4&m?ur.decode(o):null,identity:8&m?fr.decode(o):null,lastMessage:16&m?mr.decode(o):null,dm:32&m?yr.decode(o):null,readLengths:d>=19&&64&m?rl.decode(o):null,lastMember:d>=19&&128&m?br.decode(o):null,version:d>=21&&256&m?e.uint.decode(o):0,preferences:d>=27&&512&m?xr.decode(o):null,activeCall:d>=28&&1024&m?tl.decode(o):null,lastMessageLabels:d>=32&&2048&m?il.decode(o):null,settings:d>=33&&4096&m?al.decode(o):null,system:d>=37&&8192&m?sl.decode(o):null,processed:d>=37&&16384&m?ll.decode(o):null}}},gr=In,kr={preencode(d,o){e.fixed32.preencode(d,o.roomKey),gr.preencode(d,o.status)},encode(d,o){e.fixed32.encode(d,o.roomKey),gr.encode(d,o.status)},decode:d=>({roomKey:e.fixed32.decode(d),status:gr.decode(d)})},Kr={preencode(o,n){e.fixed32.preencode(o,n.mailbox),e.fixed32.preencode(o,n.key),o.end++,n.roomKey&&e.fixed32.preencode(o,n.roomKey),n.keyPair&&r.preencode(o,n.keyPair),n.responseKeyPair&&r.preencode(o,n.responseKeyPair),d>=39&&n.activeClock&&e.uint.preencode(o,n.activeClock)},encode(o,n){const c=(n.roomKey?1:0)|(n.keyPair?2:0)|(n.responseKeyPair?4:0)|(d>=38&&n.pending?8:0)|(d>=39&&n.activeClock?16:0);e.fixed32.encode(o,n.mailbox),e.fixed32.encode(o,n.key),e.uint.encode(o,c),n.roomKey&&e.fixed32.encode(o,n.roomKey),n.keyPair&&r.encode(o,n.keyPair),n.responseKeyPair&&r.encode(o,n.responseKeyPair),d>=39&&n.activeClock&&e.uint.encode(o,n.activeClock)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=e.uint.decode(o);return{mailbox:n,key:c,roomKey:1&t?e.fixed32.decode(o):null,keyPair:2&t?r.decode(o):null,responseKeyPair:4&t?r.decode(o):null,pending:d>=38&&!!(8&t),activeClock:d>=39&&16&t?e.uint.decode(o):0}}},hr=le,wr={preencode(d,o){e.fixed32.preencode(d,o.key),hr.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),hr.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),profile:hr.decode(d)})},Rr=lr,Pr={preencode(d,o){e.fixed32.preencode(d,o.roomKey),Rr.preencode(d,o.device)},encode(d,o){e.fixed32.encode(d,o.roomKey),Rr.encode(d,o.device)},decode:d=>({roomKey:e.fixed32.decode(d),device:Rr.decode(d)})},Tr=k,Ar={preencode(o,n){Tr.preencode(o,n.file),e.fixed32.preencode(o,n.roomKey),o.end++,n.encryptionKey&&e.buffer.preencode(o,n.encryptionKey),d>=28&&n.lastAccessed&&e.uint.preencode(o,n.lastAccessed),d>=28&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(n.encryptionKey?1:0)|(n.cleared?2:0)|(n.own?4:0)|(d>=28&&n.lastAccessed?8:0)|(d>=28&&n.version?16:0);Tr.encode(o,n.file),e.fixed32.encode(o,n.roomKey),e.uint.encode(o,c),n.encryptionKey&&e.buffer.encode(o,n.encryptionKey),d>=28&&n.lastAccessed&&e.uint.encode(o,n.lastAccessed),d>=28&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=Tr.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{file:n,roomKey:c,encryptionKey:1&r?e.buffer.decode(o):null,cleared:!!(2&r),own:!!(4&r),lastAccessed:d>=28&&8&r?e.uint.decode(o):0,version:d>=28&&16&r?e.uint.decode(o):0}}},Mr=$,Sr={preencode(o,c){Mr.preencode(o,c.header),n.preencode(o,c.oplog),e.uint.preencode(o,c.index),pl.preencode(o,c.preview),o.end++,d>=12&&c.displayType&&Gr.preencode(o,c.displayType)},encode(o,c){const r=d>=12&&c.displayType?1:0;Mr.encode(o,c.header),n.encode(o,c.oplog),e.uint.encode(o,c.index),pl.encode(o,c.preview),e.uint.encode(o,r),d>=12&&c.displayType&&Gr.encode(o,c.displayType)},decode(o){const c=Mr.decode(o),r=n.decode(o),t=e.uint.decode(o),i=pl.decode(o),a=o.start<o.end?e.uint.decode(o):0;return{header:c,oplog:r,index:t,preview:i,displayType:d>=12&&1&a?Gr.decode(o):0}}},Ir={preencode(o,n){o.end++,d>=4&&n.memberKey&&e.fixed32.preencode(o,n.memberKey)},encode(o,n){const c=d>=4&&n.memberKey?1:0;e.uint.encode(o,c),d>=4&&n.memberKey&&e.fixed32.encode(o,n.memberKey)},decode(o){const n=e.uint.decode(o);return{memberKey:d>=4&&1&n?e.fixed32.decode(o):null}}},Cr=le,Vr={preencode(e,d){Cr.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){Cr.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:Cr.decode(e),attestation:ne.decode(e)})},Hr=$,Fr={preencode(d,o){Hr.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){Hr.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:Hr.decode(d),key:e.fixed32.decode(d)})},Dr={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),ne.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){e.fixed32.encode(d,o.deviceKey),ne.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({deviceKey:e.fixed32.decode(d),privateProfileIdentity:ne.decode(d),deviceProof:e.buffer.decode(d)})},Lr={preencode(o,n){e.fixed32.preencode(o,n.roomKey),e.fixed32.preencode(o,n.encryptionKey),e.fixed32.preencode(o,n.seed),o.end++,d>=9&&n.fastForwardTo&&e.fixed32.preencode(o,n.fastForwardTo)},encode(o,n){const c=d>=9&&n.fastForwardTo?1:0;e.fixed32.encode(o,n.roomKey),e.fixed32.encode(o,n.encryptionKey),e.fixed32.encode(o,n.seed),e.uint.encode(o,c),d>=9&&n.fastForwardTo&&e.fixed32.encode(o,n.fastForwardTo)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o);return{roomKey:n,encryptionKey:c,seed:r,fastForwardTo:d>=9&&1&t?e.fixed32.decode(o):null}}},jr={preencode(o,n){e.fixed32.preencode(o,n.publicKey),e.fixed32.preencode(o,n.writerKey),e.fixed32.preencode(o,n.devicePublicKey),o.end++,d>=9&&n.privateProfileKey&&e.fixed32.preencode(o,n.privateProfileKey)},encode(o,n){const c=d>=9&&n.privateProfileKey?1:0;e.fixed32.encode(o,n.publicKey),e.fixed32.encode(o,n.writerKey),e.fixed32.encode(o,n.devicePublicKey),e.uint.encode(o,c),d>=9&&n.privateProfileKey&&e.fixed32.encode(o,n.privateProfileKey)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o);return{publicKey:n,writerKey:c,devicePublicKey:r,privateProfileKey:d>=9&&1&t?e.fixed32.decode(o):null}}},qr=$,Br={preencode(d,o){qr.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey)},encode(d,o){qr.encode(d,o.header),e.fixed32.encode(d,o.memberKey)},decode:d=>({header:qr.decode(d),memberKey:e.fixed32.decode(d)})},Er={preencode(d,o){e.fixed32.preencode(d,o.privateProfileKey)},encode(d,o){e.fixed32.encode(d,o.privateProfileKey)},decode:d=>({privateProfileKey:e.fixed32.decode(d)})},zr={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.responsePublicKey)},encode(d,o){e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.responsePublicKey)},decode:d=>({key:e.fixed32.decode(d),responsePublicKey:e.fixed32.decode(d)})},Or={preencode(o,n){e.fixed32.preencode(o,n.roomKey),o.end++,d>=10&&n.repairs&&e.uint.preencode(o,n.repairs)},encode(o,n){const c=d>=10&&n.repairs?1:0;e.fixed32.encode(o,n.roomKey),e.uint.encode(o,c),d>=10&&n.repairs&&e.uint.encode(o,n.repairs)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o);return{roomKey:n,repairs:d>=10&&1&c?e.uint.decode(o):0}}},Nr={preencode(o,n){o.end++,d>=11&&n.key&&e.string.preencode(o,n.key),d>=11&&n.description&&e.string.preencode(o,n.description)},encode(o,n){const c=(d>=11&&n.key?1:0)|(d>=11&&n.value?2:0)|(d>=11&&n.description?4:0);e.uint.encode(o,c),d>=11&&n.key&&e.string.encode(o,n.key),d>=11&&n.description&&e.string.encode(o,n.description)},decode(o){const n=e.uint.decode(o);return{key:d>=11&&1&n?e.string.decode(o):null,value:d>=11&&!!(2&n),description:d>=11&&4&n?e.string.decode(o):null}}},Ur=e.array(e.frame(Nr)),Jr={preencode(e,o){e.end++,d>=11&&o.flags&&Ur.preencode(e,o.flags)},encode(o,n){const c=d>=11&&n.flags?1:0;e.uint.encode(o,c),d>=11&&n.flags&&Ur.encode(o,n.flags)},decode(o){const n=e.uint.decode(o);return{flags:d>=11&&1&n?Ur.decode(o):null}}},Wr={HttpLink:1,PearLink:2},Gr={preencode(e,d){e.end++},encode(d,o){if(o>2)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Qr=$,Xr={preencode(d,o){Qr.preencode(d,o.header),e.uint.preencode(d,o.value)},encode(d,o){Qr.encode(d,o.header),e.uint.encode(d,o.value)},decode:d=>({header:Qr.decode(d),value:e.uint.decode(d)})},Yr={preencode(d,o){e.uint.preencode(d,o.key),e.uint.preencode(d,o.value)},encode(d,o){e.uint.encode(d,o.key),e.uint.encode(d,o.value)},decode:d=>({key:e.uint.decode(d),value:e.uint.decode(d)})},Zr=$,$r={preencode(o,n){Zr.preencode(o,n.header),e.uint.preencode(o,n.from),e.uint.preencode(o,n.to),o.end++,d>=29&&n.buildType&&xi.preencode(o,n.buildType)},encode(o,n){const c=d>=29&&n.buildType?1:0;Zr.encode(o,n.header),e.uint.encode(o,n.from),e.uint.encode(o,n.to),e.uint.encode(o,c),d>=29&&n.buildType&&xi.encode(o,n.buildType)},decode(o){const n=Zr.decode(o),c=e.uint.decode(o),r=e.uint.decode(o),t=o.start<o.end?e.uint.decode(o):0;return{header:n,from:c,to:r,buildType:d>=29&&1&t?xi.decode(o):null}}},_r={RoomType:1,IsExperimental:2,IsJoiningDisabled:3,IsAppendingDisabled:4,IsCallingDisabled:5,IsMembershipEventsDisabled:6,IsAttachmentsDisabled:7,IsLinksDisabled:8,IsRoomInviteHidden:9},et={preencode(e,d){e.end++},encode(d,o){if(o>9)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},dt=We,ot={preencode(o,n){o.end++,d>=16&&n.nodes&&dt.preencode(o,n.nodes),d>=24&&n.concurrency&&e.uint.preencode(o,n.concurrency),d>=24&&n.maxWindow&&e.uint.preencode(o,n.maxWindow),d>=24&&n.randomPunchInterval&&e.uint.preencode(o,n.randomPunchInterval),d>=24&&n.connectionKeepAlive&&e.uint.preencode(o,n.connectionKeepAlive)},encode(o,n){const c=(d>=16&&n.nodes?1:0)|(d>=24&&n.concurrency?2:0)|(d>=24&&n.maxWindow?4:0)|(d>=24&&n.randomPunchInterval?8:0)|(d>=24&&n.connectionKeepAlive?16:0);e.uint.encode(o,c),d>=16&&n.nodes&&dt.encode(o,n.nodes),d>=24&&n.concurrency&&e.uint.encode(o,n.concurrency),d>=24&&n.maxWindow&&e.uint.encode(o,n.maxWindow),d>=24&&n.randomPunchInterval&&e.uint.encode(o,n.randomPunchInterval),d>=24&&n.connectionKeepAlive&&e.uint.encode(o,n.connectionKeepAlive)},decode(o){const n=e.uint.decode(o);return{nodes:d>=16&&1&n?dt.decode(o):null,concurrency:d>=24&&2&n?e.uint.decode(o):0,maxWindow:d>=24&&4&n?e.uint.decode(o):0,randomPunchInterval:d>=24&&8&n?e.uint.decode(o):0,connectionKeepAlive:d>=24&&16&n?e.uint.decode(o):0}}},nt={en:"en",it:"it",ru:"ru",es:"es",de:"de"},ct={preencode(e,d){e.end++},encode(d,o){switch(o){case"en":e.uint.encode(d,1);break;case"it":e.uint.encode(d,2);break;case"ru":e.uint.encode(d,3);break;case"es":e.uint.encode(d,4);break;case"de":e.uint.encode(d,5);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"en";case 2:return"it";case 3:return"ru";case 4:return"es";case 5:return"de";default:return null}}},rt=Fd,tt={preencode(d,o){rt.preencode(d,o.range),ct.preencode(d,o.language),e.string.preencode(d,o.text)},encode(d,o){rt.encode(d,o.range),ct.encode(d,o.language),e.string.encode(d,o.text)},decode:d=>({range:rt.decode(d),language:ct.decode(d),text:e.string.decode(d)})},it={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.count)},encode(d,o){e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.count)},decode:d=>({roomKey:e.fixed32.decode(d),count:e.uint.decode(d)})},at={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.key)},decode:d=>({deviceKey:e.fixed32.decode(d),key:e.fixed32.decode(d)})},st=$,lt={preencode(d,o){st.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){st.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:st.decode(d),key:e.fixed32.decode(d)})},pt=$,ut={preencode(d,o){pt.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){pt.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:pt.decode(d),key:e.fixed32.decode(d)})},ft={Flag:1},mt={preencode(e,d){e.end++},encode(d,o){if(o>1)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},yt={preencode(d,o){uo.preencode(d,o.id),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),mt.preencode(d,o.label)},encode(d,o){uo.encode(d,o.id),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),mt.encode(d,o.label)},decode:d=>({id:uo.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),label:mt.decode(d)})},bt=$,xt={preencode(e,d){bt.preencode(e,d.header),n.preencode(e,d.oplog),mt.preencode(e,d.label)},encode(e,d){bt.encode(e,d.header),n.encode(e,d.oplog),mt.encode(e,d.label)},decode:e=>({header:bt.decode(e),oplog:n.decode(e),label:mt.decode(e)})},vt=$,gt={preencode(e,d){vt.preencode(e,d.header),n.preencode(e,d.oplog),mt.preencode(e,d.label)},encode(e,d){vt.encode(e,d.header),n.encode(e,d.oplog),mt.encode(e,d.label)},decode:e=>({header:vt.decode(e),oplog:n.decode(e),label:mt.decode(e)})},kt={preencode(d,o){mt.preencode(d,o.label),e.uint.preencode(d,o.count)},encode(d,o){mt.encode(d,o.label),e.uint.encode(d,o.count)},decode:d=>({label:mt.decode(d),count:e.uint.decode(d)})},Kt=e.array(e.frame(kt)),ht={preencode(o,n){uo.preencode(o,n.id),e.uint.preencode(o,n.total),Kt.preencode(o,n.labels),e.uint.preencode(o,n.editedAt),o.end++,d>=24&&n.flagsClock&&e.uint.preencode(o,n.flagsClock),d>=24&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(d>=24&&n.flagsClock?1:0)|(d>=24&&n.version?2:0)|(d>=25&&n.isDeleted?4:0);uo.encode(o,n.id),e.uint.encode(o,n.total),Kt.encode(o,n.labels),e.uint.encode(o,n.editedAt),e.uint.encode(o,c),d>=24&&n.flagsClock&&e.uint.encode(o,n.flagsClock),d>=24&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=uo.decode(o),c=e.uint.decode(o),r=Kt.decode(o),t=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{id:n,total:c,labels:r,editedAt:t,flagsClock:d>=24&&1&i?e.uint.decode(o):0,version:d>=24&&2&i?e.uint.decode(o):0,isDeleted:d>=25&&!!(4&i)}}},wt=$,Rt={preencode(d,o){wt.preencode(d,o.header),e.uint.preencode(d,o.length)},encode(d,o){wt.encode(d,o.header),e.uint.encode(d,o.length)},decode:d=>({header:wt.decode(d),length:e.uint.decode(d)})},Pt={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.length)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.length)},decode:d=>({memberKey:e.fixed32.decode(d),length:e.uint.decode(d)})},Tt=Z,At={preencode(o,n){o.end++,d>=33&&n.profileSnoozeTime&&e.uint.preencode(o,n.profileSnoozeTime)},encode(o,n){const c=(d>=19&&n.disableReadReceipts?1:0)|(d>=31&&n.stripAttachmentMetadata?2:0)|(d>=33&&n.profileSnoozeTime?4:0);e.uint.encode(o,c),d>=33&&n.profileSnoozeTime&&e.uint.encode(o,n.profileSnoozeTime)},decode(o){const n=e.uint.decode(o);return{disableReadReceipts:d>=19&&!!(1&n),stripAttachmentMetadata:d>=31&&!!(2&n),profileSnoozeTime:d>=33&&4&n?e.uint.decode(o):0}}},Mt={disableReadReceipts:"disableReadReceipts",stripAttachmentMetadata:"stripAttachmentMetadata",profileSnoozeTime:"profileSnoozeTime"},St={preencode(e,d){e.end++},encode(d,o){switch(o){case"disableReadReceipts":e.uint.encode(d,1);break;case"stripAttachmentMetadata":e.uint.encode(d,2);break;case"profileSnoozeTime":e.uint.encode(d,3);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"disableReadReceipts";case 2:return"stripAttachmentMetadata";case 3:return"profileSnoozeTime";default:return null}}},It=$,Ct=e.frame(At),Vt={preencode(e,d){It.preencode(e,d.header),St.preencode(e,d.key),Ct.preencode(e,d.settings)},encode(e,d){It.encode(e,d.header),St.encode(e,d.key),Ct.encode(e,d.settings)},decode:e=>({header:It.decode(e),key:St.decode(e),settings:Ct.decode(e)})},Ht={preencode(o,n){o.end++,d>=20&&n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=23&&n.coreKey&&e.fixed32.preencode(o,n.coreKey)},encode(o,n){const c=(d>=20&&n.roomKey?1:0)|(d>=23&&n.coreKey?2:0);e.uint.encode(o,c),d>=20&&n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=23&&n.coreKey&&e.fixed32.encode(o,n.coreKey)},decode(o){const n=e.uint.decode(o);return{roomKey:d>=20&&1&n?e.fixed32.decode(o):null,coreKey:d>=23&&2&n?e.fixed32.decode(o):null}}},Ft=e.frame(Ht),Dt={preencode(o,n){e.string.preencode(o,n.code),e.string.preencode(o,n.message),e.string.preencode(o,n.stack),e.uint.preencode(o,n.timestamp),o.end++,d>=20&&n.details&&Ft.preencode(o,n.details)},encode(o,n){const c=d>=20&&n.details?1:0;e.string.encode(o,n.code),e.string.encode(o,n.message),e.string.encode(o,n.stack),e.uint.encode(o,n.timestamp),e.uint.encode(o,c),d>=20&&n.details&&Ft.encode(o,n.details)},decode(o){const n=e.string.decode(o),c=e.string.decode(o),r=e.string.decode(o),t=e.uint.decode(o),i=e.uint.decode(o);return{code:n,message:c,stack:r,timestamp:t,details:d>=20&&1&i?Ft.decode(o):null}}},Lt={RESUME:1,WAKEUP:2,PRESUSPEND:3,SUSPEND:4},jt={preencode(e,d){e.end++},encode(d,o){if(o>4)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},qt={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.total)},encode(d,o){e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.total)},decode:d=>({roomKey:e.fixed32.decode(d),total:e.uint.decode(d)})},Bt={Flag:1},Et={preencode(e,d){e.end++},encode(d,o){if(o>1)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},zt={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),Et.preencode(d,o.label)},encode(d,o){e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),Et.encode(d,o.label)},decode:d=>({key:e.fixed32.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),label:Et.decode(d)})},Ot=$,Nt={preencode(d,o){Ot.preencode(d,o.header),e.fixed32.preencode(d,o.key),Et.preencode(d,o.label)},encode(d,o){Ot.encode(d,o.header),e.fixed32.encode(d,o.key),Et.encode(d,o.label)},decode:d=>({header:Ot.decode(d),key:e.fixed32.decode(d),label:Et.decode(d)})},Ut={preencode(d,o){Et.preencode(d,o.label),e.uint.preencode(d,o.count)},encode(d,o){Et.encode(d,o.label),e.uint.encode(d,o.count)},decode:d=>({label:Et.decode(d),count:e.uint.decode(d)})},Jt=e.array(e.frame(Ut)),Wt={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.total),Jt.preencode(d,o.labels),e.uint.preencode(d,o.editedAt),e.uint.preencode(d,o.flagsClock)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.total),Jt.encode(d,o.labels),e.uint.encode(d,o.editedAt),e.uint.encode(d,o.flagsClock)},decode:d=>({key:e.fixed32.decode(d),total:e.uint.decode(d),labels:Jt.decode(d),editedAt:e.uint.decode(d),flagsClock:e.uint.decode(d)})},Gt={preencode(d,o){e.float64.preencode(d,o.latitude),e.float64.preencode(d,o.longitude)},encode(d,o){e.float64.encode(d,o.latitude),e.float64.encode(d,o.longitude)},decode:d=>({latitude:e.float64.decode(d),longitude:e.float64.decode(d)})},Qt=$,Xt={preencode(d,o){Qt.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.fromDeviceKey)},encode(d,o){Qt.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.fromDeviceKey)},decode:d=>({header:Qt.decode(d),deviceKey:e.fixed32.decode(d),fromDeviceKey:e.fixed32.decode(d)})},Yt=$,Zt=X,$t={preencode(o,n){Yt.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),e.buffer.preencode(o,n.encryptionKey),o.end++,d>=28&&n.streams&&Zt.preencode(o,n.streams),d>=28&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=28&&n.version&&e.uint.preencode(o,n.version),d>=36&&n.streamInputs&&ul.preencode(o,n.streamInputs),d>=36&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey)},encode(o,n){const c=(d>=28&&n.streams?1:0)|(d>=28&&n.discoveryKey?2:0)|(d>=28&&n.version?4:0)|(d>=36&&n.streamInputs?8:0)|(d>=36&&n.swarmKey?16:0);Yt.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,c),d>=28&&n.streams&&Zt.encode(o,n.streams),d>=28&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=28&&n.version&&e.uint.encode(o,n.version),d>=36&&n.streamInputs&&ul.encode(o,n.streamInputs),d>=36&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey)},decode(o){const n=Yt.decode(o),c=e.fixed32.decode(o),r=e.buffer.decode(o),t=e.uint.decode(o);return{header:n,callKey:c,encryptionKey:r,streams:d>=28&&1&t?Zt.decode(o):null,discoveryKey:d>=28&&2&t?e.fixed32.decode(o):null,version:d>=28&&4&t?e.uint.decode(o):0,streamInputs:d>=36&&8&t?ul.decode(o):null,swarmKey:d>=36&&16&t?e.fixed32.decode(o):null}}},_t=$,ei=X,di={preencode(o,n){_t.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),o.end++,d>=28&&n.streams&&ei.preencode(o,n.streams),d>=36&&n.streamInputs&&fl.preencode(o,n.streamInputs),d>=36&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey)},encode(o,n){const c=(d>=28&&n.streams?1:0)|(d>=36&&n.streamInputs?2:0)|(d>=36&&n.swarmKey?4:0);_t.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.uint.encode(o,c),d>=28&&n.streams&&ei.encode(o,n.streams),d>=36&&n.streamInputs&&fl.encode(o,n.streamInputs),d>=36&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey)},decode(o){const n=_t.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{header:n,callKey:c,streams:d>=28&&1&r?ei.decode(o):null,streamInputs:d>=36&&2&r?fl.decode(o):null,swarmKey:d>=36&&4&r?e.fixed32.decode(o):null}}},oi=$,ni={preencode(d,o){oi.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){oi.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:oi.decode(d),callKey:e.fixed32.decode(d)})},ci=$,ri={preencode(d,o){ci.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){ci.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:ci.decode(d),callKey:e.fixed32.decode(d)})},ti=$,ii={preencode(o,n){ti.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.streamKey),o.end++,d>=36&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=36&&n.type&&e.string.preencode(o,n.type)},encode(o,n){const c=(d>=36&&n.mediaStreamId?1:0)|(d>=36&&n.type?2:0)|(d>=36&&n.muted?4:0);ti.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.streamKey),e.uint.encode(o,c),d>=36&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=36&&n.type&&e.string.encode(o,n.type)},decode(o){const n=ti.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=o.start<o.end?e.uint.decode(o):0;return{header:n,callKey:c,streamKey:r,mediaStreamId:d>=36&&1&t?e.string.decode(o):null,type:d>=36&&2&t?e.string.decode(o):null,muted:d>=36&&!!(4&t)}}},ai=$,si={preencode(d,o){ai.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.streamKey)},encode(d,o){ai.encode(d,o.header),e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.streamKey)},decode:d=>({header:ai.decode(d),callKey:e.fixed32.decode(d),streamKey:e.fixed32.decode(d)})},li={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.buffer.preencode(o,n.encryptionKey),e.uint.preencode(o,n.createdAt),o.end++,d>=28&&n.endedAt&&e.uint.preencode(o,n.endedAt),d>=28&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=28&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(d>=28&&n.endedAt?1:0)|(d>=28&&n.discoveryKey?2:0)|(d>=28&&n.version?4:0);e.fixed32.encode(o,n.callKey),e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=28&&n.endedAt&&e.uint.encode(o,n.endedAt),d>=28&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=28&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=e.fixed32.decode(o),c=e.buffer.decode(o),r=e.uint.decode(o),t=e.uint.decode(o);return{callKey:n,encryptionKey:c,createdAt:r,endedAt:d>=28&&1&t?e.uint.decode(o):0,discoveryKey:d>=28&&2&t?e.fixed32.decode(o):null,version:d>=28&&4&t?e.uint.decode(o):0}}},pi={preencode(d,o){e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.createdAt)},encode(d,o){e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.createdAt)},decode:d=>({callKey:e.fixed32.decode(d),memberKey:e.fixed32.decode(d),createdAt:e.uint.decode(d)})},ui={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.deviceKey),e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.createdAt),o.end++,d>=28&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),d>=32&&n.lastHeartbeatAt&&e.uint.preencode(o,n.lastHeartbeatAt)},encode(o,n){const c=(d>=28&&n.swarmKey?1:0)|(d>=32&&n.lastHeartbeatAt?2:0)|(d>=33&&n.isRecording?4:0);e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.deviceKey),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=28&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey),d>=32&&n.lastHeartbeatAt&&e.uint.encode(o,n.lastHeartbeatAt)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o),i=e.uint.decode(o);return{callKey:n,deviceKey:c,memberKey:r,createdAt:t,swarmKey:d>=28&&1&i?e.fixed32.decode(o):null,lastHeartbeatAt:d>=32&&2&i?e.uint.decode(o):0,isRecording:d>=33&&!!(4&i)}}},fi={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.deviceKey),e.buffer.preencode(o,n.streamKey),e.uint.preencode(o,n.createdAt),o.end++,d>=36&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=36&&n.type&&e.string.preencode(o,n.type),d>=36&&n.statusKey&&e.uint.preencode(o,n.statusKey)},encode(o,n){const c=(d>=36&&n.mediaStreamId?1:0)|(d>=36&&n.type?2:0)|(d>=36&&n.statusKey?4:0);e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.deviceKey),e.buffer.encode(o,n.streamKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=36&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=36&&n.type&&e.string.encode(o,n.type),d>=36&&n.statusKey&&e.uint.encode(o,n.statusKey)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.buffer.decode(o),t=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{callKey:n,deviceKey:c,streamKey:r,createdAt:t,mediaStreamId:d>=36&&1&i?e.string.decode(o):null,type:d>=36&&2&i?e.string.decode(o):null,statusKey:d>=36&&4&i?e.uint.decode(o):0}}},mi={preencode(o,n){e.fixed32.preencode(o,n.callKey),o.end++,d>=28&&n.selfDeviceKey&&e.fixed32.preencode(o,n.selfDeviceKey),d>=36&&n.createdAt&&e.uint.preencode(o,n.createdAt)},encode(o,n){const c=(d>=28&&n.selfDeviceKey?1:0)|(d>=36&&n.createdAt?2:0);e.fixed32.encode(o,n.callKey),e.uint.encode(o,c),d>=28&&n.selfDeviceKey&&e.fixed32.encode(o,n.selfDeviceKey),d>=36&&n.createdAt&&e.uint.encode(o,n.createdAt)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o);return{callKey:n,selfDeviceKey:d>=28&&1&c?e.fixed32.decode(o):null,createdAt:d>=36&&2&c?e.uint.decode(o):0}}},yi={preencode(d,o){e.uint.preencode(d,o.lastCleared)},encode(d,o){e.uint.encode(d,o.lastCleared)},decode:d=>({lastCleared:e.uint.decode(d)})},bi={Nightly:"Nightly",Internal:"Internal",Production:"Production"},xi={preencode(e,d){e.end++},encode(d,o){switch(o){case"Nightly":e.uint.encode(d,1);break;case"Internal":e.uint.encode(d,2);break;case"Production":e.uint.encode(d,3);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"Nightly";case 2:return"Internal";case 3:return"Production";default:return null}}},vi=$,gi={preencode(e,d){vi.preencode(e,d.header)},encode(e,d){vi.encode(e,d.header)},decode:e=>({header:vi.decode(e)})},ki=$,Ki={preencode(e,d){ki.preencode(e,d.header)},encode(e,d){ki.encode(e,d.header)},decode:e=>({header:ki.decode(e)})},hi={preencode(o,n){xi.preencode(o,n.buildType),o.end++,d>=30&&n.latestOfflineAbi&&e.uint.preencode(o,n.latestOfflineAbi)},encode(o,n){const c=d>=30&&n.latestOfflineAbi?1:0;xi.encode(o,n.buildType),e.uint.encode(o,c),d>=30&&n.latestOfflineAbi&&e.uint.encode(o,n.latestOfflineAbi)},decode(o){const n=xi.decode(o),c=o.start<o.end?e.uint.decode(o):0;return{buildType:n,latestOfflineAbi:d>=30&&1&c?e.uint.decode(o):0}}},wi=$,Ri={preencode(d,o){wi.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),e.buffer.preencode(d,o.deviceProof),e.buffer.preencode(d,o.writerProof)},encode(d,o){wi.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.buffer.encode(d,o.deviceProof),e.buffer.encode(d,o.writerProof)},decode:d=>({header:wi.decode(d),deviceKey:e.fixed32.decode(d),deviceProof:e.buffer.decode(d),writerProof:e.buffer.decode(d)})},Pi={preencode(o,n){o.end++,d>=31&&n.otaResyncPrivateProfileBump&&e.uint.preencode(o,n.otaResyncPrivateProfileBump)},encode(o,n){const c=d>=31&&n.otaResyncPrivateProfileBump?1:0;e.uint.encode(o,c),d>=31&&n.otaResyncPrivateProfileBump&&e.uint.encode(o,n.otaResyncPrivateProfileBump)},decode(o){const n=e.uint.decode(o);return{otaResyncPrivateProfileBump:d>=31&&1&n?e.uint.decode(o):0}}},Ti={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.buffer.preencode(d,o.proof),e.uint.preencode(d,o.createdAt)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.buffer.encode(d,o.proof),e.uint.encode(d,o.createdAt)},decode:d=>({deviceKey:e.fixed32.decode(d),proof:e.buffer.decode(d),createdAt:e.uint.decode(d)})},Ai=$,Mi={preencode(d,o){Ai.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Ai.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Ai.decode(d),callKey:e.fixed32.decode(d)})},Si=$,Ii={preencode(d,o){Si.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.deviceKey)},encode(d,o){Si.encode(d,o.header),e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.deviceKey)},decode:d=>({header:Si.decode(d),callKey:e.fixed32.decode(d),deviceKey:e.fixed32.decode(d)})},Ci=e.frame(ht),Vi=e.array(e.frame(yt)),Hi={preencode(e,d){Ci.preencode(e,d.digest),Vi.preencode(e,d.mine)},encode(e,d){Ci.encode(e,d.digest),Vi.encode(e,d.mine)},decode:e=>({digest:Ci.decode(e),mine:Vi.decode(e)})},Fi=$,Di={preencode(d,o){Fi.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Fi.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Fi.decode(d),callKey:e.fixed32.decode(d)})},Li=$,ji={preencode(d,o){Li.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Li.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Li.decode(d),callKey:e.fixed32.decode(d)})},qi={preencode(o,n){o.end++,d>=33&&n.profileSnoozeTime&&e.uint.preencode(o,n.profileSnoozeTime)},encode(o,n){const c=(d>=33&&n.disableReadReceipts?1:0)|(d>=33&&n.stripAttachmentMetadata?2:0)|(d>=33&&n.profileSnoozeTime?4:0);e.uint.encode(o,c),d>=33&&n.profileSnoozeTime&&e.uint.encode(o,n.profileSnoozeTime)},decode(o){const n=e.uint.decode(o);return{disableReadReceipts:d>=33&&!!(1&n),stripAttachmentMetadata:d>=33&&!!(2&n),profileSnoozeTime:d>=33&&4&n?e.uint.decode(o):0}}},Bi={preencode(o,n){o.end++,d>=33&&n.maxPeers&&e.uint.preencode(o,n.maxPeers)},encode(o,n){const c=d>=33&&n.maxPeers?1:0;e.uint.encode(o,c),d>=33&&n.maxPeers&&e.uint.encode(o,n.maxPeers)},decode(o){const n=e.uint.decode(o);return{maxPeers:d>=33&&1&n?e.uint.decode(o):0}}},Ei=$,zi={preencode(e,d){Ei.preencode(e,d.header),n.preencode(e,d.oplog)},encode(e,d){Ei.encode(e,d.header),n.encode(e,d.oplog)},decode:e=>({header:Ei.decode(e),oplog:n.decode(e)})},Oi=$,Ni={preencode(e,d){Oi.preencode(e,d.header)},encode(e,d){Oi.encode(e,d.header)},decode:e=>({header:Oi.decode(e)})},Ui={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.timestamp)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.timestamp)},decode:d=>({memberKey:e.fixed32.decode(d),timestamp:e.uint.decode(d)})},Ji=$,Wi={preencode(o,n){Ji.preencode(o,n.header),e.fixed32.preencode(o,n.memberKey),o.end++,d>=34&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=d>=34&&n.alias?1:0;Ji.encode(o,n.header),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,c),d>=34&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=Ji.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{header:n,memberKey:c,alias:d>=34&&1&r?e.string.decode(o):null}}},Gi={preencode(d,o){e.uint.preencode(d,o.streams)},encode(d,o){e.uint.encode(d,o.streams)},decode:d=>({streams:e.uint.decode(d)})},Qi={preencode(d,o){e.fixed32.preencode(d,o.streamKey),e.string.preencode(d,o.mediaStreamId),e.string.preencode(d,o.type),d.end++},encode(o,n){const c=d>=36&&n.muted?1:0;e.fixed32.encode(o,n.streamKey),e.string.encode(o,n.mediaStreamId),e.string.encode(o,n.type),e.uint.encode(o,c)},decode(o){const n=e.fixed32.decode(o),c=e.string.decode(o),r=e.string.decode(o),t=e.uint.decode(o);return{streamKey:n,mediaStreamId:c,type:r,muted:d>=36&&!!(1&t)}}},Xi=$,Yi={preencode(d,o){Xi.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.streamKey),d.end++},encode(o,n){const c=d>=36&&n.muted?1:0;Xi.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.streamKey),e.uint.encode(o,c)},decode(o){const n=Xi.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o);return{header:n,callKey:c,streamKey:r,muted:d>=36&&!!(1&t)}}},Zi={preencode(d,o){e.uint.preencode(d,o.statusKey),d.end++},encode(o,n){const c=d>=36&&n.muted?1:0;e.uint.encode(o,n.statusKey),e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o),c=e.uint.decode(o);return{statusKey:n,muted:d>=36&&!!(1&c)}}},$i={preencode(n,c){e.fixed32.preencode(n,c.key),n.end++,d>=37&&c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),d>=37&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=(d>=37&&c.encryptionKey?1:0)|(d>=37&&c.bootFrom?2:0);e.fixed32.encode(n,c.key),e.uint.encode(n,r),d>=37&&c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),d>=37&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.uint.decode(n);return{key:c,encryptionKey:d>=37&&1&r?e.buffer.decode(n):null,bootFrom:d>=37&&2&r?o.decode(n):null}}},_i={preencode(d,o){e.fixed32.preencode(d,o.hash)},encode(d,o){e.fixed32.encode(d,o.hash)},decode:d=>({hash:e.fixed32.decode(d)})},ea={preencode(d,o){e.fixed32.preencode(d,o.hash),e.buffer.preencode(d,o.data)},encode(d,o){e.fixed32.encode(d,o.hash),e.buffer.encode(d,o.data)},decode:d=>({hash:e.fixed32.decode(d),data:e.buffer.decode(d)})},da={preencode(n,c){o.preencode(n,c.autobeeMigrationHead),n.end++,d>=37&&c.legacyViewHead&&o.preencode(n,c.legacyViewHead),d>=37&&c.dbViewHead&&o.preencode(n,c.dbViewHead),d>=37&&c.blobsViewHead&&o.preencode(n,c.blobsViewHead),e.uint.preencode(n,c.createdAt)},encode(n,c){const r=(d>=37&&c.legacyViewHead?1:0)|(d>=37&&c.dbViewHead?2:0)|(d>=37&&c.blobsViewHead?4:0);o.encode(n,c.autobeeMigrationHead),e.uint.encode(n,r),d>=37&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=37&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=37&&c.blobsViewHead&&o.encode(n,c.blobsViewHead),e.uint.encode(n,c.createdAt)},decode(n){const c=o.decode(n),r=e.uint.decode(n);return{autobeeMigrationHead:c,legacyViewHead:d>=37&&1&r?o.decode(n):null,dbViewHead:d>=37&&2&r?o.decode(n):null,blobsViewHead:d>=37&&4&r?o.decode(n):null,createdAt:e.uint.decode(n)}}},oa=$,na={preencode(e,n){oa.preencode(e,n.header),o.preencode(e,n.head),e.end++,d>=37&&n.legacyViewHead&&o.preencode(e,n.legacyViewHead),d>=37&&n.dbViewHead&&o.preencode(e,n.dbViewHead),d>=37&&n.blobsViewHead&&o.preencode(e,n.blobsViewHead)},encode(n,c){const r=(d>=37&&c.legacyViewHead?1:0)|(d>=37&&c.dbViewHead?2:0)|(d>=37&&c.blobsViewHead?4:0);oa.encode(n,c.header),o.encode(n,c.head),e.uint.encode(n,r),d>=37&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=37&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=37&&c.blobsViewHead&&o.encode(n,c.blobsViewHead)},decode(n){const c=oa.decode(n),r=o.decode(n),t=e.uint.decode(n);return{header:c,head:r,legacyViewHead:d>=37&&1&t?o.decode(n):null,dbViewHead:d>=37&&2&t?o.decode(n):null,blobsViewHead:d>=37&&4&t?o.decode(n):null}}},ca={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.fixed32.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.seed),n.end++,d>=37&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=d>=37&&c.bootFrom?1:0;e.fixed32.encode(n,c.roomKey),e.fixed32.encode(n,c.encryptionKey),e.fixed32.encode(n,c.seed),e.uint.encode(n,r),d>=37&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.fixed32.decode(n),t=e.fixed32.decode(n),i=e.uint.decode(n);return{roomKey:c,encryptionKey:r,seed:t,bootFrom:d>=37&&1&i?o.decode(n):null}}},ra=id,ta={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.fixed32.preencode(d,o.deviceKey),e.uint.preencode(d,o.deviceLength),e.uint.preencode(d,o.clock),ra.preencode(d,o.status)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,o.deviceLength),e.uint.encode(d,o.clock),ra.encode(d,o.status)},decode:d=>({memberKey:e.fixed32.decode(d),deviceKey:e.fixed32.decode(d),deviceLength:e.uint.decode(d),clock:e.uint.decode(d),status:ra.decode(d)})},ia={preencode(d,o){e.fixed32.preencode(d,o.hash),e.buffer.preencode(d,o.blob)},encode(d,o){e.fixed32.encode(d,o.hash),e.buffer.encode(d,o.blob)},decode:d=>({hash:e.fixed32.decode(d),blob:e.buffer.decode(d)})},aa=In,sa=Cn,la=gn,pa={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),aa.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,d>=37&&c.initiator&&o.preencode(n,c.initiator),d>=37&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=37&&c.identitySwap&&sa.preencode(n,c.identitySwap),d>=37&&c.identitySwapV2&&la.preencode(n,c.identitySwapV2),d>=37&&c.contact&&e.fixed32.preencode(n,c.contact)},encode(n,c){const r=(d>=37&&c.initiator?1:0)|(d>=37&&c.bootFrom?2:0)|(d>=37&&c.identitySwap?4:0)|(d>=37&&c.identitySwapV2?8:0)|(d>=37&&c.contact?16:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),aa.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,r),d>=37&&c.initiator&&o.encode(n,c.initiator),d>=37&&c.bootFrom&&o.encode(n,c.bootFrom),d>=37&&c.identitySwap&&sa.encode(n,c.identitySwap),d>=37&&c.identitySwapV2&&la.encode(n,c.identitySwapV2),d>=37&&c.contact&&e.fixed32.encode(n,c.contact)},decode(n){const c=e.fixed32.decode(n),r=e.buffer.decode(n),t=e.fixed32.decode(n),i=aa.decode(n),a=e.uint.decode(n),s=e.uint.decode(n);return{roomKey:c,encryptionKey:r,mailbox:t,status:i,clock:a,initiator:d>=37&&1&s?o.decode(n):null,bootFrom:d>=37&&2&s?o.decode(n):null,identitySwap:d>=37&&4&s?sa.decode(n):null,identitySwapV2:d>=37&&8&s?la.decode(n):null,contact:d>=37&&16&s?e.fixed32.decode(n):null}}},ua=$,fa={preencode(n,c){ua.preencode(n,c.header),e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),n.end++,d>=37&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=37&&c.initiator&&o.preencode(n,c.initiator),d>=37&&c.dm&&e.fixed32.preencode(n,c.dm)},encode(n,c){const r=(d>=37&&c.bootFrom?1:0)|(d>=37&&c.initiator?2:0)|(d>=37&&c.dm?4:0)|(d>=37&&c.isReadOnly?8:0);ua.encode(n,c.header),e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),e.uint.encode(n,r),d>=37&&c.bootFrom&&o.encode(n,c.bootFrom),d>=37&&c.initiator&&o.encode(n,c.initiator),d>=37&&c.dm&&e.fixed32.encode(n,c.dm)},decode(n){const c=ua.decode(n),r=e.fixed32.decode(n),t=e.buffer.decode(n),i=e.fixed32.decode(n),a=e.uint.decode(n);return{header:c,roomKey:r,encryptionKey:t,mailbox:i,bootFrom:d>=37&&1&a?o.decode(n):null,initiator:d>=37&&2&a?o.decode(n):null,dm:d>=37&&4&a?e.fixed32.decode(n):null,isReadOnly:d>=37&&!!(8&a)}}},ma={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),n.end++,d>=37&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=37&&c.initiator&&o.preencode(n,c.initiator)},encode(n,c){const r=(d>=37&&c.bootFrom?1:0)|(d>=37&&c.initiator?2:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.uint.encode(n,r),d>=37&&c.bootFrom&&o.encode(n,c.bootFrom),d>=37&&c.initiator&&o.encode(n,c.initiator)},decode(n){const c=e.fixed32.decode(n),r=e.buffer.decode(n),t=e.uint.decode(n);return{roomKey:c,encryptionKey:r,bootFrom:d>=37&&1&t?o.decode(n):null,initiator:d>=37&&2&t?o.decode(n):null}}},ya={preencode(d,o){e.fixed32.preencode(d,o.roomKey),ml.preencode(d,o.head),e.uint.preencode(d,o.timestamp),d.end++},encode(o,n){const c=d>=37&&n.incremental?1:0;e.fixed32.encode(o,n.roomKey),ml.encode(o,n.head),e.uint.encode(o,n.timestamp),e.uint.encode(o,c)},decode(o){const n=e.fixed32.decode(o),c=ml.decode(o),r=e.uint.decode(o),t=e.uint.decode(o);return{roomKey:n,head:c,timestamp:r,incremental:d>=37&&!!(1&t)}}},ba={preencode(o,n){o.end++,d>=37&&n.key&&e.fixed32.preencode(o,n.key),e.uint.preencode(o,n.length)},encode(o,n){const c=d>=37&&n.key?1:0;e.uint.encode(o,c),d>=37&&n.key&&e.fixed32.encode(o,n.key),e.uint.encode(o,n.length)},decode(o){const n=e.uint.decode(o);return{key:d>=37&&1&n?e.fixed32.decode(o):null,length:e.uint.decode(o)}}},xa={preencode(n,c){e.fixed32.preencode(n,c.roomKey),n.end++,d>=37&&c.legacyViewHead&&o.preencode(n,c.legacyViewHead),d>=37&&c.dbViewHead&&o.preencode(n,c.dbViewHead),d>=37&&c.blobsViewHead&&o.preencode(n,c.blobsViewHead),d>=37&&c.autobeeMigrationHead&&o.preencode(n,c.autobeeMigrationHead)},encode(n,c){const r=(d>=37&&c.legacyViewHead?1:0)|(d>=37&&c.dbViewHead?2:0)|(d>=37&&c.blobsViewHead?4:0)|(d>=37&&c.autobeeMigrationHead?8:0);e.fixed32.encode(n,c.roomKey),e.uint.encode(n,r),d>=37&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=37&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=37&&c.blobsViewHead&&o.encode(n,c.blobsViewHead),d>=37&&c.autobeeMigrationHead&&o.encode(n,c.autobeeMigrationHead)},decode(n){const c=e.fixed32.decode(n),r=e.uint.decode(n);return{roomKey:c,legacyViewHead:d>=37&&1&r?o.decode(n):null,dbViewHead:d>=37&&2&r?o.decode(n):null,blobsViewHead:d>=37&&4&r?o.decode(n):null,autobeeMigrationHead:d>=37&&8&r?o.decode(n):null}}},va={preencode(d,o){e.fixed32.preencode(d,o.id),e.fixed32.preencode(d,o.writerKey),e.buffer.preencode(d,o.blindResponse)},encode(d,o){e.fixed32.encode(d,o.id),e.fixed32.encode(d,o.writerKey),e.buffer.encode(d,o.blindResponse)},decode:d=>({id:e.fixed32.decode(d),writerKey:e.fixed32.decode(d),blindResponse:e.buffer.decode(d)})},ga=$,ka={preencode(d,o){ga.preencode(d,o.header),e.buffer.preencode(d,o.blindResponse)},encode(d,o){ga.encode(d,o.header),e.buffer.encode(d,o.blindResponse)},decode:d=>({header:ga.decode(d),blindResponse:e.buffer.decode(d)})},Ka=e.frame(Ac),ha={preencode(o,n){e.string.preencode(o,n.mnemonic),o.end++,d>=39&&n.profileDiscoveryTimeout&&e.uint.preencode(o,n.profileDiscoveryTimeout),d>=39&&n.privateProfileKey&&e.fixed32.preencode(o,n.privateProfileKey),d>=39&&n.identity&&Ka.preencode(o,n.identity)},encode(o,n){const c=(d>=39&&n.profileDiscoveryTimeout?1:0)|(d>=39&&n.privateProfileKey?2:0)|(d>=39&&n.identity?4:0);e.string.encode(o,n.mnemonic),e.uint.encode(o,c),d>=39&&n.profileDiscoveryTimeout&&e.uint.encode(o,n.profileDiscoveryTimeout),d>=39&&n.privateProfileKey&&e.fixed32.encode(o,n.privateProfileKey),d>=39&&n.identity&&Ka.encode(o,n.identity)},decode(o){const n=e.string.decode(o),c=e.uint.decode(o);return{mnemonic:n,profileDiscoveryTimeout:d>=39&&1&c?e.uint.decode(o):0,privateProfileKey:d>=39&&2&c?e.fixed32.decode(o):null,identity:d>=39&&4&c?Ka.decode(o):null}}},wa=hc,Ra={preencode(o,n){e.uint.preencode(o,n.priority),o.end++,n.v3&&wa.preencode(o,n.v3),d>=5&&n.timestamp&&e.uint.preencode(o,n.timestamp)},encode(o,n){const c=(n.v3?1:0)|(d>=3&&n.errored?2:0)|(d>=5&&n.timestamp?4:0);e.uint.encode(o,n.priority),e.uint.encode(o,c),n.v3&&wa.encode(o,n.v3),d>=5&&n.timestamp&&e.uint.encode(o,n.timestamp)},decode(o){const n=e.uint.decode(o),c=e.uint.decode(o);return{roomKey:null,priority:n,v3:1&c?wa.decode(o):null,errored:d>=3&&!!(2&c),timestamp:d>=5&&4&c?e.uint.decode(o):0}}},Pa=Xo,Ta=fo,Aa=ir,Ma=vc,Sa=sr,Ia=lr,Ca=pr,Va=Oo,Ha=$o,Fa=mr,Da=X,La=br,ja=In,qa={preencode(o,n){const c=(n.selfDevice?1:0)|(n.selfMember?2:0)|(n.config?4:0)|(n.identity?8:0)|(n.lastMessage?16:0)|(n.dm?32:0)|(d>=19&&n.readLengths?64:0)|(d>=19&&n.lastMember?128:0)|(d>=21&&n.version?256:0)|(d>=27&&n.preferences?512:0)|(d>=28&&n.activeCall?1024:0)|(d>=32&&n.lastMessageLabels?2048:0)|(d>=33&&n.settings?4096:0)|(d>=37&&n.system?8192:0)|(d>=37&&n.processed?16384:0);e.fixed32.preencode(o,n.discoveryKey),e.buffer.preencode(o,n.encryptionKey),Pa.preencode(o,n.digest),Ta.preencode(o,n.stats),Aa.preencode(o,n.timestamps),e.uint.preencode(o,n.fork),e.uint.preencode(o,n.length),e.fixed32.preencode(o,n.seed),Ma.preencode(o,n.capabilities),Sa.preencode(o,n.status),e.uint.preencode(o,c),n.selfDevice&&Ia.preencode(o,n.selfDevice),n.selfMember&&Ca.preencode(o,n.selfMember),n.config&&Va.preencode(o,n.config),n.identity&&Ha.preencode(o,n.identity),n.lastMessage&&Fa.preencode(o,n.lastMessage),n.dm&&Da.preencode(o,n.dm),d>=19&&n.readLengths&&yl.preencode(o,n.readLengths),d>=19&&n.lastMember&&La.preencode(o,n.lastMember),d>=21&&n.version&&e.uint.preencode(o,n.version),d>=27&&n.preferences&&ja.preencode(o,n.preferences),d>=28&&n.activeCall&&bl.preencode(o,n.activeCall),d>=32&&n.lastMessageLabels&&xl.preencode(o,n.lastMessageLabels),d>=33&&n.settings&&vl.preencode(o,n.settings),d>=37&&n.system&&gl.preencode(o,n.system),d>=37&&n.processed&&kl.preencode(o,n.processed)},encode(o,n){const c=(n.selfDevice?1:0)|(n.selfMember?2:0)|(n.config?4:0)|(n.identity?8:0)|(n.lastMessage?16:0)|(n.dm?32:0)|(d>=19&&n.readLengths?64:0)|(d>=19&&n.lastMember?128:0)|(d>=21&&n.version?256:0)|(d>=27&&n.preferences?512:0)|(d>=28&&n.activeCall?1024:0)|(d>=32&&n.lastMessageLabels?2048:0)|(d>=33&&n.settings?4096:0)|(d>=37&&n.system?8192:0)|(d>=37&&n.processed?16384:0);e.fixed32.encode(o,n.discoveryKey),e.buffer.encode(o,n.encryptionKey),Pa.encode(o,n.digest),Ta.encode(o,n.stats),Aa.encode(o,n.timestamps),e.uint.encode(o,n.fork),e.uint.encode(o,n.length),e.fixed32.encode(o,n.seed),Ma.encode(o,n.capabilities),Sa.encode(o,n.status),e.uint.encode(o,c),n.selfDevice&&Ia.encode(o,n.selfDevice),n.selfMember&&Ca.encode(o,n.selfMember),n.config&&Va.encode(o,n.config),n.identity&&Ha.encode(o,n.identity),n.lastMessage&&Fa.encode(o,n.lastMessage),n.dm&&Da.encode(o,n.dm),d>=19&&n.readLengths&&yl.encode(o,n.readLengths),d>=19&&n.lastMember&&La.encode(o,n.lastMember),d>=21&&n.version&&e.uint.encode(o,n.version),d>=27&&n.preferences&&ja.encode(o,n.preferences),d>=28&&n.activeCall&&bl.encode(o,n.activeCall),d>=32&&n.lastMessageLabels&&xl.encode(o,n.lastMessageLabels),d>=33&&n.settings&&vl.encode(o,n.settings),d>=37&&n.system&&gl.encode(o,n.system),d>=37&&n.processed&&kl.encode(o,n.processed)},decode(o){const n=e.fixed32.decode(o),c=e.buffer.decode(o),r=Pa.decode(o),t=Ta.decode(o),i=Aa.decode(o),a=e.uint.decode(o),s=e.uint.decode(o),l=e.fixed32.decode(o),p=Ma.decode(o),u=Sa.decode(o),f=e.uint.decode(o);return{roomKey:null,discoveryKey:n,encryptionKey:c,digest:r,stats:t,timestamps:i,fork:a,length:s,seed:l,capabilities:p,status:u,selfDevice:1&f?Ia.decode(o):null,selfMember:2&f?Ca.decode(o):null,config:4&f?Va.decode(o):null,identity:8&f?Ha.decode(o):null,lastMessage:16&f?Fa.decode(o):null,dm:32&f?Da.decode(o):null,readLengths:d>=19&&64&f?yl.decode(o):null,lastMember:d>=19&&128&f?La.decode(o):null,version:d>=21&&256&f?e.uint.decode(o):0,preferences:d>=27&&512&f?ja.decode(o):null,activeCall:d>=28&&1024&f?bl.decode(o):null,lastMessageLabels:d>=32&&2048&f?xl.decode(o):null,settings:d>=33&&4096&f?vl.decode(o):null,system:d>=37&&8192&f?gl.decode(o):null,processed:d>=37&&16384&f?kl.decode(o):null}}},Ba=In,Ea={preencode(e,d){Ba.preencode(e,d.status)},encode(e,d){Ba.encode(e,d.status)},decode:e=>({roomKey:null,status:Ba.decode(e)})},za={preencode(o,n){e.fixed32.preencode(o,n.key),o.end++,n.roomKey&&e.fixed32.preencode(o,n.roomKey),n.keyPair&&r.preencode(o,n.keyPair),n.responseKeyPair&&r.preencode(o,n.responseKeyPair),d>=39&&n.activeClock&&e.uint.preencode(o,n.activeClock)},encode(o,n){const c=(n.roomKey?1:0)|(n.keyPair?2:0)|(n.responseKeyPair?4:0)|(d>=38&&n.pending?8:0)|(d>=39&&n.activeClock?16:0);e.fixed32.encode(o,n.key),e.uint.encode(o,c),n.roomKey&&e.fixed32.encode(o,n.roomKey),n.keyPair&&r.encode(o,n.keyPair),n.responseKeyPair&&r.encode(o,n.responseKeyPair),d>=39&&n.activeClock&&e.uint.encode(o,n.activeClock)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o);return{mailbox:null,key:n,roomKey:1&c?e.fixed32.decode(o):null,keyPair:2&c?r.decode(o):null,responseKeyPair:4&c?r.decode(o):null,pending:d>=38&&!!(8&c),activeClock:d>=39&&16&c?e.uint.decode(o):0}}},Oa=le,Na={preencode(e,d){Oa.preencode(e,d.profile)},encode(e,d){Oa.encode(e,d.profile)},decode:e=>({key:null,profile:Oa.decode(e)})},Ua=re,Ja=te,Wa={preencode(d,o){e.fixed32.preencode(d,o.memberKey),Ua.preencode(d,o.status),Kl.preencode(d,o.profile),d.end++,o.invitation&&Ja.preencode(d,o.invitation)},encode(d,o){const n=o.invitation?1:0;e.fixed32.encode(d,o.memberKey),Ua.encode(d,o.status),Kl.encode(d,o.profile),e.uint.encode(d,n),o.invitation&&Ja.encode(d,o.invitation)},decode:d=>({key:null,memberKey:e.fixed32.decode(d),status:Ua.decode(d),profile:Kl.decode(d),invitation:1&e.uint.decode(d)?Ja.decode(d):null})},Ga=lr,Qa={preencode(d,o){e.fixed32.preencode(d,o.roomKey),Ga.preencode(d,o.device)},encode(d,o){e.fixed32.encode(d,o.roomKey),Ga.encode(d,o.device)},decode:d=>({roomKey:e.fixed32.decode(d),device:Ga.decode(d)})},Xa={preencode(o,n){hl.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=32&&n.contactInfo&&wl.preencode(o,n.contactInfo),d>=32&&n.version&&e.uint.preencode(o,n.version),d>=34&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=32&&n.contactInfo?4:0)|(d>=32&&n.version?8:0)|(d>=34&&n.alias?16:0);hl.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=32&&n.contactInfo&&wl.encode(o,n.contactInfo),d>=32&&n.version&&e.uint.encode(o,n.version),d>=34&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=hl.decode(o),c=e.uint.decode(o);return{memberKey:null,status:n,mailbox:1&c?e.fixed32.decode(o):null,roomKey:2&c?e.fixed32.decode(o):null,contactInfo:d>=32&&4&c?wl.decode(o):null,version:d>=32&&8&c?e.uint.decode(o):0,alias:d>=34&&16&c?e.string.decode(o):null}}},Ya=Jc,Za=Wc,$a=Gc,_a=Qc,es=Xc,ds=Yc,os=Zc,ns=$c,cs=_c,rs={preencode(d,o){const n=(o.restoreIdentity?1:0)|(o.createRoom?2:0)|(o.leaveRoom?4:0)|(o.clearRoom?8:0)|(o.joinRoomInvitation?16:0)|(o.joinRoomKeys?32:0)|(o.joinRoomResponse?64:0)|(o.sendContactRequest?128:0)|(o.migrateV2Room?256:0);e.uint.preencode(d,n),o.restoreIdentity&&Ya.preencode(d,o.restoreIdentity),o.createRoom&&Za.preencode(d,o.createRoom),o.leaveRoom&&$a.preencode(d,o.leaveRoom),o.clearRoom&&_a.preencode(d,o.clearRoom),o.joinRoomInvitation&&es.preencode(d,o.joinRoomInvitation),o.joinRoomKeys&&ds.preencode(d,o.joinRoomKeys),o.joinRoomResponse&&os.preencode(d,o.joinRoomResponse),o.sendContactRequest&&ns.preencode(d,o.sendContactRequest),o.migrateV2Room&&cs.preencode(d,o.migrateV2Room)},encode(d,o){const n=(o.restoreIdentity?1:0)|(o.createRoom?2:0)|(o.leaveRoom?4:0)|(o.clearRoom?8:0)|(o.joinRoomInvitation?16:0)|(o.joinRoomKeys?32:0)|(o.joinRoomResponse?64:0)|(o.sendContactRequest?128:0)|(o.migrateV2Room?256:0);e.uint.encode(d,n),o.restoreIdentity&&Ya.encode(d,o.restoreIdentity),o.createRoom&&Za.encode(d,o.createRoom),o.leaveRoom&&$a.encode(d,o.leaveRoom),o.clearRoom&&_a.encode(d,o.clearRoom),o.joinRoomInvitation&&es.encode(d,o.joinRoomInvitation),o.joinRoomKeys&&ds.encode(d,o.joinRoomKeys),o.joinRoomResponse&&os.encode(d,o.joinRoomResponse),o.sendContactRequest&&ns.encode(d,o.sendContactRequest),o.migrateV2Room&&cs.encode(d,o.migrateV2Room)},decode(d){const o=e.uint.decode(d);return{discoveryKey:null,priority:0,timestamp:0,type:0,restoreIdentity:1&o?Ya.decode(d):null,createRoom:2&o?Za.decode(d):null,leaveRoom:4&o?$a.decode(d):null,clearRoom:8&o?_a.decode(d):null,joinRoomInvitation:16&o?es.decode(d):null,joinRoomKeys:32&o?ds.decode(d):null,joinRoomResponse:64&o?os.decode(d):null,sendContactRequest:128&o?ns.decode(d):null,migrateV2Room:256&o?cs.decode(d):null}}},ts={preencode(d,o){e.uint.preencode(d,o.blockLength),e.uint.preencode(d,o.byteOffset),e.uint.preencode(d,o.byteLength)},encode(d,o){e.uint.encode(d,o.blockLength),e.uint.encode(d,o.byteOffset),e.uint.encode(d,o.byteLength)},decode:d=>({blockOffset:0,blockLength:e.uint.decode(d),byteOffset:e.uint.decode(d),byteLength:e.uint.decode(d)})},is={preencode(e,d){a.preencode(e,d.blob)},encode(e,d){a.encode(e,d.blob)},decode:e=>({key:null,blob:a.decode(e)})},as=m,ss=y,ls={preencode(o,n){o.end++,n.inlined&&e.buffer.preencode(o,n.inlined),n.blob&&a.preencode(o,n.blob),n.externalBlob&&as.preencode(o,n.externalBlob),n.externalDrive&&ss.preencode(o,n.externalDrive),d>=37&&n.bee&&_i.preencode(o,n.bee)},encode(o,n){const c=(n.inlined?1:0)|(n.blob?2:0)|(n.externalBlob?4:0)|(n.externalDrive?8:0)|(d>=37&&n.bee?16:0);e.uint.encode(o,c),n.inlined&&e.buffer.encode(o,n.inlined),n.blob&&a.encode(o,n.blob),n.externalBlob&&as.encode(o,n.externalBlob),n.externalDrive&&ss.encode(o,n.externalDrive),d>=37&&n.bee&&_i.encode(o,n.bee)},decode(o){const n=e.uint.decode(o);return{inlined:1&n?e.buffer.decode(o):null,blob:2&n?a.decode(o):null,externalBlob:4&n?as.decode(o):null,externalDrive:8&n?ss.decode(o):null,bee:d>=37&&16&n?_i.decode(o):null}}},ps=x,us=v,fs={preencode(d,o){ps.preencode(d,o.pointer),d.end++,o.metadata&&us.preencode(d,o.metadata),o.preview&&Rl.preencode(d,o.preview),o.hash&&e.fixed32.preencode(d,o.hash)},encode(d,o){const n=(o.metadata?1:0)|(o.preview?2:0)|(o.hash?4:0);ps.encode(d,o.pointer),e.uint.encode(d,n),o.metadata&&us.encode(d,o.metadata),o.preview&&Rl.encode(d,o.preview),o.hash&&e.fixed32.encode(d,o.hash)},decode(d){const o=ps.decode(d),n=e.uint.decode(d);return{pointer:o,metadata:1&n?us.decode(d):null,preview:2&n?Rl.decode(d):null,hash:4&n?e.fixed32.decode(d):null}}},ms=k,ys={preencode(o,n){ms.preencode(o,n.file),e.fixed32.preencode(o,n.roomKey),o.end++,n.encryptionKey&&e.buffer.preencode(o,n.encryptionKey),d>=28&&n.lastAccessed&&e.uint.preencode(o,n.lastAccessed),d>=28&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(n.encryptionKey?1:0)|(n.cleared?2:0)|(n.own?4:0)|(d>=28&&n.lastAccessed?8:0)|(d>=28&&n.version?16:0);ms.encode(o,n.file),e.fixed32.encode(o,n.roomKey),e.uint.encode(o,c),n.encryptionKey&&e.buffer.encode(o,n.encryptionKey),d>=28&&n.lastAccessed&&e.uint.encode(o,n.lastAccessed),d>=28&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=ms.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{file:n,roomKey:c,encryptionKey:1&r?e.buffer.decode(o):null,cleared:!!(2&r),own:!!(4&r),lastAccessed:d>=28&&8&r?e.uint.decode(o):0,version:d>=28&&16&r?e.uint.decode(o):0}}},bs={preencode(d,o){e.uint.preencode(d,o.size)},encode(d,o){e.uint.encode(d,o.size)},decode:d=>({key:null,path:null,version:0,size:e.uint.decode(d)})},xs=m,vs=y,gs={preencode(o,n){o.end++,n.inlined&&e.buffer.preencode(o,n.inlined),n.blob&&a.preencode(o,n.blob),n.externalBlob&&xs.preencode(o,n.externalBlob),n.externalDrive&&vs.preencode(o,n.externalDrive),d>=37&&n.bee&&_i.preencode(o,n.bee)},encode(o,n){const c=(n.inlined?1:0)|(n.blob?2:0)|(n.externalBlob?4:0)|(n.externalDrive?8:0)|(d>=37&&n.bee?16:0);e.uint.encode(o,c),n.inlined&&e.buffer.encode(o,n.inlined),n.blob&&a.encode(o,n.blob),n.externalBlob&&xs.encode(o,n.externalBlob),n.externalDrive&&vs.encode(o,n.externalDrive),d>=37&&n.bee&&_i.encode(o,n.bee)},decode(o){const n=e.uint.decode(o);return{inlined:1&n?e.buffer.decode(o):null,blob:2&n?a.decode(o):null,externalBlob:4&n?xs.decode(o):null,externalDrive:8&n?vs.decode(o):null,bee:d>=37&&16&n?_i.decode(o):null}}},ks=x,Ks=v,hs={preencode(d,o){ks.preencode(d,o.pointer),d.end++,o.metadata&&Ks.preencode(d,o.metadata),o.preview&&Pl.preencode(d,o.preview),o.hash&&e.fixed32.preencode(d,o.hash)},encode(d,o){const n=(o.metadata?1:0)|(o.preview?2:0)|(o.hash?4:0);ks.encode(d,o.pointer),e.uint.encode(d,n),o.metadata&&Ks.encode(d,o.metadata),o.preview&&Pl.encode(d,o.preview),o.hash&&e.fixed32.encode(d,o.hash)},decode(d){const o=ks.decode(d),n=e.uint.decode(d);return{pointer:o,metadata:1&n?Ks.decode(d):null,preview:2&n?Pl.decode(d):null,hash:4&n?e.fixed32.decode(d):null}}},ws=k,Rs={preencode(o,n){ws.preencode(o,n.file),e.fixed32.preencode(o,n.roomKey),o.end++,n.encryptionKey&&e.buffer.preencode(o,n.encryptionKey),d>=28&&n.lastAccessed&&e.uint.preencode(o,n.lastAccessed),d>=28&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(n.encryptionKey?1:0)|(n.cleared?2:0)|(n.own?4:0)|(d>=28&&n.lastAccessed?8:0)|(d>=28&&n.version?16:0);ws.encode(o,n.file),e.fixed32.encode(o,n.roomKey),e.uint.encode(o,c),n.encryptionKey&&e.buffer.encode(o,n.encryptionKey),d>=28&&n.lastAccessed&&e.uint.encode(o,n.lastAccessed),d>=28&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=ws.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{file:n,roomKey:c,encryptionKey:1&r?e.buffer.decode(o):null,cleared:!!(2&r),own:!!(4&r),lastAccessed:d>=28&&8&r?e.uint.decode(o):0,version:d>=28&&16&r?e.uint.decode(o):0}}},Ps={preencode(d,o){e.uint.preencode(d,o.timestamp),d.end++,o.lastSynced&&e.uint.preencode(d,o.lastSynced)},encode(d,o){const n=(o.lastSynced?1:0)|(o.dirty?2:0);e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.lastSynced&&e.uint.encode(d,o.lastSynced)},decode(d){const o=e.uint.decode(d),n=e.uint.decode(d);return{discoveryPublicKey:null,timestamp:o,lastSynced:1&n?e.uint.decode(d):0,dirty:!!(2&n)}}},Ts={preencode(e,d){},encode(e,d){},decode:e=>({key:null,responsePublicKey:null})},As={preencode(o,n){o.end++,d>=10&&n.repairs&&e.uint.preencode(o,n.repairs)},encode(o,n){const c=d>=10&&n.repairs?1:0;e.uint.encode(o,c),d>=10&&n.repairs&&e.uint.encode(o,n.repairs)},decode(o){const n=e.uint.decode(o);return{roomKey:null,repairs:d>=10&&1&n?e.uint.decode(o):0}}},Ms={preencode(d,o){e.uint.preencode(d,o.count)},encode(d,o){e.uint.encode(d,o.count)},decode:d=>({roomKey:null,count:e.uint.decode(d)})},Ss=Ft,Is={preencode(o,n){e.string.preencode(o,n.code),e.string.preencode(o,n.message),e.string.preencode(o,n.stack),o.end++,d>=20&&n.details&&Ss.preencode(o,n.details)},encode(o,n){const c=d>=20&&n.details?1:0;e.string.encode(o,n.code),e.string.encode(o,n.message),e.string.encode(o,n.stack),e.uint.encode(o,c),d>=20&&n.details&&Ss.encode(o,n.details)},decode(o){const n=e.string.decode(o),c=e.string.decode(o),r=e.string.decode(o),t=e.uint.decode(o);return{code:n,message:c,stack:r,timestamp:0,details:d>=20&&1&t?Ss.decode(o):null}}},Cs={preencode(d,o){e.uint.preencode(d,o.total)},encode(d,o){e.uint.encode(d,o.total)},decode:d=>({roomKey:null,total:e.uint.decode(d)})},Vs={preencode(d,o){e.buffer.preencode(d,o.proof),e.uint.preencode(d,o.createdAt)},encode(d,o){e.buffer.encode(d,o.proof),e.uint.encode(d,o.createdAt)},decode:d=>({deviceKey:null,proof:e.buffer.decode(d),createdAt:e.uint.decode(d)})},Hs={preencode(d,o){Tl.preencode(d,o.head),e.uint.preencode(d,o.timestamp),d.end++},encode(o,n){const c=d>=37&&n.incremental?1:0;Tl.encode(o,n.head),e.uint.encode(o,n.timestamp),e.uint.encode(o,c)},decode(o){const n=Tl.decode(o),c=e.uint.decode(o),r=e.uint.decode(o);return{roomKey:null,head:n,timestamp:c,incremental:d>=37&&!!(1&r)}}},Fs={preencode(e,n){e.end++,d>=37&&n.legacyViewHead&&o.preencode(e,n.legacyViewHead),d>=37&&n.dbViewHead&&o.preencode(e,n.dbViewHead),d>=37&&n.blobsViewHead&&o.preencode(e,n.blobsViewHead),d>=37&&n.autobeeMigrationHead&&o.preencode(e,n.autobeeMigrationHead)},encode(n,c){const r=(d>=37&&c.legacyViewHead?1:0)|(d>=37&&c.dbViewHead?2:0)|(d>=37&&c.blobsViewHead?4:0)|(d>=37&&c.autobeeMigrationHead?8:0);e.uint.encode(n,r),d>=37&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=37&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=37&&c.blobsViewHead&&o.encode(n,c.blobsViewHead),d>=37&&c.autobeeMigrationHead&&o.encode(n,c.autobeeMigrationHead)},decode(n){const c=e.uint.decode(n);return{roomKey:null,legacyViewHead:d>=37&&1&c?o.decode(n):null,dbViewHead:d>=37&&2&c?o.decode(n):null,blobsViewHead:d>=37&&4&c?o.decode(n):null,autobeeMigrationHead:d>=37&&8&c?o.decode(n):null}}},Ds=e.frame(w),Ls=e.frame(Gi),js=Ds,qs=e.array(ct),Bs=e.frame(se),Es=Ds,zs=Bs,Os=e.frame(Lr),Ns=e.frame(ca),Us=Bs,Js=e.frame(fd),Ws=e.frame(Ir),Gs=e.frame(Gt),Qs=Gs,Xs=e.array(e.frame(tt)),Ys=Ds,Zs=e.frame(zn),$s=e.frame(Vr),_s=Zs,el=$s,dl=Zs,ol=$s,nl=e.frame(jr),cl=$s,rl=e.array(e.frame(Pt)),tl=e.frame(mi),il=e.frame(Hi),al=e.frame(qi),sl=e.frame(ba),ll=sl,pl=Ds,ul=e.array(e.frame(Qi)),fl=ul,ml=sl,yl=rl,bl=tl,xl=il,vl=al,gl=sl,kl=sl,Kl=Bs,hl=Zs,wl=$s,Rl=Ds,Pl=Ds,Tl=sl;function Al(e){switch(e){case"@keet/head":return o;case"@keet/oplog-id":return n;case"@keet/encryption-keypair":return c;case"@keet/signing-keypair":return r;case"@keet/room-keys":return t;case"@keet/operation-header":return i;case"@keet/blob-pointer":return a;case"@keet/file-dimensions":return s;case"@keet/file-metadata":return p;case"@keet/external-drive-pointer":return u;case"@keet/external-blob-pointer":return f;case"@keet/file-pointer":return b;case"@keet/file":return g;case"@keet/image-file":return w;case"@keet/file-status":return R;case"@keet/file-record":return A;case"@keet/device-status":return M;case"@keet/member-status":return S;case"@keet/member-moderation-status":return I;case"@keet/abi":return C;case"@keet/device-stats":return V;case"@keet/member-stats":return H;case"@keet/chat-stats":return F;case"@keet/file-stats":return D;case"@keet/stats":return E;case"@keet/room-type":return O;case"@keet/system-settings":return N;case"@keet/system-digest":return W;case"@keet/room-seed":return G;case"@keet/room-capabilities":return Q;case"@keet/room-config":return Y;case"@keet/blind-peer":return Z;case"@keet/add-blind-peer-operation":return ee;case"@keet/remove-blind-peer-operation":return oe;case"@keet/identity-attestation":return ne;case"@keet/device-invitation":return ce;case"@keet/device":return ie;case"@keet/member-profile":return ae;case"@keet/device-profile":return se;case"@keet/member-update":return pe;case"@keet/device-update":return ue;case"@keet/signed-pairing-data":return fe;case"@keet/device-request-identity":return me;case"@keet/device-response-identity":return ye;case"@keet/device-request-with-invitation":return ge;case"@keet/device-request-with-invitation-and-proof":return Ke;case"@keet/device-request-with-member-proof":return Re;case"@keet/device-request":return Ae;case"@keet/device-response":return Ie;case"@keet/invitation-metadata":return Ce;case"@keet/invitation":return Fe;case"@keet/add-invitation-operation":return je;case"@keet/remove-invitation-operation":return Be;case"@keet/sendable-room-invitation":return Ee;case"@keet/sendable-identity-invitation":return ze;case"@keet/sendable-contact-invitation":return Oe;case"@keet/sendable-invitation":return Ge;case"@keet/add-device-operation":return Xe;case"@keet/update-device-operation":return Ze;case"@keet/start-indexing-operation":return $e;case"@keet/stop-indexing-operation":return _e;case"@keet/join-request":return dd;case"@keet/accept-join-request-operation":return cd;case"@keet/reject-join-request-operation":return td;case"@keet/member":return sd;case"@keet/full-member":return ud;case"@keet/member-proofs":return fd;case"@keet/update-member-operation":return bd;case"@keet/change-member-status-operation":return gd;case"@keet/change-member-role-operation":return Kd;case"@keet/remove-member-operation":return wd;case"@keet/member-activity":return Rd;case"@keet/member-joined-event":return Pd;case"@keet/member-left-event":return Td;case"@keet/title-changed-chat-event":return Ad;case"@keet/chat-event":return Cd;case"@keet/sendable-event":return Vd;case"@keet/display-range":return Hd;case"@keet/display-content-range":return Dd;case"@keet/mention-display-item":return jd;case"@keet/link-preview":return Ed;case"@keet/display-link-item":return Nd;case"@keet/display":return _d;case"@keet/oplog-message":return co;case"@keet/index-message":return io;case"@keet/full-index-message":return lo;case"@keet/message-status":return po;case"@keet/message-index-id":return uo;case"@keet/thread":return mo;case"@keet/chat-message-record":return vo;case"@keet/full-chat-message-record":return ho;case"@keet/add-chat-message-operation":return Po;case"@keet/remove-chat-message-operation":return Ao;case"@keet/update-chat-message-operation":return Io;case"@keet/pin-chat-message-operation":return Vo;case"@keet/reaction":return Ho;case"@keet/reactions-summary":return Fo;case"@keet/reactions-digest":return Lo;case"@keet/add-reaction-operation":return qo;case"@keet/remove-reaction-operation":return Eo;case"@keet/update-room-config-operation":return No;case"@keet/group-member":return Uo;case"@keet/user-registry-info":return Jo;case"@keet/room-identity":return Go;case"@keet/genesis-operation":return dn;case"@keet/upgrade-operation":return nn;case"@keet/update-system-settings-operation":return tn;case"@keet-private-id/contact":return an;case"@keet-private-id/v3-room-migration-info":return sn;case"@keet-private-id/run-v3-migration-operation":return un;case"@keet-private-id/update-identity-operation":return mn;case"@keet-private-id/counters":return yn;case"@keet-private-id/stats":return bn;case"@keet-private-id/add-entropy-operation":return xn;case"@keet-private-id/pending-invitation-identity":return vn;case"@keet-private-id/pending-invitation":return kn;case"@keet-private-id/resolve-pending-invitation-operation":return hn;case"@keet-private-id/add-pending-invitation-operation":return Pn;case"@keet-private-id/remove-pending-invitation-operation":return An;case"@keet-private-id/identity-swap":return Mn;case"@keet-private-id/room-status":return Sn;case"@keet-private-id/room":return Hn;case"@keet-private-id/add-room-operation":return Dn;case"@keet-private-id/remove-room-operation":return jn;case"@keet-private-id/update-room-status-operation":return En;case"@keet-private-id/contact-status":return zn;case"@keet-private-id/contact-record":return On;case"@keet-private-id/add-contact-operation":return Jn;case"@keet-private-id/update-contact-status-operation":return Gn;case"@keet-private-id/remove-contact-operation":return Xn;case"@keet-private-id/contact-request-status":return Yn;case"@keet-private-id/contact-request-body":return _n;case"@keet-private-id/contact-request":return dc;case"@keet-private-id/contact-request-record":return rc;case"@keet-private-id/add-contact-request-operation":return ic;case"@keet-private-id/update-contact-request-status-operation":return lc;case"@keet-private-id/profile-discovery-record-v1":return pc;case"@keet-private-id/profile-discovery-record":return uc;case"@local/background-sync-room":return fc;case"@local/stats":return mc;case"@local/migration-status":return yc;case"@local/v3-private-profile-migration":return xc;case"@local/v3-room-migration":return kc;case"@local/room-migration-stats":return Kc;case"@local/room-migration":return wc;case"@local/identity-status":return Rc;case"@local/identity-record":return Ac;case"@local/tasks":return Sc;case"@local/room-keys":return Ic;case"@local/join-room-invitation-task":return Vc;case"@local/join-room-response-task":return Hc;case"@local/fast-forward-to":return Fc;case"@local/add-room-fields":return Dc;case"@local/join-room-keys-task":return jc;case"@local/create-room-task":return Bc;case"@local/leave-room-task":return Ec;case"@local/clear-room-task":return zc;case"@local/restore-identity-task":return Oc;case"@local/send-contact-request-task":return Nc;case"@local/migrate-v2-room-task":return Uc;case"@local/task":return er;case"@local/shared-invitation":return or;case"@local/room-status":return nr;case"@local/room-timestamps":return cr;case"@local/room":return vr;case"@local/room-preferences":return kr;case"@local/writer":return Kr;case"@local/member":return wr;case"@local/device":return Pr;case"@local/file":return Ar;case"@keet/add-file-preview-operation":return Sr;case"@keet/member-removed-event":return Ir;case"@keet/member-contact-info":return Vr;case"@keet/remove-device-operation":return Fr;case"@keet/device-identity":return Dr;case"@keet/readonly-room-invitation":return Lr;case"@keet-private-id/identity-swap-v2":return jr;case"@keet-private-id/activate-contact-room-operation":return Br;case"@local/identity-swap":return Er;case"@local/writer-append":return zr;case"@local/room-metadata":return Or;case"@local/debug-flag":return Nr;case"@local/debug":return Jr;case"@keet/display-type":return Gr;case"@keet/test-increment-operation":return Xr;case"@keet/test-collection-record-1":return Yr;case"@keet/migrate-abi-operation":return $r;case"@keet/system-settings-keys":return et;case"@local/hyperdht-record":return ot;case"@keet/room-supported-language":return ct;case"@keet/translation-display-item":return tt;case"@local/unread":return it;case"@keet-private-id/unreads":return at;case"@keet-private-id/add-unreads-key-operation":return lt;case"@keet-private-id/remove-unreads-key-operation":return ut;case"@keet/label-type":return mt;case"@keet/chat-label":return yt;case"@keet/add-chat-label-operation":return xt;case"@keet/remove-chat-label-operation":return gt;case"@keet/chat-label-summary":return kt;case"@keet/chat-label-digest":return ht;case"@keet/update-read-length-operation":return Rt;case"@keet/read-length":return Pt;case"@keet/tmp-removed-member":return Tt;case"@keet-private-id/settings":return At;case"@keet-private-id/user-settings-key":return St;case"@keet-private-id/update-settings-operation":return Vt;case"@local/error-record-details":return Ht;case"@local/error-record":return Dt;case"@local/keet-state":return jt;case"@local/file-stats":return qt;case"@keet/member-label-type":return Et;case"@keet/member-label":return zt;case"@keet/add-member-label-operation":return Nt;case"@keet/member-label-summary":return Ut;case"@keet/member-label-digest":return Wt;case"@keet/location-shared-event":return Gt;case"@keet/move-indexer-operation":return Xt;case"@keet/start-call":return $t;case"@keet/join-call":return di;case"@keet/leave-call":return ni;case"@keet/end-call":return ri;case"@keet/add-call-stream":return ii;case"@keet/remove-call-stream":return si;case"@keet/call-record":return li;case"@keet/call-member-record":return pi;case"@keet/call-device-record":return ui;case"@keet/call-stream-record":return fi;case"@local/active-call":return mi;case"@local/file-gc-info":return yi;case"@keet/build-type":return xi;case"@keet/test-crash-operation":return gi;case"@keet/test-dispatch-error-operation":return Ki;case"@local/environment-record":return hi;case"@keet-private-id/shorten-device-attestation-operation":return Ri;case"@local/ota-actions":return Pi;case"@local/device-attestation":return Ti;case"@keet/call-device-heartbeat":return Mi;case"@keet/remove-call-device":return Ii;case"@local/chat-labels":return Hi;case"@keet/start-call-recording":return Di;case"@keet/stop-call-recording":return ji;case"@local/settings":return qi;case"@local/hyperswarm-record":return Bi;case"@keet/dismiss-chat-reports-operation":return zi;case"@keet/update-typing-indicator-operation":return Ni;case"@keet/typing-indicator":return Ui;case"@keet-private-id/update-contact-alias-operation":return Wi;case"@keet/call-stats":return Gi;case"@keet/call-stream-input":return Qi;case"@keet/update-call-stream":return Yi;case"@keet/call-stream-status-record":return Zi;case"@keet/room-keys-v2":return $i;case"@keet/blob-pointer-v2":return _i;case"@keet/blob":return ea;case"@keet/autobee-migration":return da;case"@keet/autobee-migration-operation":return na;case"@keet/readonly-room-invitation-v2":return ca;case"@keet/admin-last-seen":return ta;case"@keet/blob-record":return ia;case"@keet-private-id/room-v2":return pa;case"@keet-private-id/add-room-operation-v2":return fa;case"@local/room-keys/v2":return ma;case"@local/room-update":return ya;case"@local/view-head":return ba;case"@local/autobee-migration":return xa;case"@keet-private-id/pending-invitation-response":return va;case"@keet-private-id/resolve-pending-invitation-operation-v2":return ka;case"@local/pending-recovery":return ha;case"@local/room-migration/hyperdb#3":return Ra;case"@local/room/hyperdb#6":return qa;case"@local/room-preferences/hyperdb#13":return Ea;case"@local/writer/hyperdb#14":return za;case"@local/member/hyperdb#17":return Na;case"@keet/device/hyperdb#18":return Wa;case"@local/device/hyperdb#18":return Qa;case"@keet-private-id/contact/hyperdb#19":return Xa;case"@local/task/hyperdb#21":return rs;case"@keet/blob-pointer/hyperdb#23":return ts;case"@keet/external-blob-pointer/hyperdb#23":return is;case"@keet/file-pointer/hyperdb#23":return ls;case"@keet/file/hyperdb#23":return fs;case"@local/file/hyperdb#23":return ys;case"@keet/external-drive-pointer/hyperdb#24":return bs;case"@keet/file-pointer/hyperdb#24":return gs;case"@keet/file/hyperdb#24":return hs;case"@local/file/hyperdb#24":return Rs;case"@local/background-sync-room/hyperdb#27":return Ps;case"@local/writer-append/hyperdb#29":return Ts;case"@local/room-metadata/hyperdb#30":return As;case"@local/unread/hyperdb#33":return Ms;case"@local/error-record/hyperdb#35":return Is;case"@local/file-stats/hyperdb#37":return Cs;case"@local/device-attestation/hyperdb#44":return Vs;case"@local/room-update/hyperdb#48":return Hs;case"@local/autobee-migration/hyperdb#50":return Fs;default:throw new Error("Encoder not found "+e)}}function Ml(e,o=39){const n=Al(e);return{preencode(e,c){d=o,n.preencode(e,c)},encode(e,c){d=o,n.encode(e,c)},decode:e=>(d=o,n.decode(e))}}const Sl=Ml;module.exports={resolveStruct:Sl,getStruct:Ml,getEnum:function(e){switch(e){case"@keet/room-type":return z;case"@local/tasks":return Mc;case"@keet/display-type":return Wr;case"@keet/system-settings-keys":return _r;case"@keet/room-supported-language":return nt;case"@keet/label-type":return ft;case"@keet-private-id/user-settings-key":return Mt;case"@local/keet-state":return Lt;case"@keet/member-label-type":return Bt;case"@keet/build-type":return bi;default:throw new Error("Enum not found "+e)}},getEncoding:Al,encode:function(o,n,c=39){return d=c,e.encode(Al(o),n)},decode:function(o,n,c=39){return d=c,e.decode(Al(o),n)},setVersion:function(e){d=e},version:d};
1const{c:e}=require("hyperschema/runtime");let d=41;const o={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.length)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.length)},decode:d=>({key:e.fixed32.decode(d),length:e.uint.decode(d)})},n={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.seq)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.seq)},decode:d=>({key:e.fixed32.decode(d),seq:e.uint.decode(d)})},c={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.secretKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.secretKey)},decode:d=>({publicKey:e.fixed32.decode(d),secretKey:e.fixed32.decode(d)})},r={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed64.preencode(d,o.secretKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed64.encode(d,o.secretKey)},decode:d=>({publicKey:e.fixed32.decode(d),secretKey:e.fixed64.decode(d)})},t={preencode(n,c){e.fixed32.preencode(n,c.key),n.end++,c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),d>=37&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=(c.encryptionKey?1:0)|(c.fastForwardTo?2:0)|(d>=37&&c.bootFrom?4:0);e.fixed32.encode(n,c.key),e.uint.encode(n,r),c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),d>=37&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.uint.decode(n);return{key:c,encryptionKey:1&r?e.buffer.decode(n):null,fastForwardTo:2&r?e.fixed32.decode(n):null,bootFrom:d>=37&&4&r?o.decode(n):null}}},i={preencode(d,o){e.uint.preencode(d,o.timestamp)},encode(d,o){e.uint.encode(d,o.timestamp)},decode:d=>({timestamp:e.uint.decode(d)})},a={preencode(d,o){e.uint.preencode(d,o.blockOffset),e.uint.preencode(d,o.blockLength),e.uint.preencode(d,o.byteOffset),e.uint.preencode(d,o.byteLength)},encode(d,o){e.uint.encode(d,o.blockOffset),e.uint.encode(d,o.blockLength),e.uint.encode(d,o.byteOffset),e.uint.encode(d,o.byteLength)},decode:d=>({blockOffset:e.uint.decode(d),blockLength:e.uint.decode(d),byteOffset:e.uint.decode(d),byteLength:e.uint.decode(d)})},s={preencode(d,o){e.uint.preencode(d,o.width),e.uint.preencode(d,o.height)},encode(d,o){e.uint.encode(d,o.width),e.uint.encode(d,o.height)},decode:d=>({width:e.uint.decode(d),height:e.uint.decode(d)})},l=e.frame(s),p={preencode(d,o){d.end++,o.name&&e.string.preencode(d,o.name),o.mimetype&&e.string.preencode(d,o.mimetype),o.dimensions&&l.preencode(d,o.dimensions),o.userdata&&e.buffer.preencode(d,o.userdata),o.duration&&e.uint.preencode(d,o.duration)},encode(d,o){const n=(o.name?1:0)|(o.mimetype?2:0)|(o.dimensions?4:0)|(o.userdata?8:0)|(o.duration?16:0)|(o.isPreview?32:0);e.uint.encode(d,n),o.name&&e.string.encode(d,o.name),o.mimetype&&e.string.encode(d,o.mimetype),o.dimensions&&l.encode(d,o.dimensions),o.userdata&&e.buffer.encode(d,o.userdata),o.duration&&e.uint.encode(d,o.duration)},decode(d){const o=e.uint.decode(d);return{name:1&o?e.string.decode(d):null,mimetype:2&o?e.string.decode(d):null,dimensions:4&o?l.decode(d):null,userdata:8&o?e.buffer.decode(d):null,duration:16&o?e.uint.decode(d):0,isPreview:!!(32&o)}}},u={preencode(d,o){e.fixed32.preencode(d,o.key),e.string.preencode(d,o.path),e.uint.preencode(d,o.version),e.uint.preencode(d,o.size)},encode(d,o){e.fixed32.encode(d,o.key),e.string.encode(d,o.path),e.uint.encode(d,o.version),e.uint.encode(d,o.size)},decode:d=>({key:e.fixed32.decode(d),path:e.string.decode(d),version:e.uint.decode(d),size:e.uint.decode(d)})},f={preencode(d,o){e.fixed32.preencode(d,o.key),a.preencode(d,o.blob)},encode(d,o){e.fixed32.encode(d,o.key),a.encode(d,o.blob)},decode:d=>({key:e.fixed32.decode(d),blob:a.decode(d)})},m=e.frame(f),y=e.frame(u),b={preencode(o,n){o.end++,n.inlined&&e.buffer.preencode(o,n.inlined),n.blob&&a.preencode(o,n.blob),n.externalBlob&&m.preencode(o,n.externalBlob),n.externalDrive&&y.preencode(o,n.externalDrive),d>=37&&n.bee&&_i.preencode(o,n.bee)},encode(o,n){const c=(n.inlined?1:0)|(n.blob?2:0)|(n.externalBlob?4:0)|(n.externalDrive?8:0)|(d>=37&&n.bee?16:0);e.uint.encode(o,c),n.inlined&&e.buffer.encode(o,n.inlined),n.blob&&a.encode(o,n.blob),n.externalBlob&&m.encode(o,n.externalBlob),n.externalDrive&&y.encode(o,n.externalDrive),d>=37&&n.bee&&_i.encode(o,n.bee)},decode(o){const n=e.uint.decode(o);return{inlined:1&n?e.buffer.decode(o):null,blob:2&n?a.decode(o):null,externalBlob:4&n?m.decode(o):null,externalDrive:8&n?y.decode(o):null,bee:d>=37&&16&n?_i.decode(o):null}}},x=e.frame(b),v=e.frame(p),g={preencode(d,o){x.preencode(d,o.pointer),d.end++,o.metadata&&v.preencode(d,o.metadata),o.preview&&Us.preencode(d,o.preview),o.hash&&e.fixed32.preencode(d,o.hash)},encode(d,o){const n=(o.metadata?1:0)|(o.preview?2:0)|(o.hash?4:0);x.encode(d,o.pointer),e.uint.encode(d,n),o.metadata&&v.encode(d,o.metadata),o.preview&&Us.encode(d,o.preview),o.hash&&e.fixed32.encode(d,o.hash)},decode(d){const o=x.decode(d),n=e.uint.decode(d);return{pointer:o,metadata:1&n?v.decode(d):null,preview:2&n?Us.decode(d):null,hash:4&n?e.fixed32.decode(d):null}}},k=e.frame(g),K=k,h=k,w={preencode(e,d){e.end++,d.small&&k.preencode(e,d.small),d.medium&&K.preencode(e,d.medium),d.large&&h.preencode(e,d.large)},encode(d,o){const n=(o.small?1:0)|(o.medium?2:0)|(o.large?4:0);e.uint.encode(d,n),o.small&&k.encode(d,o.small),o.medium&&K.encode(d,o.medium),o.large&&h.encode(d,o.large)},decode(d){const o=e.uint.decode(d);return{small:1&o?k.decode(d):null,medium:2&o?K.decode(d):null,large:4&o?h.decode(d):null}}},R={preencode(e,d){e.end++},encode(d,o){const n=o.isDeleted?1:0;e.uint.encode(d,n)},decode:d=>({isDeleted:!!(1&e.uint.decode(d))})},P=e.frame(R),T=k,A={preencode(o,c){e.uint.preencode(o,c.id),n.preencode(o,c.oplog),P.preencode(o,c.status),T.preencode(o,c.file),o.end++,d>=22&&c.version&&e.uint.preencode(o,c.version)},encode(o,c){const r=d>=22&&c.version?1:0;e.uint.encode(o,c.id),n.encode(o,c.oplog),P.encode(o,c.status),T.encode(o,c.file),e.uint.encode(o,r),d>=22&&c.version&&e.uint.encode(o,c.version)},decode(o){const c=e.uint.decode(o),r=n.decode(o),t=P.decode(o),i=T.decode(o),a=o.start<o.end?e.uint.decode(o):0;return{id:c,oplog:r,status:t,file:i,version:d>=22&&1&a?e.uint.decode(o):0}}},M={preencode(e,d){e.end++},encode(d,o){const n=(o.isActive?1:0)|(o.isIndexing?2:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isActive:!!(1&o),isIndexing:!!(2&o)}}},S={preencode(o,n){const c=(n.isAdmin?1:0)|(n.isModerator?2:0)|(n.isPending?4:0)|(n.isActive?8:0)|(n.isMuted?16:0)|(n.isBanned?32:0)|(n.isShadowBanned?64:0)|(d>=19&&n.isRemoved?128:0);e.uint.preencode(o,c)},encode(o,n){const c=(n.isAdmin?1:0)|(n.isModerator?2:0)|(n.isPending?4:0)|(n.isActive?8:0)|(n.isMuted?16:0)|(n.isBanned?32:0)|(n.isShadowBanned?64:0)|(d>=19&&n.isRemoved?128:0);e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{isAdmin:!!(1&n),isModerator:!!(2&n),isPending:!!(4&n),isActive:!!(8&n),isMuted:!!(16&n),isBanned:!!(32&n),isShadowBanned:!!(64&n),isRemoved:d>=19&&!!(128&n)}}},I={preencode(e,d){e.end++},encode(d,o){const n=(o.isMuted?1:0)|(o.isBanned?2:0)|(o.isShadowBanned?4:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isMuted:!!(1&o),isBanned:!!(2&o),isShadowBanned:!!(4&o)}}},C={preencode(d,o){e.uint.preencode(d,o.version)},encode(d,o){e.uint.encode(d,o.version)},decode:d=>({version:e.uint.decode(d)})},V={preencode(d,o){e.uint.preencode(d,o.total),e.uint.preencode(d,o.active)},encode(d,o){e.uint.encode(d,o.total),e.uint.encode(d,o.active)},decode:d=>({total:e.uint.decode(d),active:e.uint.decode(d)})},H={preencode(d,o){e.uint.preencode(d,o.total),e.uint.preencode(d,o.active),e.uint.preencode(d,o.pending)},encode(d,o){e.uint.encode(d,o.total),e.uint.encode(d,o.active),e.uint.encode(d,o.pending)},decode:d=>({total:e.uint.decode(d),active:e.uint.decode(d),pending:e.uint.decode(d)})},F={preencode(o,n){e.uint.preencode(o,n.clock),e.uint.preencode(o,n.pinned),e.uint.preencode(o,n.threads),e.uint.preencode(o,n.timestamp),o.end++,d>=24&&n.flagsClock&&e.uint.preencode(o,n.flagsClock)},encode(o,n){const c=d>=24&&n.flagsClock?1:0;e.uint.encode(o,n.clock),e.uint.encode(o,n.pinned),e.uint.encode(o,n.threads),e.uint.encode(o,n.timestamp),e.uint.encode(o,c),d>=24&&n.flagsClock&&e.uint.encode(o,n.flagsClock)},decode(o){const n=e.uint.decode(o),c=e.uint.decode(o),r=e.uint.decode(o),t=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{clock:n,pinned:c,threads:r,timestamp:t,flagsClock:d>=24&&1&i?e.uint.decode(o):0}}},D={preencode(d,o){e.uint.preencode(d,o.clock)},encode(d,o){e.uint.encode(d,o.clock)},decode:d=>({clock:e.uint.decode(d)})},L=e.frame(V),j=e.frame(H),q=e.frame(F),B=e.frame(D),E={preencode(e,o){L.preencode(e,o.devices),j.preencode(e,o.members),q.preencode(e,o.chat),B.preencode(e,o.files),e.end++,d>=36&&o.calls&&Js.preencode(e,o.calls)},encode(o,n){const c=d>=36&&n.calls?1:0;L.encode(o,n.devices),j.encode(o,n.members),q.encode(o,n.chat),B.encode(o,n.files),e.uint.encode(o,c),d>=36&&n.calls&&Js.encode(o,n.calls)},decode(o){const n=L.decode(o),c=j.decode(o),r=q.decode(o),t=B.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{devices:n,members:c,chat:r,files:t,calls:d>=36&&1&i?Js.decode(o):null}}},z={Default:1,Broadcast:2,DirectMessage:3},O={preencode(e,d){e.end++},encode(d,o){if(o>3)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},N={preencode(o,n){const c=(n.roomType?1:0)|(n.isExperimental?2:0)|(n.isJoiningDisabled?4:0)|(n.isAppendingDisabled?8:0)|(n.isCallingDisabled?16:0)|(n.isMembershipEventsDisabled?32:0)|(d>=28&&n.isAttachmentsDisabled?64:0)|(d>=28&&n.isLinksDisabled?128:0)|(d>=29&&n.buildType?256:0)|(d>=33&&n.isRoomInviteHidden?512:0);e.uint.preencode(o,c),n.roomType&&O.preencode(o,n.roomType),d>=29&&n.buildType&&xi.preencode(o,n.buildType)},encode(o,n){const c=(n.roomType?1:0)|(n.isExperimental?2:0)|(n.isJoiningDisabled?4:0)|(n.isAppendingDisabled?8:0)|(n.isCallingDisabled?16:0)|(n.isMembershipEventsDisabled?32:0)|(d>=28&&n.isAttachmentsDisabled?64:0)|(d>=28&&n.isLinksDisabled?128:0)|(d>=29&&n.buildType?256:0)|(d>=33&&n.isRoomInviteHidden?512:0);e.uint.encode(o,c),n.roomType&&O.encode(o,n.roomType),d>=29&&n.buildType&&xi.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{roomType:1&n?O.decode(o):0,isExperimental:!!(2&n),isJoiningDisabled:!!(4&n),isAppendingDisabled:!!(8&n),isCallingDisabled:!!(16&n),isMembershipEventsDisabled:!!(32&n),isAttachmentsDisabled:d>=28&&!!(64&n),isLinksDisabled:d>=28&&!!(128&n),buildType:d>=29&&256&n?xi.decode(o):null,isRoomInviteHidden:d>=33&&!!(512&n)}}},U=e.frame(C),J=e.frame(N),W={preencode(d,o){U.preencode(d,o.abi),J.preencode(d,o.settings),e.uint.preencode(d,o.creationTime)},encode(d,o){U.encode(d,o.abi),J.encode(d,o.settings),e.uint.encode(d,o.creationTime)},decode:d=>({abi:U.decode(d),settings:J.decode(d),creationTime:e.uint.decode(d)})},G={preencode(d,o){e.fixed32.preencode(d,o.seed)},encode(d,o){e.fixed32.encode(d,o.seed)},decode:d=>({seed:e.fixed32.decode(d)})},Q={preencode(d,o){c.preencode(d,o.mailboxKeyPair),r.preencode(d,o.discoveryKeyPair),e.fixed32.preencode(d,o.wakeupTopic),e.fixed32.preencode(d,o.swarmTopic)},encode(d,o){c.encode(d,o.mailboxKeyPair),r.encode(d,o.discoveryKeyPair),e.fixed32.encode(d,o.wakeupTopic),e.fixed32.encode(d,o.swarmTopic)},decode:d=>({mailboxKeyPair:c.decode(d),discoveryKeyPair:r.decode(d),wakeupTopic:e.fixed32.decode(d),swarmTopic:e.fixed32.decode(d)})},X=e.array(e.fixed32),Y={preencode(o,n){o.end++,n.title&&e.string.preencode(o,n.title),n.avatar&&Ws.preencode(o,n.avatar),n.description&&e.string.preencode(o,n.description),d>=17&&n.supportedLanguages&&Gs.preencode(o,n.supportedLanguages),d>=19&&n.blindPeers&&X.preencode(o,n.blindPeers)},encode(o,n){const c=(n.title?1:0)|(n.avatar?2:0)|(n.description?4:0)|(d>=17&&n.supportedLanguages?8:0)|(d>=19&&n.blindPeers?16:0);e.uint.encode(o,c),n.title&&e.string.encode(o,n.title),n.avatar&&Ws.encode(o,n.avatar),n.description&&e.string.encode(o,n.description),d>=17&&n.supportedLanguages&&Gs.encode(o,n.supportedLanguages),d>=19&&n.blindPeers&&X.encode(o,n.blindPeers)},decode(o){const n=e.uint.decode(o);return{title:1&n?e.string.decode(o):null,avatar:2&n?Ws.decode(o):null,description:4&n?e.string.decode(o):null,supportedLanguages:d>=17&&8&n?Gs.decode(o):null,blindPeers:d>=19&&16&n?X.decode(o):null}}},Z={preencode(d,o){e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.key)},decode:d=>({key:e.fixed32.decode(d)})},$=e.frame(i),_=e.frame(Z),ee={preencode(e,d){$.preencode(e,d.header),_.preencode(e,d.peer)},encode(e,d){$.encode(e,d.header),_.encode(e,d.peer)},decode:e=>({header:$.decode(e),peer:_.decode(e)})},de=$,oe={preencode(d,o){de.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){de.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:de.decode(d),key:e.fixed32.decode(d)})},ne={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.buffer.preencode(d,o.proof)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.buffer.encode(d,o.proof)},decode:d=>({memberKey:e.fixed32.decode(d),proof:e.buffer.decode(d)})},ce={preencode(d,o){e.fixed32.preencode(d,o.id),e.buffer.preencode(d,o.response)},encode(d,o){e.fixed32.encode(d,o.id),e.buffer.encode(d,o.response)},decode:d=>({id:e.fixed32.decode(d),response:e.buffer.decode(d)})},re=e.frame(M),te=e.frame(ce),ie={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.memberKey),re.preencode(d,o.status),Qs.preencode(d,o.profile),d.end++,o.invitation&&te.preencode(d,o.invitation)},encode(d,o){const n=o.invitation?1:0;e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.memberKey),re.encode(d,o.status),Qs.encode(d,o.profile),e.uint.encode(d,n),o.invitation&&te.encode(d,o.invitation)},decode:d=>({key:e.fixed32.decode(d),memberKey:e.fixed32.decode(d),status:re.decode(d),profile:Qs.decode(d),invitation:1&e.uint.decode(d)?te.decode(d):null})},ae={preencode(d,o){e.uint.preencode(d,o.timestamp),d.end++,o.mailbox&&e.fixed32.preencode(d,o.mailbox),o.displayName&&e.string.preencode(d,o.displayName),o.avatar&&Xs.preencode(d,o.avatar),o.username&&e.string.preencode(d,o.username)},encode(d,o){const n=(o.mailbox?1:0)|(o.displayName?2:0)|(o.avatar?4:0)|(o.username?8:0);e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.mailbox&&e.fixed32.encode(d,o.mailbox),o.displayName&&e.string.encode(d,o.displayName),o.avatar&&Xs.encode(d,o.avatar),o.username&&e.string.encode(d,o.username)},decode(d){const o=e.uint.decode(d),n=e.uint.decode(d);return{timestamp:o,mailbox:1&n?e.fixed32.decode(d):null,displayName:2&n?e.string.decode(d):null,avatar:4&n?Xs.decode(d):null,username:8&n?e.string.decode(d):null}}},se={preencode(o,n){o.end++,n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),n.name&&e.string.preencode(o,n.name),d>=29&&n.buildType&&xi.preencode(o,n.buildType)},encode(o,n){const c=(n.swarmKey?1:0)|(n.name?2:0)|(n.isMobile?4:0)|(d>=29&&n.buildType?8:0);e.uint.encode(o,c),n.swarmKey&&e.fixed32.encode(o,n.swarmKey),n.name&&e.string.encode(o,n.name),d>=29&&n.buildType&&xi.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{swarmKey:1&n?e.fixed32.decode(o):null,name:2&n?e.string.decode(o):null,isMobile:!!(4&n),buildType:d>=29&&8&n?xi.decode(o):null}}},le=e.frame(ae),pe={preencode(e,d){le.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){le.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:le.decode(e),attestation:ne.decode(e)})},ue={preencode(e,d){Ys.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){Ys.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:Ys.decode(e),attestation:ne.decode(e)})},fe={preencode(d,o){e.fixed32.preencode(d,o.id),e.buffer.preencode(d,o.data),e.buffer.preencode(d,o.signature)},encode(d,o){e.fixed32.encode(d,o.id),e.buffer.encode(d,o.data),e.buffer.encode(d,o.signature)},decode:d=>({id:e.fixed32.decode(d),data:e.buffer.decode(d),signature:e.buffer.decode(d)})},me={preencode(d,o){e.fixed32.preencode(d,o.devicePublicKey)},encode(d,o){e.fixed32.encode(d,o.devicePublicKey)},decode:d=>({devicePublicKey:e.fixed32.decode(d)})},ye={preencode(d,o){ne.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){ne.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({privateProfileIdentity:ne.decode(d),deviceProof:e.buffer.decode(d)})},be=e.frame(ue),xe=e.frame(pe),ve=e.frame(me),ge={preencode(n,c){e.fixed32.preencode(n,c.deviceKey),r.preencode(n,c.keyPair),be.preencode(n,c.device),xe.preencode(n,c.member),n.end++,c.identity&&ve.preencode(n,c.identity),d>=37&&c.link&&o.preencode(n,c.link)},encode(n,c){const t=(c.identity?1:0)|(d>=37&&c.link?2:0);e.fixed32.encode(n,c.deviceKey),r.encode(n,c.keyPair),be.encode(n,c.device),xe.encode(n,c.member),e.uint.encode(n,t),c.identity&&ve.encode(n,c.identity),d>=37&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),t=r.decode(n),i=be.decode(n),a=xe.decode(n),s=e.uint.decode(n);return{deviceKey:c,keyPair:t,device:i,member:a,identity:1&s?ve.decode(n):null,link:d>=37&&2&s?o.decode(n):null}}},ke=e.frame(ge),Ke={preencode(d,o){e.fixed32.preencode(d,o.id),ke.preencode(d,o.request),e.buffer.preencode(d,o.signature)},encode(d,o){e.fixed32.encode(d,o.id),ke.encode(d,o.request),e.buffer.encode(d,o.signature)},decode:d=>({id:e.fixed32.decode(d),request:ke.decode(d),signature:e.buffer.decode(d)})},he=be,we=xe,Re={preencode(e,d){he.preencode(e,d.device),e.end++,d.member&&we.preencode(e,d.member)},encode(d,o){const n=o.member?1:0;he.encode(d,o.device),e.uint.encode(d,n),o.member&&we.encode(d,o.member)},decode:d=>({device:he.decode(d),member:1&e.uint.decode(d)?we.decode(d):null})},Pe=e.frame(Ke),Te=e.frame(Re),Ae={preencode(e,d){e.end++,d.withInvitation&&Pe.preencode(e,d.withInvitation),d.withMemberProof&&Te.preencode(e,d.withMemberProof)},encode(d,o){const n=(o.withInvitation?1:0)|(o.withMemberProof?2:0);e.uint.encode(d,n),o.withInvitation&&Pe.encode(d,o.withInvitation),o.withMemberProof&&Te.encode(d,o.withMemberProof)},decode(d){const o=e.uint.decode(d);return{withInvitation:1&o?Pe.decode(d):null,withMemberProof:2&o?Te.decode(d):null}}},Me=e.frame(fe),Se=e.frame(ye),Ie={preencode(e,d){Me.preencode(e,d.signedKeys),e.end++,d.identity&&Se.preencode(e,d.identity)},encode(d,o){const n=o.identity?1:0;Me.encode(d,o.signedKeys),e.uint.encode(d,n),o.identity&&Se.encode(d,o.identity)},decode:d=>({signedKeys:Me.decode(d),identity:1&e.uint.decode(d)?Se.decode(d):null})},Ce={preencode(o,n){o.end++,n.expiration&&e.uint.preencode(o,n.expiration),d>=29&&n.buildType&&xi.preencode(o,n.buildType)},encode(o,n){const c=(n.expiration?1:0)|(n.requiresConfirmation?2:0)|(n.canModerate?4:0)|(n.canAdmin?8:0)|(d>=29&&n.buildType?16:0);e.uint.encode(o,c),n.expiration&&e.uint.encode(o,n.expiration),d>=29&&n.buildType&&xi.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{expiration:1&n?e.uint.decode(o):0,requiresConfirmation:!!(2&n),canModerate:!!(4&n),canAdmin:!!(8&n),buildType:d>=29&&16&n?xi.decode(o):null}}},Ve=Me,He=e.frame(Ce),Fe={preencode(d,n){e.fixed32.preencode(d,n.id),Ve.preencode(d,n.response),He.preencode(d,n.metadata),d.end++,n.anchor&&o.preencode(d,n.anchor)},encode(d,n){const c=(n.anchor?1:0)|(n.isActive?2:0);e.fixed32.encode(d,n.id),Ve.encode(d,n.response),He.encode(d,n.metadata),e.uint.encode(d,c),n.anchor&&o.encode(d,n.anchor)},decode(d){const n=e.fixed32.decode(d),c=Ve.decode(d),r=He.decode(d),t=e.uint.decode(d);return{id:n,response:c,metadata:r,anchor:1&t?o.decode(d):null,isActive:!!(2&t)}}},De=$,Le=e.frame(Fe),je={preencode(e,d){De.preencode(e,d.header),Le.preencode(e,d.invitation)},encode(e,d){De.encode(e,d.header),Le.encode(e,d.invitation)},decode:e=>({header:De.decode(e),invitation:Le.decode(e)})},qe=$,Be={preencode(d,o){qe.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){qe.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:qe.decode(d),id:e.fixed32.decode(d)})},Ee={preencode(d,n){e.fixed32.preencode(d,n.mailbox),e.fixed32.preencode(d,n.invitationSeed),o.preencode(d,n.anchor)},encode(d,n){e.fixed32.encode(d,n.mailbox),e.fixed32.encode(d,n.invitationSeed),o.encode(d,n.anchor)},decode:d=>({mailbox:e.fixed32.decode(d),invitationSeed:e.fixed32.decode(d),anchor:o.decode(d)})},ze={preencode(d,n){e.fixed32.preencode(d,n.mailbox),e.fixed32.preencode(d,n.invitationSeed),o.preencode(d,n.anchor),e.fixed32.preencode(d,n.identityPublicKey)},encode(d,n){e.fixed32.encode(d,n.mailbox),e.fixed32.encode(d,n.invitationSeed),o.encode(d,n.anchor),e.fixed32.encode(d,n.identityPublicKey)},decode:d=>({mailbox:e.fixed32.decode(d),invitationSeed:e.fixed32.decode(d),anchor:o.decode(d),identityPublicKey:e.fixed32.decode(d)})},Oe={preencode(d,o){e.fixed32.preencode(d,o.mailbox)},encode(d,o){e.fixed32.encode(d,o.mailbox)},decode:d=>({mailbox:e.fixed32.decode(d)})},Ne=e.frame(Ee),Ue=e.frame(ze),Je=e.frame(Oe),We=e.array(e.ipv4Address),Ge={preencode(e,o){e.end++,o.room&&Ne.preencode(e,o.room),o.identity&&Ue.preencode(e,o.identity),o.contact&&Je.preencode(e,o.contact),d>=9&&o.readonly&&Zs.preencode(e,o.readonly),d>=17&&o.additionalNodes&&We.preencode(e,o.additionalNodes),d>=29&&o.buildType&&xi.preencode(e,o.buildType),d>=37&&o["readonly-v2"]&&$s.preencode(e,o["readonly-v2"])},encode(o,n){const c=(n.room?1:0)|(n.identity?2:0)|(n.contact?4:0)|(d>=9&&n.readonly?8:0)|(d>=17&&n.additionalNodes?16:0)|(d>=29&&n.buildType?32:0)|(d>=37&&n["readonly-v2"]?64:0);e.uint.encode(o,c),n.room&&Ne.encode(o,n.room),n.identity&&Ue.encode(o,n.identity),n.contact&&Je.encode(o,n.contact),d>=9&&n.readonly&&Zs.encode(o,n.readonly),d>=17&&n.additionalNodes&&We.encode(o,n.additionalNodes),d>=29&&n.buildType&&xi.encode(o,n.buildType),d>=37&&n["readonly-v2"]&&$s.encode(o,n["readonly-v2"])},decode(o){const n=e.uint.decode(o);return{room:1&n?Ne.decode(o):null,identity:2&n?Ue.decode(o):null,contact:4&n?Je.decode(o):null,readonly:d>=9&&8&n?Zs.decode(o):null,additionalNodes:d>=17&&16&n?We.decode(o):null,buildType:d>=29&&32&n?xi.decode(o):null,"readonly-v2":d>=37&&64&n?$s.decode(o):null}}},Qe=$,Xe={preencode(d,o){Qe.preencode(d,o.header),e.buffer.preencode(d,o.blindRequest)},encode(d,o){Qe.encode(d,o.header),e.buffer.encode(d,o.blindRequest)},decode:d=>({header:Qe.decode(d),blindRequest:e.buffer.decode(d)})},Ye=$,Ze={preencode(o,n){Ye.preencode(o,n.header),o.end++,n.profile&&_s.preencode(o,n.profile),d>=34&&n.key&&e.fixed32.preencode(o,n.key)},encode(o,n){const c=(n.profile?1:0)|(d>=34&&n.key?2:0);Ye.encode(o,n.header),e.uint.encode(o,c),n.profile&&_s.encode(o,n.profile),d>=34&&n.key&&e.fixed32.encode(o,n.key)},decode(o){const n=Ye.decode(o),c=e.uint.decode(o);return{header:n,profile:1&c?_s.decode(o):null,key:d>=34&&2&c?e.fixed32.decode(o):null}}},$e={preencode(e,d){},encode(e,d){},decode:e=>({})},_e=$e,ed=ke,dd={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.id),ed.preencode(d,o.request)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.id),ed.encode(d,o.request)},decode:d=>({deviceKey:e.fixed32.decode(d),id:e.fixed32.decode(d),request:ed.decode(d)})},od=$,nd=Se,cd={preencode(d,o){od.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),d.end++,o.identity&&nd.preencode(d,o.identity)},encode(d,o){const n=o.identity?1:0;od.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,n),o.identity&&nd.encode(d,o.identity)},decode:d=>({header:od.decode(d),deviceKey:e.fixed32.decode(d),identity:1&e.uint.decode(d)?nd.decode(d):null})},rd=$,td={preencode(d,o){rd.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey)},encode(d,o){rd.encode(d,o.header),e.fixed32.encode(d,o.deviceKey)},decode:d=>({header:rd.decode(d),deviceKey:e.fixed32.decode(d)})},id=e.frame(S),ad=le,sd={preencode(d,o){e.fixed32.preencode(d,o.key),id.preencode(d,o.status),ad.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),id.encode(d,o.status),ad.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),status:id.decode(d),profile:ad.decode(d)})},ld=id,pd=le,ud={preencode(d,o){e.fixed32.preencode(d,o.key),ld.preencode(d,o.status),pd.preencode(d,o.profile),d.end++,o.proofs&&el.preencode(d,o.proofs)},encode(d,o){const n=o.proofs?1:0;e.fixed32.encode(d,o.key),ld.encode(d,o.status),pd.encode(d,o.profile),e.uint.encode(d,n),o.proofs&&el.encode(d,o.proofs)},decode:d=>({key:e.fixed32.decode(d),status:ld.decode(d),profile:pd.decode(d),proofs:1&e.uint.decode(d)?el.decode(d):null})},fd={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++,o.profileAttestation&&e.buffer.preencode(d,o.profileAttestation),o.latestReceipt&&e.buffer.preencode(d,o.latestReceipt)},encode(d,o){const n=(o.profileAttestation?1:0)|(o.latestReceipt?2:0);e.fixed32.encode(d,o.key),e.uint.encode(d,n),o.profileAttestation&&e.buffer.encode(d,o.profileAttestation),o.latestReceipt&&e.buffer.encode(d,o.latestReceipt)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d);return{key:o,profileAttestation:1&n?e.buffer.decode(d):null,latestReceipt:2&n?e.buffer.decode(d):null}}},md=$,yd=xe,bd={preencode(e,d){md.preencode(e,d.header),yd.preencode(e,d.member)},encode(e,d){md.encode(e,d.header),yd.encode(e,d.member)},decode:e=>({header:md.decode(e),member:yd.decode(e)})},xd=$,vd=e.frame(I),gd={preencode(d,o){xd.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),vd.preencode(d,o.status)},encode(d,o){xd.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),vd.encode(d,o.status)},decode:d=>({header:xd.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:vd.decode(d)})},kd=$,Kd={preencode(d,o){kd.preencode(d,o.header),e.fixed32.preencode(d,o.key),d.end++},encode(d,o){const n=(o.isModerator?1:0)|(o.isAdmin?2:0);kd.encode(d,o.header),e.fixed32.encode(d,o.key),e.uint.encode(d,n)},decode(d){const o=kd.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{header:o,key:n,isModerator:!!(1&c),isAdmin:!!(2&c)}}},hd=$,wd={preencode(d,o){hd.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){hd.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:hd.decode(d),key:e.fixed32.decode(d)})},Rd={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.mentions)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.mentions)},decode:d=>({key:e.fixed32.decode(d),mentions:e.uint.decode(d)})},Pd={preencode(d,o){d.end++,o.memberKey&&e.fixed32.preencode(d,o.memberKey)},encode(d,o){const n=o.memberKey?1:0;e.uint.encode(d,n),o.memberKey&&e.fixed32.encode(d,o.memberKey)},decode:d=>({memberKey:1&e.uint.decode(d)?e.fixed32.decode(d):null})},Td=Pd,Ad={preencode(d,o){d.end++,o.from&&e.string.preencode(d,o.from),o.to&&e.string.preencode(d,o.to)},encode(d,o){const n=(o.from?1:0)|(o.to?2:0);e.uint.encode(d,n),o.from&&e.string.encode(d,o.from),o.to&&e.string.encode(d,o.to)},decode(d){const o=e.uint.decode(d);return{from:1&o?e.string.decode(d):null,to:2&o?e.string.decode(d):null}}},Md=e.frame(Pd),Sd=e.frame(Td),Id=e.frame(Ad),Cd={preencode(o,n){const c=(n.memberJoined?1:0)|(n.memberLeft?2:0)|(n.titleChanged?4:0)|(n.callStarted?8:0)|(n.callHangup?16:0)|(n.callMissed?32:0)|(d>=4&&n.roomAvatarChanged?64:0)|(d>=4&&n.invitationCreated?128:0)|(d>=4&&n.memberRemoved?256:0)|(d>=27&&n.locationShared?512:0);e.uint.preencode(o,c),n.memberJoined&&Md.preencode(o,n.memberJoined),n.memberLeft&&Sd.preencode(o,n.memberLeft),n.titleChanged&&Id.preencode(o,n.titleChanged),d>=4&&n.memberRemoved&&dl.preencode(o,n.memberRemoved),d>=27&&n.locationShared&&ol.preencode(o,n.locationShared)},encode(o,n){const c=(n.memberJoined?1:0)|(n.memberLeft?2:0)|(n.titleChanged?4:0)|(n.callStarted?8:0)|(n.callHangup?16:0)|(n.callMissed?32:0)|(d>=4&&n.roomAvatarChanged?64:0)|(d>=4&&n.invitationCreated?128:0)|(d>=4&&n.memberRemoved?256:0)|(d>=27&&n.locationShared?512:0);e.uint.encode(o,c),n.memberJoined&&Md.encode(o,n.memberJoined),n.memberLeft&&Sd.encode(o,n.memberLeft),n.titleChanged&&Id.encode(o,n.titleChanged),d>=4&&n.memberRemoved&&dl.encode(o,n.memberRemoved),d>=27&&n.locationShared&&ol.encode(o,n.locationShared)},decode(o){const n=e.uint.decode(o);return{memberJoined:1&n?Md.decode(o):null,memberLeft:2&n?Sd.decode(o):null,titleChanged:4&n?Id.decode(o):null,callStarted:!!(8&n),callHangup:!!(16&n),callMissed:!!(32&n),roomAvatarChanged:d>=4&&!!(64&n),invitationCreated:d>=4&&!!(128&n),memberRemoved:d>=4&&256&n?dl.decode(o):null,locationShared:d>=27&&512&n?ol.decode(o):null}}},Vd={preencode(e,o){e.end++,d>=27&&o.locationShared&&nl.preencode(e,o.locationShared)},encode(o,n){const c=(n.callStarted?1:0)|(n.callHangup?2:0)|(n.callMissed?4:0)|(d>=27&&n.locationShared?8:0);e.uint.encode(o,c),d>=27&&n.locationShared&&nl.encode(o,n.locationShared)},decode(o){const n=e.uint.decode(o);return{callStarted:!!(1&n),callHangup:!!(2&n),callMissed:!!(4&n),locationShared:d>=27&&8&n?nl.decode(o):null}}},Hd={preencode(d,o){e.uint.preencode(d,o.start),e.uint.preencode(d,o.length)},encode(d,o){e.uint.encode(d,o.start),e.uint.encode(d,o.length)},decode:d=>({start:e.uint.decode(d),length:e.uint.decode(d)})},Fd=e.frame(Hd),Dd={preencode(d,o){Fd.preencode(d,o.range),e.string.preencode(d,o.content)},encode(d,o){Fd.encode(d,o.range),e.string.encode(d,o.content)},decode:d=>({range:Fd.decode(d),content:e.string.decode(d)})},Ld=Fd,jd={preencode(d,o){Ld.preencode(d,o.range),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Ld.encode(d,o.range),e.fixed32.encode(d,o.memberKey)},decode:d=>({range:Ld.decode(d),memberKey:e.fixed32.decode(d)})},qd=k,Bd=e.array(e.uint),Ed={preencode(o,n){o.end++,n.title&&e.string.preencode(o,n.title),n.description&&e.string.preencode(o,n.description),n.file&&qd.preencode(o,n.file),d>=12&&n.files&&Bd.preencode(o,n.files)},encode(o,n){const c=(n.title?1:0)|(n.description?2:0)|(n.file?4:0)|(d>=12&&n.files?8:0);e.uint.encode(o,c),n.title&&e.string.encode(o,n.title),n.description&&e.string.encode(o,n.description),n.file&&qd.encode(o,n.file),d>=12&&n.files&&Bd.encode(o,n.files)},decode(o){const n=e.uint.decode(o);return{title:1&n?e.string.decode(o):null,description:2&n?e.string.decode(o):null,file:4&n?qd.decode(o):null,files:d>=12&&8&n?Bd.decode(o):null}}},zd=Fd,Od=e.frame(Ed),Nd={preencode(d,o){zd.preencode(d,o.range),e.string.preencode(d,o.url),d.end++,o.preview&&Od.preencode(d,o.preview)},encode(d,o){const n=o.preview?1:0;zd.encode(d,o.range),e.string.encode(d,o.url),e.uint.encode(d,n),o.preview&&Od.encode(d,o.preview)},decode:d=>({range:zd.decode(d),url:e.string.decode(d),preview:1&e.uint.decode(d)?Od.decode(d):null})},Ud=e.array(e.frame(jd)),Jd=e.array(e.frame(Nd)),Wd=Jd,Gd=e.array(e.frame(Hd)),Qd=Gd,Xd=Gd,Yd=e.array(e.frame(Dd)),Zd=Gd,$d=Gd,_d={preencode(o,n){const c=(n.mention?1:0)|(n.httpLink?2:0)|(n.pearLink?4:0)|(n.bold?8:0)|(n.italic?16:0)|(n.code?32:0)|(n.emoji?64:0)|(n.codeBlock?128:0)|(n.strike?256:0)|(d>=17&&n.translation?512:0);e.uint.preencode(o,c),n.mention&&Ud.preencode(o,n.mention),n.httpLink&&Jd.preencode(o,n.httpLink),n.pearLink&&Wd.preencode(o,n.pearLink),n.bold&&Gd.preencode(o,n.bold),n.italic&&Qd.preencode(o,n.italic),n.code&&Xd.preencode(o,n.code),n.emoji&&Yd.preencode(o,n.emoji),n.codeBlock&&Zd.preencode(o,n.codeBlock),n.strike&&$d.preencode(o,n.strike),d>=17&&n.translation&&cl.preencode(o,n.translation)},encode(o,n){const c=(n.mention?1:0)|(n.httpLink?2:0)|(n.pearLink?4:0)|(n.bold?8:0)|(n.italic?16:0)|(n.code?32:0)|(n.emoji?64:0)|(n.codeBlock?128:0)|(n.strike?256:0)|(d>=17&&n.translation?512:0);e.uint.encode(o,c),n.mention&&Ud.encode(o,n.mention),n.httpLink&&Jd.encode(o,n.httpLink),n.pearLink&&Wd.encode(o,n.pearLink),n.bold&&Gd.encode(o,n.bold),n.italic&&Qd.encode(o,n.italic),n.code&&Xd.encode(o,n.code),n.emoji&&Yd.encode(o,n.emoji),n.codeBlock&&Zd.encode(o,n.codeBlock),n.strike&&$d.encode(o,n.strike),d>=17&&n.translation&&cl.encode(o,n.translation)},decode(o){const n=e.uint.decode(o);return{mention:1&n?Ud.decode(o):null,httpLink:2&n?Jd.decode(o):null,pearLink:4&n?Wd.decode(o):null,bold:8&n?Gd.decode(o):null,italic:16&n?Qd.decode(o):null,code:32&n?Xd.decode(o):null,emoji:64&n?Yd.decode(o):null,codeBlock:128&n?Zd.decode(o):null,strike:256&n?$d.decode(o):null,translation:d>=17&&512&n?cl.decode(o):null}}},eo=e.array(e.frame(g)),oo=e.frame(_d),no=e.frame(Vd),co={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&eo.preencode(d,o.files),o.display&&oo.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent),o.event&&no.preencode(d,o.event)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(c.event?32:0)|(d>=27&&c.forwarded?64:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&eo.encode(o,c.files),c.display&&oo.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent),c.event&&no.encode(o,c.event)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?eo.decode(o):null,display:4&c?oo.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,event:32&c?no.decode(o):null,forwarded:d>=27&&!!(64&c)}}},ro=Bd,to=oo,io={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&ro.preencode(d,o.files),o.display&&to.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(d>=27&&c.forwarded?32:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&ro.encode(o,c.files),c.display&&to.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?ro.decode(o):null,display:4&c?to.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,forwarded:d>=27&&!!(32&c)}}},ao=eo,so=oo,lo={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&ao.preencode(d,o.files),o.display&&so.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(d>=27&&c.forwarded?32:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&ao.encode(o,c.files),c.display&&so.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?ao.decode(o):null,display:4&c?so.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,forwarded:d>=27&&!!(32&c)}}},po={preencode(e,d){e.end++},encode(d,o){const n=(o.isEdited?1:0)|(o.isDeleted?2:0)|(o.isPinned?4:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isEdited:!!(1&o),isDeleted:!!(2&o),isPinned:!!(4&o)}}},uo={preencode(d,o){e.uint.preencode(d,o.thread),e.uint.preencode(d,o.index)},encode(d,o){e.uint.encode(d,o.thread),e.uint.encode(d,o.index)},decode:d=>({thread:e.uint.decode(d),index:e.uint.decode(d)})},fo=e.frame(E),mo={preencode(d,o){e.uint.preencode(d,o.id),e.uint.preencode(d,o.count),d.end++,o.parent&&n.preencode(d,o.parent),o.stats&&fo.preencode(d,o.stats)},encode(d,o){const c=(o.parent?1:0)|(o.stats?2:0);e.uint.encode(d,o.id),e.uint.encode(d,o.count),e.uint.encode(d,c),o.parent&&n.encode(d,o.parent),o.stats&&fo.encode(d,o.stats)},decode(d){const o=e.uint.decode(d),c=e.uint.decode(d),r=e.uint.decode(d);return{id:o,count:c,parent:1&r?n.decode(d):null,stats:2&r?fo.decode(d):null}}},yo=e.frame(po),bo=e.frame(io),xo=e.frame(Cd),vo={preencode(d,o){uo.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),yo.preencode(d,o.status),o.message&&bo.preencode(d,o.message),o.event&&xo.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);uo.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),yo.encode(d,o.status),o.message&&bo.encode(d,o.message),o.event&&xo.encode(d,o.event)},decode(d){const o=uo.decode(d),c=n.decode(d),r=e.uint.decode(d),t=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:r,timestamp:t,editedAt:1&i?e.uint.decode(d):0,status:yo.decode(d),message:2&i?bo.decode(d):null,event:4&i?xo.decode(d):null}}},go=yo,ko=e.frame(lo),Ko=xo,ho={preencode(d,o){uo.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),go.preencode(d,o.status),o.message&&ko.preencode(d,o.message),o.event&&Ko.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);uo.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),go.encode(d,o.status),o.message&&ko.encode(d,o.message),o.event&&Ko.encode(d,o.event)},decode(d){const o=uo.decode(d),c=n.decode(d),r=e.uint.decode(d),t=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:r,timestamp:t,editedAt:1&i?e.uint.decode(d):0,status:go.decode(d),message:2&i?ko.decode(d):null,event:4&i?Ko.decode(d):null}}},wo=$,Ro=e.frame(co),Po={preencode(e,d){wo.preencode(e,d.header),Ro.preencode(e,d.message)},encode(e,d){wo.encode(e,d.header),Ro.encode(e,d.message)},decode:e=>({header:wo.decode(e),message:Ro.decode(e)})},To=$,Ao={preencode(e,d){To.preencode(e,d.header),n.preencode(e,d.oplog)},encode(e,d){To.encode(e,d.header),n.encode(e,d.oplog)},decode:e=>({header:To.decode(e),oplog:n.decode(e)})},Mo=$,So=Ro,Io={preencode(e,d){Mo.preencode(e,d.header),n.preencode(e,d.oplog),So.preencode(e,d.message)},encode(e,d){Mo.encode(e,d.header),n.encode(e,d.oplog),So.encode(e,d.message)},decode:e=>({header:Mo.decode(e),oplog:n.decode(e),message:So.decode(e)})},Co=$,Vo={preencode(e,d){Co.preencode(e,d.header),n.preencode(e,d.oplog),e.end++},encode(d,o){const c=o.isPinned?1:0;Co.encode(d,o.header),n.encode(d,o.oplog),e.uint.encode(d,c)},decode:d=>({header:Co.decode(d),oplog:n.decode(d),isPinned:!!(1&e.uint.decode(d))})},Ho={preencode(d,o){uo.preencode(d,o.id),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),e.string.preencode(d,o.reaction)},encode(d,o){uo.encode(d,o.id),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),e.string.encode(d,o.reaction)},decode:d=>({id:uo.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),reaction:e.string.decode(d)})},Fo={preencode(d,o){e.string.preencode(d,o.text),e.uint.preencode(d,o.count)},encode(d,o){e.string.encode(d,o.text),e.uint.encode(d,o.count)},decode:d=>({text:e.string.decode(d),count:e.uint.decode(d)})},Do=e.array(e.frame(Fo)),Lo={preencode(o,n){uo.preencode(o,n.id),e.uint.preencode(o,n.total),Do.preencode(o,n.reactions),o.end++,d>=17&&n.editedAt&&e.uint.preencode(o,n.editedAt)},encode(o,n){const c=d>=17&&n.editedAt?1:0;uo.encode(o,n.id),e.uint.encode(o,n.total),Do.encode(o,n.reactions),e.uint.encode(o,c),d>=17&&n.editedAt&&e.uint.encode(o,n.editedAt)},decode(o){const n=uo.decode(o),c=e.uint.decode(o),r=Do.decode(o),t=o.start<o.end?e.uint.decode(o):0;return{id:n,total:c,reactions:r,editedAt:d>=17&&1&t?e.uint.decode(o):0}}},jo=$,qo={preencode(d,o){jo.preencode(d,o.header),n.preencode(d,o.oplog),e.string.preencode(d,o.reaction)},encode(d,o){jo.encode(d,o.header),n.encode(d,o.oplog),e.string.encode(d,o.reaction)},decode:d=>({header:jo.decode(d),oplog:n.decode(d),reaction:e.string.decode(d)})},Bo=$,Eo={preencode(d,o){Bo.preencode(d,o.header),n.preencode(d,o.oplog),e.string.preencode(d,o.reaction)},encode(d,o){Bo.encode(d,o.header),n.encode(d,o.oplog),e.string.encode(d,o.reaction)},decode:d=>({header:Bo.decode(d),oplog:n.decode(d),reaction:e.string.decode(d)})},zo=$,Oo=e.frame(Y),No={preencode(d,o){zo.preencode(d,o.header),e.uint.preencode(d,o.key),Oo.preencode(d,o.config)},encode(d,o){zo.encode(d,o.header),e.uint.encode(d,o.key),Oo.encode(d,o.config)},decode:d=>({header:zo.decode(d),key:e.uint.decode(d),config:Oo.decode(d)})},Uo={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.string.preencode(d,o.displayName),d.end++,o.avatar&&rl.preencode(d,o.avatar)},encode(d,o){const n=o.avatar?1:0;e.fixed32.encode(d,o.memberKey),e.string.encode(d,o.displayName),e.uint.encode(d,n),o.avatar&&rl.encode(d,o.avatar)},decode:d=>({memberKey:e.fixed32.decode(d),displayName:e.string.decode(d),avatar:1&e.uint.decode(d)?rl.decode(d):null})},Jo={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++,o.username&&e.string.preencode(d,o.username)},encode(d,o){const n=o.username?1:0;e.fixed32.encode(d,o.key),e.uint.encode(d,n),o.username&&e.string.encode(d,o.username)},decode:d=>({key:e.fixed32.decode(d),username:1&e.uint.decode(d)?e.string.decode(d):null})},Wo=e.frame(Jo),Go={preencode(d,o){e.fixed32.preencode(d,o.publicKey),d.end++,o.discoveryCoreKey&&e.fixed32.preencode(d,o.discoveryCoreKey),o.userRegistry&&Wo.preencode(d,o.userRegistry)},encode(d,o){const n=(o.discoveryCoreKey?1:0)|(o.userRegistry?2:0);e.fixed32.encode(d,o.publicKey),e.uint.encode(d,n),o.discoveryCoreKey&&e.fixed32.encode(d,o.discoveryCoreKey),o.userRegistry&&Wo.encode(d,o.userRegistry)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d);return{publicKey:o,discoveryCoreKey:1&n?e.fixed32.decode(d):null,userRegistry:2&n?Wo.decode(d):null}}},Qo=$,Xo=e.frame(W),Yo=e.frame(G),Zo=Oo,$o=e.frame(Go),_o=be,en=e.array(e.frame(pe)),dn={preencode(e,d){Qo.preencode(e,d.header),Xo.preencode(e,d.digest),Yo.preencode(e,d.capabilities),e.end++,d.config&&Zo.preencode(e,d.config),d.identity&&$o.preencode(e,d.identity),d.bootstrapDevice&&_o.preencode(e,d.bootstrapDevice),d.initialMembers&&en.preencode(e,d.initialMembers)},encode(d,o){const n=(o.config?1:0)|(o.identity?2:0)|(o.bootstrapDevice?4:0)|(o.initialMembers?8:0);Qo.encode(d,o.header),Xo.encode(d,o.digest),Yo.encode(d,o.capabilities),e.uint.encode(d,n),o.config&&Zo.encode(d,o.config),o.identity&&$o.encode(d,o.identity),o.bootstrapDevice&&_o.encode(d,o.bootstrapDevice),o.initialMembers&&en.encode(d,o.initialMembers)},decode(d){const o=Qo.decode(d),n=Xo.decode(d),c=Yo.decode(d),r=e.uint.decode(d);return{header:o,digest:n,capabilities:c,config:1&r?Zo.decode(d):null,identity:2&r?$o.decode(d):null,bootstrapDevice:4&r?_o.decode(d):null,initialMembers:8&r?en.decode(d):null}}},on=$,nn={preencode(d,o){on.preencode(d,o.header),e.uint.preencode(d,o.version)},encode(d,o){on.encode(d,o.header),e.uint.encode(d,o.version)},decode:d=>({header:on.decode(d),version:e.uint.decode(d)})},cn=$,rn=J,tn={preencode(d,o){cn.preencode(d,o.header),e.uint.preencode(d,o.key),rn.preencode(d,o.settings)},encode(d,o){cn.encode(d,o.header),e.uint.encode(d,o.key),rn.encode(d,o.settings)},decode:d=>({header:cn.decode(d),key:e.uint.decode(d),settings:rn.decode(d)})},an={preencode(o,n){e.fixed32.preencode(o,n.memberKey),tl.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=32&&n.contactInfo&&il.preencode(o,n.contactInfo),d>=32&&n.version&&e.uint.preencode(o,n.version),d>=34&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=32&&n.contactInfo?4:0)|(d>=32&&n.version?8:0)|(d>=34&&n.alias?16:0);e.fixed32.encode(o,n.memberKey),tl.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=32&&n.contactInfo&&il.encode(o,n.contactInfo),d>=32&&n.version&&e.uint.encode(o,n.version),d>=34&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.fixed32.decode(o),c=tl.decode(o),r=e.uint.decode(o);return{memberKey:n,status:c,mailbox:1&r?e.fixed32.decode(o):null,roomKey:2&r?e.fixed32.decode(o):null,contactInfo:d>=32&&4&r?il.decode(o):null,version:d>=32&&8&r?e.uint.decode(o):0,alias:d>=34&&16&r?e.string.decode(o):null}}},sn={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.seed),o.preencode(d,n.initiator),e.fixed32.preencode(d,n.fastForwardTo)},encode(d,n){e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.fixed32.encode(d,n.seed),o.encode(d,n.initiator),e.fixed32.encode(d,n.fastForwardTo)},decode:d=>({roomKey:e.fixed32.decode(d),encryptionKey:e.buffer.decode(d),seed:e.fixed32.decode(d),initiator:o.decode(d),fastForwardTo:e.fixed32.decode(d)})},ln=e.array(e.frame(sn)),pn=X,un={preencode(e,d){ln.preencode(e,d.sharedRooms),pn.preencode(e,d.blockedContacts)},encode(e,d){ln.encode(e,d.sharedRooms),pn.encode(e,d.blockedContacts)},decode:e=>({sharedRooms:ln.decode(e),blockedContacts:pn.decode(e)})},fn=$o,mn={preencode(e,d){fn.preencode(e,d.identity)},encode(e,d){fn.encode(e,d.identity)},decode:e=>({identity:fn.decode(e)})},yn={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.contacts)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.contacts)},decode:d=>({rooms:e.uint.decode(d),contacts:e.uint.decode(d)})},bn={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.contactRequests)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.contactRequests)},decode:d=>({rooms:e.uint.decode(d),contactRequests:e.uint.decode(d)})},xn={preencode(d,o){e.buffer.preencode(d,o.entropy)},encode(d,o){e.buffer.encode(d,o.entropy)},decode:d=>({entropy:e.buffer.decode(d)})},vn={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.devicePublicKey),e.fixed32.preencode(d,o.writerKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.devicePublicKey),e.fixed32.encode(d,o.writerKey)},decode:d=>({publicKey:e.fixed32.decode(d),devicePublicKey:e.fixed32.decode(d),writerKey:e.fixed32.decode(d)})},gn=e.frame(vn),kn={preencode(n,c){e.fixed32.preencode(n,c.id),e.fixed32.preencode(n,c.invitationSeed),e.fixed32.preencode(n,c.mailbox),r.preencode(n,c.responseKeyPair),o.preencode(n,c.initiator),o.preencode(n,c.inviter),n.end++,c.identity&&gn.preencode(n,c.identity),d>=29&&c.buildType&&xi.preencode(n,c.buildType),d>=37&&c.link&&o.preencode(n,c.link)},encode(n,c){const t=(c.identity?1:0)|(d>=29&&c.buildType?2:0)|(d>=37&&c.link?4:0);e.fixed32.encode(n,c.id),e.fixed32.encode(n,c.invitationSeed),e.fixed32.encode(n,c.mailbox),r.encode(n,c.responseKeyPair),o.encode(n,c.initiator),o.encode(n,c.inviter),e.uint.encode(n,t),c.identity&&gn.encode(n,c.identity),d>=29&&c.buildType&&xi.encode(n,c.buildType),d>=37&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),t=e.fixed32.decode(n),i=e.fixed32.decode(n),a=r.decode(n),s=o.decode(n),l=o.decode(n),p=e.uint.decode(n);return{id:c,invitationSeed:t,mailbox:i,responseKeyPair:a,initiator:s,inviter:l,identity:1&p?gn.decode(n):null,buildType:d>=29&&2&p?xi.decode(n):null,link:d>=37&&4&p?o.decode(n):null}}},Kn=$,hn={preencode(d,o){Kn.preencode(d,o.header),e.buffer.preencode(d,o.blindResponse)},encode(d,o){Kn.encode(d,o.header),e.buffer.encode(d,o.blindResponse)},decode:d=>({header:Kn.decode(d),blindResponse:e.buffer.decode(d)})},wn=$,Rn=e.frame(kn),Pn={preencode(e,d){wn.preencode(e,d.header),Rn.preencode(e,d.invitation)},encode(e,d){wn.encode(e,d.header),Rn.encode(e,d.invitation)},decode:e=>({header:wn.decode(e),invitation:Rn.decode(e)})},Tn=$,An={preencode(d,o){Tn.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){Tn.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:Tn.decode(d),id:e.fixed32.decode(d)})},Mn={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.devicePublicKey),d.end++,o.privateProfileKey&&e.fixed32.preencode(d,o.privateProfileKey),o.deviceKeyPair&&r.preencode(d,o.deviceKeyPair),e.buffer.preencode(d,o.deviceProof)},encode(d,o){const n=(o.privateProfileKey?1:0)|(o.deviceKeyPair?2:0);e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.devicePublicKey),e.uint.encode(d,n),o.privateProfileKey&&e.fixed32.encode(d,o.privateProfileKey),o.deviceKeyPair&&r.encode(d,o.deviceKeyPair),e.buffer.encode(d,o.deviceProof)},decode(d){const o=e.fixed32.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{publicKey:o,devicePublicKey:n,privateProfileKey:1&c?e.fixed32.decode(d):null,deviceKeyPair:2&c?r.decode(d):null,deviceProof:e.buffer.decode(d)}}},Sn={preencode(o,n){o.end++,d>=35&&n.roomSnoozeTime&&e.uint.preencode(o,n.roomSnoozeTime)},encode(o,n){const c=(n.isActive?1:0)|(n.isFullyMuted?2:0)|(n.isMentionsOnlyMuted?4:0)|(d>=14&&n.isReadOnly?8:0)|(d>=27&&n.isFavorite?16:0)|(d>=31&&n.isUnread?32:0)|(d>=35&&n.roomSnoozeTime?64:0);e.uint.encode(o,c),d>=35&&n.roomSnoozeTime&&e.uint.encode(o,n.roomSnoozeTime)},decode(o){const n=e.uint.decode(o);return{isActive:!!(1&n),isFullyMuted:!!(2&n),isMentionsOnlyMuted:!!(4&n),isReadOnly:d>=14&&!!(8&n),isFavorite:d>=27&&!!(16&n),isUnread:d>=31&&!!(32&n),roomSnoozeTime:d>=35&&64&n?e.uint.decode(o):0}}},In=e.frame(Sn),Cn=e.frame(Mn),Vn=gn,Hn={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),In.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,c.initiator&&o.preencode(n,c.initiator),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),c.identitySwap&&Cn.preencode(n,c.identitySwap),d>=9&&c.identitySwapV2&&Vn.preencode(n,c.identitySwapV2),d>=15&&c.contact&&e.fixed32.preencode(n,c.contact),d>=37&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=39&&c.activeClock&&e.uint.preencode(n,c.activeClock)},encode(n,c){const r=(c.initiator?1:0)|(c.fastForwardTo?2:0)|(c.identitySwap?4:0)|(d>=9&&c.identitySwapV2?8:0)|(d>=15&&c.contact?16:0)|(d>=37&&c.bootFrom?32:0)|(d>=39&&c.activeClock?64:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),In.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,r),c.initiator&&o.encode(n,c.initiator),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),c.identitySwap&&Cn.encode(n,c.identitySwap),d>=9&&c.identitySwapV2&&Vn.encode(n,c.identitySwapV2),d>=15&&c.contact&&e.fixed32.encode(n,c.contact),d>=37&&c.bootFrom&&o.encode(n,c.bootFrom),d>=39&&c.activeClock&&e.uint.encode(n,c.activeClock)},decode(n){const c=e.fixed32.decode(n),r=e.buffer.decode(n),t=e.fixed32.decode(n),i=In.decode(n),a=e.uint.decode(n),s=e.uint.decode(n);return{roomKey:c,encryptionKey:r,mailbox:t,status:i,clock:a,initiator:1&s?o.decode(n):null,fastForwardTo:2&s?e.fixed32.decode(n):null,identitySwap:4&s?Cn.decode(n):null,identitySwapV2:d>=9&&8&s?Vn.decode(n):null,contact:d>=15&&16&s?e.fixed32.decode(n):null,bootFrom:d>=37&&32&s?o.decode(n):null,activeClock:d>=39&&64&s?e.uint.decode(n):0}}},Fn=$,Dn={preencode(d,n){Fn.preencode(d,n.header),e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.mailbox),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.dm&&e.fixed32.preencode(d,n.dm)},encode(n,c){const r=(c.fastForwardTo?1:0)|(c.initiator?2:0)|(c.dm?4:0)|(d>=14&&c.isReadOnly?8:0);Fn.encode(n,c.header),e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),e.uint.encode(n,r),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),c.initiator&&o.encode(n,c.initiator),c.dm&&e.fixed32.encode(n,c.dm)},decode(n){const c=Fn.decode(n),r=e.fixed32.decode(n),t=e.buffer.decode(n),i=e.fixed32.decode(n),a=e.uint.decode(n);return{header:c,roomKey:r,encryptionKey:t,mailbox:i,fastForwardTo:1&a?e.fixed32.decode(n):null,initiator:2&a?o.decode(n):null,dm:4&a?e.fixed32.decode(n):null,isReadOnly:d>=14&&!!(8&a)}}},Ln=$,jn={preencode(d,o){Ln.preencode(d,o.header),e.fixed32.preencode(d,o.discoveryKey)},encode(d,o){Ln.encode(d,o.header),e.fixed32.encode(d,o.discoveryKey)},decode:d=>({header:Ln.decode(d),discoveryKey:e.fixed32.decode(d)})},qn=$,Bn=In,En={preencode(d,o){qn.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.key),Bn.preencode(d,o.status)},encode(d,o){qn.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.key),Bn.encode(d,o.status)},decode:d=>({header:qn.decode(d),roomKey:e.fixed32.decode(d),key:e.uint.decode(d),status:Bn.decode(d)})},zn={preencode(e,d){e.end++},encode(o,n){const c=(n.isBlocked?1:0)|(d>=32&&n.isActive?2:0);e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{isBlocked:!!(1&n),isActive:d>=32&&!!(2&n)}}},On={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.clock),al.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=32&&n.contactInfo&&sl.preencode(o,n.contactInfo),d>=34&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=32&&n.contactInfo?4:0)|(d>=34&&n.alias?8:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.clock),al.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=32&&n.contactInfo&&sl.encode(o,n.contactInfo),d>=34&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),r=al.decode(o),t=e.uint.decode(o);return{memberKey:n,clock:c,status:r,mailbox:1&t?e.fixed32.decode(o):null,roomKey:2&t?e.fixed32.decode(o):null,contactInfo:d>=32&&4&t?sl.decode(o):null,alias:d>=34&&8&t?e.string.decode(o):null}}},Nn=$,Un=e.frame(an),Jn={preencode(e,d){Nn.preencode(e,d.header),Un.preencode(e,d.contact)},encode(e,d){Nn.encode(e,d.header),Un.encode(e,d.contact)},decode:e=>({header:Nn.decode(e),contact:Un.decode(e)})},Wn=$,Gn={preencode(d,o){Wn.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),ll.preencode(d,o.status)},encode(d,o){Wn.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),ll.encode(d,o.status)},decode:d=>({header:Wn.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:ll.decode(d)})},Qn=$,Xn={preencode(d,o){Qn.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Qn.encode(d,o.header),e.fixed32.encode(d,o.memberKey)},decode:d=>({header:Qn.decode(d),memberKey:e.fixed32.decode(d)})},Yn={preencode(e,d){e.end++},encode(d,o){const n=(o.isPending?1:0)|(o.isAccepted?2:0)|(o.isRejected?4:0)|(o.isDiscarded?8:0)|(o.isSeen?16:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isPending:!!(1&o),isAccepted:!!(2&o),isRejected:!!(4&o),isDiscarded:!!(8&o),isSeen:!!(16&o)}}},Zn=xe,$n=e.frame(t),_n={preencode(d,o){Zn.preencode(d,o.sender),$n.preencode(d,o.keys),e.fixed32.preencode(d,o.mailbox),d.end++,o.message&&e.string.preencode(d,o.message)},encode(d,o){const n=o.message?1:0;Zn.encode(d,o.sender),$n.encode(d,o.keys),e.fixed32.encode(d,o.mailbox),e.uint.encode(d,n),o.message&&e.string.encode(d,o.message)},decode:d=>({sender:Zn.decode(d),keys:$n.decode(d),mailbox:e.fixed32.decode(d),message:1&e.uint.decode(d)?e.string.decode(d):null})},ec=e.frame(_n),dc={preencode(o,n){ec.preencode(o,n.body),ne.preencode(o,n.attestation),o.end++,d>=41&&n.recipientProof&&e.buffer.preencode(o,n.recipientProof)},encode(o,n){const c=d>=41&&n.recipientProof?1:0;ec.encode(o,n.body),ne.encode(o,n.attestation),e.uint.encode(o,c),d>=41&&n.recipientProof&&e.buffer.encode(o,n.recipientProof)},decode(o){const n=ec.decode(o),c=ne.decode(o),r=o.start<o.end?e.uint.decode(o):0;return{body:n,attestation:c,recipientProof:d>=41&&1&r?e.buffer.decode(o):null}}},oc=le,nc=e.frame(Yn),cc=$n,rc={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.clock),oc.preencode(o,n.sender),nc.preencode(o,n.status),cc.preencode(o,n.keys),e.fixed32.preencode(o,n.mailbox),o.end++,n.message&&e.string.preencode(o,n.message),d>=17&&n.sentAt&&e.uint.preencode(o,n.sentAt),d>=32&&n.contactInfo&&pl.preencode(o,n.contactInfo)},encode(o,n){const c=(n.message?1:0)|(d>=17&&n.sentAt?2:0)|(d>=32&&n.contactInfo?4:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.clock),oc.encode(o,n.sender),nc.encode(o,n.status),cc.encode(o,n.keys),e.fixed32.encode(o,n.mailbox),e.uint.encode(o,c),n.message&&e.string.encode(o,n.message),d>=17&&n.sentAt&&e.uint.encode(o,n.sentAt),d>=32&&n.contactInfo&&pl.encode(o,n.contactInfo)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),r=oc.decode(o),t=nc.decode(o),i=cc.decode(o),a=e.fixed32.decode(o),s=e.uint.decode(o);return{memberKey:n,clock:c,sender:r,status:t,keys:i,mailbox:a,message:1&s?e.string.decode(o):null,sentAt:d>=17&&2&s?e.uint.decode(o):0,contactInfo:d>=32&&4&s?pl.decode(o):null}}},tc=$,ic={preencode(d,o){tc.preencode(d,o.header),e.buffer.preencode(d,o.blindRequest)},encode(d,o){tc.encode(d,o.header),e.buffer.encode(d,o.blindRequest)},decode:d=>({header:tc.decode(d),blindRequest:e.buffer.decode(d)})},ac=$,sc=nc,lc={preencode(o,n){ac.preencode(o,n.header),e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.key),sc.preencode(o,n.status),o.end++,d>=15&&n.roomKey&&e.fixed32.preencode(o,n.roomKey)},encode(o,n){const c=d>=15&&n.roomKey?1:0;ac.encode(o,n.header),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.key),sc.encode(o,n.status),e.uint.encode(o,c),d>=15&&n.roomKey&&e.fixed32.encode(o,n.roomKey)},decode(o){const n=ac.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o),t=sc.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{header:n,memberKey:c,key:r,status:t,roomKey:d>=15&&1&i?e.fixed32.decode(o):null}}},pc={preencode(d,o){e.uint.preencode(d,o.timestamp),e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.mailbox)},encode(d,o){e.uint.encode(d,o.timestamp),e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.mailbox)},decode:d=>({version:0,timestamp:e.uint.decode(d),key:e.fixed32.decode(d),mailbox:e.fixed32.decode(d)})},uc={preencode(d,o){const n=o.version??1;switch(e.uint.preencode(d,n),n){case 0:case 1:pc.preencode(d,o);break;default:throw new Error("Unsupported version")}},encode(d,o){const n=o.version??1;switch(e.uint.encode(d,n),n){case 0:case 1:pc.encode(d,o);break;default:throw new Error("Unsupported version")}},decode(d){const o=e.uint.decode(d);switch(o){case 0:case 1:{const e=pc.decode(d);return e.version=o,e}default:throw new Error("Unsupported version")}}},fc={preencode(d,o){e.fixed32.preencode(d,o.discoveryPublicKey),e.uint.preencode(d,o.timestamp),d.end++,o.lastSynced&&e.uint.preencode(d,o.lastSynced)},encode(d,o){const n=(o.lastSynced?1:0)|(o.dirty?2:0);e.fixed32.encode(d,o.discoveryPublicKey),e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.lastSynced&&e.uint.encode(d,o.lastSynced)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d),c=e.uint.decode(d);return{discoveryPublicKey:o,timestamp:n,lastSynced:1&c?e.uint.decode(d):0,dirty:!!(2&c)}}},mc={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.activeRooms)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.activeRooms)},decode:d=>({rooms:e.uint.decode(d),activeRooms:e.uint.decode(d)})},yc=C,bc=X,xc={preencode(e,d){e.end++,d.blockedMembers&&bc.preencode(e,d.blockedMembers)},encode(d,o){const n=o.blockedMembers?1:0;e.uint.encode(d,n),o.blockedMembers&&bc.encode(d,o.blockedMembers)},decode:d=>({blockedMembers:1&e.uint.decode(d)?bc.decode(d):null})},vc=e.frame(Q),gc=e.frame(xc),kc={preencode(d,n){e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.seed),vc.preencode(d,n.capabilities),o.preencode(d,n.initiator),e.fixed32.preencode(d,n.fastForwardTo),d.end++,n.privateProfile&&gc.preencode(d,n.privateProfile)},encode(d,n){const c=n.privateProfile?1:0;e.buffer.encode(d,n.encryptionKey),e.fixed32.encode(d,n.seed),vc.encode(d,n.capabilities),o.encode(d,n.initiator),e.fixed32.encode(d,n.fastForwardTo),e.uint.encode(d,c),n.privateProfile&&gc.encode(d,n.privateProfile)},decode:d=>({encryptionKey:e.buffer.decode(d),seed:e.fixed32.decode(d),capabilities:vc.decode(d),initiator:o.decode(d),fastForwardTo:e.fixed32.decode(d),privateProfile:1&e.uint.decode(d)?gc.decode(d):null})},Kc={preencode(d,o){d.end++,o.count&&e.uint.preencode(d,o.count)},encode(d,o){const n=o.count?1:0;e.uint.encode(d,n),o.count&&e.uint.encode(d,o.count)},decode:d=>({count:1&e.uint.decode(d)?e.uint.decode(d):0})},hc=e.frame(kc),wc={preencode(o,n){e.fixed32.preencode(o,n.roomKey),e.uint.preencode(o,n.priority),o.end++,n.v3&&hc.preencode(o,n.v3),d>=5&&n.timestamp&&e.uint.preencode(o,n.timestamp)},encode(o,n){const c=(n.v3?1:0)|(d>=3&&n.errored?2:0)|(d>=5&&n.timestamp?4:0);e.fixed32.encode(o,n.roomKey),e.uint.encode(o,n.priority),e.uint.encode(o,c),n.v3&&hc.encode(o,n.v3),d>=5&&n.timestamp&&e.uint.encode(o,n.timestamp)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),r=e.uint.decode(o);return{roomKey:n,priority:c,v3:1&r?hc.decode(o):null,errored:d>=3&&!!(2&r),timestamp:d>=5&&4&r?e.uint.decode(o):0}}},Rc={preencode(e,d){e.end++},encode(d,o){const n=o.isConfirmed?1:0;e.uint.encode(d,n)},decode:d=>({isConfirmed:!!(1&e.uint.decode(d))})},Pc=e.frame(Rc),Tc=Cn,Ac={preencode(o,n){e.fixed32.preencode(o,n.publicKey),e.fixed32.preencode(o,n.privateProfileKey),r.preencode(o,n.deviceKeyPair),e.buffer.preencode(o,n.deviceProof),Pc.preencode(o,n.status),o.end++,n.entropy&&e.buffer.preencode(o,n.entropy),n.swap&&Tc.preencode(o,n.swap),d>=9&&n.swapV2&&ul.preencode(o,n.swapV2),d>=31&&n.proofShortenedAt&&e.uint.preencode(o,n.proofShortenedAt)},encode(o,n){const c=(n.entropy?1:0)|(n.swap?2:0)|(d>=9&&n.swapV2?4:0)|(d>=31&&n.proofShortenedAt?8:0);e.fixed32.encode(o,n.publicKey),e.fixed32.encode(o,n.privateProfileKey),r.encode(o,n.deviceKeyPair),e.buffer.encode(o,n.deviceProof),Pc.encode(o,n.status),e.uint.encode(o,c),n.entropy&&e.buffer.encode(o,n.entropy),n.swap&&Tc.encode(o,n.swap),d>=9&&n.swapV2&&ul.encode(o,n.swapV2),d>=31&&n.proofShortenedAt&&e.uint.encode(o,n.proofShortenedAt)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=r.decode(o),i=e.buffer.decode(o),a=Pc.decode(o),s=e.uint.decode(o);return{publicKey:n,privateProfileKey:c,deviceKeyPair:t,deviceProof:i,status:a,entropy:1&s?e.buffer.decode(o):null,swap:2&s?Tc.decode(o):null,swapV2:d>=9&&4&s?ul.decode(o):null,proofShortenedAt:d>=31&&8&s?e.uint.decode(o):0}}},Mc={RestoreIdentity:1,CreateRoom:2,LeaveRoom:3,ClearRoom:4,JoinRoomInvitation:5,JoinRoomKeys:6,JoinRoomResponse:7,SendContactRequest:8,TestFastTask:9,TestSlowTask:10,TestErrorTask:11},Sc={preencode(e,d){e.end++},encode(d,o){if(o>11)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Ic={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator)},encode(d,n){const c=(n.fastForwardTo?1:0)|(n.initiator?2:0);e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.uint.encode(d,c),n.fastForwardTo&&e.fixed32.encode(d,n.fastForwardTo),n.initiator&&o.encode(d,n.initiator)},decode(d){const n=e.fixed32.decode(d),c=e.buffer.decode(d),r=e.uint.decode(d);return{roomKey:n,encryptionKey:c,fastForwardTo:1&r?e.fixed32.decode(d):null,initiator:2&r?o.decode(d):null}}},Cc=Rn,Vc={preencode(e,d){Cc.preencode(e,d.invitation)},encode(e,d){Cc.encode(e,d.invitation)},decode:e=>({invitation:Cc.decode(e)})},Hc={preencode(d,o){e.fixed32.preencode(d,o.mailbox),r.preencode(d,o.keyPair),e.buffer.preencode(d,o.response)},encode(d,o){e.fixed32.encode(d,o.mailbox),r.encode(d,o.keyPair),e.buffer.encode(d,o.response)},decode:d=>({mailbox:e.fixed32.decode(d),keyPair:r.decode(d),response:e.buffer.decode(d)})},Fc=Z,Dc={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.mailbox&&e.fixed32.preencode(d,n.mailbox)},encode(d,n){const c=(n.fastForwardTo?1:0)|(n.initiator?2:0)|(n.mailbox?4:0);e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.uint.encode(d,c),n.fastForwardTo&&e.fixed32.encode(d,n.fastForwardTo),n.initiator&&o.encode(d,n.initiator),n.mailbox&&e.fixed32.encode(d,n.mailbox)},decode(d){const n=e.fixed32.decode(d),c=e.buffer.decode(d),r=e.uint.decode(d);return{roomKey:n,encryptionKey:c,fastForwardTo:1&r?e.fixed32.decode(d):null,initiator:2&r?o.decode(d):null,mailbox:4&r?e.fixed32.decode(d):null}}},Lc=e.frame(Dc),jc={preencode(o,n){Lc.preencode(o,n.keys),o.end++,d>=39&&n.activeClock&&e.uint.preencode(o,n.activeClock)},encode(o,n){const c=(d>=39&&n.activeClock?1:0)|(d>=39&&n.isReadOnly?2:0);Lc.encode(o,n.keys),e.uint.encode(o,c),d>=39&&n.activeClock&&e.uint.encode(o,n.activeClock)},decode(o){const n=Lc.decode(o),c=o.start<o.end?e.uint.decode(o):0;return{keys:n,activeClock:d>=39&&1&c?e.uint.decode(o):0,isReadOnly:d>=39&&!!(2&c)}}},qc=e.frame(dn),Bc={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.mailbox&&e.fixed32.preencode(d,n.mailbox),n.keyPair&&r.preencode(d,n.keyPair),n.genesis&&qc.preencode(d,n.genesis)},encode(d,n){const c=(n.fastForwardTo?1:0)|(n.initiator?2:0)|(n.mailbox?4:0)|(n.keyPair?8:0)|(n.genesis?16:0)|(n.isPrivateProfile?32:0);e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.uint.encode(d,c),n.fastForwardTo&&e.fixed32.encode(d,n.fastForwardTo),n.initiator&&o.encode(d,n.initiator),n.mailbox&&e.fixed32.encode(d,n.mailbox),n.keyPair&&r.encode(d,n.keyPair),n.genesis&&qc.encode(d,n.genesis)},decode(d){const n=e.fixed32.decode(d),c=e.buffer.decode(d),t=e.uint.decode(d);return{roomKey:n,encryptionKey:c,fastForwardTo:1&t?e.fixed32.decode(d):null,initiator:2&t?o.decode(d):null,mailbox:4&t?e.fixed32.decode(d):null,keyPair:8&t?r.decode(d):null,genesis:16&t?qc.decode(d):null,isPrivateProfile:!!(32&t)}}},Ec={preencode(d,o){e.fixed32.preencode(d,o.roomKey),d.end++},encode(d,o){const n=o.isGossiped?1:0;e.fixed32.encode(d,o.roomKey),e.uint.encode(d,n)},decode:d=>({roomKey:e.fixed32.decode(d),isGossiped:!!(1&e.uint.decode(d))})},zc={preencode(d,o){e.fixed32.preencode(d,o.roomKey)},encode(d,o){e.fixed32.encode(d,o.roomKey)},decode:d=>({roomKey:e.fixed32.decode(d)})},Oc={preencode(d,o){e.string.preencode(d,o.mnemonic),d.end++,o.profileDiscoveryTimeout&&e.uint.preencode(d,o.profileDiscoveryTimeout)},encode(d,o){const n=(o.profileDiscoveryTimeout?1:0)|(o.recover?2:0);e.string.encode(d,o.mnemonic),e.uint.encode(d,n),o.profileDiscoveryTimeout&&e.uint.encode(d,o.profileDiscoveryTimeout)},decode(d){const o=e.string.decode(d),n=e.uint.decode(d);return{mnemonic:o,profileDiscoveryTimeout:1&n?e.uint.decode(d):0,recover:!!(2&n)}}},Nc={preencode(o,n){e.fixed32.preencode(o,n.roomKey),e.fixed32.preencode(o,n.memberKey),o.end++,n.message&&e.string.preencode(o,n.message),d>=6&&n.contactInfo&&fl.preencode(o,n.contactInfo)},encode(o,n){const c=(n.message?1:0)|(d>=6&&n.contactInfo?2:0);e.fixed32.encode(o,n.roomKey),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,c),n.message&&e.string.encode(o,n.message),d>=6&&n.contactInfo&&fl.encode(o,n.contactInfo)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{roomKey:n,memberKey:c,message:1&r?e.string.decode(o):null,contactInfo:d>=6&&2&r?fl.decode(o):null}}},Uc={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++},encode(d,o){const n=o.isPrivateProfile?1:0;e.fixed32.encode(d,o.key),e.uint.encode(d,n)},decode:d=>({key:e.fixed32.decode(d),isPrivateProfile:!!(1&e.uint.decode(d))})},Jc=e.frame(Oc),Wc=e.frame(Bc),Gc=e.frame(Ec),Qc=e.frame(zc),Xc=e.frame(Vc),Yc=e.frame(jc),Zc=e.frame(Hc),$c=e.frame(Nc),_c=e.frame(Uc),er={preencode(d,o){const n=(o.restoreIdentity?1:0)|(o.createRoom?2:0)|(o.leaveRoom?4:0)|(o.clearRoom?8:0)|(o.joinRoomInvitation?16:0)|(o.joinRoomKeys?32:0)|(o.joinRoomResponse?64:0)|(o.sendContactRequest?128:0)|(o.migrateV2Room?256:0);e.fixed32.preencode(d,o.discoveryKey),e.uint.preencode(d,o.priority),e.uint.preencode(d,o.timestamp),e.uint.preencode(d,o.type),e.uint.preencode(d,n),o.restoreIdentity&&Jc.preencode(d,o.restoreIdentity),o.createRoom&&Wc.preencode(d,o.createRoom),o.leaveRoom&&Gc.preencode(d,o.leaveRoom),o.clearRoom&&Qc.preencode(d,o.clearRoom),o.joinRoomInvitation&&Xc.preencode(d,o.joinRoomInvitation),o.joinRoomKeys&&Yc.preencode(d,o.joinRoomKeys),o.joinRoomResponse&&Zc.preencode(d,o.joinRoomResponse),o.sendContactRequest&&$c.preencode(d,o.sendContactRequest),o.migrateV2Room&&_c.preencode(d,o.migrateV2Room)},encode(d,o){const n=(o.restoreIdentity?1:0)|(o.createRoom?2:0)|(o.leaveRoom?4:0)|(o.clearRoom?8:0)|(o.joinRoomInvitation?16:0)|(o.joinRoomKeys?32:0)|(o.joinRoomResponse?64:0)|(o.sendContactRequest?128:0)|(o.migrateV2Room?256:0);e.fixed32.encode(d,o.discoveryKey),e.uint.encode(d,o.priority),e.uint.encode(d,o.timestamp),e.uint.encode(d,o.type),e.uint.encode(d,n),o.restoreIdentity&&Jc.encode(d,o.restoreIdentity),o.createRoom&&Wc.encode(d,o.createRoom),o.leaveRoom&&Gc.encode(d,o.leaveRoom),o.clearRoom&&Qc.encode(d,o.clearRoom),o.joinRoomInvitation&&Xc.encode(d,o.joinRoomInvitation),o.joinRoomKeys&&Yc.encode(d,o.joinRoomKeys),o.joinRoomResponse&&Zc.encode(d,o.joinRoomResponse),o.sendContactRequest&&$c.encode(d,o.sendContactRequest),o.migrateV2Room&&_c.encode(d,o.migrateV2Room)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d),c=e.uint.decode(d),r=e.uint.decode(d),t=e.uint.decode(d);return{discoveryKey:o,priority:n,timestamp:c,type:r,restoreIdentity:1&t?Jc.decode(d):null,createRoom:2&t?Wc.decode(d):null,leaveRoom:4&t?Gc.decode(d):null,clearRoom:8&t?Qc.decode(d):null,joinRoomInvitation:16&t?Xc.decode(d):null,joinRoomKeys:32&t?Yc.decode(d):null,joinRoomResponse:64&t?Zc.decode(d):null,sendContactRequest:128&t?$c.decode(d):null,migrateV2Room:256&t?_c.decode(d):null}}},dr=Le,or={preencode(d,o){e.buffer.preencode(d,o.seed),dr.preencode(d,o.invitation)},encode(d,o){e.buffer.encode(d,o.seed),dr.encode(d,o.invitation)},decode:d=>({seed:e.buffer.decode(d),invitation:dr.decode(d)})},nr={preencode(e,d){e.end++},encode(o,n){const c=(n.isWritable?1:0)|(n.isReadable?2:0)|(n.isPrivateProfile?4:0)|(d>=8&&n.isRemoved?8:0);e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{isWritable:!!(1&n),isReadable:!!(2&n),isPrivateProfile:!!(4&n),isRemoved:d>=8&&!!(8&n)}}},cr={preencode(d,o){e.uint.preencode(d,o.creation),e.uint.preencode(d,o.latestSync),e.uint.preencode(d,o.latestChatMessage)},encode(d,o){e.uint.encode(d,o.creation),e.uint.encode(d,o.latestSync),e.uint.encode(d,o.latestChatMessage)},decode:d=>({creation:e.uint.decode(d),latestSync:e.uint.decode(d),latestChatMessage:e.uint.decode(d)})},rr=Xo,tr=fo,ir=e.frame(cr),ar=vc,sr=e.frame(nr),lr=e.frame(ie),pr=e.frame(ud),ur=Oo,fr=$o,mr=e.frame(ho),yr=X,br=e.frame(sd),xr=In,vr={preencode(o,n){const c=(n.selfDevice?1:0)|(n.selfMember?2:0)|(n.config?4:0)|(n.identity?8:0)|(n.lastMessage?16:0)|(n.dm?32:0)|(d>=19&&n.readLengths?64:0)|(d>=19&&n.lastMember?128:0)|(d>=21&&n.version?256:0)|(d>=27&&n.preferences?512:0)|(d>=28&&n.activeCall?1024:0)|(d>=32&&n.lastMessageLabels?2048:0)|(d>=33&&n.settings?4096:0)|(d>=37&&n.system?8192:0)|(d>=37&&n.processed?16384:0);e.fixed32.preencode(o,n.roomKey),e.fixed32.preencode(o,n.discoveryKey),e.buffer.preencode(o,n.encryptionKey),rr.preencode(o,n.digest),tr.preencode(o,n.stats),ir.preencode(o,n.timestamps),e.uint.preencode(o,n.fork),e.uint.preencode(o,n.length),e.fixed32.preencode(o,n.seed),ar.preencode(o,n.capabilities),sr.preencode(o,n.status),e.uint.preencode(o,c),n.selfDevice&&lr.preencode(o,n.selfDevice),n.selfMember&&pr.preencode(o,n.selfMember),n.config&&ur.preencode(o,n.config),n.identity&&fr.preencode(o,n.identity),n.lastMessage&&mr.preencode(o,n.lastMessage),n.dm&&yr.preencode(o,n.dm),d>=19&&n.readLengths&&ml.preencode(o,n.readLengths),d>=19&&n.lastMember&&br.preencode(o,n.lastMember),d>=21&&n.version&&e.uint.preencode(o,n.version),d>=27&&n.preferences&&xr.preencode(o,n.preferences),d>=28&&n.activeCall&&yl.preencode(o,n.activeCall),d>=32&&n.lastMessageLabels&&bl.preencode(o,n.lastMessageLabels),d>=33&&n.settings&&xl.preencode(o,n.settings),d>=37&&n.system&&vl.preencode(o,n.system),d>=37&&n.processed&&gl.preencode(o,n.processed)},encode(o,n){const c=(n.selfDevice?1:0)|(n.selfMember?2:0)|(n.config?4:0)|(n.identity?8:0)|(n.lastMessage?16:0)|(n.dm?32:0)|(d>=19&&n.readLengths?64:0)|(d>=19&&n.lastMember?128:0)|(d>=21&&n.version?256:0)|(d>=27&&n.preferences?512:0)|(d>=28&&n.activeCall?1024:0)|(d>=32&&n.lastMessageLabels?2048:0)|(d>=33&&n.settings?4096:0)|(d>=37&&n.system?8192:0)|(d>=37&&n.processed?16384:0);e.fixed32.encode(o,n.roomKey),e.fixed32.encode(o,n.discoveryKey),e.buffer.encode(o,n.encryptionKey),rr.encode(o,n.digest),tr.encode(o,n.stats),ir.encode(o,n.timestamps),e.uint.encode(o,n.fork),e.uint.encode(o,n.length),e.fixed32.encode(o,n.seed),ar.encode(o,n.capabilities),sr.encode(o,n.status),e.uint.encode(o,c),n.selfDevice&&lr.encode(o,n.selfDevice),n.selfMember&&pr.encode(o,n.selfMember),n.config&&ur.encode(o,n.config),n.identity&&fr.encode(o,n.identity),n.lastMessage&&mr.encode(o,n.lastMessage),n.dm&&yr.encode(o,n.dm),d>=19&&n.readLengths&&ml.encode(o,n.readLengths),d>=19&&n.lastMember&&br.encode(o,n.lastMember),d>=21&&n.version&&e.uint.encode(o,n.version),d>=27&&n.preferences&&xr.encode(o,n.preferences),d>=28&&n.activeCall&&yl.encode(o,n.activeCall),d>=32&&n.lastMessageLabels&&bl.encode(o,n.lastMessageLabels),d>=33&&n.settings&&xl.encode(o,n.settings),d>=37&&n.system&&vl.encode(o,n.system),d>=37&&n.processed&&gl.encode(o,n.processed)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.buffer.decode(o),t=rr.decode(o),i=tr.decode(o),a=ir.decode(o),s=e.uint.decode(o),l=e.uint.decode(o),p=e.fixed32.decode(o),u=ar.decode(o),f=sr.decode(o),m=e.uint.decode(o);return{roomKey:n,discoveryKey:c,encryptionKey:r,digest:t,stats:i,timestamps:a,fork:s,length:l,seed:p,capabilities:u,status:f,selfDevice:1&m?lr.decode(o):null,selfMember:2&m?pr.decode(o):null,config:4&m?ur.decode(o):null,identity:8&m?fr.decode(o):null,lastMessage:16&m?mr.decode(o):null,dm:32&m?yr.decode(o):null,readLengths:d>=19&&64&m?ml.decode(o):null,lastMember:d>=19&&128&m?br.decode(o):null,version:d>=21&&256&m?e.uint.decode(o):0,preferences:d>=27&&512&m?xr.decode(o):null,activeCall:d>=28&&1024&m?yl.decode(o):null,lastMessageLabels:d>=32&&2048&m?bl.decode(o):null,settings:d>=33&&4096&m?xl.decode(o):null,system:d>=37&&8192&m?vl.decode(o):null,processed:d>=37&&16384&m?gl.decode(o):null}}},gr=In,kr={preencode(d,o){e.fixed32.preencode(d,o.roomKey),gr.preencode(d,o.status)},encode(d,o){e.fixed32.encode(d,o.roomKey),gr.encode(d,o.status)},decode:d=>({roomKey:e.fixed32.decode(d),status:gr.decode(d)})},Kr={preencode(o,n){e.fixed32.preencode(o,n.mailbox),e.fixed32.preencode(o,n.key),o.end++,n.roomKey&&e.fixed32.preencode(o,n.roomKey),n.keyPair&&r.preencode(o,n.keyPair),n.responseKeyPair&&r.preencode(o,n.responseKeyPair),d>=39&&n.activeClock&&e.uint.preencode(o,n.activeClock)},encode(o,n){const c=(n.roomKey?1:0)|(n.keyPair?2:0)|(n.responseKeyPair?4:0)|(d>=38&&n.pending?8:0)|(d>=39&&n.activeClock?16:0);e.fixed32.encode(o,n.mailbox),e.fixed32.encode(o,n.key),e.uint.encode(o,c),n.roomKey&&e.fixed32.encode(o,n.roomKey),n.keyPair&&r.encode(o,n.keyPair),n.responseKeyPair&&r.encode(o,n.responseKeyPair),d>=39&&n.activeClock&&e.uint.encode(o,n.activeClock)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=e.uint.decode(o);return{mailbox:n,key:c,roomKey:1&t?e.fixed32.decode(o):null,keyPair:2&t?r.decode(o):null,responseKeyPair:4&t?r.decode(o):null,pending:d>=38&&!!(8&t),activeClock:d>=39&&16&t?e.uint.decode(o):0}}},hr=le,wr={preencode(d,o){e.fixed32.preencode(d,o.key),hr.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),hr.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),profile:hr.decode(d)})},Rr=lr,Pr={preencode(d,o){e.fixed32.preencode(d,o.roomKey),Rr.preencode(d,o.device)},encode(d,o){e.fixed32.encode(d,o.roomKey),Rr.encode(d,o.device)},decode:d=>({roomKey:e.fixed32.decode(d),device:Rr.decode(d)})},Tr=k,Ar={preencode(o,n){Tr.preencode(o,n.file),e.fixed32.preencode(o,n.roomKey),o.end++,n.encryptionKey&&e.buffer.preencode(o,n.encryptionKey),d>=28&&n.lastAccessed&&e.uint.preencode(o,n.lastAccessed),d>=28&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(n.encryptionKey?1:0)|(n.cleared?2:0)|(n.own?4:0)|(d>=28&&n.lastAccessed?8:0)|(d>=28&&n.version?16:0);Tr.encode(o,n.file),e.fixed32.encode(o,n.roomKey),e.uint.encode(o,c),n.encryptionKey&&e.buffer.encode(o,n.encryptionKey),d>=28&&n.lastAccessed&&e.uint.encode(o,n.lastAccessed),d>=28&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=Tr.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{file:n,roomKey:c,encryptionKey:1&r?e.buffer.decode(o):null,cleared:!!(2&r),own:!!(4&r),lastAccessed:d>=28&&8&r?e.uint.decode(o):0,version:d>=28&&16&r?e.uint.decode(o):0}}},Mr=$,Sr={preencode(o,c){Mr.preencode(o,c.header),n.preencode(o,c.oplog),e.uint.preencode(o,c.index),kl.preencode(o,c.preview),o.end++,d>=12&&c.displayType&&Gr.preencode(o,c.displayType)},encode(o,c){const r=d>=12&&c.displayType?1:0;Mr.encode(o,c.header),n.encode(o,c.oplog),e.uint.encode(o,c.index),kl.encode(o,c.preview),e.uint.encode(o,r),d>=12&&c.displayType&&Gr.encode(o,c.displayType)},decode(o){const c=Mr.decode(o),r=n.decode(o),t=e.uint.decode(o),i=kl.decode(o),a=o.start<o.end?e.uint.decode(o):0;return{header:c,oplog:r,index:t,preview:i,displayType:d>=12&&1&a?Gr.decode(o):0}}},Ir={preencode(o,n){o.end++,d>=4&&n.memberKey&&e.fixed32.preencode(o,n.memberKey)},encode(o,n){const c=d>=4&&n.memberKey?1:0;e.uint.encode(o,c),d>=4&&n.memberKey&&e.fixed32.encode(o,n.memberKey)},decode(o){const n=e.uint.decode(o);return{memberKey:d>=4&&1&n?e.fixed32.decode(o):null}}},Cr=le,Vr={preencode(e,d){Cr.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){Cr.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:Cr.decode(e),attestation:ne.decode(e)})},Hr=$,Fr={preencode(d,o){Hr.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){Hr.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:Hr.decode(d),key:e.fixed32.decode(d)})},Dr={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),ne.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){e.fixed32.encode(d,o.deviceKey),ne.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({deviceKey:e.fixed32.decode(d),privateProfileIdentity:ne.decode(d),deviceProof:e.buffer.decode(d)})},Lr={preencode(o,n){e.fixed32.preencode(o,n.roomKey),e.fixed32.preencode(o,n.encryptionKey),e.fixed32.preencode(o,n.seed),o.end++,d>=9&&n.fastForwardTo&&e.fixed32.preencode(o,n.fastForwardTo)},encode(o,n){const c=d>=9&&n.fastForwardTo?1:0;e.fixed32.encode(o,n.roomKey),e.fixed32.encode(o,n.encryptionKey),e.fixed32.encode(o,n.seed),e.uint.encode(o,c),d>=9&&n.fastForwardTo&&e.fixed32.encode(o,n.fastForwardTo)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o);return{roomKey:n,encryptionKey:c,seed:r,fastForwardTo:d>=9&&1&t?e.fixed32.decode(o):null}}},jr={preencode(o,n){e.fixed32.preencode(o,n.publicKey),e.fixed32.preencode(o,n.writerKey),e.fixed32.preencode(o,n.devicePublicKey),o.end++,d>=9&&n.privateProfileKey&&e.fixed32.preencode(o,n.privateProfileKey)},encode(o,n){const c=d>=9&&n.privateProfileKey?1:0;e.fixed32.encode(o,n.publicKey),e.fixed32.encode(o,n.writerKey),e.fixed32.encode(o,n.devicePublicKey),e.uint.encode(o,c),d>=9&&n.privateProfileKey&&e.fixed32.encode(o,n.privateProfileKey)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o);return{publicKey:n,writerKey:c,devicePublicKey:r,privateProfileKey:d>=9&&1&t?e.fixed32.decode(o):null}}},qr=$,Br={preencode(d,o){qr.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey)},encode(d,o){qr.encode(d,o.header),e.fixed32.encode(d,o.memberKey)},decode:d=>({header:qr.decode(d),memberKey:e.fixed32.decode(d)})},Er={preencode(d,o){e.fixed32.preencode(d,o.privateProfileKey)},encode(d,o){e.fixed32.encode(d,o.privateProfileKey)},decode:d=>({privateProfileKey:e.fixed32.decode(d)})},zr={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.responsePublicKey)},encode(d,o){e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.responsePublicKey)},decode:d=>({key:e.fixed32.decode(d),responsePublicKey:e.fixed32.decode(d)})},Or={preencode(o,n){e.fixed32.preencode(o,n.roomKey),o.end++,d>=10&&n.repairs&&e.uint.preencode(o,n.repairs)},encode(o,n){const c=d>=10&&n.repairs?1:0;e.fixed32.encode(o,n.roomKey),e.uint.encode(o,c),d>=10&&n.repairs&&e.uint.encode(o,n.repairs)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o);return{roomKey:n,repairs:d>=10&&1&c?e.uint.decode(o):0}}},Nr={preencode(o,n){o.end++,d>=11&&n.key&&e.string.preencode(o,n.key),d>=11&&n.description&&e.string.preencode(o,n.description)},encode(o,n){const c=(d>=11&&n.key?1:0)|(d>=11&&n.value?2:0)|(d>=11&&n.description?4:0);e.uint.encode(o,c),d>=11&&n.key&&e.string.encode(o,n.key),d>=11&&n.description&&e.string.encode(o,n.description)},decode(o){const n=e.uint.decode(o);return{key:d>=11&&1&n?e.string.decode(o):null,value:d>=11&&!!(2&n),description:d>=11&&4&n?e.string.decode(o):null}}},Ur=e.array(e.frame(Nr)),Jr={preencode(e,o){e.end++,d>=11&&o.flags&&Ur.preencode(e,o.flags)},encode(o,n){const c=d>=11&&n.flags?1:0;e.uint.encode(o,c),d>=11&&n.flags&&Ur.encode(o,n.flags)},decode(o){const n=e.uint.decode(o);return{flags:d>=11&&1&n?Ur.decode(o):null}}},Wr={HttpLink:1,PearLink:2},Gr={preencode(e,d){e.end++},encode(d,o){if(o>2)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Qr=$,Xr={preencode(d,o){Qr.preencode(d,o.header),e.uint.preencode(d,o.value)},encode(d,o){Qr.encode(d,o.header),e.uint.encode(d,o.value)},decode:d=>({header:Qr.decode(d),value:e.uint.decode(d)})},Yr={preencode(d,o){e.uint.preencode(d,o.key),e.uint.preencode(d,o.value)},encode(d,o){e.uint.encode(d,o.key),e.uint.encode(d,o.value)},decode:d=>({key:e.uint.decode(d),value:e.uint.decode(d)})},Zr=$,$r={preencode(o,n){Zr.preencode(o,n.header),e.uint.preencode(o,n.from),e.uint.preencode(o,n.to),o.end++,d>=29&&n.buildType&&xi.preencode(o,n.buildType)},encode(o,n){const c=d>=29&&n.buildType?1:0;Zr.encode(o,n.header),e.uint.encode(o,n.from),e.uint.encode(o,n.to),e.uint.encode(o,c),d>=29&&n.buildType&&xi.encode(o,n.buildType)},decode(o){const n=Zr.decode(o),c=e.uint.decode(o),r=e.uint.decode(o),t=o.start<o.end?e.uint.decode(o):0;return{header:n,from:c,to:r,buildType:d>=29&&1&t?xi.decode(o):null}}},_r={RoomType:1,IsExperimental:2,IsJoiningDisabled:3,IsAppendingDisabled:4,IsCallingDisabled:5,IsMembershipEventsDisabled:6,IsAttachmentsDisabled:7,IsLinksDisabled:8,IsRoomInviteHidden:9},et={preencode(e,d){e.end++},encode(d,o){if(o>9)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},dt=We,ot={preencode(o,n){o.end++,d>=16&&n.nodes&&dt.preencode(o,n.nodes),d>=24&&n.concurrency&&e.uint.preencode(o,n.concurrency),d>=24&&n.maxWindow&&e.uint.preencode(o,n.maxWindow),d>=24&&n.randomPunchInterval&&e.uint.preencode(o,n.randomPunchInterval),d>=24&&n.connectionKeepAlive&&e.uint.preencode(o,n.connectionKeepAlive)},encode(o,n){const c=(d>=16&&n.nodes?1:0)|(d>=24&&n.concurrency?2:0)|(d>=24&&n.maxWindow?4:0)|(d>=24&&n.randomPunchInterval?8:0)|(d>=24&&n.connectionKeepAlive?16:0);e.uint.encode(o,c),d>=16&&n.nodes&&dt.encode(o,n.nodes),d>=24&&n.concurrency&&e.uint.encode(o,n.concurrency),d>=24&&n.maxWindow&&e.uint.encode(o,n.maxWindow),d>=24&&n.randomPunchInterval&&e.uint.encode(o,n.randomPunchInterval),d>=24&&n.connectionKeepAlive&&e.uint.encode(o,n.connectionKeepAlive)},decode(o){const n=e.uint.decode(o);return{nodes:d>=16&&1&n?dt.decode(o):null,concurrency:d>=24&&2&n?e.uint.decode(o):0,maxWindow:d>=24&&4&n?e.uint.decode(o):0,randomPunchInterval:d>=24&&8&n?e.uint.decode(o):0,connectionKeepAlive:d>=24&&16&n?e.uint.decode(o):0}}},nt={en:"en",it:"it",ru:"ru",es:"es",de:"de"},ct={preencode(e,d){e.end++},encode(d,o){switch(o){case"en":e.uint.encode(d,1);break;case"it":e.uint.encode(d,2);break;case"ru":e.uint.encode(d,3);break;case"es":e.uint.encode(d,4);break;case"de":e.uint.encode(d,5);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"en";case 2:return"it";case 3:return"ru";case 4:return"es";case 5:return"de";default:return null}}},rt=Fd,tt={preencode(d,o){rt.preencode(d,o.range),ct.preencode(d,o.language),e.string.preencode(d,o.text)},encode(d,o){rt.encode(d,o.range),ct.encode(d,o.language),e.string.encode(d,o.text)},decode:d=>({range:rt.decode(d),language:ct.decode(d),text:e.string.decode(d)})},it={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.count)},encode(d,o){e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.count)},decode:d=>({roomKey:e.fixed32.decode(d),count:e.uint.decode(d)})},at={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.key)},decode:d=>({deviceKey:e.fixed32.decode(d),key:e.fixed32.decode(d)})},st=$,lt={preencode(d,o){st.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){st.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:st.decode(d),key:e.fixed32.decode(d)})},pt=$,ut={preencode(d,o){pt.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){pt.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:pt.decode(d),key:e.fixed32.decode(d)})},ft={Flag:1},mt={preencode(e,d){e.end++},encode(d,o){if(o>1)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},yt={preencode(d,o){uo.preencode(d,o.id),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),mt.preencode(d,o.label)},encode(d,o){uo.encode(d,o.id),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),mt.encode(d,o.label)},decode:d=>({id:uo.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),label:mt.decode(d)})},bt=$,xt={preencode(e,d){bt.preencode(e,d.header),n.preencode(e,d.oplog),mt.preencode(e,d.label)},encode(e,d){bt.encode(e,d.header),n.encode(e,d.oplog),mt.encode(e,d.label)},decode:e=>({header:bt.decode(e),oplog:n.decode(e),label:mt.decode(e)})},vt=$,gt={preencode(e,d){vt.preencode(e,d.header),n.preencode(e,d.oplog),mt.preencode(e,d.label)},encode(e,d){vt.encode(e,d.header),n.encode(e,d.oplog),mt.encode(e,d.label)},decode:e=>({header:vt.decode(e),oplog:n.decode(e),label:mt.decode(e)})},kt={preencode(d,o){mt.preencode(d,o.label),e.uint.preencode(d,o.count)},encode(d,o){mt.encode(d,o.label),e.uint.encode(d,o.count)},decode:d=>({label:mt.decode(d),count:e.uint.decode(d)})},Kt=e.array(e.frame(kt)),ht={preencode(o,n){uo.preencode(o,n.id),e.uint.preencode(o,n.total),Kt.preencode(o,n.labels),e.uint.preencode(o,n.editedAt),o.end++,d>=24&&n.flagsClock&&e.uint.preencode(o,n.flagsClock),d>=24&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(d>=24&&n.flagsClock?1:0)|(d>=24&&n.version?2:0)|(d>=25&&n.isDeleted?4:0);uo.encode(o,n.id),e.uint.encode(o,n.total),Kt.encode(o,n.labels),e.uint.encode(o,n.editedAt),e.uint.encode(o,c),d>=24&&n.flagsClock&&e.uint.encode(o,n.flagsClock),d>=24&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=uo.decode(o),c=e.uint.decode(o),r=Kt.decode(o),t=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{id:n,total:c,labels:r,editedAt:t,flagsClock:d>=24&&1&i?e.uint.decode(o):0,version:d>=24&&2&i?e.uint.decode(o):0,isDeleted:d>=25&&!!(4&i)}}},wt=$,Rt={preencode(d,o){wt.preencode(d,o.header),e.uint.preencode(d,o.length)},encode(d,o){wt.encode(d,o.header),e.uint.encode(d,o.length)},decode:d=>({header:wt.decode(d),length:e.uint.decode(d)})},Pt={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.length)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.length)},decode:d=>({memberKey:e.fixed32.decode(d),length:e.uint.decode(d)})},Tt=Z,At={preencode(o,n){o.end++,d>=33&&n.profileSnoozeTime&&e.uint.preencode(o,n.profileSnoozeTime)},encode(o,n){const c=(d>=19&&n.disableReadReceipts?1:0)|(d>=31&&n.stripAttachmentMetadata?2:0)|(d>=33&&n.profileSnoozeTime?4:0);e.uint.encode(o,c),d>=33&&n.profileSnoozeTime&&e.uint.encode(o,n.profileSnoozeTime)},decode(o){const n=e.uint.decode(o);return{disableReadReceipts:d>=19&&!!(1&n),stripAttachmentMetadata:d>=31&&!!(2&n),profileSnoozeTime:d>=33&&4&n?e.uint.decode(o):0}}},Mt={disableReadReceipts:"disableReadReceipts",stripAttachmentMetadata:"stripAttachmentMetadata",profileSnoozeTime:"profileSnoozeTime"},St={preencode(e,d){e.end++},encode(d,o){switch(o){case"disableReadReceipts":e.uint.encode(d,1);break;case"stripAttachmentMetadata":e.uint.encode(d,2);break;case"profileSnoozeTime":e.uint.encode(d,3);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"disableReadReceipts";case 2:return"stripAttachmentMetadata";case 3:return"profileSnoozeTime";default:return null}}},It=$,Ct=e.frame(At),Vt={preencode(e,d){It.preencode(e,d.header),St.preencode(e,d.key),Ct.preencode(e,d.settings)},encode(e,d){It.encode(e,d.header),St.encode(e,d.key),Ct.encode(e,d.settings)},decode:e=>({header:It.decode(e),key:St.decode(e),settings:Ct.decode(e)})},Ht={preencode(o,n){o.end++,d>=20&&n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=23&&n.coreKey&&e.fixed32.preencode(o,n.coreKey)},encode(o,n){const c=(d>=20&&n.roomKey?1:0)|(d>=23&&n.coreKey?2:0);e.uint.encode(o,c),d>=20&&n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=23&&n.coreKey&&e.fixed32.encode(o,n.coreKey)},decode(o){const n=e.uint.decode(o);return{roomKey:d>=20&&1&n?e.fixed32.decode(o):null,coreKey:d>=23&&2&n?e.fixed32.decode(o):null}}},Ft=e.frame(Ht),Dt={preencode(o,n){e.string.preencode(o,n.code),e.string.preencode(o,n.message),e.string.preencode(o,n.stack),e.uint.preencode(o,n.timestamp),o.end++,d>=20&&n.details&&Ft.preencode(o,n.details)},encode(o,n){const c=d>=20&&n.details?1:0;e.string.encode(o,n.code),e.string.encode(o,n.message),e.string.encode(o,n.stack),e.uint.encode(o,n.timestamp),e.uint.encode(o,c),d>=20&&n.details&&Ft.encode(o,n.details)},decode(o){const n=e.string.decode(o),c=e.string.decode(o),r=e.string.decode(o),t=e.uint.decode(o),i=e.uint.decode(o);return{code:n,message:c,stack:r,timestamp:t,details:d>=20&&1&i?Ft.decode(o):null}}},Lt={RESUME:1,WAKEUP:2,PRESUSPEND:3,SUSPEND:4},jt={preencode(e,d){e.end++},encode(d,o){if(o>4)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},qt={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.total)},encode(d,o){e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.total)},decode:d=>({roomKey:e.fixed32.decode(d),total:e.uint.decode(d)})},Bt={Flag:1},Et={preencode(e,d){e.end++},encode(d,o){if(o>1)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},zt={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),Et.preencode(d,o.label)},encode(d,o){e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),Et.encode(d,o.label)},decode:d=>({key:e.fixed32.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),label:Et.decode(d)})},Ot=$,Nt={preencode(d,o){Ot.preencode(d,o.header),e.fixed32.preencode(d,o.key),Et.preencode(d,o.label)},encode(d,o){Ot.encode(d,o.header),e.fixed32.encode(d,o.key),Et.encode(d,o.label)},decode:d=>({header:Ot.decode(d),key:e.fixed32.decode(d),label:Et.decode(d)})},Ut={preencode(d,o){Et.preencode(d,o.label),e.uint.preencode(d,o.count)},encode(d,o){Et.encode(d,o.label),e.uint.encode(d,o.count)},decode:d=>({label:Et.decode(d),count:e.uint.decode(d)})},Jt=e.array(e.frame(Ut)),Wt={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.total),Jt.preencode(d,o.labels),e.uint.preencode(d,o.editedAt),e.uint.preencode(d,o.flagsClock)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.total),Jt.encode(d,o.labels),e.uint.encode(d,o.editedAt),e.uint.encode(d,o.flagsClock)},decode:d=>({key:e.fixed32.decode(d),total:e.uint.decode(d),labels:Jt.decode(d),editedAt:e.uint.decode(d),flagsClock:e.uint.decode(d)})},Gt={preencode(d,o){e.float64.preencode(d,o.latitude),e.float64.preencode(d,o.longitude)},encode(d,o){e.float64.encode(d,o.latitude),e.float64.encode(d,o.longitude)},decode:d=>({latitude:e.float64.decode(d),longitude:e.float64.decode(d)})},Qt=$,Xt={preencode(d,o){Qt.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.fromDeviceKey)},encode(d,o){Qt.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.fromDeviceKey)},decode:d=>({header:Qt.decode(d),deviceKey:e.fixed32.decode(d),fromDeviceKey:e.fixed32.decode(d)})},Yt=$,Zt=X,$t={preencode(o,n){Yt.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),e.buffer.preencode(o,n.encryptionKey),o.end++,d>=28&&n.streams&&Zt.preencode(o,n.streams),d>=28&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=28&&n.version&&e.uint.preencode(o,n.version),d>=36&&n.streamInputs&&Kl.preencode(o,n.streamInputs),d>=36&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey)},encode(o,n){const c=(d>=28&&n.streams?1:0)|(d>=28&&n.discoveryKey?2:0)|(d>=28&&n.version?4:0)|(d>=36&&n.streamInputs?8:0)|(d>=36&&n.swarmKey?16:0);Yt.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,c),d>=28&&n.streams&&Zt.encode(o,n.streams),d>=28&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=28&&n.version&&e.uint.encode(o,n.version),d>=36&&n.streamInputs&&Kl.encode(o,n.streamInputs),d>=36&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey)},decode(o){const n=Yt.decode(o),c=e.fixed32.decode(o),r=e.buffer.decode(o),t=e.uint.decode(o);return{header:n,callKey:c,encryptionKey:r,streams:d>=28&&1&t?Zt.decode(o):null,discoveryKey:d>=28&&2&t?e.fixed32.decode(o):null,version:d>=28&&4&t?e.uint.decode(o):0,streamInputs:d>=36&&8&t?Kl.decode(o):null,swarmKey:d>=36&&16&t?e.fixed32.decode(o):null}}},_t=$,ei=X,di={preencode(o,n){_t.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),o.end++,d>=28&&n.streams&&ei.preencode(o,n.streams),d>=36&&n.streamInputs&&hl.preencode(o,n.streamInputs),d>=36&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey)},encode(o,n){const c=(d>=28&&n.streams?1:0)|(d>=36&&n.streamInputs?2:0)|(d>=36&&n.swarmKey?4:0);_t.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.uint.encode(o,c),d>=28&&n.streams&&ei.encode(o,n.streams),d>=36&&n.streamInputs&&hl.encode(o,n.streamInputs),d>=36&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey)},decode(o){const n=_t.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{header:n,callKey:c,streams:d>=28&&1&r?ei.decode(o):null,streamInputs:d>=36&&2&r?hl.decode(o):null,swarmKey:d>=36&&4&r?e.fixed32.decode(o):null}}},oi=$,ni={preencode(d,o){oi.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){oi.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:oi.decode(d),callKey:e.fixed32.decode(d)})},ci=$,ri={preencode(d,o){ci.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){ci.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:ci.decode(d),callKey:e.fixed32.decode(d)})},ti=$,ii={preencode(o,n){ti.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.streamKey),o.end++,d>=36&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=36&&n.type&&e.string.preencode(o,n.type)},encode(o,n){const c=(d>=36&&n.mediaStreamId?1:0)|(d>=36&&n.type?2:0)|(d>=36&&n.muted?4:0);ti.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.streamKey),e.uint.encode(o,c),d>=36&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=36&&n.type&&e.string.encode(o,n.type)},decode(o){const n=ti.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=o.start<o.end?e.uint.decode(o):0;return{header:n,callKey:c,streamKey:r,mediaStreamId:d>=36&&1&t?e.string.decode(o):null,type:d>=36&&2&t?e.string.decode(o):null,muted:d>=36&&!!(4&t)}}},ai=$,si={preencode(d,o){ai.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.streamKey)},encode(d,o){ai.encode(d,o.header),e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.streamKey)},decode:d=>({header:ai.decode(d),callKey:e.fixed32.decode(d),streamKey:e.fixed32.decode(d)})},li={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.buffer.preencode(o,n.encryptionKey),e.uint.preencode(o,n.createdAt),o.end++,d>=28&&n.endedAt&&e.uint.preencode(o,n.endedAt),d>=28&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=28&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(d>=28&&n.endedAt?1:0)|(d>=28&&n.discoveryKey?2:0)|(d>=28&&n.version?4:0);e.fixed32.encode(o,n.callKey),e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=28&&n.endedAt&&e.uint.encode(o,n.endedAt),d>=28&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=28&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=e.fixed32.decode(o),c=e.buffer.decode(o),r=e.uint.decode(o),t=e.uint.decode(o);return{callKey:n,encryptionKey:c,createdAt:r,endedAt:d>=28&&1&t?e.uint.decode(o):0,discoveryKey:d>=28&&2&t?e.fixed32.decode(o):null,version:d>=28&&4&t?e.uint.decode(o):0}}},pi={preencode(d,o){e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.createdAt)},encode(d,o){e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.createdAt)},decode:d=>({callKey:e.fixed32.decode(d),memberKey:e.fixed32.decode(d),createdAt:e.uint.decode(d)})},ui={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.deviceKey),e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.createdAt),o.end++,d>=28&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),d>=32&&n.lastHeartbeatAt&&e.uint.preencode(o,n.lastHeartbeatAt)},encode(o,n){const c=(d>=28&&n.swarmKey?1:0)|(d>=32&&n.lastHeartbeatAt?2:0)|(d>=33&&n.isRecording?4:0);e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.deviceKey),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=28&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey),d>=32&&n.lastHeartbeatAt&&e.uint.encode(o,n.lastHeartbeatAt)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o),i=e.uint.decode(o);return{callKey:n,deviceKey:c,memberKey:r,createdAt:t,swarmKey:d>=28&&1&i?e.fixed32.decode(o):null,lastHeartbeatAt:d>=32&&2&i?e.uint.decode(o):0,isRecording:d>=33&&!!(4&i)}}},fi={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.deviceKey),e.buffer.preencode(o,n.streamKey),e.uint.preencode(o,n.createdAt),o.end++,d>=36&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=36&&n.type&&e.string.preencode(o,n.type),d>=36&&n.statusKey&&e.uint.preencode(o,n.statusKey)},encode(o,n){const c=(d>=36&&n.mediaStreamId?1:0)|(d>=36&&n.type?2:0)|(d>=36&&n.statusKey?4:0);e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.deviceKey),e.buffer.encode(o,n.streamKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=36&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=36&&n.type&&e.string.encode(o,n.type),d>=36&&n.statusKey&&e.uint.encode(o,n.statusKey)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.buffer.decode(o),t=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{callKey:n,deviceKey:c,streamKey:r,createdAt:t,mediaStreamId:d>=36&&1&i?e.string.decode(o):null,type:d>=36&&2&i?e.string.decode(o):null,statusKey:d>=36&&4&i?e.uint.decode(o):0}}},mi={preencode(o,n){e.fixed32.preencode(o,n.callKey),o.end++,d>=28&&n.selfDeviceKey&&e.fixed32.preencode(o,n.selfDeviceKey),d>=36&&n.createdAt&&e.uint.preencode(o,n.createdAt)},encode(o,n){const c=(d>=28&&n.selfDeviceKey?1:0)|(d>=36&&n.createdAt?2:0);e.fixed32.encode(o,n.callKey),e.uint.encode(o,c),d>=28&&n.selfDeviceKey&&e.fixed32.encode(o,n.selfDeviceKey),d>=36&&n.createdAt&&e.uint.encode(o,n.createdAt)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o);return{callKey:n,selfDeviceKey:d>=28&&1&c?e.fixed32.decode(o):null,createdAt:d>=36&&2&c?e.uint.decode(o):0}}},yi={preencode(d,o){e.uint.preencode(d,o.lastCleared)},encode(d,o){e.uint.encode(d,o.lastCleared)},decode:d=>({lastCleared:e.uint.decode(d)})},bi={Nightly:"Nightly",Internal:"Internal",Production:"Production"},xi={preencode(e,d){e.end++},encode(d,o){switch(o){case"Nightly":e.uint.encode(d,1);break;case"Internal":e.uint.encode(d,2);break;case"Production":e.uint.encode(d,3);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"Nightly";case 2:return"Internal";case 3:return"Production";default:return null}}},vi=$,gi={preencode(e,d){vi.preencode(e,d.header)},encode(e,d){vi.encode(e,d.header)},decode:e=>({header:vi.decode(e)})},ki=$,Ki={preencode(e,d){ki.preencode(e,d.header)},encode(e,d){ki.encode(e,d.header)},decode:e=>({header:ki.decode(e)})},hi={preencode(o,n){xi.preencode(o,n.buildType),o.end++,d>=30&&n.latestOfflineAbi&&e.uint.preencode(o,n.latestOfflineAbi)},encode(o,n){const c=d>=30&&n.latestOfflineAbi?1:0;xi.encode(o,n.buildType),e.uint.encode(o,c),d>=30&&n.latestOfflineAbi&&e.uint.encode(o,n.latestOfflineAbi)},decode(o){const n=xi.decode(o),c=o.start<o.end?e.uint.decode(o):0;return{buildType:n,latestOfflineAbi:d>=30&&1&c?e.uint.decode(o):0}}},wi=$,Ri={preencode(d,o){wi.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),e.buffer.preencode(d,o.deviceProof),e.buffer.preencode(d,o.writerProof)},encode(d,o){wi.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.buffer.encode(d,o.deviceProof),e.buffer.encode(d,o.writerProof)},decode:d=>({header:wi.decode(d),deviceKey:e.fixed32.decode(d),deviceProof:e.buffer.decode(d),writerProof:e.buffer.decode(d)})},Pi={preencode(o,n){o.end++,d>=31&&n.otaResyncPrivateProfileBump&&e.uint.preencode(o,n.otaResyncPrivateProfileBump)},encode(o,n){const c=d>=31&&n.otaResyncPrivateProfileBump?1:0;e.uint.encode(o,c),d>=31&&n.otaResyncPrivateProfileBump&&e.uint.encode(o,n.otaResyncPrivateProfileBump)},decode(o){const n=e.uint.decode(o);return{otaResyncPrivateProfileBump:d>=31&&1&n?e.uint.decode(o):0}}},Ti={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.buffer.preencode(d,o.proof),e.uint.preencode(d,o.createdAt)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.buffer.encode(d,o.proof),e.uint.encode(d,o.createdAt)},decode:d=>({deviceKey:e.fixed32.decode(d),proof:e.buffer.decode(d),createdAt:e.uint.decode(d)})},Ai=$,Mi={preencode(d,o){Ai.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Ai.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Ai.decode(d),callKey:e.fixed32.decode(d)})},Si=$,Ii={preencode(d,o){Si.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.deviceKey)},encode(d,o){Si.encode(d,o.header),e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.deviceKey)},decode:d=>({header:Si.decode(d),callKey:e.fixed32.decode(d),deviceKey:e.fixed32.decode(d)})},Ci=e.frame(ht),Vi=e.array(e.frame(yt)),Hi={preencode(e,d){Ci.preencode(e,d.digest),Vi.preencode(e,d.mine)},encode(e,d){Ci.encode(e,d.digest),Vi.encode(e,d.mine)},decode:e=>({digest:Ci.decode(e),mine:Vi.decode(e)})},Fi=$,Di={preencode(d,o){Fi.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Fi.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Fi.decode(d),callKey:e.fixed32.decode(d)})},Li=$,ji={preencode(d,o){Li.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Li.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Li.decode(d),callKey:e.fixed32.decode(d)})},qi={preencode(o,n){o.end++,d>=33&&n.profileSnoozeTime&&e.uint.preencode(o,n.profileSnoozeTime)},encode(o,n){const c=(d>=33&&n.disableReadReceipts?1:0)|(d>=33&&n.stripAttachmentMetadata?2:0)|(d>=33&&n.profileSnoozeTime?4:0);e.uint.encode(o,c),d>=33&&n.profileSnoozeTime&&e.uint.encode(o,n.profileSnoozeTime)},decode(o){const n=e.uint.decode(o);return{disableReadReceipts:d>=33&&!!(1&n),stripAttachmentMetadata:d>=33&&!!(2&n),profileSnoozeTime:d>=33&&4&n?e.uint.decode(o):0}}},Bi={preencode(o,n){o.end++,d>=33&&n.maxPeers&&e.uint.preencode(o,n.maxPeers)},encode(o,n){const c=d>=33&&n.maxPeers?1:0;e.uint.encode(o,c),d>=33&&n.maxPeers&&e.uint.encode(o,n.maxPeers)},decode(o){const n=e.uint.decode(o);return{maxPeers:d>=33&&1&n?e.uint.decode(o):0}}},Ei=$,zi={preencode(e,d){Ei.preencode(e,d.header),n.preencode(e,d.oplog)},encode(e,d){Ei.encode(e,d.header),n.encode(e,d.oplog)},decode:e=>({header:Ei.decode(e),oplog:n.decode(e)})},Oi=$,Ni={preencode(e,d){Oi.preencode(e,d.header)},encode(e,d){Oi.encode(e,d.header)},decode:e=>({header:Oi.decode(e)})},Ui={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.timestamp)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.timestamp)},decode:d=>({memberKey:e.fixed32.decode(d),timestamp:e.uint.decode(d)})},Ji=$,Wi={preencode(o,n){Ji.preencode(o,n.header),e.fixed32.preencode(o,n.memberKey),o.end++,d>=34&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=d>=34&&n.alias?1:0;Ji.encode(o,n.header),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,c),d>=34&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=Ji.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{header:n,memberKey:c,alias:d>=34&&1&r?e.string.decode(o):null}}},Gi={preencode(d,o){e.uint.preencode(d,o.streams)},encode(d,o){e.uint.encode(d,o.streams)},decode:d=>({streams:e.uint.decode(d)})},Qi={preencode(d,o){e.fixed32.preencode(d,o.streamKey),e.string.preencode(d,o.mediaStreamId),e.string.preencode(d,o.type),d.end++},encode(o,n){const c=d>=36&&n.muted?1:0;e.fixed32.encode(o,n.streamKey),e.string.encode(o,n.mediaStreamId),e.string.encode(o,n.type),e.uint.encode(o,c)},decode(o){const n=e.fixed32.decode(o),c=e.string.decode(o),r=e.string.decode(o),t=e.uint.decode(o);return{streamKey:n,mediaStreamId:c,type:r,muted:d>=36&&!!(1&t)}}},Xi=$,Yi={preencode(d,o){Xi.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.streamKey),d.end++},encode(o,n){const c=d>=36&&n.muted?1:0;Xi.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.streamKey),e.uint.encode(o,c)},decode(o){const n=Xi.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o);return{header:n,callKey:c,streamKey:r,muted:d>=36&&!!(1&t)}}},Zi={preencode(d,o){e.uint.preencode(d,o.statusKey),d.end++},encode(o,n){const c=d>=36&&n.muted?1:0;e.uint.encode(o,n.statusKey),e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o),c=e.uint.decode(o);return{statusKey:n,muted:d>=36&&!!(1&c)}}},$i={preencode(n,c){e.fixed32.preencode(n,c.key),n.end++,d>=37&&c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),d>=37&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=(d>=37&&c.encryptionKey?1:0)|(d>=37&&c.bootFrom?2:0);e.fixed32.encode(n,c.key),e.uint.encode(n,r),d>=37&&c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),d>=37&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.uint.decode(n);return{key:c,encryptionKey:d>=37&&1&r?e.buffer.decode(n):null,bootFrom:d>=37&&2&r?o.decode(n):null}}},_i={preencode(d,o){e.fixed32.preencode(d,o.hash)},encode(d,o){e.fixed32.encode(d,o.hash)},decode:d=>({hash:e.fixed32.decode(d)})},ea={preencode(d,o){e.fixed32.preencode(d,o.hash),e.buffer.preencode(d,o.data)},encode(d,o){e.fixed32.encode(d,o.hash),e.buffer.encode(d,o.data)},decode:d=>({hash:e.fixed32.decode(d),data:e.buffer.decode(d)})},da={preencode(n,c){o.preencode(n,c.autobeeMigrationHead),n.end++,d>=37&&c.legacyViewHead&&o.preencode(n,c.legacyViewHead),d>=37&&c.dbViewHead&&o.preencode(n,c.dbViewHead),d>=37&&c.blobsViewHead&&o.preencode(n,c.blobsViewHead),e.uint.preencode(n,c.createdAt)},encode(n,c){const r=(d>=37&&c.legacyViewHead?1:0)|(d>=37&&c.dbViewHead?2:0)|(d>=37&&c.blobsViewHead?4:0);o.encode(n,c.autobeeMigrationHead),e.uint.encode(n,r),d>=37&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=37&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=37&&c.blobsViewHead&&o.encode(n,c.blobsViewHead),e.uint.encode(n,c.createdAt)},decode(n){const c=o.decode(n),r=e.uint.decode(n);return{autobeeMigrationHead:c,legacyViewHead:d>=37&&1&r?o.decode(n):null,dbViewHead:d>=37&&2&r?o.decode(n):null,blobsViewHead:d>=37&&4&r?o.decode(n):null,createdAt:e.uint.decode(n)}}},oa=$,na={preencode(e,n){oa.preencode(e,n.header),o.preencode(e,n.head),e.end++,d>=37&&n.legacyViewHead&&o.preencode(e,n.legacyViewHead),d>=37&&n.dbViewHead&&o.preencode(e,n.dbViewHead),d>=37&&n.blobsViewHead&&o.preencode(e,n.blobsViewHead)},encode(n,c){const r=(d>=37&&c.legacyViewHead?1:0)|(d>=37&&c.dbViewHead?2:0)|(d>=37&&c.blobsViewHead?4:0);oa.encode(n,c.header),o.encode(n,c.head),e.uint.encode(n,r),d>=37&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=37&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=37&&c.blobsViewHead&&o.encode(n,c.blobsViewHead)},decode(n){const c=oa.decode(n),r=o.decode(n),t=e.uint.decode(n);return{header:c,head:r,legacyViewHead:d>=37&&1&t?o.decode(n):null,dbViewHead:d>=37&&2&t?o.decode(n):null,blobsViewHead:d>=37&&4&t?o.decode(n):null}}},ca={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.fixed32.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.seed),n.end++,d>=37&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=d>=37&&c.bootFrom?1:0;e.fixed32.encode(n,c.roomKey),e.fixed32.encode(n,c.encryptionKey),e.fixed32.encode(n,c.seed),e.uint.encode(n,r),d>=37&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.fixed32.decode(n),t=e.fixed32.decode(n),i=e.uint.decode(n);return{roomKey:c,encryptionKey:r,seed:t,bootFrom:d>=37&&1&i?o.decode(n):null}}},ra=id,ta={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.fixed32.preencode(d,o.deviceKey),e.uint.preencode(d,o.deviceLength),e.uint.preencode(d,o.clock),ra.preencode(d,o.status)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,o.deviceLength),e.uint.encode(d,o.clock),ra.encode(d,o.status)},decode:d=>({memberKey:e.fixed32.decode(d),deviceKey:e.fixed32.decode(d),deviceLength:e.uint.decode(d),clock:e.uint.decode(d),status:ra.decode(d)})},ia={preencode(d,o){e.fixed32.preencode(d,o.hash),e.buffer.preencode(d,o.blob)},encode(d,o){e.fixed32.encode(d,o.hash),e.buffer.encode(d,o.blob)},decode:d=>({hash:e.fixed32.decode(d),blob:e.buffer.decode(d)})},aa=In,sa=Cn,la=gn,pa={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),aa.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,d>=37&&c.initiator&&o.preencode(n,c.initiator),d>=37&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=37&&c.identitySwap&&sa.preencode(n,c.identitySwap),d>=37&&c.identitySwapV2&&la.preencode(n,c.identitySwapV2),d>=37&&c.contact&&e.fixed32.preencode(n,c.contact)},encode(n,c){const r=(d>=37&&c.initiator?1:0)|(d>=37&&c.bootFrom?2:0)|(d>=37&&c.identitySwap?4:0)|(d>=37&&c.identitySwapV2?8:0)|(d>=37&&c.contact?16:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),aa.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,r),d>=37&&c.initiator&&o.encode(n,c.initiator),d>=37&&c.bootFrom&&o.encode(n,c.bootFrom),d>=37&&c.identitySwap&&sa.encode(n,c.identitySwap),d>=37&&c.identitySwapV2&&la.encode(n,c.identitySwapV2),d>=37&&c.contact&&e.fixed32.encode(n,c.contact)},decode(n){const c=e.fixed32.decode(n),r=e.buffer.decode(n),t=e.fixed32.decode(n),i=aa.decode(n),a=e.uint.decode(n),s=e.uint.decode(n);return{roomKey:c,encryptionKey:r,mailbox:t,status:i,clock:a,initiator:d>=37&&1&s?o.decode(n):null,bootFrom:d>=37&&2&s?o.decode(n):null,identitySwap:d>=37&&4&s?sa.decode(n):null,identitySwapV2:d>=37&&8&s?la.decode(n):null,contact:d>=37&&16&s?e.fixed32.decode(n):null}}},ua=$,fa={preencode(n,c){ua.preencode(n,c.header),e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),n.end++,d>=37&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=37&&c.initiator&&o.preencode(n,c.initiator),d>=37&&c.dm&&e.fixed32.preencode(n,c.dm)},encode(n,c){const r=(d>=37&&c.bootFrom?1:0)|(d>=37&&c.initiator?2:0)|(d>=37&&c.dm?4:0)|(d>=37&&c.isReadOnly?8:0);ua.encode(n,c.header),e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),e.uint.encode(n,r),d>=37&&c.bootFrom&&o.encode(n,c.bootFrom),d>=37&&c.initiator&&o.encode(n,c.initiator),d>=37&&c.dm&&e.fixed32.encode(n,c.dm)},decode(n){const c=ua.decode(n),r=e.fixed32.decode(n),t=e.buffer.decode(n),i=e.fixed32.decode(n),a=e.uint.decode(n);return{header:c,roomKey:r,encryptionKey:t,mailbox:i,bootFrom:d>=37&&1&a?o.decode(n):null,initiator:d>=37&&2&a?o.decode(n):null,dm:d>=37&&4&a?e.fixed32.decode(n):null,isReadOnly:d>=37&&!!(8&a)}}},ma={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),n.end++,d>=37&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=37&&c.initiator&&o.preencode(n,c.initiator)},encode(n,c){const r=(d>=37&&c.bootFrom?1:0)|(d>=37&&c.initiator?2:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.uint.encode(n,r),d>=37&&c.bootFrom&&o.encode(n,c.bootFrom),d>=37&&c.initiator&&o.encode(n,c.initiator)},decode(n){const c=e.fixed32.decode(n),r=e.buffer.decode(n),t=e.uint.decode(n);return{roomKey:c,encryptionKey:r,bootFrom:d>=37&&1&t?o.decode(n):null,initiator:d>=37&&2&t?o.decode(n):null}}},ya={preencode(d,o){e.fixed32.preencode(d,o.roomKey),wl.preencode(d,o.head),e.uint.preencode(d,o.timestamp),d.end++},encode(o,n){const c=d>=37&&n.incremental?1:0;e.fixed32.encode(o,n.roomKey),wl.encode(o,n.head),e.uint.encode(o,n.timestamp),e.uint.encode(o,c)},decode(o){const n=e.fixed32.decode(o),c=wl.decode(o),r=e.uint.decode(o),t=e.uint.decode(o);return{roomKey:n,head:c,timestamp:r,incremental:d>=37&&!!(1&t)}}},ba={preencode(o,n){o.end++,d>=37&&n.key&&e.fixed32.preencode(o,n.key),e.uint.preencode(o,n.length)},encode(o,n){const c=d>=37&&n.key?1:0;e.uint.encode(o,c),d>=37&&n.key&&e.fixed32.encode(o,n.key),e.uint.encode(o,n.length)},decode(o){const n=e.uint.decode(o);return{key:d>=37&&1&n?e.fixed32.decode(o):null,length:e.uint.decode(o)}}},xa={preencode(n,c){e.fixed32.preencode(n,c.roomKey),n.end++,d>=37&&c.legacyViewHead&&o.preencode(n,c.legacyViewHead),d>=37&&c.dbViewHead&&o.preencode(n,c.dbViewHead),d>=37&&c.blobsViewHead&&o.preencode(n,c.blobsViewHead),d>=37&&c.autobeeMigrationHead&&o.preencode(n,c.autobeeMigrationHead)},encode(n,c){const r=(d>=37&&c.legacyViewHead?1:0)|(d>=37&&c.dbViewHead?2:0)|(d>=37&&c.blobsViewHead?4:0)|(d>=37&&c.autobeeMigrationHead?8:0);e.fixed32.encode(n,c.roomKey),e.uint.encode(n,r),d>=37&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=37&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=37&&c.blobsViewHead&&o.encode(n,c.blobsViewHead),d>=37&&c.autobeeMigrationHead&&o.encode(n,c.autobeeMigrationHead)},decode(n){const c=e.fixed32.decode(n),r=e.uint.decode(n);return{roomKey:c,legacyViewHead:d>=37&&1&r?o.decode(n):null,dbViewHead:d>=37&&2&r?o.decode(n):null,blobsViewHead:d>=37&&4&r?o.decode(n):null,autobeeMigrationHead:d>=37&&8&r?o.decode(n):null}}},va={preencode(d,o){e.fixed32.preencode(d,o.id),e.fixed32.preencode(d,o.writerKey),e.buffer.preencode(d,o.blindResponse)},encode(d,o){e.fixed32.encode(d,o.id),e.fixed32.encode(d,o.writerKey),e.buffer.encode(d,o.blindResponse)},decode:d=>({id:e.fixed32.decode(d),writerKey:e.fixed32.decode(d),blindResponse:e.buffer.decode(d)})},ga=$,ka={preencode(d,o){ga.preencode(d,o.header),e.buffer.preencode(d,o.blindResponse)},encode(d,o){ga.encode(d,o.header),e.buffer.encode(d,o.blindResponse)},decode:d=>({header:ga.decode(d),blindResponse:e.buffer.decode(d)})},Ka=e.frame(Ac),ha={preencode(o,n){e.string.preencode(o,n.mnemonic),o.end++,d>=39&&n.profileDiscoveryTimeout&&e.uint.preencode(o,n.profileDiscoveryTimeout),d>=39&&n.privateProfileKey&&e.fixed32.preencode(o,n.privateProfileKey),d>=39&&n.identity&&Ka.preencode(o,n.identity)},encode(o,n){const c=(d>=39&&n.profileDiscoveryTimeout?1:0)|(d>=39&&n.privateProfileKey?2:0)|(d>=39&&n.identity?4:0);e.string.encode(o,n.mnemonic),e.uint.encode(o,c),d>=39&&n.profileDiscoveryTimeout&&e.uint.encode(o,n.profileDiscoveryTimeout),d>=39&&n.privateProfileKey&&e.fixed32.encode(o,n.privateProfileKey),d>=39&&n.identity&&Ka.encode(o,n.identity)},decode(o){const n=e.string.decode(o),c=e.uint.decode(o);return{mnemonic:n,profileDiscoveryTimeout:d>=39&&1&c?e.uint.decode(o):0,privateProfileKey:d>=39&&2&c?e.fixed32.decode(o):null,identity:d>=39&&4&c?Ka.decode(o):null}}},wa=$,Ra={preencode(e,d){wa.preencode(e,d.header)},encode(e,d){wa.encode(e,d.header)},decode:e=>({header:wa.decode(e)})},Pa=$,Ta={preencode(o,c){Pa.preencode(o,c.header),n.preencode(o,c.oplog),e.uint.preencode(o,c.index),o.end++,d>=40&&c.displayType&&Gr.preencode(o,c.displayType)},encode(o,c){const r=d>=40&&c.displayType?1:0;Pa.encode(o,c.header),n.encode(o,c.oplog),e.uint.encode(o,c.index),e.uint.encode(o,r),d>=40&&c.displayType&&Gr.encode(o,c.displayType)},decode(o){const c=Pa.decode(o),r=n.decode(o),t=e.uint.decode(o),i=e.uint.decode(o);return{header:c,oplog:r,index:t,displayType:d>=40&&1&i?Gr.decode(o):0}}},Aa=$,Ma=Od,Sa={preencode(d,o){Aa.preencode(d,o.header),n.preencode(d,o.oplog),Gr.preencode(d,o.displayType),e.uint.preencode(d,o.index),Ma.preencode(d,o.preview)},encode(d,o){Aa.encode(d,o.header),n.encode(d,o.oplog),Gr.encode(d,o.displayType),e.uint.encode(d,o.index),Ma.encode(d,o.preview)},decode:d=>({header:Aa.decode(d),oplog:n.decode(d),displayType:Gr.decode(d),index:e.uint.decode(d),preview:Ma.decode(d)})},Ia=$,Ca={preencode(d,o){Ia.preencode(d,o.header),n.preencode(d,o.oplog),Gr.preencode(d,o.displayType),e.uint.preencode(d,o.index)},encode(d,o){Ia.encode(d,o.header),n.encode(d,o.oplog),Gr.encode(d,o.displayType),e.uint.encode(d,o.index)},decode:d=>({header:Ia.decode(d),oplog:n.decode(d),displayType:Gr.decode(d),index:e.uint.decode(d)})},Va=hc,Ha={preencode(o,n){e.uint.preencode(o,n.priority),o.end++,n.v3&&Va.preencode(o,n.v3),d>=5&&n.timestamp&&e.uint.preencode(o,n.timestamp)},encode(o,n){const c=(n.v3?1:0)|(d>=3&&n.errored?2:0)|(d>=5&&n.timestamp?4:0);e.uint.encode(o,n.priority),e.uint.encode(o,c),n.v3&&Va.encode(o,n.v3),d>=5&&n.timestamp&&e.uint.encode(o,n.timestamp)},decode(o){const n=e.uint.decode(o),c=e.uint.decode(o);return{roomKey:null,priority:n,v3:1&c?Va.decode(o):null,errored:d>=3&&!!(2&c),timestamp:d>=5&&4&c?e.uint.decode(o):0}}},Fa=Xo,Da=fo,La=ir,ja=vc,qa=sr,Ba=lr,Ea=pr,za=Oo,Oa=$o,Na=mr,Ua=X,Ja=br,Wa=In,Ga={preencode(o,n){const c=(n.selfDevice?1:0)|(n.selfMember?2:0)|(n.config?4:0)|(n.identity?8:0)|(n.lastMessage?16:0)|(n.dm?32:0)|(d>=19&&n.readLengths?64:0)|(d>=19&&n.lastMember?128:0)|(d>=21&&n.version?256:0)|(d>=27&&n.preferences?512:0)|(d>=28&&n.activeCall?1024:0)|(d>=32&&n.lastMessageLabels?2048:0)|(d>=33&&n.settings?4096:0)|(d>=37&&n.system?8192:0)|(d>=37&&n.processed?16384:0);e.fixed32.preencode(o,n.discoveryKey),e.buffer.preencode(o,n.encryptionKey),Fa.preencode(o,n.digest),Da.preencode(o,n.stats),La.preencode(o,n.timestamps),e.uint.preencode(o,n.fork),e.uint.preencode(o,n.length),e.fixed32.preencode(o,n.seed),ja.preencode(o,n.capabilities),qa.preencode(o,n.status),e.uint.preencode(o,c),n.selfDevice&&Ba.preencode(o,n.selfDevice),n.selfMember&&Ea.preencode(o,n.selfMember),n.config&&za.preencode(o,n.config),n.identity&&Oa.preencode(o,n.identity),n.lastMessage&&Na.preencode(o,n.lastMessage),n.dm&&Ua.preencode(o,n.dm),d>=19&&n.readLengths&&Rl.preencode(o,n.readLengths),d>=19&&n.lastMember&&Ja.preencode(o,n.lastMember),d>=21&&n.version&&e.uint.preencode(o,n.version),d>=27&&n.preferences&&Wa.preencode(o,n.preferences),d>=28&&n.activeCall&&Pl.preencode(o,n.activeCall),d>=32&&n.lastMessageLabels&&Tl.preencode(o,n.lastMessageLabels),d>=33&&n.settings&&Al.preencode(o,n.settings),d>=37&&n.system&&Ml.preencode(o,n.system),d>=37&&n.processed&&Sl.preencode(o,n.processed)},encode(o,n){const c=(n.selfDevice?1:0)|(n.selfMember?2:0)|(n.config?4:0)|(n.identity?8:0)|(n.lastMessage?16:0)|(n.dm?32:0)|(d>=19&&n.readLengths?64:0)|(d>=19&&n.lastMember?128:0)|(d>=21&&n.version?256:0)|(d>=27&&n.preferences?512:0)|(d>=28&&n.activeCall?1024:0)|(d>=32&&n.lastMessageLabels?2048:0)|(d>=33&&n.settings?4096:0)|(d>=37&&n.system?8192:0)|(d>=37&&n.processed?16384:0);e.fixed32.encode(o,n.discoveryKey),e.buffer.encode(o,n.encryptionKey),Fa.encode(o,n.digest),Da.encode(o,n.stats),La.encode(o,n.timestamps),e.uint.encode(o,n.fork),e.uint.encode(o,n.length),e.fixed32.encode(o,n.seed),ja.encode(o,n.capabilities),qa.encode(o,n.status),e.uint.encode(o,c),n.selfDevice&&Ba.encode(o,n.selfDevice),n.selfMember&&Ea.encode(o,n.selfMember),n.config&&za.encode(o,n.config),n.identity&&Oa.encode(o,n.identity),n.lastMessage&&Na.encode(o,n.lastMessage),n.dm&&Ua.encode(o,n.dm),d>=19&&n.readLengths&&Rl.encode(o,n.readLengths),d>=19&&n.lastMember&&Ja.encode(o,n.lastMember),d>=21&&n.version&&e.uint.encode(o,n.version),d>=27&&n.preferences&&Wa.encode(o,n.preferences),d>=28&&n.activeCall&&Pl.encode(o,n.activeCall),d>=32&&n.lastMessageLabels&&Tl.encode(o,n.lastMessageLabels),d>=33&&n.settings&&Al.encode(o,n.settings),d>=37&&n.system&&Ml.encode(o,n.system),d>=37&&n.processed&&Sl.encode(o,n.processed)},decode(o){const n=e.fixed32.decode(o),c=e.buffer.decode(o),r=Fa.decode(o),t=Da.decode(o),i=La.decode(o),a=e.uint.decode(o),s=e.uint.decode(o),l=e.fixed32.decode(o),p=ja.decode(o),u=qa.decode(o),f=e.uint.decode(o);return{roomKey:null,discoveryKey:n,encryptionKey:c,digest:r,stats:t,timestamps:i,fork:a,length:s,seed:l,capabilities:p,status:u,selfDevice:1&f?Ba.decode(o):null,selfMember:2&f?Ea.decode(o):null,config:4&f?za.decode(o):null,identity:8&f?Oa.decode(o):null,lastMessage:16&f?Na.decode(o):null,dm:32&f?Ua.decode(o):null,readLengths:d>=19&&64&f?Rl.decode(o):null,lastMember:d>=19&&128&f?Ja.decode(o):null,version:d>=21&&256&f?e.uint.decode(o):0,preferences:d>=27&&512&f?Wa.decode(o):null,activeCall:d>=28&&1024&f?Pl.decode(o):null,lastMessageLabels:d>=32&&2048&f?Tl.decode(o):null,settings:d>=33&&4096&f?Al.decode(o):null,system:d>=37&&8192&f?Ml.decode(o):null,processed:d>=37&&16384&f?Sl.decode(o):null}}},Qa=In,Xa={preencode(e,d){Qa.preencode(e,d.status)},encode(e,d){Qa.encode(e,d.status)},decode:e=>({roomKey:null,status:Qa.decode(e)})},Ya={preencode(o,n){e.fixed32.preencode(o,n.key),o.end++,n.roomKey&&e.fixed32.preencode(o,n.roomKey),n.keyPair&&r.preencode(o,n.keyPair),n.responseKeyPair&&r.preencode(o,n.responseKeyPair),d>=39&&n.activeClock&&e.uint.preencode(o,n.activeClock)},encode(o,n){const c=(n.roomKey?1:0)|(n.keyPair?2:0)|(n.responseKeyPair?4:0)|(d>=38&&n.pending?8:0)|(d>=39&&n.activeClock?16:0);e.fixed32.encode(o,n.key),e.uint.encode(o,c),n.roomKey&&e.fixed32.encode(o,n.roomKey),n.keyPair&&r.encode(o,n.keyPair),n.responseKeyPair&&r.encode(o,n.responseKeyPair),d>=39&&n.activeClock&&e.uint.encode(o,n.activeClock)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o);return{mailbox:null,key:n,roomKey:1&c?e.fixed32.decode(o):null,keyPair:2&c?r.decode(o):null,responseKeyPair:4&c?r.decode(o):null,pending:d>=38&&!!(8&c),activeClock:d>=39&&16&c?e.uint.decode(o):0}}},Za=le,$a={preencode(e,d){Za.preencode(e,d.profile)},encode(e,d){Za.encode(e,d.profile)},decode:e=>({key:null,profile:Za.decode(e)})},_a=re,es=te,ds={preencode(d,o){e.fixed32.preencode(d,o.memberKey),_a.preencode(d,o.status),Il.preencode(d,o.profile),d.end++,o.invitation&&es.preencode(d,o.invitation)},encode(d,o){const n=o.invitation?1:0;e.fixed32.encode(d,o.memberKey),_a.encode(d,o.status),Il.encode(d,o.profile),e.uint.encode(d,n),o.invitation&&es.encode(d,o.invitation)},decode:d=>({key:null,memberKey:e.fixed32.decode(d),status:_a.decode(d),profile:Il.decode(d),invitation:1&e.uint.decode(d)?es.decode(d):null})},os=lr,ns={preencode(d,o){e.fixed32.preencode(d,o.roomKey),os.preencode(d,o.device)},encode(d,o){e.fixed32.encode(d,o.roomKey),os.encode(d,o.device)},decode:d=>({roomKey:e.fixed32.decode(d),device:os.decode(d)})},cs={preencode(o,n){Cl.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=32&&n.contactInfo&&Vl.preencode(o,n.contactInfo),d>=32&&n.version&&e.uint.preencode(o,n.version),d>=34&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=32&&n.contactInfo?4:0)|(d>=32&&n.version?8:0)|(d>=34&&n.alias?16:0);Cl.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=32&&n.contactInfo&&Vl.encode(o,n.contactInfo),d>=32&&n.version&&e.uint.encode(o,n.version),d>=34&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=Cl.decode(o),c=e.uint.decode(o);return{memberKey:null,status:n,mailbox:1&c?e.fixed32.decode(o):null,roomKey:2&c?e.fixed32.decode(o):null,contactInfo:d>=32&&4&c?Vl.decode(o):null,version:d>=32&&8&c?e.uint.decode(o):0,alias:d>=34&&16&c?e.string.decode(o):null}}},rs=Jc,ts=Wc,is=Gc,as=Qc,ss=Xc,ls=Yc,ps=Zc,us=$c,fs=_c,ms={preencode(d,o){const n=(o.restoreIdentity?1:0)|(o.createRoom?2:0)|(o.leaveRoom?4:0)|(o.clearRoom?8:0)|(o.joinRoomInvitation?16:0)|(o.joinRoomKeys?32:0)|(o.joinRoomResponse?64:0)|(o.sendContactRequest?128:0)|(o.migrateV2Room?256:0);e.uint.preencode(d,n),o.restoreIdentity&&rs.preencode(d,o.restoreIdentity),o.createRoom&&ts.preencode(d,o.createRoom),o.leaveRoom&&is.preencode(d,o.leaveRoom),o.clearRoom&&as.preencode(d,o.clearRoom),o.joinRoomInvitation&&ss.preencode(d,o.joinRoomInvitation),o.joinRoomKeys&&ls.preencode(d,o.joinRoomKeys),o.joinRoomResponse&&ps.preencode(d,o.joinRoomResponse),o.sendContactRequest&&us.preencode(d,o.sendContactRequest),o.migrateV2Room&&fs.preencode(d,o.migrateV2Room)},encode(d,o){const n=(o.restoreIdentity?1:0)|(o.createRoom?2:0)|(o.leaveRoom?4:0)|(o.clearRoom?8:0)|(o.joinRoomInvitation?16:0)|(o.joinRoomKeys?32:0)|(o.joinRoomResponse?64:0)|(o.sendContactRequest?128:0)|(o.migrateV2Room?256:0);e.uint.encode(d,n),o.restoreIdentity&&rs.encode(d,o.restoreIdentity),o.createRoom&&ts.encode(d,o.createRoom),o.leaveRoom&&is.encode(d,o.leaveRoom),o.clearRoom&&as.encode(d,o.clearRoom),o.joinRoomInvitation&&ss.encode(d,o.joinRoomInvitation),o.joinRoomKeys&&ls.encode(d,o.joinRoomKeys),o.joinRoomResponse&&ps.encode(d,o.joinRoomResponse),o.sendContactRequest&&us.encode(d,o.sendContactRequest),o.migrateV2Room&&fs.encode(d,o.migrateV2Room)},decode(d){const o=e.uint.decode(d);return{discoveryKey:null,priority:0,timestamp:0,type:0,restoreIdentity:1&o?rs.decode(d):null,createRoom:2&o?ts.decode(d):null,leaveRoom:4&o?is.decode(d):null,clearRoom:8&o?as.decode(d):null,joinRoomInvitation:16&o?ss.decode(d):null,joinRoomKeys:32&o?ls.decode(d):null,joinRoomResponse:64&o?ps.decode(d):null,sendContactRequest:128&o?us.decode(d):null,migrateV2Room:256&o?fs.decode(d):null}}},ys={preencode(d,o){e.uint.preencode(d,o.blockLength),e.uint.preencode(d,o.byteOffset),e.uint.preencode(d,o.byteLength)},encode(d,o){e.uint.encode(d,o.blockLength),e.uint.encode(d,o.byteOffset),e.uint.encode(d,o.byteLength)},decode:d=>({blockOffset:0,blockLength:e.uint.decode(d),byteOffset:e.uint.decode(d),byteLength:e.uint.decode(d)})},bs={preencode(e,d){a.preencode(e,d.blob)},encode(e,d){a.encode(e,d.blob)},decode:e=>({key:null,blob:a.decode(e)})},xs=m,vs=y,gs={preencode(o,n){o.end++,n.inlined&&e.buffer.preencode(o,n.inlined),n.blob&&a.preencode(o,n.blob),n.externalBlob&&xs.preencode(o,n.externalBlob),n.externalDrive&&vs.preencode(o,n.externalDrive),d>=37&&n.bee&&_i.preencode(o,n.bee)},encode(o,n){const c=(n.inlined?1:0)|(n.blob?2:0)|(n.externalBlob?4:0)|(n.externalDrive?8:0)|(d>=37&&n.bee?16:0);e.uint.encode(o,c),n.inlined&&e.buffer.encode(o,n.inlined),n.blob&&a.encode(o,n.blob),n.externalBlob&&xs.encode(o,n.externalBlob),n.externalDrive&&vs.encode(o,n.externalDrive),d>=37&&n.bee&&_i.encode(o,n.bee)},decode(o){const n=e.uint.decode(o);return{inlined:1&n?e.buffer.decode(o):null,blob:2&n?a.decode(o):null,externalBlob:4&n?xs.decode(o):null,externalDrive:8&n?vs.decode(o):null,bee:d>=37&&16&n?_i.decode(o):null}}},ks=x,Ks=v,hs={preencode(d,o){ks.preencode(d,o.pointer),d.end++,o.metadata&&Ks.preencode(d,o.metadata),o.preview&&Hl.preencode(d,o.preview),o.hash&&e.fixed32.preencode(d,o.hash)},encode(d,o){const n=(o.metadata?1:0)|(o.preview?2:0)|(o.hash?4:0);ks.encode(d,o.pointer),e.uint.encode(d,n),o.metadata&&Ks.encode(d,o.metadata),o.preview&&Hl.encode(d,o.preview),o.hash&&e.fixed32.encode(d,o.hash)},decode(d){const o=ks.decode(d),n=e.uint.decode(d);return{pointer:o,metadata:1&n?Ks.decode(d):null,preview:2&n?Hl.decode(d):null,hash:4&n?e.fixed32.decode(d):null}}},ws=k,Rs={preencode(o,n){ws.preencode(o,n.file),e.fixed32.preencode(o,n.roomKey),o.end++,n.encryptionKey&&e.buffer.preencode(o,n.encryptionKey),d>=28&&n.lastAccessed&&e.uint.preencode(o,n.lastAccessed),d>=28&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(n.encryptionKey?1:0)|(n.cleared?2:0)|(n.own?4:0)|(d>=28&&n.lastAccessed?8:0)|(d>=28&&n.version?16:0);ws.encode(o,n.file),e.fixed32.encode(o,n.roomKey),e.uint.encode(o,c),n.encryptionKey&&e.buffer.encode(o,n.encryptionKey),d>=28&&n.lastAccessed&&e.uint.encode(o,n.lastAccessed),d>=28&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=ws.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{file:n,roomKey:c,encryptionKey:1&r?e.buffer.decode(o):null,cleared:!!(2&r),own:!!(4&r),lastAccessed:d>=28&&8&r?e.uint.decode(o):0,version:d>=28&&16&r?e.uint.decode(o):0}}},Ps={preencode(d,o){e.uint.preencode(d,o.size)},encode(d,o){e.uint.encode(d,o.size)},decode:d=>({key:null,path:null,version:0,size:e.uint.decode(d)})},Ts=m,As=y,Ms={preencode(o,n){o.end++,n.inlined&&e.buffer.preencode(o,n.inlined),n.blob&&a.preencode(o,n.blob),n.externalBlob&&Ts.preencode(o,n.externalBlob),n.externalDrive&&As.preencode(o,n.externalDrive),d>=37&&n.bee&&_i.preencode(o,n.bee)},encode(o,n){const c=(n.inlined?1:0)|(n.blob?2:0)|(n.externalBlob?4:0)|(n.externalDrive?8:0)|(d>=37&&n.bee?16:0);e.uint.encode(o,c),n.inlined&&e.buffer.encode(o,n.inlined),n.blob&&a.encode(o,n.blob),n.externalBlob&&Ts.encode(o,n.externalBlob),n.externalDrive&&As.encode(o,n.externalDrive),d>=37&&n.bee&&_i.encode(o,n.bee)},decode(o){const n=e.uint.decode(o);return{inlined:1&n?e.buffer.decode(o):null,blob:2&n?a.decode(o):null,externalBlob:4&n?Ts.decode(o):null,externalDrive:8&n?As.decode(o):null,bee:d>=37&&16&n?_i.decode(o):null}}},Ss=x,Is=v,Cs={preencode(d,o){Ss.preencode(d,o.pointer),d.end++,o.metadata&&Is.preencode(d,o.metadata),o.preview&&Fl.preencode(d,o.preview),o.hash&&e.fixed32.preencode(d,o.hash)},encode(d,o){const n=(o.metadata?1:0)|(o.preview?2:0)|(o.hash?4:0);Ss.encode(d,o.pointer),e.uint.encode(d,n),o.metadata&&Is.encode(d,o.metadata),o.preview&&Fl.encode(d,o.preview),o.hash&&e.fixed32.encode(d,o.hash)},decode(d){const o=Ss.decode(d),n=e.uint.decode(d);return{pointer:o,metadata:1&n?Is.decode(d):null,preview:2&n?Fl.decode(d):null,hash:4&n?e.fixed32.decode(d):null}}},Vs=k,Hs={preencode(o,n){Vs.preencode(o,n.file),e.fixed32.preencode(o,n.roomKey),o.end++,n.encryptionKey&&e.buffer.preencode(o,n.encryptionKey),d>=28&&n.lastAccessed&&e.uint.preencode(o,n.lastAccessed),d>=28&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(n.encryptionKey?1:0)|(n.cleared?2:0)|(n.own?4:0)|(d>=28&&n.lastAccessed?8:0)|(d>=28&&n.version?16:0);Vs.encode(o,n.file),e.fixed32.encode(o,n.roomKey),e.uint.encode(o,c),n.encryptionKey&&e.buffer.encode(o,n.encryptionKey),d>=28&&n.lastAccessed&&e.uint.encode(o,n.lastAccessed),d>=28&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=Vs.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{file:n,roomKey:c,encryptionKey:1&r?e.buffer.decode(o):null,cleared:!!(2&r),own:!!(4&r),lastAccessed:d>=28&&8&r?e.uint.decode(o):0,version:d>=28&&16&r?e.uint.decode(o):0}}},Fs={preencode(d,o){e.uint.preencode(d,o.timestamp),d.end++,o.lastSynced&&e.uint.preencode(d,o.lastSynced)},encode(d,o){const n=(o.lastSynced?1:0)|(o.dirty?2:0);e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.lastSynced&&e.uint.encode(d,o.lastSynced)},decode(d){const o=e.uint.decode(d),n=e.uint.decode(d);return{discoveryPublicKey:null,timestamp:o,lastSynced:1&n?e.uint.decode(d):0,dirty:!!(2&n)}}},Ds={preencode(e,d){},encode(e,d){},decode:e=>({key:null,responsePublicKey:null})},Ls={preencode(o,n){o.end++,d>=10&&n.repairs&&e.uint.preencode(o,n.repairs)},encode(o,n){const c=d>=10&&n.repairs?1:0;e.uint.encode(o,c),d>=10&&n.repairs&&e.uint.encode(o,n.repairs)},decode(o){const n=e.uint.decode(o);return{roomKey:null,repairs:d>=10&&1&n?e.uint.decode(o):0}}},js={preencode(d,o){e.uint.preencode(d,o.count)},encode(d,o){e.uint.encode(d,o.count)},decode:d=>({roomKey:null,count:e.uint.decode(d)})},qs=Ft,Bs={preencode(o,n){e.string.preencode(o,n.code),e.string.preencode(o,n.message),e.string.preencode(o,n.stack),o.end++,d>=20&&n.details&&qs.preencode(o,n.details)},encode(o,n){const c=d>=20&&n.details?1:0;e.string.encode(o,n.code),e.string.encode(o,n.message),e.string.encode(o,n.stack),e.uint.encode(o,c),d>=20&&n.details&&qs.encode(o,n.details)},decode(o){const n=e.string.decode(o),c=e.string.decode(o),r=e.string.decode(o),t=e.uint.decode(o);return{code:n,message:c,stack:r,timestamp:0,details:d>=20&&1&t?qs.decode(o):null}}},Es={preencode(d,o){e.uint.preencode(d,o.total)},encode(d,o){e.uint.encode(d,o.total)},decode:d=>({roomKey:null,total:e.uint.decode(d)})},zs={preencode(d,o){e.buffer.preencode(d,o.proof),e.uint.preencode(d,o.createdAt)},encode(d,o){e.buffer.encode(d,o.proof),e.uint.encode(d,o.createdAt)},decode:d=>({deviceKey:null,proof:e.buffer.decode(d),createdAt:e.uint.decode(d)})},Os={preencode(d,o){Dl.preencode(d,o.head),e.uint.preencode(d,o.timestamp),d.end++},encode(o,n){const c=d>=37&&n.incremental?1:0;Dl.encode(o,n.head),e.uint.encode(o,n.timestamp),e.uint.encode(o,c)},decode(o){const n=Dl.decode(o),c=e.uint.decode(o),r=e.uint.decode(o);return{roomKey:null,head:n,timestamp:c,incremental:d>=37&&!!(1&r)}}},Ns={preencode(e,n){e.end++,d>=37&&n.legacyViewHead&&o.preencode(e,n.legacyViewHead),d>=37&&n.dbViewHead&&o.preencode(e,n.dbViewHead),d>=37&&n.blobsViewHead&&o.preencode(e,n.blobsViewHead),d>=37&&n.autobeeMigrationHead&&o.preencode(e,n.autobeeMigrationHead)},encode(n,c){const r=(d>=37&&c.legacyViewHead?1:0)|(d>=37&&c.dbViewHead?2:0)|(d>=37&&c.blobsViewHead?4:0)|(d>=37&&c.autobeeMigrationHead?8:0);e.uint.encode(n,r),d>=37&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=37&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=37&&c.blobsViewHead&&o.encode(n,c.blobsViewHead),d>=37&&c.autobeeMigrationHead&&o.encode(n,c.autobeeMigrationHead)},decode(n){const c=e.uint.decode(n);return{roomKey:null,legacyViewHead:d>=37&&1&c?o.decode(n):null,dbViewHead:d>=37&&2&c?o.decode(n):null,blobsViewHead:d>=37&&4&c?o.decode(n):null,autobeeMigrationHead:d>=37&&8&c?o.decode(n):null}}},Us=e.frame(w),Js=e.frame(Gi),Ws=Us,Gs=e.array(ct),Qs=e.frame(se),Xs=Us,Ys=Qs,Zs=e.frame(Lr),$s=e.frame(ca),_s=Qs,el=e.frame(fd),dl=e.frame(Ir),ol=e.frame(Gt),nl=ol,cl=e.array(e.frame(tt)),rl=Us,tl=e.frame(zn),il=e.frame(Vr),al=tl,sl=il,ll=tl,pl=il,ul=e.frame(jr),fl=il,ml=e.array(e.frame(Pt)),yl=e.frame(mi),bl=e.frame(Hi),xl=e.frame(qi),vl=e.frame(ba),gl=vl,kl=Us,Kl=e.array(e.frame(Qi)),hl=Kl,wl=vl,Rl=ml,Pl=yl,Tl=bl,Al=xl,Ml=vl,Sl=vl,Il=Qs,Cl=tl,Vl=il,Hl=Us,Fl=Us,Dl=vl;function Ll(e){switch(e){case"@keet/head":return o;case"@keet/oplog-id":return n;case"@keet/encryption-keypair":return c;case"@keet/signing-keypair":return r;case"@keet/room-keys":return t;case"@keet/operation-header":return i;case"@keet/blob-pointer":return a;case"@keet/file-dimensions":return s;case"@keet/file-metadata":return p;case"@keet/external-drive-pointer":return u;case"@keet/external-blob-pointer":return f;case"@keet/file-pointer":return b;case"@keet/file":return g;case"@keet/image-file":return w;case"@keet/file-status":return R;case"@keet/file-record":return A;case"@keet/device-status":return M;case"@keet/member-status":return S;case"@keet/member-moderation-status":return I;case"@keet/abi":return C;case"@keet/device-stats":return V;case"@keet/member-stats":return H;case"@keet/chat-stats":return F;case"@keet/file-stats":return D;case"@keet/stats":return E;case"@keet/room-type":return O;case"@keet/system-settings":return N;case"@keet/system-digest":return W;case"@keet/room-seed":return G;case"@keet/room-capabilities":return Q;case"@keet/room-config":return Y;case"@keet/blind-peer":return Z;case"@keet/add-blind-peer-operation":return ee;case"@keet/remove-blind-peer-operation":return oe;case"@keet/identity-attestation":return ne;case"@keet/device-invitation":return ce;case"@keet/device":return ie;case"@keet/member-profile":return ae;case"@keet/device-profile":return se;case"@keet/member-update":return pe;case"@keet/device-update":return ue;case"@keet/signed-pairing-data":return fe;case"@keet/device-request-identity":return me;case"@keet/device-response-identity":return ye;case"@keet/device-request-with-invitation":return ge;case"@keet/device-request-with-invitation-and-proof":return Ke;case"@keet/device-request-with-member-proof":return Re;case"@keet/device-request":return Ae;case"@keet/device-response":return Ie;case"@keet/invitation-metadata":return Ce;case"@keet/invitation":return Fe;case"@keet/add-invitation-operation":return je;case"@keet/remove-invitation-operation":return Be;case"@keet/sendable-room-invitation":return Ee;case"@keet/sendable-identity-invitation":return ze;case"@keet/sendable-contact-invitation":return Oe;case"@keet/sendable-invitation":return Ge;case"@keet/add-device-operation":return Xe;case"@keet/update-device-operation":return Ze;case"@keet/start-indexing-operation":return $e;case"@keet/stop-indexing-operation":return _e;case"@keet/join-request":return dd;case"@keet/accept-join-request-operation":return cd;case"@keet/reject-join-request-operation":return td;case"@keet/member":return sd;case"@keet/full-member":return ud;case"@keet/member-proofs":return fd;case"@keet/update-member-operation":return bd;case"@keet/change-member-status-operation":return gd;case"@keet/change-member-role-operation":return Kd;case"@keet/remove-member-operation":return wd;case"@keet/member-activity":return Rd;case"@keet/member-joined-event":return Pd;case"@keet/member-left-event":return Td;case"@keet/title-changed-chat-event":return Ad;case"@keet/chat-event":return Cd;case"@keet/sendable-event":return Vd;case"@keet/display-range":return Hd;case"@keet/display-content-range":return Dd;case"@keet/mention-display-item":return jd;case"@keet/link-preview":return Ed;case"@keet/display-link-item":return Nd;case"@keet/display":return _d;case"@keet/oplog-message":return co;case"@keet/index-message":return io;case"@keet/full-index-message":return lo;case"@keet/message-status":return po;case"@keet/message-index-id":return uo;case"@keet/thread":return mo;case"@keet/chat-message-record":return vo;case"@keet/full-chat-message-record":return ho;case"@keet/add-chat-message-operation":return Po;case"@keet/remove-chat-message-operation":return Ao;case"@keet/update-chat-message-operation":return Io;case"@keet/pin-chat-message-operation":return Vo;case"@keet/reaction":return Ho;case"@keet/reactions-summary":return Fo;case"@keet/reactions-digest":return Lo;case"@keet/add-reaction-operation":return qo;case"@keet/remove-reaction-operation":return Eo;case"@keet/update-room-config-operation":return No;case"@keet/group-member":return Uo;case"@keet/user-registry-info":return Jo;case"@keet/room-identity":return Go;case"@keet/genesis-operation":return dn;case"@keet/upgrade-operation":return nn;case"@keet/update-system-settings-operation":return tn;case"@keet-private-id/contact":return an;case"@keet-private-id/v3-room-migration-info":return sn;case"@keet-private-id/run-v3-migration-operation":return un;case"@keet-private-id/update-identity-operation":return mn;case"@keet-private-id/counters":return yn;case"@keet-private-id/stats":return bn;case"@keet-private-id/add-entropy-operation":return xn;case"@keet-private-id/pending-invitation-identity":return vn;case"@keet-private-id/pending-invitation":return kn;case"@keet-private-id/resolve-pending-invitation-operation":return hn;case"@keet-private-id/add-pending-invitation-operation":return Pn;case"@keet-private-id/remove-pending-invitation-operation":return An;case"@keet-private-id/identity-swap":return Mn;case"@keet-private-id/room-status":return Sn;case"@keet-private-id/room":return Hn;case"@keet-private-id/add-room-operation":return Dn;case"@keet-private-id/remove-room-operation":return jn;case"@keet-private-id/update-room-status-operation":return En;case"@keet-private-id/contact-status":return zn;case"@keet-private-id/contact-record":return On;case"@keet-private-id/add-contact-operation":return Jn;case"@keet-private-id/update-contact-status-operation":return Gn;case"@keet-private-id/remove-contact-operation":return Xn;case"@keet-private-id/contact-request-status":return Yn;case"@keet-private-id/contact-request-body":return _n;case"@keet-private-id/contact-request":return dc;case"@keet-private-id/contact-request-record":return rc;case"@keet-private-id/add-contact-request-operation":return ic;case"@keet-private-id/update-contact-request-status-operation":return lc;case"@keet-private-id/profile-discovery-record-v1":return pc;case"@keet-private-id/profile-discovery-record":return uc;case"@local/background-sync-room":return fc;case"@local/stats":return mc;case"@local/migration-status":return yc;case"@local/v3-private-profile-migration":return xc;case"@local/v3-room-migration":return kc;case"@local/room-migration-stats":return Kc;case"@local/room-migration":return wc;case"@local/identity-status":return Rc;case"@local/identity-record":return Ac;case"@local/tasks":return Sc;case"@local/room-keys":return Ic;case"@local/join-room-invitation-task":return Vc;case"@local/join-room-response-task":return Hc;case"@local/fast-forward-to":return Fc;case"@local/add-room-fields":return Dc;case"@local/join-room-keys-task":return jc;case"@local/create-room-task":return Bc;case"@local/leave-room-task":return Ec;case"@local/clear-room-task":return zc;case"@local/restore-identity-task":return Oc;case"@local/send-contact-request-task":return Nc;case"@local/migrate-v2-room-task":return Uc;case"@local/task":return er;case"@local/shared-invitation":return or;case"@local/room-status":return nr;case"@local/room-timestamps":return cr;case"@local/room":return vr;case"@local/room-preferences":return kr;case"@local/writer":return Kr;case"@local/member":return wr;case"@local/device":return Pr;case"@local/file":return Ar;case"@keet/add-file-preview-operation":return Sr;case"@keet/member-removed-event":return Ir;case"@keet/member-contact-info":return Vr;case"@keet/remove-device-operation":return Fr;case"@keet/device-identity":return Dr;case"@keet/readonly-room-invitation":return Lr;case"@keet-private-id/identity-swap-v2":return jr;case"@keet-private-id/activate-contact-room-operation":return Br;case"@local/identity-swap":return Er;case"@local/writer-append":return zr;case"@local/room-metadata":return Or;case"@local/debug-flag":return Nr;case"@local/debug":return Jr;case"@keet/display-type":return Gr;case"@keet/test-increment-operation":return Xr;case"@keet/test-collection-record-1":return Yr;case"@keet/migrate-abi-operation":return $r;case"@keet/system-settings-keys":return et;case"@local/hyperdht-record":return ot;case"@keet/room-supported-language":return ct;case"@keet/translation-display-item":return tt;case"@local/unread":return it;case"@keet-private-id/unreads":return at;case"@keet-private-id/add-unreads-key-operation":return lt;case"@keet-private-id/remove-unreads-key-operation":return ut;case"@keet/label-type":return mt;case"@keet/chat-label":return yt;case"@keet/add-chat-label-operation":return xt;case"@keet/remove-chat-label-operation":return gt;case"@keet/chat-label-summary":return kt;case"@keet/chat-label-digest":return ht;case"@keet/update-read-length-operation":return Rt;case"@keet/read-length":return Pt;case"@keet/tmp-removed-member":return Tt;case"@keet-private-id/settings":return At;case"@keet-private-id/user-settings-key":return St;case"@keet-private-id/update-settings-operation":return Vt;case"@local/error-record-details":return Ht;case"@local/error-record":return Dt;case"@local/keet-state":return jt;case"@local/file-stats":return qt;case"@keet/member-label-type":return Et;case"@keet/member-label":return zt;case"@keet/add-member-label-operation":return Nt;case"@keet/member-label-summary":return Ut;case"@keet/member-label-digest":return Wt;case"@keet/location-shared-event":return Gt;case"@keet/move-indexer-operation":return Xt;case"@keet/start-call":return $t;case"@keet/join-call":return di;case"@keet/leave-call":return ni;case"@keet/end-call":return ri;case"@keet/add-call-stream":return ii;case"@keet/remove-call-stream":return si;case"@keet/call-record":return li;case"@keet/call-member-record":return pi;case"@keet/call-device-record":return ui;case"@keet/call-stream-record":return fi;case"@local/active-call":return mi;case"@local/file-gc-info":return yi;case"@keet/build-type":return xi;case"@keet/test-crash-operation":return gi;case"@keet/test-dispatch-error-operation":return Ki;case"@local/environment-record":return hi;case"@keet-private-id/shorten-device-attestation-operation":return Ri;case"@local/ota-actions":return Pi;case"@local/device-attestation":return Ti;case"@keet/call-device-heartbeat":return Mi;case"@keet/remove-call-device":return Ii;case"@local/chat-labels":return Hi;case"@keet/start-call-recording":return Di;case"@keet/stop-call-recording":return ji;case"@local/settings":return qi;case"@local/hyperswarm-record":return Bi;case"@keet/dismiss-chat-reports-operation":return zi;case"@keet/update-typing-indicator-operation":return Ni;case"@keet/typing-indicator":return Ui;case"@keet-private-id/update-contact-alias-operation":return Wi;case"@keet/call-stats":return Gi;case"@keet/call-stream-input":return Qi;case"@keet/update-call-stream":return Yi;case"@keet/call-stream-status-record":return Zi;case"@keet/room-keys-v2":return $i;case"@keet/blob-pointer-v2":return _i;case"@keet/blob":return ea;case"@keet/autobee-migration":return da;case"@keet/autobee-migration-operation":return na;case"@keet/readonly-room-invitation-v2":return ca;case"@keet/admin-last-seen":return ta;case"@keet/blob-record":return ia;case"@keet-private-id/room-v2":return pa;case"@keet-private-id/add-room-operation-v2":return fa;case"@local/room-keys/v2":return ma;case"@local/room-update":return ya;case"@local/view-head":return ba;case"@local/autobee-migration":return xa;case"@keet-private-id/pending-invitation-response":return va;case"@keet-private-id/resolve-pending-invitation-operation-v2":return ka;case"@local/pending-recovery":return ha;case"@keet/claim-admin-devices-operation":return Ra;case"@keet/remove-file-preview-operation":return Ta;case"@keet/add-link-preview-operation":return Sa;case"@keet/remove-link-preview-operation":return Ca;case"@local/room-migration/hyperdb#3":return Ha;case"@local/room/hyperdb#6":return Ga;case"@local/room-preferences/hyperdb#13":return Xa;case"@local/writer/hyperdb#14":return Ya;case"@local/member/hyperdb#17":return $a;case"@keet/device/hyperdb#18":return ds;case"@local/device/hyperdb#18":return ns;case"@keet-private-id/contact/hyperdb#19":return cs;case"@local/task/hyperdb#21":return ms;case"@keet/blob-pointer/hyperdb#23":return ys;case"@keet/external-blob-pointer/hyperdb#23":return bs;case"@keet/file-pointer/hyperdb#23":return gs;case"@keet/file/hyperdb#23":return hs;case"@local/file/hyperdb#23":return Rs;case"@keet/external-drive-pointer/hyperdb#24":return Ps;case"@keet/file-pointer/hyperdb#24":return Ms;case"@keet/file/hyperdb#24":return Cs;case"@local/file/hyperdb#24":return Hs;case"@local/background-sync-room/hyperdb#27":return Fs;case"@local/writer-append/hyperdb#29":return Ds;case"@local/room-metadata/hyperdb#30":return Ls;case"@local/unread/hyperdb#33":return js;case"@local/error-record/hyperdb#35":return Bs;case"@local/file-stats/hyperdb#37":return Es;case"@local/device-attestation/hyperdb#44":return zs;case"@local/room-update/hyperdb#48":return Os;case"@local/autobee-migration/hyperdb#50":return Ns;default:throw new Error("Encoder not found "+e)}}function jl(e,o=41){const n=Ll(e);return{preencode(e,c){d=o,n.preencode(e,c)},encode(e,c){d=o,n.encode(e,c)},decode:e=>(d=o,n.decode(e))}}const ql=jl;module.exports={resolveStruct:ql,getStruct:jl,getEnum:function(e){switch(e){case"@keet/room-type":return z;case"@local/tasks":return Mc;case"@keet/display-type":return Wr;case"@keet/system-settings-keys":return _r;case"@keet/room-supported-language":return nt;case"@keet/label-type":return ft;case"@keet-private-id/user-settings-key":return Mt;case"@local/keet-state":return Lt;case"@keet/member-label-type":return Bt;case"@keet/build-type":return bi;default:throw new Error("Enum not found "+e)}},getEncoding:Ll,encode:function(o,n,c=41){return d=c,e.encode(Ll(o),n)},decode:function(o,n,c=41){return d=c,e.decode(Ll(o),n)},setVersion:function(e){d=e},version:d};
@holepunchto/keet-core/schema/spec/local/hyperschema/index.js +1 -1
……@@ -1 +1 @@
1const{c:e}=require("hyperschema/runtime");let d=39;const o={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.length)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.length)},decode:d=>({key:e.fixed32.decode(d),length:e.uint.decode(d)})},n={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.seq)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.seq)},decode:d=>({key:e.fixed32.decode(d),seq:e.uint.decode(d)})},c={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.secretKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.secretKey)},decode:d=>({publicKey:e.fixed32.decode(d),secretKey:e.fixed32.decode(d)})},r={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed64.preencode(d,o.secretKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed64.encode(d,o.secretKey)},decode:d=>({publicKey:e.fixed32.decode(d),secretKey:e.fixed64.decode(d)})},t={preencode(n,c){e.fixed32.preencode(n,c.key),n.end++,c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),d>=37&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=(c.encryptionKey?1:0)|(c.fastForwardTo?2:0)|(d>=37&&c.bootFrom?4:0);e.fixed32.encode(n,c.key),e.uint.encode(n,r),c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),d>=37&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.uint.decode(n);return{key:c,encryptionKey:1&r?e.buffer.decode(n):null,fastForwardTo:2&r?e.fixed32.decode(n):null,bootFrom:d>=37&&4&r?o.decode(n):null}}},i={preencode(d,o){e.uint.preencode(d,o.timestamp)},encode(d,o){e.uint.encode(d,o.timestamp)},decode:d=>({timestamp:e.uint.decode(d)})},a={preencode(d,o){e.uint.preencode(d,o.blockOffset),e.uint.preencode(d,o.blockLength),e.uint.preencode(d,o.byteOffset),e.uint.preencode(d,o.byteLength)},encode(d,o){e.uint.encode(d,o.blockOffset),e.uint.encode(d,o.blockLength),e.uint.encode(d,o.byteOffset),e.uint.encode(d,o.byteLength)},decode:d=>({blockOffset:e.uint.decode(d),blockLength:e.uint.decode(d),byteOffset:e.uint.decode(d),byteLength:e.uint.decode(d)})},s={preencode(d,o){e.uint.preencode(d,o.width),e.uint.preencode(d,o.height)},encode(d,o){e.uint.encode(d,o.width),e.uint.encode(d,o.height)},decode:d=>({width:e.uint.decode(d),height:e.uint.decode(d)})},p=e.frame(s),l={preencode(d,o){d.end++,o.name&&e.string.preencode(d,o.name),o.mimetype&&e.string.preencode(d,o.mimetype),o.dimensions&&p.preencode(d,o.dimensions),o.userdata&&e.buffer.preencode(d,o.userdata),o.duration&&e.uint.preencode(d,o.duration)},encode(d,o){const n=(o.name?1:0)|(o.mimetype?2:0)|(o.dimensions?4:0)|(o.userdata?8:0)|(o.duration?16:0)|(o.isPreview?32:0);e.uint.encode(d,n),o.name&&e.string.encode(d,o.name),o.mimetype&&e.string.encode(d,o.mimetype),o.dimensions&&p.encode(d,o.dimensions),o.userdata&&e.buffer.encode(d,o.userdata),o.duration&&e.uint.encode(d,o.duration)},decode(d){const o=e.uint.decode(d);return{name:1&o?e.string.decode(d):null,mimetype:2&o?e.string.decode(d):null,dimensions:4&o?p.decode(d):null,userdata:8&o?e.buffer.decode(d):null,duration:16&o?e.uint.decode(d):0,isPreview:!!(32&o)}}},u={preencode(d,o){e.fixed32.preencode(d,o.key),e.string.preencode(d,o.path),e.uint.preencode(d,o.version),e.uint.preencode(d,o.size)},encode(d,o){e.fixed32.encode(d,o.key),e.string.encode(d,o.path),e.uint.encode(d,o.version),e.uint.encode(d,o.size)},decode:d=>({key:e.fixed32.decode(d),path:e.string.decode(d),version:e.uint.decode(d),size:e.uint.decode(d)})},f={preencode(d,o){e.fixed32.preencode(d,o.key),a.preencode(d,o.blob)},encode(d,o){e.fixed32.encode(d,o.key),a.encode(d,o.blob)},decode:d=>({key:e.fixed32.decode(d),blob:a.decode(d)})},m=e.frame(f),y=e.frame(u),b={preencode(o,n){o.end++,n.inlined&&e.buffer.preencode(o,n.inlined),n.blob&&a.preencode(o,n.blob),n.externalBlob&&m.preencode(o,n.externalBlob),n.externalDrive&&y.preencode(o,n.externalDrive),d>=37&&n.bee&&_i.preencode(o,n.bee)},encode(o,n){const c=(n.inlined?1:0)|(n.blob?2:0)|(n.externalBlob?4:0)|(n.externalDrive?8:0)|(d>=37&&n.bee?16:0);e.uint.encode(o,c),n.inlined&&e.buffer.encode(o,n.inlined),n.blob&&a.encode(o,n.blob),n.externalBlob&&m.encode(o,n.externalBlob),n.externalDrive&&y.encode(o,n.externalDrive),d>=37&&n.bee&&_i.encode(o,n.bee)},decode(o){const n=e.uint.decode(o);return{inlined:1&n?e.buffer.decode(o):null,blob:2&n?a.decode(o):null,externalBlob:4&n?m.decode(o):null,externalDrive:8&n?y.decode(o):null,bee:d>=37&&16&n?_i.decode(o):null}}},x=e.frame(b),v=e.frame(l),k={preencode(d,o){x.preencode(d,o.pointer),d.end++,o.metadata&&v.preencode(d,o.metadata),o.preview&&wa.preencode(d,o.preview),o.hash&&e.fixed32.preencode(d,o.hash)},encode(d,o){const n=(o.metadata?1:0)|(o.preview?2:0)|(o.hash?4:0);x.encode(d,o.pointer),e.uint.encode(d,n),o.metadata&&v.encode(d,o.metadata),o.preview&&wa.encode(d,o.preview),o.hash&&e.fixed32.encode(d,o.hash)},decode(d){const o=x.decode(d),n=e.uint.decode(d);return{pointer:o,metadata:1&n?v.decode(d):null,preview:2&n?wa.decode(d):null,hash:4&n?e.fixed32.decode(d):null}}},g=e.frame(k),K=g,h=g,w={preencode(e,d){e.end++,d.small&&g.preencode(e,d.small),d.medium&&K.preencode(e,d.medium),d.large&&h.preencode(e,d.large)},encode(d,o){const n=(o.small?1:0)|(o.medium?2:0)|(o.large?4:0);e.uint.encode(d,n),o.small&&g.encode(d,o.small),o.medium&&K.encode(d,o.medium),o.large&&h.encode(d,o.large)},decode(d){const o=e.uint.decode(d);return{small:1&o?g.decode(d):null,medium:2&o?K.decode(d):null,large:4&o?h.decode(d):null}}},P={preencode(e,d){e.end++},encode(d,o){const n=o.isDeleted?1:0;e.uint.encode(d,n)},decode:d=>({isDeleted:!!(1&e.uint.decode(d))})},T=e.frame(P),R=g,A={preencode(o,c){e.uint.preencode(o,c.id),n.preencode(o,c.oplog),T.preencode(o,c.status),R.preencode(o,c.file),o.end++,d>=22&&c.version&&e.uint.preencode(o,c.version)},encode(o,c){const r=d>=22&&c.version?1:0;e.uint.encode(o,c.id),n.encode(o,c.oplog),T.encode(o,c.status),R.encode(o,c.file),e.uint.encode(o,r),d>=22&&c.version&&e.uint.encode(o,c.version)},decode(o){const c=e.uint.decode(o),r=n.decode(o),t=T.decode(o),i=R.decode(o),a=o.start<o.end?e.uint.decode(o):0;return{id:c,oplog:r,status:t,file:i,version:d>=22&&1&a?e.uint.decode(o):0}}},S={preencode(e,d){e.end++},encode(d,o){const n=(o.isActive?1:0)|(o.isIndexing?2:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isActive:!!(1&o),isIndexing:!!(2&o)}}},I={preencode(o,n){const c=(n.isAdmin?1:0)|(n.isModerator?2:0)|(n.isPending?4:0)|(n.isActive?8:0)|(n.isMuted?16:0)|(n.isBanned?32:0)|(n.isShadowBanned?64:0)|(d>=19&&n.isRemoved?128:0);e.uint.preencode(o,c)},encode(o,n){const c=(n.isAdmin?1:0)|(n.isModerator?2:0)|(n.isPending?4:0)|(n.isActive?8:0)|(n.isMuted?16:0)|(n.isBanned?32:0)|(n.isShadowBanned?64:0)|(d>=19&&n.isRemoved?128:0);e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{isAdmin:!!(1&n),isModerator:!!(2&n),isPending:!!(4&n),isActive:!!(8&n),isMuted:!!(16&n),isBanned:!!(32&n),isShadowBanned:!!(64&n),isRemoved:d>=19&&!!(128&n)}}},F={preencode(e,d){e.end++},encode(d,o){const n=(o.isMuted?1:0)|(o.isBanned?2:0)|(o.isShadowBanned?4:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isMuted:!!(1&o),isBanned:!!(2&o),isShadowBanned:!!(4&o)}}},M={preencode(d,o){e.uint.preencode(d,o.version)},encode(d,o){e.uint.encode(d,o.version)},decode:d=>({version:e.uint.decode(d)})},C={preencode(d,o){e.uint.preencode(d,o.total),e.uint.preencode(d,o.active)},encode(d,o){e.uint.encode(d,o.total),e.uint.encode(d,o.active)},decode:d=>({total:e.uint.decode(d),active:e.uint.decode(d)})},V={preencode(d,o){e.uint.preencode(d,o.total),e.uint.preencode(d,o.active),e.uint.preencode(d,o.pending)},encode(d,o){e.uint.encode(d,o.total),e.uint.encode(d,o.active),e.uint.encode(d,o.pending)},decode:d=>({total:e.uint.decode(d),active:e.uint.decode(d),pending:e.uint.decode(d)})},H={preencode(o,n){e.uint.preencode(o,n.clock),e.uint.preencode(o,n.pinned),e.uint.preencode(o,n.threads),e.uint.preencode(o,n.timestamp),o.end++,d>=24&&n.flagsClock&&e.uint.preencode(o,n.flagsClock)},encode(o,n){const c=d>=24&&n.flagsClock?1:0;e.uint.encode(o,n.clock),e.uint.encode(o,n.pinned),e.uint.encode(o,n.threads),e.uint.encode(o,n.timestamp),e.uint.encode(o,c),d>=24&&n.flagsClock&&e.uint.encode(o,n.flagsClock)},decode(o){const n=e.uint.decode(o),c=e.uint.decode(o),r=e.uint.decode(o),t=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{clock:n,pinned:c,threads:r,timestamp:t,flagsClock:d>=24&&1&i?e.uint.decode(o):0}}},D={preencode(d,o){e.uint.preencode(d,o.clock)},encode(d,o){e.uint.encode(d,o.clock)},decode:d=>({clock:e.uint.decode(d)})},L=e.frame(C),q=e.frame(V),j=e.frame(H),E=e.frame(D),B={preencode(e,o){L.preencode(e,o.devices),q.preencode(e,o.members),j.preencode(e,o.chat),E.preencode(e,o.files),e.end++,d>=36&&o.calls&&Pa.preencode(e,o.calls)},encode(o,n){const c=d>=36&&n.calls?1:0;L.encode(o,n.devices),q.encode(o,n.members),j.encode(o,n.chat),E.encode(o,n.files),e.uint.encode(o,c),d>=36&&n.calls&&Pa.encode(o,n.calls)},decode(o){const n=L.decode(o),c=q.decode(o),r=j.decode(o),t=E.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{devices:n,members:c,chat:r,files:t,calls:d>=36&&1&i?Pa.decode(o):null}}},z={Default:1,Broadcast:2,DirectMessage:3},O={preencode(e,d){e.end++},encode(d,o){if(o>3)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},N={preencode(o,n){const c=(n.roomType?1:0)|(n.isExperimental?2:0)|(n.isJoiningDisabled?4:0)|(n.isAppendingDisabled?8:0)|(n.isCallingDisabled?16:0)|(n.isMembershipEventsDisabled?32:0)|(d>=28&&n.isAttachmentsDisabled?64:0)|(d>=28&&n.isLinksDisabled?128:0)|(d>=29&&n.buildType?256:0)|(d>=33&&n.isRoomInviteHidden?512:0);e.uint.preencode(o,c),n.roomType&&O.preencode(o,n.roomType),d>=29&&n.buildType&&xi.preencode(o,n.buildType)},encode(o,n){const c=(n.roomType?1:0)|(n.isExperimental?2:0)|(n.isJoiningDisabled?4:0)|(n.isAppendingDisabled?8:0)|(n.isCallingDisabled?16:0)|(n.isMembershipEventsDisabled?32:0)|(d>=28&&n.isAttachmentsDisabled?64:0)|(d>=28&&n.isLinksDisabled?128:0)|(d>=29&&n.buildType?256:0)|(d>=33&&n.isRoomInviteHidden?512:0);e.uint.encode(o,c),n.roomType&&O.encode(o,n.roomType),d>=29&&n.buildType&&xi.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{roomType:1&n?O.decode(o):0,isExperimental:!!(2&n),isJoiningDisabled:!!(4&n),isAppendingDisabled:!!(8&n),isCallingDisabled:!!(16&n),isMembershipEventsDisabled:!!(32&n),isAttachmentsDisabled:d>=28&&!!(64&n),isLinksDisabled:d>=28&&!!(128&n),buildType:d>=29&&256&n?xi.decode(o):null,isRoomInviteHidden:d>=33&&!!(512&n)}}},U=e.frame(M),J=e.frame(N),W={preencode(d,o){U.preencode(d,o.abi),J.preencode(d,o.settings),e.uint.preencode(d,o.creationTime)},encode(d,o){U.encode(d,o.abi),J.encode(d,o.settings),e.uint.encode(d,o.creationTime)},decode:d=>({abi:U.decode(d),settings:J.decode(d),creationTime:e.uint.decode(d)})},G={preencode(d,o){e.fixed32.preencode(d,o.seed)},encode(d,o){e.fixed32.encode(d,o.seed)},decode:d=>({seed:e.fixed32.decode(d)})},Q={preencode(d,o){c.preencode(d,o.mailboxKeyPair),r.preencode(d,o.discoveryKeyPair),e.fixed32.preencode(d,o.wakeupTopic),e.fixed32.preencode(d,o.swarmTopic)},encode(d,o){c.encode(d,o.mailboxKeyPair),r.encode(d,o.discoveryKeyPair),e.fixed32.encode(d,o.wakeupTopic),e.fixed32.encode(d,o.swarmTopic)},decode:d=>({mailboxKeyPair:c.decode(d),discoveryKeyPair:r.decode(d),wakeupTopic:e.fixed32.decode(d),swarmTopic:e.fixed32.decode(d)})},X=e.array(e.fixed32),Y={preencode(o,n){o.end++,n.title&&e.string.preencode(o,n.title),n.avatar&&Ta.preencode(o,n.avatar),n.description&&e.string.preencode(o,n.description),d>=17&&n.supportedLanguages&&Ra.preencode(o,n.supportedLanguages),d>=19&&n.blindPeers&&X.preencode(o,n.blindPeers)},encode(o,n){const c=(n.title?1:0)|(n.avatar?2:0)|(n.description?4:0)|(d>=17&&n.supportedLanguages?8:0)|(d>=19&&n.blindPeers?16:0);e.uint.encode(o,c),n.title&&e.string.encode(o,n.title),n.avatar&&Ta.encode(o,n.avatar),n.description&&e.string.encode(o,n.description),d>=17&&n.supportedLanguages&&Ra.encode(o,n.supportedLanguages),d>=19&&n.blindPeers&&X.encode(o,n.blindPeers)},decode(o){const n=e.uint.decode(o);return{title:1&n?e.string.decode(o):null,avatar:2&n?Ta.decode(o):null,description:4&n?e.string.decode(o):null,supportedLanguages:d>=17&&8&n?Ra.decode(o):null,blindPeers:d>=19&&16&n?X.decode(o):null}}},Z={preencode(d,o){e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.key)},decode:d=>({key:e.fixed32.decode(d)})},$=e.frame(i),_=e.frame(Z),ee={preencode(e,d){$.preencode(e,d.header),_.preencode(e,d.peer)},encode(e,d){$.encode(e,d.header),_.encode(e,d.peer)},decode:e=>({header:$.decode(e),peer:_.decode(e)})},de=$,oe={preencode(d,o){de.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){de.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:de.decode(d),key:e.fixed32.decode(d)})},ne={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.buffer.preencode(d,o.proof)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.buffer.encode(d,o.proof)},decode:d=>({memberKey:e.fixed32.decode(d),proof:e.buffer.decode(d)})},ce={preencode(d,o){e.fixed32.preencode(d,o.id),e.buffer.preencode(d,o.response)},encode(d,o){e.fixed32.encode(d,o.id),e.buffer.encode(d,o.response)},decode:d=>({id:e.fixed32.decode(d),response:e.buffer.decode(d)})},re=e.frame(S),te=e.frame(ce),ie={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.memberKey),re.preencode(d,o.status),Aa.preencode(d,o.profile),d.end++,o.invitation&&te.preencode(d,o.invitation)},encode(d,o){const n=o.invitation?1:0;e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.memberKey),re.encode(d,o.status),Aa.encode(d,o.profile),e.uint.encode(d,n),o.invitation&&te.encode(d,o.invitation)},decode:d=>({key:e.fixed32.decode(d),memberKey:e.fixed32.decode(d),status:re.decode(d),profile:Aa.decode(d),invitation:1&e.uint.decode(d)?te.decode(d):null})},ae={preencode(d,o){e.uint.preencode(d,o.timestamp),d.end++,o.mailbox&&e.fixed32.preencode(d,o.mailbox),o.displayName&&e.string.preencode(d,o.displayName),o.avatar&&Sa.preencode(d,o.avatar),o.username&&e.string.preencode(d,o.username)},encode(d,o){const n=(o.mailbox?1:0)|(o.displayName?2:0)|(o.avatar?4:0)|(o.username?8:0);e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.mailbox&&e.fixed32.encode(d,o.mailbox),o.displayName&&e.string.encode(d,o.displayName),o.avatar&&Sa.encode(d,o.avatar),o.username&&e.string.encode(d,o.username)},decode(d){const o=e.uint.decode(d),n=e.uint.decode(d);return{timestamp:o,mailbox:1&n?e.fixed32.decode(d):null,displayName:2&n?e.string.decode(d):null,avatar:4&n?Sa.decode(d):null,username:8&n?e.string.decode(d):null}}},se={preencode(o,n){o.end++,n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),n.name&&e.string.preencode(o,n.name),d>=29&&n.buildType&&xi.preencode(o,n.buildType)},encode(o,n){const c=(n.swarmKey?1:0)|(n.name?2:0)|(n.isMobile?4:0)|(d>=29&&n.buildType?8:0);e.uint.encode(o,c),n.swarmKey&&e.fixed32.encode(o,n.swarmKey),n.name&&e.string.encode(o,n.name),d>=29&&n.buildType&&xi.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{swarmKey:1&n?e.fixed32.decode(o):null,name:2&n?e.string.decode(o):null,isMobile:!!(4&n),buildType:d>=29&&8&n?xi.decode(o):null}}},pe=e.frame(ae),le={preencode(e,d){pe.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){pe.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:pe.decode(e),attestation:ne.decode(e)})},ue={preencode(e,d){Ia.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){Ia.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:Ia.decode(e),attestation:ne.decode(e)})},fe={preencode(d,o){e.fixed32.preencode(d,o.id),e.buffer.preencode(d,o.data),e.buffer.preencode(d,o.signature)},encode(d,o){e.fixed32.encode(d,o.id),e.buffer.encode(d,o.data),e.buffer.encode(d,o.signature)},decode:d=>({id:e.fixed32.decode(d),data:e.buffer.decode(d),signature:e.buffer.decode(d)})},me={preencode(d,o){e.fixed32.preencode(d,o.devicePublicKey)},encode(d,o){e.fixed32.encode(d,o.devicePublicKey)},decode:d=>({devicePublicKey:e.fixed32.decode(d)})},ye={preencode(d,o){ne.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){ne.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({privateProfileIdentity:ne.decode(d),deviceProof:e.buffer.decode(d)})},be=e.frame(ue),xe=e.frame(le),ve=e.frame(me),ke={preencode(n,c){e.fixed32.preencode(n,c.deviceKey),r.preencode(n,c.keyPair),be.preencode(n,c.device),xe.preencode(n,c.member),n.end++,c.identity&&ve.preencode(n,c.identity),d>=37&&c.link&&o.preencode(n,c.link)},encode(n,c){const t=(c.identity?1:0)|(d>=37&&c.link?2:0);e.fixed32.encode(n,c.deviceKey),r.encode(n,c.keyPair),be.encode(n,c.device),xe.encode(n,c.member),e.uint.encode(n,t),c.identity&&ve.encode(n,c.identity),d>=37&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),t=r.decode(n),i=be.decode(n),a=xe.decode(n),s=e.uint.decode(n);return{deviceKey:c,keyPair:t,device:i,member:a,identity:1&s?ve.decode(n):null,link:d>=37&&2&s?o.decode(n):null}}},ge=e.frame(ke),Ke={preencode(d,o){e.fixed32.preencode(d,o.id),ge.preencode(d,o.request),e.buffer.preencode(d,o.signature)},encode(d,o){e.fixed32.encode(d,o.id),ge.encode(d,o.request),e.buffer.encode(d,o.signature)},decode:d=>({id:e.fixed32.decode(d),request:ge.decode(d),signature:e.buffer.decode(d)})},he=be,we=xe,Pe={preencode(e,d){he.preencode(e,d.device),e.end++,d.member&&we.preencode(e,d.member)},encode(d,o){const n=o.member?1:0;he.encode(d,o.device),e.uint.encode(d,n),o.member&&we.encode(d,o.member)},decode:d=>({device:he.decode(d),member:1&e.uint.decode(d)?we.decode(d):null})},Te=e.frame(Ke),Re=e.frame(Pe),Ae={preencode(e,d){e.end++,d.withInvitation&&Te.preencode(e,d.withInvitation),d.withMemberProof&&Re.preencode(e,d.withMemberProof)},encode(d,o){const n=(o.withInvitation?1:0)|(o.withMemberProof?2:0);e.uint.encode(d,n),o.withInvitation&&Te.encode(d,o.withInvitation),o.withMemberProof&&Re.encode(d,o.withMemberProof)},decode(d){const o=e.uint.decode(d);return{withInvitation:1&o?Te.decode(d):null,withMemberProof:2&o?Re.decode(d):null}}},Se=e.frame(fe),Ie=e.frame(ye),Fe={preencode(e,d){Se.preencode(e,d.signedKeys),e.end++,d.identity&&Ie.preencode(e,d.identity)},encode(d,o){const n=o.identity?1:0;Se.encode(d,o.signedKeys),e.uint.encode(d,n),o.identity&&Ie.encode(d,o.identity)},decode:d=>({signedKeys:Se.decode(d),identity:1&e.uint.decode(d)?Ie.decode(d):null})},Me={preencode(o,n){o.end++,n.expiration&&e.uint.preencode(o,n.expiration),d>=29&&n.buildType&&xi.preencode(o,n.buildType)},encode(o,n){const c=(n.expiration?1:0)|(n.requiresConfirmation?2:0)|(n.canModerate?4:0)|(n.canAdmin?8:0)|(d>=29&&n.buildType?16:0);e.uint.encode(o,c),n.expiration&&e.uint.encode(o,n.expiration),d>=29&&n.buildType&&xi.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{expiration:1&n?e.uint.decode(o):0,requiresConfirmation:!!(2&n),canModerate:!!(4&n),canAdmin:!!(8&n),buildType:d>=29&&16&n?xi.decode(o):null}}},Ce=Se,Ve=e.frame(Me),He={preencode(d,n){e.fixed32.preencode(d,n.id),Ce.preencode(d,n.response),Ve.preencode(d,n.metadata),d.end++,n.anchor&&o.preencode(d,n.anchor)},encode(d,n){const c=(n.anchor?1:0)|(n.isActive?2:0);e.fixed32.encode(d,n.id),Ce.encode(d,n.response),Ve.encode(d,n.metadata),e.uint.encode(d,c),n.anchor&&o.encode(d,n.anchor)},decode(d){const n=e.fixed32.decode(d),c=Ce.decode(d),r=Ve.decode(d),t=e.uint.decode(d);return{id:n,response:c,metadata:r,anchor:1&t?o.decode(d):null,isActive:!!(2&t)}}},De=$,Le=e.frame(He),qe={preencode(e,d){De.preencode(e,d.header),Le.preencode(e,d.invitation)},encode(e,d){De.encode(e,d.header),Le.encode(e,d.invitation)},decode:e=>({header:De.decode(e),invitation:Le.decode(e)})},je=$,Ee={preencode(d,o){je.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){je.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:je.decode(d),id:e.fixed32.decode(d)})},Be={preencode(d,n){e.fixed32.preencode(d,n.mailbox),e.fixed32.preencode(d,n.invitationSeed),o.preencode(d,n.anchor)},encode(d,n){e.fixed32.encode(d,n.mailbox),e.fixed32.encode(d,n.invitationSeed),o.encode(d,n.anchor)},decode:d=>({mailbox:e.fixed32.decode(d),invitationSeed:e.fixed32.decode(d),anchor:o.decode(d)})},ze={preencode(d,n){e.fixed32.preencode(d,n.mailbox),e.fixed32.preencode(d,n.invitationSeed),o.preencode(d,n.anchor),e.fixed32.preencode(d,n.identityPublicKey)},encode(d,n){e.fixed32.encode(d,n.mailbox),e.fixed32.encode(d,n.invitationSeed),o.encode(d,n.anchor),e.fixed32.encode(d,n.identityPublicKey)},decode:d=>({mailbox:e.fixed32.decode(d),invitationSeed:e.fixed32.decode(d),anchor:o.decode(d),identityPublicKey:e.fixed32.decode(d)})},Oe={preencode(d,o){e.fixed32.preencode(d,o.mailbox)},encode(d,o){e.fixed32.encode(d,o.mailbox)},decode:d=>({mailbox:e.fixed32.decode(d)})},Ne=e.frame(Be),Ue=e.frame(ze),Je=e.frame(Oe),We=e.array(e.ipv4Address),Ge={preencode(e,o){e.end++,o.room&&Ne.preencode(e,o.room),o.identity&&Ue.preencode(e,o.identity),o.contact&&Je.preencode(e,o.contact),d>=9&&o.readonly&&Fa.preencode(e,o.readonly),d>=17&&o.additionalNodes&&We.preencode(e,o.additionalNodes),d>=29&&o.buildType&&xi.preencode(e,o.buildType),d>=37&&o["readonly-v2"]&&Ma.preencode(e,o["readonly-v2"])},encode(o,n){const c=(n.room?1:0)|(n.identity?2:0)|(n.contact?4:0)|(d>=9&&n.readonly?8:0)|(d>=17&&n.additionalNodes?16:0)|(d>=29&&n.buildType?32:0)|(d>=37&&n["readonly-v2"]?64:0);e.uint.encode(o,c),n.room&&Ne.encode(o,n.room),n.identity&&Ue.encode(o,n.identity),n.contact&&Je.encode(o,n.contact),d>=9&&n.readonly&&Fa.encode(o,n.readonly),d>=17&&n.additionalNodes&&We.encode(o,n.additionalNodes),d>=29&&n.buildType&&xi.encode(o,n.buildType),d>=37&&n["readonly-v2"]&&Ma.encode(o,n["readonly-v2"])},decode(o){const n=e.uint.decode(o);return{room:1&n?Ne.decode(o):null,identity:2&n?Ue.decode(o):null,contact:4&n?Je.decode(o):null,readonly:d>=9&&8&n?Fa.decode(o):null,additionalNodes:d>=17&&16&n?We.decode(o):null,buildType:d>=29&&32&n?xi.decode(o):null,"readonly-v2":d>=37&&64&n?Ma.decode(o):null}}},Qe=$,Xe={preencode(d,o){Qe.preencode(d,o.header),e.buffer.preencode(d,o.blindRequest)},encode(d,o){Qe.encode(d,o.header),e.buffer.encode(d,o.blindRequest)},decode:d=>({header:Qe.decode(d),blindRequest:e.buffer.decode(d)})},Ye=$,Ze={preencode(o,n){Ye.preencode(o,n.header),o.end++,n.profile&&Ca.preencode(o,n.profile),d>=34&&n.key&&e.fixed32.preencode(o,n.key)},encode(o,n){const c=(n.profile?1:0)|(d>=34&&n.key?2:0);Ye.encode(o,n.header),e.uint.encode(o,c),n.profile&&Ca.encode(o,n.profile),d>=34&&n.key&&e.fixed32.encode(o,n.key)},decode(o){const n=Ye.decode(o),c=e.uint.decode(o);return{header:n,profile:1&c?Ca.decode(o):null,key:d>=34&&2&c?e.fixed32.decode(o):null}}},$e={preencode(e,d){},encode(e,d){},decode:e=>({})},_e=$e,ed=ge,dd={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.id),ed.preencode(d,o.request)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.id),ed.encode(d,o.request)},decode:d=>({deviceKey:e.fixed32.decode(d),id:e.fixed32.decode(d),request:ed.decode(d)})},od=$,nd=Ie,cd={preencode(d,o){od.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),d.end++,o.identity&&nd.preencode(d,o.identity)},encode(d,o){const n=o.identity?1:0;od.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,n),o.identity&&nd.encode(d,o.identity)},decode:d=>({header:od.decode(d),deviceKey:e.fixed32.decode(d),identity:1&e.uint.decode(d)?nd.decode(d):null})},rd=$,td={preencode(d,o){rd.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey)},encode(d,o){rd.encode(d,o.header),e.fixed32.encode(d,o.deviceKey)},decode:d=>({header:rd.decode(d),deviceKey:e.fixed32.decode(d)})},id=e.frame(I),ad=pe,sd={preencode(d,o){e.fixed32.preencode(d,o.key),id.preencode(d,o.status),ad.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),id.encode(d,o.status),ad.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),status:id.decode(d),profile:ad.decode(d)})},pd=id,ld=pe,ud={preencode(d,o){e.fixed32.preencode(d,o.key),pd.preencode(d,o.status),ld.preencode(d,o.profile),d.end++,o.proofs&&Va.preencode(d,o.proofs)},encode(d,o){const n=o.proofs?1:0;e.fixed32.encode(d,o.key),pd.encode(d,o.status),ld.encode(d,o.profile),e.uint.encode(d,n),o.proofs&&Va.encode(d,o.proofs)},decode:d=>({key:e.fixed32.decode(d),status:pd.decode(d),profile:ld.decode(d),proofs:1&e.uint.decode(d)?Va.decode(d):null})},fd={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++,o.profileAttestation&&e.buffer.preencode(d,o.profileAttestation),o.latestReceipt&&e.buffer.preencode(d,o.latestReceipt)},encode(d,o){const n=(o.profileAttestation?1:0)|(o.latestReceipt?2:0);e.fixed32.encode(d,o.key),e.uint.encode(d,n),o.profileAttestation&&e.buffer.encode(d,o.profileAttestation),o.latestReceipt&&e.buffer.encode(d,o.latestReceipt)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d);return{key:o,profileAttestation:1&n?e.buffer.decode(d):null,latestReceipt:2&n?e.buffer.decode(d):null}}},md=$,yd=xe,bd={preencode(e,d){md.preencode(e,d.header),yd.preencode(e,d.member)},encode(e,d){md.encode(e,d.header),yd.encode(e,d.member)},decode:e=>({header:md.decode(e),member:yd.decode(e)})},xd=$,vd=e.frame(F),kd={preencode(d,o){xd.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),vd.preencode(d,o.status)},encode(d,o){xd.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),vd.encode(d,o.status)},decode:d=>({header:xd.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:vd.decode(d)})},gd=$,Kd={preencode(d,o){gd.preencode(d,o.header),e.fixed32.preencode(d,o.key),d.end++},encode(d,o){const n=(o.isModerator?1:0)|(o.isAdmin?2:0);gd.encode(d,o.header),e.fixed32.encode(d,o.key),e.uint.encode(d,n)},decode(d){const o=gd.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{header:o,key:n,isModerator:!!(1&c),isAdmin:!!(2&c)}}},hd=$,wd={preencode(d,o){hd.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){hd.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:hd.decode(d),key:e.fixed32.decode(d)})},Pd={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.mentions)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.mentions)},decode:d=>({key:e.fixed32.decode(d),mentions:e.uint.decode(d)})},Td={preencode(d,o){d.end++,o.memberKey&&e.fixed32.preencode(d,o.memberKey)},encode(d,o){const n=o.memberKey?1:0;e.uint.encode(d,n),o.memberKey&&e.fixed32.encode(d,o.memberKey)},decode:d=>({memberKey:1&e.uint.decode(d)?e.fixed32.decode(d):null})},Rd=Td,Ad={preencode(d,o){d.end++,o.from&&e.string.preencode(d,o.from),o.to&&e.string.preencode(d,o.to)},encode(d,o){const n=(o.from?1:0)|(o.to?2:0);e.uint.encode(d,n),o.from&&e.string.encode(d,o.from),o.to&&e.string.encode(d,o.to)},decode(d){const o=e.uint.decode(d);return{from:1&o?e.string.decode(d):null,to:2&o?e.string.decode(d):null}}},Sd=e.frame(Td),Id=e.frame(Rd),Fd=e.frame(Ad),Md={preencode(o,n){const c=(n.memberJoined?1:0)|(n.memberLeft?2:0)|(n.titleChanged?4:0)|(n.callStarted?8:0)|(n.callHangup?16:0)|(n.callMissed?32:0)|(d>=4&&n.roomAvatarChanged?64:0)|(d>=4&&n.invitationCreated?128:0)|(d>=4&&n.memberRemoved?256:0)|(d>=27&&n.locationShared?512:0);e.uint.preencode(o,c),n.memberJoined&&Sd.preencode(o,n.memberJoined),n.memberLeft&&Id.preencode(o,n.memberLeft),n.titleChanged&&Fd.preencode(o,n.titleChanged),d>=4&&n.memberRemoved&&Ha.preencode(o,n.memberRemoved),d>=27&&n.locationShared&&Da.preencode(o,n.locationShared)},encode(o,n){const c=(n.memberJoined?1:0)|(n.memberLeft?2:0)|(n.titleChanged?4:0)|(n.callStarted?8:0)|(n.callHangup?16:0)|(n.callMissed?32:0)|(d>=4&&n.roomAvatarChanged?64:0)|(d>=4&&n.invitationCreated?128:0)|(d>=4&&n.memberRemoved?256:0)|(d>=27&&n.locationShared?512:0);e.uint.encode(o,c),n.memberJoined&&Sd.encode(o,n.memberJoined),n.memberLeft&&Id.encode(o,n.memberLeft),n.titleChanged&&Fd.encode(o,n.titleChanged),d>=4&&n.memberRemoved&&Ha.encode(o,n.memberRemoved),d>=27&&n.locationShared&&Da.encode(o,n.locationShared)},decode(o){const n=e.uint.decode(o);return{memberJoined:1&n?Sd.decode(o):null,memberLeft:2&n?Id.decode(o):null,titleChanged:4&n?Fd.decode(o):null,callStarted:!!(8&n),callHangup:!!(16&n),callMissed:!!(32&n),roomAvatarChanged:d>=4&&!!(64&n),invitationCreated:d>=4&&!!(128&n),memberRemoved:d>=4&&256&n?Ha.decode(o):null,locationShared:d>=27&&512&n?Da.decode(o):null}}},Cd={preencode(e,o){e.end++,d>=27&&o.locationShared&&La.preencode(e,o.locationShared)},encode(o,n){const c=(n.callStarted?1:0)|(n.callHangup?2:0)|(n.callMissed?4:0)|(d>=27&&n.locationShared?8:0);e.uint.encode(o,c),d>=27&&n.locationShared&&La.encode(o,n.locationShared)},decode(o){const n=e.uint.decode(o);return{callStarted:!!(1&n),callHangup:!!(2&n),callMissed:!!(4&n),locationShared:d>=27&&8&n?La.decode(o):null}}},Vd={preencode(d,o){e.uint.preencode(d,o.start),e.uint.preencode(d,o.length)},encode(d,o){e.uint.encode(d,o.start),e.uint.encode(d,o.length)},decode:d=>({start:e.uint.decode(d),length:e.uint.decode(d)})},Hd=e.frame(Vd),Dd={preencode(d,o){Hd.preencode(d,o.range),e.string.preencode(d,o.content)},encode(d,o){Hd.encode(d,o.range),e.string.encode(d,o.content)},decode:d=>({range:Hd.decode(d),content:e.string.decode(d)})},Ld=Hd,qd={preencode(d,o){Ld.preencode(d,o.range),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Ld.encode(d,o.range),e.fixed32.encode(d,o.memberKey)},decode:d=>({range:Ld.decode(d),memberKey:e.fixed32.decode(d)})},jd=g,Ed=e.array(e.uint),Bd={preencode(o,n){o.end++,n.title&&e.string.preencode(o,n.title),n.description&&e.string.preencode(o,n.description),n.file&&jd.preencode(o,n.file),d>=12&&n.files&&Ed.preencode(o,n.files)},encode(o,n){const c=(n.title?1:0)|(n.description?2:0)|(n.file?4:0)|(d>=12&&n.files?8:0);e.uint.encode(o,c),n.title&&e.string.encode(o,n.title),n.description&&e.string.encode(o,n.description),n.file&&jd.encode(o,n.file),d>=12&&n.files&&Ed.encode(o,n.files)},decode(o){const n=e.uint.decode(o);return{title:1&n?e.string.decode(o):null,description:2&n?e.string.decode(o):null,file:4&n?jd.decode(o):null,files:d>=12&&8&n?Ed.decode(o):null}}},zd=Hd,Od=e.frame(Bd),Nd={preencode(d,o){zd.preencode(d,o.range),e.string.preencode(d,o.url),d.end++,o.preview&&Od.preencode(d,o.preview)},encode(d,o){const n=o.preview?1:0;zd.encode(d,o.range),e.string.encode(d,o.url),e.uint.encode(d,n),o.preview&&Od.encode(d,o.preview)},decode:d=>({range:zd.decode(d),url:e.string.decode(d),preview:1&e.uint.decode(d)?Od.decode(d):null})},Ud=e.array(e.frame(qd)),Jd=e.array(e.frame(Nd)),Wd=Jd,Gd=e.array(e.frame(Vd)),Qd=Gd,Xd=Gd,Yd=e.array(e.frame(Dd)),Zd=Gd,$d=Gd,_d={preencode(o,n){const c=(n.mention?1:0)|(n.httpLink?2:0)|(n.pearLink?4:0)|(n.bold?8:0)|(n.italic?16:0)|(n.code?32:0)|(n.emoji?64:0)|(n.codeBlock?128:0)|(n.strike?256:0)|(d>=17&&n.translation?512:0);e.uint.preencode(o,c),n.mention&&Ud.preencode(o,n.mention),n.httpLink&&Jd.preencode(o,n.httpLink),n.pearLink&&Wd.preencode(o,n.pearLink),n.bold&&Gd.preencode(o,n.bold),n.italic&&Qd.preencode(o,n.italic),n.code&&Xd.preencode(o,n.code),n.emoji&&Yd.preencode(o,n.emoji),n.codeBlock&&Zd.preencode(o,n.codeBlock),n.strike&&$d.preencode(o,n.strike),d>=17&&n.translation&&qa.preencode(o,n.translation)},encode(o,n){const c=(n.mention?1:0)|(n.httpLink?2:0)|(n.pearLink?4:0)|(n.bold?8:0)|(n.italic?16:0)|(n.code?32:0)|(n.emoji?64:0)|(n.codeBlock?128:0)|(n.strike?256:0)|(d>=17&&n.translation?512:0);e.uint.encode(o,c),n.mention&&Ud.encode(o,n.mention),n.httpLink&&Jd.encode(o,n.httpLink),n.pearLink&&Wd.encode(o,n.pearLink),n.bold&&Gd.encode(o,n.bold),n.italic&&Qd.encode(o,n.italic),n.code&&Xd.encode(o,n.code),n.emoji&&Yd.encode(o,n.emoji),n.codeBlock&&Zd.encode(o,n.codeBlock),n.strike&&$d.encode(o,n.strike),d>=17&&n.translation&&qa.encode(o,n.translation)},decode(o){const n=e.uint.decode(o);return{mention:1&n?Ud.decode(o):null,httpLink:2&n?Jd.decode(o):null,pearLink:4&n?Wd.decode(o):null,bold:8&n?Gd.decode(o):null,italic:16&n?Qd.decode(o):null,code:32&n?Xd.decode(o):null,emoji:64&n?Yd.decode(o):null,codeBlock:128&n?Zd.decode(o):null,strike:256&n?$d.decode(o):null,translation:d>=17&&512&n?qa.decode(o):null}}},eo=e.array(e.frame(k)),oo=e.frame(_d),no=e.frame(Cd),co={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&eo.preencode(d,o.files),o.display&&oo.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent),o.event&&no.preencode(d,o.event)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(c.event?32:0)|(d>=27&&c.forwarded?64:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&eo.encode(o,c.files),c.display&&oo.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent),c.event&&no.encode(o,c.event)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?eo.decode(o):null,display:4&c?oo.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,event:32&c?no.decode(o):null,forwarded:d>=27&&!!(64&c)}}},ro=Ed,to=oo,io={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&ro.preencode(d,o.files),o.display&&to.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(d>=27&&c.forwarded?32:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&ro.encode(o,c.files),c.display&&to.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?ro.decode(o):null,display:4&c?to.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,forwarded:d>=27&&!!(32&c)}}},ao=eo,so=oo,po={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&ao.preencode(d,o.files),o.display&&so.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(d>=27&&c.forwarded?32:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&ao.encode(o,c.files),c.display&&so.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?ao.decode(o):null,display:4&c?so.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,forwarded:d>=27&&!!(32&c)}}},lo={preencode(e,d){e.end++},encode(d,o){const n=(o.isEdited?1:0)|(o.isDeleted?2:0)|(o.isPinned?4:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isEdited:!!(1&o),isDeleted:!!(2&o),isPinned:!!(4&o)}}},uo={preencode(d,o){e.uint.preencode(d,o.thread),e.uint.preencode(d,o.index)},encode(d,o){e.uint.encode(d,o.thread),e.uint.encode(d,o.index)},decode:d=>({thread:e.uint.decode(d),index:e.uint.decode(d)})},fo=e.frame(B),mo={preencode(d,o){e.uint.preencode(d,o.id),e.uint.preencode(d,o.count),d.end++,o.parent&&n.preencode(d,o.parent),o.stats&&fo.preencode(d,o.stats)},encode(d,o){const c=(o.parent?1:0)|(o.stats?2:0);e.uint.encode(d,o.id),e.uint.encode(d,o.count),e.uint.encode(d,c),o.parent&&n.encode(d,o.parent),o.stats&&fo.encode(d,o.stats)},decode(d){const o=e.uint.decode(d),c=e.uint.decode(d),r=e.uint.decode(d);return{id:o,count:c,parent:1&r?n.decode(d):null,stats:2&r?fo.decode(d):null}}},yo=e.frame(lo),bo=e.frame(io),xo=e.frame(Md),vo={preencode(d,o){uo.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),yo.preencode(d,o.status),o.message&&bo.preencode(d,o.message),o.event&&xo.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);uo.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),yo.encode(d,o.status),o.message&&bo.encode(d,o.message),o.event&&xo.encode(d,o.event)},decode(d){const o=uo.decode(d),c=n.decode(d),r=e.uint.decode(d),t=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:r,timestamp:t,editedAt:1&i?e.uint.decode(d):0,status:yo.decode(d),message:2&i?bo.decode(d):null,event:4&i?xo.decode(d):null}}},ko=yo,go=e.frame(po),Ko=xo,ho={preencode(d,o){uo.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),ko.preencode(d,o.status),o.message&&go.preencode(d,o.message),o.event&&Ko.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);uo.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),ko.encode(d,o.status),o.message&&go.encode(d,o.message),o.event&&Ko.encode(d,o.event)},decode(d){const o=uo.decode(d),c=n.decode(d),r=e.uint.decode(d),t=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:r,timestamp:t,editedAt:1&i?e.uint.decode(d):0,status:ko.decode(d),message:2&i?go.decode(d):null,event:4&i?Ko.decode(d):null}}},wo=$,Po=e.frame(co),To={preencode(e,d){wo.preencode(e,d.header),Po.preencode(e,d.message)},encode(e,d){wo.encode(e,d.header),Po.encode(e,d.message)},decode:e=>({header:wo.decode(e),message:Po.decode(e)})},Ro=$,Ao={preencode(e,d){Ro.preencode(e,d.header),n.preencode(e,d.oplog)},encode(e,d){Ro.encode(e,d.header),n.encode(e,d.oplog)},decode:e=>({header:Ro.decode(e),oplog:n.decode(e)})},So=$,Io=Po,Fo={preencode(e,d){So.preencode(e,d.header),n.preencode(e,d.oplog),Io.preencode(e,d.message)},encode(e,d){So.encode(e,d.header),n.encode(e,d.oplog),Io.encode(e,d.message)},decode:e=>({header:So.decode(e),oplog:n.decode(e),message:Io.decode(e)})},Mo=$,Co={preencode(e,d){Mo.preencode(e,d.header),n.preencode(e,d.oplog),e.end++},encode(d,o){const c=o.isPinned?1:0;Mo.encode(d,o.header),n.encode(d,o.oplog),e.uint.encode(d,c)},decode:d=>({header:Mo.decode(d),oplog:n.decode(d),isPinned:!!(1&e.uint.decode(d))})},Vo={preencode(d,o){uo.preencode(d,o.id),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),e.string.preencode(d,o.reaction)},encode(d,o){uo.encode(d,o.id),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),e.string.encode(d,o.reaction)},decode:d=>({id:uo.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),reaction:e.string.decode(d)})},Ho={preencode(d,o){e.string.preencode(d,o.text),e.uint.preencode(d,o.count)},encode(d,o){e.string.encode(d,o.text),e.uint.encode(d,o.count)},decode:d=>({text:e.string.decode(d),count:e.uint.decode(d)})},Do=e.array(e.frame(Ho)),Lo={preencode(o,n){uo.preencode(o,n.id),e.uint.preencode(o,n.total),Do.preencode(o,n.reactions),o.end++,d>=17&&n.editedAt&&e.uint.preencode(o,n.editedAt)},encode(o,n){const c=d>=17&&n.editedAt?1:0;uo.encode(o,n.id),e.uint.encode(o,n.total),Do.encode(o,n.reactions),e.uint.encode(o,c),d>=17&&n.editedAt&&e.uint.encode(o,n.editedAt)},decode(o){const n=uo.decode(o),c=e.uint.decode(o),r=Do.decode(o),t=o.start<o.end?e.uint.decode(o):0;return{id:n,total:c,reactions:r,editedAt:d>=17&&1&t?e.uint.decode(o):0}}},qo=$,jo={preencode(d,o){qo.preencode(d,o.header),n.preencode(d,o.oplog),e.string.preencode(d,o.reaction)},encode(d,o){qo.encode(d,o.header),n.encode(d,o.oplog),e.string.encode(d,o.reaction)},decode:d=>({header:qo.decode(d),oplog:n.decode(d),reaction:e.string.decode(d)})},Eo=$,Bo={preencode(d,o){Eo.preencode(d,o.header),n.preencode(d,o.oplog),e.string.preencode(d,o.reaction)},encode(d,o){Eo.encode(d,o.header),n.encode(d,o.oplog),e.string.encode(d,o.reaction)},decode:d=>({header:Eo.decode(d),oplog:n.decode(d),reaction:e.string.decode(d)})},zo=$,Oo=e.frame(Y),No={preencode(d,o){zo.preencode(d,o.header),e.uint.preencode(d,o.key),Oo.preencode(d,o.config)},encode(d,o){zo.encode(d,o.header),e.uint.encode(d,o.key),Oo.encode(d,o.config)},decode:d=>({header:zo.decode(d),key:e.uint.decode(d),config:Oo.decode(d)})},Uo={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.string.preencode(d,o.displayName),d.end++,o.avatar&&ja.preencode(d,o.avatar)},encode(d,o){const n=o.avatar?1:0;e.fixed32.encode(d,o.memberKey),e.string.encode(d,o.displayName),e.uint.encode(d,n),o.avatar&&ja.encode(d,o.avatar)},decode:d=>({memberKey:e.fixed32.decode(d),displayName:e.string.decode(d),avatar:1&e.uint.decode(d)?ja.decode(d):null})},Jo={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++,o.username&&e.string.preencode(d,o.username)},encode(d,o){const n=o.username?1:0;e.fixed32.encode(d,o.key),e.uint.encode(d,n),o.username&&e.string.encode(d,o.username)},decode:d=>({key:e.fixed32.decode(d),username:1&e.uint.decode(d)?e.string.decode(d):null})},Wo=e.frame(Jo),Go={preencode(d,o){e.fixed32.preencode(d,o.publicKey),d.end++,o.discoveryCoreKey&&e.fixed32.preencode(d,o.discoveryCoreKey),o.userRegistry&&Wo.preencode(d,o.userRegistry)},encode(d,o){const n=(o.discoveryCoreKey?1:0)|(o.userRegistry?2:0);e.fixed32.encode(d,o.publicKey),e.uint.encode(d,n),o.discoveryCoreKey&&e.fixed32.encode(d,o.discoveryCoreKey),o.userRegistry&&Wo.encode(d,o.userRegistry)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d);return{publicKey:o,discoveryCoreKey:1&n?e.fixed32.decode(d):null,userRegistry:2&n?Wo.decode(d):null}}},Qo=$,Xo=e.frame(W),Yo=e.frame(G),Zo=Oo,$o=e.frame(Go),_o=be,en=e.array(e.frame(le)),dn={preencode(e,d){Qo.preencode(e,d.header),Xo.preencode(e,d.digest),Yo.preencode(e,d.capabilities),e.end++,d.config&&Zo.preencode(e,d.config),d.identity&&$o.preencode(e,d.identity),d.bootstrapDevice&&_o.preencode(e,d.bootstrapDevice),d.initialMembers&&en.preencode(e,d.initialMembers)},encode(d,o){const n=(o.config?1:0)|(o.identity?2:0)|(o.bootstrapDevice?4:0)|(o.initialMembers?8:0);Qo.encode(d,o.header),Xo.encode(d,o.digest),Yo.encode(d,o.capabilities),e.uint.encode(d,n),o.config&&Zo.encode(d,o.config),o.identity&&$o.encode(d,o.identity),o.bootstrapDevice&&_o.encode(d,o.bootstrapDevice),o.initialMembers&&en.encode(d,o.initialMembers)},decode(d){const o=Qo.decode(d),n=Xo.decode(d),c=Yo.decode(d),r=e.uint.decode(d);return{header:o,digest:n,capabilities:c,config:1&r?Zo.decode(d):null,identity:2&r?$o.decode(d):null,bootstrapDevice:4&r?_o.decode(d):null,initialMembers:8&r?en.decode(d):null}}},on=$,nn={preencode(d,o){on.preencode(d,o.header),e.uint.preencode(d,o.version)},encode(d,o){on.encode(d,o.header),e.uint.encode(d,o.version)},decode:d=>({header:on.decode(d),version:e.uint.decode(d)})},cn=$,rn=J,tn={preencode(d,o){cn.preencode(d,o.header),e.uint.preencode(d,o.key),rn.preencode(d,o.settings)},encode(d,o){cn.encode(d,o.header),e.uint.encode(d,o.key),rn.encode(d,o.settings)},decode:d=>({header:cn.decode(d),key:e.uint.decode(d),settings:rn.decode(d)})},an={preencode(o,n){e.fixed32.preencode(o,n.memberKey),Ea.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=32&&n.contactInfo&&Ba.preencode(o,n.contactInfo),d>=32&&n.version&&e.uint.preencode(o,n.version),d>=34&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=32&&n.contactInfo?4:0)|(d>=32&&n.version?8:0)|(d>=34&&n.alias?16:0);e.fixed32.encode(o,n.memberKey),Ea.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=32&&n.contactInfo&&Ba.encode(o,n.contactInfo),d>=32&&n.version&&e.uint.encode(o,n.version),d>=34&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.fixed32.decode(o),c=Ea.decode(o),r=e.uint.decode(o);return{memberKey:n,status:c,mailbox:1&r?e.fixed32.decode(o):null,roomKey:2&r?e.fixed32.decode(o):null,contactInfo:d>=32&&4&r?Ba.decode(o):null,version:d>=32&&8&r?e.uint.decode(o):0,alias:d>=34&&16&r?e.string.decode(o):null}}},sn={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.seed),o.preencode(d,n.initiator),e.fixed32.preencode(d,n.fastForwardTo)},encode(d,n){e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.fixed32.encode(d,n.seed),o.encode(d,n.initiator),e.fixed32.encode(d,n.fastForwardTo)},decode:d=>({roomKey:e.fixed32.decode(d),encryptionKey:e.buffer.decode(d),seed:e.fixed32.decode(d),initiator:o.decode(d),fastForwardTo:e.fixed32.decode(d)})},pn=e.array(e.frame(sn)),ln=X,un={preencode(e,d){pn.preencode(e,d.sharedRooms),ln.preencode(e,d.blockedContacts)},encode(e,d){pn.encode(e,d.sharedRooms),ln.encode(e,d.blockedContacts)},decode:e=>({sharedRooms:pn.decode(e),blockedContacts:ln.decode(e)})},fn=$o,mn={preencode(e,d){fn.preencode(e,d.identity)},encode(e,d){fn.encode(e,d.identity)},decode:e=>({identity:fn.decode(e)})},yn={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.contacts)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.contacts)},decode:d=>({rooms:e.uint.decode(d),contacts:e.uint.decode(d)})},bn={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.contactRequests)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.contactRequests)},decode:d=>({rooms:e.uint.decode(d),contactRequests:e.uint.decode(d)})},xn={preencode(d,o){e.buffer.preencode(d,o.entropy)},encode(d,o){e.buffer.encode(d,o.entropy)},decode:d=>({entropy:e.buffer.decode(d)})},vn={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.devicePublicKey),e.fixed32.preencode(d,o.writerKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.devicePublicKey),e.fixed32.encode(d,o.writerKey)},decode:d=>({publicKey:e.fixed32.decode(d),devicePublicKey:e.fixed32.decode(d),writerKey:e.fixed32.decode(d)})},kn=e.frame(vn),gn={preencode(n,c){e.fixed32.preencode(n,c.id),e.fixed32.preencode(n,c.invitationSeed),e.fixed32.preencode(n,c.mailbox),r.preencode(n,c.responseKeyPair),o.preencode(n,c.initiator),o.preencode(n,c.inviter),n.end++,c.identity&&kn.preencode(n,c.identity),d>=29&&c.buildType&&xi.preencode(n,c.buildType),d>=37&&c.link&&o.preencode(n,c.link)},encode(n,c){const t=(c.identity?1:0)|(d>=29&&c.buildType?2:0)|(d>=37&&c.link?4:0);e.fixed32.encode(n,c.id),e.fixed32.encode(n,c.invitationSeed),e.fixed32.encode(n,c.mailbox),r.encode(n,c.responseKeyPair),o.encode(n,c.initiator),o.encode(n,c.inviter),e.uint.encode(n,t),c.identity&&kn.encode(n,c.identity),d>=29&&c.buildType&&xi.encode(n,c.buildType),d>=37&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),t=e.fixed32.decode(n),i=e.fixed32.decode(n),a=r.decode(n),s=o.decode(n),p=o.decode(n),l=e.uint.decode(n);return{id:c,invitationSeed:t,mailbox:i,responseKeyPair:a,initiator:s,inviter:p,identity:1&l?kn.decode(n):null,buildType:d>=29&&2&l?xi.decode(n):null,link:d>=37&&4&l?o.decode(n):null}}},Kn=$,hn={preencode(d,o){Kn.preencode(d,o.header),e.buffer.preencode(d,o.blindResponse)},encode(d,o){Kn.encode(d,o.header),e.buffer.encode(d,o.blindResponse)},decode:d=>({header:Kn.decode(d),blindResponse:e.buffer.decode(d)})},wn=$,Pn=e.frame(gn),Tn={preencode(e,d){wn.preencode(e,d.header),Pn.preencode(e,d.invitation)},encode(e,d){wn.encode(e,d.header),Pn.encode(e,d.invitation)},decode:e=>({header:wn.decode(e),invitation:Pn.decode(e)})},Rn=$,An={preencode(d,o){Rn.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){Rn.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:Rn.decode(d),id:e.fixed32.decode(d)})},Sn={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.devicePublicKey),d.end++,o.privateProfileKey&&e.fixed32.preencode(d,o.privateProfileKey),o.deviceKeyPair&&r.preencode(d,o.deviceKeyPair),e.buffer.preencode(d,o.deviceProof)},encode(d,o){const n=(o.privateProfileKey?1:0)|(o.deviceKeyPair?2:0);e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.devicePublicKey),e.uint.encode(d,n),o.privateProfileKey&&e.fixed32.encode(d,o.privateProfileKey),o.deviceKeyPair&&r.encode(d,o.deviceKeyPair),e.buffer.encode(d,o.deviceProof)},decode(d){const o=e.fixed32.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{publicKey:o,devicePublicKey:n,privateProfileKey:1&c?e.fixed32.decode(d):null,deviceKeyPair:2&c?r.decode(d):null,deviceProof:e.buffer.decode(d)}}},In={preencode(o,n){o.end++,d>=35&&n.roomSnoozeTime&&e.uint.preencode(o,n.roomSnoozeTime)},encode(o,n){const c=(n.isActive?1:0)|(n.isFullyMuted?2:0)|(n.isMentionsOnlyMuted?4:0)|(d>=14&&n.isReadOnly?8:0)|(d>=27&&n.isFavorite?16:0)|(d>=31&&n.isUnread?32:0)|(d>=35&&n.roomSnoozeTime?64:0);e.uint.encode(o,c),d>=35&&n.roomSnoozeTime&&e.uint.encode(o,n.roomSnoozeTime)},decode(o){const n=e.uint.decode(o);return{isActive:!!(1&n),isFullyMuted:!!(2&n),isMentionsOnlyMuted:!!(4&n),isReadOnly:d>=14&&!!(8&n),isFavorite:d>=27&&!!(16&n),isUnread:d>=31&&!!(32&n),roomSnoozeTime:d>=35&&64&n?e.uint.decode(o):0}}},Fn=e.frame(In),Mn=e.frame(Sn),Cn=kn,Vn={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),Fn.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,c.initiator&&o.preencode(n,c.initiator),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),c.identitySwap&&Mn.preencode(n,c.identitySwap),d>=9&&c.identitySwapV2&&Cn.preencode(n,c.identitySwapV2),d>=15&&c.contact&&e.fixed32.preencode(n,c.contact),d>=37&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=39&&c.activeClock&&e.uint.preencode(n,c.activeClock)},encode(n,c){const r=(c.initiator?1:0)|(c.fastForwardTo?2:0)|(c.identitySwap?4:0)|(d>=9&&c.identitySwapV2?8:0)|(d>=15&&c.contact?16:0)|(d>=37&&c.bootFrom?32:0)|(d>=39&&c.activeClock?64:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),Fn.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,r),c.initiator&&o.encode(n,c.initiator),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),c.identitySwap&&Mn.encode(n,c.identitySwap),d>=9&&c.identitySwapV2&&Cn.encode(n,c.identitySwapV2),d>=15&&c.contact&&e.fixed32.encode(n,c.contact),d>=37&&c.bootFrom&&o.encode(n,c.bootFrom),d>=39&&c.activeClock&&e.uint.encode(n,c.activeClock)},decode(n){const c=e.fixed32.decode(n),r=e.buffer.decode(n),t=e.fixed32.decode(n),i=Fn.decode(n),a=e.uint.decode(n),s=e.uint.decode(n);return{roomKey:c,encryptionKey:r,mailbox:t,status:i,clock:a,initiator:1&s?o.decode(n):null,fastForwardTo:2&s?e.fixed32.decode(n):null,identitySwap:4&s?Mn.decode(n):null,identitySwapV2:d>=9&&8&s?Cn.decode(n):null,contact:d>=15&&16&s?e.fixed32.decode(n):null,bootFrom:d>=37&&32&s?o.decode(n):null,activeClock:d>=39&&64&s?e.uint.decode(n):0}}},Hn=$,Dn={preencode(d,n){Hn.preencode(d,n.header),e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.mailbox),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.dm&&e.fixed32.preencode(d,n.dm)},encode(n,c){const r=(c.fastForwardTo?1:0)|(c.initiator?2:0)|(c.dm?4:0)|(d>=14&&c.isReadOnly?8:0);Hn.encode(n,c.header),e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),e.uint.encode(n,r),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),c.initiator&&o.encode(n,c.initiator),c.dm&&e.fixed32.encode(n,c.dm)},decode(n){const c=Hn.decode(n),r=e.fixed32.decode(n),t=e.buffer.decode(n),i=e.fixed32.decode(n),a=e.uint.decode(n);return{header:c,roomKey:r,encryptionKey:t,mailbox:i,fastForwardTo:1&a?e.fixed32.decode(n):null,initiator:2&a?o.decode(n):null,dm:4&a?e.fixed32.decode(n):null,isReadOnly:d>=14&&!!(8&a)}}},Ln=$,qn={preencode(d,o){Ln.preencode(d,o.header),e.fixed32.preencode(d,o.discoveryKey)},encode(d,o){Ln.encode(d,o.header),e.fixed32.encode(d,o.discoveryKey)},decode:d=>({header:Ln.decode(d),discoveryKey:e.fixed32.decode(d)})},jn=$,En=Fn,Bn={preencode(d,o){jn.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.key),En.preencode(d,o.status)},encode(d,o){jn.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.key),En.encode(d,o.status)},decode:d=>({header:jn.decode(d),roomKey:e.fixed32.decode(d),key:e.uint.decode(d),status:En.decode(d)})},zn={preencode(e,d){e.end++},encode(o,n){const c=(n.isBlocked?1:0)|(d>=32&&n.isActive?2:0);e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{isBlocked:!!(1&n),isActive:d>=32&&!!(2&n)}}},On={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.clock),za.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=32&&n.contactInfo&&Oa.preencode(o,n.contactInfo),d>=34&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=32&&n.contactInfo?4:0)|(d>=34&&n.alias?8:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.clock),za.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=32&&n.contactInfo&&Oa.encode(o,n.contactInfo),d>=34&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),r=za.decode(o),t=e.uint.decode(o);return{memberKey:n,clock:c,status:r,mailbox:1&t?e.fixed32.decode(o):null,roomKey:2&t?e.fixed32.decode(o):null,contactInfo:d>=32&&4&t?Oa.decode(o):null,alias:d>=34&&8&t?e.string.decode(o):null}}},Nn=$,Un=e.frame(an),Jn={preencode(e,d){Nn.preencode(e,d.header),Un.preencode(e,d.contact)},encode(e,d){Nn.encode(e,d.header),Un.encode(e,d.contact)},decode:e=>({header:Nn.decode(e),contact:Un.decode(e)})},Wn=$,Gn={preencode(d,o){Wn.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),Na.preencode(d,o.status)},encode(d,o){Wn.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),Na.encode(d,o.status)},decode:d=>({header:Wn.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:Na.decode(d)})},Qn=$,Xn={preencode(d,o){Qn.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Qn.encode(d,o.header),e.fixed32.encode(d,o.memberKey)},decode:d=>({header:Qn.decode(d),memberKey:e.fixed32.decode(d)})},Yn={preencode(e,d){e.end++},encode(d,o){const n=(o.isPending?1:0)|(o.isAccepted?2:0)|(o.isRejected?4:0)|(o.isDiscarded?8:0)|(o.isSeen?16:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isPending:!!(1&o),isAccepted:!!(2&o),isRejected:!!(4&o),isDiscarded:!!(8&o),isSeen:!!(16&o)}}},Zn=xe,$n=e.frame(t),_n={preencode(d,o){Zn.preencode(d,o.sender),$n.preencode(d,o.keys),e.fixed32.preencode(d,o.mailbox),d.end++,o.message&&e.string.preencode(d,o.message)},encode(d,o){const n=o.message?1:0;Zn.encode(d,o.sender),$n.encode(d,o.keys),e.fixed32.encode(d,o.mailbox),e.uint.encode(d,n),o.message&&e.string.encode(d,o.message)},decode:d=>({sender:Zn.decode(d),keys:$n.decode(d),mailbox:e.fixed32.decode(d),message:1&e.uint.decode(d)?e.string.decode(d):null})},ec=e.frame(_n),dc={preencode(e,d){ec.preencode(e,d.body),ne.preencode(e,d.attestation)},encode(e,d){ec.encode(e,d.body),ne.encode(e,d.attestation)},decode:e=>({body:ec.decode(e),attestation:ne.decode(e)})},oc=pe,nc=e.frame(Yn),cc=$n,rc={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.clock),oc.preencode(o,n.sender),nc.preencode(o,n.status),cc.preencode(o,n.keys),e.fixed32.preencode(o,n.mailbox),o.end++,n.message&&e.string.preencode(o,n.message),d>=17&&n.sentAt&&e.uint.preencode(o,n.sentAt),d>=32&&n.contactInfo&&Ua.preencode(o,n.contactInfo)},encode(o,n){const c=(n.message?1:0)|(d>=17&&n.sentAt?2:0)|(d>=32&&n.contactInfo?4:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.clock),oc.encode(o,n.sender),nc.encode(o,n.status),cc.encode(o,n.keys),e.fixed32.encode(o,n.mailbox),e.uint.encode(o,c),n.message&&e.string.encode(o,n.message),d>=17&&n.sentAt&&e.uint.encode(o,n.sentAt),d>=32&&n.contactInfo&&Ua.encode(o,n.contactInfo)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),r=oc.decode(o),t=nc.decode(o),i=cc.decode(o),a=e.fixed32.decode(o),s=e.uint.decode(o);return{memberKey:n,clock:c,sender:r,status:t,keys:i,mailbox:a,message:1&s?e.string.decode(o):null,sentAt:d>=17&&2&s?e.uint.decode(o):0,contactInfo:d>=32&&4&s?Ua.decode(o):null}}},tc=$,ic={preencode(d,o){tc.preencode(d,o.header),e.buffer.preencode(d,o.blindRequest)},encode(d,o){tc.encode(d,o.header),e.buffer.encode(d,o.blindRequest)},decode:d=>({header:tc.decode(d),blindRequest:e.buffer.decode(d)})},ac=$,sc=nc,pc={preencode(o,n){ac.preencode(o,n.header),e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.key),sc.preencode(o,n.status),o.end++,d>=15&&n.roomKey&&e.fixed32.preencode(o,n.roomKey)},encode(o,n){const c=d>=15&&n.roomKey?1:0;ac.encode(o,n.header),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.key),sc.encode(o,n.status),e.uint.encode(o,c),d>=15&&n.roomKey&&e.fixed32.encode(o,n.roomKey)},decode(o){const n=ac.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o),t=sc.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{header:n,memberKey:c,key:r,status:t,roomKey:d>=15&&1&i?e.fixed32.decode(o):null}}},lc={preencode(d,o){e.uint.preencode(d,o.timestamp),e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.mailbox)},encode(d,o){e.uint.encode(d,o.timestamp),e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.mailbox)},decode:d=>({version:e.uint.decode(d),timestamp:e.uint.decode(d),key:e.fixed32.decode(d),mailbox:e.fixed32.decode(d)})},uc={preencode(d,o){const n=o.version??1;switch(e.uint.preencode(d,n),n){case 0:case 1:lc.preencode(d,o);break;default:throw new Error("Unsupported version")}},encode(d,o){const n=o.version??1;switch(e.uint.encode(d,n),n){case 0:case 1:lc.encode(d,o);break;default:throw new Error("Unsupported version")}},decode(d){const o=d.start,n=e.uint.decode(d);switch(d.start=o,n){case 0:case 1:return lc.decode(d);default:throw new Error("Unsupported version")}}},fc={preencode(d,o){e.fixed32.preencode(d,o.discoveryPublicKey),e.uint.preencode(d,o.timestamp),d.end++,o.lastSynced&&e.uint.preencode(d,o.lastSynced)},encode(d,o){const n=(o.lastSynced?1:0)|(o.dirty?2:0);e.fixed32.encode(d,o.discoveryPublicKey),e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.lastSynced&&e.uint.encode(d,o.lastSynced)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d),c=e.uint.decode(d);return{discoveryPublicKey:o,timestamp:n,lastSynced:1&c?e.uint.decode(d):0,dirty:!!(2&c)}}},mc={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.activeRooms)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.activeRooms)},decode:d=>({rooms:e.uint.decode(d),activeRooms:e.uint.decode(d)})},yc=M,bc=X,xc={preencode(e,d){e.end++,d.blockedMembers&&bc.preencode(e,d.blockedMembers)},encode(d,o){const n=o.blockedMembers?1:0;e.uint.encode(d,n),o.blockedMembers&&bc.encode(d,o.blockedMembers)},decode:d=>({blockedMembers:1&e.uint.decode(d)?bc.decode(d):null})},vc=e.frame(Q),kc=e.frame(xc),gc={preencode(d,n){e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.seed),vc.preencode(d,n.capabilities),o.preencode(d,n.initiator),e.fixed32.preencode(d,n.fastForwardTo),d.end++,n.privateProfile&&kc.preencode(d,n.privateProfile)},encode(d,n){const c=n.privateProfile?1:0;e.buffer.encode(d,n.encryptionKey),e.fixed32.encode(d,n.seed),vc.encode(d,n.capabilities),o.encode(d,n.initiator),e.fixed32.encode(d,n.fastForwardTo),e.uint.encode(d,c),n.privateProfile&&kc.encode(d,n.privateProfile)},decode:d=>({encryptionKey:e.buffer.decode(d),seed:e.fixed32.decode(d),capabilities:vc.decode(d),initiator:o.decode(d),fastForwardTo:e.fixed32.decode(d),privateProfile:1&e.uint.decode(d)?kc.decode(d):null})},Kc={preencode(d,o){d.end++,o.count&&e.uint.preencode(d,o.count)},encode(d,o){const n=o.count?1:0;e.uint.encode(d,n),o.count&&e.uint.encode(d,o.count)},decode:d=>({count:1&e.uint.decode(d)?e.uint.decode(d):0})},hc=e.frame(gc),wc={preencode(o,n){e.fixed32.preencode(o,n.roomKey),e.uint.preencode(o,n.priority),o.end++,n.v3&&hc.preencode(o,n.v3),d>=5&&n.timestamp&&e.uint.preencode(o,n.timestamp)},encode(o,n){const c=(n.v3?1:0)|(d>=3&&n.errored?2:0)|(d>=5&&n.timestamp?4:0);e.fixed32.encode(o,n.roomKey),e.uint.encode(o,n.priority),e.uint.encode(o,c),n.v3&&hc.encode(o,n.v3),d>=5&&n.timestamp&&e.uint.encode(o,n.timestamp)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),r=e.uint.decode(o);return{roomKey:n,priority:c,v3:1&r?hc.decode(o):null,errored:d>=3&&!!(2&r),timestamp:d>=5&&4&r?e.uint.decode(o):0}}},Pc={preencode(e,d){e.end++},encode(d,o){const n=o.isConfirmed?1:0;e.uint.encode(d,n)},decode:d=>({isConfirmed:!!(1&e.uint.decode(d))})},Tc=e.frame(Pc),Rc=Mn,Ac={preencode(o,n){e.fixed32.preencode(o,n.publicKey),e.fixed32.preencode(o,n.privateProfileKey),r.preencode(o,n.deviceKeyPair),e.buffer.preencode(o,n.deviceProof),Tc.preencode(o,n.status),o.end++,n.entropy&&e.buffer.preencode(o,n.entropy),n.swap&&Rc.preencode(o,n.swap),d>=9&&n.swapV2&&Ja.preencode(o,n.swapV2),d>=31&&n.proofShortenedAt&&e.uint.preencode(o,n.proofShortenedAt)},encode(o,n){const c=(n.entropy?1:0)|(n.swap?2:0)|(d>=9&&n.swapV2?4:0)|(d>=31&&n.proofShortenedAt?8:0);e.fixed32.encode(o,n.publicKey),e.fixed32.encode(o,n.privateProfileKey),r.encode(o,n.deviceKeyPair),e.buffer.encode(o,n.deviceProof),Tc.encode(o,n.status),e.uint.encode(o,c),n.entropy&&e.buffer.encode(o,n.entropy),n.swap&&Rc.encode(o,n.swap),d>=9&&n.swapV2&&Ja.encode(o,n.swapV2),d>=31&&n.proofShortenedAt&&e.uint.encode(o,n.proofShortenedAt)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=r.decode(o),i=e.buffer.decode(o),a=Tc.decode(o),s=e.uint.decode(o);return{publicKey:n,privateProfileKey:c,deviceKeyPair:t,deviceProof:i,status:a,entropy:1&s?e.buffer.decode(o):null,swap:2&s?Rc.decode(o):null,swapV2:d>=9&&4&s?Ja.decode(o):null,proofShortenedAt:d>=31&&8&s?e.uint.decode(o):0}}},Sc={RestoreIdentity:1,CreateRoom:2,LeaveRoom:3,ClearRoom:4,JoinRoomInvitation:5,JoinRoomKeys:6,JoinRoomResponse:7,SendContactRequest:8,TestFastTask:9,TestSlowTask:10,TestErrorTask:11},Ic={preencode(e,d){e.end++},encode(d,o){if(o>11)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Fc={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator)},encode(d,n){const c=(n.fastForwardTo?1:0)|(n.initiator?2:0);e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.uint.encode(d,c),n.fastForwardTo&&e.fixed32.encode(d,n.fastForwardTo),n.initiator&&o.encode(d,n.initiator)},decode(d){const n=e.fixed32.decode(d),c=e.buffer.decode(d),r=e.uint.decode(d);return{roomKey:n,encryptionKey:c,fastForwardTo:1&r?e.fixed32.decode(d):null,initiator:2&r?o.decode(d):null}}},Mc=Pn,Cc={preencode(e,d){Mc.preencode(e,d.invitation)},encode(e,d){Mc.encode(e,d.invitation)},decode:e=>({invitation:Mc.decode(e)})},Vc={preencode(d,o){e.fixed32.preencode(d,o.mailbox),r.preencode(d,o.keyPair),e.buffer.preencode(d,o.response)},encode(d,o){e.fixed32.encode(d,o.mailbox),r.encode(d,o.keyPair),e.buffer.encode(d,o.response)},decode:d=>({mailbox:e.fixed32.decode(d),keyPair:r.decode(d),response:e.buffer.decode(d)})},Hc=Z,Dc={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.mailbox&&e.fixed32.preencode(d,n.mailbox)},encode(d,n){const c=(n.fastForwardTo?1:0)|(n.initiator?2:0)|(n.mailbox?4:0);e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.uint.encode(d,c),n.fastForwardTo&&e.fixed32.encode(d,n.fastForwardTo),n.initiator&&o.encode(d,n.initiator),n.mailbox&&e.fixed32.encode(d,n.mailbox)},decode(d){const n=e.fixed32.decode(d),c=e.buffer.decode(d),r=e.uint.decode(d);return{roomKey:n,encryptionKey:c,fastForwardTo:1&r?e.fixed32.decode(d):null,initiator:2&r?o.decode(d):null,mailbox:4&r?e.fixed32.decode(d):null}}},Lc=e.frame(Dc),qc={preencode(o,n){Lc.preencode(o,n.keys),o.end++,d>=39&&n.activeClock&&e.uint.preencode(o,n.activeClock)},encode(o,n){const c=(d>=39&&n.activeClock?1:0)|(d>=39&&n.isReadOnly?2:0);Lc.encode(o,n.keys),e.uint.encode(o,c),d>=39&&n.activeClock&&e.uint.encode(o,n.activeClock)},decode(o){const n=Lc.decode(o),c=o.start<o.end?e.uint.decode(o):0;return{keys:n,activeClock:d>=39&&1&c?e.uint.decode(o):0,isReadOnly:d>=39&&!!(2&c)}}},jc=e.frame(dn),Ec={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.mailbox&&e.fixed32.preencode(d,n.mailbox),n.keyPair&&r.preencode(d,n.keyPair),n.genesis&&jc.preencode(d,n.genesis)},encode(d,n){const c=(n.fastForwardTo?1:0)|(n.initiator?2:0)|(n.mailbox?4:0)|(n.keyPair?8:0)|(n.genesis?16:0)|(n.isPrivateProfile?32:0);e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.uint.encode(d,c),n.fastForwardTo&&e.fixed32.encode(d,n.fastForwardTo),n.initiator&&o.encode(d,n.initiator),n.mailbox&&e.fixed32.encode(d,n.mailbox),n.keyPair&&r.encode(d,n.keyPair),n.genesis&&jc.encode(d,n.genesis)},decode(d){const n=e.fixed32.decode(d),c=e.buffer.decode(d),t=e.uint.decode(d);return{roomKey:n,encryptionKey:c,fastForwardTo:1&t?e.fixed32.decode(d):null,initiator:2&t?o.decode(d):null,mailbox:4&t?e.fixed32.decode(d):null,keyPair:8&t?r.decode(d):null,genesis:16&t?jc.decode(d):null,isPrivateProfile:!!(32&t)}}},Bc={preencode(d,o){e.fixed32.preencode(d,o.roomKey),d.end++},encode(d,o){const n=o.isGossiped?1:0;e.fixed32.encode(d,o.roomKey),e.uint.encode(d,n)},decode:d=>({roomKey:e.fixed32.decode(d),isGossiped:!!(1&e.uint.decode(d))})},zc={preencode(d,o){e.fixed32.preencode(d,o.roomKey)},encode(d,o){e.fixed32.encode(d,o.roomKey)},decode:d=>({roomKey:e.fixed32.decode(d)})},Oc={preencode(d,o){e.string.preencode(d,o.mnemonic),d.end++,o.profileDiscoveryTimeout&&e.uint.preencode(d,o.profileDiscoveryTimeout)},encode(d,o){const n=(o.profileDiscoveryTimeout?1:0)|(o.recover?2:0);e.string.encode(d,o.mnemonic),e.uint.encode(d,n),o.profileDiscoveryTimeout&&e.uint.encode(d,o.profileDiscoveryTimeout)},decode(d){const o=e.string.decode(d),n=e.uint.decode(d);return{mnemonic:o,profileDiscoveryTimeout:1&n?e.uint.decode(d):0,recover:!!(2&n)}}},Nc={preencode(o,n){e.fixed32.preencode(o,n.roomKey),e.fixed32.preencode(o,n.memberKey),o.end++,n.message&&e.string.preencode(o,n.message),d>=6&&n.contactInfo&&Wa.preencode(o,n.contactInfo)},encode(o,n){const c=(n.message?1:0)|(d>=6&&n.contactInfo?2:0);e.fixed32.encode(o,n.roomKey),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,c),n.message&&e.string.encode(o,n.message),d>=6&&n.contactInfo&&Wa.encode(o,n.contactInfo)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{roomKey:n,memberKey:c,message:1&r?e.string.decode(o):null,contactInfo:d>=6&&2&r?Wa.decode(o):null}}},Uc={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++},encode(d,o){const n=o.isPrivateProfile?1:0;e.fixed32.encode(d,o.key),e.uint.encode(d,n)},decode:d=>({key:e.fixed32.decode(d),isPrivateProfile:!!(1&e.uint.decode(d))})},Jc=e.frame(Oc),Wc=e.frame(Ec),Gc=e.frame(Bc),Qc=e.frame(zc),Xc=e.frame(Cc),Yc=e.frame(qc),Zc=e.frame(Vc),$c=e.frame(Nc),_c=e.frame(Uc),er={preencode(d,o){const n=(o.restoreIdentity?1:0)|(o.createRoom?2:0)|(o.leaveRoom?4:0)|(o.clearRoom?8:0)|(o.joinRoomInvitation?16:0)|(o.joinRoomKeys?32:0)|(o.joinRoomResponse?64:0)|(o.sendContactRequest?128:0)|(o.migrateV2Room?256:0);e.fixed32.preencode(d,o.discoveryKey),e.uint.preencode(d,o.priority),e.uint.preencode(d,o.timestamp),e.uint.preencode(d,o.type),e.uint.preencode(d,n),o.restoreIdentity&&Jc.preencode(d,o.restoreIdentity),o.createRoom&&Wc.preencode(d,o.createRoom),o.leaveRoom&&Gc.preencode(d,o.leaveRoom),o.clearRoom&&Qc.preencode(d,o.clearRoom),o.joinRoomInvitation&&Xc.preencode(d,o.joinRoomInvitation),o.joinRoomKeys&&Yc.preencode(d,o.joinRoomKeys),o.joinRoomResponse&&Zc.preencode(d,o.joinRoomResponse),o.sendContactRequest&&$c.preencode(d,o.sendContactRequest),o.migrateV2Room&&_c.preencode(d,o.migrateV2Room)},encode(d,o){const n=(o.restoreIdentity?1:0)|(o.createRoom?2:0)|(o.leaveRoom?4:0)|(o.clearRoom?8:0)|(o.joinRoomInvitation?16:0)|(o.joinRoomKeys?32:0)|(o.joinRoomResponse?64:0)|(o.sendContactRequest?128:0)|(o.migrateV2Room?256:0);e.fixed32.encode(d,o.discoveryKey),e.uint.encode(d,o.priority),e.uint.encode(d,o.timestamp),e.uint.encode(d,o.type),e.uint.encode(d,n),o.restoreIdentity&&Jc.encode(d,o.restoreIdentity),o.createRoom&&Wc.encode(d,o.createRoom),o.leaveRoom&&Gc.encode(d,o.leaveRoom),o.clearRoom&&Qc.encode(d,o.clearRoom),o.joinRoomInvitation&&Xc.encode(d,o.joinRoomInvitation),o.joinRoomKeys&&Yc.encode(d,o.joinRoomKeys),o.joinRoomResponse&&Zc.encode(d,o.joinRoomResponse),o.sendContactRequest&&$c.encode(d,o.sendContactRequest),o.migrateV2Room&&_c.encode(d,o.migrateV2Room)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d),c=e.uint.decode(d),r=e.uint.decode(d),t=e.uint.decode(d);return{discoveryKey:o,priority:n,timestamp:c,type:r,restoreIdentity:1&t?Jc.decode(d):null,createRoom:2&t?Wc.decode(d):null,leaveRoom:4&t?Gc.decode(d):null,clearRoom:8&t?Qc.decode(d):null,joinRoomInvitation:16&t?Xc.decode(d):null,joinRoomKeys:32&t?Yc.decode(d):null,joinRoomResponse:64&t?Zc.decode(d):null,sendContactRequest:128&t?$c.decode(d):null,migrateV2Room:256&t?_c.decode(d):null}}},dr=Le,or={preencode(d,o){e.buffer.preencode(d,o.seed),dr.preencode(d,o.invitation)},encode(d,o){e.buffer.encode(d,o.seed),dr.encode(d,o.invitation)},decode:d=>({seed:e.buffer.decode(d),invitation:dr.decode(d)})},nr={preencode(e,d){e.end++},encode(o,n){const c=(n.isWritable?1:0)|(n.isReadable?2:0)|(n.isPrivateProfile?4:0)|(d>=8&&n.isRemoved?8:0);e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{isWritable:!!(1&n),isReadable:!!(2&n),isPrivateProfile:!!(4&n),isRemoved:d>=8&&!!(8&n)}}},cr={preencode(d,o){e.uint.preencode(d,o.creation),e.uint.preencode(d,o.latestSync),e.uint.preencode(d,o.latestChatMessage)},encode(d,o){e.uint.encode(d,o.creation),e.uint.encode(d,o.latestSync),e.uint.encode(d,o.latestChatMessage)},decode:d=>({creation:e.uint.decode(d),latestSync:e.uint.decode(d),latestChatMessage:e.uint.decode(d)})},rr=Xo,tr=fo,ir=e.frame(cr),ar=vc,sr=e.frame(nr),pr=e.frame(ie),lr=e.frame(ud),ur=Oo,fr=$o,mr=e.frame(ho),yr=X,br=e.frame(sd),xr=Fn,vr={preencode(o,n){const c=(n.selfDevice?1:0)|(n.selfMember?2:0)|(n.config?4:0)|(n.identity?8:0)|(n.lastMessage?16:0)|(n.dm?32:0)|(d>=19&&n.readLengths?64:0)|(d>=19&&n.lastMember?128:0)|(d>=21&&n.version?256:0)|(d>=27&&n.preferences?512:0)|(d>=28&&n.activeCall?1024:0)|(d>=32&&n.lastMessageLabels?2048:0)|(d>=33&&n.settings?4096:0)|(d>=37&&n.system?8192:0)|(d>=37&&n.processed?16384:0);e.fixed32.preencode(o,n.roomKey),e.fixed32.preencode(o,n.discoveryKey),e.buffer.preencode(o,n.encryptionKey),rr.preencode(o,n.digest),tr.preencode(o,n.stats),ir.preencode(o,n.timestamps),e.uint.preencode(o,n.fork),e.uint.preencode(o,n.length),e.fixed32.preencode(o,n.seed),ar.preencode(o,n.capabilities),sr.preencode(o,n.status),e.uint.preencode(o,c),n.selfDevice&&pr.preencode(o,n.selfDevice),n.selfMember&&lr.preencode(o,n.selfMember),n.config&&ur.preencode(o,n.config),n.identity&&fr.preencode(o,n.identity),n.lastMessage&&mr.preencode(o,n.lastMessage),n.dm&&yr.preencode(o,n.dm),d>=19&&n.readLengths&&Ga.preencode(o,n.readLengths),d>=19&&n.lastMember&&br.preencode(o,n.lastMember),d>=21&&n.version&&e.uint.preencode(o,n.version),d>=27&&n.preferences&&xr.preencode(o,n.preferences),d>=28&&n.activeCall&&Qa.preencode(o,n.activeCall),d>=32&&n.lastMessageLabels&&Xa.preencode(o,n.lastMessageLabels),d>=33&&n.settings&&Ya.preencode(o,n.settings),d>=37&&n.system&&Za.preencode(o,n.system),d>=37&&n.processed&&$a.preencode(o,n.processed)},encode(o,n){const c=(n.selfDevice?1:0)|(n.selfMember?2:0)|(n.config?4:0)|(n.identity?8:0)|(n.lastMessage?16:0)|(n.dm?32:0)|(d>=19&&n.readLengths?64:0)|(d>=19&&n.lastMember?128:0)|(d>=21&&n.version?256:0)|(d>=27&&n.preferences?512:0)|(d>=28&&n.activeCall?1024:0)|(d>=32&&n.lastMessageLabels?2048:0)|(d>=33&&n.settings?4096:0)|(d>=37&&n.system?8192:0)|(d>=37&&n.processed?16384:0);e.fixed32.encode(o,n.roomKey),e.fixed32.encode(o,n.discoveryKey),e.buffer.encode(o,n.encryptionKey),rr.encode(o,n.digest),tr.encode(o,n.stats),ir.encode(o,n.timestamps),e.uint.encode(o,n.fork),e.uint.encode(o,n.length),e.fixed32.encode(o,n.seed),ar.encode(o,n.capabilities),sr.encode(o,n.status),e.uint.encode(o,c),n.selfDevice&&pr.encode(o,n.selfDevice),n.selfMember&&lr.encode(o,n.selfMember),n.config&&ur.encode(o,n.config),n.identity&&fr.encode(o,n.identity),n.lastMessage&&mr.encode(o,n.lastMessage),n.dm&&yr.encode(o,n.dm),d>=19&&n.readLengths&&Ga.encode(o,n.readLengths),d>=19&&n.lastMember&&br.encode(o,n.lastMember),d>=21&&n.version&&e.uint.encode(o,n.version),d>=27&&n.preferences&&xr.encode(o,n.preferences),d>=28&&n.activeCall&&Qa.encode(o,n.activeCall),d>=32&&n.lastMessageLabels&&Xa.encode(o,n.lastMessageLabels),d>=33&&n.settings&&Ya.encode(o,n.settings),d>=37&&n.system&&Za.encode(o,n.system),d>=37&&n.processed&&$a.encode(o,n.processed)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.buffer.decode(o),t=rr.decode(o),i=tr.decode(o),a=ir.decode(o),s=e.uint.decode(o),p=e.uint.decode(o),l=e.fixed32.decode(o),u=ar.decode(o),f=sr.decode(o),m=e.uint.decode(o);return{roomKey:n,discoveryKey:c,encryptionKey:r,digest:t,stats:i,timestamps:a,fork:s,length:p,seed:l,capabilities:u,status:f,selfDevice:1&m?pr.decode(o):null,selfMember:2&m?lr.decode(o):null,config:4&m?ur.decode(o):null,identity:8&m?fr.decode(o):null,lastMessage:16&m?mr.decode(o):null,dm:32&m?yr.decode(o):null,readLengths:d>=19&&64&m?Ga.decode(o):null,lastMember:d>=19&&128&m?br.decode(o):null,version:d>=21&&256&m?e.uint.decode(o):0,preferences:d>=27&&512&m?xr.decode(o):null,activeCall:d>=28&&1024&m?Qa.decode(o):null,lastMessageLabels:d>=32&&2048&m?Xa.decode(o):null,settings:d>=33&&4096&m?Ya.decode(o):null,system:d>=37&&8192&m?Za.decode(o):null,processed:d>=37&&16384&m?$a.decode(o):null}}},kr=Fn,gr={preencode(d,o){e.fixed32.preencode(d,o.roomKey),kr.preencode(d,o.status)},encode(d,o){e.fixed32.encode(d,o.roomKey),kr.encode(d,o.status)},decode:d=>({roomKey:e.fixed32.decode(d),status:kr.decode(d)})},Kr={preencode(o,n){e.fixed32.preencode(o,n.mailbox),e.fixed32.preencode(o,n.key),o.end++,n.roomKey&&e.fixed32.preencode(o,n.roomKey),n.keyPair&&r.preencode(o,n.keyPair),n.responseKeyPair&&r.preencode(o,n.responseKeyPair),d>=39&&n.activeClock&&e.uint.preencode(o,n.activeClock)},encode(o,n){const c=(n.roomKey?1:0)|(n.keyPair?2:0)|(n.responseKeyPair?4:0)|(d>=38&&n.pending?8:0)|(d>=39&&n.activeClock?16:0);e.fixed32.encode(o,n.mailbox),e.fixed32.encode(o,n.key),e.uint.encode(o,c),n.roomKey&&e.fixed32.encode(o,n.roomKey),n.keyPair&&r.encode(o,n.keyPair),n.responseKeyPair&&r.encode(o,n.responseKeyPair),d>=39&&n.activeClock&&e.uint.encode(o,n.activeClock)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=e.uint.decode(o);return{mailbox:n,key:c,roomKey:1&t?e.fixed32.decode(o):null,keyPair:2&t?r.decode(o):null,responseKeyPair:4&t?r.decode(o):null,pending:d>=38&&!!(8&t),activeClock:d>=39&&16&t?e.uint.decode(o):0}}},hr=pe,wr={preencode(d,o){e.fixed32.preencode(d,o.key),hr.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),hr.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),profile:hr.decode(d)})},Pr=pr,Tr={preencode(d,o){e.fixed32.preencode(d,o.roomKey),Pr.preencode(d,o.device)},encode(d,o){e.fixed32.encode(d,o.roomKey),Pr.encode(d,o.device)},decode:d=>({roomKey:e.fixed32.decode(d),device:Pr.decode(d)})},Rr=g,Ar={preencode(o,n){Rr.preencode(o,n.file),e.fixed32.preencode(o,n.roomKey),o.end++,n.encryptionKey&&e.buffer.preencode(o,n.encryptionKey),d>=28&&n.lastAccessed&&e.uint.preencode(o,n.lastAccessed),d>=28&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(n.encryptionKey?1:0)|(n.cleared?2:0)|(n.own?4:0)|(d>=28&&n.lastAccessed?8:0)|(d>=28&&n.version?16:0);Rr.encode(o,n.file),e.fixed32.encode(o,n.roomKey),e.uint.encode(o,c),n.encryptionKey&&e.buffer.encode(o,n.encryptionKey),d>=28&&n.lastAccessed&&e.uint.encode(o,n.lastAccessed),d>=28&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=Rr.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{file:n,roomKey:c,encryptionKey:1&r?e.buffer.decode(o):null,cleared:!!(2&r),own:!!(4&r),lastAccessed:d>=28&&8&r?e.uint.decode(o):0,version:d>=28&&16&r?e.uint.decode(o):0}}},Sr=$,Ir={preencode(o,c){Sr.preencode(o,c.header),n.preencode(o,c.oplog),e.uint.preencode(o,c.index),_a.preencode(o,c.preview),o.end++,d>=12&&c.displayType&&Gr.preencode(o,c.displayType)},encode(o,c){const r=d>=12&&c.displayType?1:0;Sr.encode(o,c.header),n.encode(o,c.oplog),e.uint.encode(o,c.index),_a.encode(o,c.preview),e.uint.encode(o,r),d>=12&&c.displayType&&Gr.encode(o,c.displayType)},decode(o){const c=Sr.decode(o),r=n.decode(o),t=e.uint.decode(o),i=_a.decode(o),a=o.start<o.end?e.uint.decode(o):0;return{header:c,oplog:r,index:t,preview:i,displayType:d>=12&&1&a?Gr.decode(o):0}}},Fr={preencode(o,n){o.end++,d>=4&&n.memberKey&&e.fixed32.preencode(o,n.memberKey)},encode(o,n){const c=d>=4&&n.memberKey?1:0;e.uint.encode(o,c),d>=4&&n.memberKey&&e.fixed32.encode(o,n.memberKey)},decode(o){const n=e.uint.decode(o);return{memberKey:d>=4&&1&n?e.fixed32.decode(o):null}}},Mr=pe,Cr={preencode(e,d){Mr.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){Mr.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:Mr.decode(e),attestation:ne.decode(e)})},Vr=$,Hr={preencode(d,o){Vr.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){Vr.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:Vr.decode(d),key:e.fixed32.decode(d)})},Dr={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),ne.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){e.fixed32.encode(d,o.deviceKey),ne.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({deviceKey:e.fixed32.decode(d),privateProfileIdentity:ne.decode(d),deviceProof:e.buffer.decode(d)})},Lr={preencode(o,n){e.fixed32.preencode(o,n.roomKey),e.fixed32.preencode(o,n.encryptionKey),e.fixed32.preencode(o,n.seed),o.end++,d>=9&&n.fastForwardTo&&e.fixed32.preencode(o,n.fastForwardTo)},encode(o,n){const c=d>=9&&n.fastForwardTo?1:0;e.fixed32.encode(o,n.roomKey),e.fixed32.encode(o,n.encryptionKey),e.fixed32.encode(o,n.seed),e.uint.encode(o,c),d>=9&&n.fastForwardTo&&e.fixed32.encode(o,n.fastForwardTo)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o);return{roomKey:n,encryptionKey:c,seed:r,fastForwardTo:d>=9&&1&t?e.fixed32.decode(o):null}}},qr={preencode(o,n){e.fixed32.preencode(o,n.publicKey),e.fixed32.preencode(o,n.writerKey),e.fixed32.preencode(o,n.devicePublicKey),o.end++,d>=9&&n.privateProfileKey&&e.fixed32.preencode(o,n.privateProfileKey)},encode(o,n){const c=d>=9&&n.privateProfileKey?1:0;e.fixed32.encode(o,n.publicKey),e.fixed32.encode(o,n.writerKey),e.fixed32.encode(o,n.devicePublicKey),e.uint.encode(o,c),d>=9&&n.privateProfileKey&&e.fixed32.encode(o,n.privateProfileKey)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o);return{publicKey:n,writerKey:c,devicePublicKey:r,privateProfileKey:d>=9&&1&t?e.fixed32.decode(o):null}}},jr=$,Er={preencode(d,o){jr.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey)},encode(d,o){jr.encode(d,o.header),e.fixed32.encode(d,o.memberKey)},decode:d=>({header:jr.decode(d),memberKey:e.fixed32.decode(d)})},Br={preencode(d,o){e.fixed32.preencode(d,o.privateProfileKey)},encode(d,o){e.fixed32.encode(d,o.privateProfileKey)},decode:d=>({privateProfileKey:e.fixed32.decode(d)})},zr={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.responsePublicKey)},encode(d,o){e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.responsePublicKey)},decode:d=>({key:e.fixed32.decode(d),responsePublicKey:e.fixed32.decode(d)})},Or={preencode(o,n){e.fixed32.preencode(o,n.roomKey),o.end++,d>=10&&n.repairs&&e.uint.preencode(o,n.repairs)},encode(o,n){const c=d>=10&&n.repairs?1:0;e.fixed32.encode(o,n.roomKey),e.uint.encode(o,c),d>=10&&n.repairs&&e.uint.encode(o,n.repairs)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o);return{roomKey:n,repairs:d>=10&&1&c?e.uint.decode(o):0}}},Nr={preencode(o,n){o.end++,d>=11&&n.key&&e.string.preencode(o,n.key),d>=11&&n.description&&e.string.preencode(o,n.description)},encode(o,n){const c=(d>=11&&n.key?1:0)|(d>=11&&n.value?2:0)|(d>=11&&n.description?4:0);e.uint.encode(o,c),d>=11&&n.key&&e.string.encode(o,n.key),d>=11&&n.description&&e.string.encode(o,n.description)},decode(o){const n=e.uint.decode(o);return{key:d>=11&&1&n?e.string.decode(o):null,value:d>=11&&!!(2&n),description:d>=11&&4&n?e.string.decode(o):null}}},Ur=e.array(e.frame(Nr)),Jr={preencode(e,o){e.end++,d>=11&&o.flags&&Ur.preencode(e,o.flags)},encode(o,n){const c=d>=11&&n.flags?1:0;e.uint.encode(o,c),d>=11&&n.flags&&Ur.encode(o,n.flags)},decode(o){const n=e.uint.decode(o);return{flags:d>=11&&1&n?Ur.decode(o):null}}},Wr={HttpLink:1,PearLink:2},Gr={preencode(e,d){e.end++},encode(d,o){if(o>2)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Qr=$,Xr={preencode(d,o){Qr.preencode(d,o.header),e.uint.preencode(d,o.value)},encode(d,o){Qr.encode(d,o.header),e.uint.encode(d,o.value)},decode:d=>({header:Qr.decode(d),value:e.uint.decode(d)})},Yr={preencode(d,o){e.uint.preencode(d,o.key),e.uint.preencode(d,o.value)},encode(d,o){e.uint.encode(d,o.key),e.uint.encode(d,o.value)},decode:d=>({key:e.uint.decode(d),value:e.uint.decode(d)})},Zr=$,$r={preencode(o,n){Zr.preencode(o,n.header),e.uint.preencode(o,n.from),e.uint.preencode(o,n.to),o.end++,d>=29&&n.buildType&&xi.preencode(o,n.buildType)},encode(o,n){const c=d>=29&&n.buildType?1:0;Zr.encode(o,n.header),e.uint.encode(o,n.from),e.uint.encode(o,n.to),e.uint.encode(o,c),d>=29&&n.buildType&&xi.encode(o,n.buildType)},decode(o){const n=Zr.decode(o),c=e.uint.decode(o),r=e.uint.decode(o),t=o.start<o.end?e.uint.decode(o):0;return{header:n,from:c,to:r,buildType:d>=29&&1&t?xi.decode(o):null}}},_r={RoomType:1,IsExperimental:2,IsJoiningDisabled:3,IsAppendingDisabled:4,IsCallingDisabled:5,IsMembershipEventsDisabled:6,IsAttachmentsDisabled:7,IsLinksDisabled:8,IsRoomInviteHidden:9},et={preencode(e,d){e.end++},encode(d,o){if(o>9)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},dt=We,ot={preencode(o,n){o.end++,d>=16&&n.nodes&&dt.preencode(o,n.nodes),d>=24&&n.concurrency&&e.uint.preencode(o,n.concurrency),d>=24&&n.maxWindow&&e.uint.preencode(o,n.maxWindow),d>=24&&n.randomPunchInterval&&e.uint.preencode(o,n.randomPunchInterval),d>=24&&n.connectionKeepAlive&&e.uint.preencode(o,n.connectionKeepAlive)},encode(o,n){const c=(d>=16&&n.nodes?1:0)|(d>=24&&n.concurrency?2:0)|(d>=24&&n.maxWindow?4:0)|(d>=24&&n.randomPunchInterval?8:0)|(d>=24&&n.connectionKeepAlive?16:0);e.uint.encode(o,c),d>=16&&n.nodes&&dt.encode(o,n.nodes),d>=24&&n.concurrency&&e.uint.encode(o,n.concurrency),d>=24&&n.maxWindow&&e.uint.encode(o,n.maxWindow),d>=24&&n.randomPunchInterval&&e.uint.encode(o,n.randomPunchInterval),d>=24&&n.connectionKeepAlive&&e.uint.encode(o,n.connectionKeepAlive)},decode(o){const n=e.uint.decode(o);return{nodes:d>=16&&1&n?dt.decode(o):null,concurrency:d>=24&&2&n?e.uint.decode(o):0,maxWindow:d>=24&&4&n?e.uint.decode(o):0,randomPunchInterval:d>=24&&8&n?e.uint.decode(o):0,connectionKeepAlive:d>=24&&16&n?e.uint.decode(o):0}}},nt={en:"en",it:"it",ru:"ru",es:"es",de:"de"},ct={preencode(e,d){e.end++},encode(d,o){switch(o){case"en":e.uint.encode(d,1);break;case"it":e.uint.encode(d,2);break;case"ru":e.uint.encode(d,3);break;case"es":e.uint.encode(d,4);break;case"de":e.uint.encode(d,5);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"en";case 2:return"it";case 3:return"ru";case 4:return"es";case 5:return"de";default:return null}}},rt=Hd,tt={preencode(d,o){rt.preencode(d,o.range),ct.preencode(d,o.language),e.string.preencode(d,o.text)},encode(d,o){rt.encode(d,o.range),ct.encode(d,o.language),e.string.encode(d,o.text)},decode:d=>({range:rt.decode(d),language:ct.decode(d),text:e.string.decode(d)})},it={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.count)},encode(d,o){e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.count)},decode:d=>({roomKey:e.fixed32.decode(d),count:e.uint.decode(d)})},at={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.key)},decode:d=>({deviceKey:e.fixed32.decode(d),key:e.fixed32.decode(d)})},st=$,pt={preencode(d,o){st.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){st.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:st.decode(d),key:e.fixed32.decode(d)})},lt=$,ut={preencode(d,o){lt.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){lt.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:lt.decode(d),key:e.fixed32.decode(d)})},ft={Flag:1},mt={preencode(e,d){e.end++},encode(d,o){if(o>1)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},yt={preencode(d,o){uo.preencode(d,o.id),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),mt.preencode(d,o.label)},encode(d,o){uo.encode(d,o.id),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),mt.encode(d,o.label)},decode:d=>({id:uo.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),label:mt.decode(d)})},bt=$,xt={preencode(e,d){bt.preencode(e,d.header),n.preencode(e,d.oplog),mt.preencode(e,d.label)},encode(e,d){bt.encode(e,d.header),n.encode(e,d.oplog),mt.encode(e,d.label)},decode:e=>({header:bt.decode(e),oplog:n.decode(e),label:mt.decode(e)})},vt=$,kt={preencode(e,d){vt.preencode(e,d.header),n.preencode(e,d.oplog),mt.preencode(e,d.label)},encode(e,d){vt.encode(e,d.header),n.encode(e,d.oplog),mt.encode(e,d.label)},decode:e=>({header:vt.decode(e),oplog:n.decode(e),label:mt.decode(e)})},gt={preencode(d,o){mt.preencode(d,o.label),e.uint.preencode(d,o.count)},encode(d,o){mt.encode(d,o.label),e.uint.encode(d,o.count)},decode:d=>({label:mt.decode(d),count:e.uint.decode(d)})},Kt=e.array(e.frame(gt)),ht={preencode(o,n){uo.preencode(o,n.id),e.uint.preencode(o,n.total),Kt.preencode(o,n.labels),e.uint.preencode(o,n.editedAt),o.end++,d>=24&&n.flagsClock&&e.uint.preencode(o,n.flagsClock),d>=24&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(d>=24&&n.flagsClock?1:0)|(d>=24&&n.version?2:0)|(d>=25&&n.isDeleted?4:0);uo.encode(o,n.id),e.uint.encode(o,n.total),Kt.encode(o,n.labels),e.uint.encode(o,n.editedAt),e.uint.encode(o,c),d>=24&&n.flagsClock&&e.uint.encode(o,n.flagsClock),d>=24&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=uo.decode(o),c=e.uint.decode(o),r=Kt.decode(o),t=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{id:n,total:c,labels:r,editedAt:t,flagsClock:d>=24&&1&i?e.uint.decode(o):0,version:d>=24&&2&i?e.uint.decode(o):0,isDeleted:d>=25&&!!(4&i)}}},wt=$,Pt={preencode(d,o){wt.preencode(d,o.header),e.uint.preencode(d,o.length)},encode(d,o){wt.encode(d,o.header),e.uint.encode(d,o.length)},decode:d=>({header:wt.decode(d),length:e.uint.decode(d)})},Tt={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.length)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.length)},decode:d=>({memberKey:e.fixed32.decode(d),length:e.uint.decode(d)})},Rt=Z,At={preencode(o,n){o.end++,d>=33&&n.profileSnoozeTime&&e.uint.preencode(o,n.profileSnoozeTime)},encode(o,n){const c=(d>=19&&n.disableReadReceipts?1:0)|(d>=31&&n.stripAttachmentMetadata?2:0)|(d>=33&&n.profileSnoozeTime?4:0);e.uint.encode(o,c),d>=33&&n.profileSnoozeTime&&e.uint.encode(o,n.profileSnoozeTime)},decode(o){const n=e.uint.decode(o);return{disableReadReceipts:d>=19&&!!(1&n),stripAttachmentMetadata:d>=31&&!!(2&n),profileSnoozeTime:d>=33&&4&n?e.uint.decode(o):0}}},St={disableReadReceipts:"disableReadReceipts",stripAttachmentMetadata:"stripAttachmentMetadata",profileSnoozeTime:"profileSnoozeTime"},It={preencode(e,d){e.end++},encode(d,o){switch(o){case"disableReadReceipts":e.uint.encode(d,1);break;case"stripAttachmentMetadata":e.uint.encode(d,2);break;case"profileSnoozeTime":e.uint.encode(d,3);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"disableReadReceipts";case 2:return"stripAttachmentMetadata";case 3:return"profileSnoozeTime";default:return null}}},Ft=$,Mt=e.frame(At),Ct={preencode(e,d){Ft.preencode(e,d.header),It.preencode(e,d.key),Mt.preencode(e,d.settings)},encode(e,d){Ft.encode(e,d.header),It.encode(e,d.key),Mt.encode(e,d.settings)},decode:e=>({header:Ft.decode(e),key:It.decode(e),settings:Mt.decode(e)})},Vt={preencode(o,n){o.end++,d>=20&&n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=23&&n.coreKey&&e.fixed32.preencode(o,n.coreKey)},encode(o,n){const c=(d>=20&&n.roomKey?1:0)|(d>=23&&n.coreKey?2:0);e.uint.encode(o,c),d>=20&&n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=23&&n.coreKey&&e.fixed32.encode(o,n.coreKey)},decode(o){const n=e.uint.decode(o);return{roomKey:d>=20&&1&n?e.fixed32.decode(o):null,coreKey:d>=23&&2&n?e.fixed32.decode(o):null}}},Ht=e.frame(Vt),Dt={preencode(o,n){e.string.preencode(o,n.code),e.string.preencode(o,n.message),e.string.preencode(o,n.stack),e.uint.preencode(o,n.timestamp),o.end++,d>=20&&n.details&&Ht.preencode(o,n.details)},encode(o,n){const c=d>=20&&n.details?1:0;e.string.encode(o,n.code),e.string.encode(o,n.message),e.string.encode(o,n.stack),e.uint.encode(o,n.timestamp),e.uint.encode(o,c),d>=20&&n.details&&Ht.encode(o,n.details)},decode(o){const n=e.string.decode(o),c=e.string.decode(o),r=e.string.decode(o),t=e.uint.decode(o),i=e.uint.decode(o);return{code:n,message:c,stack:r,timestamp:t,details:d>=20&&1&i?Ht.decode(o):null}}},Lt={RESUME:1,WAKEUP:2,PRESUSPEND:3,SUSPEND:4},qt={preencode(e,d){e.end++},encode(d,o){if(o>4)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},jt={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.total)},encode(d,o){e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.total)},decode:d=>({roomKey:e.fixed32.decode(d),total:e.uint.decode(d)})},Et={Flag:1},Bt={preencode(e,d){e.end++},encode(d,o){if(o>1)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},zt={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),Bt.preencode(d,o.label)},encode(d,o){e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),Bt.encode(d,o.label)},decode:d=>({key:e.fixed32.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),label:Bt.decode(d)})},Ot=$,Nt={preencode(d,o){Ot.preencode(d,o.header),e.fixed32.preencode(d,o.key),Bt.preencode(d,o.label)},encode(d,o){Ot.encode(d,o.header),e.fixed32.encode(d,o.key),Bt.encode(d,o.label)},decode:d=>({header:Ot.decode(d),key:e.fixed32.decode(d),label:Bt.decode(d)})},Ut={preencode(d,o){Bt.preencode(d,o.label),e.uint.preencode(d,o.count)},encode(d,o){Bt.encode(d,o.label),e.uint.encode(d,o.count)},decode:d=>({label:Bt.decode(d),count:e.uint.decode(d)})},Jt=e.array(e.frame(Ut)),Wt={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.total),Jt.preencode(d,o.labels),e.uint.preencode(d,o.editedAt),e.uint.preencode(d,o.flagsClock)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.total),Jt.encode(d,o.labels),e.uint.encode(d,o.editedAt),e.uint.encode(d,o.flagsClock)},decode:d=>({key:e.fixed32.decode(d),total:e.uint.decode(d),labels:Jt.decode(d),editedAt:e.uint.decode(d),flagsClock:e.uint.decode(d)})},Gt={preencode(d,o){e.float64.preencode(d,o.latitude),e.float64.preencode(d,o.longitude)},encode(d,o){e.float64.encode(d,o.latitude),e.float64.encode(d,o.longitude)},decode:d=>({latitude:e.float64.decode(d),longitude:e.float64.decode(d)})},Qt=$,Xt={preencode(d,o){Qt.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.fromDeviceKey)},encode(d,o){Qt.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.fromDeviceKey)},decode:d=>({header:Qt.decode(d),deviceKey:e.fixed32.decode(d),fromDeviceKey:e.fixed32.decode(d)})},Yt=$,Zt=X,$t={preencode(o,n){Yt.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),e.buffer.preencode(o,n.encryptionKey),o.end++,d>=28&&n.streams&&Zt.preencode(o,n.streams),d>=28&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=28&&n.version&&e.uint.preencode(o,n.version),d>=36&&n.streamInputs&&es.preencode(o,n.streamInputs),d>=36&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey)},encode(o,n){const c=(d>=28&&n.streams?1:0)|(d>=28&&n.discoveryKey?2:0)|(d>=28&&n.version?4:0)|(d>=36&&n.streamInputs?8:0)|(d>=36&&n.swarmKey?16:0);Yt.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,c),d>=28&&n.streams&&Zt.encode(o,n.streams),d>=28&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=28&&n.version&&e.uint.encode(o,n.version),d>=36&&n.streamInputs&&es.encode(o,n.streamInputs),d>=36&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey)},decode(o){const n=Yt.decode(o),c=e.fixed32.decode(o),r=e.buffer.decode(o),t=e.uint.decode(o);return{header:n,callKey:c,encryptionKey:r,streams:d>=28&&1&t?Zt.decode(o):null,discoveryKey:d>=28&&2&t?e.fixed32.decode(o):null,version:d>=28&&4&t?e.uint.decode(o):0,streamInputs:d>=36&&8&t?es.decode(o):null,swarmKey:d>=36&&16&t?e.fixed32.decode(o):null}}},_t=$,ei=X,di={preencode(o,n){_t.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),o.end++,d>=28&&n.streams&&ei.preencode(o,n.streams),d>=36&&n.streamInputs&&ds.preencode(o,n.streamInputs),d>=36&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey)},encode(o,n){const c=(d>=28&&n.streams?1:0)|(d>=36&&n.streamInputs?2:0)|(d>=36&&n.swarmKey?4:0);_t.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.uint.encode(o,c),d>=28&&n.streams&&ei.encode(o,n.streams),d>=36&&n.streamInputs&&ds.encode(o,n.streamInputs),d>=36&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey)},decode(o){const n=_t.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{header:n,callKey:c,streams:d>=28&&1&r?ei.decode(o):null,streamInputs:d>=36&&2&r?ds.decode(o):null,swarmKey:d>=36&&4&r?e.fixed32.decode(o):null}}},oi=$,ni={preencode(d,o){oi.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){oi.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:oi.decode(d),callKey:e.fixed32.decode(d)})},ci=$,ri={preencode(d,o){ci.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){ci.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:ci.decode(d),callKey:e.fixed32.decode(d)})},ti=$,ii={preencode(o,n){ti.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.streamKey),o.end++,d>=36&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=36&&n.type&&e.string.preencode(o,n.type)},encode(o,n){const c=(d>=36&&n.mediaStreamId?1:0)|(d>=36&&n.type?2:0)|(d>=36&&n.muted?4:0);ti.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.streamKey),e.uint.encode(o,c),d>=36&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=36&&n.type&&e.string.encode(o,n.type)},decode(o){const n=ti.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=o.start<o.end?e.uint.decode(o):0;return{header:n,callKey:c,streamKey:r,mediaStreamId:d>=36&&1&t?e.string.decode(o):null,type:d>=36&&2&t?e.string.decode(o):null,muted:d>=36&&!!(4&t)}}},ai=$,si={preencode(d,o){ai.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.streamKey)},encode(d,o){ai.encode(d,o.header),e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.streamKey)},decode:d=>({header:ai.decode(d),callKey:e.fixed32.decode(d),streamKey:e.fixed32.decode(d)})},pi={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.buffer.preencode(o,n.encryptionKey),e.uint.preencode(o,n.createdAt),o.end++,d>=28&&n.endedAt&&e.uint.preencode(o,n.endedAt),d>=28&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=28&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(d>=28&&n.endedAt?1:0)|(d>=28&&n.discoveryKey?2:0)|(d>=28&&n.version?4:0);e.fixed32.encode(o,n.callKey),e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=28&&n.endedAt&&e.uint.encode(o,n.endedAt),d>=28&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=28&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=e.fixed32.decode(o),c=e.buffer.decode(o),r=e.uint.decode(o),t=e.uint.decode(o);return{callKey:n,encryptionKey:c,createdAt:r,endedAt:d>=28&&1&t?e.uint.decode(o):0,discoveryKey:d>=28&&2&t?e.fixed32.decode(o):null,version:d>=28&&4&t?e.uint.decode(o):0}}},li={preencode(d,o){e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.createdAt)},encode(d,o){e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.createdAt)},decode:d=>({callKey:e.fixed32.decode(d),memberKey:e.fixed32.decode(d),createdAt:e.uint.decode(d)})},ui={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.deviceKey),e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.createdAt),o.end++,d>=28&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),d>=32&&n.lastHeartbeatAt&&e.uint.preencode(o,n.lastHeartbeatAt)},encode(o,n){const c=(d>=28&&n.swarmKey?1:0)|(d>=32&&n.lastHeartbeatAt?2:0)|(d>=33&&n.isRecording?4:0);e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.deviceKey),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=28&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey),d>=32&&n.lastHeartbeatAt&&e.uint.encode(o,n.lastHeartbeatAt)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o),i=e.uint.decode(o);return{callKey:n,deviceKey:c,memberKey:r,createdAt:t,swarmKey:d>=28&&1&i?e.fixed32.decode(o):null,lastHeartbeatAt:d>=32&&2&i?e.uint.decode(o):0,isRecording:d>=33&&!!(4&i)}}},fi={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.deviceKey),e.buffer.preencode(o,n.streamKey),e.uint.preencode(o,n.createdAt),o.end++,d>=36&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=36&&n.type&&e.string.preencode(o,n.type),d>=36&&n.statusKey&&e.uint.preencode(o,n.statusKey)},encode(o,n){const c=(d>=36&&n.mediaStreamId?1:0)|(d>=36&&n.type?2:0)|(d>=36&&n.statusKey?4:0);e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.deviceKey),e.buffer.encode(o,n.streamKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=36&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=36&&n.type&&e.string.encode(o,n.type),d>=36&&n.statusKey&&e.uint.encode(o,n.statusKey)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.buffer.decode(o),t=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{callKey:n,deviceKey:c,streamKey:r,createdAt:t,mediaStreamId:d>=36&&1&i?e.string.decode(o):null,type:d>=36&&2&i?e.string.decode(o):null,statusKey:d>=36&&4&i?e.uint.decode(o):0}}},mi={preencode(o,n){e.fixed32.preencode(o,n.callKey),o.end++,d>=28&&n.selfDeviceKey&&e.fixed32.preencode(o,n.selfDeviceKey),d>=36&&n.createdAt&&e.uint.preencode(o,n.createdAt)},encode(o,n){const c=(d>=28&&n.selfDeviceKey?1:0)|(d>=36&&n.createdAt?2:0);e.fixed32.encode(o,n.callKey),e.uint.encode(o,c),d>=28&&n.selfDeviceKey&&e.fixed32.encode(o,n.selfDeviceKey),d>=36&&n.createdAt&&e.uint.encode(o,n.createdAt)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o);return{callKey:n,selfDeviceKey:d>=28&&1&c?e.fixed32.decode(o):null,createdAt:d>=36&&2&c?e.uint.decode(o):0}}},yi={preencode(d,o){e.uint.preencode(d,o.lastCleared)},encode(d,o){e.uint.encode(d,o.lastCleared)},decode:d=>({lastCleared:e.uint.decode(d)})},bi={Nightly:"Nightly",Internal:"Internal",Production:"Production"},xi={preencode(e,d){e.end++},encode(d,o){switch(o){case"Nightly":e.uint.encode(d,1);break;case"Internal":e.uint.encode(d,2);break;case"Production":e.uint.encode(d,3);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"Nightly";case 2:return"Internal";case 3:return"Production";default:return null}}},vi=$,ki={preencode(e,d){vi.preencode(e,d.header)},encode(e,d){vi.encode(e,d.header)},decode:e=>({header:vi.decode(e)})},gi=$,Ki={preencode(e,d){gi.preencode(e,d.header)},encode(e,d){gi.encode(e,d.header)},decode:e=>({header:gi.decode(e)})},hi={preencode(o,n){xi.preencode(o,n.buildType),o.end++,d>=30&&n.latestOfflineAbi&&e.uint.preencode(o,n.latestOfflineAbi)},encode(o,n){const c=d>=30&&n.latestOfflineAbi?1:0;xi.encode(o,n.buildType),e.uint.encode(o,c),d>=30&&n.latestOfflineAbi&&e.uint.encode(o,n.latestOfflineAbi)},decode(o){const n=xi.decode(o),c=o.start<o.end?e.uint.decode(o):0;return{buildType:n,latestOfflineAbi:d>=30&&1&c?e.uint.decode(o):0}}},wi=$,Pi={preencode(d,o){wi.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),e.buffer.preencode(d,o.deviceProof),e.buffer.preencode(d,o.writerProof)},encode(d,o){wi.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.buffer.encode(d,o.deviceProof),e.buffer.encode(d,o.writerProof)},decode:d=>({header:wi.decode(d),deviceKey:e.fixed32.decode(d),deviceProof:e.buffer.decode(d),writerProof:e.buffer.decode(d)})},Ti={preencode(o,n){o.end++,d>=31&&n.otaResyncPrivateProfileBump&&e.uint.preencode(o,n.otaResyncPrivateProfileBump)},encode(o,n){const c=d>=31&&n.otaResyncPrivateProfileBump?1:0;e.uint.encode(o,c),d>=31&&n.otaResyncPrivateProfileBump&&e.uint.encode(o,n.otaResyncPrivateProfileBump)},decode(o){const n=e.uint.decode(o);return{otaResyncPrivateProfileBump:d>=31&&1&n?e.uint.decode(o):0}}},Ri={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.buffer.preencode(d,o.proof),e.uint.preencode(d,o.createdAt)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.buffer.encode(d,o.proof),e.uint.encode(d,o.createdAt)},decode:d=>({deviceKey:e.fixed32.decode(d),proof:e.buffer.decode(d),createdAt:e.uint.decode(d)})},Ai=$,Si={preencode(d,o){Ai.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Ai.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Ai.decode(d),callKey:e.fixed32.decode(d)})},Ii=$,Fi={preencode(d,o){Ii.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.deviceKey)},encode(d,o){Ii.encode(d,o.header),e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.deviceKey)},decode:d=>({header:Ii.decode(d),callKey:e.fixed32.decode(d),deviceKey:e.fixed32.decode(d)})},Mi=e.frame(ht),Ci=e.array(e.frame(yt)),Vi={preencode(e,d){Mi.preencode(e,d.digest),Ci.preencode(e,d.mine)},encode(e,d){Mi.encode(e,d.digest),Ci.encode(e,d.mine)},decode:e=>({digest:Mi.decode(e),mine:Ci.decode(e)})},Hi=$,Di={preencode(d,o){Hi.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Hi.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Hi.decode(d),callKey:e.fixed32.decode(d)})},Li=$,qi={preencode(d,o){Li.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Li.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Li.decode(d),callKey:e.fixed32.decode(d)})},ji={preencode(o,n){o.end++,d>=33&&n.profileSnoozeTime&&e.uint.preencode(o,n.profileSnoozeTime)},encode(o,n){const c=(d>=33&&n.disableReadReceipts?1:0)|(d>=33&&n.stripAttachmentMetadata?2:0)|(d>=33&&n.profileSnoozeTime?4:0);e.uint.encode(o,c),d>=33&&n.profileSnoozeTime&&e.uint.encode(o,n.profileSnoozeTime)},decode(o){const n=e.uint.decode(o);return{disableReadReceipts:d>=33&&!!(1&n),stripAttachmentMetadata:d>=33&&!!(2&n),profileSnoozeTime:d>=33&&4&n?e.uint.decode(o):0}}},Ei={preencode(o,n){o.end++,d>=33&&n.maxPeers&&e.uint.preencode(o,n.maxPeers)},encode(o,n){const c=d>=33&&n.maxPeers?1:0;e.uint.encode(o,c),d>=33&&n.maxPeers&&e.uint.encode(o,n.maxPeers)},decode(o){const n=e.uint.decode(o);return{maxPeers:d>=33&&1&n?e.uint.decode(o):0}}},Bi=$,zi={preencode(e,d){Bi.preencode(e,d.header),n.preencode(e,d.oplog)},encode(e,d){Bi.encode(e,d.header),n.encode(e,d.oplog)},decode:e=>({header:Bi.decode(e),oplog:n.decode(e)})},Oi=$,Ni={preencode(e,d){Oi.preencode(e,d.header)},encode(e,d){Oi.encode(e,d.header)},decode:e=>({header:Oi.decode(e)})},Ui={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.timestamp)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.timestamp)},decode:d=>({memberKey:e.fixed32.decode(d),timestamp:e.uint.decode(d)})},Ji=$,Wi={preencode(o,n){Ji.preencode(o,n.header),e.fixed32.preencode(o,n.memberKey),o.end++,d>=34&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=d>=34&&n.alias?1:0;Ji.encode(o,n.header),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,c),d>=34&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=Ji.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{header:n,memberKey:c,alias:d>=34&&1&r?e.string.decode(o):null}}},Gi={preencode(d,o){e.uint.preencode(d,o.streams)},encode(d,o){e.uint.encode(d,o.streams)},decode:d=>({streams:e.uint.decode(d)})},Qi={preencode(d,o){e.fixed32.preencode(d,o.streamKey),e.string.preencode(d,o.mediaStreamId),e.string.preencode(d,o.type),d.end++},encode(o,n){const c=d>=36&&n.muted?1:0;e.fixed32.encode(o,n.streamKey),e.string.encode(o,n.mediaStreamId),e.string.encode(o,n.type),e.uint.encode(o,c)},decode(o){const n=e.fixed32.decode(o),c=e.string.decode(o),r=e.string.decode(o),t=e.uint.decode(o);return{streamKey:n,mediaStreamId:c,type:r,muted:d>=36&&!!(1&t)}}},Xi=$,Yi={preencode(d,o){Xi.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.streamKey),d.end++},encode(o,n){const c=d>=36&&n.muted?1:0;Xi.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.streamKey),e.uint.encode(o,c)},decode(o){const n=Xi.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o);return{header:n,callKey:c,streamKey:r,muted:d>=36&&!!(1&t)}}},Zi={preencode(d,o){e.uint.preencode(d,o.statusKey),d.end++},encode(o,n){const c=d>=36&&n.muted?1:0;e.uint.encode(o,n.statusKey),e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o),c=e.uint.decode(o);return{statusKey:n,muted:d>=36&&!!(1&c)}}},$i={preencode(n,c){e.fixed32.preencode(n,c.key),n.end++,d>=37&&c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),d>=37&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=(d>=37&&c.encryptionKey?1:0)|(d>=37&&c.bootFrom?2:0);e.fixed32.encode(n,c.key),e.uint.encode(n,r),d>=37&&c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),d>=37&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.uint.decode(n);return{key:c,encryptionKey:d>=37&&1&r?e.buffer.decode(n):null,bootFrom:d>=37&&2&r?o.decode(n):null}}},_i={preencode(d,o){e.fixed32.preencode(d,o.hash)},encode(d,o){e.fixed32.encode(d,o.hash)},decode:d=>({hash:e.fixed32.decode(d)})},ea={preencode(d,o){e.fixed32.preencode(d,o.hash),e.buffer.preencode(d,o.data)},encode(d,o){e.fixed32.encode(d,o.hash),e.buffer.encode(d,o.data)},decode:d=>({hash:e.fixed32.decode(d),data:e.buffer.decode(d)})},da={preencode(n,c){o.preencode(n,c.autobeeMigrationHead),n.end++,d>=37&&c.legacyViewHead&&o.preencode(n,c.legacyViewHead),d>=37&&c.dbViewHead&&o.preencode(n,c.dbViewHead),d>=37&&c.blobsViewHead&&o.preencode(n,c.blobsViewHead),e.uint.preencode(n,c.createdAt)},encode(n,c){const r=(d>=37&&c.legacyViewHead?1:0)|(d>=37&&c.dbViewHead?2:0)|(d>=37&&c.blobsViewHead?4:0);o.encode(n,c.autobeeMigrationHead),e.uint.encode(n,r),d>=37&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=37&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=37&&c.blobsViewHead&&o.encode(n,c.blobsViewHead),e.uint.encode(n,c.createdAt)},decode(n){const c=o.decode(n),r=e.uint.decode(n);return{autobeeMigrationHead:c,legacyViewHead:d>=37&&1&r?o.decode(n):null,dbViewHead:d>=37&&2&r?o.decode(n):null,blobsViewHead:d>=37&&4&r?o.decode(n):null,createdAt:e.uint.decode(n)}}},oa=$,na={preencode(e,n){oa.preencode(e,n.header),o.preencode(e,n.head),e.end++,d>=37&&n.legacyViewHead&&o.preencode(e,n.legacyViewHead),d>=37&&n.dbViewHead&&o.preencode(e,n.dbViewHead),d>=37&&n.blobsViewHead&&o.preencode(e,n.blobsViewHead)},encode(n,c){const r=(d>=37&&c.legacyViewHead?1:0)|(d>=37&&c.dbViewHead?2:0)|(d>=37&&c.blobsViewHead?4:0);oa.encode(n,c.header),o.encode(n,c.head),e.uint.encode(n,r),d>=37&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=37&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=37&&c.blobsViewHead&&o.encode(n,c.blobsViewHead)},decode(n){const c=oa.decode(n),r=o.decode(n),t=e.uint.decode(n);return{header:c,head:r,legacyViewHead:d>=37&&1&t?o.decode(n):null,dbViewHead:d>=37&&2&t?o.decode(n):null,blobsViewHead:d>=37&&4&t?o.decode(n):null}}},ca={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.fixed32.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.seed),n.end++,d>=37&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=d>=37&&c.bootFrom?1:0;e.fixed32.encode(n,c.roomKey),e.fixed32.encode(n,c.encryptionKey),e.fixed32.encode(n,c.seed),e.uint.encode(n,r),d>=37&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.fixed32.decode(n),t=e.fixed32.decode(n),i=e.uint.decode(n);return{roomKey:c,encryptionKey:r,seed:t,bootFrom:d>=37&&1&i?o.decode(n):null}}},ra=id,ta={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.fixed32.preencode(d,o.deviceKey),e.uint.preencode(d,o.deviceLength),e.uint.preencode(d,o.clock),ra.preencode(d,o.status)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,o.deviceLength),e.uint.encode(d,o.clock),ra.encode(d,o.status)},decode:d=>({memberKey:e.fixed32.decode(d),deviceKey:e.fixed32.decode(d),deviceLength:e.uint.decode(d),clock:e.uint.decode(d),status:ra.decode(d)})},ia={preencode(d,o){e.fixed32.preencode(d,o.hash),e.buffer.preencode(d,o.blob)},encode(d,o){e.fixed32.encode(d,o.hash),e.buffer.encode(d,o.blob)},decode:d=>({hash:e.fixed32.decode(d),blob:e.buffer.decode(d)})},aa=Fn,sa=Mn,pa=kn,la={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),aa.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,d>=37&&c.initiator&&o.preencode(n,c.initiator),d>=37&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=37&&c.identitySwap&&sa.preencode(n,c.identitySwap),d>=37&&c.identitySwapV2&&pa.preencode(n,c.identitySwapV2),d>=37&&c.contact&&e.fixed32.preencode(n,c.contact)},encode(n,c){const r=(d>=37&&c.initiator?1:0)|(d>=37&&c.bootFrom?2:0)|(d>=37&&c.identitySwap?4:0)|(d>=37&&c.identitySwapV2?8:0)|(d>=37&&c.contact?16:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),aa.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,r),d>=37&&c.initiator&&o.encode(n,c.initiator),d>=37&&c.bootFrom&&o.encode(n,c.bootFrom),d>=37&&c.identitySwap&&sa.encode(n,c.identitySwap),d>=37&&c.identitySwapV2&&pa.encode(n,c.identitySwapV2),d>=37&&c.contact&&e.fixed32.encode(n,c.contact)},decode(n){const c=e.fixed32.decode(n),r=e.buffer.decode(n),t=e.fixed32.decode(n),i=aa.decode(n),a=e.uint.decode(n),s=e.uint.decode(n);return{roomKey:c,encryptionKey:r,mailbox:t,status:i,clock:a,initiator:d>=37&&1&s?o.decode(n):null,bootFrom:d>=37&&2&s?o.decode(n):null,identitySwap:d>=37&&4&s?sa.decode(n):null,identitySwapV2:d>=37&&8&s?pa.decode(n):null,contact:d>=37&&16&s?e.fixed32.decode(n):null}}},ua=$,fa={preencode(n,c){ua.preencode(n,c.header),e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),n.end++,d>=37&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=37&&c.initiator&&o.preencode(n,c.initiator),d>=37&&c.dm&&e.fixed32.preencode(n,c.dm)},encode(n,c){const r=(d>=37&&c.bootFrom?1:0)|(d>=37&&c.initiator?2:0)|(d>=37&&c.dm?4:0)|(d>=37&&c.isReadOnly?8:0);ua.encode(n,c.header),e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),e.uint.encode(n,r),d>=37&&c.bootFrom&&o.encode(n,c.bootFrom),d>=37&&c.initiator&&o.encode(n,c.initiator),d>=37&&c.dm&&e.fixed32.encode(n,c.dm)},decode(n){const c=ua.decode(n),r=e.fixed32.decode(n),t=e.buffer.decode(n),i=e.fixed32.decode(n),a=e.uint.decode(n);return{header:c,roomKey:r,encryptionKey:t,mailbox:i,bootFrom:d>=37&&1&a?o.decode(n):null,initiator:d>=37&&2&a?o.decode(n):null,dm:d>=37&&4&a?e.fixed32.decode(n):null,isReadOnly:d>=37&&!!(8&a)}}},ma={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),n.end++,d>=37&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=37&&c.initiator&&o.preencode(n,c.initiator)},encode(n,c){const r=(d>=37&&c.bootFrom?1:0)|(d>=37&&c.initiator?2:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.uint.encode(n,r),d>=37&&c.bootFrom&&o.encode(n,c.bootFrom),d>=37&&c.initiator&&o.encode(n,c.initiator)},decode(n){const c=e.fixed32.decode(n),r=e.buffer.decode(n),t=e.uint.decode(n);return{roomKey:c,encryptionKey:r,bootFrom:d>=37&&1&t?o.decode(n):null,initiator:d>=37&&2&t?o.decode(n):null}}},ya={preencode(d,o){e.fixed32.preencode(d,o.roomKey),os.preencode(d,o.head),e.uint.preencode(d,o.timestamp),d.end++},encode(o,n){const c=d>=37&&n.incremental?1:0;e.fixed32.encode(o,n.roomKey),os.encode(o,n.head),e.uint.encode(o,n.timestamp),e.uint.encode(o,c)},decode(o){const n=e.fixed32.decode(o),c=os.decode(o),r=e.uint.decode(o),t=e.uint.decode(o);return{roomKey:n,head:c,timestamp:r,incremental:d>=37&&!!(1&t)}}},ba={preencode(o,n){o.end++,d>=37&&n.key&&e.fixed32.preencode(o,n.key),e.uint.preencode(o,n.length)},encode(o,n){const c=d>=37&&n.key?1:0;e.uint.encode(o,c),d>=37&&n.key&&e.fixed32.encode(o,n.key),e.uint.encode(o,n.length)},decode(o){const n=e.uint.decode(o);return{key:d>=37&&1&n?e.fixed32.decode(o):null,length:e.uint.decode(o)}}},xa={preencode(n,c){e.fixed32.preencode(n,c.roomKey),n.end++,d>=37&&c.legacyViewHead&&o.preencode(n,c.legacyViewHead),d>=37&&c.dbViewHead&&o.preencode(n,c.dbViewHead),d>=37&&c.blobsViewHead&&o.preencode(n,c.blobsViewHead),d>=37&&c.autobeeMigrationHead&&o.preencode(n,c.autobeeMigrationHead)},encode(n,c){const r=(d>=37&&c.legacyViewHead?1:0)|(d>=37&&c.dbViewHead?2:0)|(d>=37&&c.blobsViewHead?4:0)|(d>=37&&c.autobeeMigrationHead?8:0);e.fixed32.encode(n,c.roomKey),e.uint.encode(n,r),d>=37&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=37&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=37&&c.blobsViewHead&&o.encode(n,c.blobsViewHead),d>=37&&c.autobeeMigrationHead&&o.encode(n,c.autobeeMigrationHead)},decode(n){const c=e.fixed32.decode(n),r=e.uint.decode(n);return{roomKey:c,legacyViewHead:d>=37&&1&r?o.decode(n):null,dbViewHead:d>=37&&2&r?o.decode(n):null,blobsViewHead:d>=37&&4&r?o.decode(n):null,autobeeMigrationHead:d>=37&&8&r?o.decode(n):null}}},va={preencode(d,o){e.fixed32.preencode(d,o.id),e.fixed32.preencode(d,o.writerKey),e.buffer.preencode(d,o.blindResponse)},encode(d,o){e.fixed32.encode(d,o.id),e.fixed32.encode(d,o.writerKey),e.buffer.encode(d,o.blindResponse)},decode:d=>({id:e.fixed32.decode(d),writerKey:e.fixed32.decode(d),blindResponse:e.buffer.decode(d)})},ka=$,ga={preencode(d,o){ka.preencode(d,o.header),e.buffer.preencode(d,o.blindResponse)},encode(d,o){ka.encode(d,o.header),e.buffer.encode(d,o.blindResponse)},decode:d=>({header:ka.decode(d),blindResponse:e.buffer.decode(d)})},Ka=e.frame(Ac),ha={preencode(o,n){e.string.preencode(o,n.mnemonic),o.end++,d>=39&&n.profileDiscoveryTimeout&&e.uint.preencode(o,n.profileDiscoveryTimeout),d>=39&&n.privateProfileKey&&e.fixed32.preencode(o,n.privateProfileKey),d>=39&&n.identity&&Ka.preencode(o,n.identity)},encode(o,n){const c=(d>=39&&n.profileDiscoveryTimeout?1:0)|(d>=39&&n.privateProfileKey?2:0)|(d>=39&&n.identity?4:0);e.string.encode(o,n.mnemonic),e.uint.encode(o,c),d>=39&&n.profileDiscoveryTimeout&&e.uint.encode(o,n.profileDiscoveryTimeout),d>=39&&n.privateProfileKey&&e.fixed32.encode(o,n.privateProfileKey),d>=39&&n.identity&&Ka.encode(o,n.identity)},decode(o){const n=e.string.decode(o),c=e.uint.decode(o);return{mnemonic:n,profileDiscoveryTimeout:d>=39&&1&c?e.uint.decode(o):0,privateProfileKey:d>=39&&2&c?e.fixed32.decode(o):null,identity:d>=39&&4&c?Ka.decode(o):null}}},wa=e.frame(w),Pa=e.frame(Gi),Ta=wa,Ra=e.array(ct),Aa=e.frame(se),Sa=wa,Ia=Aa,Fa=e.frame(Lr),Ma=e.frame(ca),Ca=Aa,Va=e.frame(fd),Ha=e.frame(Fr),Da=e.frame(Gt),La=Da,qa=e.array(e.frame(tt)),ja=wa,Ea=e.frame(zn),Ba=e.frame(Cr),za=Ea,Oa=Ba,Na=Ea,Ua=Ba,Ja=e.frame(qr),Wa=Ba,Ga=e.array(e.frame(Tt)),Qa=e.frame(mi),Xa=e.frame(Vi),Ya=e.frame(ji),Za=e.frame(ba),$a=Za,_a=wa,es=e.array(e.frame(Qi)),ds=es,os=Za;function ns(e){switch(e){case"@keet/head":return o;case"@keet/oplog-id":return n;case"@keet/encryption-keypair":return c;case"@keet/signing-keypair":return r;case"@keet/room-keys":return t;case"@keet/operation-header":return i;case"@keet/blob-pointer":return a;case"@keet/file-dimensions":return s;case"@keet/file-metadata":return l;case"@keet/external-drive-pointer":return u;case"@keet/external-blob-pointer":return f;case"@keet/file-pointer":return b;case"@keet/file":return k;case"@keet/image-file":return w;case"@keet/file-status":return P;case"@keet/file-record":return A;case"@keet/device-status":return S;case"@keet/member-status":return I;case"@keet/member-moderation-status":return F;case"@keet/abi":return M;case"@keet/device-stats":return C;case"@keet/member-stats":return V;case"@keet/chat-stats":return H;case"@keet/file-stats":return D;case"@keet/stats":return B;case"@keet/room-type":return O;case"@keet/system-settings":return N;case"@keet/system-digest":return W;case"@keet/room-seed":return G;case"@keet/room-capabilities":return Q;case"@keet/room-config":return Y;case"@keet/blind-peer":return Z;case"@keet/add-blind-peer-operation":return ee;case"@keet/remove-blind-peer-operation":return oe;case"@keet/identity-attestation":return ne;case"@keet/device-invitation":return ce;case"@keet/device":return ie;case"@keet/member-profile":return ae;case"@keet/device-profile":return se;case"@keet/member-update":return le;case"@keet/device-update":return ue;case"@keet/signed-pairing-data":return fe;case"@keet/device-request-identity":return me;case"@keet/device-response-identity":return ye;case"@keet/device-request-with-invitation":return ke;case"@keet/device-request-with-invitation-and-proof":return Ke;case"@keet/device-request-with-member-proof":return Pe;case"@keet/device-request":return Ae;case"@keet/device-response":return Fe;case"@keet/invitation-metadata":return Me;case"@keet/invitation":return He;case"@keet/add-invitation-operation":return qe;case"@keet/remove-invitation-operation":return Ee;case"@keet/sendable-room-invitation":return Be;case"@keet/sendable-identity-invitation":return ze;case"@keet/sendable-contact-invitation":return Oe;case"@keet/sendable-invitation":return Ge;case"@keet/add-device-operation":return Xe;case"@keet/update-device-operation":return Ze;case"@keet/start-indexing-operation":return $e;case"@keet/stop-indexing-operation":return _e;case"@keet/join-request":return dd;case"@keet/accept-join-request-operation":return cd;case"@keet/reject-join-request-operation":return td;case"@keet/member":return sd;case"@keet/full-member":return ud;case"@keet/member-proofs":return fd;case"@keet/update-member-operation":return bd;case"@keet/change-member-status-operation":return kd;case"@keet/change-member-role-operation":return Kd;case"@keet/remove-member-operation":return wd;case"@keet/member-activity":return Pd;case"@keet/member-joined-event":return Td;case"@keet/member-left-event":return Rd;case"@keet/title-changed-chat-event":return Ad;case"@keet/chat-event":return Md;case"@keet/sendable-event":return Cd;case"@keet/display-range":return Vd;case"@keet/display-content-range":return Dd;case"@keet/mention-display-item":return qd;case"@keet/link-preview":return Bd;case"@keet/display-link-item":return Nd;case"@keet/display":return _d;case"@keet/oplog-message":return co;case"@keet/index-message":return io;case"@keet/full-index-message":return po;case"@keet/message-status":return lo;case"@keet/message-index-id":return uo;case"@keet/thread":return mo;case"@keet/chat-message-record":return vo;case"@keet/full-chat-message-record":return ho;case"@keet/add-chat-message-operation":return To;case"@keet/remove-chat-message-operation":return Ao;case"@keet/update-chat-message-operation":return Fo;case"@keet/pin-chat-message-operation":return Co;case"@keet/reaction":return Vo;case"@keet/reactions-summary":return Ho;case"@keet/reactions-digest":return Lo;case"@keet/add-reaction-operation":return jo;case"@keet/remove-reaction-operation":return Bo;case"@keet/update-room-config-operation":return No;case"@keet/group-member":return Uo;case"@keet/user-registry-info":return Jo;case"@keet/room-identity":return Go;case"@keet/genesis-operation":return dn;case"@keet/upgrade-operation":return nn;case"@keet/update-system-settings-operation":return tn;case"@keet-private-id/contact":return an;case"@keet-private-id/v3-room-migration-info":return sn;case"@keet-private-id/run-v3-migration-operation":return un;case"@keet-private-id/update-identity-operation":return mn;case"@keet-private-id/counters":return yn;case"@keet-private-id/stats":return bn;case"@keet-private-id/add-entropy-operation":return xn;case"@keet-private-id/pending-invitation-identity":return vn;case"@keet-private-id/pending-invitation":return gn;case"@keet-private-id/resolve-pending-invitation-operation":return hn;case"@keet-private-id/add-pending-invitation-operation":return Tn;case"@keet-private-id/remove-pending-invitation-operation":return An;case"@keet-private-id/identity-swap":return Sn;case"@keet-private-id/room-status":return In;case"@keet-private-id/room":return Vn;case"@keet-private-id/add-room-operation":return Dn;case"@keet-private-id/remove-room-operation":return qn;case"@keet-private-id/update-room-status-operation":return Bn;case"@keet-private-id/contact-status":return zn;case"@keet-private-id/contact-record":return On;case"@keet-private-id/add-contact-operation":return Jn;case"@keet-private-id/update-contact-status-operation":return Gn;case"@keet-private-id/remove-contact-operation":return Xn;case"@keet-private-id/contact-request-status":return Yn;case"@keet-private-id/contact-request-body":return _n;case"@keet-private-id/contact-request":return dc;case"@keet-private-id/contact-request-record":return rc;case"@keet-private-id/add-contact-request-operation":return ic;case"@keet-private-id/update-contact-request-status-operation":return pc;case"@keet-private-id/profile-discovery-record-v1":return lc;case"@keet-private-id/profile-discovery-record":return uc;case"@local/background-sync-room":return fc;case"@local/stats":return mc;case"@local/migration-status":return yc;case"@local/v3-private-profile-migration":return xc;case"@local/v3-room-migration":return gc;case"@local/room-migration-stats":return Kc;case"@local/room-migration":return wc;case"@local/identity-status":return Pc;case"@local/identity-record":return Ac;case"@local/tasks":return Ic;case"@local/room-keys":return Fc;case"@local/join-room-invitation-task":return Cc;case"@local/join-room-response-task":return Vc;case"@local/fast-forward-to":return Hc;case"@local/add-room-fields":return Dc;case"@local/join-room-keys-task":return qc;case"@local/create-room-task":return Ec;case"@local/leave-room-task":return Bc;case"@local/clear-room-task":return zc;case"@local/restore-identity-task":return Oc;case"@local/send-contact-request-task":return Nc;case"@local/migrate-v2-room-task":return Uc;case"@local/task":return er;case"@local/shared-invitation":return or;case"@local/room-status":return nr;case"@local/room-timestamps":return cr;case"@local/room":return vr;case"@local/room-preferences":return gr;case"@local/writer":return Kr;case"@local/member":return wr;case"@local/device":return Tr;case"@local/file":return Ar;case"@keet/add-file-preview-operation":return Ir;case"@keet/member-removed-event":return Fr;case"@keet/member-contact-info":return Cr;case"@keet/remove-device-operation":return Hr;case"@keet/device-identity":return Dr;case"@keet/readonly-room-invitation":return Lr;case"@keet-private-id/identity-swap-v2":return qr;case"@keet-private-id/activate-contact-room-operation":return Er;case"@local/identity-swap":return Br;case"@local/writer-append":return zr;case"@local/room-metadata":return Or;case"@local/debug-flag":return Nr;case"@local/debug":return Jr;case"@keet/display-type":return Gr;case"@keet/test-increment-operation":return Xr;case"@keet/test-collection-record-1":return Yr;case"@keet/migrate-abi-operation":return $r;case"@keet/system-settings-keys":return et;case"@local/hyperdht-record":return ot;case"@keet/room-supported-language":return ct;case"@keet/translation-display-item":return tt;case"@local/unread":return it;case"@keet-private-id/unreads":return at;case"@keet-private-id/add-unreads-key-operation":return pt;case"@keet-private-id/remove-unreads-key-operation":return ut;case"@keet/label-type":return mt;case"@keet/chat-label":return yt;case"@keet/add-chat-label-operation":return xt;case"@keet/remove-chat-label-operation":return kt;case"@keet/chat-label-summary":return gt;case"@keet/chat-label-digest":return ht;case"@keet/update-read-length-operation":return Pt;case"@keet/read-length":return Tt;case"@keet/tmp-removed-member":return Rt;case"@keet-private-id/settings":return At;case"@keet-private-id/user-settings-key":return It;case"@keet-private-id/update-settings-operation":return Ct;case"@local/error-record-details":return Vt;case"@local/error-record":return Dt;case"@local/keet-state":return qt;case"@local/file-stats":return jt;case"@keet/member-label-type":return Bt;case"@keet/member-label":return zt;case"@keet/add-member-label-operation":return Nt;case"@keet/member-label-summary":return Ut;case"@keet/member-label-digest":return Wt;case"@keet/location-shared-event":return Gt;case"@keet/move-indexer-operation":return Xt;case"@keet/start-call":return $t;case"@keet/join-call":return di;case"@keet/leave-call":return ni;case"@keet/end-call":return ri;case"@keet/add-call-stream":return ii;case"@keet/remove-call-stream":return si;case"@keet/call-record":return pi;case"@keet/call-member-record":return li;case"@keet/call-device-record":return ui;case"@keet/call-stream-record":return fi;case"@local/active-call":return mi;case"@local/file-gc-info":return yi;case"@keet/build-type":return xi;case"@keet/test-crash-operation":return ki;case"@keet/test-dispatch-error-operation":return Ki;case"@local/environment-record":return hi;case"@keet-private-id/shorten-device-attestation-operation":return Pi;case"@local/ota-actions":return Ti;case"@local/device-attestation":return Ri;case"@keet/call-device-heartbeat":return Si;case"@keet/remove-call-device":return Fi;case"@local/chat-labels":return Vi;case"@keet/start-call-recording":return Di;case"@keet/stop-call-recording":return qi;case"@local/settings":return ji;case"@local/hyperswarm-record":return Ei;case"@keet/dismiss-chat-reports-operation":return zi;case"@keet/update-typing-indicator-operation":return Ni;case"@keet/typing-indicator":return Ui;case"@keet-private-id/update-contact-alias-operation":return Wi;case"@keet/call-stats":return Gi;case"@keet/call-stream-input":return Qi;case"@keet/update-call-stream":return Yi;case"@keet/call-stream-status-record":return Zi;case"@keet/room-keys-v2":return $i;case"@keet/blob-pointer-v2":return _i;case"@keet/blob":return ea;case"@keet/autobee-migration":return da;case"@keet/autobee-migration-operation":return na;case"@keet/readonly-room-invitation-v2":return ca;case"@keet/admin-last-seen":return ta;case"@keet/blob-record":return ia;case"@keet-private-id/room-v2":return la;case"@keet-private-id/add-room-operation-v2":return fa;case"@local/room-keys/v2":return ma;case"@local/room-update":return ya;case"@local/view-head":return ba;case"@local/autobee-migration":return xa;case"@keet-private-id/pending-invitation-response":return va;case"@keet-private-id/resolve-pending-invitation-operation-v2":return ga;case"@local/pending-recovery":return ha;default:throw new Error("Encoder not found "+e)}}function cs(e,o=39){const n=ns(e);return{preencode(e,c){d=o,n.preencode(e,c)},encode(e,c){d=o,n.encode(e,c)},decode:e=>(d=o,n.decode(e))}}const rs=cs;module.exports={resolveStruct:rs,getStruct:cs,getEnum:function(e){switch(e){case"@keet/room-type":return z;case"@local/tasks":return Sc;case"@keet/display-type":return Wr;case"@keet/system-settings-keys":return _r;case"@keet/room-supported-language":return nt;case"@keet/label-type":return ft;case"@keet-private-id/user-settings-key":return St;case"@local/keet-state":return Lt;case"@keet/member-label-type":return Et;case"@keet/build-type":return bi;default:throw new Error("Enum not found "+e)}},getEncoding:ns,encode:function(o,n,c=39){return d=c,e.encode(ns(o),n)},decode:function(o,n,c=39){return d=c,e.decode(ns(o),n)},setVersion:function(e){d=e},version:d};
1const{c:e}=require("hyperschema/runtime");let d=41;const o={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.length)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.length)},decode:d=>({key:e.fixed32.decode(d),length:e.uint.decode(d)})},n={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.seq)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.seq)},decode:d=>({key:e.fixed32.decode(d),seq:e.uint.decode(d)})},c={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.secretKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.secretKey)},decode:d=>({publicKey:e.fixed32.decode(d),secretKey:e.fixed32.decode(d)})},r={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed64.preencode(d,o.secretKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed64.encode(d,o.secretKey)},decode:d=>({publicKey:e.fixed32.decode(d),secretKey:e.fixed64.decode(d)})},t={preencode(n,c){e.fixed32.preencode(n,c.key),n.end++,c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),d>=37&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=(c.encryptionKey?1:0)|(c.fastForwardTo?2:0)|(d>=37&&c.bootFrom?4:0);e.fixed32.encode(n,c.key),e.uint.encode(n,r),c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),d>=37&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.uint.decode(n);return{key:c,encryptionKey:1&r?e.buffer.decode(n):null,fastForwardTo:2&r?e.fixed32.decode(n):null,bootFrom:d>=37&&4&r?o.decode(n):null}}},i={preencode(d,o){e.uint.preencode(d,o.timestamp)},encode(d,o){e.uint.encode(d,o.timestamp)},decode:d=>({timestamp:e.uint.decode(d)})},a={preencode(d,o){e.uint.preencode(d,o.blockOffset),e.uint.preencode(d,o.blockLength),e.uint.preencode(d,o.byteOffset),e.uint.preencode(d,o.byteLength)},encode(d,o){e.uint.encode(d,o.blockOffset),e.uint.encode(d,o.blockLength),e.uint.encode(d,o.byteOffset),e.uint.encode(d,o.byteLength)},decode:d=>({blockOffset:e.uint.decode(d),blockLength:e.uint.decode(d),byteOffset:e.uint.decode(d),byteLength:e.uint.decode(d)})},s={preencode(d,o){e.uint.preencode(d,o.width),e.uint.preencode(d,o.height)},encode(d,o){e.uint.encode(d,o.width),e.uint.encode(d,o.height)},decode:d=>({width:e.uint.decode(d),height:e.uint.decode(d)})},p=e.frame(s),l={preencode(d,o){d.end++,o.name&&e.string.preencode(d,o.name),o.mimetype&&e.string.preencode(d,o.mimetype),o.dimensions&&p.preencode(d,o.dimensions),o.userdata&&e.buffer.preencode(d,o.userdata),o.duration&&e.uint.preencode(d,o.duration)},encode(d,o){const n=(o.name?1:0)|(o.mimetype?2:0)|(o.dimensions?4:0)|(o.userdata?8:0)|(o.duration?16:0)|(o.isPreview?32:0);e.uint.encode(d,n),o.name&&e.string.encode(d,o.name),o.mimetype&&e.string.encode(d,o.mimetype),o.dimensions&&p.encode(d,o.dimensions),o.userdata&&e.buffer.encode(d,o.userdata),o.duration&&e.uint.encode(d,o.duration)},decode(d){const o=e.uint.decode(d);return{name:1&o?e.string.decode(d):null,mimetype:2&o?e.string.decode(d):null,dimensions:4&o?p.decode(d):null,userdata:8&o?e.buffer.decode(d):null,duration:16&o?e.uint.decode(d):0,isPreview:!!(32&o)}}},u={preencode(d,o){e.fixed32.preencode(d,o.key),e.string.preencode(d,o.path),e.uint.preencode(d,o.version),e.uint.preencode(d,o.size)},encode(d,o){e.fixed32.encode(d,o.key),e.string.encode(d,o.path),e.uint.encode(d,o.version),e.uint.encode(d,o.size)},decode:d=>({key:e.fixed32.decode(d),path:e.string.decode(d),version:e.uint.decode(d),size:e.uint.decode(d)})},f={preencode(d,o){e.fixed32.preencode(d,o.key),a.preencode(d,o.blob)},encode(d,o){e.fixed32.encode(d,o.key),a.encode(d,o.blob)},decode:d=>({key:e.fixed32.decode(d),blob:a.decode(d)})},m=e.frame(f),y=e.frame(u),b={preencode(o,n){o.end++,n.inlined&&e.buffer.preencode(o,n.inlined),n.blob&&a.preencode(o,n.blob),n.externalBlob&&m.preencode(o,n.externalBlob),n.externalDrive&&y.preencode(o,n.externalDrive),d>=37&&n.bee&&_i.preencode(o,n.bee)},encode(o,n){const c=(n.inlined?1:0)|(n.blob?2:0)|(n.externalBlob?4:0)|(n.externalDrive?8:0)|(d>=37&&n.bee?16:0);e.uint.encode(o,c),n.inlined&&e.buffer.encode(o,n.inlined),n.blob&&a.encode(o,n.blob),n.externalBlob&&m.encode(o,n.externalBlob),n.externalDrive&&y.encode(o,n.externalDrive),d>=37&&n.bee&&_i.encode(o,n.bee)},decode(o){const n=e.uint.decode(o);return{inlined:1&n?e.buffer.decode(o):null,blob:2&n?a.decode(o):null,externalBlob:4&n?m.decode(o):null,externalDrive:8&n?y.decode(o):null,bee:d>=37&&16&n?_i.decode(o):null}}},x=e.frame(b),v=e.frame(l),k={preencode(d,o){x.preencode(d,o.pointer),d.end++,o.metadata&&v.preencode(d,o.metadata),o.preview&&Ca.preencode(d,o.preview),o.hash&&e.fixed32.preencode(d,o.hash)},encode(d,o){const n=(o.metadata?1:0)|(o.preview?2:0)|(o.hash?4:0);x.encode(d,o.pointer),e.uint.encode(d,n),o.metadata&&v.encode(d,o.metadata),o.preview&&Ca.encode(d,o.preview),o.hash&&e.fixed32.encode(d,o.hash)},decode(d){const o=x.decode(d),n=e.uint.decode(d);return{pointer:o,metadata:1&n?v.decode(d):null,preview:2&n?Ca.decode(d):null,hash:4&n?e.fixed32.decode(d):null}}},g=e.frame(k),K=g,h=g,w={preencode(e,d){e.end++,d.small&&g.preencode(e,d.small),d.medium&&K.preencode(e,d.medium),d.large&&h.preencode(e,d.large)},encode(d,o){const n=(o.small?1:0)|(o.medium?2:0)|(o.large?4:0);e.uint.encode(d,n),o.small&&g.encode(d,o.small),o.medium&&K.encode(d,o.medium),o.large&&h.encode(d,o.large)},decode(d){const o=e.uint.decode(d);return{small:1&o?g.decode(d):null,medium:2&o?K.decode(d):null,large:4&o?h.decode(d):null}}},P={preencode(e,d){e.end++},encode(d,o){const n=o.isDeleted?1:0;e.uint.encode(d,n)},decode:d=>({isDeleted:!!(1&e.uint.decode(d))})},T=e.frame(P),R=g,A={preencode(o,c){e.uint.preencode(o,c.id),n.preencode(o,c.oplog),T.preencode(o,c.status),R.preencode(o,c.file),o.end++,d>=22&&c.version&&e.uint.preencode(o,c.version)},encode(o,c){const r=d>=22&&c.version?1:0;e.uint.encode(o,c.id),n.encode(o,c.oplog),T.encode(o,c.status),R.encode(o,c.file),e.uint.encode(o,r),d>=22&&c.version&&e.uint.encode(o,c.version)},decode(o){const c=e.uint.decode(o),r=n.decode(o),t=T.decode(o),i=R.decode(o),a=o.start<o.end?e.uint.decode(o):0;return{id:c,oplog:r,status:t,file:i,version:d>=22&&1&a?e.uint.decode(o):0}}},S={preencode(e,d){e.end++},encode(d,o){const n=(o.isActive?1:0)|(o.isIndexing?2:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isActive:!!(1&o),isIndexing:!!(2&o)}}},I={preencode(o,n){const c=(n.isAdmin?1:0)|(n.isModerator?2:0)|(n.isPending?4:0)|(n.isActive?8:0)|(n.isMuted?16:0)|(n.isBanned?32:0)|(n.isShadowBanned?64:0)|(d>=19&&n.isRemoved?128:0);e.uint.preencode(o,c)},encode(o,n){const c=(n.isAdmin?1:0)|(n.isModerator?2:0)|(n.isPending?4:0)|(n.isActive?8:0)|(n.isMuted?16:0)|(n.isBanned?32:0)|(n.isShadowBanned?64:0)|(d>=19&&n.isRemoved?128:0);e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{isAdmin:!!(1&n),isModerator:!!(2&n),isPending:!!(4&n),isActive:!!(8&n),isMuted:!!(16&n),isBanned:!!(32&n),isShadowBanned:!!(64&n),isRemoved:d>=19&&!!(128&n)}}},F={preencode(e,d){e.end++},encode(d,o){const n=(o.isMuted?1:0)|(o.isBanned?2:0)|(o.isShadowBanned?4:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isMuted:!!(1&o),isBanned:!!(2&o),isShadowBanned:!!(4&o)}}},M={preencode(d,o){e.uint.preencode(d,o.version)},encode(d,o){e.uint.encode(d,o.version)},decode:d=>({version:e.uint.decode(d)})},C={preencode(d,o){e.uint.preencode(d,o.total),e.uint.preencode(d,o.active)},encode(d,o){e.uint.encode(d,o.total),e.uint.encode(d,o.active)},decode:d=>({total:e.uint.decode(d),active:e.uint.decode(d)})},V={preencode(d,o){e.uint.preencode(d,o.total),e.uint.preencode(d,o.active),e.uint.preencode(d,o.pending)},encode(d,o){e.uint.encode(d,o.total),e.uint.encode(d,o.active),e.uint.encode(d,o.pending)},decode:d=>({total:e.uint.decode(d),active:e.uint.decode(d),pending:e.uint.decode(d)})},H={preencode(o,n){e.uint.preencode(o,n.clock),e.uint.preencode(o,n.pinned),e.uint.preencode(o,n.threads),e.uint.preencode(o,n.timestamp),o.end++,d>=24&&n.flagsClock&&e.uint.preencode(o,n.flagsClock)},encode(o,n){const c=d>=24&&n.flagsClock?1:0;e.uint.encode(o,n.clock),e.uint.encode(o,n.pinned),e.uint.encode(o,n.threads),e.uint.encode(o,n.timestamp),e.uint.encode(o,c),d>=24&&n.flagsClock&&e.uint.encode(o,n.flagsClock)},decode(o){const n=e.uint.decode(o),c=e.uint.decode(o),r=e.uint.decode(o),t=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{clock:n,pinned:c,threads:r,timestamp:t,flagsClock:d>=24&&1&i?e.uint.decode(o):0}}},D={preencode(d,o){e.uint.preencode(d,o.clock)},encode(d,o){e.uint.encode(d,o.clock)},decode:d=>({clock:e.uint.decode(d)})},L=e.frame(C),q=e.frame(V),j=e.frame(H),E=e.frame(D),B={preencode(e,o){L.preencode(e,o.devices),q.preencode(e,o.members),j.preencode(e,o.chat),E.preencode(e,o.files),e.end++,d>=36&&o.calls&&Va.preencode(e,o.calls)},encode(o,n){const c=d>=36&&n.calls?1:0;L.encode(o,n.devices),q.encode(o,n.members),j.encode(o,n.chat),E.encode(o,n.files),e.uint.encode(o,c),d>=36&&n.calls&&Va.encode(o,n.calls)},decode(o){const n=L.decode(o),c=q.decode(o),r=j.decode(o),t=E.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{devices:n,members:c,chat:r,files:t,calls:d>=36&&1&i?Va.decode(o):null}}},z={Default:1,Broadcast:2,DirectMessage:3},O={preencode(e,d){e.end++},encode(d,o){if(o>3)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},N={preencode(o,n){const c=(n.roomType?1:0)|(n.isExperimental?2:0)|(n.isJoiningDisabled?4:0)|(n.isAppendingDisabled?8:0)|(n.isCallingDisabled?16:0)|(n.isMembershipEventsDisabled?32:0)|(d>=28&&n.isAttachmentsDisabled?64:0)|(d>=28&&n.isLinksDisabled?128:0)|(d>=29&&n.buildType?256:0)|(d>=33&&n.isRoomInviteHidden?512:0);e.uint.preencode(o,c),n.roomType&&O.preencode(o,n.roomType),d>=29&&n.buildType&&xi.preencode(o,n.buildType)},encode(o,n){const c=(n.roomType?1:0)|(n.isExperimental?2:0)|(n.isJoiningDisabled?4:0)|(n.isAppendingDisabled?8:0)|(n.isCallingDisabled?16:0)|(n.isMembershipEventsDisabled?32:0)|(d>=28&&n.isAttachmentsDisabled?64:0)|(d>=28&&n.isLinksDisabled?128:0)|(d>=29&&n.buildType?256:0)|(d>=33&&n.isRoomInviteHidden?512:0);e.uint.encode(o,c),n.roomType&&O.encode(o,n.roomType),d>=29&&n.buildType&&xi.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{roomType:1&n?O.decode(o):0,isExperimental:!!(2&n),isJoiningDisabled:!!(4&n),isAppendingDisabled:!!(8&n),isCallingDisabled:!!(16&n),isMembershipEventsDisabled:!!(32&n),isAttachmentsDisabled:d>=28&&!!(64&n),isLinksDisabled:d>=28&&!!(128&n),buildType:d>=29&&256&n?xi.decode(o):null,isRoomInviteHidden:d>=33&&!!(512&n)}}},U=e.frame(M),J=e.frame(N),W={preencode(d,o){U.preencode(d,o.abi),J.preencode(d,o.settings),e.uint.preencode(d,o.creationTime)},encode(d,o){U.encode(d,o.abi),J.encode(d,o.settings),e.uint.encode(d,o.creationTime)},decode:d=>({abi:U.decode(d),settings:J.decode(d),creationTime:e.uint.decode(d)})},G={preencode(d,o){e.fixed32.preencode(d,o.seed)},encode(d,o){e.fixed32.encode(d,o.seed)},decode:d=>({seed:e.fixed32.decode(d)})},Q={preencode(d,o){c.preencode(d,o.mailboxKeyPair),r.preencode(d,o.discoveryKeyPair),e.fixed32.preencode(d,o.wakeupTopic),e.fixed32.preencode(d,o.swarmTopic)},encode(d,o){c.encode(d,o.mailboxKeyPair),r.encode(d,o.discoveryKeyPair),e.fixed32.encode(d,o.wakeupTopic),e.fixed32.encode(d,o.swarmTopic)},decode:d=>({mailboxKeyPair:c.decode(d),discoveryKeyPair:r.decode(d),wakeupTopic:e.fixed32.decode(d),swarmTopic:e.fixed32.decode(d)})},X=e.array(e.fixed32),Y={preencode(o,n){o.end++,n.title&&e.string.preencode(o,n.title),n.avatar&&Ha.preencode(o,n.avatar),n.description&&e.string.preencode(o,n.description),d>=17&&n.supportedLanguages&&Da.preencode(o,n.supportedLanguages),d>=19&&n.blindPeers&&X.preencode(o,n.blindPeers)},encode(o,n){const c=(n.title?1:0)|(n.avatar?2:0)|(n.description?4:0)|(d>=17&&n.supportedLanguages?8:0)|(d>=19&&n.blindPeers?16:0);e.uint.encode(o,c),n.title&&e.string.encode(o,n.title),n.avatar&&Ha.encode(o,n.avatar),n.description&&e.string.encode(o,n.description),d>=17&&n.supportedLanguages&&Da.encode(o,n.supportedLanguages),d>=19&&n.blindPeers&&X.encode(o,n.blindPeers)},decode(o){const n=e.uint.decode(o);return{title:1&n?e.string.decode(o):null,avatar:2&n?Ha.decode(o):null,description:4&n?e.string.decode(o):null,supportedLanguages:d>=17&&8&n?Da.decode(o):null,blindPeers:d>=19&&16&n?X.decode(o):null}}},Z={preencode(d,o){e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.key)},decode:d=>({key:e.fixed32.decode(d)})},$=e.frame(i),_=e.frame(Z),ee={preencode(e,d){$.preencode(e,d.header),_.preencode(e,d.peer)},encode(e,d){$.encode(e,d.header),_.encode(e,d.peer)},decode:e=>({header:$.decode(e),peer:_.decode(e)})},de=$,oe={preencode(d,o){de.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){de.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:de.decode(d),key:e.fixed32.decode(d)})},ne={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.buffer.preencode(d,o.proof)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.buffer.encode(d,o.proof)},decode:d=>({memberKey:e.fixed32.decode(d),proof:e.buffer.decode(d)})},ce={preencode(d,o){e.fixed32.preencode(d,o.id),e.buffer.preencode(d,o.response)},encode(d,o){e.fixed32.encode(d,o.id),e.buffer.encode(d,o.response)},decode:d=>({id:e.fixed32.decode(d),response:e.buffer.decode(d)})},re=e.frame(S),te=e.frame(ce),ie={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.memberKey),re.preencode(d,o.status),La.preencode(d,o.profile),d.end++,o.invitation&&te.preencode(d,o.invitation)},encode(d,o){const n=o.invitation?1:0;e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.memberKey),re.encode(d,o.status),La.encode(d,o.profile),e.uint.encode(d,n),o.invitation&&te.encode(d,o.invitation)},decode:d=>({key:e.fixed32.decode(d),memberKey:e.fixed32.decode(d),status:re.decode(d),profile:La.decode(d),invitation:1&e.uint.decode(d)?te.decode(d):null})},ae={preencode(d,o){e.uint.preencode(d,o.timestamp),d.end++,o.mailbox&&e.fixed32.preencode(d,o.mailbox),o.displayName&&e.string.preencode(d,o.displayName),o.avatar&&qa.preencode(d,o.avatar),o.username&&e.string.preencode(d,o.username)},encode(d,o){const n=(o.mailbox?1:0)|(o.displayName?2:0)|(o.avatar?4:0)|(o.username?8:0);e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.mailbox&&e.fixed32.encode(d,o.mailbox),o.displayName&&e.string.encode(d,o.displayName),o.avatar&&qa.encode(d,o.avatar),o.username&&e.string.encode(d,o.username)},decode(d){const o=e.uint.decode(d),n=e.uint.decode(d);return{timestamp:o,mailbox:1&n?e.fixed32.decode(d):null,displayName:2&n?e.string.decode(d):null,avatar:4&n?qa.decode(d):null,username:8&n?e.string.decode(d):null}}},se={preencode(o,n){o.end++,n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),n.name&&e.string.preencode(o,n.name),d>=29&&n.buildType&&xi.preencode(o,n.buildType)},encode(o,n){const c=(n.swarmKey?1:0)|(n.name?2:0)|(n.isMobile?4:0)|(d>=29&&n.buildType?8:0);e.uint.encode(o,c),n.swarmKey&&e.fixed32.encode(o,n.swarmKey),n.name&&e.string.encode(o,n.name),d>=29&&n.buildType&&xi.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{swarmKey:1&n?e.fixed32.decode(o):null,name:2&n?e.string.decode(o):null,isMobile:!!(4&n),buildType:d>=29&&8&n?xi.decode(o):null}}},pe=e.frame(ae),le={preencode(e,d){pe.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){pe.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:pe.decode(e),attestation:ne.decode(e)})},ue={preencode(e,d){ja.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){ja.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:ja.decode(e),attestation:ne.decode(e)})},fe={preencode(d,o){e.fixed32.preencode(d,o.id),e.buffer.preencode(d,o.data),e.buffer.preencode(d,o.signature)},encode(d,o){e.fixed32.encode(d,o.id),e.buffer.encode(d,o.data),e.buffer.encode(d,o.signature)},decode:d=>({id:e.fixed32.decode(d),data:e.buffer.decode(d),signature:e.buffer.decode(d)})},me={preencode(d,o){e.fixed32.preencode(d,o.devicePublicKey)},encode(d,o){e.fixed32.encode(d,o.devicePublicKey)},decode:d=>({devicePublicKey:e.fixed32.decode(d)})},ye={preencode(d,o){ne.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){ne.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({privateProfileIdentity:ne.decode(d),deviceProof:e.buffer.decode(d)})},be=e.frame(ue),xe=e.frame(le),ve=e.frame(me),ke={preencode(n,c){e.fixed32.preencode(n,c.deviceKey),r.preencode(n,c.keyPair),be.preencode(n,c.device),xe.preencode(n,c.member),n.end++,c.identity&&ve.preencode(n,c.identity),d>=37&&c.link&&o.preencode(n,c.link)},encode(n,c){const t=(c.identity?1:0)|(d>=37&&c.link?2:0);e.fixed32.encode(n,c.deviceKey),r.encode(n,c.keyPair),be.encode(n,c.device),xe.encode(n,c.member),e.uint.encode(n,t),c.identity&&ve.encode(n,c.identity),d>=37&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),t=r.decode(n),i=be.decode(n),a=xe.decode(n),s=e.uint.decode(n);return{deviceKey:c,keyPair:t,device:i,member:a,identity:1&s?ve.decode(n):null,link:d>=37&&2&s?o.decode(n):null}}},ge=e.frame(ke),Ke={preencode(d,o){e.fixed32.preencode(d,o.id),ge.preencode(d,o.request),e.buffer.preencode(d,o.signature)},encode(d,o){e.fixed32.encode(d,o.id),ge.encode(d,o.request),e.buffer.encode(d,o.signature)},decode:d=>({id:e.fixed32.decode(d),request:ge.decode(d),signature:e.buffer.decode(d)})},he=be,we=xe,Pe={preencode(e,d){he.preencode(e,d.device),e.end++,d.member&&we.preencode(e,d.member)},encode(d,o){const n=o.member?1:0;he.encode(d,o.device),e.uint.encode(d,n),o.member&&we.encode(d,o.member)},decode:d=>({device:he.decode(d),member:1&e.uint.decode(d)?we.decode(d):null})},Te=e.frame(Ke),Re=e.frame(Pe),Ae={preencode(e,d){e.end++,d.withInvitation&&Te.preencode(e,d.withInvitation),d.withMemberProof&&Re.preencode(e,d.withMemberProof)},encode(d,o){const n=(o.withInvitation?1:0)|(o.withMemberProof?2:0);e.uint.encode(d,n),o.withInvitation&&Te.encode(d,o.withInvitation),o.withMemberProof&&Re.encode(d,o.withMemberProof)},decode(d){const o=e.uint.decode(d);return{withInvitation:1&o?Te.decode(d):null,withMemberProof:2&o?Re.decode(d):null}}},Se=e.frame(fe),Ie=e.frame(ye),Fe={preencode(e,d){Se.preencode(e,d.signedKeys),e.end++,d.identity&&Ie.preencode(e,d.identity)},encode(d,o){const n=o.identity?1:0;Se.encode(d,o.signedKeys),e.uint.encode(d,n),o.identity&&Ie.encode(d,o.identity)},decode:d=>({signedKeys:Se.decode(d),identity:1&e.uint.decode(d)?Ie.decode(d):null})},Me={preencode(o,n){o.end++,n.expiration&&e.uint.preencode(o,n.expiration),d>=29&&n.buildType&&xi.preencode(o,n.buildType)},encode(o,n){const c=(n.expiration?1:0)|(n.requiresConfirmation?2:0)|(n.canModerate?4:0)|(n.canAdmin?8:0)|(d>=29&&n.buildType?16:0);e.uint.encode(o,c),n.expiration&&e.uint.encode(o,n.expiration),d>=29&&n.buildType&&xi.encode(o,n.buildType)},decode(o){const n=e.uint.decode(o);return{expiration:1&n?e.uint.decode(o):0,requiresConfirmation:!!(2&n),canModerate:!!(4&n),canAdmin:!!(8&n),buildType:d>=29&&16&n?xi.decode(o):null}}},Ce=Se,Ve=e.frame(Me),He={preencode(d,n){e.fixed32.preencode(d,n.id),Ce.preencode(d,n.response),Ve.preencode(d,n.metadata),d.end++,n.anchor&&o.preencode(d,n.anchor)},encode(d,n){const c=(n.anchor?1:0)|(n.isActive?2:0);e.fixed32.encode(d,n.id),Ce.encode(d,n.response),Ve.encode(d,n.metadata),e.uint.encode(d,c),n.anchor&&o.encode(d,n.anchor)},decode(d){const n=e.fixed32.decode(d),c=Ce.decode(d),r=Ve.decode(d),t=e.uint.decode(d);return{id:n,response:c,metadata:r,anchor:1&t?o.decode(d):null,isActive:!!(2&t)}}},De=$,Le=e.frame(He),qe={preencode(e,d){De.preencode(e,d.header),Le.preencode(e,d.invitation)},encode(e,d){De.encode(e,d.header),Le.encode(e,d.invitation)},decode:e=>({header:De.decode(e),invitation:Le.decode(e)})},je=$,Ee={preencode(d,o){je.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){je.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:je.decode(d),id:e.fixed32.decode(d)})},Be={preencode(d,n){e.fixed32.preencode(d,n.mailbox),e.fixed32.preencode(d,n.invitationSeed),o.preencode(d,n.anchor)},encode(d,n){e.fixed32.encode(d,n.mailbox),e.fixed32.encode(d,n.invitationSeed),o.encode(d,n.anchor)},decode:d=>({mailbox:e.fixed32.decode(d),invitationSeed:e.fixed32.decode(d),anchor:o.decode(d)})},ze={preencode(d,n){e.fixed32.preencode(d,n.mailbox),e.fixed32.preencode(d,n.invitationSeed),o.preencode(d,n.anchor),e.fixed32.preencode(d,n.identityPublicKey)},encode(d,n){e.fixed32.encode(d,n.mailbox),e.fixed32.encode(d,n.invitationSeed),o.encode(d,n.anchor),e.fixed32.encode(d,n.identityPublicKey)},decode:d=>({mailbox:e.fixed32.decode(d),invitationSeed:e.fixed32.decode(d),anchor:o.decode(d),identityPublicKey:e.fixed32.decode(d)})},Oe={preencode(d,o){e.fixed32.preencode(d,o.mailbox)},encode(d,o){e.fixed32.encode(d,o.mailbox)},decode:d=>({mailbox:e.fixed32.decode(d)})},Ne=e.frame(Be),Ue=e.frame(ze),Je=e.frame(Oe),We=e.array(e.ipv4Address),Ge={preencode(e,o){e.end++,o.room&&Ne.preencode(e,o.room),o.identity&&Ue.preencode(e,o.identity),o.contact&&Je.preencode(e,o.contact),d>=9&&o.readonly&&Ea.preencode(e,o.readonly),d>=17&&o.additionalNodes&&We.preencode(e,o.additionalNodes),d>=29&&o.buildType&&xi.preencode(e,o.buildType),d>=37&&o["readonly-v2"]&&Ba.preencode(e,o["readonly-v2"])},encode(o,n){const c=(n.room?1:0)|(n.identity?2:0)|(n.contact?4:0)|(d>=9&&n.readonly?8:0)|(d>=17&&n.additionalNodes?16:0)|(d>=29&&n.buildType?32:0)|(d>=37&&n["readonly-v2"]?64:0);e.uint.encode(o,c),n.room&&Ne.encode(o,n.room),n.identity&&Ue.encode(o,n.identity),n.contact&&Je.encode(o,n.contact),d>=9&&n.readonly&&Ea.encode(o,n.readonly),d>=17&&n.additionalNodes&&We.encode(o,n.additionalNodes),d>=29&&n.buildType&&xi.encode(o,n.buildType),d>=37&&n["readonly-v2"]&&Ba.encode(o,n["readonly-v2"])},decode(o){const n=e.uint.decode(o);return{room:1&n?Ne.decode(o):null,identity:2&n?Ue.decode(o):null,contact:4&n?Je.decode(o):null,readonly:d>=9&&8&n?Ea.decode(o):null,additionalNodes:d>=17&&16&n?We.decode(o):null,buildType:d>=29&&32&n?xi.decode(o):null,"readonly-v2":d>=37&&64&n?Ba.decode(o):null}}},Qe=$,Xe={preencode(d,o){Qe.preencode(d,o.header),e.buffer.preencode(d,o.blindRequest)},encode(d,o){Qe.encode(d,o.header),e.buffer.encode(d,o.blindRequest)},decode:d=>({header:Qe.decode(d),blindRequest:e.buffer.decode(d)})},Ye=$,Ze={preencode(o,n){Ye.preencode(o,n.header),o.end++,n.profile&&za.preencode(o,n.profile),d>=34&&n.key&&e.fixed32.preencode(o,n.key)},encode(o,n){const c=(n.profile?1:0)|(d>=34&&n.key?2:0);Ye.encode(o,n.header),e.uint.encode(o,c),n.profile&&za.encode(o,n.profile),d>=34&&n.key&&e.fixed32.encode(o,n.key)},decode(o){const n=Ye.decode(o),c=e.uint.decode(o);return{header:n,profile:1&c?za.decode(o):null,key:d>=34&&2&c?e.fixed32.decode(o):null}}},$e={preencode(e,d){},encode(e,d){},decode:e=>({})},_e=$e,ed=ge,dd={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.id),ed.preencode(d,o.request)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.id),ed.encode(d,o.request)},decode:d=>({deviceKey:e.fixed32.decode(d),id:e.fixed32.decode(d),request:ed.decode(d)})},od=$,nd=Ie,cd={preencode(d,o){od.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),d.end++,o.identity&&nd.preencode(d,o.identity)},encode(d,o){const n=o.identity?1:0;od.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,n),o.identity&&nd.encode(d,o.identity)},decode:d=>({header:od.decode(d),deviceKey:e.fixed32.decode(d),identity:1&e.uint.decode(d)?nd.decode(d):null})},rd=$,td={preencode(d,o){rd.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey)},encode(d,o){rd.encode(d,o.header),e.fixed32.encode(d,o.deviceKey)},decode:d=>({header:rd.decode(d),deviceKey:e.fixed32.decode(d)})},id=e.frame(I),ad=pe,sd={preencode(d,o){e.fixed32.preencode(d,o.key),id.preencode(d,o.status),ad.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),id.encode(d,o.status),ad.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),status:id.decode(d),profile:ad.decode(d)})},pd=id,ld=pe,ud={preencode(d,o){e.fixed32.preencode(d,o.key),pd.preencode(d,o.status),ld.preencode(d,o.profile),d.end++,o.proofs&&Oa.preencode(d,o.proofs)},encode(d,o){const n=o.proofs?1:0;e.fixed32.encode(d,o.key),pd.encode(d,o.status),ld.encode(d,o.profile),e.uint.encode(d,n),o.proofs&&Oa.encode(d,o.proofs)},decode:d=>({key:e.fixed32.decode(d),status:pd.decode(d),profile:ld.decode(d),proofs:1&e.uint.decode(d)?Oa.decode(d):null})},fd={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++,o.profileAttestation&&e.buffer.preencode(d,o.profileAttestation),o.latestReceipt&&e.buffer.preencode(d,o.latestReceipt)},encode(d,o){const n=(o.profileAttestation?1:0)|(o.latestReceipt?2:0);e.fixed32.encode(d,o.key),e.uint.encode(d,n),o.profileAttestation&&e.buffer.encode(d,o.profileAttestation),o.latestReceipt&&e.buffer.encode(d,o.latestReceipt)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d);return{key:o,profileAttestation:1&n?e.buffer.decode(d):null,latestReceipt:2&n?e.buffer.decode(d):null}}},md=$,yd=xe,bd={preencode(e,d){md.preencode(e,d.header),yd.preencode(e,d.member)},encode(e,d){md.encode(e,d.header),yd.encode(e,d.member)},decode:e=>({header:md.decode(e),member:yd.decode(e)})},xd=$,vd=e.frame(F),kd={preencode(d,o){xd.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),vd.preencode(d,o.status)},encode(d,o){xd.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),vd.encode(d,o.status)},decode:d=>({header:xd.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:vd.decode(d)})},gd=$,Kd={preencode(d,o){gd.preencode(d,o.header),e.fixed32.preencode(d,o.key),d.end++},encode(d,o){const n=(o.isModerator?1:0)|(o.isAdmin?2:0);gd.encode(d,o.header),e.fixed32.encode(d,o.key),e.uint.encode(d,n)},decode(d){const o=gd.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{header:o,key:n,isModerator:!!(1&c),isAdmin:!!(2&c)}}},hd=$,wd={preencode(d,o){hd.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){hd.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:hd.decode(d),key:e.fixed32.decode(d)})},Pd={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.mentions)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.mentions)},decode:d=>({key:e.fixed32.decode(d),mentions:e.uint.decode(d)})},Td={preencode(d,o){d.end++,o.memberKey&&e.fixed32.preencode(d,o.memberKey)},encode(d,o){const n=o.memberKey?1:0;e.uint.encode(d,n),o.memberKey&&e.fixed32.encode(d,o.memberKey)},decode:d=>({memberKey:1&e.uint.decode(d)?e.fixed32.decode(d):null})},Rd=Td,Ad={preencode(d,o){d.end++,o.from&&e.string.preencode(d,o.from),o.to&&e.string.preencode(d,o.to)},encode(d,o){const n=(o.from?1:0)|(o.to?2:0);e.uint.encode(d,n),o.from&&e.string.encode(d,o.from),o.to&&e.string.encode(d,o.to)},decode(d){const o=e.uint.decode(d);return{from:1&o?e.string.decode(d):null,to:2&o?e.string.decode(d):null}}},Sd=e.frame(Td),Id=e.frame(Rd),Fd=e.frame(Ad),Md={preencode(o,n){const c=(n.memberJoined?1:0)|(n.memberLeft?2:0)|(n.titleChanged?4:0)|(n.callStarted?8:0)|(n.callHangup?16:0)|(n.callMissed?32:0)|(d>=4&&n.roomAvatarChanged?64:0)|(d>=4&&n.invitationCreated?128:0)|(d>=4&&n.memberRemoved?256:0)|(d>=27&&n.locationShared?512:0);e.uint.preencode(o,c),n.memberJoined&&Sd.preencode(o,n.memberJoined),n.memberLeft&&Id.preencode(o,n.memberLeft),n.titleChanged&&Fd.preencode(o,n.titleChanged),d>=4&&n.memberRemoved&&Na.preencode(o,n.memberRemoved),d>=27&&n.locationShared&&Ua.preencode(o,n.locationShared)},encode(o,n){const c=(n.memberJoined?1:0)|(n.memberLeft?2:0)|(n.titleChanged?4:0)|(n.callStarted?8:0)|(n.callHangup?16:0)|(n.callMissed?32:0)|(d>=4&&n.roomAvatarChanged?64:0)|(d>=4&&n.invitationCreated?128:0)|(d>=4&&n.memberRemoved?256:0)|(d>=27&&n.locationShared?512:0);e.uint.encode(o,c),n.memberJoined&&Sd.encode(o,n.memberJoined),n.memberLeft&&Id.encode(o,n.memberLeft),n.titleChanged&&Fd.encode(o,n.titleChanged),d>=4&&n.memberRemoved&&Na.encode(o,n.memberRemoved),d>=27&&n.locationShared&&Ua.encode(o,n.locationShared)},decode(o){const n=e.uint.decode(o);return{memberJoined:1&n?Sd.decode(o):null,memberLeft:2&n?Id.decode(o):null,titleChanged:4&n?Fd.decode(o):null,callStarted:!!(8&n),callHangup:!!(16&n),callMissed:!!(32&n),roomAvatarChanged:d>=4&&!!(64&n),invitationCreated:d>=4&&!!(128&n),memberRemoved:d>=4&&256&n?Na.decode(o):null,locationShared:d>=27&&512&n?Ua.decode(o):null}}},Cd={preencode(e,o){e.end++,d>=27&&o.locationShared&&Ja.preencode(e,o.locationShared)},encode(o,n){const c=(n.callStarted?1:0)|(n.callHangup?2:0)|(n.callMissed?4:0)|(d>=27&&n.locationShared?8:0);e.uint.encode(o,c),d>=27&&n.locationShared&&Ja.encode(o,n.locationShared)},decode(o){const n=e.uint.decode(o);return{callStarted:!!(1&n),callHangup:!!(2&n),callMissed:!!(4&n),locationShared:d>=27&&8&n?Ja.decode(o):null}}},Vd={preencode(d,o){e.uint.preencode(d,o.start),e.uint.preencode(d,o.length)},encode(d,o){e.uint.encode(d,o.start),e.uint.encode(d,o.length)},decode:d=>({start:e.uint.decode(d),length:e.uint.decode(d)})},Hd=e.frame(Vd),Dd={preencode(d,o){Hd.preencode(d,o.range),e.string.preencode(d,o.content)},encode(d,o){Hd.encode(d,o.range),e.string.encode(d,o.content)},decode:d=>({range:Hd.decode(d),content:e.string.decode(d)})},Ld=Hd,qd={preencode(d,o){Ld.preencode(d,o.range),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Ld.encode(d,o.range),e.fixed32.encode(d,o.memberKey)},decode:d=>({range:Ld.decode(d),memberKey:e.fixed32.decode(d)})},jd=g,Ed=e.array(e.uint),Bd={preencode(o,n){o.end++,n.title&&e.string.preencode(o,n.title),n.description&&e.string.preencode(o,n.description),n.file&&jd.preencode(o,n.file),d>=12&&n.files&&Ed.preencode(o,n.files)},encode(o,n){const c=(n.title?1:0)|(n.description?2:0)|(n.file?4:0)|(d>=12&&n.files?8:0);e.uint.encode(o,c),n.title&&e.string.encode(o,n.title),n.description&&e.string.encode(o,n.description),n.file&&jd.encode(o,n.file),d>=12&&n.files&&Ed.encode(o,n.files)},decode(o){const n=e.uint.decode(o);return{title:1&n?e.string.decode(o):null,description:2&n?e.string.decode(o):null,file:4&n?jd.decode(o):null,files:d>=12&&8&n?Ed.decode(o):null}}},zd=Hd,Od=e.frame(Bd),Nd={preencode(d,o){zd.preencode(d,o.range),e.string.preencode(d,o.url),d.end++,o.preview&&Od.preencode(d,o.preview)},encode(d,o){const n=o.preview?1:0;zd.encode(d,o.range),e.string.encode(d,o.url),e.uint.encode(d,n),o.preview&&Od.encode(d,o.preview)},decode:d=>({range:zd.decode(d),url:e.string.decode(d),preview:1&e.uint.decode(d)?Od.decode(d):null})},Ud=e.array(e.frame(qd)),Jd=e.array(e.frame(Nd)),Wd=Jd,Gd=e.array(e.frame(Vd)),Qd=Gd,Xd=Gd,Yd=e.array(e.frame(Dd)),Zd=Gd,$d=Gd,_d={preencode(o,n){const c=(n.mention?1:0)|(n.httpLink?2:0)|(n.pearLink?4:0)|(n.bold?8:0)|(n.italic?16:0)|(n.code?32:0)|(n.emoji?64:0)|(n.codeBlock?128:0)|(n.strike?256:0)|(d>=17&&n.translation?512:0);e.uint.preencode(o,c),n.mention&&Ud.preencode(o,n.mention),n.httpLink&&Jd.preencode(o,n.httpLink),n.pearLink&&Wd.preencode(o,n.pearLink),n.bold&&Gd.preencode(o,n.bold),n.italic&&Qd.preencode(o,n.italic),n.code&&Xd.preencode(o,n.code),n.emoji&&Yd.preencode(o,n.emoji),n.codeBlock&&Zd.preencode(o,n.codeBlock),n.strike&&$d.preencode(o,n.strike),d>=17&&n.translation&&Wa.preencode(o,n.translation)},encode(o,n){const c=(n.mention?1:0)|(n.httpLink?2:0)|(n.pearLink?4:0)|(n.bold?8:0)|(n.italic?16:0)|(n.code?32:0)|(n.emoji?64:0)|(n.codeBlock?128:0)|(n.strike?256:0)|(d>=17&&n.translation?512:0);e.uint.encode(o,c),n.mention&&Ud.encode(o,n.mention),n.httpLink&&Jd.encode(o,n.httpLink),n.pearLink&&Wd.encode(o,n.pearLink),n.bold&&Gd.encode(o,n.bold),n.italic&&Qd.encode(o,n.italic),n.code&&Xd.encode(o,n.code),n.emoji&&Yd.encode(o,n.emoji),n.codeBlock&&Zd.encode(o,n.codeBlock),n.strike&&$d.encode(o,n.strike),d>=17&&n.translation&&Wa.encode(o,n.translation)},decode(o){const n=e.uint.decode(o);return{mention:1&n?Ud.decode(o):null,httpLink:2&n?Jd.decode(o):null,pearLink:4&n?Wd.decode(o):null,bold:8&n?Gd.decode(o):null,italic:16&n?Qd.decode(o):null,code:32&n?Xd.decode(o):null,emoji:64&n?Yd.decode(o):null,codeBlock:128&n?Zd.decode(o):null,strike:256&n?$d.decode(o):null,translation:d>=17&&512&n?Wa.decode(o):null}}},eo=e.array(e.frame(k)),oo=e.frame(_d),no=e.frame(Cd),co={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&eo.preencode(d,o.files),o.display&&oo.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent),o.event&&no.preencode(d,o.event)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(c.event?32:0)|(d>=27&&c.forwarded?64:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&eo.encode(o,c.files),c.display&&oo.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent),c.event&&no.encode(o,c.event)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?eo.decode(o):null,display:4&c?oo.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,event:32&c?no.decode(o):null,forwarded:d>=27&&!!(64&c)}}},ro=Ed,to=oo,io={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&ro.preencode(d,o.files),o.display&&to.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(d>=27&&c.forwarded?32:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&ro.encode(o,c.files),c.display&&to.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?ro.decode(o):null,display:4&c?to.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,forwarded:d>=27&&!!(32&c)}}},ao=eo,so=oo,po={preencode(d,o){d.end++,o.text&&e.string.preencode(d,o.text),o.files&&ao.preencode(d,o.files),o.display&&so.preencode(d,o.display),o.replyTo&&n.preencode(d,o.replyTo),o.parent&&n.preencode(d,o.parent)},encode(o,c){const r=(c.text?1:0)|(c.files?2:0)|(c.display?4:0)|(c.replyTo?8:0)|(c.parent?16:0)|(d>=27&&c.forwarded?32:0);e.uint.encode(o,r),c.text&&e.string.encode(o,c.text),c.files&&ao.encode(o,c.files),c.display&&so.encode(o,c.display),c.replyTo&&n.encode(o,c.replyTo),c.parent&&n.encode(o,c.parent)},decode(o){const c=e.uint.decode(o);return{text:1&c?e.string.decode(o):null,files:2&c?ao.decode(o):null,display:4&c?so.decode(o):null,replyTo:8&c?n.decode(o):null,parent:16&c?n.decode(o):null,forwarded:d>=27&&!!(32&c)}}},lo={preencode(e,d){e.end++},encode(d,o){const n=(o.isEdited?1:0)|(o.isDeleted?2:0)|(o.isPinned?4:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isEdited:!!(1&o),isDeleted:!!(2&o),isPinned:!!(4&o)}}},uo={preencode(d,o){e.uint.preencode(d,o.thread),e.uint.preencode(d,o.index)},encode(d,o){e.uint.encode(d,o.thread),e.uint.encode(d,o.index)},decode:d=>({thread:e.uint.decode(d),index:e.uint.decode(d)})},fo=e.frame(B),mo={preencode(d,o){e.uint.preencode(d,o.id),e.uint.preencode(d,o.count),d.end++,o.parent&&n.preencode(d,o.parent),o.stats&&fo.preencode(d,o.stats)},encode(d,o){const c=(o.parent?1:0)|(o.stats?2:0);e.uint.encode(d,o.id),e.uint.encode(d,o.count),e.uint.encode(d,c),o.parent&&n.encode(d,o.parent),o.stats&&fo.encode(d,o.stats)},decode(d){const o=e.uint.decode(d),c=e.uint.decode(d),r=e.uint.decode(d);return{id:o,count:c,parent:1&r?n.decode(d):null,stats:2&r?fo.decode(d):null}}},yo=e.frame(lo),bo=e.frame(io),xo=e.frame(Md),vo={preencode(d,o){uo.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),yo.preencode(d,o.status),o.message&&bo.preencode(d,o.message),o.event&&xo.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);uo.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),yo.encode(d,o.status),o.message&&bo.encode(d,o.message),o.event&&xo.encode(d,o.event)},decode(d){const o=uo.decode(d),c=n.decode(d),r=e.uint.decode(d),t=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:r,timestamp:t,editedAt:1&i?e.uint.decode(d):0,status:yo.decode(d),message:2&i?bo.decode(d):null,event:4&i?xo.decode(d):null}}},ko=yo,go=e.frame(po),Ko=xo,ho={preencode(d,o){uo.preencode(d,o.id),n.preencode(d,o.oplog),e.uint.preencode(d,o.clock),e.uint.preencode(d,o.timestamp),d.end++,o.editedAt&&e.uint.preencode(d,o.editedAt),ko.preencode(d,o.status),o.message&&go.preencode(d,o.message),o.event&&Ko.preencode(d,o.event)},encode(d,o){const c=(o.editedAt?1:0)|(o.message?2:0)|(o.event?4:0);uo.encode(d,o.id),n.encode(d,o.oplog),e.uint.encode(d,o.clock),e.uint.encode(d,o.timestamp),e.uint.encode(d,c),o.editedAt&&e.uint.encode(d,o.editedAt),ko.encode(d,o.status),o.message&&go.encode(d,o.message),o.event&&Ko.encode(d,o.event)},decode(d){const o=uo.decode(d),c=n.decode(d),r=e.uint.decode(d),t=e.uint.decode(d),i=e.uint.decode(d);return{id:o,oplog:c,clock:r,timestamp:t,editedAt:1&i?e.uint.decode(d):0,status:ko.decode(d),message:2&i?go.decode(d):null,event:4&i?Ko.decode(d):null}}},wo=$,Po=e.frame(co),To={preencode(e,d){wo.preencode(e,d.header),Po.preencode(e,d.message)},encode(e,d){wo.encode(e,d.header),Po.encode(e,d.message)},decode:e=>({header:wo.decode(e),message:Po.decode(e)})},Ro=$,Ao={preencode(e,d){Ro.preencode(e,d.header),n.preencode(e,d.oplog)},encode(e,d){Ro.encode(e,d.header),n.encode(e,d.oplog)},decode:e=>({header:Ro.decode(e),oplog:n.decode(e)})},So=$,Io=Po,Fo={preencode(e,d){So.preencode(e,d.header),n.preencode(e,d.oplog),Io.preencode(e,d.message)},encode(e,d){So.encode(e,d.header),n.encode(e,d.oplog),Io.encode(e,d.message)},decode:e=>({header:So.decode(e),oplog:n.decode(e),message:Io.decode(e)})},Mo=$,Co={preencode(e,d){Mo.preencode(e,d.header),n.preencode(e,d.oplog),e.end++},encode(d,o){const c=o.isPinned?1:0;Mo.encode(d,o.header),n.encode(d,o.oplog),e.uint.encode(d,c)},decode:d=>({header:Mo.decode(d),oplog:n.decode(d),isPinned:!!(1&e.uint.decode(d))})},Vo={preencode(d,o){uo.preencode(d,o.id),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),e.string.preencode(d,o.reaction)},encode(d,o){uo.encode(d,o.id),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),e.string.encode(d,o.reaction)},decode:d=>({id:uo.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),reaction:e.string.decode(d)})},Ho={preencode(d,o){e.string.preencode(d,o.text),e.uint.preencode(d,o.count)},encode(d,o){e.string.encode(d,o.text),e.uint.encode(d,o.count)},decode:d=>({text:e.string.decode(d),count:e.uint.decode(d)})},Do=e.array(e.frame(Ho)),Lo={preencode(o,n){uo.preencode(o,n.id),e.uint.preencode(o,n.total),Do.preencode(o,n.reactions),o.end++,d>=17&&n.editedAt&&e.uint.preencode(o,n.editedAt)},encode(o,n){const c=d>=17&&n.editedAt?1:0;uo.encode(o,n.id),e.uint.encode(o,n.total),Do.encode(o,n.reactions),e.uint.encode(o,c),d>=17&&n.editedAt&&e.uint.encode(o,n.editedAt)},decode(o){const n=uo.decode(o),c=e.uint.decode(o),r=Do.decode(o),t=o.start<o.end?e.uint.decode(o):0;return{id:n,total:c,reactions:r,editedAt:d>=17&&1&t?e.uint.decode(o):0}}},qo=$,jo={preencode(d,o){qo.preencode(d,o.header),n.preencode(d,o.oplog),e.string.preencode(d,o.reaction)},encode(d,o){qo.encode(d,o.header),n.encode(d,o.oplog),e.string.encode(d,o.reaction)},decode:d=>({header:qo.decode(d),oplog:n.decode(d),reaction:e.string.decode(d)})},Eo=$,Bo={preencode(d,o){Eo.preencode(d,o.header),n.preencode(d,o.oplog),e.string.preencode(d,o.reaction)},encode(d,o){Eo.encode(d,o.header),n.encode(d,o.oplog),e.string.encode(d,o.reaction)},decode:d=>({header:Eo.decode(d),oplog:n.decode(d),reaction:e.string.decode(d)})},zo=$,Oo=e.frame(Y),No={preencode(d,o){zo.preencode(d,o.header),e.uint.preencode(d,o.key),Oo.preencode(d,o.config)},encode(d,o){zo.encode(d,o.header),e.uint.encode(d,o.key),Oo.encode(d,o.config)},decode:d=>({header:zo.decode(d),key:e.uint.decode(d),config:Oo.decode(d)})},Uo={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.string.preencode(d,o.displayName),d.end++,o.avatar&&Ga.preencode(d,o.avatar)},encode(d,o){const n=o.avatar?1:0;e.fixed32.encode(d,o.memberKey),e.string.encode(d,o.displayName),e.uint.encode(d,n),o.avatar&&Ga.encode(d,o.avatar)},decode:d=>({memberKey:e.fixed32.decode(d),displayName:e.string.decode(d),avatar:1&e.uint.decode(d)?Ga.decode(d):null})},Jo={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++,o.username&&e.string.preencode(d,o.username)},encode(d,o){const n=o.username?1:0;e.fixed32.encode(d,o.key),e.uint.encode(d,n),o.username&&e.string.encode(d,o.username)},decode:d=>({key:e.fixed32.decode(d),username:1&e.uint.decode(d)?e.string.decode(d):null})},Wo=e.frame(Jo),Go={preencode(d,o){e.fixed32.preencode(d,o.publicKey),d.end++,o.discoveryCoreKey&&e.fixed32.preencode(d,o.discoveryCoreKey),o.userRegistry&&Wo.preencode(d,o.userRegistry)},encode(d,o){const n=(o.discoveryCoreKey?1:0)|(o.userRegistry?2:0);e.fixed32.encode(d,o.publicKey),e.uint.encode(d,n),o.discoveryCoreKey&&e.fixed32.encode(d,o.discoveryCoreKey),o.userRegistry&&Wo.encode(d,o.userRegistry)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d);return{publicKey:o,discoveryCoreKey:1&n?e.fixed32.decode(d):null,userRegistry:2&n?Wo.decode(d):null}}},Qo=$,Xo=e.frame(W),Yo=e.frame(G),Zo=Oo,$o=e.frame(Go),_o=be,en=e.array(e.frame(le)),dn={preencode(e,d){Qo.preencode(e,d.header),Xo.preencode(e,d.digest),Yo.preencode(e,d.capabilities),e.end++,d.config&&Zo.preencode(e,d.config),d.identity&&$o.preencode(e,d.identity),d.bootstrapDevice&&_o.preencode(e,d.bootstrapDevice),d.initialMembers&&en.preencode(e,d.initialMembers)},encode(d,o){const n=(o.config?1:0)|(o.identity?2:0)|(o.bootstrapDevice?4:0)|(o.initialMembers?8:0);Qo.encode(d,o.header),Xo.encode(d,o.digest),Yo.encode(d,o.capabilities),e.uint.encode(d,n),o.config&&Zo.encode(d,o.config),o.identity&&$o.encode(d,o.identity),o.bootstrapDevice&&_o.encode(d,o.bootstrapDevice),o.initialMembers&&en.encode(d,o.initialMembers)},decode(d){const o=Qo.decode(d),n=Xo.decode(d),c=Yo.decode(d),r=e.uint.decode(d);return{header:o,digest:n,capabilities:c,config:1&r?Zo.decode(d):null,identity:2&r?$o.decode(d):null,bootstrapDevice:4&r?_o.decode(d):null,initialMembers:8&r?en.decode(d):null}}},on=$,nn={preencode(d,o){on.preencode(d,o.header),e.uint.preencode(d,o.version)},encode(d,o){on.encode(d,o.header),e.uint.encode(d,o.version)},decode:d=>({header:on.decode(d),version:e.uint.decode(d)})},cn=$,rn=J,tn={preencode(d,o){cn.preencode(d,o.header),e.uint.preencode(d,o.key),rn.preencode(d,o.settings)},encode(d,o){cn.encode(d,o.header),e.uint.encode(d,o.key),rn.encode(d,o.settings)},decode:d=>({header:cn.decode(d),key:e.uint.decode(d),settings:rn.decode(d)})},an={preencode(o,n){e.fixed32.preencode(o,n.memberKey),Qa.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=32&&n.contactInfo&&Xa.preencode(o,n.contactInfo),d>=32&&n.version&&e.uint.preencode(o,n.version),d>=34&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=32&&n.contactInfo?4:0)|(d>=32&&n.version?8:0)|(d>=34&&n.alias?16:0);e.fixed32.encode(o,n.memberKey),Qa.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=32&&n.contactInfo&&Xa.encode(o,n.contactInfo),d>=32&&n.version&&e.uint.encode(o,n.version),d>=34&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.fixed32.decode(o),c=Qa.decode(o),r=e.uint.decode(o);return{memberKey:n,status:c,mailbox:1&r?e.fixed32.decode(o):null,roomKey:2&r?e.fixed32.decode(o):null,contactInfo:d>=32&&4&r?Xa.decode(o):null,version:d>=32&&8&r?e.uint.decode(o):0,alias:d>=34&&16&r?e.string.decode(o):null}}},sn={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.seed),o.preencode(d,n.initiator),e.fixed32.preencode(d,n.fastForwardTo)},encode(d,n){e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.fixed32.encode(d,n.seed),o.encode(d,n.initiator),e.fixed32.encode(d,n.fastForwardTo)},decode:d=>({roomKey:e.fixed32.decode(d),encryptionKey:e.buffer.decode(d),seed:e.fixed32.decode(d),initiator:o.decode(d),fastForwardTo:e.fixed32.decode(d)})},pn=e.array(e.frame(sn)),ln=X,un={preencode(e,d){pn.preencode(e,d.sharedRooms),ln.preencode(e,d.blockedContacts)},encode(e,d){pn.encode(e,d.sharedRooms),ln.encode(e,d.blockedContacts)},decode:e=>({sharedRooms:pn.decode(e),blockedContacts:ln.decode(e)})},fn=$o,mn={preencode(e,d){fn.preencode(e,d.identity)},encode(e,d){fn.encode(e,d.identity)},decode:e=>({identity:fn.decode(e)})},yn={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.contacts)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.contacts)},decode:d=>({rooms:e.uint.decode(d),contacts:e.uint.decode(d)})},bn={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.contactRequests)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.contactRequests)},decode:d=>({rooms:e.uint.decode(d),contactRequests:e.uint.decode(d)})},xn={preencode(d,o){e.buffer.preencode(d,o.entropy)},encode(d,o){e.buffer.encode(d,o.entropy)},decode:d=>({entropy:e.buffer.decode(d)})},vn={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.devicePublicKey),e.fixed32.preencode(d,o.writerKey)},encode(d,o){e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.devicePublicKey),e.fixed32.encode(d,o.writerKey)},decode:d=>({publicKey:e.fixed32.decode(d),devicePublicKey:e.fixed32.decode(d),writerKey:e.fixed32.decode(d)})},kn=e.frame(vn),gn={preencode(n,c){e.fixed32.preencode(n,c.id),e.fixed32.preencode(n,c.invitationSeed),e.fixed32.preencode(n,c.mailbox),r.preencode(n,c.responseKeyPair),o.preencode(n,c.initiator),o.preencode(n,c.inviter),n.end++,c.identity&&kn.preencode(n,c.identity),d>=29&&c.buildType&&xi.preencode(n,c.buildType),d>=37&&c.link&&o.preencode(n,c.link)},encode(n,c){const t=(c.identity?1:0)|(d>=29&&c.buildType?2:0)|(d>=37&&c.link?4:0);e.fixed32.encode(n,c.id),e.fixed32.encode(n,c.invitationSeed),e.fixed32.encode(n,c.mailbox),r.encode(n,c.responseKeyPair),o.encode(n,c.initiator),o.encode(n,c.inviter),e.uint.encode(n,t),c.identity&&kn.encode(n,c.identity),d>=29&&c.buildType&&xi.encode(n,c.buildType),d>=37&&c.link&&o.encode(n,c.link)},decode(n){const c=e.fixed32.decode(n),t=e.fixed32.decode(n),i=e.fixed32.decode(n),a=r.decode(n),s=o.decode(n),p=o.decode(n),l=e.uint.decode(n);return{id:c,invitationSeed:t,mailbox:i,responseKeyPair:a,initiator:s,inviter:p,identity:1&l?kn.decode(n):null,buildType:d>=29&&2&l?xi.decode(n):null,link:d>=37&&4&l?o.decode(n):null}}},Kn=$,hn={preencode(d,o){Kn.preencode(d,o.header),e.buffer.preencode(d,o.blindResponse)},encode(d,o){Kn.encode(d,o.header),e.buffer.encode(d,o.blindResponse)},decode:d=>({header:Kn.decode(d),blindResponse:e.buffer.decode(d)})},wn=$,Pn=e.frame(gn),Tn={preencode(e,d){wn.preencode(e,d.header),Pn.preencode(e,d.invitation)},encode(e,d){wn.encode(e,d.header),Pn.encode(e,d.invitation)},decode:e=>({header:wn.decode(e),invitation:Pn.decode(e)})},Rn=$,An={preencode(d,o){Rn.preencode(d,o.header),e.fixed32.preencode(d,o.id)},encode(d,o){Rn.encode(d,o.header),e.fixed32.encode(d,o.id)},decode:d=>({header:Rn.decode(d),id:e.fixed32.decode(d)})},Sn={preencode(d,o){e.fixed32.preencode(d,o.publicKey),e.fixed32.preencode(d,o.devicePublicKey),d.end++,o.privateProfileKey&&e.fixed32.preencode(d,o.privateProfileKey),o.deviceKeyPair&&r.preencode(d,o.deviceKeyPair),e.buffer.preencode(d,o.deviceProof)},encode(d,o){const n=(o.privateProfileKey?1:0)|(o.deviceKeyPair?2:0);e.fixed32.encode(d,o.publicKey),e.fixed32.encode(d,o.devicePublicKey),e.uint.encode(d,n),o.privateProfileKey&&e.fixed32.encode(d,o.privateProfileKey),o.deviceKeyPair&&r.encode(d,o.deviceKeyPair),e.buffer.encode(d,o.deviceProof)},decode(d){const o=e.fixed32.decode(d),n=e.fixed32.decode(d),c=e.uint.decode(d);return{publicKey:o,devicePublicKey:n,privateProfileKey:1&c?e.fixed32.decode(d):null,deviceKeyPair:2&c?r.decode(d):null,deviceProof:e.buffer.decode(d)}}},In={preencode(o,n){o.end++,d>=35&&n.roomSnoozeTime&&e.uint.preencode(o,n.roomSnoozeTime)},encode(o,n){const c=(n.isActive?1:0)|(n.isFullyMuted?2:0)|(n.isMentionsOnlyMuted?4:0)|(d>=14&&n.isReadOnly?8:0)|(d>=27&&n.isFavorite?16:0)|(d>=31&&n.isUnread?32:0)|(d>=35&&n.roomSnoozeTime?64:0);e.uint.encode(o,c),d>=35&&n.roomSnoozeTime&&e.uint.encode(o,n.roomSnoozeTime)},decode(o){const n=e.uint.decode(o);return{isActive:!!(1&n),isFullyMuted:!!(2&n),isMentionsOnlyMuted:!!(4&n),isReadOnly:d>=14&&!!(8&n),isFavorite:d>=27&&!!(16&n),isUnread:d>=31&&!!(32&n),roomSnoozeTime:d>=35&&64&n?e.uint.decode(o):0}}},Fn=e.frame(In),Mn=e.frame(Sn),Cn=kn,Vn={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),Fn.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,c.initiator&&o.preencode(n,c.initiator),c.fastForwardTo&&e.fixed32.preencode(n,c.fastForwardTo),c.identitySwap&&Mn.preencode(n,c.identitySwap),d>=9&&c.identitySwapV2&&Cn.preencode(n,c.identitySwapV2),d>=15&&c.contact&&e.fixed32.preencode(n,c.contact),d>=37&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=39&&c.activeClock&&e.uint.preencode(n,c.activeClock)},encode(n,c){const r=(c.initiator?1:0)|(c.fastForwardTo?2:0)|(c.identitySwap?4:0)|(d>=9&&c.identitySwapV2?8:0)|(d>=15&&c.contact?16:0)|(d>=37&&c.bootFrom?32:0)|(d>=39&&c.activeClock?64:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),Fn.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,r),c.initiator&&o.encode(n,c.initiator),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),c.identitySwap&&Mn.encode(n,c.identitySwap),d>=9&&c.identitySwapV2&&Cn.encode(n,c.identitySwapV2),d>=15&&c.contact&&e.fixed32.encode(n,c.contact),d>=37&&c.bootFrom&&o.encode(n,c.bootFrom),d>=39&&c.activeClock&&e.uint.encode(n,c.activeClock)},decode(n){const c=e.fixed32.decode(n),r=e.buffer.decode(n),t=e.fixed32.decode(n),i=Fn.decode(n),a=e.uint.decode(n),s=e.uint.decode(n);return{roomKey:c,encryptionKey:r,mailbox:t,status:i,clock:a,initiator:1&s?o.decode(n):null,fastForwardTo:2&s?e.fixed32.decode(n):null,identitySwap:4&s?Mn.decode(n):null,identitySwapV2:d>=9&&8&s?Cn.decode(n):null,contact:d>=15&&16&s?e.fixed32.decode(n):null,bootFrom:d>=37&&32&s?o.decode(n):null,activeClock:d>=39&&64&s?e.uint.decode(n):0}}},Hn=$,Dn={preencode(d,n){Hn.preencode(d,n.header),e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.mailbox),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.dm&&e.fixed32.preencode(d,n.dm)},encode(n,c){const r=(c.fastForwardTo?1:0)|(c.initiator?2:0)|(c.dm?4:0)|(d>=14&&c.isReadOnly?8:0);Hn.encode(n,c.header),e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),e.uint.encode(n,r),c.fastForwardTo&&e.fixed32.encode(n,c.fastForwardTo),c.initiator&&o.encode(n,c.initiator),c.dm&&e.fixed32.encode(n,c.dm)},decode(n){const c=Hn.decode(n),r=e.fixed32.decode(n),t=e.buffer.decode(n),i=e.fixed32.decode(n),a=e.uint.decode(n);return{header:c,roomKey:r,encryptionKey:t,mailbox:i,fastForwardTo:1&a?e.fixed32.decode(n):null,initiator:2&a?o.decode(n):null,dm:4&a?e.fixed32.decode(n):null,isReadOnly:d>=14&&!!(8&a)}}},Ln=$,qn={preencode(d,o){Ln.preencode(d,o.header),e.fixed32.preencode(d,o.discoveryKey)},encode(d,o){Ln.encode(d,o.header),e.fixed32.encode(d,o.discoveryKey)},decode:d=>({header:Ln.decode(d),discoveryKey:e.fixed32.decode(d)})},jn=$,En=Fn,Bn={preencode(d,o){jn.preencode(d,o.header),e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.key),En.preencode(d,o.status)},encode(d,o){jn.encode(d,o.header),e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.key),En.encode(d,o.status)},decode:d=>({header:jn.decode(d),roomKey:e.fixed32.decode(d),key:e.uint.decode(d),status:En.decode(d)})},zn={preencode(e,d){e.end++},encode(o,n){const c=(n.isBlocked?1:0)|(d>=32&&n.isActive?2:0);e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{isBlocked:!!(1&n),isActive:d>=32&&!!(2&n)}}},On={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.clock),Ya.preencode(o,n.status),o.end++,n.mailbox&&e.fixed32.preencode(o,n.mailbox),n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=32&&n.contactInfo&&Za.preencode(o,n.contactInfo),d>=34&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=(n.mailbox?1:0)|(n.roomKey?2:0)|(d>=32&&n.contactInfo?4:0)|(d>=34&&n.alias?8:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.clock),Ya.encode(o,n.status),e.uint.encode(o,c),n.mailbox&&e.fixed32.encode(o,n.mailbox),n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=32&&n.contactInfo&&Za.encode(o,n.contactInfo),d>=34&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),r=Ya.decode(o),t=e.uint.decode(o);return{memberKey:n,clock:c,status:r,mailbox:1&t?e.fixed32.decode(o):null,roomKey:2&t?e.fixed32.decode(o):null,contactInfo:d>=32&&4&t?Za.decode(o):null,alias:d>=34&&8&t?e.string.decode(o):null}}},Nn=$,Un=e.frame(an),Jn={preencode(e,d){Nn.preencode(e,d.header),Un.preencode(e,d.contact)},encode(e,d){Nn.encode(e,d.header),Un.encode(e,d.contact)},decode:e=>({header:Nn.decode(e),contact:Un.decode(e)})},Wn=$,Gn={preencode(d,o){Wn.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.key),$a.preencode(d,o.status)},encode(d,o){Wn.encode(d,o.header),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.key),$a.encode(d,o.status)},decode:d=>({header:Wn.decode(d),memberKey:e.fixed32.decode(d),key:e.uint.decode(d),status:$a.decode(d)})},Qn=$,Xn={preencode(d,o){Qn.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey)},encode(d,o){Qn.encode(d,o.header),e.fixed32.encode(d,o.memberKey)},decode:d=>({header:Qn.decode(d),memberKey:e.fixed32.decode(d)})},Yn={preencode(e,d){e.end++},encode(d,o){const n=(o.isPending?1:0)|(o.isAccepted?2:0)|(o.isRejected?4:0)|(o.isDiscarded?8:0)|(o.isSeen?16:0);e.uint.encode(d,n)},decode(d){const o=e.uint.decode(d);return{isPending:!!(1&o),isAccepted:!!(2&o),isRejected:!!(4&o),isDiscarded:!!(8&o),isSeen:!!(16&o)}}},Zn=xe,$n=e.frame(t),_n={preencode(d,o){Zn.preencode(d,o.sender),$n.preencode(d,o.keys),e.fixed32.preencode(d,o.mailbox),d.end++,o.message&&e.string.preencode(d,o.message)},encode(d,o){const n=o.message?1:0;Zn.encode(d,o.sender),$n.encode(d,o.keys),e.fixed32.encode(d,o.mailbox),e.uint.encode(d,n),o.message&&e.string.encode(d,o.message)},decode:d=>({sender:Zn.decode(d),keys:$n.decode(d),mailbox:e.fixed32.decode(d),message:1&e.uint.decode(d)?e.string.decode(d):null})},ec=e.frame(_n),dc={preencode(o,n){ec.preencode(o,n.body),ne.preencode(o,n.attestation),o.end++,d>=41&&n.recipientProof&&e.buffer.preencode(o,n.recipientProof)},encode(o,n){const c=d>=41&&n.recipientProof?1:0;ec.encode(o,n.body),ne.encode(o,n.attestation),e.uint.encode(o,c),d>=41&&n.recipientProof&&e.buffer.encode(o,n.recipientProof)},decode(o){const n=ec.decode(o),c=ne.decode(o),r=o.start<o.end?e.uint.decode(o):0;return{body:n,attestation:c,recipientProof:d>=41&&1&r?e.buffer.decode(o):null}}},oc=pe,nc=e.frame(Yn),cc=$n,rc={preencode(o,n){e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.clock),oc.preencode(o,n.sender),nc.preencode(o,n.status),cc.preencode(o,n.keys),e.fixed32.preencode(o,n.mailbox),o.end++,n.message&&e.string.preencode(o,n.message),d>=17&&n.sentAt&&e.uint.preencode(o,n.sentAt),d>=32&&n.contactInfo&&_a.preencode(o,n.contactInfo)},encode(o,n){const c=(n.message?1:0)|(d>=17&&n.sentAt?2:0)|(d>=32&&n.contactInfo?4:0);e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.clock),oc.encode(o,n.sender),nc.encode(o,n.status),cc.encode(o,n.keys),e.fixed32.encode(o,n.mailbox),e.uint.encode(o,c),n.message&&e.string.encode(o,n.message),d>=17&&n.sentAt&&e.uint.encode(o,n.sentAt),d>=32&&n.contactInfo&&_a.encode(o,n.contactInfo)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),r=oc.decode(o),t=nc.decode(o),i=cc.decode(o),a=e.fixed32.decode(o),s=e.uint.decode(o);return{memberKey:n,clock:c,sender:r,status:t,keys:i,mailbox:a,message:1&s?e.string.decode(o):null,sentAt:d>=17&&2&s?e.uint.decode(o):0,contactInfo:d>=32&&4&s?_a.decode(o):null}}},tc=$,ic={preencode(d,o){tc.preencode(d,o.header),e.buffer.preencode(d,o.blindRequest)},encode(d,o){tc.encode(d,o.header),e.buffer.encode(d,o.blindRequest)},decode:d=>({header:tc.decode(d),blindRequest:e.buffer.decode(d)})},ac=$,sc=nc,pc={preencode(o,n){ac.preencode(o,n.header),e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.key),sc.preencode(o,n.status),o.end++,d>=15&&n.roomKey&&e.fixed32.preencode(o,n.roomKey)},encode(o,n){const c=d>=15&&n.roomKey?1:0;ac.encode(o,n.header),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.key),sc.encode(o,n.status),e.uint.encode(o,c),d>=15&&n.roomKey&&e.fixed32.encode(o,n.roomKey)},decode(o){const n=ac.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o),t=sc.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{header:n,memberKey:c,key:r,status:t,roomKey:d>=15&&1&i?e.fixed32.decode(o):null}}},lc={preencode(d,o){e.uint.preencode(d,o.timestamp),e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.mailbox)},encode(d,o){e.uint.encode(d,o.timestamp),e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.mailbox)},decode:d=>({version:0,timestamp:e.uint.decode(d),key:e.fixed32.decode(d),mailbox:e.fixed32.decode(d)})},uc={preencode(d,o){const n=o.version??1;switch(e.uint.preencode(d,n),n){case 0:case 1:lc.preencode(d,o);break;default:throw new Error("Unsupported version")}},encode(d,o){const n=o.version??1;switch(e.uint.encode(d,n),n){case 0:case 1:lc.encode(d,o);break;default:throw new Error("Unsupported version")}},decode(d){const o=e.uint.decode(d);switch(o){case 0:case 1:{const e=lc.decode(d);return e.version=o,e}default:throw new Error("Unsupported version")}}},fc={preencode(d,o){e.fixed32.preencode(d,o.discoveryPublicKey),e.uint.preencode(d,o.timestamp),d.end++,o.lastSynced&&e.uint.preencode(d,o.lastSynced)},encode(d,o){const n=(o.lastSynced?1:0)|(o.dirty?2:0);e.fixed32.encode(d,o.discoveryPublicKey),e.uint.encode(d,o.timestamp),e.uint.encode(d,n),o.lastSynced&&e.uint.encode(d,o.lastSynced)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d),c=e.uint.decode(d);return{discoveryPublicKey:o,timestamp:n,lastSynced:1&c?e.uint.decode(d):0,dirty:!!(2&c)}}},mc={preencode(d,o){e.uint.preencode(d,o.rooms),e.uint.preencode(d,o.activeRooms)},encode(d,o){e.uint.encode(d,o.rooms),e.uint.encode(d,o.activeRooms)},decode:d=>({rooms:e.uint.decode(d),activeRooms:e.uint.decode(d)})},yc=M,bc=X,xc={preencode(e,d){e.end++,d.blockedMembers&&bc.preencode(e,d.blockedMembers)},encode(d,o){const n=o.blockedMembers?1:0;e.uint.encode(d,n),o.blockedMembers&&bc.encode(d,o.blockedMembers)},decode:d=>({blockedMembers:1&e.uint.decode(d)?bc.decode(d):null})},vc=e.frame(Q),kc=e.frame(xc),gc={preencode(d,n){e.buffer.preencode(d,n.encryptionKey),e.fixed32.preencode(d,n.seed),vc.preencode(d,n.capabilities),o.preencode(d,n.initiator),e.fixed32.preencode(d,n.fastForwardTo),d.end++,n.privateProfile&&kc.preencode(d,n.privateProfile)},encode(d,n){const c=n.privateProfile?1:0;e.buffer.encode(d,n.encryptionKey),e.fixed32.encode(d,n.seed),vc.encode(d,n.capabilities),o.encode(d,n.initiator),e.fixed32.encode(d,n.fastForwardTo),e.uint.encode(d,c),n.privateProfile&&kc.encode(d,n.privateProfile)},decode:d=>({encryptionKey:e.buffer.decode(d),seed:e.fixed32.decode(d),capabilities:vc.decode(d),initiator:o.decode(d),fastForwardTo:e.fixed32.decode(d),privateProfile:1&e.uint.decode(d)?kc.decode(d):null})},Kc={preencode(d,o){d.end++,o.count&&e.uint.preencode(d,o.count)},encode(d,o){const n=o.count?1:0;e.uint.encode(d,n),o.count&&e.uint.encode(d,o.count)},decode:d=>({count:1&e.uint.decode(d)?e.uint.decode(d):0})},hc=e.frame(gc),wc={preencode(o,n){e.fixed32.preencode(o,n.roomKey),e.uint.preencode(o,n.priority),o.end++,n.v3&&hc.preencode(o,n.v3),d>=5&&n.timestamp&&e.uint.preencode(o,n.timestamp)},encode(o,n){const c=(n.v3?1:0)|(d>=3&&n.errored?2:0)|(d>=5&&n.timestamp?4:0);e.fixed32.encode(o,n.roomKey),e.uint.encode(o,n.priority),e.uint.encode(o,c),n.v3&&hc.encode(o,n.v3),d>=5&&n.timestamp&&e.uint.encode(o,n.timestamp)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o),r=e.uint.decode(o);return{roomKey:n,priority:c,v3:1&r?hc.decode(o):null,errored:d>=3&&!!(2&r),timestamp:d>=5&&4&r?e.uint.decode(o):0}}},Pc={preencode(e,d){e.end++},encode(d,o){const n=o.isConfirmed?1:0;e.uint.encode(d,n)},decode:d=>({isConfirmed:!!(1&e.uint.decode(d))})},Tc=e.frame(Pc),Rc=Mn,Ac={preencode(o,n){e.fixed32.preencode(o,n.publicKey),e.fixed32.preencode(o,n.privateProfileKey),r.preencode(o,n.deviceKeyPair),e.buffer.preencode(o,n.deviceProof),Tc.preencode(o,n.status),o.end++,n.entropy&&e.buffer.preencode(o,n.entropy),n.swap&&Rc.preencode(o,n.swap),d>=9&&n.swapV2&&es.preencode(o,n.swapV2),d>=31&&n.proofShortenedAt&&e.uint.preencode(o,n.proofShortenedAt)},encode(o,n){const c=(n.entropy?1:0)|(n.swap?2:0)|(d>=9&&n.swapV2?4:0)|(d>=31&&n.proofShortenedAt?8:0);e.fixed32.encode(o,n.publicKey),e.fixed32.encode(o,n.privateProfileKey),r.encode(o,n.deviceKeyPair),e.buffer.encode(o,n.deviceProof),Tc.encode(o,n.status),e.uint.encode(o,c),n.entropy&&e.buffer.encode(o,n.entropy),n.swap&&Rc.encode(o,n.swap),d>=9&&n.swapV2&&es.encode(o,n.swapV2),d>=31&&n.proofShortenedAt&&e.uint.encode(o,n.proofShortenedAt)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=r.decode(o),i=e.buffer.decode(o),a=Tc.decode(o),s=e.uint.decode(o);return{publicKey:n,privateProfileKey:c,deviceKeyPair:t,deviceProof:i,status:a,entropy:1&s?e.buffer.decode(o):null,swap:2&s?Rc.decode(o):null,swapV2:d>=9&&4&s?es.decode(o):null,proofShortenedAt:d>=31&&8&s?e.uint.decode(o):0}}},Sc={RestoreIdentity:1,CreateRoom:2,LeaveRoom:3,ClearRoom:4,JoinRoomInvitation:5,JoinRoomKeys:6,JoinRoomResponse:7,SendContactRequest:8,TestFastTask:9,TestSlowTask:10,TestErrorTask:11},Ic={preencode(e,d){e.end++},encode(d,o){if(o>11)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Fc={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator)},encode(d,n){const c=(n.fastForwardTo?1:0)|(n.initiator?2:0);e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.uint.encode(d,c),n.fastForwardTo&&e.fixed32.encode(d,n.fastForwardTo),n.initiator&&o.encode(d,n.initiator)},decode(d){const n=e.fixed32.decode(d),c=e.buffer.decode(d),r=e.uint.decode(d);return{roomKey:n,encryptionKey:c,fastForwardTo:1&r?e.fixed32.decode(d):null,initiator:2&r?o.decode(d):null}}},Mc=Pn,Cc={preencode(e,d){Mc.preencode(e,d.invitation)},encode(e,d){Mc.encode(e,d.invitation)},decode:e=>({invitation:Mc.decode(e)})},Vc={preencode(d,o){e.fixed32.preencode(d,o.mailbox),r.preencode(d,o.keyPair),e.buffer.preencode(d,o.response)},encode(d,o){e.fixed32.encode(d,o.mailbox),r.encode(d,o.keyPair),e.buffer.encode(d,o.response)},decode:d=>({mailbox:e.fixed32.decode(d),keyPair:r.decode(d),response:e.buffer.decode(d)})},Hc=Z,Dc={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.mailbox&&e.fixed32.preencode(d,n.mailbox)},encode(d,n){const c=(n.fastForwardTo?1:0)|(n.initiator?2:0)|(n.mailbox?4:0);e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.uint.encode(d,c),n.fastForwardTo&&e.fixed32.encode(d,n.fastForwardTo),n.initiator&&o.encode(d,n.initiator),n.mailbox&&e.fixed32.encode(d,n.mailbox)},decode(d){const n=e.fixed32.decode(d),c=e.buffer.decode(d),r=e.uint.decode(d);return{roomKey:n,encryptionKey:c,fastForwardTo:1&r?e.fixed32.decode(d):null,initiator:2&r?o.decode(d):null,mailbox:4&r?e.fixed32.decode(d):null}}},Lc=e.frame(Dc),qc={preencode(o,n){Lc.preencode(o,n.keys),o.end++,d>=39&&n.activeClock&&e.uint.preencode(o,n.activeClock)},encode(o,n){const c=(d>=39&&n.activeClock?1:0)|(d>=39&&n.isReadOnly?2:0);Lc.encode(o,n.keys),e.uint.encode(o,c),d>=39&&n.activeClock&&e.uint.encode(o,n.activeClock)},decode(o){const n=Lc.decode(o),c=o.start<o.end?e.uint.decode(o):0;return{keys:n,activeClock:d>=39&&1&c?e.uint.decode(o):0,isReadOnly:d>=39&&!!(2&c)}}},jc=e.frame(dn),Ec={preencode(d,n){e.fixed32.preencode(d,n.roomKey),e.buffer.preencode(d,n.encryptionKey),d.end++,n.fastForwardTo&&e.fixed32.preencode(d,n.fastForwardTo),n.initiator&&o.preencode(d,n.initiator),n.mailbox&&e.fixed32.preencode(d,n.mailbox),n.keyPair&&r.preencode(d,n.keyPair),n.genesis&&jc.preencode(d,n.genesis)},encode(d,n){const c=(n.fastForwardTo?1:0)|(n.initiator?2:0)|(n.mailbox?4:0)|(n.keyPair?8:0)|(n.genesis?16:0)|(n.isPrivateProfile?32:0);e.fixed32.encode(d,n.roomKey),e.buffer.encode(d,n.encryptionKey),e.uint.encode(d,c),n.fastForwardTo&&e.fixed32.encode(d,n.fastForwardTo),n.initiator&&o.encode(d,n.initiator),n.mailbox&&e.fixed32.encode(d,n.mailbox),n.keyPair&&r.encode(d,n.keyPair),n.genesis&&jc.encode(d,n.genesis)},decode(d){const n=e.fixed32.decode(d),c=e.buffer.decode(d),t=e.uint.decode(d);return{roomKey:n,encryptionKey:c,fastForwardTo:1&t?e.fixed32.decode(d):null,initiator:2&t?o.decode(d):null,mailbox:4&t?e.fixed32.decode(d):null,keyPair:8&t?r.decode(d):null,genesis:16&t?jc.decode(d):null,isPrivateProfile:!!(32&t)}}},Bc={preencode(d,o){e.fixed32.preencode(d,o.roomKey),d.end++},encode(d,o){const n=o.isGossiped?1:0;e.fixed32.encode(d,o.roomKey),e.uint.encode(d,n)},decode:d=>({roomKey:e.fixed32.decode(d),isGossiped:!!(1&e.uint.decode(d))})},zc={preencode(d,o){e.fixed32.preencode(d,o.roomKey)},encode(d,o){e.fixed32.encode(d,o.roomKey)},decode:d=>({roomKey:e.fixed32.decode(d)})},Oc={preencode(d,o){e.string.preencode(d,o.mnemonic),d.end++,o.profileDiscoveryTimeout&&e.uint.preencode(d,o.profileDiscoveryTimeout)},encode(d,o){const n=(o.profileDiscoveryTimeout?1:0)|(o.recover?2:0);e.string.encode(d,o.mnemonic),e.uint.encode(d,n),o.profileDiscoveryTimeout&&e.uint.encode(d,o.profileDiscoveryTimeout)},decode(d){const o=e.string.decode(d),n=e.uint.decode(d);return{mnemonic:o,profileDiscoveryTimeout:1&n?e.uint.decode(d):0,recover:!!(2&n)}}},Nc={preencode(o,n){e.fixed32.preencode(o,n.roomKey),e.fixed32.preencode(o,n.memberKey),o.end++,n.message&&e.string.preencode(o,n.message),d>=6&&n.contactInfo&&ds.preencode(o,n.contactInfo)},encode(o,n){const c=(n.message?1:0)|(d>=6&&n.contactInfo?2:0);e.fixed32.encode(o,n.roomKey),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,c),n.message&&e.string.encode(o,n.message),d>=6&&n.contactInfo&&ds.encode(o,n.contactInfo)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{roomKey:n,memberKey:c,message:1&r?e.string.decode(o):null,contactInfo:d>=6&&2&r?ds.decode(o):null}}},Uc={preencode(d,o){e.fixed32.preencode(d,o.key),d.end++},encode(d,o){const n=o.isPrivateProfile?1:0;e.fixed32.encode(d,o.key),e.uint.encode(d,n)},decode:d=>({key:e.fixed32.decode(d),isPrivateProfile:!!(1&e.uint.decode(d))})},Jc=e.frame(Oc),Wc=e.frame(Ec),Gc=e.frame(Bc),Qc=e.frame(zc),Xc=e.frame(Cc),Yc=e.frame(qc),Zc=e.frame(Vc),$c=e.frame(Nc),_c=e.frame(Uc),er={preencode(d,o){const n=(o.restoreIdentity?1:0)|(o.createRoom?2:0)|(o.leaveRoom?4:0)|(o.clearRoom?8:0)|(o.joinRoomInvitation?16:0)|(o.joinRoomKeys?32:0)|(o.joinRoomResponse?64:0)|(o.sendContactRequest?128:0)|(o.migrateV2Room?256:0);e.fixed32.preencode(d,o.discoveryKey),e.uint.preencode(d,o.priority),e.uint.preencode(d,o.timestamp),e.uint.preencode(d,o.type),e.uint.preencode(d,n),o.restoreIdentity&&Jc.preencode(d,o.restoreIdentity),o.createRoom&&Wc.preencode(d,o.createRoom),o.leaveRoom&&Gc.preencode(d,o.leaveRoom),o.clearRoom&&Qc.preencode(d,o.clearRoom),o.joinRoomInvitation&&Xc.preencode(d,o.joinRoomInvitation),o.joinRoomKeys&&Yc.preencode(d,o.joinRoomKeys),o.joinRoomResponse&&Zc.preencode(d,o.joinRoomResponse),o.sendContactRequest&&$c.preencode(d,o.sendContactRequest),o.migrateV2Room&&_c.preencode(d,o.migrateV2Room)},encode(d,o){const n=(o.restoreIdentity?1:0)|(o.createRoom?2:0)|(o.leaveRoom?4:0)|(o.clearRoom?8:0)|(o.joinRoomInvitation?16:0)|(o.joinRoomKeys?32:0)|(o.joinRoomResponse?64:0)|(o.sendContactRequest?128:0)|(o.migrateV2Room?256:0);e.fixed32.encode(d,o.discoveryKey),e.uint.encode(d,o.priority),e.uint.encode(d,o.timestamp),e.uint.encode(d,o.type),e.uint.encode(d,n),o.restoreIdentity&&Jc.encode(d,o.restoreIdentity),o.createRoom&&Wc.encode(d,o.createRoom),o.leaveRoom&&Gc.encode(d,o.leaveRoom),o.clearRoom&&Qc.encode(d,o.clearRoom),o.joinRoomInvitation&&Xc.encode(d,o.joinRoomInvitation),o.joinRoomKeys&&Yc.encode(d,o.joinRoomKeys),o.joinRoomResponse&&Zc.encode(d,o.joinRoomResponse),o.sendContactRequest&&$c.encode(d,o.sendContactRequest),o.migrateV2Room&&_c.encode(d,o.migrateV2Room)},decode(d){const o=e.fixed32.decode(d),n=e.uint.decode(d),c=e.uint.decode(d),r=e.uint.decode(d),t=e.uint.decode(d);return{discoveryKey:o,priority:n,timestamp:c,type:r,restoreIdentity:1&t?Jc.decode(d):null,createRoom:2&t?Wc.decode(d):null,leaveRoom:4&t?Gc.decode(d):null,clearRoom:8&t?Qc.decode(d):null,joinRoomInvitation:16&t?Xc.decode(d):null,joinRoomKeys:32&t?Yc.decode(d):null,joinRoomResponse:64&t?Zc.decode(d):null,sendContactRequest:128&t?$c.decode(d):null,migrateV2Room:256&t?_c.decode(d):null}}},dr=Le,or={preencode(d,o){e.buffer.preencode(d,o.seed),dr.preencode(d,o.invitation)},encode(d,o){e.buffer.encode(d,o.seed),dr.encode(d,o.invitation)},decode:d=>({seed:e.buffer.decode(d),invitation:dr.decode(d)})},nr={preencode(e,d){e.end++},encode(o,n){const c=(n.isWritable?1:0)|(n.isReadable?2:0)|(n.isPrivateProfile?4:0)|(d>=8&&n.isRemoved?8:0);e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o);return{isWritable:!!(1&n),isReadable:!!(2&n),isPrivateProfile:!!(4&n),isRemoved:d>=8&&!!(8&n)}}},cr={preencode(d,o){e.uint.preencode(d,o.creation),e.uint.preencode(d,o.latestSync),e.uint.preencode(d,o.latestChatMessage)},encode(d,o){e.uint.encode(d,o.creation),e.uint.encode(d,o.latestSync),e.uint.encode(d,o.latestChatMessage)},decode:d=>({creation:e.uint.decode(d),latestSync:e.uint.decode(d),latestChatMessage:e.uint.decode(d)})},rr=Xo,tr=fo,ir=e.frame(cr),ar=vc,sr=e.frame(nr),pr=e.frame(ie),lr=e.frame(ud),ur=Oo,fr=$o,mr=e.frame(ho),yr=X,br=e.frame(sd),xr=Fn,vr={preencode(o,n){const c=(n.selfDevice?1:0)|(n.selfMember?2:0)|(n.config?4:0)|(n.identity?8:0)|(n.lastMessage?16:0)|(n.dm?32:0)|(d>=19&&n.readLengths?64:0)|(d>=19&&n.lastMember?128:0)|(d>=21&&n.version?256:0)|(d>=27&&n.preferences?512:0)|(d>=28&&n.activeCall?1024:0)|(d>=32&&n.lastMessageLabels?2048:0)|(d>=33&&n.settings?4096:0)|(d>=37&&n.system?8192:0)|(d>=37&&n.processed?16384:0);e.fixed32.preencode(o,n.roomKey),e.fixed32.preencode(o,n.discoveryKey),e.buffer.preencode(o,n.encryptionKey),rr.preencode(o,n.digest),tr.preencode(o,n.stats),ir.preencode(o,n.timestamps),e.uint.preencode(o,n.fork),e.uint.preencode(o,n.length),e.fixed32.preencode(o,n.seed),ar.preencode(o,n.capabilities),sr.preencode(o,n.status),e.uint.preencode(o,c),n.selfDevice&&pr.preencode(o,n.selfDevice),n.selfMember&&lr.preencode(o,n.selfMember),n.config&&ur.preencode(o,n.config),n.identity&&fr.preencode(o,n.identity),n.lastMessage&&mr.preencode(o,n.lastMessage),n.dm&&yr.preencode(o,n.dm),d>=19&&n.readLengths&&os.preencode(o,n.readLengths),d>=19&&n.lastMember&&br.preencode(o,n.lastMember),d>=21&&n.version&&e.uint.preencode(o,n.version),d>=27&&n.preferences&&xr.preencode(o,n.preferences),d>=28&&n.activeCall&&ns.preencode(o,n.activeCall),d>=32&&n.lastMessageLabels&&cs.preencode(o,n.lastMessageLabels),d>=33&&n.settings&&rs.preencode(o,n.settings),d>=37&&n.system&&ts.preencode(o,n.system),d>=37&&n.processed&&is.preencode(o,n.processed)},encode(o,n){const c=(n.selfDevice?1:0)|(n.selfMember?2:0)|(n.config?4:0)|(n.identity?8:0)|(n.lastMessage?16:0)|(n.dm?32:0)|(d>=19&&n.readLengths?64:0)|(d>=19&&n.lastMember?128:0)|(d>=21&&n.version?256:0)|(d>=27&&n.preferences?512:0)|(d>=28&&n.activeCall?1024:0)|(d>=32&&n.lastMessageLabels?2048:0)|(d>=33&&n.settings?4096:0)|(d>=37&&n.system?8192:0)|(d>=37&&n.processed?16384:0);e.fixed32.encode(o,n.roomKey),e.fixed32.encode(o,n.discoveryKey),e.buffer.encode(o,n.encryptionKey),rr.encode(o,n.digest),tr.encode(o,n.stats),ir.encode(o,n.timestamps),e.uint.encode(o,n.fork),e.uint.encode(o,n.length),e.fixed32.encode(o,n.seed),ar.encode(o,n.capabilities),sr.encode(o,n.status),e.uint.encode(o,c),n.selfDevice&&pr.encode(o,n.selfDevice),n.selfMember&&lr.encode(o,n.selfMember),n.config&&ur.encode(o,n.config),n.identity&&fr.encode(o,n.identity),n.lastMessage&&mr.encode(o,n.lastMessage),n.dm&&yr.encode(o,n.dm),d>=19&&n.readLengths&&os.encode(o,n.readLengths),d>=19&&n.lastMember&&br.encode(o,n.lastMember),d>=21&&n.version&&e.uint.encode(o,n.version),d>=27&&n.preferences&&xr.encode(o,n.preferences),d>=28&&n.activeCall&&ns.encode(o,n.activeCall),d>=32&&n.lastMessageLabels&&cs.encode(o,n.lastMessageLabels),d>=33&&n.settings&&rs.encode(o,n.settings),d>=37&&n.system&&ts.encode(o,n.system),d>=37&&n.processed&&is.encode(o,n.processed)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.buffer.decode(o),t=rr.decode(o),i=tr.decode(o),a=ir.decode(o),s=e.uint.decode(o),p=e.uint.decode(o),l=e.fixed32.decode(o),u=ar.decode(o),f=sr.decode(o),m=e.uint.decode(o);return{roomKey:n,discoveryKey:c,encryptionKey:r,digest:t,stats:i,timestamps:a,fork:s,length:p,seed:l,capabilities:u,status:f,selfDevice:1&m?pr.decode(o):null,selfMember:2&m?lr.decode(o):null,config:4&m?ur.decode(o):null,identity:8&m?fr.decode(o):null,lastMessage:16&m?mr.decode(o):null,dm:32&m?yr.decode(o):null,readLengths:d>=19&&64&m?os.decode(o):null,lastMember:d>=19&&128&m?br.decode(o):null,version:d>=21&&256&m?e.uint.decode(o):0,preferences:d>=27&&512&m?xr.decode(o):null,activeCall:d>=28&&1024&m?ns.decode(o):null,lastMessageLabels:d>=32&&2048&m?cs.decode(o):null,settings:d>=33&&4096&m?rs.decode(o):null,system:d>=37&&8192&m?ts.decode(o):null,processed:d>=37&&16384&m?is.decode(o):null}}},kr=Fn,gr={preencode(d,o){e.fixed32.preencode(d,o.roomKey),kr.preencode(d,o.status)},encode(d,o){e.fixed32.encode(d,o.roomKey),kr.encode(d,o.status)},decode:d=>({roomKey:e.fixed32.decode(d),status:kr.decode(d)})},Kr={preencode(o,n){e.fixed32.preencode(o,n.mailbox),e.fixed32.preencode(o,n.key),o.end++,n.roomKey&&e.fixed32.preencode(o,n.roomKey),n.keyPair&&r.preencode(o,n.keyPair),n.responseKeyPair&&r.preencode(o,n.responseKeyPair),d>=39&&n.activeClock&&e.uint.preencode(o,n.activeClock)},encode(o,n){const c=(n.roomKey?1:0)|(n.keyPair?2:0)|(n.responseKeyPair?4:0)|(d>=38&&n.pending?8:0)|(d>=39&&n.activeClock?16:0);e.fixed32.encode(o,n.mailbox),e.fixed32.encode(o,n.key),e.uint.encode(o,c),n.roomKey&&e.fixed32.encode(o,n.roomKey),n.keyPair&&r.encode(o,n.keyPair),n.responseKeyPair&&r.encode(o,n.responseKeyPair),d>=39&&n.activeClock&&e.uint.encode(o,n.activeClock)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),t=e.uint.decode(o);return{mailbox:n,key:c,roomKey:1&t?e.fixed32.decode(o):null,keyPair:2&t?r.decode(o):null,responseKeyPair:4&t?r.decode(o):null,pending:d>=38&&!!(8&t),activeClock:d>=39&&16&t?e.uint.decode(o):0}}},hr=pe,wr={preencode(d,o){e.fixed32.preencode(d,o.key),hr.preencode(d,o.profile)},encode(d,o){e.fixed32.encode(d,o.key),hr.encode(d,o.profile)},decode:d=>({key:e.fixed32.decode(d),profile:hr.decode(d)})},Pr=pr,Tr={preencode(d,o){e.fixed32.preencode(d,o.roomKey),Pr.preencode(d,o.device)},encode(d,o){e.fixed32.encode(d,o.roomKey),Pr.encode(d,o.device)},decode:d=>({roomKey:e.fixed32.decode(d),device:Pr.decode(d)})},Rr=g,Ar={preencode(o,n){Rr.preencode(o,n.file),e.fixed32.preencode(o,n.roomKey),o.end++,n.encryptionKey&&e.buffer.preencode(o,n.encryptionKey),d>=28&&n.lastAccessed&&e.uint.preencode(o,n.lastAccessed),d>=28&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(n.encryptionKey?1:0)|(n.cleared?2:0)|(n.own?4:0)|(d>=28&&n.lastAccessed?8:0)|(d>=28&&n.version?16:0);Rr.encode(o,n.file),e.fixed32.encode(o,n.roomKey),e.uint.encode(o,c),n.encryptionKey&&e.buffer.encode(o,n.encryptionKey),d>=28&&n.lastAccessed&&e.uint.encode(o,n.lastAccessed),d>=28&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=Rr.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{file:n,roomKey:c,encryptionKey:1&r?e.buffer.decode(o):null,cleared:!!(2&r),own:!!(4&r),lastAccessed:d>=28&&8&r?e.uint.decode(o):0,version:d>=28&&16&r?e.uint.decode(o):0}}},Sr=$,Ir={preencode(o,c){Sr.preencode(o,c.header),n.preencode(o,c.oplog),e.uint.preencode(o,c.index),as.preencode(o,c.preview),o.end++,d>=12&&c.displayType&&Gr.preencode(o,c.displayType)},encode(o,c){const r=d>=12&&c.displayType?1:0;Sr.encode(o,c.header),n.encode(o,c.oplog),e.uint.encode(o,c.index),as.encode(o,c.preview),e.uint.encode(o,r),d>=12&&c.displayType&&Gr.encode(o,c.displayType)},decode(o){const c=Sr.decode(o),r=n.decode(o),t=e.uint.decode(o),i=as.decode(o),a=o.start<o.end?e.uint.decode(o):0;return{header:c,oplog:r,index:t,preview:i,displayType:d>=12&&1&a?Gr.decode(o):0}}},Fr={preencode(o,n){o.end++,d>=4&&n.memberKey&&e.fixed32.preencode(o,n.memberKey)},encode(o,n){const c=d>=4&&n.memberKey?1:0;e.uint.encode(o,c),d>=4&&n.memberKey&&e.fixed32.encode(o,n.memberKey)},decode(o){const n=e.uint.decode(o);return{memberKey:d>=4&&1&n?e.fixed32.decode(o):null}}},Mr=pe,Cr={preencode(e,d){Mr.preencode(e,d.profile),ne.preencode(e,d.attestation)},encode(e,d){Mr.encode(e,d.profile),ne.encode(e,d.attestation)},decode:e=>({profile:Mr.decode(e),attestation:ne.decode(e)})},Vr=$,Hr={preencode(d,o){Vr.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){Vr.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:Vr.decode(d),key:e.fixed32.decode(d)})},Dr={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),ne.preencode(d,o.privateProfileIdentity),e.buffer.preencode(d,o.deviceProof)},encode(d,o){e.fixed32.encode(d,o.deviceKey),ne.encode(d,o.privateProfileIdentity),e.buffer.encode(d,o.deviceProof)},decode:d=>({deviceKey:e.fixed32.decode(d),privateProfileIdentity:ne.decode(d),deviceProof:e.buffer.decode(d)})},Lr={preencode(o,n){e.fixed32.preencode(o,n.roomKey),e.fixed32.preencode(o,n.encryptionKey),e.fixed32.preencode(o,n.seed),o.end++,d>=9&&n.fastForwardTo&&e.fixed32.preencode(o,n.fastForwardTo)},encode(o,n){const c=d>=9&&n.fastForwardTo?1:0;e.fixed32.encode(o,n.roomKey),e.fixed32.encode(o,n.encryptionKey),e.fixed32.encode(o,n.seed),e.uint.encode(o,c),d>=9&&n.fastForwardTo&&e.fixed32.encode(o,n.fastForwardTo)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o);return{roomKey:n,encryptionKey:c,seed:r,fastForwardTo:d>=9&&1&t?e.fixed32.decode(o):null}}},qr={preencode(o,n){e.fixed32.preencode(o,n.publicKey),e.fixed32.preencode(o,n.writerKey),e.fixed32.preencode(o,n.devicePublicKey),o.end++,d>=9&&n.privateProfileKey&&e.fixed32.preencode(o,n.privateProfileKey)},encode(o,n){const c=d>=9&&n.privateProfileKey?1:0;e.fixed32.encode(o,n.publicKey),e.fixed32.encode(o,n.writerKey),e.fixed32.encode(o,n.devicePublicKey),e.uint.encode(o,c),d>=9&&n.privateProfileKey&&e.fixed32.encode(o,n.privateProfileKey)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o);return{publicKey:n,writerKey:c,devicePublicKey:r,privateProfileKey:d>=9&&1&t?e.fixed32.decode(o):null}}},jr=$,Er={preencode(d,o){jr.preencode(d,o.header),e.fixed32.preencode(d,o.memberKey)},encode(d,o){jr.encode(d,o.header),e.fixed32.encode(d,o.memberKey)},decode:d=>({header:jr.decode(d),memberKey:e.fixed32.decode(d)})},Br={preencode(d,o){e.fixed32.preencode(d,o.privateProfileKey)},encode(d,o){e.fixed32.encode(d,o.privateProfileKey)},decode:d=>({privateProfileKey:e.fixed32.decode(d)})},zr={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.responsePublicKey)},encode(d,o){e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.responsePublicKey)},decode:d=>({key:e.fixed32.decode(d),responsePublicKey:e.fixed32.decode(d)})},Or={preencode(o,n){e.fixed32.preencode(o,n.roomKey),o.end++,d>=10&&n.repairs&&e.uint.preencode(o,n.repairs)},encode(o,n){const c=d>=10&&n.repairs?1:0;e.fixed32.encode(o,n.roomKey),e.uint.encode(o,c),d>=10&&n.repairs&&e.uint.encode(o,n.repairs)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o);return{roomKey:n,repairs:d>=10&&1&c?e.uint.decode(o):0}}},Nr={preencode(o,n){o.end++,d>=11&&n.key&&e.string.preencode(o,n.key),d>=11&&n.description&&e.string.preencode(o,n.description)},encode(o,n){const c=(d>=11&&n.key?1:0)|(d>=11&&n.value?2:0)|(d>=11&&n.description?4:0);e.uint.encode(o,c),d>=11&&n.key&&e.string.encode(o,n.key),d>=11&&n.description&&e.string.encode(o,n.description)},decode(o){const n=e.uint.decode(o);return{key:d>=11&&1&n?e.string.decode(o):null,value:d>=11&&!!(2&n),description:d>=11&&4&n?e.string.decode(o):null}}},Ur=e.array(e.frame(Nr)),Jr={preencode(e,o){e.end++,d>=11&&o.flags&&Ur.preencode(e,o.flags)},encode(o,n){const c=d>=11&&n.flags?1:0;e.uint.encode(o,c),d>=11&&n.flags&&Ur.encode(o,n.flags)},decode(o){const n=e.uint.decode(o);return{flags:d>=11&&1&n?Ur.decode(o):null}}},Wr={HttpLink:1,PearLink:2},Gr={preencode(e,d){e.end++},encode(d,o){if(o>2)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},Qr=$,Xr={preencode(d,o){Qr.preencode(d,o.header),e.uint.preencode(d,o.value)},encode(d,o){Qr.encode(d,o.header),e.uint.encode(d,o.value)},decode:d=>({header:Qr.decode(d),value:e.uint.decode(d)})},Yr={preencode(d,o){e.uint.preencode(d,o.key),e.uint.preencode(d,o.value)},encode(d,o){e.uint.encode(d,o.key),e.uint.encode(d,o.value)},decode:d=>({key:e.uint.decode(d),value:e.uint.decode(d)})},Zr=$,$r={preencode(o,n){Zr.preencode(o,n.header),e.uint.preencode(o,n.from),e.uint.preencode(o,n.to),o.end++,d>=29&&n.buildType&&xi.preencode(o,n.buildType)},encode(o,n){const c=d>=29&&n.buildType?1:0;Zr.encode(o,n.header),e.uint.encode(o,n.from),e.uint.encode(o,n.to),e.uint.encode(o,c),d>=29&&n.buildType&&xi.encode(o,n.buildType)},decode(o){const n=Zr.decode(o),c=e.uint.decode(o),r=e.uint.decode(o),t=o.start<o.end?e.uint.decode(o):0;return{header:n,from:c,to:r,buildType:d>=29&&1&t?xi.decode(o):null}}},_r={RoomType:1,IsExperimental:2,IsJoiningDisabled:3,IsAppendingDisabled:4,IsCallingDisabled:5,IsMembershipEventsDisabled:6,IsAttachmentsDisabled:7,IsLinksDisabled:8,IsRoomInviteHidden:9},et={preencode(e,d){e.end++},encode(d,o){if(o>9)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},dt=We,ot={preencode(o,n){o.end++,d>=16&&n.nodes&&dt.preencode(o,n.nodes),d>=24&&n.concurrency&&e.uint.preencode(o,n.concurrency),d>=24&&n.maxWindow&&e.uint.preencode(o,n.maxWindow),d>=24&&n.randomPunchInterval&&e.uint.preencode(o,n.randomPunchInterval),d>=24&&n.connectionKeepAlive&&e.uint.preencode(o,n.connectionKeepAlive)},encode(o,n){const c=(d>=16&&n.nodes?1:0)|(d>=24&&n.concurrency?2:0)|(d>=24&&n.maxWindow?4:0)|(d>=24&&n.randomPunchInterval?8:0)|(d>=24&&n.connectionKeepAlive?16:0);e.uint.encode(o,c),d>=16&&n.nodes&&dt.encode(o,n.nodes),d>=24&&n.concurrency&&e.uint.encode(o,n.concurrency),d>=24&&n.maxWindow&&e.uint.encode(o,n.maxWindow),d>=24&&n.randomPunchInterval&&e.uint.encode(o,n.randomPunchInterval),d>=24&&n.connectionKeepAlive&&e.uint.encode(o,n.connectionKeepAlive)},decode(o){const n=e.uint.decode(o);return{nodes:d>=16&&1&n?dt.decode(o):null,concurrency:d>=24&&2&n?e.uint.decode(o):0,maxWindow:d>=24&&4&n?e.uint.decode(o):0,randomPunchInterval:d>=24&&8&n?e.uint.decode(o):0,connectionKeepAlive:d>=24&&16&n?e.uint.decode(o):0}}},nt={en:"en",it:"it",ru:"ru",es:"es",de:"de"},ct={preencode(e,d){e.end++},encode(d,o){switch(o){case"en":e.uint.encode(d,1);break;case"it":e.uint.encode(d,2);break;case"ru":e.uint.encode(d,3);break;case"es":e.uint.encode(d,4);break;case"de":e.uint.encode(d,5);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"en";case 2:return"it";case 3:return"ru";case 4:return"es";case 5:return"de";default:return null}}},rt=Hd,tt={preencode(d,o){rt.preencode(d,o.range),ct.preencode(d,o.language),e.string.preencode(d,o.text)},encode(d,o){rt.encode(d,o.range),ct.encode(d,o.language),e.string.encode(d,o.text)},decode:d=>({range:rt.decode(d),language:ct.decode(d),text:e.string.decode(d)})},it={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.count)},encode(d,o){e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.count)},decode:d=>({roomKey:e.fixed32.decode(d),count:e.uint.decode(d)})},at={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.key)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.key)},decode:d=>({deviceKey:e.fixed32.decode(d),key:e.fixed32.decode(d)})},st=$,pt={preencode(d,o){st.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){st.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:st.decode(d),key:e.fixed32.decode(d)})},lt=$,ut={preencode(d,o){lt.preencode(d,o.header),e.fixed32.preencode(d,o.key)},encode(d,o){lt.encode(d,o.header),e.fixed32.encode(d,o.key)},decode:d=>({header:lt.decode(d),key:e.fixed32.decode(d)})},ft={Flag:1},mt={preencode(e,d){e.end++},encode(d,o){if(o>1)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},yt={preencode(d,o){uo.preencode(d,o.id),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),mt.preencode(d,o.label)},encode(d,o){uo.encode(d,o.id),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),mt.encode(d,o.label)},decode:d=>({id:uo.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),label:mt.decode(d)})},bt=$,xt={preencode(e,d){bt.preencode(e,d.header),n.preencode(e,d.oplog),mt.preencode(e,d.label)},encode(e,d){bt.encode(e,d.header),n.encode(e,d.oplog),mt.encode(e,d.label)},decode:e=>({header:bt.decode(e),oplog:n.decode(e),label:mt.decode(e)})},vt=$,kt={preencode(e,d){vt.preencode(e,d.header),n.preencode(e,d.oplog),mt.preencode(e,d.label)},encode(e,d){vt.encode(e,d.header),n.encode(e,d.oplog),mt.encode(e,d.label)},decode:e=>({header:vt.decode(e),oplog:n.decode(e),label:mt.decode(e)})},gt={preencode(d,o){mt.preencode(d,o.label),e.uint.preencode(d,o.count)},encode(d,o){mt.encode(d,o.label),e.uint.encode(d,o.count)},decode:d=>({label:mt.decode(d),count:e.uint.decode(d)})},Kt=e.array(e.frame(gt)),ht={preencode(o,n){uo.preencode(o,n.id),e.uint.preencode(o,n.total),Kt.preencode(o,n.labels),e.uint.preencode(o,n.editedAt),o.end++,d>=24&&n.flagsClock&&e.uint.preencode(o,n.flagsClock),d>=24&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(d>=24&&n.flagsClock?1:0)|(d>=24&&n.version?2:0)|(d>=25&&n.isDeleted?4:0);uo.encode(o,n.id),e.uint.encode(o,n.total),Kt.encode(o,n.labels),e.uint.encode(o,n.editedAt),e.uint.encode(o,c),d>=24&&n.flagsClock&&e.uint.encode(o,n.flagsClock),d>=24&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=uo.decode(o),c=e.uint.decode(o),r=Kt.decode(o),t=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{id:n,total:c,labels:r,editedAt:t,flagsClock:d>=24&&1&i?e.uint.decode(o):0,version:d>=24&&2&i?e.uint.decode(o):0,isDeleted:d>=25&&!!(4&i)}}},wt=$,Pt={preencode(d,o){wt.preencode(d,o.header),e.uint.preencode(d,o.length)},encode(d,o){wt.encode(d,o.header),e.uint.encode(d,o.length)},decode:d=>({header:wt.decode(d),length:e.uint.decode(d)})},Tt={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.length)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.length)},decode:d=>({memberKey:e.fixed32.decode(d),length:e.uint.decode(d)})},Rt=Z,At={preencode(o,n){o.end++,d>=33&&n.profileSnoozeTime&&e.uint.preencode(o,n.profileSnoozeTime)},encode(o,n){const c=(d>=19&&n.disableReadReceipts?1:0)|(d>=31&&n.stripAttachmentMetadata?2:0)|(d>=33&&n.profileSnoozeTime?4:0);e.uint.encode(o,c),d>=33&&n.profileSnoozeTime&&e.uint.encode(o,n.profileSnoozeTime)},decode(o){const n=e.uint.decode(o);return{disableReadReceipts:d>=19&&!!(1&n),stripAttachmentMetadata:d>=31&&!!(2&n),profileSnoozeTime:d>=33&&4&n?e.uint.decode(o):0}}},St={disableReadReceipts:"disableReadReceipts",stripAttachmentMetadata:"stripAttachmentMetadata",profileSnoozeTime:"profileSnoozeTime"},It={preencode(e,d){e.end++},encode(d,o){switch(o){case"disableReadReceipts":e.uint.encode(d,1);break;case"stripAttachmentMetadata":e.uint.encode(d,2);break;case"profileSnoozeTime":e.uint.encode(d,3);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"disableReadReceipts";case 2:return"stripAttachmentMetadata";case 3:return"profileSnoozeTime";default:return null}}},Ft=$,Mt=e.frame(At),Ct={preencode(e,d){Ft.preencode(e,d.header),It.preencode(e,d.key),Mt.preencode(e,d.settings)},encode(e,d){Ft.encode(e,d.header),It.encode(e,d.key),Mt.encode(e,d.settings)},decode:e=>({header:Ft.decode(e),key:It.decode(e),settings:Mt.decode(e)})},Vt={preencode(o,n){o.end++,d>=20&&n.roomKey&&e.fixed32.preencode(o,n.roomKey),d>=23&&n.coreKey&&e.fixed32.preencode(o,n.coreKey)},encode(o,n){const c=(d>=20&&n.roomKey?1:0)|(d>=23&&n.coreKey?2:0);e.uint.encode(o,c),d>=20&&n.roomKey&&e.fixed32.encode(o,n.roomKey),d>=23&&n.coreKey&&e.fixed32.encode(o,n.coreKey)},decode(o){const n=e.uint.decode(o);return{roomKey:d>=20&&1&n?e.fixed32.decode(o):null,coreKey:d>=23&&2&n?e.fixed32.decode(o):null}}},Ht=e.frame(Vt),Dt={preencode(o,n){e.string.preencode(o,n.code),e.string.preencode(o,n.message),e.string.preencode(o,n.stack),e.uint.preencode(o,n.timestamp),o.end++,d>=20&&n.details&&Ht.preencode(o,n.details)},encode(o,n){const c=d>=20&&n.details?1:0;e.string.encode(o,n.code),e.string.encode(o,n.message),e.string.encode(o,n.stack),e.uint.encode(o,n.timestamp),e.uint.encode(o,c),d>=20&&n.details&&Ht.encode(o,n.details)},decode(o){const n=e.string.decode(o),c=e.string.decode(o),r=e.string.decode(o),t=e.uint.decode(o),i=e.uint.decode(o);return{code:n,message:c,stack:r,timestamp:t,details:d>=20&&1&i?Ht.decode(o):null}}},Lt={RESUME:1,WAKEUP:2,PRESUSPEND:3,SUSPEND:4},qt={preencode(e,d){e.end++},encode(d,o){if(o>4)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},jt={preencode(d,o){e.fixed32.preencode(d,o.roomKey),e.uint.preencode(d,o.total)},encode(d,o){e.fixed32.encode(d,o.roomKey),e.uint.encode(d,o.total)},decode:d=>({roomKey:e.fixed32.decode(d),total:e.uint.decode(d)})},Et={Flag:1},Bt={preencode(e,d){e.end++},encode(d,o){if(o>1)throw new Error("Unknown enum");e.uint.encode(d,o)},decode:d=>e.uint.decode(d)},zt={preencode(d,o){e.fixed32.preencode(d,o.key),e.fixed32.preencode(d,o.sender),e.uint.preencode(d,o.clock),Bt.preencode(d,o.label)},encode(d,o){e.fixed32.encode(d,o.key),e.fixed32.encode(d,o.sender),e.uint.encode(d,o.clock),Bt.encode(d,o.label)},decode:d=>({key:e.fixed32.decode(d),sender:e.fixed32.decode(d),clock:e.uint.decode(d),label:Bt.decode(d)})},Ot=$,Nt={preencode(d,o){Ot.preencode(d,o.header),e.fixed32.preencode(d,o.key),Bt.preencode(d,o.label)},encode(d,o){Ot.encode(d,o.header),e.fixed32.encode(d,o.key),Bt.encode(d,o.label)},decode:d=>({header:Ot.decode(d),key:e.fixed32.decode(d),label:Bt.decode(d)})},Ut={preencode(d,o){Bt.preencode(d,o.label),e.uint.preencode(d,o.count)},encode(d,o){Bt.encode(d,o.label),e.uint.encode(d,o.count)},decode:d=>({label:Bt.decode(d),count:e.uint.decode(d)})},Jt=e.array(e.frame(Ut)),Wt={preencode(d,o){e.fixed32.preencode(d,o.key),e.uint.preencode(d,o.total),Jt.preencode(d,o.labels),e.uint.preencode(d,o.editedAt),e.uint.preencode(d,o.flagsClock)},encode(d,o){e.fixed32.encode(d,o.key),e.uint.encode(d,o.total),Jt.encode(d,o.labels),e.uint.encode(d,o.editedAt),e.uint.encode(d,o.flagsClock)},decode:d=>({key:e.fixed32.decode(d),total:e.uint.decode(d),labels:Jt.decode(d),editedAt:e.uint.decode(d),flagsClock:e.uint.decode(d)})},Gt={preencode(d,o){e.float64.preencode(d,o.latitude),e.float64.preencode(d,o.longitude)},encode(d,o){e.float64.encode(d,o.latitude),e.float64.encode(d,o.longitude)},decode:d=>({latitude:e.float64.decode(d),longitude:e.float64.decode(d)})},Qt=$,Xt={preencode(d,o){Qt.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),e.fixed32.preencode(d,o.fromDeviceKey)},encode(d,o){Qt.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.fixed32.encode(d,o.fromDeviceKey)},decode:d=>({header:Qt.decode(d),deviceKey:e.fixed32.decode(d),fromDeviceKey:e.fixed32.decode(d)})},Yt=$,Zt=X,$t={preencode(o,n){Yt.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),e.buffer.preencode(o,n.encryptionKey),o.end++,d>=28&&n.streams&&Zt.preencode(o,n.streams),d>=28&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=28&&n.version&&e.uint.preencode(o,n.version),d>=36&&n.streamInputs&&ss.preencode(o,n.streamInputs),d>=36&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey)},encode(o,n){const c=(d>=28&&n.streams?1:0)|(d>=28&&n.discoveryKey?2:0)|(d>=28&&n.version?4:0)|(d>=36&&n.streamInputs?8:0)|(d>=36&&n.swarmKey?16:0);Yt.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,c),d>=28&&n.streams&&Zt.encode(o,n.streams),d>=28&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=28&&n.version&&e.uint.encode(o,n.version),d>=36&&n.streamInputs&&ss.encode(o,n.streamInputs),d>=36&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey)},decode(o){const n=Yt.decode(o),c=e.fixed32.decode(o),r=e.buffer.decode(o),t=e.uint.decode(o);return{header:n,callKey:c,encryptionKey:r,streams:d>=28&&1&t?Zt.decode(o):null,discoveryKey:d>=28&&2&t?e.fixed32.decode(o):null,version:d>=28&&4&t?e.uint.decode(o):0,streamInputs:d>=36&&8&t?ss.decode(o):null,swarmKey:d>=36&&16&t?e.fixed32.decode(o):null}}},_t=$,ei=X,di={preencode(o,n){_t.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),o.end++,d>=28&&n.streams&&ei.preencode(o,n.streams),d>=36&&n.streamInputs&&ps.preencode(o,n.streamInputs),d>=36&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey)},encode(o,n){const c=(d>=28&&n.streams?1:0)|(d>=36&&n.streamInputs?2:0)|(d>=36&&n.swarmKey?4:0);_t.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.uint.encode(o,c),d>=28&&n.streams&&ei.encode(o,n.streams),d>=36&&n.streamInputs&&ps.encode(o,n.streamInputs),d>=36&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey)},decode(o){const n=_t.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{header:n,callKey:c,streams:d>=28&&1&r?ei.decode(o):null,streamInputs:d>=36&&2&r?ps.decode(o):null,swarmKey:d>=36&&4&r?e.fixed32.decode(o):null}}},oi=$,ni={preencode(d,o){oi.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){oi.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:oi.decode(d),callKey:e.fixed32.decode(d)})},ci=$,ri={preencode(d,o){ci.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){ci.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:ci.decode(d),callKey:e.fixed32.decode(d)})},ti=$,ii={preencode(o,n){ti.preencode(o,n.header),e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.streamKey),o.end++,d>=36&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=36&&n.type&&e.string.preencode(o,n.type)},encode(o,n){const c=(d>=36&&n.mediaStreamId?1:0)|(d>=36&&n.type?2:0)|(d>=36&&n.muted?4:0);ti.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.streamKey),e.uint.encode(o,c),d>=36&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=36&&n.type&&e.string.encode(o,n.type)},decode(o){const n=ti.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=o.start<o.end?e.uint.decode(o):0;return{header:n,callKey:c,streamKey:r,mediaStreamId:d>=36&&1&t?e.string.decode(o):null,type:d>=36&&2&t?e.string.decode(o):null,muted:d>=36&&!!(4&t)}}},ai=$,si={preencode(d,o){ai.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.streamKey)},encode(d,o){ai.encode(d,o.header),e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.streamKey)},decode:d=>({header:ai.decode(d),callKey:e.fixed32.decode(d),streamKey:e.fixed32.decode(d)})},pi={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.buffer.preencode(o,n.encryptionKey),e.uint.preencode(o,n.createdAt),o.end++,d>=28&&n.endedAt&&e.uint.preencode(o,n.endedAt),d>=28&&n.discoveryKey&&e.fixed32.preencode(o,n.discoveryKey),d>=28&&n.version&&e.uint.preencode(o,n.version)},encode(o,n){const c=(d>=28&&n.endedAt?1:0)|(d>=28&&n.discoveryKey?2:0)|(d>=28&&n.version?4:0);e.fixed32.encode(o,n.callKey),e.buffer.encode(o,n.encryptionKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=28&&n.endedAt&&e.uint.encode(o,n.endedAt),d>=28&&n.discoveryKey&&e.fixed32.encode(o,n.discoveryKey),d>=28&&n.version&&e.uint.encode(o,n.version)},decode(o){const n=e.fixed32.decode(o),c=e.buffer.decode(o),r=e.uint.decode(o),t=e.uint.decode(o);return{callKey:n,encryptionKey:c,createdAt:r,endedAt:d>=28&&1&t?e.uint.decode(o):0,discoveryKey:d>=28&&2&t?e.fixed32.decode(o):null,version:d>=28&&4&t?e.uint.decode(o):0}}},li={preencode(d,o){e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.createdAt)},encode(d,o){e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.createdAt)},decode:d=>({callKey:e.fixed32.decode(d),memberKey:e.fixed32.decode(d),createdAt:e.uint.decode(d)})},ui={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.deviceKey),e.fixed32.preencode(o,n.memberKey),e.uint.preencode(o,n.createdAt),o.end++,d>=28&&n.swarmKey&&e.fixed32.preencode(o,n.swarmKey),d>=32&&n.lastHeartbeatAt&&e.uint.preencode(o,n.lastHeartbeatAt)},encode(o,n){const c=(d>=28&&n.swarmKey?1:0)|(d>=32&&n.lastHeartbeatAt?2:0)|(d>=33&&n.isRecording?4:0);e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.deviceKey),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=28&&n.swarmKey&&e.fixed32.encode(o,n.swarmKey),d>=32&&n.lastHeartbeatAt&&e.uint.encode(o,n.lastHeartbeatAt)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o),i=e.uint.decode(o);return{callKey:n,deviceKey:c,memberKey:r,createdAt:t,swarmKey:d>=28&&1&i?e.fixed32.decode(o):null,lastHeartbeatAt:d>=32&&2&i?e.uint.decode(o):0,isRecording:d>=33&&!!(4&i)}}},fi={preencode(o,n){e.fixed32.preencode(o,n.callKey),e.fixed32.preencode(o,n.deviceKey),e.buffer.preencode(o,n.streamKey),e.uint.preencode(o,n.createdAt),o.end++,d>=36&&n.mediaStreamId&&e.string.preencode(o,n.mediaStreamId),d>=36&&n.type&&e.string.preencode(o,n.type),d>=36&&n.statusKey&&e.uint.preencode(o,n.statusKey)},encode(o,n){const c=(d>=36&&n.mediaStreamId?1:0)|(d>=36&&n.type?2:0)|(d>=36&&n.statusKey?4:0);e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.deviceKey),e.buffer.encode(o,n.streamKey),e.uint.encode(o,n.createdAt),e.uint.encode(o,c),d>=36&&n.mediaStreamId&&e.string.encode(o,n.mediaStreamId),d>=36&&n.type&&e.string.encode(o,n.type),d>=36&&n.statusKey&&e.uint.encode(o,n.statusKey)},decode(o){const n=e.fixed32.decode(o),c=e.fixed32.decode(o),r=e.buffer.decode(o),t=e.uint.decode(o),i=o.start<o.end?e.uint.decode(o):0;return{callKey:n,deviceKey:c,streamKey:r,createdAt:t,mediaStreamId:d>=36&&1&i?e.string.decode(o):null,type:d>=36&&2&i?e.string.decode(o):null,statusKey:d>=36&&4&i?e.uint.decode(o):0}}},mi={preencode(o,n){e.fixed32.preencode(o,n.callKey),o.end++,d>=28&&n.selfDeviceKey&&e.fixed32.preencode(o,n.selfDeviceKey),d>=36&&n.createdAt&&e.uint.preencode(o,n.createdAt)},encode(o,n){const c=(d>=28&&n.selfDeviceKey?1:0)|(d>=36&&n.createdAt?2:0);e.fixed32.encode(o,n.callKey),e.uint.encode(o,c),d>=28&&n.selfDeviceKey&&e.fixed32.encode(o,n.selfDeviceKey),d>=36&&n.createdAt&&e.uint.encode(o,n.createdAt)},decode(o){const n=e.fixed32.decode(o),c=e.uint.decode(o);return{callKey:n,selfDeviceKey:d>=28&&1&c?e.fixed32.decode(o):null,createdAt:d>=36&&2&c?e.uint.decode(o):0}}},yi={preencode(d,o){e.uint.preencode(d,o.lastCleared)},encode(d,o){e.uint.encode(d,o.lastCleared)},decode:d=>({lastCleared:e.uint.decode(d)})},bi={Nightly:"Nightly",Internal:"Internal",Production:"Production"},xi={preencode(e,d){e.end++},encode(d,o){switch(o){case"Nightly":e.uint.encode(d,1);break;case"Internal":e.uint.encode(d,2);break;case"Production":e.uint.encode(d,3);break;default:throw new Error("Unknown enum")}},decode(d){switch(e.uint.decode(d)){case 1:return"Nightly";case 2:return"Internal";case 3:return"Production";default:return null}}},vi=$,ki={preencode(e,d){vi.preencode(e,d.header)},encode(e,d){vi.encode(e,d.header)},decode:e=>({header:vi.decode(e)})},gi=$,Ki={preencode(e,d){gi.preencode(e,d.header)},encode(e,d){gi.encode(e,d.header)},decode:e=>({header:gi.decode(e)})},hi={preencode(o,n){xi.preencode(o,n.buildType),o.end++,d>=30&&n.latestOfflineAbi&&e.uint.preencode(o,n.latestOfflineAbi)},encode(o,n){const c=d>=30&&n.latestOfflineAbi?1:0;xi.encode(o,n.buildType),e.uint.encode(o,c),d>=30&&n.latestOfflineAbi&&e.uint.encode(o,n.latestOfflineAbi)},decode(o){const n=xi.decode(o),c=o.start<o.end?e.uint.decode(o):0;return{buildType:n,latestOfflineAbi:d>=30&&1&c?e.uint.decode(o):0}}},wi=$,Pi={preencode(d,o){wi.preencode(d,o.header),e.fixed32.preencode(d,o.deviceKey),e.buffer.preencode(d,o.deviceProof),e.buffer.preencode(d,o.writerProof)},encode(d,o){wi.encode(d,o.header),e.fixed32.encode(d,o.deviceKey),e.buffer.encode(d,o.deviceProof),e.buffer.encode(d,o.writerProof)},decode:d=>({header:wi.decode(d),deviceKey:e.fixed32.decode(d),deviceProof:e.buffer.decode(d),writerProof:e.buffer.decode(d)})},Ti={preencode(o,n){o.end++,d>=31&&n.otaResyncPrivateProfileBump&&e.uint.preencode(o,n.otaResyncPrivateProfileBump)},encode(o,n){const c=d>=31&&n.otaResyncPrivateProfileBump?1:0;e.uint.encode(o,c),d>=31&&n.otaResyncPrivateProfileBump&&e.uint.encode(o,n.otaResyncPrivateProfileBump)},decode(o){const n=e.uint.decode(o);return{otaResyncPrivateProfileBump:d>=31&&1&n?e.uint.decode(o):0}}},Ri={preencode(d,o){e.fixed32.preencode(d,o.deviceKey),e.buffer.preencode(d,o.proof),e.uint.preencode(d,o.createdAt)},encode(d,o){e.fixed32.encode(d,o.deviceKey),e.buffer.encode(d,o.proof),e.uint.encode(d,o.createdAt)},decode:d=>({deviceKey:e.fixed32.decode(d),proof:e.buffer.decode(d),createdAt:e.uint.decode(d)})},Ai=$,Si={preencode(d,o){Ai.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Ai.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Ai.decode(d),callKey:e.fixed32.decode(d)})},Ii=$,Fi={preencode(d,o){Ii.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.deviceKey)},encode(d,o){Ii.encode(d,o.header),e.fixed32.encode(d,o.callKey),e.fixed32.encode(d,o.deviceKey)},decode:d=>({header:Ii.decode(d),callKey:e.fixed32.decode(d),deviceKey:e.fixed32.decode(d)})},Mi=e.frame(ht),Ci=e.array(e.frame(yt)),Vi={preencode(e,d){Mi.preencode(e,d.digest),Ci.preencode(e,d.mine)},encode(e,d){Mi.encode(e,d.digest),Ci.encode(e,d.mine)},decode:e=>({digest:Mi.decode(e),mine:Ci.decode(e)})},Hi=$,Di={preencode(d,o){Hi.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Hi.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Hi.decode(d),callKey:e.fixed32.decode(d)})},Li=$,qi={preencode(d,o){Li.preencode(d,o.header),e.fixed32.preencode(d,o.callKey)},encode(d,o){Li.encode(d,o.header),e.fixed32.encode(d,o.callKey)},decode:d=>({header:Li.decode(d),callKey:e.fixed32.decode(d)})},ji={preencode(o,n){o.end++,d>=33&&n.profileSnoozeTime&&e.uint.preencode(o,n.profileSnoozeTime)},encode(o,n){const c=(d>=33&&n.disableReadReceipts?1:0)|(d>=33&&n.stripAttachmentMetadata?2:0)|(d>=33&&n.profileSnoozeTime?4:0);e.uint.encode(o,c),d>=33&&n.profileSnoozeTime&&e.uint.encode(o,n.profileSnoozeTime)},decode(o){const n=e.uint.decode(o);return{disableReadReceipts:d>=33&&!!(1&n),stripAttachmentMetadata:d>=33&&!!(2&n),profileSnoozeTime:d>=33&&4&n?e.uint.decode(o):0}}},Ei={preencode(o,n){o.end++,d>=33&&n.maxPeers&&e.uint.preencode(o,n.maxPeers)},encode(o,n){const c=d>=33&&n.maxPeers?1:0;e.uint.encode(o,c),d>=33&&n.maxPeers&&e.uint.encode(o,n.maxPeers)},decode(o){const n=e.uint.decode(o);return{maxPeers:d>=33&&1&n?e.uint.decode(o):0}}},Bi=$,zi={preencode(e,d){Bi.preencode(e,d.header),n.preencode(e,d.oplog)},encode(e,d){Bi.encode(e,d.header),n.encode(e,d.oplog)},decode:e=>({header:Bi.decode(e),oplog:n.decode(e)})},Oi=$,Ni={preencode(e,d){Oi.preencode(e,d.header)},encode(e,d){Oi.encode(e,d.header)},decode:e=>({header:Oi.decode(e)})},Ui={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.uint.preencode(d,o.timestamp)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.uint.encode(d,o.timestamp)},decode:d=>({memberKey:e.fixed32.decode(d),timestamp:e.uint.decode(d)})},Ji=$,Wi={preencode(o,n){Ji.preencode(o,n.header),e.fixed32.preencode(o,n.memberKey),o.end++,d>=34&&n.alias&&e.string.preencode(o,n.alias)},encode(o,n){const c=d>=34&&n.alias?1:0;Ji.encode(o,n.header),e.fixed32.encode(o,n.memberKey),e.uint.encode(o,c),d>=34&&n.alias&&e.string.encode(o,n.alias)},decode(o){const n=Ji.decode(o),c=e.fixed32.decode(o),r=e.uint.decode(o);return{header:n,memberKey:c,alias:d>=34&&1&r?e.string.decode(o):null}}},Gi={preencode(d,o){e.uint.preencode(d,o.streams)},encode(d,o){e.uint.encode(d,o.streams)},decode:d=>({streams:e.uint.decode(d)})},Qi={preencode(d,o){e.fixed32.preencode(d,o.streamKey),e.string.preencode(d,o.mediaStreamId),e.string.preencode(d,o.type),d.end++},encode(o,n){const c=d>=36&&n.muted?1:0;e.fixed32.encode(o,n.streamKey),e.string.encode(o,n.mediaStreamId),e.string.encode(o,n.type),e.uint.encode(o,c)},decode(o){const n=e.fixed32.decode(o),c=e.string.decode(o),r=e.string.decode(o),t=e.uint.decode(o);return{streamKey:n,mediaStreamId:c,type:r,muted:d>=36&&!!(1&t)}}},Xi=$,Yi={preencode(d,o){Xi.preencode(d,o.header),e.fixed32.preencode(d,o.callKey),e.fixed32.preencode(d,o.streamKey),d.end++},encode(o,n){const c=d>=36&&n.muted?1:0;Xi.encode(o,n.header),e.fixed32.encode(o,n.callKey),e.fixed32.encode(o,n.streamKey),e.uint.encode(o,c)},decode(o){const n=Xi.decode(o),c=e.fixed32.decode(o),r=e.fixed32.decode(o),t=e.uint.decode(o);return{header:n,callKey:c,streamKey:r,muted:d>=36&&!!(1&t)}}},Zi={preencode(d,o){e.uint.preencode(d,o.statusKey),d.end++},encode(o,n){const c=d>=36&&n.muted?1:0;e.uint.encode(o,n.statusKey),e.uint.encode(o,c)},decode(o){const n=e.uint.decode(o),c=e.uint.decode(o);return{statusKey:n,muted:d>=36&&!!(1&c)}}},$i={preencode(n,c){e.fixed32.preencode(n,c.key),n.end++,d>=37&&c.encryptionKey&&e.buffer.preencode(n,c.encryptionKey),d>=37&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=(d>=37&&c.encryptionKey?1:0)|(d>=37&&c.bootFrom?2:0);e.fixed32.encode(n,c.key),e.uint.encode(n,r),d>=37&&c.encryptionKey&&e.buffer.encode(n,c.encryptionKey),d>=37&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.uint.decode(n);return{key:c,encryptionKey:d>=37&&1&r?e.buffer.decode(n):null,bootFrom:d>=37&&2&r?o.decode(n):null}}},_i={preencode(d,o){e.fixed32.preencode(d,o.hash)},encode(d,o){e.fixed32.encode(d,o.hash)},decode:d=>({hash:e.fixed32.decode(d)})},ea={preencode(d,o){e.fixed32.preencode(d,o.hash),e.buffer.preencode(d,o.data)},encode(d,o){e.fixed32.encode(d,o.hash),e.buffer.encode(d,o.data)},decode:d=>({hash:e.fixed32.decode(d),data:e.buffer.decode(d)})},da={preencode(n,c){o.preencode(n,c.autobeeMigrationHead),n.end++,d>=37&&c.legacyViewHead&&o.preencode(n,c.legacyViewHead),d>=37&&c.dbViewHead&&o.preencode(n,c.dbViewHead),d>=37&&c.blobsViewHead&&o.preencode(n,c.blobsViewHead),e.uint.preencode(n,c.createdAt)},encode(n,c){const r=(d>=37&&c.legacyViewHead?1:0)|(d>=37&&c.dbViewHead?2:0)|(d>=37&&c.blobsViewHead?4:0);o.encode(n,c.autobeeMigrationHead),e.uint.encode(n,r),d>=37&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=37&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=37&&c.blobsViewHead&&o.encode(n,c.blobsViewHead),e.uint.encode(n,c.createdAt)},decode(n){const c=o.decode(n),r=e.uint.decode(n);return{autobeeMigrationHead:c,legacyViewHead:d>=37&&1&r?o.decode(n):null,dbViewHead:d>=37&&2&r?o.decode(n):null,blobsViewHead:d>=37&&4&r?o.decode(n):null,createdAt:e.uint.decode(n)}}},oa=$,na={preencode(e,n){oa.preencode(e,n.header),o.preencode(e,n.head),e.end++,d>=37&&n.legacyViewHead&&o.preencode(e,n.legacyViewHead),d>=37&&n.dbViewHead&&o.preencode(e,n.dbViewHead),d>=37&&n.blobsViewHead&&o.preencode(e,n.blobsViewHead)},encode(n,c){const r=(d>=37&&c.legacyViewHead?1:0)|(d>=37&&c.dbViewHead?2:0)|(d>=37&&c.blobsViewHead?4:0);oa.encode(n,c.header),o.encode(n,c.head),e.uint.encode(n,r),d>=37&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=37&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=37&&c.blobsViewHead&&o.encode(n,c.blobsViewHead)},decode(n){const c=oa.decode(n),r=o.decode(n),t=e.uint.decode(n);return{header:c,head:r,legacyViewHead:d>=37&&1&t?o.decode(n):null,dbViewHead:d>=37&&2&t?o.decode(n):null,blobsViewHead:d>=37&&4&t?o.decode(n):null}}},ca={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.fixed32.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.seed),n.end++,d>=37&&c.bootFrom&&o.preencode(n,c.bootFrom)},encode(n,c){const r=d>=37&&c.bootFrom?1:0;e.fixed32.encode(n,c.roomKey),e.fixed32.encode(n,c.encryptionKey),e.fixed32.encode(n,c.seed),e.uint.encode(n,r),d>=37&&c.bootFrom&&o.encode(n,c.bootFrom)},decode(n){const c=e.fixed32.decode(n),r=e.fixed32.decode(n),t=e.fixed32.decode(n),i=e.uint.decode(n);return{roomKey:c,encryptionKey:r,seed:t,bootFrom:d>=37&&1&i?o.decode(n):null}}},ra=id,ta={preencode(d,o){e.fixed32.preencode(d,o.memberKey),e.fixed32.preencode(d,o.deviceKey),e.uint.preencode(d,o.deviceLength),e.uint.preencode(d,o.clock),ra.preencode(d,o.status)},encode(d,o){e.fixed32.encode(d,o.memberKey),e.fixed32.encode(d,o.deviceKey),e.uint.encode(d,o.deviceLength),e.uint.encode(d,o.clock),ra.encode(d,o.status)},decode:d=>({memberKey:e.fixed32.decode(d),deviceKey:e.fixed32.decode(d),deviceLength:e.uint.decode(d),clock:e.uint.decode(d),status:ra.decode(d)})},ia={preencode(d,o){e.fixed32.preencode(d,o.hash),e.buffer.preencode(d,o.blob)},encode(d,o){e.fixed32.encode(d,o.hash),e.buffer.encode(d,o.blob)},decode:d=>({hash:e.fixed32.decode(d),blob:e.buffer.decode(d)})},aa=Fn,sa=Mn,pa=kn,la={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),aa.preencode(n,c.status),e.uint.preencode(n,c.clock),n.end++,d>=37&&c.initiator&&o.preencode(n,c.initiator),d>=37&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=37&&c.identitySwap&&sa.preencode(n,c.identitySwap),d>=37&&c.identitySwapV2&&pa.preencode(n,c.identitySwapV2),d>=37&&c.contact&&e.fixed32.preencode(n,c.contact)},encode(n,c){const r=(d>=37&&c.initiator?1:0)|(d>=37&&c.bootFrom?2:0)|(d>=37&&c.identitySwap?4:0)|(d>=37&&c.identitySwapV2?8:0)|(d>=37&&c.contact?16:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),aa.encode(n,c.status),e.uint.encode(n,c.clock),e.uint.encode(n,r),d>=37&&c.initiator&&o.encode(n,c.initiator),d>=37&&c.bootFrom&&o.encode(n,c.bootFrom),d>=37&&c.identitySwap&&sa.encode(n,c.identitySwap),d>=37&&c.identitySwapV2&&pa.encode(n,c.identitySwapV2),d>=37&&c.contact&&e.fixed32.encode(n,c.contact)},decode(n){const c=e.fixed32.decode(n),r=e.buffer.decode(n),t=e.fixed32.decode(n),i=aa.decode(n),a=e.uint.decode(n),s=e.uint.decode(n);return{roomKey:c,encryptionKey:r,mailbox:t,status:i,clock:a,initiator:d>=37&&1&s?o.decode(n):null,bootFrom:d>=37&&2&s?o.decode(n):null,identitySwap:d>=37&&4&s?sa.decode(n):null,identitySwapV2:d>=37&&8&s?pa.decode(n):null,contact:d>=37&&16&s?e.fixed32.decode(n):null}}},ua=$,fa={preencode(n,c){ua.preencode(n,c.header),e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),e.fixed32.preencode(n,c.mailbox),n.end++,d>=37&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=37&&c.initiator&&o.preencode(n,c.initiator),d>=37&&c.dm&&e.fixed32.preencode(n,c.dm)},encode(n,c){const r=(d>=37&&c.bootFrom?1:0)|(d>=37&&c.initiator?2:0)|(d>=37&&c.dm?4:0)|(d>=37&&c.isReadOnly?8:0);ua.encode(n,c.header),e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.fixed32.encode(n,c.mailbox),e.uint.encode(n,r),d>=37&&c.bootFrom&&o.encode(n,c.bootFrom),d>=37&&c.initiator&&o.encode(n,c.initiator),d>=37&&c.dm&&e.fixed32.encode(n,c.dm)},decode(n){const c=ua.decode(n),r=e.fixed32.decode(n),t=e.buffer.decode(n),i=e.fixed32.decode(n),a=e.uint.decode(n);return{header:c,roomKey:r,encryptionKey:t,mailbox:i,bootFrom:d>=37&&1&a?o.decode(n):null,initiator:d>=37&&2&a?o.decode(n):null,dm:d>=37&&4&a?e.fixed32.decode(n):null,isReadOnly:d>=37&&!!(8&a)}}},ma={preencode(n,c){e.fixed32.preencode(n,c.roomKey),e.buffer.preencode(n,c.encryptionKey),n.end++,d>=37&&c.bootFrom&&o.preencode(n,c.bootFrom),d>=37&&c.initiator&&o.preencode(n,c.initiator)},encode(n,c){const r=(d>=37&&c.bootFrom?1:0)|(d>=37&&c.initiator?2:0);e.fixed32.encode(n,c.roomKey),e.buffer.encode(n,c.encryptionKey),e.uint.encode(n,r),d>=37&&c.bootFrom&&o.encode(n,c.bootFrom),d>=37&&c.initiator&&o.encode(n,c.initiator)},decode(n){const c=e.fixed32.decode(n),r=e.buffer.decode(n),t=e.uint.decode(n);return{roomKey:c,encryptionKey:r,bootFrom:d>=37&&1&t?o.decode(n):null,initiator:d>=37&&2&t?o.decode(n):null}}},ya={preencode(d,o){e.fixed32.preencode(d,o.roomKey),ls.preencode(d,o.head),e.uint.preencode(d,o.timestamp),d.end++},encode(o,n){const c=d>=37&&n.incremental?1:0;e.fixed32.encode(o,n.roomKey),ls.encode(o,n.head),e.uint.encode(o,n.timestamp),e.uint.encode(o,c)},decode(o){const n=e.fixed32.decode(o),c=ls.decode(o),r=e.uint.decode(o),t=e.uint.decode(o);return{roomKey:n,head:c,timestamp:r,incremental:d>=37&&!!(1&t)}}},ba={preencode(o,n){o.end++,d>=37&&n.key&&e.fixed32.preencode(o,n.key),e.uint.preencode(o,n.length)},encode(o,n){const c=d>=37&&n.key?1:0;e.uint.encode(o,c),d>=37&&n.key&&e.fixed32.encode(o,n.key),e.uint.encode(o,n.length)},decode(o){const n=e.uint.decode(o);return{key:d>=37&&1&n?e.fixed32.decode(o):null,length:e.uint.decode(o)}}},xa={preencode(n,c){e.fixed32.preencode(n,c.roomKey),n.end++,d>=37&&c.legacyViewHead&&o.preencode(n,c.legacyViewHead),d>=37&&c.dbViewHead&&o.preencode(n,c.dbViewHead),d>=37&&c.blobsViewHead&&o.preencode(n,c.blobsViewHead),d>=37&&c.autobeeMigrationHead&&o.preencode(n,c.autobeeMigrationHead)},encode(n,c){const r=(d>=37&&c.legacyViewHead?1:0)|(d>=37&&c.dbViewHead?2:0)|(d>=37&&c.blobsViewHead?4:0)|(d>=37&&c.autobeeMigrationHead?8:0);e.fixed32.encode(n,c.roomKey),e.uint.encode(n,r),d>=37&&c.legacyViewHead&&o.encode(n,c.legacyViewHead),d>=37&&c.dbViewHead&&o.encode(n,c.dbViewHead),d>=37&&c.blobsViewHead&&o.encode(n,c.blobsViewHead),d>=37&&c.autobeeMigrationHead&&o.encode(n,c.autobeeMigrationHead)},decode(n){const c=e.fixed32.decode(n),r=e.uint.decode(n);return{roomKey:c,legacyViewHead:d>=37&&1&r?o.decode(n):null,dbViewHead:d>=37&&2&r?o.decode(n):null,blobsViewHead:d>=37&&4&r?o.decode(n):null,autobeeMigrationHead:d>=37&&8&r?o.decode(n):null}}},va={preencode(d,o){e.fixed32.preencode(d,o.id),e.fixed32.preencode(d,o.writerKey),e.buffer.preencode(d,o.blindResponse)},encode(d,o){e.fixed32.encode(d,o.id),e.fixed32.encode(d,o.writerKey),e.buffer.encode(d,o.blindResponse)},decode:d=>({id:e.fixed32.decode(d),writerKey:e.fixed32.decode(d),blindResponse:e.buffer.decode(d)})},ka=$,ga={preencode(d,o){ka.preencode(d,o.header),e.buffer.preencode(d,o.blindResponse)},encode(d,o){ka.encode(d,o.header),e.buffer.encode(d,o.blindResponse)},decode:d=>({header:ka.decode(d),blindResponse:e.buffer.decode(d)})},Ka=e.frame(Ac),ha={preencode(o,n){e.string.preencode(o,n.mnemonic),o.end++,d>=39&&n.profileDiscoveryTimeout&&e.uint.preencode(o,n.profileDiscoveryTimeout),d>=39&&n.privateProfileKey&&e.fixed32.preencode(o,n.privateProfileKey),d>=39&&n.identity&&Ka.preencode(o,n.identity)},encode(o,n){const c=(d>=39&&n.profileDiscoveryTimeout?1:0)|(d>=39&&n.privateProfileKey?2:0)|(d>=39&&n.identity?4:0);e.string.encode(o,n.mnemonic),e.uint.encode(o,c),d>=39&&n.profileDiscoveryTimeout&&e.uint.encode(o,n.profileDiscoveryTimeout),d>=39&&n.privateProfileKey&&e.fixed32.encode(o,n.privateProfileKey),d>=39&&n.identity&&Ka.encode(o,n.identity)},decode(o){const n=e.string.decode(o),c=e.uint.decode(o);return{mnemonic:n,profileDiscoveryTimeout:d>=39&&1&c?e.uint.decode(o):0,privateProfileKey:d>=39&&2&c?e.fixed32.decode(o):null,identity:d>=39&&4&c?Ka.decode(o):null}}},wa=$,Pa={preencode(e,d){wa.preencode(e,d.header)},encode(e,d){wa.encode(e,d.header)},decode:e=>({header:wa.decode(e)})},Ta=$,Ra={preencode(o,c){Ta.preencode(o,c.header),n.preencode(o,c.oplog),e.uint.preencode(o,c.index),o.end++,d>=40&&c.displayType&&Gr.preencode(o,c.displayType)},encode(o,c){const r=d>=40&&c.displayType?1:0;Ta.encode(o,c.header),n.encode(o,c.oplog),e.uint.encode(o,c.index),e.uint.encode(o,r),d>=40&&c.displayType&&Gr.encode(o,c.displayType)},decode(o){const c=Ta.decode(o),r=n.decode(o),t=e.uint.decode(o),i=e.uint.decode(o);return{header:c,oplog:r,index:t,displayType:d>=40&&1&i?Gr.decode(o):0}}},Aa=$,Sa=Od,Ia={preencode(d,o){Aa.preencode(d,o.header),n.preencode(d,o.oplog),Gr.preencode(d,o.displayType),e.uint.preencode(d,o.index),Sa.preencode(d,o.preview)},encode(d,o){Aa.encode(d,o.header),n.encode(d,o.oplog),Gr.encode(d,o.displayType),e.uint.encode(d,o.index),Sa.encode(d,o.preview)},decode:d=>({header:Aa.decode(d),oplog:n.decode(d),displayType:Gr.decode(d),index:e.uint.decode(d),preview:Sa.decode(d)})},Fa=$,Ma={preencode(d,o){Fa.preencode(d,o.header),n.preencode(d,o.oplog),Gr.preencode(d,o.displayType),e.uint.preencode(d,o.index)},encode(d,o){Fa.encode(d,o.header),n.encode(d,o.oplog),Gr.encode(d,o.displayType),e.uint.encode(d,o.index)},decode:d=>({header:Fa.decode(d),oplog:n.decode(d),displayType:Gr.decode(d),index:e.uint.decode(d)})},Ca=e.frame(w),Va=e.frame(Gi),Ha=Ca,Da=e.array(ct),La=e.frame(se),qa=Ca,ja=La,Ea=e.frame(Lr),Ba=e.frame(ca),za=La,Oa=e.frame(fd),Na=e.frame(Fr),Ua=e.frame(Gt),Ja=Ua,Wa=e.array(e.frame(tt)),Ga=Ca,Qa=e.frame(zn),Xa=e.frame(Cr),Ya=Qa,Za=Xa,$a=Qa,_a=Xa,es=e.frame(qr),ds=Xa,os=e.array(e.frame(Tt)),ns=e.frame(mi),cs=e.frame(Vi),rs=e.frame(ji),ts=e.frame(ba),is=ts,as=Ca,ss=e.array(e.frame(Qi)),ps=ss,ls=ts;function us(e){switch(e){case"@keet/head":return o;case"@keet/oplog-id":return n;case"@keet/encryption-keypair":return c;case"@keet/signing-keypair":return r;case"@keet/room-keys":return t;case"@keet/operation-header":return i;case"@keet/blob-pointer":return a;case"@keet/file-dimensions":return s;case"@keet/file-metadata":return l;case"@keet/external-drive-pointer":return u;case"@keet/external-blob-pointer":return f;case"@keet/file-pointer":return b;case"@keet/file":return k;case"@keet/image-file":return w;case"@keet/file-status":return P;case"@keet/file-record":return A;case"@keet/device-status":return S;case"@keet/member-status":return I;case"@keet/member-moderation-status":return F;case"@keet/abi":return M;case"@keet/device-stats":return C;case"@keet/member-stats":return V;case"@keet/chat-stats":return H;case"@keet/file-stats":return D;case"@keet/stats":return B;case"@keet/room-type":return O;case"@keet/system-settings":return N;case"@keet/system-digest":return W;case"@keet/room-seed":return G;case"@keet/room-capabilities":return Q;case"@keet/room-config":return Y;case"@keet/blind-peer":return Z;case"@keet/add-blind-peer-operation":return ee;case"@keet/remove-blind-peer-operation":return oe;case"@keet/identity-attestation":return ne;case"@keet/device-invitation":return ce;case"@keet/device":return ie;case"@keet/member-profile":return ae;case"@keet/device-profile":return se;case"@keet/member-update":return le;case"@keet/device-update":return ue;case"@keet/signed-pairing-data":return fe;case"@keet/device-request-identity":return me;case"@keet/device-response-identity":return ye;case"@keet/device-request-with-invitation":return ke;case"@keet/device-request-with-invitation-and-proof":return Ke;case"@keet/device-request-with-member-proof":return Pe;case"@keet/device-request":return Ae;case"@keet/device-response":return Fe;case"@keet/invitation-metadata":return Me;case"@keet/invitation":return He;case"@keet/add-invitation-operation":return qe;case"@keet/remove-invitation-operation":return Ee;case"@keet/sendable-room-invitation":return Be;case"@keet/sendable-identity-invitation":return ze;case"@keet/sendable-contact-invitation":return Oe;case"@keet/sendable-invitation":return Ge;case"@keet/add-device-operation":return Xe;case"@keet/update-device-operation":return Ze;case"@keet/start-indexing-operation":return $e;case"@keet/stop-indexing-operation":return _e;case"@keet/join-request":return dd;case"@keet/accept-join-request-operation":return cd;case"@keet/reject-join-request-operation":return td;case"@keet/member":return sd;case"@keet/full-member":return ud;case"@keet/member-proofs":return fd;case"@keet/update-member-operation":return bd;case"@keet/change-member-status-operation":return kd;case"@keet/change-member-role-operation":return Kd;case"@keet/remove-member-operation":return wd;case"@keet/member-activity":return Pd;case"@keet/member-joined-event":return Td;case"@keet/member-left-event":return Rd;case"@keet/title-changed-chat-event":return Ad;case"@keet/chat-event":return Md;case"@keet/sendable-event":return Cd;case"@keet/display-range":return Vd;case"@keet/display-content-range":return Dd;case"@keet/mention-display-item":return qd;case"@keet/link-preview":return Bd;case"@keet/display-link-item":return Nd;case"@keet/display":return _d;case"@keet/oplog-message":return co;case"@keet/index-message":return io;case"@keet/full-index-message":return po;case"@keet/message-status":return lo;case"@keet/message-index-id":return uo;case"@keet/thread":return mo;case"@keet/chat-message-record":return vo;case"@keet/full-chat-message-record":return ho;case"@keet/add-chat-message-operation":return To;case"@keet/remove-chat-message-operation":return Ao;case"@keet/update-chat-message-operation":return Fo;case"@keet/pin-chat-message-operation":return Co;case"@keet/reaction":return Vo;case"@keet/reactions-summary":return Ho;case"@keet/reactions-digest":return Lo;case"@keet/add-reaction-operation":return jo;case"@keet/remove-reaction-operation":return Bo;case"@keet/update-room-config-operation":return No;case"@keet/group-member":return Uo;case"@keet/user-registry-info":return Jo;case"@keet/room-identity":return Go;case"@keet/genesis-operation":return dn;case"@keet/upgrade-operation":return nn;case"@keet/update-system-settings-operation":return tn;case"@keet-private-id/contact":return an;case"@keet-private-id/v3-room-migration-info":return sn;case"@keet-private-id/run-v3-migration-operation":return un;case"@keet-private-id/update-identity-operation":return mn;case"@keet-private-id/counters":return yn;case"@keet-private-id/stats":return bn;case"@keet-private-id/add-entropy-operation":return xn;case"@keet-private-id/pending-invitation-identity":return vn;case"@keet-private-id/pending-invitation":return gn;case"@keet-private-id/resolve-pending-invitation-operation":return hn;case"@keet-private-id/add-pending-invitation-operation":return Tn;case"@keet-private-id/remove-pending-invitation-operation":return An;case"@keet-private-id/identity-swap":return Sn;case"@keet-private-id/room-status":return In;case"@keet-private-id/room":return Vn;case"@keet-private-id/add-room-operation":return Dn;case"@keet-private-id/remove-room-operation":return qn;case"@keet-private-id/update-room-status-operation":return Bn;case"@keet-private-id/contact-status":return zn;case"@keet-private-id/contact-record":return On;case"@keet-private-id/add-contact-operation":return Jn;case"@keet-private-id/update-contact-status-operation":return Gn;case"@keet-private-id/remove-contact-operation":return Xn;case"@keet-private-id/contact-request-status":return Yn;case"@keet-private-id/contact-request-body":return _n;case"@keet-private-id/contact-request":return dc;case"@keet-private-id/contact-request-record":return rc;case"@keet-private-id/add-contact-request-operation":return ic;case"@keet-private-id/update-contact-request-status-operation":return pc;case"@keet-private-id/profile-discovery-record-v1":return lc;case"@keet-private-id/profile-discovery-record":return uc;case"@local/background-sync-room":return fc;case"@local/stats":return mc;case"@local/migration-status":return yc;case"@local/v3-private-profile-migration":return xc;case"@local/v3-room-migration":return gc;case"@local/room-migration-stats":return Kc;case"@local/room-migration":return wc;case"@local/identity-status":return Pc;case"@local/identity-record":return Ac;case"@local/tasks":return Ic;case"@local/room-keys":return Fc;case"@local/join-room-invitation-task":return Cc;case"@local/join-room-response-task":return Vc;case"@local/fast-forward-to":return Hc;case"@local/add-room-fields":return Dc;case"@local/join-room-keys-task":return qc;case"@local/create-room-task":return Ec;case"@local/leave-room-task":return Bc;case"@local/clear-room-task":return zc;case"@local/restore-identity-task":return Oc;case"@local/send-contact-request-task":return Nc;case"@local/migrate-v2-room-task":return Uc;case"@local/task":return er;case"@local/shared-invitation":return or;case"@local/room-status":return nr;case"@local/room-timestamps":return cr;case"@local/room":return vr;case"@local/room-preferences":return gr;case"@local/writer":return Kr;case"@local/member":return wr;case"@local/device":return Tr;case"@local/file":return Ar;case"@keet/add-file-preview-operation":return Ir;case"@keet/member-removed-event":return Fr;case"@keet/member-contact-info":return Cr;case"@keet/remove-device-operation":return Hr;case"@keet/device-identity":return Dr;case"@keet/readonly-room-invitation":return Lr;case"@keet-private-id/identity-swap-v2":return qr;case"@keet-private-id/activate-contact-room-operation":return Er;case"@local/identity-swap":return Br;case"@local/writer-append":return zr;case"@local/room-metadata":return Or;case"@local/debug-flag":return Nr;case"@local/debug":return Jr;case"@keet/display-type":return Gr;case"@keet/test-increment-operation":return Xr;case"@keet/test-collection-record-1":return Yr;case"@keet/migrate-abi-operation":return $r;case"@keet/system-settings-keys":return et;case"@local/hyperdht-record":return ot;case"@keet/room-supported-language":return ct;case"@keet/translation-display-item":return tt;case"@local/unread":return it;case"@keet-private-id/unreads":return at;case"@keet-private-id/add-unreads-key-operation":return pt;case"@keet-private-id/remove-unreads-key-operation":return ut;case"@keet/label-type":return mt;case"@keet/chat-label":return yt;case"@keet/add-chat-label-operation":return xt;case"@keet/remove-chat-label-operation":return kt;case"@keet/chat-label-summary":return gt;case"@keet/chat-label-digest":return ht;case"@keet/update-read-length-operation":return Pt;case"@keet/read-length":return Tt;case"@keet/tmp-removed-member":return Rt;case"@keet-private-id/settings":return At;case"@keet-private-id/user-settings-key":return It;case"@keet-private-id/update-settings-operation":return Ct;case"@local/error-record-details":return Vt;case"@local/error-record":return Dt;case"@local/keet-state":return qt;case"@local/file-stats":return jt;case"@keet/member-label-type":return Bt;case"@keet/member-label":return zt;case"@keet/add-member-label-operation":return Nt;case"@keet/member-label-summary":return Ut;case"@keet/member-label-digest":return Wt;case"@keet/location-shared-event":return Gt;case"@keet/move-indexer-operation":return Xt;case"@keet/start-call":return $t;case"@keet/join-call":return di;case"@keet/leave-call":return ni;case"@keet/end-call":return ri;case"@keet/add-call-stream":return ii;case"@keet/remove-call-stream":return si;case"@keet/call-record":return pi;case"@keet/call-member-record":return li;case"@keet/call-device-record":return ui;case"@keet/call-stream-record":return fi;case"@local/active-call":return mi;case"@local/file-gc-info":return yi;case"@keet/build-type":return xi;case"@keet/test-crash-operation":return ki;case"@keet/test-dispatch-error-operation":return Ki;case"@local/environment-record":return hi;case"@keet-private-id/shorten-device-attestation-operation":return Pi;case"@local/ota-actions":return Ti;case"@local/device-attestation":return Ri;case"@keet/call-device-heartbeat":return Si;case"@keet/remove-call-device":return Fi;case"@local/chat-labels":return Vi;case"@keet/start-call-recording":return Di;case"@keet/stop-call-recording":return qi;case"@local/settings":return ji;case"@local/hyperswarm-record":return Ei;case"@keet/dismiss-chat-reports-operation":return zi;case"@keet/update-typing-indicator-operation":return Ni;case"@keet/typing-indicator":return Ui;case"@keet-private-id/update-contact-alias-operation":return Wi;case"@keet/call-stats":return Gi;case"@keet/call-stream-input":return Qi;case"@keet/update-call-stream":return Yi;case"@keet/call-stream-status-record":return Zi;case"@keet/room-keys-v2":return $i;case"@keet/blob-pointer-v2":return _i;case"@keet/blob":return ea;case"@keet/autobee-migration":return da;case"@keet/autobee-migration-operation":return na;case"@keet/readonly-room-invitation-v2":return ca;case"@keet/admin-last-seen":return ta;case"@keet/blob-record":return ia;case"@keet-private-id/room-v2":return la;case"@keet-private-id/add-room-operation-v2":return fa;case"@local/room-keys/v2":return ma;case"@local/room-update":return ya;case"@local/view-head":return ba;case"@local/autobee-migration":return xa;case"@keet-private-id/pending-invitation-response":return va;case"@keet-private-id/resolve-pending-invitation-operation-v2":return ga;case"@local/pending-recovery":return ha;case"@keet/claim-admin-devices-operation":return Pa;case"@keet/remove-file-preview-operation":return Ra;case"@keet/add-link-preview-operation":return Ia;case"@keet/remove-link-preview-operation":return Ma;default:throw new Error("Encoder not found "+e)}}function fs(e,o=41){const n=us(e);return{preencode(e,c){d=o,n.preencode(e,c)},encode(e,c){d=o,n.encode(e,c)},decode:e=>(d=o,n.decode(e))}}const ms=fs;module.exports={resolveStruct:ms,getStruct:fs,getEnum:function(e){switch(e){case"@keet/room-type":return z;case"@local/tasks":return Sc;case"@keet/display-type":return Wr;case"@keet/system-settings-keys":return _r;case"@keet/room-supported-language":return nt;case"@keet/label-type":return ft;case"@keet-private-id/user-settings-key":return St;case"@local/keet-state":return Lt;case"@keet/member-label-type":return Et;case"@keet/build-type":return bi;default:throw new Error("Enum not found "+e)}},getEncoding:us,encode:function(o,n,c=41){return d=c,e.encode(us(o),n)},decode:function(o,n,c=41){return d=c,e.decode(us(o),n)},setVersion:function(e){d=e},version:d};
@holepunchto/keet-core/schema/versions.js +1 -1
……@@ -1 +1 @@
1const E={DMS:1,LEAVE_ROOM:2,V2_CONFIG:3,PINNED_MESSAGES:4,ROOM_RENAME_EVENT:5,REPLY_TO:6,PERMISSION_DOWNGRADE:7,REMOVE_MEMBER:8,MUTE_MEMBER:9,V2_PRIVATE_PROFILE:10,ROOM_LOCKING:11,DISABLE_MEMBERSHIP_EVENTS:12,DISPLAY_NAME_VALIDATION:13,CALL_HANGUP_EVENT:14,CALL_MISSED_EVENT:15,UNREADS:16,PRIVATE_PROFILE_SETTINGS:17,READ_LENGTH:18,REMOVE_MEMBER_V2:19,CHAT_LABELS:20,MULTI_FILES:21,REPORTED_MSG_INDEX:22,REPORTED_MEMBER_INDEX:23,LOCATION_SHARED_EVENT:24,FAVORITE_ROOMS:25,FORWARDED_MESSAGE:26,CALLS_V2:27,MOVE_INDEXER:28,DISABLE_FILE_ATTACHMENTS:29,DISABLE_LINKS:30,DM_PEERS_TO_MODS:31,V2_UNREADS:32,ROOM_MARK_UNREAD:33,STRIP_ATTACHMENT_METADATA:34,SHORTEN_ATTESTATION:34,CALLS_HEARTBEAT:35,CONTACT_BOOK:36,HIDE_ROOM_INVITE:37,CALL_RECORDING:38,PROFILE_SNOOZE_TIME:39,CROSS_DEVICE_RENAME:40,DISMISS_CHAT_REPORTS:41,TYPING_INDICATOR:42,CONTACT_ALIAS:43,ROOM_SNOOZE_TIME:44,CALL_STREAM_STATUS:45,CALLS_V3:46},_={},A=[{abi:1,features:[E.LEAVE_ROOM,E.V2_CONFIG]},{abi:2,features:[E.PINNED_MESSAGES,E.ROOM_RENAME_EVENT,E.REPLY_TO]},{abi:3,features:[E.MUTE_MEMBER]},{abi:4,features:[E.DMS]},{abi:5,features:[E.PERMISSION_DOWNGRADE]},{abi:6,features:[E.REMOVE_MEMBER]},{abi:7,features:[E.ROOM_LOCKING]},{abi:8,features:[E.V2_PRIVATE_PROFILE]},{abi:9,features:[]},{abi:10,features:[]},{abi:11,features:[]},{abi:12,features:[]},{abi:13,features:[]},{abi:14,features:[]},{abi:15,features:[E.UNREADS]},{abi:16,features:[]},{abi:17,features:[E.PRIVATE_PROFILE_SETTINGS,E.READ_LENGTH,E.REMOVE_MEMBER_V2,E.CHAT_LABELS]},{abi:18,features:[E.MULTI_FILES]},{abi:19,features:[E.REPORTED_MSG_INDEX]},{abi:20,features:[E.REPORTED_MEMBER_INDEX]},{abi:21,features:[E.LOCATION_SHARED_EVENT,E.FAVORITE_ROOMS,E.FORWARDED_MESSAGE]},{abi:22,features:[]},{abi:23,features:[E.CALLS_V2,E.MOVE_INDEXER],autoupgrade:!0},{abi:24,features:[E.DISABLE_FILE_ATTACHMENTS,E.DISABLE_LINKS,E.DM_PEERS_TO_MODS]},{abi:25,features:[]},{abi:26,features:[]},{abi:27,features:[]},{abi:28,features:[E.V2_UNREADS]},{abi:29,features:[E.ROOM_MARK_UNREAD,E.STRIP_ATTACHMENT_METADATA,E.SHORTEN_ATTESTATION]},{abi:30,features:[E.CALLS_HEARTBEAT,E.CONTACT_BOOK]},{abi:31,features:[E.HIDE_ROOM_INVITE,E.CALL_RECORDING,E.PROFILE_SNOOZE_TIME]},{abi:32,features:[E.CROSS_DEVICE_RENAME,E.DISMISS_CHAT_REPORTS,E.TYPING_INDICATOR]},{abi:33,features:[E.CONTACT_ALIAS]},{abi:34,features:[E.ROOM_SNOOZE_TIME]},{abi:35,stable:!0,features:[E.CALL_STREAM_STATUS,E.CALLS_V3]},{abi:36,features:[]}],T=new Map;let R=-1,O=-1,e=-1;for(const{abi:E,features:_,stable:S,autoupgrade:I}of A){for(const A of _)T.set(A,E);I&&(e=E),S&&(R=E),O=E}const S=O+1;for(const[A,R]of Object.entries(E))T.has(R)&&(_[A]=T.get(R));module.exports={isFeatureSupported:function(E,_){const A=T.get(_);return!!A&&A<=E},FEATURES_TO_ABI:_,FEATURES:E,STABLE:R,AUTOUPGRADE:e,MINIMUM:S,MIN_AUTOBEE_ABI:36,EXPERIMENTAL:O,FORCE_UPDATE:1};
1const E={DMS:1,LEAVE_ROOM:2,V2_CONFIG:3,PINNED_MESSAGES:4,ROOM_RENAME_EVENT:5,REPLY_TO:6,PERMISSION_DOWNGRADE:7,REMOVE_MEMBER:8,MUTE_MEMBER:9,V2_PRIVATE_PROFILE:10,ROOM_LOCKING:11,DISABLE_MEMBERSHIP_EVENTS:12,DISPLAY_NAME_VALIDATION:13,CALL_HANGUP_EVENT:14,CALL_MISSED_EVENT:15,UNREADS:16,PRIVATE_PROFILE_SETTINGS:17,READ_LENGTH:18,REMOVE_MEMBER_V2:19,CHAT_LABELS:20,MULTI_FILES:21,REPORTED_MSG_INDEX:22,REPORTED_MEMBER_INDEX:23,LOCATION_SHARED_EVENT:24,FAVORITE_ROOMS:25,FORWARDED_MESSAGE:26,CALLS_V2:27,MOVE_INDEXER:28,DISABLE_FILE_ATTACHMENTS:29,DISABLE_LINKS:30,DM_PEERS_TO_MODS:31,V2_UNREADS:32,ROOM_MARK_UNREAD:33,STRIP_ATTACHMENT_METADATA:34,SHORTEN_ATTESTATION:34,CALLS_HEARTBEAT:35,CONTACT_BOOK:36,HIDE_ROOM_INVITE:37,CALL_RECORDING:38,PROFILE_SNOOZE_TIME:39,CROSS_DEVICE_RENAME:40,DISMISS_CHAT_REPORTS:41,TYPING_INDICATOR:42,CONTACT_ALIAS:43,ROOM_SNOOZE_TIME:44,CALL_STREAM_STATUS:45,CALLS_V3:46,PREVIEWS:47,ADMIN_DEVICE_INDEXING:48},_={},A=[{abi:1,features:[E.LEAVE_ROOM,E.V2_CONFIG]},{abi:2,features:[E.PINNED_MESSAGES,E.ROOM_RENAME_EVENT,E.REPLY_TO]},{abi:3,features:[E.MUTE_MEMBER]},{abi:4,features:[E.DMS]},{abi:5,features:[E.PERMISSION_DOWNGRADE]},{abi:6,features:[E.REMOVE_MEMBER]},{abi:7,features:[E.ROOM_LOCKING]},{abi:8,features:[E.V2_PRIVATE_PROFILE]},{abi:9,features:[]},{abi:10,features:[]},{abi:11,features:[]},{abi:12,features:[]},{abi:13,features:[]},{abi:14,features:[]},{abi:15,features:[E.UNREADS]},{abi:16,features:[]},{abi:17,features:[E.PRIVATE_PROFILE_SETTINGS,E.READ_LENGTH,E.REMOVE_MEMBER_V2,E.CHAT_LABELS]},{abi:18,features:[E.MULTI_FILES]},{abi:19,features:[E.REPORTED_MSG_INDEX]},{abi:20,features:[E.REPORTED_MEMBER_INDEX]},{abi:21,features:[E.LOCATION_SHARED_EVENT,E.FAVORITE_ROOMS,E.FORWARDED_MESSAGE]},{abi:22,features:[]},{abi:23,features:[E.CALLS_V2,E.MOVE_INDEXER],autoupgrade:!0},{abi:24,features:[E.DISABLE_FILE_ATTACHMENTS,E.DISABLE_LINKS,E.DM_PEERS_TO_MODS]},{abi:25,features:[]},{abi:26,features:[]},{abi:27,features:[]},{abi:28,features:[E.V2_UNREADS]},{abi:29,features:[E.ROOM_MARK_UNREAD,E.STRIP_ATTACHMENT_METADATA,E.SHORTEN_ATTESTATION]},{abi:30,features:[E.CALLS_HEARTBEAT,E.CONTACT_BOOK]},{abi:31,features:[E.HIDE_ROOM_INVITE,E.CALL_RECORDING,E.PROFILE_SNOOZE_TIME]},{abi:32,features:[E.CROSS_DEVICE_RENAME,E.DISMISS_CHAT_REPORTS,E.TYPING_INDICATOR]},{abi:33,features:[E.CONTACT_ALIAS]},{abi:34,features:[E.ROOM_SNOOZE_TIME]},{abi:35,stable:!0,features:[E.CALL_STREAM_STATUS,E.CALLS_V3]},{abi:36,features:[]},{abi:37,stable:!0,features:[E.PREVIEWS,E.ADMIN_DEVICE_INDEXING]}],R=new Map;let T=-1,O=-1,I=-1;for(const{abi:E,features:_,stable:e,autoupgrade:S}of A){for(const A of _)R.set(A,E);S&&(I=E),e&&(T=E),O=E}const e=O;for(const[A,T]of Object.entries(E))R.has(T)&&(_[A]=R.get(T));module.exports={isFeatureSupported:function(E,_){const A=R.get(_);return!!A&&A<=E},FEATURES_TO_ABI:_,FEATURES:E,STABLE:T,AUTOUPGRADE:I,MINIMUM:e,MIN_AUTOBEE_ABI:36,EXPERIMENTAL:O,FORCE_UPDATE:1};
@holepunchto/keet-indexing/lib/config/index.js +1 -1
……@@ -1 +1 @@
1const{Transform:e,pipeline:t}=require("streamx"),i=require("compact-encoding"),a=require("b4a"),{ConfigSchema:s}=require("@holepunchto/keet-core-schemas"),{UpdateConfigOperationV1:n,UpdateConfigOperationV2:o}=s.Operations,{CONFIG:r,VALIDATION:c,FEATURES:h,GENERIC_EVENTS:u,isFeatureSupported:E}=require("@holepunchto/keet-core-api");module.exports=class{static Operations=new Set([n.TYPE,o.TYPE]);constructor(e){this.view=e,this.chat=null,this.members=null,this.config=null,this.configV2=null}initialize(){this.chat=this.view.chat,this.members=this.view.members,this.chat=this.view.chat,this.config=this.view.collections.config,this.configV2=this.view.bee}async get(e){const t=await this.configV2.get(e,s.Encoding);return s.getValue(t)}async getAll(e={}){const t={};for await(const{key:i,value:a}of this.createReadStream(e))t[i]=a;return t}async put(e,t){await this.configV2.put(e,t,s.Encoding)}createReadStream(i={}){const a=this.configV2.createReadStream(i,s.Encoding);return t(a,new e({transform(e,t){t(null,{key:e.key,value:s.getValue(e)})}}))}async getConfig(){const e=await this.config.get(r.V1_CONFIG_KEY);return{...e?e.value:{},...await this.getAll()}}async isBroadcastRoom(){const e=await this.getConfig();return!!e&&"1"===e.roomType}async isDisableMembershipEvents(){return 1===await this.get(r.DISABLE_MEMBERSHIP_EVENTS)}async deletePinnedMessageIfExists(e){const t=await this.get(r.PINNED_MESSAGES)||[],i=t.findIndex(t=>a.equals(t.key,e.key)&&t.seq===e.seq);-1!==i&&(t.splice(i,1),await this.put(r.PINNED_MESSAGES,s.encodeValue(r.PINNED_MESSAGES,t)))}async _validate(e,t){const i=s.decodeValue(e,t);switch(e){case r.PINNED_MESSAGES:return!await this.view.isUnsupportedFeature(h.PINNED_MESSAGES)&&(await Promise.all([this._pinLimitNotExceeded(e,i),this._pinnedMessageExists(e,i)])).every(e=>!0===e);case r.DISABLE_MEMBERSHIP_EVENTS:return await this.view.isFeatureSupported(h.DISABLE_MEMBERSHIP_EVENTS);default:return!0}}_pinLimitNotExceeded(e,t){return t.length<=c.PINNED_MESSAGES_LIMIT}async _pinnedMessageExists(e,t){const i=t.length?t[t.length-1]:null;return!i||await this.chat.messageExists(i)}async _maybeTrackChange({id:e,timestamp:t,from:i,to:a}){await this.view.isFeatureSupported(h.ROOM_RENAME_EVENT)&&null!==i&&i!==a&&await this.chat.addMessage({id:e,timestamp:t,event:{type:u.ROOM_TITLE_CHANGED,value:{from:i,to:a}}})}async _applyUpdateConfigOperationV1(e,{id:t}){const{key:a,value:s}=e.value;if(!await this.members.isModerator(t.key))return;const n=await this.view.internal.getCodeVersion();if(E(n,h.V2_CONFIG))return this.put(a,i.encode(i.string,s));const o=await this.getConfig();s?o[a]=s:delete o[a],await this.config.update(r.V1_CONFIG_KEY,o,{upsert:!0})}async _applyUpdateConfigOperationV2(e,t){const{id:i}=t,{key:a,value:n}=e.value;if(await this.members.isModerator(i.key)&&await this._validate(a,n)){if(a===r.ROOM_TITLE){const e=await this.get(a),i=s.decodeValue(a,n);await this._maybeTrackChange({...t,from:e,to:i})}await this.put(a,n)}}autobaseApply(e,t){switch(e.type){case n.TYPE:return this._applyUpdateConfigOperationV1(e,t);case o.TYPE:return this._applyUpdateConfigOperationV2(e,t)}}async migrate(){const e=await this.config.get(r.V1_CONFIG_KEY);if(e&&e.value)for await(const t of Object.keys(e.value)){const a=e.value[t];await this.put(t,i.encode(i.string,a))}}};
1const{Transform:e,pipeline:t}=require("streamx"),i=require("compact-encoding"),a=require("b4a"),{ConfigSchema:s}=require("@holepunchto/keet-core-schemas"),{UpdateConfigOperationV1:n,UpdateConfigOperationV2:o}=s.Operations,{CONFIG:r,VALIDATION:c,FEATURES:h,GENERIC_EVENTS:u,isFeatureSupported:E}=require("@holepunchto/keet-core-api");module.exports=class{static Operations=new Set([n.TYPE,o.TYPE]);constructor(e){this.view=e,this.chat=null,this.members=null,this.config=null,this.configV2=null}initialize(){this.chat=this.view.chat,this.members=this.view.members,this.chat=this.view.chat,this.config=this.view.collections.config,this.configV2=this.view.bee}async get(e){const t=await this.configV2.get(e,s.Encoding);return s.getValue(t)}async getAll(e={}){const t={};for await(const{key:i,value:a}of this.createReadStream(e))t[i]=a;return t}async put(e,t){await this.configV2.put(e,t,s.Encoding)}createReadStream(i={}){const a=this.configV2.createReadStream(i,s.Encoding);return t(a,new e({transform(e,t){t(null,{key:e.key,value:s.getValue(e)})}}))}async getConfig(){const e=await this.config.get(r.V1_CONFIG_KEY);return{...e?e.value:{},...await this.getAll()}}async isBroadcastRoom(){const e=await this.getConfig();return!!e&&"1"===e.roomType}async isDisableMembershipEvents(){return 1===await this.get(r.DISABLE_MEMBERSHIP_EVENTS)}async deletePinnedMessageIfExists(e){const t=await this.get(r.PINNED_MESSAGES)||[],i=t.findIndex(t=>a.equals(t.key,e.key)&&t.seq===e.seq);-1!==i&&(t.splice(i,1),await this.put(r.PINNED_MESSAGES,s.encodeValue(r.PINNED_MESSAGES,t)))}async _validate(e,t){const i=s.decodeValue(e,t);switch(e){case r.PINNED_MESSAGES:return!await this.view.isUnsupportedFeature(h.PINNED_MESSAGES)&&(await Promise.all([this._pinLimitNotExceeded(e,i),this._pinnedMessageExists(e,i)])).every(e=>!0===e);case r.DISABLE_MEMBERSHIP_EVENTS:return await this.view.isFeatureSupported(h.DISABLE_MEMBERSHIP_EVENTS);default:return!0}}_pinLimitNotExceeded(e,t){return t.length<=c.PINNED_MESSAGES_LIMIT}async _pinnedMessageExists(e,t){const i=t.length?t[t.length-1]:null;return!i||await this.chat.messageExists(i)}async _maybeTrackChange({id:e,timestamp:t,from:i,to:a}){await this.view.isFeatureSupported(h.ROOM_RENAME_EVENT)&&null!==i&&i!==a&&await this.chat.addMessage({id:e,timestamp:t,event:{type:u.ROOM_TITLE_CHANGED,value:{from:i,to:a}}})}async _applyUpdateConfigOperationV1(e,{id:t}){const{key:a,value:s}=e.value;if(!await this.members.isModerator(t.key))return;const n=await this.view.internal.getCodeVersion();if(E(n,h.V2_CONFIG))return s?this.put(a,i.encode(i.string,s)):this.configV2.del(a);const o=await this.getConfig();s?o[a]=s:delete o[a],await this.config.update(r.V1_CONFIG_KEY,o,{upsert:!0})}async _applyUpdateConfigOperationV2(e,t){const{id:i}=t,{key:a,value:n}=e.value;if(await this.members.isModerator(i.key)&&await this._validate(a,n)){if(a===r.ROOM_TITLE){const e=await this.get(a),i=s.decodeValue(a,n);await this._maybeTrackChange({...t,from:e,to:i})}await this.put(a,n)}}autobaseApply(e,t){switch(e.type){case n.TYPE:return this._applyUpdateConfigOperationV1(e,t);case o.TYPE:return this._applyUpdateConfigOperationV2(e,t)}}async migrate(){const e=await this.config.get(r.V1_CONFIG_KEY);if(e&&e.value)for await(const t of Object.keys(e.value)){const a=e.value[t];await this.put(t,i.encode(i.string,a))}}};
@holepunchto/keet-indexing/package.json +1 -1
……@@ -1,6 +1,6 @@
11{
22 "name": "@holepunchto/keet-indexing",
3 "version": "6.4.1",
3 "version": "6.4.2",
44 "description": "Indexing logic for Keet's Autobase DB",
55 "main": "index.js",
66 "repository": {