summaryrefslogtreecommitdiff
path: root/includes/external/matrix/node_modules/matrix-widget-api/dist
diff options
context:
space:
mode:
authorRaindropsSys <raindrops@equestria.dev>2023-11-17 23:25:29 +0100
committerRaindropsSys <raindrops@equestria.dev>2023-11-17 23:25:29 +0100
commit953ddd82e48dd206cef5ac94456549aed13b3ad5 (patch)
tree8f003106ee2e7f422e5a22d2ee04d0db302e66c0 /includes/external/matrix/node_modules/matrix-widget-api/dist
parent62a9199846b0c07c03218703b33e8385764f42d9 (diff)
downloadpluralconnect-953ddd82e48dd206cef5ac94456549aed13b3ad5.tar.gz
pluralconnect-953ddd82e48dd206cef5ac94456549aed13b3ad5.tar.bz2
pluralconnect-953ddd82e48dd206cef5ac94456549aed13b3ad5.zip
Updated 30 files and deleted 2976 files (automated)
Diffstat (limited to 'includes/external/matrix/node_modules/matrix-widget-api/dist')
-rw-r--r--includes/external/matrix/node_modules/matrix-widget-api/dist/api.js5105
-rw-r--r--includes/external/matrix/node_modules/matrix-widget-api/dist/api.min.js1
2 files changed, 0 insertions, 5106 deletions
diff --git a/includes/external/matrix/node_modules/matrix-widget-api/dist/api.js b/includes/external/matrix/node_modules/matrix-widget-api/dist/api.js
deleted file mode 100644
index 74f35ca..0000000
--- a/includes/external/matrix/node_modules/matrix-widget-api/dist/api.js
+++ /dev/null
@@ -1,5105 +0,0 @@
-(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.mxwidgets = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
-"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.ClientWidgetApi = void 0;
-
-var _events = require("events");
-
-var _PostmessageTransport = require("./transport/PostmessageTransport");
-
-var _WidgetApiDirection = require("./interfaces/WidgetApiDirection");
-
-var _WidgetApiAction = require("./interfaces/WidgetApiAction");
-
-var _Capabilities = require("./interfaces/Capabilities");
-
-var _ApiVersion = require("./interfaces/ApiVersion");
-
-var _WidgetEventCapability = require("./models/WidgetEventCapability");
-
-var _GetOpenIDAction = require("./interfaces/GetOpenIDAction");
-
-var _SimpleObservable = require("./util/SimpleObservable");
-
-var _Symbols = require("./Symbols");
-
-function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
-
-function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
-
-function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
-
-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 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 ? Object.setPrototypeOf.bind() : 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.bind() : 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; }
-
-function _asyncIterator(iterable) { var method, async, sync, retry = 2; for ("undefined" != typeof Symbol && (async = Symbol.asyncIterator, sync = Symbol.iterator); retry--;) { if (async && null != (method = iterable[async])) return method.call(iterable); if (sync && null != (method = iterable[sync])) return new AsyncFromSyncIterator(method.call(iterable)); async = "@@asyncIterator", sync = "@@iterator"; } throw new TypeError("Object is not async iterable"); }
-
-function AsyncFromSyncIterator(s) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var done = r.done; return Promise.resolve(r.value).then(function (value) { return { value: value, done: done }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(s) { this.s = s, this.n = s.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, "return": function _return(value) { var ret = this.s["return"]; return void 0 === ret ? Promise.resolve({ value: value, done: !0 }) : AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments)); }, "throw": function _throw(value) { var thr = this.s["return"]; return void 0 === thr ? Promise.reject(value) : AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(s); }
-
-/**
- * API handler for the client side of widgets. This raises events
- * for each action received as `action:${action}` (eg: "action:screenshot").
- * Default handling can be prevented by using preventDefault() on the
- * raised event. The default handling varies for each action: ones
- * which the SDK can handle safely are acknowledged appropriately and
- * ones which are unhandled (custom or require the client to do something)
- * are rejected with an error.
- *
- * Events which are preventDefault()ed must reply using the transport.
- * The events raised will have a default of an IWidgetApiRequest
- * interface.
- *
- * When the ClientWidgetApi is ready to start sending requests, it will
- * raise a "ready" CustomEvent. After the ready event fires, actions can
- * be sent and the transport will be ready.
- *
- * When the widget has indicated it has loaded, this class raises a
- * "preparing" CustomEvent. The preparing event does not indicate that
- * the widget is ready to receive communications - that is signified by
- * the ready event exclusively.
- *
- * This class only handles one widget at a time.
- */
-var ClientWidgetApi = /*#__PURE__*/function (_EventEmitter) {
- _inherits(ClientWidgetApi, _EventEmitter);
-
- var _super = _createSuper(ClientWidgetApi);
-
- // contentLoadedActionSent is used to check that only one ContentLoaded request is send.
-
- /**
- * Creates a new client widget API. This will instantiate the transport
- * and start everything. When the iframe is loaded under the widget's
- * conditions, a "ready" event will be raised.
- * @param {Widget} widget The widget to communicate with.
- * @param {HTMLIFrameElement} iframe The iframe the widget is in.
- * @param {WidgetDriver} driver The driver for this widget/client.
- */
- function ClientWidgetApi(widget, iframe, driver) {
- var _this;
-
- _classCallCheck(this, ClientWidgetApi);
-
- _this = _super.call(this);
- _this.widget = widget;
- _this.iframe = iframe;
- _this.driver = driver;
-
- _defineProperty(_assertThisInitialized(_this), "transport", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "contentLoadedActionSent", false);
-
- _defineProperty(_assertThisInitialized(_this), "allowedCapabilities", new Set());
-
- _defineProperty(_assertThisInitialized(_this), "allowedEvents", []);
-
- _defineProperty(_assertThisInitialized(_this), "isStopped", false);
-
- _defineProperty(_assertThisInitialized(_this), "turnServers", null);
-
- if (!(iframe !== null && iframe !== void 0 && iframe.contentWindow)) {
- throw new Error("No iframe supplied");
- }
-
- if (!widget) {
- throw new Error("Invalid widget");
- }
-
- if (!driver) {
- throw new Error("Invalid driver");
- }
-
- _this.transport = new _PostmessageTransport.PostmessageTransport(_WidgetApiDirection.WidgetApiDirection.ToWidget, widget.id, iframe.contentWindow, window);
- _this.transport.targetOrigin = widget.origin;
-
- _this.transport.on("message", _this.handleMessage.bind(_assertThisInitialized(_this)));
-
- iframe.addEventListener("load", _this.onIframeLoad.bind(_assertThisInitialized(_this)));
-
- _this.transport.start();
-
- return _this;
- }
-
- _createClass(ClientWidgetApi, [{
- key: "hasCapability",
- value: function hasCapability(capability) {
- return this.allowedCapabilities.has(capability);
- }
- }, {
- key: "canUseRoomTimeline",
- value: function canUseRoomTimeline(roomId) {
- return this.hasCapability("org.matrix.msc2762.timeline:".concat(_Symbols.Symbols.AnyRoom)) || this.hasCapability("org.matrix.msc2762.timeline:".concat(roomId));
- }
- }, {
- key: "canSendRoomEvent",
- value: function canSendRoomEvent(eventType) {
- var msgtype = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
- return this.allowedEvents.some(function (e) {
- return e.matchesAsRoomEvent(_WidgetEventCapability.EventDirection.Send, eventType, msgtype);
- });
- }
- }, {
- key: "canSendStateEvent",
- value: function canSendStateEvent(eventType, stateKey) {
- return this.allowedEvents.some(function (e) {
- return e.matchesAsStateEvent(_WidgetEventCapability.EventDirection.Send, eventType, stateKey);
- });
- }
- }, {
- key: "canSendToDeviceEvent",
- value: function canSendToDeviceEvent(eventType) {
- return this.allowedEvents.some(function (e) {
- return e.matchesAsToDeviceEvent(_WidgetEventCapability.EventDirection.Send, eventType);
- });
- }
- }, {
- key: "canReceiveRoomEvent",
- value: function canReceiveRoomEvent(eventType) {
- var msgtype = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
- return this.allowedEvents.some(function (e) {
- return e.matchesAsRoomEvent(_WidgetEventCapability.EventDirection.Receive, eventType, msgtype);
- });
- }
- }, {
- key: "canReceiveStateEvent",
- value: function canReceiveStateEvent(eventType, stateKey) {
- return this.allowedEvents.some(function (e) {
- return e.matchesAsStateEvent(_WidgetEventCapability.EventDirection.Receive, eventType, stateKey);
- });
- }
- }, {
- key: "canReceiveToDeviceEvent",
- value: function canReceiveToDeviceEvent(eventType) {
- return this.allowedEvents.some(function (e) {
- return e.matchesAsToDeviceEvent(_WidgetEventCapability.EventDirection.Receive, eventType);
- });
- }
- }, {
- key: "stop",
- value: function stop() {
- this.isStopped = true;
- this.transport.stop();
- }
- }, {
- key: "beginCapabilities",
- value: function beginCapabilities() {
- var _this2 = this;
-
- // widget has loaded - tell all the listeners that
- this.emit("preparing");
- var requestedCaps;
- this.transport.send(_WidgetApiAction.WidgetApiToWidgetAction.Capabilities, {}).then(function (caps) {
- requestedCaps = caps.capabilities;
- return _this2.driver.validateCapabilities(new Set(caps.capabilities));
- }).then(function (allowedCaps) {
- console.log("Widget ".concat(_this2.widget.id, " is allowed capabilities:"), Array.from(allowedCaps));
- _this2.allowedCapabilities = allowedCaps;
- _this2.allowedEvents = _WidgetEventCapability.WidgetEventCapability.findEventCapabilities(allowedCaps);
-
- _this2.notifyCapabilities(requestedCaps);
-
- _this2.emit("ready");
- });
- }
- }, {
- key: "notifyCapabilities",
- value: function notifyCapabilities(requested) {
- var _this3 = this;
-
- this.transport.send(_WidgetApiAction.WidgetApiToWidgetAction.NotifyCapabilities, {
- requested: requested,
- approved: Array.from(this.allowedCapabilities)
- })["catch"](function (e) {
- console.warn("non-fatal error notifying widget of approved capabilities:", e);
- }).then(function () {
- _this3.emit("capabilitiesNotified");
- });
- }
- }, {
- key: "onIframeLoad",
- value: function onIframeLoad(ev) {
- if (this.widget.waitForIframeLoad) {
- // If the widget is set to waitForIframeLoad the capabilities immediatly get setup after load.
- // The client does not wait for the ContentLoaded action.
- this.beginCapabilities();
- } else {
- // Reaching this means, that the Iframe got reloaded/loaded and
- // the clientApi is awaiting the FIRST ContentLoaded action.
- this.contentLoadedActionSent = false;
- }
- }
- }, {
- key: "handleContentLoadedAction",
- value: function handleContentLoadedAction(action) {
- if (this.contentLoadedActionSent) {
- throw new Error("Improper sequence: ContentLoaded Action can only be send once after the widget loaded " + "and should only be used if waitForIframeLoad is false (default=true)");
- }
-
- if (this.widget.waitForIframeLoad) {
- this.transport.reply(action, {
- error: {
- message: "Improper sequence: not expecting ContentLoaded event if " + "waitForIframLoad is true (default=true)"
- }
- });
- } else {
- this.transport.reply(action, {});
- this.beginCapabilities();
- }
-
- this.contentLoadedActionSent = true;
- }
- }, {
- key: "replyVersions",
- value: function replyVersions(request) {
- this.transport.reply(request, {
- supported_versions: _ApiVersion.CurrentApiVersions
- });
- }
- }, {
- key: "handleCapabilitiesRenegotiate",
- value: function handleCapabilitiesRenegotiate(request) {
- var _request$data,
- _this4 = this;
-
- // acknowledge first
- this.transport.reply(request, {});
- var requested = ((_request$data = request.data) === null || _request$data === void 0 ? void 0 : _request$data.capabilities) || [];
- var newlyRequested = new Set(requested.filter(function (r) {
- return !_this4.hasCapability(r);
- }));
-
- if (newlyRequested.size === 0) {
- // Nothing to do - notify capabilities
- return this.notifyCapabilities([]);
- }
-
- this.driver.validateCapabilities(newlyRequested).then(function (allowed) {
- allowed.forEach(function (c) {
- return _this4.allowedCapabilities.add(c);
- });
-
- var allowedEvents = _WidgetEventCapability.WidgetEventCapability.findEventCapabilities(allowed);
-
- allowedEvents.forEach(function (c) {
- return _this4.allowedEvents.push(c);
- });
- return _this4.notifyCapabilities(Array.from(newlyRequested));
- });
- }
- }, {
- key: "handleNavigate",
- value: function handleNavigate(request) {
- var _request$data2,
- _request$data3,
- _this5 = this;
-
- if (!this.hasCapability(_Capabilities.MatrixCapabilities.MSC2931Navigate)) {
- return this.transport.reply(request, {
- error: {
- message: "Missing capability"
- }
- });
- }
-
- if (!((_request$data2 = request.data) !== null && _request$data2 !== void 0 && _request$data2.uri) || !((_request$data3 = request.data) !== null && _request$data3 !== void 0 && _request$data3.uri.toString().startsWith("https://matrix.to/#"))) {
- return this.transport.reply(request, {
- error: {
- message: "Invalid matrix.to URI"
- }
- });
- }
-
- var onErr = function onErr(e) {
- console.error("[ClientWidgetApi] Failed to handle navigation: ", e);
- return _this5.transport.reply(request, {
- error: {
- message: "Error handling navigation"
- }
- });
- };
-
- try {
- this.driver.navigate(request.data.uri.toString())["catch"](function (e) {
- return onErr(e);
- }).then(function () {
- return _this5.transport.reply(request, {});
- });
- } catch (e) {
- return onErr(e);
- }
- }
- }, {
- key: "handleOIDC",
- value: function handleOIDC(request) {
- var _this6 = this;
-
- var phase = 1; // 1 = initial request, 2 = after user manual confirmation
-
- var replyState = function replyState(state, credential) {
- credential = credential || {};
-
- if (phase > 1) {
- return _this6.transport.send(_WidgetApiAction.WidgetApiToWidgetAction.OpenIDCredentials, _objectSpread({
- state: state,
- original_request_id: request.requestId
- }, credential));
- } else {
- return _this6.transport.reply(request, _objectSpread({
- state: state
- }, credential));
- }
- };
-
- var replyError = function replyError(msg) {
- console.error("[ClientWidgetApi] Failed to handle OIDC: ", msg);
-
- if (phase > 1) {
- // We don't have a way to indicate that a random error happened in this flow, so
- // just block the attempt.
- return replyState(_GetOpenIDAction.OpenIDRequestState.Blocked);
- } else {
- return _this6.transport.reply(request, {
- error: {
- message: msg
- }
- });
- }
- };
-
- var observer = new _SimpleObservable.SimpleObservable(function (update) {
- if (update.state === _GetOpenIDAction.OpenIDRequestState.PendingUserConfirmation && phase > 1) {
- observer.close();
- return replyError("client provided out-of-phase response to OIDC flow");
- }
-
- if (update.state === _GetOpenIDAction.OpenIDRequestState.PendingUserConfirmation) {
- replyState(update.state);
- phase++;
- return;
- }
-
- if (update.state === _GetOpenIDAction.OpenIDRequestState.Allowed && !update.token) {
- return replyError("client provided invalid OIDC token for an allowed request");
- }
-
- if (update.state === _GetOpenIDAction.OpenIDRequestState.Blocked) {
- update.token = undefined; // just in case the client did something weird
- }
-
- observer.close();
- return replyState(update.state, update.token);
- });
- this.driver.askOpenID(observer);
- }
- }, {
- key: "handleReadEvents",
- value: function handleReadEvents(request) {
- var _this7 = this;
-
- if (!request.data.type) {
- return this.transport.reply(request, {
- error: {
- message: "Invalid request - missing event type"
- }
- });
- }
-
- if (request.data.limit !== undefined && (!request.data.limit || request.data.limit < 0)) {
- return this.transport.reply(request, {
- error: {
- message: "Invalid request - limit out of range"
- }
- });
- }
-
- var askRoomIds = null; // null denotes current room only
-
- if (request.data.room_ids) {
- askRoomIds = request.data.room_ids;
-
- if (!Array.isArray(askRoomIds)) {
- askRoomIds = [askRoomIds];
- }
-
- var _iterator2 = _createForOfIteratorHelper(askRoomIds),
- _step2;
-
- try {
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
- var roomId = _step2.value;
-
- if (!this.canUseRoomTimeline(roomId)) {
- return this.transport.reply(request, {
- error: {
- message: "Unable to access room timeline: ".concat(roomId)
- }
- });
- }
- }
- } catch (err) {
- _iterator2.e(err);
- } finally {
- _iterator2.f();
- }
- }
-
- var limit = request.data.limit || 0;
- var events = Promise.resolve([]);
-
- if (request.data.state_key !== undefined) {
- var stateKey = request.data.state_key === true ? undefined : request.data.state_key.toString();
-
- if (!this.canReceiveStateEvent(request.data.type, stateKey !== null && stateKey !== void 0 ? stateKey : null)) {
- return this.transport.reply(request, {
- error: {
- message: "Cannot read state events of this type"
- }
- });
- }
-
- events = this.driver.readStateEvents(request.data.type, stateKey, limit, askRoomIds);
- } else {
- if (!this.canReceiveRoomEvent(request.data.type, request.data.msgtype)) {
- return this.transport.reply(request, {
- error: {
- message: "Cannot read room events of this type"
- }
- });
- }
-
- events = this.driver.readRoomEvents(request.data.type, request.data.msgtype, limit, askRoomIds);
- }
-
- return events.then(function (evs) {
- return _this7.transport.reply(request, {
- events: evs
- });
- });
- }
- }, {
- key: "handleSendEvent",
- value: function handleSendEvent(request) {
- var _this8 = this;
-
- if (!request.data.type) {
- return this.transport.reply(request, {
- error: {
- message: "Invalid request - missing event type"
- }
- });
- }
-
- if (!!request.data.room_id && !this.canUseRoomTimeline(request.data.room_id)) {
- return this.transport.reply(request, {
- error: {
- message: "Unable to access room timeline: ".concat(request.data.room_id)
- }
- });
- }
-
- var isState = request.data.state_key !== null && request.data.state_key !== undefined;
- var sendEventPromise;
-
- if (isState) {
- if (!this.canSendStateEvent(request.data.type, request.data.state_key)) {
- return this.transport.reply(request, {
- error: {
- message: "Cannot send state events of this type"
- }
- });
- }
-
- sendEventPromise = this.driver.sendEvent(request.data.type, request.data.content || {}, request.data.state_key, request.data.room_id);
- } else {
- var content = request.data.content || {};
- var msgtype = content['msgtype'];
-
- if (!this.canSendRoomEvent(request.data.type, msgtype)) {
- return this.transport.reply(request, {
- error: {
- message: "Cannot send room events of this type"
- }
- });
- }
-
- sendEventPromise = this.driver.sendEvent(request.data.type, content, null, // not sending a state event
- request.data.room_id);
- }
-
- sendEventPromise.then(function (sentEvent) {
- return _this8.transport.reply(request, {
- room_id: sentEvent.roomId,
- event_id: sentEvent.eventId
- });
- })["catch"](function (e) {
- console.error("error sending event: ", e);
- return _this8.transport.reply(request, {
- error: {
- message: "Error sending event"
- }
- });
- });
- }
- }, {
- key: "handleSendToDevice",
- value: function () {
- var _handleSendToDevice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
- return _regeneratorRuntime().wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- if (request.data.type) {
- _context.next = 5;
- break;
- }
-
- _context.next = 3;
- return this.transport.reply(request, {
- error: {
- message: "Invalid request - missing event type"
- }
- });
-
- case 3:
- _context.next = 32;
- break;
-
- case 5:
- if (request.data.messages) {
- _context.next = 10;
- break;
- }
-
- _context.next = 8;
- return this.transport.reply(request, {
- error: {
- message: "Invalid request - missing event contents"
- }
- });
-
- case 8:
- _context.next = 32;
- break;
-
- case 10:
- if (!(typeof request.data.encrypted !== "boolean")) {
- _context.next = 15;
- break;
- }
-
- _context.next = 13;
- return this.transport.reply(request, {
- error: {
- message: "Invalid request - missing encryption flag"
- }
- });
-
- case 13:
- _context.next = 32;
- break;
-
- case 15:
- if (this.canSendToDeviceEvent(request.data.type)) {
- _context.next = 20;
- break;
- }
-
- _context.next = 18;
- return this.transport.reply(request, {
- error: {
- message: "Cannot send to-device events of this type"
- }
- });
-
- case 18:
- _context.next = 32;
- break;
-
- case 20:
- _context.prev = 20;
- _context.next = 23;
- return this.driver.sendToDevice(request.data.type, request.data.encrypted, request.data.messages);
-
- case 23:
- _context.next = 25;
- return this.transport.reply(request, {});
-
- case 25:
- _context.next = 32;
- break;
-
- case 27:
- _context.prev = 27;
- _context.t0 = _context["catch"](20);
- console.error("error sending to-device event", _context.t0);
- _context.next = 32;
- return this.transport.reply(request, {
- error: {
- message: "Error sending event"
- }
- });
-
- case 32:
- case "end":
- return _context.stop();
- }
- }
- }, _callee, this, [[20, 27]]);
- }));
-
- function handleSendToDevice(_x) {
- return _handleSendToDevice.apply(this, arguments);
- }
-
- return handleSendToDevice;
- }()
- }, {
- key: "pollTurnServers",
- value: function () {
- var _pollTurnServers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(turnServers, initialServer) {
- var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, server;
-
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- _context2.prev = 0;
- _context2.next = 3;
- return this.transport.send(_WidgetApiAction.WidgetApiToWidgetAction.UpdateTurnServers, initialServer // it's compatible, but missing the index signature
- );
-
- case 3:
- // Pick the generator up where we left off
- _iteratorAbruptCompletion = false;
- _didIteratorError = false;
- _context2.prev = 5;
- _iterator = _asyncIterator(turnServers);
-
- case 7:
- _context2.next = 9;
- return _iterator.next();
-
- case 9:
- if (!(_iteratorAbruptCompletion = !(_step = _context2.sent).done)) {
- _context2.next = 16;
- break;
- }
-
- server = _step.value;
- _context2.next = 13;
- return this.transport.send(_WidgetApiAction.WidgetApiToWidgetAction.UpdateTurnServers, server // it's compatible, but missing the index signature
- );
-
- case 13:
- _iteratorAbruptCompletion = false;
- _context2.next = 7;
- break;
-
- case 16:
- _context2.next = 22;
- break;
-
- case 18:
- _context2.prev = 18;
- _context2.t0 = _context2["catch"](5);
- _didIteratorError = true;
- _iteratorError = _context2.t0;
-
- case 22:
- _context2.prev = 22;
- _context2.prev = 23;
-
- if (!(_iteratorAbruptCompletion && _iterator["return"] != null)) {
- _context2.next = 27;
- break;
- }
-
- _context2.next = 27;
- return _iterator["return"]();
-
- case 27:
- _context2.prev = 27;
-
- if (!_didIteratorError) {
- _context2.next = 30;
- break;
- }
-
- throw _iteratorError;
-
- case 30:
- return _context2.finish(27);
-
- case 31:
- return _context2.finish(22);
-
- case 32:
- _context2.next = 37;
- break;
-
- case 34:
- _context2.prev = 34;
- _context2.t1 = _context2["catch"](0);
- console.error("error polling for TURN servers", _context2.t1);
-
- case 37:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2, this, [[0, 34], [5, 18, 22, 32], [23,, 27, 31]]);
- }));
-
- function pollTurnServers(_x2, _x3) {
- return _pollTurnServers.apply(this, arguments);
- }
-
- return pollTurnServers;
- }()
- }, {
- key: "handleWatchTurnServers",
- value: function () {
- var _handleWatchTurnServers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(request) {
- var turnServers, _yield$turnServers$ne, done, value;
-
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- if (this.hasCapability(_Capabilities.MatrixCapabilities.MSC3846TurnServers)) {
- _context3.next = 5;
- break;
- }
-
- _context3.next = 3;
- return this.transport.reply(request, {
- error: {
- message: "Missing capability"
- }
- });
-
- case 3:
- _context3.next = 30;
- break;
-
- case 5:
- if (!this.turnServers) {
- _context3.next = 10;
- break;
- }
-
- _context3.next = 8;
- return this.transport.reply(request, {});
-
- case 8:
- _context3.next = 30;
- break;
-
- case 10:
- _context3.prev = 10;
- turnServers = this.driver.getTurnServers(); // Peek at the first result, so we can at least verify that the
- // client isn't banned from getting TURN servers entirely
-
- _context3.next = 14;
- return turnServers.next();
-
- case 14:
- _yield$turnServers$ne = _context3.sent;
- done = _yield$turnServers$ne.done;
- value = _yield$turnServers$ne.value;
-
- if (!done) {
- _context3.next = 19;
- break;
- }
-
- throw new Error("Client refuses to provide any TURN servers");
-
- case 19:
- _context3.next = 21;
- return this.transport.reply(request, {});
-
- case 21:
- // Start the poll loop, sending the widget the initial result
- this.pollTurnServers(turnServers, value);
- this.turnServers = turnServers;
- _context3.next = 30;
- break;
-
- case 25:
- _context3.prev = 25;
- _context3.t0 = _context3["catch"](10);
- console.error("error getting first TURN server results", _context3.t0);
- _context3.next = 30;
- return this.transport.reply(request, {
- error: {
- message: "TURN servers not available"
- }
- });
-
- case 30:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee3, this, [[10, 25]]);
- }));
-
- function handleWatchTurnServers(_x4) {
- return _handleWatchTurnServers.apply(this, arguments);
- }
-
- return handleWatchTurnServers;
- }()
- }, {
- key: "handleUnwatchTurnServers",
- value: function () {
- var _handleUnwatchTurnServers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(request) {
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
- while (1) {
- switch (_context4.prev = _context4.next) {
- case 0:
- if (this.hasCapability(_Capabilities.MatrixCapabilities.MSC3846TurnServers)) {
- _context4.next = 5;
- break;
- }
-
- _context4.next = 3;
- return this.transport.reply(request, {
- error: {
- message: "Missing capability"
- }
- });
-
- case 3:
- _context4.next = 15;
- break;
-
- case 5:
- if (this.turnServers) {
- _context4.next = 10;
- break;
- }
-
- _context4.next = 8;
- return this.transport.reply(request, {});
-
- case 8:
- _context4.next = 15;
- break;
-
- case 10:
- _context4.next = 12;
- return this.turnServers["return"](undefined);
-
- case 12:
- this.turnServers = null;
- _context4.next = 15;
- return this.transport.reply(request, {});
-
- case 15:
- case "end":
- return _context4.stop();
- }
- }
- }, _callee4, this);
- }));
-
- function handleUnwatchTurnServers(_x5) {
- return _handleUnwatchTurnServers.apply(this, arguments);
- }
-
- return handleUnwatchTurnServers;
- }()
- }, {
- key: "handleReadRelations",
- value: function () {
- var _handleReadRelations = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(request) {
- var _this9 = this;
-
- var result, chunk;
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
- while (1) {
- switch (_context5.prev = _context5.next) {
- case 0:
- if (request.data.event_id) {
- _context5.next = 2;
- break;
- }
-
- return _context5.abrupt("return", this.transport.reply(request, {
- error: {
- message: "Invalid request - missing event ID"
- }
- }));
-
- case 2:
- if (!(request.data.limit !== undefined && request.data.limit < 0)) {
- _context5.next = 4;
- break;
- }
-
- return _context5.abrupt("return", this.transport.reply(request, {
- error: {
- message: "Invalid request - limit out of range"
- }
- }));
-
- case 4:
- if (!(request.data.room_id !== undefined && !this.canUseRoomTimeline(request.data.room_id))) {
- _context5.next = 6;
- break;
- }
-
- return _context5.abrupt("return", this.transport.reply(request, {
- error: {
- message: "Unable to access room timeline: ".concat(request.data.room_id)
- }
- }));
-
- case 6:
- _context5.prev = 6;
- _context5.next = 9;
- return this.driver.readEventRelations(request.data.event_id, request.data.room_id, request.data.rel_type, request.data.event_type, request.data.from, request.data.to, request.data.limit, request.data.direction);
-
- case 9:
- result = _context5.sent;
- // only return events that the user has the permission to receive
- chunk = result.chunk.filter(function (e) {
- if (e.state_key !== undefined) {
- return _this9.canReceiveStateEvent(e.type, e.state_key);
- } else {
- return _this9.canReceiveRoomEvent(e.type, e.content['msgtype']);
- }
- });
- return _context5.abrupt("return", this.transport.reply(request, {
- chunk: chunk,
- prev_batch: result.prevBatch,
- next_batch: result.nextBatch
- }));
-
- case 14:
- _context5.prev = 14;
- _context5.t0 = _context5["catch"](6);
- console.error("error getting the relations", _context5.t0);
- _context5.next = 19;
- return this.transport.reply(request, {
- error: {
- message: "Unexpected error while reading relations"
- }
- });
-
- case 19:
- case "end":
- return _context5.stop();
- }
- }
- }, _callee5, this, [[6, 14]]);
- }));
-
- function handleReadRelations(_x6) {
- return _handleReadRelations.apply(this, arguments);
- }
-
- return handleReadRelations;
- }()
- }, {
- key: "handleUserDirectorySearch",
- value: function () {
- var _handleUserDirectorySearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(request) {
- var result;
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
- while (1) {
- switch (_context6.prev = _context6.next) {
- case 0:
- if (this.hasCapability(_Capabilities.MatrixCapabilities.MSC3973UserDirectorySearch)) {
- _context6.next = 2;
- break;
- }
-
- return _context6.abrupt("return", this.transport.reply(request, {
- error: {
- message: "Missing capability"
- }
- }));
-
- case 2:
- if (!(typeof request.data.search_term !== 'string')) {
- _context6.next = 4;
- break;
- }
-
- return _context6.abrupt("return", this.transport.reply(request, {
- error: {
- message: "Invalid request - missing search term"
- }
- }));
-
- case 4:
- if (!(request.data.limit !== undefined && request.data.limit < 0)) {
- _context6.next = 6;
- break;
- }
-
- return _context6.abrupt("return", this.transport.reply(request, {
- error: {
- message: "Invalid request - limit out of range"
- }
- }));
-
- case 6:
- _context6.prev = 6;
- _context6.next = 9;
- return this.driver.searchUserDirectory(request.data.search_term, request.data.limit);
-
- case 9:
- result = _context6.sent;
- return _context6.abrupt("return", this.transport.reply(request, {
- limited: result.limited,
- results: result.results.map(function (r) {
- return {
- user_id: r.userId,
- display_name: r.displayName,
- avatar_url: r.avatarUrl
- };
- })
- }));
-
- case 13:
- _context6.prev = 13;
- _context6.t0 = _context6["catch"](6);
- console.error("error searching in the user directory", _context6.t0);
- _context6.next = 18;
- return this.transport.reply(request, {
- error: {
- message: "Unexpected error while searching in the user directory"
- }
- });
-
- case 18:
- case "end":
- return _context6.stop();
- }
- }
- }, _callee6, this, [[6, 13]]);
- }));
-
- function handleUserDirectorySearch(_x7) {
- return _handleUserDirectorySearch.apply(this, arguments);
- }
-
- return handleUserDirectorySearch;
- }()
- }, {
- key: "handleMessage",
- value: function handleMessage(ev) {
- if (this.isStopped) return;
- var actionEv = new CustomEvent("action:".concat(ev.detail.action), {
- detail: ev.detail,
- cancelable: true
- });
- this.emit("action:".concat(ev.detail.action), actionEv);
-
- if (!actionEv.defaultPrevented) {
- switch (ev.detail.action) {
- case _WidgetApiAction.WidgetApiFromWidgetAction.ContentLoaded:
- return this.handleContentLoadedAction(ev.detail);
-
- case _WidgetApiAction.WidgetApiFromWidgetAction.SupportedApiVersions:
- return this.replyVersions(ev.detail);
-
- case _WidgetApiAction.WidgetApiFromWidgetAction.SendEvent:
- return this.handleSendEvent(ev.detail);
-
- case _WidgetApiAction.WidgetApiFromWidgetAction.SendToDevice:
- return this.handleSendToDevice(ev.detail);
-
- case _WidgetApiAction.WidgetApiFromWidgetAction.GetOpenIDCredentials:
- return this.handleOIDC(ev.detail);
-
- case _WidgetApiAction.WidgetApiFromWidgetAction.MSC2931Navigate:
- return this.handleNavigate(ev.detail);
-
- case _WidgetApiAction.WidgetApiFromWidgetAction.MSC2974RenegotiateCapabilities:
- return this.handleCapabilitiesRenegotiate(ev.detail);
-
- case _WidgetApiAction.WidgetApiFromWidgetAction.MSC2876ReadEvents:
- return this.handleReadEvents(ev.detail);
-
- case _WidgetApiAction.WidgetApiFromWidgetAction.WatchTurnServers:
- return this.handleWatchTurnServers(ev.detail);
-
- case _WidgetApiAction.WidgetApiFromWidgetAction.UnwatchTurnServers:
- return this.handleUnwatchTurnServers(ev.detail);
-
- case _WidgetApiAction.WidgetApiFromWidgetAction.MSC3869ReadRelations:
- return this.handleReadRelations(ev.detail);
-
- case _WidgetApiAction.WidgetApiFromWidgetAction.MSC3973UserDirectorySearch:
- return this.handleUserDirectorySearch(ev.detail);
-
- default:
- return this.transport.reply(ev.detail, {
- error: {
- message: "Unknown or unsupported action: " + ev.detail.action
- }
- });
- }
- }
- }
- /**
- * Takes a screenshot of the widget.
- * @returns Resolves to the widget's screenshot.
- * @throws Throws if there is a problem.
- */
-
- }, {
- key: "takeScreenshot",
- value: function takeScreenshot() {
- return this.transport.send(_WidgetApiAction.WidgetApiToWidgetAction.TakeScreenshot, {});
- }
- /**
- * Alerts the widget to whether or not it is currently visible.
- * @param {boolean} isVisible Whether the widget is visible or not.
- * @returns {Promise<IWidgetApiResponseData>} Resolves when the widget acknowledges the update.
- */
-
- }, {
- key: "updateVisibility",
- value: function updateVisibility(isVisible) {
- return this.transport.send(_WidgetApiAction.WidgetApiToWidgetAction.UpdateVisibility, {
- visible: isVisible
- });
- }
- }, {
- key: "sendWidgetConfig",
- value: function sendWidgetConfig(data) {
- return this.transport.send(_WidgetApiAction.WidgetApiToWidgetAction.WidgetConfig, data).then();
- }
- }, {
- key: "notifyModalWidgetButtonClicked",
- value: function notifyModalWidgetButtonClicked(id) {
- return this.transport.send(_WidgetApiAction.WidgetApiToWidgetAction.ButtonClicked, {
- id: id
- }).then();
- }
- }, {
- key: "notifyModalWidgetClose",
- value: function notifyModalWidgetClose(data) {
- return this.transport.send(_WidgetApiAction.WidgetApiToWidgetAction.CloseModalWidget, data).then();
- }
- /**
- * Feeds an event to the widget. If the widget is not able to accept the event due to
- * permissions, this will no-op and return calmly. If the widget failed to handle the
- * event, this will raise an error.
- * @param {IRoomEvent} rawEvent The event to (try to) send to the widget.
- * @param {string} currentViewedRoomId The room ID the user is currently interacting with.
- * Not the room ID of the event.
- * @returns {Promise<void>} Resolves when complete, rejects if there was an error sending.
- */
-
- }, {
- key: "feedEvent",
- value: function () {
- var _feedEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(rawEvent, currentViewedRoomId) {
- var _rawEvent$content;
-
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
- while (1) {
- switch (_context7.prev = _context7.next) {
- case 0:
- if (!(rawEvent.room_id !== currentViewedRoomId && !this.canUseRoomTimeline(rawEvent.room_id))) {
- _context7.next = 2;
- break;
- }
-
- return _context7.abrupt("return");
-
- case 2:
- if (!(rawEvent.state_key !== undefined && rawEvent.state_key !== null)) {
- _context7.next = 7;
- break;
- }
-
- if (this.canReceiveStateEvent(rawEvent.type, rawEvent.state_key)) {
- _context7.next = 5;
- break;
- }
-
- return _context7.abrupt("return");
-
- case 5:
- _context7.next = 9;
- break;
-
- case 7:
- if (this.canReceiveRoomEvent(rawEvent.type, (_rawEvent$content = rawEvent.content) === null || _rawEvent$content === void 0 ? void 0 : _rawEvent$content["msgtype"])) {
- _context7.next = 9;
- break;
- }
-
- return _context7.abrupt("return");
-
- case 9:
- _context7.next = 11;
- return this.transport.send(_WidgetApiAction.WidgetApiToWidgetAction.SendEvent, rawEvent // it's compatible, but missing the index signature
- );
-
- case 11:
- case "end":
- return _context7.stop();
- }
- }
- }, _callee7, this);
- }));
-
- function feedEvent(_x8, _x9) {
- return _feedEvent.apply(this, arguments);
- }
-
- return feedEvent;
- }()
- /**
- * Feeds a to-device event to the widget. If the widget is not able to accept the
- * event due to permissions, this will no-op and return calmly. If the widget failed
- * to handle the event, this will raise an error.
- * @param {IRoomEvent} rawEvent The event to (try to) send to the widget.
- * @param {boolean} encrypted Whether the event contents were encrypted.
- * @returns {Promise<void>} Resolves when complete, rejects if there was an error sending.
- */
-
- }, {
- key: "feedToDevice",
- value: function () {
- var _feedToDevice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(rawEvent, encrypted) {
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
- while (1) {
- switch (_context8.prev = _context8.next) {
- case 0:
- if (!this.canReceiveToDeviceEvent(rawEvent.type)) {
- _context8.next = 3;
- break;
- }
-
- _context8.next = 3;
- return this.transport.send(_WidgetApiAction.WidgetApiToWidgetAction.SendToDevice, // it's compatible, but missing the index signature
- _objectSpread(_objectSpread({}, rawEvent), {}, {
- encrypted: encrypted
- }));
-
- case 3:
- case "end":
- return _context8.stop();
- }
- }
- }, _callee8, this);
- }));
-
- function feedToDevice(_x10, _x11) {
- return _feedToDevice.apply(this, arguments);
- }
-
- return feedToDevice;
- }()
- }]);
-
- return ClientWidgetApi;
-}(_events.EventEmitter);
-
-exports.ClientWidgetApi = ClientWidgetApi;
-},{"./Symbols":2,"./interfaces/ApiVersion":6,"./interfaces/Capabilities":7,"./interfaces/GetOpenIDAction":10,"./interfaces/WidgetApiAction":34,"./interfaces/WidgetApiDirection":35,"./models/WidgetEventCapability":40,"./transport/PostmessageTransport":46,"./util/SimpleObservable":47,"events":48}],2:[function(require,module,exports){
-"use strict";
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-exports.Symbols = void 0;
-
-/*
- * Copyright 2021 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.
- */
-var Symbols;
-exports.Symbols = Symbols;
-
-(function (Symbols) {
- Symbols["AnyRoom"] = "*";
-})(Symbols || (exports.Symbols = Symbols = {}));
-},{}],3:[function(require,module,exports){
-"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.WidgetApi = void 0;
-
-var _events = require("events");
-
-var _WidgetApiDirection = require("./interfaces/WidgetApiDirection");
-
-var _ApiVersion = require("./interfaces/ApiVersion");
-
-var _PostmessageTransport = require("./transport/PostmessageTransport");
-
-var _WidgetApiAction = require("./interfaces/WidgetApiAction");
-
-var _GetOpenIDAction = require("./interfaces/GetOpenIDAction");
-
-var _WidgetType = require("./interfaces/WidgetType");
-
-var _ModalWidgetActions = require("./interfaces/ModalWidgetActions");
-
-var _WidgetEventCapability = require("./models/WidgetEventCapability");
-
-var _Symbols = require("./Symbols");
-
-function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
-
-function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
-
-function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
-
-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 ? Object.setPrototypeOf.bind() : 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.bind() : 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; }
-
-function _awaitAsyncGenerator(value) { return new _AwaitValue(value); }
-
-function _wrapAsyncGenerator(fn) { return function () { return new _AsyncGenerator(fn.apply(this, arguments)); }; }
-
-function _AsyncGenerator(gen) { var front, back; function send(key, arg) { return new Promise(function (resolve, reject) { var request = { key: key, arg: arg, resolve: resolve, reject: reject, next: null }; if (back) { back = back.next = request; } else { front = back = request; resume(key, arg); } }); } function resume(key, arg) { try { var result = gen[key](arg); var value = result.value; var wrappedAwait = value instanceof _AwaitValue; Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { if (wrappedAwait) { resume(key === "return" ? "return" : "next", arg); return; } settle(result.done ? "return" : "normal", arg); }, function (err) { resume("throw", err); }); } catch (err) { settle("throw", err); } } function settle(type, value) { switch (type) { case "return": front.resolve({ value: value, done: true }); break; case "throw": front.reject(value); break; default: front.resolve({ value: value, done: false }); break; } front = front.next; if (front) { resume(front.key, front.arg); } else { back = null; } } this._invoke = send; if (typeof gen["return"] !== "function") { this["return"] = undefined; } }
-
-_AsyncGenerator.prototype[typeof Symbol === "function" && Symbol.asyncIterator || "@@asyncIterator"] = function () { return this; };
-
-_AsyncGenerator.prototype.next = function (arg) { return this._invoke("next", arg); };
-
-_AsyncGenerator.prototype["throw"] = function (arg) { return this._invoke("throw", arg); };
-
-_AsyncGenerator.prototype["return"] = function (arg) { return this._invoke("return", arg); };
-
-function _AwaitValue(value) { this.wrapped = value; }
-
-/**
- * API handler for widgets. This raises events for each action
- * received as `action:${action}` (eg: "action:screenshot").
- * Default handling can be prevented by using preventDefault()
- * on the raised event. The default handling varies for each
- * action: ones which the SDK can handle safely are acknowledged
- * appropriately and ones which are unhandled (custom or require
- * the widget to do something) are rejected with an error.
- *
- * Events which are preventDefault()ed must reply using the
- * transport. The events raised will have a detail of an
- * IWidgetApiRequest interface.
- *
- * When the WidgetApi is ready to start sending requests, it will
- * raise a "ready" CustomEvent. After the ready event fires, actions
- * can be sent and the transport will be ready.
- */
-var WidgetApi = /*#__PURE__*/function (_EventEmitter) {
- _inherits(WidgetApi, _EventEmitter);
-
- var _super = _createSuper(WidgetApi);
-
- /**
- * Creates a new API handler for the given widget.
- * @param {string} widgetId The widget ID to listen for. If not supplied then
- * the API will use the widget ID from the first valid request it receives.
- * @param {string} clientOrigin The origin of the client, or null if not known.
- */
- function WidgetApi() {
- var _this2;
-
- var widgetId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
- var clientOrigin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
-
- _classCallCheck(this, WidgetApi);
-
- _this2 = _super.call(this);
- _this2.clientOrigin = clientOrigin;
-
- _defineProperty(_assertThisInitialized(_this2), "transport", void 0);
-
- _defineProperty(_assertThisInitialized(_this2), "capabilitiesFinished", false);
-
- _defineProperty(_assertThisInitialized(_this2), "supportsMSC2974Renegotiate", false);
-
- _defineProperty(_assertThisInitialized(_this2), "requestedCapabilities", []);
-
- _defineProperty(_assertThisInitialized(_this2), "approvedCapabilities", void 0);
-
- _defineProperty(_assertThisInitialized(_this2), "cachedClientVersions", void 0);
-
- _defineProperty(_assertThisInitialized(_this2), "turnServerWatchers", 0);
-
- if (!window.parent) {
- throw new Error("No parent window. This widget doesn't appear to be embedded properly.");
- }
-
- _this2.transport = new _PostmessageTransport.PostmessageTransport(_WidgetApiDirection.WidgetApiDirection.FromWidget, widgetId, window.parent, window);
- _this2.transport.targetOrigin = clientOrigin;
-
- _this2.transport.on("message", _this2.handleMessage.bind(_assertThisInitialized(_this2)));
-
- return _this2;
- }
- /**
- * Determines if the widget was granted a particular capability. Note that on
- * clients where the capabilities are not fed back to the widget this function
- * will rely on requested capabilities instead.
- * @param {Capability} capability The capability to check for approval of.
- * @returns {boolean} True if the widget has approval for the given capability.
- */
-
-
- _createClass(WidgetApi, [{
- key: "hasCapability",
- value: function hasCapability(capability) {
- if (Array.isArray(this.approvedCapabilities)) {
- return this.approvedCapabilities.includes(capability);
- }
-
- return this.requestedCapabilities.includes(capability);
- }
- /**
- * Request a capability from the client. It is not guaranteed to be allowed,
- * but will be asked for.
- * @param {Capability} capability The capability to request.
- * @throws Throws if the capabilities negotiation has already started and the
- * widget is unable to request additional capabilities.
- */
-
- }, {
- key: "requestCapability",
- value: function requestCapability(capability) {
- if (this.capabilitiesFinished && !this.supportsMSC2974Renegotiate) {
- throw new Error("Capabilities have already been negotiated");
- }
-
- this.requestedCapabilities.push(capability);
- }
- /**
- * Request capabilities from the client. They are not guaranteed to be allowed,
- * but will be asked for if the negotiation has not already happened.
- * @param {Capability[]} capabilities The capabilities to request.
- * @throws Throws if the capabilities negotiation has already started.
- */
-
- }, {
- key: "requestCapabilities",
- value: function requestCapabilities(capabilities) {
- var _this3 = this;
-
- capabilities.forEach(function (cap) {
- return _this3.requestCapability(cap);
- });
- }
- /**
- * Requests the capability to interact with rooms other than the user's currently
- * viewed room. Applies to event receiving and sending.
- * @param {string | Symbols.AnyRoom} roomId The room ID, or `Symbols.AnyRoom` to
- * denote all known rooms.
- */
-
- }, {
- key: "requestCapabilityForRoomTimeline",
- value: function requestCapabilityForRoomTimeline(roomId) {
- this.requestCapability("org.matrix.msc2762.timeline:".concat(roomId));
- }
- /**
- * Requests the capability to send a given state event with optional explicit
- * state key. It is not guaranteed to be allowed, but will be asked for if the
- * negotiation has not already happened.
- * @param {string} eventType The state event type to ask for.
- * @param {string} stateKey If specified, the specific state key to request.
- * Otherwise all state keys will be requested.
- */
-
- }, {
- key: "requestCapabilityToSendState",
- value: function requestCapabilityToSendState(eventType, stateKey) {
- this.requestCapability(_WidgetEventCapability.WidgetEventCapability.forStateEvent(_WidgetEventCapability.EventDirection.Send, eventType, stateKey).raw);
- }
- /**
- * Requests the capability to receive a given state event with optional explicit
- * state key. It is not guaranteed to be allowed, but will be asked for if the
- * negotiation has not already happened.
- * @param {string} eventType The state event type to ask for.
- * @param {string} stateKey If specified, the specific state key to request.
- * Otherwise all state keys will be requested.
- */
-
- }, {
- key: "requestCapabilityToReceiveState",
- value: function requestCapabilityToReceiveState(eventType, stateKey) {
- this.requestCapability(_WidgetEventCapability.WidgetEventCapability.forStateEvent(_WidgetEventCapability.EventDirection.Receive, eventType, stateKey).raw);
- }
- /**
- * Requests the capability to send a given to-device event. It is not
- * guaranteed to be allowed, but will be asked for if the negotiation has
- * not already happened.
- * @param {string} eventType The room event type to ask for.
- */
-
- }, {
- key: "requestCapabilityToSendToDevice",
- value: function requestCapabilityToSendToDevice(eventType) {
- this.requestCapability(_WidgetEventCapability.WidgetEventCapability.forToDeviceEvent(_WidgetEventCapability.EventDirection.Send, eventType).raw);
- }
- /**
- * Requests the capability to receive a given to-device event. It is not
- * guaranteed to be allowed, but will be asked for if the negotiation has
- * not already happened.
- * @param {string} eventType The room event type to ask for.
- */
-
- }, {
- key: "requestCapabilityToReceiveToDevice",
- value: function requestCapabilityToReceiveToDevice(eventType) {
- this.requestCapability(_WidgetEventCapability.WidgetEventCapability.forToDeviceEvent(_WidgetEventCapability.EventDirection.Receive, eventType).raw);
- }
- /**
- * Requests the capability to send a given room event. It is not guaranteed to be
- * allowed, but will be asked for if the negotiation has not already happened.
- * @param {string} eventType The room event type to ask for.
- */
-
- }, {
- key: "requestCapabilityToSendEvent",
- value: function requestCapabilityToSendEvent(eventType) {
- this.requestCapability(_WidgetEventCapability.WidgetEventCapability.forRoomEvent(_WidgetEventCapability.EventDirection.Send, eventType).raw);
- }
- /**
- * Requests the capability to receive a given room event. It is not guaranteed to be
- * allowed, but will be asked for if the negotiation has not already happened.
- * @param {string} eventType The room event type to ask for.
- */
-
- }, {
- key: "requestCapabilityToReceiveEvent",
- value: function requestCapabilityToReceiveEvent(eventType) {
- this.requestCapability(_WidgetEventCapability.WidgetEventCapability.forRoomEvent(_WidgetEventCapability.EventDirection.Receive, eventType).raw);
- }
- /**
- * Requests the capability to send a given message event with optional explicit
- * `msgtype`. It is not guaranteed to be allowed, but will be asked for if the
- * negotiation has not already happened.
- * @param {string} msgtype If specified, the specific msgtype to request.
- * Otherwise all message types will be requested.
- */
-
- }, {
- key: "requestCapabilityToSendMessage",
- value: function requestCapabilityToSendMessage(msgtype) {
- this.requestCapability(_WidgetEventCapability.WidgetEventCapability.forRoomMessageEvent(_WidgetEventCapability.EventDirection.Send, msgtype).raw);
- }
- /**
- * Requests the capability to receive a given message event with optional explicit
- * `msgtype`. It is not guaranteed to be allowed, but will be asked for if the
- * negotiation has not already happened.
- * @param {string} msgtype If specified, the specific msgtype to request.
- * Otherwise all message types will be requested.
- */
-
- }, {
- key: "requestCapabilityToReceiveMessage",
- value: function requestCapabilityToReceiveMessage(msgtype) {
- this.requestCapability(_WidgetEventCapability.WidgetEventCapability.forRoomMessageEvent(_WidgetEventCapability.EventDirection.Receive, msgtype).raw);
- }
- /**
- * Requests an OpenID Connect token from the client for the currently logged in
- * user. This token can be validated server-side with the federation API. Note
- * that the widget is responsible for validating the token and caching any results
- * it needs.
- * @returns {Promise<IOpenIDCredentials>} Resolves to a token for verification.
- * @throws Throws if the user rejected the request or the request failed.
- */
-
- }, {
- key: "requestOpenIDConnectToken",
- value: function requestOpenIDConnectToken() {
- var _this4 = this;
-
- return new Promise(function (resolve, reject) {
- _this4.transport.sendComplete(_WidgetApiAction.WidgetApiFromWidgetAction.GetOpenIDCredentials, {}).then(function (response) {
- var rdata = response.response;
-
- if (rdata.state === _GetOpenIDAction.OpenIDRequestState.Allowed) {
- resolve(rdata);
- } else if (rdata.state === _GetOpenIDAction.OpenIDRequestState.Blocked) {
- reject(new Error("User declined to verify their identity"));
- } else if (rdata.state === _GetOpenIDAction.OpenIDRequestState.PendingUserConfirmation) {
- var handlerFn = function handlerFn(ev) {
- ev.preventDefault();
- var request = ev.detail;
- if (request.data.original_request_id !== response.requestId) return;
-
- if (request.data.state === _GetOpenIDAction.OpenIDRequestState.Allowed) {
- resolve(request.data);
-
- _this4.transport.reply(request, {}); // ack
-
- } else if (request.data.state === _GetOpenIDAction.OpenIDRequestState.Blocked) {
- reject(new Error("User declined to verify their identity"));
-
- _this4.transport.reply(request, {}); // ack
-
- } else {
- reject(new Error("Invalid state on reply: " + rdata.state));
-
- _this4.transport.reply(request, {
- error: {
- message: "Invalid state"
- }
- });
- }
-
- _this4.off("action:".concat(_WidgetApiAction.WidgetApiToWidgetAction.OpenIDCredentials), handlerFn);
- };
-
- _this4.on("action:".concat(_WidgetApiAction.WidgetApiToWidgetAction.OpenIDCredentials), handlerFn);
- } else {
- reject(new Error("Invalid state: " + rdata.state));
- }
- })["catch"](reject);
- });
- }
- /**
- * Asks the client for additional capabilities. Capabilities can be queued for this
- * request with the requestCapability() functions.
- * @returns {Promise<void>} Resolves when complete. Note that the promise resolves when
- * the capabilities request has gone through, not when the capabilities are approved/denied.
- * Use the WidgetApiToWidgetAction.NotifyCapabilities action to detect changes.
- */
-
- }, {
- key: "updateRequestedCapabilities",
- value: function updateRequestedCapabilities() {
- return this.transport.send(_WidgetApiAction.WidgetApiFromWidgetAction.MSC2974RenegotiateCapabilities, {
- capabilities: this.requestedCapabilities
- }).then();
- }
- /**
- * Tell the client that the content has been loaded.
- * @returns {Promise} Resolves when the client acknowledges the request.
- */
-
- }, {
- key: "sendContentLoaded",
- value: function sendContentLoaded() {
- return this.transport.send(_WidgetApiAction.WidgetApiFromWidgetAction.ContentLoaded, {}).then();
- }
- /**
- * Sends a sticker to the client.
- * @param {IStickerActionRequestData} sticker The sticker to send.
- * @returns {Promise} Resolves when the client acknowledges the request.
- */
-
- }, {
- key: "sendSticker",
- value: function sendSticker(sticker) {
- return this.transport.send(_WidgetApiAction.WidgetApiFromWidgetAction.SendSticker, sticker).then();
- }
- /**
- * Asks the client to set the always-on-screen status for this widget.
- * @param {boolean} value The new state to request.
- * @returns {Promise<boolean>} Resolve with true if the client was able to fulfill
- * the request, resolves to false otherwise. Rejects if an error occurred.
- */
-
- }, {
- key: "setAlwaysOnScreen",
- value: function setAlwaysOnScreen(value) {
- return this.transport.send(_WidgetApiAction.WidgetApiFromWidgetAction.UpdateAlwaysOnScreen, {
- value: value
- }).then(function (res) {
- return res.success;
- });
- }
- /**
- * Opens a modal widget.
- * @param {string} url The URL to the modal widget.
- * @param {string} name The name of the widget.
- * @param {IModalWidgetOpenRequestDataButton[]} buttons The buttons to have on the widget.
- * @param {IModalWidgetCreateData} data Data to supply to the modal widget.
- * @param {WidgetType} type The type of modal widget.
- * @returns {Promise<void>} Resolves when the modal widget has been opened.
- */
-
- }, {
- key: "openModalWidget",
- value: function openModalWidget(url, name) {
- var buttons = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
- var data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
- var type = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _WidgetType.MatrixWidgetType.Custom;
- return this.transport.send(_WidgetApiAction.WidgetApiFromWidgetAction.OpenModalWidget, {
- type: type,
- url: url,
- name: name,
- buttons: buttons,
- data: data
- }).then();
- }
- /**
- * Closes the modal widget. The widget's session will be terminated shortly after.
- * @param {IModalWidgetReturnData} data Optional data to close the modal widget with.
- * @returns {Promise<void>} Resolves when complete.
- */
-
- }, {
- key: "closeModalWidget",
- value: function closeModalWidget() {
- var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- return this.transport.send(_WidgetApiAction.WidgetApiFromWidgetAction.CloseModalWidget, data).then();
- }
- }, {
- key: "sendRoomEvent",
- value: function sendRoomEvent(eventType, content, roomId) {
- return this.transport.send(_WidgetApiAction.WidgetApiFromWidgetAction.SendEvent, {
- type: eventType,
- content: content,
- room_id: roomId
- });
- }
- }, {
- key: "sendStateEvent",
- value: function sendStateEvent(eventType, stateKey, content, roomId) {
- return this.transport.send(_WidgetApiAction.WidgetApiFromWidgetAction.SendEvent, {
- type: eventType,
- content: content,
- state_key: stateKey,
- room_id: roomId
- });
- }
- /**
- * Sends a to-device event.
- * @param {string} eventType The type of events being sent.
- * @param {boolean} encrypted Whether to encrypt the message contents.
- * @param {Object} contentMap A map from user IDs to device IDs to message contents.
- * @returns {Promise<ISendToDeviceFromWidgetResponseData>} Resolves when complete.
- */
-
- }, {
- key: "sendToDevice",
- value: function sendToDevice(eventType, encrypted, contentMap) {
- return this.transport.send(_WidgetApiAction.WidgetApiFromWidgetAction.SendToDevice, {
- type: eventType,
- encrypted: encrypted,
- messages: contentMap
- });
- }
- }, {
- key: "readRoomEvents",
- value: function readRoomEvents(eventType, limit, msgtype, roomIds) {
- var data = {
- type: eventType,
- msgtype: msgtype
- };
-
- if (limit !== undefined) {
- data.limit = limit;
- }
-
- if (roomIds) {
- if (roomIds.includes(_Symbols.Symbols.AnyRoom)) {
- data.room_ids = _Symbols.Symbols.AnyRoom;
- } else {
- data.room_ids = roomIds;
- }
- }
-
- return this.transport.send(_WidgetApiAction.WidgetApiFromWidgetAction.MSC2876ReadEvents, data).then(function (r) {
- return r.events;
- });
- }
- /**
- * Reads all related events given a known eventId.
- * @param eventId The id of the parent event to be read.
- * @param roomId The room to look within. When undefined, the user's currently
- * viewed room.
- * @param relationType The relationship type of child events to search for.
- * When undefined, all relations are returned.
- * @param eventType The event type of child events to search for. When undefined,
- * all related events are returned.
- * @param limit The maximum number of events to retrieve per room. If not
- * supplied, the server will apply a default limit.
- * @param from The pagination token to start returning results from, as
- * received from a previous call. If not supplied, results start at the most
- * recent topological event known to the server.
- * @param to The pagination token to stop returning results at. If not
- * supplied, results continue up to limit or until there are no more events.
- * @param direction The direction to search for according to MSC3715.
- * @returns Resolves to the room relations.
- */
-
- }, {
- key: "readEventRelations",
- value: function () {
- var _readEventRelations = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(eventId, roomId, relationType, eventType, limit, from, to, direction) {
- var versions, data;
- return _regeneratorRuntime().wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- _context.next = 2;
- return this.getClientVersions();
-
- case 2:
- versions = _context.sent;
-
- if (versions.includes(_ApiVersion.UnstableApiVersion.MSC3869)) {
- _context.next = 5;
- break;
- }
-
- throw new Error("The read_relations action is not supported by the client.");
-
- case 5:
- data = {
- event_id: eventId,
- rel_type: relationType,
- event_type: eventType,
- room_id: roomId,
- to: to,
- from: from,
- limit: limit,
- direction: direction
- };
- return _context.abrupt("return", this.transport.send(_WidgetApiAction.WidgetApiFromWidgetAction.MSC3869ReadRelations, data));
-
- case 7:
- case "end":
- return _context.stop();
- }
- }
- }, _callee, this);
- }));
-
- function readEventRelations(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8) {
- return _readEventRelations.apply(this, arguments);
- }
-
- return readEventRelations;
- }()
- }, {
- key: "readStateEvents",
- value: function readStateEvents(eventType, limit, stateKey, roomIds) {
- var data = {
- type: eventType,
- state_key: stateKey === undefined ? true : stateKey
- };
-
- if (limit !== undefined) {
- data.limit = limit;
- }
-
- if (roomIds) {
- if (roomIds.includes(_Symbols.Symbols.AnyRoom)) {
- data.room_ids = _Symbols.Symbols.AnyRoom;
- } else {
- data.room_ids = roomIds;
- }
- }
-
- return this.transport.send(_WidgetApiAction.WidgetApiFromWidgetAction.MSC2876ReadEvents, data).then(function (r) {
- return r.events;
- });
- }
- /**
- * Sets a button as disabled or enabled on the modal widget. Buttons are enabled by default.
- * @param {ModalButtonID} buttonId The button ID to enable/disable.
- * @param {boolean} isEnabled Whether or not the button is enabled.
- * @returns {Promise<void>} Resolves when complete.
- * @throws Throws if the button cannot be disabled, or the client refuses to disable the button.
- */
-
- }, {
- key: "setModalButtonEnabled",
- value: function setModalButtonEnabled(buttonId, isEnabled) {
- if (buttonId === _ModalWidgetActions.BuiltInModalButtonID.Close) {
- throw new Error("The close button cannot be disabled");
- }
-
- return this.transport.send(_WidgetApiAction.WidgetApiFromWidgetAction.SetModalButtonEnabled, {
- button: buttonId,
- enabled: isEnabled
- }).then();
- }
- /**
- * Attempts to navigate the client to the given URI. This can only be called with Matrix URIs
- * (currently only matrix.to, but in future a Matrix URI scheme will be defined).
- * @param {string} uri The URI to navigate to.
- * @returns {Promise<void>} Resolves when complete.
- * @throws Throws if the URI is invalid or cannot be processed.
- * @deprecated This currently relies on an unstable MSC (MSC2931).
- */
-
- }, {
- key: "navigateTo",
- value: function navigateTo(uri) {
- if (!uri || !uri.startsWith("https://matrix.to/#")) {
- throw new Error("Invalid matrix.to URI");
- }
-
- return this.transport.send(_WidgetApiAction.WidgetApiFromWidgetAction.MSC2931Navigate, {
- uri: uri
- }).then();
- }
- /**
- * Starts watching for TURN servers, yielding an initial set of credentials as soon as possible,
- * and thereafter yielding new credentials whenever the previous ones expire.
- * @yields {ITurnServer} The TURN server URIs and credentials currently available to the widget.
- */
-
- }, {
- key: "getTurnServers",
- value: function getTurnServers() {
- var _this = this;
-
- return _wrapAsyncGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
- var setTurnServer, onUpdateTurnServers;
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- onUpdateTurnServers = /*#__PURE__*/function () {
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(ev) {
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- ev.preventDefault();
- setTurnServer(ev.detail.data);
- _context2.next = 4;
- return _this.transport.reply(ev.detail, {});
-
- case 4:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2);
- }));
-
- return function onUpdateTurnServers(_x9) {
- return _ref.apply(this, arguments);
- };
- }(); // Start listening for updates before we even start watching, to catch
- // TURN data that is sent immediately
-
-
- _this.on("action:".concat(_WidgetApiAction.WidgetApiToWidgetAction.UpdateTurnServers), onUpdateTurnServers); // Only send the 'watch' action if we aren't already watching
-
-
- if (!(_this.turnServerWatchers === 0)) {
- _context3.next = 12;
- break;
- }
-
- _context3.prev = 3;
- _context3.next = 6;
- return _awaitAsyncGenerator(_this.transport.send(_WidgetApiAction.WidgetApiFromWidgetAction.WatchTurnServers, {}));
-
- case 6:
- _context3.next = 12;
- break;
-
- case 8:
- _context3.prev = 8;
- _context3.t0 = _context3["catch"](3);
-
- _this.off("action:".concat(_WidgetApiAction.WidgetApiToWidgetAction.UpdateTurnServers), onUpdateTurnServers);
-
- throw _context3.t0;
-
- case 12:
- _this.turnServerWatchers++;
- _context3.prev = 13;
-
- case 14:
- if (!true) {
- _context3.next = 21;
- break;
- }
-
- _context3.next = 17;
- return _awaitAsyncGenerator(new Promise(function (resolve) {
- return setTurnServer = resolve;
- }));
-
- case 17:
- _context3.next = 19;
- return _context3.sent;
-
- case 19:
- _context3.next = 14;
- break;
-
- case 21:
- _context3.prev = 21;
-
- // The loop was broken by the caller - clean up
- _this.off("action:".concat(_WidgetApiAction.WidgetApiToWidgetAction.UpdateTurnServers), onUpdateTurnServers); // Since sending the 'unwatch' action will end updates for all other
- // consumers, only send it if we're the only consumer remaining
-
-
- _this.turnServerWatchers--;
-
- if (!(_this.turnServerWatchers === 0)) {
- _context3.next = 27;
- break;
- }
-
- _context3.next = 27;
- return _awaitAsyncGenerator(_this.transport.send(_WidgetApiAction.WidgetApiFromWidgetAction.UnwatchTurnServers, {}));
-
- case 27:
- return _context3.finish(21);
-
- case 28:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee3, null, [[3, 8], [13,, 21, 28]]);
- }))();
- }
- /**
- * Search for users in the user directory.
- * @param searchTerm The term to search for.
- * @param limit The maximum number of results to return. If not supplied, the
- * @returns Resolves to the search results.
- */
-
- }, {
- key: "searchUserDirectory",
- value: function () {
- var _searchUserDirectory = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(searchTerm, limit) {
- var versions, data;
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
- while (1) {
- switch (_context4.prev = _context4.next) {
- case 0:
- _context4.next = 2;
- return this.getClientVersions();
-
- case 2:
- versions = _context4.sent;
-
- if (versions.includes(_ApiVersion.UnstableApiVersion.MSC3973)) {
- _context4.next = 5;
- break;
- }
-
- throw new Error("The user_directory_search action is not supported by the client.");
-
- case 5:
- data = {
- search_term: searchTerm,
- limit: limit
- };
- return _context4.abrupt("return", this.transport.send(_WidgetApiAction.WidgetApiFromWidgetAction.MSC3973UserDirectorySearch, data));
-
- case 7:
- case "end":
- return _context4.stop();
- }
- }
- }, _callee4, this);
- }));
-
- function searchUserDirectory(_x10, _x11) {
- return _searchUserDirectory.apply(this, arguments);
- }
-
- return searchUserDirectory;
- }()
- /**
- * Starts the communication channel. This should be done early to ensure
- * that messages are not missed. Communication can only be stopped by the client.
- */
-
- }, {
- key: "start",
- value: function start() {
- var _this5 = this;
-
- this.transport.start();
- this.getClientVersions().then(function (v) {
- if (v.includes(_ApiVersion.UnstableApiVersion.MSC2974)) {
- _this5.supportsMSC2974Renegotiate = true;
- }
- });
- }
- }, {
- key: "handleMessage",
- value: function handleMessage(ev) {
- var actionEv = new CustomEvent("action:".concat(ev.detail.action), {
- detail: ev.detail,
- cancelable: true
- });
- this.emit("action:".concat(ev.detail.action), actionEv);
-
- if (!actionEv.defaultPrevented) {
- switch (ev.detail.action) {
- case _WidgetApiAction.WidgetApiToWidgetAction.SupportedApiVersions:
- return this.replyVersions(ev.detail);
-
- case _WidgetApiAction.WidgetApiToWidgetAction.Capabilities:
- return this.handleCapabilities(ev.detail);
-
- case _WidgetApiAction.WidgetApiToWidgetAction.UpdateVisibility:
- return this.transport.reply(ev.detail, {});
- // ack to avoid error spam
-
- case _WidgetApiAction.WidgetApiToWidgetAction.NotifyCapabilities:
- return this.transport.reply(ev.detail, {});
- // ack to avoid error spam
-
- default:
- return this.transport.reply(ev.detail, {
- error: {
- message: "Unknown or unsupported action: " + ev.detail.action
- }
- });
- }
- }
- }
- }, {
- key: "replyVersions",
- value: function replyVersions(request) {
- this.transport.reply(request, {
- supported_versions: _ApiVersion.CurrentApiVersions
- });
- }
- }, {
- key: "getClientVersions",
- value: function getClientVersions() {
- var _this6 = this;
-
- if (Array.isArray(this.cachedClientVersions)) {
- return Promise.resolve(this.cachedClientVersions);
- }
-
- return this.transport.send(_WidgetApiAction.WidgetApiFromWidgetAction.SupportedApiVersions, {}).then(function (r) {
- _this6.cachedClientVersions = r.supported_versions;
- return r.supported_versions;
- })["catch"](function (e) {
- console.warn("non-fatal error getting supported client versions: ", e);
- return [];
- });
- }
- }, {
- key: "handleCapabilities",
- value: function handleCapabilities(request) {
- var _this7 = this;
-
- if (this.capabilitiesFinished) {
- return this.transport.reply(request, {
- error: {
- message: "Capability negotiation already completed"
- }
- });
- } // See if we can expect a capabilities notification or not
-
-
- return this.getClientVersions().then(function (v) {
- if (v.includes(_ApiVersion.UnstableApiVersion.MSC2871)) {
- _this7.once("action:".concat(_WidgetApiAction.WidgetApiToWidgetAction.NotifyCapabilities), function (ev) {
- _this7.approvedCapabilities = ev.detail.data.approved;
-
- _this7.emit("ready");
- });
- } else {
- // if we can't expect notification, we're as done as we can be
- _this7.emit("ready");
- } // in either case, reply to that capabilities request
-
-
- _this7.capabilitiesFinished = true;
- return _this7.transport.reply(request, {
- capabilities: _this7.requestedCapabilities
- });
- });
- }
- }]);
-
- return WidgetApi;
-}(_events.EventEmitter);
-
-exports.WidgetApi = WidgetApi;
-},{"./Symbols":2,"./interfaces/ApiVersion":6,"./interfaces/GetOpenIDAction":10,"./interfaces/ModalWidgetActions":20,"./interfaces/WidgetApiAction":34,"./interfaces/WidgetApiDirection":35,"./interfaces/WidgetType":38,"./models/WidgetEventCapability":40,"./transport/PostmessageTransport":46,"events":48}],4:[function(require,module,exports){
-"use strict";
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-exports.WidgetDriver = void 0;
-
-var _ = require("..");
-
-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; }
-
-/**
- * Represents the functions and behaviour the widget-api is unable to
- * do, such as prompting the user for information or interacting with
- * the UI. Clients are expected to implement this class and override
- * any functions they need/want to support.
- *
- * This class assumes the client will have a context of a Widget
- * instance already.
- */
-var WidgetDriver = /*#__PURE__*/function () {
- function WidgetDriver() {
- _classCallCheck(this, WidgetDriver);
- }
-
- _createClass(WidgetDriver, [{
- key: "validateCapabilities",
- value:
- /**
- * Verifies the widget's requested capabilities, returning the ones
- * it is approved to use. Mutating the requested capabilities will
- * have no effect.
- *
- * This SHOULD result in the user being prompted to approve/deny
- * capabilities.
- *
- * By default this rejects all capabilities (returns an empty set).
- * @param {Set<Capability>} requested The set of requested capabilities.
- * @returns {Promise<Set<Capability>>} Resolves to the allowed capabilities.
- */
- function validateCapabilities(requested) {
- return Promise.resolve(new Set());
- }
- /**
- * Sends an event into a room. If `roomId` is falsy, the client should send the event
- * into the room the user is currently looking at. The widget API will have already
- * verified that the widget is capable of sending the event to that room.
- * @param {string} eventType The event type to be sent.
- * @param {*} content The content for the event.
- * @param {string|null} stateKey The state key if this is a state event, otherwise null.
- * May be an empty string.
- * @param {string|null} roomId The room ID to send the event to. If falsy, the room the
- * user is currently looking at.
- * @returns {Promise<ISendEventDetails>} Resolves when the event has been sent with
- * details of that event.
- * @throws Rejected when the event could not be sent.
- */
-
- }, {
- key: "sendEvent",
- value: function sendEvent(eventType, content) {
- var stateKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
- var roomId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
- return Promise.reject(new Error("Failed to override function"));
- }
- /**
- * Sends a to-device event. The widget API will have already verified that the widget
- * is capable of sending the event.
- * @param {string} eventType The event type to be sent.
- * @param {boolean} encrypted Whether to encrypt the message contents.
- * @param {Object} contentMap A map from user ID and device ID to event content.
- * @returns {Promise<void>} Resolves when the event has been sent.
- * @throws Rejected when the event could not be sent.
- */
-
- }, {
- key: "sendToDevice",
- value: function sendToDevice(eventType, encrypted, contentMap) {
- return Promise.reject(new Error("Failed to override function"));
- }
- /**
- * Reads all events of the given type, and optionally `msgtype` (if applicable/defined),
- * the user has access to. The widget API will have already verified that the widget is
- * capable of receiving the events. Less events than the limit are allowed to be returned,
- * but not more. If `roomIds` is supplied, it may contain `Symbols.AnyRoom` to denote that
- * `limit` in each of the client's known rooms should be returned. When `null`, only the
- * room the user is currently looking at should be considered.
- * @param eventType The event type to be read.
- * @param msgtype The msgtype of the events to be read, if applicable/defined.
- * @param limit The maximum number of events to retrieve per room. Will be zero to denote "as many
- * as possible".
- * @param roomIds When null, the user's currently viewed room. Otherwise, the list of room IDs
- * to look within, possibly containing Symbols.AnyRoom to denote all known rooms.
- * @returns {Promise<IRoomEvent[]>} Resolves to the room events, or an empty array.
- */
-
- }, {
- key: "readRoomEvents",
- value: function readRoomEvents(eventType, msgtype, limit) {
- var roomIds = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
- return Promise.resolve([]);
- }
- /**
- * Reads all events of the given type, and optionally state key (if applicable/defined),
- * the user has access to. The widget API will have already verified that the widget is
- * capable of receiving the events. Less events than the limit are allowed to be returned,
- * but not more. If `roomIds` is supplied, it may contain `Symbols.AnyRoom` to denote that
- * `limit` in each of the client's known rooms should be returned. When `null`, only the
- * room the user is currently looking at should be considered.
- * @param eventType The event type to be read.
- * @param stateKey The state key of the events to be read, if applicable/defined.
- * @param limit The maximum number of events to retrieve. Will be zero to denote "as many
- * as possible".
- * @param roomIds When null, the user's currently viewed room. Otherwise, the list of room IDs
- * to look within, possibly containing Symbols.AnyRoom to denote all known rooms.
- * @returns {Promise<IRoomEvent[]>} Resolves to the state events, or an empty array.
- */
-
- }, {
- key: "readStateEvents",
- value: function readStateEvents(eventType, stateKey, limit) {
- var roomIds = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
- return Promise.resolve([]);
- }
- /**
- * Reads all events that are related to a given event. The widget API will
- * have already verified that the widget is capable of receiving the event,
- * or will make sure to reject access to events which are returned from this
- * function, but are not capable of receiving. If `relationType` or `eventType`
- * are set, the returned events should already be filtered. Less events than
- * the limit are allowed to be returned, but not more.
- * @param eventId The id of the parent event to be read.
- * @param roomId The room to look within. When undefined, the user's
- * currently viewed room.
- * @param relationType The relationship type of child events to search for.
- * When undefined, all relations are returned.
- * @param eventType The event type of child events to search for. When undefined,
- * all related events are returned.
- * @param from The pagination token to start returning results from, as
- * received from a previous call. If not supplied, results start at the most
- * recent topological event known to the server.
- * @param to The pagination token to stop returning results at. If not
- * supplied, results continue up to limit or until there are no more events.
- * @param limit The maximum number of events to retrieve per room. If not
- * supplied, the server will apply a default limit.
- * @param direction The direction to search for according to MSC3715
- * @returns Resolves to the room relations.
- */
-
- }, {
- key: "readEventRelations",
- value: function readEventRelations(eventId, roomId, relationType, eventType, from, to, limit, direction) {
- return Promise.resolve({
- chunk: []
- });
- }
- /**
- * Asks the user for permission to validate their identity through OpenID Connect. The
- * interface for this function is an observable which accepts the state machine of the
- * OIDC exchange flow. For example, if the client/user blocks the request then it would
- * feed back a `{state: Blocked}` into the observable. Similarly, if the user already
- * approved the widget then a `{state: Allowed}` would be fed into the observable alongside
- * the token itself. If the client is asking for permission, it should feed in a
- * `{state: PendingUserConfirmation}` followed by the relevant Allowed or Blocked state.
- *
- * The widget API will reject the widget's request with an error if this contract is not
- * met properly. By default, the widget driver will block all OIDC requests.
- * @param {SimpleObservable<IOpenIDUpdate>} observer The observable to feed updates into.
- */
-
- }, {
- key: "askOpenID",
- value: function askOpenID(observer) {
- observer.update({
- state: _.OpenIDRequestState.Blocked
- });
- }
- /**
- * Navigates the client with a matrix.to URI. In future this function will also be provided
- * with the Matrix URIs once matrix.to is replaced. The given URI will have already been
- * lightly checked to ensure it looks like a valid URI, though the implementation is recommended
- * to do further checks on the URI.
- * @param {string} uri The URI to navigate to.
- * @returns {Promise<void>} Resolves when complete.
- * @throws Throws if there's a problem with the navigation, such as invalid format.
- */
-
- }, {
- key: "navigate",
- value: function navigate(uri) {
- throw new Error("Navigation is not implemented");
- }
- /**
- * Polls for TURN server data, yielding an initial set of credentials as soon as possible, and
- * thereafter yielding new credentials whenever the previous ones expire. The widget API will
- * have already verified that the widget has permission to access TURN servers.
- * @yields {ITurnServer} The TURN server URIs and credentials currently available to the client.
- */
-
- }, {
- key: "getTurnServers",
- value: function getTurnServers() {
- throw new Error("TURN server support is not implemented");
- }
- /**
- * Search for users in the user directory.
- * @param searchTerm The term to search for.
- * @param limit The maximum number of results to return. If not supplied, the
- * @returns Resolves to the search results.
- */
-
- }, {
- key: "searchUserDirectory",
- value: function searchUserDirectory(searchTerm, limit) {
- return Promise.resolve({
- limited: false,
- results: []
- });
- }
- }]);
-
- return WidgetDriver;
-}();
-
-exports.WidgetDriver = WidgetDriver;
-},{"..":5}],5:[function(require,module,exports){
-"use strict";
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-
-var _WidgetApi = require("./WidgetApi");
-
-Object.keys(_WidgetApi).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _WidgetApi[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _WidgetApi[key];
- }
- });
-});
-
-var _ClientWidgetApi = require("./ClientWidgetApi");
-
-Object.keys(_ClientWidgetApi).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _ClientWidgetApi[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _ClientWidgetApi[key];
- }
- });
-});
-
-var _Symbols = require("./Symbols");
-
-Object.keys(_Symbols).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _Symbols[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _Symbols[key];
- }
- });
-});
-
-var _ITransport = require("./transport/ITransport");
-
-Object.keys(_ITransport).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _ITransport[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _ITransport[key];
- }
- });
-});
-
-var _PostmessageTransport = require("./transport/PostmessageTransport");
-
-Object.keys(_PostmessageTransport).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _PostmessageTransport[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _PostmessageTransport[key];
- }
- });
-});
-
-var _ICustomWidgetData = require("./interfaces/ICustomWidgetData");
-
-Object.keys(_ICustomWidgetData).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _ICustomWidgetData[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _ICustomWidgetData[key];
- }
- });
-});
-
-var _IJitsiWidgetData = require("./interfaces/IJitsiWidgetData");
-
-Object.keys(_IJitsiWidgetData).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _IJitsiWidgetData[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _IJitsiWidgetData[key];
- }
- });
-});
-
-var _IStickerpickerWidgetData = require("./interfaces/IStickerpickerWidgetData");
-
-Object.keys(_IStickerpickerWidgetData).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _IStickerpickerWidgetData[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _IStickerpickerWidgetData[key];
- }
- });
-});
-
-var _IWidget = require("./interfaces/IWidget");
-
-Object.keys(_IWidget).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _IWidget[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _IWidget[key];
- }
- });
-});
-
-var _WidgetType = require("./interfaces/WidgetType");
-
-Object.keys(_WidgetType).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _WidgetType[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _WidgetType[key];
- }
- });
-});
-
-var _IWidgetApiErrorResponse = require("./interfaces/IWidgetApiErrorResponse");
-
-Object.keys(_IWidgetApiErrorResponse).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _IWidgetApiErrorResponse[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _IWidgetApiErrorResponse[key];
- }
- });
-});
-
-var _IWidgetApiRequest = require("./interfaces/IWidgetApiRequest");
-
-Object.keys(_IWidgetApiRequest).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _IWidgetApiRequest[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _IWidgetApiRequest[key];
- }
- });
-});
-
-var _IWidgetApiResponse = require("./interfaces/IWidgetApiResponse");
-
-Object.keys(_IWidgetApiResponse).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _IWidgetApiResponse[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _IWidgetApiResponse[key];
- }
- });
-});
-
-var _WidgetApiAction = require("./interfaces/WidgetApiAction");
-
-Object.keys(_WidgetApiAction).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _WidgetApiAction[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _WidgetApiAction[key];
- }
- });
-});
-
-var _WidgetApiDirection = require("./interfaces/WidgetApiDirection");
-
-Object.keys(_WidgetApiDirection).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _WidgetApiDirection[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _WidgetApiDirection[key];
- }
- });
-});
-
-var _ApiVersion = require("./interfaces/ApiVersion");
-
-Object.keys(_ApiVersion).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _ApiVersion[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _ApiVersion[key];
- }
- });
-});
-
-var _Capabilities = require("./interfaces/Capabilities");
-
-Object.keys(_Capabilities).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _Capabilities[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _Capabilities[key];
- }
- });
-});
-
-var _CapabilitiesAction = require("./interfaces/CapabilitiesAction");
-
-Object.keys(_CapabilitiesAction).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _CapabilitiesAction[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _CapabilitiesAction[key];
- }
- });
-});
-
-var _ContentLoadedAction = require("./interfaces/ContentLoadedAction");
-
-Object.keys(_ContentLoadedAction).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _ContentLoadedAction[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _ContentLoadedAction[key];
- }
- });
-});
-
-var _ScreenshotAction = require("./interfaces/ScreenshotAction");
-
-Object.keys(_ScreenshotAction).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _ScreenshotAction[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _ScreenshotAction[key];
- }
- });
-});
-
-var _StickerAction = require("./interfaces/StickerAction");
-
-Object.keys(_StickerAction).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _StickerAction[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _StickerAction[key];
- }
- });
-});
-
-var _StickyAction = require("./interfaces/StickyAction");
-
-Object.keys(_StickyAction).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _StickyAction[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _StickyAction[key];
- }
- });
-});
-
-var _SupportedVersionsAction = require("./interfaces/SupportedVersionsAction");
-
-Object.keys(_SupportedVersionsAction).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _SupportedVersionsAction[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _SupportedVersionsAction[key];
- }
- });
-});
-
-var _VisibilityAction = require("./interfaces/VisibilityAction");
-
-Object.keys(_VisibilityAction).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _VisibilityAction[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _VisibilityAction[key];
- }
- });
-});
-
-var _GetOpenIDAction = require("./interfaces/GetOpenIDAction");
-
-Object.keys(_GetOpenIDAction).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _GetOpenIDAction[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _GetOpenIDAction[key];
- }
- });
-});
-
-var _OpenIDCredentialsAction = require("./interfaces/OpenIDCredentialsAction");
-
-Object.keys(_OpenIDCredentialsAction).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _OpenIDCredentialsAction[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _OpenIDCredentialsAction[key];
- }
- });
-});
-
-var _WidgetKind = require("./interfaces/WidgetKind");
-
-Object.keys(_WidgetKind).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _WidgetKind[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _WidgetKind[key];
- }
- });
-});
-
-var _ModalButtonKind = require("./interfaces/ModalButtonKind");
-
-Object.keys(_ModalButtonKind).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _ModalButtonKind[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _ModalButtonKind[key];
- }
- });
-});
-
-var _ModalWidgetActions = require("./interfaces/ModalWidgetActions");
-
-Object.keys(_ModalWidgetActions).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _ModalWidgetActions[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _ModalWidgetActions[key];
- }
- });
-});
-
-var _SetModalButtonEnabledAction = require("./interfaces/SetModalButtonEnabledAction");
-
-Object.keys(_SetModalButtonEnabledAction).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _SetModalButtonEnabledAction[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _SetModalButtonEnabledAction[key];
- }
- });
-});
-
-var _WidgetConfigAction = require("./interfaces/WidgetConfigAction");
-
-Object.keys(_WidgetConfigAction).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _WidgetConfigAction[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _WidgetConfigAction[key];
- }
- });
-});
-
-var _SendEventAction = require("./interfaces/SendEventAction");
-
-Object.keys(_SendEventAction).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _SendEventAction[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _SendEventAction[key];
- }
- });
-});
-
-var _SendToDeviceAction = require("./interfaces/SendToDeviceAction");
-
-Object.keys(_SendToDeviceAction).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _SendToDeviceAction[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _SendToDeviceAction[key];
- }
- });
-});
-
-var _ReadEventAction = require("./interfaces/ReadEventAction");
-
-Object.keys(_ReadEventAction).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _ReadEventAction[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _ReadEventAction[key];
- }
- });
-});
-
-var _IRoomEvent = require("./interfaces/IRoomEvent");
-
-Object.keys(_IRoomEvent).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _IRoomEvent[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _IRoomEvent[key];
- }
- });
-});
-
-var _NavigateAction = require("./interfaces/NavigateAction");
-
-Object.keys(_NavigateAction).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _NavigateAction[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _NavigateAction[key];
- }
- });
-});
-
-var _TurnServerActions = require("./interfaces/TurnServerActions");
-
-Object.keys(_TurnServerActions).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _TurnServerActions[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _TurnServerActions[key];
- }
- });
-});
-
-var _ReadRelationsAction = require("./interfaces/ReadRelationsAction");
-
-Object.keys(_ReadRelationsAction).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _ReadRelationsAction[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _ReadRelationsAction[key];
- }
- });
-});
-
-var _WidgetEventCapability = require("./models/WidgetEventCapability");
-
-Object.keys(_WidgetEventCapability).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _WidgetEventCapability[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _WidgetEventCapability[key];
- }
- });
-});
-
-var _url = require("./models/validation/url");
-
-Object.keys(_url).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _url[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _url[key];
- }
- });
-});
-
-var _utils = require("./models/validation/utils");
-
-Object.keys(_utils).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _utils[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _utils[key];
- }
- });
-});
-
-var _Widget = require("./models/Widget");
-
-Object.keys(_Widget).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _Widget[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _Widget[key];
- }
- });
-});
-
-var _WidgetParser = require("./models/WidgetParser");
-
-Object.keys(_WidgetParser).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _WidgetParser[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _WidgetParser[key];
- }
- });
-});
-
-var _urlTemplate = require("./templating/url-template");
-
-Object.keys(_urlTemplate).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _urlTemplate[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _urlTemplate[key];
- }
- });
-});
-
-var _SimpleObservable = require("./util/SimpleObservable");
-
-Object.keys(_SimpleObservable).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _SimpleObservable[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _SimpleObservable[key];
- }
- });
-});
-
-var _WidgetDriver = require("./driver/WidgetDriver");
-
-Object.keys(_WidgetDriver).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (key in exports && exports[key] === _WidgetDriver[key]) return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _WidgetDriver[key];
- }
- });
-});
-},{"./ClientWidgetApi":1,"./Symbols":2,"./WidgetApi":3,"./driver/WidgetDriver":4,"./interfaces/ApiVersion":6,"./interfaces/Capabilities":7,"./interfaces/CapabilitiesAction":8,"./interfaces/ContentLoadedAction":9,"./interfaces/GetOpenIDAction":10,"./interfaces/ICustomWidgetData":11,"./interfaces/IJitsiWidgetData":12,"./interfaces/IRoomEvent":13,"./interfaces/IStickerpickerWidgetData":14,"./interfaces/IWidget":15,"./interfaces/IWidgetApiErrorResponse":16,"./interfaces/IWidgetApiRequest":17,"./interfaces/IWidgetApiResponse":18,"./interfaces/ModalButtonKind":19,"./interfaces/ModalWidgetActions":20,"./interfaces/NavigateAction":21,"./interfaces/OpenIDCredentialsAction":22,"./interfaces/ReadEventAction":23,"./interfaces/ReadRelationsAction":24,"./interfaces/ScreenshotAction":25,"./interfaces/SendEventAction":26,"./interfaces/SendToDeviceAction":27,"./interfaces/SetModalButtonEnabledAction":28,"./interfaces/StickerAction":29,"./interfaces/StickyAction":30,"./interfaces/SupportedVersionsAction":31,"./interfaces/TurnServerActions":32,"./interfaces/VisibilityAction":33,"./interfaces/WidgetApiAction":34,"./interfaces/WidgetApiDirection":35,"./interfaces/WidgetConfigAction":36,"./interfaces/WidgetKind":37,"./interfaces/WidgetType":38,"./models/Widget":39,"./models/WidgetEventCapability":40,"./models/WidgetParser":41,"./models/validation/url":42,"./models/validation/utils":43,"./templating/url-template":44,"./transport/ITransport":45,"./transport/PostmessageTransport":46,"./util/SimpleObservable":47}],6:[function(require,module,exports){
-"use strict";
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-exports.UnstableApiVersion = exports.MatrixApiVersion = exports.CurrentApiVersions = void 0;
-
-/*
- * Copyright 2020 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.
- */
-var MatrixApiVersion;
-exports.MatrixApiVersion = MatrixApiVersion;
-
-(function (MatrixApiVersion) {
- MatrixApiVersion["Prerelease1"] = "0.0.1";
- MatrixApiVersion["Prerelease2"] = "0.0.2";
-})(MatrixApiVersion || (exports.MatrixApiVersion = MatrixApiVersion = {}));
-
-var UnstableApiVersion;
-exports.UnstableApiVersion = UnstableApiVersion;
-
-(function (UnstableApiVersion) {
- UnstableApiVersion["MSC2762"] = "org.matrix.msc2762";
- UnstableApiVersion["MSC2871"] = "org.matrix.msc2871";
- UnstableApiVersion["MSC2931"] = "org.matrix.msc2931";
- UnstableApiVersion["MSC2974"] = "org.matrix.msc2974";
- UnstableApiVersion["MSC2876"] = "org.matrix.msc2876";
- UnstableApiVersion["MSC3819"] = "org.matrix.msc3819";
- UnstableApiVersion["MSC3846"] = "town.robin.msc3846";
- UnstableApiVersion["MSC3869"] = "org.matrix.msc3869";
- UnstableApiVersion["MSC3973"] = "org.matrix.msc3973";
-})(UnstableApiVersion || (exports.UnstableApiVersion = UnstableApiVersion = {}));
-
-var CurrentApiVersions = [MatrixApiVersion.Prerelease1, MatrixApiVersion.Prerelease2, //MatrixApiVersion.V010,
-UnstableApiVersion.MSC2762, UnstableApiVersion.MSC2871, UnstableApiVersion.MSC2931, UnstableApiVersion.MSC2974, UnstableApiVersion.MSC2876, UnstableApiVersion.MSC3819, UnstableApiVersion.MSC3846, UnstableApiVersion.MSC3869, UnstableApiVersion.MSC3973];
-exports.CurrentApiVersions = CurrentApiVersions;
-},{}],7:[function(require,module,exports){
-"use strict";
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-exports.VideoConferenceCapabilities = exports.StickerpickerCapabilities = exports.MatrixCapabilities = void 0;
-exports.getTimelineRoomIDFromCapability = getTimelineRoomIDFromCapability;
-exports.isTimelineCapability = isTimelineCapability;
-exports.isTimelineCapabilityFor = isTimelineCapabilityFor;
-
-/*
- * Copyright 2020 - 2021 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.
- */
-var MatrixCapabilities;
-exports.MatrixCapabilities = MatrixCapabilities;
-
-(function (MatrixCapabilities) {
- MatrixCapabilities["Screenshots"] = "m.capability.screenshot";
- MatrixCapabilities["StickerSending"] = "m.sticker";
- MatrixCapabilities["AlwaysOnScreen"] = "m.always_on_screen";
- MatrixCapabilities["RequiresClient"] = "io.element.requires_client";
- MatrixCapabilities["MSC2931Navigate"] = "org.matrix.msc2931.navigate";
- MatrixCapabilities["MSC3846TurnServers"] = "town.robin.msc3846.turn_servers";
- MatrixCapabilities["MSC3973UserDirectorySearch"] = "org.matrix.msc3973.user_directory_search";
-})(MatrixCapabilities || (exports.MatrixCapabilities = MatrixCapabilities = {}));
-
-var StickerpickerCapabilities = [MatrixCapabilities.StickerSending];
-exports.StickerpickerCapabilities = StickerpickerCapabilities;
-var VideoConferenceCapabilities = [MatrixCapabilities.AlwaysOnScreen];
-/**
- * Determines if a capability is a capability for a timeline.
- * @param {Capability} capability The capability to test.
- * @returns {boolean} True if a timeline capability, false otherwise.
- */
-
-exports.VideoConferenceCapabilities = VideoConferenceCapabilities;
-
-function isTimelineCapability(capability) {
- // TODO: Change when MSC2762 becomes stable.
- return capability === null || capability === void 0 ? void 0 : capability.startsWith("org.matrix.msc2762.timeline:");
-}
-/**
- * Determines if a capability is a timeline capability for the given room.
- * @param {Capability} capability The capability to test.
- * @param {string | Symbols.AnyRoom} roomId The room ID, or `Symbols.AnyRoom` for that designation.
- * @returns {boolean} True if a matching capability, false otherwise.
- */
-
-
-function isTimelineCapabilityFor(capability, roomId) {
- return capability === "org.matrix.msc2762.timeline:".concat(roomId);
-}
-/**
- * Gets the room ID described by a timeline capability.
- * @param {string} capability The capability to parse.
- * @returns {string} The room ID.
- */
-
-
-function getTimelineRoomIDFromCapability(capability) {
- return capability.substring(capability.indexOf(":") + 1);
-}
-},{}],8:[function(require,module,exports){
-"use strict";
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-},{}],9:[function(require,module,exports){
-arguments[4][8][0].apply(exports,arguments)
-},{"dup":8}],10:[function(require,module,exports){
-"use strict";
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-exports.OpenIDRequestState = void 0;
-
-/*
- * Copyright 2020 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.
- */
-var OpenIDRequestState;
-exports.OpenIDRequestState = OpenIDRequestState;
-
-(function (OpenIDRequestState) {
- OpenIDRequestState["Allowed"] = "allowed";
- OpenIDRequestState["Blocked"] = "blocked";
- OpenIDRequestState["PendingUserConfirmation"] = "request";
-})(OpenIDRequestState || (exports.OpenIDRequestState = OpenIDRequestState = {}));
-},{}],11:[function(require,module,exports){
-arguments[4][8][0].apply(exports,arguments)
-},{"dup":8}],12:[function(require,module,exports){
-arguments[4][8][0].apply(exports,arguments)
-},{"dup":8}],13:[function(require,module,exports){
-arguments[4][8][0].apply(exports,arguments)
-},{"dup":8}],14:[function(require,module,exports){
-arguments[4][8][0].apply(exports,arguments)
-},{"dup":8}],15:[function(require,module,exports){
-arguments[4][8][0].apply(exports,arguments)
-},{"dup":8}],16:[function(require,module,exports){
-"use strict";
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-exports.isErrorResponse = isErrorResponse;
-
-/*
- * Copyright 2020 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 isErrorResponse(responseData) {
- if ("error" in responseData) {
- var err = responseData;
- return !!err.error.message;
- }
-
- return false;
-}
-},{}],17:[function(require,module,exports){
-arguments[4][8][0].apply(exports,arguments)
-},{"dup":8}],18:[function(require,module,exports){
-arguments[4][8][0].apply(exports,arguments)
-},{"dup":8}],19:[function(require,module,exports){
-"use strict";
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-exports.ModalButtonKind = void 0;
-
-/*
- * Copyright 2020 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.
- */
-var ModalButtonKind;
-exports.ModalButtonKind = ModalButtonKind;
-
-(function (ModalButtonKind) {
- ModalButtonKind["Primary"] = "m.primary";
- ModalButtonKind["Secondary"] = "m.secondary";
- ModalButtonKind["Warning"] = "m.warning";
- ModalButtonKind["Danger"] = "m.danger";
- ModalButtonKind["Link"] = "m.link";
-})(ModalButtonKind || (exports.ModalButtonKind = ModalButtonKind = {}));
-},{}],20:[function(require,module,exports){
-"use strict";
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-exports.BuiltInModalButtonID = void 0;
-
-/*
- * Copyright 2020 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.
- */
-var BuiltInModalButtonID;
-exports.BuiltInModalButtonID = BuiltInModalButtonID;
-
-(function (BuiltInModalButtonID) {
- BuiltInModalButtonID["Close"] = "m.close";
-})(BuiltInModalButtonID || (exports.BuiltInModalButtonID = BuiltInModalButtonID = {}));
-},{}],21:[function(require,module,exports){
-arguments[4][8][0].apply(exports,arguments)
-},{"dup":8}],22:[function(require,module,exports){
-arguments[4][8][0].apply(exports,arguments)
-},{"dup":8}],23:[function(require,module,exports){
-arguments[4][8][0].apply(exports,arguments)
-},{"dup":8}],24:[function(require,module,exports){
-arguments[4][8][0].apply(exports,arguments)
-},{"dup":8}],25:[function(require,module,exports){
-arguments[4][8][0].apply(exports,arguments)
-},{"dup":8}],26:[function(require,module,exports){
-arguments[4][8][0].apply(exports,arguments)
-},{"dup":8}],27:[function(require,module,exports){
-arguments[4][8][0].apply(exports,arguments)
-},{"dup":8}],28:[function(require,module,exports){
-arguments[4][8][0].apply(exports,arguments)
-},{"dup":8}],29:[function(require,module,exports){
-arguments[4][8][0].apply(exports,arguments)
-},{"dup":8}],30:[function(require,module,exports){
-arguments[4][8][0].apply(exports,arguments)
-},{"dup":8}],31:[function(require,module,exports){
-arguments[4][8][0].apply(exports,arguments)
-},{"dup":8}],32:[function(require,module,exports){
-arguments[4][8][0].apply(exports,arguments)
-},{"dup":8}],33:[function(require,module,exports){
-arguments[4][8][0].apply(exports,arguments)
-},{"dup":8}],34:[function(require,module,exports){
-"use strict";
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-exports.WidgetApiToWidgetAction = exports.WidgetApiFromWidgetAction = void 0;
-
-/*
- * Copyright 2020 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.
- */
-var WidgetApiToWidgetAction;
-exports.WidgetApiToWidgetAction = WidgetApiToWidgetAction;
-
-(function (WidgetApiToWidgetAction) {
- WidgetApiToWidgetAction["SupportedApiVersions"] = "supported_api_versions";
- WidgetApiToWidgetAction["Capabilities"] = "capabilities";
- WidgetApiToWidgetAction["NotifyCapabilities"] = "notify_capabilities";
- WidgetApiToWidgetAction["TakeScreenshot"] = "screenshot";
- WidgetApiToWidgetAction["UpdateVisibility"] = "visibility";
- WidgetApiToWidgetAction["OpenIDCredentials"] = "openid_credentials";
- WidgetApiToWidgetAction["WidgetConfig"] = "widget_config";
- WidgetApiToWidgetAction["CloseModalWidget"] = "close_modal";
- WidgetApiToWidgetAction["ButtonClicked"] = "button_clicked";
- WidgetApiToWidgetAction["SendEvent"] = "send_event";
- WidgetApiToWidgetAction["SendToDevice"] = "send_to_device";
- WidgetApiToWidgetAction["UpdateTurnServers"] = "update_turn_servers";
-})(WidgetApiToWidgetAction || (exports.WidgetApiToWidgetAction = WidgetApiToWidgetAction = {}));
-
-var WidgetApiFromWidgetAction;
-exports.WidgetApiFromWidgetAction = WidgetApiFromWidgetAction;
-
-(function (WidgetApiFromWidgetAction) {
- WidgetApiFromWidgetAction["SupportedApiVersions"] = "supported_api_versions";
- WidgetApiFromWidgetAction["ContentLoaded"] = "content_loaded";
- WidgetApiFromWidgetAction["SendSticker"] = "m.sticker";
- WidgetApiFromWidgetAction["UpdateAlwaysOnScreen"] = "set_always_on_screen";
- WidgetApiFromWidgetAction["GetOpenIDCredentials"] = "get_openid";
- WidgetApiFromWidgetAction["CloseModalWidget"] = "close_modal";
- WidgetApiFromWidgetAction["OpenModalWidget"] = "open_modal";
- WidgetApiFromWidgetAction["SetModalButtonEnabled"] = "set_button_enabled";
- WidgetApiFromWidgetAction["SendEvent"] = "send_event";
- WidgetApiFromWidgetAction["SendToDevice"] = "send_to_device";
- WidgetApiFromWidgetAction["WatchTurnServers"] = "watch_turn_servers";
- WidgetApiFromWidgetAction["UnwatchTurnServers"] = "unwatch_turn_servers";
- WidgetApiFromWidgetAction["MSC2876ReadEvents"] = "org.matrix.msc2876.read_events";
- WidgetApiFromWidgetAction["MSC2931Navigate"] = "org.matrix.msc2931.navigate";
- WidgetApiFromWidgetAction["MSC2974RenegotiateCapabilities"] = "org.matrix.msc2974.request_capabilities";
- WidgetApiFromWidgetAction["MSC3869ReadRelations"] = "org.matrix.msc3869.read_relations";
- WidgetApiFromWidgetAction["MSC3973UserDirectorySearch"] = "org.matrix.msc3973.user_directory_search";
-})(WidgetApiFromWidgetAction || (exports.WidgetApiFromWidgetAction = WidgetApiFromWidgetAction = {}));
-},{}],35:[function(require,module,exports){
-"use strict";
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-exports.WidgetApiDirection = void 0;
-exports.invertedDirection = invertedDirection;
-
-/*
- * Copyright 2020 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.
- */
-var WidgetApiDirection;
-exports.WidgetApiDirection = WidgetApiDirection;
-
-(function (WidgetApiDirection) {
- WidgetApiDirection["ToWidget"] = "toWidget";
- WidgetApiDirection["FromWidget"] = "fromWidget";
-})(WidgetApiDirection || (exports.WidgetApiDirection = WidgetApiDirection = {}));
-
-function invertedDirection(dir) {
- if (dir === WidgetApiDirection.ToWidget) {
- return WidgetApiDirection.FromWidget;
- } else if (dir === WidgetApiDirection.FromWidget) {
- return WidgetApiDirection.ToWidget;
- } else {
- throw new Error("Invalid direction");
- }
-}
-},{}],36:[function(require,module,exports){
-arguments[4][8][0].apply(exports,arguments)
-},{"dup":8}],37:[function(require,module,exports){
-"use strict";
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-exports.WidgetKind = void 0;
-
-/*
- * Copyright 2020 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.
- */
-var WidgetKind;
-exports.WidgetKind = WidgetKind;
-
-(function (WidgetKind) {
- WidgetKind["Room"] = "room";
- WidgetKind["Account"] = "account";
- WidgetKind["Modal"] = "modal";
-})(WidgetKind || (exports.WidgetKind = WidgetKind = {}));
-},{}],38:[function(require,module,exports){
-"use strict";
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-exports.MatrixWidgetType = void 0;
-
-/*
- * Copyright 2020 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.
- */
-var MatrixWidgetType;
-exports.MatrixWidgetType = MatrixWidgetType;
-
-(function (MatrixWidgetType) {
- MatrixWidgetType["Custom"] = "m.custom";
- MatrixWidgetType["JitsiMeet"] = "m.jitsi";
- MatrixWidgetType["Stickerpicker"] = "m.stickerpicker";
-})(MatrixWidgetType || (exports.MatrixWidgetType = MatrixWidgetType = {}));
-},{}],39:[function(require,module,exports){
-"use strict";
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-exports.Widget = void 0;
-
-var _utils = require("./validation/utils");
-
-var _ = require("..");
-
-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; }
-
-/**
- * Represents the barest form of widget.
- */
-var Widget = /*#__PURE__*/function () {
- function Widget(definition) {
- _classCallCheck(this, Widget);
-
- this.definition = definition;
- if (!this.definition) throw new Error("Definition is required");
- (0, _utils.assertPresent)(definition, "id");
- (0, _utils.assertPresent)(definition, "creatorUserId");
- (0, _utils.assertPresent)(definition, "type");
- (0, _utils.assertPresent)(definition, "url");
- }
- /**
- * The user ID who created the widget.
- */
-
-
- _createClass(Widget, [{
- key: "creatorUserId",
- get: function get() {
- return this.definition.creatorUserId;
- }
- /**
- * The type of widget.
- */
-
- }, {
- key: "type",
- get: function get() {
- return this.definition.type;
- }
- /**
- * The ID of the widget.
- */
-
- }, {
- key: "id",
- get: function get() {
- return this.definition.id;
- }
- /**
- * The name of the widget, or null if not set.
- */
-
- }, {
- key: "name",
- get: function get() {
- return this.definition.name || null;
- }
- /**
- * The title for the widget, or null if not set.
- */
-
- }, {
- key: "title",
- get: function get() {
- return this.rawData.title || null;
- }
- /**
- * The templated URL for the widget.
- */
-
- }, {
- key: "templateUrl",
- get: function get() {
- return this.definition.url;
- }
- /**
- * The origin for this widget.
- */
-
- }, {
- key: "origin",
- get: function get() {
- return new URL(this.templateUrl).origin;
- }
- /**
- * Whether or not the client should wait for the iframe to load. Defaults
- * to true.
- */
-
- }, {
- key: "waitForIframeLoad",
- get: function get() {
- if (this.definition.waitForIframeLoad === false) return false;
- if (this.definition.waitForIframeLoad === true) return true;
- return true; // default true
- }
- /**
- * The raw data for the widget. This will always be defined, though
- * may be empty.
- */
-
- }, {
- key: "rawData",
- get: function get() {
- return this.definition.data || {};
- }
- /**
- * Gets a complete widget URL for the client to render.
- * @param {ITemplateParams} params The template parameters.
- * @returns {string} A templated URL.
- */
-
- }, {
- key: "getCompleteUrl",
- value: function getCompleteUrl(params) {
- return (0, _.runTemplate)(this.templateUrl, this.definition, params);
- }
- }]);
-
- return Widget;
-}();
-
-exports.Widget = Widget;
-},{"..":5,"./validation/utils":43}],40:[function(require,module,exports){
-"use strict";
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-exports.WidgetEventCapability = exports.EventKind = exports.EventDirection = 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; }
-
-/*
- * Copyright 2020 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.
- */
-var EventKind;
-exports.EventKind = EventKind;
-
-(function (EventKind) {
- EventKind["Event"] = "event";
- EventKind["State"] = "state_event";
- EventKind["ToDevice"] = "to_device";
-})(EventKind || (exports.EventKind = EventKind = {}));
-
-var EventDirection;
-exports.EventDirection = EventDirection;
-
-(function (EventDirection) {
- EventDirection["Send"] = "send";
- EventDirection["Receive"] = "receive";
-})(EventDirection || (exports.EventDirection = EventDirection = {}));
-
-var WidgetEventCapability = /*#__PURE__*/function () {
- function WidgetEventCapability(direction, eventType, kind, keyStr, raw) {
- _classCallCheck(this, WidgetEventCapability);
-
- this.direction = direction;
- this.eventType = eventType;
- this.kind = kind;
- this.keyStr = keyStr;
- this.raw = raw;
- }
-
- _createClass(WidgetEventCapability, [{
- key: "matchesAsStateEvent",
- value: function matchesAsStateEvent(direction, eventType, stateKey) {
- if (this.kind !== EventKind.State) return false; // not a state event
-
- if (this.direction !== direction) return false; // direction mismatch
-
- if (this.eventType !== eventType) return false; // event type mismatch
-
- if (this.keyStr === null) return true; // all state keys are allowed
-
- if (this.keyStr === stateKey) return true; // this state key is allowed
- // Default not allowed
-
- return false;
- }
- }, {
- key: "matchesAsToDeviceEvent",
- value: function matchesAsToDeviceEvent(direction, eventType) {
- if (this.kind !== EventKind.ToDevice) return false; // not a to-device event
-
- if (this.direction !== direction) return false; // direction mismatch
-
- if (this.eventType !== eventType) return false; // event type mismatch
- // Checks passed, the event is allowed
-
- return true;
- }
- }, {
- key: "matchesAsRoomEvent",
- value: function matchesAsRoomEvent(direction, eventType) {
- var msgtype = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
- if (this.kind !== EventKind.Event) return false; // not a room event
-
- if (this.direction !== direction) return false; // direction mismatch
-
- if (this.eventType !== eventType) return false; // event type mismatch
-
- if (this.eventType === "m.room.message") {
- if (this.keyStr === null) return true; // all message types are allowed
-
- if (this.keyStr === msgtype) return true; // this message type is allowed
- } else {
- return true; // already passed the check for if the event is allowed
- } // Default not allowed
-
-
- return false;
- }
- }], [{
- key: "forStateEvent",
- value: function forStateEvent(direction, eventType, stateKey) {
- // TODO: Enable support for m.* namespace once the MSC lands.
- // https://github.com/matrix-org/matrix-widget-api/issues/22
- eventType = eventType.replace(/#/g, '\\#');
- stateKey = stateKey !== null && stateKey !== undefined ? "#".concat(stateKey) : '';
- var str = "org.matrix.msc2762.".concat(direction, ".state_event:").concat(eventType).concat(stateKey); // cheat by sending it through the processor
-
- return WidgetEventCapability.findEventCapabilities([str])[0];
- }
- }, {
- key: "forToDeviceEvent",
- value: function forToDeviceEvent(direction, eventType) {
- // TODO: Enable support for m.* namespace once the MSC lands.
- // https://github.com/matrix-org/matrix-widget-api/issues/56
- var str = "org.matrix.msc3819.".concat(direction, ".to_device:").concat(eventType); // cheat by sending it through the processor
-
- return WidgetEventCapability.findEventCapabilities([str])[0];
- }
- }, {
- key: "forRoomEvent",
- value: function forRoomEvent(direction, eventType) {
- // TODO: Enable support for m.* namespace once the MSC lands.
- // https://github.com/matrix-org/matrix-widget-api/issues/22
- var str = "org.matrix.msc2762.".concat(direction, ".event:").concat(eventType); // cheat by sending it through the processor
-
- return WidgetEventCapability.findEventCapabilities([str])[0];
- }
- }, {
- key: "forRoomMessageEvent",
- value: function forRoomMessageEvent(direction, msgtype) {
- // TODO: Enable support for m.* namespace once the MSC lands.
- // https://github.com/matrix-org/matrix-widget-api/issues/22
- msgtype = msgtype === null || msgtype === undefined ? '' : msgtype;
- var str = "org.matrix.msc2762.".concat(direction, ".event:m.room.message#").concat(msgtype); // cheat by sending it through the processor
-
- return WidgetEventCapability.findEventCapabilities([str])[0];
- }
- /**
- * Parses a capabilities request to find all the event capability requests.
- * @param {Iterable<Capability>} capabilities The capabilities requested/to parse.
- * @returns {WidgetEventCapability[]} An array of event capability requests. May be empty, but never null.
- */
-
- }, {
- key: "findEventCapabilities",
- value: function findEventCapabilities(capabilities) {
- var parsed = [];
-
- var _iterator = _createForOfIteratorHelper(capabilities),
- _step;
-
- try {
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
- var cap = _step.value;
- var _direction = null;
- var eventSegment = void 0;
- var _kind = null; // TODO: Enable support for m.* namespace once the MSCs land.
- // https://github.com/matrix-org/matrix-widget-api/issues/22
- // https://github.com/matrix-org/matrix-widget-api/issues/56
-
- if (cap.startsWith("org.matrix.msc2762.send.event:")) {
- _direction = EventDirection.Send;
- _kind = EventKind.Event;
- eventSegment = cap.substring("org.matrix.msc2762.send.event:".length);
- } else if (cap.startsWith("org.matrix.msc2762.send.state_event:")) {
- _direction = EventDirection.Send;
- _kind = EventKind.State;
- eventSegment = cap.substring("org.matrix.msc2762.send.state_event:".length);
- } else if (cap.startsWith("org.matrix.msc3819.send.to_device:")) {
- _direction = EventDirection.Send;
- _kind = EventKind.ToDevice;
- eventSegment = cap.substring("org.matrix.msc3819.send.to_device:".length);
- } else if (cap.startsWith("org.matrix.msc2762.receive.event:")) {
- _direction = EventDirection.Receive;
- _kind = EventKind.Event;
- eventSegment = cap.substring("org.matrix.msc2762.receive.event:".length);
- } else if (cap.startsWith("org.matrix.msc2762.receive.state_event:")) {
- _direction = EventDirection.Receive;
- _kind = EventKind.State;
- eventSegment = cap.substring("org.matrix.msc2762.receive.state_event:".length);
- } else if (cap.startsWith("org.matrix.msc3819.receive.to_device:")) {
- _direction = EventDirection.Receive;
- _kind = EventKind.ToDevice;
- eventSegment = cap.substring("org.matrix.msc3819.receive.to_device:".length);
- }
-
- if (_direction === null || _kind === null || eventSegment === undefined) continue; // The capability uses `#` as a separator between event type and state key/msgtype,
- // so we split on that. However, a # is also valid in either one of those so we
- // join accordingly.
- // Eg: `m.room.message##m.text` is "m.room.message" event with msgtype "#m.text".
-
- var expectingKeyStr = eventSegment.startsWith("m.room.message#") || _kind === EventKind.State;
-
- var _keyStr = null;
-
- if (eventSegment.includes('#') && expectingKeyStr) {
- // Dev note: regex is difficult to write, so instead the rules are manually written
- // out. This is probably just as understandable as a boring regex though, so win-win?
- // Test cases:
- // str eventSegment keyStr
- // -------------------------------------------------------------
- // m.room.message# m.room.message <empty string>
- // m.room.message#test m.room.message test
- // m.room.message\# m.room.message# test
- // m.room.message##test m.room.message #test
- // m.room.message\##test m.room.message# test
- // m.room.message\\##test m.room.message\# test
- // m.room.message\\###test m.room.message\# #test
- // First step: explode the string
- var parts = eventSegment.split('#'); // To form the eventSegment, we'll keep finding parts of the exploded string until
- // there's one that doesn't end with the escape character (\). We'll then join those
- // segments together with the exploding character. We have to remember to consume the
- // escape character as well.
-
- var idx = parts.findIndex(function (p) {
- return !p.endsWith("\\");
- });
- eventSegment = parts.slice(0, idx + 1).map(function (p) {
- return p.endsWith('\\') ? p.substring(0, p.length - 1) : p;
- }).join('#'); // The keyStr is whatever is left over.
-
- _keyStr = parts.slice(idx + 1).join('#');
- }
-
- parsed.push(new WidgetEventCapability(_direction, eventSegment, _kind, _keyStr, cap));
- }
- } catch (err) {
- _iterator.e(err);
- } finally {
- _iterator.f();
- }
-
- return parsed;
- }
- }]);
-
- return WidgetEventCapability;
-}();
-
-exports.WidgetEventCapability = WidgetEventCapability;
-},{}],41:[function(require,module,exports){
-"use strict";
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-exports.WidgetParser = void 0;
-
-var _Widget = require("./Widget");
-
-var _url = require("./validation/url");
-
-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; }
-
-var WidgetParser = /*#__PURE__*/function () {
- function WidgetParser() {// private constructor because this is a util class
-
- _classCallCheck(this, WidgetParser);
- }
- /**
- * Parses widgets from the "m.widgets" account data event. This will always
- * return an array, though may be empty if no valid widgets were found.
- * @param {IAccountDataWidgets} content The content of the "m.widgets" account data.
- * @returns {Widget[]} The widgets in account data, or an empty array.
- */
-
-
- _createClass(WidgetParser, null, [{
- key: "parseAccountData",
- value: function parseAccountData(content) {
- if (!content) return [];
- var result = [];
-
- for (var _i = 0, _Object$keys = Object.keys(content); _i < _Object$keys.length; _i++) {
- var _widgetId = _Object$keys[_i];
- var roughWidget = content[_widgetId];
- if (!roughWidget) continue;
- if (roughWidget.type !== "m.widget" && roughWidget.type !== "im.vector.modular.widgets") continue;
- if (!roughWidget.sender) continue;
- var probableWidgetId = roughWidget.state_key || roughWidget.id;
- if (probableWidgetId !== _widgetId) continue;
- var asStateEvent = {
- content: roughWidget.content,
- sender: roughWidget.sender,
- type: "m.widget",
- state_key: _widgetId,
- event_id: "$example",
- room_id: "!example",
- origin_server_ts: 1
- };
- var widget = WidgetParser.parseRoomWidget(asStateEvent);
- if (widget) result.push(widget);
- }
-
- return result;
- }
- /**
- * Parses all the widgets possible in the given array. This will always return
- * an array, though may be empty if no widgets could be parsed.
- * @param {IStateEvent[]} currentState The room state to parse.
- * @returns {Widget[]} The widgets in the state, or an empty array.
- */
-
- }, {
- key: "parseWidgetsFromRoomState",
- value: function parseWidgetsFromRoomState(currentState) {
- if (!currentState) return [];
- var result = [];
-
- var _iterator = _createForOfIteratorHelper(currentState),
- _step;
-
- try {
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
- var state = _step.value;
- var widget = WidgetParser.parseRoomWidget(state);
- if (widget) result.push(widget);
- }
- } catch (err) {
- _iterator.e(err);
- } finally {
- _iterator.f();
- }
-
- return result;
- }
- /**
- * Parses a state event into a widget. If the state event does not represent
- * a widget (wrong event type, invalid widget, etc) then null is returned.
- * @param {IStateEvent} stateEvent The state event.
- * @returns {Widget|null} The widget, or null if invalid
- */
-
- }, {
- key: "parseRoomWidget",
- value: function parseRoomWidget(stateEvent) {
- if (!stateEvent) return null; // TODO: [Legacy] Remove legacy support
-
- if (stateEvent.type !== "m.widget" && stateEvent.type !== "im.vector.modular.widgets") {
- return null;
- } // Dev note: Throughout this function we have null safety to ensure that
- // if the caller did not supply something useful that we don't error. This
- // is done against the requirements of the interface because not everyone
- // will have an interface to validate against.
-
-
- var content = stateEvent.content || {}; // Form our best approximation of a widget with the information we have
-
- var estimatedWidget = {
- id: stateEvent.state_key,
- creatorUserId: content['creatorUserId'] || stateEvent.sender,
- name: content['name'],
- type: content['type'],
- url: content['url'],
- waitForIframeLoad: content['waitForIframeLoad'],
- data: content['data']
- }; // Finally, process that widget
-
- return WidgetParser.processEstimatedWidget(estimatedWidget);
- }
- }, {
- key: "processEstimatedWidget",
- value: function processEstimatedWidget(widget) {
- // Validate that the widget has the best chance of passing as a widget
- if (!widget.id || !widget.creatorUserId || !widget.type) {
- return null;
- }
-
- if (!(0, _url.isValidUrl)(widget.url)) {
- return null;
- } // TODO: Validate data for known widget types
-
-
- return new _Widget.Widget(widget);
- }
- }]);
-
- return WidgetParser;
-}();
-
-exports.WidgetParser = WidgetParser;
-},{"./Widget":39,"./validation/url":42}],42:[function(require,module,exports){
-"use strict";
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-exports.isValidUrl = isValidUrl;
-
-/*
- * Copyright 2020 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 isValidUrl(val) {
- if (!val) return false; // easy: not valid if not present
-
- try {
- var parsed = new URL(val);
-
- if (parsed.protocol !== "http" && parsed.protocol !== "https") {
- return false;
- }
-
- return true;
- } catch (e) {
- if (e instanceof TypeError) {
- return false;
- }
-
- throw e;
- }
-}
-},{}],43:[function(require,module,exports){
-"use strict";
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-exports.assertPresent = assertPresent;
-
-/*
- * Copyright 2020 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 assertPresent(obj, key) {
- if (!obj[key]) {
- throw new Error("".concat(key, " is required"));
- }
-}
-},{}],44:[function(require,module,exports){
-"use strict";
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-exports.runTemplate = runTemplate;
-exports.toString = toString;
-
-/*
- * Copyright 2020, 2021 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 runTemplate(url, widget, params) {
- // Always apply the supplied params over top of data to ensure the data can't lie about them.
- var variables = Object.assign({}, widget.data, {
- 'matrix_room_id': params.widgetRoomId || "",
- 'matrix_user_id': params.currentUserId,
- 'matrix_display_name': params.userDisplayName || params.currentUserId,
- 'matrix_avatar_url': params.userHttpAvatarUrl || "",
- 'matrix_widget_id': widget.id,
- // TODO: Convert to stable (https://github.com/matrix-org/matrix-doc/pull/2873)
- 'org.matrix.msc2873.client_id': params.clientId || "",
- 'org.matrix.msc2873.client_theme': params.clientTheme || "",
- 'org.matrix.msc2873.client_language': params.clientLanguage || ""
- });
- var result = url;
-
- for (var _i = 0, _Object$keys = Object.keys(variables); _i < _Object$keys.length; _i++) {
- var key = _Object$keys[_i];
- // Regex escape from https://stackoverflow.com/a/6969486/7037379
- var pattern = "$".concat(key).replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
-
- var rexp = new RegExp(pattern, 'g'); // This is technically not what we're supposed to do for a couple of reasons:
- // 1. We are assuming that there won't later be a $key match after we replace a variable.
- // 2. We are assuming that the variable is in a place where it can be escaped (eg: path or query string).
-
- result = result.replace(rexp, encodeURIComponent(toString(variables[key])));
- }
-
- return result;
-}
-
-function toString(a) {
- if (a === null || a === undefined) {
- return "".concat(a);
- }
-
- return String(a);
-}
-},{}],45:[function(require,module,exports){
-arguments[4][8][0].apply(exports,arguments)
-},{"dup":8}],46:[function(require,module,exports){
-"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.PostmessageTransport = void 0;
-
-var _events = require("events");
-
-var _ = require("..");
-
-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 ? Object.setPrototypeOf.bind() : 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.bind() : 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; }
-
-/**
- * Transport for the Widget API over postMessage.
- */
-var PostmessageTransport = /*#__PURE__*/function (_EventEmitter) {
- _inherits(PostmessageTransport, _EventEmitter);
-
- var _super = _createSuper(PostmessageTransport);
-
- function PostmessageTransport(sendDirection, initialWidgetId, transportWindow, inboundWindow) {
- var _this;
-
- _classCallCheck(this, PostmessageTransport);
-
- _this = _super.call(this);
- _this.sendDirection = sendDirection;
- _this.initialWidgetId = initialWidgetId;
- _this.transportWindow = transportWindow;
- _this.inboundWindow = inboundWindow;
-
- _defineProperty(_assertThisInitialized(_this), "strictOriginCheck", false);
-
- _defineProperty(_assertThisInitialized(_this), "targetOrigin", "*");
-
- _defineProperty(_assertThisInitialized(_this), "timeoutSeconds", 10);
-
- _defineProperty(_assertThisInitialized(_this), "_ready", false);
-
- _defineProperty(_assertThisInitialized(_this), "_widgetId", null);
-
- _defineProperty(_assertThisInitialized(_this), "outboundRequests", new Map());
-
- _defineProperty(_assertThisInitialized(_this), "stopController", new AbortController());
-
- _this._widgetId = initialWidgetId;
- return _this;
- }
-
- _createClass(PostmessageTransport, [{
- key: "ready",
- get: function get() {
- return this._ready;
- }
- }, {
- key: "widgetId",
- get: function get() {
- return this._widgetId || null;
- }
- }, {
- key: "nextRequestId",
- get: function get() {
- var idBase = "widgetapi-".concat(Date.now());
- var index = 0;
- var id = idBase;
-
- while (this.outboundRequests.has(id)) {
- id = "".concat(idBase, "-").concat(index++);
- } // reserve the ID
-
-
- this.outboundRequests.set(id, null);
- return id;
- }
- }, {
- key: "sendInternal",
- value: function sendInternal(message) {
- console.log("[PostmessageTransport] Sending object to ".concat(this.targetOrigin, ": "), message);
- this.transportWindow.postMessage(message, this.targetOrigin);
- }
- }, {
- key: "reply",
- value: function reply(request, responseData) {
- return this.sendInternal(_objectSpread(_objectSpread({}, request), {}, {
- response: responseData
- }));
- }
- }, {
- key: "send",
- value: function send(action, data) {
- return this.sendComplete(action, data).then(function (r) {
- return r.response;
- });
- }
- }, {
- key: "sendComplete",
- value: function sendComplete(action, data) {
- var _this2 = this;
-
- if (!this.ready || !this.widgetId) {
- return Promise.reject(new Error("Not ready or unknown widget ID"));
- }
-
- var request = {
- api: this.sendDirection,
- widgetId: this.widgetId,
- requestId: this.nextRequestId,
- action: action,
- data: data
- };
-
- if (action === _.WidgetApiToWidgetAction.UpdateVisibility) {
- request['visible'] = data['visible'];
- }
-
- return new Promise(function (prResolve, prReject) {
- var resolve = function resolve(response) {
- cleanUp();
- prResolve(response);
- };
-
- var reject = function reject(err) {
- cleanUp();
- prReject(err);
- };
-
- var timerId = setTimeout(function () {
- return reject(new Error("Request timed out"));
- }, (_this2.timeoutSeconds || 1) * 1000);
-
- var onStop = function onStop() {
- return reject(new Error("Transport stopped"));
- };
-
- _this2.stopController.signal.addEventListener("abort", onStop);
-
- var cleanUp = function cleanUp() {
- _this2.outboundRequests["delete"](request.requestId);
-
- clearTimeout(timerId);
-
- _this2.stopController.signal.removeEventListener("abort", onStop);
- };
-
- _this2.outboundRequests.set(request.requestId, {
- request: request,
- resolve: resolve,
- reject: reject
- });
-
- _this2.sendInternal(request);
- });
- }
- }, {
- key: "start",
- value: function start() {
- var _this3 = this;
-
- this.inboundWindow.addEventListener("message", function (ev) {
- _this3.handleMessage(ev);
- });
- this._ready = true;
- }
- }, {
- key: "stop",
- value: function stop() {
- this._ready = false;
- this.stopController.abort();
- }
- }, {
- key: "handleMessage",
- value: function handleMessage(ev) {
- if (this.stopController.signal.aborted) return;
- if (!ev.data) return; // invalid event
-
- if (this.strictOriginCheck && ev.origin !== window.origin) return; // bad origin
- // treat the message as a response first, then downgrade to a request
-
- var response = ev.data;
- if (!response.action || !response.requestId || !response.widgetId) return; // invalid request/response
-
- if (!response.response) {
- // it's a request
- var request = response;
- if (request.api !== (0, _.invertedDirection)(this.sendDirection)) return; // wrong direction
-
- this.handleRequest(request);
- } else {
- // it's a response
- if (response.api !== this.sendDirection) return; // wrong direction
-
- this.handleResponse(response);
- }
- }
- }, {
- key: "handleRequest",
- value: function handleRequest(request) {
- if (this.widgetId) {
- if (this.widgetId !== request.widgetId) return; // wrong widget
- } else {
- this._widgetId = request.widgetId;
- }
-
- this.emit("message", new CustomEvent("message", {
- detail: request
- }));
- }
- }, {
- key: "handleResponse",
- value: function handleResponse(response) {
- if (response.widgetId !== this.widgetId) return; // wrong widget
-
- var req = this.outboundRequests.get(response.requestId);
- if (!req) return; // response to an unknown request
-
- if ((0, _.isErrorResponse)(response.response)) {
- var _err = response.response;
- req.reject(new Error(_err.error.message));
- } else {
- req.resolve(response);
- }
- }
- }]);
-
- return PostmessageTransport;
-}(_events.EventEmitter);
-
-exports.PostmessageTransport = PostmessageTransport;
-},{"..":5,"events":48}],47:[function(require,module,exports){
-"use strict";
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-exports.SimpleObservable = 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; }
-
-/*
- * Copyright 2020 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.
- */
-var SimpleObservable = /*#__PURE__*/function () {
- function SimpleObservable(initialFn) {
- _classCallCheck(this, SimpleObservable);
-
- _defineProperty(this, "listeners", []);
-
- if (initialFn) this.listeners.push(initialFn);
- }
-
- _createClass(SimpleObservable, [{
- key: "onUpdate",
- value: function onUpdate(fn) {
- this.listeners.push(fn);
- }
- }, {
- key: "update",
- value: function update(val) {
- var _iterator = _createForOfIteratorHelper(this.listeners),
- _step;
-
- try {
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
- var listener = _step.value;
- listener(val);
- }
- } catch (err) {
- _iterator.e(err);
- } finally {
- _iterator.f();
- }
- }
- }, {
- key: "close",
- value: function close() {
- this.listeners = []; // reset
- }
- }]);
-
- return SimpleObservable;
-}();
-
-exports.SimpleObservable = SimpleObservable;
-},{}],48:[function(require,module,exports){
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
-// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-// USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-'use strict';
-
-var R = typeof Reflect === 'object' ? Reflect : null
-var ReflectApply = R && typeof R.apply === 'function'
- ? R.apply
- : function ReflectApply(target, receiver, args) {
- return Function.prototype.apply.call(target, receiver, args);
- }
-
-var ReflectOwnKeys
-if (R && typeof R.ownKeys === 'function') {
- ReflectOwnKeys = R.ownKeys
-} else if (Object.getOwnPropertySymbols) {
- ReflectOwnKeys = function ReflectOwnKeys(target) {
- return Object.getOwnPropertyNames(target)
- .concat(Object.getOwnPropertySymbols(target));
- };
-} else {
- ReflectOwnKeys = function ReflectOwnKeys(target) {
- return Object.getOwnPropertyNames(target);
- };
-}
-
-function ProcessEmitWarning(warning) {
- if (console && console.warn) console.warn(warning);
-}
-
-var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
- return value !== value;
-}
-
-function EventEmitter() {
- EventEmitter.init.call(this);
-}
-module.exports = EventEmitter;
-module.exports.once = once;
-
-// Backwards-compat with node 0.10.x
-EventEmitter.EventEmitter = EventEmitter;
-
-EventEmitter.prototype._events = undefined;
-EventEmitter.prototype._eventsCount = 0;
-EventEmitter.prototype._maxListeners = undefined;
-
-// By default EventEmitters will print a warning if more than 10 listeners are
-// added to it. This is a useful default which helps finding memory leaks.
-var defaultMaxListeners = 10;
-
-function checkListener(listener) {
- if (typeof listener !== 'function') {
- throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
- }
-}
-
-Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
- enumerable: true,
- get: function() {
- return defaultMaxListeners;
- },
- set: function(arg) {
- if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {
- throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.');
- }
- defaultMaxListeners = arg;
- }
-});
-
-EventEmitter.init = function() {
-
- if (this._events === undefined ||
- this._events === Object.getPrototypeOf(this)._events) {
- this._events = Object.create(null);
- this._eventsCount = 0;
- }
-
- this._maxListeners = this._maxListeners || undefined;
-};
-
-// Obviously not all Emitters should be limited to 10. This function allows
-// that to be increased. Set to zero for unlimited.
-EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
- if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {
- throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.');
- }
- this._maxListeners = n;
- return this;
-};
-
-function _getMaxListeners(that) {
- if (that._maxListeners === undefined)
- return EventEmitter.defaultMaxListeners;
- return that._maxListeners;
-}
-
-EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
- return _getMaxListeners(this);
-};
-
-EventEmitter.prototype.emit = function emit(type) {
- var args = [];
- for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
- var doError = (type === 'error');
-
- var events = this._events;
- if (events !== undefined)
- doError = (doError && events.error === undefined);
- else if (!doError)
- return false;
-
- // If there is no 'error' event listener then throw.
- if (doError) {
- var er;
- if (args.length > 0)
- er = args[0];
- if (er instanceof Error) {
- // Note: The comments on the `throw` lines are intentional, they show
- // up in Node's output if this results in an unhandled exception.
- throw er; // Unhandled 'error' event
- }
- // At least give some kind of context to the user
- var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));
- err.context = er;
- throw err; // Unhandled 'error' event
- }
-
- var handler = events[type];
-
- if (handler === undefined)
- return false;
-
- if (typeof handler === 'function') {
- ReflectApply(handler, this, args);
- } else {
- var len = handler.length;
- var listeners = arrayClone(handler, len);
- for (var i = 0; i < len; ++i)
- ReflectApply(listeners[i], this, args);
- }
-
- return true;
-};
-
-function _addListener(target, type, listener, prepend) {
- var m;
- var events;
- var existing;
-
- checkListener(listener);
-
- events = target._events;
- if (events === undefined) {
- events = target._events = Object.create(null);
- target._eventsCount = 0;
- } else {
- // To avoid recursion in the case that type === "newListener"! Before
- // adding it to the listeners, first emit "newListener".
- if (events.newListener !== undefined) {
- target.emit('newListener', type,
- listener.listener ? listener.listener : listener);
-
- // Re-assign `events` because a newListener handler could have caused the
- // this._events to be assigned to a new object
- events = target._events;
- }
- existing = events[type];
- }
-
- if (existing === undefined) {
- // Optimize the case of one listener. Don't need the extra array object.
- existing = events[type] = listener;
- ++target._eventsCount;
- } else {
- if (typeof existing === 'function') {
- // Adding the second element, need to change to array.
- existing = events[type] =
- prepend ? [listener, existing] : [existing, listener];
- // If we've already got an array, just append.
- } else if (prepend) {
- existing.unshift(listener);
- } else {
- existing.push(listener);
- }
-
- // Check for listener leak
- m = _getMaxListeners(target);
- if (m > 0 && existing.length > m && !existing.warned) {
- existing.warned = true;
- // No error code for this since it is a Warning
- // eslint-disable-next-line no-restricted-syntax
- var w = new Error('Possible EventEmitter memory leak detected. ' +
- existing.length + ' ' + String(type) + ' listeners ' +
- 'added. Use emitter.setMaxListeners() to ' +
- 'increase limit');
- w.name = 'MaxListenersExceededWarning';
- w.emitter = target;
- w.type = type;
- w.count = existing.length;
- ProcessEmitWarning(w);
- }
- }
-
- return target;
-}
-
-EventEmitter.prototype.addListener = function addListener(type, listener) {
- return _addListener(this, type, listener, false);
-};
-
-EventEmitter.prototype.on = EventEmitter.prototype.addListener;
-
-EventEmitter.prototype.prependListener =
- function prependListener(type, listener) {
- return _addListener(this, type, listener, true);
- };
-
-function onceWrapper() {
- if (!this.fired) {
- this.target.removeListener(this.type, this.wrapFn);
- this.fired = true;
- if (arguments.length === 0)
- return this.listener.call(this.target);
- return this.listener.apply(this.target, arguments);
- }
-}
-
-function _onceWrap(target, type, listener) {
- var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
- var wrapped = onceWrapper.bind(state);
- wrapped.listener = listener;
- state.wrapFn = wrapped;
- return wrapped;
-}
-
-EventEmitter.prototype.once = function once(type, listener) {
- checkListener(listener);
- this.on(type, _onceWrap(this, type, listener));
- return this;
-};
-
-EventEmitter.prototype.prependOnceListener =
- function prependOnceListener(type, listener) {
- checkListener(listener);
- this.prependListener(type, _onceWrap(this, type, listener));
- return this;
- };
-
-// Emits a 'removeListener' event if and only if the listener was removed.
-EventEmitter.prototype.removeListener =
- function removeListener(type, listener) {
- var list, events, position, i, originalListener;
-
- checkListener(listener);
-
- events = this._events;
- if (events === undefined)
- return this;
-
- list = events[type];
- if (list === undefined)
- return this;
-
- if (list === listener || list.listener === listener) {
- if (--this._eventsCount === 0)
- this._events = Object.create(null);
- else {
- delete events[type];
- if (events.removeListener)
- this.emit('removeListener', type, list.listener || listener);
- }
- } else if (typeof list !== 'function') {
- position = -1;
-
- for (i = list.length - 1; i >= 0; i--) {
- if (list[i] === listener || list[i].listener === listener) {
- originalListener = list[i].listener;
- position = i;
- break;
- }
- }
-
- if (position < 0)
- return this;
-
- if (position === 0)
- list.shift();
- else {
- spliceOne(list, position);
- }
-
- if (list.length === 1)
- events[type] = list[0];
-
- if (events.removeListener !== undefined)
- this.emit('removeListener', type, originalListener || listener);
- }
-
- return this;
- };
-
-EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
-
-EventEmitter.prototype.removeAllListeners =
- function removeAllListeners(type) {
- var listeners, events, i;
-
- events = this._events;
- if (events === undefined)
- return this;
-
- // not listening for removeListener, no need to emit
- if (events.removeListener === undefined) {
- if (arguments.length === 0) {
- this._events = Object.create(null);
- this._eventsCount = 0;
- } else if (events[type] !== undefined) {
- if (--this._eventsCount === 0)
- this._events = Object.create(null);
- else
- delete events[type];
- }
- return this;
- }
-
- // emit removeListener for all listeners on all events
- if (arguments.length === 0) {
- var keys = Object.keys(events);
- var key;
- for (i = 0; i < keys.length; ++i) {
- key = keys[i];
- if (key === 'removeListener') continue;
- this.removeAllListeners(key);
- }
- this.removeAllListeners('removeListener');
- this._events = Object.create(null);
- this._eventsCount = 0;
- return this;
- }
-
- listeners = events[type];
-
- if (typeof listeners === 'function') {
- this.removeListener(type, listeners);
- } else if (listeners !== undefined) {
- // LIFO order
- for (i = listeners.length - 1; i >= 0; i--) {
- this.removeListener(type, listeners[i]);
- }
- }
-
- return this;
- };
-
-function _listeners(target, type, unwrap) {
- var events = target._events;
-
- if (events === undefined)
- return [];
-
- var evlistener = events[type];
- if (evlistener === undefined)
- return [];
-
- if (typeof evlistener === 'function')
- return unwrap ? [evlistener.listener || evlistener] : [evlistener];
-
- return unwrap ?
- unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
-}
-
-EventEmitter.prototype.listeners = function listeners(type) {
- return _listeners(this, type, true);
-};
-
-EventEmitter.prototype.rawListeners = function rawListeners(type) {
- return _listeners(this, type, false);
-};
-
-EventEmitter.listenerCount = function(emitter, type) {
- if (typeof emitter.listenerCount === 'function') {
- return emitter.listenerCount(type);
- } else {
- return listenerCount.call(emitter, type);
- }
-};
-
-EventEmitter.prototype.listenerCount = listenerCount;
-function listenerCount(type) {
- var events = this._events;
-
- if (events !== undefined) {
- var evlistener = events[type];
-
- if (typeof evlistener === 'function') {
- return 1;
- } else if (evlistener !== undefined) {
- return evlistener.length;
- }
- }
-
- return 0;
-}
-
-EventEmitter.prototype.eventNames = function eventNames() {
- return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
-};
-
-function arrayClone(arr, n) {
- var copy = new Array(n);
- for (var i = 0; i < n; ++i)
- copy[i] = arr[i];
- return copy;
-}
-
-function spliceOne(list, index) {
- for (; index + 1 < list.length; index++)
- list[index] = list[index + 1];
- list.pop();
-}
-
-function unwrapListeners(arr) {
- var ret = new Array(arr.length);
- for (var i = 0; i < ret.length; ++i) {
- ret[i] = arr[i].listener || arr[i];
- }
- return ret;
-}
-
-function once(emitter, name) {
- return new Promise(function (resolve, reject) {
- function errorListener(err) {
- emitter.removeListener(name, resolver);
- reject(err);
- }
-
- function resolver() {
- if (typeof emitter.removeListener === 'function') {
- emitter.removeListener('error', errorListener);
- }
- resolve([].slice.call(arguments));
- };
-
- eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });
- if (name !== 'error') {
- addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });
- }
- });
-}
-
-function addErrorHandlerIfEventEmitter(emitter, handler, flags) {
- if (typeof emitter.on === 'function') {
- eventTargetAgnosticAddListener(emitter, 'error', handler, flags);
- }
-}
-
-function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
- if (typeof emitter.on === 'function') {
- if (flags.once) {
- emitter.once(name, listener);
- } else {
- emitter.on(name, listener);
- }
- } else if (typeof emitter.addEventListener === 'function') {
- // EventTarget does not have `error` event semantics like Node
- // EventEmitters, we do not listen for `error` events here.
- emitter.addEventListener(name, function wrapListener(arg) {
- // IE does not have builtin `{ once: true }` support so we
- // have to do it manually.
- if (flags.once) {
- emitter.removeEventListener(name, wrapListener);
- }
- listener(arg);
- });
- } else {
- throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter);
- }
-}
-
-},{}]},{},[5])(5)
-});
-
-//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJsaWIvQ2xpZW50V2lkZ2V0QXBpLmpzIiwibGliL1N5bWJvbHMuanMiLCJsaWIvV2lkZ2V0QXBpLmpzIiwibGliL2RyaXZlci9XaWRnZXREcml2ZXIuanMiLCJsaWIvaW5kZXguanMiLCJsaWIvaW50ZXJmYWNlcy9BcGlWZXJzaW9uLmpzIiwibGliL2ludGVyZmFjZXMvQ2FwYWJpbGl0aWVzLmpzIiwibGliL2ludGVyZmFjZXMvQ2FwYWJpbGl0aWVzQWN0aW9uLmpzIiwibGliL2ludGVyZmFjZXMvR2V0T3BlbklEQWN0aW9uLmpzIiwibGliL2ludGVyZmFjZXMvSVdpZGdldEFwaUVycm9yUmVzcG9uc2UuanMiLCJsaWIvaW50ZXJmYWNlcy9Nb2RhbEJ1dHRvbktpbmQuanMiLCJsaWIvaW50ZXJmYWNlcy9Nb2RhbFdpZGdldEFjdGlvbnMuanMiLCJsaWIvaW50ZXJmYWNlcy9XaWRnZXRBcGlBY3Rpb24uanMiLCJsaWIvaW50ZXJmYWNlcy9XaWRnZXRBcGlEaXJlY3Rpb24uanMiLCJsaWIvaW50ZXJmYWNlcy9XaWRnZXRLaW5kLmpzIiwibGliL2ludGVyZmFjZXM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iAgICAgICAgICByb29tX2lkOiBzZW50RXZlbnQucm9vbUlkLFxuICAgICAgICAgIGV2ZW50X2lkOiBzZW50RXZlbnQuZXZlbnRJZFxuICAgICAgICB9KTtcbiAgICAgIH0pW1wiY2F0Y2hcIl0oZnVuY3Rpb24gKGUpIHtcbiAgICAgICAgY29uc29sZS5lcnJvcihcImVycm9yIHNlbmRpbmcgZXZlbnQ6IFwiLCBlKTtcbiAgICAgICAgcmV0dXJuIF90aGlzOC50cmFuc3BvcnQucmVwbHkocmVxdWVzdCwge1xuICAgICAgICAgIGVycm9yOiB7XG4gICAgICAgICAgICBtZXNzYWdlOiBcIkVycm9yIHNlbmRpbmcgZXZlbnRcIlxuICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgICB9KTtcbiAgICB9XG4gIH0sIHtcbiAgICBrZXk6IFwiaGFuZGxlU2VuZFRvRGV2aWNlXCIsXG4gICAgdmFsdWU6IGZ1bmN0aW9uICgpIHtcbiAgICAgIHZhciBfaGFuZGxlU2VuZFRvRGV2aWNlID0gX2FzeW5jVG9HZW5lcmF0b3IoIC8qI19fUFVSRV9fKi9fcmVnZW5lcmF0b3JSdW50aW1lKCkubWFyayhmdW5jdGlvbiBfY2FsbGVlKHJlcXVlc3QpIHtcbiAgICAgICAgcmV0dXJuIF9yZWdlbmVyYXRvclJ1bnRpbWUoKS53cmFwKGZ1bmN0aW9uIF9jYWxsZWUkKF9jb250ZXh0KSB7XG4gICAgICAgICAgd2hpbGUgKDEpIHtcbiAgICAgICAgICAgIHN3aXRjaCAoX2NvbnRleHQucHJldiA9IF9jb250ZXh0Lm5leHQpIHtcbiAgICAgICAgICAgICAgY2FzZSAwOlxuICAgICAgICAgICAgICAgIGlmIChyZXF1ZXN0LmRhdGEudHlwZSkge1xuICAgICAgICAgICAgICAgICAgX2NvbnRleHQubmV4dCA9IDU7XG4gICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBfY29udGV4dC5uZXh0ID0gMztcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy50cmFuc3BvcnQucmVwbHkocmVxdWVzdCwge1xuICAgICAgICAgICAgICAgICAgZXJyb3I6IHtcbiAgICAgICAgICAgICAgICAgICAgbWVzc2FnZTogXCJJbnZhbGlkIHJlcXVlc3QgLSBtaXNzaW5nIGV2ZW50IHR5cGVcIlxuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgIGNhc2UgMzpcbiAgICAgICAgICAgICAgICBfY29udGV4dC5uZXh0ID0gMzI7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICAgICAgY2FzZSA1OlxuICAgICAgICAgICAgICAgIGlmIChyZXF1ZXN0LmRhdGEubWVzc2FnZXMpIHtcbiAgICAgICAgICAgICAgICAgIF9jb250ZXh0Lm5leHQgPSAxMDtcbiAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIF9jb250ZXh0Lm5leHQgPSA4O1xuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnRyYW5zcG9ydC5yZXBseShyZXF1ZXN0LCB7XG4gICAgICAgICAgICAgICAgICBlcnJvcjoge1xuICAgICAgICAgICAgICAgICAgICBtZXNzYWdlOiBcIkludmFsaWQgcmVxdWVzdCAtIG1pc3NpbmcgZXZlbnQgY29udGVudHNcIlxuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgIGNhc2UgODpcbiAgICAgICAgICAgICAgICBfY29udGV4dC5uZXh0ID0gMzI7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICAgICAgY2FzZSAxMDpcbiAgICAgICAgICAgICAgICBpZiAoISh0eXBlb2YgcmVxdWVzdC5kYXRhLmVuY3J5cHRlZCAhPT0gXCJib29sZWFuXCIpKSB7XG4gICAgICAgICAgICAgICAgICBfY29udGV4dC5uZXh0ID0gMTU7XG4gICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBfY29udGV4dC5uZXh0ID0gMTM7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMudHJhbnNwb3J0LnJlcGx5KHJlcXVlc3QsIHtcbiAgICAgICAgICAgICAgICAgIGVycm9yOiB7XG4gICAgICAgICAgICAgICAgICAgIG1lc3NhZ2U6IFwiSW52YWxpZCByZXF1ZXN0IC0gbWlzc2luZyBlbmNyeXB0aW9uIGZsYWdcIlxuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgIGNhc2UgMTM6XG4gICAgICAgICAgICAgICAgX2NvbnRleHQubmV4dCA9IDMyO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuXG4gICAgICAgICAgICAgIGNhc2UgMTU6XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuY2FuU2VuZFRvRGV2aWNlRXZlbnQocmVxdWVzdC5kYXRhLnR5cGUpKSB7XG4gICAgICAgICAgICAgICAgICBfY29udGV4dC5uZXh0ID0gMjA7XG4gICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBfY29udGV4dC5uZXh0ID0gMTg7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMudHJhbnNwb3J0LnJlcGx5KHJlcXVlc3QsIHtcbiAgICAgICAgICAgICAgICAgIGVycm9yOiB7XG4gICAgICAgICAgICAgICAgICAgIG1lc3NhZ2U6IFwiQ2Fubm90IHNlbmQgdG8tZGV2aWNlIGV2ZW50cyBvZiB0aGlzIHR5cGVcIlxuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgIGNhc2UgMTg6XG4gICAgICAgICAgICAgICAgX2NvbnRleHQubmV4dCA9IDMyO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuXG4gICAgICAgICAgICAgIGNhc2UgMjA6XG4gICAgICAgICAgICAgICAgX2NvbnRleHQucHJldiA9IDIwO1xuICAgICAgICAgICAgICAgIF9jb250ZXh0Lm5leHQgPSAyMztcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5kcml2ZXIuc2VuZFRvRGV2aWNlKHJlcXVlc3QuZGF0YS50eXBlLCByZXF1ZXN0LmRhdGEuZW5jcnlwdGVkLCByZXF1ZXN0LmRhdGEubWVzc2FnZXMpO1xuXG4gICAgICAgICAgICAgIGNhc2UgMjM6XG4gICAgICAgICAgICAgICAgX2NvbnRleHQubmV4dCA9IDI1O1xuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnRyYW5zcG9ydC5yZXBseShyZXF1ZXN0LCB7fSk7XG5cbiAgICAgICAgICAgICAgY2FzZSAyNTpcbiAgICAgICAgICAgICAgICBfY29udGV4dC5uZXh0ID0gMzI7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICAgICAgY2FzZSAyNzpcbiAgICAgICAgICAgICAgICBfY29udGV4dC5wcmV2ID0gMjc7XG4gICAgICAgICAgICAgICAgX2NvbnRleHQudDAgPSBfY29udGV4dFtcImNhdGNoXCJdKDIwKTtcbiAgICAgICAgICAgICAgICBjb25zb2xlLmVycm9yKFwiZXJyb3Igc2VuZGluZyB0by1kZXZpY2UgZXZlbnRcIiwgX2NvbnRleHQudDApO1xuICAgICAgICAgICAgICAgIF9jb250ZXh0Lm5leHQgPSAzMjtcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy50cmFuc3BvcnQucmVwbHkocmVxdWVzdCwge1xuICAgICAgICAgICAgICAgICAgZXJyb3I6IHtcbiAgICAgICAgICAgICAgICAgICAgbWVzc2FnZTogXCJFcnJvciBzZW5kaW5nIGV2ZW50XCJcbiAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9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IF9jb250ZXh0Mi5wcmV2ID0gMDtcbiAgICAgICAgICAgICAgICBfY29udGV4dDIubmV4dCA9IDM7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMudHJhbnNwb3J0LnNlbmQoX1dpZGdldEFwaUFjdGlvbi5XaWRnZXRBcGlUb1dpZGdldEFjdGlvbi5VcGRhdGVUdXJuU2VydmVycywgaW5pdGlhbFNlcnZlciAvLyBpdCdzIGNvbXBhdGlibGUsIGJ1dCBtaXNzaW5nIHRoZSBpbmRleCBzaWduYXR1cmVcbiAgICAgICAgICAgICAgICApO1xuXG4gICAgICAgICAgICAgIGNhc2UgMzpcbiAgICAgICAgICAgICAgICAvLyBQaWNrIHRoZSBnZW5lcmF0b3IgdXAgd2hlcmUgd2UgbGVmdCBvZmZcbiAgICAgICAgICAgICAgICBfaXRlcmF0b3JBYnJ1cHRDb21wbGV0aW9uID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgX2RpZEl0ZXJhdG9yRXJyb3IgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICBfY29udGV4dDIucHJldiA9IDU7XG4gICAgICAgICAgICAgICAgX2l0ZXJhdG9yID0gX2FzeW5jSXRlcmF0b3IodHVyblNlcnZlcnMpO1xuXG4gICAgICAgICAgICAgIGNhc2UgNzpcbiAgICAgICAgICAgICAgICBfY29udGV4dDIubmV4dCA9IDk7XG4gICAgICAgICAgICAgICAgcmV0dXJuIF9pdGVyYXRvci5uZXh0KCk7XG5cbiAgICAgICAgICAgICAgY2FzZSA5OlxuICAgICAgICAgICAgICAgIGlmICghKF9pdGVyYXRvckFicnVwdENvbXBsZXRpb24gPSAhKF9zdGVwID0gX2NvbnRleHQyLnNlbnQpLmRvbmUpKSB7XG4gICAgICAgICAgICAgICAgICBfY29udGV4dDIubmV4dCA9IDE2O1xuICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgc2VydmVyID0gX3N0ZXAudmFsdWU7XG4gICAgICAgICAgICAgICAgX2NvbnRleHQyLm5leHQgPSAxMztcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy50cmFuc3BvcnQuc2VuZChfV2lkZ2V0QXBpQWN0aW9uLldpZGdldEFwaVRvV2lkZ2V0QWN0aW9uLlVwZGF0ZVR1cm5TZXJ2ZXJzLCBzZXJ2ZXIgLy8gaXQncyBjb21wYXRpYmxlLCBidXQgbWlzc2luZyB0aGUgaW5kZXggc2lnbmF0dXJlXG4gICAgICAgICAgICAgICAgKTtcblxuICAgICAgICAgICAgICBjYXNlIDEzOlxuICAgICAgICAgICAgICAgIF9pdGVyYXRvckFicnVwdENvbXBsZXRpb24gPSBmYWxzZTtcbiAgICAgICAgICAgICAgICBfY29udGV4dDIubmV4dCA9IDc7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICAgICAgY2FzZSAxNjpcbiAgICAgICAgICAgICAgICBfY29udGV4dDIubmV4dCA9IDIyO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuXG4gICAgICAgICAgICAgIGNhc2UgMTg6XG4gICAgICAgICAgICAgICAgX2NvbnRleHQyLnByZXYgPSAxODtcbiAgICAgICAgICAgICAgICBfY29udGV4dDIudDAgPSBfY29udGV4dDJbXCJjYXRjaFwiXSg1KTtcbiAgICAgICAgICAgICAgICBfZGlkSXRlcmF0b3JFcnJvciA9IHRydWU7XG4gICAgICAgICAgICAgICAgX2l0ZXJhdG9yRXJyb3IgPSBfY29udGV4dDIudDA7XG5cbiAgICAgICAgICAgICAgY2FzZSAyMjpcbiAgICAgICAgICAgICAgICBfY29udGV4dDIucHJldiA9IDIyO1xuICAgICAgICAgICAgICAgIF9jb250ZXh0Mi5wcmV2ID0gMjM7XG5cbiAgICAgICAgICAgICAgICBpZiAoIShfaXRlcmF0b3JBYnJ1cHRDb21wbGV0aW9uICYmIF9pdGVyYXRvcltcInJldHVyblwiXSAhPSBudWxsKSkge1xuICAgICAgICAgICAgICAgICAgX2NvbnRleHQyLm5leHQgPSAyNztcbiAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIF9jb250ZXh0Mi5uZXh0ID0gMjc7XG4gICAgICAgICAgICAgICAgcmV0dXJuIF9pdGVyYXRvcltcInJldHVyblwiXSgpO1xuXG4gICAgICAgICAgICAgIGNhc2UgMjc6XG4gICAgICAgICAgICAgICAgX2NvbnRleHQyLnByZXYgPSAyNztcblxuICAgICAgICAgICAgICAgIGlmICghX2RpZEl0ZXJhdG9yRXJyb3IpIHtcbiAgICAgICAgICAgICAgICAgIF9jb250ZXh0Mi5uZXh0ID0gMzA7XG4gICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICB0aHJvdyBfaXRlcmF0b3JFcnJvcjtcblxuICAgICAgICAgICAgICBjYXNlIDMwOlxuICAgICAgICAgICAgICAgIHJldHVybiBfY29udGV4dDIuZmluaXNoKDI3KTtcblxuICAgICAgICAgICAgICBjYXNlIDMxOlxuICAgICAgICAgICAgICAgIHJldHVybiBfY29udGV4dDIuZmluaXNoKDIyKTtcblxuICAgICAgICAgICAgICBjYXNlIDMyOlxuICAgICAgICAgICAgICAgIF9jb250ZXh0Mi5uZXh0ID0gMzc7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICAgICAgY2FzZSAzNDpcbiAgICAgICAgICAgICAgICBfY29udGV4dDIucHJldiA9IDM0O1xuICAgICAgICAgICAgICAgIF9jb250ZXh0Mi50MSA9IF9jb250ZXh0MltcImNhdGNoXCJdKDApO1xuICAgICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoXCJlcnJvciBwb2xsaW5nIGZvciBUVVJOIHNlcnZlcnNcIiwgX2NvbnRleHQyLnQxKTtcblxuICAgICAgICAgICAgICBjYXNlIDM3OlxuICAgICAgICAgICAgICBjYXNlIFwiZW5kXCI6XG4gICAgICAgICA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biAgICAgICAgICAgICAgICAgIF9jb250ZXh0My5uZXh0ID0gNTtcbiAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIF9jb250ZXh0My5uZXh0ID0gMztcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy50cmFuc3BvcnQucmVwbHkocmVxdWVzdCwge1xuICAgICAgICAgICAgICAgICAgZXJyb3I6IHtcbiAgICAgICAgICAgICAgICAgICAgbWVzc2FnZTogXCJNaXNzaW5nIGNhcGFiaWxpdHlcIlxuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgIGNhc2UgMzpcbiAgICAgICAgICAgICAgICBfY29udGV4dDMubmV4dCA9IDMwO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuXG4gICAgICAgICAgICAgIGNhc2UgNTpcbiAgICAgICAgICAgICAgICBpZiAoIXRoaXMudHVyblNlcnZlcnMpIHtcbiAgICAgICAgICAgICAgICAgIF9jb250ZXh0My5uZXh0ID0gMTA7XG4gICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBfY29udGV4dDMubmV4dCA9IDg7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMudHJhbnNwb3J0LnJlcGx5KHJlcXVlc3QsIHt9KTtcblxuICAgICAgICAgICAgICBjYXNlIDg6XG4gICAgICAgICAgICAgICAgX2NvbnRleHQzLm5leHQgPSAzMDtcbiAgICAgICAgICAgICAgICBicmVhaztcblxuICAgICAgICAgICAgICBjYXNlIDEwOlxuICAgICAgICAgICAgICAgIF9jb250ZXh0My5wcmV2ID0gMTA7XG4gICAgICAgICAgICAgICAgdHVyblNlcnZlcnMgPSB0aGlzLmRyaXZlci5nZXRUdXJuU2VydmVycygpOyAvLyBQZWVrIGF0IHRoZSBmaXJzdCByZXN1bHQsIHNvIHdlIGNhbiBhdCBsZWFzdCB2ZXJpZnkgdGhhdCB0aGVcbiAgICAgICAgICAgICAgICAvLyBjbGllbnQgaXNuJ3QgYmFubmVkIGZyb20gZ2V0dGluZyBUVVJOIHNlcnZlcnMgZW50aXJlbHlcblxuICAgICAgICAgICAgICAgIF9jb250ZXh0My5uZXh0ID0gMTQ7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHR1cm5TZXJ2ZXJzLm5leHQoKTtcblxuICAgICAgICAgICAgICBjYXNlIDE0OlxuICAgICAgICAgICAgICAgIF95aWVsZCR0dXJuU2VydmVycyRuZSA9IF9jb250ZXh0My5zZW50O1xuICAgICAgICAgICAgICAgIGRvbmUgPSBfeWllbGQkdHVyblNlcnZlcnMkbmUuZG9uZTtcbiAgICAgICAgICAgICAgICB2YWx1ZSA9IF95aWVsZCR0dXJuU2VydmVycyRuZS52YWx1ZTtcblxuICAgICAgICAgICAgICAgIGlmICghZG9uZSkge1xuICAgICAgICAgICAgICAgICAgX2NvbnRleHQzLm5leHQgPSAxOTtcbiAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcIkNsaWVudCByZWZ1c2VzIHRvIHByb3ZpZGUgYW55IFRVUk4gc2VydmVyc1wiKTtcblxuICAgICAgICAgICAgICBjYXNlIDE5OlxuICAgICAgICAgICAgICAgIF9jb250ZXh0My5uZXh0ID0gMjE7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMudHJhbnNwb3J0LnJlcGx5KHJlcXVlc3QsIHt9KTtcblxuICAgICAgICAgICAgICBjYXNlIDIxOlxuICAgICAgICAgICAgICAgIC8vIFN0YXJ0IHRoZSBwb2xsIGxvb3AsIHNlbmRpbmcgdGhlIHdpZGdldCB0aGUgaW5pdGlhbCByZXN1bHRcbiAgICAgICAgICAgICAgICB0aGlzLnBvbGxUdXJuU2VydmVycyh0dXJuU2VydmVycywgdmFsdWUpO1xuICAgICAgICAgICAgICAgIHRoaXMudHVyblNlcnZlcnMgPSB0dXJuU2VydmVycztcbiAgICAgICAgICAgICAgICBfY29udGV4dDMubmV4dCA9IDMwO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuXG4gICAgICAgICAgICAgIGNhc2UgMjU6XG4gICAgICAgICAgICAgICAgX2NvbnRleHQzLnByZXYgPSAyNTtcbiAgICAgICAgICAgICAgICBfY29udGV4dDMudDAgPSBfY29udGV4dDNbXCJjYXRjaFwiXSgxMCk7XG4gICAgICAgICAgICAgICAgY29uc29sZS5lcnJvcihcImVycm9yIGdldHRpbmcgZmlyc3QgVFVSTiBzZXJ2ZXIgcmVzdWx0c1wiLCBfY29udGV4dDMudDApO1xuICAgICAgICAgICAgICAgIF9jb250ZXh0My5uZXh0ID0gMzA7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMudHJhbnNwb3J0LnJlcGx5KHJlcXVlc3QsIHtcbiAgICAgICAgICAgICAgICAgIGVycm9yOiB7XG4gICAgICAgICAgICAgICAgICAgIG1lc3NhZ2U6IFwiVFVSTiBzZXJ2ZXJzIG5vdCBhdmFpbGFibGVcIlxuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgIGNhc2UgMzA6XG4gICAgICAgICAgICAgIGNhc2UgXCJlbmRcIjpcbiAgICAgICAgICAgICAgICByZXR1cm4gX2NvbnRleHQzLnN0b3AoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH0sIF9jYWxsZWUzLCB0aGlzLCBbWzEwLCAyNV1dKTtcbiAgICAgIH0pKTtcblxuICAgICAgZnVuY3Rpb24gaGFuZGxlV2F0Y2hUdXJuU2VydmVycyhfeDQpIHtcbiAgICAgICAgcmV0dXJuIF9oYW5kbGVXYXRjaFR1cm5TZXJ2ZXJzLmFwcGx5KHRoaXMsIGFyZ3VtZW50cyk7XG4gICAgICB9XG5cbiAgICAgIHJldHVybiBoYW5kbGVXYXRjaFR1cm5TZXJ2ZXJzO1xuICAgIH0oKVxuICB9LCB7XG4gICAga2V5OiBcImhhbmRsZVVud2F0Y2hUdXJuU2VydmVyc1wiLFxuICAgIHZhbHVlOiBmdW5jdGlvbiAoKSB7XG4gICAgICB2YXIgX2hhbmRsZVVud2F0Y2hUdXJuU2VydmVycyA9IF9hc3luY1RvR2VuZXJhdG9yKCAvKiNfX1BVUkVfXyovX3JlZ2VuZXJhdG9yUnVudGltZSgpLm1hcmsoZnVuY3Rpb24gX2NhbGxlZTQocmVxdWVzdCkge1xuICAgICAgICByZXR1cm4gX3JlZ2VuZXJhdG9yUnVudGltZSgpLndyYXAoZnVuY3Rpb24gX2NhbGxlZTQkKF9jb250ZXh0NCkge1xuICAgICAgICAgIHdoaWxlICgxKSB7XG4gICAgICAgICAgICBzd2l0Y2ggKF9jb250ZXh0NC5wcmV2ID0gX2NvbnRleHQ0Lm5leHQpIHtcbiAgICAgICAgICAgICAgY2FzZSAwOlxuICAgICAgICAgICAgICAgIGlmICh0aGlzLmhhc0NhcGFiaWxpdHkoX0NhcGFiaWxpdGllcy5NYXRyaXhDYXBhYmlsaXRpZXMuTVNDMzg0NlR1cm5TZXJ2ZXJzKSkge1xuICAgICAgICAgICAgICAgICAgX2NvbnRleHQ0Lm5leHQgPSA1O1xuICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgX2NvbnRleHQ0Lm5leHQgPSAzO1xuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnRyYW5zcG9ydC5yZXBseShyZXF1ZXN0LCB7XG4gICAgICAgICAgICAgICAgICBlcnJvcjoge1xuICAgICAgICAgICAgICAgICAgICBtZXNzYWdlOiBcIk1pc3NpbmcgY2FwYWJpbGl0eVwiXG4gICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgICAgY2FzZSAzOlxuICAgICAgICAgICAgICAgIF9jb250ZXh0NC5uZXh0ID0gMTU7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICAgICAgY2FzZSA1OlxuICAgICAgICAgICAgICAgIGlmICh0aGlzLnR1cm5TZXJ2ZXJzKSB7XG4gICAgICAgICAgICAgICAgICBfY29udGV4dDQubmV4dCA9IDEwO1xuICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgX2NvbnRleHQ0Lm5leHQgPSA4O1xuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnRyYW5zcG9ydC5yZXBseShyZXF1ZXN0LCB7fSk7XG5cbiAgICAgICAgICAgICAgY2FzZSA4OlxuICAgICAgICAgICAgICAgIF9jb250ZXh0NC5uZXh0ID0gMTU7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICAgICAgY2FzZSAxMDpcbiAgICAgICAgICAgICAgICBfY29udGV4dDQubmV4dCA9IDEyO1xuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnR1cm5TZXJ2ZXJzW1wicmV0dXJuXCJdKHVuZGVmaW5lZCk7XG5cbiAgICAgICAgICAgICAgY2FzZSAxMjpcbiAgICAgICAgICAgICAgICB0aGlzLnR1cm5TZXJ2ZXJzID0gbnVsbDtcbiAgICAgICAgICAgICAgICBfY29udGV4dDQubmV4dCA9IDE1O1xuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnRyYW5zcG9ydC5yZXBseShyZXF1ZXN0LCB7fSk7XG5cbiAgICAgICAgICAgICAgY2FzZSAxNTpcbiAgICAgICAgICAgICAgY2FzZSBcImVuZFwiOlxuICAgICAgICAgICAgICAgIHJldHVybiBfY29udGV4dDQuc3RvcCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSwgX2NhbGxlZTQsIHRoaXMpO1xuICAgICAgfSkpO1xuXG4gICAgICBmdW5jdGlvbiBoYW5kbGVVbnd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AgbWVzc2FnZTogXCJJbnZhbGlkIHJlcXVlc3QgLSBtaXNzaW5nIGV2ZW50IElEXCJcbiAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9KSk7XG5cbiAgICAgICAgICAgICAgY2FzZSAyOlxuICAgICAgICAgICAgICAgIGlmICghKHJlcXVlc3QuZGF0YS5saW1pdCAhPT0gdW5kZWZpbmVkICYmIHJlcXVlc3QuZGF0YS5saW1pdCA8IDApKSB7XG4gICAgICAgICAgICAgICAgICBfY29udGV4dDUubmV4dCA9IDQ7XG4gICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICByZXR1cm4gX2NvbnRleHQ1LmFicnVwdChcInJldHVyblwiLCB0aGlzLnRyYW5zcG9ydC5yZXBseShyZXF1ZXN0LCB7XG4gICAgICAgICAgICAgICAgICBlcnJvcjoge1xuICAgICAgICAgICAgICAgICAgICBtZXNzYWdlOiBcIkludmFsaWQgcmVxdWVzdCAtIGxpbWl0IG91dCBvZiByYW5nZVwiXG4gICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSkpO1xuXG4gICAgICAgICAgICAgIGNhc2UgNDpcbiAgICAgICAgICAgICAgICBpZiAoIShyZXF1ZXN0LmRhdGEucm9vbV9pZCAhPT0gdW5kZWZpbmVkICYmICF0aGlzLmNhblVzZVJvb21UaW1lbGluZShyZXF1ZXN0LmRhdGEucm9vbV9pZCkpKSB7XG4gICAgICAgICAgICAgICAgICBfY29udGV4dDUubmV4dCA9IDY7XG4gICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICByZXR1cm4gX2NvbnRleHQ1LmFicnVwdChcInJldHVyblwiLCB0aGlzLnRyYW5zcG9ydC5yZXBseShyZXF1ZXN0LCB7XG4gICAgICAgICAgICAgICAgICBlcnJvcjoge1xuICAgICAgICAgICAgICAgICAgICBtZXNzYWdlOiB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5SZWNlaXZlUm9vbUV2ZW50KGUudHlwZSwgZS5jb250ZW50Wydtc2d0eXBlJ10pO1xuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIHJldHVybiBfY29udGV4dDUuYWJydXB0KFwicmV0dXJuXCIsIHRoaXMudHJhbnNwb3J0LnJlcGx5KHJlcXVlc3QsIHtcbiAgICAgICAgICAgICAgICAgIGNodW5rOiBjaHVuayxcbiAgICAgICAgICAgICAgICAgIHByZXZfYmF0Y2g6IHJlc3VsdC5wcmV2QmF0Y2gsXG4gICAgICAgICAgICAgICAgICBuZXh0X2JhdGNoOiByZXN1bHQubmV4dEJhdGNoXG4gICAgICAgICAgICAgICAgfSkpO1xuXG4gICAgICAgICAgICAgIGNhc2UgMTQ6XG4gICAgICAgICAgICAgICAgX2NvbnRleHQ1LnByZXYgPSAxNDtcbiAgICAgICAgICAgICAgICBfY29udGV4dDUudDAgPSBfY29udGV4dDVbXCJjYXRjaFwiXSg2KTtcbiAgICAgICAgICAgICAgICBjb25zb2xlLmVycm9yKFwiZXJyb3IgZ2V0dGluZyB0aGUgcmVsYXRpb25zXCIsIF9jb250ZXh0NS50MCk7XG4gICAgICAgICAgICAgICAgX2NvbnRleHQ1Lm5leHQgPSAxOTtcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy50cmFuc3BvcnQucmVwbHkocmVxdWVzdCwge1xuICAgICAgICAgICAgICAgICAgZXJyb3I6IHtcbiAgICAgICAgICAgICAgICAgICAgbWVzc2FnZTogXCJVbmV4cGVjdGVkIGVycm9yIHdoaWxlIHJlYWRpbmcgcmVsYXRpb25zXCJcbiAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9KTtcblxuICAgICAgICAgICAgICBjYXNlIDE5OlxuICAgICAgICAgICAgICBjYXNlIFwiZW5kXCI6XG4gICAgICAgICAgICAgICAgcmV0dXJuIF9jb250ZXh0NS5zdG9wKCk7XG4gICAgICAg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gICAgIHJldHVybiBfY29udGV4dDYuYWJydXB0KFwicmV0dXJuXCIsIHRoaXMudHJhbnNwb3J0LnJlcGx5KHJlcXVlc3QsIHtcbiAgICAgICAgICAgICAgICAgIGVycm9yOiB7XG4gICAgICAgICAgICAgICAgICAgIG1lc3NhZ2U6IFwiTWlzc2luZyBjYXBhYmlsaXR5XCJcbiAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9KSk7XG5cbiAgICAgICAgICAgICAgY2FzZSAyOlxuICAgICAgICAgICAgICAgIGlmICghKHR5cGVvZiByZXF1ZXN0LmRhdGEuc2VhcmNoX3Rlcm0gIT09ICdzdHJpbmcnKSkge1xuICAgICAgICAgICAgICAgICAgX2NvbnRleHQ2Lm5leHQgPSA0O1xuICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgcmV0dXJuIF9jb250ZXh0Ni5hYnJ1cHQoXCJyZXR1cm5cIiwgdGhpcy50cmFuc3BvcnQucmVwbHkocmVxdWVzdCwge1xuICAgICAgICAgICAgICAgICAgZXJyb3I6IHtcbiAgICAgICAgICAgICAgICAgICAgbWVzc2FnZTogXCJJbnZhbGlkIHJlcXVlc3QgLSBtaXNzaW5nIHNlYXJjaCB0ZXJtXCJcbiAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9KSk7XG5cbiAgICAgICAgICAgICAgY2FzZSA0OlxuICAgICAgICAgICAgICAgIGlmICghKHJlcXVlc3QuZGF0YS5saW1pdCAhPT0gdW5kZWZpbmVkICYmIHJlcXVlc3QuZGF0YS5saW1pdCA8IDApKSB7XG4gICAgICAgICAgICAgICAgICBfY29udGV4dDYubmV4dCA9IDY7XG4gICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICByZXR1cm4gX2NvbnRleHQ2LmFicnVwdChcInJldHVyblwiLCB0aGlzLnRyYW5zcG9ydC5yZXBseShyZXF1ZXN0LCB7XG4gICAgICAgICAgICAgICAgICBlcnJvcjoge1xuICAgICAgICAgICAgICAgICAgICBtZXNzYWdlOiBcIkludmFsaWQgcmVxdWVzdCAtIGxpbWl0IG91dCBvZiByYW5nZVwiXG4gICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSkpO1xuXG4gICAgICAgICAgICAgIGNhc2UgNjpcbiAgICAgICAgICAgICAgICBfY29udGV4dDYucHJldiA9IDY7XG4gICAgICAgICAgICAgICAgX2NvbnRleHQ2Lm5leHQgPSA5O1xuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmRyaXZlci5zZWFyY2hVc2VyRGlyZWN0b3J5KHJlcXVlc3QuZGF0YS5zZWFyY2hfdGVybSwgcmVxdWVzdC5kYXRhLmxpbWl0KTtcblxuICAgICAgICAgICAgICBjYXNlIDk6XG4gICAgICAgICAgICAgICAgcmVzdWx0ID0gX2NvbnRleHQ2LnNlbnQ7XG4gICAgICAgICAgICAgICAgcmV0dXJuIF9jb250ZXh0Ni5hYnJ1cHQoXCJyZXR1cm5cIiwgdGhpcy50cmFuc3BvcnQucmVwbHkocmVxdWVzdCwge1xuICAgICAgICAgICAgICAgICAgbGltaXRlZDogcmVzdWx0LmxpbWl0ZWQsXG4gICAgICAgICAgICAgICAgICByZXN1bHRzOiByZXN1bHQucmVzdWx0cy5tYXAoZnVuY3Rpb24gKHIpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICAgICAgICB1c2VyX2lkOiByLnVzZXJJZCxcbiAgICAgICAgICAgICAgICAgICAgICBkaXNwbGF5X25hbWU6IHIuZGlzcGxheU5hbWUsXG4gICAgICAgICAgICAgICAgICAgICAgYXZhdGFyX3VybDogci5hdmF0YXJVcmxcbiAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAgICAgfSkpO1xuXG4gICAgICAgICAgICAgIGNhc2UgMTM6XG4gICAgICAgICAgICAgICAgX2NvbnRleHQ2LnByZXYgPSAxMztcbiAgICAgICAgICAgICAgICBfY29udGV4dDYudDAgPSBfY29udGV4dDZbXCJjYXRjaFwiXSg2KTtcbiAgICAgICAgICAgICAgICBjb25zb2xlLmVycm9yKFwiZXJyb3Igc2VhcmNoaW5nIGluIHRoZSB1c2VyIGRpcmVjdG9yeVwiLCBfY29udGV4dDYudDApO1xuICAgICAgICAgICAgICAgIF9jb250ZXh0Ni5uZXh0ID0gMTg7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMudHJhbnNwb3J0LnJlcGx5KHJlcXVlc3QsIHtcbiAgICAgICAgICAgICAgICAgIGVycm9yOiB7XG4gICAgICAgICAgICAgICAgICAgIG1lc3NhZ2U6IFwiVW5leHBlY3RlZCBlcnJvciB3aGlsZSBzZWFyY2hpbmcgaW4gdGhlIHVzZXIgZGlyZWN0b3J5XCJcbiAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9KTtcblxuICAgICAgICAgICAgICBjYXNlIDE4OlxuICAgICAgICAgICAgICBjYXNlIFwiZW5kXCI6XG4gICAgICAgICAgICAgICAgcmV0dXJuIF9jb250ZXh0Ni5zdG9wKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9LCBfY2FsbGVlNiwgdGhpcywgW1s2LCAxM11dKTtcbiAgICAgIH0pKTtcblxuICAgICAgZnVuY3Rpb24gaGFuZGxlVXNlckRpcmVjdG9yeVNlYXJjaChfeDcpIHtcbiAgICAgICAgcmV0dXJuIF9oYW5kbGVVc2VyRGlyZWN0b3J5U2VhcmNoLmFwcGx5KHRoaXMsIGFyZ3VtZW50cyk7XG4gICAgICB9XG5cbiAgICAgIHJldHVybiBoYW5kbGVVc2VyRGlyZWN0b3J5U2VhcmNoO1xuICAgIH0oKVxuICB9LCB7XG4gICAga2V5OiBcImhhbmRsZU1lc3NhZ2VcIixcbiAgICB2YWx1Z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gIHJldHVybiBfY29udGV4dDcuYWJydXB0KFwicmV0dXJuXCIpO1xuXG4gICAgICAgICAgICAgIGNhc2UgMjpcbiAgICAgICAgICAgICAgICBpZiAoIShyYXdFdmVudC5zdGF0ZV9rZXkgIT09IHVuZGVmaW5lZCAmJiByYXdFdmVudC5zdGF0ZV9rZXkgIT09IG51bGwpKSB7XG4gICAgICAgICAgICAgICAgICBfY29udGV4dDcubmV4dCA9IDc7XG4gICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBpZiAodGhpcy5jYW5SZWNlaXZlU3RhdGVFdmVudChyYXdFdmVudC50eXBlLCByYXdFdmVudC5zdGF0ZV9rZXkpKSB7XG4gICAgICAgICAgICAgICAgICBfY29udGV4dDcubmV4dCA9IDU7XG4gICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICByZXR1cm4gX2NvbnRleHQ3LmFicnVwdChcInJldHVyblwiKTtcblxuICAgICAgICAgICAgICBjYXNlIDU6XG4gICAgICAgICAgICAgICAgX2NvbnRleHQ3Lm5leHQgPSA5O1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuXG4gICAgICAgICAgICAgIGNhc2UgNzpcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5jYW5SZWNlaXZlUm9vbUV2ZW50KHJhd0V2ZW50LnR5cGUsIChfcmF3RXZlbnQkY29udGVudCA9IHJhd0V2ZW50LmNvbnRlbnQpID09PSBudWxsIHx8IF9yYXdFdmVudCRjb250ZW50ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfcmF3RXZlbnQkY29udGVudFtcIm1zZ3R5cGVcIl0pKSB7XG4gICAgICAgICAgICAgICAgICBfY29udGV4dDcubmV4dCA9IDk7XG4gICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICByZXR1cm4gX2NvbnRleHQ3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FJlc29sdmVzIHRvIHRoZSByb29tIHJlbGF0aW9ucy5cbiAgICAgKi9cblxuICB9LCB7XG4gICAga2V5OiBcInJlYWRFdmVudFJlbGF0aW9uc1wiLFxuICAgIHZhbHVlOiBmdW5jdGlvbiAoKSB7XG4gICAgICB2YXIgX3JlYWRFdmVudFJlbGF0aW9ucyA9IF9hc3luY1RvR2VuZXJhdG9yKCAvKiNfX1BVUkVfXyovX3JlZ2VuZXJhdG9yUnVudGltZSgpLm1hcmsoZnVuY3Rpb24gX2NhbGxlZShldmVudElkLCByb29tSWQsIHJlbGF0aW9uVHlwZSwgZXZlbnRUeXBlLCBsaW1pdCwgZnJvbSwgdG8sIGRpcmVjdGlvbikge1xuICAgICAgICB2YXIgdmVyc2lvbnMsIGRhdGE7XG4gICAgICAgIHJldHVybiBfcmVnZW5lcmF0b3JSdW50aW1lKCkud3JhcChmdW5jdGlvbiBfY2FsbGVlJChfY29udGV4dCkge1xuICAgICAgICAgIHdoaWxlICgxKSB7XG4gICAgICAgICAgICBzd2l0Y2ggKF9jb250ZXh0LnByZXYgPSBfY29udGV4dC5uZXh0KSB7XG4gICAgICAgICAgICAgIGNhc2UgMDpcbiAgICAgICAgICAgICAgICBfY29udGV4dC5uZXh0ID0gMjtcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5nZXRDbGllbnRWZXJzaW9ucygpO1xuXG4gICAgICAgICAgICAgIGNhc2UgMjpcbiAgICAgICAgICAgICAgICB2ZXJzaW9ucyA9IF9jb250ZXh0LnNlbnQ7XG5cbiAgICAgICAgICAgICAgICBpZiAodmVyc2lvbnMuaW5jbHVkZXMoX0FwaVZlcnNpb24uVW5zdGFibGVBcGlWZXJzaW9uLk1TQzM4NjkpKSB7XG4gICAgICAgICAgICAgICAgICBfY29udGV4dC5uZXh0ID0gNTtcbiAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcIlRoZSByZWFkX3JlbGF0aW9ucyBhY3Rpb24gaXMgbm90IHN1cHBvcnRlZCBieSB0aGUgY2xpZW50LlwiKTtcblxuICAgICAgICAgICAgICBjYXNlIDU6XG4gICAgICAgICAgICAgICAgZGF0YSA9IHtcbiAgICAgICAgICAgICAgICAgIGV2ZW50X2lkOiBldmVudElkLFxuICAgICAgICAgICAgICAgICAgcmVsX3R5cGU6IHJlbGF0aW9uVHlwZSxcbiAgICAgICAgICAgICAgICAgIGV2ZW50X3R5cGU6IGV2ZW50VHlwZSxcbiAgICAgICAgICAgICAgICAgIHJvb21faWQ6IHJvb21JZCxcbiAgICAgICAgICAgICAgICAgIHRvOiB0byxcbiAgICAgICAgICAgICAgICAgIGZyb206IGZyb20sXG4gICAgICAgICAgICAgICAgICBsaW1pdDogbGltaXQsXG4gICAgICAgICAgICAgICAgICBkaXJlY3Rpb246IGRpcmVjdGlvblxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgcmV0dXJuIF9jb250ZXh0LmFicnVwdChcInJldHVyblwiLCB0aGlzLnRyYW5zcG9ydC5zZW5kKF9XaWRnZXRBcGlBY3Rpb24uV2lkZ2V0QXBpRnJvbVdpZGdldEFjdGlvbi5NU0MzODY5UmVhZFJlbGF0aW9ucywgZGF0YSkpO1xuXG4gICAgICAgICAgICAgIGNhc2UgNzpcbiAgICAgICAgICAgICAgY2FzZSBcImVuZFwiOlxuICAgICAgICAgICAgICAgIHJldHVybiBfY29udGV4dC5zdG9wKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9LCBfY2FsbGVlLCB0aGlzKTtcbiAgICAgIH0pKTtcblxuICAgICAgZnVuY3Rpb24gcmVhZEV2ZW50UmVsYXRpb25zKF94LCBfeDIsIF94MywgX3g0LCBfeDUsIF94NiwgX3g3LCBfeDgpIHtcbiAgICAgICAgcmV0dXJuIF9yZWFkRXZlbnRSZWxhdGlvbnMuYXBwbHkodGhpcywgYXJndW1lbnRzK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udGltZSgpLm1hcmsoZnVuY3Rpb24gX2NhbGxlZTIoZXYpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9yZWdlbmVyYXRvclJ1bnRpbWUoKS53cmFwKGZ1bmN0aW9uIF9jYWxsZWUyJChfY29udGV4dDIpIHtcbiAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoMSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChfY29udGV4dDIucHJldiA9IF9jb250ZXh0Mi5uZXh0KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMDpcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBldi5wcmV2ZW50RGVmYXVsdCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldFR1cm5TZXJ2ZXIoZXYuZGV0YWlsLmRhdGEpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jb250ZXh0Mi5uZXh0ID0gNDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3RoaXMudHJhbnNwb3J0LnJlcGx5KGV2LmRldGFpbCwge30pO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgNDpcbiAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBcImVuZFwiOlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY29udGV4dDIuc3RvcCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfSwgX2NhbGxlZTIpO1xuICAgICAgICAgICAgICAgICAgfSkpO1xuXG4gICAgICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gb25VcGRhdGVUdXJuU2VydmVycyhfeDkpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9yZWYuYXBwbHkodGhpcywgYXJndW1lbnRzKTtcbiAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgfSgpOyAvLyBTdGFydCBsaXN0ZW5pbmcgZm9yIHVwZGF0ZXMgYmVmb3JlIHdlIGV2ZW4gc3RhcnQgd2F0Y2hpbmcsIHRvIGNhdGNoXG4gICAgICAgICAgICAgICAgLy8gVFVSTiBkYXRhIHRoYXQgaXMgc2VudCBpbW1lZGlhdGVseVxuXG5cbiAgICAgICAgICAgICAgICBfdGhpcy5vbihcImFjdGlvbjpcIi5jb25jYXQoX1dpZGdldEFwaUFjdGlvbi5XaWRnZXRBcGlUb1dpZGdldEFjdGlvbi5VcGRhdGVUdXJuU2VydmVycyksIG9uVXBkYXRlVHVyblNlcnZlcnMpOyAvLyBPbmx5IHNlbmQgdGhlICd3YXRjaCcgYWN0aW9uIGlmIHdlIGFyZW4ndCBhbHJlYWR5IHdhdGNoaW5nXG5cblxuICAgICAgICAgICAgICAgIGlmICghKF90aGlzLnR1cm5TZXJ2ZXJXYXRjaGVycyA9PT0gMCkpIHtcbiAgICAgICAgICAgICAgICAgIF9jb250ZXh0My5uZXh0ID0gMTI7XG4gICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBfY29udGV4dDMucHJldiA9IDM7XG4gICAgICAgICAgICAgICAgX2NvbnRleHQzLm5leHQgPSA2O1xuICAgICAgICAgICAgICAgIHJldHVybiBfYXdhaXRBc3luY0dlbmVyYXRvcihfdGhpcy50cmFuc3BvcnQuc2VuZChfV2lkZ2V0QXBpQWN0aW9uLldpZGdldEFwaUZyb21XaWRnZXRBY3Rpb24uV2F0Y2hUdXJuU2VydmVycywge30pKTtcblxuICAgICAgICAgICAgICBjYXNlIDY6XG4gICAgICAgICAgICAgICAgX2NvbnRleHQzLm5leHQgPSAxMjtcbiAgICAgICAgICAgICAgICBicmVhaztcblxuICAgICAgICAgICAgICBjYXNlIDg6XG4gICAgICAgICAgICAgICAgX2NvbnRleHQzLnByZXYgPSA4O1xuICAgICAgICAgICAgICAgIF9jb250ZXh0My50MCA9IF9jb250ZXh0M1tcImNhdGNoXCJdKDMpO1xuXG4gICAgICAgICAgICAgICAgX3RoaXMub2ZmKFwiYWN0aW9uOlwiLmNvbmNhdChfV2lkZ2V0QXBpQWN0aW9uLldpZGdldEFwaVRvV2lkZ2V0QWN0aW9uLlVwZGF0ZVR1cm5TZXJ2ZXJzKSwgb25VcGRhdGVUdXJuU2VydmVycyk7XG5cbiAgICAgICAgICAgICAgICB0aHJvdyBfY29udGV4dDMudDA7XG5cbiAgICAgICAgICAgICAgY2FzZSAxMjpcbiAgICAgICAgICAgICAgICBfdGhpcy50dXJuU2VydmVyV2F0Y2hlcnMrKztcbiAgICAgICAgICAgICAgICBfY29udGV4dDMucHJldiA9IDEzO1xuXG4gICAgICAgICAgICAgIGNhc2UgMTQ6XG4gICAgICAgICAgICAgICAgaWYgKCF0cnVlKSB7XG4gICAgICAgICAgICAgICAgICBfY29udGV4dDMubmV4dCA9IDIxO1xuICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgX2NvbnRleHQzLm5leHQgPSAxNztcbiAgICAgICAgICAgICAgICByZXR1cm4gX2F3YWl0QXN5bmNHZW5lcmF0b3IobmV3IFByb21pc2UoZnVuY3Rpb24gKHJlc29sdmUpIHtcbiAgICAgICAgICAgICAgICAgIHJldHVybiBzZXRUdXJuU2VydmVyID0gcmVzb2x2ZTtcbiAgICAgICAgICAgICAgICB9KSk7XG5cbiAgICAgICAgICAgICAgY2FzZSAxNzpcbiAgICAgICAgICAgICAgICBfY29udGV4dDMubmV4dCA9IDE5O1xuICAgICAgICAgICAgICAgIHJldHVybiBfY29udGV4dDMuc2VudDtcblxuICAgICAgICAgICAgICBjYXNlIDE5OlxuICAgICAgICAgICAgICAgIF9jb250ZXh0My5uZXh0ID0gMTQ7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICAgICAgY2FzZSAyMTpcbiAgICAgICAgICAgICAgICBfY29udGV4dDMucHJldiA9IDIxO1xuXG4gICAgICAgICAgICAgICAgLy8gVGhlIGxvb3Agd2FzIGJyb2tlbiBieSB0aGUgY2FsbGVyIC0gY2xlYW4gdXBcbiAgICAgICAgICAgICAgICBfdGhpcy5vZmYoXCJhY3Rpb246XCIuY29uY2F0KF9XaWRnZXRBcGlBY3Rpb24uV2lkZ2V0QXBpVG9XaWRnZXRBY3Rpb24uVXBkYXRlVHVyblNlcnZlcnMpLCBvblVwZGF0ZVR1cm5TZXJ2ZXJzKTsgLy8gU2luY2Ugc2VuZGluZyB0aGUgJ3Vud2F0Y2gnIGFjdGlvbiB3aWxsIGVuZCB1cGRhdGVzIGZvciBhbGwgb3RoZXJcbiAgICAgICAgICAgICAgICAvLyBjb25zdW1lcnMsIG9ubHkgc2VuZCBpdCBpZiB3ZSdyZSB0aGUgb25seSBjb25zdW1lciByZW1haW5pbmdcblxuXG4gICAgICAgICAgICAgICAgX3RoaXMudHVyblNlcnZlcldhdGNoZXJzLS07XG5cbiAgICAgICAgICAgICAgICBpZiAoIShfdGhpcy50dXJuU2VydmVyV2F0Y2hlcnMgPT09IDApKSB7XG4gICAgICAgICAgICAgICAgICBfY29udGV4dDMubmV4dCA9IDI3O1xuICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgX2NvbnRleHQzLm5leHQgPSAyNztcbiAgICAgICAgICAgICAgICByZXR1cm4gX2F3YWl0QXN5bmNHZW5lcmF0b3IoX3RoaXMudHJhbnNwb3J0LnNlbmQoX1dpZGdldEFwaUFjdGlvbi5XaWRnZXRBcGlGcm9tV2lkZ2V0QWN0aW9uLlVud2F0Y2hUdXJuU2VydmVycywge30pKTtcblxuICAgICAgICAgICAgICBjYXNlIDI3OlxuICAgICAgICAgICAgICAgIHJldHVybiBfY29udGV4dDMuZmluaXNoKDIxKTtcblxuICAgICAgICAgICAgICBjYXNlIDI4OlxuICAgICAgICAgICAgICB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ICAgIF9jb250ZXh0NC5uZXh0ID0gMjtcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5nZXRDbGllbnRWZXJzaW9ucygpO1xuXG4gICAgICAgICAgICAgIGNhc2UgMjpcbiAgICAgICAgICAgICAgICB2ZXJzaW9ucyA9IF9jb250ZXh0NC5zZW50O1xuXG4gICAgICAgICAgICAgICAgaWYgKHZlcnNpb25zLmluY2x1ZGVzKF9BcGlWZXJzaW9uLlVuc3RhYmxlQXBpVmVyc2lvbi5NU0MzOTczKSkge1xuICAgICAgICAgICAgICAgICAgX2NvbnRleHQ0Lm5leHQgPSA1O1xuICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFwiVGhlIHVzZXJfZGlyZWN0b3J5X3NlYXJjaCBhY3Rpb24gaXMgbm90IHN1cHBvcnRlZCBieSB0aGUgY2xpZW50LlwiKTtcblxuICAgICAgICAgICAgICBjYXNlIDU6XG4gICAgICAgICAgICAgICAgZGF0YSA9IHtcbiAgICAgICAgICAgICAgICAgIHNlYXJjaF90ZXJtOiBzZWFyY2hUZXJtLFxuICAgICAgICAgICAgICAgICAgbGltaXQ6IGxpbWl0XG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICByZXR1cm4gX2NvbnRleHQ0LmFicnVwdChcInJldHVyblwiLCB0aGlzLnRyYW5zcG9ydC5zZW5kKF9XaWRnZXRBcGlBY3Rpb24uV2lkZ2V0QXBpRnJvbVdpZGdldEFjdGlvbi5NU0MzOTczVXNlckRpcmVjdG9yeVNlYXJjaCwgZGF0YSkpO1xuXG4gICAgICAgICAgICAgIGNhc2UgNzpcbiAgICAgICAgICAgICAgY2FzZSBcImVuZFwiOlxuICAgICAgICAgICAgICAgIHJldHVybiBfY29udGV4dDQuc3RvcCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSwgX2NhbGxlZ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B2YXIgcmVxdWVzdCA9IHtcbiAgICAgICAgYXBpOiB0aGlzLnNlbmREaXJlY3Rpb24sXG4gICAgICAgIHdpZGdldElkOiB0aGlzLndpZGdldElkLFxuICAgICAgICByZXF1ZXN0SWQ6IHRoaXMubmV4dFJlcXVlc3RJZCxcbiAgICAgICAgYWN0aW9uOiBhY3Rpb24sXG4gICAgICAgIGRhdGE6IGRhdGFcbiAgICAgIH07XG5cbiAgICAgIGlmIChhY3Rpb24gPT09IF8uV2lkZ2V0QXBpVG9XaWRnZXRBY3Rpb24uVXBkYXRlVmlzaWJpbGl0eSkge1xuICAgICAgICByZXF1ZXN0Wyd2aXNpYmxlJ10gPSBkYXRhWyd2aXNpYmxlJ107XG4gICAgICB9XG5cbiAgICAgIHJldHVybiBuZXcgUHJvbWlzZShmdW5jdGlvbiAocHJSZXNvbHZlLCBwclJlamVjdCkge1xuICAgICAgICB2YXIgcmVzb2x2ZSA9IGZ1bmN0aW9uIHJlc29sdmUocmVzcG9uc2UpIHtcbiAgICAgICAgICBjbGVhblVwKCk7XG4gICAgICAgICAgcHJSZXNvbHZlKHJlc3BvbnNlKTtcbiAgICAgICAgfTtcblxuICAgICAgICB2YXIgcmVqZWN0ID0gZnVuY3Rpb24gcmVqZWN0KGVycikge1xuICAgICAgICAgIGNsZWFuVXAoKTtcbiAgICAgICAgICBwclJlamVjdChlcnIpO1xuICAgICAgICB9O1xuXG4gICAgICAgIHZhciB0aW1lcklkID0gc2V0VGltZW91dChmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgcmV0dXJuIHJlamVjdChuZXcgRXJyb3IoXCJSZXF1ZXN0IHRpbWVkIG91dFwiKSk7XG4gICAgICAgIH0sIChfdGhpczIudGltZW91dFNlY29uZHMgfHwgMSkgKiAxMDAwKTtcblxuICAgICAgICB2YXIgb25TdG9wID0gZnVuY3Rpb24gb25TdG9wKCkge1xuICAgICAgICAgIHJldHVybiByZWplY3QobmV3IEVycm9yKFwiVHJhbnNwb3J0IHN0b3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lzdGVuZXI7XG4gICAgICAgICAgICBwb3NpdGlvbiA9IGk7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBpZiAocG9zaXRpb24gPCAwKVxuICAgICAgICAgIHJldHVybiB0aGlzO1xuXG4gICAgICAgIGlmIChwb3NpdGlvbiA9PT0gMClcbiAgICAgICAgICBsaXN0LnNoaWZ0KCk7XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgIHNwbGljZU9uZShsaXN0LCBwb3NpdGlvbik7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAobGlzdC5sZW5ndGggPT09IDEpXG4gICAgICAgICAgZXZlbnRzW3R5cGVdID0gbGlzdFswXTtcblxuICAgICAgICBpZiAoZXZlbnRzLnJlbW92ZUxpc3RlbmVyICE9PSB1bmRlZmluZWQpXG4gICAgICAgICAgdGhpcy5lbWl0KCdyZW1vdmVMaXN0ZW5lcicsIHR5cGUsIG9yaWdpbmFsTGlzdGVuZXIgfHwgbGlzdGVuZXIpO1xuICAgICAgfVxuXG4gICAgICByZXR1cm4gdGhpcztcbiAgICB9O1xuXG5FdmVudEVtaXR0ZXIucHJvdG90eXBlLm9mZiA9IEV2ZW50RW1pdHRlci5wcm90b3R5cGUucmVtb3ZlTGlzdGVuZXI7XG5cbkV2ZW50RW1pdHRlci5wcm90b3R5cGUucmVtb3ZlQWxsTGlzdGVuZXJzID1cbiAgICBmdW5jdGlvbiByZW1vdmVBbGxMaXN0ZW5lcnModHlwZSkge1xuICAgICAgdmFyIGxpc3RlbmVycywgZXZlbnRzLCBpO1xuXG4gICAgICBldmVudHMgPSB0aGlzLl9ldmVudHM7XG4gICAgICBpZiAoZXZlbnRzID09PSB1bmRlZmluZWQpXG4gICAgICAgIHJldHVybiB0aGlzO1xuXG4gICAgICAvLyBub3QgbGlzdGVuaW5nIGZvciByZW1vdmVMaXN0ZW5lciwgbm8gbmVlZCB0byBlbWl0XG4gICAgICBpZiAoZXZlbnRzL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ci5hZGRFdmVudExpc3RlbmVyID09PSAnZnVuY3Rpb24nKSB7XG4gICAgLy8gRXZlbnRUYXJnZXQgZG9lcyBub3QgaGF2ZSBgZXJyb3JgIGV2ZW50IHNlbWFudGljcyBsaWtlIE5vZGVcbiAgICAvLyBFdmVudEVtaXR0ZXJzLCB3ZSBkbyBub3QgbGlzdGVuIGZvciBgZXJyb3JgIGV2ZW50cyBoZXJlLlxuICAgIGVtaXR0ZXIuYWRkRXZlbnRMaXN0ZW5lcihuYW1lLCBmdW5jdGlvbiB3cmFwTGlzdGVuZXIoYXJnKSB7XG4gICAgICAvLyBJRSBkb2VzIG5vdCBoYXZlIGJ1aWx0aW4gYHsgb25jZTogdHJ1ZSB9YCBzdXBwb3J0IHNvIHdlXG4gICAgICAvLyBoYXZlIHRvIGRvIGl0IG1hbnVhbGx5LlxuICAgICAgaWYgKGZsYWdzLm9uY2UpIHtcbiAgICAgICAgZW1pdHRlci5yZW1vdmVFdmVudExpc3RlbmVyKG5hbWUsIHdyYXBMaXN0ZW5lcik7XG4gICAgICB9XG4gICAgICBsaXN0ZW5lcihhcmcpO1xuICAgIH0pO1xuICB9IGVsc2Uge1xuICAgIHRocm93IG5ldyBUeXBlRXJyb3IoJ1RoZSBcImVtaXR0ZXJcIiBhcmd1bWVudCBtdXN0IGJlIG9mIHR5cGUgRXZlbnRFbWl0dGVyLiBSZWNlaXZlZCB0eXBlICcgKyB0eXBlb2YgZW1pdHRlcik7XG4gIH1cbn1cbiJdfQ==
diff --git a/includes/external/matrix/node_modules/matrix-widget-api/dist/api.min.js b/includes/external/matrix/node_modules/matrix-widget-api/dist/api.min.js
deleted file mode 100644
index 6f89502..0000000
--- a/includes/external/matrix/node_modules/matrix-widget-api/dist/api.min.js
+++ /dev/null
@@ -1 +0,0 @@
-!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).mxwidgets=e()}}((function(){var e,t=function(e){var t;return function(r){return t||e(t={exports:{},parent:r},t.exports),t.exports}},r=t((function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=s({});Object.keys(r).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===r[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}}))}));var c=a({});Object.keys(c).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===c[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return c[e]}}))})),Object.keys(K).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===K[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return K[e]}}))})),Object.keys(ee).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===ee[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return ee[e]}}))}));var l=u({});Object.keys(l).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===l[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return l[e]}}))})),Object.keys(te).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===te[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return te[e]}}))})),Object.keys(re).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===re[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return re[e]}}))})),Object.keys(ne).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===ne[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return ne[e]}}))})),Object.keys(ie).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===ie[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return ie[e]}}))})),Object.keys(I).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===I[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return I[e]}}))})),Object.keys(oe).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===oe[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return oe[e]}}))})),Object.keys(ae).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===ae[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return ae[e]}}))})),Object.keys(se).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===se[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return se[e]}}))})),Object.keys(P).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===P[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return P[e]}}))})),Object.keys(E).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===E[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return E[e]}}))})),Object.keys(C).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===C[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return C[e]}}))})),Object.keys(Y).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===Y[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return Y[e]}}))})),Object.keys(ue).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===ue[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return ue[e]}}))})),Object.keys(ce).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===ce[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return ce[e]}}))})),Object.keys(le).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===le[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return le[e]}}))})),Object.keys(de).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===de[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return de[e]}}))})),Object.keys(fe).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===fe[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return fe[e]}}))})),Object.keys(pe).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===pe[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return pe[e]}}))})),Object.keys(ve).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===ve[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return ve[e]}}))})),Object.keys(T).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===T[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return T[e]}}))})),Object.keys(he).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===he[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return he[e]}}))})),Object.keys(me).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===me[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return me[e]}}))})),Object.keys(be).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===be[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return be[e]}}))})),Object.keys(D).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===D[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return D[e]}}))})),Object.keys(we).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===we[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return we[e]}}))})),Object.keys(_e).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===_e[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return _e[e]}}))})),Object.keys(Oe).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===Oe[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return Oe[e]}}))})),Object.keys(ke).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===ke[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return ke[e]}}))})),Object.keys(Ee).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===Ee[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return Ee[e]}}))})),Object.keys(Se).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===Se[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return Se[e]}}))})),Object.keys(je).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===je[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return je[e]}}))})),Object.keys(Ce).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===Ce[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return Ce[e]}}))})),Object.keys(xe).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===xe[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return xe[e]}}))})),Object.keys(F).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===F[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return F[e]}}))})),Object.keys(Ae).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===Ae[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return Ae[e]}}))})),Object.keys(We).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===We[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return We[e]}}))}));var d=o({});Object.keys(d).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===d[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return d[e]}}))}));var f=i({});Object.keys(f).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===f[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return f[e]}}))})),Object.keys(Pe).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===Pe[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return Pe[e]}}))})),Object.keys(J).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===J[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return J[e]}}))}));var p=n({});Object.keys(p).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===p[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return p[e]}}))}))})),n=t((function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WidgetDriver=void 0;var n=r({});function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,r;return t=e,(r=[{key:"validateCapabilities",value:function(e){return Promise.resolve(new Set)}},{key:"sendEvent",value:function(e,t){return Promise.reject(new Error("Failed to override function"))}},{key:"sendToDevice",value:function(e,t,r){return Promise.reject(new Error("Failed to override function"))}},{key:"readRoomEvents",value:function(e,t,r){return Promise.resolve([])}},{key:"readStateEvents",value:function(e,t,r){return Promise.resolve([])}},{key:"readEventRelations",value:function(e,t,r,n,i,o,a,s){return Promise.resolve({chunk:[]})}},{key:"askOpenID",value:function(e){e.update({state:n.OpenIDRequestState.Blocked})}},{key:"navigate",value:function(e){throw new Error("Navigation is not implemented")}},{key:"getTurnServers",value:function(){throw new Error("TURN server support is not implemented")}},{key:"searchUserDirectory",value:function(e,t){return Promise.resolve({limited:!1,results:[]})}}])&&i(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.WidgetDriver=o})),i=t((function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WidgetParser=void 0;var r=o({});function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var a=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,o;return t=e,o=[{key:"parseAccountData",value:function(t){if(!t)return[];for(var r=[],n=0,i=Object.keys(t);n<i.length;n++){var o=i[n],a=t[o];if(a&&("m.widget"===a.type||"im.vector.modular.widgets"===a.type)&&a.sender&&(a.state_key||a.id)===o){var s={content:a.content,sender:a.sender,type:"m.widget",state_key:o,event_id:"$example",room_id:"!example",origin_server_ts:1},u=e.parseRoomWidget(s);u&&r.push(u)}}return r}},{key:"parseWidgetsFromRoomState",value:function(t){if(!t)return[];var r,i=[],o=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return n(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,o=function(){};return{s:o,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:o}}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 a,s=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(u)throw a}}}}(t);try{for(o.s();!(r=o.n()).done;){var a=r.value,s=e.parseRoomWidget(a);s&&i.push(s)}}catch(u){o.e(u)}finally{o.f()}return i}},{key:"parseRoomWidget",value:function(t){if(!t)return null;if("m.widget"!==t.type&&"im.vector.modular.widgets"!==t.type)return null;var r=t.content||{},n={id:t.state_key,creatorUserId:r.creatorUserId||t.sender,name:r.name,type:r.type,url:r.url,waitForIframeLoad:r.waitForIframeLoad,data:r.data};return e.processEstimatedWidget(n)}},{key:"processEstimatedWidget",value:function(e){return e.id&&e.creatorUserId&&e.type&&(0,Ae.isValidUrl)(e.url)?new r.Widget(e):null}}],null&&i(t.prototype,null),o&&i(t,o),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.WidgetParser=a})),o=t((function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Widget=void 0;var n=r({});function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var o=function(){function e(t){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.definition=t,!this.definition)throw new Error("Definition is required");(0,We.assertPresent)(t,"id"),(0,We.assertPresent)(t,"creatorUserId"),(0,We.assertPresent)(t,"type"),(0,We.assertPresent)(t,"url")}var t,r;return t=e,(r=[{key:"creatorUserId",get:function(){return this.definition.creatorUserId}},{key:"type",get:function(){return this.definition.type}},{key:"id",get:function(){return this.definition.id}},{key:"name",get:function(){return this.definition.name||null}},{key:"title",get:function(){return this.rawData.title||null}},{key:"templateUrl",get:function(){return this.definition.url}},{key:"origin",get:function(){return new URL(this.templateUrl).origin}},{key:"waitForIframeLoad",get:function(){return!1!==this.definition.waitForIframeLoad&&(this.definition.waitForIframeLoad,!0)}},{key:"rawData",get:function(){return this.definition.data||{}}},{key:"getCompleteUrl",value:function(e){return(0,n.runTemplate)(this.templateUrl,this.definition,e)}}])&&i(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.Widget=o})),a=t((function(e,t){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.ClientWidgetApi=void 0;var n=u({});function i(){i=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(x){c=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var i=t&&t.prototype instanceof p?t:p,o=Object.create(i.prototype),a=new S(n||[]);return o._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=O(a,r);if(s){if(s===f)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=d(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,a),o}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(x){return{type:"throw",arg:x}}}e.wrap=l;var f={};function p(){}function v(){}function h(){}var y={};c(y,a,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(j([])));g&&g!==t&&n.call(g,a)&&(y=g);var b=h.prototype=p.prototype=Object.create(y);function w(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function _(e,t){var i;this._invoke=function(o,a){function s(){return new t((function(i,s){!function i(o,a,s,u){var c=d(e[o],e,a);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==r(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){i("next",e,s,u)}),(function(e){i("throw",e,s,u)})):t.resolve(f).then((function(e){l.value=e,s(l)}),(function(e){return i("throw",e,s,u)}))}u(c.arg)}(o,a,i,s)}))}return i=i?i.then(s,s):s()}}function O(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,O(e,t),"throw"===t.method))return f;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=d(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,f;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function j(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:C}}function C(){return{value:void 0,done:!0}}return v.prototype=h,c(b,"constructor",h),c(h,"constructor",v),v.displayName=c(h,u,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,c(e,u,"GeneratorFunction")),e.prototype=Object.create(b),e},e.awrap=function(e){return{__await:e}},w(_.prototype),c(_.prototype,s,(function(){return this})),e.AsyncIterator=_,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new _(l(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},w(b),c(b,u,"Generator"),c(b,a,(function(){return this})),c(b,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=j,S.prototype={constructor:S,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),E(r),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;E(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:j(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}function o(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(c){return void r(c)}s.done?t(u):Promise.resolve(u).then(n,i)}function a(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var a=e.apply(t,r);function s(e){o(a,n,i,s,u,"next",e)}function u(e){o(a,n,i,s,u,"throw",e)}s(void 0)}))}}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function d(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach((function(t){y(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function f(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function p(e,t){return(p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function v(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function h(e){return(h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function y(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function m(e){var t,r,n,i=2;for("undefined"!=typeof Symbol&&(r=Symbol.asyncIterator,n=Symbol.iterator);i--;){if(r&&null!=(t=e[r]))return t.call(e);if(n&&null!=(t=e[n]))return new g(t.call(e));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function g(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then((function(e){return{value:e,done:t}}))}return(g=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var r=this.s.return;return void 0===r?Promise.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?Promise.reject(e):t(r.apply(this.s,arguments))}},new g(e)}var b=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&p(e,t)}(A,c.EventEmitter);var t,o,u,l,g,b,w,_,O,k,S,j,x=(u=A,l=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=h(u);if(l){var n=h(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return v(e)}(this,e)});function A(e,t,r){var i;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,A),(i=x.call(this)).widget=e,i.iframe=t,i.driver=r,y(v(i),"transport",void 0),y(v(i),"contentLoadedActionSent",!1),y(v(i),"allowedCapabilities",new Set),y(v(i),"allowedEvents",[]),y(v(i),"isStopped",!1),y(v(i),"turnServers",null),null==t||!t.contentWindow)throw new Error("No iframe supplied");if(!e)throw new Error("Invalid widget");if(!r)throw new Error("Invalid driver");return i.transport=new n.PostmessageTransport(E.WidgetApiDirection.ToWidget,e.id,t.contentWindow,window),i.transport.targetOrigin=e.origin,i.transport.on("message",i.handleMessage.bind(v(i))),t.addEventListener("load",i.onIframeLoad.bind(v(i))),i.transport.start(),i}return t=A,(o=[{key:"hasCapability",value:function(e){return this.allowedCapabilities.has(e)}},{key:"canUseRoomTimeline",value:function(e){return this.hasCapability("org.matrix.msc2762.timeline:".concat(K.Symbols.AnyRoom))||this.hasCapability("org.matrix.msc2762.timeline:".concat(e))}},{key:"canSendRoomEvent",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.allowedEvents.some((function(r){return r.matchesAsRoomEvent(F.EventDirection.Send,e,t)}))}},{key:"canSendStateEvent",value:function(e,t){return this.allowedEvents.some((function(r){return r.matchesAsStateEvent(F.EventDirection.Send,e,t)}))}},{key:"canSendToDeviceEvent",value:function(e){return this.allowedEvents.some((function(t){return t.matchesAsToDeviceEvent(F.EventDirection.Send,e)}))}},{key:"canReceiveRoomEvent",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.allowedEvents.some((function(r){return r.matchesAsRoomEvent(F.EventDirection.Receive,e,t)}))}},{key:"canReceiveStateEvent",value:function(e,t){return this.allowedEvents.some((function(r){return r.matchesAsStateEvent(F.EventDirection.Receive,e,t)}))}},{key:"canReceiveToDeviceEvent",value:function(e){return this.allowedEvents.some((function(t){return t.matchesAsToDeviceEvent(F.EventDirection.Receive,e)}))}},{key:"stop",value:function(){this.isStopped=!0,this.transport.stop()}},{key:"beginCapabilities",value:function(){var e,t=this;this.emit("preparing"),this.transport.send(P.WidgetApiToWidgetAction.Capabilities,{}).then((function(r){return e=r.capabilities,t.driver.validateCapabilities(new Set(r.capabilities))})).then((function(r){console.log("Widget ".concat(t.widget.id," is allowed capabilities:"),Array.from(r)),t.allowedCapabilities=r,t.allowedEvents=F.WidgetEventCapability.findEventCapabilities(r),t.notifyCapabilities(e),t.emit("ready")}))}},{key:"notifyCapabilities",value:function(e){var t=this;this.transport.send(P.WidgetApiToWidgetAction.NotifyCapabilities,{requested:e,approved:Array.from(this.allowedCapabilities)}).catch((function(e){console.warn("non-fatal error notifying widget of approved capabilities:",e)})).then((function(){t.emit("capabilitiesNotified")}))}},{key:"onIframeLoad",value:function(e){this.widget.waitForIframeLoad?this.beginCapabilities():this.contentLoadedActionSent=!1}},{key:"handleContentLoadedAction",value:function(e){if(this.contentLoadedActionSent)throw new Error("Improper sequence: ContentLoaded Action can only be send once after the widget loaded and should only be used if waitForIframeLoad is false (default=true)");this.widget.waitForIframeLoad?this.transport.reply(e,{error:{message:"Improper sequence: not expecting ContentLoaded event if waitForIframLoad is true (default=true)"}}):(this.transport.reply(e,{}),this.beginCapabilities()),this.contentLoadedActionSent=!0}},{key:"replyVersions",value:function(e){this.transport.reply(e,{supported_versions:C.CurrentApiVersions})}},{key:"handleCapabilitiesRenegotiate",value:function(e){var t,r=this;this.transport.reply(e,{});var n=(null===(t=e.data)||void 0===t?void 0:t.capabilities)||[],i=new Set(n.filter((function(e){return!r.hasCapability(e)})));if(0===i.size)return this.notifyCapabilities([]);this.driver.validateCapabilities(i).then((function(e){return e.forEach((function(e){return r.allowedCapabilities.add(e)})),F.WidgetEventCapability.findEventCapabilities(e).forEach((function(e){return r.allowedEvents.push(e)})),r.notifyCapabilities(Array.from(i))}))}},{key:"handleNavigate",value:function(e){var t,r,n=this;if(!this.hasCapability(Y.MatrixCapabilities.MSC2931Navigate))return this.transport.reply(e,{error:{message:"Missing capability"}});if(null===(t=e.data)||void 0===t||!t.uri||null===(r=e.data)||void 0===r||!r.uri.toString().startsWith("https://matrix.to/#"))return this.transport.reply(e,{error:{message:"Invalid matrix.to URI"}});var i=function(t){return console.error("[ClientWidgetApi] Failed to handle navigation: ",t),n.transport.reply(e,{error:{message:"Error handling navigation"}})};try{this.driver.navigate(e.data.uri.toString()).catch((function(e){return i(e)})).then((function(){return n.transport.reply(e,{})}))}catch(o){return i(o)}}},{key:"handleOIDC",value:function(e){var t=this,r=1,n=function(n,i){return i=i||{},r>1?t.transport.send(P.WidgetApiToWidgetAction.OpenIDCredentials,d({state:n,original_request_id:e.requestId},i)):t.transport.reply(e,d({state:n},i))},i=function(i){return console.error("[ClientWidgetApi] Failed to handle OIDC: ",i),r>1?n(T.OpenIDRequestState.Blocked):t.transport.reply(e,{error:{message:i}})},o=new J.SimpleObservable((function(e){return e.state===T.OpenIDRequestState.PendingUserConfirmation&&r>1?(o.close(),i("client provided out-of-phase response to OIDC flow")):e.state===T.OpenIDRequestState.PendingUserConfirmation?(n(e.state),void r++):e.state!==T.OpenIDRequestState.Allowed||e.token?(e.state===T.OpenIDRequestState.Blocked&&(e.token=void 0),o.close(),n(e.state,e.token)):i("client provided invalid OIDC token for an allowed request")}));this.driver.askOpenID(o)}},{key:"handleReadEvents",value:function(e){var t=this;if(!e.data.type)return this.transport.reply(e,{error:{message:"Invalid request - missing event type"}});if(void 0!==e.data.limit&&(!e.data.limit||e.data.limit<0))return this.transport.reply(e,{error:{message:"Invalid request - limit out of range"}});var r=null;if(e.data.room_ids){r=e.data.room_ids,Array.isArray(r)||(r=[r]);var n,i=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return s(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?s(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}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 o,a=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){u=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw o}}}}(r);try{for(i.s();!(n=i.n()).done;){var o=n.value;if(!this.canUseRoomTimeline(o))return this.transport.reply(e,{error:{message:"Unable to access room timeline: ".concat(o)}})}}catch(l){i.e(l)}finally{i.f()}}var a=e.data.limit||0,u=Promise.resolve([]);if(void 0!==e.data.state_key){var c=!0===e.data.state_key?void 0:e.data.state_key.toString();if(!this.canReceiveStateEvent(e.data.type,null!=c?c:null))return this.transport.reply(e,{error:{message:"Cannot read state events of this type"}});u=this.driver.readStateEvents(e.data.type,c,a,r)}else{if(!this.canReceiveRoomEvent(e.data.type,e.data.msgtype))return this.transport.reply(e,{error:{message:"Cannot read room events of this type"}});u=this.driver.readRoomEvents(e.data.type,e.data.msgtype,a,r)}return u.then((function(r){return t.transport.reply(e,{events:r})}))}},{key:"handleSendEvent",value:function(e){var t,r=this;if(!e.data.type)return this.transport.reply(e,{error:{message:"Invalid request - missing event type"}});if(e.data.room_id&&!this.canUseRoomTimeline(e.data.room_id))return this.transport.reply(e,{error:{message:"Unable to access room timeline: ".concat(e.data.room_id)}});if(null!==e.data.state_key&&void 0!==e.data.state_key){if(!this.canSendStateEvent(e.data.type,e.data.state_key))return this.transport.reply(e,{error:{message:"Cannot send state events of this type"}});t=this.driver.sendEvent(e.data.type,e.data.content||{},e.data.state_key,e.data.room_id)}else{var n=e.data.content||{},i=n.msgtype;if(!this.canSendRoomEvent(e.data.type,i))return this.transport.reply(e,{error:{message:"Cannot send room events of this type"}});t=this.driver.sendEvent(e.data.type,n,null,e.data.room_id)}t.then((function(t){return r.transport.reply(e,{room_id:t.roomId,event_id:t.eventId})})).catch((function(t){return console.error("error sending event: ",t),r.transport.reply(e,{error:{message:"Error sending event"}})}))}},{key:"handleSendToDevice",value:(j=a(i().mark((function e(t){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.data.type){e.next=5;break}return e.next=3,this.transport.reply(t,{error:{message:"Invalid request - missing event type"}});case 3:e.next=32;break;case 5:if(t.data.messages){e.next=10;break}return e.next=8,this.transport.reply(t,{error:{message:"Invalid request - missing event contents"}});case 8:e.next=32;break;case 10:if("boolean"==typeof t.data.encrypted){e.next=15;break}return e.next=13,this.transport.reply(t,{error:{message:"Invalid request - missing encryption flag"}});case 13:e.next=32;break;case 15:if(this.canSendToDeviceEvent(t.data.type)){e.next=20;break}return e.next=18,this.transport.reply(t,{error:{message:"Cannot send to-device events of this type"}});case 18:e.next=32;break;case 20:return e.prev=20,e.next=23,this.driver.sendToDevice(t.data.type,t.data.encrypted,t.data.messages);case 23:return e.next=25,this.transport.reply(t,{});case 25:e.next=32;break;case 27:return e.prev=27,e.t0=e.catch(20),console.error("error sending to-device event",e.t0),e.next=32,this.transport.reply(t,{error:{message:"Error sending event"}});case 32:case"end":return e.stop()}}),e,this,[[20,27]])}))),function(e){return j.apply(this,arguments)})},{key:"pollTurnServers",value:(S=a(i().mark((function e(t,r){var n,o,a,s,u,c;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.transport.send(P.WidgetApiToWidgetAction.UpdateTurnServers,r);case 3:n=!1,o=!1,e.prev=5,s=m(t);case 7:return e.next=9,s.next();case 9:if(!(n=!(u=e.sent).done)){e.next=16;break}return c=u.value,e.next=13,this.transport.send(P.WidgetApiToWidgetAction.UpdateTurnServers,c);case 13:n=!1,e.next=7;break;case 16:e.next=22;break;case 18:e.prev=18,e.t0=e.catch(5),o=!0,a=e.t0;case 22:if(e.prev=22,e.prev=23,!n||null==s.return){e.next=27;break}return e.next=27,s.return();case 27:if(e.prev=27,!o){e.next=30;break}throw a;case 30:return e.finish(27);case 31:return e.finish(22);case 32:e.next=37;break;case 34:e.prev=34,e.t1=e.catch(0),console.error("error polling for TURN servers",e.t1);case 37:case"end":return e.stop()}}),e,this,[[0,34],[5,18,22,32],[23,,27,31]])}))),function(e,t){return S.apply(this,arguments)})},{key:"handleWatchTurnServers",value:(k=a(i().mark((function e(t){var r,n,o,a;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.hasCapability(Y.MatrixCapabilities.MSC3846TurnServers)){e.next=5;break}return e.next=3,this.transport.reply(t,{error:{message:"Missing capability"}});case 3:e.next=30;break;case 5:if(!this.turnServers){e.next=10;break}return e.next=8,this.transport.reply(t,{});case 8:e.next=30;break;case 10:return e.prev=10,r=this.driver.getTurnServers(),e.next=14,r.next();case 14:if(n=e.sent,o=n.done,a=n.value,!o){e.next=19;break}throw new Error("Client refuses to provide any TURN servers");case 19:return e.next=21,this.transport.reply(t,{});case 21:this.pollTurnServers(r,a),this.turnServers=r,e.next=30;break;case 25:return e.prev=25,e.t0=e.catch(10),console.error("error getting first TURN server results",e.t0),e.next=30,this.transport.reply(t,{error:{message:"TURN servers not available"}});case 30:case"end":return e.stop()}}),e,this,[[10,25]])}))),function(e){return k.apply(this,arguments)})},{key:"handleUnwatchTurnServers",value:(O=a(i().mark((function e(t){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.hasCapability(Y.MatrixCapabilities.MSC3846TurnServers)){e.next=5;break}return e.next=3,this.transport.reply(t,{error:{message:"Missing capability"}});case 3:e.next=15;break;case 5:if(this.turnServers){e.next=10;break}return e.next=8,this.transport.reply(t,{});case 8:e.next=15;break;case 10:return e.next=12,this.turnServers.return(void 0);case 12:return this.turnServers=null,e.next=15,this.transport.reply(t,{});case 15:case"end":return e.stop()}}),e,this)}))),function(e){return O.apply(this,arguments)})},{key:"handleReadRelations",value:(_=a(i().mark((function e(t){var r,n,o=this;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.data.event_id){e.next=2;break}return e.abrupt("return",this.transport.reply(t,{error:{message:"Invalid request - missing event ID"}}));case 2:if(!(void 0!==t.data.limit&&t.data.limit<0)){e.next=4;break}return e.abrupt("return",this.transport.reply(t,{error:{message:"Invalid request - limit out of range"}}));case 4:if(void 0===t.data.room_id||this.canUseRoomTimeline(t.data.room_id)){e.next=6;break}return e.abrupt("return",this.transport.reply(t,{error:{message:"Unable to access room timeline: ".concat(t.data.room_id)}}));case 6:return e.prev=6,e.next=9,this.driver.readEventRelations(t.data.event_id,t.data.room_id,t.data.rel_type,t.data.event_type,t.data.from,t.data.to,t.data.limit,t.data.direction);case 9:return r=e.sent,n=r.chunk.filter((function(e){return void 0!==e.state_key?o.canReceiveStateEvent(e.type,e.state_key):o.canReceiveRoomEvent(e.type,e.content.msgtype)})),e.abrupt("return",this.transport.reply(t,{chunk:n,prev_batch:r.prevBatch,next_batch:r.nextBatch}));case 14:return e.prev=14,e.t0=e.catch(6),console.error("error getting the relations",e.t0),e.next=19,this.transport.reply(t,{error:{message:"Unexpected error while reading relations"}});case 19:case"end":return e.stop()}}),e,this,[[6,14]])}))),function(e){return _.apply(this,arguments)})},{key:"handleUserDirectorySearch",value:(w=a(i().mark((function e(t){var r;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.hasCapability(Y.MatrixCapabilities.MSC3973UserDirectorySearch)){e.next=2;break}return e.abrupt("return",this.transport.reply(t,{error:{message:"Missing capability"}}));case 2:if("string"==typeof t.data.search_term){e.next=4;break}return e.abrupt("return",this.transport.reply(t,{error:{message:"Invalid request - missing search term"}}));case 4:if(!(void 0!==t.data.limit&&t.data.limit<0)){e.next=6;break}return e.abrupt("return",this.transport.reply(t,{error:{message:"Invalid request - limit out of range"}}));case 6:return e.prev=6,e.next=9,this.driver.searchUserDirectory(t.data.search_term,t.data.limit);case 9:return r=e.sent,e.abrupt("return",this.transport.reply(t,{limited:r.limited,results:r.results.map((function(e){return{user_id:e.userId,display_name:e.displayName,avatar_url:e.avatarUrl}}))}));case 13:return e.prev=13,e.t0=e.catch(6),console.error("error searching in the user directory",e.t0),e.next=18,this.transport.reply(t,{error:{message:"Unexpected error while searching in the user directory"}});case 18:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e){return w.apply(this,arguments)})},{key:"handleMessage",value:function(e){if(!this.isStopped){var t=new CustomEvent("action:".concat(e.detail.action),{detail:e.detail,cancelable:!0});if(this.emit("action:".concat(e.detail.action),t),!t.defaultPrevented)switch(e.detail.action){case P.WidgetApiFromWidgetAction.ContentLoaded:return this.handleContentLoadedAction(e.detail);case P.WidgetApiFromWidgetAction.SupportedApiVersions:return this.replyVersions(e.detail);case P.WidgetApiFromWidgetAction.SendEvent:return this.handleSendEvent(e.detail);case P.WidgetApiFromWidgetAction.SendToDevice:return this.handleSendToDevice(e.detail);case P.WidgetApiFromWidgetAction.GetOpenIDCredentials:return this.handleOIDC(e.detail);case P.WidgetApiFromWidgetAction.MSC2931Navigate:return this.handleNavigate(e.detail);case P.WidgetApiFromWidgetAction.MSC2974RenegotiateCapabilities:return this.handleCapabilitiesRenegotiate(e.detail);case P.WidgetApiFromWidgetAction.MSC2876ReadEvents:return this.handleReadEvents(e.detail);case P.WidgetApiFromWidgetAction.WatchTurnServers:return this.handleWatchTurnServers(e.detail);case P.WidgetApiFromWidgetAction.UnwatchTurnServers:return this.handleUnwatchTurnServers(e.detail);case P.WidgetApiFromWidgetAction.MSC3869ReadRelations:return this.handleReadRelations(e.detail);case P.WidgetApiFromWidgetAction.MSC3973UserDirectorySearch:return this.handleUserDirectorySearch(e.detail);default:return this.transport.reply(e.detail,{error:{message:"Unknown or unsupported action: "+e.detail.action}})}}}},{key:"takeScreenshot",value:function(){return this.transport.send(P.WidgetApiToWidgetAction.TakeScreenshot,{})}},{key:"updateVisibility",value:function(e){return this.transport.send(P.WidgetApiToWidgetAction.UpdateVisibility,{visible:e})}},{key:"sendWidgetConfig",value:function(e){return this.transport.send(P.WidgetApiToWidgetAction.WidgetConfig,e).then()}},{key:"notifyModalWidgetButtonClicked",value:function(e){return this.transport.send(P.WidgetApiToWidgetAction.ButtonClicked,{id:e}).then()}},{key:"notifyModalWidgetClose",value:function(e){return this.transport.send(P.WidgetApiToWidgetAction.CloseModalWidget,e).then()}},{key:"feedEvent",value:(b=a(i().mark((function e(t,r){var n;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.room_id===r||this.canUseRoomTimeline(t.room_id)){e.next=2;break}return e.abrupt("return");case 2:if(void 0===t.state_key||null===t.state_key){e.next=7;break}if(this.canReceiveStateEvent(t.type,t.state_key)){e.next=5;break}return e.abrupt("return");case 5:e.next=9;break;case 7:if(this.canReceiveRoomEvent(t.type,null===(n=t.content)||void 0===n?void 0:n.msgtype)){e.next=9;break}return e.abrupt("return");case 9:return e.next=11,this.transport.send(P.WidgetApiToWidgetAction.SendEvent,t);case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return b.apply(this,arguments)})},{key:"feedToDevice",value:(g=a(i().mark((function e(t,r){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.canReceiveToDeviceEvent(t.type)){e.next=3;break}return e.next=3,this.transport.send(P.WidgetApiToWidgetAction.SendToDevice,d(d({},t),{},{encrypted:r}));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return g.apply(this,arguments)})}])&&f(t.prototype,o),Object.defineProperty(t,"prototype",{writable:!1}),A}();t.ClientWidgetApi=b})),s=t((function(e,t){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.WidgetApi=void 0;var n=u({});function i(){i=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(x){c=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var i=t&&t.prototype instanceof p?t:p,o=Object.create(i.prototype),a=new S(n||[]);return o._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=O(a,r);if(s){if(s===f)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=d(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,a),o}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(x){return{type:"throw",arg:x}}}e.wrap=l;var f={};function p(){}function v(){}function h(){}var y={};c(y,a,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(j([])));g&&g!==t&&n.call(g,a)&&(y=g);var b=h.prototype=p.prototype=Object.create(y);function w(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function _(e,t){var i;this._invoke=function(o,a){function s(){return new t((function(i,s){!function i(o,a,s,u){var c=d(e[o],e,a);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==r(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){i("next",e,s,u)}),(function(e){i("throw",e,s,u)})):t.resolve(f).then((function(e){l.value=e,s(l)}),(function(e){return i("throw",e,s,u)}))}u(c.arg)}(o,a,i,s)}))}return i=i?i.then(s,s):s()}}function O(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,O(e,t),"throw"===t.method))return f;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=d(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,f;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function j(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:C}}function C(){return{value:void 0,done:!0}}return v.prototype=h,c(b,"constructor",h),c(h,"constructor",v),v.displayName=c(h,u,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,c(e,u,"GeneratorFunction")),e.prototype=Object.create(b),e},e.awrap=function(e){return{__await:e}},w(_.prototype),c(_.prototype,s,(function(){return this})),e.AsyncIterator=_,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new _(l(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},w(b),c(b,u,"Generator"),c(b,a,(function(){return this})),c(b,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=j,S.prototype={constructor:S,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),E(r),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;E(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:j(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}function o(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(c){return void r(c)}s.done?t(u):Promise.resolve(u).then(n,i)}function a(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var a=e.apply(t,r);function s(e){o(a,n,i,s,u,"next",e)}function u(e){o(a,n,i,s,u,"throw",e)}s(void 0)}))}}function s(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function l(e,t){return(l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function d(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function p(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function v(e){return new y(e)}function h(e){var t,r;function n(t,r){try{var o=e[t](r),a=o.value,s=a instanceof y;Promise.resolve(s?a.wrapped:a).then((function(e){s?n("return"===t?"return":"next",e):i(o.done?"return":"normal",e)}),(function(e){n("throw",e)}))}catch(u){i("throw",u)}}function i(e,i){switch(e){case"return":t.resolve({value:i,done:!0});break;case"throw":t.reject(i);break;default:t.resolve({value:i,done:!1})}(t=t.next)?n(t.key,t.arg):r=null}this._invoke=function(e,i){return new Promise((function(o,a){var s={key:e,arg:i,resolve:o,reject:a,next:null};r?r=r.next=s:(t=r=s,n(e,i))}))},"function"!=typeof e.return&&(this.return=void 0)}function y(e){this.wrapped=e}h.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},h.prototype.next=function(e){return this._invoke("next",e)},h.prototype.throw=function(e){return this._invoke("throw",e)},h.prototype.return=function(e){return this._invoke("return",e)};var m=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&l(e,t)}(w,c.EventEmitter);var t,o,u,y,m,g,b=(u=w,y=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=f(u);if(y){var n=f(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return d(e)}(this,e)});function w(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,w),(e=b.call(this)).clientOrigin=r,p(d(e),"transport",void 0),p(d(e),"capabilitiesFinished",!1),p(d(e),"supportsMSC2974Renegotiate",!1),p(d(e),"requestedCapabilities",[]),p(d(e),"approvedCapabilities",void 0),p(d(e),"cachedClientVersions",void 0),p(d(e),"turnServerWatchers",0),!window.parent)throw new Error("No parent window. This widget doesn't appear to be embedded properly.");return e.transport=new n.PostmessageTransport(E.WidgetApiDirection.FromWidget,t,window.parent,window),e.transport.targetOrigin=r,e.transport.on("message",e.handleMessage.bind(d(e))),e}return t=w,(o=[{key:"hasCapability",value:function(e){return Array.isArray(this.approvedCapabilities)?this.approvedCapabilities.includes(e):this.requestedCapabilities.includes(e)}},{key:"requestCapability",value:function(e){if(this.capabilitiesFinished&&!this.supportsMSC2974Renegotiate)throw new Error("Capabilities have already been negotiated");this.requestedCapabilities.push(e)}},{key:"requestCapabilities",value:function(e){var t=this;e.forEach((function(e){return t.requestCapability(e)}))}},{key:"requestCapabilityForRoomTimeline",value:function(e){this.requestCapability("org.matrix.msc2762.timeline:".concat(e))}},{key:"requestCapabilityToSendState",value:function(e,t){this.requestCapability(F.WidgetEventCapability.forStateEvent(F.EventDirection.Send,e,t).raw)}},{key:"requestCapabilityToReceiveState",value:function(e,t){this.requestCapability(F.WidgetEventCapability.forStateEvent(F.EventDirection.Receive,e,t).raw)}},{key:"requestCapabilityToSendToDevice",value:function(e){this.requestCapability(F.WidgetEventCapability.forToDeviceEvent(F.EventDirection.Send,e).raw)}},{key:"requestCapabilityToReceiveToDevice",value:function(e){this.requestCapability(F.WidgetEventCapability.forToDeviceEvent(F.EventDirection.Receive,e).raw)}},{key:"requestCapabilityToSendEvent",value:function(e){this.requestCapability(F.WidgetEventCapability.forRoomEvent(F.EventDirection.Send,e).raw)}},{key:"requestCapabilityToReceiveEvent",value:function(e){this.requestCapability(F.WidgetEventCapability.forRoomEvent(F.EventDirection.Receive,e).raw)}},{key:"requestCapabilityToSendMessage",value:function(e){this.requestCapability(F.WidgetEventCapability.forRoomMessageEvent(F.EventDirection.Send,e).raw)}},{key:"requestCapabilityToReceiveMessage",value:function(e){this.requestCapability(F.WidgetEventCapability.forRoomMessageEvent(F.EventDirection.Receive,e).raw)}},{key:"requestOpenIDConnectToken",value:function(){var e=this;return new Promise((function(t,r){e.transport.sendComplete(P.WidgetApiFromWidgetAction.GetOpenIDCredentials,{}).then((function(n){var i=n.response;i.state===T.OpenIDRequestState.Allowed?t(i):i.state===T.OpenIDRequestState.Blocked?r(new Error("User declined to verify their identity")):i.state===T.OpenIDRequestState.PendingUserConfirmation?e.on("action:".concat(P.WidgetApiToWidgetAction.OpenIDCredentials),(function o(a){a.preventDefault();var s=a.detail;s.data.original_request_id===n.requestId&&(s.data.state===T.OpenIDRequestState.Allowed?(t(s.data),e.transport.reply(s,{})):s.data.state===T.OpenIDRequestState.Blocked?(r(new Error("User declined to verify their identity")),e.transport.reply(s,{})):(r(new Error("Invalid state on reply: "+i.state)),e.transport.reply(s,{error:{message:"Invalid state"}})),e.off("action:".concat(P.WidgetApiToWidgetAction.OpenIDCredentials),o))})):r(new Error("Invalid state: "+i.state))})).catch(r)}))}},{key:"updateRequestedCapabilities",value:function(){return this.transport.send(P.WidgetApiFromWidgetAction.MSC2974RenegotiateCapabilities,{capabilities:this.requestedCapabilities}).then()}},{key:"sendContentLoaded",value:function(){return this.transport.send(P.WidgetApiFromWidgetAction.ContentLoaded,{}).then()}},{key:"sendSticker",value:function(e){return this.transport.send(P.WidgetApiFromWidgetAction.SendSticker,e).then()}},{key:"setAlwaysOnScreen",value:function(e){return this.transport.send(P.WidgetApiFromWidgetAction.UpdateAlwaysOnScreen,{value:e}).then((function(e){return e.success}))}},{key:"openModalWidget",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:I.MatrixWidgetType.Custom;return this.transport.send(P.WidgetApiFromWidgetAction.OpenModalWidget,{type:i,url:e,name:t,buttons:r,data:n}).then()}},{key:"closeModalWidget",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.transport.send(P.WidgetApiFromWidgetAction.CloseModalWidget,e).then()}},{key:"sendRoomEvent",value:function(e,t,r){return this.transport.send(P.WidgetApiFromWidgetAction.SendEvent,{type:e,content:t,room_id:r})}},{key:"sendStateEvent",value:function(e,t,r,n){return this.transport.send(P.WidgetApiFromWidgetAction.SendEvent,{type:e,content:r,state_key:t,room_id:n})}},{key:"sendToDevice",value:function(e,t,r){return this.transport.send(P.WidgetApiFromWidgetAction.SendToDevice,{type:e,encrypted:t,messages:r})}},{key:"readRoomEvents",value:function(e,t,r,n){var i={type:e,msgtype:r};return void 0!==t&&(i.limit=t),n&&(n.includes(K.Symbols.AnyRoom)?i.room_ids=K.Symbols.AnyRoom:i.room_ids=n),this.transport.send(P.WidgetApiFromWidgetAction.MSC2876ReadEvents,i).then((function(e){return e.events}))}},{key:"readEventRelations",value:(g=a(i().mark((function e(t,r,n,o,a,s,u,c){var l;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getClientVersions();case 2:if(e.sent.includes(C.UnstableApiVersion.MSC3869)){e.next=5;break}throw new Error("The read_relations action is not supported by the client.");case 5:return l={event_id:t,rel_type:n,event_type:o,room_id:r,to:u,from:s,limit:a,direction:c},e.abrupt("return",this.transport.send(P.WidgetApiFromWidgetAction.MSC3869ReadRelations,l));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,i,o,a,s){return g.apply(this,arguments)})},{key:"readStateEvents",value:function(e,t,r,n){var i={type:e,state_key:void 0===r||r};return void 0!==t&&(i.limit=t),n&&(n.includes(K.Symbols.AnyRoom)?i.room_ids=K.Symbols.AnyRoom:i.room_ids=n),this.transport.send(P.WidgetApiFromWidgetAction.MSC2876ReadEvents,i).then((function(e){return e.events}))}},{key:"setModalButtonEnabled",value:function(e,t){if(e===D.BuiltInModalButtonID.Close)throw new Error("The close button cannot be disabled");return this.transport.send(P.WidgetApiFromWidgetAction.SetModalButtonEnabled,{button:e,enabled:t}).then()}},{key:"navigateTo",value:function(e){if(!e||!e.startsWith("https://matrix.to/#"))throw new Error("Invalid matrix.to URI");return this.transport.send(P.WidgetApiFromWidgetAction.MSC2931Navigate,{uri:e}).then()}},{key:"getTurnServers",value:function(){var e,t=this;return(e=i().mark((function e(){var r,n;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=function(){var e=a(i().mark((function e(n){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n.preventDefault(),r(n.detail.data),e.next=4,t.transport.reply(n.detail,{});case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),t.on("action:".concat(P.WidgetApiToWidgetAction.UpdateTurnServers),n),0!==t.turnServerWatchers){e.next=12;break}return e.prev=3,e.next=6,v(t.transport.send(P.WidgetApiFromWidgetAction.WatchTurnServers,{}));case 6:e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(3),t.off("action:".concat(P.WidgetApiToWidgetAction.UpdateTurnServers),n),e.t0;case 12:t.turnServerWatchers++,e.prev=13;case 14:return e.next=17,v(new Promise((function(e){return r=e})));case 17:return e.next=19,e.sent;case 19:e.next=14;break;case 21:if(e.prev=21,t.off("action:".concat(P.WidgetApiToWidgetAction.UpdateTurnServers),n),t.turnServerWatchers--,0!==t.turnServerWatchers){e.next=27;break}return e.next=27,v(t.transport.send(P.WidgetApiFromWidgetAction.UnwatchTurnServers,{}));case 27:return e.finish(21);case 28:case"end":return e.stop()}}),e,null,[[3,8],[13,,21,28]])})),function(){return new h(e.apply(this,arguments))})()}},{key:"searchUserDirectory",value:(m=a(i().mark((function e(t,r){var n;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getClientVersions();case 2:if(e.sent.includes(C.UnstableApiVersion.MSC3973)){e.next=5;break}throw new Error("The user_directory_search action is not supported by the client.");case 5:return n={search_term:t,limit:r},e.abrupt("return",this.transport.send(P.WidgetApiFromWidgetAction.MSC3973UserDirectorySearch,n));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return m.apply(this,arguments)})},{key:"start",value:function(){var e=this;this.transport.start(),this.getClientVersions().then((function(t){t.includes(C.UnstableApiVersion.MSC2974)&&(e.supportsMSC2974Renegotiate=!0)}))}},{key:"handleMessage",value:function(e){var t=new CustomEvent("action:".concat(e.detail.action),{detail:e.detail,cancelable:!0});if(this.emit("action:".concat(e.detail.action),t),!t.defaultPrevented)switch(e.detail.action){case P.WidgetApiToWidgetAction.SupportedApiVersions:return this.replyVersions(e.detail);case P.WidgetApiToWidgetAction.Capabilities:return this.handleCapabilities(e.detail);case P.WidgetApiToWidgetAction.UpdateVisibility:case P.WidgetApiToWidgetAction.NotifyCapabilities:return this.transport.reply(e.detail,{});default:return this.transport.reply(e.detail,{error:{message:"Unknown or unsupported action: "+e.detail.action}})}}},{key:"replyVersions",value:function(e){this.transport.reply(e,{supported_versions:C.CurrentApiVersions})}},{key:"getClientVersions",value:function(){var e=this;return Array.isArray(this.cachedClientVersions)?Promise.resolve(this.cachedClientVersions):this.transport.send(P.WidgetApiFromWidgetAction.SupportedApiVersions,{}).then((function(t){return e.cachedClientVersions=t.supported_versions,t.supported_versions})).catch((function(e){return console.warn("non-fatal error getting supported client versions: ",e),[]}))}},{key:"handleCapabilities",value:function(e){var t=this;return this.capabilitiesFinished?this.transport.reply(e,{error:{message:"Capability negotiation already completed"}}):this.getClientVersions().then((function(r){return r.includes(C.UnstableApiVersion.MSC2871)?t.once("action:".concat(P.WidgetApiToWidgetAction.NotifyCapabilities),(function(e){t.approvedCapabilities=e.detail.data.approved,t.emit("ready")})):t.emit("ready"),t.capabilitiesFinished=!0,t.transport.reply(e,{capabilities:t.requestedCapabilities})}))}}])&&s(t.prototype,o),Object.defineProperty(t,"prototype",{writable:!1}),w}();t.WidgetApi=m})),u=t((function(e,t){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.PostmessageTransport=void 0;var i=r({});function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function a(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?o(Object(r),!0).forEach((function(t){f(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function s(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function u(e,t){return(u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function l(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var p=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&u(e,t)}(h,c.EventEmitter);var t,r,o,p,v=(o=h,p=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=d(o);if(p){var r=d(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"===n(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return l(e)}(this,e)});function h(e,t,r,n){var i;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,h),(i=v.call(this)).sendDirection=e,i.initialWidgetId=t,i.transportWindow=r,i.inboundWindow=n,f(l(i),"strictOriginCheck",!1),f(l(i),"targetOrigin","*"),f(l(i),"timeoutSeconds",10),f(l(i),"_ready",!1),f(l(i),"_widgetId",null),f(l(i),"outboundRequests",new Map),f(l(i),"stopController",new AbortController),i._widgetId=t,i}return t=h,(r=[{key:"ready",get:function(){return this._ready}},{key:"widgetId",get:function(){return this._widgetId||null}},{key:"nextRequestId",get:function(){for(var e="widgetapi-".concat(Date.now()),t=0,r=e;this.outboundRequests.has(r);)r="".concat(e,"-").concat(t++);return this.outboundRequests.set(r,null),r}},{key:"sendInternal",value:function(e){console.log("[PostmessageTransport] Sending object to ".concat(this.targetOrigin,": "),e),this.transportWindow.postMessage(e,this.targetOrigin)}},{key:"reply",value:function(e,t){return this.sendInternal(a(a({},e),{},{response:t}))}},{key:"send",value:function(e,t){return this.sendComplete(e,t).then((function(e){return e.response}))}},{key:"sendComplete",value:function(e,t){var r=this;if(!this.ready||!this.widgetId)return Promise.reject(new Error("Not ready or unknown widget ID"));var n={api:this.sendDirection,widgetId:this.widgetId,requestId:this.nextRequestId,action:e,data:t};return e===i.WidgetApiToWidgetAction.UpdateVisibility&&(n.visible=t.visible),new Promise((function(e,t){var i=function(e){s(),t(e)},o=setTimeout((function(){return i(new Error("Request timed out"))}),1e3*(r.timeoutSeconds||1)),a=function(){return i(new Error("Transport stopped"))};r.stopController.signal.addEventListener("abort",a);var s=function(){r.outboundRequests.delete(n.requestId),clearTimeout(o),r.stopController.signal.removeEventListener("abort",a)};r.outboundRequests.set(n.requestId,{request:n,resolve:function(t){s(),e(t)},reject:i}),r.sendInternal(n)}))}},{key:"start",value:function(){var e=this;this.inboundWindow.addEventListener("message",(function(t){e.handleMessage(t)})),this._ready=!0}},{key:"stop",value:function(){this._ready=!1,this.stopController.abort()}},{key:"handleMessage",value:function(e){if(!this.stopController.signal.aborted&&e.data&&(!this.strictOriginCheck||e.origin===window.origin)){var t=e.data;if(t.action&&t.requestId&&t.widgetId)if(t.response){if(t.api!==this.sendDirection)return;this.handleResponse(t)}else{var r=t;if(r.api!==(0,i.invertedDirection)(this.sendDirection))return;this.handleRequest(r)}}}},{key:"handleRequest",value:function(e){if(this.widgetId){if(this.widgetId!==e.widgetId)return}else this._widgetId=e.widgetId;this.emit("message",new CustomEvent("message",{detail:e}))}},{key:"handleResponse",value:function(e){if(e.widgetId===this.widgetId){var t=this.outboundRequests.get(e.requestId);if(t)if((0,i.isErrorResponse)(e.response)){var r=e.response;t.reject(new Error(r.error.message))}else t.resolve(e)}}}])&&s(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),h}();t.PostmessageTransport=p})),c={},l="object"==typeof Reflect?Reflect:null,d=l&&"function"==typeof l.apply?l.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};e=l&&"function"==typeof l.ownKeys?l.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var f=Number.isNaN||function(e){return e!=e};function p(){p.init.call(this)}(c=p).once=function(e,t){return new Promise((function(r,n){function i(r){e.removeListener(t,o),n(r)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}O(e,t,o,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&O(e,"error",t,{once:!0})}(e,i)}))},p.EventEmitter=p,p.prototype._events=void 0,p.prototype._eventsCount=0,p.prototype._maxListeners=void 0;var v=10;function h(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function y(e){return void 0===e._maxListeners?p.defaultMaxListeners:e._maxListeners}function m(e,t,r,n){var i,o,a,s;if(h(r),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),a=o[t]),void 0===a)a=o[t]=r,++e._eventsCount;else if("function"==typeof a?a=o[t]=n?[r,a]:[a,r]:n?a.unshift(r):a.push(r),(i=y(e))>0&&a.length>i&&!a.warned){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=a.length,s=u,console&&console.warn&&console.warn(s)}return e}function g(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=function(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}.bind(n);return i.listener=r,n.wrapFn=i,i}function b(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(i):_(i,i.length)}function w(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function _(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function O(e,t,r,n){if("function"==typeof e.on)n.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function i(o){n.once&&e.removeEventListener(t,i),r(o)}))}}Object.defineProperty(p,"defaultMaxListeners",{enumerable:!0,get:function(){return v},set:function(e){if("number"!=typeof e||e<0||f(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");v=e}}),p.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},p.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||f(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},p.prototype.getMaxListeners=function(){return y(this)},p.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var n="error"===e,i=this._events;if(void 0!==i)n=n&&void 0===i.error;else if(!n)return!1;if(n){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var s=i[e];if(void 0===s)return!1;if("function"==typeof s)d(s,this,t);else{var u=s.length,c=_(s,u);for(r=0;r<u;++r)d(c[r],this,t)}return!0},p.prototype.addListener=function(e,t){return m(this,e,t,!1)},p.prototype.on=p.prototype.addListener,p.prototype.prependListener=function(e,t){return m(this,e,t,!0)},p.prototype.once=function(e,t){return h(t),this.on(e,g(this,e,t)),this},p.prototype.prependOnceListener=function(e,t){return h(t),this.prependListener(e,g(this,e,t)),this},p.prototype.removeListener=function(e,t){var r,n,i,o,a;if(h(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,o=r.length-1;o>=0;o--)if(r[o]===t||r[o].listener===t){a=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,i),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,a||t)}return this},p.prototype.off=p.prototype.removeListener,p.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var i,o=Object.keys(r);for(n=0;n<o.length;++n)"removeListener"!==(i=o[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},p.prototype.listeners=function(e){return b(this,e,!0)},p.prototype.rawListeners=function(e){return b(this,e,!1)},p.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):w.call(e,t)},p.prototype.listenerCount=w,p.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]};var k,E={};Object.defineProperty(E,"__esModule",{value:!0}),E.WidgetApiDirection=void 0,E.invertedDirection=function(e){if(e===k.ToWidget)return k.FromWidget;if(e===k.FromWidget)return k.ToWidget;throw new Error("Invalid direction")},E.WidgetApiDirection=k,function(e){e.ToWidget="toWidget",e.FromWidget="fromWidget"}(k||(E.WidgetApiDirection=k={}));var S,j,C={};Object.defineProperty(C,"__esModule",{value:!0}),C.UnstableApiVersion=C.MatrixApiVersion=C.CurrentApiVersions=void 0,C.MatrixApiVersion=S,function(e){e.Prerelease1="0.0.1",e.Prerelease2="0.0.2"}(S||(C.MatrixApiVersion=S={})),C.UnstableApiVersion=j,function(e){e.MSC2762="org.matrix.msc2762",e.MSC2871="org.matrix.msc2871",e.MSC2931="org.matrix.msc2931",e.MSC2974="org.matrix.msc2974",e.MSC2876="org.matrix.msc2876",e.MSC3819="org.matrix.msc3819",e.MSC3846="town.robin.msc3846",e.MSC3869="org.matrix.msc3869",e.MSC3973="org.matrix.msc3973"}(j||(C.UnstableApiVersion=j={}));var x=[S.Prerelease1,S.Prerelease2,j.MSC2762,j.MSC2871,j.MSC2931,j.MSC2974,j.MSC2876,j.MSC3819,j.MSC3846,j.MSC3869,j.MSC3973];C.CurrentApiVersions=x;var A,W,P={};Object.defineProperty(P,"__esModule",{value:!0}),P.WidgetApiToWidgetAction=P.WidgetApiFromWidgetAction=void 0,P.WidgetApiToWidgetAction=A,function(e){e.SupportedApiVersions="supported_api_versions",e.Capabilities="capabilities",e.NotifyCapabilities="notify_capabilities",e.TakeScreenshot="screenshot",e.UpdateVisibility="visibility",e.OpenIDCredentials="openid_credentials",e.WidgetConfig="widget_config",e.CloseModalWidget="close_modal",e.ButtonClicked="button_clicked",e.SendEvent="send_event",e.SendToDevice="send_to_device",e.UpdateTurnServers="update_turn_servers"}(A||(P.WidgetApiToWidgetAction=A={})),P.WidgetApiFromWidgetAction=W,function(e){e.SupportedApiVersions="supported_api_versions",e.ContentLoaded="content_loaded",e.SendSticker="m.sticker",e.UpdateAlwaysOnScreen="set_always_on_screen",e.GetOpenIDCredentials="get_openid",e.CloseModalWidget="close_modal",e.OpenModalWidget="open_modal",e.SetModalButtonEnabled="set_button_enabled",e.SendEvent="send_event",e.SendToDevice="send_to_device",e.WatchTurnServers="watch_turn_servers",e.UnwatchTurnServers="unwatch_turn_servers",e.MSC2876ReadEvents="org.matrix.msc2876.read_events",e.MSC2931Navigate="org.matrix.msc2931.navigate",e.MSC2974RenegotiateCapabilities="org.matrix.msc2974.request_capabilities",e.MSC3869ReadRelations="org.matrix.msc3869.read_relations",e.MSC3973UserDirectorySearch="org.matrix.msc3973.user_directory_search"}(W||(P.WidgetApiFromWidgetAction=W={}));var M,T={};Object.defineProperty(T,"__esModule",{value:!0}),T.OpenIDRequestState=void 0,T.OpenIDRequestState=M,function(e){e.Allowed="allowed",e.Blocked="blocked",e.PendingUserConfirmation="request"}(M||(T.OpenIDRequestState=M={}));var R,I={};Object.defineProperty(I,"__esModule",{value:!0}),I.MatrixWidgetType=void 0,I.MatrixWidgetType=R,function(e){e.Custom="m.custom",e.JitsiMeet="m.jitsi",e.Stickerpicker="m.stickerpicker"}(R||(I.MatrixWidgetType=R={}));var L,D={};Object.defineProperty(D,"__esModule",{value:!0}),D.BuiltInModalButtonID=void 0,D.BuiltInModalButtonID=L,function(e){e.Close="m.close"}(L||(D.BuiltInModalButtonID=L={}));var U,q,F={};function N(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function V(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}Object.defineProperty(F,"__esModule",{value:!0}),F.WidgetEventCapability=F.EventKind=F.EventDirection=void 0,F.EventKind=U,function(e){e.Event="event",e.State="state_event",e.ToDevice="to_device"}(U||(F.EventKind=U={})),F.EventDirection=q,function(e){e.Send="send",e.Receive="receive"}(q||(F.EventDirection=q={}));var B=function(){function e(t,r,n,i,o){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.direction=t,this.eventType=r,this.kind=n,this.keyStr=i,this.raw=o}var t,r,n;return t=e,n=[{key:"forStateEvent",value:function(t,r,n){r=r.replace(/#/g,"\\#"),n=null!=n?"#".concat(n):"";var i="org.matrix.msc2762.".concat(t,".state_event:").concat(r).concat(n);return e.findEventCapabilities([i])[0]}},{key:"forToDeviceEvent",value:function(t,r){var n="org.matrix.msc3819.".concat(t,".to_device:").concat(r);return e.findEventCapabilities([n])[0]}},{key:"forRoomEvent",value:function(t,r){var n="org.matrix.msc2762.".concat(t,".event:").concat(r);return e.findEventCapabilities([n])[0]}},{key:"forRoomMessageEvent",value:function(t,r){r=null==r?"":r;var n="org.matrix.msc2762.".concat(t,".event:m.room.message#").concat(r);return e.findEventCapabilities([n])[0]}},{key:"findEventCapabilities",value:function(t){var r,n=[],i=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return N(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?N(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}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 o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}(t);try{for(i.s();!(r=i.n()).done;){var o=r.value,a=null,s=void 0,u=null;if(o.startsWith("org.matrix.msc2762.send.event:")?(a=q.Send,u=U.Event,s=o.substring("org.matrix.msc2762.send.event:".length)):o.startsWith("org.matrix.msc2762.send.state_event:")?(a=q.Send,u=U.State,s=o.substring("org.matrix.msc2762.send.state_event:".length)):o.startsWith("org.matrix.msc3819.send.to_device:")?(a=q.Send,u=U.ToDevice,s=o.substring("org.matrix.msc3819.send.to_device:".length)):o.startsWith("org.matrix.msc2762.receive.event:")?(a=q.Receive,u=U.Event,s=o.substring("org.matrix.msc2762.receive.event:".length)):o.startsWith("org.matrix.msc2762.receive.state_event:")?(a=q.Receive,u=U.State,s=o.substring("org.matrix.msc2762.receive.state_event:".length)):o.startsWith("org.matrix.msc3819.receive.to_device:")&&(a=q.Receive,u=U.ToDevice,s=o.substring("org.matrix.msc3819.receive.to_device:".length)),null!==a&&null!==u&&void 0!==s){var c=s.startsWith("m.room.message#")||u===U.State,l=null;if(s.includes("#")&&c){var d=s.split("#"),f=d.findIndex((function(e){return!e.endsWith("\\")}));s=d.slice(0,f+1).map((function(e){return e.endsWith("\\")?e.substring(0,e.length-1):e})).join("#"),l=d.slice(f+1).join("#")}n.push(new e(a,s,u,l,o))}}}catch(p){i.e(p)}finally{i.f()}return n}}],(r=[{key:"matchesAsStateEvent",value:function(e,t,r){return this.kind===U.State&&this.direction===e&&this.eventType===t&&(null===this.keyStr||this.keyStr===r)}},{key:"matchesAsToDeviceEvent",value:function(e,t){return this.kind===U.ToDevice&&this.direction===e&&this.eventType===t}},{key:"matchesAsRoomEvent",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return this.kind===U.Event&&this.direction===e&&this.eventType===t&&("m.room.message"!==this.eventType||null===this.keyStr||this.keyStr===r)}}])&&V(t.prototype,r),n&&V(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();F.WidgetEventCapability=B;var G,K={};Object.defineProperty(K,"__esModule",{value:!0}),K.Symbols=void 0,K.Symbols=G,function(e){e.AnyRoom="*"}(G||(K.Symbols=G={}));var $,Y={};Object.defineProperty(Y,"__esModule",{value:!0}),Y.VideoConferenceCapabilities=Y.StickerpickerCapabilities=Y.MatrixCapabilities=void 0,Y.getTimelineRoomIDFromCapability=function(e){return e.substring(e.indexOf(":")+1)},Y.isTimelineCapability=function(e){return null==e?void 0:e.startsWith("org.matrix.msc2762.timeline:")},Y.isTimelineCapabilityFor=function(e,t){return e==="org.matrix.msc2762.timeline:".concat(t)},Y.MatrixCapabilities=$,function(e){e.Screenshots="m.capability.screenshot",e.StickerSending="m.sticker",e.AlwaysOnScreen="m.always_on_screen",e.RequiresClient="io.element.requires_client",e.MSC2931Navigate="org.matrix.msc2931.navigate",e.MSC3846TurnServers="town.robin.msc3846.turn_servers",e.MSC3973UserDirectorySearch="org.matrix.msc3973.user_directory_search"}($||(Y.MatrixCapabilities=$={}));var z=[$.StickerSending];Y.StickerpickerCapabilities=z;var H=[$.AlwaysOnScreen];Y.VideoConferenceCapabilities=H;var J={};function Q(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function X(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}Object.defineProperty(J,"__esModule",{value:!0}),J.SimpleObservable=void 0;var Z=function(){function e(t){var r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),r=[],"listeners"in this?Object.defineProperty(this,"listeners",{value:r,enumerable:!0,configurable:!0,writable:!0}):this.listeners=r,t&&this.listeners.push(t)}var t,r;return t=e,(r=[{key:"onUpdate",value:function(e){this.listeners.push(e)}},{key:"update",value:function(e){var t,r=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return Q(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Q(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}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 o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}(this.listeners);try{for(r.s();!(t=r.n()).done;)(0,t.value)(e)}catch(n){r.e(n)}finally{r.f()}}},{key:"close",value:function(){this.listeners=[]}}])&&X(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),e}();J.SimpleObservable=Z;var ee={};Object.defineProperty(ee,"__esModule",{value:!0});var te={};Object.defineProperty(te,"__esModule",{value:!0});var re={};Object.defineProperty(re,"__esModule",{value:!0});var ne={};Object.defineProperty(ne,"__esModule",{value:!0});var ie={};Object.defineProperty(ie,"__esModule",{value:!0});var oe={};Object.defineProperty(oe,"__esModule",{value:!0}),oe.isErrorResponse=function(e){return"error"in e&&!!e.error.message};var ae={};Object.defineProperty(ae,"__esModule",{value:!0});var se={};Object.defineProperty(se,"__esModule",{value:!0});var ue={};Object.defineProperty(ue,"__esModule",{value:!0});var ce={};Object.defineProperty(ce,"__esModule",{value:!0});var le={};Object.defineProperty(le,"__esModule",{value:!0});var de={};Object.defineProperty(de,"__esModule",{value:!0});var fe={};Object.defineProperty(fe,"__esModule",{value:!0});var pe={};Object.defineProperty(pe,"__esModule",{value:!0});var ve={};Object.defineProperty(ve,"__esModule",{value:!0});var he={};Object.defineProperty(he,"__esModule",{value:!0});var ye,me={};Object.defineProperty(me,"__esModule",{value:!0}),me.WidgetKind=void 0,me.WidgetKind=ye,function(e){e.Room="room",e.Account="account",e.Modal="modal"}(ye||(me.WidgetKind=ye={}));var ge,be={};Object.defineProperty(be,"__esModule",{value:!0}),be.ModalButtonKind=void 0,be.ModalButtonKind=ge,function(e){e.Primary="m.primary",e.Secondary="m.secondary",e.Warning="m.warning",e.Danger="m.danger",e.Link="m.link"}(ge||(be.ModalButtonKind=ge={}));var we={};Object.defineProperty(we,"__esModule",{value:!0});var _e={};Object.defineProperty(_e,"__esModule",{value:!0});var Oe={};Object.defineProperty(Oe,"__esModule",{value:!0});var ke={};Object.defineProperty(ke,"__esModule",{value:!0});var Ee={};Object.defineProperty(Ee,"__esModule",{value:!0});var Se={};Object.defineProperty(Se,"__esModule",{value:!0});var je={};Object.defineProperty(je,"__esModule",{value:!0});var Ce={};Object.defineProperty(Ce,"__esModule",{value:!0});var xe={};Object.defineProperty(xe,"__esModule",{value:!0});var Ae={};Object.defineProperty(Ae,"__esModule",{value:!0}),Ae.isValidUrl=function(e){if(!e)return!1;try{var t=new URL(e);return"http"===t.protocol||"https"===t.protocol}catch(r){if(r instanceof TypeError)return!1;throw r}};var We={};Object.defineProperty(We,"__esModule",{value:!0}),We.assertPresent=function(e,t){if(!e[t])throw new Error("".concat(t," is required"))};var Pe={};function Me(e){return null==e?"".concat(e):String(e)}return Object.defineProperty(Pe,"__esModule",{value:!0}),Pe.runTemplate=function(e,t,r){for(var n=Object.assign({},t.data,{matrix_room_id:r.widgetRoomId||"",matrix_user_id:r.currentUserId,matrix_display_name:r.userDisplayName||r.currentUserId,matrix_avatar_url:r.userHttpAvatarUrl||"",matrix_widget_id:t.id,"org.matrix.msc2873.client_id":r.clientId||"","org.matrix.msc2873.client_theme":r.clientTheme||"","org.matrix.msc2873.client_language":r.clientLanguage||""}),i=e,o=0,a=Object.keys(n);o<a.length;o++){var s=a[o],u="$".concat(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=new RegExp(u,"g");i=i.replace(c,encodeURIComponent(Me(n[s])))}return i},Pe.toString=Me,r(),r})); \ No newline at end of file