diff --git a/src/i18n/en.json b/src/i18n/en.json index 8dca547c..2defa979 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -13,6 +13,25 @@ "label_push_notifications_disabled": "Notification alerts (requires HTTPS):", "title_tag_manager": "Tags (user discovery)", "button_logout": "Logout", + "requested_permissions": "Requested", + "granted_permissions": "Granted", + "menu_item_edit_permissions": "Edit permissions", + "label_other_user": "Other", + "title_info": "Info", + "label_topic_name": "Name", + "label_private": "Private comment", + "private_editing_placeholder": "Visible to you only", + "label_muting_topic": "Muted:", + "action_more": "More", + "label_your_permissions": "Your permissions:", + "label_permissions": "Permissions:", + "label_you": "You:", + "label_default_access": "Default access mode:", + "label_group_members": "Group members:", + "button_add_members": "Add members", + "button_leave": "Leave", + "group_has_no_members": "No members", + "action_leave_chat": "Leave", "login_prompt": "Login", "password_prompt": "Password", "stay_logged_in": "Stay logged in", @@ -45,6 +64,17 @@ "numeric_confirmation_code_prompt": "Numbers only", "button_confirm": "Confirm", "invalid_content": "invalid content", + "menu_item_info": "Info", + "menu_item_clear_messages": "Clear messages", + "menu_item_clear_messages_for_all": "Clear for All", + "menu_item_delete": "Delete", + "menu_item_delete_for_all": "Delete for All", + "menu_item_mute": "Mute", + "menu_item_unmute": "Unmute", + "menu_item_delete_topic": "Delete", + "menu_item_unblock": "Unblock", + "menu_item_block": "Block", + "menu_item_member_delete": "Remove", "title_group_members": "Group members", "button_ok": "OK", "button_cancel": "Cancel", diff --git a/src/i18n/ru.json b/src/i18n/ru.json index be1cd074..3807c564 100644 --- a/src/i18n/ru.json +++ b/src/i18n/ru.json @@ -62,13 +62,43 @@ "email_dative": "емейлу", "title_group_members": "Участники", "download_action": "скачать", - "permission_join": "Присоединяться ({val})", + "permission_join": "Подписываться ({val})", "permission_read": "Читать ({val})", "permission_write": "Писать ({val})", - "permission_pres": "Получать уведомления ({val})", - "permission_admin": "Администрировать ({val})", + "permission_pres": "Уведомлять ({val})", + "permission_admin": "Подтверждать ({val})", "permission_share": "Приглашать ({val})", "permission_delete": "Удалять ({val})", "permission_owner": "Владелец ({val})", - "title_permissions": "Права доступа" -} \ No newline at end of file + "title_permissions": "Права доступа", + "requested_permissions": "Требуются", + "granted_permissions": "Получены", + "menu_item_edit_permissions": "Права доступа", + "label_other_user": "Второй", + "label_topic_name": "Название", + "label_private": "Комментарий", + "private_editing_placeholder": "Виден только вам", + "label_muting_topic": "Без уведомлений", + "action_more": "Ещё", + "label_your_permissions": "Ваши права доступа:", + "label_permissions": "Права доступа:", + "label_you": "Вы:", + "label_default_access": "Права по умолчанию:", + "label_group_members": "Участники чата:", + "button_add_members": "Добавить", + "button_leave": "Отписаться", + "group_has_no_members": "Нет участников", + "action_leave_chat": "Уйти из чата", + "menu_item_info": "Информация", + "menu_item_clear_messages": "Удалить сообщения", + "menu_item_clear_messages_for_all": "Удалить для всех", + "menu_item_delete": "Удалить", + "menu_item_delete_for_all": "Удалить для всех", + "menu_item_mute": "Не уведомлять", + "menu_item_unmute": "Уведомлять", + "menu_item_delete_topic": "Удалить", + "menu_item_unblock": "Разблокировать", + "menu_item_block": "Заблокировать", + "menu_item_member_delete": "Отписать", + "title_info": "Подробности" +} diff --git a/src/lib/local-storage.js b/src/lib/local-storage.js index 9f134872..3c32aa94 100644 --- a/src/lib/local-storage.js +++ b/src/lib/local-storage.js @@ -15,7 +15,12 @@ export default class LocalStorageUtil { // Partially or wholly update stored object. static updateObject(key, value) { - let oldVal = localStorage.getObject(key); - localStorage.setObject(key, Object.assign(oldVal || {}, value)); + let oldVal = this.getObject(key); + this.setObject(key, Object.assign(oldVal || {}, value)); + } + + // Just a wrapper. + static removeItem(key) { + localStorage.removeItem(key); } } diff --git a/src/messages.json b/src/messages.json index 4ecbb40c..73450781 100644 --- a/src/messages.json +++ b/src/messages.json @@ -14,6 +14,25 @@ "label_push_notifications_disabled": "Notification alerts (requires HTTPS):", "title_tag_manager": "Tags (user discovery)", "button_logout": "Logout", + "requested_permissions": "Requested", + "granted_permissions": "Granted", + "menu_item_edit_permissions": "Edit permissions", + "label_other_user": "Other", + "title_info": "Info", + "label_topic_name": "Name", + "label_private": "Private comment", + "private_editing_placeholder": "Visible to you only", + "label_muting_topic": "Muted:", + "action_more": "More", + "label_your_permissions": "Your permissions:", + "label_permissions": "Permissions:", + "label_you": "You:", + "label_default_access": "Default access mode:", + "label_group_members": "Group members:", + "button_add_members": "Add members", + "button_leave": "Leave", + "group_has_no_members": "No members", + "action_leave_chat": "Leave", "login_prompt": "Login", "password_prompt": "Password", "stay_logged_in": "Stay logged in", @@ -46,6 +65,17 @@ "numeric_confirmation_code_prompt": "Numbers only", "button_confirm": "Confirm", "invalid_content": "invalid content", + "menu_item_info": "Info", + "menu_item_clear_messages": "Clear messages", + "menu_item_clear_messages_for_all": "Clear for All", + "menu_item_delete": "Delete", + "menu_item_delete_for_all": "Delete for All", + "menu_item_mute": "Mute", + "menu_item_unmute": "Unmute", + "menu_item_delete_topic": "Delete", + "menu_item_unblock": "Unblock", + "menu_item_block": "Block", + "menu_item_member_delete": "Remove", "title_group_members": "Group members", "button_ok": "OK", "button_cancel": "Cancel", @@ -140,11 +170,41 @@ "permission_join": "Присоединяться ({val})", "permission_read": "Читать ({val})", "permission_write": "Писать ({val})", - "permission_pres": "Получать уведомления ({val})", - "permission_admin": "Администрировать ({val})", + "permission_pres": "Уведомлять ({val})", + "permission_admin": "Подтверждать ({val})", "permission_share": "Приглашать ({val})", "permission_delete": "Удалять ({val})", "permission_owner": "Владелец ({val})", - "title_permissions": "Права доступа" + "title_permissions": "Права доступа", + "requested_permissions": "Требуются", + "granted_permissions": "Получены", + "menu_item_edit_permissions": "Права доступа", + "label_other_user": "Второй", + "label_topic_name": "Название", + "label_private": "Комментарий", + "private_editing_placeholder": "Виден только вам", + "label_muting_topic": "Без уведомлений", + "action_more": "Ещё", + "label_your_permissions": "Ваши права доступа:", + "label_permissions": "Права доступа:", + "label_you": "Вы:", + "label_default_access": "Права по умолчанию:", + "label_group_members": "Участники чата:", + "button_add_members": "Добавить", + "button_leave": "Отписаться", + "group_has_no_members": "Нет участников", + "action_leave_chat": "Уйти из чата", + "menu_item_info": "Информация", + "menu_item_clear_messages": "Удалить сообщения", + "menu_item_clear_messages_for_all": "Удалить для всех", + "menu_item_delete": "Удалить", + "menu_item_delete_for_all": "Удалить для всех", + "menu_item_mute": "Не уведомлять", + "menu_item_unmute": "Уведомлять", + "menu_item_delete_topic": "Удалить", + "menu_item_unblock": "Разблокировать", + "menu_item_block": "Заблокировать", + "menu_item_member_delete": "Отписать", + "title_info": "Подробности" } } \ No newline at end of file diff --git a/src/views/info-view.jsx b/src/views/info-view.jsx index f42af084..42ba43e5 100644 --- a/src/views/info-view.jsx +++ b/src/views/info-view.jsx @@ -1,5 +1,6 @@ // InfoView: panel with topic/user info. import React from 'react'; +import { FormattedMessage, defineMessages, injectIntl } from 'react-intl'; import AvatarUpload from '../widgets/avatar-upload.jsx'; import CheckBox from '../widgets/checkbox.jsx'; @@ -13,7 +14,30 @@ import TagManager from '../widgets/tag-manager.jsx'; import { makeImageUrl } from '../lib/blob-helpers.js'; -export default class InfoView extends React.Component { +const messages = defineMessages({ + requested: { + id: 'requested_permissions', + defaultMessage: 'Requested', + description: 'Title for permissions' + }, + granted: { + id: 'granted_permissions', + defaultMessage: 'Granted', + description: 'Title for permissions' + }, + edit_permissions: { + id: 'menu_item_edit_permissions', + defaultMessage: 'Edit permissions', + description: 'Menu item [Edit permissions]' + }, + other_user: { + id: 'label_other_user', + defaultMessage: 'Other', + description: 'Label for the other user when the user is unnamed' + } +}); + +class InfoView extends React.Component { constructor(props) { super(props); @@ -241,6 +265,7 @@ export default class InfoView extends React.Component { } handleLaunchPermissionsEditor(which, uid) { + const {formatMessage} = this.props.intl; let toEdit, toCompare, toSkip, titleEdit, titleCompare, userTitle, userAvatar; switch (which) { case 'mode': @@ -250,15 +275,15 @@ export default class InfoView extends React.Component { toEdit = this.state.modeWant; toCompare = this.state.modeGiven; toSkip = this.state.groupTopic ? 'O' : 'ASDO'; - titleEdit = "Requested"; - titleCompare = "Granted"; + titleEdit = formatMessage(messages.requested); + titleCompare = formatMessage(messages.granted); break; case 'given': toEdit = this.state.modeGiven2; toCompare = this.state.modeWant2; toSkip = this.state.groupTopic ? (this.state.owner ? '' : 'O') : 'ASDO'; - titleEdit = "Granted"; - titleCompare = "Requested"; + titleEdit = formatMessage(messages.granted); + titleCompare = formatMessage(messages.requested); break; case 'auth': toEdit = this.state.auth; @@ -280,8 +305,8 @@ export default class InfoView extends React.Component { toEdit = user.acs.getGiven(); toCompare = user.acs.getWant(); toSkip = this.state.owner ? '' : 'O'; - titleEdit = "Granted"; - titleCompare = "Requested"; + titleEdit = formatMessage(messages.granted); + titleCompare = formatMessage(messages.requested); if (user.public) { userTitle = user.public.fn; userAvatar = user.public.photo; @@ -342,18 +367,19 @@ export default class InfoView extends React.Component { } handleContextMenu(params) { - var instance = this; - var topic = this.props.tinode.getTopic(this.props.topic); + const {formatMessage} = this.props.intl; + const instance = this; + const topic = this.props.tinode.getTopic(this.props.topic); if (!topic) { return; } - var user = topic.subscriber(params.topicName); + const user = topic.subscriber(params.topicName); if (!user || !user.acs) { return; } - var menuItems = [ - {title: "Edit permissions", handler: function() { + const menuItems = [ + {title: formatMessage(messages.edit_permissions), handler: function() { instance.handleLaunchPermissionsEditor('user', params.topicName); }}, 'member_delete', @@ -368,10 +394,14 @@ export default class InfoView extends React.Component { } render() { + const {formatMessage} = this.props.intl; + return (
-
Info
+
+ +
@@ -407,17 +437,31 @@ export default class InfoView extends React.Component {
-
+
Unknown} readOnly={!this.state.owner} value={this.state.fullName} onFinished={this.handleFullNameUpdate} />
-
-
+
+ +
+
+ { + (private_placeholder) => + } +
- +
- + { + (more) => + } {this.state.moreInfoExpanded ?
- + {this.state.address}
{this.state.groupTopic ?
- + {this.state.access} @@ -454,13 +507,20 @@ export default class InfoView extends React.Component {
:
-
+
+ +
-
Yours:   +   {this.state.access}
-
{this.state.fullName ? this.state.fullName : "Other"}′s: +
{this.state.fullName ? this.state.fullName : formatMessage(messages.other_user)}:   {this.state.modeGiven2} @@ -470,7 +530,12 @@ export default class InfoView extends React.Component { } {this.state.sharer && (this.state.auth || this.state.anon) ?
-
+
+ +
Auth: {this.state.admin ?
{this.state.owner ? - + { + (tags) => + } : null } @@ -514,37 +581,46 @@ export default class InfoView extends React.Component { {this.state.groupTopic ?
- +
{this.state.sharer ? - person_add Add members + person_add : null} {!this.state.owner ? - exit_to_app Leave + exit_to_app : null}
- + { + (no_members) => + }
: } @@ -554,3 +630,5 @@ export default class InfoView extends React.Component { ); } }; + +export default injectIntl(InfoView); diff --git a/src/views/tinode-web.jsx b/src/views/tinode-web.jsx index 2a8ec80c..07aeec8e 100644 --- a/src/views/tinode-web.jsx +++ b/src/views/tinode-web.jsx @@ -1,8 +1,9 @@ // The top-level class to hold all functionality together. import React from 'react'; import ReactDOM from 'react-dom'; +import { injectIntl } from 'react-intl'; -import 'firebase/app'; +import * as firebase from 'firebase/app'; import 'firebase/messaging'; import Tinode from 'tinode-sdk'; @@ -23,7 +24,10 @@ import { updateFavicon } from '../lib/utils.js'; // Sound to play on message received. const POP_SOUND = new Audio('audio/msg.mp3'); -export default class TinodeWeb extends React.Component { +console.log("desktop alerts: is secure, is localhost, firebase, navigator, fb_init", + isSecureConnection(), isLocalHost(), (typeof firebase), (typeof navigator), (typeof FIREBASE_INIT)); + +class TinodeWeb extends React.Component { constructor(props) { super(props); @@ -353,7 +357,7 @@ export default class TinodeWeb extends React.Component { // Login failed, report error. this.setState({loginDisabled: false, credMethod: undefined, credCode: undefined}); this.handleError(err.message, 'err'); - LocalStorageUtil.removeItem('auth-token'); + localStorage.removeItem('auth-token'); HashNavigation.navigateTo(''); }); } else { @@ -396,7 +400,7 @@ export default class TinodeWeb extends React.Component { withDesc(). build() ).catch((err) => { - LocalStorageUtil.removeItem('auth-token'); + localStorage.removeItem('auth-token'); this.handleError(err.message, 'err'); HashNavigation.navigateTo(''); }); @@ -744,7 +748,7 @@ export default class TinodeWeb extends React.Component { console.log("Unable to delete token.", err); }).finally(() => { LocalStorageUtil.updateObject('settings', {desktopAlerts: false}); - LocalStorageUtil.removeItem('firebase-token'); + localStorage.removeItem('firebase-token'); this.setState({desktopAlerts: false, firebaseToken: null}); }); } else { @@ -865,7 +869,7 @@ export default class TinodeWeb extends React.Component { handleLogout() { updateFavicon(0); - LocalStorageUtil.removeItem('auth-token'); + localStorage.removeItem('auth-token'); if (this.tinode) { this.tinode.onDisconnect = undefined; this.tinode.disconnect(); @@ -906,12 +910,15 @@ export default class TinodeWeb extends React.Component { } defaultTopicContextMenu(topicName) { - var muted = false, blocked = false, subscribed = false, deleter = false; - var topic = this.tinode.getTopic(topicName); + const topic = this.tinode.getTopic(topicName); + const {formatMessage} = this.props.intl; + + let muted = false, blocked = false, subscribed = false, deleter = false; if (topic) { if (topic.isSubscribed()) { subscribed = true; - var acs = topic.getAccessMode(); + + let acs = topic.getAccessMode(); muted = acs && acs.isMuted(); blocked = acs && !acs.isJoiner(); deleter = acs && acs.isDeleter(); @@ -919,7 +926,7 @@ export default class TinodeWeb extends React.Component { } return [ - subscribed ? {title: "Info", handler: this.handleShowInfoView} : null, + subscribed ? {title: formatMessage({id: 'menu_item_info'}), handler: this.handleShowInfoView} : null, subscribed ? 'messages_clear' : null, subscribed && deleter ? 'messages_clear_hard' : null, subscribed ? (muted ? 'topic_unmute' : 'topic_mute') : null, @@ -1128,3 +1135,5 @@ export default class TinodeWeb extends React.Component { ); } }; + +export default injectIntl(TinodeWeb); diff --git a/src/widgets/context-menu.jsx b/src/widgets/context-menu.jsx index 97be0eeb..bc9d8532 100644 --- a/src/widgets/context-menu.jsx +++ b/src/widgets/context-menu.jsx @@ -1,38 +1,99 @@ // Context Menu: popup/dropdown menu. import React from 'react'; import ReactDOM from 'react-dom'; +import { injectIntl, defineMessages } from 'react-intl'; import { REM_SIZE } from '../config.js'; -export default class ContextMenu extends React.Component { +const messages = defineMessages({ + info: { + id: 'menu_item_info', + defaultMessage: 'Info', + description: 'Show extended topic information' + }, + clear_messages: { + id: 'menu_item_clear_messages', + defaultMessage: 'Clear messages', + description: 'Delete all messages' + }, + clear_for_all: { + id: 'menu_item_clear_messages_for_all', + defaultMessage: 'Clear for All', + description: 'Delete all message(s) for all members' + }, + 'delete': { + id: 'menu_item_delete', + defaultMessage: 'Delete', + description: 'Delete selected messages' + }, + delete_for_all: { + id: 'menu_item_delete_for_all', + defaultMessage: 'Delete for All', + description: 'Delete selected message(s) for all members' + }, + mute: { + id: 'menu_item_mute', + defaultMessage: 'Mute', + description: 'Turn off notifications' + }, + unmute: { + id: 'menu_item_unmute', + defaultMessage: 'Unmute', + description: 'Turn notifications on' + }, + topic_delete: { + id: 'menu_item_delete_topic', + defaultMessage: 'Delete', + description: 'Delete entire topic' + }, + unblock: { + id: 'menu_item_unblock', + defaultMessage: 'Unblock', + description: 'Unblock user' + }, + block: { + id: 'menu_item_block', + defaultMessage: 'Block', + description: 'Block user' + }, + member_delete: { + id: 'menu_item_member_delete', + defaultMessage: 'Remove', + description: 'Remove user from topic' + } +}); + +class ContextMenu extends React.Component { constructor(props) { super(props); + const {formatMessage} = props.intl; + this.handlePageClick = this.handlePageClick.bind(this); this.handleEscapeKey = this.handleEscapeKey.bind(this); this.handleClick = this.handleClick.bind(this); // Preconfigured menu items. this.MenuItems = { - 'topic_info': {title: "Info", handler: null}, + 'topic_info': {title: formatMessage(messages.info), handler: null}, - 'messages_clear': {title: "Clear messages", handler: (params, errorHandler) => { + 'messages_clear': {title: formatMessage(messages.clear_messages), handler: (params, errorHandler) => { this.deleteMessages(true, false, params, errorHandler); }}, - 'messages_clear_hard': {title: "Clear for All", handler: (params, errorHandler) => { + 'messages_clear_hard': {title: formatMessage(messages.clear_for_all), handler: (params, errorHandler) => { this.deleteMessages(true, true, params, errorHandler); }}, - 'message_delete': {title: "Delete", handler: (params, errorHandler) => { + 'message_delete': {title: formatMessage(messages.delete), handler: (params, errorHandler) => { this.deleteMessages(false, false, params, errorHandler); }}, - 'message_delete_hard': {title: "Delete for All", handler: (params, errorHandler) => { + 'message_delete_hard': {title: formatMessage(messages.delete_for_all), handler: (params, errorHandler) => { this.deleteMessages(false, true, params, errorHandler); }}, - 'topic_unmute': {title: "Unmute", handler: this.topicPermissionSetter.bind(this, '+P')}, - 'topic_mute': {title: "Mute", handler: this.topicPermissionSetter.bind(this, '-P')}, - 'topic_unblock': {title: "Unblock", handler: this.topicPermissionSetter.bind(this, '+J')}, - 'topic_block': {title: "Block", handler: this.topicPermissionSetter.bind(this, '-J')}, - 'topic_delete': {title: "Delete", handler: (params, errorHandler) => { + 'topic_unmute': {title: formatMessage(messages.unmute), handler: this.topicPermissionSetter.bind(this, '+P')}, + 'topic_mute': {title: formatMessage(messages.mute), handler: this.topicPermissionSetter.bind(this, '-P')}, + 'topic_unblock': {title: formatMessage(messages.unblock), handler: this.topicPermissionSetter.bind(this, '+J')}, + 'topic_block': {title: formatMessage(messages.block), handler: this.topicPermissionSetter.bind(this, '-J')}, + 'topic_delete': {title: formatMessage(messages.topic_delete), handler: (params, errorHandler) => { let topic = this.props.tinode.getTopic(params.topicName); if (!topic) { console.log("Topic not found: ", params.topicName); @@ -44,9 +105,9 @@ export default class ContextMenu extends React.Component { } }); }}, - - 'permissions': {title: "Edit permissions", handler: null}, - 'member_delete': {title: "Remove", handler: (params, errorHandler) => { + // menu_item_edit_permissions is defined elsewhere. + 'permissions': {title: formatMessage({id: 'menu_item_edit_permissions'}), handler: null}, + 'member_delete': {title: formatMessage(messages.member_delete), handler: (params, errorHandler) => { let topic = this.props.tinode.getTopic(params.topicName); if (!topic || !params.user) { console.log("Topic or user not found: '" + params.topicName + "', '" + params.user + "'"); @@ -58,10 +119,10 @@ export default class ContextMenu extends React.Component { } }); }}, - 'member_mute': {title: "Mute", handler: this.topicPermissionSetter.bind(this, '-P')}, - 'member_unmute': {title: "Unmute", handler: this.topicPermissionSetter.bind(this, '+P')}, - 'member_block': {title: "Block", handler: this.topicPermissionSetter.bind(this, '-J')}, - 'member_unblock': {title: "Unblock", handler: this.topicPermissionSetter.bind(this, '+J')}, + 'member_mute': {title: formatMessage(messages.mute), handler: this.topicPermissionSetter.bind(this, '-P')}, + 'member_unmute': {title: formatMessage(messages.unmute), handler: this.topicPermissionSetter.bind(this, '+P')}, + 'member_block': {title: formatMessage(messages.block), handler: this.topicPermissionSetter.bind(this, '-J')}, + 'member_unblock': {title: formatMessage(messages.unblock), handler: this.topicPermissionSetter.bind(this, '+J')}, }; } @@ -104,7 +165,7 @@ export default class ContextMenu extends React.Component { // Menu Actions deleteMessages(all, hard, params, errorHandler) { - var topic = this.props.tinode.getTopic(params.topicName); + const topic = this.props.tinode.getTopic(params.topicName); if (!topic) { console.log("Topic not found: ", params.topicName); return; @@ -127,13 +188,13 @@ export default class ContextMenu extends React.Component { // Function is used by context menu to set permissions. topicPermissionSetter(mode, params, errorHandler) { - var topic = this.props.tinode.getTopic(params.topicName); + const topic = this.props.tinode.getTopic(params.topicName); if (!topic) { console.log("Topic not found", params.topicName); return; } - var am, user; + let am, user; if (params.user) { user = topic.subscriber(params.user); if (!user) { @@ -171,16 +232,16 @@ export default class ContextMenu extends React.Component { }); // Ensure that menu is inside the app-container. - var hSize = 12 * REM_SIZE; - var vSize = REM_SIZE * (0.7 + menu.length * 2.5); - var left = (this.props.bounds.right - this.props.clickAt.x < hSize) ? + const hSize = 12 * REM_SIZE; + const vSize = REM_SIZE * (0.7 + menu.length * 2.5); + const left = (this.props.bounds.right - this.props.clickAt.x < hSize) ? (this.props.clickAt.x - this.props.bounds.left - hSize) : (this.props.clickAt.x - this.props.bounds.left); - var top = (this.props.bounds.bottom - this.props.clickAt.y < vSize) ? + const top = (this.props.bounds.bottom - this.props.clickAt.y < vSize) ? (this.props.clickAt.y - this.props.bounds.top - vSize) : (this.props.clickAt.y - this.props.bounds.top); - var position = { + const position = { left: left + 'px', top: top + 'px' }; @@ -192,3 +253,5 @@ export default class ContextMenu extends React.Component { ); } } + +export default injectIntl(ContextMenu); diff --git a/umd/index.dev.js b/umd/index.dev.js index ae67c644..3fa1a8cc 100644 --- a/umd/index.dev.js +++ b/umd/index.dev.js @@ -720,7 +720,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return LocalStorageUtil; });\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _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); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nvar LocalStorageUtil = function () {\n function LocalStorageUtil() {\n _classCallCheck(this, LocalStorageUtil);\n }\n\n _createClass(LocalStorageUtil, null, [{\n key: \"setObject\",\n value: function setObject(key, value) {\n localStorage.setItem(key, JSON.stringify(value));\n }\n }, {\n key: \"getObject\",\n value: function getObject(key) {\n var value = localStorage.getItem(key);\n return value && JSON.parse(value);\n }\n }, {\n key: \"updateObject\",\n value: function updateObject(key, value) {\n var oldVal = localStorage.getObject(key);\n localStorage.setObject(key, Object.assign(oldVal || {}, value));\n }\n }]);\n\n return LocalStorageUtil;\n}();\n\n\n\n//# sourceURL=webpack:///./src/lib/local-storage.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return LocalStorageUtil; });\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _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); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nvar LocalStorageUtil = function () {\n function LocalStorageUtil() {\n _classCallCheck(this, LocalStorageUtil);\n }\n\n _createClass(LocalStorageUtil, null, [{\n key: \"setObject\",\n value: function setObject(key, value) {\n localStorage.setItem(key, JSON.stringify(value));\n }\n }, {\n key: \"getObject\",\n value: function getObject(key) {\n var value = localStorage.getItem(key);\n return value && JSON.parse(value);\n }\n }, {\n key: \"updateObject\",\n value: function updateObject(key, value) {\n var oldVal = this.getObject(key);\n this.setObject(key, Object.assign(oldVal || {}, value));\n }\n }, {\n key: \"removeItem\",\n value: function removeItem(key) {\n localStorage.removeItem(key);\n }\n }]);\n\n return LocalStorageUtil;\n}();\n\n\n\n//# sourceURL=webpack:///./src/lib/local-storage.js?"); /***/ }), @@ -767,7 +767,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /*! exports provided: en, ru, default */ /***/ (function(module) { -eval("module.exports = {\"en\":{\"contacts_not_found\":\"You have no chats
¯\\\\\\\\_(ツ)_/¯\",\"full_name_prompt\":\"Full name, e.g. John Doe\",\"email_prompt\":\"Email, e.g. jdoe@example.com\",\"button_sign_up\":\"Sign up\",\"label_your_name\":\"Your name\",\"label_password\":\"Password\",\"password_unchanged_prompt\":\"Unchanged\",\"label_user_id\":\"Address:\",\"label_default_access_mode\":\"Default access mode:\",\"label_message_sound\":\"Message sound:\",\"label_push_notifications\":\"Notification alerts:\",\"label_push_notifications_disabled\":\"Notification alerts (requires HTTPS):\",\"title_tag_manager\":\"Tags (user discovery)\",\"button_logout\":\"Logout\",\"login_prompt\":\"Login\",\"password_prompt\":\"Password\",\"stay_logged_in\":\"Stay logged in\",\"forgot_password_link\":\"Forgot password?\",\"button_sign_in\":\"Sign in\",\"label_client\":\"Client:\",\"label_server\":\"Server:\",\"online_now\":\"online now\",\"last_seen_timestamp\":\"Last seen\",\"title_not_found\":\"Not found\",\"unnamed_topic\":\"Unnamed\",\"messages_not_readable\":\"no access to messages\",\"tabtitle_find_user\":\"find\",\"tabtitle_new_group\":\"new group\",\"tabtitle_group_by_id\":\"by id\",\"search_for_contacts\":\"Use search to find contacts\",\"label_server_to_use\":\"Server to use:\",\"label_wire_transport\":\"Wire transport:\",\"button_update\":\"Update\",\"sidepanel_title_login\":\"Sign In\",\"sidepanel_title_register\":\"Create Account\",\"sidepanel_title_settings\":\"Settings\",\"sidepanel_title_edit_account\":\"Edit Account\",\"sidepanel_title_newtpk\":\"Start New Chat\",\"sidepanel_title_cred\":\"Confirm Credentials\",\"sidepanel_title_reset\":\"Reset Password\",\"phone_dative\":\"phone\",\"email_dative\":\"email\",\"enter_confirmation_code_prompt\":\"Enter confirmation code sent to you by {method}:\",\"numeric_confirmation_code_prompt\":\"Numbers only\",\"button_confirm\":\"Confirm\",\"invalid_content\":\"invalid content\",\"title_group_members\":\"Group members\",\"button_ok\":\"OK\",\"button_cancel\":\"Cancel\",\"download_action\":\"download\",\"label_file_name\":\"File name:\",\"label_content_type\":\"Content type:\",\"label_size\":\"Size:\",\"permission_join\":\"Join ({val})\",\"permission_read\":\"Read ({val})\",\"permission_write\":\"Write ({val})\",\"permission_pres\":\"Get notified ({val})\",\"permission_admin\":\"Approve ({val})\",\"permission_share\":\"Share ({val})\",\"permission_delete\":\"Delete ({val})\",\"permission_owner\":\"Owner ({val})\",\"title_permissions\":\"Permissions\",\"message_sending\":\"sending...\",\"message_sending_failed\":\"failed\",\"search_placeholder\":\"List like email:alice@example.com, tel:17025550003...\",\"messaging_disabled_prompt\":\"Messaging disabled\",\"new_message_prompt\":\"New message\",\"file_attachment_too_large\":\"The file size {size} exceeds the {limit} limit.\",\"cannot_initiate_file_upload\":\"Cannot initiate file upload.\",\"tags_not_found\":\"No tags defined. Add some.\",\"tags_editor_no_tags\":\"Add some tags\",\"title_manage_tags\":\"Manage tags\"},\"ru\":{\"contacts_not_found\":\"Чатов нет
¯\\\\\\\\_(ツ)_/¯\",\"full_name_prompt\":\"Полное имя, напр. Иван Петров\",\"email_prompt\":\"Email, напр. ivan@example.com\",\"button_sign_up\":\"Создать счет\",\"label_your_name\":\"Ваше имя\",\"label_password\":\"Пароль\",\"password_unchanged_prompt\":\"Не изменен\",\"label_user_id\":\"Адрес:\",\"label_default_access_mode\":\"Доступ по умолчанию:\",\"label_message_sound\":\"Звук нового сообщения:\",\"label_push_notifications\":\"Уведомления:\",\"label_push_notifications_disabled\":\"Уведомления (требуют HTTPS):\",\"title_tag_manager\":\"Таги для поиска\",\"button_logout\":\"Выйти\",\"login_prompt\":\"Логин\",\"password_prompt\":\"Пароль\",\"stay_logged_in\":\"Запомнить\",\"forgot_password_link\":\"Напомнить пароль\",\"button_sign_in\":\"Войти\",\"label_client\":\"Клиент:\",\"label_server\":\"Сервер:\",\"online_now\":\"онлайн\",\"last_seen_timestamp\":\"Был активен\",\"title_not_found\":\"Не найден\",\"unnamed_topic\":\"Без названия\",\"messages_not_readable\":\"нет доступа к сообщениям\",\"tabtitle_find_user\":\"найти\",\"tabtitle_new_group\":\"создать\",\"tabtitle_group_by_id\":\"по id\",\"label_server_to_use\":\"Использовать сервер:\",\"label_wire_transport\":\"Соединение:\",\"button_update\":\"Применить\",\"sidepanel_title_login\":\"Авторизация\",\"sidepanel_title_register\":\"Зарегистрироваться\",\"sidepanel_title_settings\":\"Настройки\",\"sidepanel_title_edit_account\":\"Редактировать счет\",\"sidepanel_title_newtpk\":\"Новый чат\",\"sidepanel_title_cred\":\"Подтвердить\",\"sidepanel_title_reset\":\"Сменить пароль\",\"tags_not_found\":\"Тагов нет. Добавьте\",\"tags_editor_no_tags\":\"Добавьте таги\",\"title_manage_tags\":\"Редактор тагов\",\"message_sending\":\"шлём...\",\"message_sending_failed\":\"ошибка\",\"search_placeholder\":\"Список, напр. email:alice@example.com, tel:17025550003...\",\"messaging_disabled_prompt\":\"Отправка недоступна\",\"new_message_prompt\":\"Новое сообщение\",\"file_attachment_too_large\":\"Размер файла {size} превышает {limit} лимит.\",\"cannot_initiate_file_upload\":\"Ошибка загрузки файла.\",\"search_for_contacts\":\"Поиск контактов\",\"enter_confirmation_code_prompt\":\"Код подтверждения, полученный по {method}:\",\"numeric_confirmation_code_prompt\":\"Только цифры\",\"button_confirm\":\"Подтвердить\",\"button_ok\":\"OK\",\"button_cancel\":\"Отменить\",\"invalid_content\":\"сообщение не читается\",\"label_file_name\":\"Имя файла:\",\"label_content_type\":\"Тип:\",\"label_size\":\"Размер:\",\"phone_dative\":\"телефону\",\"email_dative\":\"емейлу\",\"title_group_members\":\"Участники\",\"download_action\":\"скачать\",\"permission_join\":\"Присоединяться ({val})\",\"permission_read\":\"Читать ({val})\",\"permission_write\":\"Писать ({val})\",\"permission_pres\":\"Получать уведомления ({val})\",\"permission_admin\":\"Администрировать ({val})\",\"permission_share\":\"Приглашать ({val})\",\"permission_delete\":\"Удалять ({val})\",\"permission_owner\":\"Владелец ({val})\",\"title_permissions\":\"Права доступа\"}};\n\n//# sourceURL=webpack:///./src/messages.json?"); +eval("module.exports = {\"en\":{\"contacts_not_found\":\"You have no chats
¯\\\\\\\\_(ツ)_/¯\",\"full_name_prompt\":\"Full name, e.g. John Doe\",\"email_prompt\":\"Email, e.g. jdoe@example.com\",\"button_sign_up\":\"Sign up\",\"label_your_name\":\"Your name\",\"label_password\":\"Password\",\"password_unchanged_prompt\":\"Unchanged\",\"label_user_id\":\"Address:\",\"label_default_access_mode\":\"Default access mode:\",\"label_message_sound\":\"Message sound:\",\"label_push_notifications\":\"Notification alerts:\",\"label_push_notifications_disabled\":\"Notification alerts (requires HTTPS):\",\"title_tag_manager\":\"Tags (user discovery)\",\"button_logout\":\"Logout\",\"requested_permissions\":\"Requested\",\"granted_permissions\":\"Granted\",\"menu_item_edit_permissions\":\"Edit permissions\",\"label_other_user\":\"Other\",\"title_info\":\"Info\",\"label_topic_name\":\"Name\",\"label_private\":\"Private comment\",\"private_editing_placeholder\":\"Visible to you only\",\"label_muting_topic\":\"Muted:\",\"action_more\":\"More\",\"label_your_permissions\":\"Your permissions:\",\"label_permissions\":\"Permissions:\",\"label_you\":\"You:\",\"label_default_access\":\"Default access mode:\",\"label_group_members\":\"Group members:\",\"button_add_members\":\"Add members\",\"button_leave\":\"Leave\",\"group_has_no_members\":\"No members\",\"action_leave_chat\":\"Leave\",\"login_prompt\":\"Login\",\"password_prompt\":\"Password\",\"stay_logged_in\":\"Stay logged in\",\"forgot_password_link\":\"Forgot password?\",\"button_sign_in\":\"Sign in\",\"label_client\":\"Client:\",\"label_server\":\"Server:\",\"online_now\":\"online now\",\"last_seen_timestamp\":\"Last seen\",\"title_not_found\":\"Not found\",\"unnamed_topic\":\"Unnamed\",\"messages_not_readable\":\"no access to messages\",\"tabtitle_find_user\":\"find\",\"tabtitle_new_group\":\"new group\",\"tabtitle_group_by_id\":\"by id\",\"search_for_contacts\":\"Use search to find contacts\",\"label_server_to_use\":\"Server to use:\",\"label_wire_transport\":\"Wire transport:\",\"button_update\":\"Update\",\"sidepanel_title_login\":\"Sign In\",\"sidepanel_title_register\":\"Create Account\",\"sidepanel_title_settings\":\"Settings\",\"sidepanel_title_edit_account\":\"Edit Account\",\"sidepanel_title_newtpk\":\"Start New Chat\",\"sidepanel_title_cred\":\"Confirm Credentials\",\"sidepanel_title_reset\":\"Reset Password\",\"phone_dative\":\"phone\",\"email_dative\":\"email\",\"enter_confirmation_code_prompt\":\"Enter confirmation code sent to you by {method}:\",\"numeric_confirmation_code_prompt\":\"Numbers only\",\"button_confirm\":\"Confirm\",\"invalid_content\":\"invalid content\",\"menu_item_info\":\"Info\",\"menu_item_clear_messages\":\"Clear messages\",\"menu_item_clear_messages_for_all\":\"Clear for All\",\"menu_item_delete\":\"Delete\",\"menu_item_delete_for_all\":\"Delete for All\",\"menu_item_mute\":\"Mute\",\"menu_item_unmute\":\"Unmute\",\"menu_item_delete_topic\":\"Delete\",\"menu_item_unblock\":\"Unblock\",\"menu_item_block\":\"Block\",\"menu_item_member_delete\":\"Remove\",\"title_group_members\":\"Group members\",\"button_ok\":\"OK\",\"button_cancel\":\"Cancel\",\"download_action\":\"download\",\"label_file_name\":\"File name:\",\"label_content_type\":\"Content type:\",\"label_size\":\"Size:\",\"permission_join\":\"Join ({val})\",\"permission_read\":\"Read ({val})\",\"permission_write\":\"Write ({val})\",\"permission_pres\":\"Get notified ({val})\",\"permission_admin\":\"Approve ({val})\",\"permission_share\":\"Share ({val})\",\"permission_delete\":\"Delete ({val})\",\"permission_owner\":\"Owner ({val})\",\"title_permissions\":\"Permissions\",\"message_sending\":\"sending...\",\"message_sending_failed\":\"failed\",\"search_placeholder\":\"List like email:alice@example.com, tel:17025550003...\",\"messaging_disabled_prompt\":\"Messaging disabled\",\"new_message_prompt\":\"New message\",\"file_attachment_too_large\":\"The file size {size} exceeds the {limit} limit.\",\"cannot_initiate_file_upload\":\"Cannot initiate file upload.\",\"tags_not_found\":\"No tags defined. Add some.\",\"tags_editor_no_tags\":\"Add some tags\",\"title_manage_tags\":\"Manage tags\"},\"ru\":{\"contacts_not_found\":\"Чатов нет
¯\\\\\\\\_(ツ)_/¯\",\"full_name_prompt\":\"Полное имя, напр. Иван Петров\",\"email_prompt\":\"Email, напр. ivan@example.com\",\"button_sign_up\":\"Создать счет\",\"label_your_name\":\"Ваше имя\",\"label_password\":\"Пароль\",\"password_unchanged_prompt\":\"Не изменен\",\"label_user_id\":\"Адрес:\",\"label_default_access_mode\":\"Доступ по умолчанию:\",\"label_message_sound\":\"Звук нового сообщения:\",\"label_push_notifications\":\"Уведомления:\",\"label_push_notifications_disabled\":\"Уведомления (требуют HTTPS):\",\"title_tag_manager\":\"Таги для поиска\",\"button_logout\":\"Выйти\",\"login_prompt\":\"Логин\",\"password_prompt\":\"Пароль\",\"stay_logged_in\":\"Запомнить\",\"forgot_password_link\":\"Напомнить пароль\",\"button_sign_in\":\"Войти\",\"label_client\":\"Клиент:\",\"label_server\":\"Сервер:\",\"online_now\":\"онлайн\",\"last_seen_timestamp\":\"Был активен\",\"title_not_found\":\"Не найден\",\"unnamed_topic\":\"Без названия\",\"messages_not_readable\":\"нет доступа к сообщениям\",\"tabtitle_find_user\":\"найти\",\"tabtitle_new_group\":\"создать\",\"tabtitle_group_by_id\":\"по id\",\"label_server_to_use\":\"Использовать сервер:\",\"label_wire_transport\":\"Соединение:\",\"button_update\":\"Применить\",\"sidepanel_title_login\":\"Авторизация\",\"sidepanel_title_register\":\"Зарегистрироваться\",\"sidepanel_title_settings\":\"Настройки\",\"sidepanel_title_edit_account\":\"Редактировать счет\",\"sidepanel_title_newtpk\":\"Новый чат\",\"sidepanel_title_cred\":\"Подтвердить\",\"sidepanel_title_reset\":\"Сменить пароль\",\"tags_not_found\":\"Тагов нет. Добавьте\",\"tags_editor_no_tags\":\"Добавьте таги\",\"title_manage_tags\":\"Редактор тагов\",\"message_sending\":\"в пути...\",\"message_sending_failed\":\"ошибка\",\"search_placeholder\":\"Список, напр. email:alice@example.com, tel:17025550003...\",\"messaging_disabled_prompt\":\"Отправка недоступна\",\"new_message_prompt\":\"Новое сообщение\",\"file_attachment_too_large\":\"Размер файла {size} превышает {limit} лимит.\",\"cannot_initiate_file_upload\":\"Ошибка загрузки файла.\",\"search_for_contacts\":\"Поиск контактов\",\"enter_confirmation_code_prompt\":\"Код подтверждения, полученный по {method}:\",\"numeric_confirmation_code_prompt\":\"Только цифры\",\"button_confirm\":\"Подтвердить\",\"button_ok\":\"OK\",\"button_cancel\":\"Отменить\",\"invalid_content\":\"сообщение не читается\",\"label_file_name\":\"Имя файла:\",\"label_content_type\":\"Тип:\",\"label_size\":\"Размер:\",\"phone_dative\":\"телефону\",\"email_dative\":\"емейлу\",\"title_group_members\":\"Участники\",\"download_action\":\"скачать\",\"permission_join\":\"Присоединяться ({val})\",\"permission_read\":\"Читать ({val})\",\"permission_write\":\"Писать ({val})\",\"permission_pres\":\"Уведомлять ({val})\",\"permission_admin\":\"Подтверждать ({val})\",\"permission_share\":\"Приглашать ({val})\",\"permission_delete\":\"Удалять ({val})\",\"permission_owner\":\"Владелец ({val})\",\"title_permissions\":\"Права доступа\",\"requested_permissions\":\"Требуются\",\"granted_permissions\":\"Получены\",\"menu_item_edit_permissions\":\"Права доступа\",\"label_other_user\":\"Второй\",\"label_topic_name\":\"Название\",\"label_private\":\"Комментарий\",\"private_editing_placeholder\":\"Виден только вам\",\"label_muting_topic\":\"Без уведомлений\",\"action_more\":\"Ещё\",\"label_your_permissions\":\"Ваши права доступа:\",\"label_permissions\":\"Права доступа:\",\"label_you\":\"Вы:\",\"label_default_access\":\"Права по умолчанию:\",\"label_group_members\":\"Участники чата:\",\"button_add_members\":\"Добавить\",\"button_leave\":\"Отписаться\",\"group_has_no_members\":\"Нет участников\",\"action_leave_chat\":\"Уйти из чата\",\"menu_item_info\":\"Информация\",\"menu_item_clear_messages\":\"Удалить сообщения\",\"menu_item_clear_messages_for_all\":\"Удалить для всех\",\"menu_item_delete\":\"Удалить\",\"menu_item_delete_for_all\":\"Удалить для всех\",\"menu_item_mute\":\"Не уведомлять\",\"menu_item_unmute\":\"Уведомлять\",\"menu_item_delete_topic\":\"Удалить\",\"menu_item_unblock\":\"Разблокировать\",\"menu_item_block\":\"Заблокировать\",\"menu_item_member_delete\":\"Отписать\",\"title_info\":\"Подробности\"}};\n\n//# sourceURL=webpack:///./src/messages.json?"); /***/ }), @@ -827,7 +827,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return InfoView; });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _widgets_avatar_upload_jsx__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../widgets/avatar-upload.jsx */ \"./src/widgets/avatar-upload.jsx\");\n/* harmony import */ var _widgets_checkbox_jsx__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../widgets/checkbox.jsx */ \"./src/widgets/checkbox.jsx\");\n/* harmony import */ var _widgets_contact_list_jsx__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../widgets/contact-list.jsx */ \"./src/widgets/contact-list.jsx\");\n/* harmony import */ var _widgets_group_manager_jsx__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../widgets/group-manager.jsx */ \"./src/widgets/group-manager.jsx\");\n/* harmony import */ var _widgets_in_place_edit_jsx__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../widgets/in-place-edit.jsx */ \"./src/widgets/in-place-edit.jsx\");\n/* harmony import */ var _widgets_menu_cancel_jsx__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../widgets/menu-cancel.jsx */ \"./src/widgets/menu-cancel.jsx\");\n/* harmony import */ var _widgets_more_button_jsx__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../widgets/more-button.jsx */ \"./src/widgets/more-button.jsx\");\n/* harmony import */ var _widgets_permissions_editor_jsx__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../widgets/permissions-editor.jsx */ \"./src/widgets/permissions-editor.jsx\");\n/* harmony import */ var _widgets_tag_manager_jsx__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../widgets/tag-manager.jsx */ \"./src/widgets/tag-manager.jsx\");\n/* harmony import */ var _lib_blob_helpers_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../lib/blob-helpers.js */ \"./src/lib/blob-helpers.js\");\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _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); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar InfoView = function (_React$Component) {\n _inherits(InfoView, _React$Component);\n\n function InfoView(props) {\n var _this;\n\n _classCallCheck(this, InfoView);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(InfoView).call(this, props));\n _this.state = {\n topic: null,\n owner: false,\n admin: false,\n sharer: false,\n muted: false,\n address: null,\n groupTopic: undefined,\n fullName: undefined,\n avatar: null,\n private: null,\n selectedContact: null,\n access: null,\n modeGiven: null,\n modeWant: null,\n modeGiven2: null,\n modeWant2: null,\n auth: null,\n anon: null,\n contactList: [],\n tags: [],\n showMemberPanel: false,\n showPermissionEditorFor: undefined,\n moreInfoExpanded: false,\n previousMetaDesc: undefined,\n previousSubsUpdated: undefined,\n previousTagsUpdated: undefined\n };\n _this.resetSubs = _this.resetSubs.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.resetDesc = _this.resetDesc.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.onMetaDesc = _this.onMetaDesc.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.onSubsUpdated = _this.onSubsUpdated.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.onTagsUpdated = _this.onTagsUpdated.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleFullNameUpdate = _this.handleFullNameUpdate.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handlePrivateUpdate = _this.handlePrivateUpdate.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleImageChanged = _this.handleImageChanged.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleMuted = _this.handleMuted.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handlePermissionsChanged = _this.handlePermissionsChanged.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleLaunchPermissionsEditor = _this.handleLaunchPermissionsEditor.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleHidePermissionsEditor = _this.handleHidePermissionsEditor.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleShowAddMembers = _this.handleShowAddMembers.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleHideAddMembers = _this.handleHideAddMembers.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleMemberUpdateRequest = _this.handleMemberUpdateRequest.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleLeave = _this.handleLeave.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleMemberSelected = _this.handleMemberSelected.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleMoreInfo = _this.handleMoreInfo.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleTagsUpdated = _this.handleTagsUpdated.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleContextMenu = _this.handleContextMenu.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n return _this;\n }\n\n _createClass(InfoView, [{\n key: \"UNSAFE_componentWillReceiveProps\",\n value: function UNSAFE_componentWillReceiveProps(props) {\n var topic = this.props.tinode.getTopic(props.topic);\n\n if (!topic) {\n return;\n }\n\n if (this.onMetaDesc != topic.onMetaDesc) {\n this.previousMetaDesc = topic.onMetaDesc;\n topic.onMetaDesc = this.onMetaDesc;\n this.previousSubsUpdated = topic.onSubsUpdated;\n topic.onSubsUpdated = this.onSubsUpdated;\n\n if (topic.getType() == 'grp') {\n this.previousTagsUpdated = topic.onTagsUpdated;\n topic.onTagsUpdated = this.onTagsUpdated;\n } else {\n this.previousTagsUpdated = undefined;\n }\n }\n\n if (this.state.topic != props.topic) {\n this.setState({\n topic: props.topic\n });\n this.resetDesc(topic, props);\n this.resetSubs(topic, props);\n }\n }\n }, {\n key: \"componentWillUnmount\",\n value: function componentWillUnmount() {\n var topic = this.props.tinode.getTopic(this.props.topic);\n\n if (!topic) {\n return;\n }\n\n this.setState({\n topic: null\n });\n topic.onMetaDesc = this.previousMetaDesc;\n topic.onSubsUpdated = this.previousSubsUpdated;\n topic.onTagsUpdated = this.previousTagsUpdated;\n }\n }, {\n key: \"resetSubs\",\n value: function resetSubs(topic, props) {\n var newState = {\n contactList: []\n };\n\n if (topic.getType() == 'p2p') {\n var user2 = topic.subscriber(props.topic);\n\n if (user2) {\n newState.modeGiven2 = user2.acs.getGiven();\n newState.modeWant2 = user2.acs.getWant();\n }\n } else {\n topic.subscribers(function (sub) {\n newState.contactList.push(sub);\n }, this);\n }\n\n this.setState(newState);\n }\n }, {\n key: \"resetDesc\",\n value: function resetDesc(topic, props) {\n var defacs = topic.getDefaultAccess() || {};\n var acs = topic.getAccessMode();\n this.setState({\n owner: acs && acs.isOwner(),\n admin: acs && acs.isAdmin(),\n sharer: acs && (acs.isAdmin() || acs.isSharer()),\n muted: acs && acs.isMuted(),\n fullName: topic.public ? topic.public.fn : undefined,\n avatar: Object(_lib_blob_helpers_js__WEBPACK_IMPORTED_MODULE_10__[\"makeImageUrl\"])(topic.public ? topic.public.photo : null),\n private: topic.private ? topic.private.comment : null,\n address: topic.name,\n groupTopic: topic.getType() == 'grp',\n showMemberPanel: false,\n access: acs ? acs.getMode() : undefined,\n modeGiven: acs ? acs.getGiven() : undefined,\n modeWant: acs ? acs.getWant() : undefined,\n auth: defacs.auth,\n anon: defacs.anon\n });\n\n if (topic.getType() == 'grp' && acs && acs.isOwner()) {\n topic.getMeta(topic.startMetaQuery().withTags().build());\n }\n }\n }, {\n key: \"onMetaDesc\",\n value: function onMetaDesc(desc) {\n var topic = this.props.tinode.getTopic(this.props.topic);\n\n if (!topic) {\n return;\n }\n\n this.resetDesc(topic, this.props);\n\n if (this.previousMetaDesc && this.previousMetaDesc != this.onMetaDesc) {\n this.previousMetaDesc(desc);\n }\n }\n }, {\n key: \"onSubsUpdated\",\n value: function onSubsUpdated() {\n var topic = this.props.tinode.getTopic(this.props.topic);\n\n if (!topic) {\n return;\n }\n\n this.resetSubs(topic, this.props);\n\n if (this.previousSubsUpdated && this.previousSubsUpdated != this.onSubsUpdated) {\n this.previousSubsUpdated();\n }\n }\n }, {\n key: \"onTagsUpdated\",\n value: function onTagsUpdated(tags) {\n this.setState({\n tags: tags\n });\n\n if (this.previousTagsUpdated && this.previousTagsUpdated != this.onTagsUpdated) {\n this.previousTagsUpdated();\n }\n }\n }, {\n key: \"handleFullNameUpdate\",\n value: function handleFullNameUpdate(fn) {\n if (this.state.fullName !== fn) {\n this.setState({\n fullName: fn\n });\n this.props.onTopicDescUpdate(this.props.topic, vcard(fn, this.state.avatar), null);\n }\n }\n }, {\n key: \"handlePrivateUpdate\",\n value: function handlePrivateUpdate(priv) {\n if (this.state.priv !== priv) {\n this.setState({\n private: priv\n });\n this.props.onTopicDescUpdate(this.props.topic, null, priv);\n }\n }\n }, {\n key: \"handleImageChanged\",\n value: function handleImageChanged(img) {\n this.setState({\n avatar: img\n });\n this.props.onTopicDescUpdate(this.props.topic, vcard(this.state.fullName, img), null);\n }\n }, {\n key: \"handleMuted\",\n value: function handleMuted(ignored, checked) {\n this.setState({\n muted: checked\n });\n this.props.onChangePermissions(this.props.topic, checked ? '-P' : '+P');\n }\n }, {\n key: \"handlePermissionsChanged\",\n value: function handlePermissionsChanged(perm) {\n switch (this.state.showPermissionEditorFor) {\n case 'auth':\n this.props.onTopicDescUpdate(this.props.topic, null, null, {\n auth: perm\n });\n break;\n\n case 'anon':\n this.props.onTopicDescUpdate(this.props.topic, null, null, {\n anon: perm\n });\n break;\n\n case 'mode':\n case 'want':\n this.props.onChangePermissions(this.props.topic, perm);\n break;\n\n case 'given':\n this.props.onChangePermissions(this.props.topic, perm, this.props.topic);\n break;\n\n case 'user':\n this.props.onChangePermissions(this.props.topic, perm, this.state.userPermissionsEdited);\n break;\n }\n\n this.setState({\n showPermissionEditorFor: undefined\n });\n }\n }, {\n key: \"handleLaunchPermissionsEditor\",\n value: function handleLaunchPermissionsEditor(which, uid) {\n var toEdit, toCompare, toSkip, titleEdit, titleCompare, userTitle, userAvatar;\n\n switch (which) {\n case 'mode':\n toEdit = this.state.access;\n break;\n\n case 'want':\n toEdit = this.state.modeWant;\n toCompare = this.state.modeGiven;\n toSkip = this.state.groupTopic ? 'O' : 'ASDO';\n titleEdit = \"Requested\";\n titleCompare = \"Granted\";\n break;\n\n case 'given':\n toEdit = this.state.modeGiven2;\n toCompare = this.state.modeWant2;\n toSkip = this.state.groupTopic ? this.state.owner ? '' : 'O' : 'ASDO';\n titleEdit = \"Granted\";\n titleCompare = \"Requested\";\n break;\n\n case 'auth':\n toEdit = this.state.auth;\n toSkip = 'O';\n break;\n\n case 'anon':\n toEdit = this.state.anon;\n toSkip = 'O';\n break;\n\n case 'user':\n {\n var topic = this.props.tinode.getTopic(this.props.topic);\n\n if (!topic) {\n return;\n }\n\n var user = topic.subscriber(uid);\n\n if (!user || !user.acs) {\n return;\n }\n\n toEdit = user.acs.getGiven();\n toCompare = user.acs.getWant();\n toSkip = this.state.owner ? '' : 'O';\n titleEdit = \"Granted\";\n titleCompare = \"Requested\";\n\n if (user.public) {\n userTitle = user.public.fn;\n userAvatar = user.public.photo;\n }\n\n break;\n }\n\n default:\n console.log(\"Unknown permission editing mode '\" + which + \"'\");\n break;\n }\n\n this.setState({\n showPermissionEditorFor: which,\n userPermissionsEdited: uid,\n userPermissionsTitle: userTitle,\n userPermissionsAvatar: userAvatar,\n editedPermissions: toEdit,\n immutablePermissions: toCompare,\n editedPermissionsTitle: titleEdit,\n immutablePermissionsTitle: titleCompare,\n editedPermissionsSkipped: toSkip\n });\n }\n }, {\n key: \"handleHidePermissionsEditor\",\n value: function handleHidePermissionsEditor() {\n this.setState({\n showPermissionEditorFor: undefined\n });\n }\n }, {\n key: \"handleShowAddMembers\",\n value: function handleShowAddMembers() {\n this.props.onInitFind();\n this.setState({\n showMemberPanel: true\n });\n }\n }, {\n key: \"handleHideAddMembers\",\n value: function handleHideAddMembers() {\n this.setState({\n showMemberPanel: false\n });\n }\n }, {\n key: \"handleMemberUpdateRequest\",\n value: function handleMemberUpdateRequest(members, added, removed) {\n this.props.onMemberUpdateRequest(this.props.topic, added, removed);\n this.setState({\n showMemberPanel: false\n });\n }\n }, {\n key: \"handleLeave\",\n value: function handleLeave() {\n this.props.onLeaveTopic(this.props.topic);\n }\n }, {\n key: \"handleMemberSelected\",\n value: function handleMemberSelected(uid) {\n this.setState({\n selectedContact: uid\n });\n }\n }, {\n key: \"handleMoreInfo\",\n value: function handleMoreInfo(open) {\n this.setState({\n moreInfoExpanded: open\n });\n }\n }, {\n key: \"handleTagsUpdated\",\n value: function handleTagsUpdated(tags) {\n if (!arrayEqual(this.state.tags.slice(0), tags.slice(0))) {\n this.props.onTopicTagsUpdate(this.props.topic, tags);\n }\n }\n }, {\n key: \"handleContextMenu\",\n value: function handleContextMenu(params) {\n var instance = this;\n var topic = this.props.tinode.getTopic(this.props.topic);\n\n if (!topic) {\n return;\n }\n\n var user = topic.subscriber(params.topicName);\n\n if (!user || !user.acs) {\n return;\n }\n\n var menuItems = [{\n title: \"Edit permissions\",\n handler: function handler() {\n instance.handleLaunchPermissionsEditor('user', params.topicName);\n }\n }, 'member_delete', user.acs.isMuted() ? 'member_unmute' : 'member_mute', user.acs.isJoiner() ? 'member_block' : 'member_unblock'];\n this.props.showContextMenu({\n topicName: this.props.topic,\n x: params.x,\n y: params.y,\n user: params.topicName\n }, menuItems);\n }\n }, {\n key: \"render\",\n value: function render() {\n return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n id: \"info-view\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"caption-panel\",\n id: \"info-caption-panel\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"panel-title\",\n id: \"info-title\"\n }, \"Info\"), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_widgets_menu_cancel_jsx__WEBPACK_IMPORTED_MODULE_6__[\"default\"], {\n onCancel: this.props.onCancel\n }))), this.props.displayMobile ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(ErrorPanel, {\n level: this.props.errorLevel,\n text: this.props.errorText,\n onClearError: this.props.onError\n }) : null, this.state.showMemberPanel ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_widgets_group_manager_jsx__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n members: this.state.contactList,\n requiredMember: this.props.myUserId,\n myUserId: this.props.myUserId,\n contacts: this.props.searchableContacts,\n onCancel: this.handleHideAddMembers,\n onSubmit: this.handleMemberUpdateRequest\n }) : this.state.showPermissionEditorFor ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_widgets_permissions_editor_jsx__WEBPACK_IMPORTED_MODULE_8__[\"default\"], {\n mode: this.state.editedPermissions,\n compare: this.state.immutablePermissions,\n skip: this.state.editedPermissionsSkipped,\n modeTitle: this.state.editedPermissionsTitle,\n compareTitle: this.state.immutablePermissionsTitle,\n userTitle: this.state.userPermissionsTitle,\n item: this.state.userPermissionsEdited,\n userAvatar: this.state.userPermissionsAvatar,\n onSubmit: this.handlePermissionsChanged,\n onCancel: this.handleHidePermissionsEditor\n }) : react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n id: \"info-view-content\",\n className: \"scrollable-panel\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"panel-form-row\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"panel-form-column\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n className: \"small\"\n }, \"Name\")), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_widgets_in_place_edit_jsx__WEBPACK_IMPORTED_MODULE_5__[\"default\"], {\n placeholder: this.state.groupTopic ? \"Group name\" : react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"i\", null, \"Unknown\"),\n readOnly: !this.state.owner,\n value: this.state.fullName,\n onFinished: this.handleFullNameUpdate\n })), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n className: \"small\"\n }, \"Private comment\")), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_widgets_in_place_edit_jsx__WEBPACK_IMPORTED_MODULE_5__[\"default\"], {\n placeholder: \"Visible to you only\",\n value: this.state.private,\n onFinished: this.handlePrivateUpdate\n }))), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_widgets_avatar_upload_jsx__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n avatar: this.state.avatar,\n readOnly: !this.state.owner,\n uid: this.props.topic,\n title: this.state.fullName,\n onImageChanged: this.handleImageChanged,\n onError: this.props.onError\n })), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"hr\"\n }), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"panel-form-column\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"panel-form-row\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", null, \"Muted:\"), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_widgets_checkbox_jsx__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n name: \"P\",\n checked: this.state.muted,\n onChange: this.handleMuted\n })), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_widgets_more_button_jsx__WEBPACK_IMPORTED_MODULE_7__[\"default\"], {\n title: \"More\",\n open: this.state.moreInfoExpanded,\n onToggle: this.handleMoreInfo\n }), this.state.moreInfoExpanded ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"panel-form-column\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"panel-form-row\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", null, \"Address:\"), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"tt\", null, this.state.address)), this.state.groupTopic ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"panel-form-row\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", null, \"Your permissions:\"), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"tt\", {\n className: \"clickable\",\n onClick: this.handleLaunchPermissionsEditor.bind(this, 'want')\n }, this.state.access)) : react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n className: \"small\"\n }, \"Permissions:\")), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"quoted\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, \"Yours: \\xA0\", react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"tt\", {\n className: \"clickable\",\n onClick: this.handleLaunchPermissionsEditor.bind(this, 'want')\n }, this.state.access)), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, this.state.fullName ? this.state.fullName : \"Other\", \"\\u2032s: \\xA0\", react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"tt\", {\n className: \"clickable\",\n onClick: this.handleLaunchPermissionsEditor.bind(this, 'given')\n }, this.state.modeGiven2)))), this.state.sharer && (this.state.auth || this.state.anon) ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n className: \"small\"\n }, \"Default access mode:\")), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"quoted\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, \"Auth: \", this.state.admin ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"tt\", {\n className: \"clickable\",\n onClick: this.handleLaunchPermissionsEditor.bind(this, 'auth')\n }, this.state.auth) : react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"tt\", null, this.state.auth)), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, \"Anon: \", this.state.admin ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"tt\", {\n className: \"clickable\",\n onClick: this.handleLaunchPermissionsEditor.bind(this, 'anon')\n }, this.state.anon) : react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"tt\", null, this.state.anon)))) : null) : null), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"hr\"\n }), this.state.owner ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_widgets_tag_manager_jsx__WEBPACK_IMPORTED_MODULE_9__[\"default\"], {\n title: \"Tags\",\n tags: this.state.tags,\n activated: false,\n onSubmit: this.handleTagsUpdated\n }) : null, this.state.owner ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"hr\"\n }) : null, this.state.groupTopic ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"panel-form-column\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"panel-form-row\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n className: \"small\"\n }, \"Group members:\")), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"panel-form-row\"\n }, this.state.sharer ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"a\", {\n href: \"javascript:;\",\n className: \"flat-button\",\n onClick: this.handleShowAddMembers\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"i\", {\n className: \"material-icons\"\n }, \"person_add\"), \" Add members\") : null, !this.state.owner ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"a\", {\n href: \"javascript:;\",\n className: \"red flat-button\",\n onClick: this.handleLeave\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"i\", {\n className: \"material-icons\"\n }, \"exit_to_app\"), \" Leave\") : null), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_widgets_contact_list_jsx__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n contacts: this.state.contactList,\n myUserId: this.props.myUserId,\n emptyListMessage: \"No members\",\n topicSelected: this.state.selectedContact,\n showOnline: false,\n showUnread: false,\n showMode: true,\n noScroll: true,\n onTopicSelected: this.handleMemberSelected,\n showContextMenu: this.state.admin ? this.handleContextMenu : false\n })) : react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"panel-form-row\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"a\", {\n href: \"javascript:;\",\n className: \"red flat-button\",\n onClick: this.handleLeave\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"i\", {\n className: \"material-icons\"\n }, \"exit_to_app\"), \" Leave\"))));\n }\n }]);\n\n return InfoView;\n}(react__WEBPACK_IMPORTED_MODULE_0___default.a.Component);\n\n\n;\n\n//# sourceURL=webpack:///./src/views/info-view.jsx?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var react_intl__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-intl */ \"./node_modules/react-intl/lib/index.es.js\");\n/* harmony import */ var _widgets_avatar_upload_jsx__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../widgets/avatar-upload.jsx */ \"./src/widgets/avatar-upload.jsx\");\n/* harmony import */ var _widgets_checkbox_jsx__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../widgets/checkbox.jsx */ \"./src/widgets/checkbox.jsx\");\n/* harmony import */ var _widgets_contact_list_jsx__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../widgets/contact-list.jsx */ \"./src/widgets/contact-list.jsx\");\n/* harmony import */ var _widgets_group_manager_jsx__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../widgets/group-manager.jsx */ \"./src/widgets/group-manager.jsx\");\n/* harmony import */ var _widgets_in_place_edit_jsx__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../widgets/in-place-edit.jsx */ \"./src/widgets/in-place-edit.jsx\");\n/* harmony import */ var _widgets_menu_cancel_jsx__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../widgets/menu-cancel.jsx */ \"./src/widgets/menu-cancel.jsx\");\n/* harmony import */ var _widgets_more_button_jsx__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../widgets/more-button.jsx */ \"./src/widgets/more-button.jsx\");\n/* harmony import */ var _widgets_permissions_editor_jsx__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../widgets/permissions-editor.jsx */ \"./src/widgets/permissions-editor.jsx\");\n/* harmony import */ var _widgets_tag_manager_jsx__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../widgets/tag-manager.jsx */ \"./src/widgets/tag-manager.jsx\");\n/* harmony import */ var _lib_blob_helpers_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../lib/blob-helpers.js */ \"./src/lib/blob-helpers.js\");\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _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); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar messages = Object(react_intl__WEBPACK_IMPORTED_MODULE_1__[\"defineMessages\"])({\n requested: {\n \"id\": \"requested_permissions\",\n \"defaultMessage\": \"Requested\"\n },\n granted: {\n \"id\": \"granted_permissions\",\n \"defaultMessage\": \"Granted\"\n },\n edit_permissions: {\n \"id\": \"menu_item_edit_permissions\",\n \"defaultMessage\": \"Edit permissions\"\n },\n other_user: {\n \"id\": \"label_other_user\",\n \"defaultMessage\": \"Other\"\n }\n});\n\nvar InfoView = function (_React$Component) {\n _inherits(InfoView, _React$Component);\n\n function InfoView(props) {\n var _this;\n\n _classCallCheck(this, InfoView);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(InfoView).call(this, props));\n _this.state = {\n topic: null,\n owner: false,\n admin: false,\n sharer: false,\n muted: false,\n address: null,\n groupTopic: undefined,\n fullName: undefined,\n avatar: null,\n private: null,\n selectedContact: null,\n access: null,\n modeGiven: null,\n modeWant: null,\n modeGiven2: null,\n modeWant2: null,\n auth: null,\n anon: null,\n contactList: [],\n tags: [],\n showMemberPanel: false,\n showPermissionEditorFor: undefined,\n moreInfoExpanded: false,\n previousMetaDesc: undefined,\n previousSubsUpdated: undefined,\n previousTagsUpdated: undefined\n };\n _this.resetSubs = _this.resetSubs.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.resetDesc = _this.resetDesc.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.onMetaDesc = _this.onMetaDesc.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.onSubsUpdated = _this.onSubsUpdated.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.onTagsUpdated = _this.onTagsUpdated.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleFullNameUpdate = _this.handleFullNameUpdate.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handlePrivateUpdate = _this.handlePrivateUpdate.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleImageChanged = _this.handleImageChanged.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleMuted = _this.handleMuted.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handlePermissionsChanged = _this.handlePermissionsChanged.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleLaunchPermissionsEditor = _this.handleLaunchPermissionsEditor.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleHidePermissionsEditor = _this.handleHidePermissionsEditor.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleShowAddMembers = _this.handleShowAddMembers.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleHideAddMembers = _this.handleHideAddMembers.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleMemberUpdateRequest = _this.handleMemberUpdateRequest.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleLeave = _this.handleLeave.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleMemberSelected = _this.handleMemberSelected.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleMoreInfo = _this.handleMoreInfo.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleTagsUpdated = _this.handleTagsUpdated.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleContextMenu = _this.handleContextMenu.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n return _this;\n }\n\n _createClass(InfoView, [{\n key: \"UNSAFE_componentWillReceiveProps\",\n value: function UNSAFE_componentWillReceiveProps(props) {\n var topic = this.props.tinode.getTopic(props.topic);\n\n if (!topic) {\n return;\n }\n\n if (this.onMetaDesc != topic.onMetaDesc) {\n this.previousMetaDesc = topic.onMetaDesc;\n topic.onMetaDesc = this.onMetaDesc;\n this.previousSubsUpdated = topic.onSubsUpdated;\n topic.onSubsUpdated = this.onSubsUpdated;\n\n if (topic.getType() == 'grp') {\n this.previousTagsUpdated = topic.onTagsUpdated;\n topic.onTagsUpdated = this.onTagsUpdated;\n } else {\n this.previousTagsUpdated = undefined;\n }\n }\n\n if (this.state.topic != props.topic) {\n this.setState({\n topic: props.topic\n });\n this.resetDesc(topic, props);\n this.resetSubs(topic, props);\n }\n }\n }, {\n key: \"componentWillUnmount\",\n value: function componentWillUnmount() {\n var topic = this.props.tinode.getTopic(this.props.topic);\n\n if (!topic) {\n return;\n }\n\n this.setState({\n topic: null\n });\n topic.onMetaDesc = this.previousMetaDesc;\n topic.onSubsUpdated = this.previousSubsUpdated;\n topic.onTagsUpdated = this.previousTagsUpdated;\n }\n }, {\n key: \"resetSubs\",\n value: function resetSubs(topic, props) {\n var newState = {\n contactList: []\n };\n\n if (topic.getType() == 'p2p') {\n var user2 = topic.subscriber(props.topic);\n\n if (user2) {\n newState.modeGiven2 = user2.acs.getGiven();\n newState.modeWant2 = user2.acs.getWant();\n }\n } else {\n topic.subscribers(function (sub) {\n newState.contactList.push(sub);\n }, this);\n }\n\n this.setState(newState);\n }\n }, {\n key: \"resetDesc\",\n value: function resetDesc(topic, props) {\n var defacs = topic.getDefaultAccess() || {};\n var acs = topic.getAccessMode();\n this.setState({\n owner: acs && acs.isOwner(),\n admin: acs && acs.isAdmin(),\n sharer: acs && (acs.isAdmin() || acs.isSharer()),\n muted: acs && acs.isMuted(),\n fullName: topic.public ? topic.public.fn : undefined,\n avatar: Object(_lib_blob_helpers_js__WEBPACK_IMPORTED_MODULE_11__[\"makeImageUrl\"])(topic.public ? topic.public.photo : null),\n private: topic.private ? topic.private.comment : null,\n address: topic.name,\n groupTopic: topic.getType() == 'grp',\n showMemberPanel: false,\n access: acs ? acs.getMode() : undefined,\n modeGiven: acs ? acs.getGiven() : undefined,\n modeWant: acs ? acs.getWant() : undefined,\n auth: defacs.auth,\n anon: defacs.anon\n });\n\n if (topic.getType() == 'grp' && acs && acs.isOwner()) {\n topic.getMeta(topic.startMetaQuery().withTags().build());\n }\n }\n }, {\n key: \"onMetaDesc\",\n value: function onMetaDesc(desc) {\n var topic = this.props.tinode.getTopic(this.props.topic);\n\n if (!topic) {\n return;\n }\n\n this.resetDesc(topic, this.props);\n\n if (this.previousMetaDesc && this.previousMetaDesc != this.onMetaDesc) {\n this.previousMetaDesc(desc);\n }\n }\n }, {\n key: \"onSubsUpdated\",\n value: function onSubsUpdated() {\n var topic = this.props.tinode.getTopic(this.props.topic);\n\n if (!topic) {\n return;\n }\n\n this.resetSubs(topic, this.props);\n\n if (this.previousSubsUpdated && this.previousSubsUpdated != this.onSubsUpdated) {\n this.previousSubsUpdated();\n }\n }\n }, {\n key: \"onTagsUpdated\",\n value: function onTagsUpdated(tags) {\n this.setState({\n tags: tags\n });\n\n if (this.previousTagsUpdated && this.previousTagsUpdated != this.onTagsUpdated) {\n this.previousTagsUpdated();\n }\n }\n }, {\n key: \"handleFullNameUpdate\",\n value: function handleFullNameUpdate(fn) {\n if (this.state.fullName !== fn) {\n this.setState({\n fullName: fn\n });\n this.props.onTopicDescUpdate(this.props.topic, vcard(fn, this.state.avatar), null);\n }\n }\n }, {\n key: \"handlePrivateUpdate\",\n value: function handlePrivateUpdate(priv) {\n if (this.state.priv !== priv) {\n this.setState({\n private: priv\n });\n this.props.onTopicDescUpdate(this.props.topic, null, priv);\n }\n }\n }, {\n key: \"handleImageChanged\",\n value: function handleImageChanged(img) {\n this.setState({\n avatar: img\n });\n this.props.onTopicDescUpdate(this.props.topic, vcard(this.state.fullName, img), null);\n }\n }, {\n key: \"handleMuted\",\n value: function handleMuted(ignored, checked) {\n this.setState({\n muted: checked\n });\n this.props.onChangePermissions(this.props.topic, checked ? '-P' : '+P');\n }\n }, {\n key: \"handlePermissionsChanged\",\n value: function handlePermissionsChanged(perm) {\n switch (this.state.showPermissionEditorFor) {\n case 'auth':\n this.props.onTopicDescUpdate(this.props.topic, null, null, {\n auth: perm\n });\n break;\n\n case 'anon':\n this.props.onTopicDescUpdate(this.props.topic, null, null, {\n anon: perm\n });\n break;\n\n case 'mode':\n case 'want':\n this.props.onChangePermissions(this.props.topic, perm);\n break;\n\n case 'given':\n this.props.onChangePermissions(this.props.topic, perm, this.props.topic);\n break;\n\n case 'user':\n this.props.onChangePermissions(this.props.topic, perm, this.state.userPermissionsEdited);\n break;\n }\n\n this.setState({\n showPermissionEditorFor: undefined\n });\n }\n }, {\n key: \"handleLaunchPermissionsEditor\",\n value: function handleLaunchPermissionsEditor(which, uid) {\n var formatMessage = this.props.intl.formatMessage;\n var toEdit, toCompare, toSkip, titleEdit, titleCompare, userTitle, userAvatar;\n\n switch (which) {\n case 'mode':\n toEdit = this.state.access;\n break;\n\n case 'want':\n toEdit = this.state.modeWant;\n toCompare = this.state.modeGiven;\n toSkip = this.state.groupTopic ? 'O' : 'ASDO';\n titleEdit = formatMessage(messages.requested);\n titleCompare = formatMessage(messages.granted);\n break;\n\n case 'given':\n toEdit = this.state.modeGiven2;\n toCompare = this.state.modeWant2;\n toSkip = this.state.groupTopic ? this.state.owner ? '' : 'O' : 'ASDO';\n titleEdit = formatMessage(messages.granted);\n titleCompare = formatMessage(messages.requested);\n break;\n\n case 'auth':\n toEdit = this.state.auth;\n toSkip = 'O';\n break;\n\n case 'anon':\n toEdit = this.state.anon;\n toSkip = 'O';\n break;\n\n case 'user':\n {\n var topic = this.props.tinode.getTopic(this.props.topic);\n\n if (!topic) {\n return;\n }\n\n var user = topic.subscriber(uid);\n\n if (!user || !user.acs) {\n return;\n }\n\n toEdit = user.acs.getGiven();\n toCompare = user.acs.getWant();\n toSkip = this.state.owner ? '' : 'O';\n titleEdit = formatMessage(messages.granted);\n titleCompare = formatMessage(messages.requested);\n\n if (user.public) {\n userTitle = user.public.fn;\n userAvatar = user.public.photo;\n }\n\n break;\n }\n\n default:\n console.log(\"Unknown permission editing mode '\" + which + \"'\");\n break;\n }\n\n this.setState({\n showPermissionEditorFor: which,\n userPermissionsEdited: uid,\n userPermissionsTitle: userTitle,\n userPermissionsAvatar: userAvatar,\n editedPermissions: toEdit,\n immutablePermissions: toCompare,\n editedPermissionsTitle: titleEdit,\n immutablePermissionsTitle: titleCompare,\n editedPermissionsSkipped: toSkip\n });\n }\n }, {\n key: \"handleHidePermissionsEditor\",\n value: function handleHidePermissionsEditor() {\n this.setState({\n showPermissionEditorFor: undefined\n });\n }\n }, {\n key: \"handleShowAddMembers\",\n value: function handleShowAddMembers() {\n this.props.onInitFind();\n this.setState({\n showMemberPanel: true\n });\n }\n }, {\n key: \"handleHideAddMembers\",\n value: function handleHideAddMembers() {\n this.setState({\n showMemberPanel: false\n });\n }\n }, {\n key: \"handleMemberUpdateRequest\",\n value: function handleMemberUpdateRequest(members, added, removed) {\n this.props.onMemberUpdateRequest(this.props.topic, added, removed);\n this.setState({\n showMemberPanel: false\n });\n }\n }, {\n key: \"handleLeave\",\n value: function handleLeave() {\n this.props.onLeaveTopic(this.props.topic);\n }\n }, {\n key: \"handleMemberSelected\",\n value: function handleMemberSelected(uid) {\n this.setState({\n selectedContact: uid\n });\n }\n }, {\n key: \"handleMoreInfo\",\n value: function handleMoreInfo(open) {\n this.setState({\n moreInfoExpanded: open\n });\n }\n }, {\n key: \"handleTagsUpdated\",\n value: function handleTagsUpdated(tags) {\n if (!arrayEqual(this.state.tags.slice(0), tags.slice(0))) {\n this.props.onTopicTagsUpdate(this.props.topic, tags);\n }\n }\n }, {\n key: \"handleContextMenu\",\n value: function handleContextMenu(params) {\n var formatMessage = this.props.intl.formatMessage;\n var instance = this;\n var topic = this.props.tinode.getTopic(this.props.topic);\n\n if (!topic) {\n return;\n }\n\n var user = topic.subscriber(params.topicName);\n\n if (!user || !user.acs) {\n return;\n }\n\n var menuItems = [{\n title: formatMessage(messages.edit_permissions),\n handler: function handler() {\n instance.handleLaunchPermissionsEditor('user', params.topicName);\n }\n }, 'member_delete', user.acs.isMuted() ? 'member_unmute' : 'member_mute', user.acs.isJoiner() ? 'member_block' : 'member_unblock'];\n this.props.showContextMenu({\n topicName: this.props.topic,\n x: params.x,\n y: params.y,\n user: params.topicName\n }, menuItems);\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this2 = this;\n\n var formatMessage = this.props.intl.formatMessage;\n return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n id: \"info-view\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"caption-panel\",\n id: \"info-caption-panel\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"panel-title\",\n id: \"info-title\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_intl__WEBPACK_IMPORTED_MODULE_1__[\"FormattedMessage\"], {\n id: \"title_info\",\n defaultMessage: \"Info\"\n })), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_widgets_menu_cancel_jsx__WEBPACK_IMPORTED_MODULE_7__[\"default\"], {\n onCancel: this.props.onCancel\n }))), this.props.displayMobile ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(ErrorPanel, {\n level: this.props.errorLevel,\n text: this.props.errorText,\n onClearError: this.props.onError\n }) : null, this.state.showMemberPanel ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_widgets_group_manager_jsx__WEBPACK_IMPORTED_MODULE_5__[\"default\"], {\n members: this.state.contactList,\n requiredMember: this.props.myUserId,\n myUserId: this.props.myUserId,\n contacts: this.props.searchableContacts,\n onCancel: this.handleHideAddMembers,\n onSubmit: this.handleMemberUpdateRequest\n }) : this.state.showPermissionEditorFor ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_widgets_permissions_editor_jsx__WEBPACK_IMPORTED_MODULE_9__[\"default\"], {\n mode: this.state.editedPermissions,\n compare: this.state.immutablePermissions,\n skip: this.state.editedPermissionsSkipped,\n modeTitle: this.state.editedPermissionsTitle,\n compareTitle: this.state.immutablePermissionsTitle,\n userTitle: this.state.userPermissionsTitle,\n item: this.state.userPermissionsEdited,\n userAvatar: this.state.userPermissionsAvatar,\n onSubmit: this.handlePermissionsChanged,\n onCancel: this.handleHidePermissionsEditor\n }) : react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n id: \"info-view-content\",\n className: \"scrollable-panel\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"panel-form-row\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"panel-form-column\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n className: \"small\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_intl__WEBPACK_IMPORTED_MODULE_1__[\"FormattedMessage\"], {\n id: \"label_topic_name\",\n defaultMessage: \"Name\"\n }))), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_widgets_in_place_edit_jsx__WEBPACK_IMPORTED_MODULE_6__[\"default\"], {\n placeholder: this.state.groupTopic ? \"Group name\" : react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"i\", null, \"Unknown\"),\n readOnly: !this.state.owner,\n value: this.state.fullName,\n onFinished: this.handleFullNameUpdate\n })), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n className: \"small\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_intl__WEBPACK_IMPORTED_MODULE_1__[\"FormattedMessage\"], {\n id: \"label_private\",\n defaultMessage: \"Private comment\"\n }))), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_intl__WEBPACK_IMPORTED_MODULE_1__[\"FormattedMessage\"], {\n id: \"private_editing_placeholder\",\n defaultMessage: \"Visible to you only\"\n }, function (private_placeholder) {\n return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_widgets_in_place_edit_jsx__WEBPACK_IMPORTED_MODULE_6__[\"default\"], {\n placeholder: private_placeholder,\n value: _this2.state.private,\n onFinished: _this2.handlePrivateUpdate\n });\n }))), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_widgets_avatar_upload_jsx__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n avatar: this.state.avatar,\n readOnly: !this.state.owner,\n uid: this.props.topic,\n title: this.state.fullName,\n onImageChanged: this.handleImageChanged,\n onError: this.props.onError\n })), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"hr\"\n }), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"panel-form-column\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"panel-form-row\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_intl__WEBPACK_IMPORTED_MODULE_1__[\"FormattedMessage\"], {\n id: \"label_muting_topic\",\n defaultMessage: \"Muted:\"\n })), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_widgets_checkbox_jsx__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n name: \"P\",\n checked: this.state.muted,\n onChange: this.handleMuted\n })), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_intl__WEBPACK_IMPORTED_MODULE_1__[\"FormattedMessage\"], {\n id: \"action_more\",\n defaultMessage: \"More\"\n }, function (more) {\n return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_widgets_more_button_jsx__WEBPACK_IMPORTED_MODULE_8__[\"default\"], {\n title: more,\n open: _this2.state.moreInfoExpanded,\n onToggle: _this2.handleMoreInfo\n });\n }), this.state.moreInfoExpanded ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"panel-form-column\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"panel-form-row\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_intl__WEBPACK_IMPORTED_MODULE_1__[\"FormattedMessage\"], {\n id: \"label_user_id\"\n })), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"tt\", null, this.state.address)), this.state.groupTopic ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"panel-form-row\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_intl__WEBPACK_IMPORTED_MODULE_1__[\"FormattedMessage\"], {\n id: \"label_your_permissions\",\n defaultMessage: \"Your permissions:\"\n })), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"tt\", {\n className: \"clickable\",\n onClick: this.handleLaunchPermissionsEditor.bind(this, 'want')\n }, this.state.access)) : react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n className: \"small\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_intl__WEBPACK_IMPORTED_MODULE_1__[\"FormattedMessage\"], {\n id: \"label_permissions\",\n defaultMessage: \"Permissions:\"\n }))), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"quoted\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_intl__WEBPACK_IMPORTED_MODULE_1__[\"FormattedMessage\"], {\n id: \"label_you\",\n defaultMessage: \"You:\"\n }), \" \\xA0\", react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"tt\", {\n className: \"clickable\",\n onClick: this.handleLaunchPermissionsEditor.bind(this, 'want')\n }, this.state.access)), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, this.state.fullName ? this.state.fullName : formatMessage(messages.other_user), \": \\xA0\", react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"tt\", {\n className: \"clickable\",\n onClick: this.handleLaunchPermissionsEditor.bind(this, 'given')\n }, this.state.modeGiven2)))), this.state.sharer && (this.state.auth || this.state.anon) ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n className: \"small\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_intl__WEBPACK_IMPORTED_MODULE_1__[\"FormattedMessage\"], {\n id: \"label_default_access\",\n defaultMessage: \"Default access mode:\"\n }))), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"quoted\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, \"Auth: \", this.state.admin ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"tt\", {\n className: \"clickable\",\n onClick: this.handleLaunchPermissionsEditor.bind(this, 'auth')\n }, this.state.auth) : react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"tt\", null, this.state.auth)), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, \"Anon: \", this.state.admin ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"tt\", {\n className: \"clickable\",\n onClick: this.handleLaunchPermissionsEditor.bind(this, 'anon')\n }, this.state.anon) : react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"tt\", null, this.state.anon)))) : null) : null), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"hr\"\n }), this.state.owner ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_intl__WEBPACK_IMPORTED_MODULE_1__[\"FormattedMessage\"], {\n id: \"title_tag_manager\"\n }, function (tags) {\n return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_widgets_tag_manager_jsx__WEBPACK_IMPORTED_MODULE_10__[\"default\"], {\n title: tags,\n tags: _this2.state.tags,\n activated: false,\n onSubmit: _this2.handleTagsUpdated\n });\n }) : null, this.state.owner ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"hr\"\n }) : null, this.state.groupTopic ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"panel-form-column\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"panel-form-row\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n className: \"small\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_intl__WEBPACK_IMPORTED_MODULE_1__[\"FormattedMessage\"], {\n id: \"label_group_members\",\n defaultMessage: \"Group members:\"\n }))), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"panel-form-row\"\n }, this.state.sharer ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"a\", {\n href: \"javascript:;\",\n className: \"flat-button\",\n onClick: this.handleShowAddMembers\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"i\", {\n className: \"material-icons\"\n }, \"person_add\"), \" \", react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_intl__WEBPACK_IMPORTED_MODULE_1__[\"FormattedMessage\"], {\n id: \"button_add_members\",\n defaultMessage: \"Add members\"\n })) : null, !this.state.owner ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"a\", {\n href: \"javascript:;\",\n className: \"red flat-button\",\n onClick: this.handleLeave\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"i\", {\n className: \"material-icons\"\n }, \"exit_to_app\"), \" \", react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_intl__WEBPACK_IMPORTED_MODULE_1__[\"FormattedMessage\"], {\n id: \"button_leave\",\n defaultMessage: \"Leave\"\n })) : null), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_intl__WEBPACK_IMPORTED_MODULE_1__[\"FormattedMessage\"], {\n id: \"group_has_no_members\",\n defaultMessage: \"No members\"\n }, function (no_members) {\n return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_widgets_contact_list_jsx__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n contacts: _this2.state.contactList,\n myUserId: _this2.props.myUserId,\n emptyListMessage: no_members,\n topicSelected: _this2.state.selectedContact,\n showOnline: false,\n showUnread: false,\n showMode: true,\n noScroll: true,\n onTopicSelected: _this2.handleMemberSelected,\n showContextMenu: _this2.state.admin ? _this2.handleContextMenu : false\n });\n })) : react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"panel-form-row\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"a\", {\n href: \"javascript:;\",\n className: \"red flat-button\",\n onClick: this.handleLeave\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"i\", {\n className: \"material-icons\"\n }, \"exit_to_app\"), \" \", react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_intl__WEBPACK_IMPORTED_MODULE_1__[\"FormattedMessage\"], {\n id: \"action_leave_chat\",\n defaultMessage: \"Leave\"\n })))));\n }\n }]);\n\n return InfoView;\n}(react__WEBPACK_IMPORTED_MODULE_0___default.a.Component);\n\n;\n/* harmony default export */ __webpack_exports__[\"default\"] = (Object(react_intl__WEBPACK_IMPORTED_MODULE_1__[\"injectIntl\"])(InfoView));\n\n//# sourceURL=webpack:///./src/views/info-view.jsx?"); /***/ }), @@ -923,7 +923,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var reac /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return TinodeWeb; });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ \"./node_modules/react-dom/index.js\");\n/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/index.cjs.js\");\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(firebase_app__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var firebase_messaging__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! firebase/messaging */ \"./node_modules/firebase/messaging/dist/index.esm.js\");\n/* harmony import */ var tinode_sdk__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! tinode-sdk */ \"./node_modules/tinode-sdk/umd/tinode.prod.js\");\n/* harmony import */ var tinode_sdk__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(tinode_sdk__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var _widgets_context_menu_jsx__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../widgets/context-menu.jsx */ \"./src/widgets/context-menu.jsx\");\n/* harmony import */ var _info_view_jsx__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./info-view.jsx */ \"./src/views/info-view.jsx\");\n/* harmony import */ var _messages_view_jsx__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./messages-view.jsx */ \"./src/views/messages-view.jsx\");\n/* harmony import */ var _sidepanel_view_jsx__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./sidepanel-view.jsx */ \"./src/views/sidepanel-view.jsx\");\n/* harmony import */ var _config_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../config.js */ \"./src/config.js\");\n/* harmony import */ var _lib_blob_helpers_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../lib/blob-helpers.js */ \"./src/lib/blob-helpers.js\");\n/* harmony import */ var _lib_host_name_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../lib/host-name.js */ \"./src/lib/host-name.js\");\n/* harmony import */ var _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../lib/local-storage.js */ \"./src/lib/local-storage.js\");\n/* harmony import */ var _lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../lib/navigation.js */ \"./src/lib/navigation.js\");\n/* harmony import */ var _lib_utils_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../lib/utils.js */ \"./src/lib/utils.js\");\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _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; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _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); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar POP_SOUND = new Audio('audio/msg.mp3');\n\nvar TinodeWeb = function (_React$Component) {\n _inherits(TinodeWeb, _React$Component);\n\n function TinodeWeb(props) {\n var _this;\n\n _classCallCheck(this, TinodeWeb);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(TinodeWeb).call(this, props));\n _this.state = _this.getBlankState();\n _this.handleResize = _this.handleResize.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleHashRoute = _this.handleHashRoute.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleOnline = _this.handleOnline.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleAppVisibility = _this.handleAppVisibility.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleReadTimer = _this.handleReadTimer.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleVisibilityEvent = _this.handleVisibilityEvent.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleError = _this.handleError.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleLoginRequest = _this.handleLoginRequest.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleConnected = _this.handleConnected.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.doLogin = _this.doLogin.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleCredentialsRequest = _this.handleCredentialsRequest.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleLoginSuccessful = _this.handleLoginSuccessful.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleDisconnect = _this.handleDisconnect.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.tnMeMetaDesc = _this.tnMeMetaDesc.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.tnMeContactUpdate = _this.tnMeContactUpdate.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.tnMeSubsUpdated = _this.tnMeSubsUpdated.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.resetContactList = _this.resetContactList.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.tnData = _this.tnData.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.tnInitFind = _this.tnInitFind.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.tnFndSubsUpdated = _this.tnFndSubsUpdated.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleSearchContacts = _this.handleSearchContacts.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleTopicSelected = _this.handleTopicSelected.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleHideMessagesView = _this.handleHideMessagesView.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleSendMessage = _this.handleSendMessage.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleNewAccount = _this.handleNewAccount.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleNewAccountRequest = _this.handleNewAccountRequest.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleUpdateAccountRequest = _this.handleUpdateAccountRequest.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleUpdateAccountTagsRequest = _this.handleUpdateAccountTagsRequest.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleSettings = _this.handleSettings.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleGlobalSettings = _this.handleGlobalSettings.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleToggleMessageSounds = _this.handleToggleMessageSounds.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.initDesktopAlerts = _this.initDesktopAlerts.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.togglePushToken = _this.togglePushToken.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.requestPushToken = _this.requestPushToken.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleSidepanelCancel = _this.handleSidepanelCancel.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleNewTopic = _this.handleNewTopic.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleNewTopicRequest = _this.handleNewTopicRequest.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleNewTopicCreated = _this.handleNewTopicCreated.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleTopicUpdateRequest = _this.handleTopicUpdateRequest.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleChangePermissions = _this.handleChangePermissions.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleTagsUpdated = _this.handleTagsUpdated.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleLogout = _this.handleLogout.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleLeaveUnsubRequest = _this.handleLeaveUnsubRequest.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleDialogCancel = _this.handleDialogCancel.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleShowContextMenu = _this.handleShowContextMenu.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.defaultTopicContextMenu = _this.defaultTopicContextMenu.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleHideContextMenu = _this.handleHideContextMenu.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleShowInfoView = _this.handleShowInfoView.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleHideInfoView = _this.handleHideInfoView.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleMemberUpdateRequest = _this.handleMemberUpdateRequest.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleValidateCredentialsRequest = _this.handleValidateCredentialsRequest.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handlePasswordResetRequest = _this.handlePasswordResetRequest.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleResetPassword = _this.handleResetPassword.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n return _this;\n }\n\n _createClass(TinodeWeb, [{\n key: \"getBlankState\",\n value: function getBlankState() {\n var _ref;\n\n var settings = _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].getObject(\"settings\") || {};\n return _ref = {\n connected: false,\n transport: settings.transport || null,\n serverAddress: settings.serverAddress || detectServerAddress(),\n serverVersion: \"no connection\",\n messageSounds: !settings.messageSoundsOff,\n desktopAlerts: settings.desktopAlerts,\n desktopAlertsEnabled: (Object(_lib_host_name_js__WEBPACK_IMPORTED_MODULE_11__[\"isSecureConnection\"])() || Object(_lib_host_name_js__WEBPACK_IMPORTED_MODULE_11__[\"isLocalHost\"])()) && typeof firebase != 'undefined' && typeof navigator != 'undefined' && typeof FIREBASE_INIT != 'undefined',\n firebaseToken: _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].getObject(\"firebase-token\"),\n errorText: '',\n errorLevel: null,\n sidePanelSelected: 'login',\n sidePanelTitle: null,\n sidePanelAvatar: null,\n dialogSelected: null,\n contextMenuVisible: false,\n login: '',\n password: '',\n myUserId: null,\n liveConnection: navigator.onLine,\n topicSelected: '',\n topicSelectedOnline: false,\n topicSelectedAcs: null,\n newGroupTopicParams: null,\n loginDisabled: false,\n displayMobile: window.innerWidth <= _config_js__WEBPACK_IMPORTED_MODULE_9__[\"MEDIA_BREAKPOINT\"],\n showInfoPanel: false,\n mobilePanel: 'sidepanel'\n }, _defineProperty(_ref, \"contextMenuVisible\", false), _defineProperty(_ref, \"contextMenuBounds\", null), _defineProperty(_ref, \"contextMenuClickAt\", null), _defineProperty(_ref, \"contextMenuParams\", null), _defineProperty(_ref, \"contextMenuItems\", []), _defineProperty(_ref, \"chatList\", []), _defineProperty(_ref, \"searchResults\", []), _defineProperty(_ref, \"searchableContacts\", []), _defineProperty(_ref, \"credMethod\", undefined), _defineProperty(_ref, \"credCode\", undefined), _ref;\n }\n }, {\n key: \"componentDidMount\",\n value: function componentDidMount() {\n var _this2 = this;\n\n window.addEventListener('resize', this.handleResize);\n window.addEventListener('online', function (e) {\n _this2.handleOnline(true);\n });\n window.addEventListener('offline', function (e) {\n _this2.handleOnline(false);\n });\n window.addEventListener('hashchange', this.handleHashRoute);\n document.addEventListener('visibilitychange', this.handleVisibilityEvent);\n this.setState({\n viewportWidth: document.documentElement.clientWidth\n });\n this.tinode = TinodeWeb.tnSetup(this.state.serverAddress, this.state.transport);\n this.tinode.onConnect = this.handleConnected;\n this.tinode.onDisconnect = this.handleDisconnect;\n\n if (this.state.desktopAlertsEnabled) {\n try {\n this.fbPush = firebase.initializeApp(FIREBASE_INIT, _config_js__WEBPACK_IMPORTED_MODULE_9__[\"APP_NAME\"]).messaging();\n this.fbPush.usePublicVapidKey(FIREBASE_INIT.messagingVapidKey);\n navigator.serviceWorker.register('/service-worker.js').then(function (reg) {\n _this2.fbPush.useServiceWorker(reg);\n\n _this2.initDesktopAlerts();\n\n if (_this2.state.desktopAlerts) {\n if (!_this2.state.firebaseToken) {\n _this2.togglePushToken(true);\n } else {\n _this2.tinode.setDeviceToken(_this2.state.firebaseToken);\n }\n }\n }).catch(function (err) {\n console.log(\"Failed to register service worker:\", err);\n });\n } catch (err) {\n this.handleError(\"Failed to initialize push notifications\", 'err');\n console.log(\"Failed to initialize push notifications\", err);\n this.setState({\n desktopAlertsEnabled: false\n });\n }\n }\n\n var token = _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].getObject('keep-logged-in') ? _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].getObject('auth-token') : undefined;\n var parsedNav = _lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].parseUrlHash(window.location.hash);\n\n if (token) {\n token.expires = new Date(token.expires);\n this.tinode.setAuthToken(token);\n this.tinode.connect().catch(function (err) {\n _this2.handleError(err.message, 'err');\n });\n delete parsedNav.params.info;\n delete parsedNav.params.tab;\n parsedNav.path[0] = '';\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].composeUrlHash(parsedNav.path, parsedNav.params));\n } else if (!parsedNav.params.token) {\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].navigateTo('');\n }\n\n this.readTimer = null;\n this.readTimerCallback = null;\n this.handleHashRoute();\n }\n }, {\n key: \"componentWillUnmount\",\n value: function componentWillUnmount() {\n window.removeEventListener('resize', this.handleResize);\n window.removeEventListener('hashchange', this.handleHashRoute);\n document.removeEventListener('visibilitychange', this.handleVisibilityEvent);\n }\n }, {\n key: \"handleResize\",\n value: function handleResize() {\n var mobile = document.documentElement.clientWidth <= _config_js__WEBPACK_IMPORTED_MODULE_9__[\"MEDIA_BREAKPOINT\"];\n this.setState({\n viewportWidth: document.documentElement.clientWidth\n });\n\n if (this.state.displayMobile != mobile) {\n this.setState({\n displayMobile: mobile\n });\n }\n }\n }, {\n key: \"handleHashRoute\",\n value: function handleHashRoute() {\n var hash = _lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].parseUrlHash(window.location.hash);\n\n if (hash.path && hash.path.length > 0) {\n if (['register', 'settings', 'edit', 'cred', 'reset', 'newtpk', 'contacts', ''].includes(hash.path[0])) {\n this.setState({\n sidePanelSelected: hash.path[0]\n });\n } else {\n console.log(\"Unknown sidepanel view\", hash.path[0]);\n }\n\n if (hash.path.length > 1 && hash.path[1] != this.state.topicSelected) {\n this.setState({\n topicSelected: tinode_sdk__WEBPACK_IMPORTED_MODULE_4___default.a.topicType(hash.path[1]) ? hash.path[1] : null\n });\n }\n } else {\n this.setState({\n sidePanelSelected: ''\n });\n }\n\n if (hash.params.method) {\n this.setState({\n credMethod: hash.params.method\n });\n }\n\n if (hash.params.code) {\n this.setState({\n credCode: hash.params.code\n });\n }\n\n this.setState({\n showInfoPanel: hash.params.info,\n newTopicTabSelected: hash.params.tab\n });\n }\n }, {\n key: \"handleOnline\",\n value: function handleOnline(online) {\n var newState = {\n liveConnection: online\n };\n\n if (online) {\n this.handleError('', null);\n } else {\n this.handleError(\"No connection\", 'warn');\n }\n\n this.setState({\n liveConnection: online\n });\n }\n }, {\n key: \"handleAppVisibility\",\n value: function handleAppVisibility(visible, callback) {\n clearTimeout(this.readTimer);\n this.readTimerCallback = callback;\n\n if (visible && callback) {\n this.readTimer = setTimeout(callback, _config_js__WEBPACK_IMPORTED_MODULE_9__[\"READ_DELAY\"]);\n } else {\n this.readTimer = null;\n }\n }\n }, {\n key: \"handleReadTimer\",\n value: function handleReadTimer(callback) {\n this.handleAppVisibility(!document.hidden, callback);\n }\n }, {\n key: \"handleVisibilityEvent\",\n value: function handleVisibilityEvent() {\n this.handleAppVisibility(!document.hidden, this.readTimerCallback);\n }\n }, {\n key: \"handleError\",\n value: function handleError(err, level) {\n this.setState({\n errorText: err,\n errorLevel: level\n });\n }\n }, {\n key: \"handleLoginRequest\",\n value: function handleLoginRequest(login, password) {\n var _this3 = this;\n\n this.setState({\n loginDisabled: true,\n login: login,\n password: password\n });\n this.handleError('', null);\n\n if (this.tinode.isConnected()) {\n this.doLogin(login, password, {\n meth: this.state.credMethod,\n resp: this.state.credCode\n });\n } else {\n this.tinode.connect().catch(function (err) {\n _this3.setState({\n loginDisabled: false\n });\n\n _this3.handleError(err.message, 'err');\n });\n }\n }\n }, {\n key: \"handleConnected\",\n value: function handleConnected() {\n var params = this.tinode.getServerInfo();\n this.setState({\n serverVersion: params.ver + ' ' + (params.build ? params.build : 'none') + '; '\n });\n this.doLogin(this.state.login, this.state.password, {\n meth: this.state.credMethod,\n resp: this.state.credCode\n });\n }\n }, {\n key: \"doLogin\",\n value: function doLogin(login, password, cred) {\n var _this4 = this;\n\n if (this.tinode.isAuthenticated()) {\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].navigateTo('');\n return;\n }\n\n cred = tinode_sdk__WEBPACK_IMPORTED_MODULE_4___default.a.credential(cred);\n var promise = null;\n var token = this.tinode.getAuthToken();\n\n if (login && password) {\n this.setState({\n password: null\n });\n promise = this.tinode.loginBasic(login, password, cred);\n } else if (token) {\n promise = this.tinode.loginToken(token.token, cred);\n }\n\n if (promise) {\n promise.then(function (ctrl) {\n if (ctrl.code >= 300 && ctrl.text === 'validate credentials') {\n if (cred) {\n _this4.handleError(\"Code does not match\", 'warn');\n }\n\n _this4.handleCredentialsRequest(ctrl.params);\n } else {\n _this4.handleLoginSuccessful();\n }\n }).catch(function (err) {\n _this4.setState({\n loginDisabled: false,\n credMethod: undefined,\n credCode: undefined\n });\n\n _this4.handleError(err.message, 'err');\n\n _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].removeItem('auth-token');\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].navigateTo('');\n });\n } else {\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].navigateTo('');\n this.setState({\n loginDisabled: false\n });\n }\n }\n }, {\n key: \"handleCredentialsRequest\",\n value: function handleCredentialsRequest(params) {\n var parsed = _lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].parseUrlHash(window.location.hash);\n parsed.path[0] = 'cred';\n parsed.params['method'] = params.cred[0];\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].composeUrlHash(parsed.path, parsed.params));\n }\n }, {\n key: \"handleLoginSuccessful\",\n value: function handleLoginSuccessful() {\n var _this5 = this;\n\n this.handleError('', null);\n\n if (_lib_local_storage_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].getObject('keep-logged-in')) {\n _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].setObject('auth-token', this.tinode.getAuthToken());\n }\n\n var me = this.tinode.getMeTopic();\n me.onMetaDesc = this.tnMeMetaDesc;\n me.onContactUpdate = this.tnMeContactUpdate;\n me.onSubsUpdated = this.tnMeSubsUpdated;\n this.setState({\n connected: true,\n credMethod: undefined,\n credCode: undefined,\n myUserId: this.tinode.getCurrentUserID()\n });\n me.subscribe(me.startMetaQuery().withLaterSub().withDesc().build()).catch(function (err) {\n _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].removeItem('auth-token');\n\n _this5.handleError(err.message, 'err');\n\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].navigateTo('');\n });\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].setUrlSidePanel(window.location.hash, 'contacts'));\n }\n }, {\n key: \"handleDisconnect\",\n value: function handleDisconnect(err) {\n this.setState({\n connected: false,\n topicSelectedOnline: false,\n dialogSelected: null,\n errorText: err && err.message ? err.message : \"Disconnected\",\n errorLevel: err && err.message ? 'err' : 'warn',\n loginDisabled: false,\n contextMenuVisible: false,\n serverVersion: \"no connection\"\n });\n }\n }, {\n key: \"tnMeMetaDesc\",\n value: function tnMeMetaDesc(desc) {\n if (desc && desc.public) {\n this.setState({\n sidePanelTitle: desc.public.fn,\n sidePanelAvatar: Object(_lib_blob_helpers_js__WEBPACK_IMPORTED_MODULE_10__[\"makeImageUrl\"])(desc.public.photo)\n });\n }\n }\n }, {\n key: \"tnMeContactUpdate\",\n value: function tnMeContactUpdate(what, cont) {\n if (what == 'on' || what == 'off') {\n this.resetContactList();\n\n if (this.state.topicSelected == cont.topic) {\n this.setState({\n topicSelectedOnline: what == 'on'\n });\n }\n } else if (what == 'read') {\n this.resetContactList();\n } else if (what == 'msg') {\n if (this.state.topicSelected != cont.topic) {\n if (this.state.messageSounds) {\n POP_SOUND.play();\n }\n\n this.resetContactList();\n } else if (document.hidden && this.state.messageSounds) {\n POP_SOUND.play();\n }\n } else if (what == 'recv') {} else if (what == 'gone' || what == 'unsub') {\n if (this.state.topicSelected == cont.topic) {\n this.handleTopicSelected(null);\n }\n\n this.resetContactList();\n } else if (what == 'acs') {\n if (this.state.topicSelected == cont.topic) {\n this.setState({\n topicSelectedAcs: cont.acs\n });\n }\n } else if (what == 'del') {} else {\n console.log(\"Unsupported (yet) presence update:\" + what + \" in: \" + cont.topic);\n }\n }\n }, {\n key: \"tnMeSubsUpdated\",\n value: function tnMeSubsUpdated(unused) {\n this.resetContactList();\n }\n }, {\n key: \"resetContactList\",\n value: function resetContactList() {\n var _this6 = this;\n\n var newState = {\n chatList: []\n };\n this.tinode.getMeTopic().contacts(function (c) {\n newState.chatList.push(c);\n\n if (_this6.state.topicSelected == c.topic) {\n newState.topicSelectedOnline = c.online;\n newState.topicSelectedAcs = c.acs;\n }\n });\n newState.searchableContacts = TinodeWeb.prepareSearchableContacts(newState.chatList, this.state.searchResults);\n this.setState(newState);\n }\n }, {\n key: \"tnData\",\n value: function tnData(data) {\n var _this7 = this;\n\n var topic = this.tinode.getTopic(data.topic);\n\n if (topic.msgStatus(data) >= tinode_sdk__WEBPACK_IMPORTED_MODULE_4___default.a.MESSAGE_STATUS_SENT) {\n clearTimeout(this.receivedTimer);\n this.receivedTimer = setTimeout(function () {\n _this7.receivedTimer = undefined;\n topic.noteRecv(data.seq);\n }, _config_js__WEBPACK_IMPORTED_MODULE_9__[\"RECEIVED_DELAY\"]);\n }\n }\n }, {\n key: \"tnInitFind\",\n value: function tnInitFind() {\n var _this8 = this;\n\n var fnd = this.tinode.getFndTopic();\n\n if (fnd.isSubscribed()) {\n this.tnFndSubsUpdated();\n } else {\n fnd.onSubsUpdated = this.tnFndSubsUpdated;\n fnd.subscribe(fnd.startMetaQuery().withSub().withTags().build()).catch(function (err) {\n _this8.handleError(err.message, 'err');\n });\n }\n }\n }, {\n key: \"tnFndSubsUpdated\",\n value: function tnFndSubsUpdated() {\n var foundContacts = [];\n this.tinode.getFndTopic().contacts(function (s) {\n foundContacts.push(s);\n });\n this.setState({\n searchResults: foundContacts,\n searchableContacts: TinodeWeb.prepareSearchableContacts(this.state.chatList, foundContacts)\n });\n }\n }, {\n key: \"handleSearchContacts\",\n value: function handleSearchContacts(query) {\n var _this9 = this;\n\n var fnd = this.tinode.getFndTopic();\n fnd.setMeta({\n desc: {\n public: query\n }\n }).then(function (ctrl) {\n return fnd.getMeta(fnd.startMetaQuery().withSub().build());\n }).catch(function (err) {\n _this9.handleError(err.message, 'err');\n });\n }\n }, {\n key: \"handleTopicSelected\",\n value: function handleTopicSelected(topicName, unused_index, online, acs) {\n if (topicName) {\n this.setState({\n errorText: '',\n errorLevel: null,\n mobilePanel: 'topic-view',\n showInfoPanel: false\n });\n\n if (this.state.topicSelected != topicName) {\n this.setState({\n topicSelectedOnline: online,\n topicSelectedAcs: acs\n });\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].setUrlTopic('', topicName));\n }\n } else {\n this.setState({\n errorText: '',\n errorLevel: null,\n mobilePanel: 'sidepanel',\n topicSelectedOnline: false,\n topicSelectedAcs: null,\n showInfoPanel: false\n });\n\n if (this.state.topicSelected) {\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].setUrlTopic('', null));\n }\n }\n }\n }, {\n key: \"handleHideMessagesView\",\n value: function handleHideMessagesView() {\n this.setState({\n mobilePanel: 'sidepanel'\n });\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].setUrlTopic(window.location.hash, null));\n }\n }, {\n key: \"handleSendMessage\",\n value: function handleSendMessage(msg, promise, uploader) {\n var _this10 = this;\n\n var topic = this.tinode.getTopic(this.state.topicSelected);\n msg = topic.createMessage(msg, false);\n msg._uploader = uploader;\n\n if (!topic.isSubscribed()) {\n if (!promise) {\n promise = Promise.resolve();\n }\n\n promise = promise.then(function () {\n return topic.subscribe();\n });\n }\n\n if (promise) {\n promise = promise.catch(function (err) {\n _this10.handleError(err.message, 'err');\n });\n }\n\n topic.publishDraft(msg, promise).catch(function (err) {\n _this10.handleError(err.message, 'err');\n });\n }\n }, {\n key: \"handleNewAccount\",\n value: function handleNewAccount() {\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].setUrlSidePanel(window.location.hash, 'register'));\n }\n }, {\n key: \"handleNewAccountRequest\",\n value: function handleNewAccountRequest(login_, password_, public_, cred_, tags_) {\n var _this11 = this;\n\n this.tinode.connect(this.state.serverAddress).then(function () {\n return _this11.tinode.createAccountBasic(login_, password_, {\n public: public_,\n tags: tags_,\n cred: tinode_sdk__WEBPACK_IMPORTED_MODULE_4___default.a.credential(cred_)\n });\n }).then(function (ctrl) {\n if (ctrl.code >= 300 && ctrl.text == 'validate credentials') {\n _this11.handleCredentialsRequest(ctrl.params);\n } else {\n _this11.handleLoginSuccessful(_this11);\n }\n }).catch(function (err) {\n _this11.handleError(err.message, 'err');\n });\n }\n }, {\n key: \"handleUpdateAccountRequest\",\n value: function handleUpdateAccountRequest(password, pub, defacs) {\n var _this12 = this;\n\n if (pub || defacs) {\n this.tinode.getMeTopic().setMeta({\n desc: {\n public: pub,\n defacs: defacs\n }\n }).catch(function (err) {\n _this12.handleError(err.message, 'err');\n });\n }\n\n if (password) {\n this.tinode.updateAccountBasic(null, this.tinode.getCurrentLogin(), password).catch(function (err) {\n _this12.handleError(err.message, 'err');\n });\n }\n }\n }, {\n key: \"handleUpdateAccountTagsRequest\",\n value: function handleUpdateAccountTagsRequest(tags) {\n var _this13 = this;\n\n this.tinode.getFndTopic().setMeta({\n tags: tags\n }).catch(function (err) {\n _this13.handleError(err.message, 'err');\n });\n }\n }, {\n key: \"handleSettings\",\n value: function handleSettings() {\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].setUrlSidePanel(window.location.hash, this.state.myUserId ? 'edit' : 'settings'));\n }\n }, {\n key: \"handleGlobalSettings\",\n value: function handleGlobalSettings(settings) {\n var serverAddress = settings.serverAddress || this.state.serverAddress;\n var transport = settings.transport || this.state.transport;\n\n if (this.tinode) {\n this.tinode.onDisconnect = undefined;\n this.tinode.disconnect();\n }\n\n this.tinode = TinodeWeb.tnSetup(serverAddress, transport);\n this.tinode.onConnect = this.handleConnected;\n this.tinode.onDisconnect = this.handleDisconnect;\n this.setState({\n serverAddress: serverAddress,\n transport: transport\n });\n _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].setObject('settings', {\n serverAddress: serverAddress,\n transport: transport\n });\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].setUrlSidePanel(window.location.hash, ''));\n }\n }, {\n key: \"initDesktopAlerts\",\n value: function initDesktopAlerts() {\n var _this14 = this;\n\n this.fbPush.onTokenRefresh(function () {\n _this14.requestPushToken(true);\n });\n this.fbPush.onMessage(function (payload) {});\n }\n }, {\n key: \"togglePushToken\",\n value: function togglePushToken(enabled) {\n var _this15 = this;\n\n if (enabled) {\n if (!this.state.firebaseToken) {\n this.fbPush.requestPermission().then(function () {\n _this15.requestPushToken(true);\n }).catch(function (err) {\n _this15.handleError(err.message, 'err');\n\n _this15.setState({\n desktopAlerts: false,\n firebaseToken: null\n });\n\n _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].updateObject('settings', {\n desktopAlerts: false\n });\n console.log(\"Failed to get permission to notify.\", err);\n });\n } else {\n this.setState({\n desktopAlerts: true\n });\n _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].updateObject('settings', {\n desktopAlerts: true\n });\n }\n } else if (this.state.firebaseToken) {\n this.fbPush.deleteToken(this.state.firebaseToken).catch(function (err) {\n console.log(\"Unable to delete token.\", err);\n }).finally(function () {\n _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].updateObject('settings', {\n desktopAlerts: false\n });\n _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].removeItem('firebase-token');\n\n _this15.setState({\n desktopAlerts: false,\n firebaseToken: null\n });\n });\n } else {\n this.setState({\n desktopAlerts: false,\n firebaseToken: null\n });\n _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].updateObject('settings', {\n desktopAlerts: false\n });\n }\n }\n }, {\n key: \"requestPushToken\",\n value: function requestPushToken(sendToServer) {\n var _this16 = this;\n\n this.fbPush.getToken().then(function (refreshedToken) {\n if (refreshedToken != _this16.state.firebaseToken) {\n _this16.tinode.setDeviceToken(refreshedToken, sendToServer);\n\n _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].setObject('firebase-token', refreshedToken);\n }\n\n _this16.setState({\n firebaseToken: refreshedToken,\n desktopAlerts: true\n });\n\n _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].updateObject('settings', {\n desktopAlerts: true\n });\n }).catch(function (err) {\n _this16.handleError(err.message, 'err');\n\n console.log(\"Failed to retrieve firebase token\", err);\n });\n }\n }, {\n key: \"handleToggleMessageSounds\",\n value: function handleToggleMessageSounds(enabled) {\n this.setState({\n messageSounds: enabled\n });\n _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].updateObject('settings', {\n messageSoundsOff: !enabled\n });\n }\n }, {\n key: \"handleSidepanelCancel\",\n value: function handleSidepanelCancel() {\n var parsed = _lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].parseUrlHash(window.location.hash);\n parsed.path[0] = this.state.myUserId ? 'contacts' : '';\n\n if (parsed.params) {\n delete parsed.params.code;\n delete parsed.params.method;\n delete parsed.params.tab;\n }\n\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].composeUrlHash(parsed.path, parsed.params));\n this.setState({\n errorText: '',\n errorLevel: null\n });\n }\n }, {\n key: \"handleNewTopic\",\n value: function handleNewTopic() {\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].setUrlSidePanel(window.location.hash, 'newtpk'));\n }\n }, {\n key: \"handleNewTopicRequest\",\n value: function handleNewTopicRequest(peerName, pub, priv, tags) {\n var _this17 = this;\n\n var topicName = peerName || this.tinode.newGroupTopicName();\n\n if (!peerName) {\n this.setState({\n newGroupTopicParams: {\n desc: {\n public: pub,\n private: {\n comment: priv\n }\n },\n tags: tags\n }\n }, function () {\n _this17.handleTopicSelected(topicName);\n });\n } else {\n this.handleTopicSelected(topicName);\n }\n }\n }, {\n key: \"handleNewTopicCreated\",\n value: function handleNewTopicCreated(oldName, newName) {\n if (this.state.topicSelected == oldName && oldName != newName) {\n this.setState({\n topicSelected: newName\n }, function () {\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].setUrlTopic('', newName));\n });\n }\n }\n }, {\n key: \"handleTopicUpdateRequest\",\n value: function handleTopicUpdateRequest(topicName, pub, priv, permissions) {\n var _this18 = this;\n\n var topic = this.tinode.getTopic(topicName);\n\n if (topic) {\n var params = {};\n\n if (pub) {\n params.public = pub;\n }\n\n if (priv) {\n params.private = {\n comment: priv\n };\n }\n\n if (permissions) {\n params.defacs = permissions;\n }\n\n topic.setMeta({\n desc: params\n }).catch(function (err) {\n _this18.handleError(err.message, 'err');\n });\n }\n }\n }, {\n key: \"handleChangePermissions\",\n value: function handleChangePermissions(topicName, mode, uid) {\n var _this19 = this;\n\n var topic = this.tinode.getTopic(topicName);\n\n if (topic) {\n var am = topic.getAccessMode();\n\n if (uid) {\n am.updateGiven(mode);\n mode = am.getGiven();\n } else {\n am.updateWant(mode);\n mode = am.getWant();\n }\n\n topic.setMeta({\n sub: {\n user: uid,\n mode: mode\n }\n }).catch(function (err) {\n _this19.handleError(err.message, 'err');\n });\n }\n }\n }, {\n key: \"handleTagsUpdated\",\n value: function handleTagsUpdated(topicName, tags) {\n var _this20 = this;\n\n var topic = this.tinode.getTopic(topicName);\n\n if (topic) {\n var instance = this;\n topic.setMeta({\n tags: tags\n }).catch(function (err) {\n _this20.handleError(err.message, 'err');\n });\n }\n }\n }, {\n key: \"handleLogout\",\n value: function handleLogout() {\n Object(_lib_utils_js__WEBPACK_IMPORTED_MODULE_14__[\"updateFavicon\"])(0);\n _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].removeItem('auth-token');\n\n if (this.tinode) {\n this.tinode.onDisconnect = undefined;\n this.tinode.disconnect();\n }\n\n this.setState(this.getBlankState());\n this.tinode = TinodeWeb.tnSetup(this.state.serverAddress, this.state.transport);\n this.tinode.onConnect = this.handleConnected;\n this.tinode.onDisconnect = this.handleDisconnect;\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].navigateTo('');\n }\n }, {\n key: \"handleLeaveUnsubRequest\",\n value: function handleLeaveUnsubRequest(topicName) {\n var _this21 = this;\n\n var topic = this.tinode.getTopic(topicName);\n\n if (!topic) {\n return;\n }\n\n topic.leave(true).then(function (ctrl) {\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].setUrlTopic(window.location.hash, ''));\n }).catch(function (err) {\n _this21.handleError(err.message, 'err');\n });\n }\n }, {\n key: \"handleDialogCancel\",\n value: function handleDialogCancel() {\n this.setState({\n dialogSelected: null\n });\n }\n }, {\n key: \"handleShowContextMenu\",\n value: function handleShowContextMenu(params, menuItems) {\n this.setState({\n contextMenuVisible: true,\n contextMenuClickAt: {\n x: params.x,\n y: params.y\n },\n contextMenuParams: params,\n contextMenuItems: menuItems || this.defaultTopicContextMenu(params.topicName),\n contextMenuBounds: react_dom__WEBPACK_IMPORTED_MODULE_1___default.a.findDOMNode(this).getBoundingClientRect()\n });\n }\n }, {\n key: \"defaultTopicContextMenu\",\n value: function defaultTopicContextMenu(topicName) {\n var muted = false,\n blocked = false,\n subscribed = false,\n deleter = false;\n var topic = this.tinode.getTopic(topicName);\n\n if (topic) {\n if (topic.isSubscribed()) {\n subscribed = true;\n var acs = topic.getAccessMode();\n muted = acs && acs.isMuted();\n blocked = acs && !acs.isJoiner();\n deleter = acs && acs.isDeleter();\n }\n }\n\n return [subscribed ? {\n title: \"Info\",\n handler: this.handleShowInfoView\n } : null, subscribed ? 'messages_clear' : null, subscribed && deleter ? 'messages_clear_hard' : null, subscribed ? muted ? 'topic_unmute' : 'topic_mute' : null, subscribed ? blocked ? 'topic_unblock' : 'topic_block' : null, 'topic_delete'];\n }\n }, {\n key: \"handleHideContextMenu\",\n value: function handleHideContextMenu() {\n this.setState({\n contextMenuVisible: false,\n contextMenuClickAt: null,\n contextMenuParams: null,\n contextMenuBounds: null\n });\n }\n }, {\n key: \"handleShowInfoView\",\n value: function handleShowInfoView() {\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].addUrlParam(window.location.hash, 'info', true));\n this.setState({\n showInfoPanel: true\n });\n }\n }, {\n key: \"handleHideInfoView\",\n value: function handleHideInfoView() {\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].removeUrlParam(window.location.hash, 'info'));\n this.setState({\n showInfoPanel: false\n });\n }\n }, {\n key: \"handleMemberUpdateRequest\",\n value: function handleMemberUpdateRequest(topicName, added, removed) {\n var _this22 = this;\n\n if (!topicName) {\n return;\n }\n\n var topic = this.tinode.getTopic(topicName);\n\n if (!topic) {\n return;\n }\n\n if (added && added.length > 0) {\n added.map(function (uid) {\n topic.invite(uid, null).catch(function (err) {\n _this22.handleError(err.message, 'err');\n });\n });\n }\n\n if (removed && removed.length > 0) {\n removed.map(function (uid) {\n topic.delSubscription(uid).catch(function (err) {\n _this22.handleError(err.message, 'err');\n });\n });\n }\n }\n }, {\n key: \"handleValidateCredentialsRequest\",\n value: function handleValidateCredentialsRequest(cred, code) {\n this.setState({\n credMethod: cred,\n credCode: code\n });\n this.doLogin(null, null, {\n meth: cred,\n resp: code\n });\n }\n }, {\n key: \"handlePasswordResetRequest\",\n value: function handlePasswordResetRequest(method, value) {\n var _this23 = this;\n\n this.tinode.connect().then(function () {\n return _this23.tinode.requestResetAuthSecret('basic', method, value);\n }).catch(function (err) {\n _this23.handleError(err.message, 'err');\n });\n }\n }, {\n key: \"handleResetPassword\",\n value: function handleResetPassword(scheme, newPassword, token) {\n var _this24 = this;\n\n token = base64ReEncode(token);\n\n if (!token) {\n this.handleError(\"Invalid security token\", 'err');\n } else {\n this.tinode.connect().then(function () {\n return _this24.tinode.updateAccountBasic(null, null, newPassword, {\n token: token\n });\n }).catch(function (err) {\n _this24.handleError(err.message, 'err');\n });\n }\n }\n }, {\n key: \"render\",\n value: function render() {\n return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n id: \"app-container\"\n }, this.state.contextMenuVisible ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_widgets_context_menu_jsx__WEBPACK_IMPORTED_MODULE_5__[\"default\"], {\n tinode: this.tinode,\n bounds: this.state.contextMenuBounds,\n clickAt: this.state.contextMenuClickAt,\n params: this.state.contextMenuParams,\n items: this.state.contextMenuItems,\n hide: this.handleHideContextMenu,\n onAction: this.handleContextMenuAction,\n onError: this.handleError\n }) : null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_sidepanel_view_jsx__WEBPACK_IMPORTED_MODULE_8__[\"default\"], {\n tinode: this.tinode,\n connected: this.state.connected,\n displayMobile: this.state.displayMobile,\n hideSelf: this.state.displayMobile && this.state.mobilePanel !== 'sidepanel',\n state: this.state.sidePanelSelected,\n title: this.state.sidePanelTitle,\n avatar: this.state.sidePanelAvatar,\n login: this.state.login,\n myUserId: this.state.myUserId,\n loginDisabled: this.state.loginDisabled,\n errorText: this.state.errorText,\n errorLevel: this.state.errorLevel,\n topicSelected: this.state.topicSelected,\n chatList: this.state.chatList,\n credMethod: this.state.credMethod,\n credCode: this.state.credCode,\n transport: this.state.transport,\n messageSounds: this.state.messageSounds,\n desktopAlerts: this.state.desktopAlerts,\n desktopAlertsEnabled: this.state.desktopAlertsEnabled,\n serverAddress: this.state.serverAddress,\n onGlobalSettings: this.handleGlobalSettings,\n onSignUp: this.handleNewAccount,\n onSettings: this.handleSettings,\n onLoginRequest: this.handleLoginRequest,\n onCreateAccount: this.handleNewAccountRequest,\n onUpdateAccount: this.handleUpdateAccountRequest,\n onUpdateAccountTags: this.handleUpdateAccountTagsRequest,\n onTogglePushNotifications: this.togglePushToken,\n onToggleMessageSounds: this.handleToggleMessageSounds,\n onTopicSelected: this.handleTopicSelected,\n onCreateTopic: this.handleNewTopicRequest,\n onNewTopic: this.handleNewTopic,\n onLogout: this.handleLogout,\n onCancel: this.handleSidepanelCancel,\n onError: this.handleError,\n onValidateCredentials: this.handleValidateCredentialsRequest,\n onPasswordResetRequest: this.handlePasswordResetRequest,\n onResetPassword: this.handleResetPassword,\n onInitFind: this.tnInitFind,\n searchResults: this.state.searchResults,\n onSearchContacts: this.handleSearchContacts,\n showContextMenu: this.handleShowContextMenu\n }), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_messages_view_jsx__WEBPACK_IMPORTED_MODULE_7__[\"default\"], {\n tinode: this.tinode,\n connected: this.state.connected,\n online: this.state.topicSelectedOnline,\n acs: this.state.topicSelectedAcs,\n displayMobile: this.state.displayMobile,\n viewportWidth: this.state.viewportWidth,\n hideSelf: this.state.displayMobile && (this.state.mobilePanel !== 'topic-view' || this.state.showInfoPanel),\n topic: this.state.topicSelected,\n myUserId: this.state.myUserId,\n serverVersion: this.state.serverVersion,\n serverAddress: this.state.serverAddress,\n errorText: this.state.errorText,\n errorLevel: this.state.errorLevel,\n newGroupTopicParams: this.state.newGroupTopicParams,\n onHideMessagesView: this.handleHideMessagesView,\n onData: this.tnData,\n onError: this.handleError,\n onNewTopicCreated: this.handleNewTopicCreated,\n readTimerHandler: this.handleReadTimer,\n showContextMenu: this.handleShowContextMenu,\n sendMessage: this.handleSendMessage\n }), this.state.showInfoPanel ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_info_view_jsx__WEBPACK_IMPORTED_MODULE_6__[\"default\"], {\n tinode: this.tinode,\n connected: this.state.connected,\n displayMobile: this.state.displayMobile,\n topic: this.state.topicSelected,\n searchableContacts: this.state.searchableContacts,\n myUserId: this.state.myUserId,\n errorText: this.state.errorText,\n errorLevel: this.state.errorLevel,\n onTopicDescUpdate: this.handleTopicUpdateRequest,\n onCancel: this.handleHideInfoView,\n onChangePermissions: this.handleChangePermissions,\n onMemberUpdateRequest: this.handleMemberUpdateRequest,\n onLeaveTopic: this.handleLeaveUnsubRequest,\n onAddMember: this.handleManageGroupMembers,\n onTopicTagsUpdate: this.handleTagsUpdated,\n onInitFind: this.tnInitFind,\n onError: this.handleError,\n showContextMenu: this.handleShowContextMenu\n }) : null);\n }\n }], [{\n key: \"tnSetup\",\n value: function tnSetup(serverAddress, transport) {\n var tinode = new tinode_sdk__WEBPACK_IMPORTED_MODULE_4___default.a(_config_js__WEBPACK_IMPORTED_MODULE_9__[\"APP_NAME\"], serverAddress, _config_js__WEBPACK_IMPORTED_MODULE_9__[\"API_KEY\"], transport, Object(_lib_host_name_js__WEBPACK_IMPORTED_MODULE_11__[\"isSecureConnection\"])());\n tinode.enableLogging(true, true);\n return tinode;\n }\n }, {\n key: \"prepareSearchableContacts\",\n value: function prepareSearchableContacts(chatList, foundContacts) {\n var merged = {};\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = chatList[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var c = _step.value;\n\n if (tinode_sdk__WEBPACK_IMPORTED_MODULE_4___default.a.topicType(c.topic) == 'p2p') {\n merged[c.topic] = {\n user: c.topic,\n updated: c.updated,\n public: c.public,\n private: c.private,\n acs: c.acs\n };\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = foundContacts[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var _c = _step2.value;\n\n if (!merged[_c.user]) {\n merged[_c.user] = _c;\n }\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n return Object.values(merged);\n }\n }]);\n\n return TinodeWeb;\n}(react__WEBPACK_IMPORTED_MODULE_0___default.a.Component);\n\n\n;\n\n//# sourceURL=webpack:///./src/views/tinode-web.jsx?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ \"./node_modules/react-dom/index.js\");\n/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var react_intl__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-intl */ \"./node_modules/react-intl/lib/index.es.js\");\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/index.cjs.js\");\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(firebase_app__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var firebase_messaging__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! firebase/messaging */ \"./node_modules/firebase/messaging/dist/index.esm.js\");\n/* harmony import */ var tinode_sdk__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! tinode-sdk */ \"./node_modules/tinode-sdk/umd/tinode.prod.js\");\n/* harmony import */ var tinode_sdk__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(tinode_sdk__WEBPACK_IMPORTED_MODULE_5__);\n/* harmony import */ var _widgets_context_menu_jsx__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../widgets/context-menu.jsx */ \"./src/widgets/context-menu.jsx\");\n/* harmony import */ var _info_view_jsx__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./info-view.jsx */ \"./src/views/info-view.jsx\");\n/* harmony import */ var _messages_view_jsx__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./messages-view.jsx */ \"./src/views/messages-view.jsx\");\n/* harmony import */ var _sidepanel_view_jsx__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./sidepanel-view.jsx */ \"./src/views/sidepanel-view.jsx\");\n/* harmony import */ var _config_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../config.js */ \"./src/config.js\");\n/* harmony import */ var _lib_blob_helpers_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../lib/blob-helpers.js */ \"./src/lib/blob-helpers.js\");\n/* harmony import */ var _lib_host_name_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../lib/host-name.js */ \"./src/lib/host-name.js\");\n/* harmony import */ var _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../lib/local-storage.js */ \"./src/lib/local-storage.js\");\n/* harmony import */ var _lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../lib/navigation.js */ \"./src/lib/navigation.js\");\n/* harmony import */ var _lib_utils_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../lib/utils.js */ \"./src/lib/utils.js\");\nfunction _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; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _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); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar POP_SOUND = new Audio('audio/msg.mp3');\nconsole.log(\"desktop alerts: is secure, is localhost, firebase, navigator, fb_init\", Object(_lib_host_name_js__WEBPACK_IMPORTED_MODULE_12__[\"isSecureConnection\"])(), Object(_lib_host_name_js__WEBPACK_IMPORTED_MODULE_12__[\"isLocalHost\"])(), _typeof(firebase_app__WEBPACK_IMPORTED_MODULE_3__), typeof navigator === \"undefined\" ? \"undefined\" : _typeof(navigator), typeof FIREBASE_INIT === \"undefined\" ? \"undefined\" : _typeof(FIREBASE_INIT));\n\nvar TinodeWeb = function (_React$Component) {\n _inherits(TinodeWeb, _React$Component);\n\n function TinodeWeb(props) {\n var _this;\n\n _classCallCheck(this, TinodeWeb);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(TinodeWeb).call(this, props));\n _this.state = _this.getBlankState();\n _this.handleResize = _this.handleResize.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleHashRoute = _this.handleHashRoute.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleOnline = _this.handleOnline.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleAppVisibility = _this.handleAppVisibility.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleReadTimer = _this.handleReadTimer.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleVisibilityEvent = _this.handleVisibilityEvent.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleError = _this.handleError.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleLoginRequest = _this.handleLoginRequest.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleConnected = _this.handleConnected.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.doLogin = _this.doLogin.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleCredentialsRequest = _this.handleCredentialsRequest.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleLoginSuccessful = _this.handleLoginSuccessful.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleDisconnect = _this.handleDisconnect.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.tnMeMetaDesc = _this.tnMeMetaDesc.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.tnMeContactUpdate = _this.tnMeContactUpdate.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.tnMeSubsUpdated = _this.tnMeSubsUpdated.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.resetContactList = _this.resetContactList.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.tnData = _this.tnData.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.tnInitFind = _this.tnInitFind.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.tnFndSubsUpdated = _this.tnFndSubsUpdated.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleSearchContacts = _this.handleSearchContacts.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleTopicSelected = _this.handleTopicSelected.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleHideMessagesView = _this.handleHideMessagesView.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleSendMessage = _this.handleSendMessage.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleNewAccount = _this.handleNewAccount.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleNewAccountRequest = _this.handleNewAccountRequest.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleUpdateAccountRequest = _this.handleUpdateAccountRequest.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleUpdateAccountTagsRequest = _this.handleUpdateAccountTagsRequest.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleSettings = _this.handleSettings.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleGlobalSettings = _this.handleGlobalSettings.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleToggleMessageSounds = _this.handleToggleMessageSounds.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.initDesktopAlerts = _this.initDesktopAlerts.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.togglePushToken = _this.togglePushToken.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.requestPushToken = _this.requestPushToken.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleSidepanelCancel = _this.handleSidepanelCancel.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleNewTopic = _this.handleNewTopic.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleNewTopicRequest = _this.handleNewTopicRequest.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleNewTopicCreated = _this.handleNewTopicCreated.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleTopicUpdateRequest = _this.handleTopicUpdateRequest.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleChangePermissions = _this.handleChangePermissions.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleTagsUpdated = _this.handleTagsUpdated.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleLogout = _this.handleLogout.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleLeaveUnsubRequest = _this.handleLeaveUnsubRequest.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleDialogCancel = _this.handleDialogCancel.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleShowContextMenu = _this.handleShowContextMenu.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.defaultTopicContextMenu = _this.defaultTopicContextMenu.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleHideContextMenu = _this.handleHideContextMenu.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleShowInfoView = _this.handleShowInfoView.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleHideInfoView = _this.handleHideInfoView.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleMemberUpdateRequest = _this.handleMemberUpdateRequest.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleValidateCredentialsRequest = _this.handleValidateCredentialsRequest.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handlePasswordResetRequest = _this.handlePasswordResetRequest.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleResetPassword = _this.handleResetPassword.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n return _this;\n }\n\n _createClass(TinodeWeb, [{\n key: \"getBlankState\",\n value: function getBlankState() {\n var _ref;\n\n var settings = _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].getObject(\"settings\") || {};\n return _ref = {\n connected: false,\n transport: settings.transport || null,\n serverAddress: settings.serverAddress || detectServerAddress(),\n serverVersion: \"no connection\",\n messageSounds: !settings.messageSoundsOff,\n desktopAlerts: settings.desktopAlerts,\n desktopAlertsEnabled: (Object(_lib_host_name_js__WEBPACK_IMPORTED_MODULE_12__[\"isSecureConnection\"])() || Object(_lib_host_name_js__WEBPACK_IMPORTED_MODULE_12__[\"isLocalHost\"])()) && typeof firebase_app__WEBPACK_IMPORTED_MODULE_3__ != 'undefined' && typeof navigator != 'undefined' && typeof FIREBASE_INIT != 'undefined',\n firebaseToken: _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].getObject(\"firebase-token\"),\n errorText: '',\n errorLevel: null,\n sidePanelSelected: 'login',\n sidePanelTitle: null,\n sidePanelAvatar: null,\n dialogSelected: null,\n contextMenuVisible: false,\n login: '',\n password: '',\n myUserId: null,\n liveConnection: navigator.onLine,\n topicSelected: '',\n topicSelectedOnline: false,\n topicSelectedAcs: null,\n newGroupTopicParams: null,\n loginDisabled: false,\n displayMobile: window.innerWidth <= _config_js__WEBPACK_IMPORTED_MODULE_10__[\"MEDIA_BREAKPOINT\"],\n showInfoPanel: false,\n mobilePanel: 'sidepanel'\n }, _defineProperty(_ref, \"contextMenuVisible\", false), _defineProperty(_ref, \"contextMenuBounds\", null), _defineProperty(_ref, \"contextMenuClickAt\", null), _defineProperty(_ref, \"contextMenuParams\", null), _defineProperty(_ref, \"contextMenuItems\", []), _defineProperty(_ref, \"chatList\", []), _defineProperty(_ref, \"searchResults\", []), _defineProperty(_ref, \"searchableContacts\", []), _defineProperty(_ref, \"credMethod\", undefined), _defineProperty(_ref, \"credCode\", undefined), _ref;\n }\n }, {\n key: \"componentDidMount\",\n value: function componentDidMount() {\n var _this2 = this;\n\n window.addEventListener('resize', this.handleResize);\n window.addEventListener('online', function (e) {\n _this2.handleOnline(true);\n });\n window.addEventListener('offline', function (e) {\n _this2.handleOnline(false);\n });\n window.addEventListener('hashchange', this.handleHashRoute);\n document.addEventListener('visibilitychange', this.handleVisibilityEvent);\n this.setState({\n viewportWidth: document.documentElement.clientWidth\n });\n this.tinode = TinodeWeb.tnSetup(this.state.serverAddress, this.state.transport);\n this.tinode.onConnect = this.handleConnected;\n this.tinode.onDisconnect = this.handleDisconnect;\n\n if (this.state.desktopAlertsEnabled) {\n try {\n this.fbPush = firebase_app__WEBPACK_IMPORTED_MODULE_3__[\"initializeApp\"](FIREBASE_INIT, _config_js__WEBPACK_IMPORTED_MODULE_10__[\"APP_NAME\"]).messaging();\n this.fbPush.usePublicVapidKey(FIREBASE_INIT.messagingVapidKey);\n navigator.serviceWorker.register('/service-worker.js').then(function (reg) {\n _this2.fbPush.useServiceWorker(reg);\n\n _this2.initDesktopAlerts();\n\n if (_this2.state.desktopAlerts) {\n if (!_this2.state.firebaseToken) {\n _this2.togglePushToken(true);\n } else {\n _this2.tinode.setDeviceToken(_this2.state.firebaseToken);\n }\n }\n }).catch(function (err) {\n console.log(\"Failed to register service worker:\", err);\n });\n } catch (err) {\n this.handleError(\"Failed to initialize push notifications\", 'err');\n console.log(\"Failed to initialize push notifications\", err);\n this.setState({\n desktopAlertsEnabled: false\n });\n }\n }\n\n var token = _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].getObject('keep-logged-in') ? _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].getObject('auth-token') : undefined;\n var parsedNav = _lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].parseUrlHash(window.location.hash);\n\n if (token) {\n token.expires = new Date(token.expires);\n this.tinode.setAuthToken(token);\n this.tinode.connect().catch(function (err) {\n _this2.handleError(err.message, 'err');\n });\n delete parsedNav.params.info;\n delete parsedNav.params.tab;\n parsedNav.path[0] = '';\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].composeUrlHash(parsedNav.path, parsedNav.params));\n } else if (!parsedNav.params.token) {\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].navigateTo('');\n }\n\n this.readTimer = null;\n this.readTimerCallback = null;\n this.handleHashRoute();\n }\n }, {\n key: \"componentWillUnmount\",\n value: function componentWillUnmount() {\n window.removeEventListener('resize', this.handleResize);\n window.removeEventListener('hashchange', this.handleHashRoute);\n document.removeEventListener('visibilitychange', this.handleVisibilityEvent);\n }\n }, {\n key: \"handleResize\",\n value: function handleResize() {\n var mobile = document.documentElement.clientWidth <= _config_js__WEBPACK_IMPORTED_MODULE_10__[\"MEDIA_BREAKPOINT\"];\n this.setState({\n viewportWidth: document.documentElement.clientWidth\n });\n\n if (this.state.displayMobile != mobile) {\n this.setState({\n displayMobile: mobile\n });\n }\n }\n }, {\n key: \"handleHashRoute\",\n value: function handleHashRoute() {\n var hash = _lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].parseUrlHash(window.location.hash);\n\n if (hash.path && hash.path.length > 0) {\n if (['register', 'settings', 'edit', 'cred', 'reset', 'newtpk', 'contacts', ''].includes(hash.path[0])) {\n this.setState({\n sidePanelSelected: hash.path[0]\n });\n } else {\n console.log(\"Unknown sidepanel view\", hash.path[0]);\n }\n\n if (hash.path.length > 1 && hash.path[1] != this.state.topicSelected) {\n this.setState({\n topicSelected: tinode_sdk__WEBPACK_IMPORTED_MODULE_5___default.a.topicType(hash.path[1]) ? hash.path[1] : null\n });\n }\n } else {\n this.setState({\n sidePanelSelected: ''\n });\n }\n\n if (hash.params.method) {\n this.setState({\n credMethod: hash.params.method\n });\n }\n\n if (hash.params.code) {\n this.setState({\n credCode: hash.params.code\n });\n }\n\n this.setState({\n showInfoPanel: hash.params.info,\n newTopicTabSelected: hash.params.tab\n });\n }\n }, {\n key: \"handleOnline\",\n value: function handleOnline(online) {\n var newState = {\n liveConnection: online\n };\n\n if (online) {\n this.handleError('', null);\n } else {\n this.handleError(\"No connection\", 'warn');\n }\n\n this.setState({\n liveConnection: online\n });\n }\n }, {\n key: \"handleAppVisibility\",\n value: function handleAppVisibility(visible, callback) {\n clearTimeout(this.readTimer);\n this.readTimerCallback = callback;\n\n if (visible && callback) {\n this.readTimer = setTimeout(callback, _config_js__WEBPACK_IMPORTED_MODULE_10__[\"READ_DELAY\"]);\n } else {\n this.readTimer = null;\n }\n }\n }, {\n key: \"handleReadTimer\",\n value: function handleReadTimer(callback) {\n this.handleAppVisibility(!document.hidden, callback);\n }\n }, {\n key: \"handleVisibilityEvent\",\n value: function handleVisibilityEvent() {\n this.handleAppVisibility(!document.hidden, this.readTimerCallback);\n }\n }, {\n key: \"handleError\",\n value: function handleError(err, level) {\n this.setState({\n errorText: err,\n errorLevel: level\n });\n }\n }, {\n key: \"handleLoginRequest\",\n value: function handleLoginRequest(login, password) {\n var _this3 = this;\n\n this.setState({\n loginDisabled: true,\n login: login,\n password: password\n });\n this.handleError('', null);\n\n if (this.tinode.isConnected()) {\n this.doLogin(login, password, {\n meth: this.state.credMethod,\n resp: this.state.credCode\n });\n } else {\n this.tinode.connect().catch(function (err) {\n _this3.setState({\n loginDisabled: false\n });\n\n _this3.handleError(err.message, 'err');\n });\n }\n }\n }, {\n key: \"handleConnected\",\n value: function handleConnected() {\n var params = this.tinode.getServerInfo();\n this.setState({\n serverVersion: params.ver + ' ' + (params.build ? params.build : 'none') + '; '\n });\n this.doLogin(this.state.login, this.state.password, {\n meth: this.state.credMethod,\n resp: this.state.credCode\n });\n }\n }, {\n key: \"doLogin\",\n value: function doLogin(login, password, cred) {\n var _this4 = this;\n\n if (this.tinode.isAuthenticated()) {\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].navigateTo('');\n return;\n }\n\n cred = tinode_sdk__WEBPACK_IMPORTED_MODULE_5___default.a.credential(cred);\n var promise = null;\n var token = this.tinode.getAuthToken();\n\n if (login && password) {\n this.setState({\n password: null\n });\n promise = this.tinode.loginBasic(login, password, cred);\n } else if (token) {\n promise = this.tinode.loginToken(token.token, cred);\n }\n\n if (promise) {\n promise.then(function (ctrl) {\n if (ctrl.code >= 300 && ctrl.text === 'validate credentials') {\n if (cred) {\n _this4.handleError(\"Code does not match\", 'warn');\n }\n\n _this4.handleCredentialsRequest(ctrl.params);\n } else {\n _this4.handleLoginSuccessful();\n }\n }).catch(function (err) {\n _this4.setState({\n loginDisabled: false,\n credMethod: undefined,\n credCode: undefined\n });\n\n _this4.handleError(err.message, 'err');\n\n localStorage.removeItem('auth-token');\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].navigateTo('');\n });\n } else {\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].navigateTo('');\n this.setState({\n loginDisabled: false\n });\n }\n }\n }, {\n key: \"handleCredentialsRequest\",\n value: function handleCredentialsRequest(params) {\n var parsed = _lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].parseUrlHash(window.location.hash);\n parsed.path[0] = 'cred';\n parsed.params['method'] = params.cred[0];\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].composeUrlHash(parsed.path, parsed.params));\n }\n }, {\n key: \"handleLoginSuccessful\",\n value: function handleLoginSuccessful() {\n var _this5 = this;\n\n this.handleError('', null);\n\n if (_lib_local_storage_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].getObject('keep-logged-in')) {\n _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].setObject('auth-token', this.tinode.getAuthToken());\n }\n\n var me = this.tinode.getMeTopic();\n me.onMetaDesc = this.tnMeMetaDesc;\n me.onContactUpdate = this.tnMeContactUpdate;\n me.onSubsUpdated = this.tnMeSubsUpdated;\n this.setState({\n connected: true,\n credMethod: undefined,\n credCode: undefined,\n myUserId: this.tinode.getCurrentUserID()\n });\n me.subscribe(me.startMetaQuery().withLaterSub().withDesc().build()).catch(function (err) {\n localStorage.removeItem('auth-token');\n\n _this5.handleError(err.message, 'err');\n\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].navigateTo('');\n });\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].setUrlSidePanel(window.location.hash, 'contacts'));\n }\n }, {\n key: \"handleDisconnect\",\n value: function handleDisconnect(err) {\n this.setState({\n connected: false,\n topicSelectedOnline: false,\n dialogSelected: null,\n errorText: err && err.message ? err.message : \"Disconnected\",\n errorLevel: err && err.message ? 'err' : 'warn',\n loginDisabled: false,\n contextMenuVisible: false,\n serverVersion: \"no connection\"\n });\n }\n }, {\n key: \"tnMeMetaDesc\",\n value: function tnMeMetaDesc(desc) {\n if (desc && desc.public) {\n this.setState({\n sidePanelTitle: desc.public.fn,\n sidePanelAvatar: Object(_lib_blob_helpers_js__WEBPACK_IMPORTED_MODULE_11__[\"makeImageUrl\"])(desc.public.photo)\n });\n }\n }\n }, {\n key: \"tnMeContactUpdate\",\n value: function tnMeContactUpdate(what, cont) {\n if (what == 'on' || what == 'off') {\n this.resetContactList();\n\n if (this.state.topicSelected == cont.topic) {\n this.setState({\n topicSelectedOnline: what == 'on'\n });\n }\n } else if (what == 'read') {\n this.resetContactList();\n } else if (what == 'msg') {\n if (this.state.topicSelected != cont.topic) {\n if (this.state.messageSounds) {\n POP_SOUND.play();\n }\n\n this.resetContactList();\n } else if (document.hidden && this.state.messageSounds) {\n POP_SOUND.play();\n }\n } else if (what == 'recv') {} else if (what == 'gone' || what == 'unsub') {\n if (this.state.topicSelected == cont.topic) {\n this.handleTopicSelected(null);\n }\n\n this.resetContactList();\n } else if (what == 'acs') {\n if (this.state.topicSelected == cont.topic) {\n this.setState({\n topicSelectedAcs: cont.acs\n });\n }\n } else if (what == 'del') {} else {\n console.log(\"Unsupported (yet) presence update:\" + what + \" in: \" + cont.topic);\n }\n }\n }, {\n key: \"tnMeSubsUpdated\",\n value: function tnMeSubsUpdated(unused) {\n this.resetContactList();\n }\n }, {\n key: \"resetContactList\",\n value: function resetContactList() {\n var _this6 = this;\n\n var newState = {\n chatList: []\n };\n this.tinode.getMeTopic().contacts(function (c) {\n newState.chatList.push(c);\n\n if (_this6.state.topicSelected == c.topic) {\n newState.topicSelectedOnline = c.online;\n newState.topicSelectedAcs = c.acs;\n }\n });\n newState.searchableContacts = TinodeWeb.prepareSearchableContacts(newState.chatList, this.state.searchResults);\n this.setState(newState);\n }\n }, {\n key: \"tnData\",\n value: function tnData(data) {\n var _this7 = this;\n\n var topic = this.tinode.getTopic(data.topic);\n\n if (topic.msgStatus(data) >= tinode_sdk__WEBPACK_IMPORTED_MODULE_5___default.a.MESSAGE_STATUS_SENT) {\n clearTimeout(this.receivedTimer);\n this.receivedTimer = setTimeout(function () {\n _this7.receivedTimer = undefined;\n topic.noteRecv(data.seq);\n }, _config_js__WEBPACK_IMPORTED_MODULE_10__[\"RECEIVED_DELAY\"]);\n }\n }\n }, {\n key: \"tnInitFind\",\n value: function tnInitFind() {\n var _this8 = this;\n\n var fnd = this.tinode.getFndTopic();\n\n if (fnd.isSubscribed()) {\n this.tnFndSubsUpdated();\n } else {\n fnd.onSubsUpdated = this.tnFndSubsUpdated;\n fnd.subscribe(fnd.startMetaQuery().withSub().withTags().build()).catch(function (err) {\n _this8.handleError(err.message, 'err');\n });\n }\n }\n }, {\n key: \"tnFndSubsUpdated\",\n value: function tnFndSubsUpdated() {\n var foundContacts = [];\n this.tinode.getFndTopic().contacts(function (s) {\n foundContacts.push(s);\n });\n this.setState({\n searchResults: foundContacts,\n searchableContacts: TinodeWeb.prepareSearchableContacts(this.state.chatList, foundContacts)\n });\n }\n }, {\n key: \"handleSearchContacts\",\n value: function handleSearchContacts(query) {\n var _this9 = this;\n\n var fnd = this.tinode.getFndTopic();\n fnd.setMeta({\n desc: {\n public: query\n }\n }).then(function (ctrl) {\n return fnd.getMeta(fnd.startMetaQuery().withSub().build());\n }).catch(function (err) {\n _this9.handleError(err.message, 'err');\n });\n }\n }, {\n key: \"handleTopicSelected\",\n value: function handleTopicSelected(topicName, unused_index, online, acs) {\n if (topicName) {\n this.setState({\n errorText: '',\n errorLevel: null,\n mobilePanel: 'topic-view',\n showInfoPanel: false\n });\n\n if (this.state.topicSelected != topicName) {\n this.setState({\n topicSelectedOnline: online,\n topicSelectedAcs: acs\n });\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].setUrlTopic('', topicName));\n }\n } else {\n this.setState({\n errorText: '',\n errorLevel: null,\n mobilePanel: 'sidepanel',\n topicSelectedOnline: false,\n topicSelectedAcs: null,\n showInfoPanel: false\n });\n\n if (this.state.topicSelected) {\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].setUrlTopic('', null));\n }\n }\n }\n }, {\n key: \"handleHideMessagesView\",\n value: function handleHideMessagesView() {\n this.setState({\n mobilePanel: 'sidepanel'\n });\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].setUrlTopic(window.location.hash, null));\n }\n }, {\n key: \"handleSendMessage\",\n value: function handleSendMessage(msg, promise, uploader) {\n var _this10 = this;\n\n var topic = this.tinode.getTopic(this.state.topicSelected);\n msg = topic.createMessage(msg, false);\n msg._uploader = uploader;\n\n if (!topic.isSubscribed()) {\n if (!promise) {\n promise = Promise.resolve();\n }\n\n promise = promise.then(function () {\n return topic.subscribe();\n });\n }\n\n if (promise) {\n promise = promise.catch(function (err) {\n _this10.handleError(err.message, 'err');\n });\n }\n\n topic.publishDraft(msg, promise).catch(function (err) {\n _this10.handleError(err.message, 'err');\n });\n }\n }, {\n key: \"handleNewAccount\",\n value: function handleNewAccount() {\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].setUrlSidePanel(window.location.hash, 'register'));\n }\n }, {\n key: \"handleNewAccountRequest\",\n value: function handleNewAccountRequest(login_, password_, public_, cred_, tags_) {\n var _this11 = this;\n\n this.tinode.connect(this.state.serverAddress).then(function () {\n return _this11.tinode.createAccountBasic(login_, password_, {\n public: public_,\n tags: tags_,\n cred: tinode_sdk__WEBPACK_IMPORTED_MODULE_5___default.a.credential(cred_)\n });\n }).then(function (ctrl) {\n if (ctrl.code >= 300 && ctrl.text == 'validate credentials') {\n _this11.handleCredentialsRequest(ctrl.params);\n } else {\n _this11.handleLoginSuccessful(_this11);\n }\n }).catch(function (err) {\n _this11.handleError(err.message, 'err');\n });\n }\n }, {\n key: \"handleUpdateAccountRequest\",\n value: function handleUpdateAccountRequest(password, pub, defacs) {\n var _this12 = this;\n\n if (pub || defacs) {\n this.tinode.getMeTopic().setMeta({\n desc: {\n public: pub,\n defacs: defacs\n }\n }).catch(function (err) {\n _this12.handleError(err.message, 'err');\n });\n }\n\n if (password) {\n this.tinode.updateAccountBasic(null, this.tinode.getCurrentLogin(), password).catch(function (err) {\n _this12.handleError(err.message, 'err');\n });\n }\n }\n }, {\n key: \"handleUpdateAccountTagsRequest\",\n value: function handleUpdateAccountTagsRequest(tags) {\n var _this13 = this;\n\n this.tinode.getFndTopic().setMeta({\n tags: tags\n }).catch(function (err) {\n _this13.handleError(err.message, 'err');\n });\n }\n }, {\n key: \"handleSettings\",\n value: function handleSettings() {\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].setUrlSidePanel(window.location.hash, this.state.myUserId ? 'edit' : 'settings'));\n }\n }, {\n key: \"handleGlobalSettings\",\n value: function handleGlobalSettings(settings) {\n var serverAddress = settings.serverAddress || this.state.serverAddress;\n var transport = settings.transport || this.state.transport;\n\n if (this.tinode) {\n this.tinode.onDisconnect = undefined;\n this.tinode.disconnect();\n }\n\n this.tinode = TinodeWeb.tnSetup(serverAddress, transport);\n this.tinode.onConnect = this.handleConnected;\n this.tinode.onDisconnect = this.handleDisconnect;\n this.setState({\n serverAddress: serverAddress,\n transport: transport\n });\n _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].setObject('settings', {\n serverAddress: serverAddress,\n transport: transport\n });\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].setUrlSidePanel(window.location.hash, ''));\n }\n }, {\n key: \"initDesktopAlerts\",\n value: function initDesktopAlerts() {\n var _this14 = this;\n\n this.fbPush.onTokenRefresh(function () {\n _this14.requestPushToken(true);\n });\n this.fbPush.onMessage(function (payload) {});\n }\n }, {\n key: \"togglePushToken\",\n value: function togglePushToken(enabled) {\n var _this15 = this;\n\n if (enabled) {\n if (!this.state.firebaseToken) {\n this.fbPush.requestPermission().then(function () {\n _this15.requestPushToken(true);\n }).catch(function (err) {\n _this15.handleError(err.message, 'err');\n\n _this15.setState({\n desktopAlerts: false,\n firebaseToken: null\n });\n\n _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].updateObject('settings', {\n desktopAlerts: false\n });\n console.log(\"Failed to get permission to notify.\", err);\n });\n } else {\n this.setState({\n desktopAlerts: true\n });\n _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].updateObject('settings', {\n desktopAlerts: true\n });\n }\n } else if (this.state.firebaseToken) {\n this.fbPush.deleteToken(this.state.firebaseToken).catch(function (err) {\n console.log(\"Unable to delete token.\", err);\n }).finally(function () {\n _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].updateObject('settings', {\n desktopAlerts: false\n });\n localStorage.removeItem('firebase-token');\n\n _this15.setState({\n desktopAlerts: false,\n firebaseToken: null\n });\n });\n } else {\n this.setState({\n desktopAlerts: false,\n firebaseToken: null\n });\n _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].updateObject('settings', {\n desktopAlerts: false\n });\n }\n }\n }, {\n key: \"requestPushToken\",\n value: function requestPushToken(sendToServer) {\n var _this16 = this;\n\n this.fbPush.getToken().then(function (refreshedToken) {\n if (refreshedToken != _this16.state.firebaseToken) {\n _this16.tinode.setDeviceToken(refreshedToken, sendToServer);\n\n _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].setObject('firebase-token', refreshedToken);\n }\n\n _this16.setState({\n firebaseToken: refreshedToken,\n desktopAlerts: true\n });\n\n _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].updateObject('settings', {\n desktopAlerts: true\n });\n }).catch(function (err) {\n _this16.handleError(err.message, 'err');\n\n console.log(\"Failed to retrieve firebase token\", err);\n });\n }\n }, {\n key: \"handleToggleMessageSounds\",\n value: function handleToggleMessageSounds(enabled) {\n this.setState({\n messageSounds: enabled\n });\n _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_13__[\"default\"].updateObject('settings', {\n messageSoundsOff: !enabled\n });\n }\n }, {\n key: \"handleSidepanelCancel\",\n value: function handleSidepanelCancel() {\n var parsed = _lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].parseUrlHash(window.location.hash);\n parsed.path[0] = this.state.myUserId ? 'contacts' : '';\n\n if (parsed.params) {\n delete parsed.params.code;\n delete parsed.params.method;\n delete parsed.params.tab;\n }\n\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].composeUrlHash(parsed.path, parsed.params));\n this.setState({\n errorText: '',\n errorLevel: null\n });\n }\n }, {\n key: \"handleNewTopic\",\n value: function handleNewTopic() {\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].setUrlSidePanel(window.location.hash, 'newtpk'));\n }\n }, {\n key: \"handleNewTopicRequest\",\n value: function handleNewTopicRequest(peerName, pub, priv, tags) {\n var _this17 = this;\n\n var topicName = peerName || this.tinode.newGroupTopicName();\n\n if (!peerName) {\n this.setState({\n newGroupTopicParams: {\n desc: {\n public: pub,\n private: {\n comment: priv\n }\n },\n tags: tags\n }\n }, function () {\n _this17.handleTopicSelected(topicName);\n });\n } else {\n this.handleTopicSelected(topicName);\n }\n }\n }, {\n key: \"handleNewTopicCreated\",\n value: function handleNewTopicCreated(oldName, newName) {\n if (this.state.topicSelected == oldName && oldName != newName) {\n this.setState({\n topicSelected: newName\n }, function () {\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].setUrlTopic('', newName));\n });\n }\n }\n }, {\n key: \"handleTopicUpdateRequest\",\n value: function handleTopicUpdateRequest(topicName, pub, priv, permissions) {\n var _this18 = this;\n\n var topic = this.tinode.getTopic(topicName);\n\n if (topic) {\n var params = {};\n\n if (pub) {\n params.public = pub;\n }\n\n if (priv) {\n params.private = {\n comment: priv\n };\n }\n\n if (permissions) {\n params.defacs = permissions;\n }\n\n topic.setMeta({\n desc: params\n }).catch(function (err) {\n _this18.handleError(err.message, 'err');\n });\n }\n }\n }, {\n key: \"handleChangePermissions\",\n value: function handleChangePermissions(topicName, mode, uid) {\n var _this19 = this;\n\n var topic = this.tinode.getTopic(topicName);\n\n if (topic) {\n var am = topic.getAccessMode();\n\n if (uid) {\n am.updateGiven(mode);\n mode = am.getGiven();\n } else {\n am.updateWant(mode);\n mode = am.getWant();\n }\n\n topic.setMeta({\n sub: {\n user: uid,\n mode: mode\n }\n }).catch(function (err) {\n _this19.handleError(err.message, 'err');\n });\n }\n }\n }, {\n key: \"handleTagsUpdated\",\n value: function handleTagsUpdated(topicName, tags) {\n var _this20 = this;\n\n var topic = this.tinode.getTopic(topicName);\n\n if (topic) {\n var instance = this;\n topic.setMeta({\n tags: tags\n }).catch(function (err) {\n _this20.handleError(err.message, 'err');\n });\n }\n }\n }, {\n key: \"handleLogout\",\n value: function handleLogout() {\n Object(_lib_utils_js__WEBPACK_IMPORTED_MODULE_15__[\"updateFavicon\"])(0);\n localStorage.removeItem('auth-token');\n\n if (this.tinode) {\n this.tinode.onDisconnect = undefined;\n this.tinode.disconnect();\n }\n\n this.setState(this.getBlankState());\n this.tinode = TinodeWeb.tnSetup(this.state.serverAddress, this.state.transport);\n this.tinode.onConnect = this.handleConnected;\n this.tinode.onDisconnect = this.handleDisconnect;\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].navigateTo('');\n }\n }, {\n key: \"handleLeaveUnsubRequest\",\n value: function handleLeaveUnsubRequest(topicName) {\n var _this21 = this;\n\n var topic = this.tinode.getTopic(topicName);\n\n if (!topic) {\n return;\n }\n\n topic.leave(true).then(function (ctrl) {\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].setUrlTopic(window.location.hash, ''));\n }).catch(function (err) {\n _this21.handleError(err.message, 'err');\n });\n }\n }, {\n key: \"handleDialogCancel\",\n value: function handleDialogCancel() {\n this.setState({\n dialogSelected: null\n });\n }\n }, {\n key: \"handleShowContextMenu\",\n value: function handleShowContextMenu(params, menuItems) {\n this.setState({\n contextMenuVisible: true,\n contextMenuClickAt: {\n x: params.x,\n y: params.y\n },\n contextMenuParams: params,\n contextMenuItems: menuItems || this.defaultTopicContextMenu(params.topicName),\n contextMenuBounds: react_dom__WEBPACK_IMPORTED_MODULE_1___default.a.findDOMNode(this).getBoundingClientRect()\n });\n }\n }, {\n key: \"defaultTopicContextMenu\",\n value: function defaultTopicContextMenu(topicName) {\n var topic = this.tinode.getTopic(topicName);\n var formatMessage = this.props.intl.formatMessage;\n var muted = false,\n blocked = false,\n subscribed = false,\n deleter = false;\n\n if (topic) {\n if (topic.isSubscribed()) {\n subscribed = true;\n var acs = topic.getAccessMode();\n muted = acs && acs.isMuted();\n blocked = acs && !acs.isJoiner();\n deleter = acs && acs.isDeleter();\n }\n }\n\n return [subscribed ? {\n title: formatMessage({\n id: 'menu_item_info'\n }),\n handler: this.handleShowInfoView\n } : null, subscribed ? 'messages_clear' : null, subscribed && deleter ? 'messages_clear_hard' : null, subscribed ? muted ? 'topic_unmute' : 'topic_mute' : null, subscribed ? blocked ? 'topic_unblock' : 'topic_block' : null, 'topic_delete'];\n }\n }, {\n key: \"handleHideContextMenu\",\n value: function handleHideContextMenu() {\n this.setState({\n contextMenuVisible: false,\n contextMenuClickAt: null,\n contextMenuParams: null,\n contextMenuBounds: null\n });\n }\n }, {\n key: \"handleShowInfoView\",\n value: function handleShowInfoView() {\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].addUrlParam(window.location.hash, 'info', true));\n this.setState({\n showInfoPanel: true\n });\n }\n }, {\n key: \"handleHideInfoView\",\n value: function handleHideInfoView() {\n _lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].removeUrlParam(window.location.hash, 'info'));\n this.setState({\n showInfoPanel: false\n });\n }\n }, {\n key: \"handleMemberUpdateRequest\",\n value: function handleMemberUpdateRequest(topicName, added, removed) {\n var _this22 = this;\n\n if (!topicName) {\n return;\n }\n\n var topic = this.tinode.getTopic(topicName);\n\n if (!topic) {\n return;\n }\n\n if (added && added.length > 0) {\n added.map(function (uid) {\n topic.invite(uid, null).catch(function (err) {\n _this22.handleError(err.message, 'err');\n });\n });\n }\n\n if (removed && removed.length > 0) {\n removed.map(function (uid) {\n topic.delSubscription(uid).catch(function (err) {\n _this22.handleError(err.message, 'err');\n });\n });\n }\n }\n }, {\n key: \"handleValidateCredentialsRequest\",\n value: function handleValidateCredentialsRequest(cred, code) {\n this.setState({\n credMethod: cred,\n credCode: code\n });\n this.doLogin(null, null, {\n meth: cred,\n resp: code\n });\n }\n }, {\n key: \"handlePasswordResetRequest\",\n value: function handlePasswordResetRequest(method, value) {\n var _this23 = this;\n\n this.tinode.connect().then(function () {\n return _this23.tinode.requestResetAuthSecret('basic', method, value);\n }).catch(function (err) {\n _this23.handleError(err.message, 'err');\n });\n }\n }, {\n key: \"handleResetPassword\",\n value: function handleResetPassword(scheme, newPassword, token) {\n var _this24 = this;\n\n token = base64ReEncode(token);\n\n if (!token) {\n this.handleError(\"Invalid security token\", 'err');\n } else {\n this.tinode.connect().then(function () {\n return _this24.tinode.updateAccountBasic(null, null, newPassword, {\n token: token\n });\n }).catch(function (err) {\n _this24.handleError(err.message, 'err');\n });\n }\n }\n }, {\n key: \"render\",\n value: function render() {\n return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n id: \"app-container\"\n }, this.state.contextMenuVisible ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_widgets_context_menu_jsx__WEBPACK_IMPORTED_MODULE_6__[\"default\"], {\n tinode: this.tinode,\n bounds: this.state.contextMenuBounds,\n clickAt: this.state.contextMenuClickAt,\n params: this.state.contextMenuParams,\n items: this.state.contextMenuItems,\n hide: this.handleHideContextMenu,\n onAction: this.handleContextMenuAction,\n onError: this.handleError\n }) : null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_sidepanel_view_jsx__WEBPACK_IMPORTED_MODULE_9__[\"default\"], {\n tinode: this.tinode,\n connected: this.state.connected,\n displayMobile: this.state.displayMobile,\n hideSelf: this.state.displayMobile && this.state.mobilePanel !== 'sidepanel',\n state: this.state.sidePanelSelected,\n title: this.state.sidePanelTitle,\n avatar: this.state.sidePanelAvatar,\n login: this.state.login,\n myUserId: this.state.myUserId,\n loginDisabled: this.state.loginDisabled,\n errorText: this.state.errorText,\n errorLevel: this.state.errorLevel,\n topicSelected: this.state.topicSelected,\n chatList: this.state.chatList,\n credMethod: this.state.credMethod,\n credCode: this.state.credCode,\n transport: this.state.transport,\n messageSounds: this.state.messageSounds,\n desktopAlerts: this.state.desktopAlerts,\n desktopAlertsEnabled: this.state.desktopAlertsEnabled,\n serverAddress: this.state.serverAddress,\n onGlobalSettings: this.handleGlobalSettings,\n onSignUp: this.handleNewAccount,\n onSettings: this.handleSettings,\n onLoginRequest: this.handleLoginRequest,\n onCreateAccount: this.handleNewAccountRequest,\n onUpdateAccount: this.handleUpdateAccountRequest,\n onUpdateAccountTags: this.handleUpdateAccountTagsRequest,\n onTogglePushNotifications: this.togglePushToken,\n onToggleMessageSounds: this.handleToggleMessageSounds,\n onTopicSelected: this.handleTopicSelected,\n onCreateTopic: this.handleNewTopicRequest,\n onNewTopic: this.handleNewTopic,\n onLogout: this.handleLogout,\n onCancel: this.handleSidepanelCancel,\n onError: this.handleError,\n onValidateCredentials: this.handleValidateCredentialsRequest,\n onPasswordResetRequest: this.handlePasswordResetRequest,\n onResetPassword: this.handleResetPassword,\n onInitFind: this.tnInitFind,\n searchResults: this.state.searchResults,\n onSearchContacts: this.handleSearchContacts,\n showContextMenu: this.handleShowContextMenu\n }), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_messages_view_jsx__WEBPACK_IMPORTED_MODULE_8__[\"default\"], {\n tinode: this.tinode,\n connected: this.state.connected,\n online: this.state.topicSelectedOnline,\n acs: this.state.topicSelectedAcs,\n displayMobile: this.state.displayMobile,\n viewportWidth: this.state.viewportWidth,\n hideSelf: this.state.displayMobile && (this.state.mobilePanel !== 'topic-view' || this.state.showInfoPanel),\n topic: this.state.topicSelected,\n myUserId: this.state.myUserId,\n serverVersion: this.state.serverVersion,\n serverAddress: this.state.serverAddress,\n errorText: this.state.errorText,\n errorLevel: this.state.errorLevel,\n newGroupTopicParams: this.state.newGroupTopicParams,\n onHideMessagesView: this.handleHideMessagesView,\n onData: this.tnData,\n onError: this.handleError,\n onNewTopicCreated: this.handleNewTopicCreated,\n readTimerHandler: this.handleReadTimer,\n showContextMenu: this.handleShowContextMenu,\n sendMessage: this.handleSendMessage\n }), this.state.showInfoPanel ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_info_view_jsx__WEBPACK_IMPORTED_MODULE_7__[\"default\"], {\n tinode: this.tinode,\n connected: this.state.connected,\n displayMobile: this.state.displayMobile,\n topic: this.state.topicSelected,\n searchableContacts: this.state.searchableContacts,\n myUserId: this.state.myUserId,\n errorText: this.state.errorText,\n errorLevel: this.state.errorLevel,\n onTopicDescUpdate: this.handleTopicUpdateRequest,\n onCancel: this.handleHideInfoView,\n onChangePermissions: this.handleChangePermissions,\n onMemberUpdateRequest: this.handleMemberUpdateRequest,\n onLeaveTopic: this.handleLeaveUnsubRequest,\n onAddMember: this.handleManageGroupMembers,\n onTopicTagsUpdate: this.handleTagsUpdated,\n onInitFind: this.tnInitFind,\n onError: this.handleError,\n showContextMenu: this.handleShowContextMenu\n }) : null);\n }\n }], [{\n key: \"tnSetup\",\n value: function tnSetup(serverAddress, transport) {\n var tinode = new tinode_sdk__WEBPACK_IMPORTED_MODULE_5___default.a(_config_js__WEBPACK_IMPORTED_MODULE_10__[\"APP_NAME\"], serverAddress, _config_js__WEBPACK_IMPORTED_MODULE_10__[\"API_KEY\"], transport, Object(_lib_host_name_js__WEBPACK_IMPORTED_MODULE_12__[\"isSecureConnection\"])());\n tinode.enableLogging(true, true);\n return tinode;\n }\n }, {\n key: \"prepareSearchableContacts\",\n value: function prepareSearchableContacts(chatList, foundContacts) {\n var merged = {};\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = chatList[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var c = _step.value;\n\n if (tinode_sdk__WEBPACK_IMPORTED_MODULE_5___default.a.topicType(c.topic) == 'p2p') {\n merged[c.topic] = {\n user: c.topic,\n updated: c.updated,\n public: c.public,\n private: c.private,\n acs: c.acs\n };\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = foundContacts[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var _c = _step2.value;\n\n if (!merged[_c.user]) {\n merged[_c.user] = _c;\n }\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n return Object.values(merged);\n }\n }]);\n\n return TinodeWeb;\n}(react__WEBPACK_IMPORTED_MODULE_0___default.a.Component);\n\n;\n/* harmony default export */ __webpack_exports__[\"default\"] = (Object(react_intl__WEBPACK_IMPORTED_MODULE_2__[\"injectIntl\"])(TinodeWeb));\n\n//# sourceURL=webpack:///./src/views/tinode-web.jsx?"); /***/ }), @@ -1043,7 +1043,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return ContextMenu; });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ \"./node_modules/react-dom/index.js\");\n/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _config_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../config.js */ \"./src/config.js\");\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _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); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\n\n\n\n\nvar ContextMenu = function (_React$Component) {\n _inherits(ContextMenu, _React$Component);\n\n function ContextMenu(props) {\n var _this;\n\n _classCallCheck(this, ContextMenu);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(ContextMenu).call(this, props));\n _this.handlePageClick = _this.handlePageClick.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleEscapeKey = _this.handleEscapeKey.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleClick = _this.handleClick.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.MenuItems = {\n 'topic_info': {\n title: \"Info\",\n handler: null\n },\n 'messages_clear': {\n title: \"Clear messages\",\n handler: function handler(params, errorHandler) {\n _this.deleteMessages(true, false, params, errorHandler);\n }\n },\n 'messages_clear_hard': {\n title: \"Clear for All\",\n handler: function handler(params, errorHandler) {\n _this.deleteMessages(true, true, params, errorHandler);\n }\n },\n 'message_delete': {\n title: \"Delete\",\n handler: function handler(params, errorHandler) {\n _this.deleteMessages(false, false, params, errorHandler);\n }\n },\n 'message_delete_hard': {\n title: \"Delete for All\",\n handler: function handler(params, errorHandler) {\n _this.deleteMessages(false, true, params, errorHandler);\n }\n },\n 'topic_unmute': {\n title: \"Unmute\",\n handler: _this.topicPermissionSetter.bind(_assertThisInitialized(_assertThisInitialized(_this)), '+P')\n },\n 'topic_mute': {\n title: \"Mute\",\n handler: _this.topicPermissionSetter.bind(_assertThisInitialized(_assertThisInitialized(_this)), '-P')\n },\n 'topic_unblock': {\n title: \"Unblock\",\n handler: _this.topicPermissionSetter.bind(_assertThisInitialized(_assertThisInitialized(_this)), '+J')\n },\n 'topic_block': {\n title: \"Block\",\n handler: _this.topicPermissionSetter.bind(_assertThisInitialized(_assertThisInitialized(_this)), '-J')\n },\n 'topic_delete': {\n title: \"Delete\",\n handler: function handler(params, errorHandler) {\n var topic = _this.props.tinode.getTopic(params.topicName);\n\n if (!topic) {\n console.log(\"Topic not found: \", params.topicName);\n return;\n }\n\n topic.delTopic().catch(function (err) {\n if (errorHandler) {\n errorHandler(err.message, 'err');\n }\n });\n }\n },\n 'permissions': {\n title: \"Edit permissions\",\n handler: null\n },\n 'member_delete': {\n title: \"Remove\",\n handler: function handler(params, errorHandler) {\n var topic = _this.props.tinode.getTopic(params.topicName);\n\n if (!topic || !params.user) {\n console.log(\"Topic or user not found: '\" + params.topicName + \"', '\" + params.user + \"'\");\n return;\n }\n\n topic.delSubscription(params.user).catch(function (err) {\n if (errorHandler) {\n errorHandler(err.message, 'err');\n }\n });\n }\n },\n 'member_mute': {\n title: \"Mute\",\n handler: _this.topicPermissionSetter.bind(_assertThisInitialized(_assertThisInitialized(_this)), '-P')\n },\n 'member_unmute': {\n title: \"Unmute\",\n handler: _this.topicPermissionSetter.bind(_assertThisInitialized(_assertThisInitialized(_this)), '+P')\n },\n 'member_block': {\n title: \"Block\",\n handler: _this.topicPermissionSetter.bind(_assertThisInitialized(_assertThisInitialized(_this)), '-J')\n },\n 'member_unblock': {\n title: \"Unblock\",\n handler: _this.topicPermissionSetter.bind(_assertThisInitialized(_assertThisInitialized(_this)), '+J')\n }\n };\n return _this;\n }\n\n _createClass(ContextMenu, [{\n key: \"componentDidMount\",\n value: function componentDidMount() {\n document.addEventListener('mousedown', this.handlePageClick, false);\n document.addEventListener('keyup', this.handleEscapeKey, false);\n }\n }, {\n key: \"componentWillUnmount\",\n value: function componentWillUnmount() {\n document.removeEventListener('mousedown', this.handlePageClick, false);\n document.removeEventListener('keyup', this.handleEscapeKey, false);\n }\n }, {\n key: \"handlePageClick\",\n value: function handlePageClick(e) {\n if (react_dom__WEBPACK_IMPORTED_MODULE_1___default.a.findDOMNode(this).contains(e.target)) {\n return;\n }\n\n e.preventDefault();\n e.stopPropagation();\n this.props.hide();\n }\n }, {\n key: \"handleEscapeKey\",\n value: function handleEscapeKey(e) {\n if (e.keyCode === 27) {\n this.props.hide();\n }\n }\n }, {\n key: \"handleClick\",\n value: function handleClick(e) {\n e.preventDefault();\n e.stopPropagation();\n this.props.hide();\n var item = this.props.items[e.currentTarget.dataset.id];\n\n if (typeof item == 'string') {\n item = this.MenuItems[item];\n }\n\n item.handler(this.props.params, this.props.onError);\n }\n }, {\n key: \"deleteMessages\",\n value: function deleteMessages(all, hard, params, errorHandler) {\n var topic = this.props.tinode.getTopic(params.topicName);\n\n if (!topic) {\n console.log(\"Topic not found: \", params.topicName);\n return;\n }\n\n if (topic.cancelSend(params.seq)) {\n return Promise.resolve();\n }\n\n var promise = all ? topic.delMessagesAll(hard) : topic.delMessagesList([params.seq], hard);\n promise.catch(function (err) {\n if (errorHandler) {\n errorHandler(err.message, 'err');\n }\n });\n }\n }, {\n key: \"topicPermissionSetter\",\n value: function topicPermissionSetter(mode, params, errorHandler) {\n var topic = this.props.tinode.getTopic(params.topicName);\n\n if (!topic) {\n console.log(\"Topic not found\", params.topicName);\n return;\n }\n\n var am, user;\n\n if (params.user) {\n user = topic.subscriber(params.user);\n\n if (!user) {\n console.log(\"Subscriber not found\", params.topicName + \"[\" + params.user + \"]\");\n return;\n }\n\n am = user.acs.updateGiven(mode).getGiven();\n } else {\n am = topic.getAccessMode().updateWant(mode).getWant();\n }\n\n topic.setMeta({\n sub: {\n user: params.user,\n mode: am\n }\n }).catch(function (err) {\n if (errorHandler) {\n errorHandler(err.message, 'err');\n }\n });\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this2 = this;\n\n var count = 0;\n var menu = [];\n this.props.items.map(function (item) {\n if (typeof item == 'string') {\n item = _this2.MenuItems[item];\n }\n\n if (item && item.title) {\n menu.push(item.title == '-' ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"li\", {\n className: \"separator\",\n key: count\n }) : react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"li\", {\n onClick: _this2.handleClick,\n \"data-id\": count,\n key: count\n }, item.title));\n }\n\n count++;\n });\n var hSize = 12 * _config_js__WEBPACK_IMPORTED_MODULE_2__[\"REM_SIZE\"];\n var vSize = _config_js__WEBPACK_IMPORTED_MODULE_2__[\"REM_SIZE\"] * (0.7 + menu.length * 2.5);\n var left = this.props.bounds.right - this.props.clickAt.x < hSize ? this.props.clickAt.x - this.props.bounds.left - hSize : this.props.clickAt.x - this.props.bounds.left;\n var top = this.props.bounds.bottom - this.props.clickAt.y < vSize ? this.props.clickAt.y - this.props.bounds.top - vSize : this.props.clickAt.y - this.props.bounds.top;\n var position = {\n left: left + 'px',\n top: top + 'px'\n };\n return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"ul\", {\n className: \"menu\",\n style: position\n }, menu);\n }\n }]);\n\n return ContextMenu;\n}(react__WEBPACK_IMPORTED_MODULE_0___default.a.Component);\n\n\n\n//# sourceURL=webpack:///./src/widgets/context-menu.jsx?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ \"./node_modules/react-dom/index.js\");\n/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var react_intl__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-intl */ \"./node_modules/react-intl/lib/index.es.js\");\n/* harmony import */ var _config_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../config.js */ \"./src/config.js\");\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _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); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\n\n\n\n\nvar messages = Object(react_intl__WEBPACK_IMPORTED_MODULE_2__[\"defineMessages\"])({\n info: {\n \"id\": \"menu_item_info\",\n \"defaultMessage\": \"Info\"\n },\n clear_messages: {\n \"id\": \"menu_item_clear_messages\",\n \"defaultMessage\": \"Clear messages\"\n },\n clear_for_all: {\n \"id\": \"menu_item_clear_messages_for_all\",\n \"defaultMessage\": \"Clear for All\"\n },\n 'delete': {\n \"id\": \"menu_item_delete\",\n \"defaultMessage\": \"Delete\"\n },\n delete_for_all: {\n \"id\": \"menu_item_delete_for_all\",\n \"defaultMessage\": \"Delete for All\"\n },\n mute: {\n \"id\": \"menu_item_mute\",\n \"defaultMessage\": \"Mute\"\n },\n unmute: {\n \"id\": \"menu_item_unmute\",\n \"defaultMessage\": \"Unmute\"\n },\n topic_delete: {\n \"id\": \"menu_item_delete_topic\",\n \"defaultMessage\": \"Delete\"\n },\n unblock: {\n \"id\": \"menu_item_unblock\",\n \"defaultMessage\": \"Unblock\"\n },\n block: {\n \"id\": \"menu_item_block\",\n \"defaultMessage\": \"Block\"\n },\n member_delete: {\n \"id\": \"menu_item_member_delete\",\n \"defaultMessage\": \"Remove\"\n }\n});\n\nvar ContextMenu = function (_React$Component) {\n _inherits(ContextMenu, _React$Component);\n\n function ContextMenu(props) {\n var _this;\n\n _classCallCheck(this, ContextMenu);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(ContextMenu).call(this, props));\n var formatMessage = props.intl.formatMessage;\n _this.handlePageClick = _this.handlePageClick.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleEscapeKey = _this.handleEscapeKey.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.handleClick = _this.handleClick.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.MenuItems = {\n 'topic_info': {\n title: formatMessage(messages.info),\n handler: null\n },\n 'messages_clear': {\n title: formatMessage(messages.clear_messages),\n handler: function handler(params, errorHandler) {\n _this.deleteMessages(true, false, params, errorHandler);\n }\n },\n 'messages_clear_hard': {\n title: formatMessage(messages.clear_for_all),\n handler: function handler(params, errorHandler) {\n _this.deleteMessages(true, true, params, errorHandler);\n }\n },\n 'message_delete': {\n title: formatMessage(messages.delete),\n handler: function handler(params, errorHandler) {\n _this.deleteMessages(false, false, params, errorHandler);\n }\n },\n 'message_delete_hard': {\n title: formatMessage(messages.delete_for_all),\n handler: function handler(params, errorHandler) {\n _this.deleteMessages(false, true, params, errorHandler);\n }\n },\n 'topic_unmute': {\n title: formatMessage(messages.unmute),\n handler: _this.topicPermissionSetter.bind(_assertThisInitialized(_assertThisInitialized(_this)), '+P')\n },\n 'topic_mute': {\n title: formatMessage(messages.mute),\n handler: _this.topicPermissionSetter.bind(_assertThisInitialized(_assertThisInitialized(_this)), '-P')\n },\n 'topic_unblock': {\n title: formatMessage(messages.unblock),\n handler: _this.topicPermissionSetter.bind(_assertThisInitialized(_assertThisInitialized(_this)), '+J')\n },\n 'topic_block': {\n title: formatMessage(messages.block),\n handler: _this.topicPermissionSetter.bind(_assertThisInitialized(_assertThisInitialized(_this)), '-J')\n },\n 'topic_delete': {\n title: formatMessage(messages.topic_delete),\n handler: function handler(params, errorHandler) {\n var topic = _this.props.tinode.getTopic(params.topicName);\n\n if (!topic) {\n console.log(\"Topic not found: \", params.topicName);\n return;\n }\n\n topic.delTopic().catch(function (err) {\n if (errorHandler) {\n errorHandler(err.message, 'err');\n }\n });\n }\n },\n 'permissions': {\n title: formatMessage({\n id: 'menu_item_edit_permissions'\n }),\n handler: null\n },\n 'member_delete': {\n title: formatMessage(messages.member_delete),\n handler: function handler(params, errorHandler) {\n var topic = _this.props.tinode.getTopic(params.topicName);\n\n if (!topic || !params.user) {\n console.log(\"Topic or user not found: '\" + params.topicName + \"', '\" + params.user + \"'\");\n return;\n }\n\n topic.delSubscription(params.user).catch(function (err) {\n if (errorHandler) {\n errorHandler(err.message, 'err');\n }\n });\n }\n },\n 'member_mute': {\n title: formatMessage(messages.mute),\n handler: _this.topicPermissionSetter.bind(_assertThisInitialized(_assertThisInitialized(_this)), '-P')\n },\n 'member_unmute': {\n title: formatMessage(messages.unmute),\n handler: _this.topicPermissionSetter.bind(_assertThisInitialized(_assertThisInitialized(_this)), '+P')\n },\n 'member_block': {\n title: formatMessage(messages.block),\n handler: _this.topicPermissionSetter.bind(_assertThisInitialized(_assertThisInitialized(_this)), '-J')\n },\n 'member_unblock': {\n title: formatMessage(messages.unblock),\n handler: _this.topicPermissionSetter.bind(_assertThisInitialized(_assertThisInitialized(_this)), '+J')\n }\n };\n return _this;\n }\n\n _createClass(ContextMenu, [{\n key: \"componentDidMount\",\n value: function componentDidMount() {\n document.addEventListener('mousedown', this.handlePageClick, false);\n document.addEventListener('keyup', this.handleEscapeKey, false);\n }\n }, {\n key: \"componentWillUnmount\",\n value: function componentWillUnmount() {\n document.removeEventListener('mousedown', this.handlePageClick, false);\n document.removeEventListener('keyup', this.handleEscapeKey, false);\n }\n }, {\n key: \"handlePageClick\",\n value: function handlePageClick(e) {\n if (react_dom__WEBPACK_IMPORTED_MODULE_1___default.a.findDOMNode(this).contains(e.target)) {\n return;\n }\n\n e.preventDefault();\n e.stopPropagation();\n this.props.hide();\n }\n }, {\n key: \"handleEscapeKey\",\n value: function handleEscapeKey(e) {\n if (e.keyCode === 27) {\n this.props.hide();\n }\n }\n }, {\n key: \"handleClick\",\n value: function handleClick(e) {\n e.preventDefault();\n e.stopPropagation();\n this.props.hide();\n var item = this.props.items[e.currentTarget.dataset.id];\n\n if (typeof item == 'string') {\n item = this.MenuItems[item];\n }\n\n item.handler(this.props.params, this.props.onError);\n }\n }, {\n key: \"deleteMessages\",\n value: function deleteMessages(all, hard, params, errorHandler) {\n var topic = this.props.tinode.getTopic(params.topicName);\n\n if (!topic) {\n console.log(\"Topic not found: \", params.topicName);\n return;\n }\n\n if (topic.cancelSend(params.seq)) {\n return Promise.resolve();\n }\n\n var promise = all ? topic.delMessagesAll(hard) : topic.delMessagesList([params.seq], hard);\n promise.catch(function (err) {\n if (errorHandler) {\n errorHandler(err.message, 'err');\n }\n });\n }\n }, {\n key: \"topicPermissionSetter\",\n value: function topicPermissionSetter(mode, params, errorHandler) {\n var topic = this.props.tinode.getTopic(params.topicName);\n\n if (!topic) {\n console.log(\"Topic not found\", params.topicName);\n return;\n }\n\n var am, user;\n\n if (params.user) {\n user = topic.subscriber(params.user);\n\n if (!user) {\n console.log(\"Subscriber not found\", params.topicName + \"[\" + params.user + \"]\");\n return;\n }\n\n am = user.acs.updateGiven(mode).getGiven();\n } else {\n am = topic.getAccessMode().updateWant(mode).getWant();\n }\n\n topic.setMeta({\n sub: {\n user: params.user,\n mode: am\n }\n }).catch(function (err) {\n if (errorHandler) {\n errorHandler(err.message, 'err');\n }\n });\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this2 = this;\n\n var count = 0;\n var menu = [];\n this.props.items.map(function (item) {\n if (typeof item == 'string') {\n item = _this2.MenuItems[item];\n }\n\n if (item && item.title) {\n menu.push(item.title == '-' ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"li\", {\n className: \"separator\",\n key: count\n }) : react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"li\", {\n onClick: _this2.handleClick,\n \"data-id\": count,\n key: count\n }, item.title));\n }\n\n count++;\n });\n var hSize = 12 * _config_js__WEBPACK_IMPORTED_MODULE_3__[\"REM_SIZE\"];\n var vSize = _config_js__WEBPACK_IMPORTED_MODULE_3__[\"REM_SIZE\"] * (0.7 + menu.length * 2.5);\n var left = this.props.bounds.right - this.props.clickAt.x < hSize ? this.props.clickAt.x - this.props.bounds.left - hSize : this.props.clickAt.x - this.props.bounds.left;\n var top = this.props.bounds.bottom - this.props.clickAt.y < vSize ? this.props.clickAt.y - this.props.bounds.top - vSize : this.props.clickAt.y - this.props.bounds.top;\n var position = {\n left: left + 'px',\n top: top + 'px'\n };\n return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"ul\", {\n className: \"menu\",\n style: position\n }, menu);\n }\n }]);\n\n return ContextMenu;\n}(react__WEBPACK_IMPORTED_MODULE_0___default.a.Component);\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (Object(react_intl__WEBPACK_IMPORTED_MODULE_2__[\"injectIntl\"])(ContextMenu));\n\n//# sourceURL=webpack:///./src/widgets/context-menu.jsx?"); /***/ }), diff --git a/umd/index.prod.js b/umd/index.prod.js index 90eff0dc..dc29bd34 100644 --- a/umd/index.prod.js +++ b/umd/index.prod.js @@ -1,4 +1,4 @@ -!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=18)}([function(e,t,n){"use strict";e.exports=n(19)},function(e,t,n){"use strict";n.r(t),n.d(t,"__extends",function(){return o}),n.d(t,"__assign",function(){return i}),n.d(t,"__rest",function(){return a}),n.d(t,"__decorate",function(){return s}),n.d(t,"__param",function(){return l}),n.d(t,"__metadata",function(){return u}),n.d(t,"__awaiter",function(){return c}),n.d(t,"__generator",function(){return d}),n.d(t,"__exportStar",function(){return p}),n.d(t,"__values",function(){return f}),n.d(t,"__read",function(){return h}),n.d(t,"__spread",function(){return m}),n.d(t,"__await",function(){return y}),n.d(t,"__asyncGenerator",function(){return v}),n.d(t,"__asyncDelegator",function(){return g}),n.d(t,"__asyncValues",function(){return b}),n.d(t,"__makeTemplateObject",function(){return _}),n.d(t,"__importStar",function(){return w}),n.d(t,"__importDefault",function(){return E}); +!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=19)}([function(e,t,n){"use strict";e.exports=n(20)},function(e,t,n){"use strict";n.r(t),n.d(t,"__extends",function(){return o}),n.d(t,"__assign",function(){return i}),n.d(t,"__rest",function(){return a}),n.d(t,"__decorate",function(){return s}),n.d(t,"__param",function(){return l}),n.d(t,"__metadata",function(){return u}),n.d(t,"__awaiter",function(){return c}),n.d(t,"__generator",function(){return d}),n.d(t,"__exportStar",function(){return p}),n.d(t,"__values",function(){return f}),n.d(t,"__read",function(){return h}),n.d(t,"__spread",function(){return m}),n.d(t,"__await",function(){return y}),n.d(t,"__asyncGenerator",function(){return v}),n.d(t,"__asyncDelegator",function(){return g}),n.d(t,"__asyncValues",function(){return b}),n.d(t,"__makeTemplateObject",function(){return _}),n.d(t,"__importStar",function(){return w}),n.d(t,"__importDefault",function(){return E}); /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use @@ -13,7 +13,7 @@ MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -var r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};function o(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function l(e,t){return function(n,r){t(n,r,e)}}function u(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function c(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{l(r.next(e))}catch(e){i(e)}}function s(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,s)}l((r=r.apply(e,t||[])).next())})}function d(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=r[2&i[0]?"return":i[0]?"throw":"next"])&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[0,o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}function h(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function m(){for(var e=[],t=0;t1||s(e,t)})})}function s(e,t){try{!function(e){e.value instanceof y?Promise.resolve(e.value.v).then(l,u):c(i[0][2],e)}(o[e](t))}catch(e){c(i[0][3],e)}}function l(e){s("next",e)}function u(e){s("throw",e)}function c(e,t){e(t),i.shift(),i.length&&s(i[0][0],i[0][1])}}function g(e){var t,n;return t={},r("next"),r("throw",function(e){throw e}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(r,o){e[r]&&(t[r]=function(t){return(n=!n)?{value:y(e[r](t)),done:"return"===r}:o?o(t):t})}}function b(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator];return t?t.call(e):f(e)}function _(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function w(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function E(e){return e&&e.__esModule?e:{default:e}}},function(e,t,n){(function(t){e.exports=function(){var e={},n=[{name:"ST",start:/(?:^|\W)(\*)[^\s*]/,end:/[^\s*](\*)(?=$|\W)/},{name:"EM",start:/(?:^|[\W_])(_)[^\s_]/,end:/[^\s_](_)(?=$|[\W_])/},{name:"DL",start:/(?:^|\W)(~)[^\s~]/,end:/[^\s~](~)(?=$|\W)/},{name:"CO",start:/(?:^|\W)(`)[^`]/,end:/[^`](`)(?=$|\W)/}],r=[{name:"LN",dataName:"url",pack:function(e){return/^[a-z]+:\/\//i.test(e)||(e="http://"+e),{url:e}},re:/(?:(?:https?|ftp):\/\/|www\.|ftp\.)[-A-Z0-9+&@#\/%=~_|$?!:,.]*[A-Z0-9+&@#\/%=~_|$]/gi},{name:"MN",dataName:"val",pack:function(e){return{val:e.slice(1)}},re:/\B@(\w\w+)/g},{name:"HT",dataName:"val",pack:function(e){return{val:e.slice(1)}},re:/\B#(\w\w+)/g}],o={ST:{name:"b",isVoid:!1},EM:{name:"i",isVoid:!1},DL:{name:"del",isVoid:!1},CO:{name:"tt",isVoid:!1},BR:{name:"br",isVoid:!0},LN:{name:"a",isVoid:!1},MN:{name:"a",isVoid:!1},HT:{name:"a",isVoid:!1},IM:{name:"img",isVoid:!0}};function i(e,t){var n;try{n=atob(e)}catch(e){console.log("Drafty: failed to decode base64-encoded object",e.message),n=atob("")}for(var r=n.length,o=new ArrayBuffer(r),i=new Uint8Array(o),a=0;a"},close:function(){return""}},EM:{open:function(){return""},close:function(){return""}},DL:{open:function(){return""},close:function(){return""}},CO:{open:function(){return""},close:function(){return""}},BR:{open:function(){return""},close:function(){return"
"}},LN:{open:function(e){return''},close:function(e){return""},props:function(e){return{href:e.url,target:"_blank"}}},MN:{open:function(e){return''},close:function(e){return""},props:function(e){return{name:e.val}}},HT:{open:function(e){return''},close:function(e){return""},props:function(e){return{name:e.val}}},IM:{open:function(e){var t=i(e.val,e.mime),n=e.ref?e.ref:t,r=(e.name?'':"")+'';return console.log("open: "+r),r},close:function(e){return e.name?"":""},props:function(e){return{src:i(e.val,e.mime),title:e.name,"data-width":e.width,"data-height":e.height,"data-name":e.name,"data-size":.75*e.val.length|0,"data-mime":e.mime}}}},s=function(){};s.parse=function(e){if("string"!=typeof e)return null;var t=e.split(/\r?\n/),o=[],i={},a=[];t.map(function(e){var t,s,l=[];if(n.map(function(t){l=l.concat(function(e,t,n,r){for(var o=[],i=0,a=e.slice(0);a.length>0;){var s=t.exec(a);if(null==s)break;var l=s.index+s[0].lastIndexOf(s[1]);a=a.slice(l+1),i=(l+=i)+1;var u=n?n.exec(a):null;if(null==u)break;var c=u.index+u[0].indexOf(u[1]);a=a.slice(c+1),i=(c+=i)+1,o.push({text:e.slice(l+1,c),children:[],start:l,end:c,type:r})}return o}(e,t.start,t.end,t.name))}),0==l.length)s={txt:e};else{l.sort(function(e,t){return e.start-t.start}),l=function e(t){if(0==t.length)return[];for(var n=[t[0]],r=t[0],o=1;or.end?(n.push(t[o]),r=t[o]):t[o].endn&&i.push({text:t.slice(n,s.start)});var l={type:s.type},u=e(t,s.start+1,s.end-1,s.children);u.length>0?l.children=u:l.text=s.text,i.push(l),n=s.end+1}return no;return o=e.offset+e.len,t})}(s.txt)).length>0){var c=[];for(var d in t){var p=t[d],f=i[p.unique];f||(f=o.length,i[p.unique]=f,o.push({tp:p.type,data:p.data})),c.push({at:p.offset,len:p.len,key:f})}s.ent=c}a.push(s)});var s={txt:""};if(a.length>0){s.txt=a[0].txt,s.fmt=(a[0].fmt||[]).concat(a[0].ent||[]);for(var l=1;l0&&(s.ent=o)}return s},s.insertImage=function(e,t,n,r,o,i,a,s,l){return(e=e||{txt:" "}).ent=e.ent||[],e.fmt=e.fmt||[],e.fmt.push({at:t,len:1,key:e.ent.length}),e.ent.push({tp:"IM",data:{mime:n,val:r,width:o,height:i,name:a,ref:l,size:0|s}}),e},s.attachFile=function(e,t,n,r,o,i){(e=e||{txt:""}).ent=e.ent||[],e.fmt=e.fmt||[],e.fmt.push({at:-1,len:0,key:e.ent.length});var a={tp:"EX",data:{mime:t,val:n,name:r,ref:i,size:0|o}};return i instanceof Promise&&(a.data.ref=i.then(function(e){a.data.ref=e},function(e){})),e.ent.push(a),e},s.UNSAFE_toHTML=function(e){var t,n,r,o=e.txt,i=e.fmt,s=e.ent,l=[];if(i)for(var u in i){var c,d=i[u],p=d.tp;if(!p){var f=s[d.key];f&&(p=f.tp,c=f.data)}a[p]&&(l.push({idx:d.at+d.len,what:a[p].close(c)}),l.push({idx:d.at,what:a[p].open(c)}))}for(var u in l.sort(function(e,t){return t.idx-e.idx}),l)l[u].what&&(t=o,n=l[u].idx,r=l[u].what,o=t.slice(0,n)+r+t.slice(n));return o},s.format=function(e,t,n){var r=e.txt,i=e.fmt,a=e.ent;if(r=r||"",!i)return[r];var s=[].concat(i);return s.map(function(e){e.at=e.at||0,e.len=e.len||0}),s.sort(function(e,t){return e.at-t.at==0?t.len-e.len:e.at-t.at}),s=s.map(function(e){var t,n=e.tp;return n||(e.key=e.key||0,t=a[e.key].data,n=a[e.key].tp),{tp:n,data:t,at:e.at,len:e.len}}),function e(t,n,r,i,a,s){for(var l=[],u=0;u0)for(var t in e.ent)if("EX"==e.ent[t].tp)return!0;return!1},s.attachments=function(e,t,n){if(e.ent&&e.ent.length>0)for(var r in e.ent)"EX"==e.ent[r].tp&&t.call(n,e.ent[r].data,r)},s.getDownloadUrl=function(e){var t=null;return e.val?t=i(e.val,e.mime):"string"==typeof e.ref&&(t=e.ref),t},s.isUploading=function(e){return e.ref instanceof Promise},s.getPreviewUrl=function(e){return e.val?i(e.val,e.mime):null},s.getEntitySize=function(e){return e.size?e.size:e.val?.75*e.val.length|0:0},s.getEntityMimeType=function(e){return e.mime||"text/plain"},s.tagName=function(e){return o[e]?o[e].name:void 0},s.attrValue=function(e,t){if(t&&a[e])return a[e].props(t)},s.getContentType=function(){return"text/x-drafty"},e=s;var l={};return function(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)}var r,o="0.15.8-rc1";"undefined"!=typeof WebSocket&&(r=WebSocket),"undefined"==typeof btoa&&(t.btoa=function(){for(var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n="",r=0,o=0,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";t.charAt(0|o)||(i="=",o%1);n+=i.charAt(63&r>>8-o%1*8)){if((e=t.charCodeAt(o+=.75))>255)throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");r=r<<8|e}return n}),"undefined"==typeof atob&&(t.atob=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").replace(/=+$/,""),t="";if(e.length%4==1)throw new Error("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r=0,o=0,i=0;n=e.charAt(i++);~n&&(o=r%4?64*o+n:n,r++%4)?t+=String.fromCharCode(255&o>>(-2*r&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return t}),"undefined"==typeof window&&(t.window={WebSocket:r,URL:{createObjectURL:function(){throw new Error("Unable to use window.URL in a non browser application")}}});var i="0",a=o||"0.15",s="tinodejs/"+a,u=503,c="Connection failed";function d(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))}function p(e,t,r){if(null==t)return e;if("object"!==n(t))return t||e;if(t instanceof Date)return t;if(t instanceof w)return new w(t);if(t instanceof Array)return t.length>0?t:e;for(var o in e||(e=t.constructor()),t)!t.hasOwnProperty(o)||!t[o]&&!1!==t[o]||r&&r[o]||"_generated"==o||(e[o]=p(e[o],t[o]));return e}function f(e,t,n,r){return e[t]=p(e[t],n,r),e[t]}function h(){var e=null;if("withCredentials"in new XMLHttpRequest)e=new XMLHttpRequest;else{if("undefined"==typeof XDomainRequest)throw new Error("browser not supported");e=new XDomainRequest}return e}function m(e,t){if("ts"===e&&"string"==typeof t&&t.length>=20&&t.length<=24){var r=new Date(t);if(r)return r}else if("acs"===e&&"object"===n(t))return new w(t);return t}function y(e,t){return"string"==typeof t&&t.length>128?"<"+t.length+", bytes: "+t.substring(0,12)+"..."+t.substring(t.length-12)+">":function(e,t){if(t instanceof Date)t=function(e){if(e&&0!=e.getTime()){var t=e.getUTCMilliseconds();return e.getUTCFullYear()+"-"+n(e.getUTCMonth()+1)+"-"+n(e.getUTCDate())+"T"+n(e.getUTCHours())+":"+n(e.getUTCMinutes())+":"+n(e.getUTCSeconds())+(t?"."+n(t,3):"")+"Z"}function n(e,t){return"0".repeat((t=t||2)-(""+e).length)+e}}(t);else if(null==t||!1===t||Array.isArray(t)&&0==t.length||"object"===n(t)&&0===Object.keys(t).length)return;return t}(0,t)}function v(e,t,n){var r=null;return"http"!==t&&"https"!==t&&"ws"!==t&&"wss"!==t||(r=t+"://","/"!==(r+=e).charAt(r.length-1)&&(r+="/"),r+="v"+i+"/channels","http"!==t&&"https"!==t||(r+="/lp"),r+="?apikey="+n),r}var g=function(e,t,o,i,a){var s=this,l=e,d=i,p=t,f=a,y=2e3,g=10,b=.3,_=null,w=0,E=!1,S=function(e){s.logger&&s.logger(e)};function T(e){var t=null;e.connect=function(n){return t&&1===t.readyState?Promise.resolve():(n&&(l=n),new Promise(function(n,o){var i=v(l,d?"wss":"ws",p);S("Connecting to: "+i);var a=new r(i);a.onopen=function(t){E=!1,e.onOpen&&e.onOpen(),n(),f&&(clearTimeout(_),_=null,w=0)},a.onclose=function(n){t=null,e.onDisconnect&&e.onDisconnect(null),!E&&f&&function(){var e=this;clearTimeout(_);var t=y*(Math.pow(2,w)*(1+b*Math.random()));w=w>=g?w:w+1,_=setTimeout(function(){S("Reconnecting, iter="+w+", timeout="+t),E||e.connect().catch(function(){})},t)}.call(e)},a.onerror=function(e){o(e)},a.onmessage=function(t){e.onMessage&&e.onMessage(t.data)},t=a}))},e.disconnect=function(){t&&(E=!0,t.close()),t=null},e.sendText=function(e){if(!t||t.readyState!=t.OPEN)throw new Error("Websocket is not connected");t.send(e)},e.isConnected=function(){return t&&1===t.readyState},e.transport=function(){return"ws"}}function k(e){var t=null,n=null,r=null;e.connect=function(r){return n?Promise.resolve():(r&&(l=r),new Promise(function(r,o){var i=v(l,d?"https":"http",p);S("Connecting to: "+i),(n=function n(r,o,i){var a=h();return a.onreadystatechange=function(s){if(4==a.readyState)if(201==a.status){var l=JSON.parse(a.responseText,m);a.responseText,t=r+"&sid="+l.ctrl.params.sid,(a=n(t)).send(null),e.onOpen&&e.onOpen(),o&&o()}else if(200==a.status)e.onMessage&&e.onMessage(a.responseText),(a=n(t)).send(null);else if(i&&i(a.responseText),e.onMessage&&a.responseText&&e.onMessage(a.responseText),e.onDisconnect){var d=a.status||u,p=a.responseText||c;e.onDisconnect(new Error(p+"("+d+")"))}},a.open("GET",r,!0),a}(i,r,o)).send(null)}).catch(function(){}))},e.disconnect=function(){r&&(r.onreadystatechange=void 0,r.abort(),r=null),n&&(n.onreadystatechange=void 0,n.abort(),n=null),e.onDisconnect&&e.onDisconnect(null),t=null},e.sendText=function(e){var n,o;if(n=t,(o=h()).onreadystatechange=function(e){if(4==o.readyState&&o.status>=400)throw new Error("LP sender failed, "+o.status)},o.open("POST",n,!0),!(r=o)||1!=r.readyState)throw new Error("Long poller failed to connect");r.send(e)},e.isConnected=function(){return n&&!0},e.transport=function(){return"lp"}}"lp"===o?k(this):"ws"===o?T(this):"object"==("undefined"==typeof window?"undefined":n(window))&&window.WebSocket?T(this):k(this),this.onMessage=void 0,this.onDisconnect=void 0,this.onOpen=void 0,this.logger=void 0},b=function(e,t,r,o,i){var l=this;this._appName=e||"Undefined",this._apiKey=r,this._browser="",this._platform="undefined",this._humanLanguage="xx","undefined"!=typeof navigator&&(this._browser=function(e){var t,n=(e=(e||"").replace(" (KHTML, like Gecko)","")).match(/(AppleWebKit\/[.\d]+)/i);if(n){for(var r=["chrome","safari","mobile","version"],o=e.substr(n.index+n[0].length).split(" "),i=[],a=0;a0?i[0][0]+"/"+i[0][1]:n[1]}else t=/trident/i.test(e)?(n=/(?:\brv[ :]+([.\d]+))|(?:\bMSIE ([.\d]+))/g.exec(e))?"MSIE/"+(n[1]||n[2]):"MSIE/?":/firefox/i.test(e)?(n=/Firefox\/([.\d]+)/g.exec(e))?"Firefox/"+n[1]:"Firefox/?":/presto/i.test(e)?(n=/Opera\/([.\d]+)/g.exec(e))?"Opera/"+n[1]:"Opera/?":(n=/([\w.]+)\/([.\d]+)/.exec(e))?n[1]+"/"+n[2]:(n=e.split(" "))[0];if((n=t.split("/")).length>1){var l=n[1].split(".");t=n[0]+"/"+l[0]+(l[1]?"."+l[1]:"")}return t}(navigator.userAgent),this._platform=navigator.platform,this._humanLanguage=navigator.language||"en-US"),this._loggingEnabled=!1,this._trimLongStrings=!1,this._myUID=null,this._authenticated=!1,this._login=null,this._authToken=null,this._inPacketCount=0,this._messageId=Math.floor(65535*Math.random()+65535),this._serverInfo=null,this._deviceToken=null,this._pendingPromises={},this._connection=new g(t,r,o,i,!0),this.logger=function(e){if(l._loggingEnabled){var t=new Date,n=("0"+t.getUTCHours()).slice(-2)+":"+("0"+t.getUTCMinutes()).slice(-2)+":"+("0"+t.getUTCSeconds()).slice(-2)+":"+("0"+t.getUTCMilliseconds()).slice(-3);console.log("["+n+"] "+e)}},this._connection.logger=this.logger,this._cache={};var d=this.cachePut=function(e,t,n){l._cache[e+":"+t]=n},f=this.cacheGet=function(e,t){return l._cache[e+":"+t]},h=this.cacheDel=function(e,t){delete l._cache[e+":"+t]},v=this.cacheMap=function(e,t){for(var n in l._cache)if(e(l._cache[n],n,t))break};this.attachCacheToTopic=function(e){e._tinode=l,e._cacheGetUser=function(e){var t=f("user",e);if(t)return{user:e,public:p({},t)}},e._cachePutUser=function(e,t){return d("user",e,p({},t.public))},e._cacheDelUser=function(e){return h("user",e)},e._cachePutSelf=function(){return d("topic",e.name,e)},e._cacheDelSelf=function(){return h("topic",e.name)}};var b=function(e,t,n,r){var o=l._pendingPromises[e];o&&(delete l._pendingPromises[e],t>=200&&t<400?o.resolve&&o.resolve(n):o.reject&&o.reject(new Error("Error: "+r+" ("+t+")")))},_=this.getNextUniqueId=function(){return 0!=l._messageId?""+l._messageId++:void 0};this.initPacket=function(e,t){switch(e){case"hi":return{hi:{id:_(),ver:a,ua:l._appName+" ("+(l._browser?l._browser+"; ":"")+l._platform+"); "+s,dev:l._deviceToken,lang:l._humanLanguage}};case"acc":return{acc:{id:_(),user:null,scheme:null,secret:null,login:!1,tags:null,desc:{},cred:{}}};case"login":return{login:{id:_(),scheme:null,secret:null}};case"sub":return{sub:{id:_(),topic:t,set:{},get:{}}};case"leave":return{leave:{id:_(),topic:t,unsub:!1}};case"pub":return{pub:{id:_(),topic:t,noecho:!1,head:null,content:{}}};case"get":return{get:{id:_(),topic:t,what:null,desc:{},sub:{},data:{}}};case"set":return{set:{id:_(),topic:t,desc:{},sub:{},tags:[]}};case"del":return{del:{id:_(),topic:t,what:null,delseq:null,user:null,hard:!1}};case"note":return{note:{topic:t,what:null,seq:void 0}};default:throw new Error("Unknown packet type requested: "+e)}},this.send=function(e,t){var r;t&&(r=function(e){var t=null;return e&&(t=new Promise(function(t,n){l._pendingPromises[e]={resolve:t,reject:n}})),t}(t)),e=function e(t){return Object.keys(t).forEach(function(r){"_"==r[0]?delete t[r]:t[r]?Array.isArray(t[r])&&0==t[r].length?delete t[r]:t[r]?"object"!=n(t[r])||t[r]instanceof Date||(e(t[r]),0==Object.getOwnPropertyNames(t[r]).length&&delete t[r]):delete t[r]:delete t[r]}),t}(e);var o=JSON.stringify(e);l.logger("out: "+(l._trimLongStrings?JSON.stringify(e,y):o));try{l._connection.sendText(o)}catch(e){if(!t)throw e;b(t,u,null,e.message)}return r},this.loginSuccessful=function(e){e.params&&e.params.user&&(l._myUID=e.params.user,l._authenticated=e&&e.code>=200&&e.code<300,e.params&&e.params.token&&e.params.expires?l._authToken={token:e.params.token,expires:new Date(e.params.expires)}:l._authToken=null,l.onLogin&&l.onLogin(e.code,e.text))},this._connection.onMessage=function(e){if(e){l._inPacketCount++,l.onRawMessage&&l.onRawMessage(e);var t=JSON.parse(e,m);if(t)if(l.logger("in: "+(l._trimLongStrings?JSON.stringify(t,y):e)),l.onMessage&&l.onMessage(t),t.ctrl)l.onCtrlMessage&&l.onCtrlMessage(t.ctrl),t.ctrl.id&&b(t.ctrl.id,t.ctrl.code,t.ctrl,t.ctrl.text),t.ctrl.params&&"data"==t.ctrl.params.what&&(n=f("topic",t.ctrl.topic))&&n._allMessagesReceived(t.ctrl.params.count);else if(t.meta)(n=f("topic",t.meta.topic))&&n._routeMeta(t.meta),l.onMetaMessage&&l.onMetaMessage(t.meta);else if(t.data)(n=f("topic",t.data.topic))&&n._routeData(t.data),l.onDataMessage&&l.onDataMessage(t.data);else if(t.pres)(n=f("topic",t.pres.topic))&&n._routePres(t.pres),l.onPresMessage&&l.onPresMessage(t.pres);else if(t.info){var n;(n=f("topic",t.info.topic))&&n._routeInfo(t.info),l.onInfoMessage&&l.onInfoMessage(t.info)}else l.logger("ERROR: Unknown packet received.");else l.logger("in: "+e),l.logger("ERROR: failed to parse data")}},this._connection.onOpen=function(){l.hello()},this._connection.onDisconnect=function(e){for(var t in l._inPacketCount=0,l._serverInfo=null,l._authenticated=!1,l._pendingPromises){var n=l._pendingPromises[t];n&&n.reject&&n.reject(new Error(c+" ("+u+")"))}l._pendingPromises={},v(function(e,t){0===t.lastIndexOf("topic:",0)&&e._resetSub()}),l.onDisconnect&&l.onDisconnect(e)}};b.credential=function(e,t,r,o){if("object"==n(e)){var i=e;t=i.val,r=i.params,o=i.resp,e=i.meth}return e&&(t||o)?[{meth:e,val:t,resp:o,params:r}]:null},b.topicType=function(e){return{me:"me",fnd:"fnd",grp:"grp",new:"grp",usr:"p2p"}["string"==typeof e?e.substring(0,3):"xxx"]},b.isNewGroupTopicName=function(e){return"string"==typeof e&&"new"==e.substring(0,3)},b.getVersion=function(){return a},b.setWebSocketProvider=function(e){r=e},b.getLibrary=function(){return s},b.MESSAGE_STATUS_NONE=0,b.MESSAGE_STATUS_QUEUED=1,b.MESSAGE_STATUS_SENDING=2,b.MESSAGE_STATUS_FAILED=3,b.MESSAGE_STATUS_SENT=4,b.MESSAGE_STATUS_RECEIVED=5,b.MESSAGE_STATUS_READ=6,b.MESSAGE_STATUS_TO_ME=7,b.DEL_CHAR="␡",b.prototype={connect:function(e){return this._connection.connect(e)},disconnect:function(){this._connection&&this._connection.disconnect()},isConnected:function(){return this._connection&&this._connection.isConnected()},isAuthenticated:function(){return this._authenticated},account:function(e,t,n,r,o){var i=this.initPacket("acc");return i.acc.user=e,i.acc.scheme=t,i.acc.secret=n,i.acc.login=r,o&&(i.acc.desc.defacs=o.defacs,i.acc.desc.public=o.public,i.acc.desc.private=o.private,i.acc.tags=o.tags,i.acc.cred=o.cred,i.acc.token=o.token),this.send(i,i.acc.id)},createAccount:function(e,t,n,r){var o=this,i=this.account("new",e,t,n,r);return n&&(i=i.then(function(e){return o.loginSuccessful(e),e})),i},createAccountBasic:function(e,t,n){return e=e||"",t=t||"",this.createAccount("basic",d(e+":"+t),!0,n)},updateAccountBasic:function(e,t,n,r){return t=t||"",n=n||"",this.account(e,"basic",d(t+":"+n),!1,r)},hello:function(){var e=this,t=this.initPacket("hi");return this.send(t,t.hi.id).then(function(t){return t.params&&(e._serverInfo=t.params),e.onConnect&&e.onConnect(),t}).catch(function(t){e.onDisconnect&&e.onDisconnect(t)})},setDeviceToken:function(e,t){var n=!1;return e&&e!=this._deviceToken&&(this._deviceToken=e,t&&this.isConnected()&&this.isAuthenticated()&&(this.send({hi:{dev:e}}),n=!0)),n},login:function(e,t,n){var r=this,o=this.initPacket("login");return o.login.scheme=e,o.login.secret=t,o.login.cred=n,this.send(o,o.login.id).then(function(e){return r.loginSuccessful(e),e})},loginBasic:function(e,t,n){var r=this;return this.login("basic",d(e+":"+t),n).then(function(t){return r._login=e,t})},loginToken:function(e,t){return this.login("token",e,t)},requestResetAuthSecret:function(e,t,n){return this.login("reset",d(e+":"+t+":"+n))},getAuthToken:function(){return this._authToken&&this._authToken.expires.getTime()>Date.now()?this._authToken:(this._authToken=null,null)},setAuthToken:function(e){this._authToken=e},subscribe:function(e,t,n){var r=this.initPacket("sub",e);return e||(e="new"),r.sub.get=t,n&&(n.sub&&(r.sub.set.sub=n.sub),b.isNewGroupTopicName(e)&&n.desc&&(r.sub.set.desc=n.desc),n.tags&&(r.sub.set.tags=n.tags)),this.send(r,r.sub.id)},leave:function(e,t){var n=this.initPacket("leave",e);return n.leave.unsub=t,this.send(n,n.leave.id)},createMessage:function(t,n,r){var o=this.initPacket("pub",t),i="string"==typeof n?e.parse(n):n;return i&&!e.isPlainText(i)&&(o.pub.head={mime:e.getContentType()},n=i),o.pub.noecho=r,o.pub.content=n,o.pub},publish:function(e,t,n){return this.publishMessage(this.createMessage(e,t,n))},publishMessage:function(e){return(e=Object.assign({},e)).seq=void 0,e.from=void 0,e.ts=void 0,this.send({pub:e},e.id)},getMeta:function(e,t){var n=this.initPacket("get",e);return n.get=p(n.get,t),this.send(n,n.get.id)},setMeta:function(e,t){var n=this.initPacket("set",e),r=[];return t&&["desc","sub","tags"].map(function(e){t.hasOwnProperty(e)&&(r.push(e),n.set[e]=t[e])}),0==r.length?Promise.reject(new Error("Invalid {set} parameters")):this.send(n,n.set.id)},delMessages:function(e,t,n){var r=this.initPacket("del",e);return r.del.what="msg",r.del.delseq=t,r.del.hard=n,this.send(r,r.del.id)},delTopic:function(e){var t=this,n=this.initPacket("del",e);return n.del.what="topic",this.send(n,n.del.id).then(function(n){return t.cacheDel("topic",e),t.ctrl})},delSubscription:function(e,t){var n=this.initPacket("del",e);return n.del.what="sub",n.del.user=t,this.send(n,n.del.id)},note:function(e,t,n){if(n<=0||n>=268435455)throw new Error("Invalid message id "+n);var r=this.initPacket("note",e);r.note.what=t,r.note.seq=n,this.send(r)},noteKeyPress:function(e){var t=this.initPacket("note",e);t.note.what="kp",this.send(t)},getTopic:function(e){var t=this.cacheGet("topic",e);return!t&&e&&(t="me"==e?new S:"fnd"==e?new T:new E(e),this.cachePut("topic",e,t),this.attachCacheToTopic(t)),t},newTopic:function(e){var t=new E("new",e);return this.attachCacheToTopic(t),t},newGroupTopicName:function(){return"new"+this.getNextUniqueId()},newTopicWith:function(e,t){var n=new E(e,t);return this.attachCacheToTopic(n),n},getMeTopic:function(){return this.getTopic("me")},getFndTopic:function(){return this.getTopic("fnd")},getLargeFileHelper:function(){return new k(this)},getCurrentUserID:function(){return this._myUID},getCurrentLogin:function(){return this._login},getServerInfo:function(){return this._serverInfo},enableLogging:function(e,t){this._loggingEnabled=e,this._trimLongStrings=e&&t},isTopicOnline:function(e){var t=this.getMeTopic(),n=t&&t.getContact(e);return n&&n.online},wantAkn:function(e){this._messageId=e?Math.floor(16777215*Math.random()+16777215):0},onWebsocketOpen:void 0,onConnect:void 0,onDisconnect:void 0,onLogin:void 0,onCtrlMessage:void 0,onDataMessage:void 0,onPresMessage:void 0,onMessage:void 0,onRawMessage:void 0};var _=function(e){this.topic=e;var t=e._tinode.getMeTopic();this.contact=t&&t.getContact(e.name),this.what={}};_.prototype={_get_ims:function(){var e=this.contact&&this.contact.updated,t=this.topic._lastDescUpdate||0;return e>t?e:t},withData:function(e,t,n){return this.what.data={since:e,before:t,limit:n},this},withLaterData:function(e){return this.withData(this.topic._maxSeq>0?this.topic._maxSeq+1:void 0,void 0,e)},withEarlierData:function(e){return this.withData(void 0,this.topic._minSeq>0?this.topic._minSeq:void 0,e)},withDesc:function(e){return this.what.desc={ims:e},this},withLaterDesc:function(){return this.withDesc(this._get_ims())},withSub:function(e,t,n){var r={ims:e,limit:t};return"me"==this.topic.getType()?r.topic=n:r.user=n,this.what.sub=r,this},withOneSub:function(e,t){return this.withSub(e,void 0,t)},withLaterOneSub:function(e){return this.withOneSub(this.topic._lastSubsUpdate,e)},withLaterSub:function(e){return this.withSub("p2p"==this.topic.getType()?this._get_ims():this.topic._lastSubsUpdate,e)},withTags:function(){return this.what.tags=!0,this},withDel:function(e,t){return(e||t)&&(this.what.del={since:e,limit:t}),this},withLaterDel:function(e){return this.withDel(this.topic._maxSeq>0?this.topic._maxDel+1:void 0,e)},build:function(){var e={},t=[],n=this;return["data","sub","desc","tags","del"].map(function(r){n.what.hasOwnProperty(r)&&(t.push(r),Object.getOwnPropertyNames(n.what[r]).length>0&&(e[r]=n.what[r]))}),t.length>0?e.what=t.join(" "):e=void 0,e}};var w=function e(t){t&&(this.given="number"==typeof t.given?t.given:e.decode(t.given),this.want="number"==typeof t.want?t.want:e.decode(t.want),this.mode=t.mode?"number"==typeof t.mode?t.mode:e.decode(t.mode):this.given&this.want)};w._NONE=0,w._JOIN=1,w._READ=2,w._WRITE=4,w._PRES=8,w._APPROVE=16,w._SHARE=32,w._DELETE=64,w._OWNER=128,w._BITMASK=w._JOIN|w._READ|w._WRITE|w._PRES|w._APPROVE|w._SHARE|w._DELETE|w._OWNER,w._INVALID=1048576,w.decode=function(e){if(!e)return null;if("number"==typeof e)return e&w._BITMASK;if("N"===e||"n"===e)return w._NONE;for(var t={J:w._JOIN,R:w._READ,W:w._WRITE,P:w._PRES,A:w._APPROVE,S:w._SHARE,D:w._DELETE,O:w._OWNER},n=w._NONE,r=0;r0)){l=!0;break}i=a-1}return l?a:r?-1:s<0?a+1:a}function r(e,t){var r=n(e,t,!1);return t.splice(r,0,e),t}return e=e||function(e,t){return e===t?0:e0)return n[0]},delRange:function(e,n){return t.splice(e,n-e)},size:function(){return t.length},reset:function(e){t=[]},forEach:function(e,n,r,o){n|=0,r=r||t.length;for(var i=n;i=300)return e;if(n._subscribed=!0,n.acs=e.params&&e.params.acs?e.params.acs:n.acs,n._new){n._new=!1,n.name=e.topic,n.created=e.ts,n.updated=e.ts,n.touched=e.ts,n._cachePutSelf();var r=n._tinode.getMeTopic();r&&r._processMetaSub([{_generated:!0,topic:n.name,created:e.ts,updated:e.ts,touched:e.ts,acs:n.acs}]),t&&t.desc&&(t.desc._generated=!0,n._processMetaDesc(t.desc))}return e})},createMessage:function(e,t){return this._tinode.createMessage(this.name,e,t)},publish:function(e,t){return this.publishMessage(this.createMessage(e,t))},publishMessage:function(t){var n=this;if(!this._subscribed)return Promise.reject(new Error("Cannot publish on inactive topic"));if(e.hasAttachments(t.content)&&!t.head.attachments){var r=[];e.attachments(t.content,function(e){r.push(e.ref)}),t.head.attachments=r}return t._sending=!0,this._tinode.publishMessage(t).then(function(e){return t._sending=!1,t.seq=e.params.seq,t.ts=e.ts,n._routeData(t),e}).catch(function(e){t._sending=!1,t._failed=!0})},publishDraft:function(e,t){var n=this;if(!t&&!this._subscribed)return Promise.reject(new Error("Cannot publish on inactive topic"));var r=e.seq||this._getQueuedSeqId();return e._generated||(e._generated=!0,e.seq=r,e.ts=new Date,e.from=this._tinode.getCurrentUserID(),e.noecho=!0,this._messages.put(e),this.onData&&this.onData(e)),(t||Promise.resolve()).then(function(){return e._cancelled?{code:300,text:"cancelled"}:n.publishMessage(e)},function(t){e._sending=!1,n._messages.delAt(n._messages.find(e)),n.onData&&n.onData()})},leave:function(e){var t=this;return this._subscribed||e?this._tinode.leave(this.name,e).then(function(n){return t._resetSub(),e&&t._gone(),n}):Promise.reject(new Error("Cannot leave inactive topic"))},getMeta:function(e){return this._subscribed?this._tinode.getMeta(this.name,e):Promise.reject(new Error("Cannot query inactive topic"))},getMessagesPage:function(e,t){var n=this,r=this.startMetaQuery();t?r.withLaterData(e):r.withEarlierData(e);var o=this.getMeta(r.build());return t||(o=o.then(function(e){e&&e.params&&!e.params.count&&(n._noEarlierMsgs=!0)})),o},setMeta:function(e){var t=this;return this._subscribed?(e.tags&&(e.tags=function(e){var t=[];if(Array.isArray(e)){for(var n=0,r=e.length;n1&&t.push(o)}t.sort().filter(function(e,t,n){return!t||e!=n[t-1]})}return 0==t.length&&t.push(b.DEL_CHAR),t}(e.tags)),this._tinode.setMeta(this.name,e).then(function(n){return n&&n.code>=300?n:(e.sub&&(n.params&&n.params.acs&&(e.sub.acs=n.params.acs,e.sub.updated=n.ts),e.sub.user||(e.sub.user=t._tinode.getCurrentUserID(),e.desc||(e.desc={})),e.sub._generated=!0,t._processMetaSub([e.sub])),e.desc&&(n.params&&n.params.acs&&(e.desc.acs=n.params.acs,e.desc.updated=n.ts),t._processMetaDesc(e.desc)),e.tags&&t._processMetaTags(e.tags),n)})):Promise.reject(new Error("Cannot update inactive topic"))},invite:function(e,t){return this.setMeta({sub:{user:e,mode:t}})},delMessages:function(e,t){var n=this;if(!this._subscribed)return Promise.reject(new Error("Cannot delete messages in inactive topic"));e.sort(function(e,t){return e.low=t.hi)});var r=e.reduce(function(e,t){return t.low<268435455&&(!t.hi||t.hi<268435455?e.push(t):e.push({low:t.low,hi:n._maxSeq+1})),e},[]);return(e.length>0?this._tinode.delMessages(this.name,r,t):Promise.resolve({params:{del:0}})).then(function(t){return t.params.del>n._maxDel&&(n._maxDel=t.params.del),e.map(function(e){e.hi?n.flushMessageRange(e.low,e.hi):n.flushMessage(e.low)}),n.onData&&n.onData(),t})},delMessagesAll:function(e){return this.delMessages([{low:1,hi:this._maxSeq+1,_all:!0}],e)},delMessagesList:function(e,t){e.sort(function(e,t){return e-t});var n=e.reduce(function(e,t){if(0==e.length)e.push({low:t});else{var n=e[e.length-1];!n.hi&&t!=n.low+1||t>n.hi?e.push({low:t}):n.hi=n.hi?Math.max(n.hi,t+1):t+1}return e},[]);return this.delMessages(n,t)},delTopic:function(){var e=this;return this._tinode.delTopic(this.name).then(function(t){return e._resetSub(),e._gone(),t})},delSubscription:function(e){var t=this;return this._subscribed?this._tinode.delSubscription(this.name,e).then(function(n){return delete t._users[e],t.onSubsUpdated&&t.onSubsUpdated(Object.keys(t._users)),n}):Promise.reject(new Error("Cannot delete subscription in inactive topic"))},note:function(e,t){var n=this._users[this._tinode.getCurrentUserID()];n?((!n[e]||n[e]0)for(var o in this._users){var i=this._users[o];i.user!==r&&i[e]>=t&&n++}return n},msgReadCount:function(e){return this.msgReceiptCount("read",e)},msgRecvCount:function(e){return this.msgReceiptCount("recv",e)},msgHasMoreMessages:function(e){return e?this.seq>this._maxSeq:this._minSeq>1&&!this._noEarlierMsgs},isNewMessage:function(e){return this._maxSeq<=e},flushMessage:function(e){var t=this._messages.find({seq:e});return t>=0?this._messages.delAt(t):void 0},flushMessageRange:function(e,t){var n=this._messages.find({seq:e});return n>=0?this._messages.delRange(n,this._messages.find({seq:t},!0)):[]},cancelSend:function(e){var t=this._messages.find({seq:e});if(t>=0){var n=this._messages.getAt(t);if(1==this.msgStatus(n))return n._cancelled=!0,this._messages.delAt(t),!0}return!1},getType:function(){return b.topicType(this.name)},getAccessMode:function(){return this.acs},getDefaultAccess:function(){return this.defacs},startMetaQuery:function(){return new _(this)},msgStatus:function(e){var t=0;return e.from==this._tinode.getCurrentUserID()?e._sending?t=2:e._failed?t=3:e.seq>=268435455?t=1:this.msgReadCount(e.seq)>0?t=6:this.msgRecvCount(e.seq)>0?t=5:e.seq>0&&(t=4):t=7,t},_routeData:function(e){e.content&&((!this.touched||this.touchedthis._maxSeq&&(this._maxSeq=e.seq),(e.seq0&&(this._lastSubsUpdate=e.ts,this._processMetaSub(e.sub)),e.del&&this._processDelMessages(e.del.clear,e.del.delseq),e.tags&&this._processMetaTags(e.tags),this.onMeta&&this.onMeta(e)},_routePres:function(e){var t;switch(e.what){case"del":this._processDelMessages(e.clear,e.delseq);break;case"on":case"off":(t=this._users[e.src])?t.online="on"==e.what:this._tinode.logger("Presence update for an unknown user",this.name,e.src);break;case"acs":var n="me"==e.src?this._tinode.getCurrentUserID():e.src;if(t=this._users[n])t.acs.updateAll(e.dacs),n==this._tinode.getCurrentUserID()&&this.acs.updateAll(e.dacs),t.acs&&t.acs.mode!=w._NONE||("p2p"==this.getType()&&this.leave(),this._processMetaSub([{user:n,deleted:new Date,_generated:!0}]));else{var r=(new w).updateAll(e.dacs);r&&r.mode!=w._NONE&&((t=this._cacheGetUser(n))?t.acs=r:(t={user:n,acs:r},this.getMeta(this.startMetaQuery().withOneSub(void 0,n).build())),t._generated=!0,t.updated=new Date,this._processMetaSub([t]))}break;default:this._tinode.logger("Ignored presence update",e.what)}this.onPres&&this.onPres(e)},_routeInfo:function(e){if("kp"!==e.what){var t=this._users[e.from];t&&(t[e.what]=e.seq)}this.onInfo&&this.onInfo(e)},_processMetaDesc:function(e,t){if(p(this,e),"string"==typeof this.created&&(this.created=new Date(this.created)),"string"==typeof this.updated&&(this.updated=new Date(this.updated)),"string"==typeof this.touched&&(this.touched=new Date(this.touched)),"me"!==this.name&&!t&&!e._generated){var n=this._tinode.getMeTopic();n&&n._processMetaSub([{_generated:!0,topic:this.name,updated:this.updated,touched:this.touched,acs:this.acs,public:this.public,private:this.private}])}this.onMetaDesc&&this.onMetaDesc(this)},_processMetaSub:function(e){var t=void 0;for(var n in e){var r=e[n];if(r.user){r.updated=new Date(r.updated),r.deleted=r.deleted?new Date(r.deleted):null;var o=null;r.deleted?(delete this._users[r.user],o=r):((o=this._users[r.user])||(o=this._cacheGetUser(r.user)),o=this._updateCachedUser(r.user,r,r._generated)),this.onMetaSub&&this.onMetaSub(o)}else r._generated||(t=r)}t&&this.onMetaDesc&&this.onMetaDesc(t),this.onSubsUpdated&&this.onSubsUpdated(Object.keys(this._users))},_processMetaTags:function(e){1==e.length&&e[0]==b.DEL_CHAR&&(e=[]),this._tags=e,this.onTagsUpdated&&this.onTagsUpdated(e)},_processDelMessages:function(e,t){this._maxDel=Math.max(e,this._maxDel),this.clear=Math.max(e,this.clear);var n=this,r=0;Array.isArray(t)&&t.map(function(e){if(e.hi)for(var t=e.low;t0&&this.onData&&this.onData()},_allMessagesReceived:function(e){this.onAllMessagesReceived&&this.onAllMessagesReceived(e)},_resetSub:function(){this._subscribed=!1},_gone:function(){this._messages.reset(),this._users={},this.acs=new w(null),this.private=null,this.public=null,this._maxSeq=0,this._minSeq=0,this._subscribed=!1;var e=this._tinode.getMeTopic();e&&e._routePres({_generated:!0,what:"gone",topic:"me",src:this.name}),this.onDeleteTopic&&this.onDeleteTopic()},_updateCachedUser:function(e,t,n){var r=this._cacheGetUser(e);return r?r=p(r,t):(n&&this.getMeta(this.startMetaQuery().withLaterOneSub(e).build()),r=p({},t)),this._cachePutUser(e,r),f(this._users,e,r)},_getQueuedSeqId:function(){return this._queuedSeqId++}};var S=function(e){E.call(this,"me",e),this._contacts={},e&&(this.onContactUpdate=e.onContactUpdate)};S.prototype=Object.create(E.prototype,{_processMetaSub:{value:function(e){var t=0;for(var n in e){var r=e[n],o=r.topic;if("fnd"!=o&&"me"!=o){r.updated=new Date(r.updated),r.touched=r.touched?new Date(r.touched):null,r.deleted=r.deleted?new Date(r.deleted):null,r.seq=0|r.seq,r.recv=0|r.recv,r.read=0|r.read,r.unread=r.seq-r.read;var i=null;if(r.deleted)i=r,delete this._contacts[o];else if(r.seen&&r.seen.when&&(r.seen.when=new Date(r.seen.when)),i=f(this._contacts,o,r),"p2p"==b.topicType(o)&&this._cachePutUser(o,i),!r._generated){var a=this._tinode.getTopic(o);a&&a._processMetaDesc(r,!0)}t++,this.onMetaSub&&this.onMetaSub(i)}}t>0&&this.onSubsUpdated&&this.onSubsUpdated(Object.keys(this._contacts))},enumerable:!0,configurable:!0,writable:!1},_routePres:{value:function(e){var t=this._contacts[e.src];if(t){switch(e.what){case"on":t.online=!0;break;case"off":t.online&&(t.online=!1,t.seen?t.seen.when=new Date:t.seen={when:new Date});break;case"msg":t.touched=new Date,t.seq=0|e.seq,t.unread=t.seq-t.read;break;case"upd":this.getMeta(this.startMetaQuery().withLaterOneSub(e.src).build());break;case"acs":t.acs?t.acs.updateAll(e.dacs):t.acs=(new w).updateAll(e.dacs);break;case"ua":t.seen={when:new Date,ua:e.ua};break;case"recv":t.recv=t.recv?Math.max(t.recv,e.seq):0|e.seq;break;case"read":t.read=t.read?Math.max(t.read,e.seq):0|e.seq,t.unread=t.seq-t.read;break;case"gone":delete this._contacts[e.src]}this.onContactUpdate&&this.onContactUpdate(e.what,t)}else if("acs"==e.what){var n=new w(e.dacs);if(!n||n.mode==w._INVALID)return void this._tinode.logger("Invalid access mode update",e.src,e.dacs);if(n.mode==w._NONE)return void this._tinode.logger("Removing non-existent subscription",e.src,e.dacs);this.getMeta(this.startMetaQuery().withOneSub(void 0,e.src).build()),this._contacts[e.src]={topic:e.src,online:!1,acs:n}}this.onPres&&this.onPres(e)},enumerable:!0,configurable:!0,writable:!1},publish:{value:function(){return Promise.reject(new Error("Publishing to 'me' is not supported"))},enumerable:!0,configurable:!0,writable:!1},contacts:{value:function(e,t){var n=e||this.onMetaSub;if(n)for(var r in this._contacts)n.call(t,this._contacts[r],r,this._contacts)},enumerable:!0,configurable:!0,writable:!0},setMsgReadRecv:{value:function(e,t,n,r){var o,i=this._contacts[e],a=!1;i&&(n|=0,"recv"===t?(o=i.recv,i.recv=i.recv?Math.max(i.recv,n):n,a=o!=i.recv):"read"===t?(o=i.read,i.read=i.read?Math.max(i.read,n):n,i.unread=i.seq-i.read,a=o!=i.read,i.recv0&&this.onSubsUpdated&&this.onSubsUpdated(Object.keys(this._contacts))},enumerable:!0,configurable:!0,writable:!1},publish:{value:function(){return Promise.reject(new Error("Publishing to 'fnd' is not supported"))},enumerable:!0,configurable:!0,writable:!1},setMeta:{value:function(e){var t=this;return Object.getPrototypeOf(T.prototype).setMeta.call(this,e).then(function(){Object.keys(t._contacts).length>0&&(t._contacts={},t.onSubsUpdated&&t.onSubsUpdated([]))})},enumerable:!0,configurable:!0,writable:!1},contacts:{value:function(e,t){var n=e||this.onMetaSub;if(n)for(var r in this._contacts)n.call(t,this._contacts[r],r,this._contacts)},enumerable:!0,configurable:!0,writable:!0}}),T.prototype.constructor=T;var k=function(e){this._tinode=e,this._apiKey=e._apiKey,this._authToken=e.getAuthToken(),this._msgId=e.getNextUniqueId(),this.xhr=h(),this.toResolve=null,this.toReject=null,this.onProgress=null,this.onSuccess=null,this.onFailure=null};k.prototype={upload:function(e,t,n,r){var o=this;if(!this._authToken)throw new Error("Must authenticate first");var a=this;this.xhr.open("POST","/v"+i+"/file/u/",!0),this.xhr.setRequestHeader("X-Tinode-APIKey",this._apiKey),this.xhr.setRequestHeader("X-Tinode-Auth","Token "+this._authToken.token);var s=new Promise(function(e,t){o.toResolve=e,o.toReject=t});this.onProgress=t,this.onSuccess=n,this.onFailure=r,this.xhr.upload.onprogress=function(e){e.lengthComputable&&a.onProgress&&a.onProgress(e.loaded/e.total)},this.xhr.onload=function(){var e;try{e=JSON.parse(this.response,m)}catch(e){a._tinode.logger("Invalid server response in LargeFileHelper",this.response)}this.status>=200&&this.status<300?(a.toResolve&&a.toResolve(e.ctrl.params.url),a.onSuccess&&a.onSuccess(e.ctrl)):this.status>=400?(a.toReject&&a.toReject(new Error(e.ctrl.text+" ("+e.ctrl.code+")")),a.onFailure&&a.onFailure(e.ctrl)):a._tinode.logger("Unexpected server response status",this.status,this.response)},this.xhr.onerror=function(e){a.toReject&&a.toReject(new Error("failed")),a.onFailure&&a.onFailure(null)},this.xhr.onabort=function(e){a.toReject&&a.toReject(new Error("upload cancelled by user")),a.onFailure&&a.onFailure(null)};try{var l=new FormData;l.append("file",e),l.set("id",this._msgId),this.xhr.send(l)}catch(e){this.toReject&&this.toReject(e),this.onFailure&&this.onFailure(null)}return s},download:function(e,t,n,r){var o=this;if(/^(?:(?:[a-z]+:)?\/\/)/i.test(e))throw new Error("The URL '"+e+"' must be relative, not absolute");if(!this._authToken)throw new Error("Must authenticate first");var i=this;this.xhr.open("GET",e,!0),this.xhr.setRequestHeader("X-Tinode-APIKey",this._apiKey),this.xhr.setRequestHeader("X-Tinode-Auth","Token "+this._authToken.token),this.xhr.responseType="blob",this.onProgress=r,this.xhr.onprogress=function(e){i.onProgress&&i.onProgress(e.loaded)};var a=new Promise(function(e,t){o.toResolve=e,o.toReject=t});this.xhr.onload=function(){if(200==this.status){var e=document.createElement("a");e.href=window.URL.createObjectURL(new Blob([this.response],{type:n})),e.style.display="none",e.setAttribute("download",t),document.body.appendChild(e),e.click(),document.body.removeChild(e),window.URL.revokeObjectURL(e.href),i.toResolve&&i.toResolve()}else if(this.status>=400&&i.toReject){var r=new FileReader;r.onload=function(){try{var e=JSON.parse(this.result,m);i.toReject(new Error(e.ctrl.text+" ("+e.ctrl.code+")"))}catch(e){i._tinode.logger("Invalid server response in LargeFileHelper",this.result),i.toReject(e)}},r.readAsText(this.response)}},this.xhr.onerror=function(e){i.toReject&&i.toReject(new Error("failed"))},this.xhr.onabort=function(){i.toReject&&i.toReject(null)};try{this.xhr.send()}catch(e){this.toReject&&this.toReject(e)}return a},cancel:function(){this.xhr&&this.xhr.readyState<4&&this.xhr.abort()},getId:function(){return this._msgId}};var C=function e(t,n){this.status=e.STATUS_NONE,this.topic=t,this.content=n};C.STATUS_NONE=0,C.STATUS_QUEUED=1,C.STATUS_SENDING=2,C.STATUS_FAILED=3,C.STATUS_SENT=4,C.STATUS_RECEIVED=5,C.STATUS_READ=6,C.STATUS_TO_ME=7,(C.prototype={toJSON:function(){},fromJSON:function(e){}}).constructor=C,(l=b).Drafty=e}.call(this,void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{}),l}()}).call(this,n(10))},function(e,t,n){e.exports=n(37)()},function(e,t,n){"use strict";!function e(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(e){console.error(e)}}(),e.exports=n(20)},function(e,t,n){"use strict";var r=n(23).default;n(30),(t=e.exports=r).default=t},function(e,t,n){"use strict";(t=e.exports=n(39).default).default=t},function(e,t,n){"use strict";var r=n(31).default;n(36),(t=e.exports=r).default=t},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1),o={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"},i=function(e,t){if(!e)throw a(t)},a=function(e){return new Error("Firebase Database ("+o.SDK_VERSION+") INTERNAL ASSERT FAILED: "+e)},s=function(e){for(var t=[],n=0,r=0;r>6|192,t[n++]=63&o|128):55296==(64512&o)&&r+1>18|240,t[n++]=o>>12&63|128,t[n++]=o>>6&63|128,t[n++]=63&o|128):(t[n++]=o>>12|224,t[n++]=o>>6&63|128,t[n++]=63&o|128)}return t},l={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:"function"==typeof atob,encodeByteArray:function(e,t){if(!Array.isArray(e))throw Error("encodeByteArray takes an array as a parameter");this.init_();for(var n=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[],o=0;o>2,d=(3&i)<<4|s>>4,p=(15&s)<<2|u>>6,f=63&u;l||(f=64,a||(p=64)),r.push(n[c],n[d],n[p],n[f])}return r.join("")},encodeString:function(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(s(e),t)},decodeString:function(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):function(e){for(var t=[],n=0,r=0;n191&&o<224){var i=e[n++];t[r++]=String.fromCharCode((31&o)<<6|63&i)}else if(o>239&&o<365){var a=((7&o)<<18|(63&(i=e[n++]))<<12|(63&(s=e[n++]))<<6|63&e[n++])-65536;t[r++]=String.fromCharCode(55296+(a>>10)),t[r++]=String.fromCharCode(56320+(1023&a))}else{i=e[n++];var s=e[n++];t[r++]=String.fromCharCode((15&o)<<12|(63&i)<<6|63&s)}}return t.join("")}(this.decodeStringToByteArray(e,t))},decodeStringToByteArray:function(e,t){this.init_();for(var n=t?this.charToByteMapWebSafe_:this.charToByteMap_,r=[],o=0;o>4;if(r.push(u),64!=s){var c=a<<4&240|s>>2;if(r.push(c),64!=l){var d=s<<6&192|l;r.push(d)}}}return r},init_:function(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(var e=0;e=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}},u=function(e){try{return l.decodeString(e,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function c(e,t){if(!(t instanceof Object))return t;switch(t.constructor){case Date:return new Date(t.getTime());case Object:void 0===e&&(e={});break;case Array:e=[];break;default:return t}for(var n in t)t.hasOwnProperty(n)&&(e[n]=c(e[n],t[n]));return e}var d=function(){function e(){var e=this;this.promise=new Promise(function(t,n){e.resolve=t,e.reject=n})}return e.prototype.wrapCallback=function(e){var t=this;return function(n,r){n?t.reject(n):t.resolve(r),"function"==typeof e&&(t.promise.catch(function(){}),1===e.length?e(n):e(n,r))}},e}(),p=function(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""},f="FirebaseError",h=Error.captureStackTrace;var m=function(){return function(e,t){if(this.code=e,this.message=t,h)h(this,y.prototype.create);else try{throw Error.apply(this,arguments)}catch(e){this.name=f,Object.defineProperty(this,"stack",{get:function(){return e.stack}})}}}();m.prototype=Object.create(Error.prototype),m.prototype.constructor=m,m.prototype.name=f;var y=function(){function e(e,t,n){this.service=e,this.serviceName=t,this.errors=n,this.pattern=/\{\$([^}]+)}/g}return e.prototype.create=function(e,t){void 0===t&&(t={});var n,r=this.errors[e],o=this.service+"/"+e;n=void 0===r?"Error":r.replace(this.pattern,function(e,n){var r=t[n];return void 0!==r?r.toString():"<"+n+"?>"}),n=this.serviceName+": "+n+" ("+o+").";var i=new m(o,n);for(var a in t)t.hasOwnProperty(a)&&"_"!==a.slice(-1)&&(i[a]=t[a]);return i},e}();function v(e){return JSON.parse(e)}var g=function(e){var t={},n={},r={},o="";try{var i=e.split(".");t=v(u(i[0])||""),n=v(u(i[1])||""),o=i[2],r=n.d||{},delete n.d}catch(e){}return{header:t,claims:n,data:r,signature:o}},b=function(e,t){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(n,e[n])},_=function(e,t){return b(t,function(t,n){e[t]=n}),e},w=function(e,t,n){for(var r in e)if(t.call(n,e[r],r,e))return r},E=function(e){function t(){var t=e.call(this)||this;t.chain_=[],t.buf_=[],t.W_=[],t.pad_=[],t.inbuf_=0,t.total_=0,t.blockSize=64,t.pad_[0]=128;for(var n=1;n>>31)}var i,a,s=this.chain_[0],l=this.chain_[1],u=this.chain_[2],c=this.chain_[3],d=this.chain_[4];for(r=0;r<80;r++){r<40?r<20?(i=c^l&(u^c),a=1518500249):(i=l^u^c,a=1859775393):r<60?(i=l&u|c&(l|u),a=2400959708):(i=l^u^c,a=3395469782);o=(s<<5|s>>>27)+i+d+a+n[r]&4294967295;d=c,c=u,u=4294967295&(l<<30|l>>>2),l=s,s=o}this.chain_[0]=this.chain_[0]+s&4294967295,this.chain_[1]=this.chain_[1]+l&4294967295,this.chain_[2]=this.chain_[2]+u&4294967295,this.chain_[3]=this.chain_[3]+c&4294967295,this.chain_[4]=this.chain_[4]+d&4294967295},t.prototype.update=function(e,t){if(null!=e){void 0===t&&(t=e.length);for(var n=t-this.blockSize,r=0,o=this.buf_,i=this.inbuf_;r=56;n--)this.buf_[n]=255&t,t/=256;this.compress_(this.buf_);var r=0;for(n=0;n<5;n++)for(var o=24;o>=0;o-=8)e[r]=this.chain_[n]>>o&255,++r;return e},t}(function(){return function(){this.blockSize=-1}}());var S=function(){function e(e,t){var n=this;this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(function(){e(n)}).catch(function(e){n.error(e)})}return e.prototype.next=function(e){this.forEachObserver(function(t){t.next(e)})},e.prototype.error=function(e){this.forEachObserver(function(t){t.error(e)}),this.close(e)},e.prototype.complete=function(){this.forEachObserver(function(e){e.complete()}),this.close()},e.prototype.subscribe=function(e,t,n){var r,o=this;if(void 0===e&&void 0===t&&void 0===n)throw new Error("Missing Observer.");void 0===(r=function(e,t){if("object"!=typeof e||null===e)return!1;for(var n=0,r=t;n 4. Need to update it?")}var o=e+" failed: ";return o+=r+" argument "}t.assert=i,t.assertionError=a,t.base64=l,t.base64Decode=u,t.base64Encode=function(e){var t=s(e);return l.encodeByteArray(t,!0)},t.CONSTANTS=o,t.deepCopy=function(e){return c(void 0,e)},t.deepExtend=c,t.patchProperty=function(e,t,n){e[t]=n},t.Deferred=d,t.getUA=p,t.isMobileCordova=function(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(p())},t.isNodeSdk=function(){return!0===o.NODE_CLIENT||!0===o.NODE_ADMIN},t.isReactNative=function(){return"object"==typeof navigator&&"ReactNative"===navigator.product},t.ErrorFactory=y,t.FirebaseError=m,t.patchCapture=function(e){var t=h;return h=e,t},t.jsonEval=v,t.stringify=function(e){return JSON.stringify(e)},t.decode=g,t.isAdmin=function(e){var t=g(e).claims;return"object"==typeof t&&!0===t.admin},t.issuedAtTime=function(e){var t=g(e).claims;return"object"==typeof t&&t.hasOwnProperty("iat")?t.iat:null},t.isValidFormat=function(e){var t=g(e).claims;return!!t&&"object"==typeof t&&t.hasOwnProperty("iat")},t.isValidTimestamp=function(e){var t,n,r=g(e).claims,o=Math.floor((new Date).getTime()/1e3);return"object"==typeof r&&(r.hasOwnProperty("nbf")?t=r.nbf:r.hasOwnProperty("iat")&&(t=r.iat),n=r.hasOwnProperty("exp")?r.exp:t+86400),o&&t&&n&&o>=t&&o<=n},t.clone=function(e){return _({},e)},t.contains=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.every=function(e,t){for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&!t(n,e[n]))return!1;return!0},t.extend=_,t.findKey=w,t.findValue=function(e,t,n){var r=w(e,t,n);return r&&e[r]},t.forEach=b,t.getAnyKey=function(e){for(var t in e)return t},t.getCount=function(e){var t=0;for(var n in e)t++;return t},t.getValues=function(e){var t=[],n=0;for(var r in e)t[n++]=e[r];return t},t.isEmpty=function(e){for(var t in e)return!1;return!0},t.isNonNullObject=function(e){return"object"==typeof e&&null!==e},t.map=function(e,t,n){var r={};for(var o in e)r[o]=t.call(n,e[o],o,e);return r},t.safeGet=function(e,t){if(Object.prototype.hasOwnProperty.call(e,t))return e[t]},t.querystring=function(e){var t=[];return b(e,function(e,n){Array.isArray(n)?n.forEach(function(n){t.push(encodeURIComponent(e)+"="+encodeURIComponent(n))}):t.push(encodeURIComponent(e)+"="+encodeURIComponent(n))}),t.length?"&"+t.join("&"):""},t.querystringDecode=function(e){var t={};return e.replace(/^\?/,"").split("&").forEach(function(e){if(e){var n=e.split("=");t[n[0]]=n[1]}}),t},t.Sha1=E,t.async=function(e,t){return function(){for(var n=[],r=0;rn&&(o=0===n?"none":"no more than "+n),o)throw new Error(e+" failed: Was called with "+r+(1===r?" argument.":" arguments.")+" Expects "+o+".")},t.validateCallback=function(e,t,n,r){if((!r||n)&&"function"!=typeof n)throw new Error(k(e,t,r)+"must be a valid function.")},t.validateContextObject=function(e,t,n,r){if((!r||n)&&("object"!=typeof n||null===n))throw new Error(k(e,t,r)+"must be a valid context object.")},t.validateNamespace=function(e,t,n,r){if((!r||n)&&"string"!=typeof n)throw new Error(k(e,t,r)+"must be a valid firebase namespace.")},t.stringLength=function(e){for(var t=0,n=0;n=55296&&r<=56319?(t+=4,n++):t+=3}return t},t.stringToByteArray=function(e){for(var t=[],n=0,r=0;r=55296&&o<=56319){var a=o-55296;i(++r>6|192,t[n++]=63&o|128):o<65536?(t[n++]=o>>12|224,t[n++]=o>>6&63|128,t[n++]=63&o|128):(t[n++]=o>>18|240,t[n++]=o>>12&63|128,t[n++]=o>>6&63|128,t[n++]=63&o|128)}return t}},function(e,t,n){"use strict";e.exports=function(e,t,n,r,o,i,a,s){if(!e){var l;if(void 0===t)l=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[n,r,o,i,a,s],c=0;(l=new Error(t.replace(/%s/g,function(){return u[c++]}))).name="Invariant Violation"}throw l.framesToPop=1,l}}},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e){e.exports={en:{contacts_not_found:"You have no chats
¯\\\\_(ツ)_/¯",full_name_prompt:"Full name, e.g. John Doe",email_prompt:"Email, e.g. jdoe@example.com",button_sign_up:"Sign up",label_your_name:"Your name",label_password:"Password",password_unchanged_prompt:"Unchanged",label_user_id:"Address:",label_default_access_mode:"Default access mode:",label_message_sound:"Message sound:",label_push_notifications:"Notification alerts:",label_push_notifications_disabled:"Notification alerts (requires HTTPS):",title_tag_manager:"Tags (user discovery)",button_logout:"Logout",login_prompt:"Login",password_prompt:"Password",stay_logged_in:"Stay logged in",forgot_password_link:"Forgot password?",button_sign_in:"Sign in",label_client:"Client:",label_server:"Server:",online_now:"online now",last_seen_timestamp:"Last seen",title_not_found:"Not found",unnamed_topic:"Unnamed",messages_not_readable:"no access to messages",tabtitle_find_user:"find",tabtitle_new_group:"new group",tabtitle_group_by_id:"by id",search_for_contacts:"Use search to find contacts",label_server_to_use:"Server to use:",label_wire_transport:"Wire transport:",button_update:"Update",sidepanel_title_login:"Sign In",sidepanel_title_register:"Create Account",sidepanel_title_settings:"Settings",sidepanel_title_edit_account:"Edit Account",sidepanel_title_newtpk:"Start New Chat",sidepanel_title_cred:"Confirm Credentials",sidepanel_title_reset:"Reset Password",phone_dative:"phone",email_dative:"email",enter_confirmation_code_prompt:"Enter confirmation code sent to you by {method}:",numeric_confirmation_code_prompt:"Numbers only",button_confirm:"Confirm",invalid_content:"invalid content",title_group_members:"Group members",button_ok:"OK",button_cancel:"Cancel",download_action:"download",label_file_name:"File name:",label_content_type:"Content type:",label_size:"Size:",permission_join:"Join ({val})",permission_read:"Read ({val})",permission_write:"Write ({val})",permission_pres:"Get notified ({val})",permission_admin:"Approve ({val})",permission_share:"Share ({val})",permission_delete:"Delete ({val})",permission_owner:"Owner ({val})",title_permissions:"Permissions",message_sending:"sending...",message_sending_failed:"failed",search_placeholder:"List like email:alice@example.com, tel:17025550003...",messaging_disabled_prompt:"Messaging disabled",new_message_prompt:"New message",file_attachment_too_large:"The file size {size} exceeds the {limit} limit.",cannot_initiate_file_upload:"Cannot initiate file upload.",tags_not_found:"No tags defined. Add some.",tags_editor_no_tags:"Add some tags",title_manage_tags:"Manage tags"},ru:{contacts_not_found:"Чатов нет
¯\\\\_(ツ)_/¯",full_name_prompt:"Полное имя, напр. Иван Петров",email_prompt:"Email, напр. ivan@example.com",button_sign_up:"Создать счет",label_your_name:"Ваше имя",label_password:"Пароль",password_unchanged_prompt:"Не изменен",label_user_id:"Адрес:",label_default_access_mode:"Доступ по умолчанию:",label_message_sound:"Звук нового сообщения:",label_push_notifications:"Уведомления:",label_push_notifications_disabled:"Уведомления (требуют HTTPS):",title_tag_manager:"Таги для поиска",button_logout:"Выйти",login_prompt:"Логин",password_prompt:"Пароль",stay_logged_in:"Запомнить",forgot_password_link:"Напомнить пароль",button_sign_in:"Войти",label_client:"Клиент:",label_server:"Сервер:",online_now:"онлайн",last_seen_timestamp:"Был активен",title_not_found:"Не найден",unnamed_topic:"Без названия",messages_not_readable:"нет доступа к сообщениям",tabtitle_find_user:"найти",tabtitle_new_group:"создать",tabtitle_group_by_id:"по id",label_server_to_use:"Использовать сервер:",label_wire_transport:"Соединение:",button_update:"Применить",sidepanel_title_login:"Авторизация",sidepanel_title_register:"Зарегистрироваться",sidepanel_title_settings:"Настройки",sidepanel_title_edit_account:"Редактировать счет",sidepanel_title_newtpk:"Новый чат",sidepanel_title_cred:"Подтвердить",sidepanel_title_reset:"Сменить пароль",tags_not_found:"Тагов нет. Добавьте",tags_editor_no_tags:"Добавьте таги",title_manage_tags:"Редактор тагов",message_sending:"шлём...",message_sending_failed:"ошибка",search_placeholder:"Список, напр. email:alice@example.com, tel:17025550003...",messaging_disabled_prompt:"Отправка недоступна",new_message_prompt:"Новое сообщение",file_attachment_too_large:"Размер файла {size} превышает {limit} лимит.",cannot_initiate_file_upload:"Ошибка загрузки файла.",search_for_contacts:"Поиск контактов",enter_confirmation_code_prompt:"Код подтверждения, полученный по {method}:",numeric_confirmation_code_prompt:"Только цифры",button_confirm:"Подтвердить",button_ok:"OK",button_cancel:"Отменить",invalid_content:"сообщение не читается",label_file_name:"Имя файла:",label_content_type:"Тип:",label_size:"Размер:",phone_dative:"телефону",email_dative:"емейлу",title_group_members:"Участники",download_action:"скачать",permission_join:"Присоединяться ({val})",permission_read:"Читать ({val})",permission_write:"Писать ({val})",permission_pres:"Получать уведомления ({val})",permission_admin:"Администрировать ({val})",permission_share:"Приглашать ({val})",permission_delete:"Удалять ({val})",permission_owner:"Владелец ({val})",title_permissions:"Права доступа"}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(8),o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i="[DEFAULT]",a=[],s=function(){function e(e,t,n){this.firebase_=n,this.isDeleted_=!1,this.services_={},this.name_=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled||!1,this.options_=r.deepCopy(e),this.INTERNAL={getUid:function(){return null},getToken:function(){return Promise.resolve(null)},addAuthTokenListener:function(e){a.push(e),setTimeout(function(){return e(null)},0)},removeAuthTokenListener:function(e){a=a.filter(function(t){return t!==e})}}}return Object.defineProperty(e.prototype,"automaticDataCollectionEnabled",{get:function(){return this.checkDestroyed_(),this._automaticDataCollectionEnabled},set:function(e){this.checkDestroyed_(),this._automaticDataCollectionEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this.checkDestroyed_(),this.name_},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"options",{get:function(){return this.checkDestroyed_(),this.options_},enumerable:!0,configurable:!0}),e.prototype.delete=function(){var e=this;return new Promise(function(t){e.checkDestroyed_(),t()}).then(function(){e.firebase_.INTERNAL.removeApp(e.name_);var t=[];return Object.keys(e.services_).forEach(function(n){Object.keys(e.services_[n]).forEach(function(r){t.push(e.services_[n][r])})}),Promise.all(t.map(function(e){return e.INTERNAL.delete()}))}).then(function(){e.isDeleted_=!0,e.services_={}})},e.prototype._getService=function(e,t){if(void 0===t&&(t=i),this.checkDestroyed_(),this.services_[e]||(this.services_[e]={}),!this.services_[e][t]){var n=t!==i?t:void 0,r=this.firebase_.INTERNAL.factories[e](this,this.extendApp.bind(this),n);this.services_[e][t]=r}return this.services_[e][t]},e.prototype.extendApp=function(e){var t=this;r.deepExtend(this,e),e.INTERNAL&&e.INTERNAL.addAuthTokenListener&&(a.forEach(function(e){t.INTERNAL.addAuthTokenListener(e)}),a=[])},e.prototype.checkDestroyed_=function(){this.isDeleted_&&l("app-deleted",{name:this.name_})},e}();function l(e,t){throw u.create(e,t)}s.prototype.name&&s.prototype.options||s.prototype.delete||console.log("dc");var u=new r.ErrorFactory("app","Firebase",{"no-app":"No Firebase App '{$name}' has been created - call Firebase App.initializeApp()","bad-app-name":"Illegal App name: '{$name}","duplicate-app":"Firebase App named '{$name}' already exists","app-deleted":"Firebase App named '{$name}' already deleted","duplicate-service":"Firebase service named '{$name}' already registered","sa-not-supported":"Initializing the Firebase SDK with a service account is only allowed in a Node.js environment. On client devices, you should instead initialize the SDK with an api key and auth domain","invalid-app-argument":"firebase.{$name}() takes either no argument or a Firebase App instance."}),c=function e(){var t={},n={},a={},u={__esModule:!0,initializeApp:function(e,n){if(void 0===n&&(n={}),"object"!=typeof n||null===n){var r=n;n={name:r}}var a=n;void 0===a.name&&(a.name=i);var c=a.name;"string"==typeof c&&c||l("bad-app-name",{name:c+""}),o(t,c)&&l("duplicate-app",{name:c});var d=new s(e,a,u);return t[c]=d,p(d,"create"),d},app:c,apps:null,Promise:Promise,SDK_VERSION:"5.5.0",INTERNAL:{registerService:function(e,t,o,i,p){n[e]&&l("duplicate-service",{name:e}),n[e]=t,i&&(a[e]=i,d().forEach(function(e){i("create",e)}));var f=function(t){return void 0===t&&(t=c()),"function"!=typeof t[e]&&l("invalid-app-argument",{name:e}),t[e]()};return void 0!==o&&r.deepExtend(f,o),u[e]=f,s.prototype[e]=function(){for(var t=[],n=0;n=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function l(e,t){return function(n,r){t(n,r,e)}}function u(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function c(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{l(r.next(e))}catch(e){i(e)}}function s(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,s)}l((r=r.apply(e,t||[])).next())})}function d(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=r[2&i[0]?"return":i[0]?"throw":"next"])&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[0,o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}function h(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function m(){for(var e=[],t=0;t1||s(e,t)})})}function s(e,t){try{!function(e){e.value instanceof y?Promise.resolve(e.value.v).then(l,u):c(i[0][2],e)}(o[e](t))}catch(e){c(i[0][3],e)}}function l(e){s("next",e)}function u(e){s("throw",e)}function c(e,t){e(t),i.shift(),i.length&&s(i[0][0],i[0][1])}}function g(e){var t,n;return t={},r("next"),r("throw",function(e){throw e}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(r,o){e[r]&&(t[r]=function(t){return(n=!n)?{value:y(e[r](t)),done:"return"===r}:o?o(t):t})}}function b(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator];return t?t.call(e):f(e)}function _(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function w(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function E(e){return e&&e.__esModule?e:{default:e}}},function(e,t,n){(function(t){e.exports=function(){var e={},n=[{name:"ST",start:/(?:^|\W)(\*)[^\s*]/,end:/[^\s*](\*)(?=$|\W)/},{name:"EM",start:/(?:^|[\W_])(_)[^\s_]/,end:/[^\s_](_)(?=$|[\W_])/},{name:"DL",start:/(?:^|\W)(~)[^\s~]/,end:/[^\s~](~)(?=$|\W)/},{name:"CO",start:/(?:^|\W)(`)[^`]/,end:/[^`](`)(?=$|\W)/}],r=[{name:"LN",dataName:"url",pack:function(e){return/^[a-z]+:\/\//i.test(e)||(e="http://"+e),{url:e}},re:/(?:(?:https?|ftp):\/\/|www\.|ftp\.)[-A-Z0-9+&@#\/%=~_|$?!:,.]*[A-Z0-9+&@#\/%=~_|$]/gi},{name:"MN",dataName:"val",pack:function(e){return{val:e.slice(1)}},re:/\B@(\w\w+)/g},{name:"HT",dataName:"val",pack:function(e){return{val:e.slice(1)}},re:/\B#(\w\w+)/g}],o={ST:{name:"b",isVoid:!1},EM:{name:"i",isVoid:!1},DL:{name:"del",isVoid:!1},CO:{name:"tt",isVoid:!1},BR:{name:"br",isVoid:!0},LN:{name:"a",isVoid:!1},MN:{name:"a",isVoid:!1},HT:{name:"a",isVoid:!1},IM:{name:"img",isVoid:!0}};function i(e,t){var n;try{n=atob(e)}catch(e){console.log("Drafty: failed to decode base64-encoded object",e.message),n=atob("")}for(var r=n.length,o=new ArrayBuffer(r),i=new Uint8Array(o),a=0;a"},close:function(){return""}},EM:{open:function(){return""},close:function(){return""}},DL:{open:function(){return""},close:function(){return""}},CO:{open:function(){return""},close:function(){return""}},BR:{open:function(){return""},close:function(){return"
"}},LN:{open:function(e){return''},close:function(e){return""},props:function(e){return{href:e.url,target:"_blank"}}},MN:{open:function(e){return''},close:function(e){return""},props:function(e){return{name:e.val}}},HT:{open:function(e){return''},close:function(e){return""},props:function(e){return{name:e.val}}},IM:{open:function(e){var t=i(e.val,e.mime),n=e.ref?e.ref:t,r=(e.name?'':"")+'';return console.log("open: "+r),r},close:function(e){return e.name?"":""},props:function(e){return{src:i(e.val,e.mime),title:e.name,"data-width":e.width,"data-height":e.height,"data-name":e.name,"data-size":.75*e.val.length|0,"data-mime":e.mime}}}},s=function(){};s.parse=function(e){if("string"!=typeof e)return null;var t=e.split(/\r?\n/),o=[],i={},a=[];t.map(function(e){var t,s,l=[];if(n.map(function(t){l=l.concat(function(e,t,n,r){for(var o=[],i=0,a=e.slice(0);a.length>0;){var s=t.exec(a);if(null==s)break;var l=s.index+s[0].lastIndexOf(s[1]);a=a.slice(l+1),i=(l+=i)+1;var u=n?n.exec(a):null;if(null==u)break;var c=u.index+u[0].indexOf(u[1]);a=a.slice(c+1),i=(c+=i)+1,o.push({text:e.slice(l+1,c),children:[],start:l,end:c,type:r})}return o}(e,t.start,t.end,t.name))}),0==l.length)s={txt:e};else{l.sort(function(e,t){return e.start-t.start}),l=function e(t){if(0==t.length)return[];for(var n=[t[0]],r=t[0],o=1;or.end?(n.push(t[o]),r=t[o]):t[o].endn&&i.push({text:t.slice(n,s.start)});var l={type:s.type},u=e(t,s.start+1,s.end-1,s.children);u.length>0?l.children=u:l.text=s.text,i.push(l),n=s.end+1}return no;return o=e.offset+e.len,t})}(s.txt)).length>0){var c=[];for(var d in t){var p=t[d],f=i[p.unique];f||(f=o.length,i[p.unique]=f,o.push({tp:p.type,data:p.data})),c.push({at:p.offset,len:p.len,key:f})}s.ent=c}a.push(s)});var s={txt:""};if(a.length>0){s.txt=a[0].txt,s.fmt=(a[0].fmt||[]).concat(a[0].ent||[]);for(var l=1;l0&&(s.ent=o)}return s},s.insertImage=function(e,t,n,r,o,i,a,s,l){return(e=e||{txt:" "}).ent=e.ent||[],e.fmt=e.fmt||[],e.fmt.push({at:t,len:1,key:e.ent.length}),e.ent.push({tp:"IM",data:{mime:n,val:r,width:o,height:i,name:a,ref:l,size:0|s}}),e},s.attachFile=function(e,t,n,r,o,i){(e=e||{txt:""}).ent=e.ent||[],e.fmt=e.fmt||[],e.fmt.push({at:-1,len:0,key:e.ent.length});var a={tp:"EX",data:{mime:t,val:n,name:r,ref:i,size:0|o}};return i instanceof Promise&&(a.data.ref=i.then(function(e){a.data.ref=e},function(e){})),e.ent.push(a),e},s.UNSAFE_toHTML=function(e){var t,n,r,o=e.txt,i=e.fmt,s=e.ent,l=[];if(i)for(var u in i){var c,d=i[u],p=d.tp;if(!p){var f=s[d.key];f&&(p=f.tp,c=f.data)}a[p]&&(l.push({idx:d.at+d.len,what:a[p].close(c)}),l.push({idx:d.at,what:a[p].open(c)}))}for(var u in l.sort(function(e,t){return t.idx-e.idx}),l)l[u].what&&(t=o,n=l[u].idx,r=l[u].what,o=t.slice(0,n)+r+t.slice(n));return o},s.format=function(e,t,n){var r=e.txt,i=e.fmt,a=e.ent;if(r=r||"",!i)return[r];var s=[].concat(i);return s.map(function(e){e.at=e.at||0,e.len=e.len||0}),s.sort(function(e,t){return e.at-t.at==0?t.len-e.len:e.at-t.at}),s=s.map(function(e){var t,n=e.tp;return n||(e.key=e.key||0,t=a[e.key].data,n=a[e.key].tp),{tp:n,data:t,at:e.at,len:e.len}}),function e(t,n,r,i,a,s){for(var l=[],u=0;u0)for(var t in e.ent)if("EX"==e.ent[t].tp)return!0;return!1},s.attachments=function(e,t,n){if(e.ent&&e.ent.length>0)for(var r in e.ent)"EX"==e.ent[r].tp&&t.call(n,e.ent[r].data,r)},s.getDownloadUrl=function(e){var t=null;return e.val?t=i(e.val,e.mime):"string"==typeof e.ref&&(t=e.ref),t},s.isUploading=function(e){return e.ref instanceof Promise},s.getPreviewUrl=function(e){return e.val?i(e.val,e.mime):null},s.getEntitySize=function(e){return e.size?e.size:e.val?.75*e.val.length|0:0},s.getEntityMimeType=function(e){return e.mime||"text/plain"},s.tagName=function(e){return o[e]?o[e].name:void 0},s.attrValue=function(e,t){if(t&&a[e])return a[e].props(t)},s.getContentType=function(){return"text/x-drafty"},e=s;var l={};return function(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)}var r,o="0.15.8-rc1";"undefined"!=typeof WebSocket&&(r=WebSocket),"undefined"==typeof btoa&&(t.btoa=function(){for(var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n="",r=0,o=0,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";t.charAt(0|o)||(i="=",o%1);n+=i.charAt(63&r>>8-o%1*8)){if((e=t.charCodeAt(o+=.75))>255)throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");r=r<<8|e}return n}),"undefined"==typeof atob&&(t.atob=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").replace(/=+$/,""),t="";if(e.length%4==1)throw new Error("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r=0,o=0,i=0;n=e.charAt(i++);~n&&(o=r%4?64*o+n:n,r++%4)?t+=String.fromCharCode(255&o>>(-2*r&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return t}),"undefined"==typeof window&&(t.window={WebSocket:r,URL:{createObjectURL:function(){throw new Error("Unable to use window.URL in a non browser application")}}});var i="0",a=o||"0.15",s="tinodejs/"+a,u=503,c="Connection failed";function d(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))}function p(e,t,r){if(null==t)return e;if("object"!==n(t))return t||e;if(t instanceof Date)return t;if(t instanceof w)return new w(t);if(t instanceof Array)return t.length>0?t:e;for(var o in e||(e=t.constructor()),t)!t.hasOwnProperty(o)||!t[o]&&!1!==t[o]||r&&r[o]||"_generated"==o||(e[o]=p(e[o],t[o]));return e}function f(e,t,n,r){return e[t]=p(e[t],n,r),e[t]}function h(){var e=null;if("withCredentials"in new XMLHttpRequest)e=new XMLHttpRequest;else{if("undefined"==typeof XDomainRequest)throw new Error("browser not supported");e=new XDomainRequest}return e}function m(e,t){if("ts"===e&&"string"==typeof t&&t.length>=20&&t.length<=24){var r=new Date(t);if(r)return r}else if("acs"===e&&"object"===n(t))return new w(t);return t}function y(e,t){return"string"==typeof t&&t.length>128?"<"+t.length+", bytes: "+t.substring(0,12)+"..."+t.substring(t.length-12)+">":function(e,t){if(t instanceof Date)t=function(e){if(e&&0!=e.getTime()){var t=e.getUTCMilliseconds();return e.getUTCFullYear()+"-"+n(e.getUTCMonth()+1)+"-"+n(e.getUTCDate())+"T"+n(e.getUTCHours())+":"+n(e.getUTCMinutes())+":"+n(e.getUTCSeconds())+(t?"."+n(t,3):"")+"Z"}function n(e,t){return"0".repeat((t=t||2)-(""+e).length)+e}}(t);else if(null==t||!1===t||Array.isArray(t)&&0==t.length||"object"===n(t)&&0===Object.keys(t).length)return;return t}(0,t)}function v(e,t,n){var r=null;return"http"!==t&&"https"!==t&&"ws"!==t&&"wss"!==t||(r=t+"://","/"!==(r+=e).charAt(r.length-1)&&(r+="/"),r+="v"+i+"/channels","http"!==t&&"https"!==t||(r+="/lp"),r+="?apikey="+n),r}var g=function(e,t,o,i,a){var s=this,l=e,d=i,p=t,f=a,y=2e3,g=10,b=.3,_=null,w=0,E=!1,S=function(e){s.logger&&s.logger(e)};function T(e){var t=null;e.connect=function(n){return t&&1===t.readyState?Promise.resolve():(n&&(l=n),new Promise(function(n,o){var i=v(l,d?"wss":"ws",p);S("Connecting to: "+i);var a=new r(i);a.onopen=function(t){E=!1,e.onOpen&&e.onOpen(),n(),f&&(clearTimeout(_),_=null,w=0)},a.onclose=function(n){t=null,e.onDisconnect&&e.onDisconnect(null),!E&&f&&function(){var e=this;clearTimeout(_);var t=y*(Math.pow(2,w)*(1+b*Math.random()));w=w>=g?w:w+1,_=setTimeout(function(){S("Reconnecting, iter="+w+", timeout="+t),E||e.connect().catch(function(){})},t)}.call(e)},a.onerror=function(e){o(e)},a.onmessage=function(t){e.onMessage&&e.onMessage(t.data)},t=a}))},e.disconnect=function(){t&&(E=!0,t.close()),t=null},e.sendText=function(e){if(!t||t.readyState!=t.OPEN)throw new Error("Websocket is not connected");t.send(e)},e.isConnected=function(){return t&&1===t.readyState},e.transport=function(){return"ws"}}function k(e){var t=null,n=null,r=null;e.connect=function(r){return n?Promise.resolve():(r&&(l=r),new Promise(function(r,o){var i=v(l,d?"https":"http",p);S("Connecting to: "+i),(n=function n(r,o,i){var a=h();return a.onreadystatechange=function(s){if(4==a.readyState)if(201==a.status){var l=JSON.parse(a.responseText,m);a.responseText,t=r+"&sid="+l.ctrl.params.sid,(a=n(t)).send(null),e.onOpen&&e.onOpen(),o&&o()}else if(200==a.status)e.onMessage&&e.onMessage(a.responseText),(a=n(t)).send(null);else if(i&&i(a.responseText),e.onMessage&&a.responseText&&e.onMessage(a.responseText),e.onDisconnect){var d=a.status||u,p=a.responseText||c;e.onDisconnect(new Error(p+"("+d+")"))}},a.open("GET",r,!0),a}(i,r,o)).send(null)}).catch(function(){}))},e.disconnect=function(){r&&(r.onreadystatechange=void 0,r.abort(),r=null),n&&(n.onreadystatechange=void 0,n.abort(),n=null),e.onDisconnect&&e.onDisconnect(null),t=null},e.sendText=function(e){var n,o;if(n=t,(o=h()).onreadystatechange=function(e){if(4==o.readyState&&o.status>=400)throw new Error("LP sender failed, "+o.status)},o.open("POST",n,!0),!(r=o)||1!=r.readyState)throw new Error("Long poller failed to connect");r.send(e)},e.isConnected=function(){return n&&!0},e.transport=function(){return"lp"}}"lp"===o?k(this):"ws"===o?T(this):"object"==("undefined"==typeof window?"undefined":n(window))&&window.WebSocket?T(this):k(this),this.onMessage=void 0,this.onDisconnect=void 0,this.onOpen=void 0,this.logger=void 0},b=function(e,t,r,o,i){var l=this;this._appName=e||"Undefined",this._apiKey=r,this._browser="",this._platform="undefined",this._humanLanguage="xx","undefined"!=typeof navigator&&(this._browser=function(e){var t,n=(e=(e||"").replace(" (KHTML, like Gecko)","")).match(/(AppleWebKit\/[.\d]+)/i);if(n){for(var r=["chrome","safari","mobile","version"],o=e.substr(n.index+n[0].length).split(" "),i=[],a=0;a0?i[0][0]+"/"+i[0][1]:n[1]}else t=/trident/i.test(e)?(n=/(?:\brv[ :]+([.\d]+))|(?:\bMSIE ([.\d]+))/g.exec(e))?"MSIE/"+(n[1]||n[2]):"MSIE/?":/firefox/i.test(e)?(n=/Firefox\/([.\d]+)/g.exec(e))?"Firefox/"+n[1]:"Firefox/?":/presto/i.test(e)?(n=/Opera\/([.\d]+)/g.exec(e))?"Opera/"+n[1]:"Opera/?":(n=/([\w.]+)\/([.\d]+)/.exec(e))?n[1]+"/"+n[2]:(n=e.split(" "))[0];if((n=t.split("/")).length>1){var l=n[1].split(".");t=n[0]+"/"+l[0]+(l[1]?"."+l[1]:"")}return t}(navigator.userAgent),this._platform=navigator.platform,this._humanLanguage=navigator.language||"en-US"),this._loggingEnabled=!1,this._trimLongStrings=!1,this._myUID=null,this._authenticated=!1,this._login=null,this._authToken=null,this._inPacketCount=0,this._messageId=Math.floor(65535*Math.random()+65535),this._serverInfo=null,this._deviceToken=null,this._pendingPromises={},this._connection=new g(t,r,o,i,!0),this.logger=function(e){if(l._loggingEnabled){var t=new Date,n=("0"+t.getUTCHours()).slice(-2)+":"+("0"+t.getUTCMinutes()).slice(-2)+":"+("0"+t.getUTCSeconds()).slice(-2)+":"+("0"+t.getUTCMilliseconds()).slice(-3);console.log("["+n+"] "+e)}},this._connection.logger=this.logger,this._cache={};var d=this.cachePut=function(e,t,n){l._cache[e+":"+t]=n},f=this.cacheGet=function(e,t){return l._cache[e+":"+t]},h=this.cacheDel=function(e,t){delete l._cache[e+":"+t]},v=this.cacheMap=function(e,t){for(var n in l._cache)if(e(l._cache[n],n,t))break};this.attachCacheToTopic=function(e){e._tinode=l,e._cacheGetUser=function(e){var t=f("user",e);if(t)return{user:e,public:p({},t)}},e._cachePutUser=function(e,t){return d("user",e,p({},t.public))},e._cacheDelUser=function(e){return h("user",e)},e._cachePutSelf=function(){return d("topic",e.name,e)},e._cacheDelSelf=function(){return h("topic",e.name)}};var b=function(e,t,n,r){var o=l._pendingPromises[e];o&&(delete l._pendingPromises[e],t>=200&&t<400?o.resolve&&o.resolve(n):o.reject&&o.reject(new Error("Error: "+r+" ("+t+")")))},_=this.getNextUniqueId=function(){return 0!=l._messageId?""+l._messageId++:void 0};this.initPacket=function(e,t){switch(e){case"hi":return{hi:{id:_(),ver:a,ua:l._appName+" ("+(l._browser?l._browser+"; ":"")+l._platform+"); "+s,dev:l._deviceToken,lang:l._humanLanguage}};case"acc":return{acc:{id:_(),user:null,scheme:null,secret:null,login:!1,tags:null,desc:{},cred:{}}};case"login":return{login:{id:_(),scheme:null,secret:null}};case"sub":return{sub:{id:_(),topic:t,set:{},get:{}}};case"leave":return{leave:{id:_(),topic:t,unsub:!1}};case"pub":return{pub:{id:_(),topic:t,noecho:!1,head:null,content:{}}};case"get":return{get:{id:_(),topic:t,what:null,desc:{},sub:{},data:{}}};case"set":return{set:{id:_(),topic:t,desc:{},sub:{},tags:[]}};case"del":return{del:{id:_(),topic:t,what:null,delseq:null,user:null,hard:!1}};case"note":return{note:{topic:t,what:null,seq:void 0}};default:throw new Error("Unknown packet type requested: "+e)}},this.send=function(e,t){var r;t&&(r=function(e){var t=null;return e&&(t=new Promise(function(t,n){l._pendingPromises[e]={resolve:t,reject:n}})),t}(t)),e=function e(t){return Object.keys(t).forEach(function(r){"_"==r[0]?delete t[r]:t[r]?Array.isArray(t[r])&&0==t[r].length?delete t[r]:t[r]?"object"!=n(t[r])||t[r]instanceof Date||(e(t[r]),0==Object.getOwnPropertyNames(t[r]).length&&delete t[r]):delete t[r]:delete t[r]}),t}(e);var o=JSON.stringify(e);l.logger("out: "+(l._trimLongStrings?JSON.stringify(e,y):o));try{l._connection.sendText(o)}catch(e){if(!t)throw e;b(t,u,null,e.message)}return r},this.loginSuccessful=function(e){e.params&&e.params.user&&(l._myUID=e.params.user,l._authenticated=e&&e.code>=200&&e.code<300,e.params&&e.params.token&&e.params.expires?l._authToken={token:e.params.token,expires:new Date(e.params.expires)}:l._authToken=null,l.onLogin&&l.onLogin(e.code,e.text))},this._connection.onMessage=function(e){if(e){l._inPacketCount++,l.onRawMessage&&l.onRawMessage(e);var t=JSON.parse(e,m);if(t)if(l.logger("in: "+(l._trimLongStrings?JSON.stringify(t,y):e)),l.onMessage&&l.onMessage(t),t.ctrl)l.onCtrlMessage&&l.onCtrlMessage(t.ctrl),t.ctrl.id&&b(t.ctrl.id,t.ctrl.code,t.ctrl,t.ctrl.text),t.ctrl.params&&"data"==t.ctrl.params.what&&(n=f("topic",t.ctrl.topic))&&n._allMessagesReceived(t.ctrl.params.count);else if(t.meta)(n=f("topic",t.meta.topic))&&n._routeMeta(t.meta),l.onMetaMessage&&l.onMetaMessage(t.meta);else if(t.data)(n=f("topic",t.data.topic))&&n._routeData(t.data),l.onDataMessage&&l.onDataMessage(t.data);else if(t.pres)(n=f("topic",t.pres.topic))&&n._routePres(t.pres),l.onPresMessage&&l.onPresMessage(t.pres);else if(t.info){var n;(n=f("topic",t.info.topic))&&n._routeInfo(t.info),l.onInfoMessage&&l.onInfoMessage(t.info)}else l.logger("ERROR: Unknown packet received.");else l.logger("in: "+e),l.logger("ERROR: failed to parse data")}},this._connection.onOpen=function(){l.hello()},this._connection.onDisconnect=function(e){for(var t in l._inPacketCount=0,l._serverInfo=null,l._authenticated=!1,l._pendingPromises){var n=l._pendingPromises[t];n&&n.reject&&n.reject(new Error(c+" ("+u+")"))}l._pendingPromises={},v(function(e,t){0===t.lastIndexOf("topic:",0)&&e._resetSub()}),l.onDisconnect&&l.onDisconnect(e)}};b.credential=function(e,t,r,o){if("object"==n(e)){var i=e;t=i.val,r=i.params,o=i.resp,e=i.meth}return e&&(t||o)?[{meth:e,val:t,resp:o,params:r}]:null},b.topicType=function(e){return{me:"me",fnd:"fnd",grp:"grp",new:"grp",usr:"p2p"}["string"==typeof e?e.substring(0,3):"xxx"]},b.isNewGroupTopicName=function(e){return"string"==typeof e&&"new"==e.substring(0,3)},b.getVersion=function(){return a},b.setWebSocketProvider=function(e){r=e},b.getLibrary=function(){return s},b.MESSAGE_STATUS_NONE=0,b.MESSAGE_STATUS_QUEUED=1,b.MESSAGE_STATUS_SENDING=2,b.MESSAGE_STATUS_FAILED=3,b.MESSAGE_STATUS_SENT=4,b.MESSAGE_STATUS_RECEIVED=5,b.MESSAGE_STATUS_READ=6,b.MESSAGE_STATUS_TO_ME=7,b.DEL_CHAR="␡",b.prototype={connect:function(e){return this._connection.connect(e)},disconnect:function(){this._connection&&this._connection.disconnect()},isConnected:function(){return this._connection&&this._connection.isConnected()},isAuthenticated:function(){return this._authenticated},account:function(e,t,n,r,o){var i=this.initPacket("acc");return i.acc.user=e,i.acc.scheme=t,i.acc.secret=n,i.acc.login=r,o&&(i.acc.desc.defacs=o.defacs,i.acc.desc.public=o.public,i.acc.desc.private=o.private,i.acc.tags=o.tags,i.acc.cred=o.cred,i.acc.token=o.token),this.send(i,i.acc.id)},createAccount:function(e,t,n,r){var o=this,i=this.account("new",e,t,n,r);return n&&(i=i.then(function(e){return o.loginSuccessful(e),e})),i},createAccountBasic:function(e,t,n){return e=e||"",t=t||"",this.createAccount("basic",d(e+":"+t),!0,n)},updateAccountBasic:function(e,t,n,r){return t=t||"",n=n||"",this.account(e,"basic",d(t+":"+n),!1,r)},hello:function(){var e=this,t=this.initPacket("hi");return this.send(t,t.hi.id).then(function(t){return t.params&&(e._serverInfo=t.params),e.onConnect&&e.onConnect(),t}).catch(function(t){e.onDisconnect&&e.onDisconnect(t)})},setDeviceToken:function(e,t){var n=!1;return e&&e!=this._deviceToken&&(this._deviceToken=e,t&&this.isConnected()&&this.isAuthenticated()&&(this.send({hi:{dev:e}}),n=!0)),n},login:function(e,t,n){var r=this,o=this.initPacket("login");return o.login.scheme=e,o.login.secret=t,o.login.cred=n,this.send(o,o.login.id).then(function(e){return r.loginSuccessful(e),e})},loginBasic:function(e,t,n){var r=this;return this.login("basic",d(e+":"+t),n).then(function(t){return r._login=e,t})},loginToken:function(e,t){return this.login("token",e,t)},requestResetAuthSecret:function(e,t,n){return this.login("reset",d(e+":"+t+":"+n))},getAuthToken:function(){return this._authToken&&this._authToken.expires.getTime()>Date.now()?this._authToken:(this._authToken=null,null)},setAuthToken:function(e){this._authToken=e},subscribe:function(e,t,n){var r=this.initPacket("sub",e);return e||(e="new"),r.sub.get=t,n&&(n.sub&&(r.sub.set.sub=n.sub),b.isNewGroupTopicName(e)&&n.desc&&(r.sub.set.desc=n.desc),n.tags&&(r.sub.set.tags=n.tags)),this.send(r,r.sub.id)},leave:function(e,t){var n=this.initPacket("leave",e);return n.leave.unsub=t,this.send(n,n.leave.id)},createMessage:function(t,n,r){var o=this.initPacket("pub",t),i="string"==typeof n?e.parse(n):n;return i&&!e.isPlainText(i)&&(o.pub.head={mime:e.getContentType()},n=i),o.pub.noecho=r,o.pub.content=n,o.pub},publish:function(e,t,n){return this.publishMessage(this.createMessage(e,t,n))},publishMessage:function(e){return(e=Object.assign({},e)).seq=void 0,e.from=void 0,e.ts=void 0,this.send({pub:e},e.id)},getMeta:function(e,t){var n=this.initPacket("get",e);return n.get=p(n.get,t),this.send(n,n.get.id)},setMeta:function(e,t){var n=this.initPacket("set",e),r=[];return t&&["desc","sub","tags"].map(function(e){t.hasOwnProperty(e)&&(r.push(e),n.set[e]=t[e])}),0==r.length?Promise.reject(new Error("Invalid {set} parameters")):this.send(n,n.set.id)},delMessages:function(e,t,n){var r=this.initPacket("del",e);return r.del.what="msg",r.del.delseq=t,r.del.hard=n,this.send(r,r.del.id)},delTopic:function(e){var t=this,n=this.initPacket("del",e);return n.del.what="topic",this.send(n,n.del.id).then(function(n){return t.cacheDel("topic",e),t.ctrl})},delSubscription:function(e,t){var n=this.initPacket("del",e);return n.del.what="sub",n.del.user=t,this.send(n,n.del.id)},note:function(e,t,n){if(n<=0||n>=268435455)throw new Error("Invalid message id "+n);var r=this.initPacket("note",e);r.note.what=t,r.note.seq=n,this.send(r)},noteKeyPress:function(e){var t=this.initPacket("note",e);t.note.what="kp",this.send(t)},getTopic:function(e){var t=this.cacheGet("topic",e);return!t&&e&&(t="me"==e?new S:"fnd"==e?new T:new E(e),this.cachePut("topic",e,t),this.attachCacheToTopic(t)),t},newTopic:function(e){var t=new E("new",e);return this.attachCacheToTopic(t),t},newGroupTopicName:function(){return"new"+this.getNextUniqueId()},newTopicWith:function(e,t){var n=new E(e,t);return this.attachCacheToTopic(n),n},getMeTopic:function(){return this.getTopic("me")},getFndTopic:function(){return this.getTopic("fnd")},getLargeFileHelper:function(){return new k(this)},getCurrentUserID:function(){return this._myUID},getCurrentLogin:function(){return this._login},getServerInfo:function(){return this._serverInfo},enableLogging:function(e,t){this._loggingEnabled=e,this._trimLongStrings=e&&t},isTopicOnline:function(e){var t=this.getMeTopic(),n=t&&t.getContact(e);return n&&n.online},wantAkn:function(e){this._messageId=e?Math.floor(16777215*Math.random()+16777215):0},onWebsocketOpen:void 0,onConnect:void 0,onDisconnect:void 0,onLogin:void 0,onCtrlMessage:void 0,onDataMessage:void 0,onPresMessage:void 0,onMessage:void 0,onRawMessage:void 0};var _=function(e){this.topic=e;var t=e._tinode.getMeTopic();this.contact=t&&t.getContact(e.name),this.what={}};_.prototype={_get_ims:function(){var e=this.contact&&this.contact.updated,t=this.topic._lastDescUpdate||0;return e>t?e:t},withData:function(e,t,n){return this.what.data={since:e,before:t,limit:n},this},withLaterData:function(e){return this.withData(this.topic._maxSeq>0?this.topic._maxSeq+1:void 0,void 0,e)},withEarlierData:function(e){return this.withData(void 0,this.topic._minSeq>0?this.topic._minSeq:void 0,e)},withDesc:function(e){return this.what.desc={ims:e},this},withLaterDesc:function(){return this.withDesc(this._get_ims())},withSub:function(e,t,n){var r={ims:e,limit:t};return"me"==this.topic.getType()?r.topic=n:r.user=n,this.what.sub=r,this},withOneSub:function(e,t){return this.withSub(e,void 0,t)},withLaterOneSub:function(e){return this.withOneSub(this.topic._lastSubsUpdate,e)},withLaterSub:function(e){return this.withSub("p2p"==this.topic.getType()?this._get_ims():this.topic._lastSubsUpdate,e)},withTags:function(){return this.what.tags=!0,this},withDel:function(e,t){return(e||t)&&(this.what.del={since:e,limit:t}),this},withLaterDel:function(e){return this.withDel(this.topic._maxSeq>0?this.topic._maxDel+1:void 0,e)},build:function(){var e={},t=[],n=this;return["data","sub","desc","tags","del"].map(function(r){n.what.hasOwnProperty(r)&&(t.push(r),Object.getOwnPropertyNames(n.what[r]).length>0&&(e[r]=n.what[r]))}),t.length>0?e.what=t.join(" "):e=void 0,e}};var w=function e(t){t&&(this.given="number"==typeof t.given?t.given:e.decode(t.given),this.want="number"==typeof t.want?t.want:e.decode(t.want),this.mode=t.mode?"number"==typeof t.mode?t.mode:e.decode(t.mode):this.given&this.want)};w._NONE=0,w._JOIN=1,w._READ=2,w._WRITE=4,w._PRES=8,w._APPROVE=16,w._SHARE=32,w._DELETE=64,w._OWNER=128,w._BITMASK=w._JOIN|w._READ|w._WRITE|w._PRES|w._APPROVE|w._SHARE|w._DELETE|w._OWNER,w._INVALID=1048576,w.decode=function(e){if(!e)return null;if("number"==typeof e)return e&w._BITMASK;if("N"===e||"n"===e)return w._NONE;for(var t={J:w._JOIN,R:w._READ,W:w._WRITE,P:w._PRES,A:w._APPROVE,S:w._SHARE,D:w._DELETE,O:w._OWNER},n=w._NONE,r=0;r0)){l=!0;break}i=a-1}return l?a:r?-1:s<0?a+1:a}function r(e,t){var r=n(e,t,!1);return t.splice(r,0,e),t}return e=e||function(e,t){return e===t?0:e0)return n[0]},delRange:function(e,n){return t.splice(e,n-e)},size:function(){return t.length},reset:function(e){t=[]},forEach:function(e,n,r,o){n|=0,r=r||t.length;for(var i=n;i=300)return e;if(n._subscribed=!0,n.acs=e.params&&e.params.acs?e.params.acs:n.acs,n._new){n._new=!1,n.name=e.topic,n.created=e.ts,n.updated=e.ts,n.touched=e.ts,n._cachePutSelf();var r=n._tinode.getMeTopic();r&&r._processMetaSub([{_generated:!0,topic:n.name,created:e.ts,updated:e.ts,touched:e.ts,acs:n.acs}]),t&&t.desc&&(t.desc._generated=!0,n._processMetaDesc(t.desc))}return e})},createMessage:function(e,t){return this._tinode.createMessage(this.name,e,t)},publish:function(e,t){return this.publishMessage(this.createMessage(e,t))},publishMessage:function(t){var n=this;if(!this._subscribed)return Promise.reject(new Error("Cannot publish on inactive topic"));if(e.hasAttachments(t.content)&&!t.head.attachments){var r=[];e.attachments(t.content,function(e){r.push(e.ref)}),t.head.attachments=r}return t._sending=!0,this._tinode.publishMessage(t).then(function(e){return t._sending=!1,t.seq=e.params.seq,t.ts=e.ts,n._routeData(t),e}).catch(function(e){t._sending=!1,t._failed=!0})},publishDraft:function(e,t){var n=this;if(!t&&!this._subscribed)return Promise.reject(new Error("Cannot publish on inactive topic"));var r=e.seq||this._getQueuedSeqId();return e._generated||(e._generated=!0,e.seq=r,e.ts=new Date,e.from=this._tinode.getCurrentUserID(),e.noecho=!0,this._messages.put(e),this.onData&&this.onData(e)),(t||Promise.resolve()).then(function(){return e._cancelled?{code:300,text:"cancelled"}:n.publishMessage(e)},function(t){e._sending=!1,n._messages.delAt(n._messages.find(e)),n.onData&&n.onData()})},leave:function(e){var t=this;return this._subscribed||e?this._tinode.leave(this.name,e).then(function(n){return t._resetSub(),e&&t._gone(),n}):Promise.reject(new Error("Cannot leave inactive topic"))},getMeta:function(e){return this._subscribed?this._tinode.getMeta(this.name,e):Promise.reject(new Error("Cannot query inactive topic"))},getMessagesPage:function(e,t){var n=this,r=this.startMetaQuery();t?r.withLaterData(e):r.withEarlierData(e);var o=this.getMeta(r.build());return t||(o=o.then(function(e){e&&e.params&&!e.params.count&&(n._noEarlierMsgs=!0)})),o},setMeta:function(e){var t=this;return this._subscribed?(e.tags&&(e.tags=function(e){var t=[];if(Array.isArray(e)){for(var n=0,r=e.length;n1&&t.push(o)}t.sort().filter(function(e,t,n){return!t||e!=n[t-1]})}return 0==t.length&&t.push(b.DEL_CHAR),t}(e.tags)),this._tinode.setMeta(this.name,e).then(function(n){return n&&n.code>=300?n:(e.sub&&(n.params&&n.params.acs&&(e.sub.acs=n.params.acs,e.sub.updated=n.ts),e.sub.user||(e.sub.user=t._tinode.getCurrentUserID(),e.desc||(e.desc={})),e.sub._generated=!0,t._processMetaSub([e.sub])),e.desc&&(n.params&&n.params.acs&&(e.desc.acs=n.params.acs,e.desc.updated=n.ts),t._processMetaDesc(e.desc)),e.tags&&t._processMetaTags(e.tags),n)})):Promise.reject(new Error("Cannot update inactive topic"))},invite:function(e,t){return this.setMeta({sub:{user:e,mode:t}})},delMessages:function(e,t){var n=this;if(!this._subscribed)return Promise.reject(new Error("Cannot delete messages in inactive topic"));e.sort(function(e,t){return e.low=t.hi)});var r=e.reduce(function(e,t){return t.low<268435455&&(!t.hi||t.hi<268435455?e.push(t):e.push({low:t.low,hi:n._maxSeq+1})),e},[]);return(e.length>0?this._tinode.delMessages(this.name,r,t):Promise.resolve({params:{del:0}})).then(function(t){return t.params.del>n._maxDel&&(n._maxDel=t.params.del),e.map(function(e){e.hi?n.flushMessageRange(e.low,e.hi):n.flushMessage(e.low)}),n.onData&&n.onData(),t})},delMessagesAll:function(e){return this.delMessages([{low:1,hi:this._maxSeq+1,_all:!0}],e)},delMessagesList:function(e,t){e.sort(function(e,t){return e-t});var n=e.reduce(function(e,t){if(0==e.length)e.push({low:t});else{var n=e[e.length-1];!n.hi&&t!=n.low+1||t>n.hi?e.push({low:t}):n.hi=n.hi?Math.max(n.hi,t+1):t+1}return e},[]);return this.delMessages(n,t)},delTopic:function(){var e=this;return this._tinode.delTopic(this.name).then(function(t){return e._resetSub(),e._gone(),t})},delSubscription:function(e){var t=this;return this._subscribed?this._tinode.delSubscription(this.name,e).then(function(n){return delete t._users[e],t.onSubsUpdated&&t.onSubsUpdated(Object.keys(t._users)),n}):Promise.reject(new Error("Cannot delete subscription in inactive topic"))},note:function(e,t){var n=this._users[this._tinode.getCurrentUserID()];n?((!n[e]||n[e]0)for(var o in this._users){var i=this._users[o];i.user!==r&&i[e]>=t&&n++}return n},msgReadCount:function(e){return this.msgReceiptCount("read",e)},msgRecvCount:function(e){return this.msgReceiptCount("recv",e)},msgHasMoreMessages:function(e){return e?this.seq>this._maxSeq:this._minSeq>1&&!this._noEarlierMsgs},isNewMessage:function(e){return this._maxSeq<=e},flushMessage:function(e){var t=this._messages.find({seq:e});return t>=0?this._messages.delAt(t):void 0},flushMessageRange:function(e,t){var n=this._messages.find({seq:e});return n>=0?this._messages.delRange(n,this._messages.find({seq:t},!0)):[]},cancelSend:function(e){var t=this._messages.find({seq:e});if(t>=0){var n=this._messages.getAt(t);if(1==this.msgStatus(n))return n._cancelled=!0,this._messages.delAt(t),!0}return!1},getType:function(){return b.topicType(this.name)},getAccessMode:function(){return this.acs},getDefaultAccess:function(){return this.defacs},startMetaQuery:function(){return new _(this)},msgStatus:function(e){var t=0;return e.from==this._tinode.getCurrentUserID()?e._sending?t=2:e._failed?t=3:e.seq>=268435455?t=1:this.msgReadCount(e.seq)>0?t=6:this.msgRecvCount(e.seq)>0?t=5:e.seq>0&&(t=4):t=7,t},_routeData:function(e){e.content&&((!this.touched||this.touchedthis._maxSeq&&(this._maxSeq=e.seq),(e.seq0&&(this._lastSubsUpdate=e.ts,this._processMetaSub(e.sub)),e.del&&this._processDelMessages(e.del.clear,e.del.delseq),e.tags&&this._processMetaTags(e.tags),this.onMeta&&this.onMeta(e)},_routePres:function(e){var t;switch(e.what){case"del":this._processDelMessages(e.clear,e.delseq);break;case"on":case"off":(t=this._users[e.src])?t.online="on"==e.what:this._tinode.logger("Presence update for an unknown user",this.name,e.src);break;case"acs":var n="me"==e.src?this._tinode.getCurrentUserID():e.src;if(t=this._users[n])t.acs.updateAll(e.dacs),n==this._tinode.getCurrentUserID()&&this.acs.updateAll(e.dacs),t.acs&&t.acs.mode!=w._NONE||("p2p"==this.getType()&&this.leave(),this._processMetaSub([{user:n,deleted:new Date,_generated:!0}]));else{var r=(new w).updateAll(e.dacs);r&&r.mode!=w._NONE&&((t=this._cacheGetUser(n))?t.acs=r:(t={user:n,acs:r},this.getMeta(this.startMetaQuery().withOneSub(void 0,n).build())),t._generated=!0,t.updated=new Date,this._processMetaSub([t]))}break;default:this._tinode.logger("Ignored presence update",e.what)}this.onPres&&this.onPres(e)},_routeInfo:function(e){if("kp"!==e.what){var t=this._users[e.from];t&&(t[e.what]=e.seq)}this.onInfo&&this.onInfo(e)},_processMetaDesc:function(e,t){if(p(this,e),"string"==typeof this.created&&(this.created=new Date(this.created)),"string"==typeof this.updated&&(this.updated=new Date(this.updated)),"string"==typeof this.touched&&(this.touched=new Date(this.touched)),"me"!==this.name&&!t&&!e._generated){var n=this._tinode.getMeTopic();n&&n._processMetaSub([{_generated:!0,topic:this.name,updated:this.updated,touched:this.touched,acs:this.acs,public:this.public,private:this.private}])}this.onMetaDesc&&this.onMetaDesc(this)},_processMetaSub:function(e){var t=void 0;for(var n in e){var r=e[n];if(r.user){r.updated=new Date(r.updated),r.deleted=r.deleted?new Date(r.deleted):null;var o=null;r.deleted?(delete this._users[r.user],o=r):((o=this._users[r.user])||(o=this._cacheGetUser(r.user)),o=this._updateCachedUser(r.user,r,r._generated)),this.onMetaSub&&this.onMetaSub(o)}else r._generated||(t=r)}t&&this.onMetaDesc&&this.onMetaDesc(t),this.onSubsUpdated&&this.onSubsUpdated(Object.keys(this._users))},_processMetaTags:function(e){1==e.length&&e[0]==b.DEL_CHAR&&(e=[]),this._tags=e,this.onTagsUpdated&&this.onTagsUpdated(e)},_processDelMessages:function(e,t){this._maxDel=Math.max(e,this._maxDel),this.clear=Math.max(e,this.clear);var n=this,r=0;Array.isArray(t)&&t.map(function(e){if(e.hi)for(var t=e.low;t0&&this.onData&&this.onData()},_allMessagesReceived:function(e){this.onAllMessagesReceived&&this.onAllMessagesReceived(e)},_resetSub:function(){this._subscribed=!1},_gone:function(){this._messages.reset(),this._users={},this.acs=new w(null),this.private=null,this.public=null,this._maxSeq=0,this._minSeq=0,this._subscribed=!1;var e=this._tinode.getMeTopic();e&&e._routePres({_generated:!0,what:"gone",topic:"me",src:this.name}),this.onDeleteTopic&&this.onDeleteTopic()},_updateCachedUser:function(e,t,n){var r=this._cacheGetUser(e);return r?r=p(r,t):(n&&this.getMeta(this.startMetaQuery().withLaterOneSub(e).build()),r=p({},t)),this._cachePutUser(e,r),f(this._users,e,r)},_getQueuedSeqId:function(){return this._queuedSeqId++}};var S=function(e){E.call(this,"me",e),this._contacts={},e&&(this.onContactUpdate=e.onContactUpdate)};S.prototype=Object.create(E.prototype,{_processMetaSub:{value:function(e){var t=0;for(var n in e){var r=e[n],o=r.topic;if("fnd"!=o&&"me"!=o){r.updated=new Date(r.updated),r.touched=r.touched?new Date(r.touched):null,r.deleted=r.deleted?new Date(r.deleted):null,r.seq=0|r.seq,r.recv=0|r.recv,r.read=0|r.read,r.unread=r.seq-r.read;var i=null;if(r.deleted)i=r,delete this._contacts[o];else if(r.seen&&r.seen.when&&(r.seen.when=new Date(r.seen.when)),i=f(this._contacts,o,r),"p2p"==b.topicType(o)&&this._cachePutUser(o,i),!r._generated){var a=this._tinode.getTopic(o);a&&a._processMetaDesc(r,!0)}t++,this.onMetaSub&&this.onMetaSub(i)}}t>0&&this.onSubsUpdated&&this.onSubsUpdated(Object.keys(this._contacts))},enumerable:!0,configurable:!0,writable:!1},_routePres:{value:function(e){var t=this._contacts[e.src];if(t){switch(e.what){case"on":t.online=!0;break;case"off":t.online&&(t.online=!1,t.seen?t.seen.when=new Date:t.seen={when:new Date});break;case"msg":t.touched=new Date,t.seq=0|e.seq,t.unread=t.seq-t.read;break;case"upd":this.getMeta(this.startMetaQuery().withLaterOneSub(e.src).build());break;case"acs":t.acs?t.acs.updateAll(e.dacs):t.acs=(new w).updateAll(e.dacs);break;case"ua":t.seen={when:new Date,ua:e.ua};break;case"recv":t.recv=t.recv?Math.max(t.recv,e.seq):0|e.seq;break;case"read":t.read=t.read?Math.max(t.read,e.seq):0|e.seq,t.unread=t.seq-t.read;break;case"gone":delete this._contacts[e.src]}this.onContactUpdate&&this.onContactUpdate(e.what,t)}else if("acs"==e.what){var n=new w(e.dacs);if(!n||n.mode==w._INVALID)return void this._tinode.logger("Invalid access mode update",e.src,e.dacs);if(n.mode==w._NONE)return void this._tinode.logger("Removing non-existent subscription",e.src,e.dacs);this.getMeta(this.startMetaQuery().withOneSub(void 0,e.src).build()),this._contacts[e.src]={topic:e.src,online:!1,acs:n}}this.onPres&&this.onPres(e)},enumerable:!0,configurable:!0,writable:!1},publish:{value:function(){return Promise.reject(new Error("Publishing to 'me' is not supported"))},enumerable:!0,configurable:!0,writable:!1},contacts:{value:function(e,t){var n=e||this.onMetaSub;if(n)for(var r in this._contacts)n.call(t,this._contacts[r],r,this._contacts)},enumerable:!0,configurable:!0,writable:!0},setMsgReadRecv:{value:function(e,t,n,r){var o,i=this._contacts[e],a=!1;i&&(n|=0,"recv"===t?(o=i.recv,i.recv=i.recv?Math.max(i.recv,n):n,a=o!=i.recv):"read"===t?(o=i.read,i.read=i.read?Math.max(i.read,n):n,i.unread=i.seq-i.read,a=o!=i.read,i.recv0&&this.onSubsUpdated&&this.onSubsUpdated(Object.keys(this._contacts))},enumerable:!0,configurable:!0,writable:!1},publish:{value:function(){return Promise.reject(new Error("Publishing to 'fnd' is not supported"))},enumerable:!0,configurable:!0,writable:!1},setMeta:{value:function(e){var t=this;return Object.getPrototypeOf(T.prototype).setMeta.call(this,e).then(function(){Object.keys(t._contacts).length>0&&(t._contacts={},t.onSubsUpdated&&t.onSubsUpdated([]))})},enumerable:!0,configurable:!0,writable:!1},contacts:{value:function(e,t){var n=e||this.onMetaSub;if(n)for(var r in this._contacts)n.call(t,this._contacts[r],r,this._contacts)},enumerable:!0,configurable:!0,writable:!0}}),T.prototype.constructor=T;var k=function(e){this._tinode=e,this._apiKey=e._apiKey,this._authToken=e.getAuthToken(),this._msgId=e.getNextUniqueId(),this.xhr=h(),this.toResolve=null,this.toReject=null,this.onProgress=null,this.onSuccess=null,this.onFailure=null};k.prototype={upload:function(e,t,n,r){var o=this;if(!this._authToken)throw new Error("Must authenticate first");var a=this;this.xhr.open("POST","/v"+i+"/file/u/",!0),this.xhr.setRequestHeader("X-Tinode-APIKey",this._apiKey),this.xhr.setRequestHeader("X-Tinode-Auth","Token "+this._authToken.token);var s=new Promise(function(e,t){o.toResolve=e,o.toReject=t});this.onProgress=t,this.onSuccess=n,this.onFailure=r,this.xhr.upload.onprogress=function(e){e.lengthComputable&&a.onProgress&&a.onProgress(e.loaded/e.total)},this.xhr.onload=function(){var e;try{e=JSON.parse(this.response,m)}catch(e){a._tinode.logger("Invalid server response in LargeFileHelper",this.response)}this.status>=200&&this.status<300?(a.toResolve&&a.toResolve(e.ctrl.params.url),a.onSuccess&&a.onSuccess(e.ctrl)):this.status>=400?(a.toReject&&a.toReject(new Error(e.ctrl.text+" ("+e.ctrl.code+")")),a.onFailure&&a.onFailure(e.ctrl)):a._tinode.logger("Unexpected server response status",this.status,this.response)},this.xhr.onerror=function(e){a.toReject&&a.toReject(new Error("failed")),a.onFailure&&a.onFailure(null)},this.xhr.onabort=function(e){a.toReject&&a.toReject(new Error("upload cancelled by user")),a.onFailure&&a.onFailure(null)};try{var l=new FormData;l.append("file",e),l.set("id",this._msgId),this.xhr.send(l)}catch(e){this.toReject&&this.toReject(e),this.onFailure&&this.onFailure(null)}return s},download:function(e,t,n,r){var o=this;if(/^(?:(?:[a-z]+:)?\/\/)/i.test(e))throw new Error("The URL '"+e+"' must be relative, not absolute");if(!this._authToken)throw new Error("Must authenticate first");var i=this;this.xhr.open("GET",e,!0),this.xhr.setRequestHeader("X-Tinode-APIKey",this._apiKey),this.xhr.setRequestHeader("X-Tinode-Auth","Token "+this._authToken.token),this.xhr.responseType="blob",this.onProgress=r,this.xhr.onprogress=function(e){i.onProgress&&i.onProgress(e.loaded)};var a=new Promise(function(e,t){o.toResolve=e,o.toReject=t});this.xhr.onload=function(){if(200==this.status){var e=document.createElement("a");e.href=window.URL.createObjectURL(new Blob([this.response],{type:n})),e.style.display="none",e.setAttribute("download",t),document.body.appendChild(e),e.click(),document.body.removeChild(e),window.URL.revokeObjectURL(e.href),i.toResolve&&i.toResolve()}else if(this.status>=400&&i.toReject){var r=new FileReader;r.onload=function(){try{var e=JSON.parse(this.result,m);i.toReject(new Error(e.ctrl.text+" ("+e.ctrl.code+")"))}catch(e){i._tinode.logger("Invalid server response in LargeFileHelper",this.result),i.toReject(e)}},r.readAsText(this.response)}},this.xhr.onerror=function(e){i.toReject&&i.toReject(new Error("failed"))},this.xhr.onabort=function(){i.toReject&&i.toReject(null)};try{this.xhr.send()}catch(e){this.toReject&&this.toReject(e)}return a},cancel:function(){this.xhr&&this.xhr.readyState<4&&this.xhr.abort()},getId:function(){return this._msgId}};var C=function e(t,n){this.status=e.STATUS_NONE,this.topic=t,this.content=n};C.STATUS_NONE=0,C.STATUS_QUEUED=1,C.STATUS_SENDING=2,C.STATUS_FAILED=3,C.STATUS_SENT=4,C.STATUS_RECEIVED=5,C.STATUS_READ=6,C.STATUS_TO_ME=7,(C.prototype={toJSON:function(){},fromJSON:function(e){}}).constructor=C,(l=b).Drafty=e}.call(this,void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{}),l}()}).call(this,n(10))},function(e,t,n){e.exports=n(38)()},function(e,t,n){"use strict";!function e(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(e){console.error(e)}}(),e.exports=n(21)},function(e,t,n){"use strict";var r=n(24).default;n(31),(t=e.exports=r).default=t},function(e,t,n){"use strict";(t=e.exports=n(40).default).default=t},function(e,t,n){"use strict";var r=n(32).default;n(37),(t=e.exports=r).default=t},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1),o={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"},i=function(e,t){if(!e)throw a(t)},a=function(e){return new Error("Firebase Database ("+o.SDK_VERSION+") INTERNAL ASSERT FAILED: "+e)},s=function(e){for(var t=[],n=0,r=0;r>6|192,t[n++]=63&o|128):55296==(64512&o)&&r+1>18|240,t[n++]=o>>12&63|128,t[n++]=o>>6&63|128,t[n++]=63&o|128):(t[n++]=o>>12|224,t[n++]=o>>6&63|128,t[n++]=63&o|128)}return t},l={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:"function"==typeof atob,encodeByteArray:function(e,t){if(!Array.isArray(e))throw Error("encodeByteArray takes an array as a parameter");this.init_();for(var n=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[],o=0;o>2,d=(3&i)<<4|s>>4,p=(15&s)<<2|u>>6,f=63&u;l||(f=64,a||(p=64)),r.push(n[c],n[d],n[p],n[f])}return r.join("")},encodeString:function(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(s(e),t)},decodeString:function(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):function(e){for(var t=[],n=0,r=0;n191&&o<224){var i=e[n++];t[r++]=String.fromCharCode((31&o)<<6|63&i)}else if(o>239&&o<365){var a=((7&o)<<18|(63&(i=e[n++]))<<12|(63&(s=e[n++]))<<6|63&e[n++])-65536;t[r++]=String.fromCharCode(55296+(a>>10)),t[r++]=String.fromCharCode(56320+(1023&a))}else{i=e[n++];var s=e[n++];t[r++]=String.fromCharCode((15&o)<<12|(63&i)<<6|63&s)}}return t.join("")}(this.decodeStringToByteArray(e,t))},decodeStringToByteArray:function(e,t){this.init_();for(var n=t?this.charToByteMapWebSafe_:this.charToByteMap_,r=[],o=0;o>4;if(r.push(u),64!=s){var c=a<<4&240|s>>2;if(r.push(c),64!=l){var d=s<<6&192|l;r.push(d)}}}return r},init_:function(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(var e=0;e=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}},u=function(e){try{return l.decodeString(e,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function c(e,t){if(!(t instanceof Object))return t;switch(t.constructor){case Date:return new Date(t.getTime());case Object:void 0===e&&(e={});break;case Array:e=[];break;default:return t}for(var n in t)t.hasOwnProperty(n)&&(e[n]=c(e[n],t[n]));return e}var d=function(){function e(){var e=this;this.promise=new Promise(function(t,n){e.resolve=t,e.reject=n})}return e.prototype.wrapCallback=function(e){var t=this;return function(n,r){n?t.reject(n):t.resolve(r),"function"==typeof e&&(t.promise.catch(function(){}),1===e.length?e(n):e(n,r))}},e}(),p=function(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""},f="FirebaseError",h=Error.captureStackTrace;var m=function(){return function(e,t){if(this.code=e,this.message=t,h)h(this,y.prototype.create);else try{throw Error.apply(this,arguments)}catch(e){this.name=f,Object.defineProperty(this,"stack",{get:function(){return e.stack}})}}}();m.prototype=Object.create(Error.prototype),m.prototype.constructor=m,m.prototype.name=f;var y=function(){function e(e,t,n){this.service=e,this.serviceName=t,this.errors=n,this.pattern=/\{\$([^}]+)}/g}return e.prototype.create=function(e,t){void 0===t&&(t={});var n,r=this.errors[e],o=this.service+"/"+e;n=void 0===r?"Error":r.replace(this.pattern,function(e,n){var r=t[n];return void 0!==r?r.toString():"<"+n+"?>"}),n=this.serviceName+": "+n+" ("+o+").";var i=new m(o,n);for(var a in t)t.hasOwnProperty(a)&&"_"!==a.slice(-1)&&(i[a]=t[a]);return i},e}();function v(e){return JSON.parse(e)}var g=function(e){var t={},n={},r={},o="";try{var i=e.split(".");t=v(u(i[0])||""),n=v(u(i[1])||""),o=i[2],r=n.d||{},delete n.d}catch(e){}return{header:t,claims:n,data:r,signature:o}},b=function(e,t){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(n,e[n])},_=function(e,t){return b(t,function(t,n){e[t]=n}),e},w=function(e,t,n){for(var r in e)if(t.call(n,e[r],r,e))return r},E=function(e){function t(){var t=e.call(this)||this;t.chain_=[],t.buf_=[],t.W_=[],t.pad_=[],t.inbuf_=0,t.total_=0,t.blockSize=64,t.pad_[0]=128;for(var n=1;n>>31)}var i,a,s=this.chain_[0],l=this.chain_[1],u=this.chain_[2],c=this.chain_[3],d=this.chain_[4];for(r=0;r<80;r++){r<40?r<20?(i=c^l&(u^c),a=1518500249):(i=l^u^c,a=1859775393):r<60?(i=l&u|c&(l|u),a=2400959708):(i=l^u^c,a=3395469782);o=(s<<5|s>>>27)+i+d+a+n[r]&4294967295;d=c,c=u,u=4294967295&(l<<30|l>>>2),l=s,s=o}this.chain_[0]=this.chain_[0]+s&4294967295,this.chain_[1]=this.chain_[1]+l&4294967295,this.chain_[2]=this.chain_[2]+u&4294967295,this.chain_[3]=this.chain_[3]+c&4294967295,this.chain_[4]=this.chain_[4]+d&4294967295},t.prototype.update=function(e,t){if(null!=e){void 0===t&&(t=e.length);for(var n=t-this.blockSize,r=0,o=this.buf_,i=this.inbuf_;r=56;n--)this.buf_[n]=255&t,t/=256;this.compress_(this.buf_);var r=0;for(n=0;n<5;n++)for(var o=24;o>=0;o-=8)e[r]=this.chain_[n]>>o&255,++r;return e},t}(function(){return function(){this.blockSize=-1}}());var S=function(){function e(e,t){var n=this;this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(function(){e(n)}).catch(function(e){n.error(e)})}return e.prototype.next=function(e){this.forEachObserver(function(t){t.next(e)})},e.prototype.error=function(e){this.forEachObserver(function(t){t.error(e)}),this.close(e)},e.prototype.complete=function(){this.forEachObserver(function(e){e.complete()}),this.close()},e.prototype.subscribe=function(e,t,n){var r,o=this;if(void 0===e&&void 0===t&&void 0===n)throw new Error("Missing Observer.");void 0===(r=function(e,t){if("object"!=typeof e||null===e)return!1;for(var n=0,r=t;n 4. Need to update it?")}var o=e+" failed: ";return o+=r+" argument "}t.assert=i,t.assertionError=a,t.base64=l,t.base64Decode=u,t.base64Encode=function(e){var t=s(e);return l.encodeByteArray(t,!0)},t.CONSTANTS=o,t.deepCopy=function(e){return c(void 0,e)},t.deepExtend=c,t.patchProperty=function(e,t,n){e[t]=n},t.Deferred=d,t.getUA=p,t.isMobileCordova=function(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(p())},t.isNodeSdk=function(){return!0===o.NODE_CLIENT||!0===o.NODE_ADMIN},t.isReactNative=function(){return"object"==typeof navigator&&"ReactNative"===navigator.product},t.ErrorFactory=y,t.FirebaseError=m,t.patchCapture=function(e){var t=h;return h=e,t},t.jsonEval=v,t.stringify=function(e){return JSON.stringify(e)},t.decode=g,t.isAdmin=function(e){var t=g(e).claims;return"object"==typeof t&&!0===t.admin},t.issuedAtTime=function(e){var t=g(e).claims;return"object"==typeof t&&t.hasOwnProperty("iat")?t.iat:null},t.isValidFormat=function(e){var t=g(e).claims;return!!t&&"object"==typeof t&&t.hasOwnProperty("iat")},t.isValidTimestamp=function(e){var t,n,r=g(e).claims,o=Math.floor((new Date).getTime()/1e3);return"object"==typeof r&&(r.hasOwnProperty("nbf")?t=r.nbf:r.hasOwnProperty("iat")&&(t=r.iat),n=r.hasOwnProperty("exp")?r.exp:t+86400),o&&t&&n&&o>=t&&o<=n},t.clone=function(e){return _({},e)},t.contains=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.every=function(e,t){for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&!t(n,e[n]))return!1;return!0},t.extend=_,t.findKey=w,t.findValue=function(e,t,n){var r=w(e,t,n);return r&&e[r]},t.forEach=b,t.getAnyKey=function(e){for(var t in e)return t},t.getCount=function(e){var t=0;for(var n in e)t++;return t},t.getValues=function(e){var t=[],n=0;for(var r in e)t[n++]=e[r];return t},t.isEmpty=function(e){for(var t in e)return!1;return!0},t.isNonNullObject=function(e){return"object"==typeof e&&null!==e},t.map=function(e,t,n){var r={};for(var o in e)r[o]=t.call(n,e[o],o,e);return r},t.safeGet=function(e,t){if(Object.prototype.hasOwnProperty.call(e,t))return e[t]},t.querystring=function(e){var t=[];return b(e,function(e,n){Array.isArray(n)?n.forEach(function(n){t.push(encodeURIComponent(e)+"="+encodeURIComponent(n))}):t.push(encodeURIComponent(e)+"="+encodeURIComponent(n))}),t.length?"&"+t.join("&"):""},t.querystringDecode=function(e){var t={};return e.replace(/^\?/,"").split("&").forEach(function(e){if(e){var n=e.split("=");t[n[0]]=n[1]}}),t},t.Sha1=E,t.async=function(e,t){return function(){for(var n=[],r=0;rn&&(o=0===n?"none":"no more than "+n),o)throw new Error(e+" failed: Was called with "+r+(1===r?" argument.":" arguments.")+" Expects "+o+".")},t.validateCallback=function(e,t,n,r){if((!r||n)&&"function"!=typeof n)throw new Error(k(e,t,r)+"must be a valid function.")},t.validateContextObject=function(e,t,n,r){if((!r||n)&&("object"!=typeof n||null===n))throw new Error(k(e,t,r)+"must be a valid context object.")},t.validateNamespace=function(e,t,n,r){if((!r||n)&&"string"!=typeof n)throw new Error(k(e,t,r)+"must be a valid firebase namespace.")},t.stringLength=function(e){for(var t=0,n=0;n=55296&&r<=56319?(t+=4,n++):t+=3}return t},t.stringToByteArray=function(e){for(var t=[],n=0,r=0;r=55296&&o<=56319){var a=o-55296;i(++r>6|192,t[n++]=63&o|128):o<65536?(t[n++]=o>>12|224,t[n++]=o>>6&63|128,t[n++]=63&o|128):(t[n++]=o>>18|240,t[n++]=o>>12&63|128,t[n++]=o>>6&63|128,t[n++]=63&o|128)}return t}},function(e,t,n){"use strict";e.exports=function(e,t,n,r,o,i,a,s){if(!e){var l;if(void 0===t)l=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[n,r,o,i,a,s],c=0;(l=new Error(t.replace(/%s/g,function(){return u[c++]}))).name="Invariant Violation"}throw l.framesToPop=1,l}}},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e){e.exports={en:{contacts_not_found:"You have no chats
¯\\\\_(ツ)_/¯",full_name_prompt:"Full name, e.g. John Doe",email_prompt:"Email, e.g. jdoe@example.com",button_sign_up:"Sign up",label_your_name:"Your name",label_password:"Password",password_unchanged_prompt:"Unchanged",label_user_id:"Address:",label_default_access_mode:"Default access mode:",label_message_sound:"Message sound:",label_push_notifications:"Notification alerts:",label_push_notifications_disabled:"Notification alerts (requires HTTPS):",title_tag_manager:"Tags (user discovery)",button_logout:"Logout",requested_permissions:"Requested",granted_permissions:"Granted",menu_item_edit_permissions:"Edit permissions",label_other_user:"Other",title_info:"Info",label_topic_name:"Name",label_private:"Private comment",private_editing_placeholder:"Visible to you only",label_muting_topic:"Muted:",action_more:"More",label_your_permissions:"Your permissions:",label_permissions:"Permissions:",label_you:"You:",label_default_access:"Default access mode:",label_group_members:"Group members:",button_add_members:"Add members",button_leave:"Leave",group_has_no_members:"No members",action_leave_chat:"Leave",login_prompt:"Login",password_prompt:"Password",stay_logged_in:"Stay logged in",forgot_password_link:"Forgot password?",button_sign_in:"Sign in",label_client:"Client:",label_server:"Server:",online_now:"online now",last_seen_timestamp:"Last seen",title_not_found:"Not found",unnamed_topic:"Unnamed",messages_not_readable:"no access to messages",tabtitle_find_user:"find",tabtitle_new_group:"new group",tabtitle_group_by_id:"by id",search_for_contacts:"Use search to find contacts",label_server_to_use:"Server to use:",label_wire_transport:"Wire transport:",button_update:"Update",sidepanel_title_login:"Sign In",sidepanel_title_register:"Create Account",sidepanel_title_settings:"Settings",sidepanel_title_edit_account:"Edit Account",sidepanel_title_newtpk:"Start New Chat",sidepanel_title_cred:"Confirm Credentials",sidepanel_title_reset:"Reset Password",phone_dative:"phone",email_dative:"email",enter_confirmation_code_prompt:"Enter confirmation code sent to you by {method}:",numeric_confirmation_code_prompt:"Numbers only",button_confirm:"Confirm",invalid_content:"invalid content",menu_item_info:"Info",menu_item_clear_messages:"Clear messages",menu_item_clear_messages_for_all:"Clear for All",menu_item_delete:"Delete",menu_item_delete_for_all:"Delete for All",menu_item_mute:"Mute",menu_item_unmute:"Unmute",menu_item_delete_topic:"Delete",menu_item_unblock:"Unblock",menu_item_block:"Block",menu_item_member_delete:"Remove",title_group_members:"Group members",button_ok:"OK",button_cancel:"Cancel",download_action:"download",label_file_name:"File name:",label_content_type:"Content type:",label_size:"Size:",permission_join:"Join ({val})",permission_read:"Read ({val})",permission_write:"Write ({val})",permission_pres:"Get notified ({val})",permission_admin:"Approve ({val})",permission_share:"Share ({val})",permission_delete:"Delete ({val})",permission_owner:"Owner ({val})",title_permissions:"Permissions",message_sending:"sending...",message_sending_failed:"failed",search_placeholder:"List like email:alice@example.com, tel:17025550003...",messaging_disabled_prompt:"Messaging disabled",new_message_prompt:"New message",file_attachment_too_large:"The file size {size} exceeds the {limit} limit.",cannot_initiate_file_upload:"Cannot initiate file upload.",tags_not_found:"No tags defined. Add some.",tags_editor_no_tags:"Add some tags",title_manage_tags:"Manage tags"},ru:{contacts_not_found:"Чатов нет
¯\\\\_(ツ)_/¯",full_name_prompt:"Полное имя, напр. Иван Петров",email_prompt:"Email, напр. ivan@example.com",button_sign_up:"Создать счет",label_your_name:"Ваше имя",label_password:"Пароль",password_unchanged_prompt:"Не изменен",label_user_id:"Адрес:",label_default_access_mode:"Доступ по умолчанию:",label_message_sound:"Звук нового сообщения:",label_push_notifications:"Уведомления:",label_push_notifications_disabled:"Уведомления (требуют HTTPS):",title_tag_manager:"Таги для поиска",button_logout:"Выйти",login_prompt:"Логин",password_prompt:"Пароль",stay_logged_in:"Запомнить",forgot_password_link:"Напомнить пароль",button_sign_in:"Войти",label_client:"Клиент:",label_server:"Сервер:",online_now:"онлайн",last_seen_timestamp:"Был активен",title_not_found:"Не найден",unnamed_topic:"Без названия",messages_not_readable:"нет доступа к сообщениям",tabtitle_find_user:"найти",tabtitle_new_group:"создать",tabtitle_group_by_id:"по id",label_server_to_use:"Использовать сервер:",label_wire_transport:"Соединение:",button_update:"Применить",sidepanel_title_login:"Авторизация",sidepanel_title_register:"Зарегистрироваться",sidepanel_title_settings:"Настройки",sidepanel_title_edit_account:"Редактировать счет",sidepanel_title_newtpk:"Новый чат",sidepanel_title_cred:"Подтвердить",sidepanel_title_reset:"Сменить пароль",tags_not_found:"Тагов нет. Добавьте",tags_editor_no_tags:"Добавьте таги",title_manage_tags:"Редактор тагов",message_sending:"в пути...",message_sending_failed:"ошибка",search_placeholder:"Список, напр. email:alice@example.com, tel:17025550003...",messaging_disabled_prompt:"Отправка недоступна",new_message_prompt:"Новое сообщение",file_attachment_too_large:"Размер файла {size} превышает {limit} лимит.",cannot_initiate_file_upload:"Ошибка загрузки файла.",search_for_contacts:"Поиск контактов",enter_confirmation_code_prompt:"Код подтверждения, полученный по {method}:",numeric_confirmation_code_prompt:"Только цифры",button_confirm:"Подтвердить",button_ok:"OK",button_cancel:"Отменить",invalid_content:"сообщение не читается",label_file_name:"Имя файла:",label_content_type:"Тип:",label_size:"Размер:",phone_dative:"телефону",email_dative:"емейлу",title_group_members:"Участники",download_action:"скачать",permission_join:"Присоединяться ({val})",permission_read:"Читать ({val})",permission_write:"Писать ({val})",permission_pres:"Уведомлять ({val})",permission_admin:"Подтверждать ({val})",permission_share:"Приглашать ({val})",permission_delete:"Удалять ({val})",permission_owner:"Владелец ({val})",title_permissions:"Права доступа",requested_permissions:"Требуются",granted_permissions:"Получены",menu_item_edit_permissions:"Права доступа",label_other_user:"Второй",label_topic_name:"Название",label_private:"Комментарий",private_editing_placeholder:"Виден только вам",label_muting_topic:"Без уведомлений",action_more:"Ещё",label_your_permissions:"Ваши права доступа:",label_permissions:"Права доступа:",label_you:"Вы:",label_default_access:"Права по умолчанию:",label_group_members:"Участники чата:",button_add_members:"Добавить",button_leave:"Отписаться",group_has_no_members:"Нет участников",action_leave_chat:"Уйти из чата",menu_item_info:"Информация",menu_item_clear_messages:"Удалить сообщения",menu_item_clear_messages_for_all:"Удалить для всех",menu_item_delete:"Удалить",menu_item_delete_for_all:"Удалить для всех",menu_item_mute:"Не уведомлять",menu_item_unmute:"Уведомлять",menu_item_delete_topic:"Удалить",menu_item_unblock:"Разблокировать",menu_item_block:"Заблокировать",menu_item_member_delete:"Отписать",title_info:"Подробности"}}},function(e,t,n){"use strict";n(42);var r=function(e){return e&&"object"==typeof e&&"default"in e?e.default:e}(n(13));e.exports=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(8),o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i="[DEFAULT]",a=[],s=function(){function e(e,t,n){this.firebase_=n,this.isDeleted_=!1,this.services_={},this.name_=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled||!1,this.options_=r.deepCopy(e),this.INTERNAL={getUid:function(){return null},getToken:function(){return Promise.resolve(null)},addAuthTokenListener:function(e){a.push(e),setTimeout(function(){return e(null)},0)},removeAuthTokenListener:function(e){a=a.filter(function(t){return t!==e})}}}return Object.defineProperty(e.prototype,"automaticDataCollectionEnabled",{get:function(){return this.checkDestroyed_(),this._automaticDataCollectionEnabled},set:function(e){this.checkDestroyed_(),this._automaticDataCollectionEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this.checkDestroyed_(),this.name_},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"options",{get:function(){return this.checkDestroyed_(),this.options_},enumerable:!0,configurable:!0}),e.prototype.delete=function(){var e=this;return new Promise(function(t){e.checkDestroyed_(),t()}).then(function(){e.firebase_.INTERNAL.removeApp(e.name_);var t=[];return Object.keys(e.services_).forEach(function(n){Object.keys(e.services_[n]).forEach(function(r){t.push(e.services_[n][r])})}),Promise.all(t.map(function(e){return e.INTERNAL.delete()}))}).then(function(){e.isDeleted_=!0,e.services_={}})},e.prototype._getService=function(e,t){if(void 0===t&&(t=i),this.checkDestroyed_(),this.services_[e]||(this.services_[e]={}),!this.services_[e][t]){var n=t!==i?t:void 0,r=this.firebase_.INTERNAL.factories[e](this,this.extendApp.bind(this),n);this.services_[e][t]=r}return this.services_[e][t]},e.prototype.extendApp=function(e){var t=this;r.deepExtend(this,e),e.INTERNAL&&e.INTERNAL.addAuthTokenListener&&(a.forEach(function(e){t.INTERNAL.addAuthTokenListener(e)}),a=[])},e.prototype.checkDestroyed_=function(){this.isDeleted_&&l("app-deleted",{name:this.name_})},e}();function l(e,t){throw u.create(e,t)}s.prototype.name&&s.prototype.options||s.prototype.delete||console.log("dc");var u=new r.ErrorFactory("app","Firebase",{"no-app":"No Firebase App '{$name}' has been created - call Firebase App.initializeApp()","bad-app-name":"Illegal App name: '{$name}","duplicate-app":"Firebase App named '{$name}' already exists","app-deleted":"Firebase App named '{$name}' already deleted","duplicate-service":"Firebase service named '{$name}' already registered","sa-not-supported":"Initializing the Firebase SDK with a service account is only allowed in a Node.js environment. On client devices, you should instead initialize the SDK with an api key and auth domain","invalid-app-argument":"firebase.{$name}() takes either no argument or a Firebase App instance."}),c=function e(){var t={},n={},a={},u={__esModule:!0,initializeApp:function(e,n){if(void 0===n&&(n={}),"object"!=typeof n||null===n){var r=n;n={name:r}}var a=n;void 0===a.name&&(a.name=i);var c=a.name;"string"==typeof c&&c||l("bad-app-name",{name:c+""}),o(t,c)&&l("duplicate-app",{name:c});var d=new s(e,a,u);return t[c]=d,p(d,"create"),d},app:c,apps:null,Promise:Promise,SDK_VERSION:"5.5.0",INTERNAL:{registerService:function(e,t,o,i,p){n[e]&&l("duplicate-service",{name:e}),n[e]=t,i&&(a[e]=i,d().forEach(function(e){i("create",e)}));var f=function(t){return void 0===t&&(t=c()),"function"!=typeof t[e]&&l("invalid-app-argument",{name:e}),t[e]()};return void 0!==o&&r.deepExtend(f,o),u[e]=f,s.prototype[e]=function(){for(var t=[],n=0;nP.length&&P.push(e)}function M(e,t,n){return null==e?0:function e(t,n,r,o){var s=typeof t;"undefined"!==s&&"boolean"!==s||(t=null);var l=!1;if(null===t)l=!0;else switch(s){case"string":case"number":l=!0;break;case"object":switch(t.$$typeof){case i:case a:l=!0}}if(l)return r(o,t,""===n?"."+A(t,0):n),1;if(l=0,n=""===n?".":n+":",Array.isArray(t))for(var u=0;uP.length&&P.push(e)}function M(e,t,n){return null==e?0:function e(t,n,r,o){var s=typeof t;"undefined"!==s&&"boolean"!==s||(t=null);var l=!1;if(null===t)l=!0;else switch(s){case"string":case"number":l=!0;break;case"object":switch(t.$$typeof){case i:case a:l=!0}}if(l)return r(o,t,""===n?"."+A(t,0):n),1;if(l=0,n=""===n?".":n+":",Array.isArray(t))for(var u=0;uthis.eventPool.length&&this.eventPool.push(e)}function fe(e){e.eventPool=[],e.getPooled=de,e.release=pe}o(ce.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():"unknown"!=typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=le)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=le)},persist:function(){this.isPersistent=le},isPersistent:ue,destructor:function(){var e,t=this.constructor.Interface;for(e in t)this[e]=null;this.nativeEvent=this._targetInst=this.dispatchConfig=null,this.isPropagationStopped=this.isDefaultPrevented=ue,this._dispatchInstances=this._dispatchListeners=null}}),ce.Interface={type:null,target:null,currentTarget:function(){return null},eventPhase:null,bubbles:null,cancelable:null,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:null,isTrusted:null},ce.extend=function(e){function t(){}function n(){return r.apply(this,arguments)}var r=this;t.prototype=r.prototype;var i=new t;return o(i,n.prototype),n.prototype=i,n.prototype.constructor=n,n.Interface=o({},r.Interface,e),n.extend=r.extend,fe(n),n},fe(ce);var he=ce.extend({data:null}),me=ce.extend({data:null}),ye=[9,13,27,32],ve=G&&"CompositionEvent"in window,ge=null;G&&"documentMode"in document&&(ge=document.documentMode);var be=G&&"TextEvent"in window&&!ge,_e=G&&(!ve||ge&&8=ge),we=String.fromCharCode(32),Ee={beforeInput:{phasedRegistrationNames:{bubbled:"onBeforeInput",captured:"onBeforeInputCapture"},dependencies:["compositionend","keypress","textInput","paste"]},compositionEnd:{phasedRegistrationNames:{bubbled:"onCompositionEnd",captured:"onCompositionEndCapture"},dependencies:"blur compositionend keydown keypress keyup mousedown".split(" ")},compositionStart:{phasedRegistrationNames:{bubbled:"onCompositionStart",captured:"onCompositionStartCapture"},dependencies:"blur compositionstart keydown keypress keyup mousedown".split(" ")},compositionUpdate:{phasedRegistrationNames:{bubbled:"onCompositionUpdate",captured:"onCompositionUpdateCapture"},dependencies:"blur compositionupdate keydown keypress keyup mousedown".split(" ")}},Se=!1;function Te(e,t){switch(e){case"keyup":return-1!==ye.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"blur":return!0;default:return!1}}function ke(e){return"object"==typeof(e=e.detail)&&"data"in e?e.data:null}var Ce=!1;var Oe={eventTypes:Ee,extractEvents:function(e,t,n,r){var o=void 0,i=void 0;if(ve)e:{switch(e){case"compositionstart":o=Ee.compositionStart;break e;case"compositionend":o=Ee.compositionEnd;break e;case"compositionupdate":o=Ee.compositionUpdate;break e}o=void 0}else Ce?Te(e,n)&&(o=Ee.compositionEnd):"keydown"===e&&229===n.keyCode&&(o=Ee.compositionStart);return o?(_e&&"ko"!==n.locale&&(Ce||o!==Ee.compositionStart?o===Ee.compositionEnd&&Ce&&(i=se()):(ie="value"in(oe=r)?oe.value:oe.textContent,Ce=!0)),o=he.getPooled(o,t,n,r),i?o.data=i:null!==(i=ke(n))&&(o.data=i),z(o),i=o):i=null,(e=be?function(e,t){switch(e){case"compositionend":return ke(t);case"keypress":return 32!==t.which?null:(Se=!0,we);case"textInput":return(e=t.data)===we&&Se?null:e;default:return null}}(e,n):function(e,t){if(Ce)return"compositionend"===e||!ve&&Te(e,t)?(e=se(),ae=ie=oe=null,Ce=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1