chat/assets/index-C8H2K9K3.js
2025-06-19 22:14:16 +02:00

3 lines
200 KiB
JavaScript

import{g as Qi,_ as v,l as k,K as rt,a as c,L as tn,b as W,D as nt,E as A,H as it,T as ke,C as I,M,d as $t,e as st,f as Hi,h as Yi,s as te,i as _t,k as rn,V as N,m as nn,n as Se,o as E,p as sn,q as _n,t as on,u as an,v as Re,I as Ke,w as cn,A as $i,x as Zi,y as Zt,z as Xi,U as gn,B as ot,S as un,F as dn,G as ln,J as Xt,N as pn,O as z,P,Q as at,R as ae,W as Ie,X as j,Y as es}from"./index-71ZZmCGz.js";let n;function er(i){n=i}let u=0,ct=null;function ce(){return(ct===null||ct.byteLength===0)&&(ct=new Uint8Array(n.memory.buffer)),ct}const ts=typeof TextEncoder>"u"?(0,module.require)("util").TextEncoder:TextEncoder;let gt=new ts("utf-8");const rs=typeof gt.encodeInto=="function"?function(i,e){return gt.encodeInto(i,e)}:function(i,e){const t=gt.encode(i);return e.set(t),{read:i.length,written:t.length}};function p(i,e,t){if(t===void 0){const a=gt.encode(i),g=e(a.length,1)>>>0;return ce().subarray(g,g+a.length).set(a),u=a.length,g}let r=i.length,s=e(r,1)>>>0;const _=ce();let o=0;for(;o<r;o++){const a=i.charCodeAt(o);if(a>127)break;_[s+o]=a}if(o!==r){o!==0&&(i=i.slice(o)),s=t(s,r,r=o+i.length*3,1)>>>0;const a=ce().subarray(s+o,s+r),g=rs(i,a);o+=g.written,s=t(s,r,o,1)>>>0}return u=o,s}let ge=null;function q(){return(ge===null||ge.buffer.detached===!0||ge.buffer.detached===void 0&&ge.buffer!==n.memory.buffer)&&(ge=new DataView(n.memory.buffer)),ge}function U(i){const e=n.__externref_table_alloc();return n.__wbindgen_export_4.set(e,i),e}function R(i,e){try{return i.apply(this,e)}catch(t){const r=U(t);n.__wbindgen_exn_store(r)}}const ns=typeof TextDecoder>"u"?(0,module.require)("util").TextDecoder:TextDecoder;let wn=new ns("utf-8",{ignoreBOM:!0,fatal:!0});wn.decode();function w(i,e){return i=i>>>0,wn.decode(ce().subarray(i,i+e))}function S(i){return i==null}function G(i,e){return i=i>>>0,ce().subarray(i/1,i/1+e)}const ut=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>{n.__wbindgen_export_6.get(i.dtor)(i.a,i.b)});function tr(i,e,t,r){const s={a:i,b:e,cnt:1,dtor:t},_=(...o)=>{s.cnt++;const a=s.a;s.a=0;try{return r(a,s.b,...o)}finally{--s.cnt===0?(n.__wbindgen_export_6.get(s.dtor)(a,s.b),ut.unregister(s)):s.a=a}};return _.original=s,ut.register(_,s,s),_}function yn(i,e,t,r){const s={a:i,b:e,cnt:1,dtor:t},_=(...o)=>{s.cnt++;try{return r(s.a,s.b,...o)}finally{--s.cnt===0&&(n.__wbindgen_export_6.get(s.dtor)(s.a,s.b),s.a=0,ut.unregister(s))}};return _.original=s,ut.register(_,s,s),_}function rr(i){const e=typeof i;if(e=="number"||e=="boolean"||i==null)return`${i}`;if(e=="string")return`"${i}"`;if(e=="symbol"){const s=i.description;return s==null?"Symbol":`Symbol(${s})`}if(e=="function"){const s=i.name;return typeof s=="string"&&s.length>0?`Function(${s})`:"Function"}if(Array.isArray(i)){const s=i.length;let _="[";s>0&&(_+=rr(i[0]));for(let o=1;o<s;o++)_+=", "+rr(i[o]);return _+="]",_}const t=/\[object ([^\]]+)\]/.exec(toString.call(i));let r;if(t&&t.length>1)r=t[1];else return toString.call(i);if(r=="Object")try{return"Object("+JSON.stringify(i)+")"}catch{return"Object"}return i instanceof Error?`${i.name}: ${i.message}
${i.stack}`:r}function Y(i,e){const t=e(i.length*1,1)>>>0;return ce().set(i,t/1),u=i.length,t}function d(i){const e=n.__wbindgen_export_4.get(i);return n.__externref_table_dealloc(i),e}function b(i,e){if(!(i instanceof e))throw new Error(`expected instance of ${e.name}`)}function F(i,e){const t=e(i.length*4,4)>>>0;for(let r=0;r<i.length;r++){const s=U(i[r]);q().setUint32(t+4*r,s,!0)}return u=i.length,t}function Ce(i,e){i=i>>>0;const t=q(),r=[];for(let s=i;s<i+4*e;s+=4)r.push(n.__wbindgen_export_4.get(t.getUint32(s,!0)));return n.__externref_drop_slice(i,e),r}let dt=null;function is(){return(dt===null||dt.byteLength===0)&&(dt=new Uint16Array(n.memory.buffer)),dt}function ss(i,e){return i=i>>>0,is().subarray(i/2,i/2+e)}function bn(){const i=n.getVersions();return Jt.__wrap(i)}function _s(){n.start()}function os(i,e,t){const r=n.closure29_externref_shim_multivalue_shim(i,e,t);if(r[1])throw d(r[0])}function as(i,e){n._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h607bd7dfd48e12ce(i,e)}function cs(i,e,t){n.closure734_externref_shim(i,e,t)}function gs(i,e){n._dyn_core__ops__function__Fn_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h6591bac8898b164c(i,e)}function us(i,e,t){n.closure410_externref_shim(i,e,t)}function ds(i,e,t,r){n.closure422_externref_shim(i,e,t,r)}const $=Object.freeze({MissingRoomKey:0,0:"MissingRoomKey",UnknownMessageIndex:1,1:"UnknownMessageIndex",MismatchedIdentityKeys:2,2:"MismatchedIdentityKeys",UnknownSenderDevice:3,3:"UnknownSenderDevice",UnsignedSenderDevice:4,4:"UnsignedSenderDevice",SenderIdentityVerificationViolation:5,5:"SenderIdentityVerificationViolation",UnableToDecrypt:6,6:"UnableToDecrypt"}),ls=Object.freeze({Ed25519:0,0:"Ed25519",Curve25519:1,1:"Curve25519",Unknown:3,3:"Unknown"}),ps=Object.freeze({Curve25519:0,0:"Curve25519",Ed25519:1,1:"Ed25519",Unknown:2,2:"Unknown"}),ue=Object.freeze({OlmV1Curve25519AesSha2:0,0:"OlmV1Curve25519AesSha2",MegolmV1AesSha2:1,1:"MegolmV1AesSha2",Unknown:2,2:"Unknown"}),Oe=Object.freeze({Invited:0,0:"Invited",Joined:1,1:"Joined",Shared:2,2:"Shared",WorldReadable:3,3:"WorldReadable"}),nr=Object.freeze({Verified:0,0:"Verified",BlackListed:1,1:"BlackListed",Ignored:2,2:"Ignored",Unset:3,3:"Unset"}),ir=Object.freeze({Trace:0,0:"Trace",Debug:1,1:"Debug",Info:2,2:"Info",Warn:3,3:"Warn",Error:4,4:"Error"}),ws=Object.freeze({Login:0,0:"Login",Reciprocate:1,1:"Reciprocate"}),re=Object.freeze({Created:0,0:"Created",Scanned:1,1:"Scanned",Confirmed:2,2:"Confirmed",Reciprocated:3,3:"Reciprocated",Done:4,4:"Done",Cancelled:5,5:"Cancelled"}),ys=Object.freeze({KeysUpload:0,0:"KeysUpload",KeysQuery:1,1:"KeysQuery",KeysClaim:2,2:"KeysClaim",ToDevice:3,3:"ToDevice",SignatureUpload:4,4:"SignatureUpload",RoomMessage:5,5:"RoomMessage",KeysBackup:6,6:"KeysBackup"}),sr=Object.freeze({Red:0,0:"Red",Grey:1,1:"Grey",None:2,2:"None"}),ne=Object.freeze({AuthenticityNotGuaranteed:0,0:"AuthenticityNotGuaranteed",UnknownDevice:1,1:"UnknownDevice",UnsignedDevice:2,2:"UnsignedDevice",UnverifiedIdentity:3,3:"UnverifiedIdentity",SentInClear:4,4:"SentInClear",VerificationViolation:5,5:"VerificationViolation"}),bs=Object.freeze({Missing:0,0:"Missing",Invalid:1,1:"Invalid",ValidButNotTrusted:2,2:"ValidButNotTrusted",ValidAndTrusted:3,3:"ValidAndTrusted"}),_r=Object.freeze({Untrusted:0,0:"Untrusted",CrossSignedOrLegacy:1,1:"CrossSignedOrLegacy",CrossSigned:2,2:"CrossSigned"}),Me=Object.freeze({SasV1:0,0:"SasV1",QrCodeScanV1:1,1:"QrCodeScanV1",QrCodeShowV1:2,2:"QrCodeShowV1",ReciprocateV1:3,3:"ReciprocateV1"}),Z=Object.freeze({Created:0,0:"Created",Requested:1,1:"Requested",Ready:2,2:"Ready",Transitioned:3,3:"Transitioned",Done:4,4:"Done",Cancelled:5,5:"Cancelled"}),hs=["pending","done"],hn=["readonly","readwrite","versionchange","readwriteflush","cleanup"],fs=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_attachment_free(i>>>0,1));class ms{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,fs.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_attachment_free(e,0)}static encrypt(e){const t=Y(e,n.__wbindgen_malloc),r=u,s=n.attachment_encrypt(t,r);if(s[2])throw d(s[1]);return Fe.__wrap(s[0])}static decrypt(e){b(e,Fe);const t=n.attachment_decrypt(e.__wbg_ptr);if(t[3])throw d(t[2]);var r=G(t[0],t[1]).slice();return n.__wbindgen_free(t[0],t[1]*1,1),r}}const fn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_backupdecryptionkey_free(i>>>0,1));class V{static __wrap(e){e=e>>>0;const t=Object.create(V.prototype);return t.__wbg_ptr=e,fn.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,fn.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_backupdecryptionkey_free(e,0)}static createRandomKey(){const e=n.backupdecryptionkey_createRandomKey();return V.__wrap(e)}static fromBase64(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u,s=n.backupdecryptionkey_fromBase64(t,r);if(s[2])throw d(s[1]);return V.__wrap(s[0])}toBase64(){return n.backupdecryptionkey_toBase64(this.__wbg_ptr)}get megolmV1PublicKey(){const e=n.backupdecryptionkey_megolmV1PublicKey(this.__wbg_ptr);return Ut.__wrap(e)}decryptV1(e,t,r){let s,_;try{const g=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),l=u,y=p(t,n.__wbindgen_malloc,n.__wbindgen_realloc),h=u,m=p(r,n.__wbindgen_malloc,n.__wbindgen_realloc),K=u,B=n.backupdecryptionkey_decryptV1(this.__wbg_ptr,g,l,y,h,m,K);var o=B[0],a=B[1];if(B[3])throw o=0,a=0,d(B[2]);return s=o,_=a,w(o,a)}finally{n.__wbindgen_free(s,_,1)}}}const mn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_backupkeys_free(i>>>0,1));class ft{static __wrap(e){e=e>>>0;const t=Object.create(ft.prototype);return t.__wbg_ptr=e,mn.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,mn.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_backupkeys_free(e,0)}get decryptionKey(){const e=n.__wbg_get_backupkeys_decryptionKey(this.__wbg_ptr);return e===0?void 0:V.__wrap(e)}set decryptionKey(e){let t=0;S(e)||(b(e,V),t=e.__destroy_into_raw()),n.__wbg_set_backupkeys_decryptionKey(this.__wbg_ptr,t)}get backupVersion(){const e=n.__wbg_get_backupkeys_backupVersion(this.__wbg_ptr);let t;return e[0]!==0&&(t=w(e[0],e[1]).slice(),n.__wbindgen_free(e[0],e[1]*1,1)),t}set backupVersion(e){var t=S(e)?0:p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u;n.__wbg_set_backupkeys_backupVersion(this.__wbg_ptr,t,r)}get decryptionKeyBase64(){return n.backupkeys_decryptionKeyBase64(this.__wbg_ptr)}}const vn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_backupsecretsbundle_free(i>>>0,1));class mt{static __wrap(e){e=e>>>0;const t=Object.create(mt.prototype);return t.__wbg_ptr=e,vn.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,vn.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_backupsecretsbundle_free(e,0)}get key(){let e,t;try{const r=n.__wbg_get_backupsecretsbundle_key(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}set key(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u;n.__wbg_set_backupsecretsbundle_key(this.__wbg_ptr,t,r)}get backup_version(){let e,t;try{const r=n.__wbg_get_backupsecretsbundle_backup_version(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}set backup_version(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u;n.__wbg_set_backupsecretsbundle_backup_version(this.__wbg_ptr,t,r)}}const or=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_base64encodedpkmessage_free(i>>>0,1));class Ee{static __wrap(e){e=e>>>0;const t=Object.create(Ee.prototype);return t.__wbg_ptr=e,or.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,or.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_base64encodedpkmessage_free(e,0)}get ciphertext(){let e,t;try{const r=n.__wbg_get_base64encodedpkmessage_ciphertext(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}set ciphertext(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u;n.__wbg_set_backupsecretsbundle_key(this.__wbg_ptr,t,r)}get mac(){let e,t;try{const r=n.__wbg_get_base64encodedpkmessage_mac(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}set mac(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u;n.__wbg_set_backupsecretsbundle_backup_version(this.__wbg_ptr,t,r)}get ephemeralKey(){let e,t;try{const r=n.__wbg_get_base64encodedpkmessage_ephemeralKey(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}set ephemeralKey(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u;n.__wbg_set_base64encodedpkmessage_ephemeralKey(this.__wbg_ptr,t,r)}constructor(e,t,r){const s=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),_=u,o=p(t,n.__wbindgen_malloc,n.__wbindgen_realloc),a=u,g=p(r,n.__wbindgen_malloc,n.__wbindgen_realloc),l=u,y=n.base64encodedpkmessage_new(s,_,o,a,g,l);return this.__wbg_ptr=y>>>0,or.register(this,this.__wbg_ptr,this),this}}const kn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_basemigrationdata_free(i>>>0,1));class ar{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,kn.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_basemigrationdata_free(e,0)}get userId(){const e=n.__wbg_get_basemigrationdata_userId(this.__wbg_ptr);return e===0?void 0:f.__wrap(e)}set userId(e){let t=0;S(e)||(b(e,f),t=e.__destroy_into_raw()),n.__wbg_set_basemigrationdata_userId(this.__wbg_ptr,t)}get deviceId(){const e=n.__wbg_get_basemigrationdata_deviceId(this.__wbg_ptr);return e===0?void 0:O.__wrap(e)}set deviceId(e){let t=0;S(e)||(b(e,O),t=e.__destroy_into_raw()),n.__wbg_set_basemigrationdata_deviceId(this.__wbg_ptr,t)}get pickledAccount(){let e,t;try{const r=n.__wbg_get_basemigrationdata_pickledAccount(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}set pickledAccount(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u;n.__wbg_set_backupsecretsbundle_key(this.__wbg_ptr,t,r)}get backupVersion(){const e=n.__wbg_get_basemigrationdata_backupVersion(this.__wbg_ptr);let t;return e[0]!==0&&(t=w(e[0],e[1]).slice(),n.__wbindgen_free(e[0],e[1]*1,1)),t}set backupVersion(e){var t=S(e)?0:p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u;n.__wbg_set_basemigrationdata_backupVersion(this.__wbg_ptr,t,r)}get backupRecoveryKey(){const e=n.__wbg_get_basemigrationdata_backupRecoveryKey(this.__wbg_ptr);let t;return e[0]!==0&&(t=w(e[0],e[1]).slice(),n.__wbindgen_free(e[0],e[1]*1,1)),t}set backupRecoveryKey(e){var t=S(e)?0:p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u;n.__wbg_set_basemigrationdata_backupRecoveryKey(this.__wbg_ptr,t,r)}get privateCrossSigningMasterKey(){const e=n.__wbg_get_basemigrationdata_privateCrossSigningMasterKey(this.__wbg_ptr);let t;return e[0]!==0&&(t=w(e[0],e[1]).slice(),n.__wbindgen_free(e[0],e[1]*1,1)),t}set privateCrossSigningMasterKey(e){var t=S(e)?0:p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u;n.__wbg_set_basemigrationdata_privateCrossSigningMasterKey(this.__wbg_ptr,t,r)}get privateCrossSigningSelfSigningKey(){const e=n.__wbg_get_basemigrationdata_privateCrossSigningSelfSigningKey(this.__wbg_ptr);let t;return e[0]!==0&&(t=w(e[0],e[1]).slice(),n.__wbindgen_free(e[0],e[1]*1,1)),t}set privateCrossSigningSelfSigningKey(e){var t=S(e)?0:p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u;n.__wbg_set_basemigrationdata_privateCrossSigningSelfSigningKey(this.__wbg_ptr,t,r)}get privateCrossSigningUserSigningKey(){const e=n.__wbg_get_basemigrationdata_privateCrossSigningUserSigningKey(this.__wbg_ptr);let t;return e[0]!==0&&(t=w(e[0],e[1]).slice(),n.__wbindgen_free(e[0],e[1]*1,1)),t}set privateCrossSigningUserSigningKey(e){var t=S(e)?0:p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u;n.__wbg_set_basemigrationdata_privateCrossSigningUserSigningKey(this.__wbg_ptr,t,r)}constructor(){const e=n.basemigrationdata_new();return this.__wbg_ptr=e>>>0,kn.register(this,this.__wbg_ptr,this),this}}const Sn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_cancelinfo_free(i>>>0,1));class le{static __wrap(e){e=e>>>0;const t=Object.create(le.prototype);return t.__wbg_ptr=e,Sn.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Sn.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_cancelinfo_free(e,0)}reason(){return n.cancelinfo_reason(this.__wbg_ptr)}cancelCode(){let e,t;try{const r=n.cancelinfo_cancelCode(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}cancelledbyUs(){return n.cancelinfo_cancelledbyUs(this.__wbg_ptr)!==0}}const Rn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_checkcode_free(i>>>0,1));class vt{static __wrap(e){e=e>>>0;const t=Object.create(vt.prototype);return t.__wbg_ptr=e,Rn.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Rn.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_checkcode_free(e,0)}as_bytes(){const e=n.checkcode_as_bytes(this.__wbg_ptr);var t=G(e[0],e[1]).slice();return n.__wbindgen_free(e[0],e[1]*1,1),t}to_digit(){return n.checkcode_to_digit(this.__wbg_ptr)}}const Kn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_collectstrategy_free(i>>>0,1));class T{static __wrap(e){e=e>>>0;const t=Object.create(T.prototype);return t.__wbg_ptr=e,Kn.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Kn.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_collectstrategy_free(e,0)}eq(e){return b(e,T),n.collectstrategy_eq(this.__wbg_ptr,e.__wbg_ptr)!==0}static deviceBasedStrategy(e,t){const r=n.collectstrategy_deviceBasedStrategy(e,t);return T.__wrap(r)}static allDevices(){const e=n.collectstrategy_allDevices();return T.__wrap(e)}static errorOnUnverifiedUserProblem(){const e=n.collectstrategy_errorOnUnverifiedUserProblem();return T.__wrap(e)}static identityBasedStrategy(){const e=n.collectstrategy_identityBasedStrategy();return T.__wrap(e)}static onlyTrustedDevices(){const e=n.collectstrategy_onlyTrustedDevices();return T.__wrap(e)}}const In=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_crosssigningbootstraprequests_free(i>>>0,1));class kt{static __wrap(e){e=e>>>0;const t=Object.create(kt.prototype);return t.__wbg_ptr=e,In.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,In.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_crosssigningbootstraprequests_free(e,0)}get uploadKeysRequest(){return n.__wbg_get_crosssigningbootstraprequests_uploadKeysRequest(this.__wbg_ptr)}get uploadSigningKeysRequest(){const e=n.__wbg_get_crosssigningbootstraprequests_uploadSigningKeysRequest(this.__wbg_ptr);return Xe.__wrap(e)}get uploadSignaturesRequest(){const e=n.__wbg_get_crosssigningbootstraprequests_uploadSignaturesRequest(this.__wbg_ptr);return fe.__wrap(e)}}const Cn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_crosssigningkeyexport_free(i>>>0,1));class St{static __wrap(e){e=e>>>0;const t=Object.create(St.prototype);return t.__wbg_ptr=e,Cn.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Cn.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_crosssigningkeyexport_free(e,0)}get masterKey(){const e=n.crosssigningkeyexport_masterKey(this.__wbg_ptr);let t;return e[0]!==0&&(t=w(e[0],e[1]).slice(),n.__wbindgen_free(e[0],e[1]*1,1)),t}get self_signing_key(){const e=n.crosssigningkeyexport_self_signing_key(this.__wbg_ptr);let t;return e[0]!==0&&(t=w(e[0],e[1]).slice(),n.__wbindgen_free(e[0],e[1]*1,1)),t}get userSigningKey(){const e=n.crosssigningkeyexport_userSigningKey(this.__wbg_ptr);let t;return e[0]!==0&&(t=w(e[0],e[1]).slice(),n.__wbindgen_free(e[0],e[1]*1,1)),t}}const On=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_crosssigningstatus_free(i>>>0,1));class Rt{static __wrap(e){e=e>>>0;const t=Object.create(Rt.prototype);return t.__wbg_ptr=e,On.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,On.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_crosssigningstatus_free(e,0)}get hasMaster(){return n.crosssigningstatus_hasMaster(this.__wbg_ptr)!==0}get hasSelfSigning(){return n.crosssigningstatus_hasSelfSigning(this.__wbg_ptr)!==0}get hasUserSigning(){return n.crosssigningstatus_hasUserSigning(this.__wbg_ptr)!==0}}const cr=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_curve25519publickey_free(i>>>0,1));class D{static __wrap(e){e=e>>>0;const t=Object.create(D.prototype);return t.__wbg_ptr=e,cr.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,cr.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_curve25519publickey_free(e,0)}constructor(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u,s=n.curve25519publickey_new(t,r);if(s[2])throw d(s[1]);return this.__wbg_ptr=s[0]>>>0,cr.register(this,this.__wbg_ptr,this),this}get length(){return n.curve25519publickey_length(this.__wbg_ptr)>>>0}toBase64(){let e,t;try{const r=n.curve25519publickey_toBase64(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}}const Mn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_curve25519secretkey_free(i>>>0,1));class ee{static __wrap(e){e=e>>>0;const t=Object.create(ee.prototype);return t.__wbg_ptr=e,Mn.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Mn.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_curve25519secretkey_free(e,0)}static new(){const e=n.curve25519secretkey_new();return ee.__wrap(e)}static fromBase64(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u,s=n.curve25519secretkey_fromBase64(t,r);if(s[2])throw d(s[1]);return ee.__wrap(s[0])}toBase64(){let e,t;try{const r=n.curve25519secretkey_toBase64(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}toUint8Array(){const e=n.curve25519secretkey_toUint8Array(this.__wbg_ptr);var t=G(e[0],e[1]).slice();return n.__wbindgen_free(e[0],e[1]*1,1),t}static fromUint8Array(e){const t=Y(e,n.__wbindgen_malloc),r=u,s=n.curve25519secretkey_fromUint8Array(t,r);if(s[2])throw d(s[1]);return ee.__wrap(s[0])}}const qn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_decryptedroomevent_free(i>>>0,1));class Kt{static __wrap(e){e=e>>>0;const t=Object.create(Kt.prototype);return t.__wbg_ptr=e,qn.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,qn.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_decryptedroomevent_free(e,0)}get event(){return n.__wbg_get_decryptedroomevent_event(this.__wbg_ptr)}get sender(){const e=n.decryptedroomevent_sender(this.__wbg_ptr);return e===0?void 0:f.__wrap(e)}get senderDevice(){const e=n.decryptedroomevent_senderDevice(this.__wbg_ptr);return e===0?void 0:O.__wrap(e)}get senderCurve25519Key(){return n.decryptedroomevent_senderCurve25519Key(this.__wbg_ptr)}get senderClaimedEd25519Key(){return n.decryptedroomevent_senderClaimedEd25519Key(this.__wbg_ptr)}get forwardingCurve25519KeyChain(){return n.decryptedroomevent_forwardingCurve25519KeyChain(this.__wbg_ptr)}shieldState(e){const t=n.decryptedroomevent_shieldState(this.__wbg_ptr,e);return t===0?void 0:Ye.__wrap(t)}}const Dn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_decryptionsettings_free(i>>>0,1));class gr{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Dn.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_decryptionsettings_free(e,0)}get sender_device_trust_requirement(){return n.__wbg_get_decryptionsettings_sender_device_trust_requirement(this.__wbg_ptr)}set sender_device_trust_requirement(e){n.__wbg_set_decryptionsettings_sender_device_trust_requirement(this.__wbg_ptr,e)}constructor(e){const t=n.decryptionsettings_new(e);return this.__wbg_ptr=t>>>0,Dn.register(this,this.__wbg_ptr,this),this}}const En=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_dehydrateddevice_free(i>>>0,1));class It{static __wrap(e){e=e>>>0;const t=Object.create(It.prototype);return t.__wbg_ptr=e,En.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,En.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_dehydrateddevice_free(e,0)}keysForUpload(e,t){return b(t,L),n.dehydrateddevice_keysForUpload(this.__wbg_ptr,e,t.__wbg_ptr)}}const Bn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_dehydrateddevicekey_free(i>>>0,1));class L{static __wrap(e){e=e>>>0;const t=Object.create(L.prototype);return t.__wbg_ptr=e,Bn.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Bn.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_dehydrateddevicekey_free(e,0)}static createRandomKey(){const e=n.dehydrateddevicekey_createRandomKey();if(e[2])throw d(e[1]);return L.__wrap(e[0])}static createKeyFromArray(e){const t=n.dehydrateddevicekey_createKeyFromArray(e);if(t[2])throw d(t[1]);return L.__wrap(t[0])}toBase64(){return n.dehydrateddevicekey_toBase64(this.__wbg_ptr)}}const Un=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_dehydrateddevices_free(i>>>0,1));class Ct{static __wrap(e){e=e>>>0;const t=Object.create(Ct.prototype);return t.__wbg_ptr=e,Un.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Un.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_dehydrateddevices_free(e,0)}create(){return n.dehydrateddevices_create(this.__wbg_ptr)}rehydrate(e,t,r){b(e,L),b(t,O);const s=p(r,n.__wbindgen_malloc,n.__wbindgen_realloc),_=u;return n.dehydrateddevices_rehydrate(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,s,_)}getDehydratedDeviceKey(){return n.dehydrateddevices_getDehydratedDeviceKey(this.__wbg_ptr)}saveDehydratedDeviceKey(e){return b(e,L),n.dehydrateddevices_saveDehydratedDeviceKey(this.__wbg_ptr,e.__wbg_ptr)}deleteDehydratedDeviceKey(){return n.dehydrateddevices_deleteDehydratedDeviceKey(this.__wbg_ptr)}}const Fn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_device_free(i>>>0,1));class Be{static __wrap(e){e=e>>>0;const t=Object.create(Be.prototype);return t.__wbg_ptr=e,Fn.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Fn.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_device_free(e,0)}requestVerification(e){var t=S(e)?0:F(e,n.__wbindgen_malloc),r=u;const s=n.device_requestVerification(this.__wbg_ptr,t,r);if(s[2])throw d(s[1]);return d(s[0])}encryptToDeviceEvent(e,t){const r=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),s=u;return n.device_encryptToDeviceEvent(this.__wbg_ptr,r,s,t)}isVerified(){return n.device_isVerified(this.__wbg_ptr)!==0}isCrossSigningTrusted(){return n.device_isCrossSigningTrusted(this.__wbg_ptr)!==0}isCrossSignedByOwner(){return n.device_isCrossSignedByOwner(this.__wbg_ptr)!==0}setLocalTrust(e){return n.device_setLocalTrust(this.__wbg_ptr,e)}get userId(){const e=n.device_userId(this.__wbg_ptr);return f.__wrap(e)}get deviceId(){const e=n.device_deviceId(this.__wbg_ptr);return O.__wrap(e)}get displayName(){const e=n.device_displayName(this.__wbg_ptr);let t;return e[0]!==0&&(t=w(e[0],e[1]).slice(),n.__wbindgen_free(e[0],e[1]*1,1)),t}getKey(e){const t=n.device_getKey(this.__wbg_ptr,e);if(t[2])throw d(t[1]);return t[0]===0?void 0:Ue.__wrap(t[0])}get curve25519Key(){const e=n.device_curve25519Key(this.__wbg_ptr);return e===0?void 0:D.__wrap(e)}get ed25519Key(){const e=n.device_ed25519Key(this.__wbg_ptr);return e===0?void 0:ie.__wrap(e)}get keys(){return n.device_keys(this.__wbg_ptr)}get algorithms(){return n.device_algorithms(this.__wbg_ptr)}get signatures(){const e=n.device_signatures(this.__wbg_ptr);return $e.__wrap(e)}get localTrustState(){return n.device_localTrustState(this.__wbg_ptr)}isLocallyTrusted(){return n.device_isLocallyTrusted(this.__wbg_ptr)!==0}isBlacklisted(){return n.device_isBlacklisted(this.__wbg_ptr)!==0}isDeleted(){return n.device_isDeleted(this.__wbg_ptr)!==0}firstTimeSeen(){const e=n.device_firstTimeSeen(this.__wbg_ptr);return BigInt.asUintN(64,e)}verify(){return n.device_verify(this.__wbg_ptr)}get isDehydrated(){return n.device_isDehydrated(this.__wbg_ptr)!==0}}const ur=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_deviceid_free(i>>>0,1));class O{static __wrap(e){e=e>>>0;const t=Object.create(O.prototype);return t.__wbg_ptr=e,ur.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,ur.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_deviceid_free(e,0)}constructor(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u,s=n.deviceid_new(t,r);return this.__wbg_ptr=s>>>0,ur.register(this,this.__wbg_ptr,this),this}toString(){let e,t;try{const r=n.deviceid_toString(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}}const Vn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_devicekey_free(i>>>0,1));class Ue{static __wrap(e){e=e>>>0;const t=Object.create(Ue.prototype);return t.__wbg_ptr=e,Vn.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Vn.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_devicekey_free(e,0)}get name(){return n.devicekey_name(this.__wbg_ptr)}get curve25519(){const e=n.devicekey_curve25519(this.__wbg_ptr);return e===0?void 0:D.__wrap(e)}get ed25519(){const e=n.devicekey_ed25519(this.__wbg_ptr);return e===0?void 0:ie.__wrap(e)}get unknown(){const e=n.devicekey_unknown(this.__wbg_ptr);let t;return e[0]!==0&&(t=w(e[0],e[1]).slice(),n.__wbindgen_free(e[0],e[1]*1,1)),t}toBase64(){let e,t;try{const r=n.devicekey_toBase64(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}}const Pn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_devicekeyalgorithm_free(i>>>0,1));class Ot{static __wrap(e){e=e>>>0;const t=Object.create(Ot.prototype);return t.__wbg_ptr=e,Pn.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Pn.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_devicekeyalgorithm_free(e,0)}get name(){return n.devicekeyalgorithm_name(this.__wbg_ptr)}toString(){let e,t;try{const r=n.devicekeyalgorithm_toString(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}}const dr=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_devicekeyid_free(i>>>0,1));class pe{static __wrap(e){e=e>>>0;const t=Object.create(pe.prototype);return t.__wbg_ptr=e,dr.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,dr.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_devicekeyid_free(e,0)}constructor(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u,s=n.devicekeyid_new(t,r);if(s[2])throw d(s[1]);return this.__wbg_ptr=s[0]>>>0,dr.register(this,this.__wbg_ptr,this),this}get algorithm(){const e=n.devicekeyid_algorithm(this.__wbg_ptr);return Ot.__wrap(e)}get deviceId(){const e=n.devicekeyid_deviceId(this.__wbg_ptr);return O.__wrap(e)}toString(){let e,t;try{const r=n.devicekeyid_toString(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}}const Tn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_devicelists_free(i>>>0,1));class lt{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Tn.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_devicelists_free(e,0)}constructor(e,t){var r=S(e)?0:F(e,n.__wbindgen_malloc),s=u,_=S(t)?0:F(t,n.__wbindgen_malloc),o=u;const a=n.devicelists_new(r,s,_,o);if(a[2])throw d(a[1]);return this.__wbg_ptr=a[0]>>>0,Tn.register(this,this.__wbg_ptr,this),this}isEmpty(){return n.devicelists_isEmpty(this.__wbg_ptr)!==0}get changed(){const e=n.devicelists_changed(this.__wbg_ptr);var t=Ce(e[0],e[1]).slice();return n.__wbindgen_free(e[0],e[1]*4,4),t}get left(){const e=n.devicelists_left(this.__wbg_ptr);var t=Ce(e[0],e[1]).slice();return n.__wbindgen_free(e[0],e[1]*4,4),t}}const An=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_ecies_free(i>>>0,1));class vs{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,An.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_ecies_free(e,0)}constructor(){const e=n.ecies_new();return this.__wbg_ptr=e>>>0,An.register(this,this.__wbg_ptr,this),this}public_key(){const e=n.ecies_public_key(this.__wbg_ptr);return D.__wrap(e)}establish_inbound_channel(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u,s=n.ecies_establish_inbound_channel(this.__wbg_ptr,t,r);if(s[2])throw d(s[1]);return Et.__wrap(s[0])}establish_outbound_channel(e,t){b(e,D);const r=p(t,n.__wbindgen_malloc,n.__wbindgen_realloc),s=u,_=n.ecies_establish_outbound_channel(this.__wbg_ptr,e.__wbg_ptr,r,s);if(_[2])throw d(_[1]);return Ft.__wrap(_[0])}}const zn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_ed25519publickey_free(i>>>0,1));class ie{static __wrap(e){e=e>>>0;const t=Object.create(ie.prototype);return t.__wbg_ptr=e,zn.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,zn.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_ed25519publickey_free(e,0)}get length(){return n.ed25519publickey_length(this.__wbg_ptr)>>>0}toBase64(){let e,t;try{const r=n.ed25519publickey_toBase64(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}}const lr=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_ed25519signature_free(i>>>0,1));class we{static __wrap(e){e=e>>>0;const t=Object.create(we.prototype);return t.__wbg_ptr=e,lr.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,lr.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_ed25519signature_free(e,0)}constructor(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u,s=n.ed25519signature_new(t,r);if(s[2])throw d(s[1]);return this.__wbg_ptr=s[0]>>>0,lr.register(this,this.__wbg_ptr,this),this}toBase64(){let e,t;try{const r=n.ed25519signature_toBase64(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}}const Nn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_emoji_free(i>>>0,1));class Mt{static __wrap(e){e=e>>>0;const t=Object.create(Mt.prototype);return t.__wbg_ptr=e,Nn.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Nn.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_emoji_free(e,0)}get symbol(){return n.emoji_symbol(this.__wbg_ptr)}get description(){return n.emoji_description(this.__wbg_ptr)}}const pr=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_encryptedattachment_free(i>>>0,1));class Fe{static __wrap(e){e=e>>>0;const t=Object.create(Fe.prototype);return t.__wbg_ptr=e,pr.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,pr.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_encryptedattachment_free(e,0)}constructor(e,t){const r=Y(e,n.__wbindgen_malloc),s=u,_=p(t,n.__wbindgen_malloc,n.__wbindgen_realloc),o=u,a=n.encryptedattachment_new(r,s,_,o);if(a[2])throw d(a[1]);return this.__wbg_ptr=a[0]>>>0,pr.register(this,this.__wbg_ptr,this),this}get encryptedData(){const e=n.encryptedattachment_encryptedData(this.__wbg_ptr);var t=G(e[0],e[1]).slice();return n.__wbindgen_free(e[0],e[1]*1,1),t}get mediaEncryptionInfo(){const e=n.encryptedattachment_mediaEncryptionInfo(this.__wbg_ptr);let t;return e[0]!==0&&(t=w(e[0],e[1]).slice(),n.__wbindgen_free(e[0],e[1]*1,1)),t}get hasMediaEncryptionInfoBeenConsumed(){return n.encryptedattachment_hasMediaEncryptionInfoBeenConsumed(this.__wbg_ptr)!==0}}const jn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_encryptioninfo_free(i>>>0,1));class qt{static __wrap(e){e=e>>>0;const t=Object.create(qt.prototype);return t.__wbg_ptr=e,jn.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,jn.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_encryptioninfo_free(e,0)}get sender(){const e=n.encryptioninfo_sender(this.__wbg_ptr);return f.__wrap(e)}get senderDevice(){const e=n.encryptioninfo_senderDevice(this.__wbg_ptr);return e===0?void 0:O.__wrap(e)}get senderCurve25519Key(){return n.encryptioninfo_senderCurve25519Key(this.__wbg_ptr)}get senderClaimedEd25519Key(){return n.encryptioninfo_senderClaimedEd25519Key(this.__wbg_ptr)}shieldState(e){const t=n.encryptioninfo_shieldState(this.__wbg_ptr,e);return Ye.__wrap(t)}}const xn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_encryptionsettings_free(i>>>0,1));class wr{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,xn.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_encryptionsettings_free(e,0)}get algorithm(){return n.__wbg_get_encryptionsettings_algorithm(this.__wbg_ptr)}set algorithm(e){n.__wbg_set_encryptionsettings_algorithm(this.__wbg_ptr,e)}get rotationPeriod(){const e=n.__wbg_get_encryptionsettings_rotationPeriod(this.__wbg_ptr);return BigInt.asUintN(64,e)}set rotationPeriod(e){n.__wbg_set_encryptionsettings_rotationPeriod(this.__wbg_ptr,e)}get rotationPeriodMessages(){const e=n.__wbg_get_encryptionsettings_rotationPeriodMessages(this.__wbg_ptr);return BigInt.asUintN(64,e)}set rotationPeriodMessages(e){n.__wbg_set_encryptionsettings_rotationPeriodMessages(this.__wbg_ptr,e)}get historyVisibility(){return n.__wbg_get_encryptionsettings_historyVisibility(this.__wbg_ptr)}set historyVisibility(e){n.__wbg_set_encryptionsettings_historyVisibility(this.__wbg_ptr,e)}get sharingStrategy(){const e=n.__wbg_get_encryptionsettings_sharingStrategy(this.__wbg_ptr);return T.__wrap(e)}set sharingStrategy(e){b(e,T);var t=e.__destroy_into_raw();n.__wbg_set_encryptionsettings_sharingStrategy(this.__wbg_ptr,t)}constructor(){const e=n.encryptionsettings_new();return this.__wbg_ptr=e>>>0,xn.register(this,this.__wbg_ptr,this),this}}const Ln=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_establishedecies_free(i>>>0,1));class se{static __wrap(e){e=e>>>0;const t=Object.create(se.prototype);return t.__wbg_ptr=e,Ln.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Ln.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_establishedecies_free(e,0)}public_key(){const e=n.establishedecies_public_key(this.__wbg_ptr);return D.__wrap(e)}encrypt(e){let t,r;try{const s=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),_=u,o=n.establishedecies_encrypt(this.__wbg_ptr,s,_);return t=o[0],r=o[1],w(o[0],o[1])}finally{n.__wbindgen_free(t,r,1)}}decrypt(e){let t,r;try{const o=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),a=u,g=n.establishedecies_decrypt(this.__wbg_ptr,o,a);var s=g[0],_=g[1];if(g[3])throw s=0,_=0,d(g[2]);return t=s,r=_,w(s,_)}finally{n.__wbindgen_free(t,r,1)}}check_code(){const e=n.establishedecies_check_code(this.__wbg_ptr);return vt.__wrap(e)}}const Wn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_eventid_free(i>>>0,1));class yr{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Wn.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_eventid_free(e,0)}constructor(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u,s=n.eventid_new(t,r);if(s[2])throw d(s[1]);return this.__wbg_ptr=s[0]>>>0,Wn.register(this,this.__wbg_ptr,this),this}get localpart(){let e,t;try{const r=n.eventid_localpart(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}get serverName(){const e=n.eventid_serverName(this.__wbg_ptr);return e===0?void 0:He.__wrap(e)}toString(){let e,t;try{const r=n.eventid_toString(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}}const Gn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_identitykeys_free(i>>>0,1));class Dt{static __wrap(e){e=e>>>0;const t=Object.create(Dt.prototype);return t.__wbg_ptr=e,Gn.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Gn.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_identitykeys_free(e,0)}get ed25519(){const e=n.__wbg_get_identitykeys_ed25519(this.__wbg_ptr);return ie.__wrap(e)}set ed25519(e){b(e,ie);var t=e.__destroy_into_raw();n.__wbg_set_identitykeys_ed25519(this.__wbg_ptr,t)}get curve25519(){const e=n.__wbg_get_identitykeys_curve25519(this.__wbg_ptr);return D.__wrap(e)}set curve25519(e){b(e,D);var t=e.__destroy_into_raw();n.__wbg_set_identitykeys_curve25519(this.__wbg_ptr,t)}}const Jn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_inboundcreationresult_free(i>>>0,1));class Et{static __wrap(e){e=e>>>0;const t=Object.create(Et.prototype);return t.__wbg_ptr=e,Jn.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Jn.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_inboundcreationresult_free(e,0)}get channel(){const e=n.__wbg_get_inboundcreationresult_channel(this.__wbg_ptr);return se.__wrap(e)}set channel(e){b(e,se);var t=e.__destroy_into_raw();n.__wbg_set_inboundcreationresult_channel(this.__wbg_ptr,t)}get message(){let e,t;try{const r=n.__wbg_get_inboundcreationresult_message(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}set message(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u;n.__wbg_set_backupsecretsbundle_key(this.__wbg_ptr,t,r)}}const Qn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_inboundgroupsession_free(i>>>0,1));class Bt{static __wrap(e){e=e>>>0;const t=Object.create(Bt.prototype);return t.__wbg_ptr=e,Qn.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Qn.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_inboundgroupsession_free(e,0)}get roomId(){const e=n.inboundgroupsession_roomId(this.__wbg_ptr);return C.__wrap(e)}get senderKey(){const e=n.inboundgroupsession_senderKey(this.__wbg_ptr);return D.__wrap(e)}get sessionId(){let e,t;try{const r=n.inboundgroupsession_sessionId(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}hasBeenImported(){return n.inboundgroupsession_hasBeenImported(this.__wbg_ptr)!==0}}const br=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_keysbackuprequest_free(i>>>0,1));class Ve{static __wrap(e){e=e>>>0;const t=Object.create(Ve.prototype);return t.__wbg_ptr=e,br.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,br.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_keysbackuprequest_free(e,0)}get id(){return n.__wbg_get_keysbackuprequest_id(this.__wbg_ptr)}get body(){return n.__wbg_get_keysbackuprequest_body(this.__wbg_ptr)}get version(){return n.__wbg_get_keysbackuprequest_version(this.__wbg_ptr)}constructor(e,t,r){const s=n.keysbackuprequest_new(e,t,r);return this.__wbg_ptr=s>>>0,br.register(this,this.__wbg_ptr,this),this}get type(){return n.keysbackuprequest_type(this.__wbg_ptr)}}const hr=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_keysclaimrequest_free(i>>>0,1));class Pe{static __wrap(e){e=e>>>0;const t=Object.create(Pe.prototype);return t.__wbg_ptr=e,hr.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,hr.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_keysclaimrequest_free(e,0)}get id(){return n.__wbg_get_keysclaimrequest_id(this.__wbg_ptr)}get body(){return n.__wbg_get_keysclaimrequest_body(this.__wbg_ptr)}constructor(e,t){const r=n.keysclaimrequest_new(e,t);return this.__wbg_ptr=r>>>0,hr.register(this,this.__wbg_ptr,this),this}get type(){return n.keysclaimrequest_type(this.__wbg_ptr)}}const fr=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_keysqueryrequest_free(i>>>0,1));class ye{static __wrap(e){e=e>>>0;const t=Object.create(ye.prototype);return t.__wbg_ptr=e,fr.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,fr.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_keysqueryrequest_free(e,0)}get id(){return n.__wbg_get_keysqueryrequest_id(this.__wbg_ptr)}get body(){return n.__wbg_get_keysqueryrequest_body(this.__wbg_ptr)}constructor(e,t){const r=n.keysqueryrequest_new(e,t);return this.__wbg_ptr=r>>>0,fr.register(this,this.__wbg_ptr,this),this}get type(){return n.keysqueryrequest_type(this.__wbg_ptr)}}const mr=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_keysuploadrequest_free(i>>>0,1));class Te{static __wrap(e){e=e>>>0;const t=Object.create(Te.prototype);return t.__wbg_ptr=e,mr.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,mr.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_keysuploadrequest_free(e,0)}get id(){return n.__wbg_get_keysuploadrequest_id(this.__wbg_ptr)}get body(){return n.__wbg_get_keysuploadrequest_body(this.__wbg_ptr)}constructor(e,t){const r=n.keysuploadrequest_new(e,t);return this.__wbg_ptr=r>>>0,mr.register(this,this.__wbg_ptr,this),this}get type(){return n.keysuploadrequest_type(this.__wbg_ptr)}}const Hn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_maybesignature_free(i>>>0,1));class Ae{static __wrap(e){e=e>>>0;const t=Object.create(Ae.prototype);return t.__wbg_ptr=e,Hn.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Hn.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_maybesignature_free(e,0)}isValid(){return n.maybesignature_isValid(this.__wbg_ptr)!==0}isInvalid(){return n.maybesignature_isInvalid(this.__wbg_ptr)!==0}get signature(){const e=n.maybesignature_signature(this.__wbg_ptr);return e===0?void 0:Lt.__wrap(e)}get invalidSignatureSource(){const e=n.maybesignature_invalidSignatureSource(this.__wbg_ptr);let t;return e[0]!==0&&(t=w(e[0],e[1]).slice(),n.__wbindgen_free(e[0],e[1]*1,1)),t}}const Yn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_megolmdecryptionerror_free(i>>>0,1));class ze{static __wrap(e){e=e>>>0;const t=Object.create(ze.prototype);return t.__wbg_ptr=e,Yn.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Yn.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_megolmdecryptionerror_free(e,0)}get code(){return n.__wbg_get_megolmdecryptionerror_code(this.__wbg_ptr)}get description(){return n.__wbg_get_megolmdecryptionerror_description(this.__wbg_ptr)}get maybe_withheld(){return n.__wbg_get_megolmdecryptionerror_maybe_withheld(this.__wbg_ptr)}}const $n=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_megolmv1backupkey_free(i>>>0,1));class Ut{static __wrap(e){e=e>>>0;const t=Object.create(Ut.prototype);return t.__wbg_ptr=e,$n.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,$n.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_megolmv1backupkey_free(e,0)}get publicKeyBase64(){return n.megolmv1backupkey_publicKeyBase64(this.__wbg_ptr)}get algorithm(){return n.megolmv1backupkey_algorithm(this.__wbg_ptr)}}const ks=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_migration_free(i>>>0,1));class pt{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,ks.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_migration_free(e,0)}static migrateBaseData(e,t,r){return b(e,ar),b(r,x),n.migration_migrateBaseData(e.__wbg_ptr,t,r.__wbg_ptr)}static migrateOlmSessions(e,t,r){const s=F(e,n.__wbindgen_malloc),_=u;return b(r,x),n.migration_migrateOlmSessions(s,_,t,r.__wbg_ptr)}static migrateMegolmSessions(e,t,r){const s=F(e,n.__wbindgen_malloc),_=u;return b(r,x),n.migration_migrateMegolmSessions(s,_,t,r.__wbg_ptr)}}const vr=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_olmmachine_free(i>>>0,1));class Ne{static __wrap(e){e=e>>>0;const t=Object.create(Ne.prototype);return t.__wbg_ptr=e,vr.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,vr.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_olmmachine_free(e,0)}constructor(){const e=n.olmmachine_new();if(e[2])throw d(e[1]);return this.__wbg_ptr=e[0]>>>0,vr.register(this,this.__wbg_ptr,this),this}static initialize(e,t,r,s){b(e,f),b(t,O);var _=S(r)?0:p(r,n.__wbindgen_malloc,n.__wbindgen_realloc),o=u,a=S(s)?0:p(s,n.__wbindgen_malloc,n.__wbindgen_realloc),g=u;return n.olmmachine_initialize(e.__wbg_ptr,t.__wbg_ptr,_,o,a,g)}static initFromStore(e,t,r){return b(e,f),b(t,O),b(r,x),n.olmmachine_initFromStore(e.__wbg_ptr,t.__wbg_ptr,r.__wbg_ptr)}get userId(){const e=n.olmmachine_userId(this.__wbg_ptr);return f.__wrap(e)}get deviceId(){const e=n.olmmachine_deviceId(this.__wbg_ptr);return O.__wrap(e)}get deviceCreationTimeMs(){return n.olmmachine_deviceCreationTimeMs(this.__wbg_ptr)}get identityKeys(){const e=n.olmmachine_identityKeys(this.__wbg_ptr);return Dt.__wrap(e)}get displayName(){return n.olmmachine_displayName(this.__wbg_ptr)}get roomKeyRequestsEnabled(){return n.olmmachine_roomKeyRequestsEnabled(this.__wbg_ptr)!==0}set roomKeyRequestsEnabled(e){n.olmmachine_set_roomKeyRequestsEnabled(this.__wbg_ptr,e)}get roomKeyForwardingEnabled(){return n.olmmachine_roomKeyForwardingEnabled(this.__wbg_ptr)!==0}set roomKeyForwardingEnabled(e){n.olmmachine_set_roomKeyForwardingEnabled(this.__wbg_ptr,e)}trackedUsers(){const e=n.olmmachine_trackedUsers(this.__wbg_ptr);if(e[2])throw d(e[1]);return d(e[0])}updateTrackedUsers(e){const t=F(e,n.__wbindgen_malloc),r=u;return n.olmmachine_updateTrackedUsers(this.__wbg_ptr,t,r)}markAllTrackedUsersAsDirty(){return n.olmmachine_markAllTrackedUsersAsDirty(this.__wbg_ptr)}receiveSyncChanges(e,t,r,s){const _=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),o=u;b(t,lt);const a=n.olmmachine_receiveSyncChanges(this.__wbg_ptr,_,o,t.__wbg_ptr,r,S(s)?0:U(s));if(a[2])throw d(a[1]);return d(a[0])}outgoingRequests(){return n.olmmachine_outgoingRequests(this.__wbg_ptr)}markRequestAsSent(e,t,r){const s=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),_=u,o=p(r,n.__wbindgen_malloc,n.__wbindgen_realloc),a=u,g=n.olmmachine_markRequestAsSent(this.__wbg_ptr,s,_,t,o,a);if(g[2])throw d(g[1]);return d(g[0])}encryptRoomEvent(e,t,r){b(e,C);const s=p(t,n.__wbindgen_malloc,n.__wbindgen_realloc),_=u,o=p(r,n.__wbindgen_malloc,n.__wbindgen_realloc),a=u,g=n.olmmachine_encryptRoomEvent(this.__wbg_ptr,e.__wbg_ptr,s,_,o,a);if(g[2])throw d(g[1]);return d(g[0])}decryptRoomEvent(e,t,r){const s=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),_=u;b(t,C),b(r,gr);const o=n.olmmachine_decryptRoomEvent(this.__wbg_ptr,s,_,t.__wbg_ptr,r.__wbg_ptr);if(o[2])throw d(o[1]);return d(o[0])}getRoomEventEncryptionInfo(e,t){const r=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),s=u;b(t,C);const _=n.olmmachine_getRoomEventEncryptionInfo(this.__wbg_ptr,r,s,t.__wbg_ptr);if(_[2])throw d(_[1]);return d(_[0])}crossSigningStatus(){return n.olmmachine_crossSigningStatus(this.__wbg_ptr)}exportSecretsBundle(){return n.olmmachine_exportSecretsBundle(this.__wbg_ptr)}importSecretsBundle(e){b(e,oe);var t=e.__destroy_into_raw();return n.olmmachine_importSecretsBundle(this.__wbg_ptr,t)}exportCrossSigningKeys(){return n.olmmachine_exportCrossSigningKeys(this.__wbg_ptr)}importCrossSigningKeys(e,t,r){var s=S(e)?0:p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),_=u,o=S(t)?0:p(t,n.__wbindgen_malloc,n.__wbindgen_realloc),a=u,g=S(r)?0:p(r,n.__wbindgen_malloc,n.__wbindgen_realloc),l=u;return n.olmmachine_importCrossSigningKeys(this.__wbg_ptr,s,_,o,a,g,l)}bootstrapCrossSigning(e){return n.olmmachine_bootstrapCrossSigning(this.__wbg_ptr,e)}getIdentity(e){return b(e,f),n.olmmachine_getIdentity(this.__wbg_ptr,e.__wbg_ptr)}sign(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u;return n.olmmachine_sign(this.__wbg_ptr,t,r)}invalidateGroupSession(e){return b(e,C),n.olmmachine_invalidateGroupSession(this.__wbg_ptr,e.__wbg_ptr)}shareRoomKey(e,t,r){b(e,C);const s=F(t,n.__wbindgen_malloc),_=u;return b(r,wr),n.olmmachine_shareRoomKey(this.__wbg_ptr,e.__wbg_ptr,s,_,r.__wbg_ptr)}queryKeysForUsers(e){const t=F(e,n.__wbindgen_malloc),r=u,s=n.olmmachine_queryKeysForUsers(this.__wbg_ptr,t,r);if(s[2])throw d(s[1]);return ye.__wrap(s[0])}getMissingSessions(e){const t=F(e,n.__wbindgen_malloc),r=u;return n.olmmachine_getMissingSessions(this.__wbg_ptr,t,r)}getUserDevices(e,t){return b(e,f),n.olmmachine_getUserDevices(this.__wbg_ptr,e.__wbg_ptr,!S(t),S(t)?0:t)}getDevice(e,t,r){return b(e,f),b(t,O),n.olmmachine_getDevice(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,!S(r),S(r)?0:r)}getVerification(e,t){b(e,f);const r=p(t,n.__wbindgen_malloc,n.__wbindgen_realloc),s=u,_=n.olmmachine_getVerification(this.__wbg_ptr,e.__wbg_ptr,r,s);if(_[2])throw d(_[1]);return d(_[0])}getVerificationRequest(e,t){b(e,f);const r=p(t,n.__wbindgen_malloc,n.__wbindgen_realloc),s=u,_=n.olmmachine_getVerificationRequest(this.__wbg_ptr,e.__wbg_ptr,r,s);return _===0?void 0:me.__wrap(_)}getVerificationRequests(e){return b(e,f),n.olmmachine_getVerificationRequests(this.__wbg_ptr,e.__wbg_ptr)}receiveVerificationEvent(e,t){const r=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),s=u;b(t,C);const _=n.olmmachine_receiveVerificationEvent(this.__wbg_ptr,r,s,t.__wbg_ptr);if(_[2])throw d(_[1]);return d(_[0])}exportRoomKeys(e){return n.olmmachine_exportRoomKeys(this.__wbg_ptr,e)}importRoomKeys(e,t){const r=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),s=u,_=n.olmmachine_importRoomKeys(this.__wbg_ptr,r,s,t);if(_[2])throw d(_[1]);return d(_[0])}importExportedRoomKeys(e,t){const r=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),s=u,_=n.olmmachine_importExportedRoomKeys(this.__wbg_ptr,r,s,t);if(_[2])throw d(_[1]);return d(_[0])}importBackedUpRoomKeys(e,t,r){const s=p(r,n.__wbindgen_malloc,n.__wbindgen_realloc),_=u,o=n.olmmachine_importBackedUpRoomKeys(this.__wbg_ptr,e,S(t)?0:U(t),s,_);if(o[2])throw d(o[1]);return d(o[0])}saveBackupDecryptionKey(e,t){b(e,V);const r=p(t,n.__wbindgen_malloc,n.__wbindgen_realloc),s=u;return n.olmmachine_saveBackupDecryptionKey(this.__wbg_ptr,e.__wbg_ptr,r,s)}getBackupKeys(){return n.olmmachine_getBackupKeys(this.__wbg_ptr)}verifyBackup(e){const t=n.olmmachine_verifyBackup(this.__wbg_ptr,e);if(t[2])throw d(t[1]);return d(t[0])}enableBackupV1(e,t){const r=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),s=u,_=p(t,n.__wbindgen_malloc,n.__wbindgen_realloc),o=u,a=n.olmmachine_enableBackupV1(this.__wbg_ptr,r,s,_,o);if(a[2])throw d(a[1]);return d(a[0])}isBackupEnabled(){return n.olmmachine_isBackupEnabled(this.__wbg_ptr)}disableBackup(){return n.olmmachine_disableBackup(this.__wbg_ptr)}backupRoomKeys(){return n.olmmachine_backupRoomKeys(this.__wbg_ptr)}roomKeyCounts(){return n.olmmachine_roomKeyCounts(this.__wbg_ptr)}static encryptExportedRoomKeys(e,t,r){let s,_;try{const g=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),l=u,y=p(t,n.__wbindgen_malloc,n.__wbindgen_realloc),h=u,m=n.olmmachine_encryptExportedRoomKeys(g,l,y,h,r);var o=m[0],a=m[1];if(m[3])throw o=0,a=0,d(m[2]);return s=o,_=a,w(o,a)}finally{n.__wbindgen_free(s,_,1)}}static decryptExportedRoomKeys(e,t){let r,s;try{const a=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),g=u,l=p(t,n.__wbindgen_malloc,n.__wbindgen_realloc),y=u,h=n.olmmachine_decryptExportedRoomKeys(a,g,l,y);var _=h[0],o=h[1];if(h[3])throw _=0,o=0,d(h[2]);return r=_,s=o,w(_,o)}finally{n.__wbindgen_free(r,s,1)}}registerRoomKeyUpdatedCallback(e){return n.olmmachine_registerRoomKeyUpdatedCallback(this.__wbg_ptr,e)}registerRoomKeysWithheldCallback(e){return n.olmmachine_registerRoomKeysWithheldCallback(this.__wbg_ptr,e)}registerUserIdentityUpdatedCallback(e){return n.olmmachine_registerUserIdentityUpdatedCallback(this.__wbg_ptr,e)}registerDevicesUpdatedCallback(e){return n.olmmachine_registerDevicesUpdatedCallback(this.__wbg_ptr,e)}registerReceiveSecretCallback(e){return n.olmmachine_registerReceiveSecretCallback(this.__wbg_ptr,e)}getSecretsFromInbox(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u;return n.olmmachine_getSecretsFromInbox(this.__wbg_ptr,t,r)}deleteSecretsFromInbox(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u;return n.olmmachine_deleteSecretsFromInbox(this.__wbg_ptr,t,r)}requestMissingSecretsIfNeeded(){return n.olmmachine_requestMissingSecretsIfNeeded(this.__wbg_ptr)}getRoomSettings(e){return b(e,C),n.olmmachine_getRoomSettings(this.__wbg_ptr,e.__wbg_ptr)}setRoomSettings(e,t){return b(e,C),b(t,_e),n.olmmachine_setRoomSettings(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr)}dehydratedDevices(){const e=n.olmmachine_dehydratedDevices(this.__wbg_ptr);return Ct.__wrap(e)}close(){const e=this.__destroy_into_raw();n.olmmachine_close(e)}}const Zn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_otheruseridentity_free(i>>>0,1));class je{static __wrap(e){e=e>>>0;const t=Object.create(je.prototype);return t.__wbg_ptr=e,Zn.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Zn.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_otheruseridentity_free(e,0)}isVerified(){return n.otheruseridentity_isVerified(this.__wbg_ptr)!==0}verify(){return n.otheruseridentity_verify(this.__wbg_ptr)}requestVerification(e,t,r){b(e,C),b(t,yr);var s=S(r)?0:F(r,n.__wbindgen_malloc),_=u;const o=n.otheruseridentity_requestVerification(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,s,_);if(o[2])throw d(o[1]);return me.__wrap(o[0])}verificationRequestContent(e){let t,r;try{var s=S(e)?0:F(e,n.__wbindgen_malloc),_=u;const g=n.otheruseridentity_verificationRequestContent(this.__wbg_ptr,s,_);var o=g[0],a=g[1];if(g[3])throw o=0,a=0,d(g[2]);return t=o,r=a,w(o,a)}finally{n.__wbindgen_free(t,r,1)}}get masterKey(){let e,t;try{const _=n.otheruseridentity_masterKey(this.__wbg_ptr);var r=_[0],s=_[1];if(_[3])throw r=0,s=0,d(_[2]);return e=r,t=s,w(r,s)}finally{n.__wbindgen_free(e,t,1)}}get selfSigningKey(){let e,t;try{const _=n.otheruseridentity_selfSigningKey(this.__wbg_ptr);var r=_[0],s=_[1];if(_[3])throw r=0,s=0,d(_[2]);return e=r,t=s,w(r,s)}finally{n.__wbindgen_free(e,t,1)}}pinCurrentMasterKey(){return n.otheruseridentity_pinCurrentMasterKey(this.__wbg_ptr)}identityNeedsUserApproval(){return n.otheruseridentity_identityNeedsUserApproval(this.__wbg_ptr)!==0}wasPreviouslyVerified(){return n.otheruseridentity_wasPreviouslyVerified(this.__wbg_ptr)!==0}withdrawVerification(){return n.otheruseridentity_withdrawVerification(this.__wbg_ptr)}hasVerificationViolation(){return n.otheruseridentity_hasVerificationViolation(this.__wbg_ptr)!==0}}const Xn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_outboundcreationresult_free(i>>>0,1));class Ft{static __wrap(e){e=e>>>0;const t=Object.create(Ft.prototype);return t.__wbg_ptr=e,Xn.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Xn.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_outboundcreationresult_free(e,0)}get channel(){const e=n.__wbg_get_inboundcreationresult_channel(this.__wbg_ptr);return se.__wrap(e)}set channel(e){b(e,se);var t=e.__destroy_into_raw();n.__wbg_set_inboundcreationresult_channel(this.__wbg_ptr,t)}get initial_message(){let e,t;try{const r=n.__wbg_get_outboundcreationresult_initial_message(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}set initial_message(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u;n.__wbg_set_backupsecretsbundle_key(this.__wbg_ptr,t,r)}}const ei=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_ownuseridentity_free(i>>>0,1));class xe{static __wrap(e){e=e>>>0;const t=Object.create(xe.prototype);return t.__wbg_ptr=e,ei.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,ei.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_ownuseridentity_free(e,0)}isVerified(){return n.ownuseridentity_isVerified(this.__wbg_ptr)!==0}verify(){return n.ownuseridentity_verify(this.__wbg_ptr)}requestVerification(e){var t=S(e)?0:F(e,n.__wbindgen_malloc),r=u;const s=n.ownuseridentity_requestVerification(this.__wbg_ptr,t,r);if(s[2])throw d(s[1]);return d(s[0])}trustsOurOwnDevice(){return n.ownuseridentity_trustsOurOwnDevice(this.__wbg_ptr)}get masterKey(){let e,t;try{const _=n.ownuseridentity_masterKey(this.__wbg_ptr);var r=_[0],s=_[1];if(_[3])throw r=0,s=0,d(_[2]);return e=r,t=s,w(r,s)}finally{n.__wbindgen_free(e,t,1)}}get selfSigningKey(){let e,t;try{const _=n.ownuseridentity_selfSigningKey(this.__wbg_ptr);var r=_[0],s=_[1];if(_[3])throw r=0,s=0,d(_[2]);return e=r,t=s,w(r,s)}finally{n.__wbindgen_free(e,t,1)}}get userSigningKey(){let e,t;try{const _=n.ownuseridentity_userSigningKey(this.__wbg_ptr);var r=_[0],s=_[1];if(_[3])throw r=0,s=0,d(_[2]);return e=r,t=s,w(r,s)}finally{n.__wbindgen_free(e,t,1)}}wasPreviouslyVerified(){return n.ownuseridentity_wasPreviouslyVerified(this.__wbg_ptr)!==0}withdrawVerification(){return n.ownuseridentity_withdrawVerification(this.__wbg_ptr)}hasVerificationViolation(){return n.ownuseridentity_hasVerificationViolation(this.__wbg_ptr)!==0}}const ti=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_pickledinboundgroupsession_free(i>>>0,1));class Le{static __unwrap(e){return e instanceof Le?e.__destroy_into_raw():0}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,ti.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_pickledinboundgroupsession_free(e,0)}get pickle(){let e,t;try{const r=n.__wbg_get_pickledinboundgroupsession_pickle(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}set pickle(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u;n.__wbg_set_backupsecretsbundle_key(this.__wbg_ptr,t,r)}get senderKey(){let e,t;try{const r=n.__wbg_get_pickledinboundgroupsession_senderKey(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}set senderKey(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u;n.__wbg_set_backupsecretsbundle_backup_version(this.__wbg_ptr,t,r)}get senderSigningKey(){const e=n.__wbg_get_pickledinboundgroupsession_senderSigningKey(this.__wbg_ptr);let t;return e[0]!==0&&(t=w(e[0],e[1]).slice(),n.__wbindgen_free(e[0],e[1]*1,1)),t}set senderSigningKey(e){var t=S(e)?0:p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u;n.__wbg_set_basemigrationdata_backupRecoveryKey(this.__wbg_ptr,t,r)}get roomId(){const e=n.__wbg_get_pickledinboundgroupsession_roomId(this.__wbg_ptr);return e===0?void 0:C.__wrap(e)}set roomId(e){let t=0;S(e)||(b(e,C),t=e.__destroy_into_raw()),n.__wbg_set_pickledinboundgroupsession_roomId(this.__wbg_ptr,t)}get imported(){return n.__wbg_get_pickledinboundgroupsession_imported(this.__wbg_ptr)!==0}set imported(e){n.__wbg_set_pickledinboundgroupsession_imported(this.__wbg_ptr,e)}get backedUp(){return n.__wbg_get_pickledinboundgroupsession_backedUp(this.__wbg_ptr)!==0}set backedUp(e){n.__wbg_set_pickledinboundgroupsession_backedUp(this.__wbg_ptr,e)}constructor(){const e=n.pickledinboundgroupsession_new();return this.__wbg_ptr=e>>>0,ti.register(this,this.__wbg_ptr,this),this}}const ri=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_pickledsession_free(i>>>0,1));class We{static __unwrap(e){return e instanceof We?e.__destroy_into_raw():0}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,ri.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_pickledsession_free(e,0)}get pickle(){let e,t;try{const r=n.__wbg_get_pickledsession_pickle(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}set pickle(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u;n.__wbg_set_backupsecretsbundle_key(this.__wbg_ptr,t,r)}get senderKey(){let e,t;try{const r=n.__wbg_get_pickledsession_senderKey(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}set senderKey(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u;n.__wbg_set_backupsecretsbundle_backup_version(this.__wbg_ptr,t,r)}get createdUsingFallbackKey(){return n.__wbg_get_pickledsession_createdUsingFallbackKey(this.__wbg_ptr)!==0}set createdUsingFallbackKey(e){n.__wbg_set_pickledsession_createdUsingFallbackKey(this.__wbg_ptr,e)}get creationTime(){return n.__wbg_get_pickledsession_creationTime(this.__wbg_ptr)}set creationTime(e){n.__wbg_set_pickledsession_creationTime(this.__wbg_ptr,e)}get lastUseTime(){return n.__wbg_get_pickledsession_lastUseTime(this.__wbg_ptr)}set lastUseTime(e){n.__wbg_set_pickledsession_lastUseTime(this.__wbg_ptr,e)}constructor(){const e=n.pickledsession_new();return this.__wbg_ptr=e>>>0,ri.register(this,this.__wbg_ptr,this),this}}const kr=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_pkdecryption_free(i>>>0,1));class Vt{static __wrap(e){e=e>>>0;const t=Object.create(Vt.prototype);return t.__wbg_ptr=e,kr.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,kr.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_pkdecryption_free(e,0)}constructor(){const e=n.pkdecryption_new();return this.__wbg_ptr=e>>>0,kr.register(this,this.__wbg_ptr,this),this}static fromKey(e){b(e,ee);const t=n.pkdecryption_fromKey(e.__wbg_ptr);return Vt.__wrap(t)}secretKey(){const e=n.pkdecryption_secretKey(this.__wbg_ptr);return ee.__wrap(e)}publicKey(){const e=n.pkdecryption_publicKey(this.__wbg_ptr);return D.__wrap(e)}decryptString(e){let t,r;try{b(e,Q);const o=n.pkdecryption_decryptString(this.__wbg_ptr,e.__wbg_ptr);var s=o[0],_=o[1];if(o[3])throw s=0,_=0,d(o[2]);return t=s,r=_,w(s,_)}finally{n.__wbindgen_free(t,r,1)}}decrypt(e){b(e,Q);const t=n.pkdecryption_decrypt(this.__wbg_ptr,e.__wbg_ptr);if(t[3])throw d(t[2]);var r=G(t[0],t[1]).slice();return n.__wbindgen_free(t[0],t[1]*1,1),r}}const ni=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_pkencryption_free(i>>>0,1));class Pt{static __wrap(e){e=e>>>0;const t=Object.create(Pt.prototype);return t.__wbg_ptr=e,ni.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,ni.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_pkencryption_free(e,0)}static fromKey(e){b(e,D);const t=n.pkencryption_fromKey(e.__wbg_ptr);return Pt.__wrap(t)}encrypt(e){const t=Y(e,n.__wbindgen_malloc),r=u,s=n.pkencryption_encrypt(this.__wbg_ptr,t,r);return Q.__wrap(s)}encryptString(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u,s=n.pkencryption_encrypt(this.__wbg_ptr,t,r);return Q.__wrap(s)}}const ii=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_pkmessage_free(i>>>0,1));class Q{static __wrap(e){e=e>>>0;const t=Object.create(Q.prototype);return t.__wbg_ptr=e,ii.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,ii.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_pkmessage_free(e,0)}ciphertext(){const e=n.pkmessage_ciphertext(this.__wbg_ptr);var t=G(e[0],e[1]).slice();return n.__wbindgen_free(e[0],e[1]*1,1),t}mac(){const e=n.pkmessage_mac(this.__wbg_ptr);var t=G(e[0],e[1]).slice();return n.__wbindgen_free(e[0],e[1]*1,1),t}ephemeralKey(){const e=n.pkmessage_ephemeralKey(this.__wbg_ptr);return D.__wrap(e)}static fromParts(e,t,r){const s=Y(e,n.__wbindgen_malloc),_=u,o=Y(t,n.__wbindgen_malloc),a=u;b(r,D);const g=n.pkmessage_fromParts(s,_,o,a,r.__wbg_ptr);return Q.__wrap(g)}static fromBase64(e){b(e,Ee);const t=n.pkmessage_fromBase64(e.__wbg_ptr);if(t[2])throw d(t[1]);return Q.__wrap(t[0])}toBase64(){const e=n.pkmessage_toBase64(this.__wbg_ptr);return Ee.__wrap(e)}}const Sr=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_putdehydrateddevicerequest_free(i>>>0,1));class Ge{static __wrap(e){e=e>>>0;const t=Object.create(Ge.prototype);return t.__wbg_ptr=e,Sr.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Sr.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_putdehydrateddevicerequest_free(e,0)}get body(){return n.__wbg_get_putdehydrateddevicerequest_body(this.__wbg_ptr)}constructor(e){const t=n.putdehydrateddevicerequest_new(e);return this.__wbg_ptr=t>>>0,Sr.register(this,this.__wbg_ptr,this),this}}const si=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_qr_free(i>>>0,1));class be{static __wrap(e){e=e>>>0;const t=Object.create(be.prototype);return t.__wbg_ptr=e,si.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,si.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_qr_free(e,0)}state(){return n.qr_state(this.__wbg_ptr)}hasBeenScanned(){return n.qr_hasBeenScanned(this.__wbg_ptr)!==0}hasBeenConfirmed(){return n.qr_hasBeenConfirmed(this.__wbg_ptr)!==0}get userId(){const e=n.qr_userId(this.__wbg_ptr);return f.__wrap(e)}get otherUserId(){const e=n.qr_otherUserId(this.__wbg_ptr);return f.__wrap(e)}get otherDeviceId(){const e=n.qr_otherDeviceId(this.__wbg_ptr);return O.__wrap(e)}weStarted(){return n.qr_weStarted(this.__wbg_ptr)!==0}cancelInfo(){const e=n.qr_cancelInfo(this.__wbg_ptr);return e===0?void 0:le.__wrap(e)}isDone(){return n.qr_isDone(this.__wbg_ptr)!==0}isCancelled(){return n.qr_isCancelled(this.__wbg_ptr)!==0}isSelfVerification(){return n.qr_isSelfVerification(this.__wbg_ptr)!==0}reciprocated(){return n.qr_reciprocated(this.__wbg_ptr)!==0}get flowId(){let e,t;try{const r=n.qr_flowId(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}get roomId(){const e=n.qr_roomId(this.__wbg_ptr);return e===0?void 0:C.__wrap(e)}toQrCode(){const e=n.qr_toQrCode(this.__wbg_ptr);if(e[2])throw d(e[1]);return Tt.__wrap(e[0])}toBytes(){const e=n.qr_toBytes(this.__wbg_ptr);if(e[2])throw d(e[1]);return d(e[0])}reciprocate(){const e=n.qr_reciprocate(this.__wbg_ptr);if(e[2])throw d(e[1]);return d(e[0])}confirmScanning(){const e=n.qr_confirmScanning(this.__wbg_ptr);if(e[2])throw d(e[1]);return d(e[0])}cancel(){const e=n.qr_cancel(this.__wbg_ptr);if(e[2])throw d(e[1]);return d(e[0])}cancelWithCode(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u,s=n.qr_cancelWithCode(this.__wbg_ptr,t,r);if(s[2])throw d(s[1]);return d(s[0])}registerChangesCallback(e){n.qr_registerChangesCallback(this.__wbg_ptr,e)}}const _i=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_qrcode_free(i>>>0,1));class Tt{static __wrap(e){e=e>>>0;const t=Object.create(Tt.prototype);return t.__wbg_ptr=e,_i.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,_i.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_qrcode_free(e,0)}renderIntoBuffer(){const e=n.qrcode_renderIntoBuffer(this.__wbg_ptr);if(e[2])throw d(e[1]);return d(e[0])}}const Rr=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_qrcodedata_free(i>>>0,1));class Je{static __wrap(e){e=e>>>0;const t=Object.create(Je.prototype);return t.__wbg_ptr=e,Rr.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Rr.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_qrcodedata_free(e,0)}constructor(e,t,r){b(e,D);var s=e.__destroy_into_raw();const _=p(t,n.__wbindgen_malloc,n.__wbindgen_realloc),o=u;var a=S(r)?0:p(r,n.__wbindgen_malloc,n.__wbindgen_realloc),g=u;const l=n.qrcodedata_new(s,_,o,a,g);if(l[2])throw d(l[1]);return this.__wbg_ptr=l[0]>>>0,Rr.register(this,this.__wbg_ptr,this),this}static fromBytes(e){const t=Y(e,n.__wbindgen_malloc),r=u,s=n.qrcodedata_fromBytes(t,r);if(s[2])throw d(s[1]);return Je.__wrap(s[0])}toBytes(){const e=n.qrcodedata_toBytes(this.__wbg_ptr);var t=G(e[0],e[1]).slice();return n.__wbindgen_free(e[0],e[1]*1,1),t}static fromBase64(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u,s=n.qrcodedata_fromBase64(t,r);if(s[2])throw d(s[1]);return Je.__wrap(s[0])}toBase64(){let e,t;try{const r=n.qrcodedata_toBase64(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}get publicKey(){const e=n.qrcodedata_publicKey(this.__wbg_ptr);return D.__wrap(e)}get rendezvousUrl(){let e,t;try{const r=n.qrcodedata_rendezvousUrl(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}get serverName(){const e=n.qrcodedata_serverName(this.__wbg_ptr);let t;return e[0]!==0&&(t=w(e[0],e[1]).slice(),n.__wbindgen_free(e[0],e[1]*1,1)),t}get mode(){return n.qrcodedata_mode(this.__wbg_ptr)}}const oi=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_qrcodescan_free(i>>>0,1));class ve{static __wrap(e){e=e>>>0;const t=Object.create(ve.prototype);return t.__wbg_ptr=e,oi.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,oi.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_qrcodescan_free(e,0)}static fromBytes(e){const t=n.qrcodescan_fromBytes(e);if(t[2])throw d(t[1]);return ve.__wrap(t[0])}}const ai=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_rehydrateddevice_free(i>>>0,1));class At{static __wrap(e){e=e>>>0;const t=Object.create(At.prototype);return t.__wbg_ptr=e,ai.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,ai.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_rehydrateddevice_free(e,0)}receiveEvents(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u;return n.rehydrateddevice_receiveEvents(this.__wbg_ptr,t,r)}}const Kr=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_roomid_free(i>>>0,1));class C{static __wrap(e){e=e>>>0;const t=Object.create(C.prototype);return t.__wbg_ptr=e,Kr.register(t,t.__wbg_ptr,t),t}static __unwrap(e){return e instanceof C?e.__destroy_into_raw():0}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Kr.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_roomid_free(e,0)}constructor(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u,s=n.roomid_new(t,r);if(s[2])throw d(s[1]);return this.__wbg_ptr=s[0]>>>0,Kr.register(this,this.__wbg_ptr,this),this}toString(){let e,t;try{const r=n.roomid_toString(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}}const ci=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_roomkeycounts_free(i>>>0,1));class zt{static __wrap(e){e=e>>>0;const t=Object.create(zt.prototype);return t.__wbg_ptr=e,ci.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,ci.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_roomkeycounts_free(e,0)}get total(){return n.__wbg_get_roomkeycounts_total(this.__wbg_ptr)}set total(e){n.__wbg_set_roomkeycounts_total(this.__wbg_ptr,e)}get backedUp(){return n.__wbg_get_roomkeycounts_backedUp(this.__wbg_ptr)}set backedUp(e){n.__wbg_set_roomkeycounts_backedUp(this.__wbg_ptr,e)}}const gi=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_roomkeyimportresult_free(i>>>0,1));class Nt{static __wrap(e){e=e>>>0;const t=Object.create(Nt.prototype);return t.__wbg_ptr=e,gi.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,gi.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_roomkeyimportresult_free(e,0)}get importedCount(){return n.__wbg_get_roomkeyimportresult_importedCount(this.__wbg_ptr)>>>0}get totalCount(){return n.__wbg_get_roomkeyimportresult_totalCount(this.__wbg_ptr)>>>0}keys(){return n.roomkeyimportresult_keys(this.__wbg_ptr)}}const ui=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_roomkeyinfo_free(i>>>0,1));class jt{static __wrap(e){e=e>>>0;const t=Object.create(jt.prototype);return t.__wbg_ptr=e,ui.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,ui.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_roomkeyinfo_free(e,0)}get algorithm(){return n.roomkeyinfo_algorithm(this.__wbg_ptr)}get roomId(){const e=n.roomkeyinfo_roomId(this.__wbg_ptr);return C.__wrap(e)}get senderKey(){const e=n.roomkeyinfo_senderKey(this.__wbg_ptr);return D.__wrap(e)}get sessionId(){let e,t;try{const r=n.roomkeyinfo_sessionId(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}}const di=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_roomkeywithheldinfo_free(i>>>0,1));class xt{static __wrap(e){e=e>>>0;const t=Object.create(xt.prototype);return t.__wbg_ptr=e,di.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,di.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_roomkeywithheldinfo_free(e,0)}get sender(){const e=n.roomkeywithheldinfo_sender(this.__wbg_ptr);return f.__wrap(e)}get algorithm(){return n.roomkeywithheldinfo_algorithm(this.__wbg_ptr)}get withheldCode(){let e,t;try{const r=n.roomkeywithheldinfo_withheldCode(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}get roomId(){const e=n.roomkeywithheldinfo_roomId(this.__wbg_ptr);return C.__wrap(e)}get sessionId(){let e,t;try{const r=n.roomkeywithheldinfo_sessionId(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}}const Ir=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_roommessagerequest_free(i>>>0,1));class Qe{static __wrap(e){e=e>>>0;const t=Object.create(Qe.prototype);return t.__wbg_ptr=e,Ir.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Ir.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_roommessagerequest_free(e,0)}get id(){return n.__wbg_get_roommessagerequest_id(this.__wbg_ptr)}get room_id(){return n.__wbg_get_roommessagerequest_room_id(this.__wbg_ptr)}get txn_id(){return n.__wbg_get_roommessagerequest_txn_id(this.__wbg_ptr)}get event_type(){return n.__wbg_get_roommessagerequest_event_type(this.__wbg_ptr)}get body(){return n.__wbg_get_roommessagerequest_body(this.__wbg_ptr)}constructor(e,t,r,s,_){const o=n.roommessagerequest_new(e,t,r,s,_);return this.__wbg_ptr=o>>>0,Ir.register(this,this.__wbg_ptr,this),this}get type(){return n.roommessagerequest_type(this.__wbg_ptr)}}const Cr=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_roomsettings_free(i>>>0,1));class _e{static __wrap(e){e=e>>>0;const t=Object.create(_e.prototype);return t.__wbg_ptr=e,Cr.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Cr.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_roomsettings_free(e,0)}get algorithm(){return n.__wbg_get_roomsettings_algorithm(this.__wbg_ptr)}set algorithm(e){n.__wbg_set_roomsettings_algorithm(this.__wbg_ptr,e)}get onlyAllowTrustedDevices(){return n.__wbg_get_roomsettings_onlyAllowTrustedDevices(this.__wbg_ptr)!==0}set onlyAllowTrustedDevices(e){n.__wbg_set_roomsettings_onlyAllowTrustedDevices(this.__wbg_ptr,e)}get sessionRotationPeriodMs(){const e=n.__wbg_get_roomsettings_sessionRotationPeriodMs(this.__wbg_ptr);return e[0]===0?void 0:e[1]}set sessionRotationPeriodMs(e){n.__wbg_set_roomsettings_sessionRotationPeriodMs(this.__wbg_ptr,!S(e),S(e)?0:e)}get sessionRotationPeriodMessages(){const e=n.__wbg_get_roomsettings_sessionRotationPeriodMessages(this.__wbg_ptr);return e[0]===0?void 0:e[1]}set sessionRotationPeriodMessages(e){n.__wbg_set_roomsettings_sessionRotationPeriodMessages(this.__wbg_ptr,!S(e),S(e)?0:e)}constructor(){const e=n.roomsettings_new();return this.__wbg_ptr=e>>>0,Cr.register(this,this.__wbg_ptr,this),this}}const li=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_sas_free(i>>>0,1));class he{static __wrap(e){e=e>>>0;const t=Object.create(he.prototype);return t.__wbg_ptr=e,li.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,li.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_sas_free(e,0)}get userId(){const e=n.sas_userId(this.__wbg_ptr);return f.__wrap(e)}get deviceId(){const e=n.sas_deviceId(this.__wbg_ptr);return O.__wrap(e)}get otherUserId(){const e=n.sas_otherUserId(this.__wbg_ptr);return f.__wrap(e)}get otherDeviceId(){const e=n.sas_otherDeviceId(this.__wbg_ptr);return O.__wrap(e)}get flowId(){let e,t;try{const r=n.sas_flowId(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}get roomId(){const e=n.sas_roomId(this.__wbg_ptr);return e===0?void 0:C.__wrap(e)}supportsEmoji(){return n.sas_supportsEmoji(this.__wbg_ptr)!==0}startedFromRequest(){return n.sas_startedFromRequest(this.__wbg_ptr)!==0}isSelfVerification(){return n.sas_isSelfVerification(this.__wbg_ptr)!==0}haveWeConfirmed(){return n.sas_haveWeConfirmed(this.__wbg_ptr)!==0}hasBeenAccepted(){return n.sas_hasBeenAccepted(this.__wbg_ptr)!==0}cancelInfo(){const e=n.sas_cancelInfo(this.__wbg_ptr);return e===0?void 0:le.__wrap(e)}weStarted(){return n.sas_weStarted(this.__wbg_ptr)!==0}accept(){const e=n.sas_accept(this.__wbg_ptr);if(e[2])throw d(e[1]);return d(e[0])}confirm(){return n.sas_confirm(this.__wbg_ptr)}cancel(){const e=n.sas_cancel(this.__wbg_ptr);if(e[2])throw d(e[1]);return d(e[0])}cancelWithCode(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u,s=n.sas_cancelWithCode(this.__wbg_ptr,t,r);if(s[2])throw d(s[1]);return d(s[0])}timedOut(){return n.sas_timedOut(this.__wbg_ptr)!==0}canBePresented(){return n.sas_canBePresented(this.__wbg_ptr)!==0}isDone(){return n.sas_isDone(this.__wbg_ptr)!==0}isCancelled(){return n.sas_isCancelled(this.__wbg_ptr)!==0}emoji(){const e=n.sas_emoji(this.__wbg_ptr);let t;return e[0]!==0&&(t=Ce(e[0],e[1]).slice(),n.__wbindgen_free(e[0],e[1]*4,4)),t}emojiIndex(){const e=n.sas_emojiIndex(this.__wbg_ptr);let t;return e[0]!==0&&(t=G(e[0],e[1]).slice(),n.__wbindgen_free(e[0],e[1]*1,1)),t}decimals(){const e=n.sas_decimals(this.__wbg_ptr);let t;return e[0]!==0&&(t=ss(e[0],e[1]).slice(),n.__wbindgen_free(e[0],e[1]*2,2)),t}registerChangesCallback(e){n.sas_registerChangesCallback(this.__wbg_ptr,e)}}const pi=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_secretsbundle_free(i>>>0,1));class oe{static __wrap(e){e=e>>>0;const t=Object.create(oe.prototype);return t.__wbg_ptr=e,pi.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,pi.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_secretsbundle_free(e,0)}get masterKey(){let e,t;try{const r=n.secretsbundle_masterKey(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}get selfSigningKey(){let e,t;try{const r=n.secretsbundle_selfSigningKey(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}get userSigningKey(){let e,t;try{const r=n.secretsbundle_userSigningKey(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}get backupBundle(){const e=n.secretsbundle_backupBundle(this.__wbg_ptr);return e===0?void 0:mt.__wrap(e)}to_json(){const e=n.secretsbundle_to_json(this.__wbg_ptr);if(e[2])throw d(e[1]);return d(e[0])}static from_json(e){const t=n.secretsbundle_from_json(e);if(t[2])throw d(t[1]);return oe.__wrap(t[0])}}const Or=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_servername_free(i>>>0,1));class He{static __wrap(e){e=e>>>0;const t=Object.create(He.prototype);return t.__wbg_ptr=e,Or.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Or.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_servername_free(e,0)}constructor(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u,s=n.servername_new(t,r);if(s[2])throw d(s[1]);return this.__wbg_ptr=s[0]>>>0,Or.register(this,this.__wbg_ptr,this),this}get host(){let e,t;try{const r=n.servername_host(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}get port(){const e=n.servername_port(this.__wbg_ptr);return e===16777215?void 0:e}isIpLiteral(){return n.servername_isIpLiteral(this.__wbg_ptr)!==0}}const wi=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_shieldstate_free(i>>>0,1));class Ye{static __wrap(e){e=e>>>0;const t=Object.create(Ye.prototype);return t.__wbg_ptr=e,wi.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,wi.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_shieldstate_free(e,0)}get color(){return n.__wbg_get_shieldstate_color(this.__wbg_ptr)}set color(e){n.__wbg_set_shieldstate_color(this.__wbg_ptr,e)}get code(){const e=n.__wbg_get_shieldstate_code(this.__wbg_ptr);return e===6?void 0:e}set code(e){n.__wbg_set_shieldstate_code(this.__wbg_ptr,S(e)?6:e)}get message(){const e=n.shieldstate_message(this.__wbg_ptr);let t;return e[0]!==0&&(t=w(e[0],e[1]).slice(),n.__wbindgen_free(e[0],e[1]*1,1)),t}}const yi=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_signature_free(i>>>0,1));class Lt{static __wrap(e){e=e>>>0;const t=Object.create(Lt.prototype);return t.__wbg_ptr=e,yi.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,yi.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_signature_free(e,0)}get ed25519(){const e=n.signature_ed25519(this.__wbg_ptr);return e===0?void 0:we.__wrap(e)}toBase64(){let e,t;try{const r=n.signature_toBase64(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}}const Mr=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_signatureuploadrequest_free(i>>>0,1));class fe{static __wrap(e){e=e>>>0;const t=Object.create(fe.prototype);return t.__wbg_ptr=e,Mr.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Mr.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_signatureuploadrequest_free(e,0)}get id(){return n.__wbg_get_signatureuploadrequest_id(this.__wbg_ptr)}get body(){return n.__wbg_get_signatureuploadrequest_body(this.__wbg_ptr)}constructor(e,t){const r=n.signatureuploadrequest_new(e,t);return this.__wbg_ptr=r>>>0,Mr.register(this,this.__wbg_ptr,this),this}get type(){return n.signatureuploadrequest_type(this.__wbg_ptr)}}const bi=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_signatureverification_free(i>>>0,1));class Wt{static __wrap(e){e=e>>>0;const t=Object.create(Wt.prototype);return t.__wbg_ptr=e,bi.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,bi.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_signatureverification_free(e,0)}get deviceState(){return n.signatureverification_deviceState(this.__wbg_ptr)}get userState(){return n.signatureverification_userState(this.__wbg_ptr)}trusted(){return n.signatureverification_trusted(this.__wbg_ptr)!==0}}const qr=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_signatures_free(i>>>0,1));class $e{static __wrap(e){e=e>>>0;const t=Object.create($e.prototype);return t.__wbg_ptr=e,qr.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,qr.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_signatures_free(e,0)}constructor(){const e=n.signatures_new();return this.__wbg_ptr=e>>>0,qr.register(this,this.__wbg_ptr,this),this}addSignature(e,t,r){b(e,f),b(t,pe),b(r,we);const s=n.signatures_addSignature(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,r.__wbg_ptr);return s===0?void 0:Ae.__wrap(s)}getSignature(e,t){b(e,f),b(t,pe);const r=n.signatures_getSignature(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr);return r===0?void 0:we.__wrap(r)}get(e){return b(e,f),n.signatures_get(this.__wbg_ptr,e.__wbg_ptr)}clear(){n.signatures_clear(this.__wbg_ptr)}isEmpty(){return n.signatures_isEmpty(this.__wbg_ptr)!==0}get count(){return n.signatures_count(this.__wbg_ptr)>>>0}asJSON(){const e=n.signatures_asJSON(this.__wbg_ptr);if(e[2])throw d(e[1]);return d(e[0])}}const hi=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_storehandle_free(i>>>0,1));class x{static __wrap(e){e=e>>>0;const t=Object.create(x.prototype);return t.__wbg_ptr=e,hi.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,hi.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_storehandle_free(e,0)}static open(e,t){var r=S(e)?0:p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),s=u,_=S(t)?0:p(t,n.__wbindgen_malloc,n.__wbindgen_realloc),o=u;return n.storehandle_open(r,s,_,o)}static openWithKey(e,t){const r=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),s=u,_=Y(t,n.__wbindgen_malloc),o=u;return n.storehandle_openWithKey(r,s,_,o)}}const Dr=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_todevicerequest_free(i>>>0,1));class Ze{static __wrap(e){e=e>>>0;const t=Object.create(Ze.prototype);return t.__wbg_ptr=e,Dr.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Dr.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_todevicerequest_free(e,0)}get id(){return n.__wbg_get_todevicerequest_id(this.__wbg_ptr)}get event_type(){return n.__wbg_get_todevicerequest_event_type(this.__wbg_ptr)}get txn_id(){return n.__wbg_get_todevicerequest_txn_id(this.__wbg_ptr)}get body(){return n.__wbg_get_todevicerequest_body(this.__wbg_ptr)}constructor(e,t,r,s){const _=n.todevicerequest_new(e,t,r,s);return this.__wbg_ptr=_>>>0,Dr.register(this,this.__wbg_ptr,this),this}get type(){return n.todevicerequest_type(this.__wbg_ptr)}}const fi=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_tracing_free(i>>>0,1));class Er{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,fi.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_tracing_free(e,0)}static isAvailable(){return n.tracing_isAvailable()!==0}constructor(e){const t=n.tracing_new(e);if(t[2])throw d(t[1]);return this.__wbg_ptr=t[0]>>>0,fi.register(this,this.__wbg_ptr,this),this}set minLevel(e){const t=n.tracing_set_minLevel(this.__wbg_ptr,e);if(t[1])throw d(t[0])}turnOn(){const e=n.tracing_turnOn(this.__wbg_ptr);if(e[1])throw d(e[0])}turnOff(){const e=n.tracing_turnOff(this.__wbg_ptr);if(e[1])throw d(e[0])}}const Br=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_uploadsigningkeysrequest_free(i>>>0,1));class Xe{static __wrap(e){e=e>>>0;const t=Object.create(Xe.prototype);return t.__wbg_ptr=e,Br.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Br.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_uploadsigningkeysrequest_free(e,0)}get body(){return n.__wbg_get_uploadsigningkeysrequest_body(this.__wbg_ptr)}constructor(e){const t=n.uploadsigningkeysrequest_new(e);return this.__wbg_ptr=t>>>0,Br.register(this,this.__wbg_ptr,this),this}}const mi=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_userdevices_free(i>>>0,1));class Gt{static __wrap(e){e=e>>>0;const t=Object.create(Gt.prototype);return t.__wbg_ptr=e,mi.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,mi.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_userdevices_free(e,0)}get(e){b(e,O);const t=n.userdevices_get(this.__wbg_ptr,e.__wbg_ptr);return t===0?void 0:Be.__wrap(t)}isAnyVerified(){return n.userdevices_isAnyVerified(this.__wbg_ptr)!==0}keys(){return n.userdevices_keys(this.__wbg_ptr)}devices(){return n.userdevices_devices(this.__wbg_ptr)}}const Ur=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_userid_free(i>>>0,1));class f{static __wrap(e){e=e>>>0;const t=Object.create(f.prototype);return t.__wbg_ptr=e,Ur.register(t,t.__wbg_ptr,t),t}static __unwrap(e){return e instanceof f?e.__destroy_into_raw():0}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Ur.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_userid_free(e,0)}constructor(e){const t=p(e,n.__wbindgen_malloc,n.__wbindgen_realloc),r=u,s=n.userid_new(t,r);if(s[2])throw d(s[1]);return this.__wbg_ptr=s[0]>>>0,Ur.register(this,this.__wbg_ptr,this),this}get localpart(){let e,t;try{const r=n.userid_localpart(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}get serverName(){const e=n.userid_serverName(this.__wbg_ptr);return He.__wrap(e)}isHistorical(){return n.userid_isHistorical(this.__wbg_ptr)!==0}toString(){let e,t;try{const r=n.userid_toString(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}clone(){const e=n.userid_clone(this.__wbg_ptr);return f.__wrap(e)}}const vi=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_verificationrequest_free(i>>>0,1));class me{static __wrap(e){e=e>>>0;const t=Object.create(me.prototype);return t.__wbg_ptr=e,vi.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,vi.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_verificationrequest_free(e,0)}static request(e,t,r,s){let _,o;try{b(e,f),b(t,O),b(r,f);var a=S(s)?0:F(s,n.__wbindgen_malloc),g=u;const h=n.verificationrequest_request(e.__wbg_ptr,t.__wbg_ptr,r.__wbg_ptr,a,g);var l=h[0],y=h[1];if(h[3])throw l=0,y=0,d(h[2]);return _=l,o=y,w(l,y)}finally{n.__wbindgen_free(_,o,1)}}get ownUserId(){const e=n.verificationrequest_ownUserId(this.__wbg_ptr);return f.__wrap(e)}get otherUserId(){const e=n.verificationrequest_otherUserId(this.__wbg_ptr);return f.__wrap(e)}get otherDeviceId(){const e=n.verificationrequest_otherDeviceId(this.__wbg_ptr);return e===0?void 0:O.__wrap(e)}get roomId(){const e=n.verificationrequest_roomId(this.__wbg_ptr);return e===0?void 0:C.__wrap(e)}get cancelInfo(){const e=n.verificationrequest_cancelInfo(this.__wbg_ptr);return e===0?void 0:le.__wrap(e)}isPassive(){return n.verificationrequest_isPassive(this.__wbg_ptr)!==0}isReady(){return n.verificationrequest_isReady(this.__wbg_ptr)!==0}timedOut(){return n.verificationrequest_timedOut(this.__wbg_ptr)!==0}timeRemainingMillis(){return n.verificationrequest_timeRemainingMillis(this.__wbg_ptr)}get theirSupportedMethods(){const e=n.verificationrequest_theirSupportedMethods(this.__wbg_ptr);if(e[3])throw d(e[2]);let t;return e[0]!==0&&(t=Ce(e[0],e[1]).slice(),n.__wbindgen_free(e[0],e[1]*4,4)),t}get ourSupportedMethods(){const e=n.verificationrequest_ourSupportedMethods(this.__wbg_ptr);if(e[3])throw d(e[2]);let t;return e[0]!==0&&(t=Ce(e[0],e[1]).slice(),n.__wbindgen_free(e[0],e[1]*4,4)),t}get flowId(){let e,t;try{const r=n.verificationrequest_flowId(this.__wbg_ptr);return e=r[0],t=r[1],w(r[0],r[1])}finally{n.__wbindgen_free(e,t,1)}}isSelfVerification(){return n.verificationrequest_isSelfVerification(this.__wbg_ptr)!==0}weStarted(){return n.verificationrequest_weStarted(this.__wbg_ptr)!==0}isDone(){return n.verificationrequest_isDone(this.__wbg_ptr)!==0}phase(){return n.verificationrequest_phase(this.__wbg_ptr)}getVerification(){return n.verificationrequest_getVerification(this.__wbg_ptr)}registerChangesCallback(e){n.verificationrequest_registerChangesCallback(this.__wbg_ptr,e)}isCancelled(){return n.verificationrequest_isCancelled(this.__wbg_ptr)!==0}acceptWithMethods(e){const t=F(e,n.__wbindgen_malloc),r=u,s=n.verificationrequest_acceptWithMethods(this.__wbg_ptr,t,r);if(s[2])throw d(s[1]);return d(s[0])}accept(){const e=n.verificationrequest_accept(this.__wbg_ptr);if(e[2])throw d(e[1]);return d(e[0])}cancel(){const e=n.verificationrequest_cancel(this.__wbg_ptr);if(e[2])throw d(e[1]);return d(e[0])}startSas(){return n.verificationrequest_startSas(this.__wbg_ptr)}generateQrCode(){return n.verificationrequest_generateQrCode(this.__wbg_ptr)}scanQrCode(e){return b(e,ve),n.verificationrequest_scanQrCode(this.__wbg_ptr,e.__wbg_ptr)}}const ki=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_versions_free(i>>>0,1));class Jt{static __wrap(e){e=e>>>0;const t=Object.create(Jt.prototype);return t.__wbg_ptr=e,ki.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,ki.unregister(this),e}free(){const e=this.__destroy_into_raw();n.__wbg_versions_free(e,0)}get vodozemac(){return n.__wbg_get_versions_vodozemac(this.__wbg_ptr)}get matrix_sdk_crypto(){return n.__wbg_get_versions_matrix_sdk_crypto(this.__wbg_ptr)}get git_sha(){return n.__wbg_get_versions_git_sha(this.__wbg_ptr)}get git_description(){return n.__wbg_get_versions_git_description(this.__wbg_ptr)}}function Ss(i,e){const t=String(e),r=p(t,n.__wbindgen_malloc,n.__wbindgen_realloc),s=u;q().setInt32(i+4*1,s,!0),q().setInt32(i+4*0,r,!0)}function Rs(i){return i.Window}function Ks(i){return i.WorkerGlobalScope}function Is(i,e){return i.add(e)}function Cs(){return R(function(i,e,t){return i.add(e,t)},arguments)}function Os(i,e){return i.at(e)}function Ms(i){return ft.__wrap(i)}function qs(){return R(function(i,e){return IDBKeyRange.bound(i,e)},arguments)}function Ds(){return R(function(i,e,t,r){return IDBKeyRange.bound(i,e,t!==0,r!==0)},arguments)}function Es(i){return i.buffer}function Bs(){return R(function(i,e){return i.call(e)},arguments)}function Us(){return R(function(i,e,t){return i.call(e,t)},arguments)}function Fs(){return R(function(i,e,t,r){return i.call(e,t,r)},arguments)}function Vs(){return R(function(i,e,t,r,s){return i.call(e,t,r,s)},arguments)}function Ps(i){return clearTimeout(i)}function Ts(){return R(function(i){return i.clear()},arguments)}function As(i){i.close()}function zs(i){return i.code}function Ns(){return R(function(i){i.continue()},arguments)}function js(){return R(function(i){return i.count()},arguments)}function xs(){return R(function(i){return i.count()},arguments)}function Ls(){return R(function(i,e,t,r,s){return i.createIndex(w(e,t),r,s)},arguments)}function Ws(){return R(function(i,e,t,r){return i.createIndex(w(e,t),r)},arguments)}function Gs(){return R(function(i,e,t){return i.createObjectStore(w(e,t))},arguments)}function Js(i){return kt.__wrap(i)}function Qs(i){return St.__wrap(i)}function Hs(i){return Rt.__wrap(i)}function Ys(i){return i.crypto}function $s(i){console.debug(i)}function Zs(i,e){i.debug(e)}function Xs(i){return Kt.__wrap(i)}function e_(i){return It.__wrap(i)}function t_(i){return L.__wrap(i)}function r_(){return R(function(i,e,t){i.deleteObjectStore(w(e,t))},arguments)}function n_(){return R(function(i,e){return i.delete(e)},arguments)}function i_(){return R(function(i){return i.delete()},arguments)}function s_(i){return Be.__wrap(i)}function __(i){return O.__wrap(i)}function o_(i){return Ue.__wrap(i)}function a_(i){return pe.__wrap(i)}function c_(i){return i.done}function g_(i){return Mt.__wrap(i)}function u_(i){return qt.__wrap(i)}function d_(i){return Object.entries(i)}function l_(i){return i.entries()}function p_(i){console.error(i)}function w_(i,e){let t,r;try{t=i,r=e,console.error(w(i,e))}finally{n.__wbindgen_free(t,r,1)}}function y_(i,e){i.error(e)}function b_(){return R(function(i){const e=i.error;return S(e)?0:U(e)},arguments)}function h_(i){return Array.from(i)}function f_(){return R(function(i){return i.getAllKeys()},arguments)}function m_(){return R(function(i){return i.getAll()},arguments)}function v_(){return R(function(i,e,t){return i.getAll(e,t>>>0)},arguments)}function k_(){return R(function(i,e){return i.getAll(e)},arguments)}function S_(){return R(function(i,e){globalThis.crypto.getRandomValues(G(i,e))},arguments)}function R_(){return R(function(i,e){i.getRandomValues(e)},arguments)}function K_(i){return i.getTime()}function I_(){return R(function(i,e){return Reflect.get(i,e)},arguments)}function C_(){return R(function(i,e){return i.get(e)},arguments)}function O_(){return R(function(i,e){return i.get(e)},arguments)}function M_(i,e){return i[e>>>0]}function q_(i,e){return i[e]}function D_(i){return i.global}function E_(i){return Bt.__wrap(i)}function B_(){return R(function(i,e,t){return i.index(w(e,t))},arguments)}function U_(){return R(function(i){const e=i.indexedDB;return S(e)?0:U(e)},arguments)}function F_(){return R(function(i){const e=i.indexedDB;return S(e)?0:U(e)},arguments)}function V_(){return R(function(i){const e=i.indexedDB;return S(e)?0:U(e)},arguments)}function P_(i,e){i.info(e)}function T_(i){console.info(i)}function A_(i){let e;try{e=i instanceof ArrayBuffer}catch{e=!1}return e}function z_(i){let e;try{e=i instanceof Map}catch{e=!1}return e}function N_(i){let e;try{e=i instanceof Promise}catch{e=!1}return e}function j_(i){let e;try{e=i instanceof Uint8Array}catch{e=!1}return e}function x_(i){return Array.isArray(i)}function L_(i){return Number.isSafeInteger(i)}function W_(i,e,t){const r=e.item(t>>>0);var s=S(r)?0:p(r,n.__wbindgen_malloc,n.__wbindgen_realloc),_=u;q().setInt32(i+4*1,_,!0),q().setInt32(i+4*0,s,!0)}function G_(){return Symbol.iterator}function J_(){return R(function(i){return i.key},arguments)}function Q_(i){return Ve.__wrap(i)}function H_(i){return Pe.__wrap(i)}function Y_(i){return ye.__wrap(i)}function $_(i){return Te.__wrap(i)}function Z_(i){return i.length}function X_(i){return i.length}function eo(i){return i.length}function to(){return R(function(i,e){return IDBKeyRange.lowerBound(i,e!==0)},arguments)}function ro(i){return Ae.__wrap(i)}function no(i){return ze.__wrap(i)}function io(i,e){const t=e.message,r=p(t,n.__wbindgen_malloc,n.__wbindgen_realloc),s=u;q().setInt32(i+4*1,s,!0),q().setInt32(i+4*0,r,!0)}function so(i){return i.msCrypto}function _o(i,e){const t=e.name,r=p(t,n.__wbindgen_malloc,n.__wbindgen_realloc),s=u;q().setInt32(i+4*1,s,!0),q().setInt32(i+4*0,r,!0)}function oo(i,e){try{var t={a:i,b:e},r=(s,_)=>{const o=t.a;t.a=0;try{return ds(o,t.b,s,_)}finally{t.a=o}};return new Promise(r)}finally{t.a=t.b=0}}function ao(i){return new Date(i)}function co(){return new Object}function go(){return new Map}function uo(){return new Array}function lo(i){return new Uint8ClampedArray(i)}function po(){return new Error}function wo(i){return new Uint8Array(i)}function yo(i){return new Set(i)}function bo(i,e){return new Function(w(i,e))}function ho(i,e,t){return new Uint8ClampedArray(i,e>>>0,t>>>0)}function fo(i,e,t){return new Uint8Array(i,e>>>0,t>>>0)}function mo(i){return new Uint8Array(i>>>0)}function vo(i){return new Uint8ClampedArray(i>>>0)}function ko(){return R(function(i,e){return new DOMException(w(i,e))},arguments)}function So(i){return i.next}function Ro(){return R(function(i){return i.next()},arguments)}function Ko(i){return i.node}function Io(i){return i.now()}function Co(){return Date.now()}function Oo(i){return i.objectStoreNames}function Mo(){return R(function(i,e,t){return i.objectStore(w(e,t))},arguments)}function qo(i){return i.oldVersion}function Do(i){return Ne.__wrap(i)}function Eo(){return R(function(i){return i.openCursor()},arguments)}function Bo(){return R(function(i){return i.openCursor()},arguments)}function Uo(){return R(function(i,e){return i.openCursor(e)},arguments)}function Fo(){return R(function(i,e,t){return i.open(w(e,t))},arguments)}function Vo(){return R(function(i,e,t,r){return i.open(w(e,t),r>>>0)},arguments)}function Po(i){return je.__wrap(i)}function To(i){return xe.__wrap(i)}function Ao(){return R(function(i,e){return JSON.parse(w(i,e))},arguments)}function zo(i){return i.performance}function No(i){return Le.__unwrap(i)}function jo(i){return We.__unwrap(i)}function xo(i){return i.process}function Lo(i,e){return i.push(e)}function Wo(){return R(function(i,e,t){return i.put(e,t)},arguments)}function Go(i){return Ge.__wrap(i)}function Jo(i){return be.__wrap(i)}function Qo(i){queueMicrotask(i)}function Ho(i){return i.queueMicrotask}function Yo(){return R(function(i,e){i.randomFillSync(e)},arguments)}function $o(i){const e=i.readyState;return(hs.indexOf(e)+1||3)-1}function Zo(i){return At.__wrap(i)}function Xo(){return R(function(){return module.require},arguments)}function ea(i){return Promise.resolve(i)}function ta(){return R(function(i){return i.result},arguments)}function ra(i){return C.__unwrap(i)}function na(i){return zt.__wrap(i)}function ia(i){return Nt.__wrap(i)}function sa(i){return jt.__wrap(i)}function _a(i){return xt.__wrap(i)}function oa(i){return Qe.__wrap(i)}function aa(i){return _e.__wrap(i)}function ca(i){return he.__wrap(i)}function ga(i){return oe.__wrap(i)}function ua(){return R(function(i,e){return setTimeout(i,e)},arguments)}function da(i,e,t){i[e>>>0]=t}function la(i,e,t){i[e]=t}function pa(i,e,t){i.set(e,t>>>0)}function wa(i,e,t){i.set(e,t>>>0)}function ya(i,e,t){return i.set(e,t)}function ba(i,e){i.onabort=e}function ha(i,e){i.onblocked=e}function fa(i,e){i.oncomplete=e}function ma(i,e){i.onerror=e}function va(i,e){i.onerror=e}function ka(i,e){i.onsuccess=e}function Sa(i,e){i.onupgradeneeded=e}function Ra(i,e){i.onversionchange=e}function Ka(i,e){i.unique=e!==0}function Ia(i){return $e.__wrap(i)}function Ca(i){return fe.__wrap(i)}function Oa(i){return Wt.__wrap(i)}function Ma(i,e){const t=e.stack,r=p(t,n.__wbindgen_malloc,n.__wbindgen_realloc),s=u;q().setInt32(i+4*1,s,!0),q().setInt32(i+4*0,r,!0)}function qa(){const i=typeof global>"u"?null:global;return S(i)?0:U(i)}function Da(){const i=typeof globalThis>"u"?null:globalThis;return S(i)?0:U(i)}function Ea(){const i=typeof self>"u"?null:self;return S(i)?0:U(i)}function Ba(){const i=typeof window>"u"?null:window;return S(i)?0:U(i)}function Ua(i){return x.__wrap(i)}function Fa(){return R(function(i){return JSON.stringify(i)},arguments)}function Va(i,e,t){return i.subarray(e>>>0,t>>>0)}function Pa(i){const e=i.target;return S(e)?0:U(e)}function Ta(i,e){return i.then(e)}function Aa(i,e,t){return i.then(e,t)}function za(i){return Ze.__wrap(i)}function Na(){return R(function(i,e,t,r){return i.transaction(w(e,t),hn[r])},arguments)}function ja(){return R(function(i,e,t){return i.transaction(e,hn[t])},arguments)}function xa(i){const e=i.transaction;return S(e)?0:U(e)}function La(){return R(function(i,e){return i.update(e)},arguments)}function Wa(i){return Gt.__wrap(i)}function Ga(i){return f.__wrap(i)}function Ja(i){return f.__unwrap(i)}function Qa(){return R(function(i){return i.value},arguments)}function Ha(i){return i.value}function Ya(i){return i.values()}function $a(i){return me.__wrap(i)}function Za(i){return i.version}function Xa(i){return i.versions}function ec(i){console.warn(i)}function tc(i,e){i.warn(e)}function rc(i){return+i}function nc(i){return i}function ic(i){return BigInt.asUintN(64,i)}function sc(i,e){const t=e,r=typeof t=="bigint"?t:void 0;q().setBigInt64(i+8*1,S(r)?BigInt(0):r,!0),q().setInt32(i+4*0,!S(r),!0)}function _c(i){const e=i;return typeof e=="boolean"?e?1:0:2}function oc(i){const e=i.original;return e.cnt--==1?(e.a=0,!0):!1}function ac(i,e,t){return tr(i,e,30,os)}function cc(i,e,t){return tr(i,e,401,as)}function gc(i,e,t){return tr(i,e,401,cs)}function uc(i,e,t){return yn(i,e,407,gs)}function dc(i,e,t){return yn(i,e,407,us)}function lc(i,e){const t=rr(e),r=p(t,n.__wbindgen_malloc,n.__wbindgen_realloc),s=u;q().setInt32(i+4*1,s,!0),q().setInt32(i+4*0,r,!0)}function pc(i,e){return new Error(w(i,e))}function wc(i,e){return i in e}function yc(){const i=n.__wbindgen_export_4,e=i.grow(4);i.set(0,void 0),i.set(e+0,void 0),i.set(e+1,null),i.set(e+2,!0),i.set(e+3,!1)}function bc(i){return Array.isArray(i)}function hc(i){return typeof i=="bigint"}function fc(i){return typeof i=="function"}function mc(i){return i===null}function vc(i){const e=i;return typeof e=="object"&&e!==null}function kc(i){return typeof i=="string"}function Sc(i){return i===void 0}function Rc(i,e){return i===e}function Kc(i,e){return i==e}function Ic(){return n.memory}function Cc(i,e){const t=e,r=typeof t=="number"?t:void 0;q().setFloat64(i+8*1,S(r)?0:r,!0),q().setInt32(i+4*0,!S(r),!0)}function Oc(i){return i}function Mc(i,e){const t=e,r=typeof t=="string"?t:void 0;var s=S(r)?0:p(r,n.__wbindgen_malloc,n.__wbindgen_realloc),_=u;q().setInt32(i+4*1,_,!0),q().setInt32(i+4*0,s,!0)}function qc(i,e){return w(i,e)}function Dc(i,e){throw new Error(w(i,e))}function Ec(i){let e;try{e=+i}catch(t){e=t}return e}const Bc=Object.freeze(Object.defineProperty({__proto__:null,Attachment:ms,BackupDecryptionKey:V,BackupKeys:ft,BackupSecretsBundle:mt,Base64EncodedPkMessage:Ee,BaseMigrationData:ar,CancelInfo:le,CheckCode:vt,CollectStrategy:T,CrossSigningBootstrapRequests:kt,CrossSigningKeyExport:St,CrossSigningStatus:Rt,Curve25519PublicKey:D,Curve25519SecretKey:ee,DecryptedRoomEvent:Kt,DecryptionErrorCode:$,DecryptionSettings:gr,DehydratedDevice:It,DehydratedDeviceKey:L,DehydratedDevices:Ct,Device:Be,DeviceId:O,DeviceKey:Ue,DeviceKeyAlgorithm:Ot,DeviceKeyAlgorithmName:ls,DeviceKeyId:pe,DeviceKeyName:ps,DeviceLists:lt,Ecies:vs,Ed25519PublicKey:ie,Ed25519Signature:we,Emoji:Mt,EncryptedAttachment:Fe,EncryptionAlgorithm:ue,EncryptionInfo:qt,EncryptionSettings:wr,EstablishedEcies:se,EventId:yr,HistoryVisibility:Oe,IdentityKeys:Dt,InboundCreationResult:Et,InboundGroupSession:Bt,KeysBackupRequest:Ve,KeysClaimRequest:Pe,KeysQueryRequest:ye,KeysUploadRequest:Te,LocalTrust:nr,LoggerLevel:ir,MaybeSignature:Ae,MegolmDecryptionError:ze,MegolmV1BackupKey:Ut,Migration:pt,OlmMachine:Ne,OtherUserIdentity:je,OutboundCreationResult:Ft,OwnUserIdentity:xe,PickledInboundGroupSession:Le,PickledSession:We,PkDecryption:Vt,PkEncryption:Pt,PkMessage:Q,PutDehydratedDeviceRequest:Ge,Qr:be,QrCode:Tt,QrCodeData:Je,QrCodeMode:ws,QrCodeScan:ve,QrState:re,RehydratedDevice:At,RequestType:ys,RoomId:C,RoomKeyCounts:zt,RoomKeyImportResult:Nt,RoomKeyInfo:jt,RoomKeyWithheldInfo:xt,RoomMessageRequest:Qe,RoomSettings:_e,Sas:he,SecretsBundle:oe,ServerName:He,ShieldColor:sr,ShieldState:Ye,ShieldStateCode:ne,Signature:Lt,SignatureState:bs,SignatureUploadRequest:fe,SignatureVerification:Wt,Signatures:$e,StoreHandle:x,ToDeviceRequest:Ze,Tracing:Er,TrustRequirement:_r,UploadSigningKeysRequest:Xe,UserDevices:Gt,UserId:f,VerificationMethod:Me,VerificationRequest:me,VerificationRequestPhase:Z,Versions:Jt,__wbg_String_8f0eb39a4a4c2f66:Ss,__wbg_Window_b0044ac7db258535:Rs,__wbg_WorkerGlobalScope_b74cefefc62a37da:Ks,__wbg_add_883d9432f9188ef2:Is,__wbg_add_9338901b80183e0f:Cs,__wbg_at_7d852dd9f194d43e:Os,__wbg_backupkeys_new:Ms,__wbg_bound_55a8d08e0491e17a:qs,__wbg_bound_f2afc3766d4545cf:Ds,__wbg_buffer_609cc3eee51ed158:Es,__wbg_call_672a4d21634d4a24:Bs,__wbg_call_7cccdd69e0791ae2:Us,__wbg_call_833bed5770ea2041:Fs,__wbg_call_b8adc8b1d0a0d8eb:Vs,__wbg_clearTimeout_5a54f8841c30079a:Ps,__wbg_clear_f450db7eeb71163f:Ts,__wbg_close_26fc2e6856d8567a:As,__wbg_code_cfd8f6868bdaed9b:zs,__wbg_continue_c46c11d3dbe1b030:Ns,__wbg_count_613cb921d67a4f26:js,__wbg_count_ea1a2987dff7759e:xs,__wbg_createIndex_873ac48adc772309:Ls,__wbg_createIndex_fcfd513cf4581834:Ws,__wbg_createObjectStore_e566459f7161f82f:Gs,__wbg_crosssigningbootstraprequests_new:Js,__wbg_crosssigningkeyexport_new:Qs,__wbg_crosssigningstatus_new:Hs,__wbg_crypto_ed58b8e10a292839:Ys,__wbg_debug_3cb59063b29f58c1:$s,__wbg_debug_f41e47509e8e4e36:Zs,__wbg_decryptedroomevent_new:Xs,__wbg_dehydrateddevice_new:e_,__wbg_dehydrateddevicekey_new:t_,__wbg_deleteObjectStore_3f08ae00cd288224:r_,__wbg_delete_200677093b4cf756:n_,__wbg_delete_2ecf7cf20900b3a2:i_,__wbg_device_new:s_,__wbg_deviceid_new:__,__wbg_devicekey_new:o_,__wbg_devicekeyid_new:a_,__wbg_done_769e5ede4b31c67b:c_,__wbg_emoji_new:g_,__wbg_encryptioninfo_new:u_,__wbg_entries_3265d4158b33e5dc:d_,__wbg_entries_c8a90a7ed73e84ce:l_,__wbg_error_524f506f44df1645:p_,__wbg_error_7534b8e9a36f1ab4:w_,__wbg_error_76286673af64a31f:y_,__wbg_error_ff4ddaabdfc5dbb3:b_,__wbg_from_2a5d3e218e67aa85:h_,__wbg_getAllKeys_b11d8835dc4be0e8:f_,__wbg_getAll_304e868beec2021f:m_,__wbg_getAll_d1e60c13c0073374:v_,__wbg_getAll_e6903c610babcd42:k_,__wbg_getRandomValues_3d90134a348e46b3:S_,__wbg_getRandomValues_bcb4912f16000dc4:R_,__wbg_getTime_46267b1c24877e30:K_,__wbg_get_67b2ba62fc30de12:I_,__wbg_get_8da03f81f6a1111e:C_,__wbg_get_93e54e8e166fbcab:O_,__wbg_get_b9b93047fe3cf45b:M_,__wbg_getwithrefkey_1dc361bd10053bfe:q_,__wbg_global_b6f5c73312f62313:D_,__wbg_inboundgroupsession_new:E_,__wbg_index_e00ca5fff206ee3e:B_,__wbg_indexedDB_601ec26c63e333de:U_,__wbg_indexedDB_b1f49280282046f8:F_,__wbg_indexedDB_f6b47b0dc333fd2f:V_,__wbg_info_3b4be85e0a44d2af:P_,__wbg_info_3daf2e093e091b66:T_,__wbg_instanceof_ArrayBuffer_e14585432e3737fc:A_,__wbg_instanceof_Map_f3469ce2244d2430:z_,__wbg_instanceof_Promise_935168b8f4b49db3:N_,__wbg_instanceof_Uint8Array_17156bcf118086a9:j_,__wbg_isArray_a1eab7e0d067391b:x_,__wbg_isSafeInteger_343e2beeeece1bb0:L_,__wbg_item_c3c26b4103ad5aaf:W_,__wbg_iterator_9a24c88df860dc65:G_,__wbg_key_29fefecef430db96:J_,__wbg_keysbackuprequest_new:Q_,__wbg_keysclaimrequest_new:H_,__wbg_keysqueryrequest_new:Y_,__wbg_keysuploadrequest_new:$_,__wbg_length_238152a0aedbb6e7:Z_,__wbg_length_a446193dc22c12f8:X_,__wbg_length_e2d2a49132c1b256:eo,__wbg_lowerBound_1872d19f5bcf83c6:to,__wbg_maybesignature_new:ro,__wbg_megolmdecryptionerror_new:no,__wbg_message_5c5d919204d42400:io,__wbg_msCrypto_0a36e2ec3a343d26:so,__wbg_name_f2d27098bfd843e7:_o,__wbg_new_23a2665fac83c611:oo,__wbg_new_31a97dac4f10fab7:ao,__wbg_new_405e22f390576ce2:co,__wbg_new_5e0be73521bc8c17:go,__wbg_new_78feb108b6472713:uo,__wbg_new_7a91e41fe43b3c92:lo,__wbg_new_8a6f238a6ece86ea:po,__wbg_new_a12002a7f91c75be:wo,__wbg_new_a239edaa1dc2968f:yo,__wbg_newnoargs_105ed471475aaf50:bo,__wbg_newwithbyteoffsetandlength_6d34787141015158:ho,__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a:fo,__wbg_newwithlength_a381634e90c276d4:mo,__wbg_newwithlength_ee8e1b95dea9d37c:vo,__wbg_newwithmessage_baedba94f03976fd:ko,__wbg_next_25feadfc0913fea9:So,__wbg_next_6574e1a8a62d1055:Ro,__wbg_node_02999533c4ea02e3:Ko,__wbg_now_2c95c9de01293173:Io,__wbg_now_807e54c39636c349:Co,__wbg_objectStoreNames_9bb1ab04a7012aaf:Oo,__wbg_objectStore_21878d46d25b64b6:Mo,__wbg_oldVersion_e8337811e52861c6:qo,__wbg_olmmachine_new:Do,__wbg_openCursor_1adef2266972fb45:Eo,__wbg_openCursor_238e247d18bde2cd:Bo,__wbg_openCursor_f4b061aa6d804b93:Uo,__wbg_open_88b1390d99a7c691:Fo,__wbg_open_e0c0b2993eb596e1:Vo,__wbg_otheruseridentity_new:Po,__wbg_ownuseridentity_new:To,__wbg_parse_def2e24ef1252aff:Ao,__wbg_performance_7a3ffd0b17f663ad:zo,__wbg_pickledinboundgroupsession_unwrap:No,__wbg_pickledsession_unwrap:jo,__wbg_process_5c1d670bc53614b8:xo,__wbg_push_737cfc8c1432c2c6:Lo,__wbg_put_066faa31a6a88f5b:Wo,__wbg_putdehydrateddevicerequest_new:Go,__wbg_qr_new:Jo,__wbg_queueMicrotask_97d92b4fcc8a61c5:Qo,__wbg_queueMicrotask_d3219def82552485:Ho,__wbg_randomFillSync_ab2cfe79ebbf2740:Yo,__wbg_readyState_4013cfdf4f22afb0:$o,__wbg_rehydrateddevice_new:Zo,__wbg_require_79b1e9274cde3c87:Xo,__wbg_resolve_4851785c9c5f573d:ea,__wbg_result_f29afabdf2c05826:ta,__wbg_roomid_unwrap:ra,__wbg_roomkeycounts_new:na,__wbg_roomkeyimportresult_new:ia,__wbg_roomkeyinfo_new:sa,__wbg_roomkeywithheldinfo_new:_a,__wbg_roommessagerequest_new:oa,__wbg_roomsettings_new:aa,__wbg_sas_new:ca,__wbg_secretsbundle_new:ga,__wbg_setTimeout_db2dbaeefb6f39c7:ua,__wbg_set_37837023f3d740e8:da,__wbg_set_3f1d0b984ed272ed:la,__wbg_set_65595bdd868b3009:pa,__wbg_set_6775f73144c2ef27:wa,__wbg_set_8fc6bf8a5b1071d1:ya,__wbg_set_wasm:er,__wbg_setonabort_3bf4db6614fa98e9:ba,__wbg_setonblocked_aebf64bd39f1eca8:ha,__wbg_setoncomplete_4d19df0dadb7c4d4:fa,__wbg_setonerror_b0d9d723b8fddbbb:ma,__wbg_setonerror_d7e3056cc6e56085:va,__wbg_setonsuccess_afa464ee777a396d:ka,__wbg_setonupgradeneeded_fcf7ce4f2eb0cb5f:Sa,__wbg_setonversionchange_6ee07fa49ee1e3a5:Ra,__wbg_setunique_dd24c422aa05df89:Ka,__wbg_signatures_new:Ia,__wbg_signatureuploadrequest_new:Ca,__wbg_signatureverification_new:Oa,__wbg_stack_0ed75d68575b0f3c:Ma,__wbg_static_accessor_GLOBAL_88a902d13a557d07:qa,__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0:Da,__wbg_static_accessor_SELF_37c5d418e4bf5819:Ea,__wbg_static_accessor_WINDOW_5de37043a91a9c40:Ba,__wbg_storehandle_new:Ua,__wbg_stringify_f7ed6987935b4a24:Fa,__wbg_subarray_aa9065fa9dc5df96:Va,__wbg_target_0a62d9d79a2a1ede:Pa,__wbg_then_44b73946d2fb3e7d:Ta,__wbg_then_48b406749878a531:Aa,__wbg_todevicerequest_new:za,__wbg_transaction_babc423936946a37:Na,__wbg_transaction_d6d07c3c9963c49e:ja,__wbg_transaction_e713aa7b07ccaedd:xa,__wbg_update_acd72607f506872a:La,__wbg_userdevices_new:Wa,__wbg_userid_new:Ga,__wbg_userid_unwrap:Ja,__wbg_value_68c4e9a54bb7fd5e:Qa,__wbg_value_cd1ffa7b1ab794f1:Ha,__wbg_values_53465c57fc8cd691:Ya,__wbg_verificationrequest_new:$a,__wbg_version_a70a33e5bbc6d6db:Za,__wbg_versions_c71aa1626a93e0a1:Xa,__wbg_warn_4ca3906c248c47c4:ec,__wbg_warn_6ce7b8525f302b4c:tc,__wbindgen_as_number:rc,__wbindgen_bigint_from_i64:nc,__wbindgen_bigint_from_u64:ic,__wbindgen_bigint_get_as_i64:sc,__wbindgen_boolean_get:_c,__wbindgen_cb_drop:oc,__wbindgen_closure_wrapper1066:ac,__wbindgen_closure_wrapper2247:cc,__wbindgen_closure_wrapper5526:gc,__wbindgen_closure_wrapper7042:uc,__wbindgen_closure_wrapper7044:dc,__wbindgen_debug_string:lc,__wbindgen_error_new:pc,__wbindgen_in:wc,__wbindgen_init_externref_table:yc,__wbindgen_is_array:bc,__wbindgen_is_bigint:hc,__wbindgen_is_function:fc,__wbindgen_is_null:mc,__wbindgen_is_object:vc,__wbindgen_is_string:kc,__wbindgen_is_undefined:Sc,__wbindgen_jsval_eq:Rc,__wbindgen_jsval_loose_eq:Kc,__wbindgen_memory:Ic,__wbindgen_number_get:Cc,__wbindgen_number_new:Oc,__wbindgen_string_get:Mc,__wbindgen_string_new:qc,__wbindgen_throw:Dc,__wbindgen_try_into_number:Ec,getVersions:bn,start:_s},Symbol.toStringTag,{value:"Module"})),Uc=new URL("/assets/matrix_sdk_crypto_wasm_bg-BKhMui86.wasm",import.meta.url);er(new Proxy({},{get(){throw new Error("@matrix-org/matrix-sdk-crypto-wasm was used before it was initialized. Call `initAsync` first.")}}));let Fr=null;async function Fc(){const{instance:i}=await WebAssembly.instantiateStreaming(fetch(Uc),{"./matrix_sdk_crypto_wasm_bg.js":Bc});er(i.exports),i.exports.__wbindgen_start()}async function Si(){Fr||(Fr=Fc()),await Fr}for(var Ri=/[\\\"\x00-\x1F]/g,J={},wt=0;wt<32;++wt)J[String.fromCharCode(wt)]="\\U"+("0000"+wt.toString(16)).slice(-4).toUpperCase();J["\b"]="\\b",J[" "]="\\t",J[`
`]="\\n",J["\f"]="\\f",J["\r"]="\\r",J['"']='\\"',J["\\"]="\\\\";function Ki(i){return Ri.lastIndex=0,i.replace(Ri,function(e){return J[e]})}function Vr(i){switch(typeof i){case"string":return'"'+Ki(i)+'"';case"number":return isFinite(i)?i:"null";case"boolean":return i;case"object":return i===null?"null":Array.isArray(i)?Vc(i):Pc(i);default:throw new Error("Cannot stringify: "+typeof i)}}function Vc(i){for(var e="[",t="",r=0;r<i.length;++r)t+=e,e=",",t+=Vr(i[r]);return e!=","?"[]":t+"]"}function Pc(i){var e="{",t="",r=Object.keys(i);r.sort();for(var s=0;s<r.length;++s){var _=r[s];t+=e+'"'+Ki(_)+'":',e=",",t+=Vr(i[_])}return e!=","?"{}":t+"}"}var Tc={stringify:Vr};const Ac=Qi(Tc);class zc{constructor(e,t,r,s,_){this.olmMachine=e,this.keyClaimManager=t,this.outgoingRequestManager=r,this.room=s,this.encryptionSettings=_,v(this,"prefixedLogger",void 0),v(this,"lazyLoadedMembersResolved",!1),v(this,"currentEncryptionPromise",Promise.resolve()),this.prefixedLogger=k.getChild("[".concat(s.roomId," encryption]"));var o=s.getJoinedMembers();this.olmMachine.updateTrackedUsers(o.map(a=>new f(a.userId))).catch(a=>this.prefixedLogger.error("Error initializing tracked users",a))}onCryptoEvent(e){if(JSON.stringify(this.encryptionSettings)!=JSON.stringify(e))throw new Error("Cannot reconfigure an active RoomEncryptor")}onRoomMembership(e){(e.membership==rt.Join||e.membership==rt.Invite&&this.room.shouldEncryptForInvitedMembers())&&this.olmMachine.updateTrackedUsers([new f(e.userId)]).catch(t=>{this.prefixedLogger.error("Unable to update tracked users",t)})}prepareForEncryption(e,t){var r=this;return c(function*(){yield r.encryptEvent(null,e,t)})()}encryptEvent(e,t,r){var s,_=this,o=new tn(this.prefixedLogger,e?(s=e.getTxnId())!==null&&s!==void 0?s:"":"prepareForEncryption"),a=this.currentEncryptionPromise.catch(()=>{}).then(c(function*(){yield W(o,"ensureEncryptionSession",c(function*(){yield _.ensureEncryptionSession(o,t,r)})),e&&(yield W(o,"encryptEventInner",c(function*(){yield _.encryptEventInner(o,e)})))}));return this.currentEncryptionPromise=a,a}ensureEncryptionSession(e,t,r){var s=this;return c(function*(){if(s.encryptionSettings.algorithm!=="m.megolm.v1.aes-sha2")throw new Error("Cannot encrypt in ".concat(s.room.roomId," for unsupported algorithm '").concat(s.encryptionSettings.algorithm,"'"));e.debug("Starting encryption");var _=yield s.room.getEncryptionTargetMembers();s.lazyLoadedMembersResolved?(e.debug("Processing outgoing requests in background"),s.outgoingRequestManager.doProcessOutgoingRequests()):(yield W(s.prefixedLogger,"loadMembersIfNeeded: updateTrackedUsers",c(function*(){yield s.olmMachine.updateTrackedUsers(_.map(y=>new f(y.userId)))})),e.debug("Updated tracked users"),s.lazyLoadedMembersResolved=!0,e.debug("Processing outgoing requests"),yield W(s.prefixedLogger,"doProcessOutgoingRequests",c(function*(){yield s.outgoingRequestManager.doProcessOutgoingRequests()}))),e.debug("Encrypting for users (shouldEncryptForInvitedMembers: ".concat(s.room.shouldEncryptForInvitedMembers(),"):"),_.map(y=>"".concat(y.userId," (").concat(y.membership,")")));var o=_.map(y=>new f(y.userId));yield W(s.prefixedLogger,"ensureSessionsForUsers",c(function*(){yield s.keyClaimManager.ensureSessionsForUsers(e,o)}));var a=new wr;switch(a.historyVisibility=Nc(s.room.getHistoryVisibility()),a.algorithm=ue.MegolmV1AesSha2,typeof s.encryptionSettings.rotation_period_ms=="number"&&(a.rotationPeriod=BigInt(s.encryptionSettings.rotation_period_ms*1e3)),typeof s.encryptionSettings.rotation_period_msgs=="number"&&(a.rotationPeriodMessages=BigInt(s.encryptionSettings.rotation_period_msgs)),r.kind){case nt.AllDevicesIsolationMode:{var g,l=(g=s.room.getBlacklistUnverifiedDevices())!==null&&g!==void 0?g:t;a.sharingStrategy=T.deviceBasedStrategy(l,r.errorOnVerifiedUserProblems)}break;case nt.OnlySignedDevicesIsolationMode:a.sharingStrategy=T.identityBasedStrategy();break}yield W(s.prefixedLogger,"shareRoomKey",c(function*(){var y=yield s.olmMachine.shareRoomKey(new C(s.room.roomId),o,a);if(y)for(var h of y)yield s.outgoingRequestManager.outgoingRequestProcessor.makeOutgoingRequest(h)}))})()}forceDiscardSession(){var e=this;return c(function*(){var t=yield e.olmMachine.invalidateGroupSession(new C(e.room.roomId));t&&e.prefixedLogger.info("Discarded existing group session")})()}encryptEventInner(e,t){var r=this;return c(function*(){e.debug("Encrypting actual message content");var s=yield r.olmMachine.encryptRoomEvent(new C(r.room.roomId),t.getType(),JSON.stringify(t.getContent()));t.makeEncrypted(A.RoomMessageEncrypted,JSON.parse(s),r.olmMachine.identityKeys.curve25519.toBase64(),r.olmMachine.identityKeys.ed25519.toBase64()),e.debug("Encrypted event successfully")})()}}function Nc(i){switch(i){case it.Invited:return Oe.Invited;case it.Joined:return Oe.Joined;case it.Shared:return Oe.Shared;case it.WorldReadable:return Oe.WorldReadable}}var qe="/_matrix/client/unstable/org.matrix.msc3814.v1",Pr="org.matrix.msc3814",jc=7*24*60*60*1e3;class xc extends ke{constructor(e,t,r,s,_){super(),this.logger=e,this.olmMachine=t,this.http=r,this.outgoingRequestProcessor=s,this.secretStorage=_,v(this,"intervalId",void 0)}cacheKey(e){var t=this;return c(function*(){yield t.olmMachine.dehydratedDevices().saveDehydratedDeviceKey(e),t.emit(I.DehydrationKeyCached)})()}isSupported(){var e=this;return c(function*(){try{yield e.http.authedRequest(M.Get,"/dehydrated_device",void 0,void 0,{prefix:qe})}catch(r){var t=r;if(t.errcode==="M_UNRECOGNIZED")return!1;if(t.errcode==="M_NOT_FOUND")return!0;throw r}return!0})()}start(){var e=arguments,t=this;return c(function*(){var r=e.length>0&&e[0]!==void 0?e[0]:{};if(typeof r=="boolean"&&(r={createNewKey:r}),!(r.onlyIfKeyCached&&!(yield t.olmMachine.dehydratedDevices().getDehydratedDeviceKey()))){if(t.stop(),r.rehydrate!==!1)try{yield t.rehydrateDeviceIfAvailable()}catch(s){t.logger.info("dehydration: Error rehydrating device:",s),t.emit(I.RehydrationError,s.message)}r.createNewKey&&(yield t.resetKey()),yield t.scheduleDeviceDehydration()}})()}isKeyStored(){var e=this;return c(function*(){return!!(yield e.secretStorage.isStored(Pr))})()}resetKey(){var e=this;return c(function*(){var t=L.createRandomKey();return yield e.secretStorage.store(Pr,t.toBase64()),yield e.cacheKey(t),t})()}getKey(e){var t=this;return c(function*(){var r=yield t.olmMachine.dehydratedDevices().getDehydratedDeviceKey();if(r)return r;var s=yield t.secretStorage.get(Pr);if(s===void 0)return e?yield t.resetKey():null;var _=$t(s);try{var o=L.createKeyFromArray(_);return yield t.cacheKey(o),o}finally{_.fill(0)}})()}rehydrateDeviceIfAvailable(){var e=this;return c(function*(){var t=yield e.getKey(!1);if(!t)return!1;var r;try{r=yield e.http.authedRequest(M.Get,"/dehydrated_device",void 0,void 0,{prefix:qe})}catch(m){var s=m;if(s.errcode==="M_NOT_FOUND"||s.errcode==="M_UNRECOGNIZED")return e.logger.info("dehydration: No dehydrated device"),!1;throw s}e.logger.info("dehydration: dehydrated device found"),e.emit(I.RehydrationStarted);var _=yield e.olmMachine.dehydratedDevices().rehydrate(t,new O(r.device_id),JSON.stringify(r.device_data));e.logger.info("dehydration: device rehydrated");for(var o=void 0,a=0,g=0,l=st("/dehydrated_device/$device_id/events",{$device_id:r.device_id});;){var y=yield e.http.authedRequest(M.Post,l,void 0,o?{next_batch:o}:{},{prefix:qe});if(y.events.length===0)break;a+=y.events.length,o=y.next_batch;var h=yield _.receiveEvents(JSON.stringify(y.events));g+=h.length,e.emit(I.RehydrationProgress,g,a)}return e.logger.info("dehydration: received ".concat(g," room keys from ").concat(a," to-device events")),e.emit(I.RehydrationCompleted),!0})()}createAndUploadDehydratedDevice(){var e=this;return c(function*(){var t=yield e.getKey(!0),r=yield e.olmMachine.dehydratedDevices().create();e.emit(I.DehydratedDeviceCreated);var s=yield r.keysForUpload("Dehydrated device",t);yield e.outgoingRequestProcessor.makeOutgoingRequest(s),e.emit(I.DehydratedDeviceUploaded),e.logger.info("dehydration: uploaded device")})()}scheduleDeviceDehydration(){var e=this;return c(function*(){e.stop(),yield e.createAndUploadDehydratedDevice(),e.intervalId=setInterval(()=>{e.createAndUploadDehydratedDevice().catch(t=>{e.emit(I.DehydratedDeviceRotationError,t.message),e.logger.error("Error creating dehydrated device:",t)})},jc)})()}stop(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=void 0)}delete(){var e=this;return c(function*(){e.stop();try{yield e.http.authedRequest(M.Delete,"/dehydrated_device",void 0,{},{prefix:qe})}catch(r){var t=r;if(t.errcode==="M_UNRECOGNIZED"||t.errcode==="M_NOT_FOUND")return;throw r}})()}}function Ii(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,r)}return t}function Lc(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ii(Object(t),!0).forEach(function(r){v(i,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):Ii(Object(t)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(t,r))})}return i}class Wc{constructor(e,t){this.olmMachine=e,this.http=t}makeOutgoingRequest(e,t){var r=this;return c(function*(){var s;if(e instanceof Te)s=yield r.requestWithRetry(M.Post,"/_matrix/client/v3/keys/upload",{},e.body);else if(e instanceof ye)s=yield r.requestWithRetry(M.Post,"/_matrix/client/v3/keys/query",{},e.body);else if(e instanceof Pe)s=yield r.requestWithRetry(M.Post,"/_matrix/client/v3/keys/claim",{},e.body);else if(e instanceof fe)s=yield r.requestWithRetry(M.Post,"/_matrix/client/v3/keys/signatures/upload",{},e.body);else if(e instanceof Ve)s=yield r.requestWithRetry(M.Put,"/_matrix/client/v3/room_keys/keys",{version:e.version},e.body);else if(e instanceof Ze)s=yield r.sendToDeviceRequest(e);else if(e instanceof Qe){var _="/_matrix/client/v3/rooms/".concat(encodeURIComponent(e.room_id),"/send/")+"".concat(encodeURIComponent(e.event_type),"/").concat(encodeURIComponent(e.txn_id));s=yield r.requestWithRetry(M.Put,_,{},e.body)}else if(e instanceof Xe){yield r.makeRequestWithUIA(M.Post,"/_matrix/client/v3/keys/device_signing/upload",{},e.body,t);return}else if(e instanceof Ge){var o=qe+"/dehydrated_device";yield r.rawJsonRequest(M.Put,o,{},e.body);return}else k.warn("Unsupported outgoing message",Object.getPrototypeOf(e)),s="";if(e.id)try{yield W(k,"Mark Request as sent ".concat(e.type),c(function*(){yield r.olmMachine.markRequestAsSent(e.id,e.type,s)}))}catch(a){if(a instanceof Error&&(a.message==="Attempt to use a moved value"||a.message==="null pointer passed to rust"))k.log("Ignoring error '".concat(a.message,"': client is likely shutting down"));else throw a}else k.trace("Outgoing request type:".concat(e.type," does not have an ID"))})()}sendToDeviceRequest(e){var t=this;return c(function*(){var r=JSON.parse(e.body),s=[];for(var[_,o]of Object.entries(r.messages))for(var[a,g]of Object.entries(o))s.push("".concat(_,"/").concat(a," (msgid ").concat(g[Hi],")"));k.info("Sending batch of to-device messages. type=".concat(e.event_type," txnid=").concat(e.txn_id),s);var l="/_matrix/client/v3/sendToDevice/".concat(encodeURIComponent(e.event_type),"/")+encodeURIComponent(e.txn_id);return yield t.requestWithRetry(M.Put,l,{},e.body)})()}makeRequestWithUIA(e,t,r,s,_){var o=this;return c(function*(){if(!_)return yield o.requestWithRetry(e,t,r,s);var a=JSON.parse(s),g=function(){var y=c(function*(h){var m=Lc({},a);h!==null&&(m.auth=h);var K=yield o.requestWithRetry(e,t,r,JSON.stringify(m));return JSON.parse(K)});return function(h){return y.apply(this,arguments)}}(),l=yield _(g);return JSON.stringify(l)})()}requestWithRetry(e,t,r,s){var _=this;return c(function*(){for(var o=0;;)try{return yield _.rawJsonRequest(e,t,r,s)}catch(g){o++;var a=Yi(g,o,!0);if(a<0)throw g;yield te(a)}})()}rawJsonRequest(e,t,r,s){var _=this;return c(function*(){var o={json:!1,headers:{"Content-Type":"application/json",Accept:"application/json"},prefix:"",localTimeoutMs:6e4};return yield _.http.authedRequest(e,t,r,s,o)})()}}class Gc{constructor(e,t){this.olmMachine=e,this.outgoingRequestProcessor=t,v(this,"currentClaimPromise",void 0),v(this,"stopped",!1),this.currentClaimPromise=Promise.resolve()}stop(){this.stopped=!0}ensureSessionsForUsers(e,t){var r=this.currentClaimPromise.catch(()=>{}).then(()=>this.ensureSessionsForUsersInner(e,t));return this.currentClaimPromise=r,r}ensureSessionsForUsersInner(e,t){var r=this;return c(function*(){if(r.stopped)throw new Error("Cannot ensure Olm sessions: shutting down");e.info("Checking for missing Olm sessions");var s=yield r.olmMachine.getMissingSessions(t.map(_=>_.clone()));s&&(e.info("Making /keys/claim request"),yield r.outgoingRequestProcessor.makeOutgoingRequest(s)),e.info("Olm sessions prepared")})()}}function Jc(i,e){var t=new Map;for(var[r,s]of i.keys.entries())t.set(r.toString(),s.toBase64());var _=_t.Unverified;i.isBlacklisted()?_=_t.Blocked:i.isVerified()&&(_=_t.Verified);var o=new Map,a=i.signatures.get(e);if(a){var g=new Map;for(var[l,y]of a.entries())y.isValid()&&y.signature&&g.set(l,y.signature.toBase64());o.set(e.toString(),g)}var h=i.algorithms,m=new Set;return h.forEach(K=>{switch(K){case ue.MegolmV1AesSha2:m.add("m.megolm.v1.aes-sha2");break;case ue.OlmV1Curve25519AesSha2:default:m.add("m.olm.v1.curve25519-aes-sha2");break}}),new rn({deviceId:i.deviceId.toString(),userId:e.toString(),keys:t,algorithms:Array.from(m),verified:_,signatures:o,displayName:i.displayName,dehydrated:i.isDehydrated})}function Qc(i){return new Map(Object.entries(i).map(e=>{var[t,r]=e;return[t,Hc(r)]}))}function Hc(i){var e,t=new Map(Object.entries(i.keys)),r=(e=i.unsigned)===null||e===void 0?void 0:e.device_display_name,s=new Map;if(i.signatures)for(var _ in i.signatures)s.set(_,new Map(Object.entries(i.signatures[_])));return new rn({deviceId:i.device_id,userId:i.user_id,keys:t,algorithms:i.algorithms,verified:_t.Unverified,signatures:s,displayName:r})}class Yc{constructor(e,t,r){this.olmMachine=e,this.outgoingRequestProcessor=t,this.secretStorage=r}bootstrapCrossSigning(e){var t=this;return c(function*(){if(e.setupNewCrossSigning){yield t.resetCrossSigning(e.authUploadDeviceSigningKeys);return}var r=yield t.olmMachine.crossSigningStatus(),s=yield t.secretStorage.get("m.cross_signing.master"),_=yield t.secretStorage.get("m.cross_signing.self_signing"),o=yield t.secretStorage.get("m.cross_signing.user_signing"),a=!!(s&&_&&o),g=r.hasMaster&&r.hasUserSigning&&r.hasSelfSigning;if(k.log("bootstrapCrossSigning: starting",{setupNewCrossSigning:e.setupNewCrossSigning,olmDeviceHasMaster:r.hasMaster,olmDeviceHasUserSigning:r.hasUserSigning,olmDeviceHasSelfSigning:r.hasSelfSigning,privateKeysInSecretStorage:a}),g)(yield t.secretStorage.hasKey())?a?k.log("bootstrapCrossSigning: Olm device has private keys and they are saved in secret storage; doing nothing"):(k.log("bootstrapCrossSigning: Olm device has private keys: exporting to secret storage"),yield t.exportCrossSigningKeysToStorage()):k.warn("bootstrapCrossSigning: Olm device has private keys, but secret storage is not yet set up; doing nothing for now.");else if(a){k.log("bootstrapCrossSigning: Cross-signing private keys not found locally, but they are available in secret storage, reading storage and caching locally");var l=yield t.olmMachine.importCrossSigningKeys(s,_,o);if(!l.hasMaster||!l.hasSelfSigning||!l.hasUserSigning)throw new Error("importCrossSigningKeys failed to import the keys");var y=yield t.olmMachine.getDevice(t.olmMachine.userId,t.olmMachine.deviceId);try{var h=yield y.verify();yield t.outgoingRequestProcessor.makeOutgoingRequest(h)}finally{y.free()}}else k.log("bootstrapCrossSigning: Cross-signing private keys not found locally or in secret storage, creating new keys"),yield t.resetCrossSigning(e.authUploadDeviceSigningKeys);k.log("bootstrapCrossSigning: complete")})()}resetCrossSigning(e){var t=this;return c(function*(){var r=yield t.olmMachine.bootstrapCrossSigning(!0);(yield t.secretStorage.hasKey())?(k.log("resetCrossSigning: exporting private keys to secret storage"),yield t.exportCrossSigningKeysToStorage()):k.warn("resetCrossSigning: Secret storage is not yet set up; not exporting keys to secret storage yet."),k.log("resetCrossSigning: publishing public keys to server");for(var s of[r.uploadKeysRequest,r.uploadSigningKeysRequest,r.uploadSignaturesRequest])s&&(yield t.outgoingRequestProcessor.makeOutgoingRequest(s,e))})()}exportCrossSigningKeysToStorage(){var e=this;return c(function*(){var t=yield e.olmMachine.exportCrossSigningKeys();t!=null&&t.masterKey?yield e.secretStorage.store("m.cross_signing.master",t.masterKey):k.error("Cannot export MSK to secret storage, private key unknown"),t!=null&&t.self_signing_key?yield e.secretStorage.store("m.cross_signing.self_signing",t.self_signing_key):k.error("Cannot export SSK to secret storage, private key unknown"),t!=null&&t.userSigningKey?yield e.secretStorage.store("m.cross_signing.user_signing",t.userSigningKey):k.error("Cannot export USK to secret storage, private key unknown")})()}}function Ci(i){return Tr.apply(this,arguments)}function Tr(){return Tr=c(function*(i){return Oi(i,["m.cross_signing.master","m.cross_signing.user_signing","m.cross_signing.self_signing"])}),Tr.apply(this,arguments)}function Oi(i,e){return Ar.apply(this,arguments)}function Ar(){return Ar=c(function*(i,e){var t=yield i.getDefaultKeyId();if(!t)return!1;for(var r of e){var s=(yield i.isStored(r))||{};if(!(t in s))return!1}return!0}),Ar.apply(this,arguments)}class de extends ke{constructor(e,t,r,s){super(),this.olmMachine=e,this.inner=t,this.outgoingRequestProcessor=r,this.supportedVerificationMethods=s,v(this,"reEmitter",void 0),v(this,"_accepting",!1),v(this,"_cancelling",!1),v(this,"_verifier",void 0),this.reEmitter=new nn(this);var _=new WeakRef(this);t.registerChangesCallback(c(function*(){var o;return(o=_.deref())===null||o===void 0?void 0:o.onChange()}))}onChange(){var e=this.inner.getVerification();e instanceof he?this._verifier===void 0||this._verifier instanceof qi?this.setVerifier(new Di(e,this,this.outgoingRequestProcessor)):this._verifier instanceof Di&&this._verifier.replaceInner(e):e instanceof be&&this._verifier===void 0&&this.setVerifier(new qi(e,this.outgoingRequestProcessor)),this.emit(Se.Change)}setVerifier(e){this._verifier&&this.reEmitter.stopReEmitting(this._verifier,[Se.Change]),this._verifier=e,this.reEmitter.reEmit(this._verifier,[Se.Change])}get transactionId(){return this.inner.flowId}get roomId(){var e;return(e=this.inner.roomId)===null||e===void 0?void 0:e.toString()}get initiatedByMe(){return this.inner.weStarted()}get otherUserId(){return this.inner.otherUserId.toString()}get otherDeviceId(){var e;return(e=this.inner.otherDeviceId)===null||e===void 0?void 0:e.toString()}getOtherDevice(){var e=this;return c(function*(){var t=e.inner.otherDeviceId;if(t)return yield e.olmMachine.getDevice(e.inner.otherUserId,t,5)})()}get isSelfVerification(){return this.inner.isSelfVerification()}get phase(){var e=this.inner.phase();switch(e){case Z.Created:case Z.Requested:return E.Requested;case Z.Ready:return this._accepting?E.Requested:E.Ready;case Z.Transitioned:if(!this._verifier)throw new Error("VerificationRequest: inner phase == Transitioned but no verifier!");return this._verifier.verificationPhase;case Z.Done:return E.Done;case Z.Cancelled:return E.Cancelled}throw new Error("Unknown verification phase ".concat(e))}get pending(){if(this.inner.isPassive())return!1;var e=this.phase;return e!==E.Done&&e!==E.Cancelled}get accepting(){return this._accepting}get declining(){return this._cancelling}get timeout(){return this.inner.timeRemainingMillis()}get methods(){throw new Error("not implemented")}get chosenMethod(){if(this.phase!==E.Started)return null;var e=this.inner.getVerification();return e instanceof he?N.Sas:e instanceof be?N.Reciprocate:null}otherPartySupportsMethod(e){var t=this.inner.theirSupportedMethods;if(t===void 0)return!1;var r=Ei[e];return t.some(s=>s===r)}accept(){var e=this;return c(function*(){if(e.inner.phase()!==Z.Requested||e._accepting)throw new Error("Cannot accept a verification request in phase ".concat(e.phase));e._accepting=!0;try{var t=e.inner.acceptWithMethods(e.supportedVerificationMethods.map(yt));t&&(yield e.outgoingRequestProcessor.makeOutgoingRequest(t))}finally{e._accepting=!1}e.emit(Se.Change)})()}cancel(e){var t=this;return c(function*(){if(!t._cancelling){t._cancelling=!0;try{var r=t.inner.cancel();r&&(yield t.outgoingRequestProcessor.makeOutgoingRequest(r))}finally{t._cancelling=!1}}})()}beginKeyVerification(e,t){throw new Error("not implemented")}startVerification(e){var t=this;return c(function*(){if(e!==N.Sas)throw new Error("Unsupported verification method ".concat(e));if(!(yield t.getOtherDevice()))throw new Error("startVerification(): other device is unknown");var r=yield t.inner.startSas();if(r){var[,s]=r;yield t.outgoingRequestProcessor.makeOutgoingRequest(s)}if(!t._verifier)throw new Error("Still no verifier after startSas() call");return t._verifier})()}scanQRCode(e){var t=this;return c(function*(){var r=ve.fromBytes(e),s=yield t.inner.scanQrCode(r);if(!t._verifier)throw new Error("Still no verifier after scanQrCode() call");var _=s.reciprocate();return _&&(yield t.outgoingRequestProcessor.makeOutgoingRequest(_)),t._verifier})()}get verifier(){return this.phase===E.Started?this._verifier:void 0}getQRCodeBytes(){throw new Error("getQRCodeBytes() unsupported in Rust Crypto; use generateQRCode() instead.")}generateQRCode(){var e=this;return c(function*(){if(!(yield e.getOtherDevice()))throw new Error("generateQRCode(): other device is unknown");var t=yield e.inner.generateQrCode();if(t)return t.toBytes()})()}get cancellationCode(){var e,t;return(e=(t=this.inner.cancelInfo)===null||t===void 0?void 0:t.cancelCode())!==null&&e!==void 0?e:null}get cancellingUserId(){var e=this.inner.cancelInfo;if(e)return e.cancelledbyUs()?this.olmMachine.userId.toString():this.inner.otherUserId.toString()}}class Mi extends ke{constructor(e,t){super(),this.inner=e,this.outgoingRequestProcessor=t,v(this,"completionDeferred",void 0),this.completionDeferred=_n();var r=new WeakRef(this);e.registerChangesCallback(c(function*(){var s;return(s=r.deref())===null||s===void 0?void 0:s.onChange()})),this.completionDeferred.promise.catch(()=>null)}onChange(){if(this.inner.isDone())this.completionDeferred.resolve(void 0);else if(this.inner.isCancelled()){var e=this.inner.cancelInfo();this.completionDeferred.reject(new Error("Verification cancelled by ".concat(e.cancelledbyUs()?"us":"them"," with code ").concat(e.cancelCode(),": ").concat(e.reason())))}this.emit(Se.Change)}get hasBeenCancelled(){return this.inner.isCancelled()}get userId(){return this.inner.otherUserId.toString()}cancel(e){var t=this.inner.cancel();t&&this.outgoingRequestProcessor.makeOutgoingRequest(t)}getShowSasCallbacks(){return null}getReciprocateQrCodeCallbacks(){return null}}class qi extends Mi{constructor(e,t){super(e,t),v(this,"callbacks",null)}onChange(){this.callbacks===null&&this.inner.hasBeenScanned()&&(this.callbacks={confirm:()=>{this.confirmScanning()},cancel:()=>this.cancel()}),super.onChange()}verify(){var e=this;return c(function*(){e.callbacks!==null&&e.emit(sn.ShowReciprocateQr,e.callbacks),yield e.completionDeferred.promise})()}get verificationPhase(){switch(this.inner.state()){case re.Created:return E.Ready;case re.Scanned:return E.Started;case re.Confirmed:return E.Started;case re.Reciprocated:return E.Started;case re.Done:return E.Done;case re.Cancelled:return E.Cancelled;default:throw new Error("Unknown qr code state ".concat(this.inner.state()))}}getReciprocateQrCodeCallbacks(){return this.callbacks}confirmScanning(){var e=this;return c(function*(){var t=e.inner.confirmScanning();t&&(yield e.outgoingRequestProcessor.makeOutgoingRequest(t))})()}}class Di extends Mi{constructor(e,t,r){super(e,r),v(this,"callbacks",null)}verify(){var e=this;return c(function*(){yield e.sendAccept(),yield e.completionDeferred.promise})()}sendAccept(){var e=this;return c(function*(){var t=e.inner.accept();t&&(yield e.outgoingRequestProcessor.makeOutgoingRequest(t))})()}onChange(){var e=this;if(super.onChange(),this.callbacks===null){var t=this.inner.emoji(),r=this.inner.decimals();if(t===void 0&&r===void 0)return;var s={};t&&(s.emoji=t.map(_=>[_.symbol,_.description])),r&&(s.decimal=[r[0],r[1],r[2]]),this.callbacks={sas:s,confirm:function(){var _=c(function*(){var a=yield e.inner.confirm();for(var g of a)yield e.outgoingRequestProcessor.makeOutgoingRequest(g)});function o(){return _.apply(this,arguments)}return o}(),mismatch:()=>{var _=this.inner.cancelWithCode("m.mismatched_sas");_&&this.outgoingRequestProcessor.makeOutgoingRequest(_)},cancel:()=>{var _=this.inner.cancelWithCode("m.user");_&&this.outgoingRequestProcessor.makeOutgoingRequest(_)}},this.emit(sn.ShowSas,this.callbacks)}}get verificationPhase(){return E.Started}getShowSasCallbacks(){return this.callbacks}replaceInner(e){if(this.inner!=e){this.inner=e;var t=new WeakRef(this);e.registerChangesCallback(c(function*(){var r;return(r=t.deref())===null||r===void 0?void 0:r.onChange()})),this.sendAccept(),this.onChange()}}}var Ei={[N.Sas]:Me.SasV1,[N.ScanQrCode]:Me.QrCodeScanV1,[N.ShowQrCode]:Me.QrCodeShowV1,[N.Reciprocate]:Me.ReciprocateV1};function yt(i){var e=Ei[i];if(e===void 0)throw new Error("Unknown verification method ".concat(i));return e}function $c(i){switch(i.getType()){case A.KeyVerificationCancel:case A.KeyVerificationDone:case A.KeyVerificationMac:case A.KeyVerificationStart:case A.KeyVerificationKey:case A.KeyVerificationReady:case A.KeyVerificationAccept:return!0;case A.RoomMessage:return i.getContent().msgtype===on.KeyVerificationRequest;default:return!1}}class Zc extends ke{constructor(e,t,r){super(),this.olmMachine=e,this.http=t,this.outgoingRequestProcessor=r,v(this,"checkedForBackup",!1),v(this,"serverBackupInfo",void 0),v(this,"activeBackupVersion",null),v(this,"stopped",!1),v(this,"backupKeysLoopRunning",!1),v(this,"keyBackupCheckInProgress",null)}stop(){this.stopped=!0}getActiveBackupVersion(){var e=this;return c(function*(){return(yield e.olmMachine.isBackupEnabled())?e.activeBackupVersion:null})()}getServerBackupInfo(){var e=this;return c(function*(){return yield e.checkKeyBackupAndEnable(!1),e.serverBackupInfo})()}isKeyBackupTrusted(e){var t=this;return c(function*(){var r=yield t.olmMachine.verifyBackup(e),s=yield t.olmMachine.getBackupKeys(),_=s==null?void 0:s.decryptionKey,o=!!_&&Bi(e,_);return{matchesDecryptionKey:o,trusted:r.trusted()}})()}checkKeyBackupAndEnable(e){return!e&&this.checkedForBackup?Promise.resolve(null):(this.keyBackupCheckInProgress||(this.keyBackupCheckInProgress=this.doCheckKeyBackup().finally(()=>{this.keyBackupCheckInProgress=null})),this.keyBackupCheckInProgress)}handleBackupSecretReceived(e){var t=this;return c(function*(){var r,s;try{s=yield t.requestKeyBackupVersion()}catch(a){return k.warn("handleBackupSecretReceived: Error checking for latest key backup",a),!1}if(!((r=s)!==null&&r!==void 0&&r.version))return k.warn("handleBackupSecretReceived: Received a backup decryption key, but there is no trusted server-side key backup"),!1;try{var _=V.fromBase64(e),o=Bi(s,_);return o?(k.info("handleBackupSecretReceived: A valid backup decryption key has been received and stored in cache."),yield t.saveBackupDecryptionKey(_,s.version),!0):(k.warn("handleBackupSecretReceived: Private decryption key does not match the public key of the current remote backup."),!1)}catch(a){k.warn("handleBackupSecretReceived: Invalid backup decryption key",a)}return!1})()}saveBackupDecryptionKey(e,t){var r=this;return c(function*(){yield r.olmMachine.saveBackupDecryptionKey(e,t),r.emit(I.KeyBackupDecryptionKeyCached,t)})()}importRoomKeys(e,t){var r=this;return c(function*(){yield r.importRoomKeysAsJson(JSON.stringify(e),t)})()}importRoomKeysAsJson(e,t){var r=this;return c(function*(){yield r.olmMachine.importExportedRoomKeys(e,(s,_)=>{var o,a={total:Number(_),successes:Number(s),stage:Ke.LoadKeys,failures:0};t==null||(o=t.progressCallback)===null||o===void 0||o.call(t,a)})})()}importBackedUpRoomKeys(e,t,r){var s=this;return c(function*(){var _=new Map;for(var o of e){var a=new C(o.room_id);_.has(a)||_.set(a,new Map),_.get(a).set(o.session_id,o)}yield s.olmMachine.importBackedUpRoomKeys(_,(g,l,y)=>{var h,m={total:Number(l),successes:Number(g),stage:Ke.LoadKeys,failures:Number(y)};r==null||(h=r.progressCallback)===null||h===void 0||h.call(r,m)},t)})()}doCheckKeyBackup(){var e=this;return c(function*(){k.log("Checking key backup status...");var t;try{t=yield e.requestKeyBackupVersion()}catch(_){return k.warn("Error checking for active key backup",_),e.serverBackupInfo=void 0,null}e.checkedForBackup=!0,t&&!t.version&&(k.warn("active backup lacks a useful 'version'; ignoring it"),t=void 0),e.serverBackupInfo=t;var r=yield e.getActiveBackupVersion();if(!t)return r!==null?(k.log("No key backup present on server: disabling key backup"),yield e.disableKeyBackup()):k.log("No key backup present on server: not enabling key backup"),null;var s=yield e.isKeyBackupTrusted(t);return!s.matchesDecryptionKey&&!s.trusted?r!==null?(k.log("Key backup present on server but not trusted: disabling key backup"),yield e.disableKeyBackup()):k.log("Key backup present on server but not trusted: not enabling key backup"):r===null?(k.log("Found usable key backup v".concat(t.version,": enabling key backups")),yield e.enableKeyBackup(t)):r!==t.version?(k.log("On backup version ".concat(r," but found version ").concat(t.version,": switching.")),yield e.disableKeyBackup(),yield e.enableKeyBackup(t)):k.log("Backup version ".concat(t.version," still current")),{backupInfo:t,trustInfo:s}})()}enableKeyBackup(e){var t=this;return c(function*(){yield t.olmMachine.enableBackupV1(e.auth_data.public_key,e.version),t.activeBackupVersion=e.version,t.emit(I.KeyBackupStatus,!0),t.backupKeysLoop()})()}maybeUploadKey(){var e=this;return c(function*(){e.activeBackupVersion!=null&&e.backupKeysLoop()})()}disableKeyBackup(){var e=this;return c(function*(){yield e.olmMachine.disableBackup(),e.activeBackupVersion=null,e.emit(I.KeyBackupStatus,!1)})()}backupKeysLoop(){var e=arguments,t=this;return c(function*(){var r=e.length>0&&e[0]!==void 0?e[0]:1e4;if(t.backupKeysLoopRunning){k.log("Backup loop already running");return}t.backupKeysLoopRunning=!0,k.log("Backup: Starting keys upload loop for backup version:".concat(t.activeBackupVersion,"."));var s=Math.random()*r;yield te(s);try{for(var _=0,o=null,a=!0;!t.stopped;){var g=void 0;try{g=yield W(k,"BackupRoomKeys: Get keys to backup from rust crypto-sdk",c(function*(){return yield t.olmMachine.backupRoomKeys()}))}catch(K){k.error("Backup: Failed to get keys to backup from rust crypto-sdk",K)}if(!g||t.stopped||!t.activeBackupVersion){k.log("Backup: Ending loop for version ".concat(t.activeBackupVersion,".")),g||t.emit(I.KeyBackupSessionsRemaining,0);return}try{if(yield t.outgoingRequestProcessor.makeOutgoingRequest(g),_=0,t.stopped)break;if(!a&&o===null)try{var l=yield t.olmMachine.roomKeyCounts();o=l.total-l.backedUp}catch(K){k.error("Backup: Failed to get key counts from rust crypto-sdk",K)}if(o!==null){t.emit(I.KeyBackupSessionsRemaining,o);var y=t.keysCountInBatch(g);o=Math.max(o-y,0)}}catch(K){if(_++,k.error("Backup: Error processing backup request for rust crypto-sdk",K),K instanceof an){var h=K.data.errcode;if(h=="M_NOT_FOUND"||h=="M_WRONG_ROOM_KEYS_VERSION"){k.log("Backup: Failed to upload keys to current vesion: ".concat(h,"."));try{yield t.disableKeyBackup()}catch(B){k.error("Backup: An error occurred while disabling key backup:",B)}t.emit(I.KeyBackupFailed,K.data.errcode),t.backupKeysLoopRunning=!1,t.checkKeyBackupAndEnable(!0);return}else if(K.isRateLimitError())try{var m=K.getRetryAfterMs();if(m&&m>0){yield te(m);continue}}catch(B){k.warn("Backup: An error occurred while retrieving a rate-limit retry delay",B)}}yield te(1e3*Math.pow(2,Math.min(_-1,4)))}a=!1}}finally{t.backupKeysLoopRunning=!1}})()}keysCountInBatch(e){var t=JSON.parse(e.body);return Fi(t)}requestKeyBackupVersion(e){var t=this;return c(function*(){return yield Ui(t.http,e)})()}setupKeyBackup(e){var t=this;return c(function*(){yield t.deleteAllKeyBackupVersions();var r=V.createRandomKey(),s=r.megolmV1PublicKey,_={public_key:s.publicKeyBase64};yield e(_);var o=yield t.http.authedRequest(M.Post,"/room_keys/version",void 0,{algorithm:s.algorithm,auth_data:_},{prefix:Re.V3});return yield t.saveBackupDecryptionKey(r,o.version),{version:o.version,algorithm:s.algorithm,authData:_,decryptionKey:r}})()}deleteAllKeyBackupVersions(){var e=this;return c(function*(){for(var t,r,s=(t=(r=yield e.requestKeyBackupVersion())===null||r===void 0?void 0:r.version)!==null&&t!==void 0?t:null;s!=null;){var _,o;yield e.deleteKeyBackupVersion(s),s=(_=(o=yield e.requestKeyBackupVersion())===null||o===void 0?void 0:o.version)!==null&&_!==void 0?_:null}})()}deleteKeyBackupVersion(e){var t=this;return c(function*(){k.debug("deleteKeyBackupVersion v:".concat(e));var r=st("/room_keys/version/$version",{$version:e});yield t.http.authedRequest(M.Delete,r,void 0,void 0,{prefix:Re.V3}),t.activeBackupVersion===e&&(t.serverBackupInfo=null,yield t.disableKeyBackup())})()}createBackupDecryptor(e){return new Xc(e)}restoreKeyBackup(e,t,r){var s=this;return c(function*(){var _=yield s.downloadKeyBackup(e);return s.importKeyBackup(_,e,t,r)})()}downloadKeyBackup(e){return this.http.authedRequest(M.Get,"/room_keys/keys",{version:e},void 0,{prefix:Re.V3})}importKeyBackup(e,t,r,s){var _=this;return c(function*(){var o,a=200,g=Fi(e),l=0,y=0;s==null||(o=s.progressCallback)===null||o===void 0||o.call(s,{total:g,successes:l,stage:Ke.LoadKeys,failures:y});var h=function(){var Li=c(function*(Ht){var Yt,et=[],Wi=function*(tt){var Ji=yield r.decryptSessions(Ht.get(tt));Ji.forEach(en=>{en.room_id=tt,et.push(en)})};for(var Gi of Ht.keys())yield*Wi(Gi);try{yield _.importBackedUpRoomKeys(et,t),l+=et.length}catch(tt){y+=et.length,k.error("Error importing keys from backup",tt)}s==null||(Yt=s.progressCallback)===null||Yt===void 0||Yt.call(s,{total:g,successes:l,stage:Ke.LoadKeys,failures:y})});return function(Ht){return Li.apply(this,arguments)}}(),m=0,K=new Map;for(var[B,H]of Object.entries(e.rooms))if(H.sessions){K.set(B,{});for(var[Qt,ji]of Object.entries(H.sessions)){var xi=K.get(B);xi[Qt]=ji,m+=1,m>=a&&(yield h(K),K=new Map,K.set(B,{}),m=0)}}return m>0&&(yield h(K)),{total:g,imported:l}})()}}function Bi(i,e){var t;return i.algorithm!=="m.megolm_backup.v1.curve25519-aes-sha2"?(k.warn("backupMatchesPrivateKey: Unsupported backup algorithm",i.algorithm),!1):((t=i.auth_data)===null||t===void 0?void 0:t.public_key)===e.megolmV1PublicKey.publicKeyBase64}class Xc{constructor(e){v(this,"decryptionKey",void 0),v(this,"sourceTrusted",void 0),this.decryptionKey=e,this.sourceTrusted=!1}decryptSessions(e){var t=this;return c(function*(){var r=[];for(var[s,_]of Object.entries(e))try{var o=JSON.parse(t.decryptionKey.decryptV1(_.session_data.ephemeral,_.session_data.mac,_.session_data.ciphertext));o.session_id=s,r.push(o)}catch(a){k.log("Failed to decrypt megolm session from backup",a,_)}return r})()}free(){this.decryptionKey.free()}}function Ui(i,e){return zr.apply(this,arguments)}function zr(){return zr=c(function*(i,e){try{var t=e?st("/room_keys/version/$version",{$version:e}):"/room_keys/version";return yield i.authedRequest(M.Get,t,void 0,void 0,{prefix:Re.V3})}catch(r){if(r.errcode==="M_NOT_FOUND")return null;throw r}}),zr.apply(this,arguments)}function Nr(i,e){var t=e.auth_data;return t.public_key===i.megolmV1PublicKey.publicKeyBase64}function Fi(i){var e=0;for(var{sessions:t}of Object.values(i.rooms))e+=Object.keys(t).length;return e}class eg{constructor(e,t,r){this.logger=e,this.olmMachine=t,this.outgoingRequestProcessor=r,v(this,"stopped",!1),v(this,"outgoingRequestLoopRunning",!1),v(this,"nextLoopDeferred",void 0)}stop(){this.stopped=!0}doProcessOutgoingRequests(){this.nextLoopDeferred||(this.nextLoopDeferred=_n());var e=this.nextLoopDeferred.promise;return this.outgoingRequestLoopRunning||this.outgoingRequestLoop().catch(t=>{this.logger.error("Uncaught error in outgoing request loop",t)}),e}outgoingRequestLoop(){var e=this;return c(function*(){if(e.outgoingRequestLoopRunning)throw new Error("Cannot run two outgoing request loops");e.outgoingRequestLoopRunning=!0;try{for(;!e.stopped&&e.nextLoopDeferred;){var t=e.nextLoopDeferred;e.nextLoopDeferred=void 0,yield e.processOutgoingRequests().then(t.resolve,t.reject)}}finally{e.outgoingRequestLoopRunning=!1}e.nextLoopDeferred&&e.nextLoopDeferred.reject(new Error("OutgoingRequestsManager was stopped"))})()}processOutgoingRequests(){var e=this;return c(function*(){if(!e.stopped){var t=yield e.olmMachine.outgoingRequests(),r=function*(o){if(e.stopped)return{v:void 0};try{yield W(e.logger,"Make outgoing request ".concat(o.type),c(function*(){yield e.outgoingRequestProcessor.makeOutgoingRequest(o)}))}catch(a){e.logger.error("Failed to process outgoing request ".concat(o.type,": ").concat(a))}},s;for(var _ of t)if(s=yield*r(_),s)return s.v}})()}}var bt=5e3,X=function(i){return i.MISSING_DECRYPTION_KEY="MISSING_DECRYPTION_KEY",i.NETWORK_ERROR="NETWORK_ERROR",i.STOPPED="STOPPED",i}(X||{});class De extends Error{constructor(e){super("Failed to get key from backup: ".concat(e)),this.code=e,this.name="KeyDownloadError"}}class Vi extends Error{constructor(e){super("Failed to get key from backup: rate limited"),this.retryMillis=e,this.name="KeyDownloadRateLimitError"}}class tg{constructor(e,t,r,s){this.olmMachine=t,this.http=r,this.backupManager=s,v(this,"stopped",!1),v(this,"configuration",null),v(this,"sessionLastCheckAttemptedTime",new Map),v(this,"logger",void 0),v(this,"downloadLoopRunning",!1),v(this,"queuedRequests",[]),v(this,"hasConfigurationProblem",!1),v(this,"currentBackupVersionCheck",null),v(this,"onBackupStatusChanged",()=>{this.hasConfigurationProblem=!1,this.configuration=null,this.getOrCreateBackupConfiguration().then(_=>{_&&this.downloadKeysLoop()})}),this.logger=e.getChild("[PerSessionKeyBackupDownloader]"),s.on(I.KeyBackupStatus,this.onBackupStatusChanged),s.on(I.KeyBackupFailed,this.onBackupStatusChanged),s.on(I.KeyBackupDecryptionKeyCached,this.onBackupStatusChanged)}isKeyBackupDownloadConfigured(){return this.configuration!==null}getServerBackupInfo(){var e=this;return c(function*(){return yield e.backupManager.getServerBackupInfo()})()}onDecryptionKeyMissingError(e,t){if(this.isAlreadyInQueue(e,t)){this.logger.trace("Not checking key backup for session ".concat(t," as it is already queued"));return}if(this.wasRequestedRecently(t)){this.logger.trace("Not checking key backup for session ".concat(t," as it was already requested recently"));return}this.queuedRequests.push({roomId:e,megolmSessionId:t}),this.downloadKeysLoop()}stop(){this.stopped=!0,this.backupManager.off(I.KeyBackupStatus,this.onBackupStatusChanged),this.backupManager.off(I.KeyBackupFailed,this.onBackupStatusChanged),this.backupManager.off(I.KeyBackupDecryptionKeyCached,this.onBackupStatusChanged)}isAlreadyInQueue(e,t){return this.queuedRequests.some(r=>r.roomId==e&&r.megolmSessionId==t)}markAsNotFoundInBackup(e){var t=Date.now();this.sessionLastCheckAttemptedTime.set(e,t),this.sessionLastCheckAttemptedTime.size>100&&(this.sessionLastCheckAttemptedTime=new Map(Array.from(this.sessionLastCheckAttemptedTime).filter((r,s)=>Math.max(t-s,0)<bt)))}wasRequestedRecently(e){var t=this.sessionLastCheckAttemptedTime.get(e);return t?Math.max(Date.now()-t,0)<bt:!1}getBackupDecryptionKey(){var e=this;return c(function*(){try{return yield e.olmMachine.getBackupKeys()}catch{return null}})()}requestRoomKeyFromBackup(e,t,r){var s=this;return c(function*(){var _=st("/room_keys/keys/$roomId/$sessionId",{$roomId:t,$sessionId:r});return yield s.http.authedRequest(M.Get,_,{version:e},void 0,{prefix:Re.V3})})()}downloadKeysLoop(){var e=this;return c(function*(){if(!e.downloadLoopRunning&&!e.hasConfigurationProblem){e.downloadLoopRunning=!0;try{for(;e.queuedRequests.length>0;){var t=e.queuedRequests[0];try{var r=yield e.getOrCreateBackupConfiguration();if(!r){e.downloadLoopRunning=!1;return}var s=yield e.queryKeyBackup(t.roomId,t.megolmSessionId,r);if(e.stopped)return;try{yield e.decryptAndImport(t,s,r)}catch(_){e.logger.error("Error while decrypting and importing key backup for session ".concat(t.megolmSessionId),_)}e.queuedRequests.shift()}catch(_){if(_ instanceof De)switch(_.code){case X.MISSING_DECRYPTION_KEY:e.markAsNotFoundInBackup(t.megolmSessionId),e.queuedRequests.shift();break;case X.NETWORK_ERROR:yield te(bt);break;case X.STOPPED:e.downloadLoopRunning=!1;return}else _ instanceof Vi&&(yield te(_.retryMillis))}}}finally{e.downloadLoopRunning=!1}}})()}queryKeyBackup(e,t,r){var s=this;return c(function*(){if(s.logger.debug("Checking key backup for session ".concat(t)),s.stopped)throw new De(X.STOPPED);try{var _=yield s.requestRoomKeyFromBackup(r.backupVersion,e,t);return s.logger.debug("Got key from backup for sessionId:".concat(t)),_}catch(l){if(s.stopped)throw new De(X.STOPPED);if(s.logger.info("No luck requesting key backup for session ".concat(t,": ").concat(l)),l instanceof an){var o=l.data.errcode;if(o=="M_NOT_FOUND")throw new De(X.MISSING_DECRYPTION_KEY);if(l.isRateLimitError()){var a;try{var g;a=(g=l.getRetryAfterMs())!==null&&g!==void 0?g:void 0}catch(y){s.logger.warn("Error while retrieving a rate-limit retry delay",y)}throw a&&a>0&&s.logger.info("Rate limited by server, waiting ".concat(a,"ms")),new Vi(a??bt)}}throw new De(X.NETWORK_ERROR)}})()}decryptAndImport(e,t,r){var s=this;return c(function*(){var _={[e.megolmSessionId]:t},o=yield r.decryptor.decryptSessions(_);for(var a of o)a.room_id=e.roomId;yield s.backupManager.importBackedUpRoomKeys(o,r.backupVersion)})()}getOrCreateBackupConfiguration(){var e=this;return c(function*(){if(e.configuration)return e.configuration;if(e.hasConfigurationProblem)return null;if(e.currentBackupVersionCheck!=null)return e.logger.debug("Already checking server version, use current promise"),yield e.currentBackupVersionCheck;e.currentBackupVersionCheck=e.internalCheckFromServer();try{return yield e.currentBackupVersionCheck}finally{e.currentBackupVersionCheck=null}})()}internalCheckFromServer(){var e=this;return c(function*(){var t,r,s,_=null;try{_=yield e.backupManager.getServerBackupInfo()}catch(h){return e.logger.debug("Backup: error while checking server version: ".concat(h)),e.hasConfigurationProblem=!0,null}if(e.logger.debug("Got current backup version from server: ".concat((t=_)===null||t===void 0?void 0:t.version)),((r=_)===null||r===void 0?void 0:r.algorithm)!="m.megolm_backup.v1.curve25519-aes-sha2"){var o;return e.logger.info("Unsupported algorithm ".concat((o=_)===null||o===void 0?void 0:o.algorithm)),e.hasConfigurationProblem=!0,null}if(!((s=_)!==null&&s!==void 0&&s.version))return e.logger.info("No current key backup"),e.hasConfigurationProblem=!0,null;var a=yield e.backupManager.getActiveBackupVersion();if(a==null||_.version!=a)return e.logger.info("The current backup version on the server (".concat(_.version,") is not trusted. Version we are currently backing up to: ").concat(a)),e.hasConfigurationProblem=!0,null;var g=yield e.getBackupDecryptionKey();if(!(g!=null&&g.decryptionKey))return e.logger.debug("Not checking key backup for session (no decryption key)"),e.hasConfigurationProblem=!0,null;if(a!=g.backupVersion)return e.logger.debug("Version for which we have a decryption key (".concat(g.backupVersion,") doesn't match the version we are backing up to (").concat(a,")")),e.hasConfigurationProblem=!0,null;var l=_.auth_data;if(l.public_key!=g.decryptionKey.megolmV1PublicKey.publicKeyBase64)return e.logger.debug("Key backup on server does not match our decryption key"),e.hasConfigurationProblem=!0,null;var y=e.backupManager.createBackupDecryptor(g.decryptionKey);return e.hasConfigurationProblem=!1,e.configuration={decryptor:y,backupVersion:a},e.configuration})()}}function rg(i,e){if(!i.private_key_salt||!i.private_key_iterations)throw new Error("Salt and/or iterations not found: this backup cannot be restored with a passphrase");return cn(e,i.private_key_salt,i.private_key_iterations,i.private_key_bits)}function Pi(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,r)}return t}function Ti(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Pi(Object(t),!0).forEach(function(r){v(i,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):Pi(Object(t)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(t,r))})}return i}var Ai=[N.Sas,N.ScanQrCode,N.ShowQrCode,N.Reciprocate];class ng extends ke{constructor(e,t,r,s,_,o,a){super(),this.logger=e,this.olmMachine=t,this.http=r,this.userId=s,this.secretStorage=o,this.cryptoCallbacks=a,v(this,"RECOVERY_KEY_DERIVATION_ITERATIONS",5e5),v(this,"_trustCrossSignedDevices",!0),v(this,"deviceIsolationMode",new $i(!1)),v(this,"stopped",!1),v(this,"roomEncryptors",{}),v(this,"eventDecryptor",void 0),v(this,"keyClaimManager",void 0),v(this,"outgoingRequestProcessor",void 0),v(this,"crossSigningIdentity",void 0),v(this,"backupManager",void 0),v(this,"outgoingRequestsManager",void 0),v(this,"perSessionBackupDownloader",void 0),v(this,"dehydratedDeviceManager",void 0),v(this,"reemitter",new nn(this)),v(this,"globalBlacklistUnverifiedDevices",!1),v(this,"_supportedVerificationMethods",Ai),this.outgoingRequestProcessor=new Wc(t,r),this.outgoingRequestsManager=new eg(this.logger,t,this.outgoingRequestProcessor),this.keyClaimManager=new Gc(t,this.outgoingRequestProcessor),this.backupManager=new Zc(t,r,this.outgoingRequestProcessor),this.perSessionBackupDownloader=new tg(this.logger,this.olmMachine,this.http,this.backupManager),this.dehydratedDeviceManager=new xc(this.logger,t,r,this.outgoingRequestProcessor,o),this.eventDecryptor=new ig(this.logger,t,this.perSessionBackupDownloader),this.reemitter.reEmit(this.backupManager,[I.KeyBackupStatus,I.KeyBackupSessionsRemaining,I.KeyBackupFailed,I.KeyBackupDecryptionKeyCached]),this.reemitter.reEmit(this.dehydratedDeviceManager,[I.DehydratedDeviceCreated,I.DehydratedDeviceUploaded,I.RehydrationStarted,I.RehydrationProgress,I.RehydrationCompleted,I.RehydrationError,I.DehydrationKeyCached,I.DehydratedDeviceRotationError]),this.crossSigningIdentity=new Yc(t,this.outgoingRequestProcessor,o),this.checkKeyBackupAndEnable()}getOlmMachineOrThrow(){if(this.stopped)throw new Zi;return this.olmMachine}set globalErrorOnUnknownDevices(e){}get globalErrorOnUnknownDevices(){return!1}stop(){this.stopped||(this.stopped=!0,this.keyClaimManager.stop(),this.backupManager.stop(),this.outgoingRequestsManager.stop(),this.perSessionBackupDownloader.stop(),this.dehydratedDeviceManager.stop(),this.olmMachine.close())}encryptEvent(e,t){var r=this;return c(function*(){var s=e.getRoomId(),_=r.roomEncryptors[s];if(!_)throw new Error("Cannot encrypt event in unconfigured room ".concat(s));yield _.encryptEvent(e,r.globalBlacklistUnverifiedDevices,r.deviceIsolationMode)})()}decryptEvent(e){var t=this;return c(function*(){var r=e.getRoomId();if(!r)throw new Error("to-device event was not decrypted in preprocessToDeviceMessages");return yield t.eventDecryptor.attemptEventDecryption(e,t.deviceIsolationMode)})()}getBackupDecryptor(e,t){var r=this;return c(function*(){if(!(t instanceof Uint8Array))throw new Error("getBackupDecryptor: expects Uint8Array");if(e.algorithm!="m.megolm_backup.v1.curve25519-aes-sha2")throw new Error("getBackupDecryptor: Unsupported algorithm ".concat(e.algorithm));var s=V.fromBase64(Zt(t));if(!Nr(s,e))throw new Error("getBackupDecryptor: key backup on server does not match the decryption key");return r.backupManager.createBackupDecryptor(s)})()}importBackedUpRoomKeys(e,t,r){var s=this;return c(function*(){return yield s.backupManager.importBackedUpRoomKeys(e,t,r)})()}getVersion(){var e=bn();return"Rust SDK ".concat(e.matrix_sdk_crypto," (").concat(e.git_sha,"), Vodozemac ").concat(e.vodozemac)}setDeviceIsolationMode(e){this.deviceIsolationMode=e}isEncryptionEnabledInRoom(e){var t=this;return c(function*(){var r=yield t.olmMachine.getRoomSettings(new C(e));return!!(r!=null&&r.algorithm)})()}getOwnDeviceKeys(){var e=this;return c(function*(){var t=e.olmMachine.identityKeys;return{ed25519:t.ed25519.toBase64(),curve25519:t.curve25519.toBase64()}})()}prepareToEncrypt(e){var t=this.roomEncryptors[e.roomId];t&&t.prepareForEncryption(this.globalBlacklistUnverifiedDevices,this.deviceIsolationMode)}forceDiscardSession(e){var t;return(t=this.roomEncryptors[e])===null||t===void 0?void 0:t.forceDiscardSession()}exportRoomKeys(){var e=this;return c(function*(){var t=yield e.olmMachine.exportRoomKeys(()=>!0);return JSON.parse(t)})()}exportRoomKeysAsJson(){var e=this;return c(function*(){return yield e.olmMachine.exportRoomKeys(()=>!0)})()}importRoomKeys(e,t){var r=this;return c(function*(){return yield r.backupManager.importRoomKeys(e,t)})()}importRoomKeysAsJson(e,t){var r=this;return c(function*(){return yield r.backupManager.importRoomKeysAsJson(e,t)})()}userHasCrossSigningKeys(){var e=arguments,t=this;return c(function*(){var r=e.length>0&&e[0]!==void 0?e[0]:t.userId,s=e.length>1&&e[1]!==void 0?e[1]:!1,_=yield t.olmMachine.trackedUsers(),o;for(var a of _)if(r===a.toString()){o=a;break}if(o!==void 0){if(r===t.userId){var g=t.olmMachine.queryKeysForUsers([o.clone()]);yield t.outgoingRequestProcessor.makeOutgoingRequest(g)}var l=yield t.olmMachine.getIdentity(o);return l==null||l.free(),l!==void 0}else if(s){var y,h=yield t.downloadDeviceList(new Set([r])),m=(y=h.master_keys)===null||y===void 0?void 0:y[r];return m?!!Object.values(m.keys)[0]:!1}else return!1})()}getUserDeviceInfo(e){var t=arguments,r=this;return c(function*(){var s=t.length>1&&t[1]!==void 0?t[1]:!1,_=new Map,o=yield r.getOlmMachineOrThrow().trackedUsers(),a=new Set;o.forEach(h=>a.add(h.toString()));var g=new Set;for(var l of e)a.has(l)?_.set(l,yield r.getUserDevices(l)):g.add(l);if(s&&g.size>=1){var y=yield r.downloadDeviceList(g);Object.entries(y.device_keys).forEach(h=>{var[m,K]=h;return _.set(m,Qc(K))})}return _})()}getUserDevices(e){var t=this;return c(function*(){var r=new f(e),s=yield t.olmMachine.getUserDevices(r,1);try{var _=s.devices();try{return new Map(_.map(o=>[o.deviceId.toString(),Jc(o,r)]))}finally{_.forEach(o=>o.free())}}finally{s.free()}})()}downloadDeviceList(e){var t=this;return c(function*(){var r={device_keys:{}};return e.forEach(s=>r.device_keys[s]=[]),yield t.http.authedRequest(M.Post,"/_matrix/client/v3/keys/query",void 0,r,{prefix:""})})()}getTrustCrossSignedDevices(){return this._trustCrossSignedDevices}setTrustCrossSignedDevices(e){this._trustCrossSignedDevices=e}setDeviceVerified(e,t){var r=arguments,s=this;return c(function*(){var _=r.length>2&&r[2]!==void 0?r[2]:!0,o=yield s.olmMachine.getDevice(new f(e),new O(t));if(!o)throw new Error("Unknown device ".concat(e,"|").concat(t));try{yield o.setLocalTrust(_?nr.Verified:nr.Unset)}finally{o.free()}})()}crossSignDevice(e){var t=this;return c(function*(){var r=yield t.olmMachine.getDevice(new f(t.userId),new O(e));if(!r)throw new Error("Unknown device ".concat(e));try{var s=yield r.verify();yield t.outgoingRequestProcessor.makeOutgoingRequest(s)}finally{r.free()}})()}getDeviceVerificationStatus(e,t){var r=this;return c(function*(){var s=yield r.olmMachine.getDevice(new f(e),new O(t));if(!s)return null;try{return new Xi({signedByOwner:s.isCrossSignedByOwner(),crossSigningVerified:s.isCrossSigningTrusted(),localVerified:s.isLocallyTrusted(),trustCrossSignedDevices:r._trustCrossSignedDevices})}finally{s.free()}})()}getUserVerificationStatus(e){var t=this;return c(function*(){var r=yield t.getOlmMachineOrThrow().getIdentity(new f(e));if(r===void 0)return new gn(!1,!1,!1);var s=r.isVerified(),_=r.wasPreviouslyVerified(),o=r instanceof je?r.identityNeedsUserApproval():!1;return r.free(),new gn(s,_,!1,o)})()}pinCurrentUserIdentity(e){var t=this;return c(function*(){var r=yield t.getOlmMachineOrThrow().getIdentity(new f(e));if(r===void 0)throw new Error("Cannot pin identity of unknown user");if(r instanceof xe)throw new Error("Cannot pin identity of own user");yield r.pinCurrentMasterKey()})()}withdrawVerificationRequirement(e){var t=this;return c(function*(){var r=yield t.getOlmMachineOrThrow().getIdentity(new f(e));if(r===void 0)throw new Error("Cannot withdraw verification of unknown user");yield r.withdrawVerification()})()}isCrossSigningReady(){var e=this;return c(function*(){var{privateKeysInSecretStorage:t,privateKeysCachedLocally:r}=yield e.getCrossSigningStatus(),s=!!r.masterKey&&!!r.selfSigningKey&&!!r.userSigningKey,_=yield e.getOwnIdentity();return!!(_!=null&&_.isVerified())&&(s||t)})()}getCrossSigningKeyId(){var e=arguments,t=this;return c(function*(){var r=e.length>0&&e[0]!==void 0?e[0]:ot.Master,s=yield t.olmMachine.getIdentity(new f(t.userId));if(!s)return null;try{var _=yield t.olmMachine.crossSigningStatus(),o=_.hasMaster&&_.hasUserSigning&&_.hasSelfSigning;if(!o||!s.isVerified())return null;var a;switch(r){case ot.Master:a=s.masterKey;break;case ot.SelfSigning:a=s.selfSigningKey;break;case ot.UserSigning:a=s.userSigningKey;break;default:return null}var g=JSON.parse(a);return Object.values(g.keys)[0]}finally{s.free()}})()}bootstrapCrossSigning(e){var t=this;return c(function*(){yield t.crossSigningIdentity.bootstrapCrossSigning(e)})()}isSecretStorageReady(){var e=this;return c(function*(){var t=["m.cross_signing.master","m.cross_signing.user_signing","m.cross_signing.self_signing"],r=(yield e.backupManager.getActiveBackupVersion())!=null;return r&&t.push("m.megolm_backup.v1"),Oi(e.secretStorage,t)})()}bootstrapSecretStorage(){var e=arguments,t=this;return c(function*(){var{createSecretStorageKey:r,setupNewSecretStorage:s,setupNewKeyBackup:_}=e.length>0&&e[0]!==void 0?e[0]:{},o=s||!(yield t.secretStorageHasAESKey());if(o){if(!r)throw new Error("unable to create a new secret storage key, createSecretStorageKey is not set");t.logger.info("bootstrapSecretStorage: creating new secret storage key");var a=yield r();if(!a)throw new Error("createSecretStorageKey() callback did not return a secret storage key");yield t.addSecretStorageKeyToSecretStorage(a)}var g=yield t.olmMachine.exportCrossSigningKeys(),l=g&&g.masterKey!==void 0&&g.self_signing_key!==void 0&&g.userSigningKey!==void 0;l&&(o||!(yield Ci(t.secretStorage)))&&(t.logger.info("bootstrapSecretStorage: cross-signing keys not yet exported; doing so now."),yield t.secretStorage.store("m.cross_signing.master",g.masterKey),yield t.secretStorage.store("m.cross_signing.user_signing",g.userSigningKey),yield t.secretStorage.store("m.cross_signing.self_signing",g.self_signing_key)),_?yield t.resetKeyBackup():yield t.saveBackupKeyToStorage()})()}saveBackupKeyToStorage(){var e=this;return c(function*(){var t=yield e.backupManager.getServerBackupInfo();if(!t||!t.version){k.info("Not saving backup key to secret storage: no backup info");return}var r=yield e.olmMachine.getBackupKeys();if(!r.decryptionKey){k.info("Not saving backup key to secret storage: no backup key");return}if(!Nr(r.decryptionKey,t)){k.info("Not saving backup key to secret storage: decryption key does not match backup info");return}var s=r.decryptionKey.toBase64();yield e.secretStorage.store("m.megolm_backup.v1",s)})()}addSecretStorageKeyToSecretStorage(e){var t=this;return c(function*(){var r,s,_,o,a=yield t.secretStorage.addKey(un,{passphrase:(r=e.keyInfo)===null||r===void 0?void 0:r.passphrase,name:(s=e.keyInfo)===null||s===void 0?void 0:s.name,key:e.privateKey});yield t.secretStorage.setDefaultKeyId(a.keyId),(_=(o=t.cryptoCallbacks).cacheSecretStorageKey)===null||_===void 0||_.call(o,a.keyId,a.keyInfo,e.privateKey)})()}secretStorageHasAESKey(){var e=this;return c(function*(){var t=yield e.secretStorage.getKey();if(!t)return!1;var[,r]=t;return r.algorithm===un})()}getCrossSigningStatus(){var e=this;return c(function*(){var t=yield e.getOlmMachineOrThrow().getIdentity(new f(e.userId)),r=!!(t!=null&&t.masterKey)&&!!(t!=null&&t.selfSigningKey)&&!!(t!=null&&t.userSigningKey);t==null||t.free();var s=yield Ci(e.secretStorage),_=yield e.getOlmMachineOrThrow().crossSigningStatus();return{publicKeysOnDevice:r,privateKeysInSecretStorage:s,privateKeysCachedLocally:{masterKey:!!(_!=null&&_.hasMaster),userSigningKey:!!(_!=null&&_.hasUserSigning),selfSigningKey:!!(_!=null&&_.hasSelfSigning)}}})()}createRecoveryKeyFromPassphrase(e){var t=this;return c(function*(){if(e){var r=dn(32),s=yield cn(e,r,t.RECOVERY_KEY_DERIVATION_ITERATIONS);return{keyInfo:{passphrase:{algorithm:"m.pbkdf2",iterations:t.RECOVERY_KEY_DERIVATION_ITERATIONS,salt:r}},privateKey:s,encodedPrivateKey:ln(s)}}else{var _=new Uint8Array(32);return globalThis.crypto.getRandomValues(_),{privateKey:_,encodedPrivateKey:ln(_)}}})()}getEncryptionInfoForEvent(e){var t=this;return c(function*(){return t.eventDecryptor.getEncryptionInfoForEvent(e)})()}getVerificationRequestsToDeviceInProgress(e){var t=this.olmMachine.getVerificationRequests(new f(e));return t.filter(r=>r.roomId===void 0).map(r=>new de(this.olmMachine,r,this.outgoingRequestProcessor,this._supportedVerificationMethods))}findVerificationRequestDMInProgress(e,t){if(!t)throw new Error("missing userId");var r=this.olmMachine.getVerificationRequests(new f(t)),s=r.find(_=>{var o;return((o=_.roomId)===null||o===void 0?void 0:o.toString())===e});if(s)return new de(this.olmMachine,s,this.outgoingRequestProcessor,this._supportedVerificationMethods)}requestVerificationDM(e,t){var r=this;return c(function*(){var s=yield r.olmMachine.getIdentity(new f(e));if(!s)throw new Error("unknown userId ".concat(e));try{var _=r._supportedVerificationMethods.map(l=>yt(l)),o=yield s.verificationRequestContent(_),a=yield r.sendVerificationRequestContent(t,o),g=yield s.requestVerification(new C(t),new yr(a),_);return new de(r.olmMachine,g,r.outgoingRequestProcessor,r._supportedVerificationMethods)}finally{s.free()}})()}sendVerificationRequestContent(e,t){var r=this;return c(function*(){var s=dn(32),{event_id:_}=yield r.http.authedRequest(M.Put,"/_matrix/client/v3/rooms/".concat(encodeURIComponent(e),"/send/m.room.message/").concat(encodeURIComponent(s)),void 0,t,{prefix:""});return _})()}setSupportedVerificationMethods(e){this._supportedVerificationMethods=e??Ai}requestOwnUserVerification(){var e=this;return c(function*(){var t=yield e.olmMachine.getIdentity(new f(e.userId));if(t===void 0)throw new Error("cannot request verification for this device when there is no existing cross-signing key");try{var[r,s]=yield t.requestVerification(e._supportedVerificationMethods.map(yt));return yield e.outgoingRequestProcessor.makeOutgoingRequest(s),new de(e.olmMachine,r,e.outgoingRequestProcessor,e._supportedVerificationMethods)}finally{t.free()}})()}requestDeviceVerification(e,t){var r=this;return c(function*(){var s=yield r.olmMachine.getDevice(new f(e),new O(t));if(!s)throw new Error("Not a known device");try{var[_,o]=s.requestVerification(r._supportedVerificationMethods.map(yt));return yield r.outgoingRequestProcessor.makeOutgoingRequest(o),new de(r.olmMachine,_,r.outgoingRequestProcessor,r._supportedVerificationMethods)}finally{s.free()}})()}getSessionBackupPrivateKey(){var e=this;return c(function*(){var t=yield e.olmMachine.getBackupKeys();return t.decryptionKey?$t(t.decryptionKey.toBase64()):null})()}storeSessionBackupPrivateKey(e,t){var r=this;return c(function*(){var s=Zt(e);if(!t)throw new Error("storeSessionBackupPrivateKey: version is required");yield r.backupManager.saveBackupDecryptionKey(V.fromBase64(s),t)})()}loadSessionBackupPrivateKeyFromSecretStorage(){var e=this;return c(function*(){var t=yield e.secretStorage.get("m.megolm_backup.v1");if(!t)throw new Error("loadSessionBackupPrivateKeyFromSecretStorage: missing decryption key in secret storage");var r=yield e.backupManager.getServerBackupInfo();if(!r||!r.version)throw new Error("loadSessionBackupPrivateKeyFromSecretStorage: unable to get backup version");var s=V.fromBase64(t);if(!Nr(s,r))throw new Error("loadSessionBackupPrivateKeyFromSecretStorage: decryption key does not match backup info");yield e.backupManager.saveBackupDecryptionKey(s,r.version)})()}getActiveSessionBackupVersion(){var e=this;return c(function*(){return yield e.backupManager.getActiveBackupVersion()})()}getKeyBackupInfo(){var e=this;return c(function*(){return(yield e.backupManager.getServerBackupInfo())||null})()}isKeyBackupTrusted(e){var t=this;return c(function*(){return yield t.backupManager.isKeyBackupTrusted(e)})()}checkKeyBackupAndEnable(){var e=this;return c(function*(){return yield e.backupManager.checkKeyBackupAndEnable(!0)})()}deleteKeyBackupVersion(e){var t=this;return c(function*(){yield t.backupManager.deleteKeyBackupVersion(e)})()}resetKeyBackup(){var e=this;return c(function*(){var t=yield e.backupManager.setupKeyBackup(r=>e.signObject(r));(yield e.secretStorageHasAESKey())&&(yield e.secretStorage.store("m.megolm_backup.v1",t.decryptionKey.toBase64())),e.checkKeyBackupAndEnable()})()}disableKeyStorage(){var e=this;return c(function*(){var t=yield e.getKeyBackupInfo();t!=null&&t.version?yield e.deleteKeyBackupVersion(t.version):k.error("Can't delete key backup version: no version available"),yield e.deleteSecretStorage(),yield e.dehydratedDeviceManager.delete()})()}signObject(e){var t=this;return c(function*(){var r=new Map(Object.entries(e.signatures||{})),s=e.unsigned;delete e.signatures,delete e.unsigned;var _=r.get(t.userId)||{},o=Ac.stringify(e),a=yield t.olmMachine.sign(o),g=JSON.parse(a.asJSON());r.set(t.userId,Ti(Ti({},_),g[t.userId])),s!==void 0&&(e.unsigned=s),e.signatures=Object.fromEntries(r.entries())})()}restoreKeyBackupWithPassphrase(e,t){var r=this;return c(function*(){var s=yield r.backupManager.getServerBackupInfo();if(!(s!=null&&s.version))throw new Error("No backup info available");var _=yield rg(s.auth_data,e);return yield r.storeSessionBackupPrivateKey(_,s.version),r.restoreKeyBackup(t)})()}restoreKeyBackup(e){var t=this;return c(function*(){var r=yield t.olmMachine.getBackupKeys(),{decryptionKey:s,backupVersion:_}=r;if(!s||!_)throw new Error("No decryption key found in crypto store");var o=$t(s.toBase64()),a=yield t.backupManager.requestKeyBackupVersion(_);if(!a)throw new Error("Backup version to restore ".concat(_," not found on server"));var g=yield t.getBackupDecryptor(a,o);try{var l;return e==null||(l=e.progressCallback)===null||l===void 0||l.call(e,{stage:Ke.Fetch}),yield t.backupManager.restoreKeyBackup(_,g,e)}finally{g.free()}})()}isDehydrationSupported(){var e=this;return c(function*(){return yield e.dehydratedDeviceManager.isSupported()})()}startDehydration(){var e=arguments,t=this;return c(function*(){var r=e.length>0&&e[0]!==void 0?e[0]:{};if(!(yield t.isCrossSigningReady())||!(yield t.isSecretStorageReady()))throw new Error("Device dehydration requires cross-signing and secret storage to be set up");return yield t.dehydratedDeviceManager.start(r||{})})()}importSecretsBundle(e){var t=this;return c(function*(){var r=oe.from_json(e);yield t.getOlmMachineOrThrow().importSecretsBundle(r)})()}exportSecretsBundle(){var e=this;return c(function*(){var t=yield e.getOlmMachineOrThrow().exportSecretsBundle(),r=t.to_json();return t.free(),r})()}encryptToDeviceMessages(e,t,r){var s=this;return c(function*(){var _=new tn(s.logger,"encryptToDeviceMessages"),o=new Set(t.map(g=>{var{userId:l}=g;return l}));yield s.keyClaimManager.ensureSessionsForUsers(_,Array.from(o).map(g=>new f(g)));var a={batch:[],eventType:A.RoomMessageEncrypted};return yield Promise.all(t.map(function(){var g=c(function*(l){var{userId:y,deviceId:h}=l,m=yield s.olmMachine.getDevice(new f(y),new O(h));if(m){var K=JSON.parse(yield m.encryptToDeviceEvent(e,r));a.batch.push({deviceId:h,userId:y,payload:K})}else s.logger.warn("encryptToDeviceMessages: unknown device ".concat(y,":").concat(h))});return function(l){return g.apply(this,arguments)}}())),a})()}resetEncryption(e){var t=this;return c(function*(){t.logger.debug("resetEncryption: resetting encryption"),t.dehydratedDeviceManager.delete(),yield t.backupManager.deleteAllKeyBackupVersions(),yield t.deleteSecretStorage(),yield t.crossSigningIdentity.bootstrapCrossSigning({setupNewCrossSigning:!0,authUploadDeviceSigningKeys:e}),yield t.resetKeyBackup(),t.logger.debug("resetEncryption: ended")})()}deleteSecretStorage(){var e=this;return c(function*(){yield e.secretStorage.store("m.cross_signing.master",null),yield e.secretStorage.store("m.cross_signing.self_signing",null),yield e.secretStorage.store("m.cross_signing.user_signing",null),yield e.secretStorage.store("m.megolm_backup.v1",null);var t=yield e.secretStorage.getDefaultKeyId();t&&(yield e.secretStorage.store("m.secret_storage.key.".concat(t),null)),yield e.secretStorage.setDefaultKeyId(null)})()}receiveSyncChanges(e){var t=this;return c(function*(){var{events:r,oneTimeKeysCounts:s=new Map,unusedFallbackKeys:_,devices:o=new lt}=e,a=yield W(k,"receiveSyncChanges",c(function*(){return yield t.olmMachine.receiveSyncChanges(r?JSON.stringify(r):"[]",o,s,_)}));return JSON.parse(a)})()}preprocessToDeviceMessages(e){var t=this;return c(function*(){var r=yield t.receiveSyncChanges({events:e});for(var s of r)if(s.type===A.KeyVerificationRequest){var _=s.sender,o=s.content.transaction_id;o&&_&&t.onIncomingKeyVerificationRequest(_,o)}return r})()}processKeyCounts(e,t){var r=this;return c(function*(){var s=e&&new Map(Object.entries(e)),_=t&&new Set(t);(s!==void 0||_!==void 0)&&(yield r.receiveSyncChanges({oneTimeKeysCounts:s,unusedFallbackKeys:_}))})()}processDeviceLists(e){var t=this;return c(function*(){var r,s,_=new lt((r=e.changed)===null||r===void 0?void 0:r.map(o=>new f(o)),(s=e.left)===null||s===void 0?void 0:s.map(o=>new f(o)));yield t.receiveSyncChanges({devices:_})})()}onCryptoEvent(e,t){var r=this;return c(function*(){var s=t.getContent(),_=new _e;if(s.algorithm==="m.megolm.v1.aes-sha2")_.algorithm=ue.MegolmV1AesSha2;else{r.logger.warn("Room ".concat(e.roomId,": ignoring crypto event with invalid algorithm ").concat(s.algorithm));return}try{_.sessionRotationPeriodMs=s.rotation_period_ms,_.sessionRotationPeriodMessages=s.rotation_period_msgs,yield r.olmMachine.setRoomSettings(new C(e.roomId),_)}catch(a){r.logger.warn("Room ".concat(e.roomId,": ignoring crypto event which caused error: ").concat(a));return}var o=r.roomEncryptors[e.roomId];o?o.onCryptoEvent(s):r.roomEncryptors[e.roomId]=new zc(r.olmMachine,r.keyClaimManager,r.outgoingRequestsManager,e,s)})()}onSyncCompleted(e){this.outgoingRequestsManager.doProcessOutgoingRequests().catch(t=>{this.logger.warn("onSyncCompleted: Error processing outgoing requests",t)})}markAllTrackedUsersAsDirty(){var e=this;return c(function*(){yield e.olmMachine.markAllTrackedUsersAsDirty()})()}onIncomingKeyVerificationRequest(e,t){var r=this.olmMachine.getVerificationRequest(new f(e),t);r?this.emit(I.VerificationRequestReceived,new de(this.olmMachine,r,this.outgoingRequestProcessor,this._supportedVerificationMethods)):this.logger.info("Ignoring just-received verification request ".concat(t," which did not start a rust-side verification"))}onRoomMembership(e,t,r){var s=this.roomEncryptors[e.getRoomId()];s&&s.onRoomMembership(t)}onRoomKeysUpdated(e){var t=this;return c(function*(){for(var r of e)t.onRoomKeyUpdated(r);t.backupManager.maybeUploadKey()})()}onRoomKeyUpdated(e){var t=this;if(!this.stopped){this.logger.debug("Got update for session ".concat(e.sessionId," from sender ").concat(e.senderKey.toBase64()," in ").concat(e.roomId.toString()));var r=this.eventDecryptor.getEventsPendingRoomKey(e.roomId.toString(),e.sessionId);if(r.length!==0){this.logger.debug("Retrying decryption on events:",r.map(o=>"".concat(o.getId())));var s=function(o){o.attemptDecryption(t,{isRetry:!0}).catch(a=>{t.logger.info("Still unable to decrypt event ".concat(o.getId()," after receiving key"))})};for(var _ of r)s(_)}}}onRoomKeysWithheld(e){var t=this;return c(function*(){for(var r of e){t.logger.debug("Got withheld message for session ".concat(r.sessionId," in ").concat(r.roomId.toString()));var s=t.eventDecryptor.getEventsPendingRoomKey(r.roomId.toString(),r.sessionId);if(s.length===0)return;t.logger.debug("Retrying decryption on events:",s.map(o=>"".concat(o.getId())));for(var _ of s)_.attemptDecryption(t,{isRetry:!0}).catch(o=>{})}})()}onUserIdentityUpdated(e){var t=this;return c(function*(){var r=yield t.getUserVerificationStatus(e.toString());t.emit(I.UserTrustStatusChanged,e.toString(),r),e.toString()===t.userId&&(t.emit(I.KeysChanged,{}),yield t.checkKeyBackupAndEnable())})()}onDevicesUpdated(e){var t=this;return c(function*(){t.emit(I.WillUpdateDevices,e,!1),t.emit(I.DevicesUpdated,e,!1)})()}handleSecretReceived(e,t){var r=this;return c(function*(){return r.logger.debug("onReceiveSecret: Received secret ".concat(e)),e==="m.megolm_backup.v1"?yield r.backupManager.handleBackupSecretReceived(t):!1})()}checkSecrets(e){var t=this;return c(function*(){var r=yield t.olmMachine.getSecretsFromInbox(e);for(var s of r)if(yield t.handleSecretReceived(e,s))break;yield t.olmMachine.deleteSecretsFromInbox(e)})()}onLiveEventFromSync(e){var t=this;return c(function*(){if(!(e.isState()||e.getUnsigned().transaction_id)){var r=function(){var a=c(function*(g){$c(e)&&(yield t.onKeyVerificationEvent(g))});return function(g){return a.apply(this,arguments)}}();if(e.isDecryptionFailure()||e.isEncrypted()){var s=3e5,_=setTimeout(()=>e.off(Xt.Decrypted,o),s),o=(a,g)=>{g||(clearTimeout(_),e.off(Xt.Decrypted,o),r(a))};e.on(Xt.Decrypted,o)}else yield r(e)}})()}onKeyVerificationEvent(e){var t=this;return c(function*(){var r=e.getRoomId();if(!r)throw new Error("missing roomId in the event");t.logger.debug("Incoming verification event ".concat(e.getId()," type ").concat(e.getType()," from ").concat(e.getSender())),yield t.olmMachine.receiveVerificationEvent(JSON.stringify({event_id:e.getId(),type:e.getType(),sender:e.getSender(),state_key:e.getStateKey(),content:e.getContent(),origin_server_ts:e.getTs()}),new C(r)),e.getType()===A.RoomMessage&&e.getContent().msgtype===on.KeyVerificationRequest&&t.onIncomingKeyVerificationRequest(e.getSender(),e.getId()),t.outgoingRequestsManager.doProcessOutgoingRequests().catch(s=>{t.logger.warn("onKeyVerificationRequest: Error processing outgoing requests",s)})})()}getOwnIdentity(){var e=this;return c(function*(){return yield e.olmMachine.getIdentity(new f(e.userId))})()}}class ig{constructor(e,t,r){this.logger=e,this.olmMachine=t,this.perSessionBackupDownloader=r,v(this,"eventsPendingKey",new pn(()=>new pn(()=>new Set)))}attemptEventDecryption(e,t){var r=this;return c(function*(){r.addEventToPendingList(e);var s;switch(t.kind){case nt.AllDevicesIsolationMode:s=_r.Untrusted;break;case nt.OnlySignedDevicesIsolationMode:s=_r.CrossSignedOrLegacy;break}try{var _=yield r.olmMachine.decryptRoomEvent(zi(e),new C(e.getRoomId()),new gr(s));return r.removeEventFromPendingList(e),{clearEvent:JSON.parse(_.event),claimedEd25519Key:_.senderClaimedEd25519Key,senderCurve25519Key:_.senderCurve25519Key,forwardingCurve25519KeyChain:_.forwardingCurve25519KeyChain}}catch(o){if(o instanceof ze)r.onMegolmDecryptionError(e,o,yield r.perSessionBackupDownloader.getServerBackupInfo());else throw new z(P.UNKNOWN_ERROR,"Unknown error")}})()}onMegolmDecryptionError(e,t,r){var s=e.getWireContent(),_={sender_key:s.sender_key,session_id:s.session_id};if(t.code===$.MissingRoomKey||t.code===$.UnknownMessageIndex){this.perSessionBackupDownloader.onDecryptionKeyMissingError(e.getRoomId(),s.session_id);var o=e.getMembershipAtEvent();if(o&&o!==rt.Join&&o!==rt.Invite)throw new z(P.HISTORICAL_MESSAGE_USER_NOT_JOINED,"This message was sent when we were not a member of the room.",_);if(e.getTs()<=this.olmMachine.deviceCreationTimeMs)throw r===null?new z(P.HISTORICAL_MESSAGE_NO_KEY_BACKUP,"This message was sent before this device logged in, and there is no key backup on the server.",_):this.perSessionBackupDownloader.isKeyBackupDownloadConfigured()?new z(P.HISTORICAL_MESSAGE_WORKING_BACKUP,"This message was sent before this device logged in. Key backup is working, but we still do not (yet) have the key.",_):new z(P.HISTORICAL_MESSAGE_BACKUP_UNCONFIGURED,"This message was sent before this device logged in, and key backup is not working.",_)}if(t.maybe_withheld){var a=t.maybe_withheld==="The sender has disabled encrypting to unverified devices."?P.MEGOLM_KEY_WITHHELD_FOR_UNVERIFIED_DEVICE:P.MEGOLM_KEY_WITHHELD;throw new z(a,t.maybe_withheld,_)}switch(t.code){case $.MissingRoomKey:throw new z(P.MEGOLM_UNKNOWN_INBOUND_SESSION_ID,"The sender's device has not sent us the keys for this message.",_);case $.UnknownMessageIndex:throw new z(P.OLM_UNKNOWN_MESSAGE_INDEX,"The sender's device has not sent us the keys for this message at this index.",_);case $.SenderIdentityVerificationViolation:throw this.removeEventFromPendingList(e),new z(P.SENDER_IDENTITY_PREVIOUSLY_VERIFIED,"The sender identity is unverified, but was previously verified.");case $.UnknownSenderDevice:throw this.removeEventFromPendingList(e),new z(P.UNKNOWN_SENDER_DEVICE,"The sender device is not known.");case $.UnsignedSenderDevice:throw this.removeEventFromPendingList(e),new z(P.UNSIGNED_SENDER_DEVICE,"The sender identity is not cross-signed.");default:throw new z(P.UNKNOWN_ERROR,t.description,_)}}getEncryptionInfoForEvent(e){var t=this;return c(function*(){if(!e.getClearContent()||e.isDecryptionFailure())return null;if(e.status!==null)return{shieldColour:at.NONE,shieldReason:null};var r=yield t.olmMachine.getRoomEventEncryptionInfo(zi(e),new C(e.getRoomId()));return sg(t.logger,r)})()}getEventsPendingRoomKey(e,t){var r=this.eventsPendingKey.get(e);if(!r)return[];var s=r.get(t);return s?[...s]:[]}addEventToPendingList(e){var t=e.getRoomId();if(t){var r=this.eventsPendingKey.getOrCreate(t),s=r.getOrCreate(e.getWireContent().session_id);s.add(e)}}removeEventFromPendingList(e){var t=e.getRoomId();if(t){var r=this.eventsPendingKey.getOrCreate(t);if(r){var s=r.get(e.getWireContent().session_id);s&&(s.delete(e),s.size===0&&(r.delete(e.getWireContent().session_id),r.size===0&&this.eventsPendingKey.delete(t)))}}}}function zi(i){return JSON.stringify({event_id:i.getId(),type:i.getWireType(),sender:i.getSender(),state_key:i.getStateKey(),content:i.getWireContent(),origin_server_ts:i.getTs()})}function sg(i,e){if(e===void 0)return null;var t=e.shieldState(!1),r;switch(t.color){case sr.Grey:r=at.GREY;break;case sr.None:r=at.NONE;break;default:r=at.RED}var s;switch(t.code){case void 0:case null:s=null;break;case ne.AuthenticityNotGuaranteed:s=ae.AUTHENTICITY_NOT_GUARANTEED;break;case ne.UnknownDevice:s=ae.UNKNOWN_DEVICE;break;case ne.UnsignedDevice:s=ae.UNSIGNED_DEVICE;break;case ne.UnverifiedIdentity:s=ae.UNVERIFIED_IDENTITY;break;case ne.SentInClear:s=ae.SENT_IN_CLEAR;break;case ne.VerificationViolation:s=ae.VERIFICATION_VIOLATION;break}return{shieldColour:r,shieldReason:s}}function _g(i){return jr.apply(this,arguments)}function jr(){return jr=c(function*(i){var e,{logger:t,legacyStore:r}=i;if(yield Si(),new Er(ir.Debug).turnOn(),!(yield r.containsData()))return;yield r.startup();var s=null;if(yield r.doTxn("readonly",[Ie.STORE_ACCOUNT],m=>{r.getAccount(m,K=>{s=K})}),!s){t.debug("Legacy crypto store is not set up (no account found). Not migrating.");return}var _=yield r.getMigrationState();if(_>=j.MEGOLM_SESSIONS_MIGRATED)return;var o=yield ag(t,r),a=yield cg(t,r),g=1+o+a;t.info("Migrating data from legacy crypto store. ".concat(o," olm sessions and ").concat(a," megolm sessions to migrate."));var l=0;function y(m){var K;l+=m,(K=i.legacyMigrationProgressListener)===null||K===void 0||K.call(i,l,g)}y(0);var h=new TextEncoder().encode(i.legacyPickleKey);_===j.NOT_STARTED&&(t.info("Migrating data from legacy crypto store. Step 1: base data"),yield og(i.http,i.userId,i.deviceId,r,h,i.storeHandle,t),_=j.INITIAL_DATA_MIGRATED,yield r.setMigrationState(_)),y(1),_===j.INITIAL_DATA_MIGRATED&&(t.info("Migrating data from legacy crypto store. Step 2: olm sessions (".concat(o," sessions to migrate).")),yield gg(t,r,h,i.storeHandle,y),_=j.OLM_SESSIONS_MIGRATED,yield r.setMigrationState(_)),_===j.OLM_SESSIONS_MIGRATED&&(t.info("Migrating data from legacy crypto store. Step 3: megolm sessions (".concat(a," sessions to migrate).")),yield ug(t,r,h,i.storeHandle,y),_=j.MEGOLM_SESSIONS_MIGRATED,yield r.setMigrationState(_)),(e=i.legacyMigrationProgressListener)===null||e===void 0||e.call(i,-1,-1),t.info("Migration from legacy crypto store complete")}),jr.apply(this,arguments)}function og(i,e,t,r,s,_,o){return xr.apply(this,arguments)}function xr(){return xr=c(function*(i,e,t,r,s,_,o){var a=new ar;a.userId=new f(e),a.deviceId=new O(t),yield r.doTxn("readonly",[Ie.STORE_ACCOUNT],H=>r.getAccount(H,Qt=>{a.pickledAccount=Qt??""}));var g=yield ht(r,s,"m.megolm_backup.v1");if(g){for(var l=!1,y=null;!l;)try{y=yield Ui(i),l=!0}catch(H){o.info("Failed to get backup version during migration, retrying in 2 seconds",H),yield te(2e3)}if(y&&y.algorithm=="m.megolm_backup.v1.curve25519-aes-sha2")try{var h,m=V.fromBase64(g),K=(h=y.auth_data)===null||h===void 0?void 0:h.public_key,B=m.megolmV1PublicKey.publicKeyBase64==K;B?(a.backupVersion=y.version,a.backupRecoveryKey=g):o.debug("The backup key to migrate does not match the active backup version","Cached pub key: ".concat(m.megolmV1PublicKey.publicKeyBase64),"Active pub key: ".concat(K))}catch(H){o.warn("Failed to check if the backup key to migrate matches the active backup version",H)}}a.privateCrossSigningMasterKey=yield ht(r,s,"master"),a.privateCrossSigningSelfSigningKey=yield ht(r,s,"self_signing"),a.privateCrossSigningUserSigningKey=yield ht(r,s,"user_signing"),yield pt.migrateBaseData(a,s,_)}),xr.apply(this,arguments)}function ag(i,e){return Lr.apply(this,arguments)}function Lr(){return Lr=c(function*(i,e){i.debug("Counting olm sessions to be migrated");var t;return yield e.doTxn("readonly",[Ie.STORE_SESSIONS],r=>e.countEndToEndSessions(r,s=>t=s)),t}),Lr.apply(this,arguments)}function cg(i,e){return Wr.apply(this,arguments)}function Wr(){return Wr=c(function*(i,e){return i.debug("Counting megolm sessions to be migrated"),yield e.countEndToEndInboundGroupSessions()}),Wr.apply(this,arguments)}function gg(i,e,t,r,s){return Gr.apply(this,arguments)}function Gr(){return Gr=c(function*(i,e,t,r,s){for(;;){var _=yield e.getEndToEndSessionsBatch();if(_===null)return;i.debug("Migrating batch of ".concat(_.length," olm sessions"));var o=[];for(var a of _){var g=new We;g.senderKey=a.deviceKey,g.pickle=a.session,g.lastUseTime=g.creationTime=new Date(a.lastReceivedMessageTs),o.push(g)}yield pt.migrateOlmSessions(o,t,r),yield e.deleteEndToEndSessionsBatch(_),s(_.length)}}),Gr.apply(this,arguments)}function ug(i,e,t,r,s){return Jr.apply(this,arguments)}function Jr(){return Jr=c(function*(i,e,t,r,s){for(;;){var _=yield e.getEndToEndInboundGroupSessionsBatch();if(_===null)return;i.debug("Migrating batch of ".concat(_.length," megolm sessions"));var o=[];for(var a of _){var g,l=a.sessionData,y=new Le;y.pickle=l.session,y.roomId=new C(l.room_id),y.senderKey=a.senderKey,y.senderSigningKey=(g=l.keysClaimed)===null||g===void 0?void 0:g.ed25519,y.backedUp=!a.needsBackup,y.imported=l.untrusted===!0,o.push(y)}yield pt.migrateMegolmSessions(o,t,r),yield e.deleteEndToEndInboundGroupSessionsBatch(_),s(_.length)}}),Jr.apply(this,arguments)}function dg(i){return Qr.apply(this,arguments)}function Qr(){return Qr=c(function*(i){var{logger:e,legacyStore:t,olmMachine:r}=i;if(yield t.containsData()){var s=yield t.getMigrationState();if(!(s>=j.ROOM_SETTINGS_MIGRATED)){var _={};yield t.doTxn("readwrite",[Ie.STORE_ROOMS],l=>{t.getEndToEndRooms(l,y=>{_=y})}),e.debug("Migrating ".concat(Object.keys(_).length," sets of room settings"));for(var[o,a]of Object.entries(_))try{var g=new _e;if(a.algorithm!=="m.megolm.v1.aes-sha2"){e.warn("Room ".concat(o,": ignoring room with invalid algorithm ").concat(a.algorithm));continue}g.algorithm=ue.MegolmV1AesSha2,g.sessionRotationPeriodMs=a.rotation_period_ms,g.sessionRotationPeriodMessages=a.rotation_period_msgs,yield r.setRoomSettings(new C(o),g)}catch(l){e.warn("Room ".concat(o,": ignoring settings ").concat(JSON.stringify(a)," which caused error ").concat(l))}e.debug("Completed room settings migration"),yield t.setMigrationState(j.ROOM_SETTINGS_MIGRATED)}}}),Qr.apply(this,arguments)}function ht(i,e,t){return Hr.apply(this,arguments)}function Hr(){return Hr=c(function*(i,e,t){var r=yield new Promise(s=>{i.doTxn("readonly",[Ie.STORE_ACCOUNT],_=>{i.getSecretStorePrivateKey(_,s,t)})});return r&&r.ciphertext&&r.iv&&r.mac?yield es(r,e,t):r instanceof Uint8Array?Zt(r):void 0}),Hr.apply(this,arguments)}function lg(i){return Yr.apply(this,arguments)}function Yr(){return Yr=c(function*(i){var{legacyCryptoStore:e,rustCrypto:t,logger:r}=i,s=yield t.getOwnIdentity();if(s&&!s.isVerified()){var _=yield pg(e);if(_){var o=JSON.parse(s.masterKey);if(!o.keys||Object.keys(o.keys).length===0){r.error("Post Migration | Unexpected error: no master key in the rust session.");return}var a=Object.values(o.keys)[0];a&&a==_&&(r.info("Post Migration: Migrating legacy trusted MSK: ".concat(_," to locally verified.")),yield s.verify())}}}),Yr.apply(this,arguments)}function pg(i){return $r.apply(this,arguments)}function $r(){return $r=c(function*(i){var e=null;return yield i.doTxn("readonly","account",t=>{i.getCrossSigningKeys(t,r=>{var s=r==null?void 0:r.master;s&&Object.keys(s.keys).length!=0&&(e=Object.values(s.keys)[0])})}),e}),$r.apply(this,arguments)}function Ni(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,r)}return t}function wg(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ni(Object(t),!0).forEach(function(r){v(i,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):Ni(Object(t)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(t,r))})}return i}function yg(i){return Zr.apply(this,arguments)}function Zr(){return Zr=c(function*(i){var{logger:e}=i;e.debug("Initialising Rust crypto-sdk WASM artifact"),yield Si(),new Er(ir.Debug).turnOn(),e.debug("Opening Rust CryptoStore");var t;i.storePrefix?i.storeKey?t=yield x.openWithKey(i.storePrefix,i.storeKey):t=yield x.open(i.storePrefix,i.storePassphrase):t=yield x.open(),i.legacyCryptoStore&&(yield _g(wg({legacyStore:i.legacyCryptoStore,storeHandle:t},i)));var r=yield bg(e,i.http,i.userId,i.deviceId,i.secretStorage,i.cryptoCallbacks,t,i.legacyCryptoStore);return t.free(),e.debug("Completed rust crypto-sdk setup"),r}),Zr.apply(this,arguments)}function bg(i,e,t,r,s,_,o,a){return Xr.apply(this,arguments)}function Xr(){return Xr=c(function*(i,e,t,r,s,_,o,a){i.debug("Init OlmMachine");var g=yield Ne.initFromStore(new f(t),new O(r),o);a&&(yield dg({logger:i,legacyStore:a,olmMachine:g})),g.roomKeyRequestsEnabled=!1;var l=new ng(i,g,e,t,r,s,_);if(yield g.registerRoomKeyUpdatedCallback(m=>l.onRoomKeysUpdated(m)),yield g.registerRoomKeysWithheldCallback(m=>l.onRoomKeysWithheld(m)),yield g.registerUserIdentityUpdatedCallback(m=>l.onUserIdentityUpdated(m)),yield g.registerDevicesUpdatedCallback(m=>l.onDevicesUpdated(m)),l.checkSecrets("m.megolm_backup.v1"),yield g.registerReceiveSecretCallback((m,K)=>l.checkSecrets(m)),yield g.outgoingRequests(),a&&(yield a.containsData())){var y=yield a.getMigrationState();if(y<j.INITIAL_OWN_KEY_QUERY_DONE){i.debug("Performing initial key query after migration");for(var h=!1;!h;)try{yield l.userHasCrossSigningKeys(t),h=!0}catch(m){i.error("Failed to check for cross-signing keys after migration, retrying",m)}yield lg({legacyCryptoStore:a,rustCrypto:l,logger:i}),yield a.setMigrationState(j.INITIAL_OWN_KEY_QUERY_DONE)}}return l}),Xr.apply(this,arguments)}export{yg as initRustCrypto};