OverviewFilesCommitsIssuesDocsReleasesPeers

keet-cli / deobfuscated / index.js

2073 lines · javascript ref:
const IdentityKey=require('keet-identity-key'),CorestoreStorage=require('hypercore-storage'),HypercoreId=require('hypercore-id-encoding'),ReadyResource=require('ready-resource'),Hyperswarm=require('hyperswarm'),DHT=require('hyperdht'),Corestore=require('corestore'),Hypercore=require('hypercore'),Hyperblobs=require('hyperblobs'),Autobase=require('autobase'),ScopeLock=require('scope-lock'),Rache=require('rache'),Wakeup=require('protomux-wakeup'),Semaphore=require('promaphore'),safetyCatch=require('safety-catch'),TaskBackoff=require('task-backoff'),crypto=require('hypercore-crypto'),c=require('compact-encoding'),z32=require('z32'),b4a=require('b4a'),fs=require('fs'),path=require('path'),BlindPeering=require('blind-peering'),MultiProfileStore=require('multi-profile-store'),Hyperconf=require('hyperconf'),KeetPush=require('@holepunchto/keet-push'),KeetUnreadAnchors=require('@holepunchto/keet-unread-anchors'),{
  generateMnemonic}
=require('bip39-mnemonic'),{
  HyperDiscoveryClient}
=require('@holepunchto/hyperdiscovery'),KeetIndexing=require('@holepunchto/keet-indexing'),KeetVersions=require('./packages/schema/versions.js'),V1KeetAPI=require('./api/v1'),V2KeetAPI=require('./api/v2'),KeetLocalDatabase=require('./lib/local'),FileManager=require('./lib/files'),TaskManager=require('./lib/tasks'),RoomViewSync=require('./lib/sync'),KeetCoreV3Apply=require('./lib/migrations/3/apply'),{
  SwarmWorker,RoomFirewall}
=require('./lib/swarm'),{
  getWriterKey,getInvitationId,createInvitation,generateRoomCapabilities,generateIdentityPairingName,generateRoomPairingName}
=require('./lib/invitations'),{
  getMemberForDeviceKey}
=require('./lib/contract/query'),{
  restoreAvatar}
=require('./lib/contract/avatars'),{
  RoomStatus}
=require('./lib/contract/identity/private'),{
  DEBUG_FLAGS,DHT_SETTINGS}
=require('./debugging'),{
  loadRouter,loadBundle}
=require('./bundle'),{
  KeetContract}
=require('./lib/contract'),{
  KeetContractError}
=require('./lib/contract/errors.js'),{
  contract:{
    hyperdispatch:{
      decode:decodeOperation},hyperschema:{
      getEncoding:getContractEncoding,encode:encodeContractStruct,decode:decodeContractStruct}
  },local:{
  hyperschema:{
    getEnum:getLocalEnum}
},config:{
hyperconf:KeetConfigSpec}
}
=require('./spec');
const ProfileDiscoveryRecord=getContractEncoding("@keet-private-id/profile-discovery-record"),UserRegistry=require('./lib/users'),ProtomuxRpcClient=require('protomux-rpc-client'),{
  KeetErrorManager,KeetErrorV2}
=require('./errors'),{
  Version}
=require('bare-semver'),{
  roomMigrationsStats}
=require('./lib/contract/stats/local'),KeetState=getLocalEnum("@local/keet-state"),PROFILES_GC_DELAY=(0x3e8)*(0x3c)*(0x3c)*(-0x3d80)*(0x1e),SWARM_KEYPAIR_NAME="keet-swarm-keypair",KEET_CORE_NAMESPACE="keet-core",KEET_UNREAD_ANCHORS_NAMESPACE="keet-unreads",DEFAULT_PROFILE_DISCOVERY_TIMEOUT=(0x3e8)*(-0x3e98),DEFAULT_PAIRING_TIMEOUT=(0x3e8)*(--0x3e97),DEFAULT_ROOM_GC_IDLE_TICKS=0x4,DEFAULT_ROOM_GC_INTERVAL=-0x2a4e,GLOBAL_TASK=b4a.alloc(0x20);
const REPAIR_VERSION=-0xb01,MAX_REPARABLE_TIP_SIZE=0x1f4,MIGRATION_VERSION=0x9,V3_MIGRATION_EXPIRATION=(-0x436a)*(-0x253e)*(0x3c)*(--0x3080)*(--0x206e),MAX_PARALLEL_ROOM_MIGRATIONS=-0x3cab,MAX_PARALLEL_DISCOVERY_SWARMING=0xa,IDENTITIES_RELEASE_TIMESTAMP=0x18e802850a8,PROD_HYPERCONF_KEY=HypercoreId.decode("w94a4mrokgp4hu757rhipc3isrxstiyupnpabat357hh6jutwrro"),DEV_HYPERCONF_KEY=HypercoreId.decode("bczu3wqy4peuxx4ybju6rjoqjsh7ihxfb7o8smrngwtqrs8h8pjo"),PROD_HYPERCONF_CORE_LENGTH=0x1,DEV_HYPERCONF_CORE_LENGTH=--0x2e7d,DHT_NODES_LIMIT=0x40,INVITE_DHT_NODES_LIMIT=--0x3e15;
class Batch{
  constructor(_0x3f577f,_0x45aafc){
    _0xdacc6c={
      _0x2a80fc:0x12a,_0x58a957:0x46,_0x722b9e:0xa},_0x4b5cc6={
      _0x3f68ca:0x55,_0x182742:0x18f,_0x152fc9:0x28a}
    ;
    this.keet=_0x3f577f,this.roomId=_0x45aafc,this.batch=null,this.length=-0xb38,this.timestamp=-0x4162;
    this.pushLength=-0x3f58;
  }
get.key(){
  _0x546b21={
    _0x1cb10c:0xf1},_0x25d01b={
    _0xb8e6a4:0xe4,_0x5ef3f8:0x2fe}
  ;
  return this.room.base.local.key;
}
._open(){
  _0x344900={
    _0x5d4aa9:0x149,_0x502b9b:0x1dd,_0x553b3c:0x192},_0x3649e1={
    _0x5e2a9e:0x147,_0x3ea24c:0x1dc}
  ;
  this.room=this.keet.internalOpenExistingRoom(this.roomId),this.batch=this.room.base.batch(),this.timestamp=Date.now();
}
._noop(){
  _0x255828={
    _0x53b6f2:0xc7,_0x352243:0x4f,_0x4c5853:0x114},_0x180aff={
    _0x4e1d2a:0x17f,_0x54162f:0xc5}
  ;
  return this.close(),this.length;
}
async.dispatch(_0x8363cf,_0x4f576d,{dryRun:dryRun=!![]}={}){
  _0x170def={
    _0x4bec8c:0x1a6,_0xd2cc22:0xc5},_0x408b26={
    _0xf67ec9:0x2c,_0x1f9e38:0x73,_0x4fc1b3:0x2d}
  ;
  if(!this.room)this._open();
  if(!this.room.opened)await this.room.ready();
  const _0x58090f=await this.room._internalEncodeOperation(_0x8363cf,_0x4f576d,{'view':this.room.view,'timestamp':this.timestamp});
  if(dryRun){
    const _0x4cca70=await this.keet.internalDryRun(this.room,this.room.view,[_0x58090f]);
    if(!_0x4cca70)return this._noop();
  }
return this.length=await this.append(_0x58090f),!this.pushLength&&shouldPushNotify(_0x8363cf)&&(this.pushLength=this.length),this.length;
}
async.append(_0x10feb8){
  _0x349a4f={
    _0x25b085:0x40,_0x5d4bec:0x85,_0x1cf08b:0x2e1}
  ;
  return this.batch.append(_0x10feb8);
}
async.flush(){
  _0x1c3738={
    _0x5b3a4d:0x117,_0x45faf4:0x46,_0x1ae49e:0x2c1},_0x58700d={
    _0x338b5a:0x1ed,_0xbb8bf9:0x20}
  ;
  try{
    return await this.batch.flush(),await this.room._postAppend({'encoded':this.batch.blocks,'pushLength':this.pushLength,'timestamp':this.timestamp}),{
      'key':this.key,'length':this.length}
    ;
  }finally{
  this.close();
}
}
.close(){
  _0x2928ea={
    _0x29968a:0x1dd,_0x123120:0x14d},_0x57d100={
    _0x24fe5c:0x8b,_0x46c43f:0x1d2}
  ;
  if(this.room)this.keet.internalReleaseRoom(this.room);
  if(this.batch)this.batch.close();
  this.batch=null,this.length=0x0;
  this.shouldPush=![];
}
}
class Room extends ReadyResource{
  constructor(_0x5a3254,_0x4b1fa6,_0x17683c,_0x2b8123,_0x54c436){
    _0x1d9cef={
      _0x17a923:0xc9,_0xda2a98:0x3f},_0x5c7781={
      _0x1995df:0xc8,_0x23c8cc:0x18a,_0x420aee:0x6a}
    ;
    super(),this.keet=_0x5a3254,this.id=_0x4b1fa6,this.key=_0x17683c,this.base=_0x54c436,this.externalBlobs=null,this.discoveryKey=_0x2b8123,this.discoveryId=HypercoreId.encode(this.discoveryKey),this.view=this.base.view,this.db=this.view.db,this.core=this.view.core,this.blobs=this.view.blobs;
    this.router=this.view.router,this.push=null;
    this.keet.push&&(this.push=this.keet.push.room(this.key,this.discoveryKey)),this.refs=-0x3718,this.idleTicks=0x0,this._pushLock=new ScopeLock({'debounce':!![]}),this.ready().catch(noop);
  }
get.deviceId(){
  _0x36868a={
    _0x177235:0x1d5,_0x14d530:0x175},_0x1a7d27={
    _0x2e5e13:0x3}
  ;
  return HypercoreId.encode(this.deviceKey);
}
get.deviceKey(){
  _0x43480c={
    _0x253970:0x35,_0x5973b:0x1bf},_0x21880a={
    _0xe066d5:0x102,_0x466562:0xe,_0x35bbf2:0x2eb}
  ;
  return this.base.local.key;
}
get.encryptionKey(){
  _0x2677d7={
    _0x44e89f:0x11d,_0x6b4247:0x2d},_0x41894d={
    _0x32648c:0x67,_0x3f69af:0x1c7,_0x48364d:0x197}
  ;
  return this.base.encryptionKey;
}
async.getStats(){
  _0x2e662b={
    _0x2c5b2c:0x81,_0x1c4731:0xbb},_0x40dd14={
    _0x33a5c1:0x56,_0x4fcb7f:0x17e},[_0x4f5639,_0x1c9e68,_0xcffc71]=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})]),_0x14e604={
    'peers':this.view.core.peers.length,'length':this.view.core.length,'signedLength':this.view.core.signedLength,'byteLength':this.view.core.byteLength}
  ;
  const _0x153bf2={
    'peers':this.base.core.peers.length,'length':this.base.length,'signedLength':this.base.signedLength,'indexedLength':this.base.indexedLength},_0x64f7d4={
    'opened':this.base.opened,'closed':this.base.closed,'opening':!!this.base.opening,'closing':!!this.base.closing,'writable':this.base.writable,'indexing':this.base.ackable,'interrupted':!!this.base.interrupted,'appending':!!this.base.appending,'flushing':!!this.base.flushing,'advancing':!!this.base._advancing}
  ;
  const _0x5a040d={
    'key':_0xcffc71.key?HypercoreId.encode(_0xcffc71.key):null,'roomKey':_0xcffc71?..roomKey?HypercoreId.encode(_0xcffc71.roomKey):null}
  ;
  return{
    'view':_0x14e604,'system':_0x153bf2,'base':_0x64f7d4,'writer':_0x5a040d,'status':_0x4f5639?..status,'preferences':_0x1c9e68?..status}
  ;
}
async._safePushNotify(_0x4bad89){
  _0x2bd89f={
    _0x2500b9:0x13d,_0x1157af:0x147,_0x5b0195:0xe8},_0x4f474f={
    _0x4cdc22:0x11c,_0x3d9777:0x182}
  ;
  !this._pushLengths&&(this._pushLengths=[]);
  this._pushLengths.push(_0x4bad89);
  if(!await this._pushLock.lock())return;
  if(this.closing)return;
  const _0x7e09b6=this._pushLengths;
  this._pushLengths=null;
  try{
    await this.push.send(this.base.local,_0x7e09b6);
  }catch(_0x2164f8){
  this.keet.onerror(_0x2164f8,{'roomKey':this.key});
}
this._pushLock.unlock();
}
async._safeBumpDiscovery(_0x3432f2){
  _0x4af455={
    _0x2658f6:0x1cf,_0x49d999:0x15b},_0x2eeb6d={
    _0x2c5dd9:0x150,_0x30b2c8:0x152,_0x73341d:0x4af}
  ;
  try{
    const _0x1b93b4=await this.keet.local.get("@local/rooms",{'roomKey':this.key});
    this.keet.discovery.announce(_0x1b93b4.capabilities.discoveryKeyPair,{'bump':_0x3432f2});
  }catch(_0x538dbc){
  this.keet.onerror(_0x538dbc,{'roomKey':this.key});
}
}
async._open(){
  _0x12ad9d={
    _0x52def7:0x55a,_0x53c2b3:0x6b0,_0x3dfc49:0x818,_0x17d79f:0x2b7,_0x5dda28:0x427,_0x4c6a7c:0x2b8,_0x538826:0x2ef,_0x4e46a8:0x439,_0x298038:0x58e,_0x479d5b:0x6ae,_0x5e977a:0x6db,_0x604937:0x14d,_0x21f593:0x323,_0x5478ea:0x2c2,_0x83e2bf:0x1bf,_0x3b9df0:0x1df,_0x2a22f0:0x1b1,_0x5c9c34:0x1d9,_0x5e5eff:0x12d},_0x3c2ce7={
    _0x50b88f:0x1dc,_0x6a50c2:0x391,_0x390597:0x41},_0xd8bb7d={
    _0x48ae43:0xfb,_0x3a3b21:0x223},_0x426f3e={
    _0x173939:0x9b},_0x4b0475={
    _0x4f4a95:0x3c0,_0x34983d:0x244,_0x1ed0fc:0x137,_0x4f2923:0x141,_0x462d64:0x2,_0x1bcb9:0x7a1,_0x52e2c3:0x712,_0x1ccc3f:0x75e,_0x239bcb:0x5e5,_0x49948c:0x632,_0x33a3fd:0x74d,_0x3a87e0:0x5d5,_0xa02ae2:0x5ec,_0x21e8e9:0x55e,_0x4f5580:0x182,_0x2f55c1:0xd0,_0x35cf75:0x11a,_0x4d21f0:0x69,_0x1090b7:0x70d,_0x2bb45f:0x7bb,_0x1cedb4:0x5fb,_0x2b1c21:0x19b,_0x111199:0x1f1,_0x43cf9d:0x1e7},_0x18df16={
    _0x3909a6:0xa3,_0x4c9da4:0x2c,_0x5212fd:0xd3},_0x4cf328={
    _0x5d040e:0x38c,_0x2e2039:0x4fc,_0x2488c5:0x408,_0x44f461:0x441,_0x266033:0x38e,_0xa46e6c:0x48,_0x2733b3:0x98,_0x15ebe1:0x68,_0x101bbf:0x1f8,_0x49d783:0x25f,_0x27179b:0x3a,_0x59c538:0x117,_0x4aae56:0x3d,_0x31b67c:0x11f,_0xa04023:0x229,_0x38c0b4:0x427,_0x1f7587:0x4a7,_0x555cd3:0x36f,_0x2f1d72:0x466,_0x39c87f:0x4e3,_0x460e62:0x58e,_0x20ae54:0x4a3,_0x5a34d3:0xaa,_0x2c84fd:0x13e,_0x548e51:0x27,_0x542f0f:0x58,_0x5d2287:0x48f,_0x58ed4b:0x446,_0x5bf56a:0x29e,_0x5d37b4:0x368,_0x339085:0x141,_0x40c742:0x190},_0x2566f7={
    _0x49c809:0x4f,_0x3bcfa7:0x665,_0x2c6e81:0xdd},_0x16d665={
    _0x5b17f4:0x99,_0x4c1d54:0x473}
  ;
  await this.base.ready(),this.internalEnsureMirroring(),this.base.on("writer",async _0x430941=>{try{if(await this.keet.local.get("@local/devices",{'device':{'key':_0x430941.core.key}}))return;const _0x373a21=await this.db.get("@keet/devices",{'key':_0x430941.core.key});if(_0x373a21)await this.db.get("@keet/members",{'key':_0x373a21.memberKey});}catch(_0x22ecca){safetyCatch(_0x22ecca);}}),this.base.local.on("remote-contiguous-length",this._handleSentLengthChanged.bind(this)),this.base.on("rotate-local-writer",()=>{this.base.local.on("remote-contiguous-length",this._handleSentLengthChanged.bind(this));});
  this.db.get("@keet/room-config").then(_0x3490d3=>{this.keet.internalProductionLog("opened id:\x20"+this.id+" title: "+_0x3490d3?..title);},safetyCatch),this.externalBlobs=new Hyperblobs(this.keet.store.get({'name':this.id+"/blobs",'encryptionKey':this.encryptionKey,'encrypted':!![],'exclusive':!![],'active':![]})),await this.externalBlobs.ready(),await this._ensureMetadata(),this.internalEnsureProfileUpdated(),this.internalEnsureUpgraded(),this.internalEnsureRepaired();
}
._close(){
  _0x1b4700={
    _0x53afb9:0x9a,_0x2fe535:0x3d,_0x2af465:0x55b},_0x35b810={
    _0xb8a2f4:0x7a,_0x2f3fc6:0x7f,_0x6a43ef:0x40}
  ;
  return Promise.all([this.base.close(),this.externalBlobs.close(),this.push?this.push.destroy():null]);
}
._handleSentLengthChanged(){
  _0x404afd={
    _0x1559a4:0x1f0,_0x2a481f:0x71},_0x402b8d={
    _0x15c27c:0x5f,_0x184434:0x1e3,_0x374b0e:0x1e5}
  ;
  if(!this.base.writable)return;
  const {
    length:_0xf3a1a7,remoteContiguousLength:_0x1c0c95}
  =this.base.local;
  if(_0xf3a1a7!==_0x1c0c95)return;
  this.keet.emit("room-sent-message",this.base.id);
}
async._ensureMetadata(){
  _0x4253df={
    _0x53b5c5:0xd2,_0x2ec589:0x10},_0x16ea4a={
    _0x3db536:0x160}
  ;
  const _0x292dec=await this.keet.internalEnterLocalTransaction();
  try{
    const [_0x52636f,_0x2a32cc]=await Promise.all([_0x292dec.get("@local/room-metadata",{'roomKey':this.key}),_0x292dec.get("@local/rooms",{'roomKey':this.key})]);
    if(_0x52636f)return;
    const _0x175d9c=!_0x2a32cc?REPAIR_VERSION:0x0;
    await _0x292dec.insert("@local/room-metadata",{'roomKey':this.key,'repairs':_0x175d9c}),await _0x292dec.flush();
  }finally{
  await this.keet.internalExitLocalTransaction();
}
}
async.internalEnsureMirroring(){
  _0x540505={
    _0x193374:0x6e,_0x3c1dd2:0x60,_0x3c049e:0x8f},_0x3e3c34={
    _0x5329f4:0x52,_0x554387:0x2fd}
  ;
  this.refs++;
  try{
    const _0x5d65ec=this.base.wakeupCapability&&this.base.wakeupCapability.key,_0xf66f88=await this.keet._getMirrorKeys(this.key);
    if(this.closing)return;
    this.keet.blindPeering.addAutobaseBackground(this.base,_0x5d65ec,{'mirrors':_0xf66f88});
  }finally{
  this.refs--;
}
}
async.internalEnsureUpgraded(){
  _0x2b840c={
    _0x39e295:0x131,_0x1261f8:0xd3},_0x11f95f={
    _0x42d433:0x8}
  ;
  this.refs++;
  try{
    const [_0x14e63a,_0x3bb699]=await Promise.all([this.db.get("@keet/system-digest"),getMemberForDeviceKey(this.db,this.deviceKey)]);
    if(!_0x3bb699?..status.isModerator||_0x14e63a?..abi.version>=this.keet.abi.autoupgrade)return;
    await this.keet.internalDispatchUpgrade(this.id,this.keet.abi.autoupgrade);
  }catch(_0x17206b){
  this.keet.onerror(_0x17206b,{'roomKey':this.key});
}finally{
this.refs--;
}
}
async.internalEnsureProfileUpdated(){
  _0x247e84={
    _0x1e88ae:0x21,_0x5619de:0x147,_0x397830:0xc3},_0x3b4adf={
    _0x1bc8c5:0x41,_0xb23fe6:0x12e}
  ;
  this.refs++;
  try{
    const [_0x18d273,_0x2cc0f8]=await Promise.all([this.keet.local.get("@local/identity"),getMemberForDeviceKey(this.db,this.deviceKey)]);
    if(this.closing||!_0x18d273||!_0x2cc0f8||b4a.equals(this.key,_0x18d273.privateProfileKey))return;
    const _0x382f4b=await this.keet.local.get("@local/rooms",{'roomKey':_0x18d273.privateProfileKey});
    if(this.closing)return;
    const _0x22cccb=_0x2cc0f8.profile.timestamp,_0x3af56b=_0x382f4b.selfMember.profile.timestamp;
    if(_0x22cccb>=_0x3af56b)return;
    const _0x4f2d5c={
      'profile':_0x382f4b.selfMember.profile,'attestation':{
        'memberKey':_0x382f4b.selfMember.key,'proof':_0x382f4b.selfMember.proofs.profileAttestation}
    }
  ;
  await this.dispatch("@keet/update-member",{'member':_0x4f2d5c});
}catch(_0x12799e){
this.keet.onerror(_0x12799e,{'roomKey':this.key});
}finally{
this.refs--;
}
}
async.internalEnsureRepaired(){
  _0x4c6719={
    _0x41126a:0x1aa,_0x2f3229:0xb6},_0x322f41={
    _0x2633fe:0x1a5}
  ;
  if(this===this.keet.privateProfile)return;
  this.refs++;
  try{
    const _0x1ac5d4=await this.keet.local.get("@local/room-metadata",{'roomKey':this.key});
    if(this.closing||_0x1ac5d4.repairs>=REPAIR_VERSION)return;
    if(this.base.linearizer.size>MAX_REPARABLE_TIP_SIZE)return;
    const _0xb17d5e=await this.db.get("@keet-private-id/identity");
    if(this.closing||_0xb17d5e)return;
    _0x1ac5d4.repairs=REPAIR_VERSION,await this.base.repair();
    if(this.closing)return;
    const _0xf2e15e=await this.keet.internalEnterLocalTransaction();
    try{
      await _0xf2e15e.insert("@local/room-metadata",_0x1ac5d4),await _0xf2e15e.flush();
    }finally{
    await this.keet.internalExitLocalTransaction();
  }
}finally{
this.refs--;
}
}
async._internalEncodeOperation(_0xd54ae,_0x3d49e4,{view:view=this.view,timestamp:timestamp=Date.now()}={}){
  _0x58994a={
    _0x4b3a28:0x89,_0x52b945:0x576},_0x1c9815={
    _0x530770:0xc,_0xd6b00:0xc0}
  ;
  const _0x2ff015=await view.db.get("@keet/system-digest"),_0x526131=loadBundle(_0x2ff015?_0x2ff015.abi.version:this.keet.abi.max);
  return _0x526131.encodeOperation(_0xd54ae,{'header':{'timestamp':timestamp},..._0x3d49e4});
}
async._encodeBatch(_0x4542cc,_0x43b659={}){
  _0x2009ae={
    _0x162f08:0xb3,_0x46d57c:0x3d9},_0x2453da={
    _0xd6e075:0xda},_0x2280e7=Array.isArray(_0x4542cc)?_0x4542cc:[_0x4542cc],_0x5ae03a=Date.now(),_0x4e909c=[];
  let _0x24e61c=![];
  for(const {type:_0x10f867,op:_0x18b4ea}of _0x2280e7){
    _0x4e909c.push(this._internalEncodeOperation(_0x10f867,_0x18b4ea,{..._0x43b659,'timestamp':_0x5ae03a})),shouldPushNotify(_0x10f867)&&(_0x24e61c=!![]);
  }
const _0x2def73=await Promise.all(_0x4e909c);
return{
  'encoded':_0x2def73,'timestamp':_0x5ae03a,'shouldPush':_0x24e61c}
;
}
async._postAppend({encoded:encoded=[],pushLength:pushLength=-0x7cc,timestamp:timestamp=Date.now()}){
  _0x323594={
    _0x5e2222:0x10c,_0x2471e0:0x1cc,_0x2d1eb6:0x3cb},_0x4e6af1={
    _0x3a8ba1:0x2c,_0x4e4dc0:0x120}
  ;
  this.keet.stats.ops+=encoded.length;
  if(this.push&&pushLength>0x0)this._safePushNotify(pushLength);
  if(this.keet.discovery)this._safeBumpDiscovery(timestamp);
  this.db.update();
}
async.dispatchBatch(_0xf0c47b,{view:view=this.view,dryRun:dryRun=!![],optimistic:optimistic=![]}={}){
  _0x49e171={
    _0x52c989:0x17,_0x3d176b:0xe2},_0x1585aa={
    _0x4d978f:0x42,_0x4a4aaf:0x5f6}
  ;
  if(!this.opened)await this.ready();
  const {
    encoded:_0x1f4da2,timestamp:_0xf94c7a,shouldPush:_0x1effdc}
  =await this._encodeBatch(_0xf0c47b,{'view':view});
  if(dryRun){
    const _0x20742f=await this.keet.internalDryRun(this,view,_0x1f4da2);
    if(!_0x20742f)return null;
  }
const _0x1dd3ff=await this.base.append(_0x1f4da2,{'optimistic':optimistic});
return await this._postAppend({'encoded':_0x1f4da2,'shouldPush':_0x1effdc,'timestamp':_0xf94c7a}),{
  'key':this.base.local.key,'length':_0x1dd3ff}
;
}
.dispatch(_0xbcc85a,_0x4a79e0,_0x22dd2d){
  _0xb43d30={
    _0x201fcf:0x92,_0x1d0f41:0x1ae,_0xf4697f:0x331},_0x33971f={
    _0x2a48f2:0x183}
  ;
  return this.dispatchBatch([{'type':_0xbcc85a,'op':_0x4a79e0}],_0x22dd2d);
}
}
module.exports=class KeetCore extends ReadyResource{
  constructor(_0x372e52,_0x5979c8={}){
    _0x4efaf9={
      _0x239ef8:0xab,_0x23f252:0x9a},_0x29d499={
      _0x4e35a6:0x5f,_0x58988c:0x1ec,_0xaf796f:0x5a3},_0x1a6c4e={
      _0x38622a:0x472,_0x50fee2:0x3b3,_0x3a67c6:0x40b,_0x4bd92b:0x6a5,_0x26ae39:0x6b2,_0x5b016d:0x4f6,_0x3e1d6d:0x5af,_0x1220f6:0x671,_0x3e9dd9:0x64d,_0x240590:0x627,_0x49f48a:0x43f,_0x1ef772:0x455,_0x14edae:0x57d},_0x4a6df7={
      _0xd83e77:0x618,_0x237c2a:0x2f,_0x40e684:0xaf}
    ;
    super(),this.dir=_0x372e52,this.opts=_0x5979c8,this.isProduction=!!_0x5979c8.production,this.isExperimental=!!_0x5979c8.experimental,this.isTesting=!!_0x5979c8.testing,this.isMobile=!!_0x5979c8.mobile,this.appVersion=_0x5979c8.appVersion?Version.parse(_0x5979c8.appVersion):null,this.debug={
    },this.versions=KeetVersions,this.abi=_0x5979c8.testingABI||{
    'max':this.isExperimental?KeetVersions.EXPERIMENTAL:KeetVersions.STABLE,'autoupgrade':this.isExperimental?KeetVersions.EXPERIMENTAL:KeetVersions.AUTOUPGRADE,'production':KeetVersions.STABLE},this.logout=_0x5979c8.logout,this.storage=new CorestoreStorage(_0x372e52,_0x5979c8.storage),this.rootCorestore=new Corestore(this.storage,{'globalCache':new Rache({'maxSize':_0x5979c8.maxCacheSize}),'manifestVersion':0x2}),this.store=this.rootCorestore.namespace(KEET_CORE_NAMESPACE),this.rootCorestore.watch(this._handleCoreOpen.bind(this)),this.local=KeetLocalDatabase.rocks(this.storage.rocks.columnFamily("keet/local-database")),this.discovery=null,this.gatekeepers=_0x5979c8.gatekeepers||[],this.push=null,this.protomuxWakeup=new Wakeup(this._handleWakeup.bind(this)),this.backoff=new TaskBackoff(),this.rooms=new Map(),this.workers=new Map(),this.firewalls=new Map(),this.activeRooms=new Set(),this._transactionLock=new ScopeLock(),this._tx=null,this.hyperconf=null,this.config=null,this.configMinVersion=null,this.errorManager=new KeetErrorManager(this,this.opts),this.swarmWorker=new SwarmWorker(this,this.opts.swarmWorker),this.files=new FileManager(this,this.opts),this._onerror=_0x5979c8.onerror||safetyCatch,this.onerror=this.errorManager?(_0x4d6ac1,_0x5b8a3b={})=>{
    const _0x1ee562=this.errorManager.normalize(_0x4d6ac1,_0x5b8a3b);
    this.errorManager.add(_0x1ee562),this._onerror(_0x1ee562);
  }
:this._onerror,this.apiV1=new V1KeetAPI(this,_0x5979c8),this.backendAPI=this.apiV1,this.api=this.backendAPI.api.core,this.tasks=null,this.swarm=null,this.swarmId=null,this.blindPeering=null,this.privateProfile=null,this.unreads=null,this.unreadsLoading=null,this.discoveryCore=null,this.discoveryCoreSession=null,this.push=null,this.state=KeetState.RESUME,this._hyperconfKey=_0x5979c8.hyperconfKey||(this.isProduction?PROD_HYPERCONF_KEY:DEV_HYPERCONF_KEY),this._hyperconfLength=_0x5979c8.hyperconfLength||(this.isProduction?PROD_HYPERCONF_CORE_LENGTH:DEV_HYPERCONF_CORE_LENGTH),this._disabledRooms=this.isTesting?new Set():null,this._relayKeys=this.isTesting?_0x5979c8.blindRelays||[]:null,this._blindPeerKeys=this.isTesting?_0x5979c8.blindMirroring||[]:null,this._gatekeeperKeys=this.isTesting?_0x5979c8.gatekeepers||[]:null,this._discoveryBootstrapKeys=this.isTesting?_0x5979c8.discoveryBootstrapKeys||[]:null,this._disableUnreadSync=this.isTesting?_0x5979c8.disableUnreadSync||![]:![],this._unreadsLock=new ScopeLock({'debounce':!![]}),this._dhtOpts=_0x5979c8.dht,this._swarmOpts=_0x5979c8.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 ScopeLock({'debounce':!![]}),this._gcEnabled=_0x5979c8.gc!==![],this._gcIdleTicks=_0x5979c8.gcIdleTicks||DEFAULT_ROOM_GC_IDLE_TICKS,this._gcInterval=_0x5979c8.gcInterval||DEFAULT_ROOM_GC_INTERVAL;
this._gcTimer=null,this._gcClosingRooms=new Set(),this._boundAutobaseTrace=this._autobaseTrace.bind(this),this.internalPairingTimeout=_0x5979c8.pairingTimeout||DEFAULT_PAIRING_TIMEOUT,this._profileDiscoveryTimeout=_0x5979c8.profileDiscoveryTimeout||DEFAULT_PROFILE_DISCOVERY_TIMEOUT,this.migrationStatus=null,this._roomMigrations=new Semaphore(MAX_PARALLEL_ROOM_MIGRATIONS),this._discoveryLock=new ScopeLock({'debounce':!![]}),this._discoverySemaphore=new Semaphore(MAX_PARALLEL_DISCOVERY_SWARMING),this._discovering=new Map(),this._rejectAnonymousProfiles=_0x5979c8.rejectAnonymousProfiles!==![],this._registryOpts=this.isTesting?_0x5979c8.userRegistry:null,this.rpcClient=null,this.userRegistry=null;
this.ackThreshold=_0x5979c8.ackThreshold,this.ackInterval=_0x5979c8.ackInterval,this.stats={
  'ops':0x0,'appends':0x0,'bytesAppended':0x0,'uploaded':0x0,'bytesUploaded':0x0,'downloaded':0x0,'bytesDownloaded':0x0},this.debugForceMigrationFailure=_0x5979c8.debugForceMigrationFailure||null,this.ready().catch(this.onerror);
}
async.backendReady(){
  _0x4c65ef={
    _0x209f93:0x17b},_0x4f4b4a={
    _0x406813:0x166}
  ;
  if(!this.backendAPI.opened)await this.backendAPI.ready();
}
get.readOnly(){
  _0x4e2872={
    _0x4eb4c5:0x13a},_0x1f35fc={
    _0x3d85bf:0x47,_0x16d3f0:0x45e}
  ;
  return this.rootCorestore.storage.readOnly||![];
}
get.suspended(){
  _0x466b8c={
    _0x52b7c7:0xf8},_0x16cc51={
    _0x1d4a88:0x132,_0x1822dd:0xc0}
  ;
  return this.state===KeetState.SUSPEND;
}
async._openNetworking(){
  _0x1fae09={
    _0x498252:0xcc,_0x43a804:0x191,_0x122c30:0x134},_0x2e587c={
    _0x2f19ab:0xd6,_0x25705c:0x20d},_0x38d218=await this.getDHTSettings();
  this.swarm=new Hyperswarm({'deferRandomPunch':!![],'dht':new DHT({..._0x38d218,...this._swarmOpts,...this._dhtOpts}),...this._swarmOpts,'relayThrough':this._relayThrough.bind(this),'keyPair':await this.rootCorestore.createKeyPair(SWARM_KEYPAIR_NAME)}),this.swarmId=HypercoreId.encode(this.swarm.keyPair.publicKey);
  this.swarm.on('connection',this._handleConnection.bind(this)),this.discovery=this._discoveryBootstrapKeys.length?new HyperDiscoveryClient(this._discoveryBootstrapKeys[0x0],{'dht':this.swarm.dht}):null;
  this.rpcClient=new ProtomuxRpcClient(this.swarm.dht,{'suspended':this.state===KeetState.SUSPEND,'relayThrough':this._relayThrough.bind(this)}),this.blindPeering=new BlindPeering(this.swarm,this.store,{'pick':0x2,'wakeup':this.protomuxWakeup,'mirrors':this.debug.disableMirrors?[]:this._blindPeerKeys,'relayThrough':this._relayThrough.bind(this)}),this._gatekeeperKeys.length>0x0&&(this.push=new KeetPush(this._gatekeeperKeys,{'dht':this.swarm.dht})),await this.swarmWorker.ready(),await this.files.ready(),this.readOnly&&(this.blindPeering.suspend(),this.swarm.suspend());
}
async._ensureDebugState(){
  _0x5c06e3={
    _0x1cf588:0x47,_0xa3a959:0x253},_0x48bd06={
    _0x14e53c:0x101},_0x42aac0=await this.internalEnterLocalTransaction();
  try{
    const _0x20cae0=await _0x42aac0.get("@local/debug")||{
    }
  ;
  if(!_0x20cae0.flags)_0x20cae0.flags=DEBUG_FLAGS;
  const _0x161532=new Set(),_0x44310e={
  }
;
for(const _0x22efd0 of _0x20cae0.flags){
  _0x161532.add(_0x22efd0.key),_0x44310e[_0x22efd0.key]=_0x22efd0.value;
}
for(const {key:_0x375ccf,value:_0x2a50da,description:_0x3b843e}of DEBUG_FLAGS){
  if(_0x161532.has(_0x375ccf))continue;
  _0x20cae0.flags.push({'key':_0x375ccf,'value':_0x2a50da,'description':_0x3b843e});
}
await _0x42aac0.insert("@local/debug",_0x20cae0),await _0x42aac0.flush(),this.debug={
  ..._0x44310e}
;
}finally{
await this.internalExitLocalTransaction();
}
}
async._open(){
  _0x1bbb2e={
    _0x39ae97:0x245,_0x4948cf:0x3d8,_0x399960:0x2b3,_0x11408b:0x21c,_0x556455:0x30a,_0x30a292:0x246,_0x494d0:0x2bf,_0x4a18b3:0x3f4,_0x2eaac7:0x407,_0x25e2db:0x415,_0x1e0bbd:0x5d3,_0x439149:0x515,_0x546182:0x4f1,_0x2adeca:0x36b,_0x2a5b2e:0x4ab,_0x11f362:0x426,_0x25a501:0x4eb,_0x20fb2a:0x369,_0x71f8c:0x2f5,_0x2e4b80:0x16e,_0xadaf0f:0x59b,_0x469651:0x5a4,_0x334706:0x44e,_0x159620:0x419,_0x1d48b9:0x2fe,_0x34362f:0x624,_0x292684:0x552,_0x4ea5bd:0x49a,_0x18b446:0x4bd,_0x1553ec:0x231,_0x287a33:0x4c1,_0xcacdbf:0x23a,_0x3faf10:0x287,_0x4185b0:0x5cd,_0xa714c3:0x35e,_0x57c6e9:0x2cc,_0x28828a:0x37f,_0xcb06de:0x3c2,_0x51fdad:0x394,_0x16f332:0x3c6,_0x4f8fc1:0x362,_0x3728a3:0x52e,_0x52f79e:0x488,_0xfca468:0x3ca,_0x8e67fc:0x5af,_0x163c69:0x511,_0x4399f9:0x5ba,_0x1fb216:0x160,_0x1d415f:0x1e3,_0x3014bd:0x2de,_0xbba824:0x4a2,_0x4a86da:0x3a2,_0x26852d:0x31d},_0x572e52={
    _0x19501d:0x244,_0x42abe1:0x286,_0x401e8c:0x2a9,_0x20966d:0x2b9,_0x5cbd99:0x156,_0xd35e36:0x111,_0x2d55b5:0x21a,_0x173764:0x2c2},_0x236c2b={
    _0x465c10:0x179,_0x5db3a0:0xd2,_0x6a7ea7:0x3eb},_0x57dbfe={
    _0x36712d:0xfe,_0x4b3a20:0x14a,_0x46aeed:0x48f}
  ;
  await this._ensureDebugState();
  await this.store.ready(),this.hyperconf=new Hyperconf(KeetConfigSpec,this.store.get(this._hyperconfKey),{'minLength':this._hyperconfLength,'production':this.isProduction});
  this.hyperconf.on("update",this._handleConfigUpdated.bind(this)),await this.hyperconf.ready(),await this._handleConfigUpdated(),await this._openNetworking(),this.tasks=new TaskManager(this),await this.tasks.ready();
  const _0x2dae19=await this._ensureMigrated();
  this._gcEnabled&&(this._gcTimer=setInterval(this._closeIdleRooms.bind(this),this._gcInterval));
  try{
    await this._loadIdentity();
  }catch(_0xd310df){
  this.onerror(_0xd310df);
}
_0x2dae19>0x0&&await this._maybeRunPostMigrations(_0x2dae19),this._refreshDiscoverySwarming(),this.discovery&&(this.discovery.on("announce",async({publicKey:_0x31de65})=>{_0x3018dd={_0x1aa846:0x1db,_0x23e70b:0x9b};this.scheduleDiscoverySwarming(_0x31de65);}),this.discovery.on("connect",async()=>{_0x3ccd82={_0x524c5f:0x1c0,_0x131db9:0x16c},_0x3cf8d1=await this.local.find("@local/rooms-by-timestamp",{'reverse':!![],'limit':0x100}).toArray();this.discovery.cork();for(const _0x11ae9a of _0x3cf8d1){const _0x5daa1c=_0x11ae9a.capabilities.discoveryKeyPair.publicKey,_0x5b4997=await this.local.get("@local/background-sync",{'discoveryPublicKey':_0x5daa1c}),_0x376751=Math.max(_0x11ae9a.timestamps.latestSync,_0x5b4997?_0x5b4997.lastSynced:0x0);this.discovery.subscribe(_0x11ae9a.capabilities.discoveryKeyPair.publicKey,{'since':_0x376751});}this.discovery.uncork();}),this.discovery.connect()),this._registryOpts&&(this.userRegistry=new UserRegistry(this,this._registryOpts),await this.userRegistry.ready());
}
async._close(){
  _0x1b2bb6={
    _0x28fce9:0xd7,_0x5e21cc:0xfd},_0x409686={
    _0x24272e:0x9d,_0x139e06:0x143}
  ;
  this.internalProductionLog("Closing\x20keet\x20core");
  if(this._gcTimer)clearInterval(this._gcTimer);
  this.backoff.destroy();
  if(this.state===KeetState.SUSPEND)await this.store.resume();
  this.internalProductionLog("Closing discovery cores");
  if(this.discoveryCore)await this.discoveryCore.close();
  if(this.discoveryCoreSession)this.discoveryCoreSession.destroy();
  this.internalProductionLog("Closing tasks"),await this.tasks.close(),this.internalProductionLog("Closing firewalls");
  for(const _0x9d0dd4 of this.firewalls.values())await _0x9d0dd4.close();
  for(const _0x17374e of this._gcClosingRooms){
    this.internalProductionLog("Closing\x20room in gc list",_0x17374e.id,_0x17374e.opened),await _0x17374e.close();
  }
this.internalProductionLog("Closing\x20user registry");
if(this.userRegistry)await this.userRegistry.close();
this.internalProductionLog("Closing rpc client"),await this.rpcClient.close(),this.internalProductionLog("Closing swarm\x20worker"),await this.swarmWorker.close(),this.internalProductionLog("Closing discovery");
if(this.discovery)await this.discovery.close();
this.internalProductionLog("Closing\x20push");
if(this.push)await this.push.destroy();
this.internalProductionLog("Closing\x20blind\x20peering"),await this.blindPeering.close(),this.internalProductionLog("Flushing DHT cache"),await this._flushDHTCache(),this.internalProductionLog("Closing\x20swarm"),await this.swarm.destroy(),this.internalProductionLog("Closing files"),await this.files.close(),this.internalProductionLog("Closing\x20all pending rooms and workers"),await Promise.allSettled([...[...this.rooms.values()].map(_0x2fe6b4=>_0x2fe6b4.close()),...[...this.workers.values()].map(_0x2e4088=>_0x2e4088.close())]),this.internalProductionLog("Closing backend"),await this.apiV1.close(),await this.internalEnterLocalTransaction(),await this.internalExitLocalTransaction();
this.internalProductionLog("Closing unread anchors"),await this.internalEnsureUnreads();
if(this.unreads)await this.unreads.close();
this.internalProductionLog("Closing\x20wakeup"),this.protomuxWakeup.destroy(),this.internalProductionLog("Closing hyperconf"),await this.hyperconf.close(),this.internalProductionLog("Closing\x20error manager");
if(this.errorManager)await this.errorManager.close();
this.internalProductionLog("Closing local db"),await this.local.close(),this.internalProductionLog("Closing\x20store"),await this.store.close(),this.internalProductionLog("Closing root corestore"),await this.rootCorestore.close(),this.internalProductionLog("Close done");
}
async.internalEnterLocalTransaction(){
  _0x1c684d={
    _0x327ed7:0x168,_0x57aae7:0x1e0}
  ;
  await this._transactionLock.lock();
  return this._tx=this.local.transaction(),this._tx;
}
async.internalExitLocalTransaction(){
  _0x46a664={
    _0x4d8e52:0x3e},_0x3eebee={
    _0x52db51:0x19d}
  ;
  await this._tx.close();
  this._transactionLock.unlock();
}
async._handleConfigUpdated(){
  _0x56f834={
    _0x4fbfb2:0x1c6},_0x20f82d={
    _0x220ba7:0x160,_0x4a3b8c:0xa1,_0x3a8833:0x1b0}
  ;
  if(this.isTesting&&!this.opts.hyperconfKey)return;
  this.config=this.hyperconf.current,this.internalProductionLog("OTA config\x20updated,\x20dkey:",HypercoreId.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,this._disabledRooms=new Set(this.config.rooms.disabled.map(_0x2f60b6=>HypercoreId.encode(_0x2f60b6))),this._disableUnreadSync=this.config.profile?..disableUnreadSync===!![];
  this.config.services.userRegistries?..length&&(this._registryOpts=this.config.services.userRegistries[0x0]);
  if(this.blindPeering)this.blindPeering.setKeys(this._blindPeerKeys);
  if(this.config.versions.minVersion){
    const {
      major:_0x35bb07,minor:_0x50ee29,patch:_0x5cf88b}
    =this.config.versions.minVersion;
    this.configMinVersion=new Version(_0x35bb07,_0x50ee29,_0x5cf88b);
  }
this.emit("force-update");
}
.shouldForceUpdate(){
  _0x32865e={
    _0x46a79f:0x197,_0x163b5c:0xa5},_0x54ddce={
    _0x2beb23:0x103,_0x5a9238:0x29d},_0x10e19d=this.config.versions.forceUpdate>KeetVersions.FORCE_UPDATE;
  const _0x1421cf=this.configMinVersion&&this.appVersion;
  const _0x40ce77=_0x1421cf?this.configMinVersion.compare(this.appVersion):0x0;
  return _0x10e19d||_0x40ce77===-0x3c21;
}
async._bumpRoom(_0x35fad9){
  _0x42e4ce={
    _0x1bf12e:0x183,_0x56beda:0x172},_0x504152={
    _0x3fa515:0x19e,_0x482a20:0x584}
  ;
  if(this.closing)return;
  if(!await this.local.get("@local/writers-by-room-key",{'roomKey':_0x35fad9}))return;
  if(this.closing)return;
  const _0x1e33aa=this.internalOpenExistingRoom(_0x35fad9);
  try{
    await _0x1e33aa.ready();
  }finally{
  this.internalReleaseRoom(_0x1e33aa);
}
}
._handleCoreOpen(_0x15f202){
  _0x52caa={
    _0x3ecfe1:0x2e,_0x51b0fa:0x7c,_0x2c3bba:0xb5,_0x4ef995:0x1c,_0xd04373:0x235},_0x535299={
    _0x535cdf:0x68d,_0x2be376:0x6d7,_0x2651c0:0x335,_0x165726:0x81,_0x5eb9dd:0x246,_0x182a1a:0x19c,_0x5b88c8:0x1e5,_0x54233f:0x18a,_0x4084e0:0x102,_0x34b667:0x301,_0x17de45:0x1a,_0x3e85da:0x162},_0x4a259a={
    _0x59bfaf:0x1c3,_0x92a837:0x19a,_0xbcf14f:0x1c0,_0x577c7e:0x2ba,_0x15b6d9:0x528,_0x29fecd:0x48d,_0xb9779c:0x51a,_0x55fda5:0x5fd,_0xe366de:0x67f,_0x2756a4:0x4fe},_0x41f475={
    _0x4607a2:0x191,_0x4d50aa:0x133,_0xeac26f:0x183},_0x6890c8={
    _0x1b0d9c:0x85,_0x26d947:0x4,_0xc0f2f0:0x1d0},_0x5df68b={
    _0x1a193f:0x32d,_0x154386:0x44d,_0x4ebbd1:0x38c,_0x39e355:0x2ee},_0x55d141={
    _0x133183:0x6a,_0x5e801f:0x315},_0x366e25={
    _0x1b95c0:0x19,_0x33ac37:0x2e1},_0x2dd8f7={
    _0x3b025a:0x33,_0xbfed4:0x56,_0x48a899:0x304,_0x323b8d:0x1a9,_0x233157:0xb,_0x1dea0c:0x569,_0x554979:0x6ec,_0x8b416a:0x107,_0x4890df:0x1fa},_0x1a6193={
    _0x1a95ff:0x1e6},_0x630678={
    _0x24b298:0x516,_0x24f586:0x526,_0x4de455:0x596,_0x2a64fd:0x562,_0x3dece0:0x682,_0x31e83f:0x56,_0x7c6b9f:0x11f,_0x5bed42:0x3a,_0x38399b:0x26b,_0x1f4141:0x53e,_0x152ab3:0x498,_0x5d471e:0x64a,_0x393fb3:0x536,_0x30f98e:0x5be,_0x204b76:0x749},_0x1170a1={
    _0x84fe1b:0xf3,_0x318fdc:0x163},_0x42ec2c={
    _0x33260b:0x15,_0x4ffdf4:0x141,_0x2cf563:0x16,_0x3e2a54:0x161,_0x480f86:0x121,_0x12aabf:0x6,_0x2cb13b:0x36,_0x4e4b62:0x14c,_0x4b7bc2:0x9c},_0xf2d584={
    _0x1c5d73:0x3b2},_0x44f159={
    _0x9cdfea:0xc5,_0x2635b0:0xfc},_0x14f061={
    _0x270c90:0x14c,_0x45bdf8:0x153,_0x5d9557:0x9f,_0x2af799:0x3,_0x101691:0xb3,_0x4eaf29:0x2e,_0x4091a7:0x1ef,_0x33953f:0xed,_0x286dcd:0xe8,_0x29a2b3:0x8c,_0x236648:0x16b,_0x310cdb:0x35a,_0x41fb41:0x21d,_0x423588:0x13a,_0x1d1f5d:0x52,_0x2878be:0x13f,_0x179c46:0x40,_0x336089:0x29f,_0x5c7e4e:0x17d,_0x410a19:0x5c,_0xe15ea4:0x2d8,_0x497602:0x30f,_0x7bcb2d:0x1da,_0x2f1b2d:0x22c,_0x4e88e3:0x231,_0x2316c9:0x69,_0x13f4cf:0x130,_0xfac6cd:0x1d,_0x543f22:0x1a8,_0x3dd2cf:0x30d,_0x3a17a2:0x204,_0x4fa7f3:0x1c1,_0x32957d:0x68,_0x26720b:0xab,_0x319254:0x8b,_0x5a0163:0x16d,_0x40bae9:0x1a8,_0xb2d4b7:0x1b0},_0x499124={
    _0x442225:0x31c},_0x236ee1=new Hypercore({'core':_0x15f202,'weak':!![]}),_0x5a96e9=new ScopeLock({'debounce':!![]}),_0x5343bb=async()=>{
    if(!await _0x5a96e9.lock())return;
    try{
      const _0x1c6f69=_0x15f202.state.storage.read(),_0x50c2fa=[_0x1c6f69.getUserData("referrer"),_0x1c6f69.getUserData("autobase/view")];
      _0x1c6f69.tryFlush();
      const [_0x2b9ed3,_0x2356f0]=await Promise.all(_0x50c2fa);
      if(!_0x2b9ed3||_0x2356f0)return;
      await this._bumpRoom(_0x2b9ed3);
    }catch(_0x468fdf){
    this.onerror(_0x468fdf);
  }finally{
  _0x5a96e9.unlock();
}
}
;
_0x236ee1.on("verification-error",_0x379aea=>{this.onerror(_0x379aea,{'coreKey':_0x236ee1.key,'prefix':"CORE_VERIFICATION_ERROR"});}),_0x236ee1.on("conflict",()=>{this.onerror(new Error("Conflict in Hypercore"),{'coreKey':_0x236ee1.key,'prefix':"CORE_CONFLICT"});}),_0x236ee1.on("invalid-request",_0x438d23=>{this.onerror(_0x438d23,{'coreKey':_0x236ee1.key,'prefix':"CORE_INVALID_REQUEST"});}),_0x236ee1.on("append",_0x5343bb),_0x236ee1.on('upload',(_0x12f38d,_0x413d8d)=>{this.stats.uploaded++;this.stats.bytesUploaded+=_0x413d8d;});
_0x236ee1.on('download',(_0x2a1642,_0x34976e)=>{this.stats.downloaded++;this.stats.bytesDownloaded+=_0x34976e;}),_0x236ee1.once("ready",()=>{_0x2d0540={_0x2fd9eb:0x135,_0x91022d:0x158},_0x4ca38d={_0x2eb50b:0x6b1,_0x52bd43:0x1bf};if(_0x236ee1.writable){let _0x22384c=_0x236ee1.length,_0x29a832=_0x236ee1.byteLength;_0x236ee1.on('append',()=>{_0x541b99=_0x236ee1.length;const _0x40db42=_0x236ee1.byteLength;this.stats.appends+=_0x541b99-_0x22384c,this.stats.bytesAppended+=_0x40db42-_0x29a832,_0x22384c=_0x541b99,_0x29a832=_0x40db42;});}});
}
async._handleWakeup(_0x41937c){
  _0x484750={
    _0x126f20:0x27d,_0x2ea550:0x257,_0x2d7a43:0x28e,_0xb8b2e8:0x412,_0x3add80:0x2ba},_0x569a76={
    _0x59876e:0x3f,_0xa18bc4:0x6f},_0xec4760={
    _0x643991:0xb0,_0x1c4f48:0x45c},_0x196414={
    _0x5b5993:0x241}
  ;
  if(this.discovery)return;
  try{
    const [_0x16b6ff,_0x2eec6f]=await Promise.all([this.local.get("@local/writers-by-wakeup-topic",{'wakeupTopic':_0x41937c}),this.local.get("@local/rooms-by-wakeup-topic",{'capabilities':{'wakeupTopic':_0x41937c}})]);
    if(!_0x16b6ff&&!_0x2eec6f)return;
    const _0x5cb768=_0x16b6ff?..mailbox||_0x2eec6f?..capabilities.mailboxKeyPair.publicKey,_0x27b5b9=this.protomuxWakeup.session(_0x5cb768,{'active':![],'discoveryKey':_0x41937c,'onpeeractive':_0x1590d5=>{if(!_0x16b6ff)return;_0x27b5b9.announce(_0x1590d5,[{'key':_0x16b6ff.key,'length':0x1}]);}});
    if(_0x2eec6f)await this._bumpRoom(_0x2eec6f.roomKey);
  }catch(_0x116019){
  this.onerror(_0x116019);
}
}
async._maybeRunMigrations(_0x5d9c52,_0x4771c6){
  _0x4771c6===-0x23df&&await require('./lib/migrations/3')(this,_0x5d9c52),_0x4771c6===-0x22d0&&await require('./lib/migrations/4')(this,_0x5d9c52),_0x4771c6===--0x2985&&await require('./lib/migrations/4')(this,_0x5d9c52),_0x4771c6<--0x27e8&&await require('./lib/migrations/7')(_0x5d9c52),_0x4771c6<0x9&&await require('./lib/migrations/8')(_0x5d9c52);
}
async._maybeRunPostMigrations(_0x474878){
  _0x474878===--0x4dda&&await require('./lib/migrations/4/post')(this),_0x474878===0x5&&await require('./lib/migrations/4/post')(this);
}
async._ensureMigrated(){
  _0x1b1a52={
    _0x285638:0xf5,_0x35a64c:0x3dd},_0x24daf6={
    _0x3238c6:0x33},_0x182604={
    _0x410bdf:0x188,_0x7ad38b:0x94}
  ;
  let _0x3c5748=0x0;
  const _0x4503ee=await this.internalEnterLocalTransaction();
  try{
    const _0x55760f=await _0x4503ee.get("@local/migrations"),_0xbdb82f=_0x55760f?_0x55760f.version:-0x37f;
    _0xbdb82f<MIGRATION_VERSION&&(_0x3c5748=_0xbdb82f,await this._maybeRunMigrations(_0x4503ee,_0xbdb82f),await _0x4503ee.insert("@local/migrations",{'version':MIGRATION_VERSION})),await _0x4503ee.flush();
  }finally{
  await this.internalExitLocalTransaction();
}
const _0x3670a8=await this.local.find("@local/room-migrations-by-priority").toArray(),_0x1137c8=[],_0x477825=[];
const _0x22ddff=[];
for(const _0x35a8a9 of _0x3670a8){
  const _0x22cc58=this._disabledRooms.has(HypercoreId.encode(_0x35a8a9.roomKey));
  if(_0x22cc58)_0x22ddff.push(_0x35a8a9);
  else{
    if(_0x35a8a9.v3?..privateProfile)_0x1137c8.push(_0x35a8a9);
    else _0x477825.push(_0x35a8a9);
  }
}
if(_0x22ddff.length>-0x1b1a){
  const _0xc1ee25=await this.internalEnterLocalTransaction();
  try{
    for(const _0x4eed1d of _0x22ddff){
      const _0x491c60=await _0xc1ee25.get("@local/room-migrations",{'roomKey':_0x4eed1d.roomKey});
      await _0xc1ee25.delete("@local/room-migrations",_0x4eed1d),await roomMigrationsStats(_0xc1ee25,null,_0x491c60);
    }
  await _0xc1ee25.flush();
}finally{
await this.internalExitLocalTransaction();
}
}
await Promise.all(_0x1137c8.map(_0x25b9c4=>{return this._migrateRoom(_0x25b9c4,{'migratingRooms':_0x477825});}));
for(const _0x1f5fc3 of _0x477825){
  this._migrateRoom(_0x1f5fc3).catch(this.onerror);
}
return _0x3c5748;
}
async._migrateRoom(_0x2c1385,{migratingRooms:_0x3347b8}={}){
  _0x1c107e={
    _0x4f1ce2:0x1af,_0x1bbbe8:0xe5,_0x3aedf7:0x2c8},_0x3c0f05={
    _0xd039d2:0x60,_0x283f63:0x21e}
  ;
  await this._roomMigrations.wait();
  try{
    const _0x5ee9e4=_0x2c1385.errored;
    if(!_0x5ee9e4){
      if(!this.migrationStatus)this.migrationStatus={
        'remaining':0x0}
      ;
      this.migrationStatus.remaining++,this.emit("migration-status",this.migrationStatus);
    }
  if(!_0x2c1385.timestamp){
    const _0x34acc1=await this.internalEnterLocalTransaction();
    try{
      _0x2c1385.timestamp=Date.now();
      const _0x3ca738=await _0x34acc1.get("@local/room-migrations",_0x2c1385);
      await _0x34acc1.insert("@local/room-migrations",_0x2c1385),await roomMigrationsStats(_0x34acc1,_0x2c1385,_0x3ca738),await _0x34acc1.flush();
    }finally{
    await this.internalExitLocalTransaction();
  }
}
const _0x5b11ff=Date.now()-_0x2c1385.timestamp>V3_MIGRATION_EXPIRATION;
let _0x5a298b=![],_0x501ec9=![];
try{
  _0x2c1385.v3&&!_0x5b11ff&&await require('./lib/migrations/3/room')(this,_0x2c1385.roomKey,_0x2c1385.v3,{'migratingRooms':_0x3347b8});
}catch(_0x235bee){
this.onerror(_0x235bee),_0x501ec9=!![],_0x5a298b=!!this.closing;
}
const _0x3e82a8=await this.internalEnterLocalTransaction();
try{
  const _0x49b7cb=await _0x3e82a8.get("@local/room-migrations",_0x2c1385);
  if(_0x501ec9){
    if(!_0x5ee9e4)_0x2c1385.errored=!_0x5a298b;
    await _0x3e82a8.insert("@local/room-migrations",_0x2c1385),await roomMigrationsStats(_0x3e82a8,_0x2c1385,_0x49b7cb);
  }else await _0x3e82a8.delete("@local/room-migrations",_0x2c1385),await roomMigrationsStats(_0x3e82a8,null,_0x49b7cb);
await _0x3e82a8.flush();
}finally{
await this.internalExitLocalTransaction();
}
!_0x5ee9e4&&(this.migrationStatus.remaining--,this.emit("migration-status",this.migrationStatus));
}finally{
this._roomMigrations.signal();
}
}
async._closeIdleRooms(){
  _0x2cd289={
    _0xa27524:0x176,_0x1d7380:0xd4},_0x2654de={
    _0x305d7f:0x13d,_0x59c8c4:0x93}
  ;
  const _0x1ca783=[];
  const _0x243b0e=[];
  for(const _0x38db4c of this.rooms.values()){
    if(_0x38db4c.refs>0x0)continue;
    if(this.activeRooms.has(_0x38db4c)||++_0x38db4c.idleTicks<this._gcIdleTicks)continue;
    this.rooms.delete(_0x38db4c.id),this._gcClosingRooms.add(_0x38db4c),_0x1ca783.push(_0x38db4c.close()),_0x243b0e.push(_0x38db4c);
  }
await Promise.allSettled(_0x1ca783);
for(const _0x21f77c of _0x243b0e)this._gcClosingRooms.delete(_0x21f77c);
}
.internalCloseRoom(_0xa89096){
  _0x4664e6={
    _0x427e53:0x12,_0x46fdc9:0x16f},_0x2c4dad={
    _0x47a225:0x1bb,_0x1b7bd0:0x295}
  ;
  this.rooms.delete(_0xa89096.id);
  this._gcClosingRooms.add(_0xa89096);
}
.debugPauseGC(){
  _0x57f774={
    _0x1a423e:0x70,_0x32d429:0xe6,_0x426597:0x129},_0x2ae24f={
    _0x262fb3:0x140,_0x21621f:0x3e2}
  ;
  if(!this._gcTimer)return;
  clearInterval(this._gcTimer),this._gcTimer=null;
}
.debugResumeGC(){
  _0x459f40={
    _0x59131d:0xdc},_0x29bd36={
    _0x52bcd6:0x90,_0x141cb9:0x40}
  ;
  if(this._gcTimer)return;
  this._gcTimer=setInterval(this._closeIdleRooms.bind(this),this._gcInterval);
}
async.internalDiscoveryCompleted(_0x9371c8,_0x2d4ae9){
  _0x496528={
    _0x31d0a0:0x65,_0xe84e72:0x517},_0x5a1384={
    _0x5b7f24:0x146,_0x2b9260:0x191,_0x3354a4:0x18c}
  ;
  try{
    const _0x44a895=this._discovering.get(_0x2d4ae9);
    if(!_0x44a895)return;
    const _0xa9378=await this.internalEnterLocalTransaction();
    try{
      const _0x54f892=_0x44a895.roomInfo,_0x4d77a7=_0x54f892.capabilities.discoveryKeyPair.publicKey;
      if(_0x44a895.room)this.internalReleaseRoom(_0x44a895.room);
      const _0x234cd8=await _0xa9378.get("@local/background-sync",{'discoveryPublicKey':_0x4d77a7});
      _0x234cd8&&await _0xa9378.insert("@local/background-sync",{..._0x234cd8,'lastSynced':Date.now(),'dirty':![]}),await _0xa9378.flush();
    }finally{
    await this.internalExitLocalTransaction();
  }
this._discovering.delete(_0x2d4ae9),this._discoverySemaphore.signal();
}catch(_0x1064e0){
this.onerror(_0x1064e0);
}
}
async._startDiscoverySwarming(_0x58616e,_0x3ed6fe){
  _0x2ca160={
    _0x3370db:0x110,_0x154316:0xc0,_0x5e845d:0xe3},_0x6967eb={
    _0x3d4a5f:0x104,_0x4701c3:0xcb}
  ;
  if(!await this._discoverySemaphore.wait())return![];
  if(this.closing)return![];
  const _0x41d91a=this._discovering.get(_0x3ed6fe);
  if(!_0x41d91a)return![];
  this.swarmWorker.startDiscoverySwarming(_0x58616e,{'roomId':_0x3ed6fe});
  if(_0x41d91a.updated)this.swarmWorker.notifyDiscoveryUpdate(_0x58616e);
  return!![];
}
async._refreshDiscoverySwarming(){
  _0xcd0686={
    _0x17e529:0xf,_0x2afc0e:0x18a,_0x4e68cb:0x1ae},_0x56f1e7={
    _0x113a08:0x2c,_0x4dad6f:0x65}
  ;
  if(!await this._discoveryLock.lock())return;
  if(this.closing)return;
  try{
    const _0x58bd59=await this.internalEnterLocalTransaction();
    try{
      for await(const {discoveryPublicKey:_0x2d1243}of _0x58bd59.find("@local/background-sync-by-dirty",{'reverse':!![]})){
        const _0x4b5865=await this.local.get("@local/rooms-by-discovery",{'capabilities':{'discoveryKeyPair':{'publicKey':_0x2d1243}}});
        if(!_0x4b5865)continue;
        const _0x482a0a=HypercoreId.encode(_0x4b5865.discoveryKey);
        if(this._discovering.has(_0x482a0a))continue;
        const _0x55a16f=this.internalOpenExistingRoom(_0x4b5865.roomKey);
        this._discovering.set(_0x482a0a,{'updated':![],'room':_0x55a16f,'roomInfo':_0x4b5865});
        const _0xf5b7c2=this._startDiscoverySwarming(_0x4b5865.capabilities.swarmTopic,_0x482a0a);
        if(!_0xf5b7c2)this.internalReleaseRoom(_0x55a16f);
      }
    await _0x58bd59.flush();
  }finally{
  await this.internalExitLocalTransaction();
}
}catch(_0x20ab12){
this.onerror(_0x20ab12);
}finally{
this._discoveryLock.unlock();
}
}
async.scheduleDiscoverySwarmingFromDiscoveryKey(_0xf4ba1){
  _0x4d398b={
    _0x39dc86:0xe3,_0x10494c:0x18a,_0x3b1597:0x45e},_0x3ea7d3={
    _0x100201:0x84,_0x42e0d2:0x1db,_0x6d0a29:0x3f5}
  ;
  const _0x4a76ad=await this.local.get("@local/rooms-by-discovery-key",{'discoveryKey':_0xf4ba1});
  if(!_0x4a76ad)return;
  return this.scheduleDiscoverySwarming(_0x4a76ad.capabilities.discoveryKeyPair.publicKey);
}
async.scheduleDiscoverySwarming(_0x3ba314){
  _0x3f7bd4={
    _0x2960b9:0x52,_0x51b9f0:0x1f9},_0x37a0a0={
    _0x224a16:0x195,_0x752a6e:0x123,_0x560975:0x290},_0x30e1d4=await this.internalEnterLocalTransaction();
  try{
    const _0x2e1ef6=await _0x30e1d4.get("@local/background-sync",{'discoveryPublicKey':_0x3ba314}),_0x55d5e1=_0x2e1ef6?..lastSynced||0x0;
    await _0x30e1d4.insert("@local/background-sync",{'discoveryPublicKey':_0x3ba314,'timestamp':Date.now(),'lastSynced':_0x55d5e1,'dirty':!![]}),await _0x30e1d4.flush();
  }finally{
  await this.internalExitLocalTransaction();
}
this._refreshDiscoverySwarming();
}
async.internalBlobsActiveInRoom(_0x38a46a){
  _0x36f6be={
    _0x3fdb2e:0xae,_0x3ff17b:0x146},_0x4e72b3={
    _0x28dcd4:0x15b,_0x4dbeb6:0xa0},_0xe333e8=HypercoreId.encode(_0x38a46a),_0x19b8fb=this.rooms.get(_0xe333e8);
  if(!_0x19b8fb)return;
  const _0x5337d7=await this.local.get("@local/rooms",{'roomKey':_0x38a46a});
  if(!_0x5337d7)return;
  const {
    capabilities:_0x34ce64}
  =_0x5337d7;
  if(!_0x34ce64||!_0x34ce64.mailboxKeyPair)return;
  try{
    await _0x19b8fb.ready();
  }catch{
  return;
}
if(!_0x19b8fb.externalBlobs)return;
const _0x2f86b4=await this._getMirrorKeys(_0x38a46a,_0x5337d7);
if(_0x19b8fb.closing)return;
this.blindPeering.addCoreBackground(_0x19b8fb.externalBlobs.core,_0x34ce64.mailboxKeyPair.publicKey,{'mirrors':_0x2f86b4,'pick':0x1});
}
async._getMirrorKeys(_0x5a7428,_0x13d197){
  _0x6c2e12={
    _0x2fa523:0x1bf,_0x53024b:0x8c,_0xff6e01:0xbd},_0x29feb5={
    _0x2362fe:0x63,_0x13f758:0x1b9}
  ;
  if(this.debug.disableMirrors)return[];
  if(!_0x5a7428)return this._blindPeerKeys;
  const _0x5b617d=_0x13d197||await this.local.get("@local/rooms",{'roomKey':_0x5a7428});
  if(!_0x5b617d||!_0x5b617d.config.blindPeers?..length)return this._blindPeerKeys;
  return _0x5b617d.config.blindPeers;
}
._relayThrough(_0x252b4b){
  _0x58815c={
    _0x27701e:0x18,_0x20751f:0x104,_0x329d3e:0x9f},_0x26e9c0={
    _0x5ed5bf:0x53,_0x243994:0x14b}
  ;
  if(_0x252b4b||this.swarm.dht.randomized)return this._relayKeys;
  return null;
}
.internalProductionLog(..._0x1c4f56){
  _0x1360de={
    _0x4350d4:0x107,_0x2770bf:0xff,_0x21742c:0x152},_0x16066f={
    _0x318150:0x141,_0x48f679:0xd3}
  ;
  if(!this.isProduction)return;
  const _0x533453=new Date();
  console.log(_0x533453,..._0x1c4f56);
}
._handleConnection(_0x11e743){
  _0x5d93ff={
    _0x105fd4:0x1bb},_0x404eb0={
    _0x96c823:0x5cc},_0x1a17a7={
    _0x59e6bb:0x356,_0xa99ac:0x82},_0x4f7ac2={
    _0x1f2f89:0x2ba,_0x1293ab:0x36c,_0x29bc60:0x2da,_0x51c9d4:0x192,_0x2fd1b5:0x41a,_0x2b87c5:0x4c7,_0x558832:0x30d,_0x4a5adb:0x18f,_0xcc5a7:0x283,_0x4a2a99:0x8d,_0x35df08:0x19f,_0x55feea:0xc0,_0x492314:0x22d,_0x316c34:0x209,_0x739907:0x203},_0x1bea26={
    _0x3bc27b:0x22e},_0x1b3bfc={
    _0x50bf77:0x1d1},_0x484b40={
    _0x26b176:0x186,_0x2c4f1b:0x1a9,_0x4225ab:0x206},_0x302bad=HypercoreId.encode(_0x11e743.publicKey),_0x26dc5b=HypercoreId.encode(_0x11e743.remotePublicKey),_0x2abb90=Date.now();
  let _0x3005b4=--0x18a0;
  this.internalProductionLog("got "+(_0x11e743.isInitiator?"client":"server")+(" connection\x20from\x20")+_0x302bad+" to "+_0x26dc5b);
  let _0x22bb1d=null;
  _0x11e743.once('error',_0x531183=>{_0x22bb1d=_0x531183;}),_0x11e743.once("close",()=>{this.internalProductionLog("connection closed to\x20"+_0x26dc5b+(", with err:\x20")+_0x22bb1d+'\x20('+(Date.now()-_0x2abb90)+'\x20ms\x20'+_0x3005b4+(" bytes recv)"));}),_0x11e743.on("data",_0x422f75=>{_0x3005b4+=_0x422f75.byteLength;});
  this.protomuxWakeup.addStream(_0x11e743),this.rootCorestore.replicate(_0x11e743);
}
async._createInitialIdentity(){
  _0x56a224={
    _0x2c6e27:0x14b,_0x29452d:0x66,_0x1aa749:0xac},_0x147f83={
    _0x2d2319:0xef,_0x288c6d:0xc3},_0x4e9af5=IdentityKey.generateMnemonic();
  const _0x4f2410=this.tasks.restoreIdentity(GLOBAL_TASK,{'mnemonic':_0x4e9af5,'recover':![]});
  await _0x4f2410.run();
}
async._loadIdentity(){
  _0x42ea66={
    _0x4bfe46:0xcc,_0x1d9f1b:0x2a,_0x1abe5c:0x1c,_0x259f97:0xa7,_0x4d7f5d:0xb9,_0x5e3c10:0x1d8,_0x4bcce5:0x60e,_0x3b5f40:0x515,_0x5c21c2:0x56c,_0x424e86:0x6cb,_0xc4d886:0x36b,_0x255718:0x45e,_0x3a836d:0x705,_0x216b14:0x60f,_0x2ff321:0x540,_0xbe9726:0x3fb,_0x1e853c:0x478,_0x4b67cb:0x502,_0x47e318:0x5bf,_0x1d7b82:0x5ad,_0x219068:0x31a,_0x110a20:0x2ba,_0x12f98f:0x334,_0x3d7fb5:0x3d5,_0x1f77c0:0x415,_0x526b60:0x21b,_0x2ceb08:0x3bf,_0x5bfe87:0x3c8,_0x28e879:0x402,_0x61136f:0x420,_0x8f4733:0x5ba},_0x363588={
    _0x402c2c:0x41f,_0x571076:0xf0,_0x3ca587:0x124},_0x31dcf6={
    _0xf1945:0x98,_0xd8b2ee:0x185},_0x10c3c3={
    _0x197567:0x1ba,_0x396c58:0x1f3}
  ;
  let _0x4e348a=await this.local.get("@local/identity");
  if(!_0x4e348a)await this._createInitialIdentity();
  _0x4e348a=await this.local.get("@local/identity");
  if(this.privateProfile)return;
  const _0x104049=await this.local.get("@local/rooms",{'roomKey':_0x4e348a.privateProfileKey});
  this.privateProfile=await this.internalOpenPrivateProfile(),this.swarmWorker.startActiveSwarming(_0x104049.capabilities.swarmTopic);
  queueMicrotask(async()=>{try{const _0x1dc027=Math.min(this.abi.production,KeetVersions.FEATURES_TO_ABI.UNREADS);await this.internalDispatchUpgrade(this.privateProfile.id,_0x1dc027),await this.internalRefreshUnreads();}catch(_0x3d9849){this.onerror(_0x3d9849);}});
}
async.internalDispatchUpgrade(_0x2b3261,_0x3f42b9){
  _0x351976={
    _0x5ec90e:0x5f},_0x4f8253={
    _0x10f892:0x1d2,_0xb26d0b:0xb1}
  ;
  if(!_0x2b3261||!_0x3f42b9)return;
  const _0x5f19ed=this.internalOpenExistingRoom(_0x2b3261);
  try{
    const _0x1e6fc5=this.batch(_0x5f19ed.id),_0x53a64c=await _0x1e6fc5.dispatch("@keet/upgrade",{'version':_0x3f42b9});
    if(_0x53a64c===-0x210e)return;
    if(_0x3f42b9>=--0x245c){
      const _0xd9160a=await _0x5f19ed.db.get("@keet/system-digest"),_0x4c975c="@keet/migrate-abi",_0x1b3d66={
        'header':{
          'timestamp':_0x1e6fc5.timestamp},'from':_0xd9160a?..abi.version,'to':_0x3f42b9},_0x3feedd=loadBundle(_0x3f42b9).encodeOperation(_0x4c975c,_0x1b3d66);
      await _0x1e6fc5.append(_0x3feedd);
    }
  await _0x1e6fc5.flush();
}finally{
this.internalReleaseRoom(_0x5f19ed);
}
}
async._bumpCache(){
  _0x2242aa={
    _0x1e2d90:0x153,_0x710f83:0x1fd},_0x12d5ad={
    _0x567fb7:0x5a,_0x2c0855:0x2c3}
  ;
  try{
    if(!await this._cacheLock.lock())return;
    try{
      await this._processCache();
    }finally{
    this._cacheLock.unlock();
  }
}catch(_0x4d9e51){
this.onerror(_0x4d9e51);
}
}
async._processCache(){
  _0x5f4eaf={
    _0x14b135:0x17c},_0x2fb049={
    _0x322046:0x4af},_0x371796=[];
  while(this._pendingTraces.length>-0x828){
    const _0x3e2c00=this._pendingTraces.pop();
    _0x371796.push(this._updateCache(_0x3e2c00));
  }
const _0x5173d7=await Promise.all(_0x371796),_0x23d399=await this.internalEnterLocalTransaction();
try{
  for(const _0x500bc1 of _0x5173d7){
    if(!_0x500bc1)continue;
    await _0x23d399.insert(_0x500bc1.collection,_0x500bc1.record);
  }
await _0x23d399.flush();
}finally{
await this.internalExitLocalTransaction();
}
}
async._updateCache({roomKey:_0x44badb,collection:_0x3b10af,record:_0x380688}){
  _0x29f3a3={
    _0x429aee:0xec,_0x1f8497:0x11c},_0x5a3728={
    _0x5bc594:0x16a,_0x2289cb:0xd0,_0x1203c2:0x141}
  ;
  if(_0x3b10af==="@keet/members"){
    if(_0x380688?..profile.avatar){
      const _0xce2ff0=this.internalOpenExistingRoom(_0x44badb);
      try{
        await restoreAvatar(_0xce2ff0.blobs,_0x380688.profile.avatar);
      }finally{
      this.internalReleaseRoom(_0xce2ff0);
    }
}
return{
  'collection':"@local/members",'record':_0x380688}
;
}
if(_0x3b10af==="@keet/devices")return{
  'collection':"@local/devices",'record':{
    'roomKey':_0x44badb,'device':_0x380688}
}
;
return null;
}
._cacheRoomReads(_0x26092b,_0x1d6e82,_0x4f3f25){
  _0x4ff549={
    _0x1a3656:0x132},_0x5c0aa5={
    _0x1e36a0:0x7c,_0x13af9:0x126}
  ;
  this._pendingTraces.push({'roomKey':_0x26092b,'collection':_0x1d6e82,'record':_0x4f3f25});
  this._bumpCache();
}
.createFirewall(_0x227abd){
  _0x5863ac={
    _0x5274b9:0x156,_0x1776b2:0x219,_0xc9213d:0x259,_0x40b498:0xbc,_0x1a91d9:0x4af,_0x4f463a:0x339,_0x38d593:0x409},_0x5676ff={
    _0x3c3947:0x53e,_0x92e0b0:0x1b5,_0x133f6a:0x6e},_0x33eabc={
    _0x93d3a5:0xfe,_0x2c1a4d:0x267},_0x365ed2=new RoomFirewall(this,_0x227abd);
  return this.firewalls.set(_0x227abd,_0x365ed2),_0x365ed2.once("close",()=>{_0x5510b2=this.firewalls.get(_0x227abd);if(_0x5510b2!==_0x365ed2)return;this.firewalls.delete(_0x227abd);}),_0x365ed2;
}
._autobaseOpen(_0x5a24f1,_0x480c05){
  _0x41d5ef={
    _0x95b1b9:0x123,_0x2c9204:0x1e},_0x487dfd={
    _0x1156c8:0xc8,_0x58d7ab:0x185}
  ;
  let _0x5c4b07=null;
  !_0x480c05.internal&&(_0x5c4b07=(_0x1b899c,_0x5b15cd)=>this._cacheRoomReads(_0x480c05.key,_0x1b899c,_0x5b15cd));
  const _0x15c20b={
    'autoUpdate':!![],'extension':![],'trace':_0x5c4b07}
  ;
  const _0x2ca3c8=KeetIndexing.autobaseOpen(_0x5a24f1,_0x480c05),_0x1cbefa=KeetContract.bee(_0x5a24f1,{'hyperdb':_0x15c20b});
  return{
    ..._0x1cbefa,'core':_0x1cbefa.cores.db,'legacy':_0x2ca3c8}
  ;
}
._autobaseClose(_0x96c3c7){
  _0xb76aaa={
    _0x259532:0x48,_0x5ec056:0xf6,_0x325ad6:0x2a0}
  ;
  return Promise.all([_0x96c3c7.db.close(),_0x96c3c7.blobs.close(),_0x96c3c7.legacy.close()]);
}
async._autobaseUpdate(_0x4bc315,_0x20ee50){
  _0x34f4f5={
    _0x14d37c:0x49,_0x47cb11:0x18,_0x1635ce:0x550},_0x3eec1a={
    _0x39c391:0x1d7,_0x389a29:0x1dc,_0x4fad14:0x2d4}
  ;
  const _0x195501=new RoomViewSync(this,_0x4bc315,_0x20ee50.base,_0x20ee50);
  await _0x195501.run();
  const _0x40add7=HypercoreId.encode(_0x20ee50.base.discoveryKey);
  _0x195501.runPostUpdate();
  const _0x730962=this._discovering.get(_0x40add7);
  _0x730962&&(_0x730962.updated=!![],this.swarmWorker.notifyDiscoveryUpdate(_0x40add7));
}
async._autobaseApply(_0x5f3e4f,_0x1dd2de,_0x38fe20,{dryRun:dryRun=![]}={}){
  _0x251fa5={
    _0x1bd7ed:0x6a,_0x5a3761:0x40},_0x575b22={
    _0x44b171:0x8d,_0x7b3f4f:0x132},{
    blobs:_0xdb19ba,db:_0x22204c,core:_0x41f584,legacy:_0x22ab95}
  =_0x1dd2de,_0x35e833=!dryRun?this._boundAutobaseTrace:null,_0x37d1a3=_0x41f584.length>0x0;
  let _0x2bc62c=![],_0x49e8fa=0x0;
  if(!_0x37d1a3){
    _0x49e8fa=await KeetCoreV3Apply.autobaseApply(_0x5f3e4f,_0x22ab95,_0x38fe20);
    if(_0x49e8fa===_0x5f3e4f.length)return!![];
    _0x2bc62c=_0x22ab95.core.length>-0x4b86;
  }
const _0x1171a2=_0x22204c.transaction(),_0x49cbaf=_0xdb19ba.batch();
let _0x1536ec=null;
let _0x30b238=![];
try{
  if(_0x2bc62c){
    const _0x4ccb28=_0x5f3e4f[_0x49e8fa];
    if(dryRun||_0x4ccb28?..optimistic)return!![];
    _0x38fe20.preferFastForward(),await KeetCoreV3Apply.migrate(this.store,_0x38fe20.base,_0x22ab95,_0x1171a2,_0x49cbaf);
  }
const _0x436892=await _0x1171a2.get("@keet/system-digest");
if(_0x436892){
  const _0x48bba8=_0x436892.settings.isExperimental?this.abi.max:this.abi.production;
  if(_0x436892.abi.version>_0x48bba8){
    if(dryRun)return![];
    _0x38fe20.interrupt({'unsupportedABI':_0x436892.abi.version,'digest':_0x436892,'nodes':_0x5f3e4f});
  }
}
const _0x58643a=_0x436892?_0x436892.abi.version:this.abi.max;
let _0x2954b1=loadRouter(_0x58643a),_0x14d924=loadBundle(_0x58643a);
_0x1171a2.setDefinition(_0x14d924.spec.contract.hyperdb);
for(let _0x3e75f1=_0x49e8fa;_0x3e75f1<_0x5f3e4f.length;_0x3e75f1++){
  const _0x586975=_0x5f3e4f[_0x3e75f1],_0x3a94eb=c.decode(c.uint,_0x586975.value);
  if(_0x3a94eb<0x2)continue;
  const _0x3c24ea=createContext(_0x1171a2,_0x49cbaf,_0x586975,_0x38fe20,_0x1dd2de,_0x2954b1,{'dryRun':dryRun,'trace':_0x35e833,'abi':this.abi});
  await _0x2954b1.dispatch(_0x586975.value,_0x3c24ea);
  const _0x2e7962=decodeOperation(_0x586975.value);
  _0x2e7962&&_0x2e7962.name==="@keet/upgrade"&&(_0x2954b1=loadRouter(_0x2e7962.value.version),_0x14d924=loadBundle(_0x2e7962.value.version),_0x1171a2.setDefinition(_0x14d924.spec.contract.hyperdb));
}
}catch(_0x4a888d){
!KeetContractError.isContractError(_0x4a888d)?_0x1536ec=_0x4a888d:(_0x30b238=!![],this.onerror(_0x4a888d));
}
const _0x2d3439=!_0x1536ec&&!_0x30b238&&_0x1171a2.updated();
!dryRun&&!_0x1536ec&&!_0x30b238?await Promise.all([_0x49cbaf.flush(),_0x1171a2.flush()]):await Promise.all([_0x49cbaf.close(),_0x1171a2.close()]);
if(_0x1536ec)throw _0x1536ec;
return _0x2d3439;
}
async._autobaseTrace({type:_0x184aaa,value:_0x83d7d6}){
  _0x4f87ad={
    _0x48b1ac:0x9a,_0x1973a5:0xb5,_0x3346ab:0x73},_0x68e9ed={
    _0x271272:0xa4,_0x19aeed:0x4ec}
  ;
  if(_0x184aaa!=="@keet/add-device")return;
  const {
    request:_0x170ad4,response:_0x4df795,invitation:_0x2b1f92}
  =_0x83d7d6,_0x48e6bc=_0x2b1f92?..metadata.expiration;
  if(_0x48e6bc>-0x45c4&&_0x48e6bc<Date.now())return;
  const _0x245ecf=_0x170ad4.member.profile.mailbox,_0x5364af=_0x170ad4.keyPair;
  if(!_0x245ecf||!_0x5364af)return;
  const _0x272772=await this.local.get("@local/identity"),_0x419869=await this.local.get("@local/rooms",{'roomKey':_0x272772.privateProfileKey});
  if(b4a.equals(_0x245ecf,_0x419869.capabilities.mailboxKeyPair.publicKey))return;
  const _0xe6545=this.tasks.joinRoomResponse(_0x5364af.publicKey,{'mailbox':_0x245ecf,'keyPair':_0x5364af,'response':_0x4df795});
  _0xe6545.runBackground();
}
async._backgroundDrain(_0xb4e3d2){
  _0x43fd3c={
    _0x574686:0xf9,_0x3bfb1b:0x14,_0x2ec930:0xef},_0x117315={
    _0x162ebf:0xe9,_0x71e578:0x210}
  ;
  let _0x6cfeac=await _0xb4e3d2.next();
  while(!_0x6cfeac.done&&!this.closing){
    const _0x42b886=await _0x6cfeac.value;
    if(this.closing)return;
    _0x6cfeac=await _0xb4e3d2.next(_0x42b886);
  }
}
async._safeLoadLegacyUnreads(){
  _0x1bdeb6={
    _0xc8f137:0xad,_0x1c5909:0xdb,_0x34a61f:0x154},_0x400f8f={
    _0x44074e:0x17c,_0x3be9fb:0x1e9,_0x472261:0x97}
  ;
  try{
    const _0x2a6fe9=[];
    for await(const _0x263955 of this.local.find("@local/rooms")){
      const _0x2679e5=await this.local.get("@local/unreads",{'roomKey':_0x263955.roomKey});
      if(!_0x2679e5)continue;
      _0x2a6fe9.push(_0x2679e5);
    }
  return _0x2a6fe9;
}catch{
return[];
}
}
async*._migrateUnreadAnchors(){
  _0x27259e={
    _0x4a0d7c:0xe5,_0x5b9ff3:0xf,_0x3f386a:0x25d},_0xd9e651={
    _0x13f7ab:0x17a},_0x2658a2=yield this._safeLoadLegacyUnreads();
  const _0x582b45=yield this.internalEnterLocalTransaction();
  try{
    const _0x33293e=this.unreads.write(),_0xbdfa09=Date.now();
    for(const {roomKey:_0x2b3f92,count:_0x5e4b2a}of _0x2658a2){
      _0x33293e.tryPut(_0x2b3f92,{'length':_0x5e4b2a+(0x1),'timestamp':_0xbdfa09}),yield _0x582b45.delete("@local/unreads",{'roomKey':_0x2b3f92});
    }
  yield _0x33293e.flush(),yield _0x582b45.flush();
}finally{
yield this.internalExitLocalTransaction();
}
}
async*._internalRefreshUnreads(){
  _0x4ec5da={
    _0x41eee2:0xe9,_0x39e442:0x288},_0x36e142={
    _0x133c9f:0x4f,_0x3889e7:0x10b,_0x27d2ba:0x376}
  ;
  if(!this.privateProfile)return;
  let _0x5c563c=yield this.privateProfile.db.get("@keet/system-digest");
  if(!_0x5c563c)return;
  yield this.privateProfile.internalEnsureUpgraded();
  _0x5c563c=yield this.privateProfile.db.get("@keet/system-digest");
  if(!KeetVersions.isFeatureSupported(_0x5c563c.abi.version,KeetVersions.FEATURES.UNREADS))return;
  if(!(yield this._unreadsLock.lock()))return;
  try{
    const _0x2785b4=[];
    let _0x23474e=!![];
    const _0x353377=yield this.privateProfile.db.find("@keet-private-id/unreads").toArray();
    for(const {deviceKey:_0x2a4649,key:_0x368b28}of _0x353377){
      b4a.equals(_0x2a4649,this.privateProfile.base.local.key)&&(_0x23474e=![]),_0x2785b4.push(_0x368b28);
    }
  if(this.unreads&&sameKeys(_0x2785b4,this.unreads.keys))return;
  this.unreads&&(yield this.unreads.close(),this.unreads=null);
  const _0x2905bc=this.privateProfile,_0x5a4bfc=_0x2905bc.base.encryptionKey,_0x5721ef=this.store.namespace(_0x2905bc.key),_0x55423a=_0x5721ef.namespace(KEET_UNREAD_ANCHORS_NAMESPACE);
  yield _0x5721ef.close();
  const _0x4e68f0=yield _0x2905bc.base.wakeupCapability&&_0x2905bc.base.wakeupCapability.key;
  this.unreads=new KeetUnreadAnchors(_0x55423a,_0x2785b4,{'blindPeering':this.blindPeering,'encryptionKey':_0x5a4bfc,'target':_0x4e68f0}),this.unreads.on("remote-update",()=>this.emit("unread-anchors-changed")),yield this.unreads.ready(),_0x23474e&&(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(){
  _0x302740={
    _0x411571:0x141,_0x4259ae:0xef,_0x236f10:0x8e},_0x10a0eb={
    _0x2b4afa:0x12d,_0x332dee:0x5c5}
  ;
  if(this._disableUnreadSync)return Promise.resolve();
  return this._backgroundDrain(this._internalRefreshUnreads());
}
async.internalLoadDiscoveryCore(){
  _0x3798c1={
    _0x52b617:0x1c0,_0x3da5a5:0x20},_0x54562d={
    _0x728e9e:0x36,_0x415f95:0x13d,_0x14280a:0xff}
  ;
  try{
    const _0x420bbd=await this.privateProfile.db.get("@keet-private-id/identity");
    if(!_0x420bbd||!_0x420bbd.discoveryCoreKey||this.closing)return;
    if(this.discoveryCore)return;
    this.discoveryCore=this.store.get({'key':_0x420bbd.discoveryCoreKey}),await this.discoveryCore.ready(),this.blindPeering.addCoreBackground(this.discoveryCore,this.discoveryCore.key,{'pick':0x3});
  }catch(_0xa568b4){
  this.onerror(_0xa568b4);
}
}
async.internalCreateDiscoveryCore(_0x36a401){
  _0x2b976a={
    _0x35109d:0x413},_0x6d42c7={
    _0x23c8a2:0x88,_0x54fda6:0x64}
  ;
  const _0x5e3b93=_0x36a401.getProfileDiscoveryEncryptionKey();
  const _0x178c9a={
    'version':0x2,'signers':[{'publicKey':_0x36a401.profileDiscoveryKeyPair.publicKey}]}
  ;
  return this.discoveryCore&&await this.discoveryCore.close(),this.discoveryCore=this.store.get({'keyPair':_0x36a401.profileDiscoveryKeyPair,'valueEncoding':ProfileDiscoveryRecord,'encryptionKey':_0x5e3b93,'manifest':_0x178c9a}),await this.discoveryCore.ready(),this.blindPeering.addCoreBackground(this.discoveryCore,this.discoveryCore.key,{'pick':0x3}),this.discoveryCoreSession=this.swarm.join(this.discoveryCore.discoveryKey,{'server':![],'client':!![]}),!![];
}
async.internalDryRun(_0x2c0528,_0x242ecc,_0x244883){
  _0xb2b497={
    _0x3a48f7:0x3cf},_0x33fbee={
    _0x2a104f:0x6c9,_0x31a521:0x6ac,_0x1bf525:0x7a6,_0x1496a5:0x67f,_0x4a55d8:0x738,_0x3f914b:0x802,_0x52ae45:0x8c1,_0xf4280f:0x7b6,_0x5a7439:0x19d,_0x5b5343:0x148,_0x3b6ce3:0x4a,_0x21d4dc:0xe0},_0x354425={
    _0xf06758:0x441,_0x2b0bf0:0x106},_0x2b5cb3={
    _0x19ec97:0x117,_0x1384df:0x1f4},_0x35d78e={
    _0x37d2a9:0x1dc,_0x56fb4a:0xa7}
  ;
  const _0x347888=_0x244883.map((_0x3d1aa7,_0x1c7e69)=>{return{'length':_0x2c0528.base.local.length+(0x1)+_0x1c7e69,'from':_0x2c0528.base.local,'value':_0x3d1aa7,'heads':[]};}),_0x1665dd=await this._autobaseApply(_0x347888,_0x242ecc,_0x2c0528.base,{'dryRun':!![]});
  return!!_0x1665dd;
}
.internalGetHeads(_0x4b39a6,_0x4eb283){
  _0x375f3b={
    _0x329197:0x86,_0x3ac506:0xb}
  ;
  const _0x3d6c93=[];
  let _0x213b97=![];
  if(_0x4eb283)for(const _0xc3b980 of _0x4eb283.base.heads()){
    _0x4b39a6&&b4a.equals(_0xc3b980.key,_0x4b39a6.key)?(_0x213b97=!![],_0x3d6c93.push({'key':_0xc3b980.key,'length':Math.max(_0xc3b980.length,_0x4b39a6.length)})):_0x3d6c93.push(_0xc3b980);
  }
return _0x4b39a6&&!_0x213b97&&_0x3d6c93.push(_0x4b39a6),_0x3d6c93;
}
async.internalGetKeyPair(_0x458e61){
  _0x22fd3d={
    _0x4db1fd:0xb6},_0x2421b2={
    _0x12f557:0x5e,_0x499eec:0x4c7}
  ;
  const _0x13a5e5=await this.local.get("@local/writers-by-room-key",{'roomKey':_0x458e61});
  if(!_0x13a5e5)return null;
  return _0x13a5e5.keyPair;
}
async.internalGetMailbox(_0x35ece0){
  _0x5f22bd={
    _0x493125:0x14d,_0x47782f:0xb,_0x3da2f0:0x2dd},_0x153775={
    _0x190cb5:0x15e,_0x5ab717:0x1c6,_0x4634e3:0x24e},_0x177a31=await this.local.get("@local/rooms",{'roomKey':_0x35ece0});
  if(!_0x177a31)return null;
  const _0x1332d7=_0x177a31.capabilities.mailboxKeyPair.publicKey,_0x10b4bc=_0x177a31.capabilities.wakeupTopic;
  return{
    'key':_0x1332d7,'discoveryKey':_0x10b4bc}
  ;
}
async.internalGetEncryptionKey(_0x24fb9a){
  _0x4d6af6={
    _0x35293f:0x2,_0x1cf572:0x17d,_0x2bfed2:0xd8},_0x2104d1={
    _0x30a419:0x18,_0x3c4ed9:0xf5}
  ;
  const _0x565d24=await this.local.get("@local/rooms",{'roomKey':_0x24fb9a});
  if(!_0x565d24||_0x565d24.status.isRemoved)return null;
  return _0x565d24.encryptionKey;
}
.internalReleaseRoom(_0xe5d5ae){
  _0x1071f1={
    _0x41f49c:0x67,_0xdf722a:0x159},_0x3a9a7c={
    _0x1e4973:0x1b,_0x3b2bde:0xc7,_0x4aba21:0x424}
  ;
  if(_0xe5d5ae.refs===0x0)throw new Error("Cannot release\x20a\x20room that was not previously opened");
  _0xe5d5ae.refs-=-0x1493;
}
.internalOpenExistingRoom(_0x3e158b,_0x4f5c5e={}){
  _0x2a6d1d={
    _0x126c26:0x33,_0x3cf90d:0x11b}
  ;
  return this.internalOpenRoom(HypercoreId.decode(_0x3e158b),null,_0x4f5c5e);
}
async.internalEnsureUnreads(){
  _0x3116d9={
    _0x50ff05:0x125,_0x2cacbe:0x23a},_0x6dea55={
    _0x2d0498:0x87,_0x59dbee:0x4b,_0x297be2:0x48e}
  ;
  if(this.unreads)return this.unreads;
  await this.ready(),await this.unreadsLoading,this.unreadsLoading=null;
  return this.unreads;
}
async.internalOpenPrivateProfile(){
  _0x5c3fb6={
    _0xe2edd9:0x170,_0x399678:0xf3},_0x1f5ffb={
    _0x2c8293:0x99,_0x229201:0x1,_0x561a56:0x485},_0x413f21=await this.local.get("@local/identity"),_0x25230d=this.internalOpenExistingRoom(_0x413f21.privateProfileKey,{'bigBatches':!![]});
  await _0x25230d.ready();
  if(!this.privateProfile||!b4a.equals(_0x25230d.key,this.privateProfile.key)){
    if(this.privateProfile)this.internalReleaseRoom(this.privateProfile);
    this.privateProfile=this.internalOpenExistingRoom(_0x413f21.privateProfileKey,{'bigBatches':!![]}),this.unreadsLoading=this.internalRefreshUnreads().catch(()=>null);
  }
return this.internalLoadDiscoveryCore(),_0x25230d;
}
async.internalSafeSwapPrivateProfiles(){
  _0x3c6319={
    _0x5ccc00:0x1e,_0x2a8187:0x20d},_0x3a790c={
    _0x3bb688:0x3f,_0xc9e2a7:0x97}
  ;
  try{
    const _0x272907=await this.internalOpenPrivateProfile();
    this.internalReleaseRoom(_0x272907);
  }catch(_0x3aa675){
  this.onerror(_0x3aa675);
}
}
.internalOpenRoom(_0x20ec0a,_0x19962c,{fastForwardTo:_0x530954,mailbox:_0x466e03,keyPair:_0x415b87,bigBatches:_0x34da5a}={}){
  _0x20bed2={
    _0x4c09a7:0x63e,_0x565092:0x4c5,_0x56beb8:0x7ce,_0x2ff7b0:0x669,_0x4ad27d:0x84b,_0x565070:0x75d,_0x267fbe:0x9b2,_0x484bb1:0x687,_0x26deda:0x54a,_0x3dca77:0x6d3,_0x1e1935:0x760,_0x4d46af:0x5fc,_0x389c93:0x879,_0x82a853:0x6f6,_0x2133e8:0x7b8,_0x240dee:0x56f},_0xe02855={
    _0x303f74:0x251,_0x524503:0x319,_0xed1de7:0x46d,_0x624ca6:0x56d,_0x149864:0x7c7,_0x497da8:0x7b3,_0x2a7b4a:0x4a4,_0x3f257f:0x4c0,_0x2d2ce1:0x604,_0x114cdb:0x506,_0x4a8916:0x3a3,_0x237712:0x4be,_0xae458b:0x547,_0x42c447:0x544,_0x26d9a9:0x47e,_0x148654:0x441,_0xfa8d2a:0x2d4,_0x1c508a:0x30d,_0x5cc5c4:0x41c},_0xf5b89f={
    _0x10f938:0x1c1,_0xbe624f:0x385},_0x4342b4={
    _0x348d63:0x43,_0x430910:0x14b,_0xbcbc5b:0x106,_0xaebcfd:0x10d,_0x4eb507:0x15d,_0x26a9f5:0x14d,_0x5b667c:0x15b,_0x471bb0:0x105,_0x3ff0c2:0x1d7,_0x448c94:0xe3,_0x4bd691:0x1db,_0x34207f:0x114,_0x534d45:0x2b,_0x4d6988:0x70,_0x2a6bc2:0x5a,_0x1ed503:0x6b,_0x5cf4d2:0x13c,_0x215096:0x1f4,_0x45218a:0x18,_0x674d57:0x16a,_0x2be445:0x3,_0x120be7:0x28b,_0x1e0103:0x19},_0x4fbb86={
    _0x5760fb:0xe5,_0x134f15:0x5},_0x56f75b={
    _0x2b54e8:0x1d4,_0x36cee1:0x19c,_0x4ead0f:0x289},_0x81143b={
    _0x7a35fc:0x59e}
  ;
  if(this.closing)throw new Error("Keet is closing");
  const _0x1e92ca=HypercoreId.encode(_0x20ec0a),_0x507363=this.rooms.get(_0x1e92ca);
  if(_0x507363)return _0x507363.idleTicks=0x0,_0x507363.refs+=--0x2d73,_0x507363;
  const _0x328c8c=crypto.discoveryKey(_0x20ec0a),_0x5a3bf8=this.store.namespace(_0x328c8c);
  let _0x524c72=null,_0x5a3db7=null,_0x413fd9=null;
  !_0x466e03&&(_0x5a3db7=this.internalGetMailbox(_0x20ec0a),_0x5a3db7.catch(this.onerror));
  !_0x415b87&&(_0x524c72=this.internalGetKeyPair(_0x20ec0a),_0x524c72.catch(this.onerror));
  !_0x19962c&&(_0x413fd9=this.internalGetEncryptionKey(_0x20ec0a),_0x413fd9.catch(this.onerror));
  _0x466e03&&(_0x466e03={'key':_0x466e03,'discoveryKey':crypto.discoveryKey(_0x466e03)});
  const _0x2c9deb=new Autobase(_0x5a3bf8,_0x20ec0a,{'backoff':this.backoff,'update':this._autobaseUpdate.bind(this),'apply':this._autobaseApply.bind(this),'close':this._autobaseClose.bind(this),'open':this._autobaseOpen.bind(this),'encryptionKey':_0x19962c||_0x413fd9,'wakeupCapability':_0x466e03||_0x5a3db7,'keyPair':_0x415b87||_0x524c72,'fastForward':this.debug.disableFastForward?![]:_0x530954,'ackThreshold':this.ackThreshold,'ackInterval':this.ackInterval,'wakeup':this.protomuxWakeup,'optimistic':!![],'encrypted':!![],'bigBatches':!!_0x34da5a});
  _0x2c9deb.on("interrupt",_0x48e874=>{this.internalProductionLog("room=",_0x2c9deb.id,"got interrupted"),this.emit("room-interrupted",_0x1e92ca,_0x48e874);}),_0x2c9deb.on('warning',_0x4e2bd5=>{console.warn("[autobase warning] room=",_0x2c9deb.id,"error=",_0x4e2bd5);this.onerror(_0x4e2bd5,{'roomKey':_0x20ec0a,'prefix':"AUTOBASE_WARNING"});}),_0x2c9deb.on("error",_0x38ae40=>{console.warn("[autobase\x20error] room=",_0x2c9deb.id,"error=",_0x38ae40);this.onerror(_0x38ae40,{'roomKey':_0x20ec0a,'prefix':"AUTOBASE_ERROR"});});
  const _0x421988=new Room(this,_0x1e92ca,_0x20ec0a,_0x328c8c,_0x2c9deb);
  return this.rooms.set(_0x1e92ca,_0x421988),_0x421988.refs+=0x1,_0x421988;
}
async.updateDevice({name:_0x252e84}={}){
  _0x3ba6ec={
    _0x577857:0x108,_0x941916:0x1a5,_0x4381af:0x517},_0x76787c={
    _0x9a136b:0x1d1,_0x39a4fc:0x1c9,_0x3c2dee:0x10}
  ;
  if(!this.opened)await this.ready();
  const _0x12c93f={
    'swarmKey':this.swarm.keyPair.publicKey,'name':_0x252e84,'isMobile':this.isMobile},_0x40529e=await this.internalOpenPrivateProfile();
  try{
    await _0x40529e.dispatch("@keet/update-device",{'profile':_0x12c93f});
  }finally{
  this.internalReleaseRoom(_0x40529e);
}
}
async.internalUpdateProfile(_0x14c715,{forceUpdateRegistry:forceUpdateRegistry=![]}={}){
  _0x3eef66={
    _0x29ee4d:0x7,_0x2ec4b4:0x41b},_0x3957fe={
    _0x2b3981:0x1ac,_0x301b3c:0x76},_0x56f0dc=await this.internalGetIdentityInfo();
  if(this.closing)return;
  if(this._rejectAnonymousProfiles&&!_0x14c715.displayName&&!forceUpdateRegistry)throw new Error("A member must\x20have\x20a profile name");
  const _0x1945cf=this.internalCreateMemberUpdate(_0x56f0dc,{'profile':_0x14c715}),_0x463911=await this.internalOpenPrivateProfile();
  let _0x38db72=null;
  try{
    _0x38db72=await _0x463911.dispatch("@keet/update-member",{'member':_0x1945cf});
  }finally{
  this.internalReleaseRoom(_0x463911);
}
if(!_0x38db72&&!forceUpdateRegistry)return;
if(_0x1945cf.profile.username)this.userRegistry?..internalUpdateRegistryMember(_0x1945cf);
}
async.updateProfile(_0x3a0b0d={}){
  _0x508680={
    _0x141e1a:0x1de,_0x187779:0x1d0},_0x302046={
    _0x5747a6:0xda,_0x22a817:0x1af,_0x383dc8:0x1a1}
  ;
  if(!this.opened)await this.ready();
  return this.internalUpdateProfile(_0x3a0b0d);
}
async.internalVerifyOptimisticCore(_0x4f5ac2){
  _0x3eab82={
    _0x4b8a92:0x196,_0x514711:0xdc,_0x16eaf1:0xaa},_0x27b0e7={
    _0x1c39a7:0x1cd,_0x55291a:0xa5,_0x5a3d6f:0x573}
  ;
  const _0x24d396=await _0x4f5ac2.getUserData("referrer");
  return!_0x24d396;
}
async.internalAppendOptimisticOperation(_0x19d465,_0x52bc0f){
  _0x5a3e64={
    _0x2e6c2f:0x1d7,_0x4dc4ad:0x4ad},_0x264285={
    _0x2cb00a:0x167,_0x55fb0e:0x55d},_0x438f98=this.store.get({'key':_0x19d465,'exclusive':!![]});
  await _0x438f98.ready();
  const _0x66168b=await this.internalVerifyOptimisticCore(_0x438f98);
  if(!_0x66168b){
    await _0x438f98.close();
    return;
  }
await _0x438f98.append(_0x52bc0f);
await _0x438f98.close();
}
async.internalCreateRoom(_0x46b1a1={}){
  _0xbd417a={
    _0x4f2401:0x67,_0x54473f:0x1b0,_0x10828b:0xe4},_0x11255f={
    _0x8b265e:0x104,_0x392ce4:0x162,_0x1fa726:0x19f},_0x27d9b7=_0x46b1a1.seed||crypto.randomBytes(0x20),_0x3bd78d=_0x46b1a1.keyPair||crypto.keyPair(),_0x59d264=_0x46b1a1.encryptionKey||crypto.randomBytes(--0x2466),_0x36126f=getWriterKey(_0x3bd78d.publicKey);
  const _0x32952d=crypto.discoveryKey(_0x36126f),_0x1d8a44=generateRoomCapabilities(_0x36126f,_0x27d9b7),_0x256a70=_0x1d8a44.mailboxKeyPair.publicKey,_0x4316e6=await this.internalEnterLocalTransaction();
  try{
    await _0x4316e6.insert("@local/writers",{'mailbox':_0x256a70,'keyPair':_0x3bd78d,'key':_0x36126f,'roomKey':_0x36126f}),await _0x4316e6.flush();
  }finally{
  await this.internalExitLocalTransaction();
}
const _0xb49741={
  'timestamp':Date.now()},_0x5bbb1c={
  'abi':{
    'version':this.isExperimental?this.abi.max:this.abi.autoupgrade},'creationTime':Date.now(),'settings':{
    'roomType':0x1,..._0x46b1a1.settings,'isExperimental':this.isExperimental}
},_0x1caaba={
'header':_0xb49741,'digest':_0x5bbb1c,'capabilities':{
  'seed':_0x27d9b7},'config':_0x46b1a1.config,'identity':_0x46b1a1.identity,'initialMembers':_0x46b1a1.initialMembers,'bootstrapDevice':_0x46b1a1.bootstrapDevice},_0x5d4069=this.tasks.createRoom(_0x32952d,{'roomKey':_0x36126f,'encryptionKey':_0x59d264,'mailbox':_0x256a70,'keyPair':_0x3bd78d,'genesis':_0x1caaba,'isPrivateProfile':!!_0x46b1a1.isPrivateProfile});
return await _0x5d4069.run(),this.discovery&&this.discovery.subscribe(_0x1d8a44.discoveryKeyPair.publicKey,{'since':Date.now()}),this.swarmWorker.refresh().catch(noop),this.internalOpenExistingRoom(_0x36126f);
}
async.createRoom(_0x3728f2){
  _0x4be9c2={
    _0x3d1f57:0x1d0,_0x45aa55:0x3fb},_0x459bc4={
    _0x550bfe:0x31,_0x328f70:0xd0,_0x2d66ee:0x5e8}
  ;
  if(!this.opened)await this.ready();
  const _0x4a7c84=await this.internalCreateRoom(_0x3728f2);
  return this.internalReleaseRoom(_0x4a7c84),_0x4a7c84.key;
}
async.leaveRoom(_0x3a98b6){
  _0x1aca45={
    _0x34960a:0x12e,_0x5b287e:0x1ee},_0x4a09b6={
    _0x562cbe:0x44}
  ;
  const _0x5025c0=await this.local.get("@local/identity"),_0x19d2e0=this.internalOpenExistingRoom(_0x3a98b6);
  await _0x19d2e0.ready();
  try{
    await _0x19d2e0.dispatch("@keet/remove-member",{'key':_0x5025c0.publicKey});
  }catch(_0x3711c3){
  this.onerror(_0x3711c3);
}finally{
this.internalReleaseRoom(_0x19d2e0);
}
await this.privateProfile.dispatch("@keet-private-id/update-room-status",{'roomKey':_0x3a98b6,'key':RoomStatus.IsActive,'status':{'isActive':![]}});
}
async.activateRoom(_0x1fec48){
  _0x2c505a={
    _0x3e4c17:0x1e6,_0x1f8c3f:0x10b,_0x108a3a:0x470},_0x30778a={
    _0x3e418c:0x95,_0x4ea420:0x2d1},_0x1a0de8=await this.local.get("@local/rooms",{'roomKey':_0x1fec48});
  if(!_0x1a0de8)return;
  const _0x1240a7=this.internalOpenExistingRoom(_0x1fec48);
  await _0x1240a7.ready();
  if(this.activeRooms.has(_0x1240a7)){
    this.internalReleaseRoom(_0x1240a7);
    return;
  }
this.activeRooms.add(_0x1240a7),this.swarmWorker.startActiveSwarming(_0x1a0de8.capabilities.swarmTopic);
}
async.deactivateRoom(_0x18faa4){
  _0x1b02bd={
    _0x4d64eb:0x1c7,_0x462ff7:0xc5,_0x2f1ada:0x135},_0x2363d4={
    _0x25a86f:0xab,_0x58f659:0xeb},_0x2e0f53=this.internalOpenExistingRoom(_0x18faa4);
  if(!this.activeRooms.has(_0x2e0f53)){
    this.internalReleaseRoom(_0x2e0f53);
    return;
  }
const _0x406aa9=await this.local.get("@local/rooms",{'roomKey':_0x18faa4});
this.activeRooms.delete(_0x2e0f53),this.swarmWorker.stopActiveSwarming(_0x406aa9.capabilities.swarmTopic),this.internalReleaseRoom(_0x2e0f53),this.internalReleaseRoom(_0x2e0f53);
}
async.internalGetIdentityInfo(){
  _0x3824e8={
    _0x3527ce:0x122,_0x3c3af0:0x41a},_0x1da70e={
    _0x41daf0:0x7e,_0x506750:0x1d4}
  ;
  const _0x4fae53=await this.local.get("@local/identity");
  if(!_0x4fae53)throw new Error("Identity does not exist");
  const _0x1f7118=await this.local.get("@local/rooms",{'roomKey':_0x4fae53.privateProfileKey});
  if(!_0x1f7118)throw new Error("Private profile does not exist");
  return{
    'identity':_0x4fae53,'privateProfile':_0x1f7118}
  ;
}
.internalGetMemberUpdate(_0x4db611,{profile:_0x6c8794}={}){
  _0x1f3238={
    _0x451212:0xe7,_0x934d07:0x14b,_0x3ec81c:0x4be},_0xfb523f={
    _0x15c560:0x94,_0x291676:0x1ab},_0x2fcf99=_0x4db611.privateProfile;
  if(!_0x2fcf99?..selfMember)return null;
  if(!_0x2fcf99.selfMember.proofs)return this.internalCreateMemberUpdate(_0x4db611);
  return{
    'profile':_0x2fcf99.selfMember.profile,'attestation':{
      'memberKey':_0x2fcf99.selfMember.key,'proof':_0x2fcf99.selfMember.proofs.profileAttestation}
  }
;
}
.internalCreateDeviceUpdate(_0x3cfbd9,_0x28ed8b,{isPrivateProfile:isPrivateProfile=![]}={}){
  _0x4afcdf={
    _0x2b0bc6:0xe5,_0x8a69ff:0xbb},_0x9952e6={
    _0x5b0648:0xe9,_0x560375:0x167},_0x418676=_0x3cfbd9.identity;
  let _0x543658=null;
  return _0x3cfbd9.privateProfile?..selfDevice&&isPrivateProfile&&(_0x543658=_0x3cfbd9.privateProfile.selfDevice.profile.name),{
    'profile':{
      'swarmKey':this.swarm.keyPair.publicKey,'name':_0x543658,'isMobile':this.isMobile},'attestation':{
      'memberKey':_0x418676.publicKey,'proof':IdentityKey.attestData(_0x28ed8b,_0x418676.deviceKeyPair,_0x418676.deviceProof)}
  }
;
}
.internalCreateMemberUpdate(_0x5894f4,{profile:_0x4de6d6}={}){
  _0x12533f={
    _0x39658f:0x71,_0x5efbb0:0x1,_0x42e82c:0x24},_0x4f4c62={
    _0x235a20:0x14,_0xe052ea:0x4e1},_0x396a5a=_0x5894f4.privateProfile?..selfMember?..profile||null;
  const _0x5e0b26=_0x5894f4.privateProfile?..capabilities.mailboxKeyPair.publicKey||_0x4de6d6.mailbox,_0x3fc934=_0x5894f4.identity,_0x4a46a1={
    ..._0x396a5a,..._0x4de6d6,'mailbox':_0x5e0b26,'timestamp':Date.now()},_0x1c42e9=encodeContractStruct("@keet/member-profile",_0x4a46a1);
  return{
    'profile':_0x4a46a1,'attestation':{
      'memberKey':_0x3fc934.publicKey,'proof':IdentityKey.attestData(_0x1c42e9,_0x3fc934.deviceKeyPair,_0x3fc934.deviceProof)}
  }
;
}
.internalGetLinkInfo(_0x27fb62){
  _0x4585fd={
    _0x18e24b:0xa3,_0x351662:0x1d8}
  ;
  try{
    return this.internalDecodeInvitation(_0x27fb62);
  }catch{
}
try{
  return this.internalDecodeContactInfo(_0x27fb62);
}catch{
}
return null;
}
.internalDecodeInvitation(_0x494fde){
  _0x166955={
    _0x22ba55:0x47,_0x5cb695:0x16b},_0x44514e={
    _0x43cf80:0x1a4}
  ;
  const _0x316769=typeof _0x494fde==="string"?z32.decode(_0x494fde):_0x494fde;
  return decodeContractStruct("@keet/sendable-invitation",_0x316769);
}
.internalDecodeContactInfo(_0x160e38){
  _0x15485d={
    _0x5a17ea:0x1d,_0x1b339a:0x158,_0x30cb7e:0x26a},_0x4d59c8={
    _0x3b7070:0xf4,_0xcc022c:0x5f,_0x15ba08:0x24e}
  ;
  return decodeContractStruct("@keet/member-contact-info",!b4a.isBuffer(_0x160e38)?b4a.from(_0x160e38,'base64'):_0x160e38);
}
.internalEncodeContactInfo(_0x51b7f5){
  _0x5116b2={
    _0x59ea3c:0x15c,_0x13438d:0x1b5},_0x22a0f7={
    _0x116b44:0xc9,_0x21f3c5:0x130}
  ;
  return encodeContractStruct("@keet/member-contact-info",_0x51b7f5);
}
.internalCreateContactInfoStruct(_0xc478be,_0x1d0560,_0x9a8a88={}){
  _0x3e2938={
    _0x4f92ab:0x1db,_0x52383a:0x1ee},_0xf1ab57={
    _0x3afa75:0x4c,_0x51491f:0x140,_0xd2e980:0x208}
  ;
  const _0xcede35={
    ..._0x1d0560.selfMember.profile,..._0x9a8a88},_0x1ffb2d=encodeContractStruct("@keet/member-profile",_0xcede35),_0x3eb3ee={
    'profile':_0xcede35,'attestation':{
      'memberKey':_0x1d0560.selfMember.key,'proof':IdentityKey.attestData(_0x1ffb2d,_0xc478be.deviceKeyPair,_0xc478be.deviceProof)}
  }
;
return this.internalEncodeContactInfo(_0x3eb3ee);
}
async.background(){
  _0x18dfe9={
    _0x387364:0x1b7,_0x49c8fa:0x205}
  ;
  return this.wakeup();
}
async.wakeup(){
  _0x1715a2={
    _0x289045:0x72,_0x473486:0x18d,_0x5f7baf:0x1d},_0x38b69b={
    _0x5dc483:0xab,_0xbc1930:0x121,_0x5e07c0:0x46d}
  ;
  this.state=KeetState.WAKEUP;
  if(!this.opened)await this.ready();
  const _0x2cd8ef=[this.resume(),this.swarmWorker.background()];
  await Promise.allSettled(_0x2cd8ef);
}
async.presuspend(){
  _0x5932ca={
    _0x13f032:0x50,_0x1866f6:0xf2},_0x302993={
    _0xe00fdc:0x16e,_0x2ff111:0x85}
  ;
  this.state=KeetState.PRESUSPEND;
  if(!this.opened)await this.ready();
  this.swarmWorker.setServerMode(![]);
}
async.suspend(){
  _0x27a3d2={
    _0x3cd144:0xee,_0x2b01d3:0x19},_0x3d0e53={
    _0x30285d:0xff,_0x1333cd:0x5f0}
  ;
  if(this.state===KeetState.SUSPEND)return;
  this.state=KeetState.SUSPEND;
  if(!this.opened)await this.ready();
  const _0x392c80=[this._flushDHTCache()];
  this.blindPeering&&_0x392c80.push(this.blindPeering.suspend());
  this.push&&_0x392c80.push(this.push.suspend());
  this.discovery&&_0x392c80.push(this.discovery.suspend());
  await Promise.allSettled(_0x392c80),await this.rpcClient.suspend();
  await this.swarm.suspend(),await this.files.server.suspend(),await this.store.suspend();
}
async.resume(){
  _0x42dc1d={
    _0x4e1751:0x2f2},_0x587a10={
    _0x474b43:0x16a,_0x25593a:0x1d6,_0x176967:0x105}
  ;
  if(this.state===KeetState.RESUME)return;
  this.state=KeetState.RESUME;
  if(!this.opened)await this.ready();
  await this.store.resume(),await this.files.server.resume();
  if(!this.readOnly)await this.swarm.resume();
  await this.rpcClient.resume();
  const _0x28c04f=[];
  this.blindPeering&&!this.readOnly&&_0x28c04f.push(this.blindPeering.resume());
  this.push&&_0x28c04f.push(this.push.resume());
  this.discovery&&_0x28c04f.push(this.discovery.resume());
  this.swarmWorker.setServerMode(!![]),_0x28c04f.push(this.swarmWorker.unbackground());
  await Promise.allSettled(_0x28c04f);
}
async._createInvitation(_0x5d04fe,_0x498cb7){
  _0xbdea13={
    _0x300a98:0x5c,_0x23d2ec:0xfd,_0x545786:0x35},_0x5de3c2={
    _0x2fc205:0x40,_0x235982:0x15d,_0x58fc88:0x2f7}
  ;
  let {
    expiration:expiration=0x0,canAdmin:canAdmin=![],canModerate:canModerate=![],identityPublicKey:identityPublicKey=null,requiresConfirmation:requiresConfirmation=![],readOnly:readOnly=![]}
  =_0x498cb7;
  if(typeof expiration==="string"){
    if(expiration==='2h')expiration=Date.now()+(-0x37b8)*(0xe10)*(0x3e8);
    else{
      if(expiration==='2d')expiration=Date.now()+(0x2)*(-0x69e)*(--0x2bd8)*(0x3e8);
      else{
        if(expiration==='2w')expiration=Date.now()+(-0x4290)*(0x7)*(-0x21ec)*(-0x4d0c)*(-0x1264);
        else throw KeetErrorV2.UNKNOWN_EXPIRATION("Unknown expiration:\x20"+expiration,{'roomKey':_0x5d04fe.key});
      }
  }
}
await _0x5d04fe.ready();
const [{seed:_0x5f4ad5},_0x48d1fd]=await Promise.all([_0x5d04fe.db.get("@keet/room-capabilities"),getMemberForDeviceKey(_0x5d04fe.db,_0x5d04fe.deviceKey)]);
if((canModerate||canAdmin)&&!_0x48d1fd.status.isModerator)throw KeetErrorV2.MODERATORS_ONLY("Only moderators can create moderator invitations",{'roomKey':_0x5d04fe.key});
const _0x5dbce9=generateRoomCapabilities(_0x5d04fe.key,_0x5f4ad5),_0x56dbb1=this.swarm.dht.toArray({'limit':INVITE_DHT_NODES_LIMIT});
if(readOnly)return encodeContractStruct("@keet/sendable-invitation",{'readonly':{'roomKey':_0x5d04fe.key,'encryptionKey':_0x5d04fe.encryptionKey,'fastForwardTo':_0x5d04fe.base.getSystemKey(),'seed':_0x5f4ad5},'additionalNodes':_0x56dbb1});
const _0x24cf8f={
  'key':_0x5d04fe.key,'encryptionKey':_0x5d04fe.encryptionKey,'fastForwardTo':_0x5d04fe.base.getSystemKey()}
;
const {
  invitation:_0x3cf804,seed:_0x4ce997}
=createInvitation(_0x24cf8f,{'requiresConfirmation':requiresConfirmation,'expiration':expiration,'canModerate':canModerate,'canAdmin':canAdmin});
await _0x5d04fe.dispatch("@keet/add-invitation",{'invitation':_0x3cf804});
const _0x123052=await _0x5d04fe.db.get("@keet/invitations",{'id':_0x3cf804.id}),_0x10d90c=_0x123052.anchor,_0x2cca53=_0x5dbce9.mailboxKeyPair.publicKey,_0x5095a2={
  'identity':null,'room':null,'contact':null,'additionalNodes':_0x56dbb1}
;
return identityPublicKey?_0x5095a2.identity={
  'mailbox':_0x2cca53,'invitationSeed':_0x4ce997,'anchor':_0x10d90c,'identityPublicKey':identityPublicKey}
:_0x5095a2.room={
  'mailbox':_0x2cca53,'invitationSeed':_0x4ce997,'anchor':_0x10d90c},encodeContractStruct("@keet/sendable-invitation",_0x5095a2);
}
async.createRoomInvitation(_0x2b811d,_0x5695f6={}){
  _0x387adf={
    _0x54ffd8:0x2f,_0x2e1d9d:0x3ca},_0x38ca40={
    _0x5179fa:0x1e0,_0x159228:0x122,_0x4d8dea:0x2d}
  ;
  if(!this.opened)await this.ready();
  const _0x21f41d=HypercoreId.decode(_0x2b811d),_0x4c30b6=this.internalOpenExistingRoom(_0x21f41d);
  try{
    const _0x4cc731=await this._createInvitation(_0x4c30b6,_0x5695f6);
    return z32.encode(_0x4cc731);
  }finally{
  this.internalReleaseRoom(_0x4c30b6);
}
}
async.createIdentityInvitation(){
  _0x465d2c={
    _0x298318:0x119},_0x20e12f={
    _0x8b65c4:0x182,_0x1584c1:0x61,_0xf2a925:0x3d1}
  ;
  if(!this.opened)await this.ready();
  const _0x57d89d=await this.local.get("@local/identity"),_0x4c820c=this.internalOpenExistingRoom(_0x57d89d.privateProfileKey);
  this.blindPeering.addAutobaseBackground(_0x4c820c.base,null,{'all':!![]});
  try{
    const _0x3eb9dc=await this._createInvitation(_0x4c820c,{'expiration':'2h','canAdmin':!![],'canModerate':!![],'requiresConfirmation':!![],'identityPublicKey':_0x57d89d.publicKey});
    return z32.encode(_0x3eb9dc);
  }finally{
  this.internalReleaseRoom(_0x4c820c);
}
}
async._startPairing(_0x23d2fd,{deviceKeyPair:_0x1cc119}={}){
  _0x197403={
    _0x51288c:0x60b},_0x4b104f={
    _0x407f34:0x9a},_0x1c3885=getInvitationId(_0x23d2fd.invitationSeed),_0x3bf4c2=_0x23d2fd.invitationSeed,_0x45770a=_0x23d2fd.mailbox,_0x388c54=_0x23d2fd.anchor,_0x4fcf13={
    'key':null,'seedId':HypercoreId.encode(_0x3bf4c2)}
  ;
  const _0x49b88d=await this.local.get("@local/rooms-by-mailbox",{'capabilities':{'mailboxKeyPair':{'publicKey':_0x45770a}}});
  let _0x369ba9=null;
  if(_0x49b88d){
    if(_0x49b88d.selfMember?..status.isRemoved)throw new Error("Removed member cannot rejoin");
    _0x369ba9=await this.local.get("@local/room-preferences",{'roomKey':_0x49b88d.roomKey});
  }
if(_0x369ba9&&_0x369ba9.status.isActive&&!_0x369ba9.status.isReadOnly)return _0x4fcf13.key=HypercoreId.encode(_0x49b88d.roomKey),_0x4fcf13;
const _0x54e2c1=crypto.keyPair(),_0x2bf467=await this.store.createKeyPair(generateRoomPairingName(_0x54e2c1.publicKey)),_0x3fac2d=this.store.get({'keyPair':_0x2bf467,'active':![]});
await _0x3fac2d.ready();
const _0x5c2bf2={
  'key':_0x3fac2d.key,'length':0x1}
;
await _0x3fac2d.close();
let _0x54c880=null;
if(_0x1cc119){
  const _0x269f10=_0x3fac2d.key,_0x5f14d1=_0x23d2fd.identityPublicKey,_0x4f2d1e=_0x1cc119.publicKey;
  _0x54c880={
    'writerKey':_0x269f10,'publicKey':_0x5f14d1,'devicePublicKey':_0x4f2d1e}
  ;
}
const _0x203752={
  'id':_0x1c3885,'mailbox':_0x45770a,'inviter':_0x388c54,'identity':_0x54c880,'initiator':_0x5c2bf2,'responseKeyPair':_0x54e2c1,'invitationSeed':_0x3bf4c2},_0x100732=await this.privateProfile.db.find("@keet-private-id/pending-invitations").toArray();
for(const _0x177c11 of _0x100732){
  if(!b4a.equals(_0x177c11.mailbox,_0x203752.mailbox))continue;
  await this.privateProfile.dispatch("@keet-private-id/remove-pending-invitation",_0x177c11);
}
return await this.privateProfile.dispatch("@keet-private-id/add-pending-invitation",{'invitation':_0x203752}),_0x4fcf13;
}
async._openReadOnlyRoom({roomKey:_0x4dee74,encryptionKey:_0x1444fe,seed:_0x520f58,fastForwardTo:_0x166065}){
  _0x482522={
    _0x26611a:0x1a4,_0xb0c2c:0x1c2,_0x593670:0x1f7},_0x3089ae={
    _0xb309ea:0x15d,_0x13f6d2:0xec,_0x4c1508:0x15b},{
    mailboxKeyPair:_0x82c19b,swarmTopic:_0x16ce47}
  =generateRoomCapabilities(_0x4dee74,_0x520f58);
  const _0x58def7=this.internalOpenRoom(_0x4dee74,_0x1444fe,{'mailbox':_0x82c19b.publicKey,'fastForwardTo':{'key':_0x166065}});
  return await _0x58def7.ready(),await this.privateProfile.dispatch("@keet-private-id/add-room",{'roomKey':_0x4dee74,'encryptionKey':_0x1444fe,'mailbox':_0x82c19b.publicKey,'fastForwardTo':_0x166065,'isReadOnly':!![]}),this.swarmWorker.startDiscoverySwarming(_0x16ce47,{'roomId':HypercoreId.encode(_0x4dee74)}),{
    'key':HypercoreId.encode(_0x4dee74),'seedId':HypercoreId.encode(_0x520f58)}
  ;
}
async.startPairingRoom(_0x37d5d7,_0x524746){
  _0x58dbf1={
    _0x567e02:0x19c,_0x14f2fc:0x1c4,_0x2388ea:0x443},_0x43617a={
    _0x1c9439:0x58,_0x50696c:0x8d,_0x1a9be2:0xe3}
  ;
  if(!this.opened)await this.ready();
  const _0x52e4fd=this.internalDecodeInvitation(_0x37d5d7);
  if(_0x52e4fd.readonly)return this._openReadOnlyRoom(_0x52e4fd.readonly);
  if(!_0x52e4fd.room)throw KeetErrorV2.INVALID_INVITATION_TYPE("Invalid room\x20invitation");
  return this._startPairing(_0x52e4fd.room,_0x524746);
}
async.startPairingIdentity(_0x2fece2){
  _0x4d68f6={
    _0x565b2a:0xde,_0x3a1270:0x104,_0x5da745:0xb1},_0x59aa24={
    _0x3538d9:0xc3,_0x160bc3:0x10c,_0xa1cf67:0x39f}
  ;
  if(!this.opened)await this.ready();
  const _0xc75029=this.internalDecodeInvitation(_0x2fece2);
  if(!_0xc75029.identity)throw KeetErrorV2.INVALID_INVITATION_TYPE("Invalid device sync invitation");
  const _0x5ece55=generateIdentityPairingName(_0xc75029.identity.identityPublicKey),_0x1dd55c=await this.store.createKeyPair(_0x5ece55);
  return this._startPairing(_0xc75029.identity,{'deviceKeyPair':_0x1dd55c});
}
async.stopPairing(_0x465913){
  _0x528119={
    _0x353522:0xc5,_0x39f9c2:0x1ec},_0x2da5d2={
    _0xc4cc7e:0x1b5,_0x216d44:0x99,_0x3b655c:0x4f8}
  ;
  if(!this.opened)await this.ready();
  const _0x22022a=await this.internalOpenPrivateProfile();
  try{
    const _0x17b693=await _0x22022a.db.get("@keet-private-id/pending-invitations",{'id':_0x465913});
    if(!_0x17b693)return;
    await _0x22022a.dispatch("@keet-private-id/remove-pending-invitation",{'id':_0x465913});
  }finally{
  this.internalReleaseRoom(_0x22022a);
}
}
async.rotateWriter(_0x4e752a){
  _0x5614fa={
    _0x356cb7:0x199,_0x574bb5:0xe9},_0x3b0ead={
    _0x36289d:0x12,_0x5437a1:0x61},[_0xb73b5,_0xdb6c3a,_0x2b1750]=await Promise.all([this.local.get("@local/writers-by-room-key",{'roomKey':_0x4e752a}),this.local.get("@local/rooms",{'roomKey':_0x4e752a}),this.privateProfile.db.get("@keet-private-id/rooms",{'roomKey':_0x4e752a})]);
  if(!_0xdb6c3a||!_0xb73b5||!_0x2b1750)return;
  const _0x1cb0db=await this.internalEnterLocalTransaction();
  try{
    await _0x1cb0db.delete("@local/writers",_0xb73b5),await _0x1cb0db.flush();
  }finally{
  await this.internalExitLocalTransaction();
}
const _0x3656e2=this.tasks.joinRoomKeys(_0x2b1750.mailbox,{'keys':_0x2b1750});
_0x3656e2.runBackground();
}
async.getRecoveryPhrase(){
  _0x561de7={
    _0x40b548:0x186,_0x5723c2:0xd2},_0x5f49aa={
    _0x364f3f:0x17,_0x5260ca:0xb0,_0x186210:0x40}
  ;
  if(!this.opened)await this.ready();
  const _0x3d072e=await this.local.get("@local/identity"),_0x7494da=_0x3d072e.entropy;
  if(!_0x7494da)return null;
  return generateMnemonic({'entropy':_0x7494da});
}
async.storeRecoveryPhrase(_0x30a666){
  _0x33ed90={
    _0x105542:0xe6,_0x42f585:0x1d5,_0x5ae9ed:0xc1},_0x43d136={
    _0x3e93e8:0x18b,_0x40e551:0x1d4,_0x274ee3:0x29f}
  ;
  const _0x243f82=await IdentityKey.from({'mnemonic':_0x30a666}),_0x404379=await this.local.get("@local/identity"),_0x18c8e8=await this.local.get("@local/rooms",{'roomKey':_0x404379.privateProfileKey});
  if(!b4a.equals(_0x404379.publicKey,_0x243f82.identityPublicKey))throw new Error("Wrong recovery phrase");
  if(_0x18c8e8.identity.discoveryCoreKey)return;
  await this.internalCreateDiscoveryCore(_0x243f82);
  if(this.discoveryCore.length>-0x2e06){
    const _0x36b63b=Math.floor((Date.now()-IDENTITIES_RELEASE_TIMESTAMP)/(-0x21a8));
    await this.discoveryCore.truncate(this.discoveryCore.length,_0x36b63b);
  }
await this.discoveryCore.append({'version':0x1,'timestamp':Date.now(),'key':_0x18c8e8.roomKey,'mailbox':_0x18c8e8.capabilities.mailboxKeyPair.publicKey}),await this.privateProfile.dispatch("@keet-private-id/update-identity",{'identity':{'publicKey':_0x243f82.identityPublicKey,'discoveryCoreKey':this.discoveryCore.key}});
}
async.confirmRecoveryPhrase({persist:persist=![]}={}){
  _0x1d009e={
    _0x5c524f:0x25,_0x3ee474:0x60,_0x145674:0x22d},_0x1209e2={
    _0x5c8734:0x1f4,_0x2e5d09:0x1ef,_0x32fd5b:0x5e7}
  ;
  if(!this.opened)await this.ready();
  const _0x32af21=await this.local.get("@local/identity");
  if(!persist)_0x32af21.entropy=null;
  _0x32af21.status.isConfirmed=!![];
  const _0x49c6e2=await this.internalEnterLocalTransaction();
  try{
    await _0x49c6e2.insert("@local/identity",_0x32af21),await _0x49c6e2.flush();
  }finally{
  await this.internalExitLocalTransaction();
}
this.emit("identity-changed");
}
async.restoreIdentity(_0x2b18aa,{create:create=!![]}={}){
  _0x4167e6={
    _0x277a12:0xc5,_0x430893:0xa8,_0x321e36:0x3e9},_0x417d25={
    _0x36f94e:0xce,_0x10b098:0x106}
  ;
  if(!this.opened)await this.ready();
  const [_0x391ba9]=await Promise.all([this.local.get("@local/identity"),IdentityKey.from({'mnemonic':_0x2b18aa})]),_0x5d0329=crypto.discoveryKey(_0x391ba9.privateProfileKey),_0x4b8677=this.tasks.restoreIdentity(_0x5d0329,{'mnemonic':_0x2b18aa,'recover':create===![],'profileDiscoveryTimeout':this._profileDiscoveryTimeout});
  await _0x4b8677.run();
  const _0x5d5eda=await this.local.get("@local/identity"),_0x2c4618=await this.local.get("@local/rooms",{'roomKey':_0x5d5eda.privateProfileKey});
  this.privateProfile=await this.internalOpenPrivateProfile(),this.swarmWorker.startActiveSwarming(_0x2c4618.capabilities.swarmTopic);
}
async.acceptJoinRequest(_0x1bc412,_0x3add15){
  _0x44b72f={
    _0xcb4a22:0x22,_0x1f98fd:0xb4,_0x468728:0x179},_0x557cde={
    _0x11890f:0x155,_0x157f09:0x2c,_0x533d2a:0x7}
  ;
  if(!this.opened)await this.ready();
  const _0x3be419=this.internalOpenExistingRoom(_0x1bc412);
  try{
    const _0x8ee487=await _0x3be419.db.get("@keet/join-requests",{'deviceKey':_0x3add15});
    if(!_0x8ee487)return;
    const _0x4bdfc4=_0x8ee487.request;
    let _0x517607=null;
    if(_0x4bdfc4.identity){
      const _0x14e792=await this.local.get("@local/identity");
      if(!b4a.equals(_0x14e792.privateProfileKey,_0x1bc412))throw new Error("Accepting an\x20identity device join request on a room that is not\x20your\x20private profile");
      _0x517607=generateIdentityJoinResponse(_0x14e792,_0x3add15,_0x4bdfc4.identity.devicePublicKey);
    }
  await _0x3be419.dispatch("@keet/accept-join-request",{'deviceKey':_0x3add15,'identity':_0x517607});
}finally{
this.internalReleaseRoom(_0x3be419);
}
}
async.rejectJoinRequest(_0x7bab55,_0x26b391){
  _0x13f1db={
    _0x3b811d:0x59,_0x20d6f9:0x24,_0x144072:0x4cf},_0x5ef554={
    _0x549fa4:0x61,_0x55584e:0xa1,_0x477e08:0x328}
  ;
  if(!this.opened)await this.ready();
  const _0x294269=this.internalOpenExistingRoom(_0x7bab55);
  try{
    const _0xd8b32e=await _0x294269.db.get("@keet/join-requests",{'deviceKey':_0x26b391});
    if(!_0xd8b32e)throw new Error("Join request for that device key does not\x20exist");
    await _0x294269.dispatch("@keet/reject-join-request",{'deviceKey':_0x26b391});
  }finally{
  this.internalReleaseRoom(_0x294269);
}
}
async._sendContactRequest(_0x56bc30){
  _0x1f31e3={
    _0x3c3246:0x128,_0x513c8c:0x183,_0x2e0f64:0x5a6},_0x56c9fe={
    _0xed9442:0x15,_0x1fbc84:0x54a}
  ;
  const _0x294e33=await this.internalOpenPrivateProfile();
  try{
    const _0x4bbb89=this.tasks.sendContactRequest(_0x56bc30.memberKey,_0x56bc30);
    _0x4bbb89.runBackground();
  }finally{
  this.internalReleaseRoom(_0x294e33);
}
}
async.sendContactRequestFromContact(_0x5b74e9,{message:_0x2ef95e}){
  _0x60c850={
    _0x5532e5:0x4e,_0x9fe594:0x28,_0x4b91b0:0x263}
  ;
  _0x5b74e9=this.internalDecodeContactInfo(_0x5b74e9);
  const _0x3e3a6f=_0x5b74e9.attestation.memberKey;
  const _0x20bd18=_0x5b74e9.attestation.memberKey;
  return this._sendContactRequest({'roomKey':_0x3e3a6f,'memberKey':_0x20bd18,'message':_0x2ef95e,'contactInfo':_0x5b74e9});
}
async.sendContactRequest(_0x431ac5,_0xb90635,{message:_0xc326ee}){
  _0x47956d={
    _0x82b684:0x106,_0x45704e:0x2},_0x2d19bb={
    _0x1e5ed4:0x178,_0x55a985:0x1a6,_0x4c441:0x33c}
  ;
  return this._sendContactRequest({'roomKey':_0x431ac5,'memberKey':_0xb90635,'message':_0xc326ee});
}
async.blockContact(_0x40bac3){
  _0x24cdce={
    _0x3d3c63:0xf0,_0x39c6c0:0x1e0,_0x39ed09:0x101},_0x369993={
    _0x52fb25:0x47,_0x26c4cf:0x1a0,_0x5659d0:0x56}
  ;
  const [_0x4a9c0d,_0x5b62f6,_0x15ae0a]=await Promise.all([this.privateProfile.db.findOne("@keet-private-id/contact-requests-by-member",{'gte':{'memberKey':_0x40bac3},'lte':{'memberKey':_0x40bac3}}),this.local.get("@local/contacts",{'memberKey':_0x40bac3}),this.local.get("@local/members",{'key':_0x40bac3})]);
  const _0x47d5a5=_0x5b62f6?..mailbox||_0x15ae0a?..profile.mailbox||_0x4a9c0d?..sender?..mailbox;
  if(!_0x47d5a5)throw new Error("Cannot find contact");
  await this.privateProfile.dispatch("@keet-private-id/add-contact",{'contact':{'memberKey':_0x40bac3,'mailbox':_0x47d5a5,'status':{'isBlocked':!![]}}});
}
async.unblockContact(_0xd28cc4){
  _0x5be525={
    _0xe93305:0x16,_0x422943:0xf4,_0x2e1009:0x214},_0x4f7542={
    _0x5ffacb:0x119,_0x4ef4b6:0x5,_0x49e68d:0x109},[_0x3ae3f9,_0x32ff59,_0x3fdc10]=await Promise.all([this.privateProfile.db.findOne("@keet-private-id/contact-requests-by-member",{'gte':{'memberKey':_0xd28cc4},'lte':{'memberKey':_0xd28cc4}}),this.local.get("@local/contacts",{'memberKey':_0xd28cc4}),this.local.get("@local/members",{'key':_0xd28cc4})]),_0xb15b4e=_0x32ff59?..mailbox||_0x3fdc10?..profile.mailbox||_0x3ae3f9?..sender?..mailbox;
  if(!_0xb15b4e)throw new Error("Cannot find contact");
  await this.privateProfile.dispatch("@keet-private-id/add-contact",{'contact':{'memberKey':_0xd28cc4,'mailbox':_0xb15b4e,'status':{'isBlocked':![]}}});
}
async._flushDHTCache(){
  _0x34355a={
    _0x195f11:0x11e,_0x1c8595:0x81},_0x1fefb9={
    _0x529b37:0x71}
  ;
  if(this.readOnly)return;
  const _0xdc6d33=this.swarm.dht.toArray({'limit':DHT_NODES_LIMIT});
  try{
    await this._setCachedDHTNodes(_0xdc6d33);
  }catch(_0x171b0a){
  this.onerror(_0x171b0a);
}
}
async.getDHTSettings(){
  _0x18c6cd={
    _0x521cef:0xba,_0x587d9c:0x1bc,_0x107547:0x4c4},_0x2dc542={
    _0x3dfc26:0x464},_0x5d80ea=await this.local.get("@local/hyperdht")||{
  }
;
const _0x472993={
  'nodes':_0x5d80ea.nodes||[],'concurrency':_0x5d80ea.concurrency||DHT_SETTINGS.concurrency,'maxWindow':_0x5d80ea.maxWindow||DHT_SETTINGS.maxWindow,'randomPunchInterval':_0x5d80ea.randomPunchInterval||DHT_SETTINGS.randomPunchInterval,'connectionKeepAlive':_0x5d80ea.connectionKeepAlive||DHT_SETTINGS.connectionKeepAlive}
;
return _0x472993;
}
async._setCachedDHTNodes(_0x300d2e){
  _0x9fa075={
    _0x4d4cff:0x31c},_0x40827a={
    _0x426e9a:0xcb,_0x403cb4:0x40}
  ;
  const _0x574dc4=await this.internalEnterLocalTransaction();
  try{
    const _0x5807a5=await this.getDHTSettings(),_0x574310={
      ..._0x5807a5,'nodes':_0x300d2e}
    ;
    await _0x574dc4.insert("@local/hyperdht",_0x574310),await _0x574dc4.flush();
  }finally{
  await this.internalExitLocalTransaction();
}
}
.batch(_0x532a95){
  return new Batch(this,_0x532a95);
}
async.dispatch(_0x39b996,_0x4d4061,_0x46b7b7){
  _0x301522={
    _0x10b488:0x74,_0xcb7937:0x1fc},_0x229ece={
    _0x59b73e:0x8f,_0x39fa95:0xb2}
  ;
  if(!this.opened)await this.ready();
  const _0x37e143=this.internalOpenExistingRoom(_0x39b996);
  try{
    return await _0x37e143.dispatch(_0x4d4061,_0x46b7b7);
  }catch(_0x3384bc){
  this.onerror(_0x3384bc);
}finally{
this.internalReleaseRoom(_0x37e143);
}
}
async.dispatchBatch(_0xa21dac,_0x306b4c){
  _0x212e46={
    _0x136de1:0x6a,_0x19116b:0x114,_0x101357:0x17d},_0x434344={
    _0xd4cc23:0x1de,_0x21ce3e:0x48a}
  ;
  if(!this.opened)await this.ready();
  const _0x54d4c3=this.internalOpenExistingRoom(_0xa21dac);
  try{
    await _0x54d4c3.dispatchBatch(_0x306b4c);
  }finally{
  this.internalReleaseRoom(_0x54d4c3);
}
}
async.selfDestruct({confirm:_0x246169}={}){
  _0xfe1fae={
    _0x48ecf4:0x165,_0x4779e0:0x76},_0xe2b1db={
    _0x42e170:0xe0,_0x2b1be4:0x137,_0x259103:0x88}
  ;
  if(_0x246169!=="do\x20not\x20go\x20gentle into that good\x20night")throw new Error("Must confirm self destruction");
  await this.ready(),await this.close();
  const _0x165695=Math.random().toString(-0x178).slice(0x2);
  const _0x499c56=path.join(this.dir,'gc',_0x165695);
  try{
    await fs.promises.mkdir(_0x499c56,{'recursive':!![]});
  }catch{
}
for(const _0x5024a0 of['cores','db','cache',"app-references"]){
  try{
    await fs.promises.rename(path.join(this.dir,_0x5024a0),path.join(_0x499c56,_0x5024a0));
  }catch{
}
}
await fs.promises.rm(_0x499c56,{'recursive':!![]});
}
static.from(_0xbec254,_0x578b60){
  _0x3f53c0={
    _0x4767ed:0x8f0,_0x348da8:0x8a0,_0x10bd9b:0x7ab,_0x477100:0x7e3},_0x466b5e={
    _0x14faa5:0x8c,_0x5152c1:0xcd},_0x5618d9={
    _0x44f8ae:0x161,_0x11415c:0x3f,_0x34c98f:0x188},_0x261a15={
    _0x122007:0x75},_0xc52deb={
    _0x215b15:0x137,_0x2dff6e:0x183,_0x16823a:0x146},_0x2877a8=MultiProfileStore.migrate(_0xbec254);
  const _0x48a1e=_0x2877a8.active()||_0x2877a8.create({'name':"default"});
  _0x2877a8.gc({'delay':PROFILES_GC_DELAY});
  const _0x526a07=new this(_0x48a1e.storage,{..._0x578b60,'logout':async()=>{_0x2877a8.remove(_0x48a1e);await new Promise(_0x630df=>setTimeout(_0x630df,-0x2ef4));await _0x526a07.close(),_0x2877a8.gc({'delay':PROFILES_GC_DELAY});}});
  return{
    'profiles':_0x2877a8,'keet':_0x526a07}
  ;
}
static.registerRPC(_0x4a9c98,_0x5bb66a,_0x1b6745){
  return new V2KeetAPI(_0x4a9c98,_0x5bb66a,_0x1b6745);
}
}
;
const dryRunHostcalls={
  'interrupt':noop,'addWriter':noop,'removeWriter':noop,'ackWriter':noop,'preferFastForward':noop,'removeable':alwaysTrue,'createAnchor':(_0x41ff78,_0x55ca4e)=>({'key':_0x41ff78,'length':_0x55ca4e})}
;
function createContext(_0x2cb4e,_0x5c0ee6,_0x40c822,_0x51d6b7,_0x3bd531,_0x2f715a,{abi:_0x1fdb04,trace:_0x33f4fd,dryRun:dryRun=![]}={}){
  _0x28781f={
    _0x123d14:0x6a,_0x24c936:0x19a,_0x21f0ac:0x29a},_0x2c4ee2={
    _0x123d75:0x86,_0x1aa0a8:0x1cc,_0x2d3756:0x431}
  ;
  return new KeetContract.OpContext(_0x2cb4e,_0x5c0ee6,{'fork':_0x3bd531.core.fork,'writer':{'key':_0x40c822.from.key,'seq':_0x40c822.length-(0x1)},'genesis':_0x3bd531.core.length===-0x412,'bootstrap':_0x51d6b7.bootstrap,'router':_0x2f715a,'hostcalls':!dryRun?_0x51d6b7:dryRunHostcalls,'dryRun':dryRun,'abi':_0x1fdb04,'trace':_0x33f4fd});
}
function generateIdentityJoinResponse(_0x212c18,_0x38f7f2,_0x212cd3){
  _0x406b58={
    _0x2b9466:0x159,_0x77f4dd:0x1c,_0x388cef:0x73},_0x4e2852={
    _0x4a92f7:0x1e6,_0x158524:0x1d1},_0x535060=IdentityKey.attestDevice(_0x212cd3,_0x212c18.deviceKeyPair,_0x212c18.deviceProof);
  const _0x4985f8=IdentityKey.attestData(_0x38f7f2,_0x212c18.deviceKeyPair,_0x212c18.deviceProof);
  return{
    'privateProfileIdentity':{
      'memberKey':_0x212c18.publicKey,'proof':_0x4985f8},'deviceProof':_0x535060}
  ;
}
function shouldPushNotify(_0x8043c5){
  _0x3782ef={
    _0x48ecaa:0x8d,_0x40b081:0x107,_0xd6169b:0x124}
  ;
  return _0x8043c5==="@keet/add-chat-message";
}
function noop(){
}
function alwaysTrue(){
  return!![];
}
function sameKeys(_0x4e6204,_0x342e36){
  _0xad7d4={
    _0x117678:0xdb,_0x178daf:0xda},_0x1967ed={
    _0x2ac74f:0x170,_0x3f31ec:0x7b,_0x5d59dc:0x224}
  ;
  if(_0x4e6204.length!==_0x342e36.length)return![];
  for(let _0x47583a=0x0;_0x47583a<_0x4e6204.length;_0x47583a++){
    if(!b4a.equals(_0x4e6204[_0x47583a],_0x342e36[_0x47583a]))return![];
  }
return!![];
}