summaryrefslogtreecommitdiffstats
path: root/comm/chat/protocols/matrix/lib/matrix-events-sdk
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /comm/chat/protocols/matrix/lib/matrix-events-sdk
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'comm/chat/protocols/matrix/lib/matrix-events-sdk')
-rw-r--r--comm/chat/protocols/matrix/lib/matrix-events-sdk/ExtensibleEvents.js189
-rw-r--r--comm/chat/protocols/matrix/lib/matrix-events-sdk/IPartialEvent.js5
-rw-r--r--comm/chat/protocols/matrix/lib/matrix-events-sdk/InvalidEventError.js69
-rw-r--r--comm/chat/protocols/matrix/lib/matrix-events-sdk/LICENSE201
-rw-r--r--comm/chat/protocols/matrix/lib/matrix-events-sdk/NamespacedMap.js149
-rw-r--r--comm/chat/protocols/matrix/lib/matrix-events-sdk/NamespacedValue.js166
-rw-r--r--comm/chat/protocols/matrix/lib/matrix-events-sdk/events/EmoteEvent.js99
-rw-r--r--comm/chat/protocols/matrix/lib/matrix-events-sdk/events/ExtensibleEvent.js60
-rw-r--r--comm/chat/protocols/matrix/lib/matrix-events-sdk/events/MessageEvent.js214
-rw-r--r--comm/chat/protocols/matrix/lib/matrix-events-sdk/events/NoticeEvent.js99
-rw-r--r--comm/chat/protocols/matrix/lib/matrix-events-sdk/events/PollEndEvent.js138
-rw-r--r--comm/chat/protocols/matrix/lib/matrix-events-sdk/events/PollResponseEvent.js198
-rw-r--r--comm/chat/protocols/matrix/lib/matrix-events-sdk/events/PollStartEvent.js287
-rw-r--r--comm/chat/protocols/matrix/lib/matrix-events-sdk/events/message_types.js74
-rw-r--r--comm/chat/protocols/matrix/lib/matrix-events-sdk/events/poll_types.js70
-rw-r--r--comm/chat/protocols/matrix/lib/matrix-events-sdk/events/relationship_types.js34
-rw-r--r--comm/chat/protocols/matrix/lib/matrix-events-sdk/index.js278
-rw-r--r--comm/chat/protocols/matrix/lib/matrix-events-sdk/interpreters/legacy/MRoomMessage.js62
-rw-r--r--comm/chat/protocols/matrix/lib/matrix-events-sdk/interpreters/modern/MMessage.js40
-rw-r--r--comm/chat/protocols/matrix/lib/matrix-events-sdk/interpreters/modern/MPoll.js41
-rw-r--r--comm/chat/protocols/matrix/lib/matrix-events-sdk/types.js49
-rw-r--r--comm/chat/protocols/matrix/lib/matrix-events-sdk/utility/MessageMatchers.js59
-rw-r--r--comm/chat/protocols/matrix/lib/matrix-events-sdk/utility/events.js51
23 files changed, 2632 insertions, 0 deletions
diff --git a/comm/chat/protocols/matrix/lib/matrix-events-sdk/ExtensibleEvents.js b/comm/chat/protocols/matrix/lib/matrix-events-sdk/ExtensibleEvents.js
new file mode 100644
index 0000000000..50a2247cb2
--- /dev/null
+++ b/comm/chat/protocols/matrix/lib/matrix-events-sdk/ExtensibleEvents.js
@@ -0,0 +1,189 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.ExtensibleEvents = void 0;
+
+var _NamespacedMap = require("./NamespacedMap");
+
+var _InvalidEventError = require("./InvalidEventError");
+
+var _MRoomMessage = require("./interpreters/legacy/MRoomMessage");
+
+var _MMessage = require("./interpreters/modern/MMessage");
+
+var _message_types = require("./events/message_types");
+
+var _poll_types = require("./events/poll_types");
+
+var _MPoll = require("./interpreters/modern/MPoll");
+
+function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
+
+function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
+
+function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
+
+function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
+
+function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
+
+/**
+ * Utility class for parsing and identifying event types in a renderable form. An
+ * instance of this class can be created to change rendering preference depending
+ * on use-case.
+ */
+var ExtensibleEvents = /*#__PURE__*/function () {
+ function ExtensibleEvents() {
+ _classCallCheck(this, ExtensibleEvents);
+
+ _defineProperty(this, "interpreters", new _NamespacedMap.NamespacedMap([// Remember to add your unit test when adding to this! ("known events" test description)
+ [_MRoomMessage.LEGACY_M_ROOM_MESSAGE, _MRoomMessage.parseMRoomMessage], [_message_types.M_MESSAGE, _MMessage.parseMMessage], [_message_types.M_EMOTE, _MMessage.parseMMessage], [_message_types.M_NOTICE, _MMessage.parseMMessage], [_poll_types.M_POLL_START, _MPoll.parseMPoll], [_poll_types.M_POLL_RESPONSE, _MPoll.parseMPoll], [_poll_types.M_POLL_END, _MPoll.parseMPoll]]));
+
+ _defineProperty(this, "_unknownInterpretOrder", [_message_types.M_MESSAGE]);
+ }
+ /**
+ * Gets the default instance for all extensible event parsing.
+ */
+
+
+ _createClass(ExtensibleEvents, [{
+ key: "unknownInterpretOrder",
+ get:
+ /**
+ * Gets the order the internal processor will use for unknown primary
+ * event types.
+ */
+ function get() {
+ var _this$_unknownInterpr;
+
+ return (_this$_unknownInterpr = this._unknownInterpretOrder) !== null && _this$_unknownInterpr !== void 0 ? _this$_unknownInterpr : [];
+ }
+ /**
+ * Sets the order the internal processor will use for unknown primary
+ * event types.
+ * @param {NamespacedValue<string, string>[]} val The parsing order.
+ */
+ ,
+ set: function set(val) {
+ this._unknownInterpretOrder = val;
+ }
+ /**
+ * Gets the order the internal processor will use for unknown primary
+ * event types.
+ */
+
+ }, {
+ key: "registerInterpreter",
+ value:
+ /**
+ * Registers a primary event type interpreter. Note that the interpreter might be
+ * called with non-primary events if the event is being parsed as a fallback.
+ * @param {NamespacedValue<string, string>} wireEventType The event type.
+ * @param {EventInterpreter} interpreter The interpreter.
+ */
+ function registerInterpreter(wireEventType, interpreter) {
+ this.interpreters.set(wireEventType, interpreter);
+ }
+ /**
+ * Registers a primary event type interpreter. Note that the interpreter might be
+ * called with non-primary events if the event is being parsed as a fallback.
+ * @param {NamespacedValue<string, string>} wireEventType The event type.
+ * @param {EventInterpreter} interpreter The interpreter.
+ */
+
+ }, {
+ key: "parse",
+ value:
+ /**
+ * Parses an event, trying the primary event type first. If the primary type is not known
+ * then the content will be inspected to find the most suitable fallback.
+ *
+ * If the parsing failed or was a completely unknown type, this will return falsy.
+ * @param {IPartialEvent<object>} wireFormat The event to parse.
+ * @returns {Optional<ExtensibleEvent>} The parsed extensible event.
+ */
+ function parse(wireFormat) {
+ try {
+ if (this.interpreters.hasNamespaced(wireFormat.type)) {
+ return this.interpreters.getNamespaced(wireFormat.type)(wireFormat);
+ }
+
+ var _iterator = _createForOfIteratorHelper(this.unknownInterpretOrder),
+ _step;
+
+ try {
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
+ var tryType = _step.value;
+
+ if (this.interpreters.has(tryType)) {
+ var val = this.interpreters.get(tryType)(wireFormat);
+ if (val) return val;
+ }
+ }
+ } catch (err) {
+ _iterator.e(err);
+ } finally {
+ _iterator.f();
+ }
+
+ return null; // cannot be parsed
+ } catch (e) {
+ if (e instanceof _InvalidEventError.InvalidEventError) {
+ return null; // fail parsing and move on
+ }
+
+ throw e; // re-throw everything else
+ }
+ }
+ /**
+ * Parses an event, trying the primary event type first. If the primary type is not known
+ * then the content will be inspected to find the most suitable fallback.
+ *
+ * If the parsing failed or was a completely unknown type, this will return falsy.
+ * @param {IPartialEvent<object>} wireFormat The event to parse.
+ * @returns {Optional<ExtensibleEvent>} The parsed extensible event.
+ */
+
+ }], [{
+ key: "defaultInstance",
+ get: function get() {
+ return ExtensibleEvents._defaultInstance;
+ }
+ }, {
+ key: "unknownInterpretOrder",
+ get: function get() {
+ return ExtensibleEvents.defaultInstance.unknownInterpretOrder;
+ }
+ /**
+ * Sets the order the internal processor will use for unknown primary
+ * event types.
+ * @param {NamespacedValue<string, string>[]} val The parsing order.
+ */
+ ,
+ set: function set(val) {
+ ExtensibleEvents.defaultInstance.unknownInterpretOrder = val;
+ }
+ }, {
+ key: "registerInterpreter",
+ value: function registerInterpreter(wireEventType, interpreter) {
+ ExtensibleEvents.defaultInstance.registerInterpreter(wireEventType, interpreter);
+ }
+ }, {
+ key: "parse",
+ value: function parse(wireFormat) {
+ return ExtensibleEvents.defaultInstance.parse(wireFormat);
+ }
+ }]);
+
+ return ExtensibleEvents;
+}();
+
+exports.ExtensibleEvents = ExtensibleEvents;
+
+_defineProperty(ExtensibleEvents, "_defaultInstance", new ExtensibleEvents()); \ No newline at end of file
diff --git a/comm/chat/protocols/matrix/lib/matrix-events-sdk/IPartialEvent.js b/comm/chat/protocols/matrix/lib/matrix-events-sdk/IPartialEvent.js
new file mode 100644
index 0000000000..430afc16cd
--- /dev/null
+++ b/comm/chat/protocols/matrix/lib/matrix-events-sdk/IPartialEvent.js
@@ -0,0 +1,5 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+}); \ No newline at end of file
diff --git a/comm/chat/protocols/matrix/lib/matrix-events-sdk/InvalidEventError.js b/comm/chat/protocols/matrix/lib/matrix-events-sdk/InvalidEventError.js
new file mode 100644
index 0000000000..a490925ba5
--- /dev/null
+++ b/comm/chat/protocols/matrix/lib/matrix-events-sdk/InvalidEventError.js
@@ -0,0 +1,69 @@
+"use strict";
+
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.InvalidEventError = void 0;
+
+function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
+
+function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
+
+function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
+
+function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
+
+function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
+
+function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
+
+function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
+
+function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
+
+function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
+
+function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
+
+function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
+
+/*
+Copyright 2022 The Matrix.org Foundation C.I.C.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+/**
+ * Thrown when an event is unforgivably unparsable.
+ */
+var InvalidEventError = /*#__PURE__*/function (_Error) {
+ _inherits(InvalidEventError, _Error);
+
+ var _super = _createSuper(InvalidEventError);
+
+ function InvalidEventError(message) {
+ _classCallCheck(this, InvalidEventError);
+
+ return _super.call(this, message);
+ }
+
+ return _createClass(InvalidEventError);
+}( /*#__PURE__*/_wrapNativeSuper(Error));
+
+exports.InvalidEventError = InvalidEventError; \ No newline at end of file
diff --git a/comm/chat/protocols/matrix/lib/matrix-events-sdk/LICENSE b/comm/chat/protocols/matrix/lib/matrix-events-sdk/LICENSE
new file mode 100644
index 0000000000..261eeb9e9f
--- /dev/null
+++ b/comm/chat/protocols/matrix/lib/matrix-events-sdk/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/comm/chat/protocols/matrix/lib/matrix-events-sdk/NamespacedMap.js b/comm/chat/protocols/matrix/lib/matrix-events-sdk/NamespacedMap.js
new file mode 100644
index 0000000000..fe71e2a124
--- /dev/null
+++ b/comm/chat/protocols/matrix/lib/matrix-events-sdk/NamespacedMap.js
@@ -0,0 +1,149 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.NamespacedMap = void 0;
+
+function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
+
+function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
+
+function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
+
+function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
+
+function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
+
+/**
+ * A `Map` implementation which accepts a NamespacedValue as a key, and arbitrary value. The
+ * namespaced value must be a string type.
+ */
+var NamespacedMap = /*#__PURE__*/function () {
+ // protected to make tests happy for access
+
+ /**
+ * Creates a new map with optional seed data.
+ * @param {Array<[NS, V]>} initial The seed data.
+ */
+ function NamespacedMap(initial) {
+ _classCallCheck(this, NamespacedMap);
+
+ _defineProperty(this, "internalMap", new Map());
+
+ if (initial) {
+ var _iterator = _createForOfIteratorHelper(initial),
+ _step;
+
+ try {
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
+ var val = _step.value;
+ this.set(val[0], val[1]);
+ }
+ } catch (err) {
+ _iterator.e(err);
+ } finally {
+ _iterator.f();
+ }
+ }
+ }
+ /**
+ * Gets a value from the map. If the value does not exist under
+ * either namespace option, falsy is returned.
+ * @param {NS} key The key.
+ * @returns {Optional<V>} The value, or falsy.
+ */
+
+
+ _createClass(NamespacedMap, [{
+ key: "get",
+ value: function get(key) {
+ if (key.name && this.internalMap.has(key.name)) {
+ return this.internalMap.get(key.name);
+ }
+
+ if (key.altName && this.internalMap.has(key.altName)) {
+ return this.internalMap.get(key.altName);
+ }
+
+ return null;
+ }
+ /**
+ * Sets a value in the map.
+ * @param {NS} key The key.
+ * @param {V} val The value.
+ */
+
+ }, {
+ key: "set",
+ value: function set(key, val) {
+ if (key.name) {
+ this.internalMap.set(key.name, val);
+ }
+
+ if (key.altName) {
+ this.internalMap.set(key.altName, val);
+ }
+ }
+ /**
+ * Determines if any of the valid namespaced values are present
+ * in the map.
+ * @param {NS} key The key.
+ * @returns {boolean} True if present.
+ */
+
+ }, {
+ key: "has",
+ value: function has(key) {
+ return !!this.get(key);
+ }
+ /**
+ * Removes all the namespaced values from the map.
+ * @param {NS} key The key.
+ */
+
+ }, {
+ key: "delete",
+ value: function _delete(key) {
+ if (key.name) {
+ this.internalMap["delete"](key.name);
+ }
+
+ if (key.altName) {
+ this.internalMap["delete"](key.altName);
+ }
+ }
+ /**
+ * Determines if the map contains a specific namespaced value
+ * instead of the parent NS type.
+ * @param {string} key The key.
+ * @returns {boolean} True if present.
+ */
+
+ }, {
+ key: "hasNamespaced",
+ value: function hasNamespaced(key) {
+ return this.internalMap.has(key);
+ }
+ /**
+ * Gets a specific namespaced value from the map instead of the
+ * parent NS type. Returns falsy if not found.
+ * @param {string} key The key.
+ * @returns {Optional<V>} The value, or falsy.
+ */
+
+ }, {
+ key: "getNamespaced",
+ value: function getNamespaced(key) {
+ return this.internalMap.get(key);
+ }
+ }]);
+
+ return NamespacedMap;
+}();
+
+exports.NamespacedMap = NamespacedMap; \ No newline at end of file
diff --git a/comm/chat/protocols/matrix/lib/matrix-events-sdk/NamespacedValue.js b/comm/chat/protocols/matrix/lib/matrix-events-sdk/NamespacedValue.js
new file mode 100644
index 0000000000..5775b420ac
--- /dev/null
+++ b/comm/chat/protocols/matrix/lib/matrix-events-sdk/NamespacedValue.js
@@ -0,0 +1,166 @@
+"use strict";
+
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.UnstableValue = exports.NamespacedValue = void 0;
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
+
+function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
+
+function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
+
+function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
+
+function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
+
+function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
+
+function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
+
+function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
+
+/*
+Copyright 2021 - 2022 The Matrix.org Foundation C.I.C.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+/**
+ * Represents a simple Matrix namespaced value. This will assume that if a stable prefix
+ * is provided that the stable prefix should be used when representing the identifier.
+ */
+var NamespacedValue = /*#__PURE__*/function () {
+ // Stable is optional, but one of the two parameters is required, hence the weird-looking types.
+ // Goal is to have developers explicitly say there is no stable value (if applicable).
+ function NamespacedValue(stable, unstable) {
+ _classCallCheck(this, NamespacedValue);
+
+ this.stable = stable;
+ this.unstable = unstable;
+
+ if (!this.unstable && !this.stable) {
+ throw new Error("One of stable or unstable values must be supplied");
+ }
+ }
+
+ _createClass(NamespacedValue, [{
+ key: "name",
+ get: function get() {
+ if (this.stable) {
+ return this.stable;
+ }
+
+ return this.unstable;
+ }
+ }, {
+ key: "altName",
+ get: function get() {
+ if (!this.stable) {
+ return null;
+ }
+
+ return this.unstable;
+ }
+ }, {
+ key: "matches",
+ value: function matches(val) {
+ return !!this.name && this.name === val || !!this.altName && this.altName === val;
+ } // this desperately wants https://github.com/microsoft/TypeScript/pull/26349 at the top level of the class
+ // so we can instantiate `NamespacedValue<string, _, _>` as a default type for that namespace.
+
+ }, {
+ key: "findIn",
+ value: function findIn(obj) {
+ var val;
+
+ if (this.name) {
+ val = obj === null || obj === void 0 ? void 0 : obj[this.name];
+ }
+
+ if (!val && this.altName) {
+ val = obj === null || obj === void 0 ? void 0 : obj[this.altName];
+ }
+
+ return val;
+ }
+ }, {
+ key: "includedIn",
+ value: function includedIn(arr) {
+ var included = false;
+
+ if (this.name) {
+ included = arr.includes(this.name);
+ }
+
+ if (!included && this.altName) {
+ included = arr.includes(this.altName);
+ }
+
+ return included;
+ }
+ }]);
+
+ return NamespacedValue;
+}();
+/**
+ * Represents a namespaced value which prioritizes the unstable value over the stable
+ * value.
+ */
+
+
+exports.NamespacedValue = NamespacedValue;
+
+var UnstableValue = /*#__PURE__*/function (_NamespacedValue) {
+ _inherits(UnstableValue, _NamespacedValue);
+
+ var _super = _createSuper(UnstableValue);
+
+ // Note: Constructor difference is that `unstable` is *required*.
+ function UnstableValue(stable, unstable) {
+ var _this;
+
+ _classCallCheck(this, UnstableValue);
+
+ _this = _super.call(this, stable, unstable);
+
+ if (!_this.unstable) {
+ throw new Error("Unstable value must be supplied");
+ }
+
+ return _this;
+ }
+
+ _createClass(UnstableValue, [{
+ key: "name",
+ get: function get() {
+ return this.unstable;
+ }
+ }, {
+ key: "altName",
+ get: function get() {
+ return this.stable;
+ }
+ }]);
+
+ return UnstableValue;
+}(NamespacedValue);
+
+exports.UnstableValue = UnstableValue; \ No newline at end of file
diff --git a/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/EmoteEvent.js b/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/EmoteEvent.js
new file mode 100644
index 0000000000..1b1a2f2cc1
--- /dev/null
+++ b/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/EmoteEvent.js
@@ -0,0 +1,99 @@
+"use strict";
+
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.EmoteEvent = void 0;
+
+var _MessageEvent2 = require("./MessageEvent");
+
+var _message_types = require("./message_types");
+
+var _events = require("../utility/events");
+
+function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
+
+function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
+
+function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
+
+function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
+
+function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
+
+function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
+
+function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
+
+function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
+
+function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
+
+function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
+
+// Emote events are just decorated message events
+
+/**
+ * Represents an emote. This is essentially a MessageEvent with
+ * emote characteristics considered.
+ */
+var EmoteEvent = /*#__PURE__*/function (_MessageEvent) {
+ _inherits(EmoteEvent, _MessageEvent);
+
+ var _super = _createSuper(EmoteEvent);
+
+ function EmoteEvent(wireFormat) {
+ _classCallCheck(this, EmoteEvent);
+
+ return _super.call(this, wireFormat);
+ }
+
+ _createClass(EmoteEvent, [{
+ key: "isEmote",
+ get: function get() {
+ return true; // override
+ }
+ }, {
+ key: "isEquivalentTo",
+ value: function isEquivalentTo(primaryEventType) {
+ return (0, _events.isEventTypeSame)(primaryEventType, _message_types.M_EMOTE) || _get(_getPrototypeOf(EmoteEvent.prototype), "isEquivalentTo", this).call(this, primaryEventType);
+ }
+ }, {
+ key: "serialize",
+ value: function serialize() {
+ var message = _get(_getPrototypeOf(EmoteEvent.prototype), "serialize", this).call(this);
+
+ message.content['msgtype'] = "m.emote";
+ return message;
+ }
+ /**
+ * Creates a new EmoteEvent from text and HTML.
+ * @param {string} text The text.
+ * @param {string} html Optional HTML.
+ * @returns {MessageEvent} The representative message event.
+ */
+
+ }], [{
+ key: "from",
+ value: function from(text, html) {
+ var _content;
+
+ return new EmoteEvent({
+ type: _message_types.M_EMOTE.name,
+ content: (_content = {}, _defineProperty(_content, _message_types.M_TEXT.name, text), _defineProperty(_content, _message_types.M_HTML.name, html), _content)
+ });
+ }
+ }]);
+
+ return EmoteEvent;
+}(_MessageEvent2.MessageEvent);
+
+exports.EmoteEvent = EmoteEvent; \ No newline at end of file
diff --git a/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/ExtensibleEvent.js b/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/ExtensibleEvent.js
new file mode 100644
index 0000000000..e7959d0a39
--- /dev/null
+++ b/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/ExtensibleEvent.js
@@ -0,0 +1,60 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.ExtensibleEvent = void 0;
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
+
+function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
+
+/*
+Copyright 2021 - 2022 The Matrix.org Foundation C.I.C.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+/**
+ * Represents an Extensible Event in Matrix.
+ */
+var ExtensibleEvent = /*#__PURE__*/function () {
+ function ExtensibleEvent(wireFormat) {
+ _classCallCheck(this, ExtensibleEvent);
+
+ this.wireFormat = wireFormat;
+ }
+ /**
+ * Shortcut to wireFormat.content
+ */
+
+
+ _createClass(ExtensibleEvent, [{
+ key: "wireContent",
+ get: function get() {
+ return this.wireFormat.content;
+ }
+ /**
+ * Serializes the event into a format which can be used to send the
+ * event to the room.
+ * @returns {IPartialEvent<object>} The serialized event.
+ */
+
+ }]);
+
+ return ExtensibleEvent;
+}();
+
+exports.ExtensibleEvent = ExtensibleEvent; \ No newline at end of file
diff --git a/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/MessageEvent.js b/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/MessageEvent.js
new file mode 100644
index 0000000000..f11d5867be
--- /dev/null
+++ b/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/MessageEvent.js
@@ -0,0 +1,214 @@
+"use strict";
+
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.MessageEvent = void 0;
+
+var _ExtensibleEvent2 = require("./ExtensibleEvent");
+
+var _types = require("../types");
+
+var _InvalidEventError = require("../InvalidEventError");
+
+var _message_types = require("./message_types");
+
+var _events = require("../utility/events");
+
+function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
+
+function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
+
+function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
+
+function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
+
+function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
+
+function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
+
+function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
+
+function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
+
+function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
+
+function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
+
+/**
+ * Represents a message event. Message events are the simplest form of event with
+ * just text (optionally of different mimetypes, like HTML).
+ *
+ * Message events can additionally be an Emote or Notice, though typically those
+ * are represented as EmoteEvent and NoticeEvent respectively.
+ */
+var MessageEvent = /*#__PURE__*/function (_ExtensibleEvent) {
+ _inherits(MessageEvent, _ExtensibleEvent);
+
+ var _super = _createSuper(MessageEvent);
+
+ /**
+ * The default text for the event.
+ */
+
+ /**
+ * The default HTML for the event, if provided.
+ */
+
+ /**
+ * All the different renderings of the message. Note that this is the same
+ * format as an m.message body but may contain elements not found directly
+ * in the event content: this is because this is interpreted based off the
+ * other information available in the event.
+ */
+
+ /**
+ * Creates a new MessageEvent from a pure format. Note that the event is
+ * *not* parsed here: it will be treated as a literal m.message primary
+ * typed event.
+ * @param {IPartialEvent<M_MESSAGE_EVENT_CONTENT>} wireFormat The event.
+ */
+ function MessageEvent(wireFormat) {
+ var _this;
+
+ _classCallCheck(this, MessageEvent);
+
+ _this = _super.call(this, wireFormat);
+
+ _defineProperty(_assertThisInitialized(_this), "text", void 0);
+
+ _defineProperty(_assertThisInitialized(_this), "html", void 0);
+
+ _defineProperty(_assertThisInitialized(_this), "renderings", void 0);
+
+ var mmessage = _message_types.M_MESSAGE.findIn(_this.wireContent);
+
+ var mtext = _message_types.M_TEXT.findIn(_this.wireContent);
+
+ var mhtml = _message_types.M_HTML.findIn(_this.wireContent);
+
+ if ((0, _types.isProvided)(mmessage)) {
+ if (!Array.isArray(mmessage)) {
+ throw new _InvalidEventError.InvalidEventError("m.message contents must be an array");
+ }
+
+ var text = mmessage.find(function (r) {
+ return !(0, _types.isProvided)(r.mimetype) || r.mimetype === "text/plain";
+ });
+ var html = mmessage.find(function (r) {
+ return r.mimetype === "text/html";
+ });
+ if (!text) throw new _InvalidEventError.InvalidEventError("m.message is missing a plain text representation");
+ _this.text = text.body;
+ _this.html = html === null || html === void 0 ? void 0 : html.body;
+ _this.renderings = mmessage;
+ } else if ((0, _types.isOptionalAString)(mtext)) {
+ _this.text = mtext;
+ _this.html = mhtml;
+ _this.renderings = [{
+ body: mtext,
+ mimetype: "text/plain"
+ }];
+
+ if (_this.html) {
+ _this.renderings.push({
+ body: _this.html,
+ mimetype: "text/html"
+ });
+ }
+ } else {
+ throw new _InvalidEventError.InvalidEventError("Missing textual representation for event");
+ }
+
+ return _this;
+ }
+ /**
+ * Gets whether this message is considered an "emote". Note that a message
+ * might be an emote and notice at the same time: while technically possible,
+ * the event should be interpreted as one or the other.
+ */
+
+
+ _createClass(MessageEvent, [{
+ key: "isEmote",
+ get: function get() {
+ return _message_types.M_EMOTE.matches(this.wireFormat.type) || (0, _types.isProvided)(_message_types.M_EMOTE.findIn(this.wireFormat.content));
+ }
+ /**
+ * Gets whether this message is considered a "notice". Note that a message
+ * might be an emote and notice at the same time: while technically possible,
+ * the event should be interpreted as one or the other.
+ */
+
+ }, {
+ key: "isNotice",
+ get: function get() {
+ return _message_types.M_NOTICE.matches(this.wireFormat.type) || (0, _types.isProvided)(_message_types.M_NOTICE.findIn(this.wireFormat.content));
+ }
+ }, {
+ key: "isEquivalentTo",
+ value: function isEquivalentTo(primaryEventType) {
+ return (0, _events.isEventTypeSame)(primaryEventType, _message_types.M_MESSAGE);
+ }
+ }, {
+ key: "serializeMMessageOnly",
+ value: function serializeMMessageOnly() {
+ var messageRendering = _defineProperty({}, _message_types.M_MESSAGE.name, this.renderings); // Use the shorthand if it's just a simple text event
+
+
+ if (this.renderings.length === 1) {
+ var mime = this.renderings[0].mimetype;
+
+ if (mime === undefined || mime === "text/plain") {
+ messageRendering = _defineProperty({}, _message_types.M_TEXT.name, this.renderings[0].body);
+ }
+ }
+
+ return messageRendering;
+ }
+ }, {
+ key: "serialize",
+ value: function serialize() {
+ var _this$html;
+
+ return {
+ type: "m.room.message",
+ content: _objectSpread(_objectSpread({}, this.serializeMMessageOnly()), {}, {
+ body: this.text,
+ msgtype: "m.text",
+ format: this.html ? "org.matrix.custom.html" : undefined,
+ formatted_body: (_this$html = this.html) !== null && _this$html !== void 0 ? _this$html : undefined
+ })
+ };
+ }
+ /**
+ * Creates a new MessageEvent from text and HTML.
+ * @param {string} text The text.
+ * @param {string} html Optional HTML.
+ * @returns {MessageEvent} The representative message event.
+ */
+
+ }], [{
+ key: "from",
+ value: function from(text, html) {
+ var _content;
+
+ return new MessageEvent({
+ type: _message_types.M_MESSAGE.name,
+ content: (_content = {}, _defineProperty(_content, _message_types.M_TEXT.name, text), _defineProperty(_content, _message_types.M_HTML.name, html), _content)
+ });
+ }
+ }]);
+
+ return MessageEvent;
+}(_ExtensibleEvent2.ExtensibleEvent);
+
+exports.MessageEvent = MessageEvent; \ No newline at end of file
diff --git a/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/NoticeEvent.js b/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/NoticeEvent.js
new file mode 100644
index 0000000000..999d192470
--- /dev/null
+++ b/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/NoticeEvent.js
@@ -0,0 +1,99 @@
+"use strict";
+
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.NoticeEvent = void 0;
+
+var _MessageEvent2 = require("./MessageEvent");
+
+var _message_types = require("./message_types");
+
+var _events = require("../utility/events");
+
+function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
+
+function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
+
+function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
+
+function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
+
+function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
+
+function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
+
+function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
+
+function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
+
+function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
+
+function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
+
+// Notice events are just decorated message events
+
+/**
+ * Represents a notice. This is essentially a MessageEvent with
+ * notice characteristics considered.
+ */
+var NoticeEvent = /*#__PURE__*/function (_MessageEvent) {
+ _inherits(NoticeEvent, _MessageEvent);
+
+ var _super = _createSuper(NoticeEvent);
+
+ function NoticeEvent(wireFormat) {
+ _classCallCheck(this, NoticeEvent);
+
+ return _super.call(this, wireFormat);
+ }
+
+ _createClass(NoticeEvent, [{
+ key: "isNotice",
+ get: function get() {
+ return true; // override
+ }
+ }, {
+ key: "isEquivalentTo",
+ value: function isEquivalentTo(primaryEventType) {
+ return (0, _events.isEventTypeSame)(primaryEventType, _message_types.M_NOTICE) || _get(_getPrototypeOf(NoticeEvent.prototype), "isEquivalentTo", this).call(this, primaryEventType);
+ }
+ }, {
+ key: "serialize",
+ value: function serialize() {
+ var message = _get(_getPrototypeOf(NoticeEvent.prototype), "serialize", this).call(this);
+
+ message.content['msgtype'] = "m.notice";
+ return message;
+ }
+ /**
+ * Creates a new NoticeEvent from text and HTML.
+ * @param {string} text The text.
+ * @param {string} html Optional HTML.
+ * @returns {MessageEvent} The representative message event.
+ */
+
+ }], [{
+ key: "from",
+ value: function from(text, html) {
+ var _content;
+
+ return new NoticeEvent({
+ type: _message_types.M_NOTICE.name,
+ content: (_content = {}, _defineProperty(_content, _message_types.M_TEXT.name, text), _defineProperty(_content, _message_types.M_HTML.name, html), _content)
+ });
+ }
+ }]);
+
+ return NoticeEvent;
+}(_MessageEvent2.MessageEvent);
+
+exports.NoticeEvent = NoticeEvent; \ No newline at end of file
diff --git a/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/PollEndEvent.js b/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/PollEndEvent.js
new file mode 100644
index 0000000000..4c55da81a4
--- /dev/null
+++ b/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/PollEndEvent.js
@@ -0,0 +1,138 @@
+"use strict";
+
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.PollEndEvent = void 0;
+
+var _poll_types = require("./poll_types");
+
+var _InvalidEventError = require("../InvalidEventError");
+
+var _relationship_types = require("./relationship_types");
+
+var _MessageEvent = require("./MessageEvent");
+
+var _message_types = require("./message_types");
+
+var _events = require("../utility/events");
+
+var _ExtensibleEvent2 = require("./ExtensibleEvent");
+
+function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
+
+function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
+
+function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
+
+function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
+
+function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
+
+function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
+
+function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
+
+function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
+
+function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
+
+function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
+
+/**
+ * Represents a poll end/closure event.
+ */
+var PollEndEvent = /*#__PURE__*/function (_ExtensibleEvent) {
+ _inherits(PollEndEvent, _ExtensibleEvent);
+
+ var _super = _createSuper(PollEndEvent);
+
+ /**
+ * The poll start event ID referenced by the response.
+ */
+
+ /**
+ * The closing message for the event.
+ */
+
+ /**
+ * Creates a new PollEndEvent from a pure format. Note that the event is *not*
+ * parsed here: it will be treated as a literal m.poll.response primary typed event.
+ * @param {IPartialEvent<M_POLL_END_EVENT_CONTENT>} wireFormat The event.
+ */
+ function PollEndEvent(wireFormat) {
+ var _this;
+
+ _classCallCheck(this, PollEndEvent);
+
+ _this = _super.call(this, wireFormat);
+
+ _defineProperty(_assertThisInitialized(_this), "pollEventId", void 0);
+
+ _defineProperty(_assertThisInitialized(_this), "closingMessage", void 0);
+
+ var rel = _this.wireContent["m.relates_to"];
+
+ if (!_relationship_types.REFERENCE_RELATION.matches(rel === null || rel === void 0 ? void 0 : rel.rel_type) || typeof (rel === null || rel === void 0 ? void 0 : rel.event_id) !== "string") {
+ throw new _InvalidEventError.InvalidEventError("Relationship must be a reference to an event");
+ }
+
+ _this.pollEventId = rel.event_id;
+ _this.closingMessage = new _MessageEvent.MessageEvent(_this.wireFormat);
+ return _this;
+ }
+
+ _createClass(PollEndEvent, [{
+ key: "isEquivalentTo",
+ value: function isEquivalentTo(primaryEventType) {
+ return (0, _events.isEventTypeSame)(primaryEventType, _poll_types.M_POLL_END);
+ }
+ }, {
+ key: "serialize",
+ value: function serialize() {
+ return {
+ type: _poll_types.M_POLL_END.name,
+ content: _objectSpread(_defineProperty({
+ "m.relates_to": {
+ rel_type: _relationship_types.REFERENCE_RELATION.name,
+ event_id: this.pollEventId
+ }
+ }, _poll_types.M_POLL_END.name, {}), this.closingMessage.serialize().content)
+ };
+ }
+ /**
+ * Creates a new PollEndEvent from a poll event ID.
+ * @param {string} pollEventId The poll start event ID.
+ * @param {string} message A closing message, typically revealing the top answer.
+ * @returns {PollStartEvent} The representative poll closure event.
+ */
+
+ }], [{
+ key: "from",
+ value: function from(pollEventId, message) {
+ var _content;
+
+ return new PollEndEvent({
+ type: _poll_types.M_POLL_END.name,
+ content: (_content = {
+ "m.relates_to": {
+ rel_type: _relationship_types.REFERENCE_RELATION.name,
+ event_id: pollEventId
+ }
+ }, _defineProperty(_content, _poll_types.M_POLL_END.name, {}), _defineProperty(_content, _message_types.M_TEXT.name, message), _content)
+ });
+ }
+ }]);
+
+ return PollEndEvent;
+}(_ExtensibleEvent2.ExtensibleEvent);
+
+exports.PollEndEvent = PollEndEvent; \ No newline at end of file
diff --git a/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/PollResponseEvent.js b/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/PollResponseEvent.js
new file mode 100644
index 0000000000..f060d55bc7
--- /dev/null
+++ b/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/PollResponseEvent.js
@@ -0,0 +1,198 @@
+"use strict";
+
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.PollResponseEvent = void 0;
+
+var _ExtensibleEvent2 = require("./ExtensibleEvent");
+
+var _poll_types = require("./poll_types");
+
+var _InvalidEventError = require("../InvalidEventError");
+
+var _relationship_types = require("./relationship_types");
+
+var _events = require("../utility/events");
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
+
+function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
+
+function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
+
+function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
+
+function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
+
+function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
+
+function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
+
+function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
+
+function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
+
+/**
+ * Represents a poll response event.
+ */
+var PollResponseEvent = /*#__PURE__*/function (_ExtensibleEvent) {
+ _inherits(PollResponseEvent, _ExtensibleEvent);
+
+ var _super = _createSuper(PollResponseEvent);
+
+ /**
+ * Creates a new PollResponseEvent from a pure format. Note that the event is *not*
+ * parsed here: it will be treated as a literal m.poll.response primary typed event.
+ *
+ * To validate the response against a poll, call `validateAgainst` after creation.
+ * @param {IPartialEvent<M_POLL_RESPONSE_EVENT_CONTENT>} wireFormat The event.
+ */
+ function PollResponseEvent(wireFormat) {
+ var _this;
+
+ _classCallCheck(this, PollResponseEvent);
+
+ _this = _super.call(this, wireFormat);
+
+ _defineProperty(_assertThisInitialized(_this), "internalAnswerIds", void 0);
+
+ _defineProperty(_assertThisInitialized(_this), "internalSpoiled", void 0);
+
+ _defineProperty(_assertThisInitialized(_this), "pollEventId", void 0);
+
+ var rel = _this.wireContent["m.relates_to"];
+
+ if (!_relationship_types.REFERENCE_RELATION.matches(rel === null || rel === void 0 ? void 0 : rel.rel_type) || typeof (rel === null || rel === void 0 ? void 0 : rel.event_id) !== "string") {
+ throw new _InvalidEventError.InvalidEventError("Relationship must be a reference to an event");
+ }
+
+ _this.pollEventId = rel.event_id;
+
+ _this.validateAgainst(null);
+
+ return _this;
+ }
+ /**
+ * Validates the poll response using the poll start event as a frame of reference. This
+ * is used to determine if the vote is spoiled, whether the answers are valid, etc.
+ * @param {PollStartEvent} poll The poll start event.
+ */
+
+
+ _createClass(PollResponseEvent, [{
+ key: "answerIds",
+ get:
+ /**
+ * The provided answers for the poll. Note that this may be falsy/unpredictable if
+ * the `spoiled` property is true.
+ */
+ function get() {
+ return this.internalAnswerIds;
+ }
+ /**
+ * The poll start event ID referenced by the response.
+ */
+
+ }, {
+ key: "spoiled",
+ get:
+ /**
+ * Whether the vote is spoiled.
+ */
+ function get() {
+ return this.internalSpoiled;
+ }
+ }, {
+ key: "validateAgainst",
+ value: function validateAgainst(poll) {
+ var response = _poll_types.M_POLL_RESPONSE.findIn(this.wireContent);
+
+ if (!Array.isArray(response === null || response === void 0 ? void 0 : response.answers)) {
+ this.internalSpoiled = true;
+ this.internalAnswerIds = [];
+ return;
+ }
+
+ var answers = response.answers;
+
+ if (answers.some(function (a) {
+ return typeof a !== "string";
+ }) || answers.length === 0) {
+ this.internalSpoiled = true;
+ this.internalAnswerIds = [];
+ return;
+ }
+
+ if (poll) {
+ if (answers.some(function (a) {
+ return !poll.answers.some(function (pa) {
+ return pa.id === a;
+ });
+ })) {
+ this.internalSpoiled = true;
+ this.internalAnswerIds = [];
+ return;
+ }
+
+ answers = answers.slice(0, poll.maxSelections);
+ }
+
+ this.internalAnswerIds = answers;
+ this.internalSpoiled = false;
+ }
+ }, {
+ key: "isEquivalentTo",
+ value: function isEquivalentTo(primaryEventType) {
+ return (0, _events.isEventTypeSame)(primaryEventType, _poll_types.M_POLL_RESPONSE);
+ }
+ }, {
+ key: "serialize",
+ value: function serialize() {
+ return {
+ type: _poll_types.M_POLL_RESPONSE.name,
+ content: _defineProperty({
+ "m.relates_to": {
+ rel_type: _relationship_types.REFERENCE_RELATION.name,
+ event_id: this.pollEventId
+ }
+ }, _poll_types.M_POLL_RESPONSE.name, {
+ answers: this.spoiled ? undefined : this.answerIds
+ })
+ };
+ }
+ /**
+ * Creates a new PollResponseEvent from a set of answers. To spoil the vote, pass an empty
+ * answers array.
+ * @param {string} answers The user's answers. Should be valid from a poll's answer IDs.
+ * @param {string} pollEventId The poll start event ID.
+ * @returns {PollStartEvent} The representative poll response event.
+ */
+
+ }], [{
+ key: "from",
+ value: function from(answers, pollEventId) {
+ return new PollResponseEvent({
+ type: _poll_types.M_POLL_RESPONSE.name,
+ content: _defineProperty({
+ "m.relates_to": {
+ rel_type: _relationship_types.REFERENCE_RELATION.name,
+ event_id: pollEventId
+ }
+ }, _poll_types.M_POLL_RESPONSE.name, {
+ answers: answers
+ })
+ });
+ }
+ }]);
+
+ return PollResponseEvent;
+}(_ExtensibleEvent2.ExtensibleEvent);
+
+exports.PollResponseEvent = PollResponseEvent; \ No newline at end of file
diff --git a/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/PollStartEvent.js b/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/PollStartEvent.js
new file mode 100644
index 0000000000..23bca9d415
--- /dev/null
+++ b/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/PollStartEvent.js
@@ -0,0 +1,287 @@
+"use strict";
+
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.PollStartEvent = exports.PollAnswerSubevent = void 0;
+
+var _poll_types = require("./poll_types");
+
+var _MessageEvent2 = require("./MessageEvent");
+
+var _message_types = require("./message_types");
+
+var _InvalidEventError = require("../InvalidEventError");
+
+var _NamespacedValue = require("../NamespacedValue");
+
+var _events = require("../utility/events");
+
+var _ExtensibleEvent2 = require("./ExtensibleEvent");
+
+function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
+
+function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
+
+function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
+
+function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
+
+function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
+
+function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
+
+function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
+
+function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
+
+function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
+
+function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
+
+function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
+
+function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
+
+function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
+
+function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
+
+function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
+
+function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
+
+/**
+ * Represents a poll answer. Note that this is represented as a subtype and is
+ * not registered as a parsable event - it is implied for usage exclusively
+ * within the PollStartEvent parsing.
+ */
+var PollAnswerSubevent = /*#__PURE__*/function (_MessageEvent) {
+ _inherits(PollAnswerSubevent, _MessageEvent);
+
+ var _super = _createSuper(PollAnswerSubevent);
+
+ /**
+ * The answer ID.
+ */
+ function PollAnswerSubevent(wireFormat) {
+ var _this;
+
+ _classCallCheck(this, PollAnswerSubevent);
+
+ _this = _super.call(this, wireFormat);
+
+ _defineProperty(_assertThisInitialized(_this), "id", void 0);
+
+ var id = wireFormat.content.id;
+
+ if (!id || typeof id !== "string") {
+ throw new _InvalidEventError.InvalidEventError("Answer ID must be a non-empty string");
+ }
+
+ _this.id = id;
+ return _this;
+ }
+
+ _createClass(PollAnswerSubevent, [{
+ key: "serialize",
+ value: function serialize() {
+ return {
+ type: "org.matrix.sdk.poll.answer",
+ content: _objectSpread({
+ id: this.id
+ }, this.serializeMMessageOnly())
+ };
+ }
+ /**
+ * Creates a new PollAnswerSubevent from ID and text.
+ * @param {string} id The answer ID (unique within the poll).
+ * @param {string} text The text.
+ * @returns {PollAnswerSubevent} The representative answer.
+ */
+
+ }], [{
+ key: "from",
+ value: function from(id, text) {
+ return new PollAnswerSubevent({
+ type: "org.matrix.sdk.poll.answer",
+ content: _defineProperty({
+ id: id
+ }, _message_types.M_TEXT.name, text)
+ });
+ }
+ }]);
+
+ return PollAnswerSubevent;
+}(_MessageEvent2.MessageEvent);
+/**
+ * Represents a poll start event.
+ */
+
+
+exports.PollAnswerSubevent = PollAnswerSubevent;
+
+var PollStartEvent = /*#__PURE__*/function (_ExtensibleEvent) {
+ _inherits(PollStartEvent, _ExtensibleEvent);
+
+ var _super2 = _createSuper(PollStartEvent);
+
+ /**
+ * The question being asked, as a MessageEvent node.
+ */
+
+ /**
+ * The interpreted kind of poll. Note that this will infer a value that is known to the
+ * SDK rather than verbatim - this means unknown types will be represented as undisclosed
+ * polls.
+ *
+ * To get the raw kind, use rawKind.
+ */
+
+ /**
+ * The true kind as provided by the event sender. Might not be valid.
+ */
+
+ /**
+ * The maximum number of selections a user is allowed to make.
+ */
+
+ /**
+ * The possible answers for the poll.
+ */
+
+ /**
+ * Creates a new PollStartEvent from a pure format. Note that the event is *not*
+ * parsed here: it will be treated as a literal m.poll.start primary typed event.
+ * @param {IPartialEvent<M_POLL_START_EVENT_CONTENT>} wireFormat The event.
+ */
+ function PollStartEvent(wireFormat) {
+ var _this2;
+
+ _classCallCheck(this, PollStartEvent);
+
+ _this2 = _super2.call(this, wireFormat);
+
+ _defineProperty(_assertThisInitialized(_this2), "question", void 0);
+
+ _defineProperty(_assertThisInitialized(_this2), "kind", void 0);
+
+ _defineProperty(_assertThisInitialized(_this2), "rawKind", void 0);
+
+ _defineProperty(_assertThisInitialized(_this2), "maxSelections", void 0);
+
+ _defineProperty(_assertThisInitialized(_this2), "answers", void 0);
+
+ var poll = _poll_types.M_POLL_START.findIn(_this2.wireContent);
+
+ if (!poll.question) {
+ throw new _InvalidEventError.InvalidEventError("A question is required");
+ }
+
+ _this2.question = new _MessageEvent2.MessageEvent({
+ type: "org.matrix.sdk.poll.question",
+ content: poll.question
+ });
+ _this2.rawKind = poll.kind;
+
+ if (_poll_types.M_POLL_KIND_DISCLOSED.matches(_this2.rawKind)) {
+ _this2.kind = _poll_types.M_POLL_KIND_DISCLOSED;
+ } else {
+ _this2.kind = _poll_types.M_POLL_KIND_UNDISCLOSED; // default & assumed value
+ }
+
+ _this2.maxSelections = Number.isFinite(poll.max_selections) && poll.max_selections > 0 ? poll.max_selections : 1;
+
+ if (!Array.isArray(poll.answers)) {
+ throw new _InvalidEventError.InvalidEventError("Poll answers must be an array");
+ }
+
+ var answers = poll.answers.slice(0, 20).map(function (a) {
+ return new PollAnswerSubevent({
+ type: "org.matrix.sdk.poll.answer",
+ content: a
+ });
+ });
+
+ if (answers.length <= 0) {
+ throw new _InvalidEventError.InvalidEventError("No answers available");
+ }
+
+ _this2.answers = answers;
+ return _this2;
+ }
+
+ _createClass(PollStartEvent, [{
+ key: "isEquivalentTo",
+ value: function isEquivalentTo(primaryEventType) {
+ return (0, _events.isEventTypeSame)(primaryEventType, _poll_types.M_POLL_START);
+ }
+ }, {
+ key: "serialize",
+ value: function serialize() {
+ var _content2;
+
+ return {
+ type: _poll_types.M_POLL_START.name,
+ content: (_content2 = {}, _defineProperty(_content2, _poll_types.M_POLL_START.name, {
+ question: this.question.serialize().content,
+ kind: this.rawKind,
+ max_selections: this.maxSelections,
+ answers: this.answers.map(function (a) {
+ return a.serialize().content;
+ })
+ }), _defineProperty(_content2, _message_types.M_TEXT.name, "".concat(this.question.text, "\n").concat(this.answers.map(function (a, i) {
+ return "".concat(i + 1, ". ").concat(a.text);
+ }).join("\n"))), _content2)
+ };
+ }
+ /**
+ * Creates a new PollStartEvent from question, answers, and metadata.
+ * @param {string} question The question to ask.
+ * @param {string} answers The answers. Should be unique within each other.
+ * @param {KNOWN_POLL_KIND|string} kind The kind of poll.
+ * @param {number} maxSelections The maximum number of selections. Must be 1 or higher.
+ * @returns {PollStartEvent} The representative poll start event.
+ */
+
+ }], [{
+ key: "from",
+ value: function from(question, answers, kind) {
+ var _content3;
+
+ var maxSelections = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
+ return new PollStartEvent({
+ type: _poll_types.M_POLL_START.name,
+ content: (_content3 = {}, _defineProperty(_content3, _message_types.M_TEXT.name, question), _defineProperty(_content3, _poll_types.M_POLL_START.name, {
+ question: _defineProperty({}, _message_types.M_TEXT.name, question),
+ kind: kind instanceof _NamespacedValue.NamespacedValue ? kind.name : kind,
+ max_selections: maxSelections,
+ answers: answers.map(function (a) {
+ return _defineProperty({
+ id: makeId()
+ }, _message_types.M_TEXT.name, a);
+ })
+ }), _content3)
+ });
+ }
+ }]);
+
+ return PollStartEvent;
+}(_ExtensibleEvent2.ExtensibleEvent);
+
+exports.PollStartEvent = PollStartEvent;
+var LETTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+
+function makeId() {
+ return _toConsumableArray(Array(16)).map(function () {
+ return LETTERS.charAt(Math.floor(Math.random() * LETTERS.length));
+ }).join('');
+} \ No newline at end of file
diff --git a/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/message_types.js b/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/message_types.js
new file mode 100644
index 0000000000..a466668bc1
--- /dev/null
+++ b/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/message_types.js
@@ -0,0 +1,74 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.M_TEXT = exports.M_NOTICE = exports.M_MESSAGE = exports.M_HTML = exports.M_EMOTE = void 0;
+
+var _NamespacedValue = require("../NamespacedValue");
+
+/*
+Copyright 2022 The Matrix.org Foundation C.I.C.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+/**
+ * The namespaced value for m.message
+ */
+var M_MESSAGE = new _NamespacedValue.UnstableValue("m.message", "org.matrix.msc1767.message");
+/**
+ * An m.message event rendering
+ */
+
+exports.M_MESSAGE = M_MESSAGE;
+
+/**
+ * The namespaced value for m.text
+ */
+var M_TEXT = new _NamespacedValue.UnstableValue("m.text", "org.matrix.msc1767.text");
+/**
+ * The content for an m.text event
+ */
+
+exports.M_TEXT = M_TEXT;
+
+/**
+ * The namespaced value for m.html
+ */
+var M_HTML = new _NamespacedValue.UnstableValue("m.html", "org.matrix.msc1767.html");
+/**
+ * The content for an m.html event
+ */
+
+exports.M_HTML = M_HTML;
+
+/**
+ * The namespaced value for m.emote
+ */
+var M_EMOTE = new _NamespacedValue.UnstableValue("m.emote", "org.matrix.msc1767.emote");
+/**
+ * The event definition for an m.emote event (in content)
+ */
+
+exports.M_EMOTE = M_EMOTE;
+
+/**
+ * The namespaced value for m.notice
+ */
+var M_NOTICE = new _NamespacedValue.UnstableValue("m.notice", "org.matrix.msc1767.notice");
+/**
+ * The event definition for an m.notice event (in content)
+ */
+
+exports.M_NOTICE = M_NOTICE; \ No newline at end of file
diff --git a/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/poll_types.js b/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/poll_types.js
new file mode 100644
index 0000000000..48e4793ae1
--- /dev/null
+++ b/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/poll_types.js
@@ -0,0 +1,70 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.M_POLL_START = exports.M_POLL_RESPONSE = exports.M_POLL_KIND_UNDISCLOSED = exports.M_POLL_KIND_DISCLOSED = exports.M_POLL_END = void 0;
+
+var _NamespacedValue = require("../NamespacedValue");
+
+/*
+Copyright 2022 The Matrix.org Foundation C.I.C.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+/**
+ * Identifier for a disclosed poll.
+ */
+var M_POLL_KIND_DISCLOSED = new _NamespacedValue.UnstableValue("m.poll.disclosed", "org.matrix.msc3381.poll.disclosed");
+/**
+ * Identifier for an undisclosed poll.
+ */
+
+exports.M_POLL_KIND_DISCLOSED = M_POLL_KIND_DISCLOSED;
+var M_POLL_KIND_UNDISCLOSED = new _NamespacedValue.UnstableValue("m.poll.undisclosed", "org.matrix.msc3381.poll.undisclosed");
+/**
+ * Any poll kind.
+ */
+
+exports.M_POLL_KIND_UNDISCLOSED = M_POLL_KIND_UNDISCLOSED;
+
+/**
+ * The namespaced value for m.poll.start
+ */
+var M_POLL_START = new _NamespacedValue.UnstableValue("m.poll.start", "org.matrix.msc3381.poll.start");
+/**
+ * The m.poll.start type within event content
+ */
+
+exports.M_POLL_START = M_POLL_START;
+
+/**
+ * The namespaced value for m.poll.response
+ */
+var M_POLL_RESPONSE = new _NamespacedValue.UnstableValue("m.poll.response", "org.matrix.msc3381.poll.response");
+/**
+ * The m.poll.response type within event content
+ */
+
+exports.M_POLL_RESPONSE = M_POLL_RESPONSE;
+
+/**
+ * The namespaced value for m.poll.end
+ */
+var M_POLL_END = new _NamespacedValue.UnstableValue("m.poll.end", "org.matrix.msc3381.poll.end");
+/**
+ * The event definition for an m.poll.end event (in content)
+ */
+
+exports.M_POLL_END = M_POLL_END; \ No newline at end of file
diff --git a/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/relationship_types.js b/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/relationship_types.js
new file mode 100644
index 0000000000..0704266479
--- /dev/null
+++ b/comm/chat/protocols/matrix/lib/matrix-events-sdk/events/relationship_types.js
@@ -0,0 +1,34 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.REFERENCE_RELATION = void 0;
+
+var _NamespacedValue = require("../NamespacedValue");
+
+/*
+Copyright 2022 The Matrix.org Foundation C.I.C.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+/**
+ * The namespaced value for an m.reference relation
+ */
+var REFERENCE_RELATION = new _NamespacedValue.NamespacedValue("m.reference");
+/**
+ * Represents any relation type
+ */
+
+exports.REFERENCE_RELATION = REFERENCE_RELATION; \ No newline at end of file
diff --git a/comm/chat/protocols/matrix/lib/matrix-events-sdk/index.js b/comm/chat/protocols/matrix/lib/matrix-events-sdk/index.js
new file mode 100644
index 0000000000..d4abcd31d5
--- /dev/null
+++ b/comm/chat/protocols/matrix/lib/matrix-events-sdk/index.js
@@ -0,0 +1,278 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _ExtensibleEvents = require("./ExtensibleEvents");
+
+Object.keys(_ExtensibleEvents).forEach(function (key) {
+ if (key === "default" || key === "__esModule") return;
+ if (key in exports && exports[key] === _ExtensibleEvents[key]) return;
+ Object.defineProperty(exports, key, {
+ enumerable: true,
+ get: function get() {
+ return _ExtensibleEvents[key];
+ }
+ });
+});
+
+var _IPartialEvent = require("./IPartialEvent");
+
+Object.keys(_IPartialEvent).forEach(function (key) {
+ if (key === "default" || key === "__esModule") return;
+ if (key in exports && exports[key] === _IPartialEvent[key]) return;
+ Object.defineProperty(exports, key, {
+ enumerable: true,
+ get: function get() {
+ return _IPartialEvent[key];
+ }
+ });
+});
+
+var _InvalidEventError = require("./InvalidEventError");
+
+Object.keys(_InvalidEventError).forEach(function (key) {
+ if (key === "default" || key === "__esModule") return;
+ if (key in exports && exports[key] === _InvalidEventError[key]) return;
+ Object.defineProperty(exports, key, {
+ enumerable: true,
+ get: function get() {
+ return _InvalidEventError[key];
+ }
+ });
+});
+
+var _NamespacedValue = require("./NamespacedValue");
+
+Object.keys(_NamespacedValue).forEach(function (key) {
+ if (key === "default" || key === "__esModule") return;
+ if (key in exports && exports[key] === _NamespacedValue[key]) return;
+ Object.defineProperty(exports, key, {
+ enumerable: true,
+ get: function get() {
+ return _NamespacedValue[key];
+ }
+ });
+});
+
+var _NamespacedMap = require("./NamespacedMap");
+
+Object.keys(_NamespacedMap).forEach(function (key) {
+ if (key === "default" || key === "__esModule") return;
+ if (key in exports && exports[key] === _NamespacedMap[key]) return;
+ Object.defineProperty(exports, key, {
+ enumerable: true,
+ get: function get() {
+ return _NamespacedMap[key];
+ }
+ });
+});
+
+var _types = require("./types");
+
+Object.keys(_types).forEach(function (key) {
+ if (key === "default" || key === "__esModule") return;
+ if (key in exports && exports[key] === _types[key]) return;
+ Object.defineProperty(exports, key, {
+ enumerable: true,
+ get: function get() {
+ return _types[key];
+ }
+ });
+});
+
+var _MessageMatchers = require("./utility/MessageMatchers");
+
+Object.keys(_MessageMatchers).forEach(function (key) {
+ if (key === "default" || key === "__esModule") return;
+ if (key in exports && exports[key] === _MessageMatchers[key]) return;
+ Object.defineProperty(exports, key, {
+ enumerable: true,
+ get: function get() {
+ return _MessageMatchers[key];
+ }
+ });
+});
+
+var _events = require("./utility/events");
+
+Object.keys(_events).forEach(function (key) {
+ if (key === "default" || key === "__esModule") return;
+ if (key in exports && exports[key] === _events[key]) return;
+ Object.defineProperty(exports, key, {
+ enumerable: true,
+ get: function get() {
+ return _events[key];
+ }
+ });
+});
+
+var _MRoomMessage = require("./interpreters/legacy/MRoomMessage");
+
+Object.keys(_MRoomMessage).forEach(function (key) {
+ if (key === "default" || key === "__esModule") return;
+ if (key in exports && exports[key] === _MRoomMessage[key]) return;
+ Object.defineProperty(exports, key, {
+ enumerable: true,
+ get: function get() {
+ return _MRoomMessage[key];
+ }
+ });
+});
+
+var _MMessage = require("./interpreters/modern/MMessage");
+
+Object.keys(_MMessage).forEach(function (key) {
+ if (key === "default" || key === "__esModule") return;
+ if (key in exports && exports[key] === _MMessage[key]) return;
+ Object.defineProperty(exports, key, {
+ enumerable: true,
+ get: function get() {
+ return _MMessage[key];
+ }
+ });
+});
+
+var _MPoll = require("./interpreters/modern/MPoll");
+
+Object.keys(_MPoll).forEach(function (key) {
+ if (key === "default" || key === "__esModule") return;
+ if (key in exports && exports[key] === _MPoll[key]) return;
+ Object.defineProperty(exports, key, {
+ enumerable: true,
+ get: function get() {
+ return _MPoll[key];
+ }
+ });
+});
+
+var _relationship_types = require("./events/relationship_types");
+
+Object.keys(_relationship_types).forEach(function (key) {
+ if (key === "default" || key === "__esModule") return;
+ if (key in exports && exports[key] === _relationship_types[key]) return;
+ Object.defineProperty(exports, key, {
+ enumerable: true,
+ get: function get() {
+ return _relationship_types[key];
+ }
+ });
+});
+
+var _ExtensibleEvent = require("./events/ExtensibleEvent");
+
+Object.keys(_ExtensibleEvent).forEach(function (key) {
+ if (key === "default" || key === "__esModule") return;
+ if (key in exports && exports[key] === _ExtensibleEvent[key]) return;
+ Object.defineProperty(exports, key, {
+ enumerable: true,
+ get: function get() {
+ return _ExtensibleEvent[key];
+ }
+ });
+});
+
+var _message_types = require("./events/message_types");
+
+Object.keys(_message_types).forEach(function (key) {
+ if (key === "default" || key === "__esModule") return;
+ if (key in exports && exports[key] === _message_types[key]) return;
+ Object.defineProperty(exports, key, {
+ enumerable: true,
+ get: function get() {
+ return _message_types[key];
+ }
+ });
+});
+
+var _MessageEvent = require("./events/MessageEvent");
+
+Object.keys(_MessageEvent).forEach(function (key) {
+ if (key === "default" || key === "__esModule") return;
+ if (key in exports && exports[key] === _MessageEvent[key]) return;
+ Object.defineProperty(exports, key, {
+ enumerable: true,
+ get: function get() {
+ return _MessageEvent[key];
+ }
+ });
+});
+
+var _EmoteEvent = require("./events/EmoteEvent");
+
+Object.keys(_EmoteEvent).forEach(function (key) {
+ if (key === "default" || key === "__esModule") return;
+ if (key in exports && exports[key] === _EmoteEvent[key]) return;
+ Object.defineProperty(exports, key, {
+ enumerable: true,
+ get: function get() {
+ return _EmoteEvent[key];
+ }
+ });
+});
+
+var _NoticeEvent = require("./events/NoticeEvent");
+
+Object.keys(_NoticeEvent).forEach(function (key) {
+ if (key === "default" || key === "__esModule") return;
+ if (key in exports && exports[key] === _NoticeEvent[key]) return;
+ Object.defineProperty(exports, key, {
+ enumerable: true,
+ get: function get() {
+ return _NoticeEvent[key];
+ }
+ });
+});
+
+var _poll_types = require("./events/poll_types");
+
+Object.keys(_poll_types).forEach(function (key) {
+ if (key === "default" || key === "__esModule") return;
+ if (key in exports && exports[key] === _poll_types[key]) return;
+ Object.defineProperty(exports, key, {
+ enumerable: true,
+ get: function get() {
+ return _poll_types[key];
+ }
+ });
+});
+
+var _PollStartEvent = require("./events/PollStartEvent");
+
+Object.keys(_PollStartEvent).forEach(function (key) {
+ if (key === "default" || key === "__esModule") return;
+ if (key in exports && exports[key] === _PollStartEvent[key]) return;
+ Object.defineProperty(exports, key, {
+ enumerable: true,
+ get: function get() {
+ return _PollStartEvent[key];
+ }
+ });
+});
+
+var _PollResponseEvent = require("./events/PollResponseEvent");
+
+Object.keys(_PollResponseEvent).forEach(function (key) {
+ if (key === "default" || key === "__esModule") return;
+ if (key in exports && exports[key] === _PollResponseEvent[key]) return;
+ Object.defineProperty(exports, key, {
+ enumerable: true,
+ get: function get() {
+ return _PollResponseEvent[key];
+ }
+ });
+});
+
+var _PollEndEvent = require("./events/PollEndEvent");
+
+Object.keys(_PollEndEvent).forEach(function (key) {
+ if (key === "default" || key === "__esModule") return;
+ if (key in exports && exports[key] === _PollEndEvent[key]) return;
+ Object.defineProperty(exports, key, {
+ enumerable: true,
+ get: function get() {
+ return _PollEndEvent[key];
+ }
+ });
+}); \ No newline at end of file
diff --git a/comm/chat/protocols/matrix/lib/matrix-events-sdk/interpreters/legacy/MRoomMessage.js b/comm/chat/protocols/matrix/lib/matrix-events-sdk/interpreters/legacy/MRoomMessage.js
new file mode 100644
index 0000000000..b362b52b16
--- /dev/null
+++ b/comm/chat/protocols/matrix/lib/matrix-events-sdk/interpreters/legacy/MRoomMessage.js
@@ -0,0 +1,62 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.LEGACY_M_ROOM_MESSAGE = void 0;
+exports.parseMRoomMessage = parseMRoomMessage;
+
+var _MessageEvent = require("../../events/MessageEvent");
+
+var _NoticeEvent = require("../../events/NoticeEvent");
+
+var _EmoteEvent = require("../../events/EmoteEvent");
+
+var _NamespacedValue = require("../../NamespacedValue");
+
+var _message_types = require("../../events/message_types");
+
+function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
+
+function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
+
+function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
+
+var LEGACY_M_ROOM_MESSAGE = new _NamespacedValue.NamespacedValue("m.room.message");
+exports.LEGACY_M_ROOM_MESSAGE = LEGACY_M_ROOM_MESSAGE;
+
+function parseMRoomMessage(wireEvent) {
+ var _wireEvent$content, _wireEvent$content2, _wireEvent$content3;
+
+ if (_message_types.M_MESSAGE.findIn(wireEvent.content) || _message_types.M_TEXT.findIn(wireEvent.content)) {
+ // We know enough about the event to coerce it into the right type
+ return new _MessageEvent.MessageEvent(wireEvent);
+ }
+
+ var msgtype = (_wireEvent$content = wireEvent.content) === null || _wireEvent$content === void 0 ? void 0 : _wireEvent$content.msgtype;
+ var text = (_wireEvent$content2 = wireEvent.content) === null || _wireEvent$content2 === void 0 ? void 0 : _wireEvent$content2.body;
+ var html = ((_wireEvent$content3 = wireEvent.content) === null || _wireEvent$content3 === void 0 ? void 0 : _wireEvent$content3.format) === "org.matrix.custom.html" ? wireEvent.content.formatted_body : null;
+
+ if (msgtype === "m.text") {
+ var _objectSpread2;
+
+ return new _MessageEvent.MessageEvent(_objectSpread(_objectSpread({}, wireEvent), {}, {
+ content: _objectSpread(_objectSpread({}, wireEvent.content), {}, (_objectSpread2 = {}, _defineProperty(_objectSpread2, _message_types.M_TEXT.name, text), _defineProperty(_objectSpread2, _message_types.M_HTML.name, html), _objectSpread2))
+ }));
+ } else if (msgtype === "m.notice") {
+ var _objectSpread3;
+
+ return new _NoticeEvent.NoticeEvent(_objectSpread(_objectSpread({}, wireEvent), {}, {
+ content: _objectSpread(_objectSpread({}, wireEvent.content), {}, (_objectSpread3 = {}, _defineProperty(_objectSpread3, _message_types.M_TEXT.name, text), _defineProperty(_objectSpread3, _message_types.M_HTML.name, html), _objectSpread3))
+ }));
+ } else if (msgtype === "m.emote") {
+ var _objectSpread4;
+
+ return new _EmoteEvent.EmoteEvent(_objectSpread(_objectSpread({}, wireEvent), {}, {
+ content: _objectSpread(_objectSpread({}, wireEvent.content), {}, (_objectSpread4 = {}, _defineProperty(_objectSpread4, _message_types.M_TEXT.name, text), _defineProperty(_objectSpread4, _message_types.M_HTML.name, html), _objectSpread4))
+ }));
+ } else {
+ // TODO: Handle other types
+ return null;
+ }
+} \ No newline at end of file
diff --git a/comm/chat/protocols/matrix/lib/matrix-events-sdk/interpreters/modern/MMessage.js b/comm/chat/protocols/matrix/lib/matrix-events-sdk/interpreters/modern/MMessage.js
new file mode 100644
index 0000000000..dd74621eb2
--- /dev/null
+++ b/comm/chat/protocols/matrix/lib/matrix-events-sdk/interpreters/modern/MMessage.js
@@ -0,0 +1,40 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.parseMMessage = parseMMessage;
+
+var _MessageEvent = require("../../events/MessageEvent");
+
+var _message_types = require("../../events/message_types");
+
+var _EmoteEvent = require("../../events/EmoteEvent");
+
+var _NoticeEvent = require("../../events/NoticeEvent");
+
+/*
+Copyright 2022 The Matrix.org Foundation C.I.C.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+function parseMMessage(wireEvent) {
+ if (_message_types.M_EMOTE.matches(wireEvent.type)) {
+ return new _EmoteEvent.EmoteEvent(wireEvent);
+ } else if (_message_types.M_NOTICE.matches(wireEvent.type)) {
+ return new _NoticeEvent.NoticeEvent(wireEvent);
+ } // default: return a generic message
+
+
+ return new _MessageEvent.MessageEvent(wireEvent);
+} \ No newline at end of file
diff --git a/comm/chat/protocols/matrix/lib/matrix-events-sdk/interpreters/modern/MPoll.js b/comm/chat/protocols/matrix/lib/matrix-events-sdk/interpreters/modern/MPoll.js
new file mode 100644
index 0000000000..af35a0fa94
--- /dev/null
+++ b/comm/chat/protocols/matrix/lib/matrix-events-sdk/interpreters/modern/MPoll.js
@@ -0,0 +1,41 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.parseMPoll = parseMPoll;
+
+var _poll_types = require("../../events/poll_types");
+
+var _PollStartEvent = require("../../events/PollStartEvent");
+
+var _PollResponseEvent = require("../../events/PollResponseEvent");
+
+var _PollEndEvent = require("../../events/PollEndEvent");
+
+/*
+Copyright 2022 The Matrix.org Foundation C.I.C.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+function parseMPoll(wireEvent) {
+ if (_poll_types.M_POLL_START.matches(wireEvent.type)) {
+ return new _PollStartEvent.PollStartEvent(wireEvent);
+ } else if (_poll_types.M_POLL_RESPONSE.matches(wireEvent.type)) {
+ return new _PollResponseEvent.PollResponseEvent(wireEvent);
+ } else if (_poll_types.M_POLL_END.matches(wireEvent.type)) {
+ return new _PollEndEvent.PollEndEvent(wireEvent);
+ }
+
+ return null; // not a poll event
+} \ No newline at end of file
diff --git a/comm/chat/protocols/matrix/lib/matrix-events-sdk/types.js b/comm/chat/protocols/matrix/lib/matrix-events-sdk/types.js
new file mode 100644
index 0000000000..1332fef9da
--- /dev/null
+++ b/comm/chat/protocols/matrix/lib/matrix-events-sdk/types.js
@@ -0,0 +1,49 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.isOptionalAString = isOptionalAString;
+exports.isProvided = isProvided;
+
+/*
+Copyright 2021 - 2022 The Matrix.org Foundation C.I.C.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+/**
+ * Represents an optional type: can either be T or a falsy value.
+ */
+
+/**
+ * Determines if the given optional string is a defined string.
+ * @param {Optional<string>} s The input string.
+ * @returns {boolean} True if the input is a defined string.
+ */
+function isOptionalAString(s) {
+ return isProvided(s) && typeof s === 'string';
+}
+/**
+ * Determines if the given optional was provided a value.
+ * @param {Optional<T>} s The optional to test.
+ * @returns {boolean} True if the value is defined.
+ */
+
+
+function isProvided(s) {
+ return s !== null && s !== undefined;
+}
+/**
+ * Represents either just T1, just T2, or T1 and T2 mixed.
+ */ \ No newline at end of file
diff --git a/comm/chat/protocols/matrix/lib/matrix-events-sdk/utility/MessageMatchers.js b/comm/chat/protocols/matrix/lib/matrix-events-sdk/utility/MessageMatchers.js
new file mode 100644
index 0000000000..beb43e5c3c
--- /dev/null
+++ b/comm/chat/protocols/matrix/lib/matrix-events-sdk/utility/MessageMatchers.js
@@ -0,0 +1,59 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.LegacyMsgType = void 0;
+exports.isEventLike = isEventLike;
+
+var _message_types = require("../events/message_types");
+
+/*
+Copyright 2022 The Matrix.org Foundation C.I.C.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+/**
+ * Represents a legacy m.room.message msgtype
+ */
+var LegacyMsgType;
+/**
+ * Determines if the given partial event looks similar enough to the given legacy msgtype
+ * to count as that message type.
+ * @param {IPartialEvent<EitherAnd<IPartialLegacyContent, M_MESSAGE_EVENT_CONTENT>>} event The event.
+ * @param {LegacyMsgType} msgtype The message type to compare for.
+ * @returns {boolean} True if the event appears to look similar enough to the msgtype.
+ */
+
+exports.LegacyMsgType = LegacyMsgType;
+
+(function (LegacyMsgType) {
+ LegacyMsgType["Text"] = "m.text";
+ LegacyMsgType["Notice"] = "m.notice";
+ LegacyMsgType["Emote"] = "m.emote";
+})(LegacyMsgType || (exports.LegacyMsgType = LegacyMsgType = {}));
+
+function isEventLike(event, msgtype) {
+ var content = event.content;
+
+ if (msgtype === LegacyMsgType.Text) {
+ return _message_types.M_MESSAGE.matches(event.type) || event.type === "m.room.message" && (content === null || content === void 0 ? void 0 : content['msgtype']) === "m.text";
+ } else if (msgtype === LegacyMsgType.Emote) {
+ return _message_types.M_EMOTE.matches(event.type) || event.type === "m.room.message" && (content === null || content === void 0 ? void 0 : content['msgtype']) === "m.emote";
+ } else if (msgtype === LegacyMsgType.Notice) {
+ return _message_types.M_NOTICE.matches(event.type) || event.type === "m.room.message" && (content === null || content === void 0 ? void 0 : content['msgtype']) === "m.notice";
+ }
+
+ return false;
+} \ No newline at end of file
diff --git a/comm/chat/protocols/matrix/lib/matrix-events-sdk/utility/events.js b/comm/chat/protocols/matrix/lib/matrix-events-sdk/utility/events.js
new file mode 100644
index 0000000000..ace7464863
--- /dev/null
+++ b/comm/chat/protocols/matrix/lib/matrix-events-sdk/utility/events.js
@@ -0,0 +1,51 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.isEventTypeSame = isEventTypeSame;
+
+/*
+Copyright 2022 The Matrix.org Foundation C.I.C.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+/**
+ * Represents a potentially namespaced event type.
+ */
+
+/**
+ * Determines if two event types are the same, including namespaces.
+ * @param {EventType} given The given event type. This will be compared
+ * against the expected type.
+ * @param {EventType} expected The expected event type.
+ * @returns {boolean} True if the given type matches the expected type.
+ */
+function isEventTypeSame(given, expected) {
+ if (typeof given === "string") {
+ if (typeof expected === "string") {
+ return expected === given;
+ } else {
+ return expected.matches(given);
+ }
+ } else {
+ if (typeof expected === "string") {
+ return given.matches(expected);
+ } else {
+ var expectedNs = expected;
+ var givenNs = given;
+ return expectedNs.matches(givenNs.name) || expectedNs.matches(givenNs.altName);
+ }
+ }
+} \ No newline at end of file