/*! For license information please see bundle.js.LICENSE */ !function(e){function t(t){for(var n,o,i=t[0],a=t[1],s=0,l=[];s(.*?)<\\/").concat(s,">|<").concat(s,">|<").concat(s,"\\s*\\/>)")]=n[s];r=y(r,a)}return r}(function(e,t){var n;t&&"object"===c()(t)&&(n=t.count,Object.keys(t).forEach((function(e){void 0===t[e]&&(console.warn("safeCounterpartTranslate called with undefined interpolation name: "+e),t[e]="undefined"),null===t[e]&&(console.warn("safeCounterpartTranslate called with null interpolation name: "+e),t[e]="null")})));var r=p.a.translate(e,t);return void 0===r&&void 0!==n&&(r=p.a.translate(e,Object.assign({},t,{locale:"en"}))),r}(e,Object.assign({interpolate:!1},t)),t,n);return r}function y(e,t){var n=[e],r=!1;for(var o in t){var i=new RegExp(o,"g"),a=!1;for(var s in n){var l=n[s];if("string"==typeof l){var u=i.exec(l);if(u){a=!0;for(var d=l.substr(0,u.index),p=[],h=void 0;u;){h=u;var g=u.slice(2),f=void 0;f=t[o]instanceof Function?t[o].apply(null,g):t[o],"object"===c()(f)&&(r=!0),"string"==typeof f&&""===f||p.push(f);var _=void 0;if(u=i.exec(l)){var v=h.index+h[0].length;_=l.substr(v,u.index-v)}else _=l.substr(h.index+h[0].length);_&&p.push(_)}n.splice.apply(n,[s,1].concat(p)),""!==d&&n.splice(s,0,d)}}}a||"%\\(count\\)s"!==o&&console.log("Could not find ".concat(i," in ").concat(e))}return r?m.a.createElement.apply(m.a,["span",null].concat(n)):n.join("")}function E(e){var t,n;return Array.isArray(e)||(e=[e]),D().then((function(r){n=r;for(var o=0;o-1)return e[r];var o=n.find((function(e){return e.substr(0,2)===t.substr(0,2)}));if(o>-1)return e[o];var i=n.find((function(e){return e.startsWith("en")}));return i>-1?e[i]:e[0]}function D(){return new Promise(function(){var e=a()(o.a.mark((function e(t,n){var r;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r="string"==typeof f?f:"i18n/languages.json",u()({method:"GET",url:r},(function(e,r,o){e||r.status<200||r.status>=300?n({err:e,response:r}):t(JSON.parse(o))}));case 2:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}())}function O(e){return new Promise((function(t,n){u()({method:"GET",url:e},(function(e,r,o){e||r.status<200||r.status>=300?n({err:e,response:r}):t(function(e){for(var t={},n=0,r=Object.keys(e);n")),e._watchers[a]=s,T.watchSetting(t,n,s),a}},{key:"unwatchSetting",value:function(t){e._watchers[t]&&(T.unwatchSetting(e._watchers[t]),delete e._watchers[t])}},{key:"monitorSetting",value:function(t,n){var r=this;this._monitors[t]||(this._monitors[t]={});var o=function(){r._monitors[t][n]=e.watchSetting(t,n,(function(e,t,n,r,o){S.a.dispatch({action:"setting_updated",settingName:e,roomId:t,level:n,newValueAtLevel:r,newValue:o})}))};if(Object.keys(this._monitors[t]).find((function(e){return e===n||null===e}))){if(null===n){for(var i=0,a=Object.keys(this._monitors[t]);i1&&void 0!==arguments[1]?arguments[1]:"default";if(!w.a[e]||!w.a[e].displayName)return null;var n=w.a[e].displayName;return n instanceof Object&&(n=n[t]?n[t]:n.default),Object(y.a)(n)}},{key:"getLabsFeatures",value:function(){var t=Object.keys(w.a).filter((function(t){return e.isFeature(t)}));return E.a.get().enableLabs?t:t.filter((function(t){return"labs"===e._getFeatureState(t)}))}},{key:"isFeature",value:function(e){return!!w.a[e]&&w.a[e].isFeature}},{key:"isFeatureEnabled",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!e.isFeature(t))throw new Error("Setting "+t+" is not a feature");return e.getValue(t,n)}},{key:"setFeatureEnabled",value:function(t,n){if(!w.a[t])throw new Error("Setting '"+t+"' does not appear to be a setting.");if(!e.isFeature(t))throw new Error("Setting "+t+" is not a feature");return e.setValue(t,null,"device",n)}},{key:"getValue",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!w.a[t])throw new Error("Setting '"+t+"' does not appear to be a setting.");var o=w.a[t],i=o.supportedLevelsAreOrdered?o.supportedLevels:U;return e.getValueAt(i[0],t,n,!1,r)}},{key:"getValueAt",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,o=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a=w.a[n];if(!a)throw new Error("Setting '"+n+"' does not appear to be a setting.");var s=a.supportedLevelsAreOrdered?a.supportedLevels:U;s.includes("default")||s.push("default");var c=s.indexOf(t);if(-1===c)throw new Error("Level "+t+" is not prioritized");if(e.isFeature(n)){var l=e._getFeatureState(n);if("enable"===l)return!0;if("disable"===l)return!1}var u=e._getHandlers(n);if(a.invertedSettingName&&(n=a.invertedSettingName),o){var d=u[t];if(!d)return e._getFinalValue(a,t,r,null,null);var p=d.getValue(n,r);return e._getFinalValue(a,t,r,p,t)}for(var h=c;h")),console.log("--- default level order: ".concat(JSON.stringify(U))),console.log("--- registered handlers: ".concat(JSON.stringify(Object.keys(A))));var o=function(t){for(var r=0,o=Object.keys(A);r"," = ").concat(JSON.stringify(s)))}catch(e){console.log("--- ".concat(a,"@").concat(n||""," THREW ERROR: ").concat(e.message)),console.error(e)}if(n)try{var c=a.getValue(t,null);console.log("--- ".concat(i,"@ = ").concat(JSON.stringify(c)))}catch(e){console.log("--- ".concat(a,"@ THREW ERROR: ").concat(e.message)),console.error(e)}}console.log("--- calculating as returned by SettingsStore"),console.log("--- these might not match if the setting uses a controller - be warned!");try{var l=e.getValue(t,n);console.log("--- SettingsStore#generic@".concat(n||""," = ").concat(JSON.stringify(l)))}catch(e){console.log("--- SettingsStore#generic@".concat(n||""," THREW ERROR: ").concat(e.message)),console.error(e)}if(n)try{var u=e.getValue(t,null);console.log("--- SettingsStore#generic@ = ".concat(JSON.stringify(u)))}catch(e){console.log("--- SettingsStore#generic@$ THREW ERROR: ".concat(e.message)),console.error(e)}var d=!0,p=!1,h=void 0;try{for(var m,g=U[Symbol.iterator]();!(d=(m=g.next()).done);d=!0){var f=m.value;try{var _=e.getValueAt(f,t,n);console.log("--- SettingsStore#".concat(f,"@").concat(n||""," = ").concat(JSON.stringify(_)))}catch(e){console.log("--- SettingsStore#".concat(f,"@").concat(n||""," THREW ERROR: ").concat(e.message)),console.error(e)}if(n)try{var v=e.getValueAt(f,t,null);console.log("--- SettingsStore#".concat(f,"@ = ").concat(JSON.stringify(v)))}catch(e){console.log("--- SettingsStore#".concat(f,"@$ THREW ERROR: ").concat(e.message)),console.error(e)}}}catch(e){p=!0,h=e}finally{try{d||null==g.return||g.return()}finally{if(p)throw h}}};o(t),r.invertedSettingName&&(console.log("--- TESTING INVERTED SETTING NAME"),console.log("--- inverted: ".concat(r.invertedSettingName)),o(r.invertedSettingName)),console.log("--- END DEBUG")}},{key:"_getHandler",value:function(t,n){var r=e._getHandlers(t);return r[n]?r[n]:null}},{key:"_getHandlers",value:function(e){if(!w.a[e])return{};var t={},n=!0,r=!1,o=void 0;try{for(var i,a=w.a[e].supportedLevels[Symbol.iterator]();!(n=(i=a.next()).done);n=!0){var s=i.value;if(!A[s])throw new Error("Unexpected level "+s);t[s]=A[s]}}catch(e){r=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw o}}return t.default||(t.default=A.default),t}},{key:"_getFeatureState",value:function(e){var t=E.a.get().features,n=E.a.get().enableLabs?"labs":"disable";t&&void 0!==t[e]&&(n=t[e]);return["enable","disable","labs"].includes(n)||(console.warn("Feature state '"+n+"' is invalid for "+e),n="disable"),n}}]),e}();p()(B,"_watchers",{}),p()(B,"_monitors",{}),e.mxSettingsStore=B}).call(this,n(34))},function(e,t){function n(e,t,n,r,o,i,a){try{var s=e[i](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,o)}e.exports=function(e){return function(){var t=this,r=arguments;return new Promise((function(o,i){var a=e.apply(t,r);function s(e){n(a,o,i,s,c,"next",e)}function c(e){n(a,o,i,s,c,"throw",e)}s(void 0)}))}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(197),o=n.n(r),i=o.a.getLogger("matrix");i.setLevel(o.a.levels.DEBUG)},function(e,t,n){"use strict";(function(e){var r=n(29),o=n.n(r),i=n(32),a=n.n(i),s=n(27),c=n.n(s),l=n(9),u=n.n(l),d=n(8),p=n.n(d),h=n(0),m=n.n(h),g=n(44),f=n.n(g),_=n(2),v=n.n(_),b=n(19),y=n.n(b),E=n(49),S=n(3),w=n(10),k=n(1),x=n(62),C=y()({displayName:"AsyncWrapper",propTypes:{prom:v.a.object.isRequired},getInitialState:function(){return{component:null,error:null}},componentWillMount:function(){var e=this;this._unmounted=!1,console.log("Starting load of AsyncWrapper for modal"),this.props.prom.then((function(t){if(!e._unmounted){var n=t.default?t.default:t;e.setState({component:n})}})).catch((function(t){console.warn("AsyncWrapper promise failed",t),e.setState({error:t})}))},componentWillUnmount:function(){this._unmounted=!0},_onWrapperCancelClick:function(){this.props.onFinished(!1)},render:function(){if(this.state.component){var e=this.state.component;return m.a.createElement(e,this.props)}if(this.state.error){var t=S.a("views.dialogs.BaseDialog"),n=S.a("views.elements.DialogButtons");return m.a.createElement(t,{onFinished:this.props.onFinished,title:Object(k.a)("Error")},Object(k.a)("Unable to load! Check your network connectivity and try again."),m.a.createElement(n,{primaryButton:Object(k.a)("Dismiss"),onPrimaryButtonClick:this._onWrapperCancelClick,hasCancel:!1}))}var r=S.a("elements.Spinner");return m.a.createElement(r,null)}}),T=function(){function e(){u()(this,e),this._counter=0,this._priorityModal=null,this._staticModal=null,this._modals=[],this.closeAll=this.closeAll.bind(this)}return p()(e,[{key:"hasDialogs",value:function(){return this._priorityModal||this._staticModal||this._modals.length>0}},{key:"getOrCreateContainer",value:function(){var e=document.getElementById("mx_Dialog_Container");return e||((e=document.createElement("div")).id="mx_Dialog_Container",document.body.appendChild(e)),e}},{key:"getOrCreateStaticContainer",value:function(){var e=document.getElementById("mx_Dialog_StaticContainer");return e||((e=document.createElement("div")).id="mx_Dialog_StaticContainer",document.body.appendChild(e)),e}},{key:"createTrackedDialog",value:function(e,t){E.a.trackEvent("Modal",e,t);for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o2?n-2:0),o=2;o1?t-1:0),r=1;r1?t-1:0),r=1;r2?n-2:0),o=2;o2?n-2:0),o=2;o=0&&n._modals.splice(s,1),n._priorityModal===e&&(n._priorityModal=null,n._modals=[]),n._staticModal===e&&(n._staticModal=null,n._modals=[]),n._reRender()},r.promise]}},{key:"createDialogAsync",value:function(e,t,n,r,o){var i=this._buildModal(e,t,n),a=i.modal,s=i.closeDialog,c=i.onFinishedProm;return r?this._priorityModal=a:o?this._staticModal=a:this._modals.unshift(a),this._reRender(),{close:s,finished:c}}},{key:"appendDialogAsync",value:function(e,t,n){var r=this._buildModal(e,t,n),o=r.modal,i=r.closeDialog,a=r.onFinishedProm;return this._modals.push(o),this._reRender(),{close:i,finished:a}}},{key:"closeAll",value:function(){var e=[].concat(o()(this._modals),[this._priorityModal]);this._modals=[],this._priorityModal=null,this._staticModal&&0===e.length&&(e.push(this._staticModal),this._staticModal=null);for(var t=0;t2?n-2:0),o=2;o",BACKTICK:"`",SPACE:" ",A:"a",B:"b",C:"c",D:"d",E:"e",F:"f",G:"g",H:"h",I:"i",J:"j",K:"k",L:"l",M:"m",N:"n",O:"o",P:"p",Q:"q",R:"r",S:"s",T:"t",U:"u",V:"v",W:"w",X:"x",Y:"y",Z:"z"};function o(e){return navigator.platform.toUpperCase().indexOf("MAC")>=0?e.metaKey&&!e.altKey&&!e.ctrlKey&&!e.shiftKey:e.ctrlKey&&!e.altKey&&!e.metaKey&&!e.shiftKey}function i(e){return navigator.platform.toUpperCase().indexOf("MAC")>=0?e.metaKey&&!e.altKey&&!e.ctrlKey:e.ctrlKey&&!e.altKey&&!e.metaKey}},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r=n(9),o=n.n(r),i=n(8),a=n.n(i),s=n(5),c=n.n(s),l={integrations_ui_url:"https://scalar.vector.im/",integrations_rest_url:"https://scalar.vector.im/api",bug_report_endpoint_url:null},u=function(){function e(){o()(this,e)}return a()(e,null,[{key:"setInstance",value:function(t){e.instance=t,window.mxReactSdkConfig=t}},{key:"get",value:function(){return e.instance||{}}},{key:"put",value:function(t){for(var n=Object.keys(l),r=0;r0&&void 0!==arguments[0]?arguments[0]:this.props.hasBackground,t={},n=null,r=this.props;r.top?t.top=r.top:t.bottom=r.bottom,r.left?(t.left=r.left,n="left"):(t.right=r.right,n="right");var o=this.state.contextMenuElem?this.state.contextMenuElem.getBoundingClientRect():null,i=10,a={};r.chevronFace&&(n=r.chevronFace);var s,c=n&&"none"!==n;if("top"===n||"bottom"===n)a.left=r.chevronOffset;else{var l=t.top,u=l;o&&(u=Math.min(t.top,document.body.clientHeight-o.height-i)),t.top=u,a.top=Math.max(r.chevronOffset,r.chevronOffset+l-u)}c&&(s=k.a.createElement("div",{style:a,className:"mx_ContextualMenu_chevron_"+n}));var d=O()({mx_ContextualMenu:!0,mx_ContextualMenu_left:!c&&t.left,mx_ContextualMenu_right:!c&&t.right,mx_ContextualMenu_top:!c&&t.top,mx_ContextualMenu_bottom:!c&&t.bottom,mx_ContextualMenu_withChevron_left:"left"===n,mx_ContextualMenu_withChevron_right:"right"===n,mx_ContextualMenu_withChevron_top:"top"===n,mx_ContextualMenu_withChevron_bottom:"bottom"===n}),p={};r.menuWidth&&(p.width=r.menuWidth),r.menuHeight&&(p.height=r.menuHeight),isNaN(Number(r.menuPaddingTop))||(p.paddingTop=r.menuPaddingTop),isNaN(Number(r.menuPaddingLeft))||(p.paddingLeft=r.menuPaddingLeft),isNaN(Number(r.menuPaddingBottom))||(p.paddingBottom=r.menuPaddingBottom),isNaN(Number(r.menuPaddingRight))||(p.paddingRight=r.menuPaddingRight);var h,m={};return isNaN(Number(r.zIndex))||(p.zIndex=r.zIndex+1,m.zIndex=r.zIndex),e&&(h=k.a.createElement("div",{className:"mx_ContextualMenu_background",style:m,onClick:r.onFinished,onContextMenu:this.onContextMenu})),k.a.createElement("div",{className:"mx_ContextualMenu_wrapper",style:M({},t,{},m),onKeyDown:this._onKeyDown},k.a.createElement("div",{className:d,style:p,ref:this.collectContextMenuRect,role:this.props.managed?"menu":void 0},s,r.children),h)}},{key:"render",value:function(){return C.a.createPortal(this.renderMenu(),P())}}]),n}(k.a.Component);S()(U,"propTypes",{top:R.a.number,bottom:R.a.number,left:R.a.number,right:R.a.number,menuWidth:R.a.number,menuHeight:R.a.number,chevronOffset:R.a.number,chevronFace:R.a.string,onFinished:R.a.func.isRequired,menuPaddingTop:R.a.number,menuPaddingRight:R.a.number,menuPaddingBottom:R.a.number,menuPaddingLeft:R.a.number,zIndex:R.a.number,hasBackground:R.a.bool,windowResize:R.a.func,managed:R.a.bool}),S()(U,"defaultProps",{hasBackground:!0,managed:!0});var B=function(e){var t=e.label,n=e.isExpanded,r=e.children,o=c()(e,["label","isExpanded","children"]),i=I.a("elements.AccessibleButton");return k.a.createElement(i,a()({},o,{title:t,"aria-label":t,"aria-haspopup":!0,"aria-expanded":n}),r)};B.propTypes=M({},N.a.propTypes,{label:R.a.string.isRequired,isExpanded:R.a.bool.isRequired});var j=function(e){var t=e.children,n=e.label,r=c()(e,["children","label"]),o=I.a("elements.AccessibleButton");return k.a.createElement(o,a()({},r,{role:"menuitem",tabIndex:-1,"aria-label":n}),t)};j.propTypes=M({},N.a.propTypes,{label:R.a.string,className:R.a.string,onClick:R.a.func.isRequired});M({},N.a.propTypes,{label:R.a.string.isRequired,className:R.a.string});var G=function(e){var t=e.children,n=e.label,r=e.active,o=void 0!==r&&r,i=e.disabled,s=void 0!==i&&i,l=c()(e,["children","label","active","disabled"]),u=I.a("elements.AccessibleButton");return k.a.createElement(u,a()({},l,{role:"menuitemcheckbox","aria-checked":o,"aria-disabled":s,tabIndex:-1,"aria-label":n}),t)};G.propTypes=M({},N.a.propTypes,{label:R.a.string,active:R.a.bool.isRequired,disabled:R.a.bool,className:R.a.string,onClick:R.a.func.isRequired});var q=function(e){var t=e.children,n=e.label,r=e.active,o=void 0!==r&&r,i=e.disabled,s=void 0!==i&&i,l=c()(e,["children","label","active","disabled"]),u=I.a("elements.AccessibleButton");return k.a.createElement(u,a()({},l,{role:"menuitemradio","aria-checked":o,"aria-disabled":s,tabIndex:-1,"aria-label":n}),t)};q.propTypes=M({},N.a.propTypes,{label:R.a.string,active:R.a.bool.isRequired,disabled:R.a.bool,className:R.a.string,onClick:R.a.func.isRequired});var V=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:12,n=e.right+window.pageXOffset+3,r=e.top+e.height/2+window.pageYOffset;return{left:n,top:r-=t+8,chevronOffset:t}},H=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"none",n={chevronFace:t},r=e.right+window.pageXOffset,o=e.bottom+window.pageYOffset,i=e.top+window.pageYOffset;return n.right=window.innerWidth-r,o=3)){e.next=3;break}return e.next=3,new Promise((function(e,t){D.push(e)}));case 3:return R++,e.prev=4,e.next=7,t();case 7:return e.abrupt("return",e.sent);case 10:throw e.prev=10,e.t0=e.catch(4),e.t0;case 13:return e.prev=13,R--,O(),e.finish(13);case 17:case"end":return e.stop()}}),e,null,[[4,10,13,17]])})))).apply(this,arguments)}var N=function(e){function t(){var e,n,r;return a()(this,t),r=u()(this,p()(t).call(this)),v()(m()(r),"STATE_KEY",{GroupMembers:"GroupMembers",GroupInvitedMembers:"GroupInvitedMembers",Summary:"Summary",GroupRooms:"GroupRooms"}),r._state={},r._state[r.STATE_KEY.Summary]={},r._state[r.STATE_KEY.GroupRooms]={},r._state[r.STATE_KEY.GroupMembers]={},r._state[r.STATE_KEY.GroupInvitedMembers]={},r._ready={},r._ready[r.STATE_KEY.Summary]={},r._ready[r.STATE_KEY.GroupRooms]={},r._ready[r.STATE_KEY.GroupMembers]={},r._ready[r.STATE_KEY.GroupInvitedMembers]={},r._fetchResourcePromise=(e={},v()(e,r.STATE_KEY.Summary,{}),v()(e,r.STATE_KEY.GroupRooms,{}),v()(e,r.STATE_KEY.GroupMembers,{}),v()(e,r.STATE_KEY.GroupInvitedMembers,{}),e),r._resourceFetcher=(n={},v()(n,r.STATE_KEY.Summary,(function(e){return F((function(){return x.a.get().getGroupSummary(e)}))})),v()(n,r.STATE_KEY.GroupRooms,(function(e){return F((function(){return x.a.get().getGroupRooms(e).then(T)}))})),v()(n,r.STATE_KEY.GroupMembers,(function(e){return F((function(){return x.a.get().getGroupUsers(e).then(C)}))})),v()(n,r.STATE_KEY.GroupInvitedMembers,(function(e){return F((function(){return x.a.get().getGroupInvitedUsers(e).then(C)}))})),n),r}return f()(t,e),c()(t,[{key:"_fetchResource",value:function(e,t){var n=this;if(!this._fetchResourcePromise[e][t]){var r=this._resourceFetcher[e](t);return this._fetchResourcePromise[e][t]=r,r.then((function(r){n._state[e][t]=r,n._ready[e][t]=!0,n._notifyListeners()})).catch((function(r){e===n.STATE_KEY.GroupInvitedMembers&&403===r.httpStatus||(console.error("Failed to get resource ".concat(e," for ").concat(t),r),n.emit("error",r,t,e))})).finally((function(){delete n._fetchResourcePromise[e][t]})),r}}},{key:"_notifyListeners",value:function(){this.emit("update")}},{key:"registerListener",value:function(e,t){var n=this;return this.on("update",t),this.emit("update"),e&&(this._fetchResource(this.STATE_KEY.Summary,e),this._fetchResource(this.STATE_KEY.GroupRooms,e),this._fetchResource(this.STATE_KEY.GroupMembers,e),this._fetchResource(this.STATE_KEY.GroupInvitedMembers,e)),{unregister:function(){n.unregisterListener(t)}}}},{key:"unregisterListener",value:function(e){this.removeListener("update",e)}},{key:"isStateReady",value:function(e,t){return this._ready[t][e]}},{key:"getGroupIdsForRoomId",value:function(e){var t=this;return Object.keys(this._state[this.STATE_KEY.GroupRooms]).filter((function(n){return(t._state[t.STATE_KEY.GroupRooms][n]||[]).some((function(t){return t.roomId===e}))}))}},{key:"getSummary",value:function(e){return this._state[this.STATE_KEY.Summary][e]||{}}},{key:"getGroupRooms",value:function(e){return this._state[this.STATE_KEY.GroupRooms][e]||[]}},{key:"getGroupMembers",value:function(e){return this._state[this.STATE_KEY.GroupMembers][e]||[]}},{key:"getGroupInvitedMembers",value:function(e){return this._state[this.STATE_KEY.GroupInvitedMembers][e]||[]}},{key:"getGroupPublicity",value:function(e){return(this._state[this.STATE_KEY.Summary][e]||{}).user?(this._state[this.STATE_KEY.Summary][e]||{}).user.is_publicised:null}},{key:"isUserPrivileged",value:function(e){return(this._state[this.STATE_KEY.Summary][e]||{}).user?(this._state[this.STATE_KEY.Summary][e]||{}).user.is_privileged:null}},{key:"refreshGroupRooms",value:function(e){return this._fetchResource(this.STATE_KEY.GroupRooms,e)}},{key:"refreshGroupMembers",value:function(e){return this._fetchResource(this.STATE_KEY.GroupMembers,e)}},{key:"addRoomToGroup",value:function(e,t,n){return x.a.get().addRoomToGroup(e,t,n).then(this._fetchResource.bind(this,this.STATE_KEY.GroupRooms,e))}},{key:"updateGroupRoomVisibility",value:function(e,t,n){return x.a.get().updateGroupRoomVisibility(e,t,n).then(this._fetchResource.bind(this,this.STATE_KEY.GroupRooms,e))}},{key:"removeRoomFromGroup",value:function(e,t){return x.a.get().removeRoomFromGroup(e,t).then(this._fetchResource.bind(this,this.STATE_KEY.Summary,e)).then(this._fetchResource.bind(this,this.STATE_KEY.GroupRooms,e))}},{key:"inviteUserToGroup",value:function(e,t){return x.a.get().inviteUserToGroup(e,t).then(this._fetchResource.bind(this,this.STATE_KEY.GroupInvitedMembers,e))}},{key:"acceptGroupInvite",value:function(e){return x.a.get().acceptGroupInvite(e).then(this._fetchResource.bind(this,this.STATE_KEY.Summary,e)).then(this._fetchResource.bind(this,this.STATE_KEY.GroupRooms,e)).then(this._fetchResource.bind(this,this.STATE_KEY.GroupMembers,e)).then(this._fetchResource.bind(this,this.STATE_KEY.GroupInvitedMembers,e))}},{key:"joinGroup",value:function(e){return x.a.get().joinGroup(e).then(this._fetchResource.bind(this,this.STATE_KEY.Summary,e)).then(this._fetchResource.bind(this,this.STATE_KEY.GroupRooms,e)).then(this._fetchResource.bind(this,this.STATE_KEY.GroupMembers,e)).then(this._fetchResource.bind(this,this.STATE_KEY.GroupInvitedMembers,e))}},{key:"leaveGroup",value:function(e){return x.a.get().leaveGroup(e).then(this._fetchResource.bind(this,this.STATE_KEY.Summary,e)).then(this._fetchResource.bind(this,this.STATE_KEY.GroupRooms,e)).then(this._fetchResource.bind(this,this.STATE_KEY.GroupMembers,e))}},{key:"addRoomToGroupSummary",value:function(e,t,n){return x.a.get().addRoomToGroupSummary(e,t,n).then(this._fetchResource.bind(this,this.STATE_KEY.Summary,e))}},{key:"addUserToGroupSummary",value:function(e,t,n){return x.a.get().addUserToGroupSummary(e,t,n).then(this._fetchResource.bind(this,this.STATE_KEY.Summary,e))}},{key:"removeRoomFromGroupSummary",value:function(e,t){return x.a.get().removeRoomFromGroupSummary(e,t).then(this._fetchResource.bind(this,this.STATE_KEY.Summary,e))}},{key:"removeUserFromGroupSummary",value:function(e,t){return x.a.get().removeUserFromGroupSummary(e,t).then(this._fetchResource.bind(this,this.STATE_KEY.Summary,e))}},{key:"setGroupPublicity",value:function(e,t){return x.a.get().setGroupPublicity(e,t).then((function(){k.a.invalidatePublicisedGroups(x.a.get().credentials.userId)})).then(this._fetchResource.bind(this,this.STATE_KEY.Summary,e))}}]),t}(S.a),A=null;A||(A=new N),t.a=A},function(e,t,n){"use strict";var r=n(0),o=Object(r.createContext)(void 0);o.displayName="MatrixClientContext",t.a=o},function(e,t){function n(){return e.exports=n=Object.assign||function(e){for(var t=1;t",'"',"`"," ","\r","\n","\t"]),u=["'"].concat(l),d=["%","/","?",";","#"].concat(u),p=["/","?","#"],h=/^[+a-z0-9A-Z_-]{0,63}$/,m=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,g={javascript:!0,"javascript:":!0},f={javascript:!0,"javascript:":!0},_={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=n(282);function b(e,t,n){if(e&&o.isObject(e)&&e instanceof i)return e;var r=new i;return r.parse(e,t,n),r}i.prototype.parse=function(e,t,n){if(!o.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var i=e.indexOf("?"),s=-1!==i&&i127?N+="x":N+=I[A];if(!N.match(h)){var P=O.slice(0,T),L=O.slice(T+1),U=I.match(m);U&&(P.push(U[1]),L.unshift(U[2])),L.length&&(b="/"+L.join(".")+b),this.hostname=P.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),D||(this.hostname=r.toASCII(this.hostname));var B=this.port?":"+this.port:"",j=this.hostname||"";this.host=j+B,this.href+=this.host,D&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==b[0]&&(b="/"+b))}if(!g[S])for(T=0,F=u.length;T0)&&n.host.split("@"))&&(n.auth=D.shift(),n.host=n.hostname=D.shift());return n.search=e.search,n.query=e.query,o.isNull(n.pathname)&&o.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n}if(!w.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var x=w.slice(-1)[0],C=(n.host||e.host||w.length>1)&&("."===x||".."===x)||""===x,T=0,R=w.length;R>=0;R--)"."===(x=w[R])?w.splice(R,1):".."===x?(w.splice(R,1),T++):T&&(w.splice(R,1),T--);if(!E&&!S)for(;T--;T)w.unshift("..");!E||""===w[0]||w[0]&&"/"===w[0].charAt(0)||w.unshift(""),C&&"/"!==w.join("/").substr(-1)&&w.push("");var D,O=""===w[0]||w[0]&&"/"===w[0].charAt(0);k&&(n.hostname=n.host=O?"":w.length?w.shift():"",(D=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=D.shift(),n.host=n.hostname=D.shift()));return(E=E||n.host&&w.length)&&!O&&w.unshift(""),w.length?n.pathname=w.join("/"):(n.pathname=null,n.path=null),o.isNull(n.pathname)&&o.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},i.prototype.parseHost=function(){var e=this.host,t=s.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},function(e,t,n){"use strict";var r=n(6),o=n.n(r),i=n(16),a=n.n(i),s=n(9),c=n.n(s),l=n(8),u=n.n(l),d=n(13),p=n.n(d),h=n(12),m=n.n(h),g=n(14),f=n.n(g),_=n(10),v=n(120),b=n(4),y=n(3),E=n(18),S=n(1),w=n(251),k={joining:!1,joinError:null,roomId:null,initialEventId:null,isInitialEventHighlighted:!1,roomAlias:null,roomLoading:!1,roomLoadError:null,forwardingEvent:null,quotingEvent:null},x=function(e){function t(){var e;return c()(this,t),(e=p()(this,m()(t).call(this,_.a)))._state=k,e}var n;return f()(t,e),u()(t,[{key:"_setState",value:function(e){this._state=Object.assign(this._state,e),this.__emitChange()}},{key:"__onDispatch",value:function(e){switch(e.action){case"view_room":this._viewRoom(e);break;case"view_my_groups":case"view_group":this._setState({roomId:null,roomAlias:null});break;case"view_room_error":this._viewRoomError(e);break;case"will_join":this._setState({joining:!0});break;case"cancel_join":this._setState({joining:!1});break;case"join_room":this._joinRoom(e);break;case"join_room_error":this._joinRoomError(e);break;case"on_client_not_viable":case"on_logged_out":this.reset();break;case"forward_event":this._setState({forwardingEvent:e.event});break;case"reply_to_event":e.event&&e.event.getRoomId()!==this._state.roomId?_.a.dispatch({action:"view_room",room_id:e.event.getRoomId(),replyingToEvent:e.event}):this._setState({replyingToEvent:e.event});break;case"open_room_settings":var t=y.a("dialogs.RoomSettingsDialog");E.a.createTrackedDialog("Room settings","",t,{roomId:e.room_id||this._state.roomId},null,!1,!0)}}},{key:"_viewRoom",value:(n=a()(o.a.mark((function e(t){var n,r,i;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.room_id){e.next=8;break}n={roomId:t.room_id,roomAlias:t.room_alias,initialEventId:t.event_id,isInitialEventHighlighted:t.highlighted,forwardingEvent:null,roomLoading:!1,roomLoadError:null,shouldPeek:void 0===t.should_peek||t.should_peek,joining:t.joining||!1,replyingToEvent:null,isEditingSettings:!1},t.replyingToEvent&&t.replyingToEvent.getRoomId()===t.room_id&&(n.replyingToEvent=t.replyingToEvent),this._state.forwardingEvent&&_.a.dispatch({action:"send_event",room_id:n.roomId,event:this._state.forwardingEvent}),this._setState(n),t.auto_join&&this._joinRoom(t),e.next=25;break;case 8:if(!t.room_alias){e.next=25;break}if(r=Object(w.a)(t.room_alias)){e.next=24;break}return this._setState({roomId:null,initialEventId:null,initialEventPixelOffset:null,isInitialEventHighlighted:null,roomAlias:t.room_alias,roomLoading:!0,roomLoadError:null}),e.prev=12,e.next=15,b.a.get().getRoomIdForAlias(t.room_alias);case 15:i=e.sent,Object(w.b)(t.room_alias,i.room_id),r=i.room_id,e.next=24;break;case 20:return e.prev=20,e.t0=e.catch(12),_.a.dispatch({action:"view_room_error",room_id:null,room_alias:t.room_alias,err:e.t0}),e.abrupt("return");case 24:_.a.dispatch({action:"view_room",room_id:r,event_id:t.event_id,highlighted:t.highlighted,room_alias:t.room_alias,auto_join:t.auto_join,oob_data:t.oob_data});case 25:case"end":return e.stop()}}),e,this,[[12,20]])}))),function(e){return n.apply(this,arguments)})},{key:"_viewRoomError",value:function(e){this._setState({roomId:e.room_id,roomAlias:e.room_alias,roomLoading:!1,roomLoadError:e.err})}},{key:"_joinRoom",value:function(e){this._setState({joining:!0}),b.a.get().joinRoom(this._state.roomAlias||this._state.roomId,e.opts).then((function(){}),(function(e){_.a.dispatch({action:"join_room_error",err:e});var t=e.message?e.message:JSON.stringify(e);t&&t.startsWith("CORS request rejected")&&(t=Object(S.a)("There was an error joining the room")),"M_INCOMPATIBLE_ROOM_VERSION"===e.errcode&&(t=React.createElement("div",null,Object(S.a)("Sorry, your homeserver is too old to participate in this room."),React.createElement("br",null),Object(S.a)("Please contact your homeserver administrator.")));var n=y.a("dialogs.ErrorDialog");E.a.createTrackedDialog("Failed to join room","",n,{title:Object(S.a)("Failed to join room"),description:t})}))}},{key:"_joinRoomError",value:function(e){this._setState({joining:!1,joinError:e.err})}},{key:"reset",value:function(){this._state=Object.assign({},k)}},{key:"getRoomId",value:function(){return this._state.roomId}},{key:"getInitialEventId",value:function(){return this._state.initialEventId}},{key:"isInitialEventHighlighted",value:function(){return this._state.isInitialEventHighlighted}},{key:"getRoomAlias",value:function(){return this._state.roomAlias}},{key:"isRoomLoading",value:function(){return this._state.roomLoading}},{key:"getRoomLoadError",value:function(){return this._state.roomLoadError}},{key:"isJoining",value:function(){return this._state.joining}},{key:"getJoinError",value:function(){return this._state.joinError}},{key:"getForwardingEvent",value:function(){return this._state.forwardingEvent}},{key:"getQuotingEvent",value:function(){return this._state.replyingToEvent}},{key:"shouldPeek",value:function(){return this._state.shouldPeek}}]),t}(v.Store),C=null;C||(C=new x),t.a=C},function(e,t,n){"use strict";n.d(t,"a",(function(){return u})),n.d(t,"b",(function(){return g}));var r=n(11),o=n.n(r),i=n(21),a=n.n(i),s=n(45),c=n(20),l=n(17),u={NOT_SENT:"not_sent",ENCRYPTING:"encrypting",SENDING:"sending",QUEUED:"queued",SENT:"sent",CANCELLED:"cancelled"},d={};function p(e){return d[e]||(d[e]=e),d[e]}var h,m,g=function(e){["state_key","type","sender","room_id","membership"].forEach((function(t){e[t]&&(e[t]=p(e[t]))})),["membership","avatar_url","displayname"].forEach((function(t){e.content&&e.content[t]&&(e.content[t]=p(e.content[t]))})),["rel_type"].forEach((function(t){e.content&&e.content["m.relates_to"]&&e.content["m.relates_to"][t]&&(e.content["m.relates_to"][t]=p(e.content["m.relates_to"][t]))})),this.event=e||{},this.sender=null,this.target=null,this.status=null,this.error=null,this.forwardLooking=!0,this._pushActions=null,this._replacingEvent=null,this._localRedactionEvent=null,this._isCancelled=!1,this._clearEvent={},this._senderCurve25519Key=null,this._claimedEd25519Key=null,this._forwardingCurve25519KeyChain=[],this._decryptionPromise=null,this._retryDecryption=!1};c.n(g,s.EventEmitter),c.i(g.prototype,{getId:function(){return this.event.event_id},getSender:function(){return this.event.sender||this.event.user_id},getType:function(){return this._clearEvent.type||this.event.type},getWireType:function(){return this.event.type},getRoomId:function(){return this.event.room_id},getTs:function(){return this.event.origin_server_ts},getDate:function(){return this.event.origin_server_ts?new Date(this.event.origin_server_ts):null},getOriginalContent:function(){return this._localRedactionEvent?{}:this._clearEvent.content||this.event.content||{}},getContent:function(){return this._localRedactionEvent?{}:this._replacingEvent?this._replacingEvent.getContent()["m.new_content"]||{}:this.getOriginalContent()},getWireContent:function(){return this.event.content||{}},getPrevContent:function(){return this.getUnsigned().prev_content||this.event.prev_content||{}},getDirectionalContent:function(){return this.forwardLooking?this.getContent():this.getPrevContent()},getAge:function(){return this.getUnsigned().age||this.event.age},getLocalAge:function(){return Date.now()-this.getTs()},getStateKey:function(){return this.event.state_key},isState:function(){return void 0!==this.event.state_key},makeEncrypted:function(e,t,n,r){this._clearEvent={type:this.event.type,content:this.event.content},this.event.type=e,this.event.content=t,this._senderCurve25519Key=n,this._claimedEd25519Key=r},isBeingDecrypted:function(){return null!=this._decryptionPromise},isDecryptionFailure:function(){return this._clearEvent&&this._clearEvent.content&&"m.bad.encrypted"===this._clearEvent.content.msgtype},attemptDecryption:(m=a()(o.a.mark((function e(t){return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isEncrypted()){e.next=2;break}throw new Error("Attempt to decrypt event which isn't encrypted");case 2:if(!this._clearEvent||!this._clearEvent.content||"m.bad.encrypted"===this._clearEvent.content.msgtype){e.next=4;break}throw new Error("Attempt to decrypt event which has already been encrypted");case 4:if(!this._decryptionPromise){e.next=8;break}return l.a.log("Event ".concat(this.getId()," already being decrypted; queueing a retry")),this._retryDecryption=!0,e.abrupt("return",this._decryptionPromise);case 8:return this._decryptionPromise=this._decryptionLoop(t),e.abrupt("return",this._decryptionPromise);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)}),cancelAndResendKeyRequest:function(e,t){var n=this.getWireContent();return e.requestRoomKey({algorithm:n.algorithm,room_id:this.getRoomId(),session_id:n.session_id,sender_key:n.sender_key},this.getKeyRequestRecipients(t),!0)},getKeyRequestRecipients:function(e){var t=this.getWireContent(),n=[{userId:e,deviceId:"*"}],r=this.getSender();return r!==e&&n.push({userId:r,deviceId:t.device_id}),n},_decryptionLoop:(h=a()(o.a.mark((function e(t){var n,r;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Promise.resolve();case 2:if(this._retryDecryption=!1,n=void 0,r=void 0,e.prev=6,t){e.next=11;break}n=this._badEncryptedMessage("Encryption not enabled"),e.next=14;break;case 11:return e.next=13,t.decryptEvent(this);case 13:n=e.sent;case 14:e.next=29;break;case 16:if(e.prev=16,e.t0=e.catch(6),"DecryptionError"===e.t0.name){e.next=23;break}return l.a.error("Error decrypting event (id=".concat(this.getId(),"): ").concat(e.t0.stack||e.t0)),this._decryptionPromise=null,this._retryDecryption=!1,e.abrupt("return");case 23:if(r=e.t0,!this._retryDecryption){e.next=27;break}return l.a.log("Got error decrypting event (id=".concat(this.getId(),": ")+"".concat(e.t0,"), but retrying")),e.abrupt("continue",2);case 27:l.a.warn("Error decrypting event (id=".concat(this.getId(),"): ").concat(e.t0.detailedString)),n=this._badEncryptedMessage(e.t0.message);case 29:return this._decryptionPromise=null,this._retryDecryption=!1,this._setClearData(n),this.setPushActions(null),this.emit("Event.decrypted",this,r),e.abrupt("return");case 37:case"end":return e.stop()}}),e,this,[[6,16]])}))),function(e){return h.apply(this,arguments)}),_badEncryptedMessage:function(e){return{clearEvent:{type:"m.room.message",content:{msgtype:"m.bad.encrypted",body:"** Unable to decrypt: "+e+" **"}}}},_setClearData:function(e){this._clearEvent=e.clearEvent,this._senderCurve25519Key=e.senderCurve25519Key||null,this._claimedEd25519Key=e.claimedEd25519Key||null,this._forwardingCurve25519KeyChain=e.forwardingCurve25519KeyChain||[]},getClearContent:function(){var e=this._clearEvent;return e&&e.content?e.content:null},isEncrypted:function(){return"m.room.encrypted"===this.event.type},getSenderKey:function(){return this._senderCurve25519Key},getKeysClaimed:function(){return{ed25519:this._claimedEd25519Key}},getClaimedEd25519Key:function(){return this._claimedEd25519Key},getForwardingCurve25519KeyChain:function(){return this._forwardingCurve25519KeyChain},getUnsigned:function(){return this.event.unsigned||{}},unmarkLocallyRedacted:function(){var e=this._localRedactionEvent;return this._localRedactionEvent=null,this.event.unsigned&&(this.event.unsigned.redacted_because=null),!!e},markLocallyRedacted:function(e){this._localRedactionEvent||(this.emit("Event.beforeRedaction",this,e),this._localRedactionEvent=e,this.event.unsigned||(this.event.unsigned={}),this.event.unsigned.redacted_because=e.event)},makeRedacted:function(e){if(!e.event)throw new Error("invalid redaction_event in makeRedacted");var t;for(t in this._localRedactionEvent=null,this.emit("Event.beforeRedaction",this,e),this._replacingEvent=null,this.event.unsigned||(this.event.unsigned={}),this.event.unsigned.redacted_because=e.event,this.event)this.event.hasOwnProperty(t)&&(f[t]||delete this.event[t]);var n=_[this.getType()]||{},r=this.getContent();for(t in r)r.hasOwnProperty(t)&&(n[t]||delete r[t])},isRedacted:function(){return Boolean(this.getUnsigned().redacted_because)},isRedaction:function(){return"m.room.redaction"===this.getType()},getPushActions:function(){return this._pushActions},setPushActions:function(e){this._pushActions=e},handleRemoteEcho:function(e){var t=this.getUnsigned(),n=this.getId();this.event=e,t.redacted_because&&(this.event.unsigned||(this.event.unsigned={}),this.event.unsigned.redacted_because=t.redacted_because),this.setStatus(null),this.getId()!==n&&this.emit("Event.localEventIdReplaced",this)},isSending:function(){return!!this.status},setStatus:function(e){this.status=e,this.emit("Event.status",this,e)},replaceLocalEventId:function(e){this.event.event_id=e,this.emit("Event.localEventIdReplaced",this)},isRelation:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,t=this.getWireContent(),n=t&&t["m.relates_to"];return n&&n.rel_type&&n.event_id&&(e&&n.rel_type===e||!e)},getRelation:function(){return this.isRelation()?this.getWireContent()["m.relates_to"]:null},makeReplaced:function(e){this.isRedacted()&&e||this._replacingEvent!==e&&(this._replacingEvent=e,this.emit("Event.replaced",this))},getAssociatedStatus:function(){return this._replacingEvent?this._replacingEvent.status:this._localRedactionEvent?this._localRedactionEvent.status:this.status},getServerAggregatedRelation:function(e){var t=this.getUnsigned()["m.relations"];if(t)return t[e]},replacingEventId:function(){var e=this.getServerAggregatedRelation("m.replace");return e?e.event_id:this._replacingEvent?this._replacingEvent.getId():void 0},replacingEvent:function(){return this._replacingEvent},replacingEventDate:function(){var e=this.getServerAggregatedRelation("m.replace");if(e){var t=e.origin_server_ts;if(Number.isFinite(t))return new Date(t)}else if(this._replacingEvent)return this._replacingEvent.getDate()},localRedactionEvent:function(){return this._localRedactionEvent},getAssociatedId:function(){var e=this.getRelation();return e?e.event_id:this.isRedaction()?this.event.redacts:void 0},hasAssocation:function(){return!!this.getAssociatedId()},updateAssociatedId:function(e){var t=this.getRelation();t?t.event_id=e:this.isRedaction()&&(this.event.redacts=e)},flagCancelled:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this._isCancelled=e},isCancelled:function(){return this._isCancelled},toJSON:function(){var e={type:this.getType(),sender:this.getSender(),content:this.getContent(),event_id:this.getId(),origin_server_ts:this.getTs(),unsigned:this.getUnsigned(),room_id:this.getRoomId()};return this.isRedaction()&&(e.redacts=this.event.redacts),this.isEncrypted()?{decrypted:e,encrypted:this.event}:e}});var f=["event_id","type","room_id","user_id","sender","state_key","prev_state","content","unsigned","origin_server_ts"].reduce((function(e,t){return e[t]=1,e}),{}),_={"m.room.member":{membership:1},"m.room.create":{creator:1},"m.room.join_rules":{join_rule:1},"m.room.power_levels":{ban:1,events:1,events_default:1,kick:1,redact:1,state_default:1,users:1,users_default:1},"m.room.aliases":{aliases:1}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(241);function o(e){this._eventTimelineSet=e,this._roomId=e.room?e.room.roomId:null,this._events=[],this._baseIndex=0,this._startState=new r.a(this._roomId),this._startState.paginationToken=null,this._endState=new r.a(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()}o.BACKWARDS="b",o.FORWARDS="f",o.prototype.initialiseState=function(e){if(this._events.length>0)throw new Error("Cannot initialise state after events are added");var t=!0,n=!1,r=void 0;try{for(var o,i=e[Symbol.iterator]();!(t=(o=i.next()).done);t=!0){var a=o.value;Object.freeze(a)}}catch(e){n=!0,r=e}finally{try{t||null==i.return||i.return()}finally{if(n)throw r}}this._startState.setStateEvents(e),this._endState.setStateEvents(e)},o.prototype.forkLive=function(e){var t=this.getState(e),n=new o(this._eventTimelineSet);return n._startState=t.clone(),n._endState=t,this._endState=t.clone(),n},o.prototype.fork=function(e){var t=this.getState(e),n=new o(this._eventTimelineSet);return n._startState=t.clone(),n._endState=t.clone(),n},o.prototype.getRoomId=function(){return this._roomId},o.prototype.getFilter=function(){return this._eventTimelineSet.getFilter()},o.prototype.getTimelineSet=function(){return this._eventTimelineSet},o.prototype.getBaseIndex=function(){return this._baseIndex},o.prototype.getEvents=function(){return this._events},o.prototype.getState=function(e){if(e==o.BACKWARDS)return this._startState;if(e==o.FORWARDS)return this._endState;throw new Error("Invalid direction '"+e+"'")},o.prototype.getPaginationToken=function(e){return this.getState(e).paginationToken},o.prototype.setPaginationToken=function(e,t){this.getState(t).paginationToken=e},o.prototype.getNeighbouringTimeline=function(e){if(e==o.BACKWARDS)return this._prevTimeline;if(e==o.FORWARDS)return this._nextTimeline;throw new Error("Invalid direction '"+e+"'")},o.prototype.setNeighbouringTimeline=function(e,t){if(this.getNeighbouringTimeline(t))throw new Error("timeline already has a neighbouring timeline - cannot reset neighbour (direction: "+t+")");if(t==o.BACKWARDS)this._prevTimeline=e;else{if(t!=o.FORWARDS)throw new Error("Invalid direction '"+t+"'");this._nextTimeline=e}this.setPaginationToken(null,t)},o.prototype.addEvent=function(e,t){var n,r=t?this._startState:this._endState,i=this.getTimelineSet();i.room&&i.room.getUnfilteredTimelineSet()===i&&(o.setEventMetadata(e,r,t),e.isState()&&(r.setStateEvents([e]),e.sender&&("m.room.member"!==e.getType()||t)||o.setEventMetadata(e,r,t))),n=t?0:this._events.length,this._events.splice(n,0,e),t&&this._baseIndex++},o.setEventMetadata=function(e,t,n){e.sender=t.getSentinelMember(e.getSender()),"m.room.member"===e.getType()&&(e.target=t.getSentinelMember(e.getStateKey())),e.isState()&&n&&(e.forwardLooking=!1)},o.prototype.removeEvent=function(e){for(var t=this._events.length-1;t>=0;t--){var n=this._events[t];if(n.getId()==e)return this._events.splice(t,1),t0&&a.length>o&&!a.warned){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=a.length,s=c,console&&console.warn&&console.warn(s)}return e}function p(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=p.bind(r);return o.listener=n,r.wrapFn=o,o}function m(e,t,n){var r=e._events;if(void 0===r)return[];var o=r[t];return void 0===o?[]:"function"==typeof o?n?[o.listener||o]:[o]:n?function(e){for(var t=new Array(e.length),n=0;n0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var c=o[e];if(void 0===c)return!1;if("function"==typeof c)i(c,this,t);else{var l=c.length,u=f(c,l);for(n=0;n=0;i--)if(n[i]===t||n[i].listener===t){a=n[i].listener,o=i;break}if(o<0)return this;0===o?n.shift():function(e,t){for(;t+1=0;r--)this.removeListener(e,t[r]);return this},s.prototype.listeners=function(e){return m(this,e,!0)},s.prototype.rawListeners=function(e){return m(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):g.call(e,t)},s.prototype.listenerCount=g,s.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},function(e,t,n){"use strict";var r=n(27),o=n.n(r),i=n(9),a=n.n(i),s=n(8),c=n.n(s),l=n(4),u=n(776),d=n.n(u),p=n(20),h=n(181),m=n(118),g=n(13),f=n.n(g),_=n(12),v=n.n(_),b=n(7),y=n.n(b),E=n(14),S=n.n(E),w=n(5),k=n.n(w),x=function(e){function t(e){var n;if(a()(this,t),n=f()(this,v()(t).call(this)),k()(y()(n),"_riotUrl",void 0),n._riotUrl=e,!n._riotUrl.startsWith("http:")&&!n._riotUrl.startsWith("https:"))throw new Error("Riot prefix URL does not appear to be an HTTP(S) URL");return n}return S()(t,e),c()(t,[{key:"forEvent",value:function(e,t,n){return"".concat(this._riotUrl,"/#/room/").concat(e,"/").concat(t).concat(this.encodeServerCandidates(n))}},{key:"forRoom",value:function(e,t){return"".concat(this._riotUrl,"/#/room/").concat(e).concat(this.encodeServerCandidates(t))}},{key:"forUser",value:function(e){return"".concat(this._riotUrl,"/#/user/").concat(e)}},{key:"forGroup",value:function(e){return"".concat(this._riotUrl,"/#/group/").concat(e)}},{key:"forEntity",value:function(e){if("!"===e[0]||"#"===e[0])return this.forRoom(e);if("@"===e[0])return this.forUser(e);if("+"===e[0])return this.forGroup(e);throw new Error("Unrecognized entity")}},{key:"isPermalinkHost",value:function(e){var t=new URL(this._riotUrl);return e===(t.host||t.hostname)}},{key:"encodeServerCandidates",value:function(e){return e&&0!==e.length?"?via=".concat(e.map((function(e){return encodeURIComponent(e)})).join("&via=")):""}},{key:"parsePermalink",value:function(e){if(!e||!e.startsWith(this._riotUrl))throw new Error("Does not appear to be a permalink");var t=e.substring("".concat(this._riotUrl,"/#/").length).split("/");if(t.length<2)throw new Error("URL is missing parts");var n=t[0],r=t[1];if("user"===n)return m.a.forUser(r);if("group"===n)return m.a.forGroup(r);if("room"===n){if(2===t.length)return m.a.forRoom(r,[]);var o=(t.length>2?t.slice(2).join("/"):"").split("?"),i=o[0],a=(o.length>1?o[1]:"").split("via=").filter((function(e){return!!e}));return m.a.forEvent(r,i,a)}throw new Error("Unknown entity type in permalink")}}]),t}(m.b),C=n(128),T=n(26);n.d(t,"a",(function(){return R})),n.d(t,"d",(function(){return D})),n.d(t,"g",(function(){return O})),n.d(t,"f",(function(){return F})),n.d(t,"e",(function(){return I})),n.d(t,"c",(function(){return N})),n.d(t,"i",(function(){return A})),n.d(t,"b",(function(){return M})),n.d(t,"h",(function(){return L}));var R=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(a()(this,e),this._room=t,this._roomId=t?t.roomId:n,this._highestPlUserId=null,this._populationMap=null,this._bannedHostsRegexps=null,this._allowedHostsRegexps=null,this._serverCandidates=null,this._started=!1,!this._roomId)throw new Error("Failed to resolve a roomId for the permalink creator to use");this.onMembership=this.onMembership.bind(this),this.onRoomState=this.onRoomState.bind(this)}return c()(e,[{key:"load",value:function(){this._room&&this._room.currentState?(this._updateAllowedServers(),this._updateHighestPlUser(),this._updatePopulationMap(),this._updateServerCandidates()):console.warn("Tried to load a permalink creator with no room state")}},{key:"start",value:function(){this.load(),this._room.on("RoomMember.membership",this.onMembership),this._room.on("RoomState.events",this.onRoomState),this._started=!0}},{key:"stop",value:function(){this._room.removeListener("RoomMember.membership",this.onMembership),this._room.removeListener("RoomState.events",this.onRoomState),this._started=!1}},{key:"isStarted",value:function(){return this._started}},{key:"forEvent",value:function(e){return P().forEvent(this._roomId,e,this._serverCandidates)}},{key:"forRoom",value:function(){return P().forRoom(this._roomId,this._serverCandidates)}},{key:"onRoomState",value:function(e){switch(e.getType()){case"m.room.server_acl":return this._updateAllowedServers(),this._updateHighestPlUser(),this._updatePopulationMap(),void this._updateServerCandidates();case"m.room.power_levels":return this._updateHighestPlUser(),void this._updateServerCandidates()}}},{key:"onMembership",value:function(e,t,n){var r=t.userId,o=t.membership,i=U(r),a="join"!==n&&"join"===o;"join"===n&&"join"!==o?this._populationMap[i]--:a&&this._populationMap[i]++,this._updateHighestPlUser(),this._updateServerCandidates()}},{key:"_updateHighestPlUser",value:function(){var e=this,t=this._room.currentState.getStateEvents("m.room.power_levels","");if(t){var n=t.getContent();if(n){var r=n.users;if(r){var i=Object.entries(r).filter((function(t){var n=o()(t,1)[0],r=e._room.getMember(n);if(!r||"join"!==r.membership)return!1;var i=U(n);return!G(i)&&!j(i,e._bannedHostsRegexps)&&j(i,e._allowedHostsRegexps)})).reduce((function(e,t){return t[1]>e[1]?t:e}),[null,0]),a=o()(i,2),s=a[0],c=a[1];if(null!==s&&c>=50)return void(this._highestPlUserId=s)}}}this._highestPlUserId=null}},{key:"_updateAllowedServers",value:function(){var e=[],t=[new RegExp(".*")];if(this._room.currentState){var n=this._room.currentState.getStateEvents("m.room.server_acl","");if(n&&n.getContent()){var r=function(e){return new RegExp("^"+p.m(e,!1)+"$")};(n.getContent().deny||[]).forEach((function(t){return e.push(r(t))}));var o=n.getContent().allow||[];t=[],o.forEach((function(e){return t.push(r(e))}))}}this._bannedHostsRegexps=e,this._allowedHostsRegexps=t}},{key:"_updatePopulationMap",value:function(){var e={},t=!0,n=!1,r=void 0;try{for(var o,i=this._room.getJoinedMembers()[Symbol.iterator]();!(t=(o=i.next()).done);t=!0){var a=U(o.value.userId);e[a]||(e[a]=0),e[a]++}}catch(e){n=!0,r=e}finally{try{t||null==i.return||i.return()}finally{if(n)throw r}}this._populationMap=e}},{key:"_updateServerCandidates",value:function(){var e=this,t=[];this._highestPlUserId&&t.push(U(this._highestPlUserId));var n=Object.keys(this._populationMap).sort((function(t,n){return e._populationMap[n]-e._populationMap[t]})).filter((function(n){return!t.includes(n)&&!G(n)&&!j(n,e._bannedHostsRegexps)&&j(n,e._allowedHostsRegexps)})).slice(0,3-t.length);t=t.concat(n),this._serverCandidates=t}}]),e}();function D(e){return P().forEntity(e)}function O(e){return P().forUser(e)}function F(e){if(!e)throw new Error("can't permalink a falsey roomId");if("!"!==e[0])return P().forRoom(e,[]);var t=l.a.get().getRoom(e);if(!t)return P().forRoom(e,[]);var n=new R(t);return n.load(),n.forRoom()}function I(e){return P().forGroup(e)}function N(e){return!!(new h.b).isPermalinkHost(e)||P().isPermalinkHost(e)}function A(e){if(!e.startsWith("http:")&&!e.startsWith("https:"))return e;var t=e.match(C.a.VECTOR_URL_PATTERN);if(t)return t[1];try{var n=L(e);if(n)if(n.roomIdOrAlias){var r=n.eventId?"/".concat(n.eventId):"";e="#/room/".concat(n.roomIdOrAlias).concat(r)}else n.groupId?e="#/group/".concat(n.groupId):n.userId&&(e="#/user/".concat(n.userId))}catch(e){}return e}function M(e){try{var t=L(e);if(!t){var n=e.match(C.a.VECTOR_URL_PATTERN);if(n){var r=new x("http://localhost"),o=n[1].split("#").slice(1).join("#");t=r.parsePermalink("http://localhost/#".concat(o))}}if(!t)return null;if(t.userId)return t.userId;if(t.groupId)return t.groupId;if(t.roomIdOrAlias)return t.roomIdOrAlias}catch(e){}return null}function P(){var e=T.a.get().permalinkPrefix;return e&&e!==h.a?new x(e):new h.b}function L(e){var t=T.a.get().permalinkPrefix;return e.startsWith(h.a)?(new h.b).parsePermalink(e):t&&e.startsWith(t)?new x(t).parsePermalink(e):null}function U(e){return e.split(":").splice(1).join(":")}function B(e){return e?new URL("https://".concat(e)).hostname:null}function j(e,t){if(!(e=B(e)))return!0;if(t.length>0&&!t[0].test)throw new Error(t[0]);return t.filter((function(t){return t.test(e)})).length>0}function G(e){return!!(e=B(e))&&(e.startsWith("[")&&e.endsWith("]")&&(e=e.substring(1,e.length-1)),d()(e))}},function(e,t){e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}},function(e,t,n){var r=n(299),o=n(300),i=n(301);e.exports=function(e,t){return r(e)||o(e,t)||i()}},function(e,t,n){"use strict";(function(e){var r=n(9),o=n.n(r),i=n(8),a=n.n(i),s=n(1),c=n(35),l=n(26),u=n(18),d=n(3),p=/#\/(groups?|room|user|settings|register|login|forgot_password|home|directory)/,h=/#\/(group|room|user)\/.*$/;function m(){var e=window.location,t=e.origin,n=e.hash,r=window.location.pathname;return t.startsWith("file://")&&(r="//"),t+r+function(e){return p.exec(e)?h.test(e)?e.replace(h,"#/$1/"):e.replace(p,"#/$1"):(console.warn('Unexpected hash location "'.concat(e,'"')),"#/")}(n)}var g={"App Platform":{id:1,expl:Object(s.b)("The platform you're on"),example:"Electron Platform"},"App Version":{id:2,expl:Object(s.b)("The version of Riot.im"),example:"15.0.0"},"User Type":{id:3,expl:Object(s.b)("Whether or not you're logged in (we don't record your username)"),example:"Logged In"},"Chosen Language":{id:4,expl:Object(s.b)("Your language of choice"),example:"en"},Instance:{id:5,expl:Object(s.b)("Which officially provided instance you are using, if any"),example:"app"},"RTE: Uses Richtext Mode":{id:6,expl:Object(s.b)("Whether or not you're using the Richtext mode of the Rich Text Editor"),example:"off"},Breadcrumbs:{id:9,expl:Object(s.b)("Whether or not you're using the 'breadcrumbs' feature (avatars above the room list)"),example:"disabled"},"Homeserver URL":{id:7,expl:Object(s.b)("Your homeserver's URL"),example:"https://matrix.org"},"Identity Server URL":{id:8,expl:Object(s.b)("Your identity server's URL"),example:"https://vector.im"}};function f(e,t){return e.includes(t)?t:""}var _=function(){function e(){o()(this,e),this._paq=null,this.disabled=!0,this.firstPage=!0}return a()(e,[{key:"enable",value:function(){(this._paq||this._init())&&(this.disabled=!1)}},{key:"disable",value:function(){this.trackEvent("Analytics","opt-out"),this._paq.push(["disableHeartBeatTimer"]),this.disabled=!0}},{key:"_init",value:function(){var e=this,t=l.a.get();if(t&&t.piwik&&t.piwik.url&&t.piwik.siteId){var n=t.piwik.url,r=t.piwik.siteId,o=this;window._paq=this._paq=window._paq||[],this._paq.push(["setTrackerUrl",n+"piwik.php"]),this._paq.push(["setSiteId",r]),this._paq.push(["trackAllContentImpressions"]),this._paq.push(["discardHashTag",!1]),this._paq.push(["enableHeartBeatTimer"]);var i,a,u=c.a.get();return this._setVisitVariable("App Platform",u.getHumanReadableName()),u.getAppVersion().then((function(t){e._setVisitVariable("App Version",t)})).catch((function(){e._setVisitVariable("App Version","unknown")})),this._setVisitVariable("Chosen Language",Object(s.d)()),"riot.im"===window.location.hostname&&this._setVisitVariable("Instance",window.location.pathname),i=document.createElement("script"),a=document.getElementsByTagName("script")[0],i.type="text/javascript",i.async=!0,i.defer=!0,i.src=n+"piwik.js",i.onload=function(){console.log("Initialised anonymous analytics"),o._paq=window._paq},a.parentNode.insertBefore(i,a),!0}}},{key:"trackPageChange",value:function(e){this.disabled||(this.firstPage?this.firstPage=!1:("number"==typeof e?this._paq.push(["setGenerationTimeMs",e]):console.warn("Analytics.trackPageChange: expected generationTimeMs to be a number"),this._paq.push(["setCustomUrl",m()]),this._paq.push(["trackPageView"])))}},{key:"trackEvent",value:function(e,t,n,r){this.disabled||(this._paq.push(["setCustomUrl",m()]),this._paq.push(["trackEvent",e,t,n,r]))}},{key:"logout",value:function(){this.disabled||this._paq.push(["deleteCookies"])}},{key:"_setVisitVariable",value:function(e,t){this.disabled||this._paq.push(["setCustomVariable",g[e].id,e,t,"visit"])}},{key:"setLoggedIn",value:function(e,t,n){if(!this.disabled){var r=l.a.get();if(r.piwik){var o=r.piwik.whitelistedHSUrls||[],i=r.piwik.whitelistedISUrls||[];this._setVisitVariable("User Type",e?"Guest":"Logged In"),this._setVisitVariable("Homeserver URL",f(o,t)),this._setVisitVariable("Identity Server URL",f(i,n))}}}},{key:"setRichtextMode",value:function(e){this.disabled||this._setVisitVariable("RTE: Uses Richtext Mode",e?"on":"off")}},{key:"setBreadcrumbs",value:function(e){this.disabled||this._setVisitVariable("Breadcrumbs",e?"enabled":"disabled")}},{key:"showDetailsModal",value:function(){var e=[];if(window.Piwik){var t=window.Piwik.getAsyncTracker();e=Object.values(g).map((function(e){return t.getCustomVariable(e.id)})).filter(Boolean)}else e=Object.keys(g).map((function(e){return[e,Object(s.a)("e.g. %(exampleValue)s",{exampleValue:g[e].example})]}));var n="".concat(window.screen.width,"x").concat(window.screen.height),r=[{expl:Object(s.b)("Every page you use in the app"),value:Object(s.a)("e.g. ",{},{CurrentPageURL:m()})},{expl:Object(s.b)("Your User Agent"),value:navigator.userAgent},{expl:Object(s.b)("Your device resolution"),value:n}],o=d.a("dialogs.ErrorDialog");u.a.createTrackedDialog("Analytics Details","",o,{title:Object(s.a)("Analytics"),description:React.createElement("div",{className:"mx_AnalyticsModal"},React.createElement("div",null,Object(s.a)("The information being sent to us to help make Riot.im better includes:")),React.createElement("table",null,e.map((function(e){return React.createElement("tr",{key:e[0]},React.createElement("td",null,Object(s.a)(g[e[0]].expl)),void 0!==e[1]&&React.createElement("td",null,React.createElement("code",null,e[1])))})),r.map((function(e,t){return React.createElement("tr",{key:t},React.createElement("td",null,Object(s.a)(e.expl)),React.createElement("td",null,React.createElement("code",null,e.value)))}))),React.createElement("div",null,Object(s.a)("Where this page includes identifiable information, such as a room, user or group ID, that data is removed before being sent to the server.")))})}}]),e}();e.mxAnalytics||(e.mxAnalytics=new _),t.a=e.mxAnalytics}).call(this,n(34))},function(e,t,n){"use strict";n.d(t,"a",(function(){return y})),n.d(t,"b",(function(){return E}));var r=n(6),o=n.n(r),i=n(16),a=n.n(i),s=n(8),c=n.n(s),l=n(9),u=n.n(l),d=n(5),p=n.n(d),h=n(0),m=n.n(h),g=n(23),f=n(1),_=n(285),v=n(26),b=[g.a.ERROR_INVALID_HOMESERVER,g.a.ERROR_INVALID_IDENTITY_SERVER],y=function e(){u()(this,e),p()(this,"hsUrl",void 0),p()(this,"hsName",void 0),p()(this,"hsNameIsDifferent",void 0),p()(this,"isUrl",void 0),p()(this,"isDefault",void 0),p()(this,"warning",void 0)},E=function(){function e(){u()(this,e)}var t,n;return c()(e,null,[{key:"isLivelinessError",value:function(e){return!!e&&!!b.find((function(t){return t===e||t===e.message}))}},{key:"authComponentStateForError",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"login";if(!t)return{serverIsAlive:!0,serverErrorIsFatal:!1,serverDeadError:null};var r=Object(f.a)("Cannot reach homeserver"),o=Object(f.a)("Ensure you have a stable internet connection, or get in touch with the server admin");e.isLivelinessError(t)||(r=Object(f.a)("Your Riot is misconfigured"),o=Object(f.a)("Ask your Riot admin to check your config for incorrect or duplicate entries.",{},{a:function(e){return m.a.createElement("a",{href:"https://github.com/vector-im/riot-web/blob/master/docs/config.md",target:"_blank",rel:"noopener"},e)}}));var i=!0,a=t.message?t.message:t;return a===g.a.ERROR_INVALID_IDENTITY_SERVER&&(i=!1,r=Object(f.a)("Cannot reach identity server"),o="register"===n?Object(f.a)("You can register, but some features will be unavailable until the identity server is back online. If you keep seeing this warning, check your configuration or contact a server admin."):"reset_password"===n?Object(f.a)("You can reset your password, but some features will be unavailable until the identity server is back online. If you keep seeing this warning, check your configuration or contact a server admin."):Object(f.a)("You can log in, but some features will be unavailable until the identity server is back online. If you keep seeing this warning, check your configuration or contact a server admin.")),{serverIsAlive:!1,serverErrorIsFatal:i,serverDeadError:m.a.createElement("div",null,m.a.createElement("strong",null,r),m.a.createElement("div",null,o))}}},{key:"validateServerConfigWithStaticUrls",value:(n=a()(o.a.mark((function t(n,r){var i,a,s,c,l,u=arguments;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=u.length>2&&void 0!==u[2]&&u[2],n){t.next=3;break}throw Object(f.h)(Object(f.b)("No homeserver URL provided"));case 3:return a={"m.homeserver":{base_url:n}},r&&(a["m.identity_server"]={base_url:r}),t.next=7,g.a.fromDiscoveryConfig(a);case 7:return s=t.sent,c=new URL(n),l=c.hostname,t.abrupt("return",e.buildValidatedConfigFromDiscovery(l,s,i));case 11:case"end":return t.stop()}}),t)}))),function(e,t){return n.apply(this,arguments)})},{key:"validateServerName",value:(t=a()(o.a.mark((function t(n){var r;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,g.a.findClientConfig(n);case 2:return r=t.sent,t.abrupt("return",e.buildValidatedConfigFromDiscovery(n,r));case 4:case"end":return t.stop()}}),t)}))),function(e){return t.apply(this,arguments)})},{key:"buildValidatedConfigFromDiscovery",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!n||!n["m.homeserver"])throw console.error("Ended up in a state of not knowing which homeserver to connect to."),Object(f.h)(Object(f.b)("Unexpected error resolving homeserver configuration"));var o=n["m.homeserver"],i=n["m.identity_server"],a=v.a.get().validated_server_config,s=a&&a.isUrl;if(i&&i.state===g.a.SUCCESS)s=i.base_url;else if(i&&i.state!==g.a.PROMPT){if(console.error("Error determining preferred identity server URL:",i),i.state===g.a.FAIL_ERROR){if(-1!==g.a.ALL_ERRORS.indexOf(i.error))throw Object(f.h)(i.error);throw Object(f.h)(Object(f.b)("Unexpected error resolving identity server configuration"))}o.error=g.a.ERROR_INVALID_IDENTITY_SERVER,i.base_url&&(s=i.base_url)}if(o.state!==g.a.SUCCESS&&(console.error("Error processing homeserver config:",o),!r||!e.isLivelinessError(o.error))){if(-1!==g.a.ALL_ERRORS.indexOf(o.error))throw Object(f.h)(o.error);throw Object(f.h)(Object(f.b)("Unexpected error resolving homeserver configuration"))}var c=o.base_url,l=t||o.server_name,u=new URL(c);if(l||(l=u.hostname),!l)throw console.error("Failed to parse homeserver name from homeserver URL"),Object(f.h)(Object(f.b)("Unexpected error resolving homeserver configuration"));return Object(_.a)(y,{hsUrl:c,hsName:l,hsNameIsDifferent:u.hostname!==l,isUrl:s,isDefault:!1,warning:o.error})}}]),e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return _}));var r=n(27),o=n.n(r),i=n(9),a=n.n(i),s=n(8),c=n.n(s),l=n(4),u=n(26),d=n(10),p=n(39),h=n(98),m=n(15),g=n(64),f=n(55);var _=function(){function e(){a()(this,e)}return c()(e,null,[{key:"canUserModifyWidgets",value:function(e){if(!e)return console.warn("No room ID specified"),!1;var t=l.a.get();if(!t)return console.warn("User must be be logged in"),!1;var n=t.getRoom(e);if(!n)return console.warn("Room ID ".concat(e," is not recognised")),!1;var r=t.credentials.userId;return r?"join"!==n.getMyMembership()?(console.warn("User ".concat(r," is not in room ").concat(e)),!1):n.currentState.maySendStateEvent("im.vector.modular.widgets",r):(console.warn("Failed to get user ID"),!1)}},{key:"isScalarUrl",value:function(e){if(!e)return console.error("Scalar URL check failed. No URL specified"),!1;var t=p.parse(e),n=u.a.get().integrations_widgets_urls;if(!n||0===n.length){var r=f.a.sharedInstance().getPrimaryManager();n=r?[r.apiUrl]:[]}for(var o=0;o0&&(y+="?"+E.join("&")),_.open("POST",y),this.useAuthorizationHeader&&_.setRequestHeader("Authorization","Bearer "+this.opts.accessToken),_.setRequestHeader("Content-Type",o),_.send(l),(p=f.promise).abort=_.abort.bind(_)}else{var S={};r&&i&&(S.filename=i),p=this.authedRequest(n.callback,"POST","/upload",S,l,{prefix:"/_matrix/media/r0",headers:{"Content-Type":o},json:!1,bodyParser:m})}var w=this,k=p.finally((function(){for(var e=0;e=400?a=function(e,t){var n,r=e.statusCode,a=function(e){var t;e.getResponseHeader?t=e.getResponseHeader("Content-Type"):e.headers&&(t=e.headers["content-type"]||null);if(!t)return null;try{return Object(i.parse)(t)}catch(e){throw new Error("Error parsing Content-Type '".concat(t,"': ").concat(e))}}(e);if(a)if("application/json"===a.type){var s="object"===o()(t)?t:JSON.parse(t);n=new f(s)}else"text/plain"===a.type&&(n=new Error("Server returned ".concat(r," error: ").concat(t)));n||(n=new Error("Server returned ".concat(r," error")));return n.httpStatus=r,n}(s,c):r&&(c=r(c))}catch(e){a=new Error("Error parsing server response: ".concat(e))}if(a)e.reject(a),t(a);else{var l={code:s.statusCode,headers:s.headers,data:c};e.resolve(n?c:l),t(null,n?c:l)}}};function f(e){e=e||{},this.errcode=e.errcode,this.name=e.errcode||"Unknown error code",this.message=e.error||"Unknown message",this.data=e}f.prototype=Object.create(Error.prototype),f.prototype.constructor=f}).call(this,n(34))},function(e,t,n){"use strict";(function(e){n.d(t,"a",(function(){return _}));var r=n(11),o=n.n(r),i=n(21),a=n.n(i),s=n(38),c=n.n(s),l=n(43),u=n.n(l),d=n(17),p=n(283),h=n(168),m=n(290),g=n(172),f=n(195),_=function(){function t(e,n){c()(this,t),this._indexedDB=e,this._dbName=n,this._backendPromise=null}return u()(t,[{key:"_connect",value:function(){var n=this;return this._backendPromise?this._backendPromise:(this._backendPromise=new Promise((function(e,t){if(n._indexedDB){d.a.log("connecting to indexeddb ".concat(n._dbName));var r=n._indexedDB.open(n._dbName,m.b);r.onupgradeneeded=function(e){var t=e.target.result,n=e.oldVersion;m.c(t,n)},r.onblocked=function(){d.a.log("can't yet open IndexedDBCryptoStore because it is open elsewhere")},r.onerror=function(e){d.a.log("Error connecting to indexeddb",e),t(e.target.error)},r.onsuccess=function(t){var r=t.target.result;d.a.log("connected to indexeddb ".concat(n._dbName)),e(new m.a(r))}}else t(new Error("no indexeddb support available"))})).then((function(e){return e.doTxn("readonly",[t.STORE_INBOUND_GROUP_SESSIONS,t.STORE_INBOUND_GROUP_SESSIONS_WITHHELD],(function(t){e.getEndToEndInboundGroupSession("","",t,(function(){}))})).then((function(){return e}))})).catch((function(t){if("VersionError"===t.name)throw d.a.warn("Crypto DB is too new for us to use!",t),new g.a(g.a.TOO_NEW);d.a.warn("unable to connect to indexeddb ".concat(n._dbName)+": falling back to localStorage store: ".concat(t));try{return new p.a(e.localStorage)}catch(t){return d.a.warn("unable to open localStorage: falling back to in-memory store: ".concat(t)),new h.a}})),this._backendPromise)}},{key:"deleteAllData",value:function(){var e=this;return new Promise((function(t,n){if(e._indexedDB){d.a.log("Removing indexeddb instance: ".concat(e._dbName));var r=e._indexedDB.deleteDatabase(e._dbName);r.onblocked=function(){d.a.log("can't yet delete IndexedDBCryptoStore because it is open elsewhere")},r.onerror=function(e){d.a.log("Error deleting data from indexeddb",e),n(e.target.error)},r.onsuccess=function(){d.a.log("Removed indexeddb instance: ".concat(e._dbName)),t()}}else n(new Error("no indexeddb support available"))})).catch((function(e){d.a.warn("unable to delete IndexedDBCryptoStore: ".concat(e))}))}},{key:"getOrAddOutgoingRoomKeyRequest",value:function(e){return this._connect().then((function(t){return t.getOrAddOutgoingRoomKeyRequest(e)}))}},{key:"getOutgoingRoomKeyRequest",value:function(e){return this._connect().then((function(t){return t.getOutgoingRoomKeyRequest(e)}))}},{key:"getOutgoingRoomKeyRequestByState",value:function(e){return this._connect().then((function(t){return t.getOutgoingRoomKeyRequestByState(e)}))}},{key:"getOutgoingRoomKeyRequestsByTarget",value:function(e,t,n){return this._connect().then((function(r){return r.getOutgoingRoomKeyRequestsByTarget(e,t,n)}))}},{key:"updateOutgoingRoomKeyRequest",value:function(e,t,n){return this._connect().then((function(r){return r.updateOutgoingRoomKeyRequest(e,t,n)}))}},{key:"deleteOutgoingRoomKeyRequest",value:function(e,t){return this._connect().then((function(n){return n.deleteOutgoingRoomKeyRequest(e,t)}))}},{key:"getAccount",value:function(e,t){this._backendPromise.then((function(n){n.getAccount(e,t)}))}},{key:"storeAccount",value:function(e,t){this._backendPromise.then((function(n){n.storeAccount(e,t)}))}},{key:"getCrossSigningKeys",value:function(e,t){this._backendPromise.then((function(n){n.getCrossSigningKeys(e,t)}))}},{key:"storeCrossSigningKeys",value:function(e,t){this._backendPromise.then((function(n){n.storeCrossSigningKeys(e,t)}))}},{key:"countEndToEndSessions",value:function(e,t){this._backendPromise.then((function(n){n.countEndToEndSessions(e,t)}))}},{key:"getEndToEndSession",value:function(e,t,n,r){this._backendPromise.then((function(o){o.getEndToEndSession(e,t,n,r)}))}},{key:"getEndToEndSessions",value:function(e,t,n){this._backendPromise.then((function(r){r.getEndToEndSessions(e,t,n)}))}},{key:"getAllEndToEndSessions",value:function(e,t){this._backendPromise.then((function(n){n.getAllEndToEndSessions(e,t)}))}},{key:"storeEndToEndSession",value:function(e,t,n,r){this._backendPromise.then((function(o){o.storeEndToEndSession(e,t,n,r)}))}},{key:"storeEndToEndSessionProblem",value:function(e,t,n){return this._backendPromise.then(function(){var r=a()(o.a.mark((function r(i){return o.a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,i.storeEndToEndSessionProblem(e,t,n);case 2:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}())}},{key:"getEndToEndSessionProblem",value:function(e,t){return this._backendPromise.then(function(){var n=a()(o.a.mark((function n(r){return o.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,r.getEndToEndSessionProblem(e,t);case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n)})));return function(e){return n.apply(this,arguments)}}())}},{key:"filterOutNotifiedErrorDevices",value:function(e){return this._backendPromise.then(function(){var t=a()(o.a.mark((function t(n){return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.filterOutNotifiedErrorDevices(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}())}},{key:"getEndToEndInboundGroupSession",value:function(e,t,n,r){this._backendPromise.then((function(o){o.getEndToEndInboundGroupSession(e,t,n,r)}))}},{key:"getAllEndToEndInboundGroupSessions",value:function(e,t){this._backendPromise.then((function(n){n.getAllEndToEndInboundGroupSessions(e,t)}))}},{key:"addEndToEndInboundGroupSession",value:function(e,t,n,r){this._backendPromise.then((function(o){o.addEndToEndInboundGroupSession(e,t,n,r)}))}},{key:"storeEndToEndInboundGroupSession",value:function(e,t,n,r){this._backendPromise.then((function(o){o.storeEndToEndInboundGroupSession(e,t,n,r)}))}},{key:"storeEndToEndInboundGroupSessionWithheld",value:function(e,t,n,r){this._backendPromise.then((function(o){o.storeEndToEndInboundGroupSessionWithheld(e,t,n,r)}))}},{key:"storeEndToEndDeviceData",value:function(e,t){this._backendPromise.then((function(n){n.storeEndToEndDeviceData(e,t)}))}},{key:"getEndToEndDeviceData",value:function(e,t){this._backendPromise.then((function(n){n.getEndToEndDeviceData(e,t)}))}},{key:"storeEndToEndRoom",value:function(e,t,n){this._backendPromise.then((function(r){r.storeEndToEndRoom(e,t,n)}))}},{key:"getEndToEndRooms",value:function(e,t){this._backendPromise.then((function(n){n.getEndToEndRooms(e,t)}))}},{key:"getSessionsNeedingBackup",value:function(e){return this._connect().then((function(t){return t.getSessionsNeedingBackup(e)}))}},{key:"countSessionsNeedingBackup",value:function(e){return this._connect().then((function(t){return t.countSessionsNeedingBackup(e)}))}},{key:"unmarkSessionsNeedingBackup",value:function(e,t){return this._connect().then((function(n){return n.unmarkSessionsNeedingBackup(e,t)}))}},{key:"markSessionsNeedingBackup",value:function(e,t){return this._connect().then((function(n){return n.markSessionsNeedingBackup(e,t)}))}},{key:"doTxn",value:function(e,t,n){return this._connect().then((function(r){return r.doTxn(e,t,n)}))}}],[{key:"exists",value:function(e,t){return f.a(e,t)}}]),t}();_.STORE_ACCOUNT="account",_.STORE_SESSIONS="sessions",_.STORE_INBOUND_GROUP_SESSIONS="inbound_group_sessions",_.STORE_INBOUND_GROUP_SESSIONS_WITHHELD="inbound_group_sessions_withheld",_.STORE_DEVICE_DATA="device_data",_.STORE_ROOMS="rooms",_.STORE_BACKUP="sessions_needing_backup"}).call(this,n(34))},function(e,t,n){"use strict";(function(e){n.d(t,"a",(function(){return k}));var r=n(29),o=n.n(r),i=n(6),a=n.n(i),s=n(16),c=n.n(s),l=n(9),u=n.n(l),d=n(8),p=n.n(d),h=n(5),m=n.n(h),g=n(26),f=n(3),_=n(18),v=n(106),b=n(51),y=n(4),E=n(23),S=n(15),w=[v.b,v.d,v.c],k=function(){function e(){u()(this,e),m()(this,"_managers",[]),m()(this,"_client",void 0),m()(this,"_wellknownRefreshTimerId",null),m()(this,"_primaryManager",void 0),this._compileManagers()}var t,n,r;return p()(e,null,[{key:"sharedInstance",value:function(){return e._instance||(e._instance=new e),e._instance}}]),p()(e,[{key:"startWatching",value:function(){var e=this;this.stopWatching(),this._client=y.a.get(),this._client.on("accountData",this._onAccountData.bind(this)),this._compileManagers(),setInterval((function(){return e._setupHomeserverManagers()}),288e5)}},{key:"stopWatching",value:function(){this._client&&(this._client.removeListener("accountData",this._onAccountData.bind(this)),null!==this._wellknownRefreshTimerId&&clearInterval(this._wellknownRefreshTimerId))}},{key:"_compileManagers",value:function(){this._managers=[],this._setupConfiguredManager(),this._setupHomeserverManagers(),this._setupAccountManagers()}},{key:"_setupConfiguredManager",value:function(){var e=g.a.get().integrations_rest_url,t=g.a.get().integrations_ui_url;e&&t&&(this._managers.push(new v.a(v.c,e,t)),this._primaryManager=null)}},{key:"_setupHomeserverManagers",value:(r=c()(a.a.mark((function e(){var t,n,r,o,i,s,c,l,u;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(y.a.get()){e.next=2;break}return e.abrupt("return");case 2:return e.prev=2,console.log("Updating homeserver-configured integration managers..."),t=y.a.getHomeserverName(),e.next=7,E.a.getRawClientConfig(t);case 7:if(!(n=e.sent)||!n["m.integrations"]){e.next=43;break}r=n["m.integrations"].managers,Array.isArray(r)||(r=[]),console.log("Homeserver has ".concat(r.length," integration managers")),this._managers=this._managers.filter((function(e){return e.kind!==v.d})),o=!0,i=!1,s=void 0,e.prev=16,c=r[Symbol.iterator]();case 18:if(o=(l=c.next()).done){e.next=26;break}if((u=l.value).api_url){e.next=22;break}return e.abrupt("continue",23);case 22:this._managers.push(new v.a(v.d,u.api_url,u.ui_url));case 23:o=!0,e.next=18;break;case 26:e.next=32;break;case 28:e.prev=28,e.t0=e.catch(16),i=!0,s=e.t0;case 32:e.prev=32,e.prev=33,o||null==c.return||c.return();case 35:if(e.prev=35,!i){e.next=38;break}throw s;case 38:return e.finish(35);case 39:return e.finish(32);case 40:this._primaryManager=null,e.next=44;break;case 43:console.log("Homeserver has no integration managers");case 44:e.next=49;break;case 46:e.prev=46,e.t1=e.catch(2),console.error(e.t1);case 49:case"end":return e.stop()}}),e,this,[[2,46],[16,28,32,40],[33,,35,39]])}))),function(){return r.apply(this,arguments)})},{key:"_setupAccountManagers",value:function(){var e=this;this._client&&this._client.getUserId()&&(b.a.getIntegrationManagerWidgets().forEach((function(t){var n=t.content.data;if(n){var r=t.content.url,o=n.api_url;if(o&&r){var i=new v.a(v.b,o,r);i.id=t.id||t.state_key||"",e._managers.push(i)}}})),this._primaryManager=null)}},{key:"_onAccountData",value:function(e){"m.widgets"===e.getType()&&this._compileManagers()}},{key:"hasManager",value:function(){return this._managers.length>0}},{key:"getOrderedManagers",value:function(){var e=this,t=[],n=!0,r=!1,i=void 0;try{for(var a,s=function(){var n=a.value,r=e._managers.filter((function(e){return e.kind===n}));if(!r||!r.length)return"continue";n===v.b&&r.sort((function(e,t){return e.id.localeCompare(t.id)})),t.push.apply(t,o()(r))},c=w[Symbol.iterator]();!(n=(a=c.next()).done);n=!0)s()}catch(e){r=!0,i=e}finally{try{n||null==c.return||c.return()}finally{if(r)throw i}}return t}},{key:"getPrimaryManager",value:function(){return this.hasManager()?this._primaryManager?this._primaryManager:(this._primaryManager=this.getOrderedManagers()[0],this._primaryManager):null}},{key:"openNoManagerDialog",value:function(){var e=f.a("dialogs.IntegrationsImpossibleDialog");_.a.createTrackedDialog("Integrations impossible","",e)}},{key:"openAll",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(!S.b.getValue("integrationProvisioning"))return this.showDisabledDialog();if(0===this._managers.length)return this.openNoManagerDialog();var r=f.a("views.dialogs.TabbedIntegrationManagerDialog");_.a.createTrackedDialog("Tabbed Integration Manager","",r,{room:e,screen:t,integrationId:n},"mx_TabbedIntegrationManagerDialog")}},{key:"showDisabledDialog",value:function(){var e=f.a("dialogs.IntegrationsDisabledDialog");_.a.createTrackedDialog("Integrations disabled","",e)}},{key:"overwriteManagerOnAccount",value:(n=c()(a.a.mark((function e(t){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.a.removeIntegrationManagerWidgets();case 2:return e.next=4,b.a.addIntegrationManagerWidget(t.name,t.uiUrl,t.apiUrl);case 4:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})},{key:"tryDiscoverManager",value:(t=c()(a.a.mark((function e(t){var n,r,o,i,s;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("Looking up integration manager via .well-known"),(t.startsWith("http:")||t.startsWith("https:"))&&(n=n.parse(t),t=n.host),e.prev=2,e.next=5,fetch("https://".concat(t,"/.well-known/matrix/integrations"));case 5:return o=e.sent,e.next=8,o.json();case 8:r=e.sent,e.next=16;break;case 11:return e.prev=11,e.t0=e.catch(2),console.error(e.t0),console.warn("Failed to locate integration manager"),e.abrupt("return",null);case 16:if(r&&r["m.integrations_widget"]){e.next=19;break}return console.warn("Missing integrations widget on .well-known response"),e.abrupt("return",null);case 19:if((i=r["m.integrations_widget"]).url&&i.data&&i.data.api_url){e.next=23;break}return console.warn("Malformed .well-known response for integrations widget"),e.abrupt("return",null);case 23:return s=new v.a(v.b,i.data.api_url,i.url),console.log("Got an integration manager (untested)"),e.abrupt("return",s);case 26:case"end":return e.stop()}}),e,null,[[2,11]])}))),function(e){return t.apply(this,arguments)})}]),e}();m()(k,"_instance",void 0),e.mxIntegrationManagers=k}).call(this,n(34))},function(e,t,n){"use strict";var r=n(11),o=n.n(r),i=n(101),a=n.n(i),s=n(21),c=n.n(s),l=n(38),u=n.n(l),d=n(43),p=n.n(d),h=n(71),m=n.n(h),g=n(68),f=n.n(g),_=n(72),v=n.n(_),b=n(17),y=function(){function e(t,n){u()(this,e),this._request=t,this._channel=n}var t,n;return p()(e,[{key:"handleEvent",value:function(e,t){return this._channel.handleEvent(e,t)}},{key:"completedContentFromEvent",value:function(e){return this._channel.completedContentFromEvent(e)}},{key:"completeContent",value:function(e,t){return this._channel.completeContent(e,t)}},{key:"send",value:(n=c()(o.a.mark((function e(t,n){var r;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._request.handleVerifierSend(t,n),e.next=3,this._channel.send(t,n);case 3:return r=e.sent,e.abrupt("return",r);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"sendCompleted",value:(t=c()(o.a.mark((function e(t,n){var r;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._request.handleVerifierSend(t,n),e.next=3,this._channel.sendCompleted(t,n);case 3:return r=e.sent,e.abrupt("return",r);case 5:case"end":return e.stop()}}),e,this)}))),function(e,n){return t.apply(this,arguments)})},{key:"transactionId",get:function(){return this._channel.transactionId}},{key:"needsDoneMessage",get:function(){return this._channel.needsDoneMessage}}]),e}(),E=n(45),S=n(63);n.d(t,"c",(function(){return k})),n.d(t,"d",(function(){return x})),n.d(t,"a",(function(){return C})),n.d(t,"b",(function(){return T})),n.d(t,"e",(function(){return R}));var w="m.key.verification.",k=w+"request",x=w+"start",C=w+"cancel",T=4,R=function(e){function t(e,n,r,o){var i;return u()(this,t),(i=m()(this,f()(t).call(this))).channel=e,i._verificationMethods=n,i._client=o,i._commonMethods=[],i._setPhase(1,!1),i._requestEvent=null,i._otherUserId=r,i._initiatedByMe=null,i._startTimestamp=null,i}var n,r,i,s,l;return v()(t,e),p()(t,[{key:"beginKeyVerification",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!this._verifier&&this._hasValidPreStartPhase()){if(this._commonMethods.length&&!this._commonMethods.includes(e))throw Object(S.g)();if(this._verifier=this._createVerifier(e,null,t),!this._verifier)throw Object(S.g)()}return this._verifier}},{key:"sendRequest",value:(l=c()(o.a.mark((function e(){var t;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(1!==this._phase){e.next=7;break}return this._initiatedByMe=!0,this._setPhase(2,!1),t=a()(this._verificationMethods.keys()),e.next=6,this.channel.send(k,{methods:t});case 6:this.emit("change");case 7:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"cancel",value:(s=c()(o.a.mark((function e(){var t,n,r,i,a,s=arguments;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=s.length>0&&void 0!==s[0]?s[0]:{},n=t.reason,r=void 0===n?"User declined":n,i=t.code,a=void 0===i?"m.user":i,5===this._phase){e.next=10;break}if(!this._verifier){e.next=6;break}return e.abrupt("return",this._verifier.cancel(Object(S.a)(a,r)));case 6:return this._setPhase(5,!1),e.next=9,this.channel.send(C,{code:a,reason:r});case 9:this.emit("change");case 10:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"waitForVerifier",value:function(){var e=this;return this.verifier?Promise.resolve(this.verifier):new Promise((function(t){e.on("change",(function n(){e.verifier&&(e.off("change",n),t(e.verifier))}))}))}},{key:"_setPhase",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this._phase=e,t&&this.emit("change")}},{key:"handleEvent",value:(i=c()(o.a.mark((function e(t,n,r){var i;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=n.getContent(),t!==k&&t!==x||null===this._startTimestamp&&(this._startTimestamp=r),t!==k){e.next=7;break}return e.next=5,this._handleRequest(i,n);case 5:e.next=10;break;case 7:if(t!==x){e.next=10;break}return e.next=10,this._handleStart(i,n);case 10:this._verifier&&(t===C||this._verifier.events&&this._verifier.events.includes(t))&&this._verifier.handleEvent(n),t===C?this._handleCancel():"m.key.verification.done"===t&&this._handleDone();case 12:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return i.apply(this,arguments)})},{key:"_handleRequest",value:(r=c()(o.a.mark((function e(t,n){var r,i=this;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(1!==this._phase){e.next=8;break}r=t.methods,this._commonMethods=r.filter((function(e){return i._verificationMethods.has(e)})),this._requestEvent=n,this._initiatedByMe=this._wasSentByMe(n),this._setPhase(2),e.next=12;break;case 8:if(2===this._phase){e.next=12;break}return b.a.warn("Ignoring flagged verification request from "+n.getSender()),e.next=12,this.cancel(Object(S.b)(Object(S.f)()));case 12:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"_hasValidPreStartPhase",value:function(){return 2===this._phase||this.channel.constructor.canCreateRequest(x)&&1===this._phase}},{key:"_handleStart",value:(n=c()(o.a.mark((function e(t,n){var r;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._hasValidPreStartPhase()){e.next=10;break}if(r=t.method,this._verificationMethods.has(r)){e.next=7;break}return e.next=5,this.cancel(Object(S.b)(Object(S.g)()));case 5:e.next=10;break;case 7:1===this.phase&&(this._initiatedByMe=this._wasSentByMe(n)),this._verifier=this._createVerifier(r,n),this._setPhase(T);case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"handleVerifierSend",value:function(e,t){e===C?this._handleCancel():e===x&&(1!==this._phase&&2!==this._phase||(this._initiatedByMe=1===this.phase,this._setPhase(T)))}},{key:"_handleCancel",value:function(){5!==this._phase&&this._setPhase(5)}},{key:"_handleDone",value:function(){this._phase===T&&this._setPhase(6)}},{key:"_createVerifier",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=t&&this._wasSentByMe(t),o=this._getVerifierTarget(t,n),i=o.userId,a=o.deviceId,s=this._verificationMethods.get(e);if(s){var c=new y(this,this.channel);return new s(c,this._client,i,a,r?null:t)}console.warn("could not find verifier constructor for method",e)}},{key:"_getVerifierTarget",value:function(e,t){if(t)return t;var n;if(e&&!this._wasSentByMe(e))n=e;else{if(!this._requestEvent||this._wasSentByMe(this._requestEvent))throw new Error("can't determine who the verifier should be targeted at. No .request or .start event and no targetDevice");n=this._requestEvent}var r=n.getSender(),o=n.getContent();return{userId:r,deviceId:o&&o.from_device}}},{key:"_wasSentByMe",value:function(e){if(e.getSender()!==this._client.getUserId())return!1;var t=e.getContent();return!(!t||t.from_device!==this._client.getDeviceId())}},{key:"methods",get:function(){return this._commonMethods}},{key:"timeout",get:function(){var e=Date.now()-this._startTimestamp;return Math.max(0,6e5-e)}},{key:"event",get:function(){return this._requestEvent}},{key:"phase",get:function(){return this._phase}},{key:"verifier",get:function(){return this._verifier}},{key:"pending",get:function(){return 1!==this._phase&&6!==this._phase&&5!==this._phase}},{key:"initiatedByMe",get:function(){return this._initiatedByMe}},{key:"requestingUserId",get:function(){return this.initiatedByMe?this._client.getUserId():this._otherUserId}},{key:"receivingUserId",get:function(){return this.initiatedByMe?this._otherUserId:this._client.getUserId()}}],[{key:"validateEvent",value:function(e,t,n,r){var o=t.getContent();if(!e.startsWith(w))return!1;if(e===k&&!Array.isArray(o.methods))return!1;if(!(e!==k&&e!==x||"string"==typeof o.from_device&&0!==o.from_device.length))return!1;if(Number.isFinite(n)){var i=Date.now()-n;if(i>597e3||i<-3e5)return b.a.log("received verification that is too old or from the future"),!1}return!0}}]),t}(E.EventEmitter)},function(e,t,n){var r=n(945);e.exports=function(e,t){if(null==e)return{};var n,o,i=r(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}},function(e,t,n){"use strict";n.d(t,"h",(function(){return G})),n.d(t,"g",(function(){return q})),n.d(t,"f",(function(){return V})),n.d(t,"c",(function(){return H})),n.d(t,"a",(function(){return Q})),n.d(t,"e",(function(){return J})),n.d(t,"d",(function(){return X})),n.d(t,"b",(function(){return Z}));var r=n(13),o=n.n(r),i=n(12),a=n.n(i),s=n(14),c=n.n(s),l=n(9),u=n.n(l),d=n(8),p=n.n(d),h=n(103),m=n(0),g=n.n(m),f=n(146),_=n.n(f),v=(n(222),n(781)),b=n(128),y=n(782),E=n.n(y),S=n(783),w=n.n(S),k=n(24),x=n.n(k),C=n(4),T=n(39),R=n.n(T),D=n(784),O=n.n(D),F=n(46),I=n(126);Object(b.a)(v);var N=/([\ud800-\udbff])([\udc00-\udfff])/,A=/([\u2100-\u2bff])/,M=new RegExp("‍| ","g"),P=new RegExp("\\s","g"),L=new RegExp("^(".concat(O.a.source,")+$"),"i"),U=/^#[0-9a-fA-F]{6}$/,B=["http","https","ftp","mailto","magnet"];function j(e){return N.test(e)||A.test(e)}function G(e){var t=Object(I.d)(e);return t&&t.shortcodes?":".concat(t.shortcodes[0],":"):""}function q(e){e=e.slice(1,e.length-1);var t=I.c.get(e);return t?t.unicode:null}function V(e){var t=_()(e,W);return g.a.createElement("div",{dangerouslySetInnerHTML:{__html:t},dir:"auto"})}function H(e){try{var t=R.a.parse(e);return!!t.protocol&&B.includes(t.protocol.slice(0,-1))}catch(e){return!1}}var z={a:function(e,t){if(t.href){t.target="_blank";var n=Object(F.i)(t.href);(n!==t.href||t.href.match(b.a.VECTOR_URL_PATTERN))&&(t.href=n,delete t.target)}return t.rel="noopener",{tagName:e,attribs:t}},img:function(e,t){return t.src&&t.src.startsWith("mxc://")?(t.src=C.a.get().mxcUrlToHttp(t.src,t.width||800,t.height||600),{tagName:e,attribs:t}):{tagName:e,attribs:{}}},code:function(e,t){if(void 0!==t.class){var n=t.class.split(/\s/).filter((function(e){return e.startsWith("language-")}));t.class=n.join(" ")}return{tagName:e,attribs:t}},"*":function(e,t){delete t.style;var n={"data-mx-color":"color","data-mx-bg-color":"background-color"},r="";return Object.keys(n).forEach((function(e){var o=n[e],i=t[e];i&&"string"==typeof i&&U.test(i)&&(r+=o+":"+i+";",delete t[e])})),r&&(t.style=r),{tagName:e,attribs:t}}},W={allowedTags:["font","del","h1","h2","h3","h4","h5","h6","blockquote","p","a","ul","ol","sup","sub","nl","li","b","i","u","strong","em","strike","code","hr","br","div","table","thead","caption","tbody","tr","th","td","pre","span","img"],allowedAttributes:{font:["color","data-mx-bg-color","data-mx-color","style"],span:["data-mx-bg-color","data-mx-color","data-mx-spoiler","style"],a:["href","name","target","rel"],img:["src","width","height","alt","title"],ol:["start"],code:["class"]},selfClosing:["img","br","hr","area","base","basefont","input","link","meta"],allowedSchemes:B,allowProtocolRelative:!1,transformTags:z},K=Object.assign({},W);K.transformTags={code:z.code,"*":z["*"]};var Y=function(){function e(t,n){u()(this,e),this.highlightClass=t,this.highlightLink=n}return p()(e,[{key:"applyHighlights",value:function(e,t){for(var n,r=0,o=[],i=t[0];(n=e.toLowerCase().indexOf(i.toLowerCase(),r))>=0;){if(n>r){var a=e.substring(r,n);o=o.concat(this._applySubHighlights(a,t))}var s=n+i.length;o.push(this._processSnippet(e.substring(n,s),!0)),r=s}return r!==e.length&&(a=e.substring(r,void 0),o=o.concat(this._applySubHighlights(a,t))),o}},{key:"_applySubHighlights",value:function(e,t){return t[1]?this.applyHighlights(e,t.slice(1)):[this._processSnippet(e,!1)]}}]),e}(),$=function(e){function t(){return u()(this,t),o()(this,a()(t).apply(this,arguments))}return c()(t,e),p()(t,[{key:"_processSnippet",value:function(e,t){if(!t)return e;var n=''+e+"";return this.highlightLink&&(n=''+n+""),n}}]),t}(Y);function Q(e,t){var n,r,o,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a="org.matrix.custom.html"===e.format&&e.formatted_body,s=!1,c=W;i.forComposerQuote&&(c=K);try{if(t&&t.length>0){var l=new $("mx_EventTile_searchHighlight",i.highlightLink),u=t.map((function(e){return _()(e,c)}));c.textFilter=function(e){return l.applyHighlights(e,u).join("")}}var d="string"==typeof e.formatted_body?e.formatted_body:null,p="string"==typeof e.body?e.body:null;i.stripReplyFallback&&d&&(d=h.a.stripHTMLReply(d)),n=i.stripReplyFallback?h.a.stripPlainReply(p):p,s=j(a?d:p),a&&(o=!0,r=_()(d,c))}finally{delete c.textFilter}if(i.returnString)return o?r:n;var m=!1;if(!i.disableBigEmoji&&s){var f=void 0!==n?n.trim():"";f=(f=f.replace(P,"")).replace(M,"");var v=L.exec(f);m=v&&v[0]&&v[0].length===f.length&&(null==e.formatted_body||!e.formatted_body.includes("http:")&&!e.formatted_body.includes("https:"))}var b=x()({mx_EventTile_body:!0,mx_EventTile_bigEmoji:m,"markdown-body":a&&!m});return o?g.a.createElement("span",{key:"body",ref:i.ref,className:b,dangerouslySetInnerHTML:{__html:r},dir:"auto"}):g.a.createElement("span",{key:"body",ref:i.ref,className:b,dir:"auto"},n)}function J(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.a.options;return E()(e,t)}function X(e){return _()((t=e,w()(t)),W);var t}function Z(e){switch(e.nodeName){case"H1":case"H2":case"H3":case"H4":case"H5":case"H6":case"PRE":case"BLOCKQUOTE":case"DIV":case"P":case"UL":case"OL":case"LI":case"HR":case"TABLE":case"THEAD":case"TBODY":case"TR":case"TH":case"TD":return!0;default:return!1}}},function(e,t,n){"use strict";n.d(t,"b",(function(){return i})),n.d(t,"a",(function(){return a})),n.d(t,"d",(function(){return s})),n.d(t,"f",(function(){return c})),n.d(t,"c",(function(){return l})),n.d(t,"e",(function(){return u})),n.d(t,"n",(function(){return d})),n.d(t,"m",(function(){return p})),n.d(t,"h",(function(){return h})),n.d(t,"g",(function(){return m})),n.d(t,"i",(function(){return g})),n.d(t,"j",(function(){return f})),n.d(t,"l",(function(){return _})),n.d(t,"k",(function(){return v}));var r=n(4),o=n(110),i="all_messages_loud",a="all_messages",s="mentions_only",c="mute",l=[a,i],u=[].concat(l,[s]);function d(e){return l.includes(e)}function p(e){return u.includes(e)}function h(e){return e.reduce((function(e,t,n){var o=f(t.roomId),i=t.getUnreadNotificationCount("highlight")>0,a=t.getUnreadNotificationCount()>0&&d(o),s=i&&p(o),c=t.hasMembershipState(r.a.get().credentials.userId,"invite");return(a||s||c)&&(e.count++,i&&(e.highlight=!0)),e}),{count:0,highlight:!1})}function m(e){return e.reduce((function(e,t,n){var r=f(t.roomId),o=t.getUnreadNotificationCount("highlight")>0,i=t.getUnreadNotificationCount(),a=i>0&&d(r),s=o&&p(r);return(a||s)&&(e.count+=i,o&&(e.highlight=!0)),e}),{count:0,highlight:!1})}function g(e){var t=f(e.roomId),n=e.getUnreadNotificationCount("highlight")>0,r=e.getUnreadNotificationCount()>0&&d(t),o=n&&p(t);return r||o}function f(e){if(r.a.get().isGuest())return a;if(b(e))return c;var t=null;try{t=r.a.get().getRoomPushRule("global",e)}catch(e){return null}return t&&t.enabled?E(t)?s:o.a.actionListToActionsObject(t.actions).tweaks.sound?i:null:a}function _(e,t){return t===c?function(e){var t=r.a.get(),n=[],o=t.getRoomPushRule("global",e);o&&n.push(t.deletePushRule("global","room",o.rule_id));return n.push(t.addPushRule("global","override",e,{conditions:[{kind:"event_match",key:"room_id",pattern:e}],actions:["dont_notify"]})),Promise.all(n)}(e):function(e,t){var n=r.a.get(),o=[],i=b(e);i&&o.push(n.deletePushRule("global","override",i.rule_id));if("all_messages"===t){var a=n.getRoomPushRule("global",e);a&&o.push(n.deletePushRule("global","room",a.rule_id))}else"mentions_only"===t?(o.push(n.addPushRule("global","room",e,{actions:["dont_notify"]})),o.push(n.setPushRuleEnabled("global","room",e,!0))):(o.push(n.addPushRule("global","room",e,{actions:["notify",{set_tweak:"sound",value:"default"}]})),o.push(n.setPushRuleEnabled("global","room",e,!0)));return Promise.all(o)}(e,t)}function v(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=e.getUnreadNotificationCount(t),o=e.currentState.getStateEvents("m.room.create","");if(o&&o.getContent().predecessor){var i=o.getContent().predecessor.room_id,a=r.a.get().getRoom(i);a&&(n+=a.getUnreadNotificationCount("highlight"))}return n}function b(e){if(!r.a.get().pushRules||!r.a.get().pushRules.global||!r.a.get().pushRules.global.override)return null;var t=!0,n=!1,o=void 0;try{for(var i,a=r.a.get().pushRules.global.override[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var s=i.value;if(y(e,s)&&E(s)&&s.enabled)return s}}catch(e){n=!0,o=e}finally{try{t||null==a.return||a.return()}finally{if(n)throw o}}return null}function y(e,t){if(1!==t.conditions.length)return!1;var n=t.conditions[0];return"event_match"===n.kind&&"room_id"===n.key&&n.pattern===e}function E(e){return 1===e.actions.length&&"dont_notify"===e.actions[0]}},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r=n(9),o=n.n(r),i=n(8),a=n.n(i),s=n(4),c=n(221),l=n.n(c),u=(n(109),function(){function e(t){o()(this,e),this.matrixClient=t,this.roomToUser=null,this._hasSentOutPatchDirectAccountDataPatch=!1,this._onAccountData=this._onAccountData.bind(this);var n=t.getAccountData("m.direct");this.mDirectEvent=n?n.getContent():{},this.userToRooms=null}return a()(e,[{key:"start",value:function(){this._populateRoomToUser(),this.matrixClient.on("accountData",this._onAccountData)}},{key:"stop",value:function(){this.matrixClient.removeListener("accountData",this._onAccountData)}},{key:"_onAccountData",value:function(e){"m.direct"==e.getType()&&(this.mDirectEvent=this.matrixClient.getAccountData("m.direct").getContent()||{},this.userToRooms=null,this.roomToUser=null)}},{key:"_patchUpSelfDMs",value:function(e){var t=this,n=this.matrixClient.getUserId(),r=e[n];if(r){var o=r.map((function(e){var r=t.matrixClient.getRoom(e);if(r){var o=r.guessDMUserId();if(o&&o!==n)return{userId:o,roomId:e}}})).filter((function(e){return!!e}));return!!o.length&&(e[n]=r.filter((function(e){return!o.some((function(t){return t.roomId===e}))})),o.forEach((function(t){var n=t.userId,r=t.roomId,o=e[n];o?(o.push(r),e[n]=l()(o)):e[n]=[r]})),!0)}}},{key:"getDMRoomsForUserId",value:function(e){return this._getUserToRooms()[e]||[]}},{key:"getDMRoomForIdentifiers",value:function(e){for(var t=this,n=this.getDMRoomsForUserId(e[0]),r=function(r){var o=t.getDMRoomsForUserId(e[r]);n=n.filter((function(e){return o.includes(e)}))},o=1;o0&&void 0!==n[0])||n[0],console.log("Lifecycle: Starting MatrixClient"),R.a.dispatch({action:"will_start_client"},!0),k.default.start(),x.a.sharedInstance().start(),j.a.sharedInstance().reset(),G.a.sharedInstance().reset(),B.b.getValue("lowBandwidth")||F.start(),I.a.makeShared().start(),q.a.sharedInstance().startWatching(),M.a.start(),V.a.sharedInstance().start(),!t){e.next=19;break}return e.next=15,y.a.start();case 15:return e.next=17,E.a.init();case 17:e.next=22;break;case 19:return console.warn("Caller requested only auxiliary services be started"),e.next=22,y.a.assign();case 22:H.a.sharedInstance().start(),R.a.dispatch({action:"client_started"}),pe()&&de();case 25:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function fe(){return _e.apply(this,arguments)}function _e(){return(_e=v()(o.a.mark((function e(){return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return le=!1,R.a.dispatch({action:"on_logged_out"},!0),ye(),e.next=5,ve();case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ve(){return be.apply(this,arguments)}function be(){return(be=v()(o.a.mark((function e(){var t;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return w.a.logout(),window.localStorage&&window.localStorage.clear(),t=Object(S.a)({baseUrl:""}),e.next=5,E.a.deleteEventIndex();case 5:return e.next=7,t.clearStores();case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ye(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];k.default.stop(),x.a.sharedInstance().stop(),j.a.sharedInstance().reset(),F.stop(),M.a.stop(),q.a.sharedInstance().stopWatching(),V.a.sharedInstance().stop(),H.a.sharedInstance().stop(),I.a.shared()&&I.a.shared().stop(),E.a.stop();var t=y.a.get();t&&(t.stopClient(),t.removeAllListeners(),e&&(y.a.unset(),E.a.unset()))}},function(e,t,n){"use strict";n.d(t,"c",(function(){return s})),n.d(t,"d",(function(){return c})),n.d(t,"b",(function(){return u})),n.d(t,"a",(function(){return d}));var r=n(6),o=n.n(r),i=n(16),a=n.n(i),s=function(e,t){return new Promise((function(n){setTimeout(n,e,t)}))};function c(e,t,n){return l.apply(this,arguments)}function l(){return(l=a()(o.a.mark((function e(t,n,r){var i;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new Promise((function(e){var o=setTimeout(e,r,n);t.then((function(){clearTimeout(o)}))})),e.abrupt("return",Promise.race([t,i]));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function u(){var e,t,n=new Promise((function(n,r){e=n,t=r}));return{resolve:e,reject:t,promise:n}}function d(e){return Promise.allSettled?Promise.allSettled(e):Promise.all(e.map((function(e){return e.then((function(e){return{status:"fulfilled",value:e}})).catch((function(e){return{status:"rejected",reason:e}}))})))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o})),n.d(t,"h",(function(){return i})),n.d(t,"e",(function(){return a})),n.d(t,"g",(function(){return s})),n.d(t,"f",(function(){return c})),n.d(t,"d",(function(){return l})),n.d(t,"i",(function(){return u})),n.d(t,"c",(function(){return d})),n.d(t,"b",(function(){return p}));var r=n(41);function o(e,t){return function(n){return function(e,t,n){return(n=n||{}).code=e,n.reason=t,new r.b({type:"m.key.verification.cancel",content:n})}(e,t,n)}}var i=o("m.user","Cancelled by user"),a=o("m.timeout","Timed out"),s=(o("m.unknown_transaction","Unknown transaction"),o("m.unknown_method","Unknown method")),c=o("m.unexpected_message","Unexpected message"),l=o("m.key_mismatch","Key mismatch"),u=o("m.user_error","User mismatch"),d=o("m.invalid_message","Invalid message");function p(e){var t=e.getContent();return t?{code:t.code,reason:t.reason}:{code:"Unknown error",reason:"m.unknown"}}},function(e,t,n){"use strict";(function(e){var r=n(9),o=n.n(r),i=n(8),a=n.n(i),s=n(13),c=n.n(s),l=n(12),u=n.n(l),d=n(7),p=n.n(d),h=n(14),m=n.n(h),g=n(45),f=n.n(g),_=n(4),v=function(e){function t(){var e;return o()(this,t),(e=c()(this,u()(t).call(this)))._persistentWidgetId=null,e._capsByWidgetId={},e._widgetMessagingByWidgetId={},e._roomIdByWidgetId={},e.onRoomStateEvents=e.onRoomStateEvents.bind(p()(e)),e.dispatcherRef=null,e}return m()(t,e),a()(t,[{key:"start",value:function(){_.a.get().on("RoomState.events",this.onRoomStateEvents)}},{key:"stop",value:function(){_.a.get()&&_.a.get().removeListener("RoomState.events",this.onRoomStateEvents),this._capsByWidgetId={},this._widgetMessagingByWidgetId={},this._roomIdByWidgetId={}}},{key:"onRoomStateEvents",value:function(e,t){"im.vector.modular.widgets"===e.getType()&&e.getStateKey()===this._persistentWidgetId&&this.destroyPersistentWidget(this._persistentWidgetId)}},{key:"destroyPersistentWidget",value:function(e){if(e===this._persistentWidgetId){var t=this._persistentWidgetId;this.setWidgetPersistence(t,!1),this.delWidgetMessaging(t),this.delWidgetCapabilities(t),this.delRoomId(t)}}},{key:"setWidgetPersistence",value:function(e,t){this._persistentWidgetId!==e||t?this._persistentWidgetId!==e&&t&&(this._persistentWidgetId=e):this._persistentWidgetId=null,this.emit("update")}},{key:"getWidgetPersistence",value:function(e){return this._persistentWidgetId===e}},{key:"getPersistentWidgetId",value:function(){return this._persistentWidgetId}},{key:"setWidgetCapabilities",value:function(e,t){this._capsByWidgetId[e]=t,this.emit("update")}},{key:"widgetHasCapability",value:function(e,t){return this._capsByWidgetId[e]&&this._capsByWidgetId[e].includes(t)}},{key:"delWidgetCapabilities",value:function(e){delete this._capsByWidgetId[e],this.emit("update")}},{key:"setWidgetMessaging",value:function(e,t){this.delWidgetMessaging(e),this._widgetMessagingByWidgetId[e]=t,this.emit("update")}},{key:"getWidgetMessaging",value:function(e){return this._widgetMessagingByWidgetId[e]}},{key:"delWidgetMessaging",value:function(e){if(this._widgetMessagingByWidgetId[e]){try{this._widgetMessagingByWidgetId[e].stop()}catch(e){console.error("Failed to stop listening for widgetMessaging events",e.message)}delete this._widgetMessagingByWidgetId[e],this.emit("update")}}},{key:"getRoomId",value:function(e){return this._roomIdByWidgetId[e]}},{key:"setRoomId",value:function(e,t){this._roomIdByWidgetId[e]=t,this.emit("update")}},{key:"delRoomId",value:function(e){delete this._roomIdByWidgetId[e],this.emit("update")}}]),t}(f.a);void 0===e.singletonActiveWidgetStore&&(e.singletonActiveWidgetStore=new v),t.a=e.singletonActiveWidgetStore}).call(this,n(34))},function(e,t,n){"use strict";n.d(t,"a",(function(){return c})),n.d(t,"c",(function(){return l})),n.d(t,"b",(function(){return u})),n.d(t,"d",(function(){return p})),n.d(t,"e",(function(){return h}));var r=n(1);function o(){return[Object(r.a)("Sun"),Object(r.a)("Mon"),Object(r.a)("Tue"),Object(r.a)("Wed"),Object(r.a)("Thu"),Object(r.a)("Fri"),Object(r.a)("Sat")]}function i(){return[Object(r.a)("Jan"),Object(r.a)("Feb"),Object(r.a)("Mar"),Object(r.a)("Apr"),Object(r.a)("May"),Object(r.a)("Jun"),Object(r.a)("Jul"),Object(r.a)("Aug"),Object(r.a)("Sep"),Object(r.a)("Oct"),Object(r.a)("Nov"),Object(r.a)("Dec")]}function a(e){return(e<10?"0":"")+e}function s(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=e.getHours()%12,o=a(e.getMinutes()),i=e.getHours()>=12?Object(r.a)("PM"):Object(r.a)("AM");if(n=n||12,t){var s=a(e.getSeconds());return"".concat(n,":").concat(o,":").concat(s).concat(i)}return"".concat(n,":").concat(o).concat(i)}function c(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=new Date,a=o(),s=i();return e.toDateString()===n.toDateString()?p(e,t):n.getTime()-e.getTime()<5184e5?Object(r.a)("%(weekDayName)s %(time)s",{weekDayName:a[e.getDay()],time:p(e,t)}):n.getFullYear()===e.getFullYear()?Object(r.a)("%(weekDayName)s, %(monthName)s %(day)s %(time)s",{weekDayName:a[e.getDay()],monthName:s[e.getMonth()],day:e.getDate(),time:p(e,t)}):u(e,t)}function l(e){var t=o(),n=i();return Object(r.a)("%(weekDayName)s, %(monthName)s %(day)s %(fullYear)s",{weekDayName:t[e.getDay()],monthName:n[e.getMonth()],day:e.getDate(),fullYear:e.getFullYear()})}function u(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=o(),a=i();return Object(r.a)("%(weekDayName)s, %(monthName)s %(day)s %(fullYear)s %(time)s",{weekDayName:n[e.getDay()],monthName:a[e.getMonth()],day:e.getDate(),fullYear:e.getFullYear(),time:d(e,t)})}function d(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return t?s(e,!0):a(e.getHours())+":"+a(e.getMinutes())+":"+a(e.getSeconds())}function p(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return t?s(e):a(e.getHours())+":"+a(e.getMinutes())}function h(e,t){return!(!t||!e)&&(Math.abs(e.getTime()-t.getTime())>864e5||e.getDay()!==t.getDay())}},function(e,t,n){"use strict";n.d(t,"e",(function(){return g})),n.d(t,"d",(function(){return _})),n.d(t,"g",(function(){return v})),n.d(t,"c",(function(){return b})),n.d(t,"f",(function(){return y})),n.d(t,"a",(function(){return E})),n.d(t,"b",(function(){return w}));var r=n(6),o=n.n(r),i=n(16),a=n.n(i),s=n(9),c=n.n(s),l=n(8),u=n.n(l),d=n(5),p=n.n(d),h=n(203),m=n(4),g="m.room.rule.user",f="m.room.rule.room",_="m.room.rule.server",v=[g,"org.matrix.mjolnir.rule.user"],b=[f,"org.matrix.mjolnir.rule.room"],y=[_,"org.matrix.mjolnir.rule.server"],E=[].concat(v,b,y);function S(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return v.includes(e)?t?v[v.length-1]:g:b.includes(e)?t?b[b.length-1]:f:y.includes(e)?t?y[y.length-1]:_:null}var w=function(){function e(t){c()(this,e),p()(this,"_rules",[]),p()(this,"_roomId",void 0),this._roomId=t,this.updateList()}var t,n;return u()(e,[{key:"banEntity",value:(n=a()(o.a.mark((function e(t,n,r){return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,m.a.get().sendStateEvent(this._roomId,S(t,!0),{entity:n,reason:r,recommendation:Object(h.c)(h.b,!0)},"rule:"+n);case 2:this._rules.push(new h.a(n,h.b,r,S(t,!1)));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"unbanEntity",value:(t=a()(o.a.mark((function e(t,n){return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,m.a.get().sendStateEvent(this._roomId,S(t,!0),{},"rule:"+n);case 2:this._rules=this._rules.filter((function(e){return e.kind!==S(t,!1)||e.entity!==n}));case 3:case"end":return e.stop()}}),e,this)}))),function(e,n){return t.apply(this,arguments)})},{key:"updateList",value:function(){this._rules=[];var e=m.a.get().getRoom(this._roomId);if(e){var t=!0,n=!1,r=void 0;try{for(var o,i=E[Symbol.iterator]();!(t=(o=i.next()).done);t=!0){var a=o.value,s=e.currentState.getStateEvents(a,void 0),c=!0,l=!1,u=void 0;try{for(var d,p=s[Symbol.iterator]();!(c=(d=p.next()).done);c=!0){var g=d.value;if(g.getStateKey()){var f=S(a,!1),_=g.getContent().entity,v=g.getContent().recommendation,b=g.getContent().reason;_&&v&&b&&this._rules.push(new h.a(_,v,b,f))}}}catch(e){l=!0,u=e}finally{try{c||null==p.return||p.return()}finally{if(l)throw u}}}}catch(e){n=!0,r=e}finally{try{t||null==i.return||i.return()}finally{if(n)throw r}}}}},{key:"roomId",get:function(){return this._roomId}},{key:"serverRules",get:function(){return this._rules.filter((function(e){return e.kind===_}))}},{key:"userRules",get:function(){return this._rules.filter((function(e){return e.kind===g}))}},{key:"roomRules",get:function(){return this._rules.filter((function(e){return e.kind===f}))}}]),e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return o})),n.d(t,"b",(function(){return i}));var r=n(20);function o(e,t,n,o,i,a){if("string"!=typeof t||!t)return"";if(0!==t.indexOf("mxc://"))return a?t:"";var s=t.slice(6),c="/_matrix/media/r0/download/",l={};n&&(l.width=Math.round(n)),o&&(l.height=Math.round(o)),i&&(l.method=i),r.s(l).length>0&&(c="/_matrix/media/r0/thumbnail/");var u=s.indexOf("#"),d="";return u>=0&&(d=s.substr(u),s=s.substr(0,u)),e+c+s+(0===r.s(l).length?"":"?"+r.e(l))+d}function i(e,t,n,o){if(!t)return null;n||(n=96),o||(o=96);var i={width:n,height:o};return e+r.f("/_matrix/media/unstable/identicon/$ident",{$ident:t})+(0===r.s(i).length?"":"?"+r.e(i))}},function(e,t){function n(t){return e.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},n(t)}e.exports=n},function(e,t,n){var r,o,i;o=[],void 0===(i="function"==typeof(r=function(){var e=XMLHttpRequest;if(!e)throw new Error("missing XMLHttpRequest");function t(i,a){if("function"!=typeof a)throw new Error("Bad callback given: "+a);if(!i)throw new Error("No options given");var s=i.onResponse;if((i="string"==typeof i?{uri:i}:JSON.parse(JSON.stringify(i))).onResponse=s,i.verbose&&(t.log=function(){var e,t,n={},i=["trace","debug","info","warn","error"];for(t=0;t>18&63,i=c>>12&63,a=c>>6&63,s=63&c,h[d++]=l.charAt(o)+l.charAt(i)+l.charAt(a)+l.charAt(s)}while(u299)&&r.error){for(var o in e=new Error("CouchDB error: "+(r.error.reason||r.error.error)),r)e[o]=r[o];return n(e,t,r)}return n(e,t,r)}))},t})?r.apply(t,o):r)||(e.exports=i)},function(e,t,n){"use strict";n.d(t,"a",(function(){return y}));var r=n(9),o=n.n(r),i=n(8),a=n.n(i),s=n(13),c=n.n(s),l=n(12),u=n.n(l),d=n(14),p=n.n(d),h=n(5),m=n.n(h),g=n(0),f=n.n(g),_=n(2),v=n.n(_),b=n(144),y=function(e){function t(){return o()(this,t),c()(this,u()(t).apply(this,arguments))}return p()(t,e),a()(t,[{key:"render",value:function(){var e=f.a.createElement("span",{className:"mx_SettingsFlag_label"},this.props.label),t=f.a.createElement(b.a,{checked:this.props.value,disabled:this.props.disabled,onChange:this.props.onChange,"aria-label":this.props.label});if(this.props.toggleInFront){var n=e;e=t,t=n}return f.a.createElement("div",{className:"mx_SettingsFlag"},e,t)}}]),t}(f.a.Component);m()(y,"propTypes",{value:v.a.bool.isRequired,onChange:v.a.func.isRequired,label:v.a.string.isRequired,disabled:v.a.bool,toggleInFront:v.a.bool})},function(e,t,n){var r=n(77),o=n(133);e.exports=function(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?o(e):t}},function(e,t,n){var r=n(225);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&r(e,t)}},function(e,t,n){"use strict";(function(e){var r=n(6),o=n.n(r),i=n(16),a=n.n(i),s=n(4),c=n(35),l=n(18),u=n(3),d=n(1),p=n(23),h=n(10),m=n(26),g=n(177),f=n(51),_=n(98),v=n(55),b=n(15);e.mxCalls={};var y=e.mxCalls,E=null,S={};function w(e){var t=document.getElementById(e);if(t){var n=function(){var e=a()(o.a.mark((function e(){return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t.play();case 3:e.next=8;break;case 5:e.prev=5,e.t0=e.catch(0),console.log("Unable to play audio clip",e.t0);case 8:case"end":return e.stop()}}),e,null,[[0,5]])})));return function(){return e.apply(this,arguments)}}();S[e]?S[e]=S[e].then((function(){return t.load(),n()})):S[e]=n()}}function k(e){var t=document.getElementById(e);t&&(S[e]?S[e]=S[e].then((function(){return t.pause()})):S[e]=t.pause())}function x(e){e.on("error",(function(t){if(console.error("Call error:",t),"unknown_devices"===t.code){var n=u.a("dialogs.QuestionDialog");l.a.createTrackedDialog("Call Failed","",n,{title:Object(d.a)("Call Failed"),description:Object(d.a)("There are unknown devices in this room: if you proceed without verifying them, it will be possible for someone to eavesdrop on your call."),button:Object(d.a)("Review Devices"),onFinished:function(t){if(t){var n=s.a.get().getRoom(e.roomId);Object(g.c)(s.a.get(),n,(function(){!function(e){"outbound"===e.direction?h.a.dispatch({action:"place_call",room_id:e.roomId,type:e.type}):e.answer()}(e)}),"outbound"===e.direction?Object(d.a)("Call Anyway"):Object(d.a)("Answer Anyway"),"outbound"===e.direction?Object(d.a)("Call"):Object(d.a)("Answer"))}}})}else{if(0===s.a.get().getTurnServers().length&&null===b.b.getValue("fallbackICEServerAllowed"))return void function(){var e=s.a.get(),t=u.a("dialogs.QuestionDialog"),n=function(e){return React.createElement("code",null,e)};l.a.createTrackedDialog("No TURN servers","",t,{title:Object(d.a)("Call failed due to misconfigured server"),description:React.createElement("div",null,React.createElement("p",null,Object(d.a)("Please ask the administrator of your homeserver (%(homeserverDomain)s) to configure a TURN server in order for calls to work reliably.",{homeserverDomain:e.getDomain()},{code:n})),React.createElement("p",null,Object(d.a)("Alternatively, you can try to use the public server at turn.matrix.org, but this will not be as reliable, and it will share your IP address with that server. You can also manage this in Settings.",null,{code:n}))),button:Object(d.a)("Try using turn.matrix.org"),cancelButton:Object(d.a)("OK"),onFinished:function(t){b.b.setValue("fallbackICEServerAllowed",null,b.a.DEVICE,t),e.setFallbackICEServerAllowed(t)}},null,!0)}();var r=u.a("dialogs.ErrorDialog");l.a.createTrackedDialog("Call Failed","",r,{title:Object(d.a)("Call Failed"),description:t.message})}})),e.on("hangup",(function(){C(void 0,e.roomId,"ended")})),e.on("state",(function(t,n){if("ringing"===t)C(e,e.roomId,"ringing"),k("ringbackAudio");else if("invite_sent"===t)C(e,e.roomId,"ringback"),w("ringbackAudio");else if("ended"===t&&"connected"===n)C(void 0,e.roomId,"ended"),k("ringbackAudio"),w("callendAudio");else if("ended"===t&&"invite_sent"===n&&("remote"===e.hangupParty||"local"===e.hangupParty&&"invite_timeout"===e.hangupReason)){C(e,e.roomId,"busy"),k("ringbackAudio"),w("busyAudio");var r=u.a("dialogs.ErrorDialog");l.a.createTrackedDialog("Call Handler","Call Timeout",r,{title:Object(d.a)("Call Timeout"),description:Object(d.a)("The remote side failed to pick up")+"."})}else"invite_sent"===n?(C(e,e.roomId,"stop_ringback"),k("ringbackAudio")):"ringing"===n?(C(e,e.roomId,"stop_ringing"),k("ringbackAudio")):"connected"===t&&(C(e,e.roomId,"connected"),k("ringbackAudio"))}))}function C(e,t,n){console.log("Call state in ".concat(t," changed to ").concat(n," (").concat(e?e.call_state:"-",")")),y[t]=e,"ringing"===n?w("ringAudio"):e&&"ringing"===e.call_state&&k("ringAudio"),e&&(e.call_state=n),h.a.dispatch({action:"call_state",room_id:t,state:n})}function T(){return(T=a()(o.a.mark((function e(t,n){var r,i,a,c,p,g,b,y,E,S,w,k,x,C,T;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=v.a.sharedInstance(),i=!1,!r.hasManager()){e.next=12;break}return e.prev=3,a=r.getPrimaryManager().getScalarClient(),e.next=7,a.connect();case 7:i=a.hasCredentials(),e.next=12;break;case 10:e.prev=10,e.t0=e.catch(3);case 12:if(i){e.next=16;break}return c=u.a("dialogs.ErrorDialog"),l.a.createTrackedDialog("Could not connect to the integration server","",c,{title:Object(d.a)("Could not connect to the integration server"),description:Object(d.a)("A conference call could not be started because the integrations server is not available")}),e.abrupt("return");case 16:if(h.a.dispatch({action:"appsDrawer",show:!0}),p=s.a.get().getRoom(t),g=f.a.getRoomWidgets(p),!_.a.roomHasPendingWidgetsOfType(t,g,"jitsi")){e.next=23;break}return b=u.a("dialogs.ErrorDialog"),l.a.createTrackedDialog("Call already in progress","",b,{title:Object(d.a)("Call in Progress"),description:Object(d.a)("A call is currently being placed!")}),e.abrupt("return");case 23:if(!(g.filter((function(e){return"jitsi"===e.getContent().type})).length>0)){e.next=29;break}return console.warn("Refusing to start conference call widget in "+t+" a conference call widget is already present"),y=u.a("dialogs.ErrorDialog"),l.a.createTrackedDialog("Already have Jitsi Widget","",y,{title:Object(d.a)("Call in Progress"),description:Object(d.a)("A call is already in progress!")}),e.abrupt("return");case 29:E=Math.random().toString(36).substring(2),S=p.roomId.replace(/[^A-Za-z0-9]/g,"")+E,w=["confId="+encodeURIComponent(S),"isAudioConf="+("voice"===n?"true":"false"),"displayName=$matrix_display_name","avatarUrl=$matrix_avatar_url","email=$matrix_user_id"].join("&"),m.a.get().integrations_jitsi_widget_url?k=m.a.get().integrations_jitsi_widget_url+"?"+w:(x=v.a.sharedInstance().getPrimaryManager().apiUrl,k=x+"/widgets/jitsi.html?"+w),C={widgetSessionId:E},T="jitsi_"+s.a.get().credentials.userId+"_"+Date.now(),f.a.setRoomWidget(t,T,"jitsi",k,"Jitsi",C).then((function(){console.log("Jitsi widget added")})).catch((function(e){if("M_FORBIDDEN"===e.errcode){var t=u.a("dialogs.ErrorDialog");l.a.createTrackedDialog("Call Failed","",t,{title:Object(d.a)("Permission Required"),description:Object(d.a)("You do not have permission to start a conference call in this room")})}console.error(e)}));case 36:case"end":return e.stop()}}),e,null,[[3,10]])})))).apply(this,arguments)}e.mxCallHandler||(h.a.register((function(e){switch(e.action){case"place_call":if(R.getAnyActiveCall()){var t=u.a("dialogs.ErrorDialog");return void l.a.createTrackedDialog("Call Handler","Existing Call",t,{title:Object(d.a)("Existing Call"),description:Object(d.a)("You are already in a call.")})}if(!s.a.get().supportsVoip()){var n=u.a("dialogs.ErrorDialog");return void l.a.createTrackedDialog("Call Handler","VoIP is unsupported",n,{title:Object(d.a)("VoIP is unsupported"),description:Object(d.a)("You cannot place VoIP calls in this browser.")})}var r=s.a.get().getRoom(e.room_id);if(!r)return void console.error("Room %s does not exist.",e.room_id);var o=r.getJoinedMembers();if(o.length<=1){var i=u.a("dialogs.ErrorDialog");return void l.a.createTrackedDialog("Call Handler","Cannot place call with self",i,{description:Object(d.a)("You cannot place a call with yourself.")})}2===o.length?(console.info("Place %s call in %s",e.type,e.room_id),function(t){if(x(t),"voice"===e.type)t.placeVoiceCall();else if("video"===e.type)t.placeVideoCall(e.remote_element,e.local_element);else if("screensharing"===e.type){var n=c.a.get().screenCaptureErrorString();if(n){C(void 0,t.roomId,"ended"),console.log("Can't capture screen: "+n);var r=u.a("dialogs.ErrorDialog");return void l.a.createTrackedDialog("Call Handler","Unable to capture screen",r,{title:Object(d.a)("Unable to capture screen"),description:n})}t.placeScreenSharingCall(e.remote_element,e.local_element)}else console.error("Unknown conf call type: %s",e.type)}(p.t.createNewMatrixCall(s.a.get(),e.room_id))):h.a.dispatch({action:"place_conference_call",room_id:e.room_id,type:e.type,remote_element:e.remote_element,local_element:e.local_element});break;case"place_conference_call":console.info("Place conference call in %s",e.room_id),function(e,t){T.apply(this,arguments)}(e.room_id,e.type);break;case"incoming_call":if(R.getAnyActiveCall())return;if(!s.a.get().supportsVoip())return;var a=e.call;x(a),C(a,a.roomId,"ringing");break;case"hangup":if(!y[e.room_id])return;y[e.room_id].hangup(),C(null,e.room_id,"ended");break;case"answer":if(!y[e.room_id])return;y[e.room_id].answer(),C(y[e.room_id],e.room_id,"connected"),h.a.dispatch({action:"view_room",room_id:e.room_id})}})),navigator.mediaSession&&(navigator.mediaSession.setActionHandler("play",(function(){})),navigator.mediaSession.setActionHandler("pause",(function(){})),navigator.mediaSession.setActionHandler("seekbackward",(function(){})),navigator.mediaSession.setActionHandler("seekforward",(function(){})),navigator.mediaSession.setActionHandler("previoustrack",(function(){})),navigator.mediaSession.setActionHandler("nexttrack",(function(){}))));var R={getCallForRoom:function(e){var t=R.getCall(e);return t||(E&&(t=E.getConferenceCallForRoom(e)),t||null)},getCall:function(e){return y[e]||null},getAnyActiveCall:function(){for(var e=Object.keys(y),t=0;t