summaryrefslogtreecommitdiffstats
path: root/comm/chat/protocols/matrix/lib/matrix-events-sdk/events
diff options
context:
space:
mode:
Diffstat (limited to 'comm/chat/protocols/matrix/lib/matrix-events-sdk/events')
-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
10 files changed, 1273 insertions, 0 deletions
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