commit 6e3bdb251287d66548c583ab7d3c70ad6143481b
parent 4bf1647594d445a2856c466588c30d3438953e38
Author: MTRNord <MTRNord@users.noreply.github.com>
Date: Tue, 19 Apr 2022 17:51:17 +0000
deploy: MTRNord/matrix-art@5a2cea08f74d94d24aa05e010a4542760a81b0c3
Diffstat:
7 files changed, 49 insertions(+), 30 deletions(-)
diff --git a/pr-121/assets/Join.c7410601.js b/pr-121/assets/Join.c7410601.js
@@ -1 +0,0 @@
-import{E as h,$ as u}from"./vendor.d4008ec4.js";import{j as r,a as t,H as g,C as p}from"./index.fcbee31f.js";const l="inline-block p-4 w-full text-gray-900 bg-gray-100 hover:ring-blue-300 hover:ring-1 focus:ring-transparent focus:outline-none dark:bg-gray-700 dark:text-white",d="inline-block p-4 w-full bg-white hover:text-gray-700 hover:bg-gray-50 hover:ring-blue-300 hover:ring-1 focus:ring-transparent focus:outline-none dark:hover:text-white dark:bg-gray-800 dark:hover:bg-gray-700";class f extends h{constructor(){super();this.state={homeserver:"https://art.midnightthoughts.space",username:"",password:"",create_profile:!0,current_tab:"login"}}async onSubmit(s){s.preventDefault();const e=this.context;!e||this.state.homeserver===""||this.state.username===""||this.state.password===""||(this.state.current_tab==="login"&&!(e!=null&&e.isLoggedIn())?await e.login(this.state.homeserver,this.state.username,this.state.password,this.state.create_profile):this.state.current_tab==="register"&&!e.isLoggedIn()&&await e.register(this.state.homeserver,this.state.username,this.state.password,this.state.create_profile),u("/",!0))}onInput(s){s.preventDefault();const e=s.target,n=e.type==="checkbox"?e.checked:e.value,a=e.name;this.setState({[a]:n})}render(s,{homeserver:e,username:n,password:a,create_profile:c,current_tab:o}){return r("div",{class:"flex flex-col",children:[t("header",{children:t(g,{})}),r("main",{class:"m-12 mt-6",children:[t("h1",{class:"text-3xl font-bold mb-4 text-white",children:"Join"}),r("div",{class:"flex items-center flex-col",children:[r("ul",{class:"w-1/4 mb-8 hidden text-sm font-medium text-center text-gray-500 rounded-lg divide-x divide-gray-200 shadow sm:flex dark:divide-gray-700 dark:text-gray-400",children:[t("li",{class:"w-full",children:t("a",{href:"#",class:o==="login"?`${l} rounded-l-lg`:`${d} rounded-l-lg`,onClick:i=>{i.preventDefault(),this.setState({current_tab:"login"})},children:"Login"})}),t("li",{class:"w-full",children:t("a",{href:"#",class:o==="register"?`${l} rounded-r-lg`:`${d} rounded-r-lg`,onClick:i=>{i.preventDefault(),this.setState({current_tab:"register"})},children:"Register"})})]}),r("form",{onSubmit:this.onSubmit.bind(this),class:"flex flex-col items-start w-1/4",children:[t("input",{class:"search-bg shadow rounded-lg border-0 py-3 px-4 placeholder-data text-white mb-4 w-full",type:"url",placeholder:"Homeserver",name:"homeserver",value:e,onInput:this.onInput.bind(this)}),t("input",{class:"search-bg shadow rounded-lg border-0 py-3 px-4 placeholder-data text-white mb-4 w-full",autocomplete:"username",type:"text",placeholder:"Username",name:"username",value:n,onInput:this.onInput.bind(this)}),t("input",{class:"search-bg shadow rounded-lg border-0 py-3 px-4 placeholder-data text-white mb-4 w-full",autoComplete:"current-password",type:"password",placeholder:"Password",name:"password",value:a,onInput:this.onInput.bind(this)}),r("label",{class:"mb-4 flex items-center",children:[t("input",{class:"checked:bg-blue-600 checked:border-transparent checked:bg-no-repeat checked:bg-[url('/tick.svg')] outline-none focus:outline-offset-2 focus:ring-blue-600 focus:ring-offset-2 focus:ring-offset-white p-0 inline-block align-middle box-border select-none shrink-0 shadow h-5 w-5 appearance-none rounded bg-white border-none",type:"checkbox",name:"create_profile",checked:c,onInput:this.onInput.bind(this)}),t("span",{class:"ml-4 text-data text-base font-medium",children:"Create account"})]}),t("button",{type:"submit",class:"text-white font-bold text-lg logo-bg rounded-xl py-2 px-10 shadow transform transition-transform ease-in-out duration-300 hover:scale-105 w-1/2 self-center",children:o==="login"?"Login":"Register"})]})]})]})]})}}f.contextType=p;export{f as default};
diff --git a/pr-121/assets/Join.e97dcbed.js b/pr-121/assets/Join.e97dcbed.js
@@ -0,0 +1 @@
+var b=Object.defineProperty;var c=Object.getOwnPropertySymbols;var m=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable;var d=(s,t,e)=>t in s?b(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,h=(s,t)=>{for(var e in t||(t={}))m.call(t,e)&&d(s,e,t[e]);if(c)for(var e of c(t))x.call(t,e)&&d(s,e,t[e]);return s};import{u as w,E as v}from"./vendor.09079154.js";import{j as r,a as n,H as y,C as k}from"./index.955c971f.js";const I=s=>t=>{const e=w();return r(s,h({navigate:e},t))},u="inline-block p-4 w-full text-gray-900 bg-gray-100 hover:ring-blue-300 hover:ring-1 focus:ring-transparent focus:outline-none dark:bg-gray-700 dark:text-white",g="inline-block p-4 w-full bg-white hover:text-gray-700 hover:bg-gray-50 hover:ring-blue-300 hover:ring-1 focus:ring-transparent focus:outline-none dark:hover:text-white dark:bg-gray-800 dark:hover:bg-gray-700";class p extends v{constructor(t){super(t);this.state={homeserver:"https://art.midnightthoughts.space",username:"",password:"",create_profile:!0,current_tab:"login"}}async onSubmit(t){t.preventDefault();const e=this.context;!e||this.state.homeserver===""||this.state.username===""||this.state.password===""||(this.state.current_tab==="login"&&!(e!=null&&e.isLoggedIn())?await e.login(this.state.homeserver,this.state.username,this.state.password,this.state.create_profile):this.state.current_tab==="register"&&!e.isLoggedIn()&&await e.register(this.state.homeserver,this.state.username,this.state.password,this.state.create_profile),this.props.navigate("/",{replace:!0}))}onInput(t){t.preventDefault();const e=t.target,a=e.type==="checkbox"?e.checked:e.value,o=e.name;this.setState({[o]:a})}render(t,{homeserver:e,username:a,password:o,create_profile:f,current_tab:i}){return n("div",{class:"flex flex-col",children:[r("header",{children:r(y,{})}),n("main",{class:"m-12 mt-6",children:[r("h1",{class:"text-3xl font-bold mb-4 text-white",children:"Join"}),n("div",{class:"flex items-center flex-col",children:[n("ul",{class:"w-1/4 mb-8 hidden text-sm font-medium text-center text-gray-500 rounded-lg divide-x divide-gray-200 shadow sm:flex dark:divide-gray-700 dark:text-gray-400",children:[r("li",{class:"w-full",children:r("a",{href:"#",class:i==="login"?`${u} rounded-l-lg`:`${g} rounded-l-lg`,onClick:l=>{l.preventDefault(),this.setState({current_tab:"login"})},children:"Login"})}),r("li",{class:"w-full",children:r("a",{href:"#",class:i==="register"?`${u} rounded-r-lg`:`${g} rounded-r-lg`,onClick:l=>{l.preventDefault(),this.setState({current_tab:"register"})},children:"Register"})})]}),n("form",{onSubmit:this.onSubmit.bind(this),class:"flex flex-col items-start w-1/4",children:[r("input",{class:"search-bg shadow rounded-lg border-0 py-3 px-4 placeholder-data text-white mb-4 w-full",type:"url",placeholder:"Homeserver",name:"homeserver",value:e,onInput:this.onInput.bind(this)}),r("input",{class:"search-bg shadow rounded-lg border-0 py-3 px-4 placeholder-data text-white mb-4 w-full",autocomplete:"username",type:"text",placeholder:"Username",name:"username",value:a,onInput:this.onInput.bind(this)}),r("input",{class:"search-bg shadow rounded-lg border-0 py-3 px-4 placeholder-data text-white mb-4 w-full",autoComplete:"current-password",type:"password",placeholder:"Password",name:"password",value:o,onInput:this.onInput.bind(this)}),n("label",{class:"mb-4 flex items-center",children:[r("input",{class:"checked:bg-blue-600 checked:border-transparent checked:bg-no-repeat checked:bg-[url('/tick.svg')] outline-none focus:outline-offset-2 focus:ring-blue-600 focus:ring-offset-2 focus:ring-offset-white p-0 inline-block align-middle box-border select-none shrink-0 shadow h-5 w-5 appearance-none rounded bg-white border-none",type:"checkbox",name:"create_profile",checked:f,onInput:this.onInput.bind(this)}),r("span",{class:"ml-4 text-data text-base font-medium",children:"Create account"})]}),r("button",{type:"submit",class:"text-white font-bold text-lg logo-bg rounded-xl py-2 px-10 shadow transform transition-transform ease-in-out duration-300 hover:scale-105 w-1/2 self-center",children:i==="login"?"Login":"Register"})]})]})]})]})}}p.contextType=k;var $=I(p);export{$ as default};
diff --git a/pr-121/assets/index.955c971f.js b/pr-121/assets/index.955c971f.js
@@ -0,0 +1 @@
+var F=Object.defineProperty,U=Object.defineProperties;var W=Object.getOwnPropertyDescriptors;var B=Object.getOwnPropertySymbols;var G=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable;var b=(c,e,t)=>e in c?F(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t,P=(c,e)=>{for(var t in e||(e={}))G.call(e,t)&&b(c,t,e[t]);if(B)for(var t of B(e))X.call(e,t)&&b(c,t,e[t]);return c},j=(c,e)=>U(c,W(e));var d=(c,e,t)=>(b(c,typeof e!="symbol"?e+"":e,t),t);import{D as Q,j as V,a as Y,E as _,L as I,P as J,l as a,b as s,W as M,M as E,c as Z,d as q,O as $,o as K,e as ee,R as te,f as O,g as ne,F as ie,S as oe,B as re}from"./vendor.09079154.js";const se=function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))o(n);new MutationObserver(n=>{for(const l of n)if(l.type==="childList")for(const r of l.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&o(r)}).observe(document,{childList:!0,subtree:!0});function t(n){const l={};return n.integrity&&(l.integrity=n.integrity),n.referrerpolicy&&(l.referrerPolicy=n.referrerpolicy),n.crossorigin==="use-credentials"?l.credentials="include":n.crossorigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function o(n){if(n.ep)return;n.ep=!0;const l=t(n);fetch(n.href,l)}};se();const ae="modulepreload",H={},le="/pr-121/",ce=function(e,t){return!t||t.length===0?e():Promise.all(t.map(o=>{if(o=`${le}${o}`,o in H)return;H[o]=!0;const n=o.endsWith(".css"),l=n?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${o}"]${l}`))return;const r=document.createElement("link");if(r.rel=n?"stylesheet":ae,n||(r.as="script",r.crossOrigin=""),r.href=o,document.head.appendChild(r),n)return new Promise((w,m)=>{r.addEventListener("load",w),r.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${o}`)))})})).then(()=>e())},R=Q(void 0),i=V,h=Y;class A extends _{render(){const e=this.context;return h("div",{class:"m-12 flex flex-col lg:flex-row items-center justify-between",children:[i(I,{to:"/",children:i("img",{alt:"Matrix Art",src:"Logo_colored.svg",class:"ease-in-out hover:scale-105 trandform transition-transform duration-300"})}),h("div",{class:"flex items-center mt-8 lg:mt-0 flex-col sm:flex-row",children:[h("div",{class:"flex items-center justify-between w-80 max-w-80 mx-6 ease-in-out hover:scale-105 trandform transition-transform duration-300",children:[i("div",{class:"absolute ml-4",children:h("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"#AAB3CF",children:[i("path",{d:"M0 0h24v24H0V0z",fill:"none"}),i("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"})]})}),i("input",{class:"search-bg shadow rounded-2xl border-0 py-3 px-4 pl-10 text-data",placeholder:"Search"})]}),e!=null&&e.isLoggedIn()?i(I,{to:"/",class:"text-white font-bold text-1xl logo-bg rounded-2xl py-3 px-12 shadow mt-4 sm:mt-0 transform transition-transform ease-in-out duration-300 hover:scale-105",children:"Post"}):i(I,{to:"/join",class:"text-white font-bold text-1xl logo-bg rounded-2xl py-3 px-12 shadow mt-4 sm:mt-0 transform transition-transform ease-in-out duration-300 hover:scale-105",children:"Join"})]})]})}}A.contextType=R;class p extends _{constructor(e){super(e)}render({user:e,post:t}){return h("div",{class:"flex flex-col",children:[i("a",{id:"gallery_click",href:t.content.file.url,class:"w-full",target:"_blank",rel:"noreferrer",children:i("img",{decoding:"async",loading:"lazy",class:"rounded-3xl shadow object-cover transform transition-transform ease-in-out duration-300 hover:scale-105",src:t.content.file.url})}),h("div",{class:"flex items-center justify-between py-4",children:[h("a",{class:"flex items-center",href:"#",children:[i("img",{class:"w-11 h-11 rounded-full mr-4 border-2 border-[#AAB3CF]",src:e.avatar_url}),i("p",{class:"text-data shadow text-lg font-medium",children:e.display_name})]}),h("div",{class:"flex text-data text-lg items-center",children:[h("a",{class:"mr-4 flex items-center",href:"#",children:[i("span",{class:"mr-2",children:h("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"#AAB3CF",children:[i("path",{d:"M0 0h24v24H0V0z",fill:"none"}),i("path",{d:"M16.5 3c-1.74 0-3.41.81-4.5 2.09C10.91 3.81 9.24 3 7.5 3 4.42 3 2 5.42 2 8.5c0 3.78 3.4 6.86 8.55 11.54L12 21.35l1.45-1.32C18.6 15.36 22 12.28 22 8.5 22 5.42 19.58 3 16.5 3zm-4.4 15.55l-.1.1-.1-.1C7.14 14.24 4 11.39 4 8.5 4 6.5 5.5 5 7.5 5c1.54 0 3.04.99 3.57 2.36h1.87C13.46 5.99 14.96 5 16.5 5c2 0 3.5 1.5 3.5 3.5 0 2.89-3.14 5.74-7.9 10.05z"})]})}),i("span",{children:"5"})]}),h("a",{class:"flex items-center",href:"#",children:[i("span",{class:"mr-2",children:h("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"#AAB3CF",children:[i("path",{d:"M0 0h24v24H0V0z",fill:"none"}),i("path",{d:"M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z"})]})}),i("span",{children:"11"})]})]})]})]})}}class y{constructor(e,t,o){d(this,"mxid");d(this,"display_name");d(this,"avatar_url");this.mxid=e,this.display_name=t,this.avatar_url=o}}class v{constructor(e,t){d(this,"event_id");d(this,"content");this.event_id=e,this.content=t}}class de extends _{constructor(){super();this.state={columns:this.settingColumns()}}settingColumns(){return window.innerWidth>=1400?4:window.innerWidth>=800?3:window.innerWidth>=500?2:1}componentDidMount(){window.addEventListener("resize",()=>this.setState({columns:this.settingColumns()}))}componentWillUnmount(){window.removeEventListener("resize",()=>this.setState({columns:this.settingColumns()}))}render(){return h("div",{class:"flex flex-col",children:[i("header",{children:i(A,{})}),h("main",{class:"m-12 mt-6",children:[i("h1",{class:"text-3xl font-bold mb-4 text-white",children:"Explore"}),i("div",{class:"flex justify-center",id:"gallery",children:h(J,{gap:24,nColumns:this.state.columns,children:[i(p,{user:new y("","Person A","https://unsplash.com/photos/_cvwXhGqG-o/download?ixid=MnwxMjA3fDB8MXxzZWFyY2h8OHx8ZmFjZXxlbnwwfDJ8fHwxNjQ4Nzc5NzYx"),post:new v("",{file:{url:"https://unsplash.com/photos/UWmrTAQ75iA/download?ixid=MnwxMjA3fDB8MXxhbGx8Mnx8fHx8fDJ8fDE2NDg4MzI0Njg"}})}),i(p,{user:new y("","Person B","https://unsplash.com/photos/uJ8LNVCBjFQ/download?ixid=MnwxMjA3fDB8MXxzZWFyY2h8MTN8fGZhY2V8ZW58MHwyfHx8MTY0ODc3OTc2MQ"),post:new v("",{file:{url:"https://unsplash.com/photos/7ptbiEPxKMQ/download?ixid=MnwxMjA3fDB8MXxhbGx8OXx8fHx8fDJ8fDE2NDg4MzI0Njg"}})}),i(p,{user:new y("","Person C","https://unsplash.com/photos/u3pi6HhSYew/download?ixid=MnwxMjA3fDB8MXxzZWFyY2h8MTd8fGZhY2V8ZW58MHwyfHx8MTY0ODc3OTc2MQ"),post:new v("",{file:{url:"https://unsplash.com/photos/ZiPlVmmKEYA/download?ixid=MnwxMjA3fDB8MXxhbGx8Mzl8fHx8fHwyfHwxNjQ4ODM2MDIz"}})}),i(p,{user:new y("","Person D","https://unsplash.com/photos/TW_z_iUD_bQ/download?ixid=MnwxMjA3fDB8MXxzZWFyY2h8ODR8fHBvcnRyYWl0fGVufDB8Mnx8fDE2NDg4NDQ3MjQ"),post:new v("",{file:{url:"https://unsplash.com/photos/FTQJBGDxKXg/download?ixid=MnwxMjA3fDB8MXxhbGx8M3x8fHx8fDJ8fDE2NDg4NDMyNDY"}})}),i(p,{user:new y("","Person E","https://unsplash.com/photos/kYtN89E5ce4/download?ixid=MnwxMjA3fDB8MXxzZWFyY2h8MTA0fHxwb3J0cmFpdHxlbnwwfDJ8fHwxNjQ4ODQ0NzQy"),post:new v("",{file:{url:"https://unsplash.com/photos/zfhxiaZO3JE/download?ixid=MnwxMjA3fDB8MXxhbGx8Mjl8fHx8fHwyfHwxNjQ4ODQzMjQ1"}})}),i(p,{user:new y("","Person E","https://unsplash.com/photos/kBonaevi3yA/download?ixid=MnwxMjA3fDB8MXxzZWFyY2h8MTE5fHxwb3J0cmFpdHxlbnwwfDJ8fHwxNjQ4ODQ0NzQy"),post:new v("",{file:{url:"https://unsplash.com/photos/jm-JKqrAXsA/download?ixid=MnwxMjA3fDB8MXxhbGx8MTAyfHx8fHx8Mnx8MTY0ODg0MzI1NQ"}})})]})})]})]})}}const S=new a.UnstableValue("m.image","org.matrix.msc1767.image"),N=new a.UnstableValue("m.file","org.matrix.msc1767.file"),L=new a.UnstableValue("m.thumbnail","org.matrix.msc1767.thumbnail"),z=new a.UnstableValue("blurhash","xyz.amorgan.blurhash"),he=new a.NamespacedValue("matrixart.description"),me=new a.NamespacedValue("matrixart.tags"),we=new a.NamespacedValue("matrixart.nsfw"),ue=new a.NamespacedValue("matrixart.license");class xe extends a.ExtensibleEvent{constructor(e){super(e);d(this,"image");d(this,"text");d(this,"thumbnails");d(this,"blurhash");d(this,"file");d(this,"description");d(this,"tags");d(this,"nsfw",!1);d(this,"license");const t=S.findIn(this.wireContent),o=a.M_TEXT.findIn(this.wireContent),n=N.findIn(this.wireContent),l=L.findIn(this.wireContent),r=z.findIn(this.wireContent),w=he.findIn(this.wireContent),m=me.findIn(this.wireContent),x=we.findIn(this.wireContent),u=ue.findIn(this.wireContent);if(a.isProvided(t)){if(!t)throw new a.InvalidEventError("m.image is required to be present");this.image=t}if(a.isProvided(n)){if(!n)throw new a.InvalidEventError("m.file is required to be present");this.file=n}if(a.isOptionalAString(o)){if(!t)throw new a.InvalidEventError("m.text is required to be present");this.text=o}if(a.isProvided(l)){if(!Array.isArray(l))throw new a.InvalidEventError("m.thumbnail contents must be an array");this.thumbnails=l}if(a.isOptionalAString(r)&&(this.blurhash=r),a.isOptionalAString(w)&&(this.description=w),a.isProvided(m)){if(!Array.isArray(m))throw new a.InvalidEventError("matrixart.tags contents must be an array");this.tags=m}if(a.isProvided(x)){if(typeof x!="boolean")throw new a.InvalidEventError("matrixart.tags contents must be an boolean");this.nsfw=x}a.isOptionalAString(u)&&(this.license=u)}isEquivalentTo(e){return a.isEventTypeSame(e,S)}serialize(){const e={[a.M_TEXT.name]:this.text,[N.name]:this.file,[S.name]:this.image,[L.name]:this.thumbnails,[z.name]:this.blurhash,["matrixart.description"]:this.description,["matrixart.tags"]:this.tags,["matrixart.nsfw"]:this.nsfw,["matrixart.license"]:this.license};return{type:"m.image",content:e}}}function fe(c){const e=c;return new xe(e)}a.ExtensibleEvents.registerInterpreter(S,fe);a.ExtensibleEvents.unknownInterpretOrder.push(S);function D(){return new Worker("/pr-121/assets/indexeddb.worker.0ae1a28d.js",{type:"module"})}class C{constructor(e){d(this,"events",[]);d(this,"currentUserDirectory");d(this,"rootDirectory");this.client=e}static async new(){var n,l,r,w,m,x;global.Olm||console.error("global.Olm does not seem to be present. Did you forget to add olm in the out directory?");let e;if(window.localStorage.getItem("server")!==null?e=window.localStorage.getItem("server"):e="https://matrix.art.midnightthoughts.space",!e)throw new Error("No matrix server URL defined");let t;if(window.localStorage.getItem("mxid_guest")!==null){const u=(n=window.localStorage.getItem("mxid_guest"))!=null?n:void 0,f=(l=window.localStorage.getItem("access_token_guest"))!=null?l:void 0,g=(r=window.localStorage.getItem("device_id_guest"))!=null?r:void 0;t=s.createClient({useAuthorizationHeader:!0,baseUrl:e,userId:u,accessToken:f,deviceId:g,sessionStore:new M(window.localStorage),store:new s.IndexedDBStore({indexedDB:window.indexedDB,dbName:"matrix-art-sync:guest",localStorage:window.localStorage,workerFactory:()=>new D}),cryptoStore:new s.IndexedDBCryptoStore(window.indexedDB,"matrix-art:crypto")}),t.setGuest(!0)}{const u=s.createClient("https://matrix.art.midnightthoughts.space"),{user_id:f,device_id:g,access_token:T}=await u.registerGuest();t=s.createClient({useAuthorizationHeader:!0,baseUrl:e,userId:f,accessToken:T,deviceId:g,sessionStore:new M(window.localStorage),store:new s.IndexedDBStore({indexedDB:window.indexedDB,dbName:"matrix-art-sync:guest",localStorage:window.localStorage,workerFactory:()=>new D}),cryptoStore:new s.IndexedDBCryptoStore(window.indexedDB,"matrix-art:crypto")}),t.setGuest(!0),window.localStorage.setItem("mxid_guest",f),window.localStorage.setItem("access_token_guest",T),window.localStorage.setItem("device_id_guest",g),window.localStorage.setItem("server",e)}let o;if(window.localStorage.getItem("mxid")!==null){const u=(w=window.localStorage.getItem("mxid"))!=null?w:void 0,f=(m=window.localStorage.getItem("access_token"))!=null?m:void 0,g=(x=window.localStorage.getItem("device_id"))!=null?x:void 0;o=s.createClient({useAuthorizationHeader:!0,baseUrl:e,userId:u,accessToken:f,deviceId:g,sessionStore:new M(window.localStorage),store:new s.IndexedDBStore({indexedDB:window.indexedDB,dbName:"matrix-art-sync:guest",localStorage:window.localStorage,workerFactory:()=>new D}),cryptoStore:new s.IndexedDBCryptoStore(window.indexedDB,"matrix-art:crypto")}),o.setGuest(!1)}return new C(o!=null?o:t)}isLoggedIn(){return this.client.isLoggedIn()&&!this.client.isGuest()}async start(){this.client.on(s.MatrixEventEvent.Decrypted,(t,o)=>{const n=t.unstableExtensibleEvent;n!=null&&n.isEquivalentTo(S)&&this.events.push(t)}),console.log("start"),await this.client.store.startup(),await this.client.initCrypto(),await this.client.startClient();const e=await this.client.joinRoom("#Matrix_Art:art.midnightthoughts.space");await k(1e3),this.rootDirectory=new E(this.client,e.roomId),console.log("started")}async register(e="https://matrix.art.midnightthoughts.space",t,o,n=!1){var l;if(this.client.stopClient(),this.client=s.createClient({useAuthorizationHeader:!0,baseUrl:e,userId:t,deviceId:"Matrix Art",sessionStore:new M(window.localStorage),store:new s.IndexedDBStore({indexedDB:window.indexedDB,dbName:"matrix-art-sync:loggedin",localStorage:window.localStorage,workerFactory:()=>new D}),cryptoStore:new s.IndexedDBCryptoStore(window.indexedDB,"matrix-art:crypto")}),await this.client.register(t,o,null,{type:"m.login.dummy"}),window.localStorage.setItem("server",e),window.localStorage.setItem("mxid",t),window.localStorage.setItem("access_token",this.client.getAccessToken()),window.localStorage.setItem("device_id","Matrix Art"),await this.start(),n){const r=(l=this.rootDirectory)==null?void 0:l.getDirectories(),w=this.client.getUserId().replace(":","_");r!=null&&r.some(m=>m.room.name===w)?this.rootDirectory=r==null?void 0:r.find(m=>m.room.name===w):await this.createProfileFolder()}}async login(e,t,o,n=!1){var l;if(this.client.stopClient(),this.client=s.createClient({useAuthorizationHeader:!0,baseUrl:e,userId:t,deviceId:"Matrix Art",sessionStore:new M(window.localStorage),store:new s.IndexedDBStore({indexedDB:window.indexedDB,dbName:"matrix-art-sync:loggedin",localStorage:window.localStorage,workerFactory:()=>new D}),cryptoStore:new s.IndexedDBCryptoStore(window.indexedDB,"matrix-art:crypto")}),await this.client.loginWithPassword(t,o),window.localStorage.setItem("server",e),window.localStorage.setItem("mxid",t),window.localStorage.setItem("access_token",this.client.getAccessToken()),window.localStorage.setItem("device_id","Matrix Art"),await this.start(),n){const r=(l=this.rootDirectory)==null?void 0:l.getDirectories();console.log(r);const w=this.client.getUserId().replace(":","_");r!=null&&r.some(m=>m.room.name===w)?this.rootDirectory=r==null?void 0:r.find(m=>m.room.name===w):await this.createProfileFolder()}}async createProfileFolder(){if(this.client.isGuest())throw new Error("Cannot create a file tree space as a guest");const e=await this.client.joinRoom("#Matrix_Art:art.midnightthoughts.space");await k(1e3),this.rootDirectory=new E(this.client,e.roomId);const t=this.client.getUserId().replace(":","_");this.currentUserDirectory=await this.createPublicSubDirectory(this.rootDirectory,t),await this.createPublicSubDirectory(this.currentUserDirectory,"Timeline")}async createPublicFileTree(e){if(this.client.isGuest())throw new Error("Cannot create a file tree space as a guest");const{room_id:t}=await this.client.createRoom({name:e,preset:s.Preset.PublicChat,power_level_content_override:j(P({},Z),{users:{["@administrator:art.midnightthoughts.space"]:100,[this.client.getUserId()]:100}}),invite:["@administrator:art.midnightthoughts.space"],creation_content:{[s.RoomCreateTypeField]:s.RoomType.Space},initial_state:[{type:s.UNSTABLE_MSC3088_PURPOSE.name,state_key:s.UNSTABLE_MSC3089_TREE_SUBTYPE.name,content:{[s.UNSTABLE_MSC3088_ENABLED.name]:!0}},{type:s.EventType.RoomEncryption,state_key:"",content:{algorithm:q}},{type:s.EventType.RoomGuestAccess,state_key:"",content:{guest_access:"can_join"}},{type:s.EventType.RoomHistoryVisibility,state_key:"",content:{history_visibility:"world_readable"}}]}),o=this.client.getRoom(t),n=o==null?void 0:o.getLiveTimeline().getState(s.EventTimeline.FORWARDS).getStateEvents(s.EventType.RoomPowerLevels,"");if(!n)throw new Error("Failed to find PL event");return await this.client.setPowerLevel(t,this.client.getUserId(),50,n),new E(this.client,t)}async createPublicSubDirectory(e,t){const o=await this.createPublicFileTree(t);return await this.client.sendStateEvent(e.roomId,s.EventType.SpaceChild,{via:[this.client.getDomain()]},o.roomId),await this.client.sendStateEvent(o.roomId,s.EventType.SpaceParent,{via:[this.client.getDomain()]},e.roomId),o}}function k(c){return new Promise(e=>setTimeout(e,c))}const ge=ie(()=>ce(()=>import("./Join.e97dcbed.js"),["assets/Join.e97dcbed.js","assets/vendor.09079154.js"]));class pe extends _{constructor(){super();this.state={client:void 0}}loadOlm(){return $.init({locateFile:()=>K}).then(()=>{console.log("Using WebAssembly Olm")}).catch(e=>(console.log("Failed to load Olm: trying legacy version",e),new Promise((t,o)=>{const n=document.createElement("script");n.src=ee,n.onload=t,n.onerror=o,document.body.appendChild(n)}).then(()=>window.Olm.init()).then(()=>{console.log("Using legacy Olm")}).catch(t=>{console.log("Both WebAssembly and asm.js Olm failed!",t)})))}async loadMatrixClient(){var t;let e=await C.new();this.setState({client:e}),console.log("Client loaded"),await((t=this.state.client)==null?void 0:t.start()),console.log("Client started")}async componentDidMount(){try{await this.loadOlm(),console.log("Olm loaded")}catch{console.log("Olm not loaded")}await this.loadMatrixClient()}render(){return i(R.Provider,{value:this.state.client,children:h(te,{children:[i(O,{path:"/",element:i(de,{})}),i(O,{path:"join",element:i(ne,{fallback:h("div",{class:"flex flex-col",children:[i("header",{children:i(A,{})}),i("main",{class:"m-12 mt-6 flex items-center justify-center",children:i("p",{class:"text-lg text-data font-bold",children:"Loading..."})})]}),children:i(ge,{})})})]})})}}oe(i(re,{basename:"/pr-121/",children:i(pe,{})}),document.querySelector("#app"));export{R as C,A as H,h as a,i as j};
diff --git a/pr-121/assets/index.fcbee31f.js b/pr-121/assets/index.fcbee31f.js
@@ -1 +0,0 @@
-var F=Object.defineProperty,U=Object.defineProperties;var R=Object.getOwnPropertyDescriptors;var B=Object.getOwnPropertySymbols;var W=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var b=(c,e,t)=>e in c?F(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t,P=(c,e)=>{for(var t in e||(e={}))W.call(e,t)&&b(c,t,e[t]);if(B)for(var t of B(e))G.call(e,t)&&b(c,t,e[t]);return c},j=(c,e)=>U(c,R(e));var d=(c,e,t)=>(b(c,typeof e!="symbol"?e+"":e,t),t);import{D as X,j as Q,a as V,E as _,b as I,P as Y,l as a,c as s,W as M,M as E,d as J,e as Z,O as $,o as q,f as K,L as ee,g as te,F as ne,S as ie}from"./vendor.d4008ec4.js";const oe=function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))o(n);new MutationObserver(n=>{for(const l of n)if(l.type==="childList")for(const r of l.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&o(r)}).observe(document,{childList:!0,subtree:!0});function t(n){const l={};return n.integrity&&(l.integrity=n.integrity),n.referrerpolicy&&(l.referrerPolicy=n.referrerpolicy),n.crossorigin==="use-credentials"?l.credentials="include":n.crossorigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function o(n){if(n.ep)return;n.ep=!0;const l=t(n);fetch(n.href,l)}};oe();const re="modulepreload",O={},se="/pr-121/",ae=function(e,t){return!t||t.length===0?e():Promise.all(t.map(o=>{if(o=`${se}${o}`,o in O)return;O[o]=!0;const n=o.endsWith(".css"),l=n?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${o}"]${l}`))return;const r=document.createElement("link");if(r.rel=n?"stylesheet":re,n||(r.as="script",r.crossOrigin=""),r.href=o,document.head.appendChild(r),n)return new Promise((w,m)=>{r.addEventListener("load",w),r.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${o}`)))})})).then(()=>e())},k=X(void 0),i=Q,h=V;class A extends _{render(){const e=this.context;return h("div",{class:"m-12 flex flex-col lg:flex-row items-center justify-between",children:[i(I,{href:"/",children:i("img",{alt:"Matrix Art",src:"Logo_colored.svg",class:"ease-in-out hover:scale-105 trandform transition-transform duration-300"})}),h("div",{class:"flex items-center mt-8 lg:mt-0 flex-col sm:flex-row",children:[h("div",{class:"flex items-center justify-between w-80 max-w-80 mx-6 ease-in-out hover:scale-105 trandform transition-transform duration-300",children:[i("div",{class:"absolute ml-4",children:h("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"#AAB3CF",children:[i("path",{d:"M0 0h24v24H0V0z",fill:"none"}),i("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"})]})}),i("input",{class:"search-bg shadow rounded-2xl border-0 py-3 px-4 pl-10 text-data",placeholder:"Search"})]}),e!=null&&e.isLoggedIn()?i(I,{class:"text-white font-bold text-1xl logo-bg rounded-2xl py-3 px-12 shadow mt-4 sm:mt-0 transform transition-transform ease-in-out duration-300 hover:scale-105",children:"Post"}):i(I,{href:"/pr-121//join",class:"text-white font-bold text-1xl logo-bg rounded-2xl py-3 px-12 shadow mt-4 sm:mt-0 transform transition-transform ease-in-out duration-300 hover:scale-105",children:"Join"})]})]})}}A.contextType=k;class p extends _{constructor(e){super(e)}render({user:e,post:t}){return h("div",{class:"flex flex-col",children:[i("a",{id:"gallery_click",href:t.content.file.url,class:"w-full",target:"_blank",rel:"noreferrer",children:i("img",{decoding:"async",loading:"lazy",class:"rounded-3xl shadow object-cover transform transition-transform ease-in-out duration-300 hover:scale-105",src:t.content.file.url})}),h("div",{class:"flex items-center justify-between py-4",children:[h("a",{class:"flex items-center",href:"#",children:[i("img",{class:"w-11 h-11 rounded-full mr-4 border-2 border-[#AAB3CF]",src:e.avatar_url}),i("p",{class:"text-data shadow text-lg font-medium",children:e.display_name})]}),h("div",{class:"flex text-data text-lg items-center",children:[h("a",{class:"mr-4 flex items-center",href:"#",children:[i("span",{class:"mr-2",children:h("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"#AAB3CF",children:[i("path",{d:"M0 0h24v24H0V0z",fill:"none"}),i("path",{d:"M16.5 3c-1.74 0-3.41.81-4.5 2.09C10.91 3.81 9.24 3 7.5 3 4.42 3 2 5.42 2 8.5c0 3.78 3.4 6.86 8.55 11.54L12 21.35l1.45-1.32C18.6 15.36 22 12.28 22 8.5 22 5.42 19.58 3 16.5 3zm-4.4 15.55l-.1.1-.1-.1C7.14 14.24 4 11.39 4 8.5 4 6.5 5.5 5 7.5 5c1.54 0 3.04.99 3.57 2.36h1.87C13.46 5.99 14.96 5 16.5 5c2 0 3.5 1.5 3.5 3.5 0 2.89-3.14 5.74-7.9 10.05z"})]})}),i("span",{children:"5"})]}),h("a",{class:"flex items-center",href:"#",children:[i("span",{class:"mr-2",children:h("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"#AAB3CF",children:[i("path",{d:"M0 0h24v24H0V0z",fill:"none"}),i("path",{d:"M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z"})]})}),i("span",{children:"11"})]})]})]})]})}}class y{constructor(e,t,o){d(this,"mxid");d(this,"display_name");d(this,"avatar_url");this.mxid=e,this.display_name=t,this.avatar_url=o}}class v{constructor(e,t){d(this,"event_id");d(this,"content");this.event_id=e,this.content=t}}class le extends _{constructor(){super();this.state={columns:this.settingColumns()}}settingColumns(){return window.innerWidth>=1400?4:window.innerWidth>=800?3:window.innerWidth>=500?2:1}componentDidMount(){window.addEventListener("resize",()=>this.setState({columns:this.settingColumns()}))}componentWillUnmount(){window.removeEventListener("resize",()=>this.setState({columns:this.settingColumns()}))}render(){return h("div",{class:"flex flex-col",children:[i("header",{children:i(A,{})}),h("main",{class:"m-12 mt-6",children:[i("h1",{class:"text-3xl font-bold mb-4 text-white",children:"Explore"}),i("div",{class:"flex justify-center",id:"gallery",children:h(Y,{gap:24,nColumns:this.state.columns,children:[i(p,{user:new y("","Person A","https://unsplash.com/photos/_cvwXhGqG-o/download?ixid=MnwxMjA3fDB8MXxzZWFyY2h8OHx8ZmFjZXxlbnwwfDJ8fHwxNjQ4Nzc5NzYx"),post:new v("",{file:{url:"https://unsplash.com/photos/UWmrTAQ75iA/download?ixid=MnwxMjA3fDB8MXxhbGx8Mnx8fHx8fDJ8fDE2NDg4MzI0Njg"}})}),i(p,{user:new y("","Person B","https://unsplash.com/photos/uJ8LNVCBjFQ/download?ixid=MnwxMjA3fDB8MXxzZWFyY2h8MTN8fGZhY2V8ZW58MHwyfHx8MTY0ODc3OTc2MQ"),post:new v("",{file:{url:"https://unsplash.com/photos/7ptbiEPxKMQ/download?ixid=MnwxMjA3fDB8MXxhbGx8OXx8fHx8fDJ8fDE2NDg4MzI0Njg"}})}),i(p,{user:new y("","Person C","https://unsplash.com/photos/u3pi6HhSYew/download?ixid=MnwxMjA3fDB8MXxzZWFyY2h8MTd8fGZhY2V8ZW58MHwyfHx8MTY0ODc3OTc2MQ"),post:new v("",{file:{url:"https://unsplash.com/photos/ZiPlVmmKEYA/download?ixid=MnwxMjA3fDB8MXxhbGx8Mzl8fHx8fHwyfHwxNjQ4ODM2MDIz"}})}),i(p,{user:new y("","Person D","https://unsplash.com/photos/TW_z_iUD_bQ/download?ixid=MnwxMjA3fDB8MXxzZWFyY2h8ODR8fHBvcnRyYWl0fGVufDB8Mnx8fDE2NDg4NDQ3MjQ"),post:new v("",{file:{url:"https://unsplash.com/photos/FTQJBGDxKXg/download?ixid=MnwxMjA3fDB8MXxhbGx8M3x8fHx8fDJ8fDE2NDg4NDMyNDY"}})}),i(p,{user:new y("","Person E","https://unsplash.com/photos/kYtN89E5ce4/download?ixid=MnwxMjA3fDB8MXxzZWFyY2h8MTA0fHxwb3J0cmFpdHxlbnwwfDJ8fHwxNjQ4ODQ0NzQy"),post:new v("",{file:{url:"https://unsplash.com/photos/zfhxiaZO3JE/download?ixid=MnwxMjA3fDB8MXxhbGx8Mjl8fHx8fHwyfHwxNjQ4ODQzMjQ1"}})}),i(p,{user:new y("","Person E","https://unsplash.com/photos/kBonaevi3yA/download?ixid=MnwxMjA3fDB8MXxzZWFyY2h8MTE5fHxwb3J0cmFpdHxlbnwwfDJ8fHwxNjQ4ODQ0NzQy"),post:new v("",{file:{url:"https://unsplash.com/photos/jm-JKqrAXsA/download?ixid=MnwxMjA3fDB8MXxhbGx8MTAyfHx8fHx8Mnx8MTY0ODg0MzI1NQ"}})})]})})]})]})}}const S=new a.UnstableValue("m.image","org.matrix.msc1767.image"),H=new a.UnstableValue("m.file","org.matrix.msc1767.file"),N=new a.UnstableValue("m.thumbnail","org.matrix.msc1767.thumbnail"),L=new a.UnstableValue("blurhash","xyz.amorgan.blurhash"),ce=new a.NamespacedValue("matrixart.description"),de=new a.NamespacedValue("matrixart.tags"),he=new a.NamespacedValue("matrixart.nsfw"),me=new a.NamespacedValue("matrixart.license");class we extends a.ExtensibleEvent{constructor(e){super(e);d(this,"image");d(this,"text");d(this,"thumbnails");d(this,"blurhash");d(this,"file");d(this,"description");d(this,"tags");d(this,"nsfw",!1);d(this,"license");const t=S.findIn(this.wireContent),o=a.M_TEXT.findIn(this.wireContent),n=H.findIn(this.wireContent),l=N.findIn(this.wireContent),r=L.findIn(this.wireContent),w=ce.findIn(this.wireContent),m=de.findIn(this.wireContent),x=he.findIn(this.wireContent),u=me.findIn(this.wireContent);if(a.isProvided(t)){if(!t)throw new a.InvalidEventError("m.image is required to be present");this.image=t}if(a.isProvided(n)){if(!n)throw new a.InvalidEventError("m.file is required to be present");this.file=n}if(a.isOptionalAString(o)){if(!t)throw new a.InvalidEventError("m.text is required to be present");this.text=o}if(a.isProvided(l)){if(!Array.isArray(l))throw new a.InvalidEventError("m.thumbnail contents must be an array");this.thumbnails=l}if(a.isOptionalAString(r)&&(this.blurhash=r),a.isOptionalAString(w)&&(this.description=w),a.isProvided(m)){if(!Array.isArray(m))throw new a.InvalidEventError("matrixart.tags contents must be an array");this.tags=m}if(a.isProvided(x)){if(typeof x!="boolean")throw new a.InvalidEventError("matrixart.tags contents must be an boolean");this.nsfw=x}a.isOptionalAString(u)&&(this.license=u)}isEquivalentTo(e){return a.isEventTypeSame(e,S)}serialize(){const e={[a.M_TEXT.name]:this.text,[H.name]:this.file,[S.name]:this.image,[N.name]:this.thumbnails,[L.name]:this.blurhash,["matrixart.description"]:this.description,["matrixart.tags"]:this.tags,["matrixart.nsfw"]:this.nsfw,["matrixart.license"]:this.license};return{type:"m.image",content:e}}}function ue(c){const e=c;return new we(e)}a.ExtensibleEvents.registerInterpreter(S,ue);a.ExtensibleEvents.unknownInterpretOrder.push(S);function D(){return new Worker("/pr-121/assets/indexeddb.worker.0ae1a28d.js",{type:"module"})}class C{constructor(e){d(this,"events",[]);d(this,"currentUserDirectory");d(this,"rootDirectory");this.client=e}static async new(){var n,l,r,w,m,x;global.Olm||console.error("global.Olm does not seem to be present. Did you forget to add olm in the out directory?");let e;if(window.localStorage.getItem("server")!==null?e=window.localStorage.getItem("server"):e="https://matrix.art.midnightthoughts.space",!e)throw new Error("No matrix server URL defined");let t;if(window.localStorage.getItem("mxid_guest")!==null){const u=(n=window.localStorage.getItem("mxid_guest"))!=null?n:void 0,f=(l=window.localStorage.getItem("access_token_guest"))!=null?l:void 0,g=(r=window.localStorage.getItem("device_id_guest"))!=null?r:void 0;t=s.createClient({useAuthorizationHeader:!0,baseUrl:e,userId:u,accessToken:f,deviceId:g,sessionStore:new M(window.localStorage),store:new s.IndexedDBStore({indexedDB:window.indexedDB,dbName:"matrix-art-sync:guest",localStorage:window.localStorage,workerFactory:()=>new D}),cryptoStore:new s.IndexedDBCryptoStore(window.indexedDB,"matrix-art:crypto")}),t.setGuest(!0)}{const u=s.createClient("https://matrix.art.midnightthoughts.space"),{user_id:f,device_id:g,access_token:T}=await u.registerGuest();t=s.createClient({useAuthorizationHeader:!0,baseUrl:e,userId:f,accessToken:T,deviceId:g,sessionStore:new M(window.localStorage),store:new s.IndexedDBStore({indexedDB:window.indexedDB,dbName:"matrix-art-sync:guest",localStorage:window.localStorage,workerFactory:()=>new D}),cryptoStore:new s.IndexedDBCryptoStore(window.indexedDB,"matrix-art:crypto")}),t.setGuest(!0),window.localStorage.setItem("mxid_guest",f),window.localStorage.setItem("access_token_guest",T),window.localStorage.setItem("device_id_guest",g),window.localStorage.setItem("server",e)}let o;if(window.localStorage.getItem("mxid")!==null){const u=(w=window.localStorage.getItem("mxid"))!=null?w:void 0,f=(m=window.localStorage.getItem("access_token"))!=null?m:void 0,g=(x=window.localStorage.getItem("device_id"))!=null?x:void 0;o=s.createClient({useAuthorizationHeader:!0,baseUrl:e,userId:u,accessToken:f,deviceId:g,sessionStore:new M(window.localStorage),store:new s.IndexedDBStore({indexedDB:window.indexedDB,dbName:"matrix-art-sync:guest",localStorage:window.localStorage,workerFactory:()=>new D}),cryptoStore:new s.IndexedDBCryptoStore(window.indexedDB,"matrix-art:crypto")}),o.setGuest(!1)}return new C(o!=null?o:t)}isLoggedIn(){return this.client.isLoggedIn()&&!this.client.isGuest()}async start(){this.client.on(s.MatrixEventEvent.Decrypted,(t,o)=>{const n=t.unstableExtensibleEvent;n!=null&&n.isEquivalentTo(S)&&this.events.push(t)}),console.log("start"),await this.client.store.startup(),await this.client.initCrypto(),await this.client.startClient();const e=await this.client.joinRoom("#Matrix_Art:art.midnightthoughts.space");await z(1e3),this.rootDirectory=new E(this.client,e.roomId),console.log("started")}async register(e="https://matrix.art.midnightthoughts.space",t,o,n=!1){var l;if(this.client.stopClient(),this.client=s.createClient({useAuthorizationHeader:!0,baseUrl:e,userId:t,deviceId:"Matrix Art",sessionStore:new M(window.localStorage),store:new s.IndexedDBStore({indexedDB:window.indexedDB,dbName:"matrix-art-sync:loggedin",localStorage:window.localStorage,workerFactory:()=>new D}),cryptoStore:new s.IndexedDBCryptoStore(window.indexedDB,"matrix-art:crypto")}),await this.client.register(t,o,null,{type:"m.login.dummy"}),window.localStorage.setItem("server",e),window.localStorage.setItem("mxid",t),window.localStorage.setItem("access_token",this.client.getAccessToken()),window.localStorage.setItem("device_id","Matrix Art"),await this.start(),n){const r=(l=this.rootDirectory)==null?void 0:l.getDirectories(),w=this.client.getUserId().replace(":","_");r!=null&&r.some(m=>m.room.name===w)?this.rootDirectory=r==null?void 0:r.find(m=>m.room.name===w):await this.createProfileFolder()}}async login(e,t,o,n=!1){var l;if(this.client.stopClient(),this.client=s.createClient({useAuthorizationHeader:!0,baseUrl:e,userId:t,deviceId:"Matrix Art",sessionStore:new M(window.localStorage),store:new s.IndexedDBStore({indexedDB:window.indexedDB,dbName:"matrix-art-sync:loggedin",localStorage:window.localStorage,workerFactory:()=>new D}),cryptoStore:new s.IndexedDBCryptoStore(window.indexedDB,"matrix-art:crypto")}),await this.client.loginWithPassword(t,o),window.localStorage.setItem("server",e),window.localStorage.setItem("mxid",t),window.localStorage.setItem("access_token",this.client.getAccessToken()),window.localStorage.setItem("device_id","Matrix Art"),await this.start(),n){const r=(l=this.rootDirectory)==null?void 0:l.getDirectories();console.log(r);const w=this.client.getUserId().replace(":","_");r!=null&&r.some(m=>m.room.name===w)?this.rootDirectory=r==null?void 0:r.find(m=>m.room.name===w):await this.createProfileFolder()}}async createProfileFolder(){if(this.client.isGuest())throw new Error("Cannot create a file tree space as a guest");const e=await this.client.joinRoom("#Matrix_Art:art.midnightthoughts.space");await z(1e3),this.rootDirectory=new E(this.client,e.roomId);const t=this.client.getUserId().replace(":","_");this.currentUserDirectory=await this.createPublicSubDirectory(this.rootDirectory,t),await this.createPublicSubDirectory(this.currentUserDirectory,"Timeline")}async createPublicFileTree(e){if(this.client.isGuest())throw new Error("Cannot create a file tree space as a guest");const{room_id:t}=await this.client.createRoom({name:e,preset:s.Preset.PublicChat,power_level_content_override:j(P({},J),{users:{["@administrator:art.midnightthoughts.space"]:100,[this.client.getUserId()]:100}}),invite:["@administrator:art.midnightthoughts.space"],creation_content:{[s.RoomCreateTypeField]:s.RoomType.Space},initial_state:[{type:s.UNSTABLE_MSC3088_PURPOSE.name,state_key:s.UNSTABLE_MSC3089_TREE_SUBTYPE.name,content:{[s.UNSTABLE_MSC3088_ENABLED.name]:!0}},{type:s.EventType.RoomEncryption,state_key:"",content:{algorithm:Z}},{type:s.EventType.RoomGuestAccess,state_key:"",content:{guest_access:"can_join"}},{type:s.EventType.RoomHistoryVisibility,state_key:"",content:{history_visibility:"world_readable"}}]}),o=this.client.getRoom(t),n=o==null?void 0:o.getLiveTimeline().getState(s.EventTimeline.FORWARDS).getStateEvents(s.EventType.RoomPowerLevels,"");if(!n)throw new Error("Failed to find PL event");return await this.client.setPowerLevel(t,this.client.getUserId(),50,n),new E(this.client,t)}async createPublicSubDirectory(e,t){const o=await this.createPublicFileTree(t);return await this.client.sendStateEvent(e.roomId,s.EventType.SpaceChild,{via:[this.client.getDomain()]},o.roomId),await this.client.sendStateEvent(o.roomId,s.EventType.SpaceParent,{via:[this.client.getDomain()]},e.roomId),o}}function z(c){return new Promise(e=>setTimeout(e,c))}const xe=ne(()=>ae(()=>import("./Join.c7410601.js"),["assets/Join.c7410601.js","assets/vendor.d4008ec4.js"]));class fe extends _{constructor(){super();this.state={client:void 0}}loadOlm(){return $.init({locateFile:()=>q}).then(()=>{console.log("Using WebAssembly Olm")}).catch(e=>(console.log("Failed to load Olm: trying legacy version",e),new Promise((t,o)=>{const n=document.createElement("script");n.src=K,n.onload=t,n.onerror=o,document.body.appendChild(n)}).then(()=>window.Olm.init()).then(()=>{console.log("Using legacy Olm")}).catch(t=>{console.log("Both WebAssembly and asm.js Olm failed!",t)})))}async loadMatrixClient(){var t;let e=await C.new();this.setState({client:e}),console.log("Client loaded"),await((t=this.state.client)==null?void 0:t.start()),console.log("Client started")}async componentDidMount(){try{await this.loadOlm(),console.log("Olm loaded")}catch{console.log("Olm not loaded")}await this.loadMatrixClient()}render(){return i(ee,{fallback:h("div",{class:"flex flex-col",children:[i("header",{children:i(A,{})}),i("main",{class:"m-12 mt-6 flex items-center justify-center",children:i("p",{class:"text-lg text-data font-bold",children:"Loading..."})})]}),children:i(k.Provider,{value:this.state.client,children:h(te,{children:[i(le,{path:"/pr-121//"}),i(xe,{path:"/pr-121//join"})]})})})}}ie(i(fe,{}),document.querySelector("#app"));export{k as C,A as H,i as a,h as j};
diff --git a/pr-121/assets/vendor.09079154.js b/pr-121/assets/vendor.09079154.js
@@ -0,0 +1,44 @@
+var G_=Object.defineProperty,W_=Object.defineProperties;var H_=Object.getOwnPropertyDescriptors;var $f=Object.getOwnPropertySymbols;var Y_=Object.prototype.hasOwnProperty,z_=Object.prototype.propertyIsEnumerable;var Nf=(n,e,t)=>e in n?G_(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,gc=(n,e)=>{for(var t in e||(e={}))Y_.call(e,t)&&Nf(n,t,e[t]);if($f)for(var t of $f(e))z_.call(e,t)&&Nf(n,t,e[t]);return n},Lf=(n,e)=>W_(n,H_(e));var za,J,qm,jm,Ra,Vm,Bf,Gm,dl={},Wm=[],J_=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function zn(n,e){for(var t in e)n[t]=e[t];return n}function Hm(n){var e=n.parentNode;e&&e.removeChild(n)}function wt(n,e,t){var r,i,s,o={};for(s in e)s=="key"?r=e[s]:s=="ref"?i=e[s]:o[s]=e[s];if(arguments.length>2&&(o.children=arguments.length>3?za.call(arguments,2):t),typeof n=="function"&&n.defaultProps!=null)for(s in n.defaultProps)o[s]===void 0&&(o[s]=n.defaultProps[s]);return Ia(n,o,r,i,null)}function Ia(n,e,t,r,i){var s={type:n,props:e,key:t,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:i==null?++qm:i};return i==null&&J.vnode!=null&&J.vnode(s),s}function Wh(){return{current:null}}function $r(n){return n.children}function Ur(n,e){this.props=n,this.context=e}function Eo(n,e){if(e==null)return n.__?Eo(n.__,n.__.__k.indexOf(n)+1):null;for(var t;e<n.__k.length;e++)if((t=n.__k[e])!=null&&t.__e!=null)return t.__e;return typeof n.type=="function"?Eo(n):null}function Ym(n){var e,t;if((n=n.__)!=null&&n.__c!=null){for(n.__e=n.__c.base=null,e=0;e<n.__k.length;e++)if((t=n.__k[e])!=null&&t.__e!=null){n.__e=n.__c.base=t.__e;break}return Ym(n)}}function Td(n){(!n.__d&&(n.__d=!0)&&Ra.push(n)&&!hl.__r++||Bf!==J.debounceRendering)&&((Bf=J.debounceRendering)||Vm)(hl)}function hl(){for(var n;hl.__r=Ra.length;)n=Ra.sort(function(e,t){return e.__v.__b-t.__v.__b}),Ra=[],n.some(function(e){var t,r,i,s,o,a;e.__d&&(o=(s=(t=e).__v).__e,(a=t.__P)&&(r=[],(i=zn({},s)).__v=s.__v+1,Hh(a,s,i,t.__n,a.ownerSVGElement!==void 0,s.__h!=null?[o]:null,r,o==null?Eo(s):o,s.__h),Qm(r,s),s.__e!=o&&Ym(s)))})}function zm(n,e,t,r,i,s,o,a,l,u){var c,g,m,f,E,I,w,k=r&&r.__k||Wm,C=k.length;for(t.__k=[],c=0;c<e.length;c++)if((f=t.__k[c]=(f=e[c])==null||typeof f=="boolean"?null:typeof f=="string"||typeof f=="number"||typeof f=="bigint"?Ia(null,f,null,null,f):Array.isArray(f)?Ia($r,{children:f},null,null,null):f.__b>0?Ia(f.type,f.props,f.key,null,f.__v):f)!=null){if(f.__=t,f.__b=t.__b+1,(m=k[c])===null||m&&f.key==m.key&&f.type===m.type)k[c]=void 0;else for(g=0;g<C;g++){if((m=k[g])&&f.key==m.key&&f.type===m.type){k[g]=void 0;break}m=null}Hh(n,f,m=m||dl,i,s,o,a,l,u),E=f.__e,(g=f.ref)&&m.ref!=g&&(w||(w=[]),m.ref&&w.push(m.ref,null,f),w.push(g,f.__c||E,f)),E!=null?(I==null&&(I=E),typeof f.type=="function"&&f.__k===m.__k?f.__d=l=Jm(f,l,n):l=Xm(n,f,m,k,E,l),typeof t.type=="function"&&(t.__d=l)):l&&m.__e==l&&l.parentNode!=n&&(l=Eo(m))}for(t.__e=I,c=C;c--;)k[c]!=null&&(typeof t.type=="function"&&k[c].__e!=null&&k[c].__e==t.__d&&(t.__d=Eo(r,c+1)),ey(k[c],k[c]));if(w)for(c=0;c<w.length;c++)Zm(w[c],w[++c],w[++c])}function Jm(n,e,t){for(var r,i=n.__k,s=0;i&&s<i.length;s++)(r=i[s])&&(r.__=n,e=typeof r.type=="function"?Jm(r,e,t):Xm(t,r,r,i,r.__e,e));return e}function wn(n,e){return e=e||[],n==null||typeof n=="boolean"||(Array.isArray(n)?n.some(function(t){wn(t,e)}):e.push(n)),e}function Xm(n,e,t,r,i,s){var o,a,l;if(e.__d!==void 0)o=e.__d,e.__d=void 0;else if(t==null||i!=s||i.parentNode==null)e:if(s==null||s.parentNode!==n)n.appendChild(i),o=null;else{for(a=s,l=0;(a=a.nextSibling)&&l<r.length;l+=2)if(a==i)break e;n.insertBefore(i,s),o=s}return o!==void 0?o:i.nextSibling}function X_(n,e,t,r,i){var s;for(s in t)s==="children"||s==="key"||s in e||fl(n,s,null,t[s],r);for(s in e)i&&typeof e[s]!="function"||s==="children"||s==="key"||s==="value"||s==="checked"||t[s]===e[s]||fl(n,s,e[s],t[s],r)}function Kf(n,e,t){e[0]==="-"?n.setProperty(e,t):n[e]=t==null?"":typeof t!="number"||J_.test(e)?t:t+"px"}function fl(n,e,t,r,i){var s;e:if(e==="style")if(typeof t=="string")n.style.cssText=t;else{if(typeof r=="string"&&(n.style.cssText=r=""),r)for(e in r)t&&e in t||Kf(n.style,e,"");if(t)for(e in t)r&&t[e]===r[e]||Kf(n.style,e,t[e])}else if(e[0]==="o"&&e[1]==="n")s=e!==(e=e.replace(/Capture$/,"")),e=e.toLowerCase()in n?e.toLowerCase().slice(2):e.slice(2),n.l||(n.l={}),n.l[e+s]=t,t?r||n.addEventListener(e,s?qf:Ff,s):n.removeEventListener(e,s?qf:Ff,s);else if(e!=="dangerouslySetInnerHTML"){if(i)e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!=="href"&&e!=="list"&&e!=="form"&&e!=="tabIndex"&&e!=="download"&&e in n)try{n[e]=t==null?"":t;break e}catch{}typeof t=="function"||(t!=null&&(t!==!1||e[0]==="a"&&e[1]==="r")?n.setAttribute(e,t):n.removeAttribute(e))}}function Ff(n){this.l[n.type+!1](J.event?J.event(n):n)}function qf(n){this.l[n.type+!0](J.event?J.event(n):n)}function Hh(n,e,t,r,i,s,o,a,l){var u,c,g,m,f,E,I,w,k,C,S,T=e.type;if(e.constructor!==void 0)return null;t.__h!=null&&(l=t.__h,a=e.__e=t.__e,e.__h=null,s=[a]),(u=J.__b)&&u(e);try{e:if(typeof T=="function"){if(w=e.props,k=(u=T.contextType)&&r[u.__c],C=u?k?k.props.value:u.__:r,t.__c?I=(c=e.__c=t.__c).__=c.__E:("prototype"in T&&T.prototype.render?e.__c=c=new T(w,C):(e.__c=c=new Ur(w,C),c.constructor=T,c.render=Z_),k&&k.sub(c),c.props=w,c.state||(c.state={}),c.context=C,c.__n=r,g=c.__d=!0,c.__h=[]),c.__s==null&&(c.__s=c.state),T.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=zn({},c.__s)),zn(c.__s,T.getDerivedStateFromProps(w,c.__s))),m=c.props,f=c.state,g)T.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(T.getDerivedStateFromProps==null&&w!==m&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(w,C),!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(w,c.__s,C)===!1||e.__v===t.__v){c.props=w,c.state=c.__s,e.__v!==t.__v&&(c.__d=!1),c.__v=e,e.__e=t.__e,e.__k=t.__k,e.__k.forEach(function(D){D&&(D.__=e)}),c.__h.length&&o.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(w,c.__s,C),c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(m,f,E)})}c.context=C,c.props=w,c.state=c.__s,(u=J.__r)&&u(e),c.__d=!1,c.__v=e,c.__P=n,u=c.render(c.props,c.state,c.context),c.state=c.__s,c.getChildContext!=null&&(r=zn(zn({},r),c.getChildContext())),g||c.getSnapshotBeforeUpdate==null||(E=c.getSnapshotBeforeUpdate(m,f)),S=u!=null&&u.type===$r&&u.key==null?u.props.children:u,zm(n,Array.isArray(S)?S:[S],e,t,r,i,s,o,a,l),c.base=e.__e,e.__h=null,c.__h.length&&o.push(c),I&&(c.__E=c.__=null),c.__e=!1}else s==null&&e.__v===t.__v?(e.__k=t.__k,e.__e=t.__e):e.__e=Q_(t.__e,e,t,r,i,s,o,l);(u=J.diffed)&&u(e)}catch(D){e.__v=null,(l||s!=null)&&(e.__e=a,e.__h=!!l,s[s.indexOf(a)]=null),J.__e(D,e,t)}}function Qm(n,e){J.__c&&J.__c(e,n),n.some(function(t){try{n=t.__h,t.__h=[],n.some(function(r){r.call(t)})}catch(r){J.__e(r,t.__v)}})}function Q_(n,e,t,r,i,s,o,a){var l,u,c,g=t.props,m=e.props,f=e.type,E=0;if(f==="svg"&&(i=!0),s!=null){for(;E<s.length;E++)if((l=s[E])&&"setAttribute"in l==!!f&&(f?l.localName===f:l.nodeType===3)){n=l,s[E]=null;break}}if(n==null){if(f===null)return document.createTextNode(m);n=i?document.createElementNS("http://www.w3.org/2000/svg",f):document.createElement(f,m.is&&m),s=null,a=!1}if(f===null)g===m||a&&n.data===m||(n.data=m);else{if(s=s&&za.call(n.childNodes),u=(g=t.props||dl).dangerouslySetInnerHTML,c=m.dangerouslySetInnerHTML,!a){if(s!=null)for(g={},E=0;E<n.attributes.length;E++)g[n.attributes[E].name]=n.attributes[E].value;(c||u)&&(c&&(u&&c.__html==u.__html||c.__html===n.innerHTML)||(n.innerHTML=c&&c.__html||""))}if(X_(n,m,g,i,a),c)e.__k=[];else if(E=e.props.children,zm(n,Array.isArray(E)?E:[E],e,t,r,i&&f!=="foreignObject",s,o,s?s[0]:t.__k&&Eo(t,0),a),s!=null)for(E=s.length;E--;)s[E]!=null&&Hm(s[E]);a||("value"in m&&(E=m.value)!==void 0&&(E!==n.value||f==="progress"&&!E||f==="option"&&E!==g.value)&&fl(n,"value",E,g.value,!1),"checked"in m&&(E=m.checked)!==void 0&&E!==n.checked&&fl(n,"checked",E,g.checked,!1))}return n}function Zm(n,e,t){try{typeof n=="function"?n(e):n.current=e}catch(r){J.__e(r,t)}}function ey(n,e,t){var r,i;if(J.unmount&&J.unmount(n),(r=n.ref)&&(r.current&&r.current!==n.__e||Zm(r,null,e)),(r=n.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(s){J.__e(s,e)}r.base=r.__P=null}if(r=n.__k)for(i=0;i<r.length;i++)r[i]&&ey(r[i],e,typeof n.type!="function");t||n.__e==null||Hm(n.__e),n.__e=n.__d=void 0}function Z_(n,e,t){return this.constructor(n,t)}function So(n,e,t){var r,i,s;J.__&&J.__(n,e),i=(r=typeof t=="function")?null:t&&t.__k||e.__k,s=[],Hh(e,n=(!r&&t||e).__k=wt($r,null,[n]),i||dl,dl,e.ownerSVGElement!==void 0,!r&&t?[t]:i?null:e.firstChild?za.call(e.childNodes):null,s,!r&&t?t:i?i.__e:e.firstChild,r),Qm(s,n)}function Yh(n,e){So(n,e,Yh)}function ty(n,e,t){var r,i,s,o=zn({},n.props);for(s in e)s=="key"?r=e[s]:s=="ref"?i=e[s]:o[s]=e[s];return arguments.length>2&&(o.children=arguments.length>3?za.call(arguments,2):t),Ia(n.type,o,r||n.key,i||n.ref,null)}function Ao(n,e){var t={__c:e="__cC"+Gm++,__:n,Consumer:function(r,i){return r.children(i)},Provider:function(r){var i,s;return this.getChildContext||(i=[],(s={})[e]=this,this.getChildContext=function(){return s},this.shouldComponentUpdate=function(o){this.props.value!==o.value&&i.some(Td)},this.sub=function(o){i.push(o);var a=o.componentWillUnmount;o.componentWillUnmount=function(){i.splice(i.indexOf(o),1),a&&a.call(o)}}),r.children}};return t.Provider.__=t.Consumer.contextType=t}za=Wm.slice,J={__e:function(n,e,t,r){for(var i,s,o;e=e.__;)if((i=e.__c)&&!i.__)try{if((s=i.constructor)&&s.getDerivedStateFromError!=null&&(i.setState(s.getDerivedStateFromError(n)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(n,r||{}),o=i.__d),o)return i.__E=i}catch(a){n=a}throw n}},qm=0,jm=function(n){return n!=null&&n.constructor===void 0},Ur.prototype.setState=function(n,e){var t;t=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=zn({},this.state),typeof n=="function"&&(n=n(zn({},t),this.props)),n&&zn(t,n),n!=null&&this.__v&&(e&&this.__h.push(e),Td(this))},Ur.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),Td(this))},Ur.prototype.render=$r,Ra=[],Vm=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,hl.__r=0,Gm=0;var eE=Object.freeze(Object.defineProperty({__proto__:null,render:So,hydrate:Yh,createElement:wt,h:wt,Fragment:$r,createRef:Wh,get isValidElement(){return jm},Component:Ur,cloneElement:ty,createContext:Ao,toChildArray:wn,get options(){return J}},Symbol.toStringTag,{value:"Module"})),Os,bt,jf,bo=0,ry=[],Vf=J.__b,Gf=J.__r,Wf=J.diffed,Hf=J.__c,Yf=J.unmount;function Do(n,e){J.__h&&J.__h(bt,n,bo||e),bo=0;var t=bt.__H||(bt.__H={__:[],__h:[]});return n>=t.__.length&&t.__.push({}),t.__[n]}function Ml(n){return bo=1,zh(sy,n)}function zh(n,e,t){var r=Do(Os++,2);return r.t=n,r.__c||(r.__=[t?t(e):sy(void 0,e),function(i){var s=r.t(r.__[0],i);r.__[0]!==s&&(r.__=[s,r.__[1]],r.__c.setState({}))}],r.__c=bt),r.__}function Jh(n,e){var t=Do(Os++,3);!J.__s&&Xh(t.__H,e)&&(t.__=n,t.__H=e,bt.__H.__h.push(t))}function Al(n,e){var t=Do(Os++,4);!J.__s&&Xh(t.__H,e)&&(t.__=n,t.__H=e,bt.__h.push(t))}function Dl(n){return bo=5,ds(function(){return{current:n}},[])}function ny(n,e,t){bo=6,Al(function(){return typeof n=="function"?(n(e()),function(){return n(null)}):n?(n.current=e(),function(){return n.current=null}):void 0},t==null?t:t.concat(n))}function ds(n,e){var t=Do(Os++,7);return Xh(t.__H,e)&&(t.__=n(),t.__H=e,t.__h=n),t.__}function xl(n,e){return bo=8,ds(function(){return n},e)}function ei(n){var e=bt.context[n.__c],t=Do(Os++,9);return t.c=n,e?(t.__==null&&(t.__=!0,e.sub(bt)),e.props.value):n.__}function iy(n,e){J.useDebugValue&&J.useDebugValue(e?e(n):n)}function tE(n){var e=Do(Os++,10),t=Ml();return e.__=n,bt.componentDidCatch||(bt.componentDidCatch=function(r){e.__&&e.__(r),t[1](r)}),[t[0],function(){t[1](void 0)}]}function rE(){for(var n;n=ry.shift();)if(n.__P)try{n.__H.__h.forEach(Jc),n.__H.__h.forEach(Od),n.__H.__h=[]}catch(e){n.__H.__h=[],J.__e(e,n.__v)}}J.__b=function(n){bt=null,Vf&&Vf(n)},J.__r=function(n){Gf&&Gf(n),Os=0;var e=(bt=n.__c).__H;e&&(e.__h.forEach(Jc),e.__h.forEach(Od),e.__h=[])},J.diffed=function(n){Wf&&Wf(n);var e=n.__c;e&&e.__H&&e.__H.__h.length&&(ry.push(e)!==1&&jf===J.requestAnimationFrame||((jf=J.requestAnimationFrame)||function(t){var r,i=function(){clearTimeout(s),zf&&cancelAnimationFrame(r),setTimeout(t)},s=setTimeout(i,100);zf&&(r=requestAnimationFrame(i))})(rE)),bt=null},J.__c=function(n,e){e.some(function(t){try{t.__h.forEach(Jc),t.__h=t.__h.filter(function(r){return!r.__||Od(r)})}catch(r){e.some(function(i){i.__h&&(i.__h=[])}),e=[],J.__e(r,t.__v)}}),Hf&&Hf(n,e)},J.unmount=function(n){Yf&&Yf(n);var e,t=n.__c;t&&t.__H&&(t.__H.__.forEach(function(r){try{Jc(r)}catch(i){e=i}}),e&&J.__e(e,t.__v))};var zf=typeof requestAnimationFrame=="function";function Jc(n){var e=bt,t=n.__c;typeof t=="function"&&(n.__c=void 0,t()),bt=e}function Od(n){var e=bt;n.__c=n.__(),bt=e}function Xh(n,e){return!n||n.length!==e.length||e.some(function(t,r){return t!==n[r]})}function sy(n,e){return typeof e=="function"?e(n):e}function oy(n,e){for(var t in e)n[t]=e[t];return n}function kd(n,e){for(var t in n)if(t!=="__source"&&!(t in e))return!0;for(var r in e)if(r!=="__source"&&n[r]!==e[r])return!0;return!1}function pl(n){this.props=n}function ay(n,e){function t(i){var s=this.props.ref,o=s==i.ref;return!o&&s&&(s.call?s(null):s.current=null),e?!e(this.props,i)||!o:kd(this.props,i)}function r(i){return this.shouldComponentUpdate=t,wt(n,i)}return r.displayName="Memo("+(n.displayName||n.name)+")",r.prototype.isReactComponent=!0,r.__f=!0,r}(pl.prototype=new Ur).isPureReactComponent=!0,pl.prototype.shouldComponentUpdate=function(n,e){return kd(this.props,n)||kd(this.state,e)};var Jf=J.__b;J.__b=function(n){n.type&&n.type.__f&&n.ref&&(n.props.ref=n.ref,n.ref=null),Jf&&Jf(n)};var nE=typeof Symbol!="undefined"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function Qh(n){function e(t,r){var i=oy({},t);return delete i.ref,n(i,!(r=t.ref||r)||typeof r=="object"&&Object.keys(r).length===0?null:r)}return e.$$typeof=nE,e.render=e,e.prototype.isReactComponent=e.__f=!0,e.displayName="ForwardRef("+(n.displayName||n.name)+")",e}var Xf=function(n,e){return n==null?null:wn(wn(n).map(e))},Zh={map:Xf,forEach:Xf,count:function(n){return n?wn(n).length:0},only:function(n){var e=wn(n);if(e.length!==1)throw"Children.only";return e[0]},toArray:wn},iE=J.__e;J.__e=function(n,e,t,r){if(n.then){for(var i,s=e;s=s.__;)if((i=s.__c)&&i.__c)return e.__e==null&&(e.__e=t.__e,e.__k=t.__k),i.__c(n,e)}iE(n,e,t,r)};var Qf=J.unmount;function Ta(){this.__u=0,this.t=null,this.__b=null}function cy(n){var e=n.__.__c;return e&&e.__e&&e.__e(n)}function ly(n){var e,t,r;function i(s){if(e||(e=n()).then(function(o){t=o.default||o},function(o){r=o}),r)throw r;if(!t)throw e;return wt(t,s)}return i.displayName="Lazy",i.__f=!0,i}function lo(){this.u=null,this.o=null}J.unmount=function(n){var e=n.__c;e&&e.__R&&e.__R(),e&&n.__h===!0&&(n.type=null),Qf&&Qf(n)},(Ta.prototype=new Ur).__c=function(n,e){var t=e.__c,r=this;r.t==null&&(r.t=[]),r.t.push(t);var i=cy(r.__v),s=!1,o=function(){s||(s=!0,t.__R=null,i?i(a):a())};t.__R=o;var a=function(){if(!--r.__u){if(r.state.__e){var u=r.state.__e;r.__v.__k[0]=function g(m,f,E){return m&&(m.__v=null,m.__k=m.__k&&m.__k.map(function(I){return g(I,f,E)}),m.__c&&m.__c.__P===f&&(m.__e&&E.insertBefore(m.__e,m.__d),m.__c.__e=!0,m.__c.__P=E)),m}(u,u.__c.__P,u.__c.__O)}var c;for(r.setState({__e:r.__b=null});c=r.t.pop();)c.forceUpdate()}},l=e.__h===!0;r.__u++||l||r.setState({__e:r.__b=r.__v.__k[0]}),n.then(o,o)},Ta.prototype.componentWillUnmount=function(){this.t=[]},Ta.prototype.render=function(n,e){if(this.__b){if(this.__v.__k){var t=document.createElement("div"),r=this.__v.__k[0].__c;this.__v.__k[0]=function s(o,a,l){return o&&(o.__c&&o.__c.__H&&(o.__c.__H.__.forEach(function(u){typeof u.__c=="function"&&u.__c()}),o.__c.__H=null),(o=oy({},o)).__c!=null&&(o.__c.__P===l&&(o.__c.__P=a),o.__c=null),o.__k=o.__k&&o.__k.map(function(u){return s(u,a,l)})),o}(this.__b,t,r.__O=r.__P)}this.__b=null}var i=e.__e&&wt($r,null,n.fallback);return i&&(i.__h=null),[wt($r,null,e.__e?null:n.children),i]};var Zf=function(n,e,t){if(++t[1]===t[0]&&n.o.delete(e),n.props.revealOrder&&(n.props.revealOrder[0]!=="t"||!n.o.size))for(t=n.u;t;){for(;t.length>3;)t.pop()();if(t[1]<t[0])break;n.u=t=t[2]}};function sE(n){return this.getChildContext=function(){return n.context},n.children}function oE(n){var e=this,t=n.i;e.componentWillUnmount=function(){So(null,e.l),e.l=null,e.i=null},e.i&&e.i!==t&&e.componentWillUnmount(),n.__v?(e.l||(e.i=t,e.l={nodeType:1,parentNode:t,childNodes:[],appendChild:function(r){this.childNodes.push(r),e.i.appendChild(r)},insertBefore:function(r,i){this.childNodes.push(r),e.i.appendChild(r)},removeChild:function(r){this.childNodes.splice(this.childNodes.indexOf(r)>>>1,1),e.i.removeChild(r)}}),So(wt(sE,{context:e.context},n.__v),e.l)):e.l&&e.componentWillUnmount()}function uy(n,e){return wt(oE,{__v:n,i:e})}(lo.prototype=new Ur).__e=function(n){var e=this,t=cy(e.__v),r=e.o.get(n);return r[0]++,function(i){var s=function(){e.props.revealOrder?(r.push(i),Zf(e,n,r)):i()};t?t(s):s()}},lo.prototype.render=function(n){this.u=null,this.o=new Map;var e=wn(n.children);n.revealOrder&&n.revealOrder[0]==="b"&&e.reverse();for(var t=e.length;t--;)this.o.set(e[t],this.u=[1,0,this.u]);return n.children},lo.prototype.componentDidUpdate=lo.prototype.componentDidMount=function(){var n=this;this.o.forEach(function(e,t){Zf(n,t,e)})};var dy=typeof Symbol!="undefined"&&Symbol.for&&Symbol.for("react.element")||60103,aE=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|marker(?!H|W|U)|overline|paint|stop|strikethrough|stroke|text(?!L)|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,cE=typeof document!="undefined",lE=function(n){return(typeof Symbol!="undefined"&&typeof Symbol()=="symbol"?/fil|che|rad/i:/fil|che|ra/i).test(n)};function hy(n,e,t){return e.__k==null&&(e.textContent=""),So(n,e),typeof t=="function"&&t(),n?n.__c:null}function fy(n,e,t){return Yh(n,e),typeof t=="function"&&t(),n?n.__c:null}Ur.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(n){Object.defineProperty(Ur.prototype,n,{configurable:!0,get:function(){return this["UNSAFE_"+n]},set:function(e){Object.defineProperty(this,n,{configurable:!0,writable:!0,value:e})}})});var ep=J.event;function uE(){}function dE(){return this.cancelBubble}function hE(){return this.defaultPrevented}J.event=function(n){return ep&&(n=ep(n)),n.persist=uE,n.isPropagationStopped=dE,n.isDefaultPrevented=hE,n.nativeEvent=n};var py,tp={configurable:!0,get:function(){return this.class}},rp=J.vnode;J.vnode=function(n){var e=n.type,t=n.props,r=t;if(typeof e=="string"){var i=e.indexOf("-")===-1;for(var s in r={},t){var o=t[s];cE&&s==="children"&&e==="noscript"||s==="value"&&"defaultValue"in t&&o==null||(s==="defaultValue"&&"value"in t&&t.value==null?s="value":s==="download"&&o===!0?o="":/ondoubleclick/i.test(s)?s="ondblclick":/^onchange(textarea|input)/i.test(s+e)&&!lE(t.type)?s="oninput":/^onfocus$/i.test(s)?s="onfocusin":/^onblur$/i.test(s)?s="onfocusout":/^on(Ani|Tra|Tou|BeforeInp|Compo)/.test(s)?s=s.toLowerCase():i&&aE.test(s)?s=s.replace(/[A-Z0-9]/,"-$&").toLowerCase():o===null&&(o=void 0),r[s]=o)}e=="select"&&r.multiple&&Array.isArray(r.value)&&(r.value=wn(t.children).forEach(function(a){a.props.selected=r.value.indexOf(a.props.value)!=-1})),e=="select"&&r.defaultValue!=null&&(r.value=wn(t.children).forEach(function(a){a.props.selected=r.multiple?r.defaultValue.indexOf(a.props.value)!=-1:r.defaultValue==a.props.value})),n.props=r,t.class!=t.className&&(tp.enumerable="className"in t,t.className!=null&&(r.class=t.className),Object.defineProperty(r,"className",tp))}n.$$typeof=dy,rp&&rp(n)};var np=J.__r;J.__r=function(n){np&&np(n),py=n.__c};var gy={ReactCurrentDispatcher:{current:{readContext:function(n){return py.__n[n.__c].props.value}}}},fE="17.0.2";function my(n){return wt.bind(null,n)}function Ul(n){return!!n&&n.$$typeof===dy}function yy(n){return Ul(n)?ty.apply(null,arguments):n}function vy(n){return!!n.__k&&(So(null,n),!0)}function _y(n){return n&&(n.base||n.nodeType===1&&n)||null}var Ey=function(n,e){return n(e)},Sy=function(n,e){return n(e)},pE=$r,gE={useState:Ml,useReducer:zh,useEffect:Jh,useLayoutEffect:Al,useRef:Dl,useImperativeHandle:ny,useMemo:ds,useCallback:xl,useContext:ei,useDebugValue:iy,version:"17.0.2",Children:Zh,render:hy,hydrate:fy,unmountComponentAtNode:vy,createPortal:uy,createElement:wt,createContext:Ao,createFactory:my,cloneElement:yy,createRef:Wh,Fragment:$r,isValidElement:Ul,findDOMNode:_y,Component:Ur,PureComponent:pl,memo:ay,forwardRef:Qh,flushSync:Sy,unstable_batchedUpdates:Ey,StrictMode:$r,Suspense:Ta,SuspenseList:lo,lazy:ly,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:gy},mE=Object.freeze(Object.defineProperty({__proto__:null,default:gE,version:fE,Children:Zh,render:hy,hydrate:fy,unmountComponentAtNode:vy,createPortal:uy,createFactory:my,cloneElement:yy,isValidElement:Ul,findDOMNode:_y,PureComponent:pl,memo:ay,forwardRef:Qh,flushSync:Sy,unstable_batchedUpdates:Ey,StrictMode:pE,Suspense:Ta,SuspenseList:lo,lazy:ly,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:gy,createElement:wt,createContext:Ao,createRef:Wh,Fragment:$r,Component:Ur,useState:Ml,useReducer:zh,useEffect:Jh,useLayoutEffect:Al,useRef:Dl,useImperativeHandle:ny,useMemo:ds,useCallback:xl,useContext:ei,useDebugValue:iy,useErrorBoundary:tE},Symbol.toStringTag,{value:"Module"}));function gl(){return gl=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},gl.apply(this,arguments)}var ss;(function(n){n.Pop="POP",n.Push="PUSH",n.Replace="REPLACE"})(ss||(ss={}));var ip=function(n){return n},sp="beforeunload",yE="popstate";function vE(n){n===void 0&&(n={});var e=n,t=e.window,r=t===void 0?document.defaultView:t,i=r.history;function s(){var U=r.location,q=U.pathname,B=U.search,te=U.hash,ye=i.state||{};return[ye.idx,ip({pathname:q,search:B,hash:te,state:ye.usr||null,key:ye.key||"default"})]}var o=null;function a(){if(o)f.call(o),o=null;else{var U=ss.Pop,q=s(),B=q[0],te=q[1];if(f.length){if(B!=null){var ye=c-B;ye&&(o={action:U,location:te,retry:function(){D(ye*-1)}},D(ye))}}else C(U)}}r.addEventListener(yE,a);var l=ss.Pop,u=s(),c=u[0],g=u[1],m=ap(),f=ap();c==null&&(c=0,i.replaceState(gl({},i.state,{idx:c}),""));function E(U){return typeof U=="string"?U:Cd(U)}function I(U,q){return q===void 0&&(q=null),ip(gl({pathname:g.pathname,hash:"",search:""},typeof U=="string"?ks(U):U,{state:q,key:_E()}))}function w(U,q){return[{usr:U.state,key:U.key,idx:q},E(U)]}function k(U,q,B){return!f.length||(f.call({action:U,location:q,retry:B}),!1)}function C(U){l=U;var q=s();c=q[0],g=q[1],m.call({action:l,location:g})}function S(U,q){var B=ss.Push,te=I(U,q);function ye(){S(U,q)}if(k(B,te,ye)){var we=w(te,c+1),Te=we[0],Ye=we[1];try{i.pushState(Te,"",Ye)}catch{r.location.assign(Ye)}C(B)}}function T(U,q){var B=ss.Replace,te=I(U,q);function ye(){T(U,q)}if(k(B,te,ye)){var we=w(te,c),Te=we[0],Ye=we[1];i.replaceState(Te,"",Ye),C(B)}}function D(U){i.go(U)}var R={get action(){return l},get location(){return g},createHref:E,push:S,replace:T,go:D,back:function(){D(-1)},forward:function(){D(1)},listen:function(q){return m.push(q)},block:function(q){var B=f.push(q);return f.length===1&&r.addEventListener(sp,op),function(){B(),f.length||r.removeEventListener(sp,op)}}};return R}function op(n){n.preventDefault(),n.returnValue=""}function ap(){var n=[];return{get length(){return n.length},push:function(t){return n.push(t),function(){n=n.filter(function(r){return r!==t})}},call:function(t){n.forEach(function(r){return r&&r(t)})}}}function _E(){return Math.random().toString(36).substr(2,8)}function Cd(n){var e=n.pathname,t=e===void 0?"/":e,r=n.search,i=r===void 0?"":r,s=n.hash,o=s===void 0?"":s;return i&&i!=="?"&&(t+=i.charAt(0)==="?"?i:"?"+i),o&&o!=="#"&&(t+=o.charAt(0)==="#"?o:"#"+o),t}function ks(n){var e={};if(n){var t=n.indexOf("#");t>=0&&(e.hash=n.substr(t),n=n.substr(0,t));var r=n.indexOf("?");r>=0&&(e.search=n.substr(r),n=n.substr(0,r)),n&&(e.pathname=n)}return e}/**
+ * React Router v6.3.0
+ *
+ * Copyright (c) Remix Software Inc.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE.md file in the root directory of this source tree.
+ *
+ * @license MIT
+ */const ef=Ao(null),tf=Ao(null),$l=Ao({outlet:null,matches:[]});function In(n,e){if(!n)throw new Error(e)}function EE(n,e,t){t===void 0&&(t="/");let r=typeof e=="string"?ks(e):e,i=Ry(r.pathname||"/",t);if(i==null)return null;let s=by(n);SE(s);let o=null;for(let a=0;o==null&&a<s.length;++a)o=PE(s[a],i);return o}function by(n,e,t,r){return e===void 0&&(e=[]),t===void 0&&(t=[]),r===void 0&&(r=""),n.forEach((i,s)=>{let o={relativePath:i.path||"",caseSensitive:i.caseSensitive===!0,childrenIndex:s,route:i};o.relativePath.startsWith("/")&&(o.relativePath.startsWith(r)||In(!1),o.relativePath=o.relativePath.slice(r.length));let a=Ui([r,o.relativePath]),l=t.concat(o);i.children&&i.children.length>0&&(i.index===!0&&In(!1),by(i.children,e,l,a)),!(i.path==null&&!i.index)&&e.push({path:a,score:kE(a,i.index),routesMeta:l})}),e}function SE(n){n.sort((e,t)=>e.score!==t.score?t.score-e.score:CE(e.routesMeta.map(r=>r.childrenIndex),t.routesMeta.map(r=>r.childrenIndex)))}const bE=/^:\w+$/,wE=3,RE=2,IE=1,TE=10,OE=-2,cp=n=>n==="*";function kE(n,e){let t=n.split("/"),r=t.length;return t.some(cp)&&(r+=OE),e&&(r+=RE),t.filter(i=>!cp(i)).reduce((i,s)=>i+(bE.test(s)?wE:s===""?IE:TE),r)}function CE(n,e){return n.length===e.length&&n.slice(0,-1).every((r,i)=>r===e[i])?n[n.length-1]-e[e.length-1]:0}function PE(n,e){let{routesMeta:t}=n,r={},i="/",s=[];for(let o=0;o<t.length;++o){let a=t[o],l=o===t.length-1,u=i==="/"?e:e.slice(i.length)||"/",c=ME({path:a.relativePath,caseSensitive:a.caseSensitive,end:l},u);if(!c)return null;Object.assign(r,c.params);let g=a.route;s.push({params:r,pathname:Ui([i,c.pathname]),pathnameBase:Iy(Ui([i,c.pathnameBase])),route:g}),c.pathnameBase!=="/"&&(i=Ui([i,c.pathnameBase]))}return s}function ME(n,e){typeof n=="string"&&(n={path:n,caseSensitive:!1,end:!0});let[t,r]=AE(n.path,n.caseSensitive,n.end),i=e.match(t);if(!i)return null;let s=i[0],o=s.replace(/(.)\/+$/,"$1"),a=i.slice(1);return{params:r.reduce((u,c,g)=>{if(c==="*"){let m=a[g]||"";o=s.slice(0,s.length-m.length).replace(/(.)\/+$/,"$1")}return u[c]=DE(a[g]||""),u},{}),pathname:s,pathnameBase:o,pattern:n}}function AE(n,e,t){e===void 0&&(e=!1),t===void 0&&(t=!0);let r=[],i="^"+n.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^$?{}|()[\]]/g,"\\$&").replace(/:(\w+)/g,(o,a)=>(r.push(a),"([^\\/]+)"));return n.endsWith("*")?(r.push("*"),i+=n==="*"||n==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):i+=t?"\\/*$":"(?:(?=[.~-]|%[0-9A-F]{2})|\\b|\\/|$)",[new RegExp(i,e?void 0:"i"),r]}function DE(n,e){try{return decodeURIComponent(n)}catch{return n}}function xE(n,e){e===void 0&&(e="/");let{pathname:t,search:r="",hash:i=""}=typeof n=="string"?ks(n):n;return{pathname:t?t.startsWith("/")?t:UE(t,e):e,search:NE(r),hash:LE(i)}}function UE(n,e){let t=e.replace(/\/+$/,"").split("/");return n.split("/").forEach(i=>{i===".."?t.length>1&&t.pop():i!=="."&&t.push(i)}),t.length>1?t.join("/"):"/"}function wy(n,e,t){let r=typeof n=="string"?ks(n):n,i=n===""||r.pathname===""?"/":r.pathname,s;if(i==null)s=t;else{let a=e.length-1;if(i.startsWith("..")){let l=i.split("/");for(;l[0]==="..";)l.shift(),a-=1;r.pathname=l.join("/")}s=a>=0?e[a]:"/"}let o=xE(r,s);return i&&i!=="/"&&i.endsWith("/")&&!o.pathname.endsWith("/")&&(o.pathname+="/"),o}function $E(n){return n===""||n.pathname===""?"/":typeof n=="string"?ks(n).pathname:n.pathname}function Ry(n,e){if(e==="/")return n;if(!n.toLowerCase().startsWith(e.toLowerCase()))return null;let t=n.charAt(e.length);return t&&t!=="/"?null:n.slice(e.length)||"/"}const Ui=n=>n.join("/").replace(/\/\/+/g,"/"),Iy=n=>n.replace(/\/+$/,"").replace(/^\/*/,"/"),NE=n=>!n||n==="?"?"":n.startsWith("?")?n:"?"+n,LE=n=>!n||n==="#"?"":n.startsWith("#")?n:"#"+n;function BE(n){Ja()||In(!1);let{basename:e,navigator:t}=ei(ef),{hash:r,pathname:i,search:s}=Ty(n),o=i;if(e!=="/"){let a=$E(n),l=a!=null&&a.endsWith("/");o=i==="/"?e+(l?"/":""):Ui([e,i])}return t.createHref({pathname:o,search:s,hash:r})}function Ja(){return ei(tf)!=null}function Nl(){return Ja()||In(!1),ei(tf).location}function KE(){Ja()||In(!1);let{basename:n,navigator:e}=ei(ef),{matches:t}=ei($l),{pathname:r}=Nl(),i=JSON.stringify(t.map(a=>a.pathnameBase)),s=Dl(!1);return Jh(()=>{s.current=!0}),xl(function(a,l){if(l===void 0&&(l={}),!s.current)return;if(typeof a=="number"){e.go(a);return}let u=wy(a,JSON.parse(i),r);n!=="/"&&(u.pathname=Ui([n,u.pathname])),(l.replace?e.replace:e.push)(u,l.state)},[n,e,i,r])}function Ty(n){let{matches:e}=ei($l),{pathname:t}=Nl(),r=JSON.stringify(e.map(i=>i.pathnameBase));return ds(()=>wy(n,JSON.parse(r),t),[n,r,t])}function FE(n,e){Ja()||In(!1);let{matches:t}=ei($l),r=t[t.length-1],i=r?r.params:{};r&&r.pathname;let s=r?r.pathnameBase:"/";r&&r.route;let o=Nl(),a;if(e){var l;let m=typeof e=="string"?ks(e):e;s==="/"||((l=m.pathname)==null?void 0:l.startsWith(s))||In(!1),a=m}else a=o;let u=a.pathname||"/",c=s==="/"?u:u.slice(s.length)||"/",g=EE(n,{pathname:c});return qE(g&&g.map(m=>Object.assign({},m,{params:Object.assign({},i,m.params),pathname:Ui([s,m.pathname]),pathnameBase:m.pathnameBase==="/"?s:Ui([s,m.pathnameBase])})),t)}function qE(n,e){return e===void 0&&(e=[]),n==null?null:n.reduceRight((t,r,i)=>wt($l.Provider,{children:r.route.element!==void 0?r.route.element:t,value:{outlet:t,matches:e.concat(n.slice(0,i+1))}}),null)}function jE(n){In(!1)}function VE(n){let{basename:e="/",children:t=null,location:r,navigationType:i=ss.Pop,navigator:s,static:o=!1}=n;Ja()&&In(!1);let a=Iy(e),l=ds(()=>({basename:a,navigator:s,static:o}),[a,s,o]);typeof r=="string"&&(r=ks(r));let{pathname:u="/",search:c="",hash:g="",state:m=null,key:f="default"}=r,E=ds(()=>{let I=Ry(u,a);return I==null?null:{pathname:I,search:c,hash:g,state:m,key:f}},[a,u,c,g,m,f]);return E==null?null:wt(ef.Provider,{value:l},wt(tf.Provider,{children:t,value:{location:E,navigationType:i}}))}function pD(n){let{children:e,location:t}=n;return FE(Pd(e),t)}function Pd(n){let e=[];return Zh.forEach(n,t=>{if(!Ul(t))return;if(t.type===$r){e.push.apply(e,Pd(t.props.children));return}t.type!==jE&&In(!1);let r={caseSensitive:t.props.caseSensitive,element:t.props.element,index:t.props.index,path:t.props.path};t.props.children&&(r.children=Pd(t.props.children)),e.push(r)}),e}/**
+ * React Router DOM v6.3.0
+ *
+ * Copyright (c) Remix Software Inc.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE.md file in the root directory of this source tree.
+ *
+ * @license MIT
+ */function Md(){return Md=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},Md.apply(this,arguments)}function GE(n,e){if(n==null)return{};var t={},r=Object.keys(n),i,s;for(s=0;s<r.length;s++)i=r[s],!(e.indexOf(i)>=0)&&(t[i]=n[i]);return t}const WE=["onClick","reloadDocument","replace","state","target","to"];function gD(n){let{basename:e,children:t,window:r}=n,i=Dl();i.current==null&&(i.current=vE({window:r}));let s=i.current,[o,a]=Ml({action:s.action,location:s.location});return Al(()=>s.listen(a),[s]),wt(VE,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:s})}function HE(n){return!!(n.metaKey||n.altKey||n.ctrlKey||n.shiftKey)}const mD=Qh(function(e,t){let{onClick:r,reloadDocument:i,replace:s=!1,state:o,target:a,to:l}=e,u=GE(e,WE),c=BE(l),g=YE(l,{replace:s,state:o,target:a});function m(f){r&&r(f),!f.defaultPrevented&&!i&&g(f)}return wt("a",Md({},u,{href:c,onClick:m,ref:t,target:a}))});function YE(n,e){let{target:t,replace:r,state:i}=e===void 0?{}:e,s=KE(),o=Nl(),a=Ty(n);return xl(l=>{if(l.button===0&&(!t||t==="_self")&&!HE(l)){l.preventDefault();let u=!!r||Cd(o)===Cd(a);s(n,{replace:u,state:i})}},[o,s,a,r,i,t,n])}var V=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function rf(n){if(n.__esModule)return n;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(n).forEach(function(t){var r=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:function(){return n[t]}})}),e}var zE=rf(eE),JE,XE,lp=zE,QE=0;function up(n,e,t,r,i){var s,o,a={};for(o in e)o=="ref"?s=e[o]:a[o]=e[o];var l={type:n,props:a,key:t,ref:s,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:--QE,__source:i,__self:r};if(typeof n=="function"&&(s=n.defaultProps))for(o in s)a[o]===void 0&&(a[o]=s[o]);return lp.options.vnode&&lp.options.vnode(l),l}XE=up,JE=up;var Oy={},ZE=rf(mE);function eS(n){if(n&&n.__esModule)return n;var e=Object.create(null);return n&&Object.keys(n).forEach(function(t){if(t!=="default"){var r=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:function(){return n[t]}})}}),e.default=n,Object.freeze(e)}Object.defineProperty(Oy,"__esModule",{value:!0});var Fn=eS(ZE);function tS({debounceMs:n}){const[e,t]=Fn.useState(window.innerWidth),r=function(i,s){let o=null;return(...a)=>{clearTimeout(o),o=setTimeout(()=>i(a),s)}}(()=>t(window.innerWidth),n);return Fn.useEffect(()=>(window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)),[r]),e}const rS=Fn.forwardRef(({as:n="div",children:e,className:t,style:r,gap:i=10,debounce:s=200,nColumns:o=3},a)=>{const l=tS({debounceMs:s}),[u,c]=Fn.useState([]);Fn.useLayoutEffect(()=>{var I;const m=w=>w.sort((k,C)=>k.size-C.size),f=typeof o=="number"?{columns:o}:(I=(w=>w==null?void 0:w[w.length-1])(m(((w,k)=>w.filter(C=>C.size<=k))(o,l))))!=null?I:(w=>w==null?void 0:w[0])(m(o)),E=Array.from({length:f.columns},w=>[]);Fn.Children.forEach(e,(w,k)=>{const C=`item-${k}`,S=Fn.cloneElement(w,Lf(gc({},w.props),{key:C}));E[k%E.length].push(S)}),c(E)},[e,o,l]);const g={mainGrid:{display:"grid",gridTemplateColumns:`repeat(${u.length}, 1fr)`,columnGap:i,alignItems:"start"},columnGrid:{display:"grid",gridTemplateColumns:"100%",rowGap:i}};return Fn.createElement(n,{ref:a,"data-testid":"plock-container",className:t,style:gc({style:r},g.mainGrid)},u.map((m,f)=>Fn.createElement("div",{"data-testid":"plock-column",style:g.columnGrid,key:f},m)))});var yD=Oy.Plock=rS,nS={},G={exports:{}};(function(n){function e(t){return t&&t.__esModule?t:{default:t}}n.exports=e,n.exports.__esModule=!0,n.exports.default=n.exports})(G);var ky={exports:{}};(function(n,e){(function(t,r){n.exports=r()})(V,function(){var t=XMLHttpRequest;if(!t)throw new Error("missing XMLHttpRequest");i.log={trace:l,debug:l,info:l,warn:l,error:l};var r=3*60*1e3;function i(f,E){if(typeof E!="function")throw new Error("Bad callback given: "+E);if(!f)throw new Error("No options given");var I=f.onResponse;if(typeof f=="string"?f={uri:f}:f=JSON.parse(JSON.stringify(f)),f.onResponse=I,f.verbose&&(i.log=u()),f.url&&(f.uri=f.url,delete f.url),!f.uri&&f.uri!=="")throw new Error("options.uri is a required argument");if(typeof f.uri!="string")throw new Error("options.uri must be a string");for(var w=["proxy","_redirectsFollowed","maxRedirects","followRedirect"],k=0;k<w.length;k++)if(f[w[k]])throw new Error("options."+w[k]+" is not supported");if(f.callback=E,f.method=f.method||"GET",f.headers=f.headers||{},f.body=f.body||null,f.timeout=f.timeout||i.DEFAULT_TIMEOUT,f.headers.host)throw new Error("Options.headers.host is not supported");f.json&&(f.headers.accept=f.headers.accept||"application/json",f.method!=="GET"&&(f.headers["content-type"]="application/json"),typeof f.json!="boolean"?f.body=JSON.stringify(f.json):typeof f.body!="string"&&(f.body=JSON.stringify(f.body)));var C=function(U){var q=[];for(var B in U)U.hasOwnProperty(B)&&q.push(encodeURIComponent(B)+"="+encodeURIComponent(U[B]));return q.join("&")};if(f.qs){var S=typeof f.qs=="string"?f.qs:C(f.qs);f.uri.indexOf("?")!==-1?f.uri=f.uri+"&"+S:f.uri=f.uri+"?"+S}var T=function(U){var q={};q.boundry="-------------------------------"+Math.floor(Math.random()*1e9);var B=[];for(var te in U)U.hasOwnProperty(te)&&B.push("--"+q.boundry+`
+Content-Disposition: form-data; name="`+te+`"
+
+`+U[te]+`
+`);return B.push("--"+q.boundry+"--"),q.body=B.join(""),q.length=q.body.length,q.type="multipart/form-data; boundary="+q.boundry,q};if(f.form){if(typeof f.form=="string")throw"form name unsupported";if(f.method==="POST"){var D=(f.encoding||"application/x-www-form-urlencoded").toLowerCase();switch(f.headers["content-type"]=D,D){case"application/x-www-form-urlencoded":f.body=C(f.form).replace(/%20/g,"+");break;case"multipart/form-data":var R=T(f.form);f.body=R.body,f.headers["content-type"]=R.type;break;default:throw new Error("unsupported encoding:"+D)}}}return f.onResponse=f.onResponse||l,f.onResponse===!0&&(f.onResponse=E,f.callback=l),!f.headers.authorization&&f.auth&&(f.headers.authorization="Basic "+m(f.auth.username+":"+f.auth.password)),o(f)}var s=0;function o(f){var E=new t,I=!1,w=g(f.uri),k="withCredentials"in E;if(s+=1,E.seq_id=s,E.id=s+": "+f.method+" "+f.uri,E._id=E.id,w&&!k){var C=new Error("Browser does not support cross-origin request: "+f.uri);return C.cors="unsupported",f.callback(C,E)}E.timeoutTimer=setTimeout(S,f.timeout);function S(){I=!0;var B=new Error("ETIMEDOUT");return B.code="ETIMEDOUT",B.duration=f.timeout,i.log.error("Timeout",{id:E._id,milliseconds:f.timeout}),f.callback(B,E)}var T={response:!1,loading:!1,end:!1};return E.onreadystatechange=D,E.open(f.method,f.uri,!0),w&&(E.withCredentials=!!f.withCredentials),E.send(f.body),E;function D(B){if(I)return i.log.debug("Ignoring timed out state change",{state:E.readyState,id:E.id});if(i.log.debug("State change",{state:E.readyState,id:E.id,timed_out:I}),E.readyState===t.OPENED){i.log.debug("Request started",{id:E.id});for(var te in f.headers)E.setRequestHeader(te,f.headers[te])}else E.readyState===t.HEADERS_RECEIVED?R():E.readyState===t.LOADING?(R(),U()):E.readyState===t.DONE&&(R(),U(),q())}function R(){if(!T.response){if(T.response=!0,i.log.debug("Got response",{id:E.id,status:E.status}),clearTimeout(E.timeoutTimer),E.statusCode=E.status,w&&E.statusCode==0){var B=new Error("CORS request rejected: "+f.uri);return B.cors="rejected",T.loading=!0,T.end=!0,f.callback(B,E)}f.onResponse(null,E)}}function U(){T.loading||(T.loading=!0,i.log.debug("Response body loading",{id:E.id}))}function q(){if(!T.end){if(T.end=!0,i.log.debug("Request done",{id:E.id}),E.body=E.responseText,f.json)try{E.body=JSON.parse(E.responseText)}catch(B){return f.callback(B,E)}f.callback(null,E,E.body)}}}i.withCredentials=!1,i.DEFAULT_TIMEOUT=r,i.defaults=function(f,E){var I=function(k){var C=function(S,T){typeof S=="string"?S={uri:S}:S=JSON.parse(JSON.stringify(S));for(var D in f)S[D]===void 0&&(S[D]=f[D]);return k(S,T)};return C},w=I(i);return w.get=I(i.get),w.post=I(i.post),w.put=I(i.put),w.head=I(i.head),w};var a=["get","put","post","head"];a.forEach(function(f){var E=f.toUpperCase(),I=f.toLowerCase();i[I]=function(w){typeof w=="string"?w={method:E,uri:w}:(w=JSON.parse(JSON.stringify(w)),w.method=E);var k=[w].concat(Array.prototype.slice.apply(arguments,[1]));return i.apply(this,k)}}),i.couch=function(f,E){typeof f=="string"&&(f={uri:f}),f.json=!0,f.body&&(f.json=f.body),delete f.body,E=E||l;var I=i(f,w);return I;function w(k,C,S){if(k)return E(k,C,S);if((C.statusCode<200||C.statusCode>299)&&S.error){k=new Error("CouchDB error: "+(S.error.reason||S.error.error));for(var T in S)k[T]=S[T];return E(k,C,S)}return E(k,C,S)}};function l(){}function u(){var f={},E=["trace","debug","info","warn","error"],I,w;for(w=0;w<E.length;w++)I=E[w],f[I]=l,typeof console!="undefined"&&console&&console[I]&&(f[I]=c(console,I));return f}function c(f,E){return I;function I(w,k){return typeof k=="object"&&(w+=" "+JSON.stringify(k)),f[E].call(f,w)}}function g(f){var E=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,I;try{I=location.href}catch{I=document.createElement("a"),I.href="",I=I.href}var w=E.exec(I.toLowerCase())||[],k=E.exec(f.toLowerCase()),C=!!(k&&(k[1]!=w[1]||k[2]!=w[2]||(k[3]||(k[1]==="http:"?80:443))!=(w[3]||(w[1]==="http:"?80:443))));return C}function m(f){var E="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",I,w,k,C,S,T,D,R,U=0,q=0,B="",te=[];if(!f)return f;do I=f.charCodeAt(U++),w=f.charCodeAt(U++),k=f.charCodeAt(U++),R=I<<16|w<<8|k,C=R>>18&63,S=R>>12&63,T=R>>6&63,D=R&63,te[q++]=E.charAt(C)+E.charAt(S)+E.charAt(T)+E.charAt(D);while(U<f.length);switch(B=te.join(""),f.length%3){case 1:B=B.slice(0,-2)+"==";break;case 2:B=B.slice(0,-1)+"=";break}return B}return i})})(ky);var iS=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},t=Symbol("test"),r=Object(t);if(typeof t=="string"||Object.prototype.toString.call(t)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var i=42;e[t]=i;for(t in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var s=Object.getOwnPropertySymbols(e);if(s.length!==1||s[0]!==t||!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var o=Object.getOwnPropertyDescriptor(e,t);if(o.value!==i||o.enumerable!==!0)return!1}return!0},dp=typeof Symbol!="undefined"&&Symbol,sS=iS,oS=function(){return typeof dp!="function"||typeof Symbol!="function"||typeof dp("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:sS()},aS="Function.prototype.bind called on incompatible ",Eu=Array.prototype.slice,cS=Object.prototype.toString,lS="[object Function]",uS=function(e){var t=this;if(typeof t!="function"||cS.call(t)!==lS)throw new TypeError(aS+t);for(var r=Eu.call(arguments,1),i,s=function(){if(this instanceof i){var c=t.apply(this,r.concat(Eu.call(arguments)));return Object(c)===c?c:this}else return t.apply(e,r.concat(Eu.call(arguments)))},o=Math.max(0,t.length-r.length),a=[],l=0;l<o;l++)a.push("$"+l);if(i=Function("binder","return function ("+a.join(",")+"){ return binder.apply(this,arguments); }")(s),t.prototype){var u=function(){};u.prototype=t.prototype,i.prototype=new u,u.prototype=null}return i},dS=uS,nf=Function.prototype.bind||dS,hS=nf,fS=hS.call(Function.call,Object.prototype.hasOwnProperty),pe,$a=SyntaxError,Cy=Function,ho=TypeError,Su=function(n){try{return Cy('"use strict"; return ('+n+").constructor;")()}catch{}},ls=Object.getOwnPropertyDescriptor;if(ls)try{ls({},"")}catch{ls=null}var bu=function(){throw new ho},pS=ls?function(){try{return arguments.callee,bu}catch{try{return ls(arguments,"callee").get}catch{return bu}}}():bu,Ls=oS(),ki=Object.getPrototypeOf||function(n){return n.__proto__},io={},gS=typeof Uint8Array=="undefined"?pe:ki(Uint8Array),fo={"%AggregateError%":typeof AggregateError=="undefined"?pe:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer=="undefined"?pe:ArrayBuffer,"%ArrayIteratorPrototype%":Ls?ki([][Symbol.iterator]()):pe,"%AsyncFromSyncIteratorPrototype%":pe,"%AsyncFunction%":io,"%AsyncGenerator%":io,"%AsyncGeneratorFunction%":io,"%AsyncIteratorPrototype%":io,"%Atomics%":typeof Atomics=="undefined"?pe:Atomics,"%BigInt%":typeof BigInt=="undefined"?pe:BigInt,"%Boolean%":Boolean,"%DataView%":typeof DataView=="undefined"?pe:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array=="undefined"?pe:Float32Array,"%Float64Array%":typeof Float64Array=="undefined"?pe:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry=="undefined"?pe:FinalizationRegistry,"%Function%":Cy,"%GeneratorFunction%":io,"%Int8Array%":typeof Int8Array=="undefined"?pe:Int8Array,"%Int16Array%":typeof Int16Array=="undefined"?pe:Int16Array,"%Int32Array%":typeof Int32Array=="undefined"?pe:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Ls?ki(ki([][Symbol.iterator]())):pe,"%JSON%":typeof JSON=="object"?JSON:pe,"%Map%":typeof Map=="undefined"?pe:Map,"%MapIteratorPrototype%":typeof Map=="undefined"||!Ls?pe:ki(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise=="undefined"?pe:Promise,"%Proxy%":typeof Proxy=="undefined"?pe:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect=="undefined"?pe:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set=="undefined"?pe:Set,"%SetIteratorPrototype%":typeof Set=="undefined"||!Ls?pe:ki(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer=="undefined"?pe:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Ls?ki(""[Symbol.iterator]()):pe,"%Symbol%":Ls?Symbol:pe,"%SyntaxError%":$a,"%ThrowTypeError%":pS,"%TypedArray%":gS,"%TypeError%":ho,"%Uint8Array%":typeof Uint8Array=="undefined"?pe:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray=="undefined"?pe:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array=="undefined"?pe:Uint16Array,"%Uint32Array%":typeof Uint32Array=="undefined"?pe:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap=="undefined"?pe:WeakMap,"%WeakRef%":typeof WeakRef=="undefined"?pe:WeakRef,"%WeakSet%":typeof WeakSet=="undefined"?pe:WeakSet},mS=function n(e){var t;if(e==="%AsyncFunction%")t=Su("async function () {}");else if(e==="%GeneratorFunction%")t=Su("function* () {}");else if(e==="%AsyncGeneratorFunction%")t=Su("async function* () {}");else if(e==="%AsyncGenerator%"){var r=n("%AsyncGeneratorFunction%");r&&(t=r.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=n("%AsyncGenerator%");i&&(t=ki(i.prototype))}return fo[e]=t,t},hp={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},Ll=nf,ml=fS,yS=Ll.call(Function.call,Array.prototype.concat),vS=Ll.call(Function.apply,Array.prototype.splice),fp=Ll.call(Function.call,String.prototype.replace),yl=Ll.call(Function.call,String.prototype.slice),_S=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,ES=/\\(\\)?/g,SS=function(e){var t=yl(e,0,1),r=yl(e,-1);if(t==="%"&&r!=="%")throw new $a("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&t!=="%")throw new $a("invalid intrinsic syntax, expected opening `%`");var i=[];return fp(e,_S,function(s,o,a,l){i[i.length]=a?fp(l,ES,"$1"):o||s}),i},bS=function(e,t){var r=e,i;if(ml(hp,r)&&(i=hp[r],r="%"+i[0]+"%"),ml(fo,r)){var s=fo[r];if(s===io&&(s=mS(r)),typeof s=="undefined"&&!t)throw new ho("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:r,value:s}}throw new $a("intrinsic "+e+" does not exist!")},sf=function(e,t){if(typeof e!="string"||e.length===0)throw new ho("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof t!="boolean")throw new ho('"allowMissing" argument must be a boolean');var r=SS(e),i=r.length>0?r[0]:"",s=bS("%"+i+"%",t),o=s.name,a=s.value,l=!1,u=s.alias;u&&(i=u[0],vS(r,yS([0,1],u)));for(var c=1,g=!0;c<r.length;c+=1){var m=r[c],f=yl(m,0,1),E=yl(m,-1);if((f==='"'||f==="'"||f==="`"||E==='"'||E==="'"||E==="`")&&f!==E)throw new $a("property names with quotes must have matching quotes");if((m==="constructor"||!g)&&(l=!0),i+="."+m,o="%"+i+"%",ml(fo,o))a=fo[o];else if(a!=null){if(!(m in a)){if(!t)throw new ho("base intrinsic for "+e+" exists, but the property is not available.");return}if(ls&&c+1>=r.length){var I=ls(a,m);g=!!I,g&&"get"in I&&!("originalValue"in I.get)?a=I.get:a=a[m]}else g=ml(a,m),a=a[m];g&&!l&&(fo[o]=a)}}return a},Py={exports:{}};(function(n){var e=nf,t=sf,r=t("%Function.prototype.apply%"),i=t("%Function.prototype.call%"),s=t("%Reflect.apply%",!0)||e.call(i,r),o=t("%Object.getOwnPropertyDescriptor%",!0),a=t("%Object.defineProperty%",!0),l=t("%Math.max%");if(a)try{a({},"a",{value:1})}catch{a=null}n.exports=function(g){var m=s(e,i,arguments);if(o&&a){var f=o(m,"length");f.configurable&&a(m,"length",{value:1+l(0,g.length-(arguments.length-1))})}return m};var u=function(){return s(e,r,arguments)};a?a(n.exports,"apply",{value:u}):n.exports.apply=u})(Py);var My=sf,Ay=Py.exports,wS=Ay(My("String.prototype.indexOf")),RS=function(e,t){var r=My(e,!!t);return typeof r=="function"&&wS(e,".prototype.")>-1?Ay(r):r},IS={},TS=Object.freeze(Object.defineProperty({__proto__:null,default:IS},Symbol.toStringTag,{value:"Module"})),Ci=rf(TS),of=typeof Map=="function"&&Map.prototype,wu=Object.getOwnPropertyDescriptor&&of?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,vl=of&&wu&&typeof wu.get=="function"?wu.get:null,OS=of&&Map.prototype.forEach,af=typeof Set=="function"&&Set.prototype,Ru=Object.getOwnPropertyDescriptor&&af?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,_l=af&&Ru&&typeof Ru.get=="function"?Ru.get:null,kS=af&&Set.prototype.forEach,CS=typeof WeakMap=="function"&&WeakMap.prototype,Oa=CS?WeakMap.prototype.has:null,PS=typeof WeakSet=="function"&&WeakSet.prototype,ka=PS?WeakSet.prototype.has:null,MS=typeof WeakRef=="function"&&WeakRef.prototype,pp=MS?WeakRef.prototype.deref:null,AS=Boolean.prototype.valueOf,DS=Object.prototype.toString,xS=Function.prototype.toString,US=String.prototype.match,cf=String.prototype.slice,xi=String.prototype.replace,$S=String.prototype.toUpperCase,gp=String.prototype.toLowerCase,Dy=RegExp.prototype.test,mp=Array.prototype.concat,_n=Array.prototype.join,NS=Array.prototype.slice,yp=Math.floor,Ad=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Iu=Object.getOwnPropertySymbols,Dd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,wo=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Mt=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===wo?"object":"symbol")?Symbol.toStringTag:null,xy=Object.prototype.propertyIsEnumerable,vp=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(n){return n.__proto__}:null);function _p(n,e){if(n===1/0||n===-1/0||n!==n||n&&n>-1e3&&n<1e3||Dy.call(/e/,e))return e;var t=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof n=="number"){var r=n<0?-yp(-n):yp(n);if(r!==n){var i=String(r),s=cf.call(e,i.length+1);return xi.call(i,t,"$&_")+"."+xi.call(xi.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return xi.call(e,t,"$&_")}var Tu=Ci.custom,Ou=Tu&&$y(Tu)?Tu:null,LS=function n(e,t,r,i){var s=t||{};if(Pi(s,"quoteStyle")&&s.quoteStyle!=="single"&&s.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Pi(s,"maxStringLength")&&(typeof s.maxStringLength=="number"?s.maxStringLength<0&&s.maxStringLength!==1/0:s.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=Pi(s,"customInspect")?s.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Pi(s,"indent")&&s.indent!==null&&s.indent!==" "&&!(parseInt(s.indent,10)===s.indent&&s.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(Pi(s,"numericSeparator")&&typeof s.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=s.numericSeparator;if(typeof e=="undefined")return"undefined";if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return Ly(e,s);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var l=String(e);return a?_p(e,l):l}if(typeof e=="bigint"){var u=String(e)+"n";return a?_p(e,u):u}var c=typeof s.depth=="undefined"?5:s.depth;if(typeof r=="undefined"&&(r=0),r>=c&&c>0&&typeof e=="object")return xd(e)?"[Array]":"[Object]";var g=nb(s,r);if(typeof i=="undefined")i=[];else if(Ny(i,e)>=0)return"[Circular]";function m(Te,Ye,Vt){if(Ye&&(i=NS.call(i),i.push(Ye)),Vt){var Gt={depth:s.depth};return Pi(s,"quoteStyle")&&(Gt.quoteStyle=s.quoteStyle),n(Te,Gt,r+1,i)}return n(Te,s,r+1,i)}if(typeof e=="function"){var f=YS(e),E=mc(e,m);return"[Function"+(f?": "+f:" (anonymous)")+"]"+(E.length>0?" { "+_n.call(E,", ")+" }":"")}if($y(e)){var I=wo?xi.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):Dd.call(e);return typeof e=="object"&&!wo?Yo(I):I}if(eb(e)){for(var w="<"+gp.call(String(e.nodeName)),k=e.attributes||[],C=0;C<k.length;C++)w+=" "+k[C].name+"="+Uy(BS(k[C].value),"double",s);return w+=">",e.childNodes&&e.childNodes.length&&(w+="..."),w+="</"+gp.call(String(e.nodeName))+">",w}if(xd(e)){if(e.length===0)return"[]";var S=mc(e,m);return g&&!rb(S)?"["+Ud(S,g)+"]":"[ "+_n.call(S,", ")+" ]"}if(qS(e)){var T=mc(e,m);return"cause"in e&&!xy.call(e,"cause")?"{ ["+String(e)+"] "+_n.call(mp.call("[cause]: "+m(e.cause),T),", ")+" }":T.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+_n.call(T,", ")+" }"}if(typeof e=="object"&&o){if(Ou&&typeof e[Ou]=="function")return e[Ou]();if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(zS(e)){var D=[];return OS.call(e,function(Te,Ye){D.push(m(Ye,e,!0)+" => "+m(Te,e))}),Ep("Map",vl.call(e),D,g)}if(QS(e)){var R=[];return kS.call(e,function(Te){R.push(m(Te,e))}),Ep("Set",_l.call(e),R,g)}if(JS(e))return ku("WeakMap");if(ZS(e))return ku("WeakSet");if(XS(e))return ku("WeakRef");if(VS(e))return Yo(m(Number(e)));if(WS(e))return Yo(m(Ad.call(e)));if(GS(e))return Yo(AS.call(e));if(jS(e))return Yo(m(String(e)));if(!KS(e)&&!FS(e)){var U=mc(e,m),q=vp?vp(e)===Object.prototype:e instanceof Object||e.constructor===Object,B=e instanceof Object?"":"null prototype",te=!q&&Mt&&Object(e)===e&&Mt in e?cf.call(Li(e),8,-1):B?"Object":"",ye=q||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",we=ye+(te||B?"["+_n.call(mp.call([],te||[],B||[]),": ")+"] ":"");return U.length===0?we+"{}":g?we+"{"+Ud(U,g)+"}":we+"{ "+_n.call(U,", ")+" }"}return String(e)};function Uy(n,e,t){var r=(t.quoteStyle||e)==="double"?'"':"'";return r+n+r}function BS(n){return xi.call(String(n),/"/g,""")}function xd(n){return Li(n)==="[object Array]"&&(!Mt||!(typeof n=="object"&&Mt in n))}function KS(n){return Li(n)==="[object Date]"&&(!Mt||!(typeof n=="object"&&Mt in n))}function FS(n){return Li(n)==="[object RegExp]"&&(!Mt||!(typeof n=="object"&&Mt in n))}function qS(n){return Li(n)==="[object Error]"&&(!Mt||!(typeof n=="object"&&Mt in n))}function jS(n){return Li(n)==="[object String]"&&(!Mt||!(typeof n=="object"&&Mt in n))}function VS(n){return Li(n)==="[object Number]"&&(!Mt||!(typeof n=="object"&&Mt in n))}function GS(n){return Li(n)==="[object Boolean]"&&(!Mt||!(typeof n=="object"&&Mt in n))}function $y(n){if(wo)return n&&typeof n=="object"&&n instanceof Symbol;if(typeof n=="symbol")return!0;if(!n||typeof n!="object"||!Dd)return!1;try{return Dd.call(n),!0}catch{}return!1}function WS(n){if(!n||typeof n!="object"||!Ad)return!1;try{return Ad.call(n),!0}catch{}return!1}var HS=Object.prototype.hasOwnProperty||function(n){return n in this};function Pi(n,e){return HS.call(n,e)}function Li(n){return DS.call(n)}function YS(n){if(n.name)return n.name;var e=US.call(xS.call(n),/^function\s*([\w$]+)/);return e?e[1]:null}function Ny(n,e){if(n.indexOf)return n.indexOf(e);for(var t=0,r=n.length;t<r;t++)if(n[t]===e)return t;return-1}function zS(n){if(!vl||!n||typeof n!="object")return!1;try{vl.call(n);try{_l.call(n)}catch{return!0}return n instanceof Map}catch{}return!1}function JS(n){if(!Oa||!n||typeof n!="object")return!1;try{Oa.call(n,Oa);try{ka.call(n,ka)}catch{return!0}return n instanceof WeakMap}catch{}return!1}function XS(n){if(!pp||!n||typeof n!="object")return!1;try{return pp.call(n),!0}catch{}return!1}function QS(n){if(!_l||!n||typeof n!="object")return!1;try{_l.call(n);try{vl.call(n)}catch{return!0}return n instanceof Set}catch{}return!1}function ZS(n){if(!ka||!n||typeof n!="object")return!1;try{ka.call(n,ka);try{Oa.call(n,Oa)}catch{return!0}return n instanceof WeakSet}catch{}return!1}function eb(n){return!n||typeof n!="object"?!1:typeof HTMLElement!="undefined"&&n instanceof HTMLElement?!0:typeof n.nodeName=="string"&&typeof n.getAttribute=="function"}function Ly(n,e){if(n.length>e.maxStringLength){var t=n.length-e.maxStringLength,r="... "+t+" more character"+(t>1?"s":"");return Ly(cf.call(n,0,e.maxStringLength),e)+r}var i=xi.call(xi.call(n,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,tb);return Uy(i,"single",e)}function tb(n){var e=n.charCodeAt(0),t={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return t?"\\"+t:"\\x"+(e<16?"0":"")+$S.call(e.toString(16))}function Yo(n){return"Object("+n+")"}function ku(n){return n+" { ? }"}function Ep(n,e,t,r){var i=r?Ud(t,r):_n.call(t,", ");return n+" ("+e+") {"+i+"}"}function rb(n){for(var e=0;e<n.length;e++)if(Ny(n[e],`
+`)>=0)return!1;return!0}function nb(n,e){var t;if(n.indent===" ")t=" ";else if(typeof n.indent=="number"&&n.indent>0)t=_n.call(Array(n.indent+1)," ");else return null;return{base:t,prev:_n.call(Array(e+1),t)}}function Ud(n,e){if(n.length===0)return"";var t=`
+`+e.prev+e.base;return t+_n.call(n,","+t)+`
+`+e.prev}function mc(n,e){var t=xd(n),r=[];if(t){r.length=n.length;for(var i=0;i<n.length;i++)r[i]=Pi(n,i)?e(n[i],n):""}var s=typeof Iu=="function"?Iu(n):[],o;if(wo){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var l in n)!Pi(n,l)||t&&String(Number(l))===l&&l<n.length||wo&&o["$"+l]instanceof Symbol||(Dy.call(/[^\w$]/,l)?r.push(e(l,n)+": "+e(n[l],n)):r.push(l+": "+e(n[l],n)));if(typeof Iu=="function")for(var u=0;u<s.length;u++)xy.call(n,s[u])&&r.push("["+e(s[u])+"]: "+e(n[s[u]],n));return r}var lf=sf,xo=RS,ib=LS,sb=lf("%TypeError%"),yc=lf("%WeakMap%",!0),vc=lf("%Map%",!0),ob=xo("WeakMap.prototype.get",!0),ab=xo("WeakMap.prototype.set",!0),cb=xo("WeakMap.prototype.has",!0),lb=xo("Map.prototype.get",!0),ub=xo("Map.prototype.set",!0),db=xo("Map.prototype.has",!0),uf=function(n,e){for(var t=n,r;(r=t.next)!==null;t=r)if(r.key===e)return t.next=r.next,r.next=n.next,n.next=r,r},hb=function(n,e){var t=uf(n,e);return t&&t.value},fb=function(n,e,t){var r=uf(n,e);r?r.value=t:n.next={key:e,next:n.next,value:t}},pb=function(n,e){return!!uf(n,e)},gb=function(){var e,t,r,i={assert:function(s){if(!i.has(s))throw new sb("Side channel does not contain "+ib(s))},get:function(s){if(yc&&s&&(typeof s=="object"||typeof s=="function")){if(e)return ob(e,s)}else if(vc){if(t)return lb(t,s)}else if(r)return hb(r,s)},has:function(s){if(yc&&s&&(typeof s=="object"||typeof s=="function")){if(e)return cb(e,s)}else if(vc){if(t)return db(t,s)}else if(r)return pb(r,s);return!1},set:function(s,o){yc&&s&&(typeof s=="object"||typeof s=="function")?(e||(e=new yc),ab(e,s,o)):vc?(t||(t=new vc),ub(t,s,o)):(r||(r={key:{},next:null}),fb(r,s,o))}};return i},mb=String.prototype.replace,yb=/%20/g,Cu={RFC1738:"RFC1738",RFC3986:"RFC3986"},df={default:Cu.RFC3986,formatters:{RFC1738:function(n){return mb.call(n,yb,"+")},RFC3986:function(n){return String(n)}},RFC1738:Cu.RFC1738,RFC3986:Cu.RFC3986},vb=df,Pu=Object.prototype.hasOwnProperty,rs=Array.isArray,on=function(){for(var n=[],e=0;e<256;++e)n.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return n}(),_b=function(e){for(;e.length>1;){var t=e.pop(),r=t.obj[t.prop];if(rs(r)){for(var i=[],s=0;s<r.length;++s)typeof r[s]!="undefined"&&i.push(r[s]);t.obj[t.prop]=i}}},By=function(e,t){for(var r=t&&t.plainObjects?Object.create(null):{},i=0;i<e.length;++i)typeof e[i]!="undefined"&&(r[i]=e[i]);return r},Eb=function n(e,t,r){if(!t)return e;if(typeof t!="object"){if(rs(e))e.push(t);else if(e&&typeof e=="object")(r&&(r.plainObjects||r.allowPrototypes)||!Pu.call(Object.prototype,t))&&(e[t]=!0);else return[e,t];return e}if(!e||typeof e!="object")return[e].concat(t);var i=e;return rs(e)&&!rs(t)&&(i=By(e,r)),rs(e)&&rs(t)?(t.forEach(function(s,o){if(Pu.call(e,o)){var a=e[o];a&&typeof a=="object"&&s&&typeof s=="object"?e[o]=n(a,s,r):e.push(s)}else e[o]=s}),e):Object.keys(t).reduce(function(s,o){var a=t[o];return Pu.call(s,o)?s[o]=n(s[o],a,r):s[o]=a,s},i)},Sb=function(e,t){return Object.keys(t).reduce(function(r,i){return r[i]=t[i],r},e)},bb=function(n,e,t){var r=n.replace(/\+/g," ");if(t==="iso-8859-1")return r.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(r)}catch{return r}},wb=function(e,t,r,i,s){if(e.length===0)return e;var o=e;if(typeof e=="symbol"?o=Symbol.prototype.toString.call(e):typeof e!="string"&&(o=String(e)),r==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(c){return"%26%23"+parseInt(c.slice(2),16)+"%3B"});for(var a="",l=0;l<o.length;++l){var u=o.charCodeAt(l);if(u===45||u===46||u===95||u===126||u>=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||s===vb.RFC1738&&(u===40||u===41)){a+=o.charAt(l);continue}if(u<128){a=a+on[u];continue}if(u<2048){a=a+(on[192|u>>6]+on[128|u&63]);continue}if(u<55296||u>=57344){a=a+(on[224|u>>12]+on[128|u>>6&63]+on[128|u&63]);continue}l+=1,u=65536+((u&1023)<<10|o.charCodeAt(l)&1023),a+=on[240|u>>18]+on[128|u>>12&63]+on[128|u>>6&63]+on[128|u&63]}return a},Rb=function(e){for(var t=[{obj:{o:e},prop:"o"}],r=[],i=0;i<t.length;++i)for(var s=t[i],o=s.obj[s.prop],a=Object.keys(o),l=0;l<a.length;++l){var u=a[l],c=o[u];typeof c=="object"&&c!==null&&r.indexOf(c)===-1&&(t.push({obj:o,prop:u}),r.push(c))}return _b(t),e},Ib=function(e){return Object.prototype.toString.call(e)==="[object RegExp]"},Tb=function(e){return!e||typeof e!="object"?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},Ob=function(e,t){return[].concat(e,t)},kb=function(e,t){if(rs(e)){for(var r=[],i=0;i<e.length;i+=1)r.push(t(e[i]));return r}return t(e)},Ky={arrayToObject:By,assign:Sb,combine:Ob,compact:Rb,decode:bb,encode:wb,isBuffer:Tb,isRegExp:Ib,maybeMap:kb,merge:Eb},Fy=gb,$d=Ky,Ca=df,Cb=Object.prototype.hasOwnProperty,Sp={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},os=Array.isArray,Pb=String.prototype.split,Mb=Array.prototype.push,qy=function(n,e){Mb.apply(n,os(e)?e:[e])},Ab=Date.prototype.toISOString,bp=Ca.default,yt={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:$d.encode,encodeValuesOnly:!1,format:bp,formatter:Ca.formatters[bp],indices:!1,serializeDate:function(e){return Ab.call(e)},skipNulls:!1,strictNullHandling:!1},Db=function(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="symbol"||typeof e=="bigint"},Mu={},xb=function n(e,t,r,i,s,o,a,l,u,c,g,m,f,E,I){for(var w=e,k=I,C=0,S=!1;(k=k.get(Mu))!==void 0&&!S;){var T=k.get(e);if(C+=1,typeof T!="undefined"){if(T===C)throw new RangeError("Cyclic object value");S=!0}typeof k.get(Mu)=="undefined"&&(C=0)}if(typeof a=="function"?w=a(t,w):w instanceof Date?w=c(w):r==="comma"&&os(w)&&(w=$d.maybeMap(w,function(Q){return Q instanceof Date?c(Q):Q})),w===null){if(i)return o&&!f?o(t,yt.encoder,E,"key",g):t;w=""}if(Db(w)||$d.isBuffer(w)){if(o){var D=f?t:o(t,yt.encoder,E,"key",g);if(r==="comma"&&f){for(var R=Pb.call(String(w),","),U="",q=0;q<R.length;++q)U+=(q===0?"":",")+m(o(R[q],yt.encoder,E,"value",g));return[m(D)+"="+U]}return[m(D)+"="+m(o(w,yt.encoder,E,"value",g))]}return[m(t)+"="+m(String(w))]}var B=[];if(typeof w=="undefined")return B;var te;if(r==="comma"&&os(w))te=[{value:w.length>0?w.join(",")||null:void 0}];else if(os(a))te=a;else{var ye=Object.keys(w);te=l?ye.sort(l):ye}for(var we=0;we<te.length;++we){var Te=te[we],Ye=typeof Te=="object"&&typeof Te.value!="undefined"?Te.value:w[Te];if(!(s&&Ye===null)){var Vt=os(w)?typeof r=="function"?r(t,Te):t:t+(u?"."+Te:"["+Te+"]");I.set(e,C);var Gt=Fy();Gt.set(Mu,I),qy(B,n(Ye,Vt,r,i,s,o,a,l,u,c,g,m,f,E,Gt))}}return B},Ub=function(e){if(!e)return yt;if(e.encoder!==null&&typeof e.encoder!="undefined"&&typeof e.encoder!="function")throw new TypeError("Encoder has to be a function.");var t=e.charset||yt.charset;if(typeof e.charset!="undefined"&&e.charset!=="utf-8"&&e.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var r=Ca.default;if(typeof e.format!="undefined"){if(!Cb.call(Ca.formatters,e.format))throw new TypeError("Unknown format option provided.");r=e.format}var i=Ca.formatters[r],s=yt.filter;return(typeof e.filter=="function"||os(e.filter))&&(s=e.filter),{addQueryPrefix:typeof e.addQueryPrefix=="boolean"?e.addQueryPrefix:yt.addQueryPrefix,allowDots:typeof e.allowDots=="undefined"?yt.allowDots:!!e.allowDots,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:yt.charsetSentinel,delimiter:typeof e.delimiter=="undefined"?yt.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:yt.encode,encoder:typeof e.encoder=="function"?e.encoder:yt.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:yt.encodeValuesOnly,filter:s,format:r,formatter:i,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:yt.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:yt.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:yt.strictNullHandling}},$b=function(n,e){var t=n,r=Ub(e),i,s;typeof r.filter=="function"?(s=r.filter,t=s("",t)):os(r.filter)&&(s=r.filter,i=s);var o=[];if(typeof t!="object"||t===null)return"";var a;e&&e.arrayFormat in Sp?a=e.arrayFormat:e&&"indices"in e?a=e.indices?"indices":"repeat":a="indices";var l=Sp[a];i||(i=Object.keys(t)),r.sort&&i.sort(r.sort);for(var u=Fy(),c=0;c<i.length;++c){var g=i[c];r.skipNulls&&t[g]===null||qy(o,xb(t[g],g,l,r.strictNullHandling,r.skipNulls,r.encode?r.encoder:null,r.filter,r.sort,r.allowDots,r.serializeDate,r.format,r.formatter,r.encodeValuesOnly,r.charset,u))}var m=o.join(r.delimiter),f=r.addQueryPrefix===!0?"?":"";return r.charsetSentinel&&(r.charset==="iso-8859-1"?f+="utf8=%26%2310003%3B&":f+="utf8=%E2%9C%93&"),m.length>0?f+m:""},Ro=Ky,Nd=Object.prototype.hasOwnProperty,Nb=Array.isArray,ut={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:Ro.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},Lb=function(n){return n.replace(/&#(\d+);/g,function(e,t){return String.fromCharCode(parseInt(t,10))})},jy=function(n,e){return n&&typeof n=="string"&&e.comma&&n.indexOf(",")>-1?n.split(","):n},Bb="utf8=%26%2310003%3B",Kb="utf8=%E2%9C%93",Fb=function(e,t){var r={},i=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,s=t.parameterLimit===1/0?void 0:t.parameterLimit,o=i.split(t.delimiter,s),a=-1,l,u=t.charset;if(t.charsetSentinel)for(l=0;l<o.length;++l)o[l].indexOf("utf8=")===0&&(o[l]===Kb?u="utf-8":o[l]===Bb&&(u="iso-8859-1"),a=l,l=o.length);for(l=0;l<o.length;++l)if(l!==a){var c=o[l],g=c.indexOf("]="),m=g===-1?c.indexOf("="):g+1,f,E;m===-1?(f=t.decoder(c,ut.decoder,u,"key"),E=t.strictNullHandling?null:""):(f=t.decoder(c.slice(0,m),ut.decoder,u,"key"),E=Ro.maybeMap(jy(c.slice(m+1),t),function(I){return t.decoder(I,ut.decoder,u,"value")})),E&&t.interpretNumericEntities&&u==="iso-8859-1"&&(E=Lb(E)),c.indexOf("[]=")>-1&&(E=Nb(E)?[E]:E),Nd.call(r,f)?r[f]=Ro.combine(r[f],E):r[f]=E}return r},qb=function(n,e,t,r){for(var i=r?e:jy(e,t),s=n.length-1;s>=0;--s){var o,a=n[s];if(a==="[]"&&t.parseArrays)o=[].concat(i);else{o=t.plainObjects?Object.create(null):{};var l=a.charAt(0)==="["&&a.charAt(a.length-1)==="]"?a.slice(1,-1):a,u=parseInt(l,10);!t.parseArrays&&l===""?o={0:i}:!isNaN(u)&&a!==l&&String(u)===l&&u>=0&&t.parseArrays&&u<=t.arrayLimit?(o=[],o[u]=i):l!=="__proto__"&&(o[l]=i)}i=o}return i},jb=function(e,t,r,i){if(!!e){var s=r.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,o=/(\[[^[\]]*])/,a=/(\[[^[\]]*])/g,l=r.depth>0&&o.exec(s),u=l?s.slice(0,l.index):s,c=[];if(u){if(!r.plainObjects&&Nd.call(Object.prototype,u)&&!r.allowPrototypes)return;c.push(u)}for(var g=0;r.depth>0&&(l=a.exec(s))!==null&&g<r.depth;){if(g+=1,!r.plainObjects&&Nd.call(Object.prototype,l[1].slice(1,-1))&&!r.allowPrototypes)return;c.push(l[1])}return l&&c.push("["+s.slice(l.index)+"]"),qb(c,t,r,i)}},Vb=function(e){if(!e)return ut;if(e.decoder!==null&&e.decoder!==void 0&&typeof e.decoder!="function")throw new TypeError("Decoder has to be a function.");if(typeof e.charset!="undefined"&&e.charset!=="utf-8"&&e.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=typeof e.charset=="undefined"?ut.charset:e.charset;return{allowDots:typeof e.allowDots=="undefined"?ut.allowDots:!!e.allowDots,allowPrototypes:typeof e.allowPrototypes=="boolean"?e.allowPrototypes:ut.allowPrototypes,allowSparse:typeof e.allowSparse=="boolean"?e.allowSparse:ut.allowSparse,arrayLimit:typeof e.arrayLimit=="number"?e.arrayLimit:ut.arrayLimit,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:ut.charsetSentinel,comma:typeof e.comma=="boolean"?e.comma:ut.comma,decoder:typeof e.decoder=="function"?e.decoder:ut.decoder,delimiter:typeof e.delimiter=="string"||Ro.isRegExp(e.delimiter)?e.delimiter:ut.delimiter,depth:typeof e.depth=="number"||e.depth===!1?+e.depth:ut.depth,ignoreQueryPrefix:e.ignoreQueryPrefix===!0,interpretNumericEntities:typeof e.interpretNumericEntities=="boolean"?e.interpretNumericEntities:ut.interpretNumericEntities,parameterLimit:typeof e.parameterLimit=="number"?e.parameterLimit:ut.parameterLimit,parseArrays:e.parseArrays!==!1,plainObjects:typeof e.plainObjects=="boolean"?e.plainObjects:ut.plainObjects,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:ut.strictNullHandling}},Gb=function(n,e){var t=Vb(e);if(n===""||n===null||typeof n=="undefined")return t.plainObjects?Object.create(null):{};for(var r=typeof n=="string"?Fb(n,t):n,i=t.plainObjects?Object.create(null):{},s=Object.keys(r),o=0;o<s.length;++o){var a=s[o],l=jb(a,r[a],t,typeof n=="string");i=Ro.merge(i,l,t)}return t.allowSparse===!0?i:Ro.compact(i)},Wb=$b,Hb=Gb,Yb=df,zb={formats:Yb,parse:Hb,stringify:Wb},Cs={},Uo={},Y={exports:{}};(function(n){function e(t,r,i){return r in t?Object.defineProperty(t,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[r]=i,t}n.exports=e,n.exports.__esModule=!0,n.exports.default=n.exports})(Y);var se={},Vy={exports:{}};(function(n){(function(e,t){n.exports?n.exports=t():e.log=t()})(V,function(){var e=function(){},t="undefined",r=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"];function s(I,w){var k=I[w];if(typeof k.bind=="function")return k.bind(I);try{return Function.prototype.bind.call(k,I)}catch{return function(){return Function.prototype.apply.apply(k,[I,arguments])}}}function o(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function a(I){return I==="debug"&&(I="log"),typeof console===t?!1:I==="trace"&&r?o:console[I]!==void 0?s(console,I):console.log!==void 0?s(console,"log"):e}function l(I,w){for(var k=0;k<i.length;k++){var C=i[k];this[C]=k<I?e:this.methodFactory(C,I,w)}this.log=this.debug}function u(I,w,k){return function(){typeof console!==t&&(l.call(this,w,k),this[I].apply(this,arguments))}}function c(I,w,k){return a(I)||u.apply(this,arguments)}function g(I,w,k){var C=this,S;w=w==null?"WARN":w;var T="loglevel";typeof I=="string"?T+=":"+I:typeof I=="symbol"&&(T=void 0);function D(B){var te=(i[B]||"silent").toUpperCase();if(!(typeof window===t||!T)){try{window.localStorage[T]=te;return}catch{}try{window.document.cookie=encodeURIComponent(T)+"="+te+";"}catch{}}}function R(){var B;if(!(typeof window===t||!T)){try{B=window.localStorage[T]}catch{}if(typeof B===t)try{var te=window.document.cookie,ye=te.indexOf(encodeURIComponent(T)+"=");ye!==-1&&(B=/^([^;]+)/.exec(te.slice(ye))[1])}catch{}return C.levels[B]===void 0&&(B=void 0),B}}function U(){if(!(typeof window===t||!T)){try{window.localStorage.removeItem(T);return}catch{}try{window.document.cookie=encodeURIComponent(T)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}C.name=I,C.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},C.methodFactory=k||c,C.getLevel=function(){return S},C.setLevel=function(B,te){if(typeof B=="string"&&C.levels[B.toUpperCase()]!==void 0&&(B=C.levels[B.toUpperCase()]),typeof B=="number"&&B>=0&&B<=C.levels.SILENT){if(S=B,te!==!1&&D(B),l.call(C,B,I),typeof console===t&&B<C.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+B},C.setDefaultLevel=function(B){w=B,R()||C.setLevel(B,!1)},C.resetLevel=function(){C.setLevel(w,!1),U()},C.enableAll=function(B){C.setLevel(C.levels.TRACE,B)},C.disableAll=function(B){C.setLevel(C.levels.SILENT,B)};var q=R();q==null&&(q=w),C.setLevel(q,!1)}var m=new g,f={};m.getLogger=function(w){if(typeof w!="symbol"&&typeof w!="string"||w==="")throw new TypeError("You must supply a name when creating a logger.");var k=f[w];return k||(k=f[w]=new g(w,m.getLevel(),m.methodFactory)),k};var E=typeof window!==t?window.log:void 0;return m.noConflict=function(){return typeof window!==t&&window.log===m&&(window.log=E),m},m.getLoggers=function(){return f},m.default=m,m})})(Vy);var Jb=G.exports;Object.defineProperty(se,"__esModule",{value:!0});se.logger=void 0;var Na=Jb(Vy.exports);const Gy="matrix";Na.default.methodFactory=function(n,e,t){return function(...r){return this.prefix&&r.unshift(this.prefix),n==="error"||n==="warn"||n==="trace"||n==="info"?console[n](...r):console.log(...r)}};const hf=Na.default.getLogger(Gy);se.logger=hf;hf.setLevel(Na.default.levels.DEBUG,!1);function Wy(n){n.withPrefix=function(e){const t=this.prefix||"";return Xb(t+e)}}Wy(hf);function Xb(n){const e=Na.default.getLogger(`${Gy}-${n}`);return e.prefix!==n&&(Wy(e),e.prefix=n,e.setLevel(Na.default.levels.DEBUG,!1)),e}var W={};const Qb="l",Zb="rn";var ew={"0":"O","1":"l","\u05AD":"\u0596","\u05AE":"\u0598","\u05A8":"\u0599","\u05A4":"\u059A","\u1AB4":"\u06DB","\u20DB":"\u06DB","\u0619":"\u0313","\u08F3":"\u0313","\u0343":"\u0313","\u0315":"\u0313","\u064F":"\u0313","\u065D":"\u0314","\u059C":"\u0301","\u059D":"\u0301","\u0618":"\u0301","\u0747":"\u0301","\u0341":"\u0301","\u0954":"\u0301","\u064E":"\u0301","\u0340":"\u0300","\u0953":"\u0300","\u030C":"\u0306","\uA67C":"\u0306","\u0658":"\u0306","\u065A":"\u0306","\u036E":"\u0306","\u06E8":"\u0306\u0307","\u0310":"\u0306\u0307","\u0901":"\u0306\u0307","\u0981":"\u0306\u0307","\u0A81":"\u0306\u0307","\u0B01":"\u0306\u0307","\u0C00":"\u0306\u0307","\u0C81":"\u0306\u0307","\u0D01":"\u0306\u0307","\u{114BF}":"\u0306\u0307","\u1CD0":"\u0302","\u0311":"\u0302","\u065B":"\u0302","\u07EE":"\u0302","\uA6F0":"\u0302","\u05AF":"\u030A","\u06DF":"\u030A","\u17D3":"\u030A","\u309A":"\u030A","\u0652":"\u030A","\u0B82":"\u030A","\u1036":"\u030A","\u17C6":"\u030A","\u{11300}":"\u030A","\u0E4D":"\u030A","\u0ECD":"\u030A","\u0366":"\u030A","\u2DEA":"\u030A","\u08EB":"\u0308","\u07F3":"\u0308","\u064B":"\u030B","\u08F0":"\u030B","\u0342":"\u0303","\u0653":"\u0303","\u05C4":"\u0307","\u06EC":"\u0307","\u0740":"\u0307","\u08EA":"\u0307","\u0741":"\u0307","\u0358":"\u0307","\u05B9":"\u0307","\u05BA":"\u0307","\u05C2":"\u0307","\u05C1":"\u0307","\u07ED":"\u0307","\u0902":"\u0307","\u0A02":"\u0307","\u0A82":"\u0307","\u0BCD":"\u0307","\u0337":"\u0338","\u1AB7":"\u0328","\u0322":"\u0328","\u0345":"\u0328","\u1CD2":"\u0304","\u0305":"\u0304","\u0659":"\u0304","\u07EB":"\u0304","\uA6F1":"\u0304","\u1CDA":"\u030E","\u0657":"\u0312","\u0357":"\u0350","\u08FF":"\u0350","\u08F8":"\u0350","\u0900":"\u0352","\u1CED":"\u0316","\u1CDC":"\u0329","\u0656":"\u0329","\u1CD5":"\u032B","\u0347":"\u0333","\u08F9":"\u0354","\u08FA":"\u0355","\u309B":"\uFF9E","\u309C":"\uFF9F","\u0336":"\u0335","\u302C":"\u0309","\u05C5":"\u0323","\u08ED":"\u0323","\u1CDD":"\u0323","\u05B4":"\u0323","\u065C":"\u0323","\u093C":"\u0323","\u09BC":"\u0323","\u0A3C":"\u0323","\u0ABC":"\u0323","\u0B3C":"\u0323","\u{111CA}":"\u0323","\u{114C3}":"\u0323","\u{10A3A}":"\u0323","\u08EE":"\u0324","\u1CDE":"\u0324","\u0F37":"\u0325","\u302D":"\u0325","\u0327":"\u0326","\u0321":"\u0326","\u0339":"\u0326","\u1CD9":"\u032D","\u1CD8":"\u032E","\u0952":"\u0331","\u0320":"\u0331","\u08F1":"\u064C","\u08E8":"\u064C","\u08E5":"\u064C",\uFC5E:"\uFE72\u0651","\u08F2":"\u064D",\uFC5F:"\uFE74\u0651",\uFCF2:"\uFE77\u0651",\uFC60:"\uFE76\u0651",\uFCF3:"\uFE79\u0651",\uFC61:"\uFE78\u0651","\u061A":"\u0650","\u0317":"\u0650",\uFCF4:"\uFE7B\u0651",\uFC62:"\uFE7A\u0651",\uFC63:"\uFE7C\u0670","\u065F":"\u0655","\u030D":"\u0670","\u0742":"\u073C","\u0A03":"\u0983","\u0C03":"\u0983","\u0C83":"\u0983","\u0D03":"\u0983","\u0D83":"\u0983","\u1038":"\u0983","\u{114C1}":"\u0983","\u17CB":"\u0E48","\u0EC8":"\u0E48","\u0EC9":"\u0E49","\u0ECA":"\u0E4A","\u0ECB":"\u0E4B","\uA66F":"\u20E9","\u2028":" ","\u2029":" ","\u1680":" ","\u2000":" ","\u2001":" ","\u2002":" ","\u2003":" ","\u2004":" ","\u2005":" ","\u2006":" ","\u2008":" ","\u2009":" ","\u200A":" ","\u205F":" ","\xA0":" ","\u2007":" ","\u202F":" ","\u07FA":"_","\uFE4D":"_","\uFE4E":"_","\uFE4F":"_","\u2010":"-","\u2011":"-","\u2012":"-","\u2013":"-","\uFE58":"-","\u06D4":"-","\u2043":"-","\u02D7":"-","\u2212":"-","\u2796":"-","\u2CBA":"-","\u2A29":"-\u0313","\u2E1A":"-\u0308","\uFB29":"-\u0307","\u2238":"-\u0307","\u2A2A":"-\u0323","\uA4FE":"-.","\uFF5E":"\u301C","\u060D":",","\u066B":",","\u201A":",","\xB8":",","\uA4F9":",","\u2E32":"\u060C","\u066C":"\u060C","\u037E":";","\u2E35":"\u061B","\u0903":":","\u0A83":":","\uFF1A":":","\u0589":":","\u0703":":","\u0704":":","\u16EC":":","\uFE30":":","\u1803":":","\u1809":":","\u205A":":","\u05C3":":","\u02F8":":","\uA789":":","\u2236":":",\u02D0:":","\uA4FD":":","\u2A74":"::=","\u29F4":":\u2192","\uFF01":"!",\u01C3:"!","\u2D51":"!","\u203C":"!!","\u2049":"!?",\u0294:"?","\u0241":"?","\u097D":"?",\u13AE:"?","\uA6EB":"?","\u2048":"?!","\u2047":"??","\u2E2E":"\u061F","\u{1D16D}":".","\u2024":".","\u0701":".","\u0702":".","\uA60E":".","\u{10A50}":".","\u0660":".","\u06F0":".","\uA4F8":".","\uA4FB":".,","\u2025":"..","\uA4FA":"..","\u2026":"...","\uA6F4":"\uA6F3\uA6F3","\u30FB":"\xB7","\uFF65":"\xB7","\u16EB":"\xB7","\u0387":"\xB7","\u2E31":"\xB7","\u{10101}":"\xB7","\u2022":"\xB7","\u2027":"\xB7","\u2219":"\xB7","\u22C5":"\xB7","\uA78F":"\xB7",\u1427:"\xB7","\u22EF":"\xB7\xB7\xB7","\u2D48":"\xB7\xB7\xB7",\u1444:"\xB7<","\u22D7":"\xB7>",\u1437:"\xB7>",\u1440:"\xB7>",\u152F:"\xB74",\u147E:"\xB7b",\u1480:"\xB7b\u0307",\u147A:"\xB7d",\u1498:"\xB7J",\u14B6:"\xB7L",\u1476:"\xB7P",\u1457:"\xB7U",\u143A:"\xB7V",\u143C:"\xB7\u0245",\u14AE:"\xB7\u0393",\u140E:"\xB7\u0394",\u1459:"\xB7\u0548",\u140C:"\xB7\u1401",\u1410:"\xB7\u1404",\u1412:"\xB7\u1405",\u1414:"\xB7\u1406",\u1417:"\xB7\u140A",\u1419:"\xB7\u140B",\u143E:"\xB7\u1432",\u1442:"\xB7\u1434",\u1446:"\xB7\u1439",\u145B:"\xB7\u144F",\u1454:"\xB7\u1450",\u145D:"\xB7\u1450",\u145F:"\xB7\u1451",\u1461:"\xB7\u1455",\u1463:"\xB7\u1456",\u1474:"\xB7\u146B",\u1478:"\xB7\u146E",\u147C:"\xB7\u1470",\u1492:"\xB7\u1489",\u1494:"\xB7\u148B",\u1496:"\xB7\u148C",\u149A:"\xB7\u148E",\u149C:"\xB7\u1490",\u149E:"\xB7\u1491",\u14AC:"\xB7\u14A3",\u14B0:"\xB7\u14A6",\u14B2:"\xB7\u14A7",\u14B4:"\xB7\u14A8",\u14B8:"\xB7\u14AB",\u14C9:"\xB7\u14C0","\u18C6":"\xB7\u14C2","\u18C8":"\xB7\u14C3","\u18CA":"\xB7\u14C4","\u18CC":"\xB7\u14C5",\u14CB:"\xB7\u14C7",\u14CD:"\xB7\u14C8",\u14DC:"\xB7\u14D3",\u14DE:"\xB7\u14D5",\u14E0:"\xB7\u14D6",\u14E2:"\xB7\u14D7",\u14E4:"\xB7\u14D8",\u14E6:"\xB7\u14DA",\u14E8:"\xB7\u14DB",\u14F6:"\xB7\u14ED",\u14F8:"\xB7\u14EF",\u14FA:"\xB7\u14F0",\u14FC:"\xB7\u14F1",\u14FE:"\xB7\u14F2",\u1500:"\xB7\u14F4",\u1502:"\xB7\u14F5",\u1517:"\xB7\u1510",\u1519:"\xB7\u1511",\u151B:"\xB7\u1512",\u151D:"\xB7\u1513",\u151F:"\xB7\u1514",\u1521:"\xB7\u1515",\u1523:"\xB7\u1516",\u1531:"\xB7\u1528",\u1533:"\xB7\u1529",\u1535:"\xB7\u152A",\u1537:"\xB7\u152B",\u1539:"\xB7\u152D",\u153B:"\xB7\u152E","\u18CE":"\xB7\u1543","\u18CF":"\xB7\u1546","\u18D0":"\xB7\u1547","\u18D1":"\xB7\u1548","\u18D2":"\xB7\u1549","\u18D3":"\xB7\u154B",\u154E:"\xB7\u154C",\u155B:"\xB7\u155A",\u1568:"\xB7\u1567","\u18B3":"\xB7\u18B1","\u18B6":"\xB7\u18B4","\u18B9":"\xB7\u18B8","\u18C2":"\xB7\u18C0","\uA830":"\u0964","\u0965":"\u0964\u0964","\u1C3C":"\u1C3B\u1C3B","\u104B":"\u104A\u104A","\u1AA9":"\u1AA8\u1AA8","\u1AAB":"\u1AAA\u1AA8","\u1B5F":"\u1B5E\u1B5E","\u{10A57}":"\u{10A56}\u{10A56}","\u{1144C}":"\u{1144B}\u{1144B}","\u{11642}":"\u{11641}\u{11641}","\u{11C42}":"\u{11C41}\u{11C41}","\u1C7F":"\u1C7E\u1C7E","\u055D":"'","\uFF07":"'","\u2018":"'","\u2019":"'","\u201B":"'","\u2032":"'","\u2035":"'","\u055A":"'","\u05F3":"'","`":"'","\u1FEF":"'","\uFF40":"'","\xB4":"'","\u0384":"'","\u1FFD":"'","\u1FBD":"'","\u1FBF":"'","\u1FFE":"'","\u02B9":"'","\u0374":"'","\u02C8":"'","\u02CA":"'","\u02CB":"'","\u02F4":"'",\u02BB:"'",\u02BD:"'",\u02BC:"'",\u02BE:"'","\uA78C":"'",\u05D9:"'","\u07F4":"'","\u07F5":"'",\u144A:"'",\u16CC:"'","\u{16F51}":"'","\u{16F52}":"'","\u1CD3":"''",'"':"''","\uFF02":"''","\u201C":"''","\u201D":"''","\u201F":"''","\u2033":"''","\u2036":"''","\u3003":"''","\u05F4":"''","\u02DD":"''","\u02BA":"''","\u02F6":"''",\u02EE:"''",\u05F2:"''","\u2034":"'''","\u2037":"'''","\u2057":"''''",\u0181:"'B",\u018A:"'D",\u0149:"'n",\u01A4:"'P",\u01AC:"'T",\u01B3:"'Y","\uFF3B":"(","\u2768":"(","\u2772":"(","\u3014":"(","\uFD3E":"(","\u2E28":"((","\u3220":"(\u30FC)","\u2475":"(2)","\u2487":"(2O)","\u2476":"(3)","\u2477":"(4)","\u2478":"(5)","\u2479":"(6)","\u247A":"(7)","\u247B":"(8)","\u247C":"(9)","\u249C":"(a)","\u{1F110}":"(A)","\u249D":"(b)","\u{1F111}":"(B)","\u249E":"(c)","\u{1F112}":"(C)","\u249F":"(d)","\u{1F113}":"(D)","\u24A0":"(e)","\u{1F114}":"(E)","\u24A1":"(f)","\u{1F115}":"(F)","\u24A2":"(g)","\u{1F116}":"(G)","\u24A3":"(h)","\u{1F117}":"(H)","\u24A4":"(i)","\u24A5":"(j)","\u{1F119}":"(J)","\u24A6":"(k)","\u{1F11A}":"(K)","\u2474":"(l)","\u{1F118}":"(l)","\u24A7":"(l)","\u{1F11B}":"(L)","\u247F":"(l2)","\u2480":"(l3)","\u2481":"(l4)","\u2482":"(l5)","\u2483":"(l6)","\u2484":"(l7)","\u2485":"(l8)","\u2486":"(l9)","\u247E":"(ll)","\u247D":"(lO)","\u{1F11C}":"(M)","\u24A9":"(n)","\u{1F11D}":"(N)","\u24AA":"(o)","\u{1F11E}":"(O)","\u24AB":"(p)","\u{1F11F}":"(P)","\u24AC":"(q)","\u{1F120}":"(Q)","\u24AD":"(r)","\u{1F121}":"(R)","\u24A8":"(rn)","\u24AE":"(s)","\u{1F122}":"(S)","\u{1F12A}":"(S)","\u24AF":"(t)","\u{1F123}":"(T)","\u24B0":"(u)","\u{1F124}":"(U)","\u24B1":"(v)","\u{1F125}":"(V)","\u24B2":"(w)","\u{1F126}":"(W)","\u24B3":"(x)","\u{1F127}":"(X)","\u24B4":"(y)","\u{1F128}":"(Y)","\u24B5":"(z)","\u{1F129}":"(Z)","\u3200":"(\u1100)","\u320E":"(\uAC00)","\u3201":"(\u1102)","\u320F":"(\uB098)","\u3202":"(\u1103)","\u3210":"(\uB2E4)","\u3203":"(\u1105)","\u3211":"(\uB77C)","\u3204":"(\u1106)","\u3212":"(\uB9C8)","\u3205":"(\u1107)","\u3213":"(\uBC14)","\u3206":"(\u1109)","\u3214":"(\uC0AC)","\u3207":"(\u110B)","\u3215":"(\uC544)","\u321D":"(\uC624\uC804)","\u321E":"(\uC624\uD6C4)","\u3208":"(\u110C)","\u3216":"(\uC790)","\u321C":"(\uC8FC)","\u3209":"(\u110E)","\u3217":"(\uCC28)","\u320A":"(\u110F)","\u3218":"(\uCE74)","\u320B":"(\u1110)","\u3219":"(\uD0C0)","\u320C":"(\u1111)","\u321A":"(\uD30C)","\u320D":"(\u1112)","\u321B":"(\uD558)","\u3226":"(\u4E03)","\u3222":"(\u4E09)","\u{1F241}":"(\u4E09)","\u3228":"(\u4E5D)","\u3221":"(\u4E8C)","\u{1F242}":"(\u4E8C)","\u3224":"(\u4E94)","\u3239":"(\u4EE3)","\u323D":"(\u4F01)","\u3241":"(\u4F11)","\u3227":"(\u516B)","\u3225":"(\u516D)","\u3238":"(\u52B4)","\u{1F247}":"(\u52DD)","\u3229":"(\u5341)","\u323F":"(\u5354)","\u3234":"(\u540D)","\u323A":"(\u547C)","\u3223":"(\u56DB)","\u322F":"(\u571F)","\u323B":"(\u5B66)","\u{1F243}":"(\u5B89)","\u{1F245}":"(\u6253)","\u{1F248}":"(\u6557)","\u3230":"(\u65E5)","\u322A":"(\u6708)","\u3232":"(\u6709)","\u322D":"(\u6728)","\u{1F240}":"(\u672C)","\u3231":"(\u682A)","\u322C":"(\u6C34)","\u322B":"(\u706B)","\u{1F244}":"(\u70B9)","\u3235":"(\u7279)","\u{1F246}":"(\u76D7)","\u323C":"(\u76E3)","\u3233":"(\u793E)","\u3237":"(\u795D)","\u3240":"(\u796D)","\u3242":"(\u81EA)","\u3243":"(\u81F3)","\u3236":"(\u8CA1)","\u323E":"(\u8CC7)","\u322E":"(\u91D1)","\uFF3D":")","\u2769":")","\u2773":")","\u3015":")","\uFD3F":")","\u2E29":"))","\u2774":"{","\u{1D114}":"{","\u2775":"}","\u301A":"\u27E6","\u301B":"\u27E7","\u27E8":"\u276C","\u2329":"\u276C","\u3008":"\u276C","\u31DB":"\u276C",\u304F:"\u276C","\u{21FE8}":"\u276C","\u27E9":"\u276D","\u232A":"\u276D","\u3009":"\u276D","\uFF3E":"\uFE3F","\u2E3F":"\xB6","\u204E":"*","\u066D":"*","\u2217":"*","\u{1031F}":"*","\u1735":"/","\u2041":"/","\u2215":"/","\u2044":"/","\u2571":"/","\u27CB":"/","\u29F8":"/","\u{1D23A}":"/","\u31D3":"/",\u3033:"/","\u2CC6":"/",\u30CE:"/",\u4E3F:"/","\u2F03":"/","\u29F6":"/\u0304","\u2AFD":"//","\u2AFB":"///","\uFF3C":"\\","\uFE68":"\\","\u2216":"\\","\u27CD":"\\","\u29F5":"\\","\u29F9":"\\","\u{1D20F}":"\\","\u{1D23B}":"\\","\u31D4":"\\",\u4E36:"\\","\u2F02":"\\","\u2CF9":"\\\\","\u244A":"\\\\","\u27C8":"\\\u1455","\uA778":"&","\u0AF0":"\u0970","\u{110BB}":"\u0970","\u{111C7}":"\u0970","\u26AC":"\u0970","\u{111DB}":"\uA8FC","\u17D9":"\u0E4F","\u17D5":"\u0E5A","\u17DA":"\u0E5B","\u0F0C":"\u0F0B","\u0F0E":"\u0F0D\u0F0D","\u02C4":"^","\u02C6":"^","\uA67E":"\u02C7","\u02D8":"\u02C7","\u203E":"\u02C9","\uFE49":"\u02C9","\uFE4A":"\u02C9","\uFE4B":"\u02C9","\uFE4C":"\u02C9","\xAF":"\u02C9","\uFFE3":"\u02C9","\u2594":"\u02C9",\u044A:"\u02C9b","\uA651":"\u02C9bi","\u0375":"\u02CF","\u02FB":"\u02EA","\uA716":"\u02EA","\uA714":"\u02EB","\u3002":"\u02F3","\u2E30":"\xB0","\u02DA":"\xB0","\u2218":"\xB0","\u25CB":"\xB0","\u25E6":"\xB0","\u235C":"\xB0\u0332","\u2364":"\xB0\u0308","\u2103":"\xB0C","\u2109":"\xB0F","\u0BF5":"\u0BF3","\u0F1B":"\u0F1A\u0F1A","\u0F1F":"\u0F1A\u0F1D","\u0FCE":"\u0F1D\u0F1A","\u0F1E":"\u0F1D\u0F1D","\u24B8":"\xA9","\u24C7":"\xAE","\u24C5":"\u2117","\u{1D21B}":"\u2144","\u2BEC":"\u219E","\u2BED":"\u219F","\u2BEE":"\u21A0","\u2BEF":"\u21A1","\u21B5":"\u21B2","\u2965":"\u21C3\u21C2","\u296F":"\u21C3\u16DA","\u{1D6DB}":"\u2202","\u{1D715}":"\u2202","\u{1D74F}":"\u2202","\u{1D789}":"\u2202","\u{1D7C3}":"\u2202","\u{1E8CC}":"\u2202","\u{1E8CD}":"\u2202\u0335",\u00F0:"\u2202\u0335","\u2300":"\u2205","\u{1D6C1}":"\u2207","\u{1D6FB}":"\u2207","\u{1D735}":"\u2207","\u{1D76F}":"\u2207","\u{1D7A9}":"\u2207","\u{118A8}":"\u2207","\u2362":"\u2207\u0308","\u236B":"\u2207\u0334","\u2588":"\u220E","\u25A0":"\u220E","\u2A3F":"\u2210","\u16ED":"+","\u2795":"+","\u{1029B}":"+","\u2A23":"+\u0302","\u2A22":"+\u030A","\u2A24":"+\u0303","\u2214":"+\u0307","\u2A25":"+\u0323","\u2A26":"+\u0330","\u2A27":"+\u2082","\u2797":"\xF7","\u2039":"<","\u276E":"<","\u02C2":"<","\u{1D236}":"<",\u1438:"<",\u16B2:"<","\u22D6":"<\xB7","\u2CB4":"<\xB7",\u1445:"<\xB7","\u226A":"<<","\u22D8":"<<<","\u1400":"=","\u2E40":"=","\u30A0":"=","\uA4FF":"=","\u225A":"=\u0306","\u2259":"=\u0302","\u2257":"=\u030A","\u2250":"=\u0307","\u2251":"=\u0307\u0323","\u2A6E":"=\u20F0","\u2A75":"==","\u2A76":"===","\u225E":"=\u036B","\u203A":">","\u276F":">","\u02C3":">","\u{1D237}":">",\u1433:">","\u{16F3F}":">",\u1441:">\xB7","\u2AA5":"><","\u226B":">>","\u2A20":">>","\u22D9":">>>","\u2053":"~","\u02DC":"~","\u1FC0":"~","\u223C":"~","\u2368":"~\u0308","\u2E1E":"~\u0307","\u2A6A":"~\u0307","\u2E1F":"~\u0323","\u{1E8C8}":"\u2220","\u22C0":"\u2227","\u222F":"\u222E\u222E","\u2230":"\u222E\u222E\u222E","\u2E2B":"\u2234","\u2E2A":"\u2235","\u2E2C":"\u2237","\u{111DE}":"\u2248","\u264E":"\u224F","\u{1F75E}":"\u224F","\u2263":"\u2261","\u2A03":"\u228D","\u2A04":"\u228E","\u{1D238}":"\u228F","\u{1D239}":"\u2290","\u2A05":"\u2293","\u2A06":"\u2294","\u2A02":"\u2297","\u235F":"\u229B","\u{1F771}":"\u22A0","\u{1F755}":"\u22A1","\u25C1":"\u22B2","\u25B7":"\u22B3","\u2363":"\u22C6\u0308","\uFE34":"\u2307","\u25E0":"\u2312","\u2A3D":"\u2319","\u2325":"\u2324","\u29C7":"\u233B","\u25CE":"\u233E","\u29BE":"\u233E","\u29C5":"\u2342","\u29B0":"\u2349","\u23C3":"\u234B","\u23C2":"\u234E","\u23C1":"\u2355","\u23C6":"\u236D","\u2638":"\u2388","\uFE35":"\u23DC","\uFE36":"\u23DD","\uFE37":"\u23DE","\uFE38":"\u23DF","\uFE39":"\u23E0","\uFE3A":"\u23E1","\u25B1":"\u23E5","\u23FC":"\u23FB","\uFE31":"\u2502","\uFF5C":"\u2502","\u2503":"\u2502","\u250F":"\u250C","\u2523":"\u251C","\u2590":"\u258C","\u2597":"\u2596","\u259D":"\u2598","\u2610":"\u25A1","\uFFED":"\u25AA","\u25B8":"\u25B6","\u25BA":"\u25B6","\u2CE9":"\u2627","\u{1F70A}":"\u2629","\u{1F312}":"\u263D","\u{1F319}":"\u263D","\u23FE":"\u263E","\u{1F318}":"\u263E","\u29D9":"\u299A","\u{1F73A}":"\u29DF","\u2A3E":"\u2A1F","\u{101A0}":"\u2CE8","\u2669":"\u{1D158}\u{1D165}","\u266A":"\u{1D158}\u{1D165}\u{1D16E}","\u24EA":"\u{1F10D}","\u21BA":"\u{1F10E}","\u02D9":"\u0971","\u0D4E":"\u0971","\uFF0D":"\u30FC","\u2014":"\u30FC","\u2015":"\u30FC","\u2500":"\u30FC","\u2501":"\u30FC","\u31D0":"\u30FC","\uA7F7":"\u30FC",\u1173:"\u30FC",\u3161:"\u30FC",\u4E00:"\u30FC","\u2F00":"\u30FC",\u1196:"\u30FC\u30FC","\uD7B9":"\u30FC\u1161","\uD7BA":"\u30FC\u1165","\uD7BB":"\u30FC\u1165\u4E28","\uD7BC":"\u30FC\u1169",\u1195:"\u30FC\u116E",\u1174:"\u30FC\u4E28",\u3162:"\u30FC\u4E28",\u1197:"\u30FC\u4E28\u116E","\u{1F10F}":"$\u20E0","\u20A4":"\xA3","\u3012":"\u20B8","\u3036":"\u20B8","\u1B5C":"\u1B50","\uA9C6":"\uA9D0","\u{114D1}":"\u09E7","\u0CE7":"\u0C67","\u1065":"\u1041","\u2460":"\u2780","\u2469":"\u2789","\u23E8":"\u2081\u2080","\u{1D7D0}":"2","\u{1D7DA}":"2","\u{1D7E4}":"2","\u{1D7EE}":"2","\u{1D7F8}":"2","\u{1FBF2}":"2","\uA75A":"2",\u01A7:"2",\u03E8:"2","\uA644":"2",\u14BF:"2","\uA6EF":"2","\uA9CF":"\u0662","\u06F2":"\u0662","\u0AE8":"\u0968","\u{114D2}":"\u09E8","\u0CE8":"\u0C68","\u2461":"\u2781",\u01BB:"2\u0335","\u{1F103}":"2,","\u2489":"2.","\u33F5":"22\u65E5","\u336E":"22\u70B9","\u33F6":"23\u65E5","\u336F":"23\u70B9","\u33F7":"24\u65E5","\u3370":"24\u70B9","\u33F8":"25\u65E5","\u33F9":"26\u65E5","\u33FA":"27\u65E5","\u33FB":"28\u65E5","\u33FC":"29\u65E5","\u33F4":"2l\u65E5","\u336D":"2l\u70B9","\u249B":"2O.","\u33F3":"2O\u65E5","\u336C":"2O\u70B9","\u0DE9":"\u0DE8\u0DCF","\u0DEF":"\u0DE8\u0DD3","\u33E1":"2\u65E5","\u32C1":"2\u6708","\u335A":"2\u70B9","\u{1D206}":"3","\u{1D7D1}":"3","\u{1D7DB}":"3","\u{1D7E5}":"3","\u{1D7EF}":"3","\u{1D7F9}":"3","\u{1FBF3}":"3","\uA7AB":"3",\u021C:"3",\u01B7:"3","\uA76A":"3","\u2CCC":"3",\u0417:"3",\u04E0:"3","\u{16F3B}":"3","\u{118CA}":"3","\u06F3":"\u0663","\u{1E8C9}":"\u0663","\u0AE9":"\u0969","\u2462":"\u2782",\u0498:"3\u0326","\u{1F104}":"3,","\u248A":"3.","\u33FE":"3l\u65E5","\u33FD":"3O\u65E5","\u33E2":"3\u65E5","\u32C2":"3\u6708","\u335B":"3\u70B9","\u{1D7D2}":"4","\u{1D7DC}":"4","\u{1D7E6}":"4","\u{1D7F0}":"4","\u{1D7FA}":"4","\u{1FBF4}":"4",\u13CE:"4","\u{118AF}":"4","\u06F4":"\u0664","\u0AEA":"\u096A","\u2463":"\u2783","\u{1F105}":"4,","\u248B":"4.",\u1530:"4\xB7","\u33E3":"4\u65E5","\u32C3":"4\u6708","\u335C":"4\u70B9","\u{1D7D3}":"5","\u{1D7DD}":"5","\u{1D7E7}":"5","\u{1D7F1}":"5","\u{1D7FB}":"5","\u{1FBF5}":"5",\u01BC:"5","\u{118BB}":"5","\u2464":"\u2784","\u{1F106}":"5,","\u248C":"5.","\u33E4":"5\u65E5","\u32C4":"5\u6708","\u335D":"5\u70B9","\u{1D7D4}":"6","\u{1D7DE}":"6","\u{1D7E8}":"6","\u{1D7F2}":"6","\u{1D7FC}":"6","\u{1FBF6}":"6","\u2CD2":"6",\u0431:"6",\u13EE:"6","\u{118D5}":"6","\u06F6":"\u0666","\u{114D6}":"\u09EC","\u2465":"\u2785","\u{1F107}":"6,","\u248D":"6.","\u33E5":"6\u65E5","\u32C5":"6\u6708","\u335E":"6\u70B9","\u{1D212}":"7","\u{1D7D5}":"7","\u{1D7DF}":"7","\u{1D7E9}":"7","\u{1D7F3}":"7","\u{1D7FD}":"7","\u{1FBF7}":"7","\u{104D2}":"7","\u{118C6}":"7","\u2466":"\u2786","\u{1F108}":"7,","\u248E":"7.","\u33E6":"7\u65E5","\u32C6":"7\u6708","\u335F":"7\u70B9","\u0B03":"8","\u09EA":"8","\u0A6A":"8","\u{1E8CB}":"8","\u{1D7D6}":"8","\u{1D7E0}":"8","\u{1D7EA}":"8","\u{1D7F4}":"8","\u{1D7FE}":"8","\u{1FBF8}":"8",\u0223:"8",\u0222:"8","\u{1031A}":"8","\u0AEE":"\u096E","\u2467":"\u2787","\u{1F109}":"8,","\u248F":"8.","\u33E7":"8\u65E5","\u32C7":"8\u6708","\u3360":"8\u70B9","\u0A67":"9","\u0B68":"9","\u09ED":"9","\u0D6D":"9","\u{1D7D7}":"9","\u{1D7E1}":"9","\u{1D7EB}":"9","\u{1D7F5}":"9","\u{1D7FF}":"9","\u{1FBF9}":"9","\uA76E":"9","\u2CCA":"9","\u{118CC}":"9","\u{118AC}":"9","\u{118D6}":"9","\u0967":"\u0669","\u{118E4}":"\u0669","\u06F9":"\u0669","\u0CEF":"\u0C6F","\u2468":"\u2788","\u{1F10A}":"9,","\u2490":"9.","\u33E8":"9\u65E5","\u32C8":"9\u6708","\u3361":"9\u70B9","\u237A":"a",\uFF41:"a","\u{1D41A}":"a","\u{1D44E}":"a","\u{1D482}":"a","\u{1D4B6}":"a","\u{1D4EA}":"a","\u{1D51E}":"a","\u{1D552}":"a","\u{1D586}":"a","\u{1D5BA}":"a","\u{1D5EE}":"a","\u{1D622}":"a","\u{1D656}":"a","\u{1D68A}":"a",\u0251:"a",\u03B1:"a","\u{1D6C2}":"a","\u{1D6FC}":"a","\u{1D736}":"a","\u{1D770}":"a","\u{1D7AA}":"a",\u0430:"a","\u2DF6":"\u0363",\uFF21:"A","\u{1D400}":"A","\u{1D434}":"A","\u{1D468}":"A","\u{1D49C}":"A","\u{1D4D0}":"A","\u{1D504}":"A","\u{1D538}":"A","\u{1D56C}":"A","\u{1D5A0}":"A","\u{1D5D4}":"A","\u{1D608}":"A","\u{1D63C}":"A","\u{1D670}":"A",\u0391:"A","\u{1D6A8}":"A","\u{1D6E2}":"A","\u{1D71C}":"A","\u{1D756}":"A","\u{1D790}":"A",\u0410:"A",\u13AA:"A",\u15C5:"A","\uA4EE":"A","\u{16F40}":"A","\u{102A0}":"A","\u2376":"a\u0332",\u01CE:"\u0103",\u01CD:"\u0102",\u0227:"\xE5",\u0226:"\xC5",\u1E9A:"\u1EA3","\u2100":"a/c","\u2101":"a/s","\uA733":"aa","\uA732":"AA",\u00E6:"ae",\u04D5:"ae",\u00C6:"AE",\u04D4:"AE","\uA735":"ao","\uA734":"AO","\u{1F707}":"AR","\uA737":"au","\uA736":"AU","\uA739":"av","\uA73B":"av","\uA738":"AV","\uA73A":"AV","\uA73D":"ay","\uA73C":"AY","\uAB7A":"\u1D00","\u2200":"\u2C6F","\u{1D217}":"\u2C6F",\u15C4:"\u2C6F","\uA4EF":"\u2C6F","\u{1041F}":"\u2C70","\u{1D41B}":"b","\u{1D44F}":"b","\u{1D483}":"b","\u{1D4B7}":"b","\u{1D4EB}":"b","\u{1D51F}":"b","\u{1D553}":"b","\u{1D587}":"b","\u{1D5BB}":"b","\u{1D5EF}":"b","\u{1D623}":"b","\u{1D657}":"b","\u{1D68B}":"b",\u0184:"b",\u042C:"b",\u13CF:"b",\u1472:"b",\u15AF:"b",\uFF22:"B",\u212C:"B","\u{1D401}":"B","\u{1D435}":"B","\u{1D469}":"B","\u{1D4D1}":"B","\u{1D505}":"B","\u{1D539}":"B","\u{1D56D}":"B","\u{1D5A1}":"B","\u{1D5D5}":"B","\u{1D609}":"B","\u{1D63D}":"B","\u{1D671}":"B","\uA7B4":"B",\u0392:"B","\u{1D6A9}":"B","\u{1D6E3}":"B","\u{1D71D}":"B","\u{1D757}":"B","\u{1D791}":"B",\u0412:"B",\u13F4:"B",\u15F7:"B","\uA4D0":"B","\u{10282}":"B","\u{102A1}":"B","\u{10301}":"B",\u0253:"b\u0314",\u1473:"b\u0307",\u0183:"b\u0304",\u0182:"b\u0304",\u0411:"b\u0304",\u0180:"b\u0335",\u048D:"b\u0335",\u048C:"b\u0335",\u0463:"b\u0335",\u0462:"b\u0335",\u147F:"b\xB7",\u1481:"b\u0307\xB7",\u1488:"b'",\u042B:"bl",\u0432:"\u0299","\u13FC":"\u0299",\uFF43:"c","\u217D":"c","\u{1D41C}":"c","\u{1D450}":"c","\u{1D484}":"c","\u{1D4B8}":"c","\u{1D4EC}":"c","\u{1D520}":"c","\u{1D554}":"c","\u{1D588}":"c","\u{1D5BC}":"c","\u{1D5F0}":"c","\u{1D624}":"c","\u{1D658}":"c","\u{1D68C}":"c","\u1D04":"c",\u03F2:"c","\u2CA5":"c",\u0441:"c","\uABAF":"c","\u{1043D}":"c","\u2DED":"\u0368","\u{1F74C}":"C","\u{118F2}":"C","\u{118E9}":"C",\uFF23:"C","\u216D":"C",\u2102:"C",\u212D:"C","\u{1D402}":"C","\u{1D436}":"C","\u{1D46A}":"C","\u{1D49E}":"C","\u{1D4D2}":"C","\u{1D56E}":"C","\u{1D5A2}":"C","\u{1D5D6}":"C","\u{1D60A}":"C","\u{1D63E}":"C","\u{1D672}":"C","\u03F9":"C","\u2CA4":"C",\u0421:"C",\u13DF:"C","\uA4DA":"C","\u{102A2}":"C","\u{10302}":"C","\u{10415}":"C","\u{1051C}":"C","\xA2":"c\u0338","\u023C":"c\u0338","\u20A1":"C\u20EB","\u{1F16E}":"C\u20E0",\u00E7:"c\u0326",\u04AB:"c\u0326",\u00C7:"C\u0326",\u04AA:"C\u0326",\u0187:"C'","\u2105":"c/o","\u2106":"c/u","\u{1F16D}":"\u33C4 \u20DD","\u22F4":"\uA793",\u025B:"\uA793",\u03B5:"\uA793","\u03F5":"\uA793","\u{1D6C6}":"\uA793","\u{1D6DC}":"\uA793","\u{1D700}":"\uA793","\u{1D716}":"\uA793","\u{1D73A}":"\uA793","\u{1D750}":"\uA793","\u{1D774}":"\uA793","\u{1D78A}":"\uA793","\u{1D7AE}":"\uA793","\u{1D7C4}":"\uA793","\u2C89":"\uA793",\u0454:"\uA793","\u0511":"\uA793","\uAB9B":"\uA793","\u{118CE}":"\uA793","\u{10429}":"\uA793","\u20AC":"\uA792","\u2C88":"\uA792",\u0404:"\uA792","\u2377":"\uA793\u0332","\u037D":"\uA73F","\u03FF":"\uA73E","\u217E":"d","\u2146":"d","\u{1D41D}":"d","\u{1D451}":"d","\u{1D485}":"d","\u{1D4B9}":"d","\u{1D4ED}":"d","\u{1D521}":"d","\u{1D555}":"d","\u{1D589}":"d","\u{1D5BD}":"d","\u{1D5F1}":"d","\u{1D625}":"d","\u{1D659}":"d","\u{1D68D}":"d","\u0501":"d",\u13E7:"d",\u146F:"d","\uA4D2":"d","\u216E":"D","\u2145":"D","\u{1D403}":"D","\u{1D437}":"D","\u{1D46B}":"D","\u{1D49F}":"D","\u{1D4D3}":"D","\u{1D507}":"D","\u{1D53B}":"D","\u{1D56F}":"D","\u{1D5A3}":"D","\u{1D5D7}":"D","\u{1D60B}":"D","\u{1D63F}":"D","\u{1D673}":"D",\u13A0:"D",\u15DE:"D",\u15EA:"D","\uA4D3":"D",\u0257:"d\u0314",\u0256:"d\u0328",\u018C:"d\u0304",\u0111:"d\u0335",\u0110:"D\u0335",\u00D0:"D\u0335",\u0189:"D\u0335","\u20AB":"d\u0335\u0331","\uA77A":"\uA779",\u147B:"d\xB7",\u1487:"d'",\u02A4:"d\u021D",\u01F3:"dz",\u02A3:"dz",\u01F2:"Dz",\u01F1:"DZ",\u01C6:"d\u017E",\u01C5:"D\u017E",\u01C4:"D\u017D",\u02A5:"d\u0291","\uAB70":"\u1D05","\u2E39":"\u1E9F",\u03B4:"\u1E9F","\u{1D6C5}":"\u1E9F","\u{1D6FF}":"\u1E9F","\u{1D739}":"\u1E9F","\u{1D773}":"\u1E9F","\u{1D7AD}":"\u1E9F",\u056E:"\u1E9F",\u1577:"\u1E9F","\u212E":"e",\uFF45:"e",\u212F:"e","\u2147":"e","\u{1D41E}":"e","\u{1D452}":"e","\u{1D486}":"e","\u{1D4EE}":"e","\u{1D522}":"e","\u{1D556}":"e","\u{1D58A}":"e","\u{1D5BE}":"e","\u{1D5F2}":"e","\u{1D626}":"e","\u{1D65A}":"e","\u{1D68E}":"e","\uAB32":"e",\u0435:"e",\u04BD:"e","\u2DF7":"\u0364","\u22FF":"E",\uFF25:"E",\u2130:"E","\u{1D404}":"E","\u{1D438}":"E","\u{1D46C}":"E","\u{1D4D4}":"E","\u{1D508}":"E","\u{1D53C}":"E","\u{1D570}":"E","\u{1D5A4}":"E","\u{1D5D8}":"E","\u{1D60C}":"E","\u{1D640}":"E","\u{1D674}":"E",\u0395:"E","\u{1D6AC}":"E","\u{1D6E6}":"E","\u{1D720}":"E","\u{1D75A}":"E","\u{1D794}":"E",\u0415:"E","\u2D39":"E",\u13AC:"E","\uA4F0":"E","\u{118A6}":"E","\u{118AE}":"E","\u{10286}":"E",\u011B:"\u0115",\u011A:"\u0114","\u0247":"e\u0338","\u0246":"E\u0338",\u04BF:"e\u0328","\uAB7C":"\u1D07",\u0259:"\u01DD",\u04D9:"\u01DD","\u2203":"\u018E","\u2D3A":"\u018E","\uA4F1":"\u018E",\u025A:"\u01DD\u02DE","\u1D14":"\u01DDo","\uAB41":"\u01DDo\u0338","\uAB42":"\u01DDo\u0335",\u04D8:"\u018F","\u{1D221}":"\u0190",\u2107:"\u0190","\u0510":"\u0190",\u13CB:"\u0190","\u{16F2D}":"\u0190","\u{10401}":"\u0190","\u1D9F":"\u1D4B","\u1D08":"\u025C",\u0437:"\u025C",\u0499:"\u025C\u0326","\u{10442}":"\u025E","\uA79D":"\u029A","\u{1042A}":"\u029A","\u{1D41F}":"f","\u{1D453}":"f","\u{1D487}":"f","\u{1D4BB}":"f","\u{1D4EF}":"f","\u{1D523}":"f","\u{1D557}":"f","\u{1D58B}":"f","\u{1D5BF}":"f","\u{1D5F3}":"f","\u{1D627}":"f","\u{1D65B}":"f","\u{1D68F}":"f","\uAB35":"f","\uA799":"f",\u017F:"f","\u1E9D":"f",\u0584:"f","\u{1D213}":"F",\u2131:"F","\u{1D405}":"F","\u{1D439}":"F","\u{1D46D}":"F","\u{1D4D5}":"F","\u{1D509}":"F","\u{1D53D}":"F","\u{1D571}":"F","\u{1D5A5}":"F","\u{1D5D9}":"F","\u{1D60D}":"F","\u{1D641}":"F","\u{1D675}":"F","\uA798":"F",\u03DC:"F","\u{1D7CA}":"F",\u15B4:"F","\uA4DD":"F","\u{118C2}":"F","\u{118A2}":"F","\u{10287}":"F","\u{102A5}":"F","\u{10525}":"F",\u0192:"f\u0326",\u0191:"F\u0326","\u1D6E":"f\u0334","\u213B":"FAX",\uFB00:"ff",\uFB03:"ffi",\uFB04:"ffl",\uFB01:"fi",\uFB02:"fl",\u02A9:"f\u014B",\u15B5:"\u2132","\uA4DE":"\u2132","\u{1D230}":"\uA7FB",\u15B7:"\uA7FB",\uFF47:"g",\u210A:"g","\u{1D420}":"g","\u{1D454}":"g","\u{1D488}":"g","\u{1D4F0}":"g","\u{1D524}":"g","\u{1D558}":"g","\u{1D58C}":"g","\u{1D5C0}":"g","\u{1D5F4}":"g","\u{1D628}":"g","\u{1D65C}":"g","\u{1D690}":"g",\u0261:"g","\u1D83":"g",\u018D:"g",\u0581:"g","\u{1D406}":"G","\u{1D43A}":"G","\u{1D46E}":"G","\u{1D4A2}":"G","\u{1D4D6}":"G","\u{1D50A}":"G","\u{1D53E}":"G","\u{1D572}":"G","\u{1D5A6}":"G","\u{1D5DA}":"G","\u{1D60E}":"G","\u{1D642}":"G","\u{1D676}":"G","\u050C":"G",\u13C0:"G",\u13F3:"G","\uA4D6":"G","\u1DA2":"\u1D4D",\u0260:"g\u0314",\u01E7:"\u011F",\u01E6:"\u011E",\u01F5:"\u0123",\u01E5:"g\u0335",\u01E4:"G\u0335",\u0193:"G'","\u050D":"\u0262","\uAB90":"\u0262","\u13FB":"\u0262",\uFF48:"h",\u210E:"h","\u{1D421}":"h","\u{1D489}":"h","\u{1D4BD}":"h","\u{1D4F1}":"h","\u{1D525}":"h","\u{1D559}":"h","\u{1D58D}":"h","\u{1D5C1}":"h","\u{1D5F5}":"h","\u{1D629}":"h","\u{1D65D}":"h","\u{1D691}":"h",\u04BB:"h",\u0570:"h",\u13C2:"h",\uFF28:"H",\u210B:"H",\u210C:"H",\u210D:"H","\u{1D407}":"H","\u{1D43B}":"H","\u{1D46F}":"H","\u{1D4D7}":"H","\u{1D573}":"H","\u{1D5A7}":"H","\u{1D5DB}":"H","\u{1D60F}":"H","\u{1D643}":"H","\u{1D677}":"H",\u0397:"H","\u{1D6AE}":"H","\u{1D6E8}":"H","\u{1D722}":"H","\u{1D75C}":"H","\u{1D796}":"H","\u2C8E":"H",\u041D:"H",\u13BB:"H",\u157C:"H","\uA4E7":"H","\u{102CF}":"H","\u1D78":"\u1D34",\u0266:"h\u0314","\uA695":"h\u0314",\u13F2:"h\u0314","\u2C67":"H\u0329",\u04A2:"H\u0329",\u0127:"h\u0335",\u210F:"h\u0335",\u045B:"h\u0335",\u0126:"H\u0335","\u04C9":"H\u0326",\u04C7:"H\u0326",\u043D:"\u029C","\uAB8B":"\u029C",\u04A3:"\u029C\u0329","\u04CA":"\u029C\u0326",\u04C8:"\u029C\u0326","\u050A":"\u01F6","\uAB80":"\u2C76","\u0370":"\u2C75",\u13A8:"\u2C75",\u13B0:"\u2C75","\uA6B1":"\u2C75","\uA795":"\uA727","\u02DB":"i","\u2373":"i",\uFF49:"i","\u2170":"i",\u2139:"i","\u2148":"i","\u{1D422}":"i","\u{1D456}":"i","\u{1D48A}":"i","\u{1D4BE}":"i","\u{1D4F2}":"i","\u{1D526}":"i","\u{1D55A}":"i","\u{1D58E}":"i","\u{1D5C2}":"i","\u{1D5F6}":"i","\u{1D62A}":"i","\u{1D65E}":"i","\u{1D692}":"i",\u0131:"i","\u{1D6A4}":"i",\u026A:"i",\u0269:"i",\u03B9:"i",\u1FBE:"i",\u037A:"i","\u{1D6CA}":"i","\u{1D704}":"i","\u{1D73E}":"i","\u{1D778}":"i","\u{1D7B2}":"i",\u0456:"i","\uA647":"i","\u04CF":"i","\uAB75":"i",\u13A5:"i","\u{118C3}":"i","\u24DB":"\u24BE","\u2378":"i\u0332",\u01D0:"\u012D",\u01CF:"\u012C",\u0268:"i\u0335","\u1D7B":"i\u0335","\u1D7C":"i\u0335","\u2171":"ii","\u2172":"iii",\u0133:"ij","\u2173":"iv","\u2178":"ix",\uFF4A:"j","\u2149":"j","\u{1D423}":"j","\u{1D457}":"j","\u{1D48B}":"j","\u{1D4BF}":"j","\u{1D4F3}":"j","\u{1D527}":"j","\u{1D55B}":"j","\u{1D58F}":"j","\u{1D5C3}":"j","\u{1D5F7}":"j","\u{1D62B}":"j","\u{1D65F}":"j","\u{1D693}":"j",\u03F3:"j",\u0458:"j",\uFF2A:"J","\u{1D409}":"J","\u{1D43D}":"J","\u{1D471}":"J","\u{1D4A5}":"J","\u{1D4D9}":"J","\u{1D50D}":"J","\u{1D541}":"J","\u{1D575}":"J","\u{1D5A9}":"J","\u{1D5DD}":"J","\u{1D611}":"J","\u{1D645}":"J","\u{1D679}":"J","\uA7B2":"J","\u037F":"J",\u0408:"J",\u13AB:"J",\u148D:"J","\uA4D9":"J","\u0249":"j\u0335","\u0248":"J\u0335",\u1499:"J\xB7","\u{1D6A5}":"\u0237",\u0575:"\u0237","\uAB7B":"\u1D0A","\u{1D424}":"k","\u{1D458}":"k","\u{1D48C}":"k","\u{1D4C0}":"k","\u{1D4F4}":"k","\u{1D528}":"k","\u{1D55C}":"k","\u{1D590}":"k","\u{1D5C4}":"k","\u{1D5F8}":"k","\u{1D62C}":"k","\u{1D660}":"k","\u{1D694}":"k",\u212A:"K",\uFF2B:"K","\u{1D40A}":"K","\u{1D43E}":"K","\u{1D472}":"K","\u{1D4A6}":"K","\u{1D4DA}":"K","\u{1D50E}":"K","\u{1D542}":"K","\u{1D576}":"K","\u{1D5AA}":"K","\u{1D5DE}":"K","\u{1D612}":"K","\u{1D646}":"K","\u{1D67A}":"K",\u039A:"K","\u{1D6B1}":"K","\u{1D6EB}":"K","\u{1D725}":"K","\u{1D75F}":"K","\u{1D799}":"K","\u2C94":"K",\u041A:"K",\u13E6:"K",\u16D5:"K","\uA4D7":"K","\u{10518}":"K",\u0199:"k\u0314","\u2C69":"K\u0329",\u049A:"K\u0329","\u20AD":"K\u0335","\uA740":"K\u0335",\u049E:"K\u0335",\u0198:"K'","\u05C0":"l","|":"l","\u2223":"l","\u23FD":"l","\uFFE8":"l","\u0661":"l","\u06F1":"l","\u{10320}":"l","\u{1E8C7}":"l","\u{1D7CF}":"l","\u{1D7D9}":"l","\u{1D7E3}":"l","\u{1D7ED}":"l","\u{1D7F7}":"l","\u{1FBF1}":"l",I:Qb,\uFF29:"l","\u2160":"l",\u2110:"l",\u2111:"l","\u{1D408}":"l","\u{1D43C}":"l","\u{1D470}":"l","\u{1D4D8}":"l","\u{1D540}":"l","\u{1D574}":"l","\u{1D5A8}":"l","\u{1D5DC}":"l","\u{1D610}":"l","\u{1D644}":"l","\u{1D678}":"l",\u0196:"l",\uFF4C:"l","\u217C":"l",\u2113:"l","\u{1D425}":"l","\u{1D459}":"l","\u{1D48D}":"l","\u{1D4C1}":"l","\u{1D4F5}":"l","\u{1D529}":"l","\u{1D55D}":"l","\u{1D591}":"l","\u{1D5C5}":"l","\u{1D5F9}":"l","\u{1D62D}":"l","\u{1D661}":"l","\u{1D695}":"l",\u01C0:"l",\u0399:"l","\u{1D6B0}":"l","\u{1D6EA}":"l","\u{1D724}":"l","\u{1D75E}":"l","\u{1D798}":"l","\u2C92":"l",\u0406:"l",\u04C0:"l",\u05D5:"l",\u05DF:"l",\u0627:"l","\u{1EE00}":"l","\u{1EE80}":"l",\uFE8E:"l",\uFE8D:"l","\u07CA":"l","\u2D4F":"l",\u16C1:"l","\uA4F2":"l","\u{16F28}":"l","\u{1028A}":"l","\u{10309}":"l","\u{1D22A}":"L","\u216C":"L",\u2112:"L","\u{1D40B}":"L","\u{1D43F}":"L","\u{1D473}":"L","\u{1D4DB}":"L","\u{1D50F}":"L","\u{1D543}":"L","\u{1D577}":"L","\u{1D5AB}":"L","\u{1D5DF}":"L","\u{1D613}":"L","\u{1D647}":"L","\u{1D67B}":"L","\u2CD0":"L",\u13DE:"L",\u14AA:"L","\uA4E1":"L","\u{16F16}":"L","\u{118A3}":"L","\u{118B2}":"L","\u{1041B}":"L","\u{10526}":"L",\uFD3C:"l\u030B",\uFD3D:"l\u030B",\u0142:"l\u0338",\u0141:"L\u0338",\u026D:"l\u0328",\u0197:"l\u0335",\u019A:"l\u0335",\u026B:"l\u0334",\u0625:"l\u0655",\uFE88:"l\u0655",\uFE87:"l\u0655",\u0673:"l\u0655",\u0140:"l\xB7",\u013F:"l\xB7",\u14B7:"l\xB7","\u{1F102}":"l,","\u2488":"l.",\u05F1:"l'","\u2493":"l2.","\u33EB":"l2\u65E5","\u32CB":"l2\u6708","\u3364":"l2\u70B9","\u2494":"l3.","\u33EC":"l3\u65E5","\u3365":"l3\u70B9","\u2495":"l4.","\u33ED":"l4\u65E5","\u3366":"l4\u70B9","\u2496":"l5.","\u33EE":"l5\u65E5","\u3367":"l5\u70B9","\u2497":"l6.","\u33EF":"l6\u65E5","\u3368":"l6\u70B9","\u2498":"l7.","\u33F0":"l7\u65E5","\u3369":"l7\u70B9","\u2499":"l8.","\u33F1":"l8\u65E5","\u336A":"l8\u70B9","\u249A":"l9.","\u33F2":"l9\u65E5","\u336B":"l9\u70B9",\u01C9:"lj",\u0132:"lJ",\u01C8:"Lj",\u01C7:"LJ","\u2016":"ll","\u2225":"ll","\u2161":"ll",\u01C1:"ll",\u05F0:"ll","\u{10199}":"l\u0335l\u0335","\u2492":"ll.","\u2162":"lll","\u{10198}":"l\u0335l\u0335S\u0335","\u33EA":"ll\u65E5","\u32CA":"ll\u6708","\u3363":"ll\u70B9",\u042E:"lO","\u2491":"lO.","\u33E9":"lO\u65E5","\u32C9":"lO\u6708","\u3362":"lO\u70B9",\u02AA:"ls","\u20B6":"lt","\u2163":"lV","\u2168":"lX",\u026E:"l\u021D",\u02AB:"lz",\u0623:"l\u0674",\uFE84:"l\u0674",\uFE83:"l\u0674",\u0672:"l\u0674",\u0675:"l\u0674",\uFDF3:"l\u0643\u0628\u0631",\uFDF2:"l\u0644\u0644\u0651\u0670o","\u33E0":"l\u65E5","\u32C0":"l\u6708","\u3359":"l\u70B9","\u2CD1":"\u029F","\uABAE":"\u029F","\u{10443}":"\u029F",\uFF2D:"M","\u216F":"M",\u2133:"M","\u{1D40C}":"M","\u{1D440}":"M","\u{1D474}":"M","\u{1D4DC}":"M","\u{1D510}":"M","\u{1D544}":"M","\u{1D578}":"M","\u{1D5AC}":"M","\u{1D5E0}":"M","\u{1D614}":"M","\u{1D648}":"M","\u{1D67C}":"M",\u039C:"M","\u{1D6B3}":"M","\u{1D6ED}":"M","\u{1D727}":"M","\u{1D761}":"M","\u{1D79B}":"M","\u03FA":"M","\u2C98":"M",\u041C:"M",\u13B7:"M",\u15F0:"M",\u16D6:"M","\uA4DF":"M","\u{102B0}":"M","\u{10311}":"M","\u04CD":"M\u0326","\u{1F76B}":"MB","\u2DE8":"\u1DDF","\u{1D427}":"n","\u{1D45B}":"n","\u{1D48F}":"n","\u{1D4C3}":"n","\u{1D4F7}":"n","\u{1D52B}":"n","\u{1D55F}":"n","\u{1D593}":"n","\u{1D5C7}":"n","\u{1D5FB}":"n","\u{1D62F}":"n","\u{1D663}":"n","\u{1D697}":"n",\u0578:"n",\u057C:"n",\uFF2E:"N",\u2115:"N","\u{1D40D}":"N","\u{1D441}":"N","\u{1D475}":"N","\u{1D4A9}":"N","\u{1D4DD}":"N","\u{1D511}":"N","\u{1D579}":"N","\u{1D5AD}":"N","\u{1D5E1}":"N","\u{1D615}":"N","\u{1D649}":"N","\u{1D67D}":"N",\u039D:"N","\u{1D6B4}":"N","\u{1D6EE}":"N","\u{1D728}":"N","\u{1D762}":"N","\u{1D79C}":"N","\u2C9A":"N","\uA4E0":"N","\u{10513}":"N","\u{1018E}":"N\u030A",\u0273:"n\u0328",\u019E:"n\u0329",\u03B7:"n\u0329","\u{1D6C8}":"n\u0329","\u{1D702}":"n\u0329","\u{1D73C}":"n\u0329","\u{1D776}":"n\u0329","\u{1D7B0}":"n\u0329",\u019D:"N\u0326","\u1D70":"n\u0334",\u01CC:"nj",\u01CB:"Nj",\u01CA:"NJ","\u2116":"No","\u0377":"\u1D0E",\u0438:"\u1D0E","\u{1044D}":"\u1D0E",\u0146:"\u0272","\u0C02":"o","\u0C82":"o","\u0D02":"o","\u0D82":"o","\u0966":"o","\u0A66":"o","\u0AE6":"o","\u0BE6":"o","\u0C66":"o","\u0CE6":"o","\u0D66":"o","\u0E50":"o","\u0ED0":"o","\u1040":"o","\u0665":"o","\u06F5":"o",\uFF4F:"o",\u2134:"o","\u{1D428}":"o","\u{1D45C}":"o","\u{1D490}":"o","\u{1D4F8}":"o","\u{1D52C}":"o","\u{1D560}":"o","\u{1D594}":"o","\u{1D5C8}":"o","\u{1D5FC}":"o","\u{1D630}":"o","\u{1D664}":"o","\u{1D698}":"o","\u1D0F":"o","\u1D11":"o","\uAB3D":"o",\u03BF:"o","\u{1D6D0}":"o","\u{1D70A}":"o","\u{1D744}":"o","\u{1D77E}":"o","\u{1D7B8}":"o",\u03C3:"o","\u{1D6D4}":"o","\u{1D70E}":"o","\u{1D748}":"o","\u{1D782}":"o","\u{1D7BC}":"o","\u2C9F":"o",\u043E:"o","\u10FF":"o",\u0585:"o",\u05E1:"o",\u0647:"o","\u{1EE24}":"o","\u{1EE64}":"o","\u{1EE84}":"o",\uFEEB:"o",\uFEEC:"o",\uFEEA:"o",\uFEE9:"o",\u06BE:"o",\uFBAC:"o",\uFBAD:"o",\uFBAB:"o",\uFBAA:"o",\u06C1:"o",\uFBA8:"o",\uFBA9:"o",\uFBA7:"o",\uFBA6:"o",\u06D5:"o",\u0D20:"o",\u101D:"o","\u{104EA}":"o","\u{118C8}":"o","\u{118D7}":"o","\u{1042C}":"o","\u07C0":"O","\u09E6":"O","\u0B66":"O","\u3007":"O","\u{114D0}":"O","\u{118E0}":"O","\u{1D7CE}":"O","\u{1D7D8}":"O","\u{1D7E2}":"O","\u{1D7EC}":"O","\u{1D7F6}":"O","\u{1FBF0}":"O",\uFF2F:"O","\u{1D40E}":"O","\u{1D442}":"O","\u{1D476}":"O","\u{1D4AA}":"O","\u{1D4DE}":"O","\u{1D512}":"O","\u{1D546}":"O","\u{1D57A}":"O","\u{1D5AE}":"O","\u{1D5E2}":"O","\u{1D616}":"O","\u{1D64A}":"O","\u{1D67E}":"O",\u039F:"O","\u{1D6B6}":"O","\u{1D6F0}":"O","\u{1D72A}":"O","\u{1D764}":"O","\u{1D79E}":"O","\u2C9E":"O",\u041E:"O",\u0555:"O","\u2D54":"O",\u12D0:"O",\u0B20:"O","\u{104C2}":"O","\uA4F3":"O","\u{118B5}":"O","\u{10292}":"O","\u{102AB}":"O","\u{10404}":"O","\u{10516}":"O","\u2070":"\xBA","\u1D52":"\xBA",\u01D2:"\u014F",\u01D1:"\u014E","\u06FF":"o\u0302",\u0150:"\xD6",\u00F8:"o\u0338","\uAB3E":"o\u0338",\u00D8:"O\u0338","\u2D41":"O\u0338",\u01FE:"O\u0338\u0301",\u0275:"o\u0335","\uA74B":"o\u0335",\u04E9:"o\u0335",\u0473:"o\u0335","\uAB8E":"o\u0335","\uABBB":"o\u0335","\u2296":"O\u0335","\u229D":"O\u0335","\u236C":"O\u0335","\u{1D21A}":"O\u0335","\u{1F714}":"O\u0335",\u019F:"O\u0335","\uA74A":"O\u0335",\u03B8:"O\u0335",\u03D1:"O\u0335","\u{1D6C9}":"O\u0335","\u{1D6DD}":"O\u0335","\u{1D703}":"O\u0335","\u{1D717}":"O\u0335","\u{1D73D}":"O\u0335","\u{1D751}":"O\u0335","\u{1D777}":"O\u0335","\u{1D78B}":"O\u0335","\u{1D7B1}":"O\u0335","\u{1D7C5}":"O\u0335",\u0398:"O\u0335","\u03F4":"O\u0335","\u{1D6AF}":"O\u0335","\u{1D6B9}":"O\u0335","\u{1D6E9}":"O\u0335","\u{1D6F3}":"O\u0335","\u{1D723}":"O\u0335","\u{1D72D}":"O\u0335","\u{1D75D}":"O\u0335","\u{1D767}":"O\u0335","\u{1D797}":"O\u0335","\u{1D7A1}":"O\u0335",\u04E8:"O\u0335",\u0472:"O\u0335","\u2D31":"O\u0335",\u13BE:"O\u0335",\u13EB:"O\u0335","\uAB74":"o\u031B",\uFCD9:"o\u0670","\u{1F101}":"O,","\u{1F100}":"O.",\u01A1:"o'",\u01A0:"O'",\u13A4:"O'","%":"\xBA/\u2080","\u066A":"\xBA/\u2080","\u2052":"\xBA/\u2080","\u2030":"\xBA/\u2080\u2080","\u0609":"\xBA/\u2080\u2080","\u2031":"\xBA/\u2080\u2080\u2080","\u060A":"\xBA/\u2080\u2080\u2080",\u0153:"oe",\u0152:"OE",\u0276:"o\u1D07","\u221E":"oo","\uA74F":"oo","\uA699":"oo","\uA74E":"OO","\uA698":"OO",\uFCD7:"o\u062C",\uFC51:"o\u062C",\uFCD8:"o\u0645",\uFC52:"o\u0645",\uFD93:"o\u0645\u062C",\uFD94:"o\u0645\u0645",\uFC53:"o\u0649",\uFC54:"o\u0649","\u0D5F":"o\u0D30o",\u1010:"o\u102C","\u3358":"O\u70B9","\u2184":"\u0254","\u1D10":"\u0254","\u037B":"\u0254","\u{1044B}":"\u0254","\u2183":"\u0186","\u03FD":"\u0186","\uA4DB":"\u0186","\u{10423}":"\u0186","\uAB3F":"\u0254\u0338","\uAB62":"\u0254e","\u{1043F}":"\u0277","\u2374":"p",\uFF50:"p","\u{1D429}":"p","\u{1D45D}":"p","\u{1D491}":"p","\u{1D4C5}":"p","\u{1D4F9}":"p","\u{1D52D}":"p","\u{1D561}":"p","\u{1D595}":"p","\u{1D5C9}":"p","\u{1D5FD}":"p","\u{1D631}":"p","\u{1D665}":"p","\u{1D699}":"p",\u03C1:"p",\u03F1:"p","\u{1D6D2}":"p","\u{1D6E0}":"p","\u{1D70C}":"p","\u{1D71A}":"p","\u{1D746}":"p","\u{1D754}":"p","\u{1D780}":"p","\u{1D78E}":"p","\u{1D7BA}":"p","\u{1D7C8}":"p","\u2CA3":"p",\u0440:"p",\uFF30:"P",\u2119:"P","\u{1D40F}":"P","\u{1D443}":"P","\u{1D477}":"P","\u{1D4AB}":"P","\u{1D4DF}":"P","\u{1D513}":"P","\u{1D57B}":"P","\u{1D5AF}":"P","\u{1D5E3}":"P","\u{1D617}":"P","\u{1D64B}":"P","\u{1D67F}":"P",\u03A1:"P","\u{1D6B8}":"P","\u{1D6F2}":"P","\u{1D72C}":"P","\u{1D766}":"P","\u{1D7A0}":"P","\u2CA2":"P",\u0420:"P",\u13E2:"P",\u146D:"P","\uA4D1":"P","\u{10295}":"P",\u01A5:"p\u0314","\u1D7D":"p\u0335",\u1477:"p\xB7",\u1486:"P'","\u1D29":"\u1D18","\uABB2":"\u1D18",\u03C6:"\u0278",\u03D5:"\u0278","\u{1D6D7}":"\u0278","\u{1D6DF}":"\u0278","\u{1D711}":"\u0278","\u{1D719}":"\u0278","\u{1D74B}":"\u0278","\u{1D753}":"\u0278","\u{1D785}":"\u0278","\u{1D78D}":"\u0278","\u{1D7BF}":"\u0278","\u{1D7C7}":"\u0278","\u2CAB":"\u0278",\u0444:"\u0278","\u{1D42A}":"q","\u{1D45E}":"q","\u{1D492}":"q","\u{1D4C6}":"q","\u{1D4FA}":"q","\u{1D52E}":"q","\u{1D562}":"q","\u{1D596}":"q","\u{1D5CA}":"q","\u{1D5FE}":"q","\u{1D632}":"q","\u{1D666}":"q","\u{1D69A}":"q","\u051B":"q",\u0563:"q",\u0566:"q",\u211A:"Q","\u{1D410}":"Q","\u{1D444}":"Q","\u{1D478}":"Q","\u{1D4AC}":"Q","\u{1D4E0}":"Q","\u{1D514}":"Q","\u{1D57C}":"Q","\u{1D5B0}":"Q","\u{1D5E4}":"Q","\u{1D618}":"Q","\u{1D64C}":"Q","\u{1D680}":"Q","\u2D55":"Q",\u02A0:"q\u0314","\u{1F700}":"QE","\u1D90":"\u024B","\u1D0B":"\u0138",\u03BA:"\u0138",\u03F0:"\u0138","\u{1D6CB}":"\u0138","\u{1D6DE}":"\u0138","\u{1D705}":"\u0138","\u{1D718}":"\u0138","\u{1D73F}":"\u0138","\u{1D752}":"\u0138","\u{1D779}":"\u0138","\u{1D78C}":"\u0138","\u{1D7B3}":"\u0138","\u{1D7C6}":"\u0138","\u2C95":"\u0138",\u043A:"\u0138","\uABB6":"\u0138",\u049B:"\u0138\u0329",\u049F:"\u0138\u0335","\u{1D42B}":"r","\u{1D45F}":"r","\u{1D493}":"r","\u{1D4C7}":"r","\u{1D4FB}":"r","\u{1D52F}":"r","\u{1D563}":"r","\u{1D597}":"r","\u{1D5CB}":"r","\u{1D5FF}":"r","\u{1D633}":"r","\u{1D667}":"r","\u{1D69B}":"r","\uAB47":"r","\uAB48":"r","\u1D26":"r","\u2C85":"r",\u0433:"r","\uAB81":"r","\u{1D216}":"R",\u211B:"R",\u211C:"R",\u211D:"R","\u{1D411}":"R","\u{1D445}":"R","\u{1D479}":"R","\u{1D4E1}":"R","\u{1D57D}":"R","\u{1D5B1}":"R","\u{1D5E5}":"R","\u{1D619}":"R","\u{1D64D}":"R","\u{1D681}":"R",\u01A6:"R",\u13A1:"R",\u13D2:"R","\u{104B4}":"R",\u1587:"R","\uA4E3":"R","\u{16F35}":"R",\u027D:"r\u0328",\u027C:"r\u0329","\u024D":"r\u0335",\u0493:"r\u0335","\u1D72":"r\u0334",\u0491:"r'","\u{118E3}":"rn",m:Zb,"\u217F":"rn","\u{1D426}":"rn","\u{1D45A}":"rn","\u{1D48E}":"rn","\u{1D4C2}":"rn","\u{1D4F6}":"rn","\u{1D52A}":"rn","\u{1D55E}":"rn","\u{1D592}":"rn","\u{1D5C6}":"rn","\u{1D5FA}":"rn","\u{1D62E}":"rn","\u{1D662}":"rn","\u{1D696}":"rn","\u{11700}":"rn","\u20A5":"rn\u0338",\u0271:"rn\u0326","\u1D6F":"rn\u0334","\u20A8":"Rs","\uAB71":"\u0280","\uABA2":"\u0280",\u044F:"\u1D19","\u1D73":"\u027E\u0334","\u2129":"\u027F",\uFF53:"s","\u{1D42C}":"s","\u{1D460}":"s","\u{1D494}":"s","\u{1D4C8}":"s","\u{1D4FC}":"s","\u{1D530}":"s","\u{1D564}":"s","\u{1D598}":"s","\u{1D5CC}":"s","\u{1D600}":"s","\u{1D634}":"s","\u{1D668}":"s","\u{1D69C}":"s","\uA731":"s",\u01BD:"s",\u0455:"s","\uABAA":"s","\u{118C1}":"s","\u{10448}":"s",\uFF33:"S","\u{1D412}":"S","\u{1D446}":"S","\u{1D47A}":"S","\u{1D4AE}":"S","\u{1D4E2}":"S","\u{1D516}":"S","\u{1D54A}":"S","\u{1D57E}":"S","\u{1D5B2}":"S","\u{1D5E6}":"S","\u{1D61A}":"S","\u{1D64E}":"S","\u{1D682}":"S",\u0405:"S",\u054F:"S",\u13D5:"S",\u13DA:"S","\uA4E2":"S","\u{16F3A}":"S","\u{10296}":"S","\u{10420}":"S",\u0282:"s\u0328","\u1D74":"s\u0334","\uA7B5":"\xDF",\u03B2:"\xDF",\u03D0:"\xDF","\u{1D6C3}":"\xDF","\u{1D6FD}":"\xDF","\u{1D737}":"\xDF","\u{1D771}":"\xDF","\u{1D7AB}":"\xDF",\u13F0:"\xDF","\u{1F75C}":"sss",\uFB06:"st","\u222B":"\u0283","\uAB4D":"\u0283","\u2211":"\u01A9","\u2140":"\u01A9",\u03A3:"\u01A9","\u{1D6BA}":"\u01A9","\u{1D6F4}":"\u01A9","\u{1D72E}":"\u01A9","\u{1D768}":"\u01A9","\u{1D7A2}":"\u01A9","\u2D49":"\u01A9","\u222C":"\u0283\u0283","\u222D":"\u0283\u0283\u0283","\u2A0C":"\u0283\u0283\u0283\u0283","\u{1D42D}":"t","\u{1D461}":"t","\u{1D495}":"t","\u{1D4C9}":"t","\u{1D4FD}":"t","\u{1D531}":"t","\u{1D565}":"t","\u{1D599}":"t","\u{1D5CD}":"t","\u{1D601}":"t","\u{1D635}":"t","\u{1D669}":"t","\u{1D69D}":"t","\u22A4":"T","\u27D9":"T","\u{1F768}":"T",\uFF34:"T","\u{1D413}":"T","\u{1D447}":"T","\u{1D47B}":"T","\u{1D4AF}":"T","\u{1D4E3}":"T","\u{1D517}":"T","\u{1D54B}":"T","\u{1D57F}":"T","\u{1D5B3}":"T","\u{1D5E7}":"T","\u{1D61B}":"T","\u{1D64F}":"T","\u{1D683}":"T",\u03A4:"T","\u{1D6BB}":"T","\u{1D6F5}":"T","\u{1D72F}":"T","\u{1D769}":"T","\u{1D7A3}":"T","\u2CA6":"T",\u0422:"T",\u13A2:"T","\uA4D4":"T","\u{16F0A}":"T","\u{118BC}":"T","\u{10297}":"T","\u{102B1}":"T","\u{10315}":"T",\u01AD:"t\u0314","\u2361":"T\u0308","\u023E":"T\u0338",\u021A:"\u0162",\u01AE:"T\u0328",\u04AC:"T\u0329","\u20AE":"T\u20EB",\u0167:"t\u0335",\u0166:"T\u0335","\u1D75":"t\u0334",\u10A0:"\uA786","\uA728":"T3",\u02A8:"t\u0255","\u2121":"TEL","\uA777":"tf",\u02A6:"ts",\u02A7:"t\u0283","\uA729":"t\u021D",\u03C4:"\u1D1B","\u{1D6D5}":"\u1D1B","\u{1D70F}":"\u1D1B","\u{1D749}":"\u1D1B","\u{1D783}":"\u1D1B","\u{1D7BD}":"\u1D1B",\u0442:"\u1D1B","\uAB72":"\u1D1B",\u04AD:"\u1D1B\u0329",\u0163:"\u01AB",\u021B:"\u01AB",\u13BF:"\u01AB","\u{1D42E}":"u","\u{1D462}":"u","\u{1D496}":"u","\u{1D4CA}":"u","\u{1D4FE}":"u","\u{1D532}":"u","\u{1D566}":"u","\u{1D59A}":"u","\u{1D5CE}":"u","\u{1D602}":"u","\u{1D636}":"u","\u{1D66A}":"u","\u{1D69E}":"u","\uA79F":"u","\u1D1C":"u","\uAB4E":"u","\uAB52":"u",\u028B:"u",\u03C5:"u","\u{1D6D6}":"u","\u{1D710}":"u","\u{1D74A}":"u","\u{1D784}":"u","\u{1D7BE}":"u",\u057D:"u","\u{104F6}":"u","\u{118D8}":"u","\u222A":"U","\u22C3":"U","\u{1D414}":"U","\u{1D448}":"U","\u{1D47C}":"U","\u{1D4B0}":"U","\u{1D4E4}":"U","\u{1D518}":"U","\u{1D54C}":"U","\u{1D580}":"U","\u{1D5B4}":"U","\u{1D5E8}":"U","\u{1D61C}":"U","\u{1D650}":"U","\u{1D684}":"U",\u054D:"U",\u1200:"U","\u{104CE}":"U",\u144C:"U","\uA4F4":"U","\u{16F42}":"U","\u{118B8}":"U",\u01D4:"\u016D",\u01D3:"\u016C","\u1D7E":"u\u0335","\uAB9C":"u\u0335","\u0244":"U\u0335",\u13CC:"U\u0335",\u1458:"U\xB7",\u1467:"U'","\u1D6B":"ue","\uAB63":"uo",\u1E43:"\uAB51",\u057A:"\u0270",\u1223:"\u0270","\u2127":"\u01B1",\u162E:"\u01B1",\u1634:"\u01B1","\u1D7F":"\u028A\u0335","\u2228":"v","\u22C1":"v",\uFF56:"v","\u2174":"v","\u{1D42F}":"v","\u{1D463}":"v","\u{1D497}":"v","\u{1D4CB}":"v","\u{1D4FF}":"v","\u{1D533}":"v","\u{1D567}":"v","\u{1D59B}":"v","\u{1D5CF}":"v","\u{1D603}":"v","\u{1D637}":"v","\u{1D66B}":"v","\u{1D69F}":"v","\u1D20":"v",\u03BD:"v","\u{1D6CE}":"v","\u{1D708}":"v","\u{1D742}":"v","\u{1D77C}":"v","\u{1D7B6}":"v",\u0475:"v",\u05D8:"v","\u{11706}":"v","\uABA9":"v","\u{118C0}":"v","\u{1D20D}":"V","\u0667":"V","\u06F7":"V","\u2164":"V","\u{1D415}":"V","\u{1D449}":"V","\u{1D47D}":"V","\u{1D4B1}":"V","\u{1D4E5}":"V","\u{1D519}":"V","\u{1D54D}":"V","\u{1D581}":"V","\u{1D5B5}":"V","\u{1D5E9}":"V","\u{1D61D}":"V","\u{1D651}":"V","\u{1D685}":"V",\u0474:"V","\u2D38":"V",\u13D9:"V",\u142F:"V","\uA6DF":"V","\uA4E6":"V","\u{16F08}":"V","\u{118A0}":"V","\u{1051D}":"V","\u{10197}":"V\u0335",\u143B:"V\xB7","\u{1F76C}":"VB","\u2175":"vi","\u2176":"vii","\u2177":"viii","\u2165":"Vl","\u2166":"Vll","\u2167":"Vlll","\u{1F708}":"V\u1DE4","\u1D27":"\u028C","\u{104D8}":"\u028C","\u0668":"\u0245","\u06F8":"\u0245",\u039B:"\u0245","\u{1D6B2}":"\u0245","\u{1D6EC}":"\u0245","\u{1D726}":"\u0245","\u{1D760}":"\u0245","\u{1D79A}":"\u0245",\u041B:"\u0245","\u2D37":"\u0245","\u{104B0}":"\u0245",\u1431:"\u0245","\uA6CE":"\u0245","\uA4E5":"\u0245","\u{16F3D}":"\u0245","\u{1028D}":"\u0245","\u04C5":"\u0245\u0326",\u143D:"\u0245\xB7",\u026F:"w","\u{1D430}":"w","\u{1D464}":"w","\u{1D498}":"w","\u{1D4CC}":"w","\u{1D500}":"w","\u{1D534}":"w","\u{1D568}":"w","\u{1D59C}":"w","\u{1D5D0}":"w","\u{1D604}":"w","\u{1D638}":"w","\u{1D66C}":"w","\u{1D6A0}":"w","\u1D21":"w",\u0461:"w","\u051D":"w",\u0561:"w","\u{1170A}":"w","\u{1170E}":"w","\u{1170F}":"w","\uAB83":"w","\u{118EF}":"W","\u{118E6}":"W","\u{1D416}":"W","\u{1D44A}":"W","\u{1D47E}":"W","\u{1D4B2}":"W","\u{1D4E6}":"W","\u{1D51A}":"W","\u{1D54E}":"W","\u{1D582}":"W","\u{1D5B6}":"W","\u{1D5EA}":"W","\u{1D61E}":"W","\u{1D652}":"W","\u{1D686}":"W","\u051C":"W",\u13B3:"W",\u13D4:"W","\uA4EA":"W",\u047D:"w\u0486\u0487","\u{114C5}":"w\u0307","\u20A9":"W\u0335","\uA761":"w\u0326","\u1D0D":"\u028D",\u043C:"\u028D","\uAB87":"\u028D","\u04CE":"\u028D\u0326","\u166E":"x","\xD7":"x","\u292B":"x","\u292C":"x","\u2A2F":"x",\uFF58:"x","\u2179":"x","\u{1D431}":"x","\u{1D465}":"x","\u{1D499}":"x","\u{1D4CD}":"x","\u{1D501}":"x","\u{1D535}":"x","\u{1D569}":"x","\u{1D59D}":"x","\u{1D5D1}":"x","\u{1D605}":"x","\u{1D639}":"x","\u{1D66D}":"x","\u{1D6A1}":"x",\u0445:"x",\u1541:"x",\u157D:"x","\u2DEF":"\u036F","\u166D":"X","\u2573":"X","\u{10322}":"X","\u{118EC}":"X",\uFF38:"X","\u2169":"X","\u{1D417}":"X","\u{1D44B}":"X","\u{1D47F}":"X","\u{1D4B3}":"X","\u{1D4E7}":"X","\u{1D51B}":"X","\u{1D54F}":"X","\u{1D583}":"X","\u{1D5B7}":"X","\u{1D5EB}":"X","\u{1D61F}":"X","\u{1D653}":"X","\u{1D687}":"X","\uA7B3":"X",\u03A7:"X","\u{1D6BE}":"X","\u{1D6F8}":"X","\u{1D732}":"X","\u{1D76C}":"X","\u{1D7A6}":"X","\u2CAC":"X",\u0425:"X","\u2D5D":"X",\u16B7:"X","\uA4EB":"X","\u{10290}":"X","\u{102B4}":"X","\u{10317}":"X","\u{10527}":"X","\u2A30":"x\u0307",\u04B2:"X\u0329","\u{10196}":"X\u0335","\u217A":"xi","\u217B":"xii","\u216A":"Xl","\u216B":"Xll",\u0263:"y","\u1D8C":"y",\uFF59:"y","\u{1D432}":"y","\u{1D466}":"y","\u{1D49A}":"y","\u{1D4CE}":"y","\u{1D502}":"y","\u{1D536}":"y","\u{1D56A}":"y","\u{1D59E}":"y","\u{1D5D2}":"y","\u{1D606}":"y","\u{1D63A}":"y","\u{1D66E}":"y","\u{1D6A2}":"y",\u028F:"y","\u1EFF":"y","\uAB5A":"y",\u03B3:"y","\u213D":"y","\u{1D6C4}":"y","\u{1D6FE}":"y","\u{1D738}":"y","\u{1D772}":"y","\u{1D7AC}":"y",\u0443:"y",\u04AF:"y",\u10E7:"y","\u{118DC}":"y",\uFF39:"Y","\u{1D418}":"Y","\u{1D44C}":"Y","\u{1D480}":"Y","\u{1D4B4}":"Y","\u{1D4E8}":"Y","\u{1D51C}":"Y","\u{1D550}":"Y","\u{1D584}":"Y","\u{1D5B8}":"Y","\u{1D5EC}":"Y","\u{1D620}":"Y","\u{1D654}":"Y","\u{1D688}":"Y",\u03A5:"Y",\u03D2:"Y","\u{1D6BC}":"Y","\u{1D6F6}":"Y","\u{1D730}":"Y","\u{1D76A}":"Y","\u{1D7A4}":"Y","\u2CA8":"Y",\u0423:"Y",\u04AE:"Y",\u13A9:"Y",\u13BD:"Y","\uA4EC":"Y","\u{16F43}":"Y","\u{118A4}":"Y","\u{102B2}":"Y",\u01B4:"y\u0314","\u024F":"y\u0335",\u04B1:"y\u0335","\xA5":"Y\u0335","\u024E":"Y\u0335",\u04B0:"Y\u0335",\u0292:"\u021D","\uA76B":"\u021D","\u2CCD":"\u021D",\u04E1:"\u021D",\u10F3:"\u021D","\u{1D433}":"z","\u{1D467}":"z","\u{1D49B}":"z","\u{1D4CF}":"z","\u{1D503}":"z","\u{1D537}":"z","\u{1D56B}":"z","\u{1D59F}":"z","\u{1D5D3}":"z","\u{1D607}":"z","\u{1D63B}":"z","\u{1D66F}":"z","\u{1D6A3}":"z","\u1D22":"z","\uAB93":"z","\u{118C4}":"z","\u{102F5}":"Z","\u{118E5}":"Z",\uFF3A:"Z",\u2124:"Z",\u2128:"Z","\u{1D419}":"Z","\u{1D44D}":"Z","\u{1D481}":"Z","\u{1D4B5}":"Z","\u{1D4E9}":"Z","\u{1D585}":"Z","\u{1D5B9}":"Z","\u{1D5ED}":"Z","\u{1D621}":"Z","\u{1D655}":"Z","\u{1D689}":"Z",\u0396:"Z","\u{1D6AD}":"Z","\u{1D6E7}":"Z","\u{1D721}":"Z","\u{1D75B}":"Z","\u{1D795}":"Z",\u13C3:"Z","\uA4DC":"Z","\u{118A9}":"Z",\u0290:"z\u0328",\u01B6:"z\u0335",\u01B5:"Z\u0335",\u0225:"z\u0326",\u0224:"Z\u0326","\u1D76":"z\u0334",\u01BF:"\xFE","\u03F8":"\xFE","\u03F7":"\xDE","\u{104C4}":"\xDE","\u2079":"\uA770","\u1D24":"\u01A8",\u03E9:"\u01A8","\uA645":"\u01A8",\u044C:"\u0185","\uAB9F":"\u0185",\u044B:"\u0185i","\uAB7E":"\u0242",\u02E4:"\u02C1","\uA6CD":"\u02A1","\u2299":"\u0298","\u2609":"\u0298","\u2A00":"\u0298","\uA668":"\u0298","\u2D59":"\u0298","\u{104C3}":"\u0298","\u213E":"\u0393","\u{1D6AA}":"\u0393","\u{1D6E4}":"\u0393","\u{1D71E}":"\u0393","\u{1D758}":"\u0393","\u{1D792}":"\u0393","\u2C84":"\u0393",\u0413:"\u0393",\u13B1:"\u0393",\u14A5:"\u0393","\u{16F07}":"\u0393",\u0492:"\u0393\u0335",\u14AF:"\u0393\xB7",\u0490:"\u0393'","\u2206":"\u0394","\u25B3":"\u0394","\u{1F702}":"\u0394","\u{1D6AB}":"\u0394","\u{1D6E5}":"\u0394","\u{1D71F}":"\u0394","\u{1D759}":"\u0394","\u{1D793}":"\u0394","\u2C86":"\u0394","\u2D60":"\u0394",\u1403:"\u0394","\u{16F1A}":"\u0394","\u{10285}":"\u0394","\u{102A3}":"\u0394","\u2359":"\u0394\u0332",\u140F:"\u0394\xB7",\u142C:"\u0394\u1420","\u{1D7CB}":"\u03DD","\u{1D6C7}":"\u03B6","\u{1D701}":"\u03B6","\u{1D73B}":"\u03B6","\u{1D775}":"\u03B6","\u{1D7AF}":"\u03B6","\u2CE4":"\u03D7","\u{1D6CC}":"\u03BB","\u{1D706}":"\u03BB","\u{1D740}":"\u03BB","\u{1D77A}":"\u03BB","\u{1D7B4}":"\u03BB","\u2C96":"\u03BB","\u{104DB}":"\u03BB",\u00B5:"\u03BC","\u{1D6CD}":"\u03BC","\u{1D707}":"\u03BC","\u{1D741}":"\u03BC","\u{1D77B}":"\u03BC","\u{1D7B5}":"\u03BC","\u{1D6CF}":"\u03BE","\u{1D709}":"\u03BE","\u{1D743}":"\u03BE","\u{1D77D}":"\u03BE","\u{1D7B7}":"\u03BE","\u{1D6B5}":"\u039E","\u{1D6EF}":"\u039E","\u{1D729}":"\u039E","\u{1D763}":"\u039E","\u{1D79D}":"\u039E",\u03D6:"\u03C0","\u213C":"\u03C0","\u{1D6D1}":"\u03C0","\u{1D6E1}":"\u03C0","\u{1D70B}":"\u03C0","\u{1D71B}":"\u03C0","\u{1D745}":"\u03C0","\u{1D755}":"\u03C0","\u{1D77F}":"\u03C0","\u{1D78F}":"\u03C0","\u{1D7B9}":"\u03C0","\u{1D7C9}":"\u03C0","\u1D28":"\u03C0",\u043F:"\u03C0","\u220F":"\u03A0","\u213F":"\u03A0","\u{1D6B7}":"\u03A0","\u{1D6F1}":"\u03A0","\u{1D72B}":"\u03A0","\u{1D765}":"\u03A0","\u{1D79F}":"\u03A0","\u2CA0":"\u03A0",\u041F:"\u03A0","\uA6DB":"\u03A0","\u{102AD}":"\u03D8","\u{10312}":"\u03D8",\u03DB:"\u03C2","\u{1D6D3}":"\u03C2","\u{1D70D}":"\u03C2","\u{1D747}":"\u03C2","\u{1D781}":"\u03C2","\u{1D7BB}":"\u03C2","\u{1D6BD}":"\u03A6","\u{1D6F7}":"\u03A6","\u{1D731}":"\u03A6","\u{1D76B}":"\u03A6","\u{1D7A5}":"\u03A6","\u2CAA":"\u03A6",\u0424:"\u03A6",\u0553:"\u03A6",\u1240:"\u03A6","\u16F0":"\u03A6","\u{102B3}":"\u03A6","\uAB53":"\u03C7","\uAB55":"\u03C7","\u{1D6D8}":"\u03C7","\u{1D712}":"\u03C7","\u{1D74C}":"\u03C7","\u{1D786}":"\u03C7","\u{1D7C0}":"\u03C7","\u2CAD":"\u03C7","\u{1D6D9}":"\u03C8","\u{1D713}":"\u03C8","\u{1D74D}":"\u03C8","\u{1D787}":"\u03C8","\u{1D7C1}":"\u03C8",\u0471:"\u03C8","\u{104F9}":"\u03C8","\u{1D6BF}":"\u03A8","\u{1D6F9}":"\u03A8","\u{1D733}":"\u03A8","\u{1D76D}":"\u03A8","\u{1D7A7}":"\u03A8","\u2CAE":"\u03A8",\u0470:"\u03A8","\u{104D1}":"\u03A8",\u16D8:"\u03A8","\u{102B5}":"\u03A8","\u2375":"\u03C9","\uA7B7":"\u03C9","\u{1D6DA}":"\u03C9","\u{1D714}":"\u03C9","\u{1D74E}":"\u03C9","\u{1D788}":"\u03C9","\u{1D7C2}":"\u03C9","\u2CB1":"\u03C9","\uA64D":"\u03C9",\u2126:"\u03A9","\u{1D6C0}":"\u03A9","\u{1D6FA}":"\u03A9","\u{1D734}":"\u03A9","\u{1D76E}":"\u03A9","\u{1D7A8}":"\u03A9",\u162F:"\u03A9",\u1635:"\u03A9","\u{102B6}":"\u03A9","\u2379":"\u03C9\u0332",\u1F7D:"\u1FF4","\u2630":"\u2CB6","\u2CDC":"\u03EC",\u0497:"\u0436\u0329",\u0496:"\u0416\u0329","\u{1D20B}":"\u0418","\u0376":"\u0418","\uA6A1":"\u0418","\u{10425}":"\u0418",\u0419:"\u040D","\u048A":"\u040D\u0326",\u045D:"\u0439","\u048B":"\u0439\u0326","\u{104BC}":"\u04C3","\u1D2B":"\u043B","\u04C6":"\u043B\u0326","\uAB60":"\u0459","\u{104EB}":"\uA669","\u1DEE":"\u2DEC","\u{104CD}":"\u040B","\u{1D202}":"\u04FE","\u{1D222}":"\u0460",\u13C7:"\u0460",\u15EF:"\u0460",\u047C:"\u0460\u0486\u0487","\u18ED":"\u0460\xB7","\uA7B6":"\uA64C",\u04CC:"\u04B7",\u04CB:"\u04B6",\u04BE:"\u04BC\u0328","\u2CBD":"\u0448","\u2CBC":"\u0428","\uA650":"\u042Al","\u2108":"\u042D","\u{1F701}":"\uA658","\u{16F1C}":"\uA658","\uA992":"\u2C3F",\u0587:"\u0565\u0582",\u1294:"\u0571",\uFB14:"\u0574\u0565",\uFB15:"\u0574\u056B",\uFB17:"\u0574\u056D",\uFB13:"\u0574\u0576","\u2229":"\u0548","\u22C2":"\u0548","\u{1D245}":"\u0548",\u1260:"\u0548",\u144E:"\u0548","\uA4F5":"\u0548",\u145A:"\u0548\xB7",\u1468:"\u0548'",\uFB16:"\u057E\u0576","\u20BD":"\u0554","\u02D3":"\u0559",\u02BF:"\u0559",\u2135:"\u05D0",\uFB21:"\u05D0",\uFB2F:"\uFB2E",\uFB30:"\uFB2E",\uFB4F:"\u05D0\u05DC",\u2136:"\u05D1",\u2137:"\u05D2",\u2138:"\u05D3",\uFB22:"\u05D3",\uFB23:"\u05D4",\uFB39:"\uFB1D",\uFB24:"\u05DB",\uFB25:"\u05DC",\uFB26:"\u05DD",\uFB20:"\u05E2",\uFB27:"\u05E8",\uFB2B:"\uFB2A",\uFB49:"\uFB2A",\uFB2D:"\uFB2C",\uFB28:"\u05EA",\uFE80:"\u0621","\u06FD":"\u0621\u0348",\uFE82:"\u0622",\uFE81:"\u0622",\uFB51:"\u0671",\uFB50:"\u0671","\u{1EE01}":"\u0628","\u{1EE21}":"\u0628","\u{1EE61}":"\u0628","\u{1EE81}":"\u0628","\u{1EEA1}":"\u0628",\uFE91:"\u0628",\uFE92:"\u0628",\uFE90:"\u0628",\uFE8F:"\u0628","\u0751":"\u0628\u06DB","\u08B6":"\u0628\u06E2","\u08A1":"\u0628\u0654",\uFCA0:"\u0628o",\uFCE2:"\u0628o",\uFC9C:"\u0628\u062C",\uFC05:"\u0628\u062C",\uFC9D:"\u0628\u062D",\uFC06:"\u0628\u062D",\uFDC2:"\u0628\u062D\u0649",\uFC9E:"\u0628\u062E",\uFC07:"\u0628\u062E",\uFCD2:"\u0628\u062E",\uFC4B:"\u0628\u062E",\uFD9E:"\u0628\u062E\u0649",\uFC6A:"\u0628\u0631",\uFC6B:"\u0628\u0632",\uFC9F:"\u0628\u0645",\uFCE1:"\u0628\u0645",\uFC6C:"\u0628\u0645",\uFC08:"\u0628\u0645",\uFC6D:"\u0628\u0646",\uFC6E:"\u0628\u0649",\uFC09:"\u0628\u0649",\uFC6F:"\u0628\u0649",\uFC0A:"\u0628\u0649",\uFB54:"\u067B",\uFB55:"\u067B",\uFB53:"\u067B",\uFB52:"\u067B",\u06D0:"\u067B",\uFBE6:"\u067B",\uFBE7:"\u067B",\uFBE5:"\u067B",\uFBE4:"\u067B",\uFB5C:"\u0680",\uFB5D:"\u0680",\uFB5B:"\u0680",\uFB5A:"\u0680","\u08A9":"\u0754","\u0767":"\u0754","\u2365":"\u0629",\u00F6:"\u0629",\uFE94:"\u0629",\uFE93:"\u0629",\u06C3:"\u0629","\u{1EE15}":"\u062A","\u{1EE35}":"\u062A","\u{1EE75}":"\u062A","\u{1EE95}":"\u062A","\u{1EEB5}":"\u062A",\uFE97:"\u062A",\uFE98:"\u062A",\uFE96:"\u062A",\uFE95:"\u062A",\uFCA5:"\u062Ao",\uFCE4:"\u062Ao",\uFCA1:"\u062A\u062C",\uFC0B:"\u062A\u062C",\uFD50:"\u062A\u062C\u0645",\uFDA0:"\u062A\u062C\u0649",\uFD9F:"\u062A\u062C\u0649",\uFCA2:"\u062A\u062D",\uFC0C:"\u062A\u062D",\uFD52:"\u062A\u062D\u062C",\uFD51:"\u062A\u062D\u062C",\uFD53:"\u062A\u062D\u0645",\uFCA3:"\u062A\u062E",\uFC0D:"\u062A\u062E",\uFD54:"\u062A\u062E\u0645",\uFDA2:"\u062A\u062E\u0649",\uFDA1:"\u062A\u062E\u0649",\uFC70:"\u062A\u0631",\uFC71:"\u062A\u0632",\uFCA4:"\u062A\u0645",\uFCE3:"\u062A\u0645",\uFC72:"\u062A\u0645",\uFC0E:"\u062A\u0645",\uFD55:"\u062A\u0645\u062C",\uFD56:"\u062A\u0645\u062D",\uFD57:"\u062A\u0645\u062E",\uFDA4:"\u062A\u0645\u0649",\uFDA3:"\u062A\u0645\u0649",\uFC73:"\u062A\u0646",\uFC74:"\u062A\u0649",\uFC0F:"\u062A\u0649",\uFC75:"\u062A\u0649",\uFC10:"\u062A\u0649",\uFB60:"\u067A",\uFB61:"\u067A",\uFB5F:"\u067A",\uFB5E:"\u067A",\uFB64:"\u067F",\uFB65:"\u067F",\uFB63:"\u067F",\uFB62:"\u067F","\u{1EE02}":"\u062C","\u{1EE22}":"\u062C","\u{1EE42}":"\u062C","\u{1EE62}":"\u062C","\u{1EE82}":"\u062C","\u{1EEA2}":"\u062C",\uFE9F:"\u062C",\uFEA0:"\u062C",\uFE9E:"\u062C",\uFE9D:"\u062C",\uFCA7:"\u062C\u062D",\uFC15:"\u062C\u062D",\uFDA6:"\u062C\u062D\u0649",\uFDBE:"\u062C\u062D\u0649",\uFDFB:"\u062C\u0644 \u062C\u0644l\u0644o",\uFCA8:"\u062C\u0645",\uFC16:"\u062C\u0645",\uFD59:"\u062C\u0645\u062D",\uFD58:"\u062C\u0645\u062D",\uFDA7:"\u062C\u0645\u0649",\uFDA5:"\u062C\u0645\u0649",\uFD1D:"\u062C\u0649",\uFD01:"\u062C\u0649",\uFD1E:"\u062C\u0649",\uFD02:"\u062C\u0649",\uFB78:"\u0683",\uFB79:"\u0683",\uFB77:"\u0683",\uFB76:"\u0683",\uFB74:"\u0684",\uFB75:"\u0684",\uFB73:"\u0684",\uFB72:"\u0684",\uFB7C:"\u0686",\uFB7D:"\u0686",\uFB7B:"\u0686",\uFB7A:"\u0686",\uFB80:"\u0687",\uFB81:"\u0687",\uFB7F:"\u0687",\uFB7E:"\u0687","\u{1EE07}":"\u062D","\u{1EE27}":"\u062D","\u{1EE47}":"\u062D","\u{1EE67}":"\u062D","\u{1EE87}":"\u062D","\u{1EEA7}":"\u062D",\uFEA3:"\u062D",\uFEA4:"\u062D",\uFEA2:"\u062D",\uFEA1:"\u062D",\u0685:"\u062D\u06DB",\u0681:"\u062D\u0654","\u0772":"\u062D\u0654",\uFCA9:"\u062D\u062C",\uFC17:"\u062D\u062C",\uFDBF:"\u062D\u062C\u0649",\uFCAA:"\u062D\u0645",\uFC18:"\u062D\u0645",\uFD5B:"\u062D\u0645\u0649",\uFD5A:"\u062D\u0645\u0649",\uFD1B:"\u062D\u0649",\uFCFF:"\u062D\u0649",\uFD1C:"\u062D\u0649",\uFD00:"\u062D\u0649","\u{1EE17}":"\u062E","\u{1EE37}":"\u062E","\u{1EE57}":"\u062E","\u{1EE77}":"\u062E","\u{1EE97}":"\u062E","\u{1EEB7}":"\u062E",\uFEA7:"\u062E",\uFEA8:"\u062E",\uFEA6:"\u062E",\uFEA5:"\u062E",\uFCAB:"\u062E\u062C",\uFC19:"\u062E\u062C",\uFC1A:"\u062E\u062D",\uFCAC:"\u062E\u0645",\uFC1B:"\u062E\u0645",\uFD1F:"\u062E\u0649",\uFD03:"\u062E\u0649",\uFD20:"\u062E\u0649",\uFD04:"\u062E\u0649","\u{102E1}":"\u062F","\u{1EE03}":"\u062F","\u{1EE83}":"\u062F","\u{1EEA3}":"\u062F",\uFEAA:"\u062F",\uFEA9:"\u062F",\u0688:"\u062F\u0615",\uFB89:"\u062F\u0615",\uFB88:"\u062F\u0615",\u068E:"\u062F\u06DB",\uFB87:"\u062F\u06DB",\uFB86:"\u062F\u06DB","\u06EE":"\u062F\u0302","\u08AE":"\u062F\u0324\u0323","\u{1EE18}":"\u0630","\u{1EE98}":"\u0630","\u{1EEB8}":"\u0630",\uFEAC:"\u0630",\uFEAB:"\u0630",\uFC5B:"\u0630\u0670",\u068B:"\u068A\u0615",\uFB85:"\u068C",\uFB84:"\u068C",\uFB83:"\u068D",\uFB82:"\u068D","\u{1EE13}":"\u0631","\u{1EE93}":"\u0631","\u{1EEB3}":"\u0631",\uFEAE:"\u0631",\uFEAD:"\u0631",\u0691:"\u0631\u0615",\uFB8D:"\u0631\u0615",\uFB8C:"\u0631\u0615",\u0698:"\u0631\u06DB",\uFB8B:"\u0631\u06DB",\uFB8A:"\u0631\u06DB",\u0692:"\u0631\u0306","\u08B9":"\u0631\u0306\u0307","\u06EF":"\u0631\u0302","\u076C":"\u0631\u0654",\uFC5C:"\u0631\u0670",\uFDF6:"\u0631\u0633\u0648\u0644","\uFDFC":"\u0631\u0649l\u0644","\u{1EE06}":"\u0632","\u{1EE86}":"\u0632","\u{1EEA6}":"\u0632",\uFEB0:"\u0632",\uFEAF:"\u0632","\u08B2":"\u0632\u0302","\u0771":"\u0697\u0615","\u{1EE0E}":"\u0633","\u{1EE2E}":"\u0633","\u{1EE4E}":"\u0633","\u{1EE6E}":"\u0633","\u{1EE8E}":"\u0633","\u{1EEAE}":"\u0633",\uFEB3:"\u0633",\uFEB4:"\u0633",\uFEB2:"\u0633",\uFEB1:"\u0633",\u0634:"\u0633\u06DB","\u{1EE14}":"\u0633\u06DB","\u{1EE34}":"\u0633\u06DB","\u{1EE54}":"\u0633\u06DB","\u{1EE74}":"\u0633\u06DB","\u{1EE94}":"\u0633\u06DB","\u{1EEB4}":"\u0633\u06DB",\uFEB7:"\u0633\u06DB",\uFEB8:"\u0633\u06DB",\uFEB6:"\u0633\u06DB",\uFEB5:"\u0633\u06DB","\u077E":"\u0633\u0302",\uFD31:"\u0633o",\uFCE8:"\u0633o",\uFD32:"\u0633\u06DBo",\uFCEA:"\u0633\u06DBo",\uFCAD:"\u0633\u062C",\uFD34:"\u0633\u062C",\uFC1C:"\u0633\u062C",\uFD2D:"\u0633\u06DB\u062C",\uFD37:"\u0633\u06DB\u062C",\uFD25:"\u0633\u06DB\u062C",\uFD09:"\u0633\u06DB\u062C",\uFD5D:"\u0633\u062C\u062D",\uFD5E:"\u0633\u062C\u0649",\uFD69:"\u0633\u06DB\u062C\u0649",\uFCAE:"\u0633\u062D",\uFD35:"\u0633\u062D",\uFC1D:"\u0633\u062D",\uFD2E:"\u0633\u06DB\u062D",\uFD38:"\u0633\u06DB\u062D",\uFD26:"\u0633\u06DB\u062D",\uFD0A:"\u0633\u06DB\u062D",\uFD5C:"\u0633\u062D\u062C",\uFD68:"\u0633\u06DB\u062D\u0645",\uFD67:"\u0633\u06DB\u062D\u0645",\uFDAA:"\u0633\u06DB\u062D\u0649",\uFCAF:"\u0633\u062E",\uFD36:"\u0633\u062E",\uFC1E:"\u0633\u062E",\uFD2F:"\u0633\u06DB\u062E",\uFD39:"\u0633\u06DB\u062E",\uFD27:"\u0633\u06DB\u062E",\uFD0B:"\u0633\u06DB\u062E",\uFDA8:"\u0633\u062E\u0649",\uFDC6:"\u0633\u062E\u0649",\uFD2A:"\u0633\u0631",\uFD0E:"\u0633\u0631",\uFD29:"\u0633\u06DB\u0631",\uFD0D:"\u0633\u06DB\u0631",\uFCB0:"\u0633\u0645",\uFCE7:"\u0633\u0645",\uFC1F:"\u0633\u0645",\uFD30:"\u0633\u06DB\u0645",\uFCE9:"\u0633\u06DB\u0645",\uFD28:"\u0633\u06DB\u0645",\uFD0C:"\u0633\u06DB\u0645",\uFD61:"\u0633\u0645\u062C",\uFD60:"\u0633\u0645\u062D",\uFD5F:"\u0633\u0645\u062D",\uFD6B:"\u0633\u06DB\u0645\u062E",\uFD6A:"\u0633\u06DB\u0645\u062E",\uFD63:"\u0633\u0645\u0645",\uFD62:"\u0633\u0645\u0645",\uFD6D:"\u0633\u06DB\u0645\u0645",\uFD6C:"\u0633\u06DB\u0645\u0645",\uFD17:"\u0633\u0649",\uFCFB:"\u0633\u0649",\uFD18:"\u0633\u0649",\uFCFC:"\u0633\u0649",\uFD19:"\u0633\u06DB\u0649",\uFCFD:"\u0633\u06DB\u0649",\uFD1A:"\u0633\u06DB\u0649",\uFCFE:"\u0633\u06DB\u0649","\u{102F2}":"\u0635","\u{1EE11}":"\u0635","\u{1EE31}":"\u0635","\u{1EE51}":"\u0635","\u{1EE71}":"\u0635","\u{1EE91}":"\u0635","\u{1EEB1}":"\u0635",\uFEBB:"\u0635",\uFEBC:"\u0635",\uFEBA:"\u0635",\uFEB9:"\u0635",\u069E:"\u0635\u06DB","\u08AF":"\u0635\u0324\u0323",\uFCB1:"\u0635\u062D",\uFC20:"\u0635\u062D",\uFD65:"\u0635\u062D\u062D",\uFD64:"\u0635\u062D\u062D",\uFDA9:"\u0635\u062D\u0649",\uFCB2:"\u0635\u062E",\uFD2B:"\u0635\u0631",\uFD0F:"\u0635\u0631",\uFDF5:"\u0635\u0644\u0639\u0645",\uFDF9:"\u0635\u0644\u0649",\uFDF0:"\u0635\u0644\u0649",\uFDFA:"\u0635\u0644\u0649 l\u0644\u0644o \u0639\u0644\u0649o \u0648\u0633\u0644\u0645",\uFCB3:"\u0635\u0645",\uFC21:"\u0635\u0645",\uFDC5:"\u0635\u0645\u0645",\uFD66:"\u0635\u0645\u0645",\uFD21:"\u0635\u0649",\uFD05:"\u0635\u0649",\uFD22:"\u0635\u0649",\uFD06:"\u0635\u0649","\u{1EE19}":"\u0636","\u{1EE39}":"\u0636","\u{1EE59}":"\u0636","\u{1EE79}":"\u0636","\u{1EE99}":"\u0636","\u{1EEB9}":"\u0636",\uFEBF:"\u0636",\uFEC0:"\u0636",\uFEBE:"\u0636",\uFEBD:"\u0636",\uFCB4:"\u0636\u062C",\uFC22:"\u0636\u062C",\uFCB5:"\u0636\u062D",\uFC23:"\u0636\u062D",\uFD6E:"\u0636\u062D\u0649",\uFDAB:"\u0636\u062D\u0649",\uFCB6:"\u0636\u062E",\uFC24:"\u0636\u062E",\uFD70:"\u0636\u062E\u0645",\uFD6F:"\u0636\u062E\u0645",\uFD2C:"\u0636\u0631",\uFD10:"\u0636\u0631",\uFCB7:"\u0636\u0645",\uFC25:"\u0636\u0645",\uFD23:"\u0636\u0649",\uFD07:"\u0636\u0649",\uFD24:"\u0636\u0649",\uFD08:"\u0636\u0649","\u{102E8}":"\u0637","\u{1EE08}":"\u0637","\u{1EE68}":"\u0637","\u{1EE88}":"\u0637","\u{1EEA8}":"\u0637",\uFEC3:"\u0637",\uFEC4:"\u0637",\uFEC2:"\u0637",\uFEC1:"\u0637",\u069F:"\u0637\u06DB",\uFCB8:"\u0637\u062D",\uFC26:"\u0637\u062D",\uFD33:"\u0637\u0645",\uFD3A:"\u0637\u0645",\uFC27:"\u0637\u0645",\uFD72:"\u0637\u0645\u062D",\uFD71:"\u0637\u0645\u062D",\uFD73:"\u0637\u0645\u0645",\uFD74:"\u0637\u0645\u0649",\uFD11:"\u0637\u0649",\uFCF5:"\u0637\u0649",\uFD12:"\u0637\u0649",\uFCF6:"\u0637\u0649","\u{1EE1A}":"\u0638","\u{1EE7A}":"\u0638","\u{1EE9A}":"\u0638","\u{1EEBA}":"\u0638",\uFEC7:"\u0638",\uFEC8:"\u0638",\uFEC6:"\u0638",\uFEC5:"\u0638",\uFCB9:"\u0638\u0645",\uFD3B:"\u0638\u0645",\uFC28:"\u0638\u0645","\u060F":"\u0639","\u{1EE0F}":"\u0639","\u{1EE2F}":"\u0639","\u{1EE4F}":"\u0639","\u{1EE6F}":"\u0639","\u{1EE8F}":"\u0639","\u{1EEAF}":"\u0639",\uFECB:"\u0639",\uFECC:"\u0639",\uFECA:"\u0639",\uFEC9:"\u0639",\uFCBA:"\u0639\u062C",\uFC29:"\u0639\u062C",\uFDC4:"\u0639\u062C\u0645",\uFD75:"\u0639\u062C\u0645",\uFDF7:"\u0639\u0644\u0649o",\uFCBB:"\u0639\u0645",\uFC2A:"\u0639\u0645",\uFD77:"\u0639\u0645\u0645",\uFD76:"\u0639\u0645\u0645",\uFD78:"\u0639\u0645\u0649",\uFDB6:"\u0639\u0645\u0649",\uFD13:"\u0639\u0649",\uFCF7:"\u0639\u0649",\uFD14:"\u0639\u0649",\uFCF8:"\u0639\u0649","\u{1EE1B}":"\u063A","\u{1EE3B}":"\u063A","\u{1EE5B}":"\u063A","\u{1EE7B}":"\u063A","\u{1EE9B}":"\u063A","\u{1EEBB}":"\u063A",\uFECF:"\u063A",\uFED0:"\u063A",\uFECE:"\u063A",\uFECD:"\u063A",\uFCBC:"\u063A\u062C",\uFC2B:"\u063A\u062C",\uFCBD:"\u063A\u0645",\uFC2C:"\u063A\u0645",\uFD79:"\u063A\u0645\u0645",\uFD7B:"\u063A\u0645\u0649",\uFD7A:"\u063A\u0645\u0649",\uFD15:"\u063A\u0649",\uFCF9:"\u063A\u0649",\uFD16:"\u063A\u0649",\uFCFA:"\u063A\u0649","\u{1EE10}":"\u0641","\u{1EE30}":"\u0641","\u{1EE70}":"\u0641","\u{1EE90}":"\u0641","\u{1EEB0}":"\u0641",\uFED3:"\u0641",\uFED4:"\u0641",\uFED2:"\u0641",\uFED1:"\u0641",\u06A7:"\u0641",\uFCBE:"\u0641\u062C",\uFC2D:"\u0641\u062C",\uFCBF:"\u0641\u062D",\uFC2E:"\u0641\u062D",\uFCC0:"\u0641\u062E",\uFC2F:"\u0641\u062E",\uFD7D:"\u0641\u062E\u0645",\uFD7C:"\u0641\u062E\u0645",\uFCC1:"\u0641\u0645",\uFC30:"\u0641\u0645",\uFDC1:"\u0641\u0645\u0649",\uFC7C:"\u0641\u0649",\uFC31:"\u0641\u0649",\uFC7D:"\u0641\u0649",\uFC32:"\u0641\u0649","\u{1EE1E}":"\u06A1","\u{1EE7E}":"\u06A1","\u08BB":"\u06A1","\u066F":"\u06A1","\u{1EE1F}":"\u06A1","\u{1EE5F}":"\u06A1","\u08BC":"\u06A1",\u06A4:"\u06A1\u06DB",\uFB6C:"\u06A1\u06DB",\uFB6D:"\u06A1\u06DB",\uFB6B:"\u06A1\u06DB",\uFB6A:"\u06A1\u06DB",\u06A8:"\u06A1\u06DB","\u08A4":"\u06A2\u06DB",\uFB70:"\u06A6",\uFB71:"\u06A6",\uFB6F:"\u06A6",\uFB6E:"\u06A6","\u{1EE12}":"\u0642","\u{1EE32}":"\u0642","\u{1EE52}":"\u0642","\u{1EE72}":"\u0642","\u{1EE92}":"\u0642","\u{1EEB2}":"\u0642",\uFED7:"\u0642",\uFED8:"\u0642",\uFED6:"\u0642",\uFED5:"\u0642",\uFCC2:"\u0642\u062D",\uFC33:"\u0642\u062D",\uFDF1:"\u0642\u0644\u0649",\uFCC3:"\u0642\u0645",\uFC34:"\u0642\u0645",\uFDB4:"\u0642\u0645\u062D",\uFD7E:"\u0642\u0645\u062D",\uFD7F:"\u0642\u0645\u0645",\uFDB2:"\u0642\u0645\u0649",\uFC7E:"\u0642\u0649",\uFC35:"\u0642\u0649",\uFC7F:"\u0642\u0649",\uFC36:"\u0642\u0649","\u{1EE0A}":"\u0643","\u{1EE2A}":"\u0643","\u{1EE6A}":"\u0643",\uFEDB:"\u0643",\uFEDC:"\u0643",\uFEDA:"\u0643",\uFED9:"\u0643",\u06A9:"\u0643",\uFB90:"\u0643",\uFB91:"\u0643",\uFB8F:"\u0643",\uFB8E:"\u0643",\u06AA:"\u0643",\u06AD:"\u0643\u06DB",\uFBD5:"\u0643\u06DB",\uFBD6:"\u0643\u06DB",\uFBD4:"\u0643\u06DB",\uFBD3:"\u0643\u06DB","\u0763":"\u0643\u06DB",\uFC80:"\u0643l",\uFC37:"\u0643l",\uFCC4:"\u0643\u062C",\uFC38:"\u0643\u062C",\uFCC5:"\u0643\u062D",\uFC39:"\u0643\u062D",\uFCC6:"\u0643\u062E",\uFC3A:"\u0643\u062E",\uFCC7:"\u0643\u0644",\uFCEB:"\u0643\u0644",\uFC81:"\u0643\u0644",\uFC3B:"\u0643\u0644",\uFCC8:"\u0643\u0645",\uFCEC:"\u0643\u0645",\uFC82:"\u0643\u0645",\uFC3C:"\u0643\u0645",\uFDC3:"\u0643\u0645\u0645",\uFDBB:"\u0643\u0645\u0645",\uFDB7:"\u0643\u0645\u0649",\uFC83:"\u0643\u0649",\uFC3D:"\u0643\u0649",\uFC84:"\u0643\u0649",\uFC3E:"\u0643\u0649","\u0762":"\u06AC",\uFB94:"\u06AF",\uFB95:"\u06AF",\uFB93:"\u06AF",\uFB92:"\u06AF","\u08B0":"\u06AF",\u06B4:"\u06AF\u06DB",\uFB9C:"\u06B1",\uFB9D:"\u06B1",\uFB9B:"\u06B1",\uFB9A:"\u06B1",\uFB98:"\u06B3",\uFB99:"\u06B3",\uFB97:"\u06B3",\uFB96:"\u06B3","\u{1EE0B}":"\u0644","\u{1EE2B}":"\u0644","\u{1EE4B}":"\u0644","\u{1EE8B}":"\u0644","\u{1EEAB}":"\u0644",\uFEDF:"\u0644",\uFEE0:"\u0644",\uFEDE:"\u0644",\uFEDD:"\u0644",\u06B7:"\u0644\u06DB",\u06B5:"\u0644\u0306",\uFEFC:"\u0644l",\uFEFB:"\u0644l",\uFEFA:"\u0644l\u0655",\uFEF9:"\u0644l\u0655",\uFEF8:"\u0644l\u0674",\uFEF7:"\u0644l\u0674",\uFCCD:"\u0644o",\uFEF6:"\u0644\u0622",\uFEF5:"\u0644\u0622",\uFCC9:"\u0644\u062C",\uFC3F:"\u0644\u062C",\uFD83:"\u0644\u062C\u062C",\uFD84:"\u0644\u062C\u062C",\uFDBA:"\u0644\u062C\u0645",\uFDBC:"\u0644\u062C\u0645",\uFDAC:"\u0644\u062C\u0649",\uFCCA:"\u0644\u062D",\uFC40:"\u0644\u062D",\uFDB5:"\u0644\u062D\u0645",\uFD80:"\u0644\u062D\u0645",\uFD82:"\u0644\u062D\u0649",\uFD81:"\u0644\u062D\u0649",\uFCCB:"\u0644\u062E",\uFC41:"\u0644\u062E",\uFD86:"\u0644\u062E\u0645",\uFD85:"\u0644\u062E\u0645",\uFCCC:"\u0644\u0645",\uFCED:"\u0644\u0645",\uFC85:"\u0644\u0645",\uFC42:"\u0644\u0645",\uFD88:"\u0644\u0645\u062D",\uFD87:"\u0644\u0645\u062D",\uFDAD:"\u0644\u0645\u0649",\uFC86:"\u0644\u0649",\uFC43:"\u0644\u0649",\uFC87:"\u0644\u0649",\uFC44:"\u0644\u0649","\u{1EE0C}":"\u0645","\u{1EE2C}":"\u0645","\u{1EE6C}":"\u0645","\u{1EE8C}":"\u0645","\u{1EEAC}":"\u0645",\uFEE3:"\u0645",\uFEE4:"\u0645",\uFEE2:"\u0645",\uFEE1:"\u0645","\u08A7":"\u0645\u06DB","\u06FE":"\u0645\u0348",\uFC88:"\u0645l",\uFCCE:"\u0645\u062C",\uFC45:"\u0645\u062C",\uFD8C:"\u0645\u062C\u062D",\uFD92:"\u0645\u062C\u062E",\uFD8D:"\u0645\u062C\u0645",\uFDC0:"\u0645\u062C\u0649",\uFCCF:"\u0645\u062D",\uFC46:"\u0645\u062D",\uFD89:"\u0645\u062D\u062C",\uFD8A:"\u0645\u062D\u0645",\uFDF4:"\u0645\u062D\u0645\u062F",\uFD8B:"\u0645\u062D\u0649",\uFCD0:"\u0645\u062E",\uFC47:"\u0645\u062E",\uFD8E:"\u0645\u062E\u062C",\uFD8F:"\u0645\u062E\u0645",\uFDB9:"\u0645\u062E\u0649",\uFCD1:"\u0645\u0645",\uFC89:"\u0645\u0645",\uFC48:"\u0645\u0645",\uFDB1:"\u0645\u0645\u0649",\uFC49:"\u0645\u0649",\uFC4A:"\u0645\u0649","\u{1EE0D}":"\u0646","\u{1EE2D}":"\u0646","\u{1EE4D}":"\u0646","\u{1EE6D}":"\u0646","\u{1EE8D}":"\u0646","\u{1EEAD}":"\u0646",\uFEE7:"\u0646",\uFEE8:"\u0646",\uFEE6:"\u0646",\uFEE5:"\u0646","\u0768":"\u0646\u0615","\u0769":"\u0646\u0306",\uFCD6:"\u0646o",\uFCEF:"\u0646o",\uFDB8:"\u0646\u062C\u062D",\uFDBD:"\u0646\u062C\u062D",\uFD98:"\u0646\u062C\u0645",\uFD97:"\u0646\u062C\u0645",\uFD99:"\u0646\u062C\u0649",\uFDC7:"\u0646\u062C\u0649",\uFCD3:"\u0646\u062D",\uFC4C:"\u0646\u062D",\uFD95:"\u0646\u062D\u0645",\uFD96:"\u0646\u062D\u0649",\uFDB3:"\u0646\u062D\u0649",\uFCD4:"\u0646\u062E",\uFC4D:"\u0646\u062E",\uFC8A:"\u0646\u0631",\uFC8B:"\u0646\u0632",\uFCD5:"\u0646\u0645",\uFCEE:"\u0646\u0645",\uFC8C:"\u0646\u0645",\uFC4E:"\u0646\u0645",\uFD9B:"\u0646\u0645\u0649",\uFD9A:"\u0646\u0645\u0649",\uFC8D:"\u0646\u0646",\uFC8E:"\u0646\u0649",\uFC4F:"\u0646\u0649",\uFC8F:"\u0646\u0649",\uFC50:"\u0646\u0649",\u06C2:"\u06C0",\uFBA5:"\u06C0",\uFBA4:"\u06C0","\u{102E4}":"\u0648","\u{1EE05}":"\u0648","\u{1EE85}":"\u0648","\u{1EEA5}":"\u0648",\uFEEE:"\u0648",\uFEED:"\u0648","\u08B1":"\u0648",\u06CB:"\u0648\u06DB",\uFBDF:"\u0648\u06DB",\uFBDE:"\u0648\u06DB",\u06C7:"\u0648\u0313",\uFBD8:"\u0648\u0313",\uFBD7:"\u0648\u0313",\u06C6:"\u0648\u0306",\uFBDA:"\u0648\u0306",\uFBD9:"\u0648\u0306",\u06C9:"\u0648\u0302",\uFBE3:"\u0648\u0302",\uFBE2:"\u0648\u0302",\u06C8:"\u0648\u0670",\uFBDC:"\u0648\u0670",\uFBDB:"\u0648\u0670",\u0624:"\u0648\u0674",\uFE86:"\u0648\u0674",\uFE85:"\u0648\u0674",\u0676:"\u0648\u0674",\u0677:"\u0648\u0313\u0674",\uFBDD:"\u0648\u0313\u0674",\uFDF8:"\u0648\u0633\u0644\u0645",\uFBE1:"\u06C5",\uFBE0:"\u06C5","\u066E":"\u0649","\u{1EE1C}":"\u0649","\u{1EE7C}":"\u0649",\u06BA:"\u0649","\u{1EE1D}":"\u0649","\u{1EE5D}":"\u0649",\uFB9F:"\u0649",\uFB9E:"\u0649","\u08BD":"\u0649",\uFBE8:"\u0649",\uFBE9:"\u0649",\uFEF0:"\u0649",\uFEEF:"\u0649",\u064A:"\u0649","\u{1EE09}":"\u0649","\u{1EE29}":"\u0649","\u{1EE49}":"\u0649","\u{1EE69}":"\u0649","\u{1EE89}":"\u0649","\u{1EEA9}":"\u0649",\uFEF3:"\u0649",\uFEF4:"\u0649",\uFEF2:"\u0649",\uFEF1:"\u0649",\u06CC:"\u0649",\uFBFE:"\u0649",\uFBFF:"\u0649",\uFBFD:"\u0649",\uFBFC:"\u0649",\u06D2:"\u0649",\uFBAF:"\u0649",\uFBAE:"\u0649",\u0679:"\u0649\u0615",\uFB68:"\u0649\u0615",\uFB69:"\u0649\u0615",\uFB67:"\u0649\u0615",\uFB66:"\u0649\u0615",\u06BB:"\u0649\u0615",\uFBA2:"\u0649\u0615",\uFBA3:"\u0649\u0615",\uFBA1:"\u0649\u0615",\uFBA0:"\u0649\u0615",\u067E:"\u0649\u06DB",\uFB58:"\u0649\u06DB",\uFB59:"\u0649\u06DB",\uFB57:"\u0649\u06DB",\uFB56:"\u0649\u06DB",\u062B:"\u0649\u06DB","\u{1EE16}":"\u0649\u06DB","\u{1EE36}":"\u0649\u06DB","\u{1EE76}":"\u0649\u06DB","\u{1EE96}":"\u0649\u06DB","\u{1EEB6}":"\u0649\u06DB",\uFE9B:"\u0649\u06DB",\uFE9C:"\u0649\u06DB",\uFE9A:"\u0649\u06DB",\uFE99:"\u0649\u06DB",\u06BD:"\u0649\u06DB",\u06D1:"\u0649\u06DB","\u063F":"\u0649\u06DB","\u08B7":"\u0649\u06DB\u06E2","\u0756":"\u0649\u0306",\u06CE:"\u0649\u0306","\u08BA":"\u0649\u0306\u0307","\u063D":"\u0649\u0302","\u08A8":"\u0649\u0654",\uFC90:"\u0649\u0670",\uFC5D:"\u0649\u0670",\uFCDE:"\u0649o",\uFCF1:"\u0649o",\uFCE6:"\u0649\u06DBo",\u0626:"\u0649\u0674",\uFE8B:"\u0649\u0674",\uFE8C:"\u0649\u0674",\uFE8A:"\u0649\u0674",\uFE89:"\u0649\u0674",\u0678:"\u0649\u0674",\uFBEB:"\u0649\u0674l",\uFBEA:"\u0649\u0674l",\uFC9B:"\u0649\u0674o",\uFCE0:"\u0649\u0674o",\uFBED:"\u0649\u0674o",\uFBEC:"\u0649\u0674o",\uFBF8:"\u0649\u0674\u067B",\uFBF7:"\u0649\u0674\u067B",\uFBF6:"\u0649\u0674\u067B",\uFC97:"\u0649\u0674\u062C",\uFC00:"\u0649\u0674\u062C",\uFC98:"\u0649\u0674\u062D",\uFC01:"\u0649\u0674\u062D",\uFC99:"\u0649\u0674\u062E",\uFC64:"\u0649\u0674\u0631",\uFC65:"\u0649\u0674\u0632",\uFC9A:"\u0649\u0674\u0645",\uFCDF:"\u0649\u0674\u0645",\uFC66:"\u0649\u0674\u0645",\uFC02:"\u0649\u0674\u0645",\uFC67:"\u0649\u0674\u0646",\uFBEF:"\u0649\u0674\u0648",\uFBEE:"\u0649\u0674\u0648",\uFBF1:"\u0649\u0674\u0648\u0313",\uFBF0:"\u0649\u0674\u0648\u0313",\uFBF3:"\u0649\u0674\u0648\u0306",\uFBF2:"\u0649\u0674\u0648\u0306",\uFBF5:"\u0649\u0674\u0648\u0670",\uFBF4:"\u0649\u0674\u0648\u0670",\uFBFB:"\u0649\u0674\u0649",\uFBFA:"\u0649\u0674\u0649",\uFC68:"\u0649\u0674\u0649",\uFBF9:"\u0649\u0674\u0649",\uFC03:"\u0649\u0674\u0649",\uFC69:"\u0649\u0674\u0649",\uFC04:"\u0649\u0674\u0649",\uFCDA:"\u0649\u062C",\uFC55:"\u0649\u062C",\uFC11:"\u0649\u06DB\u062C",\uFDAF:"\u0649\u062C\u0649",\uFCDB:"\u0649\u062D",\uFC56:"\u0649\u062D",\uFDAE:"\u0649\u062D\u0649",\uFCDC:"\u0649\u062E",\uFC57:"\u0649\u062E",\uFC91:"\u0649\u0631",\uFC76:"\u0649\u06DB\u0631",\uFC92:"\u0649\u0632",\uFC77:"\u0649\u06DB\u0632",\uFCDD:"\u0649\u0645",\uFCF0:"\u0649\u0645",\uFC93:"\u0649\u0645",\uFC58:"\u0649\u0645",\uFCA6:"\u0649\u06DB\u0645",\uFCE5:"\u0649\u06DB\u0645",\uFC78:"\u0649\u06DB\u0645",\uFC12:"\u0649\u06DB\u0645",\uFD9D:"\u0649\u0645\u0645",\uFD9C:"\u0649\u0645\u0645",\uFDB0:"\u0649\u0645\u0649",\uFC94:"\u0649\u0646",\uFC79:"\u0649\u06DB\u0646",\uFC95:"\u0649\u0649",\uFC59:"\u0649\u0649",\uFC96:"\u0649\u0649",\uFC5A:"\u0649\u0649",\uFC7A:"\u0649\u06DB\u0649",\uFC13:"\u0649\u06DB\u0649",\uFC7B:"\u0649\u06DB\u0649",\uFC14:"\u0649\u06DB\u0649",\uFBB1:"\u06D3",\uFBB0:"\u06D3","\u{102B8}":"\u2D40","\u205E":"\u2D42","\u2E3D":"\u2D42","\u2999":"\u2D42","\uFE19":"\u2D57","\u205D":"\u2D57","\u22EE":"\u2D57",\u0544:"\u1206",\u054C:"\u1261",\u053B:"\u12AE",\u054A:"\u1323",\u0906:"\u0905\u093E",\u0912:"\u0905\u093E\u0946",\u0913:"\u0905\u093E\u0947",\u0914:"\u0905\u093E\u0948","\u0904":"\u0905\u0946",\u0911:"\u0905\u0949",\u090D:"\u090F\u0945",\u090E:"\u090F\u0946",\u0910:"\u090F\u0947",\u0908:"\u0930\u094D\u0907",\u0ABD:"\u093D","\u{111DC}":"\uA8FB","\u{111CB}":"\u093A","\u0AC1":"\u0941","\u0AC2":"\u0942","\u0A4B":"\u0946","\u0A4D":"\u094D","\u0ACD":"\u094D",\u0986:"\u0985\u09BE",\u09E0:"\u098B\u09C3",\u09E1:"\u098B\u09C3","\u{11492}":"\u0998","\u{11494}":"\u099A","\u{11496}":"\u099C","\u{11498}":"\u099E","\u{11499}":"\u099F","\u{1149B}":"\u09A1","\u{114AA}":"\u09A3","\u{1149E}":"\u09A4","\u{1149F}":"\u09A5","\u{114A0}":"\u09A6","\u{114A1}":"\u09A7","\u{114A2}":"\u09A8","\u{114A3}":"\u09AA","\u{114A9}":"\u09AC","\u{114A7}":"\u09AE","\u{114A8}":"\u09AF","\u{114AB}":"\u09B0","\u{1149D}":"\u09B2","\u{114AD}":"\u09B7","\u{114AE}":"\u09B8","\u{114C4}":"\u09BD","\u{114B0}":"\u09BE","\u{114B1}":"\u09BF","\u{114B9}":"\u09C7","\u{114BC}":"\u09CB","\u{114BE}":"\u09CC","\u{114C2}":"\u09CD","\u{114BD}":"\u09D7",\u0A09:"\u0A73\u0A41",\u0A0A:"\u0A73\u0A42",\u0A06:"\u0A05\u0A3E",\u0A10:"\u0A05\u0A48",\u0A14:"\u0A05\u0A4C",\u0A07:"\u0A72\u0A3F",\u0A08:"\u0A72\u0A40",\u0A0F:"\u0A72\u0A47",\u0A86:"\u0A85\u0ABE",\u0A91:"\u0A85\u0ABE\u0AC5",\u0A93:"\u0A85\u0ABE\u0AC7",\u0A94:"\u0A85\u0ABE\u0AC8",\u0A8D:"\u0A85\u0AC5",\u0A8F:"\u0A85\u0AC7",\u0A90:"\u0A85\u0AC8",\u0B06:"\u0B05\u0B3E","\u0BEE":"\u0B85",\u0BB0:"\u0B88","\u0BBE":"\u0B88","\u0BEB":"\u0B88\u0BC1","\u0BE8":"\u0B89",\u0D09:"\u0B89",\u0B8A:"\u0B89\u0BB3",\u0D0A:"\u0B89\u0D57","\u0BED":"\u0B8E","\u0BF7":"\u0B8E\u0BB5",\u0B9C:"\u0B90",\u0D1C:"\u0B90","\u0BE7":"\u0B95","\u0BEA":"\u0B9A","\u0BEC":"\u0B9A\u0BC1","\u0BF2":"\u0B9A\u0BC2","\u0D3A":"\u0B9F\u0BBF",\u0D23:"\u0BA3","\u0BFA":"\u0BA8\u0BC0","\u0BF4":"\u0BAE\u0BC0","\u0BF0":"\u0BAF",\u0D34:"\u0BB4","\u0BD7":"\u0BB3","\u0BC8":"\u0BA9",\u0D36:"\u0BB6","\u0BF8":"\u0BB7","\u0D3F":"\u0BBF","\u0D40":"\u0BBF","\u0BCA":"\u0BC6\u0B88","\u0BCC":"\u0BC6\u0BB3","\u0BCB":"\u0BC7\u0B88",\u0C85:"\u0C05",\u0C86:"\u0C06",\u0C87:"\u0C07",\u0C60:"\u0C0B\u0C3E",\u0C61:"\u0C0C\u0C3E",\u0C92:"\u0C12",\u0C14:"\u0C12\u0C4C",\u0C94:"\u0C12\u0C4C",\u0C13:"\u0C12\u0C55",\u0C93:"\u0C12\u0C55",\u0C9C:"\u0C1C",\u0C9E:"\u0C1E",\u0C22:"\u0C21\u0323",\u0CA3:"\u0C23",\u0C25:"\u0C27\u05BC",\u0C2D:"\u0C2C\u0323",\u0CAF:"\u0C2F",\u0C20:"\u0C30\u05BC",\u0CB1:"\u0C31",\u0CB2:"\u0C32",\u0C37:"\u0C35\u0323",\u0C39:"\u0C35\u0C3E",\u0C2E:"\u0C35\u0C41","\u0C42":"\u0C41\u0C3E","\u0C44":"\u0C43\u0C3E",\u0CE1:"\u0C8C\u0CBE",\u0D08:"\u0D07\u0D57",\u0D10:"\u0D0E\u0D46",\u0D13:"\u0D12\u0D3E",\u0D14:"\u0D12\u0D57",\u0D61:"\u0D1E","\u0D6B":"\u0D26\u0D4D\u0D30","\u0D79":"\u0D28\u0D41",\u0D0C:"\u0D28\u0D41",\u0D19:"\u0D28\u0D41","\u0D6F":"\u0D28\u0D4D","\u0D7B":"\u0D28\u0D4D","\u0D6C":"\u0D28\u0D4D\u0D28","\u0D5A":"\u0D28\u0D4D\u0D2E",\u0D31:"\u0D30","\u0D6A":"\u0D30\u0D4D","\u0D7C":"\u0D30\u0D4D","\u0D6E":"\u0D35\u0D4D\u0D30","\u0D76":"\u0D39\u0D4D\u0D2E","\u0D42":"\u0D41","\u0D43":"\u0D41","\u0D48":"\u0D46\u0D46","\u0DEA":"\u0DA2","\u0DEB":"\u0DAF","\u{11413}":"\u{11434}\u{11442}\u{11412}","\u{11419}":"\u{11434}\u{11442}\u{11418}","\u{11424}":"\u{11434}\u{11442}\u{11423}","\u{1142A}":"\u{11434}\u{11442}\u{11429}","\u{1142D}":"\u{11434}\u{11442}\u{1142C}","\u{1142F}":"\u{11434}\u{11442}\u{1142E}","\u{115D8}":"\u{11582}","\u{115D9}":"\u{11582}","\u{115DA}":"\u{11583}","\u{115DB}":"\u{11584}","\u{115DC}":"\u{115B2}","\u{115DD}":"\u{115B3}",\u0E03:"\u0E02",\u0E14:"\u0E04",\u0E15:"\u0E04",\u0E21:"\u0E06",\u0E88:"\u0E08",\u0E0B:"\u0E0A",\u0E0F:"\u0E0E",\u0E17:"\u0E11",\u0E9A:"\u0E1A",\u0E9B:"\u0E1B",\u0E9D:"\u0E1D",\u0E9E:"\u0E1E",\u0E9F:"\u0E1F",\u0E26:"\u0E20",\u0E8D:"\u0E22","\u17D4":"\u0E2F",\u0E45:"\u0E32",\u0E33:"\u030A\u0E32","\u17B7":"\u0E34","\u17B8":"\u0E35","\u17B9":"\u0E36","\u17BA":"\u0E37","\u0EB8":"\u0E38","\u0EB9":"\u0E39",\u0E41:"\u0E40\u0E40",\u0EDC:"\u0EAB\u0E99",\u0EDD:"\u0EAB\u0EA1",\u0EB3:"\u030A\u0EB2","\u0F02":"\u0F60\u0F74\u0F82\u0F7F","\u0F03":"\u0F60\u0F74\u0F82\u0F14",\u0F6A:"\u0F62",\u0F00:"\u0F68\u0F7C\u0F7E","\u0F77":"\u0FB2\u0F71\u0F80","\u0F79":"\u0FB3\u0F71\u0F80","\u{11CB2}":"\u{11CAA}","\u1081":"\u1002\u103E",\u1000:"\u1002\u102C","\u1070":"\u1003\u103E","\u1066":"\u1015\u103E",\u101F:"\u1015\u102C","\u106F":"\u1015\u102C\u103E","\u107E":"\u107D\u103E",\u1029:"\u101E\u103C",\u102A:"\u101E\u103C\u1031\u102C\u103A","\u109E":"\u1083\u030A",\u17A3:"\u17A2","\u19D0":"\u199E","\u19D1":"\u19B1","\u1A80":"\u1A45","\u1A90":"\u1A45","\uAA53":"\uAA01","\uAA56":"\uAA23","\u1B52":"\u1B0D","\u1B53":"\u1B11","\u1B58":"\u1B28","\uA9A3":"\uA99D",\u1896:"\u185C",\u1855:"\u1835",\u1FF6:"\u13EF",\u140D:"\u1401\xB7",\u142B:"\u1401\u1420",\u1411:"\u1404\xB7",\u1413:"\u1405\xB7",\u142D:"\u1405\u1420",\u1415:"\u1406\xB7",\u1418:"\u140A\xB7",\u142E:"\u140A\u1420",\u141A:"\u140B\xB7","\u18DD":"\u141E\u18DF",\u14D1:"\u1421",\u1540:"\u1429",\u143F:"\u1432\xB7",\u1443:"\u1434\xB7","\u2369":"\u1435",\u1447:"\u1439\xB7",\u145C:"\u144F\xB7","\u2E27":"\u1450","\u2283":"\u1450",\u145E:"\u1450\xB7",\u1469:"\u1450'","\u27C9":"\u1450/","\u2AD7":"\u1450\u1455",\u1460:"\u1451\xB7","\u2E26":"\u1455","\u2282":"\u1455",\u1462:"\u1455\xB7",\u146A:"\u1455'",\u1464:"\u1456\xB7",\u1475:"\u146B\xB7",\u1485:"\u146B'",\u1479:"\u146E\xB7",\u147D:"\u1470\xB7",\u1603:"\u1489",\u1493:"\u1489\xB7",\u1495:"\u148B\xB7",\u1497:"\u148C\xB7",\u149B:"\u148E\xB7",\u1602:"\u1490",\u149D:"\u1490\xB7",\u149F:"\u1491\xB7",\u14AD:"\u14A3\xB7",\u14B1:"\u14A6\xB7",\u14B3:"\u14A7\xB7",\u14B5:"\u14A8\xB7",\u14B9:"\u14AB\xB7",\u14CA:"\u14C0\xB7","\u18C7":"\u14C2\xB7","\u18C9":"\u14C3\xB7","\u18CB":"\u14C4\xB7","\u18CD":"\u14C5\xB7",\u14CC:"\u14C7\xB7",\u14CE:"\u14C8\xB7",\u1604:"\u14D3",\u14DD:"\u14D3\xB7",\u14DF:"\u14D5\xB7",\u14E1:"\u14D6\xB7",\u14E3:"\u14D7\xB7",\u14E5:"\u14D8\xB7",\u1607:"\u14DA",\u14E7:"\u14DA\xB7",\u14E9:"\u14DB\xB7",\u14F7:"\u14ED\xB7",\u14F9:"\u14EF\xB7",\u14FB:"\u14F0\xB7",\u14FD:"\u14F1\xB7",\u14FF:"\u14F2\xB7",\u1501:"\u14F4\xB7",\u1503:"\u14F5\xB7",\u150C:"\u150B<",\u150E:"\u150Bb",\u150D:"\u150B\u1455",\u150F:"\u150B\u1490",\u1518:"\u1510\xB7",\u151A:"\u1511\xB7",\u151C:"\u1512\xB7",\u151E:"\u1513\xB7",\u1520:"\u1514\xB7",\u1522:"\u1515\xB7",\u1524:"\u1516\xB7",\u1532:"\u1528\xB7",\u1534:"\u1529\xB7",\u1536:"\u152A\xB7",\u1538:"\u152B\xB7",\u153A:"\u152D\xB7",\u153C:"\u152E\xB7",\u1622:"\u1543","\u18E0":"\u1543\xB7",\u1623:"\u1546",\u1624:"\u154A",\u154F:"\u154C\xB7",\u1583:"\u1550b",\u1584:"\u1550b\u0307",\u1581:"\u1550d",\u157F:"\u1550P",\u166F:"\u1550\u146B",\u157E:"\u1550\u146C",\u1580:"\u1550\u146E",\u1582:"\u1550\u1470",\u1585:"\u1550\u1483",\u155C:"\u155A\xB7","\u18E3":"\u155E\xB7","\u18E4":"\u1566\xB7",\u1569:"\u1567\xB7","\u18E5":"\u156B\xB7","\u18E8":"\u1586\xB7",\u1591:"\u1595J",\u1670:"\u1595\u1489",\u158E:"\u1595\u148A",\u158F:"\u1595\u148B",\u1590:"\u1595\u148C",\u1592:"\u1595\u148E",\u1593:"\u1595\u1490",\u1594:"\u1595\u1491",\u1673:"\u1596J",\u1671:"\u1596\u148B",\u1672:"\u1596\u148C",\u1674:"\u1596\u148E",\u1675:"\u1596\u1490",\u1676:"\u1596\u1491","\u18EA":"\u1597\xB7","\u1677":"\u15A7\xB7","\u1678":"\u15A8\xB7","\u1679":"\u15A9\xB7","\u167A":"\u15AA\xB7","\u167B":"\u15AB\xB7","\u167C":"\u15AC\xB7","\u167D":"\u15AD\xB7","\u2AAB":"\u15D2","\u2AAA":"\u15D5","\uA4F7":"\u15E1","\u18F0":"\u15F4\xB7","\u18F2":"\u161B\xB7","\u1DBB":"\u1646","\uA4ED":"\u1660","\u1DBA":"\u18D4","\u1D3E":"\u18D6","\u18DC":"\u18DF\u141E",\u02E1:"\u18F3",\u02B3:"\u18F4",\u02E2:"\u18F5","\u18DB":"\u18F5","\uA6B0":"\u16B9",\u16E1:"\u16BC","\u237F":"\u16BD",\u16C2:"\u16BD","\u{1D23F}":"\u16CB","\u2191":"\u16CF","\u21BF":"\u16D0","\u296E":"\u16D0\u21C2","\u2963":"\u16D0\u16DA","\u2D63":"\u16EF","\u21BE":"\u16DA","\u2A21":"\u16DA","\u22C4":"\u16DC","\u25C7":"\u16DC","\u25CA":"\u16DC","\u2662":"\u16DC","\u{1F754}":"\u16DC","\u{118B7}":"\u16DC","\u{10294}":"\u16DC","\u235A":"\u16DC\u0332","\u22C8":"\u16DE","\u2A1D":"\u16DE","\u{104D0}":"\u16E6","\u2195":"\u16E8","\u{10CFC}":"\u{10C82}","\u{10CFA}":"\u{10CA5}",\u3131:"\u1100",\u11A8:"\u1100",\u1101:"\u1100\u1100",\u3132:"\u1100\u1100",\u11A9:"\u1100\u1100","\u11FA":"\u1100\u1102","\u115A":"\u1100\u1103",\u11C3:"\u1100\u1105","\u11FB":"\u1100\u1107",\u11AA:"\u1100\u1109",\u3133:"\u1100\u1109",\u11C4:"\u1100\u1109\u1100","\u11FC":"\u1100\u110E","\u11FD":"\u1100\u110F","\u11FE":"\u1100\u1112",\u3134:"\u1102",\u11AB:"\u1102",\u1113:"\u1102\u1100",\u11C5:"\u1102\u1100",\u1114:"\u1102\u1102",\u3165:"\u1102\u1102","\u11FF":"\u1102\u1102",\u1115:"\u1102\u1103",\u3166:"\u1102\u1103",\u11C6:"\u1102\u1103","\uD7CB":"\u1102\u1105",\u1116:"\u1102\u1107","\u115B":"\u1102\u1109",\u11C7:"\u1102\u1109",\u3167:"\u1102\u1109","\u115C":"\u1102\u110C",\u11AC:"\u1102\u110C",\u3135:"\u1102\u110C","\uD7CC":"\u1102\u110E",\u11C9:"\u1102\u1110","\u115D":"\u1102\u1112",\u11AD:"\u1102\u1112",\u3136:"\u1102\u1112",\u11C8:"\u1102\u1140",\u3168:"\u1102\u1140",\u3137:"\u1103",\u11AE:"\u1103",\u1117:"\u1103\u1100",\u11CA:"\u1103\u1100",\u1104:"\u1103\u1103",\u3138:"\u1103\u1103","\uD7CD":"\u1103\u1103","\uD7CE":"\u1103\u1103\u1107","\u115E":"\u1103\u1105",\u11CB:"\u1103\u1105","\uA960":"\u1103\u1106","\uA961":"\u1103\u1107","\uD7CF":"\u1103\u1107","\uA962":"\u1103\u1109","\uD7D0":"\u1103\u1109","\uD7D1":"\u1103\u1109\u1100","\uA963":"\u1103\u110C","\uD7D2":"\u1103\u110C","\uD7D3":"\u1103\u110E","\uD7D4":"\u1103\u1110",\u3139:"\u1105",\u11AF:"\u1105","\uA964":"\u1105\u1100",\u11B0:"\u1105\u1100",\u313A:"\u1105\u1100","\uA965":"\u1105\u1100\u1100","\uD7D5":"\u1105\u1100\u1100",\u11CC:"\u1105\u1100\u1109",\u3169:"\u1105\u1100\u1109","\uD7D6":"\u1105\u1100\u1112",\u1118:"\u1105\u1102",\u11CD:"\u1105\u1102","\uA966":"\u1105\u1103",\u11CE:"\u1105\u1103",\u316A:"\u1105\u1103","\uA967":"\u1105\u1103\u1103",\u11CF:"\u1105\u1103\u1112",\u1119:"\u1105\u1105",\u11D0:"\u1105\u1105","\uD7D7":"\u1105\u1105\u110F","\uA968":"\u1105\u1106",\u11B1:"\u1105\u1106",\u313B:"\u1105\u1106",\u11D1:"\u1105\u1106\u1100",\u11D2:"\u1105\u1106\u1109","\uD7D8":"\u1105\u1106\u1112","\uA969":"\u1105\u1107",\u11B2:"\u1105\u1107",\u313C:"\u1105\u1107","\uD7D9":"\u1105\u1107\u1103","\uA96A":"\u1105\u1107\u1107",\u11D3:"\u1105\u1107\u1109",\u316B:"\u1105\u1107\u1109","\uA96B":"\u1105\u1107\u110B",\u11D5:"\u1105\u1107\u110B","\uD7DA":"\u1105\u1107\u1111",\u11D4:"\u1105\u1107\u1112","\uA96C":"\u1105\u1109",\u11B3:"\u1105\u1109",\u313D:"\u1105\u1109",\u11D6:"\u1105\u1109\u1109",\u111B:"\u1105\u110B","\uD7DD":"\u1105\u110B","\uA96D":"\u1105\u110C","\uA96E":"\u1105\u110F",\u11D8:"\u1105\u110F",\u11B4:"\u1105\u1110",\u313E:"\u1105\u1110",\u11B5:"\u1105\u1111",\u313F:"\u1105\u1111",\u111A:"\u1105\u1112",\u3140:"\u1105\u1112",\u113B:"\u1105\u1112",\u11B6:"\u1105\u1112","\uD7F2":"\u1105\u1112",\u11D7:"\u1105\u1140",\u316C:"\u1105\u1140","\uD7DB":"\u1105\u114C",\u11D9:"\u1105\u1159",\u316D:"\u1105\u1159","\uD7DC":"\u1105\u1159\u1112",\u3141:"\u1106",\u11B7:"\u1106","\uA96F":"\u1106\u1100",\u11DA:"\u1106\u1100","\uD7DE":"\u1106\u1102","\uD7DF":"\u1106\u1102\u1102","\uA970":"\u1106\u1103",\u11DB:"\u1106\u1105","\uD7E0":"\u1106\u1106",\u111C:"\u1106\u1107",\u316E:"\u1106\u1107",\u11DC:"\u1106\u1107","\uD7E1":"\u1106\u1107\u1109","\uA971":"\u1106\u1109",\u11DD:"\u1106\u1109",\u316F:"\u1106\u1109",\u11DE:"\u1106\u1109\u1109",\u111D:"\u1106\u110B",\u3171:"\u1106\u110B",\u11E2:"\u1106\u110B","\uD7E2":"\u1106\u110C",\u11E0:"\u1106\u110E",\u11E1:"\u1106\u1112",\u11DF:"\u1106\u1140",\u3170:"\u1106\u1140",\u3142:"\u1107",\u11B8:"\u1107",\u111E:"\u1107\u1100",\u3172:"\u1107\u1100",\u111F:"\u1107\u1102",\u1120:"\u1107\u1103",\u3173:"\u1107\u1103","\uD7E3":"\u1107\u1103",\u11E3:"\u1107\u1105","\uD7E4":"\u1107\u1105\u1111","\uD7E5":"\u1107\u1106",\u1108:"\u1107\u1107",\u3143:"\u1107\u1107","\uD7E6":"\u1107\u1107",\u112C:"\u1107\u1107\u110B",\u3179:"\u1107\u1107\u110B",\u1121:"\u1107\u1109",\u3144:"\u1107\u1109",\u11B9:"\u1107\u1109",\u1122:"\u1107\u1109\u1100",\u3174:"\u1107\u1109\u1100",\u1123:"\u1107\u1109\u1103",\u3175:"\u1107\u1109\u1103","\uD7E7":"\u1107\u1109\u1103",\u1124:"\u1107\u1109\u1107",\u1125:"\u1107\u1109\u1109",\u1126:"\u1107\u1109\u110C","\uA972":"\u1107\u1109\u1110",\u112B:"\u1107\u110B",\u3178:"\u1107\u110B",\u11E6:"\u1107\u110B",\u1127:"\u1107\u110C",\u3176:"\u1107\u110C","\uD7E8":"\u1107\u110C",\u1128:"\u1107\u110E","\uD7E9":"\u1107\u110E","\uA973":"\u1107\u110F",\u1129:"\u1107\u1110",\u3177:"\u1107\u1110",\u112A:"\u1107\u1111",\u11E4:"\u1107\u1111","\uA974":"\u1107\u1112",\u11E5:"\u1107\u1112",\u3145:"\u1109",\u11BA:"\u1109",\u112D:"\u1109\u1100",\u317A:"\u1109\u1100",\u11E7:"\u1109\u1100",\u112E:"\u1109\u1102",\u317B:"\u1109\u1102",\u112F:"\u1109\u1103",\u317C:"\u1109\u1103",\u11E8:"\u1109\u1103",\u1130:"\u1109\u1105",\u11E9:"\u1109\u1105",\u1131:"\u1109\u1106","\uD7EA":"\u1109\u1106",\u1132:"\u1109\u1107",\u317D:"\u1109\u1107",\u11EA:"\u1109\u1107",\u1133:"\u1109\u1107\u1100","\uD7EB":"\u1109\u1107\u110B",\u110A:"\u1109\u1109",\u3146:"\u1109\u1109",\u11BB:"\u1109\u1109","\uD7EC":"\u1109\u1109\u1100","\uD7ED":"\u1109\u1109\u1103","\uA975":"\u1109\u1109\u1107",\u1134:"\u1109\u1109\u1109",\u1135:"\u1109\u110B",\u1136:"\u1109\u110C",\u317E:"\u1109\u110C","\uD7EF":"\u1109\u110C",\u1137:"\u1109\u110E","\uD7F0":"\u1109\u110E",\u1138:"\u1109\u110F",\u1139:"\u1109\u1110","\uD7F1":"\u1109\u1110",\u113A:"\u1109\u1111","\uD7EE":"\u1109\u1140",\u3147:"\u110B",\u11BC:"\u110B",\u1141:"\u110B\u1100",\u11EC:"\u110B\u1100",\u11ED:"\u110B\u1100\u1100",\u1142:"\u110B\u1103","\uA976":"\u110B\u1105",\u1143:"\u110B\u1106",\u1144:"\u110B\u1107",\u1145:"\u110B\u1109",\u11F1:"\u110B\u1109",\u3182:"\u110B\u1109",\u1147:"\u110B\u110B",\u3180:"\u110B\u110B",\u11EE:"\u110B\u110B",\u1148:"\u110B\u110C",\u1149:"\u110B\u110E",\u11EF:"\u110B\u110F",\u114A:"\u110B\u1110",\u114B:"\u110B\u1111","\uA977":"\u110B\u1112",\u1146:"\u110B\u1140",\u11F2:"\u110B\u1140",\u3183:"\u110B\u1140",\u3148:"\u110C",\u11BD:"\u110C","\uD7F7":"\u110C\u1107","\uD7F8":"\u110C\u1107\u1107",\u114D:"\u110C\u110B",\u110D:"\u110C\u110C",\u3149:"\u110C\u110C","\uD7F9":"\u110C\u110C","\uA978":"\u110C\u110C\u1112",\u314A:"\u110E",\u11BE:"\u110E",\u1152:"\u110E\u110F",\u1153:"\u110E\u1112",\u314B:"\u110F",\u11BF:"\u110F",\u314C:"\u1110",\u11C0:"\u1110","\uA979":"\u1110\u1110",\u314D:"\u1111",\u11C1:"\u1111",\u1156:"\u1111\u1107",\u11F3:"\u1111\u1107","\uD7FA":"\u1111\u1109",\u1157:"\u1111\u110B",\u3184:"\u1111\u110B",\u11F4:"\u1111\u110B","\uD7FB":"\u1111\u1110","\uA97A":"\u1111\u1112",\u314E:"\u1112",\u11C2:"\u1112",\u11F5:"\u1112\u1102",\u11F6:"\u1112\u1105",\u11F7:"\u1112\u1106",\u11F8:"\u1112\u1107","\uA97B":"\u1112\u1109",\u1158:"\u1112\u1112",\u3185:"\u1112\u1112",\u113D:"\u113C\u113C",\u113F:"\u113E\u113E",\u317F:"\u1140",\u11EB:"\u1140","\uD7F3":"\u1140\u1107","\uD7F4":"\u1140\u1107\u110B",\u3181:"\u114C",\u11F0:"\u114C","\uD7F5":"\u114C\u1106","\uD7F6":"\u114C\u1112",\u114F:"\u114E\u114E",\u1151:"\u1150\u1150",\u3186:"\u1159",\u11F9:"\u1159","\uA97C":"\u1159\u1159",\u3164:"\u1160",\u314F:"\u1161","\u11A3":"\u1161\u30FC",\u1176:"\u1161\u1169",\u1177:"\u1161\u116E",\u1162:"\u1161\u4E28",\u3150:"\u1161\u4E28",\u3151:"\u1163",\u1178:"\u1163\u1169",\u1179:"\u1163\u116D","\u11A4":"\u1163\u116E",\u1164:"\u1163\u4E28",\u3152:"\u1163\u4E28",\u3153:"\u1165",\u117C:"\u1165\u30FC",\u117A:"\u1165\u1169",\u117B:"\u1165\u116E",\u1166:"\u1165\u4E28",\u3154:"\u1165\u4E28",\u3155:"\u1167","\u11A5":"\u1167\u1163",\u117D:"\u1167\u1169",\u117E:"\u1167\u116E",\u1168:"\u1167\u4E28",\u3156:"\u1167\u4E28",\u3157:"\u1169",\u116A:"\u1169\u1161",\u3158:"\u1169\u1161",\u116B:"\u1169\u1161\u4E28",\u3159:"\u1169\u1161\u4E28","\u11A6":"\u1169\u1163","\u11A7":"\u1169\u1163\u4E28",\u117F:"\u1169\u1165",\u1180:"\u1169\u1165\u4E28","\uD7B0":"\u1169\u1167",\u1181:"\u1169\u1167\u4E28",\u1182:"\u1169\u1169","\uD7B1":"\u1169\u1169\u4E28",\u1183:"\u1169\u116E",\u116C:"\u1169\u4E28",\u315A:"\u1169\u4E28",\u315B:"\u116D","\uD7B2":"\u116D\u1161","\uD7B3":"\u116D\u1161\u4E28",\u1184:"\u116D\u1163",\u3187:"\u116D\u1163",\u1186:"\u116D\u1163",\u1185:"\u116D\u1163\u4E28",\u3188:"\u116D\u1163\u4E28","\uD7B4":"\u116D\u1165",\u1187:"\u116D\u1169",\u1188:"\u116D\u4E28",\u3189:"\u116D\u4E28",\u315C:"\u116E",\u1189:"\u116E\u1161",\u118A:"\u116E\u1161\u4E28",\u116F:"\u116E\u1165",\u315D:"\u116E\u1165",\u118B:"\u116E\u1165\u30FC",\u1170:"\u116E\u1165\u4E28",\u315E:"\u116E\u1165\u4E28","\uD7B5":"\u116E\u1167",\u118C:"\u116E\u1167\u4E28",\u118D:"\u116E\u116E",\u1171:"\u116E\u4E28",\u315F:"\u116E\u4E28","\uD7B6":"\u116E\u4E28\u4E28",\u3160:"\u1172",\u118E:"\u1172\u1161","\uD7B7":"\u1172\u1161\u4E28",\u118F:"\u1172\u1165",\u1190:"\u1172\u1165\u4E28",\u1191:"\u1172\u1167",\u318A:"\u1172\u1167",\u1192:"\u1172\u1167\u4E28",\u318B:"\u1172\u1167\u4E28","\uD7B8":"\u1172\u1169",\u1193:"\u1172\u116E",\u1194:"\u1172\u4E28",\u318C:"\u1172\u4E28",\u318D:"\u119E","\uD7C5":"\u119E\u1161",\u119F:"\u119E\u1165","\uD7C6":"\u119E\u1165\u4E28",\u11A0:"\u119E\u116E",\u11A2:"\u119E\u119E",\u11A1:"\u119E\u4E28",\u318E:"\u119E\u4E28",\u30D8:"\u3078","\u2341":"\u303C","\u29C4":"\u303C","\uA49E":"\uA04A","\uA4AC":"\uA050","\uA49C":"\uA0C0","\uA4A8":"\uA132","\uA4BF":"\uA259","\uA4BE":"\uA2B1","\uA494":"\uA2CD","\uA4C0":"\uA3AB","\uA4C2":"\uA3B5","\uA4BA":"\uA3BF","\uA4B0":"\uA3C2","\uA4A7":"\uA458","\u22A5":"\uA4D5","\u27C2":"\uA4D5","\u{1D21C}":"\uA4D5","\uA7B1":"\uA4D5","\uA79E":"\uA4E4","\u2141":"\uA4E8","\u2142":"\uA4F6","\u{1D215}":"\uA4F6","\u{1D22B}":"\uA4F6","\u{16F26}":"\uA4F6","\u{10411}":"\uA4F6","\u2143":"\u{16F00}","\u{11AE6}":"\u{11AE5}\u{11AEF}","\u{11AE8}":"\u{11AE5}\u{11AE5}","\u{11AE9}":"\u{11AE5}\u{11AE5}\u{11AEF}","\u{11AEA}":"\u{11AE5}\u{11AE5}\u{11AF0}","\u{11AE7}":"\u{11AE5}\u{11AF0}","\u{11AF4}":"\u{11AF3}\u{11AEF}","\u{11AF6}":"\u{11AF3}\u{11AF3}","\u{11AF7}":"\u{11AF3}\u{11AF3}\u{11AEF}","\u{11AF8}":"\u{11AF3}\u{11AF3}\u{11AF0}","\u{11AF5}":"\u{11AF3}\u{11AF0}","\u{11AEC}":"\u{11AEB}\u{11AEF}","\u{11AED}":"\u{11AEB}\u{11AEB}","\u{11AEE}":"\u{11AEB}\u{11AEB}\u{11AEF}","\u2295":"\u{102A8}","\u2A01":"\u{102A8}","\u{1F728}":"\u{102A8}","\uA69A":"\u{102A8}","\u25BD":"\u{102BC}","\u{1D214}":"\u{102BC}","\u{1F704}":"\u{102BC}","\u29D6":"\u{102C0}","\uA79B":"\u{1043A}","\uA79A":"\u{10412}","\u{104A0}":"\u{10486}","\u{103D1}":"\u{10382}","\u{103D3}":"\u{10393}","\u{12038}":"\u{1039A}","\u2625":"\u{1099E}","\u{132F9}":"\u{1099E}","\u3039":"\u5344",\uF967:"\u4E0D","\u{2F800}":"\u4E3D","\uFA70":"\u4E26","\u239C":"\u4E28","\u239F":"\u4E28","\u23A2":"\u4E28","\u23A5":"\u4E28","\u23AA":"\u4E28","\u23AE":"\u4E28","\u31D1":"\u4E28",\u1175:"\u4E28",\u3163:"\u4E28","\u2F01":"\u4E28",\u119C:"\u4E28\u30FC",\u1198:"\u4E28\u1161",\u1199:"\u4E28\u1163","\uD7BD":"\u4E28\u1163\u1169","\uD7BE":"\u4E28\u1163\u4E28","\uD7BF":"\u4E28\u1167","\uD7C0":"\u4E28\u1167\u4E28",\u119A:"\u4E28\u1169","\uD7C1":"\u4E28\u1169\u4E28","\uD7C2":"\u4E28\u116D",\u119B:"\u4E28\u116E","\uD7C3":"\u4E28\u1172",\u119D:"\u4E28\u119E","\uD7C4":"\u4E28\u4E28",\uF905:"\u4E32","\u{2F801}":"\u4E38",\uF95E:"\u4E39","\u{2F802}":"\u4E41","\u31E0":"\u4E59","\u2F04":"\u4E59","\u31DF":"\u4E5A","\u2E83":"\u4E5A","\u31D6":"\u4E5B","\u2E82":"\u4E5B","\u2EF2":"\u4E80",\uF91B:"\u4E82","\u31DA":"\u4E85","\u2F05":"\u4E85",\uF9BA:"\u4E86",\u30CB:"\u4E8C","\u2F06":"\u4E8C","\u{2F803}":"\u{20122}","\u2F07":"\u4EA0",\uF977:"\u4EAE","\u2F08":"\u4EBA",\u30A4:"\u4EBB","\u2E85":"\u4EBB",\uF9FD:"\u4EC0","\u{2F819}":"\u4ECC",\uF9A8:"\u4EE4","\u{2F804}":"\u4F60",\u5002:"\u4F75","\u{2F807}":"\u4F75","\uFA73":"\u4F80",\uF92D:"\u4F86",\uF9B5:"\u4F8B","\uFA30":"\u4FAE","\u{2F805}":"\u4FAE","\u{2F806}":"\u4FBB",\uF965:"\u4FBF",\u503C:"\u5024",\uF9D4:"\u502B","\u{2F808}":"\u507A","\u{2F809}":"\u5099","\u{2F80B}":"\u50CF",\uF9BB:"\u50DA","\uFA31":"\u50E7","\u{2F80A}":"\u50E7","\u{2F80C}":"\u349E","\u2F09":"\u513F",\uFA0C:"\u5140","\u2E8E":"\u5140","\uFA74":"\u5145","\uFA32":"\u514D","\u{2F80E}":"\u514D","\u{2F80F}":"\u5154","\u{2F810}":"\u5164","\u2F0A":"\u5165","\u{2F814}":"\u5167","\uFA72":"\u5168",\uF978:"\u5169",\u30CF:"\u516B","\u2F0B":"\u516B",\uF9D1:"\u516D","\u{2F811}":"\u5177","\u{2F812}":"\u{2051C}","\u{2F91B}":"\u{20525}","\uFA75":"\u5180","\u{2F813}":"\u34B9","\u2F0C":"\u5182","\u{2F815}":"\u518D","\u{2F816}":"\u{2054B}","\u{2F8D2}":"\u5192","\u{2F8D3}":"\u5195","\u{2F9CA}":"\u34BB","\u{2F8D4}":"\u6700","\u2F0D":"\u5196","\u{2F817}":"\u5197","\u{2F818}":"\u51A4","\u2F0E":"\u51AB","\u{2F81A}":"\u51AC","\uFA71":"\u51B5","\u{2F81B}":"\u51B5",\uF92E:"\u51B7",\uF979:"\u51C9",\uF955:"\u51CC",\uF954:"\u51DC",\uFA15:"\u51DE","\u2F0F":"\u51E0","\u{2F80D}":"\u{2063A}","\u{2F81D}":"\u51F5","\u2F10":"\u51F5","\u2F11":"\u5200","\u2E89":"\u5202","\u{2F81E}":"\u5203",\uFA00:"\u5207","\u{2F850}":"\u5207",\uF99C:"\u5217",\uF9DD:"\u5229","\u{2F81F}":"\u34DF",\uF9FF:"\u523A","\u{2F820}":"\u523B","\u{2F821}":"\u5246","\u{2F822}":"\u5272","\u{2F823}":"\u5277",\uF9C7:"\u5289","\u{2F9D9}":"\u{20804}",\u30AB:"\u529B",\uF98A:"\u529B","\u2F12":"\u529B",\uF99D:"\u52A3","\u{2F824}":"\u3515","\u{2F992}":"\u52B3","\uFA76":"\u52C7","\u{2F825}":"\u52C7","\uFA33":"\u52C9","\u{2F826}":"\u52C9",\uF952:"\u52D2",\uF92F:"\u52DE","\uFA34":"\u52E4","\u{2F827}":"\u52E4",\uF97F:"\u52F5","\u2F13":"\u52F9","\uFA77":"\u52FA","\u{2F828}":"\u52FA","\u{2F829}":"\u5305","\u{2F82A}":"\u5306","\u{2F9DD}":"\u{208DE}","\u2F14":"\u5315",\uF963:"\u5317","\u{2F82B}":"\u5317","\u2F15":"\u531A","\u2F16":"\u5338",\uF9EB:"\u533F","\u2F17":"\u5341","\u3038":"\u5341","\u303A":"\u5345","\u{2F82C}":"\u5349","\u0FD6":"\u534D","\u0FD5":"\u5350","\uFA35":"\u5351","\u{2F82D}":"\u5351","\u{2F82E}":"\u535A",\u30C8:"\u535C","\u2F18":"\u535C","\u2F19":"\u5369","\u2E8B":"\u353E","\u{2F82F}":"\u5373",\uF91C:"\u5375","\u{2F830}":"\u537D","\u{2F831}":"\u537F","\u{2F832}":"\u537F","\u{2F833}":"\u537F","\u2F1A":"\u5382","\u{2F834}":"\u{20A2C}","\u2F1B":"\u53B6",\uF96B:"\u53C3","\u2F1C":"\u53C8","\u{2F836}":"\u53CA","\u{2F837}":"\u53DF","\u{2F838}":"\u{20B63}",\u30ED:"\u53E3","\u2F1D":"\u53E3",\u56D7:"\u53E3","\u2F1E":"\u53E3",\uF906:"\u53E5","\u{2F839}":"\u53EB","\u{2F83A}":"\u53F1","\u{2F83B}":"\u5406",\uF9DE:"\u540F",\uF9ED:"\u541D","\u{2F83D}":"\u5438",\uF980:"\u5442","\u{2F83E}":"\u5448","\u{2F83F}":"\u5468","\u{2F83C}":"\u549E","\u{2F840}":"\u54A2",\uF99E:"\u54BD",\u439B:"\u3588","\u{2F841}":"\u54F6","\u{2F842}":"\u5510","\u{2F843}":"\u5553",\u555F:"\u5553","\uFA79":"\u5555","\u{2F844}":"\u5563","\u{2F845}":"\u5584","\u{2F846}":"\u5584",\uF90B:"\u5587","\uFA7A":"\u5599","\u{2F847}":"\u5599","\uFA36":"\u559D","\uFA78":"\u559D","\u{2F848}":"\u55AB","\u{2F849}":"\u55B3",\uFA0D:"\u55C0","\u{2F84A}":"\u55C2","\uFA7B":"\u55E2","\uFA37":"\u5606","\u{2F84C}":"\u5606","\u{2F84E}":"\u5651","\u{2F84F}":"\u5674","\uFA38":"\u5668",\uF9A9:"\u56F9","\u{2F84B}":"\u5716","\u{2F84D}":"\u5717","\u2F1F":"\u571F",\u58EB:"\u571F","\u2F20":"\u571F","\u{2F855}":"\u578B","\u{2F852}":"\u57CE",\u39B3:"\u363D","\u{2F853}":"\u57F4","\u{2F854}":"\u580D","\u{2F857}":"\u5831","\u{2F856}":"\u5832","\uFA39":"\u5840",\uFA10:"\u585A","\uFA7C":"\u585A",\uF96C:"\u585E",\u586B:"\u5861",\u58FF:"\u58AB","\u{2F858}":"\u58AC","\uFA7D":"\u58B3",\uF94A:"\u58D8",\uF942:"\u58DF","\u{2F859}":"\u{214E4}","\u{2F851}":"\u58EE","\u{2F85A}":"\u58F2","\u{2F85B}":"\u58F7","\u2F21":"\u5902","\u{2F85C}":"\u5906","\u2F22":"\u590A",\u30BF:"\u5915","\u2F23":"\u5915","\u{2F85D}":"\u591A","\u{2F85E}":"\u5922","\u2F24":"\u5927","\uFA7E":"\u5944",\uF90C:"\u5948",\uF909:"\u5951","\uFA7F":"\u5954","\u{2F85F}":"\u5962",\uF981:"\u5973","\u2F25":"\u5973","\u{2F860}":"\u{216A8}","\u{2F861}":"\u{216EA}","\u{2F865}":"\u59D8","\u{2F862}":"\u59EC","\u{2F863}":"\u5A1B","\u{2F864}":"\u5A27","\uFA80":"\u5A62","\u{2F866}":"\u5A66",\u5B00:"\u5AAF","\u{2F867}":"\u36EE","\u{2F868}":"\u36FC","\u{2F986}":"\u5AB5","\u{2F869}":"\u5B08","\uFA81":"\u5B28","\u{2F86A}":"\u5B3E","\u{2F86B}":"\u5B3E","\u2F26":"\u5B50","\u2F27":"\u5B80",\uFA04:"\u5B85","\u{2F86C}":"\u{219C8}","\u{2F86D}":"\u5BC3","\u{2F86E}":"\u5BD8",\uF95F:"\u5BE7",\uF9AA:"\u5BE7","\u{2F86F}":"\u5BE7",\uF9BC:"\u5BEE","\u{2F870}":"\u5BF3","\u{2F871}":"\u{21B18}","\u2F28":"\u5BF8","\u{2F872}":"\u5BFF","\u{2F873}":"\u5C06","\u2F29":"\u5C0F","\u{2F875}":"\u5C22","\u2E90":"\u5C22","\u2F2A":"\u5C22","\u2E8F":"\u5C23","\u{2F876}":"\u3781","\u2F2B":"\u5C38",\uF9BD:"\u5C3F","\u{2F877}":"\u5C60",\uF94B:"\u5C62","\uFA3B":"\u5C64",\uF9DF:"\u5C65","\uFA3C":"\u5C6E","\u{2F878}":"\u5C6E","\u2F2C":"\u5C6E","\u{2F8F8}":"\u{21D0B}","\u2F2D":"\u5C71","\u{2F879}":"\u5CC0","\u{2F87A}":"\u5C8D","\u{2F87B}":"\u{21DE4}","\u{2F87D}":"\u{21DE6}",\uF9D5:"\u5D19","\u{2F87C}":"\u5D43",\uF921:"\u5D50","\u{2F87F}":"\u5D6B","\u{2F87E}":"\u5D6E","\u{2F880}":"\u5D7C","\u{2F9F4}":"\u5DB2",\uF9AB:"\u5DBA","\u2F2E":"\u5DDB","\u{2F882}":"\u5DE2",\u30A8:"\u5DE5","\u2F2F":"\u5DE5","\u2F30":"\u5DF1","\u2E92":"\u5DF3","\u{2F883}":"\u382F","\u{2F884}":"\u5DFD","\u2F31":"\u5DFE",\u5E32:"\u5E21","\u{2F885}":"\u5E28","\u{2F886}":"\u5E3D","\u{2F887}":"\u5E69","\u{2F888}":"\u3862","\u{2F889}":"\u{22183}","\u2F32":"\u5E72",\uF98E:"\u5E74","\u{2F939}":"\u{2219F}","\u2E93":"\u5E7A","\u2F33":"\u5E7A","\u2F34":"\u5E7F",\uFA01:"\u5EA6","\u{2F88A}":"\u387C","\u{2F88B}":"\u5EB0","\u{2F88C}":"\u5EB3","\u{2F88D}":"\u5EB6",\uF928:"\u5ECA","\u{2F88E}":"\u5ECA",\uF9A2:"\u5EC9","\uFA82":"\u5ED2",\uFA0B:"\u5ED3","\uFA83":"\u5ED9",\uF982:"\u5EEC","\u2F35":"\u5EF4","\u{2F890}":"\u5EFE","\u2F36":"\u5EFE","\u{2F891}":"\u{22331}","\u{2F892}":"\u{22331}",\uF943:"\u5F04","\u2F37":"\u5F0B","\u2F38":"\u5F13","\u{2F894}":"\u5F22","\u{2F895}":"\u5F22","\u2F39":"\u5F50","\u2E94":"\u5F51","\u{2F874}":"\u5F53","\u{2F896}":"\u38C7","\u2F3A":"\u5F61","\u{2F899}":"\u5F62","\uFA84":"\u5F69","\u{2F89A}":"\u5F6B","\u2F3B":"\u5F73",\uF9D8:"\u5F8B","\u{2F89B}":"\u38E3","\u{2F89C}":"\u5F9A",\uF966:"\u5FA9","\uFA85":"\u5FAD","\u2F3C":"\u5FC3","\u2E96":"\u5FC4","\u2E97":"\u38FA","\u{2F89D}":"\u5FCD","\u{2F89E}":"\u5FD7",\uF9A3:"\u5FF5","\u{2F89F}":"\u5FF9",\uF960:"\u6012",\uF9AC:"\u601C","\uFA6B":"\u6075","\u{2F8A2}":"\u391C","\u{2F8A1}":"\u393A","\u{2F8A0}":"\u6081","\uFA3D":"\u6094","\u{2F8A3}":"\u6094","\u{2F8A5}":"\u60C7","\uFA86":"\u60D8",\uF9B9:"\u60E1","\u{2F8A4}":"\u{226D4}","\uFA88":"\u6108","\uFA3E":"\u6168",\uF9D9:"\u6144","\u{2F8A6}":"\u6148","\u{2F8A7}":"\u614C","\u{2F8A9}":"\u614C","\uFA87":"\u614E","\u{2F8A8}":"\u614E","\uFA8A":"\u6160","\u{2F8AA}":"\u617A","\uFA3F":"\u618E","\uFA89":"\u618E","\u{2F8AB}":"\u618E",\uF98F:"\u6190","\u{2F8AD}":"\u61A4","\u{2F8AE}":"\u61AF","\u{2F8AC}":"\u61B2","\uFAD0":"\u{22844}","\uFACF":"\u{2284A}","\u{2F8AF}":"\u61DE","\uFA40":"\u61F2","\uFA8B":"\u61F2","\u{2F8B0}":"\u61F2",\uF90D:"\u61F6","\u{2F8B1}":"\u61F6",\uF990:"\u6200","\u2F3D":"\u6208","\u{2F8B2}":"\u6210","\u{2F8B3}":"\u621B",\uF9D2:"\u622E","\uFA8C":"\u6234","\u2F3E":"\u6236",\u6238:"\u6236","\u2F3F":"\u624B","\u2E98":"\u624C","\u{2F8B4}":"\u625D","\u{2F8B5}":"\u62B1",\uF925:"\u62C9",\uF95B:"\u62CF",\uFA02:"\u62D3","\u{2F8B6}":"\u62D4","\u{2F8BA}":"\u62FC",\uF973:"\u62FE","\u{2F8B8}":"\u{22B0C}","\u{2F8B9}":"\u633D","\u{2F8B7}":"\u6350","\u{2F8BB}":"\u6368",\uF9A4:"\u637B","\u{2F8BC}":"\u6383",\uF975:"\u63A0","\u{2F8C1}":"\u63A9","\uFA8D":"\u63C4","\u{2F8BD}":"\u63E4","\uFA8F":"\u6452","\u{2F8BE}":"\u{22BF1}","\uFA8E":"\u641C","\u{2F8BF}":"\u6422","\u{2F8C0}":"\u63C5","\u{2F8C3}":"\u6469","\u{2F8C6}":"\u6477","\u{2F8C4}":"\u647E","\u{2F8C2}":"\u3A2E",\u6409:"\u3A41",\uF991:"\u649A","\u{2F8C5}":"\u649D",\uF930:"\u64C4","\u{2F8C7}":"\u3A6C","\u2F40":"\u652F","\u2F41":"\u6534","\u2E99":"\u6535","\uFA41":"\u654F","\u{2F8C8}":"\u654F","\uFA90":"\u6556","\u{2F8C9}":"\u656C",\uF969:"\u6578","\u{2F8CA}":"\u{2300A}","\u2F42":"\u6587","\u2EEB":"\u6589","\u2F43":"\u6597",\uF9BE:"\u6599","\u2F44":"\u65A4","\u2F45":"\u65B9",\uF983:"\u65C5","\u2F46":"\u65E0","\u2E9B":"\u65E1","\uFA42":"\u65E2","\u{2F8CB}":"\u65E3","\u2F47":"\u65E5",\uF9E0:"\u6613",\u66F6:"\u3ADA","\u{2F8D1}":"\u3AE4","\u{2F8CD}":"\u6649",\u6669:"\u665A",\uFA12:"\u6674","\uFA91":"\u6674","\uFA43":"\u6691","\u{2F8CF}":"\u6691",\uF9C5:"\u6688","\u{2F8D0}":"\u3B08","\u{2F8D5}":"\u669C",\uFA06:"\u66B4",\uF98B:"\u66C6","\u{2F8CE}":"\u3B19","\u{2F897}":"\u{232B8}","\u2F48":"\u66F0",\uF901:"\u66F4","\u{2F8CC}":"\u66F8","\u2F49":"\u6708","\u{2F980}":"\u{2335F}",\u80A6:"\u670C",\u80D0:"\u670F",\u80CA:"\u6710",\u8101:"\u6713",\u80F6:"\u3B35",\uF929:"\u6717","\uFA92":"\u6717","\u{2F8D8}":"\u6717",\u8127:"\u6718","\uFA93":"\u671B","\u{2F8D9}":"\u671B",\u5E50:"\u3B3A",\u4420:"\u3B3B","\u{2F989}":"\u{23393}",\u81A7:"\u6723","\u{2F98A}":"\u{2339C}","\u2F4A":"\u6728",\uF9E1:"\u674E","\u{2F8DC}":"\u6753","\uFA94":"\u6756","\u{2F8DB}":"\u675E","\u{2F8DD}":"\u{233C3}",\u67FF:"\u676E",\uF9C8:"\u677B","\u{2F8E0}":"\u6785",\uF9F4:"\u6797","\u{2F8DE}":"\u3B49","\uFAD1":"\u{233D5}",\uF9C9:"\u67F3","\u{2F8DF}":"\u67FA",\uF9DA:"\u6817","\u{2F8E5}":"\u681F","\u{2F8E1}":"\u6852","\u{2F8E3}":"\u{2346D}",\uF97A:"\u6881","\uFA44":"\u6885","\u{2F8E2}":"\u6885","\u{2F8E4}":"\u688E",\uF9E2:"\u68A8","\u{2F8E6}":"\u6914","\u{2F8E8}":"\u6942","\uFAD2":"\u3B9D","\u{2F8E7}":"\u3B9D",\u69E9:"\u3BA3",\u6A27:"\u699D","\u{2F8E9}":"\u69A3","\u{2F8EA}":"\u69EA",\uF914:"\u6A02",\uF95C:"\u6A02",\uF9BF:"\u6A02",\uF94C:"\u6A13","\u{2F8EC}":"\u{236A3}","\u{2F8EB}":"\u6AA8",\uF931:"\u6AD3","\u{2F8ED}":"\u6ADB",\uF91D:"\u6B04","\u{2F8EE}":"\u3C18","\u2F4B":"\u6B20","\u{2F8EF}":"\u6B21","\u{2F8F0}":"\u{238A7}","\u{2F8F1}":"\u6B54","\u{2F8F2}":"\u3C4E","\u2F4C":"\u6B62","\u2EED":"\u6B6F","\u{2F8F3}":"\u6B72",\uF98C:"\u6B77","\uFA95":"\u6B79","\u2F4D":"\u6B79","\u2E9E":"\u6B7A","\u{2F8F4}":"\u6B9F",\uF9A5:"\u6BAE","\u2F4E":"\u6BB3",\uF970:"\u6BBA","\uFA96":"\u6BBA","\u{2F8F5}":"\u6BBA","\u{2F8F6}":"\u6BBB","\u{2F8F7}":"\u{23A8D}","\u2F4F":"\u6BCB","\u2E9F":"\u6BCD","\u{2F8F9}":"\u{23AFA}","\u2F50":"\u6BD4","\u2F51":"\u6BDB","\u2F52":"\u6C0F","\u2EA0":"\u6C11","\u2F53":"\u6C14","\u2F54":"\u6C34","\u2EA1":"\u6C35","\u2EA2":"\u6C3A","\u{2F8FA}":"\u6C4E","\u{2F8FE}":"\u6C67",\uF972:"\u6C88","\u{2F8FC}":"\u6CBF",\uF968:"\u6CCC","\u{2F8FD}":"\u6CCD",\uF9E3:"\u6CE5","\u{2F8FB}":"\u{23CBC}",\uF915:"\u6D1B",\uFA05:"\u6D1E","\u{2F907}":"\u6D34","\u{2F900}":"\u6D3E",\uF9CA:"\u6D41","\uFA97":"\u6D41","\u{2F902}":"\u6D41","\u{2F8FF}":"\u6D16","\u{2F903}":"\u6D69",\uF92A:"\u6D6A","\uFA45":"\u6D77","\u{2F901}":"\u6D77","\u{2F904}":"\u6D78","\u{2F905}":"\u6D85","\u{2F906}":"\u{23D1E}",\uF9F5:"\u6DCB",\uF94D:"\u6DDA",\uF9D6:"\u6DEA","\u{2F90E}":"\u6DF9","\uFA46":"\u6E1A","\u{2F908}":"\u6E2F","\u{2F909}":"\u6E6E",\u6F59:"\u6E88","\uFA99":"\u6ECB","\u{2F90B}":"\u6ECB",\uF9CB:"\u6E9C",\uF9EC:"\u6EBA","\u{2F90C}":"\u6EC7",\uF904:"\u6ED1","\uFA98":"\u6EDB","\u{2F90A}":"\u3D33",\uF94E:"\u6F0F","\uFA47":"\u6F22","\uFA9A":"\u6F22",\uF992:"\u6F23","\u{2F90D}":"\u{23ED1}","\u{2F90F}":"\u6F6E","\u{2F910}":"\u{23F5E}","\u{2F911}":"\u{23F8E}","\u{2F912}":"\u6FC6",\uF922:"\u6FEB",\uF984:"\u6FFE","\u{2F915}":"\u701B","\uFA9B":"\u701E","\u{2F914}":"\u701E","\u{2F913}":"\u7039","\u{2F917}":"\u704A","\u{2F916}":"\u3D96","\u2F55":"\u706B","\u2EA3":"\u706C","\u{2F835}":"\u7070","\u{2F919}":"\u7077","\u{2F918}":"\u707D",\uF9FB:"\u7099","\u{2F91A}":"\u70AD",\uF99F:"\u70C8",\uF916:"\u70D9","\uFA48":"\u716E","\uFA9C":"\u716E","\u{2F91D}":"\u{24263}","\u{2F91C}":"\u7145",\uF993:"\u7149","\uFA6C":"\u{242EE}","\u{2F91E}":"\u719C",\uF9C0:"\u71CE",\uF9EE:"\u71D0","\u{2F91F}":"\u{243AB}",\uF932:"\u7210",\uF91E:"\u721B","\u{2F920}":"\u7228","\u2F56":"\u722A","\uFA49":"\u722B","\u2EA4":"\u722B","\uFA9E":"\u7235","\u{2F921}":"\u7235","\u2F57":"\u7236","\u2F58":"\u723B","\u2EA6":"\u4E2C","\u2F59":"\u723F","\u2F5A":"\u7247","\u{2F922}":"\u7250","\u2F5B":"\u7259","\u{2F923}":"\u{24608}","\u2F5C":"\u725B",\uF946:"\u7262","\u{2F924}":"\u7280","\u{2F925}":"\u7295","\u2F5D":"\u72AC","\u2EA8":"\u72AD","\uFA9F":"\u72AF",\uF9FA:"\u72C0","\u{2F926}":"\u{24735}",\uF92B:"\u72FC",\uFA16:"\u732A","\uFAA0":"\u732A","\u{2F927}":"\u{24814}",\uF9A7:"\u7375","\u{2F928}":"\u737A","\u2F5E":"\u7384",\uF961:"\u7387",\uF9DB:"\u7387","\u2F5F":"\u7389","\u{2F929}":"\u738B","\u{2F92A}":"\u3EAC","\u{2F92B}":"\u73A5",\uF9AD:"\u73B2","\u{2F92C}":"\u3EB8","\u{2F92D}":"\u3EB8",\uF917:"\u73DE",\uF9CC:"\u7409",\uF9E4:"\u7406","\uFA4A":"\u7422","\u{2F92E}":"\u7447","\u{2F92F}":"\u745C",\uF9AE:"\u7469","\uFAA1":"\u7471","\u{2F930}":"\u7471","\u{2F931}":"\u7485",\uF994:"\u7489",\uF9EF:"\u7498","\u{2F932}":"\u74CA","\u2F60":"\u74DC","\u2F61":"\u74E6","\u{2F933}":"\u3F1B","\uFAA2":"\u7506","\u2F62":"\u7518","\u2F63":"\u751F","\u{2F934}":"\u7524","\u2F64":"\u7528","\u2F65":"\u7530","\uFAA3":"\u753B","\u{2F936}":"\u753E","\u{2F935}":"\u{24C36}",\uF9CD:"\u7559",\uF976:"\u7565",\uF962:"\u7570","\u{2F938}":"\u7570","\u{2F937}":"\u{24C92}","\u2F66":"\u758B","\u2F67":"\u7592",\uF9E5:"\u75E2","\u{2F93A}":"\u7610","\uFAA5":"\u761F","\uFAA4":"\u761D",\uF9C1:"\u7642",\uF90E:"\u7669","\u2F68":"\u7676","\u2F69":"\u767D","\u{2F93B}":"\u{24FA1}","\u{2F93C}":"\u{24FB8}","\u2F6A":"\u76AE","\u2F6B":"\u76BF","\u{2F93D}":"\u{25044}","\u{2F93E}":"\u3FFC",\uFA17:"\u76CA","\uFAA6":"\u76CA","\uFAA7":"\u76DB",\uF933:"\u76E7","\u{2F93F}":"\u4008","\u2F6C":"\u76EE","\uFAA8":"\u76F4","\u{2F940}":"\u76F4","\u{2F942}":"\u{250F2}","\u{2F941}":"\u{250F3}",\uF96D:"\u7701","\uFAD3":"\u4018","\u{2F943}":"\u{25119}","\u{2F945}":"\u771E","\u{2F946}":"\u771F","\u{2F947}":"\u771F","\u{2F944}":"\u{25133}","\uFAAA":"\u7740","\uFAA9":"\u774A","\u{2F948}":"\u774A","\u9FC3":"\u4039","\uFAD4":"\u4039","\u{2F949}":"\u4039",\u6663:"\u403F","\u{2F94B}":"\u4046","\u{2F94A}":"\u778B","\uFAD5":"\u{25249}","\uFA9D":"\u77A7","\u2F6D":"\u77DB","\u2F6E":"\u77E2","\u2F6F":"\u77F3","\u{2F94C}":"\u4096","\u{2F94D}":"\u{2541D}",\u784F:"\u7814","\u{2F94E}":"\u784E",\uF9CE:"\u786B",\uF93B:"\u788C","\u{2F94F}":"\u788C","\uFA4B":"\u7891",\uF947:"\u78CA","\uFAAB":"\u78CC","\u{2F950}":"\u78CC",\uF964:"\u78FB","\u{2F951}":"\u40E3",\uF985:"\u792A","\u2F70":"\u793A","\u2EAD":"\u793B",\uFA18:"\u793C","\uFA4C":"\u793E","\uFA4E":"\u7948","\uFA4D":"\u7949","\u{2F952}":"\u{25626}","\uFA4F":"\u7950","\uFA50":"\u7956","\u{2F953}":"\u7956","\uFA51":"\u795D",\uFA19:"\u795E",\uFA1A:"\u7965","\uFA61":"\u8996","\uFAB8":"\u8996",\uF93C:"\u797F","\u{2F954}":"\u{2569A}","\uFA52":"\u798D","\uFA53":"\u798E",\uFA1B:"\u798F","\u{2F956}":"\u798F","\u{2F955}":"\u{256C5}",\uF9B6:"\u79AE","\u2F71":"\u79B8","\u2F72":"\u79BE",\uF995:"\u79CA","\u{2F958}":"\u412F","\u{2F957}":"\u79EB",\uF956:"\u7A1C","\u{2F95A}":"\u7A4A","\uFA54":"\u7A40","\u{2F959}":"\u7A40","\u{2F95B}":"\u7A4F","\u2F73":"\u7A74","\uFA55":"\u7A81","\u{2F95C}":"\u{2597C}","\uFAAC":"\u7AB1",\uF9F7:"\u7ACB","\u2F74":"\u7ACB","\u2EEF":"\u7ADC","\u{2F95D}":"\u{25AA7}","\u{2F95E}":"\u{25AA7}","\u{2F95F}":"\u7AEE","\u2F75":"\u7AF9",\uF9F8:"\u7B20","\uFA56":"\u7BC0","\uFAAD":"\u7BC0","\u{2F960}":"\u4202","\u{2F961}":"\u{25BAB}","\u{2F962}":"\u7BC6","\u{2F964}":"\u4227","\u{2F963}":"\u7BC9","\u{2F965}":"\u{25C80}","\uFAD6":"\u{25CD0}",\uF9A6:"\u7C3E",\uF944:"\u7C60","\u2F76":"\u7C73","\uFAAE":"\u7C7B",\uF9F9:"\u7C92",\uFA1D:"\u7CBE","\u{2F966}":"\u7CD2",\uFA03:"\u7CD6","\u{2F968}":"\u7CE8","\u{2F967}":"\u42A0","\u{2F969}":"\u7CE3",\uF97B:"\u7CE7","\u2F77":"\u7CF8","\u2EAF":"\u7CF9","\u{2F96B}":"\u{25F86}","\u{2F96A}":"\u7D00",\uF9CF:"\u7D10",\uF96A:"\u7D22",\uF94F:"\u7D2F",\u7D76:"\u7D55","\u{2F96C}":"\u7D63","\uFAAF":"\u7D5B",\uF93D:"\u7DA0",\uF957:"\u7DBE","\u{2F96E}":"\u7DC7",\uF996:"\u7DF4","\uFA57":"\u7DF4","\uFAB0":"\u7DF4","\u{2F96F}":"\u7E02","\u{2F96D}":"\u4301","\uFA58":"\u7E09",\uF950:"\u7E37","\uFA59":"\u7E41","\u{2F970}":"\u7E45","\u{2F898}":"\u{261DA}","\u{2F971}":"\u4334","\u2F78":"\u7F36","\u{2F972}":"\u{26228}","\uFAB1":"\u7F3E","\u{2F973}":"\u{26247}","\u2F79":"\u7F51","\u2EAB":"\u7F52","\u2EB2":"\u7F52","\u2EB1":"\u7F53","\u{2F974}":"\u4359","\uFA5A":"\u7F72","\u{2F975}":"\u{262D9}",\uF9E6:"\u7F79","\u{2F976}":"\u7F7A",\uF90F:"\u7F85","\u{2F977}":"\u{2633E}","\u2F7A":"\u7F8A","\u{2F978}":"\u7F95",\uF9AF:"\u7F9A",\uFA1E:"\u7FBD","\u2F7B":"\u7FBD","\u{2F979}":"\u7FFA",\uF934:"\u8001","\u2F7C":"\u8001","\u2EB9":"\u8002","\uFA5B":"\u8005","\uFAB2":"\u8005","\u{2F97A}":"\u8005","\u2F7D":"\u800C","\u{2F97B}":"\u{264DA}","\u2F7E":"\u8012","\u{2F97C}":"\u{26523}","\u2F7F":"\u8033",\uF9B0:"\u8046","\u{2F97D}":"\u8060","\u{2F97E}":"\u{265A8}",\uF997:"\u806F","\u{2F97F}":"\u8070",\uF945:"\u807E","\u2F80":"\u807F","\u2EBA":"\u8080","\u2F81":"\u8089",\uF953:"\u808B","\u{2F8D6}":"\u80AD","\u{2F982}":"\u80B2","\u{2F981}":"\u43D5","\u{2F8D7}":"\u43D9",\u8141:"\u80FC","\u{2F983}":"\u8103","\u{2F985}":"\u813E","\u{2F984}":"\u440B","\u{2F8DA}":"\u6721","\u{2F987}":"\u{267A7}","\u{2F988}":"\u{267B5}",\u6726:"\u4443",\uF926:"\u81D8","\u2F82":"\u81E3",\uF9F6:"\u81E8","\u2F83":"\u81EA","\uFA5C":"\u81ED","\u2F84":"\u81F3","\u2F85":"\u81FC","\u{2F893}":"\u8201","\u{2F98B}":"\u8201","\u{2F98C}":"\u8204","\u2F86":"\u820C","\uFA6D":"\u8218","\u2F87":"\u821B","\u2F88":"\u821F","\u{2F98E}":"\u446B","\u2F89":"\u826E",\uF97C:"\u826F","\u2F8A":"\u8272","\u2F8B":"\u8278","\uFA5D":"\u8279","\uFA5E":"\u8279","\u2EBE":"\u8279","\u2EBF":"\u8279","\u2EC0":"\u8279","\u{2F990}":"\u828B","\u{2F98F}":"\u8291","\u{2F991}":"\u829D","\u{2F993}":"\u82B1","\u{2F994}":"\u82B3","\u{2F995}":"\u82BD",\uF974:"\u82E5","\u{2F998}":"\u82E5","\u{2F996}":"\u82E6","\u{2F997}":"\u{26B3C}",\uF9FE:"\u8336","\uFAB3":"\u8352","\u{2F99A}":"\u8363","\u{2F999}":"\u831D","\u{2F99C}":"\u8323","\u{2F99D}":"\u83BD","\u{2F9A0}":"\u8353",\uF93E:"\u83C9","\u{2F9A1}":"\u83CA","\u{2F9A2}":"\u83CC","\u{2F9A3}":"\u83DC","\u{2F99E}":"\u83E7","\uFAB4":"\u83EF",\uF958:"\u83F1","\uFA5F":"\u8457","\u{2F99F}":"\u8457","\u{2F9A4}":"\u{26C36}","\u{2F99B}":"\u83AD",\uF918:"\u843D",\uF96E:"\u8449",\u853F:"\u848D","\u{2F9A6}":"\u{26CD5}","\u{2F9A5}":"\u{26D6B}",\uF999:"\u84EE","\u{2F9A8}":"\u84F1","\u{2F9A9}":"\u84F3",\uF9C2:"\u84FC","\u{2F9AA}":"\u8516","\u{2F9A7}":"\u452B","\u{2F9AC}":"\u8564","\u{2F9AD}":"\u{26F2C}",\uF923:"\u85CD","\u{2F9AE}":"\u455D","\u{2F9B0}":"\u{26FB1}","\u{2F9AF}":"\u4561",\uF9F0:"\u85FA",\uF935:"\u8606","\u{2F9B2}":"\u456B",\uFA20:"\u8612",\uF91F:"\u862D","\u{2F9B1}":"\u{270D2}",\u8641:"\u8637",\uF910:"\u863F","\u2F8C":"\u864D","\u2EC1":"\u864E","\u{2F9B3}":"\u8650",\uF936:"\u865C","\u{2F9B4}":"\u865C","\u{2F9B5}":"\u8667","\u{2F9B6}":"\u8669","\u2F8D":"\u866B","\u{2F9B7}":"\u86A9","\u{2F9B8}":"\u8688","\u{2F9BA}":"\u86E2","\u{2F9B9}":"\u870E","\u{2F9BC}":"\u8728","\u{2F9BD}":"\u876B","\u{2F9C0}":"\u87E1","\uFAB5":"\u8779","\u{2F9BB}":"\u8779","\u{2F9BE}":"\u8786","\u{2F9BF}":"\u45D7","\u{2F9AB}":"\u{273CA}",\uF911:"\u87BA","\u{2F9C1}":"\u8801","\u{2F9C2}":"\u45F9",\uF927:"\u881F","\u2F8E":"\u8840",\uFA08:"\u884C","\u2F8F":"\u884C","\u{2F9C3}":"\u8860","\u{2F9C4}":"\u8863","\u2F90":"\u8863","\u2EC2":"\u8864",\uF9A0:"\u88C2","\u{2F9C5}":"\u{27667}",\uF9E7:"\u88CF","\u{2F9C6}":"\u88D7","\u{2F9C7}":"\u88DE",\uF9E8:"\u88E1",\uF912:"\u88F8","\u{2F9C9}":"\u88FA","\u{2F9C8}":"\u4635","\uFA60":"\u8910","\uFAB6":"\u8941",\uF924:"\u8964","\u2F91":"\u897E","\u2EC4":"\u897F","\u2EC3":"\u8980","\uFAB7":"\u8986",\uFA0A:"\u898B","\u2F92":"\u898B","\u{2F9CB}":"\u{278AE}","\u2EC5":"\u89C1","\u2F93":"\u89D2","\u2F94":"\u8A00","\u{2F9CC}":"\u{27966}",\u8A7D:"\u8A2E",\u8A1E:"\u46B6","\u{2F9CD}":"\u46BE","\u{2F9CE}":"\u46C7","\u{2F9CF}":"\u8AA0",\uF96F:"\u8AAA",\uF9A1:"\u8AAA","\uFAB9":"\u8ABF","\uFABB":"\u8ACB",\uF97D:"\u8AD2",\uF941:"\u8AD6","\uFABE":"\u8AED","\u{2F9D0}":"\u8AED",\uFA22:"\u8AF8","\uFABA":"\u8AF8",\uF95D:"\u8AFE","\uFABD":"\u8AFE","\uFA62":"\u8B01","\uFABC":"\u8B01","\uFA63":"\u8B39","\uFABF":"\u8B39",\uF9FC:"\u8B58",\uF95A:"\u8B80",\u8B8F:"\u8B86","\uFAC0":"\u8B8A","\u{2F9D1}":"\u8B8A","\u2EC8":"\u8BA0","\u2F95":"\u8C37","\u2F96":"\u8C46",\uF900:"\u8C48","\u{2F9D2}":"\u8C55","\u2F97":"\u8C55",\u8C63:"\u8C5C","\u2F98":"\u8C78","\u{2F9D3}":"\u{27CA8}","\u2F99":"\u8C9D","\u{2F9D4}":"\u8CAB","\u{2F9D5}":"\u8CC1",\uF948:"\u8CC2",\uF903:"\u8CC8","\uFA64":"\u8CD3","\uFA65":"\u8D08","\uFAC1":"\u8D08","\u{2F9D6}":"\u8D1B","\u2EC9":"\u8D1D","\u2F9A":"\u8D64","\u2F9B":"\u8D70","\u{2F9D7}":"\u8D77",\u8D86:"\u8D7F","\uFAD7":"\u{27ED3}","\u{2F9D8}":"\u{27F2F}","\u2F9C":"\u8DB3","\u{2F9DA}":"\u8DCB","\u{2F9DB}":"\u8DBC",\u8DFA:"\u8DE5",\uF937:"\u8DEF","\u{2F9DC}":"\u8DF0",\u8E9B:"\u8E97","\u2F9D":"\u8EAB",\uF902:"\u8ECA","\u2F9E":"\u8ECA","\u{2F9DE}":"\u8ED4",\u8F27:"\u8EFF",\uF998:"\u8F26",\uF9D7:"\u8F2A","\uFAC2":"\u8F38","\u{2F9DF}":"\u8F38",\uFA07:"\u8F3B",\uF98D:"\u8F62","\u2ECB":"\u8F66","\u2F9F":"\u8F9B","\u{2F98D}":"\u8F9E",\uF971:"\u8FB0","\u2FA0":"\u8FB0","\u2FA1":"\u8FB5","\uFA66":"\u8FB6","\u2ECC":"\u8FB6","\u2ECD":"\u8FB6","\u{2F881}":"\u5DE1",\uF99A:"\u9023",\uFA25:"\u9038","\uFA67":"\u9038","\uFAC3":"\u9072",\uF9C3:"\u907C","\u{2F9E0}":"\u{285D2}","\u{2F9E1}":"\u{285ED}",\uF913:"\u908F","\u2FA2":"\u9091","\u{2F9E2}":"\u9094",\uF92C:"\u90CE",\u90DE:"\u90CE","\uFA2E":"\u90CE","\u{2F9E3}":"\u90F1",\uFA26:"\u90FD","\u{2F9E5}":"\u{2872E}","\u{2F9E4}":"\u9111","\u{2F9E6}":"\u911B","\u2FA3":"\u9149",\uF919:"\u916A","\uFAC4":"\u9199",\uF9B7:"\u91B4","\u2FA4":"\u91C6",\uF9E9:"\u91CC","\u2FA5":"\u91CC",\uF97E:"\u91CF",\uF90A:"\u91D1","\u2FA6":"\u91D1",\uF9B1:"\u9234","\u{2F9E7}":"\u9238","\uFAC5":"\u9276","\u{2F9E8}":"\u92D7","\u{2F9E9}":"\u92D8","\u{2F9EA}":"\u927C",\uF93F:"\u9304",\uF99B:"\u934A",\u93AE:"\u93AD","\u{2F9EB}":"\u93F9","\u{2F9EC}":"\u9415","\u{2F9ED}":"\u{28BFA}","\u2ED0":"\u9485","\u2ED1":"\u9577","\u2FA7":"\u9577","\u2ED2":"\u9578","\u2ED3":"\u957F","\u2FA8":"\u9580","\u{2F9EE}":"\u958B","\u{2F9EF}":"\u4995",\uF986:"\u95AD","\u{2F9F0}":"\u95B7","\u{2F9F1}":"\u{28D77}","\u2ED4":"\u95E8","\u2FA9":"\u961C","\u2ECF":"\u961D","\u2ED6":"\u961D",\uF9C6:"\u962E",\uF951:"\u964B",\uFA09:"\u964D",\uF959:"\u9675",\uF9D3:"\u9678","\uFAC6":"\u967C",\uF9DC:"\u9686",\uF9F1:"\u96A3","\u{2F9F2}":"\u49E6","\u2FAA":"\u96B6","\uFA2F":"\u96B7",\u96B8:"\u96B7",\uF9B8:"\u96B7","\u2FAB":"\u96B9","\u{2F9F3}":"\u96C3",\uF9EA:"\u96E2","\uFA68":"\u96E3","\uFAC7":"\u96E3","\u2FAC":"\u96E8",\uF9B2:"\u96F6",\uF949:"\u96F7","\u{2F9F5}":"\u9723","\u{2F9F6}":"\u{29145}",\uF938:"\u9732",\uF9B3:"\u9748","\u2FAD":"\u9751","\u2ED8":"\u9752",\uFA1C:"\u9756","\uFAC8":"\u9756","\u{2F81C}":"\u{291DF}","\u2FAE":"\u975E","\u2FAF":"\u9762","\u{2F9F7}":"\u{2921A}","\u2FB0":"\u9769","\u{2F9F8}":"\u4A6E","\u{2F9F9}":"\u4A76","\u2FB1":"\u97CB","\uFAC9":"\u97DB","\u{2F9FA}":"\u97E0","\u2ED9":"\u97E6","\u2FB2":"\u97ED","\u{2F9FB}":"\u{2940A}","\u2FB3":"\u97F3","\uFA69":"\u97FF","\uFACA":"\u97FF","\u2FB4":"\u9801","\u{2F9FC}":"\u4AB2","\uFACB":"\u980B","\u{2F9FE}":"\u980B","\u{2F9FF}":"\u980B",\uF9B4:"\u9818","\u{2FA00}":"\u9829","\u{2F9FD}":"\u{29496}","\uFA6A":"\u983B","\uFACC":"\u983B",\uF9D0:"\u985E","\u2EDA":"\u9875","\u2FB5":"\u98A8","\u{2FA01}":"\u{295B6}","\u2EDB":"\u98CE","\u2FB6":"\u98DB","\u2EDC":"\u98DE","\u2EDD":"\u98DF","\u2FB7":"\u98DF","\u2EDF":"\u98E0","\u{2FA02}":"\u98E2",\uFA2A:"\u98EF",\uFA2B:"\u98FC","\u{2FA03}":"\u4B33",\uFA2C:"\u9928","\u{2FA04}":"\u9929","\u2EE0":"\u9963","\u2FB8":"\u9996","\u2FB9":"\u9999","\u{2FA05}":"\u99A7","\u2FBA":"\u99AC","\u{2FA06}":"\u99C2",\uF91A:"\u99F1","\u{2FA07}":"\u99FE",\uF987:"\u9A6A","\u2EE2":"\u9A6C","\u2FBB":"\u9AA8","\u{2FA08}":"\u4BCE","\u2FBC":"\u9AD8","\u2FBD":"\u9ADF","\u{2FA09}":"\u{29B30}","\uFACD":"\u9B12","\u{2FA0A}":"\u9B12","\u2FBE":"\u9B25","\u2FBF":"\u9B2F","\u2FC0":"\u9B32","\u2FC1":"\u9B3C","\u2EE4":"\u9B3C","\u2FC2":"\u9B5A",\uF939:"\u9B6F","\u{2FA0B}":"\u9C40",\uF9F2:"\u9C57","\u2EE5":"\u9C7C","\u2FC3":"\u9CE5","\u{2FA0C}":"\u9CFD","\u{2FA0D}":"\u4CCE","\u{2FA0F}":"\u9D67","\u{2FA0E}":"\u4CED","\u{2FA10}":"\u{2A0CE}",\uFA2D:"\u9DB4","\u{2FA12}":"\u{2A105}","\u{2FA11}":"\u4CF8",\uF93A:"\u9DFA","\u{2FA13}":"\u{2A20E}",\uF920:"\u9E1E",\u9E43:"\u9E42","\u2FC4":"\u9E75",\uF940:"\u9E7F","\u2FC5":"\u9E7F","\u{2FA14}":"\u{2A291}",\uF988:"\u9E97",\uF9F3:"\u9E9F","\u2FC6":"\u9EA5","\u2EE8":"\u9EA6","\u{2FA15}":"\u9EBB","\u2FC7":"\u9EBB","\u{2F88F}":"\u{2A392}","\u2FC8":"\u9EC3","\u2EE9":"\u9EC4","\u2FC9":"\u9ECD",\uF989:"\u9ECE","\u{2FA16}":"\u4D56","\u2FCA":"\u9ED1",\u9ED2:"\u9ED1","\uFA3A":"\u58A8","\u{2FA17}":"\u9EF9","\u2FCB":"\u9EF9","\u2FCC":"\u9EFD","\u{2FA19}":"\u9F05","\u{2FA18}":"\u9EFE","\u2FCD":"\u9F0E","\u{2FA1A}":"\u9F0F","\u2FCE":"\u9F13","\u{2FA1B}":"\u9F16","\u2FCF":"\u9F20","\u{2FA1C}":"\u9F3B","\u2FD0":"\u9F3B","\uFAD8":"\u9F43","\u2FD1":"\u9F4A","\u2EEC":"\u9F50","\u2FD2":"\u9F52","\u{2FA1D}":"\u{2A600}","\u2EEE":"\u9F7F",\uF9C4:"\u9F8D","\u2FD3":"\u9F8D","\uFAD9":"\u9F8E","\u2EF0":"\u9F99",\uF907:"\u9F9C",\uF908:"\u9F9C","\uFACE":"\u9F9C","\u2FD4":"\u9F9C","\u2EF3":"\u9F9F","\u2FD5":"\u9FA0"},Hy=ew;function tw(n){return n.replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")}var rw=RegExp(Object.keys(Hy).map(tw).join("|"),"g");function nw(n){return Hy[n]}function iw(n){return n.replace(rw,nw)}var sw=iw,Xa={exports:{}},Yy={};function Nr(n,e){typeof e=="boolean"&&(e={forever:e}),this._originalTimeouts=JSON.parse(JSON.stringify(n)),this._timeouts=n,this._options=e||{},this._maxRetryTime=e&&e.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}var ow=Nr;Nr.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};Nr.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};Nr.prototype.retry=function(n){if(this._timeout&&clearTimeout(this._timeout),!n)return!1;var e=new Date().getTime();if(n&&e-this._operationStart>=this._maxRetryTime)return this._errors.push(n),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(n);var t=this._timeouts.shift();if(t===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),t=this._cachedTimeouts.slice(-1);else return!1;var r=this;return this._timer=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},t),this._options.unref&&this._timer.unref(),!0};Nr.prototype.attempt=function(n,e){this._fn=n,e&&(e.timeout&&(this._operationTimeout=e.timeout),e.cb&&(this._operationTimeoutCb=e.cb));var t=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){t._operationTimeoutCb()},t._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};Nr.prototype.try=function(n){console.log("Using RetryOperation.try() is deprecated"),this.attempt(n)};Nr.prototype.start=function(n){console.log("Using RetryOperation.start() is deprecated"),this.attempt(n)};Nr.prototype.start=Nr.prototype.try;Nr.prototype.errors=function(){return this._errors};Nr.prototype.attempts=function(){return this._attempts};Nr.prototype.mainError=function(){if(this._errors.length===0)return null;for(var n={},e=null,t=0,r=0;r<this._errors.length;r++){var i=this._errors[r],s=i.message,o=(n[s]||0)+1;n[s]=o,o>=t&&(e=i,t=o)}return e};(function(n){var e=ow;n.operation=function(t){var r=n.timeouts(t);return new e(r,{forever:t&&(t.forever||t.retries===1/0),unref:t&&t.unref,maxRetryTime:t&&t.maxRetryTime})},n.timeouts=function(t){if(t instanceof Array)return[].concat(t);var r={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var i in t)r[i]=t[i];if(r.minTimeout>r.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var s=[],o=0;o<r.retries;o++)s.push(this.createTimeout(o,r));return t&&t.forever&&!s.length&&s.push(this.createTimeout(o,r)),s.sort(function(a,l){return a-l}),s},n.createTimeout=function(t,r){var i=r.randomize?Math.random()+1:1,s=Math.round(i*Math.max(r.minTimeout,1)*Math.pow(r.factor,t));return s=Math.min(s,r.maxTimeout),s},n.wrap=function(t,r,i){if(r instanceof Array&&(i=r,r=null),!i){i=[];for(var s in t)typeof t[s]=="function"&&i.push(s)}for(var o=0;o<i.length;o++){var a=i[o],l=t[a];t[a]=function(c){var g=n.operation(r),m=Array.prototype.slice.call(arguments,1),f=m.pop();m.push(function(E){g.retry(E)||(E&&(arguments[0]=g.mainError()),f.apply(this,arguments))}),g.attempt(function(){c.apply(t,m)})}.bind(t,l),t[a].options=r}}})(Yy);var aw=Yy;const cw=aw,lw=["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"];class zy extends Error{constructor(e){super();e instanceof Error?(this.originalError=e,{message:e}=e):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}}const uw=(n,e,t)=>{const r=t.retries-(e-1);return n.attemptNumber=e,n.retriesLeft=r,n},dw=n=>lw.includes(n),Jy=(n,e)=>new Promise((t,r)=>{e=gc({onFailedAttempt:()=>{},retries:10},e);const i=cw.operation(e);i.attempt(async s=>{try{t(await n(s))}catch(o){if(!(o instanceof Error)){r(new TypeError(`Non-error was thrown: "${o}". You should only throw errors.`));return}if(o instanceof zy)i.stop(),r(o.originalError);else if(o instanceof TypeError&&!dw(o.message))i.stop(),r(o);else{uw(o,s,e);try{await e.onFailedAttempt(o)}catch(a){r(a);return}i.retry(o)||r(i.mainError())}}})});Xa.exports=Jy;Xa.exports.default=Jy;Xa.exports.AbortError=zy;var Xy=G.exports;Object.defineProperty(W,"__esModule",{value:!0});W.DEFAULT_ALPHABET=void 0;W.alphabetPad=Bd;W.averageBetweenStrings=Bw;W.baseToString=Io;W.checkObjectHasKeys=_w;W.checkObjectHasNoAdditionalKeys=Ew;W.chunkPromises=Uw;W.compare=jw;W.decodeParams=gw;W.deepCompare=Ld;W.deepCopy=Sw;W.deepSortedObjectEntries=Qy;W.defer=Aw;W.encodeParams=pw;W.encodeUri=mw;W.ensureNoTrailingSlash=Cw;W.escapeRegExp=ev;W.getCrypto=Lw;W.globToRegexp=kw;W.inherits=bw;W.isFunction=vw;W.isNullOrUndefined=Mw;W.isNumber=Rw;W.lexicographicCompare=rv;W.nextString=Kw;W.normalize=Tw;W.polyfillSuper=ww;W.prevString=Fw;W.promiseMapSeries=Dw;W.promiseTry=xw;W.recursivelyAssign=nv;W.removeDirectionOverrideChars=Iw;W.removeElement=yw;W.removeHiddenChars=Zy;W.setCrypto=Nw;W.simpleRetryOperation=$w;W.sleep=Pw;W.stringToBase=La;var hw=Xy(sw),fw=Xy(Xa.exports);function pw(n){const e=new URLSearchParams;for(const[t,r]of Object.entries(n))r!=null&&e.set(t,String(r));return e.toString()}function gw(n){const e={},t=new URLSearchParams(n);for(const r of t.keys()){const i=t.getAll(r);e[r]=i.length===1?i[0]:i}return e}function mw(n,e){for(const t in e)!e.hasOwnProperty(t)||(n=n.replace(t,encodeURIComponent(e[t])));return n}function yw(n,e,t){let r;if(t){for(r=n.length-1;r>=0;r--)if(e(n[r],r,n))return n.splice(r,1),!0}else for(r=0;r<n.length;r++)if(e(n[r],r,n))return n.splice(r,1),!0;return!1}function vw(n){return Object.prototype.toString.call(n)==="[object Function]"}function _w(n,e){for(let t=0;t<e.length;t++)if(!n.hasOwnProperty(e[t]))throw new Error("Missing required key: "+e[t])}function Ew(n,e){for(const t in n)if(!!n.hasOwnProperty(t)&&e.indexOf(t)===-1)throw new Error("Unknown key: "+t)}function Sw(n){return JSON.parse(JSON.stringify(n))}function Ld(n,e){if(n===e)return!0;if(typeof n!=typeof e)return!1;if(typeof n=="number"&&isNaN(n)&&isNaN(e))return!0;if(n===null||e===null)return n===e;if(!(n instanceof Object)||n.constructor!==e.constructor||n.prototype!==e.prototype)return!1;if(n instanceof RegExp||n instanceof Date)return n.toString()===e.toString();if(n instanceof Array){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(!Ld(n[t],e[t]))return!1}else{let t;for(t in e)if(e.hasOwnProperty(t)!==n.hasOwnProperty(t))return!1;for(t in e)if(e.hasOwnProperty(t)!==n.hasOwnProperty(t)||!Ld(n[t],e[t]))return!1}return!0}function Qy(n){if(typeof n!="object"||n==null||Array.isArray(n))return n;const e=[];for(const[t,r]of Object.entries(n))e.push([t,Qy(r)]);return e.sort((t,r)=>rv(t[0],r[0])),e}function bw(n,e){n.super_=e,n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}})}function ww(n,e,...t){try{e.call(n,...t)}catch{const i=new e(...t);Object.assign(n,i)}}function Rw(n){return typeof n=="number"&&isFinite(n)}function Zy(n){return typeof n=="string"?(0,hw.default)(n.normalize("NFD").replace(Ow,"")):""}function Iw(n){return typeof n=="string"?n.replace(/[\u202d-\u202e]/g,""):""}function Tw(n){return Zy(n.toLowerCase()).replace(/[\\'!"#$%&()*+,\-./:;<=>?@[\]^_`{|}~\u2000-\u206f\u2e00-\u2e7f]/g,"").toLowerCase()}const Ow=/[\u2000-\u200F\u202A-\u202F\u0300-\u036F\uFEFF\u061C\s]/g;function ev(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function kw(n,e){e=typeof e=="boolean"?e:!0;let t=ev(n);return t=t.replace(/\\\*/g,".*"),t=t.replace(/\?/g,"."),e&&(t=t.replace(/\\\[(!|)(.*)\\]/g,function(r,i,s,o,a){const l=i&&"^"||"",u=s.replace(/\\-/,"-");return"["+l+u+"]"})),t}function Cw(n){return n&&n.endsWith("/")?n.substr(0,n.length-1):n}function Pw(n,e){return new Promise(t=>{setTimeout(t,n,e)})}function Mw(n){return n==null}function Aw(){let n,e;const t=new Promise((r,i)=>{n=r,e=i});return{resolve:n,reject:e,promise:t}}async function Dw(n,e){for(const t of n)await e(await t)}function xw(n){return new Promise(e=>e(n()))}async function Uw(n,e){const t=[];for(let r=0;r<n.length;r+=e)t.push(...await Promise.all(n.slice(r,r+e).map(i=>i())));return t}function $w(n){return(0,fw.default)(e=>n(e),{forever:!0,factor:2,minTimeout:3e3,maxTimeout:15e3})}let tv;function Nw(n){tv=n}function Lw(){return tv}const Ps=(()=>{let n="";for(let e=32;e<=126;e++)n+=String.fromCharCode(e);return n})();W.DEFAULT_ALPHABET=Ps;function Bd(n,e,t=Ps){return n.padEnd(e,t[0])}function Io(n,e=Ps){const t=BigInt(e.length);if(n<=t){var r;return(r=e[Number(n)-1])!==null&&r!==void 0?r:""}let i=n/t,s=Number(n%t)-1;return s<0&&(i-=BigInt(Math.abs(s)),s=Number(t)-1),Io(i,e)+e[s]}function La(n,e=Ps){const t=BigInt(e.length);let r=BigInt(0);for(let i=n.length-1,s=BigInt(0);i>=0;i--,s++){const o=n.charCodeAt(i)-e.charCodeAt(0);r+=BigInt(1+o)*t**s}return r}function Bw(n,e,t=Ps){const r=Math.max(n.length,e.length),i=La(Bd(n,r,t),t),s=La(Bd(e,r,t),t),o=(i+s)/BigInt(2);return o===i||o==s?Io(o,t)+t[0]:Io(o,t)}function Kw(n,e=Ps){return Io(La(n,e)+BigInt(1),e)}function Fw(n,e=Ps){return Io(La(n,e)-BigInt(1),e)}function rv(n,e){return n<e?-1:n===e?0:1}const qw=new Intl.Collator;function jw(n,e){return qw.compare(n,e)}function nv(n,e,t=!1){for(const[r,i]of Object.entries(e)){if(n[r]instanceof Object&&i){nv(n[r],i);continue}if(i!=null||!t){n[r]=i;continue}}return n}var Vw=G.exports;Object.defineProperty(Uo,"__esModule",{value:!0});Uo.MemoryCryptoStore=void 0;var Zt=Vw(Y.exports),_c=se,wp=Gw(W);function iv(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(iv=function(r){return r?t:e})(n)}function Gw(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=iv(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}function Rp(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function Ip(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Rp(Object(t),!0).forEach(function(r){(0,Zt.default)(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Rp(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}class Ww{constructor(){(0,Zt.default)(this,"outgoingRoomKeyRequests",[]),(0,Zt.default)(this,"account",null),(0,Zt.default)(this,"crossSigningKeys",null),(0,Zt.default)(this,"privateKeys",{}),(0,Zt.default)(this,"sessions",{}),(0,Zt.default)(this,"sessionProblems",{}),(0,Zt.default)(this,"notifiedErrorDevices",{}),(0,Zt.default)(this,"inboundGroupSessions",{}),(0,Zt.default)(this,"inboundGroupSessionsWithheld",{}),(0,Zt.default)(this,"deviceData",null),(0,Zt.default)(this,"rooms",{}),(0,Zt.default)(this,"sessionsNeedingBackup",{}),(0,Zt.default)(this,"sharedHistoryInboundGroupSessions",{})}async startup(){return this}deleteAllData(){return Promise.resolve()}getOrAddOutgoingRoomKeyRequest(e){const t=e.requestBody;return wp.promiseTry(()=>{const r=this._getOutgoingRoomKeyRequest(t);return r?(_c.logger.log(`already have key request outstanding for ${t.room_id} / ${t.session_id}: not sending another`),r):(_c.logger.log(`enqueueing key request for ${t.room_id} / `+t.session_id),this.outgoingRoomKeyRequests.push(e),e)})}getOutgoingRoomKeyRequest(e){return Promise.resolve(this._getOutgoingRoomKeyRequest(e))}_getOutgoingRoomKeyRequest(e){for(const t of this.outgoingRoomKeyRequests)if(wp.deepCompare(t.requestBody,e))return t;return null}getOutgoingRoomKeyRequestByState(e){for(const t of this.outgoingRoomKeyRequests)for(const r of e)if(t.state===r)return Promise.resolve(t);return Promise.resolve(null)}getAllOutgoingRoomKeyRequestsByState(e){return Promise.resolve(this.outgoingRoomKeyRequests.filter(t=>t.state==e))}getOutgoingRoomKeyRequestsByTarget(e,t,r){const i=[];for(const s of this.outgoingRoomKeyRequests)for(const o of r)s.state===o&&s.recipients.includes({userId:e,deviceId:t})&&i.push(s);return Promise.resolve(i)}updateOutgoingRoomKeyRequest(e,t,r){for(const i of this.outgoingRoomKeyRequests)if(i.requestId===e)return i.state!==t?(_c.logger.warn(`Cannot update room key request from ${t} as it was already updated to ${i.state}`),Promise.resolve(null)):(Object.assign(i,r),Promise.resolve(i));return Promise.resolve(null)}deleteOutgoingRoomKeyRequest(e,t){for(let r=0;r<this.outgoingRoomKeyRequests.length;r++){const i=this.outgoingRoomKeyRequests[r];if(i.requestId===e)return i.state!=t?(_c.logger.warn(`Cannot delete room key request in state ${i.state} (expected ${t})`),Promise.resolve(null)):(this.outgoingRoomKeyRequests.splice(r,1),Promise.resolve(i))}return Promise.resolve(null)}getAccount(e,t){t(this.account)}storeAccount(e,t){this.account=t}getCrossSigningKeys(e,t){t(this.crossSigningKeys)}getSecretStorePrivateKey(e,t,r){const i=this.privateKeys[r];t(i||null)}storeCrossSigningKeys(e,t){this.crossSigningKeys=t}storeSecretStorePrivateKey(e,t,r){this.privateKeys[t]=r}countEndToEndSessions(e,t){t(Object.keys(this.sessions).length)}getEndToEndSession(e,t,r,i){const s=this.sessions[e]||{};i(s[t]||null)}getEndToEndSessions(e,t,r){r(this.sessions[e]||{})}getAllEndToEndSessions(e,t){Object.entries(this.sessions).forEach(([r,i])=>{Object.entries(i).forEach(([s,o])=>{t(Ip(Ip({},o),{},{deviceKey:r,sessionId:s}))})})}storeEndToEndSession(e,t,r,i){let s=this.sessions[e];s===void 0&&(s={},this.sessions[e]=s),s[t]=r}async storeEndToEndSessionProblem(e,t,r){const i=this.sessionProblems[e]=this.sessionProblems[e]||[];i.push({type:t,fixed:r,time:Date.now()}),i.sort((s,o)=>s.time-o.time)}async getEndToEndSessionProblem(e,t){const r=this.sessionProblems[e]||[];if(!r.length)return null;const i=r[r.length-1];for(const s of r)if(s.time>t)return Object.assign({},s,{fixed:i.fixed});return i.fixed?null:i}async filterOutNotifiedErrorDevices(e){const t=this.notifiedErrorDevices,r=[];for(const i of e){const{userId:s,deviceInfo:o}=i;s in t?o.deviceId in t[s]||(r.push(i),t[s][o.deviceId]=!0):(r.push(i),t[s]={[o.deviceId]:!0})}return r}getEndToEndInboundGroupSession(e,t,r,i){const s=e+"/"+t;i(this.inboundGroupSessions[s]||null,this.inboundGroupSessionsWithheld[s]||null)}getAllEndToEndInboundGroupSessions(e,t){for(const r of Object.keys(this.inboundGroupSessions))t({senderKey:r.substr(0,43),sessionId:r.substr(44),sessionData:this.inboundGroupSessions[r]});t(null)}addEndToEndInboundGroupSession(e,t,r,i){const s=e+"/"+t;this.inboundGroupSessions[s]===void 0&&(this.inboundGroupSessions[s]=r)}storeEndToEndInboundGroupSession(e,t,r,i){this.inboundGroupSessions[e+"/"+t]=r}storeEndToEndInboundGroupSessionWithheld(e,t,r,i){const s=e+"/"+t;this.inboundGroupSessionsWithheld[s]=r}getEndToEndDeviceData(e,t){t(this.deviceData)}storeEndToEndDeviceData(e,t){this.deviceData=e}storeEndToEndRoom(e,t,r){this.rooms[e]=t}getEndToEndRooms(e,t){t(this.rooms)}getSessionsNeedingBackup(e){const t=[];for(const r in this.sessionsNeedingBackup)if(this.inboundGroupSessions[r]&&(t.push({senderKey:r.substr(0,43),sessionId:r.substr(44),sessionData:this.inboundGroupSessions[r]}),e&&r.length>=e))break;return Promise.resolve(t)}countSessionsNeedingBackup(){return Promise.resolve(Object.keys(this.sessionsNeedingBackup).length)}unmarkSessionsNeedingBackup(e){for(const t of e){const r=t.senderKey+"/"+t.sessionId;delete this.sessionsNeedingBackup[r]}return Promise.resolve()}markSessionsNeedingBackup(e){for(const t of e){const r=t.senderKey+"/"+t.sessionId;this.sessionsNeedingBackup[r]=!0}return Promise.resolve()}addSharedHistoryInboundGroupSession(e,t,r){const i=this.sharedHistoryInboundGroupSessions[e]||[];i.push([t,r]),this.sharedHistoryInboundGroupSessions[e]=i}getSharedHistoryInboundGroupSessions(e){return Promise.resolve(this.sharedHistoryInboundGroupSessions[e]||[])}doTxn(e,t,r){return Promise.resolve(r(null))}}Uo.MemoryCryptoStore=Ww;var Qa={},Qr={},je={},Bl={exports:{}},po=typeof Reflect=="object"?Reflect:null,Tp=po&&typeof po.apply=="function"?po.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)},Xc;po&&typeof po.ownKeys=="function"?Xc=po.ownKeys:Object.getOwnPropertySymbols?Xc=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Xc=function(e){return Object.getOwnPropertyNames(e)};function Hw(n){console&&console.warn&&console.warn(n)}var sv=Number.isNaN||function(e){return e!==e};function Pe(){Pe.init.call(this)}Bl.exports=Pe;Bl.exports.once=Xw;Pe.EventEmitter=Pe;Pe.prototype._events=void 0;Pe.prototype._eventsCount=0;Pe.prototype._maxListeners=void 0;var Op=10;function Kl(n){if(typeof n!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n)}Object.defineProperty(Pe,"defaultMaxListeners",{enumerable:!0,get:function(){return Op},set:function(n){if(typeof n!="number"||n<0||sv(n))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+n+".");Op=n}});Pe.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Pe.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||sv(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function ov(n){return n._maxListeners===void 0?Pe.defaultMaxListeners:n._maxListeners}Pe.prototype.getMaxListeners=function(){return ov(this)};Pe.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var i=e==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var l=s[e];if(l===void 0)return!1;if(typeof l=="function")Tp(l,this,t);else for(var u=l.length,c=dv(l,u),r=0;r<u;++r)Tp(c[r],this,t);return!0};function av(n,e,t,r){var i,s,o;if(Kl(t),s=n._events,s===void 0?(s=n._events=Object.create(null),n._eventsCount=0):(s.newListener!==void 0&&(n.emit("newListener",e,t.listener?t.listener:t),s=n._events),o=s[e]),o===void 0)o=s[e]=t,++n._eventsCount;else if(typeof o=="function"?o=s[e]=r?[t,o]:[o,t]:r?o.unshift(t):o.push(t),i=ov(n),i>0&&o.length>i&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=n,a.type=e,a.count=o.length,Hw(a)}return n}Pe.prototype.addListener=function(e,t){return av(this,e,t,!1)};Pe.prototype.on=Pe.prototype.addListener;Pe.prototype.prependListener=function(e,t){return av(this,e,t,!0)};function Yw(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function cv(n,e,t){var r={fired:!1,wrapFn:void 0,target:n,type:e,listener:t},i=Yw.bind(r);return i.listener=t,r.wrapFn=i,i}Pe.prototype.once=function(e,t){return Kl(t),this.on(e,cv(this,e,t)),this};Pe.prototype.prependOnceListener=function(e,t){return Kl(t),this.prependListener(e,cv(this,e,t)),this};Pe.prototype.removeListener=function(e,t){var r,i,s,o,a;if(Kl(t),i=this._events,i===void 0)return this;if(r=i[e],r===void 0)return this;if(r===t||r.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||t));else if(typeof r!="function"){for(s=-1,o=r.length-1;o>=0;o--)if(r[o]===t||r[o].listener===t){a=r[o].listener,s=o;break}if(s<0)return this;s===0?r.shift():zw(r,s),r.length===1&&(i[e]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||t)}return this};Pe.prototype.off=Pe.prototype.removeListener;Pe.prototype.removeAllListeners=function(e){var t,r,i;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[e]),this;if(arguments.length===0){var s=Object.keys(r),o;for(i=0;i<s.length;++i)o=s[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=r[e],typeof t=="function")this.removeListener(e,t);else if(t!==void 0)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this};function lv(n,e,t){var r=n._events;if(r===void 0)return[];var i=r[e];return i===void 0?[]:typeof i=="function"?t?[i.listener||i]:[i]:t?Jw(i):dv(i,i.length)}Pe.prototype.listeners=function(e){return lv(this,e,!0)};Pe.prototype.rawListeners=function(e){return lv(this,e,!1)};Pe.listenerCount=function(n,e){return typeof n.listenerCount=="function"?n.listenerCount(e):uv.call(n,e)};Pe.prototype.listenerCount=uv;function uv(n){var e=this._events;if(e!==void 0){var t=e[n];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}Pe.prototype.eventNames=function(){return this._eventsCount>0?Xc(this._events):[]};function dv(n,e){for(var t=new Array(e),r=0;r<e;++r)t[r]=n[r];return t}function zw(n,e){for(;e+1<n.length;e++)n[e]=n[e+1];n.pop()}function Jw(n){for(var e=new Array(n.length),t=0;t<e.length;++t)e[t]=n[t].listener||n[t];return e}function Xw(n,e){return new Promise(function(t,r){function i(o){n.removeListener(e,s),r(o)}function s(){typeof n.removeListener=="function"&&n.removeListener("error",i),t([].slice.call(arguments))}hv(n,e,s,{once:!0}),e!=="error"&&Qw(n,i,{once:!0})})}function Qw(n,e,t){typeof n.on=="function"&&hv(n,"error",e,t)}function hv(n,e,t,r){if(typeof n.on=="function")r.once?n.once(e,t):n.on(e,t);else if(typeof n.addEventListener=="function")n.addEventListener(e,function i(s){r.once&&n.removeEventListener(e,i),t(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof n)}Object.defineProperty(je,"__esModule",{value:!0});je.TypedEventEmitter=je.EventEmitterEvents=void 0;var Zw=Bl.exports;let Kd;je.EventEmitterEvents=Kd;(function(n){n.NewListener="newListener",n.RemoveListener="removeListener",n.Error="error"})(Kd||(je.EventEmitterEvents=Kd={}));class e0 extends Zw.EventEmitter{addListener(e,t){return super.addListener(e,t)}emit(e,...t){return super.emit(e,...t)}eventNames(){return super.eventNames()}listenerCount(e){return super.listenerCount(e)}listeners(e){return super.listeners(e)}off(e,t){return super.off(e,t)}on(e,t){return super.on(e,t)}once(e,t){return super.once(e,t)}prependListener(e,t){return super.prependListener(e,t)}prependOnceListener(e,t){return super.prependOnceListener(e,t)}removeAllListeners(e){return super.removeAllListeners(e)}removeListener(e,t){return super.removeListener(e,t)}rawListeners(e){return super.rawListeners(e)}}je.TypedEventEmitter=e0;var t0=G.exports;Object.defineProperty(Qr,"__esModule",{value:!0});Qr.UserEvent=Qr.User=void 0;var jr=t0(Y.exports),r0=je;let Vn;Qr.UserEvent=Vn;(function(n){n.DisplayName="User.displayName",n.AvatarUrl="User.avatarUrl",n.Presence="User.presence",n.CurrentlyActive="User.currentlyActive",n.LastPresenceTs="User.lastPresenceTs",n._UnstableStatusMessage="User.unstable_statusMessage"})(Vn||(Qr.UserEvent=Vn={}));class n0 extends r0.TypedEventEmitter{constructor(e){super();this.userId=e,(0,jr.default)(this,"modified",void 0),(0,jr.default)(this,"displayName",void 0),(0,jr.default)(this,"rawDisplayName",void 0),(0,jr.default)(this,"avatarUrl",void 0),(0,jr.default)(this,"presenceStatusMsg",null),(0,jr.default)(this,"presence","offline"),(0,jr.default)(this,"lastActiveAgo",0),(0,jr.default)(this,"lastPresenceTs",0),(0,jr.default)(this,"currentlyActive",!1),(0,jr.default)(this,"events",{presence:null,profile:null}),(0,jr.default)(this,"unstable_statusMessage",""),this.displayName=e,this.rawDisplayName=e,this.avatarUrl=null,this.updateModifiedTime()}setPresenceEvent(e){if(e.getType()!=="m.presence")return;const t=this.events.presence===null;this.events.presence=e;const r=[];(e.getContent().presence!==this.presence||t)&&r.push(Vn.Presence),e.getContent().avatar_url&&e.getContent().avatar_url!==this.avatarUrl&&r.push(Vn.AvatarUrl),e.getContent().displayname&&e.getContent().displayname!==this.displayName&&r.push(Vn.DisplayName),e.getContent().currently_active!==void 0&&e.getContent().currently_active!==this.currentlyActive&&r.push(Vn.CurrentlyActive),this.presence=e.getContent().presence,r.push(Vn.LastPresenceTs),e.getContent().status_msg&&(this.presenceStatusMsg=e.getContent().status_msg),e.getContent().displayname&&(this.displayName=e.getContent().displayname),e.getContent().avatar_url&&(this.avatarUrl=e.getContent().avatar_url),this.lastActiveAgo=e.getContent().last_active_ago,this.lastPresenceTs=Date.now(),this.currentlyActive=e.getContent().currently_active,this.updateModifiedTime();for(let i=0;i<r.length;i++)this.emit(r[i],e,this)}setDisplayName(e){const t=this.displayName;typeof e=="string"?this.displayName=e:this.displayName=void 0,e!==t&&this.updateModifiedTime()}setRawDisplayName(e){typeof e=="string"?this.rawDisplayName=e:this.rawDisplayName=void 0}setAvatarUrl(e){const t=this.avatarUrl;this.avatarUrl=e,e!==t&&this.updateModifiedTime()}updateModifiedTime(){this.modified=Date.now()}getLastModifiedTime(){return this.modified}getLastActiveTs(){return this.lastPresenceTs-this.lastActiveAgo}unstable_updateStatusMessage(e){e.getContent()?this.unstable_statusMessage=e.getContent().status:this.unstable_statusMessage="",this.updateModifiedTime(),this.emit(Vn._UnstableStatusMessage,this)}}Qr.User=n0;var Tn={},Zr={},$o={};Object.defineProperty($o,"__esModule",{value:!0});$o.getHttpUriForMxc=o0;var i0=s0(W);function fv(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(fv=function(r){return r?t:e})(n)}function s0(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=fv(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}function o0(n,e,t,r,i,s=!1){if(typeof e!="string"||!e)return"";if(e.indexOf("mxc://")!==0)return s?e:"";let o=e.slice(6),a="/_matrix/media/r0/download/";const l={};t&&(l.width=Math.round(t).toString()),r&&(l.height=Math.round(r).toString()),i&&(l.method=i),Object.keys(l).length>0&&(a="/_matrix/media/r0/thumbnail/");const u=o.indexOf("#");let c="";u>=0&&(c=o.substr(u),o=o.substr(0,u));const g=Object.keys(l).length===0?"":"?"+i0.encodeParams(l);return n+a+o+g+c}var ie={},_r={},a0=G.exports;Object.defineProperty(_r,"__esModule",{value:!0});_r.UnstableValue=_r.ServerControlledNamespacedValue=_r.NamespacedValue=void 0;var c0=a0(Y.exports);class ff{constructor(e,t){if(this.stable=e,this.unstable=t,!this.unstable&&!this.stable)throw new Error("One of stable or unstable values must be supplied")}get name(){return this.stable?this.stable:this.unstable}get altName(){return this.stable?this.unstable:null}matches(e){return this.name===e||this.altName===e}findIn(e){let t;return this.name&&(t=e==null?void 0:e[this.name]),!t&&this.altName&&(t=e==null?void 0:e[this.altName]),t}includedIn(e){let t=!1;return this.name&&(t=e.includes(this.name)),!t&&this.altName&&(t=e.includes(this.altName)),t}}_r.NamespacedValue=ff;class l0 extends ff{constructor(...e){super(...e);(0,c0.default)(this,"preferUnstable",!1)}setPreferUnstable(e){this.preferUnstable=e}get name(){return this.stable&&!this.preferUnstable?this.stable:this.unstable}}_r.ServerControlledNamespacedValue=l0;class u0 extends ff{constructor(e,t){super(e,t);if(!this.unstable)throw new Error("Unstable value must be supplied")}get name(){return this.unstable}get altName(){return this.stable}}_r.UnstableValue=u0;Object.defineProperty(ie,"__esModule",{value:!0});ie.UNSTABLE_MSC3089_TREE_SUBTYPE=ie.UNSTABLE_MSC3089_LEAF=ie.UNSTABLE_MSC3089_BRANCH=ie.UNSTABLE_MSC3088_PURPOSE=ie.UNSTABLE_MSC3088_ENABLED=ie.UNSTABLE_ELEMENT_FUNCTIONAL_USERS=ie.RoomType=ie.RoomCreateTypeField=ie.RelationType=ie.MsgType=ie.EventType=ie.EVENT_VISIBILITY_CHANGE_TYPE=void 0;var Ms=_r;let Fd;ie.EventType=Fd;(function(n){n.RoomCanonicalAlias="m.room.canonical_alias",n.RoomCreate="m.room.create",n.RoomJoinRules="m.room.join_rules",n.RoomMember="m.room.member",n.RoomThirdPartyInvite="m.room.third_party_invite",n.RoomPowerLevels="m.room.power_levels",n.RoomName="m.room.name",n.RoomTopic="m.room.topic",n.RoomAvatar="m.room.avatar",n.RoomPinnedEvents="m.room.pinned_events",n.RoomEncryption="m.room.encryption",n.RoomHistoryVisibility="m.room.history_visibility",n.RoomGuestAccess="m.room.guest_access",n.RoomServerAcl="m.room.server_acl",n.RoomTombstone="m.room.tombstone",n.RoomAliases="m.room.aliases",n.SpaceChild="m.space.child",n.SpaceParent="m.space.parent",n.RoomRedaction="m.room.redaction",n.RoomMessage="m.room.message",n.RoomMessageEncrypted="m.room.encrypted",n.Sticker="m.sticker",n.CallInvite="m.call.invite",n.CallCandidates="m.call.candidates",n.CallAnswer="m.call.answer",n.CallHangup="m.call.hangup",n.CallReject="m.call.reject",n.CallSelectAnswer="m.call.select_answer",n.CallNegotiate="m.call.negotiate",n.CallSDPStreamMetadataChanged="m.call.sdp_stream_metadata_changed",n.CallSDPStreamMetadataChangedPrefix="org.matrix.call.sdp_stream_metadata_changed",n.CallReplaces="m.call.replaces",n.CallAssertedIdentity="m.call.asserted_identity",n.CallAssertedIdentityPrefix="org.matrix.call.asserted_identity",n.KeyVerificationRequest="m.key.verification.request",n.KeyVerificationStart="m.key.verification.start",n.KeyVerificationCancel="m.key.verification.cancel",n.KeyVerificationMac="m.key.verification.mac",n.KeyVerificationDone="m.key.verification.done",n.RoomMessageFeedback="m.room.message.feedback",n.Reaction="m.reaction",n.Typing="m.typing",n.Receipt="m.receipt",n.Presence="m.presence",n.FullyRead="m.fully_read",n.Tag="m.tag",n.SpaceOrder="org.matrix.msc3230.space_order",n.PushRules="m.push_rules",n.Direct="m.direct",n.IgnoredUserList="m.ignored_user_list",n.RoomKey="m.room_key",n.RoomKeyRequest="m.room_key_request",n.ForwardedRoomKey="m.forwarded_room_key",n.Dummy="m.dummy"})(Fd||(ie.EventType=Fd={}));let qd;ie.RelationType=qd;(function(n){n.Annotation="m.annotation",n.Replace="m.replace",n.Reference="m.reference",n.Thread="io.element.thread"})(qd||(ie.RelationType=qd={}));let jd;ie.MsgType=jd;(function(n){n.Text="m.text",n.Emote="m.emote",n.Notice="m.notice",n.Image="m.image",n.File="m.file",n.Audio="m.audio",n.Location="m.location",n.Video="m.video",n.KeyVerificationRequest="m.key.verification.request"})(jd||(ie.MsgType=jd={}));const d0="type";ie.RoomCreateTypeField=d0;let Vd;ie.RoomType=Vd;(function(n){n.Space="m.space"})(Vd||(ie.RoomType=Vd={}));const h0=new Ms.UnstableValue("m.room.purpose","org.matrix.msc3088.purpose");ie.UNSTABLE_MSC3088_PURPOSE=h0;const f0=new Ms.UnstableValue("m.enabled","org.matrix.msc3088.enabled");ie.UNSTABLE_MSC3088_ENABLED=f0;const p0=new Ms.UnstableValue("m.data_tree","org.matrix.msc3089.data_tree");ie.UNSTABLE_MSC3089_TREE_SUBTYPE=p0;const g0=new Ms.UnstableValue("m.leaf","org.matrix.msc3089.leaf");ie.UNSTABLE_MSC3089_LEAF=g0;const m0=new Ms.UnstableValue("m.branch","org.matrix.msc3089.branch");ie.UNSTABLE_MSC3089_BRANCH=m0;const y0=new Ms.UnstableValue("io.element.functional_members","io.element.functional_members");ie.UNSTABLE_ELEMENT_FUNCTIONAL_USERS=y0;const v0=new Ms.UnstableValue("m.visibility","org.matrix.msc3531.visibility");ie.EVENT_VISIBILITY_CHANGE_TYPE=v0;var _0=G.exports;Object.defineProperty(Zr,"__esModule",{value:!0});Zr.RoomMemberEvent=Zr.RoomMember=void 0;var wr=_0(Y.exports),E0=$o,go=R0(W),S0=se,b0=je,w0=ie;function pv(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(pv=function(r){return r?t:e})(n)}function R0(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=pv(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}let as;Zr.RoomMemberEvent=as;(function(n){n.Membership="RoomMember.membership",n.Name="RoomMember.name",n.PowerLevel="RoomMember.powerLevel",n.Typing="RoomMember.typing"})(as||(Zr.RoomMemberEvent=as={}));class I0 extends b0.TypedEventEmitter{constructor(e,t){super();this.roomId=e,this.userId=t,(0,wr.default)(this,"_isOutOfBand",!1),(0,wr.default)(this,"_modified",void 0),(0,wr.default)(this,"_requestedProfileInfo",void 0),(0,wr.default)(this,"typing",!1),(0,wr.default)(this,"name",void 0),(0,wr.default)(this,"rawDisplayName",void 0),(0,wr.default)(this,"powerLevel",0),(0,wr.default)(this,"powerLevelNorm",0),(0,wr.default)(this,"user",null),(0,wr.default)(this,"membership",null),(0,wr.default)(this,"disambiguate",!1),(0,wr.default)(this,"events",{member:null}),this.name=t,this.rawDisplayName=t,this.updateModifiedTime()}markOutOfBand(){this._isOutOfBand=!0}isOutOfBand(){return this._isOutOfBand}setMembershipEvent(e,t){const r=e.getDirectionalContent().displayname;if(e.getType()!==w0.EventType.RoomMember)return;this._isOutOfBand=!1,this.events.member=e;const i=this.membership;this.membership=e.getDirectionalContent().membership,this.membership===void 0&&S0.logger.trace(`membership event with membership undefined (forwardLooking: ${e.forwardLooking})!`,e.getContent(),"prevcontent is ",e.getPrevContent()),this.disambiguate=k0(this.userId,r,t);const s=this.name;this.name=C0(this.userId,r,t,this.disambiguate),this.rawDisplayName=go.removeDirectionOverrideChars(e.getDirectionalContent().displayname),(!this.rawDisplayName||!go.removeHiddenChars(this.rawDisplayName))&&(this.rawDisplayName=this.userId),i!==this.membership&&(this.updateModifiedTime(),this.emit(as.Membership,e,this,i)),s!==this.name&&(this.updateModifiedTime(),this.emit(as.Name,e,this,s))}setPowerLevelEvent(e){if(e.getType()!=="m.room.power_levels")return;const t=e.getDirectionalContent();let r=t.users_default||0;const i=t.users||{};Object.values(i).forEach(function(a){r=Math.max(r,a)});const s=this.powerLevel,o=this.powerLevelNorm;i[this.userId]!==void 0&&Number.isInteger(i[this.userId])?this.powerLevel=i[this.userId]:t.users_default!==void 0?this.powerLevel=t.users_default:this.powerLevel=0,this.powerLevelNorm=0,r>0&&(this.powerLevelNorm=this.powerLevel*100/r),(s!==this.powerLevel||o!==this.powerLevelNorm)&&(this.updateModifiedTime(),this.emit(as.PowerLevel,e,this))}setTypingEvent(e){if(e.getType()!=="m.typing")return;const t=this.typing;this.typing=!1;const r=e.getContent().user_ids;!Array.isArray(r)||(r.indexOf(this.userId)!==-1&&(this.typing=!0),t!==this.typing&&(this.updateModifiedTime(),this.emit(as.Typing,e,this)))}updateModifiedTime(){this._modified=Date.now()}getLastModifiedTime(){return this._modified}isKicked(){return this.membership==="leave"&&this.events.member.getSender()!==this.events.member.getStateKey()}getDMInviter(){if(this.events.member){const e=this.events.member;let t=e.getContent(),r=e.getSender();if(t.membership==="join"&&(t=e.getPrevContent(),r=e.getUnsigned().prev_sender),t.membership==="invite"&&t.is_direct)return r}}getAvatarUrl(e,t,r,i,s=!0,o){const a=this.getMxcAvatarUrl();if(!a&&!s)return null;const l=(0,E0.getHttpUriForMxc)(e,a,t,r,i,o);return l||null}getMxcAvatarUrl(){return this.events.member?this.events.member.getDirectionalContent().avatar_url:this.user?this.user.avatarUrl:null}}Zr.RoomMember=I0;const T0=/@.+:.+/,O0=/[\u200E\u200F\u202A-\u202F]/;function k0(n,e,t){return!e||e===n||!go.removeHiddenChars(e)||!t?!1:!!(T0.test(e)||O0.test(e)||t.getUserIdsWithDisplayName(e).some(i=>i!==n))}function C0(n,e,t,r){return r?go.removeDirectionOverrideChars(e)+" ("+n+")":!e||e===n||!go.removeHiddenChars(e)?n:go.removeDirectionOverrideChars(e)}var Je={};Object.defineProperty(Je,"__esModule",{value:!0});Je.Visibility=Je.RestrictedAllowType=Je.Preset=Je.JoinRule=Je.HistoryVisibility=Je.GuestAccess=void 0;let Gd;Je.Visibility=Gd;(function(n){n.Public="public",n.Private="private"})(Gd||(Je.Visibility=Gd={}));let Wd;Je.Preset=Wd;(function(n){n.PrivateChat="private_chat",n.TrustedPrivateChat="trusted_private_chat",n.PublicChat="public_chat"})(Wd||(Je.Preset=Wd={}));let Hd;Je.JoinRule=Hd;(function(n){n.Public="public",n.Invite="invite",n.Private="private",n.Knock="knock",n.Restricted="restricted"})(Hd||(Je.JoinRule=Hd={}));let Yd;Je.RestrictedAllowType=Yd;(function(n){n.RoomMembership="m.room_membership"})(Yd||(Je.RestrictedAllowType=Yd={}));let zd;Je.GuestAccess=zd;(function(n){n.CanJoin="can_join",n.Forbidden="forbidden"})(zd||(Je.GuestAccess=zd={}));let Jd;Je.HistoryVisibility=Jd;(function(n){n.Invited="invited",n.Joined="joined",n.Shared="shared",n.WorldReadable="world_readable"})(Jd||(Je.HistoryVisibility=Jd={}));var vr={},Rn={};Object.defineProperty(Rn,"__esModule",{value:!0});Rn.M_BEACON_INFO_VARIABLE=Rn.M_BEACON_INFO=Rn.M_BEACON=void 0;var pf=_r;const P0=new pf.UnstableValue("m.beacon_info.*","org.matrix.msc3489.beacon_info.*");Rn.M_BEACON_INFO_VARIABLE=P0;const M0=new pf.UnstableValue("m.beacon_info","org.matrix.msc3489.beacon_info");Rn.M_BEACON_INFO=M0;const A0=new pf.UnstableValue("m.beacon","org.matrix.msc3489.beacon");Rn.M_BEACON=A0;var Xe={},Fl={},ql={},Za={};Object.defineProperty(Za,"__esModule",{value:!0});Za.NamespacedMap=void 0;function D0(n,e){var t=typeof Symbol!="undefined"&&n[Symbol.iterator]||n["@@iterator"];if(!t){if(Array.isArray(n)||(t=x0(n))||e&&n&&typeof n.length=="number"){t&&(n=t);var r=0,i=function(){};return{s:i,n:function(){return r>=n.length?{done:!0}:{done:!1,value:n[r++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
+In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s=!0,o=!1,a;return{s:function(){t=t.call(n)},n:function(){var u=t.next();return s=u.done,u},e:function(u){o=!0,a=u},f:function(){try{!s&&t.return!=null&&t.return()}finally{if(o)throw a}}}}function x0(n,e){if(!!n){if(typeof n=="string")return kp(n,e);var t=Object.prototype.toString.call(n).slice(8,-1);if(t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set")return Array.from(n);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return kp(n,e)}}function kp(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,r=new Array(e);t<e;t++)r[t]=n[t];return r}function U0(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function Cp(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function $0(n,e,t){return e&&Cp(n.prototype,e),t&&Cp(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function N0(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}var L0=function(){function n(e){if(U0(this,n),N0(this,"internalMap",new Map),e){var t=D0(e),r;try{for(t.s();!(r=t.n()).done;){var i=r.value;this.set(i[0],i[1])}}catch(s){t.e(s)}finally{t.f()}}}return $0(n,[{key:"get",value:function(t){return t.name&&this.internalMap.has(t.name)?this.internalMap.get(t.name):t.altName&&this.internalMap.has(t.altName)?this.internalMap.get(t.altName):null}},{key:"set",value:function(t,r){t.name&&this.internalMap.set(t.name,r),t.altName&&this.internalMap.set(t.altName,r)}},{key:"has",value:function(t){return!!this.get(t)}},{key:"delete",value:function(t){t.name&&this.internalMap.delete(t.name),t.altName&&this.internalMap.delete(t.altName)}},{key:"hasNamespaced",value:function(t){return this.internalMap.has(t)}},{key:"getNamespaced",value:function(t){return this.internalMap.get(t)}}]),n}();Za.NamespacedMap=L0;var ii={};function Xd(n){return Xd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Xd(n)}Object.defineProperty(ii,"__esModule",{value:!0});ii.InvalidEventError=void 0;function Pp(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function B0(n,e,t){return e&&Pp(n.prototype,e),t&&Pp(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function K0(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function F0(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&Ba(n,e)}function q0(n){var e=gv();return function(){var r=Ka(n),i;if(e){var s=Ka(this).constructor;i=Reflect.construct(r,arguments,s)}else i=r.apply(this,arguments);return j0(this,i)}}function j0(n,e){if(e&&(Xd(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return V0(n)}function V0(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function Qd(n){var e=typeof Map=="function"?new Map:void 0;return Qd=function(r){if(r===null||!G0(r))return r;if(typeof r!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e!="undefined"){if(e.has(r))return e.get(r);e.set(r,i)}function i(){return Qc(r,arguments,Ka(this).constructor)}return i.prototype=Object.create(r.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Ba(i,r)},Qd(n)}function Qc(n,e,t){return gv()?Qc=Reflect.construct:Qc=function(i,s,o){var a=[null];a.push.apply(a,s);var l=Function.bind.apply(i,a),u=new l;return o&&Ba(u,o.prototype),u},Qc.apply(null,arguments)}function gv(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function G0(n){return Function.toString.call(n).indexOf("[native code]")!==-1}function Ba(n,e){return Ba=Object.setPrototypeOf||function(r,i){return r.__proto__=i,r},Ba(n,e)}function Ka(n){return Ka=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Ka(n)}var W0=function(n){F0(t,n);var e=q0(t);function t(r){return K0(this,t),e.call(this,r)}return B0(t)}(Qd(Error));ii.InvalidEventError=W0;var No={},Cn={},Bi={};Object.defineProperty(Bi,"__esModule",{value:!0});Bi.ExtensibleEvent=void 0;function H0(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function Mp(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function Y0(n,e,t){return e&&Mp(n.prototype,e),t&&Mp(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}var z0=function(){function n(e){H0(this,n),this.wireFormat=e}return Y0(n,[{key:"wireContent",get:function(){return this.wireFormat.content}}]),n}();Bi.ExtensibleEvent=z0;var ec={};Object.defineProperty(ec,"__esModule",{value:!0});ec.isOptionalAString=J0;ec.isProvided=mv;function J0(n){return mv(n)&&typeof n=="string"}function mv(n){return n!=null}var tt={},en={};function Zd(n){return Zd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Zd(n)}Object.defineProperty(en,"__esModule",{value:!0});en.UnstableValue=en.NamespacedValue=void 0;function X0(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&eh(n,e)}function eh(n,e){return eh=Object.setPrototypeOf||function(r,i){return r.__proto__=i,r},eh(n,e)}function Q0(n){var e=tR();return function(){var r=El(n),i;if(e){var s=El(this).constructor;i=Reflect.construct(r,arguments,s)}else i=r.apply(this,arguments);return Z0(this,i)}}function Z0(n,e){if(e&&(Zd(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return eR(n)}function eR(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function tR(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function El(n){return El=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},El(n)}function yv(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function Ap(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function vv(n,e,t){return e&&Ap(n.prototype,e),t&&Ap(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}var _v=function(){function n(e,t){if(yv(this,n),this.stable=e,this.unstable=t,!this.unstable&&!this.stable)throw new Error("One of stable or unstable values must be supplied")}return vv(n,[{key:"name",get:function(){return this.stable?this.stable:this.unstable}},{key:"altName",get:function(){return this.stable?this.unstable:null}},{key:"matches",value:function(t){return!!this.name&&this.name===t||!!this.altName&&this.altName===t}},{key:"findIn",value:function(t){var r;return this.name&&(r=t==null?void 0:t[this.name]),!r&&this.altName&&(r=t==null?void 0:t[this.altName]),r}},{key:"includedIn",value:function(t){var r=!1;return this.name&&(r=t.includes(this.name)),!r&&this.altName&&(r=t.includes(this.altName)),r}}]),n}();en.NamespacedValue=_v;var rR=function(n){X0(t,n);var e=Q0(t);function t(r,i){var s;if(yv(this,t),s=e.call(this,r,i),!s.unstable)throw new Error("Unstable value must be supplied");return s}return vv(t,[{key:"name",get:function(){return this.unstable}},{key:"altName",get:function(){return this.stable}}]),t}(_v);en.UnstableValue=rR;Object.defineProperty(tt,"__esModule",{value:!0});tt.M_TEXT=tt.M_NOTICE=tt.M_MESSAGE=tt.M_HTML=tt.M_EMOTE=void 0;var tc=en,nR=new tc.UnstableValue("m.message","org.matrix.msc1767.message");tt.M_MESSAGE=nR;var iR=new tc.UnstableValue("m.text","org.matrix.msc1767.text");tt.M_TEXT=iR;var sR=new tc.UnstableValue("m.html","org.matrix.msc1767.html");tt.M_HTML=sR;var oR=new tc.UnstableValue("m.emote","org.matrix.msc1767.emote");tt.M_EMOTE=oR;var aR=new tc.UnstableValue("m.notice","org.matrix.msc1767.notice");tt.M_NOTICE=aR;var si={};Object.defineProperty(si,"__esModule",{value:!0});si.isEventTypeSame=cR;function cR(n,e){if(typeof n=="string")return typeof e=="string"?e===n:e.matches(n);if(typeof e=="string")return n.matches(e);var t=e,r=n;return t.matches(r.name)||t.matches(r.altName)}function th(n){return th=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},th(n)}Object.defineProperty(Cn,"__esModule",{value:!0});Cn.MessageEvent=void 0;var lR=Bi,zo=ec,Au=ii,fr=tt,uR=si;function Dp(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function xp(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Dp(Object(t),!0).forEach(function(r){Ti(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Dp(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function dR(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function Up(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function hR(n,e,t){return e&&Up(n.prototype,e),t&&Up(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function fR(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&rh(n,e)}function rh(n,e){return rh=Object.setPrototypeOf||function(r,i){return r.__proto__=i,r},rh(n,e)}function pR(n){var e=mR();return function(){var r=Sl(n),i;if(e){var s=Sl(this).constructor;i=Reflect.construct(r,arguments,s)}else i=r.apply(this,arguments);return gR(this,i)}}function gR(n,e){if(e&&(th(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Zc(n)}function Zc(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function mR(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Sl(n){return Sl=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Sl(n)}function Ti(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}var yR=function(n){fR(t,n);var e=pR(t);function t(r){var i;dR(this,t),i=e.call(this,r),Ti(Zc(i),"text",void 0),Ti(Zc(i),"html",void 0),Ti(Zc(i),"renderings",void 0);var s=fr.M_MESSAGE.findIn(i.wireContent),o=fr.M_TEXT.findIn(i.wireContent),a=fr.M_HTML.findIn(i.wireContent);if((0,zo.isProvided)(s)){if(!Array.isArray(s))throw new Au.InvalidEventError("m.message contents must be an array");var l=s.find(function(c){return!(0,zo.isProvided)(c.mimetype)||c.mimetype==="text/plain"}),u=s.find(function(c){return c.mimetype==="text/html"});if(!l)throw new Au.InvalidEventError("m.message is missing a plain text representation");i.text=l.body,i.html=u==null?void 0:u.body,i.renderings=s}else if((0,zo.isOptionalAString)(o))i.text=o,i.html=a,i.renderings=[{body:o,mimetype:"text/plain"}],i.html&&i.renderings.push({body:i.html,mimetype:"text/html"});else throw new Au.InvalidEventError("Missing textual representation for event");return i}return hR(t,[{key:"isEmote",get:function(){return fr.M_EMOTE.matches(this.wireFormat.type)||(0,zo.isProvided)(fr.M_EMOTE.findIn(this.wireFormat.content))}},{key:"isNotice",get:function(){return fr.M_NOTICE.matches(this.wireFormat.type)||(0,zo.isProvided)(fr.M_NOTICE.findIn(this.wireFormat.content))}},{key:"isEquivalentTo",value:function(i){return(0,uR.isEventTypeSame)(i,fr.M_MESSAGE)}},{key:"serializeMMessageOnly",value:function(){var i=Ti({},fr.M_MESSAGE.name,this.renderings);if(this.renderings.length===1){var s=this.renderings[0].mimetype;(s===void 0||s==="text/plain")&&(i=Ti({},fr.M_TEXT.name,this.renderings[0].body))}return i}},{key:"serialize",value:function(){var i;return{type:"m.room.message",content:xp(xp({},this.serializeMMessageOnly()),{},{body:this.text,msgtype:"m.text",format:this.html?"org.matrix.custom.html":void 0,formatted_body:(i=this.html)!==null&&i!==void 0?i:void 0})}}}],[{key:"from",value:function(i,s){var o;return new t({type:fr.M_MESSAGE.name,content:(o={},Ti(o,fr.M_TEXT.name,i),Ti(o,fr.M_HTML.name,s),o)})}}]),t}(lR.ExtensibleEvent);Cn.MessageEvent=yR;var Lo={};function nh(n){return nh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},nh(n)}Object.defineProperty(Lo,"__esModule",{value:!0});Lo.NoticeEvent=void 0;var vR=Cn,Ec=tt,_R=si;function $p(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function ER(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function Np(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function SR(n,e,t){return e&&Np(n.prototype,e),t&&Np(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function Pa(){return typeof Reflect!="undefined"&&Reflect.get?Pa=Reflect.get:Pa=function(e,t,r){var i=bR(e,t);if(!!i){var s=Object.getOwnPropertyDescriptor(i,t);return s.get?s.get.call(arguments.length<3?e:r):s.value}},Pa.apply(this,arguments)}function bR(n,e){for(;!Object.prototype.hasOwnProperty.call(n,e)&&(n=hs(n),n!==null););return n}function wR(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&ih(n,e)}function ih(n,e){return ih=Object.setPrototypeOf||function(r,i){return r.__proto__=i,r},ih(n,e)}function RR(n){var e=OR();return function(){var r=hs(n),i;if(e){var s=hs(this).constructor;i=Reflect.construct(r,arguments,s)}else i=r.apply(this,arguments);return IR(this,i)}}function IR(n,e){if(e&&(nh(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return TR(n)}function TR(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function OR(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function hs(n){return hs=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},hs(n)}var kR=function(n){wR(t,n);var e=RR(t);function t(r){return ER(this,t),e.call(this,r)}return SR(t,[{key:"isNotice",get:function(){return!0}},{key:"isEquivalentTo",value:function(i){return(0,_R.isEventTypeSame)(i,Ec.M_NOTICE)||Pa(hs(t.prototype),"isEquivalentTo",this).call(this,i)}},{key:"serialize",value:function(){var i=Pa(hs(t.prototype),"serialize",this).call(this);return i.content.msgtype="m.notice",i}}],[{key:"from",value:function(i,s){var o;return new t({type:Ec.M_NOTICE.name,content:(o={},$p(o,Ec.M_TEXT.name,i),$p(o,Ec.M_HTML.name,s),o)})}}]),t}(vR.MessageEvent);Lo.NoticeEvent=kR;var Bo={};function sh(n){return sh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},sh(n)}Object.defineProperty(Bo,"__esModule",{value:!0});Bo.EmoteEvent=void 0;var CR=Cn,Sc=tt,PR=si;function Lp(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function MR(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function Bp(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function AR(n,e,t){return e&&Bp(n.prototype,e),t&&Bp(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function Ma(){return typeof Reflect!="undefined"&&Reflect.get?Ma=Reflect.get:Ma=function(e,t,r){var i=DR(e,t);if(!!i){var s=Object.getOwnPropertyDescriptor(i,t);return s.get?s.get.call(arguments.length<3?e:r):s.value}},Ma.apply(this,arguments)}function DR(n,e){for(;!Object.prototype.hasOwnProperty.call(n,e)&&(n=fs(n),n!==null););return n}function xR(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&oh(n,e)}function oh(n,e){return oh=Object.setPrototypeOf||function(r,i){return r.__proto__=i,r},oh(n,e)}function UR(n){var e=LR();return function(){var r=fs(n),i;if(e){var s=fs(this).constructor;i=Reflect.construct(r,arguments,s)}else i=r.apply(this,arguments);return $R(this,i)}}function $R(n,e){if(e&&(sh(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return NR(n)}function NR(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function LR(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function fs(n){return fs=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},fs(n)}var BR=function(n){xR(t,n);var e=UR(t);function t(r){return MR(this,t),e.call(this,r)}return AR(t,[{key:"isEmote",get:function(){return!0}},{key:"isEquivalentTo",value:function(i){return(0,PR.isEventTypeSame)(i,Sc.M_EMOTE)||Ma(fs(t.prototype),"isEquivalentTo",this).call(this,i)}},{key:"serialize",value:function(){var i=Ma(fs(t.prototype),"serialize",this).call(this);return i.content.msgtype="m.emote",i}}],[{key:"from",value:function(i,s){var o;return new t({type:Sc.M_EMOTE.name,content:(o={},Lp(o,Sc.M_TEXT.name,i),Lp(o,Sc.M_HTML.name,s),o)})}}]),t}(CR.MessageEvent);Bo.EmoteEvent=BR;Object.defineProperty(No,"__esModule",{value:!0});No.LEGACY_M_ROOM_MESSAGE=void 0;No.parseMRoomMessage=VR;var Kp=Cn,KR=Lo,FR=Bo,qR=en,yi=tt;function Fp(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function Rr(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Fp(Object(t),!0).forEach(function(r){Ji(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Fp(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function Ji(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}var jR=new qR.NamespacedValue("m.room.message");No.LEGACY_M_ROOM_MESSAGE=jR;function VR(n){var e,t,r;if(yi.M_MESSAGE.findIn(n.content)||yi.M_TEXT.findIn(n.content))return new Kp.MessageEvent(n);var i=(e=n.content)===null||e===void 0?void 0:e.msgtype,s=(t=n.content)===null||t===void 0?void 0:t.body,o=((r=n.content)===null||r===void 0?void 0:r.format)==="org.matrix.custom.html"?n.content.formatted_body:null;if(i==="m.text"){var a;return new Kp.MessageEvent(Rr(Rr({},n),{},{content:Rr(Rr({},n.content),{},(a={},Ji(a,yi.M_TEXT.name,s),Ji(a,yi.M_HTML.name,o),a))}))}else if(i==="m.notice"){var l;return new KR.NoticeEvent(Rr(Rr({},n),{},{content:Rr(Rr({},n.content),{},(l={},Ji(l,yi.M_TEXT.name,s),Ji(l,yi.M_HTML.name,o),l))}))}else if(i==="m.emote"){var u;return new FR.EmoteEvent(Rr(Rr({},n),{},{content:Rr(Rr({},n.content),{},(u={},Ji(u,yi.M_TEXT.name,s),Ji(u,yi.M_HTML.name,o),u))}))}else return null}var jl={};Object.defineProperty(jl,"__esModule",{value:!0});jl.parseMMessage=YR;var GR=Cn,qp=tt,WR=Bo,HR=Lo;function YR(n){return qp.M_EMOTE.matches(n.type)?new WR.EmoteEvent(n):qp.M_NOTICE.matches(n.type)?new HR.NoticeEvent(n):new GR.MessageEvent(n)}var Et={};Object.defineProperty(Et,"__esModule",{value:!0});Et.M_POLL_START=Et.M_POLL_RESPONSE=Et.M_POLL_KIND_UNDISCLOSED=Et.M_POLL_KIND_DISCLOSED=Et.M_POLL_END=void 0;var rc=en,zR=new rc.UnstableValue("m.poll.disclosed","org.matrix.msc3381.poll.disclosed");Et.M_POLL_KIND_DISCLOSED=zR;var JR=new rc.UnstableValue("m.poll.undisclosed","org.matrix.msc3381.poll.undisclosed");Et.M_POLL_KIND_UNDISCLOSED=JR;var XR=new rc.UnstableValue("m.poll.start","org.matrix.msc3381.poll.start");Et.M_POLL_START=XR;var QR=new rc.UnstableValue("m.poll.response","org.matrix.msc3381.poll.response");Et.M_POLL_RESPONSE=QR;var ZR=new rc.UnstableValue("m.poll.end","org.matrix.msc3381.poll.end");Et.M_POLL_END=ZR;var Vl={},ps={};function ah(n){return ah=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ah(n)}Object.defineProperty(ps,"__esModule",{value:!0});ps.PollStartEvent=ps.PollAnswerSubevent=void 0;var Dn=Et,Ev=Cn,Ea=tt,el=ii,eI=en,tI=si,rI=Bi;function nI(n){return aI(n)||oI(n)||sI(n)||iI()}function iI(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
+In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function sI(n,e){if(!!n){if(typeof n=="string")return ch(n,e);var t=Object.prototype.toString.call(n).slice(8,-1);if(t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set")return Array.from(n);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return ch(n,e)}}function oI(n){if(typeof Symbol!="undefined"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function aI(n){if(Array.isArray(n))return ch(n)}function ch(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,r=new Array(e);t<e;t++)r[t]=n[t];return r}function jp(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function cI(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?jp(Object(t),!0).forEach(function(r){rr(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):jp(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function Sv(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function Vp(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function bv(n,e,t){return e&&Vp(n.prototype,e),t&&Vp(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function wv(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&lh(n,e)}function lh(n,e){return lh=Object.setPrototypeOf||function(r,i){return r.__proto__=i,r},lh(n,e)}function Rv(n){var e=uI();return function(){var r=bl(n),i;if(e){var s=bl(this).constructor;i=Reflect.construct(r,arguments,s)}else i=r.apply(this,arguments);return lI(this,i)}}function lI(n,e){if(e&&(ah(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return ns(n)}function ns(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function uI(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function bl(n){return bl=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},bl(n)}function rr(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}var Iv=function(n){wv(t,n);var e=Rv(t);function t(r){var i;Sv(this,t),i=e.call(this,r),rr(ns(i),"id",void 0);var s=r.content.id;if(!s||typeof s!="string")throw new el.InvalidEventError("Answer ID must be a non-empty string");return i.id=s,i}return bv(t,[{key:"serialize",value:function(){return{type:"org.matrix.sdk.poll.answer",content:cI({id:this.id},this.serializeMMessageOnly())}}}],[{key:"from",value:function(i,s){return new t({type:"org.matrix.sdk.poll.answer",content:rr({id:i},Ea.M_TEXT.name,s)})}}]),t}(Ev.MessageEvent);ps.PollAnswerSubevent=Iv;var dI=function(n){wv(t,n);var e=Rv(t);function t(r){var i;Sv(this,t),i=e.call(this,r),rr(ns(i),"question",void 0),rr(ns(i),"kind",void 0),rr(ns(i),"rawKind",void 0),rr(ns(i),"maxSelections",void 0),rr(ns(i),"answers",void 0);var s=Dn.M_POLL_START.findIn(i.wireContent);if(!s.question)throw new el.InvalidEventError("A question is required");if(i.question=new Ev.MessageEvent({type:"org.matrix.sdk.poll.question",content:s.question}),i.rawKind=s.kind,Dn.M_POLL_KIND_DISCLOSED.matches(i.rawKind)?i.kind=Dn.M_POLL_KIND_DISCLOSED:i.kind=Dn.M_POLL_KIND_UNDISCLOSED,i.maxSelections=Number.isFinite(s.max_selections)&&s.max_selections>0?s.max_selections:1,!Array.isArray(s.answers))throw new el.InvalidEventError("Poll answers must be an array");var o=s.answers.slice(0,20).map(function(a){return new Iv({type:"org.matrix.sdk.poll.answer",content:a})});if(o.length<=0)throw new el.InvalidEventError("No answers available");return i.answers=o,i}return bv(t,[{key:"isEquivalentTo",value:function(i){return(0,tI.isEventTypeSame)(i,Dn.M_POLL_START)}},{key:"serialize",value:function(){var i;return{type:Dn.M_POLL_START.name,content:(i={},rr(i,Dn.M_POLL_START.name,{question:this.question.serialize().content,kind:this.rawKind,max_selections:this.maxSelections,answers:this.answers.map(function(s){return s.serialize().content})}),rr(i,Ea.M_TEXT.name,"".concat(this.question.text,`
+`).concat(this.answers.map(function(s,o){return"".concat(o+1,". ").concat(s.text)}).join(`
+`))),i)}}}],[{key:"from",value:function(i,s,o){var a,l=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;return new t({type:Dn.M_POLL_START.name,content:(a={},rr(a,Ea.M_TEXT.name,i),rr(a,Dn.M_POLL_START.name,{question:rr({},Ea.M_TEXT.name,i),kind:o instanceof eI.NamespacedValue?o.name:o,max_selections:l,answers:s.map(function(u){return rr({id:hI()},Ea.M_TEXT.name,u)})}),a)})}}]),t}(rI.ExtensibleEvent);ps.PollStartEvent=dI;var Gp="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";function hI(){return nI(Array(16)).map(function(){return Gp.charAt(Math.floor(Math.random()*Gp.length))}).join("")}var nc={},Ko={};Object.defineProperty(Ko,"__esModule",{value:!0});Ko.REFERENCE_RELATION=void 0;var fI=en,pI=new fI.NamespacedValue("m.reference");Ko.REFERENCE_RELATION=pI;function uh(n){return uh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},uh(n)}Object.defineProperty(nc,"__esModule",{value:!0});nc.PollResponseEvent=void 0;var gI=Bi,Bs=Et,mI=ii,Du=Ko,yI=si;function vI(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function Wp(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function _I(n,e,t){return e&&Wp(n.prototype,e),t&&Wp(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function EI(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&dh(n,e)}function dh(n,e){return dh=Object.setPrototypeOf||function(r,i){return r.__proto__=i,r},dh(n,e)}function SI(n){var e=wI();return function(){var r=wl(n),i;if(e){var s=wl(this).constructor;i=Reflect.construct(r,arguments,s)}else i=r.apply(this,arguments);return bI(this,i)}}function bI(n,e){if(e&&(uh(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return tl(n)}function tl(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function wI(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function wl(n){return wl=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},wl(n)}function Jo(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}var RI=function(n){EI(t,n);var e=SI(t);function t(r){var i;vI(this,t),i=e.call(this,r),Jo(tl(i),"internalAnswerIds",void 0),Jo(tl(i),"internalSpoiled",void 0),Jo(tl(i),"pollEventId",void 0);var s=i.wireContent["m.relates_to"];if(!Du.REFERENCE_RELATION.matches(s==null?void 0:s.rel_type)||typeof(s==null?void 0:s.event_id)!="string")throw new mI.InvalidEventError("Relationship must be a reference to an event");return i.pollEventId=s.event_id,i.validateAgainst(null),i}return _I(t,[{key:"answerIds",get:function(){return this.internalAnswerIds}},{key:"spoiled",get:function(){return this.internalSpoiled}},{key:"validateAgainst",value:function(i){var s=Bs.M_POLL_RESPONSE.findIn(this.wireContent);if(!Array.isArray(s==null?void 0:s.answers)){this.internalSpoiled=!0,this.internalAnswerIds=[];return}var o=s.answers;if(o.some(function(a){return typeof a!="string"})||o.length===0){this.internalSpoiled=!0,this.internalAnswerIds=[];return}if(i){if(o.some(function(a){return!i.answers.some(function(l){return l.id===a})})){this.internalSpoiled=!0,this.internalAnswerIds=[];return}o=o.slice(0,i.maxSelections)}this.internalAnswerIds=o,this.internalSpoiled=!1}},{key:"isEquivalentTo",value:function(i){return(0,yI.isEventTypeSame)(i,Bs.M_POLL_RESPONSE)}},{key:"serialize",value:function(){return{type:Bs.M_POLL_RESPONSE.name,content:Jo({"m.relates_to":{rel_type:Du.REFERENCE_RELATION.name,event_id:this.pollEventId}},Bs.M_POLL_RESPONSE.name,{answers:this.spoiled?void 0:this.answerIds})}}}],[{key:"from",value:function(i,s){return new t({type:Bs.M_POLL_RESPONSE.name,content:Jo({"m.relates_to":{rel_type:Du.REFERENCE_RELATION.name,event_id:s}},Bs.M_POLL_RESPONSE.name,{answers:i})})}}]),t}(gI.ExtensibleEvent);nc.PollResponseEvent=RI;var ic={};function hh(n){return hh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},hh(n)}Object.defineProperty(ic,"__esModule",{value:!0});ic.PollEndEvent=void 0;var Xo=Et,II=ii,xu=Ko,TI=Cn,OI=tt,kI=si,CI=Bi;function Hp(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function PI(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Hp(Object(t),!0).forEach(function(r){so(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Hp(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function MI(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function Yp(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function AI(n,e,t){return e&&Yp(n.prototype,e),t&&Yp(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function DI(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&fh(n,e)}function fh(n,e){return fh=Object.setPrototypeOf||function(r,i){return r.__proto__=i,r},fh(n,e)}function xI(n){var e=$I();return function(){var r=Rl(n),i;if(e){var s=Rl(this).constructor;i=Reflect.construct(r,arguments,s)}else i=r.apply(this,arguments);return UI(this,i)}}function UI(n,e){if(e&&(hh(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return ph(n)}function ph(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function $I(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Rl(n){return Rl=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Rl(n)}function so(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}var NI=function(n){DI(t,n);var e=xI(t);function t(r){var i;MI(this,t),i=e.call(this,r),so(ph(i),"pollEventId",void 0),so(ph(i),"closingMessage",void 0);var s=i.wireContent["m.relates_to"];if(!xu.REFERENCE_RELATION.matches(s==null?void 0:s.rel_type)||typeof(s==null?void 0:s.event_id)!="string")throw new II.InvalidEventError("Relationship must be a reference to an event");return i.pollEventId=s.event_id,i.closingMessage=new TI.MessageEvent(i.wireFormat),i}return AI(t,[{key:"isEquivalentTo",value:function(i){return(0,kI.isEventTypeSame)(i,Xo.M_POLL_END)}},{key:"serialize",value:function(){return{type:Xo.M_POLL_END.name,content:PI(so({"m.relates_to":{rel_type:xu.REFERENCE_RELATION.name,event_id:this.pollEventId}},Xo.M_POLL_END.name,{}),this.closingMessage.serialize().content)}}}],[{key:"from",value:function(i,s){var o;return new t({type:Xo.M_POLL_END.name,content:(o={"m.relates_to":{rel_type:xu.REFERENCE_RELATION.name,event_id:i}},so(o,Xo.M_POLL_END.name,{}),so(o,OI.M_TEXT.name,s),o)})}}]),t}(CI.ExtensibleEvent);ic.PollEndEvent=NI;Object.defineProperty(Vl,"__esModule",{value:!0});Vl.parseMPoll=FI;var Uu=Et,LI=ps,BI=nc,KI=ic;function FI(n){return Uu.M_POLL_START.matches(n.type)?new LI.PollStartEvent(n):Uu.M_POLL_RESPONSE.matches(n.type)?new BI.PollResponseEvent(n):Uu.M_POLL_END.matches(n.type)?new KI.PollEndEvent(n):null}Object.defineProperty(ql,"__esModule",{value:!0});ql.ExtensibleEvents=void 0;var qI=Za,jI=ii,zp=No,$u=jl,bc=tt,Nu=Et,Lu=Vl;function VI(n,e){var t=typeof Symbol!="undefined"&&n[Symbol.iterator]||n["@@iterator"];if(!t){if(Array.isArray(n)||(t=GI(n))||e&&n&&typeof n.length=="number"){t&&(n=t);var r=0,i=function(){};return{s:i,n:function(){return r>=n.length?{done:!0}:{done:!1,value:n[r++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
+In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s=!0,o=!1,a;return{s:function(){t=t.call(n)},n:function(){var u=t.next();return s=u.done,u},e:function(u){o=!0,a=u},f:function(){try{!s&&t.return!=null&&t.return()}finally{if(o)throw a}}}}function GI(n,e){if(!!n){if(typeof n=="string")return Jp(n,e);var t=Object.prototype.toString.call(n).slice(8,-1);if(t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set")return Array.from(n);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Jp(n,e)}}function Jp(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,r=new Array(e);t<e;t++)r[t]=n[t];return r}function WI(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function Xp(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function HI(n,e,t){return e&&Xp(n.prototype,e),t&&Xp(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function gh(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}var mh=function(){function n(){WI(this,n),gh(this,"interpreters",new qI.NamespacedMap([[zp.LEGACY_M_ROOM_MESSAGE,zp.parseMRoomMessage],[bc.M_MESSAGE,$u.parseMMessage],[bc.M_EMOTE,$u.parseMMessage],[bc.M_NOTICE,$u.parseMMessage],[Nu.M_POLL_START,Lu.parseMPoll],[Nu.M_POLL_RESPONSE,Lu.parseMPoll],[Nu.M_POLL_END,Lu.parseMPoll]])),gh(this,"_unknownInterpretOrder",[bc.M_MESSAGE])}return HI(n,[{key:"unknownInterpretOrder",get:function(){var t;return(t=this._unknownInterpretOrder)!==null&&t!==void 0?t:[]},set:function(t){this._unknownInterpretOrder=t}},{key:"registerInterpreter",value:function(t,r){this.interpreters.set(t,r)}},{key:"parse",value:function(t){try{if(this.interpreters.hasNamespaced(t.type))return this.interpreters.getNamespaced(t.type)(t);var r=VI(this.unknownInterpretOrder),i;try{for(r.s();!(i=r.n()).done;){var s=i.value;if(this.interpreters.has(s)){var o=this.interpreters.get(s)(t);if(o)return o}}}catch(a){r.e(a)}finally{r.f()}return null}catch(a){if(a instanceof jI.InvalidEventError)return null;throw a}}}],[{key:"defaultInstance",get:function(){return n._defaultInstance}},{key:"unknownInterpretOrder",get:function(){return n.defaultInstance.unknownInterpretOrder},set:function(t){n.defaultInstance.unknownInterpretOrder=t}},{key:"registerInterpreter",value:function(t,r){n.defaultInstance.registerInterpreter(t,r)}},{key:"parse",value:function(t){return n.defaultInstance.parse(t)}}]),n}();ql.ExtensibleEvents=mh;gh(mh,"_defaultInstance",new mh);var Tv={};Object.defineProperty(Tv,"__esModule",{value:!0});var Fo={};Object.defineProperty(Fo,"__esModule",{value:!0});Fo.LegacyMsgType=void 0;Fo.isEventLike=YI;var Bu=tt,mo;Fo.LegacyMsgType=mo;(function(n){n.Text="m.text",n.Notice="m.notice",n.Emote="m.emote"})(mo||(Fo.LegacyMsgType=mo={}));function YI(n,e){var t=n.content;return e===mo.Text?Bu.M_MESSAGE.matches(n.type)||n.type==="m.room.message"&&(t==null?void 0:t.msgtype)==="m.text":e===mo.Emote?Bu.M_EMOTE.matches(n.type)||n.type==="m.room.message"&&(t==null?void 0:t.msgtype)==="m.emote":e===mo.Notice?Bu.M_NOTICE.matches(n.type)||n.type==="m.room.message"&&(t==null?void 0:t.msgtype)==="m.notice":!1}(function(n){Object.defineProperty(n,"__esModule",{value:!0});var e=ql;Object.keys(e).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===e[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return e[R]}})});var t=Tv;Object.keys(t).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===t[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return t[R]}})});var r=ii;Object.keys(r).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===r[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return r[R]}})});var i=en;Object.keys(i).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===i[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return i[R]}})});var s=Za;Object.keys(s).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===s[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return s[R]}})});var o=ec;Object.keys(o).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===o[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return o[R]}})});var a=Fo;Object.keys(a).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===a[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return a[R]}})});var l=si;Object.keys(l).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===l[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return l[R]}})});var u=No;Object.keys(u).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===u[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return u[R]}})});var c=jl;Object.keys(c).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===c[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return c[R]}})});var g=Vl;Object.keys(g).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===g[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return g[R]}})});var m=Ko;Object.keys(m).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===m[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return m[R]}})});var f=Bi;Object.keys(f).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===f[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return f[R]}})});var E=tt;Object.keys(E).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===E[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return E[R]}})});var I=Cn;Object.keys(I).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===I[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return I[R]}})});var w=Bo;Object.keys(w).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===w[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return w[R]}})});var k=Lo;Object.keys(k).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===k[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return k[R]}})});var C=Et;Object.keys(C).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===C[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return C[R]}})});var S=ps;Object.keys(S).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===S[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return S[R]}})});var T=nc;Object.keys(T).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===T[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return T[R]}})});var D=ic;Object.keys(D).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===D[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return D[R]}})})})(Fl);var Gl={};Object.defineProperty(Gl,"__esModule",{value:!0});Gl.TEXT_NODE_TYPE=void 0;var zI=_r;const JI=new zI.UnstableValue("m.text","org.matrix.msc1767.text");Gl.TEXT_NODE_TYPE=JI;var Jr={};Object.defineProperty(Jr,"__esModule",{value:!0});Jr.M_TIMESTAMP=Jr.M_LOCATION=Jr.M_ASSET=Jr.LocationAssetType=void 0;var gf=_r;let yh;Jr.LocationAssetType=yh;(function(n){n.Self="m.self",n.Pin="m.pin"})(yh||(Jr.LocationAssetType=yh={}));const XI=new gf.UnstableValue("m.asset","org.matrix.msc3488.asset");Jr.M_ASSET=XI;const QI=new gf.UnstableValue("m.ts","org.matrix.msc3488.ts");Jr.M_TIMESTAMP=QI;const ZI=new gf.UnstableValue("m.location","org.matrix.msc3488.location");Jr.M_LOCATION=ZI;var eT=G.exports;Object.defineProperty(Xe,"__esModule",{value:!0});Xe.makeBeaconInfoContent=Xe.makeBeaconContent=Xe.getTextForLocationEvent=void 0;Xe.makeEmoteMessage=lT;Xe.makeHtmlEmote=oT;Xe.makeHtmlMessage=iT;Xe.makeHtmlNotice=sT;Xe.makeLocationContent=void 0;Xe.makeNotice=cT;Xe.makeTextMessage=aT;Xe.parseLocationEvent=Xe.parseBeaconInfoContent=void 0;var tT=eT(Y.exports),rT=Fl,Ov=Rn,As=ie,kv=Gl,St=Jr;function Qp(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function nT(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Qp(Object(t),!0).forEach(function(r){(0,tT.default)(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Qp(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function iT(n,e){return{msgtype:As.MsgType.Text,format:"org.matrix.custom.html",body:n,formatted_body:e}}function sT(n,e){return{msgtype:As.MsgType.Notice,format:"org.matrix.custom.html",body:n,formatted_body:e}}function oT(n,e){return{msgtype:As.MsgType.Emote,format:"org.matrix.custom.html",body:n,formatted_body:e}}function aT(n){return{msgtype:As.MsgType.Text,body:n}}function cT(n){return{msgtype:As.MsgType.Notice,body:n}}function lT(n){return{msgtype:As.MsgType.Emote,body:n}}const Cv=(n,e,t,r)=>{const i=`at ${new Date(t).toISOString()}`,s=e===St.LocationAssetType.Self?"User":void 0,o=r?`"${r}"`:void 0;return[s,"Location",o,n,i].filter(Boolean).join(" ")};Xe.getTextForLocationEvent=Cv;const Pv=(n,e,t,r,i)=>{const s=n!=null?n:Cv(e,i||St.LocationAssetType.Self,t,r),o=t?{[St.M_TIMESTAMP.name]:t}:{};return nT({msgtype:As.MsgType.Location,body:s,geo_uri:e,[St.M_LOCATION.name]:{description:r,uri:e},[St.M_ASSET.name]:{type:i||St.LocationAssetType.Self},[kv.TEXT_NODE_TYPE.name]:s},o)};Xe.makeLocationContent=Pv;const uT=n=>{var e,t;const r=St.M_LOCATION.findIn(n),i=St.M_ASSET.findIn(n),s=St.M_TIMESTAMP.findIn(n),o=kv.TEXT_NODE_TYPE.findIn(n),a=(e=r==null?void 0:r.uri)!==null&&e!==void 0?e:n==null?void 0:n.geo_uri,l=r==null?void 0:r.description,u=(t=i==null?void 0:i.type)!==null&&t!==void 0?t:St.LocationAssetType.Self,c=o!=null?o:n.body;return Pv(c,a,s,l,u)};Xe.parseLocationEvent=uT;const dT=(n,e,t,r,i)=>({[Ov.M_BEACON_INFO.name]:{description:t,timeout:n,live:e},[St.M_TIMESTAMP.name]:i||Date.now(),[St.M_ASSET.name]:{type:r!=null?r:St.LocationAssetType.Self}});Xe.makeBeaconInfoContent=dT;const hT=n=>{const{description:e,timeout:t,live:r}=Ov.M_BEACON_INFO.findIn(n),{type:i}=St.M_ASSET.findIn(n),s=St.M_TIMESTAMP.findIn(n);return{description:e,timeout:t,live:r,assetType:i,timestamp:s}};Xe.parseBeaconInfoContent=hT;const fT=(n,e,t,r)=>({[St.M_LOCATION.name]:{description:r,uri:n},[St.M_TIMESTAMP.name]:e,"m.relates_to":{rel_type:rT.REFERENCE_RELATION.name,event_id:t}});Xe.makeBeaconContent=fT;var pT=G.exports;Object.defineProperty(vr,"__esModule",{value:!0});vr.isTimestampInDuration=vr.isBeaconInfoEventType=vr.BeaconEvent=vr.Beacon=void 0;var wc=pT(Y.exports),Zp=Rn,gT=Xe,mT=je;let Fa;vr.BeaconEvent=Fa;(function(n){n.New="Beacon.new",n.Update="Beacon.update",n.LivenessChange="Beacon.LivenessChange"})(Fa||(vr.BeaconEvent=Fa={}));const Mv=(n,e,t)=>t>=n&&n+e>=t;vr.isTimestampInDuration=Mv;const yT=n=>n.startsWith(Zp.M_BEACON_INFO.name)||n.startsWith(Zp.M_BEACON_INFO.altName);vr.isBeaconInfoEventType=yT;class vT extends mT.TypedEventEmitter{constructor(e){super();this.rootEvent=e,(0,wc.default)(this,"roomId",void 0),(0,wc.default)(this,"_beaconInfo",void 0),(0,wc.default)(this,"_isLive",void 0),(0,wc.default)(this,"livenessWatchInterval",void 0),this.setBeaconInfo(this.rootEvent),this.roomId=this.rootEvent.getRoomId()}get isLive(){return this._isLive}get identifier(){return this.beaconInfoEventType}get beaconInfoId(){return this.rootEvent.getId()}get beaconInfoOwner(){return this.rootEvent.getStateKey()}get beaconInfoEventType(){return this.rootEvent.getType()}get beaconInfo(){return this._beaconInfo}update(e){if(e.getType()!==this.beaconInfoEventType)throw new Error("Invalid updating event");this.rootEvent=e,this.setBeaconInfo(this.rootEvent),this.emit(Fa.Update,e,this)}destroy(){this.livenessWatchInterval&&clearInterval(this.livenessWatchInterval)}monitorLiveness(){if(this.livenessWatchInterval&&clearInterval(this.livenessWatchInterval),this.isLive){var e,t;const r=((e=this._beaconInfo)===null||e===void 0?void 0:e.timestamp)+((t=this._beaconInfo)===null||t===void 0?void 0:t.timeout)+1-Date.now();r>1&&(this.livenessWatchInterval=setInterval(this.checkLiveness.bind(this),r))}}setBeaconInfo(e){this._beaconInfo=(0,gT.parseBeaconInfoContent)(e.getContent()),this.checkLiveness()}checkLiveness(){var e,t,r;const i=this.isLive;this._isLive=((e=this._beaconInfo)===null||e===void 0?void 0:e.live)&&Mv((t=this._beaconInfo)===null||t===void 0?void 0:t.timestamp,(r=this._beaconInfo)===null||r===void 0?void 0:r.timeout,Date.now()),i!==this.isLive&&this.emit(Fa.LivenessChange,this.isLive,this)}}vr.Beacon=vT;var tn={};Object.defineProperty(tn,"__esModule",{value:!0});tn.TypedReEmitter=tn.ReEmitter=void 0;class Av{constructor(e){this.target=e}reEmit(e,t){for(const r of t){const i=(...s)=>{r==="error"&&this.target.listenerCount("error")===0||this.target.emit(r,...s,e)};e.on(r,i)}}}tn.ReEmitter=Av;class _T extends Av{constructor(e){super(e)}reEmit(e,t){super.reEmit(e,t)}}tn.TypedReEmitter=_T;var ET=G.exports;Object.defineProperty(Tn,"__esModule",{value:!0});Tn.RoomStateEvent=Tn.RoomState=void 0;var xt=ET(Y.exports),eg=Zr,Ku=se,Qo=wT(W),zt=ie,Fu=Je,ST=je,Fi=vr,bT=tn;function Dv(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(Dv=function(r){return r?t:e})(n)}function wT(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=Dv(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}var mr;(function(n){n[n.NotStarted=0]="NotStarted",n[n.InProgress=1]="InProgress",n[n.Finished=2]="Finished"})(mr||(mr={}));let zr;Tn.RoomStateEvent=zr;(function(n){n.Events="RoomState.events",n.Members="RoomState.members",n.NewMember="RoomState.newMember",n.Update="RoomState.update",n.BeaconLiveness="RoomState.BeaconLiveness"})(zr||(Tn.RoomStateEvent=zr={}));class mf extends ST.TypedEventEmitter{constructor(e,t={status:mr.NotStarted}){super();this.roomId=e,this.oobMemberFlags=t,(0,xt.default)(this,"reEmitter",new bT.TypedReEmitter(this)),(0,xt.default)(this,"sentinels",{}),(0,xt.default)(this,"displayNameToUserIds",{}),(0,xt.default)(this,"userIdsToDisplayNames",{}),(0,xt.default)(this,"tokenToInvite",{}),(0,xt.default)(this,"joinedMemberCount",null),(0,xt.default)(this,"summaryJoinedMemberCount",null),(0,xt.default)(this,"invitedMemberCount",null),(0,xt.default)(this,"summaryInvitedMemberCount",null),(0,xt.default)(this,"modified",void 0),(0,xt.default)(this,"members",{}),(0,xt.default)(this,"events",new Map),(0,xt.default)(this,"paginationToken",null),(0,xt.default)(this,"beacons",new Map),(0,xt.default)(this,"liveBeaconIds",[]),this.updateModifiedTime()}getJoinedMemberCount(){return this.summaryJoinedMemberCount!==null?this.summaryJoinedMemberCount:(this.joinedMemberCount===null&&(this.joinedMemberCount=this.getMembers().reduce((e,t)=>t.membership==="join"?e+1:e,0)),this.joinedMemberCount)}setJoinedMemberCount(e){this.summaryJoinedMemberCount=e}getInvitedMemberCount(){return this.summaryInvitedMemberCount!==null?this.summaryInvitedMemberCount:(this.invitedMemberCount===null&&(this.invitedMemberCount=this.getMembers().reduce((e,t)=>t.membership==="invite"?e+1:e,0)),this.invitedMemberCount)}setInvitedMemberCount(e){this.summaryInvitedMemberCount=e}getMembers(){return Object.values(this.members)}getMembersExcept(e){return this.getMembers().filter(t=>!e.includes(t.userId))}getMember(e){return this.members[e]||null}getSentinelMember(e){if(!e)return null;let t=this.sentinels[e];if(t===void 0){t=new eg.RoomMember(this.roomId,e);const r=this.members[e];r&&t.setMembershipEvent(r.events.member,this),this.sentinels[e]=t}return t}getStateEvents(e,t){if(!this.events.has(e))return t===void 0?[]:null;if(t===void 0)return Array.from(this.events.get(e).values());const r=this.events.get(e).get(t);return r||null}get hasLiveBeacons(){var e;return!!((e=this.liveBeaconIds)!==null&&e!==void 0&&e.length)}clone(){const e=new mf(this.roomId,this.oobMemberFlags),t=this.oobMemberFlags.status;return this.oobMemberFlags.status=mr.NotStarted,Array.from(this.events.values()).forEach(r=>{e.setStateEvents(Array.from(r.values()))}),this.oobMemberFlags.status=t,this.summaryInvitedMemberCount!==null&&e.setInvitedMemberCount(this.getInvitedMemberCount()),this.summaryJoinedMemberCount!==null&&e.setJoinedMemberCount(this.getJoinedMemberCount()),this.oobMemberFlags.status==mr.Finished&&this.getMembers().forEach(r=>{r.isOutOfBand()&&e.getMember(r.userId).markOutOfBand()}),e}setUnknownStateEvents(e){const t=e.filter(r=>!this.events.has(r.getType())||!this.events.get(r.getType()).has(r.getStateKey()));this.setStateEvents(t)}setStateEvents(e){this.updateModifiedTime(),e.forEach(t=>{if(t.getRoomId()!==this.roomId||!t.isState())return;(0,Fi.isBeaconInfoEventType)(t.getType())&&this.setBeacon(t);const r=this.getStateEventMatching(t);this.setStateEvent(t),t.getType()===zt.EventType.RoomMember&&(this.updateDisplayNameCache(t.getStateKey(),t.getContent().displayname),this.updateThirdPartyTokenCache(t)),this.emit(zr.Events,t,this,r)}),this.onBeaconLivenessChange(),e.forEach(t=>{if(t.getRoomId()===this.roomId&&!!t.isState()){if(t.getType()===zt.EventType.RoomMember){const r=t.getStateKey();(t.getContent().membership==="leave"||t.getContent().membership==="ban")&&(t.getContent().avatar_url=t.getContent().avatar_url||t.getPrevContent().avatar_url,t.getContent().displayname=t.getContent().displayname||t.getPrevContent().displayname);const i=this.getOrCreateMember(r,t);i.setMembershipEvent(t,this),this.updateMember(i),this.emit(zr.Members,t,this,i)}else if(t.getType()===zt.EventType.RoomPowerLevels){if(t.getStateKey()!=="")return;Object.values(this.members).forEach(i=>{const s=i.getLastModifiedTime();i.setPowerLevelEvent(t),s!==i.getLastModifiedTime()&&this.emit(zr.Members,t,this,i)}),this.sentinels={}}}}),this.emit(zr.Update,this)}getOrCreateMember(e,t){let r=this.members[e];return r||(r=new eg.RoomMember(this.roomId,e),this.members[e]=r,this.emit(zr.NewMember,t,this,r)),r}setStateEvent(e){this.events.has(e.getType())||this.events.set(e.getType(),new Map),this.events.get(e.getType()).set(e.getStateKey(),e)}setBeacon(e){if(this.beacons.has(e.getType()))return this.beacons.get(e.getType()).update(e);const t=new Fi.Beacon(e);this.reEmitter.reEmit(t,[Fi.BeaconEvent.New,Fi.BeaconEvent.Update,Fi.BeaconEvent.LivenessChange]),this.emit(Fi.BeaconEvent.New,e,t),t.on(Fi.BeaconEvent.LivenessChange,this.onBeaconLivenessChange.bind(this)),this.beacons.set(t.beaconInfoEventType,t)}onBeaconLivenessChange(){var e;const t=!!((e=this.liveBeaconIds)!==null&&e!==void 0&&e.length);this.liveBeaconIds=Array.from(this.beacons.values()).filter(i=>i.isLive).map(i=>i.beaconInfoId);const r=!!this.liveBeaconIds.length;t!==r&&this.emit(zr.BeaconLiveness,this,r)}getStateEventMatching(e){var t,r;return(t=(r=this.events.get(e.getType()))===null||r===void 0?void 0:r.get(e.getStateKey()))!==null&&t!==void 0?t:null}updateMember(e){const t=this.getStateEvents(zt.EventType.RoomPowerLevels,"");t&&e.setPowerLevelEvent(t),delete this.sentinels[e.userId],this.members[e.userId]=e,this.joinedMemberCount=null,this.invitedMemberCount=null}needsOutOfBandMembers(){return this.oobMemberFlags.status===mr.NotStarted}markOutOfBandMembersStarted(){this.oobMemberFlags.status===mr.NotStarted&&(this.oobMemberFlags.status=mr.InProgress)}markOutOfBandMembersFailed(){this.oobMemberFlags.status===mr.InProgress&&(this.oobMemberFlags.status=mr.NotStarted)}clearOutOfBandMembers(){let e=0;Object.keys(this.members).forEach(t=>{this.members[t].isOutOfBand()&&(++e,delete this.members[t])}),Ku.logger.log(`LL: RoomState removed ${e} members...`),this.oobMemberFlags.status=mr.NotStarted}setOutOfBandMembers(e){Ku.logger.log(`LL: RoomState about to set ${e.length} OOB members ...`),this.oobMemberFlags.status===mr.InProgress&&(Ku.logger.log("LL: RoomState put in finished state ..."),this.oobMemberFlags.status=mr.Finished,e.forEach(t=>this.setOutOfBandMember(t)),this.emit(zr.Update,this))}setOutOfBandMember(e){if(e.getType()!==zt.EventType.RoomMember)return;const t=e.getStateKey(),r=this.getMember(t);if(r&&!r.isOutOfBand())return;const i=this.getOrCreateMember(t,e);i.setMembershipEvent(e,this),i.markOutOfBand(),this.updateDisplayNameCache(i.userId,i.name),this.setStateEvent(e),this.updateMember(i),this.emit(zr.Members,e,this,i)}setTypingEvent(e){Object.values(this.members).forEach(function(t){t.setTypingEvent(e)})}getInviteForThreePidToken(e){return this.tokenToInvite[e]||null}updateModifiedTime(){this.modified=Date.now()}getLastModifiedTime(){return this.modified}getUserIdsWithDisplayName(e){return this.displayNameToUserIds[Qo.removeHiddenChars(e)]||[]}maySendRedactionForEvent(e,t){const r=this.getMember(t);if(!r||r.membership==="leave"||e.status||e.isRedacted())return!1;const i=this.maySendEvent(zt.EventType.RoomRedaction,t);return e.getSender()===t?i:this.hasSufficientPowerLevelFor("redact",r.powerLevel)}hasSufficientPowerLevelFor(e,t){const r=this.getStateEvents(zt.EventType.RoomPowerLevels,"");let i={};r&&(i=r.getContent());let s=50;return Qo.isNumber(i[e])&&(s=i[e]),t>=s}maySendMessage(e){return this.maySendEventOfType(zt.EventType.RoomMessage,e,!1)}maySendEvent(e,t){return this.maySendEventOfType(e,t,!1)}mayClientSendStateEvent(e,t){return t.isGuest()?!1:this.maySendStateEvent(e,t.credentials.userId)}maySendStateEvent(e,t){return this.maySendEventOfType(e,t,!0)}maySendEventOfType(e,t,r){const i=this.getStateEvents(zt.EventType.RoomPowerLevels,"");let s,o={},a=0,l=0,u=0;if(i){s=i.getContent(),o=s.events||{},Number.isSafeInteger(s.state_default)?a=s.state_default:a=50;const g=s.users&&s.users[t];Number.isSafeInteger(g)?u=g:Number.isSafeInteger(s.users_default)&&(u=s.users_default),Number.isSafeInteger(s.events_default)&&(l=s.events_default)}let c=r?a:l;return Number.isSafeInteger(o[e])&&(c=o[e]),u>=c}mayTriggerNotifOfType(e,t){const r=this.getMember(t);if(!r)return!1;const i=this.getStateEvents(zt.EventType.RoomPowerLevels,"");let s=50;return i&&i.getContent()&&i.getContent().notifications&&Qo.isNumber(i.getContent().notifications[e])&&(s=i.getContent().notifications[e]),r.powerLevel>=s}getJoinRule(){var e;const t=this.getStateEvents(zt.EventType.RoomJoinRules,"");return((e=t==null?void 0:t.getContent())!==null&&e!==void 0?e:{}).join_rule||Fu.JoinRule.Invite}getHistoryVisibility(){var e;const t=this.getStateEvents(zt.EventType.RoomHistoryVisibility,"");return((e=t==null?void 0:t.getContent())!==null&&e!==void 0?e:{}).history_visibility||Fu.HistoryVisibility.Shared}getGuestAccess(){var e;const t=this.getStateEvents(zt.EventType.RoomGuestAccess,"");return((e=t==null?void 0:t.getContent())!==null&&e!==void 0?e:{}).guest_access||Fu.GuestAccess.Forbidden}updateThirdPartyTokenCache(e){if(!e.getContent().third_party_invite)return;const t=(e.getContent().third_party_invite.signed||{}).token;!t||!this.getStateEvents(zt.EventType.RoomThirdPartyInvite,t)||(this.tokenToInvite[t]=e)}updateDisplayNameCache(e,t){const r=this.userIdsToDisplayNames[e];if(delete this.userIdsToDisplayNames[e],r){const s=Qo.removeHiddenChars(r),o=this.displayNameToUserIds[s];if(o){const a=o.filter(l=>l!==e);this.displayNameToUserIds[s]=a}}this.userIdsToDisplayNames[e]=t;const i=t&&Qo.removeHiddenChars(t);i&&(this.displayNameToUserIds[i]||(this.displayNameToUserIds[i]=[]),this.displayNameToUserIds[i].push(e))}}Tn.RoomState=mf;var RT=G.exports;Object.defineProperty(Qa,"__esModule",{value:!0});Qa.MemoryStore=void 0;var an=RT(Y.exports),IT=Qr,tg=Tn;function rg(n){return typeof n=="string"&&!!n&&n!=="undefined"&&n!=="null"||typeof n=="number"}class TT{constructor(e={}){(0,an.default)(this,"rooms",{}),(0,an.default)(this,"groups",{}),(0,an.default)(this,"users",{}),(0,an.default)(this,"syncToken",null),(0,an.default)(this,"filters",{}),(0,an.default)(this,"accountData",{}),(0,an.default)(this,"localStorage",void 0),(0,an.default)(this,"oobMembers",{}),(0,an.default)(this,"clientOptions",{}),(0,an.default)(this,"onRoomMember",(t,r,i)=>{if(i.membership==="invite")return;const s=this.users[i.userId]||new IT.User(i.userId);i.name&&(s.setDisplayName(i.name),i.events.member&&s.setRawDisplayName(i.events.member.getDirectionalContent().displayname)),i.events.member&&i.events.member.getContent().avatar_url&&s.setAvatarUrl(i.events.member.getContent().avatar_url),this.users[s.userId]=s}),this.localStorage=e.localStorage}getSyncToken(){return this.syncToken}isNewlyCreated(){return Promise.resolve(!0)}setSyncToken(e){this.syncToken=e}storeGroup(e){this.groups[e.groupId]=e}getGroup(e){return this.groups[e]||null}getGroups(){return Object.values(this.groups)}storeRoom(e){this.rooms[e.roomId]=e,e.currentState.on(tg.RoomStateEvent.Members,this.onRoomMember),e.currentState.getMembers().forEach(t=>{this.onRoomMember(null,e.currentState,t)})}getRoom(e){return this.rooms[e]||null}getRooms(){return Object.values(this.rooms)}removeRoom(e){this.rooms[e]&&this.rooms[e].currentState.removeListener(tg.RoomStateEvent.Members,this.onRoomMember),delete this.rooms[e]}getRoomSummaries(){return Object.values(this.rooms).map(function(e){return e.summary})}storeUser(e){this.users[e.userId]=e}getUser(e){return this.users[e]||null}getUsers(){return Object.values(this.users)}scrollback(e,t){return[]}storeEvents(e,t,r,i){}storeFilter(e){!e||(this.filters[e.userId]||(this.filters[e.userId]={}),this.filters[e.userId][e.filterId]=e)}getFilter(e,t){return!this.filters[e]||!this.filters[e][t]?null:this.filters[e][t]}getFilterIdByName(e){if(!this.localStorage)return null;const t="mxjssdk_memory_filter_"+e;try{const r=this.localStorage.getItem(t);if(rg(r))return r}catch{}return null}setFilterIdByName(e,t){if(!this.localStorage)return;const r="mxjssdk_memory_filter_"+e;try{rg(t)?this.localStorage.setItem(r,t):this.localStorage.removeItem(r)}catch{}}storeAccountDataEvents(e){e.forEach(t=>{this.accountData[t.getType()]=t})}getAccountData(e){return this.accountData[e]}setSyncData(e){return Promise.resolve()}wantsSave(){return!1}save(e){}startup(){return Promise.resolve()}getSavedSync(){return Promise.resolve(null)}getSavedSyncToken(){return Promise.resolve(null)}deleteAllData(){return this.rooms={},this.users={},this.syncToken=null,this.filters={},this.accountData={},Promise.resolve()}getOutOfBandMembers(e){return Promise.resolve(this.oobMembers[e]||null)}setOutOfBandMembers(e,t){return this.oobMembers[e]=t,Promise.resolve()}clearOutOfBandMembers(e){return this.oobMembers={},Promise.resolve()}getClientOptions(){return Promise.resolve(this.clientOptions)}storeClientOptions(e){return this.clientOptions=Object.assign({},e),Promise.resolve()}}Qa.MemoryStore=TT;var Wl={},OT=G.exports;Object.defineProperty(Wl,"__esModule",{value:!0});Wl.MatrixScheduler=void 0;var Rc=OT(Y.exports),ng=CT(W),kT=ie;function xv(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(xv=function(r){return r?t:e})(n)}function CT(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=xv(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}class Il{static RETRY_BACKOFF_RATELIMIT(e,t,r){if(r.httpStatus===400||r.httpStatus===403||r.httpStatus===401||r.cors==="rejected"||r.name==="M_TOO_LARGE")return-1;if(r.name==="M_LIMIT_EXCEEDED"){const i=r.data.retry_after_ms;if(i>0)return i}return t>4?-1:1e3*Math.pow(2,t)}static QUEUE_MESSAGES(e){return e.getType()===kT.EventType.RoomMessage||e.hasAssocation()?"message":null}constructor(e=Il.RETRY_BACKOFF_RATELIMIT,t=Il.QUEUE_MESSAGES){this.retryAlgorithm=e,this.queueAlgorithm=t,(0,Rc.default)(this,"queues",{}),(0,Rc.default)(this,"activeQueues",[]),(0,Rc.default)(this,"procFn",null),(0,Rc.default)(this,"processQueue",r=>{const i=this.peekNextEvent(r);if(!i){const s=this.activeQueues.indexOf(r);s>=0&&this.activeQueues.splice(s,1);return}Zo("Queue '%s' has %s pending events",r,this.queues[r].length),Promise.resolve().then(()=>this.procFn(i.event)).then(s=>{this.removeNextEvent(r),Zo("Queue '%s' sent event %s",r,i.event.getId()),i.defer.resolve(s),this.processQueue(r)},s=>{i.attempts+=1;const o=this.retryAlgorithm(i.event,i.attempts,s);Zo("retry(%s) err=%s event_id=%s waitTime=%s",i.attempts,s,i.event.getId(),o),o===-1?(Zo("Queue '%s' giving up on event %s",r,i.event.getId()),this.removeNextEvent(r),i.defer.reject(s),this.processQueue(r)):setTimeout(this.processQueue,o,r)})})}getQueueForEvent(e){const t=this.queueAlgorithm(e);return!t||!this.queues[t]?null:this.queues[t].map(function(r){return r.event})}removeEventFromQueue(e){const t=this.queueAlgorithm(e);if(!t||!this.queues[t])return!1;let r=!1;return ng.removeElement(this.queues[t],i=>{if(i.event.getId()===e.getId())return r=!0,!0}),r}setProcessFunction(e){this.procFn=e,this.startProcessingQueues()}queueEvent(e){const t=this.queueAlgorithm(e);if(!t)return null;this.queues[t]||(this.queues[t]=[]);const r=ng.defer();return this.queues[t].push({event:e,defer:r,attempts:0}),Zo("Queue algorithm dumped event %s into queue '%s'",e.getId(),t),this.startProcessingQueues(),r.promise}startProcessingQueues(){!this.procFn||Object.keys(this.queues).filter(e=>this.activeQueues.indexOf(e)===-1&&this.queues[e].length>0).forEach(e=>{this.activeQueues.push(e),this.processQueue(e)})}peekNextEvent(e){const t=this.queues[e];return Array.isArray(t)?t[0]:null}removeNextEvent(e){const t=this.queues[e];return Array.isArray(t)?t.shift():null}}Wl.MatrixScheduler=Il;function Zo(...n){}var st={},$i={},lr={},ti={},qt={},PT=G.exports;Object.defineProperty(qt,"__esModule",{value:!0});qt.EventTimeline=qt.Direction=void 0;var Yr=PT(Y.exports),ig=Tn,MT=ie;let gs;qt.Direction=gs;(function(n){n.Backward="b",n.Forward="f"})(gs||(qt.Direction=gs={}));class nr{static setEventMetadata(e,t,r){var i,s,o,a;(i=e.sender)!==null&&i!==void 0&&(s=i.events)!==null&&s!==void 0&&s.member||(e.sender=t.getSentinelMember(e.getSender())),!((o=e.target)!==null&&o!==void 0&&(a=o.events)!==null&&a!==void 0&&a.member)&&e.getType()===MT.EventType.RoomMember&&(e.target=t.getSentinelMember(e.getStateKey())),e.isState()&&r&&(e.forwardLooking=!1)}constructor(e){var t,r;this.eventTimelineSet=e,(0,Yr.default)(this,"roomId",void 0),(0,Yr.default)(this,"name",void 0),(0,Yr.default)(this,"events",[]),(0,Yr.default)(this,"baseIndex",0),(0,Yr.default)(this,"startState",void 0),(0,Yr.default)(this,"endState",void 0),(0,Yr.default)(this,"prevTimeline",void 0),(0,Yr.default)(this,"nextTimeline",void 0),(0,Yr.default)(this,"paginationRequests",{[gs.Backward]:null,[gs.Forward]:null}),this.roomId=(t=(r=e.room)===null||r===void 0?void 0:r.roomId)!==null&&t!==void 0?t:null,this.startState=new ig.RoomState(this.roomId),this.startState.paginationToken=null,this.endState=new ig.RoomState(this.roomId),this.endState.paginationToken=null,this.prevTimeline=null,this.nextTimeline=null,this.paginationRequests={b:null,f:null},this.name=this.roomId+":"+new Date().toISOString()}initialiseState(e){if(this.events.length>0)throw new Error("Cannot initialise state after events are added");for(const t of e)Object.freeze(t);this.startState.setStateEvents(e),this.endState.setStateEvents(e)}forkLive(e){const t=this.getState(e),r=new nr(this.eventTimelineSet);return r.startState=t.clone(),r.endState=t,this.endState=t.clone(),r}fork(e){const t=this.getState(e),r=new nr(this.eventTimelineSet);return r.startState=t.clone(),r.endState=t.clone(),r}getRoomId(){return this.roomId}getFilter(){return this.eventTimelineSet.getFilter()}getTimelineSet(){return this.eventTimelineSet}getBaseIndex(){return this.baseIndex}getEvents(){return this.events}getState(e){if(e==nr.BACKWARDS)return this.startState;if(e==nr.FORWARDS)return this.endState;throw new Error("Invalid direction '"+e+"'")}getPaginationToken(e){return this.getState(e).paginationToken}setPaginationToken(e,t){this.getState(t).paginationToken=e}getNeighbouringTimeline(e){if(e==nr.BACKWARDS)return this.prevTimeline;if(e==nr.FORWARDS)return this.nextTimeline;throw new Error("Invalid direction '"+e+"'")}setNeighbouringTimeline(e,t){if(this.getNeighbouringTimeline(t))throw new Error("timeline already has a neighbouring timeline - cannot reset neighbour (direction: "+t+")");if(t==nr.BACKWARDS)this.prevTimeline=e;else if(t==nr.FORWARDS)this.nextTimeline=e;else throw new Error("Invalid direction '"+t+"'");this.setPaginationToken(null,t)}addEvent(e,t,r){r||(r=t?this.startState:this.endState);const i=this.getTimelineSet();i.room&&(nr.setEventMetadata(e,r,t),e.isState()&&i.room.getUnfilteredTimelineSet()===i&&(r.setStateEvents([e]),(!e.sender||e.getType()==="m.room.member"&&!t)&&nr.setEventMetadata(e,r,t)));let s;t?s=0:s=this.events.length,this.events.splice(s,0,e),t&&this.baseIndex++}removeEvent(e){for(let t=this.events.length-1;t>=0;t--){const r=this.events[t];if(r.getId()==e)return this.events.splice(t,1),t<this.baseIndex&&this.baseIndex--,r}return null}toString(){return this.name}}qt.EventTimeline=nr;(0,Yr.default)(nr,"BACKWARDS",gs.Backward);(0,Yr.default)(nr,"FORWARDS",gs.Forward);var jt={},lt={},AT=G.exports;Object.defineProperty(lt,"__esModule",{value:!0});lt.ThreadFilterType=lt.ThreadEvent=lt.Thread=lt.THREAD_RELATION_TYPE=lt.FILTER_RELATED_BY_SENDERS=lt.FILTER_RELATED_BY_REL_TYPES=void 0;var Hr=AT(Y.exports),Ic=Cs,DT=tn,sg=jt,qu=qt,xT=ti,UT=je,yf=_r;let yo;lt.ThreadEvent=yo;(function(n){n.New="Thread.new",n.Update="Thread.update",n.NewReply="Thread.newReply",n.ViewThread="Thread.viewThread"})(yo||(lt.ThreadEvent=yo={}));class pn extends UT.TypedEventEmitter{constructor(e,t){var r;super();if(this.rootEvent=e,(0,Hr.default)(this,"timelineSet",void 0),(0,Hr.default)(this,"_currentUserParticipated",!1),(0,Hr.default)(this,"reEmitter",void 0),(0,Hr.default)(this,"lastEvent",void 0),(0,Hr.default)(this,"replyCount",0),(0,Hr.default)(this,"room",void 0),(0,Hr.default)(this,"client",void 0),(0,Hr.default)(this,"initialEventsFetched",!1),(0,Hr.default)(this,"id",void 0),(0,Hr.default)(this,"onEcho",o=>{this.timelineSet.eventIdToTimeline(o.getId())&&this.emit(yo.Update,this)}),this.room=t.room,this.client=t.client,this.timelineSet=new xT.EventTimelineSet(this.room,{unstableClientRelationAggregation:!0,timelineSupport:!0,pendingEvents:!0}),this.reEmitter=new DT.TypedReEmitter(this),this.reEmitter.reEmit(this.timelineSet,[Ic.RoomEvent.Timeline,Ic.RoomEvent.TimelineReset]),e)this.id=e.getId();else{var i,s;this.id=t==null||(i=t.initialEvents)===null||i===void 0||(s=i.find(o=>o.isThreadRelation))===null||s===void 0?void 0:s.relationEventId}this.initialiseThread(this.rootEvent),t==null||(r=t.initialEvents)===null||r===void 0||r.forEach(o=>this.addEvent(o,!1)),this.room.on(Ic.RoomEvent.LocalEchoUpdated,this.onEcho),this.room.on(Ic.RoomEvent.Timeline,this.onEcho)}static setServerSideSupport(e,t){pn.hasServerSideSupport=e,t||(Uv.setPreferUnstable(!0),$v.setPreferUnstable(!0),Sa.setPreferUnstable(!0))}get roomState(){return this.room.getLiveTimeline().getState(qu.EventTimeline.FORWARDS)}addEventToTimeline(e,t){if(e.getUnsigned().transaction_id){const r=this.room.getEventForTxnId(e.getUnsigned().transaction_id);if(r){this.room.handleRemoteEcho(e,r);return}}this.findEventById(e.getId())||this.timelineSet.addEventToTimeline(e,this.liveTimeline,t,!1,this.roomState)}async addEvent(e,t){var r;pn.hasServerSideSupport||(e.setThread(this),this.addEventToTimeline(e,t),await this.client.decryptEventIfNeeded(e,{})),pn.hasServerSideSupport&&this.initialEventsFetched&&e.localTimestamp>this.lastReply().localTimestamp&&this.addEventToTimeline(e,!1),!this._currentUserParticipated&&e.getSender()===this.client.getUserId()&&(this._currentUserParticipated=!0);const i=((r=e.getRelation())===null||r===void 0?void 0:r.rel_type)===Sa.name;!pn.hasServerSideSupport&&i&&this.replyCount++,(!this.lastEvent||i&&e.getId()!==this.lastEvent.getId()&&e.localTimestamp>this.lastEvent.localTimestamp)&&(this.lastEvent=e,this.lastEvent.getId()!==this.id&&(pn.hasServerSideSupport&&this.replyCount++,this.emit(yo.NewReply,this,e))),this.emit(yo.Update,this)}initialiseThread(e){const t=e==null?void 0:e.getServerAggregatedRelation(Sa.name);if(pn.hasServerSideSupport&&t){this.replyCount=t.count,this._currentUserParticipated=t.current_user_participated;const r=new sg.MatrixEvent(t.latest_event);this.setEventMetadata(r),this.lastEvent=r}}async fetchInitialEvents(){if(!pn.hasServerSideSupport)return this.initialEventsFetched=!0,null;try{const e=await this.fetchEvents();return this.initialEventsFetched=!0,e}catch{return null}}setEventMetadata(e){qu.EventTimeline.setEventMetadata(e,this.roomState,!1),e.setThread(this)}findEventById(e){return this.timelineSet.findEventById(e)}lastReply(e=()=>!0){for(let t=this.events.length-1;t>=0;t--){const r=this.events[t];if(e(r))return r}}get roomId(){return this.room.roomId}get length(){return this.replyCount}get replyToEvent(){return this.lastEvent}get events(){return this.liveTimeline.getEvents()}has(e){return this.timelineSet.findEventById(e)instanceof sg.MatrixEvent}get hasCurrentUserParticipated(){return this._currentUserParticipated}get liveTimeline(){return this.timelineSet.getLiveTimeline()}async fetchEvents(e={limit:20}){let{originalEvent:t,events:r,prevBatch:i,nextBatch:s}=await this.client.relations(this.room.roomId,this.id,Sa.name,null,e);!e.to&&!s&&(r=[...r,t]),await Promise.all(r.map(a=>(this.setEventMetadata(a),this.client.decryptEventIfNeeded(a))));const o=!e.direction||e.direction===qu.Direction.Backward;return this.timelineSet.addEventsToTimeline(r,o,this.liveTimeline,o?s:i),{originalEvent:t,events:r,prevBatch:i,nextBatch:s}}}lt.Thread=pn;(0,Hr.default)(pn,"hasServerSideSupport",void 0);const Uv=new yf.ServerControlledNamespacedValue("related_by_senders","io.element.relation_senders");lt.FILTER_RELATED_BY_SENDERS=Uv;const $v=new yf.ServerControlledNamespacedValue("related_by_rel_types","io.element.relation_types");lt.FILTER_RELATED_BY_REL_TYPES=$v;const Sa=new yf.ServerControlledNamespacedValue("m.thread","io.element.thread");lt.THREAD_RELATION_TYPE=Sa;let vh;lt.ThreadFilterType=vh;(function(n){n[n.My=0]="My",n[n.All=1]="All"})(vh||(lt.ThreadFilterType=vh={}));var qo={};Object.defineProperty(qo,"__esModule",{value:!0});qo.EventStatus=void 0;let _h;qo.EventStatus=_h;(function(n){n.NOT_SENT="not_sent",n.ENCRYPTING="encrypting",n.SENDING="sending",n.QUEUED="queued",n.SENT="sent",n.CANCELLED="cancelled"})(_h||(qo.EventStatus=_h={}));(function(n){var e=G.exports;Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"EventStatus",{enumerable:!0,get:function(){return c.EventStatus}}),n.MatrixEventEvent=n.MatrixEvent=void 0;var t=e(Y.exports),r=Fl,i=se,s=ie,o=W,a=lt,l=tn,u=je,c=qo;const g={};function m(C){return g[C]||(g[C]=C),g[C]}const f=Object.freeze({visible:!0});let E;n.MatrixEventEvent=E,function(C){C.Decrypted="Event.decrypted",C.BeforeRedaction="Event.beforeRedaction",C.VisibilityChange="Event.visibilityChange",C.LocalEventIdReplaced="Event.localEventIdReplaced",C.Status="Event.status",C.Replaced="Event.replaced",C.RelationsCreated="Event.relationsCreated"}(E||(n.MatrixEventEvent=E={}));class I extends u.TypedEventEmitter{constructor(S={}){var T;super();this.event=S,(0,t.default)(this,"pushActions",null),(0,t.default)(this,"_replacingEvent",null),(0,t.default)(this,"_localRedactionEvent",null),(0,t.default)(this,"_isCancelled",!1),(0,t.default)(this,"clearEvent",void 0),(0,t.default)(this,"visibility",f),(0,t.default)(this,"_hasCachedExtEv",!1),(0,t.default)(this,"_cachedExtEv",void 0),(0,t.default)(this,"senderCurve25519Key",null),(0,t.default)(this,"claimedEd25519Key",null),(0,t.default)(this,"forwardingCurve25519KeyChain",[]),(0,t.default)(this,"untrusted",null),(0,t.default)(this,"_decryptionPromise",null),(0,t.default)(this,"retryDecryption",!1),(0,t.default)(this,"txnId",null),(0,t.default)(this,"thread",null),(0,t.default)(this,"threadId",void 0),(0,t.default)(this,"localTimestamp",void 0),(0,t.default)(this,"sender",null),(0,t.default)(this,"target",null),(0,t.default)(this,"status",null),(0,t.default)(this,"error",null),(0,t.default)(this,"forwardLooking",!0),(0,t.default)(this,"verificationRequest",null),(0,t.default)(this,"reEmitter",void 0),["state_key","type","sender","room_id","membership"].forEach(D=>{typeof S[D]=="string"&&(S[D]=m(S[D]))}),["membership","avatar_url","displayname"].forEach(D=>{var R;typeof((R=S.content)===null||R===void 0?void 0:R[D])=="string"&&(S.content[D]=m(S.content[D]))}),["rel_type"].forEach(D=>{var R,U;typeof((R=S.content)===null||R===void 0||(U=R["m.relates_to"])===null||U===void 0?void 0:U[D])=="string"&&(S.content["m.relates_to"][D]=m(S.content["m.relates_to"][D]))}),this.txnId=S.txn_id||null,this.localTimestamp=Date.now()-((T=this.getAge())!==null&&T!==void 0?T:0),this.reEmitter=new l.TypedReEmitter(this)}get unstableExtensibleEvent(){return this._hasCachedExtEv||(this._cachedExtEv=r.ExtensibleEvents.parse(this.getEffectiveEvent())),this._cachedExtEv}invalidateExtensibleEvent(){this._hasCachedExtEv=!1}getEffectiveEvent(){const S=Object.assign({},this.getContent());if(this.getWireType()===s.EventType.RoomMessageEncrypted)for(const[T,D]of Object.entries(this.getWireContent()))["algorithm","ciphertext","device_id","sender_key","session_id"].includes(T)||S[T]===void 0&&(S[T]=D);return Object.assign({},this.event,this.clearEvent,{content:S})}getId(){return this.event.event_id}getSender(){return this.event.sender||this.event.user_id}getType(){return this.clearEvent?this.clearEvent.type:this.event.type}getWireType(){return this.event.type}getRoomId(){return this.event.room_id}getTs(){return this.event.origin_server_ts}getDate(){return this.event.origin_server_ts?new Date(this.event.origin_server_ts):null}getOriginalContent(){return this._localRedactionEvent?{}:this.clearEvent?this.clearEvent.content||{}:this.event.content||{}}getContent(){return this._localRedactionEvent?{}:this._replacingEvent?this._replacingEvent.getContent()["m.new_content"]||{}:this.getOriginalContent()}getWireContent(){return this.event.content||{}}get threadRootId(){var S;const T=(S=this.getWireContent())===null||S===void 0?void 0:S["m.relates_to"];if((T==null?void 0:T.rel_type)===a.THREAD_RELATION_TYPE.name)return T.event_id;var D;return((D=this.getThread())===null||D===void 0?void 0:D.id)||this.threadId}get isThreadRelation(){return!!this.threadRootId&&this.threadId!==this.getId()}get isThreadRoot(){var S;return!!this.getServerAggregatedRelation(a.THREAD_RELATION_TYPE.name)||((S=this.getThread())===null||S===void 0?void 0:S.id)===this.getId()}get replyEventId(){var S;const T=this.getContent()["m.relates_to"]||this.getWireContent()["m.relates_to"];return T==null||(S=T["m.in_reply_to"])===null||S===void 0?void 0:S.event_id}get relationEventId(){var S,T;return(S=this.getWireContent())===null||S===void 0||(T=S["m.relates_to"])===null||T===void 0?void 0:T.event_id}getPrevContent(){return this.getUnsigned().prev_content||this.event.prev_content||{}}getDirectionalContent(){return this.forwardLooking?this.getContent():this.getPrevContent()}getAge(){return this.getUnsigned().age||this.event.age}getLocalAge(){return Date.now()-this.localTimestamp}getStateKey(){return this.event.state_key}isState(){return this.event.state_key!==void 0}makeEncrypted(S,T,D,R){this.clearEvent={type:this.event.type,content:this.event.content},this.event.type=S,this.event.content=T,this.senderCurve25519Key=D,this.claimedEd25519Key=R}isBeingDecrypted(){return this._decryptionPromise!=null}getDecryptionPromise(){return this._decryptionPromise}isDecryptionFailure(){var S,T;return((S=this.clearEvent)===null||S===void 0||(T=S.content)===null||T===void 0?void 0:T.msgtype)==="m.bad.encrypted"}shouldAttemptDecryption(){return!(this.isRedacted()||this.isBeingDecrypted()||this.clearEvent||!this.isEncrypted())}async attemptDecryption(S,T={}){if(typeof T=="boolean"&&(T={isRetry:T}),!this.isEncrypted())throw new Error("Attempt to decrypt event which isn't encrypted");if(this.clearEvent&&!this.isDecryptionFailure())throw new Error("Attempt to decrypt event which has already been decrypted");return this._decryptionPromise?(i.logger.log(`Event ${this.getId()} already being decrypted; queueing a retry`),this.retryDecryption=!0,this._decryptionPromise):(this._decryptionPromise=this.decryptionLoop(S,T),this._decryptionPromise)}cancelAndResendKeyRequest(S,T){const D=this.getWireContent();return S.requestRoomKey({algorithm:D.algorithm,room_id:this.getRoomId(),session_id:D.session_id,sender_key:D.sender_key},this.getKeyRequestRecipients(T),!0)}getKeyRequestRecipients(S){const T=this.getWireContent(),D=[{userId:S,deviceId:"*"}],R=this.getSender();return R!==S&&D.push({userId:R,deviceId:T.device_id}),D}async decryptionLoop(S,T={}){for(await Promise.resolve();;){this.retryDecryption=!1;let D,R;try{S?(D=await S.decryptEvent(this),T.isRetry===!0&&i.logger.info(`Decrypted event on retry (id=${this.getId()})`)):D=this.badEncryptedMessage("Encryption not enabled")}catch(U){if(U.name!=="DecryptionError"){const q=T.isRetry?"re":"";i.logger.error(`Error ${q}decrypting event (id=${this.getId()}): ${U.stack||U}`),this._decryptionPromise=null,this.retryDecryption=!1;return}if(R=U,this.retryDecryption){i.logger.log(`Got error decrypting event (id=${this.getId()}: ${U}), but retrying`);continue}i.logger.warn(`Error decrypting event (id=${this.getId()}): ${U.detailedString}`),D=this.badEncryptedMessage(U.message)}this._decryptionPromise=null,this.retryDecryption=!1,this.setClearData(D),this.setPushActions(null),T.emit!==!1&&this.emit(E.Decrypted,this,R);return}}badEncryptedMessage(S){return{clearEvent:{type:s.EventType.RoomMessage,content:{msgtype:"m.bad.encrypted",body:"** Unable to decrypt: "+S+" **"}}}}setClearData(S){this.clearEvent=S.clearEvent,this.senderCurve25519Key=S.senderCurve25519Key||null,this.claimedEd25519Key=S.claimedEd25519Key||null,this.forwardingCurve25519KeyChain=S.forwardingCurve25519KeyChain||[],this.untrusted=S.untrusted||!1,this.invalidateExtensibleEvent()}getClearContent(){return this.clearEvent?this.clearEvent.content:null}isEncrypted(){return!this.isState()&&this.event.type===s.EventType.RoomMessageEncrypted}getSenderKey(){return this.senderCurve25519Key}getKeysClaimed(){return{ed25519:this.claimedEd25519Key}}getClaimedEd25519Key(){return this.claimedEd25519Key}getForwardingCurve25519KeyChain(){return this.forwardingCurve25519KeyChain}isKeySourceUntrusted(){return this.untrusted}getUnsigned(){return this.event.unsigned||{}}setUnsigned(S){this.event.unsigned=S}unmarkLocallyRedacted(){const S=this._localRedactionEvent;return this._localRedactionEvent=null,this.event.unsigned&&(this.event.unsigned.redacted_because=null),!!S}markLocallyRedacted(S){this._localRedactionEvent||(this.emit(E.BeforeRedaction,this,S),this._localRedactionEvent=S,this.event.unsigned||(this.event.unsigned={}),this.event.unsigned.redacted_because=S.event)}applyVisibilityEvent(S){const T=S?S.visible:!0,D=S?S.reason:null;let R=!1;(this.visibility.visible!==S.visible||!this.visibility.visible&&this.visibility.reason!==D)&&(R=!0),R&&(T?this.visibility=f:this.visibility=Object.freeze({visible:!1,reason:D}),R&&this.emit(E.VisibilityChange,this,T))}messageVisibility(){return this.visibility}makeRedacted(S){if(!S.event)throw new Error("invalid redactionEvent in makeRedacted");this._localRedactionEvent=null,this.emit(E.BeforeRedaction,this,S),this._replacingEvent=null,this.event.unsigned||(this.event.unsigned={}),this.event.unsigned.redacted_because=S.event;let T;for(T in this.event)!this.event.hasOwnProperty(T)||w.has(T)||delete this.event[T];const D=k[this.getType()]||{},R=this.getContent();for(T in R)!R.hasOwnProperty(T)||D[T]||delete R[T];this.invalidateExtensibleEvent()}isRedacted(){return Boolean(this.getUnsigned().redacted_because)}isRedaction(){return this.getType()===s.EventType.RoomRedaction}asVisibilityChange(){if(!s.EVENT_VISIBILITY_CHANGE_TYPE.matches(this.getType()))return null;const S=this.getRelation();if(!S||S.rel_type!="m.reference")return null;const T=S.event_id;if(!T)return null;const D=this.getWireContent(),R=!!D.visible,U=D.reason;return U&&typeof U!="string"?null:{visible:R,reason:U,eventId:T}}isVisibilityEvent(){return s.EVENT_VISIBILITY_CHANGE_TYPE.matches(this.getType())}getRedactionEvent(){var S;if(!this.isRedacted())return null;if((S=this.clearEvent)!==null&&S!==void 0&&S.unsigned){var T;return(T=this.clearEvent)===null||T===void 0?void 0:T.unsigned.redacted_because}else return this.event.unsigned.redacted_because?this.event.unsigned.redacted_because:{}}getPushActions(){return this.pushActions}setPushActions(S){this.pushActions=S}handleRemoteEcho(S){const T=this.getUnsigned(),D=this.getId();this.event=S,T.redacted_because&&(this.event.unsigned||(this.event.unsigned={}),this.event.unsigned.redacted_because=T.redacted_because),this.setStatus(null),this.getId()!==D&&this.emit(E.LocalEventIdReplaced,this),this.localTimestamp=Date.now()-this.getAge()}isSending(){return!!this.status}setStatus(S){this.status=S,this.emit(E.Status,this,S)}replaceLocalEventId(S){this.event.event_id=S,this.emit(E.LocalEventIdReplaced,this)}isRelation(S=void 0){const T=this.getWireContent(),D=T&&T["m.relates_to"];return D&&D.rel_type&&D.event_id&&(S&&D.rel_type===S||!S)}getRelation(){return this.isRelation()?this.getWireContent()["m.relates_to"]:null}makeReplaced(S){this.isRedacted()&&S||this._replacingEvent!==S&&(this._replacingEvent=S,this.emit(E.Replaced,this),this.invalidateExtensibleEvent())}getAssociatedStatus(){return this._replacingEvent?this._replacingEvent.status:this._localRedactionEvent?this._localRedactionEvent.status:this.status}getServerAggregatedRelation(S){var T;return(T=this.getUnsigned()["m.relations"])===null||T===void 0?void 0:T[S]}replacingEventId(){const S=this.getServerAggregatedRelation(s.RelationType.Replace);if(S)return S.event_id;if(this._replacingEvent)return this._replacingEvent.getId()}replacingEvent(){return this._replacingEvent}replacingEventDate(){const S=this.getServerAggregatedRelation(s.RelationType.Replace);if(S){const T=S.origin_server_ts;if(Number.isFinite(T))return new Date(T)}else if(this._replacingEvent)return this._replacingEvent.getDate()}localRedactionEvent(){return this._localRedactionEvent}getAssociatedId(){const S=this.getRelation();if(this.replyEventId)return this.replyEventId;if(S)return S.event_id;if(this.isRedaction())return this.event.redacts}hasAssocation(){return!!this.getAssociatedId()}updateAssociatedId(S){const T=this.getRelation();T?T.event_id=S:this.isRedaction()&&(this.event.redacts=S)}flagCancelled(S=!0){this._isCancelled=S}isCancelled(){return this._isCancelled}toSnapshot(){const S=new I(JSON.parse(JSON.stringify(this.event)));for(const[T,D]of Object.entries(this))T!=="event"&&(S[T]=D);return S}isEquivalentTo(S){if(!S)return!1;if(S===this)return!0;const T=(0,o.deepSortedObjectEntries)(this.event),D=(0,o.deepSortedObjectEntries)(S.event);return JSON.stringify(T)===JSON.stringify(D)}toJSON(){const S=this.getEffectiveEvent();return this.isEncrypted()?{decrypted:S,encrypted:this.event}:S}setVerificationRequest(S){this.verificationRequest=S}setTxnId(S){this.txnId=S}getTxnId(){return this.txnId}setThread(S){this.thread=S,this.setThreadId(S.id),this.reEmitter.reEmit(S,[a.ThreadEvent.Update])}getThread(){return this.thread}setThreadId(S){this.threadId=S}}n.MatrixEvent=I;const w=new Set(["event_id","type","room_id","user_id","sender","state_key","prev_state","content","unsigned","origin_server_ts"]),k={[s.EventType.RoomMember]:{membership:1},[s.EventType.RoomCreate]:{creator:1},[s.EventType.RoomJoinRules]:{join_rule:1},[s.EventType.RoomPowerLevels]:{ban:1,events:1,events_default:1,kick:1,redact:1,state_default:1,users:1,users_default:1},[s.EventType.RoomAliases]:{aliases:1}}})(jt);var ms={},$T=G.exports;Object.defineProperty(ms,"__esModule",{value:!0});ms.RelationsEvent=ms.Relations=void 0;var xn=$T(Y.exports),qi=jt,Tc=se,Vr=ie,NT=je;let vo;ms.RelationsEvent=vo;(function(n){n.Add="Relations.add",n.Remove="Relations.remove",n.Redaction="Relations.redaction"})(vo||(ms.RelationsEvent=vo={}));class LT extends NT.TypedEventEmitter{constructor(e,t,r){super();this.relationType=e,this.eventType=t,this.room=r,(0,xn.default)(this,"relationEventIds",new Set),(0,xn.default)(this,"relations",new Set),(0,xn.default)(this,"annotationsByKey",{}),(0,xn.default)(this,"annotationsBySender",{}),(0,xn.default)(this,"sortedAnnotationsByKey",[]),(0,xn.default)(this,"targetEvent",null),(0,xn.default)(this,"creationEmitted",!1),(0,xn.default)(this,"onEventStatus",(i,s)=>{if(!i.isSending()){i.removeListener(qi.MatrixEventEvent.Status,this.onEventStatus);return}s===qi.EventStatus.CANCELLED&&(i.removeListener(qi.MatrixEventEvent.Status,this.onEventStatus),this.removeEvent(i))}),(0,xn.default)(this,"onBeforeRedaction",async i=>{if(!!this.relations.has(i)){if(this.relations.delete(i),this.relationType===Vr.RelationType.Annotation)this.removeAnnotationFromAggregation(i);else if(this.relationType===Vr.RelationType.Replace&&this.targetEvent){const s=await this.getLastReplacement();this.targetEvent.makeReplaced(s)}i.removeListener(qi.MatrixEventEvent.BeforeRedaction,this.onBeforeRedaction),this.emit(vo.Redaction,i)}})}async addEvent(e){if(this.relationEventIds.has(e.getId()))return;const t=e.getRelation();if(!t){Tc.logger.error("Event must have relation info");return}const r=t.rel_type,i=e.getType();if(this.relationType!==r||this.eventType!==i){Tc.logger.error("Event relation info doesn't match this container");return}if(e.isSending()&&e.on(qi.MatrixEventEvent.Status,this.onEventStatus),this.relations.add(e),this.relationEventIds.add(e.getId()),this.relationType===Vr.RelationType.Annotation)this.addAnnotationToAggregation(e);else if(this.relationType===Vr.RelationType.Replace&&this.targetEvent){const s=await this.getLastReplacement();this.targetEvent.makeReplaced(s)}e.on(qi.MatrixEventEvent.BeforeRedaction,this.onBeforeRedaction),this.emit(vo.Add,e),this.maybeEmitCreated()}async removeEvent(e){if(!this.relations.has(e))return;const t=e.getRelation();if(!t){Tc.logger.error("Event must have relation info");return}const r=t.rel_type,i=e.getType();if(this.relationType!==r||this.eventType!==i){Tc.logger.error("Event relation info doesn't match this container");return}if(this.relations.delete(e),this.relationType===Vr.RelationType.Annotation)this.removeAnnotationFromAggregation(e);else if(this.relationType===Vr.RelationType.Replace&&this.targetEvent){const s=await this.getLastReplacement();this.targetEvent.makeReplaced(s)}this.emit(vo.Remove,e)}getRelations(){return[...this.relations]}addAnnotationToAggregation(e){const{key:t}=e.getRelation();if(!t)return;let r=this.annotationsByKey[t];r||(r=this.annotationsByKey[t]=new Set,this.sortedAnnotationsByKey.push([t,r])),r.add(e),this.sortedAnnotationsByKey.sort((o,a)=>{const l=o[1];return a[1].size-l.size});const i=e.getSender();let s=this.annotationsBySender[i];s||(s=this.annotationsBySender[i]=new Set),s.add(e)}removeAnnotationFromAggregation(e){const{key:t}=e.getRelation();if(!t)return;const r=this.annotationsByKey[t];r&&(r.delete(e),this.sortedAnnotationsByKey.sort((o,a)=>{const l=o[1];return a[1].size-l.size}));const i=e.getSender(),s=this.annotationsBySender[i];s&&s.delete(e)}getSortedAnnotationsByKey(){return this.relationType!==Vr.RelationType.Annotation?null:this.sortedAnnotationsByKey}getAnnotationsBySender(){return this.relationType!==Vr.RelationType.Annotation?null:this.annotationsBySender}async getLastReplacement(){if(this.relationType!==Vr.RelationType.Replace||!this.targetEvent)return null;const e=this.targetEvent.getServerAggregatedRelation(Vr.RelationType.Replace),t=e&&e.origin_server_ts,r=this.getRelations().reduce((i,s)=>s.getSender()!==this.targetEvent.getSender()||t&&t>s.getTs()||i&&i.getTs()>s.getTs()?i:s,null);return r!=null&&r.shouldAttemptDecryption()?await r.attemptDecryption(this.room.client.crypto):r!=null&&r.isBeingDecrypted()&&await r.getDecryptionPromise(),r}async setTargetEvent(e){if(!this.targetEvent){if(this.targetEvent=e,this.relationType===Vr.RelationType.Replace){const t=await this.getLastReplacement();t&&this.targetEvent.makeReplaced(t)}this.maybeEmitCreated()}}maybeEmitCreated(){this.creationEmitted||!this.targetEvent||!this.relations.size||(this.creationEmitted=!0,this.targetEvent.emit(qi.MatrixEventEvent.RelationsCreated,this.relationType,this.eventType))}}ms.Relations=LT;var BT=G.exports;Object.defineProperty(ti,"__esModule",{value:!0});ti.EventTimelineSet=ti.DuplicateStrategy=void 0;var vi=BT(Y.exports),dt=qt,og=jt,is=se,KT=ms,ju=lr,FT=je;let oo;oo=is.logger.log.bind(is.logger);let qa;ti.DuplicateStrategy=qa;(function(n){n.Ignore="ignore",n.Replace="replace"})(qa||(ti.DuplicateStrategy=qa={}));class qT extends FT.TypedEventEmitter{constructor(e,t){super();this.room=e,(0,vi.default)(this,"timelineSupport",void 0),(0,vi.default)(this,"unstableClientRelationAggregation",void 0),(0,vi.default)(this,"displayPendingEvents",void 0),(0,vi.default)(this,"liveTimeline",void 0),(0,vi.default)(this,"timelines",void 0),(0,vi.default)(this,"_eventIdToTimeline",void 0),(0,vi.default)(this,"filter",void 0),(0,vi.default)(this,"relations",void 0),this.timelineSupport=Boolean(t.timelineSupport),this.liveTimeline=new dt.EventTimeline(this),this.unstableClientRelationAggregation=!!t.unstableClientRelationAggregation,this.displayPendingEvents=t.pendingEvents!==!1,this.timelines=[this.liveTimeline],this._eventIdToTimeline={},this.filter=t.filter,this.unstableClientRelationAggregation&&(this.relations={})}getTimelines(){return this.timelines}getFilter(){return this.filter}setFilter(e){this.filter=e}getPendingEvents(){return!this.room||!this.displayPendingEvents?[]:this.room.getPendingEvents()}getLiveTimeline(){return this.liveTimeline}eventIdToTimeline(e){return this._eventIdToTimeline[e]}replaceEventId(e,t){const r=this._eventIdToTimeline[e];r&&(delete this._eventIdToTimeline[e],this._eventIdToTimeline[t]=r)}resetLiveTimeline(e,t){const r=!this.timelineSupport||!t,i=this.liveTimeline,s=r?i.forkLive(dt.EventTimeline.FORWARDS):i.fork(dt.EventTimeline.FORWARDS);r?(this.timelines=[s],this._eventIdToTimeline={}):this.timelines.push(s),t&&i.setPaginationToken(t,dt.EventTimeline.FORWARDS),s.setPaginationToken(e,dt.EventTimeline.BACKWARDS),this.liveTimeline=s,this.emit(ju.RoomEvent.TimelineReset,this.room,this,r)}getTimelineForEvent(e){const t=this._eventIdToTimeline[e];return t===void 0?null:t}findEventById(e){const t=this.getTimelineForEvent(e);if(!!t)return t.getEvents().find(function(r){return r.getId()==e})}addTimeline(){if(!this.timelineSupport)throw new Error("timeline support is disabled. Set the 'timelineSupport' parameter to true when creating MatrixClient to enable it.");const e=new dt.EventTimeline(this);return this.timelines.push(e),e}addEventsToTimeline(e,t,r,i){if(!r)throw new Error("'timeline' not specified for EventTimelineSet.addEventsToTimeline");if(!t&&r==this.liveTimeline)throw new Error("EventTimelineSet.addEventsToTimeline cannot be used for adding events to the live timeline - use Room.addLiveEvents instead");if(this.filter&&(e=this.filter.filterRoomTimeline(e),!e.length))return;const s=t?dt.EventTimeline.BACKWARDS:dt.EventTimeline.FORWARDS,o=t?dt.EventTimeline.FORWARDS:dt.EventTimeline.BACKWARDS;let a=!1,l=!1;for(let u=0;u<e.length;u++){const c=e[u],g=c.getId(),m=this._eventIdToTimeline[g];if(!m){this.addEventToTimeline(c,r,t),l=!0,a=!0;continue}if(l=!1,m==r){oo("Event "+g+" already in timeline "+r);continue}const f=r.getNeighbouringTimeline(s);if(f){m==f?oo("Event "+g+" in neighbouring timeline - switching to "+m):oo("Event "+g+" already in a different timeline "+m),r=m;continue}is.logger.info("Already have timeline for "+g+" - joining timeline "+r+" to "+m);const E=m===this.liveTimeline,I=r===this.liveTimeline,w=s===dt.EventTimeline.BACKWARDS&&E,k=s===dt.EventTimeline.FORWARDS&&I;if(w||k){w&&is.logger.warn("Refusing to set a preceding existingTimeLine on our timeline as the existingTimeLine is live ("+m+")"),k&&is.logger.warn("Refusing to set our preceding timeline on a existingTimeLine as our timeline is live ("+r+")");continue}r.setNeighbouringTimeline(m,s),m.setNeighbouringTimeline(r,o),r=m,a=!0}if(l||!a){if(s===dt.EventTimeline.FORWARDS&&r===this.liveTimeline){is.logger.warn({lastEventWasNew:l,didUpdate:a}),is.logger.warn(`Refusing to set forwards pagination token of live timeline ${r} to ${i}`);return}r.setPaginationToken(i,s)}}addLiveEvent(e,t=qa.Ignore,r=!1,i){if(this.filter&&!this.filter.filterRoomTimeline([e]).length)return;const s=this._eventIdToTimeline[e.getId()];if(s){if(t===qa.Replace){oo("EventTimelineSet.addLiveEvent: replacing duplicate event "+e.getId());const o=s.getEvents();for(let a=0;a<o.length;a++)if(o[a].getId()===e.getId()){i||(i=s.getState(dt.EventTimeline.FORWARDS)),dt.EventTimeline.setEventMetadata(e,i,!1),o[a]=e;break}}else oo("EventTimelineSet.addLiveEvent: ignoring duplicate event "+e.getId());return}this.addEventToTimeline(e,this.liveTimeline,!1,r,i)}addEventToTimeline(e,t,r,i=!1,s){const o=e.getId();t.addEvent(e,r,s),this._eventIdToTimeline[o]=t,this.setRelationsTarget(e),this.aggregateRelations(e);const a={timeline:t,liveEvent:!r&&t==this.liveTimeline&&!i};this.emit(ju.RoomEvent.Timeline,e,this.room,Boolean(r),!1,a)}handleRemoteEcho(e,t,r){const i=this._eventIdToTimeline[t];i?(delete this._eventIdToTimeline[t],this._eventIdToTimeline[r]=i):this.filter?this.filter.filterRoomTimeline([e]).length&&this.addEventToTimeline(e,this.liveTimeline,!1):this.addEventToTimeline(e,this.liveTimeline,!1)}removeEvent(e){const t=this._eventIdToTimeline[e];if(!t)return null;const r=t.removeEvent(e);if(r){delete this._eventIdToTimeline[e];const i={timeline:t};this.emit(ju.RoomEvent.Timeline,r,this.room,void 0,!0,i)}return r}compareEventOrdering(e,t){if(e==t)return 0;const r=this._eventIdToTimeline[e],i=this._eventIdToTimeline[t];if(r===void 0||i===void 0)return null;if(r===i){let o,a;const l=r.getEvents();for(let u=0;u<l.length&&(o===void 0||a===void 0);u++){const c=l[u].getId();c==e&&(o=u),c==t&&(a=u)}return o-a}let s=r;for(;s;){if(s===i)return-1;s=s.getNeighbouringTimeline(dt.EventTimeline.FORWARDS)}for(s=r;s;){if(s===i)return 1;s=s.getNeighbouringTimeline(dt.EventTimeline.BACKWARDS)}return null}getRelationsForEvent(e,t,r){if(!this.unstableClientRelationAggregation)throw new Error("Client-side relation aggregation is disabled");if(!e||!t||!r)throw new Error("Invalid arguments for `getRelationsForEvent`");return((this.relations[e]||{})[t]||{})[r]}getAllRelationsEventForEvent(e){const t=this.relations[e]||{},r=[];for(const i of Object.values(t))for(const s of Object.values(i))r.push(...s.getRelations());return r}setRelationsTarget(e){if(!this.unstableClientRelationAggregation)return;const t=this.relations[e.getId()];if(!!t)for(const r of Object.values(t))for(const i of Object.values(r))i.setTargetEvent(e)}aggregateRelations(e){if(!this.unstableClientRelationAggregation||e.isRedacted()||e.status===og.EventStatus.CANCELLED)return;if(e.isBeingDecrypted()||e.shouldAttemptDecryption()){e.once(og.MatrixEventEvent.Decrypted,()=>{this.aggregateRelations(e)});return}const t=e.getRelation();if(!t)return;const r=t.event_id,i=t.rel_type,s=e.getType();let o=this.relations[r];o||(o=this.relations[r]={});let a=o[i];a||(a=o[i]={});let l=a[s],u;l||(l=a[s]=new KT.Relations(i,s,this.room),u=this.findEventById(r)||this.room.getPendingEvent(r),u&&l.setTargetEvent(u)),l.addEvent(e)}}ti.EventTimelineSet=qT;var sc={};Object.defineProperty(sc,"__esModule",{value:!0});sc.RoomSummary=void 0;class jT{constructor(e,t){this.roomId=e}}sc.RoomSummary=jT;var Ds={},Hl={};Object.defineProperty(Hl,"__esModule",{value:!0});Hl.FilterComponent=void 0;var ji=lt;function VT(n,e){if(e.endsWith("*")){const t=e.slice(0,-1);return n.substr(0,t.length)===t}else return n===e}class GT{constructor(e,t){this.filterJson=e,this.userId=t}check(e){var t,r;const i=((t=e.getUnsigned())===null||t===void 0?void 0:t["m.relations"])||{},s=Object.keys(i),o=[];return this.userId&&i!==null&&i!==void 0&&(r=i[ji.THREAD_RELATION_TYPE.name])!==null&&r!==void 0&&r.current_user_participated&&o.push(this.userId),this.checkFields(e.getRoomId(),e.getSender(),e.getType(),e.getContent()?e.getContent().url!==void 0:!1,s,o)}toJSON(){return{types:this.filterJson.types||null,not_types:this.filterJson.not_types||[],rooms:this.filterJson.rooms||null,not_rooms:this.filterJson.not_rooms||[],senders:this.filterJson.senders||null,not_senders:this.filterJson.not_senders||[],contains_url:this.filterJson.contains_url||null,[ji.FILTER_RELATED_BY_SENDERS.name]:this.filterJson[ji.FILTER_RELATED_BY_SENDERS.name]||[],[ji.FILTER_RELATED_BY_REL_TYPES.name]:this.filterJson[ji.FILTER_RELATED_BY_REL_TYPES.name]||[]}}checkFields(e,t,r,i,s,o){const a={rooms:function(g){return e===g},senders:function(g){return t===g},types:function(g){return VT(r,g)}};for(let g=0;g<Object.keys(a).length;g++){const m=Object.keys(a)[g],f=a[m],E="not_"+m,I=this.filterJson[E];if(I!=null&&I.some(f))return!1;const w=this.filterJson[m];if(w&&!w.some(f))return!1}const l=this.filterJson.contains_url;if(l!==void 0&&l!==i)return!1;const u=this.filterJson[ji.FILTER_RELATED_BY_REL_TYPES.name];if(u!==void 0&&!this.arrayMatchesFilter(u,s))return!1;const c=this.filterJson[ji.FILTER_RELATED_BY_SENDERS.name];return!(c!==void 0&&!this.arrayMatchesFilter(c,o))}arrayMatchesFilter(e,t){return t.length>0&&e.every(r=>t.includes(r))}filter(e){return e.filter(this.check,this)}limit(){return this.filterJson.limit!==void 0?this.filterJson.limit:10}}Hl.FilterComponent=GT;var WT=G.exports;Object.defineProperty(Ds,"__esModule",{value:!0});Ds.Filter=void 0;var rl=WT(Y.exports),ag=Hl;function Vu(n,e,t){const r=e.split(".");let i=n;for(let s=0;s<r.length-1;s++)i[r[s]]||(i[r[s]]={}),i=i[r[s]];i[r[r.length-1]]=t}class Yl{static fromJson(e,t,r){const i=new Yl(e,t);return i.setDefinition(r),i}constructor(e,t){this.userId=e,this.filterId=t,(0,rl.default)(this,"definition",{}),(0,rl.default)(this,"roomFilter",void 0),(0,rl.default)(this,"roomTimelineFilter",void 0)}getFilterId(){return this.filterId}getDefinition(){return this.definition}setDefinition(e){this.definition=e;const t=e.room,r={};t&&(t.rooms&&(r.rooms=t.rooms),t.rooms&&(r.not_rooms=t.not_rooms)),this.roomFilter=new ag.FilterComponent(r,this.userId),this.roomTimelineFilter=new ag.FilterComponent((t==null?void 0:t.timeline)||{},this.userId)}getRoomTimelineFilterComponent(){return this.roomTimelineFilter}filterRoomTimeline(e){return this.roomTimelineFilter.filter(this.roomFilter.filter(e))}setTimelineLimit(e){Vu(this.definition,"room.timeline.limit",e)}setLazyLoadMembers(e){Vu(this.definition,"room.state.lazy_load_members",!!e)}setIncludeLeaveRooms(e){Vu(this.definition,"room.include_leave",e)}}Ds.Filter=Yl;(0,rl.default)(Yl,"LAZY_LOADING_MESSAGES_FILTER",{lazy_load_members:!0});var me={},vf={};/*!
+ * content-type
+ * Copyright(c) 2015 Douglas Christopher Wilson
+ * MIT Licensed
+ */var cg=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,HT=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,Nv=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,YT=/\\([\u000b\u0020-\u00ff])/g,zT=/([\\"])/g,Lv=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;vf.format=JT;vf.parse=XT;function JT(n){if(!n||typeof n!="object")throw new TypeError("argument obj is required");var e=n.parameters,t=n.type;if(!t||!Lv.test(t))throw new TypeError("invalid type");var r=t;if(e&&typeof e=="object")for(var i,s=Object.keys(e).sort(),o=0;o<s.length;o++){if(i=s[o],!Nv.test(i))throw new TypeError("invalid parameter name");r+="; "+i+"="+ZT(e[i])}return r}function XT(n){if(!n)throw new TypeError("argument string is required");var e=typeof n=="object"?QT(n):n;if(typeof e!="string")throw new TypeError("argument string is required to be a string");var t=e.indexOf(";"),r=t!==-1?e.substr(0,t).trim():e.trim();if(!Lv.test(r))throw new TypeError("invalid media type");var i=new eO(r.toLowerCase());if(t!==-1){var s,o,a;for(cg.lastIndex=t;o=cg.exec(e);){if(o.index!==t)throw new TypeError("invalid parameter format");t+=o[0].length,s=o[1].toLowerCase(),a=o[2],a[0]==='"'&&(a=a.substr(1,a.length-2).replace(YT,"$1")),i.parameters[s]=a}if(t!==e.length)throw new TypeError("invalid parameter format")}return i}function QT(n){var e;if(typeof n.getHeader=="function"?e=n.getHeader("content-type"):typeof n.headers=="object"&&(e=n.headers&&n.headers["content-type"]),typeof e!="string")throw new TypeError("content-type header is missing from object");return e}function ZT(n){var e=String(n);if(Nv.test(e))return e;if(e.length>0&&!HT.test(e))throw new TypeError("invalid parameter value");return'"'+e.replace(zT,"\\$1")+'"'}function eO(n){this.parameters=Object.create(null),this.type=n}var oc={};Object.defineProperty(oc,"__esModule",{value:!0});oc.clearTimeout=aO;oc.setNow=sO;oc.setTimeout=oO;var tO=se;const rO=1e3;let nO=0,Gu;const Jn=[],iO=function(...n){};function sO(n){zl=n||Date.now}let zl=Date.now;function oO(n,e,...t){e=e||0,e<0&&(e=0);const r=zl()+e,i=nO++,s={runAt:r,func:n,params:t,key:i},o=lO(Jn,function(a){return a.runAt-r});return Jn.splice(o,0,s),_f(),i}function aO(n){if(Jn.length===0)return;let e;for(e=0;e<Jn.length;e++)if(Jn[e].key==n){Jn.splice(e,1);break}e===0&&_f()}function _f(){Gu&&V.clearTimeout(Gu);const n=Jn[0];if(!n)return;const e=zl(),t=Math.min(n.runAt-e,rO);Gu=V.setTimeout(cO,t)}function cO(){let n;const e=zl(),t=[];for(;;){const r=Jn[0];if(!r||r.runAt>e)break;n=Jn.shift(),iO("runCallbacks: popping",n.key),t.push(n)}_f();for(let r=0;r<t.length;r++){n=t[r];try{n.func.apply(V,n.params)}catch(i){tO.logger.error("Uncaught exception in callback function",i.stack||i)}}}function lO(n,e){let t=0,r=n.length;for(;t<r;){const i=t+r>>1;e(n[i])>0?r=i:t=i+1}return t}var uO=G.exports;Object.defineProperty(me,"__esModule",{value:!0});me.PREFIX_V1=me.PREFIX_UNSTABLE=me.PREFIX_R0=me.PREFIX_MEDIA_R0=me.PREFIX_IDENTITY_V2=me.PREFIX_IDENTITY_V1=me.Method=me.MatrixHttpApi=me.MatrixError=me.HttpApiEvent=me.ConnectionError=me.AbortError=void 0;me.retryNetworkOperation=SO;var Aa=uO(Y.exports),dO=vf,Vi=Kv(oc),_i=Kv(W),nl=se;function Bv(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(Bv=function(r){return r?t:e})(n)}function Kv(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=Bv(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}function lg(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function ug(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?lg(Object(t),!0).forEach(function(r){(0,Aa.default)(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):lg(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}const hO="/_matrix/client/r0";me.PREFIX_R0=hO;const fO="/_matrix/client/v1";me.PREFIX_V1=fO;const pO="/_matrix/client/unstable";me.PREFIX_UNSTABLE=pO;const gO="/_matrix/identity/api/v1";me.PREFIX_IDENTITY_V1=gO;const mO="/_matrix/identity/v2";me.PREFIX_IDENTITY_V2=mO;const yO="/_matrix/media/r0";me.PREFIX_MEDIA_R0=yO;let ja;me.Method=ja;(function(n){n.Get="GET",n.Put="PUT",n.Post="POST",n.Delete="DELETE"})(ja||(me.Method=ja={}));let Va;me.HttpApiEvent=Va;(function(n){n.SessionLoggedOut="Session.logged_out",n.NoConsent="no_consent"})(Va||(me.HttpApiEvent=Va={}));class vO{constructor(e,t){this.eventEmitter=e,this.opts=t,(0,Aa.default)(this,"uploads",[]),_i.checkObjectHasKeys(t,["baseUrl","request","prefix"]),t.onlyData=!!t.onlyData,t.useAuthorizationHeader=!!t.useAuthorizationHeader}setIdBaseUrl(e){this.opts.idBaseUrl=e}getContentUri(){return{base:this.opts.baseUrl,path:"/_matrix/media/r0/upload",params:{access_token:this.opts.accessToken}}}uploadContent(e,t){_i.isFunction(t)?t={callback:t}:t||(t={});const r=t.includeFilename!==!1,i=t.type||e.type||"application/octet-stream",s=t.name||e.name;let o=e;const a=o.stream;a&&typeof a!="function"&&(nl.logger.warn("Using `file.stream` as the content to upload. Future versions of the js-sdk will change this to expect `file` to be the content directly."),o=a);let l=t.rawResponse;l===void 0&&(V.XMLHttpRequest?l=!1:(nl.logger.warn("Returning the raw JSON from uploadContent(). Future versions of the js-sdk will change this default, to return the parsed object. Set opts.rawResponse=false to change this behaviour now."),l=!0));let u=t.onlyContentUri;!l&&u===void 0&&(V.XMLHttpRequest?(nl.logger.warn("Returning only the content-uri from uploadContent(). Future versions of the js-sdk will change this default, to return the whole response object. Set opts.onlyContentUri=false to change this behaviour now."),u=!0):u=!1);const c={loaded:0,total:0};let g,m=null;if(l||(m=function(f){let E=JSON.parse(f);if(u&&(E=E.content_uri,E===void 0))throw Error("Bad response");return E}),V.XMLHttpRequest){const f=_i.defer(),E=new V.XMLHttpRequest,I=Wu(f,t.callback,this.opts.onlyData),w=function(){E.abort(),I(new Error("Timeout"))};let k=Vi.setTimeout(w,3e4);E.onreadystatechange=function(){let T;switch(E.readyState){case V.XMLHttpRequest.DONE:Vi.clearTimeout(k);try{if(E.status===0)throw new Fv;if(!E.responseText)throw new Error("No response body.");T=E.responseText,m&&(T=m(T))}catch(D){D.http_status=E.status,I(D);return}I(void 0,E,T);break}},E.upload.addEventListener("progress",function(T){Vi.clearTimeout(k),c.loaded=T.loaded,c.total=T.total,k=Vi.setTimeout(w,3e4),t.progressHandler&&t.progressHandler({loaded:T.loaded,total:T.total})});let C=this.opts.baseUrl+"/_matrix/media/r0/upload";const S=[];r&&s&&S.push("filename="+encodeURIComponent(s)),this.opts.useAuthorizationHeader||S.push("access_token="+encodeURIComponent(this.opts.accessToken)),S.length>0&&(C+="?"+S.join("&")),E.open("POST",C),this.opts.useAuthorizationHeader&&E.setRequestHeader("Authorization","Bearer "+this.opts.accessToken),E.setRequestHeader("Content-Type",i),E.send(o),g=f.promise,g.abort=E.abort.bind(E)}else{const f={};r&&s&&(f.filename=s);const E={"Content-Type":i};o.length===0&&(E["Content-Length"]="0"),g=this.authedRequest(t.callback,ja.Post,"/upload",f,o,{prefix:"/_matrix/media/r0",headers:E,json:!1,bodyParser:m})}return c.promise=g.finally(()=>{for(let f=0;f<this.uploads.length;++f)if(this.uploads[f]===c){this.uploads.splice(f,1);return}}),c.promise.abort=g.abort,this.uploads.push(c),c.promise}cancelUpload(e){return e.abort?(e.abort(),!0):!1}getCurrentUploads(){return this.uploads}idServerRequest(e,t,r,i,s,o){if(!this.opts.idBaseUrl)throw new Error("No identity server base URL set");const a=this.opts.idBaseUrl+s+r;if(e!==void 0&&!_i.isFunction(e))throw Error("Expected callback to be a function but got "+typeof e);const l={uri:a,method:t,withCredentials:!1,json:!0,_matrix_opts:this.opts,headers:{}};t===ja.Get?l.qs=i:typeof i=="object"&&(l.json=i),o&&(l.headers.Authorization=`Bearer ${o}`);const u=_i.defer();return this.opts.request(l,Wu(u,e,this.opts.onlyData)),u.promise}authedRequest(e,t,r,i,s,o){i||(i={});let a=o||{};this.opts.useAuthorizationHeader?(isFinite(o)&&(a={localTimeoutMs:o}),a.headers||(a.headers={}),a.headers.Authorization||(a.headers.Authorization="Bearer "+this.opts.accessToken),i.access_token&&delete i.access_token):i.access_token||(i.access_token=this.opts.accessToken);const l=this.request(e,t,r,i,s,a);return l.catch(u=>{var c;u.errcode=="M_UNKNOWN_TOKEN"&&!((c=a)!==null&&c!==void 0&&c.inhibitLogoutEmit)?this.eventEmitter.emit(Va.SessionLoggedOut,u):u.errcode=="M_CONSENT_NOT_GIVEN"&&this.eventEmitter.emit(Va.NoConsent,u.message,u.data.consent_uri)}),l}request(e,t,r,i,s,o){var a;const l=(a=o==null?void 0:o.prefix)!==null&&a!==void 0?a:this.opts.prefix,u=this.opts.baseUrl+l+r;return this.requestOtherUrl(e,t,u,i,s,o)}requestOtherUrl(e,t,r,i,s,o){let a=o||{};return isFinite(o)&&(a={localTimeoutMs:o}),this.doRequest(e,t,r,i,s,a)}getUrl(e,t,r){let i="";return t&&(i="?"+_i.encodeParams(t)),this.opts.baseUrl+r+e+i}doRequest(e,t,r,i,s,o){var a;if(e!==void 0&&!_i.isFunction(e))throw Error("Expected callback to be a function but got "+typeof e);this.opts.extraParams&&(i=ug(ug({},i||{}),this.opts.extraParams));const l=Object.assign({},o.headers||{});o||(o={});const u=(a=o.json)!==null&&a!==void 0?a:!0;let c=o.bodyParser;u&&(s&&(s=JSON.stringify(s),l["content-type"]="application/json"),l.accept||(l.accept="application/json"),c===void 0&&(c=function(C){return JSON.parse(C)}));const g=_i.defer();let m,f=!1,E;const I=o.localTimeoutMs||this.opts.localTimeoutMs,w=()=>{I&&(m&&Vi.clearTimeout(m),m=Vi.setTimeout(function(){var C,S;f=!0,(C=E)===null||C===void 0||(S=C.abort)===null||S===void 0||S.call(C),g.reject(new Jl({error:"Locally timed out waiting for a response",errcode:"ORG.MATRIX.JSSDK_TIMEOUT",timeout:I}))},I))};w();const k=g.promise;try{E=this.opts.request({uri:r,method:t,withCredentials:!1,qs:i,qsStringifyOptions:o.qsStringifyOptions,useQuerystring:!0,body:s,json:!1,timeout:I,headers:l||{},_matrix_opts:this.opts},(C,S,T)=>{if(I&&(Vi.clearTimeout(m),f))return;Wu(g,e,this.opts.onlyData,c)(C,S,T)}),E&&("onprogress"in E&&(E.onprogress=C=>{w()}),E.abort&&(k.abort=E.abort.bind(E)))}catch(C){g.reject(C),e&&e(C)}return k}}me.MatrixHttpApi=vO;function Eh(n){return n.status||n.statusCode}function Wu(n,e,t=!1,r){return function(i,s,o){i&&!(i.name==="AbortError"||i==="aborted")&&!(i instanceof Jl)&&(i=new Ef("request failed",i));let a=o;if(!i)try{Eh(s)>=400?i=_O(s,o):r&&(a=r(o))}catch(l){i=new Error(`Error parsing server response: ${l}`)}if(i)n.reject(i),e==null||e(i);else if(t)n.resolve(a),e==null||e(null,a);else{const l={code:Eh(s),headers:s.headers,data:a};n.resolve(l),e==null||e(null,l)}}}function _O(n,e){const t=Eh(n),r=EO(n);let i;if(r)if(r.type==="application/json"){const s=typeof e=="object"?e:JSON.parse(e);i=new Jl(s)}else r.type==="text/plain"&&(i=new Error(`Server returned ${t} error: ${e}`));return i||(i=new Error(`Server returned ${t} error`)),i.httpStatus=t,i}function EO(n){let e;if(n.getResponseHeader?e=n.getResponseHeader("Content-Type"):n.headers&&(e=n.headers["content-type"]||null),!e)return null;try{return(0,dO.parse)(e)}catch(t){throw new Error(`Error parsing Content-Type '${e}': ${t}`)}}class Jl extends Error{constructor(e={}){super(`MatrixError: ${e.errcode}`);(0,Aa.default)(this,"errcode",void 0),(0,Aa.default)(this,"data",void 0),(0,Aa.default)(this,"httpStatus",void 0),this.errcode=e.errcode,this.name=e.errcode||"Unknown error code",this.message=e.error||"Unknown message",this.data=e}}me.MatrixError=Jl;class Ef extends Error{constructor(e,t=void 0){super(e+(t?`: ${t.message}`:""))}get name(){return"ConnectionError"}}me.ConnectionError=Ef;class Fv extends Error{constructor(){super("Operation aborted")}get name(){return"AbortError"}}me.AbortError=Fv;async function SO(n,e){let t=0,r=null;for(;t<n;)try{if(t>0){const i=1e3*Math.pow(2,t);nl.logger.log(`network operation failed ${t} times, retrying in ${i}ms...`),await new Promise(s=>setTimeout(s,i))}return await e()}catch(i){if(i instanceof Ef)t+=1,r=i;else throw i}throw r}var bO=G.exports;Object.defineProperty(lr,"__esModule",{value:!0});lr.RoomEvent=lr.Room=lr.NotificationCountType=void 0;var Oe=bO(Y.exports),Hu=ti,Jt=qt,wO=$o,ea=PO(W),il=jt,De=qo,RO=Zr,IO=sc,ht=se,TO=tn,Ne=ie,Ei=st,OO=Ds,Ir=lt,kO=me,CO=je;function qv(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(qv=function(r){return r?t:e})(n)}function PO(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=qv(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}function dg(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function hg(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?dg(Object(t),!0).forEach(function(r){(0,Oe.default)(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):dg(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}const fg="6",pg=["1","2","3","4","5","6"];function gg(n,e,t){return new il.MatrixEvent({content:{[e.getId()]:{[t]:{[n]:{ts:e.getTs()}}}},type:"m.receipt",room_id:e.getRoomId()})}const Ks=0,Fs=1,MO=30;let Tl;lr.NotificationCountType=Tl;(function(n){n.Highlight="highlight",n.Total="total"})(Tl||(lr.NotificationCountType=Tl={}));let it;lr.RoomEvent=it;(function(n){n.MyMembership="Room.myMembership",n.Tags="Room.tags",n.AccountData="Room.accountData",n.Receipt="Room.receipt",n.Name="Room.name",n.Redaction="Room.redaction",n.RedactionCancelled="Room.redactionCancelled",n.LocalEchoUpdated="Room.localEchoUpdated",n.Timeline="Room.timeline",n.TimelineReset="Room.timelineReset"})(it||(lr.RoomEvent=it={}));class AO extends CO.TypedEventEmitter{constructor(e,t,r,i={}){super();if(this.roomId=e,this.client=t,this.myUserId=r,this.opts=i,(0,Oe.default)(this,"reEmitter",void 0),(0,Oe.default)(this,"txnToEvent",{}),(0,Oe.default)(this,"receipts",{}),(0,Oe.default)(this,"receiptCacheByEventId",{}),(0,Oe.default)(this,"notificationCounts",{}),(0,Oe.default)(this,"timelineSets",void 0),(0,Oe.default)(this,"threadsTimelineSets",[]),(0,Oe.default)(this,"filteredTimelineSets",{}),(0,Oe.default)(this,"pendingEventList",void 0),(0,Oe.default)(this,"blacklistUnverifiedDevices",null),(0,Oe.default)(this,"selfMembership",null),(0,Oe.default)(this,"summaryHeroes",null),(0,Oe.default)(this,"getTypeWarning",!1),(0,Oe.default)(this,"getVersionWarning",!1),(0,Oe.default)(this,"membersPromise",void 0),(0,Oe.default)(this,"name",void 0),(0,Oe.default)(this,"normalizedName",void 0),(0,Oe.default)(this,"tags",{}),(0,Oe.default)(this,"accountData",{}),(0,Oe.default)(this,"summary",null),(0,Oe.default)(this,"storageToken",void 0),(0,Oe.default)(this,"timeline",void 0),(0,Oe.default)(this,"oldState",void 0),(0,Oe.default)(this,"currentState",void 0),(0,Oe.default)(this,"threads",new Map),(0,Oe.default)(this,"lastThread",void 0),(0,Oe.default)(this,"visibilityEvents",new Map),(0,Oe.default)(this,"threadTimelineSetsPromise",null),this.setMaxListeners(100),this.reEmitter=new TO.TypedReEmitter(this),i.pendingEventOrdering=i.pendingEventOrdering||Ei.PendingEventOrdering.Chronological,this.name=e,this.timelineSets=[new Hu.EventTimelineSet(this,i)],this.reEmitter.reEmit(this.getUnfilteredTimelineSet(),[it.Timeline,it.TimelineReset]),this.fixUpLegacyTimelineFields(),this.opts.pendingEventOrdering===Ei.PendingEventOrdering.Detached){this.pendingEventList=[];const s=t.sessionStore.store.getItem(Yu(this.roomId));s&&JSON.parse(s).forEach(async o=>{const a=new il.MatrixEvent(o);a.getType()===Ne.EventType.RoomMessageEncrypted&&await a.attemptDecryption(this.client.crypto),a.setStatus(De.EventStatus.NOT_SENT),this.addPendingEvent(a,a.getTxnId())})}this.opts.lazyLoadMembers?this.membersPromise=null:this.membersPromise=Promise.resolve(!1)}async createThreadsTimelineSets(){var e;if(this.threadTimelineSetsPromise)return this.threadTimelineSetsPromise;if((e=this.client)!==null&&e!==void 0&&e.supportsExperimentalThreads)try{this.threadTimelineSetsPromise=Promise.all([this.createThreadTimelineSet(),this.createThreadTimelineSet(Ir.ThreadFilterType.My)]);const t=await this.threadTimelineSetsPromise;this.threadsTimelineSets.push(...t)}catch{this.threadTimelineSetsPromise=null}}decryptCriticalEvents(){const e=this.getEventReadUpTo(this.client.getUserId(),!0),t=this.getLiveTimeline().getEvents(),r=t.findIndex(s=>s.event.event_id===e),i=t.slice(r).filter(s=>s.shouldAttemptDecryption()).reverse().map(s=>s.attemptDecryption(this.client.crypto,{isRetry:!0}));return Promise.allSettled(i)}decryptAllEvents(){const e=this.getUnfilteredTimelineSet().getLiveTimeline().getEvents().filter(t=>t.shouldAttemptDecryption()).reverse().map(t=>t.attemptDecryption(this.client.crypto,{isRetry:!0}));return Promise.allSettled(e)}getVersion(){const e=this.currentState.getStateEvents(Ne.EventType.RoomCreate,"");if(!e)return this.getVersionWarning||(ht.logger.warn("[getVersion] Room "+this.roomId+" does not have an m.room.create event"),this.getVersionWarning=!0),"1";const t=e.getContent().room_version;return t===void 0?"1":t}shouldUpgradeToVersion(){return pg.includes(this.getVersion())?null:fg}async getRecommendedVersion(){let t=(await this.client.getCapabilities())["m.room_versions"];if(!t){t={default:fg,available:{}};for(const i of pg)t.available[i]=Ei.RoomVersionStability.Stable}let r=this.checkVersionAgainstCapability(t);if(r.urgent&&r.needsUpgrade)if(ht.logger.warn("Refreshing room version capability because the server looks to be supporting a newer room version we don't know about."),t=(await this.client.getCapabilities(!0))["m.room_versions"],t)r=this.checkVersionAgainstCapability(t);else return ht.logger.warn("No room version capability - assuming upgrade required."),r;return r}checkVersionAgainstCapability(e){const t=this.getVersion();ht.logger.log(`[${this.roomId}] Current version: ${t}`),ht.logger.log(`[${this.roomId}] Version capability: `,e);const r={version:t,needsUpgrade:!1,urgent:!1};return t===e.default||Object.keys(e.available).filter(s=>e.available[s]==="stable").includes(t)||(r.version=e.default,r.needsUpgrade=!0,r.urgent=!!this.getVersion().match(/^[0-9]+[0-9.]*$/g),r.urgent?ht.logger.warn(`URGENT upgrade required on ${this.roomId}`):ht.logger.warn(`Non-urgent upgrade required on ${this.roomId}`)),r}userMayUpgradeRoom(e){return this.currentState.maySendStateEvent(Ne.EventType.RoomTombstone,e)}getPendingEvents(){if(this.opts.pendingEventOrdering!==Ei.PendingEventOrdering.Detached)throw new Error("Cannot call getPendingEvents with pendingEventOrdering == "+this.opts.pendingEventOrdering);return this.pendingEventList}removePendingEvent(e){if(this.opts.pendingEventOrdering!==Ei.PendingEventOrdering.Detached)throw new Error("Cannot call removePendingEvent with pendingEventOrdering == "+this.opts.pendingEventOrdering);const t=ea.removeElement(this.pendingEventList,function(r){return r.getId()==e},!1);return this.savePendingEvents(),t}hasPendingEvent(e){return this.opts.pendingEventOrdering!==Ei.PendingEventOrdering.Detached?!1:this.pendingEventList.some(t=>t.getId()===e)}getPendingEvent(e){return this.opts.pendingEventOrdering!==Ei.PendingEventOrdering.Detached?null:this.pendingEventList.find(t=>t.getId()===e)}getLiveTimeline(){return this.getUnfilteredTimelineSet().getLiveTimeline()}getLastActiveTimestamp(){const t=this.getLiveTimeline().getEvents();return t.length?t[t.length-1].getTs():Number.MIN_SAFE_INTEGER}getMyMembership(){return this.selfMembership}getDMInviter(){if(this.myUserId){const e=this.getMember(this.myUserId);if(e)return e.getDMInviter()}if(this.selfMembership==="invite"&&this.getInvitedAndJoinedMemberCount()==2&&this.summaryHeroes.length)return this.summaryHeroes[0]}guessDMUserId(){const e=this.getMember(this.myUserId);if(e){const s=e.getDMInviter();if(s)return s}if(Array.isArray(this.summaryHeroes)&&this.summaryHeroes.length)return this.summaryHeroes[0];const i=this.currentState.getMembers().find(s=>s.userId!==this.myUserId);return i?i.userId:this.myUserId}getAvatarFallbackMember(){if(this.getInvitedAndJoinedMemberCount()>2)return;const t=Array.isArray(this.summaryHeroes)&&this.summaryHeroes.length;if(t){const i=this.summaryHeroes.map(s=>this.getMember(s)).find(s=>!!s);if(i)return i}const r=this.currentState.getMembers();if(r.length<=2){const i=r.find(s=>s.userId!==this.myUserId);if(i)return i}if(t){const i=this.summaryHeroes.map(s=>this.client.getUser(s)).find(s=>!!s);if(i){const s=new RO.RoomMember(this.roomId,i.userId);return s.user=i,s}}}updateMyMembership(e){const t=this.selfMembership;this.selfMembership=e,t!==e&&(e==="leave"&&this.cleanupAfterLeaving(),this.emit(it.MyMembership,this,e,t))}async loadMembersFromServer(){const e=this.client.store.getSyncToken(),t=ea.encodeParams({not_membership:"leave",at:e}),r=ea.encodeUri("/rooms/$roomId/members?"+t,{$roomId:this.roomId});return(await this.client.http.authedRequest(void 0,kO.Method.Get,r)).chunk}async loadMembers(){let e=!1,t=await this.client.store.getOutOfBandMembers(this.roomId);return(t===null||this.client.isCryptoEnabled()&&this.client.isRoomEncrypted(this.roomId))&&(e=!0,t=await this.loadMembersFromServer(),ht.logger.log(`LL: got ${t.length} members from server for room ${this.roomId}`)),{memberEvents:t.map(this.client.getEventMapper()),fromServer:e}}loadMembersIfNeeded(){if(this.membersPromise)return this.membersPromise;this.currentState.markOutOfBandMembersStarted();const e=this.loadMembers().then(t=>(this.currentState.setOutOfBandMembers(t.memberEvents),this.client.isCryptoEnabled()&&this.client.isRoomEncrypted(this.roomId)&&this.client.crypto.trackRoomDevices(this.roomId),t.fromServer)).catch(t=>{throw this.membersPromise=null,this.currentState.markOutOfBandMembersFailed(),t});return e.then(t=>{if(t){const r=this.currentState.getMembers().filter(s=>s.isOutOfBand()).map(s=>s.events.member.event);return ht.logger.log(`LL: telling store to write ${r.length} members for room ${this.roomId}`),this.client.store.setOutOfBandMembers(this.roomId,r).catch(s=>{ht.logger.log("LL: storing OOB room members failed, oh well",s)})}}).catch(t=>{ht.logger.error(t)}),this.membersPromise=e,this.membersPromise}async clearLoadedMembersIfNeeded(){this.opts.lazyLoadMembers&&this.membersPromise&&(await this.loadMembersIfNeeded(),await this.client.store.clearOutOfBandMembers(this.roomId),this.currentState.clearOutOfBandMembers(),this.membersPromise=null)}cleanupAfterLeaving(){this.clearLoadedMembersIfNeeded().catch(e=>{ht.logger.error(`error after clearing loaded members from room ${this.roomId} after leaving`),ht.logger.log(e)})}resetLiveTimeline(e,t){for(let r=0;r<this.timelineSets.length;r++)this.timelineSets[r].resetLiveTimeline(e,t);this.fixUpLegacyTimelineFields()}fixUpLegacyTimelineFields(){this.timeline=this.getLiveTimeline().getEvents(),this.oldState=this.getLiveTimeline().getState(Jt.EventTimeline.BACKWARDS),this.currentState=this.getLiveTimeline().getState(Jt.EventTimeline.FORWARDS)}async hasUnverifiedDevices(){if(!this.client.isRoomEncrypted(this.roomId))return!1;const e=await this.getEncryptionTargetMembers();for(const t of e)if(this.client.getStoredDevicesForUser(t.userId).some(i=>i.isUnverified()))return!0;return!1}getTimelineSets(){return this.timelineSets}getUnfilteredTimelineSet(){return this.timelineSets[0]}getTimelineForEvent(e){const t=this.findEventById(e),r=this.findThreadForEvent(t);return r?r.timelineSet.getLiveTimeline():this.getUnfilteredTimelineSet().getTimelineForEvent(e)}addTimeline(){return this.getUnfilteredTimelineSet().addTimeline()}findEventById(e){let t=this.getUnfilteredTimelineSet().findEventById(e);if(t)return t;{const r=this.getThreads();for(let i=0;i<r.length;i++)if(t=r[i].findEventById(e),t)return t}}getUnreadNotificationCount(e=Tl.Total){return this.notificationCounts[e]}setUnreadNotificationCount(e,t){this.notificationCounts[e]=t}setSummary(e){const t=e["m.heroes"],r=e["m.joined_member_count"],i=e["m.invited_member_count"];Number.isInteger(r)&&this.currentState.setJoinedMemberCount(r),Number.isInteger(i)&&this.currentState.setInvitedMemberCount(i),Array.isArray(t)&&(this.summaryHeroes=t.filter(s=>s!==this.myUserId))}setBlacklistUnverifiedDevices(e){this.blacklistUnverifiedDevices=e}getBlacklistUnverifiedDevices(){return this.blacklistUnverifiedDevices}getAvatarUrl(e,t,r,i,s=!0){const o=this.currentState.getStateEvents(Ne.EventType.RoomAvatar,"");if(!o&&!s)return null;const a=o?o.getContent().url:null;return a?(0,wO.getHttpUriForMxc)(e,a,t,r,i):null}getMxcAvatarUrl(){var e,t;return((e=this.currentState.getStateEvents(Ne.EventType.RoomAvatar,""))===null||e===void 0||(t=e.getContent())===null||t===void 0?void 0:t.url)||null}getAliases(){const e=[],t=this.currentState.getStateEvents(Ne.EventType.RoomAliases);if(t)for(let r=0;r<t.length;++r){const i=t[r];if(Array.isArray(i.getContent().aliases)){const s=i.getContent().aliases.filter(o=>!(typeof o!="string"||o[0]!=="#"||!o.endsWith(`:${i.getStateKey()}`)));Array.prototype.push.apply(e,s)}}return e}getCanonicalAlias(){const e=this.currentState.getStateEvents(Ne.EventType.RoomCanonicalAlias,"");return e&&e.getContent().alias||null}getAltAliases(){const e=this.currentState.getStateEvents(Ne.EventType.RoomCanonicalAlias,"");return e?e.getContent().alt_aliases||[]:[]}addEventsToTimeline(e,t,r,i){r.getTimelineSet().addEventsToTimeline(e,t,r,i)}getThread(e){return this.getThreads().find(t=>t.id===e)}getThreads(){return Array.from(this.threads.values())}getMember(e){return this.currentState.getMember(e)}getMembers(){return this.currentState.getMembers()}getJoinedMembers(){return this.getMembersWithMembership("join")}getJoinedMemberCount(){return this.currentState.getJoinedMemberCount()}getInvitedMemberCount(){return this.currentState.getInvitedMemberCount()}getInvitedAndJoinedMemberCount(){return this.getInvitedMemberCount()+this.getJoinedMemberCount()}getMembersWithMembership(e){return this.currentState.getMembers().filter(function(t){return t.membership===e})}async getEncryptionTargetMembers(){await this.loadMembersIfNeeded();let e=this.getMembersWithMembership("join");return this.shouldEncryptForInvitedMembers()&&(e=e.concat(this.getMembersWithMembership("invite"))),e}shouldEncryptForInvitedMembers(){var e;const t=this.currentState.getStateEvents(Ne.EventType.RoomHistoryVisibility,"");return(t==null||(e=t.getContent())===null||e===void 0?void 0:e.history_visibility)!=="joined"}getDefaultRoomName(e){return this.calculateRoomName(e,!0)}hasMembershipState(e,t){const r=this.getMember(e);return r?r.membership===t:!1}getOrCreateFilteredTimelineSet(e,{prepopulateTimeline:t=!0,pendingEvents:r=!0}={}){if(this.filteredTimelineSets[e.filterId])return this.filteredTimelineSets[e.filterId];const i=Object.assign({filter:e,pendingEvents:r},this.opts),s=new Hu.EventTimelineSet(this,i);this.reEmitter.reEmit(s,[it.Timeline,it.TimelineReset]),this.filteredTimelineSets[e.filterId]=s,this.timelineSets.push(s);const o=this.getLiveTimeline();if(t){o.getEvents().forEach(function(l){s.addLiveEvent(l)});let a=o;for(;a.getNeighbouringTimeline(Jt.EventTimeline.BACKWARDS);)a=a.getNeighbouringTimeline(Jt.EventTimeline.BACKWARDS);s.getLiveTimeline().setPaginationToken(a.getPaginationToken(Jt.EventTimeline.BACKWARDS),Jt.EventTimeline.BACKWARDS)}else{const a=o.getPaginationToken(Jt.Direction.Forward);s.getLiveTimeline().setPaginationToken(a,Jt.Direction.Backward)}return s}async createThreadTimelineSet(e){let t;if(Ir.Thread.hasServerSideSupport){const r=this.client.getUserId(),i=new OO.Filter(r),s={room:{timeline:{[Ir.FILTER_RELATED_BY_REL_TYPES.name]:[Ir.THREAD_RELATION_TYPE.name]}}};e===Ir.ThreadFilterType.My&&(s.room.timeline[Ir.FILTER_RELATED_BY_SENDERS.name]=[r]),i.setDefinition(s);const o=await this.client.getOrCreateFilter(`THREAD_PANEL_${this.roomId}_${e}`,i);i.filterId=o,t=this.getOrCreateFilteredTimelineSet(i,{prepopulateTimeline:!1,pendingEvents:!1}),t.getLiveTimeline().setPaginationToken("",Jt.EventTimeline.BACKWARDS)}else t=new Hu.EventTimelineSet(this,{pendingEvents:!1}),Array.from(this.threads).forEach(([,r])=>{if(r.length===0)return;const i=r.events.some(s=>s.getSender()===this.client.getUserId());(e!==Ir.ThreadFilterType.My||i)&&t.getLiveTimeline().addEvent(r.rootEvent,!1)});return t}removeFilteredTimelineSet(e){const t=this.filteredTimelineSets[e.filterId];delete this.filteredTimelineSets[e.filterId];const r=this.timelineSets.indexOf(t);r>-1&&this.timelineSets.splice(r,1)}findThreadForEvent(e){if(!e)return null;if(e.isThreadRelation)return this.threads.get(e.threadRootId);if(e.isThreadRoot)return this.threads.get(e.getId());{const t=this.findEventById(e.getAssociatedId());return this.findThreadForEvent(t)}}async addThreadedEvent(e,t){this.applyRedaction(e);let r=this.findThreadForEvent(e);if(r)r.addEvent(e,t);else{const i=[e];let s=this.findEventById(e.threadRootId);try{let o;e.threadRootId&&(o=await this.client.fetchRoomEvent(this.roomId,e.threadRootId)),s?s.setUnsigned(o.unsigned):s=new il.MatrixEvent(o)}finally{r=this.createThread(s,i,t)}}this.emit(Ir.ThreadEvent.Update,r)}createThread(e,t=[],r){if(e){const o=this.getTimelineForEvent(e.getId()),a=o==null?void 0:o.getTimelineSet().getAllRelationsEventForEvent(e.getId());a&&(t=t.concat(a))}const i=new Ir.Thread(e,{initialEvents:t,room:this,client:this.client});if(i.id){var s;return this.threads.set(i.id,i),this.reEmitter.reEmit(i,[Ir.ThreadEvent.Update,it.Timeline,it.TimelineReset]),(!this.lastThread||((s=this.lastThread.rootEvent)===null||s===void 0?void 0:s.localTimestamp)<(e==null?void 0:e.localTimestamp))&&(this.lastThread=i),this.emit(Ir.ThreadEvent.New,i,r),this.threadsTimelineSets.forEach(o=>{i.rootEvent&&(Ir.Thread.hasServerSideSupport?o.addLiveEvent(i.rootEvent):o.addEventToTimeline(i.rootEvent,o.getLiveTimeline(),r))}),i}}applyRedaction(e){if(e.isRedaction()){const t=e.event.redacts,r=this.findEventById(t);r&&(r.makeRedacted(e),r.getStateKey()&&this.currentState.getStateEvents(r.getType(),r.getStateKey()).getId()===r.getId()&&this.currentState.setStateEvents([r]),this.emit(it.Redaction,e,this),this.visibilityEvents.delete(t),r.isVisibilityEvent()&&this.redactVisibilityChangeEvent(e))}}addLiveEvent(e,t,r=!1){if(this.applyRedaction(e),e.isVisibilityEvent()&&this.applyNewVisibilityEvent(e),this.applyPendingVisibilityEvents(e),e.getUnsigned().transaction_id){const i=this.txnToEvent[e.getUnsigned().transaction_id];if(i){this.handleRemoteEcho(e,i);return}}for(let i=0;i<this.timelineSets.length;i++)this.timelineSets[i].addLiveEvent(e,t,r);e.sender&&e.getType()!==Ne.EventType.RoomRedaction&&this.addReceipt(gg(e.sender.userId,e,"m.read"),!0)}addPendingEvent(e,t){if(e.status!==De.EventStatus.SENDING&&e.status!==De.EventStatus.NOT_SENT)throw new Error("addPendingEvent called on an event with status "+e.status);if(this.txnToEvent[t])throw new Error("addPendingEvent called on an event with known txnId "+t);if(Jt.EventTimeline.setEventMetadata(e,this.getLiveTimeline().getState(Jt.EventTimeline.FORWARDS),!1),this.txnToEvent[t]=e,this.opts.pendingEventOrdering===Ei.PendingEventOrdering.Detached){if(this.pendingEventList.some(i=>i.status===De.EventStatus.NOT_SENT)&&(ht.logger.warn("Setting event as NOT_SENT due to messages in the same state"),e.setStatus(De.EventStatus.NOT_SENT)),this.pendingEventList.push(e),this.savePendingEvents(),e.isRelation()&&this.aggregateNonLiveRelation(e),e.isRedaction()){var r;const i=e.event.redacts;let s=(r=this.pendingEventList)===null||r===void 0?void 0:r.find(o=>o.getId()===i);s||(s=this.findEventById(i)),s&&(s.markLocallyRedacted(e),this.emit(it.Redaction,e,this))}}else for(let i=0;i<this.timelineSets.length;i++){const s=this.timelineSets[i];s.getFilter()?s.getFilter().filterRoomTimeline([e]).length&&s.addEventToTimeline(e,s.getLiveTimeline(),!1):s.addEventToTimeline(e,s.getLiveTimeline(),!1)}this.emit(it.LocalEchoUpdated,e,this,null,null)}savePendingEvents(){if(this.pendingEventList){const e=this.pendingEventList.map(r=>hg(hg({},r.event),{},{txn_id:r.getTxnId()})).filter(r=>{const i=r.type===Ne.EventType.RoomMessageEncrypted,s=this.client.isRoomEncrypted(this.roomId);return i||!s}),{store:t}=this.client.sessionStore;this.pendingEventList.length>0?t.setItem(Yu(this.roomId),JSON.stringify(e)):t.removeItem(Yu(this.roomId))}}aggregateNonLiveRelation(e){const t=this.findThreadForEvent(e);if(t&&t.timelineSet.aggregateRelations(e),(t==null?void 0:t.id)===e.getAssociatedId()||!t)for(let r=0;r<this.timelineSets.length;r++){const i=this.timelineSets[r];i.getFilter()?i.getFilter().filterRoomTimeline([e]).length&&i.aggregateRelations(e):i.aggregateRelations(e)}}getEventForTxnId(e){return this.txnToEvent[e]}handleRemoteEcho(e,t){const r=t.getId(),i=e.getId(),s=t.status;ht.logger.debug(`Got remote echo for event ${r} -> ${i} old status ${s}`),delete this.txnToEvent[e.getUnsigned().transaction_id],this.pendingEventList&&this.removePendingEvent(r),t.handleRemoteEcho(e.event);const o=this.findThreadForEvent(e);if(o&&o.timelineSet.handleRemoteEcho(t,r,i),(o==null?void 0:o.id)===e.getAssociatedId()||!o)for(let a=0;a<this.timelineSets.length;a++)this.timelineSets[a].handleRemoteEcho(t,r,i);this.emit(it.LocalEchoUpdated,t,this,r,s)}updatePendingEvent(e,t,r){if(ht.logger.log(`setting pendingEvent status to ${t} in ${e.getRoomId()} event ID ${e.getId()} -> ${r}`),t==De.EventStatus.SENT&&!r)throw new Error("updatePendingEvent called with status=SENT, but no new event id");if(t==De.EventStatus.SENT&&this.getTimelineForEvent(r))return;const i=e.status,s=e.getId();if(!i)throw new Error("updatePendingEventStatus called on an event which is not a local echo.");const o=DO[i];if(!o||o.indexOf(t)<0)throw new Error("Invalid EventStatus transition "+i+"->"+t);if(e.setStatus(t),t==De.EventStatus.SENT){e.replaceLocalEventId(r);const a=this.findThreadForEvent(e);if(a&&a.timelineSet.replaceEventId(s,r),(a==null?void 0:a.id)===e.getAssociatedId()||!a)for(let l=0;l<this.timelineSets.length;l++)this.timelineSets[l].replaceEventId(s,r)}else if(t==De.EventStatus.CANCELLED){if(this.pendingEventList){const a=this.pendingEventList.findIndex(l=>l.getId()===s);if(a!==-1){const[l]=this.pendingEventList.splice(a,1);l.isRedaction()&&this.revertRedactionLocalEcho(l)}}this.removeEvent(s)}this.savePendingEvents(),this.emit(it.LocalEchoUpdated,e,this,s,i)}revertRedactionLocalEcho(e){const t=e.event.redacts;if(!t)return;const r=this.getUnfilteredTimelineSet().findEventById(t);r&&(r.unmarkLocallyRedacted(),this.emit(it.RedactionCancelled,e,this),r.isRelation()&&this.aggregateNonLiveRelation(r))}addLiveEvents(e,t,r=!1){let i;if(t&&["replace","ignore"].indexOf(t)===-1)throw new Error("duplicateStrategy MUST be either 'replace' or 'ignore'");for(i=0;i<this.timelineSets.length;i++){const s=this.timelineSets[i].getLiveTimeline();if(s.getPaginationToken(Jt.EventTimeline.FORWARDS))throw new Error("live timeline "+i+" is no longer live - it has a pagination token ("+s.getPaginationToken(Jt.EventTimeline.FORWARDS)+")");if(s.getNeighbouringTimeline(Jt.EventTimeline.FORWARDS))throw new Error("live timeline "+i+" is no longer live - it has a neighbouring timeline")}for(i=0;i<e.length;i++){this.addLiveEvent(e[i],t,r);const s=this.findThreadForEvent(e[i]);s&&s.addEvent(e[i],!0)}}addEphemeralEvents(e){for(const t of e)t.getType()==="m.typing"?this.currentState.setTypingEvent(t):t.getType()==="m.receipt"&&this.addReceipt(t)}removeEvents(e){for(let t=0;t<e.length;++t)this.removeEvent(e[t])}removeEvent(e){let t=!1;for(let r=0;r<this.timelineSets.length;r++){const i=this.timelineSets[r].removeEvent(e);i&&(i.isRedaction()&&this.revertRedactionLocalEcho(i),t=!0)}return t}recalculate(){const e=this.currentState.getStateEvents(Ne.EventType.RoomMember,this.myUserId);e&&e.getContent().membership==="invite"&&(e.getUnsigned().invite_room_state||[]).forEach(i=>{this.currentState.getStateEvents(i.type,i.state_key)||this.currentState.setStateEvents([new il.MatrixEvent({type:i.type,state_key:i.state_key,content:i.content,event_id:"$fake"+Date.now(),room_id:this.roomId,user_id:this.myUserId})])});const t=this.name;this.name=this.calculateRoomName(this.myUserId),this.normalizedName=(0,ea.normalize)(this.name),this.summary=new IO.RoomSummary(this.roomId,{title:this.name}),t!==this.name&&this.emit(it.Name,this)}getUsersReadUpTo(e){return this.getReceiptsForEvent(e).filter(function(t){return t.type==="m.read"}).map(function(t){return t.userId})}getReadReceiptForUserId(e,t=!1){var r,i;const[s,o]=(r=(i=this.receipts["m.read"])===null||i===void 0?void 0:i[e])!==null&&r!==void 0?r:[];return t?s:o!=null?o:s}getEventReadUpTo(e,t=!1){var r;const i=this.getReadReceiptForUserId(e,t);return(r=i==null?void 0:i.eventId)!==null&&r!==void 0?r:null}hasUserReadEvent(e,t){const r=this.getEventReadUpTo(e,!1);if(r===t||this.timeline.length&&this.timeline[this.timeline.length-1].getSender()&&this.timeline[this.timeline.length-1].getSender()===e)return!0;for(let i=this.timeline.length-1;i>=0;--i){const s=this.timeline[i];if(s.getId()===t)return!1;if(s.getId()===r)return!0}return!1}getReceiptsForEvent(e){return this.receiptCacheByEventId[e.getId()]||[]}addReceipt(e,t=!1){this.addReceiptsToStructure(e,t),this.emit(it.Receipt,e,this)}addReceiptsToStructure(e,t){const r=e.getContent();Object.keys(r).forEach(i=>{Object.keys(r[i]).forEach(s=>{Object.keys(r[i][s]).forEach(o=>{var a,l;const u=r[i][s][o];this.receipts[s]||(this.receipts[s]={}),this.receipts[s][o]||(this.receipts[s][o]=[null,null]);const c=this.receipts[s][o];let g=c[Ks];if(t){var m;g=(m=c[Fs])!==null&&m!==void 0?m:c[Ks]}if(g){const T=this.getUnfilteredTimelineSet().compareEventOrdering(g.eventId,i);if(T!==null&&T>=0)return}const f={eventId:i,data:u},E=t?c[Ks]:f,I=t?f:c[Fs];let w=null;E&&I&&(w=this.getUnfilteredTimelineSet().compareEventOrdering(E.eventId,I.eventId));const k=w===null||w<0,C=(a=c[Fs])!==null&&a!==void 0?a:c[Ks];t&&k?c[Fs]=f:t||(c[Ks]=f,k||(c[Fs]=null));const S=(l=c[Fs])!==null&&l!==void 0?l:c[Ks];if(C!==S){if(C&&this.receiptCacheByEventId[C.eventId]){const T=C.eventId;this.receiptCacheByEventId[T]=this.receiptCacheByEventId[T].filter(D=>D.type!==s||D.userId!==o),this.receiptCacheByEventId[T].length<1&&delete this.receiptCacheByEventId[T]}this.receiptCacheByEventId[i]||(this.receiptCacheByEventId[i]=[]),this.receiptCacheByEventId[i].push({userId:o,type:s,data:u})}})})})}addLocalEchoReceipt(e,t,r){this.addReceipt(gg(e,t,r),!0)}addTags(e){this.tags=e.getContent().tags||{},this.emit(it.Tags,e,this)}addAccountData(e){for(let t=0;t<e.length;t++){const r=e[t];r.getType()==="m.tag"&&this.addTags(r);const i=this.accountData[r.getType()];this.accountData[r.getType()]=r,this.emit(it.AccountData,r,this,i)}}getAccountData(e){return this.accountData[e]}maySendMessage(){return this.getMyMembership()==="join"&&(this.client.isRoomEncrypted(this.roomId)?this.currentState.maySendEvent(Ne.EventType.RoomMessageEncrypted,this.myUserId):this.currentState.maySendEvent(Ne.EventType.RoomMessage,this.myUserId))}canInvite(e){let t=this.getMyMembership()==="join";const r=this.currentState.getStateEvents(Ne.EventType.RoomPowerLevels,""),i=r&&r.getContent(),s=this.getMember(e);return i&&s&&i.invite>s.powerLevel&&(t=!1),t}getJoinRule(){return this.currentState.getJoinRule()}getHistoryVisibility(){return this.currentState.getHistoryVisibility()}getGuestAccess(){return this.currentState.getGuestAccess()}getType(){const e=this.currentState.getStateEvents(Ne.EventType.RoomCreate,"");if(!e){this.getTypeWarning||(ht.logger.warn("[getType] Room "+this.roomId+" does not have an m.room.create event"),this.getTypeWarning=!0);return}return e.getContent()[Ne.RoomCreateTypeField]}isSpaceRoom(){return this.getType()===Ne.RoomType.Space}calculateRoomName(e,t=!1){if(!t){const m=this.currentState.getStateEvents(Ne.EventType.RoomName,"");if(m&&m.getContent()&&m.getContent().name)return m.getContent().name}const r=this.getCanonicalAlias();if(r)return r;const i=this.currentState.getJoinedMemberCount(),s=this.currentState.getInvitedMemberCount();let o=i+s-1,a=[];const l=this.currentState.getStateEvents(Ne.UNSTABLE_ELEMENT_FUNCTIONAL_USERS.name,"");Array.isArray(l==null?void 0:l.getContent().service_members)&&(a=l.getContent().service_members);let u=null;if(this.summaryHeroes)u=[],this.summaryHeroes.forEach(m=>{if(a.includes(m)){o--;return}const f=this.getMember(m);u.push(f?f.name:m)});else{let m=this.currentState.getMembers().filter(f=>f.userId!==e&&(f.membership==="invite"||f.membership==="join"));m=m.filter(({userId:f})=>a.includes(f)?(o--,!1):!0),m.sort((f,E)=>ea.compare(f.userId,E.userId)),m=m.slice(0,5),u=m.map(f=>f.name)}if(o)return zu(u,o);if(this.getMyMembership()=="join"){const m=this.currentState.getStateEvents(Ne.EventType.RoomThirdPartyInvite);if(m&&m.length){const f=m.map(E=>E.getContent().display_name);return`Inviting ${zu(f)}`}}let g=u;return g.length||(g=this.currentState.getMembers().filter(m=>m.userId!==e&&m.membership!=="invite"&&m.membership!=="join").map(m=>m.name)),g.length?`Empty room (was ${zu(g)})`:"Empty room"}applyNewVisibilityEvent(e){const t=e.asVisibilityChange();if(!t)return;const r=e.getSender();if(!r||!(Ne.EVENT_VISIBILITY_CHANGE_TYPE.name&&this.currentState.maySendStateEvent(Ne.EVENT_VISIBILITY_CHANGE_TYPE.name,r)||Ne.EVENT_VISIBILITY_CHANGE_TYPE.altName&&this.currentState.maySendStateEvent(Ne.EVENT_VISIBILITY_CHANGE_TYPE.altName,r)))return;const s=this.visibilityEvents.get(t.eventId);if(s){let a=s.length-1;const l=Math.max(0,s.length-MO);for(;a>=l&&!(s[a].getTs()<e.getTs());--a);a===-1?s.unshift(e):s.splice(a+1,0,e)}else this.visibilityEvents.set(t.eventId,[e]);const o=this.findEventById(t.eventId);!o||o.applyVisibilityEvent(t)}redactVisibilityChangeEvent(e){if(!e.isVisibilityEvent)throw new Error("expected a visibility change event");const r=e.getRelation().event_id,i=this.visibilityEvents.get(r);if(!i)return;const s=i.findIndex(o=>o.getId()===e.getId());if(s!==-1&&(i.splice(s,1),s===i.length)){const o=this.findEventById(r);if(!o)return;if(s===0)this.visibilityEvents.delete(r),o.applyVisibilityEvent();else{const l=i[i.length-1].asVisibilityChange();if(!l)throw new Error("at this stage, visibility changes should be well-formed");o.applyVisibilityEvent(l)}}}applyPendingVisibilityEvents(e){const t=this.visibilityEvents.get(e.getId());if(!t||t.length==0)return;const r=t[t.length-1],i=r.asVisibilityChange();!i||(i.visible,!(r.getTs()<e.getTs())&&e.applyVisibilityEvent(i))}}lr.Room=AO;function Yu(n){return`mx_pending_events_${n}`}const DO={[De.EventStatus.ENCRYPTING]:[De.EventStatus.SENDING,De.EventStatus.NOT_SENT,De.EventStatus.CANCELLED],[De.EventStatus.SENDING]:[De.EventStatus.ENCRYPTING,De.EventStatus.QUEUED,De.EventStatus.NOT_SENT,De.EventStatus.SENT],[De.EventStatus.QUEUED]:[De.EventStatus.SENDING,De.EventStatus.CANCELLED],[De.EventStatus.SENT]:[],[De.EventStatus.NOT_SENT]:[De.EventStatus.SENDING,De.EventStatus.QUEUED,De.EventStatus.CANCELLED],[De.EventStatus.CANCELLED]:[]};function zu(n,e=n.length+1){const t=e-1;return n.length?n.length===1&&t<=1?n[0]:n.length===2&&t<=2?`${n[0]} and ${n[1]}`:t>1?`${n[0]} and ${t} others`:`${n[0]} and 1 other`:"Empty room"}var Xl={};Object.defineProperty(Xl,"__esModule",{value:!0});Xl.Group=ac;var xO=Bl.exports,UO=$O(W);function jv(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(jv=function(r){return r?t:e})(n)}function $O(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=jv(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}function ac(n){this.groupId=n,this.name=null,this.avatarUrl=null,this.myMembership=null,this.inviter=null}UO.inherits(ac,xO.EventEmitter);ac.prototype.setProfile=function(n,e){this.name===n&&this.avatarUrl===e||(this.name=n||this.groupId,this.avatarUrl=e,this.emit("Group.profile",this))};ac.prototype.setMyMembership=function(n){this.myMembership!==n&&(this.myMembership=n,this.emit("Group.myMembership",this))};ac.prototype.setInviter=function(n){this.inviter=n};var cc={},Fe={};Object.defineProperty(Fe,"__esModule",{value:!0});Fe.TweakName=Fe.RuleId=Fe.PushRuleKind=Fe.PushRuleActionName=Fe.DMMemberCountCondition=Fe.ConditionOperator=Fe.ConditionKind=void 0;Fe.isDmMemberCountCondition=LO;let Sh;Fe.PushRuleActionName=Sh;(function(n){n.DontNotify="dont_notify",n.Notify="notify",n.Coalesce="coalesce"})(Sh||(Fe.PushRuleActionName=Sh={}));let bh;Fe.TweakName=bh;(function(n){n.Highlight="highlight",n.Sound="sound"})(bh||(Fe.TweakName=bh={}));let wh;Fe.ConditionOperator=wh;(function(n){n.ExactEquals="==",n.LessThan="<",n.GreaterThan=">",n.GreaterThanOrEqual=">=",n.LessThanOrEqual="<="})(wh||(Fe.ConditionOperator=wh={}));const NO="2";Fe.DMMemberCountCondition=NO;function LO(n){return n==="==2"||n==="2"}let Rh;Fe.ConditionKind=Rh;(function(n){n.EventMatch="event_match",n.ContainsDisplayName="contains_display_name",n.RoomMemberCount="room_member_count",n.SenderNotificationPermission="sender_notification_permission"})(Rh||(Fe.ConditionKind=Rh={}));let Ih;Fe.PushRuleKind=Ih;(function(n){n.Override="override",n.ContentSpecific="content",n.RoomSpecific="room",n.SenderSpecific="sender",n.Underride="underride"})(Ih||(Fe.PushRuleKind=Ih={}));let Th;Fe.RuleId=Th;(function(n){n.Master=".m.rule.master",n.ContainsDisplayName=".m.rule.contains_display_name",n.ContainsUserName=".m.rule.contains_user_name",n.AtRoomNotification=".m.rule.roomnotif",n.DM=".m.rule.room_one_to_one",n.EncryptedDM=".m.rule.encrypted_room_one_to_one",n.Message=".m.rule.message",n.EncryptedMessage=".m.rule.encrypted",n.InviteToSelf=".m.rule.invite_for_me",n.MemberEvent=".m.rule.member_event",n.IncomingCall=".m.rule.call",n.SuppressNotices=".m.rule.suppress_notices",n.Tombstone=".m.rule.tombstone"})(Th||(Fe.RuleId=Th={}));var BO=G.exports;Object.defineProperty(cc,"__esModule",{value:!0});cc.PushProcessor=void 0;var Vv=BO(Y.exports),Ju=W,KO=se,Be=Fe;function mg(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function yg(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?mg(Object(t),!0).forEach(function(r){(0,Vv.default)(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):mg(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}const Xu=[Be.PushRuleKind.Override,Be.PushRuleKind.ContentSpecific,Be.PushRuleKind.RoomSpecific,Be.PushRuleKind.SenderSpecific,Be.PushRuleKind.Underride],FO=[{rule_id:".m.rule.tombstone",default:!0,enabled:!0,conditions:[{kind:Be.ConditionKind.EventMatch,key:"type",pattern:"m.room.tombstone"},{kind:Be.ConditionKind.EventMatch,key:"state_key",pattern:""}],actions:[Be.PushRuleActionName.Notify,{set_tweak:Be.TweakName.Highlight,value:!0}]},{rule_id:".m.rule.reaction",default:!0,enabled:!0,conditions:[{kind:Be.ConditionKind.EventMatch,key:"type",pattern:"m.reaction"}],actions:[Be.PushRuleActionName.DontNotify]}];class Ai{constructor(e){this.client=e}static actionListToActionsObject(e){const t={notify:!1,tweaks:{}};for(let r=0;r<e.length;++r){const i=e[r];i===Be.PushRuleActionName.Notify?t.notify=!0:typeof i=="object"&&(i.value===void 0&&(i.value=!0),t.tweaks[i.set_tweak]=i.value)}return t}static rewriteDefaultRules(e){let t=JSON.parse(JSON.stringify(e));t||(t={}),t.global||(t.global={}),t.global.override||(t.global.override=[]);const r=t.global.override;for(const i of FO){const s=r.find(o=>o.rule_id===i.rule_id);if(s)s.default=i.default,s.conditions=i.conditions,s.actions=i.actions;else{const o=i.rule_id;KO.logger.warn(`Adding default global override for ${o}`),r.push(i)}}return t}matchingRuleFromKindSet(e,t){for(let r=0;r<Xu.length;++r){const i=Xu[r],s=t[i];if(!!s)for(let o=0;o<s.length;++o){const a=s[o];if(!a.enabled)continue;const l=this.templateRuleToRaw(i,a);if(!!l&&this.ruleMatchesEvent(l,e))return yg(yg({},a),{},{kind:i})}}return null}templateRuleToRaw(e,t){const r={rule_id:t.rule_id,actions:t.actions,conditions:[]};switch(e){case Be.PushRuleKind.Underride:case Be.PushRuleKind.Override:r.conditions=t.conditions;break;case Be.PushRuleKind.RoomSpecific:if(!t.rule_id)return null;r.conditions.push({kind:Be.ConditionKind.EventMatch,key:"room_id",value:t.rule_id});break;case Be.PushRuleKind.SenderSpecific:if(!t.rule_id)return null;r.conditions.push({kind:Be.ConditionKind.EventMatch,key:"user_id",value:t.rule_id});break;case Be.PushRuleKind.ContentSpecific:if(!t.pattern)return null;r.conditions.push({kind:Be.ConditionKind.EventMatch,key:"content.body",pattern:t.pattern});break}return r}eventFulfillsCondition(e,t){switch(e.kind){case Be.ConditionKind.EventMatch:return this.eventFulfillsEventMatchCondition(e,t);case Be.ConditionKind.ContainsDisplayName:return this.eventFulfillsDisplayNameCondition(e,t);case Be.ConditionKind.RoomMemberCount:return this.eventFulfillsRoomMemberCountCondition(e,t);case Be.ConditionKind.SenderNotificationPermission:return this.eventFulfillsSenderNotifPermCondition(e,t)}return!1}eventFulfillsSenderNotifPermCondition(e,t){const r=e.key;if(!r)return!1;const i=this.client.getRoom(t.getRoomId());return i!=null&&i.currentState?i.currentState.mayTriggerNotifOfType(r,t.getSender()):!1}eventFulfillsRoomMemberCountCondition(e,t){if(!e.is)return!1;const r=this.client.getRoom(t.getRoomId());if(!r||!r.currentState||!r.currentState.members)return!1;const i=r.currentState.getJoinedMemberCount(),s=e.is.match(/^([=<>]*)([0-9]*)$/);if(!s)return!1;const o=s[1],a=parseInt(s[2]);if(isNaN(a))return!1;switch(o){case"":case"==":return i==a;case"<":return i<a;case">":return i>a;case"<=":return i<=a;case">=":return i>=a;default:return!1}}eventFulfillsDisplayNameCondition(e,t){let r=t.getContent();if(t.isEncrypted()&&t.getClearContent()&&(r=t.getClearContent()),!r||!r.body||typeof r.body!="string")return!1;const i=this.client.getRoom(t.getRoomId());if(!i||!i.currentState||!i.currentState.members||!i.currentState.getMember(this.client.credentials.userId))return!1;const s=i.currentState.getMember(this.client.credentials.userId).name,o=new RegExp("(^|\\W)"+(0,Ju.escapeRegExp)(s)+"(\\W|$)","i");return r.body.search(o)>-1}eventFulfillsEventMatchCondition(e,t){if(!e.key)return!1;const r=this.valueForDottedKey(e.key,t);if(typeof r!="string")return!1;if(e.value)return e.value===r;if(typeof e.pattern!="string")return!1;let i;return e.key=="content.body"?i=this.createCachedRegex("(^|\\W)",e.pattern,"(\\W|$)"):i=this.createCachedRegex("^",e.pattern,"$"),!!r.match(i)}createCachedRegex(e,t,r){return Ai.cachedGlobToRegex[t]||(Ai.cachedGlobToRegex[t]=new RegExp(e+(0,Ju.globToRegexp)(t)+r,"i")),Ai.cachedGlobToRegex[t]}valueForDottedKey(e,t){const r=e.split(".");let i;const s=r[0];for(s==="content"?(i=t.getContent(),r.shift()):s==="type"?(i=t.getType(),r.shift()):i=t.event;r.length>0;){const o=r.shift();if((0,Ju.isNullOrUndefined)(i[o]))return null;i=i[o]}return i}matchingRuleForEventWithRulesets(e,t){return!t||e.getSender()===this.client.credentials.userId?null:this.matchingRuleFromKindSet(e,t.global)}pushActionsForEventAndRulesets(e,t){const r=this.matchingRuleForEventWithRulesets(e,t);if(!r)return{};const i=Ai.actionListToActionsObject(r.actions);return i.tweaks.highlight===void 0&&(i.tweaks.highlight=r.kind==Be.PushRuleKind.ContentSpecific),i}ruleMatchesEvent(e,t){var r;if(!((r=e.conditions)!==null&&r!==void 0&&r.length))return!0;let i=!0;for(let s=0;s<e.conditions.length;++s){const o=e.conditions[s];i&=this.eventFulfillsCondition(o,t)}return i}actionsForEvent(e){return this.pushActionsForEventAndRulesets(e,this.client.pushRules)}getPushRuleById(e){for(const t of["global"])if(this.client.pushRules[t]!==void 0){for(const r of Xu)if(this.client.pushRules[t][r]!==void 0){for(const i of this.client.pushRules[t][r])if(i.rule_id===e)return i}}return null}}cc.PushProcessor=Ai;(0,Vv.default)(Ai,"cachedGlobToRegex",{});var oi={};Object.defineProperty(oi,"__esModule",{value:!0});oi.InvalidCryptoStoreError=Zl;oi.InvalidStoreError=Ql;oi.KeySignatureUploadError=void 0;function Ql(n,e){const t=`Store is invalid because ${n}, please stop the client, delete all data and start the client again`,r=Reflect.construct(Error,[t]);return Reflect.setPrototypeOf(r,Reflect.getPrototypeOf(this)),r.reason=n,r.value=e,r}Ql.TOGGLED_LAZY_LOADING="TOGGLED_LAZY_LOADING";Ql.prototype=Object.create(Error.prototype,{constructor:{value:Error,enumerable:!1,writable:!0,configurable:!0}});Reflect.setPrototypeOf(Ql,Error);function Zl(n){const e=`Crypto store is invalid because ${n}, please stop the client, delete all data and start the client again`,t=Reflect.construct(Error,[e]);return Reflect.setPrototypeOf(t,Reflect.getPrototypeOf(this)),t.reason=n,t.name="InvalidCryptoStoreError",t}Zl.TOO_NEW="TOO_NEW";Zl.prototype=Object.create(Error.prototype,{constructor:{value:Error,enumerable:!1,writable:!0,configurable:!0}});Reflect.setPrototypeOf(Zl,Error);class qO extends Error{constructor(e,t){super(e);this.value=t}}oi.KeySignatureUploadError=qO;var ri={},jO=G.exports;Object.defineProperty(ri,"__esModule",{value:!0});ri.SyncAccumulator=ri.Category=void 0;var ta=jO(Y.exports),VO=se,GO=W;let Bt;ri.Category=Bt;(function(n){n.Invite="invite",n.Leave="leave",n.Join="join"})(Bt||(ri.Category=Bt={}));class WO{constructor(e={}){this.opts=e,(0,ta.default)(this,"accountData",{}),(0,ta.default)(this,"inviteRooms",{}),(0,ta.default)(this,"joinRooms",{}),(0,ta.default)(this,"nextBatch",null),(0,ta.default)(this,"groups",{invite:{},join:{},leave:{}}),this.opts.maxTimelineEntries=this.opts.maxTimelineEntries||50}accumulate(e,t=!1){this.accumulateRooms(e,t),this.accumulateGroups(e),this.accumulateAccountData(e),this.nextBatch=e.next_batch}accumulateAccountData(e){!e.account_data||!e.account_data.events||e.account_data.events.forEach(t=>{this.accountData[t.type]=t})}accumulateRooms(e,t=!1){!e.rooms||(e.rooms.invite&&Object.keys(e.rooms.invite).forEach(r=>{this.accumulateRoom(r,Bt.Invite,e.rooms.invite[r],t)}),e.rooms.join&&Object.keys(e.rooms.join).forEach(r=>{this.accumulateRoom(r,Bt.Join,e.rooms.join[r],t)}),e.rooms.leave&&Object.keys(e.rooms.leave).forEach(r=>{this.accumulateRoom(r,Bt.Leave,e.rooms.leave[r],t)}))}accumulateRoom(e,t,r,i=!1){switch(t){case Bt.Invite:this.accumulateInviteState(e,r);break;case Bt.Join:this.inviteRooms[e]&&delete this.inviteRooms[e],this.accumulateJoinState(e,r,i);break;case Bt.Leave:this.inviteRooms[e]?delete this.inviteRooms[e]:delete this.joinRooms[e];break;default:VO.logger.error("Unknown cateogory: ",t)}}accumulateInviteState(e,t){if(!t.invite_state||!t.invite_state.events)return;if(!this.inviteRooms[e]){this.inviteRooms[e]={invite_state:t.invite_state};return}const r=this.inviteRooms[e];t.invite_state.events.forEach(i=>{let s=!1;for(let o=0;o<r.invite_state.events.length;o++){const a=r.invite_state.events[o];a.type===i.type&&a.state_key==i.state_key&&(r.invite_state.events[o]=i,s=!0)}s||r.invite_state.events.push(i)})}accumulateJoinState(e,t,r=!1){this.joinRooms[e]||(this.joinRooms[e]={_currentState:Object.create(null),_timeline:[],_accountData:Object.create(null),_unreadNotifications:{},_summary:{},_readReceipts:{}});const i=this.joinRooms[e];if(t.account_data&&t.account_data.events&&t.account_data.events.forEach(s=>{i._accountData[s.type]=s}),t.unread_notifications&&(i._unreadNotifications=t.unread_notifications),t.summary){const s="m.heroes",o="m.invited_member_count",a="m.joined_member_count",l=i._summary,u=t.summary;l[s]=u[s]||l[s],l[a]=u[a]||l[a],l[o]=u[o]||l[o]}if(t.ephemeral&&t.ephemeral.events&&t.ephemeral.events.forEach(s=>{s.type!=="m.receipt"||!s.content||Object.keys(s.content).forEach(o=>{!s.content[o]["m.read"]||Object.keys(s.content[o]["m.read"]).forEach(a=>{i._readReceipts[a]={data:s.content[o]["m.read"][a],eventId:o}})})}),t.timeline&&t.timeline.limited&&(i._timeline=[]),t.state&&t.state.events&&t.state.events.forEach(s=>{Qu(i._currentState,s)}),t.timeline&&t.timeline.events&&t.timeline.events.forEach((s,o)=>{Qu(i._currentState,s);let a;if(r)a=s;else{a=Object.assign({},s),a.unsigned!==void 0&&(a.unsigned=Object.assign({},a.unsigned));const l=s.unsigned?s.unsigned.age:s.age;l!==void 0&&(a._localTs=Date.now()-l)}i._timeline.push({event:a,token:o===0?t.timeline.prev_batch:null})}),i._timeline.length>this.opts.maxTimelineEntries){const s=i._timeline.length-this.opts.maxTimelineEntries;for(let o=s;o<i._timeline.length;o++)if(i._timeline[o].token){i._timeline=i._timeline.slice(o,i._timeline.length);break}}}accumulateGroups(e){!e.groups||(e.groups.invite&&Object.keys(e.groups.invite).forEach(t=>{this.accumulateGroup(t,Bt.Invite,e.groups.invite[t])}),e.groups.join&&Object.keys(e.groups.join).forEach(t=>{this.accumulateGroup(t,Bt.Join,e.groups.join[t])}),e.groups.leave&&Object.keys(e.groups.leave).forEach(t=>{this.accumulateGroup(t,Bt.Leave,e.groups.leave[t])}))}accumulateGroup(e,t,r){for(const i of[Bt.Invite,Bt.Leave,Bt.Join])delete this.groups[i][e];this.groups[t][e]=r}getJSON(e=!1){const t={join:{},invite:{},leave:{}};Object.keys(this.inviteRooms).forEach(i=>{t.invite[i]=this.inviteRooms[i]}),Object.keys(this.joinRooms).forEach(i=>{const s=this.joinRooms[i],o={ephemeral:{events:[]},account_data:{events:[]},state:{events:[]},timeline:{events:[],prev_batch:null},unread_notifications:s._unreadNotifications,summary:s._summary};Object.keys(s._accountData).forEach(u=>{o.account_data.events.push(s._accountData[u])});const a={type:"m.receipt",room_id:i,content:{}};Object.keys(s._readReceipts).forEach(u=>{const c=s._readReceipts[u];a.content[c.eventId]||(a.content[c.eventId]={"m.read":{}}),a.content[c.eventId]["m.read"][u]=c.data}),Object.keys(a.content).length>0&&o.ephemeral.events.push(a),s._timeline.forEach(u=>{if(!o.timeline.prev_batch){if(!u.token)return;o.timeline.prev_batch=u.token}let c;!e&&u.event._localTs?(c=Object.assign({},u.event),c.unsigned!==void 0&&(c.unsigned=Object.assign({},c.unsigned)),delete c._localTs,c.unsigned=c.unsigned||{},c.unsigned.age=Date.now()-u.event._localTs):c=u.event,o.timeline.events.push(c)});const l=Object.create(null);for(let u=o.timeline.events.length-1;u>=0;u--){const c=o.timeline.events[u];if(c.state_key===null||c.state_key===void 0)continue;const g=(0,GO.deepCopy)(c);g.unsigned&&(g.unsigned.prev_content&&(g.content=g.unsigned.prev_content),g.unsigned.prev_sender&&(g.sender=g.unsigned.prev_sender)),Qu(l,g)}Object.keys(s._currentState).forEach(u=>{Object.keys(s._currentState[u]).forEach(c=>{let g=s._currentState[u][c];l[u]&&l[u][c]&&(g=l[u][c]),o.state.events.push(g)})}),t.join[i]=o});const r=[];return Object.keys(this.accountData).forEach(i=>{r.push(this.accountData[i])}),{nextBatch:this.nextBatch,roomsData:t,groupsData:this.groups,accountData:r}}getNextBatchToken(){return this.nextBatch}}ri.SyncAccumulator=WO;function Qu(n,e){e.state_key===null||e.state_key===void 0||!e.type||(n[e.type]||(n[e.type]=Object.create(null)),n[e.type][e.state_key]=e)}var HO=G.exports;Object.defineProperty($i,"__esModule",{value:!0});$i.SyncState=$i.SyncApi=void 0;var Tr=HO(Y.exports),qs=Qr,It=lr,YO=Xl,js=XO(W),vg=Ds,_g=qt,zO=cc,er=se,Eg=oi,qe=st,Zu=ri,Oc=me,JO=ie,Si=Tn,kc=Zr,ed=vr;function Gv(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(Gv=function(r){return r?t:e})(n)}function XO(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=Gv(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}const Sg=80*1e3,QO=3;let kt;$i.SyncState=kt;(function(n){n.Error="ERROR",n.Prepared="PREPARED",n.Stopped="STOPPED",n.Syncing="SYNCING",n.Catchup="CATCHUP",n.Reconnecting="RECONNECTING"})(kt||($i.SyncState=kt={}));function bg(n,e){return"FILTER_SYNC_"+n+(e?"_"+e:"")}function Me(...n){er.logger.log(...n)}var Oh;(function(n){n.Offline="offline",n.Online="online",n.Unavailable="unavailable"})(Oh||(Oh={}));class ZO{constructor(e,t={}){var r;this.client=e,this.opts=t,(0,Tr.default)(this,"_peekRoom",null),(0,Tr.default)(this,"currentSyncRequest",null),(0,Tr.default)(this,"syncState",null),(0,Tr.default)(this,"syncStateData",null),(0,Tr.default)(this,"catchingUp",!1),(0,Tr.default)(this,"running",!1),(0,Tr.default)(this,"keepAliveTimer",null),(0,Tr.default)(this,"connectionReturnedDefer",null),(0,Tr.default)(this,"notifEvents",[]),(0,Tr.default)(this,"failedSyncCount",0),(0,Tr.default)(this,"storeIsInvalid",!1),(0,Tr.default)(this,"onOnline",()=>{Me("Browser thinks we are back online"),this.startKeepAlives(0)}),this.opts.initialSyncLimit=(r=this.opts.initialSyncLimit)!==null&&r!==void 0?r:8,this.opts.resolveInvitesToProfiles=this.opts.resolveInvitesToProfiles||!1,this.opts.pollTimeout=this.opts.pollTimeout||30*1e3,this.opts.pendingEventOrdering=this.opts.pendingEventOrdering||qe.PendingEventOrdering.Chronological,this.opts.experimentalThreadSupport=this.opts.experimentalThreadSupport===!0,t.canResetEntireTimeline||(t.canResetEntireTimeline=i=>!1),e.getNotifTimelineSet()&&e.reEmitter.reEmit(e.getNotifTimelineSet(),[It.RoomEvent.Timeline,It.RoomEvent.TimelineReset])}createRoom(e){const t=this.client,{timelineSupport:r,unstableClientRelationAggregation:i}=t,s=new It.Room(e,t,t.getUserId(),{lazyLoadMembers:this.opts.lazyLoadMembers,pendingEventOrdering:this.opts.pendingEventOrdering,timelineSupport:r,unstableClientRelationAggregation:i});return t.reEmitter.reEmit(s,[It.RoomEvent.Name,It.RoomEvent.Redaction,It.RoomEvent.RedactionCancelled,It.RoomEvent.Receipt,It.RoomEvent.Tags,It.RoomEvent.LocalEchoUpdated,It.RoomEvent.AccountData,It.RoomEvent.MyMembership,It.RoomEvent.Timeline,It.RoomEvent.TimelineReset]),this.registerStateListeners(s),s}createGroup(e){const t=this.client,r=new YO.Group(e);return t.reEmitter.reEmit(r,[qe.ClientEvent.GroupProfile,qe.ClientEvent.GroupMyMembership]),t.store.storeGroup(r),r}registerStateListeners(e){const t=this.client;t.reEmitter.reEmit(e.currentState,[Si.RoomStateEvent.Events,Si.RoomStateEvent.Members,Si.RoomStateEvent.NewMember,Si.RoomStateEvent.Update,ed.BeaconEvent.New,ed.BeaconEvent.Update,ed.BeaconEvent.LivenessChange]),e.currentState.on(Si.RoomStateEvent.NewMember,function(r,i,s){s.user=t.getUser(s.userId),t.reEmitter.reEmit(s,[kc.RoomMemberEvent.Name,kc.RoomMemberEvent.Typing,kc.RoomMemberEvent.PowerLevel,kc.RoomMemberEvent.Membership])})}deregisterStateListeners(e){e.currentState.removeAllListeners(Si.RoomStateEvent.Events),e.currentState.removeAllListeners(Si.RoomStateEvent.Members),e.currentState.removeAllListeners(Si.RoomStateEvent.NewMember)}syncLeftRooms(){const e=this.client,t=new vg.Filter(this.client.credentials.userId);t.setTimelineLimit(1),t.setIncludeLeaveRooms(!0);const r=this.opts.pollTimeout+Sg,i={timeout:0};return e.getOrCreateFilter(bg(e.credentials.userId,"LEFT_ROOMS"),t).then(function(s){return i.filter=s,e.http.authedRequest(void 0,Oc.Method.Get,"/sync",i,void 0,r)}).then(s=>{var o;let a=[];(o=s.rooms)!==null&&o!==void 0&&o.leave&&(a=this.mapSyncResponseToRoomArray(s.rooms.leave));const l=[];return a.forEach(async u=>{const c=u.room;if(l.push(c),!u.isBrandNewRoom)return;u.timeline=u.timeline||{};const g=this.mapSyncEventsFormat(u.timeline,c),[m,f]=this.client.partitionThreadedEvents(g),E=this.mapSyncEventsFormat(u.state,c);c.getLiveTimeline().setPaginationToken(u.timeline.prev_batch,_g.EventTimeline.BACKWARDS),this.processRoomEvents(c,E,m),await this.processThreadEvents(c,f,!1),c.recalculate(),e.store.storeRoom(c),e.emit(qe.ClientEvent.Room,c),this.processEventsForNotifs(c,g)}),l})}peek(e){if(this._peekRoom&&this._peekRoom.roomId===e)return Promise.resolve(this._peekRoom);const t=this.client;return this._peekRoom=this.createRoom(e),this.client.roomInitialSync(e,20).then(r=>{r.messages=r.messages||{chunk:[]},r.messages.chunk=r.messages.chunk||[],r.state=r.state||[];const i=js.deepCopy(r.state).map(t.getEventMapper()),s=r.state.map(t.getEventMapper()),o=r.messages.chunk.map(t.getEventMapper());return r.presence&&Array.isArray(r.presence)&&r.presence.map(t.getEventMapper()).forEach(function(a){let l=t.store.getUser(a.getContent().user_id);l?l.setPresenceEvent(a):(l=Cc(t,a.getContent().user_id),l.setPresenceEvent(a),t.store.storeUser(l)),t.emit(qe.ClientEvent.Event,a)}),r.messages.start&&(this._peekRoom.oldState.paginationToken=r.messages.start),this._peekRoom.oldState.setStateEvents(i),this._peekRoom.currentState.setStateEvents(s),this.resolveInvites(this._peekRoom),this._peekRoom.recalculate(),this._peekRoom.addEventsToTimeline(o.reverse(),!0,this._peekRoom.getLiveTimeline(),r.messages.start),t.store.storeRoom(this._peekRoom),t.emit(qe.ClientEvent.Room,this._peekRoom),this.peekPoll(this._peekRoom),this._peekRoom})}stopPeeking(){this._peekRoom=null}peekPoll(e,t){if(this._peekRoom!==e){Me("Stopped peeking in room %s",e.roomId);return}this.client.http.authedRequest(void 0,Oc.Method.Get,"/events",{room_id:e.roomId,timeout:String(30*1e3),from:t},void 0,50*1e3).then(r=>{if(this._peekRoom!==e){Me("Stopped peeking in room %s",e.roomId);return}r.chunk.filter(function(s){return s.type==="m.presence"}).map(this.client.getEventMapper()).forEach(s=>{let o=this.client.store.getUser(s.getContent().user_id);o?o.setPresenceEvent(s):(o=Cc(this.client,s.getContent().user_id),o.setPresenceEvent(s),this.client.store.storeUser(o)),this.client.emit(qe.ClientEvent.Event,s)});const i=r.chunk.filter(function(s){return s.room_id===e.roomId&&s.event_id}).map(this.client.getEventMapper());e.addLiveEvents(i),this.peekPoll(e,r.end)},r=>{er.logger.error("[%s] Peek poll failed: %s",e.roomId,r),setTimeout(()=>{this.peekPoll(e,t)},30*1e3)})}getSyncState(){return this.syncState}getSyncStateData(){return this.syncStateData}async recoverFromSyncStartupError(e,t){await e;const r=this.startKeepAlives();this.updateSyncState(kt.Error,{error:t}),await r}async wasLazyLoadingToggled(e=!1){let t=!1;if(!await this.client.store.isNewlyCreated()){const i=await this.client.store.getClientOptions();return i&&(t=!!i.lazyLoadMembers),t!==e}return!1}shouldAbortSync(e){return e.errcode==="M_UNKNOWN_TOKEN"?(er.logger.warn("Token no longer valid - assuming logout"),this.stop(),this.updateSyncState(kt.Error,{error:e}),!0):!1}sync(){const e=this.client;this.running=!0,V.window&&V.window.addEventListener&&V.window.addEventListener("online",this.onOnline,!1);let t=Promise.resolve(),r=null;const i=async()=>{try{Me("Getting push rules...");const l=await e.getPushRules();Me("Got push rules"),e.pushRules=l}catch(l){if(er.logger.error("Getting push rules failed",l),this.shouldAbortSync(l))return;Me("Waiting for saved sync before retrying push rules..."),await this.recoverFromSyncStartupError(t,l),i();return}o()},s=()=>{const l=new vg.Filter(e.credentials.userId);return l.setTimelineLimit(this.opts.initialSyncLimit),l},o=async()=>{if(Me("Checking lazy load status..."),this.opts.lazyLoadMembers&&e.isGuest()&&(this.opts.lazyLoadMembers=!1),this.opts.lazyLoadMembers&&(Me("Checking server lazy load support..."),await e.doesServerSupportLazyLoading()?(Me("Enabling lazy load on sync filter..."),this.opts.filter||(this.opts.filter=s()),this.opts.filter.setLazyLoadMembers(!0)):(Me("LL: lazy loading requested but not supported by server, so disabling"),this.opts.lazyLoadMembers=!1)),Me("Checking whether lazy loading has changed in store..."),await this.wasLazyLoadingToggled(this.opts.lazyLoadMembers)){this.storeIsInvalid=!0;const u=Eg.InvalidStoreError.TOGGLED_LAZY_LOADING,c=new Eg.InvalidStoreError(u,!!this.opts.lazyLoadMembers);this.updateSyncState(kt.Error,{error:c}),er.logger.warn("InvalidStoreError: store is not usable: stopping sync.");return}this.opts.lazyLoadMembers&&this.opts.crypto&&this.opts.crypto.enableLazyLoading();try{Me("Storing client options..."),await this.client.storeClientOptions(),Me("Stored client options")}catch(u){throw er.logger.error("Storing client options failed",u),u}a()},a=async()=>{Me("Getting filter...");let l;this.opts.filter?l=this.opts.filter:l=s();let u;try{u=await e.getOrCreateFilter(bg(e.credentials.userId),l)}catch(c){if(er.logger.error("Getting filter failed",c),this.shouldAbortSync(c))return;Me("Waiting for saved sync before retrying filter..."),await this.recoverFromSyncStartupError(t,c),a();return}e.resetNotifTimelineSet(),this.currentSyncRequest===null&&(Me("Sending first sync request..."),this.currentSyncRequest=this.doSyncRequest({filterId:u},r)),Me("Waiting for saved sync before starting sync processing..."),await t,this.doSync({filterId:u})};e.isGuest()?this.doSync({}):(Me("Getting saved sync token..."),t=e.store.getSavedSyncToken().then(l=>(Me("Got saved sync token"),r=l,Me("Getting saved sync..."),e.store.getSavedSync())).then(l=>{if(Me(`Got reply from saved sync, exists? ${!!l}`),l)return this.syncFromCache(l)}).catch(l=>{er.logger.error("Getting saved sync failed",l)}),i())}stop(){Me("SyncApi.stop"),V.window&&V.window.removeEventListener&&V.window.removeEventListener("online",this.onOnline,!1),this.running=!1,this.currentSyncRequest&&this.currentSyncRequest.abort(),this.keepAliveTimer&&(clearTimeout(this.keepAliveTimer),this.keepAliveTimer=null)}retryImmediately(){return this.connectionReturnedDefer?(this.startKeepAlives(0),!0):!1}async syncFromCache(e){Me("sync(): not doing HTTP hit, instead returning stored /sync data");const t=e.nextBatch;this.client.store.setSyncToken(t);const r={oldSyncToken:null,nextSyncToken:t,catchingUp:!1,fromCache:!0},i={next_batch:t,rooms:e.roomsData,groups:e.groupsData,account_data:{events:e.accountData}};try{await this.processSyncResponse(r,i)}catch(s){er.logger.error("Error processing cached sync",s.stack||s)}this.storeIsInvalid||this.updateSyncState(kt.Prepared,r)}async doSync(e){const t=this.client;if(!this.running){Me("Sync no longer running: exiting."),this.connectionReturnedDefer&&(this.connectionReturnedDefer.reject(),this.connectionReturnedDefer=null),this.updateSyncState(kt.Stopped);return}const r=t.store.getSyncToken();let i;try{this.currentSyncRequest===null&&(this.currentSyncRequest=this.doSyncRequest(e,r)),i=await this.currentSyncRequest}catch(o){this.onSyncError(o,e);return}finally{this.currentSyncRequest=null}t.store.setSyncToken(i.next_batch),this.failedSyncCount=0,await t.store.setSyncData(i);const s={oldSyncToken:r,nextSyncToken:i.next_batch,catchingUp:this.catchingUp};this.opts.crypto&&await this.opts.crypto.onSyncWillProcess(s);try{await this.processSyncResponse(s,i)}catch(o){er.logger.error("Caught /sync error",o.stack||o),this.client.emit(qe.ClientEvent.SyncUnexpectedError,o)}s.catchingUp=this.catchingUp,e.hasSyncedBefore||(this.updateSyncState(kt.Prepared,s),e.hasSyncedBefore=!0),this.opts.crypto&&await this.opts.crypto.onSyncCompleted(s),this.updateSyncState(kt.Syncing,s),t.store.wantsSave()&&(this.opts.crypto&&await this.opts.crypto.saveDeviceList(0),t.store.save()),this.doSync(e)}doSyncRequest(e,t){const r=this.getSyncParams(e,t);return this.client.http.authedRequest(void 0,Oc.Method.Get,"/sync",r,void 0,r.timeout+Sg)}getSyncParams(e,t){let r=this.opts.pollTimeout;(this.getSyncState()!=="SYNCING"||this.catchingUp)&&(this.catchingUp=!0,r=0);let i=e.filterId;this.client.isGuest()&&!i&&(i=this.getGuestFilter());const s={filter:i,timeout:r};return this.opts.disablePresence&&(s.set_presence=Oh.Offline),t?s.since=t:s._cacheBuster=Date.now(),(this.getSyncState()=="ERROR"||this.getSyncState()=="RECONNECTING")&&(s.timeout=0),s}onSyncError(e,t){if(!this.running){Me("Sync no longer running: exiting"),this.connectionReturnedDefer&&(this.connectionReturnedDefer.reject(),this.connectionReturnedDefer=null),this.updateSyncState(kt.Stopped);return}er.logger.error("/sync error %s",e),er.logger.error(e),!this.shouldAbortSync(e)&&(this.failedSyncCount++,er.logger.log("Number of consecutive failed sync requests:",this.failedSyncCount),Me("Starting keep-alive"),this.startKeepAlives().then(r=>{r&&this.getSyncState()===kt.Error&&this.updateSyncState(kt.Catchup,{oldSyncToken:null,nextSyncToken:null,catchingUp:!0}),this.doSync(t)}),this.currentSyncRequest=null,this.updateSyncState(this.failedSyncCount>=QO?kt.Error:kt.Reconnecting,{error:e}))}async processSyncResponse(e,t){const r=this.client;if(t.presence&&Array.isArray(t.presence.events)&&t.presence.events.map(r.getEventMapper()).forEach(function(a){let l=r.store.getUser(a.getSender());l?l.setPresenceEvent(a):(l=Cc(r,a.getSender()),l.setPresenceEvent(a),r.store.storeUser(l)),r.emit(qe.ClientEvent.Event,a)}),t.account_data&&Array.isArray(t.account_data.events)){const a=t.account_data.events.map(r.getEventMapper()),l=a.reduce((u,c)=>(u[c.getId()]=r.store.getAccountData(c.getType()),u),{});r.store.storeAccountDataEvents(a),a.forEach(function(u){if(u.getType()===JO.EventType.PushRules){const g=u.getContent();r.pushRules=zO.PushProcessor.rewriteDefaultRules(g)}const c=l[u.getId()];return r.emit(qe.ClientEvent.AccountData,u,c),u})}if(t.to_device&&Array.isArray(t.to_device.events)&&t.to_device.events.length>0){const a=[];t.to_device.events.map(r.getEventMapper()).map(l=>{if(l.getType()==="m.key.verification.cancel"){const u=l.getContent().transaction_id;u&&a.push(u)}return l}).forEach(function(l){const u=l.getContent();if(l.getType()=="m.room.message"&&u.msgtype=="m.bad.encrypted"){er.logger.log("Ignoring undecryptable to-device event from "+l.getSender());return}if(l.getType()==="m.key.verification.start"||l.getType()==="m.key.verification.request"){const c=u.transaction_id;a.includes(c)&&l.flagCancelled()}r.emit(qe.ClientEvent.ToDeviceEvent,l)})}else this.catchingUp=!1;t.groups&&(t.groups.invite&&this.processGroupSyncEntry(t.groups.invite,Zu.Category.Invite),t.groups.join&&this.processGroupSyncEntry(t.groups.join,Zu.Category.Join),t.groups.leave&&this.processGroupSyncEntry(t.groups.leave,Zu.Category.Leave));let i=[],s=[],o=[];if(t.rooms&&(t.rooms.invite&&(i=this.mapSyncResponseToRoomArray(t.rooms.invite)),t.rooms.join&&(s=this.mapSyncResponseToRoomArray(t.rooms.join)),t.rooms.leave&&(o=this.mapSyncResponseToRoomArray(t.rooms.leave))),this.notifEvents=[],i.forEach(a=>{const l=a.room,u=this.mapSyncEventsFormat(a.invite_state,l);this.processRoomEvents(l,u),a.isBrandNewRoom&&(l.recalculate(),r.store.storeRoom(l),r.emit(qe.ClientEvent.Room,l)),u.forEach(function(c){r.emit(qe.ClientEvent.Event,c)}),l.updateMyMembership("invite")}),await js.promiseMapSeries(s,async a=>{const l=a.room,u=this.mapSyncEventsFormat(a.state,l),c=this.mapSyncEventsFormat(a.timeline,l,!1),g=this.mapSyncEventsFormat(a.ephemeral),m=this.mapSyncEventsFormat(a.account_data),f=r.isRoomEncrypted(l.roomId);if(a.unread_notifications&&(l.setUnreadNotificationCount(It.NotificationCountType.Total,a.unread_notifications.notification_count),(!f||f&&l.getUnreadNotificationCount(It.NotificationCountType.Highlight)<=0)&&l.setUnreadNotificationCount(It.NotificationCountType.Highlight,a.unread_notifications.highlight_count)),a.timeline=a.timeline||{},a.isBrandNewRoom)l.getLiveTimeline().setPaginationToken(a.timeline.prev_batch,_g.EventTimeline.BACKWARDS);else if(a.timeline.limited){let k=!0;for(let C=c.length-1;C>=0;C--){const S=c[C].getId();if(l.getTimelineForEvent(S)){Me("Already have event "+S+" in limited sync - not resetting"),k=!1,c.splice(0,C);break}}k&&(this.deregisterStateListeners(l),l.resetLiveTimeline(a.timeline.prev_batch,this.opts.canResetEntireTimeline(l.roomId)?null:e.oldSyncToken),r.resetNotifTimelineSet(),this.registerStateListeners(l))}const[E,I]=this.client.partitionThreadedEvents(c);this.processRoomEvents(l,u,E,e.fromCache),await this.processThreadEvents(l,I,!1),a.summary&&l.setSummary(a.summary),l.addEphemeralEvents(g),l.addAccountData(m),l.recalculate(),a.isBrandNewRoom&&(r.store.storeRoom(l),r.emit(qe.ClientEvent.Room,l)),this.processEventsForNotifs(l,c);const w=async k=>{if(r.emit(qe.ClientEvent.Event,k),k.isState()&&k.getType()=="m.room.encryption"&&this.opts.crypto&&await this.opts.crypto.onCryptoEvent(k),k.isState()&&k.getType()==="im.vector.user_status"){let C=r.store.getUser(k.getStateKey());C?C.unstable_updateStatusMessage(k):(C=Cc(r,k.getStateKey()),C.unstable_updateStatusMessage(k),r.store.storeUser(C))}};await js.promiseMapSeries(u,w),await js.promiseMapSeries(E,w),await js.promiseMapSeries(I,w),g.forEach(function(k){r.emit(qe.ClientEvent.Event,k)}),m.forEach(function(k){r.emit(qe.ClientEvent.Event,k)}),l.updateMyMembership("join"),l.decryptCriticalEvents()}),o.forEach(async a=>{const l=a.room,u=this.mapSyncEventsFormat(a.state,l),c=this.mapSyncEventsFormat(a.timeline,l),g=this.mapSyncEventsFormat(a.account_data),[m,f]=this.client.partitionThreadedEvents(c);this.processRoomEvents(l,u,m),await this.processThreadEvents(l,f,!1),l.addAccountData(g),l.recalculate(),a.isBrandNewRoom&&(r.store.storeRoom(l),r.emit(qe.ClientEvent.Room,l)),this.processEventsForNotifs(l,c),u.forEach(function(E){r.emit(qe.ClientEvent.Event,E)}),m.forEach(function(E){r.emit(qe.ClientEvent.Event,E)}),f.forEach(function(E){r.emit(qe.ClientEvent.Event,E)}),g.forEach(function(E){r.emit(qe.ClientEvent.Event,E)}),l.updateMyMembership("leave")}),e.oldSyncToken&&this.notifEvents.length&&(this.notifEvents.sort(function(a,l){return a.getTs()-l.getTs()}),this.notifEvents.forEach(function(a){r.getNotifTimelineSet().addLiveEvent(a)})),t.device_lists&&this.opts.crypto&&await this.opts.crypto.handleDeviceListChanges(e,t.device_lists),this.opts.crypto&&t.device_one_time_keys_count){const a=t.device_one_time_keys_count.signed_curve25519||0;this.opts.crypto.updateOneTimeKeyCount(a)}if(this.opts.crypto&&(t.device_unused_fallback_key_types||t["org.matrix.msc2732.device_unused_fallback_key_types"])){const a=t.device_unused_fallback_key_types||t["org.matrix.msc2732.device_unused_fallback_key_types"];this.opts.crypto.setNeedsNewFallback(a instanceof Array&&!a.includes("signed_curve25519"))}}startKeepAlives(e){return e===void 0&&(e=2e3+Math.floor(Math.random()*5e3)),this.keepAliveTimer!==null&&clearTimeout(this.keepAliveTimer),e>0?this.keepAliveTimer=setTimeout(this.pokeKeepAlive.bind(this),e):this.pokeKeepAlive(),this.connectionReturnedDefer||(this.connectionReturnedDefer=js.defer()),this.connectionReturnedDefer.promise}pokeKeepAlive(e=!1){const t=()=>{clearTimeout(this.keepAliveTimer),this.connectionReturnedDefer&&(this.connectionReturnedDefer.resolve(e),this.connectionReturnedDefer=null)};this.client.http.request(void 0,Oc.Method.Get,"/_matrix/client/versions",void 0,void 0,{prefix:"",localTimeoutMs:15*1e3}).then(()=>{t()},r=>{r.httpStatus==400||r.httpStatus==404?this.keepAliveTimer=setTimeout(t,2e3):(e=!0,this.keepAliveTimer=setTimeout(this.pokeKeepAlive.bind(this,e),5e3+Math.floor(Math.random()*5e3)),this.updateSyncState(kt.Error,{error:r}))})}processGroupSyncEntry(e,t){for(const r of Object.keys(e)){const i=e[r];let s=this.client.store.getGroup(r);const o=s===null;s===null&&(s=this.createGroup(r)),i.profile&&s.setProfile(i.profile.name,i.profile.avatar_url),i.inviter&&s.setInviter({userId:i.inviter}),s.setMyMembership(t),o&&this.client.emit(qe.ClientEvent.Group,s)}}mapSyncResponseToRoomArray(e){const t=this.client;return Object.keys(e).map(r=>{const i=e[r];let s=t.store.getRoom(r),o=!1;return s||(s=this.createRoom(r),o=!0),i.room=s,i.isBrandNewRoom=o,i})}mapSyncEventsFormat(e,t,r=!0){if(!e||!Array.isArray(e.events))return[];const i=this.client.getEventMapper({decrypt:r});return e.events.map(function(s){return t&&(s.room_id=t.roomId),i(s)})}resolveInvites(e){if(!e||!this.opts.resolveInvitesToProfiles)return;const t=this.client;e.getMembersWithMembership("invite").forEach(function(r){if(r._requestedProfileInfo)return;r._requestedProfileInfo=!0;const i=t.getUser(r.userId);let s;i?s=Promise.resolve({avatar_url:i.avatarUrl,displayname:i.displayName}):s=t.getProfileInfo(r.userId),s.then(function(o){const a=r.events.member;a.getContent().membership==="invite"&&(a.getContent().avatar_url=o.avatar_url,a.getContent().displayname=o.displayname,r.setMembershipEvent(a,e.currentState))},function(o){})})}processRoomEvents(e,t,r,i=!1){const s=e.getLiveTimeline(),o=s.getEvents().length==0;if(o){for(const a of t)this.client.getPushActionsForEvent(a);s.initialiseState(t)}this.resolveInvites(e),e.recalculate(),o||(e.oldState.setStateEvents(t||[]),e.currentState.setStateEvents(t||[])),e.addLiveEvents(r||[],null,i)}processThreadEvents(e,t,r){return this.client.processThreadEvents(e,t,r)}processEventsForNotifs(e,t){if(this.client.getNotifTimelineSet())for(let r=0;r<t.length;r++){const i=this.client.getPushActionsForEvent(t[r]);i&&i.notify&&i.tweaks&&i.tweaks.highlight&&this.notifEvents.push(t[r])}}getGuestFilter(){return"{}"}updateSyncState(e,t){const r=this.syncState;this.syncState=e,this.syncStateData=t,this.client.emit(qe.ClientEvent.Sync,this.syncState,r,t)}}$i.SyncApi=ZO;function Cc(n,e){const t=new qs.User(e);return n.reEmitter.reEmit(t,[qs.UserEvent.AvatarUrl,qs.UserEvent.DisplayName,qs.UserEvent.Presence,qs.UserEvent.CurrentlyActive,qs.UserEvent.LastPresenceTs]),t}var eu={},ek=G.exports;Object.defineProperty(eu,"__esModule",{value:!0});eu.StubStore=void 0;var wg=ek(Y.exports);class tk{constructor(){(0,wg.default)(this,"accountData",{}),(0,wg.default)(this,"fromToken",null)}isNewlyCreated(){return Promise.resolve(!0)}getSyncToken(){return this.fromToken}setSyncToken(e){this.fromToken=e}storeGroup(e){}getGroup(e){return null}getGroups(){return[]}storeRoom(e){}getRoom(e){return null}getRooms(){return[]}removeRoom(e){}getRoomSummaries(){return[]}storeUser(e){}getUser(e){return null}getUsers(){return[]}scrollback(e,t){return[]}storeEvents(e,t,r,i){}storeFilter(e){}getFilter(e,t){return null}getFilterIdByName(e){return null}setFilterIdByName(e,t){}storeAccountDataEvents(e){}getAccountData(e){}setSyncData(e){return Promise.resolve()}wantsSave(){return!1}save(){}startup(){return Promise.resolve()}getSavedSync(){return Promise.resolve(null)}getSavedSyncToken(){return Promise.resolve(null)}deleteAllData(){return Promise.resolve()}getOutOfBandMembers(){return Promise.resolve(null)}setOutOfBandMembers(e,t){return Promise.resolve()}clearOutOfBandMembers(){return Promise.resolve()}getClientOptions(){return Promise.resolve({})}storeClientOptions(e){return Promise.resolve()}}eu.StubStore=tk;var Ce={},ai={};Object.defineProperty(ai,"__esModule",{value:!0});ai.randomLowercaseString=ik;ai.randomString=nk;ai.randomUppercaseString=sk;const Wv="abcdefghijklmnopqrstuvwxyz",Hv="ABCDEFGHIJKLMNOPQRSTUVWXYZ",rk="0123456789";function nk(n){return Sf(n,Hv+Wv+rk)}function ik(n){return Sf(n,Wv)}function sk(n){return Sf(n,Hv)}function Sf(n,e){let t="";for(let r=0;r<n;++r)t+=e.charAt(Math.floor(Math.random()*e.length));return t}var ys={};Object.defineProperty(ys,"__esModule",{value:!0});ys.SDPStreamMetadataPurpose=ys.SDPStreamMetadataKey=void 0;const ok="org.matrix.msc3077.sdp_stream_metadata";ys.SDPStreamMetadataKey=ok;let kh;ys.SDPStreamMetadataPurpose=kh;(function(n){n.Usermedia="m.usermedia",n.Screenshare="m.screenshare"})(kh||(ys.SDPStreamMetadataPurpose=kh={}));var Qn={},ak=G.exports;Object.defineProperty(Qn,"__esModule",{value:!0});Qn.SPEAKING_THRESHOLD=Qn.CallFeedEvent=Qn.CallFeed=void 0;var ft=ak(Y.exports),ck=je;const lk=200,Yv=-60;Qn.SPEAKING_THRESHOLD=Yv;const uk=8;let gn;Qn.CallFeedEvent=gn;(function(n){n.NewStream="new_stream",n.MuteStateChanged="mute_state_changed",n.VolumeChanged="volume_changed",n.Speaking="speaking"})(gn||(Qn.CallFeedEvent=gn={}));class dk extends ck.TypedEventEmitter{constructor(e){super();(0,ft.default)(this,"stream",void 0),(0,ft.default)(this,"userId",void 0),(0,ft.default)(this,"purpose",void 0),(0,ft.default)(this,"speakingVolumeSamples",void 0),(0,ft.default)(this,"client",void 0),(0,ft.default)(this,"roomId",void 0),(0,ft.default)(this,"audioMuted",void 0),(0,ft.default)(this,"videoMuted",void 0),(0,ft.default)(this,"measuringVolumeActivity",!1),(0,ft.default)(this,"audioContext",void 0),(0,ft.default)(this,"analyser",void 0),(0,ft.default)(this,"frequencyBinCount",void 0),(0,ft.default)(this,"speakingThreshold",Yv),(0,ft.default)(this,"speaking",!1),(0,ft.default)(this,"volumeLooperTimeout",void 0),(0,ft.default)(this,"onAddTrack",()=>{this.emit(gn.NewStream,this.stream)}),(0,ft.default)(this,"volumeLooper",()=>{if(!this.analyser||!this.measuringVolumeActivity)return;this.analyser.getFloatFrequencyData(this.frequencyBinCount);let t=-1/0;for(let i=0;i<this.frequencyBinCount.length;i++)this.frequencyBinCount[i]>t&&(t=this.frequencyBinCount[i]);this.speakingVolumeSamples.shift(),this.speakingVolumeSamples.push(t),this.emit(gn.VolumeChanged,t);let r=!1;for(let i=0;i<this.speakingVolumeSamples.length;i++)if(this.speakingVolumeSamples[i]>this.speakingThreshold){r=!0;break}this.speaking!==r&&(this.speaking=r,this.emit(gn.Speaking,this.speaking)),this.volumeLooperTimeout=setTimeout(this.volumeLooper,lk)}),this.client=e.client,this.roomId=e.roomId,this.userId=e.userId,this.purpose=e.purpose,this.audioMuted=e.audioMuted,this.videoMuted=e.videoMuted,this.speakingVolumeSamples=new Array(uk).fill(-1/0),this.updateStream(null,e.stream),this.hasAudioTrack&&this.initVolumeMeasuring()}get hasAudioTrack(){return this.stream.getAudioTracks().length>0}updateStream(e,t){t!==e&&(e&&(e.removeEventListener("addtrack",this.onAddTrack),this.measureVolumeActivity(!1)),t&&(this.stream=t,t.addEventListener("addtrack",this.onAddTrack),this.hasAudioTrack?this.initVolumeMeasuring():this.measureVolumeActivity(!1)),this.emit(gn.NewStream,this.stream))}initVolumeMeasuring(){const e=window.AudioContext||window.webkitAudioContext;if(!this.hasAudioTrack||!e)return;this.audioContext=new e,this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=512,this.analyser.smoothingTimeConstant=.1,this.audioContext.createMediaStreamSource(this.stream).connect(this.analyser),this.frequencyBinCount=new Float32Array(this.analyser.frequencyBinCount)}getMember(){return this.client.getRoom(this.roomId).getMember(this.userId)}isLocal(){return this.userId===this.client.getUserId()}isAudioMuted(){return this.stream.getAudioTracks().length===0||this.audioMuted}isVideoMuted(){return this.stream.getVideoTracks().length===0||this.videoMuted}isSpeaking(){return this.speaking}setNewStream(e){this.updateStream(this.stream,e)}setAudioMuted(e){this.audioMuted=e,this.speakingVolumeSamples.fill(-1/0),this.emit(gn.MuteStateChanged,this.audioMuted,this.videoMuted)}setVideoMuted(e){this.videoMuted=e,this.emit(gn.MuteStateChanged,this.audioMuted,this.videoMuted)}measureVolumeActivity(e){if(e){if(!this.audioContext||!this.analyser||!this.frequencyBinCount||!this.hasAudioTrack)return;this.measuringVolumeActivity=!0,this.volumeLooper()}else this.measuringVolumeActivity=!1,this.speakingVolumeSamples.fill(-1/0),this.emit(gn.VolumeChanged,-1/0)}setSpeakingThreshold(e){this.speakingThreshold=e}dispose(){clearTimeout(this.volumeLooperTimeout)}}Qn.CallFeed=dk;var hk=G.exports;Object.defineProperty(Ce,"__esModule",{value:!0});Ce.MatrixCall=Ce.CallType=Ce.CallState=Ce.CallParty=Ce.CallEvent=Ce.CallErrorCode=Ce.CallError=Ce.CallDirection=void 0;Ce.createNewMatrixCall=yk;var re=hk(Y.exports),F=se,td=pk(W),Or=ie,fk=ai,He=ys,ra=Qn,Rg=je;function zv(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(zv=function(r){return r?t:e})(n)}function pk(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=zv(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}let he;Ce.CallState=he;(function(n){n.Fledgling="fledgling",n.InviteSent="invite_sent",n.WaitLocalMedia="wait_local_media",n.CreateOffer="create_offer",n.CreateAnswer="create_answer",n.Connecting="connecting",n.Connected="connected",n.Ringing="ringing",n.Ended="ended"})(he||(Ce.CallState=he={}));let Ga;Ce.CallType=Ga;(function(n){n.Voice="voice",n.Video="video"})(Ga||(Ce.CallType=Ga={}));let Gn;Ce.CallDirection=Gn;(function(n){n.Inbound="inbound",n.Outbound="outbound"})(Gn||(Ce.CallDirection=Gn={}));let ze;Ce.CallParty=ze;(function(n){n.Local="local",n.Remote="remote"})(ze||(Ce.CallParty=ze={}));let Ae;Ce.CallEvent=Ae;(function(n){n.Hangup="hangup",n.State="state",n.Error="error",n.Replaced="replaced",n.LocalHoldUnhold="local_hold_unhold",n.RemoteHoldUnhold="remote_hold_unhold",n.HoldUnhold="hold_unhold",n.FeedsChanged="feeds_changed",n.AssertedIdentityChanged="asserted_identity_changed",n.LengthChanged="length_changed",n.DataChannel="datachannel"})(Ae||(Ce.CallEvent=Ae={}));let ge;Ce.CallErrorCode=ge;(function(n){n.UserHangup="user_hangup",n.LocalOfferFailed="local_offer_failed",n.NoUserMedia="no_user_media",n.UnknownDevices="unknown_devices",n.SendInvite="send_invite",n.CreateAnswer="create_answer",n.SendAnswer="send_answer",n.SetRemoteDescription="set_remote_description",n.SetLocalDescription="set_local_description",n.AnsweredElsewhere="answered_elsewhere",n.IceFailed="ice_failed",n.InviteTimeout="invite_timeout",n.Replaced="replaced",n.SignallingFailed="signalling_timeout",n.UserBusy="user_busy",n.Transfered="transferred"})(ge||(Ce.CallErrorCode=ge={}));const gk=1,mk="stun:turn.matrix.org",Ig=6e4;class Xi extends Error{constructor(e,t,r){super(t+": "+r);(0,re.default)(this,"code",void 0),this.code=e}}Ce.CallError=Xi;function Vs(){return Date.now().toString()+(0,fk.randomString)(16)}class Jv extends Rg.TypedEventEmitter{constructor(e){super();(0,re.default)(this,"roomId",void 0),(0,re.default)(this,"callId",void 0),(0,re.default)(this,"state",he.Fledgling),(0,re.default)(this,"hangupParty",void 0),(0,re.default)(this,"hangupReason",void 0),(0,re.default)(this,"direction",void 0),(0,re.default)(this,"ourPartyId",void 0),(0,re.default)(this,"client",void 0),(0,re.default)(this,"forceTURN",void 0),(0,re.default)(this,"turnServers",void 0),(0,re.default)(this,"candidateSendQueue",[]),(0,re.default)(this,"candidateSendTries",0),(0,re.default)(this,"sentEndOfCandidates",!1),(0,re.default)(this,"peerConn",void 0),(0,re.default)(this,"feeds",[]),(0,re.default)(this,"usermediaSenders",[]),(0,re.default)(this,"screensharingSenders",[]),(0,re.default)(this,"inviteOrAnswerSent",!1),(0,re.default)(this,"waitForLocalAVStream",void 0),(0,re.default)(this,"successor",void 0),(0,re.default)(this,"opponentMember",void 0),(0,re.default)(this,"opponentVersion",void 0),(0,re.default)(this,"opponentPartyId",void 0),(0,re.default)(this,"opponentCaps",void 0),(0,re.default)(this,"inviteTimeout",void 0),(0,re.default)(this,"remoteOnHold",!1),(0,re.default)(this,"callStatsAtEnd",void 0),(0,re.default)(this,"makingOffer",!1),(0,re.default)(this,"ignoreOffer",void 0),(0,re.default)(this,"remoteCandidateBuffer",new Map),(0,re.default)(this,"remoteAssertedIdentity",void 0),(0,re.default)(this,"remoteSDPStreamMetadata",void 0),(0,re.default)(this,"callLengthInterval",void 0),(0,re.default)(this,"callLength",0),(0,re.default)(this,"gotLocalIceCandidate",t=>{if(t.candidate){if(F.logger.debug("Call "+this.callId+" got local ICE "+t.candidate.sdpMid+" candidate: "+t.candidate.candidate),this.callHasEnded())return;(t.candidate.candidate!==""||!this.sentEndOfCandidates)&&(this.queueCandidate(t.candidate),t.candidate.candidate===""&&(this.sentEndOfCandidates=!0))}}),(0,re.default)(this,"onIceGatheringStateChange",t=>{if(F.logger.debug("ice gathering state changed to "+this.peerConn.iceGatheringState),this.peerConn.iceGatheringState==="complete"&&!this.sentEndOfCandidates){const r={candidate:""};this.queueCandidate(r),this.sentEndOfCandidates=!0}}),(0,re.default)(this,"gotLocalOffer",async t=>{if(F.logger.debug("Created offer: ",t),this.callHasEnded()){F.logger.debug("Ignoring newly created offer on call ID "+this.callId+" because the call has ended");return}try{await this.peerConn.setLocalDescription(t)}catch(s){F.logger.debug("Error setting local description!",s),this.terminate(ze.Local,ge.SetLocalDescription,!0);return}if(this.peerConn.iceGatheringState==="gathering"&&await new Promise(s=>{setTimeout(s,200)}),this.callHasEnded())return;const r=this.state===he.CreateOffer?Or.EventType.CallInvite:Or.EventType.CallNegotiate,i={lifetime:Ig};this.state===he.CreateOffer?i.offer=this.peerConn.localDescription:i.description=this.peerConn.localDescription,i.capabilities={"m.call.transferee":this.client.supportsCallTransfer,"m.call.dtmf":!1},i[He.SDPStreamMetadataKey]=this.getLocalSDPStreamMetadata(),F.logger.info(`Discarding ${this.candidateSendQueue.length} candidates that will be sent in offer`),this.candidateSendQueue=[];try{await this.sendVoipEvent(r,i)}catch(s){F.logger.error("Failed to send invite",s),s.event&&this.client.cancelPendingEvent(s.event);let o=ge.SignallingFailed,a="Signalling failed";this.state===he.CreateOffer&&(o=ge.SendInvite,a="Failed to send invite"),s.name=="UnknownDeviceError"&&(o=ge.UnknownDevices,a="Unknown devices present in the room"),this.emit(Ae.Error,new Xi(o,a,s)),this.terminate(ze.Local,o,!1);return}this.sendCandidateQueue(),this.state===he.CreateOffer&&(this.inviteOrAnswerSent=!0,this.setState(he.InviteSent),this.inviteTimeout=setTimeout(()=>{this.inviteTimeout=null,this.state===he.InviteSent&&this.hangup(ge.InviteTimeout,!1)},Ig))}),(0,re.default)(this,"getLocalOfferFailed",t=>{F.logger.error("Failed to get local offer",t),this.emit(Ae.Error,new Xi(ge.LocalOfferFailed,"Failed to get local offer!",t)),this.terminate(ze.Local,ge.LocalOfferFailed,!1)}),(0,re.default)(this,"getUserMediaFailed",t=>{if(this.successor){this.successor.getUserMediaFailed(t);return}F.logger.warn("Failed to get user media - ending call",t),this.emit(Ae.Error,new Xi(ge.NoUserMedia,"Couldn't start capturing media! Is your microphone set up and does this app have permission?",t)),this.terminate(ze.Local,ge.NoUserMedia,!1)}),(0,re.default)(this,"onIceConnectionStateChanged",()=>{this.callHasEnded()||(F.logger.debug("Call ID "+this.callId+": ICE connection state changed to: "+this.peerConn.iceConnectionState),this.peerConn.iceConnectionState=="connected"?(this.setState(he.Connected),this.callLengthInterval||(this.callLengthInterval=setInterval(()=>{this.callLength++,this.emit(Ae.LengthChanged,this.callLength)},1e3))):this.peerConn.iceConnectionState=="failed"&&this.hangup(ge.IceFailed,!1))}),(0,re.default)(this,"onSignallingStateChanged",()=>{F.logger.debug("call "+this.callId+": Signalling state changed to: "+this.peerConn.signalingState)}),(0,re.default)(this,"onTrack",t=>{if(t.streams.length===0){F.logger.warn(`Streamless ${t.track.kind} found: ignoring.`);return}const r=t.streams[0];this.pushRemoteFeed(r),r.addEventListener("removetrack",()=>{r.getTracks().length===0&&(F.logger.info(`Stream ID ${r.id} has no tracks remaining - removing`),this.deleteFeedByStream(r))})}),(0,re.default)(this,"onDataChannel",t=>{this.emit(Ae.DataChannel,t.channel)}),(0,re.default)(this,"onNegotiationNeeded",async()=>{if(F.logger.info("Negotiation is needed!"),this.state!==he.CreateOffer&&this.opponentVersion===0){F.logger.info("Opponent does not support renegotiation: ignoring negotiationneeded event");return}this.makingOffer=!0;try{this.getRidOfRTXCodecs();const t=await this.peerConn.createOffer();await this.gotLocalOffer(t)}catch(t){this.getLocalOfferFailed(t);return}finally{this.makingOffer=!1}}),(0,re.default)(this,"onHangupReceived",t=>{F.logger.debug("Hangup received for call ID "+this.callId),this.partyIdMatches(t)||this.state===he.Ringing?this.terminate(ze.Remote,t.reason||ge.UserHangup,!0):F.logger.info(`Ignoring message from party ID ${t.party_id}: our partner is ${this.opponentPartyId}`)}),(0,re.default)(this,"onRejectReceived",t=>{F.logger.debug("Reject received for call ID "+this.callId),[he.InviteSent,he.Ringing].includes(this.state)||this.state===he.Fledgling&&this.direction===Gn.Inbound?this.terminate(ze.Remote,t.reason||ge.UserHangup,!0):F.logger.debug(`Call is in state: ${this.state}: ignoring reject`)}),(0,re.default)(this,"onAnsweredElsewhere",t=>{F.logger.debug("Call ID "+this.callId+" answered elsewhere"),this.terminate(ze.Remote,ge.AnsweredElsewhere,!0)}),this.roomId=e.roomId,this.client=e.client,this.forceTURN=e.forceTURN,this.ourPartyId=this.client.deviceId,this.turnServers=e.turnServers||[],this.turnServers.length===0&&this.client.isFallbackICEServerAllowed()&&this.turnServers.push({urls:[mk]});for(const t of this.turnServers)td.checkObjectHasKeys(t,["urls"]);this.callId=Vs()}async placeVoiceCall(){await this.placeCall(!0,!1)}async placeVideoCall(){await this.placeCall(!0,!0)}createDataChannel(e,t){const r=this.peerConn.createDataChannel(e,t);return this.emit(Ae.DataChannel,r),F.logger.debug("created data channel"),r}getOpponentMember(){return this.opponentMember}opponentCanBeTransferred(){return Boolean(this.opponentCaps&&this.opponentCaps["m.call.transferee"])}opponentSupportsDTMF(){return Boolean(this.opponentCaps&&this.opponentCaps["m.call.dtmf"])}getRemoteAssertedIdentity(){return this.remoteAssertedIdentity}get type(){return this.hasLocalUserMediaVideoTrack||this.hasRemoteUserMediaVideoTrack?Ga.Video:Ga.Voice}get hasLocalUserMediaVideoTrack(){var e;return((e=this.localUsermediaStream)===null||e===void 0?void 0:e.getVideoTracks().length)>0}get hasRemoteUserMediaVideoTrack(){return this.getRemoteFeeds().some(e=>e.purpose===He.SDPStreamMetadataPurpose.Usermedia&&e.stream.getVideoTracks().length>0)}get hasLocalUserMediaAudioTrack(){var e;return((e=this.localUsermediaStream)===null||e===void 0?void 0:e.getAudioTracks().length)>0}get hasRemoteUserMediaAudioTrack(){return this.getRemoteFeeds().some(e=>e.purpose===He.SDPStreamMetadataPurpose.Usermedia&&e.stream.getAudioTracks().length>0)}get localUsermediaFeed(){return this.getLocalFeeds().find(e=>e.purpose===He.SDPStreamMetadataPurpose.Usermedia)}get localScreensharingFeed(){return this.getLocalFeeds().find(e=>e.purpose===He.SDPStreamMetadataPurpose.Screenshare)}get localUsermediaStream(){var e;return(e=this.localUsermediaFeed)===null||e===void 0?void 0:e.stream}get localScreensharingStream(){var e;return(e=this.localScreensharingFeed)===null||e===void 0?void 0:e.stream}get remoteUsermediaFeed(){return this.getRemoteFeeds().find(e=>e.purpose===He.SDPStreamMetadataPurpose.Usermedia)}get remoteScreensharingFeed(){return this.getRemoteFeeds().find(e=>e.purpose===He.SDPStreamMetadataPurpose.Screenshare)}get remoteUsermediaStream(){var e;return(e=this.remoteUsermediaFeed)===null||e===void 0?void 0:e.stream}get remoteScreensharingStream(){var e;return(e=this.remoteScreensharingFeed)===null||e===void 0?void 0:e.stream}getFeedByStreamId(e){return this.getFeeds().find(t=>t.stream.id===e)}getFeeds(){return this.feeds}getLocalFeeds(){return this.feeds.filter(e=>e.isLocal())}getRemoteFeeds(){return this.feeds.filter(e=>!e.isLocal())}getLocalSDPStreamMetadata(){const e={};for(const t of this.getLocalFeeds())e[t.stream.id]={purpose:t.purpose,audio_muted:t.isAudioMuted(),video_muted:t.isVideoMuted()};return F.logger.debug("Got local SDPStreamMetadata",e),e}noIncomingFeeds(){return!this.feeds.some(e=>!e.isLocal())}pushRemoteFeed(e){if(!this.opponentSupportsSDPStreamMetadata()){this.pushRemoteFeedWithoutMetadata(e);return}const t=this.getOpponentMember().userId,r=this.remoteSDPStreamMetadata[e.id].purpose,i=this.remoteSDPStreamMetadata[e.id].audio_muted,s=this.remoteSDPStreamMetadata[e.id].video_muted;if(!r){F.logger.warn(`Ignoring stream with id ${e.id} because we didn't get any metadata about it`);return}const o=this.getRemoteFeeds().find(a=>a.purpose===r);o?o.setNewStream(e):(this.feeds.push(new ra.CallFeed({client:this.client,roomId:this.roomId,userId:t,stream:e,purpose:r,audioMuted:i,videoMuted:s})),this.emit(Ae.FeedsChanged,this.feeds)),F.logger.info(`Pushed remote stream (id="${e.id}", active="${e.active}", purpose=${r})`)}pushRemoteFeedWithoutMetadata(e){var t;const r=this.getOpponentMember().userId,i=He.SDPStreamMetadataPurpose.Usermedia,s=(t=this.feeds.find(a=>!a.isLocal()))===null||t===void 0?void 0:t.stream;if(s&&e.id!==s.id){F.logger.warn(`Ignoring new stream ID ${e.id}: we already have stream ID ${s.id}`);return}const o=this.getFeedByStreamId(e.id);o?o.setNewStream(e):(this.feeds.push(new ra.CallFeed({client:this.client,roomId:this.roomId,audioMuted:!1,videoMuted:!1,userId:r,stream:e,purpose:i})),this.emit(Ae.FeedsChanged,this.feeds)),F.logger.info(`Pushed remote stream (id="${e.id}", active="${e.active}")`)}pushNewLocalFeed(e,t,r=!0){const i=this.client.getUserId();bi(e.getAudioTracks(),!0),bi(e.getVideoTracks(),!0);const s=this.getLocalFeeds().find(o=>o.purpose===t);s?s.setNewStream(e):(this.pushLocalFeed(new ra.CallFeed({client:this.client,roomId:this.roomId,audioMuted:!1,videoMuted:!1,userId:i,stream:e,purpose:t}),r),this.emit(Ae.FeedsChanged,this.feeds))}pushLocalFeed(e,t=!0){if(this.feeds.push(e),t){const r=e.purpose===He.SDPStreamMetadataPurpose.Usermedia?this.usermediaSenders:this.screensharingSenders;r.splice(0,r.length);for(const i of e.stream.getTracks())F.logger.info(`Adding track (id="${i.id}", kind="${i.kind}", streamId="${e.stream.id}", streamPurpose="${e.purpose}", enabled=${i.enabled}) to peer connection`),r.push(this.peerConn.addTrack(i,e.stream))}F.logger.info(`Pushed local stream (id="${e.stream.id}", active="${e.stream.active}", purpose="${e.purpose}")`),this.emit(Ae.FeedsChanged,this.feeds)}removeLocalFeed(e){const t=e.purpose===He.SDPStreamMetadataPurpose.Usermedia?this.usermediaSenders:this.screensharingSenders;for(const r of t)this.peerConn.removeTrack(r);t.splice(0,t.length),this.deleteFeedByStream(e.stream)}deleteAllFeeds(){for(const e of this.feeds)e.dispose();this.feeds=[],this.emit(Ae.FeedsChanged,this.feeds)}deleteFeedByStream(e){F.logger.debug(`Removing feed with stream id ${e.id}`);const t=this.getFeedByStreamId(e.id);if(!t){F.logger.warn(`Didn't find the feed with stream id ${e.id} to delete`);return}t.dispose(),this.feeds.splice(this.feeds.indexOf(t),1),this.emit(Ae.FeedsChanged,this.feeds)}async getCurrentCallStats(){return this.callHasEnded()?this.callStatsAtEnd:this.collectCallStats()}async collectCallStats(){if(!this.peerConn)return;const e=await this.peerConn.getStats(),t=[];for(const r of e)t.push(r[1]);return t}async initWithInvite(e){var t;const r=e.getContent();this.direction=Gn.Inbound,await this.client.checkTurnServers()||F.logger.warn("Failed to get TURN credentials! Proceeding with call anyway...");const s=r[He.SDPStreamMetadataKey];s?this.updateRemoteSDPStreamMetadata(s):F.logger.debug("Did not get any SDPStreamMetadata! Can not send/receive multiple streams"),this.peerConn=this.createPeerConnection(),this.chooseOpponent(e);try{await this.peerConn.setRemoteDescription(r.offer),await this.addBufferedIceCandidates()}catch(a){F.logger.debug("Failed to set remote description",a),this.terminate(ze.Local,ge.SetRemoteDescription,!1);return}const o=(t=this.feeds.find(a=>!a.isLocal()))===null||t===void 0?void 0:t.stream;if(!o||o.getTracks().length===0){F.logger.error("No remote stream or no tracks after setting remote description!"),this.terminate(ze.Local,ge.SetRemoteDescription,!1);return}this.setState(he.Ringing),e.getLocalAge()&&setTimeout(()=>{this.state==he.Ringing&&(F.logger.debug("Call invite has expired. Hanging up."),this.hangupParty=ze.Remote,this.setState(he.Ended),this.stopAllMedia(),this.peerConn.signalingState!="closed"&&this.peerConn.close(),this.emit(Ae.Hangup))},r.lifetime-e.getLocalAge())}initWithHangup(e){this.setState(he.Ended)}shouldAnswerWithMediaType(e,t,r){return e&&!t?(F.logger.warn(`Unable to answer with ${r} because the other side isn't sending it either.`),!1):!td.isNullOrUndefined(e)&&e!==t&&!this.opponentSupportsSDPStreamMetadata()?(F.logger.warn(`Unable to answer with ${r}=${e} because the other side doesn't support it. Answering with ${r}=${t}.`),t):e!=null?e:t}async answer(e,t){if(!this.inviteOrAnswerSent){if(e===!1&&t===!1)throw new Error("You CANNOT answer a call without media");if(F.logger.debug(`Answering call ${this.callId}`),!this.localUsermediaStream&&!this.waitForLocalAVStream){const r=this.state,i=this.shouldAnswerWithMediaType(e,this.hasRemoteUserMediaAudioTrack,"audio"),s=this.shouldAnswerWithMediaType(t,this.hasRemoteUserMediaVideoTrack,"video");this.setState(he.WaitLocalMedia),this.waitForLocalAVStream=!0;try{const o=await this.client.getMediaHandler().getUserMediaStream(i,s);this.waitForLocalAVStream=!1;const l=[new ra.CallFeed({client:this.client,roomId:this.roomId,userId:this.client.getUserId(),stream:o,purpose:He.SDPStreamMetadataPurpose.Usermedia,audioMuted:!1,videoMuted:!1})];this.localScreensharingFeed&&l.push(this.localScreensharingFeed),this.answerWithCallFeeds(l)}catch(o){if(s)F.logger.warn("Failed to getUserMedia(), trying to getUserMedia() without video"),this.setState(r),this.waitForLocalAVStream=!1,await this.answer(i,!1);else{this.getUserMediaFailed(o);return}}}else this.waitForLocalAVStream&&this.setState(he.WaitLocalMedia)}}answerWithCallFeeds(e){this.inviteOrAnswerSent||(F.logger.debug(`Answering call ${this.callId}`),this.gotCallFeedsForAnswer(e))}replacedBy(e){this.state===he.WaitLocalMedia?(F.logger.debug("Telling new call to wait for local media"),e.waitForLocalAVStream=!0):[he.CreateOffer,he.InviteSent].includes(this.state)&&(F.logger.debug("Handing local stream to new call"),e.gotCallFeedsForAnswer(this.getLocalFeeds())),this.successor=e,this.emit(Ae.Replaced,e),this.hangup(ge.Replaced,!0)}hangup(e,t){if(this.callHasEnded()||(F.logger.debug("Ending call "+this.callId),this.terminate(ze.Local,e,!t),this.state===he.WaitLocalMedia))return;const r={};(this.opponentVersion&&this.opponentVersion>=1||e!==ge.UserHangup)&&(r.reason=e),this.sendVoipEvent(Or.EventType.CallHangup,r)}reject(){if(this.state!==he.Ringing)throw Error("Call must be in 'ringing' state to reject!");if(this.opponentVersion<1){F.logger.info(`Opponent version is less than 1 (${this.opponentVersion}): sending hangup instead of reject`),this.hangup(ge.UserHangup,!0);return}F.logger.debug("Rejecting call: "+this.callId),this.terminate(ze.Local,ge.UserHangup,!0),this.sendVoipEvent(Or.EventType.CallReject,{})}async upgradeCall(e,t){if(!(!e&&!t)&&!!this.opponentSupportsSDPStreamMetadata())try{const r=e||this.hasLocalUserMediaAudioTrack,i=t||this.hasLocalUserMediaVideoTrack,s=await this.client.getMediaHandler().getUserMediaStream(r,i,!1);await this.updateLocalUsermediaStream(s,e,t)}catch(r){F.logger.error("Failed to upgrade the call",r),this.emit(Ae.Error,new Xi(ge.NoUserMedia,"Failed to get camera access: ",r))}}opponentSupportsSDPStreamMetadata(){return Boolean(this.remoteSDPStreamMetadata)}isScreensharing(){return Boolean(this.localScreensharingStream)}async setScreensharingEnabled(e,t){if(e&&this.isScreensharing())return F.logger.warn("There is already a screensharing stream - there is nothing to do!"),!0;if(!e&&!this.isScreensharing())return F.logger.warn("There already isn't a screensharing stream - there is nothing to do!"),!1;if(!this.opponentSupportsSDPStreamMetadata())return await this.setScreensharingEnabledWithoutMetadataSupport(e,t);if(F.logger.debug(`Set screensharing enabled? ${e}`),e)try{const r=await this.client.getMediaHandler().getScreensharingStream(t);return r?(this.pushNewLocalFeed(r,He.SDPStreamMetadataPurpose.Screenshare),!0):!1}catch(r){return F.logger.error("Failed to get screen-sharing stream:",r),!1}else{for(const r of this.screensharingSenders)this.peerConn.removeTrack(r);return this.client.getMediaHandler().stopScreensharingStream(this.localScreensharingStream),this.deleteFeedByStream(this.localScreensharingStream),!1}}async setScreensharingEnabledWithoutMetadataSupport(e,t){if(F.logger.debug(`Set screensharing enabled? ${e} using replaceTrack()`),e)try{const r=await this.client.getMediaHandler().getScreensharingStream(t);if(!r)return!1;const i=r.getTracks().find(o=>o.kind==="video");return this.usermediaSenders.find(o=>{var a;return((a=o.track)===null||a===void 0?void 0:a.kind)==="video"}).replaceTrack(i),this.pushNewLocalFeed(r,He.SDPStreamMetadataPurpose.Screenshare,!1),!0}catch(r){return F.logger.error("Failed to get screen-sharing stream:",r),!1}else{const r=this.localUsermediaStream.getTracks().find(s=>s.kind==="video");return this.usermediaSenders.find(s=>{var o;return((o=s.track)===null||o===void 0?void 0:o.kind)==="video"}).replaceTrack(r),this.client.getMediaHandler().stopScreensharingStream(this.localScreensharingStream),this.deleteFeedByStream(this.localScreensharingStream),!1}}async updateLocalUsermediaStream(e,t=!1,r=!1){const i=this.localUsermediaFeed,s=t||!i.isAudioMuted()&&!this.remoteOnHold,o=r||!i.isVideoMuted()&&!this.remoteOnHold;bi(e.getAudioTracks(),s),bi(e.getVideoTracks(),o);for(const l of this.localUsermediaStream.getTracks())this.localUsermediaStream.removeTrack(l),l.stop();for(const l of e.getTracks())this.localUsermediaStream.addTrack(l);const a=[];for(const l of e.getTracks()){const u=this.usermediaSenders.find(g=>{var m;return((m=g.track)===null||m===void 0?void 0:m.kind)===l.kind});let c;u?(F.logger.info(`Replacing track (id="${l.id}", kind="${l.kind}", streamId="${e.id}", streamPurpose="${i.purpose}") to peer connection`),await u.replaceTrack(l),c=u):(F.logger.info(`Adding track (id="${l.id}", kind="${l.kind}", streamId="${e.id}", streamPurpose="${i.purpose}") to peer connection`),c=this.peerConn.addTrack(l,this.localUsermediaStream)),a.push(c)}this.usermediaSenders=a}async setLocalVideoMuted(e){var t;return await this.client.getMediaHandler().hasVideoDevice()?!this.hasLocalUserMediaVideoTrack&&!e?(await this.upgradeCall(!1,!0),this.isLocalVideoMuted()):((t=this.localUsermediaFeed)===null||t===void 0||t.setVideoMuted(e),this.updateMuteStatus(),this.isLocalVideoMuted()):this.isLocalVideoMuted()}isLocalVideoMuted(){var e;return(e=this.localUsermediaFeed)===null||e===void 0?void 0:e.isVideoMuted()}async setMicrophoneMuted(e){var t;return await this.client.getMediaHandler().hasAudioDevice()?!this.hasLocalUserMediaAudioTrack&&!e?(await this.upgradeCall(!0,!1),this.isMicrophoneMuted()):((t=this.localUsermediaFeed)===null||t===void 0||t.setAudioMuted(e),this.updateMuteStatus(),this.isMicrophoneMuted()):this.isMicrophoneMuted()}isMicrophoneMuted(){var e;return(e=this.localUsermediaFeed)===null||e===void 0?void 0:e.isAudioMuted()}isRemoteOnHold(){return this.remoteOnHold}setRemoteOnHold(e){if(this.isRemoteOnHold()!==e){this.remoteOnHold=e;for(const t of this.peerConn.getTransceivers())t.direction=e?"sendonly":"sendrecv";this.updateMuteStatus(),this.emit(Ae.RemoteHoldUnhold,this.remoteOnHold)}}isLocalOnHold(){if(this.state!==he.Connected)return!1;let e=!0;for(const t of this.peerConn.getTransceivers())["inactive","recvonly"].includes(t.currentDirection)||(e=!1);return e}sendDtmfDigit(e){for(const t of this.peerConn.getSenders())if(t.track.kind==="audio"&&t.dtmf){t.dtmf.insertDTMF(e);return}throw new Error("Unable to find a track to send DTMF on")}updateMuteStatus(){this.sendVoipEvent(Or.EventType.CallSDPStreamMetadataChangedPrefix,{[He.SDPStreamMetadataKey]:this.getLocalSDPStreamMetadata()});const e=this.isMicrophoneMuted()||this.remoteOnHold,t=this.isLocalVideoMuted()||this.remoteOnHold;bi(this.localUsermediaStream.getAudioTracks(),!e),bi(this.localUsermediaStream.getVideoTracks(),!t)}gotCallFeedsForInvite(e){if(this.successor){this.successor.gotCallFeedsForAnswer(e);return}if(this.callHasEnded()){this.stopAllMedia();return}for(const t of e)this.pushLocalFeed(t);this.setState(he.CreateOffer),F.logger.debug("gotUserMediaForInvite")}async sendAnswer(){const e={answer:{sdp:this.peerConn.localDescription.sdp,type:this.peerConn.localDescription.type},[He.SDPStreamMetadataKey]:this.getLocalSDPStreamMetadata()};e.capabilities={"m.call.transferee":this.client.supportsCallTransfer,"m.call.dtmf":!1},F.logger.info(`Discarding ${this.candidateSendQueue.length} candidates that will be sent in answer`),this.candidateSendQueue=[];try{await this.sendVoipEvent(Or.EventType.CallAnswer,e),this.inviteOrAnswerSent=!0}catch(t){this.setState(he.Ringing),this.client.cancelPendingEvent(t.event);let r=ge.SendAnswer,i="Failed to send answer";throw t.name=="UnknownDeviceError"&&(r=ge.UnknownDevices,i="Unknown devices present in the room"),this.emit(Ae.Error,new Xi(r,i,t)),t}this.sendCandidateQueue()}async gotCallFeedsForAnswer(e){if(this.callHasEnded())return;this.waitForLocalAVStream=!1;for(const r of e)this.pushLocalFeed(r);this.setState(he.CreateAnswer);let t;try{this.getRidOfRTXCodecs(),t=await this.peerConn.createAnswer()}catch(r){F.logger.debug("Failed to create answer: ",r),this.terminate(ze.Local,ge.CreateAnswer,!0);return}try{await this.peerConn.setLocalDescription(t),this.setState(he.Connecting),await new Promise(r=>{setTimeout(r,200)}),this.sendAnswer()}catch(r){F.logger.debug("Error setting local description!",r),this.terminate(ze.Local,ge.SetLocalDescription,!0);return}}async onRemoteIceCandidatesReceived(e){if(this.callHasEnded())return;const t=e.getContent(),r=t.candidates;if(!r){F.logger.info("Ignoring candidates event with no candidates!");return}const i=t.version===0?null:t.party_id||null;if(this.opponentPartyId===void 0){F.logger.info(`Buffering ${r.length} candidates until we pick an opponent`);const s=this.remoteCandidateBuffer.get(i)||[];s.push(...r),this.remoteCandidateBuffer.set(i,s);return}if(!this.partyIdMatches(t)){F.logger.info(`Ignoring candidates from party ID ${t.party_id}: we have chosen party ID ${this.opponentPartyId}`);return}await this.addIceCandidates(r)}async onAnswerReceived(e){const t=e.getContent();if(F.logger.debug(`Got answer for call ID ${this.callId} from party ID ${t.party_id}`),this.callHasEnded()){F.logger.debug(`Ignoring answer because call ID ${this.callId} has ended`);return}if(this.opponentPartyId!==void 0){F.logger.info(`Ignoring answer from party ID ${t.party_id}: we already have an answer/reject from ${this.opponentPartyId}`);return}this.chooseOpponent(e),await this.addBufferedIceCandidates(),this.setState(he.Connecting);const r=t[He.SDPStreamMetadataKey];r?this.updateRemoteSDPStreamMetadata(r):F.logger.warn("Did not get any SDPStreamMetadata! Can not send/receive multiple streams");try{await this.peerConn.setRemoteDescription(t.answer)}catch(i){F.logger.debug("Failed to set remote description",i),this.terminate(ze.Local,ge.SetRemoteDescription,!1);return}if(this.opponentPartyId!==null)try{await this.sendVoipEvent(Or.EventType.CallSelectAnswer,{selected_party_id:this.opponentPartyId})}catch(i){F.logger.warn("Failed to send select_answer event",i)}}async onSelectAnswerReceived(e){if(this.direction!==Gn.Inbound){F.logger.warn("Got select_answer for an outbound call: ignoring");return}const t=e.getContent().selected_party_id;if(t==null){F.logger.warn("Got nonsensical select_answer with null/undefined selected_party_id: ignoring");return}t!==this.ourPartyId&&(F.logger.info(`Got select_answer for party ID ${t}: we are party ID ${this.ourPartyId}.`),this.terminate(ze.Remote,ge.AnsweredElsewhere,!0))}async onNegotiateReceived(e){const t=e.getContent(),r=t.description;if(!r||!r.sdp||!r.type){F.logger.info("Ignoring invalid m.call.negotiate event");return}const i=this.direction===Gn.Inbound,s=r.type==="offer"&&(this.makingOffer||this.peerConn.signalingState!=="stable");if(this.ignoreOffer=!i&&s,this.ignoreOffer){F.logger.info("Ignoring colliding negotiate event because we're impolite");return}const o=this.isLocalOnHold(),a=t[He.SDPStreamMetadataKey];a?this.updateRemoteSDPStreamMetadata(a):F.logger.warn("Received negotiation event without SDPStreamMetadata!");try{if(await this.peerConn.setRemoteDescription(r),r.type==="offer"){this.getRidOfRTXCodecs();const u=await this.peerConn.createAnswer();await this.peerConn.setLocalDescription(u),this.sendVoipEvent(Or.EventType.CallNegotiate,{description:this.peerConn.localDescription,[He.SDPStreamMetadataKey]:this.getLocalSDPStreamMetadata()})}}catch(u){F.logger.warn("Failed to complete negotiation",u)}const l=this.isLocalOnHold();o!==l&&(this.emit(Ae.LocalHoldUnhold,l),this.emit(Ae.HoldUnhold,l))}updateRemoteSDPStreamMetadata(e){this.remoteSDPStreamMetadata=td.recursivelyAssign(this.remoteSDPStreamMetadata||{},e,!0);for(const s of this.getRemoteFeeds()){var t,r,i;const o=s.stream.id;s.setAudioMuted((t=this.remoteSDPStreamMetadata[o])===null||t===void 0?void 0:t.audio_muted),s.setVideoMuted((r=this.remoteSDPStreamMetadata[o])===null||r===void 0?void 0:r.video_muted),s.purpose=(i=this.remoteSDPStreamMetadata[o])===null||i===void 0?void 0:i.purpose}}onSDPStreamMetadataChangedReceived(e){const r=e.getContent()[He.SDPStreamMetadataKey];this.updateRemoteSDPStreamMetadata(r)}async onAssertedIdentityReceived(e){const t=e.getContent();!t.asserted_identity||(this.remoteAssertedIdentity={id:t.asserted_identity.id,displayName:t.asserted_identity.display_name},this.emit(Ae.AssertedIdentityChanged))}callHasEnded(){return this.state===he.Ended}getRidOfRTXCodecs(){if(!RTCRtpReceiver.getCapabilities||!RTCRtpSender.getCapabilities)return;const e=RTCRtpReceiver.getCapabilities("video").codecs,r=[...RTCRtpSender.getCapabilities("video").codecs,...e];for(const o of r)if(o.mimeType==="video/rtx"){const a=r.indexOf(o);r.splice(a,1)}for(const o of this.peerConn.getTransceivers()){var i,s;this.screensharingSenders.includes(o.sender)&&(((i=o.sender.track)===null||i===void 0?void 0:i.kind)==="video"||((s=o.receiver.track)===null||s===void 0?void 0:s.kind)==="video")&&o.setCodecPreferences(r)}}setState(e){const t=this.state;this.state=e,this.emit(Ae.State,e,t)}sendVoipEvent(e,t){return this.client.sendEvent(this.roomId,e,Object.assign({},t,{version:gk,call_id:this.callId,party_id:this.ourPartyId}))}queueCandidate(e){if(this.candidateSendQueue.push(e),this.state===he.Ringing||!this.inviteOrAnswerSent)return;const t=this.direction===Gn.Inbound?500:2e3;this.candidateSendTries===0&&setTimeout(()=>{this.sendCandidateQueue()},t)}async transfer(e){const t=await this.client.getProfileInfo(e),r=Vs(),i={replacement_id:Vs(),target_user:{id:e,display_name:t.displayname,avatar_url:t.avatar_url},create_call:r};await this.sendVoipEvent(Or.EventType.CallReplaces,i),await this.terminate(ze.Local,ge.Transfered,!0)}async transferToCall(e){const t=await this.client.getProfileInfo(e.getOpponentMember().userId),r=await this.client.getProfileInfo(this.getOpponentMember().userId),i=Vs(),s={replacement_id:Vs(),target_user:{id:this.getOpponentMember().userId,display_name:r.displayname,avatar_url:r.avatar_url},await_call:i};await e.sendVoipEvent(Or.EventType.CallReplaces,s);const o={replacement_id:Vs(),target_user:{id:e.getOpponentMember().userId,display_name:t.displayname,avatar_url:t.avatar_url},create_call:i};await this.sendVoipEvent(Or.EventType.CallReplaces,o),await this.terminate(ze.Local,ge.Transfered,!0),await e.terminate(ze.Local,ge.Transfered,!0)}async terminate(e,t,r){this.callHasEnded()||(this.callStatsAtEnd=await this.collectCallStats(),this.inviteTimeout&&(clearTimeout(this.inviteTimeout),this.inviteTimeout=null),this.callLengthInterval&&(clearInterval(this.callLengthInterval),this.callLengthInterval=null),t!==ge.Replaced&&this.stopAllMedia(),this.deleteAllFeeds(),this.hangupParty=e,this.hangupReason=t,this.setState(he.Ended),this.peerConn&&this.peerConn.signalingState!=="closed"&&this.peerConn.close(),r&&this.emit(Ae.Hangup))}stopAllMedia(){F.logger.debug("Stopping all media for call",this.callId);for(const e of this.feeds)if(e.isLocal()&&e.purpose===He.SDPStreamMetadataPurpose.Usermedia)this.client.getMediaHandler().stopUserMediaStream(e.stream);else if(e.isLocal()&&e.purpose===He.SDPStreamMetadataPurpose.Screenshare)this.client.getMediaHandler().stopScreensharingStream(e.stream);else{F.logger.debug("Stopping remote stream",e.stream.id);for(const t of e.stream.getTracks())t.stop()}}checkForErrorListener(){if(this.listeners(Rg.EventEmitterEvents.Error).length===0)throw new Error("You MUST attach an error listener using call.on('error', function() {})")}async sendCandidateQueue(){if(this.candidateSendQueue.length===0)return;const e=this.candidateSendQueue;this.candidateSendQueue=[],++this.candidateSendTries;const t={candidates:e};F.logger.debug("Attempting to send "+e.length+" candidates");try{await this.sendVoipEvent(Or.EventType.CallCandidates,t),this.candidateSendTries=0}catch(r){if(r.event&&this.client.cancelPendingEvent(r.event),this.candidateSendQueue.push(...e),this.candidateSendTries>5){F.logger.debug("Failed to send candidates on attempt "+this.candidateSendTries+". Giving up on this call.",r);const s=ge.SignallingFailed,o="Signalling failed";this.emit(Ae.Error,new Xi(s,o,r)),this.hangup(s,!1);return}const i=500*Math.pow(2,this.candidateSendTries);++this.candidateSendTries,F.logger.debug("Failed to send candidates. Retrying in "+i+"ms",r),setTimeout(()=>{this.sendCandidateQueue()},i)}}async placeCall(e,t){if(!e)throw new Error("You CANNOT start a call without audio");this.setState(he.WaitLocalMedia);try{const r=await this.client.getMediaHandler().getUserMediaStream(e,t);bi(r.getAudioTracks(),!0),bi(r.getVideoTracks(),!0);const i=new ra.CallFeed({client:this.client,roomId:this.roomId,userId:this.client.getUserId(),stream:r,purpose:He.SDPStreamMetadataPurpose.Usermedia,audioMuted:!1,videoMuted:!1});await this.placeCallWithCallFeeds([i])}catch(r){this.getUserMediaFailed(r);return}}async placeCallWithCallFeeds(e){this.checkForErrorListener(),this.direction=Gn.Outbound,this.client.callEventHandler.calls.set(this.callId,this),await this.client.checkTurnServers()||F.logger.warn("Failed to get TURN credentials! Proceeding with call anyway..."),this.peerConn=this.createPeerConnection(),this.gotCallFeedsForInvite(e)}createPeerConnection(){const e=new window.RTCPeerConnection({iceTransportPolicy:this.forceTURN?"relay":void 0,iceServers:this.turnServers,iceCandidatePoolSize:this.client.iceCandidatePoolSize});return e.addEventListener("iceconnectionstatechange",this.onIceConnectionStateChanged),e.addEventListener("signalingstatechange",this.onSignallingStateChanged),e.addEventListener("icecandidate",this.gotLocalIceCandidate),e.addEventListener("icegatheringstatechange",this.onIceGatheringStateChange),e.addEventListener("track",this.onTrack),e.addEventListener("negotiationneeded",this.onNegotiationNeeded),e.addEventListener("datachannel",this.onDataChannel),e}partyIdMatches(e){return(e.version===0?null:e.party_id||null)===this.opponentPartyId}chooseOpponent(e){const t=e.getContent();F.logger.debug(`Choosing party ID ${t.party_id} for call ID ${this.callId}`),this.opponentVersion=t.version,this.opponentVersion===0?this.opponentPartyId=null:this.opponentPartyId=t.party_id||null,this.opponentCaps=t.capabilities||{},this.opponentMember=e.sender}async addBufferedIceCandidates(){const e=this.remoteCandidateBuffer.get(this.opponentPartyId);e&&(F.logger.info(`Adding ${e.length} buffered candidates for opponent ${this.opponentPartyId}`),await this.addIceCandidates(e)),this.remoteCandidateBuffer=null}async addIceCandidates(e){for(const t of e){if((t.sdpMid===null||t.sdpMid===void 0)&&(t.sdpMLineIndex===null||t.sdpMLineIndex===void 0)){F.logger.debug("Ignoring remote ICE candidate with no sdpMid or sdpMLineIndex");continue}F.logger.debug("Call "+this.callId+" got remote ICE "+t.sdpMid+" candidate: "+t.candidate);try{await this.peerConn.addIceCandidate(t)}catch(r){this.ignoreOffer||F.logger.info("Failed to add remote ICE candidate",r)}}}get hasPeerConnection(){return Boolean(this.peerConn)}}Ce.MatrixCall=Jv;function bi(n,e){for(let t=0;t<n.length;t++)n[t].enabled=e}function yk(n,e,t){if(typeof window=="undefined"||typeof document=="undefined")return null;try{if(!Boolean(window.RTCPeerConnection||window.RTCSessionDescription||window.RTCIceCandidate||navigator.mediaDevices))return F.logger.error("WebRTC is not supported in this browser / environment"),null}catch(o){return F.logger.error("Exception thrown when trying to access WebRTC",o),null}const r=t?t.forceTURN:!1,i={client:n,roomId:e,turnServers:n.getTurnServers(),forceTURN:n.forceTURN||r},s=new Jv(i);return n.reEmitter.reEmit(s,Object.values(Ae)),s}var vs={},vk=G.exports;Object.defineProperty(vs,"__esModule",{value:!0});vs.CallEventHandlerEvent=vs.CallEventHandler=void 0;var Gs=vk(Y.exports),_k=jt,wi=se,pr=Ce,Ut=ie,Tg=st,Ek=$i,Og=lr;const Sk=3e3;let Ol;vs.CallEventHandlerEvent=Ol;(function(n){n.Incoming="Call.incoming"})(Ol||(vs.CallEventHandlerEvent=Ol={}));class bk{constructor(e){(0,Gs.default)(this,"client",void 0),(0,Gs.default)(this,"calls",void 0),(0,Gs.default)(this,"callEventBuffer",void 0),(0,Gs.default)(this,"candidateEventsByCall",void 0),(0,Gs.default)(this,"evaluateEventBuffer",async()=>{if(this.client.getSyncState()===Ek.SyncState.Syncing){await Promise.all(this.callEventBuffer.map(r=>{this.client.decryptEventIfNeeded(r)}));const t=new Set;for(const r of this.callEventBuffer)(r.getType()===Ut.EventType.CallAnswer||r.getType()===Ut.EventType.CallHangup)&&t.add(r.getContent().call_id);for(const r of this.callEventBuffer)if(!(r.getType()===Ut.EventType.CallInvite&&t.has(r.getContent().call_id)))try{await this.handleCallEvent(r)}catch(i){wi.logger.error("Caught exception handling call event",i)}this.callEventBuffer=[]}}),(0,Gs.default)(this,"onRoomTimeline",t=>{this.client.decryptEventIfNeeded(t),(this.eventIsACall(t)||t.isBeingDecrypted())&&this.callEventBuffer.push(t),(t.isBeingDecrypted()||t.isDecryptionFailure())&&t.once(_k.MatrixEventEvent.Decrypted,async()=>{if(!!this.eventIsACall(t))if(this.callEventBuffer.includes(t))this.evaluateEventBuffer();else try{await this.handleCallEvent(t)}catch(r){wi.logger.error("Caught exception handling call event",r)}})}),this.client=e,this.calls=new Map,this.callEventBuffer=[],this.candidateEventsByCall=new Map}start(){this.client.on(Tg.ClientEvent.Sync,this.evaluateEventBuffer),this.client.on(Og.RoomEvent.Timeline,this.onRoomTimeline)}stop(){this.client.removeListener(Tg.ClientEvent.Sync,this.evaluateEventBuffer),this.client.removeListener(Og.RoomEvent.Timeline,this.onRoomTimeline)}eventIsACall(e){const t=e.getType();return t.startsWith("m.call.")||t.startsWith("org.matrix.call.")}async handleCallEvent(e){const t=e.getContent(),r=e.getType(),i=e.getSender()===this.client.credentials.userId;let s=t.call_id?this.calls.get(t.call_id):void 0;if(r===Ut.EventType.CallInvite){if(i||e.getLocalAge()>t.lifetime-Sk||s&&s.state===pr.CallState.Ended)return;s&&wi.logger.log(`WARN: Already have a MatrixCall with id ${t.call_id} but got an invite. Clobbering.`);const o=this.client.getTurnServersExpiry()-Date.now();if(wi.logger.info("Current turn creds expire in "+o+" ms"),s=(0,pr.createNewMatrixCall)(this.client,e.getRoomId(),{forceTURN:this.client.forceTURN}),!s){wi.logger.log("Incoming call ID "+t.call_id+" but this client doesn't support WebRTC");return}if(s.callId=t.call_id,await s.initWithInvite(e),this.calls.set(s.callId,s),this.candidateEventsByCall.get(s.callId))for(const l of this.candidateEventsByCall.get(s.callId))s.onRemoteIceCandidatesReceived(l);let a;for(const l of this.calls.values()){const u=[pr.CallState.WaitLocalMedia,pr.CallState.CreateOffer,pr.CallState.InviteSent].includes(l.state);if(s.roomId===l.roomId&&l.direction===pr.CallDirection.Outbound&&u){a=l;break}}a?a.state===pr.CallState.WaitLocalMedia||a.state===pr.CallState.CreateOffer||a.callId>s.callId?(wi.logger.log("Glare detected: answering incoming call "+s.callId+" and canceling outgoing call "+a.callId),a.replacedBy(s),s.answer()):(wi.logger.log("Glare detected: rejecting incoming call "+s.callId+" and keeping outgoing call "+a.callId),s.hangup(pr.CallErrorCode.Replaced,!0)):this.client.emit(Ol.Incoming,s);return}else if(r===Ut.EventType.CallCandidates){if(i)return;s?s.onRemoteIceCandidatesReceived(e):(this.candidateEventsByCall.has(t.call_id)||this.candidateEventsByCall.set(t.call_id,[]),this.candidateEventsByCall.get(t.call_id).push(e));return}else if([Ut.EventType.CallHangup,Ut.EventType.CallReject].includes(r)){s?s.state!==pr.CallState.Ended&&(r===Ut.EventType.CallHangup?s.onHangupReceived(t):s.onRejectReceived(t),s.state===pr.CallState.Ended&&this.calls.delete(t.call_id)):(s=(0,pr.createNewMatrixCall)(this.client,e.getRoomId()),s&&(s.callId=t.call_id,s.initWithHangup(e),this.calls.set(t.call_id,s)));return}if(!s||!s.hasPeerConnection){wi.logger.warn("Discarding an event, we don't have a call/peerConn",r);return}if(e.getContent().party_id!==s.ourPartyId)switch(r){case Ut.EventType.CallAnswer:i?s.state===pr.CallState.Ringing&&s.onAnsweredElsewhere(t):s.onAnswerReceived(e);break;case Ut.EventType.CallSelectAnswer:s.onSelectAnswerReceived(e);break;case Ut.EventType.CallNegotiate:s.onNegotiateReceived(e);break;case Ut.EventType.CallAssertedIdentity:case Ut.EventType.CallAssertedIdentityPrefix:s.onAssertedIdentityReceived(e);break;case Ut.EventType.CallSDPStreamMetadataChanged:case Ut.EventType.CallSDPStreamMetadataChangedPrefix:s.onSDPStreamMetadataChangedReceived(e);break}}}vs.CallEventHandler=bk;var Ni={},wk=G.exports;Object.defineProperty(Ni,"__esModule",{value:!0});Ni.AutoDiscoveryAction=Ni.AutoDiscovery=void 0;var ur=wk(Y.exports),kg=Ci,Un=se;let ar;Ni.AutoDiscoveryAction=ar;(function(n){n.SUCCESS="SUCCESS",n.IGNORE="IGNORE",n.PROMPT="PROMPT",n.FAIL_PROMPT="FAIL_PROMPT",n.FAIL_ERROR="FAIL_ERROR"})(ar||(Ni.AutoDiscoveryAction=ar={}));class Z{static async fromDiscoveryConfig(e){const t={"m.homeserver":{state:Z.FAIL_ERROR,error:Z.ERROR_INVALID,base_url:null},"m.identity_server":{state:Z.PROMPT,error:null,base_url:null}};if(!e||!e["m.homeserver"])return Un.logger.error("No m.homeserver key in config"),t["m.homeserver"].state=Z.FAIL_PROMPT,t["m.homeserver"].error=Z.ERROR_INVALID,Promise.resolve(t);if(!e["m.homeserver"].base_url)return Un.logger.error("No m.homeserver base_url in config"),t["m.homeserver"].state=Z.FAIL_PROMPT,t["m.homeserver"].error=Z.ERROR_INVALID_HS_BASE_URL,Promise.resolve(t);const r=this.sanitizeWellKnownUrl(e["m.homeserver"].base_url);if(!r)return Un.logger.error("Invalid base_url for m.homeserver"),t["m.homeserver"].error=Z.ERROR_INVALID_HS_BASE_URL,Promise.resolve(t);const i=await this.fetchWellKnownObject(`${r}/_matrix/client/versions`);if(!i||!i.raw.versions)return Un.logger.error("Invalid /versions response"),t["m.homeserver"].error=Z.ERROR_INVALID_HOMESERVER,t["m.homeserver"].base_url=r,Promise.resolve(t);t["m.homeserver"]={state:Z.SUCCESS,error:null,base_url:r};let s="";if(e["m.identity_server"]){const o={"m.homeserver":t["m.homeserver"],"m.identity_server":{state:Z.FAIL_PROMPT,error:Z.ERROR_INVALID_IS,base_url:null}};if(s=this.sanitizeWellKnownUrl(e["m.identity_server"].base_url),!s)return Un.logger.error("Invalid base_url for m.identity_server"),o["m.identity_server"].error=Z.ERROR_INVALID_IS_BASE_URL,Promise.resolve(o);const a=await this.fetchWellKnownObject(`${s}/_matrix/identity/api/v1`);if(!a||!a.raw||a.action!==ar.SUCCESS)return Un.logger.error("Invalid /api/v1 response"),o["m.identity_server"].error=Z.ERROR_INVALID_IDENTITY_SERVER,o["m.identity_server"].base_url=s,Promise.resolve(o)}return s&&s.toString().length>0&&(t["m.identity_server"]={state:Z.SUCCESS,error:null,base_url:s}),Object.keys(e).map(o=>{if(o==="m.homeserver"||o==="m.identity_server"){const a=["error","state","base_url"];for(const l of Object.keys(e[o]))a.includes(l)||(t[o][l]=e[o][l])}else t[o]=e[o]}),Promise.resolve(t)}static async findClientConfig(e){if(!e||typeof e!="string"||e.length===0)throw new Error("'domain' must be a string of non-zero length");const t={"m.homeserver":{state:Z.FAIL_ERROR,error:Z.ERROR_INVALID,base_url:null},"m.identity_server":{state:Z.PROMPT,error:null,base_url:null}},r=await this.fetchWellKnownObject(`https://${e}/.well-known/matrix/client`);return!r||r.action!==ar.SUCCESS?(Un.logger.error("No response or error when parsing .well-known"),r.reason&&Un.logger.error(r.reason),r.action===ar.IGNORE?t["m.homeserver"]={state:Z.PROMPT,error:null,base_url:null}:(t["m.homeserver"].state=Z.FAIL_PROMPT,t["m.homeserver"].error=Z.ERROR_INVALID),Promise.resolve(t)):Z.fromDiscoveryConfig(r.raw)}static async getRawClientConfig(e){if(!e||typeof e!="string"||e.length===0)throw new Error("'domain' must be a string of non-zero length");const t=await this.fetchWellKnownObject(`https://${e}/.well-known/matrix/client`);return t?t.raw||{}:{}}static sanitizeWellKnownUrl(e){if(!e)return!1;try{let t=null;try{kg.URL?t=new kg.URL(e):t=new URL(e)}catch{t=new URL(e)}if(!t||!t.hostname||t.protocol!=="http:"&&t.protocol!=="https:")return!1;const r=t.port?`:${t.port}`:"",i=t.pathname?t.pathname:"";let s=`${t.protocol}//${t.hostname}${r}${i}`;return s.endsWith("/")&&(s=s.substring(0,s.length-1)),s}catch(t){return Un.logger.error(t),!1}}static async fetchWellKnownObject(e){return new Promise(function(t,r){const i=Cs.getRequest();if(!i)throw new Error("No request library available");i({method:"GET",uri:e,timeout:5e3},(s,o,a)=>{if(s||o&&(o.statusCode<200||o.statusCode>=300)){let l=ar.FAIL_PROMPT,u=(s?s.message:null)||"General failure";o&&o.statusCode===404&&(l=ar.IGNORE,u=Z.ERROR_MISSING_WELLKNOWN),t({raw:{},action:l,reason:u,error:s});return}try{t({raw:JSON.parse(a),action:ar.SUCCESS})}catch(l){let u=Z.ERROR_INVALID;l.name==="SyntaxError"&&(u=Z.ERROR_INVALID_JSON),t({raw:{},action:ar.FAIL_PROMPT,reason:u,error:l})}})})}}Ni.AutoDiscovery=Z;(0,ur.default)(Z,"ERROR_INVALID","Invalid homeserver discovery response");(0,ur.default)(Z,"ERROR_GENERIC_FAILURE","Failed to get autodiscovery configuration from server");(0,ur.default)(Z,"ERROR_INVALID_HS_BASE_URL","Invalid base_url for m.homeserver");(0,ur.default)(Z,"ERROR_INVALID_HOMESERVER","Homeserver URL does not appear to be a valid Matrix homeserver");(0,ur.default)(Z,"ERROR_INVALID_IS_BASE_URL","Invalid base_url for m.identity_server");(0,ur.default)(Z,"ERROR_INVALID_IDENTITY_SERVER","Identity server URL does not appear to be a valid identity server");(0,ur.default)(Z,"ERROR_INVALID_IS","Invalid identity server discovery response");(0,ur.default)(Z,"ERROR_MISSING_WELLKNOWN","No .well-known JSON file found");(0,ur.default)(Z,"ERROR_INVALID_JSON","Invalid JSON");(0,ur.default)(Z,"ALL_ERRORS",[Z.ERROR_INVALID,Z.ERROR_GENERIC_FAILURE,Z.ERROR_INVALID_HS_BASE_URL,Z.ERROR_INVALID_HOMESERVER,Z.ERROR_INVALID_IS_BASE_URL,Z.ERROR_INVALID_IDENTITY_SERVER,Z.ERROR_INVALID_IS,Z.ERROR_MISSING_WELLKNOWN,Z.ERROR_INVALID_JSON]);(0,ur.default)(Z,"FAIL_ERROR",ar.FAIL_ERROR);(0,ur.default)(Z,"FAIL_PROMPT",ar.FAIL_PROMPT);(0,ur.default)(Z,"PROMPT",ar.PROMPT);(0,ur.default)(Z,"SUCCESS",ar.SUCCESS);var xe={},Cg=/[\\\"\x00-\x1F]/g,ci={};for(var Pc=0;Pc<32;++Pc)ci[String.fromCharCode(Pc)]="\\U"+("0000"+Pc.toString(16)).slice(-4).toUpperCase();ci["\b"]="\\b";ci[" "]="\\t";ci[`
+`]="\\n";ci["\f"]="\\f";ci["\r"]="\\r";ci['"']='\\"';ci["\\"]="\\\\";function Xv(n){return Cg.lastIndex=0,n.replace(Cg,function(e){return ci[e]})}function bf(n){switch(typeof n){case"string":return'"'+Xv(n)+'"';case"number":return isFinite(n)?n:"null";case"boolean":return n;case"object":return n===null?"null":Array.isArray(n)?Rk(n):Ik(n);default:throw new Error("Cannot stringify: "+typeof n)}}function Rk(n){for(var e="[",t="",r=0;r<n.length;++r)t+=e,e=",",t+=bf(n[r]);return e!=","?"[]":t+"]"}function Ik(n){var e="{",t="",r=Object.keys(n);r.sort();for(var i=0;i<r.length;++i){var s=r[i];t+=e+'"'+Xv(s)+'":',e=",",t+=bf(n[s])}return e!=","?"{}":t+"}"}var tu={stringify:bf},Tk=G.exports;Object.defineProperty(xe,"__esModule",{value:!0});xe.OLM_ALGORITHM=xe.MEGOLM_BACKUP_ALGORITHM=Ck=xe.MEGOLM_ALGORITHM=void 0;xe.decodeBase64=Lk;xe.encodeBase64=Zv;xe.encodeUnpaddedBase64=Nk;xe.encryptMessageForDevice=Mk;xe.ensureOlmSessionsForDevices=Dk;xe.getExistingOlmSessions=Ak;xe.pkSign=Uk;xe.pkVerify=$k;xe.verifySignature=Qv;var wf=Tk(tu),Da=se,Wa;(function(n){n.Olm="m.olm.v1.curve25519-aes-sha2",n.Megolm="m.megolm.v1.aes-sha2",n.MegolmBackup="m.megolm_backup.v1.curve25519-aes-sha2"})(Wa||(Wa={}));const Ok=Wa.Olm;xe.OLM_ALGORITHM=Ok;const kk=Wa.Megolm;var Ck=xe.MEGOLM_ALGORITHM=kk;const Pk=Wa.MegolmBackup;xe.MEGOLM_BACKUP_ALGORITHM=Pk;async function Mk(n,e,t,r,i,s,o){const a=s.getIdentityKey(),l=await r.getSessionIdForDevice(a);if(l===null)return;Da.logger.log("Using sessionid "+l+" for device "+i+":"+s.deviceId);const u={sender:e,sender_device:t,keys:{ed25519:r.deviceEd25519Key},recipient:i,recipient_keys:{ed25519:s.getFingerprint()}};Object.assign(u,o),n[a]=await r.encryptMessage(a,l,JSON.stringify(u))}async function Ak(n,e,t){const r={},i={},s=[];for(const[o,a]of Object.entries(t))for(const l of a){const u=l.deviceId,c=l.getIdentityKey();s.push((async()=>{const g=await n.getSessionIdForDevice(c,!0);g===null?(r[o]=r[o]||[],r[o].push(l)):(i[o]=i[o]||{},i[o][u]={device:l,sessionId:g})})())}return await Promise.all(s),[r,i]}async function Dk(n,e,t,r=!1,i,s,o=Da.logger){typeof r=="number"&&(o=s,s=i,i=r,r=!1);const a=[],l={},u={};for(const[,I]of Object.entries(t))for(const w of I){const k=w.getIdentityKey();k!==n.deviceCurve25519Key&&(n.sessionsInProgress[k]||(n.sessionsInProgress[k]=new Promise(C=>{u[k]=S=>{delete n.sessionsInProgress[k],C(S)}})))}for(const[I,w]of Object.entries(t)){l[I]={};for(const k of w){const C=k.deviceId,S=k.getIdentityKey();if(S===n.deviceCurve25519Key){o.info("Attempted to start session with ourself! Ignoring"),l[I][C]={device:k,sessionId:null};continue}const T=`for ${S} (${I}:${C})`,D=await n.getSessionIdForDevice(S,!!u[S],o);D!==null&&u[S]&&u[S](),(D===null||r)&&(r?o.info(`Forcing new Olm session ${T}`):o.info(`Making new Olm session ${T}`),a.push([I,C])),l[I][C]={device:k,sessionId:D}}}if(a.length===0)return l;const c="signed_curve25519";let g,m=`one-time keys for ${a.length} devices`;try{o.debug(`Claiming ${m}`),g=await e.claimOneTimeKeys(a,c,i),o.debug(`Claimed ${m}`)}catch(I){for(const w of Object.values(u))w();throw o.log(`Failed to claim ${m}`,I,a),I}s&&"failures"in g&&s.push(...Object.keys(g.failures));const f=g.one_time_keys||{},E=[];for(const[I,w]of Object.entries(t)){const k=f[I]||{};for(let C=0;C<w.length;C++){const S=w[C],T=S.deviceId,D=S.getIdentityKey();if(D===n.deviceCurve25519Key||l[I][T].sessionId&&!r)continue;const R=k[T]||{};let U=null;for(const q in R)q.indexOf(c+":")===0&&(U=R[q]);if(!U){o.warn(`No one-time keys (alg=${c}) for device ${I}:${T}`),u[D]&&u[D]();continue}E.push(xk(n,U,I,S).then(q=>{u[D]&&u[D](q),l[I][T].sessionId=q},q=>{throw u[D]&&u[D](),q}))}}return m=`Olm sessions for ${E.length} devices`,o.debug(`Starting ${m}`),await Promise.all(E),o.debug(`Started ${m}`),l}async function xk(n,e,t,r){const i=r.deviceId;try{await Qv(n,e,t,i,r.getFingerprint())}catch(o){return Da.logger.error("Unable to verify signature on one-time key for device "+t+":"+i+":",o),null}let s;try{s=await n.createOutboundSession(r.getIdentityKey(),e.key)}catch(o){return Da.logger.error("Error starting olm session with device "+t+":"+i+": "+o),null}return Da.logger.log("Started new olm sessionid "+s+" for device "+t+":"+i),s}async function Qv(n,e,t,r,i){const s="ed25519:"+r,l=((e.signatures||{})[t]||{})[s];if(!l)throw Error("No signature");const u=Object.assign({},e);"unsigned"in u&&delete u.unsigned,delete u.signatures;const c=wf.default.stringify(u);n.verifySignature(i,c,l)}function Uk(n,e,t,r){let i=!1;if(e instanceof Uint8Array){const a=new V.Olm.PkSigning;r=a.init_with_seed(e),e=a,i=!0}const s=n.signatures||{};delete n.signatures;const o=n.unsigned;n.unsigned&&delete n.unsigned;try{const a=s[t]||{};return s[t]=a,a["ed25519:"+r]=e.sign(wf.default.stringify(n))}finally{n.signatures=s,o&&(n.unsigned=o),i&&e.free()}}function $k(n,e,t){const r="ed25519:"+e;if(!(n.signatures&&n.signatures[t]&&n.signatures[t][r]))throw new Error("No signature");const i=n.signatures[t][r],s=new V.Olm.Utility,o=n.signatures;delete n.signatures;const a=n.unsigned;n.unsigned&&delete n.unsigned;try{s.ed25519_verify(e,wf.default.stringify(n),i)}finally{n.signatures=o,a&&(n.unsigned=a),s.free()}}function Zv(n){return Buffer.from(n).toString("base64")}function Nk(n){return Zv(n).replace(/=+$/g,"")}function Lk(n){return Buffer.from(n,"base64")}var ru={},Br={},nu={};Object.defineProperty(nu,"__esModule",{value:!0});nu.LocalStorageCryptoStore=void 0;var Pg=se,Bk=Uo;const Er="crypto.",rd=Er+"account",Mg=Er+"cross_signing_keys",Ag=Er+"notified_error_devices",Dg=Er+"device_data",sl=Er+"inboundgroupsessions/",Kk=Er+"inboundgroupsessions.withheld/",Fk=Er+"rooms/",Ws=Er+"sessionsneedingbackup";function Mc(n){return Er+"sessions/"+n}function xg(n){return Er+"session.problems/"+n}function nd(n,e){return sl+n+"/"+e}function Ug(n,e){return Kk+n+"/"+e}function $g(n){return Fk+n}class qk extends Bk.MemoryCryptoStore{static exists(e){const t=e.length;for(let r=0;r<t;r++)if(e.key(r).startsWith(Er))return!0;return!1}constructor(e){super();this.store=e}countEndToEndSessions(e,t){let r=0;for(let i=0;i<this.store.length;++i)this.store.key(i).startsWith(Mc(""))&&++r;t(r)}_getEndToEndSessions(e){const t=pt(this.store,Mc(e)),r={};for(const[i,s]of Object.entries(t||{}))typeof s=="string"?r[i]={session:s}:r[i]=s;return r}getEndToEndSession(e,t,r,i){const s=this._getEndToEndSessions(e);i(s[t]||{})}getEndToEndSessions(e,t,r){r(this._getEndToEndSessions(e)||{})}getAllEndToEndSessions(e,t){for(let r=0;r<this.store.length;++r)if(this.store.key(r).startsWith(Mc(""))){const i=this.store.key(r).split("/")[1];for(const s of Object.values(this._getEndToEndSessions(i)))t(s)}}storeEndToEndSession(e,t,r,i){const s=this._getEndToEndSessions(e)||{};s[t]=r,kr(this.store,Mc(e),s)}async storeEndToEndSessionProblem(e,t,r){const i=xg(e),s=pt(this.store,i)||[];s.push({type:t,fixed:r,time:Date.now()}),s.sort((o,a)=>o.time-a.time),kr(this.store,i,s)}async getEndToEndSessionProblem(e,t){const r=xg(e),i=pt(this.store,r)||[];if(!i.length)return null;const s=i[i.length-1];for(const o of i)if(o.time>t)return Object.assign({},o,{fixed:s.fixed});return s.fixed?null:s}async filterOutNotifiedErrorDevices(e){const t=pt(this.store,Ag)||{},r=[];for(const i of e){const{userId:s,deviceInfo:o}=i;s in t?o.deviceId in t[s]||(r.push(i),t[s][o.deviceId]=!0):(r.push(i),t[s]={[o.deviceId]:!0})}return kr(this.store,Ag,t),r}getEndToEndInboundGroupSession(e,t,r,i){i(pt(this.store,nd(e,t)),pt(this.store,Ug(e,t)))}getAllEndToEndInboundGroupSessions(e,t){for(let r=0;r<this.store.length;++r){const i=this.store.key(r);i.startsWith(sl)&&t({senderKey:i.substr(sl.length,43),sessionId:i.substr(sl.length+44),sessionData:pt(this.store,i)})}t(null)}addEndToEndInboundGroupSession(e,t,r,i){pt(this.store,nd(e,t))||this.storeEndToEndInboundGroupSession(e,t,r,i)}storeEndToEndInboundGroupSession(e,t,r,i){kr(this.store,nd(e,t),r)}storeEndToEndInboundGroupSessionWithheld(e,t,r,i){kr(this.store,Ug(e,t),r)}getEndToEndDeviceData(e,t){t(pt(this.store,Dg))}storeEndToEndDeviceData(e,t){kr(this.store,Dg,e)}storeEndToEndRoom(e,t,r){kr(this.store,$g(e),t)}getEndToEndRooms(e,t){const r={},i=$g("");for(let s=0;s<this.store.length;++s){const o=this.store.key(s);if(o.startsWith(i)){const a=o.substr(i.length);r[a]=pt(this.store,o)}}t(r)}getSessionsNeedingBackup(e){const t=pt(this.store,Ws)||{},r=[];for(const i in t)if(Object.prototype.hasOwnProperty.call(t,i)){const s=i.substr(0,43),o=i.substr(44);if(this.getEndToEndInboundGroupSession(s,o,null,a=>{r.push({senderKey:s,sessionId:o,sessionData:a})}),e&&i.length>=e)break}return Promise.resolve(r)}countSessionsNeedingBackup(){const e=pt(this.store,Ws)||{};return Promise.resolve(Object.keys(e).length)}unmarkSessionsNeedingBackup(e){const t=pt(this.store,Ws)||{};for(const r of e)delete t[r.senderKey+"/"+r.sessionId];return kr(this.store,Ws,t),Promise.resolve()}markSessionsNeedingBackup(e){const t=pt(this.store,Ws)||{};for(const r of e)t[r.senderKey+"/"+r.sessionId]=!0;return kr(this.store,Ws,t),Promise.resolve()}deleteAllData(){return this.store.removeItem(rd),Promise.resolve()}getAccount(e,t){const r=pt(this.store,rd);t(r)}storeAccount(e,t){kr(this.store,rd,t)}getCrossSigningKeys(e,t){const r=pt(this.store,Mg);t(r)}getSecretStorePrivateKey(e,t,r){const i=pt(this.store,Er+`ssss_cache.${r}`);t(i)}storeCrossSigningKeys(e,t){kr(this.store,Mg,t)}storeSecretStorePrivateKey(e,t,r){kr(this.store,Er+`ssss_cache.${t}`,r)}doTxn(e,t,r){return Promise.resolve(r(null))}}nu.LocalStorageCryptoStore=qk;function pt(n,e){try{return JSON.parse(n.getItem(e))}catch(t){Pg.logger.log("Error: Failed to get key %s: %s",e,t.stack||t),Pg.logger.log(t.stack)}return null}function kr(n,e,t){n.setItem(e,JSON.stringify(t))}var _s={},jk=G.exports;Object.defineProperty(_s,"__esModule",{value:!0});_s.VERSION=_s.Backend=void 0;_s.upgradeDatabase=Yk;var Vk=jk(Y.exports),mn=se,Gk=Wk(W);function e_(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(e_=function(r){return r?t:e})(n)}function Wk(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=e_(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}const t_=10;_s.VERSION=t_;class Hk{constructor(e){this.db=e,(0,Vk.default)(this,"nextTxnId",0),e.onversionchange=()=>{mn.logger.log(`versionchange for indexeddb ${this.db.name}: closing`),e.close()}}async startup(){return this}async deleteAllData(){throw Error("This is not implemented, call IDBFactory::deleteDatabase(dbName) instead.")}getOrAddOutgoingRoomKeyRequest(e){const t=e.requestBody;return new Promise((r,i)=>{const s=this.db.transaction("outgoingRoomKeyRequests","readwrite");s.onerror=i,this._getOutgoingRoomKeyRequest(s,t,o=>{if(o){mn.logger.log(`already have key request outstanding for ${t.room_id} / ${t.session_id}: not sending another`),r(o);return}mn.logger.log(`enqueueing key request for ${t.room_id} / `+t.session_id),s.oncomplete=()=>{r(e)},s.objectStore("outgoingRoomKeyRequests").add(e)})})}getOutgoingRoomKeyRequest(e){return new Promise((t,r)=>{const i=this.db.transaction("outgoingRoomKeyRequests","readonly");i.onerror=r,this._getOutgoingRoomKeyRequest(i,e,s=>{t(s)})})}_getOutgoingRoomKeyRequest(e,t,r){const o=e.objectStore("outgoingRoomKeyRequests").index("session").openCursor([t.room_id,t.session_id]);o.onsuccess=()=>{const a=o.result;if(!a){r(null);return}const l=a.value;if(Gk.deepCompare(l.requestBody,t)){r(l);return}a.continue()}}getOutgoingRoomKeyRequestByState(e){if(e.length===0)return Promise.resolve(null);let t=0,r;function i(){const u=this.result;if(u){r=u.value;return}if(t++,t>=e.length)return;const c=e[t],g=this.source.openCursor(c);g.onsuccess=i}const s=this.db.transaction("outgoingRoomKeyRequests","readonly"),o=s.objectStore("outgoingRoomKeyRequests"),a=e[t],l=o.index("state").openCursor(a);return l.onsuccess=i,Gi(s).then(()=>r)}getAllOutgoingRoomKeyRequestsByState(e){return new Promise((t,r)=>{const a=this.db.transaction("outgoingRoomKeyRequests","readonly").objectStore("outgoingRoomKeyRequests").index("state").getAll(e);a.onsuccess=()=>t(a.result),a.onerror=()=>r(a.error)})}getOutgoingRoomKeyRequestsByTarget(e,t,r){let i=0;const s=[];function o(){const g=this.result;if(g){const m=g.value;m.recipients.includes({userId:e,deviceId:t})&&s.push(m),g.continue()}else{if(i++,i>=r.length)return;const m=r[i],f=this.source.openCursor(m);f.onsuccess=o}}const a=this.db.transaction("outgoingRoomKeyRequests","readonly"),l=a.objectStore("outgoingRoomKeyRequests"),u=r[i],c=l.index("state").openCursor(u);return c.onsuccess=o,Gi(a).then(()=>s)}updateOutgoingRoomKeyRequest(e,t,r){let i=null;function s(){const l=this.result;if(!l)return;const u=l.value;if(u.state!=t){mn.logger.warn(`Cannot update room key request from ${t} as it was already updated to ${u.state}`);return}Object.assign(u,r),l.update(u),i=u}const o=this.db.transaction("outgoingRoomKeyRequests","readwrite"),a=o.objectStore("outgoingRoomKeyRequests").openCursor(e);return a.onsuccess=s,Gi(o).then(()=>i)}deleteOutgoingRoomKeyRequest(e,t){const r=this.db.transaction("outgoingRoomKeyRequests","readwrite"),i=r.objectStore("outgoingRoomKeyRequests").openCursor(e);return i.onsuccess=()=>{const s=i.result;if(!s)return;const o=s.value;if(o.state!=t){mn.logger.warn(`Cannot delete room key request in state ${o.state} (expected ${t})`);return}s.delete()},Gi(r)}getAccount(e,t){const i=e.objectStore("account").get("-");i.onsuccess=function(){try{t(i.result||null)}catch(s){Xt(e,s)}}}storeAccount(e,t){e.objectStore("account").put(t,"-")}getCrossSigningKeys(e,t){const i=e.objectStore("account").get("crossSigningKeys");i.onsuccess=function(){try{t(i.result||null)}catch(s){Xt(e,s)}}}getSecretStorePrivateKey(e,t,r){const s=e.objectStore("account").get(`ssss_cache:${r}`);s.onsuccess=function(){try{t(s.result||null)}catch(o){Xt(e,o)}}}storeCrossSigningKeys(e,t){e.objectStore("account").put(t,"crossSigningKeys")}storeSecretStorePrivateKey(e,t,r){e.objectStore("account").put(r,`ssss_cache:${t}`)}countEndToEndSessions(e,t){const i=e.objectStore("sessions").count();i.onsuccess=function(){try{t(i.result)}catch(s){Xt(e,s)}}}getEndToEndSessions(e,t,r){const o=t.objectStore("sessions").index("deviceKey").openCursor(e),a={};o.onsuccess=function(){const l=o.result;if(l)a[l.value.sessionId]={session:l.value.session,lastReceivedMessageTs:l.value.lastReceivedMessageTs},l.continue();else try{r(a)}catch(u){Xt(t,u)}}}getEndToEndSession(e,t,r,i){const o=r.objectStore("sessions").get([e,t]);o.onsuccess=function(){try{o.result?i({session:o.result.session,lastReceivedMessageTs:o.result.lastReceivedMessageTs}):i(null)}catch(a){Xt(r,a)}}}getAllEndToEndSessions(e,t){const i=e.objectStore("sessions").openCursor();i.onsuccess=function(){try{const s=i.result;s?(t(s.value),s.continue()):t(null)}catch(s){Xt(e,s)}}}storeEndToEndSession(e,t,r,i){i.objectStore("sessions").put({deviceKey:e,sessionId:t,session:r.session,lastReceivedMessageTs:r.lastReceivedMessageTs})}async storeEndToEndSessionProblem(e,t,r){const i=this.db.transaction("session_problems","readwrite");return i.objectStore("session_problems").put({deviceKey:e,type:t,fixed:r,time:Date.now()}),Gi(i)}async getEndToEndSessionProblem(e,t){let r;const i=this.db.transaction("session_problems","readwrite"),a=i.objectStore("session_problems").index("deviceKey").getAll(e);return a.onsuccess=()=>{const l=a.result;if(!l.length){r=null;return}l.sort((c,g)=>c.time-g.time);const u=l[l.length-1];for(const c of l)if(c.time>t){r=Object.assign({},c,{fixed:u.fixed});return}u.fixed?r=null:r=u},await Gi(i),r}async filterOutNotifiedErrorDevices(e){const r=this.db.transaction("notified_error_devices","readwrite").objectStore("notified_error_devices"),i=[];return await Promise.all(e.map(s=>new Promise(o=>{const{userId:a,deviceInfo:l}=s,u=r.get([a,l.deviceId]);u.onsuccess=function(){u.result||(r.put({userId:a,deviceId:l.deviceId}),i.push(s)),o()}}))),i}getEndToEndInboundGroupSession(e,t,r,i){let s=!1,o=!1;const l=r.objectStore("inbound_group_sessions").get([e,t]);l.onsuccess=function(){try{l.result?s=l.result.session:s=null,o!==!1&&i(s,o)}catch(g){Xt(r,g)}};const c=r.objectStore("inbound_group_sessions_withheld").get([e,t]);c.onsuccess=function(){try{c.result?o=c.result.session:o=null,s!==!1&&i(s,o)}catch(g){Xt(r,g)}}}getAllEndToEndInboundGroupSessions(e,t){const i=e.objectStore("inbound_group_sessions").openCursor();i.onsuccess=function(){const s=i.result;if(s){try{t({senderKey:s.value.senderCurve25519Key,sessionId:s.value.sessionId,sessionData:s.value.session})}catch(o){Xt(e,o)}s.continue()}else try{t(null)}catch(o){Xt(e,o)}}}addEndToEndInboundGroupSession(e,t,r,i){const o=i.objectStore("inbound_group_sessions").add({senderCurve25519Key:e,sessionId:t,session:r});o.onerror=a=>{o.error.name==="ConstraintError"?(a.stopPropagation(),a.preventDefault(),mn.logger.log("Ignoring duplicate inbound group session: "+e+" / "+t)):Xt(i,new Error("Failed to add inbound group session: "+o.error))}}storeEndToEndInboundGroupSession(e,t,r,i){i.objectStore("inbound_group_sessions").put({senderCurve25519Key:e,sessionId:t,session:r})}storeEndToEndInboundGroupSessionWithheld(e,t,r,i){i.objectStore("inbound_group_sessions_withheld").put({senderCurve25519Key:e,sessionId:t,session:r})}getEndToEndDeviceData(e,t){const i=e.objectStore("device_data").get("-");i.onsuccess=function(){try{t(i.result||null)}catch(s){Xt(e,s)}}}storeEndToEndDeviceData(e,t){t.objectStore("device_data").put(e,"-")}storeEndToEndRoom(e,t,r){r.objectStore("rooms").put(t,e)}getEndToEndRooms(e,t){const r={},s=e.objectStore("rooms").openCursor();s.onsuccess=function(){const o=s.result;if(o)r[o.key]=o.value,o.continue();else try{t(r)}catch(a){Xt(e,a)}}}getSessionsNeedingBackup(e){return new Promise((t,r)=>{const i=[],s=this.db.transaction(["sessions_needing_backup","inbound_group_sessions"],"readonly");s.onerror=r,s.oncomplete=function(){t(i)};const o=s.objectStore("sessions_needing_backup"),a=s.objectStore("inbound_group_sessions"),l=o.openCursor();l.onsuccess=function(){const u=l.result;if(u){const c=a.get(u.key);c.onsuccess=function(){i.push({senderKey:c.result.senderCurve25519Key,sessionId:c.result.sessionId,sessionData:c.result.session})},(!e||i.length<e)&&u.continue()}}})}countSessionsNeedingBackup(e){e||(e=this.db.transaction("sessions_needing_backup","readonly"));const t=e.objectStore("sessions_needing_backup");return new Promise((r,i)=>{const s=t.count();s.onerror=i,s.onsuccess=()=>r(s.result)})}async unmarkSessionsNeedingBackup(e,t){t||(t=this.db.transaction("sessions_needing_backup","readwrite"));const r=t.objectStore("sessions_needing_backup");await Promise.all(e.map(i=>new Promise((s,o)=>{const a=r.delete([i.senderKey,i.sessionId]);a.onsuccess=s,a.onerror=o})))}async markSessionsNeedingBackup(e,t){t||(t=this.db.transaction("sessions_needing_backup","readwrite"));const r=t.objectStore("sessions_needing_backup");await Promise.all(e.map(i=>new Promise((s,o)=>{const a=r.put({senderCurve25519Key:i.senderKey,sessionId:i.sessionId});a.onsuccess=s,a.onerror=o})))}addSharedHistoryInboundGroupSession(e,t,r,i){i||(i=this.db.transaction("shared_history_inbound_group_sessions","readwrite"));const s=i.objectStore("shared_history_inbound_group_sessions"),o=s.get([e]);o.onsuccess=()=>{const{sessions:a}=o.result||{sessions:[]};a.push([t,r]),s.put({roomId:e,sessions:a})}}getSharedHistoryInboundGroupSessions(e,t){t||(t=this.db.transaction("shared_history_inbound_group_sessions","readonly"));const i=t.objectStore("shared_history_inbound_group_sessions").get([e]);return new Promise((s,o)=>{i.onsuccess=()=>{const{sessions:a}=i.result||{sessions:[]};s(a)},i.onerror=o})}doTxn(e,t,r,i=mn.logger){const s=this.db.transaction(t,e),o=Gi(s),a=r(s);return o.then(()=>a)}}_s.Backend=Hk;function Yk(n,e){mn.logger.log(`Upgrading IndexedDBCryptoStore from version ${e} to ${t_}`),e<1&&zk(n),e<2&&n.createObjectStore("account"),e<3&&n.createObjectStore("sessions",{keyPath:["deviceKey","sessionId"]}).createIndex("deviceKey","deviceKey"),e<4&&n.createObjectStore("inbound_group_sessions",{keyPath:["senderCurve25519Key","sessionId"]}),e<5&&n.createObjectStore("device_data"),e<6&&n.createObjectStore("rooms"),e<7&&n.createObjectStore("sessions_needing_backup",{keyPath:["senderCurve25519Key","sessionId"]}),e<8&&n.createObjectStore("inbound_group_sessions_withheld",{keyPath:["senderCurve25519Key","sessionId"]}),e<9&&(n.createObjectStore("session_problems",{keyPath:["deviceKey","time"]}).createIndex("deviceKey","deviceKey"),n.createObjectStore("notified_error_devices",{keyPath:["userId","deviceId"]})),e<10&&n.createObjectStore("shared_history_inbound_group_sessions",{keyPath:["roomId"]})}function zk(n){const e=n.createObjectStore("outgoingRoomKeyRequests",{keyPath:"requestId"});e.createIndex("session",["requestBody.room_id","requestBody.session_id"]),e.createIndex("state","state")}function Xt(n,e){n._mx_abortexception=e;try{n.abort()}catch{}}function Gi(n){return new Promise((e,t)=>{n.oncomplete=()=>{n._mx_abortexception!==void 0&&t(n._mx_abortexception),e(null)},n.onerror=r=>{n._mx_abortexception!==void 0?t(n._mx_abortexception):(mn.logger.log("Error performing indexeddb txn",r),t(n.error))},n.onabort=r=>{n._mx_abortexception!==void 0?t(n._mx_abortexception):(mn.logger.log("Error performing indexeddb txn",r),t(n.error))}})}var iu={};Object.defineProperty(iu,"__esModule",{value:!0});iu.exists=Jk;function Jk(n,e){return new Promise((t,r)=>{let i=!0;const s=n.open(e);s.onupgradeneeded=()=>{i=!1},s.onblocked=()=>r(s.error),s.onsuccess=()=>{s.result.close(),i||n.deleteDatabase(e),t(i)},s.onerror=o=>r(s.error)})}var Xk=G.exports;Object.defineProperty(Br,"__esModule",{value:!0});Br.IndexedDBCryptoStore=void 0;var On=Xk(Y.exports),Cr=se,Qk=nu,Zk=Uo,id=n_(_s),Ng=oi,eC=n_(iu);function r_(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(r_=function(r){return r?t:e})(n)}function n_(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=r_(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}class Lr{static exists(e,t){return eC.exists(e,t)}constructor(e,t){this.indexedDB=e,this.dbName=t,(0,On.default)(this,"backendPromise",null),(0,On.default)(this,"backend",null)}startup(){return this.backendPromise?this.backendPromise:(this.backendPromise=new Promise((e,t)=>{if(!this.indexedDB){t(new Error("no indexeddb support available"));return}Cr.logger.log(`connecting to indexeddb ${this.dbName}`);const r=this.indexedDB.open(this.dbName,id.VERSION);r.onupgradeneeded=i=>{const s=r.result,o=i.oldVersion;id.upgradeDatabase(s,o)},r.onblocked=()=>{Cr.logger.log("can't yet open IndexedDBCryptoStore because it is open elsewhere")},r.onerror=i=>{Cr.logger.log("Error connecting to indexeddb",i),t(r.error)},r.onsuccess=()=>{const i=r.result;Cr.logger.log(`connected to indexeddb ${this.dbName}`),e(new id.Backend(i))}}).then(e=>e.doTxn("readonly",[Lr.STORE_INBOUND_GROUP_SESSIONS,Lr.STORE_INBOUND_GROUP_SESSIONS_WITHHELD],t=>{e.getEndToEndInboundGroupSession("","",t,()=>{})}).then(()=>e)).catch(e=>{if(e.name==="VersionError")throw Cr.logger.warn("Crypto DB is too new for us to use!",e),new Ng.InvalidCryptoStoreError(Ng.InvalidCryptoStoreError.TOO_NEW);Cr.logger.warn(`unable to connect to indexeddb ${this.dbName}: falling back to localStorage store: ${e}`);try{return new Qk.LocalStorageCryptoStore(V.localStorage)}catch(t){return Cr.logger.warn(`unable to open localStorage: falling back to in-memory store: ${t}`),new Zk.MemoryCryptoStore}}).then(e=>(this.backend=e,e)),this.backendPromise)}deleteAllData(){return new Promise((e,t)=>{if(!this.indexedDB){t(new Error("no indexeddb support available"));return}Cr.logger.log(`Removing indexeddb instance: ${this.dbName}`);const r=this.indexedDB.deleteDatabase(this.dbName);r.onblocked=()=>{Cr.logger.log("can't yet delete IndexedDBCryptoStore because it is open elsewhere")},r.onerror=i=>{Cr.logger.log("Error deleting data from indexeddb",i),t(r.error)},r.onsuccess=()=>{Cr.logger.log(`Removed indexeddb instance: ${this.dbName}`),e()}}).catch(e=>{Cr.logger.warn(`unable to delete IndexedDBCryptoStore: ${e}`)})}getOrAddOutgoingRoomKeyRequest(e){return this.backend.getOrAddOutgoingRoomKeyRequest(e)}getOutgoingRoomKeyRequest(e){return this.backend.getOutgoingRoomKeyRequest(e)}getOutgoingRoomKeyRequestByState(e){return this.backend.getOutgoingRoomKeyRequestByState(e)}getAllOutgoingRoomKeyRequestsByState(e){return this.backend.getAllOutgoingRoomKeyRequestsByState(e)}getOutgoingRoomKeyRequestsByTarget(e,t,r){return this.backend.getOutgoingRoomKeyRequestsByTarget(e,t,r)}updateOutgoingRoomKeyRequest(e,t,r){return this.backend.updateOutgoingRoomKeyRequest(e,t,r)}deleteOutgoingRoomKeyRequest(e,t){return this.backend.deleteOutgoingRoomKeyRequest(e,t)}getAccount(e,t){this.backend.getAccount(e,t)}storeAccount(e,t){this.backend.storeAccount(e,t)}getCrossSigningKeys(e,t){this.backend.getCrossSigningKeys(e,t)}getSecretStorePrivateKey(e,t,r){this.backend.getSecretStorePrivateKey(e,t,r)}storeCrossSigningKeys(e,t){this.backend.storeCrossSigningKeys(e,t)}storeSecretStorePrivateKey(e,t,r){this.backend.storeSecretStorePrivateKey(e,t,r)}countEndToEndSessions(e,t){this.backend.countEndToEndSessions(e,t)}getEndToEndSession(e,t,r,i){this.backend.getEndToEndSession(e,t,r,i)}getEndToEndSessions(e,t,r){this.backend.getEndToEndSessions(e,t,r)}getAllEndToEndSessions(e,t){this.backend.getAllEndToEndSessions(e,t)}storeEndToEndSession(e,t,r,i){this.backend.storeEndToEndSession(e,t,r,i)}storeEndToEndSessionProblem(e,t,r){return this.backend.storeEndToEndSessionProblem(e,t,r)}getEndToEndSessionProblem(e,t){return this.backend.getEndToEndSessionProblem(e,t)}filterOutNotifiedErrorDevices(e){return this.backend.filterOutNotifiedErrorDevices(e)}getEndToEndInboundGroupSession(e,t,r,i){this.backend.getEndToEndInboundGroupSession(e,t,r,i)}getAllEndToEndInboundGroupSessions(e,t){this.backend.getAllEndToEndInboundGroupSessions(e,t)}addEndToEndInboundGroupSession(e,t,r,i){this.backend.addEndToEndInboundGroupSession(e,t,r,i)}storeEndToEndInboundGroupSession(e,t,r,i){this.backend.storeEndToEndInboundGroupSession(e,t,r,i)}storeEndToEndInboundGroupSessionWithheld(e,t,r,i){this.backend.storeEndToEndInboundGroupSessionWithheld(e,t,r,i)}storeEndToEndDeviceData(e,t){this.backend.storeEndToEndDeviceData(e,t)}getEndToEndDeviceData(e,t){this.backend.getEndToEndDeviceData(e,t)}storeEndToEndRoom(e,t,r){this.backend.storeEndToEndRoom(e,t,r)}getEndToEndRooms(e,t){this.backend.getEndToEndRooms(e,t)}getSessionsNeedingBackup(e){return this.backend.getSessionsNeedingBackup(e)}countSessionsNeedingBackup(e){return this.backend.countSessionsNeedingBackup(e)}unmarkSessionsNeedingBackup(e,t){return this.backend.unmarkSessionsNeedingBackup(e,t)}markSessionsNeedingBackup(e,t){return this.backend.markSessionsNeedingBackup(e,t)}addSharedHistoryInboundGroupSession(e,t,r,i){this.backend.addSharedHistoryInboundGroupSession(e,t,r,i)}getSharedHistoryInboundGroupSessions(e,t){return this.backend.getSharedHistoryInboundGroupSessions(e,t)}doTxn(e,t,r,i){return this.backend.doTxn(e,t,r,i)}}Br.IndexedDBCryptoStore=Lr;(0,On.default)(Lr,"STORE_ACCOUNT","account");(0,On.default)(Lr,"STORE_SESSIONS","sessions");(0,On.default)(Lr,"STORE_INBOUND_GROUP_SESSIONS","inbound_group_sessions");(0,On.default)(Lr,"STORE_INBOUND_GROUP_SESSIONS_WITHHELD","inbound_group_sessions_withheld");(0,On.default)(Lr,"STORE_SHARED_HISTORY_INBOUND_GROUP_SESSIONS","shared_history_inbound_group_sessions");(0,On.default)(Lr,"STORE_DEVICE_DATA","device_data");(0,On.default)(Lr,"STORE_ROOMS","rooms");(0,On.default)(Lr,"STORE_BACKUP","sessions_needing_backup");var tC=G.exports;Object.defineProperty(ru,"__esModule",{value:!0});ru.RoomList=void 0;var rC=tC(Y.exports),Lg=Br;class nC{constructor(e){this.cryptoStore=e,(0,rC.default)(this,"roomEncryption",{})}async init(){await this.cryptoStore.doTxn("readwrite",[Lg.IndexedDBCryptoStore.STORE_ROOMS],e=>{this.cryptoStore.getEndToEndRooms(e,t=>{this.roomEncryption=t})})}getRoomEncryption(e){return this.roomEncryption[e]||null}isRoomEncrypted(e){return Boolean(this.getRoomEncryption(e))}async setRoomEncryption(e,t){this.roomEncryption[e]=t,await this.cryptoStore.doTxn("readwrite",[Lg.IndexedDBCryptoStore.STORE_ROOMS],r=>{this.cryptoStore.storeEndToEndRoom(e,t,r)})}}ru.RoomList=nC;var jo={};Object.defineProperty(jo,"__esModule",{value:!0});jo.SERVICE_TYPES=void 0;let Ch;jo.SERVICE_TYPES=Ch;(function(n){n.IS="SERVICE_TYPE_IS",n.IM="SERVICE_TYPE_IM"})(Ch||(jo.SERVICE_TYPES=Ch={}));var Ft={},Es={},Rf={},xs={},iC=G.exports;Object.defineProperty(xs,"__esModule",{value:!0});xs.DeviceInfo=void 0;var Qi=iC(Y.exports),Xn;(function(n){n[n.Blocked=-1]="Blocked",n[n.Unverified=0]="Unverified",n[n.Verified=1]="Verified"})(Xn||(Xn={}));class su{static fromStorage(e,t){const r=new su(t);for(const i in e)e.hasOwnProperty(i)&&(r[i]=e[i]);return r}constructor(e){this.deviceId=e,(0,Qi.default)(this,"algorithms",void 0),(0,Qi.default)(this,"keys",{}),(0,Qi.default)(this,"verified",Xn.Unverified),(0,Qi.default)(this,"known",!1),(0,Qi.default)(this,"unsigned",{}),(0,Qi.default)(this,"signatures",{})}toStorage(){return{algorithms:this.algorithms,keys:this.keys,verified:this.verified,known:this.known,unsigned:this.unsigned,signatures:this.signatures}}getFingerprint(){return this.keys["ed25519:"+this.deviceId]}getIdentityKey(){return this.keys["curve25519:"+this.deviceId]}getDisplayName(){return this.unsigned.device_display_name||null}isBlocked(){return this.verified==Xn.Blocked}isVerified(){return this.verified==Xn.Verified}isUnverified(){return this.verified==Xn.Unverified}isKnown(){return this.known===!0}}xs.DeviceInfo=su;(0,Qi.default)(su,"DeviceVerification",{VERIFIED:Xn.Verified,UNVERIFIED:Xn.Unverified,BLOCKED:Xn.Blocked});var _t={},sC=G.exports;Object.defineProperty(_t,"__esModule",{value:!0});_t.UnknownDeviceError=_t.EncryptionAlgorithm=_t.ENCRYPTION_CLASSES=_t.DecryptionError=_t.DecryptionAlgorithm=_t.DECRYPTION_CLASSES=void 0;_t.registerAlgorithm=dC;var Dr=sC(Y.exports);const i_={};_t.ENCRYPTION_CLASSES=i_;const s_={};_t.DECRYPTION_CLASSES=s_;class oC{constructor(e){(0,Dr.default)(this,"userId",void 0),(0,Dr.default)(this,"deviceId",void 0),(0,Dr.default)(this,"crypto",void 0),(0,Dr.default)(this,"olmDevice",void 0),(0,Dr.default)(this,"baseApis",void 0),(0,Dr.default)(this,"roomId",void 0),this.userId=e.userId,this.deviceId=e.deviceId,this.crypto=e.crypto,this.olmDevice=e.olmDevice,this.baseApis=e.baseApis,this.roomId=e.roomId}prepareToEncrypt(e){}onRoomMembership(e,t,r){}}_t.EncryptionAlgorithm=oC;class aC{constructor(e){(0,Dr.default)(this,"userId",void 0),(0,Dr.default)(this,"crypto",void 0),(0,Dr.default)(this,"olmDevice",void 0),(0,Dr.default)(this,"baseApis",void 0),(0,Dr.default)(this,"roomId",void 0),this.userId=e.userId,this.crypto=e.crypto,this.olmDevice=e.olmDevice,this.baseApis=e.baseApis,this.roomId=e.roomId}onRoomKeyEvent(e){}async importRoomKey(e,t){}hasKeysForKeyRequest(e){return Promise.resolve(!1)}shareKeysWithDevice(e){throw new Error("shareKeysWithDevice not supported for this DecryptionAlgorithm")}async retryDecryptionFromSender(e){return!1}}_t.DecryptionAlgorithm=aC;class cC extends Error{constructor(e,t,r){super(t);this.code=e,(0,Dr.default)(this,"detailedString",void 0),this.code=e,this.name="DecryptionError",this.detailedString=lC(this,r)}}_t.DecryptionError=cC;function lC(n,e){let t=n.name+"[msg: "+n.message;return e&&(t+=", "+Object.keys(e).map(r=>r+": "+e[r]).join(", ")),t+="]",t}class uC extends Error{constructor(e,t){super(e);this.devices=t,this.name="UnknownDeviceError",this.devices=t}}_t.UnknownDeviceError=uC;function dC(n,e,t){i_[n]=e,s_[n]=t}var hC=G.exports,Bg=hC(Y.exports),Kg=se,Ph=pC(xe),fC=xs,fn=_t;function o_(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(o_=function(r){return r?t:e})(n)}function pC(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=o_(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}const gC=fC.DeviceInfo.DeviceVerification;class mC extends fn.EncryptionAlgorithm{constructor(...e){super(...e);(0,Bg.default)(this,"sessionPrepared",!1),(0,Bg.default)(this,"prepPromise",null)}ensureSession(e){return this.prepPromise?this.prepPromise:this.sessionPrepared?Promise.resolve():(this.prepPromise=this.crypto.downloadKeys(e).then(t=>this.crypto.ensureOlmSessionsForUsers(e)).then(()=>{this.sessionPrepared=!0}).finally(()=>{this.prepPromise=null}),this.prepPromise)}async encryptMessage(e,t,r){const s=(await e.getEncryptionTargetMembers()).map(function(u){return u.userId});await this.ensureSession(s);const o={room_id:e.roomId,type:t,content:r},a={algorithm:Ph.OLM_ALGORITHM,sender_key:this.olmDevice.deviceCurve25519Key,ciphertext:{}},l=[];for(let u=0;u<s.length;++u){const c=s[u],g=this.crypto.getStoredDevicesForUser(c);for(let m=0;m<g.length;++m){const f=g[m];f.getIdentityKey()!=this.olmDevice.deviceCurve25519Key&&f.verified!=gC.BLOCKED&&l.push(Ph.encryptMessageForDevice(a.ciphertext,this.userId,this.deviceId,this.olmDevice,c,f,o))}}return await Promise.all(l).then(()=>a)}}class yC extends fn.DecryptionAlgorithm{async decryptEvent(e){const t=e.getWireContent(),r=t.sender_key,i=t.ciphertext;if(!i)throw new fn.DecryptionError("OLM_MISSING_CIPHERTEXT","Missing ciphertext");if(!(this.olmDevice.deviceCurve25519Key in i))throw new fn.DecryptionError("OLM_NOT_INCLUDED_IN_RECIPIENTS","Not included in recipients");const s=i[this.olmDevice.deviceCurve25519Key];let o;try{o=await this.decryptMessage(r,s)}catch(u){throw new fn.DecryptionError("OLM_BAD_ENCRYPTED_MESSAGE","Bad Encrypted Message",{sender:r,err:u})}const a=JSON.parse(o);if(a.recipient!=this.userId)throw new fn.DecryptionError("OLM_BAD_RECIPIENT","Message was intented for "+a.recipient);if(a.recipient_keys.ed25519!=this.olmDevice.deviceEd25519Key)throw new fn.DecryptionError("OLM_BAD_RECIPIENT_KEY","Message not intended for this device",{intended:a.recipient_keys.ed25519,our_key:this.olmDevice.deviceEd25519Key});if(a.sender!=e.getSender())throw new fn.DecryptionError("OLM_FORWARDED_MESSAGE","Message forwarded from "+a.sender,{reported_sender:e.getSender()});if(a.room_id!==e.getRoomId())throw new fn.DecryptionError("OLM_BAD_ROOM","Message intended for room "+a.room_id,{reported_room:e.getRoomId()});const l=a.keys||{};return{clearEvent:a,senderCurve25519Key:r,claimedEd25519Key:l.ed25519||null}}async decryptMessage(e,t){if(t.type!==0)return this.reallyDecryptMessage(e,t);{const r=this.olmDevice.olmPrekeyPromise.then(()=>this.reallyDecryptMessage(e,t));return this.olmDevice.olmPrekeyPromise=r.catch(()=>{}),await r}}async reallyDecryptMessage(e,t){const r=await this.olmDevice.getSessionIdsForDevice(e),i={};for(let o=0;o<r.length;o++){const a=r[o];try{const l=await this.olmDevice.decryptMessage(e,a,t.type,t.body);return Kg.logger.log("Decrypted Olm message from "+e+" with session "+a),l}catch(l){if(await this.olmDevice.matchesSession(e,a,t.type,t.body))throw new Error("Error decrypting prekey message with existing session id "+a+": "+l.message);i[a]=l.message}}if(t.type!==0)throw r.length===0?new Error("No existing sessions"):new Error("Error decrypting non-prekey message with existing sessions: "+JSON.stringify(i));let s;try{s=await this.olmDevice.createInboundSession(e,t.type,t.body)}catch(o){throw i["(new)"]=o.message,new Error("Error decrypting prekey message: "+JSON.stringify(i))}return Kg.logger.log("created new inbound Olm session ID "+s.session_id+" with "+e),s.payload}}(0,fn.registerAlgorithm)(Ph.OLM_ALGORITHM,mC,yC);var If={},vC=G.exports;Object.defineProperty(If,"__esModule",{value:!0});If.isRoomSharedHistory=c_;var xr=vC(Y.exports),H=se,et=_C(xe),Wn=_t,Fg=Es;function a_(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(a_=function(r){return r?t:e})(n)}function _C(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=a_(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}function c_(n){var e,t;const r=n==null||(e=n.currentState)===null||e===void 0?void 0:e.getStateEvents("m.room.history_visibility",""),i=r==null||(t=r.getContent())===null||t===void 0?void 0:t.history_visibility;return["world_readable","shared"].includes(i)}class EC{constructor(e,t=!1){this.sessionId=e,this.sharedHistory=t,(0,xr.default)(this,"useCount",0),(0,xr.default)(this,"creationTime",void 0),(0,xr.default)(this,"sharedWithDevices",{}),(0,xr.default)(this,"blockedDevicesNotified",{}),this.creationTime=new Date().getTime()}needsRotation(e,t){const r=new Date().getTime()-this.creationTime;return this.useCount>=e||r>=t?(H.logger.log("Rotating megolm session after "+this.useCount+" messages, "+r+"ms"),!0):!1}markSharedWithDevice(e,t,r,i){this.sharedWithDevices[e]||(this.sharedWithDevices[e]={}),this.sharedWithDevices[e][t]={deviceKey:r,messageIndex:i}}markNotifiedBlockedDevice(e,t){this.blockedDevicesNotified[e]||(this.blockedDevicesNotified[e]={}),this.blockedDevicesNotified[e][t]=!0}sharedWithTooManyDevices(e){for(const t in this.sharedWithDevices)if(!!this.sharedWithDevices.hasOwnProperty(t)){if(!e.hasOwnProperty(t))return H.logger.log("Starting new megolm session because we shared with "+t),!0;for(const r in this.sharedWithDevices[t])if(!!this.sharedWithDevices[t].hasOwnProperty(r)&&!e[t].hasOwnProperty(r))return H.logger.log("Starting new megolm session because we shared with "+t+":"+r),!0}}}class SC extends Wn.EncryptionAlgorithm{constructor(e){var t,r,i,s;super(e);(0,xr.default)(this,"setupPromise",Promise.resolve(void 0)),(0,xr.default)(this,"outboundSessions",{}),(0,xr.default)(this,"sessionRotationPeriodMsgs",void 0),(0,xr.default)(this,"sessionRotationPeriodMs",void 0),(0,xr.default)(this,"encryptionPreparation",void 0),(0,xr.default)(this,"encryptionPreparationMetadata",void 0),this.sessionRotationPeriodMsgs=(t=(r=e.config)===null||r===void 0?void 0:r.rotation_period_msgs)!==null&&t!==void 0?t:100,this.sessionRotationPeriodMs=(i=(s=e.config)===null||s===void 0?void 0:s.rotation_period_ms)!==null&&i!==void 0?i:7*24*3600*1e3}async ensureOutboundSession(e,t,r,i=!1){let s;const o=async u=>{s=u;const c=c_(e);s&&c!==s.sharedHistory&&(s=null),s&&s.needsRotation(this.sessionRotationPeriodMsgs,this.sessionRotationPeriodMs)&&(H.logger.log("Starting new megolm session because we need to rotate."),s=null),s&&s.sharedWithTooManyDevices(t)&&(s=null),s||(H.logger.log(`Starting new megolm session for room ${this.roomId}`),s=await this.prepareNewSession(c),H.logger.log(`Started new megolm session ${s.sessionId} for room ${this.roomId}`),this.outboundSessions[s.sessionId]=s);const g={};for(const[w,k]of Object.entries(t))for(const[C,S]of Object.entries(k))S.getIdentityKey()!=this.olmDevice.deviceCurve25519Key&&(!s.sharedWithDevices[w]||s.sharedWithDevices[w][C]===void 0)&&(g[w]=g[w]||[],g[w].push(S));const m=this.olmDevice.getOutboundGroupSessionKey(s.sessionId),f={type:"m.room_key",content:{algorithm:et.MEGOLM_ALGORITHM,room_id:this.roomId,session_id:s.sessionId,session_key:m.key,chain_index:m.chain_index,"org.matrix.msc3061.shared_history":c}},[E,I]=await et.getExistingOlmSessions(this.olmDevice,this.baseApis,g);await Promise.all([(async()=>{H.logger.debug(`Sharing keys with existing Olm sessions in ${this.roomId}`,I),await this.shareKeyWithOlmSessions(s,m,f,I),H.logger.debug(`Shared keys with existing Olm sessions in ${this.roomId}`)})(),(async()=>{H.logger.debug(`Sharing keys (start phase 1) with new Olm sessions in ${this.roomId}`,E);const w=[],k=Date.now(),C=[];await this.shareKeyWithDevices(s,m,f,E,w,i?1e4:2e3,C),H.logger.debug(`Shared keys (end phase 1) with new Olm sessions in ${this.roomId}`),!i&&Date.now()-k<1e4?(async()=>{const S={},T=new Set;for(const R of C)T.add(R);const D=[];for(const{userId:R,deviceInfo:U}of w){const q=R.slice(R.indexOf(":")+1);T.has(q)?(S[R]=S[R]||[],S[R].push(U)):D.push({userId:R,deviceInfo:U})}H.logger.debug(`Sharing keys (start phase 2) with new Olm sessions in ${this.roomId}`),await this.shareKeyWithDevices(s,m,f,S,D,3e4),H.logger.debug(`Shared keys (end phase 2) with new Olm sessions in ${this.roomId}`),await this.notifyFailedOlmDevices(s,m,D)})():await this.notifyFailedOlmDevices(s,m,w),H.logger.debug(`Shared keys (all phases done) with new Olm sessions in ${this.roomId}`)})(),(async()=>{H.logger.debug(`There are ${Object.entries(r).length} blocked devices in ${this.roomId}`,Object.entries(r)),H.logger.debug(`Notifying newly blocked devices in ${this.roomId}`);const w={};let k=0;for(const[C,S]of Object.entries(r))for(const[T,D]of Object.entries(S))(!s.blockedDevicesNotified[C]||s.blockedDevicesNotified[C][T]===void 0)&&(w[C]=w[C]||{},w[C][T]={device:D},k++);await this.notifyBlockedDevices(s,w),H.logger.debug(`Notified ${k} newly blocked devices in ${this.roomId}`,w)})()])};function a(){return s}const l=this.setupPromise.then(o);return l.catch(u=>{H.logger.error(`Failed to ensure outbound session in ${this.roomId}`,u)}),this.setupPromise=l.then(a,a),l.then(a)}async prepareNewSession(e){const t=this.olmDevice.createOutboundGroupSession(),r=this.olmDevice.getOutboundGroupSessionKey(t);return await this.olmDevice.addInboundGroupSession(this.roomId,this.olmDevice.deviceCurve25519Key,[],t,r.key,{ed25519:this.olmDevice.deviceEd25519Key},!1,{sharedHistory:e}),this.crypto.backupManager.backupGroupSession(this.olmDevice.deviceCurve25519Key,t),new EC(t,e)}getDevicesWithoutSessions(e,t,r=[]){for(const[i,s]of Object.entries(t)){const o=e[i];for(const a of s){const l=a.deviceId;if(!o[l].sessionId){r.push({userId:i,deviceInfo:a}),delete o[l];continue}}}return r}splitDevices(e){let r=[];const i=[r];for(const[s,o]of Object.entries(e)){for(const a of Object.values(o))r.push({userId:s,deviceInfo:a.device});r.length>20&&(r=[],i.push(r))}return r.length===0&&i.pop(),i}encryptAndSendKeysToDevices(e,t,r,i){const s={},o=new Map,a=[];for(let l=0;l<r.length;l++){const u={algorithm:et.OLM_ALGORITHM,sender_key:this.olmDevice.deviceCurve25519Key,ciphertext:{}},c=r[l],g=c.userId,m=c.deviceInfo,f=m.deviceId;o.set(f,m),s[g]||(s[g]={}),s[g][f]=u,a.push(et.encryptMessageForDevice(u.ciphertext,this.userId,this.deviceId,this.olmDevice,g,m,i))}return Promise.all(a).then(()=>{for(const l of Object.keys(s)){for(const u of Object.keys(s[l]))Object.keys(s[l][u].ciphertext).length===0&&(H.logger.log("No ciphertext for device "+l+":"+u+": pruning"),delete s[l][u]);Object.keys(s[l]).length===0&&(H.logger.log("Pruned all devices for user "+l),delete s[l])}if(Object.keys(s).length===0){H.logger.log("No users left to send to: aborting");return}return this.baseApis.sendToDevice("m.room.encrypted",s).then(()=>{for(const l of Object.keys(s))for(const u of Object.keys(s[l]))e.markSharedWithDevice(l,u,o.get(u).getIdentityKey(),t)})})}async sendBlockedNotificationsToDevices(e,t,r){const i={};for(const s of t){const o=s.userId,a=s.deviceInfo,u=a.deviceInfo.deviceId,c=Object.assign({},r);c.code=a.code,c.reason=a.reason,c.code==="m.no_olm"&&(delete c.room_id,delete c.session_id),i[o]||(i[o]={}),i[o][u]=c}await this.baseApis.sendToDevice("org.matrix.room_key.withheld",i),await this.baseApis.sendToDevice("m.room_key.withheld",i);for(const s of Object.keys(i))for(const o of Object.keys(i[s]))e.markNotifiedBlockedDevice(s,o)}async reshareKeyWithDevice(e,t,r,i){const s=this.outboundSessions[t];if(!s){H.logger.debug(`megolm session ${t} not found: not re-sharing keys`);return}if(s.sharedWithDevices[r]===void 0){H.logger.debug(`megolm session ${t} never shared with user ${r}`);return}const o=s.sharedWithDevices[r][i.deviceId];if(o===void 0){H.logger.debug("megolm session ID "+t+" never shared with device "+r+":"+i.deviceId);return}if(o.deviceKey!==i.getIdentityKey()){H.logger.warn(`Session has been shared with device ${i.deviceId} but with identity key ${o.deviceKey}. Key is now ${i.getIdentityKey()}!`);return}const a=await this.olmDevice.getInboundGroupSessionKey(this.roomId,e,t,o.messageIndex);if(!a){H.logger.warn(`No inbound session key found for megolm ${t}: not re-sharing keys`);return}await et.ensureOlmSessionsForDevices(this.olmDevice,this.baseApis,{[r]:[i]});const l={type:"m.forwarded_room_key",content:{algorithm:et.MEGOLM_ALGORITHM,room_id:this.roomId,session_id:t,session_key:a.key,chain_index:a.chain_index,sender_key:e,sender_claimed_ed25519_key:a.sender_claimed_ed25519_key,forwarding_curve25519_key_chain:a.forwarding_curve25519_key_chain,"org.matrix.msc3061.shared_history":a.shared_history||!1}},u={algorithm:et.OLM_ALGORITHM,sender_key:this.olmDevice.deviceCurve25519Key,ciphertext:{}};await et.encryptMessageForDevice(u.ciphertext,this.userId,this.deviceId,this.olmDevice,r,i,l),await this.baseApis.sendToDevice("m.room.encrypted",{[r]:{[i.deviceId]:u}}),H.logger.debug(`Re-shared key for megolm session ${t} with ${r}:${i.deviceId}`)}async shareKeyWithDevices(e,t,r,i,s,o,a){H.logger.debug(`Ensuring Olm sessions for devices in ${this.roomId}`);const l=await et.ensureOlmSessionsForDevices(this.olmDevice,this.baseApis,i,!1,o,a,H.logger.withPrefix(`[${this.roomId}]`));H.logger.debug(`Ensured Olm sessions for devices in ${this.roomId}`),this.getDevicesWithoutSessions(l,i,s),H.logger.debug(`Sharing keys with newly created Olm sessions in ${this.roomId}`),await this.shareKeyWithOlmSessions(e,t,r,l),H.logger.debug(`Shared keys with newly created Olm sessions in ${this.roomId}`)}async shareKeyWithOlmSessions(e,t,r,i){const s=this.splitDevices(i);for(let o=0;o<s.length;o++){const a=`megolm keys for ${e.sessionId} in ${this.roomId} (slice ${o+1}/${s.length})`;try{H.logger.debug(`Sharing ${a}`,s[o].map(l=>`${l.userId}/${l.deviceInfo.deviceId}`)),await this.encryptAndSendKeysToDevices(e,t.chain_index,s[o],r),H.logger.debug(`Shared ${a}`)}catch(l){throw H.logger.error(`Failed to share ${a}`),l}}}async notifyFailedOlmDevices(e,t,r){H.logger.debug(`Notifying ${r.length} devices we failed to create Olm sessions in ${this.roomId}`);for(const{userId:o,deviceInfo:a}of r){const l=a.deviceId;e.markSharedWithDevice(o,l,a.getIdentityKey(),t.chain_index)}const i=await this.olmDevice.filterOutNotifiedErrorDevices(r);H.logger.debug(`Need to notify ${i.length} failed devices which haven't been notified before in ${this.roomId}`);const s={};for(const{userId:o,deviceInfo:a}of i)s[o]=s[o]||{},s[o][a.deviceId]={device:{code:"m.no_olm",reason:Fg.WITHHELD_MESSAGES["m.no_olm"],deviceInfo:a}};await this.notifyBlockedDevices(e,s),H.logger.debug(`Notified ${i.length} devices we failed to create Olm sessions in ${this.roomId}`)}async notifyBlockedDevices(e,t){const r={room_id:this.roomId,session_id:e.sessionId,algorithm:et.MEGOLM_ALGORITHM,sender_key:this.olmDevice.deviceCurve25519Key},i=this.splitDevices(t);for(let s=0;s<i.length;s++)try{await this.sendBlockedNotificationsToDevices(e,i[s],r),H.logger.log(`Completed blacklist notification for ${e.sessionId} in ${this.roomId} (slice ${s+1}/${i.length})`)}catch(o){throw H.logger.log(`blacklist notification for ${e.sessionId} in ${this.roomId} (slice ${s+1}/${i.length}) failed`),o}}prepareToEncrypt(e){if(this.encryptionPreparation){const t=Date.now()-this.encryptionPreparationMetadata.startTime;H.logger.debug(`Already started preparing to encrypt for ${this.roomId} ${t} ms ago, skipping`);return}H.logger.debug(`Preparing to encrypt events for ${this.roomId}`),this.encryptionPreparationMetadata={startTime:Date.now()},this.encryptionPreparation=(async()=>{try{H.logger.debug(`Getting devices in ${this.roomId}`);const[t,r]=await this.getDevicesInRoom(e);this.crypto.getGlobalErrorOnUnknownDevices()&&this.removeUnknownDevices(t),H.logger.debug(`Ensuring outbound session in ${this.roomId}`),await this.ensureOutboundSession(e,t,r,!0),H.logger.debug(`Ready to encrypt events for ${this.roomId}`)}catch(t){H.logger.error(`Failed to prepare to encrypt events for ${this.roomId}`,t)}finally{delete this.encryptionPreparationMetadata,delete this.encryptionPreparation}})()}async encryptMessage(e,t,r){if(H.logger.log(`Starting to encrypt event for ${this.roomId}`),this.encryptionPreparation)try{await this.encryptionPreparation}catch{}const[i,s]=await this.getDevicesInRoom(e);this.crypto.getGlobalErrorOnUnknownDevices()&&this.checkForUnknownDevices(i);const o=await this.ensureOutboundSession(e,i,s),a={room_id:this.roomId,type:t,content:r},l=this.olmDevice.encryptGroupMessage(o.sessionId,JSON.stringify(a)),u={algorithm:et.MEGOLM_ALGORITHM,sender_key:this.olmDevice.deviceCurve25519Key,ciphertext:l,session_id:o.sessionId,device_id:this.deviceId};return o.useCount++,u}forceDiscardSession(){this.setupPromise=this.setupPromise.then(()=>null)}checkForUnknownDevices(e){const t={};if(Object.keys(e).forEach(r=>{Object.keys(e[r]).forEach(i=>{const s=e[r][i];s.isUnverified()&&!s.isKnown()&&(t[r]||(t[r]={}),t[r][i]=s)})}),Object.keys(t).length)throw new Wn.UnknownDeviceError("This room contains unknown devices which have not been verified. We strongly recommend you verify them before continuing.",t)}removeUnknownDevices(e){for(const[t,r]of Object.entries(e)){for(const[i,s]of Object.entries(r))s.isUnverified()&&!s.isKnown()&&delete r[i];Object.keys(r).length===0&&delete e[t]}}async getDevicesInRoom(e){const r=(await e.getEncryptionTargetMembers()).map(function(a){return a.userId});let i=this.crypto.getGlobalBlacklistUnverifiedDevices();typeof e.getBlacklistUnverifiedDevices()=="boolean"&&(i=e.getBlacklistUnverifiedDevices());const s=await this.crypto.downloadKeys(r,!1),o={};for(const a in s){if(!s.hasOwnProperty(a))continue;const l=s[a];for(const u in l){if(!l.hasOwnProperty(u))continue;const c=this.crypto.checkDeviceTrust(a,u);if(l[u].isBlocked()||!c.isVerified()&&i){o[a]||(o[a]={});const g=l[u].isBlocked();o[a][u]={code:g?"m.blacklisted":"m.unverified",reason:Fg.WITHHELD_MESSAGES[g?"m.blacklisted":"m.unverified"],deviceInfo:l[u]},delete l[u]}}}return[s,o]}}class bC extends Wn.DecryptionAlgorithm{constructor(...e){super(...e);(0,xr.default)(this,"pendingEvents",{}),(0,xr.default)(this,"olmlib",et)}async decryptEvent(e){const t=e.getWireContent();if(!t.sender_key||!t.session_id||!t.ciphertext)throw new Wn.DecryptionError("MEGOLM_MISSING_FIELDS","Missing fields in input");this.addEventToPendingList(e);let r;try{r=await this.olmDevice.decryptGroupMessage(e.getRoomId(),t.sender_key,t.session_id,t.ciphertext,e.getId(),e.getTs())}catch(s){if(s.name==="DecryptionError")throw s;let o="OLM_DECRYPT_GROUP_MESSAGE_ERROR";throw s&&s.message==="OLM.UNKNOWN_MESSAGE_INDEX"&&(this.requestKeysForEvent(e),o="OLM_UNKNOWN_MESSAGE_INDEX"),new Wn.DecryptionError(o,s?s.toString():"Unknown Error: Error is undefined",{session:t.sender_key+"|"+t.session_id})}if(r===null){this.requestKeysForEvent(e);const s=await this.olmDevice.sessionMayHaveProblems(t.sender_key,e.getTs()-12e4);if(s){let o=qg[s.type]||qg.unknown;throw s.fixed&&(o+=" Trying to create a new secure channel and re-requesting the keys."),new Wn.DecryptionError("MEGOLM_UNKNOWN_INBOUND_SESSION_ID",o,{session:t.sender_key+"|"+t.session_id})}throw new Wn.DecryptionError("MEGOLM_UNKNOWN_INBOUND_SESSION_ID","The sender's device has not sent us the keys for this message.",{session:t.sender_key+"|"+t.session_id})}this.removeEventFromPendingList(e);const i=JSON.parse(r.result);if(i.room_id!==e.getRoomId())throw new Wn.DecryptionError("MEGOLM_BAD_ROOM","Message intended for room "+i.room_id);return{clearEvent:i,senderCurve25519Key:r.senderKey,claimedEd25519Key:r.keysClaimed.ed25519,forwardingCurve25519KeyChain:r.forwardingCurve25519KeyChain,untrusted:r.untrusted}}requestKeysForEvent(e){const t=e.getWireContent(),r=e.getKeyRequestRecipients(this.userId);this.crypto.requestRoomKey({room_id:e.getRoomId(),algorithm:t.algorithm,sender_key:t.sender_key,session_id:t.session_id},r)}addEventToPendingList(e){const t=e.getWireContent(),r=t.sender_key,i=t.session_id;this.pendingEvents[r]||(this.pendingEvents[r]=new Map);const s=this.pendingEvents[r];s.has(i)||s.set(i,new Set),s.get(i).add(e)}removeEventFromPendingList(e){const t=e.getWireContent(),r=t.sender_key,i=t.session_id,s=this.pendingEvents[r],o=s==null?void 0:s.get(i);!o||(o.delete(e),o.size===0&&s.delete(i),s.size===0&&delete this.pendingEvents[r])}onRoomKeyEvent(e){const t=e.getContent(),r=t.session_id;let i=e.getSenderKey(),s=[],o=!1,a;if(!t.room_id||!r||!t.session_key){H.logger.error("key event is missing fields");return}if(!i){H.logger.error("key event has no sender key (not encrypted?)");return}if(e.getType()=="m.forwarded_room_key"){if(o=!0,s=t.forwarding_curve25519_key_chain,Array.isArray(s)||(s=[]),s=s.slice(),s.push(i),i=t.sender_key,!i){H.logger.error("forwarded_room_key event is missing sender_key field");return}const u=t.sender_claimed_ed25519_key;if(!u){H.logger.error("forwarded_room_key_event is missing sender_claimed_ed25519_key field");return}a={ed25519:u}}else a=e.getKeysClaimed();const l={};return t["org.matrix.msc3061.shared_history"]&&(l.sharedHistory=!0),this.olmDevice.addInboundGroupSession(t.room_id,i,s,r,t.session_key,a,o,l).then(()=>{this.retryDecryption(i,r).then(u=>{u&&this.crypto.cancelRoomKeyRequest({algorithm:t.algorithm,room_id:t.room_id,session_id:t.session_id,sender_key:i})})}).then(()=>{this.crypto.backupManager.backupGroupSession(i,t.session_id)}).catch(u=>{H.logger.error(`Error handling m.room_key_event: ${u}`)})}async onRoomKeyWithheldEvent(e){const t=e.getContent(),r=t.sender_key;if(t.code==="m.no_olm"){const i=e.getSender();if(H.logger.warn(`${i}:${r} was unable to establish an olm session with us`),await this.olmDevice.getSessionIdForDevice(r)){H.logger.debug("New session already created. Not creating a new one."),await this.olmDevice.recordSessionProblem(r,"no_olm",!0),this.retryDecryptionFromSender(r);return}let s=this.crypto.deviceList.getDeviceByIdentityKey(t.algorithm,r);if(!s&&(await this.crypto.downloadKeys([i],!1),s=this.crypto.deviceList.getDeviceByIdentityKey(t.algorithm,r),!s)){H.logger.info("Couldn't find device for identity key "+r+": not establishing session"),await this.olmDevice.recordSessionProblem(r,"no_olm",!1),this.retryDecryptionFromSender(r);return}await et.ensureOlmSessionsForDevices(this.olmDevice,this.baseApis,{[i]:[s]},!1);const o={algorithm:et.OLM_ALGORITHM,sender_key:this.olmDevice.deviceCurve25519Key,ciphertext:{}};await et.encryptMessageForDevice(o.ciphertext,this.userId,void 0,this.olmDevice,i,s,{type:"m.dummy"}),await this.olmDevice.recordSessionProblem(r,"no_olm",!0),this.retryDecryptionFromSender(r),await this.baseApis.sendToDevice("m.room.encrypted",{[i]:{[s.deviceId]:o}})}else await this.olmDevice.addInboundGroupSessionWithheld(t.room_id,r,t.session_id,t.code,t.reason)}hasKeysForKeyRequest(e){const t=e.requestBody;return this.olmDevice.hasInboundSessionKeys(t.room_id,t.sender_key,t.session_id)}shareKeysWithDevice(e){const t=e.userId,r=e.deviceId,i=this.crypto.getStoredDevice(t,r),s=e.requestBody;this.olmlib.ensureOlmSessionsForDevices(this.olmDevice,this.baseApis,{[t]:[i]}).then(o=>o[t][r].sessionId?(H.logger.log("sharing keys for session "+s.sender_key+"|"+s.session_id+" with device "+t+":"+r),this.buildKeyForwardingMessage(s.room_id,s.sender_key,s.session_id)):null).then(o=>{const a={algorithm:et.OLM_ALGORITHM,sender_key:this.olmDevice.deviceCurve25519Key,ciphertext:{}};return this.olmlib.encryptMessageForDevice(a.ciphertext,this.userId,void 0,this.olmDevice,t,i,o).then(()=>{const l={[t]:{[r]:a}};return this.baseApis.sendToDevice("m.room.encrypted",l)})})}async buildKeyForwardingMessage(e,t,r){const i=await this.olmDevice.getInboundGroupSessionKey(e,t,r);return{type:"m.forwarded_room_key",content:{algorithm:et.MEGOLM_ALGORITHM,room_id:e,sender_key:t,sender_claimed_ed25519_key:i.sender_claimed_ed25519_key,session_id:r,session_key:i.key,chain_index:i.chain_index,forwarding_curve25519_key_chain:i.forwarding_curve25519_key_chain,"org.matrix.msc3061.shared_history":i.shared_history||!1}}}importRoomKey(e,t={}){const r={};return(t.untrusted||e.untrusted)&&(r.untrusted=!0),e["org.matrix.msc3061.shared_history"]&&(r.sharedHistory=!0),this.olmDevice.addInboundGroupSession(e.room_id,e.sender_key,e.forwarding_curve25519_key_chain,e.session_id,e.session_key,e.sender_claimed_keys,!0,r).then(()=>{t.source!=="backup"&&this.crypto.backupManager.backupGroupSession(e.sender_key,e.session_id).catch(i=>{H.logger.log("Failed to back up megolm session",i)}),this.retryDecryption(e.sender_key,e.session_id)})}async retryDecryption(e,t){var r;const i=this.pendingEvents[e];if(!i)return!0;const s=i.get(t);return s?(H.logger.debug("Retrying decryption on events",[...s]),await Promise.all([...s].map(async o=>{try{await o.attemptDecryption(this.crypto,{isRetry:!0})}catch{}})),!((r=this.pendingEvents[e])!==null&&r!==void 0&&r.has(t))):!0}async retryDecryptionFromSender(e){const t=this.pendingEvents[e];return t?(delete this.pendingEvents[e],await Promise.all([...t].map(async([r,i])=>{await Promise.all([...i].map(async s=>{try{await s.attemptDecryption(this.crypto)}catch{}}))})),!this.pendingEvents[e]):!0}async sendSharedHistoryInboundSessions(e){await et.ensureOlmSessionsForDevices(this.olmDevice,this.baseApis,e),H.logger.log("sendSharedHistoryInboundSessions to users",Object.keys(e));const t=await this.olmDevice.getSharedHistoryInboundGroupSessions(this.roomId);H.logger.log("shared-history sessions",t);for(const[r,i]of t){const s=await this.buildKeyForwardingMessage(this.roomId,r,i),o=[],a={};for(const[l,u]of Object.entries(e)){a[l]={};for(const c of u){const g={algorithm:et.OLM_ALGORITHM,sender_key:this.olmDevice.deviceCurve25519Key,ciphertext:{}};a[l][c.deviceId]=g,o.push(et.encryptMessageForDevice(g.ciphertext,this.userId,void 0,this.olmDevice,l,c,s))}}await Promise.all(o);for(const l of Object.keys(a)){for(const u of Object.keys(a[l]))Object.keys(a[l][u].ciphertext).length===0&&(H.logger.log("No ciphertext for device "+l+":"+u+": pruning"),delete a[l][u]);Object.keys(a[l]).length===0&&(H.logger.log("Pruned all devices for user "+l),delete a[l])}if(Object.keys(a).length===0){H.logger.log("No users left to send to: aborting");return}await this.baseApis.sendToDevice("m.room.encrypted",a)}}}const qg={no_olm:"The sender was unable to establish a secure channel.",unknown:"The secure channel with the sender was corrupted."};(0,Wn.registerAlgorithm)(et.MEGOLM_ALGORITHM,SC,bC);(function(n){Object.defineProperty(n,"__esModule",{value:!0});var e=_t;Object.keys(e).forEach(function(t){t==="default"||t==="__esModule"||t in n&&n[t]===e[t]||Object.defineProperty(n,t,{enumerable:!0,get:function(){return e[t]}})})})(Rf);var wC=G.exports;Object.defineProperty(Es,"__esModule",{value:!0});Es.WITHHELD_MESSAGES=Es.OlmDevice=void 0;var Ri=wC(Y.exports),rt=se,be=Br,jg=RC(Rf);function l_(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(l_=function(r){return r?t:e})(n)}function RC(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=l_(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}const Vg=65536*3/4;function Gg(n){if(n===void 0)throw new Error("payloadString undefined");if(n.length>Vg){const e=new Error("Message too long ("+n.length+" bytes). The maximum for an encrypted message is "+Vg+" bytes.");throw e.data={errcode:"M_TOO_LARGE",error:"Payload too large for encrypted message"},e}}class IC{constructor(e){this.cryptoStore=e,(0,Ri.default)(this,"pickleKey","DEFAULT_KEY"),(0,Ri.default)(this,"deviceCurve25519Key",null),(0,Ri.default)(this,"deviceEd25519Key",null),(0,Ri.default)(this,"maxOneTimeKeys",null),(0,Ri.default)(this,"outboundGroupSessionStore",{}),(0,Ri.default)(this,"inboundGroupSessionMessageIndexes",{}),(0,Ri.default)(this,"sessionsInProgress",{}),(0,Ri.default)(this,"olmPrekeyPromise",Promise.resolve())}static getOlmVersion(){return V.Olm.get_library_version()}async init({pickleKey:e,fromExportedDevice:t}={}){let r;const i=new V.Olm.Account;try{t?(e&&rt.logger.warn("ignoring opts.pickleKey because opts.fromExportedDevice is present."),this.pickleKey=t.pickleKey,await this.initialiseFromExportedDevice(t,i)):(e&&(this.pickleKey=e),await this.initialiseAccount(i)),r=JSON.parse(i.identity_keys()),this.maxOneTimeKeys=i.max_number_of_one_time_keys()}finally{i.free()}this.deviceCurve25519Key=r.curve25519,this.deviceEd25519Key=r.ed25519}async initialiseFromExportedDevice(e,t){await this.cryptoStore.doTxn("readwrite",[be.IndexedDBCryptoStore.STORE_ACCOUNT,be.IndexedDBCryptoStore.STORE_SESSIONS],r=>{this.cryptoStore.storeAccount(r,e.pickledAccount),e.sessions.forEach(i=>{const{deviceKey:s,sessionId:o}=i,a={session:i.session,lastReceivedMessageTs:i.lastReceivedMessageTs};this.cryptoStore.storeEndToEndSession(s,o,a,r)})}),t.unpickle(this.pickleKey,e.pickledAccount)}async initialiseAccount(e){await this.cryptoStore.doTxn("readwrite",[be.IndexedDBCryptoStore.STORE_ACCOUNT],t=>{this.cryptoStore.getAccount(t,r=>{r!==null?e.unpickle(this.pickleKey,r):(e.create(),r=e.pickle(this.pickleKey),this.cryptoStore.storeAccount(t,r))})})}getAccount(e,t){this.cryptoStore.getAccount(e,r=>{const i=new V.Olm.Account;try{i.unpickle(this.pickleKey,r),t(i)}finally{i.free()}})}storeAccount(e,t){this.cryptoStore.storeAccount(e,t.pickle(this.pickleKey))}async export(){const e={pickleKey:this.pickleKey};return await this.cryptoStore.doTxn("readonly",[be.IndexedDBCryptoStore.STORE_ACCOUNT,be.IndexedDBCryptoStore.STORE_SESSIONS],t=>{this.cryptoStore.getAccount(t,r=>{e.pickledAccount=r}),e.sessions=[],this.cryptoStore.getAllEndToEndSessions(t,r=>{e.sessions.push(r)})}),e}getSession(e,t,r,i){this.cryptoStore.getEndToEndSession(e,t,r,s=>{this.unpickleSession(s,i)})}unpickleSession(e,t){const r=new V.Olm.Session;try{r.unpickle(this.pickleKey,e.session);const i=Object.assign({},e,{session:r});t(i)}finally{r.free()}}saveSession(e,t,r){const i=t.session.session_id(),s=Object.assign(t,{session:t.session.pickle(this.pickleKey)});this.cryptoStore.storeEndToEndSession(e,i,s,r)}getUtility(e){const t=new V.Olm.Utility;try{return e(t)}finally{t.free()}}async sign(e){let t;return await this.cryptoStore.doTxn("readonly",[be.IndexedDBCryptoStore.STORE_ACCOUNT],r=>{this.getAccount(r,i=>{t=i.sign(e)})}),t}async getOneTimeKeys(){let e;return await this.cryptoStore.doTxn("readonly",[be.IndexedDBCryptoStore.STORE_ACCOUNT],t=>{this.getAccount(t,r=>{e=JSON.parse(r.one_time_keys())})}),e}maxNumberOfOneTimeKeys(){return this.maxOneTimeKeys}async markKeysAsPublished(){await this.cryptoStore.doTxn("readwrite",[be.IndexedDBCryptoStore.STORE_ACCOUNT],e=>{this.getAccount(e,t=>{t.mark_keys_as_published(),this.storeAccount(e,t)})})}generateOneTimeKeys(e){return this.cryptoStore.doTxn("readwrite",[be.IndexedDBCryptoStore.STORE_ACCOUNT],t=>{this.getAccount(t,r=>{r.generate_one_time_keys(e),this.storeAccount(t,r)})})}async generateFallbackKey(){await this.cryptoStore.doTxn("readwrite",[be.IndexedDBCryptoStore.STORE_ACCOUNT],e=>{this.getAccount(e,t=>{t.generate_fallback_key(),this.storeAccount(e,t)})})}async getFallbackKey(){let e;return await this.cryptoStore.doTxn("readonly",[be.IndexedDBCryptoStore.STORE_ACCOUNT],t=>{this.getAccount(t,r=>{e=JSON.parse(r.unpublished_fallback_key())})}),e}async forgetOldFallbackKey(){await this.cryptoStore.doTxn("readwrite",[be.IndexedDBCryptoStore.STORE_ACCOUNT],e=>{this.getAccount(e,t=>{t.forget_old_fallback_key(),this.storeAccount(e,t)})})}async createOutboundSession(e,t){let r;return await this.cryptoStore.doTxn("readwrite",[be.IndexedDBCryptoStore.STORE_ACCOUNT,be.IndexedDBCryptoStore.STORE_SESSIONS],i=>{this.getAccount(i,s=>{const o=new V.Olm.Session;try{o.create_outbound(s,e,t),r=o.session_id(),this.storeAccount(i,s);const a={session:o,lastReceivedMessageTs:Date.now()};this.saveSession(e,a,i)}finally{o.free()}})},rt.logger.withPrefix("[createOutboundSession]")),r}async createInboundSession(e,t,r){if(t!==0)throw new Error("Need messageType == 0 to create inbound session");let i;return await this.cryptoStore.doTxn("readwrite",[be.IndexedDBCryptoStore.STORE_ACCOUNT,be.IndexedDBCryptoStore.STORE_SESSIONS],s=>{this.getAccount(s,o=>{const a=new V.Olm.Session;try{a.create_inbound_from(o,e,r),o.remove_one_time_keys(a),this.storeAccount(s,o);const l=a.decrypt(t,r),u={session:a,lastReceivedMessageTs:Date.now()};this.saveSession(e,u,s),i={payload:l,session_id:a.session_id()}}finally{a.free()}})},rt.logger.withPrefix("[createInboundSession]")),i}async getSessionIdsForDevice(e){const t=rt.logger.withPrefix("[getSessionIdsForDevice]");if(this.sessionsInProgress[e]){t.debug(`Waiting for Olm session for ${e} to be created`);try{await this.sessionsInProgress[e]}catch{}}let r;return await this.cryptoStore.doTxn("readonly",[be.IndexedDBCryptoStore.STORE_SESSIONS],i=>{this.cryptoStore.getEndToEndSessions(e,i,s=>{r=Object.keys(s)})},t),r}async getSessionIdForDevice(e,t=!1,r){const i=await this.getSessionInfoForDevice(e,t,r);if(i.length===0)return null;let s=0;for(let o=1;o<i.length;o++){const a=i[o],l=a.lastReceivedMessageTs===void 0?0:a.lastReceivedMessageTs,u=i[s],c=u.lastReceivedMessageTs===void 0?0:u.lastReceivedMessageTs;(l>c||l===c&&a.sessionId<u.sessionId)&&(s=o)}return i[s].sessionId}async getSessionInfoForDevice(e,t=!1,r=rt.logger){if(r=r.withPrefix("[getSessionInfoForDevice]"),this.sessionsInProgress[e]&&!t){r.debug(`Waiting for Olm session for ${e} to be created`);try{await this.sessionsInProgress[e]}catch{}}const i=[];return await this.cryptoStore.doTxn("readonly",[be.IndexedDBCryptoStore.STORE_SESSIONS],s=>{this.cryptoStore.getEndToEndSessions(e,s,o=>{const a=Object.keys(o).sort();for(const l of a)this.unpickleSession(o[l],u=>{i.push({lastReceivedMessageTs:u.lastReceivedMessageTs,hasReceivedMessage:u.session.has_received_message(),sessionId:l})})})},r),i}async encryptMessage(e,t,r){Gg(r);let i;return await this.cryptoStore.doTxn("readwrite",[be.IndexedDBCryptoStore.STORE_SESSIONS],s=>{this.getSession(e,t,s,o=>{const a=o.session.describe();rt.logger.log("encryptMessage: Olm Session ID "+t+" to "+e+": "+a),i=o.session.encrypt(r),this.saveSession(e,o,s)})},rt.logger.withPrefix("[encryptMessage]")),i}async decryptMessage(e,t,r,i){let s;return await this.cryptoStore.doTxn("readwrite",[be.IndexedDBCryptoStore.STORE_SESSIONS],o=>{this.getSession(e,t,o,a=>{const l=a.session.describe();rt.logger.log("decryptMessage: Olm Session ID "+t+" from "+e+": "+l),s=a.session.decrypt(r,i),a.lastReceivedMessageTs=Date.now(),this.saveSession(e,a,o)})},rt.logger.withPrefix("[decryptMessage]")),s}async matchesSession(e,t,r,i){if(r!==0)return!1;let s;return await this.cryptoStore.doTxn("readonly",[be.IndexedDBCryptoStore.STORE_SESSIONS],o=>{this.getSession(e,t,o,a=>{s=a.session.matches_inbound(i)})},rt.logger.withPrefix("[matchesSession]")),s}async recordSessionProblem(e,t,r){await this.cryptoStore.storeEndToEndSessionProblem(e,t,r)}async sessionMayHaveProblems(e,t){return await this.cryptoStore.getEndToEndSessionProblem(e,t)}async filterOutNotifiedErrorDevices(e){return await this.cryptoStore.filterOutNotifiedErrorDevices(e)}saveOutboundGroupSession(e){this.outboundGroupSessionStore[e.session_id()]=e.pickle(this.pickleKey)}getOutboundGroupSession(e,t){const r=this.outboundGroupSessionStore[e];if(r===void 0)throw new Error("Unknown outbound group session "+e);const i=new V.Olm.OutboundGroupSession;try{return i.unpickle(this.pickleKey,r),t(i)}finally{i.free()}}createOutboundGroupSession(){const e=new V.Olm.OutboundGroupSession;try{return e.create(),this.saveOutboundGroupSession(e),e.session_id()}finally{e.free()}}encryptGroupMessage(e,t){return rt.logger.log(`encrypting msg with megolm session ${e}`),Gg(t),this.getOutboundGroupSession(e,r=>{const i=r.encrypt(t);return this.saveOutboundGroupSession(r),i})}getOutboundGroupSessionKey(e){return this.getOutboundGroupSession(e,function(t){return{chain_index:t.message_index(),key:t.session_key()}})}unpickleInboundGroupSession(e,t){const r=new V.Olm.InboundGroupSession;try{return r.unpickle(this.pickleKey,e.session),t(r)}finally{r.free()}}getInboundGroupSession(e,t,r,i,s){this.cryptoStore.getEndToEndInboundGroupSession(t,r,i,(o,a)=>{if(o===null){s(null,null,a);return}if(e!==null&&e!==o.room_id)throw new Error("Mismatched room_id for inbound group session (expected "+o.room_id+", was "+e+")");this.unpickleInboundGroupSession(o,l=>{s(l,o,a)})})}async addInboundGroupSession(e,t,r,i,s,o,a,l={}){await this.cryptoStore.doTxn("readwrite",[be.IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS,be.IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS_WITHHELD,be.IndexedDBCryptoStore.STORE_SHARED_HISTORY_INBOUND_GROUP_SESSIONS],u=>{this.getInboundGroupSession(e,t,i,u,(c,g)=>{const m=new V.Olm.InboundGroupSession;try{if(a?m.import_session(s):m.create(s),i!=m.session_id())throw new Error("Mismatched group session ID from senderKey: "+t);if(c&&(rt.logger.log("Update for megolm session "+t+"/"+i),c.first_known_index()<=m.first_known_index()&&!(c.first_known_index()==m.first_known_index()&&!l.untrusted&&g.untrusted))){rt.logger.log(`Keeping existing megolm session ${i}`);return}rt.logger.info("Storing megolm session "+t+"/"+i+" with first index "+m.first_known_index());const f=Object.assign({},l,{room_id:e,session:m.pickle(this.pickleKey),keysClaimed:o,forwardingCurve25519KeyChain:r});this.cryptoStore.storeEndToEndInboundGroupSession(t,i,f,u),!c&&l.sharedHistory&&this.cryptoStore.addSharedHistoryInboundGroupSession(e,t,i,u)}finally{m.free()}})},rt.logger.withPrefix("[addInboundGroupSession]"))}async addInboundGroupSessionWithheld(e,t,r,i,s){await this.cryptoStore.doTxn("readwrite",[be.IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS_WITHHELD],o=>{this.cryptoStore.storeEndToEndInboundGroupSessionWithheld(t,r,{room_id:e,code:i,reason:s},o)})}async decryptGroupMessage(e,t,r,i,s,o){let a,l;if(await this.cryptoStore.doTxn("readwrite",[be.IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS,be.IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS_WITHHELD],u=>{this.getInboundGroupSession(e,t,r,u,(c,g,m)=>{if(c===null){m&&(l=new jg.DecryptionError("MEGOLM_UNKNOWN_INBOUND_SESSION_ID",Wg(m),{session:t+"|"+r})),a=null;return}let f;try{f=c.decrypt(i)}catch(I){I&&I.message==="OLM.UNKNOWN_MESSAGE_INDEX"&&m?l=new jg.DecryptionError("MEGOLM_UNKNOWN_INBOUND_SESSION_ID",Wg(m),{session:t+"|"+r}):l=I;return}let E=f.plaintext;if(E===void 0)E=f;else{const I=t+"|"+r+"|"+f.message_index;if(I in this.inboundGroupSessionMessageIndexes){const w=this.inboundGroupSessionMessageIndexes[I];if(w.id!==s||w.timestamp!==o){l=new Error("Duplicate message index, possible replay attack: "+I);return}}this.inboundGroupSessionMessageIndexes[I]={id:s,timestamp:o}}g.session=c.pickle(this.pickleKey),this.cryptoStore.storeEndToEndInboundGroupSession(t,r,g,u),a={result:E,keysClaimed:g.keysClaimed||{},senderKey:t,forwardingCurve25519KeyChain:g.forwardingCurve25519KeyChain||[],untrusted:g.untrusted}})},rt.logger.withPrefix("[decryptGroupMessage]")),l)throw l;return a}async hasInboundSessionKeys(e,t,r){let i;return await this.cryptoStore.doTxn("readonly",[be.IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS,be.IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS_WITHHELD],s=>{this.cryptoStore.getEndToEndInboundGroupSession(t,r,s,o=>{if(o===null){i=!1;return}e!==o.room_id?(rt.logger.warn(`requested keys for inbound group session ${t}|${r}, with incorrect room_id (expected ${o.room_id}, was ${e})`),i=!1):i=!0})},rt.logger.withPrefix("[hasInboundSessionKeys]")),i}async getInboundGroupSessionKey(e,t,r,i){let s;return await this.cryptoStore.doTxn("readonly",[be.IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS,be.IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS_WITHHELD],o=>{this.getInboundGroupSession(e,t,r,o,(a,l)=>{if(a===null){s=null;return}i===void 0&&(i=a.first_known_index());const u=a.export_session(i),g=(l.keysClaimed||{}).ed25519||null;s={chain_index:i,key:u,forwarding_curve25519_key_chain:l.forwardingCurve25519KeyChain||[],sender_claimed_ed25519_key:g,shared_history:l.sharedHistory||!1}})},rt.logger.withPrefix("[getInboundGroupSessionKey]")),s}exportInboundGroupSession(e,t,r){return this.unpickleInboundGroupSession(r,i=>{const s=i.first_known_index();return{sender_key:e,sender_claimed_keys:r.keysClaimed,room_id:r.room_id,session_id:t,session_key:i.export_session(s),forwarding_curve25519_key_chain:r.forwardingCurve25519KeyChain||[],first_known_index:i.first_known_index(),"org.matrix.msc3061.shared_history":r.sharedHistory||!1}})}async getSharedHistoryInboundGroupSessions(e){let t;return await this.cryptoStore.doTxn("readonly",[be.IndexedDBCryptoStore.STORE_SHARED_HISTORY_INBOUND_GROUP_SESSIONS],r=>{t=this.cryptoStore.getSharedHistoryInboundGroupSessions(e,r)},rt.logger.withPrefix("[getSharedHistoryInboundGroupSessionsForRoom]")),t}verifySignature(e,t,r){this.getUtility(function(i){i.ed25519_verify(e,t,r)})}}Es.OlmDevice=IC;const Mh={"m.unverified":"The sender has disabled encrypting to unverified devices.","m.blacklisted":"The sender has blocked you.","m.unauthorised":"You are not authorised to read the message.","m.no_olm":"Unable to establish a secure channel."};Es.WITHHELD_MESSAGES=Mh;function Wg(n){return n.code&&n.code in Mh?Mh[n.code]:n.reason?n.reason:"decryption key withheld"}var Ss={},Pt={},li={};Object.defineProperty(li,"__esModule",{value:!0});li.calculateKeyCheck=AC;li.decryptAES=PC;li.encryptAES=f_;var Tf=W,Sn=xe;const bn=typeof window!="undefined"&&window.crypto?window.crypto.subtle||window.crypto.webkitSubtle:null,u_=new Uint8Array(8);async function TC(n,e,t,r){const i=(0,Tf.getCrypto)();if(!i)throw new Error("No usable crypto implementation");let s;r?s=(0,Sn.decodeBase64)(r):(s=i.randomBytes(16),s[8]&=127);const[o,a]=d_(e,t),l=i.createCipheriv("aes-256-ctr",o,s),u=Buffer.concat([l.update(n,"utf8"),l.final()]),c=i.createHmac("sha256",a).update(u).digest("base64");return{iv:(0,Sn.encodeBase64)(s),ciphertext:u.toString("base64"),mac:c}}async function OC(n,e,t){const r=(0,Tf.getCrypto)();if(!r)throw new Error("No usable crypto implementation");const[i,s]=d_(e,t);if(r.createHmac("sha256",s).update(Buffer.from(n.ciphertext,"base64")).digest("base64").replace(/=+$/g,"")!==n.mac.replace(/=+$/g,""))throw new Error(`Error decrypting secret ${t}: bad MAC`);const a=r.createDecipheriv("aes-256-ctr",i,(0,Sn.decodeBase64)(n.iv));return a.update(n.ciphertext,"base64","utf8")+a.final("utf8")}function d_(n,e){const t=(0,Tf.getCrypto)(),r=t.createHmac("sha256",u_).update(n).digest(),i=Buffer.alloc(1,1),s=t.createHmac("sha256",r).update(e,"utf8").update(i).digest();i[0]=2;const o=t.createHmac("sha256",r).update(s).update(e,"utf8").update(i).digest();return[s,o]}async function kC(n,e,t,r){let i;r?i=(0,Sn.decodeBase64)(r):(i=new Uint8Array(16),window.crypto.getRandomValues(i),i[8]&=127);const[s,o]=await h_(e,t),a=new TextEncoder().encode(n),l=await bn.encrypt({name:"AES-CTR",counter:i,length:64},s,a),u=await bn.sign({name:"HMAC"},o,l);return{iv:(0,Sn.encodeBase64)(i),ciphertext:(0,Sn.encodeBase64)(l),mac:(0,Sn.encodeBase64)(u)}}async function CC(n,e,t){const[r,i]=await h_(e,t),s=(0,Sn.decodeBase64)(n.ciphertext);if(!await bn.verify({name:"HMAC"},i,(0,Sn.decodeBase64)(n.mac),s))throw new Error(`Error decrypting secret ${t}: bad MAC`);const o=await bn.decrypt({name:"AES-CTR",counter:(0,Sn.decodeBase64)(n.iv),length:64},r,s);return new TextDecoder().decode(new Uint8Array(o))}async function h_(n,e){const t=await bn.importKey("raw",n,{name:"HKDF"},!1,["deriveBits"]),r=await bn.deriveBits({name:"HKDF",salt:u_,info:new TextEncoder().encode(e),hash:"SHA-256"},t,512),i=r.slice(0,32),s=r.slice(32),o=bn.importKey("raw",i,{name:"AES-CTR"},!1,["encrypt","decrypt"]),a=bn.importKey("raw",s,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign","verify"]);return await Promise.all([o,a])}function f_(n,e,t,r){return bn?kC(n,e,t,r):TC(n,e,t,r)}function PC(n,e,t){return bn?CC(n,e,t):OC(n,e,t)}const MC="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";function AC(n,e){return f_(MC,n,"",e)}var DC=G.exports;Object.defineProperty(Pt,"__esModule",{value:!0});Pt.UserTrustLevel=Pt.DeviceTrustLevel=Pt.CrossSigningLevel=Pt.CrossSigningInfo=void 0;Pt.createCryptoStoreCacheCallbacks=$C;Pt.requestKeysDuringVerification=NC;var sd=DC(Y.exports),ir=xe,Kt=se,Hg=Br,Yg=li;const xC=1e3*60;function Ac(n){return Object.values(n.keys)[0]}class ou{constructor(e,t={},r={}){this.userId=e,this.callbacks=t,this.cacheCallbacks=r,(0,sd.default)(this,"keys",{}),(0,sd.default)(this,"firstUse",!0),(0,sd.default)(this,"crossSigningVerifiedBefore",!1)}static fromStorage(e,t){const r=new ou(t);for(const i in e)e.hasOwnProperty(i)&&(r[i]=e[i]);return r}toStorage(){return{keys:this.keys,firstUse:this.firstUse,crossSigningVerifiedBefore:this.crossSigningVerifiedBefore}}async getCrossSigningKey(e,t){const r=["master","self_signing","user_signing"].indexOf(e)>=0;if(!this.callbacks.getCrossSigningKey)throw new Error("No getCrossSigningKey callback supplied");t===void 0&&(t=this.getId(e));function i(l){if(!l)return;const u=new V.Olm.PkSigning,c=u.init_with_seed(l);if(c===t)return[c,u];u.free()}let s;this.cacheCallbacks.getCrossSigningKeyCache&&r&&(s=await this.cacheCallbacks.getCrossSigningKeyCache(e,t));const o=i(s);if(o)return o;s=await this.callbacks.getCrossSigningKey(e,t);const a=i(s);if(a)return this.cacheCallbacks.storeCrossSigningKeyCache&&r&&await this.cacheCallbacks.storeCrossSigningKeyCache(e,s),a;throw s?new Error("Key type "+e+" from getCrossSigningKey callback did not match"):new Error("getCrossSigningKey callback for "+e+" returned falsey")}async isStoredInSecretStorage(e){const t=await e.isStored("m.cross_signing.master",!1)||{};function r(i){for(const s of Object.keys(t))i[s]||delete t[s]}for(const i of["self_signing","user_signing"])r(await e.isStored(`m.cross_signing.${i}`,!1)||{});return Object.keys(t).length?t:null}static async storeInSecretStorage(e,t){for(const[r,i]of e){const s=(0,ir.encodeBase64)(i);await t.store(`m.cross_signing.${r}`,s)}}static async getFromSecretStorage(e,t){const r=await t.get(`m.cross_signing.${e}`);return r?(0,ir.decodeBase64)(r):null}async isStoredInKeyCache(e){const t=this.cacheCallbacks;if(!t)return!1;const r=e?[e]:["master","self_signing","user_signing"];for(const i of r)if(!await t.getCrossSigningKeyCache(i))return!1;return!0}async getCrossSigningKeysFromCache(){const e=new Map,t=this.cacheCallbacks;if(!t)return e;for(const r of["master","self_signing","user_signing"]){const i=await t.getCrossSigningKeyCache(r);!i||e.set(r,i)}return e}getId(e="master"){if(!this.keys[e])return null;const t=this.keys[e];return Ac(t)}async resetKeys(e){if(!this.callbacks.saveCrossSigningKeys)throw new Error("No saveCrossSigningKeys callback supplied");if(e===void 0||e&yn.MASTER||!this.keys.master)e=yn.MASTER|yn.USER_SIGNING|yn.SELF_SIGNING;else if(e===0)return;const t={},r={};let i,s;try{if(e&yn.MASTER?(i=new V.Olm.PkSigning,t.master=i.generate_seed(),s=i.init_with_seed(t.master),r.master={user_id:this.userId,usage:["master"],keys:{["ed25519:"+s]:s}}):[s,i]=await this.getCrossSigningKey("master"),e&yn.SELF_SIGNING){const o=new V.Olm.PkSigning;try{t.self_signing=o.generate_seed();const a=o.init_with_seed(t.self_signing);r.self_signing={user_id:this.userId,usage:["self_signing"],keys:{["ed25519:"+a]:a}},(0,ir.pkSign)(r.self_signing,i,this.userId,s)}finally{o.free()}}if(e&yn.USER_SIGNING){const o=new V.Olm.PkSigning;try{t.user_signing=o.generate_seed();const a=o.init_with_seed(t.user_signing);r.user_signing={user_id:this.userId,usage:["user_signing"],keys:{["ed25519:"+a]:a}},(0,ir.pkSign)(r.user_signing,i,this.userId,s)}finally{o.free()}}Object.assign(this.keys,r),this.callbacks.saveCrossSigningKeys(t)}finally{i&&i.free()}}clearKeys(){this.keys={}}setKeys(e){const t={};if(e.master){if(e.master.user_id!==this.userId){const i="Mismatched user ID "+e.master.user_id+" in master key from "+this.userId;throw Kt.logger.error(i),new Error(i)}this.keys.master?Ac(e.master)!==this.getId()&&(this.firstUse=!1):this.firstUse=!0,t.master=e.master}else if(this.keys.master)t.master=this.keys.master;else throw new Error("Tried to set cross-signing keys without a master key");const r=Ac(t.master);if(e.user_signing){if(e.user_signing.user_id!==this.userId){const i="Mismatched user ID "+e.master.user_id+" in user_signing key from "+this.userId;throw Kt.logger.error(i),new Error(i)}try{(0,ir.pkVerify)(e.user_signing,r,this.userId)}catch(i){throw Kt.logger.error("invalid signature on user-signing key"),i}}if(e.self_signing){if(e.self_signing.user_id!==this.userId){const i="Mismatched user ID "+e.master.user_id+" in self_signing key from "+this.userId;throw Kt.logger.error(i),new Error(i)}try{(0,ir.pkVerify)(e.self_signing,r,this.userId)}catch(i){throw Kt.logger.error("invalid signature on self-signing key"),i}}e.master&&(this.keys.master=e.master,this.keys.self_signing=null,this.keys.user_signing=null),e.self_signing&&(this.keys.self_signing=e.self_signing),e.user_signing&&(this.keys.user_signing=e.user_signing)}updateCrossSigningVerifiedBefore(e){!this.crossSigningVerifiedBefore&&e&&(this.crossSigningVerifiedBefore=!0)}async signObject(e,t){if(!this.keys[t])throw new Error("Attempted to sign with "+t+" key but no such key present");const[r,i]=await this.getCrossSigningKey(t);try{return(0,ir.pkSign)(e,i,this.userId,r),e}finally{i.free()}}async signUser(e){if(!this.keys.user_signing){Kt.logger.info("No user signing key: not signing user");return}return this.signObject(e.keys.master,"user_signing")}async signDevice(e,t){if(e!==this.userId)throw new Error(`Trying to sign ${e}'s device; can only sign our own device`);if(!this.keys.self_signing){Kt.logger.info("No self signing key: not signing device");return}return this.signObject({algorithms:t.algorithms,keys:t.keys,device_id:t.deviceId,user_id:e},"self_signing")}checkUserTrust(e){if(this.userId===e.userId&&this.getId()&&this.getId()===e.getId()&&this.getId("self_signing")&&this.getId("self_signing")===e.getId("self_signing"))return new ol(!0,!0,this.firstUse);if(!this.keys.user_signing)return new ol(!1,!1,e.firstUse);let t;const r=e.keys.master,i=this.getId("user_signing");try{(0,ir.pkVerify)(r,i,this.userId),t=!0}catch{t=!1}return new ol(t,e.crossSigningVerifiedBefore,e.firstUse)}checkDeviceTrust(e,t,r,i){const s=this.checkUserTrust(e),o=e.keys.self_signing;if(!o)return new _o(!1,!1,r,i);const a=UC(t,e.userId);try{return(0,ir.pkVerify)(o,e.getId(),e.userId),(0,ir.pkVerify)(a,Ac(o),e.userId),_o.fromUserTrustLevel(s,r,i)}catch{return new _o(!1,!1,r,i)}}getCacheCallbacks(){return this.cacheCallbacks}}Pt.CrossSigningInfo=ou;function UC(n,e){return{algorithms:n.algorithms,keys:n.keys,device_id:n.deviceId,user_id:e,signatures:n.signatures}}let yn;Pt.CrossSigningLevel=yn;(function(n){n[n.MASTER=4]="MASTER",n[n.USER_SIGNING=2]="USER_SIGNING",n[n.SELF_SIGNING=1]="SELF_SIGNING"})(yn||(Pt.CrossSigningLevel=yn={}));class ol{constructor(e,t,r){this.crossSigningVerified=e,this.crossSigningVerifiedBefore=t,this.tofu=r}isVerified(){return this.isCrossSigningVerified()}isCrossSigningVerified(){return this.crossSigningVerified}wasCrossSigningVerified(){return this.crossSigningVerifiedBefore}isTofu(){return this.tofu}}Pt.UserTrustLevel=ol;class _o{constructor(e,t,r,i){this.crossSigningVerified=e,this.tofu=t,this.localVerified=r,this.trustCrossSignedDevices=i}static fromUserTrustLevel(e,t,r){return new _o(e.isCrossSigningVerified(),e.isTofu(),t,r)}isVerified(){return Boolean(this.isLocallyVerified()||this.trustCrossSignedDevices&&this.isCrossSigningVerified())}isCrossSigningVerified(){return this.crossSigningVerified}isLocallyVerified(){return this.localVerified}isTofu(){return this.tofu}}Pt.DeviceTrustLevel=_o;function $C(n,e){return{getCrossSigningKeyCache:async function(t,r){const i=await new Promise(s=>n.doTxn("readonly",[Hg.IndexedDBCryptoStore.STORE_ACCOUNT],o=>{n.getSecretStorePrivateKey(o,s,t)}));if(i&&i.ciphertext){const s=Buffer.from(e.pickleKey),o=await(0,Yg.decryptAES)(i,s,t);return(0,ir.decodeBase64)(o)}else return i},storeCrossSigningKeyCache:async function(t,r){if(!(r instanceof Uint8Array))throw new Error(`storeCrossSigningKeyCache expects Uint8Array, got ${r}`);const i=Buffer.from(e.pickleKey),s=await(0,Yg.encryptAES)((0,ir.encodeBase64)(r),i,t);return n.doTxn("readwrite",[Hg.IndexedDBCryptoStore.STORE_ACCOUNT],o=>{n.storeSecretStorePrivateKey(o,t,s)})}}}function NC(n,e,t){if(n.getUserId()===e)return Kt.logger.log("Cross-signing: Self-verification done; requesting keys"),new Promise((r,i)=>{const s=n,o=s.crypto.crossSigningInfo,a=new ou(o.userId,{getCrossSigningKey:async c=>{Kt.logger.debug("Cross-signing: requesting secret",c,t);const{promise:g}=s.requestSecret(`m.cross_signing.${c}`,[t]),m=await g,f=(0,ir.decodeBase64)(m);return Uint8Array.from(f)}},o.getCacheCallbacks());a.keys=o.keys;const l=new Promise(c=>{setTimeout(c,xC,new Error("Timeout"))}),u=(async()=>{if(!await s.crypto.getSessionBackupPrivateKey()){Kt.logger.info("No cached backup key found. Requesting...");const m=await s.requestSecret("m.megolm_backup.v1",[t]).promise;Kt.logger.info("Got key backup key, decoding...");const f=(0,ir.decodeBase64)(m);Kt.logger.info("Decoded backup key, storing..."),await s.crypto.storeSessionBackupPrivateKey(Uint8Array.from(f)),Kt.logger.info("Backup key stored. Starting backup restore...");const E=await s.getKeyBackupVersion();s.restoreKeyBackupWithCache(void 0,void 0,E).then(()=>{Kt.logger.info("Backup restored.")})}})();return Promise.race([Promise.all([a.getCrossSigningKey("master"),a.getCrossSigningKey("self_signing"),a.getCrossSigningKey("user_signing"),u]),l]).then(r,i)}).catch(r=>{Kt.logger.warn("Cross-signing: failure while requesting keys:",r)})}var LC=G.exports;Object.defineProperty(Ss,"__esModule",{value:!0});Ss.TrackingStatus=Ss.DeviceList=void 0;var vt=LC(Y.exports),Ue=se,xa=xs,p_=Pt,Ah=KC(xe),zg=Br,od=W,BC=je,Dh=Ft;function g_(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(g_=function(r){return r?t:e})(n)}function KC(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=g_(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}let Ct;Ss.TrackingStatus=Ct;(function(n){n[n.NotTracked=0]="NotTracked",n[n.PendingDownload=1]="PendingDownload",n[n.DownloadInProgress=2]="DownloadInProgress",n[n.UpToDate=3]="UpToDate"})(Ct||(Ss.TrackingStatus=Ct={}));class FC extends BC.TypedEventEmitter{constructor(e,t,r,i=250){super();this.cryptoStore=t,this.keyDownloadChunkSize=i,(0,vt.default)(this,"devices",{}),(0,vt.default)(this,"crossSigningInfo",{}),(0,vt.default)(this,"userByIdentityKey",{}),(0,vt.default)(this,"deviceTrackingStatus",{}),(0,vt.default)(this,"syncToken",null),(0,vt.default)(this,"keyDownloadsInProgressByUser",{}),(0,vt.default)(this,"dirty",!1),(0,vt.default)(this,"savePromise",null),(0,vt.default)(this,"resolveSavePromise",null),(0,vt.default)(this,"savePromiseTime",null),(0,vt.default)(this,"saveTimer",null),(0,vt.default)(this,"hasFetched",null),(0,vt.default)(this,"serialiser",void 0),this.serialiser=new qC(e,r,this)}async load(){await this.cryptoStore.doTxn("readonly",[zg.IndexedDBCryptoStore.STORE_DEVICE_DATA],e=>{this.cryptoStore.getEndToEndDeviceData(e,t=>{this.hasFetched=Boolean(t&&t.devices),this.devices=t?t.devices:{},this.crossSigningInfo=t?t.crossSigningInfo||{}:{},this.deviceTrackingStatus=t?t.trackingStatus:{},this.syncToken=t?t.syncToken:null,this.userByIdentityKey={};for(const r of Object.keys(this.devices)){const i=this.devices[r];for(const s of Object.keys(i)){const o=i[s].keys["curve25519:"+s];o!==void 0&&(this.userByIdentityKey[o]=r)}}})});for(const e of Object.keys(this.deviceTrackingStatus))this.deviceTrackingStatus[e]==Ct.DownloadInProgress&&(this.deviceTrackingStatus[e]=Ct.PendingDownload)}stop(){this.saveTimer!==null&&clearTimeout(this.saveTimer)}async saveIfDirty(e=500){if(!this.dirty)return Promise.resolve(!1);const t=Date.now()+e;this.savePromiseTime&&t<this.savePromiseTime&&(clearTimeout(this.saveTimer),this.saveTimer=null,this.savePromiseTime=null);let r=this.savePromise;if(r===null&&(r=new Promise((i,s)=>{this.resolveSavePromise=i}),this.savePromise=r),this.saveTimer===null){const i=this.resolveSavePromise;this.savePromiseTime=t,this.saveTimer=setTimeout(()=>{Ue.logger.log("Saving device tracking data",this.syncToken),this.savePromiseTime=null,this.saveTimer=null,this.savePromise=null,this.resolveSavePromise=null,this.cryptoStore.doTxn("readwrite",[zg.IndexedDBCryptoStore.STORE_DEVICE_DATA],s=>{this.cryptoStore.storeEndToEndDeviceData({devices:this.devices,crossSigningInfo:this.crossSigningInfo,trackingStatus:this.deviceTrackingStatus,syncToken:this.syncToken},s)}).then(()=>{this.dirty=!1,i(!0)},s=>{Ue.logger.error("Failed to save device tracking data",this.syncToken),Ue.logger.error(s)})},e)}return r}getSyncToken(){return this.syncToken}setSyncToken(e){this.syncToken=e}downloadKeys(e,t){const r=[],i=[];if(e.forEach(s=>{const o=this.deviceTrackingStatus[s];this.keyDownloadsInProgressByUser[s]?(Ue.logger.log(`downloadKeys: already have a download in progress for ${s}: awaiting its result`),i.push(this.keyDownloadsInProgressByUser[s])):(t||o!=Ct.UpToDate)&&r.push(s)}),r.length!=0){Ue.logger.log("downloadKeys: downloading for",r);const s=this.doKeyDownload(r);i.push(s)}return i.length===0&&Ue.logger.log("downloadKeys: already have all necessary keys"),Promise.all(i).then(()=>this.getDevicesFromStore(e))}getDevicesFromStore(e){const t={};return e.map(r=>{t[r]={},(this.getStoredDevicesForUser(r)||[]).map(function(s){t[r][s.deviceId]=s})}),t}getKnownUserIds(){return Object.keys(this.devices)}getStoredDevicesForUser(e){const t=this.devices[e];if(!t)return null;const r=[];for(const i in t)t.hasOwnProperty(i)&&r.push(xa.DeviceInfo.fromStorage(t[i],i));return r}getRawStoredDevicesForUser(e){return this.devices[e]}getStoredCrossSigningForUser(e){return this.crossSigningInfo[e]?p_.CrossSigningInfo.fromStorage(this.crossSigningInfo[e],e):null}storeCrossSigningForUser(e,t){this.crossSigningInfo[e]=t,this.dirty=!0}getStoredDevice(e,t){const r=this.devices[e];if(!(!r||!r[t]))return xa.DeviceInfo.fromStorage(r[t],t)}getUserByIdentityKey(e,t){return e!==Ah.OLM_ALGORITHM&&e!==Ah.MEGOLM_ALGORITHM?null:this.userByIdentityKey[t]}getDeviceByIdentityKey(e,t){const r=this.getUserByIdentityKey(e,t);if(!r)return null;const i=this.devices[r];if(!i)return null;for(const s in i){if(!i.hasOwnProperty(s))continue;const o=i[s];for(const a in o.keys){if(!o.keys.hasOwnProperty(a)||a.indexOf("curve25519:")!==0)continue;if(o.keys[a]==t)return xa.DeviceInfo.fromStorage(o,s)}}return null}storeDevicesForUser(e,t){this.setRawStoredDevicesForUser(e,t),this.dirty=!0}startTrackingDeviceList(e){if(typeof e!="string")throw new Error("userId must be a string; was "+e);this.deviceTrackingStatus[e]||(Ue.logger.log("Now tracking device list for "+e),this.deviceTrackingStatus[e]=Ct.PendingDownload,this.dirty=!0)}stopTrackingDeviceList(e){this.deviceTrackingStatus[e]&&(Ue.logger.log("No longer tracking device list for "+e),this.deviceTrackingStatus[e]=Ct.NotTracked,this.dirty=!0)}stopTrackingAllDeviceLists(){for(const e of Object.keys(this.deviceTrackingStatus))this.deviceTrackingStatus[e]=Ct.NotTracked;this.dirty=!0}invalidateUserDeviceList(e){this.deviceTrackingStatus[e]&&(Ue.logger.log("Marking device list outdated for",e),this.deviceTrackingStatus[e]=Ct.PendingDownload,this.dirty=!0)}refreshOutdatedDeviceLists(){this.saveIfDirty();const e=[];for(const t of Object.keys(this.deviceTrackingStatus))this.deviceTrackingStatus[t]==Ct.PendingDownload&&e.push(t);return this.doKeyDownload(e)}setRawStoredDevicesForUser(e,t){if(this.devices[e]!==void 0)for(const[r,i]of Object.entries(this.devices[e])){const s=i.keys["curve25519:"+r];delete this.userByIdentityKey[s]}this.devices[e]=t;for(const[r,i]of Object.entries(t)){const s=i.keys["curve25519:"+r];this.userByIdentityKey[s]=e}}setRawStoredCrossSigningForUser(e,t){this.crossSigningInfo[e]=t}doKeyDownload(e){if(e.length===0)return Promise.resolve();const t=this.serialiser.updateDevicesForUsers(e,this.syncToken).then(()=>{r(!0)},i=>{throw Ue.logger.error("Error downloading keys for "+e+":",i),r(!1),i});e.forEach(i=>{this.keyDownloadsInProgressByUser[i]=t,this.deviceTrackingStatus[i]==Ct.PendingDownload&&(this.deviceTrackingStatus[i]=Ct.DownloadInProgress)});const r=i=>{this.emit(Dh.CryptoEvent.WillUpdateDevices,e,!this.hasFetched),e.forEach(s=>{if(this.dirty=!0,this.keyDownloadsInProgressByUser[s]!==t){Ue.logger.log("Another update in the queue for",s,"- not marking up-to-date");return}delete this.keyDownloadsInProgressByUser[s],this.deviceTrackingStatus[s]==Ct.DownloadInProgress&&(i?(this.deviceTrackingStatus[s]=Ct.UpToDate,Ue.logger.log("Device list for",s,"now up to date")):this.deviceTrackingStatus[s]=Ct.PendingDownload)}),this.saveIfDirty(),this.emit(Dh.CryptoEvent.DevicesUpdated,e,!this.hasFetched),this.hasFetched=!0};return t}}Ss.DeviceList=FC;class qC{constructor(e,t,r){this.baseApis=e,this.olmDevice=t,this.deviceList=r,(0,vt.default)(this,"downloadInProgress",!1),(0,vt.default)(this,"keyDownloadsQueuedByUser",{}),(0,vt.default)(this,"queuedQueryDeferred",null),(0,vt.default)(this,"syncToken",null)}updateDevicesForUsers(e,t){return e.forEach(r=>{this.keyDownloadsQueuedByUser[r]=!0}),this.queuedQueryDeferred||(this.queuedQueryDeferred=(0,od.defer)()),this.syncToken=t,this.downloadInProgress?(Ue.logger.log("Queued key download for",e),this.queuedQueryDeferred.promise):this.doQueuedQueries()}doQueuedQueries(){if(this.downloadInProgress)throw new Error("DeviceListUpdateSerialiser.doQueuedQueries called with request active");const e=Object.keys(this.keyDownloadsQueuedByUser);this.keyDownloadsQueuedByUser={};const t=this.queuedQueryDeferred;this.queuedQueryDeferred=null,Ue.logger.log("Starting key download for",e),this.downloadInProgress=!0;const r={};this.syncToken&&(r.token=this.syncToken);const i=[];for(let s=0;s<e.length;s+=this.deviceList.keyDownloadChunkSize){const o=e.slice(s,s+this.deviceList.keyDownloadChunkSize);i.push(()=>this.baseApis.downloadKeysForUsers(o,r))}return(0,od.chunkPromises)(i,3).then(async s=>{const o=Object.assign({},...s.map(c=>c.device_keys||{})),a=Object.assign({},...s.map(c=>c.master_keys||{})),l=Object.assign({},...s.map(c=>c.self_signing_keys||{})),u=Object.assign({},...s.map(c=>c.user_signing_keys||{}));for(const c of e){await(0,od.sleep)(5);try{await this.processQueryResponseForUser(c,o[c],{master:a[c],self_signing:l[c],user_signing:u[c]})}catch(g){Ue.logger.error(`Error processing keys for ${c}:`,g)}}}).then(()=>{Ue.logger.log("Completed key download for "+e),this.downloadInProgress=!1,t.resolve(),this.queuedQueryDeferred&&this.doQueuedQueries()},s=>{Ue.logger.warn("Error downloading keys for "+e+":",s),this.downloadInProgress=!1,t.reject(s)}),t.promise}async processQueryResponseForUser(e,t,r){Ue.logger.log("got device keys for "+e+":",t),Ue.logger.log("got cross-signing keys for "+e+":",r);{const i={},s=this.deviceList.getRawStoredDevicesForUser(e);s&&Object.keys(s).forEach(a=>{const l=xa.DeviceInfo.fromStorage(s[a],a);i[a]=l}),await jC(this.olmDevice,e,i,t||{},this.baseApis.getUserId(),this.baseApis.deviceId);const o={};Object.keys(i).forEach(a=>{o[a]=i[a].toStorage()}),this.deviceList.setRawStoredDevicesForUser(e,o)}if(r&&(r.master||r.self_signing||r.user_signing)){const i=this.deviceList.getStoredCrossSigningForUser(e)||new p_.CrossSigningInfo(e);i.setKeys(r),this.deviceList.setRawStoredCrossSigningForUser(e,i.toStorage()),this.deviceList.emit(Dh.CryptoEvent.UserCrossSigningUpdated,e)}}}async function jC(n,e,t,r,i,s){let o=!1;for(const a in t)if(!!t.hasOwnProperty(a)&&!(a in r)){if(e===i&&a===s){Ue.logger.warn(`Local device ${a} missing from sync, skipping removal`);continue}Ue.logger.log("Device "+e+":"+a+" has been removed"),delete t[a],o=!0}for(const a in r){if(!r.hasOwnProperty(a))continue;const l=r[a];if(l.user_id!==e){Ue.logger.warn("Mismatched user_id "+l.user_id+" in keys from "+e+":"+a);continue}if(l.device_id!==a){Ue.logger.warn("Mismatched device_id "+l.device_id+" in keys from "+e+":"+a);continue}await VC(n,t,l)&&(o=!0)}return o}async function VC(n,e,t){if(!t.keys)return!1;const r=t.device_id,i=t.user_id,s="ed25519:"+r,o=t.keys[s];if(!o)return Ue.logger.warn("Device "+i+":"+r+" has no ed25519 key"),!1;const a=t.unsigned||{},l=t.signatures||{};try{await Ah.verifySignature(n,t,i,r,o)}catch(c){return Ue.logger.warn("Unable to verify signature on device "+i+":"+r+":"+c),!1}let u;if(r in e){if(u=e[r],u.getFingerprint()!=o)return Ue.logger.warn("Ed25519 key for device "+i+":"+r+" has changed"),!1}else e[r]=u=new xa.DeviceInfo(r);return u.keys=t.keys||{},u.algorithms=t.algorithms||[],u.unsigned=a,u.signatures=l,!0}var To={},GC=G.exports;Object.defineProperty(To,"__esModule",{value:!0});To.EncryptionSetupOperation=To.EncryptionSetupBuilder=void 0;var vn=GC(Y.exports),WC=se,HC=jt,YC=Pt,zC=Br,Dc=me,JC=Cs,XC=je;class QC{constructor(e,t){(0,vn.default)(this,"accountDataClientAdapter",void 0),(0,vn.default)(this,"crossSigningCallbacks",void 0),(0,vn.default)(this,"ssssCryptoCallbacks",void 0),(0,vn.default)(this,"crossSigningKeys",null),(0,vn.default)(this,"keySignatures",null),(0,vn.default)(this,"keyBackupInfo",null),(0,vn.default)(this,"sessionBackupPrivateKey",void 0),this.accountDataClientAdapter=new ZC(e),this.crossSigningCallbacks=new eP,this.ssssCryptoCallbacks=new tP(t)}addCrossSigningKeys(e,t){this.crossSigningKeys={authUpload:e,keys:t}}addSessionBackup(e){this.keyBackupInfo=e}addSessionBackupPrivateKeyToCache(e){this.sessionBackupPrivateKey=e}addKeySignature(e,t,r){this.keySignatures||(this.keySignatures={});const i=this.keySignatures[e]||{};this.keySignatures[e]=i,i[t]=r}async setAccountData(e,t){await this.accountDataClientAdapter.setAccountData(e,t)}buildOperation(){const e=this.accountDataClientAdapter.values;return new m_(e,this.crossSigningKeys,this.keyBackupInfo,this.keySignatures)}async persist(e){if(this.crossSigningKeys){const t=(0,YC.createCryptoStoreCacheCallbacks)(e.cryptoStore,e.olmDevice);for(const r of["master","self_signing","user_signing"]){WC.logger.log(`Cache ${r} cross-signing private key locally`);const i=this.crossSigningCallbacks.privateKeys.get(r);await t.storeCrossSigningKeyCache(r,i)}await e.cryptoStore.doTxn("readwrite",[zC.IndexedDBCryptoStore.STORE_ACCOUNT],r=>{e.cryptoStore.storeCrossSigningKeys(r,this.crossSigningKeys.keys)})}this.sessionBackupPrivateKey&&await e.storeSessionBackupPrivateKey(this.sessionBackupPrivateKey)}}To.EncryptionSetupBuilder=QC;class m_{constructor(e,t,r,i){this.accountData=e,this.crossSigningKeys=t,this.keyBackupInfo=r,this.keySignatures=i}async apply(e){const t=e.baseApis;if(this.crossSigningKeys){const r={};for(const[i,s]of Object.entries(this.crossSigningKeys.keys))r[i+"_key"]=s;await this.crossSigningKeys.authUpload(i=>t.uploadDeviceSigningKeys(i,r)),e.crossSigningInfo.setKeys(this.crossSigningKeys.keys)}if(this.accountData)for(const[r,i]of this.accountData)await t.setAccountData(r,i);this.keySignatures&&await t.uploadKeySignatures(this.keySignatures),this.keyBackupInfo&&(this.keyBackupInfo.version?await t.http.authedRequest(void 0,Dc.Method.Put,"/room_keys/version/"+this.keyBackupInfo.version,void 0,{algorithm:this.keyBackupInfo.algorithm,auth_data:this.keyBackupInfo.auth_data},{prefix:Dc.PREFIX_UNSTABLE}):await t.http.authedRequest(void 0,Dc.Method.Post,"/room_keys/version",void 0,this.keyBackupInfo,{prefix:Dc.PREFIX_UNSTABLE}))}}To.EncryptionSetupOperation=m_;class ZC extends XC.TypedEventEmitter{constructor(e){super();this.existingValues=e,(0,vn.default)(this,"values",new Map)}getAccountDataFromServer(e){return Promise.resolve(this.getAccountData(e))}getAccountData(e){const t=this.values.get(e);if(t)return t;const r=this.existingValues[e];return r?r.getContent():null}setAccountData(e,t){const r=this.values.get(e);return this.values.set(e,t),Promise.resolve().then(()=>{const i=new HC.MatrixEvent({type:e,content:t});return this.emit(JC.ClientEvent.AccountData,i,r),{}})}}class eP{constructor(){(0,vn.default)(this,"privateKeys",new Map)}getCrossSigningKeyCache(e,t){return this.getCrossSigningKey(e,t)}storeCrossSigningKeyCache(e,t){return this.privateKeys.set(e,t),Promise.resolve()}getCrossSigningKey(e,t){return Promise.resolve(this.privateKeys.get(e))}saveCrossSigningKeys(e){for(const[t,r]of Object.entries(e))this.privateKeys.set(t,r)}}class tP{constructor(e){this.delegateCryptoCallbacks=e,(0,vn.default)(this,"privateKeys",new Map)}async getSecretStorageKey({keys:e},t){var r;for(const i of Object.keys(e)){const s=this.privateKeys.get(i);if(s)return[i,s]}if(this!==null&&this!==void 0&&(r=this.delegateCryptoCallbacks)!==null&&r!==void 0&&r.getSecretStorageKey){const i=await this.delegateCryptoCallbacks.getSecretStorageKey({keys:e},t);if(i){const[s,o]=i;this.privateKeys.set(s,o)}return i}return null}addPrivateKey(e,t,r){var i,s;this.privateKeys.set(e,r),(i=this.delegateCryptoCallbacks)===null||i===void 0||(s=i.cacheSecretStorageKey)===null||s===void 0||s.call(i,e,t,r)}}var Oo={},rP=G.exports;Object.defineProperty(Oo,"__esModule",{value:!0});Oo.SecretStorage=Oo.SECRET_STORAGE_ALGORITHM_V1_AES=void 0;var nP=rP(Y.exports),cn=se,na=sP(xe),iP=ai,xc=li,ad=Cs;function y_(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(y_=function(r){return r?t:e})(n)}function sP(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=y_(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}const Zi="m.secret_storage.v1.aes-hmac-sha2";Oo.SECRET_STORAGE_ALGORITHM_V1_AES=Zi;class oP{constructor(e,t,r){this.accountDataAdapter=e,this.cryptoCallbacks=t,this.baseApis=r,(0,nP.default)(this,"requests",new Map)}async getDefaultKeyId(){const e=await this.accountDataAdapter.getAccountDataFromServer("m.secret_storage.default_key");return e?e.key:null}setDefaultKeyId(e){return new Promise((t,r)=>{const i=s=>{s.getType()==="m.secret_storage.default_key"&&s.getContent().key===e&&(this.accountDataAdapter.removeListener(ad.ClientEvent.AccountData,i),t())};this.accountDataAdapter.on(ad.ClientEvent.AccountData,i),this.accountDataAdapter.setAccountData("m.secret_storage.default_key",{key:e}).catch(s=>{this.accountDataAdapter.removeListener(ad.ClientEvent.AccountData,i),r(s)})})}async addKey(e,t,r){const i={algorithm:e};if(t||(t={}),t.name&&(i.name=t.name),e===Zi){if(t.passphrase&&(i.passphrase=t.passphrase),t.key){const{iv:s,mac:o}=await(0,xc.calculateKeyCheck)(t.key);i.iv=s,i.mac=o}}else throw new Error(`Unknown key algorithm ${e}`);if(!r)do r=(0,iP.randomString)(32);while(await this.accountDataAdapter.getAccountDataFromServer(`m.secret_storage.key.${r}`));return await this.accountDataAdapter.setAccountData(`m.secret_storage.key.${r}`,i),{keyId:r,keyInfo:i}}async getKey(e){if(e||(e=await this.getDefaultKeyId()),!e)return null;const t=await this.accountDataAdapter.getAccountDataFromServer("m.secret_storage.key."+e);return t?[e,t]:null}async hasKey(e){return Boolean(await this.getKey(e))}async checkKey(e,t){if(t.algorithm===Zi)if(t.mac){const{mac:r}=await(0,xc.calculateKeyCheck)(e,t.iv);return t.mac.replace(/=+$/g,"")===r.replace(/=+$/g,"")}else return!0;else throw new Error("Unknown algorithm")}async store(e,t,r){const i={};if(!r){const s=await this.getDefaultKeyId();if(!s)throw new Error("No keys specified and no default key present");r=[s]}if(r.length===0)throw new Error("Zero keys given to encrypt with!");for(const s of r){const o=await this.accountDataAdapter.getAccountDataFromServer("m.secret_storage.key."+s);if(!o)throw new Error("Unknown key: "+s);if(o.algorithm===Zi){const a={[s]:o},[,l]=await this.getSecretStorageKey(a,e);i[s]=await l.encrypt(t)}else cn.logger.warn("unknown algorithm for secret storage key "+s+": "+o.algorithm)}await this.accountDataAdapter.setAccountData(e,{encrypted:i})}async get(e){const t=await this.accountDataAdapter.getAccountDataFromServer(e);if(!t)return;if(!t.encrypted)throw new Error("Content is not encrypted!");const r={};for(const o of Object.keys(t.encrypted)){const a=await this.accountDataAdapter.getAccountDataFromServer("m.secret_storage.key."+o),l=t.encrypted[o];a.algorithm===Zi&&l.iv&&l.ciphertext&&l.mac&&(r[o]=a)}if(Object.keys(r).length===0)throw new Error(`Could not decrypt ${e} because none of the keys it is encrypted with are for a supported algorithm`);let i,s;try{[i,s]=await this.getSecretStorageKey(r,e);const o=t.encrypted[i];return o.passthrough?(0,na.encodeBase64)(s.get_private_key()):await s.decrypt(o)}finally{s&&s.free&&s.free()}}async isStored(e,t){const r=await this.accountDataAdapter.getAccountDataFromServer(e);if(!r||!r.encrypted)return null;const i={};for(const s of Object.keys(r.encrypted)){const o=await this.accountDataAdapter.getAccountDataFromServer("m.secret_storage.key."+s);if(!o)continue;const a=r.encrypted[s];o.algorithm===Zi&&a.iv&&a.ciphertext&&a.mac&&(i[s]=o)}return Object.keys(i).length?i:null}request(e,t){const r=this.baseApis.makeTxnId();let i,s;const o=new Promise((c,g)=>{i=c,s=g});this.requests.set(r,{name:e,devices:t,resolve:i,reject:s});const a=c=>{const g={action:"request_cancellation",requesting_device_id:this.baseApis.deviceId,request_id:r},m={};for(const f of t)m[f]=g;this.baseApis.sendToDevice("m.secret.request",{[this.baseApis.getUserId()]:m}),s(new Error(c||"Cancelled"))},l={name:e,action:"request",requesting_device_id:this.baseApis.deviceId,request_id:r},u={};for(const c of t)u[c]=l;return cn.logger.info(`Request secret ${e} from ${t}, id ${r}`),this.baseApis.sendToDevice("m.secret.request",{[this.baseApis.getUserId()]:u}),{requestId:r,promise:o,cancel:a}}async onRequestReceived(e){const t=e.getSender(),r=e.getContent();if(t!==this.baseApis.getUserId()||!(r.name&&r.action&&r.requesting_device_id&&r.request_id))return;const i=r.requesting_device_id;if(r.action!=="request_cancellation"){if(r.action==="request"){if(i===this.baseApis.deviceId||(cn.logger.info("received request for secret ("+t+", "+i+", "+r.request_id+")"),!this.cryptoCallbacks.onSecretRequested))return;const s=await this.cryptoCallbacks.onSecretRequested(t,i,r.request_id,r.name,this.baseApis.checkDeviceTrust(t,i));if(s){cn.logger.info(`Preparing ${r.name} secret for ${i}`);const o={type:"m.secret.send",content:{request_id:r.request_id,secret:s}},a={algorithm:na.OLM_ALGORITHM,sender_key:this.baseApis.crypto.olmDevice.deviceCurve25519Key,ciphertext:{}};await na.ensureOlmSessionsForDevices(this.baseApis.crypto.olmDevice,this.baseApis,{[t]:[this.baseApis.getStoredDevice(t,i)]}),await na.encryptMessageForDevice(a.ciphertext,this.baseApis.getUserId(),this.baseApis.deviceId,this.baseApis.crypto.olmDevice,t,this.baseApis.getStoredDevice(t,i),o);const l={[t]:{[i]:a}};cn.logger.info(`Sending ${r.name} secret for ${i}`),this.baseApis.sendToDevice("m.room.encrypted",l)}else cn.logger.info(`Request denied for ${r.name} secret for ${i}`)}}}onSecretReceived(e){if(e.getSender()!==this.baseApis.getUserId())return;const t=e.getContent();cn.logger.log("got secret share for request",t.request_id);const r=this.requests.get(t.request_id);if(r){const i=this.baseApis.crypto.deviceList.getDeviceByIdentityKey(na.OLM_ALGORITHM,e.getSenderKey());if(!i){cn.logger.log("secret share from unknown device with key",e.getSenderKey());return}if(!r.devices.includes(i.deviceId)){cn.logger.log("unsolicited secret share from device",i.deviceId);return}cn.logger.log(`Successfully received secret ${r.name} from ${i.deviceId}`),r.resolve(t.secret)}}async getSecretStorageKey(e,t){if(!this.cryptoCallbacks.getSecretStorageKey)throw new Error("No getSecretStorageKey callback supplied");const r=await this.cryptoCallbacks.getSecretStorageKey({keys:e},t);if(!r)throw new Error("getSecretStorageKey callback returned falsey");if(r.length<2)throw new Error("getSecretStorageKey callback returned invalid data");const[i,s]=r;if(!e[i])throw new Error("App returned unknown key from getSecretStorageKey!");if(e[i].algorithm===Zi)return[i,{encrypt:async function(a){return await(0,xc.encryptAES)(a,s,t)},decrypt:async function(a){return await(0,xc.decryptAES)(a,s,t)}}];throw new Error("Unknown key type: "+e[i].algorithm)}}Oo.SecretStorage=oP;var bs={},aP=G.exports;Object.defineProperty(bs,"__esModule",{value:!0});bs.RoomKeyRequestState=bs.OutgoingRoomKeyRequestManager=void 0;var cd=aP(Y.exports),$n=se,cP=ie;const lP=500;let Ee;bs.RoomKeyRequestState=Ee;(function(n){n[n.Unsent=0]="Unsent",n[n.Sent=1]="Sent",n[n.CancellationPending=2]="CancellationPending",n[n.CancellationPendingAndWillResend=3]="CancellationPendingAndWillResend"})(Ee||(bs.RoomKeyRequestState=Ee={}));class uP{constructor(e,t,r){this.baseApis=e,this.deviceId=t,this.cryptoStore=r,(0,cd.default)(this,"sendOutgoingRoomKeyRequestsTimer",null),(0,cd.default)(this,"sendOutgoingRoomKeyRequestsRunning",!1),(0,cd.default)(this,"clientRunning",!1)}start(){this.clientRunning=!0}stop(){$n.logger.log("stopping OutgoingRoomKeyRequestManager"),this.clientRunning=!1}sendQueuedRequests(){this.startTimer()}async queueRoomKeyRequest(e,t,r=!1){const i=await this.cryptoStore.getOutgoingRoomKeyRequest(e);if(!i)await this.cryptoStore.getOrAddOutgoingRoomKeyRequest({requestBody:e,recipients:t,requestId:this.baseApis.makeTxnId(),state:Ee.Unsent});else switch(i.state){case Ee.CancellationPendingAndWillResend:case Ee.Unsent:return;case Ee.CancellationPending:{const s=r?Ee.CancellationPendingAndWillResend:Ee.Sent;await this.cryptoStore.updateOutgoingRoomKeyRequest(i.requestId,Ee.CancellationPending,{state:s,cancellationTxnId:this.baseApis.makeTxnId()});break}case Ee.Sent:{if(r){const s=Ee.CancellationPendingAndWillResend,o=await this.cryptoStore.updateOutgoingRoomKeyRequest(i.requestId,Ee.Sent,{state:s,cancellationTxnId:this.baseApis.makeTxnId(),requestTxnId:this.baseApis.makeTxnId()});if(!o)return await this.queueRoomKeyRequest(e,t,r);try{await this.sendOutgoingRoomKeyRequestCancellation(o,!0)}catch(a){$n.logger.error("Error sending room key request cancellation; will retry later.",a)}}break}default:throw new Error("unhandled state: "+i.state)}}cancelRoomKeyRequest(e){return this.cryptoStore.getOutgoingRoomKeyRequest(e).then(t=>{if(!!t)switch(t.state){case Ee.CancellationPending:case Ee.CancellationPendingAndWillResend:return;case Ee.Unsent:return $n.logger.log("deleting unnecessary room key request for "+Uc(e)),this.cryptoStore.deleteOutgoingRoomKeyRequest(t.requestId,Ee.Unsent);case Ee.Sent:return this.cryptoStore.updateOutgoingRoomKeyRequest(t.requestId,Ee.Sent,{state:Ee.CancellationPending,cancellationTxnId:this.baseApis.makeTxnId()}).then(r=>{if(!r){$n.logger.log("Tried to cancel room key request for "+Uc(e)+" but it was already cancelled in another tab");return}this.sendOutgoingRoomKeyRequestCancellation(r).catch(i=>{$n.logger.error("Error sending room key request cancellation; will retry later.",i),this.startTimer()})});default:throw new Error("unhandled state: "+t.state)}})}getOutgoingSentRoomKeyRequest(e,t){return this.cryptoStore.getOutgoingRoomKeyRequestsByTarget(e,t,[Ee.Sent])}async cancelAndResendAllOutgoingRequests(){const e=await this.cryptoStore.getAllOutgoingRoomKeyRequestsByState(Ee.Sent);return Promise.all(e.map(({requestBody:t,recipients:r})=>this.queueRoomKeyRequest(t,r,!0)))}startTimer(){if(this.sendOutgoingRoomKeyRequestsTimer)return;const e=()=>{if(this.sendOutgoingRoomKeyRequestsRunning)throw new Error("RoomKeyRequestSend already in progress!");this.sendOutgoingRoomKeyRequestsRunning=!0,this.sendOutgoingRoomKeyRequests().finally(()=>{this.sendOutgoingRoomKeyRequestsRunning=!1}).catch(t=>{$n.logger.warn(`error in OutgoingRoomKeyRequestManager: ${t}`)})};this.sendOutgoingRoomKeyRequestsTimer=setTimeout(e,lP)}sendOutgoingRoomKeyRequests(){return this.clientRunning?this.cryptoStore.getOutgoingRoomKeyRequestByState([Ee.CancellationPending,Ee.CancellationPendingAndWillResend,Ee.Unsent]).then(e=>{if(!e){this.sendOutgoingRoomKeyRequestsTimer=null;return}let t;switch(e.state){case Ee.Unsent:t=this.sendOutgoingRoomKeyRequest(e);break;case Ee.CancellationPending:t=this.sendOutgoingRoomKeyRequestCancellation(e);break;case Ee.CancellationPendingAndWillResend:t=this.sendOutgoingRoomKeyRequestCancellation(e,!0);break}return t.then(()=>this.sendOutgoingRoomKeyRequests()).catch(r=>{$n.logger.error("Error sending room key request; will retry later.",r),this.sendOutgoingRoomKeyRequestsTimer=null})}):(this.sendOutgoingRoomKeyRequestsTimer=null,Promise.resolve())}sendOutgoingRoomKeyRequest(e){$n.logger.log(`Requesting keys for ${Uc(e.requestBody)} from ${Jg(e.recipients)}(id ${e.requestId})`);const t={action:"request",requesting_device_id:this.deviceId,request_id:e.requestId,body:e.requestBody};return this.sendMessageToDevices(t,e.recipients,e.requestTxnId||e.requestId).then(()=>this.cryptoStore.updateOutgoingRoomKeyRequest(e.requestId,Ee.Unsent,{state:Ee.Sent}))}sendOutgoingRoomKeyRequestCancellation(e,t=!1){$n.logger.log(`Sending cancellation for key request for ${Uc(e.requestBody)} to ${Jg(e.recipients)} (cancellation id ${e.cancellationTxnId})`);const r={action:"request_cancellation",requesting_device_id:this.deviceId,request_id:e.requestId};return this.sendMessageToDevices(r,e.recipients,e.cancellationTxnId).then(()=>t?this.cryptoStore.updateOutgoingRoomKeyRequest(e.requestId,Ee.CancellationPendingAndWillResend,{state:Ee.Unsent}):this.cryptoStore.deleteOutgoingRoomKeyRequest(e.requestId,Ee.CancellationPending))}sendMessageToDevices(e,t,r){const i={};for(const s of t)i[s.userId]||(i[s.userId]={}),i[s.userId][s.deviceId]=e;return this.baseApis.sendToDevice(cP.EventType.RoomKeyRequest,i,r)}}bs.OutgoingRoomKeyRequestManager=uP;function Uc(n){return n.room_id+" / "+n.session_id}function Jg(n){return"["+n.map(e=>`${e.userId}:${e.deviceId}`).join(",")+"]"}var cr={},Xr={},Ke={};Object.defineProperty(Ke,"__esModule",{value:!0});Ke.errorFactory=ui;Ke.errorFromEvent=EP;Ke.newUserMismatchError=Ke.newUserCancelledError=Ke.newUnknownTransactionError=Ke.newUnknownMethodError=Ke.newUnexpectedMessageError=Ke.newTimeoutError=Ke.newKeyMismatchError=Ke.newInvalidMessageError=void 0;Ke.newVerificationError=v_;var dP=jt;function v_(n,e,t){const r=Object.assign({},{code:n,reason:e},t);return new dP.MatrixEvent({type:"m.key.verification.cancel",content:r})}function ui(n,e){return function(t){return v_(n,e,t)}}const hP=ui("m.user","Cancelled by user");Ke.newUserCancelledError=hP;const fP=ui("m.timeout","Timed out");Ke.newTimeoutError=fP;const pP=ui("m.unknown_transaction","Unknown transaction");Ke.newUnknownTransactionError=pP;const gP=ui("m.unknown_method","Unknown method");Ke.newUnknownMethodError=gP;const mP=ui("m.unexpected_message","Unexpected message");Ke.newUnexpectedMessageError=mP;const yP=ui("m.key_mismatch","Key mismatch");Ke.newKeyMismatchError=yP;const vP=ui("m.user_error","User mismatch");Ke.newUserMismatchError=vP;const _P=ui("m.invalid_message","Invalid message");Ke.newInvalidMessageError=_P;function EP(n){const e=n.getContent();if(e){const{code:t,reason:r}=e;return{code:t,reason:r}}else return{code:"Unknown error",reason:"m.unknown"}}var SP=G.exports;Object.defineProperty(Xr,"__esModule",{value:!0});Xr.VerificationEvent=Xr.VerificationBase=Xr.SwitchStartEventError=void 0;var Gr=SP(Y.exports),bP=jt,ia=se,wP=xs,RP=Ke,IP=Pt,TP=je;const Xg=new Error("Verification timed out");class __ extends Error{constructor(e){super();this.startEvent=e}}Xr.SwitchStartEventError=__;let kl;Xr.VerificationEvent=kl;(function(n){n.Cancel="cancel"})(kl||(Xr.VerificationEvent=kl={}));class OP extends TP.TypedEventEmitter{constructor(e,t,r,i,s,o){super();this.channel=e,this.baseApis=t,this.userId=r,this.deviceId=i,this.startEvent=s,this.request=o,(0,Gr.default)(this,"cancelled",!1),(0,Gr.default)(this,"_done",!1),(0,Gr.default)(this,"promise",null),(0,Gr.default)(this,"transactionTimeoutTimer",null),(0,Gr.default)(this,"expectedEvent",void 0),(0,Gr.default)(this,"resolve",void 0),(0,Gr.default)(this,"reject",void 0),(0,Gr.default)(this,"resolveEvent",void 0),(0,Gr.default)(this,"rejectEvent",void 0),(0,Gr.default)(this,"started",void 0),(0,Gr.default)(this,"doVerification",void 0)}get initiatedByMe(){if(!this.startEvent)return!0;const e=this.startEvent.getSender(),t=this.startEvent.getContent();return e===this.baseApis.getUserId()&&t.from_device===this.baseApis.getDeviceId()}get hasBeenCancelled(){return this.cancelled}resetTimer(){ia.logger.info("Refreshing/starting the verification transaction timeout timer"),this.transactionTimeoutTimer!==null&&clearTimeout(this.transactionTimeoutTimer),this.transactionTimeoutTimer=setTimeout(()=>{!this._done&&!this.cancelled&&(ia.logger.info("Triggering verification timeout"),this.cancel(Xg))},10*60*1e3)}endTimer(){this.transactionTimeoutTimer!==null&&(clearTimeout(this.transactionTimeoutTimer),this.transactionTimeoutTimer=null)}send(e,t){return this.channel.send(e,t)}waitForEvent(e){if(this._done)return Promise.reject(new Error("Verification is already done"));const t=this.request.getEventFromOtherParty(e);return t?Promise.resolve(t):(this.expectedEvent=e,new Promise((r,i)=>{this.resolveEvent=r,this.rejectEvent=i}))}canSwitchStartEvent(e){return!1}switchStartEvent(e){if(this.canSwitchStartEvent(e))if(ia.logger.log("Verification Base: switching verification start event",{restartingFlow:!!this.rejectEvent}),this.rejectEvent){const t=this.rejectEvent;this.rejectEvent=void 0,t(new __(e))}else this.startEvent=e}handleEvent(e){if(!this._done){if(e.getType()===this.expectedEvent)this.expectedEvent!=="m.key.verification.done"&&(this.expectedEvent=void 0,this.rejectEvent=void 0,this.resetTimer(),this.resolveEvent(e));else if(e.getType()==="m.key.verification.cancel"){const t=this.reject;if(this.reject=void 0,t){const r=e.getContent(),{reason:i,code:s}=r;t(new Error(`Other side cancelled verification because ${i} (${s})`))}}else if(this.expectedEvent){const t=new Error("Unexpected message: expecting "+this.expectedEvent+" but got "+e.getType());if(this.expectedEvent=void 0,this.rejectEvent){const r=this.rejectEvent;this.rejectEvent=void 0,r(t)}this.cancel(t)}}}done(){if(this.endTimer(),!this._done)return this.request.onVerifierFinished(),this.resolve(),(0,IP.requestKeysDuringVerification)(this.baseApis,this.userId,this.deviceId)}cancel(e){if(this.endTimer(),!this._done){if(this.cancelled=!0,this.request.onVerifierCancelled(),this.userId&&this.deviceId)if(e===Xg){const t=(0,RP.newTimeoutError)();this.send(t.getType(),t.getContent())}else if(e instanceof bP.MatrixEvent){if(e.getSender()!==this.userId){const r=e.getContent();e.getType()==="m.key.verification.cancel"?(r.code=r.code||"m.unknown",r.reason=r.reason||r.body||"Unknown reason",this.send("m.key.verification.cancel",r)):this.send("m.key.verification.cancel",{code:"m.unknown",reason:r.body||"Unknown reason"})}}else this.send("m.key.verification.cancel",{code:"m.unknown",reason:e.toString()});this.promise!==null?this.reject&&this.reject(e):this.promise=Promise.reject(e),this.emit(kl.Cancel,e)}}verify(){return this.promise?this.promise:(this.promise=new Promise((e,t)=>{this.resolve=(...r)=>{this._done=!0,this.endTimer(),e(...r)},this.reject=r=>{this._done=!0,this.endTimer(),t(r)}}),this.doVerification&&!this.started&&(this.started=!0,this.resetTimer(),Promise.resolve(this.doVerification()).then(this.done.bind(this),this.cancel.bind(this))),this.promise)}async verifyKeys(e,t,r){const i=[];for(const[s,o]of Object.entries(t)){const a=s.split(":",2)[1],l=this.baseApis.getStoredDevice(e,a);if(l)r(s,l,o),i.push(a);else{const u=this.baseApis.crypto.deviceList.getStoredCrossSigningForUser(e);u&&u.getId()===a?(r(s,wP.DeviceInfo.fromStorage({keys:{[s]:a}},a),o),i.push(a)):ia.logger.warn(`verification: Could not find device ${a} to verify`)}}if(!i.length)throw new Error("No devices could be verified");ia.logger.info("Verification completed! Marking devices verified: ",i);for(const s of i)await this.baseApis.setDeviceVerified(e,s)}get events(){}}Xr.VerificationBase=OP;var kP=G.exports;Object.defineProperty(cr,"__esModule",{value:!0});cr.SHOW_QR_CODE_METHOD=cr.SCAN_QR_CODE_METHOD=cr.ReciprocateQRCode=cr.QrCodeEvent=cr.QRCodeData=void 0;var Qg=kP(Y.exports),CP=Xr,Hs=Ke,Zg=xe,em=se;const PP="m.qr_code.show.v1";cr.SHOW_QR_CODE_METHOD=PP;const MP="m.qr_code.scan.v1";cr.SCAN_QR_CODE_METHOD=MP;let Cl;cr.QrCodeEvent=Cl;(function(n){n.ShowReciprocateQr="show_reciprocate_qr"})(Cl||(cr.QrCodeEvent=Cl={}));class Of extends CP.VerificationBase{constructor(...e){super(...e);(0,Qg.default)(this,"reciprocateQREvent",void 0),(0,Qg.default)(this,"doVerification",async()=>{if(!this.startEvent)throw new Error("It is not currently possible to start verificationwith this method yet.");const{qrCodeData:t}=this.request;if(this.startEvent.getContent().secret!==t.encodedSharedSecret)throw(0,Hs.newKeyMismatchError)();await new Promise((i,s)=>{this.reciprocateQREvent={confirm:i,cancel:()=>s((0,Hs.newUserCancelledError)())},this.emit(Cl.ShowReciprocateQr,this.reciprocateQREvent)});const r={};switch(t.mode){case sr.VerifyOtherUser:{const i=t.otherUserMasterKey;r[`ed25519:${i}`]=i;break}case sr.VerifySelfTrusted:{const i=this.request.targetDevice.deviceId;r[`ed25519:${i}`]=t.otherDeviceKey;break}case sr.VerifySelfUntrusted:{const i=t.myMasterKey;r[`ed25519:${i}`]=i;break}}await this.verifyKeys(this.userId,r,(i,s,o)=>{const a=r[i];if(!a)throw(0,Hs.newKeyMismatchError)();if(o!==a)throw em.logger.error("key ID from key info does not match"),(0,Hs.newKeyMismatchError)();for(const l in s.keys){if(!l.startsWith("ed25519"))continue;const u=r[l];if(!u)throw(0,Hs.newKeyMismatchError)();if(s.keys[l]!==u)throw em.logger.error("master key does not match"),(0,Hs.newKeyMismatchError)()}})})}static factory(e,t,r,i,s,o){return new Of(e,t,r,i,s,o)}static get NAME(){return"m.reciprocate.v1"}}cr.ReciprocateQRCode=Of;const AP=2,DP="MATRIX";var sr;(function(n){n[n.VerifyOtherUser=0]="VerifyOtherUser",n[n.VerifySelfTrusted=1]="VerifySelfTrusted",n[n.VerifySelfUntrusted=2]="VerifySelfUntrusted"})(sr||(sr={}));class Mi{constructor(e,t,r,i,s,o){this.mode=e,this.sharedSecret=t,this.otherUserMasterKey=r,this.otherDeviceKey=i,this.myMasterKey=s,this.buffer=o}static async create(e,t){const r=Mi.generateSharedSecret(),i=Mi.determineMode(e,t);let s=null,o=null,a=null;if(i===sr.VerifyOtherUser)s=t.getStoredCrossSigningForUser(e.otherUserId).getId("master");else if(i===sr.VerifySelfTrusted)o=await Mi.getOtherDeviceKey(e,t);else if(i===sr.VerifySelfUntrusted){const c=t.getUserId();a=t.getStoredCrossSigningForUser(c).getId("master")}const l=Mi.generateQrData(e,t,i,r,s,o,a),u=Mi.generateBuffer(l);return new Mi(i,r,s,o,a,u)}get encodedSharedSecret(){return this.sharedSecret}getBuffer(){return this.buffer}static generateSharedSecret(){const e=new Uint8Array(11);return V.crypto.getRandomValues(e),(0,Zg.encodeUnpaddedBase64)(e)}static async getOtherDeviceKey(e,t){const r=t.getUserId(),i=e.targetDevice,s=i?i.deviceId:null,o=t.getStoredDevice(r,s);if(!o)throw new Error("could not find device "+s);return o.getFingerprint()}static determineMode(e,t){const r=t.getUserId(),i=e.otherUserId;let s=sr.VerifyOtherUser;return r===i&&(t.checkUserTrust(r).isCrossSigningVerified()?s=sr.VerifySelfTrusted:s=sr.VerifySelfUntrusted),s}static generateQrData(e,t,r,i,s,o,a){const l=t.getUserId(),u=e.channel.transactionId,c={prefix:DP,version:AP,mode:r,transactionId:u,firstKeyB64:"",secondKeyB64:"",secretB64:i},g=t.getStoredCrossSigningForUser(l);return r===sr.VerifyOtherUser?(c.firstKeyB64=g.getId("master"),c.secondKeyB64=s):r===sr.VerifySelfTrusted?(c.firstKeyB64=g.getId("master"),c.secondKeyB64=o):r===sr.VerifySelfUntrusted&&(c.firstKeyB64=t.getDeviceEd25519Key(),c.secondKeyB64=a),c}static generateBuffer(e){let t=Buffer.alloc(0);const r=a=>{const l=Buffer.from([a]);t=Buffer.concat([t,l])},i=a=>{const l=Buffer.alloc(2);l.writeInt16BE(a,0),t=Buffer.concat([t,l])},s=(a,l,u=!0)=>{const c=Buffer.from(a,l);u&&i(c.byteLength),t=Buffer.concat([t,c])},o=a=>{const l=(0,Zg.decodeBase64)(a),u=Buffer.from(l);t=Buffer.concat([t,u])};return s(e.prefix,"ascii",!1),r(e.version),r(e.mode),s(e.transactionId,"utf-8"),o(e.firstKeyB64),o(e.secondKeyB64),o(e.secretB64),t}}cr.QRCodeData=Mi;var ws={},E_=G.exports;Object.defineProperty(ws,"__esModule",{value:!0});ws.SasEvent=ws.SAS=void 0;var sa=E_(Y.exports),tm=E_(tu),ld=Xr,qn=Ke,xP=se;const ud="m.key.verification.start",UP=["m.key.verification.accept","m.key.verification.key","m.key.verification.mac"];let $c;const rm=(0,qn.errorFactory)("m.mismatched_sas","Mismatched short authentication string"),$P=(0,qn.errorFactory)("m.mismatched_commitment","Mismatched commitment");function NP(n){return[(n[0]<<5|n[1]>>3)+1e3,((n[1]&7)<<10|n[2]<<2|n[3]>>6)+1e3,((n[3]&63)<<7|n[4]>>1)+1e3]}const LP=[["\u{1F436}","dog"],["\u{1F431}","cat"],["\u{1F981}","lion"],["\u{1F40E}","horse"],["\u{1F984}","unicorn"],["\u{1F437}","pig"],["\u{1F418}","elephant"],["\u{1F430}","rabbit"],["\u{1F43C}","panda"],["\u{1F413}","rooster"],["\u{1F427}","penguin"],["\u{1F422}","turtle"],["\u{1F41F}","fish"],["\u{1F419}","octopus"],["\u{1F98B}","butterfly"],["\u{1F337}","flower"],["\u{1F333}","tree"],["\u{1F335}","cactus"],["\u{1F344}","mushroom"],["\u{1F30F}","globe"],["\u{1F319}","moon"],["\u2601\uFE0F","cloud"],["\u{1F525}","fire"],["\u{1F34C}","banana"],["\u{1F34E}","apple"],["\u{1F353}","strawberry"],["\u{1F33D}","corn"],["\u{1F355}","pizza"],["\u{1F382}","cake"],["\u2764\uFE0F","heart"],["\u{1F642}","smiley"],["\u{1F916}","robot"],["\u{1F3A9}","hat"],["\u{1F453}","glasses"],["\u{1F527}","spanner"],["\u{1F385}","santa"],["\u{1F44D}","thumbs up"],["\u2602\uFE0F","umbrella"],["\u231B","hourglass"],["\u23F0","clock"],["\u{1F381}","gift"],["\u{1F4A1}","light bulb"],["\u{1F4D5}","book"],["\u270F\uFE0F","pencil"],["\u{1F4CE}","paperclip"],["\u2702\uFE0F","scissors"],["\u{1F512}","lock"],["\u{1F511}","key"],["\u{1F528}","hammer"],["\u260E\uFE0F","telephone"],["\u{1F3C1}","flag"],["\u{1F682}","train"],["\u{1F6B2}","bicycle"],["\u2708\uFE0F","aeroplane"],["\u{1F680}","rocket"],["\u{1F3C6}","trophy"],["\u26BD","ball"],["\u{1F3B8}","guitar"],["\u{1F3BA}","trumpet"],["\u{1F514}","bell"],["\u2693\uFE0F","anchor"],["\u{1F3A7}","headphones"],["\u{1F4C1}","folder"],["\u{1F4CC}","pin"]];function BP(n){return[n[0]>>2,(n[0]&3)<<4|n[1]>>4,(n[1]&15)<<2|n[2]>>6,n[2]&63,n[3]>>2,(n[3]&3)<<4|n[4]>>4,(n[4]&15)<<2|n[5]>>6].map(t=>LP[t])}const xh={decimal:NP,emoji:BP};function nm(n,e){const t={};for(const r of e)r in xh&&(t[r]=xh[r](n));return t}const KP={"hkdf-hmac-sha256":"calculate_mac","hmac-sha256":"calculate_mac_long_kdf"};function oa(n,e){return function(...t){const i=n[KP[e]].apply(n,t);return xP.logger.log("SAS calculateMAC:",e,t,i),i}}const im={"curve25519-hkdf-sha256":function(n,e,t){const r=`${n.baseApis.getUserId()}|${n.baseApis.deviceId}|${n.ourSASPubKey}|`,i=`${n.userId}|${n.deviceId}|${n.theirSASPubKey}|`,s="MATRIX_KEY_VERIFICATION_SAS|"+(n.initiatedByMe?r+i:i+r)+n.channel.transactionId;return e.generate_bytes(s,t)},curve25519:function(n,e,t){const r=`${n.baseApis.getUserId()}${n.baseApis.deviceId}`,i=`${n.userId}${n.deviceId}`,s="MATRIX_KEY_VERIFICATION_SAS"+(n.initiatedByMe?r+i:i+r)+n.channel.transactionId;return e.generate_bytes(s,t)}},Uh=["curve25519-hkdf-sha256","curve25519"],$h=["sha256"],Nh=["hkdf-hmac-sha256","hmac-sha256"],S_=Object.keys(xh),FP=new Set(Uh),qP=new Set($h),jP=new Set(Nh),sm=new Set(S_);function aa(n,e){return n instanceof Array?n.filter(t=>e.has(t)):[]}let Ha;ws.SasEvent=Ha;(function(n){n.ShowSas="show_sas"})(Ha||(ws.SasEvent=Ha={}));class Pl extends ld.VerificationBase{constructor(...e){super(...e);(0,sa.default)(this,"waitingForAccept",void 0),(0,sa.default)(this,"ourSASPubKey",void 0),(0,sa.default)(this,"theirSASPubKey",void 0),(0,sa.default)(this,"sasEvent",void 0),(0,sa.default)(this,"doVerification",async()=>{await V.Olm.init(),$c=$c||new V.Olm.Utility,await this.baseApis.downloadKeys([this.userId]);let t=!1;do try{return this.initiatedByMe?await this.doSendVerification():await this.doRespondVerification()}catch(r){if(r instanceof ld.SwitchStartEventError)this.startEvent=r.startEvent,t=!0;else throw r}while(t)})}static get NAME(){return"m.sas.v1"}get events(){return UP}canSwitchStartEvent(e){if(e.getType()!==ud)return!1;const t=e.getContent();return t&&t.method===Pl.NAME&&this.waitingForAccept}async sendStart(){const e=this.channel.completeContent(ud,{method:Pl.NAME,from_device:this.baseApis.deviceId,key_agreement_protocols:Uh,hashes:$h,message_authentication_codes:Nh,short_authentication_string:S_});return await this.channel.sendCompleted(ud,e),e}async doSendVerification(){this.waitingForAccept=!0;let e;if(this.startEvent?e=this.channel.completedContentFromEvent(this.startEvent):e=await this.sendStart(),!this.initiatedByMe)throw new ld.SwitchStartEventError(this.startEvent);let t;try{t=await this.waitForEvent("m.key.verification.accept")}finally{this.waitingForAccept=!1}let r=t.getContent();const i=aa(r.short_authentication_string,sm);if(!(FP.has(r.key_agreement_protocol)&&qP.has(r.hash)&&jP.has(r.message_authentication_code)&&i.length))throw(0,qn.newUnknownMethodError)();if(typeof r.commitment!="string")throw(0,qn.newInvalidMessageError)();const s=r.key_agreement_protocol,o=r.message_authentication_code,a=r.commitment,l=new V.Olm.SAS;try{this.ourSASPubKey=l.get_pubkey(),await this.send("m.key.verification.key",{key:this.ourSASPubKey}),t=await this.waitForEvent("m.key.verification.key"),r=t.getContent();const u=r.key+tm.default.stringify(e);if($c.sha256(u)!==a)throw $P();this.theirSASPubKey=r.key,l.set_their_key(r.key);const c=im[s](this,l,6),g=new Promise((m,f)=>{this.sasEvent={sas:nm(c,i),confirm:async()=>{try{await this.sendMAC(l,o),m()}catch(E){f(E)}},cancel:()=>f((0,qn.newUserCancelledError)()),mismatch:()=>f(rm())},this.emit(Ha.ShowSas,this.sasEvent)});[t]=await Promise.all([this.waitForEvent("m.key.verification.mac").then(m=>(this.expectedEvent="m.key.verification.done",m)),g]),r=t.getContent(),await this.checkMAC(l,r,o)}finally{l.free()}}async doRespondVerification(){let e=this.channel.completedContentFromEvent(this.startEvent);const t=aa(Uh,new Set(e.key_agreement_protocols))[0],r=aa($h,new Set(e.hashes))[0],i=aa(Nh,new Set(e.message_authentication_codes))[0],s=aa(e.short_authentication_string,sm);if(!(t!==void 0&&r!==void 0&&i!==void 0&&s.length))throw(0,qn.newUnknownMethodError)();const o=new V.Olm.SAS;try{const a=o.get_pubkey()+tm.default.stringify(e);await this.send("m.key.verification.accept",{key_agreement_protocol:t,hash:r,message_authentication_code:i,short_authentication_string:s,commitment:$c.sha256(a)});let l=await this.waitForEvent("m.key.verification.key");e=l.getContent(),this.theirSASPubKey=e.key,o.set_their_key(e.key),this.ourSASPubKey=o.get_pubkey(),await this.send("m.key.verification.key",{key:this.ourSASPubKey});const u=im[t](this,o,6),c=new Promise((g,m)=>{this.sasEvent={sas:nm(u,s),confirm:async()=>{try{await this.sendMAC(o,i),g()}catch(f){m(f)}},cancel:()=>m((0,qn.newUserCancelledError)()),mismatch:()=>m(rm())},this.emit(Ha.ShowSas,this.sasEvent)});[l]=await Promise.all([this.waitForEvent("m.key.verification.mac").then(g=>(this.expectedEvent="m.key.verification.done",g)),c]),e=l.getContent(),await this.checkMAC(o,e,i)}finally{o.free()}}sendMAC(e,t){const r={},i=[],s="MATRIX_KEY_VERIFICATION_MAC"+this.baseApis.getUserId()+this.baseApis.deviceId+this.userId+this.deviceId+this.channel.transactionId,o=`ed25519:${this.baseApis.deviceId}`;r[o]=oa(e,t)(this.baseApis.getDeviceEd25519Key(),s+o),i.push(o);const a=this.baseApis.getCrossSigningId();if(a){const u=`ed25519:${a}`;r[u]=oa(e,t)(a,s+u),i.push(u)}const l=oa(e,t)(i.sort().join(","),s+"KEY_IDS");return this.send("m.key.verification.mac",{mac:r,keys:l})}async checkMAC(e,t,r){const i="MATRIX_KEY_VERIFICATION_MAC"+this.userId+this.deviceId+this.baseApis.getUserId()+this.baseApis.deviceId+this.channel.transactionId;if(t.keys!==oa(e,r)(Object.keys(t.mac).sort().join(","),i+"KEY_IDS"))throw(0,qn.newKeyMismatchError)();await this.verifyKeys(this.userId,t.mac,(s,o,a)=>{if(a!==oa(e,r)(o.keys[s],i+s))throw(0,qn.newKeyMismatchError)()})}}ws.SAS=Pl;var Us={};Object.defineProperty(Us,"__esModule",{value:!0});Us.deriveKey=Cf;Us.keyFromAuthData=HP;Us.keyFromPassphrase=YP;var VP=ai,GP=W;const WP=typeof window!="undefined"&&window.crypto?window.crypto.subtle||window.crypto.webkitSubtle:null,om=5e5,kf=256;async function HP(n,e){if(!V.Olm)throw new Error("Olm is not available");if(!n.private_key_salt||!n.private_key_iterations)throw new Error("Salt and/or iterations not found: this backup cannot be restored with a passphrase");return await Cf(e,n.private_key_salt,n.private_key_iterations,n.private_key_bits||kf)}async function YP(n){if(!V.Olm)throw new Error("Olm is not available");const e=(0,VP.randomString)(32);return{key:await Cf(n,e,om,kf),salt:e,iterations:om}}async function Cf(n,e,t,r=kf){return WP?zP(n,e,t,r):JP(n,e,t,r)}async function zP(n,e,t,r){const i=V.crypto.subtle,s=V.TextEncoder;if(!i||!s)throw new Error("Password-based backup is not avaiable on this platform");const o=await i.importKey("raw",new s().encode(n),{name:"PBKDF2"},!1,["deriveBits"]),a=await i.deriveBits({name:"PBKDF2",salt:new s().encode(e),iterations:t,hash:"SHA-512"},o,r);return new Uint8Array(a)}async function JP(n,e,t,r){const i=(0,GP.getCrypto)();if(!i)throw new Error("No usable crypto implementation");return i.pbkdf2Sync(n,Buffer.from(e,"binary"),t,r,"sha512")}var Vo={},Lh={exports:{}},b_={},au={};au.byteLength=ZP;au.toByteArray=tM;au.fromByteArray=iM;var En=[],Ar=[],XP=typeof Uint8Array!="undefined"?Uint8Array:Array,dd="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var Ys=0,QP=dd.length;Ys<QP;++Ys)En[Ys]=dd[Ys],Ar[dd.charCodeAt(Ys)]=Ys;Ar["-".charCodeAt(0)]=62;Ar["_".charCodeAt(0)]=63;function w_(n){var e=n.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=n.indexOf("=");t===-1&&(t=e);var r=t===e?0:4-t%4;return[t,r]}function ZP(n){var e=w_(n),t=e[0],r=e[1];return(t+r)*3/4-r}function eM(n,e,t){return(e+t)*3/4-t}function tM(n){var e,t=w_(n),r=t[0],i=t[1],s=new XP(eM(n,r,i)),o=0,a=i>0?r-4:r,l;for(l=0;l<a;l+=4)e=Ar[n.charCodeAt(l)]<<18|Ar[n.charCodeAt(l+1)]<<12|Ar[n.charCodeAt(l+2)]<<6|Ar[n.charCodeAt(l+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=Ar[n.charCodeAt(l)]<<2|Ar[n.charCodeAt(l+1)]>>4,s[o++]=e&255),i===1&&(e=Ar[n.charCodeAt(l)]<<10|Ar[n.charCodeAt(l+1)]<<4|Ar[n.charCodeAt(l+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function rM(n){return En[n>>18&63]+En[n>>12&63]+En[n>>6&63]+En[n&63]}function nM(n,e,t){for(var r,i=[],s=e;s<t;s+=3)r=(n[s]<<16&16711680)+(n[s+1]<<8&65280)+(n[s+2]&255),i.push(rM(r));return i.join("")}function iM(n){for(var e,t=n.length,r=t%3,i=[],s=16383,o=0,a=t-r;o<a;o+=s)i.push(nM(n,o,o+s>a?a:o+s));return r===1?(e=n[t-1],i.push(En[e>>2]+En[e<<4&63]+"==")):r===2&&(e=(n[t-2]<<8)+n[t-1],i.push(En[e>>10]+En[e>>4&63]+En[e<<2&63]+"=")),i.join("")}var Pf={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Pf.read=function(n,e,t,r,i){var s,o,a=i*8-r-1,l=(1<<a)-1,u=l>>1,c=-7,g=t?i-1:0,m=t?-1:1,f=n[e+g];for(g+=m,s=f&(1<<-c)-1,f>>=-c,c+=a;c>0;s=s*256+n[e+g],g+=m,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=r;c>0;o=o*256+n[e+g],g+=m,c-=8);if(s===0)s=1-u;else{if(s===l)return o?NaN:(f?-1:1)*(1/0);o=o+Math.pow(2,r),s=s-u}return(f?-1:1)*o*Math.pow(2,s-r)};Pf.write=function(n,e,t,r,i,s){var o,a,l,u=s*8-i-1,c=(1<<u)-1,g=c>>1,m=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:s-1,E=r?1:-1,I=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),o+g>=1?e+=m/l:e+=m*Math.pow(2,1-g),e*l>=2&&(o++,l/=2),o+g>=c?(a=0,o=c):o+g>=1?(a=(e*l-1)*Math.pow(2,i),o=o+g):(a=e*Math.pow(2,g-1)*Math.pow(2,i),o=0));i>=8;n[t+f]=a&255,f+=E,a/=256,i-=8);for(o=o<<i|a,u+=i;u>0;n[t+f]=o&255,f+=E,o/=256,u-=8);n[t+f-E]|=I*128};/*!
+ * The buffer module from node.js, for the browser.
+ *
+ * @author Feross Aboukhadijeh <https://feross.org>
+ * @license MIT
+ */(function(n){const e=au,t=Pf,r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=a,n.SlowBuffer=C,n.INSPECT_MAX_BYTES=50;const i=2147483647;n.kMaxLength=i,a.TYPED_ARRAY_SUPPORT=s(),!a.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function s(){try{const v=new Uint8Array(1),d={foo:function(){return 42}};return Object.setPrototypeOf(d,Uint8Array.prototype),Object.setPrototypeOf(v,d),v.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(!!a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(!!a.isBuffer(this))return this.byteOffset}});function o(v){if(v>i)throw new RangeError('The value "'+v+'" is invalid for option "size"');const d=new Uint8Array(v);return Object.setPrototypeOf(d,a.prototype),d}function a(v,d,h){if(typeof v=="number"){if(typeof d=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return g(v)}return l(v,d,h)}a.poolSize=8192;function l(v,d,h){if(typeof v=="string")return m(v,d);if(ArrayBuffer.isView(v))return E(v);if(v==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof v);if(Ht(v,ArrayBuffer)||v&&Ht(v.buffer,ArrayBuffer)||typeof SharedArrayBuffer!="undefined"&&(Ht(v,SharedArrayBuffer)||v&&Ht(v.buffer,SharedArrayBuffer)))return I(v,d,h);if(typeof v=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const b=v.valueOf&&v.valueOf();if(b!=null&&b!==v)return a.from(b,d,h);const P=w(v);if(P)return P;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof v[Symbol.toPrimitive]=="function")return a.from(v[Symbol.toPrimitive]("string"),d,h);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof v)}a.from=function(v,d,h){return l(v,d,h)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function u(v){if(typeof v!="number")throw new TypeError('"size" argument must be of type number');if(v<0)throw new RangeError('The value "'+v+'" is invalid for option "size"')}function c(v,d,h){return u(v),v<=0?o(v):d!==void 0?typeof h=="string"?o(v).fill(d,h):o(v).fill(d):o(v)}a.alloc=function(v,d,h){return c(v,d,h)};function g(v){return u(v),o(v<0?0:k(v)|0)}a.allocUnsafe=function(v){return g(v)},a.allocUnsafeSlow=function(v){return g(v)};function m(v,d){if((typeof d!="string"||d==="")&&(d="utf8"),!a.isEncoding(d))throw new TypeError("Unknown encoding: "+d);const h=S(v,d)|0;let b=o(h);const P=b.write(v,d);return P!==h&&(b=b.slice(0,P)),b}function f(v){const d=v.length<0?0:k(v.length)|0,h=o(d);for(let b=0;b<d;b+=1)h[b]=v[b]&255;return h}function E(v){if(Ht(v,Uint8Array)){const d=new Uint8Array(v);return I(d.buffer,d.byteOffset,d.byteLength)}return f(v)}function I(v,d,h){if(d<0||v.byteLength<d)throw new RangeError('"offset" is outside of buffer bounds');if(v.byteLength<d+(h||0))throw new RangeError('"length" is outside of buffer bounds');let b;return d===void 0&&h===void 0?b=new Uint8Array(v):h===void 0?b=new Uint8Array(v,d):b=new Uint8Array(v,d,h),Object.setPrototypeOf(b,a.prototype),b}function w(v){if(a.isBuffer(v)){const d=k(v.length)|0,h=o(d);return h.length===0||v.copy(h,0,0,d),h}if(v.length!==void 0)return typeof v.length!="number"||Wo(v.length)?o(0):f(v);if(v.type==="Buffer"&&Array.isArray(v.data))return f(v.data)}function k(v){if(v>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return v|0}function C(v){return+v!=v&&(v=0),a.alloc(+v)}a.isBuffer=function(d){return d!=null&&d._isBuffer===!0&&d!==a.prototype},a.compare=function(d,h){if(Ht(d,Uint8Array)&&(d=a.from(d,d.offset,d.byteLength)),Ht(h,Uint8Array)&&(h=a.from(h,h.offset,h.byteLength)),!a.isBuffer(d)||!a.isBuffer(h))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(d===h)return 0;let b=d.length,P=h.length;for(let A=0,$=Math.min(b,P);A<$;++A)if(d[A]!==h[A]){b=d[A],P=h[A];break}return b<P?-1:P<b?1:0},a.isEncoding=function(d){switch(String(d).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(d,h){if(!Array.isArray(d))throw new TypeError('"list" argument must be an Array of Buffers');if(d.length===0)return a.alloc(0);let b;if(h===void 0)for(h=0,b=0;b<d.length;++b)h+=d[b].length;const P=a.allocUnsafe(h);let A=0;for(b=0;b<d.length;++b){let $=d[b];if(Ht($,Uint8Array))A+$.length>P.length?(a.isBuffer($)||($=a.from($)),$.copy(P,A)):Uint8Array.prototype.set.call(P,$,A);else if(a.isBuffer($))$.copy(P,A);else throw new TypeError('"list" argument must be an Array of Buffers');A+=$.length}return P};function S(v,d){if(a.isBuffer(v))return v.length;if(ArrayBuffer.isView(v)||Ht(v,ArrayBuffer))return v.byteLength;if(typeof v!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof v);const h=v.length,b=arguments.length>2&&arguments[2]===!0;if(!b&&h===0)return 0;let P=!1;for(;;)switch(d){case"ascii":case"latin1":case"binary":return h;case"utf8":case"utf-8":return Ns(v).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return h*2;case"hex":return h>>>1;case"base64":return Mn(v).length;default:if(P)return b?-1:Ns(v).length;d=(""+d).toLowerCase(),P=!0}}a.byteLength=S;function T(v,d,h){let b=!1;if((d===void 0||d<0)&&(d=0),d>this.length||((h===void 0||h>this.length)&&(h=this.length),h<=0)||(h>>>=0,d>>>=0,h<=d))return"";for(v||(v="utf8");;)switch(v){case"hex":return Kr(this,d,h);case"utf8":case"utf-8":return Ye(this,d,h);case"ascii":return Q(this,d,h);case"latin1":case"binary":return rn(this,d,h);case"base64":return Te(this,d,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return di(this,d,h);default:if(b)throw new TypeError("Unknown encoding: "+v);v=(v+"").toLowerCase(),b=!0}}a.prototype._isBuffer=!0;function D(v,d,h){const b=v[d];v[d]=v[h],v[h]=b}a.prototype.swap16=function(){const d=this.length;if(d%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let h=0;h<d;h+=2)D(this,h,h+1);return this},a.prototype.swap32=function(){const d=this.length;if(d%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let h=0;h<d;h+=4)D(this,h,h+3),D(this,h+1,h+2);return this},a.prototype.swap64=function(){const d=this.length;if(d%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let h=0;h<d;h+=8)D(this,h,h+7),D(this,h+1,h+6),D(this,h+2,h+5),D(this,h+3,h+4);return this},a.prototype.toString=function(){const d=this.length;return d===0?"":arguments.length===0?Ye(this,0,d):T.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(d){if(!a.isBuffer(d))throw new TypeError("Argument must be a Buffer");return this===d?!0:a.compare(this,d)===0},a.prototype.inspect=function(){let d="";const h=n.INSPECT_MAX_BYTES;return d=this.toString("hex",0,h).replace(/(.{2})/g,"$1 ").trim(),this.length>h&&(d+=" ... "),"<Buffer "+d+">"},r&&(a.prototype[r]=a.prototype.inspect),a.prototype.compare=function(d,h,b,P,A){if(Ht(d,Uint8Array)&&(d=a.from(d,d.offset,d.byteLength)),!a.isBuffer(d))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof d);if(h===void 0&&(h=0),b===void 0&&(b=d?d.length:0),P===void 0&&(P=0),A===void 0&&(A=this.length),h<0||b>d.length||P<0||A>this.length)throw new RangeError("out of range index");if(P>=A&&h>=b)return 0;if(P>=A)return-1;if(h>=b)return 1;if(h>>>=0,b>>>=0,P>>>=0,A>>>=0,this===d)return 0;let $=A-P,ne=b-h;const Ie=Math.min($,ne),de=this.slice(P,A),ke=d.slice(h,b);for(let ve=0;ve<Ie;++ve)if(de[ve]!==ke[ve]){$=de[ve],ne=ke[ve];break}return $<ne?-1:ne<$?1:0};function R(v,d,h,b,P){if(v.length===0)return-1;if(typeof h=="string"?(b=h,h=0):h>2147483647?h=2147483647:h<-2147483648&&(h=-2147483648),h=+h,Wo(h)&&(h=P?0:v.length-1),h<0&&(h=v.length+h),h>=v.length){if(P)return-1;h=v.length-1}else if(h<0)if(P)h=0;else return-1;if(typeof d=="string"&&(d=a.from(d,b)),a.isBuffer(d))return d.length===0?-1:U(v,d,h,b,P);if(typeof d=="number")return d=d&255,typeof Uint8Array.prototype.indexOf=="function"?P?Uint8Array.prototype.indexOf.call(v,d,h):Uint8Array.prototype.lastIndexOf.call(v,d,h):U(v,[d],h,b,P);throw new TypeError("val must be string, number or Buffer")}function U(v,d,h,b,P){let A=1,$=v.length,ne=d.length;if(b!==void 0&&(b=String(b).toLowerCase(),b==="ucs2"||b==="ucs-2"||b==="utf16le"||b==="utf-16le")){if(v.length<2||d.length<2)return-1;A=2,$/=2,ne/=2,h/=2}function Ie(ke,ve){return A===1?ke[ve]:ke.readUInt16BE(ve*A)}let de;if(P){let ke=-1;for(de=h;de<$;de++)if(Ie(v,de)===Ie(d,ke===-1?0:de-ke)){if(ke===-1&&(ke=de),de-ke+1===ne)return ke*A}else ke!==-1&&(de-=de-ke),ke=-1}else for(h+ne>$&&(h=$-ne),de=h;de>=0;de--){let ke=!0;for(let ve=0;ve<ne;ve++)if(Ie(v,de+ve)!==Ie(d,ve)){ke=!1;break}if(ke)return de}return-1}a.prototype.includes=function(d,h,b){return this.indexOf(d,h,b)!==-1},a.prototype.indexOf=function(d,h,b){return R(this,d,h,b,!0)},a.prototype.lastIndexOf=function(d,h,b){return R(this,d,h,b,!1)};function q(v,d,h,b){h=Number(h)||0;const P=v.length-h;b?(b=Number(b),b>P&&(b=P)):b=P;const A=d.length;b>A/2&&(b=A/2);let $;for($=0;$<b;++$){const ne=parseInt(d.substr($*2,2),16);if(Wo(ne))return $;v[h+$]=ne}return $}function B(v,d,h,b){return gi(Ns(d,v.length-h),v,h,b)}function te(v,d,h,b){return gi(dc(d),v,h,b)}function ye(v,d,h,b){return gi(Mn(d),v,h,b)}function we(v,d,h,b){return gi(yu(d,v.length-h),v,h,b)}a.prototype.write=function(d,h,b,P){if(h===void 0)P="utf8",b=this.length,h=0;else if(b===void 0&&typeof h=="string")P=h,b=this.length,h=0;else if(isFinite(h))h=h>>>0,isFinite(b)?(b=b>>>0,P===void 0&&(P="utf8")):(P=b,b=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const A=this.length-h;if((b===void 0||b>A)&&(b=A),d.length>0&&(b<0||h<0)||h>this.length)throw new RangeError("Attempt to write outside buffer bounds");P||(P="utf8");let $=!1;for(;;)switch(P){case"hex":return q(this,d,h,b);case"utf8":case"utf-8":return B(this,d,h,b);case"ascii":case"latin1":case"binary":return te(this,d,h,b);case"base64":return ye(this,d,h,b);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return we(this,d,h,b);default:if($)throw new TypeError("Unknown encoding: "+P);P=(""+P).toLowerCase(),$=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Te(v,d,h){return d===0&&h===v.length?e.fromByteArray(v):e.fromByteArray(v.slice(d,h))}function Ye(v,d,h){h=Math.min(v.length,h);const b=[];let P=d;for(;P<h;){const A=v[P];let $=null,ne=A>239?4:A>223?3:A>191?2:1;if(P+ne<=h){let Ie,de,ke,ve;switch(ne){case 1:A<128&&($=A);break;case 2:Ie=v[P+1],(Ie&192)===128&&(ve=(A&31)<<6|Ie&63,ve>127&&($=ve));break;case 3:Ie=v[P+1],de=v[P+2],(Ie&192)===128&&(de&192)===128&&(ve=(A&15)<<12|(Ie&63)<<6|de&63,ve>2047&&(ve<55296||ve>57343)&&($=ve));break;case 4:Ie=v[P+1],de=v[P+2],ke=v[P+3],(Ie&192)===128&&(de&192)===128&&(ke&192)===128&&(ve=(A&15)<<18|(Ie&63)<<12|(de&63)<<6|ke&63,ve>65535&&ve<1114112&&($=ve))}}$===null?($=65533,ne=1):$>65535&&($-=65536,b.push($>>>10&1023|55296),$=56320|$&1023),b.push($),P+=ne}return Gt(b)}const Vt=4096;function Gt(v){const d=v.length;if(d<=Vt)return String.fromCharCode.apply(String,v);let h="",b=0;for(;b<d;)h+=String.fromCharCode.apply(String,v.slice(b,b+=Vt));return h}function Q(v,d,h){let b="";h=Math.min(v.length,h);for(let P=d;P<h;++P)b+=String.fromCharCode(v[P]&127);return b}function rn(v,d,h){let b="";h=Math.min(v.length,h);for(let P=d;P<h;++P)b+=String.fromCharCode(v[P]);return b}function Kr(v,d,h){const b=v.length;(!d||d<0)&&(d=0),(!h||h<0||h>b)&&(h=b);let P="";for(let A=d;A<h;++A)P+=hc[v[A]];return P}function di(v,d,h){const b=v.slice(d,h);let P="";for(let A=0;A<b.length-1;A+=2)P+=String.fromCharCode(b[A]+b[A+1]*256);return P}a.prototype.slice=function(d,h){const b=this.length;d=~~d,h=h===void 0?b:~~h,d<0?(d+=b,d<0&&(d=0)):d>b&&(d=b),h<0?(h+=b,h<0&&(h=0)):h>b&&(h=b),h<d&&(h=d);const P=this.subarray(d,h);return Object.setPrototypeOf(P,a.prototype),P};function Re(v,d,h){if(v%1!==0||v<0)throw new RangeError("offset is not uint");if(v+d>h)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(d,h,b){d=d>>>0,h=h>>>0,b||Re(d,h,this.length);let P=this[d],A=1,$=0;for(;++$<h&&(A*=256);)P+=this[d+$]*A;return P},a.prototype.readUintBE=a.prototype.readUIntBE=function(d,h,b){d=d>>>0,h=h>>>0,b||Re(d,h,this.length);let P=this[d+--h],A=1;for(;h>0&&(A*=256);)P+=this[d+--h]*A;return P},a.prototype.readUint8=a.prototype.readUInt8=function(d,h){return d=d>>>0,h||Re(d,1,this.length),this[d]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(d,h){return d=d>>>0,h||Re(d,2,this.length),this[d]|this[d+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(d,h){return d=d>>>0,h||Re(d,2,this.length),this[d]<<8|this[d+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(d,h){return d=d>>>0,h||Re(d,4,this.length),(this[d]|this[d+1]<<8|this[d+2]<<16)+this[d+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(d,h){return d=d>>>0,h||Re(d,4,this.length),this[d]*16777216+(this[d+1]<<16|this[d+2]<<8|this[d+3])},a.prototype.readBigUInt64LE=qr(function(d){d=d>>>0,ot(d,"offset");const h=this[d],b=this[d+7];(h===void 0||b===void 0)&&at(d,this.length-8);const P=h+this[++d]*2**8+this[++d]*2**16+this[++d]*2**24,A=this[++d]+this[++d]*2**8+this[++d]*2**16+b*2**24;return BigInt(P)+(BigInt(A)<<BigInt(32))}),a.prototype.readBigUInt64BE=qr(function(d){d=d>>>0,ot(d,"offset");const h=this[d],b=this[d+7];(h===void 0||b===void 0)&&at(d,this.length-8);const P=h*2**24+this[++d]*2**16+this[++d]*2**8+this[++d],A=this[++d]*2**24+this[++d]*2**16+this[++d]*2**8+b;return(BigInt(P)<<BigInt(32))+BigInt(A)}),a.prototype.readIntLE=function(d,h,b){d=d>>>0,h=h>>>0,b||Re(d,h,this.length);let P=this[d],A=1,$=0;for(;++$<h&&(A*=256);)P+=this[d+$]*A;return A*=128,P>=A&&(P-=Math.pow(2,8*h)),P},a.prototype.readIntBE=function(d,h,b){d=d>>>0,h=h>>>0,b||Re(d,h,this.length);let P=h,A=1,$=this[d+--P];for(;P>0&&(A*=256);)$+=this[d+--P]*A;return A*=128,$>=A&&($-=Math.pow(2,8*h)),$},a.prototype.readInt8=function(d,h){return d=d>>>0,h||Re(d,1,this.length),this[d]&128?(255-this[d]+1)*-1:this[d]},a.prototype.readInt16LE=function(d,h){d=d>>>0,h||Re(d,2,this.length);const b=this[d]|this[d+1]<<8;return b&32768?b|4294901760:b},a.prototype.readInt16BE=function(d,h){d=d>>>0,h||Re(d,2,this.length);const b=this[d+1]|this[d]<<8;return b&32768?b|4294901760:b},a.prototype.readInt32LE=function(d,h){return d=d>>>0,h||Re(d,4,this.length),this[d]|this[d+1]<<8|this[d+2]<<16|this[d+3]<<24},a.prototype.readInt32BE=function(d,h){return d=d>>>0,h||Re(d,4,this.length),this[d]<<24|this[d+1]<<16|this[d+2]<<8|this[d+3]},a.prototype.readBigInt64LE=qr(function(d){d=d>>>0,ot(d,"offset");const h=this[d],b=this[d+7];(h===void 0||b===void 0)&&at(d,this.length-8);const P=this[d+4]+this[d+5]*2**8+this[d+6]*2**16+(b<<24);return(BigInt(P)<<BigInt(32))+BigInt(h+this[++d]*2**8+this[++d]*2**16+this[++d]*2**24)}),a.prototype.readBigInt64BE=qr(function(d){d=d>>>0,ot(d,"offset");const h=this[d],b=this[d+7];(h===void 0||b===void 0)&&at(d,this.length-8);const P=(h<<24)+this[++d]*2**16+this[++d]*2**8+this[++d];return(BigInt(P)<<BigInt(32))+BigInt(this[++d]*2**24+this[++d]*2**16+this[++d]*2**8+b)}),a.prototype.readFloatLE=function(d,h){return d=d>>>0,h||Re(d,4,this.length),t.read(this,d,!0,23,4)},a.prototype.readFloatBE=function(d,h){return d=d>>>0,h||Re(d,4,this.length),t.read(this,d,!1,23,4)},a.prototype.readDoubleLE=function(d,h){return d=d>>>0,h||Re(d,8,this.length),t.read(this,d,!0,52,8)},a.prototype.readDoubleBE=function(d,h){return d=d>>>0,h||Re(d,8,this.length),t.read(this,d,!1,52,8)};function $e(v,d,h,b,P,A){if(!a.isBuffer(v))throw new TypeError('"buffer" argument must be a Buffer instance');if(d>P||d<A)throw new RangeError('"value" argument is out of bounds');if(h+b>v.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(d,h,b,P){if(d=+d,h=h>>>0,b=b>>>0,!P){const ne=Math.pow(2,8*b)-1;$e(this,d,h,b,ne,0)}let A=1,$=0;for(this[h]=d&255;++$<b&&(A*=256);)this[h+$]=d/A&255;return h+b},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(d,h,b,P){if(d=+d,h=h>>>0,b=b>>>0,!P){const ne=Math.pow(2,8*b)-1;$e(this,d,h,b,ne,0)}let A=b-1,$=1;for(this[h+A]=d&255;--A>=0&&($*=256);)this[h+A]=d/$&255;return h+b},a.prototype.writeUint8=a.prototype.writeUInt8=function(d,h,b){return d=+d,h=h>>>0,b||$e(this,d,h,1,255,0),this[h]=d&255,h+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(d,h,b){return d=+d,h=h>>>0,b||$e(this,d,h,2,65535,0),this[h]=d&255,this[h+1]=d>>>8,h+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(d,h,b){return d=+d,h=h>>>0,b||$e(this,d,h,2,65535,0),this[h]=d>>>8,this[h+1]=d&255,h+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(d,h,b){return d=+d,h=h>>>0,b||$e(this,d,h,4,4294967295,0),this[h+3]=d>>>24,this[h+2]=d>>>16,this[h+1]=d>>>8,this[h]=d&255,h+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(d,h,b){return d=+d,h=h>>>0,b||$e(this,d,h,4,4294967295,0),this[h]=d>>>24,this[h+1]=d>>>16,this[h+2]=d>>>8,this[h+3]=d&255,h+4};function hi(v,d,h,b,P){Sr(d,b,P,v,h,7);let A=Number(d&BigInt(4294967295));v[h++]=A,A=A>>8,v[h++]=A,A=A>>8,v[h++]=A,A=A>>8,v[h++]=A;let $=Number(d>>BigInt(32)&BigInt(4294967295));return v[h++]=$,$=$>>8,v[h++]=$,$=$>>8,v[h++]=$,$=$>>8,v[h++]=$,h}function Fr(v,d,h,b,P){Sr(d,b,P,v,h,7);let A=Number(d&BigInt(4294967295));v[h+7]=A,A=A>>8,v[h+6]=A,A=A>>8,v[h+5]=A,A=A>>8,v[h+4]=A;let $=Number(d>>BigInt(32)&BigInt(4294967295));return v[h+3]=$,$=$>>8,v[h+2]=$,$=$>>8,v[h+1]=$,$=$>>8,v[h]=$,h+8}a.prototype.writeBigUInt64LE=qr(function(d,h=0){return hi(this,d,h,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=qr(function(d,h=0){return Fr(this,d,h,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(d,h,b,P){if(d=+d,h=h>>>0,!P){const Ie=Math.pow(2,8*b-1);$e(this,d,h,b,Ie-1,-Ie)}let A=0,$=1,ne=0;for(this[h]=d&255;++A<b&&($*=256);)d<0&&ne===0&&this[h+A-1]!==0&&(ne=1),this[h+A]=(d/$>>0)-ne&255;return h+b},a.prototype.writeIntBE=function(d,h,b,P){if(d=+d,h=h>>>0,!P){const Ie=Math.pow(2,8*b-1);$e(this,d,h,b,Ie-1,-Ie)}let A=b-1,$=1,ne=0;for(this[h+A]=d&255;--A>=0&&($*=256);)d<0&&ne===0&&this[h+A+1]!==0&&(ne=1),this[h+A]=(d/$>>0)-ne&255;return h+b},a.prototype.writeInt8=function(d,h,b){return d=+d,h=h>>>0,b||$e(this,d,h,1,127,-128),d<0&&(d=255+d+1),this[h]=d&255,h+1},a.prototype.writeInt16LE=function(d,h,b){return d=+d,h=h>>>0,b||$e(this,d,h,2,32767,-32768),this[h]=d&255,this[h+1]=d>>>8,h+2},a.prototype.writeInt16BE=function(d,h,b){return d=+d,h=h>>>0,b||$e(this,d,h,2,32767,-32768),this[h]=d>>>8,this[h+1]=d&255,h+2},a.prototype.writeInt32LE=function(d,h,b){return d=+d,h=h>>>0,b||$e(this,d,h,4,2147483647,-2147483648),this[h]=d&255,this[h+1]=d>>>8,this[h+2]=d>>>16,this[h+3]=d>>>24,h+4},a.prototype.writeInt32BE=function(d,h,b){return d=+d,h=h>>>0,b||$e(this,d,h,4,2147483647,-2147483648),d<0&&(d=4294967295+d+1),this[h]=d>>>24,this[h+1]=d>>>16,this[h+2]=d>>>8,this[h+3]=d&255,h+4},a.prototype.writeBigInt64LE=qr(function(d,h=0){return hi(this,d,h,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=qr(function(d,h=0){return Fr(this,d,h,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Pn(v,d,h,b,P,A){if(h+b>v.length)throw new RangeError("Index out of range");if(h<0)throw new RangeError("Index out of range")}function fi(v,d,h,b,P){return d=+d,h=h>>>0,P||Pn(v,d,h,4),t.write(v,d,h,b,23,4),h+4}a.prototype.writeFloatLE=function(d,h,b){return fi(this,d,h,!0,b)},a.prototype.writeFloatBE=function(d,h,b){return fi(this,d,h,!1,b)};function pi(v,d,h,b,P){return d=+d,h=h>>>0,P||Pn(v,d,h,8),t.write(v,d,h,b,52,8),h+8}a.prototype.writeDoubleLE=function(d,h,b){return pi(this,d,h,!0,b)},a.prototype.writeDoubleBE=function(d,h,b){return pi(this,d,h,!1,b)},a.prototype.copy=function(d,h,b,P){if(!a.isBuffer(d))throw new TypeError("argument should be a Buffer");if(b||(b=0),!P&&P!==0&&(P=this.length),h>=d.length&&(h=d.length),h||(h=0),P>0&&P<b&&(P=b),P===b||d.length===0||this.length===0)return 0;if(h<0)throw new RangeError("targetStart out of bounds");if(b<0||b>=this.length)throw new RangeError("Index out of range");if(P<0)throw new RangeError("sourceEnd out of bounds");P>this.length&&(P=this.length),d.length-h<P-b&&(P=d.length-h+b);const A=P-b;return this===d&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(h,b,P):Uint8Array.prototype.set.call(d,this.subarray(b,P),h),A},a.prototype.fill=function(d,h,b,P){if(typeof d=="string"){if(typeof h=="string"?(P=h,h=0,b=this.length):typeof b=="string"&&(P=b,b=this.length),P!==void 0&&typeof P!="string")throw new TypeError("encoding must be a string");if(typeof P=="string"&&!a.isEncoding(P))throw new TypeError("Unknown encoding: "+P);if(d.length===1){const $=d.charCodeAt(0);(P==="utf8"&&$<128||P==="latin1")&&(d=$)}}else typeof d=="number"?d=d&255:typeof d=="boolean"&&(d=Number(d));if(h<0||this.length<h||this.length<b)throw new RangeError("Out of range index");if(b<=h)return this;h=h>>>0,b=b===void 0?this.length:b>>>0,d||(d=0);let A;if(typeof d=="number")for(A=h;A<b;++A)this[A]=d;else{const $=a.isBuffer(d)?d:a.from(d,P),ne=$.length;if(ne===0)throw new TypeError('The value "'+d+'" is invalid for argument "value"');for(A=0;A<b-h;++A)this[A+h]=$[A%ne]}return this};const _={};function dr(v,d,h){_[v]=class extends h{constructor(){super();Object.defineProperty(this,"message",{value:d.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${v}]`,this.stack,delete this.name}get code(){return v}set code(P){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:P,writable:!0})}toString(){return`${this.name} [${v}]: ${this.message}`}}}dr("ERR_BUFFER_OUT_OF_BOUNDS",function(v){return v?`${v} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),dr("ERR_INVALID_ARG_TYPE",function(v,d){return`The "${v}" argument must be of type number. Received type ${typeof d}`},TypeError),dr("ERR_OUT_OF_RANGE",function(v,d,h){let b=`The value of "${v}" is out of range.`,P=h;return Number.isInteger(h)&&Math.abs(h)>2**32?P=At(String(h)):typeof h=="bigint"&&(P=String(h),(h>BigInt(2)**BigInt(32)||h<-(BigInt(2)**BigInt(32)))&&(P=At(P)),P+="n"),b+=` It must be ${d}. Received ${P}`,b},RangeError);function At(v){let d="",h=v.length;const b=v[0]==="-"?1:0;for(;h>=b+4;h-=3)d=`_${v.slice(h-3,h)}${d}`;return`${v.slice(0,h)}${d}`}function hr(v,d,h){ot(d,"offset"),(v[d]===void 0||v[d+h]===void 0)&&at(d,v.length-(h+1))}function Sr(v,d,h,b,P,A){if(v>h||v<d){const $=typeof d=="bigint"?"n":"";let ne;throw A>3?d===0||d===BigInt(0)?ne=`>= 0${$} and < 2${$} ** ${(A+1)*8}${$}`:ne=`>= -(2${$} ** ${(A+1)*8-1}${$}) and < 2 ** ${(A+1)*8-1}${$}`:ne=`>= ${d}${$} and <= ${h}${$}`,new _.ERR_OUT_OF_RANGE("value",ne,v)}hr(b,P,A)}function ot(v,d){if(typeof v!="number")throw new _.ERR_INVALID_ARG_TYPE(d,"number",v)}function at(v,d,h){throw Math.floor(v)!==v?(ot(v,h),new _.ERR_OUT_OF_RANGE(h||"offset","an integer",v)):d<0?new _.ERR_BUFFER_OUT_OF_BOUNDS:new _.ERR_OUT_OF_RANGE(h||"offset",`>= ${h?1:0} and <= ${d}`,v)}const uc=/[^+/0-9A-Za-z-_]/g;function Wt(v){if(v=v.split("=")[0],v=v.trim().replace(uc,""),v.length<2)return"";for(;v.length%4!==0;)v=v+"=";return v}function Ns(v,d){d=d||1/0;let h;const b=v.length;let P=null;const A=[];for(let $=0;$<b;++$){if(h=v.charCodeAt($),h>55295&&h<57344){if(!P){if(h>56319){(d-=3)>-1&&A.push(239,191,189);continue}else if($+1===b){(d-=3)>-1&&A.push(239,191,189);continue}P=h;continue}if(h<56320){(d-=3)>-1&&A.push(239,191,189),P=h;continue}h=(P-55296<<10|h-56320)+65536}else P&&(d-=3)>-1&&A.push(239,191,189);if(P=null,h<128){if((d-=1)<0)break;A.push(h)}else if(h<2048){if((d-=2)<0)break;A.push(h>>6|192,h&63|128)}else if(h<65536){if((d-=3)<0)break;A.push(h>>12|224,h>>6&63|128,h&63|128)}else if(h<1114112){if((d-=4)<0)break;A.push(h>>18|240,h>>12&63|128,h>>6&63|128,h&63|128)}else throw new Error("Invalid code point")}return A}function dc(v){const d=[];for(let h=0;h<v.length;++h)d.push(v.charCodeAt(h)&255);return d}function yu(v,d){let h,b,P;const A=[];for(let $=0;$<v.length&&!((d-=2)<0);++$)h=v.charCodeAt($),b=h>>8,P=h%256,A.push(P),A.push(b);return A}function Mn(v){return e.toByteArray(Wt(v))}function gi(v,d,h,b){let P;for(P=0;P<b&&!(P+h>=d.length||P>=v.length);++P)d[P+h]=v[P];return P}function Ht(v,d){return v instanceof d||v!=null&&v.constructor!=null&&v.constructor.name!=null&&v.constructor.name===d.name}function Wo(v){return v!==v}const hc=function(){const v="0123456789abcdef",d=new Array(256);for(let h=0;h<16;++h){const b=h*16;for(let P=0;P<16;++P)d[b+P]=v[h]+v[P]}return d}();function qr(v){return typeof BigInt=="undefined"?fc:v}function fc(){throw new Error("BigInt not supported")}})(b_);(function(n,e){var t=b_,r=t.Buffer;function i(o,a){for(var l in o)a[l]=o[l]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?n.exports=t:(i(t,e),e.Buffer=s);function s(o,a,l){return r(o,a,l)}i(r,s),s.from=function(o,a,l){if(typeof o=="number")throw new TypeError("Argument must not be a number");return r(o,a,l)},s.alloc=function(o,a,l){if(typeof o!="number")throw new TypeError("Argument must be a number");var u=r(o);return a!==void 0?typeof l=="string"?u.fill(a,l):u.fill(a):u.fill(0),u},s.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r(o)},s.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return t.SlowBuffer(o)}})(Lh,Lh.exports);var Nc=Lh.exports.Buffer;function sM(n){if(n.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),t=0;t<e.length;t++)e[t]=255;for(var r=0;r<n.length;r++){var i=n.charAt(r),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=r}var o=n.length,a=n.charAt(0),l=Math.log(o)/Math.log(256),u=Math.log(256)/Math.log(o);function c(f){if((Array.isArray(f)||f instanceof Uint8Array)&&(f=Nc.from(f)),!Nc.isBuffer(f))throw new TypeError("Expected Buffer");if(f.length===0)return"";for(var E=0,I=0,w=0,k=f.length;w!==k&&f[w]===0;)w++,E++;for(var C=(k-w)*u+1>>>0,S=new Uint8Array(C);w!==k;){for(var T=f[w],D=0,R=C-1;(T!==0||D<I)&&R!==-1;R--,D++)T+=256*S[R]>>>0,S[R]=T%o>>>0,T=T/o>>>0;if(T!==0)throw new Error("Non-zero carry");I=D,w++}for(var U=C-I;U!==C&&S[U]===0;)U++;for(var q=a.repeat(E);U<C;++U)q+=n.charAt(S[U]);return q}function g(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return Nc.alloc(0);for(var E=0,I=0,w=0;f[E]===a;)I++,E++;for(var k=(f.length-E)*l+1>>>0,C=new Uint8Array(k);f[E];){var S=e[f.charCodeAt(E)];if(S===255)return;for(var T=0,D=k-1;(S!==0||T<w)&&D!==-1;D--,T++)S+=o*C[D]>>>0,C[D]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");w=T,E++}for(var R=k-w;R!==k&&C[R]===0;)R++;var U=Nc.allocUnsafe(I+(k-R));U.fill(0,0,I);for(var q=I;R!==k;)U[q++]=C[R++];return U}function m(f){var E=g(f);if(E)return E;throw new Error("Non-base"+o+" character")}return{encode:c,decodeUnsafe:g,decode:m}}var oM=sM,aM=oM,cM="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",lM=aM(cM),uM=G.exports;Object.defineProperty(Vo,"__esModule",{value:!0});Vo.decodeRecoveryKey=hM;Vo.encodeRecoveryKey=dM;var R_=uM(lM);const Di=[139,1];function dM(n){const e=new Buffer(Di.length+n.length+1);e.set(Di,0),e.set(n,Di.length);let t=0;for(let i=0;i<e.length-1;++i)t^=e[i];return e[e.length-1]=t,R_.default.encode(e).match(/.{1,4}/g).join(" ")}function hM(n){const e=R_.default.decode(n.replace(/ /g,""));let t=0;for(const r of e)t^=r;if(t!==0)throw new Error("Incorrect parity");for(let r=0;r<Di.length;++r)if(e[r]!==Di[r])throw new Error("Incorrect prefix");if(e.length!==Di.length+V.Olm.PRIVATE_KEY_LENGTH+1)throw new Error("Incorrect length");return Uint8Array.from(e.slice(Di.length,Di.length+V.Olm.PRIVATE_KEY_LENGTH))}var fe={},fM=G.exports;Object.defineProperty(fe,"__esModule",{value:!0});fe.VerificationRequestEvent=fe.VerificationRequest=fe.START_TYPE=fe.REQUEST_TYPE=fe.READY_TYPE=fe.Phase=fe.PHASE_UNSENT=fe.PHASE_STARTED=fe.PHASE_REQUESTED=fe.PHASE_READY=fe.PHASE_DONE=fe.PHASE_CANCELLED=fe.EVENT_PREFIX=fe.DONE_TYPE=fe.CANCEL_TYPE=void 0;var Tt=fM(Y.exports),Wi=se,Hi=Ke,am=cr,pM=je;const gM=10*60*1e3,mM=2*60*1e3,yM=3*1e3,$s="m.key.verification.";fe.EVENT_PREFIX=$s;const tr=$s+"request";fe.REQUEST_TYPE=tr;const gr=$s+"start";fe.START_TYPE=gr;const es=$s+"cancel";fe.CANCEL_TYPE=es;const I_=$s+"done";fe.DONE_TYPE=I_;const Oi=$s+"ready";fe.READY_TYPE=Oi;let ni;fe.Phase=ni;(function(n){n[n.Unsent=1]="Unsent",n[n.Requested=2]="Requested",n[n.Ready=3]="Ready",n[n.Started=4]="Started",n[n.Cancelled=5]="Cancelled",n[n.Done=6]="Done"})(ni||(fe.Phase=ni={}));const dn=ni.Unsent;fe.PHASE_UNSENT=dn;const Mr=ni.Requested;fe.PHASE_REQUESTED=Mr;const hn=ni.Ready;fe.PHASE_READY=hn;const ts=ni.Started;fe.PHASE_STARTED=ts;const ao=ni.Cancelled;fe.PHASE_CANCELLED=ao;const co=ni.Done;fe.PHASE_DONE=co;let Hn;fe.VerificationRequestEvent=Hn;(function(n){n.Change="change"})(Hn||(fe.VerificationRequestEvent=Hn={}));class vM extends pM.TypedEventEmitter{constructor(e,t,r){super();this.channel=e,this.verificationMethods=t,this.client=r,(0,Tt.default)(this,"eventsByUs",new Map),(0,Tt.default)(this,"eventsByThem",new Map),(0,Tt.default)(this,"_observeOnly",!1),(0,Tt.default)(this,"timeoutTimer",null),(0,Tt.default)(this,"_accepting",!1),(0,Tt.default)(this,"_declining",!1),(0,Tt.default)(this,"verifierHasFinished",!1),(0,Tt.default)(this,"_cancelled",!1),(0,Tt.default)(this,"_chosenMethod",null),(0,Tt.default)(this,"_qrCodeData",null),(0,Tt.default)(this,"requestReceivedAt",null),(0,Tt.default)(this,"commonMethods",[]),(0,Tt.default)(this,"_phase",void 0),(0,Tt.default)(this,"_cancellingUserId",void 0),(0,Tt.default)(this,"_verifier",void 0),(0,Tt.default)(this,"cancelOnTimeout",()=>{try{this.initiatedByMe?this.cancel({reason:"Other party didn't accept in time",code:"m.timeout"}):this.cancel({reason:"User didn't accept in time",code:"m.timeout"})}catch(i){Wi.logger.error("Error while cancelling verification request",i)}}),this.channel.request=this,this.setPhase(dn,!1)}static validateEvent(e,t,r){const i=t.getContent();return!e||!e.startsWith($s)?!1:i?(e===tr||e===Oi)&&!Array.isArray(i.methods)?(Wi.logger.log("VerificationRequest: validateEvent: fail because methods"),!1):(e===tr||e===Oi||e===gr)&&(typeof i.from_device!="string"||i.from_device.length===0)?(Wi.logger.log("VerificationRequest: validateEvent: fail because from_device"),!1):!0:(Wi.logger.log("VerificationRequest: validateEvent: no content"),!1)}get invalid(){return this.phase===dn}get requested(){return this.phase===Mr}get cancelled(){return this.phase===ao}get ready(){return this.phase===hn}get started(){return this.phase===ts}get done(){return this.phase===co}get methods(){return this.commonMethods}get chosenMethod(){return this._chosenMethod}calculateEventTimeout(e){let t=this.channel.getTimestamp(e)+gM;if(this.requestReceivedAt&&!this.initiatedByMe&&this.phase<=Mr){const r=this.requestReceivedAt+mM;t=Math.min(t,r)}return Math.max(0,t-Date.now())}get timeout(){const e=this.getEventByEither(tr);return e?this.calculateEventTimeout(e):0}get requestEvent(){return this.getEventByEither(tr)}get phase(){return this._phase}get verifier(){return this._verifier}get canAccept(){return this.phase<hn&&!this._accepting&&!this._declining}get accepting(){return this._accepting}get declining(){return this._declining}get pending(){return!this.observeOnly&&this._phase!==co&&this._phase!==ao}get qrCodeData(){return this._qrCodeData}otherPartySupportsMethod(e,t=!1){if(!t&&!this.ready&&!this.started)return!1;const r=this.eventsByThem.get(tr)||this.eventsByThem.get(Oi);if(!r){if(this.started&&this.initiatedByMe){const o=this.eventsByUs.get(gr),a=o&&o.getContent(),l=a&&a.method;return e==l}return!1}const i=r.getContent();if(!i)return!1;const{methods:s}=i;return Array.isArray(s)?s.includes(e):!1}get initiatedByMe(){const e=this.eventsByUs.size+this.eventsByThem.size===0;if(this._phase===dn&&e)return!0;const t=this.eventsByUs.has(tr),r=this.eventsByThem.has(tr);if(t&&!r)return!0;if(!t&&r)return!1;const i=this.eventsByUs.has(gr),s=this.eventsByThem.has(gr);return!!(i&&!s)}get requestingUserId(){return this.initiatedByMe?this.client.getUserId():this.otherUserId}get receivingUserId(){return this.initiatedByMe?this.otherUserId:this.client.getUserId()}get otherUserId(){return this.channel.userId}get isSelfVerification(){return this.client.getUserId()===this.otherUserId}get cancellingUserId(){const e=this.eventsByUs.get(es),t=this.eventsByThem.get(es);if(e&&(!t||e.getId()<t.getId()))return e.getSender();if(t)return t.getSender()}get cancellationCode(){const e=this.getEventByEither(es);return e?e.getContent().code:null}get observeOnly(){return this._observeOnly}get targetDevice(){const r=(this.eventsByThem.get(tr)||this.eventsByThem.get(Oi)||this.eventsByThem.get(gr)).getContent().from_device;return{userId:this.otherUserId,deviceId:r}}beginKeyVerification(e,t=null){if(!this.observeOnly&&!this._verifier&&(this.phase===Mr||this.phase===hn||this.phase===dn&&this.channel.canCreateRequest(gr))){if(this.commonMethods.length&&!this.commonMethods.includes(e)||(this._verifier=this.createVerifier(e,null,t),!this._verifier))throw(0,Hi.newUnknownMethodError)();this._chosenMethod=e}return this._verifier}async sendRequest(){if(!this.observeOnly&&this._phase===dn){const e=[...this.verificationMethods.keys()];await this.channel.send(tr,{methods:e})}}async cancel({reason:e="User declined",code:t="m.user"}={}){if(!this.observeOnly&&this._phase!==ao){if(this._declining=!0,this.emit(Hn.Change),this._verifier)return this._verifier.cancel((0,Hi.errorFactory)(t,e)());this._cancellingUserId=this.client.getUserId(),await this.channel.send(es,{code:t,reason:e})}}async accept(){if(!this.observeOnly&&this.phase===Mr&&!this.initiatedByMe){const e=[...this.verificationMethods.keys()];this._accepting=!0,this.emit(Hn.Change),await this.channel.send(Oi,{methods:e})}}waitFor(e){return new Promise((t,r)=>{const i=()=>{let s=!1;return e(this)?(t(this),s=!0):this.cancelled&&(r(new Error("cancelled")),s=!0),s&&this.off(Hn.Change,i),s};i()||this.on(Hn.Change,i)})}setPhase(e,t=!0){this._phase=e,t&&this.emit(Hn.Change)}getEventByEither(e){return this.eventsByThem.get(e)||this.eventsByUs.get(e)}getEventBy(e,t=!1){return t?this.eventsByThem.get(e):this.eventsByUs.get(e)}calculatePhaseTransitions(){const e=[{phase:dn}],t=()=>e[e.length-1].phase,r=this.eventsByThem.has(tr),i=this.getEventBy(tr,r);i&&e.push({phase:Mr,event:i});const s=i&&this.getEventBy(Oi,!r);s&&t()===Mr&&e.push({phase:hn,event:s});let o;if(s||!i){const u=this.eventsByThem.get(gr),c=this.eventsByUs.get(gr);u&&c?o=u.getSender()<c.getSender()?u:c:o=u||c}else o=this.getEventBy(gr,!r);if(o){const u=t()===Mr&&i.getSender()!==o.getSender(),c=t()===dn&&this.channel.canCreateRequest(gr);(u||t()===hn||c)&&e.push({phase:ts,event:o})}const a=this.eventsByUs.get(I_);(this.verifierHasFinished||a&&t()===ts)&&e.push({phase:co});const l=this.getEventByEither(es);return(this._cancelled||l)&&t()!==co&&e.push({phase:ao,event:l}),e}transitionToPhase(e){const{phase:t,event:r}=e;if((t===Mr||t===hn)&&!this.wasSentByOwnDevice(r)){const i=r.getContent();this.commonMethods=i.methods.filter(s=>this.verificationMethods.has(s))}if(this.observeOnly||(t===Mr||t===ts||t===hn)&&this.channel.receiveStartFromOtherDevices&&this.wasSentByOwnUser(r)&&!this.wasSentByOwnDevice(r)&&(this._observeOnly=!0),t===ts){const{method:i}=r.getContent();!this._verifier&&!this.observeOnly&&(this._verifier=this.createVerifier(i,r),this._verifier?this._chosenMethod=i:this.cancel({code:"m.unknown_method",reason:`Unknown method: ${i}`}))}}applyPhaseTransitions(){const e=this.calculatePhaseTransitions(),t=e.findIndex(i=>i.phase===this.phase),r=e.slice(t+1);for(const i of r)this.transitionToPhase(i);return r}isWinningStartRace(e){if(e.getType()!==gr)return!1;const t=this._verifier.startEvent;let r;if(this.isSelfVerification)if(t){const s=t.getContent();r=s&&s.from_device}else r=this.client.getDeviceId();else t?r=t.getSender():r=this.client.getUserId();let i;if(this.isSelfVerification){const s=e.getContent();i=s&&s.from_device}else i=e.getSender();return i<r}hasEventId(e){for(const t of this.eventsByUs.values())if(t.getId()===e)return!0;for(const t of this.eventsByThem.values())if(t.getId()===e)return!0;return!1}async handleEvent(e,t,r,i,s){if(this.done||this.cancelled)return;const o=this._observeOnly;if(this.adjustObserveOnly(t,r),!this.observeOnly&&!i&&await this.cancelOnError(e,t)||(s?this.eventsByUs.has(e):this.eventsByThem.has(e)))return;const l=this.phase;this.addEvent(e,t,s);const u=this.applyPhaseTransitions();try{if(this._verifier&&!this.observeOnly){const g=this.isWinningStartRace(t);if(this._verifier.canSwitchStartEvent(t)&&g)this._verifier.switchStartEvent(t);else if(!i){var c;(e===es||(c=this._verifier.events)!==null&&c!==void 0&&c.includes(e))&&this._verifier.handleEvent(t)}}if(u.length){r&&u.some(f=>f.phase===hn)&&this.otherPartySupportsMethod(am.SCAN_QR_CODE_METHOD,!0)&&(this._qrCodeData=await am.QRCodeData.create(this,this.client));const g=u[u.length-1],{phase:m}=g;this.setupTimeout(m),this.setPhase(m)}else this._observeOnly!==o&&this.emit(Hn.Change)}finally{Wi.logger.log(`Verification request ${this.channel.transactionId}: ${e} event with id:${t.getId()}, content:${JSON.stringify(t.getContent())} deviceId:${this.channel.deviceId}, sender:${t.getSender()}, isSentByUs:${s}, isLiveEvent:${r}, isRemoteEcho:${i}, phase:${l}=>${this.phase}, observeOnly:${o}=>${this._observeOnly}`)}}setupTimeout(e){!this.timeoutTimer&&!this.observeOnly&&e===Mr&&(this.timeoutTimer=setTimeout(this.cancelOnTimeout,this.timeout)),this.timeoutTimer&&(e===ts||e===hn||e===co||e===ao)&&(clearTimeout(this.timeoutTimer),this.timeoutTimer=null)}async cancelOnError(e,t){if(e===gr){const s=t.getContent().method;if(!this.verificationMethods.has(s))return await this.cancel((0,Hi.errorFromEvent)((0,Hi.newUnknownMethodError)())),!0}const r=e===tr&&this.phase!==dn,i=e===Oi&&this.phase!==Mr;if(this.phase!==dn&&(r||i)){Wi.logger.warn(`Cancelling, unexpected ${e} verification event from ${t.getSender()}`);const s=`Unexpected ${e} event in phase ${this.phase}`;return await this.cancel((0,Hi.errorFromEvent)((0,Hi.newUnexpectedMessageError)({reason:s}))),!0}return!1}adjustObserveOnly(e,t=!1){t||(this._observeOnly=!0),this.calculateEventTimeout(e)<yM&&(this._observeOnly=!0)}addEvent(e,t,r=!1){if(r?this.eventsByUs.set(e,t):this.eventsByThem.set(e,t),e===tr){for(const[i,s]of this.eventsByThem.entries())s.getSender()!==this.otherUserId&&this.eventsByThem.delete(i);this.requestReceivedAt=Date.now()}}createVerifier(e,t=null,r=null){r||(r=this.targetDevice);const{userId:i,deviceId:s}=r,o=this.verificationMethods.get(e);if(!o){Wi.logger.warn("could not find verifier constructor for method",e);return}return new o(this.channel,this.client,i,s,t,this)}wasSentByOwnUser(e){return e.getSender()===this.client.getUserId()}wasSentByOwnDevice(e){if(!this.wasSentByOwnUser(e))return!1;const t=e.getContent();return!(!t||t.from_device!==this.client.getDeviceId())}onVerifierCancelled(){this._cancelled=!0;const e=this.applyPhaseTransitions();e.length&&this.setPhase(e[e.length-1].phase)}onVerifierFinished(){this.channel.send("m.key.verification.done",{}),this.verifierHasFinished=!0;const e=this.applyPhaseTransitions();e.length&&this.setPhase(e[e.length-1].phase)}getEventFromOtherParty(e){return this.eventsByThem.get(e)}}fe.VerificationRequest=vM;var ko={},_M=G.exports;Object.defineProperty(ko,"__esModule",{value:!0});ko.InRoomRequests=ko.InRoomChannel=void 0;var T_=_M(Y.exports),$t=fe,hd=se,EM=ie;const cm=EM.EventType.RoomMessage,lm="m.reference",um="m.relates_to";class or{constructor(e,t,r=null){this.client=e,this.roomId=t,this.userId=r,(0,T_.default)(this,"requestEventId",null)}get receiveStartFromOtherDevices(){return!0}get transactionId(){return this.requestEventId}static getOtherPartyUserId(e,t){if(or.getEventType(e)!==$t.REQUEST_TYPE)return;const i=t.getUserId(),s=e.getSender(),a=e.getContent().to;if(s===i)return a;if(a===i)return s}getTimestamp(e){return e.getTs()}static canCreateRequest(e){return e===$t.REQUEST_TYPE}canCreateRequest(e){return or.canCreateRequest(e)}static getTransactionId(e){if(or.getEventType(e)===$t.REQUEST_TYPE)return e.getId();{const t=e.getRelation();if(t&&t.rel_type===lm)return t.event_id}}static validateEvent(e,t){const r=or.getTransactionId(e);if(typeof r!="string"||r.length===0)return!1;const i=or.getEventType(e),s=e.getContent();if(i===$t.REQUEST_TYPE){if(!s||typeof s.to!="string"||!s.to.length)return hd.logger.log("InRoomChannel: validateEvent: no valid to "+(s&&s.to)),!1;if(!or.getOtherPartyUserId(e,t))return hd.logger.log(`InRoomChannel: validateEvent: not directed to or sent by me: ${e.getSender()}, ${s&&s.to}`),!1}return $t.VerificationRequest.validateEvent(i,e,t)}static getEventType(e){const t=e.getType();if(t===cm){const r=e.getContent();if(r){const{msgtype:i}=r;if(i===$t.REQUEST_TYPE)return $t.REQUEST_TYPE}}return t&&t!==$t.REQUEST_TYPE?t:""}async handleEvent(e,t,r=!1){if(t.hasEventId(e.getId()))return;const i=or.getEventType(e);if(e.getRoomId()!==this.roomId)return;if(this.userId===null){const u=or.getOtherPartyUserId(e,this.client);u&&(this.userId=u)}const s=this.client.getUserId(),o=e.getSender();if(this.userId!==null&&o!==s&&o!==this.userId){hd.logger.log(`InRoomChannel: ignoring verification event from non-participating sender ${o}`);return}this.requestEventId===null&&(this.requestEventId=or.getTransactionId(e));const a=!!e.getUnsigned().transaction_id,l=e.getSender()===this.client.getUserId();return await t.handleEvent(i,e,r,a,l)}completedContentFromEvent(e){const t=Object.assign({},e.getContent());return t[um]=e.getRelation(),t}completeContent(e,t){return t=Object.assign({},t),(e===$t.REQUEST_TYPE||e===$t.READY_TYPE||e===$t.START_TYPE)&&(t.from_device=this.client.getDeviceId()),e===$t.REQUEST_TYPE?t={body:this.client.getUserId()+" is requesting to verify your key, but your client does not support in-chat key verification. You will need to use legacy key verification to verify keys.",msgtype:$t.REQUEST_TYPE,to:this.userId,from_device:t.from_device,methods:t.methods}:t[um]={rel_type:lm,event_id:this.transactionId},t}send(e,t){const r=this.completeContent(e,t);return this.sendCompleted(e,r)}async sendCompleted(e,t){let r=e;e===$t.REQUEST_TYPE&&(r=cm);const i=await this.client.sendEvent(this.roomId,r,t);e===$t.REQUEST_TYPE&&(this.requestEventId=i.event_id)}}ko.InRoomChannel=or;class SM{constructor(){(0,T_.default)(this,"requestsByRoomId",new Map)}getRequest(e){const t=e.getRoomId(),r=or.getTransactionId(e);return this.getRequestByTxnId(t,r)}getRequestByChannel(e){return this.getRequestByTxnId(e.roomId,e.transactionId)}getRequestByTxnId(e,t){const r=this.requestsByRoomId.get(e);if(r)return r.get(t)}setRequest(e,t){this.doSetRequest(e.getRoomId(),or.getTransactionId(e),t)}setRequestByChannel(e,t){this.doSetRequest(e.roomId,e.transactionId,t)}doSetRequest(e,t,r){let i=this.requestsByRoomId.get(e);i||(i=new Map,this.requestsByRoomId.set(e,i)),i.set(t,r)}removeRequest(e){const t=e.getRoomId(),r=this.requestsByRoomId.get(t);r&&(r.delete(or.getTransactionId(e)),r.size===0&&this.requestsByRoomId.delete(t))}findRequestInProgress(e){const t=this.requestsByRoomId.get(e);if(t){for(const r of t.values())if(r.pending)return r}}}ko.InRoomRequests=SM;var Co={},bM=G.exports;Object.defineProperty(Co,"__esModule",{value:!0});Co.ToDeviceRequests=Co.ToDeviceChannel=void 0;var O_=bM(Y.exports),wM=ai,ca=se,Le=fe,dm=Ke,RM=jt;class us{constructor(e,t,r,i=null,s=null){this.client=e,this.userId=t,this.devices=r,this.transactionId=i,this.deviceId=s,(0,O_.default)(this,"request",void 0)}isToDevices(e){if(e.length===this.devices.length){for(const t of e)if(!this.devices.includes(t))return!1;return!0}else return!1}static getEventType(e){return e.getType()}static getTransactionId(e){const t=e.getContent();return t&&t.transaction_id}static canCreateRequest(e){return e===Le.REQUEST_TYPE||e===Le.START_TYPE}canCreateRequest(e){return us.canCreateRequest(e)}static validateEvent(e,t){if(e.isCancelled())return ca.logger.warn("Ignoring flagged verification request from "+e.getSender()),!1;const r=e.getContent();if(!r)return ca.logger.warn("ToDeviceChannel.validateEvent: invalid: no content"),!1;if(!r.transaction_id)return ca.logger.warn("ToDeviceChannel.validateEvent: invalid: no transaction_id"),!1;const i=e.getType();if(i===Le.REQUEST_TYPE){if(!Number.isFinite(r.timestamp))return ca.logger.warn("ToDeviceChannel.validateEvent: invalid: no timestamp"),!1;if(e.getSender()===t.getUserId()&&r.from_device==t.getDeviceId())return ca.logger.warn("ToDeviceChannel.validateEvent: invalid: from own device"),!1}return Le.VerificationRequest.validateEvent(i,e,t)}getTimestamp(e){const t=e.getContent();return t&&t.timestamp}async handleEvent(e,t,r=!1){const i=e.getType(),s=e.getContent();if(i===Le.REQUEST_TYPE||i===Le.READY_TYPE||i===Le.START_TYPE){this.transactionId||(this.transactionId=s.transaction_id);const u=s.from_device;if(!this.deviceId&&this.devices.includes(u)&&(this.deviceId=u),!this.deviceId||this.deviceId!==u){const c=this.completeContent(Le.CANCEL_TYPE,(0,dm.errorFromEvent)((0,dm.newUnexpectedMessageError)()));return this.sendToDevices(Le.CANCEL_TYPE,c,[u])}}const o=t.phase===Le.PHASE_STARTED||t.phase===Le.PHASE_READY;await t.handleEvent(e.getType(),e,r,!1,!1);const a=t.phase===Le.PHASE_STARTED||t.phase===Le.PHASE_READY;if((i===Le.START_TYPE||i===Le.READY_TYPE)&&!o&&a&&this.deviceId){const u=this.devices.filter(c=>c!==this.deviceId&&c!==this.client.getDeviceId());if(u.length){const c=this.completeContent(Le.CANCEL_TYPE,{code:"m.accepted",reason:"Verification request accepted by another device"});await this.sendToDevices(Le.CANCEL_TYPE,c,u)}}}completedContentFromEvent(e){return e.getContent()}completeContent(e,t){return t=Object.assign({},t),this.transactionId&&(t.transaction_id=this.transactionId),(e===Le.REQUEST_TYPE||e===Le.READY_TYPE||e===Le.START_TYPE)&&(t.from_device=this.client.getDeviceId()),e===Le.REQUEST_TYPE&&(t.timestamp=Date.now()),t}send(e,t={}){(e===Le.REQUEST_TYPE||e===Le.START_TYPE)&&!this.transactionId&&(this.transactionId=us.makeTransactionId());const r=this.completeContent(e,t);return this.sendCompleted(e,r)}async sendCompleted(e,t){let r;e===Le.REQUEST_TYPE||e===Le.CANCEL_TYPE&&!this.deviceId?r=await this.sendToDevices(e,t,this.devices):r=await this.sendToDevices(e,t,[this.deviceId]);const i=new RM.MatrixEvent({sender:this.client.getUserId(),content:t,type:e});return await this.request.handleEvent(e,i,!0,!0,!0),r}async sendToDevices(e,t,r){if(r.length){const i={};for(const s of r)i[s]=t;await this.client.sendToDevice(e,{[this.userId]:i})}}static makeTransactionId(){return(0,wM.randomString)(32)}}Co.ToDeviceChannel=us;class IM{constructor(){(0,O_.default)(this,"requestsByUserId",new Map)}getRequest(e){return this.getRequestBySenderAndTxnId(e.getSender(),us.getTransactionId(e))}getRequestByChannel(e){return this.getRequestBySenderAndTxnId(e.userId,e.transactionId)}getRequestBySenderAndTxnId(e,t){const r=this.requestsByUserId.get(e);if(r)return r.get(t)}setRequest(e,t){this.setRequestBySenderAndTxnId(e.getSender(),us.getTransactionId(e),t)}setRequestByChannel(e,t){this.setRequestBySenderAndTxnId(e.userId,e.transactionId,t)}setRequestBySenderAndTxnId(e,t,r){let i=this.requestsByUserId.get(e);i||(i=new Map,this.requestsByUserId.set(e,i)),i.set(t,r)}removeRequest(e){const t=e.getSender(),r=this.requestsByUserId.get(t);r&&(r.delete(us.getTransactionId(e)),r.size===0&&this.requestsByUserId.delete(t))}findRequestInProgress(e,t){const r=this.requestsByUserId.get(e);if(r){for(const i of r.values())if(i.pending&&i.channel.isToDevices(t))return i}}getRequestsInProgress(e){const t=this.requestsByUserId.get(e);return t?Array.from(t.values()).filter(r=>r.pending):[]}}Co.ToDeviceRequests=IM;var cu={},TM=G.exports;Object.defineProperty(cu,"__esModule",{value:!0});cu.IllegalMethod=void 0;var OM=TM(Y.exports),kM=Xr;class Mf extends kM.VerificationBase{constructor(...e){super(...e);(0,OM.default)(this,"doVerification",async()=>{throw new Error("Verification is not possible with this method")})}static factory(e,t,r,i,s,o){return new Mf(e,t,r,i,s,o)}static get NAME(){return"org.matrix.illegal_method"}}cu.IllegalMethod=Mf;var Rs={},k_=G.exports;Object.defineProperty(Rs,"__esModule",{value:!0});Rs.DehydrationManager=Rs.DEHYDRATION_ALGORITHM=void 0;var la=k_(Y.exports),fd=k_(tu),hm=xe,pd=Br,fm=li,Nn=se,pm=me;const al="org.matrix.msc2697.v1.olm.libolm_pickle";Rs.DEHYDRATION_ALGORITHM=al;const gm=7*24*60*60*1e3;class CM{constructor(e){this.crypto=e,(0,la.default)(this,"inProgress",!1),(0,la.default)(this,"timeoutId",void 0),(0,la.default)(this,"key",void 0),(0,la.default)(this,"keyInfo",void 0),(0,la.default)(this,"deviceDisplayName",void 0),this.getDehydrationKeyFromCache()}async getDehydrationKeyFromCache(){return await this.crypto.cryptoStore.doTxn("readonly",[pd.IndexedDBCryptoStore.STORE_ACCOUNT],e=>{this.crypto.cryptoStore.getSecretStorePrivateKey(e,async t=>{if(t){const{key:r,keyInfo:i,deviceDisplayName:s,time:o}=t,a=Buffer.from(this.crypto.olmDevice.pickleKey),l=await(0,fm.decryptAES)(r,a,al);this.key=(0,hm.decodeBase64)(l),this.keyInfo=i,this.deviceDisplayName=s;const u=Date.now(),c=Math.max(1,o+gm-u);this.timeoutId=V.setTimeout(this.dehydrateDevice.bind(this),c)}},"dehydration")})}async setKeyAndQueueDehydration(e,t={},r=void 0){await this.setKey(e,t,r)||this.dehydrateDevice()}async setKey(e,t={},r=void 0){if(!e){this.timeoutId&&(V.clearTimeout(this.timeoutId),this.timeoutId=void 0),await this.crypto.cryptoStore.doTxn("readwrite",[pd.IndexedDBCryptoStore.STORE_ACCOUNT],s=>{this.crypto.cryptoStore.storeSecretStorePrivateKey(s,"dehydration",null)}),this.key=void 0,this.keyInfo=void 0;return}let i=this.key&&e.length==this.key.length;for(let s=0;i&&s<e.length;s++)e[s]!=this.key[s]&&(i=!1);return i||(this.key=e,this.keyInfo=t,this.deviceDisplayName=r),i}async dehydrateDevice(){if(this.inProgress){Nn.logger.log("Dehydration already in progress -- not starting new dehydration");return}this.inProgress=!0,this.timeoutId&&(V.clearTimeout(this.timeoutId),this.timeoutId=void 0);try{const e=Buffer.from(this.crypto.olmDevice.pickleKey),t=await(0,fm.encryptAES)((0,hm.encodeBase64)(this.key),e,al);await this.crypto.cryptoStore.doTxn("readwrite",[pd.IndexedDBCryptoStore.STORE_ACCOUNT],w=>{this.crypto.cryptoStore.storeSecretStorePrivateKey(w,"dehydration",{keyInfo:this.keyInfo,key:t,deviceDisplayName:this.deviceDisplayName,time:Date.now()})}),Nn.logger.log("Attempting to dehydrate device"),Nn.logger.log("Creating account");const r=new V.Olm.Account;r.create();const i=JSON.parse(r.identity_keys()),s=r.max_number_of_one_time_keys();r.generate_one_time_keys(s/2),r.generate_fallback_key();const o=JSON.parse(r.one_time_keys()),a=JSON.parse(r.fallback_key());r.mark_keys_as_published();const l=r.pickle(new Uint8Array(this.key)),u={algorithm:al,account:l};this.keyInfo.passphrase&&(u.passphrase=this.keyInfo.passphrase),Nn.logger.log("Uploading account to server");const g=(await this.crypto.baseApis.http.authedRequest(void 0,pm.Method.Put,"/dehydrated_device",void 0,{device_data:u,initial_device_display_name:this.deviceDisplayName},{prefix:"/_matrix/client/unstable/org.matrix.msc2697.v2"})).device_id;Nn.logger.log("Preparing device keys",g);const m={algorithms:this.crypto.supportedAlgorithms,device_id:g,user_id:this.crypto.userId,keys:{[`ed25519:${g}`]:i.ed25519,[`curve25519:${g}`]:i.curve25519}},f=r.sign(fd.default.stringify(m));m.signatures={[this.crypto.userId]:{[`ed25519:${g}`]:f}},this.crypto.crossSigningInfo.getId("self_signing")&&await this.crypto.crossSigningInfo.signObject(m,"self_signing"),Nn.logger.log("Preparing one-time keys");const E={};for(const[w,k]of Object.entries(o.curve25519)){const C={key:k},S=r.sign(fd.default.stringify(C));C.signatures={[this.crypto.userId]:{[`ed25519:${g}`]:S}},E[`signed_curve25519:${w}`]=C}Nn.logger.log("Preparing fallback keys");const I={};for(const[w,k]of Object.entries(a.curve25519)){const C={key:k,fallback:!0},S=r.sign(fd.default.stringify(C));C.signatures={[this.crypto.userId]:{[`ed25519:${g}`]:S}},I[`signed_curve25519:${w}`]=C}return Nn.logger.log("Uploading keys to server"),await this.crypto.baseApis.http.authedRequest(void 0,pm.Method.Post,"/keys/upload/"+encodeURI(g),void 0,{device_keys:m,one_time_keys:E,"org.matrix.msc2732.fallback_keys":I}),Nn.logger.log("Done dehydrating"),this.timeoutId=V.setTimeout(this.dehydrateDevice.bind(this),gm),g}finally{this.inProgress=!1}}stop(){this.timeoutId&&(V.clearTimeout(this.timeoutId),this.timeoutId=void 0)}}Rs.DehydrationManager=CM;var yr={},PM=G.exports;Object.defineProperty(yr,"__esModule",{value:!0});yr.algorithmsByName=yr.DefaultAlgorithm=yr.Curve25519=yr.BackupManager=yr.Aes256=void 0;var uo=PM(Y.exports),MM=st,mt=se,ua=xe,C_=Us,Bh=W,mm=Br,AM=Vo,da=li,DM=_r,zs=Ft;const xM=200;class Ua{constructor(e,t){this.baseApis=e,this.getKey=t,(0,uo.default)(this,"algorithm",void 0),(0,uo.default)(this,"backupInfo",void 0),(0,uo.default)(this,"checkedForBackup",void 0),(0,uo.default)(this,"sendingBackups",void 0),this.checkedForBackup=!1,this.sendingBackups=!1}get version(){return this.backupInfo&&this.backupInfo.version}static checkBackupVersion(e){const t=cl[e.algorithm];if(!t)throw new Error("Unknown backup algorithm: "+e.algorithm);if(typeof e.auth_data!="object")throw new Error("Invalid backup data returned");return t.checkBackupVersion(e)}static async makeAlgorithm(e,t){const r=cl[e.algorithm];if(!r)throw new Error("Unknown backup algorithm");return await r.init(e.auth_data,t)}async enableKeyBackup(e){this.backupInfo=e,this.algorithm&&this.algorithm.free(),this.algorithm=await Ua.makeAlgorithm(e,this.getKey),this.baseApis.emit(zs.CryptoEvent.KeyBackupStatus,!0),this.scheduleKeyBackupSend()}disableKeyBackup(){this.algorithm&&this.algorithm.free(),this.algorithm=void 0,this.backupInfo=void 0,this.baseApis.emit(zs.CryptoEvent.KeyBackupStatus,!1)}getKeyBackupEnabled(){return this.checkedForBackup?Boolean(this.algorithm):null}async prepareKeyBackupVersion(e,t){const r=t?cl[t]:P_;if(!r)throw new Error("Unknown backup algorithm");const[i,s]=await r.prepare(e),o=(0,AM.encodeRecoveryKey)(i);return{algorithm:r.algorithmName,auth_data:s,recovery_key:o,privateKey:i}}async createKeyBackupVersion(e){this.algorithm=await Ua.makeAlgorithm(e,this.getKey)}async checkAndStart(){if(mt.logger.log("Checking key backup status..."),this.baseApis.isGuest())return mt.logger.log("Skipping key backup check since user is guest"),this.checkedForBackup=!0,null;let e;try{e=await this.baseApis.getKeyBackupVersion()}catch(r){return mt.logger.log("Error checking for active key backup",r),r.httpStatus===404&&(this.checkedForBackup=!0),null}this.checkedForBackup=!0;const t=await this.isKeyBackupTrusted(e);return t.usable&&!this.backupInfo?(mt.logger.log("Found usable key backup v"+e.version+": enabling key backups"),await this.enableKeyBackup(e)):!t.usable&&this.backupInfo?(mt.logger.log("No usable key backup: disabling key backup"),this.disableKeyBackup()):!t.usable&&!this.backupInfo?mt.logger.log("No usable key backup: not enabling key backup"):t.usable&&this.backupInfo&&(e.version!==this.backupInfo.version?(mt.logger.log("On backup version "+this.backupInfo.version+" but found version "+e.version+": switching."),this.disableKeyBackup(),await this.enableKeyBackup(e),await this.scheduleAllGroupSessionsForBackup()):mt.logger.log("Backup version "+e.version+" still current")),{backupInfo:e,trustInfo:t}}async checkKeyBackup(){return this.checkedForBackup=!1,this.checkAndStart()}async isKeyBackupTrusted(e){const t={usable:!1,trusted_locally:!1,sigs:[]};if(!e||!e.algorithm||!e.auth_data||!e.auth_data.signatures)return mt.logger.info("Key backup is absent or missing required data"),t;const r=await this.baseApis.crypto.getSessionBackupPrivateKey();if(r){let s;try{s=await Ua.makeAlgorithm(e,async()=>r),await s.keyMatches(r)&&(mt.logger.info("Backup is trusted locally"),t.trusted_locally=!0)}catch{}finally{s&&s.free()}}const i=e.auth_data.signatures[this.baseApis.getUserId()]||{};for(const s of Object.keys(i)){const o=s.split(":");if(o[0]!=="ed25519"){mt.logger.log("Ignoring unknown signature type: "+o[0]);continue}const a={deviceId:o[1]},l=this.baseApis.crypto.crossSigningInfo.getId();if(l===a.deviceId){a.crossSigningId=!0;try{await(0,ua.verifySignature)(this.baseApis.crypto.olmDevice,e.auth_data,this.baseApis.getUserId(),a.deviceId,l),a.valid=!0}catch(c){mt.logger.warn("Bad signature from cross signing key "+l,c),a.valid=!1}t.sigs.push(a);continue}const u=this.baseApis.crypto.deviceList.getStoredDevice(this.baseApis.getUserId(),a.deviceId);if(u){a.device=u,a.deviceTrust=await this.baseApis.checkDeviceTrust(this.baseApis.getUserId(),a.deviceId);try{await(0,ua.verifySignature)(this.baseApis.crypto.olmDevice,e.auth_data,this.baseApis.getUserId(),u.deviceId,u.getFingerprint()),a.valid=!0}catch(c){mt.logger.info("Bad signature from key ID "+s+" userID "+this.baseApis.getUserId()+" device ID "+u.deviceId+" fingerprint: "+u.getFingerprint(),e.auth_data,c),a.valid=!1}}else a.valid=null,mt.logger.info("Ignoring signature from unknown key "+s);t.sigs.push(a)}return t.usable=t.sigs.some(s=>s.valid&&(s.device&&s.deviceTrust.isVerified()||s.crossSigningId)),t.usable=t.usable||t.trusted_locally,t}async scheduleKeyBackupSend(e=1e4){if(!this.sendingBackups){this.sendingBackups=!0;try{const t=Math.random()*e;await(0,Bh.sleep)(t,void 0);let r=0;for(;;){if(!this.algorithm)return;try{if(await this.backupPendingKeys(xM)===0)return;r=0}catch(i){if(r++,mt.logger.log("Key backup request failed",i),i.data&&(i.data.errcode=="M_NOT_FOUND"||i.data.errcode=="M_WRONG_ROOM_KEYS_VERSION"))throw await this.checkKeyBackup(),this.baseApis.crypto.emit(zs.CryptoEvent.KeyBackupFailed,i.data.errcode),i}r&&await(0,Bh.sleep)(1e3*Math.pow(2,Math.min(r-1,4)),void 0)}}finally{this.sendingBackups=!1}}}async backupPendingKeys(e){const t=await this.baseApis.crypto.cryptoStore.getSessionsNeedingBackup(e);if(!t.length)return 0;let r=await this.baseApis.crypto.cryptoStore.countSessionsNeedingBackup();this.baseApis.crypto.emit(zs.CryptoEvent.KeyBackupSessionsRemaining,r);const i={};for(const s of t){const o=s.sessionData.room_id;i[o]===void 0&&(i[o]={sessions:{}});const a=await this.baseApis.crypto.olmDevice.exportInboundGroupSession(s.senderKey,s.sessionId,s.sessionData);a.algorithm=ua.MEGOLM_ALGORITHM;const l=(a.forwarding_curve25519_key_chain||[]).length,u=this.baseApis.crypto.deviceList.getUserByIdentityKey(ua.MEGOLM_ALGORITHM,s.senderKey),c=this.baseApis.crypto.deviceList.getDeviceByIdentityKey(ua.MEGOLM_ALGORITHM,s.senderKey),g=this.baseApis.crypto.checkDeviceInfoTrust(u,c).isVerified();i[o].sessions[s.sessionId]={first_message_index:a.first_known_index,forwarded_count:l,is_verified:g,session_data:await this.algorithm.encryptSession(a)}}return await this.baseApis.sendKeyBackup(void 0,void 0,this.backupInfo.version,{rooms:i}),await this.baseApis.crypto.cryptoStore.unmarkSessionsNeedingBackup(t),r=await this.baseApis.crypto.cryptoStore.countSessionsNeedingBackup(),this.baseApis.crypto.emit(zs.CryptoEvent.KeyBackupSessionsRemaining,r),t.length}async backupGroupSession(e,t){await this.baseApis.crypto.cryptoStore.markSessionsNeedingBackup([{senderKey:e,sessionId:t}]),this.backupInfo&&this.scheduleKeyBackupSend()}async scheduleAllGroupSessionsForBackup(){await this.flagAllGroupSessionsForBackup(),this.scheduleKeyBackupSend(0)}async flagAllGroupSessionsForBackup(){await this.baseApis.crypto.cryptoStore.doTxn("readwrite",[mm.IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS,mm.IndexedDBCryptoStore.STORE_BACKUP],t=>{this.baseApis.crypto.cryptoStore.getAllEndToEndInboundGroupSessions(t,r=>{r!==null&&this.baseApis.crypto.cryptoStore.markSessionsNeedingBackup([r],t)})});const e=await this.baseApis.crypto.cryptoStore.countSessionsNeedingBackup();return this.baseApis.emit(zs.CryptoEvent.KeyBackupSessionsRemaining,e),e}countSessionsNeedingBackup(){return this.baseApis.crypto.cryptoStore.countSessionsNeedingBackup()}}yr.BackupManager=Ua;class Is{constructor(e,t,r){this.authData=e,this.publicKey=t,this.getKey=r}static async init(e,t){if(!e||!("public_key"in e))throw new Error("auth_data missing required information");const r=new V.Olm.PkEncryption;return r.set_recipient_key(e.public_key),new Is(e,r,t)}static async prepare(e){const t=new V.Olm.PkDecryption;try{const r={};if(!e)r.public_key=t.generate_key();else if(e instanceof Uint8Array)r.public_key=t.init_with_private_key(e);else{const s=await(0,C_.keyFromPassphrase)(e);r.private_key_salt=s.salt,r.private_key_iterations=s.iterations,r.public_key=t.init_with_private_key(s.key)}return new V.Olm.PkEncryption().set_recipient_key(r.public_key),[t.get_private_key(),r]}finally{t.free()}}static checkBackupVersion(e){if(!("public_key"in e.auth_data))throw new Error("Invalid backup data returned")}get untrusted(){return!0}async encryptSession(e){const t=Object.assign({},e);return delete t.session_id,delete t.room_id,delete t.first_known_index,this.publicKey.encrypt(JSON.stringify(t))}async decryptSessions(e){const t=await this.getKey(),r=new V.Olm.PkDecryption;try{if(r.init_with_private_key(t)!==this.authData.public_key)throw{errcode:MM.MatrixClient.RESTORE_BACKUP_ERROR_BAD_KEY};const s=[];for(const[o,a]of Object.entries(e))try{const l=JSON.parse(r.decrypt(a.session_data.ephemeral,a.session_data.mac,a.session_data.ciphertext));l.session_id=o,s.push(l)}catch(l){mt.logger.log("Failed to decrypt megolm session from backup",l,a)}return s}finally{r.free()}}async keyMatches(e){const t=new V.Olm.PkDecryption;let r;try{r=t.init_with_private_key(e)}finally{t.free()}return r===this.authData.public_key}free(){this.publicKey.free()}}yr.Curve25519=Is;(0,uo.default)(Is,"algorithmName","m.megolm_backup.v1.curve25519-aes-sha2");function UM(n){var e;const t=(0,Bh.getCrypto)();if(t)return t.randomBytes(n);if((e=window)!==null&&e!==void 0&&e.crypto){const r=new Uint8Array(n);return window.crypto.getRandomValues(r),r}throw new Error("No usable crypto implementation")}const $M=new DM.UnstableValue(null,"org.matrix.msc3270.v1.aes-hmac-sha2");class Po{constructor(e,t){this.authData=e,this.key=t}static async init(e,t){if(!e)throw new Error("auth_data missing");const r=await t();if(e.mac){const{mac:i}=await(0,da.calculateKeyCheck)(r,e.iv);if(e.mac.replace(/=+$/g,"")!==i.replace(/=+/g,""))throw new Error("Key does not match")}return new Po(e,r)}static async prepare(e){let t;const r={};if(!e)t=UM(32);else if(e instanceof Uint8Array)t=new Uint8Array(e);else{const o=await(0,C_.keyFromPassphrase)(e);r.private_key_salt=o.salt,r.private_key_iterations=o.iterations,t=o.key}const{iv:i,mac:s}=await(0,da.calculateKeyCheck)(t);return r.iv=i,r.mac=s,[t,r]}static checkBackupVersion(e){if(!("iv"in e.auth_data&&"mac"in e.auth_data))throw new Error("Invalid backup data returned")}get untrusted(){return!1}async encryptSession(e){const t=Object.assign({},e);return delete t.session_id,delete t.room_id,delete t.first_known_index,await(0,da.encryptAES)(JSON.stringify(t),this.key,e.session_id)}async decryptSessions(e){const t=[];for(const[r,i]of Object.entries(e))try{const s=JSON.parse(await(0,da.decryptAES)(i.session_data,this.key,r));s.session_id=r,t.push(s)}catch(s){mt.logger.log("Failed to decrypt megolm session from backup",s,i)}return t}async keyMatches(e){if(this.authData.mac){const{mac:t}=await(0,da.calculateKeyCheck)(e,this.authData.iv);return this.authData.mac.replace(/=+$/g,"")===t.replace(/=+/g,"")}else return!0}free(){this.key.fill(0)}}yr.Aes256=Po;(0,uo.default)(Po,"algorithmName",$M.name);const cl={[Is.algorithmName]:Is,[Po.algorithmName]:Po};yr.algorithmsByName=cl;const P_=Is;yr.DefaultAlgorithm=P_;var M_=G.exports;Object.defineProperty(Ft,"__esModule",{value:!0});Ft.IncomingRoomKeyRequest=Ft.CryptoEvent=Ft.Crypto=void 0;Ft.fixBackupKey=ul;Ft.isCryptoAvailable=zM;Ft.verificationMethods=void 0;var ae=M_(Y.exports),NM=M_(tu),LM=tn,L=se,ym=Es,Ot=D_(xe),BM=Ss,ll=xs,Lc=D_(Rf),Ln=Pt,vm=To,Js=Oo,KM=bs,ha=Br,ba=cr,Kh=ws,FM=Us,_m=Vo,fa=fe,Bc=ko,Wr=Co,Em=cu,Kc=oi,gd=li,qM=Rs,jM=yr,VM=lr,GM=Zr,Bn=jt,WM=st,HM=je;function A_(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(A_=function(r){return r?t:e})(n)}function D_(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=A_(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}const Kn=ll.DeviceInfo.DeviceVerification,md={[ba.ReciprocateQRCode.NAME]:ba.ReciprocateQRCode,[Kh.SAS.NAME]:Kh.SAS,[ba.SHOW_QR_CODE_METHOD]:Em.IllegalMethod,[ba.SCAN_QR_CODE_METHOD]:Em.IllegalMethod},YM={RECIPROCATE_QR_CODE:ba.ReciprocateQRCode.NAME,SAS:Kh.SAS.NAME};Ft.verificationMethods=YM;function zM(){return Boolean(V.Olm)}const JM=60*60*1e3;let Ze;Ft.CryptoEvent=Ze;(function(n){n.DeviceVerificationChanged="deviceVerificationChanged",n.UserTrustStatusChanged="userTrustStatusChanged",n.UserCrossSigningUpdated="userCrossSigningUpdated",n.RoomKeyRequest="crypto.roomKeyRequest",n.RoomKeyRequestCancellation="crypto.roomKeyRequestCancellation",n.KeyBackupStatus="crypto.keyBackupStatus",n.KeyBackupFailed="crypto.keyBackupFailed",n.KeyBackupSessionsRemaining="crypto.keyBackupSessionsRemaining",n.KeySignatureUploadFailure="crypto.keySignatureUploadFailure",n.VerificationRequest="crypto.verification.request",n.Warning="crypto.warning",n.WillUpdateDevices="crypto.willUpdateDevices",n.DevicesUpdated="crypto.devicesUpdated",n.KeysChanged="crossSigning.keysChanged"})(Ze||(Ft.CryptoEvent=Ze={}));class XM extends HM.TypedEventEmitter{static getOlmVersion(){return ym.OlmDevice.getOlmVersion()}constructor(e,t,r,i,s,o,a,l){super();if(this.baseApis=e,this.sessionStore=t,this.userId=r,this.deviceId=i,this.clientStore=s,this.cryptoStore=o,this.roomList=a,(0,ae.default)(this,"backupManager",void 0),(0,ae.default)(this,"crossSigningInfo",void 0),(0,ae.default)(this,"olmDevice",void 0),(0,ae.default)(this,"deviceList",void 0),(0,ae.default)(this,"dehydrationManager",void 0),(0,ae.default)(this,"secretStorage",void 0),(0,ae.default)(this,"reEmitter",void 0),(0,ae.default)(this,"verificationMethods",void 0),(0,ae.default)(this,"supportedAlgorithms",void 0),(0,ae.default)(this,"outgoingRoomKeyRequestManager",void 0),(0,ae.default)(this,"toDeviceVerificationRequests",void 0),(0,ae.default)(this,"inRoomVerificationRequests",void 0),(0,ae.default)(this,"trustCrossSignedDevices",!0),(0,ae.default)(this,"lastOneTimeKeyCheck",null),(0,ae.default)(this,"oneTimeKeyCheckInProgress",!1),(0,ae.default)(this,"roomEncryptors",{}),(0,ae.default)(this,"roomDecryptors",{}),(0,ae.default)(this,"deviceKeys",{}),(0,ae.default)(this,"globalBlacklistUnverifiedDevices",!1),(0,ae.default)(this,"globalErrorOnUnknownDevices",!0),(0,ae.default)(this,"receivedRoomKeyRequests",[]),(0,ae.default)(this,"receivedRoomKeyRequestCancellations",[]),(0,ae.default)(this,"processingRoomKeyRequests",!1),(0,ae.default)(this,"lazyLoadMembers",!1),(0,ae.default)(this,"roomDeviceTrackingState",{}),(0,ae.default)(this,"lastNewSessionForced",{}),(0,ae.default)(this,"sendKeyRequestsImmediately",!1),(0,ae.default)(this,"oneTimeKeyCount",void 0),(0,ae.default)(this,"needsNewFallback",void 0),(0,ae.default)(this,"fallbackCleanup",void 0),(0,ae.default)(this,"onDeviceListUserCrossSigningUpdated",async g=>{if(g===this.userId){const m=this.deviceList.getStoredCrossSigningForUser(g),f=m?m.getId():null,E=this.crossSigningInfo.getId();E&&f&&!(E!==f)?await this.checkOwnCrossSigningTrust():(this.storeTrustedSelfKeys(null),this.emit(Ze.KeysChanged,{}),this.emit(Ze.UserTrustStatusChanged,this.userId,this.checkUserTrust(g)))}else{await this.checkDeviceVerifications(g);const m=this.deviceList.getStoredCrossSigningForUser(g);m&&(m.updateCrossSigningVerifiedBefore(this.checkUserTrust(g).isCrossSigningVerified()),this.deviceList.setRawStoredCrossSigningForUser(g,m.toStorage())),this.emit(Ze.UserTrustStatusChanged,g,this.checkUserTrust(g))}}),(0,ae.default)(this,"onMembership",(g,m,f)=>{try{this.onRoomMembership(g,m,f)}catch(E){L.logger.error("Error handling membership change:",E)}}),(0,ae.default)(this,"onToDeviceEvent",g=>{try{L.logger.log(`received to_device ${g.getType()} from: ${g.getSender()} id: ${g.getId()}`),g.getType()=="m.room_key"||g.getType()=="m.forwarded_room_key"?this.onRoomKeyEvent(g):g.getType()=="m.room_key_request"?this.onRoomKeyRequestEvent(g):g.getType()==="m.secret.request"?this.secretStorage.onRequestReceived(g):g.getType()==="m.secret.send"?this.secretStorage.onSecretReceived(g):g.getType()==="m.room_key.withheld"||g.getType()==="org.matrix.room_key.withheld"?this.onRoomKeyWithheldEvent(g):g.getContent().transaction_id?this.onKeyVerificationMessage(g):g.getContent().msgtype==="m.bad.encrypted"?this.onToDeviceBadEncrypted(g):(g.isBeingDecrypted()||g.shouldAttemptDecryption())&&(g.isBeingDecrypted()||g.attemptDecryption(this),g.once(Bn.MatrixEventEvent.Decrypted,m=>{this.onToDeviceEvent(m)}))}catch(m){L.logger.error("Error handling toDeviceEvent:",m)}}),(0,ae.default)(this,"onTimelineEvent",(g,m,f,E,{liveEvent:I=!0}={})=>{if(!Bc.InRoomChannel.validateEvent(g,this.baseApis))return;const w=k=>{const C=new Bc.InRoomChannel(this.baseApis,k.getRoomId());return new fa.VerificationRequest(C,this.verificationMethods,this.baseApis)};this.handleVerificationEvent(g,this.inRoomVerificationRequests,w,I)}),this.reEmitter=new LM.TypedReEmitter(this),l){this.verificationMethods=new Map;for(const g of l)typeof g=="string"?md[g]&&this.verificationMethods.set(g,md[g]):g.NAME?this.verificationMethods.set(g.NAME,g):L.logger.warn(`Excluding unknown verification method ${g}`)}else this.verificationMethods=new Map(Object.entries(md));this.backupManager=new jM.BackupManager(e,async()=>{const g=await this.getSessionBackupPrivateKey();if(g)return g;const m=await this.getSecret("m.megolm_backup.v1");if(m){const f=ul(m);if(f){const[E]=await this.getSecretStorageKey();await this.storeSecret("m.megolm_backup.v1",f,[E])}return Ot.decodeBase64(f||m)}if(this.baseApis.cryptoCallbacks&&this.baseApis.cryptoCallbacks.getBackupKey)return await this.baseApis.cryptoCallbacks.getBackupKey();throw new Error("Unable to get private key")}),this.olmDevice=new ym.OlmDevice(o),this.deviceList=new BM.DeviceList(e,o,this.olmDevice),this.deviceList.on(Ze.UserCrossSigningUpdated,this.onDeviceListUserCrossSigningUpdated),this.reEmitter.reEmit(this.deviceList,[Ze.DevicesUpdated,Ze.WillUpdateDevices]),this.supportedAlgorithms=Object.keys(Lc.DECRYPTION_CLASSES),this.outgoingRoomKeyRequestManager=new KM.OutgoingRoomKeyRequestManager(e,this.deviceId,this.cryptoStore),this.toDeviceVerificationRequests=new Wr.ToDeviceRequests,this.inRoomVerificationRequests=new Bc.InRoomRequests;const u=this.baseApis.cryptoCallbacks||{},c=(0,Ln.createCryptoStoreCacheCallbacks)(o,this.olmDevice);this.crossSigningInfo=new Ln.CrossSigningInfo(r,u,c),this.secretStorage=new Js.SecretStorage(e,u,e),this.dehydrationManager=new qM.DehydrationManager(this),!u.getCrossSigningKey&&u.getSecretStorageKey&&(u.getCrossSigningKey=async g=>Ln.CrossSigningInfo.getFromSecretStorage(g,this.secretStorage))}async init({exportedOlmDevice:e,pickleKey:t}={}){L.logger.log("Crypto: initialising Olm..."),await V.Olm.init(),L.logger.log(e?"Crypto: initialising Olm device from exported device...":"Crypto: initialising Olm device..."),await this.olmDevice.init({fromExportedDevice:e,pickleKey:t}),L.logger.log("Crypto: loading device list..."),await this.deviceList.load(),this.deviceKeys["ed25519:"+this.deviceId]=this.olmDevice.deviceEd25519Key,this.deviceKeys["curve25519:"+this.deviceId]=this.olmDevice.deviceCurve25519Key,L.logger.log("Crypto: fetching own devices...");let r=this.deviceList.getRawStoredDevicesForUser(this.userId);if(r||(r={}),!r[this.deviceId]){L.logger.log("Crypto: adding this device to the store...");const i={keys:this.deviceKeys,algorithms:this.supportedAlgorithms,verified:Kn.VERIFIED,known:!0};r[this.deviceId]=i,this.deviceList.storeDevicesForUser(this.userId,r),this.deviceList.saveIfDirty()}await this.cryptoStore.doTxn("readonly",[ha.IndexedDBCryptoStore.STORE_ACCOUNT],i=>{this.cryptoStore.getCrossSigningKeys(i,s=>{s&&Object.keys(s).length!==0&&(L.logger.log("Loaded cross-signing public keys from crypto store"),this.crossSigningInfo.setKeys(s))})}),this.deviceList.startTrackingDeviceList(this.userId),L.logger.log("Crypto: checking for key backup..."),this.backupManager.checkAndStart()}getCryptoTrustCrossSignedDevices(){return this.trustCrossSignedDevices}setCryptoTrustCrossSignedDevices(e){this.trustCrossSignedDevices=e;for(const t of this.deviceList.getKnownUserIds()){const r=this.deviceList.getRawStoredDevicesForUser(t);for(const i of Object.keys(r)){const s=this.checkDeviceTrust(t,i);if(!s.isLocallyVerified()&&s.isCrossSigningVerified()){const o=this.deviceList.getStoredDevice(t,i);this.emit(Ze.DeviceVerificationChanged,t,i,o)}}}}async createRecoveryKeyFromPassphrase(e){const t=new V.Olm.PkDecryption;try{const r={};if(e){const o=await(0,FM.keyFromPassphrase)(e);r.passphrase={algorithm:"m.pbkdf2",iterations:o.iterations,salt:o.salt},r.pubkey=t.init_with_private_key(o.key)}else r.pubkey=t.generate_key();const i=t.get_private_key(),s=(0,_m.encodeRecoveryKey)(i);return{keyInfo:r,encodedPrivateKey:s,privateKey:i}}finally{t&&t.free()}}async isCrossSigningReady(){const e=this.crossSigningInfo.getId(),t=await this.crossSigningInfo.isStoredInKeyCache()||await this.crossSigningInfo.isStoredInSecretStorage(this.secretStorage);return!!(e&&t)}async isSecretStorageReady(){const e=await this.secretStorage.hasKey(),t=await this.crossSigningInfo.isStoredInSecretStorage(this.secretStorage),r=!this.backupManager.getKeyBackupEnabled()||await this.baseApis.isKeyBackupKeyStored();return!!(e&&t&&r)}async bootstrapCrossSigning({authUploadDeviceSigningKeys:e,setupNewCrossSigning:t}={}){L.logger.log("Bootstrapping cross-signing");const r=this.baseApis.cryptoCallbacks,i=new vm.EncryptionSetupBuilder(this.baseApis.store.accountData,r),s=new Ln.CrossSigningInfo(this.userId,i.crossSigningCallbacks,i.crossSigningCallbacks),o=async()=>{s.resetKeys(),await this.signObject(s.keys.master),i.addCrossSigningKeys(e,s.keys);const f=this.deviceList.getStoredDevice(this.userId,this.deviceId),E=await s.signDevice(this.userId,f);i.addKeySignature(this.userId,this.deviceId,E),this.backupManager.backupInfo&&(await s.signObject(this.backupManager.backupInfo.auth_data,"master"),i.addSessionBackup(this.backupManager.backupInfo))},a=this.crossSigningInfo.getId(),l=await this.crossSigningInfo.isStoredInKeyCache(),u=await this.crossSigningInfo.isStoredInSecretStorage(this.secretStorage),c=l||u;L.logger.log({setupNewCrossSigning:t,publicKeysOnDevice:a,privateKeysInCache:l,privateKeysInStorage:u,privateKeysExistSomewhere:c}),!c||t?(L.logger.log("Cross-signing private keys not found locally or in secret storage, creating new keys"),await o()):a&&l?L.logger.log("Cross-signing public keys trusted and private keys found locally"):u&&(L.logger.log("Cross-signing private keys not found locally, but they are available in secret storage, reading storage and caching locally"),await this.checkOwnCrossSigningTrust({allowPrivateKeyRequests:!0}));const g=i.crossSigningCallbacks.privateKeys;if(g.size&&!this.baseApis.cryptoCallbacks.saveCrossSigningKeys){const f=new Js.SecretStorage(i.accountDataClientAdapter,i.ssssCryptoCallbacks);await f.hasKey()&&(L.logger.log("Storing new cross-signing private keys in secret storage"),await Ln.CrossSigningInfo.storeInSecretStorage(g,f))}await i.buildOperation().apply(this),await i.persist(this),L.logger.log("Cross-signing ready")}async bootstrapSecretStorage({createSecretStorageKey:e=async()=>({}),keyBackupInfo:t,setupNewKeyBackup:r,setupNewSecretStorage:i,getKeyBackupPassphrase:s}={}){L.logger.log("Bootstrapping Secure Secret Storage");const o=this.baseApis.cryptoCallbacks,a=new vm.EncryptionSetupBuilder(this.baseApis.store.accountData,o),l=new Js.SecretStorage(a.accountDataClientAdapter,a.ssssCryptoCallbacks);let u=null;const c=async(S,T)=>{T&&(S.key=T);const{keyId:D,keyInfo:R}=await l.addKey(Js.SECRET_STORAGE_ALGORITHM_V1_AES,S);return T&&a.ssssCryptoCallbacks.addPrivateKey(D,R,T),await l.setDefaultKeyId(D),D},g=async(S,T)=>{if(!T.mac){const D=await this.baseApis.cryptoCallbacks.getSecretStorageKey({keys:{[S]:T}},"");if(D){const R=D[1];a.ssssCryptoCallbacks.addPrivateKey(S,T,R);const{iv:U,mac:q}=await(0,gd.calculateKeyCheck)(R);T.iv=U,T.mac=q,await a.setAccountData(`m.secret_storage.key.${S}`,T)}}},m=async S=>{if(this.crossSigningInfo.getId()&&await this.crossSigningInfo.isStoredInKeyCache("master"))try{L.logger.log("Adding cross-signing signature to key backup"),await this.crossSigningInfo.signObject(S,"master")}catch(T){L.logger.error("Signing key backup with cross-signing keys failed",T)}else L.logger.warn("Cross-signing keys not available, skipping signature on key backup")},f=await this.getSecretStorageKey(),[E,I]=f||[null,null],w=!i&&I&&I.algorithm===Js.SECRET_STORAGE_ALGORITHM_V1_AES;if(L.logger.log({keyBackupInfo:t,setupNewKeyBackup:r,setupNewSecretStorage:i,storageExists:w,oldKeyInfo:I}),!w&&!t){L.logger.log("Secret storage does not exist, creating new storage key");const{keyInfo:S,privateKey:T}=await e();u=await c(S,T)}else if(!w&&t){L.logger.log("Secret storage does not exist, using key backup key");const S=await this.getSessionBackupPrivateKey()||await s(),T={};t.auth_data.private_key_salt&&t.auth_data.private_key_iterations&&(T.passphrase={algorithm:"m.pbkdf2",iterations:t.auth_data.private_key_iterations,salt:t.auth_data.private_key_salt,bits:256}),u=await c(T,S),await l.store("m.megolm_backup.v1",Ot.encodeBase64(S),[u]),await m(t.auth_data),a.addSessionBackup(t)}else L.logger.log("Secret storage exists"),I&&I.algorithm===Js.SECRET_STORAGE_ALGORITHM_V1_AES&&await g(E,I);if(!this.baseApis.cryptoCallbacks.saveCrossSigningKeys&&await this.isCrossSigningReady()&&(u||!await this.crossSigningInfo.isStoredInSecretStorage(l))){L.logger.log("Copying cross-signing private keys from cache to secret storage");const S=await this.crossSigningInfo.getCrossSigningKeysFromCache();await Ln.CrossSigningInfo.storeInSecretStorage(S,l)}if(r&&!t){L.logger.log("Creating new message key backup version");const S=await this.baseApis.prepareKeyBackupVersion(null,{secureSecretStorage:!1}),T=(0,_m.decodeRecoveryKey)(S.recovery_key);await l.store("m.megolm_backup.v1",Ot.encodeBase64(T));const D={algorithm:S.algorithm,auth_data:S.auth_data};await m(D.auth_data),await this.signObject(D.auth_data),a.addSessionBackup(D)}const k=await l.get("m.megolm_backup.v1");if(k){L.logger.info("Got session backup key from secret storage: caching");const S=ul(k);S&&await l.store("m.megolm_backup.v1",S,[u||E]);const T=new Uint8Array(Ot.decodeBase64(S||k));await a.addSessionBackupPrivateKeyToCache(T)}else if(this.backupManager.getKeyBackupEnabled()){const S=await this.getSessionBackupPrivateKey()||await s();if(!S){L.logger.error("Key backup is enabled but couldn't get key backup key!");return}L.logger.info("Got session backup key from cache/user that wasn't in SSSS: saving to SSSS"),await l.store("m.megolm_backup.v1",Ot.encodeBase64(S))}await a.buildOperation().apply(this),await a.persist(this),L.logger.log("Secure Secret Storage ready")}addSecretStorageKey(e,t,r){return this.secretStorage.addKey(e,t,r)}hasSecretStorageKey(e){return this.secretStorage.hasKey(e)}getSecretStorageKey(e){return this.secretStorage.getKey(e)}storeSecret(e,t,r){return this.secretStorage.store(e,t,r)}getSecret(e){return this.secretStorage.get(e)}isSecretStored(e,t){return this.secretStorage.isStored(e,t)}requestSecret(e,t){return t||(t=Object.keys(this.deviceList.getRawStoredDevicesForUser(this.userId))),this.secretStorage.request(e,t)}getDefaultSecretStorageKeyId(){return this.secretStorage.getDefaultKeyId()}setDefaultSecretStorageKeyId(e){return this.secretStorage.setDefaultKeyId(e)}checkSecretStorageKey(e,t){return this.secretStorage.checkKey(e,t)}checkSecretStoragePrivateKey(e,t){let r=null;try{return r=new V.Olm.PkDecryption,r.init_with_private_key(e)===t}finally{r&&r.free()}}async getSessionBackupPrivateKey(){let e=await new Promise(t=>{this.cryptoStore.doTxn("readonly",[ha.IndexedDBCryptoStore.STORE_ACCOUNT],r=>{this.cryptoStore.getSecretStorePrivateKey(r,t,"m.megolm_backup.v1")})});if(e&&typeof e=="string"&&(e=new Uint8Array(Ot.decodeBase64(ul(e)||e)),await this.storeSessionBackupPrivateKey(e)),e&&e.ciphertext){const t=Buffer.from(this.olmDevice.pickleKey),r=await(0,gd.decryptAES)(e,t,"m.megolm_backup.v1");e=Ot.decodeBase64(r)}return e}async storeSessionBackupPrivateKey(e){if(!(e instanceof Uint8Array))throw new Error(`storeSessionBackupPrivateKey expects Uint8Array, got ${e}`);const t=Buffer.from(this.olmDevice.pickleKey),r=await(0,gd.encryptAES)(Ot.encodeBase64(e),t,"m.megolm_backup.v1");return this.cryptoStore.doTxn("readwrite",[ha.IndexedDBCryptoStore.STORE_ACCOUNT],i=>{this.cryptoStore.storeSecretStorePrivateKey(i,"m.megolm_backup.v1",r)})}checkCrossSigningPrivateKey(e,t){let r=null;try{return r=new V.Olm.PkSigning,r.init_with_seed(e)===t}finally{r&&r.free()}}async afterCrossSigningLocalKeyChange(){L.logger.info("Starting cross-signing key change post-processing");const e=this.deviceList.getStoredDevice(this.userId,this.deviceId),t=await this.crossSigningInfo.signDevice(this.userId,e);L.logger.info(`Starting background key sig upload for ${this.deviceId}`);const r=({shouldEmit:s=!1})=>this.baseApis.uploadKeySignatures({[this.userId]:{[this.deviceId]:t}}).then(o=>{const{failures:a}=o||{};if(Object.keys(a||[]).length>0)throw s&&this.baseApis.emit(Ze.KeySignatureUploadFailure,a,"afterCrossSigningLocalKeyChange",r),new Kc.KeySignatureUploadError("Key upload failed",{failures:a});L.logger.info(`Finished background key sig upload for ${this.deviceId}`)}).catch(o=>{L.logger.error(`Error during background key sig upload for ${this.deviceId}`,o)});r({shouldEmit:!0});const i=this.baseApis.cryptoCallbacks.shouldUpgradeDeviceVerifications;if(i){L.logger.info("Starting device verification upgrade");const s={};for(const[o,a]of Object.entries(this.deviceList.crossSigningInfo)){const l=await this.checkForDeviceVerificationUpgrade(o,Ln.CrossSigningInfo.fromStorage(a,o));l&&(s[o]=l)}if(Object.keys(s).length>0){L.logger.info(`Found ${Object.keys(s).length} verif users to upgrade`);try{const o=await i({users:s});if(o)for(const a of o)a in s&&await this.baseApis.setDeviceVerified(a,s[a].crossSigningInfo.getId())}catch(o){L.logger.log("shouldUpgradeDeviceVerifications threw an error: not upgrading",o)}}L.logger.info("Finished device verification upgrade")}L.logger.info("Finished cross-signing key change post-processing")}async checkForDeviceVerificationUpgrade(e,t){const r=this.crossSigningInfo.checkUserTrust(t);if(t.firstUse&&!r.isVerified()){const i=this.deviceList.getRawStoredDevicesForUser(e),s=await this.checkForValidDeviceSignature(e,t.keys.master,i);if(s.length)return{devices:s.map(o=>ll.DeviceInfo.fromStorage(i[o],o)),crossSigningInfo:t}}}async checkForValidDeviceSignature(e,t,r){const i=[];if(r&&t.signatures&&t.signatures[e])for(const s of Object.keys(t.signatures[e])){const[,o]=s.split(":",2);if(o in r&&r[o].verified===Kn.VERIFIED)try{await Ot.verifySignature(this.olmDevice,t,e,o,r[o].keys[s]),i.push(o)}catch{}}return i}getCrossSigningId(e){return this.crossSigningInfo.getId(e)}getStoredCrossSigningForUser(e){return this.deviceList.getStoredCrossSigningForUser(e)}checkUserTrust(e){const t=this.deviceList.getStoredCrossSigningForUser(e);return t?this.crossSigningInfo.checkUserTrust(t):new Ln.UserTrustLevel(!1,!1,!1)}checkDeviceTrust(e,t){const r=this.deviceList.getStoredDevice(e,t);return this.checkDeviceInfoTrust(e,r)}checkDeviceInfoTrust(e,t){const r=!!(t&&t.isVerified()),i=this.deviceList.getStoredCrossSigningForUser(e);if(t&&i){const s=this.trustCrossSignedDevices||e===this.userId;return this.crossSigningInfo.checkDeviceTrust(i,t,r,s)}else return new Ln.DeviceTrustLevel(!1,!1,r,!1)}async checkOwnCrossSigningTrust({allowPrivateKeyRequests:e=!1}={}){const t=this.userId;await this.downloadKeys([this.userId]);const r=await this.crossSigningInfo.getCrossSigningKeysFromCache(),i=this.deviceList.getStoredCrossSigningForUser(t);if(!i){L.logger.error("Got cross-signing update event for user "+t+" but no new cross-signing information found!");return}const s=i.getId(),o=this.crossSigningInfo.getId()!==s,a=i.getId()&&!r.has("master");if(o&&L.logger.info("Got new master public key",s),e&&(o||a)){L.logger.info("Attempting to retrieve cross-signing master private key");let w=null;try{w=(await this.crossSigningInfo.getCrossSigningKey("master",s))[1],L.logger.info("Got cross-signing master private key")}finally{w&&w.free()}}const l=this.crossSigningInfo.getId("self_signing"),u=this.crossSigningInfo.getId("user_signing");this.storeTrustedSelfKeys(i.keys);const c=l!==i.getId("self_signing"),g=u!==i.getId("user_signing"),m=i.getId("self_signing")&&!r.has("self_signing"),f=i.getId("user_signing")&&!r.has("user_signing"),E={};if(c&&L.logger.info("Got new self-signing key",i.getId("self_signing")),e&&(c||m)){L.logger.info("Attempting to retrieve cross-signing self-signing private key");let w=null;try{w=(await this.crossSigningInfo.getCrossSigningKey("self_signing",i.getId("self_signing")))[1],L.logger.info("Got cross-signing self-signing private key")}finally{w&&w.free()}const k=this.deviceList.getStoredDevice(this.userId,this.deviceId),C=await this.crossSigningInfo.signDevice(this.userId,k);E[this.deviceId]=C}if(g&&L.logger.info("Got new user-signing key",i.getId("user_signing")),e&&(g||f)){L.logger.info("Attempting to retrieve cross-signing user-signing private key");let w=null;try{w=(await this.crossSigningInfo.getCrossSigningKey("user_signing",i.getId("user_signing")))[1],L.logger.info("Got cross-signing user-signing private key")}finally{w&&w.free()}}if(o){const w=this.crossSigningInfo.keys.master;await this.signObject(w);const k=w.signatures[this.userId]["ed25519:"+this.deviceId];E[this.crossSigningInfo.getId()]=Object.assign({},w,{signatures:{[this.userId]:{["ed25519:"+this.deviceId]:k}}})}const I=Object.keys(E);if(I.length){const w=({shouldEmit:k=!1})=>(L.logger.info(`Starting background key sig upload for ${I}`),this.baseApis.uploadKeySignatures({[this.userId]:E}).then(C=>{const{failures:S}=C||{};if(L.logger.info(`Finished background key sig upload for ${I}`),Object.keys(S||[]).length>0)throw k&&this.baseApis.emit(Ze.KeySignatureUploadFailure,S,"checkOwnCrossSigningTrust",w),new Kc.KeySignatureUploadError("Key upload failed",{failures:S})}).catch(C=>{L.logger.error(`Error during background key sig upload for ${I}`,C)}));w({shouldEmit:!0})}this.emit(Ze.UserTrustStatusChanged,t,this.checkUserTrust(t)),o&&(this.emit(Ze.KeysChanged,{}),await this.afterCrossSigningLocalKeyChange()),await this.backupManager.checkKeyBackup()}async storeTrustedSelfKeys(e){e?this.crossSigningInfo.setKeys(e):this.crossSigningInfo.clearKeys(),await this.cryptoStore.doTxn("readwrite",[ha.IndexedDBCryptoStore.STORE_ACCOUNT],t=>{this.cryptoStore.storeCrossSigningKeys(t,this.crossSigningInfo.keys)})}async checkDeviceVerifications(e){const t=this.baseApis.cryptoCallbacks.shouldUpgradeDeviceVerifications;if(!!t){if(L.logger.info(`Starting device verification upgrade for ${e}`),this.crossSigningInfo.keys.user_signing){const r=this.deviceList.getStoredCrossSigningForUser(e);if(r){const i=await this.checkForDeviceVerificationUpgrade(e,r);i&&(await t({users:{[e]:i}})).includes(e)&&await this.baseApis.setDeviceVerified(e,r.getId())}}L.logger.info(`Finished device verification upgrade for ${e}`)}}async setTrustedBackupPubKey(e){this.sessionStore.setLocalTrustedBackupPubKey(e),await this.backupManager.checkKeyBackup()}enableLazyLoading(){this.lazyLoadMembers=!0}registerEventHandlers(e){e.on(GM.RoomMemberEvent.Membership,this.onMembership),e.on(WM.ClientEvent.ToDeviceEvent,this.onToDeviceEvent),e.on(VM.RoomEvent.Timeline,this.onTimelineEvent),e.on(Bn.MatrixEventEvent.Decrypted,this.onTimelineEvent)}start(){this.outgoingRoomKeyRequestManager.start()}stop(){this.outgoingRoomKeyRequestManager.stop(),this.deviceList.stop(),this.dehydrationManager.stop()}getDeviceEd25519Key(){return this.olmDevice.deviceEd25519Key}getDeviceCurve25519Key(){return this.olmDevice.deviceCurve25519Key}setGlobalBlacklistUnverifiedDevices(e){this.globalBlacklistUnverifiedDevices=e}getGlobalBlacklistUnverifiedDevices(){return this.globalBlacklistUnverifiedDevices}setGlobalErrorOnUnknownDevices(e){this.globalErrorOnUnknownDevices=e}getGlobalErrorOnUnknownDevices(){return this.globalErrorOnUnknownDevices}uploadDeviceKeys(){const e={algorithms:this.supportedAlgorithms,device_id:this.deviceId,keys:this.deviceKeys,user_id:this.userId};return this.signObject(e).then(()=>this.baseApis.uploadKeysRequest({device_keys:e}))}updateOneTimeKeyCount(e){if(isFinite(e))this.oneTimeKeyCount=e;else throw new TypeError("Parameter for updateOneTimeKeyCount has to be a number")}setNeedsNewFallback(e){this.needsNewFallback=!!e}getNeedsNewFallback(){return this.needsNewFallback}maybeUploadOneTimeKeys(){if(this.oneTimeKeyCheckInProgress)return;const r=Date.now();if(this.lastOneTimeKeyCheck!==null&&r-this.lastOneTimeKeyCheck<6e4)return;this.lastOneTimeKeyCheck=r;const i=this.olmDevice.maxNumberOfOneTimeKeys(),s=Math.floor(i/2),o=async a=>{for(;s>a||this.getNeedsNewFallback();){if(s>a){L.logger.info("generating oneTimeKeys");const u=Math.min(s-a,5);await this.olmDevice.generateOneTimeKeys(u)}if(this.getNeedsNewFallback()){const u=await this.olmDevice.getFallbackKey();(!u.curve25519||Object.keys(u.curve25519).length==0)&&(L.logger.info("generating fallback key"),this.fallbackCleanup&&(clearTimeout(this.fallbackCleanup),delete this.fallbackCleanup),await this.olmDevice.generateFallbackKey())}L.logger.info("calling uploadOneTimeKeys");const l=await this.uploadOneTimeKeys();if(l.one_time_key_counts&&l.one_time_key_counts.signed_curve25519)a=l.one_time_key_counts.signed_curve25519;else throw new Error("response for uploading keys does not contain one_time_key_counts.signed_curve25519")}};this.oneTimeKeyCheckInProgress=!0,Promise.resolve().then(()=>this.oneTimeKeyCount!==void 0?Promise.resolve(this.oneTimeKeyCount):this.baseApis.uploadKeysRequest({}).then(a=>a.one_time_key_counts.signed_curve25519||0)).then(a=>o(a)).catch(a=>{L.logger.error("Error uploading one-time keys",a.stack||a)}).finally(()=>{this.oneTimeKeyCount=void 0,this.oneTimeKeyCheckInProgress=!1})}async uploadOneTimeKeys(){const e=[];let t;if(this.getNeedsNewFallback()){t={};const a=await this.olmDevice.getFallbackKey();for(const[l,u]of Object.entries(a.curve25519)){const c={key:u,fallback:!0};t["signed_curve25519:"+l]=c,e.push(this.signObject(c))}this.setNeedsNewFallback(!1)}const r=await this.olmDevice.getOneTimeKeys(),i={};for(const a in r.curve25519)if(r.curve25519.hasOwnProperty(a)){const l={key:r.curve25519[a]};i["signed_curve25519:"+a]=l,e.push(this.signObject(l))}await Promise.all(e);const s={one_time_keys:i};t&&(s["org.matrix.msc2732.fallback_keys"]=t,s.fallback_keys=t);const o=await this.baseApis.uploadKeysRequest(s);return t&&(this.fallbackCleanup=setTimeout(()=>{delete this.fallbackCleanup,this.olmDevice.forgetOldFallbackKey()},60*60*1e3)),await this.olmDevice.markKeysAsPublished(),o}downloadKeys(e,t){return this.deviceList.downloadKeys(e,t)}getStoredDevicesForUser(e){return this.deviceList.getStoredDevicesForUser(e)}getStoredDevice(e,t){return this.deviceList.getStoredDevice(e,t)}saveDeviceList(e){return this.deviceList.saveIfDirty(e)}async setDeviceVerification(e,t,r,i,s){r===void 0&&(r=null),i===void 0&&(i=null),s===void 0&&(s=null);const o=this.deviceList.getStoredCrossSigningForUser(e);if(o&&o.getId()===t){if(i!==null||s!==null)throw new Error("Cannot set blocked or known for a cross-signing key");if(!r)throw new Error("Cannot set a cross-signing key as unverified");if(!this.crossSigningInfo.getId()&&e===this.crossSigningInfo.userId&&(this.storeTrustedSelfKeys(o.keys),this.emit(Ze.UserTrustStatusChanged,this.userId,this.checkUserTrust(e))),e!==this.userId){L.logger.info("Master key "+o.getId()+" for "+e+" marked verified. Signing...");const m=await this.crossSigningInfo.signUser(o);if(m){const f=async({shouldEmit:E=!1})=>{L.logger.info("Uploading signature for "+e+"...");const I=await this.baseApis.uploadKeySignatures({[e]:{[t]:m}}),{failures:w}=I||{};if(Object.keys(w||[]).length>0)throw E&&this.baseApis.emit(Ze.KeySignatureUploadFailure,w,"setDeviceVerification",f),new Kc.KeySignatureUploadError("Key upload failed",{failures:w})};await f({shouldEmit:!0})}return m}else return o}const a=this.deviceList.getRawStoredDevicesForUser(e);if(!a||!a[t])throw new Error("Unknown device "+e+":"+t);const l=a[t];let u=l.verified;r?u=Kn.VERIFIED:r!==null&&u==Kn.VERIFIED&&(u=Kn.UNVERIFIED),i?u=Kn.BLOCKED:i!==null&&u==Kn.BLOCKED&&(u=Kn.UNVERIFIED);let c=l.known;if(s!==null&&(c=s),(l.verified!==u||l.known!==c)&&(l.verified=u,l.known=c,this.deviceList.storeDevicesForUser(e,a),this.deviceList.saveIfDirty()),r&&e===this.userId){L.logger.info("Own device "+t+" marked verified: signing");let m;if(this.checkDeviceTrust(e,t).isCrossSigningVerified()?L.logger.log(`Own device ${t} already cross-signing verified`):m=await this.crossSigningInfo.signDevice(e,ll.DeviceInfo.fromStorage(l,t)),m){const E=async({shouldEmit:I=!1})=>{L.logger.info("Uploading signature for "+t);const w=await this.baseApis.uploadKeySignatures({[e]:{[t]:m}}),{failures:k}=w||{};if(Object.keys(k||[]).length>0)throw I&&this.baseApis.emit(Ze.KeySignatureUploadFailure,k,"setDeviceVerification",E),new Kc.KeySignatureUploadError("Key upload failed",{failures:k})};await E({shouldEmit:!0})}}const g=ll.DeviceInfo.fromStorage(l,t);return this.emit(Ze.DeviceVerificationChanged,e,t,g),g}findVerificationRequestDMInProgress(e){return this.inRoomVerificationRequests.findRequestInProgress(e)}getVerificationRequestsToDeviceInProgress(e){return this.toDeviceVerificationRequests.getRequestsInProgress(e)}requestVerificationDM(e,t){const r=this.inRoomVerificationRequests.findRequestInProgress(t);if(r)return Promise.resolve(r);const i=new Bc.InRoomChannel(this.baseApis,t,e);return this.requestVerificationWithChannel(e,i,this.inRoomVerificationRequests)}requestVerification(e,t){t||(t=Object.keys(this.deviceList.getRawStoredDevicesForUser(e)));const r=this.toDeviceVerificationRequests.findRequestInProgress(e,t);if(r)return Promise.resolve(r);const i=new Wr.ToDeviceChannel(this.baseApis,e,t,Wr.ToDeviceChannel.makeTransactionId());return this.requestVerificationWithChannel(e,i,this.toDeviceVerificationRequests)}async requestVerificationWithChannel(e,t,r){let i=new fa.VerificationRequest(t,this.verificationMethods,this.baseApis);t.transactionId&&r.setRequestByChannel(t,i),await i.sendRequest();const s=r.getRequestByChannel(t);return s?i=s:(L.logger.log(`Crypto: adding new request to requestsByTxnId with id ${t.transactionId} ${t.roomId}`),r.setRequestByChannel(t,i)),i}beginKeyVerification(e,t,r,i=null){let s;if(i){if(s=this.toDeviceVerificationRequests.getRequestBySenderAndTxnId(t,i),!s)throw new Error(`No request found for user ${t} with transactionId ${i}`)}else{i=Wr.ToDeviceChannel.makeTransactionId();const o=new Wr.ToDeviceChannel(this.baseApis,t,[r],i,r);s=new fa.VerificationRequest(o,this.verificationMethods,this.baseApis),this.toDeviceVerificationRequests.setRequestBySenderAndTxnId(t,i,s)}return s.beginKeyVerification(e,{userId:t,deviceId:r})}async legacyDeviceVerification(e,t,r){const i=Wr.ToDeviceChannel.makeTransactionId(),s=new Wr.ToDeviceChannel(this.baseApis,e,[t],i,t),o=new fa.VerificationRequest(s,this.verificationMethods,this.baseApis);this.toDeviceVerificationRequests.setRequestBySenderAndTxnId(e,i,o);const a=o.beginKeyVerification(r,{userId:e,deviceId:t});return await Promise.race([a.verify(),o.waitFor(l=>l.started)]),o}async getOlmSessionsForUser(e){const t=this.getStoredDevicesForUser(e)||[],r={};for(let i=0;i<t.length;++i){const s=t[i],o=s.getIdentityKey(),a=await this.olmDevice.getSessionInfoForDevice(o);r[s.deviceId]={deviceIdKey:o,sessions:a}}return r}getEventSenderDeviceInfo(e){const t=e.getSenderKey(),r=e.getWireContent().algorithm;if(!t||!r||e.getForwardingCurve25519KeyChain().length>0||e.isKeySourceUntrusted())return null;const s=this.deviceList.getDeviceByIdentityKey(r,t);if(s===null)return null;const o=e.getClaimedEd25519Key();return o?o!==s.getFingerprint()?(L.logger.warn("Event "+e.getId()+" claims ed25519 key "+o+" but sender device has key "+s.getFingerprint()),null):s:(L.logger.warn("Event "+e.getId()+" claims no ed25519 key: cannot verify sending device"),null)}getEventEncryptionInfo(e){const t={};if(t.senderKey=e.getSenderKey(),t.algorithm=e.getWireContent().algorithm,!t.senderKey||!t.algorithm)return t.encrypted=!1,t;t.encrypted=!0,e.getForwardingCurve25519KeyChain().length>0||e.isKeySourceUntrusted()?t.authenticated=!1:t.authenticated=!0,t.sender=this.deviceList.getDeviceByIdentityKey(t.algorithm,t.senderKey);const i=e.getClaimedEd25519Key();return i||(L.logger.warn("Event "+e.getId()+" claims no ed25519 key: cannot verify sending device"),t.mismatchedSender=!0),t.sender&&i!==t.sender.getFingerprint()&&(L.logger.warn("Event "+e.getId()+" claims ed25519 key "+i+"but sender device has key "+t.sender.getFingerprint()),t.mismatchedSender=!0),t}forceDiscardSession(e){const t=this.roomEncryptors[e];if(t===void 0)throw new Error("Room not encrypted");if(t.forceDiscardSession===void 0)throw new Error("Room encryption algorithm doesn't support session discarding");t.forceDiscardSession()}async setRoomEncryption(e,t,r){if(!t.algorithm){L.logger.log("Ignoring setRoomEncryption with no algorithm");return}const i=this.roomList.getRoomEncryption(e);if(i&&JSON.stringify(i)!=JSON.stringify(t)){L.logger.error("Ignoring m.room.encryption event which requests a change of config in "+e);return}if(this.roomEncryptors[e])return;let o=null;i||(o=this.roomList.setRoomEncryption(e,t));const a=Lc.ENCRYPTION_CLASSES[t.algorithm];if(!a)throw new Error("Unable to encrypt with "+t.algorithm);const l=new a({userId:this.userId,deviceId:this.deviceId,crypto:this,olmDevice:this.olmDevice,baseApis:this.baseApis,roomId:e,config:t});this.roomEncryptors[e]=l,o&&await o,this.lazyLoadMembers?L.logger.log("Enabling encryption in "+e):(L.logger.log("Enabling encryption in "+e+"; starting to track device lists for all users therein"),await this.trackRoomDevices(e),r||this.deviceList.refreshOutdatedDeviceLists())}trackRoomDevices(e){const t=async()=>{if(!this.roomEncryptors[e])return;const i=this.clientStore.getRoom(e);if(!i)throw new Error(`Unable to start tracking devices in unknown room ${e}`);L.logger.log(`Starting to track devices for room ${e} ...`),(await i.getEncryptionTargetMembers()).forEach(o=>{this.deviceList.startTrackingDeviceList(o.userId)})};let r=this.roomDeviceTrackingState[e];return r||(r=t(),this.roomDeviceTrackingState[e]=r.catch(i=>{throw this.roomDeviceTrackingState[e]=null,i})),r}ensureOlmSessionsForUsers(e,t){const r={};for(let i=0;i<e.length;++i){const s=e[i];r[s]=[];const o=this.getStoredDevicesForUser(s)||[];for(let a=0;a<o.length;++a){const l=o[a];l.getIdentityKey()!=this.olmDevice.deviceCurve25519Key&&l.verified!=Kn.BLOCKED&&r[s].push(l)}}return Ot.ensureOlmSessionsForDevices(this.olmDevice,this.baseApis,r,t)}async exportRoomKeys(){const e=[];return await this.cryptoStore.doTxn("readonly",[ha.IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS],t=>{this.cryptoStore.getAllEndToEndInboundGroupSessions(t,r=>{if(r===null)return;const i=this.olmDevice.exportInboundGroupSession(r.senderKey,r.sessionId,r.sessionData);delete i.first_known_index,i.algorithm=Ot.MEGOLM_ALGORITHM,e.push(i)})}),e}importRoomKeys(e,t={}){let r=0,i=0;const s=e.length;function o(){t.progressCallback({stage:"load_keys",successes:r,failures:i,total:s})}return Promise.all(e.map(a=>!a.room_id||!a.algorithm?(L.logger.warn("ignoring room key entry with missing fields",a),i++,t.progressCallback&&o(),null):this.getRoomDecryptor(a.room_id,a.algorithm).importRoomKey(a,t).finally(()=>{r++,t.progressCallback&&o()}))).then()}countSessionsNeedingBackup(){return this.backupManager.countSessionsNeedingBackup()}prepareToEncrypt(e){const t=this.roomEncryptors[e.roomId];t&&t.prepareToEncrypt(e)}async encryptEvent(e,t){if(!t)throw new Error("Cannot send encrypted messages in unknown rooms");const r=e.getRoomId(),i=this.roomEncryptors[r];if(!i)throw new Error("Room was previously configured to use encryption, but is no longer. Perhaps the homeserver is hiding the configuration event.");this.roomDeviceTrackingState[r]||this.trackRoomDevices(r),await this.roomDeviceTrackingState[r];let s=e.getContent();const o=s["m.relates_to"];o&&(s=Object.assign({},s),delete s["m.relates_to"]);const a=s["io.element.performance_metrics"];a&&(s=Object.assign({},s),delete s["io.element.performance_metrics"]);const l=await i.encryptMessage(t,e.getType(),s);o&&(l["m.relates_to"]=o),a&&(l["io.element.performance_metrics"]=a),e.makeEncrypted("m.room.encrypted",l,this.olmDevice.deviceCurve25519Key,this.olmDevice.deviceEd25519Key)}async decryptEvent(e){if(e.isRedacted()){const t=new Bn.MatrixEvent(e.getUnsigned().redacted_because),r=await this.decryptEvent(t);return{clearEvent:{room_id:e.getRoomId(),type:"m.room.message",content:{},unsigned:{redacted_because:r.clearEvent}}}}else{const t=e.getWireContent();return await this.getRoomDecryptor(e.getRoomId(),t.algorithm).decryptEvent(e)}}async handleDeviceListChanges(e,t){!e.oldSyncToken||await this.evalDeviceListChanges(t)}requestRoomKey(e,t,r=!1){return this.outgoingRoomKeyRequestManager.queueRoomKeyRequest(e,t,r).then(()=>{this.sendKeyRequestsImmediately&&this.outgoingRoomKeyRequestManager.sendQueuedRequests()}).catch(i=>{L.logger.error("Error requesting key for event",i)})}cancelRoomKeyRequest(e){this.outgoingRoomKeyRequestManager.cancelRoomKeyRequest(e).catch(t=>{L.logger.warn("Error clearing pending room key requests",t)})}async cancelAndResendAllOutgoingKeyRequests(){await this.outgoingRoomKeyRequestManager.cancelAndResendAllOutgoingRequests()}async onCryptoEvent(e){const t=e.getRoomId(),r=e.getContent();try{await this.setRoomEncryption(t,r,!0)}catch(i){L.logger.error("Error configuring encryption in room "+t+":",i)}}async onSyncWillProcess(e){e.oldSyncToken||(L.logger.log("Initial sync performed - resetting device tracking state"),this.deviceList.stopTrackingAllDeviceLists(),this.deviceList.startTrackingDeviceList(this.userId),this.roomDeviceTrackingState={}),this.sendKeyRequestsImmediately=!1}async onSyncCompleted(e){this.deviceList.setSyncToken(e.nextSyncToken),this.deviceList.saveIfDirty(),this.deviceList.startTrackingDeviceList(this.userId),this.deviceList.refreshOutdatedDeviceLists(),e.catchingUp||(this.maybeUploadOneTimeKeys(),this.processReceivedRoomKeyRequests(),this.outgoingRoomKeyRequestManager.sendQueuedRequests(),this.sendKeyRequestsImmediately=!0)}async evalDeviceListChanges(e){if(e.changed&&Array.isArray(e.changed)&&e.changed.forEach(t=>{this.deviceList.invalidateUserDeviceList(t)}),e.left&&Array.isArray(e.left)&&e.left.length){const t=new Set(await this.getTrackedE2eUsers());e.left.forEach(r=>{t.has(r)||this.deviceList.stopTrackingDeviceList(r)})}}async getTrackedE2eUsers(){const e=[];for(const t of this.getTrackedE2eRooms()){const r=await t.getEncryptionTargetMembers();for(const i of r)e.push(i.userId)}return e}getTrackedE2eRooms(){return this.clientStore.getRooms().filter(e=>{if(!this.roomEncryptors[e.roomId]||!this.roomDeviceTrackingState[e.roomId])return!1;const r=e.getMyMembership();return r==="join"||r==="invite"})}onRoomKeyEvent(e){const t=e.getContent();if(!t.room_id||!t.algorithm){L.logger.error("key event is missing fields");return}this.backupManager.checkedForBackup||this.backupManager.checkAndStart(),this.getRoomDecryptor(t.room_id,t.algorithm).onRoomKeyEvent(e)}onRoomKeyWithheldEvent(e){const t=e.getContent();if(t.code!=="m.no_olm"&&(!t.room_id||!t.session_id)||!t.algorithm||!t.sender_key){L.logger.error("key withheld event is missing fields");return}L.logger.info(`Got room key withheld event from ${e.getSender()} (${t.sender_key}) for ${t.algorithm}/${t.room_id}/${t.session_id} with reason ${t.code} (${t.reason})`);const r=this.getRoomDecryptor(t.room_id,t.algorithm);if(r.onRoomKeyWithheldEvent&&r.onRoomKeyWithheldEvent(e),!t.room_id){const i=this.getRoomDecryptors(t.algorithm);for(const s of i)s.retryDecryptionFromSender(t.sender_key)}}onKeyVerificationMessage(e){if(!Wr.ToDeviceChannel.validateEvent(e,this.baseApis))return;const t=r=>{if(!Wr.ToDeviceChannel.canCreateRequest(Wr.ToDeviceChannel.getEventType(r)))return;const i=r.getContent(),s=i&&i.from_device;if(!s)return;const o=r.getSender(),a=new Wr.ToDeviceChannel(this.baseApis,o,[s]);return new fa.VerificationRequest(a,this.verificationMethods,this.baseApis)};this.handleVerificationEvent(e,this.toDeviceVerificationRequests,t)}async handleVerificationEvent(e,t,r,i=!0){if(e.isSending()&&e.status!=Bn.EventStatus.SENT){let l,u;try{await new Promise((c,g)=>{l=c,u=()=>{e.status==Bn.EventStatus.CANCELLED&&g(new Error("Event status set to CANCELLED."))},e.once(Bn.MatrixEventEvent.LocalEventIdReplaced,l),e.on(Bn.MatrixEventEvent.Status,u)})}catch(c){L.logger.error("error while waiting for the verification event to be sent: "+c.message);return}finally{e.removeListener(Bn.MatrixEventEvent.LocalEventIdReplaced,l),e.removeListener(Bn.MatrixEventEvent.Status,u)}}let s=t.getRequest(e),o=!1;if(!s){if(s=r(e),!s){L.logger.log(`Crypto: could not find VerificationRequest for ${e.getType()}, and could not create one, so ignoring.`);return}o=!0,t.setRequest(e,s)}e.setVerificationRequest(s);try{await s.channel.handleEvent(e,s,i)}catch(l){L.logger.error("error while handling verification event: "+l.message)}o&&!s.initiatedByMe&&!s.invalid&&!s.observeOnly&&this.baseApis.emit(Ze.VerificationRequest,s)}async onToDeviceBadEncrypted(e){const t=e.getWireContent(),r=e.getSender(),i=t.algorithm,s=t.sender_key,o=()=>{const m=this.getRoomDecryptors(Ot.MEGOLM_ALGORITHM);for(const f of m)f.retryDecryptionFromSender(s)};if(r===void 0||s===void 0||s===void 0)return;this.lastNewSessionForced[r]=this.lastNewSessionForced[r]||{};const a=this.lastNewSessionForced[r][s]||0;if(a+JM>Date.now()){L.logger.debug("New session already forced with device "+r+":"+s+" at "+a+": not forcing another"),await this.olmDevice.recordSessionProblem(s,"wedged",!0),o();return}let l=this.deviceList.getDeviceByIdentityKey(i,s);if(!l&&(await this.downloadKeys([r],!1),l=this.deviceList.getDeviceByIdentityKey(i,s),!l)){L.logger.info("Couldn't find device for identity key "+s+": not re-establishing session"),await this.olmDevice.recordSessionProblem(s,"wedged",!1),o();return}const u={};u[r]=[l],await Ot.ensureOlmSessionsForDevices(this.olmDevice,this.baseApis,u,!0),this.lastNewSessionForced[r][s]=Date.now();const c={algorithm:Ot.OLM_ALGORITHM,sender_key:this.olmDevice.deviceCurve25519Key,ciphertext:{}};await Ot.encryptMessageForDevice(c.ciphertext,this.userId,this.deviceId,this.olmDevice,r,l,{type:"m.dummy"}),await this.olmDevice.recordSessionProblem(s,"wedged",!0),o(),await this.baseApis.sendToDevice("m.room.encrypted",{[r]:{[l.deviceId]:c}});const g=await this.outgoingRoomKeyRequestManager.getOutgoingSentRoomKeyRequest(r,l.deviceId);for(const m of g)this.requestRoomKey(m.requestBody,m.recipients,!0)}onRoomMembership(e,t,r){const i=t.roomId,s=this.roomEncryptors[i];!s||(this.roomDeviceTrackingState[i]&&(t.membership=="join"?(L.logger.log("Join event for "+t.userId+" in "+i),this.deviceList.startTrackingDeviceList(t.userId)):t.membership=="invite"&&this.clientStore.getRoom(i).shouldEncryptForInvitedMembers()&&(L.logger.log("Invite event for "+t.userId+" in "+i),this.deviceList.startTrackingDeviceList(t.userId))),s.onRoomMembership(e,t,r))}onRoomKeyRequestEvent(e){const t=e.getContent();if(t.action==="request"){const r=new x_(e);this.receivedRoomKeyRequests.push(r)}else if(t.action==="request_cancellation"){const r=new QM(e);this.receivedRoomKeyRequestCancellations.push(r)}}async processReceivedRoomKeyRequests(){if(!this.processingRoomKeyRequests){this.processingRoomKeyRequests=!0;try{const e=this.receivedRoomKeyRequests;this.receivedRoomKeyRequests=[];const t=this.receivedRoomKeyRequestCancellations;this.receivedRoomKeyRequestCancellations=[],await Promise.all(e.map(r=>this.processReceivedRoomKeyRequest(r))),await Promise.all(t.map(r=>this.processReceivedRoomKeyRequestCancellation(r)))}catch(e){L.logger.error(`Error processing room key requsts: ${e}`)}finally{this.processingRoomKeyRequests=!1}}}async processReceivedRoomKeyRequest(e){const t=e.userId,r=e.deviceId,i=e.requestBody,s=i.room_id,o=i.algorithm;if(L.logger.log(`m.room_key_request from ${t}:${r} for ${s} / ${i.session_id} (id ${e.requestId})`),t!==this.userId){if(!this.roomEncryptors[s]){L.logger.debug(`room key request for unencrypted room ${s}`);return}const l=this.roomEncryptors[s],u=this.deviceList.getStoredDevice(t,r);if(!u){L.logger.debug(`Ignoring keyshare for unknown device ${t}:${r}`);return}try{await l.reshareKeyWithDevice(i.sender_key,i.session_id,t,u)}catch(c){L.logger.warn("Failed to re-share keys for session "+i.session_id+" with device "+t+":"+u.deviceId,c)}return}if(r===this.deviceId){L.logger.log("Ignoring room key request from ourselves");return}if(!this.roomDecryptors[s]){L.logger.log(`room key request for unencrypted room ${s}`);return}const a=this.roomDecryptors[s][o];if(!a){L.logger.log(`room key request for unknown alg ${o} in room ${s}`);return}if(!await a.hasKeysForKeyRequest(e)){L.logger.log(`room key request for unknown session ${s} / `+i.session_id);return}if(e.share=()=>{a.shareKeysWithDevice(e)},this.checkDeviceTrust(t,r).isVerified()){L.logger.log("device is already verified: sharing keys"),e.share();return}this.emit(Ze.RoomKeyRequest,e)}async processReceivedRoomKeyRequestCancellation(e){L.logger.log(`m.room_key_request cancellation for ${e.userId}:${e.deviceId} (id ${e.requestId})`),this.emit(Ze.RoomKeyRequestCancellation,e)}getRoomDecryptor(e,t){let r,i;if(e=e||null,e&&(r=this.roomDecryptors[e],r||(this.roomDecryptors[e]=r={}),i=r[t],i))return i;const s=Lc.DECRYPTION_CLASSES[t];if(!s)throw new Lc.DecryptionError("UNKNOWN_ENCRYPTION_ALGORITHM",'Unknown encryption algorithm "'+t+'".');return i=new s({userId:this.userId,crypto:this,olmDevice:this.olmDevice,baseApis:this.baseApis,roomId:e}),r&&(r[t]=i),i}getRoomDecryptors(e){const t=[];for(const r of Object.values(this.roomDecryptors))e in r&&t.push(r[e]);return t}async signObject(e){const t=e.signatures||{},r=e.unsigned;delete e.signatures,delete e.unsigned,t[this.userId]=t[this.userId]||{},t[this.userId]["ed25519:"+this.deviceId]=await this.olmDevice.sign(NM.default.stringify(e)),e.signatures=t,r!==void 0&&(e.unsigned=r)}}Ft.Crypto=XM;function ul(n){if(typeof n!="string"||n.indexOf(",")<0)return null;const e=Uint8Array.from(n.split(","),t=>parseInt(t));return Ot.encodeBase64(e)}class x_{constructor(e){(0,ae.default)(this,"userId",void 0),(0,ae.default)(this,"deviceId",void 0),(0,ae.default)(this,"requestId",void 0),(0,ae.default)(this,"requestBody",void 0),(0,ae.default)(this,"share",void 0);const t=e.getContent();this.userId=e.getSender(),this.deviceId=t.requesting_device_id,this.requestId=t.request_id,this.requestBody=t.body||{},this.share=()=>{throw new Error("don't know how to share keys for this request yet")}}}Ft.IncomingRoomKeyRequest=x_;class QM{constructor(e){(0,ae.default)(this,"userId",void 0),(0,ae.default)(this,"deviceId",void 0),(0,ae.default)(this,"requestId",void 0);const t=e.getContent();this.userId=e.getSender(),this.deviceId=t.requesting_device_id,this.requestId=t.request_id}}var lu={},uu={},ZM=G.exports;Object.defineProperty(uu,"__esModule",{value:!0});uu.EventContext=void 0;var yd=ZM(Y.exports),Xs=qt;class eA{constructor(e){(0,yd.default)(this,"timeline",void 0),(0,yd.default)(this,"ourEventIndex",0),(0,yd.default)(this,"paginateTokens",{[Xs.Direction.Backward]:null,[Xs.Direction.Forward]:null}),this.timeline=[e]}getEvent(){return this.timeline[this.ourEventIndex]}getTimeline(){return this.timeline}getOurEventIndex(){return this.ourEventIndex}getPaginateToken(e=!1){return this.paginateTokens[e?Xs.Direction.Backward:Xs.Direction.Forward]}setPaginateToken(e,t=!1){this.paginateTokens[t?Xs.Direction.Backward:Xs.Direction.Forward]=e}addEvents(e,t=!1){t?(this.timeline=e.concat(this.timeline),this.ourEventIndex+=e.length):this.timeline=this.timeline.concat(e)}}uu.EventContext=eA;Object.defineProperty(lu,"__esModule",{value:!0});lu.SearchResult=void 0;var tA=uu;class Af{static fromJson(e,t){const r=e.context||{},i=r.events_before||[],s=r.events_after||[],o=new tA.EventContext(t(e.result));return o.setPaginateToken(r.start,!0),o.addEvents(i.map(t),!0),o.addEvents(s.map(t),!1),o.setPaginateToken(r.end,!1),new Af(e.rank,o)}constructor(e,t){this.rank=e,this.context=t}}lu.SearchResult=Af;var lc={};Object.defineProperty(lc,"__esModule",{value:!0});lc.CrossSigningKey=void 0;let Fh;lc.CrossSigningKey=Fh;(function(n){n.Master="master",n.SelfSigning="self_signing",n.UserSigning="user_signing"})(Fh||(lc.CrossSigningKey=Fh={}));var Df={};Object.defineProperty(Df,"__esModule",{value:!0});Df.eventMapperFor=rA;var Fc=jt;function rA(n,e){const t=Boolean(e.preventReEmit),r=e.decrypt!==!1;function i(s){const o=new Fc.MatrixEvent(s),a=n.getRoom(o.getRoomId());return a!=null&&a.threads.has(o.getId())&&o.setThread(a.threads.get(o.getId())),o.isEncrypted()&&(t||n.reEmitter.reEmit(o,[Fc.MatrixEventEvent.Decrypted]),r&&n.decryptEventIfNeeded(o)),t||n.reEmitter.reEmit(o,[Fc.MatrixEventEvent.Replaced,Fc.MatrixEventEvent.VisibilityChange]),o}return i}var Zn={},du={},nA=G.exports;Object.defineProperty(du,"__esModule",{value:!0});du.MSC3089Branch=void 0;var iA=nA(Y.exports),Qs=ie,sA=qt;function Sm(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function Ii(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Sm(Object(t),!0).forEach(function(r){(0,iA.default)(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Sm(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}class oA{constructor(e,t,r){this.client=e,this.indexEvent=t,this.directory=r}get id(){const e=this.indexEvent.getStateKey();if(!e)throw new Error("State key not found for branch");return e}get isActive(){return this.indexEvent.getContent().active===!0}get version(){var e;return(e=this.indexEvent.getContent().version)!==null&&e!==void 0?e:1}get roomId(){return this.indexEvent.getRoomId()}async delete(){await this.client.sendStateEvent(this.roomId,Qs.UNSTABLE_MSC3089_BRANCH.name,{},this.id),await this.client.redactEvent(this.roomId,this.id);const e=(await this.getVersionHistory())[1];e&&await e.delete()}getName(){return this.indexEvent.getContent().name||"Unnamed File"}async setName(e){await this.client.sendStateEvent(this.roomId,Qs.UNSTABLE_MSC3089_BRANCH.name,Ii(Ii({},this.indexEvent.getContent()),{},{name:e}),this.id)}isLocked(){return this.indexEvent.getContent().locked||!1}async setLocked(e){await this.client.sendStateEvent(this.roomId,Qs.UNSTABLE_MSC3089_BRANCH.name,Ii(Ii({},this.indexEvent.getContent()),{},{locked:e}),this.id)}async getFileInfo(){const t=(await this.getFileEvent()).getOriginalContent().file,r=this.client.mxcUrlToHttp(t.url);if(!r)throw new Error(`No HTTP URL available for ${t.url}`);return{info:t,httpUrl:r}}async getFileEvent(){const e=this.client.getRoom(this.roomId);if(!e)throw new Error("Unknown room");let t=e.getUnfilteredTimelineSet().findEventById(this.id);for(;!t&&e.getLiveTimeline().getState(sA.EventTimeline.BACKWARDS).paginationToken;)await this.client.scrollback(e,100),t=e.getUnfilteredTimelineSet().findEventById(this.id);if(!t)throw new Error("Failed to find event");return await this.client.decryptEventIfNeeded(t,{emit:!0,isRetry:!0}),t}async createNewVersion(e,t,r,i){const s=await this.directory.createFile(e,t,r,Ii(Ii({},i!=null?i:{}),{},{"m.new_content":!0,"m.relates_to":{rel_type:Qs.RelationType.Replace,event_id:this.id}}));return await this.client.sendStateEvent(this.roomId,Qs.UNSTABLE_MSC3089_BRANCH.name,{active:!0,name:e,version:this.version+1},s.event_id),await this.client.sendStateEvent(this.roomId,Qs.UNSTABLE_MSC3089_BRANCH.name,Ii(Ii({},this.indexEvent.getContent()),{},{active:!1}),this.id),s}async getVersionHistory(){const e=[];e.push(this);const t=this.client.getRoom(this.roomId);if(!t)throw new Error("Invalid or unknown room");const r=[...t.getLiveTimeline().getEvents()].reverse();let i,s=await this.getFileEvent();do if(i=r.find(o=>o.replacingEventId()===s.getId()),i){const o=this.directory.getFile(i.getId());if(o)e.push(o),s=i;else break}while(i);return e}}du.MSC3089Branch=oA;var U_=G.exports;Object.defineProperty(Zn,"__esModule",{value:!0});Zn.TreePermissions=fA=Zn.MSC3089TreeSpace=dA=Zn.DEFAULT_TREE_POWER_LEVELS_TEMPLATE=void 0;var $_=U_(Y.exports),aA=U_(Xa.exports),Se=ie,cA=se,Qt=W,bm=du,lA=If;function wm(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function Yi(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?wm(Object(t),!0).forEach(function(r){(0,$_.default)(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):wm(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}const uA={invite:100,kick:100,ban:100,redact:50,state_default:50,events_default:50,users_default:0,events:{[Se.EventType.RoomPowerLevels]:100,[Se.EventType.RoomHistoryVisibility]:100,[Se.EventType.RoomTombstone]:100,[Se.EventType.RoomEncryption]:100,[Se.EventType.RoomName]:50,[Se.EventType.RoomMessage]:50,[Se.EventType.RoomMessageEncrypted]:50,[Se.EventType.Sticker]:50},users:{}};var dA=Zn.DEFAULT_TREE_POWER_LEVELS_TEMPLATE=uA;let Yn;Zn.TreePermissions=Yn;(function(n){n.Viewer="viewer",n.Editor="editor",n.Owner="owner"})(Yn||(Zn.TreePermissions=Yn={}));class hA{constructor(e,t){if(this.client=e,this.roomId=t,(0,$_.default)(this,"room",void 0),this.room=this.client.getRoom(this.roomId),!this.room)throw new Error("Unknown room")}get id(){return this.roomId}get isTopLevel(){const e=this.room.currentState.getStateEvents(Se.EventType.SpaceParent);return e!=null&&e.length?e.every(t=>{var r;return!((r=t.getContent())!==null&&r!==void 0&&r.via)}):!0}async setName(e){await this.client.sendStateEvent(this.roomId,Se.EventType.RoomName,{name:e},"")}async invite(e,t=!0,r=!0){const i=[this.retryInvite(e)];return t&&i.push(...this.getDirectories().map(s=>s.invite(e,t,r))),Promise.all(i).then(()=>{r&&(0,lA.isRoomSharedHistory)(this.room)&&this.client.sendSharedHistoryKeys(this.roomId,[e])})}retryInvite(e){return(0,Qt.simpleRetryOperation)(async()=>{await this.client.invite(this.roomId,e).catch(t=>{throw(t==null?void 0:t.errcode)==="M_FORBIDDEN"?new aA.default.AbortError(t):t})})}async setPermissions(e,t){var r;const i=this.room.currentState.getStateEvents(Se.EventType.RoomPowerLevels,"");if(Array.isArray(i))throw new Error("Unexpected return type for power levels");const s=i.getContent()||{},o=s.users_default||0,a=s.events_default||50,l=((r=s.events)===null||r===void 0?void 0:r[Se.EventType.RoomPowerLevels])||100,u=s.users||{};switch(t){case Yn.Viewer:u[e]=o;break;case Yn.Editor:u[e]=a;break;case Yn.Owner:u[e]=l;break;default:throw new Error("Invalid role: "+t)}s.users=u,await this.client.sendStateEvent(this.roomId,Se.EventType.RoomPowerLevels,s,"")}getPermissions(e){var t,r;const i=this.room.currentState.getStateEvents(Se.EventType.RoomPowerLevels,"");if(Array.isArray(i))throw new Error("Unexpected return type for power levels");const s=i.getContent()||{},o=s.users_default||0,a=s.events_default||50,l=((t=s.events)===null||t===void 0?void 0:t[Se.EventType.RoomPowerLevels])||100,u=((r=s.users)===null||r===void 0?void 0:r[e])||o;return u>=l?Yn.Owner:u>=a?Yn.Editor:Yn.Viewer}async createDirectory(e){const t=await this.client.unstableCreateFileTree(e);return await this.client.sendStateEvent(this.roomId,Se.EventType.SpaceChild,{via:[this.client.getDomain()]},t.roomId),await this.client.sendStateEvent(t.roomId,Se.EventType.SpaceParent,{via:[this.client.getDomain()]},this.roomId),t}getDirectories(){const e=[],t=this.room.currentState.getStateEvents(Se.EventType.SpaceChild);for(const r of t)try{const i=r.getStateKey();if(i){const s=this.client.unstableGetFileTreeSpace(i);s&&e.push(s)}}catch(i){cA.logger.warn("Unable to create tree space instance for listing. Are we joined?",i)}return e}getDirectory(e){return this.getDirectories().find(t=>t.roomId===e)}async delete(){const e=this.getDirectories();for(const i of e)await i.delete();const t=["invite","knock","join"],r=this.room.currentState.getStateEvents(Se.EventType.RoomMember);for(const i of r)if(i.getStateKey()!==this.client.getUserId()&&t.includes(i.getContent().membership)){const o=i.getStateKey();if(!o)throw new Error("State key not found for branch");await this.client.kick(this.roomId,o,"Room deleted")}await this.client.leave(this.roomId)}getOrderedChildren(e){const t=e.map(r=>({roomId:r.getStateKey(),order:r.getContent().order})).filter(r=>r.roomId);return t.sort((r,i)=>{if(r.order&&!i.order)return-1;if(!r.order&&i.order)return 1;if(!r.order&&!i.order){var s,o,a,l;const u=this.client.getRoom(r.roomId),c=this.client.getRoom(i.roomId);if(!u||!c)return(0,Qt.lexicographicCompare)(r.roomId,i.roomId);const g=(s=(o=u.currentState.getStateEvents(Se.EventType.RoomCreate,""))===null||o===void 0?void 0:o.getTs())!==null&&s!==void 0?s:0,m=(a=(l=c.currentState.getStateEvents(Se.EventType.RoomCreate,""))===null||l===void 0?void 0:l.getTs())!==null&&a!==void 0?a:0;return g===m?(0,Qt.lexicographicCompare)(r.roomId,i.roomId):g-m}else return(0,Qt.lexicographicCompare)(r.order,i.order)}),t}getParentRoom(){const t=this.room.currentState.getStateEvents(Se.EventType.SpaceParent)[0];if(!t)throw new Error("Expected to have a parent in a non-top level space");const r=t.getStateKey();if(!r)throw new Error("No state key found for parent");const i=this.client.getRoom(r);if(!i)throw new Error("Unable to locate room for parent");return i}getOrder(){if(this.isTopLevel)return-1;const t=this.getParentRoom().currentState.getStateEvents(Se.EventType.SpaceChild);return this.getOrderedChildren(t).findIndex(i=>i.roomId===this.roomId)}async setOrder(e){var t;if(this.isTopLevel)throw new Error("Cannot set order of top level spaces currently");const r=this.getParentRoom(),i=r.currentState.getStateEvents(Se.EventType.SpaceChild),s=this.getOrderedChildren(i);e=Math.max(Math.min(e,s.length-1),0);const a=this.getOrder()<e;a&&e===s.length-1?e--:!a&&e===0&&e++;const l=s[a?e:e-1],u=s[a?e+1:e];let c=Qt.DEFAULT_ALPHABET[0],g=!1;if(!l)u!=null&&u.order&&(c=(0,Qt.prevString)(u.order));else if(e===s.length-1)u!=null&&u.order&&(c=(0,Qt.nextString)(u.order));else{const I=l==null?void 0:l.order,w=u==null?void 0:u.order;I&&w?I===w?c=(0,Qt.nextString)(I):c=(0,Qt.averageBetweenStrings)(I,w):I?c=(0,Qt.nextString)(I):w?c=(0,Qt.prevString)(w):g=!0}if(g){let I;for(let w=0;w<=e;w++){const k=s[w];if(w===0&&(I=k.order),k.order)I=k.order;else{var m;I=I?(0,Qt.nextString)(I):Qt.DEFAULT_ALPHABET[0];const C=r.currentState.getStateEvents(Se.EventType.SpaceChild,k.roomId),S=(m=C==null?void 0:C.getContent())!==null&&m!==void 0?m:{via:[this.client.getDomain()]};await this.client.sendStateEvent(r.roomId,Se.EventType.SpaceChild,Yi(Yi({},S),{},{order:I}),k.roomId)}}I&&(c=(0,Qt.nextString)(I))}const f=r.currentState.getStateEvents(Se.EventType.SpaceChild,this.roomId),E=(t=f==null?void 0:f.getContent())!==null&&t!==void 0?t:{via:[this.client.getDomain()]};await this.client.sendStateEvent(r.roomId,Se.EventType.SpaceChild,Yi(Yi({},E),{},{order:c}),this.roomId)}async createFile(e,t,r,i){var s;const o=await this.client.uploadContent(t,{includeFilename:!1,onlyContentUri:!0,rawResponse:!1});r.url=o;const a={msgtype:Se.MsgType.File,body:e,url:o,file:r};i=(s=i)!==null&&s!==void 0?s:{},i["m.new_content"]&&(i["m.new_content"]=a);const l=await this.client.sendMessage(this.roomId,Yi(Yi(Yi({},i),a),{},{[Se.UNSTABLE_MSC3089_LEAF.name]:{}}));return await this.client.sendStateEvent(this.roomId,Se.UNSTABLE_MSC3089_BRANCH.name,{active:!0,name:e},l.event_id),l}getFile(e){const t=this.room.currentState.getStateEvents(Se.UNSTABLE_MSC3089_BRANCH.name,e);return t?new bm.MSC3089Branch(this.client,t,this):null}listFiles(){return this.listAllFiles().filter(e=>e.isActive)}listAllFiles(){var e;return((e=this.room.currentState.getStateEvents(Se.UNSTABLE_MSC3089_BRANCH.name))!==null&&e!==void 0?e:[]).map(r=>new bm.MSC3089Branch(this.client,r,this))}}var fA=Zn.MSC3089TreeSpace=hA,Go={};Object.defineProperty(Go,"__esModule",{value:!0});Go.SearchOrderBy=void 0;var Rm;(function(n){n.RoomId="room_id",n.Sender="sender"})(Rm||(Rm={}));let qh;Go.SearchOrderBy=qh;(function(n){n.Recent="recent",n.Rank="rank"})(qh||(Go.SearchOrderBy=qh={}));var hu={},pA=G.exports;Object.defineProperty(hu,"__esModule",{value:!0});hu.MediaHandler=void 0;var pa=pA(Y.exports),Pr=se,gA=Ce;class mA{constructor(e){this.client=e,(0,pa.default)(this,"audioInput",void 0),(0,pa.default)(this,"videoInput",void 0),(0,pa.default)(this,"localUserMediaStream",void 0),(0,pa.default)(this,"userMediaStreams",[]),(0,pa.default)(this,"screensharingStreams",[])}async setAudioInput(e){Pr.logger.info("LOG setting audio input to",e),this.audioInput!==e&&(this.audioInput=e,await this.updateLocalUsermediaStreams())}async setVideoInput(e){Pr.logger.info("LOG setting video input to",e),this.videoInput!==e&&(this.videoInput=e,await this.updateLocalUsermediaStreams())}async updateLocalUsermediaStreams(){if(this.userMediaStreams.length===0)return;const e=new Map;for(const t of this.client.callEventHandler.calls.values())e.set(t.callId,{audio:t.hasLocalUserMediaAudioTrack,video:t.hasLocalUserMediaVideoTrack});for(const t of this.client.callEventHandler.calls.values()){if(t.state===gA.CallState.Ended||!e.has(t.callId))continue;const{audio:r,video:i}=e.get(t.callId),s=await this.getUserMediaStream(r,i,!1);await t.updateLocalUsermediaStream(s)}}async hasAudioDevice(){return(await navigator.mediaDevices.enumerateDevices()).filter(t=>t.kind==="audioinput").length>0}async hasVideoDevice(){return(await navigator.mediaDevices.enumerateDevices()).filter(t=>t.kind==="videoinput").length>0}async getUserMediaStream(e,t,r=!0){var i,s,o,a;const l=e&&await this.hasAudioDevice(),u=t&&await this.hasVideoDevice();let c;if(!this.localUserMediaStream||this.localUserMediaStream.getAudioTracks().length===0&&l||this.localUserMediaStream.getVideoTracks().length===0&&u||((i=this.localUserMediaStream.getAudioTracks()[0])===null||i===void 0||(s=i.getSettings())===null||s===void 0?void 0:s.deviceId)!==this.audioInput||((o=this.localUserMediaStream.getVideoTracks()[0])===null||o===void 0||(a=o.getSettings())===null||a===void 0?void 0:a.deviceId)!==this.videoInput){const g=this.getUserMediaContraints(l,u);Pr.logger.log("Getting user media with constraints",g),c=await navigator.mediaDevices.getUserMedia(g);for(const m of c.getTracks()){const f=m.getSettings();m.kind==="audio"?this.audioInput=f.deviceId:m.kind==="video"&&(this.videoInput=f.deviceId)}r&&(this.localUserMediaStream=c)}else{if(c=this.localUserMediaStream.clone(),!l)for(const g of c.getAudioTracks())c.removeTrack(g);if(!u)for(const g of c.getVideoTracks())c.removeTrack(g)}return r&&this.userMediaStreams.push(c),c}stopUserMediaStream(e){Pr.logger.debug("Stopping usermedia stream",e.id);for(const r of e.getTracks())r.stop();const t=this.userMediaStreams.indexOf(e);t!==-1&&(Pr.logger.debug("Splicing usermedia stream out stream array",e.id),this.userMediaStreams.splice(t,1)),this.localUserMediaStream===e&&(this.localUserMediaStream=void 0)}async getScreensharingStream(e,t=!0){let r;if(this.screensharingStreams.length===0){const i=this.getScreenshareContraints(e);if(!i)return null;e?(Pr.logger.debug("Getting screensharing stream using getUserMedia()",e),r=await navigator.mediaDevices.getUserMedia(i)):(Pr.logger.debug("Getting screensharing stream using getDisplayMedia()"),r=await navigator.mediaDevices.getDisplayMedia(i))}else{const i=this.screensharingStreams[this.screensharingStreams.length-1];Pr.logger.log("Cloning screensharing stream",i.id),r=i.clone()}return t&&this.screensharingStreams.push(r),r}stopScreensharingStream(e){Pr.logger.debug("Stopping screensharing stream",e.id);for(const r of e.getTracks())r.stop();const t=this.screensharingStreams.indexOf(e);t!==-1&&(Pr.logger.debug("Splicing screensharing stream out stream array",e.id),this.screensharingStreams.splice(t,1))}stopAllStreams(){for(const e of this.userMediaStreams)for(const t of e.getTracks())t.stop();for(const e of this.screensharingStreams)for(const t of e.getTracks())t.stop();this.userMediaStreams=[],this.screensharingStreams=[],this.localUserMediaStream=void 0}getUserMediaContraints(e,t){const r=!!navigator.webkitGetUserMedia;return{audio:e?{deviceId:this.audioInput?{ideal:this.audioInput}:void 0}:!1,video:t?{deviceId:this.videoInput?{ideal:this.videoInput}:void 0,width:r?{exact:640}:{ideal:640},height:r?{exact:360}:{ideal:360}}:!1}}getScreenshareContraints(e){return e?(Pr.logger.debug("Using desktop capturer source",e),{audio:!1,video:{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:e}}}):(Pr.logger.debug("Not using desktop capturer source"),{audio:!1,video:!0})}}hu.MediaHandler=mA;var yA=G.exports;Object.defineProperty(st,"__esModule",{value:!0});st.RoomVersionStability=st.PendingEventOrdering=st.MatrixClient=st.ClientEvent=st.CRYPTO_ENABLED=void 0;var X=yA(Y.exports),vd=Fl,Zs=$i,nt=jt,vA=eu,Im=Ce,qc=Ds,_A=vs,N=xf(W),ga=qt,_d=cc,EA=Ni,Ed=xf(xe),SA=tn,bA=ru,oe=se,Tm=jo,M=me,Nt=Ft,Sd=Vo,Om=Us,bd=Qr,wA=$o,RA=lu,IA=Rs,eo=Cs,TA=lc,to=xf(Xe),ue=ie,OA=Je,kA=Df,CA=ai,km=yr,wd=Zn,PA=Go,jc=Fe,MA=hu,AA=je,Vc=lt,DA=Rn;function N_(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(N_=function(r){return r?t:e})(n)}function xf(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=N_(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}function Cm(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function Gc(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Cm(Object(t),!0).forEach(function(r){(0,X.default)(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Cm(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}const xA=3e3,UA=(0,Nt.isCryptoAvailable)();st.CRYPTO_ENABLED=UA;const $A=216e5,Pm=10*60*1e3;let jh;st.PendingEventOrdering=jh;(function(n){n.Chronological="chronological",n.Detached="detached"})(jh||(st.PendingEventOrdering=jh={}));let Vh;st.RoomVersionStability=Vh;(function(n){n.Stable="stable",n.Unstable="unstable"})(Vh||(st.RoomVersionStability=Vh={}));var Mm;(function(n){n.MasterKey="master_key",n.SelfSigningKey="self_signing_key",n.UserSigningKey="user_signing_key"})(Mm||(Mm={}));const ln="$";let cs;st.ClientEvent=cs;(function(n){n.Sync="sync",n.Event="event",n.ToDeviceEvent="toDeviceEvent",n.AccountData="accountData",n.Room="Room",n.DeleteRoom="deleteRoom",n.SyncUnexpectedError="sync.unexpectedError",n.ClientWellKnown="WellKnown.client",n.Group="Group",n.GroupProfile="Group.profile",n.GroupMyMembership="Group.myMembership"})(cs||(st.ClientEvent=cs={}));class fu extends AA.TypedEventEmitter{constructor(e){super();(0,X.default)(this,"reEmitter",new SA.TypedReEmitter(this)),(0,X.default)(this,"olmVersion",null),(0,X.default)(this,"usingExternalCrypto",!1),(0,X.default)(this,"store",void 0),(0,X.default)(this,"deviceId",void 0),(0,X.default)(this,"credentials",void 0),(0,X.default)(this,"pickleKey",void 0),(0,X.default)(this,"scheduler",void 0),(0,X.default)(this,"clientRunning",!1),(0,X.default)(this,"timelineSupport",!1),(0,X.default)(this,"urlPreviewCache",{}),(0,X.default)(this,"unstableClientRelationAggregation",!1),(0,X.default)(this,"identityServer",void 0),(0,X.default)(this,"sessionStore",void 0),(0,X.default)(this,"http",void 0),(0,X.default)(this,"crypto",void 0),(0,X.default)(this,"cryptoCallbacks",void 0),(0,X.default)(this,"callEventHandler",void 0),(0,X.default)(this,"supportsCallTransfer",!1),(0,X.default)(this,"forceTURN",!1),(0,X.default)(this,"iceCandidatePoolSize",0),(0,X.default)(this,"idBaseUrl",void 0),(0,X.default)(this,"baseUrl",void 0),(0,X.default)(this,"canSupportVoip",!1),(0,X.default)(this,"peekSync",null),(0,X.default)(this,"isGuestAccount",!1),(0,X.default)(this,"ongoingScrollbacks",{}),(0,X.default)(this,"notifTimelineSet",null),(0,X.default)(this,"cryptoStore",void 0),(0,X.default)(this,"verificationMethods",void 0),(0,X.default)(this,"fallbackICEServerAllowed",!1),(0,X.default)(this,"roomList",void 0),(0,X.default)(this,"syncApi",void 0),(0,X.default)(this,"pushRules",void 0),(0,X.default)(this,"syncLeftRoomsPromise",void 0),(0,X.default)(this,"syncedLeftRooms",!1),(0,X.default)(this,"clientOpts",void 0),(0,X.default)(this,"clientWellKnownIntervalID",void 0),(0,X.default)(this,"canResetTimelineCallback",void 0),(0,X.default)(this,"pushProcessor",new _d.PushProcessor(this)),(0,X.default)(this,"serverVersionsPromise",void 0),(0,X.default)(this,"cachedCapabilities",void 0),(0,X.default)(this,"clientWellKnown",void 0),(0,X.default)(this,"clientWellKnownPromise",void 0),(0,X.default)(this,"turnServers",[]),(0,X.default)(this,"turnServersExpiry",0),(0,X.default)(this,"checkTurnServersIntervalID",void 0),(0,X.default)(this,"exportedOlmDeviceToImport",void 0),(0,X.default)(this,"txnCtr",0),(0,X.default)(this,"mediaHandler",new MA.MediaHandler(this)),(0,X.default)(this,"pendingEventEncryption",new Map),(0,X.default)(this,"startCallEventHandler",()=>{this.isInitialSyncComplete()&&(this.callEventHandler.start(),this.off(cs.Sync,this.startCallEventHandler))}),e.baseUrl=N.ensureNoTrailingSlash(e.baseUrl),e.idBaseUrl=N.ensureNoTrailingSlash(e.idBaseUrl),this.baseUrl=e.baseUrl,this.idBaseUrl=e.idBaseUrl,this.usingExternalCrypto=e.usingExternalCrypto,this.store=e.store||new vA.StubStore,this.deviceId=e.deviceId||null;const t=e.userId||null;this.credentials={userId:t},this.http=new M.MatrixHttpApi(this,{baseUrl:e.baseUrl,idBaseUrl:e.idBaseUrl,accessToken:e.accessToken,request:e.request,prefix:M.PREFIX_R0,onlyData:!0,extraParams:e.queryParams,localTimeoutMs:e.localTimeoutMs,useAuthorizationHeader:e.useAuthorizationHeader}),e.deviceToImport?this.deviceId?oe.logger.warn("not importing device because device ID is provided to constructor independently of exported data"):this.credentials.userId?oe.logger.warn("not importing device because user ID is provided to constructor independently of exported data"):e.deviceToImport.deviceId?(this.deviceId=e.deviceToImport.deviceId,this.credentials.userId=e.deviceToImport.userId,this.exportedOlmDeviceToImport=e.deviceToImport.olmDevice):oe.logger.warn("not importing device because no device ID in exported data"):e.pickleKey&&(this.pickleKey=e.pickleKey),this.scheduler=e.scheduler,this.scheduler&&this.scheduler.setProcessFunction(async i=>{const s=this.getRoom(i.getRoomId());i.status!==nt.EventStatus.SENDING&&this.updatePendingEventStatus(s,i,nt.EventStatus.SENDING);const o=await this.sendEventHttpRequest(i);return s&&s.updatePendingEvent(i,nt.EventStatus.SENT,o.event_id),o}),(0,Im.createNewMatrixCall)(this,void 0,void 0)&&(this.callEventHandler=new _A.CallEventHandler(this),this.canSupportVoip=!0,this.on(cs.Sync,this.startCallEventHandler)),this.timelineSupport=Boolean(e.timelineSupport),this.unstableClientRelationAggregation=!!e.unstableClientRelationAggregation,this.cryptoStore=e.cryptoStore,this.sessionStore=e.sessionStore,this.verificationMethods=e.verificationMethods,this.cryptoCallbacks=e.cryptoCallbacks||{},this.forceTURN=e.forceTURN||!1,this.iceCandidatePoolSize=e.iceCandidatePoolSize===void 0?0:e.iceCandidatePoolSize,this.supportsCallTransfer=e.supportsCallTransfer||!1,this.fallbackICEServerAllowed=e.fallbackICEServerAllowed||!1,this.roomList=new bA.RoomList(this.cryptoStore),this.on(nt.MatrixEventEvent.Decrypted,i=>{var s,o;const a=i.getPushActions(),l=this.getPushActionsForEvent(i,!0),u=this.getRoom(i.getRoomId());if(!u)return;const c=u.getUnreadNotificationCount(eo.NotificationCountType.Highlight),g=!!(a!=null&&(s=a.tweaks)!==null&&s!==void 0&&s.highlight),m=!!(l!=null&&(o=l.tweaks)!==null&&o!==void 0&&o.highlight);if((g!==m||c>0)&&!u.hasUserReadEvent(this.getUserId(),i.getId())){let f=c;m&&!g&&f++,!m&&g&&f--,u.setUnreadNotificationCount(eo.NotificationCountType.Highlight,f),u.getUnreadNotificationCount(eo.NotificationCountType.Total)<f&&u.setUnreadNotificationCount(eo.NotificationCountType.Total,f)}}),this.on(eo.RoomEvent.Receipt,(i,s)=>{if(s&&this.isRoomEncrypted(s.roomId)){const o=i.getContent();if(!(Object.keys(o).filter(g=>Object.keys(o[g]["m.read"]).includes(this.getUserId())).length>0))return;const l=20,u=s.getLiveTimeline().getEvents();let c=0;for(let g=u.length-1;g>=0;g--){if(g===u.length-l)return;const m=u[g];if(s.hasUserReadEvent(this.getUserId(),m.getId()))break;const f=this.getPushActionsForEvent(m);c+=f.tweaks&&f.tweaks.highlight?1:0}s.setUnreadNotificationCount(eo.NotificationCountType.Highlight,c)}})}async startClient(e){if(this.clientRunning)return;this.clientRunning=!0,typeof e=="number"&&(e={initialSyncLimit:e});const t=this.getUserId();t&&this.store.storeUser(new bd.User(t)),this.crypto&&(this.crypto.uploadDeviceKeys(),this.crypto.start()),this.canSupportVoip&&(this.checkTurnServersIntervalID=setInterval(()=>{this.checkTurnServers()},Pm),this.checkTurnServers()),this.syncApi&&(oe.logger.error("Still have sync object whilst not running: stopping old one"),this.syncApi.stop());try{const{serverSupport:r,stable:i}=await this.doesServerSupportThread();Vc.Thread.setServerSideSupport(r,i)}catch{Vc.Thread.setServerSideSupport(!1,!0)}this.clientOpts=Object.assign({},e),this.clientOpts.crypto=this.crypto,this.clientOpts.canResetEntireTimeline=r=>this.canResetTimelineCallback?this.canResetTimelineCallback(r):!1,this.syncApi=new Zs.SyncApi(this,this.clientOpts),this.syncApi.sync(),this.clientOpts.clientWellKnownPollPeriod!==void 0&&(this.clientWellKnownIntervalID=setInterval(()=>{this.fetchClientWellKnown()},1e3*this.clientOpts.clientWellKnownPollPeriod),this.fetchClientWellKnown())}stopClient(){var e,t,r,i;oe.logger.log("stopping MatrixClient"),this.clientRunning=!1,(e=this.syncApi)===null||e===void 0||e.stop(),this.syncApi=null,(t=this.crypto)===null||t===void 0||t.stop(),(r=this.peekSync)===null||r===void 0||r.stopPeeking(),(i=this.callEventHandler)===null||i===void 0||i.stop(),this.callEventHandler=null,V.clearInterval(this.checkTurnServersIntervalID),this.clientWellKnownIntervalID!==void 0&&V.clearInterval(this.clientWellKnownIntervalID)}async rehydrateDevice(){if(this.crypto)throw new Error("Cannot rehydrate device after crypto is initialized");if(!this.cryptoCallbacks.getDehydrationKey)return;const e=await this.getDehydratedDevice();if(!e)return;if(!e.device_data||!e.device_id){oe.logger.info("no dehydrated device found");return}const t=new V.Olm.Account;try{const r=e.device_data;if(r.algorithm!==IA.DEHYDRATION_ALGORITHM){oe.logger.warn("Wrong algorithm for dehydrated device");return}oe.logger.log("unpickling dehydrated device");const i=await this.cryptoCallbacks.getDehydrationKey(r,o=>{t.unpickle(new Uint8Array(o),r.account)});if(t.unpickle(i,r.account),oe.logger.log("unpickled device"),(await this.http.authedRequest(void 0,M.Method.Post,"/dehydrated_device/claim",void 0,{device_id:e.device_id},{prefix:"/_matrix/client/unstable/org.matrix.msc2697.v2"})).success===!0){this.deviceId=e.device_id,oe.logger.info("using dehydrated device");const o=this.pickleKey||"DEFAULT_KEY";return this.exportedOlmDeviceToImport={pickledAccount:t.pickle(o),sessions:[],pickleKey:o},t.free(),this.deviceId}else{t.free(),oe.logger.info("not using dehydrated device");return}}catch(r){t.free(),oe.logger.warn("could not unpickle",r)}}async getDehydratedDevice(){try{return await this.http.authedRequest(void 0,M.Method.Get,"/dehydrated_device",void 0,void 0,{prefix:"/_matrix/client/unstable/org.matrix.msc2697.v2"})}catch(e){oe.logger.info("could not get dehydrated device",e.toString());return}}async setDehydrationKey(e,t,r){if(!this.crypto){oe.logger.warn("not dehydrating device if crypto is not enabled");return}return await this.crypto.dehydrationManager.setKeyAndQueueDehydration(e,t,r)}async createDehydratedDevice(e,t,r){if(!this.crypto){oe.logger.warn("not dehydrating device if crypto is not enabled");return}return await this.crypto.dehydrationManager.setKey(e,t,r),await this.crypto.dehydrationManager.dehydrateDevice()}async exportDevice(){if(!this.crypto){oe.logger.warn("not exporting device if crypto is not enabled");return}return{userId:this.credentials.userId,deviceId:this.deviceId,olmDevice:await this.crypto.olmDevice.export()}}clearStores(){if(this.clientRunning)throw new Error("Cannot clear stores while client is running");const e=[];return e.push(this.store.deleteAllData()),this.cryptoStore&&e.push(this.cryptoStore.deleteAllData()),Promise.all(e).then()}getUserId(){return this.credentials&&this.credentials.userId?this.credentials.userId:null}getDomain(){return this.credentials&&this.credentials.userId?this.credentials.userId.replace(/^.*?:/,""):null}getUserIdLocalpart(){return this.credentials&&this.credentials.userId?this.credentials.userId.split(":")[0].substring(1):null}getDeviceId(){return this.deviceId}supportsVoip(){return this.canSupportVoip}getMediaHandler(){return this.mediaHandler}setForceTURN(e){this.forceTURN=e}setSupportsCallTransfer(e){this.supportsCallTransfer=e}createCall(e){return(0,Im.createNewMatrixCall)(this,e)}getSyncState(){return this.syncApi?this.syncApi.getSyncState():null}getSyncStateData(){return this.syncApi?this.syncApi.getSyncStateData():null}isInitialSyncComplete(){const e=this.getSyncState();return e?e===Zs.SyncState.Prepared||e===Zs.SyncState.Syncing:!1}isGuest(){return this.isGuestAccount}setGuest(e){this.isGuestAccount=e}getScheduler(){return this.scheduler}retryImmediately(){return this.syncApi.retryImmediately()}getNotifTimelineSet(){return this.notifTimelineSet}setNotifTimelineSet(e){this.notifTimelineSet=e}getCapabilities(e=!1){const t=new Date().getTime();return this.cachedCapabilities&&!e&&t<this.cachedCapabilities.expiration?(oe.logger.log("Returning cached capabilities"),Promise.resolve(this.cachedCapabilities.capabilities)):this.http.authedRequest(void 0,M.Method.Get,"/capabilities").catch(r=>{oe.logger.error(r)}).then((r={})=>{const i=r.capabilities||{},s=Object.keys(i).length?$A:6e4+Math.random()*5e3;return this.cachedCapabilities={capabilities:i,expiration:t+s},oe.logger.log("Caching capabilities: ",i),i})}async initCrypto(){if(!(0,Nt.isCryptoAvailable)())throw new Error("End-to-end encryption not supported in this js-sdk build: did you remember to load the olm library?");if(this.crypto){oe.logger.warn("Attempt to re-initialise e2e encryption on MatrixClient");return}if(!this.sessionStore)throw new Error("Cannot enable encryption: no sessionStore provided");if(!this.cryptoStore)throw new Error("Cannot enable encryption: no cryptoStore provided");oe.logger.log("Crypto: Starting up crypto store..."),await this.cryptoStore.startup(),oe.logger.log("Crypto: initialising roomlist..."),await this.roomList.init();const e=this.getUserId();if(e===null)throw new Error("Cannot enable encryption on MatrixClient with unknown userId: ensure userId is passed in createClient().");if(this.deviceId===null)throw new Error("Cannot enable encryption on MatrixClient with unknown deviceId: ensure deviceId is passed in createClient().");const t=new Nt.Crypto(this,this.sessionStore,e,this.deviceId,this.store,this.cryptoStore,this.roomList,this.verificationMethods);this.reEmitter.reEmit(t,[Nt.CryptoEvent.KeyBackupFailed,Nt.CryptoEvent.KeyBackupSessionsRemaining,Nt.CryptoEvent.RoomKeyRequest,Nt.CryptoEvent.RoomKeyRequestCancellation,Nt.CryptoEvent.Warning,Nt.CryptoEvent.DevicesUpdated,Nt.CryptoEvent.WillUpdateDevices,Nt.CryptoEvent.DeviceVerificationChanged,Nt.CryptoEvent.UserTrustStatusChanged,Nt.CryptoEvent.KeysChanged]),oe.logger.log("Crypto: initialising crypto object..."),await t.init({exportedOlmDevice:this.exportedOlmDeviceToImport,pickleKey:this.pickleKey}),delete this.exportedOlmDeviceToImport,this.olmVersion=Nt.Crypto.getOlmVersion(),t.registerEventHandlers(this),this.crypto=t}isCryptoEnabled(){return!!this.crypto}getDeviceEd25519Key(){return this.crypto?this.crypto.getDeviceEd25519Key():null}getDeviceCurve25519Key(){return this.crypto?this.crypto.getDeviceCurve25519Key():null}async uploadKeys(){if(!this.crypto)throw new Error("End-to-end encryption disabled");await this.crypto.uploadDeviceKeys()}downloadKeys(e,t){return this.crypto?this.crypto.downloadKeys(e,t):Promise.reject(new Error("End-to-end encryption disabled"))}getStoredDevicesForUser(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.getStoredDevicesForUser(e)||[]}getStoredDevice(e,t){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.getStoredDevice(e,t)||null}setDeviceVerified(e,t,r=!0){const i=this.setDeviceVerification(e,t,r,null,null);return e==this.credentials.userId&&this.checkKeyBackup(),i}setDeviceBlocked(e,t,r=!0){return this.setDeviceVerification(e,t,null,r,null)}setDeviceKnown(e,t,r=!0){return this.setDeviceVerification(e,t,null,null,r)}async setDeviceVerification(e,t,r,i,s){if(!this.crypto)throw new Error("End-to-end encryption disabled");await this.crypto.setDeviceVerification(e,t,r,i,s)}requestVerificationDM(e,t){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.requestVerificationDM(e,t)}findVerificationRequestDMInProgress(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.findVerificationRequestDMInProgress(e)}getVerificationRequestsToDeviceInProgress(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.getVerificationRequestsToDeviceInProgress(e)}requestVerification(e,t){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.requestVerification(e,t)}beginKeyVerification(e,t,r){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.beginKeyVerification(e,t,r)}checkSecretStorageKey(e,t){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.checkSecretStorageKey(e,t)}setGlobalBlacklistUnverifiedDevices(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.setGlobalBlacklistUnverifiedDevices(e)}getGlobalBlacklistUnverifiedDevices(){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.getGlobalBlacklistUnverifiedDevices()}setGlobalErrorOnUnknownDevices(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.setGlobalErrorOnUnknownDevices(e)}getGlobalErrorOnUnknownDevices(){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.getGlobalErrorOnUnknownDevices()}getCrossSigningId(e=TA.CrossSigningKey.Master){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.getCrossSigningId(e)}getStoredCrossSigningForUser(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.getStoredCrossSigningForUser(e)}checkUserTrust(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.checkUserTrust(e)}checkDeviceTrust(e,t){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.checkDeviceTrust(e,t)}checkOwnCrossSigningTrust(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.checkOwnCrossSigningTrust(e)}checkCrossSigningPrivateKey(e,t){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.checkCrossSigningPrivateKey(e,t)}legacyDeviceVerification(e,t,r){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.legacyDeviceVerification(e,t,r)}prepareToEncrypt(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.prepareToEncrypt(e)}isCrossSigningReady(){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.isCrossSigningReady()}bootstrapCrossSigning(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.bootstrapCrossSigning(e)}getCryptoTrustCrossSignedDevices(){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.getCryptoTrustCrossSignedDevices()}setCryptoTrustCrossSignedDevices(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.setCryptoTrustCrossSignedDevices(e)}countSessionsNeedingBackup(){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.countSessionsNeedingBackup()}getEventEncryptionInfo(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.getEventEncryptionInfo(e)}createRecoveryKeyFromPassphrase(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.createRecoveryKeyFromPassphrase(e)}isSecretStorageReady(){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.isSecretStorageReady()}bootstrapSecretStorage(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.bootstrapSecretStorage(e)}addSecretStorageKey(e,t,r){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.addSecretStorageKey(e,t,r)}hasSecretStorageKey(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.hasSecretStorageKey(e)}storeSecret(e,t,r){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.storeSecret(e,t,r)}getSecret(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.getSecret(e)}isSecretStored(e,t){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.isSecretStored(e,t)}requestSecret(e,t){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.requestSecret(e,t)}getDefaultSecretStorageKeyId(){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.getDefaultSecretStorageKeyId()}setDefaultSecretStorageKeyId(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.setDefaultSecretStorageKeyId(e)}checkSecretStoragePrivateKey(e,t){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.checkSecretStoragePrivateKey(e,t)}async getEventSenderDeviceInfo(e){return this.crypto?this.crypto.getEventSenderDeviceInfo(e):null}async isEventSenderVerified(e){const t=await this.getEventSenderDeviceInfo(e);return t?t.isVerified():!1}cancelAndResendEventRoomKeyRequest(e){return e.cancelAndResendKeyRequest(this.crypto,this.getUserId())}setRoomEncryption(e,t){if(!this.crypto)throw new Error("End-to-End encryption disabled");return this.crypto.setRoomEncryption(e,t)}isRoomEncrypted(e){const t=this.getRoom(e);return t?t.currentState.getStateEvents(ue.EventType.RoomEncryption,"")?!0:this.roomList.isRoomEncrypted(e):!1}forceDiscardSession(e){if(!this.crypto)throw new Error("End-to-End encryption disabled");this.crypto.forceDiscardSession(e)}exportRoomKeys(){return this.crypto?this.crypto.exportRoomKeys():Promise.reject(new Error("End-to-end encryption disabled"))}importRoomKeys(e,t){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.importRoomKeys(e,t)}checkKeyBackup(){return this.crypto.backupManager.checkKeyBackup()}async getKeyBackupVersion(){let e;try{e=await this.http.authedRequest(void 0,M.Method.Get,"/room_keys/version",void 0,void 0,{prefix:M.PREFIX_UNSTABLE})}catch(t){if(t.errcode==="M_NOT_FOUND")return null;throw t}try{km.BackupManager.checkBackupVersion(e)}catch(t){throw t}return e}isKeyBackupTrusted(e){return this.crypto.backupManager.isKeyBackupTrusted(e)}getKeyBackupEnabled(){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.backupManager.getKeyBackupEnabled()}enableKeyBackup(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.backupManager.enableKeyBackup(e)}disableKeyBackup(){if(!this.crypto)throw new Error("End-to-end encryption disabled");this.crypto.backupManager.disableKeyBackup()}async prepareKeyBackupVersion(e,t={secureSecretStorage:!1}){if(!this.crypto)throw new Error("End-to-end encryption disabled");const{algorithm:r,auth_data:i,recovery_key:s,privateKey:o}=await this.crypto.backupManager.prepareKeyBackupVersion(e);return t.secureSecretStorage&&(await this.storeSecret("m.megolm_backup.v1",(0,Ed.encodeBase64)(o)),oe.logger.info("Key backup private key stored in secret storage")),{algorithm:r,auth_data:i,recovery_key:s}}isKeyBackupKeyStored(){return Promise.resolve(this.isSecretStored("m.megolm_backup.v1",!1))}async createKeyBackupVersion(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");await this.crypto.backupManager.createKeyBackupVersion(e);const t={algorithm:e.algorithm,auth_data:e.auth_data};await this.crypto.signObject(t.auth_data),this.cryptoCallbacks.getCrossSigningKey&&this.crypto.crossSigningInfo.getId()&&await this.crypto.crossSigningInfo.signObject(t.auth_data,"master");const r=await this.http.authedRequest(void 0,M.Method.Post,"/room_keys/version",void 0,t,{prefix:M.PREFIX_UNSTABLE});return await this.checkKeyBackup(),this.getKeyBackupEnabled()||oe.logger.error("Key backup not usable even though we just created it"),r}deleteKeyBackupVersion(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");this.crypto.backupManager.version&&this.crypto.backupManager.disableKeyBackup();const t=N.encodeUri("/room_keys/version/$version",{$version:e});return this.http.authedRequest(void 0,M.Method.Delete,t,void 0,void 0,{prefix:M.PREFIX_UNSTABLE})}makeKeyBackupPath(e,t,r){let i;return t!==void 0?i=N.encodeUri("/room_keys/keys/$roomId/$sessionId",{$roomId:e,$sessionId:t}):e!==void 0?i=N.encodeUri("/room_keys/keys/$roomId",{$roomId:e}):i="/room_keys/keys",{path:i,queryData:r===void 0?void 0:{version:r}}}sendKeyBackup(e,t,r,i){if(!this.crypto)throw new Error("End-to-end encryption disabled");const s=this.makeKeyBackupPath(e,t,r);return this.http.authedRequest(void 0,M.Method.Put,s.path,s.queryData,i,{prefix:M.PREFIX_UNSTABLE})}async scheduleAllGroupSessionsForBackup(){if(!this.crypto)throw new Error("End-to-end encryption disabled");await this.crypto.backupManager.scheduleAllGroupSessionsForBackup()}flagAllGroupSessionsForBackup(){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.backupManager.flagAllGroupSessionsForBackup()}isValidRecoveryKey(e){try{return(0,Sd.decodeRecoveryKey)(e),!0}catch{return!1}}keyBackupKeyFromPassword(e,t){return(0,Om.keyFromAuthData)(t.auth_data,e)}keyBackupKeyFromRecoveryKey(e){return(0,Sd.decodeRecoveryKey)(e)}async restoreKeyBackupWithPassword(e,t,r,i,s){const o=await(0,Om.keyFromAuthData)(i.auth_data,e);return this.restoreKeyBackup(o,t,r,i,s)}async restoreKeyBackupWithSecretStorage(e,t,r,i){const s=await this.getSecret("m.megolm_backup.v1"),o=(0,Nt.fixBackupKey)(s);if(o){const[l]=await this.crypto.getSecretStorageKey();await this.storeSecret("m.megolm_backup.v1",o,[l])}const a=(0,Ed.decodeBase64)(o||s);return this.restoreKeyBackup(a,t,r,e,i)}restoreKeyBackupWithRecoveryKey(e,t,r,i,s){const o=(0,Sd.decodeRecoveryKey)(e);return this.restoreKeyBackup(o,t,r,i,s)}async restoreKeyBackupWithCache(e,t,r,i){const s=await this.crypto.getSessionBackupPrivateKey();if(!s)throw new Error("Couldn't get key");return this.restoreKeyBackup(s,e,t,r,i)}async restoreKeyBackup(e,t,r,i,s){const o=s==null?void 0:s.cacheCompleteCallback,a=s==null?void 0:s.progressCallback;if(!this.crypto)throw new Error("End-to-end encryption disabled");let l=0,u=[];const c=this.makeKeyBackupPath(t,r,i.version),g=await km.BackupManager.makeAlgorithm(i,async()=>e),m=g.untrusted;try{if(!await g.keyMatches(e))return Promise.reject(new M.MatrixError({errcode:fu.RESTORE_BACKUP_ERROR_BAD_KEY}));this.crypto.storeSessionBackupPrivateKey(e).catch(E=>{oe.logger.warn("Error caching session backup key:",E)}).then(o),a&&a({stage:"fetch"});const f=await this.http.authedRequest(void 0,M.Method.Get,c.path,c.queryData,void 0,{prefix:M.PREFIX_UNSTABLE});if(f.rooms){const E=f.rooms;for(const[I,w]of Object.entries(E)){if(!w.sessions)continue;l+=Object.keys(w.sessions).length;const k=await g.decryptSessions(w.sessions);for(const C of k)C.room_id=I,u.push(C)}}else if(f.sessions){const E=f.sessions;l=Object.keys(E).length,u=await g.decryptSessions(E);for(const I of u)I.room_id=t}else{l=1;try{const[E]=await g.decryptSessions({[r]:f});E.room_id=t,E.session_id=r,u.push(E)}catch(E){oe.logger.log("Failed to decrypt megolm session from backup",E)}}}finally{g.free()}return await this.importRoomKeys(u,{progressCallback:a,untrusted:m,source:"backup"}),await this.checkKeyBackup(),{total:l,imported:u.length}}deleteKeysFromBackup(e,t,r){if(!this.crypto)throw new Error("End-to-end encryption disabled");const i=this.makeKeyBackupPath(e,t,r);return this.http.authedRequest(void 0,M.Method.Delete,i.path,i.queryData,void 0,{prefix:M.PREFIX_UNSTABLE})}async sendSharedHistoryKeys(e,t){if(!this.crypto)throw new Error("End-to-end encryption disabled");const r=this.roomList.getRoomEncryption(e);if(!r){oe.logger.error("Unknown room. Not sharing decryption keys");return}const i=await this.crypto.downloadKeys(t),s={};for(const[a,l]of Object.entries(i))s[a]=Object.values(l);const o=this.crypto.getRoomDecryptor(e,r.algorithm);o.sendSharedHistoryInboundSessions?await o.sendSharedHistoryInboundSessions(s):oe.logger.warn("Algorithm does not support sharing previous keys",r.algorithm)}getGroup(e){return this.store.getGroup(e)}getGroups(){return this.store.getGroups()}getMediaConfig(e){return this.http.authedRequest(e,M.Method.Get,"/config",void 0,void 0,{prefix:M.PREFIX_MEDIA_R0})}getRoom(e){return this.store.getRoom(e)}getRooms(){return this.store.getRooms()}getVisibleRooms(){const e=this.store.getRooms(),t=new Set;for(const r of e){const i=r.currentState.getStateEvents(ue.EventType.RoomCreate,"");if(i){const s=i.getContent().predecessor;s&&s.room_id&&t.add(s.room_id)}}return e.filter(r=>!(r.currentState.getStateEvents(ue.EventType.RoomTombstone,"")&&t.has(r.roomId)))}getUser(e){return this.store.getUser(e)}getUsers(){return this.store.getUsers()}setAccountData(e,t,r){const i=N.encodeUri("/user/$userId/account_data/$type",{$userId:this.credentials.userId,$type:e}),s=(0,M.retryNetworkOperation)(5,()=>this.http.authedRequest(void 0,M.Method.Put,i,void 0,t));return r&&s.then(o=>r(null,o),r),s}getAccountData(e){return this.store.getAccountData(e)}async getAccountDataFromServer(e){if(this.isInitialSyncComplete()){const r=this.store.getAccountData(e);return r?r.getContent():null}const t=N.encodeUri("/user/$userId/account_data/$type",{$userId:this.credentials.userId,$type:e});try{return await this.http.authedRequest(void 0,M.Method.Get,t,void 0)}catch(r){if(r.data&&r.data.errcode==="M_NOT_FOUND")return null;throw r}}getIgnoredUsers(){const e=this.getAccountData("m.ignored_user_list");return!e||!e.getContent()||!e.getContent().ignored_users?[]:Object.keys(e.getContent().ignored_users)}setIgnoredUsers(e,t){const r={ignored_users:{}};return e.map(i=>r.ignored_users[i]={}),this.setAccountData("m.ignored_user_list",r,t)}isUserIgnored(e){return this.getIgnoredUsers().includes(e)}async joinRoom(e,t,r){if(N.isFunction(t))throw new Error("Expected 'opts' object, got function.");t=t||{},t.syncRoom===void 0&&(t.syncRoom=!0);const i=this.getRoom(e);if(i&&i.hasMembershipState(this.credentials.userId,"join"))return Promise.resolve(i);let s=Promise.resolve();t.inviteSignUrl&&(s=this.http.requestOtherUrl(void 0,M.Method.Post,t.inviteSignUrl,{mxid:this.credentials.userId}));const o={};t.viaServers&&(o.server_name=t.viaServers);const a={qsStringifyOptions:{arrayFormat:"repeat"}};try{const l={},u=await s;u&&(l.third_party_signed=u);const c=N.encodeUri("/join/$roomid",{$roomid:e}),m=(await this.http.authedRequest(void 0,M.Method.Post,c,o,l,a)).room_id,E=new Zs.SyncApi(this,this.clientOpts).createRoom(m);return t.syncRoom,r==null||r(null,E),E}catch(l){throw r==null||r(l),l}}resendEvent(e,t){return this.updatePendingEventStatus(t,e,nt.EventStatus.SENDING),this.encryptAndSendEvent(t,e)}cancelPendingEvent(e){if(![nt.EventStatus.QUEUED,nt.EventStatus.NOT_SENT,nt.EventStatus.ENCRYPTING].includes(e.status))throw new Error("cannot cancel an event with status "+e.status);e.status===nt.EventStatus.ENCRYPTING?this.pendingEventEncryption.delete(e.getId()):this.scheduler&&e.status===nt.EventStatus.QUEUED&&this.scheduler.removeEventFromQueue(e);const t=this.getRoom(e.getRoomId());this.updatePendingEventStatus(t,e,nt.EventStatus.CANCELLED)}setRoomName(e,t,r){return this.sendStateEvent(e,ue.EventType.RoomName,{name:t},void 0,r)}setRoomTopic(e,t,r){return this.sendStateEvent(e,ue.EventType.RoomTopic,{topic:t},void 0,r)}getRoomTags(e,t){const r=N.encodeUri("/user/$userId/rooms/$roomId/tags/",{$userId:this.credentials.userId,$roomId:e});return this.http.authedRequest(t,M.Method.Get,r,void 0)}setRoomTag(e,t,r,i){const s=N.encodeUri("/user/$userId/rooms/$roomId/tags/$tag",{$userId:this.credentials.userId,$roomId:e,$tag:t});return this.http.authedRequest(i,M.Method.Put,s,void 0,r)}deleteRoomTag(e,t,r){const i=N.encodeUri("/user/$userId/rooms/$roomId/tags/$tag",{$userId:this.credentials.userId,$roomId:e,$tag:t});return this.http.authedRequest(r,M.Method.Delete,i,void 0,void 0)}setRoomAccountData(e,t,r,i){const s=N.encodeUri("/user/$userId/rooms/$roomId/account_data/$type",{$userId:this.credentials.userId,$roomId:e,$type:t});return this.http.authedRequest(i,M.Method.Put,s,void 0,r)}setPowerLevel(e,t,r,i,s){let o={users:{}};(i==null?void 0:i.getType())===ue.EventType.RoomPowerLevels&&(o=N.deepCopy(i.getContent())),o.users[t]=r;const a=N.encodeUri("/rooms/$roomId/state/m.room.power_levels",{$roomId:e});return this.http.authedRequest(s,M.Method.Put,a,void 0,o)}async unstable_createLiveBeacon(e,t,r){const i=this.getUserId(),s=DA.M_BEACON_INFO_VARIABLE.name.replace("*",`${i}.${r}`);return this.unstable_setLiveBeacon(e,s,t)}async unstable_setLiveBeacon(e,t,r){const i=this.getUserId();return this.sendStateEvent(e,t,r,i)}sendEvent(e,t,r,i,s,o){var a,l;if(!((a=t)!==null&&a!==void 0&&a.startsWith(ln))&&t!==null&&(o=s,s=i,i=r,r=t,t=null),t&&!((l=i["m.relates_to"])!==null&&l!==void 0&&l.rel_type)){var u;i["m.relates_to"]=Gc(Gc({},i["m.relates_to"]),{},{rel_type:Vc.THREAD_RELATION_TYPE.name,event_id:t});const g=(u=this.getRoom(e))===null||u===void 0?void 0:u.threads.get(t);if(g){var c;i["m.relates_to"]["m.in_reply_to"]={event_id:(c=g.lastReply(m=>m.isRelation(Vc.THREAD_RELATION_TYPE.name)&&!m.status))===null||c===void 0?void 0:c.getId()}}}return this.sendCompleteEvent(e,t,{type:r,content:i},s,o)}sendCompleteEvent(e,t,r,i,s){N.isFunction(i)&&(s=i,i=void 0),i||(i=this.makeTxnId());const o=new nt.MatrixEvent(Object.assign(r,{event_id:"~"+e+":"+i,user_id:this.credentials.userId,sender:this.credentials.userId,room_id:e,origin_server_ts:new Date().getTime()})),a=this.getRoom(e),l=a==null?void 0:a.threads.get(t);l&&(o.setThread(l),o.setThreadId(l.id));const u=o.getAssociatedId();if(u!=null&&u.startsWith("~")){const g=a.getPendingEvents().find(m=>m.getId()===u);g.once(nt.MatrixEventEvent.LocalEventIdReplaced,()=>{o.updateAssociatedId(g.getId())})}const c=o.getType();return oe.logger.log(`sendEvent of type ${c} in ${e} with txnId ${i}`),o.setTxnId(i),o.setStatus(nt.EventStatus.SENDING),a&&a.addPendingEvent(o,i),o.status===nt.EventStatus.NOT_SENT?Promise.reject(new Error("Event blocked by other events not yet sent")):this.encryptAndSendEvent(a,o,s)}encryptAndSendEvent(e,t,r){let i=!1;return Promise.resolve().then(()=>{const s=this.encryptEventIfNeeded(t,e);return s?(this.pendingEventEncryption.set(t.getId(),s),this.updatePendingEventStatus(e,t,nt.EventStatus.ENCRYPTING),s.then(()=>{if(!this.pendingEventEncryption.has(t.getId())){i=!0;return}this.updatePendingEventStatus(e,t,nt.EventStatus.SENDING)})):null}).then(()=>{if(i)return{};let s;return this.scheduler&&(s=this.scheduler.queueEvent(t),s&&this.scheduler.getQueueForEvent(t).length>1&&this.updatePendingEventStatus(e,t,nt.EventStatus.QUEUED)),s||(s=this.sendEventHttpRequest(t),e&&(s=s.then(o=>(e.updatePendingEvent(t,nt.EventStatus.SENT,o.event_id),o)))),s}).then(s=>(r==null||r(null,s),s)).catch(s=>{oe.logger.error("Error sending event",s.stack||s);try{t.error=s,this.updatePendingEventStatus(e,t,nt.EventStatus.NOT_SENT),s.event=t,r==null||r(s)}catch(o){oe.logger.error("Exception in error handler!",o.stack||s)}throw s})}encryptEventIfNeeded(e,t){if(e.isEncrypted()||e.isRedaction()||!this.isRoomEncrypted(e.getRoomId())||!this.crypto&&this.usingExternalCrypto||e.getType()===ue.EventType.Reaction)return null;if(!this.crypto)throw new Error("This room is configured to use encryption, but your client does not support encryption.");return this.crypto.encryptEvent(e,t)}getEncryptedIfNeededEventType(e,t){return t===ue.EventType.Reaction?t:this.isRoomEncrypted(e)?ue.EventType.RoomMessageEncrypted:t}updatePendingEventStatus(e,t,r){e?e.updatePendingEvent(t,r):t.setStatus(r)}sendEventHttpRequest(e){let t=e.getTxnId();t||(t=this.makeTxnId(),e.setTxnId(t));const r={$roomId:e.getRoomId(),$eventType:e.getWireType(),$stateKey:e.getStateKey(),$txnId:t};let i;if(e.isState()){let s="/rooms/$roomId/state/$eventType";e.getStateKey()&&e.getStateKey().length>0&&(s="/rooms/$roomId/state/$eventType/$stateKey"),i=N.encodeUri(s,r)}else if(e.isRedaction()){const s="/rooms/$roomId/redact/$redactsEventId/$txnId";i=N.encodeUri(s,Object.assign({$redactsEventId:e.event.redacts},r))}else i=N.encodeUri("/rooms/$roomId/send/$eventType/$txnId",r);return this.http.authedRequest(void 0,M.Method.Put,i,void 0,e.getWireContent()).then(s=>(oe.logger.log(`Event sent to ${e.getRoomId()} with event id ${s.event_id}`),s))}redactEvent(e,t,r,i,s){var o;(o=r)!==null&&o!==void 0&&o.startsWith(ln)||(s=i,i=r,r=t,t=null);const l=(typeof s=="object"?s:{}).reason,u=typeof s=="function"?s:void 0;return this.sendCompleteEvent(e,t,{type:ue.EventType.RoomRedaction,content:{reason:l},redacts:r},i,u)}sendMessage(e,t,r,i,s){typeof t!="string"&&t!==null&&(s=i,i=r,r=t,t=null),N.isFunction(i)&&(s=i,i=void 0);let o=ue.EventType.RoomMessage,a=r;const l=(c={},g=!0)=>{let m=null;if(c.msgtype===ue.MsgType.Text?m=vd.MessageEvent.from(c.body,c.formatted_body).serialize():c.msgtype===ue.MsgType.Emote?m=vd.EmoteEvent.from(c.body,c.formatted_body).serialize():c.msgtype===ue.MsgType.Notice&&(m=vd.NoticeEvent.from(c.body,c.formatted_body).serialize()),m&&c["m.new_content"]&&g){const f=l(c["m.new_content"],!1);f&&(m.content["m.new_content"]=f.content)}if(m)for(const[f,E]of Object.entries(c))m.content.hasOwnProperty(f)||(m.content[f]=E);return m},u=l(a);return u&&(o=u.type,a=u.content),this.sendEvent(e,t,o,a,i,s)}sendTextMessage(e,t,r,i,s){var o;!((o=t)!==null&&o!==void 0&&o.startsWith(ln))&&t!==null&&(s=i,i=r,r=t,t=null);const a=to.makeTextMessage(r);return this.sendMessage(e,t,a,i,s)}sendNotice(e,t,r,i,s){var o;!((o=t)!==null&&o!==void 0&&o.startsWith(ln))&&t!==null&&(s=i,i=r,r=t,t=null);const a=to.makeNotice(r);return this.sendMessage(e,t,a,i,s)}sendEmoteMessage(e,t,r,i,s){var o;!((o=t)!==null&&o!==void 0&&o.startsWith(ln))&&t!==null&&(s=i,i=r,r=t,t=null);const a=to.makeEmoteMessage(r);return this.sendMessage(e,t,a,i,s)}sendImageMessage(e,t,r,i,s="Image",o){var a;!((a=t)!==null&&a!==void 0&&a.startsWith(ln))&&t!==null&&(o=s,s=i||"Image",i=r,r=t,t=null),N.isFunction(s)&&(o=s,s=void 0);const l={msgtype:ue.MsgType.Image,url:r,info:i,body:s};return this.sendMessage(e,t,l,void 0,o)}sendStickerMessage(e,t,r,i,s="Sticker",o){var a;!((a=t)!==null&&a!==void 0&&a.startsWith(ln))&&t!==null&&(o=s,s=i||"Sticker",i=r,r=t,t=null),N.isFunction(s)&&(o=s,s=void 0);const l={url:r,info:i,body:s};return this.sendEvent(e,t,ue.EventType.Sticker,l,void 0,o)}sendHtmlMessage(e,t,r,i,s){var o;!((o=t)!==null&&o!==void 0&&o.startsWith(ln))&&t!==null&&(s=i,i=r,r=t,t=null);const a=to.makeHtmlMessage(r,i);return this.sendMessage(e,t,a,void 0,s)}sendHtmlNotice(e,t,r,i,s){var o;!((o=t)!==null&&o!==void 0&&o.startsWith(ln))&&t!==null&&(s=i,i=r,r=t,t=null);const a=to.makeHtmlNotice(r,i);return this.sendMessage(e,t,a,void 0,s)}sendHtmlEmote(e,t,r,i,s){var o;!((o=t)!==null&&o!==void 0&&o.startsWith(ln))&&t!==null&&(s=i,i=r,r=t,t=null);const a=to.makeHtmlEmote(r,i);return this.sendMessage(e,t,a,void 0,s)}sendReceipt(e,t,r,i){if(typeof r=="function"&&(i=r,r={}),this.isGuest())return Promise.resolve({});const s=N.encodeUri("/rooms/$roomId/receipt/$receiptType/$eventId",{$roomId:e.getRoomId(),$receiptType:t,$eventId:e.getId()}),o=this.http.authedRequest(i,M.Method.Post,s,void 0,r||{}),a=this.getRoom(e.getRoomId());return a&&a.addLocalEchoReceipt(this.credentials.userId,e,t),o}async sendReadReceipt(e,t,r){typeof t=="function"&&(r=t,t={}),t||(t={});const i=e.getId(),s=this.getRoom(e.getRoomId());if(s&&s.hasPendingEvent(i))throw new Error(`Cannot set read receipt to a pending event (${i})`);const o={"org.matrix.msc2285.hidden":Boolean(t.hidden)};return this.sendReceipt(e,"m.read",o,r)}async setRoomReadMarkers(e,t,r,i){const s=this.getRoom(e);if(s&&s.hasPendingEvent(t))throw new Error(`Cannot set read marker to a pending event (${t})`);let o;if(r){if(o=r.getId(),s&&s.hasPendingEvent(o))throw new Error(`Cannot set read receipt to a pending event (${o})`);s&&s.addLocalEchoReceipt(this.credentials.userId,r,"m.read")}return this.setRoomReadMarkersHttpRequest(e,t,o,i)}getUrlPreview(e,t,r){t=Math.floor(t/6e4)*6e4;const i=new URL(e);i.hash="",e=i.toString();const s=t+"_"+e,o=this.urlPreviewCache[s];if(o)return r&&o.then(r).catch(r),o;const a=this.http.authedRequest(r,M.Method.Get,"/preview_url",{url:e,ts:t.toString()},void 0,{prefix:M.PREFIX_MEDIA_R0});return this.urlPreviewCache[s]=a,a}sendTyping(e,t,r,i){if(this.isGuest())return Promise.resolve({});const s=N.encodeUri("/rooms/$roomId/typing/$userId",{$roomId:e,$userId:this.credentials.userId}),o={typing:t};return t&&(o.timeout=r||2e4),this.http.authedRequest(i,M.Method.Put,s,void 0,o)}getRoomUpgradeHistory(e,t=!1){let r=this.getRoom(e);if(!r)return[];const i=[r];let s=r.currentState.getStateEvents(ue.EventType.RoomCreate,"");for(;s;){const a=s.getContent().predecessor;if(a&&a.room_id){const l=this.getRoom(a.room_id);if(!l)break;if(t){const u=l.currentState.getStateEvents(ue.EventType.RoomTombstone,"");if(!u||u.getContent().replacement_room!==l.roomId)break}i.splice(0,0,l),s=l.currentState.getStateEvents(ue.EventType.RoomCreate,"")}else break}let o=r.currentState.getStateEvents(ue.EventType.RoomTombstone,"");for(;o;){const a=this.getRoom(o.getContent().replacement_room);if(!a||a.roomId===r.roomId||t&&(s=a.currentState.getStateEvents(ue.EventType.RoomCreate,""),!s||!s.getContent().predecessor||s.getContent().predecessor.room_id!==r.roomId))break;if(i.push(a),new Set(i.map(u=>u.roomId)).size<i.length)return i.slice(0,i.length-1);r=a,o=r.currentState.getStateEvents(ue.EventType.RoomTombstone,"")}return i}invite(e,t,r,i){return this.membershipChange(e,t,"invite",i,r)}inviteByEmail(e,t,r){return this.inviteByThreePid(e,"email",t,r)}async inviteByThreePid(e,t,r,i){const s=N.encodeUri("/rooms/$roomId/invite",{$roomId:e}),o=this.getIdentityServerUrl(!0);if(!o)return Promise.reject(new M.MatrixError({error:"No supplied identity server URL",errcode:"ORG.MATRIX.JSSDK_MISSING_PARAM"}));const a={id_server:o,medium:t,address:r};if(this.identityServer&&this.identityServer.getAccessToken&&await this.doesServerAcceptIdentityAccessToken()){const l=await this.identityServer.getAccessToken();l&&(a.id_access_token=l)}return this.http.authedRequest(i,M.Method.Post,s,void 0,a)}leave(e,t){return this.membershipChange(e,void 0,"leave",void 0,t)}leaveRoomChain(e,t=!0){const r=this.getRoomUpgradeHistory(e);let i=r;if(!t){i=[];for(const l of r)if(i.push(l),l.roomId===e)break}const s={},o=[],a=l=>this.leave(l).then(()=>{s[l]=null}).catch(u=>(s[l]=u,null));for(const l of i)o.push(a(l.roomId));return Promise.all(o).then(()=>s)}ban(e,t,r,i){return this.membershipChange(e,t,"ban",r,i)}forget(e,t,r){t===void 0&&(t=!0);const i=this.membershipChange(e,void 0,"forget",void 0,r);return t?i.then(s=>(this.store.removeRoom(e),this.emit(cs.DeleteRoom,e),s)):i}unban(e,t,r){const i=N.encodeUri("/rooms/$roomId/unban",{$roomId:e}),s={user_id:t};return this.http.authedRequest(r,M.Method.Post,i,void 0,s)}kick(e,t,r,i){const s=N.encodeUri("/rooms/$roomId/kick",{$roomId:e}),o={user_id:t,reason:r};return this.http.authedRequest(i,M.Method.Post,s,void 0,o)}membershipChange(e,t,r,i,s){N.isFunction(i)&&(s=i,i=void 0);const o=N.encodeUri("/rooms/$room_id/$membership",{$room_id:e,$membership:r});return this.http.authedRequest(s,M.Method.Post,o,void 0,{user_id:t,reason:i})}getPushActionsForEvent(e,t=!1){return(!e.getPushActions()||t)&&e.setPushActions(this.pushProcessor.actionsForEvent(e)),e.getPushActions()}setProfileInfo(e,t,r){const i=N.encodeUri("/profile/$userId/$info",{$userId:this.credentials.userId,$info:e});return this.http.authedRequest(r,M.Method.Put,i,void 0,t)}async setDisplayName(e,t){const r=await this.setProfileInfo("displayname",{displayname:e},t),i=this.getUser(this.getUserId());return i&&(i.displayName=e,i.emit(bd.UserEvent.DisplayName,i.events.presence,i)),r}async setAvatarUrl(e,t){const r=await this.setProfileInfo("avatar_url",{avatar_url:e},t),i=this.getUser(this.getUserId());return i&&(i.avatarUrl=e,i.emit(bd.UserEvent.AvatarUrl,i.events.presence,i)),r}mxcUrlToHttp(e,t,r,i,s){return(0,wA.getHttpUriForMxc)(this.baseUrl,e,t,r,i,s)}_unstable_setStatusMessage(e){const t="im.vector.user_status";return Promise.all(this.getRooms().map(async r=>{const i=r.getMyMembership()==="join",s=r.getInvitedAndJoinedMemberCount()===2;!i||!s||!r.currentState.mayClientSendStateEvent(t,this)||await this.sendStateEvent(r.roomId,t,{status:e},this.getUserId())})).then()}setPresence(e,t){const r=N.encodeUri("/presence/$userId/status",{$userId:this.credentials.userId});if(typeof e=="string"&&(e={presence:e}),["offline","online","unavailable"].indexOf(e.presence)===-1)throw new Error("Bad presence value: "+e.presence);return this.http.authedRequest(t,M.Method.Put,r,void 0,e)}getPresence(e,t){const r=N.encodeUri("/presence/$userId/status",{$userId:e});return this.http.authedRequest(t,M.Method.Get,r,void 0,void 0)}scrollback(e,t=30,r){N.isFunction(t)&&(r=t,t=void 0);let i=0,s=this.ongoingScrollbacks[e.roomId]||{};if(s.promise)return s.promise;if(s.errorTs){const l=Date.now()-s.errorTs;i=Math.max(xA-l,0)}if(e.oldState.paginationToken===null)return Promise.resolve(e);const o=this.store.scrollback(e,t).length;if(o===t)return Promise.resolve(e);t=t-o;const a=new Promise((l,u)=>{(0,N.sleep)(i).then(()=>this.createMessagesRequest(e.roomId,e.oldState.paginationToken,t,ga.Direction.Backward)).then(async c=>{var g;const m=c.chunk.map(this.getEventMapper());if(c.state){const I=c.state.map(this.getEventMapper());e.currentState.setUnknownStateEvents(I)}const[f,E]=this.partitionThreadedEvents(m);e.addEventsToTimeline(f,!0,e.getLiveTimeline()),await this.processThreadEvents(e,E,!0),e.oldState.paginationToken=c.end,c.chunk.length===0&&(e.oldState.paginationToken=null),this.store.storeEvents(e,m,c.end,!0),this.ongoingScrollbacks[e.roomId]=null,(g=r)===null||g===void 0||g(null,e),l(e)}).catch(c=>{var g;this.ongoingScrollbacks[e.roomId]={errorTs:Date.now()},(g=r)===null||g===void 0||g(c),u(c)})});return s={promise:a,errorTs:null},this.ongoingScrollbacks[e.roomId]=s,a}getEventMapper(e){return(0,kA.eventMapperFor)(this,e||{})}getEventTimeline(e,t){if(!this.timelineSupport)throw new Error("timeline support is disabled. Set the 'timelineSupport' parameter to true when creating MatrixClient to enable it.");if(e.getTimelineForEvent(t))return Promise.resolve(e.getTimelineForEvent(t));const r=N.encodeUri("/rooms/$roomId/context/$eventId",{$roomId:e.room.roomId,$eventId:t});let i;return this.clientOpts.lazyLoadMembers&&(i={filter:JSON.stringify(qc.Filter.LAZY_LOADING_MESSAGES_FILTER)}),this.http.authedRequest(void 0,M.Method.Get,r,i).then(async o=>{if(!o.event)throw new Error("'event' not in '/context' result - homeserver too old?");if(e.getTimelineForEvent(t))return e.getTimelineForEvent(t);o.events_after.reverse();const l=o.events_after.concat([o.event]).concat(o.events_before).map(this.getEventMapper());let u=e.getTimelineForEvent(l[0].getId());if(!u)u=e.addTimeline(),u.initialiseState(o.state.map(this.getEventMapper())),u.getState(ga.EventTimeline.FORWARDS).paginationToken=o.end;else{const m=o.state.map(this.getEventMapper());u.getState(ga.EventTimeline.BACKWARDS).setUnknownStateEvents(m)}const[c,g]=this.partitionThreadedEvents(l);return e.addEventsToTimeline(c,!0,u,o.start),await this.processThreadEvents(e.room,g,!0),e.getTimelineForEvent(t)||u})}createMessagesRequest(e,t,r=30,i,s){const o=N.encodeUri("/rooms/$roomId/messages",{$roomId:e}),a={limit:r.toString(),dir:i};t&&(a.from=t);let l=null;if(this.clientOpts.lazyLoadMembers&&(l=Object.assign({},qc.Filter.LAZY_LOADING_MESSAGES_FILTER)),s){var u;l=l||{},Object.assign(l,(u=s.getRoomTimelineFilterComponent())===null||u===void 0?void 0:u.toJSON())}return l&&(a.filter=JSON.stringify(l)),this.http.authedRequest(void 0,M.Method.Get,o,a)}paginateEventTimeline(e,t){const r=e.getTimelineSet()===this.notifTimelineSet;t=t||{};const i=t.backwards||!1;if(r&&!i)throw new Error("paginateNotifTimeline can only paginate backwards");const s=i?ga.EventTimeline.BACKWARDS:ga.EventTimeline.FORWARDS,o=e.getPaginationToken(s),a=e.paginationRequests[s];if(a)return a;let l,u,c;if(r){var g;l="/notifications",u={limit:((g=t.limit)!==null&&g!==void 0?g:30).toString(),only:"highlight"},o!=="end"&&(u.from=o),c=this.http.authedRequest(void 0,M.Method.Get,l,u,void 0).then(async m=>{const f=m.next_token,E=[];for(let C=0;C<m.notifications.length;C++){const S=m.notifications[C],T=this.getEventMapper()(S.event);T.setPushActions(_d.PushProcessor.actionListToActionsObject(S.actions)),T.event.room_id=S.room_id,E[C]=T}const[I,w]=this.partitionThreadedEvents(E),k=e.getTimelineSet();return k.addEventsToTimeline(I,i,e,f),await this.processThreadEvents(k.room,w,i),i&&!m.next_token&&e.setPaginationToken(null,s),!!m.next_token}).finally(()=>{e.paginationRequests[s]=null}),e.paginationRequests[s]=c}else{const m=this.getRoom(e.getRoomId());if(!m)throw new Error("Unknown room "+e.getRoomId());c=this.createMessagesRequest(e.getRoomId(),o,t.limit,s,e.getFilter()).then(async f=>{if(f.state){const C=e.getState(s),S=f.state.map(this.getEventMapper());C.setUnknownStateEvents(S)}const E=f.end,I=f.chunk.map(this.getEventMapper()),[w,k]=this.partitionThreadedEvents(I);return e.getTimelineSet().addEventsToTimeline(w,i,e,E),await this.processThreadEvents(m,k,i),i&&f.end==f.start&&e.setPaginationToken(null,s),f.end!=f.start}).finally(()=>{e.paginationRequests[s]=null}),e.paginationRequests[s]=c}return c}resetNotifTimelineSet(){!this.notifTimelineSet||this.notifTimelineSet.resetLiveTimeline("end",null)}peekInRoom(e){return this.peekSync&&this.peekSync.stopPeeking(),this.peekSync=new Zs.SyncApi(this,this.clientOpts),this.peekSync.peek(e)}stopPeeking(){this.peekSync&&(this.peekSync.stopPeeking(),this.peekSync=null)}setGuestAccess(e,t){const r=this.sendStateEvent(e,ue.EventType.RoomGuestAccess,{guest_access:t.allowJoin?"can_join":"forbidden"},"");let i=Promise.resolve(void 0);return t.allowRead&&(i=this.sendStateEvent(e,ue.EventType.RoomHistoryVisibility,{history_visibility:"world_readable"},"")),Promise.all([i,r]).then()}requestRegisterEmailToken(e,t,r,i){return this.requestTokenFromEndpoint("/register/email/requestToken",{email:e,client_secret:t,send_attempt:r,next_link:i})}requestRegisterMsisdnToken(e,t,r,i,s){return this.requestTokenFromEndpoint("/register/msisdn/requestToken",{country:e,phone_number:t,client_secret:r,send_attempt:i,next_link:s})}requestAdd3pidEmailToken(e,t,r,i){return this.requestTokenFromEndpoint("/account/3pid/email/requestToken",{email:e,client_secret:t,send_attempt:r,next_link:i})}requestAdd3pidMsisdnToken(e,t,r,i,s){return this.requestTokenFromEndpoint("/account/3pid/msisdn/requestToken",{country:e,phone_number:t,client_secret:r,send_attempt:i,next_link:s})}requestPasswordEmailToken(e,t,r,i){return this.requestTokenFromEndpoint("/account/password/email/requestToken",{email:e,client_secret:t,send_attempt:r,next_link:i})}requestPasswordMsisdnToken(e,t,r,i,s){return this.requestTokenFromEndpoint("/account/password/msisdn/requestToken",{country:e,phone_number:t,client_secret:r,send_attempt:i,next_link:s})}async requestTokenFromEndpoint(e,t){const r=Object.assign({},t);if(!await this.doesServerSupportSeparateAddAndBind()&&this.idBaseUrl){const i=new URL(this.idBaseUrl);if(r.id_server=i.host,this.identityServer&&this.identityServer.getAccessToken&&await this.doesServerAcceptIdentityAccessToken()){const s=await this.identityServer.getAccessToken();s&&(r.id_access_token=s)}}return this.http.request(void 0,M.Method.Post,e,void 0,r)}getRoomPushRule(e,t){if(this.pushRules)for(let r=0;r<this.pushRules[e].room.length;r++){const i=this.pushRules[e].room[r];if(i.rule_id===t)return i}else throw new Error("SyncApi.sync() must be done before accessing to push rules.")}setRoomMutePushRule(e,t,r){let i,s;const o=this.getRoomPushRule(e,t);if(o&&0<=o.actions.indexOf("dont_notify")&&(s=!0),!r)s&&(i=this.deletePushRule(e,jc.PushRuleKind.RoomSpecific,o.rule_id));else if(!o)i=this.addPushRule(e,jc.PushRuleKind.RoomSpecific,t,{actions:["dont_notify"]});else if(!s){const a=N.defer();this.deletePushRule(e,jc.PushRuleKind.RoomSpecific,o.rule_id).then(()=>{this.addPushRule(e,jc.PushRuleKind.RoomSpecific,t,{actions:["dont_notify"]}).then(()=>{a.resolve()}).catch(l=>{a.reject(l)})}).catch(l=>{a.reject(l)}),i=a.promise}if(i)return new Promise((a,l)=>{i.then(()=>{this.getPushRules().then(u=>{this.pushRules=u,a()}).catch(u=>{l(u)})}).catch(u=>{this.getPushRules().then(c=>{this.pushRules=c,l(u)}).catch(c=>{l(u)})})})}searchMessageText(e,t){const r={search_term:e.query};return"keys"in e&&(r.keys=e.keys),this.search({body:{search_categories:{room_events:r}}},t)}searchRoomEvents(e){const t={search_categories:{room_events:{search_term:e.term,filter:e.filter,order_by:PA.SearchOrderBy.Recent,event_context:{before_limit:1,after_limit:1,include_profile:!0}}}},r={_query:t,results:[],highlights:[]};return this.search({body:t}).then(i=>this.processRoomEventsSearch(r,i))}backPaginateRoomEventsSearch(e){if(!e.next_batch)return Promise.reject(new Error("Cannot backpaginate event search any further"));if(e.pendingRequest)return e.pendingRequest;const t={body:e._query,next_batch:e.next_batch},r=this.search(t).then(i=>this.processRoomEventsSearch(e,i)).finally(()=>{e.pendingRequest=null});return e.pendingRequest=r,r}processRoomEventsSearch(e,t){const r=t.search_categories.room_events;e.count=r.count,e.next_batch=r.next_batch;const i=new Set(r.highlights);e.highlights.forEach(o=>{i.add(o)}),e.highlights=Array.from(i);const s=r.results?r.results.length:0;for(let o=0;o<s;o++){const a=RA.SearchResult.fromJson(r.results[o],this.getEventMapper()),l=this.getRoom(a.context.getEvent().getRoomId());if(l)for(const u of a.context.getTimeline()){const c=l.getMember(u.getSender());!u.sender&&c&&(u.sender=c)}e.results.push(a)}return e}syncLeftRooms(){if(this.syncedLeftRooms)return Promise.resolve([]);if(this.syncLeftRoomsPromise)return this.syncLeftRoomsPromise;const e=new Zs.SyncApi(this,this.clientOpts);return this.syncLeftRoomsPromise=e.syncLeftRooms(),this.syncLeftRoomsPromise.then(t=>{oe.logger.log("Marking success of sync left room request"),this.syncedLeftRooms=!0}).finally(()=>{this.syncLeftRoomsPromise=null}),this.syncLeftRoomsPromise}createFilter(e){const t=N.encodeUri("/user/$userId/filter",{$userId:this.credentials.userId});return this.http.authedRequest(void 0,M.Method.Post,t,void 0,e).then(r=>{const i=qc.Filter.fromJson(this.credentials.userId,r.filter_id,e);return this.store.storeFilter(i),i})}getFilter(e,t,r){if(r){const s=this.store.getFilter(e,t);if(s)return Promise.resolve(s)}const i=N.encodeUri("/user/$userId/filter/$filterId",{$userId:e,$filterId:t});return this.http.authedRequest(void 0,M.Method.Get,i,void 0,void 0).then(s=>{const o=qc.Filter.fromJson(e,t,s);return this.store.storeFilter(o),o})}async getOrCreateFilter(e,t){const r=this.store.getFilterIdByName(e);let i;if(r){try{const o=await this.getFilter(this.credentials.userId,r,!0);if(o){const a=o.getDefinition(),l=t.getDefinition();N.deepCompare(a,l)&&(i=r)}}catch(o){if(o.errcode!=="M_UNKNOWN"&&o.errcode!=="M_NOT_FOUND")throw o}i||this.store.setFilterIdByName(e,void 0)}if(i)return i;const s=await this.createFilter(t.getDefinition());return this.store.setFilterIdByName(e,s.filterId),s.filterId}getOpenIdToken(){const e=N.encodeUri("/user/$userId/openid/request_token",{$userId:this.credentials.userId});return this.http.authedRequest(void 0,M.Method.Post,e,void 0,{})}turnServer(e){return this.http.authedRequest(e,M.Method.Get,"/voip/turnServer")}getTurnServers(){return this.turnServers||[]}getTurnServersExpiry(){return this.turnServersExpiry}async checkTurnServers(){if(!this.canSupportVoip)return;let e=!1;const t=this.turnServersExpiry-Date.now();if(t>Pm)oe.logger.debug("TURN creds are valid for another "+t+" ms: not fetching new ones."),e=!0;else{oe.logger.debug("Fetching new TURN credentials");try{const r=await this.turnServer();if(r.uris){oe.logger.log("Got TURN URIs: "+r.uris+" refresh in "+r.ttl+" secs");const i={urls:r.uris,username:r.username,credential:r.password};this.turnServers=[i],this.turnServersExpiry=Date.now()+r.ttl*1e3,e=!0}}catch(r){oe.logger.error("Failed to get TURN URIs",r),r.httpStatus===403&&(oe.logger.info("TURN access unavailable for this account: stopping credentials checks"),this.checkTurnServersIntervalID!==null&&V.clearInterval(this.checkTurnServersIntervalID),this.checkTurnServersIntervalID=null)}}return e}setFallbackICEServerAllowed(e){this.fallbackICEServerAllowed=e}isFallbackICEServerAllowed(){return this.fallbackICEServerAllowed}isSynapseAdministrator(){const e=N.encodeUri("/_synapse/admin/v1/users/$userId/admin",{$userId:this.getUserId()});return this.http.authedRequest(void 0,M.Method.Get,e,void 0,void 0,{prefix:""}).then(t=>t.admin)}whoisSynapseUser(e){const t=N.encodeUri("/_synapse/admin/v1/whois/$userId",{$userId:e});return this.http.authedRequest(void 0,M.Method.Get,t,void 0,void 0,{prefix:""})}deactivateSynapseUser(e){const t=N.encodeUri("/_synapse/admin/v1/deactivate/$userId",{$userId:e});return this.http.authedRequest(void 0,M.Method.Post,t,void 0,void 0,{prefix:""})}async fetchClientWellKnown(){this.clientWellKnownPromise=EA.AutoDiscovery.getRawClientConfig(this.getDomain()),this.clientWellKnown=await this.clientWellKnownPromise,this.emit(cs.ClientWellKnown,this.clientWellKnown)}getClientWellKnown(){return this.clientWellKnown}waitForClientWellKnown(){return this.clientWellKnownPromise}storeClientOptions(){const e=["boolean","string","number"],t=Object.entries(this.clientOpts).filter(([r,i])=>e.includes(typeof i)).reduce((r,[i,s])=>(r[i]=s,r),{});return this.store.storeClientOptions(t)}async _unstable_getSharedRooms(e){if(!await this.doesServerSupportUnstableFeature("uk.half-shot.msc2666"))throw Error("Server does not support shared_rooms API");const t=N.encodeUri("/uk.half-shot.msc2666/user/shared_rooms/$userId",{$userId:e});return(await this.http.authedRequest(void 0,M.Method.Get,t,void 0,void 0,{prefix:M.PREFIX_UNSTABLE})).joined}getVersions(){return this.serverVersionsPromise?this.serverVersionsPromise:(this.serverVersionsPromise=this.http.request(void 0,M.Method.Get,"/_matrix/client/versions",void 0,void 0,{prefix:""}).catch(e=>{throw this.serverVersionsPromise=null,e}),this.serverVersionsPromise)}async isVersionSupported(e){const{versions:t}=await this.getVersions();return t&&t.includes(e)}async doesServerSupportLazyLoading(){const e=await this.getVersions();if(!e)return!1;const t=e.versions,r=e.unstable_features;return t&&t.includes("r0.5.0")||r&&r["m.lazy_load_members"]}async doesServerRequireIdServerParam(){const e=await this.getVersions();if(!e)return!0;const t=e.versions;if(t&&t.includes("r0.6.0"))return!1;const r=e.unstable_features;return!r||r["m.require_identity_server"]===void 0?!0:r["m.require_identity_server"]}async doesServerAcceptIdentityAccessToken(){const e=await this.getVersions();if(!e)return!1;const t=e.versions,r=e.unstable_features;return t&&t.includes("r0.6.0")||r&&r["m.id_access_token"]}async doesServerSupportSeparateAddAndBind(){const e=await this.getVersions();if(!e)return!1;const t=e.versions,r=e.unstable_features;return t&&t.includes("r0.6.0")||r&&r["m.separate_add_and_bind"]}async doesServerSupportUnstableFeature(e){const t=await this.getVersions();if(!t)return!1;const r=t.unstable_features;return r&&!!r[e]}async doesServerForceEncryptionForPreset(e){const t=await this.getVersions();if(!t)return!1;const r=t.unstable_features,i=e.includes("_chat")?e.substring(0,e.indexOf("_chat")):e;return r&&!!r[`io.element.e2ee_forced.${i}`]}async doesServerSupportThread(){try{const e=await this.doesServerSupportUnstableFeature("org.matrix.msc3440"),t=await this.doesServerSupportUnstableFeature("org.matrix.msc3440.stable")||await this.isVersionSupported("v1.3");return{serverSupport:e||t,stable:t}}catch{return null}}hasLazyLoadMembersEnabled(){return!!this.clientOpts.lazyLoadMembers}setCanResetTimelineCallback(e){this.canResetTimelineCallback=e}getCanResetTimelineCallback(){return this.canResetTimelineCallback}async relations(e,t,r,i,s={}){const o=this.getEncryptedIfNeededEventType(e,i),a=await this.fetchRelations(e,t,r,o,s),l=this.getEventMapper();let u;a.original_event&&(u=l(a.original_event));let c=a.chunk.map(l);if(o===ue.EventType.RoomMessageEncrypted){const g=u?c.concat(u):c;await Promise.all(g.map(m=>this.decryptEventIfNeeded(m))),i!==null&&(c=c.filter(m=>m.getType()===i))}return u&&r===ue.RelationType.Replace&&(c=c.filter(g=>g.getSender()===u.getSender())),{originalEvent:u,events:c,nextBatch:a.next_batch,prevBatch:a.prev_batch}}getCrossSigningCacheCallbacks(){var e;return(e=this.crypto)===null||e===void 0?void 0:e.crossSigningInfo.getCacheCallbacks()}generateClientSecret(){return(0,CA.randomString)(32)}decryptEventIfNeeded(e,t){return e.shouldAttemptDecryption()&&e.attemptDecryption(this.crypto,t),e.isBeingDecrypted()?e.getDecryptionPromise():Promise.resolve()}termsUrlForService(e,t){switch(e){case Tm.SERVICE_TYPES.IS:return t+M.PREFIX_IDENTITY_V2+"/terms";case Tm.SERVICE_TYPES.IM:return t+"/_matrix/integrations/v1/terms";default:throw new Error("Unsupported service type")}}getHomeserverUrl(){return this.baseUrl}getIdentityServerUrl(e=!1){return e&&(this.idBaseUrl.startsWith("http://")||this.idBaseUrl.startsWith("https://"))?this.idBaseUrl.split("://")[1]:this.idBaseUrl}setIdentityServerUrl(e){this.idBaseUrl=N.ensureNoTrailingSlash(e),this.http.setIdBaseUrl(this.idBaseUrl)}getAccessToken(){return this.http.opts.accessToken||null}setAccessToken(e){this.http.opts.accessToken=e}isLoggedIn(){return this.http.opts.accessToken!==void 0}makeTxnId(){return"m"+new Date().getTime()+"."+this.txnCtr++}isUsernameAvailable(e){return this.http.authedRequest(void 0,M.Method.Get,"/register/available",{username:e}).then(t=>t.available).catch(t=>t.errcode==="M_USER_IN_USE"?!1:Promise.reject(t))}register(e,t,r,i,s,o,a,l){s===!0?s={email:!0}:(s==null||s===!1)&&(s={}),typeof a=="function"&&(l=a,a=void 0),r&&(i.session=r);const u={auth:i,refresh_token:!0};return e!=null&&(u.username=e),t!=null&&(u.password=t),s.email&&(u.bind_email=!0),s.msisdn&&(u.bind_msisdn=!0),o!=null&&(u.guest_access_token=o),a!=null&&(u.inhibit_login=a),t!=null&&(u.x_show_msisdn=!0),this.registerRequest(u,void 0,l)}registerGuest(e,t){return e=e||{},e.body=e.body||{},this.registerRequest(e.body,"guest",t)}registerRequest(e,t,r){const i={};return t&&(i.kind=t),this.http.request(r,M.Method.Post,"/register",i,e)}refreshToken(e){return this.http.authedRequest(void 0,M.Method.Post,"/refresh",void 0,{refresh_token:e},{prefix:M.PREFIX_V1,inhibitLogoutEmit:!0})}loginFlows(e){return this.http.request(e,M.Method.Get,"/login")}login(e,t,r){const i={type:e};return Object.assign(i,t),this.http.authedRequest((s,o)=>{o&&o.access_token&&o.user_id&&(this.http.opts.accessToken=o.access_token,this.credentials={userId:o.user_id}),r&&r(s,o)},M.Method.Post,"/login",void 0,i)}loginWithPassword(e,t,r){return this.login("m.login.password",{user:e,password:t},r)}loginWithSAML2(e,t){return this.login("m.login.saml2",{relay_state:e},t)}getCasLoginUrl(e){return this.getSsoLoginUrl(e,"cas")}getSsoLoginUrl(e,t="sso",r){let i="/login/"+t+"/redirect";return r&&(i+="/"+r),this.http.getUrl(i,{redirectUrl:e},M.PREFIX_R0)}loginWithToken(e,t){return this.login("m.login.token",{token:e},t)}async logout(e){var t,r;if((t=this.crypto)!==null&&t!==void 0&&(r=t.backupManager)!==null&&r!==void 0&&r.getKeyBackupEnabled())try{for(;await this.crypto.backupManager.backupPendingKeys(200)>0;);}catch(i){oe.logger.error("Key backup request failed when logging out. Some keys may be missing from backup",i)}return this.http.authedRequest(e,M.Method.Post,"/logout")}deactivateAccount(e,t){if(typeof t=="function")throw new Error("deactivateAccount no longer accepts a callback parameter");const r={};return e&&(r.auth=e),t!==void 0&&(r.erase=t),this.http.authedRequest(void 0,M.Method.Post,"/account/deactivate",void 0,r)}getFallbackAuthUrl(e,t){const r=N.encodeUri("/auth/$loginType/fallback/web",{$loginType:e});return this.http.getUrl(r,{session:t},M.PREFIX_R0)}async createRoom(e,t){const r=(e.invite_3pid||[]).filter(i=>!i.id_access_token);if(r.length>0&&this.identityServer&&this.identityServer.getAccessToken&&await this.doesServerAcceptIdentityAccessToken()){const i=await this.identityServer.getAccessToken();if(i)for(const s of r)s.id_access_token=i}return this.http.authedRequest(t,M.Method.Post,"/createRoom",void 0,e)}async fetchRelations(e,t,r,i,s={}){const o=N.encodeParams(s);let a="/rooms/$roomId/relations/$eventId";r!==null?(a+="/$relationType",i!==null&&(a+="/$eventType")):i!==null&&(oe.logger.warn(`eventType: ${i} ignored when fetching
+ relations as relationType is null`),i=null);const l=N.encodeUri(a+"?"+o,{$roomId:e,$eventId:t,$relationType:r,$eventType:i});return await this.http.authedRequest(void 0,M.Method.Get,l,null,null,{prefix:M.PREFIX_UNSTABLE})}roomState(e,t){const r=N.encodeUri("/rooms/$roomId/state",{$roomId:e});return this.http.authedRequest(t,M.Method.Get,r)}fetchRoomEvent(e,t,r){const i=N.encodeUri("/rooms/$roomId/event/$eventId",{$roomId:e,$eventId:t});return this.http.authedRequest(r,M.Method.Get,i)}members(e,t,r,i,s){const o={};t&&(o.membership=t),r&&(o.not_membership=r),i&&(o.at=i);const a=N.encodeParams(o),l=N.encodeUri("/rooms/$roomId/members?"+a,{$roomId:e});return this.http.authedRequest(s,M.Method.Get,l)}upgradeRoom(e,t){const r=N.encodeUri("/rooms/$roomId/upgrade",{$roomId:e});return this.http.authedRequest(void 0,M.Method.Post,r,void 0,{new_version:t})}getStateEvent(e,t,r,i){const s={$roomId:e,$eventType:t,$stateKey:r};let o=N.encodeUri("/rooms/$roomId/state/$eventType",s);return r!==void 0&&(o=N.encodeUri(o+"/$stateKey",s)),this.http.authedRequest(i,M.Method.Get,o)}sendStateEvent(e,t,r,i="",s){const o={$roomId:e,$eventType:t,$stateKey:i};let a=N.encodeUri("/rooms/$roomId/state/$eventType",o);return i!==void 0&&(a=N.encodeUri(a+"/$stateKey",o)),this.http.authedRequest(s,M.Method.Put,a,void 0,r)}roomInitialSync(e,t,r){var i,s;N.isFunction(t)&&(r=t,t=void 0);const o=N.encodeUri("/rooms/$roomId/initialSync",{$roomId:e});return this.http.authedRequest(r,M.Method.Get,o,{limit:(i=(s=t)===null||s===void 0?void 0:s.toString())!==null&&i!==void 0?i:"30"})}setRoomReadMarkersHttpRequest(e,t,r,i){const s=N.encodeUri("/rooms/$roomId/read_markers",{$roomId:e}),o={"m.fully_read":t,"m.read":r,"org.matrix.msc2285.hidden":Boolean(i?i.hidden:!1)};return this.http.authedRequest(void 0,M.Method.Post,s,void 0,o)}getJoinedRooms(){const e=N.encodeUri("/joined_rooms",{});return this.http.authedRequest(void 0,M.Method.Get,e)}getJoinedRoomMembers(e){const t=N.encodeUri("/rooms/$roomId/joined_members",{$roomId:e});return this.http.authedRequest(void 0,M.Method.Get,t)}publicRooms(e,t){typeof e=="function"&&(t=e,e={}),e===void 0&&(e={});const r={};return e.server&&(r.server=e.server,delete e.server),Object.keys(e).length===0&&Object.keys(r).length===0?this.http.authedRequest(t,M.Method.Get,"/publicRooms"):this.http.authedRequest(t,M.Method.Post,"/publicRooms",r,e)}createAlias(e,t,r){const i=N.encodeUri("/directory/room/$alias",{$alias:e}),s={room_id:t};return this.http.authedRequest(r,M.Method.Put,i,void 0,s)}deleteAlias(e,t){const r=N.encodeUri("/directory/room/$alias",{$alias:e});return this.http.authedRequest(t,M.Method.Delete,r,void 0,void 0)}unstableGetLocalAliases(e,t){const r=N.encodeUri("/rooms/$roomId/aliases",{$roomId:e}),i=M.PREFIX_UNSTABLE+"/org.matrix.msc2432";return this.http.authedRequest(t,M.Method.Get,r,null,null,{prefix:i})}getRoomIdForAlias(e,t){const r=N.encodeUri("/directory/room/$alias",{$alias:e});return this.http.authedRequest(t,M.Method.Get,r)}resolveRoomAlias(e,t){const r=N.encodeUri("/directory/room/$alias",{$alias:e});return this.http.request(t,M.Method.Get,r)}getRoomDirectoryVisibility(e,t){const r=N.encodeUri("/directory/list/room/$roomId",{$roomId:e});return this.http.authedRequest(t,M.Method.Get,r)}setRoomDirectoryVisibility(e,t,r){const i=N.encodeUri("/directory/list/room/$roomId",{$roomId:e});return this.http.authedRequest(r,M.Method.Put,i,void 0,{visibility:t})}setRoomDirectoryVisibilityAppService(e,t,r,i){const s=N.encodeUri("/directory/list/appservice/$networkId/$roomId",{$networkId:e,$roomId:t});return this.http.authedRequest(i,M.Method.Put,s,void 0,{visibility:r})}searchUserDirectory(e){const t={search_term:e.term};return e.limit!==void 0&&(t.limit=e.limit),this.http.authedRequest(void 0,M.Method.Post,"/user_directory/search",void 0,t)}uploadContent(e,t){return this.http.uploadContent(e,t)}cancelUpload(e){return this.http.cancelUpload(e)}getCurrentUploads(){return this.http.getCurrentUploads()}getProfileInfo(e,t,r){N.isFunction(t)&&(r=t,t=void 0);const i=t?N.encodeUri("/profile/$userId/$info",{$userId:e,$info:t}):N.encodeUri("/profile/$userId",{$userId:e});return this.http.authedRequest(r,M.Method.Get,i)}getThreePids(e){const t="/account/3pid";return this.http.authedRequest(e,M.Method.Get,t,void 0,void 0)}addThreePid(e,t,r){const i="/account/3pid",s={threePidCreds:e,bind:t};return this.http.authedRequest(r,M.Method.Post,i,null,s)}async addThreePidOnly(e){const t="/account/3pid/add",r=await this.isVersionSupported("r0.6.0")?M.PREFIX_R0:M.PREFIX_UNSTABLE;return this.http.authedRequest(void 0,M.Method.Post,t,null,e,{prefix:r})}async bindThreePid(e){const t="/account/3pid/bind",r=await this.isVersionSupported("r0.6.0")?M.PREFIX_R0:M.PREFIX_UNSTABLE;return this.http.authedRequest(void 0,M.Method.Post,t,null,e,{prefix:r})}async unbindThreePid(e,t){const r="/account/3pid/unbind",i={medium:e,address:t,id_server:this.getIdentityServerUrl(!0)},s=await this.isVersionSupported("r0.6.0")?M.PREFIX_R0:M.PREFIX_UNSTABLE;return this.http.authedRequest(void 0,M.Method.Post,r,null,i,{prefix:s})}deleteThreePid(e,t){const r="/account/3pid/delete";return this.http.authedRequest(void 0,M.Method.Post,r,null,{medium:e,address:t})}setPassword(e,t,r){const i="/account/password",s={auth:e,new_password:t};return this.http.authedRequest(r,M.Method.Post,i,null,s)}getDevices(){return this.http.authedRequest(void 0,M.Method.Get,"/devices",void 0,void 0)}getDevice(e){const t=N.encodeUri("/devices/$device_id",{$device_id:e});return this.http.authedRequest(void 0,M.Method.Get,t,void 0,void 0)}setDeviceDetails(e,t){const r=N.encodeUri("/devices/$device_id",{$device_id:e});return this.http.authedRequest(void 0,M.Method.Put,r,void 0,t)}deleteDevice(e,t){const r=N.encodeUri("/devices/$device_id",{$device_id:e}),i={};return t&&(i.auth=t),this.http.authedRequest(void 0,M.Method.Delete,r,void 0,i)}deleteMultipleDevices(e,t){const r={devices:e};t&&(r.auth=t);const i="/delete_devices";return this.http.authedRequest(void 0,M.Method.Post,i,void 0,r)}getPushers(e){const t="/pushers";return this.http.authedRequest(e,M.Method.Get,t,void 0,void 0)}setPusher(e,t){const r="/pushers/set";return this.http.authedRequest(t,M.Method.Post,r,null,e)}getPushRules(e){return this.http.authedRequest(e,M.Method.Get,"/pushrules/").then(t=>_d.PushProcessor.rewriteDefaultRules(t))}addPushRule(e,t,r,i,s){const o=N.encodeUri("/pushrules/"+e+"/$kind/$ruleId",{$kind:t,$ruleId:r});return this.http.authedRequest(s,M.Method.Put,o,void 0,i)}deletePushRule(e,t,r,i){const s=N.encodeUri("/pushrules/"+e+"/$kind/$ruleId",{$kind:t,$ruleId:r});return this.http.authedRequest(i,M.Method.Delete,s)}setPushRuleEnabled(e,t,r,i,s){const o=N.encodeUri("/pushrules/"+e+"/$kind/$ruleId/enabled",{$kind:t,$ruleId:r});return this.http.authedRequest(s,M.Method.Put,o,void 0,{enabled:i})}setPushRuleActions(e,t,r,i,s){const o=N.encodeUri("/pushrules/"+e+"/$kind/$ruleId/actions",{$kind:t,$ruleId:r});return this.http.authedRequest(s,M.Method.Put,o,void 0,{actions:i})}search(e,t){const r={};return e.next_batch&&(r.next_batch=e.next_batch),this.http.authedRequest(t,M.Method.Post,"/search",r,e.body)}uploadKeysRequest(e,t,r){return this.http.authedRequest(r,M.Method.Post,"/keys/upload",void 0,e)}uploadKeySignatures(e){return this.http.authedRequest(void 0,M.Method.Post,"/keys/signatures/upload",void 0,e,{prefix:M.PREFIX_UNSTABLE})}downloadKeysForUsers(e,t){if(N.isFunction(t))throw new Error("downloadKeysForUsers no longer accepts a callback parameter");t=t||{};const r={device_keys:{}};return"token"in t&&(r.token=t.token),e.forEach(i=>{r.device_keys[i]=[]}),this.http.authedRequest(void 0,M.Method.Post,"/keys/query",void 0,r)}claimOneTimeKeys(e,t="signed_curve25519",r){const i={};t===void 0&&(t="signed_curve25519");for(let a=0;a<e.length;++a){const l=e[a][0],u=e[a][1],c=i[l]||{};i[l]=c,c[u]=t}const s={one_time_keys:i};r&&(s.timeout=r);const o="/keys/claim";return this.http.authedRequest(void 0,M.Method.Post,o,void 0,s)}getKeyChanges(e,t){const r={from:e,to:t},i="/keys/changes";return this.http.authedRequest(void 0,M.Method.Get,i,r,void 0)}uploadDeviceSigningKeys(e,t){const r=Object.assign({},t);return e&&Object.assign(r,{auth:e}),this.http.authedRequest(void 0,M.Method.Post,"/keys/device_signing/upload",void 0,r,{prefix:M.PREFIX_UNSTABLE})}registerWithIdentityServer(e){if(!this.idBaseUrl)throw new Error("No identity server base URL set");const t=this.idBaseUrl+M.PREFIX_IDENTITY_V2+"/account/register";return this.http.requestOtherUrl(void 0,M.Method.Post,t,null,e)}async requestEmailToken(e,t,r,i,s,o){const a={client_secret:t,email:e,send_attempt:r==null?void 0:r.toString(),next_link:i};return await this.http.idServerRequest(s,M.Method.Post,"/validate/email/requestToken",a,M.PREFIX_IDENTITY_V2,o)}async requestMsisdnToken(e,t,r,i,s,o,a){const l={client_secret:r,country:e,phone_number:t,send_attempt:i==null?void 0:i.toString(),next_link:s};return await this.http.idServerRequest(o,M.Method.Post,"/validate/msisdn/requestToken",l,M.PREFIX_IDENTITY_V2,a)}async submitMsisdnToken(e,t,r,i){const s={sid:e,client_secret:t,token:r};return await this.http.idServerRequest(void 0,M.Method.Post,"/validate/msisdn/submitToken",s,M.PREFIX_IDENTITY_V2,i)}submitMsisdnTokenOtherUrl(e,t,r,i){const s={sid:t,client_secret:r,token:i};return this.http.requestOtherUrl(void 0,M.Method.Post,e,void 0,s)}getIdentityHashDetails(e){return this.http.idServerRequest(void 0,M.Method.Get,"/hash_details",null,M.PREFIX_IDENTITY_V2,e)}async identityHashedLookup(e,t){const r={},i=await this.getIdentityHashDetails(t);if(!i||!i.lookup_pepper||!i.algorithms)throw new Error("Unsupported identity server: bad response");r.pepper=i.lookup_pepper;const s={};if(i.algorithms.includes("sha256")){const l=new V.Olm.Utility;r.addresses=e.map(u=>{const c=u[0].toLowerCase(),g=u[1].toLowerCase(),m=l.sha256(`${c} ${g} ${r.pepper}`).replace(/\+/g,"-").replace(/\//g,"_");return s[m]=u[0],m}),r.algorithm="sha256"}else if(i.algorithms.includes("none"))r.addresses=e.map(l=>{const u=l[0].toLowerCase(),c=l[1].toLowerCase(),g=`${u} ${c}`;return s[g]=l[0],g}),r.algorithm="none";else throw new Error("Unsupported identity server: unknown hash algorithm");const o=await this.http.idServerRequest(void 0,M.Method.Post,"/lookup",r,M.PREFIX_IDENTITY_V2,t);if(!o||!o.mappings)return[];const a=[];for(const l of Object.keys(o.mappings)){const u=o.mappings[l],c=s[l];if(!c)throw new Error("Identity server returned more results than expected");a.push({address:c,mxid:u})}return a}async lookupThreePid(e,t,r,i){const o=(await this.identityHashedLookup([[t,e]],i)).find(l=>l.address===t);if(!o)return r&&r(null,{}),{};const a={address:t,medium:e,mxid:o.mxid};return r&&r(null,a),a}async bulkLookupThreePids(e,t){const r=await this.identityHashedLookup(e.map(s=>[s[1],s[0]]),t),i=[];for(const s of r){const o=e.find(a=>a[1]===s.address);if(!o)throw new Error("Identity sever returned unexpected results");i.push([o[0],s.address,s.mxid])}return{threepids:i}}getIdentityAccount(e){return this.http.idServerRequest(void 0,M.Method.Get,"/account",void 0,M.PREFIX_IDENTITY_V2,e)}sendToDevice(e,t,r){const i=N.encodeUri("/sendToDevice/$eventType/$txnId",{$eventType:e,$txnId:r||this.makeTxnId()}),s={messages:t},o=Object.keys(t).reduce((a,l)=>(a[l]=Object.keys(t[l]),a),{});return oe.logger.log(`PUT ${i}`,o),this.http.authedRequest(void 0,M.Method.Put,i,void 0,s)}getThirdpartyProtocols(){return this.http.authedRequest(void 0,M.Method.Get,"/thirdparty/protocols",void 0,void 0).then(e=>{if(!e||typeof e!="object")throw new Error(`/thirdparty/protocols did not return an object: ${e}`);return e})}getThirdpartyLocation(e,t){const r=N.encodeUri("/thirdparty/location/$protocol",{$protocol:e});return this.http.authedRequest(void 0,M.Method.Get,r,t,void 0)}getThirdpartyUser(e,t){const r=N.encodeUri("/thirdparty/user/$protocol",{$protocol:e});return this.http.authedRequest(void 0,M.Method.Get,r,t,void 0)}getTerms(e,t){const r=this.termsUrlForService(e,t);return this.http.requestOtherUrl(void 0,M.Method.Get,r)}agreeToTerms(e,t,r,i){const s=this.termsUrlForService(e,t),o={Authorization:"Bearer "+r};return this.http.requestOtherUrl(void 0,M.Method.Post,s,null,{user_accepts:i},{headers:o})}reportEvent(e,t,r,i){const s=N.encodeUri("/rooms/$roomId/report/$eventId",{$roomId:e,$eventId:t});return this.http.authedRequest(void 0,M.Method.Post,s,null,{score:r,reason:i})}getRoomHierarchy(e,t,r,i=!1,s){const o=N.encodeUri("/rooms/$roomId/hierarchy",{$roomId:e}),a={suggested_only:String(i),max_depth:r==null?void 0:r.toString(),from:s,limit:t==null?void 0:t.toString()};return this.http.authedRequest(void 0,M.Method.Get,o,a,void 0,{prefix:M.PREFIX_V1}).catch(l=>{if(l.errcode==="M_UNRECOGNIZED")return this.http.authedRequest(void 0,M.Method.Get,o,a,void 0,{prefix:"/_matrix/client/unstable/org.matrix.msc2946"});throw l})}async unstableCreateFileTree(e){const{room_id:t}=await this.createRoom({name:e,preset:OA.Preset.PrivateChat,power_level_content_override:Gc(Gc({},wd.DEFAULT_TREE_POWER_LEVELS_TEMPLATE),{},{users:{[this.getUserId()]:100}}),creation_content:{[ue.RoomCreateTypeField]:ue.RoomType.Space},initial_state:[{type:ue.UNSTABLE_MSC3088_PURPOSE.name,state_key:ue.UNSTABLE_MSC3089_TREE_SUBTYPE.name,content:{[ue.UNSTABLE_MSC3088_ENABLED.name]:!0}},{type:ue.EventType.RoomEncryption,state_key:"",content:{algorithm:Ed.MEGOLM_ALGORITHM}}]});return new wd.MSC3089TreeSpace(this,t)}unstableGetFileTreeSpace(e){var t,r;const i=this.getRoom(e);if((i==null?void 0:i.getMyMembership())!=="join")return null;const s=i.currentState.getStateEvents(ue.EventType.RoomCreate,""),o=i.currentState.getStateEvents(ue.UNSTABLE_MSC3088_PURPOSE.name,ue.UNSTABLE_MSC3089_TREE_SUBTYPE.name);if(!s)throw new Error("Expected single room create event");return!(o!=null&&(t=o.getContent())!==null&&t!==void 0&&t[ue.UNSTABLE_MSC3088_ENABLED.name])||((r=s.getContent())===null||r===void 0?void 0:r[ue.RoomCreateTypeField])!==ue.RoomType.Space?null:new wd.MSC3089TreeSpace(this,e)}getGroupSummary(e){const t=N.encodeUri("/groups/$groupId/summary",{$groupId:e});return this.http.authedRequest(void 0,M.Method.Get,t)}getGroupProfile(e){const t=N.encodeUri("/groups/$groupId/profile",{$groupId:e});return this.http.authedRequest(void 0,M.Method.Get,t)}setGroupProfile(e,t){const r=N.encodeUri("/groups/$groupId/profile",{$groupId:e});return this.http.authedRequest(void 0,M.Method.Post,r,void 0,t)}setGroupJoinPolicy(e,t){const r=N.encodeUri("/groups/$groupId/settings/m.join_policy",{$groupId:e});return this.http.authedRequest(void 0,M.Method.Put,r,void 0,{"m.join_policy":t})}getGroupUsers(e){const t=N.encodeUri("/groups/$groupId/users",{$groupId:e});return this.http.authedRequest(void 0,M.Method.Get,t)}getGroupInvitedUsers(e){const t=N.encodeUri("/groups/$groupId/invited_users",{$groupId:e});return this.http.authedRequest(void 0,M.Method.Get,t)}getGroupRooms(e){const t=N.encodeUri("/groups/$groupId/rooms",{$groupId:e});return this.http.authedRequest(void 0,M.Method.Get,t)}inviteUserToGroup(e,t){const r=N.encodeUri("/groups/$groupId/admin/users/invite/$userId",{$groupId:e,$userId:t});return this.http.authedRequest(void 0,M.Method.Put,r,void 0,{})}removeUserFromGroup(e,t){const r=N.encodeUri("/groups/$groupId/admin/users/remove/$userId",{$groupId:e,$userId:t});return this.http.authedRequest(void 0,M.Method.Put,r,void 0,{})}addUserToGroupSummary(e,t,r){const i=N.encodeUri(r?"/groups/$groupId/summary/$roleId/users/$userId":"/groups/$groupId/summary/users/$userId",{$groupId:e,$roleId:r,$userId:t});return this.http.authedRequest(void 0,M.Method.Put,i,void 0,{})}removeUserFromGroupSummary(e,t){const r=N.encodeUri("/groups/$groupId/summary/users/$userId",{$groupId:e,$userId:t});return this.http.authedRequest(void 0,M.Method.Delete,r,void 0,{})}addRoomToGroupSummary(e,t,r){const i=N.encodeUri(r?"/groups/$groupId/summary/$categoryId/rooms/$roomId":"/groups/$groupId/summary/rooms/$roomId",{$groupId:e,$categoryId:r,$roomId:t});return this.http.authedRequest(void 0,M.Method.Put,i,void 0,{})}removeRoomFromGroupSummary(e,t){const r=N.encodeUri("/groups/$groupId/summary/rooms/$roomId",{$groupId:e,$roomId:t});return this.http.authedRequest(void 0,M.Method.Delete,r,void 0,{})}addRoomToGroup(e,t,r){r===void 0&&(r=!0);const i=N.encodeUri("/groups/$groupId/admin/rooms/$roomId",{$groupId:e,$roomId:t});return this.http.authedRequest(void 0,M.Method.Put,i,void 0,{"m.visibility":{type:r?"public":"private"}})}updateGroupRoomVisibility(e,t,r){const i=N.encodeUri("/groups/$groupId/admin/rooms/$roomId/config/m.visibility",{$groupId:e,$roomId:t});return this.http.authedRequest(void 0,M.Method.Put,i,void 0,{type:r?"public":"private"})}removeRoomFromGroup(e,t){const r=N.encodeUri("/groups/$groupId/admin/rooms/$roomId",{$groupId:e,$roomId:t});return this.http.authedRequest(void 0,M.Method.Delete,r,void 0,{})}acceptGroupInvite(e,t=null){const r=N.encodeUri("/groups/$groupId/self/accept_invite",{$groupId:e});return this.http.authedRequest(void 0,M.Method.Put,r,void 0,t||{})}joinGroup(e){const t=N.encodeUri("/groups/$groupId/self/join",{$groupId:e});return this.http.authedRequest(void 0,M.Method.Put,t,void 0,{})}leaveGroup(e){const t=N.encodeUri("/groups/$groupId/self/leave",{$groupId:e});return this.http.authedRequest(void 0,M.Method.Put,t,void 0,{})}getJoinedGroups(){const e=N.encodeUri("/joined_groups",{});return this.http.authedRequest(void 0,M.Method.Get,e)}createGroup(e){const t=N.encodeUri("/create_group",{});return this.http.authedRequest(void 0,M.Method.Post,t,void 0,e)}getPublicisedGroups(e){const t=N.encodeUri("/publicised_groups",{});return this.http.authedRequest(void 0,M.Method.Post,t,void 0,{user_ids:e})}setGroupPublicity(e,t){const r=N.encodeUri("/groups/$groupId/self/update_publicity",{$groupId:e});return this.http.authedRequest(void 0,M.Method.Put,r,void 0,{publicise:t})}supportsExperimentalThreads(){var e;return((e=this.clientOpts)===null||e===void 0?void 0:e.experimentalThreadSupport)||!1}async getRoomSummary(e,t){const r=N.encodeUri("/rooms/$roomid/summary",{$roomid:e});return this.http.authedRequest(void 0,M.Method.Get,r,{via:t},null,{qsStringifyOptions:{arrayFormat:"repeat"},prefix:"/_matrix/client/unstable/im.nheko.summary"})}findThreadRoots(e){const t=new Set;for(const r of e)r.isThreadRelation&&t.add(r.relationEventId);return t}eventShouldLiveIn(e,t,r,i){if(e.isThreadRoot)return{shouldLiveInRoom:!0,shouldLiveInThread:!0,threadId:e.getId()};if(e.isThreadRelation)return{shouldLiveInRoom:!1,shouldLiveInThread:!0,threadId:e.relationEventId};const s=e.getAssociatedId(),o=(t==null?void 0:t.findEventById(s))||r.find(l=>l.getId()===s);return(o==null?void 0:o.isThreadRoot)||i.has(e.relationEventId)?{shouldLiveInRoom:!0,shouldLiveInThread:!0,threadId:e.relationEventId}:o!=null&&o.getAssociatedId()?this.eventShouldLiveIn(o,t,r,i):{shouldLiveInRoom:!0,shouldLiveInThread:!1}}partitionThreadedEvents(e){if(this.supportsExperimentalThreads()){const i=this.findThreadRoots(e);return e.reduce((s,o)=>{const a=this.getRoom(o.getRoomId()),{shouldLiveInRoom:l,shouldLiveInThread:u,threadId:c}=this.eventShouldLiveIn(o,a,e,i);return l&&s[0].push(o),u&&(o.setThreadId(c),s[1].push(o)),s},[[],[]])}else return[e,[]]}async processThreadEvents(e,t,r){for(const i of t)await e.addThreadedEvent(i,r)}async whoami(){return this.http.authedRequest(void 0,M.Method.Get,"/account/whoami")}async timestampToEvent(e,t,r){const i=N.encodeUri("/rooms/$roomId/timestamp_to_event",{$roomId:e});return await this.http.authedRequest(void 0,M.Method.Get,i,{ts:t.toString(),dir:r},void 0,{prefix:"/_matrix/client/unstable/org.matrix.msc3030"})}}st.MatrixClient=fu;(0,X.default)(fu,"RESTORE_BACKUP_ERROR_BAD_KEY","RESTORE_BACKUP_ERROR_BAD_KEY");var Mo={},NA=G.exports;Object.defineProperty(Mo,"__esModule",{value:!0});Mo.TimelineWindow=Mo.TimelineIndex=void 0;var wa=NA(Y.exports),jn=qt;const Am=function(){},LA=5;class BA{constructor(e,t,r={}){this.client=e,this.timelineSet=t,(0,wa.default)(this,"windowLimit",void 0),(0,wa.default)(this,"start",null),(0,wa.default)(this,"end",null),(0,wa.default)(this,"eventCount",0),this.windowLimit=r.windowLimit||1e3}load(e,t=20){const r=i=>{let s;const o=i.getEvents();if(!e)s=o.length;else{for(let u=0;u<o.length;u++)if(o[u].getId()==e){s=u;break}if(s===void 0)throw new Error("getEventTimeline result didn't include requested event")}const a=Math.min(o.length,s+Math.ceil(t/2)),l=Math.max(0,a-t);this.start=new Gh(i,l-i.getBaseIndex()),this.end=new Gh(i,a-i.getBaseIndex()),this.eventCount=a-l};if(e){const i=this.timelineSet.getTimelineForEvent(e);return i?(r(i),Promise.resolve(i)):this.client.getEventTimeline(this.timelineSet,e).then(r)}else{const i=this.timelineSet.getLiveTimeline();return r(i),Promise.resolve()}}getTimelineIndex(e){if(e==jn.EventTimeline.BACKWARDS)return this.start;if(e==jn.EventTimeline.FORWARDS)return this.end;throw new Error("Invalid direction '"+e+"'")}extend(e,t){const r=this.getTimelineIndex(e);if(!r)return!1;const i=e==jn.EventTimeline.BACKWARDS?r.retreat(t):r.advance(t);if(i){this.eventCount+=i,Am("TimelineWindow: increased cap by "+i+" (now "+this.eventCount+")");const s=this.eventCount-this.windowLimit;return s>0&&this.unpaginate(s,e!=jn.EventTimeline.BACKWARDS),!0}return!1}canPaginate(e){const t=this.getTimelineIndex(e);if(!t)return!1;if(e==jn.EventTimeline.BACKWARDS){if(t.index>t.minIndex())return!0}else if(t.index<t.maxIndex())return!0;return Boolean(t.timeline.getNeighbouringTimeline(e)||t.timeline.getPaginationToken(e)!==null)}paginate(e,t,r=!0,i=LA){const s=this.getTimelineIndex(e);if(!s)return Promise.resolve(!1);if(s.pendingPaginate)return s.pendingPaginate;if(this.extend(e,t))return Promise.resolve(!0);if(!r||i===0||s.timeline.getPaginationToken(e)===null)return Promise.resolve(!1);const a=this.client.paginateEventTimeline(s.timeline,{backwards:e==jn.EventTimeline.BACKWARDS,limit:t}).finally(function(){s.pendingPaginate=null}).then(l=>l?this.paginate(e,t,!0,i-1):!1);return s.pendingPaginate=a,a}unpaginate(e,t){const r=t?this.start:this.end;if(e>this.eventCount||e<0)throw new Error("Attemting to unpaginate "+e+" events, but only have "+this.eventCount+" in the timeline");for(;e>0;){const i=t?r.advance(e):r.retreat(e);if(i<=0)throw new Error("Unable to unpaginate any further, but still have "+this.eventCount+" events");e-=i,this.eventCount-=i,Am("TimelineWindow.unpaginate: dropped "+i+" (now "+this.eventCount+")")}}getEvents(){if(!this.start)return[];const e=[];let t=this.start.timeline;for(;;){const r=t.getEvents();let i=0,s=r.length;t===this.start.timeline&&(i=this.start.index+t.getBaseIndex()),t===this.end.timeline&&(s=this.end.index+t.getBaseIndex());for(let o=i;o<s;o++)e.push(r[o]);if(t===this.end.timeline)break;t=t.getNeighbouringTimeline(jn.EventTimeline.FORWARDS)}return e}}Mo.TimelineWindow=BA;class Gh{constructor(e,t){this.timeline=e,this.index=t,(0,wa.default)(this,"pendingPaginate",void 0)}minIndex(){return this.timeline.getBaseIndex()*-1}maxIndex(){return this.timeline.getEvents().length-this.timeline.getBaseIndex()}advance(e){if(!e)return 0;let t;if(e<0){if(t=Math.max(e,this.minIndex()-this.index),t<0)return this.index+=t,t}else if(t=Math.min(e,this.maxIndex()-this.index),t>0)return this.index+=t,t;const r=this.timeline.getNeighbouringTimeline(e<0?jn.EventTimeline.BACKWARDS:jn.EventTimeline.FORWARDS);return r?(this.timeline=r,e<0?this.index=this.maxIndex():this.index=this.minIndex(),this.advance(e)):0}retreat(e){return this.advance(e*-1)*-1}}Mo.TimelineIndex=Gh;var Ts={},KA=G.exports;Object.defineProperty(Ts,"__esModule",{value:!0});Ts.InteractiveAuth=Ts.AuthType=void 0;var Lt=KA(Y.exports),Rd=se,FA=W;const ma="m.login.email.identity",Dm="m.login.msisdn";let Ya;Ts.AuthType=Ya;(function(n){n.Password="m.login.password",n.Recaptcha="m.login.recaptcha",n.Terms="m.login.terms",n.Email="m.login.email.identity",n.Msisdn="m.login.msisdn",n.Sso="m.login.sso",n.SsoUnstable="org.matrix.login.sso",n.Dummy="m.login.dummy",n.RegistrationToken="org.matrix.msc3231.login.registration_token"})(Ya||(Ts.AuthType=Ya={}));class qA extends Error{constructor(e,t,r){super(e);this.required_stages=t,this.flows=r,(0,Lt.default)(this,"name","NoAuthFlowFoundError")}}class jA{constructor(e){var t;(0,Lt.default)(this,"matrixClient",void 0),(0,Lt.default)(this,"inputs",void 0),(0,Lt.default)(this,"clientSecret",void 0),(0,Lt.default)(this,"requestCallback",void 0),(0,Lt.default)(this,"busyChangedCallback",void 0),(0,Lt.default)(this,"stateUpdatedCallback",void 0),(0,Lt.default)(this,"requestEmailTokenCallback",void 0),(0,Lt.default)(this,"data",void 0),(0,Lt.default)(this,"emailSid",void 0),(0,Lt.default)(this,"requestingEmailToken",!1),(0,Lt.default)(this,"attemptAuthDeferred",null),(0,Lt.default)(this,"chosenFlow",null),(0,Lt.default)(this,"currentStage",null),(0,Lt.default)(this,"submitPromise",null),this.matrixClient=e.matrixClient,this.data=e.authData||{},this.requestCallback=e.doRequest,this.busyChangedCallback=e.busyChanged,this.stateUpdatedCallback=e.stateUpdated||e.startAuthStage,this.requestEmailTokenCallback=e.requestEmailToken,this.inputs=e.inputs||{},e.sessionId&&(this.data.session=e.sessionId),this.clientSecret=e.clientSecret||this.matrixClient.generateClientSecret(),this.emailSid=(t=e.emailSid)!==null&&t!==void 0?t:null}attemptAuth(){var e;this.attemptAuthDeferred=(0,FA.defer)();const t=this.attemptAuthDeferred.promise;if((e=this.data)!==null&&e!==void 0&&e.flows)this.startNextAuthStage();else{var r;(r=this.busyChangedCallback)===null||r===void 0||r.call(this,!0);let i=null;this.data.session&&(i={session:this.data.session}),this.doRequest(i).finally(()=>{var s;(s=this.busyChangedCallback)===null||s===void 0||s.call(this,!1)})}return t}async poll(){if(!this.data.session||!this.attemptAuthDeferred||this.submitPromise)return;let e={};if(this.currentStage==ma&&this.emailSid){const t={sid:this.emailSid,client_secret:this.clientSecret};if(await this.matrixClient.doesServerRequireIdServerParam()){const r=new URL(this.matrixClient.getIdentityServerUrl());t.id_server=r.host}e={type:ma,threepid_creds:t,threepidCreds:t}}this.submitAuthDict(e,!0)}getSessionId(){return this.data?this.data.session:void 0}getClientSecret(){return this.clientSecret}getStageParams(e){var t;return(t=this.data.params)===null||t===void 0?void 0:t[e]}getChosenFlow(){return this.chosenFlow}async submitAuthDict(e,t=!1){if(!this.attemptAuthDeferred)throw new Error("submitAuthDict() called before attemptAuth()");if(!t){var r;(r=this.busyChangedCallback)===null||r===void 0||r.call(this,!0)}for(;this.submitPromise;)try{await this.submitPromise}catch{}let i;this.data.session?(i={session:this.data.session},Object.assign(i,e)):i=e;try{this.submitPromise=this.doRequest(i,t),await this.submitPromise}finally{if(this.submitPromise=null,!t){var s;(s=this.busyChangedCallback)===null||s===void 0||s.call(this,!1)}}}getEmailSid(){return this.emailSid}setEmailSid(e){this.emailSid=e}async doRequest(e,t=!1){try{const o=await this.requestCallback(e,t);this.attemptAuthDeferred.resolve(o),this.attemptAuthDeferred=null}catch(o){var r,i;const a=(r=(i=o.data)===null||i===void 0?void 0:i.flows)!==null&&r!==void 0?r:null,l=this.data.flows||Boolean(a);if(o.httpStatus!==401||!o.data||!l)if(t)Rd.logger.log("Background poll request failed doing UI auth: ignoring",o);else{var s;(s=this.attemptAuthDeferred)===null||s===void 0||s.reject(o)}!o.data.flows&&!o.data.completed&&!o.data.session&&(o.data.flows=this.data.flows,o.data.completed=this.data.completed,o.data.session=this.data.session),this.data=o.data;try{this.startNextAuthStage()}catch(u){this.attemptAuthDeferred.reject(u),this.attemptAuthDeferred=null;return}if(!this.emailSid&&!this.requestingEmailToken&&this.chosenFlow.stages.includes(Ya.Email)){this.requestingEmailToken=!0;try{const u=await this.requestEmailTokenCallback(this.inputs.emailAddress,this.clientSecret,1,this.data.session);this.emailSid=u.sid}catch(u){this.attemptAuthDeferred.reject(u),this.attemptAuthDeferred=null}finally{this.requestingEmailToken=!1}}}}startNextAuthStage(){const e=this.chooseStage();if(!e)throw new Error("No incomplete flows from the server");if(this.currentStage=e,e===Ya.Dummy){this.submitAuthDict({type:"m.login.dummy"});return}if(this.data&&this.data.errcode||this.data.error){this.stateUpdatedCallback(e,{errcode:this.data.errcode||"",error:this.data.error||""});return}const t={};e==ma&&(t.emailSid=this.emailSid),this.stateUpdatedCallback(e,t)}chooseStage(){this.chosenFlow===null&&(this.chosenFlow=this.chooseFlow()),Rd.logger.log("Active flow => %s",JSON.stringify(this.chosenFlow));const e=this.firstUncompletedStage(this.chosenFlow);return Rd.logger.log("Next stage: %s",e),e}chooseFlow(){const e=this.data.flows||[],t=Boolean(this.inputs.emailAddress)||Boolean(this.emailSid),r=Boolean(this.inputs.phoneCountry)&&Boolean(this.inputs.phoneNumber);for(const s of e){let o=!1,a=!1;for(const l of s.stages)l===ma?o=!0:l==Dm&&(a=!0);if(o==t&&a==r)return s}const i=[];throw t&&i.push(ma),r&&i.push(Dm),new qA("No appropriate authentication flow found",i,e)}firstUncompletedStage(e){const t=this.data.completed||[];for(let r=0;r<e.stages.length;++r){const i=e.stages[r];if(t.indexOf(i)===-1)return i}}}Ts.InteractiveAuth=jA;var pu={},gu={},VA=G.exports;Object.defineProperty(gu,"__esModule",{value:!0});gu.LocalIndexedDBStoreBackend=void 0;var ya=VA(Y.exports),GA=ri,zi=B_(W),WA=B_(iu),Qe=se;function L_(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(L_=function(r){return r?t:e})(n)}function B_(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=L_(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}const HA=3;function YA(n){n.createObjectStore("users",{keyPath:["userId"]}),n.createObjectStore("accountData",{keyPath:["type"]}),n.createObjectStore("sync",{keyPath:["clobber"]})}function zA(n){n.createObjectStore("oob_membership_events",{keyPath:["room_id","state_key"]}).createIndex("room","room_id")}function JA(n){n.createObjectStore("client_options",{keyPath:["clobber"]})}function Wc(n,e,t){const r=n.openCursor(e);return new Promise((i,s)=>{const o=[];r.onerror=()=>{s(new Error("Query failed: "+r.error))},r.onsuccess=()=>{const a=r.result;if(!a){i(o);return}o.push(t(a)),a.continue()}})}function va(n){return new Promise((e,t)=>{n.oncomplete=function(r){e(r)},n.onerror=function(){t(n.error)}})}function K_(n){return new Promise((e,t)=>{n.onsuccess=function(r){e(r)},n.onerror=function(){t(n.error)}})}function XA(n){return new Promise((e,t)=>{n.onsuccess=()=>e(n),n.onerror=r=>t(r)})}function xm(n){return K_(n).then(e=>n.result)}class QA{static exists(e,t){return t="matrix-js-sdk:"+(t||"default"),WA.exists(e,t)}constructor(e,t){this.indexedDB=e,(0,ya.default)(this,"dbName",void 0),(0,ya.default)(this,"syncAccumulator",void 0),(0,ya.default)(this,"db",null),(0,ya.default)(this,"disconnected",!0),(0,ya.default)(this,"_isNewlyCreated",!1),this.dbName="matrix-js-sdk:"+(t||"default"),this.syncAccumulator=new GA.SyncAccumulator}connect(){if(!this.disconnected)return Qe.logger.log("LocalIndexedDBStoreBackend.connect: already connected or connecting"),Promise.resolve();this.disconnected=!1,Qe.logger.log("LocalIndexedDBStoreBackend.connect: connecting...");const e=this.indexedDB.open(this.dbName,HA);return e.onupgradeneeded=t=>{const r=e.result,i=t.oldVersion;Qe.logger.log(`LocalIndexedDBStoreBackend.connect: upgrading from ${i}`),i<1&&(this._isNewlyCreated=!0,YA(r)),i<2&&zA(r),i<3&&JA(r)},e.onblocked=()=>{Qe.logger.log("can't yet open LocalIndexedDBStoreBackend because it is open elsewhere")},Qe.logger.log("LocalIndexedDBStoreBackend.connect: awaiting connection..."),K_(e).then(()=>(Qe.logger.log("LocalIndexedDBStoreBackend.connect: connected"),this.db=e.result,this.db.onversionchange=()=>{this.db.close()},this.init()))}isNewlyCreated(){return Promise.resolve(this._isNewlyCreated)}init(){return Promise.all([this.loadAccountData(),this.loadSyncData()]).then(([e,t])=>{Qe.logger.log("LocalIndexedDBStoreBackend: loaded initial data"),this.syncAccumulator.accumulate({next_batch:t.nextBatch,rooms:t.roomsData,groups:t.groupsData,account_data:{events:e}},!0)})}getOutOfBandMembers(e){return new Promise((t,r)=>{const o=this.db.transaction(["oob_membership_events"],"readonly").objectStore("oob_membership_events").index("room"),a=IDBKeyRange.only(e),l=o.openCursor(a),u=[];let c=!1;l.onsuccess=()=>{const g=l.result;if(!g)return!u.length&&!c?t(null):t(u);const m=g.value;m.oob_written?c=!0:u.push(m),g.continue()},l.onerror=g=>{r(g)}}).then(t=>(Qe.logger.log(`LL: got ${t&&t.length} membershipEvents from storage for room ${e} ...`),t))}async setOutOfBandMembers(e,t){Qe.logger.log(`LL: backend about to store ${t.length} members for ${e}`);const r=this.db.transaction(["oob_membership_events"],"readwrite"),i=r.objectStore("oob_membership_events");t.forEach(o=>{i.put(o)});const s={room_id:e,oob_written:!0,state_key:0};i.put(s),await va(r),Qe.logger.log(`LL: backend done storing for ${e}!`)}async clearOutOfBandMembers(e){const i=this.db.transaction(["oob_membership_events"],"readonly").objectStore("oob_membership_events").index("room"),s=IDBKeyRange.only(e),o=xm(i.openKeyCursor(s,"next")).then(f=>f&&f.primaryKey[1]),a=xm(i.openKeyCursor(s,"prev")).then(f=>f&&f.primaryKey[1]),[l,u]=await Promise.all([o,a]),g=this.db.transaction(["oob_membership_events"],"readwrite").objectStore("oob_membership_events"),m=IDBKeyRange.bound([e,l],[e,u]);Qe.logger.log(`LL: Deleting all users + marker in storage for room ${e}, with key range:`,[e,l],[e,u]),await XA(g.delete(m))}clearDatabase(){return new Promise(e=>{Qe.logger.log(`Removing indexeddb instance: ${this.dbName}`);const t=this.indexedDB.deleteDatabase(this.dbName);t.onblocked=()=>{Qe.logger.log(`can't yet delete indexeddb ${this.dbName} because it is open elsewhere`)},t.onerror=()=>{Qe.logger.warn(`unable to delete js-sdk store indexeddb: ${t.error}`),e()},t.onsuccess=()=>{Qe.logger.log(`Removed indexeddb instance: ${this.dbName}`),e()}})}getSavedSync(e=!0){const t=this.syncAccumulator.getJSON();return t.nextBatch?e?Promise.resolve(zi.deepCopy(t)):Promise.resolve(t):Promise.resolve(null)}getNextBatchToken(){return Promise.resolve(this.syncAccumulator.getNextBatchToken())}setSyncData(e){return Promise.resolve().then(()=>{this.syncAccumulator.accumulate(e)})}async syncToDatabase(e){const t=this.syncAccumulator.getJSON(!0);await Promise.all([this.persistUserPresenceEvents(e),this.persistAccountData(t.accountData),this.persistSyncData(t.nextBatch,t.roomsData,t.groupsData)])}persistSyncData(e,t,r){return Qe.logger.log("Persisting sync data up to",e),zi.promiseTry(()=>{const i=this.db.transaction(["sync"],"readwrite");return i.objectStore("sync").put({clobber:"-",nextBatch:e,roomsData:t,groupsData:r}),va(i).then()})}persistAccountData(e){return zi.promiseTry(()=>{const t=this.db.transaction(["accountData"],"readwrite"),r=t.objectStore("accountData");for(let i=0;i<e.length;i++)r.put(e[i]);return va(t).then()})}persistUserPresenceEvents(e){return zi.promiseTry(()=>{const t=this.db.transaction(["users"],"readwrite"),r=t.objectStore("users");for(const i of e)r.put({userId:i[0],event:i[1]});return va(t).then()})}getUserPresenceEvents(){return zi.promiseTry(()=>{const t=this.db.transaction(["users"],"readonly").objectStore("users");return Wc(t,void 0,r=>[r.value.userId,r.value.event])})}loadAccountData(){return Qe.logger.log("LocalIndexedDBStoreBackend: loading account data..."),zi.promiseTry(()=>{const t=this.db.transaction(["accountData"],"readonly").objectStore("accountData");return Wc(t,void 0,r=>r.value).then(r=>(Qe.logger.log("LocalIndexedDBStoreBackend: loaded account data"),r))})}loadSyncData(){return Qe.logger.log("LocalIndexedDBStoreBackend: loading sync data..."),zi.promiseTry(()=>{const t=this.db.transaction(["sync"],"readonly").objectStore("sync");return Wc(t,void 0,r=>r.value).then(r=>(Qe.logger.log("LocalIndexedDBStoreBackend: loaded sync data"),r.length>1&&Qe.logger.warn("loadSyncData: More than 1 sync row found."),r.length>0?r[0]:{}))})}getClientOptions(){return Promise.resolve().then(()=>{const t=this.db.transaction(["client_options"],"readonly").objectStore("client_options");return Wc(t,void 0,r=>{if(r.value&&r.value&&r.value.options)return r.value.options}).then(r=>r[0])})}async storeClientOptions(e){const t=this.db.transaction(["client_options"],"readwrite");t.objectStore("client_options").put({clobber:"-",options:e}),await va(t)}}gu.LocalIndexedDBStoreBackend=QA;var mu={},ZA=G.exports;Object.defineProperty(mu,"__esModule",{value:!0});mu.RemoteIndexedDBStoreBackend=void 0;var _a=ZA(Y.exports),Hc=se,eD=W;class tD{constructor(e,t){this.workerFactory=e,this.dbName=t,(0,_a.default)(this,"worker",void 0),(0,_a.default)(this,"nextSeq",0),(0,_a.default)(this,"inFlight",{}),(0,_a.default)(this,"startPromise",null),(0,_a.default)(this,"onWorkerMessage",r=>{const i=r.data;if(i.command=="cmd_success"||i.command=="cmd_fail"){if(i.seq===void 0){Hc.logger.error("Got reply from worker with no seq");return}const s=this.inFlight[i.seq];if(s===void 0){Hc.logger.error("Got reply for unknown seq "+i.seq);return}if(delete this.inFlight[i.seq],i.command=="cmd_success")s.resolve(i.result);else{const o=new Error(i.error.message);o.name=i.error.name,s.reject(o)}}else Hc.logger.warn("Unrecognised message from worker: ",i)})}connect(){return this.ensureStarted().then(()=>this.doCmd("connect"))}clearDatabase(){return this.ensureStarted().then(()=>this.doCmd("clearDatabase"))}isNewlyCreated(){return this.doCmd("isNewlyCreated")}getSavedSync(){return this.doCmd("getSavedSync")}getNextBatchToken(){return this.doCmd("getNextBatchToken")}setSyncData(e){return this.doCmd("setSyncData",[e])}syncToDatabase(e){return this.doCmd("syncToDatabase",[e])}getOutOfBandMembers(e){return this.doCmd("getOutOfBandMembers",[e])}setOutOfBandMembers(e,t){return this.doCmd("setOutOfBandMembers",[e,t])}clearOutOfBandMembers(e){return this.doCmd("clearOutOfBandMembers",[e])}getClientOptions(){return this.doCmd("getClientOptions")}storeClientOptions(e){return this.doCmd("storeClientOptions",[e])}getUserPresenceEvents(){return this.doCmd("getUserPresenceEvents")}ensureStarted(){return this.startPromise===null&&(this.worker=this.workerFactory(),this.worker.onmessage=this.onWorkerMessage,this.startPromise=this.doCmd("_setupWorker",[this.dbName]).then(()=>{Hc.logger.log("IndexedDB worker is ready")})),this.startPromise}doCmd(e,t){return Promise.resolve().then(()=>{const r=this.nextSeq++,i=(0,eD.defer)();return this.inFlight[r]=i,this.worker.postMessage({command:e,seq:r,args:t}),i.promise})}}mu.RemoteIndexedDBStoreBackend=tD;var rD=G.exports;Object.defineProperty(pu,"__esModule",{value:!0});pu.IndexedDBStore=void 0;var gt=rD(Y.exports),nD=Qa,Um=gu,iD=mu,sD=Qr,oD=jt,un=se,aD=je;const cD=1e3*60*5;class lD extends nD.MemoryStore{static exists(e,t){return Um.LocalIndexedDBStoreBackend.exists(e,t)}constructor(e){super(e);if((0,gt.default)(this,"backend",void 0),(0,gt.default)(this,"startedUp",!1),(0,gt.default)(this,"syncTs",0),(0,gt.default)(this,"userModifiedMap",{}),(0,gt.default)(this,"emitter",new aD.TypedEventEmitter),(0,gt.default)(this,"on",this.emitter.on.bind(this.emitter)),(0,gt.default)(this,"getSavedSync",this.degradable(()=>this.backend.getSavedSync(),"getSavedSync")),(0,gt.default)(this,"isNewlyCreated",this.degradable(()=>this.backend.isNewlyCreated(),"isNewlyCreated")),(0,gt.default)(this,"getSavedSyncToken",this.degradable(()=>this.backend.getNextBatchToken(),"getSavedSyncToken")),(0,gt.default)(this,"deleteAllData",this.degradable(()=>(super.deleteAllData(),this.backend.clearDatabase().then(()=>{un.logger.log("Deleted indexeddb data.")},t=>{throw un.logger.error(`Failed to delete indexeddb data: ${t}`),t})))),(0,gt.default)(this,"reallySave",this.degradable(()=>{this.syncTs=Date.now();const t=[];for(const r of this.getUsers())this.userModifiedMap[r.userId]!==r.getLastModifiedTime()&&(!r.events.presence||(t.push([r.userId,r.events.presence.event]),this.userModifiedMap[r.userId]=r.getLastModifiedTime()));return this.backend.syncToDatabase(t)})),(0,gt.default)(this,"setSyncData",this.degradable(t=>this.backend.setSyncData(t),"setSyncData")),(0,gt.default)(this,"getOutOfBandMembers",this.degradable(t=>this.backend.getOutOfBandMembers(t),"getOutOfBandMembers")),(0,gt.default)(this,"setOutOfBandMembers",this.degradable((t,r)=>(super.setOutOfBandMembers(t,r),this.backend.setOutOfBandMembers(t,r)),"setOutOfBandMembers")),(0,gt.default)(this,"clearOutOfBandMembers",this.degradable(t=>(super.clearOutOfBandMembers(t),this.backend.clearOutOfBandMembers(t)),"clearOutOfBandMembers")),(0,gt.default)(this,"getClientOptions",this.degradable(()=>this.backend.getClientOptions(),"getClientOptions")),(0,gt.default)(this,"storeClientOptions",this.degradable(t=>(super.storeClientOptions(t),this.backend.storeClientOptions(t)),"storeClientOptions")),!e.indexedDB)throw new Error("Missing required option: indexedDB");e.workerFactory?this.backend=new iD.RemoteIndexedDBStoreBackend(e.workerFactory,e.dbName):this.backend=new Um.LocalIndexedDBStoreBackend(e.indexedDB,e.dbName)}startup(){return this.startedUp?(un.logger.log("IndexedDBStore.startup: already started"),Promise.resolve()):(un.logger.log("IndexedDBStore.startup: connecting to backend"),this.backend.connect().then(()=>(un.logger.log("IndexedDBStore.startup: loading presence events"),this.backend.getUserPresenceEvents())).then(e=>{un.logger.log("IndexedDBStore.startup: processing presence events"),e.forEach(([t,r])=>{const i=new sD.User(t);r&&i.setPresenceEvent(new oD.MatrixEvent(r)),this.userModifiedMap[i.userId]=i.getLastModifiedTime(),this.storeUser(i)})}))}wantsSave(){return Date.now()-this.syncTs>cD}save(e=!1){return e||this.wantsSave()?this.reallySave():Promise.resolve()}degradable(e,t){const r=super[t];return async(...i)=>{try{return e.call(this,...i)}catch(s){un.logger.error("IndexedDBStore failure, degrading to MemoryStore",s),this.emitter.emit("degraded",s);try{un.logger.log("IndexedDBStore trying to delete degraded data"),await this.backend.clearDatabase(),un.logger.log("IndexedDBStore delete after degrading succeeded")}catch(o){un.logger.warn("IndexedDBStore delete after degrading failed",o)}if(r)return r(...i)}}}}pu.IndexedDBStore=lD;var Uf={};Object.defineProperty(Uf,"__esModule",{value:!0});var _D=Uf.WebStorageSessionStore=q_,Yc=uD(W);function F_(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(F_=function(r){return r?t:e})(n)}function uD(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=F_(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}const kn="session.e2e.";function q_(n){if(this.store=n,!Yc.isFunction(n.getItem)||!Yc.isFunction(n.setItem)||!Yc.isFunction(n.removeItem)||!Yc.isFunction(n.key)||typeof n.length!="number")throw new Error("Supplied webStore does not meet the WebStorage API interface")}q_.prototype={removeEndToEndAccount:function(){this.store.removeItem($m)},getEndToEndAccount:function(){return this.store.getItem($m)},getAllEndToEndDevices:function(){const n=Km(""),e={};for(let t=0;t<this.store.length;++t){const r=this.store.key(t),i=r.substr(n.length);r.startsWith(n)&&(e[i]=ro(this.store,r))}return e},getEndToEndDeviceTrackingStatus:function(){return ro(this.store,Lm)},getEndToEndDeviceSyncToken:function(){return ro(this.store,Nm)},removeEndToEndDeviceData:function(){no(this.store,Km("")),no(this.store,Lm),no(this.store,Nm)},getEndToEndSessions:function(n){return ro(this.store,zc(n))},getAllEndToEndSessions:function(){const n=Fm(this.store,zc("")),e={};for(const t of n){const r=t.substr(zc("").length);e[r]=ro(this.store,t)}return e},removeAllEndToEndSessions:function(){no(this.store,zc(""))},getAllEndToEndInboundGroupSessionKeys:function(){const n=kn+"inboundgroupsessions/",e=[];for(let t=0;t<this.store.length;t++){const r=this.store.key(t);!r.startsWith(n)||e.push({senderKey:r.substr(n.length,43),sessionId:r.substr(n.length+44)})}return e},getEndToEndInboundGroupSession:function(n,e){const t=dD(n,e);return this.store.getItem(t)},removeAllEndToEndInboundGroupSessions:function(){no(this.store,kn+"inboundgroupsessions/")},getAllEndToEndRooms:function(){const n=Fm(this.store,Id("")),e={};for(const t of n){const r=t.substr(Id("").length);e[r]=ro(this.store,t)}return e},removeAllEndToEndRooms:function(){no(this.store,Id(""))},setLocalTrustedBackupPubKey:function(n){this.store.setItem(Bm,n)},getLocalTrustedBackupPubKey:function(){return this.store.getItem(Bm)}};const $m=kn+"account",Nm=kn+"device_sync_token",Lm=kn+"device_tracking",Bm=kn+"trusted_backup_pubkey";function Km(n){return kn+"devices/"+n}function zc(n){return kn+"sessions/"+n}function dD(n,e){return kn+"inboundgroupsessions/"+n+"/"+e}function Id(n){return kn+"rooms/"+n}function ro(n,e){try{return JSON.parse(n.getItem(e))}catch(t){hD(t.stack)}return null}function Fm(n,e){const t=[];for(let r=0;r<n.length;++r){const i=n.key(r);i.startsWith(e)&&t.push(i)}return t}function no(n,e){const t=[];for(let r=0;r<n.length;++r){const i=n.key(r);i.startsWith(e)&&t.push(i)}for(const r of t)n.removeItem(r)}function hD(...n){}var j_={};Object.defineProperty(j_,"__esModule",{value:!0});(function(n){Object.defineProperty(n,"__esModule",{value:!0});var e={request:!0,getRequest:!0,wrapRequest:!0,setCryptoStoreFactory:!0,createClient:!0,ContentHelpers:!0,createNewMatrixCall:!0};n.ContentHelpers=void 0,n.createClient=pi,Object.defineProperty(n,"createNewMatrixCall",{enumerable:!0,get:function(){return rn.createNewMatrixCall}}),n.getRequest=hi,n.request=$e,n.setCryptoStoreFactory=fi,n.wrapRequest=Fr;var t=Uo;Object.keys(t).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===t[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return t[_]}})});var r=Qa;Object.keys(r).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===r[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return r[_]}})});var i=Wl;Object.keys(i).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===i[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return i[_]}})});var s=st;Object.keys(s).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===s[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return s[_]}})});var o=me;Object.keys(o).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===o[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return o[_]}})});var a=Ni;Object.keys(a).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===a[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return a[_]}})});var l=ri;Object.keys(l).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===l[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return l[_]}})});var u=oi;Object.keys(u).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===u[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return u[_]}})});var c=vr;Object.keys(c).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===c[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return c[_]}})});var g=jt;Object.keys(g).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===g[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return g[_]}})});var m=lr;Object.keys(m).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===m[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return m[_]}})});var f=Xl;Object.keys(f).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===f[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return f[_]}})});var E=qt;Object.keys(E).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===E[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return E[_]}})});var I=ti;Object.keys(I).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===I[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return I[_]}})});var w=Zr;Object.keys(w).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===w[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return w[_]}})});var k=Tn;Object.keys(k).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===k[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return k[_]}})});var C=Qr;Object.keys(C).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===C[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return C[_]}})});var S=Ds;Object.keys(S).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===S[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return S[_]}})});var T=Mo;Object.keys(T).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===T[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return T[_]}})});var D=Ts;Object.keys(D).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===D[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return D[_]}})});var R=jo;Object.keys(R).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===R[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return R[_]}})});var U=pu;Object.keys(U).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===U[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return U[_]}})});var q=Uf;Object.keys(q).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===q[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return q[_]}})});var B=Br;Object.keys(B).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===B[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return B[_]}})});var te=$o;Object.keys(te).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===te[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return te[_]}})});var ye=ie;Object.keys(ye).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===ye[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return ye[_]}})});var we=Fe;Object.keys(we).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===we[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return we[_]}})});var Te=Je;Object.keys(Te).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===Te[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return Te[_]}})});var Ye=j_;Object.keys(Ye).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===Ye[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return Ye[_]}})});var Vt=Go;Object.keys(Vt).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===Vt[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return Vt[_]}})});var Gt=sc;Object.keys(Gt).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===Gt[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return Gt[_]}})});var Q=di(Xe);n.ContentHelpers=Q;var rn=Ce;function Kr(_){if(typeof WeakMap!="function")return null;var dr=new WeakMap,At=new WeakMap;return(Kr=function(hr){return hr?At:dr})(_)}function di(_,dr){if(!dr&&_&&_.__esModule)return _;if(_===null||typeof _!="object"&&typeof _!="function")return{default:_};var At=Kr(dr);if(At&&At.has(_))return At.get(_);var hr={},Sr=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var ot in _)if(ot!=="default"&&Object.prototype.hasOwnProperty.call(_,ot)){var at=Sr?Object.getOwnPropertyDescriptor(_,ot):null;at&&(at.get||at.set)?Object.defineProperty(hr,ot,at):hr[ot]=_[ot]}return hr.default=_,At&&At.set(_,hr),hr}let Re;function $e(_){Re=_}function hi(){return Re}function Fr(_){const dr=Re;Re=function(At,hr){return _(dr,At,hr)}}let Pn=()=>new t.MemoryCryptoStore;function fi(_){Pn=_}function pi(_){return typeof _=="string"&&(_={baseUrl:_}),_.request=_.request||Re,_.store=_.store||new r.MemoryStore({localStorage:V.localStorage}),_.scheduler=_.scheduler||new i.MatrixScheduler,_.cryptoStore=_.cryptoStore||Pn(),new s.MatrixClient(_)}})(Cs);(function(n){var e=G.exports;Object.defineProperty(n,"__esModule",{value:!0});var t={};n.default=void 0;var r=e(ky.exports),i=e(zb),s=a(Cs);Object.keys(s).forEach(function(c){c==="default"||c==="__esModule"||Object.prototype.hasOwnProperty.call(t,c)||c in n&&n[c]===s[c]||Object.defineProperty(n,c,{enumerable:!0,get:function(){return s[c]}})});function o(c){if(typeof WeakMap!="function")return null;var g=new WeakMap,m=new WeakMap;return(o=function(f){return f?m:g})(c)}function a(c,g){if(!g&&c&&c.__esModule)return c;if(c===null||typeof c!="object"&&typeof c!="function")return{default:c};var m=o(g);if(m&&m.has(c))return m.get(c);var f={},E=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var I in c)if(I!=="default"&&Object.prototype.hasOwnProperty.call(c,I)){var w=E?Object.getOwnPropertyDescriptor(c,I):null;w&&(w.get||w.set)?Object.defineProperty(f,I,w):f[I]=c[I]}return f.default=c,m&&m.set(c,f),f}if(s.getRequest())throw new Error("Multiple matrix-js-sdk entrypoints detected!");s.request(function(c,g){return c.qs=i.default.stringify(c.qs||{},c.qsStringifyOptions),(0,r.default)(c,g)});let l;try{l=V.indexedDB}catch{}l&&s.setCryptoStoreFactory(function(){return new s.IndexedDBCryptoStore(l,"matrix-js-sdk:crypto")});var u=s;n.default=u,V.matrixcs=s})(nS);var ED="/pr-121/assets/olm.b3e0f9b4.wasm",SD="/pr-121/assets/olm_legacy.9dc48f49.js",V_={exports:{}};(function(n,e){// @license magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7&dn=apache-2.0.txt Apache-2.0
+var t=function(){var r={},i,s,o=function(){var l=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename!="undefined"&&(l=l||__filename),function(u){u=u||{};var c;c||(c=typeof u!="undefined"?u:{});var g,m;c.ready=new Promise(function(p,y){g=p,m=y});var f;if(typeof window!="undefined")f=function(p){window.crypto.getRandomValues(p)};else if(n.exports){var E=Ci;f=function(p){var y=E.randomBytes(p.length);p.set(y)},process=V.process}else throw Error("Cannot find global to attach library to");if(typeof OLM_OPTIONS!="undefined")for(var I in OLM_OPTIONS)OLM_OPTIONS.hasOwnProperty(I)&&(c[I]=OLM_OPTIONS[I]);c.onRuntimeInitialized=function(){nn=c._olm_error(),r.PRIVATE_KEY_LENGTH=c._olm_pk_private_key_length(),i&&i()},c.onAbort=function(p){s&&s(p)};var w={},k;for(k in c)c.hasOwnProperty(k)&&(w[k]=c[k]);var C=typeof window=="object",S=typeof importScripts=="function",T="",D,R,U,q,B;typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"?(T=S?Ci.dirname(T)+"/":__dirname+"/",D=function(p,y){return q||(q=Ci),B||(B=Ci),p=B.normalize(p),q.readFileSync(p,y?null:"utf8")},U=function(p){return p=D(p,!0),p.buffer||(p=new Uint8Array(p)),p.buffer||at("Assertion failed: undefined"),p},R=function(p,y,O){q||(q=Ci),B||(B=Ci),p=B.normalize(p),q.readFile(p,function(x,K){x?O(x):y(K.buffer)})},1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),process.on("uncaughtException",function(p){throw p}),process.on("unhandledRejection",at),c.inspect=function(){return"[Emscripten Module object]"}):(C||S)&&(S?T=self.location.href:typeof document!="undefined"&&document.currentScript&&(T=document.currentScript.src),l&&(T=l),T.indexOf("blob:")!==0?T=T.substr(0,T.lastIndexOf("/")+1):T="",D=function(p){var y=new XMLHttpRequest;return y.open("GET",p,!1),y.send(null),y.responseText},S&&(U=function(p){var y=new XMLHttpRequest;return y.open("GET",p,!1),y.responseType="arraybuffer",y.send(null),new Uint8Array(y.response)}),R=function(p,y,O){var x=new XMLHttpRequest;x.open("GET",p,!0),x.responseType="arraybuffer",x.onload=function(){x.status==200||x.status==0&&x.response?y(x.response):O()},x.onerror=O,x.send(null)}),c.print||console.log.bind(console);var te=c.printErr||console.warn.bind(console);for(k in w)w.hasOwnProperty(k)&&(c[k]=w[k]);w=null;var ye;c.wasmBinary&&(ye=c.wasmBinary),c.noExitRuntime,typeof WebAssembly!="object"&&at("no native wasm support detected");function we(p){var y="i8";switch(y.charAt(y.length-1)==="*"&&(y="i32"),y){case"i1":Re[p>>0]=0;break;case"i8":Re[p>>0]=0;break;case"i16":hi[p>>1]=0;break;case"i32":Fr[p>>2]=0;break;case"i64":gi=[0,(Mn=0,1<=+Math.abs(Mn)?0<Mn?(Math.min(+Math.floor(Mn/4294967296),4294967295)|0)>>>0:~~+Math.ceil((Mn-+(~~Mn>>>0))/4294967296)>>>0:0)],Fr[p>>2]=gi[0],Fr[p+4>>2]=gi[1];break;case"float":Pn[p>>2]=0;break;case"double":fi[p>>3]=0;break;default:at("invalid type for setValue: "+y)}}function Te(p,y){switch(y=y||"i8",y.charAt(y.length-1)==="*"&&(y="i32"),y){case"i1":return Re[p>>0];case"i8":return Re[p>>0];case"i16":return hi[p>>1];case"i32":return Fr[p>>2];case"i64":return Fr[p>>2];case"float":return Pn[p>>2];case"double":return fi[p>>3];default:at("invalid type for getValue: "+y)}return null}var Ye,Vt=!1,Gt=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):void 0;function Q(p,y){if(p){var O=$e,x=p+y;for(y=p;O[y]&&!(y>=x);)++y;if(16<y-p&&O.subarray&&Gt)p=Gt.decode(O.subarray(p,y));else{for(x="";p<y;){var K=O[p++];if(K&128){var ee=O[p++]&63;if((K&224)==192)x+=String.fromCharCode((K&31)<<6|ee);else{var _e=O[p++]&63;K=(K&240)==224?(K&15)<<12|ee<<6|_e:(K&7)<<18|ee<<12|_e<<6|O[p++]&63,65536>K?x+=String.fromCharCode(K):(K-=65536,x+=String.fromCharCode(55296|K>>10,56320|K&1023))}}else x+=String.fromCharCode(K)}p=x}}else p="";return p}function rn(p,y,O,x){if(!(0<x))return 0;var K=O;x=O+x-1;for(var ee=0;ee<p.length;++ee){var _e=p.charCodeAt(ee);if(55296<=_e&&57343>=_e){var Dt=p.charCodeAt(++ee);_e=65536+((_e&1023)<<10)|Dt&1023}if(127>=_e){if(O>=x)break;y[O++]=_e}else{if(2047>=_e){if(O+1>=x)break;y[O++]=192|_e>>6}else{if(65535>=_e){if(O+2>=x)break;y[O++]=224|_e>>12}else{if(O+3>=x)break;y[O++]=240|_e>>18,y[O++]=128|_e>>12&63}y[O++]=128|_e>>6&63}y[O++]=128|_e&63}}return y[O]=0,O-K}function Kr(p){for(var y=0,O=0;O<p.length;++O){var x=p.charCodeAt(O);55296<=x&&57343>=x&&(x=65536+((x&1023)<<10)|p.charCodeAt(++O)&1023),127>=x?++y:y=2047>=x?y+2:65535>=x?y+3:y+4}return y}function di(p,y){for(var O=0;O<p.length;++O)Re[y++>>0]=p.charCodeAt(O)}var Re,$e,hi,Fr,Pn,fi,pi,_=[],dr=[],At=[];function hr(){var p=c.preRun.shift();_.unshift(p)}var Sr=0,ot=null;c.preloadedImages={},c.preloadedAudios={};function at(p){throw c.onAbort&&c.onAbort(p),te(p),Vt=!0,p=new WebAssembly.RuntimeError("abort("+p+"). Build with -s ASSERTIONS=1 for more info."),m(p),p}function uc(){return Wt.startsWith("data:application/octet-stream;base64,")}var Wt;if(Wt="olm.wasm",!uc()){var Ns=Wt;Wt=c.locateFile?c.locateFile(Ns,T):T+Ns}function dc(){var p=Wt;try{if(p==Wt&&ye)return new Uint8Array(ye);if(U)return U(p);throw"both async and sync fetching of the wasm failed"}catch(y){at(y)}}function yu(){if(!ye&&(C||S)){if(typeof fetch=="function"&&!Wt.startsWith("file://"))return fetch(Wt,{credentials:"same-origin"}).then(function(p){if(!p.ok)throw"failed to load wasm binary file at '"+Wt+"'";return p.arrayBuffer()}).catch(function(){return dc()});if(R)return new Promise(function(p,y){R(Wt,function(O){p(new Uint8Array(O))},y)})}return Promise.resolve().then(function(){return dc()})}var Mn,gi;function Ht(p){for(;0<p.length;){var y=p.shift();if(typeof y=="function")y(c);else{var O=y.cc;typeof O=="number"?y.bc===void 0?pi.get(O)():pi.get(O)(y.bc):O(y.bc===void 0?null:y.bc)}}}var Wo={a:function(p,y,O){$e.copyWithin(p,y,y+O)},b:function(){at("OOM")}};(function(){function p(K){c.asm=K.exports,Ye=c.asm.c,K=Ye.buffer,c.HEAP8=Re=new Int8Array(K),c.HEAP16=hi=new Int16Array(K),c.HEAP32=Fr=new Int32Array(K),c.HEAPU8=$e=new Uint8Array(K),c.HEAPU16=new Uint16Array(K),c.HEAPU32=new Uint32Array(K),c.HEAPF32=Pn=new Float32Array(K),c.HEAPF64=fi=new Float64Array(K),pi=c.asm.e,dr.unshift(c.asm.d),Sr--,c.monitorRunDependencies&&c.monitorRunDependencies(Sr),Sr==0&&ot&&(K=ot,ot=null,K())}function y(K){p(K.instance)}function O(K){return yu().then(function(ee){return WebAssembly.instantiate(ee,x)}).then(function(ee){return ee}).then(K,function(ee){te("failed to asynchronously prepare wasm: "+ee),at(ee)})}var x={a:Wo};if(Sr++,c.monitorRunDependencies&&c.monitorRunDependencies(Sr),c.instantiateWasm)try{return c.instantiateWasm(x,p)}catch(K){return te("Module.instantiateWasm callback failed with error: "+K),!1}return function(){return ye||typeof WebAssembly.instantiateStreaming!="function"||uc()||Wt.startsWith("file://")||typeof fetch!="function"?O(y):fetch(Wt,{credentials:"same-origin"}).then(function(K){return WebAssembly.instantiateStreaming(K,x).then(y,function(ee){return te("wasm streaming compile failed: "+ee),te("falling back to ArrayBuffer instantiation"),O(y)})})}().catch(m),{}})(),c.___wasm_call_ctors=function(){return(c.___wasm_call_ctors=c.asm.d).apply(null,arguments)},c._olm_pk_encryption_last_error=function(){return(c._olm_pk_encryption_last_error=c.asm.f).apply(null,arguments)},c.__olm_error_to_string=function(){return(c.__olm_error_to_string=c.asm.g).apply(null,arguments)},c._olm_pk_encryption_last_error_code=function(){return(c._olm_pk_encryption_last_error_code=c.asm.h).apply(null,arguments)},c._olm_pk_encryption_size=function(){return(c._olm_pk_encryption_size=c.asm.i).apply(null,arguments)},c._olm_pk_encryption=function(){return(c._olm_pk_encryption=c.asm.j).apply(null,arguments)},c._olm_clear_pk_encryption=function(){return(c._olm_clear_pk_encryption=c.asm.k).apply(null,arguments)},c._olm_pk_encryption_set_recipient_key=function(){return(c._olm_pk_encryption_set_recipient_key=c.asm.l).apply(null,arguments)},c._olm_pk_key_length=function(){return(c._olm_pk_key_length=c.asm.m).apply(null,arguments)},c._olm_pk_ciphertext_length=function(){return(c._olm_pk_ciphertext_length=c.asm.n).apply(null,arguments)},c._olm_pk_mac_length=function(){return(c._olm_pk_mac_length=c.asm.o).apply(null,arguments)},c._olm_pk_encrypt_random_length=function(){return(c._olm_pk_encrypt_random_length=c.asm.p).apply(null,arguments)},c._olm_pk_encrypt=function(){return(c._olm_pk_encrypt=c.asm.q).apply(null,arguments)},c._olm_pk_decryption_last_error=function(){return(c._olm_pk_decryption_last_error=c.asm.r).apply(null,arguments)},c._olm_pk_decryption_last_error_code=function(){return(c._olm_pk_decryption_last_error_code=c.asm.s).apply(null,arguments)},c._olm_pk_decryption_size=function(){return(c._olm_pk_decryption_size=c.asm.t).apply(null,arguments)},c._olm_pk_decryption=function(){return(c._olm_pk_decryption=c.asm.u).apply(null,arguments)},c._olm_clear_pk_decryption=function(){return(c._olm_clear_pk_decryption=c.asm.v).apply(null,arguments)},c._olm_pk_private_key_length=function(){return(c._olm_pk_private_key_length=c.asm.w).apply(null,arguments)},c._olm_pk_generate_key_random_length=function(){return(c._olm_pk_generate_key_random_length=c.asm.x).apply(null,arguments)},c._olm_pk_key_from_private=function(){return(c._olm_pk_key_from_private=c.asm.y).apply(null,arguments)},c._olm_pk_generate_key=function(){return(c._olm_pk_generate_key=c.asm.z).apply(null,arguments)},c._olm_pickle_pk_decryption_length=function(){return(c._olm_pickle_pk_decryption_length=c.asm.A).apply(null,arguments)},c._olm_pickle_pk_decryption=function(){return(c._olm_pickle_pk_decryption=c.asm.B).apply(null,arguments)},c._olm_unpickle_pk_decryption=function(){return(c._olm_unpickle_pk_decryption=c.asm.C).apply(null,arguments)},c._olm_pk_max_plaintext_length=function(){return(c._olm_pk_max_plaintext_length=c.asm.D).apply(null,arguments)},c._olm_pk_decrypt=function(){return(c._olm_pk_decrypt=c.asm.E).apply(null,arguments)},c._olm_pk_get_private_key=function(){return(c._olm_pk_get_private_key=c.asm.F).apply(null,arguments)},c._olm_pk_signing_size=function(){return(c._olm_pk_signing_size=c.asm.G).apply(null,arguments)},c._olm_pk_signing=function(){return(c._olm_pk_signing=c.asm.H).apply(null,arguments)},c._olm_pk_signing_last_error=function(){return(c._olm_pk_signing_last_error=c.asm.I).apply(null,arguments)},c._olm_pk_signing_last_error_code=function(){return(c._olm_pk_signing_last_error_code=c.asm.J).apply(null,arguments)},c._olm_clear_pk_signing=function(){return(c._olm_clear_pk_signing=c.asm.K).apply(null,arguments)},c._olm_pk_signing_seed_length=function(){return(c._olm_pk_signing_seed_length=c.asm.L).apply(null,arguments)},c._olm_pk_signing_public_key_length=function(){return(c._olm_pk_signing_public_key_length=c.asm.M).apply(null,arguments)},c._olm_pk_signing_key_from_seed=function(){return(c._olm_pk_signing_key_from_seed=c.asm.N).apply(null,arguments)},c._olm_pk_signature_length=function(){return(c._olm_pk_signature_length=c.asm.O).apply(null,arguments)},c._olm_pk_sign=function(){return(c._olm_pk_sign=c.asm.P).apply(null,arguments)},c._olm_get_library_version=function(){return(c._olm_get_library_version=c.asm.Q).apply(null,arguments)},c._olm_error=function(){return(c._olm_error=c.asm.R).apply(null,arguments)},c._olm_account_last_error=function(){return(c._olm_account_last_error=c.asm.S).apply(null,arguments)},c._olm_account_last_error_code=function(){return(c._olm_account_last_error_code=c.asm.T).apply(null,arguments)},c._olm_session_last_error=function(){return(c._olm_session_last_error=c.asm.U).apply(null,arguments)},c._olm_session_last_error_code=function(){return(c._olm_session_last_error_code=c.asm.V).apply(null,arguments)},c._olm_utility_last_error=function(){return(c._olm_utility_last_error=c.asm.W).apply(null,arguments)},c._olm_utility_last_error_code=function(){return(c._olm_utility_last_error_code=c.asm.X).apply(null,arguments)},c._olm_account_size=function(){return(c._olm_account_size=c.asm.Y).apply(null,arguments)},c._olm_session_size=function(){return(c._olm_session_size=c.asm.Z).apply(null,arguments)},c._olm_utility_size=function(){return(c._olm_utility_size=c.asm._).apply(null,arguments)},c._olm_account=function(){return(c._olm_account=c.asm.$).apply(null,arguments)},c._olm_session=function(){return(c._olm_session=c.asm.aa).apply(null,arguments)},c._olm_utility=function(){return(c._olm_utility=c.asm.ba).apply(null,arguments)},c._olm_clear_account=function(){return(c._olm_clear_account=c.asm.ca).apply(null,arguments)},c._olm_clear_session=function(){return(c._olm_clear_session=c.asm.da).apply(null,arguments)},c._olm_clear_utility=function(){return(c._olm_clear_utility=c.asm.ea).apply(null,arguments)},c._olm_pickle_account_length=function(){return(c._olm_pickle_account_length=c.asm.fa).apply(null,arguments)},c._olm_pickle_session_length=function(){return(c._olm_pickle_session_length=c.asm.ga).apply(null,arguments)},c._olm_pickle_account=function(){return(c._olm_pickle_account=c.asm.ha).apply(null,arguments)},c._olm_pickle_session=function(){return(c._olm_pickle_session=c.asm.ia).apply(null,arguments)},c._olm_unpickle_account=function(){return(c._olm_unpickle_account=c.asm.ja).apply(null,arguments)},c._olm_unpickle_session=function(){return(c._olm_unpickle_session=c.asm.ka).apply(null,arguments)},c._olm_create_account_random_length=function(){return(c._olm_create_account_random_length=c.asm.la).apply(null,arguments)},c._olm_create_account=function(){return(c._olm_create_account=c.asm.ma).apply(null,arguments)},c._olm_account_identity_keys_length=function(){return(c._olm_account_identity_keys_length=c.asm.na).apply(null,arguments)},c._olm_account_identity_keys=function(){return(c._olm_account_identity_keys=c.asm.oa).apply(null,arguments)},c._olm_account_signature_length=function(){return(c._olm_account_signature_length=c.asm.pa).apply(null,arguments)},c._olm_account_sign=function(){return(c._olm_account_sign=c.asm.qa).apply(null,arguments)},c._olm_account_one_time_keys_length=function(){return(c._olm_account_one_time_keys_length=c.asm.ra).apply(null,arguments)},c._olm_account_one_time_keys=function(){return(c._olm_account_one_time_keys=c.asm.sa).apply(null,arguments)},c._olm_account_mark_keys_as_published=function(){return(c._olm_account_mark_keys_as_published=c.asm.ta).apply(null,arguments)},c._olm_account_max_number_of_one_time_keys=function(){return(c._olm_account_max_number_of_one_time_keys=c.asm.ua).apply(null,arguments)},c._olm_account_generate_one_time_keys_random_length=function(){return(c._olm_account_generate_one_time_keys_random_length=c.asm.va).apply(null,arguments)},c._olm_account_generate_one_time_keys=function(){return(c._olm_account_generate_one_time_keys=c.asm.wa).apply(null,arguments)},c._olm_account_generate_fallback_key_random_length=function(){return(c._olm_account_generate_fallback_key_random_length=c.asm.xa).apply(null,arguments)},c._olm_account_generate_fallback_key=function(){return(c._olm_account_generate_fallback_key=c.asm.ya).apply(null,arguments)},c._olm_account_fallback_key_length=function(){return(c._olm_account_fallback_key_length=c.asm.za).apply(null,arguments)},c._olm_account_fallback_key=function(){return(c._olm_account_fallback_key=c.asm.Aa).apply(null,arguments)},c._olm_account_unpublished_fallback_key_length=function(){return(c._olm_account_unpublished_fallback_key_length=c.asm.Ba).apply(null,arguments)},c._olm_account_unpublished_fallback_key=function(){return(c._olm_account_unpublished_fallback_key=c.asm.Ca).apply(null,arguments)},c._olm_account_forget_old_fallback_key=function(){return(c._olm_account_forget_old_fallback_key=c.asm.Da).apply(null,arguments)},c._olm_create_outbound_session_random_length=function(){return(c._olm_create_outbound_session_random_length=c.asm.Ea).apply(null,arguments)},c._olm_create_outbound_session=function(){return(c._olm_create_outbound_session=c.asm.Fa).apply(null,arguments)},c._olm_create_inbound_session=function(){return(c._olm_create_inbound_session=c.asm.Ga).apply(null,arguments)},c._olm_create_inbound_session_from=function(){return(c._olm_create_inbound_session_from=c.asm.Ha).apply(null,arguments)},c._olm_session_id_length=function(){return(c._olm_session_id_length=c.asm.Ia).apply(null,arguments)},c._olm_session_id=function(){return(c._olm_session_id=c.asm.Ja).apply(null,arguments)},c._olm_session_has_received_message=function(){return(c._olm_session_has_received_message=c.asm.Ka).apply(null,arguments)},c._olm_session_describe=function(){return(c._olm_session_describe=c.asm.La).apply(null,arguments)},c._olm_matches_inbound_session=function(){return(c._olm_matches_inbound_session=c.asm.Ma).apply(null,arguments)},c._olm_matches_inbound_session_from=function(){return(c._olm_matches_inbound_session_from=c.asm.Na).apply(null,arguments)},c._olm_remove_one_time_keys=function(){return(c._olm_remove_one_time_keys=c.asm.Oa).apply(null,arguments)},c._olm_encrypt_message_type=function(){return(c._olm_encrypt_message_type=c.asm.Pa).apply(null,arguments)},c._olm_encrypt_random_length=function(){return(c._olm_encrypt_random_length=c.asm.Qa).apply(null,arguments)},c._olm_encrypt_message_length=function(){return(c._olm_encrypt_message_length=c.asm.Ra).apply(null,arguments)},c._olm_encrypt=function(){return(c._olm_encrypt=c.asm.Sa).apply(null,arguments)},c._olm_decrypt_max_plaintext_length=function(){return(c._olm_decrypt_max_plaintext_length=c.asm.Ta).apply(null,arguments)},c._olm_decrypt=function(){return(c._olm_decrypt=c.asm.Ua).apply(null,arguments)},c._olm_sha256_length=function(){return(c._olm_sha256_length=c.asm.Va).apply(null,arguments)},c._olm_sha256=function(){return(c._olm_sha256=c.asm.Wa).apply(null,arguments)},c._olm_ed25519_verify=function(){return(c._olm_ed25519_verify=c.asm.Xa).apply(null,arguments)},c._olm_inbound_group_session_size=function(){return(c._olm_inbound_group_session_size=c.asm.Ya).apply(null,arguments)},c._olm_inbound_group_session=function(){return(c._olm_inbound_group_session=c.asm.Za).apply(null,arguments)},c._olm_clear_inbound_group_session=function(){return(c._olm_clear_inbound_group_session=c.asm._a).apply(null,arguments)},c._olm_inbound_group_session_last_error=function(){return(c._olm_inbound_group_session_last_error=c.asm.$a).apply(null,arguments)},c._olm_inbound_group_session_last_error_code=function(){return(c._olm_inbound_group_session_last_error_code=c.asm.ab).apply(null,arguments)},c._olm_init_inbound_group_session=function(){return(c._olm_init_inbound_group_session=c.asm.bb).apply(null,arguments)},c._olm_import_inbound_group_session=function(){return(c._olm_import_inbound_group_session=c.asm.cb).apply(null,arguments)},c._olm_pickle_inbound_group_session_length=function(){return(c._olm_pickle_inbound_group_session_length=c.asm.db).apply(null,arguments)},c._olm_pickle_inbound_group_session=function(){return(c._olm_pickle_inbound_group_session=c.asm.eb).apply(null,arguments)},c._olm_unpickle_inbound_group_session=function(){return(c._olm_unpickle_inbound_group_session=c.asm.fb).apply(null,arguments)},c._olm_group_decrypt_max_plaintext_length=function(){return(c._olm_group_decrypt_max_plaintext_length=c.asm.gb).apply(null,arguments)},c._olm_group_decrypt=function(){return(c._olm_group_decrypt=c.asm.hb).apply(null,arguments)},c._olm_inbound_group_session_id_length=function(){return(c._olm_inbound_group_session_id_length=c.asm.ib).apply(null,arguments)},c._olm_inbound_group_session_id=function(){return(c._olm_inbound_group_session_id=c.asm.jb).apply(null,arguments)},c._olm_inbound_group_session_first_known_index=function(){return(c._olm_inbound_group_session_first_known_index=c.asm.kb).apply(null,arguments)},c._olm_inbound_group_session_is_verified=function(){return(c._olm_inbound_group_session_is_verified=c.asm.lb).apply(null,arguments)},c._olm_export_inbound_group_session_length=function(){return(c._olm_export_inbound_group_session_length=c.asm.mb).apply(null,arguments)},c._olm_export_inbound_group_session=function(){return(c._olm_export_inbound_group_session=c.asm.nb).apply(null,arguments)},c._olm_sas_last_error=function(){return(c._olm_sas_last_error=c.asm.ob).apply(null,arguments)},c._olm_sas_last_error_code=function(){return(c._olm_sas_last_error_code=c.asm.pb).apply(null,arguments)},c._olm_sas_size=function(){return(c._olm_sas_size=c.asm.qb).apply(null,arguments)},c._olm_sas=function(){return(c._olm_sas=c.asm.rb).apply(null,arguments)},c._olm_clear_sas=function(){return(c._olm_clear_sas=c.asm.sb).apply(null,arguments)},c._olm_create_sas_random_length=function(){return(c._olm_create_sas_random_length=c.asm.tb).apply(null,arguments)},c._olm_create_sas=function(){return(c._olm_create_sas=c.asm.ub).apply(null,arguments)},c._olm_sas_pubkey_length=function(){return(c._olm_sas_pubkey_length=c.asm.vb).apply(null,arguments)},c._olm_sas_get_pubkey=function(){return(c._olm_sas_get_pubkey=c.asm.wb).apply(null,arguments)},c._olm_sas_set_their_key=function(){return(c._olm_sas_set_their_key=c.asm.xb).apply(null,arguments)},c._olm_sas_is_their_key_set=function(){return(c._olm_sas_is_their_key_set=c.asm.yb).apply(null,arguments)},c._olm_sas_generate_bytes=function(){return(c._olm_sas_generate_bytes=c.asm.zb).apply(null,arguments)},c._olm_sas_mac_length=function(){return(c._olm_sas_mac_length=c.asm.Ab).apply(null,arguments)},c._olm_sas_calculate_mac_fixed_base64=function(){return(c._olm_sas_calculate_mac_fixed_base64=c.asm.Bb).apply(null,arguments)},c._olm_sas_calculate_mac=function(){return(c._olm_sas_calculate_mac=c.asm.Cb).apply(null,arguments)},c._olm_sas_calculate_mac_long_kdf=function(){return(c._olm_sas_calculate_mac_long_kdf=c.asm.Db).apply(null,arguments)},c._olm_outbound_group_session_size=function(){return(c._olm_outbound_group_session_size=c.asm.Eb).apply(null,arguments)},c._olm_outbound_group_session=function(){return(c._olm_outbound_group_session=c.asm.Fb).apply(null,arguments)},c._olm_clear_outbound_group_session=function(){return(c._olm_clear_outbound_group_session=c.asm.Gb).apply(null,arguments)},c._olm_outbound_group_session_last_error=function(){return(c._olm_outbound_group_session_last_error=c.asm.Hb).apply(null,arguments)},c._olm_outbound_group_session_last_error_code=function(){return(c._olm_outbound_group_session_last_error_code=c.asm.Ib).apply(null,arguments)},c._olm_pickle_outbound_group_session_length=function(){return(c._olm_pickle_outbound_group_session_length=c.asm.Jb).apply(null,arguments)},c._olm_pickle_outbound_group_session=function(){return(c._olm_pickle_outbound_group_session=c.asm.Kb).apply(null,arguments)},c._olm_unpickle_outbound_group_session=function(){return(c._olm_unpickle_outbound_group_session=c.asm.Lb).apply(null,arguments)},c._olm_init_outbound_group_session_random_length=function(){return(c._olm_init_outbound_group_session_random_length=c.asm.Mb).apply(null,arguments)},c._olm_init_outbound_group_session=function(){return(c._olm_init_outbound_group_session=c.asm.Nb).apply(null,arguments)},c._olm_group_encrypt_message_length=function(){return(c._olm_group_encrypt_message_length=c.asm.Ob).apply(null,arguments)},c._olm_group_encrypt=function(){return(c._olm_group_encrypt=c.asm.Pb).apply(null,arguments)},c._olm_outbound_group_session_id_length=function(){return(c._olm_outbound_group_session_id_length=c.asm.Qb).apply(null,arguments)},c._olm_outbound_group_session_id=function(){return(c._olm_outbound_group_session_id=c.asm.Rb).apply(null,arguments)},c._olm_outbound_group_session_message_index=function(){return(c._olm_outbound_group_session_message_index=c.asm.Sb).apply(null,arguments)},c._olm_outbound_group_session_key_length=function(){return(c._olm_outbound_group_session_key_length=c.asm.Tb).apply(null,arguments)},c._olm_outbound_group_session_key=function(){return(c._olm_outbound_group_session_key=c.asm.Ub).apply(null,arguments)},c._malloc=function(){return(c._malloc=c.asm.Vb).apply(null,arguments)},c._free=function(){return(c._free=c.asm.Wb).apply(null,arguments)};var hc=c.stackSave=function(){return(hc=c.stackSave=c.asm.Xb).apply(null,arguments)},qr=c.stackRestore=function(){return(qr=c.stackRestore=c.asm.Yb).apply(null,arguments)},fc=c.stackAlloc=function(){return(fc=c.stackAlloc=c.asm.Zb).apply(null,arguments)};c.ALLOC_STACK=1;var v;ot=function p(){v||d(),v||(ot=p)};function d(){function p(){if(!v&&(v=!0,c.calledRun=!0,!Vt)){if(Ht(dr),g(c),c.onRuntimeInitialized&&c.onRuntimeInitialized(),c.postRun)for(typeof c.postRun=="function"&&(c.postRun=[c.postRun]);c.postRun.length;){var y=c.postRun.shift();At.unshift(y)}Ht(At)}}if(!(0<Sr)){if(c.preRun)for(typeof c.preRun=="function"&&(c.preRun=[c.preRun]);c.preRun.length;)hr();Ht(_),0<Sr||(c.setStatus?(c.setStatus("Running..."),setTimeout(function(){setTimeout(function(){c.setStatus("")},1),p()},1)):p())}}if(c.run=d,c.preInit)for(typeof c.preInit=="function"&&(c.preInit=[c.preInit]);0<c.preInit.length;)c.preInit.pop()();d();function h(){var p=c._olm_outbound_group_session_size();this.ac=Ve(p),this.$b=c._olm_outbound_group_session(this.ac)}function b(p){return function(){var y=p.apply(this,arguments);if(y===nn)throw y=Q(c._olm_outbound_group_session_last_error(arguments[0])),Error("OLM."+y);return y}}h.prototype.free=function(){c._olm_clear_outbound_group_session(this.$b),Ge(this.$b)},h.prototype.pickle=z(function(p){p=ce(p);var y=b(c._olm_pickle_outbound_group_session_length)(this.$b),O=j(p),x=j(y+1);try{b(c._olm_pickle_outbound_group_session)(this.$b,O,p.length,x,y)}finally{for(le(O,p.length),O=0;O<p.length;O++)p[O]=0}return Q(x,y)}),h.prototype.unpickle=z(function(p,y){p=ce(p);var O=j(p);y=ce(y);var x=j(y);try{b(c._olm_unpickle_outbound_group_session)(this.$b,O,p.length,x,y.length)}finally{for(le(O,p.length),O=0;O<p.length;O++)p[O]=0}}),h.prototype.create=z(function(){var p=b(c._olm_init_outbound_group_session_random_length)(this.$b),y=br(p,f);try{b(c._olm_init_outbound_group_session)(this.$b,y,p)}finally{le(y,p)}}),h.prototype.encrypt=function(p){try{var y=Kr(p),O=b(c._olm_group_encrypt_message_length)(this.$b,y),x=Ve(y+1);rn(p,$e,x,y+1);var K=Ve(O+1);return b(c._olm_group_encrypt)(this.$b,x,y,K,O),we(K+O),Q(K,O)}finally{x!==void 0&&(le(x,y+1),Ge(x)),K!==void 0&&Ge(K)}},h.prototype.session_id=z(function(){var p=b(c._olm_outbound_group_session_id_length)(this.$b),y=j(p+1);return b(c._olm_outbound_group_session_id)(this.$b,y,p),Q(y,p)}),h.prototype.session_key=z(function(){var p=b(c._olm_outbound_group_session_key_length)(this.$b),y=j(p+1);b(c._olm_outbound_group_session_key)(this.$b,y,p);var O=Q(y,p);return le(y,p),O}),h.prototype.message_index=function(){return b(c._olm_outbound_group_session_message_index)(this.$b)},r.OutboundGroupSession=h;function P(){var p=c._olm_inbound_group_session_size();this.ac=Ve(p),this.$b=c._olm_inbound_group_session(this.ac)}function A(p){return function(){var y=p.apply(this,arguments);if(y===nn)throw y=Q(c._olm_inbound_group_session_last_error(arguments[0])),Error("OLM."+y);return y}}P.prototype.free=function(){c._olm_clear_inbound_group_session(this.$b),Ge(this.$b)},P.prototype.pickle=z(function(p){p=ce(p);var y=A(c._olm_pickle_inbound_group_session_length)(this.$b),O=j(p),x=j(y+1);try{A(c._olm_pickle_inbound_group_session)(this.$b,O,p.length,x,y)}finally{for(le(O,p.length),O=0;O<p.length;O++)p[O]=0}return Q(x,y)}),P.prototype.unpickle=z(function(p,y){p=ce(p);var O=j(p);y=ce(y);var x=j(y);try{A(c._olm_unpickle_inbound_group_session)(this.$b,O,p.length,x,y.length)}finally{for(le(O,p.length),O=0;O<p.length;O++)p[O]=0}}),P.prototype.create=z(function(p){p=ce(p);var y=j(p);try{A(c._olm_init_inbound_group_session)(this.$b,y,p.length)}finally{for(le(y,p.length),y=0;y<p.length;y++)p[y]=0}}),P.prototype.import_session=z(function(p){p=ce(p);var y=j(p);try{A(c._olm_import_inbound_group_session)(this.$b,y,p.length)}finally{for(le(y,p.length),y=0;y<p.length;y++)p[y]=0}}),P.prototype.decrypt=z(function(p){try{var y=Ve(p.length);di(p,y);var O=A(c._olm_group_decrypt_max_plaintext_length)(this.$b,y,p.length);di(p,y);var x=Ve(O+1),K=j(4),ee=A(c._olm_group_decrypt)(this.$b,y,p.length,x,O,K);return we(x+ee),{plaintext:Q(x,ee),message_index:Te(K,"i32")}}finally{y!==void 0&&Ge(y),x!==void 0&&(le(x,ee),Ge(x))}}),P.prototype.session_id=z(function(){var p=A(c._olm_inbound_group_session_id_length)(this.$b),y=j(p+1);return A(c._olm_inbound_group_session_id)(this.$b,y,p),Q(y,p)}),P.prototype.first_known_index=z(function(){return A(c._olm_inbound_group_session_first_known_index)(this.$b)}),P.prototype.export_session=z(function(p){var y=A(c._olm_export_inbound_group_session_length)(this.$b),O=j(y+1);return b(c._olm_export_inbound_group_session)(this.$b,O,y,p),p=Q(O,y),le(O,y),p}),r.InboundGroupSession=P;function $(){var p=c._olm_pk_encryption_size();this.ac=Ve(p),this.$b=c._olm_pk_encryption(this.ac)}function ne(p){return function(){var y=p.apply(this,arguments);if(y===nn)throw y=Q(c._olm_pk_encryption_last_error(arguments[0])),Error("OLM."+y);return y}}$.prototype.free=function(){c._olm_clear_pk_encryption(this.$b),Ge(this.$b)},$.prototype.set_recipient_key=z(function(p){p=ce(p);var y=j(p);ne(c._olm_pk_encryption_set_recipient_key)(this.$b,y,p.length)}),$.prototype.encrypt=z(function(p){try{var y=Kr(p),O=Ve(y+1);rn(p,$e,O,y+1);var x=ne(c._olm_pk_encrypt_random_length)(),K=br(x,f),ee=ne(c._olm_pk_ciphertext_length)(this.$b,y),_e=Ve(ee+1),Dt=ne(c._olm_pk_mac_length)(this.$b),Ho=j(Dt+1);we(Ho+Dt);var Ki=ne(c._olm_pk_key_length)(),sn=j(Ki+1);return we(sn+Ki),ne(c._olm_pk_encrypt)(this.$b,O,y,_e,ee,Ho,Dt,sn,Ki,K,x),we(_e+ee),{ciphertext:Q(_e,ee),mac:Q(Ho,Dt),ephemeral:Q(sn,Ki)}}finally{K!==void 0&&le(K,x),O!==void 0&&(le(O,y+1),Ge(O)),_e!==void 0&&Ge(_e)}});function Ie(){var p=c._olm_pk_decryption_size();this.ac=Ve(p),this.$b=c._olm_pk_decryption(this.ac)}function de(p){return function(){var y=p.apply(this,arguments);if(y===nn)throw y=Q(c._olm_pk_decryption_last_error(arguments[0])),Error("OLM."+y);return y}}Ie.prototype.free=function(){c._olm_clear_pk_decryption(this.$b),Ge(this.$b)},Ie.prototype.init_with_private_key=z(function(p){var y=j(p.length);c.HEAPU8.set(p,y);var O=de(c._olm_pk_key_length)(),x=j(O+1);try{de(c._olm_pk_key_from_private)(this.$b,x,O,y,p.length)}finally{le(y,p.length)}return Q(x,O)}),Ie.prototype.generate_key=z(function(){var p=de(c._olm_pk_private_key_length)(),y=br(p,f),O=de(c._olm_pk_key_length)(),x=j(O+1);try{de(c._olm_pk_key_from_private)(this.$b,x,O,y,p)}finally{le(y,p)}return Q(x,O)}),Ie.prototype.get_private_key=z(function(){var p=ne(c._olm_pk_private_key_length)(),y=j(p);de(c._olm_pk_get_private_key)(this.$b,y,p);var O=new Uint8Array(new Uint8Array(c.HEAPU8.buffer,y,p));return le(y,p),O}),Ie.prototype.pickle=z(function(p){p=ce(p);var y=de(c._olm_pickle_pk_decryption_length)(this.$b),O=j(p),x=j(y+1);try{de(c._olm_pickle_pk_decryption)(this.$b,O,p.length,x,y)}finally{for(le(O,p.length),O=0;O<p.length;O++)p[O]=0}return Q(x,y)}),Ie.prototype.unpickle=z(function(p,y){p=ce(p);var O=j(p),x=ce(y),K=j(x);y=de(c._olm_pk_key_length)();var ee=j(y+1);try{de(c._olm_unpickle_pk_decryption)(this.$b,O,p.length,K,x.length,ee,y)}finally{for(le(O,p.length),O=0;O<p.length;O++)p[O]=0}return Q(ee,y)}),Ie.prototype.decrypt=z(function(p,y,O){try{var x=Kr(O),K=Ve(x+1);rn(O,$e,K,x+1);var ee=ce(p),_e=j(ee),Dt=ce(y),Ho=j(Dt),Ki=de(c._olm_pk_max_plaintext_length)(this.$b,x),sn=Ve(Ki+1),_u=de(c._olm_pk_decrypt)(this.$b,_e,ee.length,Ho,Dt.length,K,x,sn,Ki);return we(sn+_u),Q(sn,_u)}finally{sn!==void 0&&(le(sn,_u+1),Ge(sn)),K!==void 0&&Ge(K)}});function ke(){var p=c._olm_pk_signing_size();this.ac=Ve(p),this.$b=c._olm_pk_signing(this.ac)}function ve(p){return function(){var y=p.apply(this,arguments);if(y===nn)throw y=Q(c._olm_pk_signing_last_error(arguments[0])),Error("OLM."+y);return y}}ke.prototype.free=function(){c._olm_clear_pk_signing(this.$b),Ge(this.$b)},ke.prototype.init_with_seed=z(function(p){var y=j(p.length);c.HEAPU8.set(p,y);var O=ve(c._olm_pk_signing_public_key_length)(),x=j(O+1);try{ve(c._olm_pk_signing_key_from_seed)(this.$b,x,O,y,p.length)}finally{le(y,p.length)}return Q(x,O)}),ke.prototype.generate_seed=z(function(){var p=ve(c._olm_pk_signing_seed_length)(),y=br(p,f),O=new Uint8Array(new Uint8Array(c.HEAPU8.buffer,y,p));return le(y,p),O}),ke.prototype.sign=z(function(p){try{var y=Kr(p),O=Ve(y+1);rn(p,$e,O,y+1);var x=ve(c._olm_pk_signature_length)(),K=j(x+1);return ve(c._olm_pk_sign)(this.$b,O,y,K,x),Q(K,x)}finally{O!==void 0&&(le(O,y+1),Ge(O))}});function mi(){var p=c._olm_sas_size(),y=c._olm_create_sas_random_length(),O=br(y,f);this.ac=Ve(p),this.$b=c._olm_sas(this.ac),c._olm_create_sas(this.$b,O,y),le(O,y)}function An(p){return function(){var y=p.apply(this,arguments);if(y===nn)throw y=Q(c._olm_sas_last_error(arguments[0])),Error("OLM."+y);return y}}mi.prototype.free=function(){c._olm_clear_sas(this.$b),Ge(this.$b)},mi.prototype.get_pubkey=z(function(){var p=An(c._olm_sas_pubkey_length)(this.$b),y=j(p+1);return An(c._olm_sas_get_pubkey)(this.$b,y,p),Q(y,p)}),mi.prototype.set_their_key=z(function(p){p=ce(p);var y=j(p);An(c._olm_sas_set_their_key)(this.$b,y,p.length)}),mi.prototype.is_their_key_set=z(function(){return!!An(c._olm_sas_is_their_key_set)(this.$b)}),mi.prototype.generate_bytes=z(function(p,y){p=ce(p);var O=j(p),x=j(y);return An(c._olm_sas_generate_bytes)(this.$b,O,p.length,x,y),new Uint8Array(new Uint8Array(c.HEAPU8.buffer,x,y))}),mi.prototype.calculate_mac=z(function(p,y){p=ce(p);var O=j(p);y=ce(y);var x=j(y),K=An(c._olm_sas_mac_length)(this.$b),ee=j(K+1);return An(c._olm_sas_calculate_mac)(this.$b,O,p.length,x,y.length,ee,K),Q(ee,K)}),mi.prototype.calculate_mac_long_kdf=z(function(p,y){p=ce(p);var O=j(p);y=ce(y);var x=j(y),K=An(c._olm_sas_mac_length)(this.$b),ee=j(K+1);return An(c._olm_sas_calculate_mac_long_kdf)(this.$b,O,p.length,x,y.length,ee,K),Q(ee,K)});var Ve=c._malloc,Ge=c._free,nn;function br(p,y){var O=fc(p);return y(new Uint8Array(c.HEAPU8.buffer,O,p)),O}function j(p){return typeof p=="number"?br(p,function(y){y.fill(0)}):br(p.length,function(y){y.set(p)})}function ce(p){if(p instanceof Uint8Array)var y=p;else y=Array(Kr(p)+1),p=rn(p,y,0,y.length),y.length=p;return y}function z(p){return function(){var y=hc();try{return p.apply(this,arguments)}finally{qr(y)}}}function le(p,y){for(;0<y--;)c.HEAP8[p++]=0}function Rt(){var p=c._olm_account_size();this.ac=Ve(p),this.$b=c._olm_account(this.ac)}function We(p){return function(){var y=p.apply(this,arguments);if(y===nn)throw y=Q(c._olm_account_last_error(arguments[0])),Error("OLM."+y);return y}}Rt.prototype.free=function(){c._olm_clear_account(this.$b),Ge(this.$b)},Rt.prototype.create=z(function(){var p=We(c._olm_create_account_random_length)(this.$b),y=br(p,f);try{We(c._olm_create_account)(this.$b,y,p)}finally{le(y,p)}}),Rt.prototype.identity_keys=z(function(){var p=We(c._olm_account_identity_keys_length)(this.$b),y=j(p+1);return We(c._olm_account_identity_keys)(this.$b,y,p),Q(y,p)}),Rt.prototype.sign=z(function(p){var y=We(c._olm_account_signature_length)(this.$b);p=ce(p);var O=j(p),x=j(y+1);try{We(c._olm_account_sign)(this.$b,O,p.length,x,y)}finally{for(le(O,p.length),O=0;O<p.length;O++)p[O]=0}return Q(x,y)}),Rt.prototype.one_time_keys=z(function(){var p=We(c._olm_account_one_time_keys_length)(this.$b),y=j(p+1);return We(c._olm_account_one_time_keys)(this.$b,y,p),Q(y,p)}),Rt.prototype.mark_keys_as_published=z(function(){We(c._olm_account_mark_keys_as_published)(this.$b)}),Rt.prototype.max_number_of_one_time_keys=z(function(){return We(c._olm_account_max_number_of_one_time_keys)(this.$b)}),Rt.prototype.generate_one_time_keys=z(function(p){var y=We(c._olm_account_generate_one_time_keys_random_length)(this.$b,p),O=br(y,f);try{We(c._olm_account_generate_one_time_keys)(this.$b,p,O,y)}finally{le(O,y)}}),Rt.prototype.remove_one_time_keys=z(function(p){We(c._olm_remove_one_time_keys)(this.$b,p.$b)}),Rt.prototype.generate_fallback_key=z(function(){var p=We(c._olm_account_generate_fallback_key_random_length)(this.$b),y=br(p,f);try{We(c._olm_account_generate_fallback_key)(this.$b,y,p)}finally{le(y,p)}}),Rt.prototype.fallback_key=z(function(){var p=We(c._olm_account_fallback_key_length)(this.$b),y=j(p+1);return We(c._olm_account_fallback_key)(this.$b,y,p),Q(y,p)}),Rt.prototype.unpublished_fallback_key=z(function(){var p=We(c._olm_account_unpublished_fallback_key_length)(this.$b),y=j(p+1);return We(c._olm_account_unpublished_fallback_key)(this.$b,y,p),Q(y,p)}),Rt.prototype.forget_old_fallback_key=z(function(){We(c._olm_account_forget_old_fallback_key)(this.$b)}),Rt.prototype.pickle=z(function(p){p=ce(p);var y=We(c._olm_pickle_account_length)(this.$b),O=j(p),x=j(y+1);try{We(c._olm_pickle_account)(this.$b,O,p.length,x,y)}finally{for(le(O,p.length),O=0;O<p.length;O++)p[O]=0}return Q(x,y)}),Rt.prototype.unpickle=z(function(p,y){p=ce(p);var O=j(p);y=ce(y);var x=j(y);try{We(c._olm_unpickle_account)(this.$b,O,p.length,x,y.length)}finally{for(le(O,p.length),O=0;O<p.length;O++)p[O]=0}});function Yt(){var p=c._olm_session_size();this.ac=Ve(p),this.$b=c._olm_session(this.ac)}function ct(p){return function(){var y=p.apply(this,arguments);if(y===nn)throw y=Q(c._olm_session_last_error(arguments[0])),Error("OLM."+y);return y}}Yt.prototype.free=function(){c._olm_clear_session(this.$b),Ge(this.$b)},Yt.prototype.pickle=z(function(p){p=ce(p);var y=ct(c._olm_pickle_session_length)(this.$b),O=j(p),x=j(y+1);try{ct(c._olm_pickle_session)(this.$b,O,p.length,x,y)}finally{for(le(O,p.length),O=0;O<p.length;O++)p[O]=0}return Q(x,y)}),Yt.prototype.unpickle=z(function(p,y){p=ce(p);var O=j(p);y=ce(y);var x=j(y);try{ct(c._olm_unpickle_session)(this.$b,O,p.length,x,y.length)}finally{for(le(O,p.length),O=0;O<p.length;O++)p[O]=0}}),Yt.prototype.create_outbound=z(function(p,y,O){var x=ct(c._olm_create_outbound_session_random_length)(this.$b),K=br(x,f);y=ce(y),O=ce(O);var ee=j(y),_e=j(O);try{ct(c._olm_create_outbound_session)(this.$b,p.$b,ee,y.length,_e,O.length,K,x)}finally{le(K,x)}}),Yt.prototype.create_inbound=z(function(p,y){y=ce(y);var O=j(y);try{ct(c._olm_create_inbound_session)(this.$b,p.$b,O,y.length)}finally{for(le(O,y.length),p=0;p<y.length;p++)y[p]=0}}),Yt.prototype.create_inbound_from=z(function(p,y,O){y=ce(y);var x=j(y);O=ce(O);var K=j(O);try{ct(c._olm_create_inbound_session_from)(this.$b,p.$b,x,y.length,K,O.length)}finally{for(le(K,O.length),p=0;p<O.length;p++)O[p]=0}}),Yt.prototype.session_id=z(function(){var p=ct(c._olm_session_id_length)(this.$b),y=j(p+1);return ct(c._olm_session_id)(this.$b,y,p),Q(y,p)}),Yt.prototype.has_received_message=function(){return!!ct(c._olm_session_has_received_message)(this.$b)},Yt.prototype.matches_inbound=z(function(p){p=ce(p);var y=j(p);return!!ct(c._olm_matches_inbound_session)(this.$b,y,p.length)}),Yt.prototype.matches_inbound_from=z(function(p,y){p=ce(p);var O=j(p);y=ce(y);var x=j(y);return!!ct(c._olm_matches_inbound_session_from)(this.$b,O,p.length,x,y.length)}),Yt.prototype.encrypt=z(function(p){try{var y=ct(c._olm_encrypt_random_length)(this.$b),O=ct(c._olm_encrypt_message_type)(this.$b),x=Kr(p),K=ct(c._olm_encrypt_message_length)(this.$b,x),ee=br(y,f),_e=Ve(x+1);rn(p,$e,_e,x+1);var Dt=Ve(K+1);return ct(c._olm_encrypt)(this.$b,_e,x,ee,y,Dt,K),we(Dt+K),{type:O,body:Q(Dt,K)}}finally{ee!==void 0&&le(ee,y),_e!==void 0&&(le(_e,x+1),Ge(_e)),Dt!==void 0&&Ge(Dt)}}),Yt.prototype.decrypt=z(function(p,y){try{var O=Ve(y.length);di(y,O);var x=ct(c._olm_decrypt_max_plaintext_length)(this.$b,p,O,y.length);di(y,O);var K=Ve(x+1),ee=ct(c._olm_decrypt)(this.$b,p,O,y.length,K,x);return we(K+ee),Q(K,ee)}finally{O!==void 0&&Ge(O),K!==void 0&&(le(K,x),Ge(K))}}),Yt.prototype.describe=z(function(){try{var p=Ve(256);return ct(c._olm_session_describe)(this.$b,p,256),Q(p)}finally{p!==void 0&&Ge(p)}});function pc(){var p=c._olm_utility_size();this.ac=Ve(p),this.$b=c._olm_utility(this.ac)}function vu(p){return function(){var y=p.apply(this,arguments);if(y===nn)throw y=Q(c._olm_utility_last_error(arguments[0])),Error("OLM."+y);return y}}return pc.prototype.free=function(){c._olm_clear_utility(this.$b),Ge(this.$b)},pc.prototype.sha256=z(function(p){var y=vu(c._olm_sha256_length)(this.$b);p=ce(p);var O=j(p),x=j(y+1);try{vu(c._olm_sha256)(this.$b,O,p.length,x,y)}finally{for(le(O,p.length),O=0;O<p.length;O++)p[O]=0}return Q(x,y)}),pc.prototype.ed25519_verify=z(function(p,y,O){p=ce(p);var x=j(p);y=ce(y);var K=j(y);O=ce(O);var ee=j(O);try{vu(c._olm_ed25519_verify)(this.$b,x,p.length,K,y.length,ee,O.length)}finally{for(le(K,y.length),p=0;p<y.length;p++)y[p]=0}}),r.Account=Rt,r.Session=Yt,r.Utility=pc,r.PkEncryption=$,r.PkDecryption=Ie,r.PkSigning=ke,r.SAS=mi,r.get_library_version=z(function(){var p=j(3);return c._olm_get_library_version(p,p+1,p+2),[Te(p,"i8"),Te(p+1,"i8"),Te(p+2,"i8")]}),u.ready}}();n.exports=o;var a;return r.init=function(l){return a||(l&&(OLM_OPTIONS=l),a=new Promise(function(u,c){i=function(){u()},s=function(g){c(g)},o()}),a)},r}();typeof window!="undefined"&&(window.Olm=t),n.exports=t;// @license-end
+})(V_);var bD=V_.exports;export{gD as B,Ao as D,pl as E,ly as F,mD as L,fA as M,bD as O,yD as P,pD as R,So as S,_D as W,JE as a,nS as b,dA as c,Ck as d,SD as e,jE as f,Ta as g,XE as j,Fl as l,ED as o,KE as u};
diff --git a/pr-121/assets/vendor.d4008ec4.js b/pr-121/assets/vendor.d4008ec4.js
@@ -1,26 +0,0 @@
-var A_=Object.defineProperty,D_=Object.defineProperties;var U_=Object.getOwnPropertyDescriptors;var wf=Object.getOwnPropertySymbols;var $_=Object.prototype.hasOwnProperty,x_=Object.prototype.propertyIsEnumerable;var Rf=(n,e,t)=>e in n?A_(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,uc=(n,e)=>{for(var t in e||(e={}))$_.call(e,t)&&Rf(n,t,e[t]);if(wf)for(var t of wf(e))x_.call(e,t)&&Rf(n,t,e[t]);return n},If=(n,e)=>D_(n,U_(e));var Ga,J,Tm,Om,Ea,km,Tf,Cm,ol={},Pm=[],N_=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function zn(n,e){for(var t in e)n[t]=e[t];return n}function Mm(n){var e=n.parentNode;e&&e.removeChild(n)}function cr(n,e,t){var r,i,s,o={};for(s in e)s=="key"?r=e[s]:s=="ref"?i=e[s]:o[s]=e[s];if(arguments.length>2&&(o.children=arguments.length>3?Ga.call(arguments,2):t),typeof n=="function"&&n.defaultProps!=null)for(s in n.defaultProps)o[s]===void 0&&(o[s]=n.defaultProps[s]);return Sa(n,o,r,i,null)}function Sa(n,e,t,r,i){var s={type:n,props:e,key:t,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:i==null?++Tm:i};return i==null&&J.vnode!=null&&J.vnode(s),s}function Dh(){return{current:null}}function Zr(n){return n.children}function Er(n,e){this.props=n,this.context=e}function mo(n,e){if(e==null)return n.__?mo(n.__,n.__.__k.indexOf(n)+1):null;for(var t;e<n.__k.length;e++)if((t=n.__k[e])!=null&&t.__e!=null)return t.__e;return typeof n.type=="function"?mo(n):null}function Am(n){var e,t;if((n=n.__)!=null&&n.__c!=null){for(n.__e=n.__c.base=null,e=0;e<n.__k.length;e++)if((t=n.__k[e])!=null&&t.__e!=null){n.__e=n.__c.base=t.__e;break}return Am(n)}}function gd(n){(!n.__d&&(n.__d=!0)&&Ea.push(n)&&!al.__r++||Tf!==J.debounceRendering)&&((Tf=J.debounceRendering)||km)(al)}function al(){for(var n;al.__r=Ea.length;)n=Ea.sort(function(e,t){return e.__v.__b-t.__v.__b}),Ea=[],n.some(function(e){var t,r,i,s,o,c;e.__d&&(o=(s=(t=e).__v).__e,(c=t.__P)&&(r=[],(i=zn({},s)).__v=s.__v+1,Uh(c,s,i,t.__n,c.ownerSVGElement!==void 0,s.__h!=null?[o]:null,r,o==null?mo(s):o,s.__h),xm(r,s),s.__e!=o&&Am(s)))})}function Dm(n,e,t,r,i,s,o,c,l,u){var a,g,m,p,E,I,w,k=r&&r.__k||Pm,P=k.length;for(t.__k=[],a=0;a<e.length;a++)if((p=t.__k[a]=(p=e[a])==null||typeof p=="boolean"?null:typeof p=="string"||typeof p=="number"||typeof p=="bigint"?Sa(null,p,null,null,p):Array.isArray(p)?Sa(Zr,{children:p},null,null,null):p.__b>0?Sa(p.type,p.props,p.key,null,p.__v):p)!=null){if(p.__=t,p.__b=t.__b+1,(m=k[a])===null||m&&p.key==m.key&&p.type===m.type)k[a]=void 0;else for(g=0;g<P;g++){if((m=k[g])&&p.key==m.key&&p.type===m.type){k[g]=void 0;break}m=null}Uh(n,p,m=m||ol,i,s,o,c,l,u),E=p.__e,(g=p.ref)&&m.ref!=g&&(w||(w=[]),m.ref&&w.push(m.ref,null,p),w.push(g,p.__c||E,p)),E!=null?(I==null&&(I=E),typeof p.type=="function"&&p.__k===m.__k?p.__d=l=Um(p,l,n):l=$m(n,p,m,k,E,l),typeof t.type=="function"&&(t.__d=l)):l&&m.__e==l&&l.parentNode!=n&&(l=mo(m))}for(t.__e=I,a=P;a--;)k[a]!=null&&(typeof t.type=="function"&&k[a].__e!=null&&k[a].__e==t.__d&&(t.__d=mo(r,a+1)),Lm(k[a],k[a]));if(w)for(a=0;a<w.length;a++)Nm(w[a],w[++a],w[++a])}function Um(n,e,t){for(var r,i=n.__k,s=0;i&&s<i.length;s++)(r=i[s])&&(r.__=n,e=typeof r.type=="function"?Um(r,e,t):$m(t,r,r,i,r.__e,e));return e}function Nr(n,e){return e=e||[],n==null||typeof n=="boolean"||(Array.isArray(n)?n.some(function(t){Nr(t,e)}):e.push(n)),e}function $m(n,e,t,r,i,s){var o,c,l;if(e.__d!==void 0)o=e.__d,e.__d=void 0;else if(t==null||i!=s||i.parentNode==null)e:if(s==null||s.parentNode!==n)n.appendChild(i),o=null;else{for(c=s,l=0;(c=c.nextSibling)&&l<r.length;l+=2)if(c==i)break e;n.insertBefore(i,s),o=s}return o!==void 0?o:i.nextSibling}function L_(n,e,t,r,i){var s;for(s in t)s==="children"||s==="key"||s in e||cl(n,s,null,t[s],r);for(s in e)i&&typeof e[s]!="function"||s==="children"||s==="key"||s==="value"||s==="checked"||t[s]===e[s]||cl(n,s,e[s],t[s],r)}function Of(n,e,t){e[0]==="-"?n.setProperty(e,t):n[e]=t==null?"":typeof t!="number"||N_.test(e)?t:t+"px"}function cl(n,e,t,r,i){var s;e:if(e==="style")if(typeof t=="string")n.style.cssText=t;else{if(typeof r=="string"&&(n.style.cssText=r=""),r)for(e in r)t&&e in t||Of(n.style,e,"");if(t)for(e in t)r&&t[e]===r[e]||Of(n.style,e,t[e])}else if(e[0]==="o"&&e[1]==="n")s=e!==(e=e.replace(/Capture$/,"")),e=e.toLowerCase()in n?e.toLowerCase().slice(2):e.slice(2),n.l||(n.l={}),n.l[e+s]=t,t?r||n.addEventListener(e,s?Cf:kf,s):n.removeEventListener(e,s?Cf:kf,s);else if(e!=="dangerouslySetInnerHTML"){if(i)e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!=="href"&&e!=="list"&&e!=="form"&&e!=="tabIndex"&&e!=="download"&&e in n)try{n[e]=t==null?"":t;break e}catch{}typeof t=="function"||(t!=null&&(t!==!1||e[0]==="a"&&e[1]==="r")?n.setAttribute(e,t):n.removeAttribute(e))}}function kf(n){this.l[n.type+!1](J.event?J.event(n):n)}function Cf(n){this.l[n.type+!0](J.event?J.event(n):n)}function Uh(n,e,t,r,i,s,o,c,l){var u,a,g,m,p,E,I,w,k,P,S,T=e.type;if(e.constructor!==void 0)return null;t.__h!=null&&(l=t.__h,c=e.__e=t.__e,e.__h=null,s=[c]),(u=J.__b)&&u(e);try{e:if(typeof T=="function"){if(w=e.props,k=(u=T.contextType)&&r[u.__c],P=u?k?k.props.value:u.__:r,t.__c?I=(a=e.__c=t.__c).__=a.__E:("prototype"in T&&T.prototype.render?e.__c=a=new T(w,P):(e.__c=a=new Er(w,P),a.constructor=T,a.render=K_),k&&k.sub(a),a.props=w,a.state||(a.state={}),a.context=P,a.__n=r,g=a.__d=!0,a.__h=[]),a.__s==null&&(a.__s=a.state),T.getDerivedStateFromProps!=null&&(a.__s==a.state&&(a.__s=zn({},a.__s)),zn(a.__s,T.getDerivedStateFromProps(w,a.__s))),m=a.props,p=a.state,g)T.getDerivedStateFromProps==null&&a.componentWillMount!=null&&a.componentWillMount(),a.componentDidMount!=null&&a.__h.push(a.componentDidMount);else{if(T.getDerivedStateFromProps==null&&w!==m&&a.componentWillReceiveProps!=null&&a.componentWillReceiveProps(w,P),!a.__e&&a.shouldComponentUpdate!=null&&a.shouldComponentUpdate(w,a.__s,P)===!1||e.__v===t.__v){a.props=w,a.state=a.__s,e.__v!==t.__v&&(a.__d=!1),a.__v=e,e.__e=t.__e,e.__k=t.__k,e.__k.forEach(function(D){D&&(D.__=e)}),a.__h.length&&o.push(a);break e}a.componentWillUpdate!=null&&a.componentWillUpdate(w,a.__s,P),a.componentDidUpdate!=null&&a.__h.push(function(){a.componentDidUpdate(m,p,E)})}a.context=P,a.props=w,a.state=a.__s,(u=J.__r)&&u(e),a.__d=!1,a.__v=e,a.__P=n,u=a.render(a.props,a.state,a.context),a.state=a.__s,a.getChildContext!=null&&(r=zn(zn({},r),a.getChildContext())),g||a.getSnapshotBeforeUpdate==null||(E=a.getSnapshotBeforeUpdate(m,p)),S=u!=null&&u.type===Zr&&u.key==null?u.props.children:u,Dm(n,Array.isArray(S)?S:[S],e,t,r,i,s,o,c,l),a.base=e.__e,e.__h=null,a.__h.length&&o.push(a),I&&(a.__E=a.__=null),a.__e=!1}else s==null&&e.__v===t.__v?(e.__k=t.__k,e.__e=t.__e):e.__e=B_(t.__e,e,t,r,i,s,o,l);(u=J.diffed)&&u(e)}catch(D){e.__v=null,(l||s!=null)&&(e.__e=c,e.__h=!!l,s[s.indexOf(c)]=null),J.__e(D,e,t)}}function xm(n,e){J.__c&&J.__c(e,n),n.some(function(t){try{n=t.__h,t.__h=[],n.some(function(r){r.call(t)})}catch(r){J.__e(r,t.__v)}})}function B_(n,e,t,r,i,s,o,c){var l,u,a,g=t.props,m=e.props,p=e.type,E=0;if(p==="svg"&&(i=!0),s!=null){for(;E<s.length;E++)if((l=s[E])&&"setAttribute"in l==!!p&&(p?l.localName===p:l.nodeType===3)){n=l,s[E]=null;break}}if(n==null){if(p===null)return document.createTextNode(m);n=i?document.createElementNS("http://www.w3.org/2000/svg",p):document.createElement(p,m.is&&m),s=null,c=!1}if(p===null)g===m||c&&n.data===m||(n.data=m);else{if(s=s&&Ga.call(n.childNodes),u=(g=t.props||ol).dangerouslySetInnerHTML,a=m.dangerouslySetInnerHTML,!c){if(s!=null)for(g={},E=0;E<n.attributes.length;E++)g[n.attributes[E].name]=n.attributes[E].value;(a||u)&&(a&&(u&&a.__html==u.__html||a.__html===n.innerHTML)||(n.innerHTML=a&&a.__html||""))}if(L_(n,m,g,i,c),a)e.__k=[];else if(E=e.props.children,Dm(n,Array.isArray(E)?E:[E],e,t,r,i&&p!=="foreignObject",s,o,s?s[0]:t.__k&&mo(t,0),c),s!=null)for(E=s.length;E--;)s[E]!=null&&Mm(s[E]);c||("value"in m&&(E=m.value)!==void 0&&(E!==n.value||p==="progress"&&!E||p==="option"&&E!==g.value)&&cl(n,"value",E,g.value,!1),"checked"in m&&(E=m.checked)!==void 0&&E!==n.checked&&cl(n,"checked",E,g.checked,!1))}return n}function Nm(n,e,t){try{typeof n=="function"?n(e):n.current=e}catch(r){J.__e(r,t)}}function Lm(n,e,t){var r,i;if(J.unmount&&J.unmount(n),(r=n.ref)&&(r.current&&r.current!==n.__e||Nm(r,null,e)),(r=n.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(s){J.__e(s,e)}r.base=r.__P=null}if(r=n.__k)for(i=0;i<r.length;i++)r[i]&&Lm(r[i],e,typeof n.type!="function");t||n.__e==null||Mm(n.__e),n.__e=n.__d=void 0}function K_(n,e,t){return this.constructor(n,t)}function yo(n,e,t){var r,i,s;J.__&&J.__(n,e),i=(r=typeof t=="function")?null:t&&t.__k||e.__k,s=[],Uh(e,n=(!r&&t||e).__k=cr(Zr,null,[n]),i||ol,ol,e.ownerSVGElement!==void 0,!r&&t?[t]:i?null:e.firstChild?Ga.call(e.childNodes):null,s,!r&&t?t:i?i.__e:e.firstChild,r),xm(s,n)}function $h(n,e){yo(n,e,$h)}function xh(n,e,t){var r,i,s,o=zn({},n.props);for(s in e)s=="key"?r=e[s]:s=="ref"?i=e[s]:o[s]=e[s];return arguments.length>2&&(o.children=arguments.length>3?Ga.call(arguments,2):t),Sa(n.type,o,r||n.key,i||n.ref,null)}function Il(n,e){var t={__c:e="__cC"+Cm++,__:n,Consumer:function(r,i){return r.children(i)},Provider:function(r){var i,s;return this.getChildContext||(i=[],(s={})[e]=this,this.getChildContext=function(){return s},this.shouldComponentUpdate=function(o){this.props.value!==o.value&&i.some(gd)},this.sub=function(o){i.push(o);var c=o.componentWillUnmount;o.componentWillUnmount=function(){i.splice(i.indexOf(o),1),c&&c.call(o)}}),r.children}};return t.Provider.__=t.Consumer.contextType=t}Ga=Pm.slice,J={__e:function(n,e,t,r){for(var i,s,o;e=e.__;)if((i=e.__c)&&!i.__)try{if((s=i.constructor)&&s.getDerivedStateFromError!=null&&(i.setState(s.getDerivedStateFromError(n)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(n,r||{}),o=i.__d),o)return i.__E=i}catch(c){n=c}throw n}},Tm=0,Om=function(n){return n!=null&&n.constructor===void 0},Er.prototype.setState=function(n,e){var t;t=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=zn({},this.state),typeof n=="function"&&(n=n(zn({},t),this.props)),n&&zn(t,n),n!=null&&this.__v&&(e&&this.__h.push(e),gd(this))},Er.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),gd(this))},Er.prototype.render=Zr,Ea=[],km=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,al.__r=0,Cm=0;var F_=Object.freeze(Object.defineProperty({__proto__:null,render:yo,hydrate:$h,createElement:cr,h:cr,Fragment:Zr,createRef:Dh,get isValidElement(){return Om},Component:Er,cloneElement:xh,createContext:Il,toChildArray:Nr,get options(){return J}},Symbol.toStringTag,{value:"Module"})),Rs,bt,Pf,vo=0,Bm=[],Mf=J.__b,Af=J.__r,Df=J.diffed,Uf=J.__c,$f=J.unmount;function ko(n,e){J.__h&&J.__h(bt,n,vo||e),vo=0;var t=bt.__H||(bt.__H={__:[],__h:[]});return n>=t.__.length&&t.__.push({}),t.__[n]}function Nh(n){return vo=1,Lh(Wm,n)}function Lh(n,e,t){var r=ko(Rs++,2);return r.t=n,r.__c||(r.__=[t?t(e):Wm(void 0,e),function(i){var s=r.t(r.__[0],i);r.__[0]!==s&&(r.__=[s,r.__[1]],r.__c.setState({}))}],r.__c=bt),r.__}function Km(n,e){var t=ko(Rs++,3);!J.__s&&Kh(t.__H,e)&&(t.__=n,t.__H=e,bt.__H.__h.push(t))}function Bh(n,e){var t=ko(Rs++,4);!J.__s&&Kh(t.__H,e)&&(t.__=n,t.__H=e,bt.__h.push(t))}function Fm(n){return vo=5,Tl(function(){return{current:n}},[])}function qm(n,e,t){vo=6,Bh(function(){return typeof n=="function"?(n(e()),function(){return n(null)}):n?(n.current=e(),function(){return n.current=null}):void 0},t==null?t:t.concat(n))}function Tl(n,e){var t=ko(Rs++,7);return Kh(t.__H,e)&&(t.__=n(),t.__H=e,t.__h=n),t.__}function jm(n,e){return vo=8,Tl(function(){return n},e)}function Vm(n){var e=bt.context[n.__c],t=ko(Rs++,9);return t.c=n,e?(t.__==null&&(t.__=!0,e.sub(bt)),e.props.value):n.__}function Gm(n,e){J.useDebugValue&&J.useDebugValue(e?e(n):n)}function q_(n){var e=ko(Rs++,10),t=Nh();return e.__=n,bt.componentDidCatch||(bt.componentDidCatch=function(r){e.__&&e.__(r),t[1](r)}),[t[0],function(){t[1](void 0)}]}function j_(){for(var n;n=Bm.shift();)if(n.__P)try{n.__H.__h.forEach(Gc),n.__H.__h.forEach(md),n.__H.__h=[]}catch(e){n.__H.__h=[],J.__e(e,n.__v)}}J.__b=function(n){bt=null,Mf&&Mf(n)},J.__r=function(n){Af&&Af(n),Rs=0;var e=(bt=n.__c).__H;e&&(e.__h.forEach(Gc),e.__h.forEach(md),e.__h=[])},J.diffed=function(n){Df&&Df(n);var e=n.__c;e&&e.__H&&e.__H.__h.length&&(Bm.push(e)!==1&&Pf===J.requestAnimationFrame||((Pf=J.requestAnimationFrame)||function(t){var r,i=function(){clearTimeout(s),xf&&cancelAnimationFrame(r),setTimeout(t)},s=setTimeout(i,100);xf&&(r=requestAnimationFrame(i))})(j_)),bt=null},J.__c=function(n,e){e.some(function(t){try{t.__h.forEach(Gc),t.__h=t.__h.filter(function(r){return!r.__||md(r)})}catch(r){e.some(function(i){i.__h&&(i.__h=[])}),e=[],J.__e(r,t.__v)}}),Uf&&Uf(n,e)},J.unmount=function(n){$f&&$f(n);var e,t=n.__c;t&&t.__H&&(t.__H.__.forEach(function(r){try{Gc(r)}catch(i){e=i}}),e&&J.__e(e,t.__v))};var xf=typeof requestAnimationFrame=="function";function Gc(n){var e=bt,t=n.__c;typeof t=="function"&&(n.__c=void 0,t()),bt=e}function md(n){var e=bt;n.__c=n.__(),bt=e}function Kh(n,e){return!n||n.length!==e.length||e.some(function(t,r){return t!==n[r]})}function Wm(n,e){return typeof e=="function"?e(n):e}var V_={};function ga(n,e){for(var t in e)n[t]=e[t];return n}function G_(n,e,t){var r,i=/(?:\?([^#]*))?(#.*)?$/,s=n.match(i),o={};if(s&&s[1])for(var c=s[1].split("&"),l=0;l<c.length;l++){var u=c[l].split("=");o[decodeURIComponent(u[0])]=decodeURIComponent(u.slice(1).join("="))}n=yd(n.replace(i,"")),e=yd(e||"");for(var a=Math.max(n.length,e.length),g=0;g<a;g++)if(e[g]&&e[g].charAt(0)===":"){var m=e[g].replace(/(^:|[+*?]+$)/g,""),p=(e[g].match(/[+*?]+$/)||V_)[0]||"",E=~p.indexOf("+"),I=~p.indexOf("*"),w=n[g]||"";if(!w&&!I&&(p.indexOf("?")<0||E)){r=!1;break}if(o[m]=decodeURIComponent(w),E||I){o[m]=n.slice(g).map(decodeURIComponent).join("/");break}}else if(e[g]!==n[g]){r=!1;break}return(t.default===!0||r!==!1)&&o}function W_(n,e){return n.rank<e.rank?1:n.rank>e.rank?-1:n.index-e.index}function H_(n,e){return n.index=e,n.rank=function(t){return t.props.default?0:yd(t.props.path).map(Y_).join("")}(n),n.props}function yd(n){return n.replace(/(^\/+|\/+$)/g,"").split("/")}function Y_(n){return n.charAt(0)==":"?1+"*+?".indexOf(n.charAt(n.length-1))||4:5}var z_={},os=[],Nf=[],yr=null,Hm={url:Fh()},J_=Il(Hm);function Fh(){var n;return""+((n=yr&&yr.location?yr.location:yr&&yr.getCurrentLocation?yr.getCurrentLocation():typeof location!="undefined"?location:z_).pathname||"")+(n.search||"")}function X_(n,e){return e===void 0&&(e=!1),typeof n!="string"&&n.url&&(e=n.replace,n=n.url),function(t){for(var r=os.length;r--;)if(os[r].canRoute(t))return!0;return!1}(n)&&function(t,r){r===void 0&&(r="push"),yr&&yr[r]?yr[r](t):typeof history!="undefined"&&history[r+"State"]&&history[r+"State"](null,null,t)}(n,e?"replace":"push"),Ym(n)}function Ym(n){for(var e=!1,t=0;t<os.length;t++)os[t].routeTo(n)&&(e=!0);return e}function Q_(n){if(n&&n.getAttribute){var e=n.getAttribute("href"),t=n.getAttribute("target");if(e&&e.match(/^\//g)&&(!t||t.match(/^_?self$/i)))return X_(e)}}function Z_(n){return n.stopImmediatePropagation&&n.stopImmediatePropagation(),n.stopPropagation&&n.stopPropagation(),n.preventDefault(),!1}function zm(n){if(!(n.ctrlKey||n.metaKey||n.altKey||n.shiftKey||n.button)){var e=n.target;do if(e.localName==="a"&&e.getAttribute("href")){if(e.hasAttribute("data-native")||e.hasAttribute("native"))return;if(Q_(e))return Z_(n)}while(e=e.parentNode)}}var Lf=!1;function eE(n){n.history&&(yr=n.history),this.state={url:n.url||Fh()}}ga(eE.prototype=new Er,{shouldComponentUpdate:function(n){return n.static!==!0||n.url!==this.props.url||n.onChange!==this.props.onChange},canRoute:function(n){var e=Nr(this.props.children);return this.g(e,n)!==void 0},routeTo:function(n){this.setState({url:n});var e=this.canRoute(n);return this.p||this.forceUpdate(),e},componentWillMount:function(){this.p=!0},componentDidMount:function(){var n=this;Lf||(Lf=!0,yr||addEventListener("popstate",function(){Ym(Fh())}),addEventListener("click",zm)),os.push(this),yr&&(this.u=yr.listen(function(e){var t=e.location||e;n.routeTo(""+(t.pathname||"")+(t.search||""))})),this.p=!1},componentWillUnmount:function(){typeof this.u=="function"&&this.u(),os.splice(os.indexOf(this),1)},componentWillUpdate:function(){this.p=!0},componentDidUpdate:function(){this.p=!1},g:function(n,e){n=n.filter(H_).sort(W_);for(var t=0;t<n.length;t++){var r=n[t],i=G_(e,r.props.path,r.props);if(i)return[r,i]}},render:function(n,e){var t,r,i=n.onChange,s=e.url,o=this.c,c=this.g(Nr(n.children),s);if(c&&(r=xh(c[0],ga(ga({url:s,matches:t=c[1]},t),{key:void 0,ref:void 0}))),s!==(o&&o.url)){ga(Hm,o=this.c={url:s,previous:o&&o.url,current:r,path:r?r.props.path:null,matches:t}),o.router=this,o.active=r?[r]:[];for(var l=Nf.length;l--;)Nf[l]({});typeof i=="function"&&i(o)}return cr(J_.Provider,{value:o},r)}});var UA=function(n){return cr("a",ga({onClick:zm},n))};function Jm(n,e){for(var t in e)n[t]=e[t];return n}function vd(n,e){for(var t in n)if(t!=="__source"&&!(t in e))return!0;for(var r in e)if(r!=="__source"&&n[r]!==e[r])return!0;return!1}function ll(n){this.props=n}function Xm(n,e){function t(i){var s=this.props.ref,o=s==i.ref;return!o&&s&&(s.call?s(null):s.current=null),e?!e(this.props,i)||!o:vd(this.props,i)}function r(i){return this.shouldComponentUpdate=t,cr(n,i)}return r.displayName="Memo("+(n.displayName||n.name)+")",r.prototype.isReactComponent=!0,r.__f=!0,r}(ll.prototype=new Er).isPureReactComponent=!0,ll.prototype.shouldComponentUpdate=function(n,e){return vd(this.props,n)||vd(this.state,e)};var Bf=J.__b;J.__b=function(n){n.type&&n.type.__f&&n.ref&&(n.props.ref=n.ref,n.ref=null),Bf&&Bf(n)};var tE=typeof Symbol!="undefined"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function Qm(n){function e(t,r){var i=Jm({},t);return delete i.ref,n(i,!(r=t.ref||r)||typeof r=="object"&&Object.keys(r).length===0?null:r)}return e.$$typeof=tE,e.render=e,e.prototype.isReactComponent=e.__f=!0,e.displayName="ForwardRef("+(n.displayName||n.name)+")",e}var Kf=function(n,e){return n==null?null:Nr(Nr(n).map(e))},Zm={map:Kf,forEach:Kf,count:function(n){return n?Nr(n).length:0},only:function(n){var e=Nr(n);if(e.length!==1)throw"Children.only";return e[0]},toArray:Nr},rE=J.__e;J.__e=function(n,e,t,r){if(n.then){for(var i,s=e;s=s.__;)if((i=s.__c)&&i.__c)return e.__e==null&&(e.__e=t.__e,e.__k=t.__k),i.__c(n,e)}rE(n,e,t,r)};var Ff=J.unmount;function ba(){this.__u=0,this.t=null,this.__b=null}function ey(n){var e=n.__.__c;return e&&e.__e&&e.__e(n)}function ty(n){var e,t,r;function i(s){if(e||(e=n()).then(function(o){t=o.default||o},function(o){r=o}),r)throw r;if(!t)throw e;return cr(t,s)}return i.displayName="Lazy",i.__f=!0,i}function so(){this.u=null,this.o=null}J.unmount=function(n){var e=n.__c;e&&e.__R&&e.__R(),e&&n.__h===!0&&(n.type=null),Ff&&Ff(n)},(ba.prototype=new Er).__c=function(n,e){var t=e.__c,r=this;r.t==null&&(r.t=[]),r.t.push(t);var i=ey(r.__v),s=!1,o=function(){s||(s=!0,t.__R=null,i?i(c):c())};t.__R=o;var c=function(){if(!--r.__u){if(r.state.__e){var u=r.state.__e;r.__v.__k[0]=function g(m,p,E){return m&&(m.__v=null,m.__k=m.__k&&m.__k.map(function(I){return g(I,p,E)}),m.__c&&m.__c.__P===p&&(m.__e&&E.insertBefore(m.__e,m.__d),m.__c.__e=!0,m.__c.__P=E)),m}(u,u.__c.__P,u.__c.__O)}var a;for(r.setState({__e:r.__b=null});a=r.t.pop();)a.forceUpdate()}},l=e.__h===!0;r.__u++||l||r.setState({__e:r.__b=r.__v.__k[0]}),n.then(o,o)},ba.prototype.componentWillUnmount=function(){this.t=[]},ba.prototype.render=function(n,e){if(this.__b){if(this.__v.__k){var t=document.createElement("div"),r=this.__v.__k[0].__c;this.__v.__k[0]=function s(o,c,l){return o&&(o.__c&&o.__c.__H&&(o.__c.__H.__.forEach(function(u){typeof u.__c=="function"&&u.__c()}),o.__c.__H=null),(o=Jm({},o)).__c!=null&&(o.__c.__P===l&&(o.__c.__P=c),o.__c=null),o.__k=o.__k&&o.__k.map(function(u){return s(u,c,l)})),o}(this.__b,t,r.__O=r.__P)}this.__b=null}var i=e.__e&&cr(Zr,null,n.fallback);return i&&(i.__h=null),[cr(Zr,null,e.__e?null:n.children),i]};var qf=function(n,e,t){if(++t[1]===t[0]&&n.o.delete(e),n.props.revealOrder&&(n.props.revealOrder[0]!=="t"||!n.o.size))for(t=n.u;t;){for(;t.length>3;)t.pop()();if(t[1]<t[0])break;n.u=t=t[2]}};function nE(n){return this.getChildContext=function(){return n.context},n.children}function iE(n){var e=this,t=n.i;e.componentWillUnmount=function(){yo(null,e.l),e.l=null,e.i=null},e.i&&e.i!==t&&e.componentWillUnmount(),n.__v?(e.l||(e.i=t,e.l={nodeType:1,parentNode:t,childNodes:[],appendChild:function(r){this.childNodes.push(r),e.i.appendChild(r)},insertBefore:function(r,i){this.childNodes.push(r),e.i.appendChild(r)},removeChild:function(r){this.childNodes.splice(this.childNodes.indexOf(r)>>>1,1),e.i.removeChild(r)}}),yo(cr(nE,{context:e.context},n.__v),e.l)):e.l&&e.componentWillUnmount()}function ry(n,e){return cr(iE,{__v:n,i:e})}(so.prototype=new Er).__e=function(n){var e=this,t=ey(e.__v),r=e.o.get(n);return r[0]++,function(i){var s=function(){e.props.revealOrder?(r.push(i),qf(e,n,r)):i()};t?t(s):s()}},so.prototype.render=function(n){this.u=null,this.o=new Map;var e=Nr(n.children);n.revealOrder&&n.revealOrder[0]==="b"&&e.reverse();for(var t=e.length;t--;)this.o.set(e[t],this.u=[1,0,this.u]);return n.children},so.prototype.componentDidUpdate=so.prototype.componentDidMount=function(){var n=this;this.o.forEach(function(e,t){qf(n,t,e)})};var ny=typeof Symbol!="undefined"&&Symbol.for&&Symbol.for("react.element")||60103,sE=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|marker(?!H|W|U)|overline|paint|stop|strikethrough|stroke|text(?!L)|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,oE=typeof document!="undefined",aE=function(n){return(typeof Symbol!="undefined"&&typeof Symbol()=="symbol"?/fil|che|rad/i:/fil|che|ra/i).test(n)};function iy(n,e,t){return e.__k==null&&(e.textContent=""),yo(n,e),typeof t=="function"&&t(),n?n.__c:null}function sy(n,e,t){return $h(n,e),typeof t=="function"&&t(),n?n.__c:null}Er.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(n){Object.defineProperty(Er.prototype,n,{configurable:!0,get:function(){return this["UNSAFE_"+n]},set:function(e){Object.defineProperty(this,n,{configurable:!0,writable:!0,value:e})}})});var jf=J.event;function cE(){}function lE(){return this.cancelBubble}function uE(){return this.defaultPrevented}J.event=function(n){return jf&&(n=jf(n)),n.persist=cE,n.isPropagationStopped=lE,n.isDefaultPrevented=uE,n.nativeEvent=n};var oy,Vf={configurable:!0,get:function(){return this.class}},Gf=J.vnode;J.vnode=function(n){var e=n.type,t=n.props,r=t;if(typeof e=="string"){var i=e.indexOf("-")===-1;for(var s in r={},t){var o=t[s];oE&&s==="children"&&e==="noscript"||s==="value"&&"defaultValue"in t&&o==null||(s==="defaultValue"&&"value"in t&&t.value==null?s="value":s==="download"&&o===!0?o="":/ondoubleclick/i.test(s)?s="ondblclick":/^onchange(textarea|input)/i.test(s+e)&&!aE(t.type)?s="oninput":/^onfocus$/i.test(s)?s="onfocusin":/^onblur$/i.test(s)?s="onfocusout":/^on(Ani|Tra|Tou|BeforeInp|Compo)/.test(s)?s=s.toLowerCase():i&&sE.test(s)?s=s.replace(/[A-Z0-9]/,"-$&").toLowerCase():o===null&&(o=void 0),r[s]=o)}e=="select"&&r.multiple&&Array.isArray(r.value)&&(r.value=Nr(t.children).forEach(function(c){c.props.selected=r.value.indexOf(c.props.value)!=-1})),e=="select"&&r.defaultValue!=null&&(r.value=Nr(t.children).forEach(function(c){c.props.selected=r.multiple?r.defaultValue.indexOf(c.props.value)!=-1:r.defaultValue==c.props.value})),n.props=r,t.class!=t.className&&(Vf.enumerable="className"in t,t.className!=null&&(r.class=t.className),Object.defineProperty(r,"className",Vf))}n.$$typeof=ny,Gf&&Gf(n)};var Wf=J.__r;J.__r=function(n){Wf&&Wf(n),oy=n.__c};var ay={ReactCurrentDispatcher:{current:{readContext:function(n){return oy.__n[n.__c].props.value}}}},dE="17.0.2";function cy(n){return cr.bind(null,n)}function qh(n){return!!n&&n.$$typeof===ny}function ly(n){return qh(n)?xh.apply(null,arguments):n}function uy(n){return!!n.__k&&(yo(null,n),!0)}function dy(n){return n&&(n.base||n.nodeType===1&&n)||null}var hy=function(n,e){return n(e)},fy=function(n,e){return n(e)},hE=Zr,fE={useState:Nh,useReducer:Lh,useEffect:Km,useLayoutEffect:Bh,useRef:Fm,useImperativeHandle:qm,useMemo:Tl,useCallback:jm,useContext:Vm,useDebugValue:Gm,version:"17.0.2",Children:Zm,render:iy,hydrate:sy,unmountComponentAtNode:uy,createPortal:ry,createElement:cr,createContext:Il,createFactory:cy,cloneElement:ly,createRef:Dh,Fragment:Zr,isValidElement:qh,findDOMNode:dy,Component:Er,PureComponent:ll,memo:Xm,forwardRef:Qm,flushSync:fy,unstable_batchedUpdates:hy,StrictMode:Zr,Suspense:ba,SuspenseList:so,lazy:ty,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:ay},pE=Object.freeze(Object.defineProperty({__proto__:null,default:fE,version:dE,Children:Zm,render:iy,hydrate:sy,unmountComponentAtNode:uy,createPortal:ry,createFactory:cy,cloneElement:ly,isValidElement:qh,findDOMNode:dy,PureComponent:ll,memo:Xm,forwardRef:Qm,flushSync:fy,unstable_batchedUpdates:hy,StrictMode:hE,Suspense:ba,SuspenseList:so,lazy:ty,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:ay,createElement:cr,createContext:Il,createRef:Dh,Fragment:Zr,Component:Er,useState:Nh,useReducer:Lh,useEffect:Km,useLayoutEffect:Bh,useRef:Fm,useImperativeHandle:qm,useMemo:Tl,useCallback:jm,useContext:Vm,useDebugValue:Gm,useErrorBoundary:q_},Symbol.toStringTag,{value:"Module"})),j=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function jh(n){if(n.__esModule)return n;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(n).forEach(function(t){var r=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:function(){return n[t]}})}),e}var gE=jh(F_),mE,yE,Hf=gE,vE=0;function Yf(n,e,t,r,i){var s,o,c={};for(o in e)o=="ref"?s=e[o]:c[o]=e[o];var l={type:n,props:c,key:t,ref:s,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:--vE,__source:i,__self:r};if(typeof n=="function"&&(s=n.defaultProps))for(o in s)c[o]===void 0&&(c[o]=s[o]);return Hf.options.vnode&&Hf.options.vnode(l),l}yE=Yf,mE=Yf;var py={},_E=jh(pE);function EE(n){if(n&&n.__esModule)return n;var e=Object.create(null);return n&&Object.keys(n).forEach(function(t){if(t!=="default"){var r=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:function(){return n[t]}})}}),e.default=n,Object.freeze(e)}Object.defineProperty(py,"__esModule",{value:!0});var Fn=EE(_E);function SE({debounceMs:n}){const[e,t]=Fn.useState(window.innerWidth),r=function(i,s){let o=null;return(...c)=>{clearTimeout(o),o=setTimeout(()=>i(c),s)}}(()=>t(window.innerWidth),n);return Fn.useEffect(()=>(window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)),[r]),e}const bE=Fn.forwardRef(({as:n="div",children:e,className:t,style:r,gap:i=10,debounce:s=200,nColumns:o=3},c)=>{const l=SE({debounceMs:s}),[u,a]=Fn.useState([]);Fn.useLayoutEffect(()=>{var I;const m=w=>w.sort((k,P)=>k.size-P.size),p=typeof o=="number"?{columns:o}:(I=(w=>w==null?void 0:w[w.length-1])(m(((w,k)=>w.filter(P=>P.size<=k))(o,l))))!=null?I:(w=>w==null?void 0:w[0])(m(o)),E=Array.from({length:p.columns},w=>[]);Fn.Children.forEach(e,(w,k)=>{const P=`item-${k}`,S=Fn.cloneElement(w,If(uc({},w.props),{key:P}));E[k%E.length].push(S)}),a(E)},[e,o,l]);const g={mainGrid:{display:"grid",gridTemplateColumns:`repeat(${u.length}, 1fr)`,columnGap:i,alignItems:"start"},columnGrid:{display:"grid",gridTemplateColumns:"100%",rowGap:i}};return Fn.createElement(n,{ref:c,"data-testid":"plock-container",className:t,style:uc({style:r},g.mainGrid)},u.map((m,p)=>Fn.createElement("div",{"data-testid":"plock-column",style:g.columnGrid,key:p},m)))});var $A=py.Plock=bE,wE={},V={exports:{}};(function(n){function e(t){return t&&t.__esModule?t:{default:t}}n.exports=e,n.exports.__esModule=!0,n.exports.default=n.exports})(V);var gy={exports:{}};(function(n,e){(function(t,r){n.exports=r()})(j,function(){var t=XMLHttpRequest;if(!t)throw new Error("missing XMLHttpRequest");i.log={trace:l,debug:l,info:l,warn:l,error:l};var r=3*60*1e3;function i(p,E){if(typeof E!="function")throw new Error("Bad callback given: "+E);if(!p)throw new Error("No options given");var I=p.onResponse;if(typeof p=="string"?p={uri:p}:p=JSON.parse(JSON.stringify(p)),p.onResponse=I,p.verbose&&(i.log=u()),p.url&&(p.uri=p.url,delete p.url),!p.uri&&p.uri!=="")throw new Error("options.uri is a required argument");if(typeof p.uri!="string")throw new Error("options.uri must be a string");for(var w=["proxy","_redirectsFollowed","maxRedirects","followRedirect"],k=0;k<w.length;k++)if(p[w[k]])throw new Error("options."+w[k]+" is not supported");if(p.callback=E,p.method=p.method||"GET",p.headers=p.headers||{},p.body=p.body||null,p.timeout=p.timeout||i.DEFAULT_TIMEOUT,p.headers.host)throw new Error("Options.headers.host is not supported");p.json&&(p.headers.accept=p.headers.accept||"application/json",p.method!=="GET"&&(p.headers["content-type"]="application/json"),typeof p.json!="boolean"?p.body=JSON.stringify(p.json):typeof p.body!="string"&&(p.body=JSON.stringify(p.body)));var P=function(L){var H=[];for(var F in L)L.hasOwnProperty(F)&&H.push(encodeURIComponent(F)+"="+encodeURIComponent(L[F]));return H.join("&")};if(p.qs){var S=typeof p.qs=="string"?p.qs:P(p.qs);p.uri.indexOf("?")!==-1?p.uri=p.uri+"&"+S:p.uri=p.uri+"?"+S}var T=function(L){var H={};H.boundry="-------------------------------"+Math.floor(Math.random()*1e9);var F=[];for(var le in L)L.hasOwnProperty(le)&&F.push("--"+H.boundry+`
-Content-Disposition: form-data; name="`+le+`"
-
-`+L[le]+`
-`);return F.push("--"+H.boundry+"--"),H.body=F.join(""),H.length=H.body.length,H.type="multipart/form-data; boundary="+H.boundry,H};if(p.form){if(typeof p.form=="string")throw"form name unsupported";if(p.method==="POST"){var D=(p.encoding||"application/x-www-form-urlencoded").toLowerCase();switch(p.headers["content-type"]=D,D){case"application/x-www-form-urlencoded":p.body=P(p.form).replace(/%20/g,"+");break;case"multipart/form-data":var R=T(p.form);p.body=R.body,p.headers["content-type"]=R.type;break;default:throw new Error("unsupported encoding:"+D)}}}return p.onResponse=p.onResponse||l,p.onResponse===!0&&(p.onResponse=E,p.callback=l),!p.headers.authorization&&p.auth&&(p.headers.authorization="Basic "+m(p.auth.username+":"+p.auth.password)),o(p)}var s=0;function o(p){var E=new t,I=!1,w=g(p.uri),k="withCredentials"in E;if(s+=1,E.seq_id=s,E.id=s+": "+p.method+" "+p.uri,E._id=E.id,w&&!k){var P=new Error("Browser does not support cross-origin request: "+p.uri);return P.cors="unsupported",p.callback(P,E)}E.timeoutTimer=setTimeout(S,p.timeout);function S(){I=!0;var F=new Error("ETIMEDOUT");return F.code="ETIMEDOUT",F.duration=p.timeout,i.log.error("Timeout",{id:E._id,milliseconds:p.timeout}),p.callback(F,E)}var T={response:!1,loading:!1,end:!1};return E.onreadystatechange=D,E.open(p.method,p.uri,!0),w&&(E.withCredentials=!!p.withCredentials),E.send(p.body),E;function D(F){if(I)return i.log.debug("Ignoring timed out state change",{state:E.readyState,id:E.id});if(i.log.debug("State change",{state:E.readyState,id:E.id,timed_out:I}),E.readyState===t.OPENED){i.log.debug("Request started",{id:E.id});for(var le in p.headers)E.setRequestHeader(le,p.headers[le])}else E.readyState===t.HEADERS_RECEIVED?R():E.readyState===t.LOADING?(R(),L()):E.readyState===t.DONE&&(R(),L(),H())}function R(){if(!T.response){if(T.response=!0,i.log.debug("Got response",{id:E.id,status:E.status}),clearTimeout(E.timeoutTimer),E.statusCode=E.status,w&&E.statusCode==0){var F=new Error("CORS request rejected: "+p.uri);return F.cors="rejected",T.loading=!0,T.end=!0,p.callback(F,E)}p.onResponse(null,E)}}function L(){T.loading||(T.loading=!0,i.log.debug("Response body loading",{id:E.id}))}function H(){if(!T.end){if(T.end=!0,i.log.debug("Request done",{id:E.id}),E.body=E.responseText,p.json)try{E.body=JSON.parse(E.responseText)}catch(F){return p.callback(F,E)}p.callback(null,E,E.body)}}}i.withCredentials=!1,i.DEFAULT_TIMEOUT=r,i.defaults=function(p,E){var I=function(k){var P=function(S,T){typeof S=="string"?S={uri:S}:S=JSON.parse(JSON.stringify(S));for(var D in p)S[D]===void 0&&(S[D]=p[D]);return k(S,T)};return P},w=I(i);return w.get=I(i.get),w.post=I(i.post),w.put=I(i.put),w.head=I(i.head),w};var c=["get","put","post","head"];c.forEach(function(p){var E=p.toUpperCase(),I=p.toLowerCase();i[I]=function(w){typeof w=="string"?w={method:E,uri:w}:(w=JSON.parse(JSON.stringify(w)),w.method=E);var k=[w].concat(Array.prototype.slice.apply(arguments,[1]));return i.apply(this,k)}}),i.couch=function(p,E){typeof p=="string"&&(p={uri:p}),p.json=!0,p.body&&(p.json=p.body),delete p.body,E=E||l;var I=i(p,w);return I;function w(k,P,S){if(k)return E(k,P,S);if((P.statusCode<200||P.statusCode>299)&&S.error){k=new Error("CouchDB error: "+(S.error.reason||S.error.error));for(var T in S)k[T]=S[T];return E(k,P,S)}return E(k,P,S)}};function l(){}function u(){var p={},E=["trace","debug","info","warn","error"],I,w;for(w=0;w<E.length;w++)I=E[w],p[I]=l,typeof console!="undefined"&&console&&console[I]&&(p[I]=a(console,I));return p}function a(p,E){return I;function I(w,k){return typeof k=="object"&&(w+=" "+JSON.stringify(k)),p[E].call(p,w)}}function g(p){var E=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,I;try{I=location.href}catch{I=document.createElement("a"),I.href="",I=I.href}var w=E.exec(I.toLowerCase())||[],k=E.exec(p.toLowerCase()),P=!!(k&&(k[1]!=w[1]||k[2]!=w[2]||(k[3]||(k[1]==="http:"?80:443))!=(w[3]||(w[1]==="http:"?80:443))));return P}function m(p){var E="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",I,w,k,P,S,T,D,R,L=0,H=0,F="",le=[];if(!p)return p;do I=p.charCodeAt(L++),w=p.charCodeAt(L++),k=p.charCodeAt(L++),R=I<<16|w<<8|k,P=R>>18&63,S=R>>12&63,T=R>>6&63,D=R&63,le[H++]=E.charAt(P)+E.charAt(S)+E.charAt(T)+E.charAt(D);while(L<p.length);switch(F=le.join(""),p.length%3){case 1:F=F.slice(0,-2)+"==";break;case 2:F=F.slice(0,-1)+"=";break}return F}return i})})(gy);var RE=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},t=Symbol("test"),r=Object(t);if(typeof t=="string"||Object.prototype.toString.call(t)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var i=42;e[t]=i;for(t in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var s=Object.getOwnPropertySymbols(e);if(s.length!==1||s[0]!==t||!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var o=Object.getOwnPropertyDescriptor(e,t);if(o.value!==i||o.enumerable!==!0)return!1}return!0},zf=typeof Symbol!="undefined"&&Symbol,IE=RE,TE=function(){return typeof zf!="function"||typeof Symbol!="function"||typeof zf("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:IE()},OE="Function.prototype.bind called on incompatible ",lu=Array.prototype.slice,kE=Object.prototype.toString,CE="[object Function]",PE=function(e){var t=this;if(typeof t!="function"||kE.call(t)!==CE)throw new TypeError(OE+t);for(var r=lu.call(arguments,1),i,s=function(){if(this instanceof i){var a=t.apply(this,r.concat(lu.call(arguments)));return Object(a)===a?a:this}else return t.apply(e,r.concat(lu.call(arguments)))},o=Math.max(0,t.length-r.length),c=[],l=0;l<o;l++)c.push("$"+l);if(i=Function("binder","return function ("+c.join(",")+"){ return binder.apply(this,arguments); }")(s),t.prototype){var u=function(){};u.prototype=t.prototype,i.prototype=new u,u.prototype=null}return i},ME=PE,Vh=Function.prototype.bind||ME,AE=Vh,DE=AE.call(Function.call,Object.prototype.hasOwnProperty),pe,Aa=SyntaxError,my=Function,ao=TypeError,uu=function(n){try{return my('"use strict"; return ('+n+").constructor;")()}catch{}},as=Object.getOwnPropertyDescriptor;if(as)try{as({},"")}catch{as=null}var du=function(){throw new ao},UE=as?function(){try{return arguments.callee,du}catch{try{return as(arguments,"callee").get}catch{return du}}}():du,Us=TE(),Oi=Object.getPrototypeOf||function(n){return n.__proto__},eo={},$E=typeof Uint8Array=="undefined"?pe:Oi(Uint8Array),co={"%AggregateError%":typeof AggregateError=="undefined"?pe:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer=="undefined"?pe:ArrayBuffer,"%ArrayIteratorPrototype%":Us?Oi([][Symbol.iterator]()):pe,"%AsyncFromSyncIteratorPrototype%":pe,"%AsyncFunction%":eo,"%AsyncGenerator%":eo,"%AsyncGeneratorFunction%":eo,"%AsyncIteratorPrototype%":eo,"%Atomics%":typeof Atomics=="undefined"?pe:Atomics,"%BigInt%":typeof BigInt=="undefined"?pe:BigInt,"%Boolean%":Boolean,"%DataView%":typeof DataView=="undefined"?pe:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array=="undefined"?pe:Float32Array,"%Float64Array%":typeof Float64Array=="undefined"?pe:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry=="undefined"?pe:FinalizationRegistry,"%Function%":my,"%GeneratorFunction%":eo,"%Int8Array%":typeof Int8Array=="undefined"?pe:Int8Array,"%Int16Array%":typeof Int16Array=="undefined"?pe:Int16Array,"%Int32Array%":typeof Int32Array=="undefined"?pe:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Us?Oi(Oi([][Symbol.iterator]())):pe,"%JSON%":typeof JSON=="object"?JSON:pe,"%Map%":typeof Map=="undefined"?pe:Map,"%MapIteratorPrototype%":typeof Map=="undefined"||!Us?pe:Oi(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise=="undefined"?pe:Promise,"%Proxy%":typeof Proxy=="undefined"?pe:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect=="undefined"?pe:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set=="undefined"?pe:Set,"%SetIteratorPrototype%":typeof Set=="undefined"||!Us?pe:Oi(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer=="undefined"?pe:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Us?Oi(""[Symbol.iterator]()):pe,"%Symbol%":Us?Symbol:pe,"%SyntaxError%":Aa,"%ThrowTypeError%":UE,"%TypedArray%":$E,"%TypeError%":ao,"%Uint8Array%":typeof Uint8Array=="undefined"?pe:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray=="undefined"?pe:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array=="undefined"?pe:Uint16Array,"%Uint32Array%":typeof Uint32Array=="undefined"?pe:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap=="undefined"?pe:WeakMap,"%WeakRef%":typeof WeakRef=="undefined"?pe:WeakRef,"%WeakSet%":typeof WeakSet=="undefined"?pe:WeakSet},xE=function n(e){var t;if(e==="%AsyncFunction%")t=uu("async function () {}");else if(e==="%GeneratorFunction%")t=uu("function* () {}");else if(e==="%AsyncGeneratorFunction%")t=uu("async function* () {}");else if(e==="%AsyncGenerator%"){var r=n("%AsyncGeneratorFunction%");r&&(t=r.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=n("%AsyncGenerator%");i&&(t=Oi(i.prototype))}return co[e]=t,t},Jf={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},Ol=Vh,ul=DE,NE=Ol.call(Function.call,Array.prototype.concat),LE=Ol.call(Function.apply,Array.prototype.splice),Xf=Ol.call(Function.call,String.prototype.replace),dl=Ol.call(Function.call,String.prototype.slice),BE=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,KE=/\\(\\)?/g,FE=function(e){var t=dl(e,0,1),r=dl(e,-1);if(t==="%"&&r!=="%")throw new Aa("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&t!=="%")throw new Aa("invalid intrinsic syntax, expected opening `%`");var i=[];return Xf(e,BE,function(s,o,c,l){i[i.length]=c?Xf(l,KE,"$1"):o||s}),i},qE=function(e,t){var r=e,i;if(ul(Jf,r)&&(i=Jf[r],r="%"+i[0]+"%"),ul(co,r)){var s=co[r];if(s===eo&&(s=xE(r)),typeof s=="undefined"&&!t)throw new ao("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:r,value:s}}throw new Aa("intrinsic "+e+" does not exist!")},Gh=function(e,t){if(typeof e!="string"||e.length===0)throw new ao("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof t!="boolean")throw new ao('"allowMissing" argument must be a boolean');var r=FE(e),i=r.length>0?r[0]:"",s=qE("%"+i+"%",t),o=s.name,c=s.value,l=!1,u=s.alias;u&&(i=u[0],LE(r,NE([0,1],u)));for(var a=1,g=!0;a<r.length;a+=1){var m=r[a],p=dl(m,0,1),E=dl(m,-1);if((p==='"'||p==="'"||p==="`"||E==='"'||E==="'"||E==="`")&&p!==E)throw new Aa("property names with quotes must have matching quotes");if((m==="constructor"||!g)&&(l=!0),i+="."+m,o="%"+i+"%",ul(co,o))c=co[o];else if(c!=null){if(!(m in c)){if(!t)throw new ao("base intrinsic for "+e+" exists, but the property is not available.");return}if(as&&a+1>=r.length){var I=as(c,m);g=!!I,g&&"get"in I&&!("originalValue"in I.get)?c=I.get:c=c[m]}else g=ul(c,m),c=c[m];g&&!l&&(co[o]=c)}}return c},yy={exports:{}};(function(n){var e=Vh,t=Gh,r=t("%Function.prototype.apply%"),i=t("%Function.prototype.call%"),s=t("%Reflect.apply%",!0)||e.call(i,r),o=t("%Object.getOwnPropertyDescriptor%",!0),c=t("%Object.defineProperty%",!0),l=t("%Math.max%");if(c)try{c({},"a",{value:1})}catch{c=null}n.exports=function(g){var m=s(e,i,arguments);if(o&&c){var p=o(m,"length");p.configurable&&c(m,"length",{value:1+l(0,g.length-(arguments.length-1))})}return m};var u=function(){return s(e,r,arguments)};c?c(n.exports,"apply",{value:u}):n.exports.apply=u})(yy);var vy=Gh,_y=yy.exports,jE=_y(vy("String.prototype.indexOf")),VE=function(e,t){var r=vy(e,!!t);return typeof r=="function"&&jE(e,".prototype.")>-1?_y(r):r},GE={},WE=Object.freeze(Object.defineProperty({__proto__:null,default:GE},Symbol.toStringTag,{value:"Module"})),ki=jh(WE),Wh=typeof Map=="function"&&Map.prototype,hu=Object.getOwnPropertyDescriptor&&Wh?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,hl=Wh&&hu&&typeof hu.get=="function"?hu.get:null,HE=Wh&&Map.prototype.forEach,Hh=typeof Set=="function"&&Set.prototype,fu=Object.getOwnPropertyDescriptor&&Hh?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,fl=Hh&&fu&&typeof fu.get=="function"?fu.get:null,YE=Hh&&Set.prototype.forEach,zE=typeof WeakMap=="function"&&WeakMap.prototype,wa=zE?WeakMap.prototype.has:null,JE=typeof WeakSet=="function"&&WeakSet.prototype,Ra=JE?WeakSet.prototype.has:null,XE=typeof WeakRef=="function"&&WeakRef.prototype,Qf=XE?WeakRef.prototype.deref:null,QE=Boolean.prototype.valueOf,ZE=Object.prototype.toString,eS=Function.prototype.toString,tS=String.prototype.match,Yh=String.prototype.slice,Di=String.prototype.replace,rS=String.prototype.toUpperCase,Zf=String.prototype.toLowerCase,Ey=RegExp.prototype.test,ep=Array.prototype.concat,Sn=Array.prototype.join,nS=Array.prototype.slice,tp=Math.floor,_d=typeof BigInt=="function"?BigInt.prototype.valueOf:null,pu=Object.getOwnPropertySymbols,Ed=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,_o=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Pt=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===_o?"object":"symbol")?Symbol.toStringTag:null,Sy=Object.prototype.propertyIsEnumerable,rp=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(n){return n.__proto__}:null);function np(n,e){if(n===1/0||n===-1/0||n!==n||n&&n>-1e3&&n<1e3||Ey.call(/e/,e))return e;var t=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof n=="number"){var r=n<0?-tp(-n):tp(n);if(r!==n){var i=String(r),s=Yh.call(e,i.length+1);return Di.call(i,t,"$&_")+"."+Di.call(Di.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Di.call(e,t,"$&_")}var gu=ki.custom,mu=gu&&wy(gu)?gu:null,iS=function n(e,t,r,i){var s=t||{};if(Ci(s,"quoteStyle")&&s.quoteStyle!=="single"&&s.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Ci(s,"maxStringLength")&&(typeof s.maxStringLength=="number"?s.maxStringLength<0&&s.maxStringLength!==1/0:s.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=Ci(s,"customInspect")?s.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Ci(s,"indent")&&s.indent!==null&&s.indent!==" "&&!(parseInt(s.indent,10)===s.indent&&s.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(Ci(s,"numericSeparator")&&typeof s.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var c=s.numericSeparator;if(typeof e=="undefined")return"undefined";if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return Iy(e,s);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var l=String(e);return c?np(e,l):l}if(typeof e=="bigint"){var u=String(e)+"n";return c?np(e,u):u}var a=typeof s.depth=="undefined"?5:s.depth;if(typeof r=="undefined"&&(r=0),r>=a&&a>0&&typeof e=="object")return Sd(e)?"[Array]":"[Object]";var g=wS(s,r);if(typeof i=="undefined")i=[];else if(Ry(i,e)>=0)return"[Circular]";function m(De,ut,ur){if(ut&&(i=nS.call(i),i.push(ut)),ur){var jt={depth:s.depth};return Ci(s,"quoteStyle")&&(jt.quoteStyle=s.quoteStyle),n(De,jt,r+1,i)}return n(De,s,r+1,i)}if(typeof e=="function"){var p=pS(e),E=dc(e,m);return"[Function"+(p?": "+p:" (anonymous)")+"]"+(E.length>0?" { "+Sn.call(E,", ")+" }":"")}if(wy(e)){var I=_o?Di.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):Ed.call(e);return typeof e=="object"&&!_o?jo(I):I}if(ES(e)){for(var w="<"+Zf.call(String(e.nodeName)),k=e.attributes||[],P=0;P<k.length;P++)w+=" "+k[P].name+"="+by(sS(k[P].value),"double",s);return w+=">",e.childNodes&&e.childNodes.length&&(w+="..."),w+="</"+Zf.call(String(e.nodeName))+">",w}if(Sd(e)){if(e.length===0)return"[]";var S=dc(e,m);return g&&!bS(S)?"["+bd(S,g)+"]":"[ "+Sn.call(S,", ")+" ]"}if(cS(e)){var T=dc(e,m);return"cause"in e&&!Sy.call(e,"cause")?"{ ["+String(e)+"] "+Sn.call(ep.call("[cause]: "+m(e.cause),T),", ")+" }":T.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+Sn.call(T,", ")+" }"}if(typeof e=="object"&&o){if(mu&&typeof e[mu]=="function")return e[mu]();if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(gS(e)){var D=[];return HE.call(e,function(De,ut){D.push(m(ut,e,!0)+" => "+m(De,e))}),ip("Map",hl.call(e),D,g)}if(vS(e)){var R=[];return YE.call(e,function(De){R.push(m(De,e))}),ip("Set",fl.call(e),R,g)}if(mS(e))return yu("WeakMap");if(_S(e))return yu("WeakSet");if(yS(e))return yu("WeakRef");if(uS(e))return jo(m(Number(e)));if(hS(e))return jo(m(_d.call(e)));if(dS(e))return jo(QE.call(e));if(lS(e))return jo(m(String(e)));if(!oS(e)&&!aS(e)){var L=dc(e,m),H=rp?rp(e)===Object.prototype:e instanceof Object||e.constructor===Object,F=e instanceof Object?"":"null prototype",le=!H&&Pt&&Object(e)===e&&Pt in e?Yh.call(xi(e),8,-1):F?"Object":"",Je=H||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",Ke=Je+(le||F?"["+Sn.call(ep.call([],le||[],F||[]),": ")+"] ":"");return L.length===0?Ke+"{}":g?Ke+"{"+bd(L,g)+"}":Ke+"{ "+Sn.call(L,", ")+" }"}return String(e)};function by(n,e,t){var r=(t.quoteStyle||e)==="double"?'"':"'";return r+n+r}function sS(n){return Di.call(String(n),/"/g,""")}function Sd(n){return xi(n)==="[object Array]"&&(!Pt||!(typeof n=="object"&&Pt in n))}function oS(n){return xi(n)==="[object Date]"&&(!Pt||!(typeof n=="object"&&Pt in n))}function aS(n){return xi(n)==="[object RegExp]"&&(!Pt||!(typeof n=="object"&&Pt in n))}function cS(n){return xi(n)==="[object Error]"&&(!Pt||!(typeof n=="object"&&Pt in n))}function lS(n){return xi(n)==="[object String]"&&(!Pt||!(typeof n=="object"&&Pt in n))}function uS(n){return xi(n)==="[object Number]"&&(!Pt||!(typeof n=="object"&&Pt in n))}function dS(n){return xi(n)==="[object Boolean]"&&(!Pt||!(typeof n=="object"&&Pt in n))}function wy(n){if(_o)return n&&typeof n=="object"&&n instanceof Symbol;if(typeof n=="symbol")return!0;if(!n||typeof n!="object"||!Ed)return!1;try{return Ed.call(n),!0}catch{}return!1}function hS(n){if(!n||typeof n!="object"||!_d)return!1;try{return _d.call(n),!0}catch{}return!1}var fS=Object.prototype.hasOwnProperty||function(n){return n in this};function Ci(n,e){return fS.call(n,e)}function xi(n){return ZE.call(n)}function pS(n){if(n.name)return n.name;var e=tS.call(eS.call(n),/^function\s*([\w$]+)/);return e?e[1]:null}function Ry(n,e){if(n.indexOf)return n.indexOf(e);for(var t=0,r=n.length;t<r;t++)if(n[t]===e)return t;return-1}function gS(n){if(!hl||!n||typeof n!="object")return!1;try{hl.call(n);try{fl.call(n)}catch{return!0}return n instanceof Map}catch{}return!1}function mS(n){if(!wa||!n||typeof n!="object")return!1;try{wa.call(n,wa);try{Ra.call(n,Ra)}catch{return!0}return n instanceof WeakMap}catch{}return!1}function yS(n){if(!Qf||!n||typeof n!="object")return!1;try{return Qf.call(n),!0}catch{}return!1}function vS(n){if(!fl||!n||typeof n!="object")return!1;try{fl.call(n);try{hl.call(n)}catch{return!0}return n instanceof Set}catch{}return!1}function _S(n){if(!Ra||!n||typeof n!="object")return!1;try{Ra.call(n,Ra);try{wa.call(n,wa)}catch{return!0}return n instanceof WeakSet}catch{}return!1}function ES(n){return!n||typeof n!="object"?!1:typeof HTMLElement!="undefined"&&n instanceof HTMLElement?!0:typeof n.nodeName=="string"&&typeof n.getAttribute=="function"}function Iy(n,e){if(n.length>e.maxStringLength){var t=n.length-e.maxStringLength,r="... "+t+" more character"+(t>1?"s":"");return Iy(Yh.call(n,0,e.maxStringLength),e)+r}var i=Di.call(Di.call(n,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,SS);return by(i,"single",e)}function SS(n){var e=n.charCodeAt(0),t={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return t?"\\"+t:"\\x"+(e<16?"0":"")+rS.call(e.toString(16))}function jo(n){return"Object("+n+")"}function yu(n){return n+" { ? }"}function ip(n,e,t,r){var i=r?bd(t,r):Sn.call(t,", ");return n+" ("+e+") {"+i+"}"}function bS(n){for(var e=0;e<n.length;e++)if(Ry(n[e],`
-`)>=0)return!1;return!0}function wS(n,e){var t;if(n.indent===" ")t=" ";else if(typeof n.indent=="number"&&n.indent>0)t=Sn.call(Array(n.indent+1)," ");else return null;return{base:t,prev:Sn.call(Array(e+1),t)}}function bd(n,e){if(n.length===0)return"";var t=`
-`+e.prev+e.base;return t+Sn.call(n,","+t)+`
-`+e.prev}function dc(n,e){var t=Sd(n),r=[];if(t){r.length=n.length;for(var i=0;i<n.length;i++)r[i]=Ci(n,i)?e(n[i],n):""}var s=typeof pu=="function"?pu(n):[],o;if(_o){o={};for(var c=0;c<s.length;c++)o["$"+s[c]]=s[c]}for(var l in n)!Ci(n,l)||t&&String(Number(l))===l&&l<n.length||_o&&o["$"+l]instanceof Symbol||(Ey.call(/[^\w$]/,l)?r.push(e(l,n)+": "+e(n[l],n)):r.push(l+": "+e(n[l],n)));if(typeof pu=="function")for(var u=0;u<s.length;u++)Sy.call(n,s[u])&&r.push("["+e(s[u])+"]: "+e(n[s[u]],n));return r}var zh=Gh,Co=VE,RS=iS,IS=zh("%TypeError%"),hc=zh("%WeakMap%",!0),fc=zh("%Map%",!0),TS=Co("WeakMap.prototype.get",!0),OS=Co("WeakMap.prototype.set",!0),kS=Co("WeakMap.prototype.has",!0),CS=Co("Map.prototype.get",!0),PS=Co("Map.prototype.set",!0),MS=Co("Map.prototype.has",!0),Jh=function(n,e){for(var t=n,r;(r=t.next)!==null;t=r)if(r.key===e)return t.next=r.next,r.next=n.next,n.next=r,r},AS=function(n,e){var t=Jh(n,e);return t&&t.value},DS=function(n,e,t){var r=Jh(n,e);r?r.value=t:n.next={key:e,next:n.next,value:t}},US=function(n,e){return!!Jh(n,e)},$S=function(){var e,t,r,i={assert:function(s){if(!i.has(s))throw new IS("Side channel does not contain "+RS(s))},get:function(s){if(hc&&s&&(typeof s=="object"||typeof s=="function")){if(e)return TS(e,s)}else if(fc){if(t)return CS(t,s)}else if(r)return AS(r,s)},has:function(s){if(hc&&s&&(typeof s=="object"||typeof s=="function")){if(e)return kS(e,s)}else if(fc){if(t)return MS(t,s)}else if(r)return US(r,s);return!1},set:function(s,o){hc&&s&&(typeof s=="object"||typeof s=="function")?(e||(e=new hc),OS(e,s,o)):fc?(t||(t=new fc),PS(t,s,o)):(r||(r={key:{},next:null}),DS(r,s,o))}};return i},xS=String.prototype.replace,NS=/%20/g,vu={RFC1738:"RFC1738",RFC3986:"RFC3986"},Xh={default:vu.RFC3986,formatters:{RFC1738:function(n){return xS.call(n,NS,"+")},RFC3986:function(n){return String(n)}},RFC1738:vu.RFC1738,RFC3986:vu.RFC3986},LS=Xh,_u=Object.prototype.hasOwnProperty,es=Array.isArray,cn=function(){for(var n=[],e=0;e<256;++e)n.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return n}(),BS=function(e){for(;e.length>1;){var t=e.pop(),r=t.obj[t.prop];if(es(r)){for(var i=[],s=0;s<r.length;++s)typeof r[s]!="undefined"&&i.push(r[s]);t.obj[t.prop]=i}}},Ty=function(e,t){for(var r=t&&t.plainObjects?Object.create(null):{},i=0;i<e.length;++i)typeof e[i]!="undefined"&&(r[i]=e[i]);return r},KS=function n(e,t,r){if(!t)return e;if(typeof t!="object"){if(es(e))e.push(t);else if(e&&typeof e=="object")(r&&(r.plainObjects||r.allowPrototypes)||!_u.call(Object.prototype,t))&&(e[t]=!0);else return[e,t];return e}if(!e||typeof e!="object")return[e].concat(t);var i=e;return es(e)&&!es(t)&&(i=Ty(e,r)),es(e)&&es(t)?(t.forEach(function(s,o){if(_u.call(e,o)){var c=e[o];c&&typeof c=="object"&&s&&typeof s=="object"?e[o]=n(c,s,r):e.push(s)}else e[o]=s}),e):Object.keys(t).reduce(function(s,o){var c=t[o];return _u.call(s,o)?s[o]=n(s[o],c,r):s[o]=c,s},i)},FS=function(e,t){return Object.keys(t).reduce(function(r,i){return r[i]=t[i],r},e)},qS=function(n,e,t){var r=n.replace(/\+/g," ");if(t==="iso-8859-1")return r.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(r)}catch{return r}},jS=function(e,t,r,i,s){if(e.length===0)return e;var o=e;if(typeof e=="symbol"?o=Symbol.prototype.toString.call(e):typeof e!="string"&&(o=String(e)),r==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(a){return"%26%23"+parseInt(a.slice(2),16)+"%3B"});for(var c="",l=0;l<o.length;++l){var u=o.charCodeAt(l);if(u===45||u===46||u===95||u===126||u>=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||s===LS.RFC1738&&(u===40||u===41)){c+=o.charAt(l);continue}if(u<128){c=c+cn[u];continue}if(u<2048){c=c+(cn[192|u>>6]+cn[128|u&63]);continue}if(u<55296||u>=57344){c=c+(cn[224|u>>12]+cn[128|u>>6&63]+cn[128|u&63]);continue}l+=1,u=65536+((u&1023)<<10|o.charCodeAt(l)&1023),c+=cn[240|u>>18]+cn[128|u>>12&63]+cn[128|u>>6&63]+cn[128|u&63]}return c},VS=function(e){for(var t=[{obj:{o:e},prop:"o"}],r=[],i=0;i<t.length;++i)for(var s=t[i],o=s.obj[s.prop],c=Object.keys(o),l=0;l<c.length;++l){var u=c[l],a=o[u];typeof a=="object"&&a!==null&&r.indexOf(a)===-1&&(t.push({obj:o,prop:u}),r.push(a))}return BS(t),e},GS=function(e){return Object.prototype.toString.call(e)==="[object RegExp]"},WS=function(e){return!e||typeof e!="object"?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},HS=function(e,t){return[].concat(e,t)},YS=function(e,t){if(es(e)){for(var r=[],i=0;i<e.length;i+=1)r.push(t(e[i]));return r}return t(e)},Oy={arrayToObject:Ty,assign:FS,combine:HS,compact:VS,decode:qS,encode:jS,isBuffer:WS,isRegExp:GS,maybeMap:YS,merge:KS},ky=$S,wd=Oy,Ia=Xh,zS=Object.prototype.hasOwnProperty,sp={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},ns=Array.isArray,JS=String.prototype.split,XS=Array.prototype.push,Cy=function(n,e){XS.apply(n,ns(e)?e:[e])},QS=Date.prototype.toISOString,op=Ia.default,yt={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:wd.encode,encodeValuesOnly:!1,format:op,formatter:Ia.formatters[op],indices:!1,serializeDate:function(e){return QS.call(e)},skipNulls:!1,strictNullHandling:!1},ZS=function(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="symbol"||typeof e=="bigint"},Eu={},eb=function n(e,t,r,i,s,o,c,l,u,a,g,m,p,E,I){for(var w=e,k=I,P=0,S=!1;(k=k.get(Eu))!==void 0&&!S;){var T=k.get(e);if(P+=1,typeof T!="undefined"){if(T===P)throw new RangeError("Cyclic object value");S=!0}typeof k.get(Eu)=="undefined"&&(P=0)}if(typeof c=="function"?w=c(t,w):w instanceof Date?w=a(w):r==="comma"&&ns(w)&&(w=wd.maybeMap(w,function(Q){return Q instanceof Date?a(Q):Q})),w===null){if(i)return o&&!p?o(t,yt.encoder,E,"key",g):t;w=""}if(ZS(w)||wd.isBuffer(w)){if(o){var D=p?t:o(t,yt.encoder,E,"key",g);if(r==="comma"&&p){for(var R=JS.call(String(w),","),L="",H=0;H<R.length;++H)L+=(H===0?"":",")+m(o(R[H],yt.encoder,E,"value",g));return[m(D)+"="+L]}return[m(D)+"="+m(o(w,yt.encoder,E,"value",g))]}return[m(t)+"="+m(String(w))]}var F=[];if(typeof w=="undefined")return F;var le;if(r==="comma"&&ns(w))le=[{value:w.length>0?w.join(",")||null:void 0}];else if(ns(c))le=c;else{var Je=Object.keys(w);le=l?Je.sort(l):Je}for(var Ke=0;Ke<le.length;++Ke){var De=le[Ke],ut=typeof De=="object"&&typeof De.value!="undefined"?De.value:w[De];if(!(s&&ut===null)){var ur=ns(w)?typeof r=="function"?r(t,De):t:t+(u?"."+De:"["+De+"]");I.set(e,P);var jt=ky();jt.set(Eu,I),Cy(F,n(ut,ur,r,i,s,o,c,l,u,a,g,m,p,E,jt))}}return F},tb=function(e){if(!e)return yt;if(e.encoder!==null&&typeof e.encoder!="undefined"&&typeof e.encoder!="function")throw new TypeError("Encoder has to be a function.");var t=e.charset||yt.charset;if(typeof e.charset!="undefined"&&e.charset!=="utf-8"&&e.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var r=Ia.default;if(typeof e.format!="undefined"){if(!zS.call(Ia.formatters,e.format))throw new TypeError("Unknown format option provided.");r=e.format}var i=Ia.formatters[r],s=yt.filter;return(typeof e.filter=="function"||ns(e.filter))&&(s=e.filter),{addQueryPrefix:typeof e.addQueryPrefix=="boolean"?e.addQueryPrefix:yt.addQueryPrefix,allowDots:typeof e.allowDots=="undefined"?yt.allowDots:!!e.allowDots,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:yt.charsetSentinel,delimiter:typeof e.delimiter=="undefined"?yt.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:yt.encode,encoder:typeof e.encoder=="function"?e.encoder:yt.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:yt.encodeValuesOnly,filter:s,format:r,formatter:i,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:yt.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:yt.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:yt.strictNullHandling}},rb=function(n,e){var t=n,r=tb(e),i,s;typeof r.filter=="function"?(s=r.filter,t=s("",t)):ns(r.filter)&&(s=r.filter,i=s);var o=[];if(typeof t!="object"||t===null)return"";var c;e&&e.arrayFormat in sp?c=e.arrayFormat:e&&"indices"in e?c=e.indices?"indices":"repeat":c="indices";var l=sp[c];i||(i=Object.keys(t)),r.sort&&i.sort(r.sort);for(var u=ky(),a=0;a<i.length;++a){var g=i[a];r.skipNulls&&t[g]===null||Cy(o,eb(t[g],g,l,r.strictNullHandling,r.skipNulls,r.encode?r.encoder:null,r.filter,r.sort,r.allowDots,r.serializeDate,r.format,r.formatter,r.encodeValuesOnly,r.charset,u))}var m=o.join(r.delimiter),p=r.addQueryPrefix===!0?"?":"";return r.charsetSentinel&&(r.charset==="iso-8859-1"?p+="utf8=%26%2310003%3B&":p+="utf8=%E2%9C%93&"),m.length>0?p+m:""},Eo=Oy,Rd=Object.prototype.hasOwnProperty,nb=Array.isArray,lt={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:Eo.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},ib=function(n){return n.replace(/&#(\d+);/g,function(e,t){return String.fromCharCode(parseInt(t,10))})},Py=function(n,e){return n&&typeof n=="string"&&e.comma&&n.indexOf(",")>-1?n.split(","):n},sb="utf8=%26%2310003%3B",ob="utf8=%E2%9C%93",ab=function(e,t){var r={},i=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,s=t.parameterLimit===1/0?void 0:t.parameterLimit,o=i.split(t.delimiter,s),c=-1,l,u=t.charset;if(t.charsetSentinel)for(l=0;l<o.length;++l)o[l].indexOf("utf8=")===0&&(o[l]===ob?u="utf-8":o[l]===sb&&(u="iso-8859-1"),c=l,l=o.length);for(l=0;l<o.length;++l)if(l!==c){var a=o[l],g=a.indexOf("]="),m=g===-1?a.indexOf("="):g+1,p,E;m===-1?(p=t.decoder(a,lt.decoder,u,"key"),E=t.strictNullHandling?null:""):(p=t.decoder(a.slice(0,m),lt.decoder,u,"key"),E=Eo.maybeMap(Py(a.slice(m+1),t),function(I){return t.decoder(I,lt.decoder,u,"value")})),E&&t.interpretNumericEntities&&u==="iso-8859-1"&&(E=ib(E)),a.indexOf("[]=")>-1&&(E=nb(E)?[E]:E),Rd.call(r,p)?r[p]=Eo.combine(r[p],E):r[p]=E}return r},cb=function(n,e,t,r){for(var i=r?e:Py(e,t),s=n.length-1;s>=0;--s){var o,c=n[s];if(c==="[]"&&t.parseArrays)o=[].concat(i);else{o=t.plainObjects?Object.create(null):{};var l=c.charAt(0)==="["&&c.charAt(c.length-1)==="]"?c.slice(1,-1):c,u=parseInt(l,10);!t.parseArrays&&l===""?o={0:i}:!isNaN(u)&&c!==l&&String(u)===l&&u>=0&&t.parseArrays&&u<=t.arrayLimit?(o=[],o[u]=i):l!=="__proto__"&&(o[l]=i)}i=o}return i},lb=function(e,t,r,i){if(!!e){var s=r.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,o=/(\[[^[\]]*])/,c=/(\[[^[\]]*])/g,l=r.depth>0&&o.exec(s),u=l?s.slice(0,l.index):s,a=[];if(u){if(!r.plainObjects&&Rd.call(Object.prototype,u)&&!r.allowPrototypes)return;a.push(u)}for(var g=0;r.depth>0&&(l=c.exec(s))!==null&&g<r.depth;){if(g+=1,!r.plainObjects&&Rd.call(Object.prototype,l[1].slice(1,-1))&&!r.allowPrototypes)return;a.push(l[1])}return l&&a.push("["+s.slice(l.index)+"]"),cb(a,t,r,i)}},ub=function(e){if(!e)return lt;if(e.decoder!==null&&e.decoder!==void 0&&typeof e.decoder!="function")throw new TypeError("Decoder has to be a function.");if(typeof e.charset!="undefined"&&e.charset!=="utf-8"&&e.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=typeof e.charset=="undefined"?lt.charset:e.charset;return{allowDots:typeof e.allowDots=="undefined"?lt.allowDots:!!e.allowDots,allowPrototypes:typeof e.allowPrototypes=="boolean"?e.allowPrototypes:lt.allowPrototypes,allowSparse:typeof e.allowSparse=="boolean"?e.allowSparse:lt.allowSparse,arrayLimit:typeof e.arrayLimit=="number"?e.arrayLimit:lt.arrayLimit,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:lt.charsetSentinel,comma:typeof e.comma=="boolean"?e.comma:lt.comma,decoder:typeof e.decoder=="function"?e.decoder:lt.decoder,delimiter:typeof e.delimiter=="string"||Eo.isRegExp(e.delimiter)?e.delimiter:lt.delimiter,depth:typeof e.depth=="number"||e.depth===!1?+e.depth:lt.depth,ignoreQueryPrefix:e.ignoreQueryPrefix===!0,interpretNumericEntities:typeof e.interpretNumericEntities=="boolean"?e.interpretNumericEntities:lt.interpretNumericEntities,parameterLimit:typeof e.parameterLimit=="number"?e.parameterLimit:lt.parameterLimit,parseArrays:e.parseArrays!==!1,plainObjects:typeof e.plainObjects=="boolean"?e.plainObjects:lt.plainObjects,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:lt.strictNullHandling}},db=function(n,e){var t=ub(e);if(n===""||n===null||typeof n=="undefined")return t.plainObjects?Object.create(null):{};for(var r=typeof n=="string"?ab(n,t):n,i=t.plainObjects?Object.create(null):{},s=Object.keys(r),o=0;o<s.length;++o){var c=s[o],l=lb(c,r[c],t,typeof n=="string");i=Eo.merge(i,l,t)}return t.allowSparse===!0?i:Eo.compact(i)},hb=rb,fb=db,pb=Xh,gb={formats:pb,parse:fb,stringify:hb},Is={},Po={},Y={exports:{}};(function(n){function e(t,r,i){return r in t?Object.defineProperty(t,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[r]=i,t}n.exports=e,n.exports.__esModule=!0,n.exports.default=n.exports})(Y);var ie={},My={exports:{}};(function(n){(function(e,t){n.exports?n.exports=t():e.log=t()})(j,function(){var e=function(){},t="undefined",r=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"];function s(I,w){var k=I[w];if(typeof k.bind=="function")return k.bind(I);try{return Function.prototype.bind.call(k,I)}catch{return function(){return Function.prototype.apply.apply(k,[I,arguments])}}}function o(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function c(I){return I==="debug"&&(I="log"),typeof console===t?!1:I==="trace"&&r?o:console[I]!==void 0?s(console,I):console.log!==void 0?s(console,"log"):e}function l(I,w){for(var k=0;k<i.length;k++){var P=i[k];this[P]=k<I?e:this.methodFactory(P,I,w)}this.log=this.debug}function u(I,w,k){return function(){typeof console!==t&&(l.call(this,w,k),this[I].apply(this,arguments))}}function a(I,w,k){return c(I)||u.apply(this,arguments)}function g(I,w,k){var P=this,S;w=w==null?"WARN":w;var T="loglevel";typeof I=="string"?T+=":"+I:typeof I=="symbol"&&(T=void 0);function D(F){var le=(i[F]||"silent").toUpperCase();if(!(typeof window===t||!T)){try{window.localStorage[T]=le;return}catch{}try{window.document.cookie=encodeURIComponent(T)+"="+le+";"}catch{}}}function R(){var F;if(!(typeof window===t||!T)){try{F=window.localStorage[T]}catch{}if(typeof F===t)try{var le=window.document.cookie,Je=le.indexOf(encodeURIComponent(T)+"=");Je!==-1&&(F=/^([^;]+)/.exec(le.slice(Je))[1])}catch{}return P.levels[F]===void 0&&(F=void 0),F}}function L(){if(!(typeof window===t||!T)){try{window.localStorage.removeItem(T);return}catch{}try{window.document.cookie=encodeURIComponent(T)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}P.name=I,P.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},P.methodFactory=k||a,P.getLevel=function(){return S},P.setLevel=function(F,le){if(typeof F=="string"&&P.levels[F.toUpperCase()]!==void 0&&(F=P.levels[F.toUpperCase()]),typeof F=="number"&&F>=0&&F<=P.levels.SILENT){if(S=F,le!==!1&&D(F),l.call(P,F,I),typeof console===t&&F<P.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+F},P.setDefaultLevel=function(F){w=F,R()||P.setLevel(F,!1)},P.resetLevel=function(){P.setLevel(w,!1),L()},P.enableAll=function(F){P.setLevel(P.levels.TRACE,F)},P.disableAll=function(F){P.setLevel(P.levels.SILENT,F)};var H=R();H==null&&(H=w),P.setLevel(H,!1)}var m=new g,p={};m.getLogger=function(w){if(typeof w!="symbol"&&typeof w!="string"||w==="")throw new TypeError("You must supply a name when creating a logger.");var k=p[w];return k||(k=p[w]=new g(w,m.getLevel(),m.methodFactory)),k};var E=typeof window!==t?window.log:void 0;return m.noConflict=function(){return typeof window!==t&&window.log===m&&(window.log=E),m},m.getLoggers=function(){return p},m.default=m,m})})(My);var mb=V.exports;Object.defineProperty(ie,"__esModule",{value:!0});ie.logger=void 0;var Da=mb(My.exports);const Ay="matrix";Da.default.methodFactory=function(n,e,t){return function(...r){return this.prefix&&r.unshift(this.prefix),n==="error"||n==="warn"||n==="trace"||n==="info"?console[n](...r):console.log(...r)}};const Qh=Da.default.getLogger(Ay);ie.logger=Qh;Qh.setLevel(Da.default.levels.DEBUG,!1);function Dy(n){n.withPrefix=function(e){const t=this.prefix||"";return yb(t+e)}}Dy(Qh);function yb(n){const e=Da.default.getLogger(`${Ay}-${n}`);return e.prefix!==n&&(Dy(e),e.prefix=n,e.setLevel(Da.default.levels.DEBUG,!1)),e}var G={};const vb="l",_b="rn";var Eb={"0":"O","1":"l","\u05AD":"\u0596","\u05AE":"\u0598","\u05A8":"\u0599","\u05A4":"\u059A","\u1AB4":"\u06DB","\u20DB":"\u06DB","\u0619":"\u0313","\u08F3":"\u0313","\u0343":"\u0313","\u0315":"\u0313","\u064F":"\u0313","\u065D":"\u0314","\u059C":"\u0301","\u059D":"\u0301","\u0618":"\u0301","\u0747":"\u0301","\u0341":"\u0301","\u0954":"\u0301","\u064E":"\u0301","\u0340":"\u0300","\u0953":"\u0300","\u030C":"\u0306","\uA67C":"\u0306","\u0658":"\u0306","\u065A":"\u0306","\u036E":"\u0306","\u06E8":"\u0306\u0307","\u0310":"\u0306\u0307","\u0901":"\u0306\u0307","\u0981":"\u0306\u0307","\u0A81":"\u0306\u0307","\u0B01":"\u0306\u0307","\u0C00":"\u0306\u0307","\u0C81":"\u0306\u0307","\u0D01":"\u0306\u0307","\u{114BF}":"\u0306\u0307","\u1CD0":"\u0302","\u0311":"\u0302","\u065B":"\u0302","\u07EE":"\u0302","\uA6F0":"\u0302","\u05AF":"\u030A","\u06DF":"\u030A","\u17D3":"\u030A","\u309A":"\u030A","\u0652":"\u030A","\u0B82":"\u030A","\u1036":"\u030A","\u17C6":"\u030A","\u{11300}":"\u030A","\u0E4D":"\u030A","\u0ECD":"\u030A","\u0366":"\u030A","\u2DEA":"\u030A","\u08EB":"\u0308","\u07F3":"\u0308","\u064B":"\u030B","\u08F0":"\u030B","\u0342":"\u0303","\u0653":"\u0303","\u05C4":"\u0307","\u06EC":"\u0307","\u0740":"\u0307","\u08EA":"\u0307","\u0741":"\u0307","\u0358":"\u0307","\u05B9":"\u0307","\u05BA":"\u0307","\u05C2":"\u0307","\u05C1":"\u0307","\u07ED":"\u0307","\u0902":"\u0307","\u0A02":"\u0307","\u0A82":"\u0307","\u0BCD":"\u0307","\u0337":"\u0338","\u1AB7":"\u0328","\u0322":"\u0328","\u0345":"\u0328","\u1CD2":"\u0304","\u0305":"\u0304","\u0659":"\u0304","\u07EB":"\u0304","\uA6F1":"\u0304","\u1CDA":"\u030E","\u0657":"\u0312","\u0357":"\u0350","\u08FF":"\u0350","\u08F8":"\u0350","\u0900":"\u0352","\u1CED":"\u0316","\u1CDC":"\u0329","\u0656":"\u0329","\u1CD5":"\u032B","\u0347":"\u0333","\u08F9":"\u0354","\u08FA":"\u0355","\u309B":"\uFF9E","\u309C":"\uFF9F","\u0336":"\u0335","\u302C":"\u0309","\u05C5":"\u0323","\u08ED":"\u0323","\u1CDD":"\u0323","\u05B4":"\u0323","\u065C":"\u0323","\u093C":"\u0323","\u09BC":"\u0323","\u0A3C":"\u0323","\u0ABC":"\u0323","\u0B3C":"\u0323","\u{111CA}":"\u0323","\u{114C3}":"\u0323","\u{10A3A}":"\u0323","\u08EE":"\u0324","\u1CDE":"\u0324","\u0F37":"\u0325","\u302D":"\u0325","\u0327":"\u0326","\u0321":"\u0326","\u0339":"\u0326","\u1CD9":"\u032D","\u1CD8":"\u032E","\u0952":"\u0331","\u0320":"\u0331","\u08F1":"\u064C","\u08E8":"\u064C","\u08E5":"\u064C",\uFC5E:"\uFE72\u0651","\u08F2":"\u064D",\uFC5F:"\uFE74\u0651",\uFCF2:"\uFE77\u0651",\uFC60:"\uFE76\u0651",\uFCF3:"\uFE79\u0651",\uFC61:"\uFE78\u0651","\u061A":"\u0650","\u0317":"\u0650",\uFCF4:"\uFE7B\u0651",\uFC62:"\uFE7A\u0651",\uFC63:"\uFE7C\u0670","\u065F":"\u0655","\u030D":"\u0670","\u0742":"\u073C","\u0A03":"\u0983","\u0C03":"\u0983","\u0C83":"\u0983","\u0D03":"\u0983","\u0D83":"\u0983","\u1038":"\u0983","\u{114C1}":"\u0983","\u17CB":"\u0E48","\u0EC8":"\u0E48","\u0EC9":"\u0E49","\u0ECA":"\u0E4A","\u0ECB":"\u0E4B","\uA66F":"\u20E9","\u2028":" ","\u2029":" ","\u1680":" ","\u2000":" ","\u2001":" ","\u2002":" ","\u2003":" ","\u2004":" ","\u2005":" ","\u2006":" ","\u2008":" ","\u2009":" ","\u200A":" ","\u205F":" ","\xA0":" ","\u2007":" ","\u202F":" ","\u07FA":"_","\uFE4D":"_","\uFE4E":"_","\uFE4F":"_","\u2010":"-","\u2011":"-","\u2012":"-","\u2013":"-","\uFE58":"-","\u06D4":"-","\u2043":"-","\u02D7":"-","\u2212":"-","\u2796":"-","\u2CBA":"-","\u2A29":"-\u0313","\u2E1A":"-\u0308","\uFB29":"-\u0307","\u2238":"-\u0307","\u2A2A":"-\u0323","\uA4FE":"-.","\uFF5E":"\u301C","\u060D":",","\u066B":",","\u201A":",","\xB8":",","\uA4F9":",","\u2E32":"\u060C","\u066C":"\u060C","\u037E":";","\u2E35":"\u061B","\u0903":":","\u0A83":":","\uFF1A":":","\u0589":":","\u0703":":","\u0704":":","\u16EC":":","\uFE30":":","\u1803":":","\u1809":":","\u205A":":","\u05C3":":","\u02F8":":","\uA789":":","\u2236":":",\u02D0:":","\uA4FD":":","\u2A74":"::=","\u29F4":":\u2192","\uFF01":"!",\u01C3:"!","\u2D51":"!","\u203C":"!!","\u2049":"!?",\u0294:"?","\u0241":"?","\u097D":"?",\u13AE:"?","\uA6EB":"?","\u2048":"?!","\u2047":"??","\u2E2E":"\u061F","\u{1D16D}":".","\u2024":".","\u0701":".","\u0702":".","\uA60E":".","\u{10A50}":".","\u0660":".","\u06F0":".","\uA4F8":".","\uA4FB":".,","\u2025":"..","\uA4FA":"..","\u2026":"...","\uA6F4":"\uA6F3\uA6F3","\u30FB":"\xB7","\uFF65":"\xB7","\u16EB":"\xB7","\u0387":"\xB7","\u2E31":"\xB7","\u{10101}":"\xB7","\u2022":"\xB7","\u2027":"\xB7","\u2219":"\xB7","\u22C5":"\xB7","\uA78F":"\xB7",\u1427:"\xB7","\u22EF":"\xB7\xB7\xB7","\u2D48":"\xB7\xB7\xB7",\u1444:"\xB7<","\u22D7":"\xB7>",\u1437:"\xB7>",\u1440:"\xB7>",\u152F:"\xB74",\u147E:"\xB7b",\u1480:"\xB7b\u0307",\u147A:"\xB7d",\u1498:"\xB7J",\u14B6:"\xB7L",\u1476:"\xB7P",\u1457:"\xB7U",\u143A:"\xB7V",\u143C:"\xB7\u0245",\u14AE:"\xB7\u0393",\u140E:"\xB7\u0394",\u1459:"\xB7\u0548",\u140C:"\xB7\u1401",\u1410:"\xB7\u1404",\u1412:"\xB7\u1405",\u1414:"\xB7\u1406",\u1417:"\xB7\u140A",\u1419:"\xB7\u140B",\u143E:"\xB7\u1432",\u1442:"\xB7\u1434",\u1446:"\xB7\u1439",\u145B:"\xB7\u144F",\u1454:"\xB7\u1450",\u145D:"\xB7\u1450",\u145F:"\xB7\u1451",\u1461:"\xB7\u1455",\u1463:"\xB7\u1456",\u1474:"\xB7\u146B",\u1478:"\xB7\u146E",\u147C:"\xB7\u1470",\u1492:"\xB7\u1489",\u1494:"\xB7\u148B",\u1496:"\xB7\u148C",\u149A:"\xB7\u148E",\u149C:"\xB7\u1490",\u149E:"\xB7\u1491",\u14AC:"\xB7\u14A3",\u14B0:"\xB7\u14A6",\u14B2:"\xB7\u14A7",\u14B4:"\xB7\u14A8",\u14B8:"\xB7\u14AB",\u14C9:"\xB7\u14C0","\u18C6":"\xB7\u14C2","\u18C8":"\xB7\u14C3","\u18CA":"\xB7\u14C4","\u18CC":"\xB7\u14C5",\u14CB:"\xB7\u14C7",\u14CD:"\xB7\u14C8",\u14DC:"\xB7\u14D3",\u14DE:"\xB7\u14D5",\u14E0:"\xB7\u14D6",\u14E2:"\xB7\u14D7",\u14E4:"\xB7\u14D8",\u14E6:"\xB7\u14DA",\u14E8:"\xB7\u14DB",\u14F6:"\xB7\u14ED",\u14F8:"\xB7\u14EF",\u14FA:"\xB7\u14F0",\u14FC:"\xB7\u14F1",\u14FE:"\xB7\u14F2",\u1500:"\xB7\u14F4",\u1502:"\xB7\u14F5",\u1517:"\xB7\u1510",\u1519:"\xB7\u1511",\u151B:"\xB7\u1512",\u151D:"\xB7\u1513",\u151F:"\xB7\u1514",\u1521:"\xB7\u1515",\u1523:"\xB7\u1516",\u1531:"\xB7\u1528",\u1533:"\xB7\u1529",\u1535:"\xB7\u152A",\u1537:"\xB7\u152B",\u1539:"\xB7\u152D",\u153B:"\xB7\u152E","\u18CE":"\xB7\u1543","\u18CF":"\xB7\u1546","\u18D0":"\xB7\u1547","\u18D1":"\xB7\u1548","\u18D2":"\xB7\u1549","\u18D3":"\xB7\u154B",\u154E:"\xB7\u154C",\u155B:"\xB7\u155A",\u1568:"\xB7\u1567","\u18B3":"\xB7\u18B1","\u18B6":"\xB7\u18B4","\u18B9":"\xB7\u18B8","\u18C2":"\xB7\u18C0","\uA830":"\u0964","\u0965":"\u0964\u0964","\u1C3C":"\u1C3B\u1C3B","\u104B":"\u104A\u104A","\u1AA9":"\u1AA8\u1AA8","\u1AAB":"\u1AAA\u1AA8","\u1B5F":"\u1B5E\u1B5E","\u{10A57}":"\u{10A56}\u{10A56}","\u{1144C}":"\u{1144B}\u{1144B}","\u{11642}":"\u{11641}\u{11641}","\u{11C42}":"\u{11C41}\u{11C41}","\u1C7F":"\u1C7E\u1C7E","\u055D":"'","\uFF07":"'","\u2018":"'","\u2019":"'","\u201B":"'","\u2032":"'","\u2035":"'","\u055A":"'","\u05F3":"'","`":"'","\u1FEF":"'","\uFF40":"'","\xB4":"'","\u0384":"'","\u1FFD":"'","\u1FBD":"'","\u1FBF":"'","\u1FFE":"'","\u02B9":"'","\u0374":"'","\u02C8":"'","\u02CA":"'","\u02CB":"'","\u02F4":"'",\u02BB:"'",\u02BD:"'",\u02BC:"'",\u02BE:"'","\uA78C":"'",\u05D9:"'","\u07F4":"'","\u07F5":"'",\u144A:"'",\u16CC:"'","\u{16F51}":"'","\u{16F52}":"'","\u1CD3":"''",'"':"''","\uFF02":"''","\u201C":"''","\u201D":"''","\u201F":"''","\u2033":"''","\u2036":"''","\u3003":"''","\u05F4":"''","\u02DD":"''","\u02BA":"''","\u02F6":"''",\u02EE:"''",\u05F2:"''","\u2034":"'''","\u2037":"'''","\u2057":"''''",\u0181:"'B",\u018A:"'D",\u0149:"'n",\u01A4:"'P",\u01AC:"'T",\u01B3:"'Y","\uFF3B":"(","\u2768":"(","\u2772":"(","\u3014":"(","\uFD3E":"(","\u2E28":"((","\u3220":"(\u30FC)","\u2475":"(2)","\u2487":"(2O)","\u2476":"(3)","\u2477":"(4)","\u2478":"(5)","\u2479":"(6)","\u247A":"(7)","\u247B":"(8)","\u247C":"(9)","\u249C":"(a)","\u{1F110}":"(A)","\u249D":"(b)","\u{1F111}":"(B)","\u249E":"(c)","\u{1F112}":"(C)","\u249F":"(d)","\u{1F113}":"(D)","\u24A0":"(e)","\u{1F114}":"(E)","\u24A1":"(f)","\u{1F115}":"(F)","\u24A2":"(g)","\u{1F116}":"(G)","\u24A3":"(h)","\u{1F117}":"(H)","\u24A4":"(i)","\u24A5":"(j)","\u{1F119}":"(J)","\u24A6":"(k)","\u{1F11A}":"(K)","\u2474":"(l)","\u{1F118}":"(l)","\u24A7":"(l)","\u{1F11B}":"(L)","\u247F":"(l2)","\u2480":"(l3)","\u2481":"(l4)","\u2482":"(l5)","\u2483":"(l6)","\u2484":"(l7)","\u2485":"(l8)","\u2486":"(l9)","\u247E":"(ll)","\u247D":"(lO)","\u{1F11C}":"(M)","\u24A9":"(n)","\u{1F11D}":"(N)","\u24AA":"(o)","\u{1F11E}":"(O)","\u24AB":"(p)","\u{1F11F}":"(P)","\u24AC":"(q)","\u{1F120}":"(Q)","\u24AD":"(r)","\u{1F121}":"(R)","\u24A8":"(rn)","\u24AE":"(s)","\u{1F122}":"(S)","\u{1F12A}":"(S)","\u24AF":"(t)","\u{1F123}":"(T)","\u24B0":"(u)","\u{1F124}":"(U)","\u24B1":"(v)","\u{1F125}":"(V)","\u24B2":"(w)","\u{1F126}":"(W)","\u24B3":"(x)","\u{1F127}":"(X)","\u24B4":"(y)","\u{1F128}":"(Y)","\u24B5":"(z)","\u{1F129}":"(Z)","\u3200":"(\u1100)","\u320E":"(\uAC00)","\u3201":"(\u1102)","\u320F":"(\uB098)","\u3202":"(\u1103)","\u3210":"(\uB2E4)","\u3203":"(\u1105)","\u3211":"(\uB77C)","\u3204":"(\u1106)","\u3212":"(\uB9C8)","\u3205":"(\u1107)","\u3213":"(\uBC14)","\u3206":"(\u1109)","\u3214":"(\uC0AC)","\u3207":"(\u110B)","\u3215":"(\uC544)","\u321D":"(\uC624\uC804)","\u321E":"(\uC624\uD6C4)","\u3208":"(\u110C)","\u3216":"(\uC790)","\u321C":"(\uC8FC)","\u3209":"(\u110E)","\u3217":"(\uCC28)","\u320A":"(\u110F)","\u3218":"(\uCE74)","\u320B":"(\u1110)","\u3219":"(\uD0C0)","\u320C":"(\u1111)","\u321A":"(\uD30C)","\u320D":"(\u1112)","\u321B":"(\uD558)","\u3226":"(\u4E03)","\u3222":"(\u4E09)","\u{1F241}":"(\u4E09)","\u3228":"(\u4E5D)","\u3221":"(\u4E8C)","\u{1F242}":"(\u4E8C)","\u3224":"(\u4E94)","\u3239":"(\u4EE3)","\u323D":"(\u4F01)","\u3241":"(\u4F11)","\u3227":"(\u516B)","\u3225":"(\u516D)","\u3238":"(\u52B4)","\u{1F247}":"(\u52DD)","\u3229":"(\u5341)","\u323F":"(\u5354)","\u3234":"(\u540D)","\u323A":"(\u547C)","\u3223":"(\u56DB)","\u322F":"(\u571F)","\u323B":"(\u5B66)","\u{1F243}":"(\u5B89)","\u{1F245}":"(\u6253)","\u{1F248}":"(\u6557)","\u3230":"(\u65E5)","\u322A":"(\u6708)","\u3232":"(\u6709)","\u322D":"(\u6728)","\u{1F240}":"(\u672C)","\u3231":"(\u682A)","\u322C":"(\u6C34)","\u322B":"(\u706B)","\u{1F244}":"(\u70B9)","\u3235":"(\u7279)","\u{1F246}":"(\u76D7)","\u323C":"(\u76E3)","\u3233":"(\u793E)","\u3237":"(\u795D)","\u3240":"(\u796D)","\u3242":"(\u81EA)","\u3243":"(\u81F3)","\u3236":"(\u8CA1)","\u323E":"(\u8CC7)","\u322E":"(\u91D1)","\uFF3D":")","\u2769":")","\u2773":")","\u3015":")","\uFD3F":")","\u2E29":"))","\u2774":"{","\u{1D114}":"{","\u2775":"}","\u301A":"\u27E6","\u301B":"\u27E7","\u27E8":"\u276C","\u2329":"\u276C","\u3008":"\u276C","\u31DB":"\u276C",\u304F:"\u276C","\u{21FE8}":"\u276C","\u27E9":"\u276D","\u232A":"\u276D","\u3009":"\u276D","\uFF3E":"\uFE3F","\u2E3F":"\xB6","\u204E":"*","\u066D":"*","\u2217":"*","\u{1031F}":"*","\u1735":"/","\u2041":"/","\u2215":"/","\u2044":"/","\u2571":"/","\u27CB":"/","\u29F8":"/","\u{1D23A}":"/","\u31D3":"/",\u3033:"/","\u2CC6":"/",\u30CE:"/",\u4E3F:"/","\u2F03":"/","\u29F6":"/\u0304","\u2AFD":"//","\u2AFB":"///","\uFF3C":"\\","\uFE68":"\\","\u2216":"\\","\u27CD":"\\","\u29F5":"\\","\u29F9":"\\","\u{1D20F}":"\\","\u{1D23B}":"\\","\u31D4":"\\",\u4E36:"\\","\u2F02":"\\","\u2CF9":"\\\\","\u244A":"\\\\","\u27C8":"\\\u1455","\uA778":"&","\u0AF0":"\u0970","\u{110BB}":"\u0970","\u{111C7}":"\u0970","\u26AC":"\u0970","\u{111DB}":"\uA8FC","\u17D9":"\u0E4F","\u17D5":"\u0E5A","\u17DA":"\u0E5B","\u0F0C":"\u0F0B","\u0F0E":"\u0F0D\u0F0D","\u02C4":"^","\u02C6":"^","\uA67E":"\u02C7","\u02D8":"\u02C7","\u203E":"\u02C9","\uFE49":"\u02C9","\uFE4A":"\u02C9","\uFE4B":"\u02C9","\uFE4C":"\u02C9","\xAF":"\u02C9","\uFFE3":"\u02C9","\u2594":"\u02C9",\u044A:"\u02C9b","\uA651":"\u02C9bi","\u0375":"\u02CF","\u02FB":"\u02EA","\uA716":"\u02EA","\uA714":"\u02EB","\u3002":"\u02F3","\u2E30":"\xB0","\u02DA":"\xB0","\u2218":"\xB0","\u25CB":"\xB0","\u25E6":"\xB0","\u235C":"\xB0\u0332","\u2364":"\xB0\u0308","\u2103":"\xB0C","\u2109":"\xB0F","\u0BF5":"\u0BF3","\u0F1B":"\u0F1A\u0F1A","\u0F1F":"\u0F1A\u0F1D","\u0FCE":"\u0F1D\u0F1A","\u0F1E":"\u0F1D\u0F1D","\u24B8":"\xA9","\u24C7":"\xAE","\u24C5":"\u2117","\u{1D21B}":"\u2144","\u2BEC":"\u219E","\u2BED":"\u219F","\u2BEE":"\u21A0","\u2BEF":"\u21A1","\u21B5":"\u21B2","\u2965":"\u21C3\u21C2","\u296F":"\u21C3\u16DA","\u{1D6DB}":"\u2202","\u{1D715}":"\u2202","\u{1D74F}":"\u2202","\u{1D789}":"\u2202","\u{1D7C3}":"\u2202","\u{1E8CC}":"\u2202","\u{1E8CD}":"\u2202\u0335",\u00F0:"\u2202\u0335","\u2300":"\u2205","\u{1D6C1}":"\u2207","\u{1D6FB}":"\u2207","\u{1D735}":"\u2207","\u{1D76F}":"\u2207","\u{1D7A9}":"\u2207","\u{118A8}":"\u2207","\u2362":"\u2207\u0308","\u236B":"\u2207\u0334","\u2588":"\u220E","\u25A0":"\u220E","\u2A3F":"\u2210","\u16ED":"+","\u2795":"+","\u{1029B}":"+","\u2A23":"+\u0302","\u2A22":"+\u030A","\u2A24":"+\u0303","\u2214":"+\u0307","\u2A25":"+\u0323","\u2A26":"+\u0330","\u2A27":"+\u2082","\u2797":"\xF7","\u2039":"<","\u276E":"<","\u02C2":"<","\u{1D236}":"<",\u1438:"<",\u16B2:"<","\u22D6":"<\xB7","\u2CB4":"<\xB7",\u1445:"<\xB7","\u226A":"<<","\u22D8":"<<<","\u1400":"=","\u2E40":"=","\u30A0":"=","\uA4FF":"=","\u225A":"=\u0306","\u2259":"=\u0302","\u2257":"=\u030A","\u2250":"=\u0307","\u2251":"=\u0307\u0323","\u2A6E":"=\u20F0","\u2A75":"==","\u2A76":"===","\u225E":"=\u036B","\u203A":">","\u276F":">","\u02C3":">","\u{1D237}":">",\u1433:">","\u{16F3F}":">",\u1441:">\xB7","\u2AA5":"><","\u226B":">>","\u2A20":">>","\u22D9":">>>","\u2053":"~","\u02DC":"~","\u1FC0":"~","\u223C":"~","\u2368":"~\u0308","\u2E1E":"~\u0307","\u2A6A":"~\u0307","\u2E1F":"~\u0323","\u{1E8C8}":"\u2220","\u22C0":"\u2227","\u222F":"\u222E\u222E","\u2230":"\u222E\u222E\u222E","\u2E2B":"\u2234","\u2E2A":"\u2235","\u2E2C":"\u2237","\u{111DE}":"\u2248","\u264E":"\u224F","\u{1F75E}":"\u224F","\u2263":"\u2261","\u2A03":"\u228D","\u2A04":"\u228E","\u{1D238}":"\u228F","\u{1D239}":"\u2290","\u2A05":"\u2293","\u2A06":"\u2294","\u2A02":"\u2297","\u235F":"\u229B","\u{1F771}":"\u22A0","\u{1F755}":"\u22A1","\u25C1":"\u22B2","\u25B7":"\u22B3","\u2363":"\u22C6\u0308","\uFE34":"\u2307","\u25E0":"\u2312","\u2A3D":"\u2319","\u2325":"\u2324","\u29C7":"\u233B","\u25CE":"\u233E","\u29BE":"\u233E","\u29C5":"\u2342","\u29B0":"\u2349","\u23C3":"\u234B","\u23C2":"\u234E","\u23C1":"\u2355","\u23C6":"\u236D","\u2638":"\u2388","\uFE35":"\u23DC","\uFE36":"\u23DD","\uFE37":"\u23DE","\uFE38":"\u23DF","\uFE39":"\u23E0","\uFE3A":"\u23E1","\u25B1":"\u23E5","\u23FC":"\u23FB","\uFE31":"\u2502","\uFF5C":"\u2502","\u2503":"\u2502","\u250F":"\u250C","\u2523":"\u251C","\u2590":"\u258C","\u2597":"\u2596","\u259D":"\u2598","\u2610":"\u25A1","\uFFED":"\u25AA","\u25B8":"\u25B6","\u25BA":"\u25B6","\u2CE9":"\u2627","\u{1F70A}":"\u2629","\u{1F312}":"\u263D","\u{1F319}":"\u263D","\u23FE":"\u263E","\u{1F318}":"\u263E","\u29D9":"\u299A","\u{1F73A}":"\u29DF","\u2A3E":"\u2A1F","\u{101A0}":"\u2CE8","\u2669":"\u{1D158}\u{1D165}","\u266A":"\u{1D158}\u{1D165}\u{1D16E}","\u24EA":"\u{1F10D}","\u21BA":"\u{1F10E}","\u02D9":"\u0971","\u0D4E":"\u0971","\uFF0D":"\u30FC","\u2014":"\u30FC","\u2015":"\u30FC","\u2500":"\u30FC","\u2501":"\u30FC","\u31D0":"\u30FC","\uA7F7":"\u30FC",\u1173:"\u30FC",\u3161:"\u30FC",\u4E00:"\u30FC","\u2F00":"\u30FC",\u1196:"\u30FC\u30FC","\uD7B9":"\u30FC\u1161","\uD7BA":"\u30FC\u1165","\uD7BB":"\u30FC\u1165\u4E28","\uD7BC":"\u30FC\u1169",\u1195:"\u30FC\u116E",\u1174:"\u30FC\u4E28",\u3162:"\u30FC\u4E28",\u1197:"\u30FC\u4E28\u116E","\u{1F10F}":"$\u20E0","\u20A4":"\xA3","\u3012":"\u20B8","\u3036":"\u20B8","\u1B5C":"\u1B50","\uA9C6":"\uA9D0","\u{114D1}":"\u09E7","\u0CE7":"\u0C67","\u1065":"\u1041","\u2460":"\u2780","\u2469":"\u2789","\u23E8":"\u2081\u2080","\u{1D7D0}":"2","\u{1D7DA}":"2","\u{1D7E4}":"2","\u{1D7EE}":"2","\u{1D7F8}":"2","\u{1FBF2}":"2","\uA75A":"2",\u01A7:"2",\u03E8:"2","\uA644":"2",\u14BF:"2","\uA6EF":"2","\uA9CF":"\u0662","\u06F2":"\u0662","\u0AE8":"\u0968","\u{114D2}":"\u09E8","\u0CE8":"\u0C68","\u2461":"\u2781",\u01BB:"2\u0335","\u{1F103}":"2,","\u2489":"2.","\u33F5":"22\u65E5","\u336E":"22\u70B9","\u33F6":"23\u65E5","\u336F":"23\u70B9","\u33F7":"24\u65E5","\u3370":"24\u70B9","\u33F8":"25\u65E5","\u33F9":"26\u65E5","\u33FA":"27\u65E5","\u33FB":"28\u65E5","\u33FC":"29\u65E5","\u33F4":"2l\u65E5","\u336D":"2l\u70B9","\u249B":"2O.","\u33F3":"2O\u65E5","\u336C":"2O\u70B9","\u0DE9":"\u0DE8\u0DCF","\u0DEF":"\u0DE8\u0DD3","\u33E1":"2\u65E5","\u32C1":"2\u6708","\u335A":"2\u70B9","\u{1D206}":"3","\u{1D7D1}":"3","\u{1D7DB}":"3","\u{1D7E5}":"3","\u{1D7EF}":"3","\u{1D7F9}":"3","\u{1FBF3}":"3","\uA7AB":"3",\u021C:"3",\u01B7:"3","\uA76A":"3","\u2CCC":"3",\u0417:"3",\u04E0:"3","\u{16F3B}":"3","\u{118CA}":"3","\u06F3":"\u0663","\u{1E8C9}":"\u0663","\u0AE9":"\u0969","\u2462":"\u2782",\u0498:"3\u0326","\u{1F104}":"3,","\u248A":"3.","\u33FE":"3l\u65E5","\u33FD":"3O\u65E5","\u33E2":"3\u65E5","\u32C2":"3\u6708","\u335B":"3\u70B9","\u{1D7D2}":"4","\u{1D7DC}":"4","\u{1D7E6}":"4","\u{1D7F0}":"4","\u{1D7FA}":"4","\u{1FBF4}":"4",\u13CE:"4","\u{118AF}":"4","\u06F4":"\u0664","\u0AEA":"\u096A","\u2463":"\u2783","\u{1F105}":"4,","\u248B":"4.",\u1530:"4\xB7","\u33E3":"4\u65E5","\u32C3":"4\u6708","\u335C":"4\u70B9","\u{1D7D3}":"5","\u{1D7DD}":"5","\u{1D7E7}":"5","\u{1D7F1}":"5","\u{1D7FB}":"5","\u{1FBF5}":"5",\u01BC:"5","\u{118BB}":"5","\u2464":"\u2784","\u{1F106}":"5,","\u248C":"5.","\u33E4":"5\u65E5","\u32C4":"5\u6708","\u335D":"5\u70B9","\u{1D7D4}":"6","\u{1D7DE}":"6","\u{1D7E8}":"6","\u{1D7F2}":"6","\u{1D7FC}":"6","\u{1FBF6}":"6","\u2CD2":"6",\u0431:"6",\u13EE:"6","\u{118D5}":"6","\u06F6":"\u0666","\u{114D6}":"\u09EC","\u2465":"\u2785","\u{1F107}":"6,","\u248D":"6.","\u33E5":"6\u65E5","\u32C5":"6\u6708","\u335E":"6\u70B9","\u{1D212}":"7","\u{1D7D5}":"7","\u{1D7DF}":"7","\u{1D7E9}":"7","\u{1D7F3}":"7","\u{1D7FD}":"7","\u{1FBF7}":"7","\u{104D2}":"7","\u{118C6}":"7","\u2466":"\u2786","\u{1F108}":"7,","\u248E":"7.","\u33E6":"7\u65E5","\u32C6":"7\u6708","\u335F":"7\u70B9","\u0B03":"8","\u09EA":"8","\u0A6A":"8","\u{1E8CB}":"8","\u{1D7D6}":"8","\u{1D7E0}":"8","\u{1D7EA}":"8","\u{1D7F4}":"8","\u{1D7FE}":"8","\u{1FBF8}":"8",\u0223:"8",\u0222:"8","\u{1031A}":"8","\u0AEE":"\u096E","\u2467":"\u2787","\u{1F109}":"8,","\u248F":"8.","\u33E7":"8\u65E5","\u32C7":"8\u6708","\u3360":"8\u70B9","\u0A67":"9","\u0B68":"9","\u09ED":"9","\u0D6D":"9","\u{1D7D7}":"9","\u{1D7E1}":"9","\u{1D7EB}":"9","\u{1D7F5}":"9","\u{1D7FF}":"9","\u{1FBF9}":"9","\uA76E":"9","\u2CCA":"9","\u{118CC}":"9","\u{118AC}":"9","\u{118D6}":"9","\u0967":"\u0669","\u{118E4}":"\u0669","\u06F9":"\u0669","\u0CEF":"\u0C6F","\u2468":"\u2788","\u{1F10A}":"9,","\u2490":"9.","\u33E8":"9\u65E5","\u32C8":"9\u6708","\u3361":"9\u70B9","\u237A":"a",\uFF41:"a","\u{1D41A}":"a","\u{1D44E}":"a","\u{1D482}":"a","\u{1D4B6}":"a","\u{1D4EA}":"a","\u{1D51E}":"a","\u{1D552}":"a","\u{1D586}":"a","\u{1D5BA}":"a","\u{1D5EE}":"a","\u{1D622}":"a","\u{1D656}":"a","\u{1D68A}":"a",\u0251:"a",\u03B1:"a","\u{1D6C2}":"a","\u{1D6FC}":"a","\u{1D736}":"a","\u{1D770}":"a","\u{1D7AA}":"a",\u0430:"a","\u2DF6":"\u0363",\uFF21:"A","\u{1D400}":"A","\u{1D434}":"A","\u{1D468}":"A","\u{1D49C}":"A","\u{1D4D0}":"A","\u{1D504}":"A","\u{1D538}":"A","\u{1D56C}":"A","\u{1D5A0}":"A","\u{1D5D4}":"A","\u{1D608}":"A","\u{1D63C}":"A","\u{1D670}":"A",\u0391:"A","\u{1D6A8}":"A","\u{1D6E2}":"A","\u{1D71C}":"A","\u{1D756}":"A","\u{1D790}":"A",\u0410:"A",\u13AA:"A",\u15C5:"A","\uA4EE":"A","\u{16F40}":"A","\u{102A0}":"A","\u2376":"a\u0332",\u01CE:"\u0103",\u01CD:"\u0102",\u0227:"\xE5",\u0226:"\xC5",\u1E9A:"\u1EA3","\u2100":"a/c","\u2101":"a/s","\uA733":"aa","\uA732":"AA",\u00E6:"ae",\u04D5:"ae",\u00C6:"AE",\u04D4:"AE","\uA735":"ao","\uA734":"AO","\u{1F707}":"AR","\uA737":"au","\uA736":"AU","\uA739":"av","\uA73B":"av","\uA738":"AV","\uA73A":"AV","\uA73D":"ay","\uA73C":"AY","\uAB7A":"\u1D00","\u2200":"\u2C6F","\u{1D217}":"\u2C6F",\u15C4:"\u2C6F","\uA4EF":"\u2C6F","\u{1041F}":"\u2C70","\u{1D41B}":"b","\u{1D44F}":"b","\u{1D483}":"b","\u{1D4B7}":"b","\u{1D4EB}":"b","\u{1D51F}":"b","\u{1D553}":"b","\u{1D587}":"b","\u{1D5BB}":"b","\u{1D5EF}":"b","\u{1D623}":"b","\u{1D657}":"b","\u{1D68B}":"b",\u0184:"b",\u042C:"b",\u13CF:"b",\u1472:"b",\u15AF:"b",\uFF22:"B",\u212C:"B","\u{1D401}":"B","\u{1D435}":"B","\u{1D469}":"B","\u{1D4D1}":"B","\u{1D505}":"B","\u{1D539}":"B","\u{1D56D}":"B","\u{1D5A1}":"B","\u{1D5D5}":"B","\u{1D609}":"B","\u{1D63D}":"B","\u{1D671}":"B","\uA7B4":"B",\u0392:"B","\u{1D6A9}":"B","\u{1D6E3}":"B","\u{1D71D}":"B","\u{1D757}":"B","\u{1D791}":"B",\u0412:"B",\u13F4:"B",\u15F7:"B","\uA4D0":"B","\u{10282}":"B","\u{102A1}":"B","\u{10301}":"B",\u0253:"b\u0314",\u1473:"b\u0307",\u0183:"b\u0304",\u0182:"b\u0304",\u0411:"b\u0304",\u0180:"b\u0335",\u048D:"b\u0335",\u048C:"b\u0335",\u0463:"b\u0335",\u0462:"b\u0335",\u147F:"b\xB7",\u1481:"b\u0307\xB7",\u1488:"b'",\u042B:"bl",\u0432:"\u0299","\u13FC":"\u0299",\uFF43:"c","\u217D":"c","\u{1D41C}":"c","\u{1D450}":"c","\u{1D484}":"c","\u{1D4B8}":"c","\u{1D4EC}":"c","\u{1D520}":"c","\u{1D554}":"c","\u{1D588}":"c","\u{1D5BC}":"c","\u{1D5F0}":"c","\u{1D624}":"c","\u{1D658}":"c","\u{1D68C}":"c","\u1D04":"c",\u03F2:"c","\u2CA5":"c",\u0441:"c","\uABAF":"c","\u{1043D}":"c","\u2DED":"\u0368","\u{1F74C}":"C","\u{118F2}":"C","\u{118E9}":"C",\uFF23:"C","\u216D":"C",\u2102:"C",\u212D:"C","\u{1D402}":"C","\u{1D436}":"C","\u{1D46A}":"C","\u{1D49E}":"C","\u{1D4D2}":"C","\u{1D56E}":"C","\u{1D5A2}":"C","\u{1D5D6}":"C","\u{1D60A}":"C","\u{1D63E}":"C","\u{1D672}":"C","\u03F9":"C","\u2CA4":"C",\u0421:"C",\u13DF:"C","\uA4DA":"C","\u{102A2}":"C","\u{10302}":"C","\u{10415}":"C","\u{1051C}":"C","\xA2":"c\u0338","\u023C":"c\u0338","\u20A1":"C\u20EB","\u{1F16E}":"C\u20E0",\u00E7:"c\u0326",\u04AB:"c\u0326",\u00C7:"C\u0326",\u04AA:"C\u0326",\u0187:"C'","\u2105":"c/o","\u2106":"c/u","\u{1F16D}":"\u33C4 \u20DD","\u22F4":"\uA793",\u025B:"\uA793",\u03B5:"\uA793","\u03F5":"\uA793","\u{1D6C6}":"\uA793","\u{1D6DC}":"\uA793","\u{1D700}":"\uA793","\u{1D716}":"\uA793","\u{1D73A}":"\uA793","\u{1D750}":"\uA793","\u{1D774}":"\uA793","\u{1D78A}":"\uA793","\u{1D7AE}":"\uA793","\u{1D7C4}":"\uA793","\u2C89":"\uA793",\u0454:"\uA793","\u0511":"\uA793","\uAB9B":"\uA793","\u{118CE}":"\uA793","\u{10429}":"\uA793","\u20AC":"\uA792","\u2C88":"\uA792",\u0404:"\uA792","\u2377":"\uA793\u0332","\u037D":"\uA73F","\u03FF":"\uA73E","\u217E":"d","\u2146":"d","\u{1D41D}":"d","\u{1D451}":"d","\u{1D485}":"d","\u{1D4B9}":"d","\u{1D4ED}":"d","\u{1D521}":"d","\u{1D555}":"d","\u{1D589}":"d","\u{1D5BD}":"d","\u{1D5F1}":"d","\u{1D625}":"d","\u{1D659}":"d","\u{1D68D}":"d","\u0501":"d",\u13E7:"d",\u146F:"d","\uA4D2":"d","\u216E":"D","\u2145":"D","\u{1D403}":"D","\u{1D437}":"D","\u{1D46B}":"D","\u{1D49F}":"D","\u{1D4D3}":"D","\u{1D507}":"D","\u{1D53B}":"D","\u{1D56F}":"D","\u{1D5A3}":"D","\u{1D5D7}":"D","\u{1D60B}":"D","\u{1D63F}":"D","\u{1D673}":"D",\u13A0:"D",\u15DE:"D",\u15EA:"D","\uA4D3":"D",\u0257:"d\u0314",\u0256:"d\u0328",\u018C:"d\u0304",\u0111:"d\u0335",\u0110:"D\u0335",\u00D0:"D\u0335",\u0189:"D\u0335","\u20AB":"d\u0335\u0331","\uA77A":"\uA779",\u147B:"d\xB7",\u1487:"d'",\u02A4:"d\u021D",\u01F3:"dz",\u02A3:"dz",\u01F2:"Dz",\u01F1:"DZ",\u01C6:"d\u017E",\u01C5:"D\u017E",\u01C4:"D\u017D",\u02A5:"d\u0291","\uAB70":"\u1D05","\u2E39":"\u1E9F",\u03B4:"\u1E9F","\u{1D6C5}":"\u1E9F","\u{1D6FF}":"\u1E9F","\u{1D739}":"\u1E9F","\u{1D773}":"\u1E9F","\u{1D7AD}":"\u1E9F",\u056E:"\u1E9F",\u1577:"\u1E9F","\u212E":"e",\uFF45:"e",\u212F:"e","\u2147":"e","\u{1D41E}":"e","\u{1D452}":"e","\u{1D486}":"e","\u{1D4EE}":"e","\u{1D522}":"e","\u{1D556}":"e","\u{1D58A}":"e","\u{1D5BE}":"e","\u{1D5F2}":"e","\u{1D626}":"e","\u{1D65A}":"e","\u{1D68E}":"e","\uAB32":"e",\u0435:"e",\u04BD:"e","\u2DF7":"\u0364","\u22FF":"E",\uFF25:"E",\u2130:"E","\u{1D404}":"E","\u{1D438}":"E","\u{1D46C}":"E","\u{1D4D4}":"E","\u{1D508}":"E","\u{1D53C}":"E","\u{1D570}":"E","\u{1D5A4}":"E","\u{1D5D8}":"E","\u{1D60C}":"E","\u{1D640}":"E","\u{1D674}":"E",\u0395:"E","\u{1D6AC}":"E","\u{1D6E6}":"E","\u{1D720}":"E","\u{1D75A}":"E","\u{1D794}":"E",\u0415:"E","\u2D39":"E",\u13AC:"E","\uA4F0":"E","\u{118A6}":"E","\u{118AE}":"E","\u{10286}":"E",\u011B:"\u0115",\u011A:"\u0114","\u0247":"e\u0338","\u0246":"E\u0338",\u04BF:"e\u0328","\uAB7C":"\u1D07",\u0259:"\u01DD",\u04D9:"\u01DD","\u2203":"\u018E","\u2D3A":"\u018E","\uA4F1":"\u018E",\u025A:"\u01DD\u02DE","\u1D14":"\u01DDo","\uAB41":"\u01DDo\u0338","\uAB42":"\u01DDo\u0335",\u04D8:"\u018F","\u{1D221}":"\u0190",\u2107:"\u0190","\u0510":"\u0190",\u13CB:"\u0190","\u{16F2D}":"\u0190","\u{10401}":"\u0190","\u1D9F":"\u1D4B","\u1D08":"\u025C",\u0437:"\u025C",\u0499:"\u025C\u0326","\u{10442}":"\u025E","\uA79D":"\u029A","\u{1042A}":"\u029A","\u{1D41F}":"f","\u{1D453}":"f","\u{1D487}":"f","\u{1D4BB}":"f","\u{1D4EF}":"f","\u{1D523}":"f","\u{1D557}":"f","\u{1D58B}":"f","\u{1D5BF}":"f","\u{1D5F3}":"f","\u{1D627}":"f","\u{1D65B}":"f","\u{1D68F}":"f","\uAB35":"f","\uA799":"f",\u017F:"f","\u1E9D":"f",\u0584:"f","\u{1D213}":"F",\u2131:"F","\u{1D405}":"F","\u{1D439}":"F","\u{1D46D}":"F","\u{1D4D5}":"F","\u{1D509}":"F","\u{1D53D}":"F","\u{1D571}":"F","\u{1D5A5}":"F","\u{1D5D9}":"F","\u{1D60D}":"F","\u{1D641}":"F","\u{1D675}":"F","\uA798":"F",\u03DC:"F","\u{1D7CA}":"F",\u15B4:"F","\uA4DD":"F","\u{118C2}":"F","\u{118A2}":"F","\u{10287}":"F","\u{102A5}":"F","\u{10525}":"F",\u0192:"f\u0326",\u0191:"F\u0326","\u1D6E":"f\u0334","\u213B":"FAX",\uFB00:"ff",\uFB03:"ffi",\uFB04:"ffl",\uFB01:"fi",\uFB02:"fl",\u02A9:"f\u014B",\u15B5:"\u2132","\uA4DE":"\u2132","\u{1D230}":"\uA7FB",\u15B7:"\uA7FB",\uFF47:"g",\u210A:"g","\u{1D420}":"g","\u{1D454}":"g","\u{1D488}":"g","\u{1D4F0}":"g","\u{1D524}":"g","\u{1D558}":"g","\u{1D58C}":"g","\u{1D5C0}":"g","\u{1D5F4}":"g","\u{1D628}":"g","\u{1D65C}":"g","\u{1D690}":"g",\u0261:"g","\u1D83":"g",\u018D:"g",\u0581:"g","\u{1D406}":"G","\u{1D43A}":"G","\u{1D46E}":"G","\u{1D4A2}":"G","\u{1D4D6}":"G","\u{1D50A}":"G","\u{1D53E}":"G","\u{1D572}":"G","\u{1D5A6}":"G","\u{1D5DA}":"G","\u{1D60E}":"G","\u{1D642}":"G","\u{1D676}":"G","\u050C":"G",\u13C0:"G",\u13F3:"G","\uA4D6":"G","\u1DA2":"\u1D4D",\u0260:"g\u0314",\u01E7:"\u011F",\u01E6:"\u011E",\u01F5:"\u0123",\u01E5:"g\u0335",\u01E4:"G\u0335",\u0193:"G'","\u050D":"\u0262","\uAB90":"\u0262","\u13FB":"\u0262",\uFF48:"h",\u210E:"h","\u{1D421}":"h","\u{1D489}":"h","\u{1D4BD}":"h","\u{1D4F1}":"h","\u{1D525}":"h","\u{1D559}":"h","\u{1D58D}":"h","\u{1D5C1}":"h","\u{1D5F5}":"h","\u{1D629}":"h","\u{1D65D}":"h","\u{1D691}":"h",\u04BB:"h",\u0570:"h",\u13C2:"h",\uFF28:"H",\u210B:"H",\u210C:"H",\u210D:"H","\u{1D407}":"H","\u{1D43B}":"H","\u{1D46F}":"H","\u{1D4D7}":"H","\u{1D573}":"H","\u{1D5A7}":"H","\u{1D5DB}":"H","\u{1D60F}":"H","\u{1D643}":"H","\u{1D677}":"H",\u0397:"H","\u{1D6AE}":"H","\u{1D6E8}":"H","\u{1D722}":"H","\u{1D75C}":"H","\u{1D796}":"H","\u2C8E":"H",\u041D:"H",\u13BB:"H",\u157C:"H","\uA4E7":"H","\u{102CF}":"H","\u1D78":"\u1D34",\u0266:"h\u0314","\uA695":"h\u0314",\u13F2:"h\u0314","\u2C67":"H\u0329",\u04A2:"H\u0329",\u0127:"h\u0335",\u210F:"h\u0335",\u045B:"h\u0335",\u0126:"H\u0335","\u04C9":"H\u0326",\u04C7:"H\u0326",\u043D:"\u029C","\uAB8B":"\u029C",\u04A3:"\u029C\u0329","\u04CA":"\u029C\u0326",\u04C8:"\u029C\u0326","\u050A":"\u01F6","\uAB80":"\u2C76","\u0370":"\u2C75",\u13A8:"\u2C75",\u13B0:"\u2C75","\uA6B1":"\u2C75","\uA795":"\uA727","\u02DB":"i","\u2373":"i",\uFF49:"i","\u2170":"i",\u2139:"i","\u2148":"i","\u{1D422}":"i","\u{1D456}":"i","\u{1D48A}":"i","\u{1D4BE}":"i","\u{1D4F2}":"i","\u{1D526}":"i","\u{1D55A}":"i","\u{1D58E}":"i","\u{1D5C2}":"i","\u{1D5F6}":"i","\u{1D62A}":"i","\u{1D65E}":"i","\u{1D692}":"i",\u0131:"i","\u{1D6A4}":"i",\u026A:"i",\u0269:"i",\u03B9:"i",\u1FBE:"i",\u037A:"i","\u{1D6CA}":"i","\u{1D704}":"i","\u{1D73E}":"i","\u{1D778}":"i","\u{1D7B2}":"i",\u0456:"i","\uA647":"i","\u04CF":"i","\uAB75":"i",\u13A5:"i","\u{118C3}":"i","\u24DB":"\u24BE","\u2378":"i\u0332",\u01D0:"\u012D",\u01CF:"\u012C",\u0268:"i\u0335","\u1D7B":"i\u0335","\u1D7C":"i\u0335","\u2171":"ii","\u2172":"iii",\u0133:"ij","\u2173":"iv","\u2178":"ix",\uFF4A:"j","\u2149":"j","\u{1D423}":"j","\u{1D457}":"j","\u{1D48B}":"j","\u{1D4BF}":"j","\u{1D4F3}":"j","\u{1D527}":"j","\u{1D55B}":"j","\u{1D58F}":"j","\u{1D5C3}":"j","\u{1D5F7}":"j","\u{1D62B}":"j","\u{1D65F}":"j","\u{1D693}":"j",\u03F3:"j",\u0458:"j",\uFF2A:"J","\u{1D409}":"J","\u{1D43D}":"J","\u{1D471}":"J","\u{1D4A5}":"J","\u{1D4D9}":"J","\u{1D50D}":"J","\u{1D541}":"J","\u{1D575}":"J","\u{1D5A9}":"J","\u{1D5DD}":"J","\u{1D611}":"J","\u{1D645}":"J","\u{1D679}":"J","\uA7B2":"J","\u037F":"J",\u0408:"J",\u13AB:"J",\u148D:"J","\uA4D9":"J","\u0249":"j\u0335","\u0248":"J\u0335",\u1499:"J\xB7","\u{1D6A5}":"\u0237",\u0575:"\u0237","\uAB7B":"\u1D0A","\u{1D424}":"k","\u{1D458}":"k","\u{1D48C}":"k","\u{1D4C0}":"k","\u{1D4F4}":"k","\u{1D528}":"k","\u{1D55C}":"k","\u{1D590}":"k","\u{1D5C4}":"k","\u{1D5F8}":"k","\u{1D62C}":"k","\u{1D660}":"k","\u{1D694}":"k",\u212A:"K",\uFF2B:"K","\u{1D40A}":"K","\u{1D43E}":"K","\u{1D472}":"K","\u{1D4A6}":"K","\u{1D4DA}":"K","\u{1D50E}":"K","\u{1D542}":"K","\u{1D576}":"K","\u{1D5AA}":"K","\u{1D5DE}":"K","\u{1D612}":"K","\u{1D646}":"K","\u{1D67A}":"K",\u039A:"K","\u{1D6B1}":"K","\u{1D6EB}":"K","\u{1D725}":"K","\u{1D75F}":"K","\u{1D799}":"K","\u2C94":"K",\u041A:"K",\u13E6:"K",\u16D5:"K","\uA4D7":"K","\u{10518}":"K",\u0199:"k\u0314","\u2C69":"K\u0329",\u049A:"K\u0329","\u20AD":"K\u0335","\uA740":"K\u0335",\u049E:"K\u0335",\u0198:"K'","\u05C0":"l","|":"l","\u2223":"l","\u23FD":"l","\uFFE8":"l","\u0661":"l","\u06F1":"l","\u{10320}":"l","\u{1E8C7}":"l","\u{1D7CF}":"l","\u{1D7D9}":"l","\u{1D7E3}":"l","\u{1D7ED}":"l","\u{1D7F7}":"l","\u{1FBF1}":"l",I:vb,\uFF29:"l","\u2160":"l",\u2110:"l",\u2111:"l","\u{1D408}":"l","\u{1D43C}":"l","\u{1D470}":"l","\u{1D4D8}":"l","\u{1D540}":"l","\u{1D574}":"l","\u{1D5A8}":"l","\u{1D5DC}":"l","\u{1D610}":"l","\u{1D644}":"l","\u{1D678}":"l",\u0196:"l",\uFF4C:"l","\u217C":"l",\u2113:"l","\u{1D425}":"l","\u{1D459}":"l","\u{1D48D}":"l","\u{1D4C1}":"l","\u{1D4F5}":"l","\u{1D529}":"l","\u{1D55D}":"l","\u{1D591}":"l","\u{1D5C5}":"l","\u{1D5F9}":"l","\u{1D62D}":"l","\u{1D661}":"l","\u{1D695}":"l",\u01C0:"l",\u0399:"l","\u{1D6B0}":"l","\u{1D6EA}":"l","\u{1D724}":"l","\u{1D75E}":"l","\u{1D798}":"l","\u2C92":"l",\u0406:"l",\u04C0:"l",\u05D5:"l",\u05DF:"l",\u0627:"l","\u{1EE00}":"l","\u{1EE80}":"l",\uFE8E:"l",\uFE8D:"l","\u07CA":"l","\u2D4F":"l",\u16C1:"l","\uA4F2":"l","\u{16F28}":"l","\u{1028A}":"l","\u{10309}":"l","\u{1D22A}":"L","\u216C":"L",\u2112:"L","\u{1D40B}":"L","\u{1D43F}":"L","\u{1D473}":"L","\u{1D4DB}":"L","\u{1D50F}":"L","\u{1D543}":"L","\u{1D577}":"L","\u{1D5AB}":"L","\u{1D5DF}":"L","\u{1D613}":"L","\u{1D647}":"L","\u{1D67B}":"L","\u2CD0":"L",\u13DE:"L",\u14AA:"L","\uA4E1":"L","\u{16F16}":"L","\u{118A3}":"L","\u{118B2}":"L","\u{1041B}":"L","\u{10526}":"L",\uFD3C:"l\u030B",\uFD3D:"l\u030B",\u0142:"l\u0338",\u0141:"L\u0338",\u026D:"l\u0328",\u0197:"l\u0335",\u019A:"l\u0335",\u026B:"l\u0334",\u0625:"l\u0655",\uFE88:"l\u0655",\uFE87:"l\u0655",\u0673:"l\u0655",\u0140:"l\xB7",\u013F:"l\xB7",\u14B7:"l\xB7","\u{1F102}":"l,","\u2488":"l.",\u05F1:"l'","\u2493":"l2.","\u33EB":"l2\u65E5","\u32CB":"l2\u6708","\u3364":"l2\u70B9","\u2494":"l3.","\u33EC":"l3\u65E5","\u3365":"l3\u70B9","\u2495":"l4.","\u33ED":"l4\u65E5","\u3366":"l4\u70B9","\u2496":"l5.","\u33EE":"l5\u65E5","\u3367":"l5\u70B9","\u2497":"l6.","\u33EF":"l6\u65E5","\u3368":"l6\u70B9","\u2498":"l7.","\u33F0":"l7\u65E5","\u3369":"l7\u70B9","\u2499":"l8.","\u33F1":"l8\u65E5","\u336A":"l8\u70B9","\u249A":"l9.","\u33F2":"l9\u65E5","\u336B":"l9\u70B9",\u01C9:"lj",\u0132:"lJ",\u01C8:"Lj",\u01C7:"LJ","\u2016":"ll","\u2225":"ll","\u2161":"ll",\u01C1:"ll",\u05F0:"ll","\u{10199}":"l\u0335l\u0335","\u2492":"ll.","\u2162":"lll","\u{10198}":"l\u0335l\u0335S\u0335","\u33EA":"ll\u65E5","\u32CA":"ll\u6708","\u3363":"ll\u70B9",\u042E:"lO","\u2491":"lO.","\u33E9":"lO\u65E5","\u32C9":"lO\u6708","\u3362":"lO\u70B9",\u02AA:"ls","\u20B6":"lt","\u2163":"lV","\u2168":"lX",\u026E:"l\u021D",\u02AB:"lz",\u0623:"l\u0674",\uFE84:"l\u0674",\uFE83:"l\u0674",\u0672:"l\u0674",\u0675:"l\u0674",\uFDF3:"l\u0643\u0628\u0631",\uFDF2:"l\u0644\u0644\u0651\u0670o","\u33E0":"l\u65E5","\u32C0":"l\u6708","\u3359":"l\u70B9","\u2CD1":"\u029F","\uABAE":"\u029F","\u{10443}":"\u029F",\uFF2D:"M","\u216F":"M",\u2133:"M","\u{1D40C}":"M","\u{1D440}":"M","\u{1D474}":"M","\u{1D4DC}":"M","\u{1D510}":"M","\u{1D544}":"M","\u{1D578}":"M","\u{1D5AC}":"M","\u{1D5E0}":"M","\u{1D614}":"M","\u{1D648}":"M","\u{1D67C}":"M",\u039C:"M","\u{1D6B3}":"M","\u{1D6ED}":"M","\u{1D727}":"M","\u{1D761}":"M","\u{1D79B}":"M","\u03FA":"M","\u2C98":"M",\u041C:"M",\u13B7:"M",\u15F0:"M",\u16D6:"M","\uA4DF":"M","\u{102B0}":"M","\u{10311}":"M","\u04CD":"M\u0326","\u{1F76B}":"MB","\u2DE8":"\u1DDF","\u{1D427}":"n","\u{1D45B}":"n","\u{1D48F}":"n","\u{1D4C3}":"n","\u{1D4F7}":"n","\u{1D52B}":"n","\u{1D55F}":"n","\u{1D593}":"n","\u{1D5C7}":"n","\u{1D5FB}":"n","\u{1D62F}":"n","\u{1D663}":"n","\u{1D697}":"n",\u0578:"n",\u057C:"n",\uFF2E:"N",\u2115:"N","\u{1D40D}":"N","\u{1D441}":"N","\u{1D475}":"N","\u{1D4A9}":"N","\u{1D4DD}":"N","\u{1D511}":"N","\u{1D579}":"N","\u{1D5AD}":"N","\u{1D5E1}":"N","\u{1D615}":"N","\u{1D649}":"N","\u{1D67D}":"N",\u039D:"N","\u{1D6B4}":"N","\u{1D6EE}":"N","\u{1D728}":"N","\u{1D762}":"N","\u{1D79C}":"N","\u2C9A":"N","\uA4E0":"N","\u{10513}":"N","\u{1018E}":"N\u030A",\u0273:"n\u0328",\u019E:"n\u0329",\u03B7:"n\u0329","\u{1D6C8}":"n\u0329","\u{1D702}":"n\u0329","\u{1D73C}":"n\u0329","\u{1D776}":"n\u0329","\u{1D7B0}":"n\u0329",\u019D:"N\u0326","\u1D70":"n\u0334",\u01CC:"nj",\u01CB:"Nj",\u01CA:"NJ","\u2116":"No","\u0377":"\u1D0E",\u0438:"\u1D0E","\u{1044D}":"\u1D0E",\u0146:"\u0272","\u0C02":"o","\u0C82":"o","\u0D02":"o","\u0D82":"o","\u0966":"o","\u0A66":"o","\u0AE6":"o","\u0BE6":"o","\u0C66":"o","\u0CE6":"o","\u0D66":"o","\u0E50":"o","\u0ED0":"o","\u1040":"o","\u0665":"o","\u06F5":"o",\uFF4F:"o",\u2134:"o","\u{1D428}":"o","\u{1D45C}":"o","\u{1D490}":"o","\u{1D4F8}":"o","\u{1D52C}":"o","\u{1D560}":"o","\u{1D594}":"o","\u{1D5C8}":"o","\u{1D5FC}":"o","\u{1D630}":"o","\u{1D664}":"o","\u{1D698}":"o","\u1D0F":"o","\u1D11":"o","\uAB3D":"o",\u03BF:"o","\u{1D6D0}":"o","\u{1D70A}":"o","\u{1D744}":"o","\u{1D77E}":"o","\u{1D7B8}":"o",\u03C3:"o","\u{1D6D4}":"o","\u{1D70E}":"o","\u{1D748}":"o","\u{1D782}":"o","\u{1D7BC}":"o","\u2C9F":"o",\u043E:"o","\u10FF":"o",\u0585:"o",\u05E1:"o",\u0647:"o","\u{1EE24}":"o","\u{1EE64}":"o","\u{1EE84}":"o",\uFEEB:"o",\uFEEC:"o",\uFEEA:"o",\uFEE9:"o",\u06BE:"o",\uFBAC:"o",\uFBAD:"o",\uFBAB:"o",\uFBAA:"o",\u06C1:"o",\uFBA8:"o",\uFBA9:"o",\uFBA7:"o",\uFBA6:"o",\u06D5:"o",\u0D20:"o",\u101D:"o","\u{104EA}":"o","\u{118C8}":"o","\u{118D7}":"o","\u{1042C}":"o","\u07C0":"O","\u09E6":"O","\u0B66":"O","\u3007":"O","\u{114D0}":"O","\u{118E0}":"O","\u{1D7CE}":"O","\u{1D7D8}":"O","\u{1D7E2}":"O","\u{1D7EC}":"O","\u{1D7F6}":"O","\u{1FBF0}":"O",\uFF2F:"O","\u{1D40E}":"O","\u{1D442}":"O","\u{1D476}":"O","\u{1D4AA}":"O","\u{1D4DE}":"O","\u{1D512}":"O","\u{1D546}":"O","\u{1D57A}":"O","\u{1D5AE}":"O","\u{1D5E2}":"O","\u{1D616}":"O","\u{1D64A}":"O","\u{1D67E}":"O",\u039F:"O","\u{1D6B6}":"O","\u{1D6F0}":"O","\u{1D72A}":"O","\u{1D764}":"O","\u{1D79E}":"O","\u2C9E":"O",\u041E:"O",\u0555:"O","\u2D54":"O",\u12D0:"O",\u0B20:"O","\u{104C2}":"O","\uA4F3":"O","\u{118B5}":"O","\u{10292}":"O","\u{102AB}":"O","\u{10404}":"O","\u{10516}":"O","\u2070":"\xBA","\u1D52":"\xBA",\u01D2:"\u014F",\u01D1:"\u014E","\u06FF":"o\u0302",\u0150:"\xD6",\u00F8:"o\u0338","\uAB3E":"o\u0338",\u00D8:"O\u0338","\u2D41":"O\u0338",\u01FE:"O\u0338\u0301",\u0275:"o\u0335","\uA74B":"o\u0335",\u04E9:"o\u0335",\u0473:"o\u0335","\uAB8E":"o\u0335","\uABBB":"o\u0335","\u2296":"O\u0335","\u229D":"O\u0335","\u236C":"O\u0335","\u{1D21A}":"O\u0335","\u{1F714}":"O\u0335",\u019F:"O\u0335","\uA74A":"O\u0335",\u03B8:"O\u0335",\u03D1:"O\u0335","\u{1D6C9}":"O\u0335","\u{1D6DD}":"O\u0335","\u{1D703}":"O\u0335","\u{1D717}":"O\u0335","\u{1D73D}":"O\u0335","\u{1D751}":"O\u0335","\u{1D777}":"O\u0335","\u{1D78B}":"O\u0335","\u{1D7B1}":"O\u0335","\u{1D7C5}":"O\u0335",\u0398:"O\u0335","\u03F4":"O\u0335","\u{1D6AF}":"O\u0335","\u{1D6B9}":"O\u0335","\u{1D6E9}":"O\u0335","\u{1D6F3}":"O\u0335","\u{1D723}":"O\u0335","\u{1D72D}":"O\u0335","\u{1D75D}":"O\u0335","\u{1D767}":"O\u0335","\u{1D797}":"O\u0335","\u{1D7A1}":"O\u0335",\u04E8:"O\u0335",\u0472:"O\u0335","\u2D31":"O\u0335",\u13BE:"O\u0335",\u13EB:"O\u0335","\uAB74":"o\u031B",\uFCD9:"o\u0670","\u{1F101}":"O,","\u{1F100}":"O.",\u01A1:"o'",\u01A0:"O'",\u13A4:"O'","%":"\xBA/\u2080","\u066A":"\xBA/\u2080","\u2052":"\xBA/\u2080","\u2030":"\xBA/\u2080\u2080","\u0609":"\xBA/\u2080\u2080","\u2031":"\xBA/\u2080\u2080\u2080","\u060A":"\xBA/\u2080\u2080\u2080",\u0153:"oe",\u0152:"OE",\u0276:"o\u1D07","\u221E":"oo","\uA74F":"oo","\uA699":"oo","\uA74E":"OO","\uA698":"OO",\uFCD7:"o\u062C",\uFC51:"o\u062C",\uFCD8:"o\u0645",\uFC52:"o\u0645",\uFD93:"o\u0645\u062C",\uFD94:"o\u0645\u0645",\uFC53:"o\u0649",\uFC54:"o\u0649","\u0D5F":"o\u0D30o",\u1010:"o\u102C","\u3358":"O\u70B9","\u2184":"\u0254","\u1D10":"\u0254","\u037B":"\u0254","\u{1044B}":"\u0254","\u2183":"\u0186","\u03FD":"\u0186","\uA4DB":"\u0186","\u{10423}":"\u0186","\uAB3F":"\u0254\u0338","\uAB62":"\u0254e","\u{1043F}":"\u0277","\u2374":"p",\uFF50:"p","\u{1D429}":"p","\u{1D45D}":"p","\u{1D491}":"p","\u{1D4C5}":"p","\u{1D4F9}":"p","\u{1D52D}":"p","\u{1D561}":"p","\u{1D595}":"p","\u{1D5C9}":"p","\u{1D5FD}":"p","\u{1D631}":"p","\u{1D665}":"p","\u{1D699}":"p",\u03C1:"p",\u03F1:"p","\u{1D6D2}":"p","\u{1D6E0}":"p","\u{1D70C}":"p","\u{1D71A}":"p","\u{1D746}":"p","\u{1D754}":"p","\u{1D780}":"p","\u{1D78E}":"p","\u{1D7BA}":"p","\u{1D7C8}":"p","\u2CA3":"p",\u0440:"p",\uFF30:"P",\u2119:"P","\u{1D40F}":"P","\u{1D443}":"P","\u{1D477}":"P","\u{1D4AB}":"P","\u{1D4DF}":"P","\u{1D513}":"P","\u{1D57B}":"P","\u{1D5AF}":"P","\u{1D5E3}":"P","\u{1D617}":"P","\u{1D64B}":"P","\u{1D67F}":"P",\u03A1:"P","\u{1D6B8}":"P","\u{1D6F2}":"P","\u{1D72C}":"P","\u{1D766}":"P","\u{1D7A0}":"P","\u2CA2":"P",\u0420:"P",\u13E2:"P",\u146D:"P","\uA4D1":"P","\u{10295}":"P",\u01A5:"p\u0314","\u1D7D":"p\u0335",\u1477:"p\xB7",\u1486:"P'","\u1D29":"\u1D18","\uABB2":"\u1D18",\u03C6:"\u0278",\u03D5:"\u0278","\u{1D6D7}":"\u0278","\u{1D6DF}":"\u0278","\u{1D711}":"\u0278","\u{1D719}":"\u0278","\u{1D74B}":"\u0278","\u{1D753}":"\u0278","\u{1D785}":"\u0278","\u{1D78D}":"\u0278","\u{1D7BF}":"\u0278","\u{1D7C7}":"\u0278","\u2CAB":"\u0278",\u0444:"\u0278","\u{1D42A}":"q","\u{1D45E}":"q","\u{1D492}":"q","\u{1D4C6}":"q","\u{1D4FA}":"q","\u{1D52E}":"q","\u{1D562}":"q","\u{1D596}":"q","\u{1D5CA}":"q","\u{1D5FE}":"q","\u{1D632}":"q","\u{1D666}":"q","\u{1D69A}":"q","\u051B":"q",\u0563:"q",\u0566:"q",\u211A:"Q","\u{1D410}":"Q","\u{1D444}":"Q","\u{1D478}":"Q","\u{1D4AC}":"Q","\u{1D4E0}":"Q","\u{1D514}":"Q","\u{1D57C}":"Q","\u{1D5B0}":"Q","\u{1D5E4}":"Q","\u{1D618}":"Q","\u{1D64C}":"Q","\u{1D680}":"Q","\u2D55":"Q",\u02A0:"q\u0314","\u{1F700}":"QE","\u1D90":"\u024B","\u1D0B":"\u0138",\u03BA:"\u0138",\u03F0:"\u0138","\u{1D6CB}":"\u0138","\u{1D6DE}":"\u0138","\u{1D705}":"\u0138","\u{1D718}":"\u0138","\u{1D73F}":"\u0138","\u{1D752}":"\u0138","\u{1D779}":"\u0138","\u{1D78C}":"\u0138","\u{1D7B3}":"\u0138","\u{1D7C6}":"\u0138","\u2C95":"\u0138",\u043A:"\u0138","\uABB6":"\u0138",\u049B:"\u0138\u0329",\u049F:"\u0138\u0335","\u{1D42B}":"r","\u{1D45F}":"r","\u{1D493}":"r","\u{1D4C7}":"r","\u{1D4FB}":"r","\u{1D52F}":"r","\u{1D563}":"r","\u{1D597}":"r","\u{1D5CB}":"r","\u{1D5FF}":"r","\u{1D633}":"r","\u{1D667}":"r","\u{1D69B}":"r","\uAB47":"r","\uAB48":"r","\u1D26":"r","\u2C85":"r",\u0433:"r","\uAB81":"r","\u{1D216}":"R",\u211B:"R",\u211C:"R",\u211D:"R","\u{1D411}":"R","\u{1D445}":"R","\u{1D479}":"R","\u{1D4E1}":"R","\u{1D57D}":"R","\u{1D5B1}":"R","\u{1D5E5}":"R","\u{1D619}":"R","\u{1D64D}":"R","\u{1D681}":"R",\u01A6:"R",\u13A1:"R",\u13D2:"R","\u{104B4}":"R",\u1587:"R","\uA4E3":"R","\u{16F35}":"R",\u027D:"r\u0328",\u027C:"r\u0329","\u024D":"r\u0335",\u0493:"r\u0335","\u1D72":"r\u0334",\u0491:"r'","\u{118E3}":"rn",m:_b,"\u217F":"rn","\u{1D426}":"rn","\u{1D45A}":"rn","\u{1D48E}":"rn","\u{1D4C2}":"rn","\u{1D4F6}":"rn","\u{1D52A}":"rn","\u{1D55E}":"rn","\u{1D592}":"rn","\u{1D5C6}":"rn","\u{1D5FA}":"rn","\u{1D62E}":"rn","\u{1D662}":"rn","\u{1D696}":"rn","\u{11700}":"rn","\u20A5":"rn\u0338",\u0271:"rn\u0326","\u1D6F":"rn\u0334","\u20A8":"Rs","\uAB71":"\u0280","\uABA2":"\u0280",\u044F:"\u1D19","\u1D73":"\u027E\u0334","\u2129":"\u027F",\uFF53:"s","\u{1D42C}":"s","\u{1D460}":"s","\u{1D494}":"s","\u{1D4C8}":"s","\u{1D4FC}":"s","\u{1D530}":"s","\u{1D564}":"s","\u{1D598}":"s","\u{1D5CC}":"s","\u{1D600}":"s","\u{1D634}":"s","\u{1D668}":"s","\u{1D69C}":"s","\uA731":"s",\u01BD:"s",\u0455:"s","\uABAA":"s","\u{118C1}":"s","\u{10448}":"s",\uFF33:"S","\u{1D412}":"S","\u{1D446}":"S","\u{1D47A}":"S","\u{1D4AE}":"S","\u{1D4E2}":"S","\u{1D516}":"S","\u{1D54A}":"S","\u{1D57E}":"S","\u{1D5B2}":"S","\u{1D5E6}":"S","\u{1D61A}":"S","\u{1D64E}":"S","\u{1D682}":"S",\u0405:"S",\u054F:"S",\u13D5:"S",\u13DA:"S","\uA4E2":"S","\u{16F3A}":"S","\u{10296}":"S","\u{10420}":"S",\u0282:"s\u0328","\u1D74":"s\u0334","\uA7B5":"\xDF",\u03B2:"\xDF",\u03D0:"\xDF","\u{1D6C3}":"\xDF","\u{1D6FD}":"\xDF","\u{1D737}":"\xDF","\u{1D771}":"\xDF","\u{1D7AB}":"\xDF",\u13F0:"\xDF","\u{1F75C}":"sss",\uFB06:"st","\u222B":"\u0283","\uAB4D":"\u0283","\u2211":"\u01A9","\u2140":"\u01A9",\u03A3:"\u01A9","\u{1D6BA}":"\u01A9","\u{1D6F4}":"\u01A9","\u{1D72E}":"\u01A9","\u{1D768}":"\u01A9","\u{1D7A2}":"\u01A9","\u2D49":"\u01A9","\u222C":"\u0283\u0283","\u222D":"\u0283\u0283\u0283","\u2A0C":"\u0283\u0283\u0283\u0283","\u{1D42D}":"t","\u{1D461}":"t","\u{1D495}":"t","\u{1D4C9}":"t","\u{1D4FD}":"t","\u{1D531}":"t","\u{1D565}":"t","\u{1D599}":"t","\u{1D5CD}":"t","\u{1D601}":"t","\u{1D635}":"t","\u{1D669}":"t","\u{1D69D}":"t","\u22A4":"T","\u27D9":"T","\u{1F768}":"T",\uFF34:"T","\u{1D413}":"T","\u{1D447}":"T","\u{1D47B}":"T","\u{1D4AF}":"T","\u{1D4E3}":"T","\u{1D517}":"T","\u{1D54B}":"T","\u{1D57F}":"T","\u{1D5B3}":"T","\u{1D5E7}":"T","\u{1D61B}":"T","\u{1D64F}":"T","\u{1D683}":"T",\u03A4:"T","\u{1D6BB}":"T","\u{1D6F5}":"T","\u{1D72F}":"T","\u{1D769}":"T","\u{1D7A3}":"T","\u2CA6":"T",\u0422:"T",\u13A2:"T","\uA4D4":"T","\u{16F0A}":"T","\u{118BC}":"T","\u{10297}":"T","\u{102B1}":"T","\u{10315}":"T",\u01AD:"t\u0314","\u2361":"T\u0308","\u023E":"T\u0338",\u021A:"\u0162",\u01AE:"T\u0328",\u04AC:"T\u0329","\u20AE":"T\u20EB",\u0167:"t\u0335",\u0166:"T\u0335","\u1D75":"t\u0334",\u10A0:"\uA786","\uA728":"T3",\u02A8:"t\u0255","\u2121":"TEL","\uA777":"tf",\u02A6:"ts",\u02A7:"t\u0283","\uA729":"t\u021D",\u03C4:"\u1D1B","\u{1D6D5}":"\u1D1B","\u{1D70F}":"\u1D1B","\u{1D749}":"\u1D1B","\u{1D783}":"\u1D1B","\u{1D7BD}":"\u1D1B",\u0442:"\u1D1B","\uAB72":"\u1D1B",\u04AD:"\u1D1B\u0329",\u0163:"\u01AB",\u021B:"\u01AB",\u13BF:"\u01AB","\u{1D42E}":"u","\u{1D462}":"u","\u{1D496}":"u","\u{1D4CA}":"u","\u{1D4FE}":"u","\u{1D532}":"u","\u{1D566}":"u","\u{1D59A}":"u","\u{1D5CE}":"u","\u{1D602}":"u","\u{1D636}":"u","\u{1D66A}":"u","\u{1D69E}":"u","\uA79F":"u","\u1D1C":"u","\uAB4E":"u","\uAB52":"u",\u028B:"u",\u03C5:"u","\u{1D6D6}":"u","\u{1D710}":"u","\u{1D74A}":"u","\u{1D784}":"u","\u{1D7BE}":"u",\u057D:"u","\u{104F6}":"u","\u{118D8}":"u","\u222A":"U","\u22C3":"U","\u{1D414}":"U","\u{1D448}":"U","\u{1D47C}":"U","\u{1D4B0}":"U","\u{1D4E4}":"U","\u{1D518}":"U","\u{1D54C}":"U","\u{1D580}":"U","\u{1D5B4}":"U","\u{1D5E8}":"U","\u{1D61C}":"U","\u{1D650}":"U","\u{1D684}":"U",\u054D:"U",\u1200:"U","\u{104CE}":"U",\u144C:"U","\uA4F4":"U","\u{16F42}":"U","\u{118B8}":"U",\u01D4:"\u016D",\u01D3:"\u016C","\u1D7E":"u\u0335","\uAB9C":"u\u0335","\u0244":"U\u0335",\u13CC:"U\u0335",\u1458:"U\xB7",\u1467:"U'","\u1D6B":"ue","\uAB63":"uo",\u1E43:"\uAB51",\u057A:"\u0270",\u1223:"\u0270","\u2127":"\u01B1",\u162E:"\u01B1",\u1634:"\u01B1","\u1D7F":"\u028A\u0335","\u2228":"v","\u22C1":"v",\uFF56:"v","\u2174":"v","\u{1D42F}":"v","\u{1D463}":"v","\u{1D497}":"v","\u{1D4CB}":"v","\u{1D4FF}":"v","\u{1D533}":"v","\u{1D567}":"v","\u{1D59B}":"v","\u{1D5CF}":"v","\u{1D603}":"v","\u{1D637}":"v","\u{1D66B}":"v","\u{1D69F}":"v","\u1D20":"v",\u03BD:"v","\u{1D6CE}":"v","\u{1D708}":"v","\u{1D742}":"v","\u{1D77C}":"v","\u{1D7B6}":"v",\u0475:"v",\u05D8:"v","\u{11706}":"v","\uABA9":"v","\u{118C0}":"v","\u{1D20D}":"V","\u0667":"V","\u06F7":"V","\u2164":"V","\u{1D415}":"V","\u{1D449}":"V","\u{1D47D}":"V","\u{1D4B1}":"V","\u{1D4E5}":"V","\u{1D519}":"V","\u{1D54D}":"V","\u{1D581}":"V","\u{1D5B5}":"V","\u{1D5E9}":"V","\u{1D61D}":"V","\u{1D651}":"V","\u{1D685}":"V",\u0474:"V","\u2D38":"V",\u13D9:"V",\u142F:"V","\uA6DF":"V","\uA4E6":"V","\u{16F08}":"V","\u{118A0}":"V","\u{1051D}":"V","\u{10197}":"V\u0335",\u143B:"V\xB7","\u{1F76C}":"VB","\u2175":"vi","\u2176":"vii","\u2177":"viii","\u2165":"Vl","\u2166":"Vll","\u2167":"Vlll","\u{1F708}":"V\u1DE4","\u1D27":"\u028C","\u{104D8}":"\u028C","\u0668":"\u0245","\u06F8":"\u0245",\u039B:"\u0245","\u{1D6B2}":"\u0245","\u{1D6EC}":"\u0245","\u{1D726}":"\u0245","\u{1D760}":"\u0245","\u{1D79A}":"\u0245",\u041B:"\u0245","\u2D37":"\u0245","\u{104B0}":"\u0245",\u1431:"\u0245","\uA6CE":"\u0245","\uA4E5":"\u0245","\u{16F3D}":"\u0245","\u{1028D}":"\u0245","\u04C5":"\u0245\u0326",\u143D:"\u0245\xB7",\u026F:"w","\u{1D430}":"w","\u{1D464}":"w","\u{1D498}":"w","\u{1D4CC}":"w","\u{1D500}":"w","\u{1D534}":"w","\u{1D568}":"w","\u{1D59C}":"w","\u{1D5D0}":"w","\u{1D604}":"w","\u{1D638}":"w","\u{1D66C}":"w","\u{1D6A0}":"w","\u1D21":"w",\u0461:"w","\u051D":"w",\u0561:"w","\u{1170A}":"w","\u{1170E}":"w","\u{1170F}":"w","\uAB83":"w","\u{118EF}":"W","\u{118E6}":"W","\u{1D416}":"W","\u{1D44A}":"W","\u{1D47E}":"W","\u{1D4B2}":"W","\u{1D4E6}":"W","\u{1D51A}":"W","\u{1D54E}":"W","\u{1D582}":"W","\u{1D5B6}":"W","\u{1D5EA}":"W","\u{1D61E}":"W","\u{1D652}":"W","\u{1D686}":"W","\u051C":"W",\u13B3:"W",\u13D4:"W","\uA4EA":"W",\u047D:"w\u0486\u0487","\u{114C5}":"w\u0307","\u20A9":"W\u0335","\uA761":"w\u0326","\u1D0D":"\u028D",\u043C:"\u028D","\uAB87":"\u028D","\u04CE":"\u028D\u0326","\u166E":"x","\xD7":"x","\u292B":"x","\u292C":"x","\u2A2F":"x",\uFF58:"x","\u2179":"x","\u{1D431}":"x","\u{1D465}":"x","\u{1D499}":"x","\u{1D4CD}":"x","\u{1D501}":"x","\u{1D535}":"x","\u{1D569}":"x","\u{1D59D}":"x","\u{1D5D1}":"x","\u{1D605}":"x","\u{1D639}":"x","\u{1D66D}":"x","\u{1D6A1}":"x",\u0445:"x",\u1541:"x",\u157D:"x","\u2DEF":"\u036F","\u166D":"X","\u2573":"X","\u{10322}":"X","\u{118EC}":"X",\uFF38:"X","\u2169":"X","\u{1D417}":"X","\u{1D44B}":"X","\u{1D47F}":"X","\u{1D4B3}":"X","\u{1D4E7}":"X","\u{1D51B}":"X","\u{1D54F}":"X","\u{1D583}":"X","\u{1D5B7}":"X","\u{1D5EB}":"X","\u{1D61F}":"X","\u{1D653}":"X","\u{1D687}":"X","\uA7B3":"X",\u03A7:"X","\u{1D6BE}":"X","\u{1D6F8}":"X","\u{1D732}":"X","\u{1D76C}":"X","\u{1D7A6}":"X","\u2CAC":"X",\u0425:"X","\u2D5D":"X",\u16B7:"X","\uA4EB":"X","\u{10290}":"X","\u{102B4}":"X","\u{10317}":"X","\u{10527}":"X","\u2A30":"x\u0307",\u04B2:"X\u0329","\u{10196}":"X\u0335","\u217A":"xi","\u217B":"xii","\u216A":"Xl","\u216B":"Xll",\u0263:"y","\u1D8C":"y",\uFF59:"y","\u{1D432}":"y","\u{1D466}":"y","\u{1D49A}":"y","\u{1D4CE}":"y","\u{1D502}":"y","\u{1D536}":"y","\u{1D56A}":"y","\u{1D59E}":"y","\u{1D5D2}":"y","\u{1D606}":"y","\u{1D63A}":"y","\u{1D66E}":"y","\u{1D6A2}":"y",\u028F:"y","\u1EFF":"y","\uAB5A":"y",\u03B3:"y","\u213D":"y","\u{1D6C4}":"y","\u{1D6FE}":"y","\u{1D738}":"y","\u{1D772}":"y","\u{1D7AC}":"y",\u0443:"y",\u04AF:"y",\u10E7:"y","\u{118DC}":"y",\uFF39:"Y","\u{1D418}":"Y","\u{1D44C}":"Y","\u{1D480}":"Y","\u{1D4B4}":"Y","\u{1D4E8}":"Y","\u{1D51C}":"Y","\u{1D550}":"Y","\u{1D584}":"Y","\u{1D5B8}":"Y","\u{1D5EC}":"Y","\u{1D620}":"Y","\u{1D654}":"Y","\u{1D688}":"Y",\u03A5:"Y",\u03D2:"Y","\u{1D6BC}":"Y","\u{1D6F6}":"Y","\u{1D730}":"Y","\u{1D76A}":"Y","\u{1D7A4}":"Y","\u2CA8":"Y",\u0423:"Y",\u04AE:"Y",\u13A9:"Y",\u13BD:"Y","\uA4EC":"Y","\u{16F43}":"Y","\u{118A4}":"Y","\u{102B2}":"Y",\u01B4:"y\u0314","\u024F":"y\u0335",\u04B1:"y\u0335","\xA5":"Y\u0335","\u024E":"Y\u0335",\u04B0:"Y\u0335",\u0292:"\u021D","\uA76B":"\u021D","\u2CCD":"\u021D",\u04E1:"\u021D",\u10F3:"\u021D","\u{1D433}":"z","\u{1D467}":"z","\u{1D49B}":"z","\u{1D4CF}":"z","\u{1D503}":"z","\u{1D537}":"z","\u{1D56B}":"z","\u{1D59F}":"z","\u{1D5D3}":"z","\u{1D607}":"z","\u{1D63B}":"z","\u{1D66F}":"z","\u{1D6A3}":"z","\u1D22":"z","\uAB93":"z","\u{118C4}":"z","\u{102F5}":"Z","\u{118E5}":"Z",\uFF3A:"Z",\u2124:"Z",\u2128:"Z","\u{1D419}":"Z","\u{1D44D}":"Z","\u{1D481}":"Z","\u{1D4B5}":"Z","\u{1D4E9}":"Z","\u{1D585}":"Z","\u{1D5B9}":"Z","\u{1D5ED}":"Z","\u{1D621}":"Z","\u{1D655}":"Z","\u{1D689}":"Z",\u0396:"Z","\u{1D6AD}":"Z","\u{1D6E7}":"Z","\u{1D721}":"Z","\u{1D75B}":"Z","\u{1D795}":"Z",\u13C3:"Z","\uA4DC":"Z","\u{118A9}":"Z",\u0290:"z\u0328",\u01B6:"z\u0335",\u01B5:"Z\u0335",\u0225:"z\u0326",\u0224:"Z\u0326","\u1D76":"z\u0334",\u01BF:"\xFE","\u03F8":"\xFE","\u03F7":"\xDE","\u{104C4}":"\xDE","\u2079":"\uA770","\u1D24":"\u01A8",\u03E9:"\u01A8","\uA645":"\u01A8",\u044C:"\u0185","\uAB9F":"\u0185",\u044B:"\u0185i","\uAB7E":"\u0242",\u02E4:"\u02C1","\uA6CD":"\u02A1","\u2299":"\u0298","\u2609":"\u0298","\u2A00":"\u0298","\uA668":"\u0298","\u2D59":"\u0298","\u{104C3}":"\u0298","\u213E":"\u0393","\u{1D6AA}":"\u0393","\u{1D6E4}":"\u0393","\u{1D71E}":"\u0393","\u{1D758}":"\u0393","\u{1D792}":"\u0393","\u2C84":"\u0393",\u0413:"\u0393",\u13B1:"\u0393",\u14A5:"\u0393","\u{16F07}":"\u0393",\u0492:"\u0393\u0335",\u14AF:"\u0393\xB7",\u0490:"\u0393'","\u2206":"\u0394","\u25B3":"\u0394","\u{1F702}":"\u0394","\u{1D6AB}":"\u0394","\u{1D6E5}":"\u0394","\u{1D71F}":"\u0394","\u{1D759}":"\u0394","\u{1D793}":"\u0394","\u2C86":"\u0394","\u2D60":"\u0394",\u1403:"\u0394","\u{16F1A}":"\u0394","\u{10285}":"\u0394","\u{102A3}":"\u0394","\u2359":"\u0394\u0332",\u140F:"\u0394\xB7",\u142C:"\u0394\u1420","\u{1D7CB}":"\u03DD","\u{1D6C7}":"\u03B6","\u{1D701}":"\u03B6","\u{1D73B}":"\u03B6","\u{1D775}":"\u03B6","\u{1D7AF}":"\u03B6","\u2CE4":"\u03D7","\u{1D6CC}":"\u03BB","\u{1D706}":"\u03BB","\u{1D740}":"\u03BB","\u{1D77A}":"\u03BB","\u{1D7B4}":"\u03BB","\u2C96":"\u03BB","\u{104DB}":"\u03BB",\u00B5:"\u03BC","\u{1D6CD}":"\u03BC","\u{1D707}":"\u03BC","\u{1D741}":"\u03BC","\u{1D77B}":"\u03BC","\u{1D7B5}":"\u03BC","\u{1D6CF}":"\u03BE","\u{1D709}":"\u03BE","\u{1D743}":"\u03BE","\u{1D77D}":"\u03BE","\u{1D7B7}":"\u03BE","\u{1D6B5}":"\u039E","\u{1D6EF}":"\u039E","\u{1D729}":"\u039E","\u{1D763}":"\u039E","\u{1D79D}":"\u039E",\u03D6:"\u03C0","\u213C":"\u03C0","\u{1D6D1}":"\u03C0","\u{1D6E1}":"\u03C0","\u{1D70B}":"\u03C0","\u{1D71B}":"\u03C0","\u{1D745}":"\u03C0","\u{1D755}":"\u03C0","\u{1D77F}":"\u03C0","\u{1D78F}":"\u03C0","\u{1D7B9}":"\u03C0","\u{1D7C9}":"\u03C0","\u1D28":"\u03C0",\u043F:"\u03C0","\u220F":"\u03A0","\u213F":"\u03A0","\u{1D6B7}":"\u03A0","\u{1D6F1}":"\u03A0","\u{1D72B}":"\u03A0","\u{1D765}":"\u03A0","\u{1D79F}":"\u03A0","\u2CA0":"\u03A0",\u041F:"\u03A0","\uA6DB":"\u03A0","\u{102AD}":"\u03D8","\u{10312}":"\u03D8",\u03DB:"\u03C2","\u{1D6D3}":"\u03C2","\u{1D70D}":"\u03C2","\u{1D747}":"\u03C2","\u{1D781}":"\u03C2","\u{1D7BB}":"\u03C2","\u{1D6BD}":"\u03A6","\u{1D6F7}":"\u03A6","\u{1D731}":"\u03A6","\u{1D76B}":"\u03A6","\u{1D7A5}":"\u03A6","\u2CAA":"\u03A6",\u0424:"\u03A6",\u0553:"\u03A6",\u1240:"\u03A6","\u16F0":"\u03A6","\u{102B3}":"\u03A6","\uAB53":"\u03C7","\uAB55":"\u03C7","\u{1D6D8}":"\u03C7","\u{1D712}":"\u03C7","\u{1D74C}":"\u03C7","\u{1D786}":"\u03C7","\u{1D7C0}":"\u03C7","\u2CAD":"\u03C7","\u{1D6D9}":"\u03C8","\u{1D713}":"\u03C8","\u{1D74D}":"\u03C8","\u{1D787}":"\u03C8","\u{1D7C1}":"\u03C8",\u0471:"\u03C8","\u{104F9}":"\u03C8","\u{1D6BF}":"\u03A8","\u{1D6F9}":"\u03A8","\u{1D733}":"\u03A8","\u{1D76D}":"\u03A8","\u{1D7A7}":"\u03A8","\u2CAE":"\u03A8",\u0470:"\u03A8","\u{104D1}":"\u03A8",\u16D8:"\u03A8","\u{102B5}":"\u03A8","\u2375":"\u03C9","\uA7B7":"\u03C9","\u{1D6DA}":"\u03C9","\u{1D714}":"\u03C9","\u{1D74E}":"\u03C9","\u{1D788}":"\u03C9","\u{1D7C2}":"\u03C9","\u2CB1":"\u03C9","\uA64D":"\u03C9",\u2126:"\u03A9","\u{1D6C0}":"\u03A9","\u{1D6FA}":"\u03A9","\u{1D734}":"\u03A9","\u{1D76E}":"\u03A9","\u{1D7A8}":"\u03A9",\u162F:"\u03A9",\u1635:"\u03A9","\u{102B6}":"\u03A9","\u2379":"\u03C9\u0332",\u1F7D:"\u1FF4","\u2630":"\u2CB6","\u2CDC":"\u03EC",\u0497:"\u0436\u0329",\u0496:"\u0416\u0329","\u{1D20B}":"\u0418","\u0376":"\u0418","\uA6A1":"\u0418","\u{10425}":"\u0418",\u0419:"\u040D","\u048A":"\u040D\u0326",\u045D:"\u0439","\u048B":"\u0439\u0326","\u{104BC}":"\u04C3","\u1D2B":"\u043B","\u04C6":"\u043B\u0326","\uAB60":"\u0459","\u{104EB}":"\uA669","\u1DEE":"\u2DEC","\u{104CD}":"\u040B","\u{1D202}":"\u04FE","\u{1D222}":"\u0460",\u13C7:"\u0460",\u15EF:"\u0460",\u047C:"\u0460\u0486\u0487","\u18ED":"\u0460\xB7","\uA7B6":"\uA64C",\u04CC:"\u04B7",\u04CB:"\u04B6",\u04BE:"\u04BC\u0328","\u2CBD":"\u0448","\u2CBC":"\u0428","\uA650":"\u042Al","\u2108":"\u042D","\u{1F701}":"\uA658","\u{16F1C}":"\uA658","\uA992":"\u2C3F",\u0587:"\u0565\u0582",\u1294:"\u0571",\uFB14:"\u0574\u0565",\uFB15:"\u0574\u056B",\uFB17:"\u0574\u056D",\uFB13:"\u0574\u0576","\u2229":"\u0548","\u22C2":"\u0548","\u{1D245}":"\u0548",\u1260:"\u0548",\u144E:"\u0548","\uA4F5":"\u0548",\u145A:"\u0548\xB7",\u1468:"\u0548'",\uFB16:"\u057E\u0576","\u20BD":"\u0554","\u02D3":"\u0559",\u02BF:"\u0559",\u2135:"\u05D0",\uFB21:"\u05D0",\uFB2F:"\uFB2E",\uFB30:"\uFB2E",\uFB4F:"\u05D0\u05DC",\u2136:"\u05D1",\u2137:"\u05D2",\u2138:"\u05D3",\uFB22:"\u05D3",\uFB23:"\u05D4",\uFB39:"\uFB1D",\uFB24:"\u05DB",\uFB25:"\u05DC",\uFB26:"\u05DD",\uFB20:"\u05E2",\uFB27:"\u05E8",\uFB2B:"\uFB2A",\uFB49:"\uFB2A",\uFB2D:"\uFB2C",\uFB28:"\u05EA",\uFE80:"\u0621","\u06FD":"\u0621\u0348",\uFE82:"\u0622",\uFE81:"\u0622",\uFB51:"\u0671",\uFB50:"\u0671","\u{1EE01}":"\u0628","\u{1EE21}":"\u0628","\u{1EE61}":"\u0628","\u{1EE81}":"\u0628","\u{1EEA1}":"\u0628",\uFE91:"\u0628",\uFE92:"\u0628",\uFE90:"\u0628",\uFE8F:"\u0628","\u0751":"\u0628\u06DB","\u08B6":"\u0628\u06E2","\u08A1":"\u0628\u0654",\uFCA0:"\u0628o",\uFCE2:"\u0628o",\uFC9C:"\u0628\u062C",\uFC05:"\u0628\u062C",\uFC9D:"\u0628\u062D",\uFC06:"\u0628\u062D",\uFDC2:"\u0628\u062D\u0649",\uFC9E:"\u0628\u062E",\uFC07:"\u0628\u062E",\uFCD2:"\u0628\u062E",\uFC4B:"\u0628\u062E",\uFD9E:"\u0628\u062E\u0649",\uFC6A:"\u0628\u0631",\uFC6B:"\u0628\u0632",\uFC9F:"\u0628\u0645",\uFCE1:"\u0628\u0645",\uFC6C:"\u0628\u0645",\uFC08:"\u0628\u0645",\uFC6D:"\u0628\u0646",\uFC6E:"\u0628\u0649",\uFC09:"\u0628\u0649",\uFC6F:"\u0628\u0649",\uFC0A:"\u0628\u0649",\uFB54:"\u067B",\uFB55:"\u067B",\uFB53:"\u067B",\uFB52:"\u067B",\u06D0:"\u067B",\uFBE6:"\u067B",\uFBE7:"\u067B",\uFBE5:"\u067B",\uFBE4:"\u067B",\uFB5C:"\u0680",\uFB5D:"\u0680",\uFB5B:"\u0680",\uFB5A:"\u0680","\u08A9":"\u0754","\u0767":"\u0754","\u2365":"\u0629",\u00F6:"\u0629",\uFE94:"\u0629",\uFE93:"\u0629",\u06C3:"\u0629","\u{1EE15}":"\u062A","\u{1EE35}":"\u062A","\u{1EE75}":"\u062A","\u{1EE95}":"\u062A","\u{1EEB5}":"\u062A",\uFE97:"\u062A",\uFE98:"\u062A",\uFE96:"\u062A",\uFE95:"\u062A",\uFCA5:"\u062Ao",\uFCE4:"\u062Ao",\uFCA1:"\u062A\u062C",\uFC0B:"\u062A\u062C",\uFD50:"\u062A\u062C\u0645",\uFDA0:"\u062A\u062C\u0649",\uFD9F:"\u062A\u062C\u0649",\uFCA2:"\u062A\u062D",\uFC0C:"\u062A\u062D",\uFD52:"\u062A\u062D\u062C",\uFD51:"\u062A\u062D\u062C",\uFD53:"\u062A\u062D\u0645",\uFCA3:"\u062A\u062E",\uFC0D:"\u062A\u062E",\uFD54:"\u062A\u062E\u0645",\uFDA2:"\u062A\u062E\u0649",\uFDA1:"\u062A\u062E\u0649",\uFC70:"\u062A\u0631",\uFC71:"\u062A\u0632",\uFCA4:"\u062A\u0645",\uFCE3:"\u062A\u0645",\uFC72:"\u062A\u0645",\uFC0E:"\u062A\u0645",\uFD55:"\u062A\u0645\u062C",\uFD56:"\u062A\u0645\u062D",\uFD57:"\u062A\u0645\u062E",\uFDA4:"\u062A\u0645\u0649",\uFDA3:"\u062A\u0645\u0649",\uFC73:"\u062A\u0646",\uFC74:"\u062A\u0649",\uFC0F:"\u062A\u0649",\uFC75:"\u062A\u0649",\uFC10:"\u062A\u0649",\uFB60:"\u067A",\uFB61:"\u067A",\uFB5F:"\u067A",\uFB5E:"\u067A",\uFB64:"\u067F",\uFB65:"\u067F",\uFB63:"\u067F",\uFB62:"\u067F","\u{1EE02}":"\u062C","\u{1EE22}":"\u062C","\u{1EE42}":"\u062C","\u{1EE62}":"\u062C","\u{1EE82}":"\u062C","\u{1EEA2}":"\u062C",\uFE9F:"\u062C",\uFEA0:"\u062C",\uFE9E:"\u062C",\uFE9D:"\u062C",\uFCA7:"\u062C\u062D",\uFC15:"\u062C\u062D",\uFDA6:"\u062C\u062D\u0649",\uFDBE:"\u062C\u062D\u0649",\uFDFB:"\u062C\u0644 \u062C\u0644l\u0644o",\uFCA8:"\u062C\u0645",\uFC16:"\u062C\u0645",\uFD59:"\u062C\u0645\u062D",\uFD58:"\u062C\u0645\u062D",\uFDA7:"\u062C\u0645\u0649",\uFDA5:"\u062C\u0645\u0649",\uFD1D:"\u062C\u0649",\uFD01:"\u062C\u0649",\uFD1E:"\u062C\u0649",\uFD02:"\u062C\u0649",\uFB78:"\u0683",\uFB79:"\u0683",\uFB77:"\u0683",\uFB76:"\u0683",\uFB74:"\u0684",\uFB75:"\u0684",\uFB73:"\u0684",\uFB72:"\u0684",\uFB7C:"\u0686",\uFB7D:"\u0686",\uFB7B:"\u0686",\uFB7A:"\u0686",\uFB80:"\u0687",\uFB81:"\u0687",\uFB7F:"\u0687",\uFB7E:"\u0687","\u{1EE07}":"\u062D","\u{1EE27}":"\u062D","\u{1EE47}":"\u062D","\u{1EE67}":"\u062D","\u{1EE87}":"\u062D","\u{1EEA7}":"\u062D",\uFEA3:"\u062D",\uFEA4:"\u062D",\uFEA2:"\u062D",\uFEA1:"\u062D",\u0685:"\u062D\u06DB",\u0681:"\u062D\u0654","\u0772":"\u062D\u0654",\uFCA9:"\u062D\u062C",\uFC17:"\u062D\u062C",\uFDBF:"\u062D\u062C\u0649",\uFCAA:"\u062D\u0645",\uFC18:"\u062D\u0645",\uFD5B:"\u062D\u0645\u0649",\uFD5A:"\u062D\u0645\u0649",\uFD1B:"\u062D\u0649",\uFCFF:"\u062D\u0649",\uFD1C:"\u062D\u0649",\uFD00:"\u062D\u0649","\u{1EE17}":"\u062E","\u{1EE37}":"\u062E","\u{1EE57}":"\u062E","\u{1EE77}":"\u062E","\u{1EE97}":"\u062E","\u{1EEB7}":"\u062E",\uFEA7:"\u062E",\uFEA8:"\u062E",\uFEA6:"\u062E",\uFEA5:"\u062E",\uFCAB:"\u062E\u062C",\uFC19:"\u062E\u062C",\uFC1A:"\u062E\u062D",\uFCAC:"\u062E\u0645",\uFC1B:"\u062E\u0645",\uFD1F:"\u062E\u0649",\uFD03:"\u062E\u0649",\uFD20:"\u062E\u0649",\uFD04:"\u062E\u0649","\u{102E1}":"\u062F","\u{1EE03}":"\u062F","\u{1EE83}":"\u062F","\u{1EEA3}":"\u062F",\uFEAA:"\u062F",\uFEA9:"\u062F",\u0688:"\u062F\u0615",\uFB89:"\u062F\u0615",\uFB88:"\u062F\u0615",\u068E:"\u062F\u06DB",\uFB87:"\u062F\u06DB",\uFB86:"\u062F\u06DB","\u06EE":"\u062F\u0302","\u08AE":"\u062F\u0324\u0323","\u{1EE18}":"\u0630","\u{1EE98}":"\u0630","\u{1EEB8}":"\u0630",\uFEAC:"\u0630",\uFEAB:"\u0630",\uFC5B:"\u0630\u0670",\u068B:"\u068A\u0615",\uFB85:"\u068C",\uFB84:"\u068C",\uFB83:"\u068D",\uFB82:"\u068D","\u{1EE13}":"\u0631","\u{1EE93}":"\u0631","\u{1EEB3}":"\u0631",\uFEAE:"\u0631",\uFEAD:"\u0631",\u0691:"\u0631\u0615",\uFB8D:"\u0631\u0615",\uFB8C:"\u0631\u0615",\u0698:"\u0631\u06DB",\uFB8B:"\u0631\u06DB",\uFB8A:"\u0631\u06DB",\u0692:"\u0631\u0306","\u08B9":"\u0631\u0306\u0307","\u06EF":"\u0631\u0302","\u076C":"\u0631\u0654",\uFC5C:"\u0631\u0670",\uFDF6:"\u0631\u0633\u0648\u0644","\uFDFC":"\u0631\u0649l\u0644","\u{1EE06}":"\u0632","\u{1EE86}":"\u0632","\u{1EEA6}":"\u0632",\uFEB0:"\u0632",\uFEAF:"\u0632","\u08B2":"\u0632\u0302","\u0771":"\u0697\u0615","\u{1EE0E}":"\u0633","\u{1EE2E}":"\u0633","\u{1EE4E}":"\u0633","\u{1EE6E}":"\u0633","\u{1EE8E}":"\u0633","\u{1EEAE}":"\u0633",\uFEB3:"\u0633",\uFEB4:"\u0633",\uFEB2:"\u0633",\uFEB1:"\u0633",\u0634:"\u0633\u06DB","\u{1EE14}":"\u0633\u06DB","\u{1EE34}":"\u0633\u06DB","\u{1EE54}":"\u0633\u06DB","\u{1EE74}":"\u0633\u06DB","\u{1EE94}":"\u0633\u06DB","\u{1EEB4}":"\u0633\u06DB",\uFEB7:"\u0633\u06DB",\uFEB8:"\u0633\u06DB",\uFEB6:"\u0633\u06DB",\uFEB5:"\u0633\u06DB","\u077E":"\u0633\u0302",\uFD31:"\u0633o",\uFCE8:"\u0633o",\uFD32:"\u0633\u06DBo",\uFCEA:"\u0633\u06DBo",\uFCAD:"\u0633\u062C",\uFD34:"\u0633\u062C",\uFC1C:"\u0633\u062C",\uFD2D:"\u0633\u06DB\u062C",\uFD37:"\u0633\u06DB\u062C",\uFD25:"\u0633\u06DB\u062C",\uFD09:"\u0633\u06DB\u062C",\uFD5D:"\u0633\u062C\u062D",\uFD5E:"\u0633\u062C\u0649",\uFD69:"\u0633\u06DB\u062C\u0649",\uFCAE:"\u0633\u062D",\uFD35:"\u0633\u062D",\uFC1D:"\u0633\u062D",\uFD2E:"\u0633\u06DB\u062D",\uFD38:"\u0633\u06DB\u062D",\uFD26:"\u0633\u06DB\u062D",\uFD0A:"\u0633\u06DB\u062D",\uFD5C:"\u0633\u062D\u062C",\uFD68:"\u0633\u06DB\u062D\u0645",\uFD67:"\u0633\u06DB\u062D\u0645",\uFDAA:"\u0633\u06DB\u062D\u0649",\uFCAF:"\u0633\u062E",\uFD36:"\u0633\u062E",\uFC1E:"\u0633\u062E",\uFD2F:"\u0633\u06DB\u062E",\uFD39:"\u0633\u06DB\u062E",\uFD27:"\u0633\u06DB\u062E",\uFD0B:"\u0633\u06DB\u062E",\uFDA8:"\u0633\u062E\u0649",\uFDC6:"\u0633\u062E\u0649",\uFD2A:"\u0633\u0631",\uFD0E:"\u0633\u0631",\uFD29:"\u0633\u06DB\u0631",\uFD0D:"\u0633\u06DB\u0631",\uFCB0:"\u0633\u0645",\uFCE7:"\u0633\u0645",\uFC1F:"\u0633\u0645",\uFD30:"\u0633\u06DB\u0645",\uFCE9:"\u0633\u06DB\u0645",\uFD28:"\u0633\u06DB\u0645",\uFD0C:"\u0633\u06DB\u0645",\uFD61:"\u0633\u0645\u062C",\uFD60:"\u0633\u0645\u062D",\uFD5F:"\u0633\u0645\u062D",\uFD6B:"\u0633\u06DB\u0645\u062E",\uFD6A:"\u0633\u06DB\u0645\u062E",\uFD63:"\u0633\u0645\u0645",\uFD62:"\u0633\u0645\u0645",\uFD6D:"\u0633\u06DB\u0645\u0645",\uFD6C:"\u0633\u06DB\u0645\u0645",\uFD17:"\u0633\u0649",\uFCFB:"\u0633\u0649",\uFD18:"\u0633\u0649",\uFCFC:"\u0633\u0649",\uFD19:"\u0633\u06DB\u0649",\uFCFD:"\u0633\u06DB\u0649",\uFD1A:"\u0633\u06DB\u0649",\uFCFE:"\u0633\u06DB\u0649","\u{102F2}":"\u0635","\u{1EE11}":"\u0635","\u{1EE31}":"\u0635","\u{1EE51}":"\u0635","\u{1EE71}":"\u0635","\u{1EE91}":"\u0635","\u{1EEB1}":"\u0635",\uFEBB:"\u0635",\uFEBC:"\u0635",\uFEBA:"\u0635",\uFEB9:"\u0635",\u069E:"\u0635\u06DB","\u08AF":"\u0635\u0324\u0323",\uFCB1:"\u0635\u062D",\uFC20:"\u0635\u062D",\uFD65:"\u0635\u062D\u062D",\uFD64:"\u0635\u062D\u062D",\uFDA9:"\u0635\u062D\u0649",\uFCB2:"\u0635\u062E",\uFD2B:"\u0635\u0631",\uFD0F:"\u0635\u0631",\uFDF5:"\u0635\u0644\u0639\u0645",\uFDF9:"\u0635\u0644\u0649",\uFDF0:"\u0635\u0644\u0649",\uFDFA:"\u0635\u0644\u0649 l\u0644\u0644o \u0639\u0644\u0649o \u0648\u0633\u0644\u0645",\uFCB3:"\u0635\u0645",\uFC21:"\u0635\u0645",\uFDC5:"\u0635\u0645\u0645",\uFD66:"\u0635\u0645\u0645",\uFD21:"\u0635\u0649",\uFD05:"\u0635\u0649",\uFD22:"\u0635\u0649",\uFD06:"\u0635\u0649","\u{1EE19}":"\u0636","\u{1EE39}":"\u0636","\u{1EE59}":"\u0636","\u{1EE79}":"\u0636","\u{1EE99}":"\u0636","\u{1EEB9}":"\u0636",\uFEBF:"\u0636",\uFEC0:"\u0636",\uFEBE:"\u0636",\uFEBD:"\u0636",\uFCB4:"\u0636\u062C",\uFC22:"\u0636\u062C",\uFCB5:"\u0636\u062D",\uFC23:"\u0636\u062D",\uFD6E:"\u0636\u062D\u0649",\uFDAB:"\u0636\u062D\u0649",\uFCB6:"\u0636\u062E",\uFC24:"\u0636\u062E",\uFD70:"\u0636\u062E\u0645",\uFD6F:"\u0636\u062E\u0645",\uFD2C:"\u0636\u0631",\uFD10:"\u0636\u0631",\uFCB7:"\u0636\u0645",\uFC25:"\u0636\u0645",\uFD23:"\u0636\u0649",\uFD07:"\u0636\u0649",\uFD24:"\u0636\u0649",\uFD08:"\u0636\u0649","\u{102E8}":"\u0637","\u{1EE08}":"\u0637","\u{1EE68}":"\u0637","\u{1EE88}":"\u0637","\u{1EEA8}":"\u0637",\uFEC3:"\u0637",\uFEC4:"\u0637",\uFEC2:"\u0637",\uFEC1:"\u0637",\u069F:"\u0637\u06DB",\uFCB8:"\u0637\u062D",\uFC26:"\u0637\u062D",\uFD33:"\u0637\u0645",\uFD3A:"\u0637\u0645",\uFC27:"\u0637\u0645",\uFD72:"\u0637\u0645\u062D",\uFD71:"\u0637\u0645\u062D",\uFD73:"\u0637\u0645\u0645",\uFD74:"\u0637\u0645\u0649",\uFD11:"\u0637\u0649",\uFCF5:"\u0637\u0649",\uFD12:"\u0637\u0649",\uFCF6:"\u0637\u0649","\u{1EE1A}":"\u0638","\u{1EE7A}":"\u0638","\u{1EE9A}":"\u0638","\u{1EEBA}":"\u0638",\uFEC7:"\u0638",\uFEC8:"\u0638",\uFEC6:"\u0638",\uFEC5:"\u0638",\uFCB9:"\u0638\u0645",\uFD3B:"\u0638\u0645",\uFC28:"\u0638\u0645","\u060F":"\u0639","\u{1EE0F}":"\u0639","\u{1EE2F}":"\u0639","\u{1EE4F}":"\u0639","\u{1EE6F}":"\u0639","\u{1EE8F}":"\u0639","\u{1EEAF}":"\u0639",\uFECB:"\u0639",\uFECC:"\u0639",\uFECA:"\u0639",\uFEC9:"\u0639",\uFCBA:"\u0639\u062C",\uFC29:"\u0639\u062C",\uFDC4:"\u0639\u062C\u0645",\uFD75:"\u0639\u062C\u0645",\uFDF7:"\u0639\u0644\u0649o",\uFCBB:"\u0639\u0645",\uFC2A:"\u0639\u0645",\uFD77:"\u0639\u0645\u0645",\uFD76:"\u0639\u0645\u0645",\uFD78:"\u0639\u0645\u0649",\uFDB6:"\u0639\u0645\u0649",\uFD13:"\u0639\u0649",\uFCF7:"\u0639\u0649",\uFD14:"\u0639\u0649",\uFCF8:"\u0639\u0649","\u{1EE1B}":"\u063A","\u{1EE3B}":"\u063A","\u{1EE5B}":"\u063A","\u{1EE7B}":"\u063A","\u{1EE9B}":"\u063A","\u{1EEBB}":"\u063A",\uFECF:"\u063A",\uFED0:"\u063A",\uFECE:"\u063A",\uFECD:"\u063A",\uFCBC:"\u063A\u062C",\uFC2B:"\u063A\u062C",\uFCBD:"\u063A\u0645",\uFC2C:"\u063A\u0645",\uFD79:"\u063A\u0645\u0645",\uFD7B:"\u063A\u0645\u0649",\uFD7A:"\u063A\u0645\u0649",\uFD15:"\u063A\u0649",\uFCF9:"\u063A\u0649",\uFD16:"\u063A\u0649",\uFCFA:"\u063A\u0649","\u{1EE10}":"\u0641","\u{1EE30}":"\u0641","\u{1EE70}":"\u0641","\u{1EE90}":"\u0641","\u{1EEB0}":"\u0641",\uFED3:"\u0641",\uFED4:"\u0641",\uFED2:"\u0641",\uFED1:"\u0641",\u06A7:"\u0641",\uFCBE:"\u0641\u062C",\uFC2D:"\u0641\u062C",\uFCBF:"\u0641\u062D",\uFC2E:"\u0641\u062D",\uFCC0:"\u0641\u062E",\uFC2F:"\u0641\u062E",\uFD7D:"\u0641\u062E\u0645",\uFD7C:"\u0641\u062E\u0645",\uFCC1:"\u0641\u0645",\uFC30:"\u0641\u0645",\uFDC1:"\u0641\u0645\u0649",\uFC7C:"\u0641\u0649",\uFC31:"\u0641\u0649",\uFC7D:"\u0641\u0649",\uFC32:"\u0641\u0649","\u{1EE1E}":"\u06A1","\u{1EE7E}":"\u06A1","\u08BB":"\u06A1","\u066F":"\u06A1","\u{1EE1F}":"\u06A1","\u{1EE5F}":"\u06A1","\u08BC":"\u06A1",\u06A4:"\u06A1\u06DB",\uFB6C:"\u06A1\u06DB",\uFB6D:"\u06A1\u06DB",\uFB6B:"\u06A1\u06DB",\uFB6A:"\u06A1\u06DB",\u06A8:"\u06A1\u06DB","\u08A4":"\u06A2\u06DB",\uFB70:"\u06A6",\uFB71:"\u06A6",\uFB6F:"\u06A6",\uFB6E:"\u06A6","\u{1EE12}":"\u0642","\u{1EE32}":"\u0642","\u{1EE52}":"\u0642","\u{1EE72}":"\u0642","\u{1EE92}":"\u0642","\u{1EEB2}":"\u0642",\uFED7:"\u0642",\uFED8:"\u0642",\uFED6:"\u0642",\uFED5:"\u0642",\uFCC2:"\u0642\u062D",\uFC33:"\u0642\u062D",\uFDF1:"\u0642\u0644\u0649",\uFCC3:"\u0642\u0645",\uFC34:"\u0642\u0645",\uFDB4:"\u0642\u0645\u062D",\uFD7E:"\u0642\u0645\u062D",\uFD7F:"\u0642\u0645\u0645",\uFDB2:"\u0642\u0645\u0649",\uFC7E:"\u0642\u0649",\uFC35:"\u0642\u0649",\uFC7F:"\u0642\u0649",\uFC36:"\u0642\u0649","\u{1EE0A}":"\u0643","\u{1EE2A}":"\u0643","\u{1EE6A}":"\u0643",\uFEDB:"\u0643",\uFEDC:"\u0643",\uFEDA:"\u0643",\uFED9:"\u0643",\u06A9:"\u0643",\uFB90:"\u0643",\uFB91:"\u0643",\uFB8F:"\u0643",\uFB8E:"\u0643",\u06AA:"\u0643",\u06AD:"\u0643\u06DB",\uFBD5:"\u0643\u06DB",\uFBD6:"\u0643\u06DB",\uFBD4:"\u0643\u06DB",\uFBD3:"\u0643\u06DB","\u0763":"\u0643\u06DB",\uFC80:"\u0643l",\uFC37:"\u0643l",\uFCC4:"\u0643\u062C",\uFC38:"\u0643\u062C",\uFCC5:"\u0643\u062D",\uFC39:"\u0643\u062D",\uFCC6:"\u0643\u062E",\uFC3A:"\u0643\u062E",\uFCC7:"\u0643\u0644",\uFCEB:"\u0643\u0644",\uFC81:"\u0643\u0644",\uFC3B:"\u0643\u0644",\uFCC8:"\u0643\u0645",\uFCEC:"\u0643\u0645",\uFC82:"\u0643\u0645",\uFC3C:"\u0643\u0645",\uFDC3:"\u0643\u0645\u0645",\uFDBB:"\u0643\u0645\u0645",\uFDB7:"\u0643\u0645\u0649",\uFC83:"\u0643\u0649",\uFC3D:"\u0643\u0649",\uFC84:"\u0643\u0649",\uFC3E:"\u0643\u0649","\u0762":"\u06AC",\uFB94:"\u06AF",\uFB95:"\u06AF",\uFB93:"\u06AF",\uFB92:"\u06AF","\u08B0":"\u06AF",\u06B4:"\u06AF\u06DB",\uFB9C:"\u06B1",\uFB9D:"\u06B1",\uFB9B:"\u06B1",\uFB9A:"\u06B1",\uFB98:"\u06B3",\uFB99:"\u06B3",\uFB97:"\u06B3",\uFB96:"\u06B3","\u{1EE0B}":"\u0644","\u{1EE2B}":"\u0644","\u{1EE4B}":"\u0644","\u{1EE8B}":"\u0644","\u{1EEAB}":"\u0644",\uFEDF:"\u0644",\uFEE0:"\u0644",\uFEDE:"\u0644",\uFEDD:"\u0644",\u06B7:"\u0644\u06DB",\u06B5:"\u0644\u0306",\uFEFC:"\u0644l",\uFEFB:"\u0644l",\uFEFA:"\u0644l\u0655",\uFEF9:"\u0644l\u0655",\uFEF8:"\u0644l\u0674",\uFEF7:"\u0644l\u0674",\uFCCD:"\u0644o",\uFEF6:"\u0644\u0622",\uFEF5:"\u0644\u0622",\uFCC9:"\u0644\u062C",\uFC3F:"\u0644\u062C",\uFD83:"\u0644\u062C\u062C",\uFD84:"\u0644\u062C\u062C",\uFDBA:"\u0644\u062C\u0645",\uFDBC:"\u0644\u062C\u0645",\uFDAC:"\u0644\u062C\u0649",\uFCCA:"\u0644\u062D",\uFC40:"\u0644\u062D",\uFDB5:"\u0644\u062D\u0645",\uFD80:"\u0644\u062D\u0645",\uFD82:"\u0644\u062D\u0649",\uFD81:"\u0644\u062D\u0649",\uFCCB:"\u0644\u062E",\uFC41:"\u0644\u062E",\uFD86:"\u0644\u062E\u0645",\uFD85:"\u0644\u062E\u0645",\uFCCC:"\u0644\u0645",\uFCED:"\u0644\u0645",\uFC85:"\u0644\u0645",\uFC42:"\u0644\u0645",\uFD88:"\u0644\u0645\u062D",\uFD87:"\u0644\u0645\u062D",\uFDAD:"\u0644\u0645\u0649",\uFC86:"\u0644\u0649",\uFC43:"\u0644\u0649",\uFC87:"\u0644\u0649",\uFC44:"\u0644\u0649","\u{1EE0C}":"\u0645","\u{1EE2C}":"\u0645","\u{1EE6C}":"\u0645","\u{1EE8C}":"\u0645","\u{1EEAC}":"\u0645",\uFEE3:"\u0645",\uFEE4:"\u0645",\uFEE2:"\u0645",\uFEE1:"\u0645","\u08A7":"\u0645\u06DB","\u06FE":"\u0645\u0348",\uFC88:"\u0645l",\uFCCE:"\u0645\u062C",\uFC45:"\u0645\u062C",\uFD8C:"\u0645\u062C\u062D",\uFD92:"\u0645\u062C\u062E",\uFD8D:"\u0645\u062C\u0645",\uFDC0:"\u0645\u062C\u0649",\uFCCF:"\u0645\u062D",\uFC46:"\u0645\u062D",\uFD89:"\u0645\u062D\u062C",\uFD8A:"\u0645\u062D\u0645",\uFDF4:"\u0645\u062D\u0645\u062F",\uFD8B:"\u0645\u062D\u0649",\uFCD0:"\u0645\u062E",\uFC47:"\u0645\u062E",\uFD8E:"\u0645\u062E\u062C",\uFD8F:"\u0645\u062E\u0645",\uFDB9:"\u0645\u062E\u0649",\uFCD1:"\u0645\u0645",\uFC89:"\u0645\u0645",\uFC48:"\u0645\u0645",\uFDB1:"\u0645\u0645\u0649",\uFC49:"\u0645\u0649",\uFC4A:"\u0645\u0649","\u{1EE0D}":"\u0646","\u{1EE2D}":"\u0646","\u{1EE4D}":"\u0646","\u{1EE6D}":"\u0646","\u{1EE8D}":"\u0646","\u{1EEAD}":"\u0646",\uFEE7:"\u0646",\uFEE8:"\u0646",\uFEE6:"\u0646",\uFEE5:"\u0646","\u0768":"\u0646\u0615","\u0769":"\u0646\u0306",\uFCD6:"\u0646o",\uFCEF:"\u0646o",\uFDB8:"\u0646\u062C\u062D",\uFDBD:"\u0646\u062C\u062D",\uFD98:"\u0646\u062C\u0645",\uFD97:"\u0646\u062C\u0645",\uFD99:"\u0646\u062C\u0649",\uFDC7:"\u0646\u062C\u0649",\uFCD3:"\u0646\u062D",\uFC4C:"\u0646\u062D",\uFD95:"\u0646\u062D\u0645",\uFD96:"\u0646\u062D\u0649",\uFDB3:"\u0646\u062D\u0649",\uFCD4:"\u0646\u062E",\uFC4D:"\u0646\u062E",\uFC8A:"\u0646\u0631",\uFC8B:"\u0646\u0632",\uFCD5:"\u0646\u0645",\uFCEE:"\u0646\u0645",\uFC8C:"\u0646\u0645",\uFC4E:"\u0646\u0645",\uFD9B:"\u0646\u0645\u0649",\uFD9A:"\u0646\u0645\u0649",\uFC8D:"\u0646\u0646",\uFC8E:"\u0646\u0649",\uFC4F:"\u0646\u0649",\uFC8F:"\u0646\u0649",\uFC50:"\u0646\u0649",\u06C2:"\u06C0",\uFBA5:"\u06C0",\uFBA4:"\u06C0","\u{102E4}":"\u0648","\u{1EE05}":"\u0648","\u{1EE85}":"\u0648","\u{1EEA5}":"\u0648",\uFEEE:"\u0648",\uFEED:"\u0648","\u08B1":"\u0648",\u06CB:"\u0648\u06DB",\uFBDF:"\u0648\u06DB",\uFBDE:"\u0648\u06DB",\u06C7:"\u0648\u0313",\uFBD8:"\u0648\u0313",\uFBD7:"\u0648\u0313",\u06C6:"\u0648\u0306",\uFBDA:"\u0648\u0306",\uFBD9:"\u0648\u0306",\u06C9:"\u0648\u0302",\uFBE3:"\u0648\u0302",\uFBE2:"\u0648\u0302",\u06C8:"\u0648\u0670",\uFBDC:"\u0648\u0670",\uFBDB:"\u0648\u0670",\u0624:"\u0648\u0674",\uFE86:"\u0648\u0674",\uFE85:"\u0648\u0674",\u0676:"\u0648\u0674",\u0677:"\u0648\u0313\u0674",\uFBDD:"\u0648\u0313\u0674",\uFDF8:"\u0648\u0633\u0644\u0645",\uFBE1:"\u06C5",\uFBE0:"\u06C5","\u066E":"\u0649","\u{1EE1C}":"\u0649","\u{1EE7C}":"\u0649",\u06BA:"\u0649","\u{1EE1D}":"\u0649","\u{1EE5D}":"\u0649",\uFB9F:"\u0649",\uFB9E:"\u0649","\u08BD":"\u0649",\uFBE8:"\u0649",\uFBE9:"\u0649",\uFEF0:"\u0649",\uFEEF:"\u0649",\u064A:"\u0649","\u{1EE09}":"\u0649","\u{1EE29}":"\u0649","\u{1EE49}":"\u0649","\u{1EE69}":"\u0649","\u{1EE89}":"\u0649","\u{1EEA9}":"\u0649",\uFEF3:"\u0649",\uFEF4:"\u0649",\uFEF2:"\u0649",\uFEF1:"\u0649",\u06CC:"\u0649",\uFBFE:"\u0649",\uFBFF:"\u0649",\uFBFD:"\u0649",\uFBFC:"\u0649",\u06D2:"\u0649",\uFBAF:"\u0649",\uFBAE:"\u0649",\u0679:"\u0649\u0615",\uFB68:"\u0649\u0615",\uFB69:"\u0649\u0615",\uFB67:"\u0649\u0615",\uFB66:"\u0649\u0615",\u06BB:"\u0649\u0615",\uFBA2:"\u0649\u0615",\uFBA3:"\u0649\u0615",\uFBA1:"\u0649\u0615",\uFBA0:"\u0649\u0615",\u067E:"\u0649\u06DB",\uFB58:"\u0649\u06DB",\uFB59:"\u0649\u06DB",\uFB57:"\u0649\u06DB",\uFB56:"\u0649\u06DB",\u062B:"\u0649\u06DB","\u{1EE16}":"\u0649\u06DB","\u{1EE36}":"\u0649\u06DB","\u{1EE76}":"\u0649\u06DB","\u{1EE96}":"\u0649\u06DB","\u{1EEB6}":"\u0649\u06DB",\uFE9B:"\u0649\u06DB",\uFE9C:"\u0649\u06DB",\uFE9A:"\u0649\u06DB",\uFE99:"\u0649\u06DB",\u06BD:"\u0649\u06DB",\u06D1:"\u0649\u06DB","\u063F":"\u0649\u06DB","\u08B7":"\u0649\u06DB\u06E2","\u0756":"\u0649\u0306",\u06CE:"\u0649\u0306","\u08BA":"\u0649\u0306\u0307","\u063D":"\u0649\u0302","\u08A8":"\u0649\u0654",\uFC90:"\u0649\u0670",\uFC5D:"\u0649\u0670",\uFCDE:"\u0649o",\uFCF1:"\u0649o",\uFCE6:"\u0649\u06DBo",\u0626:"\u0649\u0674",\uFE8B:"\u0649\u0674",\uFE8C:"\u0649\u0674",\uFE8A:"\u0649\u0674",\uFE89:"\u0649\u0674",\u0678:"\u0649\u0674",\uFBEB:"\u0649\u0674l",\uFBEA:"\u0649\u0674l",\uFC9B:"\u0649\u0674o",\uFCE0:"\u0649\u0674o",\uFBED:"\u0649\u0674o",\uFBEC:"\u0649\u0674o",\uFBF8:"\u0649\u0674\u067B",\uFBF7:"\u0649\u0674\u067B",\uFBF6:"\u0649\u0674\u067B",\uFC97:"\u0649\u0674\u062C",\uFC00:"\u0649\u0674\u062C",\uFC98:"\u0649\u0674\u062D",\uFC01:"\u0649\u0674\u062D",\uFC99:"\u0649\u0674\u062E",\uFC64:"\u0649\u0674\u0631",\uFC65:"\u0649\u0674\u0632",\uFC9A:"\u0649\u0674\u0645",\uFCDF:"\u0649\u0674\u0645",\uFC66:"\u0649\u0674\u0645",\uFC02:"\u0649\u0674\u0645",\uFC67:"\u0649\u0674\u0646",\uFBEF:"\u0649\u0674\u0648",\uFBEE:"\u0649\u0674\u0648",\uFBF1:"\u0649\u0674\u0648\u0313",\uFBF0:"\u0649\u0674\u0648\u0313",\uFBF3:"\u0649\u0674\u0648\u0306",\uFBF2:"\u0649\u0674\u0648\u0306",\uFBF5:"\u0649\u0674\u0648\u0670",\uFBF4:"\u0649\u0674\u0648\u0670",\uFBFB:"\u0649\u0674\u0649",\uFBFA:"\u0649\u0674\u0649",\uFC68:"\u0649\u0674\u0649",\uFBF9:"\u0649\u0674\u0649",\uFC03:"\u0649\u0674\u0649",\uFC69:"\u0649\u0674\u0649",\uFC04:"\u0649\u0674\u0649",\uFCDA:"\u0649\u062C",\uFC55:"\u0649\u062C",\uFC11:"\u0649\u06DB\u062C",\uFDAF:"\u0649\u062C\u0649",\uFCDB:"\u0649\u062D",\uFC56:"\u0649\u062D",\uFDAE:"\u0649\u062D\u0649",\uFCDC:"\u0649\u062E",\uFC57:"\u0649\u062E",\uFC91:"\u0649\u0631",\uFC76:"\u0649\u06DB\u0631",\uFC92:"\u0649\u0632",\uFC77:"\u0649\u06DB\u0632",\uFCDD:"\u0649\u0645",\uFCF0:"\u0649\u0645",\uFC93:"\u0649\u0645",\uFC58:"\u0649\u0645",\uFCA6:"\u0649\u06DB\u0645",\uFCE5:"\u0649\u06DB\u0645",\uFC78:"\u0649\u06DB\u0645",\uFC12:"\u0649\u06DB\u0645",\uFD9D:"\u0649\u0645\u0645",\uFD9C:"\u0649\u0645\u0645",\uFDB0:"\u0649\u0645\u0649",\uFC94:"\u0649\u0646",\uFC79:"\u0649\u06DB\u0646",\uFC95:"\u0649\u0649",\uFC59:"\u0649\u0649",\uFC96:"\u0649\u0649",\uFC5A:"\u0649\u0649",\uFC7A:"\u0649\u06DB\u0649",\uFC13:"\u0649\u06DB\u0649",\uFC7B:"\u0649\u06DB\u0649",\uFC14:"\u0649\u06DB\u0649",\uFBB1:"\u06D3",\uFBB0:"\u06D3","\u{102B8}":"\u2D40","\u205E":"\u2D42","\u2E3D":"\u2D42","\u2999":"\u2D42","\uFE19":"\u2D57","\u205D":"\u2D57","\u22EE":"\u2D57",\u0544:"\u1206",\u054C:"\u1261",\u053B:"\u12AE",\u054A:"\u1323",\u0906:"\u0905\u093E",\u0912:"\u0905\u093E\u0946",\u0913:"\u0905\u093E\u0947",\u0914:"\u0905\u093E\u0948","\u0904":"\u0905\u0946",\u0911:"\u0905\u0949",\u090D:"\u090F\u0945",\u090E:"\u090F\u0946",\u0910:"\u090F\u0947",\u0908:"\u0930\u094D\u0907",\u0ABD:"\u093D","\u{111DC}":"\uA8FB","\u{111CB}":"\u093A","\u0AC1":"\u0941","\u0AC2":"\u0942","\u0A4B":"\u0946","\u0A4D":"\u094D","\u0ACD":"\u094D",\u0986:"\u0985\u09BE",\u09E0:"\u098B\u09C3",\u09E1:"\u098B\u09C3","\u{11492}":"\u0998","\u{11494}":"\u099A","\u{11496}":"\u099C","\u{11498}":"\u099E","\u{11499}":"\u099F","\u{1149B}":"\u09A1","\u{114AA}":"\u09A3","\u{1149E}":"\u09A4","\u{1149F}":"\u09A5","\u{114A0}":"\u09A6","\u{114A1}":"\u09A7","\u{114A2}":"\u09A8","\u{114A3}":"\u09AA","\u{114A9}":"\u09AC","\u{114A7}":"\u09AE","\u{114A8}":"\u09AF","\u{114AB}":"\u09B0","\u{1149D}":"\u09B2","\u{114AD}":"\u09B7","\u{114AE}":"\u09B8","\u{114C4}":"\u09BD","\u{114B0}":"\u09BE","\u{114B1}":"\u09BF","\u{114B9}":"\u09C7","\u{114BC}":"\u09CB","\u{114BE}":"\u09CC","\u{114C2}":"\u09CD","\u{114BD}":"\u09D7",\u0A09:"\u0A73\u0A41",\u0A0A:"\u0A73\u0A42",\u0A06:"\u0A05\u0A3E",\u0A10:"\u0A05\u0A48",\u0A14:"\u0A05\u0A4C",\u0A07:"\u0A72\u0A3F",\u0A08:"\u0A72\u0A40",\u0A0F:"\u0A72\u0A47",\u0A86:"\u0A85\u0ABE",\u0A91:"\u0A85\u0ABE\u0AC5",\u0A93:"\u0A85\u0ABE\u0AC7",\u0A94:"\u0A85\u0ABE\u0AC8",\u0A8D:"\u0A85\u0AC5",\u0A8F:"\u0A85\u0AC7",\u0A90:"\u0A85\u0AC8",\u0B06:"\u0B05\u0B3E","\u0BEE":"\u0B85",\u0BB0:"\u0B88","\u0BBE":"\u0B88","\u0BEB":"\u0B88\u0BC1","\u0BE8":"\u0B89",\u0D09:"\u0B89",\u0B8A:"\u0B89\u0BB3",\u0D0A:"\u0B89\u0D57","\u0BED":"\u0B8E","\u0BF7":"\u0B8E\u0BB5",\u0B9C:"\u0B90",\u0D1C:"\u0B90","\u0BE7":"\u0B95","\u0BEA":"\u0B9A","\u0BEC":"\u0B9A\u0BC1","\u0BF2":"\u0B9A\u0BC2","\u0D3A":"\u0B9F\u0BBF",\u0D23:"\u0BA3","\u0BFA":"\u0BA8\u0BC0","\u0BF4":"\u0BAE\u0BC0","\u0BF0":"\u0BAF",\u0D34:"\u0BB4","\u0BD7":"\u0BB3","\u0BC8":"\u0BA9",\u0D36:"\u0BB6","\u0BF8":"\u0BB7","\u0D3F":"\u0BBF","\u0D40":"\u0BBF","\u0BCA":"\u0BC6\u0B88","\u0BCC":"\u0BC6\u0BB3","\u0BCB":"\u0BC7\u0B88",\u0C85:"\u0C05",\u0C86:"\u0C06",\u0C87:"\u0C07",\u0C60:"\u0C0B\u0C3E",\u0C61:"\u0C0C\u0C3E",\u0C92:"\u0C12",\u0C14:"\u0C12\u0C4C",\u0C94:"\u0C12\u0C4C",\u0C13:"\u0C12\u0C55",\u0C93:"\u0C12\u0C55",\u0C9C:"\u0C1C",\u0C9E:"\u0C1E",\u0C22:"\u0C21\u0323",\u0CA3:"\u0C23",\u0C25:"\u0C27\u05BC",\u0C2D:"\u0C2C\u0323",\u0CAF:"\u0C2F",\u0C20:"\u0C30\u05BC",\u0CB1:"\u0C31",\u0CB2:"\u0C32",\u0C37:"\u0C35\u0323",\u0C39:"\u0C35\u0C3E",\u0C2E:"\u0C35\u0C41","\u0C42":"\u0C41\u0C3E","\u0C44":"\u0C43\u0C3E",\u0CE1:"\u0C8C\u0CBE",\u0D08:"\u0D07\u0D57",\u0D10:"\u0D0E\u0D46",\u0D13:"\u0D12\u0D3E",\u0D14:"\u0D12\u0D57",\u0D61:"\u0D1E","\u0D6B":"\u0D26\u0D4D\u0D30","\u0D79":"\u0D28\u0D41",\u0D0C:"\u0D28\u0D41",\u0D19:"\u0D28\u0D41","\u0D6F":"\u0D28\u0D4D","\u0D7B":"\u0D28\u0D4D","\u0D6C":"\u0D28\u0D4D\u0D28","\u0D5A":"\u0D28\u0D4D\u0D2E",\u0D31:"\u0D30","\u0D6A":"\u0D30\u0D4D","\u0D7C":"\u0D30\u0D4D","\u0D6E":"\u0D35\u0D4D\u0D30","\u0D76":"\u0D39\u0D4D\u0D2E","\u0D42":"\u0D41","\u0D43":"\u0D41","\u0D48":"\u0D46\u0D46","\u0DEA":"\u0DA2","\u0DEB":"\u0DAF","\u{11413}":"\u{11434}\u{11442}\u{11412}","\u{11419}":"\u{11434}\u{11442}\u{11418}","\u{11424}":"\u{11434}\u{11442}\u{11423}","\u{1142A}":"\u{11434}\u{11442}\u{11429}","\u{1142D}":"\u{11434}\u{11442}\u{1142C}","\u{1142F}":"\u{11434}\u{11442}\u{1142E}","\u{115D8}":"\u{11582}","\u{115D9}":"\u{11582}","\u{115DA}":"\u{11583}","\u{115DB}":"\u{11584}","\u{115DC}":"\u{115B2}","\u{115DD}":"\u{115B3}",\u0E03:"\u0E02",\u0E14:"\u0E04",\u0E15:"\u0E04",\u0E21:"\u0E06",\u0E88:"\u0E08",\u0E0B:"\u0E0A",\u0E0F:"\u0E0E",\u0E17:"\u0E11",\u0E9A:"\u0E1A",\u0E9B:"\u0E1B",\u0E9D:"\u0E1D",\u0E9E:"\u0E1E",\u0E9F:"\u0E1F",\u0E26:"\u0E20",\u0E8D:"\u0E22","\u17D4":"\u0E2F",\u0E45:"\u0E32",\u0E33:"\u030A\u0E32","\u17B7":"\u0E34","\u17B8":"\u0E35","\u17B9":"\u0E36","\u17BA":"\u0E37","\u0EB8":"\u0E38","\u0EB9":"\u0E39",\u0E41:"\u0E40\u0E40",\u0EDC:"\u0EAB\u0E99",\u0EDD:"\u0EAB\u0EA1",\u0EB3:"\u030A\u0EB2","\u0F02":"\u0F60\u0F74\u0F82\u0F7F","\u0F03":"\u0F60\u0F74\u0F82\u0F14",\u0F6A:"\u0F62",\u0F00:"\u0F68\u0F7C\u0F7E","\u0F77":"\u0FB2\u0F71\u0F80","\u0F79":"\u0FB3\u0F71\u0F80","\u{11CB2}":"\u{11CAA}","\u1081":"\u1002\u103E",\u1000:"\u1002\u102C","\u1070":"\u1003\u103E","\u1066":"\u1015\u103E",\u101F:"\u1015\u102C","\u106F":"\u1015\u102C\u103E","\u107E":"\u107D\u103E",\u1029:"\u101E\u103C",\u102A:"\u101E\u103C\u1031\u102C\u103A","\u109E":"\u1083\u030A",\u17A3:"\u17A2","\u19D0":"\u199E","\u19D1":"\u19B1","\u1A80":"\u1A45","\u1A90":"\u1A45","\uAA53":"\uAA01","\uAA56":"\uAA23","\u1B52":"\u1B0D","\u1B53":"\u1B11","\u1B58":"\u1B28","\uA9A3":"\uA99D",\u1896:"\u185C",\u1855:"\u1835",\u1FF6:"\u13EF",\u140D:"\u1401\xB7",\u142B:"\u1401\u1420",\u1411:"\u1404\xB7",\u1413:"\u1405\xB7",\u142D:"\u1405\u1420",\u1415:"\u1406\xB7",\u1418:"\u140A\xB7",\u142E:"\u140A\u1420",\u141A:"\u140B\xB7","\u18DD":"\u141E\u18DF",\u14D1:"\u1421",\u1540:"\u1429",\u143F:"\u1432\xB7",\u1443:"\u1434\xB7","\u2369":"\u1435",\u1447:"\u1439\xB7",\u145C:"\u144F\xB7","\u2E27":"\u1450","\u2283":"\u1450",\u145E:"\u1450\xB7",\u1469:"\u1450'","\u27C9":"\u1450/","\u2AD7":"\u1450\u1455",\u1460:"\u1451\xB7","\u2E26":"\u1455","\u2282":"\u1455",\u1462:"\u1455\xB7",\u146A:"\u1455'",\u1464:"\u1456\xB7",\u1475:"\u146B\xB7",\u1485:"\u146B'",\u1479:"\u146E\xB7",\u147D:"\u1470\xB7",\u1603:"\u1489",\u1493:"\u1489\xB7",\u1495:"\u148B\xB7",\u1497:"\u148C\xB7",\u149B:"\u148E\xB7",\u1602:"\u1490",\u149D:"\u1490\xB7",\u149F:"\u1491\xB7",\u14AD:"\u14A3\xB7",\u14B1:"\u14A6\xB7",\u14B3:"\u14A7\xB7",\u14B5:"\u14A8\xB7",\u14B9:"\u14AB\xB7",\u14CA:"\u14C0\xB7","\u18C7":"\u14C2\xB7","\u18C9":"\u14C3\xB7","\u18CB":"\u14C4\xB7","\u18CD":"\u14C5\xB7",\u14CC:"\u14C7\xB7",\u14CE:"\u14C8\xB7",\u1604:"\u14D3",\u14DD:"\u14D3\xB7",\u14DF:"\u14D5\xB7",\u14E1:"\u14D6\xB7",\u14E3:"\u14D7\xB7",\u14E5:"\u14D8\xB7",\u1607:"\u14DA",\u14E7:"\u14DA\xB7",\u14E9:"\u14DB\xB7",\u14F7:"\u14ED\xB7",\u14F9:"\u14EF\xB7",\u14FB:"\u14F0\xB7",\u14FD:"\u14F1\xB7",\u14FF:"\u14F2\xB7",\u1501:"\u14F4\xB7",\u1503:"\u14F5\xB7",\u150C:"\u150B<",\u150E:"\u150Bb",\u150D:"\u150B\u1455",\u150F:"\u150B\u1490",\u1518:"\u1510\xB7",\u151A:"\u1511\xB7",\u151C:"\u1512\xB7",\u151E:"\u1513\xB7",\u1520:"\u1514\xB7",\u1522:"\u1515\xB7",\u1524:"\u1516\xB7",\u1532:"\u1528\xB7",\u1534:"\u1529\xB7",\u1536:"\u152A\xB7",\u1538:"\u152B\xB7",\u153A:"\u152D\xB7",\u153C:"\u152E\xB7",\u1622:"\u1543","\u18E0":"\u1543\xB7",\u1623:"\u1546",\u1624:"\u154A",\u154F:"\u154C\xB7",\u1583:"\u1550b",\u1584:"\u1550b\u0307",\u1581:"\u1550d",\u157F:"\u1550P",\u166F:"\u1550\u146B",\u157E:"\u1550\u146C",\u1580:"\u1550\u146E",\u1582:"\u1550\u1470",\u1585:"\u1550\u1483",\u155C:"\u155A\xB7","\u18E3":"\u155E\xB7","\u18E4":"\u1566\xB7",\u1569:"\u1567\xB7","\u18E5":"\u156B\xB7","\u18E8":"\u1586\xB7",\u1591:"\u1595J",\u1670:"\u1595\u1489",\u158E:"\u1595\u148A",\u158F:"\u1595\u148B",\u1590:"\u1595\u148C",\u1592:"\u1595\u148E",\u1593:"\u1595\u1490",\u1594:"\u1595\u1491",\u1673:"\u1596J",\u1671:"\u1596\u148B",\u1672:"\u1596\u148C",\u1674:"\u1596\u148E",\u1675:"\u1596\u1490",\u1676:"\u1596\u1491","\u18EA":"\u1597\xB7","\u1677":"\u15A7\xB7","\u1678":"\u15A8\xB7","\u1679":"\u15A9\xB7","\u167A":"\u15AA\xB7","\u167B":"\u15AB\xB7","\u167C":"\u15AC\xB7","\u167D":"\u15AD\xB7","\u2AAB":"\u15D2","\u2AAA":"\u15D5","\uA4F7":"\u15E1","\u18F0":"\u15F4\xB7","\u18F2":"\u161B\xB7","\u1DBB":"\u1646","\uA4ED":"\u1660","\u1DBA":"\u18D4","\u1D3E":"\u18D6","\u18DC":"\u18DF\u141E",\u02E1:"\u18F3",\u02B3:"\u18F4",\u02E2:"\u18F5","\u18DB":"\u18F5","\uA6B0":"\u16B9",\u16E1:"\u16BC","\u237F":"\u16BD",\u16C2:"\u16BD","\u{1D23F}":"\u16CB","\u2191":"\u16CF","\u21BF":"\u16D0","\u296E":"\u16D0\u21C2","\u2963":"\u16D0\u16DA","\u2D63":"\u16EF","\u21BE":"\u16DA","\u2A21":"\u16DA","\u22C4":"\u16DC","\u25C7":"\u16DC","\u25CA":"\u16DC","\u2662":"\u16DC","\u{1F754}":"\u16DC","\u{118B7}":"\u16DC","\u{10294}":"\u16DC","\u235A":"\u16DC\u0332","\u22C8":"\u16DE","\u2A1D":"\u16DE","\u{104D0}":"\u16E6","\u2195":"\u16E8","\u{10CFC}":"\u{10C82}","\u{10CFA}":"\u{10CA5}",\u3131:"\u1100",\u11A8:"\u1100",\u1101:"\u1100\u1100",\u3132:"\u1100\u1100",\u11A9:"\u1100\u1100","\u11FA":"\u1100\u1102","\u115A":"\u1100\u1103",\u11C3:"\u1100\u1105","\u11FB":"\u1100\u1107",\u11AA:"\u1100\u1109",\u3133:"\u1100\u1109",\u11C4:"\u1100\u1109\u1100","\u11FC":"\u1100\u110E","\u11FD":"\u1100\u110F","\u11FE":"\u1100\u1112",\u3134:"\u1102",\u11AB:"\u1102",\u1113:"\u1102\u1100",\u11C5:"\u1102\u1100",\u1114:"\u1102\u1102",\u3165:"\u1102\u1102","\u11FF":"\u1102\u1102",\u1115:"\u1102\u1103",\u3166:"\u1102\u1103",\u11C6:"\u1102\u1103","\uD7CB":"\u1102\u1105",\u1116:"\u1102\u1107","\u115B":"\u1102\u1109",\u11C7:"\u1102\u1109",\u3167:"\u1102\u1109","\u115C":"\u1102\u110C",\u11AC:"\u1102\u110C",\u3135:"\u1102\u110C","\uD7CC":"\u1102\u110E",\u11C9:"\u1102\u1110","\u115D":"\u1102\u1112",\u11AD:"\u1102\u1112",\u3136:"\u1102\u1112",\u11C8:"\u1102\u1140",\u3168:"\u1102\u1140",\u3137:"\u1103",\u11AE:"\u1103",\u1117:"\u1103\u1100",\u11CA:"\u1103\u1100",\u1104:"\u1103\u1103",\u3138:"\u1103\u1103","\uD7CD":"\u1103\u1103","\uD7CE":"\u1103\u1103\u1107","\u115E":"\u1103\u1105",\u11CB:"\u1103\u1105","\uA960":"\u1103\u1106","\uA961":"\u1103\u1107","\uD7CF":"\u1103\u1107","\uA962":"\u1103\u1109","\uD7D0":"\u1103\u1109","\uD7D1":"\u1103\u1109\u1100","\uA963":"\u1103\u110C","\uD7D2":"\u1103\u110C","\uD7D3":"\u1103\u110E","\uD7D4":"\u1103\u1110",\u3139:"\u1105",\u11AF:"\u1105","\uA964":"\u1105\u1100",\u11B0:"\u1105\u1100",\u313A:"\u1105\u1100","\uA965":"\u1105\u1100\u1100","\uD7D5":"\u1105\u1100\u1100",\u11CC:"\u1105\u1100\u1109",\u3169:"\u1105\u1100\u1109","\uD7D6":"\u1105\u1100\u1112",\u1118:"\u1105\u1102",\u11CD:"\u1105\u1102","\uA966":"\u1105\u1103",\u11CE:"\u1105\u1103",\u316A:"\u1105\u1103","\uA967":"\u1105\u1103\u1103",\u11CF:"\u1105\u1103\u1112",\u1119:"\u1105\u1105",\u11D0:"\u1105\u1105","\uD7D7":"\u1105\u1105\u110F","\uA968":"\u1105\u1106",\u11B1:"\u1105\u1106",\u313B:"\u1105\u1106",\u11D1:"\u1105\u1106\u1100",\u11D2:"\u1105\u1106\u1109","\uD7D8":"\u1105\u1106\u1112","\uA969":"\u1105\u1107",\u11B2:"\u1105\u1107",\u313C:"\u1105\u1107","\uD7D9":"\u1105\u1107\u1103","\uA96A":"\u1105\u1107\u1107",\u11D3:"\u1105\u1107\u1109",\u316B:"\u1105\u1107\u1109","\uA96B":"\u1105\u1107\u110B",\u11D5:"\u1105\u1107\u110B","\uD7DA":"\u1105\u1107\u1111",\u11D4:"\u1105\u1107\u1112","\uA96C":"\u1105\u1109",\u11B3:"\u1105\u1109",\u313D:"\u1105\u1109",\u11D6:"\u1105\u1109\u1109",\u111B:"\u1105\u110B","\uD7DD":"\u1105\u110B","\uA96D":"\u1105\u110C","\uA96E":"\u1105\u110F",\u11D8:"\u1105\u110F",\u11B4:"\u1105\u1110",\u313E:"\u1105\u1110",\u11B5:"\u1105\u1111",\u313F:"\u1105\u1111",\u111A:"\u1105\u1112",\u3140:"\u1105\u1112",\u113B:"\u1105\u1112",\u11B6:"\u1105\u1112","\uD7F2":"\u1105\u1112",\u11D7:"\u1105\u1140",\u316C:"\u1105\u1140","\uD7DB":"\u1105\u114C",\u11D9:"\u1105\u1159",\u316D:"\u1105\u1159","\uD7DC":"\u1105\u1159\u1112",\u3141:"\u1106",\u11B7:"\u1106","\uA96F":"\u1106\u1100",\u11DA:"\u1106\u1100","\uD7DE":"\u1106\u1102","\uD7DF":"\u1106\u1102\u1102","\uA970":"\u1106\u1103",\u11DB:"\u1106\u1105","\uD7E0":"\u1106\u1106",\u111C:"\u1106\u1107",\u316E:"\u1106\u1107",\u11DC:"\u1106\u1107","\uD7E1":"\u1106\u1107\u1109","\uA971":"\u1106\u1109",\u11DD:"\u1106\u1109",\u316F:"\u1106\u1109",\u11DE:"\u1106\u1109\u1109",\u111D:"\u1106\u110B",\u3171:"\u1106\u110B",\u11E2:"\u1106\u110B","\uD7E2":"\u1106\u110C",\u11E0:"\u1106\u110E",\u11E1:"\u1106\u1112",\u11DF:"\u1106\u1140",\u3170:"\u1106\u1140",\u3142:"\u1107",\u11B8:"\u1107",\u111E:"\u1107\u1100",\u3172:"\u1107\u1100",\u111F:"\u1107\u1102",\u1120:"\u1107\u1103",\u3173:"\u1107\u1103","\uD7E3":"\u1107\u1103",\u11E3:"\u1107\u1105","\uD7E4":"\u1107\u1105\u1111","\uD7E5":"\u1107\u1106",\u1108:"\u1107\u1107",\u3143:"\u1107\u1107","\uD7E6":"\u1107\u1107",\u112C:"\u1107\u1107\u110B",\u3179:"\u1107\u1107\u110B",\u1121:"\u1107\u1109",\u3144:"\u1107\u1109",\u11B9:"\u1107\u1109",\u1122:"\u1107\u1109\u1100",\u3174:"\u1107\u1109\u1100",\u1123:"\u1107\u1109\u1103",\u3175:"\u1107\u1109\u1103","\uD7E7":"\u1107\u1109\u1103",\u1124:"\u1107\u1109\u1107",\u1125:"\u1107\u1109\u1109",\u1126:"\u1107\u1109\u110C","\uA972":"\u1107\u1109\u1110",\u112B:"\u1107\u110B",\u3178:"\u1107\u110B",\u11E6:"\u1107\u110B",\u1127:"\u1107\u110C",\u3176:"\u1107\u110C","\uD7E8":"\u1107\u110C",\u1128:"\u1107\u110E","\uD7E9":"\u1107\u110E","\uA973":"\u1107\u110F",\u1129:"\u1107\u1110",\u3177:"\u1107\u1110",\u112A:"\u1107\u1111",\u11E4:"\u1107\u1111","\uA974":"\u1107\u1112",\u11E5:"\u1107\u1112",\u3145:"\u1109",\u11BA:"\u1109",\u112D:"\u1109\u1100",\u317A:"\u1109\u1100",\u11E7:"\u1109\u1100",\u112E:"\u1109\u1102",\u317B:"\u1109\u1102",\u112F:"\u1109\u1103",\u317C:"\u1109\u1103",\u11E8:"\u1109\u1103",\u1130:"\u1109\u1105",\u11E9:"\u1109\u1105",\u1131:"\u1109\u1106","\uD7EA":"\u1109\u1106",\u1132:"\u1109\u1107",\u317D:"\u1109\u1107",\u11EA:"\u1109\u1107",\u1133:"\u1109\u1107\u1100","\uD7EB":"\u1109\u1107\u110B",\u110A:"\u1109\u1109",\u3146:"\u1109\u1109",\u11BB:"\u1109\u1109","\uD7EC":"\u1109\u1109\u1100","\uD7ED":"\u1109\u1109\u1103","\uA975":"\u1109\u1109\u1107",\u1134:"\u1109\u1109\u1109",\u1135:"\u1109\u110B",\u1136:"\u1109\u110C",\u317E:"\u1109\u110C","\uD7EF":"\u1109\u110C",\u1137:"\u1109\u110E","\uD7F0":"\u1109\u110E",\u1138:"\u1109\u110F",\u1139:"\u1109\u1110","\uD7F1":"\u1109\u1110",\u113A:"\u1109\u1111","\uD7EE":"\u1109\u1140",\u3147:"\u110B",\u11BC:"\u110B",\u1141:"\u110B\u1100",\u11EC:"\u110B\u1100",\u11ED:"\u110B\u1100\u1100",\u1142:"\u110B\u1103","\uA976":"\u110B\u1105",\u1143:"\u110B\u1106",\u1144:"\u110B\u1107",\u1145:"\u110B\u1109",\u11F1:"\u110B\u1109",\u3182:"\u110B\u1109",\u1147:"\u110B\u110B",\u3180:"\u110B\u110B",\u11EE:"\u110B\u110B",\u1148:"\u110B\u110C",\u1149:"\u110B\u110E",\u11EF:"\u110B\u110F",\u114A:"\u110B\u1110",\u114B:"\u110B\u1111","\uA977":"\u110B\u1112",\u1146:"\u110B\u1140",\u11F2:"\u110B\u1140",\u3183:"\u110B\u1140",\u3148:"\u110C",\u11BD:"\u110C","\uD7F7":"\u110C\u1107","\uD7F8":"\u110C\u1107\u1107",\u114D:"\u110C\u110B",\u110D:"\u110C\u110C",\u3149:"\u110C\u110C","\uD7F9":"\u110C\u110C","\uA978":"\u110C\u110C\u1112",\u314A:"\u110E",\u11BE:"\u110E",\u1152:"\u110E\u110F",\u1153:"\u110E\u1112",\u314B:"\u110F",\u11BF:"\u110F",\u314C:"\u1110",\u11C0:"\u1110","\uA979":"\u1110\u1110",\u314D:"\u1111",\u11C1:"\u1111",\u1156:"\u1111\u1107",\u11F3:"\u1111\u1107","\uD7FA":"\u1111\u1109",\u1157:"\u1111\u110B",\u3184:"\u1111\u110B",\u11F4:"\u1111\u110B","\uD7FB":"\u1111\u1110","\uA97A":"\u1111\u1112",\u314E:"\u1112",\u11C2:"\u1112",\u11F5:"\u1112\u1102",\u11F6:"\u1112\u1105",\u11F7:"\u1112\u1106",\u11F8:"\u1112\u1107","\uA97B":"\u1112\u1109",\u1158:"\u1112\u1112",\u3185:"\u1112\u1112",\u113D:"\u113C\u113C",\u113F:"\u113E\u113E",\u317F:"\u1140",\u11EB:"\u1140","\uD7F3":"\u1140\u1107","\uD7F4":"\u1140\u1107\u110B",\u3181:"\u114C",\u11F0:"\u114C","\uD7F5":"\u114C\u1106","\uD7F6":"\u114C\u1112",\u114F:"\u114E\u114E",\u1151:"\u1150\u1150",\u3186:"\u1159",\u11F9:"\u1159","\uA97C":"\u1159\u1159",\u3164:"\u1160",\u314F:"\u1161","\u11A3":"\u1161\u30FC",\u1176:"\u1161\u1169",\u1177:"\u1161\u116E",\u1162:"\u1161\u4E28",\u3150:"\u1161\u4E28",\u3151:"\u1163",\u1178:"\u1163\u1169",\u1179:"\u1163\u116D","\u11A4":"\u1163\u116E",\u1164:"\u1163\u4E28",\u3152:"\u1163\u4E28",\u3153:"\u1165",\u117C:"\u1165\u30FC",\u117A:"\u1165\u1169",\u117B:"\u1165\u116E",\u1166:"\u1165\u4E28",\u3154:"\u1165\u4E28",\u3155:"\u1167","\u11A5":"\u1167\u1163",\u117D:"\u1167\u1169",\u117E:"\u1167\u116E",\u1168:"\u1167\u4E28",\u3156:"\u1167\u4E28",\u3157:"\u1169",\u116A:"\u1169\u1161",\u3158:"\u1169\u1161",\u116B:"\u1169\u1161\u4E28",\u3159:"\u1169\u1161\u4E28","\u11A6":"\u1169\u1163","\u11A7":"\u1169\u1163\u4E28",\u117F:"\u1169\u1165",\u1180:"\u1169\u1165\u4E28","\uD7B0":"\u1169\u1167",\u1181:"\u1169\u1167\u4E28",\u1182:"\u1169\u1169","\uD7B1":"\u1169\u1169\u4E28",\u1183:"\u1169\u116E",\u116C:"\u1169\u4E28",\u315A:"\u1169\u4E28",\u315B:"\u116D","\uD7B2":"\u116D\u1161","\uD7B3":"\u116D\u1161\u4E28",\u1184:"\u116D\u1163",\u3187:"\u116D\u1163",\u1186:"\u116D\u1163",\u1185:"\u116D\u1163\u4E28",\u3188:"\u116D\u1163\u4E28","\uD7B4":"\u116D\u1165",\u1187:"\u116D\u1169",\u1188:"\u116D\u4E28",\u3189:"\u116D\u4E28",\u315C:"\u116E",\u1189:"\u116E\u1161",\u118A:"\u116E\u1161\u4E28",\u116F:"\u116E\u1165",\u315D:"\u116E\u1165",\u118B:"\u116E\u1165\u30FC",\u1170:"\u116E\u1165\u4E28",\u315E:"\u116E\u1165\u4E28","\uD7B5":"\u116E\u1167",\u118C:"\u116E\u1167\u4E28",\u118D:"\u116E\u116E",\u1171:"\u116E\u4E28",\u315F:"\u116E\u4E28","\uD7B6":"\u116E\u4E28\u4E28",\u3160:"\u1172",\u118E:"\u1172\u1161","\uD7B7":"\u1172\u1161\u4E28",\u118F:"\u1172\u1165",\u1190:"\u1172\u1165\u4E28",\u1191:"\u1172\u1167",\u318A:"\u1172\u1167",\u1192:"\u1172\u1167\u4E28",\u318B:"\u1172\u1167\u4E28","\uD7B8":"\u1172\u1169",\u1193:"\u1172\u116E",\u1194:"\u1172\u4E28",\u318C:"\u1172\u4E28",\u318D:"\u119E","\uD7C5":"\u119E\u1161",\u119F:"\u119E\u1165","\uD7C6":"\u119E\u1165\u4E28",\u11A0:"\u119E\u116E",\u11A2:"\u119E\u119E",\u11A1:"\u119E\u4E28",\u318E:"\u119E\u4E28",\u30D8:"\u3078","\u2341":"\u303C","\u29C4":"\u303C","\uA49E":"\uA04A","\uA4AC":"\uA050","\uA49C":"\uA0C0","\uA4A8":"\uA132","\uA4BF":"\uA259","\uA4BE":"\uA2B1","\uA494":"\uA2CD","\uA4C0":"\uA3AB","\uA4C2":"\uA3B5","\uA4BA":"\uA3BF","\uA4B0":"\uA3C2","\uA4A7":"\uA458","\u22A5":"\uA4D5","\u27C2":"\uA4D5","\u{1D21C}":"\uA4D5","\uA7B1":"\uA4D5","\uA79E":"\uA4E4","\u2141":"\uA4E8","\u2142":"\uA4F6","\u{1D215}":"\uA4F6","\u{1D22B}":"\uA4F6","\u{16F26}":"\uA4F6","\u{10411}":"\uA4F6","\u2143":"\u{16F00}","\u{11AE6}":"\u{11AE5}\u{11AEF}","\u{11AE8}":"\u{11AE5}\u{11AE5}","\u{11AE9}":"\u{11AE5}\u{11AE5}\u{11AEF}","\u{11AEA}":"\u{11AE5}\u{11AE5}\u{11AF0}","\u{11AE7}":"\u{11AE5}\u{11AF0}","\u{11AF4}":"\u{11AF3}\u{11AEF}","\u{11AF6}":"\u{11AF3}\u{11AF3}","\u{11AF7}":"\u{11AF3}\u{11AF3}\u{11AEF}","\u{11AF8}":"\u{11AF3}\u{11AF3}\u{11AF0}","\u{11AF5}":"\u{11AF3}\u{11AF0}","\u{11AEC}":"\u{11AEB}\u{11AEF}","\u{11AED}":"\u{11AEB}\u{11AEB}","\u{11AEE}":"\u{11AEB}\u{11AEB}\u{11AEF}","\u2295":"\u{102A8}","\u2A01":"\u{102A8}","\u{1F728}":"\u{102A8}","\uA69A":"\u{102A8}","\u25BD":"\u{102BC}","\u{1D214}":"\u{102BC}","\u{1F704}":"\u{102BC}","\u29D6":"\u{102C0}","\uA79B":"\u{1043A}","\uA79A":"\u{10412}","\u{104A0}":"\u{10486}","\u{103D1}":"\u{10382}","\u{103D3}":"\u{10393}","\u{12038}":"\u{1039A}","\u2625":"\u{1099E}","\u{132F9}":"\u{1099E}","\u3039":"\u5344",\uF967:"\u4E0D","\u{2F800}":"\u4E3D","\uFA70":"\u4E26","\u239C":"\u4E28","\u239F":"\u4E28","\u23A2":"\u4E28","\u23A5":"\u4E28","\u23AA":"\u4E28","\u23AE":"\u4E28","\u31D1":"\u4E28",\u1175:"\u4E28",\u3163:"\u4E28","\u2F01":"\u4E28",\u119C:"\u4E28\u30FC",\u1198:"\u4E28\u1161",\u1199:"\u4E28\u1163","\uD7BD":"\u4E28\u1163\u1169","\uD7BE":"\u4E28\u1163\u4E28","\uD7BF":"\u4E28\u1167","\uD7C0":"\u4E28\u1167\u4E28",\u119A:"\u4E28\u1169","\uD7C1":"\u4E28\u1169\u4E28","\uD7C2":"\u4E28\u116D",\u119B:"\u4E28\u116E","\uD7C3":"\u4E28\u1172",\u119D:"\u4E28\u119E","\uD7C4":"\u4E28\u4E28",\uF905:"\u4E32","\u{2F801}":"\u4E38",\uF95E:"\u4E39","\u{2F802}":"\u4E41","\u31E0":"\u4E59","\u2F04":"\u4E59","\u31DF":"\u4E5A","\u2E83":"\u4E5A","\u31D6":"\u4E5B","\u2E82":"\u4E5B","\u2EF2":"\u4E80",\uF91B:"\u4E82","\u31DA":"\u4E85","\u2F05":"\u4E85",\uF9BA:"\u4E86",\u30CB:"\u4E8C","\u2F06":"\u4E8C","\u{2F803}":"\u{20122}","\u2F07":"\u4EA0",\uF977:"\u4EAE","\u2F08":"\u4EBA",\u30A4:"\u4EBB","\u2E85":"\u4EBB",\uF9FD:"\u4EC0","\u{2F819}":"\u4ECC",\uF9A8:"\u4EE4","\u{2F804}":"\u4F60",\u5002:"\u4F75","\u{2F807}":"\u4F75","\uFA73":"\u4F80",\uF92D:"\u4F86",\uF9B5:"\u4F8B","\uFA30":"\u4FAE","\u{2F805}":"\u4FAE","\u{2F806}":"\u4FBB",\uF965:"\u4FBF",\u503C:"\u5024",\uF9D4:"\u502B","\u{2F808}":"\u507A","\u{2F809}":"\u5099","\u{2F80B}":"\u50CF",\uF9BB:"\u50DA","\uFA31":"\u50E7","\u{2F80A}":"\u50E7","\u{2F80C}":"\u349E","\u2F09":"\u513F",\uFA0C:"\u5140","\u2E8E":"\u5140","\uFA74":"\u5145","\uFA32":"\u514D","\u{2F80E}":"\u514D","\u{2F80F}":"\u5154","\u{2F810}":"\u5164","\u2F0A":"\u5165","\u{2F814}":"\u5167","\uFA72":"\u5168",\uF978:"\u5169",\u30CF:"\u516B","\u2F0B":"\u516B",\uF9D1:"\u516D","\u{2F811}":"\u5177","\u{2F812}":"\u{2051C}","\u{2F91B}":"\u{20525}","\uFA75":"\u5180","\u{2F813}":"\u34B9","\u2F0C":"\u5182","\u{2F815}":"\u518D","\u{2F816}":"\u{2054B}","\u{2F8D2}":"\u5192","\u{2F8D3}":"\u5195","\u{2F9CA}":"\u34BB","\u{2F8D4}":"\u6700","\u2F0D":"\u5196","\u{2F817}":"\u5197","\u{2F818}":"\u51A4","\u2F0E":"\u51AB","\u{2F81A}":"\u51AC","\uFA71":"\u51B5","\u{2F81B}":"\u51B5",\uF92E:"\u51B7",\uF979:"\u51C9",\uF955:"\u51CC",\uF954:"\u51DC",\uFA15:"\u51DE","\u2F0F":"\u51E0","\u{2F80D}":"\u{2063A}","\u{2F81D}":"\u51F5","\u2F10":"\u51F5","\u2F11":"\u5200","\u2E89":"\u5202","\u{2F81E}":"\u5203",\uFA00:"\u5207","\u{2F850}":"\u5207",\uF99C:"\u5217",\uF9DD:"\u5229","\u{2F81F}":"\u34DF",\uF9FF:"\u523A","\u{2F820}":"\u523B","\u{2F821}":"\u5246","\u{2F822}":"\u5272","\u{2F823}":"\u5277",\uF9C7:"\u5289","\u{2F9D9}":"\u{20804}",\u30AB:"\u529B",\uF98A:"\u529B","\u2F12":"\u529B",\uF99D:"\u52A3","\u{2F824}":"\u3515","\u{2F992}":"\u52B3","\uFA76":"\u52C7","\u{2F825}":"\u52C7","\uFA33":"\u52C9","\u{2F826}":"\u52C9",\uF952:"\u52D2",\uF92F:"\u52DE","\uFA34":"\u52E4","\u{2F827}":"\u52E4",\uF97F:"\u52F5","\u2F13":"\u52F9","\uFA77":"\u52FA","\u{2F828}":"\u52FA","\u{2F829}":"\u5305","\u{2F82A}":"\u5306","\u{2F9DD}":"\u{208DE}","\u2F14":"\u5315",\uF963:"\u5317","\u{2F82B}":"\u5317","\u2F15":"\u531A","\u2F16":"\u5338",\uF9EB:"\u533F","\u2F17":"\u5341","\u3038":"\u5341","\u303A":"\u5345","\u{2F82C}":"\u5349","\u0FD6":"\u534D","\u0FD5":"\u5350","\uFA35":"\u5351","\u{2F82D}":"\u5351","\u{2F82E}":"\u535A",\u30C8:"\u535C","\u2F18":"\u535C","\u2F19":"\u5369","\u2E8B":"\u353E","\u{2F82F}":"\u5373",\uF91C:"\u5375","\u{2F830}":"\u537D","\u{2F831}":"\u537F","\u{2F832}":"\u537F","\u{2F833}":"\u537F","\u2F1A":"\u5382","\u{2F834}":"\u{20A2C}","\u2F1B":"\u53B6",\uF96B:"\u53C3","\u2F1C":"\u53C8","\u{2F836}":"\u53CA","\u{2F837}":"\u53DF","\u{2F838}":"\u{20B63}",\u30ED:"\u53E3","\u2F1D":"\u53E3",\u56D7:"\u53E3","\u2F1E":"\u53E3",\uF906:"\u53E5","\u{2F839}":"\u53EB","\u{2F83A}":"\u53F1","\u{2F83B}":"\u5406",\uF9DE:"\u540F",\uF9ED:"\u541D","\u{2F83D}":"\u5438",\uF980:"\u5442","\u{2F83E}":"\u5448","\u{2F83F}":"\u5468","\u{2F83C}":"\u549E","\u{2F840}":"\u54A2",\uF99E:"\u54BD",\u439B:"\u3588","\u{2F841}":"\u54F6","\u{2F842}":"\u5510","\u{2F843}":"\u5553",\u555F:"\u5553","\uFA79":"\u5555","\u{2F844}":"\u5563","\u{2F845}":"\u5584","\u{2F846}":"\u5584",\uF90B:"\u5587","\uFA7A":"\u5599","\u{2F847}":"\u5599","\uFA36":"\u559D","\uFA78":"\u559D","\u{2F848}":"\u55AB","\u{2F849}":"\u55B3",\uFA0D:"\u55C0","\u{2F84A}":"\u55C2","\uFA7B":"\u55E2","\uFA37":"\u5606","\u{2F84C}":"\u5606","\u{2F84E}":"\u5651","\u{2F84F}":"\u5674","\uFA38":"\u5668",\uF9A9:"\u56F9","\u{2F84B}":"\u5716","\u{2F84D}":"\u5717","\u2F1F":"\u571F",\u58EB:"\u571F","\u2F20":"\u571F","\u{2F855}":"\u578B","\u{2F852}":"\u57CE",\u39B3:"\u363D","\u{2F853}":"\u57F4","\u{2F854}":"\u580D","\u{2F857}":"\u5831","\u{2F856}":"\u5832","\uFA39":"\u5840",\uFA10:"\u585A","\uFA7C":"\u585A",\uF96C:"\u585E",\u586B:"\u5861",\u58FF:"\u58AB","\u{2F858}":"\u58AC","\uFA7D":"\u58B3",\uF94A:"\u58D8",\uF942:"\u58DF","\u{2F859}":"\u{214E4}","\u{2F851}":"\u58EE","\u{2F85A}":"\u58F2","\u{2F85B}":"\u58F7","\u2F21":"\u5902","\u{2F85C}":"\u5906","\u2F22":"\u590A",\u30BF:"\u5915","\u2F23":"\u5915","\u{2F85D}":"\u591A","\u{2F85E}":"\u5922","\u2F24":"\u5927","\uFA7E":"\u5944",\uF90C:"\u5948",\uF909:"\u5951","\uFA7F":"\u5954","\u{2F85F}":"\u5962",\uF981:"\u5973","\u2F25":"\u5973","\u{2F860}":"\u{216A8}","\u{2F861}":"\u{216EA}","\u{2F865}":"\u59D8","\u{2F862}":"\u59EC","\u{2F863}":"\u5A1B","\u{2F864}":"\u5A27","\uFA80":"\u5A62","\u{2F866}":"\u5A66",\u5B00:"\u5AAF","\u{2F867}":"\u36EE","\u{2F868}":"\u36FC","\u{2F986}":"\u5AB5","\u{2F869}":"\u5B08","\uFA81":"\u5B28","\u{2F86A}":"\u5B3E","\u{2F86B}":"\u5B3E","\u2F26":"\u5B50","\u2F27":"\u5B80",\uFA04:"\u5B85","\u{2F86C}":"\u{219C8}","\u{2F86D}":"\u5BC3","\u{2F86E}":"\u5BD8",\uF95F:"\u5BE7",\uF9AA:"\u5BE7","\u{2F86F}":"\u5BE7",\uF9BC:"\u5BEE","\u{2F870}":"\u5BF3","\u{2F871}":"\u{21B18}","\u2F28":"\u5BF8","\u{2F872}":"\u5BFF","\u{2F873}":"\u5C06","\u2F29":"\u5C0F","\u{2F875}":"\u5C22","\u2E90":"\u5C22","\u2F2A":"\u5C22","\u2E8F":"\u5C23","\u{2F876}":"\u3781","\u2F2B":"\u5C38",\uF9BD:"\u5C3F","\u{2F877}":"\u5C60",\uF94B:"\u5C62","\uFA3B":"\u5C64",\uF9DF:"\u5C65","\uFA3C":"\u5C6E","\u{2F878}":"\u5C6E","\u2F2C":"\u5C6E","\u{2F8F8}":"\u{21D0B}","\u2F2D":"\u5C71","\u{2F879}":"\u5CC0","\u{2F87A}":"\u5C8D","\u{2F87B}":"\u{21DE4}","\u{2F87D}":"\u{21DE6}",\uF9D5:"\u5D19","\u{2F87C}":"\u5D43",\uF921:"\u5D50","\u{2F87F}":"\u5D6B","\u{2F87E}":"\u5D6E","\u{2F880}":"\u5D7C","\u{2F9F4}":"\u5DB2",\uF9AB:"\u5DBA","\u2F2E":"\u5DDB","\u{2F882}":"\u5DE2",\u30A8:"\u5DE5","\u2F2F":"\u5DE5","\u2F30":"\u5DF1","\u2E92":"\u5DF3","\u{2F883}":"\u382F","\u{2F884}":"\u5DFD","\u2F31":"\u5DFE",\u5E32:"\u5E21","\u{2F885}":"\u5E28","\u{2F886}":"\u5E3D","\u{2F887}":"\u5E69","\u{2F888}":"\u3862","\u{2F889}":"\u{22183}","\u2F32":"\u5E72",\uF98E:"\u5E74","\u{2F939}":"\u{2219F}","\u2E93":"\u5E7A","\u2F33":"\u5E7A","\u2F34":"\u5E7F",\uFA01:"\u5EA6","\u{2F88A}":"\u387C","\u{2F88B}":"\u5EB0","\u{2F88C}":"\u5EB3","\u{2F88D}":"\u5EB6",\uF928:"\u5ECA","\u{2F88E}":"\u5ECA",\uF9A2:"\u5EC9","\uFA82":"\u5ED2",\uFA0B:"\u5ED3","\uFA83":"\u5ED9",\uF982:"\u5EEC","\u2F35":"\u5EF4","\u{2F890}":"\u5EFE","\u2F36":"\u5EFE","\u{2F891}":"\u{22331}","\u{2F892}":"\u{22331}",\uF943:"\u5F04","\u2F37":"\u5F0B","\u2F38":"\u5F13","\u{2F894}":"\u5F22","\u{2F895}":"\u5F22","\u2F39":"\u5F50","\u2E94":"\u5F51","\u{2F874}":"\u5F53","\u{2F896}":"\u38C7","\u2F3A":"\u5F61","\u{2F899}":"\u5F62","\uFA84":"\u5F69","\u{2F89A}":"\u5F6B","\u2F3B":"\u5F73",\uF9D8:"\u5F8B","\u{2F89B}":"\u38E3","\u{2F89C}":"\u5F9A",\uF966:"\u5FA9","\uFA85":"\u5FAD","\u2F3C":"\u5FC3","\u2E96":"\u5FC4","\u2E97":"\u38FA","\u{2F89D}":"\u5FCD","\u{2F89E}":"\u5FD7",\uF9A3:"\u5FF5","\u{2F89F}":"\u5FF9",\uF960:"\u6012",\uF9AC:"\u601C","\uFA6B":"\u6075","\u{2F8A2}":"\u391C","\u{2F8A1}":"\u393A","\u{2F8A0}":"\u6081","\uFA3D":"\u6094","\u{2F8A3}":"\u6094","\u{2F8A5}":"\u60C7","\uFA86":"\u60D8",\uF9B9:"\u60E1","\u{2F8A4}":"\u{226D4}","\uFA88":"\u6108","\uFA3E":"\u6168",\uF9D9:"\u6144","\u{2F8A6}":"\u6148","\u{2F8A7}":"\u614C","\u{2F8A9}":"\u614C","\uFA87":"\u614E","\u{2F8A8}":"\u614E","\uFA8A":"\u6160","\u{2F8AA}":"\u617A","\uFA3F":"\u618E","\uFA89":"\u618E","\u{2F8AB}":"\u618E",\uF98F:"\u6190","\u{2F8AD}":"\u61A4","\u{2F8AE}":"\u61AF","\u{2F8AC}":"\u61B2","\uFAD0":"\u{22844}","\uFACF":"\u{2284A}","\u{2F8AF}":"\u61DE","\uFA40":"\u61F2","\uFA8B":"\u61F2","\u{2F8B0}":"\u61F2",\uF90D:"\u61F6","\u{2F8B1}":"\u61F6",\uF990:"\u6200","\u2F3D":"\u6208","\u{2F8B2}":"\u6210","\u{2F8B3}":"\u621B",\uF9D2:"\u622E","\uFA8C":"\u6234","\u2F3E":"\u6236",\u6238:"\u6236","\u2F3F":"\u624B","\u2E98":"\u624C","\u{2F8B4}":"\u625D","\u{2F8B5}":"\u62B1",\uF925:"\u62C9",\uF95B:"\u62CF",\uFA02:"\u62D3","\u{2F8B6}":"\u62D4","\u{2F8BA}":"\u62FC",\uF973:"\u62FE","\u{2F8B8}":"\u{22B0C}","\u{2F8B9}":"\u633D","\u{2F8B7}":"\u6350","\u{2F8BB}":"\u6368",\uF9A4:"\u637B","\u{2F8BC}":"\u6383",\uF975:"\u63A0","\u{2F8C1}":"\u63A9","\uFA8D":"\u63C4","\u{2F8BD}":"\u63E4","\uFA8F":"\u6452","\u{2F8BE}":"\u{22BF1}","\uFA8E":"\u641C","\u{2F8BF}":"\u6422","\u{2F8C0}":"\u63C5","\u{2F8C3}":"\u6469","\u{2F8C6}":"\u6477","\u{2F8C4}":"\u647E","\u{2F8C2}":"\u3A2E",\u6409:"\u3A41",\uF991:"\u649A","\u{2F8C5}":"\u649D",\uF930:"\u64C4","\u{2F8C7}":"\u3A6C","\u2F40":"\u652F","\u2F41":"\u6534","\u2E99":"\u6535","\uFA41":"\u654F","\u{2F8C8}":"\u654F","\uFA90":"\u6556","\u{2F8C9}":"\u656C",\uF969:"\u6578","\u{2F8CA}":"\u{2300A}","\u2F42":"\u6587","\u2EEB":"\u6589","\u2F43":"\u6597",\uF9BE:"\u6599","\u2F44":"\u65A4","\u2F45":"\u65B9",\uF983:"\u65C5","\u2F46":"\u65E0","\u2E9B":"\u65E1","\uFA42":"\u65E2","\u{2F8CB}":"\u65E3","\u2F47":"\u65E5",\uF9E0:"\u6613",\u66F6:"\u3ADA","\u{2F8D1}":"\u3AE4","\u{2F8CD}":"\u6649",\u6669:"\u665A",\uFA12:"\u6674","\uFA91":"\u6674","\uFA43":"\u6691","\u{2F8CF}":"\u6691",\uF9C5:"\u6688","\u{2F8D0}":"\u3B08","\u{2F8D5}":"\u669C",\uFA06:"\u66B4",\uF98B:"\u66C6","\u{2F8CE}":"\u3B19","\u{2F897}":"\u{232B8}","\u2F48":"\u66F0",\uF901:"\u66F4","\u{2F8CC}":"\u66F8","\u2F49":"\u6708","\u{2F980}":"\u{2335F}",\u80A6:"\u670C",\u80D0:"\u670F",\u80CA:"\u6710",\u8101:"\u6713",\u80F6:"\u3B35",\uF929:"\u6717","\uFA92":"\u6717","\u{2F8D8}":"\u6717",\u8127:"\u6718","\uFA93":"\u671B","\u{2F8D9}":"\u671B",\u5E50:"\u3B3A",\u4420:"\u3B3B","\u{2F989}":"\u{23393}",\u81A7:"\u6723","\u{2F98A}":"\u{2339C}","\u2F4A":"\u6728",\uF9E1:"\u674E","\u{2F8DC}":"\u6753","\uFA94":"\u6756","\u{2F8DB}":"\u675E","\u{2F8DD}":"\u{233C3}",\u67FF:"\u676E",\uF9C8:"\u677B","\u{2F8E0}":"\u6785",\uF9F4:"\u6797","\u{2F8DE}":"\u3B49","\uFAD1":"\u{233D5}",\uF9C9:"\u67F3","\u{2F8DF}":"\u67FA",\uF9DA:"\u6817","\u{2F8E5}":"\u681F","\u{2F8E1}":"\u6852","\u{2F8E3}":"\u{2346D}",\uF97A:"\u6881","\uFA44":"\u6885","\u{2F8E2}":"\u6885","\u{2F8E4}":"\u688E",\uF9E2:"\u68A8","\u{2F8E6}":"\u6914","\u{2F8E8}":"\u6942","\uFAD2":"\u3B9D","\u{2F8E7}":"\u3B9D",\u69E9:"\u3BA3",\u6A27:"\u699D","\u{2F8E9}":"\u69A3","\u{2F8EA}":"\u69EA",\uF914:"\u6A02",\uF95C:"\u6A02",\uF9BF:"\u6A02",\uF94C:"\u6A13","\u{2F8EC}":"\u{236A3}","\u{2F8EB}":"\u6AA8",\uF931:"\u6AD3","\u{2F8ED}":"\u6ADB",\uF91D:"\u6B04","\u{2F8EE}":"\u3C18","\u2F4B":"\u6B20","\u{2F8EF}":"\u6B21","\u{2F8F0}":"\u{238A7}","\u{2F8F1}":"\u6B54","\u{2F8F2}":"\u3C4E","\u2F4C":"\u6B62","\u2EED":"\u6B6F","\u{2F8F3}":"\u6B72",\uF98C:"\u6B77","\uFA95":"\u6B79","\u2F4D":"\u6B79","\u2E9E":"\u6B7A","\u{2F8F4}":"\u6B9F",\uF9A5:"\u6BAE","\u2F4E":"\u6BB3",\uF970:"\u6BBA","\uFA96":"\u6BBA","\u{2F8F5}":"\u6BBA","\u{2F8F6}":"\u6BBB","\u{2F8F7}":"\u{23A8D}","\u2F4F":"\u6BCB","\u2E9F":"\u6BCD","\u{2F8F9}":"\u{23AFA}","\u2F50":"\u6BD4","\u2F51":"\u6BDB","\u2F52":"\u6C0F","\u2EA0":"\u6C11","\u2F53":"\u6C14","\u2F54":"\u6C34","\u2EA1":"\u6C35","\u2EA2":"\u6C3A","\u{2F8FA}":"\u6C4E","\u{2F8FE}":"\u6C67",\uF972:"\u6C88","\u{2F8FC}":"\u6CBF",\uF968:"\u6CCC","\u{2F8FD}":"\u6CCD",\uF9E3:"\u6CE5","\u{2F8FB}":"\u{23CBC}",\uF915:"\u6D1B",\uFA05:"\u6D1E","\u{2F907}":"\u6D34","\u{2F900}":"\u6D3E",\uF9CA:"\u6D41","\uFA97":"\u6D41","\u{2F902}":"\u6D41","\u{2F8FF}":"\u6D16","\u{2F903}":"\u6D69",\uF92A:"\u6D6A","\uFA45":"\u6D77","\u{2F901}":"\u6D77","\u{2F904}":"\u6D78","\u{2F905}":"\u6D85","\u{2F906}":"\u{23D1E}",\uF9F5:"\u6DCB",\uF94D:"\u6DDA",\uF9D6:"\u6DEA","\u{2F90E}":"\u6DF9","\uFA46":"\u6E1A","\u{2F908}":"\u6E2F","\u{2F909}":"\u6E6E",\u6F59:"\u6E88","\uFA99":"\u6ECB","\u{2F90B}":"\u6ECB",\uF9CB:"\u6E9C",\uF9EC:"\u6EBA","\u{2F90C}":"\u6EC7",\uF904:"\u6ED1","\uFA98":"\u6EDB","\u{2F90A}":"\u3D33",\uF94E:"\u6F0F","\uFA47":"\u6F22","\uFA9A":"\u6F22",\uF992:"\u6F23","\u{2F90D}":"\u{23ED1}","\u{2F90F}":"\u6F6E","\u{2F910}":"\u{23F5E}","\u{2F911}":"\u{23F8E}","\u{2F912}":"\u6FC6",\uF922:"\u6FEB",\uF984:"\u6FFE","\u{2F915}":"\u701B","\uFA9B":"\u701E","\u{2F914}":"\u701E","\u{2F913}":"\u7039","\u{2F917}":"\u704A","\u{2F916}":"\u3D96","\u2F55":"\u706B","\u2EA3":"\u706C","\u{2F835}":"\u7070","\u{2F919}":"\u7077","\u{2F918}":"\u707D",\uF9FB:"\u7099","\u{2F91A}":"\u70AD",\uF99F:"\u70C8",\uF916:"\u70D9","\uFA48":"\u716E","\uFA9C":"\u716E","\u{2F91D}":"\u{24263}","\u{2F91C}":"\u7145",\uF993:"\u7149","\uFA6C":"\u{242EE}","\u{2F91E}":"\u719C",\uF9C0:"\u71CE",\uF9EE:"\u71D0","\u{2F91F}":"\u{243AB}",\uF932:"\u7210",\uF91E:"\u721B","\u{2F920}":"\u7228","\u2F56":"\u722A","\uFA49":"\u722B","\u2EA4":"\u722B","\uFA9E":"\u7235","\u{2F921}":"\u7235","\u2F57":"\u7236","\u2F58":"\u723B","\u2EA6":"\u4E2C","\u2F59":"\u723F","\u2F5A":"\u7247","\u{2F922}":"\u7250","\u2F5B":"\u7259","\u{2F923}":"\u{24608}","\u2F5C":"\u725B",\uF946:"\u7262","\u{2F924}":"\u7280","\u{2F925}":"\u7295","\u2F5D":"\u72AC","\u2EA8":"\u72AD","\uFA9F":"\u72AF",\uF9FA:"\u72C0","\u{2F926}":"\u{24735}",\uF92B:"\u72FC",\uFA16:"\u732A","\uFAA0":"\u732A","\u{2F927}":"\u{24814}",\uF9A7:"\u7375","\u{2F928}":"\u737A","\u2F5E":"\u7384",\uF961:"\u7387",\uF9DB:"\u7387","\u2F5F":"\u7389","\u{2F929}":"\u738B","\u{2F92A}":"\u3EAC","\u{2F92B}":"\u73A5",\uF9AD:"\u73B2","\u{2F92C}":"\u3EB8","\u{2F92D}":"\u3EB8",\uF917:"\u73DE",\uF9CC:"\u7409",\uF9E4:"\u7406","\uFA4A":"\u7422","\u{2F92E}":"\u7447","\u{2F92F}":"\u745C",\uF9AE:"\u7469","\uFAA1":"\u7471","\u{2F930}":"\u7471","\u{2F931}":"\u7485",\uF994:"\u7489",\uF9EF:"\u7498","\u{2F932}":"\u74CA","\u2F60":"\u74DC","\u2F61":"\u74E6","\u{2F933}":"\u3F1B","\uFAA2":"\u7506","\u2F62":"\u7518","\u2F63":"\u751F","\u{2F934}":"\u7524","\u2F64":"\u7528","\u2F65":"\u7530","\uFAA3":"\u753B","\u{2F936}":"\u753E","\u{2F935}":"\u{24C36}",\uF9CD:"\u7559",\uF976:"\u7565",\uF962:"\u7570","\u{2F938}":"\u7570","\u{2F937}":"\u{24C92}","\u2F66":"\u758B","\u2F67":"\u7592",\uF9E5:"\u75E2","\u{2F93A}":"\u7610","\uFAA5":"\u761F","\uFAA4":"\u761D",\uF9C1:"\u7642",\uF90E:"\u7669","\u2F68":"\u7676","\u2F69":"\u767D","\u{2F93B}":"\u{24FA1}","\u{2F93C}":"\u{24FB8}","\u2F6A":"\u76AE","\u2F6B":"\u76BF","\u{2F93D}":"\u{25044}","\u{2F93E}":"\u3FFC",\uFA17:"\u76CA","\uFAA6":"\u76CA","\uFAA7":"\u76DB",\uF933:"\u76E7","\u{2F93F}":"\u4008","\u2F6C":"\u76EE","\uFAA8":"\u76F4","\u{2F940}":"\u76F4","\u{2F942}":"\u{250F2}","\u{2F941}":"\u{250F3}",\uF96D:"\u7701","\uFAD3":"\u4018","\u{2F943}":"\u{25119}","\u{2F945}":"\u771E","\u{2F946}":"\u771F","\u{2F947}":"\u771F","\u{2F944}":"\u{25133}","\uFAAA":"\u7740","\uFAA9":"\u774A","\u{2F948}":"\u774A","\u9FC3":"\u4039","\uFAD4":"\u4039","\u{2F949}":"\u4039",\u6663:"\u403F","\u{2F94B}":"\u4046","\u{2F94A}":"\u778B","\uFAD5":"\u{25249}","\uFA9D":"\u77A7","\u2F6D":"\u77DB","\u2F6E":"\u77E2","\u2F6F":"\u77F3","\u{2F94C}":"\u4096","\u{2F94D}":"\u{2541D}",\u784F:"\u7814","\u{2F94E}":"\u784E",\uF9CE:"\u786B",\uF93B:"\u788C","\u{2F94F}":"\u788C","\uFA4B":"\u7891",\uF947:"\u78CA","\uFAAB":"\u78CC","\u{2F950}":"\u78CC",\uF964:"\u78FB","\u{2F951}":"\u40E3",\uF985:"\u792A","\u2F70":"\u793A","\u2EAD":"\u793B",\uFA18:"\u793C","\uFA4C":"\u793E","\uFA4E":"\u7948","\uFA4D":"\u7949","\u{2F952}":"\u{25626}","\uFA4F":"\u7950","\uFA50":"\u7956","\u{2F953}":"\u7956","\uFA51":"\u795D",\uFA19:"\u795E",\uFA1A:"\u7965","\uFA61":"\u8996","\uFAB8":"\u8996",\uF93C:"\u797F","\u{2F954}":"\u{2569A}","\uFA52":"\u798D","\uFA53":"\u798E",\uFA1B:"\u798F","\u{2F956}":"\u798F","\u{2F955}":"\u{256C5}",\uF9B6:"\u79AE","\u2F71":"\u79B8","\u2F72":"\u79BE",\uF995:"\u79CA","\u{2F958}":"\u412F","\u{2F957}":"\u79EB",\uF956:"\u7A1C","\u{2F95A}":"\u7A4A","\uFA54":"\u7A40","\u{2F959}":"\u7A40","\u{2F95B}":"\u7A4F","\u2F73":"\u7A74","\uFA55":"\u7A81","\u{2F95C}":"\u{2597C}","\uFAAC":"\u7AB1",\uF9F7:"\u7ACB","\u2F74":"\u7ACB","\u2EEF":"\u7ADC","\u{2F95D}":"\u{25AA7}","\u{2F95E}":"\u{25AA7}","\u{2F95F}":"\u7AEE","\u2F75":"\u7AF9",\uF9F8:"\u7B20","\uFA56":"\u7BC0","\uFAAD":"\u7BC0","\u{2F960}":"\u4202","\u{2F961}":"\u{25BAB}","\u{2F962}":"\u7BC6","\u{2F964}":"\u4227","\u{2F963}":"\u7BC9","\u{2F965}":"\u{25C80}","\uFAD6":"\u{25CD0}",\uF9A6:"\u7C3E",\uF944:"\u7C60","\u2F76":"\u7C73","\uFAAE":"\u7C7B",\uF9F9:"\u7C92",\uFA1D:"\u7CBE","\u{2F966}":"\u7CD2",\uFA03:"\u7CD6","\u{2F968}":"\u7CE8","\u{2F967}":"\u42A0","\u{2F969}":"\u7CE3",\uF97B:"\u7CE7","\u2F77":"\u7CF8","\u2EAF":"\u7CF9","\u{2F96B}":"\u{25F86}","\u{2F96A}":"\u7D00",\uF9CF:"\u7D10",\uF96A:"\u7D22",\uF94F:"\u7D2F",\u7D76:"\u7D55","\u{2F96C}":"\u7D63","\uFAAF":"\u7D5B",\uF93D:"\u7DA0",\uF957:"\u7DBE","\u{2F96E}":"\u7DC7",\uF996:"\u7DF4","\uFA57":"\u7DF4","\uFAB0":"\u7DF4","\u{2F96F}":"\u7E02","\u{2F96D}":"\u4301","\uFA58":"\u7E09",\uF950:"\u7E37","\uFA59":"\u7E41","\u{2F970}":"\u7E45","\u{2F898}":"\u{261DA}","\u{2F971}":"\u4334","\u2F78":"\u7F36","\u{2F972}":"\u{26228}","\uFAB1":"\u7F3E","\u{2F973}":"\u{26247}","\u2F79":"\u7F51","\u2EAB":"\u7F52","\u2EB2":"\u7F52","\u2EB1":"\u7F53","\u{2F974}":"\u4359","\uFA5A":"\u7F72","\u{2F975}":"\u{262D9}",\uF9E6:"\u7F79","\u{2F976}":"\u7F7A",\uF90F:"\u7F85","\u{2F977}":"\u{2633E}","\u2F7A":"\u7F8A","\u{2F978}":"\u7F95",\uF9AF:"\u7F9A",\uFA1E:"\u7FBD","\u2F7B":"\u7FBD","\u{2F979}":"\u7FFA",\uF934:"\u8001","\u2F7C":"\u8001","\u2EB9":"\u8002","\uFA5B":"\u8005","\uFAB2":"\u8005","\u{2F97A}":"\u8005","\u2F7D":"\u800C","\u{2F97B}":"\u{264DA}","\u2F7E":"\u8012","\u{2F97C}":"\u{26523}","\u2F7F":"\u8033",\uF9B0:"\u8046","\u{2F97D}":"\u8060","\u{2F97E}":"\u{265A8}",\uF997:"\u806F","\u{2F97F}":"\u8070",\uF945:"\u807E","\u2F80":"\u807F","\u2EBA":"\u8080","\u2F81":"\u8089",\uF953:"\u808B","\u{2F8D6}":"\u80AD","\u{2F982}":"\u80B2","\u{2F981}":"\u43D5","\u{2F8D7}":"\u43D9",\u8141:"\u80FC","\u{2F983}":"\u8103","\u{2F985}":"\u813E","\u{2F984}":"\u440B","\u{2F8DA}":"\u6721","\u{2F987}":"\u{267A7}","\u{2F988}":"\u{267B5}",\u6726:"\u4443",\uF926:"\u81D8","\u2F82":"\u81E3",\uF9F6:"\u81E8","\u2F83":"\u81EA","\uFA5C":"\u81ED","\u2F84":"\u81F3","\u2F85":"\u81FC","\u{2F893}":"\u8201","\u{2F98B}":"\u8201","\u{2F98C}":"\u8204","\u2F86":"\u820C","\uFA6D":"\u8218","\u2F87":"\u821B","\u2F88":"\u821F","\u{2F98E}":"\u446B","\u2F89":"\u826E",\uF97C:"\u826F","\u2F8A":"\u8272","\u2F8B":"\u8278","\uFA5D":"\u8279","\uFA5E":"\u8279","\u2EBE":"\u8279","\u2EBF":"\u8279","\u2EC0":"\u8279","\u{2F990}":"\u828B","\u{2F98F}":"\u8291","\u{2F991}":"\u829D","\u{2F993}":"\u82B1","\u{2F994}":"\u82B3","\u{2F995}":"\u82BD",\uF974:"\u82E5","\u{2F998}":"\u82E5","\u{2F996}":"\u82E6","\u{2F997}":"\u{26B3C}",\uF9FE:"\u8336","\uFAB3":"\u8352","\u{2F99A}":"\u8363","\u{2F999}":"\u831D","\u{2F99C}":"\u8323","\u{2F99D}":"\u83BD","\u{2F9A0}":"\u8353",\uF93E:"\u83C9","\u{2F9A1}":"\u83CA","\u{2F9A2}":"\u83CC","\u{2F9A3}":"\u83DC","\u{2F99E}":"\u83E7","\uFAB4":"\u83EF",\uF958:"\u83F1","\uFA5F":"\u8457","\u{2F99F}":"\u8457","\u{2F9A4}":"\u{26C36}","\u{2F99B}":"\u83AD",\uF918:"\u843D",\uF96E:"\u8449",\u853F:"\u848D","\u{2F9A6}":"\u{26CD5}","\u{2F9A5}":"\u{26D6B}",\uF999:"\u84EE","\u{2F9A8}":"\u84F1","\u{2F9A9}":"\u84F3",\uF9C2:"\u84FC","\u{2F9AA}":"\u8516","\u{2F9A7}":"\u452B","\u{2F9AC}":"\u8564","\u{2F9AD}":"\u{26F2C}",\uF923:"\u85CD","\u{2F9AE}":"\u455D","\u{2F9B0}":"\u{26FB1}","\u{2F9AF}":"\u4561",\uF9F0:"\u85FA",\uF935:"\u8606","\u{2F9B2}":"\u456B",\uFA20:"\u8612",\uF91F:"\u862D","\u{2F9B1}":"\u{270D2}",\u8641:"\u8637",\uF910:"\u863F","\u2F8C":"\u864D","\u2EC1":"\u864E","\u{2F9B3}":"\u8650",\uF936:"\u865C","\u{2F9B4}":"\u865C","\u{2F9B5}":"\u8667","\u{2F9B6}":"\u8669","\u2F8D":"\u866B","\u{2F9B7}":"\u86A9","\u{2F9B8}":"\u8688","\u{2F9BA}":"\u86E2","\u{2F9B9}":"\u870E","\u{2F9BC}":"\u8728","\u{2F9BD}":"\u876B","\u{2F9C0}":"\u87E1","\uFAB5":"\u8779","\u{2F9BB}":"\u8779","\u{2F9BE}":"\u8786","\u{2F9BF}":"\u45D7","\u{2F9AB}":"\u{273CA}",\uF911:"\u87BA","\u{2F9C1}":"\u8801","\u{2F9C2}":"\u45F9",\uF927:"\u881F","\u2F8E":"\u8840",\uFA08:"\u884C","\u2F8F":"\u884C","\u{2F9C3}":"\u8860","\u{2F9C4}":"\u8863","\u2F90":"\u8863","\u2EC2":"\u8864",\uF9A0:"\u88C2","\u{2F9C5}":"\u{27667}",\uF9E7:"\u88CF","\u{2F9C6}":"\u88D7","\u{2F9C7}":"\u88DE",\uF9E8:"\u88E1",\uF912:"\u88F8","\u{2F9C9}":"\u88FA","\u{2F9C8}":"\u4635","\uFA60":"\u8910","\uFAB6":"\u8941",\uF924:"\u8964","\u2F91":"\u897E","\u2EC4":"\u897F","\u2EC3":"\u8980","\uFAB7":"\u8986",\uFA0A:"\u898B","\u2F92":"\u898B","\u{2F9CB}":"\u{278AE}","\u2EC5":"\u89C1","\u2F93":"\u89D2","\u2F94":"\u8A00","\u{2F9CC}":"\u{27966}",\u8A7D:"\u8A2E",\u8A1E:"\u46B6","\u{2F9CD}":"\u46BE","\u{2F9CE}":"\u46C7","\u{2F9CF}":"\u8AA0",\uF96F:"\u8AAA",\uF9A1:"\u8AAA","\uFAB9":"\u8ABF","\uFABB":"\u8ACB",\uF97D:"\u8AD2",\uF941:"\u8AD6","\uFABE":"\u8AED","\u{2F9D0}":"\u8AED",\uFA22:"\u8AF8","\uFABA":"\u8AF8",\uF95D:"\u8AFE","\uFABD":"\u8AFE","\uFA62":"\u8B01","\uFABC":"\u8B01","\uFA63":"\u8B39","\uFABF":"\u8B39",\uF9FC:"\u8B58",\uF95A:"\u8B80",\u8B8F:"\u8B86","\uFAC0":"\u8B8A","\u{2F9D1}":"\u8B8A","\u2EC8":"\u8BA0","\u2F95":"\u8C37","\u2F96":"\u8C46",\uF900:"\u8C48","\u{2F9D2}":"\u8C55","\u2F97":"\u8C55",\u8C63:"\u8C5C","\u2F98":"\u8C78","\u{2F9D3}":"\u{27CA8}","\u2F99":"\u8C9D","\u{2F9D4}":"\u8CAB","\u{2F9D5}":"\u8CC1",\uF948:"\u8CC2",\uF903:"\u8CC8","\uFA64":"\u8CD3","\uFA65":"\u8D08","\uFAC1":"\u8D08","\u{2F9D6}":"\u8D1B","\u2EC9":"\u8D1D","\u2F9A":"\u8D64","\u2F9B":"\u8D70","\u{2F9D7}":"\u8D77",\u8D86:"\u8D7F","\uFAD7":"\u{27ED3}","\u{2F9D8}":"\u{27F2F}","\u2F9C":"\u8DB3","\u{2F9DA}":"\u8DCB","\u{2F9DB}":"\u8DBC",\u8DFA:"\u8DE5",\uF937:"\u8DEF","\u{2F9DC}":"\u8DF0",\u8E9B:"\u8E97","\u2F9D":"\u8EAB",\uF902:"\u8ECA","\u2F9E":"\u8ECA","\u{2F9DE}":"\u8ED4",\u8F27:"\u8EFF",\uF998:"\u8F26",\uF9D7:"\u8F2A","\uFAC2":"\u8F38","\u{2F9DF}":"\u8F38",\uFA07:"\u8F3B",\uF98D:"\u8F62","\u2ECB":"\u8F66","\u2F9F":"\u8F9B","\u{2F98D}":"\u8F9E",\uF971:"\u8FB0","\u2FA0":"\u8FB0","\u2FA1":"\u8FB5","\uFA66":"\u8FB6","\u2ECC":"\u8FB6","\u2ECD":"\u8FB6","\u{2F881}":"\u5DE1",\uF99A:"\u9023",\uFA25:"\u9038","\uFA67":"\u9038","\uFAC3":"\u9072",\uF9C3:"\u907C","\u{2F9E0}":"\u{285D2}","\u{2F9E1}":"\u{285ED}",\uF913:"\u908F","\u2FA2":"\u9091","\u{2F9E2}":"\u9094",\uF92C:"\u90CE",\u90DE:"\u90CE","\uFA2E":"\u90CE","\u{2F9E3}":"\u90F1",\uFA26:"\u90FD","\u{2F9E5}":"\u{2872E}","\u{2F9E4}":"\u9111","\u{2F9E6}":"\u911B","\u2FA3":"\u9149",\uF919:"\u916A","\uFAC4":"\u9199",\uF9B7:"\u91B4","\u2FA4":"\u91C6",\uF9E9:"\u91CC","\u2FA5":"\u91CC",\uF97E:"\u91CF",\uF90A:"\u91D1","\u2FA6":"\u91D1",\uF9B1:"\u9234","\u{2F9E7}":"\u9238","\uFAC5":"\u9276","\u{2F9E8}":"\u92D7","\u{2F9E9}":"\u92D8","\u{2F9EA}":"\u927C",\uF93F:"\u9304",\uF99B:"\u934A",\u93AE:"\u93AD","\u{2F9EB}":"\u93F9","\u{2F9EC}":"\u9415","\u{2F9ED}":"\u{28BFA}","\u2ED0":"\u9485","\u2ED1":"\u9577","\u2FA7":"\u9577","\u2ED2":"\u9578","\u2ED3":"\u957F","\u2FA8":"\u9580","\u{2F9EE}":"\u958B","\u{2F9EF}":"\u4995",\uF986:"\u95AD","\u{2F9F0}":"\u95B7","\u{2F9F1}":"\u{28D77}","\u2ED4":"\u95E8","\u2FA9":"\u961C","\u2ECF":"\u961D","\u2ED6":"\u961D",\uF9C6:"\u962E",\uF951:"\u964B",\uFA09:"\u964D",\uF959:"\u9675",\uF9D3:"\u9678","\uFAC6":"\u967C",\uF9DC:"\u9686",\uF9F1:"\u96A3","\u{2F9F2}":"\u49E6","\u2FAA":"\u96B6","\uFA2F":"\u96B7",\u96B8:"\u96B7",\uF9B8:"\u96B7","\u2FAB":"\u96B9","\u{2F9F3}":"\u96C3",\uF9EA:"\u96E2","\uFA68":"\u96E3","\uFAC7":"\u96E3","\u2FAC":"\u96E8",\uF9B2:"\u96F6",\uF949:"\u96F7","\u{2F9F5}":"\u9723","\u{2F9F6}":"\u{29145}",\uF938:"\u9732",\uF9B3:"\u9748","\u2FAD":"\u9751","\u2ED8":"\u9752",\uFA1C:"\u9756","\uFAC8":"\u9756","\u{2F81C}":"\u{291DF}","\u2FAE":"\u975E","\u2FAF":"\u9762","\u{2F9F7}":"\u{2921A}","\u2FB0":"\u9769","\u{2F9F8}":"\u4A6E","\u{2F9F9}":"\u4A76","\u2FB1":"\u97CB","\uFAC9":"\u97DB","\u{2F9FA}":"\u97E0","\u2ED9":"\u97E6","\u2FB2":"\u97ED","\u{2F9FB}":"\u{2940A}","\u2FB3":"\u97F3","\uFA69":"\u97FF","\uFACA":"\u97FF","\u2FB4":"\u9801","\u{2F9FC}":"\u4AB2","\uFACB":"\u980B","\u{2F9FE}":"\u980B","\u{2F9FF}":"\u980B",\uF9B4:"\u9818","\u{2FA00}":"\u9829","\u{2F9FD}":"\u{29496}","\uFA6A":"\u983B","\uFACC":"\u983B",\uF9D0:"\u985E","\u2EDA":"\u9875","\u2FB5":"\u98A8","\u{2FA01}":"\u{295B6}","\u2EDB":"\u98CE","\u2FB6":"\u98DB","\u2EDC":"\u98DE","\u2EDD":"\u98DF","\u2FB7":"\u98DF","\u2EDF":"\u98E0","\u{2FA02}":"\u98E2",\uFA2A:"\u98EF",\uFA2B:"\u98FC","\u{2FA03}":"\u4B33",\uFA2C:"\u9928","\u{2FA04}":"\u9929","\u2EE0":"\u9963","\u2FB8":"\u9996","\u2FB9":"\u9999","\u{2FA05}":"\u99A7","\u2FBA":"\u99AC","\u{2FA06}":"\u99C2",\uF91A:"\u99F1","\u{2FA07}":"\u99FE",\uF987:"\u9A6A","\u2EE2":"\u9A6C","\u2FBB":"\u9AA8","\u{2FA08}":"\u4BCE","\u2FBC":"\u9AD8","\u2FBD":"\u9ADF","\u{2FA09}":"\u{29B30}","\uFACD":"\u9B12","\u{2FA0A}":"\u9B12","\u2FBE":"\u9B25","\u2FBF":"\u9B2F","\u2FC0":"\u9B32","\u2FC1":"\u9B3C","\u2EE4":"\u9B3C","\u2FC2":"\u9B5A",\uF939:"\u9B6F","\u{2FA0B}":"\u9C40",\uF9F2:"\u9C57","\u2EE5":"\u9C7C","\u2FC3":"\u9CE5","\u{2FA0C}":"\u9CFD","\u{2FA0D}":"\u4CCE","\u{2FA0F}":"\u9D67","\u{2FA0E}":"\u4CED","\u{2FA10}":"\u{2A0CE}",\uFA2D:"\u9DB4","\u{2FA12}":"\u{2A105}","\u{2FA11}":"\u4CF8",\uF93A:"\u9DFA","\u{2FA13}":"\u{2A20E}",\uF920:"\u9E1E",\u9E43:"\u9E42","\u2FC4":"\u9E75",\uF940:"\u9E7F","\u2FC5":"\u9E7F","\u{2FA14}":"\u{2A291}",\uF988:"\u9E97",\uF9F3:"\u9E9F","\u2FC6":"\u9EA5","\u2EE8":"\u9EA6","\u{2FA15}":"\u9EBB","\u2FC7":"\u9EBB","\u{2F88F}":"\u{2A392}","\u2FC8":"\u9EC3","\u2EE9":"\u9EC4","\u2FC9":"\u9ECD",\uF989:"\u9ECE","\u{2FA16}":"\u4D56","\u2FCA":"\u9ED1",\u9ED2:"\u9ED1","\uFA3A":"\u58A8","\u{2FA17}":"\u9EF9","\u2FCB":"\u9EF9","\u2FCC":"\u9EFD","\u{2FA19}":"\u9F05","\u{2FA18}":"\u9EFE","\u2FCD":"\u9F0E","\u{2FA1A}":"\u9F0F","\u2FCE":"\u9F13","\u{2FA1B}":"\u9F16","\u2FCF":"\u9F20","\u{2FA1C}":"\u9F3B","\u2FD0":"\u9F3B","\uFAD8":"\u9F43","\u2FD1":"\u9F4A","\u2EEC":"\u9F50","\u2FD2":"\u9F52","\u{2FA1D}":"\u{2A600}","\u2EEE":"\u9F7F",\uF9C4:"\u9F8D","\u2FD3":"\u9F8D","\uFAD9":"\u9F8E","\u2EF0":"\u9F99",\uF907:"\u9F9C",\uF908:"\u9F9C","\uFACE":"\u9F9C","\u2FD4":"\u9F9C","\u2EF3":"\u9F9F","\u2FD5":"\u9FA0"},Uy=Eb;function Sb(n){return n.replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")}var bb=RegExp(Object.keys(Uy).map(Sb).join("|"),"g");function wb(n){return Uy[n]}function Rb(n){return n.replace(bb,wb)}var Ib=Rb,Wa={exports:{}},$y={};function Lr(n,e){typeof e=="boolean"&&(e={forever:e}),this._originalTimeouts=JSON.parse(JSON.stringify(n)),this._timeouts=n,this._options=e||{},this._maxRetryTime=e&&e.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}var Tb=Lr;Lr.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};Lr.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};Lr.prototype.retry=function(n){if(this._timeout&&clearTimeout(this._timeout),!n)return!1;var e=new Date().getTime();if(n&&e-this._operationStart>=this._maxRetryTime)return this._errors.push(n),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(n);var t=this._timeouts.shift();if(t===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),t=this._cachedTimeouts.slice(-1);else return!1;var r=this;return this._timer=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},t),this._options.unref&&this._timer.unref(),!0};Lr.prototype.attempt=function(n,e){this._fn=n,e&&(e.timeout&&(this._operationTimeout=e.timeout),e.cb&&(this._operationTimeoutCb=e.cb));var t=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){t._operationTimeoutCb()},t._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};Lr.prototype.try=function(n){console.log("Using RetryOperation.try() is deprecated"),this.attempt(n)};Lr.prototype.start=function(n){console.log("Using RetryOperation.start() is deprecated"),this.attempt(n)};Lr.prototype.start=Lr.prototype.try;Lr.prototype.errors=function(){return this._errors};Lr.prototype.attempts=function(){return this._attempts};Lr.prototype.mainError=function(){if(this._errors.length===0)return null;for(var n={},e=null,t=0,r=0;r<this._errors.length;r++){var i=this._errors[r],s=i.message,o=(n[s]||0)+1;n[s]=o,o>=t&&(e=i,t=o)}return e};(function(n){var e=Tb;n.operation=function(t){var r=n.timeouts(t);return new e(r,{forever:t&&(t.forever||t.retries===1/0),unref:t&&t.unref,maxRetryTime:t&&t.maxRetryTime})},n.timeouts=function(t){if(t instanceof Array)return[].concat(t);var r={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var i in t)r[i]=t[i];if(r.minTimeout>r.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var s=[],o=0;o<r.retries;o++)s.push(this.createTimeout(o,r));return t&&t.forever&&!s.length&&s.push(this.createTimeout(o,r)),s.sort(function(c,l){return c-l}),s},n.createTimeout=function(t,r){var i=r.randomize?Math.random()+1:1,s=Math.round(i*Math.max(r.minTimeout,1)*Math.pow(r.factor,t));return s=Math.min(s,r.maxTimeout),s},n.wrap=function(t,r,i){if(r instanceof Array&&(i=r,r=null),!i){i=[];for(var s in t)typeof t[s]=="function"&&i.push(s)}for(var o=0;o<i.length;o++){var c=i[o],l=t[c];t[c]=function(a){var g=n.operation(r),m=Array.prototype.slice.call(arguments,1),p=m.pop();m.push(function(E){g.retry(E)||(E&&(arguments[0]=g.mainError()),p.apply(this,arguments))}),g.attempt(function(){a.apply(t,m)})}.bind(t,l),t[c].options=r}}})($y);var Ob=$y;const kb=Ob,Cb=["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"];class xy extends Error{constructor(e){super();e instanceof Error?(this.originalError=e,{message:e}=e):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}}const Pb=(n,e,t)=>{const r=t.retries-(e-1);return n.attemptNumber=e,n.retriesLeft=r,n},Mb=n=>Cb.includes(n),Ny=(n,e)=>new Promise((t,r)=>{e=uc({onFailedAttempt:()=>{},retries:10},e);const i=kb.operation(e);i.attempt(async s=>{try{t(await n(s))}catch(o){if(!(o instanceof Error)){r(new TypeError(`Non-error was thrown: "${o}". You should only throw errors.`));return}if(o instanceof xy)i.stop(),r(o.originalError);else if(o instanceof TypeError&&!Mb(o.message))i.stop(),r(o);else{Pb(o,s,e);try{await e.onFailedAttempt(o)}catch(c){r(c);return}i.retry(o)||r(i.mainError())}}})});Wa.exports=Ny;Wa.exports.default=Ny;Wa.exports.AbortError=xy;var Ly=V.exports;Object.defineProperty(G,"__esModule",{value:!0});G.DEFAULT_ALPHABET=void 0;G.alphabetPad=Td;G.averageBetweenStrings=sw;G.baseToString=So;G.checkObjectHasKeys=Bb;G.checkObjectHasNoAdditionalKeys=Kb;G.chunkPromises=tw;G.compare=lw;G.decodeParams=$b;G.deepCompare=Id;G.deepCopy=Fb;G.deepSortedObjectEntries=By;G.defer=Qb;G.encodeParams=Ub;G.encodeUri=xb;G.ensureNoTrailingSlash=zb;G.escapeRegExp=Fy;G.getCrypto=iw;G.globToRegexp=Yb;G.inherits=qb;G.isFunction=Lb;G.isNullOrUndefined=Xb;G.isNumber=Vb;G.lexicographicCompare=jy;G.nextString=ow;G.normalize=Wb;G.polyfillSuper=jb;G.prevString=aw;G.promiseMapSeries=Zb;G.promiseTry=ew;G.recursivelyAssign=Vy;G.removeDirectionOverrideChars=Gb;G.removeElement=Nb;G.removeHiddenChars=Ky;G.setCrypto=nw;G.simpleRetryOperation=rw;G.sleep=Jb;G.stringToBase=Ua;var Ab=Ly(Ib),Db=Ly(Wa.exports);function Ub(n){const e=new URLSearchParams;for(const[t,r]of Object.entries(n))r!=null&&e.set(t,String(r));return e.toString()}function $b(n){const e={},t=new URLSearchParams(n);for(const r of t.keys()){const i=t.getAll(r);e[r]=i.length===1?i[0]:i}return e}function xb(n,e){for(const t in e)!e.hasOwnProperty(t)||(n=n.replace(t,encodeURIComponent(e[t])));return n}function Nb(n,e,t){let r;if(t){for(r=n.length-1;r>=0;r--)if(e(n[r],r,n))return n.splice(r,1),!0}else for(r=0;r<n.length;r++)if(e(n[r],r,n))return n.splice(r,1),!0;return!1}function Lb(n){return Object.prototype.toString.call(n)==="[object Function]"}function Bb(n,e){for(let t=0;t<e.length;t++)if(!n.hasOwnProperty(e[t]))throw new Error("Missing required key: "+e[t])}function Kb(n,e){for(const t in n)if(!!n.hasOwnProperty(t)&&e.indexOf(t)===-1)throw new Error("Unknown key: "+t)}function Fb(n){return JSON.parse(JSON.stringify(n))}function Id(n,e){if(n===e)return!0;if(typeof n!=typeof e)return!1;if(typeof n=="number"&&isNaN(n)&&isNaN(e))return!0;if(n===null||e===null)return n===e;if(!(n instanceof Object)||n.constructor!==e.constructor||n.prototype!==e.prototype)return!1;if(n instanceof RegExp||n instanceof Date)return n.toString()===e.toString();if(n instanceof Array){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(!Id(n[t],e[t]))return!1}else{let t;for(t in e)if(e.hasOwnProperty(t)!==n.hasOwnProperty(t))return!1;for(t in e)if(e.hasOwnProperty(t)!==n.hasOwnProperty(t)||!Id(n[t],e[t]))return!1}return!0}function By(n){if(typeof n!="object"||n==null||Array.isArray(n))return n;const e=[];for(const[t,r]of Object.entries(n))e.push([t,By(r)]);return e.sort((t,r)=>jy(t[0],r[0])),e}function qb(n,e){n.super_=e,n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}})}function jb(n,e,...t){try{e.call(n,...t)}catch{const i=new e(...t);Object.assign(n,i)}}function Vb(n){return typeof n=="number"&&isFinite(n)}function Ky(n){return typeof n=="string"?(0,Ab.default)(n.normalize("NFD").replace(Hb,"")):""}function Gb(n){return typeof n=="string"?n.replace(/[\u202d-\u202e]/g,""):""}function Wb(n){return Ky(n.toLowerCase()).replace(/[\\'!"#$%&()*+,\-./:;<=>?@[\]^_`{|}~\u2000-\u206f\u2e00-\u2e7f]/g,"").toLowerCase()}const Hb=/[\u2000-\u200F\u202A-\u202F\u0300-\u036F\uFEFF\u061C\s]/g;function Fy(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Yb(n,e){e=typeof e=="boolean"?e:!0;let t=Fy(n);return t=t.replace(/\\\*/g,".*"),t=t.replace(/\?/g,"."),e&&(t=t.replace(/\\\[(!|)(.*)\\]/g,function(r,i,s,o,c){const l=i&&"^"||"",u=s.replace(/\\-/,"-");return"["+l+u+"]"})),t}function zb(n){return n&&n.endsWith("/")?n.substr(0,n.length-1):n}function Jb(n,e){return new Promise(t=>{setTimeout(t,n,e)})}function Xb(n){return n==null}function Qb(){let n,e;const t=new Promise((r,i)=>{n=r,e=i});return{resolve:n,reject:e,promise:t}}async function Zb(n,e){for(const t of n)await e(await t)}function ew(n){return new Promise(e=>e(n()))}async function tw(n,e){const t=[];for(let r=0;r<n.length;r+=e)t.push(...await Promise.all(n.slice(r,r+e).map(i=>i())));return t}function rw(n){return(0,Db.default)(e=>n(e),{forever:!0,factor:2,minTimeout:3e3,maxTimeout:15e3})}let qy;function nw(n){qy=n}function iw(){return qy}const Ts=(()=>{let n="";for(let e=32;e<=126;e++)n+=String.fromCharCode(e);return n})();G.DEFAULT_ALPHABET=Ts;function Td(n,e,t=Ts){return n.padEnd(e,t[0])}function So(n,e=Ts){const t=BigInt(e.length);if(n<=t){var r;return(r=e[Number(n)-1])!==null&&r!==void 0?r:""}let i=n/t,s=Number(n%t)-1;return s<0&&(i-=BigInt(Math.abs(s)),s=Number(t)-1),So(i,e)+e[s]}function Ua(n,e=Ts){const t=BigInt(e.length);let r=BigInt(0);for(let i=n.length-1,s=BigInt(0);i>=0;i--,s++){const o=n.charCodeAt(i)-e.charCodeAt(0);r+=BigInt(1+o)*t**s}return r}function sw(n,e,t=Ts){const r=Math.max(n.length,e.length),i=Ua(Td(n,r,t),t),s=Ua(Td(e,r,t),t),o=(i+s)/BigInt(2);return o===i||o==s?So(o,t)+t[0]:So(o,t)}function ow(n,e=Ts){return So(Ua(n,e)+BigInt(1),e)}function aw(n,e=Ts){return So(Ua(n,e)-BigInt(1),e)}function jy(n,e){return n<e?-1:n===e?0:1}const cw=new Intl.Collator;function lw(n,e){return cw.compare(n,e)}function Vy(n,e,t=!1){for(const[r,i]of Object.entries(e)){if(n[r]instanceof Object&&i){Vy(n[r],i);continue}if(i!=null||!t){n[r]=i;continue}}return n}var uw=V.exports;Object.defineProperty(Po,"__esModule",{value:!0});Po.MemoryCryptoStore=void 0;var Xt=uw(Y.exports),pc=ie,ap=dw(G);function Gy(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(Gy=function(r){return r?t:e})(n)}function dw(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=Gy(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}function cp(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function lp(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?cp(Object(t),!0).forEach(function(r){(0,Xt.default)(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):cp(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}class hw{constructor(){(0,Xt.default)(this,"outgoingRoomKeyRequests",[]),(0,Xt.default)(this,"account",null),(0,Xt.default)(this,"crossSigningKeys",null),(0,Xt.default)(this,"privateKeys",{}),(0,Xt.default)(this,"sessions",{}),(0,Xt.default)(this,"sessionProblems",{}),(0,Xt.default)(this,"notifiedErrorDevices",{}),(0,Xt.default)(this,"inboundGroupSessions",{}),(0,Xt.default)(this,"inboundGroupSessionsWithheld",{}),(0,Xt.default)(this,"deviceData",null),(0,Xt.default)(this,"rooms",{}),(0,Xt.default)(this,"sessionsNeedingBackup",{}),(0,Xt.default)(this,"sharedHistoryInboundGroupSessions",{})}async startup(){return this}deleteAllData(){return Promise.resolve()}getOrAddOutgoingRoomKeyRequest(e){const t=e.requestBody;return ap.promiseTry(()=>{const r=this._getOutgoingRoomKeyRequest(t);return r?(pc.logger.log(`already have key request outstanding for ${t.room_id} / ${t.session_id}: not sending another`),r):(pc.logger.log(`enqueueing key request for ${t.room_id} / `+t.session_id),this.outgoingRoomKeyRequests.push(e),e)})}getOutgoingRoomKeyRequest(e){return Promise.resolve(this._getOutgoingRoomKeyRequest(e))}_getOutgoingRoomKeyRequest(e){for(const t of this.outgoingRoomKeyRequests)if(ap.deepCompare(t.requestBody,e))return t;return null}getOutgoingRoomKeyRequestByState(e){for(const t of this.outgoingRoomKeyRequests)for(const r of e)if(t.state===r)return Promise.resolve(t);return Promise.resolve(null)}getAllOutgoingRoomKeyRequestsByState(e){return Promise.resolve(this.outgoingRoomKeyRequests.filter(t=>t.state==e))}getOutgoingRoomKeyRequestsByTarget(e,t,r){const i=[];for(const s of this.outgoingRoomKeyRequests)for(const o of r)s.state===o&&s.recipients.includes({userId:e,deviceId:t})&&i.push(s);return Promise.resolve(i)}updateOutgoingRoomKeyRequest(e,t,r){for(const i of this.outgoingRoomKeyRequests)if(i.requestId===e)return i.state!==t?(pc.logger.warn(`Cannot update room key request from ${t} as it was already updated to ${i.state}`),Promise.resolve(null)):(Object.assign(i,r),Promise.resolve(i));return Promise.resolve(null)}deleteOutgoingRoomKeyRequest(e,t){for(let r=0;r<this.outgoingRoomKeyRequests.length;r++){const i=this.outgoingRoomKeyRequests[r];if(i.requestId===e)return i.state!=t?(pc.logger.warn(`Cannot delete room key request in state ${i.state} (expected ${t})`),Promise.resolve(null)):(this.outgoingRoomKeyRequests.splice(r,1),Promise.resolve(i))}return Promise.resolve(null)}getAccount(e,t){t(this.account)}storeAccount(e,t){this.account=t}getCrossSigningKeys(e,t){t(this.crossSigningKeys)}getSecretStorePrivateKey(e,t,r){const i=this.privateKeys[r];t(i||null)}storeCrossSigningKeys(e,t){this.crossSigningKeys=t}storeSecretStorePrivateKey(e,t,r){this.privateKeys[t]=r}countEndToEndSessions(e,t){t(Object.keys(this.sessions).length)}getEndToEndSession(e,t,r,i){const s=this.sessions[e]||{};i(s[t]||null)}getEndToEndSessions(e,t,r){r(this.sessions[e]||{})}getAllEndToEndSessions(e,t){Object.entries(this.sessions).forEach(([r,i])=>{Object.entries(i).forEach(([s,o])=>{t(lp(lp({},o),{},{deviceKey:r,sessionId:s}))})})}storeEndToEndSession(e,t,r,i){let s=this.sessions[e];s===void 0&&(s={},this.sessions[e]=s),s[t]=r}async storeEndToEndSessionProblem(e,t,r){const i=this.sessionProblems[e]=this.sessionProblems[e]||[];i.push({type:t,fixed:r,time:Date.now()}),i.sort((s,o)=>s.time-o.time)}async getEndToEndSessionProblem(e,t){const r=this.sessionProblems[e]||[];if(!r.length)return null;const i=r[r.length-1];for(const s of r)if(s.time>t)return Object.assign({},s,{fixed:i.fixed});return i.fixed?null:i}async filterOutNotifiedErrorDevices(e){const t=this.notifiedErrorDevices,r=[];for(const i of e){const{userId:s,deviceInfo:o}=i;s in t?o.deviceId in t[s]||(r.push(i),t[s][o.deviceId]=!0):(r.push(i),t[s]={[o.deviceId]:!0})}return r}getEndToEndInboundGroupSession(e,t,r,i){const s=e+"/"+t;i(this.inboundGroupSessions[s]||null,this.inboundGroupSessionsWithheld[s]||null)}getAllEndToEndInboundGroupSessions(e,t){for(const r of Object.keys(this.inboundGroupSessions))t({senderKey:r.substr(0,43),sessionId:r.substr(44),sessionData:this.inboundGroupSessions[r]});t(null)}addEndToEndInboundGroupSession(e,t,r,i){const s=e+"/"+t;this.inboundGroupSessions[s]===void 0&&(this.inboundGroupSessions[s]=r)}storeEndToEndInboundGroupSession(e,t,r,i){this.inboundGroupSessions[e+"/"+t]=r}storeEndToEndInboundGroupSessionWithheld(e,t,r,i){const s=e+"/"+t;this.inboundGroupSessionsWithheld[s]=r}getEndToEndDeviceData(e,t){t(this.deviceData)}storeEndToEndDeviceData(e,t){this.deviceData=e}storeEndToEndRoom(e,t,r){this.rooms[e]=t}getEndToEndRooms(e,t){t(this.rooms)}getSessionsNeedingBackup(e){const t=[];for(const r in this.sessionsNeedingBackup)if(this.inboundGroupSessions[r]&&(t.push({senderKey:r.substr(0,43),sessionId:r.substr(44),sessionData:this.inboundGroupSessions[r]}),e&&r.length>=e))break;return Promise.resolve(t)}countSessionsNeedingBackup(){return Promise.resolve(Object.keys(this.sessionsNeedingBackup).length)}unmarkSessionsNeedingBackup(e){for(const t of e){const r=t.senderKey+"/"+t.sessionId;delete this.sessionsNeedingBackup[r]}return Promise.resolve()}markSessionsNeedingBackup(e){for(const t of e){const r=t.senderKey+"/"+t.sessionId;this.sessionsNeedingBackup[r]=!0}return Promise.resolve()}addSharedHistoryInboundGroupSession(e,t,r){const i=this.sharedHistoryInboundGroupSessions[e]||[];i.push([t,r]),this.sharedHistoryInboundGroupSessions[e]=i}getSharedHistoryInboundGroupSessions(e){return Promise.resolve(this.sharedHistoryInboundGroupSessions[e]||[])}doTxn(e,t,r){return Promise.resolve(r(null))}}Po.MemoryCryptoStore=hw;var Ha={},en={},qe={},kl={exports:{}},lo=typeof Reflect=="object"?Reflect:null,up=lo&&typeof lo.apply=="function"?lo.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)},Wc;lo&&typeof lo.ownKeys=="function"?Wc=lo.ownKeys:Object.getOwnPropertySymbols?Wc=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Wc=function(e){return Object.getOwnPropertyNames(e)};function fw(n){console&&console.warn&&console.warn(n)}var Wy=Number.isNaN||function(e){return e!==e};function Oe(){Oe.init.call(this)}kl.exports=Oe;kl.exports.once=yw;Oe.EventEmitter=Oe;Oe.prototype._events=void 0;Oe.prototype._eventsCount=0;Oe.prototype._maxListeners=void 0;var dp=10;function Cl(n){if(typeof n!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n)}Object.defineProperty(Oe,"defaultMaxListeners",{enumerable:!0,get:function(){return dp},set:function(n){if(typeof n!="number"||n<0||Wy(n))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+n+".");dp=n}});Oe.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Oe.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Wy(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Hy(n){return n._maxListeners===void 0?Oe.defaultMaxListeners:n._maxListeners}Oe.prototype.getMaxListeners=function(){return Hy(this)};Oe.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var i=e==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var c=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw c.context=o,c}var l=s[e];if(l===void 0)return!1;if(typeof l=="function")up(l,this,t);else for(var u=l.length,a=Qy(l,u),r=0;r<u;++r)up(a[r],this,t);return!0};function Yy(n,e,t,r){var i,s,o;if(Cl(t),s=n._events,s===void 0?(s=n._events=Object.create(null),n._eventsCount=0):(s.newListener!==void 0&&(n.emit("newListener",e,t.listener?t.listener:t),s=n._events),o=s[e]),o===void 0)o=s[e]=t,++n._eventsCount;else if(typeof o=="function"?o=s[e]=r?[t,o]:[o,t]:r?o.unshift(t):o.push(t),i=Hy(n),i>0&&o.length>i&&!o.warned){o.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=n,c.type=e,c.count=o.length,fw(c)}return n}Oe.prototype.addListener=function(e,t){return Yy(this,e,t,!1)};Oe.prototype.on=Oe.prototype.addListener;Oe.prototype.prependListener=function(e,t){return Yy(this,e,t,!0)};function pw(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function zy(n,e,t){var r={fired:!1,wrapFn:void 0,target:n,type:e,listener:t},i=pw.bind(r);return i.listener=t,r.wrapFn=i,i}Oe.prototype.once=function(e,t){return Cl(t),this.on(e,zy(this,e,t)),this};Oe.prototype.prependOnceListener=function(e,t){return Cl(t),this.prependListener(e,zy(this,e,t)),this};Oe.prototype.removeListener=function(e,t){var r,i,s,o,c;if(Cl(t),i=this._events,i===void 0)return this;if(r=i[e],r===void 0)return this;if(r===t||r.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||t));else if(typeof r!="function"){for(s=-1,o=r.length-1;o>=0;o--)if(r[o]===t||r[o].listener===t){c=r[o].listener,s=o;break}if(s<0)return this;s===0?r.shift():gw(r,s),r.length===1&&(i[e]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",e,c||t)}return this};Oe.prototype.off=Oe.prototype.removeListener;Oe.prototype.removeAllListeners=function(e){var t,r,i;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[e]),this;if(arguments.length===0){var s=Object.keys(r),o;for(i=0;i<s.length;++i)o=s[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=r[e],typeof t=="function")this.removeListener(e,t);else if(t!==void 0)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this};function Jy(n,e,t){var r=n._events;if(r===void 0)return[];var i=r[e];return i===void 0?[]:typeof i=="function"?t?[i.listener||i]:[i]:t?mw(i):Qy(i,i.length)}Oe.prototype.listeners=function(e){return Jy(this,e,!0)};Oe.prototype.rawListeners=function(e){return Jy(this,e,!1)};Oe.listenerCount=function(n,e){return typeof n.listenerCount=="function"?n.listenerCount(e):Xy.call(n,e)};Oe.prototype.listenerCount=Xy;function Xy(n){var e=this._events;if(e!==void 0){var t=e[n];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}Oe.prototype.eventNames=function(){return this._eventsCount>0?Wc(this._events):[]};function Qy(n,e){for(var t=new Array(e),r=0;r<e;++r)t[r]=n[r];return t}function gw(n,e){for(;e+1<n.length;e++)n[e]=n[e+1];n.pop()}function mw(n){for(var e=new Array(n.length),t=0;t<e.length;++t)e[t]=n[t].listener||n[t];return e}function yw(n,e){return new Promise(function(t,r){function i(o){n.removeListener(e,s),r(o)}function s(){typeof n.removeListener=="function"&&n.removeListener("error",i),t([].slice.call(arguments))}Zy(n,e,s,{once:!0}),e!=="error"&&vw(n,i,{once:!0})})}function vw(n,e,t){typeof n.on=="function"&&Zy(n,"error",e,t)}function Zy(n,e,t,r){if(typeof n.on=="function")r.once?n.once(e,t):n.on(e,t);else if(typeof n.addEventListener=="function")n.addEventListener(e,function i(s){r.once&&n.removeEventListener(e,i),t(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof n)}Object.defineProperty(qe,"__esModule",{value:!0});qe.TypedEventEmitter=qe.EventEmitterEvents=void 0;var _w=kl.exports;let Od;qe.EventEmitterEvents=Od;(function(n){n.NewListener="newListener",n.RemoveListener="removeListener",n.Error="error"})(Od||(qe.EventEmitterEvents=Od={}));class Ew extends _w.EventEmitter{addListener(e,t){return super.addListener(e,t)}emit(e,...t){return super.emit(e,...t)}eventNames(){return super.eventNames()}listenerCount(e){return super.listenerCount(e)}listeners(e){return super.listeners(e)}off(e,t){return super.off(e,t)}on(e,t){return super.on(e,t)}once(e,t){return super.once(e,t)}prependListener(e,t){return super.prependListener(e,t)}prependOnceListener(e,t){return super.prependOnceListener(e,t)}removeAllListeners(e){return super.removeAllListeners(e)}removeListener(e,t){return super.removeListener(e,t)}rawListeners(e){return super.rawListeners(e)}}qe.TypedEventEmitter=Ew;var Sw=V.exports;Object.defineProperty(en,"__esModule",{value:!0});en.UserEvent=en.User=void 0;var Vr=Sw(Y.exports),bw=qe;let Vn;en.UserEvent=Vn;(function(n){n.DisplayName="User.displayName",n.AvatarUrl="User.avatarUrl",n.Presence="User.presence",n.CurrentlyActive="User.currentlyActive",n.LastPresenceTs="User.lastPresenceTs",n._UnstableStatusMessage="User.unstable_statusMessage"})(Vn||(en.UserEvent=Vn={}));class ww extends bw.TypedEventEmitter{constructor(e){super();this.userId=e,(0,Vr.default)(this,"modified",void 0),(0,Vr.default)(this,"displayName",void 0),(0,Vr.default)(this,"rawDisplayName",void 0),(0,Vr.default)(this,"avatarUrl",void 0),(0,Vr.default)(this,"presenceStatusMsg",null),(0,Vr.default)(this,"presence","offline"),(0,Vr.default)(this,"lastActiveAgo",0),(0,Vr.default)(this,"lastPresenceTs",0),(0,Vr.default)(this,"currentlyActive",!1),(0,Vr.default)(this,"events",{presence:null,profile:null}),(0,Vr.default)(this,"unstable_statusMessage",""),this.displayName=e,this.rawDisplayName=e,this.avatarUrl=null,this.updateModifiedTime()}setPresenceEvent(e){if(e.getType()!=="m.presence")return;const t=this.events.presence===null;this.events.presence=e;const r=[];(e.getContent().presence!==this.presence||t)&&r.push(Vn.Presence),e.getContent().avatar_url&&e.getContent().avatar_url!==this.avatarUrl&&r.push(Vn.AvatarUrl),e.getContent().displayname&&e.getContent().displayname!==this.displayName&&r.push(Vn.DisplayName),e.getContent().currently_active!==void 0&&e.getContent().currently_active!==this.currentlyActive&&r.push(Vn.CurrentlyActive),this.presence=e.getContent().presence,r.push(Vn.LastPresenceTs),e.getContent().status_msg&&(this.presenceStatusMsg=e.getContent().status_msg),e.getContent().displayname&&(this.displayName=e.getContent().displayname),e.getContent().avatar_url&&(this.avatarUrl=e.getContent().avatar_url),this.lastActiveAgo=e.getContent().last_active_ago,this.lastPresenceTs=Date.now(),this.currentlyActive=e.getContent().currently_active,this.updateModifiedTime();for(let i=0;i<r.length;i++)this.emit(r[i],e,this)}setDisplayName(e){const t=this.displayName;typeof e=="string"?this.displayName=e:this.displayName=void 0,e!==t&&this.updateModifiedTime()}setRawDisplayName(e){typeof e=="string"?this.rawDisplayName=e:this.rawDisplayName=void 0}setAvatarUrl(e){const t=this.avatarUrl;this.avatarUrl=e,e!==t&&this.updateModifiedTime()}updateModifiedTime(){this.modified=Date.now()}getLastModifiedTime(){return this.modified}getLastActiveTs(){return this.lastPresenceTs-this.lastActiveAgo}unstable_updateStatusMessage(e){e.getContent()?this.unstable_statusMessage=e.getContent().status:this.unstable_statusMessage="",this.updateModifiedTime(),this.emit(Vn._UnstableStatusMessage,this)}}en.User=ww;var Tn={},tn={},Mo={};Object.defineProperty(Mo,"__esModule",{value:!0});Mo.getHttpUriForMxc=Tw;var Rw=Iw(G);function ev(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(ev=function(r){return r?t:e})(n)}function Iw(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=ev(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}function Tw(n,e,t,r,i,s=!1){if(typeof e!="string"||!e)return"";if(e.indexOf("mxc://")!==0)return s?e:"";let o=e.slice(6),c="/_matrix/media/r0/download/";const l={};t&&(l.width=Math.round(t).toString()),r&&(l.height=Math.round(r).toString()),i&&(l.method=i),Object.keys(l).length>0&&(c="/_matrix/media/r0/thumbnail/");const u=o.indexOf("#");let a="";u>=0&&(a=o.substr(u),o=o.substr(0,u));const g=Object.keys(l).length===0?"":"?"+Rw.encodeParams(l);return n+c+o+g+a}var ne={},Sr={},Ow=V.exports;Object.defineProperty(Sr,"__esModule",{value:!0});Sr.UnstableValue=Sr.ServerControlledNamespacedValue=Sr.NamespacedValue=void 0;var kw=Ow(Y.exports);class Zh{constructor(e,t){if(this.stable=e,this.unstable=t,!this.unstable&&!this.stable)throw new Error("One of stable or unstable values must be supplied")}get name(){return this.stable?this.stable:this.unstable}get altName(){return this.stable?this.unstable:null}matches(e){return this.name===e||this.altName===e}findIn(e){let t;return this.name&&(t=e==null?void 0:e[this.name]),!t&&this.altName&&(t=e==null?void 0:e[this.altName]),t}includedIn(e){let t=!1;return this.name&&(t=e.includes(this.name)),!t&&this.altName&&(t=e.includes(this.altName)),t}}Sr.NamespacedValue=Zh;class Cw extends Zh{constructor(...e){super(...e);(0,kw.default)(this,"preferUnstable",!1)}setPreferUnstable(e){this.preferUnstable=e}get name(){return this.stable&&!this.preferUnstable?this.stable:this.unstable}}Sr.ServerControlledNamespacedValue=Cw;class Pw extends Zh{constructor(e,t){super(e,t);if(!this.unstable)throw new Error("Unstable value must be supplied")}get name(){return this.unstable}get altName(){return this.stable}}Sr.UnstableValue=Pw;Object.defineProperty(ne,"__esModule",{value:!0});ne.UNSTABLE_MSC3089_TREE_SUBTYPE=ne.UNSTABLE_MSC3089_LEAF=ne.UNSTABLE_MSC3089_BRANCH=ne.UNSTABLE_MSC3088_PURPOSE=ne.UNSTABLE_MSC3088_ENABLED=ne.UNSTABLE_ELEMENT_FUNCTIONAL_USERS=ne.RoomType=ne.RoomCreateTypeField=ne.RelationType=ne.MsgType=ne.EventType=ne.EVENT_VISIBILITY_CHANGE_TYPE=void 0;var Os=Sr;let kd;ne.EventType=kd;(function(n){n.RoomCanonicalAlias="m.room.canonical_alias",n.RoomCreate="m.room.create",n.RoomJoinRules="m.room.join_rules",n.RoomMember="m.room.member",n.RoomThirdPartyInvite="m.room.third_party_invite",n.RoomPowerLevels="m.room.power_levels",n.RoomName="m.room.name",n.RoomTopic="m.room.topic",n.RoomAvatar="m.room.avatar",n.RoomPinnedEvents="m.room.pinned_events",n.RoomEncryption="m.room.encryption",n.RoomHistoryVisibility="m.room.history_visibility",n.RoomGuestAccess="m.room.guest_access",n.RoomServerAcl="m.room.server_acl",n.RoomTombstone="m.room.tombstone",n.RoomAliases="m.room.aliases",n.SpaceChild="m.space.child",n.SpaceParent="m.space.parent",n.RoomRedaction="m.room.redaction",n.RoomMessage="m.room.message",n.RoomMessageEncrypted="m.room.encrypted",n.Sticker="m.sticker",n.CallInvite="m.call.invite",n.CallCandidates="m.call.candidates",n.CallAnswer="m.call.answer",n.CallHangup="m.call.hangup",n.CallReject="m.call.reject",n.CallSelectAnswer="m.call.select_answer",n.CallNegotiate="m.call.negotiate",n.CallSDPStreamMetadataChanged="m.call.sdp_stream_metadata_changed",n.CallSDPStreamMetadataChangedPrefix="org.matrix.call.sdp_stream_metadata_changed",n.CallReplaces="m.call.replaces",n.CallAssertedIdentity="m.call.asserted_identity",n.CallAssertedIdentityPrefix="org.matrix.call.asserted_identity",n.KeyVerificationRequest="m.key.verification.request",n.KeyVerificationStart="m.key.verification.start",n.KeyVerificationCancel="m.key.verification.cancel",n.KeyVerificationMac="m.key.verification.mac",n.KeyVerificationDone="m.key.verification.done",n.RoomMessageFeedback="m.room.message.feedback",n.Reaction="m.reaction",n.Typing="m.typing",n.Receipt="m.receipt",n.Presence="m.presence",n.FullyRead="m.fully_read",n.Tag="m.tag",n.SpaceOrder="org.matrix.msc3230.space_order",n.PushRules="m.push_rules",n.Direct="m.direct",n.IgnoredUserList="m.ignored_user_list",n.RoomKey="m.room_key",n.RoomKeyRequest="m.room_key_request",n.ForwardedRoomKey="m.forwarded_room_key",n.Dummy="m.dummy"})(kd||(ne.EventType=kd={}));let Cd;ne.RelationType=Cd;(function(n){n.Annotation="m.annotation",n.Replace="m.replace",n.Reference="m.reference",n.Thread="io.element.thread"})(Cd||(ne.RelationType=Cd={}));let Pd;ne.MsgType=Pd;(function(n){n.Text="m.text",n.Emote="m.emote",n.Notice="m.notice",n.Image="m.image",n.File="m.file",n.Audio="m.audio",n.Location="m.location",n.Video="m.video",n.KeyVerificationRequest="m.key.verification.request"})(Pd||(ne.MsgType=Pd={}));const Mw="type";ne.RoomCreateTypeField=Mw;let Md;ne.RoomType=Md;(function(n){n.Space="m.space"})(Md||(ne.RoomType=Md={}));const Aw=new Os.UnstableValue("m.room.purpose","org.matrix.msc3088.purpose");ne.UNSTABLE_MSC3088_PURPOSE=Aw;const Dw=new Os.UnstableValue("m.enabled","org.matrix.msc3088.enabled");ne.UNSTABLE_MSC3088_ENABLED=Dw;const Uw=new Os.UnstableValue("m.data_tree","org.matrix.msc3089.data_tree");ne.UNSTABLE_MSC3089_TREE_SUBTYPE=Uw;const $w=new Os.UnstableValue("m.leaf","org.matrix.msc3089.leaf");ne.UNSTABLE_MSC3089_LEAF=$w;const xw=new Os.UnstableValue("m.branch","org.matrix.msc3089.branch");ne.UNSTABLE_MSC3089_BRANCH=xw;const Nw=new Os.UnstableValue("io.element.functional_members","io.element.functional_members");ne.UNSTABLE_ELEMENT_FUNCTIONAL_USERS=Nw;const Lw=new Os.UnstableValue("m.visibility","org.matrix.msc3531.visibility");ne.EVENT_VISIBILITY_CHANGE_TYPE=Lw;var Bw=V.exports;Object.defineProperty(tn,"__esModule",{value:!0});tn.RoomMemberEvent=tn.RoomMember=void 0;var Ir=Bw(Y.exports),Kw=Mo,uo=Vw(G),Fw=ie,qw=qe,jw=ne;function tv(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(tv=function(r){return r?t:e})(n)}function Vw(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=tv(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}let is;tn.RoomMemberEvent=is;(function(n){n.Membership="RoomMember.membership",n.Name="RoomMember.name",n.PowerLevel="RoomMember.powerLevel",n.Typing="RoomMember.typing"})(is||(tn.RoomMemberEvent=is={}));class Gw extends qw.TypedEventEmitter{constructor(e,t){super();this.roomId=e,this.userId=t,(0,Ir.default)(this,"_isOutOfBand",!1),(0,Ir.default)(this,"_modified",void 0),(0,Ir.default)(this,"_requestedProfileInfo",void 0),(0,Ir.default)(this,"typing",!1),(0,Ir.default)(this,"name",void 0),(0,Ir.default)(this,"rawDisplayName",void 0),(0,Ir.default)(this,"powerLevel",0),(0,Ir.default)(this,"powerLevelNorm",0),(0,Ir.default)(this,"user",null),(0,Ir.default)(this,"membership",null),(0,Ir.default)(this,"disambiguate",!1),(0,Ir.default)(this,"events",{member:null}),this.name=t,this.rawDisplayName=t,this.updateModifiedTime()}markOutOfBand(){this._isOutOfBand=!0}isOutOfBand(){return this._isOutOfBand}setMembershipEvent(e,t){const r=e.getDirectionalContent().displayname;if(e.getType()!==jw.EventType.RoomMember)return;this._isOutOfBand=!1,this.events.member=e;const i=this.membership;this.membership=e.getDirectionalContent().membership,this.membership===void 0&&Fw.logger.trace(`membership event with membership undefined (forwardLooking: ${e.forwardLooking})!`,e.getContent(),"prevcontent is ",e.getPrevContent()),this.disambiguate=Yw(this.userId,r,t);const s=this.name;this.name=zw(this.userId,r,t,this.disambiguate),this.rawDisplayName=uo.removeDirectionOverrideChars(e.getDirectionalContent().displayname),(!this.rawDisplayName||!uo.removeHiddenChars(this.rawDisplayName))&&(this.rawDisplayName=this.userId),i!==this.membership&&(this.updateModifiedTime(),this.emit(is.Membership,e,this,i)),s!==this.name&&(this.updateModifiedTime(),this.emit(is.Name,e,this,s))}setPowerLevelEvent(e){if(e.getType()!=="m.room.power_levels")return;const t=e.getDirectionalContent();let r=t.users_default||0;const i=t.users||{};Object.values(i).forEach(function(c){r=Math.max(r,c)});const s=this.powerLevel,o=this.powerLevelNorm;i[this.userId]!==void 0&&Number.isInteger(i[this.userId])?this.powerLevel=i[this.userId]:t.users_default!==void 0?this.powerLevel=t.users_default:this.powerLevel=0,this.powerLevelNorm=0,r>0&&(this.powerLevelNorm=this.powerLevel*100/r),(s!==this.powerLevel||o!==this.powerLevelNorm)&&(this.updateModifiedTime(),this.emit(is.PowerLevel,e,this))}setTypingEvent(e){if(e.getType()!=="m.typing")return;const t=this.typing;this.typing=!1;const r=e.getContent().user_ids;!Array.isArray(r)||(r.indexOf(this.userId)!==-1&&(this.typing=!0),t!==this.typing&&(this.updateModifiedTime(),this.emit(is.Typing,e,this)))}updateModifiedTime(){this._modified=Date.now()}getLastModifiedTime(){return this._modified}isKicked(){return this.membership==="leave"&&this.events.member.getSender()!==this.events.member.getStateKey()}getDMInviter(){if(this.events.member){const e=this.events.member;let t=e.getContent(),r=e.getSender();if(t.membership==="join"&&(t=e.getPrevContent(),r=e.getUnsigned().prev_sender),t.membership==="invite"&&t.is_direct)return r}}getAvatarUrl(e,t,r,i,s=!0,o){const c=this.getMxcAvatarUrl();if(!c&&!s)return null;const l=(0,Kw.getHttpUriForMxc)(e,c,t,r,i,o);return l||null}getMxcAvatarUrl(){return this.events.member?this.events.member.getDirectionalContent().avatar_url:this.user?this.user.avatarUrl:null}}tn.RoomMember=Gw;const Ww=/@.+:.+/,Hw=/[\u200E\u200F\u202A-\u202F]/;function Yw(n,e,t){return!e||e===n||!uo.removeHiddenChars(e)||!t?!1:!!(Ww.test(e)||Hw.test(e)||t.getUserIdsWithDisplayName(e).some(i=>i!==n))}function zw(n,e,t,r){return r?uo.removeDirectionOverrideChars(e)+" ("+n+")":!e||e===n||!uo.removeHiddenChars(e)?n:uo.removeDirectionOverrideChars(e)}var Ye={};Object.defineProperty(Ye,"__esModule",{value:!0});Ye.Visibility=Ye.RestrictedAllowType=Ye.Preset=Ye.JoinRule=Ye.HistoryVisibility=Ye.GuestAccess=void 0;let Ad;Ye.Visibility=Ad;(function(n){n.Public="public",n.Private="private"})(Ad||(Ye.Visibility=Ad={}));let Dd;Ye.Preset=Dd;(function(n){n.PrivateChat="private_chat",n.TrustedPrivateChat="trusted_private_chat",n.PublicChat="public_chat"})(Dd||(Ye.Preset=Dd={}));let Ud;Ye.JoinRule=Ud;(function(n){n.Public="public",n.Invite="invite",n.Private="private",n.Knock="knock",n.Restricted="restricted"})(Ud||(Ye.JoinRule=Ud={}));let $d;Ye.RestrictedAllowType=$d;(function(n){n.RoomMembership="m.room_membership"})($d||(Ye.RestrictedAllowType=$d={}));let xd;Ye.GuestAccess=xd;(function(n){n.CanJoin="can_join",n.Forbidden="forbidden"})(xd||(Ye.GuestAccess=xd={}));let Nd;Ye.HistoryVisibility=Nd;(function(n){n.Invited="invited",n.Joined="joined",n.Shared="shared",n.WorldReadable="world_readable"})(Nd||(Ye.HistoryVisibility=Nd={}));var _r={},In={};Object.defineProperty(In,"__esModule",{value:!0});In.M_BEACON_INFO_VARIABLE=In.M_BEACON_INFO=In.M_BEACON=void 0;var ef=Sr;const Jw=new ef.UnstableValue("m.beacon_info.*","org.matrix.msc3489.beacon_info.*");In.M_BEACON_INFO_VARIABLE=Jw;const Xw=new ef.UnstableValue("m.beacon_info","org.matrix.msc3489.beacon_info");In.M_BEACON_INFO=Xw;const Qw=new ef.UnstableValue("m.beacon","org.matrix.msc3489.beacon");In.M_BEACON=Qw;var ze={},Pl={},Ml={},Ya={};Object.defineProperty(Ya,"__esModule",{value:!0});Ya.NamespacedMap=void 0;function Zw(n,e){var t=typeof Symbol!="undefined"&&n[Symbol.iterator]||n["@@iterator"];if(!t){if(Array.isArray(n)||(t=e0(n))||e&&n&&typeof n.length=="number"){t&&(n=t);var r=0,i=function(){};return{s:i,n:function(){return r>=n.length?{done:!0}:{done:!1,value:n[r++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
-In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s=!0,o=!1,c;return{s:function(){t=t.call(n)},n:function(){var u=t.next();return s=u.done,u},e:function(u){o=!0,c=u},f:function(){try{!s&&t.return!=null&&t.return()}finally{if(o)throw c}}}}function e0(n,e){if(!!n){if(typeof n=="string")return hp(n,e);var t=Object.prototype.toString.call(n).slice(8,-1);if(t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set")return Array.from(n);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return hp(n,e)}}function hp(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,r=new Array(e);t<e;t++)r[t]=n[t];return r}function t0(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function fp(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function r0(n,e,t){return e&&fp(n.prototype,e),t&&fp(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function n0(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}var i0=function(){function n(e){if(t0(this,n),n0(this,"internalMap",new Map),e){var t=Zw(e),r;try{for(t.s();!(r=t.n()).done;){var i=r.value;this.set(i[0],i[1])}}catch(s){t.e(s)}finally{t.f()}}}return r0(n,[{key:"get",value:function(t){return t.name&&this.internalMap.has(t.name)?this.internalMap.get(t.name):t.altName&&this.internalMap.has(t.altName)?this.internalMap.get(t.altName):null}},{key:"set",value:function(t,r){t.name&&this.internalMap.set(t.name,r),t.altName&&this.internalMap.set(t.altName,r)}},{key:"has",value:function(t){return!!this.get(t)}},{key:"delete",value:function(t){t.name&&this.internalMap.delete(t.name),t.altName&&this.internalMap.delete(t.altName)}},{key:"hasNamespaced",value:function(t){return this.internalMap.has(t)}},{key:"getNamespaced",value:function(t){return this.internalMap.get(t)}}]),n}();Ya.NamespacedMap=i0;var ni={};function Ld(n){return Ld=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ld(n)}Object.defineProperty(ni,"__esModule",{value:!0});ni.InvalidEventError=void 0;function pp(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function s0(n,e,t){return e&&pp(n.prototype,e),t&&pp(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function o0(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function a0(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&$a(n,e)}function c0(n){var e=rv();return function(){var r=xa(n),i;if(e){var s=xa(this).constructor;i=Reflect.construct(r,arguments,s)}else i=r.apply(this,arguments);return l0(this,i)}}function l0(n,e){if(e&&(Ld(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return u0(n)}function u0(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function Bd(n){var e=typeof Map=="function"?new Map:void 0;return Bd=function(r){if(r===null||!d0(r))return r;if(typeof r!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e!="undefined"){if(e.has(r))return e.get(r);e.set(r,i)}function i(){return Hc(r,arguments,xa(this).constructor)}return i.prototype=Object.create(r.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),$a(i,r)},Bd(n)}function Hc(n,e,t){return rv()?Hc=Reflect.construct:Hc=function(i,s,o){var c=[null];c.push.apply(c,s);var l=Function.bind.apply(i,c),u=new l;return o&&$a(u,o.prototype),u},Hc.apply(null,arguments)}function rv(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function d0(n){return Function.toString.call(n).indexOf("[native code]")!==-1}function $a(n,e){return $a=Object.setPrototypeOf||function(r,i){return r.__proto__=i,r},$a(n,e)}function xa(n){return xa=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},xa(n)}var h0=function(n){a0(t,n);var e=c0(t);function t(r){return o0(this,t),e.call(this,r)}return s0(t)}(Bd(Error));ni.InvalidEventError=h0;var Ao={},Cn={},Ni={};Object.defineProperty(Ni,"__esModule",{value:!0});Ni.ExtensibleEvent=void 0;function f0(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function gp(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function p0(n,e,t){return e&&gp(n.prototype,e),t&&gp(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}var g0=function(){function n(e){f0(this,n),this.wireFormat=e}return p0(n,[{key:"wireContent",get:function(){return this.wireFormat.content}}]),n}();Ni.ExtensibleEvent=g0;var za={};Object.defineProperty(za,"__esModule",{value:!0});za.isOptionalAString=m0;za.isProvided=nv;function m0(n){return nv(n)&&typeof n=="string"}function nv(n){return n!=null}var et={},rn={};function Kd(n){return Kd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Kd(n)}Object.defineProperty(rn,"__esModule",{value:!0});rn.UnstableValue=rn.NamespacedValue=void 0;function y0(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&Fd(n,e)}function Fd(n,e){return Fd=Object.setPrototypeOf||function(r,i){return r.__proto__=i,r},Fd(n,e)}function v0(n){var e=S0();return function(){var r=pl(n),i;if(e){var s=pl(this).constructor;i=Reflect.construct(r,arguments,s)}else i=r.apply(this,arguments);return _0(this,i)}}function _0(n,e){if(e&&(Kd(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return E0(n)}function E0(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function S0(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function pl(n){return pl=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},pl(n)}function iv(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function mp(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function sv(n,e,t){return e&&mp(n.prototype,e),t&&mp(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}var ov=function(){function n(e,t){if(iv(this,n),this.stable=e,this.unstable=t,!this.unstable&&!this.stable)throw new Error("One of stable or unstable values must be supplied")}return sv(n,[{key:"name",get:function(){return this.stable?this.stable:this.unstable}},{key:"altName",get:function(){return this.stable?this.unstable:null}},{key:"matches",value:function(t){return!!this.name&&this.name===t||!!this.altName&&this.altName===t}},{key:"findIn",value:function(t){var r;return this.name&&(r=t==null?void 0:t[this.name]),!r&&this.altName&&(r=t==null?void 0:t[this.altName]),r}},{key:"includedIn",value:function(t){var r=!1;return this.name&&(r=t.includes(this.name)),!r&&this.altName&&(r=t.includes(this.altName)),r}}]),n}();rn.NamespacedValue=ov;var b0=function(n){y0(t,n);var e=v0(t);function t(r,i){var s;if(iv(this,t),s=e.call(this,r,i),!s.unstable)throw new Error("Unstable value must be supplied");return s}return sv(t,[{key:"name",get:function(){return this.unstable}},{key:"altName",get:function(){return this.stable}}]),t}(ov);rn.UnstableValue=b0;Object.defineProperty(et,"__esModule",{value:!0});et.M_TEXT=et.M_NOTICE=et.M_MESSAGE=et.M_HTML=et.M_EMOTE=void 0;var Ja=rn,w0=new Ja.UnstableValue("m.message","org.matrix.msc1767.message");et.M_MESSAGE=w0;var R0=new Ja.UnstableValue("m.text","org.matrix.msc1767.text");et.M_TEXT=R0;var I0=new Ja.UnstableValue("m.html","org.matrix.msc1767.html");et.M_HTML=I0;var T0=new Ja.UnstableValue("m.emote","org.matrix.msc1767.emote");et.M_EMOTE=T0;var O0=new Ja.UnstableValue("m.notice","org.matrix.msc1767.notice");et.M_NOTICE=O0;var ii={};Object.defineProperty(ii,"__esModule",{value:!0});ii.isEventTypeSame=k0;function k0(n,e){if(typeof n=="string")return typeof e=="string"?e===n:e.matches(n);if(typeof e=="string")return n.matches(e);var t=e,r=n;return t.matches(r.name)||t.matches(r.altName)}function qd(n){return qd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},qd(n)}Object.defineProperty(Cn,"__esModule",{value:!0});Cn.MessageEvent=void 0;var C0=Ni,Vo=za,Su=ni,fr=et,P0=ii;function yp(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function vp(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?yp(Object(t),!0).forEach(function(r){Ii(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):yp(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function M0(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function _p(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function A0(n,e,t){return e&&_p(n.prototype,e),t&&_p(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function D0(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&jd(n,e)}function jd(n,e){return jd=Object.setPrototypeOf||function(r,i){return r.__proto__=i,r},jd(n,e)}function U0(n){var e=x0();return function(){var r=gl(n),i;if(e){var s=gl(this).constructor;i=Reflect.construct(r,arguments,s)}else i=r.apply(this,arguments);return $0(this,i)}}function $0(n,e){if(e&&(qd(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Yc(n)}function Yc(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function x0(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function gl(n){return gl=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},gl(n)}function Ii(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}var N0=function(n){D0(t,n);var e=U0(t);function t(r){var i;M0(this,t),i=e.call(this,r),Ii(Yc(i),"text",void 0),Ii(Yc(i),"html",void 0),Ii(Yc(i),"renderings",void 0);var s=fr.M_MESSAGE.findIn(i.wireContent),o=fr.M_TEXT.findIn(i.wireContent),c=fr.M_HTML.findIn(i.wireContent);if((0,Vo.isProvided)(s)){if(!Array.isArray(s))throw new Su.InvalidEventError("m.message contents must be an array");var l=s.find(function(a){return!(0,Vo.isProvided)(a.mimetype)||a.mimetype==="text/plain"}),u=s.find(function(a){return a.mimetype==="text/html"});if(!l)throw new Su.InvalidEventError("m.message is missing a plain text representation");i.text=l.body,i.html=u==null?void 0:u.body,i.renderings=s}else if((0,Vo.isOptionalAString)(o))i.text=o,i.html=c,i.renderings=[{body:o,mimetype:"text/plain"}],i.html&&i.renderings.push({body:i.html,mimetype:"text/html"});else throw new Su.InvalidEventError("Missing textual representation for event");return i}return A0(t,[{key:"isEmote",get:function(){return fr.M_EMOTE.matches(this.wireFormat.type)||(0,Vo.isProvided)(fr.M_EMOTE.findIn(this.wireFormat.content))}},{key:"isNotice",get:function(){return fr.M_NOTICE.matches(this.wireFormat.type)||(0,Vo.isProvided)(fr.M_NOTICE.findIn(this.wireFormat.content))}},{key:"isEquivalentTo",value:function(i){return(0,P0.isEventTypeSame)(i,fr.M_MESSAGE)}},{key:"serializeMMessageOnly",value:function(){var i=Ii({},fr.M_MESSAGE.name,this.renderings);if(this.renderings.length===1){var s=this.renderings[0].mimetype;(s===void 0||s==="text/plain")&&(i=Ii({},fr.M_TEXT.name,this.renderings[0].body))}return i}},{key:"serialize",value:function(){var i;return{type:"m.room.message",content:vp(vp({},this.serializeMMessageOnly()),{},{body:this.text,msgtype:"m.text",format:this.html?"org.matrix.custom.html":void 0,formatted_body:(i=this.html)!==null&&i!==void 0?i:void 0})}}}],[{key:"from",value:function(i,s){var o;return new t({type:fr.M_MESSAGE.name,content:(o={},Ii(o,fr.M_TEXT.name,i),Ii(o,fr.M_HTML.name,s),o)})}}]),t}(C0.ExtensibleEvent);Cn.MessageEvent=N0;var Do={};function Vd(n){return Vd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Vd(n)}Object.defineProperty(Do,"__esModule",{value:!0});Do.NoticeEvent=void 0;var L0=Cn,gc=et,B0=ii;function Ep(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function K0(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function Sp(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function F0(n,e,t){return e&&Sp(n.prototype,e),t&&Sp(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function Ta(){return typeof Reflect!="undefined"&&Reflect.get?Ta=Reflect.get:Ta=function(e,t,r){var i=q0(e,t);if(!!i){var s=Object.getOwnPropertyDescriptor(i,t);return s.get?s.get.call(arguments.length<3?e:r):s.value}},Ta.apply(this,arguments)}function q0(n,e){for(;!Object.prototype.hasOwnProperty.call(n,e)&&(n=ls(n),n!==null););return n}function j0(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&Gd(n,e)}function Gd(n,e){return Gd=Object.setPrototypeOf||function(r,i){return r.__proto__=i,r},Gd(n,e)}function V0(n){var e=H0();return function(){var r=ls(n),i;if(e){var s=ls(this).constructor;i=Reflect.construct(r,arguments,s)}else i=r.apply(this,arguments);return G0(this,i)}}function G0(n,e){if(e&&(Vd(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return W0(n)}function W0(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function H0(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ls(n){return ls=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},ls(n)}var Y0=function(n){j0(t,n);var e=V0(t);function t(r){return K0(this,t),e.call(this,r)}return F0(t,[{key:"isNotice",get:function(){return!0}},{key:"isEquivalentTo",value:function(i){return(0,B0.isEventTypeSame)(i,gc.M_NOTICE)||Ta(ls(t.prototype),"isEquivalentTo",this).call(this,i)}},{key:"serialize",value:function(){var i=Ta(ls(t.prototype),"serialize",this).call(this);return i.content.msgtype="m.notice",i}}],[{key:"from",value:function(i,s){var o;return new t({type:gc.M_NOTICE.name,content:(o={},Ep(o,gc.M_TEXT.name,i),Ep(o,gc.M_HTML.name,s),o)})}}]),t}(L0.MessageEvent);Do.NoticeEvent=Y0;var Uo={};function Wd(n){return Wd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Wd(n)}Object.defineProperty(Uo,"__esModule",{value:!0});Uo.EmoteEvent=void 0;var z0=Cn,mc=et,J0=ii;function bp(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function X0(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function wp(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function Q0(n,e,t){return e&&wp(n.prototype,e),t&&wp(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function Oa(){return typeof Reflect!="undefined"&&Reflect.get?Oa=Reflect.get:Oa=function(e,t,r){var i=Z0(e,t);if(!!i){var s=Object.getOwnPropertyDescriptor(i,t);return s.get?s.get.call(arguments.length<3?e:r):s.value}},Oa.apply(this,arguments)}function Z0(n,e){for(;!Object.prototype.hasOwnProperty.call(n,e)&&(n=us(n),n!==null););return n}function eR(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&Hd(n,e)}function Hd(n,e){return Hd=Object.setPrototypeOf||function(r,i){return r.__proto__=i,r},Hd(n,e)}function tR(n){var e=iR();return function(){var r=us(n),i;if(e){var s=us(this).constructor;i=Reflect.construct(r,arguments,s)}else i=r.apply(this,arguments);return rR(this,i)}}function rR(n,e){if(e&&(Wd(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return nR(n)}function nR(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function iR(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function us(n){return us=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},us(n)}var sR=function(n){eR(t,n);var e=tR(t);function t(r){return X0(this,t),e.call(this,r)}return Q0(t,[{key:"isEmote",get:function(){return!0}},{key:"isEquivalentTo",value:function(i){return(0,J0.isEventTypeSame)(i,mc.M_EMOTE)||Oa(us(t.prototype),"isEquivalentTo",this).call(this,i)}},{key:"serialize",value:function(){var i=Oa(us(t.prototype),"serialize",this).call(this);return i.content.msgtype="m.emote",i}}],[{key:"from",value:function(i,s){var o;return new t({type:mc.M_EMOTE.name,content:(o={},bp(o,mc.M_TEXT.name,i),bp(o,mc.M_HTML.name,s),o)})}}]),t}(z0.MessageEvent);Uo.EmoteEvent=sR;Object.defineProperty(Ao,"__esModule",{value:!0});Ao.LEGACY_M_ROOM_MESSAGE=void 0;Ao.parseMRoomMessage=uR;var Rp=Cn,oR=Do,aR=Uo,cR=rn,mi=et;function Ip(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function Tr(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ip(Object(t),!0).forEach(function(r){Yi(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Ip(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function Yi(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}var lR=new cR.NamespacedValue("m.room.message");Ao.LEGACY_M_ROOM_MESSAGE=lR;function uR(n){var e,t,r;if(mi.M_MESSAGE.findIn(n.content)||mi.M_TEXT.findIn(n.content))return new Rp.MessageEvent(n);var i=(e=n.content)===null||e===void 0?void 0:e.msgtype,s=(t=n.content)===null||t===void 0?void 0:t.body,o=((r=n.content)===null||r===void 0?void 0:r.format)==="org.matrix.custom.html"?n.content.formatted_body:null;if(i==="m.text"){var c;return new Rp.MessageEvent(Tr(Tr({},n),{},{content:Tr(Tr({},n.content),{},(c={},Yi(c,mi.M_TEXT.name,s),Yi(c,mi.M_HTML.name,o),c))}))}else if(i==="m.notice"){var l;return new oR.NoticeEvent(Tr(Tr({},n),{},{content:Tr(Tr({},n.content),{},(l={},Yi(l,mi.M_TEXT.name,s),Yi(l,mi.M_HTML.name,o),l))}))}else if(i==="m.emote"){var u;return new aR.EmoteEvent(Tr(Tr({},n),{},{content:Tr(Tr({},n.content),{},(u={},Yi(u,mi.M_TEXT.name,s),Yi(u,mi.M_HTML.name,o),u))}))}else return null}var Al={};Object.defineProperty(Al,"__esModule",{value:!0});Al.parseMMessage=pR;var dR=Cn,Tp=et,hR=Uo,fR=Do;function pR(n){return Tp.M_EMOTE.matches(n.type)?new hR.EmoteEvent(n):Tp.M_NOTICE.matches(n.type)?new fR.NoticeEvent(n):new dR.MessageEvent(n)}var Et={};Object.defineProperty(Et,"__esModule",{value:!0});Et.M_POLL_START=Et.M_POLL_RESPONSE=Et.M_POLL_KIND_UNDISCLOSED=Et.M_POLL_KIND_DISCLOSED=Et.M_POLL_END=void 0;var Xa=rn,gR=new Xa.UnstableValue("m.poll.disclosed","org.matrix.msc3381.poll.disclosed");Et.M_POLL_KIND_DISCLOSED=gR;var mR=new Xa.UnstableValue("m.poll.undisclosed","org.matrix.msc3381.poll.undisclosed");Et.M_POLL_KIND_UNDISCLOSED=mR;var yR=new Xa.UnstableValue("m.poll.start","org.matrix.msc3381.poll.start");Et.M_POLL_START=yR;var vR=new Xa.UnstableValue("m.poll.response","org.matrix.msc3381.poll.response");Et.M_POLL_RESPONSE=vR;var _R=new Xa.UnstableValue("m.poll.end","org.matrix.msc3381.poll.end");Et.M_POLL_END=_R;var Dl={},ds={};function Yd(n){return Yd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Yd(n)}Object.defineProperty(ds,"__esModule",{value:!0});ds.PollStartEvent=ds.PollAnswerSubevent=void 0;var Dn=Et,av=Cn,ma=et,zc=ni,ER=rn,SR=ii,bR=Ni;function wR(n){return OR(n)||TR(n)||IR(n)||RR()}function RR(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
-In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function IR(n,e){if(!!n){if(typeof n=="string")return zd(n,e);var t=Object.prototype.toString.call(n).slice(8,-1);if(t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set")return Array.from(n);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return zd(n,e)}}function TR(n){if(typeof Symbol!="undefined"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function OR(n){if(Array.isArray(n))return zd(n)}function zd(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,r=new Array(e);t<e;t++)r[t]=n[t];return r}function Op(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function kR(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Op(Object(t),!0).forEach(function(r){er(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Op(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function cv(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function kp(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function lv(n,e,t){return e&&kp(n.prototype,e),t&&kp(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function uv(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&Jd(n,e)}function Jd(n,e){return Jd=Object.setPrototypeOf||function(r,i){return r.__proto__=i,r},Jd(n,e)}function dv(n){var e=PR();return function(){var r=ml(n),i;if(e){var s=ml(this).constructor;i=Reflect.construct(r,arguments,s)}else i=r.apply(this,arguments);return CR(this,i)}}function CR(n,e){if(e&&(Yd(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return ts(n)}function ts(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function PR(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ml(n){return ml=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},ml(n)}function er(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}var hv=function(n){uv(t,n);var e=dv(t);function t(r){var i;cv(this,t),i=e.call(this,r),er(ts(i),"id",void 0);var s=r.content.id;if(!s||typeof s!="string")throw new zc.InvalidEventError("Answer ID must be a non-empty string");return i.id=s,i}return lv(t,[{key:"serialize",value:function(){return{type:"org.matrix.sdk.poll.answer",content:kR({id:this.id},this.serializeMMessageOnly())}}}],[{key:"from",value:function(i,s){return new t({type:"org.matrix.sdk.poll.answer",content:er({id:i},ma.M_TEXT.name,s)})}}]),t}(av.MessageEvent);ds.PollAnswerSubevent=hv;var MR=function(n){uv(t,n);var e=dv(t);function t(r){var i;cv(this,t),i=e.call(this,r),er(ts(i),"question",void 0),er(ts(i),"kind",void 0),er(ts(i),"rawKind",void 0),er(ts(i),"maxSelections",void 0),er(ts(i),"answers",void 0);var s=Dn.M_POLL_START.findIn(i.wireContent);if(!s.question)throw new zc.InvalidEventError("A question is required");if(i.question=new av.MessageEvent({type:"org.matrix.sdk.poll.question",content:s.question}),i.rawKind=s.kind,Dn.M_POLL_KIND_DISCLOSED.matches(i.rawKind)?i.kind=Dn.M_POLL_KIND_DISCLOSED:i.kind=Dn.M_POLL_KIND_UNDISCLOSED,i.maxSelections=Number.isFinite(s.max_selections)&&s.max_selections>0?s.max_selections:1,!Array.isArray(s.answers))throw new zc.InvalidEventError("Poll answers must be an array");var o=s.answers.slice(0,20).map(function(c){return new hv({type:"org.matrix.sdk.poll.answer",content:c})});if(o.length<=0)throw new zc.InvalidEventError("No answers available");return i.answers=o,i}return lv(t,[{key:"isEquivalentTo",value:function(i){return(0,SR.isEventTypeSame)(i,Dn.M_POLL_START)}},{key:"serialize",value:function(){var i;return{type:Dn.M_POLL_START.name,content:(i={},er(i,Dn.M_POLL_START.name,{question:this.question.serialize().content,kind:this.rawKind,max_selections:this.maxSelections,answers:this.answers.map(function(s){return s.serialize().content})}),er(i,ma.M_TEXT.name,"".concat(this.question.text,`
-`).concat(this.answers.map(function(s,o){return"".concat(o+1,". ").concat(s.text)}).join(`
-`))),i)}}}],[{key:"from",value:function(i,s,o){var c,l=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;return new t({type:Dn.M_POLL_START.name,content:(c={},er(c,ma.M_TEXT.name,i),er(c,Dn.M_POLL_START.name,{question:er({},ma.M_TEXT.name,i),kind:o instanceof ER.NamespacedValue?o.name:o,max_selections:l,answers:s.map(function(u){return er({id:AR()},ma.M_TEXT.name,u)})}),c)})}}]),t}(bR.ExtensibleEvent);ds.PollStartEvent=MR;var Cp="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";function AR(){return wR(Array(16)).map(function(){return Cp.charAt(Math.floor(Math.random()*Cp.length))}).join("")}var Qa={},$o={};Object.defineProperty($o,"__esModule",{value:!0});$o.REFERENCE_RELATION=void 0;var DR=rn,UR=new DR.NamespacedValue("m.reference");$o.REFERENCE_RELATION=UR;function Xd(n){return Xd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Xd(n)}Object.defineProperty(Qa,"__esModule",{value:!0});Qa.PollResponseEvent=void 0;var $R=Ni,$s=Et,xR=ni,bu=$o,NR=ii;function LR(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function Pp(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function BR(n,e,t){return e&&Pp(n.prototype,e),t&&Pp(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function KR(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&Qd(n,e)}function Qd(n,e){return Qd=Object.setPrototypeOf||function(r,i){return r.__proto__=i,r},Qd(n,e)}function FR(n){var e=jR();return function(){var r=yl(n),i;if(e){var s=yl(this).constructor;i=Reflect.construct(r,arguments,s)}else i=r.apply(this,arguments);return qR(this,i)}}function qR(n,e){if(e&&(Xd(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Jc(n)}function Jc(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function jR(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function yl(n){return yl=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},yl(n)}function Go(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}var VR=function(n){KR(t,n);var e=FR(t);function t(r){var i;LR(this,t),i=e.call(this,r),Go(Jc(i),"internalAnswerIds",void 0),Go(Jc(i),"internalSpoiled",void 0),Go(Jc(i),"pollEventId",void 0);var s=i.wireContent["m.relates_to"];if(!bu.REFERENCE_RELATION.matches(s==null?void 0:s.rel_type)||typeof(s==null?void 0:s.event_id)!="string")throw new xR.InvalidEventError("Relationship must be a reference to an event");return i.pollEventId=s.event_id,i.validateAgainst(null),i}return BR(t,[{key:"answerIds",get:function(){return this.internalAnswerIds}},{key:"spoiled",get:function(){return this.internalSpoiled}},{key:"validateAgainst",value:function(i){var s=$s.M_POLL_RESPONSE.findIn(this.wireContent);if(!Array.isArray(s==null?void 0:s.answers)){this.internalSpoiled=!0,this.internalAnswerIds=[];return}var o=s.answers;if(o.some(function(c){return typeof c!="string"})||o.length===0){this.internalSpoiled=!0,this.internalAnswerIds=[];return}if(i){if(o.some(function(c){return!i.answers.some(function(l){return l.id===c})})){this.internalSpoiled=!0,this.internalAnswerIds=[];return}o=o.slice(0,i.maxSelections)}this.internalAnswerIds=o,this.internalSpoiled=!1}},{key:"isEquivalentTo",value:function(i){return(0,NR.isEventTypeSame)(i,$s.M_POLL_RESPONSE)}},{key:"serialize",value:function(){return{type:$s.M_POLL_RESPONSE.name,content:Go({"m.relates_to":{rel_type:bu.REFERENCE_RELATION.name,event_id:this.pollEventId}},$s.M_POLL_RESPONSE.name,{answers:this.spoiled?void 0:this.answerIds})}}}],[{key:"from",value:function(i,s){return new t({type:$s.M_POLL_RESPONSE.name,content:Go({"m.relates_to":{rel_type:bu.REFERENCE_RELATION.name,event_id:s}},$s.M_POLL_RESPONSE.name,{answers:i})})}}]),t}($R.ExtensibleEvent);Qa.PollResponseEvent=VR;var Za={};function Zd(n){return Zd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Zd(n)}Object.defineProperty(Za,"__esModule",{value:!0});Za.PollEndEvent=void 0;var Wo=Et,GR=ni,wu=$o,WR=Cn,HR=et,YR=ii,zR=Ni;function Mp(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function JR(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Mp(Object(t),!0).forEach(function(r){to(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Mp(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function XR(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function Ap(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function QR(n,e,t){return e&&Ap(n.prototype,e),t&&Ap(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function ZR(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&eh(n,e)}function eh(n,e){return eh=Object.setPrototypeOf||function(r,i){return r.__proto__=i,r},eh(n,e)}function eI(n){var e=rI();return function(){var r=vl(n),i;if(e){var s=vl(this).constructor;i=Reflect.construct(r,arguments,s)}else i=r.apply(this,arguments);return tI(this,i)}}function tI(n,e){if(e&&(Zd(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return th(n)}function th(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function rI(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function vl(n){return vl=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},vl(n)}function to(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}var nI=function(n){ZR(t,n);var e=eI(t);function t(r){var i;XR(this,t),i=e.call(this,r),to(th(i),"pollEventId",void 0),to(th(i),"closingMessage",void 0);var s=i.wireContent["m.relates_to"];if(!wu.REFERENCE_RELATION.matches(s==null?void 0:s.rel_type)||typeof(s==null?void 0:s.event_id)!="string")throw new GR.InvalidEventError("Relationship must be a reference to an event");return i.pollEventId=s.event_id,i.closingMessage=new WR.MessageEvent(i.wireFormat),i}return QR(t,[{key:"isEquivalentTo",value:function(i){return(0,YR.isEventTypeSame)(i,Wo.M_POLL_END)}},{key:"serialize",value:function(){return{type:Wo.M_POLL_END.name,content:JR(to({"m.relates_to":{rel_type:wu.REFERENCE_RELATION.name,event_id:this.pollEventId}},Wo.M_POLL_END.name,{}),this.closingMessage.serialize().content)}}}],[{key:"from",value:function(i,s){var o;return new t({type:Wo.M_POLL_END.name,content:(o={"m.relates_to":{rel_type:wu.REFERENCE_RELATION.name,event_id:i}},to(o,Wo.M_POLL_END.name,{}),to(o,HR.M_TEXT.name,s),o)})}}]),t}(zR.ExtensibleEvent);Za.PollEndEvent=nI;Object.defineProperty(Dl,"__esModule",{value:!0});Dl.parseMPoll=aI;var Ru=Et,iI=ds,sI=Qa,oI=Za;function aI(n){return Ru.M_POLL_START.matches(n.type)?new iI.PollStartEvent(n):Ru.M_POLL_RESPONSE.matches(n.type)?new sI.PollResponseEvent(n):Ru.M_POLL_END.matches(n.type)?new oI.PollEndEvent(n):null}Object.defineProperty(Ml,"__esModule",{value:!0});Ml.ExtensibleEvents=void 0;var cI=Ya,lI=ni,Dp=Ao,Iu=Al,yc=et,Tu=Et,Ou=Dl;function uI(n,e){var t=typeof Symbol!="undefined"&&n[Symbol.iterator]||n["@@iterator"];if(!t){if(Array.isArray(n)||(t=dI(n))||e&&n&&typeof n.length=="number"){t&&(n=t);var r=0,i=function(){};return{s:i,n:function(){return r>=n.length?{done:!0}:{done:!1,value:n[r++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
-In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s=!0,o=!1,c;return{s:function(){t=t.call(n)},n:function(){var u=t.next();return s=u.done,u},e:function(u){o=!0,c=u},f:function(){try{!s&&t.return!=null&&t.return()}finally{if(o)throw c}}}}function dI(n,e){if(!!n){if(typeof n=="string")return Up(n,e);var t=Object.prototype.toString.call(n).slice(8,-1);if(t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set")return Array.from(n);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Up(n,e)}}function Up(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,r=new Array(e);t<e;t++)r[t]=n[t];return r}function hI(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function $p(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function fI(n,e,t){return e&&$p(n.prototype,e),t&&$p(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function rh(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}var nh=function(){function n(){hI(this,n),rh(this,"interpreters",new cI.NamespacedMap([[Dp.LEGACY_M_ROOM_MESSAGE,Dp.parseMRoomMessage],[yc.M_MESSAGE,Iu.parseMMessage],[yc.M_EMOTE,Iu.parseMMessage],[yc.M_NOTICE,Iu.parseMMessage],[Tu.M_POLL_START,Ou.parseMPoll],[Tu.M_POLL_RESPONSE,Ou.parseMPoll],[Tu.M_POLL_END,Ou.parseMPoll]])),rh(this,"_unknownInterpretOrder",[yc.M_MESSAGE])}return fI(n,[{key:"unknownInterpretOrder",get:function(){var t;return(t=this._unknownInterpretOrder)!==null&&t!==void 0?t:[]},set:function(t){this._unknownInterpretOrder=t}},{key:"registerInterpreter",value:function(t,r){this.interpreters.set(t,r)}},{key:"parse",value:function(t){try{if(this.interpreters.hasNamespaced(t.type))return this.interpreters.getNamespaced(t.type)(t);var r=uI(this.unknownInterpretOrder),i;try{for(r.s();!(i=r.n()).done;){var s=i.value;if(this.interpreters.has(s)){var o=this.interpreters.get(s)(t);if(o)return o}}}catch(c){r.e(c)}finally{r.f()}return null}catch(c){if(c instanceof lI.InvalidEventError)return null;throw c}}}],[{key:"defaultInstance",get:function(){return n._defaultInstance}},{key:"unknownInterpretOrder",get:function(){return n.defaultInstance.unknownInterpretOrder},set:function(t){n.defaultInstance.unknownInterpretOrder=t}},{key:"registerInterpreter",value:function(t,r){n.defaultInstance.registerInterpreter(t,r)}},{key:"parse",value:function(t){return n.defaultInstance.parse(t)}}]),n}();Ml.ExtensibleEvents=nh;rh(nh,"_defaultInstance",new nh);var fv={};Object.defineProperty(fv,"__esModule",{value:!0});var xo={};Object.defineProperty(xo,"__esModule",{value:!0});xo.LegacyMsgType=void 0;xo.isEventLike=pI;var ku=et,ho;xo.LegacyMsgType=ho;(function(n){n.Text="m.text",n.Notice="m.notice",n.Emote="m.emote"})(ho||(xo.LegacyMsgType=ho={}));function pI(n,e){var t=n.content;return e===ho.Text?ku.M_MESSAGE.matches(n.type)||n.type==="m.room.message"&&(t==null?void 0:t.msgtype)==="m.text":e===ho.Emote?ku.M_EMOTE.matches(n.type)||n.type==="m.room.message"&&(t==null?void 0:t.msgtype)==="m.emote":e===ho.Notice?ku.M_NOTICE.matches(n.type)||n.type==="m.room.message"&&(t==null?void 0:t.msgtype)==="m.notice":!1}(function(n){Object.defineProperty(n,"__esModule",{value:!0});var e=Ml;Object.keys(e).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===e[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return e[R]}})});var t=fv;Object.keys(t).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===t[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return t[R]}})});var r=ni;Object.keys(r).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===r[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return r[R]}})});var i=rn;Object.keys(i).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===i[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return i[R]}})});var s=Ya;Object.keys(s).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===s[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return s[R]}})});var o=za;Object.keys(o).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===o[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return o[R]}})});var c=xo;Object.keys(c).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===c[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return c[R]}})});var l=ii;Object.keys(l).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===l[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return l[R]}})});var u=Ao;Object.keys(u).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===u[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return u[R]}})});var a=Al;Object.keys(a).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===a[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return a[R]}})});var g=Dl;Object.keys(g).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===g[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return g[R]}})});var m=$o;Object.keys(m).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===m[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return m[R]}})});var p=Ni;Object.keys(p).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===p[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return p[R]}})});var E=et;Object.keys(E).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===E[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return E[R]}})});var I=Cn;Object.keys(I).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===I[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return I[R]}})});var w=Uo;Object.keys(w).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===w[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return w[R]}})});var k=Do;Object.keys(k).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===k[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return k[R]}})});var P=Et;Object.keys(P).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===P[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return P[R]}})});var S=ds;Object.keys(S).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===S[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return S[R]}})});var T=Qa;Object.keys(T).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===T[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return T[R]}})});var D=Za;Object.keys(D).forEach(function(R){R==="default"||R==="__esModule"||R in n&&n[R]===D[R]||Object.defineProperty(n,R,{enumerable:!0,get:function(){return D[R]}})})})(Pl);var Ul={};Object.defineProperty(Ul,"__esModule",{value:!0});Ul.TEXT_NODE_TYPE=void 0;var gI=Sr;const mI=new gI.UnstableValue("m.text","org.matrix.msc1767.text");Ul.TEXT_NODE_TYPE=mI;var Xr={};Object.defineProperty(Xr,"__esModule",{value:!0});Xr.M_TIMESTAMP=Xr.M_LOCATION=Xr.M_ASSET=Xr.LocationAssetType=void 0;var tf=Sr;let ih;Xr.LocationAssetType=ih;(function(n){n.Self="m.self",n.Pin="m.pin"})(ih||(Xr.LocationAssetType=ih={}));const yI=new tf.UnstableValue("m.asset","org.matrix.msc3488.asset");Xr.M_ASSET=yI;const vI=new tf.UnstableValue("m.ts","org.matrix.msc3488.ts");Xr.M_TIMESTAMP=vI;const _I=new tf.UnstableValue("m.location","org.matrix.msc3488.location");Xr.M_LOCATION=_I;var EI=V.exports;Object.defineProperty(ze,"__esModule",{value:!0});ze.makeBeaconInfoContent=ze.makeBeaconContent=ze.getTextForLocationEvent=void 0;ze.makeEmoteMessage=CI;ze.makeHtmlEmote=TI;ze.makeHtmlMessage=RI;ze.makeHtmlNotice=II;ze.makeLocationContent=void 0;ze.makeNotice=kI;ze.makeTextMessage=OI;ze.parseLocationEvent=ze.parseBeaconInfoContent=void 0;var SI=EI(Y.exports),bI=Pl,pv=In,ks=ne,gv=Ul,St=Xr;function xp(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function wI(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?xp(Object(t),!0).forEach(function(r){(0,SI.default)(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):xp(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function RI(n,e){return{msgtype:ks.MsgType.Text,format:"org.matrix.custom.html",body:n,formatted_body:e}}function II(n,e){return{msgtype:ks.MsgType.Notice,format:"org.matrix.custom.html",body:n,formatted_body:e}}function TI(n,e){return{msgtype:ks.MsgType.Emote,format:"org.matrix.custom.html",body:n,formatted_body:e}}function OI(n){return{msgtype:ks.MsgType.Text,body:n}}function kI(n){return{msgtype:ks.MsgType.Notice,body:n}}function CI(n){return{msgtype:ks.MsgType.Emote,body:n}}const mv=(n,e,t,r)=>{const i=`at ${new Date(t).toISOString()}`,s=e===St.LocationAssetType.Self?"User":void 0,o=r?`"${r}"`:void 0;return[s,"Location",o,n,i].filter(Boolean).join(" ")};ze.getTextForLocationEvent=mv;const yv=(n,e,t,r,i)=>{const s=n!=null?n:mv(e,i||St.LocationAssetType.Self,t,r),o=t?{[St.M_TIMESTAMP.name]:t}:{};return wI({msgtype:ks.MsgType.Location,body:s,geo_uri:e,[St.M_LOCATION.name]:{description:r,uri:e},[St.M_ASSET.name]:{type:i||St.LocationAssetType.Self},[gv.TEXT_NODE_TYPE.name]:s},o)};ze.makeLocationContent=yv;const PI=n=>{var e,t;const r=St.M_LOCATION.findIn(n),i=St.M_ASSET.findIn(n),s=St.M_TIMESTAMP.findIn(n),o=gv.TEXT_NODE_TYPE.findIn(n),c=(e=r==null?void 0:r.uri)!==null&&e!==void 0?e:n==null?void 0:n.geo_uri,l=r==null?void 0:r.description,u=(t=i==null?void 0:i.type)!==null&&t!==void 0?t:St.LocationAssetType.Self,a=o!=null?o:n.body;return yv(a,c,s,l,u)};ze.parseLocationEvent=PI;const MI=(n,e,t,r,i)=>({[pv.M_BEACON_INFO.name]:{description:t,timeout:n,live:e},[St.M_TIMESTAMP.name]:i||Date.now(),[St.M_ASSET.name]:{type:r!=null?r:St.LocationAssetType.Self}});ze.makeBeaconInfoContent=MI;const AI=n=>{const{description:e,timeout:t,live:r}=pv.M_BEACON_INFO.findIn(n),{type:i}=St.M_ASSET.findIn(n),s=St.M_TIMESTAMP.findIn(n);return{description:e,timeout:t,live:r,assetType:i,timestamp:s}};ze.parseBeaconInfoContent=AI;const DI=(n,e,t,r)=>({[St.M_LOCATION.name]:{description:r,uri:n},[St.M_TIMESTAMP.name]:e,"m.relates_to":{rel_type:bI.REFERENCE_RELATION.name,event_id:t}});ze.makeBeaconContent=DI;var UI=V.exports;Object.defineProperty(_r,"__esModule",{value:!0});_r.isTimestampInDuration=_r.isBeaconInfoEventType=_r.BeaconEvent=_r.Beacon=void 0;var vc=UI(Y.exports),Np=In,$I=ze,xI=qe;let Na;_r.BeaconEvent=Na;(function(n){n.New="Beacon.new",n.Update="Beacon.update",n.LivenessChange="Beacon.LivenessChange"})(Na||(_r.BeaconEvent=Na={}));const vv=(n,e,t)=>t>=n&&n+e>=t;_r.isTimestampInDuration=vv;const NI=n=>n.startsWith(Np.M_BEACON_INFO.name)||n.startsWith(Np.M_BEACON_INFO.altName);_r.isBeaconInfoEventType=NI;class LI extends xI.TypedEventEmitter{constructor(e){super();this.rootEvent=e,(0,vc.default)(this,"roomId",void 0),(0,vc.default)(this,"_beaconInfo",void 0),(0,vc.default)(this,"_isLive",void 0),(0,vc.default)(this,"livenessWatchInterval",void 0),this.setBeaconInfo(this.rootEvent),this.roomId=this.rootEvent.getRoomId()}get isLive(){return this._isLive}get identifier(){return this.beaconInfoEventType}get beaconInfoId(){return this.rootEvent.getId()}get beaconInfoOwner(){return this.rootEvent.getStateKey()}get beaconInfoEventType(){return this.rootEvent.getType()}get beaconInfo(){return this._beaconInfo}update(e){if(e.getType()!==this.beaconInfoEventType)throw new Error("Invalid updating event");this.rootEvent=e,this.setBeaconInfo(this.rootEvent),this.emit(Na.Update,e,this)}destroy(){this.livenessWatchInterval&&clearInterval(this.livenessWatchInterval)}monitorLiveness(){if(this.livenessWatchInterval&&clearInterval(this.livenessWatchInterval),this.isLive){var e,t;const r=((e=this._beaconInfo)===null||e===void 0?void 0:e.timestamp)+((t=this._beaconInfo)===null||t===void 0?void 0:t.timeout)+1-Date.now();r>1&&(this.livenessWatchInterval=setInterval(this.checkLiveness.bind(this),r))}}setBeaconInfo(e){this._beaconInfo=(0,$I.parseBeaconInfoContent)(e.getContent()),this.checkLiveness()}checkLiveness(){var e,t,r;const i=this.isLive;this._isLive=((e=this._beaconInfo)===null||e===void 0?void 0:e.live)&&vv((t=this._beaconInfo)===null||t===void 0?void 0:t.timestamp,(r=this._beaconInfo)===null||r===void 0?void 0:r.timeout,Date.now()),i!==this.isLive&&this.emit(Na.LivenessChange,this.isLive,this)}}_r.Beacon=LI;var nn={};Object.defineProperty(nn,"__esModule",{value:!0});nn.TypedReEmitter=nn.ReEmitter=void 0;class _v{constructor(e){this.target=e}reEmit(e,t){for(const r of t){const i=(...s)=>{r==="error"&&this.target.listenerCount("error")===0||this.target.emit(r,...s,e)};e.on(r,i)}}}nn.ReEmitter=_v;class BI extends _v{constructor(e){super(e)}reEmit(e,t){super.reEmit(e,t)}}nn.TypedReEmitter=BI;var KI=V.exports;Object.defineProperty(Tn,"__esModule",{value:!0});Tn.RoomStateEvent=Tn.RoomState=void 0;var Dt=KI(Y.exports),Lp=tn,Cu=ie,Ho=jI(G),Ht=ne,Pu=Ye,FI=qe,Bi=_r,qI=nn;function Ev(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(Ev=function(r){return r?t:e})(n)}function jI(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=Ev(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}var mr;(function(n){n[n.NotStarted=0]="NotStarted",n[n.InProgress=1]="InProgress",n[n.Finished=2]="Finished"})(mr||(mr={}));let Jr;Tn.RoomStateEvent=Jr;(function(n){n.Events="RoomState.events",n.Members="RoomState.members",n.NewMember="RoomState.newMember",n.Update="RoomState.update",n.BeaconLiveness="RoomState.BeaconLiveness"})(Jr||(Tn.RoomStateEvent=Jr={}));class rf extends FI.TypedEventEmitter{constructor(e,t={status:mr.NotStarted}){super();this.roomId=e,this.oobMemberFlags=t,(0,Dt.default)(this,"reEmitter",new qI.TypedReEmitter(this)),(0,Dt.default)(this,"sentinels",{}),(0,Dt.default)(this,"displayNameToUserIds",{}),(0,Dt.default)(this,"userIdsToDisplayNames",{}),(0,Dt.default)(this,"tokenToInvite",{}),(0,Dt.default)(this,"joinedMemberCount",null),(0,Dt.default)(this,"summaryJoinedMemberCount",null),(0,Dt.default)(this,"invitedMemberCount",null),(0,Dt.default)(this,"summaryInvitedMemberCount",null),(0,Dt.default)(this,"modified",void 0),(0,Dt.default)(this,"members",{}),(0,Dt.default)(this,"events",new Map),(0,Dt.default)(this,"paginationToken",null),(0,Dt.default)(this,"beacons",new Map),(0,Dt.default)(this,"liveBeaconIds",[]),this.updateModifiedTime()}getJoinedMemberCount(){return this.summaryJoinedMemberCount!==null?this.summaryJoinedMemberCount:(this.joinedMemberCount===null&&(this.joinedMemberCount=this.getMembers().reduce((e,t)=>t.membership==="join"?e+1:e,0)),this.joinedMemberCount)}setJoinedMemberCount(e){this.summaryJoinedMemberCount=e}getInvitedMemberCount(){return this.summaryInvitedMemberCount!==null?this.summaryInvitedMemberCount:(this.invitedMemberCount===null&&(this.invitedMemberCount=this.getMembers().reduce((e,t)=>t.membership==="invite"?e+1:e,0)),this.invitedMemberCount)}setInvitedMemberCount(e){this.summaryInvitedMemberCount=e}getMembers(){return Object.values(this.members)}getMembersExcept(e){return this.getMembers().filter(t=>!e.includes(t.userId))}getMember(e){return this.members[e]||null}getSentinelMember(e){if(!e)return null;let t=this.sentinels[e];if(t===void 0){t=new Lp.RoomMember(this.roomId,e);const r=this.members[e];r&&t.setMembershipEvent(r.events.member,this),this.sentinels[e]=t}return t}getStateEvents(e,t){if(!this.events.has(e))return t===void 0?[]:null;if(t===void 0)return Array.from(this.events.get(e).values());const r=this.events.get(e).get(t);return r||null}get hasLiveBeacons(){var e;return!!((e=this.liveBeaconIds)!==null&&e!==void 0&&e.length)}clone(){const e=new rf(this.roomId,this.oobMemberFlags),t=this.oobMemberFlags.status;return this.oobMemberFlags.status=mr.NotStarted,Array.from(this.events.values()).forEach(r=>{e.setStateEvents(Array.from(r.values()))}),this.oobMemberFlags.status=t,this.summaryInvitedMemberCount!==null&&e.setInvitedMemberCount(this.getInvitedMemberCount()),this.summaryJoinedMemberCount!==null&&e.setJoinedMemberCount(this.getJoinedMemberCount()),this.oobMemberFlags.status==mr.Finished&&this.getMembers().forEach(r=>{r.isOutOfBand()&&e.getMember(r.userId).markOutOfBand()}),e}setUnknownStateEvents(e){const t=e.filter(r=>!this.events.has(r.getType())||!this.events.get(r.getType()).has(r.getStateKey()));this.setStateEvents(t)}setStateEvents(e){this.updateModifiedTime(),e.forEach(t=>{if(t.getRoomId()!==this.roomId||!t.isState())return;(0,Bi.isBeaconInfoEventType)(t.getType())&&this.setBeacon(t);const r=this.getStateEventMatching(t);this.setStateEvent(t),t.getType()===Ht.EventType.RoomMember&&(this.updateDisplayNameCache(t.getStateKey(),t.getContent().displayname),this.updateThirdPartyTokenCache(t)),this.emit(Jr.Events,t,this,r)}),this.onBeaconLivenessChange(),e.forEach(t=>{if(t.getRoomId()===this.roomId&&!!t.isState()){if(t.getType()===Ht.EventType.RoomMember){const r=t.getStateKey();(t.getContent().membership==="leave"||t.getContent().membership==="ban")&&(t.getContent().avatar_url=t.getContent().avatar_url||t.getPrevContent().avatar_url,t.getContent().displayname=t.getContent().displayname||t.getPrevContent().displayname);const i=this.getOrCreateMember(r,t);i.setMembershipEvent(t,this),this.updateMember(i),this.emit(Jr.Members,t,this,i)}else if(t.getType()===Ht.EventType.RoomPowerLevels){if(t.getStateKey()!=="")return;Object.values(this.members).forEach(i=>{const s=i.getLastModifiedTime();i.setPowerLevelEvent(t),s!==i.getLastModifiedTime()&&this.emit(Jr.Members,t,this,i)}),this.sentinels={}}}}),this.emit(Jr.Update,this)}getOrCreateMember(e,t){let r=this.members[e];return r||(r=new Lp.RoomMember(this.roomId,e),this.members[e]=r,this.emit(Jr.NewMember,t,this,r)),r}setStateEvent(e){this.events.has(e.getType())||this.events.set(e.getType(),new Map),this.events.get(e.getType()).set(e.getStateKey(),e)}setBeacon(e){if(this.beacons.has(e.getType()))return this.beacons.get(e.getType()).update(e);const t=new Bi.Beacon(e);this.reEmitter.reEmit(t,[Bi.BeaconEvent.New,Bi.BeaconEvent.Update,Bi.BeaconEvent.LivenessChange]),this.emit(Bi.BeaconEvent.New,e,t),t.on(Bi.BeaconEvent.LivenessChange,this.onBeaconLivenessChange.bind(this)),this.beacons.set(t.beaconInfoEventType,t)}onBeaconLivenessChange(){var e;const t=!!((e=this.liveBeaconIds)!==null&&e!==void 0&&e.length);this.liveBeaconIds=Array.from(this.beacons.values()).filter(i=>i.isLive).map(i=>i.beaconInfoId);const r=!!this.liveBeaconIds.length;t!==r&&this.emit(Jr.BeaconLiveness,this,r)}getStateEventMatching(e){var t,r;return(t=(r=this.events.get(e.getType()))===null||r===void 0?void 0:r.get(e.getStateKey()))!==null&&t!==void 0?t:null}updateMember(e){const t=this.getStateEvents(Ht.EventType.RoomPowerLevels,"");t&&e.setPowerLevelEvent(t),delete this.sentinels[e.userId],this.members[e.userId]=e,this.joinedMemberCount=null,this.invitedMemberCount=null}needsOutOfBandMembers(){return this.oobMemberFlags.status===mr.NotStarted}markOutOfBandMembersStarted(){this.oobMemberFlags.status===mr.NotStarted&&(this.oobMemberFlags.status=mr.InProgress)}markOutOfBandMembersFailed(){this.oobMemberFlags.status===mr.InProgress&&(this.oobMemberFlags.status=mr.NotStarted)}clearOutOfBandMembers(){let e=0;Object.keys(this.members).forEach(t=>{this.members[t].isOutOfBand()&&(++e,delete this.members[t])}),Cu.logger.log(`LL: RoomState removed ${e} members...`),this.oobMemberFlags.status=mr.NotStarted}setOutOfBandMembers(e){Cu.logger.log(`LL: RoomState about to set ${e.length} OOB members ...`),this.oobMemberFlags.status===mr.InProgress&&(Cu.logger.log("LL: RoomState put in finished state ..."),this.oobMemberFlags.status=mr.Finished,e.forEach(t=>this.setOutOfBandMember(t)),this.emit(Jr.Update,this))}setOutOfBandMember(e){if(e.getType()!==Ht.EventType.RoomMember)return;const t=e.getStateKey(),r=this.getMember(t);if(r&&!r.isOutOfBand())return;const i=this.getOrCreateMember(t,e);i.setMembershipEvent(e,this),i.markOutOfBand(),this.updateDisplayNameCache(i.userId,i.name),this.setStateEvent(e),this.updateMember(i),this.emit(Jr.Members,e,this,i)}setTypingEvent(e){Object.values(this.members).forEach(function(t){t.setTypingEvent(e)})}getInviteForThreePidToken(e){return this.tokenToInvite[e]||null}updateModifiedTime(){this.modified=Date.now()}getLastModifiedTime(){return this.modified}getUserIdsWithDisplayName(e){return this.displayNameToUserIds[Ho.removeHiddenChars(e)]||[]}maySendRedactionForEvent(e,t){const r=this.getMember(t);if(!r||r.membership==="leave"||e.status||e.isRedacted())return!1;const i=this.maySendEvent(Ht.EventType.RoomRedaction,t);return e.getSender()===t?i:this.hasSufficientPowerLevelFor("redact",r.powerLevel)}hasSufficientPowerLevelFor(e,t){const r=this.getStateEvents(Ht.EventType.RoomPowerLevels,"");let i={};r&&(i=r.getContent());let s=50;return Ho.isNumber(i[e])&&(s=i[e]),t>=s}maySendMessage(e){return this.maySendEventOfType(Ht.EventType.RoomMessage,e,!1)}maySendEvent(e,t){return this.maySendEventOfType(e,t,!1)}mayClientSendStateEvent(e,t){return t.isGuest()?!1:this.maySendStateEvent(e,t.credentials.userId)}maySendStateEvent(e,t){return this.maySendEventOfType(e,t,!0)}maySendEventOfType(e,t,r){const i=this.getStateEvents(Ht.EventType.RoomPowerLevels,"");let s,o={},c=0,l=0,u=0;if(i){s=i.getContent(),o=s.events||{},Number.isSafeInteger(s.state_default)?c=s.state_default:c=50;const g=s.users&&s.users[t];Number.isSafeInteger(g)?u=g:Number.isSafeInteger(s.users_default)&&(u=s.users_default),Number.isSafeInteger(s.events_default)&&(l=s.events_default)}let a=r?c:l;return Number.isSafeInteger(o[e])&&(a=o[e]),u>=a}mayTriggerNotifOfType(e,t){const r=this.getMember(t);if(!r)return!1;const i=this.getStateEvents(Ht.EventType.RoomPowerLevels,"");let s=50;return i&&i.getContent()&&i.getContent().notifications&&Ho.isNumber(i.getContent().notifications[e])&&(s=i.getContent().notifications[e]),r.powerLevel>=s}getJoinRule(){var e;const t=this.getStateEvents(Ht.EventType.RoomJoinRules,"");return((e=t==null?void 0:t.getContent())!==null&&e!==void 0?e:{}).join_rule||Pu.JoinRule.Invite}getHistoryVisibility(){var e;const t=this.getStateEvents(Ht.EventType.RoomHistoryVisibility,"");return((e=t==null?void 0:t.getContent())!==null&&e!==void 0?e:{}).history_visibility||Pu.HistoryVisibility.Shared}getGuestAccess(){var e;const t=this.getStateEvents(Ht.EventType.RoomGuestAccess,"");return((e=t==null?void 0:t.getContent())!==null&&e!==void 0?e:{}).guest_access||Pu.GuestAccess.Forbidden}updateThirdPartyTokenCache(e){if(!e.getContent().third_party_invite)return;const t=(e.getContent().third_party_invite.signed||{}).token;!t||!this.getStateEvents(Ht.EventType.RoomThirdPartyInvite,t)||(this.tokenToInvite[t]=e)}updateDisplayNameCache(e,t){const r=this.userIdsToDisplayNames[e];if(delete this.userIdsToDisplayNames[e],r){const s=Ho.removeHiddenChars(r),o=this.displayNameToUserIds[s];if(o){const c=o.filter(l=>l!==e);this.displayNameToUserIds[s]=c}}this.userIdsToDisplayNames[e]=t;const i=t&&Ho.removeHiddenChars(t);i&&(this.displayNameToUserIds[i]||(this.displayNameToUserIds[i]=[]),this.displayNameToUserIds[i].push(e))}}Tn.RoomState=rf;var VI=V.exports;Object.defineProperty(Ha,"__esModule",{value:!0});Ha.MemoryStore=void 0;var ln=VI(Y.exports),GI=en,Bp=Tn;function Kp(n){return typeof n=="string"&&!!n&&n!=="undefined"&&n!=="null"||typeof n=="number"}class WI{constructor(e={}){(0,ln.default)(this,"rooms",{}),(0,ln.default)(this,"groups",{}),(0,ln.default)(this,"users",{}),(0,ln.default)(this,"syncToken",null),(0,ln.default)(this,"filters",{}),(0,ln.default)(this,"accountData",{}),(0,ln.default)(this,"localStorage",void 0),(0,ln.default)(this,"oobMembers",{}),(0,ln.default)(this,"clientOptions",{}),(0,ln.default)(this,"onRoomMember",(t,r,i)=>{if(i.membership==="invite")return;const s=this.users[i.userId]||new GI.User(i.userId);i.name&&(s.setDisplayName(i.name),i.events.member&&s.setRawDisplayName(i.events.member.getDirectionalContent().displayname)),i.events.member&&i.events.member.getContent().avatar_url&&s.setAvatarUrl(i.events.member.getContent().avatar_url),this.users[s.userId]=s}),this.localStorage=e.localStorage}getSyncToken(){return this.syncToken}isNewlyCreated(){return Promise.resolve(!0)}setSyncToken(e){this.syncToken=e}storeGroup(e){this.groups[e.groupId]=e}getGroup(e){return this.groups[e]||null}getGroups(){return Object.values(this.groups)}storeRoom(e){this.rooms[e.roomId]=e,e.currentState.on(Bp.RoomStateEvent.Members,this.onRoomMember),e.currentState.getMembers().forEach(t=>{this.onRoomMember(null,e.currentState,t)})}getRoom(e){return this.rooms[e]||null}getRooms(){return Object.values(this.rooms)}removeRoom(e){this.rooms[e]&&this.rooms[e].currentState.removeListener(Bp.RoomStateEvent.Members,this.onRoomMember),delete this.rooms[e]}getRoomSummaries(){return Object.values(this.rooms).map(function(e){return e.summary})}storeUser(e){this.users[e.userId]=e}getUser(e){return this.users[e]||null}getUsers(){return Object.values(this.users)}scrollback(e,t){return[]}storeEvents(e,t,r,i){}storeFilter(e){!e||(this.filters[e.userId]||(this.filters[e.userId]={}),this.filters[e.userId][e.filterId]=e)}getFilter(e,t){return!this.filters[e]||!this.filters[e][t]?null:this.filters[e][t]}getFilterIdByName(e){if(!this.localStorage)return null;const t="mxjssdk_memory_filter_"+e;try{const r=this.localStorage.getItem(t);if(Kp(r))return r}catch{}return null}setFilterIdByName(e,t){if(!this.localStorage)return;const r="mxjssdk_memory_filter_"+e;try{Kp(t)?this.localStorage.setItem(r,t):this.localStorage.removeItem(r)}catch{}}storeAccountDataEvents(e){e.forEach(t=>{this.accountData[t.getType()]=t})}getAccountData(e){return this.accountData[e]}setSyncData(e){return Promise.resolve()}wantsSave(){return!1}save(e){}startup(){return Promise.resolve()}getSavedSync(){return Promise.resolve(null)}getSavedSyncToken(){return Promise.resolve(null)}deleteAllData(){return this.rooms={},this.users={},this.syncToken=null,this.filters={},this.accountData={},Promise.resolve()}getOutOfBandMembers(e){return Promise.resolve(this.oobMembers[e]||null)}setOutOfBandMembers(e,t){return this.oobMembers[e]=t,Promise.resolve()}clearOutOfBandMembers(e){return this.oobMembers={},Promise.resolve()}getClientOptions(){return Promise.resolve(this.clientOptions)}storeClientOptions(e){return this.clientOptions=Object.assign({},e),Promise.resolve()}}Ha.MemoryStore=WI;var $l={},HI=V.exports;Object.defineProperty($l,"__esModule",{value:!0});$l.MatrixScheduler=void 0;var _c=HI(Y.exports),Fp=zI(G),YI=ne;function Sv(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(Sv=function(r){return r?t:e})(n)}function zI(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=Sv(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}class _l{static RETRY_BACKOFF_RATELIMIT(e,t,r){if(r.httpStatus===400||r.httpStatus===403||r.httpStatus===401||r.cors==="rejected"||r.name==="M_TOO_LARGE")return-1;if(r.name==="M_LIMIT_EXCEEDED"){const i=r.data.retry_after_ms;if(i>0)return i}return t>4?-1:1e3*Math.pow(2,t)}static QUEUE_MESSAGES(e){return e.getType()===YI.EventType.RoomMessage||e.hasAssocation()?"message":null}constructor(e=_l.RETRY_BACKOFF_RATELIMIT,t=_l.QUEUE_MESSAGES){this.retryAlgorithm=e,this.queueAlgorithm=t,(0,_c.default)(this,"queues",{}),(0,_c.default)(this,"activeQueues",[]),(0,_c.default)(this,"procFn",null),(0,_c.default)(this,"processQueue",r=>{const i=this.peekNextEvent(r);if(!i){const s=this.activeQueues.indexOf(r);s>=0&&this.activeQueues.splice(s,1);return}Yo("Queue '%s' has %s pending events",r,this.queues[r].length),Promise.resolve().then(()=>this.procFn(i.event)).then(s=>{this.removeNextEvent(r),Yo("Queue '%s' sent event %s",r,i.event.getId()),i.defer.resolve(s),this.processQueue(r)},s=>{i.attempts+=1;const o=this.retryAlgorithm(i.event,i.attempts,s);Yo("retry(%s) err=%s event_id=%s waitTime=%s",i.attempts,s,i.event.getId(),o),o===-1?(Yo("Queue '%s' giving up on event %s",r,i.event.getId()),this.removeNextEvent(r),i.defer.reject(s),this.processQueue(r)):setTimeout(this.processQueue,o,r)})})}getQueueForEvent(e){const t=this.queueAlgorithm(e);return!t||!this.queues[t]?null:this.queues[t].map(function(r){return r.event})}removeEventFromQueue(e){const t=this.queueAlgorithm(e);if(!t||!this.queues[t])return!1;let r=!1;return Fp.removeElement(this.queues[t],i=>{if(i.event.getId()===e.getId())return r=!0,!0}),r}setProcessFunction(e){this.procFn=e,this.startProcessingQueues()}queueEvent(e){const t=this.queueAlgorithm(e);if(!t)return null;this.queues[t]||(this.queues[t]=[]);const r=Fp.defer();return this.queues[t].push({event:e,defer:r,attempts:0}),Yo("Queue algorithm dumped event %s into queue '%s'",e.getId(),t),this.startProcessingQueues(),r.promise}startProcessingQueues(){!this.procFn||Object.keys(this.queues).filter(e=>this.activeQueues.indexOf(e)===-1&&this.queues[e].length>0).forEach(e=>{this.activeQueues.push(e),this.processQueue(e)})}peekNextEvent(e){const t=this.queues[e];return Array.isArray(t)?t[0]:null}removeNextEvent(e){const t=this.queues[e];return Array.isArray(t)?t.shift():null}}$l.MatrixScheduler=_l;function Yo(...n){}var it={},Ui={},ar={},ei={},Ft={},JI=V.exports;Object.defineProperty(Ft,"__esModule",{value:!0});Ft.EventTimeline=Ft.Direction=void 0;var zr=JI(Y.exports),qp=Tn,XI=ne;let hs;Ft.Direction=hs;(function(n){n.Backward="b",n.Forward="f"})(hs||(Ft.Direction=hs={}));class tr{static setEventMetadata(e,t,r){var i,s,o,c;(i=e.sender)!==null&&i!==void 0&&(s=i.events)!==null&&s!==void 0&&s.member||(e.sender=t.getSentinelMember(e.getSender())),!((o=e.target)!==null&&o!==void 0&&(c=o.events)!==null&&c!==void 0&&c.member)&&e.getType()===XI.EventType.RoomMember&&(e.target=t.getSentinelMember(e.getStateKey())),e.isState()&&r&&(e.forwardLooking=!1)}constructor(e){var t,r;this.eventTimelineSet=e,(0,zr.default)(this,"roomId",void 0),(0,zr.default)(this,"name",void 0),(0,zr.default)(this,"events",[]),(0,zr.default)(this,"baseIndex",0),(0,zr.default)(this,"startState",void 0),(0,zr.default)(this,"endState",void 0),(0,zr.default)(this,"prevTimeline",void 0),(0,zr.default)(this,"nextTimeline",void 0),(0,zr.default)(this,"paginationRequests",{[hs.Backward]:null,[hs.Forward]:null}),this.roomId=(t=(r=e.room)===null||r===void 0?void 0:r.roomId)!==null&&t!==void 0?t:null,this.startState=new qp.RoomState(this.roomId),this.startState.paginationToken=null,this.endState=new qp.RoomState(this.roomId),this.endState.paginationToken=null,this.prevTimeline=null,this.nextTimeline=null,this.paginationRequests={b:null,f:null},this.name=this.roomId+":"+new Date().toISOString()}initialiseState(e){if(this.events.length>0)throw new Error("Cannot initialise state after events are added");for(const t of e)Object.freeze(t);this.startState.setStateEvents(e),this.endState.setStateEvents(e)}forkLive(e){const t=this.getState(e),r=new tr(this.eventTimelineSet);return r.startState=t.clone(),r.endState=t,this.endState=t.clone(),r}fork(e){const t=this.getState(e),r=new tr(this.eventTimelineSet);return r.startState=t.clone(),r.endState=t.clone(),r}getRoomId(){return this.roomId}getFilter(){return this.eventTimelineSet.getFilter()}getTimelineSet(){return this.eventTimelineSet}getBaseIndex(){return this.baseIndex}getEvents(){return this.events}getState(e){if(e==tr.BACKWARDS)return this.startState;if(e==tr.FORWARDS)return this.endState;throw new Error("Invalid direction '"+e+"'")}getPaginationToken(e){return this.getState(e).paginationToken}setPaginationToken(e,t){this.getState(t).paginationToken=e}getNeighbouringTimeline(e){if(e==tr.BACKWARDS)return this.prevTimeline;if(e==tr.FORWARDS)return this.nextTimeline;throw new Error("Invalid direction '"+e+"'")}setNeighbouringTimeline(e,t){if(this.getNeighbouringTimeline(t))throw new Error("timeline already has a neighbouring timeline - cannot reset neighbour (direction: "+t+")");if(t==tr.BACKWARDS)this.prevTimeline=e;else if(t==tr.FORWARDS)this.nextTimeline=e;else throw new Error("Invalid direction '"+t+"'");this.setPaginationToken(null,t)}addEvent(e,t,r){r||(r=t?this.startState:this.endState);const i=this.getTimelineSet();i.room&&(tr.setEventMetadata(e,r,t),e.isState()&&i.room.getUnfilteredTimelineSet()===i&&(r.setStateEvents([e]),(!e.sender||e.getType()==="m.room.member"&&!t)&&tr.setEventMetadata(e,r,t)));let s;t?s=0:s=this.events.length,this.events.splice(s,0,e),t&&this.baseIndex++}removeEvent(e){for(let t=this.events.length-1;t>=0;t--){const r=this.events[t];if(r.getId()==e)return this.events.splice(t,1),t<this.baseIndex&&this.baseIndex--,r}return null}toString(){return this.name}}Ft.EventTimeline=tr;(0,zr.default)(tr,"BACKWARDS",hs.Backward);(0,zr.default)(tr,"FORWARDS",hs.Forward);var qt={},ct={},QI=V.exports;Object.defineProperty(ct,"__esModule",{value:!0});ct.ThreadFilterType=ct.ThreadEvent=ct.Thread=ct.THREAD_RELATION_TYPE=ct.FILTER_RELATED_BY_SENDERS=ct.FILTER_RELATED_BY_REL_TYPES=void 0;var Yr=QI(Y.exports),Ec=Is,ZI=nn,jp=qt,Mu=Ft,eT=ei,tT=qe,nf=Sr;let fo;ct.ThreadEvent=fo;(function(n){n.New="Thread.new",n.Update="Thread.update",n.NewReply="Thread.newReply",n.ViewThread="Thread.viewThread"})(fo||(ct.ThreadEvent=fo={}));class mn extends tT.TypedEventEmitter{constructor(e,t){var r;super();if(this.rootEvent=e,(0,Yr.default)(this,"timelineSet",void 0),(0,Yr.default)(this,"_currentUserParticipated",!1),(0,Yr.default)(this,"reEmitter",void 0),(0,Yr.default)(this,"lastEvent",void 0),(0,Yr.default)(this,"replyCount",0),(0,Yr.default)(this,"room",void 0),(0,Yr.default)(this,"client",void 0),(0,Yr.default)(this,"initialEventsFetched",!1),(0,Yr.default)(this,"id",void 0),(0,Yr.default)(this,"onEcho",o=>{this.timelineSet.eventIdToTimeline(o.getId())&&this.emit(fo.Update,this)}),this.room=t.room,this.client=t.client,this.timelineSet=new eT.EventTimelineSet(this.room,{unstableClientRelationAggregation:!0,timelineSupport:!0,pendingEvents:!0}),this.reEmitter=new ZI.TypedReEmitter(this),this.reEmitter.reEmit(this.timelineSet,[Ec.RoomEvent.Timeline,Ec.RoomEvent.TimelineReset]),e)this.id=e.getId();else{var i,s;this.id=t==null||(i=t.initialEvents)===null||i===void 0||(s=i.find(o=>o.isThreadRelation))===null||s===void 0?void 0:s.relationEventId}this.initialiseThread(this.rootEvent),t==null||(r=t.initialEvents)===null||r===void 0||r.forEach(o=>this.addEvent(o,!1)),this.room.on(Ec.RoomEvent.LocalEchoUpdated,this.onEcho),this.room.on(Ec.RoomEvent.Timeline,this.onEcho)}static setServerSideSupport(e,t){mn.hasServerSideSupport=e,t||(bv.setPreferUnstable(!0),wv.setPreferUnstable(!0),ya.setPreferUnstable(!0))}get roomState(){return this.room.getLiveTimeline().getState(Mu.EventTimeline.FORWARDS)}addEventToTimeline(e,t){if(e.getUnsigned().transaction_id){const r=this.room.getEventForTxnId(e.getUnsigned().transaction_id);if(r){this.room.handleRemoteEcho(e,r);return}}this.findEventById(e.getId())||this.timelineSet.addEventToTimeline(e,this.liveTimeline,t,!1,this.roomState)}async addEvent(e,t){var r;mn.hasServerSideSupport||(e.setThread(this),this.addEventToTimeline(e,t),await this.client.decryptEventIfNeeded(e,{})),mn.hasServerSideSupport&&this.initialEventsFetched&&e.localTimestamp>this.lastReply().localTimestamp&&this.addEventToTimeline(e,!1),!this._currentUserParticipated&&e.getSender()===this.client.getUserId()&&(this._currentUserParticipated=!0);const i=((r=e.getRelation())===null||r===void 0?void 0:r.rel_type)===ya.name;!mn.hasServerSideSupport&&i&&this.replyCount++,(!this.lastEvent||i&&e.getId()!==this.lastEvent.getId()&&e.localTimestamp>this.lastEvent.localTimestamp)&&(this.lastEvent=e,this.lastEvent.getId()!==this.id&&(mn.hasServerSideSupport&&this.replyCount++,this.emit(fo.NewReply,this,e))),this.emit(fo.Update,this)}initialiseThread(e){const t=e==null?void 0:e.getServerAggregatedRelation(ya.name);if(mn.hasServerSideSupport&&t){this.replyCount=t.count,this._currentUserParticipated=t.current_user_participated;const r=new jp.MatrixEvent(t.latest_event);this.setEventMetadata(r),this.lastEvent=r}}async fetchInitialEvents(){if(!mn.hasServerSideSupport)return this.initialEventsFetched=!0,null;try{const e=await this.fetchEvents();return this.initialEventsFetched=!0,e}catch{return null}}setEventMetadata(e){Mu.EventTimeline.setEventMetadata(e,this.roomState,!1),e.setThread(this)}findEventById(e){return this.timelineSet.findEventById(e)}lastReply(e=()=>!0){for(let t=this.events.length-1;t>=0;t--){const r=this.events[t];if(e(r))return r}}get roomId(){return this.room.roomId}get length(){return this.replyCount}get replyToEvent(){return this.lastEvent}get events(){return this.liveTimeline.getEvents()}has(e){return this.timelineSet.findEventById(e)instanceof jp.MatrixEvent}get hasCurrentUserParticipated(){return this._currentUserParticipated}get liveTimeline(){return this.timelineSet.getLiveTimeline()}async fetchEvents(e={limit:20}){let{originalEvent:t,events:r,prevBatch:i,nextBatch:s}=await this.client.relations(this.room.roomId,this.id,ya.name,null,e);!e.to&&!s&&(r=[...r,t]),await Promise.all(r.map(c=>(this.setEventMetadata(c),this.client.decryptEventIfNeeded(c))));const o=!e.direction||e.direction===Mu.Direction.Backward;return this.timelineSet.addEventsToTimeline(r,o,this.liveTimeline,o?s:i),{originalEvent:t,events:r,prevBatch:i,nextBatch:s}}}ct.Thread=mn;(0,Yr.default)(mn,"hasServerSideSupport",void 0);const bv=new nf.ServerControlledNamespacedValue("related_by_senders","io.element.relation_senders");ct.FILTER_RELATED_BY_SENDERS=bv;const wv=new nf.ServerControlledNamespacedValue("related_by_rel_types","io.element.relation_types");ct.FILTER_RELATED_BY_REL_TYPES=wv;const ya=new nf.ServerControlledNamespacedValue("m.thread","io.element.thread");ct.THREAD_RELATION_TYPE=ya;let sh;ct.ThreadFilterType=sh;(function(n){n[n.My=0]="My",n[n.All=1]="All"})(sh||(ct.ThreadFilterType=sh={}));var No={};Object.defineProperty(No,"__esModule",{value:!0});No.EventStatus=void 0;let oh;No.EventStatus=oh;(function(n){n.NOT_SENT="not_sent",n.ENCRYPTING="encrypting",n.SENDING="sending",n.QUEUED="queued",n.SENT="sent",n.CANCELLED="cancelled"})(oh||(No.EventStatus=oh={}));(function(n){var e=V.exports;Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"EventStatus",{enumerable:!0,get:function(){return a.EventStatus}}),n.MatrixEventEvent=n.MatrixEvent=void 0;var t=e(Y.exports),r=Pl,i=ie,s=ne,o=G,c=ct,l=nn,u=qe,a=No;const g={};function m(P){return g[P]||(g[P]=P),g[P]}const p=Object.freeze({visible:!0});let E;n.MatrixEventEvent=E,function(P){P.Decrypted="Event.decrypted",P.BeforeRedaction="Event.beforeRedaction",P.VisibilityChange="Event.visibilityChange",P.LocalEventIdReplaced="Event.localEventIdReplaced",P.Status="Event.status",P.Replaced="Event.replaced",P.RelationsCreated="Event.relationsCreated"}(E||(n.MatrixEventEvent=E={}));class I extends u.TypedEventEmitter{constructor(S={}){var T;super();this.event=S,(0,t.default)(this,"pushActions",null),(0,t.default)(this,"_replacingEvent",null),(0,t.default)(this,"_localRedactionEvent",null),(0,t.default)(this,"_isCancelled",!1),(0,t.default)(this,"clearEvent",void 0),(0,t.default)(this,"visibility",p),(0,t.default)(this,"_hasCachedExtEv",!1),(0,t.default)(this,"_cachedExtEv",void 0),(0,t.default)(this,"senderCurve25519Key",null),(0,t.default)(this,"claimedEd25519Key",null),(0,t.default)(this,"forwardingCurve25519KeyChain",[]),(0,t.default)(this,"untrusted",null),(0,t.default)(this,"_decryptionPromise",null),(0,t.default)(this,"retryDecryption",!1),(0,t.default)(this,"txnId",null),(0,t.default)(this,"thread",null),(0,t.default)(this,"threadId",void 0),(0,t.default)(this,"localTimestamp",void 0),(0,t.default)(this,"sender",null),(0,t.default)(this,"target",null),(0,t.default)(this,"status",null),(0,t.default)(this,"error",null),(0,t.default)(this,"forwardLooking",!0),(0,t.default)(this,"verificationRequest",null),(0,t.default)(this,"reEmitter",void 0),["state_key","type","sender","room_id","membership"].forEach(D=>{typeof S[D]=="string"&&(S[D]=m(S[D]))}),["membership","avatar_url","displayname"].forEach(D=>{var R;typeof((R=S.content)===null||R===void 0?void 0:R[D])=="string"&&(S.content[D]=m(S.content[D]))}),["rel_type"].forEach(D=>{var R,L;typeof((R=S.content)===null||R===void 0||(L=R["m.relates_to"])===null||L===void 0?void 0:L[D])=="string"&&(S.content["m.relates_to"][D]=m(S.content["m.relates_to"][D]))}),this.txnId=S.txn_id||null,this.localTimestamp=Date.now()-((T=this.getAge())!==null&&T!==void 0?T:0),this.reEmitter=new l.TypedReEmitter(this)}get unstableExtensibleEvent(){return this._hasCachedExtEv||(this._cachedExtEv=r.ExtensibleEvents.parse(this.getEffectiveEvent())),this._cachedExtEv}invalidateExtensibleEvent(){this._hasCachedExtEv=!1}getEffectiveEvent(){const S=Object.assign({},this.getContent());if(this.getWireType()===s.EventType.RoomMessageEncrypted)for(const[T,D]of Object.entries(this.getWireContent()))["algorithm","ciphertext","device_id","sender_key","session_id"].includes(T)||S[T]===void 0&&(S[T]=D);return Object.assign({},this.event,this.clearEvent,{content:S})}getId(){return this.event.event_id}getSender(){return this.event.sender||this.event.user_id}getType(){return this.clearEvent?this.clearEvent.type:this.event.type}getWireType(){return this.event.type}getRoomId(){return this.event.room_id}getTs(){return this.event.origin_server_ts}getDate(){return this.event.origin_server_ts?new Date(this.event.origin_server_ts):null}getOriginalContent(){return this._localRedactionEvent?{}:this.clearEvent?this.clearEvent.content||{}:this.event.content||{}}getContent(){return this._localRedactionEvent?{}:this._replacingEvent?this._replacingEvent.getContent()["m.new_content"]||{}:this.getOriginalContent()}getWireContent(){return this.event.content||{}}get threadRootId(){var S;const T=(S=this.getWireContent())===null||S===void 0?void 0:S["m.relates_to"];if((T==null?void 0:T.rel_type)===c.THREAD_RELATION_TYPE.name)return T.event_id;var D;return((D=this.getThread())===null||D===void 0?void 0:D.id)||this.threadId}get isThreadRelation(){return!!this.threadRootId&&this.threadId!==this.getId()}get isThreadRoot(){var S;return!!this.getServerAggregatedRelation(c.THREAD_RELATION_TYPE.name)||((S=this.getThread())===null||S===void 0?void 0:S.id)===this.getId()}get replyEventId(){var S;const T=this.getContent()["m.relates_to"]||this.getWireContent()["m.relates_to"];return T==null||(S=T["m.in_reply_to"])===null||S===void 0?void 0:S.event_id}get relationEventId(){var S,T;return(S=this.getWireContent())===null||S===void 0||(T=S["m.relates_to"])===null||T===void 0?void 0:T.event_id}getPrevContent(){return this.getUnsigned().prev_content||this.event.prev_content||{}}getDirectionalContent(){return this.forwardLooking?this.getContent():this.getPrevContent()}getAge(){return this.getUnsigned().age||this.event.age}getLocalAge(){return Date.now()-this.localTimestamp}getStateKey(){return this.event.state_key}isState(){return this.event.state_key!==void 0}makeEncrypted(S,T,D,R){this.clearEvent={type:this.event.type,content:this.event.content},this.event.type=S,this.event.content=T,this.senderCurve25519Key=D,this.claimedEd25519Key=R}isBeingDecrypted(){return this._decryptionPromise!=null}getDecryptionPromise(){return this._decryptionPromise}isDecryptionFailure(){var S,T;return((S=this.clearEvent)===null||S===void 0||(T=S.content)===null||T===void 0?void 0:T.msgtype)==="m.bad.encrypted"}shouldAttemptDecryption(){return!(this.isRedacted()||this.isBeingDecrypted()||this.clearEvent||!this.isEncrypted())}async attemptDecryption(S,T={}){if(typeof T=="boolean"&&(T={isRetry:T}),!this.isEncrypted())throw new Error("Attempt to decrypt event which isn't encrypted");if(this.clearEvent&&!this.isDecryptionFailure())throw new Error("Attempt to decrypt event which has already been decrypted");return this._decryptionPromise?(i.logger.log(`Event ${this.getId()} already being decrypted; queueing a retry`),this.retryDecryption=!0,this._decryptionPromise):(this._decryptionPromise=this.decryptionLoop(S,T),this._decryptionPromise)}cancelAndResendKeyRequest(S,T){const D=this.getWireContent();return S.requestRoomKey({algorithm:D.algorithm,room_id:this.getRoomId(),session_id:D.session_id,sender_key:D.sender_key},this.getKeyRequestRecipients(T),!0)}getKeyRequestRecipients(S){const T=this.getWireContent(),D=[{userId:S,deviceId:"*"}],R=this.getSender();return R!==S&&D.push({userId:R,deviceId:T.device_id}),D}async decryptionLoop(S,T={}){for(await Promise.resolve();;){this.retryDecryption=!1;let D,R;try{S?(D=await S.decryptEvent(this),T.isRetry===!0&&i.logger.info(`Decrypted event on retry (id=${this.getId()})`)):D=this.badEncryptedMessage("Encryption not enabled")}catch(L){if(L.name!=="DecryptionError"){const H=T.isRetry?"re":"";i.logger.error(`Error ${H}decrypting event (id=${this.getId()}): ${L.stack||L}`),this._decryptionPromise=null,this.retryDecryption=!1;return}if(R=L,this.retryDecryption){i.logger.log(`Got error decrypting event (id=${this.getId()}: ${L}), but retrying`);continue}i.logger.warn(`Error decrypting event (id=${this.getId()}): ${L.detailedString}`),D=this.badEncryptedMessage(L.message)}this._decryptionPromise=null,this.retryDecryption=!1,this.setClearData(D),this.setPushActions(null),T.emit!==!1&&this.emit(E.Decrypted,this,R);return}}badEncryptedMessage(S){return{clearEvent:{type:s.EventType.RoomMessage,content:{msgtype:"m.bad.encrypted",body:"** Unable to decrypt: "+S+" **"}}}}setClearData(S){this.clearEvent=S.clearEvent,this.senderCurve25519Key=S.senderCurve25519Key||null,this.claimedEd25519Key=S.claimedEd25519Key||null,this.forwardingCurve25519KeyChain=S.forwardingCurve25519KeyChain||[],this.untrusted=S.untrusted||!1,this.invalidateExtensibleEvent()}getClearContent(){return this.clearEvent?this.clearEvent.content:null}isEncrypted(){return!this.isState()&&this.event.type===s.EventType.RoomMessageEncrypted}getSenderKey(){return this.senderCurve25519Key}getKeysClaimed(){return{ed25519:this.claimedEd25519Key}}getClaimedEd25519Key(){return this.claimedEd25519Key}getForwardingCurve25519KeyChain(){return this.forwardingCurve25519KeyChain}isKeySourceUntrusted(){return this.untrusted}getUnsigned(){return this.event.unsigned||{}}setUnsigned(S){this.event.unsigned=S}unmarkLocallyRedacted(){const S=this._localRedactionEvent;return this._localRedactionEvent=null,this.event.unsigned&&(this.event.unsigned.redacted_because=null),!!S}markLocallyRedacted(S){this._localRedactionEvent||(this.emit(E.BeforeRedaction,this,S),this._localRedactionEvent=S,this.event.unsigned||(this.event.unsigned={}),this.event.unsigned.redacted_because=S.event)}applyVisibilityEvent(S){const T=S?S.visible:!0,D=S?S.reason:null;let R=!1;(this.visibility.visible!==S.visible||!this.visibility.visible&&this.visibility.reason!==D)&&(R=!0),R&&(T?this.visibility=p:this.visibility=Object.freeze({visible:!1,reason:D}),R&&this.emit(E.VisibilityChange,this,T))}messageVisibility(){return this.visibility}makeRedacted(S){if(!S.event)throw new Error("invalid redactionEvent in makeRedacted");this._localRedactionEvent=null,this.emit(E.BeforeRedaction,this,S),this._replacingEvent=null,this.event.unsigned||(this.event.unsigned={}),this.event.unsigned.redacted_because=S.event;let T;for(T in this.event)!this.event.hasOwnProperty(T)||w.has(T)||delete this.event[T];const D=k[this.getType()]||{},R=this.getContent();for(T in R)!R.hasOwnProperty(T)||D[T]||delete R[T];this.invalidateExtensibleEvent()}isRedacted(){return Boolean(this.getUnsigned().redacted_because)}isRedaction(){return this.getType()===s.EventType.RoomRedaction}asVisibilityChange(){if(!s.EVENT_VISIBILITY_CHANGE_TYPE.matches(this.getType()))return null;const S=this.getRelation();if(!S||S.rel_type!="m.reference")return null;const T=S.event_id;if(!T)return null;const D=this.getWireContent(),R=!!D.visible,L=D.reason;return L&&typeof L!="string"?null:{visible:R,reason:L,eventId:T}}isVisibilityEvent(){return s.EVENT_VISIBILITY_CHANGE_TYPE.matches(this.getType())}getRedactionEvent(){var S;if(!this.isRedacted())return null;if((S=this.clearEvent)!==null&&S!==void 0&&S.unsigned){var T;return(T=this.clearEvent)===null||T===void 0?void 0:T.unsigned.redacted_because}else return this.event.unsigned.redacted_because?this.event.unsigned.redacted_because:{}}getPushActions(){return this.pushActions}setPushActions(S){this.pushActions=S}handleRemoteEcho(S){const T=this.getUnsigned(),D=this.getId();this.event=S,T.redacted_because&&(this.event.unsigned||(this.event.unsigned={}),this.event.unsigned.redacted_because=T.redacted_because),this.setStatus(null),this.getId()!==D&&this.emit(E.LocalEventIdReplaced,this),this.localTimestamp=Date.now()-this.getAge()}isSending(){return!!this.status}setStatus(S){this.status=S,this.emit(E.Status,this,S)}replaceLocalEventId(S){this.event.event_id=S,this.emit(E.LocalEventIdReplaced,this)}isRelation(S=void 0){const T=this.getWireContent(),D=T&&T["m.relates_to"];return D&&D.rel_type&&D.event_id&&(S&&D.rel_type===S||!S)}getRelation(){return this.isRelation()?this.getWireContent()["m.relates_to"]:null}makeReplaced(S){this.isRedacted()&&S||this._replacingEvent!==S&&(this._replacingEvent=S,this.emit(E.Replaced,this),this.invalidateExtensibleEvent())}getAssociatedStatus(){return this._replacingEvent?this._replacingEvent.status:this._localRedactionEvent?this._localRedactionEvent.status:this.status}getServerAggregatedRelation(S){var T;return(T=this.getUnsigned()["m.relations"])===null||T===void 0?void 0:T[S]}replacingEventId(){const S=this.getServerAggregatedRelation(s.RelationType.Replace);if(S)return S.event_id;if(this._replacingEvent)return this._replacingEvent.getId()}replacingEvent(){return this._replacingEvent}replacingEventDate(){const S=this.getServerAggregatedRelation(s.RelationType.Replace);if(S){const T=S.origin_server_ts;if(Number.isFinite(T))return new Date(T)}else if(this._replacingEvent)return this._replacingEvent.getDate()}localRedactionEvent(){return this._localRedactionEvent}getAssociatedId(){const S=this.getRelation();if(this.replyEventId)return this.replyEventId;if(S)return S.event_id;if(this.isRedaction())return this.event.redacts}hasAssocation(){return!!this.getAssociatedId()}updateAssociatedId(S){const T=this.getRelation();T?T.event_id=S:this.isRedaction()&&(this.event.redacts=S)}flagCancelled(S=!0){this._isCancelled=S}isCancelled(){return this._isCancelled}toSnapshot(){const S=new I(JSON.parse(JSON.stringify(this.event)));for(const[T,D]of Object.entries(this))T!=="event"&&(S[T]=D);return S}isEquivalentTo(S){if(!S)return!1;if(S===this)return!0;const T=(0,o.deepSortedObjectEntries)(this.event),D=(0,o.deepSortedObjectEntries)(S.event);return JSON.stringify(T)===JSON.stringify(D)}toJSON(){const S=this.getEffectiveEvent();return this.isEncrypted()?{decrypted:S,encrypted:this.event}:S}setVerificationRequest(S){this.verificationRequest=S}setTxnId(S){this.txnId=S}getTxnId(){return this.txnId}setThread(S){this.thread=S,this.setThreadId(S.id),this.reEmitter.reEmit(S,[c.ThreadEvent.Update])}getThread(){return this.thread}setThreadId(S){this.threadId=S}}n.MatrixEvent=I;const w=new Set(["event_id","type","room_id","user_id","sender","state_key","prev_state","content","unsigned","origin_server_ts"]),k={[s.EventType.RoomMember]:{membership:1},[s.EventType.RoomCreate]:{creator:1},[s.EventType.RoomJoinRules]:{join_rule:1},[s.EventType.RoomPowerLevels]:{ban:1,events:1,events_default:1,kick:1,redact:1,state_default:1,users:1,users_default:1},[s.EventType.RoomAliases]:{aliases:1}}})(qt);var fs={},rT=V.exports;Object.defineProperty(fs,"__esModule",{value:!0});fs.RelationsEvent=fs.Relations=void 0;var Un=rT(Y.exports),Ki=qt,Sc=ie,Gr=ne,nT=qe;let po;fs.RelationsEvent=po;(function(n){n.Add="Relations.add",n.Remove="Relations.remove",n.Redaction="Relations.redaction"})(po||(fs.RelationsEvent=po={}));class iT extends nT.TypedEventEmitter{constructor(e,t,r){super();this.relationType=e,this.eventType=t,this.room=r,(0,Un.default)(this,"relationEventIds",new Set),(0,Un.default)(this,"relations",new Set),(0,Un.default)(this,"annotationsByKey",{}),(0,Un.default)(this,"annotationsBySender",{}),(0,Un.default)(this,"sortedAnnotationsByKey",[]),(0,Un.default)(this,"targetEvent",null),(0,Un.default)(this,"creationEmitted",!1),(0,Un.default)(this,"onEventStatus",(i,s)=>{if(!i.isSending()){i.removeListener(Ki.MatrixEventEvent.Status,this.onEventStatus);return}s===Ki.EventStatus.CANCELLED&&(i.removeListener(Ki.MatrixEventEvent.Status,this.onEventStatus),this.removeEvent(i))}),(0,Un.default)(this,"onBeforeRedaction",async i=>{if(!!this.relations.has(i)){if(this.relations.delete(i),this.relationType===Gr.RelationType.Annotation)this.removeAnnotationFromAggregation(i);else if(this.relationType===Gr.RelationType.Replace&&this.targetEvent){const s=await this.getLastReplacement();this.targetEvent.makeReplaced(s)}i.removeListener(Ki.MatrixEventEvent.BeforeRedaction,this.onBeforeRedaction),this.emit(po.Redaction,i)}})}async addEvent(e){if(this.relationEventIds.has(e.getId()))return;const t=e.getRelation();if(!t){Sc.logger.error("Event must have relation info");return}const r=t.rel_type,i=e.getType();if(this.relationType!==r||this.eventType!==i){Sc.logger.error("Event relation info doesn't match this container");return}if(e.isSending()&&e.on(Ki.MatrixEventEvent.Status,this.onEventStatus),this.relations.add(e),this.relationEventIds.add(e.getId()),this.relationType===Gr.RelationType.Annotation)this.addAnnotationToAggregation(e);else if(this.relationType===Gr.RelationType.Replace&&this.targetEvent){const s=await this.getLastReplacement();this.targetEvent.makeReplaced(s)}e.on(Ki.MatrixEventEvent.BeforeRedaction,this.onBeforeRedaction),this.emit(po.Add,e),this.maybeEmitCreated()}async removeEvent(e){if(!this.relations.has(e))return;const t=e.getRelation();if(!t){Sc.logger.error("Event must have relation info");return}const r=t.rel_type,i=e.getType();if(this.relationType!==r||this.eventType!==i){Sc.logger.error("Event relation info doesn't match this container");return}if(this.relations.delete(e),this.relationType===Gr.RelationType.Annotation)this.removeAnnotationFromAggregation(e);else if(this.relationType===Gr.RelationType.Replace&&this.targetEvent){const s=await this.getLastReplacement();this.targetEvent.makeReplaced(s)}this.emit(po.Remove,e)}getRelations(){return[...this.relations]}addAnnotationToAggregation(e){const{key:t}=e.getRelation();if(!t)return;let r=this.annotationsByKey[t];r||(r=this.annotationsByKey[t]=new Set,this.sortedAnnotationsByKey.push([t,r])),r.add(e),this.sortedAnnotationsByKey.sort((o,c)=>{const l=o[1];return c[1].size-l.size});const i=e.getSender();let s=this.annotationsBySender[i];s||(s=this.annotationsBySender[i]=new Set),s.add(e)}removeAnnotationFromAggregation(e){const{key:t}=e.getRelation();if(!t)return;const r=this.annotationsByKey[t];r&&(r.delete(e),this.sortedAnnotationsByKey.sort((o,c)=>{const l=o[1];return c[1].size-l.size}));const i=e.getSender(),s=this.annotationsBySender[i];s&&s.delete(e)}getSortedAnnotationsByKey(){return this.relationType!==Gr.RelationType.Annotation?null:this.sortedAnnotationsByKey}getAnnotationsBySender(){return this.relationType!==Gr.RelationType.Annotation?null:this.annotationsBySender}async getLastReplacement(){if(this.relationType!==Gr.RelationType.Replace||!this.targetEvent)return null;const e=this.targetEvent.getServerAggregatedRelation(Gr.RelationType.Replace),t=e&&e.origin_server_ts,r=this.getRelations().reduce((i,s)=>s.getSender()!==this.targetEvent.getSender()||t&&t>s.getTs()||i&&i.getTs()>s.getTs()?i:s,null);return r!=null&&r.shouldAttemptDecryption()?await r.attemptDecryption(this.room.client.crypto):r!=null&&r.isBeingDecrypted()&&await r.getDecryptionPromise(),r}async setTargetEvent(e){if(!this.targetEvent){if(this.targetEvent=e,this.relationType===Gr.RelationType.Replace){const t=await this.getLastReplacement();t&&this.targetEvent.makeReplaced(t)}this.maybeEmitCreated()}}maybeEmitCreated(){this.creationEmitted||!this.targetEvent||!this.relations.size||(this.creationEmitted=!0,this.targetEvent.emit(Ki.MatrixEventEvent.RelationsCreated,this.relationType,this.eventType))}}fs.Relations=iT;var sT=V.exports;Object.defineProperty(ei,"__esModule",{value:!0});ei.EventTimelineSet=ei.DuplicateStrategy=void 0;var yi=sT(Y.exports),dt=Ft,Vp=qt,rs=ie,oT=fs,Au=ar,aT=qe;let ro;ro=rs.logger.log.bind(rs.logger);let La;ei.DuplicateStrategy=La;(function(n){n.Ignore="ignore",n.Replace="replace"})(La||(ei.DuplicateStrategy=La={}));class cT extends aT.TypedEventEmitter{constructor(e,t){super();this.room=e,(0,yi.default)(this,"timelineSupport",void 0),(0,yi.default)(this,"unstableClientRelationAggregation",void 0),(0,yi.default)(this,"displayPendingEvents",void 0),(0,yi.default)(this,"liveTimeline",void 0),(0,yi.default)(this,"timelines",void 0),(0,yi.default)(this,"_eventIdToTimeline",void 0),(0,yi.default)(this,"filter",void 0),(0,yi.default)(this,"relations",void 0),this.timelineSupport=Boolean(t.timelineSupport),this.liveTimeline=new dt.EventTimeline(this),this.unstableClientRelationAggregation=!!t.unstableClientRelationAggregation,this.displayPendingEvents=t.pendingEvents!==!1,this.timelines=[this.liveTimeline],this._eventIdToTimeline={},this.filter=t.filter,this.unstableClientRelationAggregation&&(this.relations={})}getTimelines(){return this.timelines}getFilter(){return this.filter}setFilter(e){this.filter=e}getPendingEvents(){return!this.room||!this.displayPendingEvents?[]:this.room.getPendingEvents()}getLiveTimeline(){return this.liveTimeline}eventIdToTimeline(e){return this._eventIdToTimeline[e]}replaceEventId(e,t){const r=this._eventIdToTimeline[e];r&&(delete this._eventIdToTimeline[e],this._eventIdToTimeline[t]=r)}resetLiveTimeline(e,t){const r=!this.timelineSupport||!t,i=this.liveTimeline,s=r?i.forkLive(dt.EventTimeline.FORWARDS):i.fork(dt.EventTimeline.FORWARDS);r?(this.timelines=[s],this._eventIdToTimeline={}):this.timelines.push(s),t&&i.setPaginationToken(t,dt.EventTimeline.FORWARDS),s.setPaginationToken(e,dt.EventTimeline.BACKWARDS),this.liveTimeline=s,this.emit(Au.RoomEvent.TimelineReset,this.room,this,r)}getTimelineForEvent(e){const t=this._eventIdToTimeline[e];return t===void 0?null:t}findEventById(e){const t=this.getTimelineForEvent(e);if(!!t)return t.getEvents().find(function(r){return r.getId()==e})}addTimeline(){if(!this.timelineSupport)throw new Error("timeline support is disabled. Set the 'timelineSupport' parameter to true when creating MatrixClient to enable it.");const e=new dt.EventTimeline(this);return this.timelines.push(e),e}addEventsToTimeline(e,t,r,i){if(!r)throw new Error("'timeline' not specified for EventTimelineSet.addEventsToTimeline");if(!t&&r==this.liveTimeline)throw new Error("EventTimelineSet.addEventsToTimeline cannot be used for adding events to the live timeline - use Room.addLiveEvents instead");if(this.filter&&(e=this.filter.filterRoomTimeline(e),!e.length))return;const s=t?dt.EventTimeline.BACKWARDS:dt.EventTimeline.FORWARDS,o=t?dt.EventTimeline.FORWARDS:dt.EventTimeline.BACKWARDS;let c=!1,l=!1;for(let u=0;u<e.length;u++){const a=e[u],g=a.getId(),m=this._eventIdToTimeline[g];if(!m){this.addEventToTimeline(a,r,t),l=!0,c=!0;continue}if(l=!1,m==r){ro("Event "+g+" already in timeline "+r);continue}const p=r.getNeighbouringTimeline(s);if(p){m==p?ro("Event "+g+" in neighbouring timeline - switching to "+m):ro("Event "+g+" already in a different timeline "+m),r=m;continue}rs.logger.info("Already have timeline for "+g+" - joining timeline "+r+" to "+m);const E=m===this.liveTimeline,I=r===this.liveTimeline,w=s===dt.EventTimeline.BACKWARDS&&E,k=s===dt.EventTimeline.FORWARDS&&I;if(w||k){w&&rs.logger.warn("Refusing to set a preceding existingTimeLine on our timeline as the existingTimeLine is live ("+m+")"),k&&rs.logger.warn("Refusing to set our preceding timeline on a existingTimeLine as our timeline is live ("+r+")");continue}r.setNeighbouringTimeline(m,s),m.setNeighbouringTimeline(r,o),r=m,c=!0}if(l||!c){if(s===dt.EventTimeline.FORWARDS&&r===this.liveTimeline){rs.logger.warn({lastEventWasNew:l,didUpdate:c}),rs.logger.warn(`Refusing to set forwards pagination token of live timeline ${r} to ${i}`);return}r.setPaginationToken(i,s)}}addLiveEvent(e,t=La.Ignore,r=!1,i){if(this.filter&&!this.filter.filterRoomTimeline([e]).length)return;const s=this._eventIdToTimeline[e.getId()];if(s){if(t===La.Replace){ro("EventTimelineSet.addLiveEvent: replacing duplicate event "+e.getId());const o=s.getEvents();for(let c=0;c<o.length;c++)if(o[c].getId()===e.getId()){i||(i=s.getState(dt.EventTimeline.FORWARDS)),dt.EventTimeline.setEventMetadata(e,i,!1),o[c]=e;break}}else ro("EventTimelineSet.addLiveEvent: ignoring duplicate event "+e.getId());return}this.addEventToTimeline(e,this.liveTimeline,!1,r,i)}addEventToTimeline(e,t,r,i=!1,s){const o=e.getId();t.addEvent(e,r,s),this._eventIdToTimeline[o]=t,this.setRelationsTarget(e),this.aggregateRelations(e);const c={timeline:t,liveEvent:!r&&t==this.liveTimeline&&!i};this.emit(Au.RoomEvent.Timeline,e,this.room,Boolean(r),!1,c)}handleRemoteEcho(e,t,r){const i=this._eventIdToTimeline[t];i?(delete this._eventIdToTimeline[t],this._eventIdToTimeline[r]=i):this.filter?this.filter.filterRoomTimeline([e]).length&&this.addEventToTimeline(e,this.liveTimeline,!1):this.addEventToTimeline(e,this.liveTimeline,!1)}removeEvent(e){const t=this._eventIdToTimeline[e];if(!t)return null;const r=t.removeEvent(e);if(r){delete this._eventIdToTimeline[e];const i={timeline:t};this.emit(Au.RoomEvent.Timeline,r,this.room,void 0,!0,i)}return r}compareEventOrdering(e,t){if(e==t)return 0;const r=this._eventIdToTimeline[e],i=this._eventIdToTimeline[t];if(r===void 0||i===void 0)return null;if(r===i){let o,c;const l=r.getEvents();for(let u=0;u<l.length&&(o===void 0||c===void 0);u++){const a=l[u].getId();a==e&&(o=u),a==t&&(c=u)}return o-c}let s=r;for(;s;){if(s===i)return-1;s=s.getNeighbouringTimeline(dt.EventTimeline.FORWARDS)}for(s=r;s;){if(s===i)return 1;s=s.getNeighbouringTimeline(dt.EventTimeline.BACKWARDS)}return null}getRelationsForEvent(e,t,r){if(!this.unstableClientRelationAggregation)throw new Error("Client-side relation aggregation is disabled");if(!e||!t||!r)throw new Error("Invalid arguments for `getRelationsForEvent`");return((this.relations[e]||{})[t]||{})[r]}getAllRelationsEventForEvent(e){const t=this.relations[e]||{},r=[];for(const i of Object.values(t))for(const s of Object.values(i))r.push(...s.getRelations());return r}setRelationsTarget(e){if(!this.unstableClientRelationAggregation)return;const t=this.relations[e.getId()];if(!!t)for(const r of Object.values(t))for(const i of Object.values(r))i.setTargetEvent(e)}aggregateRelations(e){if(!this.unstableClientRelationAggregation||e.isRedacted()||e.status===Vp.EventStatus.CANCELLED)return;if(e.isBeingDecrypted()||e.shouldAttemptDecryption()){e.once(Vp.MatrixEventEvent.Decrypted,()=>{this.aggregateRelations(e)});return}const t=e.getRelation();if(!t)return;const r=t.event_id,i=t.rel_type,s=e.getType();let o=this.relations[r];o||(o=this.relations[r]={});let c=o[i];c||(c=o[i]={});let l=c[s],u;l||(l=c[s]=new oT.Relations(i,s,this.room),u=this.findEventById(r)||this.room.getPendingEvent(r),u&&l.setTargetEvent(u)),l.addEvent(e)}}ei.EventTimelineSet=cT;var ec={};Object.defineProperty(ec,"__esModule",{value:!0});ec.RoomSummary=void 0;class lT{constructor(e,t){this.roomId=e}}ec.RoomSummary=lT;var Cs={},xl={};Object.defineProperty(xl,"__esModule",{value:!0});xl.FilterComponent=void 0;var Fi=ct;function uT(n,e){if(e.endsWith("*")){const t=e.slice(0,-1);return n.substr(0,t.length)===t}else return n===e}class dT{constructor(e,t){this.filterJson=e,this.userId=t}check(e){var t,r;const i=((t=e.getUnsigned())===null||t===void 0?void 0:t["m.relations"])||{},s=Object.keys(i),o=[];return this.userId&&i!==null&&i!==void 0&&(r=i[Fi.THREAD_RELATION_TYPE.name])!==null&&r!==void 0&&r.current_user_participated&&o.push(this.userId),this.checkFields(e.getRoomId(),e.getSender(),e.getType(),e.getContent()?e.getContent().url!==void 0:!1,s,o)}toJSON(){return{types:this.filterJson.types||null,not_types:this.filterJson.not_types||[],rooms:this.filterJson.rooms||null,not_rooms:this.filterJson.not_rooms||[],senders:this.filterJson.senders||null,not_senders:this.filterJson.not_senders||[],contains_url:this.filterJson.contains_url||null,[Fi.FILTER_RELATED_BY_SENDERS.name]:this.filterJson[Fi.FILTER_RELATED_BY_SENDERS.name]||[],[Fi.FILTER_RELATED_BY_REL_TYPES.name]:this.filterJson[Fi.FILTER_RELATED_BY_REL_TYPES.name]||[]}}checkFields(e,t,r,i,s,o){const c={rooms:function(g){return e===g},senders:function(g){return t===g},types:function(g){return uT(r,g)}};for(let g=0;g<Object.keys(c).length;g++){const m=Object.keys(c)[g],p=c[m],E="not_"+m,I=this.filterJson[E];if(I!=null&&I.some(p))return!1;const w=this.filterJson[m];if(w&&!w.some(p))return!1}const l=this.filterJson.contains_url;if(l!==void 0&&l!==i)return!1;const u=this.filterJson[Fi.FILTER_RELATED_BY_REL_TYPES.name];if(u!==void 0&&!this.arrayMatchesFilter(u,s))return!1;const a=this.filterJson[Fi.FILTER_RELATED_BY_SENDERS.name];return!(a!==void 0&&!this.arrayMatchesFilter(a,o))}arrayMatchesFilter(e,t){return t.length>0&&e.every(r=>t.includes(r))}filter(e){return e.filter(this.check,this)}limit(){return this.filterJson.limit!==void 0?this.filterJson.limit:10}}xl.FilterComponent=dT;var hT=V.exports;Object.defineProperty(Cs,"__esModule",{value:!0});Cs.Filter=void 0;var Xc=hT(Y.exports),Gp=xl;function Du(n,e,t){const r=e.split(".");let i=n;for(let s=0;s<r.length-1;s++)i[r[s]]||(i[r[s]]={}),i=i[r[s]];i[r[r.length-1]]=t}class Nl{static fromJson(e,t,r){const i=new Nl(e,t);return i.setDefinition(r),i}constructor(e,t){this.userId=e,this.filterId=t,(0,Xc.default)(this,"definition",{}),(0,Xc.default)(this,"roomFilter",void 0),(0,Xc.default)(this,"roomTimelineFilter",void 0)}getFilterId(){return this.filterId}getDefinition(){return this.definition}setDefinition(e){this.definition=e;const t=e.room,r={};t&&(t.rooms&&(r.rooms=t.rooms),t.rooms&&(r.not_rooms=t.not_rooms)),this.roomFilter=new Gp.FilterComponent(r,this.userId),this.roomTimelineFilter=new Gp.FilterComponent((t==null?void 0:t.timeline)||{},this.userId)}getRoomTimelineFilterComponent(){return this.roomTimelineFilter}filterRoomTimeline(e){return this.roomTimelineFilter.filter(this.roomFilter.filter(e))}setTimelineLimit(e){Du(this.definition,"room.timeline.limit",e)}setLazyLoadMembers(e){Du(this.definition,"room.state.lazy_load_members",!!e)}setIncludeLeaveRooms(e){Du(this.definition,"room.include_leave",e)}}Cs.Filter=Nl;(0,Xc.default)(Nl,"LAZY_LOADING_MESSAGES_FILTER",{lazy_load_members:!0});var me={},sf={};/*!
- * content-type
- * Copyright(c) 2015 Douglas Christopher Wilson
- * MIT Licensed
- */var Wp=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,fT=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,Rv=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,pT=/\\([\u000b\u0020-\u00ff])/g,gT=/([\\"])/g,Iv=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;sf.format=mT;sf.parse=yT;function mT(n){if(!n||typeof n!="object")throw new TypeError("argument obj is required");var e=n.parameters,t=n.type;if(!t||!Iv.test(t))throw new TypeError("invalid type");var r=t;if(e&&typeof e=="object")for(var i,s=Object.keys(e).sort(),o=0;o<s.length;o++){if(i=s[o],!Rv.test(i))throw new TypeError("invalid parameter name");r+="; "+i+"="+_T(e[i])}return r}function yT(n){if(!n)throw new TypeError("argument string is required");var e=typeof n=="object"?vT(n):n;if(typeof e!="string")throw new TypeError("argument string is required to be a string");var t=e.indexOf(";"),r=t!==-1?e.substr(0,t).trim():e.trim();if(!Iv.test(r))throw new TypeError("invalid media type");var i=new ET(r.toLowerCase());if(t!==-1){var s,o,c;for(Wp.lastIndex=t;o=Wp.exec(e);){if(o.index!==t)throw new TypeError("invalid parameter format");t+=o[0].length,s=o[1].toLowerCase(),c=o[2],c[0]==='"'&&(c=c.substr(1,c.length-2).replace(pT,"$1")),i.parameters[s]=c}if(t!==e.length)throw new TypeError("invalid parameter format")}return i}function vT(n){var e;if(typeof n.getHeader=="function"?e=n.getHeader("content-type"):typeof n.headers=="object"&&(e=n.headers&&n.headers["content-type"]),typeof e!="string")throw new TypeError("content-type header is missing from object");return e}function _T(n){var e=String(n);if(Rv.test(e))return e;if(e.length>0&&!fT.test(e))throw new TypeError("invalid parameter value");return'"'+e.replace(gT,"\\$1")+'"'}function ET(n){this.parameters=Object.create(null),this.type=n}var tc={};Object.defineProperty(tc,"__esModule",{value:!0});tc.clearTimeout=OT;tc.setNow=IT;tc.setTimeout=TT;var ST=ie;const bT=1e3;let wT=0,Uu;const Jn=[],RT=function(...n){};function IT(n){Ll=n||Date.now}let Ll=Date.now;function TT(n,e,...t){e=e||0,e<0&&(e=0);const r=Ll()+e,i=wT++,s={runAt:r,func:n,params:t,key:i},o=CT(Jn,function(c){return c.runAt-r});return Jn.splice(o,0,s),of(),i}function OT(n){if(Jn.length===0)return;let e;for(e=0;e<Jn.length;e++)if(Jn[e].key==n){Jn.splice(e,1);break}e===0&&of()}function of(){Uu&&j.clearTimeout(Uu);const n=Jn[0];if(!n)return;const e=Ll(),t=Math.min(n.runAt-e,bT);Uu=j.setTimeout(kT,t)}function kT(){let n;const e=Ll(),t=[];for(;;){const r=Jn[0];if(!r||r.runAt>e)break;n=Jn.shift(),RT("runCallbacks: popping",n.key),t.push(n)}of();for(let r=0;r<t.length;r++){n=t[r];try{n.func.apply(j,n.params)}catch(i){ST.logger.error("Uncaught exception in callback function",i.stack||i)}}}function CT(n,e){let t=0,r=n.length;for(;t<r;){const i=t+r>>1;e(n[i])>0?r=i:t=i+1}return t}var PT=V.exports;Object.defineProperty(me,"__esModule",{value:!0});me.PREFIX_V1=me.PREFIX_UNSTABLE=me.PREFIX_R0=me.PREFIX_MEDIA_R0=me.PREFIX_IDENTITY_V2=me.PREFIX_IDENTITY_V1=me.Method=me.MatrixHttpApi=me.MatrixError=me.HttpApiEvent=me.ConnectionError=me.AbortError=void 0;me.retryNetworkOperation=FT;var ka=PT(Y.exports),MT=sf,qi=Ov(tc),vi=Ov(G),Qc=ie;function Tv(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(Tv=function(r){return r?t:e})(n)}function Ov(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=Tv(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}function Hp(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function Yp(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Hp(Object(t),!0).forEach(function(r){(0,ka.default)(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Hp(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}const AT="/_matrix/client/r0";me.PREFIX_R0=AT;const DT="/_matrix/client/v1";me.PREFIX_V1=DT;const UT="/_matrix/client/unstable";me.PREFIX_UNSTABLE=UT;const $T="/_matrix/identity/api/v1";me.PREFIX_IDENTITY_V1=$T;const xT="/_matrix/identity/v2";me.PREFIX_IDENTITY_V2=xT;const NT="/_matrix/media/r0";me.PREFIX_MEDIA_R0=NT;let Ba;me.Method=Ba;(function(n){n.Get="GET",n.Put="PUT",n.Post="POST",n.Delete="DELETE"})(Ba||(me.Method=Ba={}));let Ka;me.HttpApiEvent=Ka;(function(n){n.SessionLoggedOut="Session.logged_out",n.NoConsent="no_consent"})(Ka||(me.HttpApiEvent=Ka={}));class LT{constructor(e,t){this.eventEmitter=e,this.opts=t,(0,ka.default)(this,"uploads",[]),vi.checkObjectHasKeys(t,["baseUrl","request","prefix"]),t.onlyData=!!t.onlyData,t.useAuthorizationHeader=!!t.useAuthorizationHeader}setIdBaseUrl(e){this.opts.idBaseUrl=e}getContentUri(){return{base:this.opts.baseUrl,path:"/_matrix/media/r0/upload",params:{access_token:this.opts.accessToken}}}uploadContent(e,t){vi.isFunction(t)?t={callback:t}:t||(t={});const r=t.includeFilename!==!1,i=t.type||e.type||"application/octet-stream",s=t.name||e.name;let o=e;const c=o.stream;c&&typeof c!="function"&&(Qc.logger.warn("Using `file.stream` as the content to upload. Future versions of the js-sdk will change this to expect `file` to be the content directly."),o=c);let l=t.rawResponse;l===void 0&&(j.XMLHttpRequest?l=!1:(Qc.logger.warn("Returning the raw JSON from uploadContent(). Future versions of the js-sdk will change this default, to return the parsed object. Set opts.rawResponse=false to change this behaviour now."),l=!0));let u=t.onlyContentUri;!l&&u===void 0&&(j.XMLHttpRequest?(Qc.logger.warn("Returning only the content-uri from uploadContent(). Future versions of the js-sdk will change this default, to return the whole response object. Set opts.onlyContentUri=false to change this behaviour now."),u=!0):u=!1);const a={loaded:0,total:0};let g,m=null;if(l||(m=function(p){let E=JSON.parse(p);if(u&&(E=E.content_uri,E===void 0))throw Error("Bad response");return E}),j.XMLHttpRequest){const p=vi.defer(),E=new j.XMLHttpRequest,I=$u(p,t.callback,this.opts.onlyData),w=function(){E.abort(),I(new Error("Timeout"))};let k=qi.setTimeout(w,3e4);E.onreadystatechange=function(){let T;switch(E.readyState){case j.XMLHttpRequest.DONE:qi.clearTimeout(k);try{if(E.status===0)throw new kv;if(!E.responseText)throw new Error("No response body.");T=E.responseText,m&&(T=m(T))}catch(D){D.http_status=E.status,I(D);return}I(void 0,E,T);break}},E.upload.addEventListener("progress",function(T){qi.clearTimeout(k),a.loaded=T.loaded,a.total=T.total,k=qi.setTimeout(w,3e4),t.progressHandler&&t.progressHandler({loaded:T.loaded,total:T.total})});let P=this.opts.baseUrl+"/_matrix/media/r0/upload";const S=[];r&&s&&S.push("filename="+encodeURIComponent(s)),this.opts.useAuthorizationHeader||S.push("access_token="+encodeURIComponent(this.opts.accessToken)),S.length>0&&(P+="?"+S.join("&")),E.open("POST",P),this.opts.useAuthorizationHeader&&E.setRequestHeader("Authorization","Bearer "+this.opts.accessToken),E.setRequestHeader("Content-Type",i),E.send(o),g=p.promise,g.abort=E.abort.bind(E)}else{const p={};r&&s&&(p.filename=s);const E={"Content-Type":i};o.length===0&&(E["Content-Length"]="0"),g=this.authedRequest(t.callback,Ba.Post,"/upload",p,o,{prefix:"/_matrix/media/r0",headers:E,json:!1,bodyParser:m})}return a.promise=g.finally(()=>{for(let p=0;p<this.uploads.length;++p)if(this.uploads[p]===a){this.uploads.splice(p,1);return}}),a.promise.abort=g.abort,this.uploads.push(a),a.promise}cancelUpload(e){return e.abort?(e.abort(),!0):!1}getCurrentUploads(){return this.uploads}idServerRequest(e,t,r,i,s,o){if(!this.opts.idBaseUrl)throw new Error("No identity server base URL set");const c=this.opts.idBaseUrl+s+r;if(e!==void 0&&!vi.isFunction(e))throw Error("Expected callback to be a function but got "+typeof e);const l={uri:c,method:t,withCredentials:!1,json:!0,_matrix_opts:this.opts,headers:{}};t===Ba.Get?l.qs=i:typeof i=="object"&&(l.json=i),o&&(l.headers.Authorization=`Bearer ${o}`);const u=vi.defer();return this.opts.request(l,$u(u,e,this.opts.onlyData)),u.promise}authedRequest(e,t,r,i,s,o){i||(i={});let c=o||{};this.opts.useAuthorizationHeader?(isFinite(o)&&(c={localTimeoutMs:o}),c.headers||(c.headers={}),c.headers.Authorization||(c.headers.Authorization="Bearer "+this.opts.accessToken),i.access_token&&delete i.access_token):i.access_token||(i.access_token=this.opts.accessToken);const l=this.request(e,t,r,i,s,c);return l.catch(u=>{var a;u.errcode=="M_UNKNOWN_TOKEN"&&!((a=c)!==null&&a!==void 0&&a.inhibitLogoutEmit)?this.eventEmitter.emit(Ka.SessionLoggedOut,u):u.errcode=="M_CONSENT_NOT_GIVEN"&&this.eventEmitter.emit(Ka.NoConsent,u.message,u.data.consent_uri)}),l}request(e,t,r,i,s,o){var c;const l=(c=o==null?void 0:o.prefix)!==null&&c!==void 0?c:this.opts.prefix,u=this.opts.baseUrl+l+r;return this.requestOtherUrl(e,t,u,i,s,o)}requestOtherUrl(e,t,r,i,s,o){let c=o||{};return isFinite(o)&&(c={localTimeoutMs:o}),this.doRequest(e,t,r,i,s,c)}getUrl(e,t,r){let i="";return t&&(i="?"+vi.encodeParams(t)),this.opts.baseUrl+r+e+i}doRequest(e,t,r,i,s,o){var c;if(e!==void 0&&!vi.isFunction(e))throw Error("Expected callback to be a function but got "+typeof e);this.opts.extraParams&&(i=Yp(Yp({},i||{}),this.opts.extraParams));const l=Object.assign({},o.headers||{});o||(o={});const u=(c=o.json)!==null&&c!==void 0?c:!0;let a=o.bodyParser;u&&(s&&(s=JSON.stringify(s),l["content-type"]="application/json"),l.accept||(l.accept="application/json"),a===void 0&&(a=function(P){return JSON.parse(P)}));const g=vi.defer();let m,p=!1,E;const I=o.localTimeoutMs||this.opts.localTimeoutMs,w=()=>{I&&(m&&qi.clearTimeout(m),m=qi.setTimeout(function(){var P,S;p=!0,(P=E)===null||P===void 0||(S=P.abort)===null||S===void 0||S.call(P),g.reject(new Bl({error:"Locally timed out waiting for a response",errcode:"ORG.MATRIX.JSSDK_TIMEOUT",timeout:I}))},I))};w();const k=g.promise;try{E=this.opts.request({uri:r,method:t,withCredentials:!1,qs:i,qsStringifyOptions:o.qsStringifyOptions,useQuerystring:!0,body:s,json:!1,timeout:I,headers:l||{},_matrix_opts:this.opts},(P,S,T)=>{if(I&&(qi.clearTimeout(m),p))return;$u(g,e,this.opts.onlyData,a)(P,S,T)}),E&&("onprogress"in E&&(E.onprogress=P=>{w()}),E.abort&&(k.abort=E.abort.bind(E)))}catch(P){g.reject(P),e&&e(P)}return k}}me.MatrixHttpApi=LT;function ah(n){return n.status||n.statusCode}function $u(n,e,t=!1,r){return function(i,s,o){i&&!(i.name==="AbortError"||i==="aborted")&&!(i instanceof Bl)&&(i=new af("request failed",i));let c=o;if(!i)try{ah(s)>=400?i=BT(s,o):r&&(c=r(o))}catch(l){i=new Error(`Error parsing server response: ${l}`)}if(i)n.reject(i),e==null||e(i);else if(t)n.resolve(c),e==null||e(null,c);else{const l={code:ah(s),headers:s.headers,data:c};n.resolve(l),e==null||e(null,l)}}}function BT(n,e){const t=ah(n),r=KT(n);let i;if(r)if(r.type==="application/json"){const s=typeof e=="object"?e:JSON.parse(e);i=new Bl(s)}else r.type==="text/plain"&&(i=new Error(`Server returned ${t} error: ${e}`));return i||(i=new Error(`Server returned ${t} error`)),i.httpStatus=t,i}function KT(n){let e;if(n.getResponseHeader?e=n.getResponseHeader("Content-Type"):n.headers&&(e=n.headers["content-type"]||null),!e)return null;try{return(0,MT.parse)(e)}catch(t){throw new Error(`Error parsing Content-Type '${e}': ${t}`)}}class Bl extends Error{constructor(e={}){super(`MatrixError: ${e.errcode}`);(0,ka.default)(this,"errcode",void 0),(0,ka.default)(this,"data",void 0),(0,ka.default)(this,"httpStatus",void 0),this.errcode=e.errcode,this.name=e.errcode||"Unknown error code",this.message=e.error||"Unknown message",this.data=e}}me.MatrixError=Bl;class af extends Error{constructor(e,t=void 0){super(e+(t?`: ${t.message}`:""))}get name(){return"ConnectionError"}}me.ConnectionError=af;class kv extends Error{constructor(){super("Operation aborted")}get name(){return"AbortError"}}me.AbortError=kv;async function FT(n,e){let t=0,r=null;for(;t<n;)try{if(t>0){const i=1e3*Math.pow(2,t);Qc.logger.log(`network operation failed ${t} times, retrying in ${i}ms...`),await new Promise(s=>setTimeout(s,i))}return await e()}catch(i){if(i instanceof af)t+=1,r=i;else throw i}throw r}var qT=V.exports;Object.defineProperty(ar,"__esModule",{value:!0});ar.RoomEvent=ar.Room=ar.NotificationCountType=void 0;var Re=qT(Y.exports),xu=ei,Yt=Ft,jT=Mo,zo=JT(G),Zc=qt,Pe=No,VT=tn,GT=ec,ht=ie,WT=nn,$e=ne,_i=it,HT=Cs,Or=ct,YT=me,zT=qe;function Cv(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(Cv=function(r){return r?t:e})(n)}function JT(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=Cv(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}function zp(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function Jp(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?zp(Object(t),!0).forEach(function(r){(0,Re.default)(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):zp(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}const Xp="6",Qp=["1","2","3","4","5","6"];function Zp(n,e,t){return new Zc.MatrixEvent({content:{[e.getId()]:{[t]:{[n]:{ts:e.getTs()}}}},type:"m.receipt",room_id:e.getRoomId()})}const xs=0,Ns=1,XT=30;let El;ar.NotificationCountType=El;(function(n){n.Highlight="highlight",n.Total="total"})(El||(ar.NotificationCountType=El={}));let nt;ar.RoomEvent=nt;(function(n){n.MyMembership="Room.myMembership",n.Tags="Room.tags",n.AccountData="Room.accountData",n.Receipt="Room.receipt",n.Name="Room.name",n.Redaction="Room.redaction",n.RedactionCancelled="Room.redactionCancelled",n.LocalEchoUpdated="Room.localEchoUpdated",n.Timeline="Room.timeline",n.TimelineReset="Room.timelineReset"})(nt||(ar.RoomEvent=nt={}));class QT extends zT.TypedEventEmitter{constructor(e,t,r,i={}){super();if(this.roomId=e,this.client=t,this.myUserId=r,this.opts=i,(0,Re.default)(this,"reEmitter",void 0),(0,Re.default)(this,"txnToEvent",{}),(0,Re.default)(this,"receipts",{}),(0,Re.default)(this,"receiptCacheByEventId",{}),(0,Re.default)(this,"notificationCounts",{}),(0,Re.default)(this,"timelineSets",void 0),(0,Re.default)(this,"threadsTimelineSets",[]),(0,Re.default)(this,"filteredTimelineSets",{}),(0,Re.default)(this,"pendingEventList",void 0),(0,Re.default)(this,"blacklistUnverifiedDevices",null),(0,Re.default)(this,"selfMembership",null),(0,Re.default)(this,"summaryHeroes",null),(0,Re.default)(this,"getTypeWarning",!1),(0,Re.default)(this,"getVersionWarning",!1),(0,Re.default)(this,"membersPromise",void 0),(0,Re.default)(this,"name",void 0),(0,Re.default)(this,"normalizedName",void 0),(0,Re.default)(this,"tags",{}),(0,Re.default)(this,"accountData",{}),(0,Re.default)(this,"summary",null),(0,Re.default)(this,"storageToken",void 0),(0,Re.default)(this,"timeline",void 0),(0,Re.default)(this,"oldState",void 0),(0,Re.default)(this,"currentState",void 0),(0,Re.default)(this,"threads",new Map),(0,Re.default)(this,"lastThread",void 0),(0,Re.default)(this,"visibilityEvents",new Map),(0,Re.default)(this,"threadTimelineSetsPromise",null),this.setMaxListeners(100),this.reEmitter=new WT.TypedReEmitter(this),i.pendingEventOrdering=i.pendingEventOrdering||_i.PendingEventOrdering.Chronological,this.name=e,this.timelineSets=[new xu.EventTimelineSet(this,i)],this.reEmitter.reEmit(this.getUnfilteredTimelineSet(),[nt.Timeline,nt.TimelineReset]),this.fixUpLegacyTimelineFields(),this.opts.pendingEventOrdering===_i.PendingEventOrdering.Detached){this.pendingEventList=[];const s=t.sessionStore.store.getItem(Nu(this.roomId));s&&JSON.parse(s).forEach(async o=>{const c=new Zc.MatrixEvent(o);c.getType()===$e.EventType.RoomMessageEncrypted&&await c.attemptDecryption(this.client.crypto),c.setStatus(Pe.EventStatus.NOT_SENT),this.addPendingEvent(c,c.getTxnId())})}this.opts.lazyLoadMembers?this.membersPromise=null:this.membersPromise=Promise.resolve(!1)}async createThreadsTimelineSets(){var e;if(this.threadTimelineSetsPromise)return this.threadTimelineSetsPromise;if((e=this.client)!==null&&e!==void 0&&e.supportsExperimentalThreads)try{this.threadTimelineSetsPromise=Promise.all([this.createThreadTimelineSet(),this.createThreadTimelineSet(Or.ThreadFilterType.My)]);const t=await this.threadTimelineSetsPromise;this.threadsTimelineSets.push(...t)}catch{this.threadTimelineSetsPromise=null}}decryptCriticalEvents(){const e=this.getEventReadUpTo(this.client.getUserId(),!0),t=this.getLiveTimeline().getEvents(),r=t.findIndex(s=>s.event.event_id===e),i=t.slice(r).filter(s=>s.shouldAttemptDecryption()).reverse().map(s=>s.attemptDecryption(this.client.crypto,{isRetry:!0}));return Promise.allSettled(i)}decryptAllEvents(){const e=this.getUnfilteredTimelineSet().getLiveTimeline().getEvents().filter(t=>t.shouldAttemptDecryption()).reverse().map(t=>t.attemptDecryption(this.client.crypto,{isRetry:!0}));return Promise.allSettled(e)}getVersion(){const e=this.currentState.getStateEvents($e.EventType.RoomCreate,"");if(!e)return this.getVersionWarning||(ht.logger.warn("[getVersion] Room "+this.roomId+" does not have an m.room.create event"),this.getVersionWarning=!0),"1";const t=e.getContent().room_version;return t===void 0?"1":t}shouldUpgradeToVersion(){return Qp.includes(this.getVersion())?null:Xp}async getRecommendedVersion(){let t=(await this.client.getCapabilities())["m.room_versions"];if(!t){t={default:Xp,available:{}};for(const i of Qp)t.available[i]=_i.RoomVersionStability.Stable}let r=this.checkVersionAgainstCapability(t);if(r.urgent&&r.needsUpgrade)if(ht.logger.warn("Refreshing room version capability because the server looks to be supporting a newer room version we don't know about."),t=(await this.client.getCapabilities(!0))["m.room_versions"],t)r=this.checkVersionAgainstCapability(t);else return ht.logger.warn("No room version capability - assuming upgrade required."),r;return r}checkVersionAgainstCapability(e){const t=this.getVersion();ht.logger.log(`[${this.roomId}] Current version: ${t}`),ht.logger.log(`[${this.roomId}] Version capability: `,e);const r={version:t,needsUpgrade:!1,urgent:!1};return t===e.default||Object.keys(e.available).filter(s=>e.available[s]==="stable").includes(t)||(r.version=e.default,r.needsUpgrade=!0,r.urgent=!!this.getVersion().match(/^[0-9]+[0-9.]*$/g),r.urgent?ht.logger.warn(`URGENT upgrade required on ${this.roomId}`):ht.logger.warn(`Non-urgent upgrade required on ${this.roomId}`)),r}userMayUpgradeRoom(e){return this.currentState.maySendStateEvent($e.EventType.RoomTombstone,e)}getPendingEvents(){if(this.opts.pendingEventOrdering!==_i.PendingEventOrdering.Detached)throw new Error("Cannot call getPendingEvents with pendingEventOrdering == "+this.opts.pendingEventOrdering);return this.pendingEventList}removePendingEvent(e){if(this.opts.pendingEventOrdering!==_i.PendingEventOrdering.Detached)throw new Error("Cannot call removePendingEvent with pendingEventOrdering == "+this.opts.pendingEventOrdering);const t=zo.removeElement(this.pendingEventList,function(r){return r.getId()==e},!1);return this.savePendingEvents(),t}hasPendingEvent(e){return this.opts.pendingEventOrdering!==_i.PendingEventOrdering.Detached?!1:this.pendingEventList.some(t=>t.getId()===e)}getPendingEvent(e){return this.opts.pendingEventOrdering!==_i.PendingEventOrdering.Detached?null:this.pendingEventList.find(t=>t.getId()===e)}getLiveTimeline(){return this.getUnfilteredTimelineSet().getLiveTimeline()}getLastActiveTimestamp(){const t=this.getLiveTimeline().getEvents();return t.length?t[t.length-1].getTs():Number.MIN_SAFE_INTEGER}getMyMembership(){return this.selfMembership}getDMInviter(){if(this.myUserId){const e=this.getMember(this.myUserId);if(e)return e.getDMInviter()}if(this.selfMembership==="invite"&&this.getInvitedAndJoinedMemberCount()==2&&this.summaryHeroes.length)return this.summaryHeroes[0]}guessDMUserId(){const e=this.getMember(this.myUserId);if(e){const s=e.getDMInviter();if(s)return s}if(Array.isArray(this.summaryHeroes)&&this.summaryHeroes.length)return this.summaryHeroes[0];const i=this.currentState.getMembers().find(s=>s.userId!==this.myUserId);return i?i.userId:this.myUserId}getAvatarFallbackMember(){if(this.getInvitedAndJoinedMemberCount()>2)return;const t=Array.isArray(this.summaryHeroes)&&this.summaryHeroes.length;if(t){const i=this.summaryHeroes.map(s=>this.getMember(s)).find(s=>!!s);if(i)return i}const r=this.currentState.getMembers();if(r.length<=2){const i=r.find(s=>s.userId!==this.myUserId);if(i)return i}if(t){const i=this.summaryHeroes.map(s=>this.client.getUser(s)).find(s=>!!s);if(i){const s=new VT.RoomMember(this.roomId,i.userId);return s.user=i,s}}}updateMyMembership(e){const t=this.selfMembership;this.selfMembership=e,t!==e&&(e==="leave"&&this.cleanupAfterLeaving(),this.emit(nt.MyMembership,this,e,t))}async loadMembersFromServer(){const e=this.client.store.getSyncToken(),t=zo.encodeParams({not_membership:"leave",at:e}),r=zo.encodeUri("/rooms/$roomId/members?"+t,{$roomId:this.roomId});return(await this.client.http.authedRequest(void 0,YT.Method.Get,r)).chunk}async loadMembers(){let e=!1,t=await this.client.store.getOutOfBandMembers(this.roomId);return(t===null||this.client.isCryptoEnabled()&&this.client.isRoomEncrypted(this.roomId))&&(e=!0,t=await this.loadMembersFromServer(),ht.logger.log(`LL: got ${t.length} members from server for room ${this.roomId}`)),{memberEvents:t.map(this.client.getEventMapper()),fromServer:e}}loadMembersIfNeeded(){if(this.membersPromise)return this.membersPromise;this.currentState.markOutOfBandMembersStarted();const e=this.loadMembers().then(t=>(this.currentState.setOutOfBandMembers(t.memberEvents),this.client.isCryptoEnabled()&&this.client.isRoomEncrypted(this.roomId)&&this.client.crypto.trackRoomDevices(this.roomId),t.fromServer)).catch(t=>{throw this.membersPromise=null,this.currentState.markOutOfBandMembersFailed(),t});return e.then(t=>{if(t){const r=this.currentState.getMembers().filter(s=>s.isOutOfBand()).map(s=>s.events.member.event);return ht.logger.log(`LL: telling store to write ${r.length} members for room ${this.roomId}`),this.client.store.setOutOfBandMembers(this.roomId,r).catch(s=>{ht.logger.log("LL: storing OOB room members failed, oh well",s)})}}).catch(t=>{ht.logger.error(t)}),this.membersPromise=e,this.membersPromise}async clearLoadedMembersIfNeeded(){this.opts.lazyLoadMembers&&this.membersPromise&&(await this.loadMembersIfNeeded(),await this.client.store.clearOutOfBandMembers(this.roomId),this.currentState.clearOutOfBandMembers(),this.membersPromise=null)}cleanupAfterLeaving(){this.clearLoadedMembersIfNeeded().catch(e=>{ht.logger.error(`error after clearing loaded members from room ${this.roomId} after leaving`),ht.logger.log(e)})}resetLiveTimeline(e,t){for(let r=0;r<this.timelineSets.length;r++)this.timelineSets[r].resetLiveTimeline(e,t);this.fixUpLegacyTimelineFields()}fixUpLegacyTimelineFields(){this.timeline=this.getLiveTimeline().getEvents(),this.oldState=this.getLiveTimeline().getState(Yt.EventTimeline.BACKWARDS),this.currentState=this.getLiveTimeline().getState(Yt.EventTimeline.FORWARDS)}async hasUnverifiedDevices(){if(!this.client.isRoomEncrypted(this.roomId))return!1;const e=await this.getEncryptionTargetMembers();for(const t of e)if(this.client.getStoredDevicesForUser(t.userId).some(i=>i.isUnverified()))return!0;return!1}getTimelineSets(){return this.timelineSets}getUnfilteredTimelineSet(){return this.timelineSets[0]}getTimelineForEvent(e){const t=this.findEventById(e),r=this.findThreadForEvent(t);return r?r.timelineSet.getLiveTimeline():this.getUnfilteredTimelineSet().getTimelineForEvent(e)}addTimeline(){return this.getUnfilteredTimelineSet().addTimeline()}findEventById(e){let t=this.getUnfilteredTimelineSet().findEventById(e);if(t)return t;{const r=this.getThreads();for(let i=0;i<r.length;i++)if(t=r[i].findEventById(e),t)return t}}getUnreadNotificationCount(e=El.Total){return this.notificationCounts[e]}setUnreadNotificationCount(e,t){this.notificationCounts[e]=t}setSummary(e){const t=e["m.heroes"],r=e["m.joined_member_count"],i=e["m.invited_member_count"];Number.isInteger(r)&&this.currentState.setJoinedMemberCount(r),Number.isInteger(i)&&this.currentState.setInvitedMemberCount(i),Array.isArray(t)&&(this.summaryHeroes=t.filter(s=>s!==this.myUserId))}setBlacklistUnverifiedDevices(e){this.blacklistUnverifiedDevices=e}getBlacklistUnverifiedDevices(){return this.blacklistUnverifiedDevices}getAvatarUrl(e,t,r,i,s=!0){const o=this.currentState.getStateEvents($e.EventType.RoomAvatar,"");if(!o&&!s)return null;const c=o?o.getContent().url:null;return c?(0,jT.getHttpUriForMxc)(e,c,t,r,i):null}getMxcAvatarUrl(){var e,t;return((e=this.currentState.getStateEvents($e.EventType.RoomAvatar,""))===null||e===void 0||(t=e.getContent())===null||t===void 0?void 0:t.url)||null}getAliases(){const e=[],t=this.currentState.getStateEvents($e.EventType.RoomAliases);if(t)for(let r=0;r<t.length;++r){const i=t[r];if(Array.isArray(i.getContent().aliases)){const s=i.getContent().aliases.filter(o=>!(typeof o!="string"||o[0]!=="#"||!o.endsWith(`:${i.getStateKey()}`)));Array.prototype.push.apply(e,s)}}return e}getCanonicalAlias(){const e=this.currentState.getStateEvents($e.EventType.RoomCanonicalAlias,"");return e&&e.getContent().alias||null}getAltAliases(){const e=this.currentState.getStateEvents($e.EventType.RoomCanonicalAlias,"");return e?e.getContent().alt_aliases||[]:[]}addEventsToTimeline(e,t,r,i){r.getTimelineSet().addEventsToTimeline(e,t,r,i)}getThread(e){return this.getThreads().find(t=>t.id===e)}getThreads(){return Array.from(this.threads.values())}getMember(e){return this.currentState.getMember(e)}getMembers(){return this.currentState.getMembers()}getJoinedMembers(){return this.getMembersWithMembership("join")}getJoinedMemberCount(){return this.currentState.getJoinedMemberCount()}getInvitedMemberCount(){return this.currentState.getInvitedMemberCount()}getInvitedAndJoinedMemberCount(){return this.getInvitedMemberCount()+this.getJoinedMemberCount()}getMembersWithMembership(e){return this.currentState.getMembers().filter(function(t){return t.membership===e})}async getEncryptionTargetMembers(){await this.loadMembersIfNeeded();let e=this.getMembersWithMembership("join");return this.shouldEncryptForInvitedMembers()&&(e=e.concat(this.getMembersWithMembership("invite"))),e}shouldEncryptForInvitedMembers(){var e;const t=this.currentState.getStateEvents($e.EventType.RoomHistoryVisibility,"");return(t==null||(e=t.getContent())===null||e===void 0?void 0:e.history_visibility)!=="joined"}getDefaultRoomName(e){return this.calculateRoomName(e,!0)}hasMembershipState(e,t){const r=this.getMember(e);return r?r.membership===t:!1}getOrCreateFilteredTimelineSet(e,{prepopulateTimeline:t=!0,pendingEvents:r=!0}={}){if(this.filteredTimelineSets[e.filterId])return this.filteredTimelineSets[e.filterId];const i=Object.assign({filter:e,pendingEvents:r},this.opts),s=new xu.EventTimelineSet(this,i);this.reEmitter.reEmit(s,[nt.Timeline,nt.TimelineReset]),this.filteredTimelineSets[e.filterId]=s,this.timelineSets.push(s);const o=this.getLiveTimeline();if(t){o.getEvents().forEach(function(l){s.addLiveEvent(l)});let c=o;for(;c.getNeighbouringTimeline(Yt.EventTimeline.BACKWARDS);)c=c.getNeighbouringTimeline(Yt.EventTimeline.BACKWARDS);s.getLiveTimeline().setPaginationToken(c.getPaginationToken(Yt.EventTimeline.BACKWARDS),Yt.EventTimeline.BACKWARDS)}else{const c=o.getPaginationToken(Yt.Direction.Forward);s.getLiveTimeline().setPaginationToken(c,Yt.Direction.Backward)}return s}async createThreadTimelineSet(e){let t;if(Or.Thread.hasServerSideSupport){const r=this.client.getUserId(),i=new HT.Filter(r),s={room:{timeline:{[Or.FILTER_RELATED_BY_REL_TYPES.name]:[Or.THREAD_RELATION_TYPE.name]}}};e===Or.ThreadFilterType.My&&(s.room.timeline[Or.FILTER_RELATED_BY_SENDERS.name]=[r]),i.setDefinition(s);const o=await this.client.getOrCreateFilter(`THREAD_PANEL_${this.roomId}_${e}`,i);i.filterId=o,t=this.getOrCreateFilteredTimelineSet(i,{prepopulateTimeline:!1,pendingEvents:!1}),t.getLiveTimeline().setPaginationToken("",Yt.EventTimeline.BACKWARDS)}else t=new xu.EventTimelineSet(this,{pendingEvents:!1}),Array.from(this.threads).forEach(([,r])=>{if(r.length===0)return;const i=r.events.some(s=>s.getSender()===this.client.getUserId());(e!==Or.ThreadFilterType.My||i)&&t.getLiveTimeline().addEvent(r.rootEvent,!1)});return t}removeFilteredTimelineSet(e){const t=this.filteredTimelineSets[e.filterId];delete this.filteredTimelineSets[e.filterId];const r=this.timelineSets.indexOf(t);r>-1&&this.timelineSets.splice(r,1)}findThreadForEvent(e){if(!e)return null;if(e.isThreadRelation)return this.threads.get(e.threadRootId);if(e.isThreadRoot)return this.threads.get(e.getId());{const t=this.findEventById(e.getAssociatedId());return this.findThreadForEvent(t)}}async addThreadedEvent(e,t){this.applyRedaction(e);let r=this.findThreadForEvent(e);if(r)r.addEvent(e,t);else{const i=[e];let s=this.findEventById(e.threadRootId);try{let o;e.threadRootId&&(o=await this.client.fetchRoomEvent(this.roomId,e.threadRootId)),s?s.setUnsigned(o.unsigned):s=new Zc.MatrixEvent(o)}finally{r=this.createThread(s,i,t)}}this.emit(Or.ThreadEvent.Update,r)}createThread(e,t=[],r){if(e){const o=this.getTimelineForEvent(e.getId()),c=o==null?void 0:o.getTimelineSet().getAllRelationsEventForEvent(e.getId());c&&(t=t.concat(c))}const i=new Or.Thread(e,{initialEvents:t,room:this,client:this.client});if(i.id){var s;return this.threads.set(i.id,i),this.reEmitter.reEmit(i,[Or.ThreadEvent.Update,nt.Timeline,nt.TimelineReset]),(!this.lastThread||((s=this.lastThread.rootEvent)===null||s===void 0?void 0:s.localTimestamp)<(e==null?void 0:e.localTimestamp))&&(this.lastThread=i),this.emit(Or.ThreadEvent.New,i,r),this.threadsTimelineSets.forEach(o=>{i.rootEvent&&(Or.Thread.hasServerSideSupport?o.addLiveEvent(i.rootEvent):o.addEventToTimeline(i.rootEvent,o.getLiveTimeline(),r))}),i}}applyRedaction(e){if(e.isRedaction()){const t=e.event.redacts,r=this.findEventById(t);r&&(r.makeRedacted(e),r.getStateKey()&&this.currentState.getStateEvents(r.getType(),r.getStateKey()).getId()===r.getId()&&this.currentState.setStateEvents([r]),this.emit(nt.Redaction,e,this),this.visibilityEvents.delete(t),r.isVisibilityEvent()&&this.redactVisibilityChangeEvent(e))}}addLiveEvent(e,t,r=!1){if(this.applyRedaction(e),e.isVisibilityEvent()&&this.applyNewVisibilityEvent(e),this.applyPendingVisibilityEvents(e),e.getUnsigned().transaction_id){const i=this.txnToEvent[e.getUnsigned().transaction_id];if(i){this.handleRemoteEcho(e,i);return}}for(let i=0;i<this.timelineSets.length;i++)this.timelineSets[i].addLiveEvent(e,t,r);e.sender&&e.getType()!==$e.EventType.RoomRedaction&&this.addReceipt(Zp(e.sender.userId,e,"m.read"),!0)}addPendingEvent(e,t){if(e.status!==Pe.EventStatus.SENDING&&e.status!==Pe.EventStatus.NOT_SENT)throw new Error("addPendingEvent called on an event with status "+e.status);if(this.txnToEvent[t])throw new Error("addPendingEvent called on an event with known txnId "+t);if(Yt.EventTimeline.setEventMetadata(e,this.getLiveTimeline().getState(Yt.EventTimeline.FORWARDS),!1),this.txnToEvent[t]=e,this.opts.pendingEventOrdering===_i.PendingEventOrdering.Detached){if(this.pendingEventList.some(i=>i.status===Pe.EventStatus.NOT_SENT)&&(ht.logger.warn("Setting event as NOT_SENT due to messages in the same state"),e.setStatus(Pe.EventStatus.NOT_SENT)),this.pendingEventList.push(e),this.savePendingEvents(),e.isRelation()&&this.aggregateNonLiveRelation(e),e.isRedaction()){var r;const i=e.event.redacts;let s=(r=this.pendingEventList)===null||r===void 0?void 0:r.find(o=>o.getId()===i);s||(s=this.findEventById(i)),s&&(s.markLocallyRedacted(e),this.emit(nt.Redaction,e,this))}}else for(let i=0;i<this.timelineSets.length;i++){const s=this.timelineSets[i];s.getFilter()?s.getFilter().filterRoomTimeline([e]).length&&s.addEventToTimeline(e,s.getLiveTimeline(),!1):s.addEventToTimeline(e,s.getLiveTimeline(),!1)}this.emit(nt.LocalEchoUpdated,e,this,null,null)}savePendingEvents(){if(this.pendingEventList){const e=this.pendingEventList.map(r=>Jp(Jp({},r.event),{},{txn_id:r.getTxnId()})).filter(r=>{const i=r.type===$e.EventType.RoomMessageEncrypted,s=this.client.isRoomEncrypted(this.roomId);return i||!s}),{store:t}=this.client.sessionStore;this.pendingEventList.length>0?t.setItem(Nu(this.roomId),JSON.stringify(e)):t.removeItem(Nu(this.roomId))}}aggregateNonLiveRelation(e){const t=this.findThreadForEvent(e);if(t&&t.timelineSet.aggregateRelations(e),(t==null?void 0:t.id)===e.getAssociatedId()||!t)for(let r=0;r<this.timelineSets.length;r++){const i=this.timelineSets[r];i.getFilter()?i.getFilter().filterRoomTimeline([e]).length&&i.aggregateRelations(e):i.aggregateRelations(e)}}getEventForTxnId(e){return this.txnToEvent[e]}handleRemoteEcho(e,t){const r=t.getId(),i=e.getId(),s=t.status;ht.logger.debug(`Got remote echo for event ${r} -> ${i} old status ${s}`),delete this.txnToEvent[e.getUnsigned().transaction_id],this.pendingEventList&&this.removePendingEvent(r),t.handleRemoteEcho(e.event);const o=this.findThreadForEvent(e);if(o&&o.timelineSet.handleRemoteEcho(t,r,i),(o==null?void 0:o.id)===e.getAssociatedId()||!o)for(let c=0;c<this.timelineSets.length;c++)this.timelineSets[c].handleRemoteEcho(t,r,i);this.emit(nt.LocalEchoUpdated,t,this,r,s)}updatePendingEvent(e,t,r){if(ht.logger.log(`setting pendingEvent status to ${t} in ${e.getRoomId()} event ID ${e.getId()} -> ${r}`),t==Pe.EventStatus.SENT&&!r)throw new Error("updatePendingEvent called with status=SENT, but no new event id");if(t==Pe.EventStatus.SENT&&this.getTimelineForEvent(r))return;const i=e.status,s=e.getId();if(!i)throw new Error("updatePendingEventStatus called on an event which is not a local echo.");const o=ZT[i];if(!o||o.indexOf(t)<0)throw new Error("Invalid EventStatus transition "+i+"->"+t);if(e.setStatus(t),t==Pe.EventStatus.SENT){e.replaceLocalEventId(r);const c=this.findThreadForEvent(e);if(c&&c.timelineSet.replaceEventId(s,r),(c==null?void 0:c.id)===e.getAssociatedId()||!c)for(let l=0;l<this.timelineSets.length;l++)this.timelineSets[l].replaceEventId(s,r)}else if(t==Pe.EventStatus.CANCELLED){if(this.pendingEventList){const c=this.pendingEventList.findIndex(l=>l.getId()===s);if(c!==-1){const[l]=this.pendingEventList.splice(c,1);l.isRedaction()&&this.revertRedactionLocalEcho(l)}}this.removeEvent(s)}this.savePendingEvents(),this.emit(nt.LocalEchoUpdated,e,this,s,i)}revertRedactionLocalEcho(e){const t=e.event.redacts;if(!t)return;const r=this.getUnfilteredTimelineSet().findEventById(t);r&&(r.unmarkLocallyRedacted(),this.emit(nt.RedactionCancelled,e,this),r.isRelation()&&this.aggregateNonLiveRelation(r))}addLiveEvents(e,t,r=!1){let i;if(t&&["replace","ignore"].indexOf(t)===-1)throw new Error("duplicateStrategy MUST be either 'replace' or 'ignore'");for(i=0;i<this.timelineSets.length;i++){const s=this.timelineSets[i].getLiveTimeline();if(s.getPaginationToken(Yt.EventTimeline.FORWARDS))throw new Error("live timeline "+i+" is no longer live - it has a pagination token ("+s.getPaginationToken(Yt.EventTimeline.FORWARDS)+")");if(s.getNeighbouringTimeline(Yt.EventTimeline.FORWARDS))throw new Error("live timeline "+i+" is no longer live - it has a neighbouring timeline")}for(i=0;i<e.length;i++){this.addLiveEvent(e[i],t,r);const s=this.findThreadForEvent(e[i]);s&&s.addEvent(e[i],!0)}}addEphemeralEvents(e){for(const t of e)t.getType()==="m.typing"?this.currentState.setTypingEvent(t):t.getType()==="m.receipt"&&this.addReceipt(t)}removeEvents(e){for(let t=0;t<e.length;++t)this.removeEvent(e[t])}removeEvent(e){let t=!1;for(let r=0;r<this.timelineSets.length;r++){const i=this.timelineSets[r].removeEvent(e);i&&(i.isRedaction()&&this.revertRedactionLocalEcho(i),t=!0)}return t}recalculate(){const e=this.currentState.getStateEvents($e.EventType.RoomMember,this.myUserId);e&&e.getContent().membership==="invite"&&(e.getUnsigned().invite_room_state||[]).forEach(i=>{this.currentState.getStateEvents(i.type,i.state_key)||this.currentState.setStateEvents([new Zc.MatrixEvent({type:i.type,state_key:i.state_key,content:i.content,event_id:"$fake"+Date.now(),room_id:this.roomId,user_id:this.myUserId})])});const t=this.name;this.name=this.calculateRoomName(this.myUserId),this.normalizedName=(0,zo.normalize)(this.name),this.summary=new GT.RoomSummary(this.roomId,{title:this.name}),t!==this.name&&this.emit(nt.Name,this)}getUsersReadUpTo(e){return this.getReceiptsForEvent(e).filter(function(t){return t.type==="m.read"}).map(function(t){return t.userId})}getReadReceiptForUserId(e,t=!1){var r,i;const[s,o]=(r=(i=this.receipts["m.read"])===null||i===void 0?void 0:i[e])!==null&&r!==void 0?r:[];return t?s:o!=null?o:s}getEventReadUpTo(e,t=!1){var r;const i=this.getReadReceiptForUserId(e,t);return(r=i==null?void 0:i.eventId)!==null&&r!==void 0?r:null}hasUserReadEvent(e,t){const r=this.getEventReadUpTo(e,!1);if(r===t||this.timeline.length&&this.timeline[this.timeline.length-1].getSender()&&this.timeline[this.timeline.length-1].getSender()===e)return!0;for(let i=this.timeline.length-1;i>=0;--i){const s=this.timeline[i];if(s.getId()===t)return!1;if(s.getId()===r)return!0}return!1}getReceiptsForEvent(e){return this.receiptCacheByEventId[e.getId()]||[]}addReceipt(e,t=!1){this.addReceiptsToStructure(e,t),this.emit(nt.Receipt,e,this)}addReceiptsToStructure(e,t){const r=e.getContent();Object.keys(r).forEach(i=>{Object.keys(r[i]).forEach(s=>{Object.keys(r[i][s]).forEach(o=>{var c,l;const u=r[i][s][o];this.receipts[s]||(this.receipts[s]={}),this.receipts[s][o]||(this.receipts[s][o]=[null,null]);const a=this.receipts[s][o];let g=a[xs];if(t){var m;g=(m=a[Ns])!==null&&m!==void 0?m:a[xs]}if(g){const T=this.getUnfilteredTimelineSet().compareEventOrdering(g.eventId,i);if(T!==null&&T>=0)return}const p={eventId:i,data:u},E=t?a[xs]:p,I=t?p:a[Ns];let w=null;E&&I&&(w=this.getUnfilteredTimelineSet().compareEventOrdering(E.eventId,I.eventId));const k=w===null||w<0,P=(c=a[Ns])!==null&&c!==void 0?c:a[xs];t&&k?a[Ns]=p:t||(a[xs]=p,k||(a[Ns]=null));const S=(l=a[Ns])!==null&&l!==void 0?l:a[xs];if(P!==S){if(P&&this.receiptCacheByEventId[P.eventId]){const T=P.eventId;this.receiptCacheByEventId[T]=this.receiptCacheByEventId[T].filter(D=>D.type!==s||D.userId!==o),this.receiptCacheByEventId[T].length<1&&delete this.receiptCacheByEventId[T]}this.receiptCacheByEventId[i]||(this.receiptCacheByEventId[i]=[]),this.receiptCacheByEventId[i].push({userId:o,type:s,data:u})}})})})}addLocalEchoReceipt(e,t,r){this.addReceipt(Zp(e,t,r),!0)}addTags(e){this.tags=e.getContent().tags||{},this.emit(nt.Tags,e,this)}addAccountData(e){for(let t=0;t<e.length;t++){const r=e[t];r.getType()==="m.tag"&&this.addTags(r);const i=this.accountData[r.getType()];this.accountData[r.getType()]=r,this.emit(nt.AccountData,r,this,i)}}getAccountData(e){return this.accountData[e]}maySendMessage(){return this.getMyMembership()==="join"&&(this.client.isRoomEncrypted(this.roomId)?this.currentState.maySendEvent($e.EventType.RoomMessageEncrypted,this.myUserId):this.currentState.maySendEvent($e.EventType.RoomMessage,this.myUserId))}canInvite(e){let t=this.getMyMembership()==="join";const r=this.currentState.getStateEvents($e.EventType.RoomPowerLevels,""),i=r&&r.getContent(),s=this.getMember(e);return i&&s&&i.invite>s.powerLevel&&(t=!1),t}getJoinRule(){return this.currentState.getJoinRule()}getHistoryVisibility(){return this.currentState.getHistoryVisibility()}getGuestAccess(){return this.currentState.getGuestAccess()}getType(){const e=this.currentState.getStateEvents($e.EventType.RoomCreate,"");if(!e){this.getTypeWarning||(ht.logger.warn("[getType] Room "+this.roomId+" does not have an m.room.create event"),this.getTypeWarning=!0);return}return e.getContent()[$e.RoomCreateTypeField]}isSpaceRoom(){return this.getType()===$e.RoomType.Space}calculateRoomName(e,t=!1){if(!t){const m=this.currentState.getStateEvents($e.EventType.RoomName,"");if(m&&m.getContent()&&m.getContent().name)return m.getContent().name}const r=this.getCanonicalAlias();if(r)return r;const i=this.currentState.getJoinedMemberCount(),s=this.currentState.getInvitedMemberCount();let o=i+s-1,c=[];const l=this.currentState.getStateEvents($e.UNSTABLE_ELEMENT_FUNCTIONAL_USERS.name,"");Array.isArray(l==null?void 0:l.getContent().service_members)&&(c=l.getContent().service_members);let u=null;if(this.summaryHeroes)u=[],this.summaryHeroes.forEach(m=>{if(c.includes(m)){o--;return}const p=this.getMember(m);u.push(p?p.name:m)});else{let m=this.currentState.getMembers().filter(p=>p.userId!==e&&(p.membership==="invite"||p.membership==="join"));m=m.filter(({userId:p})=>c.includes(p)?(o--,!1):!0),m.sort((p,E)=>zo.compare(p.userId,E.userId)),m=m.slice(0,5),u=m.map(p=>p.name)}if(o)return Lu(u,o);if(this.getMyMembership()=="join"){const m=this.currentState.getStateEvents($e.EventType.RoomThirdPartyInvite);if(m&&m.length){const p=m.map(E=>E.getContent().display_name);return`Inviting ${Lu(p)}`}}let g=u;return g.length||(g=this.currentState.getMembers().filter(m=>m.userId!==e&&m.membership!=="invite"&&m.membership!=="join").map(m=>m.name)),g.length?`Empty room (was ${Lu(g)})`:"Empty room"}applyNewVisibilityEvent(e){const t=e.asVisibilityChange();if(!t)return;const r=e.getSender();if(!r||!($e.EVENT_VISIBILITY_CHANGE_TYPE.name&&this.currentState.maySendStateEvent($e.EVENT_VISIBILITY_CHANGE_TYPE.name,r)||$e.EVENT_VISIBILITY_CHANGE_TYPE.altName&&this.currentState.maySendStateEvent($e.EVENT_VISIBILITY_CHANGE_TYPE.altName,r)))return;const s=this.visibilityEvents.get(t.eventId);if(s){let c=s.length-1;const l=Math.max(0,s.length-XT);for(;c>=l&&!(s[c].getTs()<e.getTs());--c);c===-1?s.unshift(e):s.splice(c+1,0,e)}else this.visibilityEvents.set(t.eventId,[e]);const o=this.findEventById(t.eventId);!o||o.applyVisibilityEvent(t)}redactVisibilityChangeEvent(e){if(!e.isVisibilityEvent)throw new Error("expected a visibility change event");const r=e.getRelation().event_id,i=this.visibilityEvents.get(r);if(!i)return;const s=i.findIndex(o=>o.getId()===e.getId());if(s!==-1&&(i.splice(s,1),s===i.length)){const o=this.findEventById(r);if(!o)return;if(s===0)this.visibilityEvents.delete(r),o.applyVisibilityEvent();else{const l=i[i.length-1].asVisibilityChange();if(!l)throw new Error("at this stage, visibility changes should be well-formed");o.applyVisibilityEvent(l)}}}applyPendingVisibilityEvents(e){const t=this.visibilityEvents.get(e.getId());if(!t||t.length==0)return;const r=t[t.length-1],i=r.asVisibilityChange();!i||(i.visible,!(r.getTs()<e.getTs())&&e.applyVisibilityEvent(i))}}ar.Room=QT;function Nu(n){return`mx_pending_events_${n}`}const ZT={[Pe.EventStatus.ENCRYPTING]:[Pe.EventStatus.SENDING,Pe.EventStatus.NOT_SENT,Pe.EventStatus.CANCELLED],[Pe.EventStatus.SENDING]:[Pe.EventStatus.ENCRYPTING,Pe.EventStatus.QUEUED,Pe.EventStatus.NOT_SENT,Pe.EventStatus.SENT],[Pe.EventStatus.QUEUED]:[Pe.EventStatus.SENDING,Pe.EventStatus.CANCELLED],[Pe.EventStatus.SENT]:[],[Pe.EventStatus.NOT_SENT]:[Pe.EventStatus.SENDING,Pe.EventStatus.QUEUED,Pe.EventStatus.CANCELLED],[Pe.EventStatus.CANCELLED]:[]};function Lu(n,e=n.length+1){const t=e-1;return n.length?n.length===1&&t<=1?n[0]:n.length===2&&t<=2?`${n[0]} and ${n[1]}`:t>1?`${n[0]} and ${t} others`:`${n[0]} and 1 other`:"Empty room"}var Kl={};Object.defineProperty(Kl,"__esModule",{value:!0});Kl.Group=rc;var eO=kl.exports,tO=rO(G);function Pv(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(Pv=function(r){return r?t:e})(n)}function rO(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=Pv(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}function rc(n){this.groupId=n,this.name=null,this.avatarUrl=null,this.myMembership=null,this.inviter=null}tO.inherits(rc,eO.EventEmitter);rc.prototype.setProfile=function(n,e){this.name===n&&this.avatarUrl===e||(this.name=n||this.groupId,this.avatarUrl=e,this.emit("Group.profile",this))};rc.prototype.setMyMembership=function(n){this.myMembership!==n&&(this.myMembership=n,this.emit("Group.myMembership",this))};rc.prototype.setInviter=function(n){this.inviter=n};var nc={},Be={};Object.defineProperty(Be,"__esModule",{value:!0});Be.TweakName=Be.RuleId=Be.PushRuleKind=Be.PushRuleActionName=Be.DMMemberCountCondition=Be.ConditionOperator=Be.ConditionKind=void 0;Be.isDmMemberCountCondition=iO;let ch;Be.PushRuleActionName=ch;(function(n){n.DontNotify="dont_notify",n.Notify="notify",n.Coalesce="coalesce"})(ch||(Be.PushRuleActionName=ch={}));let lh;Be.TweakName=lh;(function(n){n.Highlight="highlight",n.Sound="sound"})(lh||(Be.TweakName=lh={}));let uh;Be.ConditionOperator=uh;(function(n){n.ExactEquals="==",n.LessThan="<",n.GreaterThan=">",n.GreaterThanOrEqual=">=",n.LessThanOrEqual="<="})(uh||(Be.ConditionOperator=uh={}));const nO="2";Be.DMMemberCountCondition=nO;function iO(n){return n==="==2"||n==="2"}let dh;Be.ConditionKind=dh;(function(n){n.EventMatch="event_match",n.ContainsDisplayName="contains_display_name",n.RoomMemberCount="room_member_count",n.SenderNotificationPermission="sender_notification_permission"})(dh||(Be.ConditionKind=dh={}));let hh;Be.PushRuleKind=hh;(function(n){n.Override="override",n.ContentSpecific="content",n.RoomSpecific="room",n.SenderSpecific="sender",n.Underride="underride"})(hh||(Be.PushRuleKind=hh={}));let fh;Be.RuleId=fh;(function(n){n.Master=".m.rule.master",n.ContainsDisplayName=".m.rule.contains_display_name",n.ContainsUserName=".m.rule.contains_user_name",n.AtRoomNotification=".m.rule.roomnotif",n.DM=".m.rule.room_one_to_one",n.EncryptedDM=".m.rule.encrypted_room_one_to_one",n.Message=".m.rule.message",n.EncryptedMessage=".m.rule.encrypted",n.InviteToSelf=".m.rule.invite_for_me",n.MemberEvent=".m.rule.member_event",n.IncomingCall=".m.rule.call",n.SuppressNotices=".m.rule.suppress_notices",n.Tombstone=".m.rule.tombstone"})(fh||(Be.RuleId=fh={}));var sO=V.exports;Object.defineProperty(nc,"__esModule",{value:!0});nc.PushProcessor=void 0;var Mv=sO(Y.exports),Bu=G,oO=ie,Ne=Be;function eg(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function tg(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?eg(Object(t),!0).forEach(function(r){(0,Mv.default)(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):eg(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}const Ku=[Ne.PushRuleKind.Override,Ne.PushRuleKind.ContentSpecific,Ne.PushRuleKind.RoomSpecific,Ne.PushRuleKind.SenderSpecific,Ne.PushRuleKind.Underride],aO=[{rule_id:".m.rule.tombstone",default:!0,enabled:!0,conditions:[{kind:Ne.ConditionKind.EventMatch,key:"type",pattern:"m.room.tombstone"},{kind:Ne.ConditionKind.EventMatch,key:"state_key",pattern:""}],actions:[Ne.PushRuleActionName.Notify,{set_tweak:Ne.TweakName.Highlight,value:!0}]},{rule_id:".m.rule.reaction",default:!0,enabled:!0,conditions:[{kind:Ne.ConditionKind.EventMatch,key:"type",pattern:"m.reaction"}],actions:[Ne.PushRuleActionName.DontNotify]}];class Mi{constructor(e){this.client=e}static actionListToActionsObject(e){const t={notify:!1,tweaks:{}};for(let r=0;r<e.length;++r){const i=e[r];i===Ne.PushRuleActionName.Notify?t.notify=!0:typeof i=="object"&&(i.value===void 0&&(i.value=!0),t.tweaks[i.set_tweak]=i.value)}return t}static rewriteDefaultRules(e){let t=JSON.parse(JSON.stringify(e));t||(t={}),t.global||(t.global={}),t.global.override||(t.global.override=[]);const r=t.global.override;for(const i of aO){const s=r.find(o=>o.rule_id===i.rule_id);if(s)s.default=i.default,s.conditions=i.conditions,s.actions=i.actions;else{const o=i.rule_id;oO.logger.warn(`Adding default global override for ${o}`),r.push(i)}}return t}matchingRuleFromKindSet(e,t){for(let r=0;r<Ku.length;++r){const i=Ku[r],s=t[i];if(!!s)for(let o=0;o<s.length;++o){const c=s[o];if(!c.enabled)continue;const l=this.templateRuleToRaw(i,c);if(!!l&&this.ruleMatchesEvent(l,e))return tg(tg({},c),{},{kind:i})}}return null}templateRuleToRaw(e,t){const r={rule_id:t.rule_id,actions:t.actions,conditions:[]};switch(e){case Ne.PushRuleKind.Underride:case Ne.PushRuleKind.Override:r.conditions=t.conditions;break;case Ne.PushRuleKind.RoomSpecific:if(!t.rule_id)return null;r.conditions.push({kind:Ne.ConditionKind.EventMatch,key:"room_id",value:t.rule_id});break;case Ne.PushRuleKind.SenderSpecific:if(!t.rule_id)return null;r.conditions.push({kind:Ne.ConditionKind.EventMatch,key:"user_id",value:t.rule_id});break;case Ne.PushRuleKind.ContentSpecific:if(!t.pattern)return null;r.conditions.push({kind:Ne.ConditionKind.EventMatch,key:"content.body",pattern:t.pattern});break}return r}eventFulfillsCondition(e,t){switch(e.kind){case Ne.ConditionKind.EventMatch:return this.eventFulfillsEventMatchCondition(e,t);case Ne.ConditionKind.ContainsDisplayName:return this.eventFulfillsDisplayNameCondition(e,t);case Ne.ConditionKind.RoomMemberCount:return this.eventFulfillsRoomMemberCountCondition(e,t);case Ne.ConditionKind.SenderNotificationPermission:return this.eventFulfillsSenderNotifPermCondition(e,t)}return!1}eventFulfillsSenderNotifPermCondition(e,t){const r=e.key;if(!r)return!1;const i=this.client.getRoom(t.getRoomId());return i!=null&&i.currentState?i.currentState.mayTriggerNotifOfType(r,t.getSender()):!1}eventFulfillsRoomMemberCountCondition(e,t){if(!e.is)return!1;const r=this.client.getRoom(t.getRoomId());if(!r||!r.currentState||!r.currentState.members)return!1;const i=r.currentState.getJoinedMemberCount(),s=e.is.match(/^([=<>]*)([0-9]*)$/);if(!s)return!1;const o=s[1],c=parseInt(s[2]);if(isNaN(c))return!1;switch(o){case"":case"==":return i==c;case"<":return i<c;case">":return i>c;case"<=":return i<=c;case">=":return i>=c;default:return!1}}eventFulfillsDisplayNameCondition(e,t){let r=t.getContent();if(t.isEncrypted()&&t.getClearContent()&&(r=t.getClearContent()),!r||!r.body||typeof r.body!="string")return!1;const i=this.client.getRoom(t.getRoomId());if(!i||!i.currentState||!i.currentState.members||!i.currentState.getMember(this.client.credentials.userId))return!1;const s=i.currentState.getMember(this.client.credentials.userId).name,o=new RegExp("(^|\\W)"+(0,Bu.escapeRegExp)(s)+"(\\W|$)","i");return r.body.search(o)>-1}eventFulfillsEventMatchCondition(e,t){if(!e.key)return!1;const r=this.valueForDottedKey(e.key,t);if(typeof r!="string")return!1;if(e.value)return e.value===r;if(typeof e.pattern!="string")return!1;let i;return e.key=="content.body"?i=this.createCachedRegex("(^|\\W)",e.pattern,"(\\W|$)"):i=this.createCachedRegex("^",e.pattern,"$"),!!r.match(i)}createCachedRegex(e,t,r){return Mi.cachedGlobToRegex[t]||(Mi.cachedGlobToRegex[t]=new RegExp(e+(0,Bu.globToRegexp)(t)+r,"i")),Mi.cachedGlobToRegex[t]}valueForDottedKey(e,t){const r=e.split(".");let i;const s=r[0];for(s==="content"?(i=t.getContent(),r.shift()):s==="type"?(i=t.getType(),r.shift()):i=t.event;r.length>0;){const o=r.shift();if((0,Bu.isNullOrUndefined)(i[o]))return null;i=i[o]}return i}matchingRuleForEventWithRulesets(e,t){return!t||e.getSender()===this.client.credentials.userId?null:this.matchingRuleFromKindSet(e,t.global)}pushActionsForEventAndRulesets(e,t){const r=this.matchingRuleForEventWithRulesets(e,t);if(!r)return{};const i=Mi.actionListToActionsObject(r.actions);return i.tweaks.highlight===void 0&&(i.tweaks.highlight=r.kind==Ne.PushRuleKind.ContentSpecific),i}ruleMatchesEvent(e,t){var r;if(!((r=e.conditions)!==null&&r!==void 0&&r.length))return!0;let i=!0;for(let s=0;s<e.conditions.length;++s){const o=e.conditions[s];i&=this.eventFulfillsCondition(o,t)}return i}actionsForEvent(e){return this.pushActionsForEventAndRulesets(e,this.client.pushRules)}getPushRuleById(e){for(const t of["global"])if(this.client.pushRules[t]!==void 0){for(const r of Ku)if(this.client.pushRules[t][r]!==void 0){for(const i of this.client.pushRules[t][r])if(i.rule_id===e)return i}}return null}}nc.PushProcessor=Mi;(0,Mv.default)(Mi,"cachedGlobToRegex",{});var si={};Object.defineProperty(si,"__esModule",{value:!0});si.InvalidCryptoStoreError=ql;si.InvalidStoreError=Fl;si.KeySignatureUploadError=void 0;function Fl(n,e){const t=`Store is invalid because ${n}, please stop the client, delete all data and start the client again`,r=Reflect.construct(Error,[t]);return Reflect.setPrototypeOf(r,Reflect.getPrototypeOf(this)),r.reason=n,r.value=e,r}Fl.TOGGLED_LAZY_LOADING="TOGGLED_LAZY_LOADING";Fl.prototype=Object.create(Error.prototype,{constructor:{value:Error,enumerable:!1,writable:!0,configurable:!0}});Reflect.setPrototypeOf(Fl,Error);function ql(n){const e=`Crypto store is invalid because ${n}, please stop the client, delete all data and start the client again`,t=Reflect.construct(Error,[e]);return Reflect.setPrototypeOf(t,Reflect.getPrototypeOf(this)),t.reason=n,t.name="InvalidCryptoStoreError",t}ql.TOO_NEW="TOO_NEW";ql.prototype=Object.create(Error.prototype,{constructor:{value:Error,enumerable:!1,writable:!0,configurable:!0}});Reflect.setPrototypeOf(ql,Error);class cO extends Error{constructor(e,t){super(e);this.value=t}}si.KeySignatureUploadError=cO;var ti={},lO=V.exports;Object.defineProperty(ti,"__esModule",{value:!0});ti.SyncAccumulator=ti.Category=void 0;var Jo=lO(Y.exports),uO=ie,dO=G;let Lt;ti.Category=Lt;(function(n){n.Invite="invite",n.Leave="leave",n.Join="join"})(Lt||(ti.Category=Lt={}));class hO{constructor(e={}){this.opts=e,(0,Jo.default)(this,"accountData",{}),(0,Jo.default)(this,"inviteRooms",{}),(0,Jo.default)(this,"joinRooms",{}),(0,Jo.default)(this,"nextBatch",null),(0,Jo.default)(this,"groups",{invite:{},join:{},leave:{}}),this.opts.maxTimelineEntries=this.opts.maxTimelineEntries||50}accumulate(e,t=!1){this.accumulateRooms(e,t),this.accumulateGroups(e),this.accumulateAccountData(e),this.nextBatch=e.next_batch}accumulateAccountData(e){!e.account_data||!e.account_data.events||e.account_data.events.forEach(t=>{this.accountData[t.type]=t})}accumulateRooms(e,t=!1){!e.rooms||(e.rooms.invite&&Object.keys(e.rooms.invite).forEach(r=>{this.accumulateRoom(r,Lt.Invite,e.rooms.invite[r],t)}),e.rooms.join&&Object.keys(e.rooms.join).forEach(r=>{this.accumulateRoom(r,Lt.Join,e.rooms.join[r],t)}),e.rooms.leave&&Object.keys(e.rooms.leave).forEach(r=>{this.accumulateRoom(r,Lt.Leave,e.rooms.leave[r],t)}))}accumulateRoom(e,t,r,i=!1){switch(t){case Lt.Invite:this.accumulateInviteState(e,r);break;case Lt.Join:this.inviteRooms[e]&&delete this.inviteRooms[e],this.accumulateJoinState(e,r,i);break;case Lt.Leave:this.inviteRooms[e]?delete this.inviteRooms[e]:delete this.joinRooms[e];break;default:uO.logger.error("Unknown cateogory: ",t)}}accumulateInviteState(e,t){if(!t.invite_state||!t.invite_state.events)return;if(!this.inviteRooms[e]){this.inviteRooms[e]={invite_state:t.invite_state};return}const r=this.inviteRooms[e];t.invite_state.events.forEach(i=>{let s=!1;for(let o=0;o<r.invite_state.events.length;o++){const c=r.invite_state.events[o];c.type===i.type&&c.state_key==i.state_key&&(r.invite_state.events[o]=i,s=!0)}s||r.invite_state.events.push(i)})}accumulateJoinState(e,t,r=!1){this.joinRooms[e]||(this.joinRooms[e]={_currentState:Object.create(null),_timeline:[],_accountData:Object.create(null),_unreadNotifications:{},_summary:{},_readReceipts:{}});const i=this.joinRooms[e];if(t.account_data&&t.account_data.events&&t.account_data.events.forEach(s=>{i._accountData[s.type]=s}),t.unread_notifications&&(i._unreadNotifications=t.unread_notifications),t.summary){const s="m.heroes",o="m.invited_member_count",c="m.joined_member_count",l=i._summary,u=t.summary;l[s]=u[s]||l[s],l[c]=u[c]||l[c],l[o]=u[o]||l[o]}if(t.ephemeral&&t.ephemeral.events&&t.ephemeral.events.forEach(s=>{s.type!=="m.receipt"||!s.content||Object.keys(s.content).forEach(o=>{!s.content[o]["m.read"]||Object.keys(s.content[o]["m.read"]).forEach(c=>{i._readReceipts[c]={data:s.content[o]["m.read"][c],eventId:o}})})}),t.timeline&&t.timeline.limited&&(i._timeline=[]),t.state&&t.state.events&&t.state.events.forEach(s=>{Fu(i._currentState,s)}),t.timeline&&t.timeline.events&&t.timeline.events.forEach((s,o)=>{Fu(i._currentState,s);let c;if(r)c=s;else{c=Object.assign({},s),c.unsigned!==void 0&&(c.unsigned=Object.assign({},c.unsigned));const l=s.unsigned?s.unsigned.age:s.age;l!==void 0&&(c._localTs=Date.now()-l)}i._timeline.push({event:c,token:o===0?t.timeline.prev_batch:null})}),i._timeline.length>this.opts.maxTimelineEntries){const s=i._timeline.length-this.opts.maxTimelineEntries;for(let o=s;o<i._timeline.length;o++)if(i._timeline[o].token){i._timeline=i._timeline.slice(o,i._timeline.length);break}}}accumulateGroups(e){!e.groups||(e.groups.invite&&Object.keys(e.groups.invite).forEach(t=>{this.accumulateGroup(t,Lt.Invite,e.groups.invite[t])}),e.groups.join&&Object.keys(e.groups.join).forEach(t=>{this.accumulateGroup(t,Lt.Join,e.groups.join[t])}),e.groups.leave&&Object.keys(e.groups.leave).forEach(t=>{this.accumulateGroup(t,Lt.Leave,e.groups.leave[t])}))}accumulateGroup(e,t,r){for(const i of[Lt.Invite,Lt.Leave,Lt.Join])delete this.groups[i][e];this.groups[t][e]=r}getJSON(e=!1){const t={join:{},invite:{},leave:{}};Object.keys(this.inviteRooms).forEach(i=>{t.invite[i]=this.inviteRooms[i]}),Object.keys(this.joinRooms).forEach(i=>{const s=this.joinRooms[i],o={ephemeral:{events:[]},account_data:{events:[]},state:{events:[]},timeline:{events:[],prev_batch:null},unread_notifications:s._unreadNotifications,summary:s._summary};Object.keys(s._accountData).forEach(u=>{o.account_data.events.push(s._accountData[u])});const c={type:"m.receipt",room_id:i,content:{}};Object.keys(s._readReceipts).forEach(u=>{const a=s._readReceipts[u];c.content[a.eventId]||(c.content[a.eventId]={"m.read":{}}),c.content[a.eventId]["m.read"][u]=a.data}),Object.keys(c.content).length>0&&o.ephemeral.events.push(c),s._timeline.forEach(u=>{if(!o.timeline.prev_batch){if(!u.token)return;o.timeline.prev_batch=u.token}let a;!e&&u.event._localTs?(a=Object.assign({},u.event),a.unsigned!==void 0&&(a.unsigned=Object.assign({},a.unsigned)),delete a._localTs,a.unsigned=a.unsigned||{},a.unsigned.age=Date.now()-u.event._localTs):a=u.event,o.timeline.events.push(a)});const l=Object.create(null);for(let u=o.timeline.events.length-1;u>=0;u--){const a=o.timeline.events[u];if(a.state_key===null||a.state_key===void 0)continue;const g=(0,dO.deepCopy)(a);g.unsigned&&(g.unsigned.prev_content&&(g.content=g.unsigned.prev_content),g.unsigned.prev_sender&&(g.sender=g.unsigned.prev_sender)),Fu(l,g)}Object.keys(s._currentState).forEach(u=>{Object.keys(s._currentState[u]).forEach(a=>{let g=s._currentState[u][a];l[u]&&l[u][a]&&(g=l[u][a]),o.state.events.push(g)})}),t.join[i]=o});const r=[];return Object.keys(this.accountData).forEach(i=>{r.push(this.accountData[i])}),{nextBatch:this.nextBatch,roomsData:t,groupsData:this.groups,accountData:r}}getNextBatchToken(){return this.nextBatch}}ti.SyncAccumulator=hO;function Fu(n,e){e.state_key===null||e.state_key===void 0||!e.type||(n[e.type]||(n[e.type]=Object.create(null)),n[e.type][e.state_key]=e)}var fO=V.exports;Object.defineProperty(Ui,"__esModule",{value:!0});Ui.SyncState=Ui.SyncApi=void 0;var kr=fO(Y.exports),Ls=en,Rt=ar,pO=Kl,Bs=yO(G),rg=Cs,ng=Ft,gO=nc,Qt=ie,ig=si,Fe=it,qu=ti,bc=me,mO=ne,Ei=Tn,wc=tn,ju=_r;function Av(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(Av=function(r){return r?t:e})(n)}function yO(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=Av(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}const sg=80*1e3,vO=3;let Ot;Ui.SyncState=Ot;(function(n){n.Error="ERROR",n.Prepared="PREPARED",n.Stopped="STOPPED",n.Syncing="SYNCING",n.Catchup="CATCHUP",n.Reconnecting="RECONNECTING"})(Ot||(Ui.SyncState=Ot={}));function og(n,e){return"FILTER_SYNC_"+n+(e?"_"+e:"")}function ke(...n){Qt.logger.log(...n)}var ph;(function(n){n.Offline="offline",n.Online="online",n.Unavailable="unavailable"})(ph||(ph={}));class _O{constructor(e,t={}){var r;this.client=e,this.opts=t,(0,kr.default)(this,"_peekRoom",null),(0,kr.default)(this,"currentSyncRequest",null),(0,kr.default)(this,"syncState",null),(0,kr.default)(this,"syncStateData",null),(0,kr.default)(this,"catchingUp",!1),(0,kr.default)(this,"running",!1),(0,kr.default)(this,"keepAliveTimer",null),(0,kr.default)(this,"connectionReturnedDefer",null),(0,kr.default)(this,"notifEvents",[]),(0,kr.default)(this,"failedSyncCount",0),(0,kr.default)(this,"storeIsInvalid",!1),(0,kr.default)(this,"onOnline",()=>{ke("Browser thinks we are back online"),this.startKeepAlives(0)}),this.opts.initialSyncLimit=(r=this.opts.initialSyncLimit)!==null&&r!==void 0?r:8,this.opts.resolveInvitesToProfiles=this.opts.resolveInvitesToProfiles||!1,this.opts.pollTimeout=this.opts.pollTimeout||30*1e3,this.opts.pendingEventOrdering=this.opts.pendingEventOrdering||Fe.PendingEventOrdering.Chronological,this.opts.experimentalThreadSupport=this.opts.experimentalThreadSupport===!0,t.canResetEntireTimeline||(t.canResetEntireTimeline=i=>!1),e.getNotifTimelineSet()&&e.reEmitter.reEmit(e.getNotifTimelineSet(),[Rt.RoomEvent.Timeline,Rt.RoomEvent.TimelineReset])}createRoom(e){const t=this.client,{timelineSupport:r,unstableClientRelationAggregation:i}=t,s=new Rt.Room(e,t,t.getUserId(),{lazyLoadMembers:this.opts.lazyLoadMembers,pendingEventOrdering:this.opts.pendingEventOrdering,timelineSupport:r,unstableClientRelationAggregation:i});return t.reEmitter.reEmit(s,[Rt.RoomEvent.Name,Rt.RoomEvent.Redaction,Rt.RoomEvent.RedactionCancelled,Rt.RoomEvent.Receipt,Rt.RoomEvent.Tags,Rt.RoomEvent.LocalEchoUpdated,Rt.RoomEvent.AccountData,Rt.RoomEvent.MyMembership,Rt.RoomEvent.Timeline,Rt.RoomEvent.TimelineReset]),this.registerStateListeners(s),s}createGroup(e){const t=this.client,r=new pO.Group(e);return t.reEmitter.reEmit(r,[Fe.ClientEvent.GroupProfile,Fe.ClientEvent.GroupMyMembership]),t.store.storeGroup(r),r}registerStateListeners(e){const t=this.client;t.reEmitter.reEmit(e.currentState,[Ei.RoomStateEvent.Events,Ei.RoomStateEvent.Members,Ei.RoomStateEvent.NewMember,Ei.RoomStateEvent.Update,ju.BeaconEvent.New,ju.BeaconEvent.Update,ju.BeaconEvent.LivenessChange]),e.currentState.on(Ei.RoomStateEvent.NewMember,function(r,i,s){s.user=t.getUser(s.userId),t.reEmitter.reEmit(s,[wc.RoomMemberEvent.Name,wc.RoomMemberEvent.Typing,wc.RoomMemberEvent.PowerLevel,wc.RoomMemberEvent.Membership])})}deregisterStateListeners(e){e.currentState.removeAllListeners(Ei.RoomStateEvent.Events),e.currentState.removeAllListeners(Ei.RoomStateEvent.Members),e.currentState.removeAllListeners(Ei.RoomStateEvent.NewMember)}syncLeftRooms(){const e=this.client,t=new rg.Filter(this.client.credentials.userId);t.setTimelineLimit(1),t.setIncludeLeaveRooms(!0);const r=this.opts.pollTimeout+sg,i={timeout:0};return e.getOrCreateFilter(og(e.credentials.userId,"LEFT_ROOMS"),t).then(function(s){return i.filter=s,e.http.authedRequest(void 0,bc.Method.Get,"/sync",i,void 0,r)}).then(s=>{var o;let c=[];(o=s.rooms)!==null&&o!==void 0&&o.leave&&(c=this.mapSyncResponseToRoomArray(s.rooms.leave));const l=[];return c.forEach(async u=>{const a=u.room;if(l.push(a),!u.isBrandNewRoom)return;u.timeline=u.timeline||{};const g=this.mapSyncEventsFormat(u.timeline,a),[m,p]=this.client.partitionThreadedEvents(g),E=this.mapSyncEventsFormat(u.state,a);a.getLiveTimeline().setPaginationToken(u.timeline.prev_batch,ng.EventTimeline.BACKWARDS),this.processRoomEvents(a,E,m),await this.processThreadEvents(a,p,!1),a.recalculate(),e.store.storeRoom(a),e.emit(Fe.ClientEvent.Room,a),this.processEventsForNotifs(a,g)}),l})}peek(e){if(this._peekRoom&&this._peekRoom.roomId===e)return Promise.resolve(this._peekRoom);const t=this.client;return this._peekRoom=this.createRoom(e),this.client.roomInitialSync(e,20).then(r=>{r.messages=r.messages||{chunk:[]},r.messages.chunk=r.messages.chunk||[],r.state=r.state||[];const i=Bs.deepCopy(r.state).map(t.getEventMapper()),s=r.state.map(t.getEventMapper()),o=r.messages.chunk.map(t.getEventMapper());return r.presence&&Array.isArray(r.presence)&&r.presence.map(t.getEventMapper()).forEach(function(c){let l=t.store.getUser(c.getContent().user_id);l?l.setPresenceEvent(c):(l=Rc(t,c.getContent().user_id),l.setPresenceEvent(c),t.store.storeUser(l)),t.emit(Fe.ClientEvent.Event,c)}),r.messages.start&&(this._peekRoom.oldState.paginationToken=r.messages.start),this._peekRoom.oldState.setStateEvents(i),this._peekRoom.currentState.setStateEvents(s),this.resolveInvites(this._peekRoom),this._peekRoom.recalculate(),this._peekRoom.addEventsToTimeline(o.reverse(),!0,this._peekRoom.getLiveTimeline(),r.messages.start),t.store.storeRoom(this._peekRoom),t.emit(Fe.ClientEvent.Room,this._peekRoom),this.peekPoll(this._peekRoom),this._peekRoom})}stopPeeking(){this._peekRoom=null}peekPoll(e,t){if(this._peekRoom!==e){ke("Stopped peeking in room %s",e.roomId);return}this.client.http.authedRequest(void 0,bc.Method.Get,"/events",{room_id:e.roomId,timeout:String(30*1e3),from:t},void 0,50*1e3).then(r=>{if(this._peekRoom!==e){ke("Stopped peeking in room %s",e.roomId);return}r.chunk.filter(function(s){return s.type==="m.presence"}).map(this.client.getEventMapper()).forEach(s=>{let o=this.client.store.getUser(s.getContent().user_id);o?o.setPresenceEvent(s):(o=Rc(this.client,s.getContent().user_id),o.setPresenceEvent(s),this.client.store.storeUser(o)),this.client.emit(Fe.ClientEvent.Event,s)});const i=r.chunk.filter(function(s){return s.room_id===e.roomId&&s.event_id}).map(this.client.getEventMapper());e.addLiveEvents(i),this.peekPoll(e,r.end)},r=>{Qt.logger.error("[%s] Peek poll failed: %s",e.roomId,r),setTimeout(()=>{this.peekPoll(e,t)},30*1e3)})}getSyncState(){return this.syncState}getSyncStateData(){return this.syncStateData}async recoverFromSyncStartupError(e,t){await e;const r=this.startKeepAlives();this.updateSyncState(Ot.Error,{error:t}),await r}async wasLazyLoadingToggled(e=!1){let t=!1;if(!await this.client.store.isNewlyCreated()){const i=await this.client.store.getClientOptions();return i&&(t=!!i.lazyLoadMembers),t!==e}return!1}shouldAbortSync(e){return e.errcode==="M_UNKNOWN_TOKEN"?(Qt.logger.warn("Token no longer valid - assuming logout"),this.stop(),this.updateSyncState(Ot.Error,{error:e}),!0):!1}sync(){const e=this.client;this.running=!0,j.window&&j.window.addEventListener&&j.window.addEventListener("online",this.onOnline,!1);let t=Promise.resolve(),r=null;const i=async()=>{try{ke("Getting push rules...");const l=await e.getPushRules();ke("Got push rules"),e.pushRules=l}catch(l){if(Qt.logger.error("Getting push rules failed",l),this.shouldAbortSync(l))return;ke("Waiting for saved sync before retrying push rules..."),await this.recoverFromSyncStartupError(t,l),i();return}o()},s=()=>{const l=new rg.Filter(e.credentials.userId);return l.setTimelineLimit(this.opts.initialSyncLimit),l},o=async()=>{if(ke("Checking lazy load status..."),this.opts.lazyLoadMembers&&e.isGuest()&&(this.opts.lazyLoadMembers=!1),this.opts.lazyLoadMembers&&(ke("Checking server lazy load support..."),await e.doesServerSupportLazyLoading()?(ke("Enabling lazy load on sync filter..."),this.opts.filter||(this.opts.filter=s()),this.opts.filter.setLazyLoadMembers(!0)):(ke("LL: lazy loading requested but not supported by server, so disabling"),this.opts.lazyLoadMembers=!1)),ke("Checking whether lazy loading has changed in store..."),await this.wasLazyLoadingToggled(this.opts.lazyLoadMembers)){this.storeIsInvalid=!0;const u=ig.InvalidStoreError.TOGGLED_LAZY_LOADING,a=new ig.InvalidStoreError(u,!!this.opts.lazyLoadMembers);this.updateSyncState(Ot.Error,{error:a}),Qt.logger.warn("InvalidStoreError: store is not usable: stopping sync.");return}this.opts.lazyLoadMembers&&this.opts.crypto&&this.opts.crypto.enableLazyLoading();try{ke("Storing client options..."),await this.client.storeClientOptions(),ke("Stored client options")}catch(u){throw Qt.logger.error("Storing client options failed",u),u}c()},c=async()=>{ke("Getting filter...");let l;this.opts.filter?l=this.opts.filter:l=s();let u;try{u=await e.getOrCreateFilter(og(e.credentials.userId),l)}catch(a){if(Qt.logger.error("Getting filter failed",a),this.shouldAbortSync(a))return;ke("Waiting for saved sync before retrying filter..."),await this.recoverFromSyncStartupError(t,a),c();return}e.resetNotifTimelineSet(),this.currentSyncRequest===null&&(ke("Sending first sync request..."),this.currentSyncRequest=this.doSyncRequest({filterId:u},r)),ke("Waiting for saved sync before starting sync processing..."),await t,this.doSync({filterId:u})};e.isGuest()?this.doSync({}):(ke("Getting saved sync token..."),t=e.store.getSavedSyncToken().then(l=>(ke("Got saved sync token"),r=l,ke("Getting saved sync..."),e.store.getSavedSync())).then(l=>{if(ke(`Got reply from saved sync, exists? ${!!l}`),l)return this.syncFromCache(l)}).catch(l=>{Qt.logger.error("Getting saved sync failed",l)}),i())}stop(){ke("SyncApi.stop"),j.window&&j.window.removeEventListener&&j.window.removeEventListener("online",this.onOnline,!1),this.running=!1,this.currentSyncRequest&&this.currentSyncRequest.abort(),this.keepAliveTimer&&(clearTimeout(this.keepAliveTimer),this.keepAliveTimer=null)}retryImmediately(){return this.connectionReturnedDefer?(this.startKeepAlives(0),!0):!1}async syncFromCache(e){ke("sync(): not doing HTTP hit, instead returning stored /sync data");const t=e.nextBatch;this.client.store.setSyncToken(t);const r={oldSyncToken:null,nextSyncToken:t,catchingUp:!1,fromCache:!0},i={next_batch:t,rooms:e.roomsData,groups:e.groupsData,account_data:{events:e.accountData}};try{await this.processSyncResponse(r,i)}catch(s){Qt.logger.error("Error processing cached sync",s.stack||s)}this.storeIsInvalid||this.updateSyncState(Ot.Prepared,r)}async doSync(e){const t=this.client;if(!this.running){ke("Sync no longer running: exiting."),this.connectionReturnedDefer&&(this.connectionReturnedDefer.reject(),this.connectionReturnedDefer=null),this.updateSyncState(Ot.Stopped);return}const r=t.store.getSyncToken();let i;try{this.currentSyncRequest===null&&(this.currentSyncRequest=this.doSyncRequest(e,r)),i=await this.currentSyncRequest}catch(o){this.onSyncError(o,e);return}finally{this.currentSyncRequest=null}t.store.setSyncToken(i.next_batch),this.failedSyncCount=0,await t.store.setSyncData(i);const s={oldSyncToken:r,nextSyncToken:i.next_batch,catchingUp:this.catchingUp};this.opts.crypto&&await this.opts.crypto.onSyncWillProcess(s);try{await this.processSyncResponse(s,i)}catch(o){Qt.logger.error("Caught /sync error",o.stack||o),this.client.emit(Fe.ClientEvent.SyncUnexpectedError,o)}s.catchingUp=this.catchingUp,e.hasSyncedBefore||(this.updateSyncState(Ot.Prepared,s),e.hasSyncedBefore=!0),this.opts.crypto&&await this.opts.crypto.onSyncCompleted(s),this.updateSyncState(Ot.Syncing,s),t.store.wantsSave()&&(this.opts.crypto&&await this.opts.crypto.saveDeviceList(0),t.store.save()),this.doSync(e)}doSyncRequest(e,t){const r=this.getSyncParams(e,t);return this.client.http.authedRequest(void 0,bc.Method.Get,"/sync",r,void 0,r.timeout+sg)}getSyncParams(e,t){let r=this.opts.pollTimeout;(this.getSyncState()!=="SYNCING"||this.catchingUp)&&(this.catchingUp=!0,r=0);let i=e.filterId;this.client.isGuest()&&!i&&(i=this.getGuestFilter());const s={filter:i,timeout:r};return this.opts.disablePresence&&(s.set_presence=ph.Offline),t?s.since=t:s._cacheBuster=Date.now(),(this.getSyncState()=="ERROR"||this.getSyncState()=="RECONNECTING")&&(s.timeout=0),s}onSyncError(e,t){if(!this.running){ke("Sync no longer running: exiting"),this.connectionReturnedDefer&&(this.connectionReturnedDefer.reject(),this.connectionReturnedDefer=null),this.updateSyncState(Ot.Stopped);return}Qt.logger.error("/sync error %s",e),Qt.logger.error(e),!this.shouldAbortSync(e)&&(this.failedSyncCount++,Qt.logger.log("Number of consecutive failed sync requests:",this.failedSyncCount),ke("Starting keep-alive"),this.startKeepAlives().then(r=>{r&&this.getSyncState()===Ot.Error&&this.updateSyncState(Ot.Catchup,{oldSyncToken:null,nextSyncToken:null,catchingUp:!0}),this.doSync(t)}),this.currentSyncRequest=null,this.updateSyncState(this.failedSyncCount>=vO?Ot.Error:Ot.Reconnecting,{error:e}))}async processSyncResponse(e,t){const r=this.client;if(t.presence&&Array.isArray(t.presence.events)&&t.presence.events.map(r.getEventMapper()).forEach(function(c){let l=r.store.getUser(c.getSender());l?l.setPresenceEvent(c):(l=Rc(r,c.getSender()),l.setPresenceEvent(c),r.store.storeUser(l)),r.emit(Fe.ClientEvent.Event,c)}),t.account_data&&Array.isArray(t.account_data.events)){const c=t.account_data.events.map(r.getEventMapper()),l=c.reduce((u,a)=>(u[a.getId()]=r.store.getAccountData(a.getType()),u),{});r.store.storeAccountDataEvents(c),c.forEach(function(u){if(u.getType()===mO.EventType.PushRules){const g=u.getContent();r.pushRules=gO.PushProcessor.rewriteDefaultRules(g)}const a=l[u.getId()];return r.emit(Fe.ClientEvent.AccountData,u,a),u})}if(t.to_device&&Array.isArray(t.to_device.events)&&t.to_device.events.length>0){const c=[];t.to_device.events.map(r.getEventMapper()).map(l=>{if(l.getType()==="m.key.verification.cancel"){const u=l.getContent().transaction_id;u&&c.push(u)}return l}).forEach(function(l){const u=l.getContent();if(l.getType()=="m.room.message"&&u.msgtype=="m.bad.encrypted"){Qt.logger.log("Ignoring undecryptable to-device event from "+l.getSender());return}if(l.getType()==="m.key.verification.start"||l.getType()==="m.key.verification.request"){const a=u.transaction_id;c.includes(a)&&l.flagCancelled()}r.emit(Fe.ClientEvent.ToDeviceEvent,l)})}else this.catchingUp=!1;t.groups&&(t.groups.invite&&this.processGroupSyncEntry(t.groups.invite,qu.Category.Invite),t.groups.join&&this.processGroupSyncEntry(t.groups.join,qu.Category.Join),t.groups.leave&&this.processGroupSyncEntry(t.groups.leave,qu.Category.Leave));let i=[],s=[],o=[];if(t.rooms&&(t.rooms.invite&&(i=this.mapSyncResponseToRoomArray(t.rooms.invite)),t.rooms.join&&(s=this.mapSyncResponseToRoomArray(t.rooms.join)),t.rooms.leave&&(o=this.mapSyncResponseToRoomArray(t.rooms.leave))),this.notifEvents=[],i.forEach(c=>{const l=c.room,u=this.mapSyncEventsFormat(c.invite_state,l);this.processRoomEvents(l,u),c.isBrandNewRoom&&(l.recalculate(),r.store.storeRoom(l),r.emit(Fe.ClientEvent.Room,l)),u.forEach(function(a){r.emit(Fe.ClientEvent.Event,a)}),l.updateMyMembership("invite")}),await Bs.promiseMapSeries(s,async c=>{const l=c.room,u=this.mapSyncEventsFormat(c.state,l),a=this.mapSyncEventsFormat(c.timeline,l,!1),g=this.mapSyncEventsFormat(c.ephemeral),m=this.mapSyncEventsFormat(c.account_data),p=r.isRoomEncrypted(l.roomId);if(c.unread_notifications&&(l.setUnreadNotificationCount(Rt.NotificationCountType.Total,c.unread_notifications.notification_count),(!p||p&&l.getUnreadNotificationCount(Rt.NotificationCountType.Highlight)<=0)&&l.setUnreadNotificationCount(Rt.NotificationCountType.Highlight,c.unread_notifications.highlight_count)),c.timeline=c.timeline||{},c.isBrandNewRoom)l.getLiveTimeline().setPaginationToken(c.timeline.prev_batch,ng.EventTimeline.BACKWARDS);else if(c.timeline.limited){let k=!0;for(let P=a.length-1;P>=0;P--){const S=a[P].getId();if(l.getTimelineForEvent(S)){ke("Already have event "+S+" in limited sync - not resetting"),k=!1,a.splice(0,P);break}}k&&(this.deregisterStateListeners(l),l.resetLiveTimeline(c.timeline.prev_batch,this.opts.canResetEntireTimeline(l.roomId)?null:e.oldSyncToken),r.resetNotifTimelineSet(),this.registerStateListeners(l))}const[E,I]=this.client.partitionThreadedEvents(a);this.processRoomEvents(l,u,E,e.fromCache),await this.processThreadEvents(l,I,!1),c.summary&&l.setSummary(c.summary),l.addEphemeralEvents(g),l.addAccountData(m),l.recalculate(),c.isBrandNewRoom&&(r.store.storeRoom(l),r.emit(Fe.ClientEvent.Room,l)),this.processEventsForNotifs(l,a);const w=async k=>{if(r.emit(Fe.ClientEvent.Event,k),k.isState()&&k.getType()=="m.room.encryption"&&this.opts.crypto&&await this.opts.crypto.onCryptoEvent(k),k.isState()&&k.getType()==="im.vector.user_status"){let P=r.store.getUser(k.getStateKey());P?P.unstable_updateStatusMessage(k):(P=Rc(r,k.getStateKey()),P.unstable_updateStatusMessage(k),r.store.storeUser(P))}};await Bs.promiseMapSeries(u,w),await Bs.promiseMapSeries(E,w),await Bs.promiseMapSeries(I,w),g.forEach(function(k){r.emit(Fe.ClientEvent.Event,k)}),m.forEach(function(k){r.emit(Fe.ClientEvent.Event,k)}),l.updateMyMembership("join"),l.decryptCriticalEvents()}),o.forEach(async c=>{const l=c.room,u=this.mapSyncEventsFormat(c.state,l),a=this.mapSyncEventsFormat(c.timeline,l),g=this.mapSyncEventsFormat(c.account_data),[m,p]=this.client.partitionThreadedEvents(a);this.processRoomEvents(l,u,m),await this.processThreadEvents(l,p,!1),l.addAccountData(g),l.recalculate(),c.isBrandNewRoom&&(r.store.storeRoom(l),r.emit(Fe.ClientEvent.Room,l)),this.processEventsForNotifs(l,a),u.forEach(function(E){r.emit(Fe.ClientEvent.Event,E)}),m.forEach(function(E){r.emit(Fe.ClientEvent.Event,E)}),p.forEach(function(E){r.emit(Fe.ClientEvent.Event,E)}),g.forEach(function(E){r.emit(Fe.ClientEvent.Event,E)}),l.updateMyMembership("leave")}),e.oldSyncToken&&this.notifEvents.length&&(this.notifEvents.sort(function(c,l){return c.getTs()-l.getTs()}),this.notifEvents.forEach(function(c){r.getNotifTimelineSet().addLiveEvent(c)})),t.device_lists&&this.opts.crypto&&await this.opts.crypto.handleDeviceListChanges(e,t.device_lists),this.opts.crypto&&t.device_one_time_keys_count){const c=t.device_one_time_keys_count.signed_curve25519||0;this.opts.crypto.updateOneTimeKeyCount(c)}if(this.opts.crypto&&(t.device_unused_fallback_key_types||t["org.matrix.msc2732.device_unused_fallback_key_types"])){const c=t.device_unused_fallback_key_types||t["org.matrix.msc2732.device_unused_fallback_key_types"];this.opts.crypto.setNeedsNewFallback(c instanceof Array&&!c.includes("signed_curve25519"))}}startKeepAlives(e){return e===void 0&&(e=2e3+Math.floor(Math.random()*5e3)),this.keepAliveTimer!==null&&clearTimeout(this.keepAliveTimer),e>0?this.keepAliveTimer=setTimeout(this.pokeKeepAlive.bind(this),e):this.pokeKeepAlive(),this.connectionReturnedDefer||(this.connectionReturnedDefer=Bs.defer()),this.connectionReturnedDefer.promise}pokeKeepAlive(e=!1){const t=()=>{clearTimeout(this.keepAliveTimer),this.connectionReturnedDefer&&(this.connectionReturnedDefer.resolve(e),this.connectionReturnedDefer=null)};this.client.http.request(void 0,bc.Method.Get,"/_matrix/client/versions",void 0,void 0,{prefix:"",localTimeoutMs:15*1e3}).then(()=>{t()},r=>{r.httpStatus==400||r.httpStatus==404?this.keepAliveTimer=setTimeout(t,2e3):(e=!0,this.keepAliveTimer=setTimeout(this.pokeKeepAlive.bind(this,e),5e3+Math.floor(Math.random()*5e3)),this.updateSyncState(Ot.Error,{error:r}))})}processGroupSyncEntry(e,t){for(const r of Object.keys(e)){const i=e[r];let s=this.client.store.getGroup(r);const o=s===null;s===null&&(s=this.createGroup(r)),i.profile&&s.setProfile(i.profile.name,i.profile.avatar_url),i.inviter&&s.setInviter({userId:i.inviter}),s.setMyMembership(t),o&&this.client.emit(Fe.ClientEvent.Group,s)}}mapSyncResponseToRoomArray(e){const t=this.client;return Object.keys(e).map(r=>{const i=e[r];let s=t.store.getRoom(r),o=!1;return s||(s=this.createRoom(r),o=!0),i.room=s,i.isBrandNewRoom=o,i})}mapSyncEventsFormat(e,t,r=!0){if(!e||!Array.isArray(e.events))return[];const i=this.client.getEventMapper({decrypt:r});return e.events.map(function(s){return t&&(s.room_id=t.roomId),i(s)})}resolveInvites(e){if(!e||!this.opts.resolveInvitesToProfiles)return;const t=this.client;e.getMembersWithMembership("invite").forEach(function(r){if(r._requestedProfileInfo)return;r._requestedProfileInfo=!0;const i=t.getUser(r.userId);let s;i?s=Promise.resolve({avatar_url:i.avatarUrl,displayname:i.displayName}):s=t.getProfileInfo(r.userId),s.then(function(o){const c=r.events.member;c.getContent().membership==="invite"&&(c.getContent().avatar_url=o.avatar_url,c.getContent().displayname=o.displayname,r.setMembershipEvent(c,e.currentState))},function(o){})})}processRoomEvents(e,t,r,i=!1){const s=e.getLiveTimeline(),o=s.getEvents().length==0;if(o){for(const c of t)this.client.getPushActionsForEvent(c);s.initialiseState(t)}this.resolveInvites(e),e.recalculate(),o||(e.oldState.setStateEvents(t||[]),e.currentState.setStateEvents(t||[])),e.addLiveEvents(r||[],null,i)}processThreadEvents(e,t,r){return this.client.processThreadEvents(e,t,r)}processEventsForNotifs(e,t){if(this.client.getNotifTimelineSet())for(let r=0;r<t.length;r++){const i=this.client.getPushActionsForEvent(t[r]);i&&i.notify&&i.tweaks&&i.tweaks.highlight&&this.notifEvents.push(t[r])}}getGuestFilter(){return"{}"}updateSyncState(e,t){const r=this.syncState;this.syncState=e,this.syncStateData=t,this.client.emit(Fe.ClientEvent.Sync,this.syncState,r,t)}}Ui.SyncApi=_O;function Rc(n,e){const t=new Ls.User(e);return n.reEmitter.reEmit(t,[Ls.UserEvent.AvatarUrl,Ls.UserEvent.DisplayName,Ls.UserEvent.Presence,Ls.UserEvent.CurrentlyActive,Ls.UserEvent.LastPresenceTs]),t}var jl={},EO=V.exports;Object.defineProperty(jl,"__esModule",{value:!0});jl.StubStore=void 0;var ag=EO(Y.exports);class SO{constructor(){(0,ag.default)(this,"accountData",{}),(0,ag.default)(this,"fromToken",null)}isNewlyCreated(){return Promise.resolve(!0)}getSyncToken(){return this.fromToken}setSyncToken(e){this.fromToken=e}storeGroup(e){}getGroup(e){return null}getGroups(){return[]}storeRoom(e){}getRoom(e){return null}getRooms(){return[]}removeRoom(e){}getRoomSummaries(){return[]}storeUser(e){}getUser(e){return null}getUsers(){return[]}scrollback(e,t){return[]}storeEvents(e,t,r,i){}storeFilter(e){}getFilter(e,t){return null}getFilterIdByName(e){return null}setFilterIdByName(e,t){}storeAccountDataEvents(e){}getAccountData(e){}setSyncData(e){return Promise.resolve()}wantsSave(){return!1}save(){}startup(){return Promise.resolve()}getSavedSync(){return Promise.resolve(null)}getSavedSyncToken(){return Promise.resolve(null)}deleteAllData(){return Promise.resolve()}getOutOfBandMembers(){return Promise.resolve(null)}setOutOfBandMembers(e,t){return Promise.resolve()}clearOutOfBandMembers(){return Promise.resolve()}getClientOptions(){return Promise.resolve({})}storeClientOptions(e){return Promise.resolve()}}jl.StubStore=SO;var Te={},oi={};Object.defineProperty(oi,"__esModule",{value:!0});oi.randomLowercaseString=RO;oi.randomString=wO;oi.randomUppercaseString=IO;const Dv="abcdefghijklmnopqrstuvwxyz",Uv="ABCDEFGHIJKLMNOPQRSTUVWXYZ",bO="0123456789";function wO(n){return cf(n,Uv+Dv+bO)}function RO(n){return cf(n,Dv)}function IO(n){return cf(n,Uv)}function cf(n,e){let t="";for(let r=0;r<n;++r)t+=e.charAt(Math.floor(Math.random()*e.length));return t}var ps={};Object.defineProperty(ps,"__esModule",{value:!0});ps.SDPStreamMetadataPurpose=ps.SDPStreamMetadataKey=void 0;const TO="org.matrix.msc3077.sdp_stream_metadata";ps.SDPStreamMetadataKey=TO;let gh;ps.SDPStreamMetadataPurpose=gh;(function(n){n.Usermedia="m.usermedia",n.Screenshare="m.screenshare"})(gh||(ps.SDPStreamMetadataPurpose=gh={}));var Qn={},OO=V.exports;Object.defineProperty(Qn,"__esModule",{value:!0});Qn.SPEAKING_THRESHOLD=Qn.CallFeedEvent=Qn.CallFeed=void 0;var ft=OO(Y.exports),kO=qe;const CO=200,$v=-60;Qn.SPEAKING_THRESHOLD=$v;const PO=8;let yn;Qn.CallFeedEvent=yn;(function(n){n.NewStream="new_stream",n.MuteStateChanged="mute_state_changed",n.VolumeChanged="volume_changed",n.Speaking="speaking"})(yn||(Qn.CallFeedEvent=yn={}));class MO extends kO.TypedEventEmitter{constructor(e){super();(0,ft.default)(this,"stream",void 0),(0,ft.default)(this,"userId",void 0),(0,ft.default)(this,"purpose",void 0),(0,ft.default)(this,"speakingVolumeSamples",void 0),(0,ft.default)(this,"client",void 0),(0,ft.default)(this,"roomId",void 0),(0,ft.default)(this,"audioMuted",void 0),(0,ft.default)(this,"videoMuted",void 0),(0,ft.default)(this,"measuringVolumeActivity",!1),(0,ft.default)(this,"audioContext",void 0),(0,ft.default)(this,"analyser",void 0),(0,ft.default)(this,"frequencyBinCount",void 0),(0,ft.default)(this,"speakingThreshold",$v),(0,ft.default)(this,"speaking",!1),(0,ft.default)(this,"volumeLooperTimeout",void 0),(0,ft.default)(this,"onAddTrack",()=>{this.emit(yn.NewStream,this.stream)}),(0,ft.default)(this,"volumeLooper",()=>{if(!this.analyser||!this.measuringVolumeActivity)return;this.analyser.getFloatFrequencyData(this.frequencyBinCount);let t=-1/0;for(let i=0;i<this.frequencyBinCount.length;i++)this.frequencyBinCount[i]>t&&(t=this.frequencyBinCount[i]);this.speakingVolumeSamples.shift(),this.speakingVolumeSamples.push(t),this.emit(yn.VolumeChanged,t);let r=!1;for(let i=0;i<this.speakingVolumeSamples.length;i++)if(this.speakingVolumeSamples[i]>this.speakingThreshold){r=!0;break}this.speaking!==r&&(this.speaking=r,this.emit(yn.Speaking,this.speaking)),this.volumeLooperTimeout=setTimeout(this.volumeLooper,CO)}),this.client=e.client,this.roomId=e.roomId,this.userId=e.userId,this.purpose=e.purpose,this.audioMuted=e.audioMuted,this.videoMuted=e.videoMuted,this.speakingVolumeSamples=new Array(PO).fill(-1/0),this.updateStream(null,e.stream),this.hasAudioTrack&&this.initVolumeMeasuring()}get hasAudioTrack(){return this.stream.getAudioTracks().length>0}updateStream(e,t){t!==e&&(e&&(e.removeEventListener("addtrack",this.onAddTrack),this.measureVolumeActivity(!1)),t&&(this.stream=t,t.addEventListener("addtrack",this.onAddTrack),this.hasAudioTrack?this.initVolumeMeasuring():this.measureVolumeActivity(!1)),this.emit(yn.NewStream,this.stream))}initVolumeMeasuring(){const e=window.AudioContext||window.webkitAudioContext;if(!this.hasAudioTrack||!e)return;this.audioContext=new e,this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=512,this.analyser.smoothingTimeConstant=.1,this.audioContext.createMediaStreamSource(this.stream).connect(this.analyser),this.frequencyBinCount=new Float32Array(this.analyser.frequencyBinCount)}getMember(){return this.client.getRoom(this.roomId).getMember(this.userId)}isLocal(){return this.userId===this.client.getUserId()}isAudioMuted(){return this.stream.getAudioTracks().length===0||this.audioMuted}isVideoMuted(){return this.stream.getVideoTracks().length===0||this.videoMuted}isSpeaking(){return this.speaking}setNewStream(e){this.updateStream(this.stream,e)}setAudioMuted(e){this.audioMuted=e,this.speakingVolumeSamples.fill(-1/0),this.emit(yn.MuteStateChanged,this.audioMuted,this.videoMuted)}setVideoMuted(e){this.videoMuted=e,this.emit(yn.MuteStateChanged,this.audioMuted,this.videoMuted)}measureVolumeActivity(e){if(e){if(!this.audioContext||!this.analyser||!this.frequencyBinCount||!this.hasAudioTrack)return;this.measuringVolumeActivity=!0,this.volumeLooper()}else this.measuringVolumeActivity=!1,this.speakingVolumeSamples.fill(-1/0),this.emit(yn.VolumeChanged,-1/0)}setSpeakingThreshold(e){this.speakingThreshold=e}dispose(){clearTimeout(this.volumeLooperTimeout)}}Qn.CallFeed=MO;var AO=V.exports;Object.defineProperty(Te,"__esModule",{value:!0});Te.MatrixCall=Te.CallType=Te.CallState=Te.CallParty=Te.CallEvent=Te.CallErrorCode=Te.CallError=Te.CallDirection=void 0;Te.createNewMatrixCall=NO;var te=AO(Y.exports),K=ie,Vu=UO(G),Cr=ne,DO=oi,We=ps,Xo=Qn,cg=qe;function xv(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(xv=function(r){return r?t:e})(n)}function UO(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=xv(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}let he;Te.CallState=he;(function(n){n.Fledgling="fledgling",n.InviteSent="invite_sent",n.WaitLocalMedia="wait_local_media",n.CreateOffer="create_offer",n.CreateAnswer="create_answer",n.Connecting="connecting",n.Connected="connected",n.Ringing="ringing",n.Ended="ended"})(he||(Te.CallState=he={}));let Fa;Te.CallType=Fa;(function(n){n.Voice="voice",n.Video="video"})(Fa||(Te.CallType=Fa={}));let Gn;Te.CallDirection=Gn;(function(n){n.Inbound="inbound",n.Outbound="outbound"})(Gn||(Te.CallDirection=Gn={}));let He;Te.CallParty=He;(function(n){n.Local="local",n.Remote="remote"})(He||(Te.CallParty=He={}));let Ce;Te.CallEvent=Ce;(function(n){n.Hangup="hangup",n.State="state",n.Error="error",n.Replaced="replaced",n.LocalHoldUnhold="local_hold_unhold",n.RemoteHoldUnhold="remote_hold_unhold",n.HoldUnhold="hold_unhold",n.FeedsChanged="feeds_changed",n.AssertedIdentityChanged="asserted_identity_changed",n.LengthChanged="length_changed",n.DataChannel="datachannel"})(Ce||(Te.CallEvent=Ce={}));let ge;Te.CallErrorCode=ge;(function(n){n.UserHangup="user_hangup",n.LocalOfferFailed="local_offer_failed",n.NoUserMedia="no_user_media",n.UnknownDevices="unknown_devices",n.SendInvite="send_invite",n.CreateAnswer="create_answer",n.SendAnswer="send_answer",n.SetRemoteDescription="set_remote_description",n.SetLocalDescription="set_local_description",n.AnsweredElsewhere="answered_elsewhere",n.IceFailed="ice_failed",n.InviteTimeout="invite_timeout",n.Replaced="replaced",n.SignallingFailed="signalling_timeout",n.UserBusy="user_busy",n.Transfered="transferred"})(ge||(Te.CallErrorCode=ge={}));const $O=1,xO="stun:turn.matrix.org",lg=6e4;class zi extends Error{constructor(e,t,r){super(t+": "+r);(0,te.default)(this,"code",void 0),this.code=e}}Te.CallError=zi;function Ks(){return Date.now().toString()+(0,DO.randomString)(16)}class Nv extends cg.TypedEventEmitter{constructor(e){super();(0,te.default)(this,"roomId",void 0),(0,te.default)(this,"callId",void 0),(0,te.default)(this,"state",he.Fledgling),(0,te.default)(this,"hangupParty",void 0),(0,te.default)(this,"hangupReason",void 0),(0,te.default)(this,"direction",void 0),(0,te.default)(this,"ourPartyId",void 0),(0,te.default)(this,"client",void 0),(0,te.default)(this,"forceTURN",void 0),(0,te.default)(this,"turnServers",void 0),(0,te.default)(this,"candidateSendQueue",[]),(0,te.default)(this,"candidateSendTries",0),(0,te.default)(this,"sentEndOfCandidates",!1),(0,te.default)(this,"peerConn",void 0),(0,te.default)(this,"feeds",[]),(0,te.default)(this,"usermediaSenders",[]),(0,te.default)(this,"screensharingSenders",[]),(0,te.default)(this,"inviteOrAnswerSent",!1),(0,te.default)(this,"waitForLocalAVStream",void 0),(0,te.default)(this,"successor",void 0),(0,te.default)(this,"opponentMember",void 0),(0,te.default)(this,"opponentVersion",void 0),(0,te.default)(this,"opponentPartyId",void 0),(0,te.default)(this,"opponentCaps",void 0),(0,te.default)(this,"inviteTimeout",void 0),(0,te.default)(this,"remoteOnHold",!1),(0,te.default)(this,"callStatsAtEnd",void 0),(0,te.default)(this,"makingOffer",!1),(0,te.default)(this,"ignoreOffer",void 0),(0,te.default)(this,"remoteCandidateBuffer",new Map),(0,te.default)(this,"remoteAssertedIdentity",void 0),(0,te.default)(this,"remoteSDPStreamMetadata",void 0),(0,te.default)(this,"callLengthInterval",void 0),(0,te.default)(this,"callLength",0),(0,te.default)(this,"gotLocalIceCandidate",t=>{if(t.candidate){if(K.logger.debug("Call "+this.callId+" got local ICE "+t.candidate.sdpMid+" candidate: "+t.candidate.candidate),this.callHasEnded())return;(t.candidate.candidate!==""||!this.sentEndOfCandidates)&&(this.queueCandidate(t.candidate),t.candidate.candidate===""&&(this.sentEndOfCandidates=!0))}}),(0,te.default)(this,"onIceGatheringStateChange",t=>{if(K.logger.debug("ice gathering state changed to "+this.peerConn.iceGatheringState),this.peerConn.iceGatheringState==="complete"&&!this.sentEndOfCandidates){const r={candidate:""};this.queueCandidate(r),this.sentEndOfCandidates=!0}}),(0,te.default)(this,"gotLocalOffer",async t=>{if(K.logger.debug("Created offer: ",t),this.callHasEnded()){K.logger.debug("Ignoring newly created offer on call ID "+this.callId+" because the call has ended");return}try{await this.peerConn.setLocalDescription(t)}catch(s){K.logger.debug("Error setting local description!",s),this.terminate(He.Local,ge.SetLocalDescription,!0);return}if(this.peerConn.iceGatheringState==="gathering"&&await new Promise(s=>{setTimeout(s,200)}),this.callHasEnded())return;const r=this.state===he.CreateOffer?Cr.EventType.CallInvite:Cr.EventType.CallNegotiate,i={lifetime:lg};this.state===he.CreateOffer?i.offer=this.peerConn.localDescription:i.description=this.peerConn.localDescription,i.capabilities={"m.call.transferee":this.client.supportsCallTransfer,"m.call.dtmf":!1},i[We.SDPStreamMetadataKey]=this.getLocalSDPStreamMetadata(),K.logger.info(`Discarding ${this.candidateSendQueue.length} candidates that will be sent in offer`),this.candidateSendQueue=[];try{await this.sendVoipEvent(r,i)}catch(s){K.logger.error("Failed to send invite",s),s.event&&this.client.cancelPendingEvent(s.event);let o=ge.SignallingFailed,c="Signalling failed";this.state===he.CreateOffer&&(o=ge.SendInvite,c="Failed to send invite"),s.name=="UnknownDeviceError"&&(o=ge.UnknownDevices,c="Unknown devices present in the room"),this.emit(Ce.Error,new zi(o,c,s)),this.terminate(He.Local,o,!1);return}this.sendCandidateQueue(),this.state===he.CreateOffer&&(this.inviteOrAnswerSent=!0,this.setState(he.InviteSent),this.inviteTimeout=setTimeout(()=>{this.inviteTimeout=null,this.state===he.InviteSent&&this.hangup(ge.InviteTimeout,!1)},lg))}),(0,te.default)(this,"getLocalOfferFailed",t=>{K.logger.error("Failed to get local offer",t),this.emit(Ce.Error,new zi(ge.LocalOfferFailed,"Failed to get local offer!",t)),this.terminate(He.Local,ge.LocalOfferFailed,!1)}),(0,te.default)(this,"getUserMediaFailed",t=>{if(this.successor){this.successor.getUserMediaFailed(t);return}K.logger.warn("Failed to get user media - ending call",t),this.emit(Ce.Error,new zi(ge.NoUserMedia,"Couldn't start capturing media! Is your microphone set up and does this app have permission?",t)),this.terminate(He.Local,ge.NoUserMedia,!1)}),(0,te.default)(this,"onIceConnectionStateChanged",()=>{this.callHasEnded()||(K.logger.debug("Call ID "+this.callId+": ICE connection state changed to: "+this.peerConn.iceConnectionState),this.peerConn.iceConnectionState=="connected"?(this.setState(he.Connected),this.callLengthInterval||(this.callLengthInterval=setInterval(()=>{this.callLength++,this.emit(Ce.LengthChanged,this.callLength)},1e3))):this.peerConn.iceConnectionState=="failed"&&this.hangup(ge.IceFailed,!1))}),(0,te.default)(this,"onSignallingStateChanged",()=>{K.logger.debug("call "+this.callId+": Signalling state changed to: "+this.peerConn.signalingState)}),(0,te.default)(this,"onTrack",t=>{if(t.streams.length===0){K.logger.warn(`Streamless ${t.track.kind} found: ignoring.`);return}const r=t.streams[0];this.pushRemoteFeed(r),r.addEventListener("removetrack",()=>{r.getTracks().length===0&&(K.logger.info(`Stream ID ${r.id} has no tracks remaining - removing`),this.deleteFeedByStream(r))})}),(0,te.default)(this,"onDataChannel",t=>{this.emit(Ce.DataChannel,t.channel)}),(0,te.default)(this,"onNegotiationNeeded",async()=>{if(K.logger.info("Negotiation is needed!"),this.state!==he.CreateOffer&&this.opponentVersion===0){K.logger.info("Opponent does not support renegotiation: ignoring negotiationneeded event");return}this.makingOffer=!0;try{this.getRidOfRTXCodecs();const t=await this.peerConn.createOffer();await this.gotLocalOffer(t)}catch(t){this.getLocalOfferFailed(t);return}finally{this.makingOffer=!1}}),(0,te.default)(this,"onHangupReceived",t=>{K.logger.debug("Hangup received for call ID "+this.callId),this.partyIdMatches(t)||this.state===he.Ringing?this.terminate(He.Remote,t.reason||ge.UserHangup,!0):K.logger.info(`Ignoring message from party ID ${t.party_id}: our partner is ${this.opponentPartyId}`)}),(0,te.default)(this,"onRejectReceived",t=>{K.logger.debug("Reject received for call ID "+this.callId),[he.InviteSent,he.Ringing].includes(this.state)||this.state===he.Fledgling&&this.direction===Gn.Inbound?this.terminate(He.Remote,t.reason||ge.UserHangup,!0):K.logger.debug(`Call is in state: ${this.state}: ignoring reject`)}),(0,te.default)(this,"onAnsweredElsewhere",t=>{K.logger.debug("Call ID "+this.callId+" answered elsewhere"),this.terminate(He.Remote,ge.AnsweredElsewhere,!0)}),this.roomId=e.roomId,this.client=e.client,this.forceTURN=e.forceTURN,this.ourPartyId=this.client.deviceId,this.turnServers=e.turnServers||[],this.turnServers.length===0&&this.client.isFallbackICEServerAllowed()&&this.turnServers.push({urls:[xO]});for(const t of this.turnServers)Vu.checkObjectHasKeys(t,["urls"]);this.callId=Ks()}async placeVoiceCall(){await this.placeCall(!0,!1)}async placeVideoCall(){await this.placeCall(!0,!0)}createDataChannel(e,t){const r=this.peerConn.createDataChannel(e,t);return this.emit(Ce.DataChannel,r),K.logger.debug("created data channel"),r}getOpponentMember(){return this.opponentMember}opponentCanBeTransferred(){return Boolean(this.opponentCaps&&this.opponentCaps["m.call.transferee"])}opponentSupportsDTMF(){return Boolean(this.opponentCaps&&this.opponentCaps["m.call.dtmf"])}getRemoteAssertedIdentity(){return this.remoteAssertedIdentity}get type(){return this.hasLocalUserMediaVideoTrack||this.hasRemoteUserMediaVideoTrack?Fa.Video:Fa.Voice}get hasLocalUserMediaVideoTrack(){var e;return((e=this.localUsermediaStream)===null||e===void 0?void 0:e.getVideoTracks().length)>0}get hasRemoteUserMediaVideoTrack(){return this.getRemoteFeeds().some(e=>e.purpose===We.SDPStreamMetadataPurpose.Usermedia&&e.stream.getVideoTracks().length>0)}get hasLocalUserMediaAudioTrack(){var e;return((e=this.localUsermediaStream)===null||e===void 0?void 0:e.getAudioTracks().length)>0}get hasRemoteUserMediaAudioTrack(){return this.getRemoteFeeds().some(e=>e.purpose===We.SDPStreamMetadataPurpose.Usermedia&&e.stream.getAudioTracks().length>0)}get localUsermediaFeed(){return this.getLocalFeeds().find(e=>e.purpose===We.SDPStreamMetadataPurpose.Usermedia)}get localScreensharingFeed(){return this.getLocalFeeds().find(e=>e.purpose===We.SDPStreamMetadataPurpose.Screenshare)}get localUsermediaStream(){var e;return(e=this.localUsermediaFeed)===null||e===void 0?void 0:e.stream}get localScreensharingStream(){var e;return(e=this.localScreensharingFeed)===null||e===void 0?void 0:e.stream}get remoteUsermediaFeed(){return this.getRemoteFeeds().find(e=>e.purpose===We.SDPStreamMetadataPurpose.Usermedia)}get remoteScreensharingFeed(){return this.getRemoteFeeds().find(e=>e.purpose===We.SDPStreamMetadataPurpose.Screenshare)}get remoteUsermediaStream(){var e;return(e=this.remoteUsermediaFeed)===null||e===void 0?void 0:e.stream}get remoteScreensharingStream(){var e;return(e=this.remoteScreensharingFeed)===null||e===void 0?void 0:e.stream}getFeedByStreamId(e){return this.getFeeds().find(t=>t.stream.id===e)}getFeeds(){return this.feeds}getLocalFeeds(){return this.feeds.filter(e=>e.isLocal())}getRemoteFeeds(){return this.feeds.filter(e=>!e.isLocal())}getLocalSDPStreamMetadata(){const e={};for(const t of this.getLocalFeeds())e[t.stream.id]={purpose:t.purpose,audio_muted:t.isAudioMuted(),video_muted:t.isVideoMuted()};return K.logger.debug("Got local SDPStreamMetadata",e),e}noIncomingFeeds(){return!this.feeds.some(e=>!e.isLocal())}pushRemoteFeed(e){if(!this.opponentSupportsSDPStreamMetadata()){this.pushRemoteFeedWithoutMetadata(e);return}const t=this.getOpponentMember().userId,r=this.remoteSDPStreamMetadata[e.id].purpose,i=this.remoteSDPStreamMetadata[e.id].audio_muted,s=this.remoteSDPStreamMetadata[e.id].video_muted;if(!r){K.logger.warn(`Ignoring stream with id ${e.id} because we didn't get any metadata about it`);return}const o=this.getRemoteFeeds().find(c=>c.purpose===r);o?o.setNewStream(e):(this.feeds.push(new Xo.CallFeed({client:this.client,roomId:this.roomId,userId:t,stream:e,purpose:r,audioMuted:i,videoMuted:s})),this.emit(Ce.FeedsChanged,this.feeds)),K.logger.info(`Pushed remote stream (id="${e.id}", active="${e.active}", purpose=${r})`)}pushRemoteFeedWithoutMetadata(e){var t;const r=this.getOpponentMember().userId,i=We.SDPStreamMetadataPurpose.Usermedia,s=(t=this.feeds.find(c=>!c.isLocal()))===null||t===void 0?void 0:t.stream;if(s&&e.id!==s.id){K.logger.warn(`Ignoring new stream ID ${e.id}: we already have stream ID ${s.id}`);return}const o=this.getFeedByStreamId(e.id);o?o.setNewStream(e):(this.feeds.push(new Xo.CallFeed({client:this.client,roomId:this.roomId,audioMuted:!1,videoMuted:!1,userId:r,stream:e,purpose:i})),this.emit(Ce.FeedsChanged,this.feeds)),K.logger.info(`Pushed remote stream (id="${e.id}", active="${e.active}")`)}pushNewLocalFeed(e,t,r=!0){const i=this.client.getUserId();Si(e.getAudioTracks(),!0),Si(e.getVideoTracks(),!0);const s=this.getLocalFeeds().find(o=>o.purpose===t);s?s.setNewStream(e):(this.pushLocalFeed(new Xo.CallFeed({client:this.client,roomId:this.roomId,audioMuted:!1,videoMuted:!1,userId:i,stream:e,purpose:t}),r),this.emit(Ce.FeedsChanged,this.feeds))}pushLocalFeed(e,t=!0){if(this.feeds.push(e),t){const r=e.purpose===We.SDPStreamMetadataPurpose.Usermedia?this.usermediaSenders:this.screensharingSenders;r.splice(0,r.length);for(const i of e.stream.getTracks())K.logger.info(`Adding track (id="${i.id}", kind="${i.kind}", streamId="${e.stream.id}", streamPurpose="${e.purpose}", enabled=${i.enabled}) to peer connection`),r.push(this.peerConn.addTrack(i,e.stream))}K.logger.info(`Pushed local stream (id="${e.stream.id}", active="${e.stream.active}", purpose="${e.purpose}")`),this.emit(Ce.FeedsChanged,this.feeds)}removeLocalFeed(e){const t=e.purpose===We.SDPStreamMetadataPurpose.Usermedia?this.usermediaSenders:this.screensharingSenders;for(const r of t)this.peerConn.removeTrack(r);t.splice(0,t.length),this.deleteFeedByStream(e.stream)}deleteAllFeeds(){for(const e of this.feeds)e.dispose();this.feeds=[],this.emit(Ce.FeedsChanged,this.feeds)}deleteFeedByStream(e){K.logger.debug(`Removing feed with stream id ${e.id}`);const t=this.getFeedByStreamId(e.id);if(!t){K.logger.warn(`Didn't find the feed with stream id ${e.id} to delete`);return}t.dispose(),this.feeds.splice(this.feeds.indexOf(t),1),this.emit(Ce.FeedsChanged,this.feeds)}async getCurrentCallStats(){return this.callHasEnded()?this.callStatsAtEnd:this.collectCallStats()}async collectCallStats(){if(!this.peerConn)return;const e=await this.peerConn.getStats(),t=[];for(const r of e)t.push(r[1]);return t}async initWithInvite(e){var t;const r=e.getContent();this.direction=Gn.Inbound,await this.client.checkTurnServers()||K.logger.warn("Failed to get TURN credentials! Proceeding with call anyway...");const s=r[We.SDPStreamMetadataKey];s?this.updateRemoteSDPStreamMetadata(s):K.logger.debug("Did not get any SDPStreamMetadata! Can not send/receive multiple streams"),this.peerConn=this.createPeerConnection(),this.chooseOpponent(e);try{await this.peerConn.setRemoteDescription(r.offer),await this.addBufferedIceCandidates()}catch(c){K.logger.debug("Failed to set remote description",c),this.terminate(He.Local,ge.SetRemoteDescription,!1);return}const o=(t=this.feeds.find(c=>!c.isLocal()))===null||t===void 0?void 0:t.stream;if(!o||o.getTracks().length===0){K.logger.error("No remote stream or no tracks after setting remote description!"),this.terminate(He.Local,ge.SetRemoteDescription,!1);return}this.setState(he.Ringing),e.getLocalAge()&&setTimeout(()=>{this.state==he.Ringing&&(K.logger.debug("Call invite has expired. Hanging up."),this.hangupParty=He.Remote,this.setState(he.Ended),this.stopAllMedia(),this.peerConn.signalingState!="closed"&&this.peerConn.close(),this.emit(Ce.Hangup))},r.lifetime-e.getLocalAge())}initWithHangup(e){this.setState(he.Ended)}shouldAnswerWithMediaType(e,t,r){return e&&!t?(K.logger.warn(`Unable to answer with ${r} because the other side isn't sending it either.`),!1):!Vu.isNullOrUndefined(e)&&e!==t&&!this.opponentSupportsSDPStreamMetadata()?(K.logger.warn(`Unable to answer with ${r}=${e} because the other side doesn't support it. Answering with ${r}=${t}.`),t):e!=null?e:t}async answer(e,t){if(!this.inviteOrAnswerSent){if(e===!1&&t===!1)throw new Error("You CANNOT answer a call without media");if(K.logger.debug(`Answering call ${this.callId}`),!this.localUsermediaStream&&!this.waitForLocalAVStream){const r=this.state,i=this.shouldAnswerWithMediaType(e,this.hasRemoteUserMediaAudioTrack,"audio"),s=this.shouldAnswerWithMediaType(t,this.hasRemoteUserMediaVideoTrack,"video");this.setState(he.WaitLocalMedia),this.waitForLocalAVStream=!0;try{const o=await this.client.getMediaHandler().getUserMediaStream(i,s);this.waitForLocalAVStream=!1;const l=[new Xo.CallFeed({client:this.client,roomId:this.roomId,userId:this.client.getUserId(),stream:o,purpose:We.SDPStreamMetadataPurpose.Usermedia,audioMuted:!1,videoMuted:!1})];this.localScreensharingFeed&&l.push(this.localScreensharingFeed),this.answerWithCallFeeds(l)}catch(o){if(s)K.logger.warn("Failed to getUserMedia(), trying to getUserMedia() without video"),this.setState(r),this.waitForLocalAVStream=!1,await this.answer(i,!1);else{this.getUserMediaFailed(o);return}}}else this.waitForLocalAVStream&&this.setState(he.WaitLocalMedia)}}answerWithCallFeeds(e){this.inviteOrAnswerSent||(K.logger.debug(`Answering call ${this.callId}`),this.gotCallFeedsForAnswer(e))}replacedBy(e){this.state===he.WaitLocalMedia?(K.logger.debug("Telling new call to wait for local media"),e.waitForLocalAVStream=!0):[he.CreateOffer,he.InviteSent].includes(this.state)&&(K.logger.debug("Handing local stream to new call"),e.gotCallFeedsForAnswer(this.getLocalFeeds())),this.successor=e,this.emit(Ce.Replaced,e),this.hangup(ge.Replaced,!0)}hangup(e,t){if(this.callHasEnded()||(K.logger.debug("Ending call "+this.callId),this.terminate(He.Local,e,!t),this.state===he.WaitLocalMedia))return;const r={};(this.opponentVersion&&this.opponentVersion>=1||e!==ge.UserHangup)&&(r.reason=e),this.sendVoipEvent(Cr.EventType.CallHangup,r)}reject(){if(this.state!==he.Ringing)throw Error("Call must be in 'ringing' state to reject!");if(this.opponentVersion<1){K.logger.info(`Opponent version is less than 1 (${this.opponentVersion}): sending hangup instead of reject`),this.hangup(ge.UserHangup,!0);return}K.logger.debug("Rejecting call: "+this.callId),this.terminate(He.Local,ge.UserHangup,!0),this.sendVoipEvent(Cr.EventType.CallReject,{})}async upgradeCall(e,t){if(!(!e&&!t)&&!!this.opponentSupportsSDPStreamMetadata())try{const r=e||this.hasLocalUserMediaAudioTrack,i=t||this.hasLocalUserMediaVideoTrack,s=await this.client.getMediaHandler().getUserMediaStream(r,i,!1);await this.updateLocalUsermediaStream(s,e,t)}catch(r){K.logger.error("Failed to upgrade the call",r),this.emit(Ce.Error,new zi(ge.NoUserMedia,"Failed to get camera access: ",r))}}opponentSupportsSDPStreamMetadata(){return Boolean(this.remoteSDPStreamMetadata)}isScreensharing(){return Boolean(this.localScreensharingStream)}async setScreensharingEnabled(e,t){if(e&&this.isScreensharing())return K.logger.warn("There is already a screensharing stream - there is nothing to do!"),!0;if(!e&&!this.isScreensharing())return K.logger.warn("There already isn't a screensharing stream - there is nothing to do!"),!1;if(!this.opponentSupportsSDPStreamMetadata())return await this.setScreensharingEnabledWithoutMetadataSupport(e,t);if(K.logger.debug(`Set screensharing enabled? ${e}`),e)try{const r=await this.client.getMediaHandler().getScreensharingStream(t);return r?(this.pushNewLocalFeed(r,We.SDPStreamMetadataPurpose.Screenshare),!0):!1}catch(r){return K.logger.error("Failed to get screen-sharing stream:",r),!1}else{for(const r of this.screensharingSenders)this.peerConn.removeTrack(r);return this.client.getMediaHandler().stopScreensharingStream(this.localScreensharingStream),this.deleteFeedByStream(this.localScreensharingStream),!1}}async setScreensharingEnabledWithoutMetadataSupport(e,t){if(K.logger.debug(`Set screensharing enabled? ${e} using replaceTrack()`),e)try{const r=await this.client.getMediaHandler().getScreensharingStream(t);if(!r)return!1;const i=r.getTracks().find(o=>o.kind==="video");return this.usermediaSenders.find(o=>{var c;return((c=o.track)===null||c===void 0?void 0:c.kind)==="video"}).replaceTrack(i),this.pushNewLocalFeed(r,We.SDPStreamMetadataPurpose.Screenshare,!1),!0}catch(r){return K.logger.error("Failed to get screen-sharing stream:",r),!1}else{const r=this.localUsermediaStream.getTracks().find(s=>s.kind==="video");return this.usermediaSenders.find(s=>{var o;return((o=s.track)===null||o===void 0?void 0:o.kind)==="video"}).replaceTrack(r),this.client.getMediaHandler().stopScreensharingStream(this.localScreensharingStream),this.deleteFeedByStream(this.localScreensharingStream),!1}}async updateLocalUsermediaStream(e,t=!1,r=!1){const i=this.localUsermediaFeed,s=t||!i.isAudioMuted()&&!this.remoteOnHold,o=r||!i.isVideoMuted()&&!this.remoteOnHold;Si(e.getAudioTracks(),s),Si(e.getVideoTracks(),o);for(const l of this.localUsermediaStream.getTracks())this.localUsermediaStream.removeTrack(l),l.stop();for(const l of e.getTracks())this.localUsermediaStream.addTrack(l);const c=[];for(const l of e.getTracks()){const u=this.usermediaSenders.find(g=>{var m;return((m=g.track)===null||m===void 0?void 0:m.kind)===l.kind});let a;u?(K.logger.info(`Replacing track (id="${l.id}", kind="${l.kind}", streamId="${e.id}", streamPurpose="${i.purpose}") to peer connection`),await u.replaceTrack(l),a=u):(K.logger.info(`Adding track (id="${l.id}", kind="${l.kind}", streamId="${e.id}", streamPurpose="${i.purpose}") to peer connection`),a=this.peerConn.addTrack(l,this.localUsermediaStream)),c.push(a)}this.usermediaSenders=c}async setLocalVideoMuted(e){var t;return await this.client.getMediaHandler().hasVideoDevice()?!this.hasLocalUserMediaVideoTrack&&!e?(await this.upgradeCall(!1,!0),this.isLocalVideoMuted()):((t=this.localUsermediaFeed)===null||t===void 0||t.setVideoMuted(e),this.updateMuteStatus(),this.isLocalVideoMuted()):this.isLocalVideoMuted()}isLocalVideoMuted(){var e;return(e=this.localUsermediaFeed)===null||e===void 0?void 0:e.isVideoMuted()}async setMicrophoneMuted(e){var t;return await this.client.getMediaHandler().hasAudioDevice()?!this.hasLocalUserMediaAudioTrack&&!e?(await this.upgradeCall(!0,!1),this.isMicrophoneMuted()):((t=this.localUsermediaFeed)===null||t===void 0||t.setAudioMuted(e),this.updateMuteStatus(),this.isMicrophoneMuted()):this.isMicrophoneMuted()}isMicrophoneMuted(){var e;return(e=this.localUsermediaFeed)===null||e===void 0?void 0:e.isAudioMuted()}isRemoteOnHold(){return this.remoteOnHold}setRemoteOnHold(e){if(this.isRemoteOnHold()!==e){this.remoteOnHold=e;for(const t of this.peerConn.getTransceivers())t.direction=e?"sendonly":"sendrecv";this.updateMuteStatus(),this.emit(Ce.RemoteHoldUnhold,this.remoteOnHold)}}isLocalOnHold(){if(this.state!==he.Connected)return!1;let e=!0;for(const t of this.peerConn.getTransceivers())["inactive","recvonly"].includes(t.currentDirection)||(e=!1);return e}sendDtmfDigit(e){for(const t of this.peerConn.getSenders())if(t.track.kind==="audio"&&t.dtmf){t.dtmf.insertDTMF(e);return}throw new Error("Unable to find a track to send DTMF on")}updateMuteStatus(){this.sendVoipEvent(Cr.EventType.CallSDPStreamMetadataChangedPrefix,{[We.SDPStreamMetadataKey]:this.getLocalSDPStreamMetadata()});const e=this.isMicrophoneMuted()||this.remoteOnHold,t=this.isLocalVideoMuted()||this.remoteOnHold;Si(this.localUsermediaStream.getAudioTracks(),!e),Si(this.localUsermediaStream.getVideoTracks(),!t)}gotCallFeedsForInvite(e){if(this.successor){this.successor.gotCallFeedsForAnswer(e);return}if(this.callHasEnded()){this.stopAllMedia();return}for(const t of e)this.pushLocalFeed(t);this.setState(he.CreateOffer),K.logger.debug("gotUserMediaForInvite")}async sendAnswer(){const e={answer:{sdp:this.peerConn.localDescription.sdp,type:this.peerConn.localDescription.type},[We.SDPStreamMetadataKey]:this.getLocalSDPStreamMetadata()};e.capabilities={"m.call.transferee":this.client.supportsCallTransfer,"m.call.dtmf":!1},K.logger.info(`Discarding ${this.candidateSendQueue.length} candidates that will be sent in answer`),this.candidateSendQueue=[];try{await this.sendVoipEvent(Cr.EventType.CallAnswer,e),this.inviteOrAnswerSent=!0}catch(t){this.setState(he.Ringing),this.client.cancelPendingEvent(t.event);let r=ge.SendAnswer,i="Failed to send answer";throw t.name=="UnknownDeviceError"&&(r=ge.UnknownDevices,i="Unknown devices present in the room"),this.emit(Ce.Error,new zi(r,i,t)),t}this.sendCandidateQueue()}async gotCallFeedsForAnswer(e){if(this.callHasEnded())return;this.waitForLocalAVStream=!1;for(const r of e)this.pushLocalFeed(r);this.setState(he.CreateAnswer);let t;try{this.getRidOfRTXCodecs(),t=await this.peerConn.createAnswer()}catch(r){K.logger.debug("Failed to create answer: ",r),this.terminate(He.Local,ge.CreateAnswer,!0);return}try{await this.peerConn.setLocalDescription(t),this.setState(he.Connecting),await new Promise(r=>{setTimeout(r,200)}),this.sendAnswer()}catch(r){K.logger.debug("Error setting local description!",r),this.terminate(He.Local,ge.SetLocalDescription,!0);return}}async onRemoteIceCandidatesReceived(e){if(this.callHasEnded())return;const t=e.getContent(),r=t.candidates;if(!r){K.logger.info("Ignoring candidates event with no candidates!");return}const i=t.version===0?null:t.party_id||null;if(this.opponentPartyId===void 0){K.logger.info(`Buffering ${r.length} candidates until we pick an opponent`);const s=this.remoteCandidateBuffer.get(i)||[];s.push(...r),this.remoteCandidateBuffer.set(i,s);return}if(!this.partyIdMatches(t)){K.logger.info(`Ignoring candidates from party ID ${t.party_id}: we have chosen party ID ${this.opponentPartyId}`);return}await this.addIceCandidates(r)}async onAnswerReceived(e){const t=e.getContent();if(K.logger.debug(`Got answer for call ID ${this.callId} from party ID ${t.party_id}`),this.callHasEnded()){K.logger.debug(`Ignoring answer because call ID ${this.callId} has ended`);return}if(this.opponentPartyId!==void 0){K.logger.info(`Ignoring answer from party ID ${t.party_id}: we already have an answer/reject from ${this.opponentPartyId}`);return}this.chooseOpponent(e),await this.addBufferedIceCandidates(),this.setState(he.Connecting);const r=t[We.SDPStreamMetadataKey];r?this.updateRemoteSDPStreamMetadata(r):K.logger.warn("Did not get any SDPStreamMetadata! Can not send/receive multiple streams");try{await this.peerConn.setRemoteDescription(t.answer)}catch(i){K.logger.debug("Failed to set remote description",i),this.terminate(He.Local,ge.SetRemoteDescription,!1);return}if(this.opponentPartyId!==null)try{await this.sendVoipEvent(Cr.EventType.CallSelectAnswer,{selected_party_id:this.opponentPartyId})}catch(i){K.logger.warn("Failed to send select_answer event",i)}}async onSelectAnswerReceived(e){if(this.direction!==Gn.Inbound){K.logger.warn("Got select_answer for an outbound call: ignoring");return}const t=e.getContent().selected_party_id;if(t==null){K.logger.warn("Got nonsensical select_answer with null/undefined selected_party_id: ignoring");return}t!==this.ourPartyId&&(K.logger.info(`Got select_answer for party ID ${t}: we are party ID ${this.ourPartyId}.`),this.terminate(He.Remote,ge.AnsweredElsewhere,!0))}async onNegotiateReceived(e){const t=e.getContent(),r=t.description;if(!r||!r.sdp||!r.type){K.logger.info("Ignoring invalid m.call.negotiate event");return}const i=this.direction===Gn.Inbound,s=r.type==="offer"&&(this.makingOffer||this.peerConn.signalingState!=="stable");if(this.ignoreOffer=!i&&s,this.ignoreOffer){K.logger.info("Ignoring colliding negotiate event because we're impolite");return}const o=this.isLocalOnHold(),c=t[We.SDPStreamMetadataKey];c?this.updateRemoteSDPStreamMetadata(c):K.logger.warn("Received negotiation event without SDPStreamMetadata!");try{if(await this.peerConn.setRemoteDescription(r),r.type==="offer"){this.getRidOfRTXCodecs();const u=await this.peerConn.createAnswer();await this.peerConn.setLocalDescription(u),this.sendVoipEvent(Cr.EventType.CallNegotiate,{description:this.peerConn.localDescription,[We.SDPStreamMetadataKey]:this.getLocalSDPStreamMetadata()})}}catch(u){K.logger.warn("Failed to complete negotiation",u)}const l=this.isLocalOnHold();o!==l&&(this.emit(Ce.LocalHoldUnhold,l),this.emit(Ce.HoldUnhold,l))}updateRemoteSDPStreamMetadata(e){this.remoteSDPStreamMetadata=Vu.recursivelyAssign(this.remoteSDPStreamMetadata||{},e,!0);for(const s of this.getRemoteFeeds()){var t,r,i;const o=s.stream.id;s.setAudioMuted((t=this.remoteSDPStreamMetadata[o])===null||t===void 0?void 0:t.audio_muted),s.setVideoMuted((r=this.remoteSDPStreamMetadata[o])===null||r===void 0?void 0:r.video_muted),s.purpose=(i=this.remoteSDPStreamMetadata[o])===null||i===void 0?void 0:i.purpose}}onSDPStreamMetadataChangedReceived(e){const r=e.getContent()[We.SDPStreamMetadataKey];this.updateRemoteSDPStreamMetadata(r)}async onAssertedIdentityReceived(e){const t=e.getContent();!t.asserted_identity||(this.remoteAssertedIdentity={id:t.asserted_identity.id,displayName:t.asserted_identity.display_name},this.emit(Ce.AssertedIdentityChanged))}callHasEnded(){return this.state===he.Ended}getRidOfRTXCodecs(){if(!RTCRtpReceiver.getCapabilities||!RTCRtpSender.getCapabilities)return;const e=RTCRtpReceiver.getCapabilities("video").codecs,r=[...RTCRtpSender.getCapabilities("video").codecs,...e];for(const o of r)if(o.mimeType==="video/rtx"){const c=r.indexOf(o);r.splice(c,1)}for(const o of this.peerConn.getTransceivers()){var i,s;this.screensharingSenders.includes(o.sender)&&(((i=o.sender.track)===null||i===void 0?void 0:i.kind)==="video"||((s=o.receiver.track)===null||s===void 0?void 0:s.kind)==="video")&&o.setCodecPreferences(r)}}setState(e){const t=this.state;this.state=e,this.emit(Ce.State,e,t)}sendVoipEvent(e,t){return this.client.sendEvent(this.roomId,e,Object.assign({},t,{version:$O,call_id:this.callId,party_id:this.ourPartyId}))}queueCandidate(e){if(this.candidateSendQueue.push(e),this.state===he.Ringing||!this.inviteOrAnswerSent)return;const t=this.direction===Gn.Inbound?500:2e3;this.candidateSendTries===0&&setTimeout(()=>{this.sendCandidateQueue()},t)}async transfer(e){const t=await this.client.getProfileInfo(e),r=Ks(),i={replacement_id:Ks(),target_user:{id:e,display_name:t.displayname,avatar_url:t.avatar_url},create_call:r};await this.sendVoipEvent(Cr.EventType.CallReplaces,i),await this.terminate(He.Local,ge.Transfered,!0)}async transferToCall(e){const t=await this.client.getProfileInfo(e.getOpponentMember().userId),r=await this.client.getProfileInfo(this.getOpponentMember().userId),i=Ks(),s={replacement_id:Ks(),target_user:{id:this.getOpponentMember().userId,display_name:r.displayname,avatar_url:r.avatar_url},await_call:i};await e.sendVoipEvent(Cr.EventType.CallReplaces,s);const o={replacement_id:Ks(),target_user:{id:e.getOpponentMember().userId,display_name:t.displayname,avatar_url:t.avatar_url},create_call:i};await this.sendVoipEvent(Cr.EventType.CallReplaces,o),await this.terminate(He.Local,ge.Transfered,!0),await e.terminate(He.Local,ge.Transfered,!0)}async terminate(e,t,r){this.callHasEnded()||(this.callStatsAtEnd=await this.collectCallStats(),this.inviteTimeout&&(clearTimeout(this.inviteTimeout),this.inviteTimeout=null),this.callLengthInterval&&(clearInterval(this.callLengthInterval),this.callLengthInterval=null),t!==ge.Replaced&&this.stopAllMedia(),this.deleteAllFeeds(),this.hangupParty=e,this.hangupReason=t,this.setState(he.Ended),this.peerConn&&this.peerConn.signalingState!=="closed"&&this.peerConn.close(),r&&this.emit(Ce.Hangup))}stopAllMedia(){K.logger.debug("Stopping all media for call",this.callId);for(const e of this.feeds)if(e.isLocal()&&e.purpose===We.SDPStreamMetadataPurpose.Usermedia)this.client.getMediaHandler().stopUserMediaStream(e.stream);else if(e.isLocal()&&e.purpose===We.SDPStreamMetadataPurpose.Screenshare)this.client.getMediaHandler().stopScreensharingStream(e.stream);else{K.logger.debug("Stopping remote stream",e.stream.id);for(const t of e.stream.getTracks())t.stop()}}checkForErrorListener(){if(this.listeners(cg.EventEmitterEvents.Error).length===0)throw new Error("You MUST attach an error listener using call.on('error', function() {})")}async sendCandidateQueue(){if(this.candidateSendQueue.length===0)return;const e=this.candidateSendQueue;this.candidateSendQueue=[],++this.candidateSendTries;const t={candidates:e};K.logger.debug("Attempting to send "+e.length+" candidates");try{await this.sendVoipEvent(Cr.EventType.CallCandidates,t),this.candidateSendTries=0}catch(r){if(r.event&&this.client.cancelPendingEvent(r.event),this.candidateSendQueue.push(...e),this.candidateSendTries>5){K.logger.debug("Failed to send candidates on attempt "+this.candidateSendTries+". Giving up on this call.",r);const s=ge.SignallingFailed,o="Signalling failed";this.emit(Ce.Error,new zi(s,o,r)),this.hangup(s,!1);return}const i=500*Math.pow(2,this.candidateSendTries);++this.candidateSendTries,K.logger.debug("Failed to send candidates. Retrying in "+i+"ms",r),setTimeout(()=>{this.sendCandidateQueue()},i)}}async placeCall(e,t){if(!e)throw new Error("You CANNOT start a call without audio");this.setState(he.WaitLocalMedia);try{const r=await this.client.getMediaHandler().getUserMediaStream(e,t);Si(r.getAudioTracks(),!0),Si(r.getVideoTracks(),!0);const i=new Xo.CallFeed({client:this.client,roomId:this.roomId,userId:this.client.getUserId(),stream:r,purpose:We.SDPStreamMetadataPurpose.Usermedia,audioMuted:!1,videoMuted:!1});await this.placeCallWithCallFeeds([i])}catch(r){this.getUserMediaFailed(r);return}}async placeCallWithCallFeeds(e){this.checkForErrorListener(),this.direction=Gn.Outbound,this.client.callEventHandler.calls.set(this.callId,this),await this.client.checkTurnServers()||K.logger.warn("Failed to get TURN credentials! Proceeding with call anyway..."),this.peerConn=this.createPeerConnection(),this.gotCallFeedsForInvite(e)}createPeerConnection(){const e=new window.RTCPeerConnection({iceTransportPolicy:this.forceTURN?"relay":void 0,iceServers:this.turnServers,iceCandidatePoolSize:this.client.iceCandidatePoolSize});return e.addEventListener("iceconnectionstatechange",this.onIceConnectionStateChanged),e.addEventListener("signalingstatechange",this.onSignallingStateChanged),e.addEventListener("icecandidate",this.gotLocalIceCandidate),e.addEventListener("icegatheringstatechange",this.onIceGatheringStateChange),e.addEventListener("track",this.onTrack),e.addEventListener("negotiationneeded",this.onNegotiationNeeded),e.addEventListener("datachannel",this.onDataChannel),e}partyIdMatches(e){return(e.version===0?null:e.party_id||null)===this.opponentPartyId}chooseOpponent(e){const t=e.getContent();K.logger.debug(`Choosing party ID ${t.party_id} for call ID ${this.callId}`),this.opponentVersion=t.version,this.opponentVersion===0?this.opponentPartyId=null:this.opponentPartyId=t.party_id||null,this.opponentCaps=t.capabilities||{},this.opponentMember=e.sender}async addBufferedIceCandidates(){const e=this.remoteCandidateBuffer.get(this.opponentPartyId);e&&(K.logger.info(`Adding ${e.length} buffered candidates for opponent ${this.opponentPartyId}`),await this.addIceCandidates(e)),this.remoteCandidateBuffer=null}async addIceCandidates(e){for(const t of e){if((t.sdpMid===null||t.sdpMid===void 0)&&(t.sdpMLineIndex===null||t.sdpMLineIndex===void 0)){K.logger.debug("Ignoring remote ICE candidate with no sdpMid or sdpMLineIndex");continue}K.logger.debug("Call "+this.callId+" got remote ICE "+t.sdpMid+" candidate: "+t.candidate);try{await this.peerConn.addIceCandidate(t)}catch(r){this.ignoreOffer||K.logger.info("Failed to add remote ICE candidate",r)}}}get hasPeerConnection(){return Boolean(this.peerConn)}}Te.MatrixCall=Nv;function Si(n,e){for(let t=0;t<n.length;t++)n[t].enabled=e}function NO(n,e,t){if(typeof window=="undefined"||typeof document=="undefined")return null;try{if(!Boolean(window.RTCPeerConnection||window.RTCSessionDescription||window.RTCIceCandidate||navigator.mediaDevices))return K.logger.error("WebRTC is not supported in this browser / environment"),null}catch(o){return K.logger.error("Exception thrown when trying to access WebRTC",o),null}const r=t?t.forceTURN:!1,i={client:n,roomId:e,turnServers:n.getTurnServers(),forceTURN:n.forceTURN||r},s=new Nv(i);return n.reEmitter.reEmit(s,Object.values(Ce)),s}var gs={},LO=V.exports;Object.defineProperty(gs,"__esModule",{value:!0});gs.CallEventHandlerEvent=gs.CallEventHandler=void 0;var Fs=LO(Y.exports),BO=qt,bi=ie,pr=Te,Ut=ne,ug=it,KO=Ui,dg=ar;const FO=3e3;let Sl;gs.CallEventHandlerEvent=Sl;(function(n){n.Incoming="Call.incoming"})(Sl||(gs.CallEventHandlerEvent=Sl={}));class qO{constructor(e){(0,Fs.default)(this,"client",void 0),(0,Fs.default)(this,"calls",void 0),(0,Fs.default)(this,"callEventBuffer",void 0),(0,Fs.default)(this,"candidateEventsByCall",void 0),(0,Fs.default)(this,"evaluateEventBuffer",async()=>{if(this.client.getSyncState()===KO.SyncState.Syncing){await Promise.all(this.callEventBuffer.map(r=>{this.client.decryptEventIfNeeded(r)}));const t=new Set;for(const r of this.callEventBuffer)(r.getType()===Ut.EventType.CallAnswer||r.getType()===Ut.EventType.CallHangup)&&t.add(r.getContent().call_id);for(const r of this.callEventBuffer)if(!(r.getType()===Ut.EventType.CallInvite&&t.has(r.getContent().call_id)))try{await this.handleCallEvent(r)}catch(i){bi.logger.error("Caught exception handling call event",i)}this.callEventBuffer=[]}}),(0,Fs.default)(this,"onRoomTimeline",t=>{this.client.decryptEventIfNeeded(t),(this.eventIsACall(t)||t.isBeingDecrypted())&&this.callEventBuffer.push(t),(t.isBeingDecrypted()||t.isDecryptionFailure())&&t.once(BO.MatrixEventEvent.Decrypted,async()=>{if(!!this.eventIsACall(t))if(this.callEventBuffer.includes(t))this.evaluateEventBuffer();else try{await this.handleCallEvent(t)}catch(r){bi.logger.error("Caught exception handling call event",r)}})}),this.client=e,this.calls=new Map,this.callEventBuffer=[],this.candidateEventsByCall=new Map}start(){this.client.on(ug.ClientEvent.Sync,this.evaluateEventBuffer),this.client.on(dg.RoomEvent.Timeline,this.onRoomTimeline)}stop(){this.client.removeListener(ug.ClientEvent.Sync,this.evaluateEventBuffer),this.client.removeListener(dg.RoomEvent.Timeline,this.onRoomTimeline)}eventIsACall(e){const t=e.getType();return t.startsWith("m.call.")||t.startsWith("org.matrix.call.")}async handleCallEvent(e){const t=e.getContent(),r=e.getType(),i=e.getSender()===this.client.credentials.userId;let s=t.call_id?this.calls.get(t.call_id):void 0;if(r===Ut.EventType.CallInvite){if(i||e.getLocalAge()>t.lifetime-FO||s&&s.state===pr.CallState.Ended)return;s&&bi.logger.log(`WARN: Already have a MatrixCall with id ${t.call_id} but got an invite. Clobbering.`);const o=this.client.getTurnServersExpiry()-Date.now();if(bi.logger.info("Current turn creds expire in "+o+" ms"),s=(0,pr.createNewMatrixCall)(this.client,e.getRoomId(),{forceTURN:this.client.forceTURN}),!s){bi.logger.log("Incoming call ID "+t.call_id+" but this client doesn't support WebRTC");return}if(s.callId=t.call_id,await s.initWithInvite(e),this.calls.set(s.callId,s),this.candidateEventsByCall.get(s.callId))for(const l of this.candidateEventsByCall.get(s.callId))s.onRemoteIceCandidatesReceived(l);let c;for(const l of this.calls.values()){const u=[pr.CallState.WaitLocalMedia,pr.CallState.CreateOffer,pr.CallState.InviteSent].includes(l.state);if(s.roomId===l.roomId&&l.direction===pr.CallDirection.Outbound&&u){c=l;break}}c?c.state===pr.CallState.WaitLocalMedia||c.state===pr.CallState.CreateOffer||c.callId>s.callId?(bi.logger.log("Glare detected: answering incoming call "+s.callId+" and canceling outgoing call "+c.callId),c.replacedBy(s),s.answer()):(bi.logger.log("Glare detected: rejecting incoming call "+s.callId+" and keeping outgoing call "+c.callId),s.hangup(pr.CallErrorCode.Replaced,!0)):this.client.emit(Sl.Incoming,s);return}else if(r===Ut.EventType.CallCandidates){if(i)return;s?s.onRemoteIceCandidatesReceived(e):(this.candidateEventsByCall.has(t.call_id)||this.candidateEventsByCall.set(t.call_id,[]),this.candidateEventsByCall.get(t.call_id).push(e));return}else if([Ut.EventType.CallHangup,Ut.EventType.CallReject].includes(r)){s?s.state!==pr.CallState.Ended&&(r===Ut.EventType.CallHangup?s.onHangupReceived(t):s.onRejectReceived(t),s.state===pr.CallState.Ended&&this.calls.delete(t.call_id)):(s=(0,pr.createNewMatrixCall)(this.client,e.getRoomId()),s&&(s.callId=t.call_id,s.initWithHangup(e),this.calls.set(t.call_id,s)));return}if(!s||!s.hasPeerConnection){bi.logger.warn("Discarding an event, we don't have a call/peerConn",r);return}if(e.getContent().party_id!==s.ourPartyId)switch(r){case Ut.EventType.CallAnswer:i?s.state===pr.CallState.Ringing&&s.onAnsweredElsewhere(t):s.onAnswerReceived(e);break;case Ut.EventType.CallSelectAnswer:s.onSelectAnswerReceived(e);break;case Ut.EventType.CallNegotiate:s.onNegotiateReceived(e);break;case Ut.EventType.CallAssertedIdentity:case Ut.EventType.CallAssertedIdentityPrefix:s.onAssertedIdentityReceived(e);break;case Ut.EventType.CallSDPStreamMetadataChanged:case Ut.EventType.CallSDPStreamMetadataChangedPrefix:s.onSDPStreamMetadataChangedReceived(e);break}}}gs.CallEventHandler=qO;var $i={},jO=V.exports;Object.defineProperty($i,"__esModule",{value:!0});$i.AutoDiscoveryAction=$i.AutoDiscovery=void 0;var lr=jO(Y.exports),hg=ki,$n=ie;let sr;$i.AutoDiscoveryAction=sr;(function(n){n.SUCCESS="SUCCESS",n.IGNORE="IGNORE",n.PROMPT="PROMPT",n.FAIL_PROMPT="FAIL_PROMPT",n.FAIL_ERROR="FAIL_ERROR"})(sr||($i.AutoDiscoveryAction=sr={}));class Z{static async fromDiscoveryConfig(e){const t={"m.homeserver":{state:Z.FAIL_ERROR,error:Z.ERROR_INVALID,base_url:null},"m.identity_server":{state:Z.PROMPT,error:null,base_url:null}};if(!e||!e["m.homeserver"])return $n.logger.error("No m.homeserver key in config"),t["m.homeserver"].state=Z.FAIL_PROMPT,t["m.homeserver"].error=Z.ERROR_INVALID,Promise.resolve(t);if(!e["m.homeserver"].base_url)return $n.logger.error("No m.homeserver base_url in config"),t["m.homeserver"].state=Z.FAIL_PROMPT,t["m.homeserver"].error=Z.ERROR_INVALID_HS_BASE_URL,Promise.resolve(t);const r=this.sanitizeWellKnownUrl(e["m.homeserver"].base_url);if(!r)return $n.logger.error("Invalid base_url for m.homeserver"),t["m.homeserver"].error=Z.ERROR_INVALID_HS_BASE_URL,Promise.resolve(t);const i=await this.fetchWellKnownObject(`${r}/_matrix/client/versions`);if(!i||!i.raw.versions)return $n.logger.error("Invalid /versions response"),t["m.homeserver"].error=Z.ERROR_INVALID_HOMESERVER,t["m.homeserver"].base_url=r,Promise.resolve(t);t["m.homeserver"]={state:Z.SUCCESS,error:null,base_url:r};let s="";if(e["m.identity_server"]){const o={"m.homeserver":t["m.homeserver"],"m.identity_server":{state:Z.FAIL_PROMPT,error:Z.ERROR_INVALID_IS,base_url:null}};if(s=this.sanitizeWellKnownUrl(e["m.identity_server"].base_url),!s)return $n.logger.error("Invalid base_url for m.identity_server"),o["m.identity_server"].error=Z.ERROR_INVALID_IS_BASE_URL,Promise.resolve(o);const c=await this.fetchWellKnownObject(`${s}/_matrix/identity/api/v1`);if(!c||!c.raw||c.action!==sr.SUCCESS)return $n.logger.error("Invalid /api/v1 response"),o["m.identity_server"].error=Z.ERROR_INVALID_IDENTITY_SERVER,o["m.identity_server"].base_url=s,Promise.resolve(o)}return s&&s.toString().length>0&&(t["m.identity_server"]={state:Z.SUCCESS,error:null,base_url:s}),Object.keys(e).map(o=>{if(o==="m.homeserver"||o==="m.identity_server"){const c=["error","state","base_url"];for(const l of Object.keys(e[o]))c.includes(l)||(t[o][l]=e[o][l])}else t[o]=e[o]}),Promise.resolve(t)}static async findClientConfig(e){if(!e||typeof e!="string"||e.length===0)throw new Error("'domain' must be a string of non-zero length");const t={"m.homeserver":{state:Z.FAIL_ERROR,error:Z.ERROR_INVALID,base_url:null},"m.identity_server":{state:Z.PROMPT,error:null,base_url:null}},r=await this.fetchWellKnownObject(`https://${e}/.well-known/matrix/client`);return!r||r.action!==sr.SUCCESS?($n.logger.error("No response or error when parsing .well-known"),r.reason&&$n.logger.error(r.reason),r.action===sr.IGNORE?t["m.homeserver"]={state:Z.PROMPT,error:null,base_url:null}:(t["m.homeserver"].state=Z.FAIL_PROMPT,t["m.homeserver"].error=Z.ERROR_INVALID),Promise.resolve(t)):Z.fromDiscoveryConfig(r.raw)}static async getRawClientConfig(e){if(!e||typeof e!="string"||e.length===0)throw new Error("'domain' must be a string of non-zero length");const t=await this.fetchWellKnownObject(`https://${e}/.well-known/matrix/client`);return t?t.raw||{}:{}}static sanitizeWellKnownUrl(e){if(!e)return!1;try{let t=null;try{hg.URL?t=new hg.URL(e):t=new URL(e)}catch{t=new URL(e)}if(!t||!t.hostname||t.protocol!=="http:"&&t.protocol!=="https:")return!1;const r=t.port?`:${t.port}`:"",i=t.pathname?t.pathname:"";let s=`${t.protocol}//${t.hostname}${r}${i}`;return s.endsWith("/")&&(s=s.substring(0,s.length-1)),s}catch(t){return $n.logger.error(t),!1}}static async fetchWellKnownObject(e){return new Promise(function(t,r){const i=Is.getRequest();if(!i)throw new Error("No request library available");i({method:"GET",uri:e,timeout:5e3},(s,o,c)=>{if(s||o&&(o.statusCode<200||o.statusCode>=300)){let l=sr.FAIL_PROMPT,u=(s?s.message:null)||"General failure";o&&o.statusCode===404&&(l=sr.IGNORE,u=Z.ERROR_MISSING_WELLKNOWN),t({raw:{},action:l,reason:u,error:s});return}try{t({raw:JSON.parse(c),action:sr.SUCCESS})}catch(l){let u=Z.ERROR_INVALID;l.name==="SyntaxError"&&(u=Z.ERROR_INVALID_JSON),t({raw:{},action:sr.FAIL_PROMPT,reason:u,error:l})}})})}}$i.AutoDiscovery=Z;(0,lr.default)(Z,"ERROR_INVALID","Invalid homeserver discovery response");(0,lr.default)(Z,"ERROR_GENERIC_FAILURE","Failed to get autodiscovery configuration from server");(0,lr.default)(Z,"ERROR_INVALID_HS_BASE_URL","Invalid base_url for m.homeserver");(0,lr.default)(Z,"ERROR_INVALID_HOMESERVER","Homeserver URL does not appear to be a valid Matrix homeserver");(0,lr.default)(Z,"ERROR_INVALID_IS_BASE_URL","Invalid base_url for m.identity_server");(0,lr.default)(Z,"ERROR_INVALID_IDENTITY_SERVER","Identity server URL does not appear to be a valid identity server");(0,lr.default)(Z,"ERROR_INVALID_IS","Invalid identity server discovery response");(0,lr.default)(Z,"ERROR_MISSING_WELLKNOWN","No .well-known JSON file found");(0,lr.default)(Z,"ERROR_INVALID_JSON","Invalid JSON");(0,lr.default)(Z,"ALL_ERRORS",[Z.ERROR_INVALID,Z.ERROR_GENERIC_FAILURE,Z.ERROR_INVALID_HS_BASE_URL,Z.ERROR_INVALID_HOMESERVER,Z.ERROR_INVALID_IS_BASE_URL,Z.ERROR_INVALID_IDENTITY_SERVER,Z.ERROR_INVALID_IS,Z.ERROR_MISSING_WELLKNOWN,Z.ERROR_INVALID_JSON]);(0,lr.default)(Z,"FAIL_ERROR",sr.FAIL_ERROR);(0,lr.default)(Z,"FAIL_PROMPT",sr.FAIL_PROMPT);(0,lr.default)(Z,"PROMPT",sr.PROMPT);(0,lr.default)(Z,"SUCCESS",sr.SUCCESS);var Me={},fg=/[\\\"\x00-\x1F]/g,ai={};for(var Ic=0;Ic<32;++Ic)ai[String.fromCharCode(Ic)]="\\U"+("0000"+Ic.toString(16)).slice(-4).toUpperCase();ai["\b"]="\\b";ai[" "]="\\t";ai[`
-`]="\\n";ai["\f"]="\\f";ai["\r"]="\\r";ai['"']='\\"';ai["\\"]="\\\\";function Lv(n){return fg.lastIndex=0,n.replace(fg,function(e){return ai[e]})}function lf(n){switch(typeof n){case"string":return'"'+Lv(n)+'"';case"number":return isFinite(n)?n:"null";case"boolean":return n;case"object":return n===null?"null":Array.isArray(n)?VO(n):GO(n);default:throw new Error("Cannot stringify: "+typeof n)}}function VO(n){for(var e="[",t="",r=0;r<n.length;++r)t+=e,e=",",t+=lf(n[r]);return e!=","?"[]":t+"]"}function GO(n){var e="{",t="",r=Object.keys(n);r.sort();for(var i=0;i<r.length;++i){var s=r[i];t+=e+'"'+Lv(s)+'":',e=",",t+=lf(n[s])}return e!=","?"{}":t+"}"}var Vl={stringify:lf},WO=V.exports;Object.defineProperty(Me,"__esModule",{value:!0});Me.OLM_ALGORITHM=Me.MEGOLM_BACKUP_ALGORITHM=zO=Me.MEGOLM_ALGORITHM=void 0;Me.decodeBase64=ik;Me.encodeBase64=Kv;Me.encodeUnpaddedBase64=nk;Me.encryptMessageForDevice=XO;Me.ensureOlmSessionsForDevices=ZO;Me.getExistingOlmSessions=QO;Me.pkSign=tk;Me.pkVerify=rk;Me.verifySignature=Bv;var uf=WO(Vl),Ca=ie,qa;(function(n){n.Olm="m.olm.v1.curve25519-aes-sha2",n.Megolm="m.megolm.v1.aes-sha2",n.MegolmBackup="m.megolm_backup.v1.curve25519-aes-sha2"})(qa||(qa={}));const HO=qa.Olm;Me.OLM_ALGORITHM=HO;const YO=qa.Megolm;var zO=Me.MEGOLM_ALGORITHM=YO;const JO=qa.MegolmBackup;Me.MEGOLM_BACKUP_ALGORITHM=JO;async function XO(n,e,t,r,i,s,o){const c=s.getIdentityKey(),l=await r.getSessionIdForDevice(c);if(l===null)return;Ca.logger.log("Using sessionid "+l+" for device "+i+":"+s.deviceId);const u={sender:e,sender_device:t,keys:{ed25519:r.deviceEd25519Key},recipient:i,recipient_keys:{ed25519:s.getFingerprint()}};Object.assign(u,o),n[c]=await r.encryptMessage(c,l,JSON.stringify(u))}async function QO(n,e,t){const r={},i={},s=[];for(const[o,c]of Object.entries(t))for(const l of c){const u=l.deviceId,a=l.getIdentityKey();s.push((async()=>{const g=await n.getSessionIdForDevice(a,!0);g===null?(r[o]=r[o]||[],r[o].push(l)):(i[o]=i[o]||{},i[o][u]={device:l,sessionId:g})})())}return await Promise.all(s),[r,i]}async function ZO(n,e,t,r=!1,i,s,o=Ca.logger){typeof r=="number"&&(o=s,s=i,i=r,r=!1);const c=[],l={},u={};for(const[,I]of Object.entries(t))for(const w of I){const k=w.getIdentityKey();k!==n.deviceCurve25519Key&&(n.sessionsInProgress[k]||(n.sessionsInProgress[k]=new Promise(P=>{u[k]=S=>{delete n.sessionsInProgress[k],P(S)}})))}for(const[I,w]of Object.entries(t)){l[I]={};for(const k of w){const P=k.deviceId,S=k.getIdentityKey();if(S===n.deviceCurve25519Key){o.info("Attempted to start session with ourself! Ignoring"),l[I][P]={device:k,sessionId:null};continue}const T=`for ${S} (${I}:${P})`,D=await n.getSessionIdForDevice(S,!!u[S],o);D!==null&&u[S]&&u[S](),(D===null||r)&&(r?o.info(`Forcing new Olm session ${T}`):o.info(`Making new Olm session ${T}`),c.push([I,P])),l[I][P]={device:k,sessionId:D}}}if(c.length===0)return l;const a="signed_curve25519";let g,m=`one-time keys for ${c.length} devices`;try{o.debug(`Claiming ${m}`),g=await e.claimOneTimeKeys(c,a,i),o.debug(`Claimed ${m}`)}catch(I){for(const w of Object.values(u))w();throw o.log(`Failed to claim ${m}`,I,c),I}s&&"failures"in g&&s.push(...Object.keys(g.failures));const p=g.one_time_keys||{},E=[];for(const[I,w]of Object.entries(t)){const k=p[I]||{};for(let P=0;P<w.length;P++){const S=w[P],T=S.deviceId,D=S.getIdentityKey();if(D===n.deviceCurve25519Key||l[I][T].sessionId&&!r)continue;const R=k[T]||{};let L=null;for(const H in R)H.indexOf(a+":")===0&&(L=R[H]);if(!L){o.warn(`No one-time keys (alg=${a}) for device ${I}:${T}`),u[D]&&u[D]();continue}E.push(ek(n,L,I,S).then(H=>{u[D]&&u[D](H),l[I][T].sessionId=H},H=>{throw u[D]&&u[D](),H}))}}return m=`Olm sessions for ${E.length} devices`,o.debug(`Starting ${m}`),await Promise.all(E),o.debug(`Started ${m}`),l}async function ek(n,e,t,r){const i=r.deviceId;try{await Bv(n,e,t,i,r.getFingerprint())}catch(o){return Ca.logger.error("Unable to verify signature on one-time key for device "+t+":"+i+":",o),null}let s;try{s=await n.createOutboundSession(r.getIdentityKey(),e.key)}catch(o){return Ca.logger.error("Error starting olm session with device "+t+":"+i+": "+o),null}return Ca.logger.log("Started new olm sessionid "+s+" for device "+t+":"+i),s}async function Bv(n,e,t,r,i){const s="ed25519:"+r,l=((e.signatures||{})[t]||{})[s];if(!l)throw Error("No signature");const u=Object.assign({},e);"unsigned"in u&&delete u.unsigned,delete u.signatures;const a=uf.default.stringify(u);n.verifySignature(i,a,l)}function tk(n,e,t,r){let i=!1;if(e instanceof Uint8Array){const c=new j.Olm.PkSigning;r=c.init_with_seed(e),e=c,i=!0}const s=n.signatures||{};delete n.signatures;const o=n.unsigned;n.unsigned&&delete n.unsigned;try{const c=s[t]||{};return s[t]=c,c["ed25519:"+r]=e.sign(uf.default.stringify(n))}finally{n.signatures=s,o&&(n.unsigned=o),i&&e.free()}}function rk(n,e,t){const r="ed25519:"+e;if(!(n.signatures&&n.signatures[t]&&n.signatures[t][r]))throw new Error("No signature");const i=n.signatures[t][r],s=new j.Olm.Utility,o=n.signatures;delete n.signatures;const c=n.unsigned;n.unsigned&&delete n.unsigned;try{s.ed25519_verify(e,uf.default.stringify(n),i)}finally{n.signatures=o,c&&(n.unsigned=c),s.free()}}function Kv(n){return Buffer.from(n).toString("base64")}function nk(n){return Kv(n).replace(/=+$/g,"")}function ik(n){return Buffer.from(n,"base64")}var Gl={},Kr={},Wl={};Object.defineProperty(Wl,"__esModule",{value:!0});Wl.LocalStorageCryptoStore=void 0;var pg=ie,sk=Po;const br="crypto.",Gu=br+"account",gg=br+"cross_signing_keys",mg=br+"notified_error_devices",yg=br+"device_data",el=br+"inboundgroupsessions/",ok=br+"inboundgroupsessions.withheld/",ak=br+"rooms/",qs=br+"sessionsneedingbackup";function Tc(n){return br+"sessions/"+n}function vg(n){return br+"session.problems/"+n}function Wu(n,e){return el+n+"/"+e}function _g(n,e){return ok+n+"/"+e}function Eg(n){return ak+n}class ck extends sk.MemoryCryptoStore{static exists(e){const t=e.length;for(let r=0;r<t;r++)if(e.key(r).startsWith(br))return!0;return!1}constructor(e){super();this.store=e}countEndToEndSessions(e,t){let r=0;for(let i=0;i<this.store.length;++i)this.store.key(i).startsWith(Tc(""))&&++r;t(r)}_getEndToEndSessions(e){const t=pt(this.store,Tc(e)),r={};for(const[i,s]of Object.entries(t||{}))typeof s=="string"?r[i]={session:s}:r[i]=s;return r}getEndToEndSession(e,t,r,i){const s=this._getEndToEndSessions(e);i(s[t]||{})}getEndToEndSessions(e,t,r){r(this._getEndToEndSessions(e)||{})}getAllEndToEndSessions(e,t){for(let r=0;r<this.store.length;++r)if(this.store.key(r).startsWith(Tc(""))){const i=this.store.key(r).split("/")[1];for(const s of Object.values(this._getEndToEndSessions(i)))t(s)}}storeEndToEndSession(e,t,r,i){const s=this._getEndToEndSessions(e)||{};s[t]=r,Pr(this.store,Tc(e),s)}async storeEndToEndSessionProblem(e,t,r){const i=vg(e),s=pt(this.store,i)||[];s.push({type:t,fixed:r,time:Date.now()}),s.sort((o,c)=>o.time-c.time),Pr(this.store,i,s)}async getEndToEndSessionProblem(e,t){const r=vg(e),i=pt(this.store,r)||[];if(!i.length)return null;const s=i[i.length-1];for(const o of i)if(o.time>t)return Object.assign({},o,{fixed:s.fixed});return s.fixed?null:s}async filterOutNotifiedErrorDevices(e){const t=pt(this.store,mg)||{},r=[];for(const i of e){const{userId:s,deviceInfo:o}=i;s in t?o.deviceId in t[s]||(r.push(i),t[s][o.deviceId]=!0):(r.push(i),t[s]={[o.deviceId]:!0})}return Pr(this.store,mg,t),r}getEndToEndInboundGroupSession(e,t,r,i){i(pt(this.store,Wu(e,t)),pt(this.store,_g(e,t)))}getAllEndToEndInboundGroupSessions(e,t){for(let r=0;r<this.store.length;++r){const i=this.store.key(r);i.startsWith(el)&&t({senderKey:i.substr(el.length,43),sessionId:i.substr(el.length+44),sessionData:pt(this.store,i)})}t(null)}addEndToEndInboundGroupSession(e,t,r,i){pt(this.store,Wu(e,t))||this.storeEndToEndInboundGroupSession(e,t,r,i)}storeEndToEndInboundGroupSession(e,t,r,i){Pr(this.store,Wu(e,t),r)}storeEndToEndInboundGroupSessionWithheld(e,t,r,i){Pr(this.store,_g(e,t),r)}getEndToEndDeviceData(e,t){t(pt(this.store,yg))}storeEndToEndDeviceData(e,t){Pr(this.store,yg,e)}storeEndToEndRoom(e,t,r){Pr(this.store,Eg(e),t)}getEndToEndRooms(e,t){const r={},i=Eg("");for(let s=0;s<this.store.length;++s){const o=this.store.key(s);if(o.startsWith(i)){const c=o.substr(i.length);r[c]=pt(this.store,o)}}t(r)}getSessionsNeedingBackup(e){const t=pt(this.store,qs)||{},r=[];for(const i in t)if(Object.prototype.hasOwnProperty.call(t,i)){const s=i.substr(0,43),o=i.substr(44);if(this.getEndToEndInboundGroupSession(s,o,null,c=>{r.push({senderKey:s,sessionId:o,sessionData:c})}),e&&i.length>=e)break}return Promise.resolve(r)}countSessionsNeedingBackup(){const e=pt(this.store,qs)||{};return Promise.resolve(Object.keys(e).length)}unmarkSessionsNeedingBackup(e){const t=pt(this.store,qs)||{};for(const r of e)delete t[r.senderKey+"/"+r.sessionId];return Pr(this.store,qs,t),Promise.resolve()}markSessionsNeedingBackup(e){const t=pt(this.store,qs)||{};for(const r of e)t[r.senderKey+"/"+r.sessionId]=!0;return Pr(this.store,qs,t),Promise.resolve()}deleteAllData(){return this.store.removeItem(Gu),Promise.resolve()}getAccount(e,t){const r=pt(this.store,Gu);t(r)}storeAccount(e,t){Pr(this.store,Gu,t)}getCrossSigningKeys(e,t){const r=pt(this.store,gg);t(r)}getSecretStorePrivateKey(e,t,r){const i=pt(this.store,br+`ssss_cache.${r}`);t(i)}storeCrossSigningKeys(e,t){Pr(this.store,gg,t)}storeSecretStorePrivateKey(e,t,r){Pr(this.store,br+`ssss_cache.${t}`,r)}doTxn(e,t,r){return Promise.resolve(r(null))}}Wl.LocalStorageCryptoStore=ck;function pt(n,e){try{return JSON.parse(n.getItem(e))}catch(t){pg.logger.log("Error: Failed to get key %s: %s",e,t.stack||t),pg.logger.log(t.stack)}return null}function Pr(n,e,t){n.setItem(e,JSON.stringify(t))}var ms={},lk=V.exports;Object.defineProperty(ms,"__esModule",{value:!0});ms.VERSION=ms.Backend=void 0;ms.upgradeDatabase=pk;var uk=lk(Y.exports),vn=ie,dk=hk(G);function Fv(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(Fv=function(r){return r?t:e})(n)}function hk(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=Fv(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}const qv=10;ms.VERSION=qv;class fk{constructor(e){this.db=e,(0,uk.default)(this,"nextTxnId",0),e.onversionchange=()=>{vn.logger.log(`versionchange for indexeddb ${this.db.name}: closing`),e.close()}}async startup(){return this}async deleteAllData(){throw Error("This is not implemented, call IDBFactory::deleteDatabase(dbName) instead.")}getOrAddOutgoingRoomKeyRequest(e){const t=e.requestBody;return new Promise((r,i)=>{const s=this.db.transaction("outgoingRoomKeyRequests","readwrite");s.onerror=i,this._getOutgoingRoomKeyRequest(s,t,o=>{if(o){vn.logger.log(`already have key request outstanding for ${t.room_id} / ${t.session_id}: not sending another`),r(o);return}vn.logger.log(`enqueueing key request for ${t.room_id} / `+t.session_id),s.oncomplete=()=>{r(e)},s.objectStore("outgoingRoomKeyRequests").add(e)})})}getOutgoingRoomKeyRequest(e){return new Promise((t,r)=>{const i=this.db.transaction("outgoingRoomKeyRequests","readonly");i.onerror=r,this._getOutgoingRoomKeyRequest(i,e,s=>{t(s)})})}_getOutgoingRoomKeyRequest(e,t,r){const o=e.objectStore("outgoingRoomKeyRequests").index("session").openCursor([t.room_id,t.session_id]);o.onsuccess=()=>{const c=o.result;if(!c){r(null);return}const l=c.value;if(dk.deepCompare(l.requestBody,t)){r(l);return}c.continue()}}getOutgoingRoomKeyRequestByState(e){if(e.length===0)return Promise.resolve(null);let t=0,r;function i(){const u=this.result;if(u){r=u.value;return}if(t++,t>=e.length)return;const a=e[t],g=this.source.openCursor(a);g.onsuccess=i}const s=this.db.transaction("outgoingRoomKeyRequests","readonly"),o=s.objectStore("outgoingRoomKeyRequests"),c=e[t],l=o.index("state").openCursor(c);return l.onsuccess=i,ji(s).then(()=>r)}getAllOutgoingRoomKeyRequestsByState(e){return new Promise((t,r)=>{const c=this.db.transaction("outgoingRoomKeyRequests","readonly").objectStore("outgoingRoomKeyRequests").index("state").getAll(e);c.onsuccess=()=>t(c.result),c.onerror=()=>r(c.error)})}getOutgoingRoomKeyRequestsByTarget(e,t,r){let i=0;const s=[];function o(){const g=this.result;if(g){const m=g.value;m.recipients.includes({userId:e,deviceId:t})&&s.push(m),g.continue()}else{if(i++,i>=r.length)return;const m=r[i],p=this.source.openCursor(m);p.onsuccess=o}}const c=this.db.transaction("outgoingRoomKeyRequests","readonly"),l=c.objectStore("outgoingRoomKeyRequests"),u=r[i],a=l.index("state").openCursor(u);return a.onsuccess=o,ji(c).then(()=>s)}updateOutgoingRoomKeyRequest(e,t,r){let i=null;function s(){const l=this.result;if(!l)return;const u=l.value;if(u.state!=t){vn.logger.warn(`Cannot update room key request from ${t} as it was already updated to ${u.state}`);return}Object.assign(u,r),l.update(u),i=u}const o=this.db.transaction("outgoingRoomKeyRequests","readwrite"),c=o.objectStore("outgoingRoomKeyRequests").openCursor(e);return c.onsuccess=s,ji(o).then(()=>i)}deleteOutgoingRoomKeyRequest(e,t){const r=this.db.transaction("outgoingRoomKeyRequests","readwrite"),i=r.objectStore("outgoingRoomKeyRequests").openCursor(e);return i.onsuccess=()=>{const s=i.result;if(!s)return;const o=s.value;if(o.state!=t){vn.logger.warn(`Cannot delete room key request in state ${o.state} (expected ${t})`);return}s.delete()},ji(r)}getAccount(e,t){const i=e.objectStore("account").get("-");i.onsuccess=function(){try{t(i.result||null)}catch(s){zt(e,s)}}}storeAccount(e,t){e.objectStore("account").put(t,"-")}getCrossSigningKeys(e,t){const i=e.objectStore("account").get("crossSigningKeys");i.onsuccess=function(){try{t(i.result||null)}catch(s){zt(e,s)}}}getSecretStorePrivateKey(e,t,r){const s=e.objectStore("account").get(`ssss_cache:${r}`);s.onsuccess=function(){try{t(s.result||null)}catch(o){zt(e,o)}}}storeCrossSigningKeys(e,t){e.objectStore("account").put(t,"crossSigningKeys")}storeSecretStorePrivateKey(e,t,r){e.objectStore("account").put(r,`ssss_cache:${t}`)}countEndToEndSessions(e,t){const i=e.objectStore("sessions").count();i.onsuccess=function(){try{t(i.result)}catch(s){zt(e,s)}}}getEndToEndSessions(e,t,r){const o=t.objectStore("sessions").index("deviceKey").openCursor(e),c={};o.onsuccess=function(){const l=o.result;if(l)c[l.value.sessionId]={session:l.value.session,lastReceivedMessageTs:l.value.lastReceivedMessageTs},l.continue();else try{r(c)}catch(u){zt(t,u)}}}getEndToEndSession(e,t,r,i){const o=r.objectStore("sessions").get([e,t]);o.onsuccess=function(){try{o.result?i({session:o.result.session,lastReceivedMessageTs:o.result.lastReceivedMessageTs}):i(null)}catch(c){zt(r,c)}}}getAllEndToEndSessions(e,t){const i=e.objectStore("sessions").openCursor();i.onsuccess=function(){try{const s=i.result;s?(t(s.value),s.continue()):t(null)}catch(s){zt(e,s)}}}storeEndToEndSession(e,t,r,i){i.objectStore("sessions").put({deviceKey:e,sessionId:t,session:r.session,lastReceivedMessageTs:r.lastReceivedMessageTs})}async storeEndToEndSessionProblem(e,t,r){const i=this.db.transaction("session_problems","readwrite");return i.objectStore("session_problems").put({deviceKey:e,type:t,fixed:r,time:Date.now()}),ji(i)}async getEndToEndSessionProblem(e,t){let r;const i=this.db.transaction("session_problems","readwrite"),c=i.objectStore("session_problems").index("deviceKey").getAll(e);return c.onsuccess=()=>{const l=c.result;if(!l.length){r=null;return}l.sort((a,g)=>a.time-g.time);const u=l[l.length-1];for(const a of l)if(a.time>t){r=Object.assign({},a,{fixed:u.fixed});return}u.fixed?r=null:r=u},await ji(i),r}async filterOutNotifiedErrorDevices(e){const r=this.db.transaction("notified_error_devices","readwrite").objectStore("notified_error_devices"),i=[];return await Promise.all(e.map(s=>new Promise(o=>{const{userId:c,deviceInfo:l}=s,u=r.get([c,l.deviceId]);u.onsuccess=function(){u.result||(r.put({userId:c,deviceId:l.deviceId}),i.push(s)),o()}}))),i}getEndToEndInboundGroupSession(e,t,r,i){let s=!1,o=!1;const l=r.objectStore("inbound_group_sessions").get([e,t]);l.onsuccess=function(){try{l.result?s=l.result.session:s=null,o!==!1&&i(s,o)}catch(g){zt(r,g)}};const a=r.objectStore("inbound_group_sessions_withheld").get([e,t]);a.onsuccess=function(){try{a.result?o=a.result.session:o=null,s!==!1&&i(s,o)}catch(g){zt(r,g)}}}getAllEndToEndInboundGroupSessions(e,t){const i=e.objectStore("inbound_group_sessions").openCursor();i.onsuccess=function(){const s=i.result;if(s){try{t({senderKey:s.value.senderCurve25519Key,sessionId:s.value.sessionId,sessionData:s.value.session})}catch(o){zt(e,o)}s.continue()}else try{t(null)}catch(o){zt(e,o)}}}addEndToEndInboundGroupSession(e,t,r,i){const o=i.objectStore("inbound_group_sessions").add({senderCurve25519Key:e,sessionId:t,session:r});o.onerror=c=>{o.error.name==="ConstraintError"?(c.stopPropagation(),c.preventDefault(),vn.logger.log("Ignoring duplicate inbound group session: "+e+" / "+t)):zt(i,new Error("Failed to add inbound group session: "+o.error))}}storeEndToEndInboundGroupSession(e,t,r,i){i.objectStore("inbound_group_sessions").put({senderCurve25519Key:e,sessionId:t,session:r})}storeEndToEndInboundGroupSessionWithheld(e,t,r,i){i.objectStore("inbound_group_sessions_withheld").put({senderCurve25519Key:e,sessionId:t,session:r})}getEndToEndDeviceData(e,t){const i=e.objectStore("device_data").get("-");i.onsuccess=function(){try{t(i.result||null)}catch(s){zt(e,s)}}}storeEndToEndDeviceData(e,t){t.objectStore("device_data").put(e,"-")}storeEndToEndRoom(e,t,r){r.objectStore("rooms").put(t,e)}getEndToEndRooms(e,t){const r={},s=e.objectStore("rooms").openCursor();s.onsuccess=function(){const o=s.result;if(o)r[o.key]=o.value,o.continue();else try{t(r)}catch(c){zt(e,c)}}}getSessionsNeedingBackup(e){return new Promise((t,r)=>{const i=[],s=this.db.transaction(["sessions_needing_backup","inbound_group_sessions"],"readonly");s.onerror=r,s.oncomplete=function(){t(i)};const o=s.objectStore("sessions_needing_backup"),c=s.objectStore("inbound_group_sessions"),l=o.openCursor();l.onsuccess=function(){const u=l.result;if(u){const a=c.get(u.key);a.onsuccess=function(){i.push({senderKey:a.result.senderCurve25519Key,sessionId:a.result.sessionId,sessionData:a.result.session})},(!e||i.length<e)&&u.continue()}}})}countSessionsNeedingBackup(e){e||(e=this.db.transaction("sessions_needing_backup","readonly"));const t=e.objectStore("sessions_needing_backup");return new Promise((r,i)=>{const s=t.count();s.onerror=i,s.onsuccess=()=>r(s.result)})}async unmarkSessionsNeedingBackup(e,t){t||(t=this.db.transaction("sessions_needing_backup","readwrite"));const r=t.objectStore("sessions_needing_backup");await Promise.all(e.map(i=>new Promise((s,o)=>{const c=r.delete([i.senderKey,i.sessionId]);c.onsuccess=s,c.onerror=o})))}async markSessionsNeedingBackup(e,t){t||(t=this.db.transaction("sessions_needing_backup","readwrite"));const r=t.objectStore("sessions_needing_backup");await Promise.all(e.map(i=>new Promise((s,o)=>{const c=r.put({senderCurve25519Key:i.senderKey,sessionId:i.sessionId});c.onsuccess=s,c.onerror=o})))}addSharedHistoryInboundGroupSession(e,t,r,i){i||(i=this.db.transaction("shared_history_inbound_group_sessions","readwrite"));const s=i.objectStore("shared_history_inbound_group_sessions"),o=s.get([e]);o.onsuccess=()=>{const{sessions:c}=o.result||{sessions:[]};c.push([t,r]),s.put({roomId:e,sessions:c})}}getSharedHistoryInboundGroupSessions(e,t){t||(t=this.db.transaction("shared_history_inbound_group_sessions","readonly"));const i=t.objectStore("shared_history_inbound_group_sessions").get([e]);return new Promise((s,o)=>{i.onsuccess=()=>{const{sessions:c}=i.result||{sessions:[]};s(c)},i.onerror=o})}doTxn(e,t,r,i=vn.logger){const s=this.db.transaction(t,e),o=ji(s),c=r(s);return o.then(()=>c)}}ms.Backend=fk;function pk(n,e){vn.logger.log(`Upgrading IndexedDBCryptoStore from version ${e} to ${qv}`),e<1&&gk(n),e<2&&n.createObjectStore("account"),e<3&&n.createObjectStore("sessions",{keyPath:["deviceKey","sessionId"]}).createIndex("deviceKey","deviceKey"),e<4&&n.createObjectStore("inbound_group_sessions",{keyPath:["senderCurve25519Key","sessionId"]}),e<5&&n.createObjectStore("device_data"),e<6&&n.createObjectStore("rooms"),e<7&&n.createObjectStore("sessions_needing_backup",{keyPath:["senderCurve25519Key","sessionId"]}),e<8&&n.createObjectStore("inbound_group_sessions_withheld",{keyPath:["senderCurve25519Key","sessionId"]}),e<9&&(n.createObjectStore("session_problems",{keyPath:["deviceKey","time"]}).createIndex("deviceKey","deviceKey"),n.createObjectStore("notified_error_devices",{keyPath:["userId","deviceId"]})),e<10&&n.createObjectStore("shared_history_inbound_group_sessions",{keyPath:["roomId"]})}function gk(n){const e=n.createObjectStore("outgoingRoomKeyRequests",{keyPath:"requestId"});e.createIndex("session",["requestBody.room_id","requestBody.session_id"]),e.createIndex("state","state")}function zt(n,e){n._mx_abortexception=e;try{n.abort()}catch{}}function ji(n){return new Promise((e,t)=>{n.oncomplete=()=>{n._mx_abortexception!==void 0&&t(n._mx_abortexception),e(null)},n.onerror=r=>{n._mx_abortexception!==void 0?t(n._mx_abortexception):(vn.logger.log("Error performing indexeddb txn",r),t(n.error))},n.onabort=r=>{n._mx_abortexception!==void 0?t(n._mx_abortexception):(vn.logger.log("Error performing indexeddb txn",r),t(n.error))}})}var Hl={};Object.defineProperty(Hl,"__esModule",{value:!0});Hl.exists=mk;function mk(n,e){return new Promise((t,r)=>{let i=!0;const s=n.open(e);s.onupgradeneeded=()=>{i=!1},s.onblocked=()=>r(s.error),s.onsuccess=()=>{s.result.close(),i||n.deleteDatabase(e),t(i)},s.onerror=o=>r(s.error)})}var yk=V.exports;Object.defineProperty(Kr,"__esModule",{value:!0});Kr.IndexedDBCryptoStore=void 0;var On=yk(Y.exports),Mr=ie,vk=Wl,_k=Po,Hu=Vv(ms),Sg=si,Ek=Vv(Hl);function jv(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(jv=function(r){return r?t:e})(n)}function Vv(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=jv(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}class Br{static exists(e,t){return Ek.exists(e,t)}constructor(e,t){this.indexedDB=e,this.dbName=t,(0,On.default)(this,"backendPromise",null),(0,On.default)(this,"backend",null)}startup(){return this.backendPromise?this.backendPromise:(this.backendPromise=new Promise((e,t)=>{if(!this.indexedDB){t(new Error("no indexeddb support available"));return}Mr.logger.log(`connecting to indexeddb ${this.dbName}`);const r=this.indexedDB.open(this.dbName,Hu.VERSION);r.onupgradeneeded=i=>{const s=r.result,o=i.oldVersion;Hu.upgradeDatabase(s,o)},r.onblocked=()=>{Mr.logger.log("can't yet open IndexedDBCryptoStore because it is open elsewhere")},r.onerror=i=>{Mr.logger.log("Error connecting to indexeddb",i),t(r.error)},r.onsuccess=()=>{const i=r.result;Mr.logger.log(`connected to indexeddb ${this.dbName}`),e(new Hu.Backend(i))}}).then(e=>e.doTxn("readonly",[Br.STORE_INBOUND_GROUP_SESSIONS,Br.STORE_INBOUND_GROUP_SESSIONS_WITHHELD],t=>{e.getEndToEndInboundGroupSession("","",t,()=>{})}).then(()=>e)).catch(e=>{if(e.name==="VersionError")throw Mr.logger.warn("Crypto DB is too new for us to use!",e),new Sg.InvalidCryptoStoreError(Sg.InvalidCryptoStoreError.TOO_NEW);Mr.logger.warn(`unable to connect to indexeddb ${this.dbName}: falling back to localStorage store: ${e}`);try{return new vk.LocalStorageCryptoStore(j.localStorage)}catch(t){return Mr.logger.warn(`unable to open localStorage: falling back to in-memory store: ${t}`),new _k.MemoryCryptoStore}}).then(e=>(this.backend=e,e)),this.backendPromise)}deleteAllData(){return new Promise((e,t)=>{if(!this.indexedDB){t(new Error("no indexeddb support available"));return}Mr.logger.log(`Removing indexeddb instance: ${this.dbName}`);const r=this.indexedDB.deleteDatabase(this.dbName);r.onblocked=()=>{Mr.logger.log("can't yet delete IndexedDBCryptoStore because it is open elsewhere")},r.onerror=i=>{Mr.logger.log("Error deleting data from indexeddb",i),t(r.error)},r.onsuccess=()=>{Mr.logger.log(`Removed indexeddb instance: ${this.dbName}`),e()}}).catch(e=>{Mr.logger.warn(`unable to delete IndexedDBCryptoStore: ${e}`)})}getOrAddOutgoingRoomKeyRequest(e){return this.backend.getOrAddOutgoingRoomKeyRequest(e)}getOutgoingRoomKeyRequest(e){return this.backend.getOutgoingRoomKeyRequest(e)}getOutgoingRoomKeyRequestByState(e){return this.backend.getOutgoingRoomKeyRequestByState(e)}getAllOutgoingRoomKeyRequestsByState(e){return this.backend.getAllOutgoingRoomKeyRequestsByState(e)}getOutgoingRoomKeyRequestsByTarget(e,t,r){return this.backend.getOutgoingRoomKeyRequestsByTarget(e,t,r)}updateOutgoingRoomKeyRequest(e,t,r){return this.backend.updateOutgoingRoomKeyRequest(e,t,r)}deleteOutgoingRoomKeyRequest(e,t){return this.backend.deleteOutgoingRoomKeyRequest(e,t)}getAccount(e,t){this.backend.getAccount(e,t)}storeAccount(e,t){this.backend.storeAccount(e,t)}getCrossSigningKeys(e,t){this.backend.getCrossSigningKeys(e,t)}getSecretStorePrivateKey(e,t,r){this.backend.getSecretStorePrivateKey(e,t,r)}storeCrossSigningKeys(e,t){this.backend.storeCrossSigningKeys(e,t)}storeSecretStorePrivateKey(e,t,r){this.backend.storeSecretStorePrivateKey(e,t,r)}countEndToEndSessions(e,t){this.backend.countEndToEndSessions(e,t)}getEndToEndSession(e,t,r,i){this.backend.getEndToEndSession(e,t,r,i)}getEndToEndSessions(e,t,r){this.backend.getEndToEndSessions(e,t,r)}getAllEndToEndSessions(e,t){this.backend.getAllEndToEndSessions(e,t)}storeEndToEndSession(e,t,r,i){this.backend.storeEndToEndSession(e,t,r,i)}storeEndToEndSessionProblem(e,t,r){return this.backend.storeEndToEndSessionProblem(e,t,r)}getEndToEndSessionProblem(e,t){return this.backend.getEndToEndSessionProblem(e,t)}filterOutNotifiedErrorDevices(e){return this.backend.filterOutNotifiedErrorDevices(e)}getEndToEndInboundGroupSession(e,t,r,i){this.backend.getEndToEndInboundGroupSession(e,t,r,i)}getAllEndToEndInboundGroupSessions(e,t){this.backend.getAllEndToEndInboundGroupSessions(e,t)}addEndToEndInboundGroupSession(e,t,r,i){this.backend.addEndToEndInboundGroupSession(e,t,r,i)}storeEndToEndInboundGroupSession(e,t,r,i){this.backend.storeEndToEndInboundGroupSession(e,t,r,i)}storeEndToEndInboundGroupSessionWithheld(e,t,r,i){this.backend.storeEndToEndInboundGroupSessionWithheld(e,t,r,i)}storeEndToEndDeviceData(e,t){this.backend.storeEndToEndDeviceData(e,t)}getEndToEndDeviceData(e,t){this.backend.getEndToEndDeviceData(e,t)}storeEndToEndRoom(e,t,r){this.backend.storeEndToEndRoom(e,t,r)}getEndToEndRooms(e,t){this.backend.getEndToEndRooms(e,t)}getSessionsNeedingBackup(e){return this.backend.getSessionsNeedingBackup(e)}countSessionsNeedingBackup(e){return this.backend.countSessionsNeedingBackup(e)}unmarkSessionsNeedingBackup(e,t){return this.backend.unmarkSessionsNeedingBackup(e,t)}markSessionsNeedingBackup(e,t){return this.backend.markSessionsNeedingBackup(e,t)}addSharedHistoryInboundGroupSession(e,t,r,i){this.backend.addSharedHistoryInboundGroupSession(e,t,r,i)}getSharedHistoryInboundGroupSessions(e,t){return this.backend.getSharedHistoryInboundGroupSessions(e,t)}doTxn(e,t,r,i){return this.backend.doTxn(e,t,r,i)}}Kr.IndexedDBCryptoStore=Br;(0,On.default)(Br,"STORE_ACCOUNT","account");(0,On.default)(Br,"STORE_SESSIONS","sessions");(0,On.default)(Br,"STORE_INBOUND_GROUP_SESSIONS","inbound_group_sessions");(0,On.default)(Br,"STORE_INBOUND_GROUP_SESSIONS_WITHHELD","inbound_group_sessions_withheld");(0,On.default)(Br,"STORE_SHARED_HISTORY_INBOUND_GROUP_SESSIONS","shared_history_inbound_group_sessions");(0,On.default)(Br,"STORE_DEVICE_DATA","device_data");(0,On.default)(Br,"STORE_ROOMS","rooms");(0,On.default)(Br,"STORE_BACKUP","sessions_needing_backup");var Sk=V.exports;Object.defineProperty(Gl,"__esModule",{value:!0});Gl.RoomList=void 0;var bk=Sk(Y.exports),bg=Kr;class wk{constructor(e){this.cryptoStore=e,(0,bk.default)(this,"roomEncryption",{})}async init(){await this.cryptoStore.doTxn("readwrite",[bg.IndexedDBCryptoStore.STORE_ROOMS],e=>{this.cryptoStore.getEndToEndRooms(e,t=>{this.roomEncryption=t})})}getRoomEncryption(e){return this.roomEncryption[e]||null}isRoomEncrypted(e){return Boolean(this.getRoomEncryption(e))}async setRoomEncryption(e,t){this.roomEncryption[e]=t,await this.cryptoStore.doTxn("readwrite",[bg.IndexedDBCryptoStore.STORE_ROOMS],r=>{this.cryptoStore.storeEndToEndRoom(e,t,r)})}}Gl.RoomList=wk;var Lo={};Object.defineProperty(Lo,"__esModule",{value:!0});Lo.SERVICE_TYPES=void 0;let mh;Lo.SERVICE_TYPES=mh;(function(n){n.IS="SERVICE_TYPE_IS",n.IM="SERVICE_TYPE_IM"})(mh||(Lo.SERVICE_TYPES=mh={}));var Kt={},ys={},df={},Ps={},Rk=V.exports;Object.defineProperty(Ps,"__esModule",{value:!0});Ps.DeviceInfo=void 0;var Ji=Rk(Y.exports),Xn;(function(n){n[n.Blocked=-1]="Blocked",n[n.Unverified=0]="Unverified",n[n.Verified=1]="Verified"})(Xn||(Xn={}));class Yl{static fromStorage(e,t){const r=new Yl(t);for(const i in e)e.hasOwnProperty(i)&&(r[i]=e[i]);return r}constructor(e){this.deviceId=e,(0,Ji.default)(this,"algorithms",void 0),(0,Ji.default)(this,"keys",{}),(0,Ji.default)(this,"verified",Xn.Unverified),(0,Ji.default)(this,"known",!1),(0,Ji.default)(this,"unsigned",{}),(0,Ji.default)(this,"signatures",{})}toStorage(){return{algorithms:this.algorithms,keys:this.keys,verified:this.verified,known:this.known,unsigned:this.unsigned,signatures:this.signatures}}getFingerprint(){return this.keys["ed25519:"+this.deviceId]}getIdentityKey(){return this.keys["curve25519:"+this.deviceId]}getDisplayName(){return this.unsigned.device_display_name||null}isBlocked(){return this.verified==Xn.Blocked}isVerified(){return this.verified==Xn.Verified}isUnverified(){return this.verified==Xn.Unverified}isKnown(){return this.known===!0}}Ps.DeviceInfo=Yl;(0,Ji.default)(Yl,"DeviceVerification",{VERIFIED:Xn.Verified,UNVERIFIED:Xn.Unverified,BLOCKED:Xn.Blocked});var _t={},Ik=V.exports;Object.defineProperty(_t,"__esModule",{value:!0});_t.UnknownDeviceError=_t.EncryptionAlgorithm=_t.ENCRYPTION_CLASSES=_t.DecryptionError=_t.DecryptionAlgorithm=_t.DECRYPTION_CLASSES=void 0;_t.registerAlgorithm=Mk;var $r=Ik(Y.exports);const Gv={};_t.ENCRYPTION_CLASSES=Gv;const Wv={};_t.DECRYPTION_CLASSES=Wv;class Tk{constructor(e){(0,$r.default)(this,"userId",void 0),(0,$r.default)(this,"deviceId",void 0),(0,$r.default)(this,"crypto",void 0),(0,$r.default)(this,"olmDevice",void 0),(0,$r.default)(this,"baseApis",void 0),(0,$r.default)(this,"roomId",void 0),this.userId=e.userId,this.deviceId=e.deviceId,this.crypto=e.crypto,this.olmDevice=e.olmDevice,this.baseApis=e.baseApis,this.roomId=e.roomId}prepareToEncrypt(e){}onRoomMembership(e,t,r){}}_t.EncryptionAlgorithm=Tk;class Ok{constructor(e){(0,$r.default)(this,"userId",void 0),(0,$r.default)(this,"crypto",void 0),(0,$r.default)(this,"olmDevice",void 0),(0,$r.default)(this,"baseApis",void 0),(0,$r.default)(this,"roomId",void 0),this.userId=e.userId,this.crypto=e.crypto,this.olmDevice=e.olmDevice,this.baseApis=e.baseApis,this.roomId=e.roomId}onRoomKeyEvent(e){}async importRoomKey(e,t){}hasKeysForKeyRequest(e){return Promise.resolve(!1)}shareKeysWithDevice(e){throw new Error("shareKeysWithDevice not supported for this DecryptionAlgorithm")}async retryDecryptionFromSender(e){return!1}}_t.DecryptionAlgorithm=Ok;class kk extends Error{constructor(e,t,r){super(t);this.code=e,(0,$r.default)(this,"detailedString",void 0),this.code=e,this.name="DecryptionError",this.detailedString=Ck(this,r)}}_t.DecryptionError=kk;function Ck(n,e){let t=n.name+"[msg: "+n.message;return e&&(t+=", "+Object.keys(e).map(r=>r+": "+e[r]).join(", ")),t+="]",t}class Pk extends Error{constructor(e,t){super(e);this.devices=t,this.name="UnknownDeviceError",this.devices=t}}_t.UnknownDeviceError=Pk;function Mk(n,e,t){Gv[n]=e,Wv[n]=t}var Ak=V.exports,wg=Ak(Y.exports),Rg=ie,yh=Uk(Me),Dk=Ps,gn=_t;function Hv(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(Hv=function(r){return r?t:e})(n)}function Uk(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=Hv(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}const $k=Dk.DeviceInfo.DeviceVerification;class xk extends gn.EncryptionAlgorithm{constructor(...e){super(...e);(0,wg.default)(this,"sessionPrepared",!1),(0,wg.default)(this,"prepPromise",null)}ensureSession(e){return this.prepPromise?this.prepPromise:this.sessionPrepared?Promise.resolve():(this.prepPromise=this.crypto.downloadKeys(e).then(t=>this.crypto.ensureOlmSessionsForUsers(e)).then(()=>{this.sessionPrepared=!0}).finally(()=>{this.prepPromise=null}),this.prepPromise)}async encryptMessage(e,t,r){const s=(await e.getEncryptionTargetMembers()).map(function(u){return u.userId});await this.ensureSession(s);const o={room_id:e.roomId,type:t,content:r},c={algorithm:yh.OLM_ALGORITHM,sender_key:this.olmDevice.deviceCurve25519Key,ciphertext:{}},l=[];for(let u=0;u<s.length;++u){const a=s[u],g=this.crypto.getStoredDevicesForUser(a);for(let m=0;m<g.length;++m){const p=g[m];p.getIdentityKey()!=this.olmDevice.deviceCurve25519Key&&p.verified!=$k.BLOCKED&&l.push(yh.encryptMessageForDevice(c.ciphertext,this.userId,this.deviceId,this.olmDevice,a,p,o))}}return await Promise.all(l).then(()=>c)}}class Nk extends gn.DecryptionAlgorithm{async decryptEvent(e){const t=e.getWireContent(),r=t.sender_key,i=t.ciphertext;if(!i)throw new gn.DecryptionError("OLM_MISSING_CIPHERTEXT","Missing ciphertext");if(!(this.olmDevice.deviceCurve25519Key in i))throw new gn.DecryptionError("OLM_NOT_INCLUDED_IN_RECIPIENTS","Not included in recipients");const s=i[this.olmDevice.deviceCurve25519Key];let o;try{o=await this.decryptMessage(r,s)}catch(u){throw new gn.DecryptionError("OLM_BAD_ENCRYPTED_MESSAGE","Bad Encrypted Message",{sender:r,err:u})}const c=JSON.parse(o);if(c.recipient!=this.userId)throw new gn.DecryptionError("OLM_BAD_RECIPIENT","Message was intented for "+c.recipient);if(c.recipient_keys.ed25519!=this.olmDevice.deviceEd25519Key)throw new gn.DecryptionError("OLM_BAD_RECIPIENT_KEY","Message not intended for this device",{intended:c.recipient_keys.ed25519,our_key:this.olmDevice.deviceEd25519Key});if(c.sender!=e.getSender())throw new gn.DecryptionError("OLM_FORWARDED_MESSAGE","Message forwarded from "+c.sender,{reported_sender:e.getSender()});if(c.room_id!==e.getRoomId())throw new gn.DecryptionError("OLM_BAD_ROOM","Message intended for room "+c.room_id,{reported_room:e.getRoomId()});const l=c.keys||{};return{clearEvent:c,senderCurve25519Key:r,claimedEd25519Key:l.ed25519||null}}async decryptMessage(e,t){if(t.type!==0)return this.reallyDecryptMessage(e,t);{const r=this.olmDevice.olmPrekeyPromise.then(()=>this.reallyDecryptMessage(e,t));return this.olmDevice.olmPrekeyPromise=r.catch(()=>{}),await r}}async reallyDecryptMessage(e,t){const r=await this.olmDevice.getSessionIdsForDevice(e),i={};for(let o=0;o<r.length;o++){const c=r[o];try{const l=await this.olmDevice.decryptMessage(e,c,t.type,t.body);return Rg.logger.log("Decrypted Olm message from "+e+" with session "+c),l}catch(l){if(await this.olmDevice.matchesSession(e,c,t.type,t.body))throw new Error("Error decrypting prekey message with existing session id "+c+": "+l.message);i[c]=l.message}}if(t.type!==0)throw r.length===0?new Error("No existing sessions"):new Error("Error decrypting non-prekey message with existing sessions: "+JSON.stringify(i));let s;try{s=await this.olmDevice.createInboundSession(e,t.type,t.body)}catch(o){throw i["(new)"]=o.message,new Error("Error decrypting prekey message: "+JSON.stringify(i))}return Rg.logger.log("created new inbound Olm session ID "+s.session_id+" with "+e),s.payload}}(0,gn.registerAlgorithm)(yh.OLM_ALGORITHM,xk,Nk);var hf={},Lk=V.exports;Object.defineProperty(hf,"__esModule",{value:!0});hf.isRoomSharedHistory=zv;var xr=Lk(Y.exports),W=ie,Ze=Bk(Me),Wn=_t,Ig=ys;function Yv(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(Yv=function(r){return r?t:e})(n)}function Bk(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=Yv(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}function zv(n){var e,t;const r=n==null||(e=n.currentState)===null||e===void 0?void 0:e.getStateEvents("m.room.history_visibility",""),i=r==null||(t=r.getContent())===null||t===void 0?void 0:t.history_visibility;return["world_readable","shared"].includes(i)}class Kk{constructor(e,t=!1){this.sessionId=e,this.sharedHistory=t,(0,xr.default)(this,"useCount",0),(0,xr.default)(this,"creationTime",void 0),(0,xr.default)(this,"sharedWithDevices",{}),(0,xr.default)(this,"blockedDevicesNotified",{}),this.creationTime=new Date().getTime()}needsRotation(e,t){const r=new Date().getTime()-this.creationTime;return this.useCount>=e||r>=t?(W.logger.log("Rotating megolm session after "+this.useCount+" messages, "+r+"ms"),!0):!1}markSharedWithDevice(e,t,r,i){this.sharedWithDevices[e]||(this.sharedWithDevices[e]={}),this.sharedWithDevices[e][t]={deviceKey:r,messageIndex:i}}markNotifiedBlockedDevice(e,t){this.blockedDevicesNotified[e]||(this.blockedDevicesNotified[e]={}),this.blockedDevicesNotified[e][t]=!0}sharedWithTooManyDevices(e){for(const t in this.sharedWithDevices)if(!!this.sharedWithDevices.hasOwnProperty(t)){if(!e.hasOwnProperty(t))return W.logger.log("Starting new megolm session because we shared with "+t),!0;for(const r in this.sharedWithDevices[t])if(!!this.sharedWithDevices[t].hasOwnProperty(r)&&!e[t].hasOwnProperty(r))return W.logger.log("Starting new megolm session because we shared with "+t+":"+r),!0}}}class Fk extends Wn.EncryptionAlgorithm{constructor(e){var t,r,i,s;super(e);(0,xr.default)(this,"setupPromise",Promise.resolve(void 0)),(0,xr.default)(this,"outboundSessions",{}),(0,xr.default)(this,"sessionRotationPeriodMsgs",void 0),(0,xr.default)(this,"sessionRotationPeriodMs",void 0),(0,xr.default)(this,"encryptionPreparation",void 0),(0,xr.default)(this,"encryptionPreparationMetadata",void 0),this.sessionRotationPeriodMsgs=(t=(r=e.config)===null||r===void 0?void 0:r.rotation_period_msgs)!==null&&t!==void 0?t:100,this.sessionRotationPeriodMs=(i=(s=e.config)===null||s===void 0?void 0:s.rotation_period_ms)!==null&&i!==void 0?i:7*24*3600*1e3}async ensureOutboundSession(e,t,r,i=!1){let s;const o=async u=>{s=u;const a=zv(e);s&&a!==s.sharedHistory&&(s=null),s&&s.needsRotation(this.sessionRotationPeriodMsgs,this.sessionRotationPeriodMs)&&(W.logger.log("Starting new megolm session because we need to rotate."),s=null),s&&s.sharedWithTooManyDevices(t)&&(s=null),s||(W.logger.log(`Starting new megolm session for room ${this.roomId}`),s=await this.prepareNewSession(a),W.logger.log(`Started new megolm session ${s.sessionId} for room ${this.roomId}`),this.outboundSessions[s.sessionId]=s);const g={};for(const[w,k]of Object.entries(t))for(const[P,S]of Object.entries(k))S.getIdentityKey()!=this.olmDevice.deviceCurve25519Key&&(!s.sharedWithDevices[w]||s.sharedWithDevices[w][P]===void 0)&&(g[w]=g[w]||[],g[w].push(S));const m=this.olmDevice.getOutboundGroupSessionKey(s.sessionId),p={type:"m.room_key",content:{algorithm:Ze.MEGOLM_ALGORITHM,room_id:this.roomId,session_id:s.sessionId,session_key:m.key,chain_index:m.chain_index,"org.matrix.msc3061.shared_history":a}},[E,I]=await Ze.getExistingOlmSessions(this.olmDevice,this.baseApis,g);await Promise.all([(async()=>{W.logger.debug(`Sharing keys with existing Olm sessions in ${this.roomId}`,I),await this.shareKeyWithOlmSessions(s,m,p,I),W.logger.debug(`Shared keys with existing Olm sessions in ${this.roomId}`)})(),(async()=>{W.logger.debug(`Sharing keys (start phase 1) with new Olm sessions in ${this.roomId}`,E);const w=[],k=Date.now(),P=[];await this.shareKeyWithDevices(s,m,p,E,w,i?1e4:2e3,P),W.logger.debug(`Shared keys (end phase 1) with new Olm sessions in ${this.roomId}`),!i&&Date.now()-k<1e4?(async()=>{const S={},T=new Set;for(const R of P)T.add(R);const D=[];for(const{userId:R,deviceInfo:L}of w){const H=R.slice(R.indexOf(":")+1);T.has(H)?(S[R]=S[R]||[],S[R].push(L)):D.push({userId:R,deviceInfo:L})}W.logger.debug(`Sharing keys (start phase 2) with new Olm sessions in ${this.roomId}`),await this.shareKeyWithDevices(s,m,p,S,D,3e4),W.logger.debug(`Shared keys (end phase 2) with new Olm sessions in ${this.roomId}`),await this.notifyFailedOlmDevices(s,m,D)})():await this.notifyFailedOlmDevices(s,m,w),W.logger.debug(`Shared keys (all phases done) with new Olm sessions in ${this.roomId}`)})(),(async()=>{W.logger.debug(`There are ${Object.entries(r).length} blocked devices in ${this.roomId}`,Object.entries(r)),W.logger.debug(`Notifying newly blocked devices in ${this.roomId}`);const w={};let k=0;for(const[P,S]of Object.entries(r))for(const[T,D]of Object.entries(S))(!s.blockedDevicesNotified[P]||s.blockedDevicesNotified[P][T]===void 0)&&(w[P]=w[P]||{},w[P][T]={device:D},k++);await this.notifyBlockedDevices(s,w),W.logger.debug(`Notified ${k} newly blocked devices in ${this.roomId}`,w)})()])};function c(){return s}const l=this.setupPromise.then(o);return l.catch(u=>{W.logger.error(`Failed to ensure outbound session in ${this.roomId}`,u)}),this.setupPromise=l.then(c,c),l.then(c)}async prepareNewSession(e){const t=this.olmDevice.createOutboundGroupSession(),r=this.olmDevice.getOutboundGroupSessionKey(t);return await this.olmDevice.addInboundGroupSession(this.roomId,this.olmDevice.deviceCurve25519Key,[],t,r.key,{ed25519:this.olmDevice.deviceEd25519Key},!1,{sharedHistory:e}),this.crypto.backupManager.backupGroupSession(this.olmDevice.deviceCurve25519Key,t),new Kk(t,e)}getDevicesWithoutSessions(e,t,r=[]){for(const[i,s]of Object.entries(t)){const o=e[i];for(const c of s){const l=c.deviceId;if(!o[l].sessionId){r.push({userId:i,deviceInfo:c}),delete o[l];continue}}}return r}splitDevices(e){let r=[];const i=[r];for(const[s,o]of Object.entries(e)){for(const c of Object.values(o))r.push({userId:s,deviceInfo:c.device});r.length>20&&(r=[],i.push(r))}return r.length===0&&i.pop(),i}encryptAndSendKeysToDevices(e,t,r,i){const s={},o=new Map,c=[];for(let l=0;l<r.length;l++){const u={algorithm:Ze.OLM_ALGORITHM,sender_key:this.olmDevice.deviceCurve25519Key,ciphertext:{}},a=r[l],g=a.userId,m=a.deviceInfo,p=m.deviceId;o.set(p,m),s[g]||(s[g]={}),s[g][p]=u,c.push(Ze.encryptMessageForDevice(u.ciphertext,this.userId,this.deviceId,this.olmDevice,g,m,i))}return Promise.all(c).then(()=>{for(const l of Object.keys(s)){for(const u of Object.keys(s[l]))Object.keys(s[l][u].ciphertext).length===0&&(W.logger.log("No ciphertext for device "+l+":"+u+": pruning"),delete s[l][u]);Object.keys(s[l]).length===0&&(W.logger.log("Pruned all devices for user "+l),delete s[l])}if(Object.keys(s).length===0){W.logger.log("No users left to send to: aborting");return}return this.baseApis.sendToDevice("m.room.encrypted",s).then(()=>{for(const l of Object.keys(s))for(const u of Object.keys(s[l]))e.markSharedWithDevice(l,u,o.get(u).getIdentityKey(),t)})})}async sendBlockedNotificationsToDevices(e,t,r){const i={};for(const s of t){const o=s.userId,c=s.deviceInfo,u=c.deviceInfo.deviceId,a=Object.assign({},r);a.code=c.code,a.reason=c.reason,a.code==="m.no_olm"&&(delete a.room_id,delete a.session_id),i[o]||(i[o]={}),i[o][u]=a}await this.baseApis.sendToDevice("org.matrix.room_key.withheld",i),await this.baseApis.sendToDevice("m.room_key.withheld",i);for(const s of Object.keys(i))for(const o of Object.keys(i[s]))e.markNotifiedBlockedDevice(s,o)}async reshareKeyWithDevice(e,t,r,i){const s=this.outboundSessions[t];if(!s){W.logger.debug(`megolm session ${t} not found: not re-sharing keys`);return}if(s.sharedWithDevices[r]===void 0){W.logger.debug(`megolm session ${t} never shared with user ${r}`);return}const o=s.sharedWithDevices[r][i.deviceId];if(o===void 0){W.logger.debug("megolm session ID "+t+" never shared with device "+r+":"+i.deviceId);return}if(o.deviceKey!==i.getIdentityKey()){W.logger.warn(`Session has been shared with device ${i.deviceId} but with identity key ${o.deviceKey}. Key is now ${i.getIdentityKey()}!`);return}const c=await this.olmDevice.getInboundGroupSessionKey(this.roomId,e,t,o.messageIndex);if(!c){W.logger.warn(`No inbound session key found for megolm ${t}: not re-sharing keys`);return}await Ze.ensureOlmSessionsForDevices(this.olmDevice,this.baseApis,{[r]:[i]});const l={type:"m.forwarded_room_key",content:{algorithm:Ze.MEGOLM_ALGORITHM,room_id:this.roomId,session_id:t,session_key:c.key,chain_index:c.chain_index,sender_key:e,sender_claimed_ed25519_key:c.sender_claimed_ed25519_key,forwarding_curve25519_key_chain:c.forwarding_curve25519_key_chain,"org.matrix.msc3061.shared_history":c.shared_history||!1}},u={algorithm:Ze.OLM_ALGORITHM,sender_key:this.olmDevice.deviceCurve25519Key,ciphertext:{}};await Ze.encryptMessageForDevice(u.ciphertext,this.userId,this.deviceId,this.olmDevice,r,i,l),await this.baseApis.sendToDevice("m.room.encrypted",{[r]:{[i.deviceId]:u}}),W.logger.debug(`Re-shared key for megolm session ${t} with ${r}:${i.deviceId}`)}async shareKeyWithDevices(e,t,r,i,s,o,c){W.logger.debug(`Ensuring Olm sessions for devices in ${this.roomId}`);const l=await Ze.ensureOlmSessionsForDevices(this.olmDevice,this.baseApis,i,!1,o,c,W.logger.withPrefix(`[${this.roomId}]`));W.logger.debug(`Ensured Olm sessions for devices in ${this.roomId}`),this.getDevicesWithoutSessions(l,i,s),W.logger.debug(`Sharing keys with newly created Olm sessions in ${this.roomId}`),await this.shareKeyWithOlmSessions(e,t,r,l),W.logger.debug(`Shared keys with newly created Olm sessions in ${this.roomId}`)}async shareKeyWithOlmSessions(e,t,r,i){const s=this.splitDevices(i);for(let o=0;o<s.length;o++){const c=`megolm keys for ${e.sessionId} in ${this.roomId} (slice ${o+1}/${s.length})`;try{W.logger.debug(`Sharing ${c}`,s[o].map(l=>`${l.userId}/${l.deviceInfo.deviceId}`)),await this.encryptAndSendKeysToDevices(e,t.chain_index,s[o],r),W.logger.debug(`Shared ${c}`)}catch(l){throw W.logger.error(`Failed to share ${c}`),l}}}async notifyFailedOlmDevices(e,t,r){W.logger.debug(`Notifying ${r.length} devices we failed to create Olm sessions in ${this.roomId}`);for(const{userId:o,deviceInfo:c}of r){const l=c.deviceId;e.markSharedWithDevice(o,l,c.getIdentityKey(),t.chain_index)}const i=await this.olmDevice.filterOutNotifiedErrorDevices(r);W.logger.debug(`Need to notify ${i.length} failed devices which haven't been notified before in ${this.roomId}`);const s={};for(const{userId:o,deviceInfo:c}of i)s[o]=s[o]||{},s[o][c.deviceId]={device:{code:"m.no_olm",reason:Ig.WITHHELD_MESSAGES["m.no_olm"],deviceInfo:c}};await this.notifyBlockedDevices(e,s),W.logger.debug(`Notified ${i.length} devices we failed to create Olm sessions in ${this.roomId}`)}async notifyBlockedDevices(e,t){const r={room_id:this.roomId,session_id:e.sessionId,algorithm:Ze.MEGOLM_ALGORITHM,sender_key:this.olmDevice.deviceCurve25519Key},i=this.splitDevices(t);for(let s=0;s<i.length;s++)try{await this.sendBlockedNotificationsToDevices(e,i[s],r),W.logger.log(`Completed blacklist notification for ${e.sessionId} in ${this.roomId} (slice ${s+1}/${i.length})`)}catch(o){throw W.logger.log(`blacklist notification for ${e.sessionId} in ${this.roomId} (slice ${s+1}/${i.length}) failed`),o}}prepareToEncrypt(e){if(this.encryptionPreparation){const t=Date.now()-this.encryptionPreparationMetadata.startTime;W.logger.debug(`Already started preparing to encrypt for ${this.roomId} ${t} ms ago, skipping`);return}W.logger.debug(`Preparing to encrypt events for ${this.roomId}`),this.encryptionPreparationMetadata={startTime:Date.now()},this.encryptionPreparation=(async()=>{try{W.logger.debug(`Getting devices in ${this.roomId}`);const[t,r]=await this.getDevicesInRoom(e);this.crypto.getGlobalErrorOnUnknownDevices()&&this.removeUnknownDevices(t),W.logger.debug(`Ensuring outbound session in ${this.roomId}`),await this.ensureOutboundSession(e,t,r,!0),W.logger.debug(`Ready to encrypt events for ${this.roomId}`)}catch(t){W.logger.error(`Failed to prepare to encrypt events for ${this.roomId}`,t)}finally{delete this.encryptionPreparationMetadata,delete this.encryptionPreparation}})()}async encryptMessage(e,t,r){if(W.logger.log(`Starting to encrypt event for ${this.roomId}`),this.encryptionPreparation)try{await this.encryptionPreparation}catch{}const[i,s]=await this.getDevicesInRoom(e);this.crypto.getGlobalErrorOnUnknownDevices()&&this.checkForUnknownDevices(i);const o=await this.ensureOutboundSession(e,i,s),c={room_id:this.roomId,type:t,content:r},l=this.olmDevice.encryptGroupMessage(o.sessionId,JSON.stringify(c)),u={algorithm:Ze.MEGOLM_ALGORITHM,sender_key:this.olmDevice.deviceCurve25519Key,ciphertext:l,session_id:o.sessionId,device_id:this.deviceId};return o.useCount++,u}forceDiscardSession(){this.setupPromise=this.setupPromise.then(()=>null)}checkForUnknownDevices(e){const t={};if(Object.keys(e).forEach(r=>{Object.keys(e[r]).forEach(i=>{const s=e[r][i];s.isUnverified()&&!s.isKnown()&&(t[r]||(t[r]={}),t[r][i]=s)})}),Object.keys(t).length)throw new Wn.UnknownDeviceError("This room contains unknown devices which have not been verified. We strongly recommend you verify them before continuing.",t)}removeUnknownDevices(e){for(const[t,r]of Object.entries(e)){for(const[i,s]of Object.entries(r))s.isUnverified()&&!s.isKnown()&&delete r[i];Object.keys(r).length===0&&delete e[t]}}async getDevicesInRoom(e){const r=(await e.getEncryptionTargetMembers()).map(function(c){return c.userId});let i=this.crypto.getGlobalBlacklistUnverifiedDevices();typeof e.getBlacklistUnverifiedDevices()=="boolean"&&(i=e.getBlacklistUnverifiedDevices());const s=await this.crypto.downloadKeys(r,!1),o={};for(const c in s){if(!s.hasOwnProperty(c))continue;const l=s[c];for(const u in l){if(!l.hasOwnProperty(u))continue;const a=this.crypto.checkDeviceTrust(c,u);if(l[u].isBlocked()||!a.isVerified()&&i){o[c]||(o[c]={});const g=l[u].isBlocked();o[c][u]={code:g?"m.blacklisted":"m.unverified",reason:Ig.WITHHELD_MESSAGES[g?"m.blacklisted":"m.unverified"],deviceInfo:l[u]},delete l[u]}}}return[s,o]}}class qk extends Wn.DecryptionAlgorithm{constructor(...e){super(...e);(0,xr.default)(this,"pendingEvents",{}),(0,xr.default)(this,"olmlib",Ze)}async decryptEvent(e){const t=e.getWireContent();if(!t.sender_key||!t.session_id||!t.ciphertext)throw new Wn.DecryptionError("MEGOLM_MISSING_FIELDS","Missing fields in input");this.addEventToPendingList(e);let r;try{r=await this.olmDevice.decryptGroupMessage(e.getRoomId(),t.sender_key,t.session_id,t.ciphertext,e.getId(),e.getTs())}catch(s){if(s.name==="DecryptionError")throw s;let o="OLM_DECRYPT_GROUP_MESSAGE_ERROR";throw s&&s.message==="OLM.UNKNOWN_MESSAGE_INDEX"&&(this.requestKeysForEvent(e),o="OLM_UNKNOWN_MESSAGE_INDEX"),new Wn.DecryptionError(o,s?s.toString():"Unknown Error: Error is undefined",{session:t.sender_key+"|"+t.session_id})}if(r===null){this.requestKeysForEvent(e);const s=await this.olmDevice.sessionMayHaveProblems(t.sender_key,e.getTs()-12e4);if(s){let o=Tg[s.type]||Tg.unknown;throw s.fixed&&(o+=" Trying to create a new secure channel and re-requesting the keys."),new Wn.DecryptionError("MEGOLM_UNKNOWN_INBOUND_SESSION_ID",o,{session:t.sender_key+"|"+t.session_id})}throw new Wn.DecryptionError("MEGOLM_UNKNOWN_INBOUND_SESSION_ID","The sender's device has not sent us the keys for this message.",{session:t.sender_key+"|"+t.session_id})}this.removeEventFromPendingList(e);const i=JSON.parse(r.result);if(i.room_id!==e.getRoomId())throw new Wn.DecryptionError("MEGOLM_BAD_ROOM","Message intended for room "+i.room_id);return{clearEvent:i,senderCurve25519Key:r.senderKey,claimedEd25519Key:r.keysClaimed.ed25519,forwardingCurve25519KeyChain:r.forwardingCurve25519KeyChain,untrusted:r.untrusted}}requestKeysForEvent(e){const t=e.getWireContent(),r=e.getKeyRequestRecipients(this.userId);this.crypto.requestRoomKey({room_id:e.getRoomId(),algorithm:t.algorithm,sender_key:t.sender_key,session_id:t.session_id},r)}addEventToPendingList(e){const t=e.getWireContent(),r=t.sender_key,i=t.session_id;this.pendingEvents[r]||(this.pendingEvents[r]=new Map);const s=this.pendingEvents[r];s.has(i)||s.set(i,new Set),s.get(i).add(e)}removeEventFromPendingList(e){const t=e.getWireContent(),r=t.sender_key,i=t.session_id,s=this.pendingEvents[r],o=s==null?void 0:s.get(i);!o||(o.delete(e),o.size===0&&s.delete(i),s.size===0&&delete this.pendingEvents[r])}onRoomKeyEvent(e){const t=e.getContent(),r=t.session_id;let i=e.getSenderKey(),s=[],o=!1,c;if(!t.room_id||!r||!t.session_key){W.logger.error("key event is missing fields");return}if(!i){W.logger.error("key event has no sender key (not encrypted?)");return}if(e.getType()=="m.forwarded_room_key"){if(o=!0,s=t.forwarding_curve25519_key_chain,Array.isArray(s)||(s=[]),s=s.slice(),s.push(i),i=t.sender_key,!i){W.logger.error("forwarded_room_key event is missing sender_key field");return}const u=t.sender_claimed_ed25519_key;if(!u){W.logger.error("forwarded_room_key_event is missing sender_claimed_ed25519_key field");return}c={ed25519:u}}else c=e.getKeysClaimed();const l={};return t["org.matrix.msc3061.shared_history"]&&(l.sharedHistory=!0),this.olmDevice.addInboundGroupSession(t.room_id,i,s,r,t.session_key,c,o,l).then(()=>{this.retryDecryption(i,r).then(u=>{u&&this.crypto.cancelRoomKeyRequest({algorithm:t.algorithm,room_id:t.room_id,session_id:t.session_id,sender_key:i})})}).then(()=>{this.crypto.backupManager.backupGroupSession(i,t.session_id)}).catch(u=>{W.logger.error(`Error handling m.room_key_event: ${u}`)})}async onRoomKeyWithheldEvent(e){const t=e.getContent(),r=t.sender_key;if(t.code==="m.no_olm"){const i=e.getSender();if(W.logger.warn(`${i}:${r} was unable to establish an olm session with us`),await this.olmDevice.getSessionIdForDevice(r)){W.logger.debug("New session already created. Not creating a new one."),await this.olmDevice.recordSessionProblem(r,"no_olm",!0),this.retryDecryptionFromSender(r);return}let s=this.crypto.deviceList.getDeviceByIdentityKey(t.algorithm,r);if(!s&&(await this.crypto.downloadKeys([i],!1),s=this.crypto.deviceList.getDeviceByIdentityKey(t.algorithm,r),!s)){W.logger.info("Couldn't find device for identity key "+r+": not establishing session"),await this.olmDevice.recordSessionProblem(r,"no_olm",!1),this.retryDecryptionFromSender(r);return}await Ze.ensureOlmSessionsForDevices(this.olmDevice,this.baseApis,{[i]:[s]},!1);const o={algorithm:Ze.OLM_ALGORITHM,sender_key:this.olmDevice.deviceCurve25519Key,ciphertext:{}};await Ze.encryptMessageForDevice(o.ciphertext,this.userId,void 0,this.olmDevice,i,s,{type:"m.dummy"}),await this.olmDevice.recordSessionProblem(r,"no_olm",!0),this.retryDecryptionFromSender(r),await this.baseApis.sendToDevice("m.room.encrypted",{[i]:{[s.deviceId]:o}})}else await this.olmDevice.addInboundGroupSessionWithheld(t.room_id,r,t.session_id,t.code,t.reason)}hasKeysForKeyRequest(e){const t=e.requestBody;return this.olmDevice.hasInboundSessionKeys(t.room_id,t.sender_key,t.session_id)}shareKeysWithDevice(e){const t=e.userId,r=e.deviceId,i=this.crypto.getStoredDevice(t,r),s=e.requestBody;this.olmlib.ensureOlmSessionsForDevices(this.olmDevice,this.baseApis,{[t]:[i]}).then(o=>o[t][r].sessionId?(W.logger.log("sharing keys for session "+s.sender_key+"|"+s.session_id+" with device "+t+":"+r),this.buildKeyForwardingMessage(s.room_id,s.sender_key,s.session_id)):null).then(o=>{const c={algorithm:Ze.OLM_ALGORITHM,sender_key:this.olmDevice.deviceCurve25519Key,ciphertext:{}};return this.olmlib.encryptMessageForDevice(c.ciphertext,this.userId,void 0,this.olmDevice,t,i,o).then(()=>{const l={[t]:{[r]:c}};return this.baseApis.sendToDevice("m.room.encrypted",l)})})}async buildKeyForwardingMessage(e,t,r){const i=await this.olmDevice.getInboundGroupSessionKey(e,t,r);return{type:"m.forwarded_room_key",content:{algorithm:Ze.MEGOLM_ALGORITHM,room_id:e,sender_key:t,sender_claimed_ed25519_key:i.sender_claimed_ed25519_key,session_id:r,session_key:i.key,chain_index:i.chain_index,forwarding_curve25519_key_chain:i.forwarding_curve25519_key_chain,"org.matrix.msc3061.shared_history":i.shared_history||!1}}}importRoomKey(e,t={}){const r={};return(t.untrusted||e.untrusted)&&(r.untrusted=!0),e["org.matrix.msc3061.shared_history"]&&(r.sharedHistory=!0),this.olmDevice.addInboundGroupSession(e.room_id,e.sender_key,e.forwarding_curve25519_key_chain,e.session_id,e.session_key,e.sender_claimed_keys,!0,r).then(()=>{t.source!=="backup"&&this.crypto.backupManager.backupGroupSession(e.sender_key,e.session_id).catch(i=>{W.logger.log("Failed to back up megolm session",i)}),this.retryDecryption(e.sender_key,e.session_id)})}async retryDecryption(e,t){var r;const i=this.pendingEvents[e];if(!i)return!0;const s=i.get(t);return s?(W.logger.debug("Retrying decryption on events",[...s]),await Promise.all([...s].map(async o=>{try{await o.attemptDecryption(this.crypto,{isRetry:!0})}catch{}})),!((r=this.pendingEvents[e])!==null&&r!==void 0&&r.has(t))):!0}async retryDecryptionFromSender(e){const t=this.pendingEvents[e];return t?(delete this.pendingEvents[e],await Promise.all([...t].map(async([r,i])=>{await Promise.all([...i].map(async s=>{try{await s.attemptDecryption(this.crypto)}catch{}}))})),!this.pendingEvents[e]):!0}async sendSharedHistoryInboundSessions(e){await Ze.ensureOlmSessionsForDevices(this.olmDevice,this.baseApis,e),W.logger.log("sendSharedHistoryInboundSessions to users",Object.keys(e));const t=await this.olmDevice.getSharedHistoryInboundGroupSessions(this.roomId);W.logger.log("shared-history sessions",t);for(const[r,i]of t){const s=await this.buildKeyForwardingMessage(this.roomId,r,i),o=[],c={};for(const[l,u]of Object.entries(e)){c[l]={};for(const a of u){const g={algorithm:Ze.OLM_ALGORITHM,sender_key:this.olmDevice.deviceCurve25519Key,ciphertext:{}};c[l][a.deviceId]=g,o.push(Ze.encryptMessageForDevice(g.ciphertext,this.userId,void 0,this.olmDevice,l,a,s))}}await Promise.all(o);for(const l of Object.keys(c)){for(const u of Object.keys(c[l]))Object.keys(c[l][u].ciphertext).length===0&&(W.logger.log("No ciphertext for device "+l+":"+u+": pruning"),delete c[l][u]);Object.keys(c[l]).length===0&&(W.logger.log("Pruned all devices for user "+l),delete c[l])}if(Object.keys(c).length===0){W.logger.log("No users left to send to: aborting");return}await this.baseApis.sendToDevice("m.room.encrypted",c)}}}const Tg={no_olm:"The sender was unable to establish a secure channel.",unknown:"The secure channel with the sender was corrupted."};(0,Wn.registerAlgorithm)(Ze.MEGOLM_ALGORITHM,Fk,qk);(function(n){Object.defineProperty(n,"__esModule",{value:!0});var e=_t;Object.keys(e).forEach(function(t){t==="default"||t==="__esModule"||t in n&&n[t]===e[t]||Object.defineProperty(n,t,{enumerable:!0,get:function(){return e[t]}})})})(df);var jk=V.exports;Object.defineProperty(ys,"__esModule",{value:!0});ys.WITHHELD_MESSAGES=ys.OlmDevice=void 0;var wi=jk(Y.exports),tt=ie,Se=Kr,Og=Vk(df);function Jv(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(Jv=function(r){return r?t:e})(n)}function Vk(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=Jv(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}const kg=65536*3/4;function Cg(n){if(n===void 0)throw new Error("payloadString undefined");if(n.length>kg){const e=new Error("Message too long ("+n.length+" bytes). The maximum for an encrypted message is "+kg+" bytes.");throw e.data={errcode:"M_TOO_LARGE",error:"Payload too large for encrypted message"},e}}class Gk{constructor(e){this.cryptoStore=e,(0,wi.default)(this,"pickleKey","DEFAULT_KEY"),(0,wi.default)(this,"deviceCurve25519Key",null),(0,wi.default)(this,"deviceEd25519Key",null),(0,wi.default)(this,"maxOneTimeKeys",null),(0,wi.default)(this,"outboundGroupSessionStore",{}),(0,wi.default)(this,"inboundGroupSessionMessageIndexes",{}),(0,wi.default)(this,"sessionsInProgress",{}),(0,wi.default)(this,"olmPrekeyPromise",Promise.resolve())}static getOlmVersion(){return j.Olm.get_library_version()}async init({pickleKey:e,fromExportedDevice:t}={}){let r;const i=new j.Olm.Account;try{t?(e&&tt.logger.warn("ignoring opts.pickleKey because opts.fromExportedDevice is present."),this.pickleKey=t.pickleKey,await this.initialiseFromExportedDevice(t,i)):(e&&(this.pickleKey=e),await this.initialiseAccount(i)),r=JSON.parse(i.identity_keys()),this.maxOneTimeKeys=i.max_number_of_one_time_keys()}finally{i.free()}this.deviceCurve25519Key=r.curve25519,this.deviceEd25519Key=r.ed25519}async initialiseFromExportedDevice(e,t){await this.cryptoStore.doTxn("readwrite",[Se.IndexedDBCryptoStore.STORE_ACCOUNT,Se.IndexedDBCryptoStore.STORE_SESSIONS],r=>{this.cryptoStore.storeAccount(r,e.pickledAccount),e.sessions.forEach(i=>{const{deviceKey:s,sessionId:o}=i,c={session:i.session,lastReceivedMessageTs:i.lastReceivedMessageTs};this.cryptoStore.storeEndToEndSession(s,o,c,r)})}),t.unpickle(this.pickleKey,e.pickledAccount)}async initialiseAccount(e){await this.cryptoStore.doTxn("readwrite",[Se.IndexedDBCryptoStore.STORE_ACCOUNT],t=>{this.cryptoStore.getAccount(t,r=>{r!==null?e.unpickle(this.pickleKey,r):(e.create(),r=e.pickle(this.pickleKey),this.cryptoStore.storeAccount(t,r))})})}getAccount(e,t){this.cryptoStore.getAccount(e,r=>{const i=new j.Olm.Account;try{i.unpickle(this.pickleKey,r),t(i)}finally{i.free()}})}storeAccount(e,t){this.cryptoStore.storeAccount(e,t.pickle(this.pickleKey))}async export(){const e={pickleKey:this.pickleKey};return await this.cryptoStore.doTxn("readonly",[Se.IndexedDBCryptoStore.STORE_ACCOUNT,Se.IndexedDBCryptoStore.STORE_SESSIONS],t=>{this.cryptoStore.getAccount(t,r=>{e.pickledAccount=r}),e.sessions=[],this.cryptoStore.getAllEndToEndSessions(t,r=>{e.sessions.push(r)})}),e}getSession(e,t,r,i){this.cryptoStore.getEndToEndSession(e,t,r,s=>{this.unpickleSession(s,i)})}unpickleSession(e,t){const r=new j.Olm.Session;try{r.unpickle(this.pickleKey,e.session);const i=Object.assign({},e,{session:r});t(i)}finally{r.free()}}saveSession(e,t,r){const i=t.session.session_id(),s=Object.assign(t,{session:t.session.pickle(this.pickleKey)});this.cryptoStore.storeEndToEndSession(e,i,s,r)}getUtility(e){const t=new j.Olm.Utility;try{return e(t)}finally{t.free()}}async sign(e){let t;return await this.cryptoStore.doTxn("readonly",[Se.IndexedDBCryptoStore.STORE_ACCOUNT],r=>{this.getAccount(r,i=>{t=i.sign(e)})}),t}async getOneTimeKeys(){let e;return await this.cryptoStore.doTxn("readonly",[Se.IndexedDBCryptoStore.STORE_ACCOUNT],t=>{this.getAccount(t,r=>{e=JSON.parse(r.one_time_keys())})}),e}maxNumberOfOneTimeKeys(){return this.maxOneTimeKeys}async markKeysAsPublished(){await this.cryptoStore.doTxn("readwrite",[Se.IndexedDBCryptoStore.STORE_ACCOUNT],e=>{this.getAccount(e,t=>{t.mark_keys_as_published(),this.storeAccount(e,t)})})}generateOneTimeKeys(e){return this.cryptoStore.doTxn("readwrite",[Se.IndexedDBCryptoStore.STORE_ACCOUNT],t=>{this.getAccount(t,r=>{r.generate_one_time_keys(e),this.storeAccount(t,r)})})}async generateFallbackKey(){await this.cryptoStore.doTxn("readwrite",[Se.IndexedDBCryptoStore.STORE_ACCOUNT],e=>{this.getAccount(e,t=>{t.generate_fallback_key(),this.storeAccount(e,t)})})}async getFallbackKey(){let e;return await this.cryptoStore.doTxn("readonly",[Se.IndexedDBCryptoStore.STORE_ACCOUNT],t=>{this.getAccount(t,r=>{e=JSON.parse(r.unpublished_fallback_key())})}),e}async forgetOldFallbackKey(){await this.cryptoStore.doTxn("readwrite",[Se.IndexedDBCryptoStore.STORE_ACCOUNT],e=>{this.getAccount(e,t=>{t.forget_old_fallback_key(),this.storeAccount(e,t)})})}async createOutboundSession(e,t){let r;return await this.cryptoStore.doTxn("readwrite",[Se.IndexedDBCryptoStore.STORE_ACCOUNT,Se.IndexedDBCryptoStore.STORE_SESSIONS],i=>{this.getAccount(i,s=>{const o=new j.Olm.Session;try{o.create_outbound(s,e,t),r=o.session_id(),this.storeAccount(i,s);const c={session:o,lastReceivedMessageTs:Date.now()};this.saveSession(e,c,i)}finally{o.free()}})},tt.logger.withPrefix("[createOutboundSession]")),r}async createInboundSession(e,t,r){if(t!==0)throw new Error("Need messageType == 0 to create inbound session");let i;return await this.cryptoStore.doTxn("readwrite",[Se.IndexedDBCryptoStore.STORE_ACCOUNT,Se.IndexedDBCryptoStore.STORE_SESSIONS],s=>{this.getAccount(s,o=>{const c=new j.Olm.Session;try{c.create_inbound_from(o,e,r),o.remove_one_time_keys(c),this.storeAccount(s,o);const l=c.decrypt(t,r),u={session:c,lastReceivedMessageTs:Date.now()};this.saveSession(e,u,s),i={payload:l,session_id:c.session_id()}}finally{c.free()}})},tt.logger.withPrefix("[createInboundSession]")),i}async getSessionIdsForDevice(e){const t=tt.logger.withPrefix("[getSessionIdsForDevice]");if(this.sessionsInProgress[e]){t.debug(`Waiting for Olm session for ${e} to be created`);try{await this.sessionsInProgress[e]}catch{}}let r;return await this.cryptoStore.doTxn("readonly",[Se.IndexedDBCryptoStore.STORE_SESSIONS],i=>{this.cryptoStore.getEndToEndSessions(e,i,s=>{r=Object.keys(s)})},t),r}async getSessionIdForDevice(e,t=!1,r){const i=await this.getSessionInfoForDevice(e,t,r);if(i.length===0)return null;let s=0;for(let o=1;o<i.length;o++){const c=i[o],l=c.lastReceivedMessageTs===void 0?0:c.lastReceivedMessageTs,u=i[s],a=u.lastReceivedMessageTs===void 0?0:u.lastReceivedMessageTs;(l>a||l===a&&c.sessionId<u.sessionId)&&(s=o)}return i[s].sessionId}async getSessionInfoForDevice(e,t=!1,r=tt.logger){if(r=r.withPrefix("[getSessionInfoForDevice]"),this.sessionsInProgress[e]&&!t){r.debug(`Waiting for Olm session for ${e} to be created`);try{await this.sessionsInProgress[e]}catch{}}const i=[];return await this.cryptoStore.doTxn("readonly",[Se.IndexedDBCryptoStore.STORE_SESSIONS],s=>{this.cryptoStore.getEndToEndSessions(e,s,o=>{const c=Object.keys(o).sort();for(const l of c)this.unpickleSession(o[l],u=>{i.push({lastReceivedMessageTs:u.lastReceivedMessageTs,hasReceivedMessage:u.session.has_received_message(),sessionId:l})})})},r),i}async encryptMessage(e,t,r){Cg(r);let i;return await this.cryptoStore.doTxn("readwrite",[Se.IndexedDBCryptoStore.STORE_SESSIONS],s=>{this.getSession(e,t,s,o=>{const c=o.session.describe();tt.logger.log("encryptMessage: Olm Session ID "+t+" to "+e+": "+c),i=o.session.encrypt(r),this.saveSession(e,o,s)})},tt.logger.withPrefix("[encryptMessage]")),i}async decryptMessage(e,t,r,i){let s;return await this.cryptoStore.doTxn("readwrite",[Se.IndexedDBCryptoStore.STORE_SESSIONS],o=>{this.getSession(e,t,o,c=>{const l=c.session.describe();tt.logger.log("decryptMessage: Olm Session ID "+t+" from "+e+": "+l),s=c.session.decrypt(r,i),c.lastReceivedMessageTs=Date.now(),this.saveSession(e,c,o)})},tt.logger.withPrefix("[decryptMessage]")),s}async matchesSession(e,t,r,i){if(r!==0)return!1;let s;return await this.cryptoStore.doTxn("readonly",[Se.IndexedDBCryptoStore.STORE_SESSIONS],o=>{this.getSession(e,t,o,c=>{s=c.session.matches_inbound(i)})},tt.logger.withPrefix("[matchesSession]")),s}async recordSessionProblem(e,t,r){await this.cryptoStore.storeEndToEndSessionProblem(e,t,r)}async sessionMayHaveProblems(e,t){return await this.cryptoStore.getEndToEndSessionProblem(e,t)}async filterOutNotifiedErrorDevices(e){return await this.cryptoStore.filterOutNotifiedErrorDevices(e)}saveOutboundGroupSession(e){this.outboundGroupSessionStore[e.session_id()]=e.pickle(this.pickleKey)}getOutboundGroupSession(e,t){const r=this.outboundGroupSessionStore[e];if(r===void 0)throw new Error("Unknown outbound group session "+e);const i=new j.Olm.OutboundGroupSession;try{return i.unpickle(this.pickleKey,r),t(i)}finally{i.free()}}createOutboundGroupSession(){const e=new j.Olm.OutboundGroupSession;try{return e.create(),this.saveOutboundGroupSession(e),e.session_id()}finally{e.free()}}encryptGroupMessage(e,t){return tt.logger.log(`encrypting msg with megolm session ${e}`),Cg(t),this.getOutboundGroupSession(e,r=>{const i=r.encrypt(t);return this.saveOutboundGroupSession(r),i})}getOutboundGroupSessionKey(e){return this.getOutboundGroupSession(e,function(t){return{chain_index:t.message_index(),key:t.session_key()}})}unpickleInboundGroupSession(e,t){const r=new j.Olm.InboundGroupSession;try{return r.unpickle(this.pickleKey,e.session),t(r)}finally{r.free()}}getInboundGroupSession(e,t,r,i,s){this.cryptoStore.getEndToEndInboundGroupSession(t,r,i,(o,c)=>{if(o===null){s(null,null,c);return}if(e!==null&&e!==o.room_id)throw new Error("Mismatched room_id for inbound group session (expected "+o.room_id+", was "+e+")");this.unpickleInboundGroupSession(o,l=>{s(l,o,c)})})}async addInboundGroupSession(e,t,r,i,s,o,c,l={}){await this.cryptoStore.doTxn("readwrite",[Se.IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS,Se.IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS_WITHHELD,Se.IndexedDBCryptoStore.STORE_SHARED_HISTORY_INBOUND_GROUP_SESSIONS],u=>{this.getInboundGroupSession(e,t,i,u,(a,g)=>{const m=new j.Olm.InboundGroupSession;try{if(c?m.import_session(s):m.create(s),i!=m.session_id())throw new Error("Mismatched group session ID from senderKey: "+t);if(a&&(tt.logger.log("Update for megolm session "+t+"/"+i),a.first_known_index()<=m.first_known_index()&&!(a.first_known_index()==m.first_known_index()&&!l.untrusted&&g.untrusted))){tt.logger.log(`Keeping existing megolm session ${i}`);return}tt.logger.info("Storing megolm session "+t+"/"+i+" with first index "+m.first_known_index());const p=Object.assign({},l,{room_id:e,session:m.pickle(this.pickleKey),keysClaimed:o,forwardingCurve25519KeyChain:r});this.cryptoStore.storeEndToEndInboundGroupSession(t,i,p,u),!a&&l.sharedHistory&&this.cryptoStore.addSharedHistoryInboundGroupSession(e,t,i,u)}finally{m.free()}})},tt.logger.withPrefix("[addInboundGroupSession]"))}async addInboundGroupSessionWithheld(e,t,r,i,s){await this.cryptoStore.doTxn("readwrite",[Se.IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS_WITHHELD],o=>{this.cryptoStore.storeEndToEndInboundGroupSessionWithheld(t,r,{room_id:e,code:i,reason:s},o)})}async decryptGroupMessage(e,t,r,i,s,o){let c,l;if(await this.cryptoStore.doTxn("readwrite",[Se.IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS,Se.IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS_WITHHELD],u=>{this.getInboundGroupSession(e,t,r,u,(a,g,m)=>{if(a===null){m&&(l=new Og.DecryptionError("MEGOLM_UNKNOWN_INBOUND_SESSION_ID",Pg(m),{session:t+"|"+r})),c=null;return}let p;try{p=a.decrypt(i)}catch(I){I&&I.message==="OLM.UNKNOWN_MESSAGE_INDEX"&&m?l=new Og.DecryptionError("MEGOLM_UNKNOWN_INBOUND_SESSION_ID",Pg(m),{session:t+"|"+r}):l=I;return}let E=p.plaintext;if(E===void 0)E=p;else{const I=t+"|"+r+"|"+p.message_index;if(I in this.inboundGroupSessionMessageIndexes){const w=this.inboundGroupSessionMessageIndexes[I];if(w.id!==s||w.timestamp!==o){l=new Error("Duplicate message index, possible replay attack: "+I);return}}this.inboundGroupSessionMessageIndexes[I]={id:s,timestamp:o}}g.session=a.pickle(this.pickleKey),this.cryptoStore.storeEndToEndInboundGroupSession(t,r,g,u),c={result:E,keysClaimed:g.keysClaimed||{},senderKey:t,forwardingCurve25519KeyChain:g.forwardingCurve25519KeyChain||[],untrusted:g.untrusted}})},tt.logger.withPrefix("[decryptGroupMessage]")),l)throw l;return c}async hasInboundSessionKeys(e,t,r){let i;return await this.cryptoStore.doTxn("readonly",[Se.IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS,Se.IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS_WITHHELD],s=>{this.cryptoStore.getEndToEndInboundGroupSession(t,r,s,o=>{if(o===null){i=!1;return}e!==o.room_id?(tt.logger.warn(`requested keys for inbound group session ${t}|${r}, with incorrect room_id (expected ${o.room_id}, was ${e})`),i=!1):i=!0})},tt.logger.withPrefix("[hasInboundSessionKeys]")),i}async getInboundGroupSessionKey(e,t,r,i){let s;return await this.cryptoStore.doTxn("readonly",[Se.IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS,Se.IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS_WITHHELD],o=>{this.getInboundGroupSession(e,t,r,o,(c,l)=>{if(c===null){s=null;return}i===void 0&&(i=c.first_known_index());const u=c.export_session(i),g=(l.keysClaimed||{}).ed25519||null;s={chain_index:i,key:u,forwarding_curve25519_key_chain:l.forwardingCurve25519KeyChain||[],sender_claimed_ed25519_key:g,shared_history:l.sharedHistory||!1}})},tt.logger.withPrefix("[getInboundGroupSessionKey]")),s}exportInboundGroupSession(e,t,r){return this.unpickleInboundGroupSession(r,i=>{const s=i.first_known_index();return{sender_key:e,sender_claimed_keys:r.keysClaimed,room_id:r.room_id,session_id:t,session_key:i.export_session(s),forwarding_curve25519_key_chain:r.forwardingCurve25519KeyChain||[],first_known_index:i.first_known_index(),"org.matrix.msc3061.shared_history":r.sharedHistory||!1}})}async getSharedHistoryInboundGroupSessions(e){let t;return await this.cryptoStore.doTxn("readonly",[Se.IndexedDBCryptoStore.STORE_SHARED_HISTORY_INBOUND_GROUP_SESSIONS],r=>{t=this.cryptoStore.getSharedHistoryInboundGroupSessions(e,r)},tt.logger.withPrefix("[getSharedHistoryInboundGroupSessionsForRoom]")),t}verifySignature(e,t,r){this.getUtility(function(i){i.ed25519_verify(e,t,r)})}}ys.OlmDevice=Gk;const vh={"m.unverified":"The sender has disabled encrypting to unverified devices.","m.blacklisted":"The sender has blocked you.","m.unauthorised":"You are not authorised to read the message.","m.no_olm":"Unable to establish a secure channel."};ys.WITHHELD_MESSAGES=vh;function Pg(n){return n.code&&n.code in vh?vh[n.code]:n.reason?n.reason:"decryption key withheld"}var vs={},Ct={},ci={};Object.defineProperty(ci,"__esModule",{value:!0});ci.calculateKeyCheck=Qk;ci.decryptAES=Jk;ci.encryptAES=e_;var ff=G,wn=Me;const Rn=typeof window!="undefined"&&window.crypto?window.crypto.subtle||window.crypto.webkitSubtle:null,Xv=new Uint8Array(8);async function Wk(n,e,t,r){const i=(0,ff.getCrypto)();if(!i)throw new Error("No usable crypto implementation");let s;r?s=(0,wn.decodeBase64)(r):(s=i.randomBytes(16),s[8]&=127);const[o,c]=Qv(e,t),l=i.createCipheriv("aes-256-ctr",o,s),u=Buffer.concat([l.update(n,"utf8"),l.final()]),a=i.createHmac("sha256",c).update(u).digest("base64");return{iv:(0,wn.encodeBase64)(s),ciphertext:u.toString("base64"),mac:a}}async function Hk(n,e,t){const r=(0,ff.getCrypto)();if(!r)throw new Error("No usable crypto implementation");const[i,s]=Qv(e,t);if(r.createHmac("sha256",s).update(Buffer.from(n.ciphertext,"base64")).digest("base64").replace(/=+$/g,"")!==n.mac.replace(/=+$/g,""))throw new Error(`Error decrypting secret ${t}: bad MAC`);const c=r.createDecipheriv("aes-256-ctr",i,(0,wn.decodeBase64)(n.iv));return c.update(n.ciphertext,"base64","utf8")+c.final("utf8")}function Qv(n,e){const t=(0,ff.getCrypto)(),r=t.createHmac("sha256",Xv).update(n).digest(),i=Buffer.alloc(1,1),s=t.createHmac("sha256",r).update(e,"utf8").update(i).digest();i[0]=2;const o=t.createHmac("sha256",r).update(s).update(e,"utf8").update(i).digest();return[s,o]}async function Yk(n,e,t,r){let i;r?i=(0,wn.decodeBase64)(r):(i=new Uint8Array(16),window.crypto.getRandomValues(i),i[8]&=127);const[s,o]=await Zv(e,t),c=new TextEncoder().encode(n),l=await Rn.encrypt({name:"AES-CTR",counter:i,length:64},s,c),u=await Rn.sign({name:"HMAC"},o,l);return{iv:(0,wn.encodeBase64)(i),ciphertext:(0,wn.encodeBase64)(l),mac:(0,wn.encodeBase64)(u)}}async function zk(n,e,t){const[r,i]=await Zv(e,t),s=(0,wn.decodeBase64)(n.ciphertext);if(!await Rn.verify({name:"HMAC"},i,(0,wn.decodeBase64)(n.mac),s))throw new Error(`Error decrypting secret ${t}: bad MAC`);const o=await Rn.decrypt({name:"AES-CTR",counter:(0,wn.decodeBase64)(n.iv),length:64},r,s);return new TextDecoder().decode(new Uint8Array(o))}async function Zv(n,e){const t=await Rn.importKey("raw",n,{name:"HKDF"},!1,["deriveBits"]),r=await Rn.deriveBits({name:"HKDF",salt:Xv,info:new TextEncoder().encode(e),hash:"SHA-256"},t,512),i=r.slice(0,32),s=r.slice(32),o=Rn.importKey("raw",i,{name:"AES-CTR"},!1,["encrypt","decrypt"]),c=Rn.importKey("raw",s,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign","verify"]);return await Promise.all([o,c])}function e_(n,e,t,r){return Rn?Yk(n,e,t,r):Wk(n,e,t,r)}function Jk(n,e,t){return Rn?zk(n,e,t):Hk(n,e,t)}const Xk="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";function Qk(n,e){return e_(Xk,n,"",e)}var Zk=V.exports;Object.defineProperty(Ct,"__esModule",{value:!0});Ct.UserTrustLevel=Ct.DeviceTrustLevel=Ct.CrossSigningLevel=Ct.CrossSigningInfo=void 0;Ct.createCryptoStoreCacheCallbacks=rC;Ct.requestKeysDuringVerification=nC;var Yu=Zk(Y.exports),rr=Me,Bt=ie,Mg=Kr,Ag=ci;const eC=1e3*60;function Oc(n){return Object.values(n.keys)[0]}class zl{constructor(e,t={},r={}){this.userId=e,this.callbacks=t,this.cacheCallbacks=r,(0,Yu.default)(this,"keys",{}),(0,Yu.default)(this,"firstUse",!0),(0,Yu.default)(this,"crossSigningVerifiedBefore",!1)}static fromStorage(e,t){const r=new zl(t);for(const i in e)e.hasOwnProperty(i)&&(r[i]=e[i]);return r}toStorage(){return{keys:this.keys,firstUse:this.firstUse,crossSigningVerifiedBefore:this.crossSigningVerifiedBefore}}async getCrossSigningKey(e,t){const r=["master","self_signing","user_signing"].indexOf(e)>=0;if(!this.callbacks.getCrossSigningKey)throw new Error("No getCrossSigningKey callback supplied");t===void 0&&(t=this.getId(e));function i(l){if(!l)return;const u=new j.Olm.PkSigning,a=u.init_with_seed(l);if(a===t)return[a,u];u.free()}let s;this.cacheCallbacks.getCrossSigningKeyCache&&r&&(s=await this.cacheCallbacks.getCrossSigningKeyCache(e,t));const o=i(s);if(o)return o;s=await this.callbacks.getCrossSigningKey(e,t);const c=i(s);if(c)return this.cacheCallbacks.storeCrossSigningKeyCache&&r&&await this.cacheCallbacks.storeCrossSigningKeyCache(e,s),c;throw s?new Error("Key type "+e+" from getCrossSigningKey callback did not match"):new Error("getCrossSigningKey callback for "+e+" returned falsey")}async isStoredInSecretStorage(e){const t=await e.isStored("m.cross_signing.master",!1)||{};function r(i){for(const s of Object.keys(t))i[s]||delete t[s]}for(const i of["self_signing","user_signing"])r(await e.isStored(`m.cross_signing.${i}`,!1)||{});return Object.keys(t).length?t:null}static async storeInSecretStorage(e,t){for(const[r,i]of e){const s=(0,rr.encodeBase64)(i);await t.store(`m.cross_signing.${r}`,s)}}static async getFromSecretStorage(e,t){const r=await t.get(`m.cross_signing.${e}`);return r?(0,rr.decodeBase64)(r):null}async isStoredInKeyCache(e){const t=this.cacheCallbacks;if(!t)return!1;const r=e?[e]:["master","self_signing","user_signing"];for(const i of r)if(!await t.getCrossSigningKeyCache(i))return!1;return!0}async getCrossSigningKeysFromCache(){const e=new Map,t=this.cacheCallbacks;if(!t)return e;for(const r of["master","self_signing","user_signing"]){const i=await t.getCrossSigningKeyCache(r);!i||e.set(r,i)}return e}getId(e="master"){if(!this.keys[e])return null;const t=this.keys[e];return Oc(t)}async resetKeys(e){if(!this.callbacks.saveCrossSigningKeys)throw new Error("No saveCrossSigningKeys callback supplied");if(e===void 0||e&_n.MASTER||!this.keys.master)e=_n.MASTER|_n.USER_SIGNING|_n.SELF_SIGNING;else if(e===0)return;const t={},r={};let i,s;try{if(e&_n.MASTER?(i=new j.Olm.PkSigning,t.master=i.generate_seed(),s=i.init_with_seed(t.master),r.master={user_id:this.userId,usage:["master"],keys:{["ed25519:"+s]:s}}):[s,i]=await this.getCrossSigningKey("master"),e&_n.SELF_SIGNING){const o=new j.Olm.PkSigning;try{t.self_signing=o.generate_seed();const c=o.init_with_seed(t.self_signing);r.self_signing={user_id:this.userId,usage:["self_signing"],keys:{["ed25519:"+c]:c}},(0,rr.pkSign)(r.self_signing,i,this.userId,s)}finally{o.free()}}if(e&_n.USER_SIGNING){const o=new j.Olm.PkSigning;try{t.user_signing=o.generate_seed();const c=o.init_with_seed(t.user_signing);r.user_signing={user_id:this.userId,usage:["user_signing"],keys:{["ed25519:"+c]:c}},(0,rr.pkSign)(r.user_signing,i,this.userId,s)}finally{o.free()}}Object.assign(this.keys,r),this.callbacks.saveCrossSigningKeys(t)}finally{i&&i.free()}}clearKeys(){this.keys={}}setKeys(e){const t={};if(e.master){if(e.master.user_id!==this.userId){const i="Mismatched user ID "+e.master.user_id+" in master key from "+this.userId;throw Bt.logger.error(i),new Error(i)}this.keys.master?Oc(e.master)!==this.getId()&&(this.firstUse=!1):this.firstUse=!0,t.master=e.master}else if(this.keys.master)t.master=this.keys.master;else throw new Error("Tried to set cross-signing keys without a master key");const r=Oc(t.master);if(e.user_signing){if(e.user_signing.user_id!==this.userId){const i="Mismatched user ID "+e.master.user_id+" in user_signing key from "+this.userId;throw Bt.logger.error(i),new Error(i)}try{(0,rr.pkVerify)(e.user_signing,r,this.userId)}catch(i){throw Bt.logger.error("invalid signature on user-signing key"),i}}if(e.self_signing){if(e.self_signing.user_id!==this.userId){const i="Mismatched user ID "+e.master.user_id+" in self_signing key from "+this.userId;throw Bt.logger.error(i),new Error(i)}try{(0,rr.pkVerify)(e.self_signing,r,this.userId)}catch(i){throw Bt.logger.error("invalid signature on self-signing key"),i}}e.master&&(this.keys.master=e.master,this.keys.self_signing=null,this.keys.user_signing=null),e.self_signing&&(this.keys.self_signing=e.self_signing),e.user_signing&&(this.keys.user_signing=e.user_signing)}updateCrossSigningVerifiedBefore(e){!this.crossSigningVerifiedBefore&&e&&(this.crossSigningVerifiedBefore=!0)}async signObject(e,t){if(!this.keys[t])throw new Error("Attempted to sign with "+t+" key but no such key present");const[r,i]=await this.getCrossSigningKey(t);try{return(0,rr.pkSign)(e,i,this.userId,r),e}finally{i.free()}}async signUser(e){if(!this.keys.user_signing){Bt.logger.info("No user signing key: not signing user");return}return this.signObject(e.keys.master,"user_signing")}async signDevice(e,t){if(e!==this.userId)throw new Error(`Trying to sign ${e}'s device; can only sign our own device`);if(!this.keys.self_signing){Bt.logger.info("No self signing key: not signing device");return}return this.signObject({algorithms:t.algorithms,keys:t.keys,device_id:t.deviceId,user_id:e},"self_signing")}checkUserTrust(e){if(this.userId===e.userId&&this.getId()&&this.getId()===e.getId()&&this.getId("self_signing")&&this.getId("self_signing")===e.getId("self_signing"))return new tl(!0,!0,this.firstUse);if(!this.keys.user_signing)return new tl(!1,!1,e.firstUse);let t;const r=e.keys.master,i=this.getId("user_signing");try{(0,rr.pkVerify)(r,i,this.userId),t=!0}catch{t=!1}return new tl(t,e.crossSigningVerifiedBefore,e.firstUse)}checkDeviceTrust(e,t,r,i){const s=this.checkUserTrust(e),o=e.keys.self_signing;if(!o)return new go(!1,!1,r,i);const c=tC(t,e.userId);try{return(0,rr.pkVerify)(o,e.getId(),e.userId),(0,rr.pkVerify)(c,Oc(o),e.userId),go.fromUserTrustLevel(s,r,i)}catch{return new go(!1,!1,r,i)}}getCacheCallbacks(){return this.cacheCallbacks}}Ct.CrossSigningInfo=zl;function tC(n,e){return{algorithms:n.algorithms,keys:n.keys,device_id:n.deviceId,user_id:e,signatures:n.signatures}}let _n;Ct.CrossSigningLevel=_n;(function(n){n[n.MASTER=4]="MASTER",n[n.USER_SIGNING=2]="USER_SIGNING",n[n.SELF_SIGNING=1]="SELF_SIGNING"})(_n||(Ct.CrossSigningLevel=_n={}));class tl{constructor(e,t,r){this.crossSigningVerified=e,this.crossSigningVerifiedBefore=t,this.tofu=r}isVerified(){return this.isCrossSigningVerified()}isCrossSigningVerified(){return this.crossSigningVerified}wasCrossSigningVerified(){return this.crossSigningVerifiedBefore}isTofu(){return this.tofu}}Ct.UserTrustLevel=tl;class go{constructor(e,t,r,i){this.crossSigningVerified=e,this.tofu=t,this.localVerified=r,this.trustCrossSignedDevices=i}static fromUserTrustLevel(e,t,r){return new go(e.isCrossSigningVerified(),e.isTofu(),t,r)}isVerified(){return Boolean(this.isLocallyVerified()||this.trustCrossSignedDevices&&this.isCrossSigningVerified())}isCrossSigningVerified(){return this.crossSigningVerified}isLocallyVerified(){return this.localVerified}isTofu(){return this.tofu}}Ct.DeviceTrustLevel=go;function rC(n,e){return{getCrossSigningKeyCache:async function(t,r){const i=await new Promise(s=>n.doTxn("readonly",[Mg.IndexedDBCryptoStore.STORE_ACCOUNT],o=>{n.getSecretStorePrivateKey(o,s,t)}));if(i&&i.ciphertext){const s=Buffer.from(e.pickleKey),o=await(0,Ag.decryptAES)(i,s,t);return(0,rr.decodeBase64)(o)}else return i},storeCrossSigningKeyCache:async function(t,r){if(!(r instanceof Uint8Array))throw new Error(`storeCrossSigningKeyCache expects Uint8Array, got ${r}`);const i=Buffer.from(e.pickleKey),s=await(0,Ag.encryptAES)((0,rr.encodeBase64)(r),i,t);return n.doTxn("readwrite",[Mg.IndexedDBCryptoStore.STORE_ACCOUNT],o=>{n.storeSecretStorePrivateKey(o,t,s)})}}}function nC(n,e,t){if(n.getUserId()===e)return Bt.logger.log("Cross-signing: Self-verification done; requesting keys"),new Promise((r,i)=>{const s=n,o=s.crypto.crossSigningInfo,c=new zl(o.userId,{getCrossSigningKey:async a=>{Bt.logger.debug("Cross-signing: requesting secret",a,t);const{promise:g}=s.requestSecret(`m.cross_signing.${a}`,[t]),m=await g,p=(0,rr.decodeBase64)(m);return Uint8Array.from(p)}},o.getCacheCallbacks());c.keys=o.keys;const l=new Promise(a=>{setTimeout(a,eC,new Error("Timeout"))}),u=(async()=>{if(!await s.crypto.getSessionBackupPrivateKey()){Bt.logger.info("No cached backup key found. Requesting...");const m=await s.requestSecret("m.megolm_backup.v1",[t]).promise;Bt.logger.info("Got key backup key, decoding...");const p=(0,rr.decodeBase64)(m);Bt.logger.info("Decoded backup key, storing..."),await s.crypto.storeSessionBackupPrivateKey(Uint8Array.from(p)),Bt.logger.info("Backup key stored. Starting backup restore...");const E=await s.getKeyBackupVersion();s.restoreKeyBackupWithCache(void 0,void 0,E).then(()=>{Bt.logger.info("Backup restored.")})}})();return Promise.race([Promise.all([c.getCrossSigningKey("master"),c.getCrossSigningKey("self_signing"),c.getCrossSigningKey("user_signing"),u]),l]).then(r,i)}).catch(r=>{Bt.logger.warn("Cross-signing: failure while requesting keys:",r)})}var iC=V.exports;Object.defineProperty(vs,"__esModule",{value:!0});vs.TrackingStatus=vs.DeviceList=void 0;var vt=iC(Y.exports),Ae=ie,Pa=Ps,t_=Ct,_h=oC(Me),Dg=Kr,zu=G,sC=qe,Eh=Kt;function r_(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(r_=function(r){return r?t:e})(n)}function oC(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=r_(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}let kt;vs.TrackingStatus=kt;(function(n){n[n.NotTracked=0]="NotTracked",n[n.PendingDownload=1]="PendingDownload",n[n.DownloadInProgress=2]="DownloadInProgress",n[n.UpToDate=3]="UpToDate"})(kt||(vs.TrackingStatus=kt={}));class aC extends sC.TypedEventEmitter{constructor(e,t,r,i=250){super();this.cryptoStore=t,this.keyDownloadChunkSize=i,(0,vt.default)(this,"devices",{}),(0,vt.default)(this,"crossSigningInfo",{}),(0,vt.default)(this,"userByIdentityKey",{}),(0,vt.default)(this,"deviceTrackingStatus",{}),(0,vt.default)(this,"syncToken",null),(0,vt.default)(this,"keyDownloadsInProgressByUser",{}),(0,vt.default)(this,"dirty",!1),(0,vt.default)(this,"savePromise",null),(0,vt.default)(this,"resolveSavePromise",null),(0,vt.default)(this,"savePromiseTime",null),(0,vt.default)(this,"saveTimer",null),(0,vt.default)(this,"hasFetched",null),(0,vt.default)(this,"serialiser",void 0),this.serialiser=new cC(e,r,this)}async load(){await this.cryptoStore.doTxn("readonly",[Dg.IndexedDBCryptoStore.STORE_DEVICE_DATA],e=>{this.cryptoStore.getEndToEndDeviceData(e,t=>{this.hasFetched=Boolean(t&&t.devices),this.devices=t?t.devices:{},this.crossSigningInfo=t?t.crossSigningInfo||{}:{},this.deviceTrackingStatus=t?t.trackingStatus:{},this.syncToken=t?t.syncToken:null,this.userByIdentityKey={};for(const r of Object.keys(this.devices)){const i=this.devices[r];for(const s of Object.keys(i)){const o=i[s].keys["curve25519:"+s];o!==void 0&&(this.userByIdentityKey[o]=r)}}})});for(const e of Object.keys(this.deviceTrackingStatus))this.deviceTrackingStatus[e]==kt.DownloadInProgress&&(this.deviceTrackingStatus[e]=kt.PendingDownload)}stop(){this.saveTimer!==null&&clearTimeout(this.saveTimer)}async saveIfDirty(e=500){if(!this.dirty)return Promise.resolve(!1);const t=Date.now()+e;this.savePromiseTime&&t<this.savePromiseTime&&(clearTimeout(this.saveTimer),this.saveTimer=null,this.savePromiseTime=null);let r=this.savePromise;if(r===null&&(r=new Promise((i,s)=>{this.resolveSavePromise=i}),this.savePromise=r),this.saveTimer===null){const i=this.resolveSavePromise;this.savePromiseTime=t,this.saveTimer=setTimeout(()=>{Ae.logger.log("Saving device tracking data",this.syncToken),this.savePromiseTime=null,this.saveTimer=null,this.savePromise=null,this.resolveSavePromise=null,this.cryptoStore.doTxn("readwrite",[Dg.IndexedDBCryptoStore.STORE_DEVICE_DATA],s=>{this.cryptoStore.storeEndToEndDeviceData({devices:this.devices,crossSigningInfo:this.crossSigningInfo,trackingStatus:this.deviceTrackingStatus,syncToken:this.syncToken},s)}).then(()=>{this.dirty=!1,i(!0)},s=>{Ae.logger.error("Failed to save device tracking data",this.syncToken),Ae.logger.error(s)})},e)}return r}getSyncToken(){return this.syncToken}setSyncToken(e){this.syncToken=e}downloadKeys(e,t){const r=[],i=[];if(e.forEach(s=>{const o=this.deviceTrackingStatus[s];this.keyDownloadsInProgressByUser[s]?(Ae.logger.log(`downloadKeys: already have a download in progress for ${s}: awaiting its result`),i.push(this.keyDownloadsInProgressByUser[s])):(t||o!=kt.UpToDate)&&r.push(s)}),r.length!=0){Ae.logger.log("downloadKeys: downloading for",r);const s=this.doKeyDownload(r);i.push(s)}return i.length===0&&Ae.logger.log("downloadKeys: already have all necessary keys"),Promise.all(i).then(()=>this.getDevicesFromStore(e))}getDevicesFromStore(e){const t={};return e.map(r=>{t[r]={},(this.getStoredDevicesForUser(r)||[]).map(function(s){t[r][s.deviceId]=s})}),t}getKnownUserIds(){return Object.keys(this.devices)}getStoredDevicesForUser(e){const t=this.devices[e];if(!t)return null;const r=[];for(const i in t)t.hasOwnProperty(i)&&r.push(Pa.DeviceInfo.fromStorage(t[i],i));return r}getRawStoredDevicesForUser(e){return this.devices[e]}getStoredCrossSigningForUser(e){return this.crossSigningInfo[e]?t_.CrossSigningInfo.fromStorage(this.crossSigningInfo[e],e):null}storeCrossSigningForUser(e,t){this.crossSigningInfo[e]=t,this.dirty=!0}getStoredDevice(e,t){const r=this.devices[e];if(!(!r||!r[t]))return Pa.DeviceInfo.fromStorage(r[t],t)}getUserByIdentityKey(e,t){return e!==_h.OLM_ALGORITHM&&e!==_h.MEGOLM_ALGORITHM?null:this.userByIdentityKey[t]}getDeviceByIdentityKey(e,t){const r=this.getUserByIdentityKey(e,t);if(!r)return null;const i=this.devices[r];if(!i)return null;for(const s in i){if(!i.hasOwnProperty(s))continue;const o=i[s];for(const c in o.keys){if(!o.keys.hasOwnProperty(c)||c.indexOf("curve25519:")!==0)continue;if(o.keys[c]==t)return Pa.DeviceInfo.fromStorage(o,s)}}return null}storeDevicesForUser(e,t){this.setRawStoredDevicesForUser(e,t),this.dirty=!0}startTrackingDeviceList(e){if(typeof e!="string")throw new Error("userId must be a string; was "+e);this.deviceTrackingStatus[e]||(Ae.logger.log("Now tracking device list for "+e),this.deviceTrackingStatus[e]=kt.PendingDownload,this.dirty=!0)}stopTrackingDeviceList(e){this.deviceTrackingStatus[e]&&(Ae.logger.log("No longer tracking device list for "+e),this.deviceTrackingStatus[e]=kt.NotTracked,this.dirty=!0)}stopTrackingAllDeviceLists(){for(const e of Object.keys(this.deviceTrackingStatus))this.deviceTrackingStatus[e]=kt.NotTracked;this.dirty=!0}invalidateUserDeviceList(e){this.deviceTrackingStatus[e]&&(Ae.logger.log("Marking device list outdated for",e),this.deviceTrackingStatus[e]=kt.PendingDownload,this.dirty=!0)}refreshOutdatedDeviceLists(){this.saveIfDirty();const e=[];for(const t of Object.keys(this.deviceTrackingStatus))this.deviceTrackingStatus[t]==kt.PendingDownload&&e.push(t);return this.doKeyDownload(e)}setRawStoredDevicesForUser(e,t){if(this.devices[e]!==void 0)for(const[r,i]of Object.entries(this.devices[e])){const s=i.keys["curve25519:"+r];delete this.userByIdentityKey[s]}this.devices[e]=t;for(const[r,i]of Object.entries(t)){const s=i.keys["curve25519:"+r];this.userByIdentityKey[s]=e}}setRawStoredCrossSigningForUser(e,t){this.crossSigningInfo[e]=t}doKeyDownload(e){if(e.length===0)return Promise.resolve();const t=this.serialiser.updateDevicesForUsers(e,this.syncToken).then(()=>{r(!0)},i=>{throw Ae.logger.error("Error downloading keys for "+e+":",i),r(!1),i});e.forEach(i=>{this.keyDownloadsInProgressByUser[i]=t,this.deviceTrackingStatus[i]==kt.PendingDownload&&(this.deviceTrackingStatus[i]=kt.DownloadInProgress)});const r=i=>{this.emit(Eh.CryptoEvent.WillUpdateDevices,e,!this.hasFetched),e.forEach(s=>{if(this.dirty=!0,this.keyDownloadsInProgressByUser[s]!==t){Ae.logger.log("Another update in the queue for",s,"- not marking up-to-date");return}delete this.keyDownloadsInProgressByUser[s],this.deviceTrackingStatus[s]==kt.DownloadInProgress&&(i?(this.deviceTrackingStatus[s]=kt.UpToDate,Ae.logger.log("Device list for",s,"now up to date")):this.deviceTrackingStatus[s]=kt.PendingDownload)}),this.saveIfDirty(),this.emit(Eh.CryptoEvent.DevicesUpdated,e,!this.hasFetched),this.hasFetched=!0};return t}}vs.DeviceList=aC;class cC{constructor(e,t,r){this.baseApis=e,this.olmDevice=t,this.deviceList=r,(0,vt.default)(this,"downloadInProgress",!1),(0,vt.default)(this,"keyDownloadsQueuedByUser",{}),(0,vt.default)(this,"queuedQueryDeferred",null),(0,vt.default)(this,"syncToken",null)}updateDevicesForUsers(e,t){return e.forEach(r=>{this.keyDownloadsQueuedByUser[r]=!0}),this.queuedQueryDeferred||(this.queuedQueryDeferred=(0,zu.defer)()),this.syncToken=t,this.downloadInProgress?(Ae.logger.log("Queued key download for",e),this.queuedQueryDeferred.promise):this.doQueuedQueries()}doQueuedQueries(){if(this.downloadInProgress)throw new Error("DeviceListUpdateSerialiser.doQueuedQueries called with request active");const e=Object.keys(this.keyDownloadsQueuedByUser);this.keyDownloadsQueuedByUser={};const t=this.queuedQueryDeferred;this.queuedQueryDeferred=null,Ae.logger.log("Starting key download for",e),this.downloadInProgress=!0;const r={};this.syncToken&&(r.token=this.syncToken);const i=[];for(let s=0;s<e.length;s+=this.deviceList.keyDownloadChunkSize){const o=e.slice(s,s+this.deviceList.keyDownloadChunkSize);i.push(()=>this.baseApis.downloadKeysForUsers(o,r))}return(0,zu.chunkPromises)(i,3).then(async s=>{const o=Object.assign({},...s.map(a=>a.device_keys||{})),c=Object.assign({},...s.map(a=>a.master_keys||{})),l=Object.assign({},...s.map(a=>a.self_signing_keys||{})),u=Object.assign({},...s.map(a=>a.user_signing_keys||{}));for(const a of e){await(0,zu.sleep)(5);try{await this.processQueryResponseForUser(a,o[a],{master:c[a],self_signing:l[a],user_signing:u[a]})}catch(g){Ae.logger.error(`Error processing keys for ${a}:`,g)}}}).then(()=>{Ae.logger.log("Completed key download for "+e),this.downloadInProgress=!1,t.resolve(),this.queuedQueryDeferred&&this.doQueuedQueries()},s=>{Ae.logger.warn("Error downloading keys for "+e+":",s),this.downloadInProgress=!1,t.reject(s)}),t.promise}async processQueryResponseForUser(e,t,r){Ae.logger.log("got device keys for "+e+":",t),Ae.logger.log("got cross-signing keys for "+e+":",r);{const i={},s=this.deviceList.getRawStoredDevicesForUser(e);s&&Object.keys(s).forEach(c=>{const l=Pa.DeviceInfo.fromStorage(s[c],c);i[c]=l}),await lC(this.olmDevice,e,i,t||{},this.baseApis.getUserId(),this.baseApis.deviceId);const o={};Object.keys(i).forEach(c=>{o[c]=i[c].toStorage()}),this.deviceList.setRawStoredDevicesForUser(e,o)}if(r&&(r.master||r.self_signing||r.user_signing)){const i=this.deviceList.getStoredCrossSigningForUser(e)||new t_.CrossSigningInfo(e);i.setKeys(r),this.deviceList.setRawStoredCrossSigningForUser(e,i.toStorage()),this.deviceList.emit(Eh.CryptoEvent.UserCrossSigningUpdated,e)}}}async function lC(n,e,t,r,i,s){let o=!1;for(const c in t)if(!!t.hasOwnProperty(c)&&!(c in r)){if(e===i&&c===s){Ae.logger.warn(`Local device ${c} missing from sync, skipping removal`);continue}Ae.logger.log("Device "+e+":"+c+" has been removed"),delete t[c],o=!0}for(const c in r){if(!r.hasOwnProperty(c))continue;const l=r[c];if(l.user_id!==e){Ae.logger.warn("Mismatched user_id "+l.user_id+" in keys from "+e+":"+c);continue}if(l.device_id!==c){Ae.logger.warn("Mismatched device_id "+l.device_id+" in keys from "+e+":"+c);continue}await uC(n,t,l)&&(o=!0)}return o}async function uC(n,e,t){if(!t.keys)return!1;const r=t.device_id,i=t.user_id,s="ed25519:"+r,o=t.keys[s];if(!o)return Ae.logger.warn("Device "+i+":"+r+" has no ed25519 key"),!1;const c=t.unsigned||{},l=t.signatures||{};try{await _h.verifySignature(n,t,i,r,o)}catch(a){return Ae.logger.warn("Unable to verify signature on device "+i+":"+r+":"+a),!1}let u;if(r in e){if(u=e[r],u.getFingerprint()!=o)return Ae.logger.warn("Ed25519 key for device "+i+":"+r+" has changed"),!1}else e[r]=u=new Pa.DeviceInfo(r);return u.keys=t.keys||{},u.algorithms=t.algorithms||[],u.unsigned=c,u.signatures=l,!0}var bo={},dC=V.exports;Object.defineProperty(bo,"__esModule",{value:!0});bo.EncryptionSetupOperation=bo.EncryptionSetupBuilder=void 0;var En=dC(Y.exports),hC=ie,fC=qt,pC=Ct,gC=Kr,kc=me,mC=Is,yC=qe;class vC{constructor(e,t){(0,En.default)(this,"accountDataClientAdapter",void 0),(0,En.default)(this,"crossSigningCallbacks",void 0),(0,En.default)(this,"ssssCryptoCallbacks",void 0),(0,En.default)(this,"crossSigningKeys",null),(0,En.default)(this,"keySignatures",null),(0,En.default)(this,"keyBackupInfo",null),(0,En.default)(this,"sessionBackupPrivateKey",void 0),this.accountDataClientAdapter=new _C(e),this.crossSigningCallbacks=new EC,this.ssssCryptoCallbacks=new SC(t)}addCrossSigningKeys(e,t){this.crossSigningKeys={authUpload:e,keys:t}}addSessionBackup(e){this.keyBackupInfo=e}addSessionBackupPrivateKeyToCache(e){this.sessionBackupPrivateKey=e}addKeySignature(e,t,r){this.keySignatures||(this.keySignatures={});const i=this.keySignatures[e]||{};this.keySignatures[e]=i,i[t]=r}async setAccountData(e,t){await this.accountDataClientAdapter.setAccountData(e,t)}buildOperation(){const e=this.accountDataClientAdapter.values;return new n_(e,this.crossSigningKeys,this.keyBackupInfo,this.keySignatures)}async persist(e){if(this.crossSigningKeys){const t=(0,pC.createCryptoStoreCacheCallbacks)(e.cryptoStore,e.olmDevice);for(const r of["master","self_signing","user_signing"]){hC.logger.log(`Cache ${r} cross-signing private key locally`);const i=this.crossSigningCallbacks.privateKeys.get(r);await t.storeCrossSigningKeyCache(r,i)}await e.cryptoStore.doTxn("readwrite",[gC.IndexedDBCryptoStore.STORE_ACCOUNT],r=>{e.cryptoStore.storeCrossSigningKeys(r,this.crossSigningKeys.keys)})}this.sessionBackupPrivateKey&&await e.storeSessionBackupPrivateKey(this.sessionBackupPrivateKey)}}bo.EncryptionSetupBuilder=vC;class n_{constructor(e,t,r,i){this.accountData=e,this.crossSigningKeys=t,this.keyBackupInfo=r,this.keySignatures=i}async apply(e){const t=e.baseApis;if(this.crossSigningKeys){const r={};for(const[i,s]of Object.entries(this.crossSigningKeys.keys))r[i+"_key"]=s;await this.crossSigningKeys.authUpload(i=>t.uploadDeviceSigningKeys(i,r)),e.crossSigningInfo.setKeys(this.crossSigningKeys.keys)}if(this.accountData)for(const[r,i]of this.accountData)await t.setAccountData(r,i);this.keySignatures&&await t.uploadKeySignatures(this.keySignatures),this.keyBackupInfo&&(this.keyBackupInfo.version?await t.http.authedRequest(void 0,kc.Method.Put,"/room_keys/version/"+this.keyBackupInfo.version,void 0,{algorithm:this.keyBackupInfo.algorithm,auth_data:this.keyBackupInfo.auth_data},{prefix:kc.PREFIX_UNSTABLE}):await t.http.authedRequest(void 0,kc.Method.Post,"/room_keys/version",void 0,this.keyBackupInfo,{prefix:kc.PREFIX_UNSTABLE}))}}bo.EncryptionSetupOperation=n_;class _C extends yC.TypedEventEmitter{constructor(e){super();this.existingValues=e,(0,En.default)(this,"values",new Map)}getAccountDataFromServer(e){return Promise.resolve(this.getAccountData(e))}getAccountData(e){const t=this.values.get(e);if(t)return t;const r=this.existingValues[e];return r?r.getContent():null}setAccountData(e,t){const r=this.values.get(e);return this.values.set(e,t),Promise.resolve().then(()=>{const i=new fC.MatrixEvent({type:e,content:t});return this.emit(mC.ClientEvent.AccountData,i,r),{}})}}class EC{constructor(){(0,En.default)(this,"privateKeys",new Map)}getCrossSigningKeyCache(e,t){return this.getCrossSigningKey(e,t)}storeCrossSigningKeyCache(e,t){return this.privateKeys.set(e,t),Promise.resolve()}getCrossSigningKey(e,t){return Promise.resolve(this.privateKeys.get(e))}saveCrossSigningKeys(e){for(const[t,r]of Object.entries(e))this.privateKeys.set(t,r)}}class SC{constructor(e){this.delegateCryptoCallbacks=e,(0,En.default)(this,"privateKeys",new Map)}async getSecretStorageKey({keys:e},t){var r;for(const i of Object.keys(e)){const s=this.privateKeys.get(i);if(s)return[i,s]}if(this!==null&&this!==void 0&&(r=this.delegateCryptoCallbacks)!==null&&r!==void 0&&r.getSecretStorageKey){const i=await this.delegateCryptoCallbacks.getSecretStorageKey({keys:e},t);if(i){const[s,o]=i;this.privateKeys.set(s,o)}return i}return null}addPrivateKey(e,t,r){var i,s;this.privateKeys.set(e,r),(i=this.delegateCryptoCallbacks)===null||i===void 0||(s=i.cacheSecretStorageKey)===null||s===void 0||s.call(i,e,t,r)}}var wo={},bC=V.exports;Object.defineProperty(wo,"__esModule",{value:!0});wo.SecretStorage=wo.SECRET_STORAGE_ALGORITHM_V1_AES=void 0;var wC=bC(Y.exports),un=ie,Qo=IC(Me),RC=oi,Cc=ci,Ju=Is;function i_(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(i_=function(r){return r?t:e})(n)}function IC(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=i_(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}const Xi="m.secret_storage.v1.aes-hmac-sha2";wo.SECRET_STORAGE_ALGORITHM_V1_AES=Xi;class TC{constructor(e,t,r){this.accountDataAdapter=e,this.cryptoCallbacks=t,this.baseApis=r,(0,wC.default)(this,"requests",new Map)}async getDefaultKeyId(){const e=await this.accountDataAdapter.getAccountDataFromServer("m.secret_storage.default_key");return e?e.key:null}setDefaultKeyId(e){return new Promise((t,r)=>{const i=s=>{s.getType()==="m.secret_storage.default_key"&&s.getContent().key===e&&(this.accountDataAdapter.removeListener(Ju.ClientEvent.AccountData,i),t())};this.accountDataAdapter.on(Ju.ClientEvent.AccountData,i),this.accountDataAdapter.setAccountData("m.secret_storage.default_key",{key:e}).catch(s=>{this.accountDataAdapter.removeListener(Ju.ClientEvent.AccountData,i),r(s)})})}async addKey(e,t,r){const i={algorithm:e};if(t||(t={}),t.name&&(i.name=t.name),e===Xi){if(t.passphrase&&(i.passphrase=t.passphrase),t.key){const{iv:s,mac:o}=await(0,Cc.calculateKeyCheck)(t.key);i.iv=s,i.mac=o}}else throw new Error(`Unknown key algorithm ${e}`);if(!r)do r=(0,RC.randomString)(32);while(await this.accountDataAdapter.getAccountDataFromServer(`m.secret_storage.key.${r}`));return await this.accountDataAdapter.setAccountData(`m.secret_storage.key.${r}`,i),{keyId:r,keyInfo:i}}async getKey(e){if(e||(e=await this.getDefaultKeyId()),!e)return null;const t=await this.accountDataAdapter.getAccountDataFromServer("m.secret_storage.key."+e);return t?[e,t]:null}async hasKey(e){return Boolean(await this.getKey(e))}async checkKey(e,t){if(t.algorithm===Xi)if(t.mac){const{mac:r}=await(0,Cc.calculateKeyCheck)(e,t.iv);return t.mac.replace(/=+$/g,"")===r.replace(/=+$/g,"")}else return!0;else throw new Error("Unknown algorithm")}async store(e,t,r){const i={};if(!r){const s=await this.getDefaultKeyId();if(!s)throw new Error("No keys specified and no default key present");r=[s]}if(r.length===0)throw new Error("Zero keys given to encrypt with!");for(const s of r){const o=await this.accountDataAdapter.getAccountDataFromServer("m.secret_storage.key."+s);if(!o)throw new Error("Unknown key: "+s);if(o.algorithm===Xi){const c={[s]:o},[,l]=await this.getSecretStorageKey(c,e);i[s]=await l.encrypt(t)}else un.logger.warn("unknown algorithm for secret storage key "+s+": "+o.algorithm)}await this.accountDataAdapter.setAccountData(e,{encrypted:i})}async get(e){const t=await this.accountDataAdapter.getAccountDataFromServer(e);if(!t)return;if(!t.encrypted)throw new Error("Content is not encrypted!");const r={};for(const o of Object.keys(t.encrypted)){const c=await this.accountDataAdapter.getAccountDataFromServer("m.secret_storage.key."+o),l=t.encrypted[o];c.algorithm===Xi&&l.iv&&l.ciphertext&&l.mac&&(r[o]=c)}if(Object.keys(r).length===0)throw new Error(`Could not decrypt ${e} because none of the keys it is encrypted with are for a supported algorithm`);let i,s;try{[i,s]=await this.getSecretStorageKey(r,e);const o=t.encrypted[i];return o.passthrough?(0,Qo.encodeBase64)(s.get_private_key()):await s.decrypt(o)}finally{s&&s.free&&s.free()}}async isStored(e,t){const r=await this.accountDataAdapter.getAccountDataFromServer(e);if(!r||!r.encrypted)return null;const i={};for(const s of Object.keys(r.encrypted)){const o=await this.accountDataAdapter.getAccountDataFromServer("m.secret_storage.key."+s);if(!o)continue;const c=r.encrypted[s];o.algorithm===Xi&&c.iv&&c.ciphertext&&c.mac&&(i[s]=o)}return Object.keys(i).length?i:null}request(e,t){const r=this.baseApis.makeTxnId();let i,s;const o=new Promise((a,g)=>{i=a,s=g});this.requests.set(r,{name:e,devices:t,resolve:i,reject:s});const c=a=>{const g={action:"request_cancellation",requesting_device_id:this.baseApis.deviceId,request_id:r},m={};for(const p of t)m[p]=g;this.baseApis.sendToDevice("m.secret.request",{[this.baseApis.getUserId()]:m}),s(new Error(a||"Cancelled"))},l={name:e,action:"request",requesting_device_id:this.baseApis.deviceId,request_id:r},u={};for(const a of t)u[a]=l;return un.logger.info(`Request secret ${e} from ${t}, id ${r}`),this.baseApis.sendToDevice("m.secret.request",{[this.baseApis.getUserId()]:u}),{requestId:r,promise:o,cancel:c}}async onRequestReceived(e){const t=e.getSender(),r=e.getContent();if(t!==this.baseApis.getUserId()||!(r.name&&r.action&&r.requesting_device_id&&r.request_id))return;const i=r.requesting_device_id;if(r.action!=="request_cancellation"){if(r.action==="request"){if(i===this.baseApis.deviceId||(un.logger.info("received request for secret ("+t+", "+i+", "+r.request_id+")"),!this.cryptoCallbacks.onSecretRequested))return;const s=await this.cryptoCallbacks.onSecretRequested(t,i,r.request_id,r.name,this.baseApis.checkDeviceTrust(t,i));if(s){un.logger.info(`Preparing ${r.name} secret for ${i}`);const o={type:"m.secret.send",content:{request_id:r.request_id,secret:s}},c={algorithm:Qo.OLM_ALGORITHM,sender_key:this.baseApis.crypto.olmDevice.deviceCurve25519Key,ciphertext:{}};await Qo.ensureOlmSessionsForDevices(this.baseApis.crypto.olmDevice,this.baseApis,{[t]:[this.baseApis.getStoredDevice(t,i)]}),await Qo.encryptMessageForDevice(c.ciphertext,this.baseApis.getUserId(),this.baseApis.deviceId,this.baseApis.crypto.olmDevice,t,this.baseApis.getStoredDevice(t,i),o);const l={[t]:{[i]:c}};un.logger.info(`Sending ${r.name} secret for ${i}`),this.baseApis.sendToDevice("m.room.encrypted",l)}else un.logger.info(`Request denied for ${r.name} secret for ${i}`)}}}onSecretReceived(e){if(e.getSender()!==this.baseApis.getUserId())return;const t=e.getContent();un.logger.log("got secret share for request",t.request_id);const r=this.requests.get(t.request_id);if(r){const i=this.baseApis.crypto.deviceList.getDeviceByIdentityKey(Qo.OLM_ALGORITHM,e.getSenderKey());if(!i){un.logger.log("secret share from unknown device with key",e.getSenderKey());return}if(!r.devices.includes(i.deviceId)){un.logger.log("unsolicited secret share from device",i.deviceId);return}un.logger.log(`Successfully received secret ${r.name} from ${i.deviceId}`),r.resolve(t.secret)}}async getSecretStorageKey(e,t){if(!this.cryptoCallbacks.getSecretStorageKey)throw new Error("No getSecretStorageKey callback supplied");const r=await this.cryptoCallbacks.getSecretStorageKey({keys:e},t);if(!r)throw new Error("getSecretStorageKey callback returned falsey");if(r.length<2)throw new Error("getSecretStorageKey callback returned invalid data");const[i,s]=r;if(!e[i])throw new Error("App returned unknown key from getSecretStorageKey!");if(e[i].algorithm===Xi)return[i,{encrypt:async function(c){return await(0,Cc.encryptAES)(c,s,t)},decrypt:async function(c){return await(0,Cc.decryptAES)(c,s,t)}}];throw new Error("Unknown key type: "+e[i].algorithm)}}wo.SecretStorage=TC;var _s={},OC=V.exports;Object.defineProperty(_s,"__esModule",{value:!0});_s.RoomKeyRequestState=_s.OutgoingRoomKeyRequestManager=void 0;var Xu=OC(Y.exports),xn=ie,kC=ne;const CC=500;let _e;_s.RoomKeyRequestState=_e;(function(n){n[n.Unsent=0]="Unsent",n[n.Sent=1]="Sent",n[n.CancellationPending=2]="CancellationPending",n[n.CancellationPendingAndWillResend=3]="CancellationPendingAndWillResend"})(_e||(_s.RoomKeyRequestState=_e={}));class PC{constructor(e,t,r){this.baseApis=e,this.deviceId=t,this.cryptoStore=r,(0,Xu.default)(this,"sendOutgoingRoomKeyRequestsTimer",null),(0,Xu.default)(this,"sendOutgoingRoomKeyRequestsRunning",!1),(0,Xu.default)(this,"clientRunning",!1)}start(){this.clientRunning=!0}stop(){xn.logger.log("stopping OutgoingRoomKeyRequestManager"),this.clientRunning=!1}sendQueuedRequests(){this.startTimer()}async queueRoomKeyRequest(e,t,r=!1){const i=await this.cryptoStore.getOutgoingRoomKeyRequest(e);if(!i)await this.cryptoStore.getOrAddOutgoingRoomKeyRequest({requestBody:e,recipients:t,requestId:this.baseApis.makeTxnId(),state:_e.Unsent});else switch(i.state){case _e.CancellationPendingAndWillResend:case _e.Unsent:return;case _e.CancellationPending:{const s=r?_e.CancellationPendingAndWillResend:_e.Sent;await this.cryptoStore.updateOutgoingRoomKeyRequest(i.requestId,_e.CancellationPending,{state:s,cancellationTxnId:this.baseApis.makeTxnId()});break}case _e.Sent:{if(r){const s=_e.CancellationPendingAndWillResend,o=await this.cryptoStore.updateOutgoingRoomKeyRequest(i.requestId,_e.Sent,{state:s,cancellationTxnId:this.baseApis.makeTxnId(),requestTxnId:this.baseApis.makeTxnId()});if(!o)return await this.queueRoomKeyRequest(e,t,r);try{await this.sendOutgoingRoomKeyRequestCancellation(o,!0)}catch(c){xn.logger.error("Error sending room key request cancellation; will retry later.",c)}}break}default:throw new Error("unhandled state: "+i.state)}}cancelRoomKeyRequest(e){return this.cryptoStore.getOutgoingRoomKeyRequest(e).then(t=>{if(!!t)switch(t.state){case _e.CancellationPending:case _e.CancellationPendingAndWillResend:return;case _e.Unsent:return xn.logger.log("deleting unnecessary room key request for "+Pc(e)),this.cryptoStore.deleteOutgoingRoomKeyRequest(t.requestId,_e.Unsent);case _e.Sent:return this.cryptoStore.updateOutgoingRoomKeyRequest(t.requestId,_e.Sent,{state:_e.CancellationPending,cancellationTxnId:this.baseApis.makeTxnId()}).then(r=>{if(!r){xn.logger.log("Tried to cancel room key request for "+Pc(e)+" but it was already cancelled in another tab");return}this.sendOutgoingRoomKeyRequestCancellation(r).catch(i=>{xn.logger.error("Error sending room key request cancellation; will retry later.",i),this.startTimer()})});default:throw new Error("unhandled state: "+t.state)}})}getOutgoingSentRoomKeyRequest(e,t){return this.cryptoStore.getOutgoingRoomKeyRequestsByTarget(e,t,[_e.Sent])}async cancelAndResendAllOutgoingRequests(){const e=await this.cryptoStore.getAllOutgoingRoomKeyRequestsByState(_e.Sent);return Promise.all(e.map(({requestBody:t,recipients:r})=>this.queueRoomKeyRequest(t,r,!0)))}startTimer(){if(this.sendOutgoingRoomKeyRequestsTimer)return;const e=()=>{if(this.sendOutgoingRoomKeyRequestsRunning)throw new Error("RoomKeyRequestSend already in progress!");this.sendOutgoingRoomKeyRequestsRunning=!0,this.sendOutgoingRoomKeyRequests().finally(()=>{this.sendOutgoingRoomKeyRequestsRunning=!1}).catch(t=>{xn.logger.warn(`error in OutgoingRoomKeyRequestManager: ${t}`)})};this.sendOutgoingRoomKeyRequestsTimer=setTimeout(e,CC)}sendOutgoingRoomKeyRequests(){return this.clientRunning?this.cryptoStore.getOutgoingRoomKeyRequestByState([_e.CancellationPending,_e.CancellationPendingAndWillResend,_e.Unsent]).then(e=>{if(!e){this.sendOutgoingRoomKeyRequestsTimer=null;return}let t;switch(e.state){case _e.Unsent:t=this.sendOutgoingRoomKeyRequest(e);break;case _e.CancellationPending:t=this.sendOutgoingRoomKeyRequestCancellation(e);break;case _e.CancellationPendingAndWillResend:t=this.sendOutgoingRoomKeyRequestCancellation(e,!0);break}return t.then(()=>this.sendOutgoingRoomKeyRequests()).catch(r=>{xn.logger.error("Error sending room key request; will retry later.",r),this.sendOutgoingRoomKeyRequestsTimer=null})}):(this.sendOutgoingRoomKeyRequestsTimer=null,Promise.resolve())}sendOutgoingRoomKeyRequest(e){xn.logger.log(`Requesting keys for ${Pc(e.requestBody)} from ${Ug(e.recipients)}(id ${e.requestId})`);const t={action:"request",requesting_device_id:this.deviceId,request_id:e.requestId,body:e.requestBody};return this.sendMessageToDevices(t,e.recipients,e.requestTxnId||e.requestId).then(()=>this.cryptoStore.updateOutgoingRoomKeyRequest(e.requestId,_e.Unsent,{state:_e.Sent}))}sendOutgoingRoomKeyRequestCancellation(e,t=!1){xn.logger.log(`Sending cancellation for key request for ${Pc(e.requestBody)} to ${Ug(e.recipients)} (cancellation id ${e.cancellationTxnId})`);const r={action:"request_cancellation",requesting_device_id:this.deviceId,request_id:e.requestId};return this.sendMessageToDevices(r,e.recipients,e.cancellationTxnId).then(()=>t?this.cryptoStore.updateOutgoingRoomKeyRequest(e.requestId,_e.CancellationPendingAndWillResend,{state:_e.Unsent}):this.cryptoStore.deleteOutgoingRoomKeyRequest(e.requestId,_e.CancellationPending))}sendMessageToDevices(e,t,r){const i={};for(const s of t)i[s.userId]||(i[s.userId]={}),i[s.userId][s.deviceId]=e;return this.baseApis.sendToDevice(kC.EventType.RoomKeyRequest,i,r)}}_s.OutgoingRoomKeyRequestManager=PC;function Pc(n){return n.room_id+" / "+n.session_id}function Ug(n){return"["+n.map(e=>`${e.userId}:${e.deviceId}`).join(",")+"]"}var or={},Qr={},Le={};Object.defineProperty(Le,"__esModule",{value:!0});Le.errorFactory=li;Le.errorFromEvent=KC;Le.newUserMismatchError=Le.newUserCancelledError=Le.newUnknownTransactionError=Le.newUnknownMethodError=Le.newUnexpectedMessageError=Le.newTimeoutError=Le.newKeyMismatchError=Le.newInvalidMessageError=void 0;Le.newVerificationError=s_;var MC=qt;function s_(n,e,t){const r=Object.assign({},{code:n,reason:e},t);return new MC.MatrixEvent({type:"m.key.verification.cancel",content:r})}function li(n,e){return function(t){return s_(n,e,t)}}const AC=li("m.user","Cancelled by user");Le.newUserCancelledError=AC;const DC=li("m.timeout","Timed out");Le.newTimeoutError=DC;const UC=li("m.unknown_transaction","Unknown transaction");Le.newUnknownTransactionError=UC;const $C=li("m.unknown_method","Unknown method");Le.newUnknownMethodError=$C;const xC=li("m.unexpected_message","Unexpected message");Le.newUnexpectedMessageError=xC;const NC=li("m.key_mismatch","Key mismatch");Le.newKeyMismatchError=NC;const LC=li("m.user_error","User mismatch");Le.newUserMismatchError=LC;const BC=li("m.invalid_message","Invalid message");Le.newInvalidMessageError=BC;function KC(n){const e=n.getContent();if(e){const{code:t,reason:r}=e;return{code:t,reason:r}}else return{code:"Unknown error",reason:"m.unknown"}}var FC=V.exports;Object.defineProperty(Qr,"__esModule",{value:!0});Qr.VerificationEvent=Qr.VerificationBase=Qr.SwitchStartEventError=void 0;var Wr=FC(Y.exports),qC=qt,Zo=ie,jC=Ps,VC=Le,GC=Ct,WC=qe;const $g=new Error("Verification timed out");class o_ extends Error{constructor(e){super();this.startEvent=e}}Qr.SwitchStartEventError=o_;let bl;Qr.VerificationEvent=bl;(function(n){n.Cancel="cancel"})(bl||(Qr.VerificationEvent=bl={}));class HC extends WC.TypedEventEmitter{constructor(e,t,r,i,s,o){super();this.channel=e,this.baseApis=t,this.userId=r,this.deviceId=i,this.startEvent=s,this.request=o,(0,Wr.default)(this,"cancelled",!1),(0,Wr.default)(this,"_done",!1),(0,Wr.default)(this,"promise",null),(0,Wr.default)(this,"transactionTimeoutTimer",null),(0,Wr.default)(this,"expectedEvent",void 0),(0,Wr.default)(this,"resolve",void 0),(0,Wr.default)(this,"reject",void 0),(0,Wr.default)(this,"resolveEvent",void 0),(0,Wr.default)(this,"rejectEvent",void 0),(0,Wr.default)(this,"started",void 0),(0,Wr.default)(this,"doVerification",void 0)}get initiatedByMe(){if(!this.startEvent)return!0;const e=this.startEvent.getSender(),t=this.startEvent.getContent();return e===this.baseApis.getUserId()&&t.from_device===this.baseApis.getDeviceId()}get hasBeenCancelled(){return this.cancelled}resetTimer(){Zo.logger.info("Refreshing/starting the verification transaction timeout timer"),this.transactionTimeoutTimer!==null&&clearTimeout(this.transactionTimeoutTimer),this.transactionTimeoutTimer=setTimeout(()=>{!this._done&&!this.cancelled&&(Zo.logger.info("Triggering verification timeout"),this.cancel($g))},10*60*1e3)}endTimer(){this.transactionTimeoutTimer!==null&&(clearTimeout(this.transactionTimeoutTimer),this.transactionTimeoutTimer=null)}send(e,t){return this.channel.send(e,t)}waitForEvent(e){if(this._done)return Promise.reject(new Error("Verification is already done"));const t=this.request.getEventFromOtherParty(e);return t?Promise.resolve(t):(this.expectedEvent=e,new Promise((r,i)=>{this.resolveEvent=r,this.rejectEvent=i}))}canSwitchStartEvent(e){return!1}switchStartEvent(e){if(this.canSwitchStartEvent(e))if(Zo.logger.log("Verification Base: switching verification start event",{restartingFlow:!!this.rejectEvent}),this.rejectEvent){const t=this.rejectEvent;this.rejectEvent=void 0,t(new o_(e))}else this.startEvent=e}handleEvent(e){if(!this._done){if(e.getType()===this.expectedEvent)this.expectedEvent!=="m.key.verification.done"&&(this.expectedEvent=void 0,this.rejectEvent=void 0,this.resetTimer(),this.resolveEvent(e));else if(e.getType()==="m.key.verification.cancel"){const t=this.reject;if(this.reject=void 0,t){const r=e.getContent(),{reason:i,code:s}=r;t(new Error(`Other side cancelled verification because ${i} (${s})`))}}else if(this.expectedEvent){const t=new Error("Unexpected message: expecting "+this.expectedEvent+" but got "+e.getType());if(this.expectedEvent=void 0,this.rejectEvent){const r=this.rejectEvent;this.rejectEvent=void 0,r(t)}this.cancel(t)}}}done(){if(this.endTimer(),!this._done)return this.request.onVerifierFinished(),this.resolve(),(0,GC.requestKeysDuringVerification)(this.baseApis,this.userId,this.deviceId)}cancel(e){if(this.endTimer(),!this._done){if(this.cancelled=!0,this.request.onVerifierCancelled(),this.userId&&this.deviceId)if(e===$g){const t=(0,VC.newTimeoutError)();this.send(t.getType(),t.getContent())}else if(e instanceof qC.MatrixEvent){if(e.getSender()!==this.userId){const r=e.getContent();e.getType()==="m.key.verification.cancel"?(r.code=r.code||"m.unknown",r.reason=r.reason||r.body||"Unknown reason",this.send("m.key.verification.cancel",r)):this.send("m.key.verification.cancel",{code:"m.unknown",reason:r.body||"Unknown reason"})}}else this.send("m.key.verification.cancel",{code:"m.unknown",reason:e.toString()});this.promise!==null?this.reject&&this.reject(e):this.promise=Promise.reject(e),this.emit(bl.Cancel,e)}}verify(){return this.promise?this.promise:(this.promise=new Promise((e,t)=>{this.resolve=(...r)=>{this._done=!0,this.endTimer(),e(...r)},this.reject=r=>{this._done=!0,this.endTimer(),t(r)}}),this.doVerification&&!this.started&&(this.started=!0,this.resetTimer(),Promise.resolve(this.doVerification()).then(this.done.bind(this),this.cancel.bind(this))),this.promise)}async verifyKeys(e,t,r){const i=[];for(const[s,o]of Object.entries(t)){const c=s.split(":",2)[1],l=this.baseApis.getStoredDevice(e,c);if(l)r(s,l,o),i.push(c);else{const u=this.baseApis.crypto.deviceList.getStoredCrossSigningForUser(e);u&&u.getId()===c?(r(s,jC.DeviceInfo.fromStorage({keys:{[s]:c}},c),o),i.push(c)):Zo.logger.warn(`verification: Could not find device ${c} to verify`)}}if(!i.length)throw new Error("No devices could be verified");Zo.logger.info("Verification completed! Marking devices verified: ",i);for(const s of i)await this.baseApis.setDeviceVerified(e,s)}get events(){}}Qr.VerificationBase=HC;var YC=V.exports;Object.defineProperty(or,"__esModule",{value:!0});or.SHOW_QR_CODE_METHOD=or.SCAN_QR_CODE_METHOD=or.ReciprocateQRCode=or.QrCodeEvent=or.QRCodeData=void 0;var xg=YC(Y.exports),zC=Qr,js=Le,Ng=Me,Lg=ie;const JC="m.qr_code.show.v1";or.SHOW_QR_CODE_METHOD=JC;const XC="m.qr_code.scan.v1";or.SCAN_QR_CODE_METHOD=XC;let wl;or.QrCodeEvent=wl;(function(n){n.ShowReciprocateQr="show_reciprocate_qr"})(wl||(or.QrCodeEvent=wl={}));class pf extends zC.VerificationBase{constructor(...e){super(...e);(0,xg.default)(this,"reciprocateQREvent",void 0),(0,xg.default)(this,"doVerification",async()=>{if(!this.startEvent)throw new Error("It is not currently possible to start verificationwith this method yet.");const{qrCodeData:t}=this.request;if(this.startEvent.getContent().secret!==t.encodedSharedSecret)throw(0,js.newKeyMismatchError)();await new Promise((i,s)=>{this.reciprocateQREvent={confirm:i,cancel:()=>s((0,js.newUserCancelledError)())},this.emit(wl.ShowReciprocateQr,this.reciprocateQREvent)});const r={};switch(t.mode){case nr.VerifyOtherUser:{const i=t.otherUserMasterKey;r[`ed25519:${i}`]=i;break}case nr.VerifySelfTrusted:{const i=this.request.targetDevice.deviceId;r[`ed25519:${i}`]=t.otherDeviceKey;break}case nr.VerifySelfUntrusted:{const i=t.myMasterKey;r[`ed25519:${i}`]=i;break}}await this.verifyKeys(this.userId,r,(i,s,o)=>{const c=r[i];if(!c)throw(0,js.newKeyMismatchError)();if(o!==c)throw Lg.logger.error("key ID from key info does not match"),(0,js.newKeyMismatchError)();for(const l in s.keys){if(!l.startsWith("ed25519"))continue;const u=r[l];if(!u)throw(0,js.newKeyMismatchError)();if(s.keys[l]!==u)throw Lg.logger.error("master key does not match"),(0,js.newKeyMismatchError)()}})})}static factory(e,t,r,i,s,o){return new pf(e,t,r,i,s,o)}static get NAME(){return"m.reciprocate.v1"}}or.ReciprocateQRCode=pf;const QC=2,ZC="MATRIX";var nr;(function(n){n[n.VerifyOtherUser=0]="VerifyOtherUser",n[n.VerifySelfTrusted=1]="VerifySelfTrusted",n[n.VerifySelfUntrusted=2]="VerifySelfUntrusted"})(nr||(nr={}));class Pi{constructor(e,t,r,i,s,o){this.mode=e,this.sharedSecret=t,this.otherUserMasterKey=r,this.otherDeviceKey=i,this.myMasterKey=s,this.buffer=o}static async create(e,t){const r=Pi.generateSharedSecret(),i=Pi.determineMode(e,t);let s=null,o=null,c=null;if(i===nr.VerifyOtherUser)s=t.getStoredCrossSigningForUser(e.otherUserId).getId("master");else if(i===nr.VerifySelfTrusted)o=await Pi.getOtherDeviceKey(e,t);else if(i===nr.VerifySelfUntrusted){const a=t.getUserId();c=t.getStoredCrossSigningForUser(a).getId("master")}const l=Pi.generateQrData(e,t,i,r,s,o,c),u=Pi.generateBuffer(l);return new Pi(i,r,s,o,c,u)}get encodedSharedSecret(){return this.sharedSecret}getBuffer(){return this.buffer}static generateSharedSecret(){const e=new Uint8Array(11);return j.crypto.getRandomValues(e),(0,Ng.encodeUnpaddedBase64)(e)}static async getOtherDeviceKey(e,t){const r=t.getUserId(),i=e.targetDevice,s=i?i.deviceId:null,o=t.getStoredDevice(r,s);if(!o)throw new Error("could not find device "+s);return o.getFingerprint()}static determineMode(e,t){const r=t.getUserId(),i=e.otherUserId;let s=nr.VerifyOtherUser;return r===i&&(t.checkUserTrust(r).isCrossSigningVerified()?s=nr.VerifySelfTrusted:s=nr.VerifySelfUntrusted),s}static generateQrData(e,t,r,i,s,o,c){const l=t.getUserId(),u=e.channel.transactionId,a={prefix:ZC,version:QC,mode:r,transactionId:u,firstKeyB64:"",secondKeyB64:"",secretB64:i},g=t.getStoredCrossSigningForUser(l);return r===nr.VerifyOtherUser?(a.firstKeyB64=g.getId("master"),a.secondKeyB64=s):r===nr.VerifySelfTrusted?(a.firstKeyB64=g.getId("master"),a.secondKeyB64=o):r===nr.VerifySelfUntrusted&&(a.firstKeyB64=t.getDeviceEd25519Key(),a.secondKeyB64=c),a}static generateBuffer(e){let t=Buffer.alloc(0);const r=c=>{const l=Buffer.from([c]);t=Buffer.concat([t,l])},i=c=>{const l=Buffer.alloc(2);l.writeInt16BE(c,0),t=Buffer.concat([t,l])},s=(c,l,u=!0)=>{const a=Buffer.from(c,l);u&&i(a.byteLength),t=Buffer.concat([t,a])},o=c=>{const l=(0,Ng.decodeBase64)(c),u=Buffer.from(l);t=Buffer.concat([t,u])};return s(e.prefix,"ascii",!1),r(e.version),r(e.mode),s(e.transactionId,"utf-8"),o(e.firstKeyB64),o(e.secondKeyB64),o(e.secretB64),t}}or.QRCodeData=Pi;var Es={},a_=V.exports;Object.defineProperty(Es,"__esModule",{value:!0});Es.SasEvent=Es.SAS=void 0;var ea=a_(Y.exports),Bg=a_(Vl),Qu=Qr,qn=Le,eP=ie;const Zu="m.key.verification.start",tP=["m.key.verification.accept","m.key.verification.key","m.key.verification.mac"];let Mc;const Kg=(0,qn.errorFactory)("m.mismatched_sas","Mismatched short authentication string"),rP=(0,qn.errorFactory)("m.mismatched_commitment","Mismatched commitment");function nP(n){return[(n[0]<<5|n[1]>>3)+1e3,((n[1]&7)<<10|n[2]<<2|n[3]>>6)+1e3,((n[3]&63)<<7|n[4]>>1)+1e3]}const iP=[["\u{1F436}","dog"],["\u{1F431}","cat"],["\u{1F981}","lion"],["\u{1F40E}","horse"],["\u{1F984}","unicorn"],["\u{1F437}","pig"],["\u{1F418}","elephant"],["\u{1F430}","rabbit"],["\u{1F43C}","panda"],["\u{1F413}","rooster"],["\u{1F427}","penguin"],["\u{1F422}","turtle"],["\u{1F41F}","fish"],["\u{1F419}","octopus"],["\u{1F98B}","butterfly"],["\u{1F337}","flower"],["\u{1F333}","tree"],["\u{1F335}","cactus"],["\u{1F344}","mushroom"],["\u{1F30F}","globe"],["\u{1F319}","moon"],["\u2601\uFE0F","cloud"],["\u{1F525}","fire"],["\u{1F34C}","banana"],["\u{1F34E}","apple"],["\u{1F353}","strawberry"],["\u{1F33D}","corn"],["\u{1F355}","pizza"],["\u{1F382}","cake"],["\u2764\uFE0F","heart"],["\u{1F642}","smiley"],["\u{1F916}","robot"],["\u{1F3A9}","hat"],["\u{1F453}","glasses"],["\u{1F527}","spanner"],["\u{1F385}","santa"],["\u{1F44D}","thumbs up"],["\u2602\uFE0F","umbrella"],["\u231B","hourglass"],["\u23F0","clock"],["\u{1F381}","gift"],["\u{1F4A1}","light bulb"],["\u{1F4D5}","book"],["\u270F\uFE0F","pencil"],["\u{1F4CE}","paperclip"],["\u2702\uFE0F","scissors"],["\u{1F512}","lock"],["\u{1F511}","key"],["\u{1F528}","hammer"],["\u260E\uFE0F","telephone"],["\u{1F3C1}","flag"],["\u{1F682}","train"],["\u{1F6B2}","bicycle"],["\u2708\uFE0F","aeroplane"],["\u{1F680}","rocket"],["\u{1F3C6}","trophy"],["\u26BD","ball"],["\u{1F3B8}","guitar"],["\u{1F3BA}","trumpet"],["\u{1F514}","bell"],["\u2693\uFE0F","anchor"],["\u{1F3A7}","headphones"],["\u{1F4C1}","folder"],["\u{1F4CC}","pin"]];function sP(n){return[n[0]>>2,(n[0]&3)<<4|n[1]>>4,(n[1]&15)<<2|n[2]>>6,n[2]&63,n[3]>>2,(n[3]&3)<<4|n[4]>>4,(n[4]&15)<<2|n[5]>>6].map(t=>iP[t])}const Sh={decimal:nP,emoji:sP};function Fg(n,e){const t={};for(const r of e)r in Sh&&(t[r]=Sh[r](n));return t}const oP={"hkdf-hmac-sha256":"calculate_mac","hmac-sha256":"calculate_mac_long_kdf"};function ta(n,e){return function(...t){const i=n[oP[e]].apply(n,t);return eP.logger.log("SAS calculateMAC:",e,t,i),i}}const qg={"curve25519-hkdf-sha256":function(n,e,t){const r=`${n.baseApis.getUserId()}|${n.baseApis.deviceId}|${n.ourSASPubKey}|`,i=`${n.userId}|${n.deviceId}|${n.theirSASPubKey}|`,s="MATRIX_KEY_VERIFICATION_SAS|"+(n.initiatedByMe?r+i:i+r)+n.channel.transactionId;return e.generate_bytes(s,t)},curve25519:function(n,e,t){const r=`${n.baseApis.getUserId()}${n.baseApis.deviceId}`,i=`${n.userId}${n.deviceId}`,s="MATRIX_KEY_VERIFICATION_SAS"+(n.initiatedByMe?r+i:i+r)+n.channel.transactionId;return e.generate_bytes(s,t)}},bh=["curve25519-hkdf-sha256","curve25519"],wh=["sha256"],Rh=["hkdf-hmac-sha256","hmac-sha256"],c_=Object.keys(Sh),aP=new Set(bh),cP=new Set(wh),lP=new Set(Rh),jg=new Set(c_);function ra(n,e){return n instanceof Array?n.filter(t=>e.has(t)):[]}let ja;Es.SasEvent=ja;(function(n){n.ShowSas="show_sas"})(ja||(Es.SasEvent=ja={}));class Rl extends Qu.VerificationBase{constructor(...e){super(...e);(0,ea.default)(this,"waitingForAccept",void 0),(0,ea.default)(this,"ourSASPubKey",void 0),(0,ea.default)(this,"theirSASPubKey",void 0),(0,ea.default)(this,"sasEvent",void 0),(0,ea.default)(this,"doVerification",async()=>{await j.Olm.init(),Mc=Mc||new j.Olm.Utility,await this.baseApis.downloadKeys([this.userId]);let t=!1;do try{return this.initiatedByMe?await this.doSendVerification():await this.doRespondVerification()}catch(r){if(r instanceof Qu.SwitchStartEventError)this.startEvent=r.startEvent,t=!0;else throw r}while(t)})}static get NAME(){return"m.sas.v1"}get events(){return tP}canSwitchStartEvent(e){if(e.getType()!==Zu)return!1;const t=e.getContent();return t&&t.method===Rl.NAME&&this.waitingForAccept}async sendStart(){const e=this.channel.completeContent(Zu,{method:Rl.NAME,from_device:this.baseApis.deviceId,key_agreement_protocols:bh,hashes:wh,message_authentication_codes:Rh,short_authentication_string:c_});return await this.channel.sendCompleted(Zu,e),e}async doSendVerification(){this.waitingForAccept=!0;let e;if(this.startEvent?e=this.channel.completedContentFromEvent(this.startEvent):e=await this.sendStart(),!this.initiatedByMe)throw new Qu.SwitchStartEventError(this.startEvent);let t;try{t=await this.waitForEvent("m.key.verification.accept")}finally{this.waitingForAccept=!1}let r=t.getContent();const i=ra(r.short_authentication_string,jg);if(!(aP.has(r.key_agreement_protocol)&&cP.has(r.hash)&&lP.has(r.message_authentication_code)&&i.length))throw(0,qn.newUnknownMethodError)();if(typeof r.commitment!="string")throw(0,qn.newInvalidMessageError)();const s=r.key_agreement_protocol,o=r.message_authentication_code,c=r.commitment,l=new j.Olm.SAS;try{this.ourSASPubKey=l.get_pubkey(),await this.send("m.key.verification.key",{key:this.ourSASPubKey}),t=await this.waitForEvent("m.key.verification.key"),r=t.getContent();const u=r.key+Bg.default.stringify(e);if(Mc.sha256(u)!==c)throw rP();this.theirSASPubKey=r.key,l.set_their_key(r.key);const a=qg[s](this,l,6),g=new Promise((m,p)=>{this.sasEvent={sas:Fg(a,i),confirm:async()=>{try{await this.sendMAC(l,o),m()}catch(E){p(E)}},cancel:()=>p((0,qn.newUserCancelledError)()),mismatch:()=>p(Kg())},this.emit(ja.ShowSas,this.sasEvent)});[t]=await Promise.all([this.waitForEvent("m.key.verification.mac").then(m=>(this.expectedEvent="m.key.verification.done",m)),g]),r=t.getContent(),await this.checkMAC(l,r,o)}finally{l.free()}}async doRespondVerification(){let e=this.channel.completedContentFromEvent(this.startEvent);const t=ra(bh,new Set(e.key_agreement_protocols))[0],r=ra(wh,new Set(e.hashes))[0],i=ra(Rh,new Set(e.message_authentication_codes))[0],s=ra(e.short_authentication_string,jg);if(!(t!==void 0&&r!==void 0&&i!==void 0&&s.length))throw(0,qn.newUnknownMethodError)();const o=new j.Olm.SAS;try{const c=o.get_pubkey()+Bg.default.stringify(e);await this.send("m.key.verification.accept",{key_agreement_protocol:t,hash:r,message_authentication_code:i,short_authentication_string:s,commitment:Mc.sha256(c)});let l=await this.waitForEvent("m.key.verification.key");e=l.getContent(),this.theirSASPubKey=e.key,o.set_their_key(e.key),this.ourSASPubKey=o.get_pubkey(),await this.send("m.key.verification.key",{key:this.ourSASPubKey});const u=qg[t](this,o,6),a=new Promise((g,m)=>{this.sasEvent={sas:Fg(u,s),confirm:async()=>{try{await this.sendMAC(o,i),g()}catch(p){m(p)}},cancel:()=>m((0,qn.newUserCancelledError)()),mismatch:()=>m(Kg())},this.emit(ja.ShowSas,this.sasEvent)});[l]=await Promise.all([this.waitForEvent("m.key.verification.mac").then(g=>(this.expectedEvent="m.key.verification.done",g)),a]),e=l.getContent(),await this.checkMAC(o,e,i)}finally{o.free()}}sendMAC(e,t){const r={},i=[],s="MATRIX_KEY_VERIFICATION_MAC"+this.baseApis.getUserId()+this.baseApis.deviceId+this.userId+this.deviceId+this.channel.transactionId,o=`ed25519:${this.baseApis.deviceId}`;r[o]=ta(e,t)(this.baseApis.getDeviceEd25519Key(),s+o),i.push(o);const c=this.baseApis.getCrossSigningId();if(c){const u=`ed25519:${c}`;r[u]=ta(e,t)(c,s+u),i.push(u)}const l=ta(e,t)(i.sort().join(","),s+"KEY_IDS");return this.send("m.key.verification.mac",{mac:r,keys:l})}async checkMAC(e,t,r){const i="MATRIX_KEY_VERIFICATION_MAC"+this.userId+this.deviceId+this.baseApis.getUserId()+this.baseApis.deviceId+this.channel.transactionId;if(t.keys!==ta(e,r)(Object.keys(t.mac).sort().join(","),i+"KEY_IDS"))throw(0,qn.newKeyMismatchError)();await this.verifyKeys(this.userId,t.mac,(s,o,c)=>{if(c!==ta(e,r)(o.keys[s],i+s))throw(0,qn.newKeyMismatchError)()})}}Es.SAS=Rl;var Ms={};Object.defineProperty(Ms,"__esModule",{value:!0});Ms.deriveKey=mf;Ms.keyFromAuthData=fP;Ms.keyFromPassphrase=pP;var uP=oi,dP=G;const hP=typeof window!="undefined"&&window.crypto?window.crypto.subtle||window.crypto.webkitSubtle:null,Vg=5e5,gf=256;async function fP(n,e){if(!j.Olm)throw new Error("Olm is not available");if(!n.private_key_salt||!n.private_key_iterations)throw new Error("Salt and/or iterations not found: this backup cannot be restored with a passphrase");return await mf(e,n.private_key_salt,n.private_key_iterations,n.private_key_bits||gf)}async function pP(n){if(!j.Olm)throw new Error("Olm is not available");const e=(0,uP.randomString)(32);return{key:await mf(n,e,Vg,gf),salt:e,iterations:Vg}}async function mf(n,e,t,r=gf){return hP?gP(n,e,t,r):mP(n,e,t,r)}async function gP(n,e,t,r){const i=j.crypto.subtle,s=j.TextEncoder;if(!i||!s)throw new Error("Password-based backup is not avaiable on this platform");const o=await i.importKey("raw",new s().encode(n),{name:"PBKDF2"},!1,["deriveBits"]),c=await i.deriveBits({name:"PBKDF2",salt:new s().encode(e),iterations:t,hash:"SHA-512"},o,r);return new Uint8Array(c)}async function mP(n,e,t,r){const i=(0,dP.getCrypto)();if(!i)throw new Error("No usable crypto implementation");return i.pbkdf2Sync(n,Buffer.from(e,"binary"),t,r,"sha512")}var Bo={},Ih={exports:{}},l_={},Jl={};Jl.byteLength=_P;Jl.toByteArray=SP;Jl.fromByteArray=RP;var bn=[],Ur=[],yP=typeof Uint8Array!="undefined"?Uint8Array:Array,ed="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var Vs=0,vP=ed.length;Vs<vP;++Vs)bn[Vs]=ed[Vs],Ur[ed.charCodeAt(Vs)]=Vs;Ur["-".charCodeAt(0)]=62;Ur["_".charCodeAt(0)]=63;function u_(n){var e=n.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=n.indexOf("=");t===-1&&(t=e);var r=t===e?0:4-t%4;return[t,r]}function _P(n){var e=u_(n),t=e[0],r=e[1];return(t+r)*3/4-r}function EP(n,e,t){return(e+t)*3/4-t}function SP(n){var e,t=u_(n),r=t[0],i=t[1],s=new yP(EP(n,r,i)),o=0,c=i>0?r-4:r,l;for(l=0;l<c;l+=4)e=Ur[n.charCodeAt(l)]<<18|Ur[n.charCodeAt(l+1)]<<12|Ur[n.charCodeAt(l+2)]<<6|Ur[n.charCodeAt(l+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=Ur[n.charCodeAt(l)]<<2|Ur[n.charCodeAt(l+1)]>>4,s[o++]=e&255),i===1&&(e=Ur[n.charCodeAt(l)]<<10|Ur[n.charCodeAt(l+1)]<<4|Ur[n.charCodeAt(l+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function bP(n){return bn[n>>18&63]+bn[n>>12&63]+bn[n>>6&63]+bn[n&63]}function wP(n,e,t){for(var r,i=[],s=e;s<t;s+=3)r=(n[s]<<16&16711680)+(n[s+1]<<8&65280)+(n[s+2]&255),i.push(bP(r));return i.join("")}function RP(n){for(var e,t=n.length,r=t%3,i=[],s=16383,o=0,c=t-r;o<c;o+=s)i.push(wP(n,o,o+s>c?c:o+s));return r===1?(e=n[t-1],i.push(bn[e>>2]+bn[e<<4&63]+"==")):r===2&&(e=(n[t-2]<<8)+n[t-1],i.push(bn[e>>10]+bn[e>>4&63]+bn[e<<2&63]+"=")),i.join("")}var yf={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */yf.read=function(n,e,t,r,i){var s,o,c=i*8-r-1,l=(1<<c)-1,u=l>>1,a=-7,g=t?i-1:0,m=t?-1:1,p=n[e+g];for(g+=m,s=p&(1<<-a)-1,p>>=-a,a+=c;a>0;s=s*256+n[e+g],g+=m,a-=8);for(o=s&(1<<-a)-1,s>>=-a,a+=r;a>0;o=o*256+n[e+g],g+=m,a-=8);if(s===0)s=1-u;else{if(s===l)return o?NaN:(p?-1:1)*(1/0);o=o+Math.pow(2,r),s=s-u}return(p?-1:1)*o*Math.pow(2,s-r)};yf.write=function(n,e,t,r,i,s){var o,c,l,u=s*8-i-1,a=(1<<u)-1,g=a>>1,m=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:s-1,E=r?1:-1,I=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(c=isNaN(e)?1:0,o=a):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),o+g>=1?e+=m/l:e+=m*Math.pow(2,1-g),e*l>=2&&(o++,l/=2),o+g>=a?(c=0,o=a):o+g>=1?(c=(e*l-1)*Math.pow(2,i),o=o+g):(c=e*Math.pow(2,g-1)*Math.pow(2,i),o=0));i>=8;n[t+p]=c&255,p+=E,c/=256,i-=8);for(o=o<<i|c,u+=i;u>0;n[t+p]=o&255,p+=E,o/=256,u-=8);n[t+p-E]|=I*128};/*!
- * The buffer module from node.js, for the browser.
- *
- * @author Feross Aboukhadijeh <https://feross.org>
- * @license MIT
- */(function(n){const e=Jl,t=yf,r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=c,n.SlowBuffer=P,n.INSPECT_MAX_BYTES=50;const i=2147483647;n.kMaxLength=i,c.TYPED_ARRAY_SUPPORT=s(),!c.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function s(){try{const v=new Uint8Array(1),d={foo:function(){return 42}};return Object.setPrototypeOf(d,Uint8Array.prototype),Object.setPrototypeOf(v,d),v.foo()===42}catch{return!1}}Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(!!c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(!!c.isBuffer(this))return this.byteOffset}});function o(v){if(v>i)throw new RangeError('The value "'+v+'" is invalid for option "size"');const d=new Uint8Array(v);return Object.setPrototypeOf(d,c.prototype),d}function c(v,d,h){if(typeof v=="number"){if(typeof d=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return g(v)}return l(v,d,h)}c.poolSize=8192;function l(v,d,h){if(typeof v=="string")return m(v,d);if(ArrayBuffer.isView(v))return E(v);if(v==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof v);if(Gt(v,ArrayBuffer)||v&&Gt(v.buffer,ArrayBuffer)||typeof SharedArrayBuffer!="undefined"&&(Gt(v,SharedArrayBuffer)||v&&Gt(v.buffer,SharedArrayBuffer)))return I(v,d,h);if(typeof v=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const b=v.valueOf&&v.valueOf();if(b!=null&&b!==v)return c.from(b,d,h);const C=w(v);if(C)return C;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof v[Symbol.toPrimitive]=="function")return c.from(v[Symbol.toPrimitive]("string"),d,h);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof v)}c.from=function(v,d,h){return l(v,d,h)},Object.setPrototypeOf(c.prototype,Uint8Array.prototype),Object.setPrototypeOf(c,Uint8Array);function u(v){if(typeof v!="number")throw new TypeError('"size" argument must be of type number');if(v<0)throw new RangeError('The value "'+v+'" is invalid for option "size"')}function a(v,d,h){return u(v),v<=0?o(v):d!==void 0?typeof h=="string"?o(v).fill(d,h):o(v).fill(d):o(v)}c.alloc=function(v,d,h){return a(v,d,h)};function g(v){return u(v),o(v<0?0:k(v)|0)}c.allocUnsafe=function(v){return g(v)},c.allocUnsafeSlow=function(v){return g(v)};function m(v,d){if((typeof d!="string"||d==="")&&(d="utf8"),!c.isEncoding(d))throw new TypeError("Unknown encoding: "+d);const h=S(v,d)|0;let b=o(h);const C=b.write(v,d);return C!==h&&(b=b.slice(0,C)),b}function p(v){const d=v.length<0?0:k(v.length)|0,h=o(d);for(let b=0;b<d;b+=1)h[b]=v[b]&255;return h}function E(v){if(Gt(v,Uint8Array)){const d=new Uint8Array(v);return I(d.buffer,d.byteOffset,d.byteLength)}return p(v)}function I(v,d,h){if(d<0||v.byteLength<d)throw new RangeError('"offset" is outside of buffer bounds');if(v.byteLength<d+(h||0))throw new RangeError('"length" is outside of buffer bounds');let b;return d===void 0&&h===void 0?b=new Uint8Array(v):h===void 0?b=new Uint8Array(v,d):b=new Uint8Array(v,d,h),Object.setPrototypeOf(b,c.prototype),b}function w(v){if(c.isBuffer(v)){const d=k(v.length)|0,h=o(d);return h.length===0||v.copy(h,0,0,d),h}if(v.length!==void 0)return typeof v.length!="number"||Fo(v.length)?o(0):p(v);if(v.type==="Buffer"&&Array.isArray(v.data))return p(v.data)}function k(v){if(v>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return v|0}function P(v){return+v!=v&&(v=0),c.alloc(+v)}c.isBuffer=function(d){return d!=null&&d._isBuffer===!0&&d!==c.prototype},c.compare=function(d,h){if(Gt(d,Uint8Array)&&(d=c.from(d,d.offset,d.byteLength)),Gt(h,Uint8Array)&&(h=c.from(h,h.offset,h.byteLength)),!c.isBuffer(d)||!c.isBuffer(h))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(d===h)return 0;let b=d.length,C=h.length;for(let A=0,$=Math.min(b,C);A<$;++A)if(d[A]!==h[A]){b=d[A],C=h[A];break}return b<C?-1:C<b?1:0},c.isEncoding=function(d){switch(String(d).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(d,h){if(!Array.isArray(d))throw new TypeError('"list" argument must be an Array of Buffers');if(d.length===0)return c.alloc(0);let b;if(h===void 0)for(h=0,b=0;b<d.length;++b)h+=d[b].length;const C=c.allocUnsafe(h);let A=0;for(b=0;b<d.length;++b){let $=d[b];if(Gt($,Uint8Array))A+$.length>C.length?(c.isBuffer($)||($=c.from($)),$.copy(C,A)):Uint8Array.prototype.set.call(C,$,A);else if(c.isBuffer($))$.copy(C,A);else throw new TypeError('"list" argument must be an Array of Buffers');A+=$.length}return C};function S(v,d){if(c.isBuffer(v))return v.length;if(ArrayBuffer.isView(v)||Gt(v,ArrayBuffer))return v.byteLength;if(typeof v!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof v);const h=v.length,b=arguments.length>2&&arguments[2]===!0;if(!b&&h===0)return 0;let C=!1;for(;;)switch(d){case"ascii":case"latin1":case"binary":return h;case"utf8":case"utf-8":return Ds(v).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return h*2;case"hex":return h>>>1;case"base64":return Mn(v).length;default:if(C)return b?-1:Ds(v).length;d=(""+d).toLowerCase(),C=!0}}c.byteLength=S;function T(v,d,h){let b=!1;if((d===void 0||d<0)&&(d=0),d>this.length||((h===void 0||h>this.length)&&(h=this.length),h<=0)||(h>>>=0,d>>>=0,h<=d))return"";for(v||(v="utf8");;)switch(v){case"hex":return Fr(this,d,h);case"utf8":case"utf-8":return ut(this,d,h);case"ascii":return Q(this,d,h);case"latin1":case"binary":return sn(this,d,h);case"base64":return De(this,d,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ui(this,d,h);default:if(b)throw new TypeError("Unknown encoding: "+v);v=(v+"").toLowerCase(),b=!0}}c.prototype._isBuffer=!0;function D(v,d,h){const b=v[d];v[d]=v[h],v[h]=b}c.prototype.swap16=function(){const d=this.length;if(d%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let h=0;h<d;h+=2)D(this,h,h+1);return this},c.prototype.swap32=function(){const d=this.length;if(d%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let h=0;h<d;h+=4)D(this,h,h+3),D(this,h+1,h+2);return this},c.prototype.swap64=function(){const d=this.length;if(d%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let h=0;h<d;h+=8)D(this,h,h+7),D(this,h+1,h+6),D(this,h+2,h+5),D(this,h+3,h+4);return this},c.prototype.toString=function(){const d=this.length;return d===0?"":arguments.length===0?ut(this,0,d):T.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,c.prototype.equals=function(d){if(!c.isBuffer(d))throw new TypeError("Argument must be a Buffer");return this===d?!0:c.compare(this,d)===0},c.prototype.inspect=function(){let d="";const h=n.INSPECT_MAX_BYTES;return d=this.toString("hex",0,h).replace(/(.{2})/g,"$1 ").trim(),this.length>h&&(d+=" ... "),"<Buffer "+d+">"},r&&(c.prototype[r]=c.prototype.inspect),c.prototype.compare=function(d,h,b,C,A){if(Gt(d,Uint8Array)&&(d=c.from(d,d.offset,d.byteLength)),!c.isBuffer(d))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof d);if(h===void 0&&(h=0),b===void 0&&(b=d?d.length:0),C===void 0&&(C=0),A===void 0&&(A=this.length),h<0||b>d.length||C<0||A>this.length)throw new RangeError("out of range index");if(C>=A&&h>=b)return 0;if(C>=A)return-1;if(h>=b)return 1;if(h>>>=0,b>>>=0,C>>>=0,A>>>=0,this===d)return 0;let $=A-C,re=b-h;const we=Math.min($,re),de=this.slice(C,A),Ie=d.slice(h,b);for(let ye=0;ye<we;++ye)if(de[ye]!==Ie[ye]){$=de[ye],re=Ie[ye];break}return $<re?-1:re<$?1:0};function R(v,d,h,b,C){if(v.length===0)return-1;if(typeof h=="string"?(b=h,h=0):h>2147483647?h=2147483647:h<-2147483648&&(h=-2147483648),h=+h,Fo(h)&&(h=C?0:v.length-1),h<0&&(h=v.length+h),h>=v.length){if(C)return-1;h=v.length-1}else if(h<0)if(C)h=0;else return-1;if(typeof d=="string"&&(d=c.from(d,b)),c.isBuffer(d))return d.length===0?-1:L(v,d,h,b,C);if(typeof d=="number")return d=d&255,typeof Uint8Array.prototype.indexOf=="function"?C?Uint8Array.prototype.indexOf.call(v,d,h):Uint8Array.prototype.lastIndexOf.call(v,d,h):L(v,[d],h,b,C);throw new TypeError("val must be string, number or Buffer")}function L(v,d,h,b,C){let A=1,$=v.length,re=d.length;if(b!==void 0&&(b=String(b).toLowerCase(),b==="ucs2"||b==="ucs-2"||b==="utf16le"||b==="utf-16le")){if(v.length<2||d.length<2)return-1;A=2,$/=2,re/=2,h/=2}function we(Ie,ye){return A===1?Ie[ye]:Ie.readUInt16BE(ye*A)}let de;if(C){let Ie=-1;for(de=h;de<$;de++)if(we(v,de)===we(d,Ie===-1?0:de-Ie)){if(Ie===-1&&(Ie=de),de-Ie+1===re)return Ie*A}else Ie!==-1&&(de-=de-Ie),Ie=-1}else for(h+re>$&&(h=$-re),de=h;de>=0;de--){let Ie=!0;for(let ye=0;ye<re;ye++)if(we(v,de+ye)!==we(d,ye)){Ie=!1;break}if(Ie)return de}return-1}c.prototype.includes=function(d,h,b){return this.indexOf(d,h,b)!==-1},c.prototype.indexOf=function(d,h,b){return R(this,d,h,b,!0)},c.prototype.lastIndexOf=function(d,h,b){return R(this,d,h,b,!1)};function H(v,d,h,b){h=Number(h)||0;const C=v.length-h;b?(b=Number(b),b>C&&(b=C)):b=C;const A=d.length;b>A/2&&(b=A/2);let $;for($=0;$<b;++$){const re=parseInt(d.substr($*2,2),16);if(Fo(re))return $;v[h+$]=re}return $}function F(v,d,h,b){return pi(Ds(d,v.length-h),v,h,b)}function le(v,d,h,b){return pi(oc(d),v,h,b)}function Je(v,d,h,b){return pi(Mn(d),v,h,b)}function Ke(v,d,h,b){return pi(ou(d,v.length-h),v,h,b)}c.prototype.write=function(d,h,b,C){if(h===void 0)C="utf8",b=this.length,h=0;else if(b===void 0&&typeof h=="string")C=h,b=this.length,h=0;else if(isFinite(h))h=h>>>0,isFinite(b)?(b=b>>>0,C===void 0&&(C="utf8")):(C=b,b=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const A=this.length-h;if((b===void 0||b>A)&&(b=A),d.length>0&&(b<0||h<0)||h>this.length)throw new RangeError("Attempt to write outside buffer bounds");C||(C="utf8");let $=!1;for(;;)switch(C){case"hex":return H(this,d,h,b);case"utf8":case"utf-8":return F(this,d,h,b);case"ascii":case"latin1":case"binary":return le(this,d,h,b);case"base64":return Je(this,d,h,b);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ke(this,d,h,b);default:if($)throw new TypeError("Unknown encoding: "+C);C=(""+C).toLowerCase(),$=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function De(v,d,h){return d===0&&h===v.length?e.fromByteArray(v):e.fromByteArray(v.slice(d,h))}function ut(v,d,h){h=Math.min(v.length,h);const b=[];let C=d;for(;C<h;){const A=v[C];let $=null,re=A>239?4:A>223?3:A>191?2:1;if(C+re<=h){let we,de,Ie,ye;switch(re){case 1:A<128&&($=A);break;case 2:we=v[C+1],(we&192)===128&&(ye=(A&31)<<6|we&63,ye>127&&($=ye));break;case 3:we=v[C+1],de=v[C+2],(we&192)===128&&(de&192)===128&&(ye=(A&15)<<12|(we&63)<<6|de&63,ye>2047&&(ye<55296||ye>57343)&&($=ye));break;case 4:we=v[C+1],de=v[C+2],Ie=v[C+3],(we&192)===128&&(de&192)===128&&(Ie&192)===128&&(ye=(A&15)<<18|(we&63)<<12|(de&63)<<6|Ie&63,ye>65535&&ye<1114112&&($=ye))}}$===null?($=65533,re=1):$>65535&&($-=65536,b.push($>>>10&1023|55296),$=56320|$&1023),b.push($),C+=re}return jt(b)}const ur=4096;function jt(v){const d=v.length;if(d<=ur)return String.fromCharCode.apply(String,v);let h="",b=0;for(;b<d;)h+=String.fromCharCode.apply(String,v.slice(b,b+=ur));return h}function Q(v,d,h){let b="";h=Math.min(v.length,h);for(let C=d;C<h;++C)b+=String.fromCharCode(v[C]&127);return b}function sn(v,d,h){let b="";h=Math.min(v.length,h);for(let C=d;C<h;++C)b+=String.fromCharCode(v[C]);return b}function Fr(v,d,h){const b=v.length;(!d||d<0)&&(d=0),(!h||h<0||h>b)&&(h=b);let C="";for(let A=d;A<h;++A)C+=ac[v[A]];return C}function ui(v,d,h){const b=v.slice(d,h);let C="";for(let A=0;A<b.length-1;A+=2)C+=String.fromCharCode(b[A]+b[A+1]*256);return C}c.prototype.slice=function(d,h){const b=this.length;d=~~d,h=h===void 0?b:~~h,d<0?(d+=b,d<0&&(d=0)):d>b&&(d=b),h<0?(h+=b,h<0&&(h=0)):h>b&&(h=b),h<d&&(h=d);const C=this.subarray(d,h);return Object.setPrototypeOf(C,c.prototype),C};function be(v,d,h){if(v%1!==0||v<0)throw new RangeError("offset is not uint");if(v+d>h)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUintLE=c.prototype.readUIntLE=function(d,h,b){d=d>>>0,h=h>>>0,b||be(d,h,this.length);let C=this[d],A=1,$=0;for(;++$<h&&(A*=256);)C+=this[d+$]*A;return C},c.prototype.readUintBE=c.prototype.readUIntBE=function(d,h,b){d=d>>>0,h=h>>>0,b||be(d,h,this.length);let C=this[d+--h],A=1;for(;h>0&&(A*=256);)C+=this[d+--h]*A;return C},c.prototype.readUint8=c.prototype.readUInt8=function(d,h){return d=d>>>0,h||be(d,1,this.length),this[d]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(d,h){return d=d>>>0,h||be(d,2,this.length),this[d]|this[d+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(d,h){return d=d>>>0,h||be(d,2,this.length),this[d]<<8|this[d+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(d,h){return d=d>>>0,h||be(d,4,this.length),(this[d]|this[d+1]<<8|this[d+2]<<16)+this[d+3]*16777216},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(d,h){return d=d>>>0,h||be(d,4,this.length),this[d]*16777216+(this[d+1]<<16|this[d+2]<<8|this[d+3])},c.prototype.readBigUInt64LE=jr(function(d){d=d>>>0,st(d,"offset");const h=this[d],b=this[d+7];(h===void 0||b===void 0)&&ot(d,this.length-8);const C=h+this[++d]*2**8+this[++d]*2**16+this[++d]*2**24,A=this[++d]+this[++d]*2**8+this[++d]*2**16+b*2**24;return BigInt(C)+(BigInt(A)<<BigInt(32))}),c.prototype.readBigUInt64BE=jr(function(d){d=d>>>0,st(d,"offset");const h=this[d],b=this[d+7];(h===void 0||b===void 0)&&ot(d,this.length-8);const C=h*2**24+this[++d]*2**16+this[++d]*2**8+this[++d],A=this[++d]*2**24+this[++d]*2**16+this[++d]*2**8+b;return(BigInt(C)<<BigInt(32))+BigInt(A)}),c.prototype.readIntLE=function(d,h,b){d=d>>>0,h=h>>>0,b||be(d,h,this.length);let C=this[d],A=1,$=0;for(;++$<h&&(A*=256);)C+=this[d+$]*A;return A*=128,C>=A&&(C-=Math.pow(2,8*h)),C},c.prototype.readIntBE=function(d,h,b){d=d>>>0,h=h>>>0,b||be(d,h,this.length);let C=h,A=1,$=this[d+--C];for(;C>0&&(A*=256);)$+=this[d+--C]*A;return A*=128,$>=A&&($-=Math.pow(2,8*h)),$},c.prototype.readInt8=function(d,h){return d=d>>>0,h||be(d,1,this.length),this[d]&128?(255-this[d]+1)*-1:this[d]},c.prototype.readInt16LE=function(d,h){d=d>>>0,h||be(d,2,this.length);const b=this[d]|this[d+1]<<8;return b&32768?b|4294901760:b},c.prototype.readInt16BE=function(d,h){d=d>>>0,h||be(d,2,this.length);const b=this[d+1]|this[d]<<8;return b&32768?b|4294901760:b},c.prototype.readInt32LE=function(d,h){return d=d>>>0,h||be(d,4,this.length),this[d]|this[d+1]<<8|this[d+2]<<16|this[d+3]<<24},c.prototype.readInt32BE=function(d,h){return d=d>>>0,h||be(d,4,this.length),this[d]<<24|this[d+1]<<16|this[d+2]<<8|this[d+3]},c.prototype.readBigInt64LE=jr(function(d){d=d>>>0,st(d,"offset");const h=this[d],b=this[d+7];(h===void 0||b===void 0)&&ot(d,this.length-8);const C=this[d+4]+this[d+5]*2**8+this[d+6]*2**16+(b<<24);return(BigInt(C)<<BigInt(32))+BigInt(h+this[++d]*2**8+this[++d]*2**16+this[++d]*2**24)}),c.prototype.readBigInt64BE=jr(function(d){d=d>>>0,st(d,"offset");const h=this[d],b=this[d+7];(h===void 0||b===void 0)&&ot(d,this.length-8);const C=(h<<24)+this[++d]*2**16+this[++d]*2**8+this[++d];return(BigInt(C)<<BigInt(32))+BigInt(this[++d]*2**24+this[++d]*2**16+this[++d]*2**8+b)}),c.prototype.readFloatLE=function(d,h){return d=d>>>0,h||be(d,4,this.length),t.read(this,d,!0,23,4)},c.prototype.readFloatBE=function(d,h){return d=d>>>0,h||be(d,4,this.length),t.read(this,d,!1,23,4)},c.prototype.readDoubleLE=function(d,h){return d=d>>>0,h||be(d,8,this.length),t.read(this,d,!0,52,8)},c.prototype.readDoubleBE=function(d,h){return d=d>>>0,h||be(d,8,this.length),t.read(this,d,!1,52,8)};function Ue(v,d,h,b,C,A){if(!c.isBuffer(v))throw new TypeError('"buffer" argument must be a Buffer instance');if(d>C||d<A)throw new RangeError('"value" argument is out of bounds');if(h+b>v.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(d,h,b,C){if(d=+d,h=h>>>0,b=b>>>0,!C){const re=Math.pow(2,8*b)-1;Ue(this,d,h,b,re,0)}let A=1,$=0;for(this[h]=d&255;++$<b&&(A*=256);)this[h+$]=d/A&255;return h+b},c.prototype.writeUintBE=c.prototype.writeUIntBE=function(d,h,b,C){if(d=+d,h=h>>>0,b=b>>>0,!C){const re=Math.pow(2,8*b)-1;Ue(this,d,h,b,re,0)}let A=b-1,$=1;for(this[h+A]=d&255;--A>=0&&($*=256);)this[h+A]=d/$&255;return h+b},c.prototype.writeUint8=c.prototype.writeUInt8=function(d,h,b){return d=+d,h=h>>>0,b||Ue(this,d,h,1,255,0),this[h]=d&255,h+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(d,h,b){return d=+d,h=h>>>0,b||Ue(this,d,h,2,65535,0),this[h]=d&255,this[h+1]=d>>>8,h+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(d,h,b){return d=+d,h=h>>>0,b||Ue(this,d,h,2,65535,0),this[h]=d>>>8,this[h+1]=d&255,h+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(d,h,b){return d=+d,h=h>>>0,b||Ue(this,d,h,4,4294967295,0),this[h+3]=d>>>24,this[h+2]=d>>>16,this[h+1]=d>>>8,this[h]=d&255,h+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(d,h,b){return d=+d,h=h>>>0,b||Ue(this,d,h,4,4294967295,0),this[h]=d>>>24,this[h+1]=d>>>16,this[h+2]=d>>>8,this[h+3]=d&255,h+4};function di(v,d,h,b,C){wr(d,b,C,v,h,7);let A=Number(d&BigInt(4294967295));v[h++]=A,A=A>>8,v[h++]=A,A=A>>8,v[h++]=A,A=A>>8,v[h++]=A;let $=Number(d>>BigInt(32)&BigInt(4294967295));return v[h++]=$,$=$>>8,v[h++]=$,$=$>>8,v[h++]=$,$=$>>8,v[h++]=$,h}function qr(v,d,h,b,C){wr(d,b,C,v,h,7);let A=Number(d&BigInt(4294967295));v[h+7]=A,A=A>>8,v[h+6]=A,A=A>>8,v[h+5]=A,A=A>>8,v[h+4]=A;let $=Number(d>>BigInt(32)&BigInt(4294967295));return v[h+3]=$,$=$>>8,v[h+2]=$,$=$>>8,v[h+1]=$,$=$>>8,v[h]=$,h+8}c.prototype.writeBigUInt64LE=jr(function(d,h=0){return di(this,d,h,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeBigUInt64BE=jr(function(d,h=0){return qr(this,d,h,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeIntLE=function(d,h,b,C){if(d=+d,h=h>>>0,!C){const we=Math.pow(2,8*b-1);Ue(this,d,h,b,we-1,-we)}let A=0,$=1,re=0;for(this[h]=d&255;++A<b&&($*=256);)d<0&&re===0&&this[h+A-1]!==0&&(re=1),this[h+A]=(d/$>>0)-re&255;return h+b},c.prototype.writeIntBE=function(d,h,b,C){if(d=+d,h=h>>>0,!C){const we=Math.pow(2,8*b-1);Ue(this,d,h,b,we-1,-we)}let A=b-1,$=1,re=0;for(this[h+A]=d&255;--A>=0&&($*=256);)d<0&&re===0&&this[h+A+1]!==0&&(re=1),this[h+A]=(d/$>>0)-re&255;return h+b},c.prototype.writeInt8=function(d,h,b){return d=+d,h=h>>>0,b||Ue(this,d,h,1,127,-128),d<0&&(d=255+d+1),this[h]=d&255,h+1},c.prototype.writeInt16LE=function(d,h,b){return d=+d,h=h>>>0,b||Ue(this,d,h,2,32767,-32768),this[h]=d&255,this[h+1]=d>>>8,h+2},c.prototype.writeInt16BE=function(d,h,b){return d=+d,h=h>>>0,b||Ue(this,d,h,2,32767,-32768),this[h]=d>>>8,this[h+1]=d&255,h+2},c.prototype.writeInt32LE=function(d,h,b){return d=+d,h=h>>>0,b||Ue(this,d,h,4,2147483647,-2147483648),this[h]=d&255,this[h+1]=d>>>8,this[h+2]=d>>>16,this[h+3]=d>>>24,h+4},c.prototype.writeInt32BE=function(d,h,b){return d=+d,h=h>>>0,b||Ue(this,d,h,4,2147483647,-2147483648),d<0&&(d=4294967295+d+1),this[h]=d>>>24,this[h+1]=d>>>16,this[h+2]=d>>>8,this[h+3]=d&255,h+4},c.prototype.writeBigInt64LE=jr(function(d,h=0){return di(this,d,h,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),c.prototype.writeBigInt64BE=jr(function(d,h=0){return qr(this,d,h,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Pn(v,d,h,b,C,A){if(h+b>v.length)throw new RangeError("Index out of range");if(h<0)throw new RangeError("Index out of range")}function hi(v,d,h,b,C){return d=+d,h=h>>>0,C||Pn(v,d,h,4),t.write(v,d,h,b,23,4),h+4}c.prototype.writeFloatLE=function(d,h,b){return hi(this,d,h,!0,b)},c.prototype.writeFloatBE=function(d,h,b){return hi(this,d,h,!1,b)};function fi(v,d,h,b,C){return d=+d,h=h>>>0,C||Pn(v,d,h,8),t.write(v,d,h,b,52,8),h+8}c.prototype.writeDoubleLE=function(d,h,b){return fi(this,d,h,!0,b)},c.prototype.writeDoubleBE=function(d,h,b){return fi(this,d,h,!1,b)},c.prototype.copy=function(d,h,b,C){if(!c.isBuffer(d))throw new TypeError("argument should be a Buffer");if(b||(b=0),!C&&C!==0&&(C=this.length),h>=d.length&&(h=d.length),h||(h=0),C>0&&C<b&&(C=b),C===b||d.length===0||this.length===0)return 0;if(h<0)throw new RangeError("targetStart out of bounds");if(b<0||b>=this.length)throw new RangeError("Index out of range");if(C<0)throw new RangeError("sourceEnd out of bounds");C>this.length&&(C=this.length),d.length-h<C-b&&(C=d.length-h+b);const A=C-b;return this===d&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(h,b,C):Uint8Array.prototype.set.call(d,this.subarray(b,C),h),A},c.prototype.fill=function(d,h,b,C){if(typeof d=="string"){if(typeof h=="string"?(C=h,h=0,b=this.length):typeof b=="string"&&(C=b,b=this.length),C!==void 0&&typeof C!="string")throw new TypeError("encoding must be a string");if(typeof C=="string"&&!c.isEncoding(C))throw new TypeError("Unknown encoding: "+C);if(d.length===1){const $=d.charCodeAt(0);(C==="utf8"&&$<128||C==="latin1")&&(d=$)}}else typeof d=="number"?d=d&255:typeof d=="boolean"&&(d=Number(d));if(h<0||this.length<h||this.length<b)throw new RangeError("Out of range index");if(b<=h)return this;h=h>>>0,b=b===void 0?this.length:b>>>0,d||(d=0);let A;if(typeof d=="number")for(A=h;A<b;++A)this[A]=d;else{const $=c.isBuffer(d)?d:c.from(d,C),re=$.length;if(re===0)throw new TypeError('The value "'+d+'" is invalid for argument "value"');for(A=0;A<b-h;++A)this[A+h]=$[A%re]}return this};const _={};function dr(v,d,h){_[v]=class extends h{constructor(){super();Object.defineProperty(this,"message",{value:d.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${v}]`,this.stack,delete this.name}get code(){return v}set code(C){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:C,writable:!0})}toString(){return`${this.name} [${v}]: ${this.message}`}}}dr("ERR_BUFFER_OUT_OF_BOUNDS",function(v){return v?`${v} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),dr("ERR_INVALID_ARG_TYPE",function(v,d){return`The "${v}" argument must be of type number. Received type ${typeof d}`},TypeError),dr("ERR_OUT_OF_RANGE",function(v,d,h){let b=`The value of "${v}" is out of range.`,C=h;return Number.isInteger(h)&&Math.abs(h)>2**32?C=Mt(String(h)):typeof h=="bigint"&&(C=String(h),(h>BigInt(2)**BigInt(32)||h<-(BigInt(2)**BigInt(32)))&&(C=Mt(C)),C+="n"),b+=` It must be ${d}. Received ${C}`,b},RangeError);function Mt(v){let d="",h=v.length;const b=v[0]==="-"?1:0;for(;h>=b+4;h-=3)d=`_${v.slice(h-3,h)}${d}`;return`${v.slice(0,h)}${d}`}function hr(v,d,h){st(d,"offset"),(v[d]===void 0||v[d+h]===void 0)&&ot(d,v.length-(h+1))}function wr(v,d,h,b,C,A){if(v>h||v<d){const $=typeof d=="bigint"?"n":"";let re;throw A>3?d===0||d===BigInt(0)?re=`>= 0${$} and < 2${$} ** ${(A+1)*8}${$}`:re=`>= -(2${$} ** ${(A+1)*8-1}${$}) and < 2 ** ${(A+1)*8-1}${$}`:re=`>= ${d}${$} and <= ${h}${$}`,new _.ERR_OUT_OF_RANGE("value",re,v)}hr(b,C,A)}function st(v,d){if(typeof v!="number")throw new _.ERR_INVALID_ARG_TYPE(d,"number",v)}function ot(v,d,h){throw Math.floor(v)!==v?(st(v,h),new _.ERR_OUT_OF_RANGE(h||"offset","an integer",v)):d<0?new _.ERR_BUFFER_OUT_OF_BOUNDS:new _.ERR_OUT_OF_RANGE(h||"offset",`>= ${h?1:0} and <= ${d}`,v)}const sc=/[^+/0-9A-Za-z-_]/g;function Vt(v){if(v=v.split("=")[0],v=v.trim().replace(sc,""),v.length<2)return"";for(;v.length%4!==0;)v=v+"=";return v}function Ds(v,d){d=d||1/0;let h;const b=v.length;let C=null;const A=[];for(let $=0;$<b;++$){if(h=v.charCodeAt($),h>55295&&h<57344){if(!C){if(h>56319){(d-=3)>-1&&A.push(239,191,189);continue}else if($+1===b){(d-=3)>-1&&A.push(239,191,189);continue}C=h;continue}if(h<56320){(d-=3)>-1&&A.push(239,191,189),C=h;continue}h=(C-55296<<10|h-56320)+65536}else C&&(d-=3)>-1&&A.push(239,191,189);if(C=null,h<128){if((d-=1)<0)break;A.push(h)}else if(h<2048){if((d-=2)<0)break;A.push(h>>6|192,h&63|128)}else if(h<65536){if((d-=3)<0)break;A.push(h>>12|224,h>>6&63|128,h&63|128)}else if(h<1114112){if((d-=4)<0)break;A.push(h>>18|240,h>>12&63|128,h>>6&63|128,h&63|128)}else throw new Error("Invalid code point")}return A}function oc(v){const d=[];for(let h=0;h<v.length;++h)d.push(v.charCodeAt(h)&255);return d}function ou(v,d){let h,b,C;const A=[];for(let $=0;$<v.length&&!((d-=2)<0);++$)h=v.charCodeAt($),b=h>>8,C=h%256,A.push(C),A.push(b);return A}function Mn(v){return e.toByteArray(Vt(v))}function pi(v,d,h,b){let C;for(C=0;C<b&&!(C+h>=d.length||C>=v.length);++C)d[C+h]=v[C];return C}function Gt(v,d){return v instanceof d||v!=null&&v.constructor!=null&&v.constructor.name!=null&&v.constructor.name===d.name}function Fo(v){return v!==v}const ac=function(){const v="0123456789abcdef",d=new Array(256);for(let h=0;h<16;++h){const b=h*16;for(let C=0;C<16;++C)d[b+C]=v[h]+v[C]}return d}();function jr(v){return typeof BigInt=="undefined"?cc:v}function cc(){throw new Error("BigInt not supported")}})(l_);(function(n,e){var t=l_,r=t.Buffer;function i(o,c){for(var l in o)c[l]=o[l]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?n.exports=t:(i(t,e),e.Buffer=s);function s(o,c,l){return r(o,c,l)}i(r,s),s.from=function(o,c,l){if(typeof o=="number")throw new TypeError("Argument must not be a number");return r(o,c,l)},s.alloc=function(o,c,l){if(typeof o!="number")throw new TypeError("Argument must be a number");var u=r(o);return c!==void 0?typeof l=="string"?u.fill(c,l):u.fill(c):u.fill(0),u},s.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r(o)},s.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return t.SlowBuffer(o)}})(Ih,Ih.exports);var Ac=Ih.exports.Buffer;function IP(n){if(n.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),t=0;t<e.length;t++)e[t]=255;for(var r=0;r<n.length;r++){var i=n.charAt(r),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=r}var o=n.length,c=n.charAt(0),l=Math.log(o)/Math.log(256),u=Math.log(256)/Math.log(o);function a(p){if((Array.isArray(p)||p instanceof Uint8Array)&&(p=Ac.from(p)),!Ac.isBuffer(p))throw new TypeError("Expected Buffer");if(p.length===0)return"";for(var E=0,I=0,w=0,k=p.length;w!==k&&p[w]===0;)w++,E++;for(var P=(k-w)*u+1>>>0,S=new Uint8Array(P);w!==k;){for(var T=p[w],D=0,R=P-1;(T!==0||D<I)&&R!==-1;R--,D++)T+=256*S[R]>>>0,S[R]=T%o>>>0,T=T/o>>>0;if(T!==0)throw new Error("Non-zero carry");I=D,w++}for(var L=P-I;L!==P&&S[L]===0;)L++;for(var H=c.repeat(E);L<P;++L)H+=n.charAt(S[L]);return H}function g(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return Ac.alloc(0);for(var E=0,I=0,w=0;p[E]===c;)I++,E++;for(var k=(p.length-E)*l+1>>>0,P=new Uint8Array(k);p[E];){var S=e[p.charCodeAt(E)];if(S===255)return;for(var T=0,D=k-1;(S!==0||T<w)&&D!==-1;D--,T++)S+=o*P[D]>>>0,P[D]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");w=T,E++}for(var R=k-w;R!==k&&P[R]===0;)R++;var L=Ac.allocUnsafe(I+(k-R));L.fill(0,0,I);for(var H=I;R!==k;)L[H++]=P[R++];return L}function m(p){var E=g(p);if(E)return E;throw new Error("Non-base"+o+" character")}return{encode:a,decodeUnsafe:g,decode:m}}var TP=IP,OP=TP,kP="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",CP=OP(kP),PP=V.exports;Object.defineProperty(Bo,"__esModule",{value:!0});Bo.decodeRecoveryKey=AP;Bo.encodeRecoveryKey=MP;var d_=PP(CP);const Ai=[139,1];function MP(n){const e=new Buffer(Ai.length+n.length+1);e.set(Ai,0),e.set(n,Ai.length);let t=0;for(let i=0;i<e.length-1;++i)t^=e[i];return e[e.length-1]=t,d_.default.encode(e).match(/.{1,4}/g).join(" ")}function AP(n){const e=d_.default.decode(n.replace(/ /g,""));let t=0;for(const r of e)t^=r;if(t!==0)throw new Error("Incorrect parity");for(let r=0;r<Ai.length;++r)if(e[r]!==Ai[r])throw new Error("Incorrect prefix");if(e.length!==Ai.length+j.Olm.PRIVATE_KEY_LENGTH+1)throw new Error("Incorrect length");return Uint8Array.from(e.slice(Ai.length,Ai.length+j.Olm.PRIVATE_KEY_LENGTH))}var fe={},DP=V.exports;Object.defineProperty(fe,"__esModule",{value:!0});fe.VerificationRequestEvent=fe.VerificationRequest=fe.START_TYPE=fe.REQUEST_TYPE=fe.READY_TYPE=fe.Phase=fe.PHASE_UNSENT=fe.PHASE_STARTED=fe.PHASE_REQUESTED=fe.PHASE_READY=fe.PHASE_DONE=fe.PHASE_CANCELLED=fe.EVENT_PREFIX=fe.DONE_TYPE=fe.CANCEL_TYPE=void 0;var It=DP(Y.exports),Vi=ie,Gi=Le,Gg=or,UP=qe;const $P=10*60*1e3,xP=2*60*1e3,NP=3*1e3,As="m.key.verification.";fe.EVENT_PREFIX=As;const Zt=As+"request";fe.REQUEST_TYPE=Zt;const gr=As+"start";fe.START_TYPE=gr;const Qi=As+"cancel";fe.CANCEL_TYPE=Qi;const h_=As+"done";fe.DONE_TYPE=h_;const Ti=As+"ready";fe.READY_TYPE=Ti;let ri;fe.Phase=ri;(function(n){n[n.Unsent=1]="Unsent",n[n.Requested=2]="Requested",n[n.Ready=3]="Ready",n[n.Started=4]="Started",n[n.Cancelled=5]="Cancelled",n[n.Done=6]="Done"})(ri||(fe.Phase=ri={}));const fn=ri.Unsent;fe.PHASE_UNSENT=fn;const Dr=ri.Requested;fe.PHASE_REQUESTED=Dr;const pn=ri.Ready;fe.PHASE_READY=pn;const Zi=ri.Started;fe.PHASE_STARTED=Zi;const no=ri.Cancelled;fe.PHASE_CANCELLED=no;const io=ri.Done;fe.PHASE_DONE=io;let Hn;fe.VerificationRequestEvent=Hn;(function(n){n.Change="change"})(Hn||(fe.VerificationRequestEvent=Hn={}));class LP extends UP.TypedEventEmitter{constructor(e,t,r){super();this.channel=e,this.verificationMethods=t,this.client=r,(0,It.default)(this,"eventsByUs",new Map),(0,It.default)(this,"eventsByThem",new Map),(0,It.default)(this,"_observeOnly",!1),(0,It.default)(this,"timeoutTimer",null),(0,It.default)(this,"_accepting",!1),(0,It.default)(this,"_declining",!1),(0,It.default)(this,"verifierHasFinished",!1),(0,It.default)(this,"_cancelled",!1),(0,It.default)(this,"_chosenMethod",null),(0,It.default)(this,"_qrCodeData",null),(0,It.default)(this,"requestReceivedAt",null),(0,It.default)(this,"commonMethods",[]),(0,It.default)(this,"_phase",void 0),(0,It.default)(this,"_cancellingUserId",void 0),(0,It.default)(this,"_verifier",void 0),(0,It.default)(this,"cancelOnTimeout",()=>{try{this.initiatedByMe?this.cancel({reason:"Other party didn't accept in time",code:"m.timeout"}):this.cancel({reason:"User didn't accept in time",code:"m.timeout"})}catch(i){Vi.logger.error("Error while cancelling verification request",i)}}),this.channel.request=this,this.setPhase(fn,!1)}static validateEvent(e,t,r){const i=t.getContent();return!e||!e.startsWith(As)?!1:i?(e===Zt||e===Ti)&&!Array.isArray(i.methods)?(Vi.logger.log("VerificationRequest: validateEvent: fail because methods"),!1):(e===Zt||e===Ti||e===gr)&&(typeof i.from_device!="string"||i.from_device.length===0)?(Vi.logger.log("VerificationRequest: validateEvent: fail because from_device"),!1):!0:(Vi.logger.log("VerificationRequest: validateEvent: no content"),!1)}get invalid(){return this.phase===fn}get requested(){return this.phase===Dr}get cancelled(){return this.phase===no}get ready(){return this.phase===pn}get started(){return this.phase===Zi}get done(){return this.phase===io}get methods(){return this.commonMethods}get chosenMethod(){return this._chosenMethod}calculateEventTimeout(e){let t=this.channel.getTimestamp(e)+$P;if(this.requestReceivedAt&&!this.initiatedByMe&&this.phase<=Dr){const r=this.requestReceivedAt+xP;t=Math.min(t,r)}return Math.max(0,t-Date.now())}get timeout(){const e=this.getEventByEither(Zt);return e?this.calculateEventTimeout(e):0}get requestEvent(){return this.getEventByEither(Zt)}get phase(){return this._phase}get verifier(){return this._verifier}get canAccept(){return this.phase<pn&&!this._accepting&&!this._declining}get accepting(){return this._accepting}get declining(){return this._declining}get pending(){return!this.observeOnly&&this._phase!==io&&this._phase!==no}get qrCodeData(){return this._qrCodeData}otherPartySupportsMethod(e,t=!1){if(!t&&!this.ready&&!this.started)return!1;const r=this.eventsByThem.get(Zt)||this.eventsByThem.get(Ti);if(!r){if(this.started&&this.initiatedByMe){const o=this.eventsByUs.get(gr),c=o&&o.getContent(),l=c&&c.method;return e==l}return!1}const i=r.getContent();if(!i)return!1;const{methods:s}=i;return Array.isArray(s)?s.includes(e):!1}get initiatedByMe(){const e=this.eventsByUs.size+this.eventsByThem.size===0;if(this._phase===fn&&e)return!0;const t=this.eventsByUs.has(Zt),r=this.eventsByThem.has(Zt);if(t&&!r)return!0;if(!t&&r)return!1;const i=this.eventsByUs.has(gr),s=this.eventsByThem.has(gr);return!!(i&&!s)}get requestingUserId(){return this.initiatedByMe?this.client.getUserId():this.otherUserId}get receivingUserId(){return this.initiatedByMe?this.otherUserId:this.client.getUserId()}get otherUserId(){return this.channel.userId}get isSelfVerification(){return this.client.getUserId()===this.otherUserId}get cancellingUserId(){const e=this.eventsByUs.get(Qi),t=this.eventsByThem.get(Qi);if(e&&(!t||e.getId()<t.getId()))return e.getSender();if(t)return t.getSender()}get cancellationCode(){const e=this.getEventByEither(Qi);return e?e.getContent().code:null}get observeOnly(){return this._observeOnly}get targetDevice(){const r=(this.eventsByThem.get(Zt)||this.eventsByThem.get(Ti)||this.eventsByThem.get(gr)).getContent().from_device;return{userId:this.otherUserId,deviceId:r}}beginKeyVerification(e,t=null){if(!this.observeOnly&&!this._verifier&&(this.phase===Dr||this.phase===pn||this.phase===fn&&this.channel.canCreateRequest(gr))){if(this.commonMethods.length&&!this.commonMethods.includes(e)||(this._verifier=this.createVerifier(e,null,t),!this._verifier))throw(0,Gi.newUnknownMethodError)();this._chosenMethod=e}return this._verifier}async sendRequest(){if(!this.observeOnly&&this._phase===fn){const e=[...this.verificationMethods.keys()];await this.channel.send(Zt,{methods:e})}}async cancel({reason:e="User declined",code:t="m.user"}={}){if(!this.observeOnly&&this._phase!==no){if(this._declining=!0,this.emit(Hn.Change),this._verifier)return this._verifier.cancel((0,Gi.errorFactory)(t,e)());this._cancellingUserId=this.client.getUserId(),await this.channel.send(Qi,{code:t,reason:e})}}async accept(){if(!this.observeOnly&&this.phase===Dr&&!this.initiatedByMe){const e=[...this.verificationMethods.keys()];this._accepting=!0,this.emit(Hn.Change),await this.channel.send(Ti,{methods:e})}}waitFor(e){return new Promise((t,r)=>{const i=()=>{let s=!1;return e(this)?(t(this),s=!0):this.cancelled&&(r(new Error("cancelled")),s=!0),s&&this.off(Hn.Change,i),s};i()||this.on(Hn.Change,i)})}setPhase(e,t=!0){this._phase=e,t&&this.emit(Hn.Change)}getEventByEither(e){return this.eventsByThem.get(e)||this.eventsByUs.get(e)}getEventBy(e,t=!1){return t?this.eventsByThem.get(e):this.eventsByUs.get(e)}calculatePhaseTransitions(){const e=[{phase:fn}],t=()=>e[e.length-1].phase,r=this.eventsByThem.has(Zt),i=this.getEventBy(Zt,r);i&&e.push({phase:Dr,event:i});const s=i&&this.getEventBy(Ti,!r);s&&t()===Dr&&e.push({phase:pn,event:s});let o;if(s||!i){const u=this.eventsByThem.get(gr),a=this.eventsByUs.get(gr);u&&a?o=u.getSender()<a.getSender()?u:a:o=u||a}else o=this.getEventBy(gr,!r);if(o){const u=t()===Dr&&i.getSender()!==o.getSender(),a=t()===fn&&this.channel.canCreateRequest(gr);(u||t()===pn||a)&&e.push({phase:Zi,event:o})}const c=this.eventsByUs.get(h_);(this.verifierHasFinished||c&&t()===Zi)&&e.push({phase:io});const l=this.getEventByEither(Qi);return(this._cancelled||l)&&t()!==io&&e.push({phase:no,event:l}),e}transitionToPhase(e){const{phase:t,event:r}=e;if((t===Dr||t===pn)&&!this.wasSentByOwnDevice(r)){const i=r.getContent();this.commonMethods=i.methods.filter(s=>this.verificationMethods.has(s))}if(this.observeOnly||(t===Dr||t===Zi||t===pn)&&this.channel.receiveStartFromOtherDevices&&this.wasSentByOwnUser(r)&&!this.wasSentByOwnDevice(r)&&(this._observeOnly=!0),t===Zi){const{method:i}=r.getContent();!this._verifier&&!this.observeOnly&&(this._verifier=this.createVerifier(i,r),this._verifier?this._chosenMethod=i:this.cancel({code:"m.unknown_method",reason:`Unknown method: ${i}`}))}}applyPhaseTransitions(){const e=this.calculatePhaseTransitions(),t=e.findIndex(i=>i.phase===this.phase),r=e.slice(t+1);for(const i of r)this.transitionToPhase(i);return r}isWinningStartRace(e){if(e.getType()!==gr)return!1;const t=this._verifier.startEvent;let r;if(this.isSelfVerification)if(t){const s=t.getContent();r=s&&s.from_device}else r=this.client.getDeviceId();else t?r=t.getSender():r=this.client.getUserId();let i;if(this.isSelfVerification){const s=e.getContent();i=s&&s.from_device}else i=e.getSender();return i<r}hasEventId(e){for(const t of this.eventsByUs.values())if(t.getId()===e)return!0;for(const t of this.eventsByThem.values())if(t.getId()===e)return!0;return!1}async handleEvent(e,t,r,i,s){if(this.done||this.cancelled)return;const o=this._observeOnly;if(this.adjustObserveOnly(t,r),!this.observeOnly&&!i&&await this.cancelOnError(e,t)||(s?this.eventsByUs.has(e):this.eventsByThem.has(e)))return;const l=this.phase;this.addEvent(e,t,s);const u=this.applyPhaseTransitions();try{if(this._verifier&&!this.observeOnly){const g=this.isWinningStartRace(t);if(this._verifier.canSwitchStartEvent(t)&&g)this._verifier.switchStartEvent(t);else if(!i){var a;(e===Qi||(a=this._verifier.events)!==null&&a!==void 0&&a.includes(e))&&this._verifier.handleEvent(t)}}if(u.length){r&&u.some(p=>p.phase===pn)&&this.otherPartySupportsMethod(Gg.SCAN_QR_CODE_METHOD,!0)&&(this._qrCodeData=await Gg.QRCodeData.create(this,this.client));const g=u[u.length-1],{phase:m}=g;this.setupTimeout(m),this.setPhase(m)}else this._observeOnly!==o&&this.emit(Hn.Change)}finally{Vi.logger.log(`Verification request ${this.channel.transactionId}: ${e} event with id:${t.getId()}, content:${JSON.stringify(t.getContent())} deviceId:${this.channel.deviceId}, sender:${t.getSender()}, isSentByUs:${s}, isLiveEvent:${r}, isRemoteEcho:${i}, phase:${l}=>${this.phase}, observeOnly:${o}=>${this._observeOnly}`)}}setupTimeout(e){!this.timeoutTimer&&!this.observeOnly&&e===Dr&&(this.timeoutTimer=setTimeout(this.cancelOnTimeout,this.timeout)),this.timeoutTimer&&(e===Zi||e===pn||e===io||e===no)&&(clearTimeout(this.timeoutTimer),this.timeoutTimer=null)}async cancelOnError(e,t){if(e===gr){const s=t.getContent().method;if(!this.verificationMethods.has(s))return await this.cancel((0,Gi.errorFromEvent)((0,Gi.newUnknownMethodError)())),!0}const r=e===Zt&&this.phase!==fn,i=e===Ti&&this.phase!==Dr;if(this.phase!==fn&&(r||i)){Vi.logger.warn(`Cancelling, unexpected ${e} verification event from ${t.getSender()}`);const s=`Unexpected ${e} event in phase ${this.phase}`;return await this.cancel((0,Gi.errorFromEvent)((0,Gi.newUnexpectedMessageError)({reason:s}))),!0}return!1}adjustObserveOnly(e,t=!1){t||(this._observeOnly=!0),this.calculateEventTimeout(e)<NP&&(this._observeOnly=!0)}addEvent(e,t,r=!1){if(r?this.eventsByUs.set(e,t):this.eventsByThem.set(e,t),e===Zt){for(const[i,s]of this.eventsByThem.entries())s.getSender()!==this.otherUserId&&this.eventsByThem.delete(i);this.requestReceivedAt=Date.now()}}createVerifier(e,t=null,r=null){r||(r=this.targetDevice);const{userId:i,deviceId:s}=r,o=this.verificationMethods.get(e);if(!o){Vi.logger.warn("could not find verifier constructor for method",e);return}return new o(this.channel,this.client,i,s,t,this)}wasSentByOwnUser(e){return e.getSender()===this.client.getUserId()}wasSentByOwnDevice(e){if(!this.wasSentByOwnUser(e))return!1;const t=e.getContent();return!(!t||t.from_device!==this.client.getDeviceId())}onVerifierCancelled(){this._cancelled=!0;const e=this.applyPhaseTransitions();e.length&&this.setPhase(e[e.length-1].phase)}onVerifierFinished(){this.channel.send("m.key.verification.done",{}),this.verifierHasFinished=!0;const e=this.applyPhaseTransitions();e.length&&this.setPhase(e[e.length-1].phase)}getEventFromOtherParty(e){return this.eventsByThem.get(e)}}fe.VerificationRequest=LP;var Ro={},BP=V.exports;Object.defineProperty(Ro,"__esModule",{value:!0});Ro.InRoomRequests=Ro.InRoomChannel=void 0;var f_=BP(Y.exports),$t=fe,td=ie,KP=ne;const Wg=KP.EventType.RoomMessage,Hg="m.reference",Yg="m.relates_to";class ir{constructor(e,t,r=null){this.client=e,this.roomId=t,this.userId=r,(0,f_.default)(this,"requestEventId",null)}get receiveStartFromOtherDevices(){return!0}get transactionId(){return this.requestEventId}static getOtherPartyUserId(e,t){if(ir.getEventType(e)!==$t.REQUEST_TYPE)return;const i=t.getUserId(),s=e.getSender(),c=e.getContent().to;if(s===i)return c;if(c===i)return s}getTimestamp(e){return e.getTs()}static canCreateRequest(e){return e===$t.REQUEST_TYPE}canCreateRequest(e){return ir.canCreateRequest(e)}static getTransactionId(e){if(ir.getEventType(e)===$t.REQUEST_TYPE)return e.getId();{const t=e.getRelation();if(t&&t.rel_type===Hg)return t.event_id}}static validateEvent(e,t){const r=ir.getTransactionId(e);if(typeof r!="string"||r.length===0)return!1;const i=ir.getEventType(e),s=e.getContent();if(i===$t.REQUEST_TYPE){if(!s||typeof s.to!="string"||!s.to.length)return td.logger.log("InRoomChannel: validateEvent: no valid to "+(s&&s.to)),!1;if(!ir.getOtherPartyUserId(e,t))return td.logger.log(`InRoomChannel: validateEvent: not directed to or sent by me: ${e.getSender()}, ${s&&s.to}`),!1}return $t.VerificationRequest.validateEvent(i,e,t)}static getEventType(e){const t=e.getType();if(t===Wg){const r=e.getContent();if(r){const{msgtype:i}=r;if(i===$t.REQUEST_TYPE)return $t.REQUEST_TYPE}}return t&&t!==$t.REQUEST_TYPE?t:""}async handleEvent(e,t,r=!1){if(t.hasEventId(e.getId()))return;const i=ir.getEventType(e);if(e.getRoomId()!==this.roomId)return;if(this.userId===null){const u=ir.getOtherPartyUserId(e,this.client);u&&(this.userId=u)}const s=this.client.getUserId(),o=e.getSender();if(this.userId!==null&&o!==s&&o!==this.userId){td.logger.log(`InRoomChannel: ignoring verification event from non-participating sender ${o}`);return}this.requestEventId===null&&(this.requestEventId=ir.getTransactionId(e));const c=!!e.getUnsigned().transaction_id,l=e.getSender()===this.client.getUserId();return await t.handleEvent(i,e,r,c,l)}completedContentFromEvent(e){const t=Object.assign({},e.getContent());return t[Yg]=e.getRelation(),t}completeContent(e,t){return t=Object.assign({},t),(e===$t.REQUEST_TYPE||e===$t.READY_TYPE||e===$t.START_TYPE)&&(t.from_device=this.client.getDeviceId()),e===$t.REQUEST_TYPE?t={body:this.client.getUserId()+" is requesting to verify your key, but your client does not support in-chat key verification. You will need to use legacy key verification to verify keys.",msgtype:$t.REQUEST_TYPE,to:this.userId,from_device:t.from_device,methods:t.methods}:t[Yg]={rel_type:Hg,event_id:this.transactionId},t}send(e,t){const r=this.completeContent(e,t);return this.sendCompleted(e,r)}async sendCompleted(e,t){let r=e;e===$t.REQUEST_TYPE&&(r=Wg);const i=await this.client.sendEvent(this.roomId,r,t);e===$t.REQUEST_TYPE&&(this.requestEventId=i.event_id)}}Ro.InRoomChannel=ir;class FP{constructor(){(0,f_.default)(this,"requestsByRoomId",new Map)}getRequest(e){const t=e.getRoomId(),r=ir.getTransactionId(e);return this.getRequestByTxnId(t,r)}getRequestByChannel(e){return this.getRequestByTxnId(e.roomId,e.transactionId)}getRequestByTxnId(e,t){const r=this.requestsByRoomId.get(e);if(r)return r.get(t)}setRequest(e,t){this.doSetRequest(e.getRoomId(),ir.getTransactionId(e),t)}setRequestByChannel(e,t){this.doSetRequest(e.roomId,e.transactionId,t)}doSetRequest(e,t,r){let i=this.requestsByRoomId.get(e);i||(i=new Map,this.requestsByRoomId.set(e,i)),i.set(t,r)}removeRequest(e){const t=e.getRoomId(),r=this.requestsByRoomId.get(t);r&&(r.delete(ir.getTransactionId(e)),r.size===0&&this.requestsByRoomId.delete(t))}findRequestInProgress(e){const t=this.requestsByRoomId.get(e);if(t){for(const r of t.values())if(r.pending)return r}}}Ro.InRoomRequests=FP;var Io={},qP=V.exports;Object.defineProperty(Io,"__esModule",{value:!0});Io.ToDeviceRequests=Io.ToDeviceChannel=void 0;var p_=qP(Y.exports),jP=oi,na=ie,xe=fe,zg=Le,VP=qt;class cs{constructor(e,t,r,i=null,s=null){this.client=e,this.userId=t,this.devices=r,this.transactionId=i,this.deviceId=s,(0,p_.default)(this,"request",void 0)}isToDevices(e){if(e.length===this.devices.length){for(const t of e)if(!this.devices.includes(t))return!1;return!0}else return!1}static getEventType(e){return e.getType()}static getTransactionId(e){const t=e.getContent();return t&&t.transaction_id}static canCreateRequest(e){return e===xe.REQUEST_TYPE||e===xe.START_TYPE}canCreateRequest(e){return cs.canCreateRequest(e)}static validateEvent(e,t){if(e.isCancelled())return na.logger.warn("Ignoring flagged verification request from "+e.getSender()),!1;const r=e.getContent();if(!r)return na.logger.warn("ToDeviceChannel.validateEvent: invalid: no content"),!1;if(!r.transaction_id)return na.logger.warn("ToDeviceChannel.validateEvent: invalid: no transaction_id"),!1;const i=e.getType();if(i===xe.REQUEST_TYPE){if(!Number.isFinite(r.timestamp))return na.logger.warn("ToDeviceChannel.validateEvent: invalid: no timestamp"),!1;if(e.getSender()===t.getUserId()&&r.from_device==t.getDeviceId())return na.logger.warn("ToDeviceChannel.validateEvent: invalid: from own device"),!1}return xe.VerificationRequest.validateEvent(i,e,t)}getTimestamp(e){const t=e.getContent();return t&&t.timestamp}async handleEvent(e,t,r=!1){const i=e.getType(),s=e.getContent();if(i===xe.REQUEST_TYPE||i===xe.READY_TYPE||i===xe.START_TYPE){this.transactionId||(this.transactionId=s.transaction_id);const u=s.from_device;if(!this.deviceId&&this.devices.includes(u)&&(this.deviceId=u),!this.deviceId||this.deviceId!==u){const a=this.completeContent(xe.CANCEL_TYPE,(0,zg.errorFromEvent)((0,zg.newUnexpectedMessageError)()));return this.sendToDevices(xe.CANCEL_TYPE,a,[u])}}const o=t.phase===xe.PHASE_STARTED||t.phase===xe.PHASE_READY;await t.handleEvent(e.getType(),e,r,!1,!1);const c=t.phase===xe.PHASE_STARTED||t.phase===xe.PHASE_READY;if((i===xe.START_TYPE||i===xe.READY_TYPE)&&!o&&c&&this.deviceId){const u=this.devices.filter(a=>a!==this.deviceId&&a!==this.client.getDeviceId());if(u.length){const a=this.completeContent(xe.CANCEL_TYPE,{code:"m.accepted",reason:"Verification request accepted by another device"});await this.sendToDevices(xe.CANCEL_TYPE,a,u)}}}completedContentFromEvent(e){return e.getContent()}completeContent(e,t){return t=Object.assign({},t),this.transactionId&&(t.transaction_id=this.transactionId),(e===xe.REQUEST_TYPE||e===xe.READY_TYPE||e===xe.START_TYPE)&&(t.from_device=this.client.getDeviceId()),e===xe.REQUEST_TYPE&&(t.timestamp=Date.now()),t}send(e,t={}){(e===xe.REQUEST_TYPE||e===xe.START_TYPE)&&!this.transactionId&&(this.transactionId=cs.makeTransactionId());const r=this.completeContent(e,t);return this.sendCompleted(e,r)}async sendCompleted(e,t){let r;e===xe.REQUEST_TYPE||e===xe.CANCEL_TYPE&&!this.deviceId?r=await this.sendToDevices(e,t,this.devices):r=await this.sendToDevices(e,t,[this.deviceId]);const i=new VP.MatrixEvent({sender:this.client.getUserId(),content:t,type:e});return await this.request.handleEvent(e,i,!0,!0,!0),r}async sendToDevices(e,t,r){if(r.length){const i={};for(const s of r)i[s]=t;await this.client.sendToDevice(e,{[this.userId]:i})}}static makeTransactionId(){return(0,jP.randomString)(32)}}Io.ToDeviceChannel=cs;class GP{constructor(){(0,p_.default)(this,"requestsByUserId",new Map)}getRequest(e){return this.getRequestBySenderAndTxnId(e.getSender(),cs.getTransactionId(e))}getRequestByChannel(e){return this.getRequestBySenderAndTxnId(e.userId,e.transactionId)}getRequestBySenderAndTxnId(e,t){const r=this.requestsByUserId.get(e);if(r)return r.get(t)}setRequest(e,t){this.setRequestBySenderAndTxnId(e.getSender(),cs.getTransactionId(e),t)}setRequestByChannel(e,t){this.setRequestBySenderAndTxnId(e.userId,e.transactionId,t)}setRequestBySenderAndTxnId(e,t,r){let i=this.requestsByUserId.get(e);i||(i=new Map,this.requestsByUserId.set(e,i)),i.set(t,r)}removeRequest(e){const t=e.getSender(),r=this.requestsByUserId.get(t);r&&(r.delete(cs.getTransactionId(e)),r.size===0&&this.requestsByUserId.delete(t))}findRequestInProgress(e,t){const r=this.requestsByUserId.get(e);if(r){for(const i of r.values())if(i.pending&&i.channel.isToDevices(t))return i}}getRequestsInProgress(e){const t=this.requestsByUserId.get(e);return t?Array.from(t.values()).filter(r=>r.pending):[]}}Io.ToDeviceRequests=GP;var Xl={},WP=V.exports;Object.defineProperty(Xl,"__esModule",{value:!0});Xl.IllegalMethod=void 0;var HP=WP(Y.exports),YP=Qr;class vf extends YP.VerificationBase{constructor(...e){super(...e);(0,HP.default)(this,"doVerification",async()=>{throw new Error("Verification is not possible with this method")})}static factory(e,t,r,i,s,o){return new vf(e,t,r,i,s,o)}static get NAME(){return"org.matrix.illegal_method"}}Xl.IllegalMethod=vf;var Ss={},g_=V.exports;Object.defineProperty(Ss,"__esModule",{value:!0});Ss.DehydrationManager=Ss.DEHYDRATION_ALGORITHM=void 0;var ia=g_(Y.exports),rd=g_(Vl),Jg=Me,nd=Kr,Xg=ci,Nn=ie,Qg=me;const rl="org.matrix.msc2697.v1.olm.libolm_pickle";Ss.DEHYDRATION_ALGORITHM=rl;const Zg=7*24*60*60*1e3;class zP{constructor(e){this.crypto=e,(0,ia.default)(this,"inProgress",!1),(0,ia.default)(this,"timeoutId",void 0),(0,ia.default)(this,"key",void 0),(0,ia.default)(this,"keyInfo",void 0),(0,ia.default)(this,"deviceDisplayName",void 0),this.getDehydrationKeyFromCache()}async getDehydrationKeyFromCache(){return await this.crypto.cryptoStore.doTxn("readonly",[nd.IndexedDBCryptoStore.STORE_ACCOUNT],e=>{this.crypto.cryptoStore.getSecretStorePrivateKey(e,async t=>{if(t){const{key:r,keyInfo:i,deviceDisplayName:s,time:o}=t,c=Buffer.from(this.crypto.olmDevice.pickleKey),l=await(0,Xg.decryptAES)(r,c,rl);this.key=(0,Jg.decodeBase64)(l),this.keyInfo=i,this.deviceDisplayName=s;const u=Date.now(),a=Math.max(1,o+Zg-u);this.timeoutId=j.setTimeout(this.dehydrateDevice.bind(this),a)}},"dehydration")})}async setKeyAndQueueDehydration(e,t={},r=void 0){await this.setKey(e,t,r)||this.dehydrateDevice()}async setKey(e,t={},r=void 0){if(!e){this.timeoutId&&(j.clearTimeout(this.timeoutId),this.timeoutId=void 0),await this.crypto.cryptoStore.doTxn("readwrite",[nd.IndexedDBCryptoStore.STORE_ACCOUNT],s=>{this.crypto.cryptoStore.storeSecretStorePrivateKey(s,"dehydration",null)}),this.key=void 0,this.keyInfo=void 0;return}let i=this.key&&e.length==this.key.length;for(let s=0;i&&s<e.length;s++)e[s]!=this.key[s]&&(i=!1);return i||(this.key=e,this.keyInfo=t,this.deviceDisplayName=r),i}async dehydrateDevice(){if(this.inProgress){Nn.logger.log("Dehydration already in progress -- not starting new dehydration");return}this.inProgress=!0,this.timeoutId&&(j.clearTimeout(this.timeoutId),this.timeoutId=void 0);try{const e=Buffer.from(this.crypto.olmDevice.pickleKey),t=await(0,Xg.encryptAES)((0,Jg.encodeBase64)(this.key),e,rl);await this.crypto.cryptoStore.doTxn("readwrite",[nd.IndexedDBCryptoStore.STORE_ACCOUNT],w=>{this.crypto.cryptoStore.storeSecretStorePrivateKey(w,"dehydration",{keyInfo:this.keyInfo,key:t,deviceDisplayName:this.deviceDisplayName,time:Date.now()})}),Nn.logger.log("Attempting to dehydrate device"),Nn.logger.log("Creating account");const r=new j.Olm.Account;r.create();const i=JSON.parse(r.identity_keys()),s=r.max_number_of_one_time_keys();r.generate_one_time_keys(s/2),r.generate_fallback_key();const o=JSON.parse(r.one_time_keys()),c=JSON.parse(r.fallback_key());r.mark_keys_as_published();const l=r.pickle(new Uint8Array(this.key)),u={algorithm:rl,account:l};this.keyInfo.passphrase&&(u.passphrase=this.keyInfo.passphrase),Nn.logger.log("Uploading account to server");const g=(await this.crypto.baseApis.http.authedRequest(void 0,Qg.Method.Put,"/dehydrated_device",void 0,{device_data:u,initial_device_display_name:this.deviceDisplayName},{prefix:"/_matrix/client/unstable/org.matrix.msc2697.v2"})).device_id;Nn.logger.log("Preparing device keys",g);const m={algorithms:this.crypto.supportedAlgorithms,device_id:g,user_id:this.crypto.userId,keys:{[`ed25519:${g}`]:i.ed25519,[`curve25519:${g}`]:i.curve25519}},p=r.sign(rd.default.stringify(m));m.signatures={[this.crypto.userId]:{[`ed25519:${g}`]:p}},this.crypto.crossSigningInfo.getId("self_signing")&&await this.crypto.crossSigningInfo.signObject(m,"self_signing"),Nn.logger.log("Preparing one-time keys");const E={};for(const[w,k]of Object.entries(o.curve25519)){const P={key:k},S=r.sign(rd.default.stringify(P));P.signatures={[this.crypto.userId]:{[`ed25519:${g}`]:S}},E[`signed_curve25519:${w}`]=P}Nn.logger.log("Preparing fallback keys");const I={};for(const[w,k]of Object.entries(c.curve25519)){const P={key:k,fallback:!0},S=r.sign(rd.default.stringify(P));P.signatures={[this.crypto.userId]:{[`ed25519:${g}`]:S}},I[`signed_curve25519:${w}`]=P}return Nn.logger.log("Uploading keys to server"),await this.crypto.baseApis.http.authedRequest(void 0,Qg.Method.Post,"/keys/upload/"+encodeURI(g),void 0,{device_keys:m,one_time_keys:E,"org.matrix.msc2732.fallback_keys":I}),Nn.logger.log("Done dehydrating"),this.timeoutId=j.setTimeout(this.dehydrateDevice.bind(this),Zg),g}finally{this.inProgress=!1}}stop(){this.timeoutId&&(j.clearTimeout(this.timeoutId),this.timeoutId=void 0)}}Ss.DehydrationManager=zP;var vr={},JP=V.exports;Object.defineProperty(vr,"__esModule",{value:!0});vr.algorithmsByName=vr.DefaultAlgorithm=vr.Curve25519=vr.BackupManager=vr.Aes256=void 0;var oo=JP(Y.exports),XP=it,mt=ie,sa=Me,m_=Ms,Th=G,em=Kr,QP=Bo,oa=ci,ZP=Sr,Gs=Kt;const eM=200;class Ma{constructor(e,t){this.baseApis=e,this.getKey=t,(0,oo.default)(this,"algorithm",void 0),(0,oo.default)(this,"backupInfo",void 0),(0,oo.default)(this,"checkedForBackup",void 0),(0,oo.default)(this,"sendingBackups",void 0),this.checkedForBackup=!1,this.sendingBackups=!1}get version(){return this.backupInfo&&this.backupInfo.version}static checkBackupVersion(e){const t=nl[e.algorithm];if(!t)throw new Error("Unknown backup algorithm: "+e.algorithm);if(typeof e.auth_data!="object")throw new Error("Invalid backup data returned");return t.checkBackupVersion(e)}static async makeAlgorithm(e,t){const r=nl[e.algorithm];if(!r)throw new Error("Unknown backup algorithm");return await r.init(e.auth_data,t)}async enableKeyBackup(e){this.backupInfo=e,this.algorithm&&this.algorithm.free(),this.algorithm=await Ma.makeAlgorithm(e,this.getKey),this.baseApis.emit(Gs.CryptoEvent.KeyBackupStatus,!0),this.scheduleKeyBackupSend()}disableKeyBackup(){this.algorithm&&this.algorithm.free(),this.algorithm=void 0,this.backupInfo=void 0,this.baseApis.emit(Gs.CryptoEvent.KeyBackupStatus,!1)}getKeyBackupEnabled(){return this.checkedForBackup?Boolean(this.algorithm):null}async prepareKeyBackupVersion(e,t){const r=t?nl[t]:y_;if(!r)throw new Error("Unknown backup algorithm");const[i,s]=await r.prepare(e),o=(0,QP.encodeRecoveryKey)(i);return{algorithm:r.algorithmName,auth_data:s,recovery_key:o,privateKey:i}}async createKeyBackupVersion(e){this.algorithm=await Ma.makeAlgorithm(e,this.getKey)}async checkAndStart(){if(mt.logger.log("Checking key backup status..."),this.baseApis.isGuest())return mt.logger.log("Skipping key backup check since user is guest"),this.checkedForBackup=!0,null;let e;try{e=await this.baseApis.getKeyBackupVersion()}catch(r){return mt.logger.log("Error checking for active key backup",r),r.httpStatus===404&&(this.checkedForBackup=!0),null}this.checkedForBackup=!0;const t=await this.isKeyBackupTrusted(e);return t.usable&&!this.backupInfo?(mt.logger.log("Found usable key backup v"+e.version+": enabling key backups"),await this.enableKeyBackup(e)):!t.usable&&this.backupInfo?(mt.logger.log("No usable key backup: disabling key backup"),this.disableKeyBackup()):!t.usable&&!this.backupInfo?mt.logger.log("No usable key backup: not enabling key backup"):t.usable&&this.backupInfo&&(e.version!==this.backupInfo.version?(mt.logger.log("On backup version "+this.backupInfo.version+" but found version "+e.version+": switching."),this.disableKeyBackup(),await this.enableKeyBackup(e),await this.scheduleAllGroupSessionsForBackup()):mt.logger.log("Backup version "+e.version+" still current")),{backupInfo:e,trustInfo:t}}async checkKeyBackup(){return this.checkedForBackup=!1,this.checkAndStart()}async isKeyBackupTrusted(e){const t={usable:!1,trusted_locally:!1,sigs:[]};if(!e||!e.algorithm||!e.auth_data||!e.auth_data.signatures)return mt.logger.info("Key backup is absent or missing required data"),t;const r=await this.baseApis.crypto.getSessionBackupPrivateKey();if(r){let s;try{s=await Ma.makeAlgorithm(e,async()=>r),await s.keyMatches(r)&&(mt.logger.info("Backup is trusted locally"),t.trusted_locally=!0)}catch{}finally{s&&s.free()}}const i=e.auth_data.signatures[this.baseApis.getUserId()]||{};for(const s of Object.keys(i)){const o=s.split(":");if(o[0]!=="ed25519"){mt.logger.log("Ignoring unknown signature type: "+o[0]);continue}const c={deviceId:o[1]},l=this.baseApis.crypto.crossSigningInfo.getId();if(l===c.deviceId){c.crossSigningId=!0;try{await(0,sa.verifySignature)(this.baseApis.crypto.olmDevice,e.auth_data,this.baseApis.getUserId(),c.deviceId,l),c.valid=!0}catch(a){mt.logger.warn("Bad signature from cross signing key "+l,a),c.valid=!1}t.sigs.push(c);continue}const u=this.baseApis.crypto.deviceList.getStoredDevice(this.baseApis.getUserId(),c.deviceId);if(u){c.device=u,c.deviceTrust=await this.baseApis.checkDeviceTrust(this.baseApis.getUserId(),c.deviceId);try{await(0,sa.verifySignature)(this.baseApis.crypto.olmDevice,e.auth_data,this.baseApis.getUserId(),u.deviceId,u.getFingerprint()),c.valid=!0}catch(a){mt.logger.info("Bad signature from key ID "+s+" userID "+this.baseApis.getUserId()+" device ID "+u.deviceId+" fingerprint: "+u.getFingerprint(),e.auth_data,a),c.valid=!1}}else c.valid=null,mt.logger.info("Ignoring signature from unknown key "+s);t.sigs.push(c)}return t.usable=t.sigs.some(s=>s.valid&&(s.device&&s.deviceTrust.isVerified()||s.crossSigningId)),t.usable=t.usable||t.trusted_locally,t}async scheduleKeyBackupSend(e=1e4){if(!this.sendingBackups){this.sendingBackups=!0;try{const t=Math.random()*e;await(0,Th.sleep)(t,void 0);let r=0;for(;;){if(!this.algorithm)return;try{if(await this.backupPendingKeys(eM)===0)return;r=0}catch(i){if(r++,mt.logger.log("Key backup request failed",i),i.data&&(i.data.errcode=="M_NOT_FOUND"||i.data.errcode=="M_WRONG_ROOM_KEYS_VERSION"))throw await this.checkKeyBackup(),this.baseApis.crypto.emit(Gs.CryptoEvent.KeyBackupFailed,i.data.errcode),i}r&&await(0,Th.sleep)(1e3*Math.pow(2,Math.min(r-1,4)),void 0)}}finally{this.sendingBackups=!1}}}async backupPendingKeys(e){const t=await this.baseApis.crypto.cryptoStore.getSessionsNeedingBackup(e);if(!t.length)return 0;let r=await this.baseApis.crypto.cryptoStore.countSessionsNeedingBackup();this.baseApis.crypto.emit(Gs.CryptoEvent.KeyBackupSessionsRemaining,r);const i={};for(const s of t){const o=s.sessionData.room_id;i[o]===void 0&&(i[o]={sessions:{}});const c=await this.baseApis.crypto.olmDevice.exportInboundGroupSession(s.senderKey,s.sessionId,s.sessionData);c.algorithm=sa.MEGOLM_ALGORITHM;const l=(c.forwarding_curve25519_key_chain||[]).length,u=this.baseApis.crypto.deviceList.getUserByIdentityKey(sa.MEGOLM_ALGORITHM,s.senderKey),a=this.baseApis.crypto.deviceList.getDeviceByIdentityKey(sa.MEGOLM_ALGORITHM,s.senderKey),g=this.baseApis.crypto.checkDeviceInfoTrust(u,a).isVerified();i[o].sessions[s.sessionId]={first_message_index:c.first_known_index,forwarded_count:l,is_verified:g,session_data:await this.algorithm.encryptSession(c)}}return await this.baseApis.sendKeyBackup(void 0,void 0,this.backupInfo.version,{rooms:i}),await this.baseApis.crypto.cryptoStore.unmarkSessionsNeedingBackup(t),r=await this.baseApis.crypto.cryptoStore.countSessionsNeedingBackup(),this.baseApis.crypto.emit(Gs.CryptoEvent.KeyBackupSessionsRemaining,r),t.length}async backupGroupSession(e,t){await this.baseApis.crypto.cryptoStore.markSessionsNeedingBackup([{senderKey:e,sessionId:t}]),this.backupInfo&&this.scheduleKeyBackupSend()}async scheduleAllGroupSessionsForBackup(){await this.flagAllGroupSessionsForBackup(),this.scheduleKeyBackupSend(0)}async flagAllGroupSessionsForBackup(){await this.baseApis.crypto.cryptoStore.doTxn("readwrite",[em.IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS,em.IndexedDBCryptoStore.STORE_BACKUP],t=>{this.baseApis.crypto.cryptoStore.getAllEndToEndInboundGroupSessions(t,r=>{r!==null&&this.baseApis.crypto.cryptoStore.markSessionsNeedingBackup([r],t)})});const e=await this.baseApis.crypto.cryptoStore.countSessionsNeedingBackup();return this.baseApis.emit(Gs.CryptoEvent.KeyBackupSessionsRemaining,e),e}countSessionsNeedingBackup(){return this.baseApis.crypto.cryptoStore.countSessionsNeedingBackup()}}vr.BackupManager=Ma;class bs{constructor(e,t,r){this.authData=e,this.publicKey=t,this.getKey=r}static async init(e,t){if(!e||!("public_key"in e))throw new Error("auth_data missing required information");const r=new j.Olm.PkEncryption;return r.set_recipient_key(e.public_key),new bs(e,r,t)}static async prepare(e){const t=new j.Olm.PkDecryption;try{const r={};if(!e)r.public_key=t.generate_key();else if(e instanceof Uint8Array)r.public_key=t.init_with_private_key(e);else{const s=await(0,m_.keyFromPassphrase)(e);r.private_key_salt=s.salt,r.private_key_iterations=s.iterations,r.public_key=t.init_with_private_key(s.key)}return new j.Olm.PkEncryption().set_recipient_key(r.public_key),[t.get_private_key(),r]}finally{t.free()}}static checkBackupVersion(e){if(!("public_key"in e.auth_data))throw new Error("Invalid backup data returned")}get untrusted(){return!0}async encryptSession(e){const t=Object.assign({},e);return delete t.session_id,delete t.room_id,delete t.first_known_index,this.publicKey.encrypt(JSON.stringify(t))}async decryptSessions(e){const t=await this.getKey(),r=new j.Olm.PkDecryption;try{if(r.init_with_private_key(t)!==this.authData.public_key)throw{errcode:XP.MatrixClient.RESTORE_BACKUP_ERROR_BAD_KEY};const s=[];for(const[o,c]of Object.entries(e))try{const l=JSON.parse(r.decrypt(c.session_data.ephemeral,c.session_data.mac,c.session_data.ciphertext));l.session_id=o,s.push(l)}catch(l){mt.logger.log("Failed to decrypt megolm session from backup",l,c)}return s}finally{r.free()}}async keyMatches(e){const t=new j.Olm.PkDecryption;let r;try{r=t.init_with_private_key(e)}finally{t.free()}return r===this.authData.public_key}free(){this.publicKey.free()}}vr.Curve25519=bs;(0,oo.default)(bs,"algorithmName","m.megolm_backup.v1.curve25519-aes-sha2");function tM(n){var e;const t=(0,Th.getCrypto)();if(t)return t.randomBytes(n);if((e=window)!==null&&e!==void 0&&e.crypto){const r=new Uint8Array(n);return window.crypto.getRandomValues(r),r}throw new Error("No usable crypto implementation")}const rM=new ZP.UnstableValue(null,"org.matrix.msc3270.v1.aes-hmac-sha2");class To{constructor(e,t){this.authData=e,this.key=t}static async init(e,t){if(!e)throw new Error("auth_data missing");const r=await t();if(e.mac){const{mac:i}=await(0,oa.calculateKeyCheck)(r,e.iv);if(e.mac.replace(/=+$/g,"")!==i.replace(/=+/g,""))throw new Error("Key does not match")}return new To(e,r)}static async prepare(e){let t;const r={};if(!e)t=tM(32);else if(e instanceof Uint8Array)t=new Uint8Array(e);else{const o=await(0,m_.keyFromPassphrase)(e);r.private_key_salt=o.salt,r.private_key_iterations=o.iterations,t=o.key}const{iv:i,mac:s}=await(0,oa.calculateKeyCheck)(t);return r.iv=i,r.mac=s,[t,r]}static checkBackupVersion(e){if(!("iv"in e.auth_data&&"mac"in e.auth_data))throw new Error("Invalid backup data returned")}get untrusted(){return!1}async encryptSession(e){const t=Object.assign({},e);return delete t.session_id,delete t.room_id,delete t.first_known_index,await(0,oa.encryptAES)(JSON.stringify(t),this.key,e.session_id)}async decryptSessions(e){const t=[];for(const[r,i]of Object.entries(e))try{const s=JSON.parse(await(0,oa.decryptAES)(i.session_data,this.key,r));s.session_id=r,t.push(s)}catch(s){mt.logger.log("Failed to decrypt megolm session from backup",s,i)}return t}async keyMatches(e){if(this.authData.mac){const{mac:t}=await(0,oa.calculateKeyCheck)(e,this.authData.iv);return this.authData.mac.replace(/=+$/g,"")===t.replace(/=+/g,"")}else return!0}free(){this.key.fill(0)}}vr.Aes256=To;(0,oo.default)(To,"algorithmName",rM.name);const nl={[bs.algorithmName]:bs,[To.algorithmName]:To};vr.algorithmsByName=nl;const y_=bs;vr.DefaultAlgorithm=y_;var v_=V.exports;Object.defineProperty(Kt,"__esModule",{value:!0});Kt.IncomingRoomKeyRequest=Kt.CryptoEvent=Kt.Crypto=void 0;Kt.fixBackupKey=sl;Kt.isCryptoAvailable=gM;Kt.verificationMethods=void 0;var oe=v_(Y.exports),nM=v_(Vl),iM=nn,N=ie,tm=ys,Tt=E_(Me),sM=vs,il=Ps,Dc=E_(df),Ln=Ct,rm=bo,Ws=wo,oM=_s,aa=Kr,va=or,Oh=Es,aM=Ms,nm=Bo,ca=fe,Uc=Ro,Hr=Io,im=Xl,$c=si,id=ci,cM=Ss,lM=vr,uM=ar,dM=tn,Bn=qt,hM=it,fM=qe;function __(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(__=function(r){return r?t:e})(n)}function E_(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=__(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}const Kn=il.DeviceInfo.DeviceVerification,sd={[va.ReciprocateQRCode.NAME]:va.ReciprocateQRCode,[Oh.SAS.NAME]:Oh.SAS,[va.SHOW_QR_CODE_METHOD]:im.IllegalMethod,[va.SCAN_QR_CODE_METHOD]:im.IllegalMethod},pM={RECIPROCATE_QR_CODE:va.ReciprocateQRCode.NAME,SAS:Oh.SAS.NAME};Kt.verificationMethods=pM;function gM(){return Boolean(j.Olm)}const mM=60*60*1e3;let Qe;Kt.CryptoEvent=Qe;(function(n){n.DeviceVerificationChanged="deviceVerificationChanged",n.UserTrustStatusChanged="userTrustStatusChanged",n.UserCrossSigningUpdated="userCrossSigningUpdated",n.RoomKeyRequest="crypto.roomKeyRequest",n.RoomKeyRequestCancellation="crypto.roomKeyRequestCancellation",n.KeyBackupStatus="crypto.keyBackupStatus",n.KeyBackupFailed="crypto.keyBackupFailed",n.KeyBackupSessionsRemaining="crypto.keyBackupSessionsRemaining",n.KeySignatureUploadFailure="crypto.keySignatureUploadFailure",n.VerificationRequest="crypto.verification.request",n.Warning="crypto.warning",n.WillUpdateDevices="crypto.willUpdateDevices",n.DevicesUpdated="crypto.devicesUpdated",n.KeysChanged="crossSigning.keysChanged"})(Qe||(Kt.CryptoEvent=Qe={}));class yM extends fM.TypedEventEmitter{static getOlmVersion(){return tm.OlmDevice.getOlmVersion()}constructor(e,t,r,i,s,o,c,l){super();if(this.baseApis=e,this.sessionStore=t,this.userId=r,this.deviceId=i,this.clientStore=s,this.cryptoStore=o,this.roomList=c,(0,oe.default)(this,"backupManager",void 0),(0,oe.default)(this,"crossSigningInfo",void 0),(0,oe.default)(this,"olmDevice",void 0),(0,oe.default)(this,"deviceList",void 0),(0,oe.default)(this,"dehydrationManager",void 0),(0,oe.default)(this,"secretStorage",void 0),(0,oe.default)(this,"reEmitter",void 0),(0,oe.default)(this,"verificationMethods",void 0),(0,oe.default)(this,"supportedAlgorithms",void 0),(0,oe.default)(this,"outgoingRoomKeyRequestManager",void 0),(0,oe.default)(this,"toDeviceVerificationRequests",void 0),(0,oe.default)(this,"inRoomVerificationRequests",void 0),(0,oe.default)(this,"trustCrossSignedDevices",!0),(0,oe.default)(this,"lastOneTimeKeyCheck",null),(0,oe.default)(this,"oneTimeKeyCheckInProgress",!1),(0,oe.default)(this,"roomEncryptors",{}),(0,oe.default)(this,"roomDecryptors",{}),(0,oe.default)(this,"deviceKeys",{}),(0,oe.default)(this,"globalBlacklistUnverifiedDevices",!1),(0,oe.default)(this,"globalErrorOnUnknownDevices",!0),(0,oe.default)(this,"receivedRoomKeyRequests",[]),(0,oe.default)(this,"receivedRoomKeyRequestCancellations",[]),(0,oe.default)(this,"processingRoomKeyRequests",!1),(0,oe.default)(this,"lazyLoadMembers",!1),(0,oe.default)(this,"roomDeviceTrackingState",{}),(0,oe.default)(this,"lastNewSessionForced",{}),(0,oe.default)(this,"sendKeyRequestsImmediately",!1),(0,oe.default)(this,"oneTimeKeyCount",void 0),(0,oe.default)(this,"needsNewFallback",void 0),(0,oe.default)(this,"fallbackCleanup",void 0),(0,oe.default)(this,"onDeviceListUserCrossSigningUpdated",async g=>{if(g===this.userId){const m=this.deviceList.getStoredCrossSigningForUser(g),p=m?m.getId():null,E=this.crossSigningInfo.getId();E&&p&&!(E!==p)?await this.checkOwnCrossSigningTrust():(this.storeTrustedSelfKeys(null),this.emit(Qe.KeysChanged,{}),this.emit(Qe.UserTrustStatusChanged,this.userId,this.checkUserTrust(g)))}else{await this.checkDeviceVerifications(g);const m=this.deviceList.getStoredCrossSigningForUser(g);m&&(m.updateCrossSigningVerifiedBefore(this.checkUserTrust(g).isCrossSigningVerified()),this.deviceList.setRawStoredCrossSigningForUser(g,m.toStorage())),this.emit(Qe.UserTrustStatusChanged,g,this.checkUserTrust(g))}}),(0,oe.default)(this,"onMembership",(g,m,p)=>{try{this.onRoomMembership(g,m,p)}catch(E){N.logger.error("Error handling membership change:",E)}}),(0,oe.default)(this,"onToDeviceEvent",g=>{try{N.logger.log(`received to_device ${g.getType()} from: ${g.getSender()} id: ${g.getId()}`),g.getType()=="m.room_key"||g.getType()=="m.forwarded_room_key"?this.onRoomKeyEvent(g):g.getType()=="m.room_key_request"?this.onRoomKeyRequestEvent(g):g.getType()==="m.secret.request"?this.secretStorage.onRequestReceived(g):g.getType()==="m.secret.send"?this.secretStorage.onSecretReceived(g):g.getType()==="m.room_key.withheld"||g.getType()==="org.matrix.room_key.withheld"?this.onRoomKeyWithheldEvent(g):g.getContent().transaction_id?this.onKeyVerificationMessage(g):g.getContent().msgtype==="m.bad.encrypted"?this.onToDeviceBadEncrypted(g):(g.isBeingDecrypted()||g.shouldAttemptDecryption())&&(g.isBeingDecrypted()||g.attemptDecryption(this),g.once(Bn.MatrixEventEvent.Decrypted,m=>{this.onToDeviceEvent(m)}))}catch(m){N.logger.error("Error handling toDeviceEvent:",m)}}),(0,oe.default)(this,"onTimelineEvent",(g,m,p,E,{liveEvent:I=!0}={})=>{if(!Uc.InRoomChannel.validateEvent(g,this.baseApis))return;const w=k=>{const P=new Uc.InRoomChannel(this.baseApis,k.getRoomId());return new ca.VerificationRequest(P,this.verificationMethods,this.baseApis)};this.handleVerificationEvent(g,this.inRoomVerificationRequests,w,I)}),this.reEmitter=new iM.TypedReEmitter(this),l){this.verificationMethods=new Map;for(const g of l)typeof g=="string"?sd[g]&&this.verificationMethods.set(g,sd[g]):g.NAME?this.verificationMethods.set(g.NAME,g):N.logger.warn(`Excluding unknown verification method ${g}`)}else this.verificationMethods=new Map(Object.entries(sd));this.backupManager=new lM.BackupManager(e,async()=>{const g=await this.getSessionBackupPrivateKey();if(g)return g;const m=await this.getSecret("m.megolm_backup.v1");if(m){const p=sl(m);if(p){const[E]=await this.getSecretStorageKey();await this.storeSecret("m.megolm_backup.v1",p,[E])}return Tt.decodeBase64(p||m)}if(this.baseApis.cryptoCallbacks&&this.baseApis.cryptoCallbacks.getBackupKey)return await this.baseApis.cryptoCallbacks.getBackupKey();throw new Error("Unable to get private key")}),this.olmDevice=new tm.OlmDevice(o),this.deviceList=new sM.DeviceList(e,o,this.olmDevice),this.deviceList.on(Qe.UserCrossSigningUpdated,this.onDeviceListUserCrossSigningUpdated),this.reEmitter.reEmit(this.deviceList,[Qe.DevicesUpdated,Qe.WillUpdateDevices]),this.supportedAlgorithms=Object.keys(Dc.DECRYPTION_CLASSES),this.outgoingRoomKeyRequestManager=new oM.OutgoingRoomKeyRequestManager(e,this.deviceId,this.cryptoStore),this.toDeviceVerificationRequests=new Hr.ToDeviceRequests,this.inRoomVerificationRequests=new Uc.InRoomRequests;const u=this.baseApis.cryptoCallbacks||{},a=(0,Ln.createCryptoStoreCacheCallbacks)(o,this.olmDevice);this.crossSigningInfo=new Ln.CrossSigningInfo(r,u,a),this.secretStorage=new Ws.SecretStorage(e,u,e),this.dehydrationManager=new cM.DehydrationManager(this),!u.getCrossSigningKey&&u.getSecretStorageKey&&(u.getCrossSigningKey=async g=>Ln.CrossSigningInfo.getFromSecretStorage(g,this.secretStorage))}async init({exportedOlmDevice:e,pickleKey:t}={}){N.logger.log("Crypto: initialising Olm..."),await j.Olm.init(),N.logger.log(e?"Crypto: initialising Olm device from exported device...":"Crypto: initialising Olm device..."),await this.olmDevice.init({fromExportedDevice:e,pickleKey:t}),N.logger.log("Crypto: loading device list..."),await this.deviceList.load(),this.deviceKeys["ed25519:"+this.deviceId]=this.olmDevice.deviceEd25519Key,this.deviceKeys["curve25519:"+this.deviceId]=this.olmDevice.deviceCurve25519Key,N.logger.log("Crypto: fetching own devices...");let r=this.deviceList.getRawStoredDevicesForUser(this.userId);if(r||(r={}),!r[this.deviceId]){N.logger.log("Crypto: adding this device to the store...");const i={keys:this.deviceKeys,algorithms:this.supportedAlgorithms,verified:Kn.VERIFIED,known:!0};r[this.deviceId]=i,this.deviceList.storeDevicesForUser(this.userId,r),this.deviceList.saveIfDirty()}await this.cryptoStore.doTxn("readonly",[aa.IndexedDBCryptoStore.STORE_ACCOUNT],i=>{this.cryptoStore.getCrossSigningKeys(i,s=>{s&&Object.keys(s).length!==0&&(N.logger.log("Loaded cross-signing public keys from crypto store"),this.crossSigningInfo.setKeys(s))})}),this.deviceList.startTrackingDeviceList(this.userId),N.logger.log("Crypto: checking for key backup..."),this.backupManager.checkAndStart()}getCryptoTrustCrossSignedDevices(){return this.trustCrossSignedDevices}setCryptoTrustCrossSignedDevices(e){this.trustCrossSignedDevices=e;for(const t of this.deviceList.getKnownUserIds()){const r=this.deviceList.getRawStoredDevicesForUser(t);for(const i of Object.keys(r)){const s=this.checkDeviceTrust(t,i);if(!s.isLocallyVerified()&&s.isCrossSigningVerified()){const o=this.deviceList.getStoredDevice(t,i);this.emit(Qe.DeviceVerificationChanged,t,i,o)}}}}async createRecoveryKeyFromPassphrase(e){const t=new j.Olm.PkDecryption;try{const r={};if(e){const o=await(0,aM.keyFromPassphrase)(e);r.passphrase={algorithm:"m.pbkdf2",iterations:o.iterations,salt:o.salt},r.pubkey=t.init_with_private_key(o.key)}else r.pubkey=t.generate_key();const i=t.get_private_key(),s=(0,nm.encodeRecoveryKey)(i);return{keyInfo:r,encodedPrivateKey:s,privateKey:i}}finally{t&&t.free()}}async isCrossSigningReady(){const e=this.crossSigningInfo.getId(),t=await this.crossSigningInfo.isStoredInKeyCache()||await this.crossSigningInfo.isStoredInSecretStorage(this.secretStorage);return!!(e&&t)}async isSecretStorageReady(){const e=await this.secretStorage.hasKey(),t=await this.crossSigningInfo.isStoredInSecretStorage(this.secretStorage),r=!this.backupManager.getKeyBackupEnabled()||await this.baseApis.isKeyBackupKeyStored();return!!(e&&t&&r)}async bootstrapCrossSigning({authUploadDeviceSigningKeys:e,setupNewCrossSigning:t}={}){N.logger.log("Bootstrapping cross-signing");const r=this.baseApis.cryptoCallbacks,i=new rm.EncryptionSetupBuilder(this.baseApis.store.accountData,r),s=new Ln.CrossSigningInfo(this.userId,i.crossSigningCallbacks,i.crossSigningCallbacks),o=async()=>{s.resetKeys(),await this.signObject(s.keys.master),i.addCrossSigningKeys(e,s.keys);const p=this.deviceList.getStoredDevice(this.userId,this.deviceId),E=await s.signDevice(this.userId,p);i.addKeySignature(this.userId,this.deviceId,E),this.backupManager.backupInfo&&(await s.signObject(this.backupManager.backupInfo.auth_data,"master"),i.addSessionBackup(this.backupManager.backupInfo))},c=this.crossSigningInfo.getId(),l=await this.crossSigningInfo.isStoredInKeyCache(),u=await this.crossSigningInfo.isStoredInSecretStorage(this.secretStorage),a=l||u;N.logger.log({setupNewCrossSigning:t,publicKeysOnDevice:c,privateKeysInCache:l,privateKeysInStorage:u,privateKeysExistSomewhere:a}),!a||t?(N.logger.log("Cross-signing private keys not found locally or in secret storage, creating new keys"),await o()):c&&l?N.logger.log("Cross-signing public keys trusted and private keys found locally"):u&&(N.logger.log("Cross-signing private keys not found locally, but they are available in secret storage, reading storage and caching locally"),await this.checkOwnCrossSigningTrust({allowPrivateKeyRequests:!0}));const g=i.crossSigningCallbacks.privateKeys;if(g.size&&!this.baseApis.cryptoCallbacks.saveCrossSigningKeys){const p=new Ws.SecretStorage(i.accountDataClientAdapter,i.ssssCryptoCallbacks);await p.hasKey()&&(N.logger.log("Storing new cross-signing private keys in secret storage"),await Ln.CrossSigningInfo.storeInSecretStorage(g,p))}await i.buildOperation().apply(this),await i.persist(this),N.logger.log("Cross-signing ready")}async bootstrapSecretStorage({createSecretStorageKey:e=async()=>({}),keyBackupInfo:t,setupNewKeyBackup:r,setupNewSecretStorage:i,getKeyBackupPassphrase:s}={}){N.logger.log("Bootstrapping Secure Secret Storage");const o=this.baseApis.cryptoCallbacks,c=new rm.EncryptionSetupBuilder(this.baseApis.store.accountData,o),l=new Ws.SecretStorage(c.accountDataClientAdapter,c.ssssCryptoCallbacks);let u=null;const a=async(S,T)=>{T&&(S.key=T);const{keyId:D,keyInfo:R}=await l.addKey(Ws.SECRET_STORAGE_ALGORITHM_V1_AES,S);return T&&c.ssssCryptoCallbacks.addPrivateKey(D,R,T),await l.setDefaultKeyId(D),D},g=async(S,T)=>{if(!T.mac){const D=await this.baseApis.cryptoCallbacks.getSecretStorageKey({keys:{[S]:T}},"");if(D){const R=D[1];c.ssssCryptoCallbacks.addPrivateKey(S,T,R);const{iv:L,mac:H}=await(0,id.calculateKeyCheck)(R);T.iv=L,T.mac=H,await c.setAccountData(`m.secret_storage.key.${S}`,T)}}},m=async S=>{if(this.crossSigningInfo.getId()&&await this.crossSigningInfo.isStoredInKeyCache("master"))try{N.logger.log("Adding cross-signing signature to key backup"),await this.crossSigningInfo.signObject(S,"master")}catch(T){N.logger.error("Signing key backup with cross-signing keys failed",T)}else N.logger.warn("Cross-signing keys not available, skipping signature on key backup")},p=await this.getSecretStorageKey(),[E,I]=p||[null,null],w=!i&&I&&I.algorithm===Ws.SECRET_STORAGE_ALGORITHM_V1_AES;if(N.logger.log({keyBackupInfo:t,setupNewKeyBackup:r,setupNewSecretStorage:i,storageExists:w,oldKeyInfo:I}),!w&&!t){N.logger.log("Secret storage does not exist, creating new storage key");const{keyInfo:S,privateKey:T}=await e();u=await a(S,T)}else if(!w&&t){N.logger.log("Secret storage does not exist, using key backup key");const S=await this.getSessionBackupPrivateKey()||await s(),T={};t.auth_data.private_key_salt&&t.auth_data.private_key_iterations&&(T.passphrase={algorithm:"m.pbkdf2",iterations:t.auth_data.private_key_iterations,salt:t.auth_data.private_key_salt,bits:256}),u=await a(T,S),await l.store("m.megolm_backup.v1",Tt.encodeBase64(S),[u]),await m(t.auth_data),c.addSessionBackup(t)}else N.logger.log("Secret storage exists"),I&&I.algorithm===Ws.SECRET_STORAGE_ALGORITHM_V1_AES&&await g(E,I);if(!this.baseApis.cryptoCallbacks.saveCrossSigningKeys&&await this.isCrossSigningReady()&&(u||!await this.crossSigningInfo.isStoredInSecretStorage(l))){N.logger.log("Copying cross-signing private keys from cache to secret storage");const S=await this.crossSigningInfo.getCrossSigningKeysFromCache();await Ln.CrossSigningInfo.storeInSecretStorage(S,l)}if(r&&!t){N.logger.log("Creating new message key backup version");const S=await this.baseApis.prepareKeyBackupVersion(null,{secureSecretStorage:!1}),T=(0,nm.decodeRecoveryKey)(S.recovery_key);await l.store("m.megolm_backup.v1",Tt.encodeBase64(T));const D={algorithm:S.algorithm,auth_data:S.auth_data};await m(D.auth_data),await this.signObject(D.auth_data),c.addSessionBackup(D)}const k=await l.get("m.megolm_backup.v1");if(k){N.logger.info("Got session backup key from secret storage: caching");const S=sl(k);S&&await l.store("m.megolm_backup.v1",S,[u||E]);const T=new Uint8Array(Tt.decodeBase64(S||k));await c.addSessionBackupPrivateKeyToCache(T)}else if(this.backupManager.getKeyBackupEnabled()){const S=await this.getSessionBackupPrivateKey()||await s();if(!S){N.logger.error("Key backup is enabled but couldn't get key backup key!");return}N.logger.info("Got session backup key from cache/user that wasn't in SSSS: saving to SSSS"),await l.store("m.megolm_backup.v1",Tt.encodeBase64(S))}await c.buildOperation().apply(this),await c.persist(this),N.logger.log("Secure Secret Storage ready")}addSecretStorageKey(e,t,r){return this.secretStorage.addKey(e,t,r)}hasSecretStorageKey(e){return this.secretStorage.hasKey(e)}getSecretStorageKey(e){return this.secretStorage.getKey(e)}storeSecret(e,t,r){return this.secretStorage.store(e,t,r)}getSecret(e){return this.secretStorage.get(e)}isSecretStored(e,t){return this.secretStorage.isStored(e,t)}requestSecret(e,t){return t||(t=Object.keys(this.deviceList.getRawStoredDevicesForUser(this.userId))),this.secretStorage.request(e,t)}getDefaultSecretStorageKeyId(){return this.secretStorage.getDefaultKeyId()}setDefaultSecretStorageKeyId(e){return this.secretStorage.setDefaultKeyId(e)}checkSecretStorageKey(e,t){return this.secretStorage.checkKey(e,t)}checkSecretStoragePrivateKey(e,t){let r=null;try{return r=new j.Olm.PkDecryption,r.init_with_private_key(e)===t}finally{r&&r.free()}}async getSessionBackupPrivateKey(){let e=await new Promise(t=>{this.cryptoStore.doTxn("readonly",[aa.IndexedDBCryptoStore.STORE_ACCOUNT],r=>{this.cryptoStore.getSecretStorePrivateKey(r,t,"m.megolm_backup.v1")})});if(e&&typeof e=="string"&&(e=new Uint8Array(Tt.decodeBase64(sl(e)||e)),await this.storeSessionBackupPrivateKey(e)),e&&e.ciphertext){const t=Buffer.from(this.olmDevice.pickleKey),r=await(0,id.decryptAES)(e,t,"m.megolm_backup.v1");e=Tt.decodeBase64(r)}return e}async storeSessionBackupPrivateKey(e){if(!(e instanceof Uint8Array))throw new Error(`storeSessionBackupPrivateKey expects Uint8Array, got ${e}`);const t=Buffer.from(this.olmDevice.pickleKey),r=await(0,id.encryptAES)(Tt.encodeBase64(e),t,"m.megolm_backup.v1");return this.cryptoStore.doTxn("readwrite",[aa.IndexedDBCryptoStore.STORE_ACCOUNT],i=>{this.cryptoStore.storeSecretStorePrivateKey(i,"m.megolm_backup.v1",r)})}checkCrossSigningPrivateKey(e,t){let r=null;try{return r=new j.Olm.PkSigning,r.init_with_seed(e)===t}finally{r&&r.free()}}async afterCrossSigningLocalKeyChange(){N.logger.info("Starting cross-signing key change post-processing");const e=this.deviceList.getStoredDevice(this.userId,this.deviceId),t=await this.crossSigningInfo.signDevice(this.userId,e);N.logger.info(`Starting background key sig upload for ${this.deviceId}`);const r=({shouldEmit:s=!1})=>this.baseApis.uploadKeySignatures({[this.userId]:{[this.deviceId]:t}}).then(o=>{const{failures:c}=o||{};if(Object.keys(c||[]).length>0)throw s&&this.baseApis.emit(Qe.KeySignatureUploadFailure,c,"afterCrossSigningLocalKeyChange",r),new $c.KeySignatureUploadError("Key upload failed",{failures:c});N.logger.info(`Finished background key sig upload for ${this.deviceId}`)}).catch(o=>{N.logger.error(`Error during background key sig upload for ${this.deviceId}`,o)});r({shouldEmit:!0});const i=this.baseApis.cryptoCallbacks.shouldUpgradeDeviceVerifications;if(i){N.logger.info("Starting device verification upgrade");const s={};for(const[o,c]of Object.entries(this.deviceList.crossSigningInfo)){const l=await this.checkForDeviceVerificationUpgrade(o,Ln.CrossSigningInfo.fromStorage(c,o));l&&(s[o]=l)}if(Object.keys(s).length>0){N.logger.info(`Found ${Object.keys(s).length} verif users to upgrade`);try{const o=await i({users:s});if(o)for(const c of o)c in s&&await this.baseApis.setDeviceVerified(c,s[c].crossSigningInfo.getId())}catch(o){N.logger.log("shouldUpgradeDeviceVerifications threw an error: not upgrading",o)}}N.logger.info("Finished device verification upgrade")}N.logger.info("Finished cross-signing key change post-processing")}async checkForDeviceVerificationUpgrade(e,t){const r=this.crossSigningInfo.checkUserTrust(t);if(t.firstUse&&!r.isVerified()){const i=this.deviceList.getRawStoredDevicesForUser(e),s=await this.checkForValidDeviceSignature(e,t.keys.master,i);if(s.length)return{devices:s.map(o=>il.DeviceInfo.fromStorage(i[o],o)),crossSigningInfo:t}}}async checkForValidDeviceSignature(e,t,r){const i=[];if(r&&t.signatures&&t.signatures[e])for(const s of Object.keys(t.signatures[e])){const[,o]=s.split(":",2);if(o in r&&r[o].verified===Kn.VERIFIED)try{await Tt.verifySignature(this.olmDevice,t,e,o,r[o].keys[s]),i.push(o)}catch{}}return i}getCrossSigningId(e){return this.crossSigningInfo.getId(e)}getStoredCrossSigningForUser(e){return this.deviceList.getStoredCrossSigningForUser(e)}checkUserTrust(e){const t=this.deviceList.getStoredCrossSigningForUser(e);return t?this.crossSigningInfo.checkUserTrust(t):new Ln.UserTrustLevel(!1,!1,!1)}checkDeviceTrust(e,t){const r=this.deviceList.getStoredDevice(e,t);return this.checkDeviceInfoTrust(e,r)}checkDeviceInfoTrust(e,t){const r=!!(t&&t.isVerified()),i=this.deviceList.getStoredCrossSigningForUser(e);if(t&&i){const s=this.trustCrossSignedDevices||e===this.userId;return this.crossSigningInfo.checkDeviceTrust(i,t,r,s)}else return new Ln.DeviceTrustLevel(!1,!1,r,!1)}async checkOwnCrossSigningTrust({allowPrivateKeyRequests:e=!1}={}){const t=this.userId;await this.downloadKeys([this.userId]);const r=await this.crossSigningInfo.getCrossSigningKeysFromCache(),i=this.deviceList.getStoredCrossSigningForUser(t);if(!i){N.logger.error("Got cross-signing update event for user "+t+" but no new cross-signing information found!");return}const s=i.getId(),o=this.crossSigningInfo.getId()!==s,c=i.getId()&&!r.has("master");if(o&&N.logger.info("Got new master public key",s),e&&(o||c)){N.logger.info("Attempting to retrieve cross-signing master private key");let w=null;try{w=(await this.crossSigningInfo.getCrossSigningKey("master",s))[1],N.logger.info("Got cross-signing master private key")}finally{w&&w.free()}}const l=this.crossSigningInfo.getId("self_signing"),u=this.crossSigningInfo.getId("user_signing");this.storeTrustedSelfKeys(i.keys);const a=l!==i.getId("self_signing"),g=u!==i.getId("user_signing"),m=i.getId("self_signing")&&!r.has("self_signing"),p=i.getId("user_signing")&&!r.has("user_signing"),E={};if(a&&N.logger.info("Got new self-signing key",i.getId("self_signing")),e&&(a||m)){N.logger.info("Attempting to retrieve cross-signing self-signing private key");let w=null;try{w=(await this.crossSigningInfo.getCrossSigningKey("self_signing",i.getId("self_signing")))[1],N.logger.info("Got cross-signing self-signing private key")}finally{w&&w.free()}const k=this.deviceList.getStoredDevice(this.userId,this.deviceId),P=await this.crossSigningInfo.signDevice(this.userId,k);E[this.deviceId]=P}if(g&&N.logger.info("Got new user-signing key",i.getId("user_signing")),e&&(g||p)){N.logger.info("Attempting to retrieve cross-signing user-signing private key");let w=null;try{w=(await this.crossSigningInfo.getCrossSigningKey("user_signing",i.getId("user_signing")))[1],N.logger.info("Got cross-signing user-signing private key")}finally{w&&w.free()}}if(o){const w=this.crossSigningInfo.keys.master;await this.signObject(w);const k=w.signatures[this.userId]["ed25519:"+this.deviceId];E[this.crossSigningInfo.getId()]=Object.assign({},w,{signatures:{[this.userId]:{["ed25519:"+this.deviceId]:k}}})}const I=Object.keys(E);if(I.length){const w=({shouldEmit:k=!1})=>(N.logger.info(`Starting background key sig upload for ${I}`),this.baseApis.uploadKeySignatures({[this.userId]:E}).then(P=>{const{failures:S}=P||{};if(N.logger.info(`Finished background key sig upload for ${I}`),Object.keys(S||[]).length>0)throw k&&this.baseApis.emit(Qe.KeySignatureUploadFailure,S,"checkOwnCrossSigningTrust",w),new $c.KeySignatureUploadError("Key upload failed",{failures:S})}).catch(P=>{N.logger.error(`Error during background key sig upload for ${I}`,P)}));w({shouldEmit:!0})}this.emit(Qe.UserTrustStatusChanged,t,this.checkUserTrust(t)),o&&(this.emit(Qe.KeysChanged,{}),await this.afterCrossSigningLocalKeyChange()),await this.backupManager.checkKeyBackup()}async storeTrustedSelfKeys(e){e?this.crossSigningInfo.setKeys(e):this.crossSigningInfo.clearKeys(),await this.cryptoStore.doTxn("readwrite",[aa.IndexedDBCryptoStore.STORE_ACCOUNT],t=>{this.cryptoStore.storeCrossSigningKeys(t,this.crossSigningInfo.keys)})}async checkDeviceVerifications(e){const t=this.baseApis.cryptoCallbacks.shouldUpgradeDeviceVerifications;if(!!t){if(N.logger.info(`Starting device verification upgrade for ${e}`),this.crossSigningInfo.keys.user_signing){const r=this.deviceList.getStoredCrossSigningForUser(e);if(r){const i=await this.checkForDeviceVerificationUpgrade(e,r);i&&(await t({users:{[e]:i}})).includes(e)&&await this.baseApis.setDeviceVerified(e,r.getId())}}N.logger.info(`Finished device verification upgrade for ${e}`)}}async setTrustedBackupPubKey(e){this.sessionStore.setLocalTrustedBackupPubKey(e),await this.backupManager.checkKeyBackup()}enableLazyLoading(){this.lazyLoadMembers=!0}registerEventHandlers(e){e.on(dM.RoomMemberEvent.Membership,this.onMembership),e.on(hM.ClientEvent.ToDeviceEvent,this.onToDeviceEvent),e.on(uM.RoomEvent.Timeline,this.onTimelineEvent),e.on(Bn.MatrixEventEvent.Decrypted,this.onTimelineEvent)}start(){this.outgoingRoomKeyRequestManager.start()}stop(){this.outgoingRoomKeyRequestManager.stop(),this.deviceList.stop(),this.dehydrationManager.stop()}getDeviceEd25519Key(){return this.olmDevice.deviceEd25519Key}getDeviceCurve25519Key(){return this.olmDevice.deviceCurve25519Key}setGlobalBlacklistUnverifiedDevices(e){this.globalBlacklistUnverifiedDevices=e}getGlobalBlacklistUnverifiedDevices(){return this.globalBlacklistUnverifiedDevices}setGlobalErrorOnUnknownDevices(e){this.globalErrorOnUnknownDevices=e}getGlobalErrorOnUnknownDevices(){return this.globalErrorOnUnknownDevices}uploadDeviceKeys(){const e={algorithms:this.supportedAlgorithms,device_id:this.deviceId,keys:this.deviceKeys,user_id:this.userId};return this.signObject(e).then(()=>this.baseApis.uploadKeysRequest({device_keys:e}))}updateOneTimeKeyCount(e){if(isFinite(e))this.oneTimeKeyCount=e;else throw new TypeError("Parameter for updateOneTimeKeyCount has to be a number")}setNeedsNewFallback(e){this.needsNewFallback=!!e}getNeedsNewFallback(){return this.needsNewFallback}maybeUploadOneTimeKeys(){if(this.oneTimeKeyCheckInProgress)return;const r=Date.now();if(this.lastOneTimeKeyCheck!==null&&r-this.lastOneTimeKeyCheck<6e4)return;this.lastOneTimeKeyCheck=r;const i=this.olmDevice.maxNumberOfOneTimeKeys(),s=Math.floor(i/2),o=async c=>{for(;s>c||this.getNeedsNewFallback();){if(s>c){N.logger.info("generating oneTimeKeys");const u=Math.min(s-c,5);await this.olmDevice.generateOneTimeKeys(u)}if(this.getNeedsNewFallback()){const u=await this.olmDevice.getFallbackKey();(!u.curve25519||Object.keys(u.curve25519).length==0)&&(N.logger.info("generating fallback key"),this.fallbackCleanup&&(clearTimeout(this.fallbackCleanup),delete this.fallbackCleanup),await this.olmDevice.generateFallbackKey())}N.logger.info("calling uploadOneTimeKeys");const l=await this.uploadOneTimeKeys();if(l.one_time_key_counts&&l.one_time_key_counts.signed_curve25519)c=l.one_time_key_counts.signed_curve25519;else throw new Error("response for uploading keys does not contain one_time_key_counts.signed_curve25519")}};this.oneTimeKeyCheckInProgress=!0,Promise.resolve().then(()=>this.oneTimeKeyCount!==void 0?Promise.resolve(this.oneTimeKeyCount):this.baseApis.uploadKeysRequest({}).then(c=>c.one_time_key_counts.signed_curve25519||0)).then(c=>o(c)).catch(c=>{N.logger.error("Error uploading one-time keys",c.stack||c)}).finally(()=>{this.oneTimeKeyCount=void 0,this.oneTimeKeyCheckInProgress=!1})}async uploadOneTimeKeys(){const e=[];let t;if(this.getNeedsNewFallback()){t={};const c=await this.olmDevice.getFallbackKey();for(const[l,u]of Object.entries(c.curve25519)){const a={key:u,fallback:!0};t["signed_curve25519:"+l]=a,e.push(this.signObject(a))}this.setNeedsNewFallback(!1)}const r=await this.olmDevice.getOneTimeKeys(),i={};for(const c in r.curve25519)if(r.curve25519.hasOwnProperty(c)){const l={key:r.curve25519[c]};i["signed_curve25519:"+c]=l,e.push(this.signObject(l))}await Promise.all(e);const s={one_time_keys:i};t&&(s["org.matrix.msc2732.fallback_keys"]=t,s.fallback_keys=t);const o=await this.baseApis.uploadKeysRequest(s);return t&&(this.fallbackCleanup=setTimeout(()=>{delete this.fallbackCleanup,this.olmDevice.forgetOldFallbackKey()},60*60*1e3)),await this.olmDevice.markKeysAsPublished(),o}downloadKeys(e,t){return this.deviceList.downloadKeys(e,t)}getStoredDevicesForUser(e){return this.deviceList.getStoredDevicesForUser(e)}getStoredDevice(e,t){return this.deviceList.getStoredDevice(e,t)}saveDeviceList(e){return this.deviceList.saveIfDirty(e)}async setDeviceVerification(e,t,r,i,s){r===void 0&&(r=null),i===void 0&&(i=null),s===void 0&&(s=null);const o=this.deviceList.getStoredCrossSigningForUser(e);if(o&&o.getId()===t){if(i!==null||s!==null)throw new Error("Cannot set blocked or known for a cross-signing key");if(!r)throw new Error("Cannot set a cross-signing key as unverified");if(!this.crossSigningInfo.getId()&&e===this.crossSigningInfo.userId&&(this.storeTrustedSelfKeys(o.keys),this.emit(Qe.UserTrustStatusChanged,this.userId,this.checkUserTrust(e))),e!==this.userId){N.logger.info("Master key "+o.getId()+" for "+e+" marked verified. Signing...");const m=await this.crossSigningInfo.signUser(o);if(m){const p=async({shouldEmit:E=!1})=>{N.logger.info("Uploading signature for "+e+"...");const I=await this.baseApis.uploadKeySignatures({[e]:{[t]:m}}),{failures:w}=I||{};if(Object.keys(w||[]).length>0)throw E&&this.baseApis.emit(Qe.KeySignatureUploadFailure,w,"setDeviceVerification",p),new $c.KeySignatureUploadError("Key upload failed",{failures:w})};await p({shouldEmit:!0})}return m}else return o}const c=this.deviceList.getRawStoredDevicesForUser(e);if(!c||!c[t])throw new Error("Unknown device "+e+":"+t);const l=c[t];let u=l.verified;r?u=Kn.VERIFIED:r!==null&&u==Kn.VERIFIED&&(u=Kn.UNVERIFIED),i?u=Kn.BLOCKED:i!==null&&u==Kn.BLOCKED&&(u=Kn.UNVERIFIED);let a=l.known;if(s!==null&&(a=s),(l.verified!==u||l.known!==a)&&(l.verified=u,l.known=a,this.deviceList.storeDevicesForUser(e,c),this.deviceList.saveIfDirty()),r&&e===this.userId){N.logger.info("Own device "+t+" marked verified: signing");let m;if(this.checkDeviceTrust(e,t).isCrossSigningVerified()?N.logger.log(`Own device ${t} already cross-signing verified`):m=await this.crossSigningInfo.signDevice(e,il.DeviceInfo.fromStorage(l,t)),m){const E=async({shouldEmit:I=!1})=>{N.logger.info("Uploading signature for "+t);const w=await this.baseApis.uploadKeySignatures({[e]:{[t]:m}}),{failures:k}=w||{};if(Object.keys(k||[]).length>0)throw I&&this.baseApis.emit(Qe.KeySignatureUploadFailure,k,"setDeviceVerification",E),new $c.KeySignatureUploadError("Key upload failed",{failures:k})};await E({shouldEmit:!0})}}const g=il.DeviceInfo.fromStorage(l,t);return this.emit(Qe.DeviceVerificationChanged,e,t,g),g}findVerificationRequestDMInProgress(e){return this.inRoomVerificationRequests.findRequestInProgress(e)}getVerificationRequestsToDeviceInProgress(e){return this.toDeviceVerificationRequests.getRequestsInProgress(e)}requestVerificationDM(e,t){const r=this.inRoomVerificationRequests.findRequestInProgress(t);if(r)return Promise.resolve(r);const i=new Uc.InRoomChannel(this.baseApis,t,e);return this.requestVerificationWithChannel(e,i,this.inRoomVerificationRequests)}requestVerification(e,t){t||(t=Object.keys(this.deviceList.getRawStoredDevicesForUser(e)));const r=this.toDeviceVerificationRequests.findRequestInProgress(e,t);if(r)return Promise.resolve(r);const i=new Hr.ToDeviceChannel(this.baseApis,e,t,Hr.ToDeviceChannel.makeTransactionId());return this.requestVerificationWithChannel(e,i,this.toDeviceVerificationRequests)}async requestVerificationWithChannel(e,t,r){let i=new ca.VerificationRequest(t,this.verificationMethods,this.baseApis);t.transactionId&&r.setRequestByChannel(t,i),await i.sendRequest();const s=r.getRequestByChannel(t);return s?i=s:(N.logger.log(`Crypto: adding new request to requestsByTxnId with id ${t.transactionId} ${t.roomId}`),r.setRequestByChannel(t,i)),i}beginKeyVerification(e,t,r,i=null){let s;if(i){if(s=this.toDeviceVerificationRequests.getRequestBySenderAndTxnId(t,i),!s)throw new Error(`No request found for user ${t} with transactionId ${i}`)}else{i=Hr.ToDeviceChannel.makeTransactionId();const o=new Hr.ToDeviceChannel(this.baseApis,t,[r],i,r);s=new ca.VerificationRequest(o,this.verificationMethods,this.baseApis),this.toDeviceVerificationRequests.setRequestBySenderAndTxnId(t,i,s)}return s.beginKeyVerification(e,{userId:t,deviceId:r})}async legacyDeviceVerification(e,t,r){const i=Hr.ToDeviceChannel.makeTransactionId(),s=new Hr.ToDeviceChannel(this.baseApis,e,[t],i,t),o=new ca.VerificationRequest(s,this.verificationMethods,this.baseApis);this.toDeviceVerificationRequests.setRequestBySenderAndTxnId(e,i,o);const c=o.beginKeyVerification(r,{userId:e,deviceId:t});return await Promise.race([c.verify(),o.waitFor(l=>l.started)]),o}async getOlmSessionsForUser(e){const t=this.getStoredDevicesForUser(e)||[],r={};for(let i=0;i<t.length;++i){const s=t[i],o=s.getIdentityKey(),c=await this.olmDevice.getSessionInfoForDevice(o);r[s.deviceId]={deviceIdKey:o,sessions:c}}return r}getEventSenderDeviceInfo(e){const t=e.getSenderKey(),r=e.getWireContent().algorithm;if(!t||!r||e.getForwardingCurve25519KeyChain().length>0||e.isKeySourceUntrusted())return null;const s=this.deviceList.getDeviceByIdentityKey(r,t);if(s===null)return null;const o=e.getClaimedEd25519Key();return o?o!==s.getFingerprint()?(N.logger.warn("Event "+e.getId()+" claims ed25519 key "+o+" but sender device has key "+s.getFingerprint()),null):s:(N.logger.warn("Event "+e.getId()+" claims no ed25519 key: cannot verify sending device"),null)}getEventEncryptionInfo(e){const t={};if(t.senderKey=e.getSenderKey(),t.algorithm=e.getWireContent().algorithm,!t.senderKey||!t.algorithm)return t.encrypted=!1,t;t.encrypted=!0,e.getForwardingCurve25519KeyChain().length>0||e.isKeySourceUntrusted()?t.authenticated=!1:t.authenticated=!0,t.sender=this.deviceList.getDeviceByIdentityKey(t.algorithm,t.senderKey);const i=e.getClaimedEd25519Key();return i||(N.logger.warn("Event "+e.getId()+" claims no ed25519 key: cannot verify sending device"),t.mismatchedSender=!0),t.sender&&i!==t.sender.getFingerprint()&&(N.logger.warn("Event "+e.getId()+" claims ed25519 key "+i+"but sender device has key "+t.sender.getFingerprint()),t.mismatchedSender=!0),t}forceDiscardSession(e){const t=this.roomEncryptors[e];if(t===void 0)throw new Error("Room not encrypted");if(t.forceDiscardSession===void 0)throw new Error("Room encryption algorithm doesn't support session discarding");t.forceDiscardSession()}async setRoomEncryption(e,t,r){if(!t.algorithm){N.logger.log("Ignoring setRoomEncryption with no algorithm");return}const i=this.roomList.getRoomEncryption(e);if(i&&JSON.stringify(i)!=JSON.stringify(t)){N.logger.error("Ignoring m.room.encryption event which requests a change of config in "+e);return}if(this.roomEncryptors[e])return;let o=null;i||(o=this.roomList.setRoomEncryption(e,t));const c=Dc.ENCRYPTION_CLASSES[t.algorithm];if(!c)throw new Error("Unable to encrypt with "+t.algorithm);const l=new c({userId:this.userId,deviceId:this.deviceId,crypto:this,olmDevice:this.olmDevice,baseApis:this.baseApis,roomId:e,config:t});this.roomEncryptors[e]=l,o&&await o,this.lazyLoadMembers?N.logger.log("Enabling encryption in "+e):(N.logger.log("Enabling encryption in "+e+"; starting to track device lists for all users therein"),await this.trackRoomDevices(e),r||this.deviceList.refreshOutdatedDeviceLists())}trackRoomDevices(e){const t=async()=>{if(!this.roomEncryptors[e])return;const i=this.clientStore.getRoom(e);if(!i)throw new Error(`Unable to start tracking devices in unknown room ${e}`);N.logger.log(`Starting to track devices for room ${e} ...`),(await i.getEncryptionTargetMembers()).forEach(o=>{this.deviceList.startTrackingDeviceList(o.userId)})};let r=this.roomDeviceTrackingState[e];return r||(r=t(),this.roomDeviceTrackingState[e]=r.catch(i=>{throw this.roomDeviceTrackingState[e]=null,i})),r}ensureOlmSessionsForUsers(e,t){const r={};for(let i=0;i<e.length;++i){const s=e[i];r[s]=[];const o=this.getStoredDevicesForUser(s)||[];for(let c=0;c<o.length;++c){const l=o[c];l.getIdentityKey()!=this.olmDevice.deviceCurve25519Key&&l.verified!=Kn.BLOCKED&&r[s].push(l)}}return Tt.ensureOlmSessionsForDevices(this.olmDevice,this.baseApis,r,t)}async exportRoomKeys(){const e=[];return await this.cryptoStore.doTxn("readonly",[aa.IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS],t=>{this.cryptoStore.getAllEndToEndInboundGroupSessions(t,r=>{if(r===null)return;const i=this.olmDevice.exportInboundGroupSession(r.senderKey,r.sessionId,r.sessionData);delete i.first_known_index,i.algorithm=Tt.MEGOLM_ALGORITHM,e.push(i)})}),e}importRoomKeys(e,t={}){let r=0,i=0;const s=e.length;function o(){t.progressCallback({stage:"load_keys",successes:r,failures:i,total:s})}return Promise.all(e.map(c=>!c.room_id||!c.algorithm?(N.logger.warn("ignoring room key entry with missing fields",c),i++,t.progressCallback&&o(),null):this.getRoomDecryptor(c.room_id,c.algorithm).importRoomKey(c,t).finally(()=>{r++,t.progressCallback&&o()}))).then()}countSessionsNeedingBackup(){return this.backupManager.countSessionsNeedingBackup()}prepareToEncrypt(e){const t=this.roomEncryptors[e.roomId];t&&t.prepareToEncrypt(e)}async encryptEvent(e,t){if(!t)throw new Error("Cannot send encrypted messages in unknown rooms");const r=e.getRoomId(),i=this.roomEncryptors[r];if(!i)throw new Error("Room was previously configured to use encryption, but is no longer. Perhaps the homeserver is hiding the configuration event.");this.roomDeviceTrackingState[r]||this.trackRoomDevices(r),await this.roomDeviceTrackingState[r];let s=e.getContent();const o=s["m.relates_to"];o&&(s=Object.assign({},s),delete s["m.relates_to"]);const c=s["io.element.performance_metrics"];c&&(s=Object.assign({},s),delete s["io.element.performance_metrics"]);const l=await i.encryptMessage(t,e.getType(),s);o&&(l["m.relates_to"]=o),c&&(l["io.element.performance_metrics"]=c),e.makeEncrypted("m.room.encrypted",l,this.olmDevice.deviceCurve25519Key,this.olmDevice.deviceEd25519Key)}async decryptEvent(e){if(e.isRedacted()){const t=new Bn.MatrixEvent(e.getUnsigned().redacted_because),r=await this.decryptEvent(t);return{clearEvent:{room_id:e.getRoomId(),type:"m.room.message",content:{},unsigned:{redacted_because:r.clearEvent}}}}else{const t=e.getWireContent();return await this.getRoomDecryptor(e.getRoomId(),t.algorithm).decryptEvent(e)}}async handleDeviceListChanges(e,t){!e.oldSyncToken||await this.evalDeviceListChanges(t)}requestRoomKey(e,t,r=!1){return this.outgoingRoomKeyRequestManager.queueRoomKeyRequest(e,t,r).then(()=>{this.sendKeyRequestsImmediately&&this.outgoingRoomKeyRequestManager.sendQueuedRequests()}).catch(i=>{N.logger.error("Error requesting key for event",i)})}cancelRoomKeyRequest(e){this.outgoingRoomKeyRequestManager.cancelRoomKeyRequest(e).catch(t=>{N.logger.warn("Error clearing pending room key requests",t)})}async cancelAndResendAllOutgoingKeyRequests(){await this.outgoingRoomKeyRequestManager.cancelAndResendAllOutgoingRequests()}async onCryptoEvent(e){const t=e.getRoomId(),r=e.getContent();try{await this.setRoomEncryption(t,r,!0)}catch(i){N.logger.error("Error configuring encryption in room "+t+":",i)}}async onSyncWillProcess(e){e.oldSyncToken||(N.logger.log("Initial sync performed - resetting device tracking state"),this.deviceList.stopTrackingAllDeviceLists(),this.deviceList.startTrackingDeviceList(this.userId),this.roomDeviceTrackingState={}),this.sendKeyRequestsImmediately=!1}async onSyncCompleted(e){this.deviceList.setSyncToken(e.nextSyncToken),this.deviceList.saveIfDirty(),this.deviceList.startTrackingDeviceList(this.userId),this.deviceList.refreshOutdatedDeviceLists(),e.catchingUp||(this.maybeUploadOneTimeKeys(),this.processReceivedRoomKeyRequests(),this.outgoingRoomKeyRequestManager.sendQueuedRequests(),this.sendKeyRequestsImmediately=!0)}async evalDeviceListChanges(e){if(e.changed&&Array.isArray(e.changed)&&e.changed.forEach(t=>{this.deviceList.invalidateUserDeviceList(t)}),e.left&&Array.isArray(e.left)&&e.left.length){const t=new Set(await this.getTrackedE2eUsers());e.left.forEach(r=>{t.has(r)||this.deviceList.stopTrackingDeviceList(r)})}}async getTrackedE2eUsers(){const e=[];for(const t of this.getTrackedE2eRooms()){const r=await t.getEncryptionTargetMembers();for(const i of r)e.push(i.userId)}return e}getTrackedE2eRooms(){return this.clientStore.getRooms().filter(e=>{if(!this.roomEncryptors[e.roomId]||!this.roomDeviceTrackingState[e.roomId])return!1;const r=e.getMyMembership();return r==="join"||r==="invite"})}onRoomKeyEvent(e){const t=e.getContent();if(!t.room_id||!t.algorithm){N.logger.error("key event is missing fields");return}this.backupManager.checkedForBackup||this.backupManager.checkAndStart(),this.getRoomDecryptor(t.room_id,t.algorithm).onRoomKeyEvent(e)}onRoomKeyWithheldEvent(e){const t=e.getContent();if(t.code!=="m.no_olm"&&(!t.room_id||!t.session_id)||!t.algorithm||!t.sender_key){N.logger.error("key withheld event is missing fields");return}N.logger.info(`Got room key withheld event from ${e.getSender()} (${t.sender_key}) for ${t.algorithm}/${t.room_id}/${t.session_id} with reason ${t.code} (${t.reason})`);const r=this.getRoomDecryptor(t.room_id,t.algorithm);if(r.onRoomKeyWithheldEvent&&r.onRoomKeyWithheldEvent(e),!t.room_id){const i=this.getRoomDecryptors(t.algorithm);for(const s of i)s.retryDecryptionFromSender(t.sender_key)}}onKeyVerificationMessage(e){if(!Hr.ToDeviceChannel.validateEvent(e,this.baseApis))return;const t=r=>{if(!Hr.ToDeviceChannel.canCreateRequest(Hr.ToDeviceChannel.getEventType(r)))return;const i=r.getContent(),s=i&&i.from_device;if(!s)return;const o=r.getSender(),c=new Hr.ToDeviceChannel(this.baseApis,o,[s]);return new ca.VerificationRequest(c,this.verificationMethods,this.baseApis)};this.handleVerificationEvent(e,this.toDeviceVerificationRequests,t)}async handleVerificationEvent(e,t,r,i=!0){if(e.isSending()&&e.status!=Bn.EventStatus.SENT){let l,u;try{await new Promise((a,g)=>{l=a,u=()=>{e.status==Bn.EventStatus.CANCELLED&&g(new Error("Event status set to CANCELLED."))},e.once(Bn.MatrixEventEvent.LocalEventIdReplaced,l),e.on(Bn.MatrixEventEvent.Status,u)})}catch(a){N.logger.error("error while waiting for the verification event to be sent: "+a.message);return}finally{e.removeListener(Bn.MatrixEventEvent.LocalEventIdReplaced,l),e.removeListener(Bn.MatrixEventEvent.Status,u)}}let s=t.getRequest(e),o=!1;if(!s){if(s=r(e),!s){N.logger.log(`Crypto: could not find VerificationRequest for ${e.getType()}, and could not create one, so ignoring.`);return}o=!0,t.setRequest(e,s)}e.setVerificationRequest(s);try{await s.channel.handleEvent(e,s,i)}catch(l){N.logger.error("error while handling verification event: "+l.message)}o&&!s.initiatedByMe&&!s.invalid&&!s.observeOnly&&this.baseApis.emit(Qe.VerificationRequest,s)}async onToDeviceBadEncrypted(e){const t=e.getWireContent(),r=e.getSender(),i=t.algorithm,s=t.sender_key,o=()=>{const m=this.getRoomDecryptors(Tt.MEGOLM_ALGORITHM);for(const p of m)p.retryDecryptionFromSender(s)};if(r===void 0||s===void 0||s===void 0)return;this.lastNewSessionForced[r]=this.lastNewSessionForced[r]||{};const c=this.lastNewSessionForced[r][s]||0;if(c+mM>Date.now()){N.logger.debug("New session already forced with device "+r+":"+s+" at "+c+": not forcing another"),await this.olmDevice.recordSessionProblem(s,"wedged",!0),o();return}let l=this.deviceList.getDeviceByIdentityKey(i,s);if(!l&&(await this.downloadKeys([r],!1),l=this.deviceList.getDeviceByIdentityKey(i,s),!l)){N.logger.info("Couldn't find device for identity key "+s+": not re-establishing session"),await this.olmDevice.recordSessionProblem(s,"wedged",!1),o();return}const u={};u[r]=[l],await Tt.ensureOlmSessionsForDevices(this.olmDevice,this.baseApis,u,!0),this.lastNewSessionForced[r][s]=Date.now();const a={algorithm:Tt.OLM_ALGORITHM,sender_key:this.olmDevice.deviceCurve25519Key,ciphertext:{}};await Tt.encryptMessageForDevice(a.ciphertext,this.userId,this.deviceId,this.olmDevice,r,l,{type:"m.dummy"}),await this.olmDevice.recordSessionProblem(s,"wedged",!0),o(),await this.baseApis.sendToDevice("m.room.encrypted",{[r]:{[l.deviceId]:a}});const g=await this.outgoingRoomKeyRequestManager.getOutgoingSentRoomKeyRequest(r,l.deviceId);for(const m of g)this.requestRoomKey(m.requestBody,m.recipients,!0)}onRoomMembership(e,t,r){const i=t.roomId,s=this.roomEncryptors[i];!s||(this.roomDeviceTrackingState[i]&&(t.membership=="join"?(N.logger.log("Join event for "+t.userId+" in "+i),this.deviceList.startTrackingDeviceList(t.userId)):t.membership=="invite"&&this.clientStore.getRoom(i).shouldEncryptForInvitedMembers()&&(N.logger.log("Invite event for "+t.userId+" in "+i),this.deviceList.startTrackingDeviceList(t.userId))),s.onRoomMembership(e,t,r))}onRoomKeyRequestEvent(e){const t=e.getContent();if(t.action==="request"){const r=new S_(e);this.receivedRoomKeyRequests.push(r)}else if(t.action==="request_cancellation"){const r=new vM(e);this.receivedRoomKeyRequestCancellations.push(r)}}async processReceivedRoomKeyRequests(){if(!this.processingRoomKeyRequests){this.processingRoomKeyRequests=!0;try{const e=this.receivedRoomKeyRequests;this.receivedRoomKeyRequests=[];const t=this.receivedRoomKeyRequestCancellations;this.receivedRoomKeyRequestCancellations=[],await Promise.all(e.map(r=>this.processReceivedRoomKeyRequest(r))),await Promise.all(t.map(r=>this.processReceivedRoomKeyRequestCancellation(r)))}catch(e){N.logger.error(`Error processing room key requsts: ${e}`)}finally{this.processingRoomKeyRequests=!1}}}async processReceivedRoomKeyRequest(e){const t=e.userId,r=e.deviceId,i=e.requestBody,s=i.room_id,o=i.algorithm;if(N.logger.log(`m.room_key_request from ${t}:${r} for ${s} / ${i.session_id} (id ${e.requestId})`),t!==this.userId){if(!this.roomEncryptors[s]){N.logger.debug(`room key request for unencrypted room ${s}`);return}const l=this.roomEncryptors[s],u=this.deviceList.getStoredDevice(t,r);if(!u){N.logger.debug(`Ignoring keyshare for unknown device ${t}:${r}`);return}try{await l.reshareKeyWithDevice(i.sender_key,i.session_id,t,u)}catch(a){N.logger.warn("Failed to re-share keys for session "+i.session_id+" with device "+t+":"+u.deviceId,a)}return}if(r===this.deviceId){N.logger.log("Ignoring room key request from ourselves");return}if(!this.roomDecryptors[s]){N.logger.log(`room key request for unencrypted room ${s}`);return}const c=this.roomDecryptors[s][o];if(!c){N.logger.log(`room key request for unknown alg ${o} in room ${s}`);return}if(!await c.hasKeysForKeyRequest(e)){N.logger.log(`room key request for unknown session ${s} / `+i.session_id);return}if(e.share=()=>{c.shareKeysWithDevice(e)},this.checkDeviceTrust(t,r).isVerified()){N.logger.log("device is already verified: sharing keys"),e.share();return}this.emit(Qe.RoomKeyRequest,e)}async processReceivedRoomKeyRequestCancellation(e){N.logger.log(`m.room_key_request cancellation for ${e.userId}:${e.deviceId} (id ${e.requestId})`),this.emit(Qe.RoomKeyRequestCancellation,e)}getRoomDecryptor(e,t){let r,i;if(e=e||null,e&&(r=this.roomDecryptors[e],r||(this.roomDecryptors[e]=r={}),i=r[t],i))return i;const s=Dc.DECRYPTION_CLASSES[t];if(!s)throw new Dc.DecryptionError("UNKNOWN_ENCRYPTION_ALGORITHM",'Unknown encryption algorithm "'+t+'".');return i=new s({userId:this.userId,crypto:this,olmDevice:this.olmDevice,baseApis:this.baseApis,roomId:e}),r&&(r[t]=i),i}getRoomDecryptors(e){const t=[];for(const r of Object.values(this.roomDecryptors))e in r&&t.push(r[e]);return t}async signObject(e){const t=e.signatures||{},r=e.unsigned;delete e.signatures,delete e.unsigned,t[this.userId]=t[this.userId]||{},t[this.userId]["ed25519:"+this.deviceId]=await this.olmDevice.sign(nM.default.stringify(e)),e.signatures=t,r!==void 0&&(e.unsigned=r)}}Kt.Crypto=yM;function sl(n){if(typeof n!="string"||n.indexOf(",")<0)return null;const e=Uint8Array.from(n.split(","),t=>parseInt(t));return Tt.encodeBase64(e)}class S_{constructor(e){(0,oe.default)(this,"userId",void 0),(0,oe.default)(this,"deviceId",void 0),(0,oe.default)(this,"requestId",void 0),(0,oe.default)(this,"requestBody",void 0),(0,oe.default)(this,"share",void 0);const t=e.getContent();this.userId=e.getSender(),this.deviceId=t.requesting_device_id,this.requestId=t.request_id,this.requestBody=t.body||{},this.share=()=>{throw new Error("don't know how to share keys for this request yet")}}}Kt.IncomingRoomKeyRequest=S_;class vM{constructor(e){(0,oe.default)(this,"userId",void 0),(0,oe.default)(this,"deviceId",void 0),(0,oe.default)(this,"requestId",void 0);const t=e.getContent();this.userId=e.getSender(),this.deviceId=t.requesting_device_id,this.requestId=t.request_id}}var Ql={},Zl={},_M=V.exports;Object.defineProperty(Zl,"__esModule",{value:!0});Zl.EventContext=void 0;var od=_M(Y.exports),Hs=Ft;class EM{constructor(e){(0,od.default)(this,"timeline",void 0),(0,od.default)(this,"ourEventIndex",0),(0,od.default)(this,"paginateTokens",{[Hs.Direction.Backward]:null,[Hs.Direction.Forward]:null}),this.timeline=[e]}getEvent(){return this.timeline[this.ourEventIndex]}getTimeline(){return this.timeline}getOurEventIndex(){return this.ourEventIndex}getPaginateToken(e=!1){return this.paginateTokens[e?Hs.Direction.Backward:Hs.Direction.Forward]}setPaginateToken(e,t=!1){this.paginateTokens[t?Hs.Direction.Backward:Hs.Direction.Forward]=e}addEvents(e,t=!1){t?(this.timeline=e.concat(this.timeline),this.ourEventIndex+=e.length):this.timeline=this.timeline.concat(e)}}Zl.EventContext=EM;Object.defineProperty(Ql,"__esModule",{value:!0});Ql.SearchResult=void 0;var SM=Zl;class _f{static fromJson(e,t){const r=e.context||{},i=r.events_before||[],s=r.events_after||[],o=new SM.EventContext(t(e.result));return o.setPaginateToken(r.start,!0),o.addEvents(i.map(t),!0),o.addEvents(s.map(t),!1),o.setPaginateToken(r.end,!1),new _f(e.rank,o)}constructor(e,t){this.rank=e,this.context=t}}Ql.SearchResult=_f;var ic={};Object.defineProperty(ic,"__esModule",{value:!0});ic.CrossSigningKey=void 0;let kh;ic.CrossSigningKey=kh;(function(n){n.Master="master",n.SelfSigning="self_signing",n.UserSigning="user_signing"})(kh||(ic.CrossSigningKey=kh={}));var Ef={};Object.defineProperty(Ef,"__esModule",{value:!0});Ef.eventMapperFor=bM;var xc=qt;function bM(n,e){const t=Boolean(e.preventReEmit),r=e.decrypt!==!1;function i(s){const o=new xc.MatrixEvent(s),c=n.getRoom(o.getRoomId());return c!=null&&c.threads.has(o.getId())&&o.setThread(c.threads.get(o.getId())),o.isEncrypted()&&(t||n.reEmitter.reEmit(o,[xc.MatrixEventEvent.Decrypted]),r&&n.decryptEventIfNeeded(o)),t||n.reEmitter.reEmit(o,[xc.MatrixEventEvent.Replaced,xc.MatrixEventEvent.VisibilityChange]),o}return i}var Zn={},eu={},wM=V.exports;Object.defineProperty(eu,"__esModule",{value:!0});eu.MSC3089Branch=void 0;var RM=wM(Y.exports),Ys=ne,IM=Ft;function sm(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function Ri(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?sm(Object(t),!0).forEach(function(r){(0,RM.default)(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):sm(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}class TM{constructor(e,t,r){this.client=e,this.indexEvent=t,this.directory=r}get id(){const e=this.indexEvent.getStateKey();if(!e)throw new Error("State key not found for branch");return e}get isActive(){return this.indexEvent.getContent().active===!0}get version(){var e;return(e=this.indexEvent.getContent().version)!==null&&e!==void 0?e:1}get roomId(){return this.indexEvent.getRoomId()}async delete(){await this.client.sendStateEvent(this.roomId,Ys.UNSTABLE_MSC3089_BRANCH.name,{},this.id),await this.client.redactEvent(this.roomId,this.id);const e=(await this.getVersionHistory())[1];e&&await e.delete()}getName(){return this.indexEvent.getContent().name||"Unnamed File"}async setName(e){await this.client.sendStateEvent(this.roomId,Ys.UNSTABLE_MSC3089_BRANCH.name,Ri(Ri({},this.indexEvent.getContent()),{},{name:e}),this.id)}isLocked(){return this.indexEvent.getContent().locked||!1}async setLocked(e){await this.client.sendStateEvent(this.roomId,Ys.UNSTABLE_MSC3089_BRANCH.name,Ri(Ri({},this.indexEvent.getContent()),{},{locked:e}),this.id)}async getFileInfo(){const t=(await this.getFileEvent()).getOriginalContent().file,r=this.client.mxcUrlToHttp(t.url);if(!r)throw new Error(`No HTTP URL available for ${t.url}`);return{info:t,httpUrl:r}}async getFileEvent(){const e=this.client.getRoom(this.roomId);if(!e)throw new Error("Unknown room");let t=e.getUnfilteredTimelineSet().findEventById(this.id);for(;!t&&e.getLiveTimeline().getState(IM.EventTimeline.BACKWARDS).paginationToken;)await this.client.scrollback(e,100),t=e.getUnfilteredTimelineSet().findEventById(this.id);if(!t)throw new Error("Failed to find event");return await this.client.decryptEventIfNeeded(t,{emit:!0,isRetry:!0}),t}async createNewVersion(e,t,r,i){const s=await this.directory.createFile(e,t,r,Ri(Ri({},i!=null?i:{}),{},{"m.new_content":!0,"m.relates_to":{rel_type:Ys.RelationType.Replace,event_id:this.id}}));return await this.client.sendStateEvent(this.roomId,Ys.UNSTABLE_MSC3089_BRANCH.name,{active:!0,name:e,version:this.version+1},s.event_id),await this.client.sendStateEvent(this.roomId,Ys.UNSTABLE_MSC3089_BRANCH.name,Ri(Ri({},this.indexEvent.getContent()),{},{active:!1}),this.id),s}async getVersionHistory(){const e=[];e.push(this);const t=this.client.getRoom(this.roomId);if(!t)throw new Error("Invalid or unknown room");const r=[...t.getLiveTimeline().getEvents()].reverse();let i,s=await this.getFileEvent();do if(i=r.find(o=>o.replacingEventId()===s.getId()),i){const o=this.directory.getFile(i.getId());if(o)e.push(o),s=i;else break}while(i);return e}}eu.MSC3089Branch=TM;var b_=V.exports;Object.defineProperty(Zn,"__esModule",{value:!0});Zn.TreePermissions=DM=Zn.MSC3089TreeSpace=MM=Zn.DEFAULT_TREE_POWER_LEVELS_TEMPLATE=void 0;var w_=b_(Y.exports),OM=b_(Wa.exports),Ee=ne,kM=ie,Jt=G,om=eu,CM=hf;function am(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function Wi(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?am(Object(t),!0).forEach(function(r){(0,w_.default)(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):am(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}const PM={invite:100,kick:100,ban:100,redact:50,state_default:50,events_default:50,users_default:0,events:{[Ee.EventType.RoomPowerLevels]:100,[Ee.EventType.RoomHistoryVisibility]:100,[Ee.EventType.RoomTombstone]:100,[Ee.EventType.RoomEncryption]:100,[Ee.EventType.RoomName]:50,[Ee.EventType.RoomMessage]:50,[Ee.EventType.RoomMessageEncrypted]:50,[Ee.EventType.Sticker]:50},users:{}};var MM=Zn.DEFAULT_TREE_POWER_LEVELS_TEMPLATE=PM;let Yn;Zn.TreePermissions=Yn;(function(n){n.Viewer="viewer",n.Editor="editor",n.Owner="owner"})(Yn||(Zn.TreePermissions=Yn={}));class AM{constructor(e,t){if(this.client=e,this.roomId=t,(0,w_.default)(this,"room",void 0),this.room=this.client.getRoom(this.roomId),!this.room)throw new Error("Unknown room")}get id(){return this.roomId}get isTopLevel(){const e=this.room.currentState.getStateEvents(Ee.EventType.SpaceParent);return e!=null&&e.length?e.every(t=>{var r;return!((r=t.getContent())!==null&&r!==void 0&&r.via)}):!0}async setName(e){await this.client.sendStateEvent(this.roomId,Ee.EventType.RoomName,{name:e},"")}async invite(e,t=!0,r=!0){const i=[this.retryInvite(e)];return t&&i.push(...this.getDirectories().map(s=>s.invite(e,t,r))),Promise.all(i).then(()=>{r&&(0,CM.isRoomSharedHistory)(this.room)&&this.client.sendSharedHistoryKeys(this.roomId,[e])})}retryInvite(e){return(0,Jt.simpleRetryOperation)(async()=>{await this.client.invite(this.roomId,e).catch(t=>{throw(t==null?void 0:t.errcode)==="M_FORBIDDEN"?new OM.default.AbortError(t):t})})}async setPermissions(e,t){var r;const i=this.room.currentState.getStateEvents(Ee.EventType.RoomPowerLevels,"");if(Array.isArray(i))throw new Error("Unexpected return type for power levels");const s=i.getContent()||{},o=s.users_default||0,c=s.events_default||50,l=((r=s.events)===null||r===void 0?void 0:r[Ee.EventType.RoomPowerLevels])||100,u=s.users||{};switch(t){case Yn.Viewer:u[e]=o;break;case Yn.Editor:u[e]=c;break;case Yn.Owner:u[e]=l;break;default:throw new Error("Invalid role: "+t)}s.users=u,await this.client.sendStateEvent(this.roomId,Ee.EventType.RoomPowerLevels,s,"")}getPermissions(e){var t,r;const i=this.room.currentState.getStateEvents(Ee.EventType.RoomPowerLevels,"");if(Array.isArray(i))throw new Error("Unexpected return type for power levels");const s=i.getContent()||{},o=s.users_default||0,c=s.events_default||50,l=((t=s.events)===null||t===void 0?void 0:t[Ee.EventType.RoomPowerLevels])||100,u=((r=s.users)===null||r===void 0?void 0:r[e])||o;return u>=l?Yn.Owner:u>=c?Yn.Editor:Yn.Viewer}async createDirectory(e){const t=await this.client.unstableCreateFileTree(e);return await this.client.sendStateEvent(this.roomId,Ee.EventType.SpaceChild,{via:[this.client.getDomain()]},t.roomId),await this.client.sendStateEvent(t.roomId,Ee.EventType.SpaceParent,{via:[this.client.getDomain()]},this.roomId),t}getDirectories(){const e=[],t=this.room.currentState.getStateEvents(Ee.EventType.SpaceChild);for(const r of t)try{const i=r.getStateKey();if(i){const s=this.client.unstableGetFileTreeSpace(i);s&&e.push(s)}}catch(i){kM.logger.warn("Unable to create tree space instance for listing. Are we joined?",i)}return e}getDirectory(e){return this.getDirectories().find(t=>t.roomId===e)}async delete(){const e=this.getDirectories();for(const i of e)await i.delete();const t=["invite","knock","join"],r=this.room.currentState.getStateEvents(Ee.EventType.RoomMember);for(const i of r)if(i.getStateKey()!==this.client.getUserId()&&t.includes(i.getContent().membership)){const o=i.getStateKey();if(!o)throw new Error("State key not found for branch");await this.client.kick(this.roomId,o,"Room deleted")}await this.client.leave(this.roomId)}getOrderedChildren(e){const t=e.map(r=>({roomId:r.getStateKey(),order:r.getContent().order})).filter(r=>r.roomId);return t.sort((r,i)=>{if(r.order&&!i.order)return-1;if(!r.order&&i.order)return 1;if(!r.order&&!i.order){var s,o,c,l;const u=this.client.getRoom(r.roomId),a=this.client.getRoom(i.roomId);if(!u||!a)return(0,Jt.lexicographicCompare)(r.roomId,i.roomId);const g=(s=(o=u.currentState.getStateEvents(Ee.EventType.RoomCreate,""))===null||o===void 0?void 0:o.getTs())!==null&&s!==void 0?s:0,m=(c=(l=a.currentState.getStateEvents(Ee.EventType.RoomCreate,""))===null||l===void 0?void 0:l.getTs())!==null&&c!==void 0?c:0;return g===m?(0,Jt.lexicographicCompare)(r.roomId,i.roomId):g-m}else return(0,Jt.lexicographicCompare)(r.order,i.order)}),t}getParentRoom(){const t=this.room.currentState.getStateEvents(Ee.EventType.SpaceParent)[0];if(!t)throw new Error("Expected to have a parent in a non-top level space");const r=t.getStateKey();if(!r)throw new Error("No state key found for parent");const i=this.client.getRoom(r);if(!i)throw new Error("Unable to locate room for parent");return i}getOrder(){if(this.isTopLevel)return-1;const t=this.getParentRoom().currentState.getStateEvents(Ee.EventType.SpaceChild);return this.getOrderedChildren(t).findIndex(i=>i.roomId===this.roomId)}async setOrder(e){var t;if(this.isTopLevel)throw new Error("Cannot set order of top level spaces currently");const r=this.getParentRoom(),i=r.currentState.getStateEvents(Ee.EventType.SpaceChild),s=this.getOrderedChildren(i);e=Math.max(Math.min(e,s.length-1),0);const c=this.getOrder()<e;c&&e===s.length-1?e--:!c&&e===0&&e++;const l=s[c?e:e-1],u=s[c?e+1:e];let a=Jt.DEFAULT_ALPHABET[0],g=!1;if(!l)u!=null&&u.order&&(a=(0,Jt.prevString)(u.order));else if(e===s.length-1)u!=null&&u.order&&(a=(0,Jt.nextString)(u.order));else{const I=l==null?void 0:l.order,w=u==null?void 0:u.order;I&&w?I===w?a=(0,Jt.nextString)(I):a=(0,Jt.averageBetweenStrings)(I,w):I?a=(0,Jt.nextString)(I):w?a=(0,Jt.prevString)(w):g=!0}if(g){let I;for(let w=0;w<=e;w++){const k=s[w];if(w===0&&(I=k.order),k.order)I=k.order;else{var m;I=I?(0,Jt.nextString)(I):Jt.DEFAULT_ALPHABET[0];const P=r.currentState.getStateEvents(Ee.EventType.SpaceChild,k.roomId),S=(m=P==null?void 0:P.getContent())!==null&&m!==void 0?m:{via:[this.client.getDomain()]};await this.client.sendStateEvent(r.roomId,Ee.EventType.SpaceChild,Wi(Wi({},S),{},{order:I}),k.roomId)}}I&&(a=(0,Jt.nextString)(I))}const p=r.currentState.getStateEvents(Ee.EventType.SpaceChild,this.roomId),E=(t=p==null?void 0:p.getContent())!==null&&t!==void 0?t:{via:[this.client.getDomain()]};await this.client.sendStateEvent(r.roomId,Ee.EventType.SpaceChild,Wi(Wi({},E),{},{order:a}),this.roomId)}async createFile(e,t,r,i){var s;const o=await this.client.uploadContent(t,{includeFilename:!1,onlyContentUri:!0,rawResponse:!1});r.url=o;const c={msgtype:Ee.MsgType.File,body:e,url:o,file:r};i=(s=i)!==null&&s!==void 0?s:{},i["m.new_content"]&&(i["m.new_content"]=c);const l=await this.client.sendMessage(this.roomId,Wi(Wi(Wi({},i),c),{},{[Ee.UNSTABLE_MSC3089_LEAF.name]:{}}));return await this.client.sendStateEvent(this.roomId,Ee.UNSTABLE_MSC3089_BRANCH.name,{active:!0,name:e},l.event_id),l}getFile(e){const t=this.room.currentState.getStateEvents(Ee.UNSTABLE_MSC3089_BRANCH.name,e);return t?new om.MSC3089Branch(this.client,t,this):null}listFiles(){return this.listAllFiles().filter(e=>e.isActive)}listAllFiles(){var e;return((e=this.room.currentState.getStateEvents(Ee.UNSTABLE_MSC3089_BRANCH.name))!==null&&e!==void 0?e:[]).map(r=>new om.MSC3089Branch(this.client,r,this))}}var DM=Zn.MSC3089TreeSpace=AM,Ko={};Object.defineProperty(Ko,"__esModule",{value:!0});Ko.SearchOrderBy=void 0;var cm;(function(n){n.RoomId="room_id",n.Sender="sender"})(cm||(cm={}));let Ch;Ko.SearchOrderBy=Ch;(function(n){n.Recent="recent",n.Rank="rank"})(Ch||(Ko.SearchOrderBy=Ch={}));var tu={},UM=V.exports;Object.defineProperty(tu,"__esModule",{value:!0});tu.MediaHandler=void 0;var la=UM(Y.exports),Ar=ie,$M=Te;class xM{constructor(e){this.client=e,(0,la.default)(this,"audioInput",void 0),(0,la.default)(this,"videoInput",void 0),(0,la.default)(this,"localUserMediaStream",void 0),(0,la.default)(this,"userMediaStreams",[]),(0,la.default)(this,"screensharingStreams",[])}async setAudioInput(e){Ar.logger.info("LOG setting audio input to",e),this.audioInput!==e&&(this.audioInput=e,await this.updateLocalUsermediaStreams())}async setVideoInput(e){Ar.logger.info("LOG setting video input to",e),this.videoInput!==e&&(this.videoInput=e,await this.updateLocalUsermediaStreams())}async updateLocalUsermediaStreams(){if(this.userMediaStreams.length===0)return;const e=new Map;for(const t of this.client.callEventHandler.calls.values())e.set(t.callId,{audio:t.hasLocalUserMediaAudioTrack,video:t.hasLocalUserMediaVideoTrack});for(const t of this.client.callEventHandler.calls.values()){if(t.state===$M.CallState.Ended||!e.has(t.callId))continue;const{audio:r,video:i}=e.get(t.callId),s=await this.getUserMediaStream(r,i,!1);await t.updateLocalUsermediaStream(s)}}async hasAudioDevice(){return(await navigator.mediaDevices.enumerateDevices()).filter(t=>t.kind==="audioinput").length>0}async hasVideoDevice(){return(await navigator.mediaDevices.enumerateDevices()).filter(t=>t.kind==="videoinput").length>0}async getUserMediaStream(e,t,r=!0){var i,s,o,c;const l=e&&await this.hasAudioDevice(),u=t&&await this.hasVideoDevice();let a;if(!this.localUserMediaStream||this.localUserMediaStream.getAudioTracks().length===0&&l||this.localUserMediaStream.getVideoTracks().length===0&&u||((i=this.localUserMediaStream.getAudioTracks()[0])===null||i===void 0||(s=i.getSettings())===null||s===void 0?void 0:s.deviceId)!==this.audioInput||((o=this.localUserMediaStream.getVideoTracks()[0])===null||o===void 0||(c=o.getSettings())===null||c===void 0?void 0:c.deviceId)!==this.videoInput){const g=this.getUserMediaContraints(l,u);Ar.logger.log("Getting user media with constraints",g),a=await navigator.mediaDevices.getUserMedia(g);for(const m of a.getTracks()){const p=m.getSettings();m.kind==="audio"?this.audioInput=p.deviceId:m.kind==="video"&&(this.videoInput=p.deviceId)}r&&(this.localUserMediaStream=a)}else{if(a=this.localUserMediaStream.clone(),!l)for(const g of a.getAudioTracks())a.removeTrack(g);if(!u)for(const g of a.getVideoTracks())a.removeTrack(g)}return r&&this.userMediaStreams.push(a),a}stopUserMediaStream(e){Ar.logger.debug("Stopping usermedia stream",e.id);for(const r of e.getTracks())r.stop();const t=this.userMediaStreams.indexOf(e);t!==-1&&(Ar.logger.debug("Splicing usermedia stream out stream array",e.id),this.userMediaStreams.splice(t,1)),this.localUserMediaStream===e&&(this.localUserMediaStream=void 0)}async getScreensharingStream(e,t=!0){let r;if(this.screensharingStreams.length===0){const i=this.getScreenshareContraints(e);if(!i)return null;e?(Ar.logger.debug("Getting screensharing stream using getUserMedia()",e),r=await navigator.mediaDevices.getUserMedia(i)):(Ar.logger.debug("Getting screensharing stream using getDisplayMedia()"),r=await navigator.mediaDevices.getDisplayMedia(i))}else{const i=this.screensharingStreams[this.screensharingStreams.length-1];Ar.logger.log("Cloning screensharing stream",i.id),r=i.clone()}return t&&this.screensharingStreams.push(r),r}stopScreensharingStream(e){Ar.logger.debug("Stopping screensharing stream",e.id);for(const r of e.getTracks())r.stop();const t=this.screensharingStreams.indexOf(e);t!==-1&&(Ar.logger.debug("Splicing screensharing stream out stream array",e.id),this.screensharingStreams.splice(t,1))}stopAllStreams(){for(const e of this.userMediaStreams)for(const t of e.getTracks())t.stop();for(const e of this.screensharingStreams)for(const t of e.getTracks())t.stop();this.userMediaStreams=[],this.screensharingStreams=[],this.localUserMediaStream=void 0}getUserMediaContraints(e,t){const r=!!navigator.webkitGetUserMedia;return{audio:e?{deviceId:this.audioInput?{ideal:this.audioInput}:void 0}:!1,video:t?{deviceId:this.videoInput?{ideal:this.videoInput}:void 0,width:r?{exact:640}:{ideal:640},height:r?{exact:360}:{ideal:360}}:!1}}getScreenshareContraints(e){return e?(Ar.logger.debug("Using desktop capturer source",e),{audio:!1,video:{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:e}}}):(Ar.logger.debug("Not using desktop capturer source"),{audio:!1,video:!0})}}tu.MediaHandler=xM;var NM=V.exports;Object.defineProperty(it,"__esModule",{value:!0});it.RoomVersionStability=it.PendingEventOrdering=it.MatrixClient=it.ClientEvent=it.CRYPTO_ENABLED=void 0;var X=NM(Y.exports),ad=Pl,zs=Ui,rt=qt,LM=jl,lm=Te,Nc=Cs,BM=gs,x=Sf(G),ua=Ft,cd=nc,KM=$i,ld=Sf(Me),FM=nn,qM=Gl,se=ie,um=Lo,M=me,xt=Kt,ud=Bo,dm=Ms,dd=en,jM=Mo,VM=Ql,GM=Ss,Js=Is,WM=ic,Xs=Sf(ze),ue=ne,HM=Ye,YM=Ef,zM=oi,hm=vr,hd=Zn,JM=Ko,Lc=Be,XM=tu,QM=qe,Bc=ct,ZM=In;function R_(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(R_=function(r){return r?t:e})(n)}function Sf(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=R_(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}function fm(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function Kc(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?fm(Object(t),!0).forEach(function(r){(0,X.default)(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):fm(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}const eA=3e3,tA=(0,xt.isCryptoAvailable)();it.CRYPTO_ENABLED=tA;const rA=216e5,pm=10*60*1e3;let Ph;it.PendingEventOrdering=Ph;(function(n){n.Chronological="chronological",n.Detached="detached"})(Ph||(it.PendingEventOrdering=Ph={}));let Mh;it.RoomVersionStability=Mh;(function(n){n.Stable="stable",n.Unstable="unstable"})(Mh||(it.RoomVersionStability=Mh={}));var gm;(function(n){n.MasterKey="master_key",n.SelfSigningKey="self_signing_key",n.UserSigningKey="user_signing_key"})(gm||(gm={}));const dn="$";let ss;it.ClientEvent=ss;(function(n){n.Sync="sync",n.Event="event",n.ToDeviceEvent="toDeviceEvent",n.AccountData="accountData",n.Room="Room",n.DeleteRoom="deleteRoom",n.SyncUnexpectedError="sync.unexpectedError",n.ClientWellKnown="WellKnown.client",n.Group="Group",n.GroupProfile="Group.profile",n.GroupMyMembership="Group.myMembership"})(ss||(it.ClientEvent=ss={}));class ru extends QM.TypedEventEmitter{constructor(e){super();(0,X.default)(this,"reEmitter",new FM.TypedReEmitter(this)),(0,X.default)(this,"olmVersion",null),(0,X.default)(this,"usingExternalCrypto",!1),(0,X.default)(this,"store",void 0),(0,X.default)(this,"deviceId",void 0),(0,X.default)(this,"credentials",void 0),(0,X.default)(this,"pickleKey",void 0),(0,X.default)(this,"scheduler",void 0),(0,X.default)(this,"clientRunning",!1),(0,X.default)(this,"timelineSupport",!1),(0,X.default)(this,"urlPreviewCache",{}),(0,X.default)(this,"unstableClientRelationAggregation",!1),(0,X.default)(this,"identityServer",void 0),(0,X.default)(this,"sessionStore",void 0),(0,X.default)(this,"http",void 0),(0,X.default)(this,"crypto",void 0),(0,X.default)(this,"cryptoCallbacks",void 0),(0,X.default)(this,"callEventHandler",void 0),(0,X.default)(this,"supportsCallTransfer",!1),(0,X.default)(this,"forceTURN",!1),(0,X.default)(this,"iceCandidatePoolSize",0),(0,X.default)(this,"idBaseUrl",void 0),(0,X.default)(this,"baseUrl",void 0),(0,X.default)(this,"canSupportVoip",!1),(0,X.default)(this,"peekSync",null),(0,X.default)(this,"isGuestAccount",!1),(0,X.default)(this,"ongoingScrollbacks",{}),(0,X.default)(this,"notifTimelineSet",null),(0,X.default)(this,"cryptoStore",void 0),(0,X.default)(this,"verificationMethods",void 0),(0,X.default)(this,"fallbackICEServerAllowed",!1),(0,X.default)(this,"roomList",void 0),(0,X.default)(this,"syncApi",void 0),(0,X.default)(this,"pushRules",void 0),(0,X.default)(this,"syncLeftRoomsPromise",void 0),(0,X.default)(this,"syncedLeftRooms",!1),(0,X.default)(this,"clientOpts",void 0),(0,X.default)(this,"clientWellKnownIntervalID",void 0),(0,X.default)(this,"canResetTimelineCallback",void 0),(0,X.default)(this,"pushProcessor",new cd.PushProcessor(this)),(0,X.default)(this,"serverVersionsPromise",void 0),(0,X.default)(this,"cachedCapabilities",void 0),(0,X.default)(this,"clientWellKnown",void 0),(0,X.default)(this,"clientWellKnownPromise",void 0),(0,X.default)(this,"turnServers",[]),(0,X.default)(this,"turnServersExpiry",0),(0,X.default)(this,"checkTurnServersIntervalID",void 0),(0,X.default)(this,"exportedOlmDeviceToImport",void 0),(0,X.default)(this,"txnCtr",0),(0,X.default)(this,"mediaHandler",new XM.MediaHandler(this)),(0,X.default)(this,"pendingEventEncryption",new Map),(0,X.default)(this,"startCallEventHandler",()=>{this.isInitialSyncComplete()&&(this.callEventHandler.start(),this.off(ss.Sync,this.startCallEventHandler))}),e.baseUrl=x.ensureNoTrailingSlash(e.baseUrl),e.idBaseUrl=x.ensureNoTrailingSlash(e.idBaseUrl),this.baseUrl=e.baseUrl,this.idBaseUrl=e.idBaseUrl,this.usingExternalCrypto=e.usingExternalCrypto,this.store=e.store||new LM.StubStore,this.deviceId=e.deviceId||null;const t=e.userId||null;this.credentials={userId:t},this.http=new M.MatrixHttpApi(this,{baseUrl:e.baseUrl,idBaseUrl:e.idBaseUrl,accessToken:e.accessToken,request:e.request,prefix:M.PREFIX_R0,onlyData:!0,extraParams:e.queryParams,localTimeoutMs:e.localTimeoutMs,useAuthorizationHeader:e.useAuthorizationHeader}),e.deviceToImport?this.deviceId?se.logger.warn("not importing device because device ID is provided to constructor independently of exported data"):this.credentials.userId?se.logger.warn("not importing device because user ID is provided to constructor independently of exported data"):e.deviceToImport.deviceId?(this.deviceId=e.deviceToImport.deviceId,this.credentials.userId=e.deviceToImport.userId,this.exportedOlmDeviceToImport=e.deviceToImport.olmDevice):se.logger.warn("not importing device because no device ID in exported data"):e.pickleKey&&(this.pickleKey=e.pickleKey),this.scheduler=e.scheduler,this.scheduler&&this.scheduler.setProcessFunction(async i=>{const s=this.getRoom(i.getRoomId());i.status!==rt.EventStatus.SENDING&&this.updatePendingEventStatus(s,i,rt.EventStatus.SENDING);const o=await this.sendEventHttpRequest(i);return s&&s.updatePendingEvent(i,rt.EventStatus.SENT,o.event_id),o}),(0,lm.createNewMatrixCall)(this,void 0,void 0)&&(this.callEventHandler=new BM.CallEventHandler(this),this.canSupportVoip=!0,this.on(ss.Sync,this.startCallEventHandler)),this.timelineSupport=Boolean(e.timelineSupport),this.unstableClientRelationAggregation=!!e.unstableClientRelationAggregation,this.cryptoStore=e.cryptoStore,this.sessionStore=e.sessionStore,this.verificationMethods=e.verificationMethods,this.cryptoCallbacks=e.cryptoCallbacks||{},this.forceTURN=e.forceTURN||!1,this.iceCandidatePoolSize=e.iceCandidatePoolSize===void 0?0:e.iceCandidatePoolSize,this.supportsCallTransfer=e.supportsCallTransfer||!1,this.fallbackICEServerAllowed=e.fallbackICEServerAllowed||!1,this.roomList=new qM.RoomList(this.cryptoStore),this.on(rt.MatrixEventEvent.Decrypted,i=>{var s,o;const c=i.getPushActions(),l=this.getPushActionsForEvent(i,!0),u=this.getRoom(i.getRoomId());if(!u)return;const a=u.getUnreadNotificationCount(Js.NotificationCountType.Highlight),g=!!(c!=null&&(s=c.tweaks)!==null&&s!==void 0&&s.highlight),m=!!(l!=null&&(o=l.tweaks)!==null&&o!==void 0&&o.highlight);if((g!==m||a>0)&&!u.hasUserReadEvent(this.getUserId(),i.getId())){let p=a;m&&!g&&p++,!m&&g&&p--,u.setUnreadNotificationCount(Js.NotificationCountType.Highlight,p),u.getUnreadNotificationCount(Js.NotificationCountType.Total)<p&&u.setUnreadNotificationCount(Js.NotificationCountType.Total,p)}}),this.on(Js.RoomEvent.Receipt,(i,s)=>{if(s&&this.isRoomEncrypted(s.roomId)){const o=i.getContent();if(!(Object.keys(o).filter(g=>Object.keys(o[g]["m.read"]).includes(this.getUserId())).length>0))return;const l=20,u=s.getLiveTimeline().getEvents();let a=0;for(let g=u.length-1;g>=0;g--){if(g===u.length-l)return;const m=u[g];if(s.hasUserReadEvent(this.getUserId(),m.getId()))break;const p=this.getPushActionsForEvent(m);a+=p.tweaks&&p.tweaks.highlight?1:0}s.setUnreadNotificationCount(Js.NotificationCountType.Highlight,a)}})}async startClient(e){if(this.clientRunning)return;this.clientRunning=!0,typeof e=="number"&&(e={initialSyncLimit:e});const t=this.getUserId();t&&this.store.storeUser(new dd.User(t)),this.crypto&&(this.crypto.uploadDeviceKeys(),this.crypto.start()),this.canSupportVoip&&(this.checkTurnServersIntervalID=setInterval(()=>{this.checkTurnServers()},pm),this.checkTurnServers()),this.syncApi&&(se.logger.error("Still have sync object whilst not running: stopping old one"),this.syncApi.stop());try{const{serverSupport:r,stable:i}=await this.doesServerSupportThread();Bc.Thread.setServerSideSupport(r,i)}catch{Bc.Thread.setServerSideSupport(!1,!0)}this.clientOpts=Object.assign({},e),this.clientOpts.crypto=this.crypto,this.clientOpts.canResetEntireTimeline=r=>this.canResetTimelineCallback?this.canResetTimelineCallback(r):!1,this.syncApi=new zs.SyncApi(this,this.clientOpts),this.syncApi.sync(),this.clientOpts.clientWellKnownPollPeriod!==void 0&&(this.clientWellKnownIntervalID=setInterval(()=>{this.fetchClientWellKnown()},1e3*this.clientOpts.clientWellKnownPollPeriod),this.fetchClientWellKnown())}stopClient(){var e,t,r,i;se.logger.log("stopping MatrixClient"),this.clientRunning=!1,(e=this.syncApi)===null||e===void 0||e.stop(),this.syncApi=null,(t=this.crypto)===null||t===void 0||t.stop(),(r=this.peekSync)===null||r===void 0||r.stopPeeking(),(i=this.callEventHandler)===null||i===void 0||i.stop(),this.callEventHandler=null,j.clearInterval(this.checkTurnServersIntervalID),this.clientWellKnownIntervalID!==void 0&&j.clearInterval(this.clientWellKnownIntervalID)}async rehydrateDevice(){if(this.crypto)throw new Error("Cannot rehydrate device after crypto is initialized");if(!this.cryptoCallbacks.getDehydrationKey)return;const e=await this.getDehydratedDevice();if(!e)return;if(!e.device_data||!e.device_id){se.logger.info("no dehydrated device found");return}const t=new j.Olm.Account;try{const r=e.device_data;if(r.algorithm!==GM.DEHYDRATION_ALGORITHM){se.logger.warn("Wrong algorithm for dehydrated device");return}se.logger.log("unpickling dehydrated device");const i=await this.cryptoCallbacks.getDehydrationKey(r,o=>{t.unpickle(new Uint8Array(o),r.account)});if(t.unpickle(i,r.account),se.logger.log("unpickled device"),(await this.http.authedRequest(void 0,M.Method.Post,"/dehydrated_device/claim",void 0,{device_id:e.device_id},{prefix:"/_matrix/client/unstable/org.matrix.msc2697.v2"})).success===!0){this.deviceId=e.device_id,se.logger.info("using dehydrated device");const o=this.pickleKey||"DEFAULT_KEY";return this.exportedOlmDeviceToImport={pickledAccount:t.pickle(o),sessions:[],pickleKey:o},t.free(),this.deviceId}else{t.free(),se.logger.info("not using dehydrated device");return}}catch(r){t.free(),se.logger.warn("could not unpickle",r)}}async getDehydratedDevice(){try{return await this.http.authedRequest(void 0,M.Method.Get,"/dehydrated_device",void 0,void 0,{prefix:"/_matrix/client/unstable/org.matrix.msc2697.v2"})}catch(e){se.logger.info("could not get dehydrated device",e.toString());return}}async setDehydrationKey(e,t,r){if(!this.crypto){se.logger.warn("not dehydrating device if crypto is not enabled");return}return await this.crypto.dehydrationManager.setKeyAndQueueDehydration(e,t,r)}async createDehydratedDevice(e,t,r){if(!this.crypto){se.logger.warn("not dehydrating device if crypto is not enabled");return}return await this.crypto.dehydrationManager.setKey(e,t,r),await this.crypto.dehydrationManager.dehydrateDevice()}async exportDevice(){if(!this.crypto){se.logger.warn("not exporting device if crypto is not enabled");return}return{userId:this.credentials.userId,deviceId:this.deviceId,olmDevice:await this.crypto.olmDevice.export()}}clearStores(){if(this.clientRunning)throw new Error("Cannot clear stores while client is running");const e=[];return e.push(this.store.deleteAllData()),this.cryptoStore&&e.push(this.cryptoStore.deleteAllData()),Promise.all(e).then()}getUserId(){return this.credentials&&this.credentials.userId?this.credentials.userId:null}getDomain(){return this.credentials&&this.credentials.userId?this.credentials.userId.replace(/^.*?:/,""):null}getUserIdLocalpart(){return this.credentials&&this.credentials.userId?this.credentials.userId.split(":")[0].substring(1):null}getDeviceId(){return this.deviceId}supportsVoip(){return this.canSupportVoip}getMediaHandler(){return this.mediaHandler}setForceTURN(e){this.forceTURN=e}setSupportsCallTransfer(e){this.supportsCallTransfer=e}createCall(e){return(0,lm.createNewMatrixCall)(this,e)}getSyncState(){return this.syncApi?this.syncApi.getSyncState():null}getSyncStateData(){return this.syncApi?this.syncApi.getSyncStateData():null}isInitialSyncComplete(){const e=this.getSyncState();return e?e===zs.SyncState.Prepared||e===zs.SyncState.Syncing:!1}isGuest(){return this.isGuestAccount}setGuest(e){this.isGuestAccount=e}getScheduler(){return this.scheduler}retryImmediately(){return this.syncApi.retryImmediately()}getNotifTimelineSet(){return this.notifTimelineSet}setNotifTimelineSet(e){this.notifTimelineSet=e}getCapabilities(e=!1){const t=new Date().getTime();return this.cachedCapabilities&&!e&&t<this.cachedCapabilities.expiration?(se.logger.log("Returning cached capabilities"),Promise.resolve(this.cachedCapabilities.capabilities)):this.http.authedRequest(void 0,M.Method.Get,"/capabilities").catch(r=>{se.logger.error(r)}).then((r={})=>{const i=r.capabilities||{},s=Object.keys(i).length?rA:6e4+Math.random()*5e3;return this.cachedCapabilities={capabilities:i,expiration:t+s},se.logger.log("Caching capabilities: ",i),i})}async initCrypto(){if(!(0,xt.isCryptoAvailable)())throw new Error("End-to-end encryption not supported in this js-sdk build: did you remember to load the olm library?");if(this.crypto){se.logger.warn("Attempt to re-initialise e2e encryption on MatrixClient");return}if(!this.sessionStore)throw new Error("Cannot enable encryption: no sessionStore provided");if(!this.cryptoStore)throw new Error("Cannot enable encryption: no cryptoStore provided");se.logger.log("Crypto: Starting up crypto store..."),await this.cryptoStore.startup(),se.logger.log("Crypto: initialising roomlist..."),await this.roomList.init();const e=this.getUserId();if(e===null)throw new Error("Cannot enable encryption on MatrixClient with unknown userId: ensure userId is passed in createClient().");if(this.deviceId===null)throw new Error("Cannot enable encryption on MatrixClient with unknown deviceId: ensure deviceId is passed in createClient().");const t=new xt.Crypto(this,this.sessionStore,e,this.deviceId,this.store,this.cryptoStore,this.roomList,this.verificationMethods);this.reEmitter.reEmit(t,[xt.CryptoEvent.KeyBackupFailed,xt.CryptoEvent.KeyBackupSessionsRemaining,xt.CryptoEvent.RoomKeyRequest,xt.CryptoEvent.RoomKeyRequestCancellation,xt.CryptoEvent.Warning,xt.CryptoEvent.DevicesUpdated,xt.CryptoEvent.WillUpdateDevices,xt.CryptoEvent.DeviceVerificationChanged,xt.CryptoEvent.UserTrustStatusChanged,xt.CryptoEvent.KeysChanged]),se.logger.log("Crypto: initialising crypto object..."),await t.init({exportedOlmDevice:this.exportedOlmDeviceToImport,pickleKey:this.pickleKey}),delete this.exportedOlmDeviceToImport,this.olmVersion=xt.Crypto.getOlmVersion(),t.registerEventHandlers(this),this.crypto=t}isCryptoEnabled(){return!!this.crypto}getDeviceEd25519Key(){return this.crypto?this.crypto.getDeviceEd25519Key():null}getDeviceCurve25519Key(){return this.crypto?this.crypto.getDeviceCurve25519Key():null}async uploadKeys(){if(!this.crypto)throw new Error("End-to-end encryption disabled");await this.crypto.uploadDeviceKeys()}downloadKeys(e,t){return this.crypto?this.crypto.downloadKeys(e,t):Promise.reject(new Error("End-to-end encryption disabled"))}getStoredDevicesForUser(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.getStoredDevicesForUser(e)||[]}getStoredDevice(e,t){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.getStoredDevice(e,t)||null}setDeviceVerified(e,t,r=!0){const i=this.setDeviceVerification(e,t,r,null,null);return e==this.credentials.userId&&this.checkKeyBackup(),i}setDeviceBlocked(e,t,r=!0){return this.setDeviceVerification(e,t,null,r,null)}setDeviceKnown(e,t,r=!0){return this.setDeviceVerification(e,t,null,null,r)}async setDeviceVerification(e,t,r,i,s){if(!this.crypto)throw new Error("End-to-end encryption disabled");await this.crypto.setDeviceVerification(e,t,r,i,s)}requestVerificationDM(e,t){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.requestVerificationDM(e,t)}findVerificationRequestDMInProgress(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.findVerificationRequestDMInProgress(e)}getVerificationRequestsToDeviceInProgress(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.getVerificationRequestsToDeviceInProgress(e)}requestVerification(e,t){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.requestVerification(e,t)}beginKeyVerification(e,t,r){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.beginKeyVerification(e,t,r)}checkSecretStorageKey(e,t){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.checkSecretStorageKey(e,t)}setGlobalBlacklistUnverifiedDevices(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.setGlobalBlacklistUnverifiedDevices(e)}getGlobalBlacklistUnverifiedDevices(){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.getGlobalBlacklistUnverifiedDevices()}setGlobalErrorOnUnknownDevices(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.setGlobalErrorOnUnknownDevices(e)}getGlobalErrorOnUnknownDevices(){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.getGlobalErrorOnUnknownDevices()}getCrossSigningId(e=WM.CrossSigningKey.Master){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.getCrossSigningId(e)}getStoredCrossSigningForUser(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.getStoredCrossSigningForUser(e)}checkUserTrust(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.checkUserTrust(e)}checkDeviceTrust(e,t){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.checkDeviceTrust(e,t)}checkOwnCrossSigningTrust(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.checkOwnCrossSigningTrust(e)}checkCrossSigningPrivateKey(e,t){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.checkCrossSigningPrivateKey(e,t)}legacyDeviceVerification(e,t,r){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.legacyDeviceVerification(e,t,r)}prepareToEncrypt(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.prepareToEncrypt(e)}isCrossSigningReady(){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.isCrossSigningReady()}bootstrapCrossSigning(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.bootstrapCrossSigning(e)}getCryptoTrustCrossSignedDevices(){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.getCryptoTrustCrossSignedDevices()}setCryptoTrustCrossSignedDevices(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.setCryptoTrustCrossSignedDevices(e)}countSessionsNeedingBackup(){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.countSessionsNeedingBackup()}getEventEncryptionInfo(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.getEventEncryptionInfo(e)}createRecoveryKeyFromPassphrase(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.createRecoveryKeyFromPassphrase(e)}isSecretStorageReady(){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.isSecretStorageReady()}bootstrapSecretStorage(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.bootstrapSecretStorage(e)}addSecretStorageKey(e,t,r){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.addSecretStorageKey(e,t,r)}hasSecretStorageKey(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.hasSecretStorageKey(e)}storeSecret(e,t,r){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.storeSecret(e,t,r)}getSecret(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.getSecret(e)}isSecretStored(e,t){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.isSecretStored(e,t)}requestSecret(e,t){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.requestSecret(e,t)}getDefaultSecretStorageKeyId(){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.getDefaultSecretStorageKeyId()}setDefaultSecretStorageKeyId(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.setDefaultSecretStorageKeyId(e)}checkSecretStoragePrivateKey(e,t){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.checkSecretStoragePrivateKey(e,t)}async getEventSenderDeviceInfo(e){return this.crypto?this.crypto.getEventSenderDeviceInfo(e):null}async isEventSenderVerified(e){const t=await this.getEventSenderDeviceInfo(e);return t?t.isVerified():!1}cancelAndResendEventRoomKeyRequest(e){return e.cancelAndResendKeyRequest(this.crypto,this.getUserId())}setRoomEncryption(e,t){if(!this.crypto)throw new Error("End-to-End encryption disabled");return this.crypto.setRoomEncryption(e,t)}isRoomEncrypted(e){const t=this.getRoom(e);return t?t.currentState.getStateEvents(ue.EventType.RoomEncryption,"")?!0:this.roomList.isRoomEncrypted(e):!1}forceDiscardSession(e){if(!this.crypto)throw new Error("End-to-End encryption disabled");this.crypto.forceDiscardSession(e)}exportRoomKeys(){return this.crypto?this.crypto.exportRoomKeys():Promise.reject(new Error("End-to-end encryption disabled"))}importRoomKeys(e,t){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.importRoomKeys(e,t)}checkKeyBackup(){return this.crypto.backupManager.checkKeyBackup()}async getKeyBackupVersion(){let e;try{e=await this.http.authedRequest(void 0,M.Method.Get,"/room_keys/version",void 0,void 0,{prefix:M.PREFIX_UNSTABLE})}catch(t){if(t.errcode==="M_NOT_FOUND")return null;throw t}try{hm.BackupManager.checkBackupVersion(e)}catch(t){throw t}return e}isKeyBackupTrusted(e){return this.crypto.backupManager.isKeyBackupTrusted(e)}getKeyBackupEnabled(){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.backupManager.getKeyBackupEnabled()}enableKeyBackup(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.backupManager.enableKeyBackup(e)}disableKeyBackup(){if(!this.crypto)throw new Error("End-to-end encryption disabled");this.crypto.backupManager.disableKeyBackup()}async prepareKeyBackupVersion(e,t={secureSecretStorage:!1}){if(!this.crypto)throw new Error("End-to-end encryption disabled");const{algorithm:r,auth_data:i,recovery_key:s,privateKey:o}=await this.crypto.backupManager.prepareKeyBackupVersion(e);return t.secureSecretStorage&&(await this.storeSecret("m.megolm_backup.v1",(0,ld.encodeBase64)(o)),se.logger.info("Key backup private key stored in secret storage")),{algorithm:r,auth_data:i,recovery_key:s}}isKeyBackupKeyStored(){return Promise.resolve(this.isSecretStored("m.megolm_backup.v1",!1))}async createKeyBackupVersion(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");await this.crypto.backupManager.createKeyBackupVersion(e);const t={algorithm:e.algorithm,auth_data:e.auth_data};await this.crypto.signObject(t.auth_data),this.cryptoCallbacks.getCrossSigningKey&&this.crypto.crossSigningInfo.getId()&&await this.crypto.crossSigningInfo.signObject(t.auth_data,"master");const r=await this.http.authedRequest(void 0,M.Method.Post,"/room_keys/version",void 0,t,{prefix:M.PREFIX_UNSTABLE});return await this.checkKeyBackup(),this.getKeyBackupEnabled()||se.logger.error("Key backup not usable even though we just created it"),r}deleteKeyBackupVersion(e){if(!this.crypto)throw new Error("End-to-end encryption disabled");this.crypto.backupManager.version&&this.crypto.backupManager.disableKeyBackup();const t=x.encodeUri("/room_keys/version/$version",{$version:e});return this.http.authedRequest(void 0,M.Method.Delete,t,void 0,void 0,{prefix:M.PREFIX_UNSTABLE})}makeKeyBackupPath(e,t,r){let i;return t!==void 0?i=x.encodeUri("/room_keys/keys/$roomId/$sessionId",{$roomId:e,$sessionId:t}):e!==void 0?i=x.encodeUri("/room_keys/keys/$roomId",{$roomId:e}):i="/room_keys/keys",{path:i,queryData:r===void 0?void 0:{version:r}}}sendKeyBackup(e,t,r,i){if(!this.crypto)throw new Error("End-to-end encryption disabled");const s=this.makeKeyBackupPath(e,t,r);return this.http.authedRequest(void 0,M.Method.Put,s.path,s.queryData,i,{prefix:M.PREFIX_UNSTABLE})}async scheduleAllGroupSessionsForBackup(){if(!this.crypto)throw new Error("End-to-end encryption disabled");await this.crypto.backupManager.scheduleAllGroupSessionsForBackup()}flagAllGroupSessionsForBackup(){if(!this.crypto)throw new Error("End-to-end encryption disabled");return this.crypto.backupManager.flagAllGroupSessionsForBackup()}isValidRecoveryKey(e){try{return(0,ud.decodeRecoveryKey)(e),!0}catch{return!1}}keyBackupKeyFromPassword(e,t){return(0,dm.keyFromAuthData)(t.auth_data,e)}keyBackupKeyFromRecoveryKey(e){return(0,ud.decodeRecoveryKey)(e)}async restoreKeyBackupWithPassword(e,t,r,i,s){const o=await(0,dm.keyFromAuthData)(i.auth_data,e);return this.restoreKeyBackup(o,t,r,i,s)}async restoreKeyBackupWithSecretStorage(e,t,r,i){const s=await this.getSecret("m.megolm_backup.v1"),o=(0,xt.fixBackupKey)(s);if(o){const[l]=await this.crypto.getSecretStorageKey();await this.storeSecret("m.megolm_backup.v1",o,[l])}const c=(0,ld.decodeBase64)(o||s);return this.restoreKeyBackup(c,t,r,e,i)}restoreKeyBackupWithRecoveryKey(e,t,r,i,s){const o=(0,ud.decodeRecoveryKey)(e);return this.restoreKeyBackup(o,t,r,i,s)}async restoreKeyBackupWithCache(e,t,r,i){const s=await this.crypto.getSessionBackupPrivateKey();if(!s)throw new Error("Couldn't get key");return this.restoreKeyBackup(s,e,t,r,i)}async restoreKeyBackup(e,t,r,i,s){const o=s==null?void 0:s.cacheCompleteCallback,c=s==null?void 0:s.progressCallback;if(!this.crypto)throw new Error("End-to-end encryption disabled");let l=0,u=[];const a=this.makeKeyBackupPath(t,r,i.version),g=await hm.BackupManager.makeAlgorithm(i,async()=>e),m=g.untrusted;try{if(!await g.keyMatches(e))return Promise.reject(new M.MatrixError({errcode:ru.RESTORE_BACKUP_ERROR_BAD_KEY}));this.crypto.storeSessionBackupPrivateKey(e).catch(E=>{se.logger.warn("Error caching session backup key:",E)}).then(o),c&&c({stage:"fetch"});const p=await this.http.authedRequest(void 0,M.Method.Get,a.path,a.queryData,void 0,{prefix:M.PREFIX_UNSTABLE});if(p.rooms){const E=p.rooms;for(const[I,w]of Object.entries(E)){if(!w.sessions)continue;l+=Object.keys(w.sessions).length;const k=await g.decryptSessions(w.sessions);for(const P of k)P.room_id=I,u.push(P)}}else if(p.sessions){const E=p.sessions;l=Object.keys(E).length,u=await g.decryptSessions(E);for(const I of u)I.room_id=t}else{l=1;try{const[E]=await g.decryptSessions({[r]:p});E.room_id=t,E.session_id=r,u.push(E)}catch(E){se.logger.log("Failed to decrypt megolm session from backup",E)}}}finally{g.free()}return await this.importRoomKeys(u,{progressCallback:c,untrusted:m,source:"backup"}),await this.checkKeyBackup(),{total:l,imported:u.length}}deleteKeysFromBackup(e,t,r){if(!this.crypto)throw new Error("End-to-end encryption disabled");const i=this.makeKeyBackupPath(e,t,r);return this.http.authedRequest(void 0,M.Method.Delete,i.path,i.queryData,void 0,{prefix:M.PREFIX_UNSTABLE})}async sendSharedHistoryKeys(e,t){if(!this.crypto)throw new Error("End-to-end encryption disabled");const r=this.roomList.getRoomEncryption(e);if(!r){se.logger.error("Unknown room. Not sharing decryption keys");return}const i=await this.crypto.downloadKeys(t),s={};for(const[c,l]of Object.entries(i))s[c]=Object.values(l);const o=this.crypto.getRoomDecryptor(e,r.algorithm);o.sendSharedHistoryInboundSessions?await o.sendSharedHistoryInboundSessions(s):se.logger.warn("Algorithm does not support sharing previous keys",r.algorithm)}getGroup(e){return this.store.getGroup(e)}getGroups(){return this.store.getGroups()}getMediaConfig(e){return this.http.authedRequest(e,M.Method.Get,"/config",void 0,void 0,{prefix:M.PREFIX_MEDIA_R0})}getRoom(e){return this.store.getRoom(e)}getRooms(){return this.store.getRooms()}getVisibleRooms(){const e=this.store.getRooms(),t=new Set;for(const r of e){const i=r.currentState.getStateEvents(ue.EventType.RoomCreate,"");if(i){const s=i.getContent().predecessor;s&&s.room_id&&t.add(s.room_id)}}return e.filter(r=>!(r.currentState.getStateEvents(ue.EventType.RoomTombstone,"")&&t.has(r.roomId)))}getUser(e){return this.store.getUser(e)}getUsers(){return this.store.getUsers()}setAccountData(e,t,r){const i=x.encodeUri("/user/$userId/account_data/$type",{$userId:this.credentials.userId,$type:e}),s=(0,M.retryNetworkOperation)(5,()=>this.http.authedRequest(void 0,M.Method.Put,i,void 0,t));return r&&s.then(o=>r(null,o),r),s}getAccountData(e){return this.store.getAccountData(e)}async getAccountDataFromServer(e){if(this.isInitialSyncComplete()){const r=this.store.getAccountData(e);return r?r.getContent():null}const t=x.encodeUri("/user/$userId/account_data/$type",{$userId:this.credentials.userId,$type:e});try{return await this.http.authedRequest(void 0,M.Method.Get,t,void 0)}catch(r){if(r.data&&r.data.errcode==="M_NOT_FOUND")return null;throw r}}getIgnoredUsers(){const e=this.getAccountData("m.ignored_user_list");return!e||!e.getContent()||!e.getContent().ignored_users?[]:Object.keys(e.getContent().ignored_users)}setIgnoredUsers(e,t){const r={ignored_users:{}};return e.map(i=>r.ignored_users[i]={}),this.setAccountData("m.ignored_user_list",r,t)}isUserIgnored(e){return this.getIgnoredUsers().includes(e)}async joinRoom(e,t,r){if(x.isFunction(t))throw new Error("Expected 'opts' object, got function.");t=t||{},t.syncRoom===void 0&&(t.syncRoom=!0);const i=this.getRoom(e);if(i&&i.hasMembershipState(this.credentials.userId,"join"))return Promise.resolve(i);let s=Promise.resolve();t.inviteSignUrl&&(s=this.http.requestOtherUrl(void 0,M.Method.Post,t.inviteSignUrl,{mxid:this.credentials.userId}));const o={};t.viaServers&&(o.server_name=t.viaServers);const c={qsStringifyOptions:{arrayFormat:"repeat"}};try{const l={},u=await s;u&&(l.third_party_signed=u);const a=x.encodeUri("/join/$roomid",{$roomid:e}),m=(await this.http.authedRequest(void 0,M.Method.Post,a,o,l,c)).room_id,E=new zs.SyncApi(this,this.clientOpts).createRoom(m);return t.syncRoom,r==null||r(null,E),E}catch(l){throw r==null||r(l),l}}resendEvent(e,t){return this.updatePendingEventStatus(t,e,rt.EventStatus.SENDING),this.encryptAndSendEvent(t,e)}cancelPendingEvent(e){if(![rt.EventStatus.QUEUED,rt.EventStatus.NOT_SENT,rt.EventStatus.ENCRYPTING].includes(e.status))throw new Error("cannot cancel an event with status "+e.status);e.status===rt.EventStatus.ENCRYPTING?this.pendingEventEncryption.delete(e.getId()):this.scheduler&&e.status===rt.EventStatus.QUEUED&&this.scheduler.removeEventFromQueue(e);const t=this.getRoom(e.getRoomId());this.updatePendingEventStatus(t,e,rt.EventStatus.CANCELLED)}setRoomName(e,t,r){return this.sendStateEvent(e,ue.EventType.RoomName,{name:t},void 0,r)}setRoomTopic(e,t,r){return this.sendStateEvent(e,ue.EventType.RoomTopic,{topic:t},void 0,r)}getRoomTags(e,t){const r=x.encodeUri("/user/$userId/rooms/$roomId/tags/",{$userId:this.credentials.userId,$roomId:e});return this.http.authedRequest(t,M.Method.Get,r,void 0)}setRoomTag(e,t,r,i){const s=x.encodeUri("/user/$userId/rooms/$roomId/tags/$tag",{$userId:this.credentials.userId,$roomId:e,$tag:t});return this.http.authedRequest(i,M.Method.Put,s,void 0,r)}deleteRoomTag(e,t,r){const i=x.encodeUri("/user/$userId/rooms/$roomId/tags/$tag",{$userId:this.credentials.userId,$roomId:e,$tag:t});return this.http.authedRequest(r,M.Method.Delete,i,void 0,void 0)}setRoomAccountData(e,t,r,i){const s=x.encodeUri("/user/$userId/rooms/$roomId/account_data/$type",{$userId:this.credentials.userId,$roomId:e,$type:t});return this.http.authedRequest(i,M.Method.Put,s,void 0,r)}setPowerLevel(e,t,r,i,s){let o={users:{}};(i==null?void 0:i.getType())===ue.EventType.RoomPowerLevels&&(o=x.deepCopy(i.getContent())),o.users[t]=r;const c=x.encodeUri("/rooms/$roomId/state/m.room.power_levels",{$roomId:e});return this.http.authedRequest(s,M.Method.Put,c,void 0,o)}async unstable_createLiveBeacon(e,t,r){const i=this.getUserId(),s=ZM.M_BEACON_INFO_VARIABLE.name.replace("*",`${i}.${r}`);return this.unstable_setLiveBeacon(e,s,t)}async unstable_setLiveBeacon(e,t,r){const i=this.getUserId();return this.sendStateEvent(e,t,r,i)}sendEvent(e,t,r,i,s,o){var c,l;if(!((c=t)!==null&&c!==void 0&&c.startsWith(dn))&&t!==null&&(o=s,s=i,i=r,r=t,t=null),t&&!((l=i["m.relates_to"])!==null&&l!==void 0&&l.rel_type)){var u;i["m.relates_to"]=Kc(Kc({},i["m.relates_to"]),{},{rel_type:Bc.THREAD_RELATION_TYPE.name,event_id:t});const g=(u=this.getRoom(e))===null||u===void 0?void 0:u.threads.get(t);if(g){var a;i["m.relates_to"]["m.in_reply_to"]={event_id:(a=g.lastReply(m=>m.isRelation(Bc.THREAD_RELATION_TYPE.name)&&!m.status))===null||a===void 0?void 0:a.getId()}}}return this.sendCompleteEvent(e,t,{type:r,content:i},s,o)}sendCompleteEvent(e,t,r,i,s){x.isFunction(i)&&(s=i,i=void 0),i||(i=this.makeTxnId());const o=new rt.MatrixEvent(Object.assign(r,{event_id:"~"+e+":"+i,user_id:this.credentials.userId,sender:this.credentials.userId,room_id:e,origin_server_ts:new Date().getTime()})),c=this.getRoom(e),l=c==null?void 0:c.threads.get(t);l&&(o.setThread(l),o.setThreadId(l.id));const u=o.getAssociatedId();if(u!=null&&u.startsWith("~")){const g=c.getPendingEvents().find(m=>m.getId()===u);g.once(rt.MatrixEventEvent.LocalEventIdReplaced,()=>{o.updateAssociatedId(g.getId())})}const a=o.getType();return se.logger.log(`sendEvent of type ${a} in ${e} with txnId ${i}`),o.setTxnId(i),o.setStatus(rt.EventStatus.SENDING),c&&c.addPendingEvent(o,i),o.status===rt.EventStatus.NOT_SENT?Promise.reject(new Error("Event blocked by other events not yet sent")):this.encryptAndSendEvent(c,o,s)}encryptAndSendEvent(e,t,r){let i=!1;return Promise.resolve().then(()=>{const s=this.encryptEventIfNeeded(t,e);return s?(this.pendingEventEncryption.set(t.getId(),s),this.updatePendingEventStatus(e,t,rt.EventStatus.ENCRYPTING),s.then(()=>{if(!this.pendingEventEncryption.has(t.getId())){i=!0;return}this.updatePendingEventStatus(e,t,rt.EventStatus.SENDING)})):null}).then(()=>{if(i)return{};let s;return this.scheduler&&(s=this.scheduler.queueEvent(t),s&&this.scheduler.getQueueForEvent(t).length>1&&this.updatePendingEventStatus(e,t,rt.EventStatus.QUEUED)),s||(s=this.sendEventHttpRequest(t),e&&(s=s.then(o=>(e.updatePendingEvent(t,rt.EventStatus.SENT,o.event_id),o)))),s}).then(s=>(r==null||r(null,s),s)).catch(s=>{se.logger.error("Error sending event",s.stack||s);try{t.error=s,this.updatePendingEventStatus(e,t,rt.EventStatus.NOT_SENT),s.event=t,r==null||r(s)}catch(o){se.logger.error("Exception in error handler!",o.stack||s)}throw s})}encryptEventIfNeeded(e,t){if(e.isEncrypted()||e.isRedaction()||!this.isRoomEncrypted(e.getRoomId())||!this.crypto&&this.usingExternalCrypto||e.getType()===ue.EventType.Reaction)return null;if(!this.crypto)throw new Error("This room is configured to use encryption, but your client does not support encryption.");return this.crypto.encryptEvent(e,t)}getEncryptedIfNeededEventType(e,t){return t===ue.EventType.Reaction?t:this.isRoomEncrypted(e)?ue.EventType.RoomMessageEncrypted:t}updatePendingEventStatus(e,t,r){e?e.updatePendingEvent(t,r):t.setStatus(r)}sendEventHttpRequest(e){let t=e.getTxnId();t||(t=this.makeTxnId(),e.setTxnId(t));const r={$roomId:e.getRoomId(),$eventType:e.getWireType(),$stateKey:e.getStateKey(),$txnId:t};let i;if(e.isState()){let s="/rooms/$roomId/state/$eventType";e.getStateKey()&&e.getStateKey().length>0&&(s="/rooms/$roomId/state/$eventType/$stateKey"),i=x.encodeUri(s,r)}else if(e.isRedaction()){const s="/rooms/$roomId/redact/$redactsEventId/$txnId";i=x.encodeUri(s,Object.assign({$redactsEventId:e.event.redacts},r))}else i=x.encodeUri("/rooms/$roomId/send/$eventType/$txnId",r);return this.http.authedRequest(void 0,M.Method.Put,i,void 0,e.getWireContent()).then(s=>(se.logger.log(`Event sent to ${e.getRoomId()} with event id ${s.event_id}`),s))}redactEvent(e,t,r,i,s){var o;(o=r)!==null&&o!==void 0&&o.startsWith(dn)||(s=i,i=r,r=t,t=null);const l=(typeof s=="object"?s:{}).reason,u=typeof s=="function"?s:void 0;return this.sendCompleteEvent(e,t,{type:ue.EventType.RoomRedaction,content:{reason:l},redacts:r},i,u)}sendMessage(e,t,r,i,s){typeof t!="string"&&t!==null&&(s=i,i=r,r=t,t=null),x.isFunction(i)&&(s=i,i=void 0);let o=ue.EventType.RoomMessage,c=r;const l=(a={},g=!0)=>{let m=null;if(a.msgtype===ue.MsgType.Text?m=ad.MessageEvent.from(a.body,a.formatted_body).serialize():a.msgtype===ue.MsgType.Emote?m=ad.EmoteEvent.from(a.body,a.formatted_body).serialize():a.msgtype===ue.MsgType.Notice&&(m=ad.NoticeEvent.from(a.body,a.formatted_body).serialize()),m&&a["m.new_content"]&&g){const p=l(a["m.new_content"],!1);p&&(m.content["m.new_content"]=p.content)}if(m)for(const[p,E]of Object.entries(a))m.content.hasOwnProperty(p)||(m.content[p]=E);return m},u=l(c);return u&&(o=u.type,c=u.content),this.sendEvent(e,t,o,c,i,s)}sendTextMessage(e,t,r,i,s){var o;!((o=t)!==null&&o!==void 0&&o.startsWith(dn))&&t!==null&&(s=i,i=r,r=t,t=null);const c=Xs.makeTextMessage(r);return this.sendMessage(e,t,c,i,s)}sendNotice(e,t,r,i,s){var o;!((o=t)!==null&&o!==void 0&&o.startsWith(dn))&&t!==null&&(s=i,i=r,r=t,t=null);const c=Xs.makeNotice(r);return this.sendMessage(e,t,c,i,s)}sendEmoteMessage(e,t,r,i,s){var o;!((o=t)!==null&&o!==void 0&&o.startsWith(dn))&&t!==null&&(s=i,i=r,r=t,t=null);const c=Xs.makeEmoteMessage(r);return this.sendMessage(e,t,c,i,s)}sendImageMessage(e,t,r,i,s="Image",o){var c;!((c=t)!==null&&c!==void 0&&c.startsWith(dn))&&t!==null&&(o=s,s=i||"Image",i=r,r=t,t=null),x.isFunction(s)&&(o=s,s=void 0);const l={msgtype:ue.MsgType.Image,url:r,info:i,body:s};return this.sendMessage(e,t,l,void 0,o)}sendStickerMessage(e,t,r,i,s="Sticker",o){var c;!((c=t)!==null&&c!==void 0&&c.startsWith(dn))&&t!==null&&(o=s,s=i||"Sticker",i=r,r=t,t=null),x.isFunction(s)&&(o=s,s=void 0);const l={url:r,info:i,body:s};return this.sendEvent(e,t,ue.EventType.Sticker,l,void 0,o)}sendHtmlMessage(e,t,r,i,s){var o;!((o=t)!==null&&o!==void 0&&o.startsWith(dn))&&t!==null&&(s=i,i=r,r=t,t=null);const c=Xs.makeHtmlMessage(r,i);return this.sendMessage(e,t,c,void 0,s)}sendHtmlNotice(e,t,r,i,s){var o;!((o=t)!==null&&o!==void 0&&o.startsWith(dn))&&t!==null&&(s=i,i=r,r=t,t=null);const c=Xs.makeHtmlNotice(r,i);return this.sendMessage(e,t,c,void 0,s)}sendHtmlEmote(e,t,r,i,s){var o;!((o=t)!==null&&o!==void 0&&o.startsWith(dn))&&t!==null&&(s=i,i=r,r=t,t=null);const c=Xs.makeHtmlEmote(r,i);return this.sendMessage(e,t,c,void 0,s)}sendReceipt(e,t,r,i){if(typeof r=="function"&&(i=r,r={}),this.isGuest())return Promise.resolve({});const s=x.encodeUri("/rooms/$roomId/receipt/$receiptType/$eventId",{$roomId:e.getRoomId(),$receiptType:t,$eventId:e.getId()}),o=this.http.authedRequest(i,M.Method.Post,s,void 0,r||{}),c=this.getRoom(e.getRoomId());return c&&c.addLocalEchoReceipt(this.credentials.userId,e,t),o}async sendReadReceipt(e,t,r){typeof t=="function"&&(r=t,t={}),t||(t={});const i=e.getId(),s=this.getRoom(e.getRoomId());if(s&&s.hasPendingEvent(i))throw new Error(`Cannot set read receipt to a pending event (${i})`);const o={"org.matrix.msc2285.hidden":Boolean(t.hidden)};return this.sendReceipt(e,"m.read",o,r)}async setRoomReadMarkers(e,t,r,i){const s=this.getRoom(e);if(s&&s.hasPendingEvent(t))throw new Error(`Cannot set read marker to a pending event (${t})`);let o;if(r){if(o=r.getId(),s&&s.hasPendingEvent(o))throw new Error(`Cannot set read receipt to a pending event (${o})`);s&&s.addLocalEchoReceipt(this.credentials.userId,r,"m.read")}return this.setRoomReadMarkersHttpRequest(e,t,o,i)}getUrlPreview(e,t,r){t=Math.floor(t/6e4)*6e4;const i=new URL(e);i.hash="",e=i.toString();const s=t+"_"+e,o=this.urlPreviewCache[s];if(o)return r&&o.then(r).catch(r),o;const c=this.http.authedRequest(r,M.Method.Get,"/preview_url",{url:e,ts:t.toString()},void 0,{prefix:M.PREFIX_MEDIA_R0});return this.urlPreviewCache[s]=c,c}sendTyping(e,t,r,i){if(this.isGuest())return Promise.resolve({});const s=x.encodeUri("/rooms/$roomId/typing/$userId",{$roomId:e,$userId:this.credentials.userId}),o={typing:t};return t&&(o.timeout=r||2e4),this.http.authedRequest(i,M.Method.Put,s,void 0,o)}getRoomUpgradeHistory(e,t=!1){let r=this.getRoom(e);if(!r)return[];const i=[r];let s=r.currentState.getStateEvents(ue.EventType.RoomCreate,"");for(;s;){const c=s.getContent().predecessor;if(c&&c.room_id){const l=this.getRoom(c.room_id);if(!l)break;if(t){const u=l.currentState.getStateEvents(ue.EventType.RoomTombstone,"");if(!u||u.getContent().replacement_room!==l.roomId)break}i.splice(0,0,l),s=l.currentState.getStateEvents(ue.EventType.RoomCreate,"")}else break}let o=r.currentState.getStateEvents(ue.EventType.RoomTombstone,"");for(;o;){const c=this.getRoom(o.getContent().replacement_room);if(!c||c.roomId===r.roomId||t&&(s=c.currentState.getStateEvents(ue.EventType.RoomCreate,""),!s||!s.getContent().predecessor||s.getContent().predecessor.room_id!==r.roomId))break;if(i.push(c),new Set(i.map(u=>u.roomId)).size<i.length)return i.slice(0,i.length-1);r=c,o=r.currentState.getStateEvents(ue.EventType.RoomTombstone,"")}return i}invite(e,t,r,i){return this.membershipChange(e,t,"invite",i,r)}inviteByEmail(e,t,r){return this.inviteByThreePid(e,"email",t,r)}async inviteByThreePid(e,t,r,i){const s=x.encodeUri("/rooms/$roomId/invite",{$roomId:e}),o=this.getIdentityServerUrl(!0);if(!o)return Promise.reject(new M.MatrixError({error:"No supplied identity server URL",errcode:"ORG.MATRIX.JSSDK_MISSING_PARAM"}));const c={id_server:o,medium:t,address:r};if(this.identityServer&&this.identityServer.getAccessToken&&await this.doesServerAcceptIdentityAccessToken()){const l=await this.identityServer.getAccessToken();l&&(c.id_access_token=l)}return this.http.authedRequest(i,M.Method.Post,s,void 0,c)}leave(e,t){return this.membershipChange(e,void 0,"leave",void 0,t)}leaveRoomChain(e,t=!0){const r=this.getRoomUpgradeHistory(e);let i=r;if(!t){i=[];for(const l of r)if(i.push(l),l.roomId===e)break}const s={},o=[],c=l=>this.leave(l).then(()=>{s[l]=null}).catch(u=>(s[l]=u,null));for(const l of i)o.push(c(l.roomId));return Promise.all(o).then(()=>s)}ban(e,t,r,i){return this.membershipChange(e,t,"ban",r,i)}forget(e,t,r){t===void 0&&(t=!0);const i=this.membershipChange(e,void 0,"forget",void 0,r);return t?i.then(s=>(this.store.removeRoom(e),this.emit(ss.DeleteRoom,e),s)):i}unban(e,t,r){const i=x.encodeUri("/rooms/$roomId/unban",{$roomId:e}),s={user_id:t};return this.http.authedRequest(r,M.Method.Post,i,void 0,s)}kick(e,t,r,i){const s=x.encodeUri("/rooms/$roomId/kick",{$roomId:e}),o={user_id:t,reason:r};return this.http.authedRequest(i,M.Method.Post,s,void 0,o)}membershipChange(e,t,r,i,s){x.isFunction(i)&&(s=i,i=void 0);const o=x.encodeUri("/rooms/$room_id/$membership",{$room_id:e,$membership:r});return this.http.authedRequest(s,M.Method.Post,o,void 0,{user_id:t,reason:i})}getPushActionsForEvent(e,t=!1){return(!e.getPushActions()||t)&&e.setPushActions(this.pushProcessor.actionsForEvent(e)),e.getPushActions()}setProfileInfo(e,t,r){const i=x.encodeUri("/profile/$userId/$info",{$userId:this.credentials.userId,$info:e});return this.http.authedRequest(r,M.Method.Put,i,void 0,t)}async setDisplayName(e,t){const r=await this.setProfileInfo("displayname",{displayname:e},t),i=this.getUser(this.getUserId());return i&&(i.displayName=e,i.emit(dd.UserEvent.DisplayName,i.events.presence,i)),r}async setAvatarUrl(e,t){const r=await this.setProfileInfo("avatar_url",{avatar_url:e},t),i=this.getUser(this.getUserId());return i&&(i.avatarUrl=e,i.emit(dd.UserEvent.AvatarUrl,i.events.presence,i)),r}mxcUrlToHttp(e,t,r,i,s){return(0,jM.getHttpUriForMxc)(this.baseUrl,e,t,r,i,s)}_unstable_setStatusMessage(e){const t="im.vector.user_status";return Promise.all(this.getRooms().map(async r=>{const i=r.getMyMembership()==="join",s=r.getInvitedAndJoinedMemberCount()===2;!i||!s||!r.currentState.mayClientSendStateEvent(t,this)||await this.sendStateEvent(r.roomId,t,{status:e},this.getUserId())})).then()}setPresence(e,t){const r=x.encodeUri("/presence/$userId/status",{$userId:this.credentials.userId});if(typeof e=="string"&&(e={presence:e}),["offline","online","unavailable"].indexOf(e.presence)===-1)throw new Error("Bad presence value: "+e.presence);return this.http.authedRequest(t,M.Method.Put,r,void 0,e)}getPresence(e,t){const r=x.encodeUri("/presence/$userId/status",{$userId:e});return this.http.authedRequest(t,M.Method.Get,r,void 0,void 0)}scrollback(e,t=30,r){x.isFunction(t)&&(r=t,t=void 0);let i=0,s=this.ongoingScrollbacks[e.roomId]||{};if(s.promise)return s.promise;if(s.errorTs){const l=Date.now()-s.errorTs;i=Math.max(eA-l,0)}if(e.oldState.paginationToken===null)return Promise.resolve(e);const o=this.store.scrollback(e,t).length;if(o===t)return Promise.resolve(e);t=t-o;const c=new Promise((l,u)=>{(0,x.sleep)(i).then(()=>this.createMessagesRequest(e.roomId,e.oldState.paginationToken,t,ua.Direction.Backward)).then(async a=>{var g;const m=a.chunk.map(this.getEventMapper());if(a.state){const I=a.state.map(this.getEventMapper());e.currentState.setUnknownStateEvents(I)}const[p,E]=this.partitionThreadedEvents(m);e.addEventsToTimeline(p,!0,e.getLiveTimeline()),await this.processThreadEvents(e,E,!0),e.oldState.paginationToken=a.end,a.chunk.length===0&&(e.oldState.paginationToken=null),this.store.storeEvents(e,m,a.end,!0),this.ongoingScrollbacks[e.roomId]=null,(g=r)===null||g===void 0||g(null,e),l(e)}).catch(a=>{var g;this.ongoingScrollbacks[e.roomId]={errorTs:Date.now()},(g=r)===null||g===void 0||g(a),u(a)})});return s={promise:c,errorTs:null},this.ongoingScrollbacks[e.roomId]=s,c}getEventMapper(e){return(0,YM.eventMapperFor)(this,e||{})}getEventTimeline(e,t){if(!this.timelineSupport)throw new Error("timeline support is disabled. Set the 'timelineSupport' parameter to true when creating MatrixClient to enable it.");if(e.getTimelineForEvent(t))return Promise.resolve(e.getTimelineForEvent(t));const r=x.encodeUri("/rooms/$roomId/context/$eventId",{$roomId:e.room.roomId,$eventId:t});let i;return this.clientOpts.lazyLoadMembers&&(i={filter:JSON.stringify(Nc.Filter.LAZY_LOADING_MESSAGES_FILTER)}),this.http.authedRequest(void 0,M.Method.Get,r,i).then(async o=>{if(!o.event)throw new Error("'event' not in '/context' result - homeserver too old?");if(e.getTimelineForEvent(t))return e.getTimelineForEvent(t);o.events_after.reverse();const l=o.events_after.concat([o.event]).concat(o.events_before).map(this.getEventMapper());let u=e.getTimelineForEvent(l[0].getId());if(!u)u=e.addTimeline(),u.initialiseState(o.state.map(this.getEventMapper())),u.getState(ua.EventTimeline.FORWARDS).paginationToken=o.end;else{const m=o.state.map(this.getEventMapper());u.getState(ua.EventTimeline.BACKWARDS).setUnknownStateEvents(m)}const[a,g]=this.partitionThreadedEvents(l);return e.addEventsToTimeline(a,!0,u,o.start),await this.processThreadEvents(e.room,g,!0),e.getTimelineForEvent(t)||u})}createMessagesRequest(e,t,r=30,i,s){const o=x.encodeUri("/rooms/$roomId/messages",{$roomId:e}),c={limit:r.toString(),dir:i};t&&(c.from=t);let l=null;if(this.clientOpts.lazyLoadMembers&&(l=Object.assign({},Nc.Filter.LAZY_LOADING_MESSAGES_FILTER)),s){var u;l=l||{},Object.assign(l,(u=s.getRoomTimelineFilterComponent())===null||u===void 0?void 0:u.toJSON())}return l&&(c.filter=JSON.stringify(l)),this.http.authedRequest(void 0,M.Method.Get,o,c)}paginateEventTimeline(e,t){const r=e.getTimelineSet()===this.notifTimelineSet;t=t||{};const i=t.backwards||!1;if(r&&!i)throw new Error("paginateNotifTimeline can only paginate backwards");const s=i?ua.EventTimeline.BACKWARDS:ua.EventTimeline.FORWARDS,o=e.getPaginationToken(s),c=e.paginationRequests[s];if(c)return c;let l,u,a;if(r){var g;l="/notifications",u={limit:((g=t.limit)!==null&&g!==void 0?g:30).toString(),only:"highlight"},o!=="end"&&(u.from=o),a=this.http.authedRequest(void 0,M.Method.Get,l,u,void 0).then(async m=>{const p=m.next_token,E=[];for(let P=0;P<m.notifications.length;P++){const S=m.notifications[P],T=this.getEventMapper()(S.event);T.setPushActions(cd.PushProcessor.actionListToActionsObject(S.actions)),T.event.room_id=S.room_id,E[P]=T}const[I,w]=this.partitionThreadedEvents(E),k=e.getTimelineSet();return k.addEventsToTimeline(I,i,e,p),await this.processThreadEvents(k.room,w,i),i&&!m.next_token&&e.setPaginationToken(null,s),!!m.next_token}).finally(()=>{e.paginationRequests[s]=null}),e.paginationRequests[s]=a}else{const m=this.getRoom(e.getRoomId());if(!m)throw new Error("Unknown room "+e.getRoomId());a=this.createMessagesRequest(e.getRoomId(),o,t.limit,s,e.getFilter()).then(async p=>{if(p.state){const P=e.getState(s),S=p.state.map(this.getEventMapper());P.setUnknownStateEvents(S)}const E=p.end,I=p.chunk.map(this.getEventMapper()),[w,k]=this.partitionThreadedEvents(I);return e.getTimelineSet().addEventsToTimeline(w,i,e,E),await this.processThreadEvents(m,k,i),i&&p.end==p.start&&e.setPaginationToken(null,s),p.end!=p.start}).finally(()=>{e.paginationRequests[s]=null}),e.paginationRequests[s]=a}return a}resetNotifTimelineSet(){!this.notifTimelineSet||this.notifTimelineSet.resetLiveTimeline("end",null)}peekInRoom(e){return this.peekSync&&this.peekSync.stopPeeking(),this.peekSync=new zs.SyncApi(this,this.clientOpts),this.peekSync.peek(e)}stopPeeking(){this.peekSync&&(this.peekSync.stopPeeking(),this.peekSync=null)}setGuestAccess(e,t){const r=this.sendStateEvent(e,ue.EventType.RoomGuestAccess,{guest_access:t.allowJoin?"can_join":"forbidden"},"");let i=Promise.resolve(void 0);return t.allowRead&&(i=this.sendStateEvent(e,ue.EventType.RoomHistoryVisibility,{history_visibility:"world_readable"},"")),Promise.all([i,r]).then()}requestRegisterEmailToken(e,t,r,i){return this.requestTokenFromEndpoint("/register/email/requestToken",{email:e,client_secret:t,send_attempt:r,next_link:i})}requestRegisterMsisdnToken(e,t,r,i,s){return this.requestTokenFromEndpoint("/register/msisdn/requestToken",{country:e,phone_number:t,client_secret:r,send_attempt:i,next_link:s})}requestAdd3pidEmailToken(e,t,r,i){return this.requestTokenFromEndpoint("/account/3pid/email/requestToken",{email:e,client_secret:t,send_attempt:r,next_link:i})}requestAdd3pidMsisdnToken(e,t,r,i,s){return this.requestTokenFromEndpoint("/account/3pid/msisdn/requestToken",{country:e,phone_number:t,client_secret:r,send_attempt:i,next_link:s})}requestPasswordEmailToken(e,t,r,i){return this.requestTokenFromEndpoint("/account/password/email/requestToken",{email:e,client_secret:t,send_attempt:r,next_link:i})}requestPasswordMsisdnToken(e,t,r,i,s){return this.requestTokenFromEndpoint("/account/password/msisdn/requestToken",{country:e,phone_number:t,client_secret:r,send_attempt:i,next_link:s})}async requestTokenFromEndpoint(e,t){const r=Object.assign({},t);if(!await this.doesServerSupportSeparateAddAndBind()&&this.idBaseUrl){const i=new URL(this.idBaseUrl);if(r.id_server=i.host,this.identityServer&&this.identityServer.getAccessToken&&await this.doesServerAcceptIdentityAccessToken()){const s=await this.identityServer.getAccessToken();s&&(r.id_access_token=s)}}return this.http.request(void 0,M.Method.Post,e,void 0,r)}getRoomPushRule(e,t){if(this.pushRules)for(let r=0;r<this.pushRules[e].room.length;r++){const i=this.pushRules[e].room[r];if(i.rule_id===t)return i}else throw new Error("SyncApi.sync() must be done before accessing to push rules.")}setRoomMutePushRule(e,t,r){let i,s;const o=this.getRoomPushRule(e,t);if(o&&0<=o.actions.indexOf("dont_notify")&&(s=!0),!r)s&&(i=this.deletePushRule(e,Lc.PushRuleKind.RoomSpecific,o.rule_id));else if(!o)i=this.addPushRule(e,Lc.PushRuleKind.RoomSpecific,t,{actions:["dont_notify"]});else if(!s){const c=x.defer();this.deletePushRule(e,Lc.PushRuleKind.RoomSpecific,o.rule_id).then(()=>{this.addPushRule(e,Lc.PushRuleKind.RoomSpecific,t,{actions:["dont_notify"]}).then(()=>{c.resolve()}).catch(l=>{c.reject(l)})}).catch(l=>{c.reject(l)}),i=c.promise}if(i)return new Promise((c,l)=>{i.then(()=>{this.getPushRules().then(u=>{this.pushRules=u,c()}).catch(u=>{l(u)})}).catch(u=>{this.getPushRules().then(a=>{this.pushRules=a,l(u)}).catch(a=>{l(u)})})})}searchMessageText(e,t){const r={search_term:e.query};return"keys"in e&&(r.keys=e.keys),this.search({body:{search_categories:{room_events:r}}},t)}searchRoomEvents(e){const t={search_categories:{room_events:{search_term:e.term,filter:e.filter,order_by:JM.SearchOrderBy.Recent,event_context:{before_limit:1,after_limit:1,include_profile:!0}}}},r={_query:t,results:[],highlights:[]};return this.search({body:t}).then(i=>this.processRoomEventsSearch(r,i))}backPaginateRoomEventsSearch(e){if(!e.next_batch)return Promise.reject(new Error("Cannot backpaginate event search any further"));if(e.pendingRequest)return e.pendingRequest;const t={body:e._query,next_batch:e.next_batch},r=this.search(t).then(i=>this.processRoomEventsSearch(e,i)).finally(()=>{e.pendingRequest=null});return e.pendingRequest=r,r}processRoomEventsSearch(e,t){const r=t.search_categories.room_events;e.count=r.count,e.next_batch=r.next_batch;const i=new Set(r.highlights);e.highlights.forEach(o=>{i.add(o)}),e.highlights=Array.from(i);const s=r.results?r.results.length:0;for(let o=0;o<s;o++){const c=VM.SearchResult.fromJson(r.results[o],this.getEventMapper()),l=this.getRoom(c.context.getEvent().getRoomId());if(l)for(const u of c.context.getTimeline()){const a=l.getMember(u.getSender());!u.sender&&a&&(u.sender=a)}e.results.push(c)}return e}syncLeftRooms(){if(this.syncedLeftRooms)return Promise.resolve([]);if(this.syncLeftRoomsPromise)return this.syncLeftRoomsPromise;const e=new zs.SyncApi(this,this.clientOpts);return this.syncLeftRoomsPromise=e.syncLeftRooms(),this.syncLeftRoomsPromise.then(t=>{se.logger.log("Marking success of sync left room request"),this.syncedLeftRooms=!0}).finally(()=>{this.syncLeftRoomsPromise=null}),this.syncLeftRoomsPromise}createFilter(e){const t=x.encodeUri("/user/$userId/filter",{$userId:this.credentials.userId});return this.http.authedRequest(void 0,M.Method.Post,t,void 0,e).then(r=>{const i=Nc.Filter.fromJson(this.credentials.userId,r.filter_id,e);return this.store.storeFilter(i),i})}getFilter(e,t,r){if(r){const s=this.store.getFilter(e,t);if(s)return Promise.resolve(s)}const i=x.encodeUri("/user/$userId/filter/$filterId",{$userId:e,$filterId:t});return this.http.authedRequest(void 0,M.Method.Get,i,void 0,void 0).then(s=>{const o=Nc.Filter.fromJson(e,t,s);return this.store.storeFilter(o),o})}async getOrCreateFilter(e,t){const r=this.store.getFilterIdByName(e);let i;if(r){try{const o=await this.getFilter(this.credentials.userId,r,!0);if(o){const c=o.getDefinition(),l=t.getDefinition();x.deepCompare(c,l)&&(i=r)}}catch(o){if(o.errcode!=="M_UNKNOWN"&&o.errcode!=="M_NOT_FOUND")throw o}i||this.store.setFilterIdByName(e,void 0)}if(i)return i;const s=await this.createFilter(t.getDefinition());return this.store.setFilterIdByName(e,s.filterId),s.filterId}getOpenIdToken(){const e=x.encodeUri("/user/$userId/openid/request_token",{$userId:this.credentials.userId});return this.http.authedRequest(void 0,M.Method.Post,e,void 0,{})}turnServer(e){return this.http.authedRequest(e,M.Method.Get,"/voip/turnServer")}getTurnServers(){return this.turnServers||[]}getTurnServersExpiry(){return this.turnServersExpiry}async checkTurnServers(){if(!this.canSupportVoip)return;let e=!1;const t=this.turnServersExpiry-Date.now();if(t>pm)se.logger.debug("TURN creds are valid for another "+t+" ms: not fetching new ones."),e=!0;else{se.logger.debug("Fetching new TURN credentials");try{const r=await this.turnServer();if(r.uris){se.logger.log("Got TURN URIs: "+r.uris+" refresh in "+r.ttl+" secs");const i={urls:r.uris,username:r.username,credential:r.password};this.turnServers=[i],this.turnServersExpiry=Date.now()+r.ttl*1e3,e=!0}}catch(r){se.logger.error("Failed to get TURN URIs",r),r.httpStatus===403&&(se.logger.info("TURN access unavailable for this account: stopping credentials checks"),this.checkTurnServersIntervalID!==null&&j.clearInterval(this.checkTurnServersIntervalID),this.checkTurnServersIntervalID=null)}}return e}setFallbackICEServerAllowed(e){this.fallbackICEServerAllowed=e}isFallbackICEServerAllowed(){return this.fallbackICEServerAllowed}isSynapseAdministrator(){const e=x.encodeUri("/_synapse/admin/v1/users/$userId/admin",{$userId:this.getUserId()});return this.http.authedRequest(void 0,M.Method.Get,e,void 0,void 0,{prefix:""}).then(t=>t.admin)}whoisSynapseUser(e){const t=x.encodeUri("/_synapse/admin/v1/whois/$userId",{$userId:e});return this.http.authedRequest(void 0,M.Method.Get,t,void 0,void 0,{prefix:""})}deactivateSynapseUser(e){const t=x.encodeUri("/_synapse/admin/v1/deactivate/$userId",{$userId:e});return this.http.authedRequest(void 0,M.Method.Post,t,void 0,void 0,{prefix:""})}async fetchClientWellKnown(){this.clientWellKnownPromise=KM.AutoDiscovery.getRawClientConfig(this.getDomain()),this.clientWellKnown=await this.clientWellKnownPromise,this.emit(ss.ClientWellKnown,this.clientWellKnown)}getClientWellKnown(){return this.clientWellKnown}waitForClientWellKnown(){return this.clientWellKnownPromise}storeClientOptions(){const e=["boolean","string","number"],t=Object.entries(this.clientOpts).filter(([r,i])=>e.includes(typeof i)).reduce((r,[i,s])=>(r[i]=s,r),{});return this.store.storeClientOptions(t)}async _unstable_getSharedRooms(e){if(!await this.doesServerSupportUnstableFeature("uk.half-shot.msc2666"))throw Error("Server does not support shared_rooms API");const t=x.encodeUri("/uk.half-shot.msc2666/user/shared_rooms/$userId",{$userId:e});return(await this.http.authedRequest(void 0,M.Method.Get,t,void 0,void 0,{prefix:M.PREFIX_UNSTABLE})).joined}getVersions(){return this.serverVersionsPromise?this.serverVersionsPromise:(this.serverVersionsPromise=this.http.request(void 0,M.Method.Get,"/_matrix/client/versions",void 0,void 0,{prefix:""}).catch(e=>{throw this.serverVersionsPromise=null,e}),this.serverVersionsPromise)}async isVersionSupported(e){const{versions:t}=await this.getVersions();return t&&t.includes(e)}async doesServerSupportLazyLoading(){const e=await this.getVersions();if(!e)return!1;const t=e.versions,r=e.unstable_features;return t&&t.includes("r0.5.0")||r&&r["m.lazy_load_members"]}async doesServerRequireIdServerParam(){const e=await this.getVersions();if(!e)return!0;const t=e.versions;if(t&&t.includes("r0.6.0"))return!1;const r=e.unstable_features;return!r||r["m.require_identity_server"]===void 0?!0:r["m.require_identity_server"]}async doesServerAcceptIdentityAccessToken(){const e=await this.getVersions();if(!e)return!1;const t=e.versions,r=e.unstable_features;return t&&t.includes("r0.6.0")||r&&r["m.id_access_token"]}async doesServerSupportSeparateAddAndBind(){const e=await this.getVersions();if(!e)return!1;const t=e.versions,r=e.unstable_features;return t&&t.includes("r0.6.0")||r&&r["m.separate_add_and_bind"]}async doesServerSupportUnstableFeature(e){const t=await this.getVersions();if(!t)return!1;const r=t.unstable_features;return r&&!!r[e]}async doesServerForceEncryptionForPreset(e){const t=await this.getVersions();if(!t)return!1;const r=t.unstable_features,i=e.includes("_chat")?e.substring(0,e.indexOf("_chat")):e;return r&&!!r[`io.element.e2ee_forced.${i}`]}async doesServerSupportThread(){try{const e=await this.doesServerSupportUnstableFeature("org.matrix.msc3440"),t=await this.doesServerSupportUnstableFeature("org.matrix.msc3440.stable")||await this.isVersionSupported("v1.3");return{serverSupport:e||t,stable:t}}catch{return null}}hasLazyLoadMembersEnabled(){return!!this.clientOpts.lazyLoadMembers}setCanResetTimelineCallback(e){this.canResetTimelineCallback=e}getCanResetTimelineCallback(){return this.canResetTimelineCallback}async relations(e,t,r,i,s={}){const o=this.getEncryptedIfNeededEventType(e,i),c=await this.fetchRelations(e,t,r,o,s),l=this.getEventMapper();let u;c.original_event&&(u=l(c.original_event));let a=c.chunk.map(l);if(o===ue.EventType.RoomMessageEncrypted){const g=u?a.concat(u):a;await Promise.all(g.map(m=>this.decryptEventIfNeeded(m))),i!==null&&(a=a.filter(m=>m.getType()===i))}return u&&r===ue.RelationType.Replace&&(a=a.filter(g=>g.getSender()===u.getSender())),{originalEvent:u,events:a,nextBatch:c.next_batch,prevBatch:c.prev_batch}}getCrossSigningCacheCallbacks(){var e;return(e=this.crypto)===null||e===void 0?void 0:e.crossSigningInfo.getCacheCallbacks()}generateClientSecret(){return(0,zM.randomString)(32)}decryptEventIfNeeded(e,t){return e.shouldAttemptDecryption()&&e.attemptDecryption(this.crypto,t),e.isBeingDecrypted()?e.getDecryptionPromise():Promise.resolve()}termsUrlForService(e,t){switch(e){case um.SERVICE_TYPES.IS:return t+M.PREFIX_IDENTITY_V2+"/terms";case um.SERVICE_TYPES.IM:return t+"/_matrix/integrations/v1/terms";default:throw new Error("Unsupported service type")}}getHomeserverUrl(){return this.baseUrl}getIdentityServerUrl(e=!1){return e&&(this.idBaseUrl.startsWith("http://")||this.idBaseUrl.startsWith("https://"))?this.idBaseUrl.split("://")[1]:this.idBaseUrl}setIdentityServerUrl(e){this.idBaseUrl=x.ensureNoTrailingSlash(e),this.http.setIdBaseUrl(this.idBaseUrl)}getAccessToken(){return this.http.opts.accessToken||null}setAccessToken(e){this.http.opts.accessToken=e}isLoggedIn(){return this.http.opts.accessToken!==void 0}makeTxnId(){return"m"+new Date().getTime()+"."+this.txnCtr++}isUsernameAvailable(e){return this.http.authedRequest(void 0,M.Method.Get,"/register/available",{username:e}).then(t=>t.available).catch(t=>t.errcode==="M_USER_IN_USE"?!1:Promise.reject(t))}register(e,t,r,i,s,o,c,l){s===!0?s={email:!0}:(s==null||s===!1)&&(s={}),typeof c=="function"&&(l=c,c=void 0),r&&(i.session=r);const u={auth:i,refresh_token:!0};return e!=null&&(u.username=e),t!=null&&(u.password=t),s.email&&(u.bind_email=!0),s.msisdn&&(u.bind_msisdn=!0),o!=null&&(u.guest_access_token=o),c!=null&&(u.inhibit_login=c),t!=null&&(u.x_show_msisdn=!0),this.registerRequest(u,void 0,l)}registerGuest(e,t){return e=e||{},e.body=e.body||{},this.registerRequest(e.body,"guest",t)}registerRequest(e,t,r){const i={};return t&&(i.kind=t),this.http.request(r,M.Method.Post,"/register",i,e)}refreshToken(e){return this.http.authedRequest(void 0,M.Method.Post,"/refresh",void 0,{refresh_token:e},{prefix:M.PREFIX_V1,inhibitLogoutEmit:!0})}loginFlows(e){return this.http.request(e,M.Method.Get,"/login")}login(e,t,r){const i={type:e};return Object.assign(i,t),this.http.authedRequest((s,o)=>{o&&o.access_token&&o.user_id&&(this.http.opts.accessToken=o.access_token,this.credentials={userId:o.user_id}),r&&r(s,o)},M.Method.Post,"/login",void 0,i)}loginWithPassword(e,t,r){return this.login("m.login.password",{user:e,password:t},r)}loginWithSAML2(e,t){return this.login("m.login.saml2",{relay_state:e},t)}getCasLoginUrl(e){return this.getSsoLoginUrl(e,"cas")}getSsoLoginUrl(e,t="sso",r){let i="/login/"+t+"/redirect";return r&&(i+="/"+r),this.http.getUrl(i,{redirectUrl:e},M.PREFIX_R0)}loginWithToken(e,t){return this.login("m.login.token",{token:e},t)}async logout(e){var t,r;if((t=this.crypto)!==null&&t!==void 0&&(r=t.backupManager)!==null&&r!==void 0&&r.getKeyBackupEnabled())try{for(;await this.crypto.backupManager.backupPendingKeys(200)>0;);}catch(i){se.logger.error("Key backup request failed when logging out. Some keys may be missing from backup",i)}return this.http.authedRequest(e,M.Method.Post,"/logout")}deactivateAccount(e,t){if(typeof t=="function")throw new Error("deactivateAccount no longer accepts a callback parameter");const r={};return e&&(r.auth=e),t!==void 0&&(r.erase=t),this.http.authedRequest(void 0,M.Method.Post,"/account/deactivate",void 0,r)}getFallbackAuthUrl(e,t){const r=x.encodeUri("/auth/$loginType/fallback/web",{$loginType:e});return this.http.getUrl(r,{session:t},M.PREFIX_R0)}async createRoom(e,t){const r=(e.invite_3pid||[]).filter(i=>!i.id_access_token);if(r.length>0&&this.identityServer&&this.identityServer.getAccessToken&&await this.doesServerAcceptIdentityAccessToken()){const i=await this.identityServer.getAccessToken();if(i)for(const s of r)s.id_access_token=i}return this.http.authedRequest(t,M.Method.Post,"/createRoom",void 0,e)}async fetchRelations(e,t,r,i,s={}){const o=x.encodeParams(s);let c="/rooms/$roomId/relations/$eventId";r!==null?(c+="/$relationType",i!==null&&(c+="/$eventType")):i!==null&&(se.logger.warn(`eventType: ${i} ignored when fetching
- relations as relationType is null`),i=null);const l=x.encodeUri(c+"?"+o,{$roomId:e,$eventId:t,$relationType:r,$eventType:i});return await this.http.authedRequest(void 0,M.Method.Get,l,null,null,{prefix:M.PREFIX_UNSTABLE})}roomState(e,t){const r=x.encodeUri("/rooms/$roomId/state",{$roomId:e});return this.http.authedRequest(t,M.Method.Get,r)}fetchRoomEvent(e,t,r){const i=x.encodeUri("/rooms/$roomId/event/$eventId",{$roomId:e,$eventId:t});return this.http.authedRequest(r,M.Method.Get,i)}members(e,t,r,i,s){const o={};t&&(o.membership=t),r&&(o.not_membership=r),i&&(o.at=i);const c=x.encodeParams(o),l=x.encodeUri("/rooms/$roomId/members?"+c,{$roomId:e});return this.http.authedRequest(s,M.Method.Get,l)}upgradeRoom(e,t){const r=x.encodeUri("/rooms/$roomId/upgrade",{$roomId:e});return this.http.authedRequest(void 0,M.Method.Post,r,void 0,{new_version:t})}getStateEvent(e,t,r,i){const s={$roomId:e,$eventType:t,$stateKey:r};let o=x.encodeUri("/rooms/$roomId/state/$eventType",s);return r!==void 0&&(o=x.encodeUri(o+"/$stateKey",s)),this.http.authedRequest(i,M.Method.Get,o)}sendStateEvent(e,t,r,i="",s){const o={$roomId:e,$eventType:t,$stateKey:i};let c=x.encodeUri("/rooms/$roomId/state/$eventType",o);return i!==void 0&&(c=x.encodeUri(c+"/$stateKey",o)),this.http.authedRequest(s,M.Method.Put,c,void 0,r)}roomInitialSync(e,t,r){var i,s;x.isFunction(t)&&(r=t,t=void 0);const o=x.encodeUri("/rooms/$roomId/initialSync",{$roomId:e});return this.http.authedRequest(r,M.Method.Get,o,{limit:(i=(s=t)===null||s===void 0?void 0:s.toString())!==null&&i!==void 0?i:"30"})}setRoomReadMarkersHttpRequest(e,t,r,i){const s=x.encodeUri("/rooms/$roomId/read_markers",{$roomId:e}),o={"m.fully_read":t,"m.read":r,"org.matrix.msc2285.hidden":Boolean(i?i.hidden:!1)};return this.http.authedRequest(void 0,M.Method.Post,s,void 0,o)}getJoinedRooms(){const e=x.encodeUri("/joined_rooms",{});return this.http.authedRequest(void 0,M.Method.Get,e)}getJoinedRoomMembers(e){const t=x.encodeUri("/rooms/$roomId/joined_members",{$roomId:e});return this.http.authedRequest(void 0,M.Method.Get,t)}publicRooms(e,t){typeof e=="function"&&(t=e,e={}),e===void 0&&(e={});const r={};return e.server&&(r.server=e.server,delete e.server),Object.keys(e).length===0&&Object.keys(r).length===0?this.http.authedRequest(t,M.Method.Get,"/publicRooms"):this.http.authedRequest(t,M.Method.Post,"/publicRooms",r,e)}createAlias(e,t,r){const i=x.encodeUri("/directory/room/$alias",{$alias:e}),s={room_id:t};return this.http.authedRequest(r,M.Method.Put,i,void 0,s)}deleteAlias(e,t){const r=x.encodeUri("/directory/room/$alias",{$alias:e});return this.http.authedRequest(t,M.Method.Delete,r,void 0,void 0)}unstableGetLocalAliases(e,t){const r=x.encodeUri("/rooms/$roomId/aliases",{$roomId:e}),i=M.PREFIX_UNSTABLE+"/org.matrix.msc2432";return this.http.authedRequest(t,M.Method.Get,r,null,null,{prefix:i})}getRoomIdForAlias(e,t){const r=x.encodeUri("/directory/room/$alias",{$alias:e});return this.http.authedRequest(t,M.Method.Get,r)}resolveRoomAlias(e,t){const r=x.encodeUri("/directory/room/$alias",{$alias:e});return this.http.request(t,M.Method.Get,r)}getRoomDirectoryVisibility(e,t){const r=x.encodeUri("/directory/list/room/$roomId",{$roomId:e});return this.http.authedRequest(t,M.Method.Get,r)}setRoomDirectoryVisibility(e,t,r){const i=x.encodeUri("/directory/list/room/$roomId",{$roomId:e});return this.http.authedRequest(r,M.Method.Put,i,void 0,{visibility:t})}setRoomDirectoryVisibilityAppService(e,t,r,i){const s=x.encodeUri("/directory/list/appservice/$networkId/$roomId",{$networkId:e,$roomId:t});return this.http.authedRequest(i,M.Method.Put,s,void 0,{visibility:r})}searchUserDirectory(e){const t={search_term:e.term};return e.limit!==void 0&&(t.limit=e.limit),this.http.authedRequest(void 0,M.Method.Post,"/user_directory/search",void 0,t)}uploadContent(e,t){return this.http.uploadContent(e,t)}cancelUpload(e){return this.http.cancelUpload(e)}getCurrentUploads(){return this.http.getCurrentUploads()}getProfileInfo(e,t,r){x.isFunction(t)&&(r=t,t=void 0);const i=t?x.encodeUri("/profile/$userId/$info",{$userId:e,$info:t}):x.encodeUri("/profile/$userId",{$userId:e});return this.http.authedRequest(r,M.Method.Get,i)}getThreePids(e){const t="/account/3pid";return this.http.authedRequest(e,M.Method.Get,t,void 0,void 0)}addThreePid(e,t,r){const i="/account/3pid",s={threePidCreds:e,bind:t};return this.http.authedRequest(r,M.Method.Post,i,null,s)}async addThreePidOnly(e){const t="/account/3pid/add",r=await this.isVersionSupported("r0.6.0")?M.PREFIX_R0:M.PREFIX_UNSTABLE;return this.http.authedRequest(void 0,M.Method.Post,t,null,e,{prefix:r})}async bindThreePid(e){const t="/account/3pid/bind",r=await this.isVersionSupported("r0.6.0")?M.PREFIX_R0:M.PREFIX_UNSTABLE;return this.http.authedRequest(void 0,M.Method.Post,t,null,e,{prefix:r})}async unbindThreePid(e,t){const r="/account/3pid/unbind",i={medium:e,address:t,id_server:this.getIdentityServerUrl(!0)},s=await this.isVersionSupported("r0.6.0")?M.PREFIX_R0:M.PREFIX_UNSTABLE;return this.http.authedRequest(void 0,M.Method.Post,r,null,i,{prefix:s})}deleteThreePid(e,t){const r="/account/3pid/delete";return this.http.authedRequest(void 0,M.Method.Post,r,null,{medium:e,address:t})}setPassword(e,t,r){const i="/account/password",s={auth:e,new_password:t};return this.http.authedRequest(r,M.Method.Post,i,null,s)}getDevices(){return this.http.authedRequest(void 0,M.Method.Get,"/devices",void 0,void 0)}getDevice(e){const t=x.encodeUri("/devices/$device_id",{$device_id:e});return this.http.authedRequest(void 0,M.Method.Get,t,void 0,void 0)}setDeviceDetails(e,t){const r=x.encodeUri("/devices/$device_id",{$device_id:e});return this.http.authedRequest(void 0,M.Method.Put,r,void 0,t)}deleteDevice(e,t){const r=x.encodeUri("/devices/$device_id",{$device_id:e}),i={};return t&&(i.auth=t),this.http.authedRequest(void 0,M.Method.Delete,r,void 0,i)}deleteMultipleDevices(e,t){const r={devices:e};t&&(r.auth=t);const i="/delete_devices";return this.http.authedRequest(void 0,M.Method.Post,i,void 0,r)}getPushers(e){const t="/pushers";return this.http.authedRequest(e,M.Method.Get,t,void 0,void 0)}setPusher(e,t){const r="/pushers/set";return this.http.authedRequest(t,M.Method.Post,r,null,e)}getPushRules(e){return this.http.authedRequest(e,M.Method.Get,"/pushrules/").then(t=>cd.PushProcessor.rewriteDefaultRules(t))}addPushRule(e,t,r,i,s){const o=x.encodeUri("/pushrules/"+e+"/$kind/$ruleId",{$kind:t,$ruleId:r});return this.http.authedRequest(s,M.Method.Put,o,void 0,i)}deletePushRule(e,t,r,i){const s=x.encodeUri("/pushrules/"+e+"/$kind/$ruleId",{$kind:t,$ruleId:r});return this.http.authedRequest(i,M.Method.Delete,s)}setPushRuleEnabled(e,t,r,i,s){const o=x.encodeUri("/pushrules/"+e+"/$kind/$ruleId/enabled",{$kind:t,$ruleId:r});return this.http.authedRequest(s,M.Method.Put,o,void 0,{enabled:i})}setPushRuleActions(e,t,r,i,s){const o=x.encodeUri("/pushrules/"+e+"/$kind/$ruleId/actions",{$kind:t,$ruleId:r});return this.http.authedRequest(s,M.Method.Put,o,void 0,{actions:i})}search(e,t){const r={};return e.next_batch&&(r.next_batch=e.next_batch),this.http.authedRequest(t,M.Method.Post,"/search",r,e.body)}uploadKeysRequest(e,t,r){return this.http.authedRequest(r,M.Method.Post,"/keys/upload",void 0,e)}uploadKeySignatures(e){return this.http.authedRequest(void 0,M.Method.Post,"/keys/signatures/upload",void 0,e,{prefix:M.PREFIX_UNSTABLE})}downloadKeysForUsers(e,t){if(x.isFunction(t))throw new Error("downloadKeysForUsers no longer accepts a callback parameter");t=t||{};const r={device_keys:{}};return"token"in t&&(r.token=t.token),e.forEach(i=>{r.device_keys[i]=[]}),this.http.authedRequest(void 0,M.Method.Post,"/keys/query",void 0,r)}claimOneTimeKeys(e,t="signed_curve25519",r){const i={};t===void 0&&(t="signed_curve25519");for(let c=0;c<e.length;++c){const l=e[c][0],u=e[c][1],a=i[l]||{};i[l]=a,a[u]=t}const s={one_time_keys:i};r&&(s.timeout=r);const o="/keys/claim";return this.http.authedRequest(void 0,M.Method.Post,o,void 0,s)}getKeyChanges(e,t){const r={from:e,to:t},i="/keys/changes";return this.http.authedRequest(void 0,M.Method.Get,i,r,void 0)}uploadDeviceSigningKeys(e,t){const r=Object.assign({},t);return e&&Object.assign(r,{auth:e}),this.http.authedRequest(void 0,M.Method.Post,"/keys/device_signing/upload",void 0,r,{prefix:M.PREFIX_UNSTABLE})}registerWithIdentityServer(e){if(!this.idBaseUrl)throw new Error("No identity server base URL set");const t=this.idBaseUrl+M.PREFIX_IDENTITY_V2+"/account/register";return this.http.requestOtherUrl(void 0,M.Method.Post,t,null,e)}async requestEmailToken(e,t,r,i,s,o){const c={client_secret:t,email:e,send_attempt:r==null?void 0:r.toString(),next_link:i};return await this.http.idServerRequest(s,M.Method.Post,"/validate/email/requestToken",c,M.PREFIX_IDENTITY_V2,o)}async requestMsisdnToken(e,t,r,i,s,o,c){const l={client_secret:r,country:e,phone_number:t,send_attempt:i==null?void 0:i.toString(),next_link:s};return await this.http.idServerRequest(o,M.Method.Post,"/validate/msisdn/requestToken",l,M.PREFIX_IDENTITY_V2,c)}async submitMsisdnToken(e,t,r,i){const s={sid:e,client_secret:t,token:r};return await this.http.idServerRequest(void 0,M.Method.Post,"/validate/msisdn/submitToken",s,M.PREFIX_IDENTITY_V2,i)}submitMsisdnTokenOtherUrl(e,t,r,i){const s={sid:t,client_secret:r,token:i};return this.http.requestOtherUrl(void 0,M.Method.Post,e,void 0,s)}getIdentityHashDetails(e){return this.http.idServerRequest(void 0,M.Method.Get,"/hash_details",null,M.PREFIX_IDENTITY_V2,e)}async identityHashedLookup(e,t){const r={},i=await this.getIdentityHashDetails(t);if(!i||!i.lookup_pepper||!i.algorithms)throw new Error("Unsupported identity server: bad response");r.pepper=i.lookup_pepper;const s={};if(i.algorithms.includes("sha256")){const l=new j.Olm.Utility;r.addresses=e.map(u=>{const a=u[0].toLowerCase(),g=u[1].toLowerCase(),m=l.sha256(`${a} ${g} ${r.pepper}`).replace(/\+/g,"-").replace(/\//g,"_");return s[m]=u[0],m}),r.algorithm="sha256"}else if(i.algorithms.includes("none"))r.addresses=e.map(l=>{const u=l[0].toLowerCase(),a=l[1].toLowerCase(),g=`${u} ${a}`;return s[g]=l[0],g}),r.algorithm="none";else throw new Error("Unsupported identity server: unknown hash algorithm");const o=await this.http.idServerRequest(void 0,M.Method.Post,"/lookup",r,M.PREFIX_IDENTITY_V2,t);if(!o||!o.mappings)return[];const c=[];for(const l of Object.keys(o.mappings)){const u=o.mappings[l],a=s[l];if(!a)throw new Error("Identity server returned more results than expected");c.push({address:a,mxid:u})}return c}async lookupThreePid(e,t,r,i){const o=(await this.identityHashedLookup([[t,e]],i)).find(l=>l.address===t);if(!o)return r&&r(null,{}),{};const c={address:t,medium:e,mxid:o.mxid};return r&&r(null,c),c}async bulkLookupThreePids(e,t){const r=await this.identityHashedLookup(e.map(s=>[s[1],s[0]]),t),i=[];for(const s of r){const o=e.find(c=>c[1]===s.address);if(!o)throw new Error("Identity sever returned unexpected results");i.push([o[0],s.address,s.mxid])}return{threepids:i}}getIdentityAccount(e){return this.http.idServerRequest(void 0,M.Method.Get,"/account",void 0,M.PREFIX_IDENTITY_V2,e)}sendToDevice(e,t,r){const i=x.encodeUri("/sendToDevice/$eventType/$txnId",{$eventType:e,$txnId:r||this.makeTxnId()}),s={messages:t},o=Object.keys(t).reduce((c,l)=>(c[l]=Object.keys(t[l]),c),{});return se.logger.log(`PUT ${i}`,o),this.http.authedRequest(void 0,M.Method.Put,i,void 0,s)}getThirdpartyProtocols(){return this.http.authedRequest(void 0,M.Method.Get,"/thirdparty/protocols",void 0,void 0).then(e=>{if(!e||typeof e!="object")throw new Error(`/thirdparty/protocols did not return an object: ${e}`);return e})}getThirdpartyLocation(e,t){const r=x.encodeUri("/thirdparty/location/$protocol",{$protocol:e});return this.http.authedRequest(void 0,M.Method.Get,r,t,void 0)}getThirdpartyUser(e,t){const r=x.encodeUri("/thirdparty/user/$protocol",{$protocol:e});return this.http.authedRequest(void 0,M.Method.Get,r,t,void 0)}getTerms(e,t){const r=this.termsUrlForService(e,t);return this.http.requestOtherUrl(void 0,M.Method.Get,r)}agreeToTerms(e,t,r,i){const s=this.termsUrlForService(e,t),o={Authorization:"Bearer "+r};return this.http.requestOtherUrl(void 0,M.Method.Post,s,null,{user_accepts:i},{headers:o})}reportEvent(e,t,r,i){const s=x.encodeUri("/rooms/$roomId/report/$eventId",{$roomId:e,$eventId:t});return this.http.authedRequest(void 0,M.Method.Post,s,null,{score:r,reason:i})}getRoomHierarchy(e,t,r,i=!1,s){const o=x.encodeUri("/rooms/$roomId/hierarchy",{$roomId:e}),c={suggested_only:String(i),max_depth:r==null?void 0:r.toString(),from:s,limit:t==null?void 0:t.toString()};return this.http.authedRequest(void 0,M.Method.Get,o,c,void 0,{prefix:M.PREFIX_V1}).catch(l=>{if(l.errcode==="M_UNRECOGNIZED")return this.http.authedRequest(void 0,M.Method.Get,o,c,void 0,{prefix:"/_matrix/client/unstable/org.matrix.msc2946"});throw l})}async unstableCreateFileTree(e){const{room_id:t}=await this.createRoom({name:e,preset:HM.Preset.PrivateChat,power_level_content_override:Kc(Kc({},hd.DEFAULT_TREE_POWER_LEVELS_TEMPLATE),{},{users:{[this.getUserId()]:100}}),creation_content:{[ue.RoomCreateTypeField]:ue.RoomType.Space},initial_state:[{type:ue.UNSTABLE_MSC3088_PURPOSE.name,state_key:ue.UNSTABLE_MSC3089_TREE_SUBTYPE.name,content:{[ue.UNSTABLE_MSC3088_ENABLED.name]:!0}},{type:ue.EventType.RoomEncryption,state_key:"",content:{algorithm:ld.MEGOLM_ALGORITHM}}]});return new hd.MSC3089TreeSpace(this,t)}unstableGetFileTreeSpace(e){var t,r;const i=this.getRoom(e);if((i==null?void 0:i.getMyMembership())!=="join")return null;const s=i.currentState.getStateEvents(ue.EventType.RoomCreate,""),o=i.currentState.getStateEvents(ue.UNSTABLE_MSC3088_PURPOSE.name,ue.UNSTABLE_MSC3089_TREE_SUBTYPE.name);if(!s)throw new Error("Expected single room create event");return!(o!=null&&(t=o.getContent())!==null&&t!==void 0&&t[ue.UNSTABLE_MSC3088_ENABLED.name])||((r=s.getContent())===null||r===void 0?void 0:r[ue.RoomCreateTypeField])!==ue.RoomType.Space?null:new hd.MSC3089TreeSpace(this,e)}getGroupSummary(e){const t=x.encodeUri("/groups/$groupId/summary",{$groupId:e});return this.http.authedRequest(void 0,M.Method.Get,t)}getGroupProfile(e){const t=x.encodeUri("/groups/$groupId/profile",{$groupId:e});return this.http.authedRequest(void 0,M.Method.Get,t)}setGroupProfile(e,t){const r=x.encodeUri("/groups/$groupId/profile",{$groupId:e});return this.http.authedRequest(void 0,M.Method.Post,r,void 0,t)}setGroupJoinPolicy(e,t){const r=x.encodeUri("/groups/$groupId/settings/m.join_policy",{$groupId:e});return this.http.authedRequest(void 0,M.Method.Put,r,void 0,{"m.join_policy":t})}getGroupUsers(e){const t=x.encodeUri("/groups/$groupId/users",{$groupId:e});return this.http.authedRequest(void 0,M.Method.Get,t)}getGroupInvitedUsers(e){const t=x.encodeUri("/groups/$groupId/invited_users",{$groupId:e});return this.http.authedRequest(void 0,M.Method.Get,t)}getGroupRooms(e){const t=x.encodeUri("/groups/$groupId/rooms",{$groupId:e});return this.http.authedRequest(void 0,M.Method.Get,t)}inviteUserToGroup(e,t){const r=x.encodeUri("/groups/$groupId/admin/users/invite/$userId",{$groupId:e,$userId:t});return this.http.authedRequest(void 0,M.Method.Put,r,void 0,{})}removeUserFromGroup(e,t){const r=x.encodeUri("/groups/$groupId/admin/users/remove/$userId",{$groupId:e,$userId:t});return this.http.authedRequest(void 0,M.Method.Put,r,void 0,{})}addUserToGroupSummary(e,t,r){const i=x.encodeUri(r?"/groups/$groupId/summary/$roleId/users/$userId":"/groups/$groupId/summary/users/$userId",{$groupId:e,$roleId:r,$userId:t});return this.http.authedRequest(void 0,M.Method.Put,i,void 0,{})}removeUserFromGroupSummary(e,t){const r=x.encodeUri("/groups/$groupId/summary/users/$userId",{$groupId:e,$userId:t});return this.http.authedRequest(void 0,M.Method.Delete,r,void 0,{})}addRoomToGroupSummary(e,t,r){const i=x.encodeUri(r?"/groups/$groupId/summary/$categoryId/rooms/$roomId":"/groups/$groupId/summary/rooms/$roomId",{$groupId:e,$categoryId:r,$roomId:t});return this.http.authedRequest(void 0,M.Method.Put,i,void 0,{})}removeRoomFromGroupSummary(e,t){const r=x.encodeUri("/groups/$groupId/summary/rooms/$roomId",{$groupId:e,$roomId:t});return this.http.authedRequest(void 0,M.Method.Delete,r,void 0,{})}addRoomToGroup(e,t,r){r===void 0&&(r=!0);const i=x.encodeUri("/groups/$groupId/admin/rooms/$roomId",{$groupId:e,$roomId:t});return this.http.authedRequest(void 0,M.Method.Put,i,void 0,{"m.visibility":{type:r?"public":"private"}})}updateGroupRoomVisibility(e,t,r){const i=x.encodeUri("/groups/$groupId/admin/rooms/$roomId/config/m.visibility",{$groupId:e,$roomId:t});return this.http.authedRequest(void 0,M.Method.Put,i,void 0,{type:r?"public":"private"})}removeRoomFromGroup(e,t){const r=x.encodeUri("/groups/$groupId/admin/rooms/$roomId",{$groupId:e,$roomId:t});return this.http.authedRequest(void 0,M.Method.Delete,r,void 0,{})}acceptGroupInvite(e,t=null){const r=x.encodeUri("/groups/$groupId/self/accept_invite",{$groupId:e});return this.http.authedRequest(void 0,M.Method.Put,r,void 0,t||{})}joinGroup(e){const t=x.encodeUri("/groups/$groupId/self/join",{$groupId:e});return this.http.authedRequest(void 0,M.Method.Put,t,void 0,{})}leaveGroup(e){const t=x.encodeUri("/groups/$groupId/self/leave",{$groupId:e});return this.http.authedRequest(void 0,M.Method.Put,t,void 0,{})}getJoinedGroups(){const e=x.encodeUri("/joined_groups",{});return this.http.authedRequest(void 0,M.Method.Get,e)}createGroup(e){const t=x.encodeUri("/create_group",{});return this.http.authedRequest(void 0,M.Method.Post,t,void 0,e)}getPublicisedGroups(e){const t=x.encodeUri("/publicised_groups",{});return this.http.authedRequest(void 0,M.Method.Post,t,void 0,{user_ids:e})}setGroupPublicity(e,t){const r=x.encodeUri("/groups/$groupId/self/update_publicity",{$groupId:e});return this.http.authedRequest(void 0,M.Method.Put,r,void 0,{publicise:t})}supportsExperimentalThreads(){var e;return((e=this.clientOpts)===null||e===void 0?void 0:e.experimentalThreadSupport)||!1}async getRoomSummary(e,t){const r=x.encodeUri("/rooms/$roomid/summary",{$roomid:e});return this.http.authedRequest(void 0,M.Method.Get,r,{via:t},null,{qsStringifyOptions:{arrayFormat:"repeat"},prefix:"/_matrix/client/unstable/im.nheko.summary"})}findThreadRoots(e){const t=new Set;for(const r of e)r.isThreadRelation&&t.add(r.relationEventId);return t}eventShouldLiveIn(e,t,r,i){if(e.isThreadRoot)return{shouldLiveInRoom:!0,shouldLiveInThread:!0,threadId:e.getId()};if(e.isThreadRelation)return{shouldLiveInRoom:!1,shouldLiveInThread:!0,threadId:e.relationEventId};const s=e.getAssociatedId(),o=(t==null?void 0:t.findEventById(s))||r.find(l=>l.getId()===s);return(o==null?void 0:o.isThreadRoot)||i.has(e.relationEventId)?{shouldLiveInRoom:!0,shouldLiveInThread:!0,threadId:e.relationEventId}:o!=null&&o.getAssociatedId()?this.eventShouldLiveIn(o,t,r,i):{shouldLiveInRoom:!0,shouldLiveInThread:!1}}partitionThreadedEvents(e){if(this.supportsExperimentalThreads()){const i=this.findThreadRoots(e);return e.reduce((s,o)=>{const c=this.getRoom(o.getRoomId()),{shouldLiveInRoom:l,shouldLiveInThread:u,threadId:a}=this.eventShouldLiveIn(o,c,e,i);return l&&s[0].push(o),u&&(o.setThreadId(a),s[1].push(o)),s},[[],[]])}else return[e,[]]}async processThreadEvents(e,t,r){for(const i of t)await e.addThreadedEvent(i,r)}async whoami(){return this.http.authedRequest(void 0,M.Method.Get,"/account/whoami")}async timestampToEvent(e,t,r){const i=x.encodeUri("/rooms/$roomId/timestamp_to_event",{$roomId:e});return await this.http.authedRequest(void 0,M.Method.Get,i,{ts:t.toString(),dir:r},void 0,{prefix:"/_matrix/client/unstable/org.matrix.msc3030"})}}it.MatrixClient=ru;(0,X.default)(ru,"RESTORE_BACKUP_ERROR_BAD_KEY","RESTORE_BACKUP_ERROR_BAD_KEY");var Oo={},nA=V.exports;Object.defineProperty(Oo,"__esModule",{value:!0});Oo.TimelineWindow=Oo.TimelineIndex=void 0;var _a=nA(Y.exports),jn=Ft;const mm=function(){},iA=5;class sA{constructor(e,t,r={}){this.client=e,this.timelineSet=t,(0,_a.default)(this,"windowLimit",void 0),(0,_a.default)(this,"start",null),(0,_a.default)(this,"end",null),(0,_a.default)(this,"eventCount",0),this.windowLimit=r.windowLimit||1e3}load(e,t=20){const r=i=>{let s;const o=i.getEvents();if(!e)s=o.length;else{for(let u=0;u<o.length;u++)if(o[u].getId()==e){s=u;break}if(s===void 0)throw new Error("getEventTimeline result didn't include requested event")}const c=Math.min(o.length,s+Math.ceil(t/2)),l=Math.max(0,c-t);this.start=new Ah(i,l-i.getBaseIndex()),this.end=new Ah(i,c-i.getBaseIndex()),this.eventCount=c-l};if(e){const i=this.timelineSet.getTimelineForEvent(e);return i?(r(i),Promise.resolve(i)):this.client.getEventTimeline(this.timelineSet,e).then(r)}else{const i=this.timelineSet.getLiveTimeline();return r(i),Promise.resolve()}}getTimelineIndex(e){if(e==jn.EventTimeline.BACKWARDS)return this.start;if(e==jn.EventTimeline.FORWARDS)return this.end;throw new Error("Invalid direction '"+e+"'")}extend(e,t){const r=this.getTimelineIndex(e);if(!r)return!1;const i=e==jn.EventTimeline.BACKWARDS?r.retreat(t):r.advance(t);if(i){this.eventCount+=i,mm("TimelineWindow: increased cap by "+i+" (now "+this.eventCount+")");const s=this.eventCount-this.windowLimit;return s>0&&this.unpaginate(s,e!=jn.EventTimeline.BACKWARDS),!0}return!1}canPaginate(e){const t=this.getTimelineIndex(e);if(!t)return!1;if(e==jn.EventTimeline.BACKWARDS){if(t.index>t.minIndex())return!0}else if(t.index<t.maxIndex())return!0;return Boolean(t.timeline.getNeighbouringTimeline(e)||t.timeline.getPaginationToken(e)!==null)}paginate(e,t,r=!0,i=iA){const s=this.getTimelineIndex(e);if(!s)return Promise.resolve(!1);if(s.pendingPaginate)return s.pendingPaginate;if(this.extend(e,t))return Promise.resolve(!0);if(!r||i===0||s.timeline.getPaginationToken(e)===null)return Promise.resolve(!1);const c=this.client.paginateEventTimeline(s.timeline,{backwards:e==jn.EventTimeline.BACKWARDS,limit:t}).finally(function(){s.pendingPaginate=null}).then(l=>l?this.paginate(e,t,!0,i-1):!1);return s.pendingPaginate=c,c}unpaginate(e,t){const r=t?this.start:this.end;if(e>this.eventCount||e<0)throw new Error("Attemting to unpaginate "+e+" events, but only have "+this.eventCount+" in the timeline");for(;e>0;){const i=t?r.advance(e):r.retreat(e);if(i<=0)throw new Error("Unable to unpaginate any further, but still have "+this.eventCount+" events");e-=i,this.eventCount-=i,mm("TimelineWindow.unpaginate: dropped "+i+" (now "+this.eventCount+")")}}getEvents(){if(!this.start)return[];const e=[];let t=this.start.timeline;for(;;){const r=t.getEvents();let i=0,s=r.length;t===this.start.timeline&&(i=this.start.index+t.getBaseIndex()),t===this.end.timeline&&(s=this.end.index+t.getBaseIndex());for(let o=i;o<s;o++)e.push(r[o]);if(t===this.end.timeline)break;t=t.getNeighbouringTimeline(jn.EventTimeline.FORWARDS)}return e}}Oo.TimelineWindow=sA;class Ah{constructor(e,t){this.timeline=e,this.index=t,(0,_a.default)(this,"pendingPaginate",void 0)}minIndex(){return this.timeline.getBaseIndex()*-1}maxIndex(){return this.timeline.getEvents().length-this.timeline.getBaseIndex()}advance(e){if(!e)return 0;let t;if(e<0){if(t=Math.max(e,this.minIndex()-this.index),t<0)return this.index+=t,t}else if(t=Math.min(e,this.maxIndex()-this.index),t>0)return this.index+=t,t;const r=this.timeline.getNeighbouringTimeline(e<0?jn.EventTimeline.BACKWARDS:jn.EventTimeline.FORWARDS);return r?(this.timeline=r,e<0?this.index=this.maxIndex():this.index=this.minIndex(),this.advance(e)):0}retreat(e){return this.advance(e*-1)*-1}}Oo.TimelineIndex=Ah;var ws={},oA=V.exports;Object.defineProperty(ws,"__esModule",{value:!0});ws.InteractiveAuth=ws.AuthType=void 0;var Nt=oA(Y.exports),fd=ie,aA=G;const da="m.login.email.identity",ym="m.login.msisdn";let Va;ws.AuthType=Va;(function(n){n.Password="m.login.password",n.Recaptcha="m.login.recaptcha",n.Terms="m.login.terms",n.Email="m.login.email.identity",n.Msisdn="m.login.msisdn",n.Sso="m.login.sso",n.SsoUnstable="org.matrix.login.sso",n.Dummy="m.login.dummy",n.RegistrationToken="org.matrix.msc3231.login.registration_token"})(Va||(ws.AuthType=Va={}));class cA extends Error{constructor(e,t,r){super(e);this.required_stages=t,this.flows=r,(0,Nt.default)(this,"name","NoAuthFlowFoundError")}}class lA{constructor(e){var t;(0,Nt.default)(this,"matrixClient",void 0),(0,Nt.default)(this,"inputs",void 0),(0,Nt.default)(this,"clientSecret",void 0),(0,Nt.default)(this,"requestCallback",void 0),(0,Nt.default)(this,"busyChangedCallback",void 0),(0,Nt.default)(this,"stateUpdatedCallback",void 0),(0,Nt.default)(this,"requestEmailTokenCallback",void 0),(0,Nt.default)(this,"data",void 0),(0,Nt.default)(this,"emailSid",void 0),(0,Nt.default)(this,"requestingEmailToken",!1),(0,Nt.default)(this,"attemptAuthDeferred",null),(0,Nt.default)(this,"chosenFlow",null),(0,Nt.default)(this,"currentStage",null),(0,Nt.default)(this,"submitPromise",null),this.matrixClient=e.matrixClient,this.data=e.authData||{},this.requestCallback=e.doRequest,this.busyChangedCallback=e.busyChanged,this.stateUpdatedCallback=e.stateUpdated||e.startAuthStage,this.requestEmailTokenCallback=e.requestEmailToken,this.inputs=e.inputs||{},e.sessionId&&(this.data.session=e.sessionId),this.clientSecret=e.clientSecret||this.matrixClient.generateClientSecret(),this.emailSid=(t=e.emailSid)!==null&&t!==void 0?t:null}attemptAuth(){var e;this.attemptAuthDeferred=(0,aA.defer)();const t=this.attemptAuthDeferred.promise;if((e=this.data)!==null&&e!==void 0&&e.flows)this.startNextAuthStage();else{var r;(r=this.busyChangedCallback)===null||r===void 0||r.call(this,!0);let i=null;this.data.session&&(i={session:this.data.session}),this.doRequest(i).finally(()=>{var s;(s=this.busyChangedCallback)===null||s===void 0||s.call(this,!1)})}return t}async poll(){if(!this.data.session||!this.attemptAuthDeferred||this.submitPromise)return;let e={};if(this.currentStage==da&&this.emailSid){const t={sid:this.emailSid,client_secret:this.clientSecret};if(await this.matrixClient.doesServerRequireIdServerParam()){const r=new URL(this.matrixClient.getIdentityServerUrl());t.id_server=r.host}e={type:da,threepid_creds:t,threepidCreds:t}}this.submitAuthDict(e,!0)}getSessionId(){return this.data?this.data.session:void 0}getClientSecret(){return this.clientSecret}getStageParams(e){var t;return(t=this.data.params)===null||t===void 0?void 0:t[e]}getChosenFlow(){return this.chosenFlow}async submitAuthDict(e,t=!1){if(!this.attemptAuthDeferred)throw new Error("submitAuthDict() called before attemptAuth()");if(!t){var r;(r=this.busyChangedCallback)===null||r===void 0||r.call(this,!0)}for(;this.submitPromise;)try{await this.submitPromise}catch{}let i;this.data.session?(i={session:this.data.session},Object.assign(i,e)):i=e;try{this.submitPromise=this.doRequest(i,t),await this.submitPromise}finally{if(this.submitPromise=null,!t){var s;(s=this.busyChangedCallback)===null||s===void 0||s.call(this,!1)}}}getEmailSid(){return this.emailSid}setEmailSid(e){this.emailSid=e}async doRequest(e,t=!1){try{const o=await this.requestCallback(e,t);this.attemptAuthDeferred.resolve(o),this.attemptAuthDeferred=null}catch(o){var r,i;const c=(r=(i=o.data)===null||i===void 0?void 0:i.flows)!==null&&r!==void 0?r:null,l=this.data.flows||Boolean(c);if(o.httpStatus!==401||!o.data||!l)if(t)fd.logger.log("Background poll request failed doing UI auth: ignoring",o);else{var s;(s=this.attemptAuthDeferred)===null||s===void 0||s.reject(o)}!o.data.flows&&!o.data.completed&&!o.data.session&&(o.data.flows=this.data.flows,o.data.completed=this.data.completed,o.data.session=this.data.session),this.data=o.data;try{this.startNextAuthStage()}catch(u){this.attemptAuthDeferred.reject(u),this.attemptAuthDeferred=null;return}if(!this.emailSid&&!this.requestingEmailToken&&this.chosenFlow.stages.includes(Va.Email)){this.requestingEmailToken=!0;try{const u=await this.requestEmailTokenCallback(this.inputs.emailAddress,this.clientSecret,1,this.data.session);this.emailSid=u.sid}catch(u){this.attemptAuthDeferred.reject(u),this.attemptAuthDeferred=null}finally{this.requestingEmailToken=!1}}}}startNextAuthStage(){const e=this.chooseStage();if(!e)throw new Error("No incomplete flows from the server");if(this.currentStage=e,e===Va.Dummy){this.submitAuthDict({type:"m.login.dummy"});return}if(this.data&&this.data.errcode||this.data.error){this.stateUpdatedCallback(e,{errcode:this.data.errcode||"",error:this.data.error||""});return}const t={};e==da&&(t.emailSid=this.emailSid),this.stateUpdatedCallback(e,t)}chooseStage(){this.chosenFlow===null&&(this.chosenFlow=this.chooseFlow()),fd.logger.log("Active flow => %s",JSON.stringify(this.chosenFlow));const e=this.firstUncompletedStage(this.chosenFlow);return fd.logger.log("Next stage: %s",e),e}chooseFlow(){const e=this.data.flows||[],t=Boolean(this.inputs.emailAddress)||Boolean(this.emailSid),r=Boolean(this.inputs.phoneCountry)&&Boolean(this.inputs.phoneNumber);for(const s of e){let o=!1,c=!1;for(const l of s.stages)l===da?o=!0:l==ym&&(c=!0);if(o==t&&c==r)return s}const i=[];throw t&&i.push(da),r&&i.push(ym),new cA("No appropriate authentication flow found",i,e)}firstUncompletedStage(e){const t=this.data.completed||[];for(let r=0;r<e.stages.length;++r){const i=e.stages[r];if(t.indexOf(i)===-1)return i}}}ws.InteractiveAuth=lA;var nu={},iu={},uA=V.exports;Object.defineProperty(iu,"__esModule",{value:!0});iu.LocalIndexedDBStoreBackend=void 0;var ha=uA(Y.exports),dA=ti,Hi=T_(G),hA=T_(Hl),Xe=ie;function I_(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(I_=function(r){return r?t:e})(n)}function T_(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=I_(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}const fA=3;function pA(n){n.createObjectStore("users",{keyPath:["userId"]}),n.createObjectStore("accountData",{keyPath:["type"]}),n.createObjectStore("sync",{keyPath:["clobber"]})}function gA(n){n.createObjectStore("oob_membership_events",{keyPath:["room_id","state_key"]}).createIndex("room","room_id")}function mA(n){n.createObjectStore("client_options",{keyPath:["clobber"]})}function Fc(n,e,t){const r=n.openCursor(e);return new Promise((i,s)=>{const o=[];r.onerror=()=>{s(new Error("Query failed: "+r.error))},r.onsuccess=()=>{const c=r.result;if(!c){i(o);return}o.push(t(c)),c.continue()}})}function fa(n){return new Promise((e,t)=>{n.oncomplete=function(r){e(r)},n.onerror=function(){t(n.error)}})}function O_(n){return new Promise((e,t)=>{n.onsuccess=function(r){e(r)},n.onerror=function(){t(n.error)}})}function yA(n){return new Promise((e,t)=>{n.onsuccess=()=>e(n),n.onerror=r=>t(r)})}function vm(n){return O_(n).then(e=>n.result)}class vA{static exists(e,t){return t="matrix-js-sdk:"+(t||"default"),hA.exists(e,t)}constructor(e,t){this.indexedDB=e,(0,ha.default)(this,"dbName",void 0),(0,ha.default)(this,"syncAccumulator",void 0),(0,ha.default)(this,"db",null),(0,ha.default)(this,"disconnected",!0),(0,ha.default)(this,"_isNewlyCreated",!1),this.dbName="matrix-js-sdk:"+(t||"default"),this.syncAccumulator=new dA.SyncAccumulator}connect(){if(!this.disconnected)return Xe.logger.log("LocalIndexedDBStoreBackend.connect: already connected or connecting"),Promise.resolve();this.disconnected=!1,Xe.logger.log("LocalIndexedDBStoreBackend.connect: connecting...");const e=this.indexedDB.open(this.dbName,fA);return e.onupgradeneeded=t=>{const r=e.result,i=t.oldVersion;Xe.logger.log(`LocalIndexedDBStoreBackend.connect: upgrading from ${i}`),i<1&&(this._isNewlyCreated=!0,pA(r)),i<2&&gA(r),i<3&&mA(r)},e.onblocked=()=>{Xe.logger.log("can't yet open LocalIndexedDBStoreBackend because it is open elsewhere")},Xe.logger.log("LocalIndexedDBStoreBackend.connect: awaiting connection..."),O_(e).then(()=>(Xe.logger.log("LocalIndexedDBStoreBackend.connect: connected"),this.db=e.result,this.db.onversionchange=()=>{this.db.close()},this.init()))}isNewlyCreated(){return Promise.resolve(this._isNewlyCreated)}init(){return Promise.all([this.loadAccountData(),this.loadSyncData()]).then(([e,t])=>{Xe.logger.log("LocalIndexedDBStoreBackend: loaded initial data"),this.syncAccumulator.accumulate({next_batch:t.nextBatch,rooms:t.roomsData,groups:t.groupsData,account_data:{events:e}},!0)})}getOutOfBandMembers(e){return new Promise((t,r)=>{const o=this.db.transaction(["oob_membership_events"],"readonly").objectStore("oob_membership_events").index("room"),c=IDBKeyRange.only(e),l=o.openCursor(c),u=[];let a=!1;l.onsuccess=()=>{const g=l.result;if(!g)return!u.length&&!a?t(null):t(u);const m=g.value;m.oob_written?a=!0:u.push(m),g.continue()},l.onerror=g=>{r(g)}}).then(t=>(Xe.logger.log(`LL: got ${t&&t.length} membershipEvents from storage for room ${e} ...`),t))}async setOutOfBandMembers(e,t){Xe.logger.log(`LL: backend about to store ${t.length} members for ${e}`);const r=this.db.transaction(["oob_membership_events"],"readwrite"),i=r.objectStore("oob_membership_events");t.forEach(o=>{i.put(o)});const s={room_id:e,oob_written:!0,state_key:0};i.put(s),await fa(r),Xe.logger.log(`LL: backend done storing for ${e}!`)}async clearOutOfBandMembers(e){const i=this.db.transaction(["oob_membership_events"],"readonly").objectStore("oob_membership_events").index("room"),s=IDBKeyRange.only(e),o=vm(i.openKeyCursor(s,"next")).then(p=>p&&p.primaryKey[1]),c=vm(i.openKeyCursor(s,"prev")).then(p=>p&&p.primaryKey[1]),[l,u]=await Promise.all([o,c]),g=this.db.transaction(["oob_membership_events"],"readwrite").objectStore("oob_membership_events"),m=IDBKeyRange.bound([e,l],[e,u]);Xe.logger.log(`LL: Deleting all users + marker in storage for room ${e}, with key range:`,[e,l],[e,u]),await yA(g.delete(m))}clearDatabase(){return new Promise(e=>{Xe.logger.log(`Removing indexeddb instance: ${this.dbName}`);const t=this.indexedDB.deleteDatabase(this.dbName);t.onblocked=()=>{Xe.logger.log(`can't yet delete indexeddb ${this.dbName} because it is open elsewhere`)},t.onerror=()=>{Xe.logger.warn(`unable to delete js-sdk store indexeddb: ${t.error}`),e()},t.onsuccess=()=>{Xe.logger.log(`Removed indexeddb instance: ${this.dbName}`),e()}})}getSavedSync(e=!0){const t=this.syncAccumulator.getJSON();return t.nextBatch?e?Promise.resolve(Hi.deepCopy(t)):Promise.resolve(t):Promise.resolve(null)}getNextBatchToken(){return Promise.resolve(this.syncAccumulator.getNextBatchToken())}setSyncData(e){return Promise.resolve().then(()=>{this.syncAccumulator.accumulate(e)})}async syncToDatabase(e){const t=this.syncAccumulator.getJSON(!0);await Promise.all([this.persistUserPresenceEvents(e),this.persistAccountData(t.accountData),this.persistSyncData(t.nextBatch,t.roomsData,t.groupsData)])}persistSyncData(e,t,r){return Xe.logger.log("Persisting sync data up to",e),Hi.promiseTry(()=>{const i=this.db.transaction(["sync"],"readwrite");return i.objectStore("sync").put({clobber:"-",nextBatch:e,roomsData:t,groupsData:r}),fa(i).then()})}persistAccountData(e){return Hi.promiseTry(()=>{const t=this.db.transaction(["accountData"],"readwrite"),r=t.objectStore("accountData");for(let i=0;i<e.length;i++)r.put(e[i]);return fa(t).then()})}persistUserPresenceEvents(e){return Hi.promiseTry(()=>{const t=this.db.transaction(["users"],"readwrite"),r=t.objectStore("users");for(const i of e)r.put({userId:i[0],event:i[1]});return fa(t).then()})}getUserPresenceEvents(){return Hi.promiseTry(()=>{const t=this.db.transaction(["users"],"readonly").objectStore("users");return Fc(t,void 0,r=>[r.value.userId,r.value.event])})}loadAccountData(){return Xe.logger.log("LocalIndexedDBStoreBackend: loading account data..."),Hi.promiseTry(()=>{const t=this.db.transaction(["accountData"],"readonly").objectStore("accountData");return Fc(t,void 0,r=>r.value).then(r=>(Xe.logger.log("LocalIndexedDBStoreBackend: loaded account data"),r))})}loadSyncData(){return Xe.logger.log("LocalIndexedDBStoreBackend: loading sync data..."),Hi.promiseTry(()=>{const t=this.db.transaction(["sync"],"readonly").objectStore("sync");return Fc(t,void 0,r=>r.value).then(r=>(Xe.logger.log("LocalIndexedDBStoreBackend: loaded sync data"),r.length>1&&Xe.logger.warn("loadSyncData: More than 1 sync row found."),r.length>0?r[0]:{}))})}getClientOptions(){return Promise.resolve().then(()=>{const t=this.db.transaction(["client_options"],"readonly").objectStore("client_options");return Fc(t,void 0,r=>{if(r.value&&r.value&&r.value.options)return r.value.options}).then(r=>r[0])})}async storeClientOptions(e){const t=this.db.transaction(["client_options"],"readwrite");t.objectStore("client_options").put({clobber:"-",options:e}),await fa(t)}}iu.LocalIndexedDBStoreBackend=vA;var su={},_A=V.exports;Object.defineProperty(su,"__esModule",{value:!0});su.RemoteIndexedDBStoreBackend=void 0;var pa=_A(Y.exports),qc=ie,EA=G;class SA{constructor(e,t){this.workerFactory=e,this.dbName=t,(0,pa.default)(this,"worker",void 0),(0,pa.default)(this,"nextSeq",0),(0,pa.default)(this,"inFlight",{}),(0,pa.default)(this,"startPromise",null),(0,pa.default)(this,"onWorkerMessage",r=>{const i=r.data;if(i.command=="cmd_success"||i.command=="cmd_fail"){if(i.seq===void 0){qc.logger.error("Got reply from worker with no seq");return}const s=this.inFlight[i.seq];if(s===void 0){qc.logger.error("Got reply for unknown seq "+i.seq);return}if(delete this.inFlight[i.seq],i.command=="cmd_success")s.resolve(i.result);else{const o=new Error(i.error.message);o.name=i.error.name,s.reject(o)}}else qc.logger.warn("Unrecognised message from worker: ",i)})}connect(){return this.ensureStarted().then(()=>this.doCmd("connect"))}clearDatabase(){return this.ensureStarted().then(()=>this.doCmd("clearDatabase"))}isNewlyCreated(){return this.doCmd("isNewlyCreated")}getSavedSync(){return this.doCmd("getSavedSync")}getNextBatchToken(){return this.doCmd("getNextBatchToken")}setSyncData(e){return this.doCmd("setSyncData",[e])}syncToDatabase(e){return this.doCmd("syncToDatabase",[e])}getOutOfBandMembers(e){return this.doCmd("getOutOfBandMembers",[e])}setOutOfBandMembers(e,t){return this.doCmd("setOutOfBandMembers",[e,t])}clearOutOfBandMembers(e){return this.doCmd("clearOutOfBandMembers",[e])}getClientOptions(){return this.doCmd("getClientOptions")}storeClientOptions(e){return this.doCmd("storeClientOptions",[e])}getUserPresenceEvents(){return this.doCmd("getUserPresenceEvents")}ensureStarted(){return this.startPromise===null&&(this.worker=this.workerFactory(),this.worker.onmessage=this.onWorkerMessage,this.startPromise=this.doCmd("_setupWorker",[this.dbName]).then(()=>{qc.logger.log("IndexedDB worker is ready")})),this.startPromise}doCmd(e,t){return Promise.resolve().then(()=>{const r=this.nextSeq++,i=(0,EA.defer)();return this.inFlight[r]=i,this.worker.postMessage({command:e,seq:r,args:t}),i.promise})}}su.RemoteIndexedDBStoreBackend=SA;var bA=V.exports;Object.defineProperty(nu,"__esModule",{value:!0});nu.IndexedDBStore=void 0;var gt=bA(Y.exports),wA=Ha,_m=iu,RA=su,IA=en,TA=qt,hn=ie,OA=qe;const kA=1e3*60*5;class CA extends wA.MemoryStore{static exists(e,t){return _m.LocalIndexedDBStoreBackend.exists(e,t)}constructor(e){super(e);if((0,gt.default)(this,"backend",void 0),(0,gt.default)(this,"startedUp",!1),(0,gt.default)(this,"syncTs",0),(0,gt.default)(this,"userModifiedMap",{}),(0,gt.default)(this,"emitter",new OA.TypedEventEmitter),(0,gt.default)(this,"on",this.emitter.on.bind(this.emitter)),(0,gt.default)(this,"getSavedSync",this.degradable(()=>this.backend.getSavedSync(),"getSavedSync")),(0,gt.default)(this,"isNewlyCreated",this.degradable(()=>this.backend.isNewlyCreated(),"isNewlyCreated")),(0,gt.default)(this,"getSavedSyncToken",this.degradable(()=>this.backend.getNextBatchToken(),"getSavedSyncToken")),(0,gt.default)(this,"deleteAllData",this.degradable(()=>(super.deleteAllData(),this.backend.clearDatabase().then(()=>{hn.logger.log("Deleted indexeddb data.")},t=>{throw hn.logger.error(`Failed to delete indexeddb data: ${t}`),t})))),(0,gt.default)(this,"reallySave",this.degradable(()=>{this.syncTs=Date.now();const t=[];for(const r of this.getUsers())this.userModifiedMap[r.userId]!==r.getLastModifiedTime()&&(!r.events.presence||(t.push([r.userId,r.events.presence.event]),this.userModifiedMap[r.userId]=r.getLastModifiedTime()));return this.backend.syncToDatabase(t)})),(0,gt.default)(this,"setSyncData",this.degradable(t=>this.backend.setSyncData(t),"setSyncData")),(0,gt.default)(this,"getOutOfBandMembers",this.degradable(t=>this.backend.getOutOfBandMembers(t),"getOutOfBandMembers")),(0,gt.default)(this,"setOutOfBandMembers",this.degradable((t,r)=>(super.setOutOfBandMembers(t,r),this.backend.setOutOfBandMembers(t,r)),"setOutOfBandMembers")),(0,gt.default)(this,"clearOutOfBandMembers",this.degradable(t=>(super.clearOutOfBandMembers(t),this.backend.clearOutOfBandMembers(t)),"clearOutOfBandMembers")),(0,gt.default)(this,"getClientOptions",this.degradable(()=>this.backend.getClientOptions(),"getClientOptions")),(0,gt.default)(this,"storeClientOptions",this.degradable(t=>(super.storeClientOptions(t),this.backend.storeClientOptions(t)),"storeClientOptions")),!e.indexedDB)throw new Error("Missing required option: indexedDB");e.workerFactory?this.backend=new RA.RemoteIndexedDBStoreBackend(e.workerFactory,e.dbName):this.backend=new _m.LocalIndexedDBStoreBackend(e.indexedDB,e.dbName)}startup(){return this.startedUp?(hn.logger.log("IndexedDBStore.startup: already started"),Promise.resolve()):(hn.logger.log("IndexedDBStore.startup: connecting to backend"),this.backend.connect().then(()=>(hn.logger.log("IndexedDBStore.startup: loading presence events"),this.backend.getUserPresenceEvents())).then(e=>{hn.logger.log("IndexedDBStore.startup: processing presence events"),e.forEach(([t,r])=>{const i=new IA.User(t);r&&i.setPresenceEvent(new TA.MatrixEvent(r)),this.userModifiedMap[i.userId]=i.getLastModifiedTime(),this.storeUser(i)})}))}wantsSave(){return Date.now()-this.syncTs>kA}save(e=!1){return e||this.wantsSave()?this.reallySave():Promise.resolve()}degradable(e,t){const r=super[t];return async(...i)=>{try{return e.call(this,...i)}catch(s){hn.logger.error("IndexedDBStore failure, degrading to MemoryStore",s),this.emitter.emit("degraded",s);try{hn.logger.log("IndexedDBStore trying to delete degraded data"),await this.backend.clearDatabase(),hn.logger.log("IndexedDBStore delete after degrading succeeded")}catch(o){hn.logger.warn("IndexedDBStore delete after degrading failed",o)}if(r)return r(...i)}}}}nu.IndexedDBStore=CA;var bf={};Object.defineProperty(bf,"__esModule",{value:!0});var NA=bf.WebStorageSessionStore=C_,jc=PA(G);function k_(n){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(k_=function(r){return r?t:e})(n)}function PA(n,e){if(!e&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var t=k_(e);if(t&&t.has(n))return t.get(n);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in n)if(s!=="default"&&Object.prototype.hasOwnProperty.call(n,s)){var o=i?Object.getOwnPropertyDescriptor(n,s):null;o&&(o.get||o.set)?Object.defineProperty(r,s,o):r[s]=n[s]}return r.default=n,t&&t.set(n,r),r}const kn="session.e2e.";function C_(n){if(this.store=n,!jc.isFunction(n.getItem)||!jc.isFunction(n.setItem)||!jc.isFunction(n.removeItem)||!jc.isFunction(n.key)||typeof n.length!="number")throw new Error("Supplied webStore does not meet the WebStorage API interface")}C_.prototype={removeEndToEndAccount:function(){this.store.removeItem(Em)},getEndToEndAccount:function(){return this.store.getItem(Em)},getAllEndToEndDevices:function(){const n=Rm(""),e={};for(let t=0;t<this.store.length;++t){const r=this.store.key(t),i=r.substr(n.length);r.startsWith(n)&&(e[i]=Qs(this.store,r))}return e},getEndToEndDeviceTrackingStatus:function(){return Qs(this.store,bm)},getEndToEndDeviceSyncToken:function(){return Qs(this.store,Sm)},removeEndToEndDeviceData:function(){Zs(this.store,Rm("")),Zs(this.store,bm),Zs(this.store,Sm)},getEndToEndSessions:function(n){return Qs(this.store,Vc(n))},getAllEndToEndSessions:function(){const n=Im(this.store,Vc("")),e={};for(const t of n){const r=t.substr(Vc("").length);e[r]=Qs(this.store,t)}return e},removeAllEndToEndSessions:function(){Zs(this.store,Vc(""))},getAllEndToEndInboundGroupSessionKeys:function(){const n=kn+"inboundgroupsessions/",e=[];for(let t=0;t<this.store.length;t++){const r=this.store.key(t);!r.startsWith(n)||e.push({senderKey:r.substr(n.length,43),sessionId:r.substr(n.length+44)})}return e},getEndToEndInboundGroupSession:function(n,e){const t=MA(n,e);return this.store.getItem(t)},removeAllEndToEndInboundGroupSessions:function(){Zs(this.store,kn+"inboundgroupsessions/")},getAllEndToEndRooms:function(){const n=Im(this.store,pd("")),e={};for(const t of n){const r=t.substr(pd("").length);e[r]=Qs(this.store,t)}return e},removeAllEndToEndRooms:function(){Zs(this.store,pd(""))},setLocalTrustedBackupPubKey:function(n){this.store.setItem(wm,n)},getLocalTrustedBackupPubKey:function(){return this.store.getItem(wm)}};const Em=kn+"account",Sm=kn+"device_sync_token",bm=kn+"device_tracking",wm=kn+"trusted_backup_pubkey";function Rm(n){return kn+"devices/"+n}function Vc(n){return kn+"sessions/"+n}function MA(n,e){return kn+"inboundgroupsessions/"+n+"/"+e}function pd(n){return kn+"rooms/"+n}function Qs(n,e){try{return JSON.parse(n.getItem(e))}catch(t){AA(t.stack)}return null}function Im(n,e){const t=[];for(let r=0;r<n.length;++r){const i=n.key(r);i.startsWith(e)&&t.push(i)}return t}function Zs(n,e){const t=[];for(let r=0;r<n.length;++r){const i=n.key(r);i.startsWith(e)&&t.push(i)}for(const r of t)n.removeItem(r)}function AA(...n){}var P_={};Object.defineProperty(P_,"__esModule",{value:!0});(function(n){Object.defineProperty(n,"__esModule",{value:!0});var e={request:!0,getRequest:!0,wrapRequest:!0,setCryptoStoreFactory:!0,createClient:!0,ContentHelpers:!0,createNewMatrixCall:!0};n.ContentHelpers=void 0,n.createClient=fi,Object.defineProperty(n,"createNewMatrixCall",{enumerable:!0,get:function(){return sn.createNewMatrixCall}}),n.getRequest=di,n.request=Ue,n.setCryptoStoreFactory=hi,n.wrapRequest=qr;var t=Po;Object.keys(t).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===t[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return t[_]}})});var r=Ha;Object.keys(r).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===r[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return r[_]}})});var i=$l;Object.keys(i).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===i[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return i[_]}})});var s=it;Object.keys(s).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===s[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return s[_]}})});var o=me;Object.keys(o).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===o[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return o[_]}})});var c=$i;Object.keys(c).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===c[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return c[_]}})});var l=ti;Object.keys(l).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===l[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return l[_]}})});var u=si;Object.keys(u).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===u[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return u[_]}})});var a=_r;Object.keys(a).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===a[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return a[_]}})});var g=qt;Object.keys(g).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===g[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return g[_]}})});var m=ar;Object.keys(m).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===m[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return m[_]}})});var p=Kl;Object.keys(p).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===p[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return p[_]}})});var E=Ft;Object.keys(E).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===E[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return E[_]}})});var I=ei;Object.keys(I).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===I[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return I[_]}})});var w=tn;Object.keys(w).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===w[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return w[_]}})});var k=Tn;Object.keys(k).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===k[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return k[_]}})});var P=en;Object.keys(P).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===P[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return P[_]}})});var S=Cs;Object.keys(S).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===S[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return S[_]}})});var T=Oo;Object.keys(T).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===T[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return T[_]}})});var D=ws;Object.keys(D).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===D[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return D[_]}})});var R=Lo;Object.keys(R).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===R[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return R[_]}})});var L=nu;Object.keys(L).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===L[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return L[_]}})});var H=bf;Object.keys(H).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===H[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return H[_]}})});var F=Kr;Object.keys(F).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===F[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return F[_]}})});var le=Mo;Object.keys(le).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===le[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return le[_]}})});var Je=ne;Object.keys(Je).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===Je[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return Je[_]}})});var Ke=Be;Object.keys(Ke).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===Ke[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return Ke[_]}})});var De=Ye;Object.keys(De).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===De[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return De[_]}})});var ut=P_;Object.keys(ut).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===ut[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return ut[_]}})});var ur=Ko;Object.keys(ur).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===ur[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return ur[_]}})});var jt=ec;Object.keys(jt).forEach(function(_){_==="default"||_==="__esModule"||Object.prototype.hasOwnProperty.call(e,_)||_ in n&&n[_]===jt[_]||Object.defineProperty(n,_,{enumerable:!0,get:function(){return jt[_]}})});var Q=ui(ze);n.ContentHelpers=Q;var sn=Te;function Fr(_){if(typeof WeakMap!="function")return null;var dr=new WeakMap,Mt=new WeakMap;return(Fr=function(hr){return hr?Mt:dr})(_)}function ui(_,dr){if(!dr&&_&&_.__esModule)return _;if(_===null||typeof _!="object"&&typeof _!="function")return{default:_};var Mt=Fr(dr);if(Mt&&Mt.has(_))return Mt.get(_);var hr={},wr=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var st in _)if(st!=="default"&&Object.prototype.hasOwnProperty.call(_,st)){var ot=wr?Object.getOwnPropertyDescriptor(_,st):null;ot&&(ot.get||ot.set)?Object.defineProperty(hr,st,ot):hr[st]=_[st]}return hr.default=_,Mt&&Mt.set(_,hr),hr}let be;function Ue(_){be=_}function di(){return be}function qr(_){const dr=be;be=function(Mt,hr){return _(dr,Mt,hr)}}let Pn=()=>new t.MemoryCryptoStore;function hi(_){Pn=_}function fi(_){return typeof _=="string"&&(_={baseUrl:_}),_.request=_.request||be,_.store=_.store||new r.MemoryStore({localStorage:j.localStorage}),_.scheduler=_.scheduler||new i.MatrixScheduler,_.cryptoStore=_.cryptoStore||Pn(),new s.MatrixClient(_)}})(Is);(function(n){var e=V.exports;Object.defineProperty(n,"__esModule",{value:!0});var t={};n.default=void 0;var r=e(gy.exports),i=e(gb),s=c(Is);Object.keys(s).forEach(function(a){a==="default"||a==="__esModule"||Object.prototype.hasOwnProperty.call(t,a)||a in n&&n[a]===s[a]||Object.defineProperty(n,a,{enumerable:!0,get:function(){return s[a]}})});function o(a){if(typeof WeakMap!="function")return null;var g=new WeakMap,m=new WeakMap;return(o=function(p){return p?m:g})(a)}function c(a,g){if(!g&&a&&a.__esModule)return a;if(a===null||typeof a!="object"&&typeof a!="function")return{default:a};var m=o(g);if(m&&m.has(a))return m.get(a);var p={},E=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var I in a)if(I!=="default"&&Object.prototype.hasOwnProperty.call(a,I)){var w=E?Object.getOwnPropertyDescriptor(a,I):null;w&&(w.get||w.set)?Object.defineProperty(p,I,w):p[I]=a[I]}return p.default=a,m&&m.set(a,p),p}if(s.getRequest())throw new Error("Multiple matrix-js-sdk entrypoints detected!");s.request(function(a,g){return a.qs=i.default.stringify(a.qs||{},a.qsStringifyOptions),(0,r.default)(a,g)});let l;try{l=j.indexedDB}catch{}l&&s.setCryptoStoreFactory(function(){return new s.IndexedDBCryptoStore(l,"matrix-js-sdk:crypto")});var u=s;n.default=u,j.matrixcs=s})(wE);var LA="/pr-121/assets/olm.b3e0f9b4.wasm",BA="/pr-121/assets/olm_legacy.9dc48f49.js",M_={exports:{}};(function(n,e){// @license magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7&dn=apache-2.0.txt Apache-2.0
-var t=function(){var r={},i,s,o=function(){var l=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename!="undefined"&&(l=l||__filename),function(u){u=u||{};var a;a||(a=typeof u!="undefined"?u:{});var g,m;a.ready=new Promise(function(f,y){g=f,m=y});var p;if(typeof window!="undefined")p=function(f){window.crypto.getRandomValues(f)};else if(n.exports){var E=ki;p=function(f){var y=E.randomBytes(f.length);f.set(y)},process=j.process}else throw Error("Cannot find global to attach library to");if(typeof OLM_OPTIONS!="undefined")for(var I in OLM_OPTIONS)OLM_OPTIONS.hasOwnProperty(I)&&(a[I]=OLM_OPTIONS[I]);a.onRuntimeInitialized=function(){on=a._olm_error(),r.PRIVATE_KEY_LENGTH=a._olm_pk_private_key_length(),i&&i()},a.onAbort=function(f){s&&s(f)};var w={},k;for(k in a)a.hasOwnProperty(k)&&(w[k]=a[k]);var P=typeof window=="object",S=typeof importScripts=="function",T="",D,R,L,H,F;typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"?(T=S?ki.dirname(T)+"/":__dirname+"/",D=function(f,y){return H||(H=ki),F||(F=ki),f=F.normalize(f),H.readFileSync(f,y?null:"utf8")},L=function(f){return f=D(f,!0),f.buffer||(f=new Uint8Array(f)),f.buffer||ot("Assertion failed: undefined"),f},R=function(f,y,O){H||(H=ki),F||(F=ki),f=F.normalize(f),H.readFile(f,function(U,B){U?O(U):y(B.buffer)})},1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),process.on("uncaughtException",function(f){throw f}),process.on("unhandledRejection",ot),a.inspect=function(){return"[Emscripten Module object]"}):(P||S)&&(S?T=self.location.href:typeof document!="undefined"&&document.currentScript&&(T=document.currentScript.src),l&&(T=l),T.indexOf("blob:")!==0?T=T.substr(0,T.lastIndexOf("/")+1):T="",D=function(f){var y=new XMLHttpRequest;return y.open("GET",f,!1),y.send(null),y.responseText},S&&(L=function(f){var y=new XMLHttpRequest;return y.open("GET",f,!1),y.responseType="arraybuffer",y.send(null),new Uint8Array(y.response)}),R=function(f,y,O){var U=new XMLHttpRequest;U.open("GET",f,!0),U.responseType="arraybuffer",U.onload=function(){U.status==200||U.status==0&&U.response?y(U.response):O()},U.onerror=O,U.send(null)}),a.print||console.log.bind(console);var le=a.printErr||console.warn.bind(console);for(k in w)w.hasOwnProperty(k)&&(a[k]=w[k]);w=null;var Je;a.wasmBinary&&(Je=a.wasmBinary),a.noExitRuntime,typeof WebAssembly!="object"&&ot("no native wasm support detected");function Ke(f){var y="i8";switch(y.charAt(y.length-1)==="*"&&(y="i32"),y){case"i1":be[f>>0]=0;break;case"i8":be[f>>0]=0;break;case"i16":di[f>>1]=0;break;case"i32":qr[f>>2]=0;break;case"i64":pi=[0,(Mn=0,1<=+Math.abs(Mn)?0<Mn?(Math.min(+Math.floor(Mn/4294967296),4294967295)|0)>>>0:~~+Math.ceil((Mn-+(~~Mn>>>0))/4294967296)>>>0:0)],qr[f>>2]=pi[0],qr[f+4>>2]=pi[1];break;case"float":Pn[f>>2]=0;break;case"double":hi[f>>3]=0;break;default:ot("invalid type for setValue: "+y)}}function De(f,y){switch(y=y||"i8",y.charAt(y.length-1)==="*"&&(y="i32"),y){case"i1":return be[f>>0];case"i8":return be[f>>0];case"i16":return di[f>>1];case"i32":return qr[f>>2];case"i64":return qr[f>>2];case"float":return Pn[f>>2];case"double":return hi[f>>3];default:ot("invalid type for getValue: "+y)}return null}var ut,ur=!1,jt=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):void 0;function Q(f,y){if(f){var O=Ue,U=f+y;for(y=f;O[y]&&!(y>=U);)++y;if(16<y-f&&O.subarray&&jt)f=jt.decode(O.subarray(f,y));else{for(U="";f<y;){var B=O[f++];if(B&128){var ee=O[f++]&63;if((B&224)==192)U+=String.fromCharCode((B&31)<<6|ee);else{var ve=O[f++]&63;B=(B&240)==224?(B&15)<<12|ee<<6|ve:(B&7)<<18|ee<<12|ve<<6|O[f++]&63,65536>B?U+=String.fromCharCode(B):(B-=65536,U+=String.fromCharCode(55296|B>>10,56320|B&1023))}}else U+=String.fromCharCode(B)}f=U}}else f="";return f}function sn(f,y,O,U){if(!(0<U))return 0;var B=O;U=O+U-1;for(var ee=0;ee<f.length;++ee){var ve=f.charCodeAt(ee);if(55296<=ve&&57343>=ve){var At=f.charCodeAt(++ee);ve=65536+((ve&1023)<<10)|At&1023}if(127>=ve){if(O>=U)break;y[O++]=ve}else{if(2047>=ve){if(O+1>=U)break;y[O++]=192|ve>>6}else{if(65535>=ve){if(O+2>=U)break;y[O++]=224|ve>>12}else{if(O+3>=U)break;y[O++]=240|ve>>18,y[O++]=128|ve>>12&63}y[O++]=128|ve>>6&63}y[O++]=128|ve&63}}return y[O]=0,O-B}function Fr(f){for(var y=0,O=0;O<f.length;++O){var U=f.charCodeAt(O);55296<=U&&57343>=U&&(U=65536+((U&1023)<<10)|f.charCodeAt(++O)&1023),127>=U?++y:y=2047>=U?y+2:65535>=U?y+3:y+4}return y}function ui(f,y){for(var O=0;O<f.length;++O)be[y++>>0]=f.charCodeAt(O)}var be,Ue,di,qr,Pn,hi,fi,_=[],dr=[],Mt=[];function hr(){var f=a.preRun.shift();_.unshift(f)}var wr=0,st=null;a.preloadedImages={},a.preloadedAudios={};function ot(f){throw a.onAbort&&a.onAbort(f),le(f),ur=!0,f=new WebAssembly.RuntimeError("abort("+f+"). Build with -s ASSERTIONS=1 for more info."),m(f),f}function sc(){return Vt.startsWith("data:application/octet-stream;base64,")}var Vt;if(Vt="olm.wasm",!sc()){var Ds=Vt;Vt=a.locateFile?a.locateFile(Ds,T):T+Ds}function oc(){var f=Vt;try{if(f==Vt&&Je)return new Uint8Array(Je);if(L)return L(f);throw"both async and sync fetching of the wasm failed"}catch(y){ot(y)}}function ou(){if(!Je&&(P||S)){if(typeof fetch=="function"&&!Vt.startsWith("file://"))return fetch(Vt,{credentials:"same-origin"}).then(function(f){if(!f.ok)throw"failed to load wasm binary file at '"+Vt+"'";return f.arrayBuffer()}).catch(function(){return oc()});if(R)return new Promise(function(f,y){R(Vt,function(O){f(new Uint8Array(O))},y)})}return Promise.resolve().then(function(){return oc()})}var Mn,pi;function Gt(f){for(;0<f.length;){var y=f.shift();if(typeof y=="function")y(a);else{var O=y.cc;typeof O=="number"?y.bc===void 0?fi.get(O)():fi.get(O)(y.bc):O(y.bc===void 0?null:y.bc)}}}var Fo={a:function(f,y,O){Ue.copyWithin(f,y,y+O)},b:function(){ot("OOM")}};(function(){function f(B){a.asm=B.exports,ut=a.asm.c,B=ut.buffer,a.HEAP8=be=new Int8Array(B),a.HEAP16=di=new Int16Array(B),a.HEAP32=qr=new Int32Array(B),a.HEAPU8=Ue=new Uint8Array(B),a.HEAPU16=new Uint16Array(B),a.HEAPU32=new Uint32Array(B),a.HEAPF32=Pn=new Float32Array(B),a.HEAPF64=hi=new Float64Array(B),fi=a.asm.e,dr.unshift(a.asm.d),wr--,a.monitorRunDependencies&&a.monitorRunDependencies(wr),wr==0&&st&&(B=st,st=null,B())}function y(B){f(B.instance)}function O(B){return ou().then(function(ee){return WebAssembly.instantiate(ee,U)}).then(function(ee){return ee}).then(B,function(ee){le("failed to asynchronously prepare wasm: "+ee),ot(ee)})}var U={a:Fo};if(wr++,a.monitorRunDependencies&&a.monitorRunDependencies(wr),a.instantiateWasm)try{return a.instantiateWasm(U,f)}catch(B){return le("Module.instantiateWasm callback failed with error: "+B),!1}return function(){return Je||typeof WebAssembly.instantiateStreaming!="function"||sc()||Vt.startsWith("file://")||typeof fetch!="function"?O(y):fetch(Vt,{credentials:"same-origin"}).then(function(B){return WebAssembly.instantiateStreaming(B,U).then(y,function(ee){return le("wasm streaming compile failed: "+ee),le("falling back to ArrayBuffer instantiation"),O(y)})})}().catch(m),{}})(),a.___wasm_call_ctors=function(){return(a.___wasm_call_ctors=a.asm.d).apply(null,arguments)},a._olm_pk_encryption_last_error=function(){return(a._olm_pk_encryption_last_error=a.asm.f).apply(null,arguments)},a.__olm_error_to_string=function(){return(a.__olm_error_to_string=a.asm.g).apply(null,arguments)},a._olm_pk_encryption_last_error_code=function(){return(a._olm_pk_encryption_last_error_code=a.asm.h).apply(null,arguments)},a._olm_pk_encryption_size=function(){return(a._olm_pk_encryption_size=a.asm.i).apply(null,arguments)},a._olm_pk_encryption=function(){return(a._olm_pk_encryption=a.asm.j).apply(null,arguments)},a._olm_clear_pk_encryption=function(){return(a._olm_clear_pk_encryption=a.asm.k).apply(null,arguments)},a._olm_pk_encryption_set_recipient_key=function(){return(a._olm_pk_encryption_set_recipient_key=a.asm.l).apply(null,arguments)},a._olm_pk_key_length=function(){return(a._olm_pk_key_length=a.asm.m).apply(null,arguments)},a._olm_pk_ciphertext_length=function(){return(a._olm_pk_ciphertext_length=a.asm.n).apply(null,arguments)},a._olm_pk_mac_length=function(){return(a._olm_pk_mac_length=a.asm.o).apply(null,arguments)},a._olm_pk_encrypt_random_length=function(){return(a._olm_pk_encrypt_random_length=a.asm.p).apply(null,arguments)},a._olm_pk_encrypt=function(){return(a._olm_pk_encrypt=a.asm.q).apply(null,arguments)},a._olm_pk_decryption_last_error=function(){return(a._olm_pk_decryption_last_error=a.asm.r).apply(null,arguments)},a._olm_pk_decryption_last_error_code=function(){return(a._olm_pk_decryption_last_error_code=a.asm.s).apply(null,arguments)},a._olm_pk_decryption_size=function(){return(a._olm_pk_decryption_size=a.asm.t).apply(null,arguments)},a._olm_pk_decryption=function(){return(a._olm_pk_decryption=a.asm.u).apply(null,arguments)},a._olm_clear_pk_decryption=function(){return(a._olm_clear_pk_decryption=a.asm.v).apply(null,arguments)},a._olm_pk_private_key_length=function(){return(a._olm_pk_private_key_length=a.asm.w).apply(null,arguments)},a._olm_pk_generate_key_random_length=function(){return(a._olm_pk_generate_key_random_length=a.asm.x).apply(null,arguments)},a._olm_pk_key_from_private=function(){return(a._olm_pk_key_from_private=a.asm.y).apply(null,arguments)},a._olm_pk_generate_key=function(){return(a._olm_pk_generate_key=a.asm.z).apply(null,arguments)},a._olm_pickle_pk_decryption_length=function(){return(a._olm_pickle_pk_decryption_length=a.asm.A).apply(null,arguments)},a._olm_pickle_pk_decryption=function(){return(a._olm_pickle_pk_decryption=a.asm.B).apply(null,arguments)},a._olm_unpickle_pk_decryption=function(){return(a._olm_unpickle_pk_decryption=a.asm.C).apply(null,arguments)},a._olm_pk_max_plaintext_length=function(){return(a._olm_pk_max_plaintext_length=a.asm.D).apply(null,arguments)},a._olm_pk_decrypt=function(){return(a._olm_pk_decrypt=a.asm.E).apply(null,arguments)},a._olm_pk_get_private_key=function(){return(a._olm_pk_get_private_key=a.asm.F).apply(null,arguments)},a._olm_pk_signing_size=function(){return(a._olm_pk_signing_size=a.asm.G).apply(null,arguments)},a._olm_pk_signing=function(){return(a._olm_pk_signing=a.asm.H).apply(null,arguments)},a._olm_pk_signing_last_error=function(){return(a._olm_pk_signing_last_error=a.asm.I).apply(null,arguments)},a._olm_pk_signing_last_error_code=function(){return(a._olm_pk_signing_last_error_code=a.asm.J).apply(null,arguments)},a._olm_clear_pk_signing=function(){return(a._olm_clear_pk_signing=a.asm.K).apply(null,arguments)},a._olm_pk_signing_seed_length=function(){return(a._olm_pk_signing_seed_length=a.asm.L).apply(null,arguments)},a._olm_pk_signing_public_key_length=function(){return(a._olm_pk_signing_public_key_length=a.asm.M).apply(null,arguments)},a._olm_pk_signing_key_from_seed=function(){return(a._olm_pk_signing_key_from_seed=a.asm.N).apply(null,arguments)},a._olm_pk_signature_length=function(){return(a._olm_pk_signature_length=a.asm.O).apply(null,arguments)},a._olm_pk_sign=function(){return(a._olm_pk_sign=a.asm.P).apply(null,arguments)},a._olm_get_library_version=function(){return(a._olm_get_library_version=a.asm.Q).apply(null,arguments)},a._olm_error=function(){return(a._olm_error=a.asm.R).apply(null,arguments)},a._olm_account_last_error=function(){return(a._olm_account_last_error=a.asm.S).apply(null,arguments)},a._olm_account_last_error_code=function(){return(a._olm_account_last_error_code=a.asm.T).apply(null,arguments)},a._olm_session_last_error=function(){return(a._olm_session_last_error=a.asm.U).apply(null,arguments)},a._olm_session_last_error_code=function(){return(a._olm_session_last_error_code=a.asm.V).apply(null,arguments)},a._olm_utility_last_error=function(){return(a._olm_utility_last_error=a.asm.W).apply(null,arguments)},a._olm_utility_last_error_code=function(){return(a._olm_utility_last_error_code=a.asm.X).apply(null,arguments)},a._olm_account_size=function(){return(a._olm_account_size=a.asm.Y).apply(null,arguments)},a._olm_session_size=function(){return(a._olm_session_size=a.asm.Z).apply(null,arguments)},a._olm_utility_size=function(){return(a._olm_utility_size=a.asm._).apply(null,arguments)},a._olm_account=function(){return(a._olm_account=a.asm.$).apply(null,arguments)},a._olm_session=function(){return(a._olm_session=a.asm.aa).apply(null,arguments)},a._olm_utility=function(){return(a._olm_utility=a.asm.ba).apply(null,arguments)},a._olm_clear_account=function(){return(a._olm_clear_account=a.asm.ca).apply(null,arguments)},a._olm_clear_session=function(){return(a._olm_clear_session=a.asm.da).apply(null,arguments)},a._olm_clear_utility=function(){return(a._olm_clear_utility=a.asm.ea).apply(null,arguments)},a._olm_pickle_account_length=function(){return(a._olm_pickle_account_length=a.asm.fa).apply(null,arguments)},a._olm_pickle_session_length=function(){return(a._olm_pickle_session_length=a.asm.ga).apply(null,arguments)},a._olm_pickle_account=function(){return(a._olm_pickle_account=a.asm.ha).apply(null,arguments)},a._olm_pickle_session=function(){return(a._olm_pickle_session=a.asm.ia).apply(null,arguments)},a._olm_unpickle_account=function(){return(a._olm_unpickle_account=a.asm.ja).apply(null,arguments)},a._olm_unpickle_session=function(){return(a._olm_unpickle_session=a.asm.ka).apply(null,arguments)},a._olm_create_account_random_length=function(){return(a._olm_create_account_random_length=a.asm.la).apply(null,arguments)},a._olm_create_account=function(){return(a._olm_create_account=a.asm.ma).apply(null,arguments)},a._olm_account_identity_keys_length=function(){return(a._olm_account_identity_keys_length=a.asm.na).apply(null,arguments)},a._olm_account_identity_keys=function(){return(a._olm_account_identity_keys=a.asm.oa).apply(null,arguments)},a._olm_account_signature_length=function(){return(a._olm_account_signature_length=a.asm.pa).apply(null,arguments)},a._olm_account_sign=function(){return(a._olm_account_sign=a.asm.qa).apply(null,arguments)},a._olm_account_one_time_keys_length=function(){return(a._olm_account_one_time_keys_length=a.asm.ra).apply(null,arguments)},a._olm_account_one_time_keys=function(){return(a._olm_account_one_time_keys=a.asm.sa).apply(null,arguments)},a._olm_account_mark_keys_as_published=function(){return(a._olm_account_mark_keys_as_published=a.asm.ta).apply(null,arguments)},a._olm_account_max_number_of_one_time_keys=function(){return(a._olm_account_max_number_of_one_time_keys=a.asm.ua).apply(null,arguments)},a._olm_account_generate_one_time_keys_random_length=function(){return(a._olm_account_generate_one_time_keys_random_length=a.asm.va).apply(null,arguments)},a._olm_account_generate_one_time_keys=function(){return(a._olm_account_generate_one_time_keys=a.asm.wa).apply(null,arguments)},a._olm_account_generate_fallback_key_random_length=function(){return(a._olm_account_generate_fallback_key_random_length=a.asm.xa).apply(null,arguments)},a._olm_account_generate_fallback_key=function(){return(a._olm_account_generate_fallback_key=a.asm.ya).apply(null,arguments)},a._olm_account_fallback_key_length=function(){return(a._olm_account_fallback_key_length=a.asm.za).apply(null,arguments)},a._olm_account_fallback_key=function(){return(a._olm_account_fallback_key=a.asm.Aa).apply(null,arguments)},a._olm_account_unpublished_fallback_key_length=function(){return(a._olm_account_unpublished_fallback_key_length=a.asm.Ba).apply(null,arguments)},a._olm_account_unpublished_fallback_key=function(){return(a._olm_account_unpublished_fallback_key=a.asm.Ca).apply(null,arguments)},a._olm_account_forget_old_fallback_key=function(){return(a._olm_account_forget_old_fallback_key=a.asm.Da).apply(null,arguments)},a._olm_create_outbound_session_random_length=function(){return(a._olm_create_outbound_session_random_length=a.asm.Ea).apply(null,arguments)},a._olm_create_outbound_session=function(){return(a._olm_create_outbound_session=a.asm.Fa).apply(null,arguments)},a._olm_create_inbound_session=function(){return(a._olm_create_inbound_session=a.asm.Ga).apply(null,arguments)},a._olm_create_inbound_session_from=function(){return(a._olm_create_inbound_session_from=a.asm.Ha).apply(null,arguments)},a._olm_session_id_length=function(){return(a._olm_session_id_length=a.asm.Ia).apply(null,arguments)},a._olm_session_id=function(){return(a._olm_session_id=a.asm.Ja).apply(null,arguments)},a._olm_session_has_received_message=function(){return(a._olm_session_has_received_message=a.asm.Ka).apply(null,arguments)},a._olm_session_describe=function(){return(a._olm_session_describe=a.asm.La).apply(null,arguments)},a._olm_matches_inbound_session=function(){return(a._olm_matches_inbound_session=a.asm.Ma).apply(null,arguments)},a._olm_matches_inbound_session_from=function(){return(a._olm_matches_inbound_session_from=a.asm.Na).apply(null,arguments)},a._olm_remove_one_time_keys=function(){return(a._olm_remove_one_time_keys=a.asm.Oa).apply(null,arguments)},a._olm_encrypt_message_type=function(){return(a._olm_encrypt_message_type=a.asm.Pa).apply(null,arguments)},a._olm_encrypt_random_length=function(){return(a._olm_encrypt_random_length=a.asm.Qa).apply(null,arguments)},a._olm_encrypt_message_length=function(){return(a._olm_encrypt_message_length=a.asm.Ra).apply(null,arguments)},a._olm_encrypt=function(){return(a._olm_encrypt=a.asm.Sa).apply(null,arguments)},a._olm_decrypt_max_plaintext_length=function(){return(a._olm_decrypt_max_plaintext_length=a.asm.Ta).apply(null,arguments)},a._olm_decrypt=function(){return(a._olm_decrypt=a.asm.Ua).apply(null,arguments)},a._olm_sha256_length=function(){return(a._olm_sha256_length=a.asm.Va).apply(null,arguments)},a._olm_sha256=function(){return(a._olm_sha256=a.asm.Wa).apply(null,arguments)},a._olm_ed25519_verify=function(){return(a._olm_ed25519_verify=a.asm.Xa).apply(null,arguments)},a._olm_inbound_group_session_size=function(){return(a._olm_inbound_group_session_size=a.asm.Ya).apply(null,arguments)},a._olm_inbound_group_session=function(){return(a._olm_inbound_group_session=a.asm.Za).apply(null,arguments)},a._olm_clear_inbound_group_session=function(){return(a._olm_clear_inbound_group_session=a.asm._a).apply(null,arguments)},a._olm_inbound_group_session_last_error=function(){return(a._olm_inbound_group_session_last_error=a.asm.$a).apply(null,arguments)},a._olm_inbound_group_session_last_error_code=function(){return(a._olm_inbound_group_session_last_error_code=a.asm.ab).apply(null,arguments)},a._olm_init_inbound_group_session=function(){return(a._olm_init_inbound_group_session=a.asm.bb).apply(null,arguments)},a._olm_import_inbound_group_session=function(){return(a._olm_import_inbound_group_session=a.asm.cb).apply(null,arguments)},a._olm_pickle_inbound_group_session_length=function(){return(a._olm_pickle_inbound_group_session_length=a.asm.db).apply(null,arguments)},a._olm_pickle_inbound_group_session=function(){return(a._olm_pickle_inbound_group_session=a.asm.eb).apply(null,arguments)},a._olm_unpickle_inbound_group_session=function(){return(a._olm_unpickle_inbound_group_session=a.asm.fb).apply(null,arguments)},a._olm_group_decrypt_max_plaintext_length=function(){return(a._olm_group_decrypt_max_plaintext_length=a.asm.gb).apply(null,arguments)},a._olm_group_decrypt=function(){return(a._olm_group_decrypt=a.asm.hb).apply(null,arguments)},a._olm_inbound_group_session_id_length=function(){return(a._olm_inbound_group_session_id_length=a.asm.ib).apply(null,arguments)},a._olm_inbound_group_session_id=function(){return(a._olm_inbound_group_session_id=a.asm.jb).apply(null,arguments)},a._olm_inbound_group_session_first_known_index=function(){return(a._olm_inbound_group_session_first_known_index=a.asm.kb).apply(null,arguments)},a._olm_inbound_group_session_is_verified=function(){return(a._olm_inbound_group_session_is_verified=a.asm.lb).apply(null,arguments)},a._olm_export_inbound_group_session_length=function(){return(a._olm_export_inbound_group_session_length=a.asm.mb).apply(null,arguments)},a._olm_export_inbound_group_session=function(){return(a._olm_export_inbound_group_session=a.asm.nb).apply(null,arguments)},a._olm_sas_last_error=function(){return(a._olm_sas_last_error=a.asm.ob).apply(null,arguments)},a._olm_sas_last_error_code=function(){return(a._olm_sas_last_error_code=a.asm.pb).apply(null,arguments)},a._olm_sas_size=function(){return(a._olm_sas_size=a.asm.qb).apply(null,arguments)},a._olm_sas=function(){return(a._olm_sas=a.asm.rb).apply(null,arguments)},a._olm_clear_sas=function(){return(a._olm_clear_sas=a.asm.sb).apply(null,arguments)},a._olm_create_sas_random_length=function(){return(a._olm_create_sas_random_length=a.asm.tb).apply(null,arguments)},a._olm_create_sas=function(){return(a._olm_create_sas=a.asm.ub).apply(null,arguments)},a._olm_sas_pubkey_length=function(){return(a._olm_sas_pubkey_length=a.asm.vb).apply(null,arguments)},a._olm_sas_get_pubkey=function(){return(a._olm_sas_get_pubkey=a.asm.wb).apply(null,arguments)},a._olm_sas_set_their_key=function(){return(a._olm_sas_set_their_key=a.asm.xb).apply(null,arguments)},a._olm_sas_is_their_key_set=function(){return(a._olm_sas_is_their_key_set=a.asm.yb).apply(null,arguments)},a._olm_sas_generate_bytes=function(){return(a._olm_sas_generate_bytes=a.asm.zb).apply(null,arguments)},a._olm_sas_mac_length=function(){return(a._olm_sas_mac_length=a.asm.Ab).apply(null,arguments)},a._olm_sas_calculate_mac_fixed_base64=function(){return(a._olm_sas_calculate_mac_fixed_base64=a.asm.Bb).apply(null,arguments)},a._olm_sas_calculate_mac=function(){return(a._olm_sas_calculate_mac=a.asm.Cb).apply(null,arguments)},a._olm_sas_calculate_mac_long_kdf=function(){return(a._olm_sas_calculate_mac_long_kdf=a.asm.Db).apply(null,arguments)},a._olm_outbound_group_session_size=function(){return(a._olm_outbound_group_session_size=a.asm.Eb).apply(null,arguments)},a._olm_outbound_group_session=function(){return(a._olm_outbound_group_session=a.asm.Fb).apply(null,arguments)},a._olm_clear_outbound_group_session=function(){return(a._olm_clear_outbound_group_session=a.asm.Gb).apply(null,arguments)},a._olm_outbound_group_session_last_error=function(){return(a._olm_outbound_group_session_last_error=a.asm.Hb).apply(null,arguments)},a._olm_outbound_group_session_last_error_code=function(){return(a._olm_outbound_group_session_last_error_code=a.asm.Ib).apply(null,arguments)},a._olm_pickle_outbound_group_session_length=function(){return(a._olm_pickle_outbound_group_session_length=a.asm.Jb).apply(null,arguments)},a._olm_pickle_outbound_group_session=function(){return(a._olm_pickle_outbound_group_session=a.asm.Kb).apply(null,arguments)},a._olm_unpickle_outbound_group_session=function(){return(a._olm_unpickle_outbound_group_session=a.asm.Lb).apply(null,arguments)},a._olm_init_outbound_group_session_random_length=function(){return(a._olm_init_outbound_group_session_random_length=a.asm.Mb).apply(null,arguments)},a._olm_init_outbound_group_session=function(){return(a._olm_init_outbound_group_session=a.asm.Nb).apply(null,arguments)},a._olm_group_encrypt_message_length=function(){return(a._olm_group_encrypt_message_length=a.asm.Ob).apply(null,arguments)},a._olm_group_encrypt=function(){return(a._olm_group_encrypt=a.asm.Pb).apply(null,arguments)},a._olm_outbound_group_session_id_length=function(){return(a._olm_outbound_group_session_id_length=a.asm.Qb).apply(null,arguments)},a._olm_outbound_group_session_id=function(){return(a._olm_outbound_group_session_id=a.asm.Rb).apply(null,arguments)},a._olm_outbound_group_session_message_index=function(){return(a._olm_outbound_group_session_message_index=a.asm.Sb).apply(null,arguments)},a._olm_outbound_group_session_key_length=function(){return(a._olm_outbound_group_session_key_length=a.asm.Tb).apply(null,arguments)},a._olm_outbound_group_session_key=function(){return(a._olm_outbound_group_session_key=a.asm.Ub).apply(null,arguments)},a._malloc=function(){return(a._malloc=a.asm.Vb).apply(null,arguments)},a._free=function(){return(a._free=a.asm.Wb).apply(null,arguments)};var ac=a.stackSave=function(){return(ac=a.stackSave=a.asm.Xb).apply(null,arguments)},jr=a.stackRestore=function(){return(jr=a.stackRestore=a.asm.Yb).apply(null,arguments)},cc=a.stackAlloc=function(){return(cc=a.stackAlloc=a.asm.Zb).apply(null,arguments)};a.ALLOC_STACK=1;var v;st=function f(){v||d(),v||(st=f)};function d(){function f(){if(!v&&(v=!0,a.calledRun=!0,!ur)){if(Gt(dr),g(a),a.onRuntimeInitialized&&a.onRuntimeInitialized(),a.postRun)for(typeof a.postRun=="function"&&(a.postRun=[a.postRun]);a.postRun.length;){var y=a.postRun.shift();Mt.unshift(y)}Gt(Mt)}}if(!(0<wr)){if(a.preRun)for(typeof a.preRun=="function"&&(a.preRun=[a.preRun]);a.preRun.length;)hr();Gt(_),0<wr||(a.setStatus?(a.setStatus("Running..."),setTimeout(function(){setTimeout(function(){a.setStatus("")},1),f()},1)):f())}}if(a.run=d,a.preInit)for(typeof a.preInit=="function"&&(a.preInit=[a.preInit]);0<a.preInit.length;)a.preInit.pop()();d();function h(){var f=a._olm_outbound_group_session_size();this.ac=je(f),this.$b=a._olm_outbound_group_session(this.ac)}function b(f){return function(){var y=f.apply(this,arguments);if(y===on)throw y=Q(a._olm_outbound_group_session_last_error(arguments[0])),Error("OLM."+y);return y}}h.prototype.free=function(){a._olm_clear_outbound_group_session(this.$b),Ve(this.$b)},h.prototype.pickle=z(function(f){f=ae(f);var y=b(a._olm_pickle_outbound_group_session_length)(this.$b),O=q(f),U=q(y+1);try{b(a._olm_pickle_outbound_group_session)(this.$b,O,f.length,U,y)}finally{for(ce(O,f.length),O=0;O<f.length;O++)f[O]=0}return Q(U,y)}),h.prototype.unpickle=z(function(f,y){f=ae(f);var O=q(f);y=ae(y);var U=q(y);try{b(a._olm_unpickle_outbound_group_session)(this.$b,O,f.length,U,y.length)}finally{for(ce(O,f.length),O=0;O<f.length;O++)f[O]=0}}),h.prototype.create=z(function(){var f=b(a._olm_init_outbound_group_session_random_length)(this.$b),y=Rr(f,p);try{b(a._olm_init_outbound_group_session)(this.$b,y,f)}finally{ce(y,f)}}),h.prototype.encrypt=function(f){try{var y=Fr(f),O=b(a._olm_group_encrypt_message_length)(this.$b,y),U=je(y+1);sn(f,Ue,U,y+1);var B=je(O+1);return b(a._olm_group_encrypt)(this.$b,U,y,B,O),Ke(B+O),Q(B,O)}finally{U!==void 0&&(ce(U,y+1),Ve(U)),B!==void 0&&Ve(B)}},h.prototype.session_id=z(function(){var f=b(a._olm_outbound_group_session_id_length)(this.$b),y=q(f+1);return b(a._olm_outbound_group_session_id)(this.$b,y,f),Q(y,f)}),h.prototype.session_key=z(function(){var f=b(a._olm_outbound_group_session_key_length)(this.$b),y=q(f+1);b(a._olm_outbound_group_session_key)(this.$b,y,f);var O=Q(y,f);return ce(y,f),O}),h.prototype.message_index=function(){return b(a._olm_outbound_group_session_message_index)(this.$b)},r.OutboundGroupSession=h;function C(){var f=a._olm_inbound_group_session_size();this.ac=je(f),this.$b=a._olm_inbound_group_session(this.ac)}function A(f){return function(){var y=f.apply(this,arguments);if(y===on)throw y=Q(a._olm_inbound_group_session_last_error(arguments[0])),Error("OLM."+y);return y}}C.prototype.free=function(){a._olm_clear_inbound_group_session(this.$b),Ve(this.$b)},C.prototype.pickle=z(function(f){f=ae(f);var y=A(a._olm_pickle_inbound_group_session_length)(this.$b),O=q(f),U=q(y+1);try{A(a._olm_pickle_inbound_group_session)(this.$b,O,f.length,U,y)}finally{for(ce(O,f.length),O=0;O<f.length;O++)f[O]=0}return Q(U,y)}),C.prototype.unpickle=z(function(f,y){f=ae(f);var O=q(f);y=ae(y);var U=q(y);try{A(a._olm_unpickle_inbound_group_session)(this.$b,O,f.length,U,y.length)}finally{for(ce(O,f.length),O=0;O<f.length;O++)f[O]=0}}),C.prototype.create=z(function(f){f=ae(f);var y=q(f);try{A(a._olm_init_inbound_group_session)(this.$b,y,f.length)}finally{for(ce(y,f.length),y=0;y<f.length;y++)f[y]=0}}),C.prototype.import_session=z(function(f){f=ae(f);var y=q(f);try{A(a._olm_import_inbound_group_session)(this.$b,y,f.length)}finally{for(ce(y,f.length),y=0;y<f.length;y++)f[y]=0}}),C.prototype.decrypt=z(function(f){try{var y=je(f.length);ui(f,y);var O=A(a._olm_group_decrypt_max_plaintext_length)(this.$b,y,f.length);ui(f,y);var U=je(O+1),B=q(4),ee=A(a._olm_group_decrypt)(this.$b,y,f.length,U,O,B);return Ke(U+ee),{plaintext:Q(U,ee),message_index:De(B,"i32")}}finally{y!==void 0&&Ve(y),U!==void 0&&(ce(U,ee),Ve(U))}}),C.prototype.session_id=z(function(){var f=A(a._olm_inbound_group_session_id_length)(this.$b),y=q(f+1);return A(a._olm_inbound_group_session_id)(this.$b,y,f),Q(y,f)}),C.prototype.first_known_index=z(function(){return A(a._olm_inbound_group_session_first_known_index)(this.$b)}),C.prototype.export_session=z(function(f){var y=A(a._olm_export_inbound_group_session_length)(this.$b),O=q(y+1);return b(a._olm_export_inbound_group_session)(this.$b,O,y,f),f=Q(O,y),ce(O,y),f}),r.InboundGroupSession=C;function $(){var f=a._olm_pk_encryption_size();this.ac=je(f),this.$b=a._olm_pk_encryption(this.ac)}function re(f){return function(){var y=f.apply(this,arguments);if(y===on)throw y=Q(a._olm_pk_encryption_last_error(arguments[0])),Error("OLM."+y);return y}}$.prototype.free=function(){a._olm_clear_pk_encryption(this.$b),Ve(this.$b)},$.prototype.set_recipient_key=z(function(f){f=ae(f);var y=q(f);re(a._olm_pk_encryption_set_recipient_key)(this.$b,y,f.length)}),$.prototype.encrypt=z(function(f){try{var y=Fr(f),O=je(y+1);sn(f,Ue,O,y+1);var U=re(a._olm_pk_encrypt_random_length)(),B=Rr(U,p),ee=re(a._olm_pk_ciphertext_length)(this.$b,y),ve=je(ee+1),At=re(a._olm_pk_mac_length)(this.$b),qo=q(At+1);Ke(qo+At);var Li=re(a._olm_pk_key_length)(),an=q(Li+1);return Ke(an+Li),re(a._olm_pk_encrypt)(this.$b,O,y,ve,ee,qo,At,an,Li,B,U),Ke(ve+ee),{ciphertext:Q(ve,ee),mac:Q(qo,At),ephemeral:Q(an,Li)}}finally{B!==void 0&&ce(B,U),O!==void 0&&(ce(O,y+1),Ve(O)),ve!==void 0&&Ve(ve)}});function we(){var f=a._olm_pk_decryption_size();this.ac=je(f),this.$b=a._olm_pk_decryption(this.ac)}function de(f){return function(){var y=f.apply(this,arguments);if(y===on)throw y=Q(a._olm_pk_decryption_last_error(arguments[0])),Error("OLM."+y);return y}}we.prototype.free=function(){a._olm_clear_pk_decryption(this.$b),Ve(this.$b)},we.prototype.init_with_private_key=z(function(f){var y=q(f.length);a.HEAPU8.set(f,y);var O=de(a._olm_pk_key_length)(),U=q(O+1);try{de(a._olm_pk_key_from_private)(this.$b,U,O,y,f.length)}finally{ce(y,f.length)}return Q(U,O)}),we.prototype.generate_key=z(function(){var f=de(a._olm_pk_private_key_length)(),y=Rr(f,p),O=de(a._olm_pk_key_length)(),U=q(O+1);try{de(a._olm_pk_key_from_private)(this.$b,U,O,y,f)}finally{ce(y,f)}return Q(U,O)}),we.prototype.get_private_key=z(function(){var f=re(a._olm_pk_private_key_length)(),y=q(f);de(a._olm_pk_get_private_key)(this.$b,y,f);var O=new Uint8Array(new Uint8Array(a.HEAPU8.buffer,y,f));return ce(y,f),O}),we.prototype.pickle=z(function(f){f=ae(f);var y=de(a._olm_pickle_pk_decryption_length)(this.$b),O=q(f),U=q(y+1);try{de(a._olm_pickle_pk_decryption)(this.$b,O,f.length,U,y)}finally{for(ce(O,f.length),O=0;O<f.length;O++)f[O]=0}return Q(U,y)}),we.prototype.unpickle=z(function(f,y){f=ae(f);var O=q(f),U=ae(y),B=q(U);y=de(a._olm_pk_key_length)();var ee=q(y+1);try{de(a._olm_unpickle_pk_decryption)(this.$b,O,f.length,B,U.length,ee,y)}finally{for(ce(O,f.length),O=0;O<f.length;O++)f[O]=0}return Q(ee,y)}),we.prototype.decrypt=z(function(f,y,O){try{var U=Fr(O),B=je(U+1);sn(O,Ue,B,U+1);var ee=ae(f),ve=q(ee),At=ae(y),qo=q(At),Li=de(a._olm_pk_max_plaintext_length)(this.$b,U),an=je(Li+1),cu=de(a._olm_pk_decrypt)(this.$b,ve,ee.length,qo,At.length,B,U,an,Li);return Ke(an+cu),Q(an,cu)}finally{an!==void 0&&(ce(an,cu+1),Ve(an)),B!==void 0&&Ve(B)}});function Ie(){var f=a._olm_pk_signing_size();this.ac=je(f),this.$b=a._olm_pk_signing(this.ac)}function ye(f){return function(){var y=f.apply(this,arguments);if(y===on)throw y=Q(a._olm_pk_signing_last_error(arguments[0])),Error("OLM."+y);return y}}Ie.prototype.free=function(){a._olm_clear_pk_signing(this.$b),Ve(this.$b)},Ie.prototype.init_with_seed=z(function(f){var y=q(f.length);a.HEAPU8.set(f,y);var O=ye(a._olm_pk_signing_public_key_length)(),U=q(O+1);try{ye(a._olm_pk_signing_key_from_seed)(this.$b,U,O,y,f.length)}finally{ce(y,f.length)}return Q(U,O)}),Ie.prototype.generate_seed=z(function(){var f=ye(a._olm_pk_signing_seed_length)(),y=Rr(f,p),O=new Uint8Array(new Uint8Array(a.HEAPU8.buffer,y,f));return ce(y,f),O}),Ie.prototype.sign=z(function(f){try{var y=Fr(f),O=je(y+1);sn(f,Ue,O,y+1);var U=ye(a._olm_pk_signature_length)(),B=q(U+1);return ye(a._olm_pk_sign)(this.$b,O,y,B,U),Q(B,U)}finally{O!==void 0&&(ce(O,y+1),Ve(O))}});function gi(){var f=a._olm_sas_size(),y=a._olm_create_sas_random_length(),O=Rr(y,p);this.ac=je(f),this.$b=a._olm_sas(this.ac),a._olm_create_sas(this.$b,O,y),ce(O,y)}function An(f){return function(){var y=f.apply(this,arguments);if(y===on)throw y=Q(a._olm_sas_last_error(arguments[0])),Error("OLM."+y);return y}}gi.prototype.free=function(){a._olm_clear_sas(this.$b),Ve(this.$b)},gi.prototype.get_pubkey=z(function(){var f=An(a._olm_sas_pubkey_length)(this.$b),y=q(f+1);return An(a._olm_sas_get_pubkey)(this.$b,y,f),Q(y,f)}),gi.prototype.set_their_key=z(function(f){f=ae(f);var y=q(f);An(a._olm_sas_set_their_key)(this.$b,y,f.length)}),gi.prototype.is_their_key_set=z(function(){return!!An(a._olm_sas_is_their_key_set)(this.$b)}),gi.prototype.generate_bytes=z(function(f,y){f=ae(f);var O=q(f),U=q(y);return An(a._olm_sas_generate_bytes)(this.$b,O,f.length,U,y),new Uint8Array(new Uint8Array(a.HEAPU8.buffer,U,y))}),gi.prototype.calculate_mac=z(function(f,y){f=ae(f);var O=q(f);y=ae(y);var U=q(y),B=An(a._olm_sas_mac_length)(this.$b),ee=q(B+1);return An(a._olm_sas_calculate_mac)(this.$b,O,f.length,U,y.length,ee,B),Q(ee,B)}),gi.prototype.calculate_mac_long_kdf=z(function(f,y){f=ae(f);var O=q(f);y=ae(y);var U=q(y),B=An(a._olm_sas_mac_length)(this.$b),ee=q(B+1);return An(a._olm_sas_calculate_mac_long_kdf)(this.$b,O,f.length,U,y.length,ee,B),Q(ee,B)});var je=a._malloc,Ve=a._free,on;function Rr(f,y){var O=cc(f);return y(new Uint8Array(a.HEAPU8.buffer,O,f)),O}function q(f){return typeof f=="number"?Rr(f,function(y){y.fill(0)}):Rr(f.length,function(y){y.set(f)})}function ae(f){if(f instanceof Uint8Array)var y=f;else y=Array(Fr(f)+1),f=sn(f,y,0,y.length),y.length=f;return y}function z(f){return function(){var y=ac();try{return f.apply(this,arguments)}finally{jr(y)}}}function ce(f,y){for(;0<y--;)a.HEAP8[f++]=0}function wt(){var f=a._olm_account_size();this.ac=je(f),this.$b=a._olm_account(this.ac)}function Ge(f){return function(){var y=f.apply(this,arguments);if(y===on)throw y=Q(a._olm_account_last_error(arguments[0])),Error("OLM."+y);return y}}wt.prototype.free=function(){a._olm_clear_account(this.$b),Ve(this.$b)},wt.prototype.create=z(function(){var f=Ge(a._olm_create_account_random_length)(this.$b),y=Rr(f,p);try{Ge(a._olm_create_account)(this.$b,y,f)}finally{ce(y,f)}}),wt.prototype.identity_keys=z(function(){var f=Ge(a._olm_account_identity_keys_length)(this.$b),y=q(f+1);return Ge(a._olm_account_identity_keys)(this.$b,y,f),Q(y,f)}),wt.prototype.sign=z(function(f){var y=Ge(a._olm_account_signature_length)(this.$b);f=ae(f);var O=q(f),U=q(y+1);try{Ge(a._olm_account_sign)(this.$b,O,f.length,U,y)}finally{for(ce(O,f.length),O=0;O<f.length;O++)f[O]=0}return Q(U,y)}),wt.prototype.one_time_keys=z(function(){var f=Ge(a._olm_account_one_time_keys_length)(this.$b),y=q(f+1);return Ge(a._olm_account_one_time_keys)(this.$b,y,f),Q(y,f)}),wt.prototype.mark_keys_as_published=z(function(){Ge(a._olm_account_mark_keys_as_published)(this.$b)}),wt.prototype.max_number_of_one_time_keys=z(function(){return Ge(a._olm_account_max_number_of_one_time_keys)(this.$b)}),wt.prototype.generate_one_time_keys=z(function(f){var y=Ge(a._olm_account_generate_one_time_keys_random_length)(this.$b,f),O=Rr(y,p);try{Ge(a._olm_account_generate_one_time_keys)(this.$b,f,O,y)}finally{ce(O,y)}}),wt.prototype.remove_one_time_keys=z(function(f){Ge(a._olm_remove_one_time_keys)(this.$b,f.$b)}),wt.prototype.generate_fallback_key=z(function(){var f=Ge(a._olm_account_generate_fallback_key_random_length)(this.$b),y=Rr(f,p);try{Ge(a._olm_account_generate_fallback_key)(this.$b,y,f)}finally{ce(y,f)}}),wt.prototype.fallback_key=z(function(){var f=Ge(a._olm_account_fallback_key_length)(this.$b),y=q(f+1);return Ge(a._olm_account_fallback_key)(this.$b,y,f),Q(y,f)}),wt.prototype.unpublished_fallback_key=z(function(){var f=Ge(a._olm_account_unpublished_fallback_key_length)(this.$b),y=q(f+1);return Ge(a._olm_account_unpublished_fallback_key)(this.$b,y,f),Q(y,f)}),wt.prototype.forget_old_fallback_key=z(function(){Ge(a._olm_account_forget_old_fallback_key)(this.$b)}),wt.prototype.pickle=z(function(f){f=ae(f);var y=Ge(a._olm_pickle_account_length)(this.$b),O=q(f),U=q(y+1);try{Ge(a._olm_pickle_account)(this.$b,O,f.length,U,y)}finally{for(ce(O,f.length),O=0;O<f.length;O++)f[O]=0}return Q(U,y)}),wt.prototype.unpickle=z(function(f,y){f=ae(f);var O=q(f);y=ae(y);var U=q(y);try{Ge(a._olm_unpickle_account)(this.$b,O,f.length,U,y.length)}finally{for(ce(O,f.length),O=0;O<f.length;O++)f[O]=0}});function Wt(){var f=a._olm_session_size();this.ac=je(f),this.$b=a._olm_session(this.ac)}function at(f){return function(){var y=f.apply(this,arguments);if(y===on)throw y=Q(a._olm_session_last_error(arguments[0])),Error("OLM."+y);return y}}Wt.prototype.free=function(){a._olm_clear_session(this.$b),Ve(this.$b)},Wt.prototype.pickle=z(function(f){f=ae(f);var y=at(a._olm_pickle_session_length)(this.$b),O=q(f),U=q(y+1);try{at(a._olm_pickle_session)(this.$b,O,f.length,U,y)}finally{for(ce(O,f.length),O=0;O<f.length;O++)f[O]=0}return Q(U,y)}),Wt.prototype.unpickle=z(function(f,y){f=ae(f);var O=q(f);y=ae(y);var U=q(y);try{at(a._olm_unpickle_session)(this.$b,O,f.length,U,y.length)}finally{for(ce(O,f.length),O=0;O<f.length;O++)f[O]=0}}),Wt.prototype.create_outbound=z(function(f,y,O){var U=at(a._olm_create_outbound_session_random_length)(this.$b),B=Rr(U,p);y=ae(y),O=ae(O);var ee=q(y),ve=q(O);try{at(a._olm_create_outbound_session)(this.$b,f.$b,ee,y.length,ve,O.length,B,U)}finally{ce(B,U)}}),Wt.prototype.create_inbound=z(function(f,y){y=ae(y);var O=q(y);try{at(a._olm_create_inbound_session)(this.$b,f.$b,O,y.length)}finally{for(ce(O,y.length),f=0;f<y.length;f++)y[f]=0}}),Wt.prototype.create_inbound_from=z(function(f,y,O){y=ae(y);var U=q(y);O=ae(O);var B=q(O);try{at(a._olm_create_inbound_session_from)(this.$b,f.$b,U,y.length,B,O.length)}finally{for(ce(B,O.length),f=0;f<O.length;f++)O[f]=0}}),Wt.prototype.session_id=z(function(){var f=at(a._olm_session_id_length)(this.$b),y=q(f+1);return at(a._olm_session_id)(this.$b,y,f),Q(y,f)}),Wt.prototype.has_received_message=function(){return!!at(a._olm_session_has_received_message)(this.$b)},Wt.prototype.matches_inbound=z(function(f){f=ae(f);var y=q(f);return!!at(a._olm_matches_inbound_session)(this.$b,y,f.length)}),Wt.prototype.matches_inbound_from=z(function(f,y){f=ae(f);var O=q(f);y=ae(y);var U=q(y);return!!at(a._olm_matches_inbound_session_from)(this.$b,O,f.length,U,y.length)}),Wt.prototype.encrypt=z(function(f){try{var y=at(a._olm_encrypt_random_length)(this.$b),O=at(a._olm_encrypt_message_type)(this.$b),U=Fr(f),B=at(a._olm_encrypt_message_length)(this.$b,U),ee=Rr(y,p),ve=je(U+1);sn(f,Ue,ve,U+1);var At=je(B+1);return at(a._olm_encrypt)(this.$b,ve,U,ee,y,At,B),Ke(At+B),{type:O,body:Q(At,B)}}finally{ee!==void 0&&ce(ee,y),ve!==void 0&&(ce(ve,U+1),Ve(ve)),At!==void 0&&Ve(At)}}),Wt.prototype.decrypt=z(function(f,y){try{var O=je(y.length);ui(y,O);var U=at(a._olm_decrypt_max_plaintext_length)(this.$b,f,O,y.length);ui(y,O);var B=je(U+1),ee=at(a._olm_decrypt)(this.$b,f,O,y.length,B,U);return Ke(B+ee),Q(B,ee)}finally{O!==void 0&&Ve(O),B!==void 0&&(ce(B,U),Ve(B))}}),Wt.prototype.describe=z(function(){try{var f=je(256);return at(a._olm_session_describe)(this.$b,f,256),Q(f)}finally{f!==void 0&&Ve(f)}});function lc(){var f=a._olm_utility_size();this.ac=je(f),this.$b=a._olm_utility(this.ac)}function au(f){return function(){var y=f.apply(this,arguments);if(y===on)throw y=Q(a._olm_utility_last_error(arguments[0])),Error("OLM."+y);return y}}return lc.prototype.free=function(){a._olm_clear_utility(this.$b),Ve(this.$b)},lc.prototype.sha256=z(function(f){var y=au(a._olm_sha256_length)(this.$b);f=ae(f);var O=q(f),U=q(y+1);try{au(a._olm_sha256)(this.$b,O,f.length,U,y)}finally{for(ce(O,f.length),O=0;O<f.length;O++)f[O]=0}return Q(U,y)}),lc.prototype.ed25519_verify=z(function(f,y,O){f=ae(f);var U=q(f);y=ae(y);var B=q(y);O=ae(O);var ee=q(O);try{au(a._olm_ed25519_verify)(this.$b,U,f.length,B,y.length,ee,O.length)}finally{for(ce(B,y.length),f=0;f<y.length;f++)y[f]=0}}),r.Account=wt,r.Session=Wt,r.Utility=lc,r.PkEncryption=$,r.PkDecryption=we,r.PkSigning=Ie,r.SAS=gi,r.get_library_version=z(function(){var f=q(3);return a._olm_get_library_version(f,f+1,f+2),[De(f,"i8"),De(f+1,"i8"),De(f+2,"i8")]}),u.ready}}();n.exports=o;var c;return r.init=function(l){return c||(l&&(OLM_OPTIONS=l),c=new Promise(function(u,a){i=function(){u()},s=function(g){a(g)},o()}),c)},r}();typeof window!="undefined"&&(window.Olm=t),n.exports=t;// @license-end
-})(M_);var KA=M_.exports;export{X_ as $,Il as D,ll as E,ty as F,ba as L,DM as M,KA as O,$A as P,yo as S,NA as W,mE as a,UA as b,wE as c,MM as d,zO as e,BA as f,eE as g,yE as j,Pl as l,LA as o};
diff --git a/pr-121/index.html b/pr-121/index.html
@@ -11,12 +11,13 @@
global = globalThis // fix for "global not defined" error
globalThis.OLM_OPTIONS = undefined; // Fix missing var for olm
</script>
- <script type="module" crossorigin src="/pr-121/assets/index.fcbee31f.js"></script>
- <link rel="modulepreload" href="/pr-121/assets/vendor.d4008ec4.js">
+ <script type="module" crossorigin src="/pr-121/assets/index.955c971f.js"></script>
+ <link rel="modulepreload" href="/pr-121/assets/vendor.09079154.js">
<link rel="stylesheet" href="/pr-121/assets/index.311ea642.css">
</head>
<body>
+ <noscript>You need to enable JavaScript to run this app.</noscript>
<div id="app"></div>
</body>